aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MAINTAINERS8
-rw-r--r--arch/alpha/include/asm/io.h12
-rw-r--r--arch/alpha/include/asm/unistd.h2
-rw-r--r--arch/alpha/include/uapi/asm/unistd.h3
-rw-r--r--arch/alpha/kernel/systbls.S3
-rw-r--r--block/bio-integrity.c2
-rw-r--r--block/blk-core.c1
-rw-r--r--block/blk-mq.c36
-rw-r--r--block/cfq-iosched.c19
-rw-r--r--block/scsi_ioctl.c40
-rw-r--r--drivers/block/brd.c6
-rw-r--r--drivers/block/xsysace.c1
-rw-r--r--drivers/md/dm-crypt.c25
-rw-r--r--drivers/misc/mei/client.c1
-rw-r--r--drivers/misc/mei/nfc.c11
-rw-r--r--drivers/scsi/scsi_lib.c1
-rw-r--r--drivers/staging/Kconfig2
-rw-r--r--drivers/staging/Makefile1
-rw-r--r--drivers/staging/android/logger.c5
-rw-r--r--drivers/staging/et131x/et131x.c68
-rw-r--r--drivers/staging/lustre/lustre/libcfs/workitem.c1
-rw-r--r--drivers/staging/lustre/lustre/obdclass/class_obd.c2
-rw-r--r--drivers/staging/rtl8188eu/os_dep/usb_intf.c2
-rw-r--r--drivers/thunderbolt/path.c21
-rw-r--r--drivers/usb/Kconfig2
-rw-r--r--drivers/usb/Makefile2
-rw-r--r--drivers/usb/core/hub.c16
-rw-r--r--drivers/usb/dwc2/gadget.c2
-rw-r--r--drivers/usb/dwc3/dwc3-omap.c2
-rw-r--r--drivers/usb/gadget/Makefile2
-rw-r--r--drivers/usb/gadget/function/Makefile4
-rw-r--r--drivers/usb/gadget/function/u_ether.c3
-rw-r--r--drivers/usb/gadget/function/uvc_video.c3
-rw-r--r--drivers/usb/gadget/legacy/Makefile6
-rw-r--r--drivers/usb/gadget/legacy/dbgp.c2
-rw-r--r--drivers/usb/gadget/legacy/inode.c2
-rw-r--r--drivers/usb/gadget/udc/Kconfig3
-rw-r--r--drivers/usb/gadget/udc/atmel_usba_udc.c2
-rw-r--r--drivers/usb/gadget/udc/fusb300_udc.c8
-rw-r--r--drivers/usb/gadget/udc/pch_udc.c22
-rw-r--r--drivers/usb/gadget/udc/r8a66597-udc.c4
-rw-r--r--drivers/usb/host/ehci-hub.c2
-rw-r--r--drivers/usb/host/xhci-pci.c9
-rw-r--r--drivers/usb/host/xhci-ring.c104
-rw-r--r--drivers/usb/host/xhci.c3
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c1
-rw-r--r--drivers/usb/musb/ux500_dma.c2
-rw-r--r--drivers/usb/phy/phy-gpio-vbus-usb.c4
-rw-r--r--drivers/usb/phy/phy-msm-usb.c4
-rw-r--r--drivers/usb/phy/phy-samsung-usb.h2
-rw-r--r--drivers/usb/phy/phy.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c3
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h7
-rw-r--r--drivers/usb/serial/option.c31
-rw-r--r--drivers/usb/serial/pl2303.c1
-rw-r--r--drivers/usb/serial/pl2303.h1
-rw-r--r--drivers/usb/serial/usb-serial.c37
-rw-r--r--drivers/usb/serial/whiteheat.c7
-rw-r--r--drivers/usb/serial/zte_ev.c20
-rw-r--r--drivers/usb/storage/unusual_devs.h6
-rw-r--r--drivers/usb/usbip/Kconfig (renamed from drivers/staging/usbip/Kconfig)0
-rw-r--r--drivers/usb/usbip/Makefile (renamed from drivers/staging/usbip/Makefile)0
-rw-r--r--drivers/usb/usbip/README (renamed from drivers/staging/usbip/README)0
-rw-r--r--drivers/usb/usbip/stub.h (renamed from drivers/staging/usbip/stub.h)0
-rw-r--r--drivers/usb/usbip/stub_dev.c (renamed from drivers/staging/usbip/stub_dev.c)27
-rw-r--r--drivers/usb/usbip/stub_main.c (renamed from drivers/staging/usbip/stub_main.c)0
-rw-r--r--drivers/usb/usbip/stub_rx.c (renamed from drivers/staging/usbip/stub_rx.c)0
-rw-r--r--drivers/usb/usbip/stub_tx.c (renamed from drivers/staging/usbip/stub_tx.c)0
-rw-r--r--drivers/usb/usbip/usbip_common.c (renamed from drivers/staging/usbip/usbip_common.c)0
-rw-r--r--drivers/usb/usbip/usbip_common.h (renamed from drivers/staging/usbip/usbip_common.h)2
-rw-r--r--drivers/usb/usbip/usbip_event.c (renamed from drivers/staging/usbip/usbip_event.c)0
-rw-r--r--drivers/usb/usbip/usbip_protocol.txt (renamed from drivers/staging/usbip/usbip_protocol.txt)0
-rw-r--r--drivers/usb/usbip/vhci.h (renamed from drivers/staging/usbip/vhci.h)0
-rw-r--r--drivers/usb/usbip/vhci_hcd.c (renamed from drivers/staging/usbip/vhci_hcd.c)0
-rw-r--r--drivers/usb/usbip/vhci_rx.c (renamed from drivers/staging/usbip/vhci_rx.c)0
-rw-r--r--drivers/usb/usbip/vhci_sysfs.c (renamed from drivers/staging/usbip/vhci_sysfs.c)0
-rw-r--r--drivers/usb/usbip/vhci_tx.c (renamed from drivers/staging/usbip/vhci_tx.c)0
-rw-r--r--drivers/usb/wusbcore/wa-xfer.c3
-rw-r--r--drivers/video/fbdev/amba-clcd.c23
-rw-r--r--drivers/video/fbdev/atmel_lcdfb.c2
-rw-r--r--drivers/video/fbdev/chipsfb.c2
-rw-r--r--drivers/video/fbdev/da8xx-fb.c2
-rw-r--r--drivers/video/of_display_timing.c1
-rw-r--r--fs/ext4/ext4.h18
-rw-r--r--fs/ext4/extents.c88
-rw-r--r--fs/ext4/inode.c44
-rw-r--r--fs/ext4/mballoc.c5
-rw-r--r--fs/ext4/namei.c56
-rw-r--r--fs/ext4/super.c5
-rw-r--r--fs/jbd2/commit.c21
-rw-r--r--fs/jbd2/journal.c56
-rw-r--r--fs/jbd2/recovery.c33
-rw-r--r--fs/jbd2/revoke.c6
-rw-r--r--fs/nfs/nfs3acl.c5
-rw-r--r--fs/nfs/nfs4proc.c26
-rw-r--r--include/linux/blk-mq.h7
-rw-r--r--include/linux/jbd2.h30
-rw-r--r--include/uapi/linux/usbip.h (renamed from drivers/staging/usbip/uapi/usbip.h)0
-rw-r--r--tools/usb/usbip/.gitignore (renamed from drivers/staging/usbip/userspace/.gitignore)0
-rw-r--r--tools/usb/usbip/AUTHORS (renamed from drivers/staging/usbip/userspace/AUTHORS)0
-rw-r--r--tools/usb/usbip/COPYING (renamed from drivers/staging/usbip/userspace/COPYING)0
-rw-r--r--tools/usb/usbip/INSTALL (renamed from drivers/staging/usbip/userspace/INSTALL)0
-rw-r--r--tools/usb/usbip/Makefile.am (renamed from drivers/staging/usbip/userspace/Makefile.am)0
-rw-r--r--tools/usb/usbip/README (renamed from drivers/staging/usbip/userspace/README)0
-rwxr-xr-xtools/usb/usbip/autogen.sh (renamed from drivers/staging/usbip/userspace/autogen.sh)0
-rwxr-xr-xtools/usb/usbip/cleanup.sh (renamed from drivers/staging/usbip/userspace/cleanup.sh)0
-rw-r--r--tools/usb/usbip/configure.ac (renamed from drivers/staging/usbip/userspace/configure.ac)0
-rw-r--r--tools/usb/usbip/doc/usbip.8 (renamed from drivers/staging/usbip/userspace/doc/usbip.8)0
-rw-r--r--tools/usb/usbip/doc/usbipd.8 (renamed from drivers/staging/usbip/userspace/doc/usbipd.8)0
-rw-r--r--tools/usb/usbip/libsrc/Makefile.am (renamed from drivers/staging/usbip/userspace/libsrc/Makefile.am)0
-rw-r--r--tools/usb/usbip/libsrc/list.h (renamed from drivers/staging/usbip/userspace/libsrc/list.h)0
-rw-r--r--tools/usb/usbip/libsrc/names.c (renamed from drivers/staging/usbip/userspace/libsrc/names.c)0
-rw-r--r--tools/usb/usbip/libsrc/names.h (renamed from drivers/staging/usbip/userspace/libsrc/names.h)0
-rw-r--r--tools/usb/usbip/libsrc/sysfs_utils.c (renamed from drivers/staging/usbip/userspace/libsrc/sysfs_utils.c)0
-rw-r--r--tools/usb/usbip/libsrc/sysfs_utils.h (renamed from drivers/staging/usbip/userspace/libsrc/sysfs_utils.h)0
-rw-r--r--tools/usb/usbip/libsrc/usbip_common.c (renamed from drivers/staging/usbip/userspace/libsrc/usbip_common.c)0
-rw-r--r--tools/usb/usbip/libsrc/usbip_common.h (renamed from drivers/staging/usbip/userspace/libsrc/usbip_common.h)0
-rw-r--r--tools/usb/usbip/libsrc/usbip_host_driver.c (renamed from drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c)0
-rw-r--r--tools/usb/usbip/libsrc/usbip_host_driver.h (renamed from drivers/staging/usbip/userspace/libsrc/usbip_host_driver.h)0
-rw-r--r--tools/usb/usbip/libsrc/vhci_driver.c (renamed from drivers/staging/usbip/userspace/libsrc/vhci_driver.c)0
-rw-r--r--tools/usb/usbip/libsrc/vhci_driver.h (renamed from drivers/staging/usbip/userspace/libsrc/vhci_driver.h)0
-rw-r--r--tools/usb/usbip/src/Makefile.am (renamed from drivers/staging/usbip/userspace/src/Makefile.am)0
-rw-r--r--tools/usb/usbip/src/usbip.c (renamed from drivers/staging/usbip/userspace/src/usbip.c)0
-rw-r--r--tools/usb/usbip/src/usbip.h (renamed from drivers/staging/usbip/userspace/src/usbip.h)0
-rw-r--r--tools/usb/usbip/src/usbip_attach.c (renamed from drivers/staging/usbip/userspace/src/usbip_attach.c)0
-rw-r--r--tools/usb/usbip/src/usbip_bind.c (renamed from drivers/staging/usbip/userspace/src/usbip_bind.c)0
-rw-r--r--tools/usb/usbip/src/usbip_detach.c (renamed from drivers/staging/usbip/userspace/src/usbip_detach.c)0
-rw-r--r--tools/usb/usbip/src/usbip_list.c (renamed from drivers/staging/usbip/userspace/src/usbip_list.c)0
-rw-r--r--tools/usb/usbip/src/usbip_network.c (renamed from drivers/staging/usbip/userspace/src/usbip_network.c)0
-rw-r--r--tools/usb/usbip/src/usbip_network.h (renamed from drivers/staging/usbip/userspace/src/usbip_network.h)0
-rw-r--r--tools/usb/usbip/src/usbip_port.c (renamed from drivers/staging/usbip/userspace/src/usbip_port.c)0
-rw-r--r--tools/usb/usbip/src/usbip_unbind.c (renamed from drivers/staging/usbip/userspace/src/usbip_unbind.c)0
-rw-r--r--tools/usb/usbip/src/usbipd.c (renamed from drivers/staging/usbip/userspace/src/usbipd.c)0
-rw-r--r--tools/usb/usbip/src/utils.c (renamed from drivers/staging/usbip/userspace/src/utils.c)0
-rw-r--r--tools/usb/usbip/src/utils.h (renamed from drivers/staging/usbip/userspace/src/utils.h)0
135 files changed, 656 insertions, 411 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 1ff06dee651d..217dc542e808 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9557,6 +9557,14 @@ S: Maintained
9557F: Documentation/usb/ohci.txt 9557F: Documentation/usb/ohci.txt
9558F: drivers/usb/host/ohci* 9558F: drivers/usb/host/ohci*
9559 9559
9560USB OVER IP DRIVER
9561M: Valentina Manea <valentina.manea.m@gmail.com>
9562M: Shuah Khan <shuah.kh@samsung.com>
9563L: linux-usb@vger.kernel.org
9564S: Maintained
9565F: drivers/usb/usbip/
9566F: tools/usb/usbip/
9567
9560USB PEGASUS DRIVER 9568USB PEGASUS DRIVER
9561M: Petko Manolov <petkan@nucleusys.com> 9569M: Petko Manolov <petkan@nucleusys.com>
9562L: linux-usb@vger.kernel.org 9570L: linux-usb@vger.kernel.org
diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
index 5ebab5895edb..f05bdb4b1cb9 100644
--- a/arch/alpha/include/asm/io.h
+++ b/arch/alpha/include/asm/io.h
@@ -500,10 +500,14 @@ extern inline void writeq(u64 b, volatile void __iomem *addr)
500#define outb_p outb 500#define outb_p outb
501#define outw_p outw 501#define outw_p outw
502#define outl_p outl 502#define outl_p outl
503#define readb_relaxed(addr) __raw_readb(addr) 503#define readb_relaxed(addr) __raw_readb(addr)
504#define readw_relaxed(addr) __raw_readw(addr) 504#define readw_relaxed(addr) __raw_readw(addr)
505#define readl_relaxed(addr) __raw_readl(addr) 505#define readl_relaxed(addr) __raw_readl(addr)
506#define readq_relaxed(addr) __raw_readq(addr) 506#define readq_relaxed(addr) __raw_readq(addr)
507#define writeb_relaxed(b, addr) __raw_writeb(b, addr)
508#define writew_relaxed(b, addr) __raw_writew(b, addr)
509#define writel_relaxed(b, addr) __raw_writel(b, addr)
510#define writeq_relaxed(b, addr) __raw_writeq(b, addr)
507 511
508#define mmiowb() 512#define mmiowb()
509 513
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h
index f2c94402e2c8..c509d306db45 100644
--- a/arch/alpha/include/asm/unistd.h
+++ b/arch/alpha/include/asm/unistd.h
@@ -3,7 +3,7 @@
3 3
4#include <uapi/asm/unistd.h> 4#include <uapi/asm/unistd.h>
5 5
6#define NR_SYSCALLS 508 6#define NR_SYSCALLS 511
7 7
8#define __ARCH_WANT_OLD_READDIR 8#define __ARCH_WANT_OLD_READDIR
9#define __ARCH_WANT_STAT64 9#define __ARCH_WANT_STAT64
diff --git a/arch/alpha/include/uapi/asm/unistd.h b/arch/alpha/include/uapi/asm/unistd.h
index 53ae7bb1bfd1..d214a0358100 100644
--- a/arch/alpha/include/uapi/asm/unistd.h
+++ b/arch/alpha/include/uapi/asm/unistd.h
@@ -469,5 +469,8 @@
469#define __NR_process_vm_writev 505 469#define __NR_process_vm_writev 505
470#define __NR_kcmp 506 470#define __NR_kcmp 506
471#define __NR_finit_module 507 471#define __NR_finit_module 507
472#define __NR_sched_setattr 508
473#define __NR_sched_getattr 509
474#define __NR_renameat2 510
472 475
473#endif /* _UAPI_ALPHA_UNISTD_H */ 476#endif /* _UAPI_ALPHA_UNISTD_H */
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index dca9b3fb0071..24789713f1ea 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -526,6 +526,9 @@ sys_call_table:
526 .quad sys_process_vm_writev /* 505 */ 526 .quad sys_process_vm_writev /* 505 */
527 .quad sys_kcmp 527 .quad sys_kcmp
528 .quad sys_finit_module 528 .quad sys_finit_module
529 .quad sys_sched_setattr
530 .quad sys_sched_getattr
531 .quad sys_renameat2 /* 510 */
529 532
530 .size sys_call_table, . - sys_call_table 533 .size sys_call_table, . - sys_call_table
531 .type sys_call_table, @object 534 .type sys_call_table, @object
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index bc423f7b02da..f14b4abbebd8 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -520,7 +520,7 @@ void bio_integrity_endio(struct bio *bio, int error)
520 */ 520 */
521 if (error) { 521 if (error) {
522 bio->bi_end_io = bip->bip_end_io; 522 bio->bi_end_io = bip->bip_end_io;
523 bio_endio(bio, error); 523 bio_endio_nodec(bio, error);
524 524
525 return; 525 return;
526 } 526 }
diff --git a/block/blk-core.c b/block/blk-core.c
index c359d72e9d76..bf930f481d43 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1252,7 +1252,6 @@ void blk_rq_set_block_pc(struct request *rq)
1252 rq->__sector = (sector_t) -1; 1252 rq->__sector = (sector_t) -1;
1253 rq->bio = rq->biotail = NULL; 1253 rq->bio = rq->biotail = NULL;
1254 memset(rq->__cmd, 0, sizeof(rq->__cmd)); 1254 memset(rq->__cmd, 0, sizeof(rq->__cmd));
1255 rq->cmd = rq->__cmd;
1256} 1255}
1257EXPORT_SYMBOL(blk_rq_set_block_pc); 1256EXPORT_SYMBOL(blk_rq_set_block_pc);
1258 1257
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 5189cb1e478a..4aac82615a46 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -112,18 +112,22 @@ static void blk_mq_usage_counter_release(struct percpu_ref *ref)
112 */ 112 */
113void blk_mq_freeze_queue(struct request_queue *q) 113void blk_mq_freeze_queue(struct request_queue *q)
114{ 114{
115 bool freeze;
116
115 spin_lock_irq(q->queue_lock); 117 spin_lock_irq(q->queue_lock);
116 q->mq_freeze_depth++; 118 freeze = !q->mq_freeze_depth++;
117 spin_unlock_irq(q->queue_lock); 119 spin_unlock_irq(q->queue_lock);
118 120
119 percpu_ref_kill(&q->mq_usage_counter); 121 if (freeze) {
120 blk_mq_run_queues(q, false); 122 percpu_ref_kill(&q->mq_usage_counter);
123 blk_mq_run_queues(q, false);
124 }
121 wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->mq_usage_counter)); 125 wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->mq_usage_counter));
122} 126}
123 127
124static void blk_mq_unfreeze_queue(struct request_queue *q) 128static void blk_mq_unfreeze_queue(struct request_queue *q)
125{ 129{
126 bool wake = false; 130 bool wake;
127 131
128 spin_lock_irq(q->queue_lock); 132 spin_lock_irq(q->queue_lock);
129 wake = !--q->mq_freeze_depth; 133 wake = !--q->mq_freeze_depth;
@@ -172,6 +176,8 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
172 /* tag was already set */ 176 /* tag was already set */
173 rq->errors = 0; 177 rq->errors = 0;
174 178
179 rq->cmd = rq->__cmd;
180
175 rq->extra_len = 0; 181 rq->extra_len = 0;
176 rq->sense_len = 0; 182 rq->sense_len = 0;
177 rq->resid_len = 0; 183 rq->resid_len = 0;
@@ -1068,13 +1074,17 @@ static void blk_mq_bio_to_request(struct request *rq, struct bio *bio)
1068 blk_account_io_start(rq, 1); 1074 blk_account_io_start(rq, 1);
1069} 1075}
1070 1076
1077static inline bool hctx_allow_merges(struct blk_mq_hw_ctx *hctx)
1078{
1079 return (hctx->flags & BLK_MQ_F_SHOULD_MERGE) &&
1080 !blk_queue_nomerges(hctx->queue);
1081}
1082
1071static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx, 1083static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx,
1072 struct blk_mq_ctx *ctx, 1084 struct blk_mq_ctx *ctx,
1073 struct request *rq, struct bio *bio) 1085 struct request *rq, struct bio *bio)
1074{ 1086{
1075 struct request_queue *q = hctx->queue; 1087 if (!hctx_allow_merges(hctx)) {
1076
1077 if (!(hctx->flags & BLK_MQ_F_SHOULD_MERGE)) {
1078 blk_mq_bio_to_request(rq, bio); 1088 blk_mq_bio_to_request(rq, bio);
1079 spin_lock(&ctx->lock); 1089 spin_lock(&ctx->lock);
1080insert_rq: 1090insert_rq:
@@ -1082,6 +1092,8 @@ insert_rq:
1082 spin_unlock(&ctx->lock); 1092 spin_unlock(&ctx->lock);
1083 return false; 1093 return false;
1084 } else { 1094 } else {
1095 struct request_queue *q = hctx->queue;
1096
1085 spin_lock(&ctx->lock); 1097 spin_lock(&ctx->lock);
1086 if (!blk_mq_attempt_merge(q, ctx, bio)) { 1098 if (!blk_mq_attempt_merge(q, ctx, bio)) {
1087 blk_mq_bio_to_request(rq, bio); 1099 blk_mq_bio_to_request(rq, bio);
@@ -1574,7 +1586,7 @@ static int blk_mq_init_hw_queues(struct request_queue *q,
1574 hctx->tags = set->tags[i]; 1586 hctx->tags = set->tags[i];
1575 1587
1576 /* 1588 /*
1577 * Allocate space for all possible cpus to avoid allocation in 1589 * Allocate space for all possible cpus to avoid allocation at
1578 * runtime 1590 * runtime
1579 */ 1591 */
1580 hctx->ctxs = kmalloc_node(nr_cpu_ids * sizeof(void *), 1592 hctx->ctxs = kmalloc_node(nr_cpu_ids * sizeof(void *),
@@ -1662,8 +1674,8 @@ static void blk_mq_map_swqueue(struct request_queue *q)
1662 1674
1663 queue_for_each_hw_ctx(q, hctx, i) { 1675 queue_for_each_hw_ctx(q, hctx, i) {
1664 /* 1676 /*
1665 * If not software queues are mapped to this hardware queue, 1677 * If no software queues are mapped to this hardware queue,
1666 * disable it and free the request entries 1678 * disable it and free the request entries.
1667 */ 1679 */
1668 if (!hctx->nr_ctx) { 1680 if (!hctx->nr_ctx) {
1669 struct blk_mq_tag_set *set = q->tag_set; 1681 struct blk_mq_tag_set *set = q->tag_set;
@@ -1713,14 +1725,10 @@ static void blk_mq_del_queue_tag_set(struct request_queue *q)
1713{ 1725{
1714 struct blk_mq_tag_set *set = q->tag_set; 1726 struct blk_mq_tag_set *set = q->tag_set;
1715 1727
1716 blk_mq_freeze_queue(q);
1717
1718 mutex_lock(&set->tag_list_lock); 1728 mutex_lock(&set->tag_list_lock);
1719 list_del_init(&q->tag_set_list); 1729 list_del_init(&q->tag_set_list);
1720 blk_mq_update_tag_set_depth(set); 1730 blk_mq_update_tag_set_depth(set);
1721 mutex_unlock(&set->tag_list_lock); 1731 mutex_unlock(&set->tag_list_lock);
1722
1723 blk_mq_unfreeze_queue(q);
1724} 1732}
1725 1733
1726static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set, 1734static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set,
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index cadc37841744..3f31cf9508e6 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1272,15 +1272,22 @@ __cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg)
1272 rb_insert_color(&cfqg->rb_node, &st->rb); 1272 rb_insert_color(&cfqg->rb_node, &st->rb);
1273} 1273}
1274 1274
1275/*
1276 * This has to be called only on activation of cfqg
1277 */
1275static void 1278static void
1276cfq_update_group_weight(struct cfq_group *cfqg) 1279cfq_update_group_weight(struct cfq_group *cfqg)
1277{ 1280{
1278 BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node));
1279
1280 if (cfqg->new_weight) { 1281 if (cfqg->new_weight) {
1281 cfqg->weight = cfqg->new_weight; 1282 cfqg->weight = cfqg->new_weight;
1282 cfqg->new_weight = 0; 1283 cfqg->new_weight = 0;
1283 } 1284 }
1285}
1286
1287static void
1288cfq_update_group_leaf_weight(struct cfq_group *cfqg)
1289{
1290 BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node));
1284 1291
1285 if (cfqg->new_leaf_weight) { 1292 if (cfqg->new_leaf_weight) {
1286 cfqg->leaf_weight = cfqg->new_leaf_weight; 1293 cfqg->leaf_weight = cfqg->new_leaf_weight;
@@ -1299,7 +1306,12 @@ cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg)
1299 /* add to the service tree */ 1306 /* add to the service tree */
1300 BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node)); 1307 BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node));
1301 1308
1302 cfq_update_group_weight(cfqg); 1309 /*
1310 * Update leaf_weight. We cannot update weight at this point
1311 * because cfqg might already have been activated and is
1312 * contributing its current weight to the parent's child_weight.
1313 */
1314 cfq_update_group_leaf_weight(cfqg);
1303 __cfq_group_service_tree_add(st, cfqg); 1315 __cfq_group_service_tree_add(st, cfqg);
1304 1316
1305 /* 1317 /*
@@ -1323,6 +1335,7 @@ cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg)
1323 */ 1335 */
1324 while ((parent = cfqg_parent(pos))) { 1336 while ((parent = cfqg_parent(pos))) {
1325 if (propagate) { 1337 if (propagate) {
1338 cfq_update_group_weight(pos);
1326 propagate = !parent->nr_active++; 1339 propagate = !parent->nr_active++;
1327 parent->children_weight += pos->weight; 1340 parent->children_weight += pos->weight;
1328 } 1341 }
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 51bf5155ee75..9b8eaeca6a79 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -279,7 +279,6 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
279 r = blk_rq_unmap_user(bio); 279 r = blk_rq_unmap_user(bio);
280 if (!ret) 280 if (!ret)
281 ret = r; 281 ret = r;
282 blk_put_request(rq);
283 282
284 return ret; 283 return ret;
285} 284}
@@ -297,8 +296,6 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
297 296
298 if (hdr->interface_id != 'S') 297 if (hdr->interface_id != 'S')
299 return -EINVAL; 298 return -EINVAL;
300 if (hdr->cmd_len > BLK_MAX_CDB)
301 return -EINVAL;
302 299
303 if (hdr->dxfer_len > (queue_max_hw_sectors(q) << 9)) 300 if (hdr->dxfer_len > (queue_max_hw_sectors(q) << 9))
304 return -EIO; 301 return -EIO;
@@ -317,16 +314,23 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
317 if (hdr->flags & SG_FLAG_Q_AT_HEAD) 314 if (hdr->flags & SG_FLAG_Q_AT_HEAD)
318 at_head = 1; 315 at_head = 1;
319 316
317 ret = -ENOMEM;
320 rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL); 318 rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL);
321 if (!rq) 319 if (!rq)
322 return -ENOMEM; 320 goto out;
323 blk_rq_set_block_pc(rq); 321 blk_rq_set_block_pc(rq);
324 322
325 if (blk_fill_sghdr_rq(q, rq, hdr, mode)) { 323 if (hdr->cmd_len > BLK_MAX_CDB) {
326 blk_put_request(rq); 324 rq->cmd = kzalloc(hdr->cmd_len, GFP_KERNEL);
327 return -EFAULT; 325 if (!rq->cmd)
326 goto out_put_request;
328 } 327 }
329 328
329 ret = -EFAULT;
330 if (blk_fill_sghdr_rq(q, rq, hdr, mode))
331 goto out_free_cdb;
332
333 ret = 0;
330 if (hdr->iovec_count) { 334 if (hdr->iovec_count) {
331 size_t iov_data_len; 335 size_t iov_data_len;
332 struct iovec *iov = NULL; 336 struct iovec *iov = NULL;
@@ -335,7 +339,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
335 0, NULL, &iov); 339 0, NULL, &iov);
336 if (ret < 0) { 340 if (ret < 0) {
337 kfree(iov); 341 kfree(iov);
338 goto out; 342 goto out_free_cdb;
339 } 343 }
340 344
341 iov_data_len = ret; 345 iov_data_len = ret;
@@ -358,7 +362,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
358 GFP_KERNEL); 362 GFP_KERNEL);
359 363
360 if (ret) 364 if (ret)
361 goto out; 365 goto out_free_cdb;
362 366
363 bio = rq->bio; 367 bio = rq->bio;
364 memset(sense, 0, sizeof(sense)); 368 memset(sense, 0, sizeof(sense));
@@ -376,9 +380,14 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
376 380
377 hdr->duration = jiffies_to_msecs(jiffies - start_time); 381 hdr->duration = jiffies_to_msecs(jiffies - start_time);
378 382
379 return blk_complete_sghdr_rq(rq, hdr, bio); 383 ret = blk_complete_sghdr_rq(rq, hdr, bio);
380out: 384
385out_free_cdb:
386 if (rq->cmd != rq->__cmd)
387 kfree(rq->cmd);
388out_put_request:
381 blk_put_request(rq); 389 blk_put_request(rq);
390out:
382 return ret; 391 return ret;
383} 392}
384 393
@@ -448,6 +457,11 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
448 } 457 }
449 458
450 rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT); 459 rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT);
460 if (!rq) {
461 err = -ENOMEM;
462 goto error;
463 }
464 blk_rq_set_block_pc(rq);
451 465
452 cmdlen = COMMAND_SIZE(opcode); 466 cmdlen = COMMAND_SIZE(opcode);
453 467
@@ -501,7 +515,6 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
501 memset(sense, 0, sizeof(sense)); 515 memset(sense, 0, sizeof(sense));
502 rq->sense = sense; 516 rq->sense = sense;
503 rq->sense_len = 0; 517 rq->sense_len = 0;
504 blk_rq_set_block_pc(rq);
505 518
506 blk_execute_rq(q, disk, rq, 0); 519 blk_execute_rq(q, disk, rq, 0);
507 520
@@ -521,7 +534,8 @@ out:
521 534
522error: 535error:
523 kfree(buffer); 536 kfree(buffer);
524 blk_put_request(rq); 537 if (rq)
538 blk_put_request(rq);
525 return err; 539 return err;
526} 540}
527EXPORT_SYMBOL_GPL(sg_scsi_ioctl); 541EXPORT_SYMBOL_GPL(sg_scsi_ioctl);
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index c7d138eca731..3598110d2cef 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -442,12 +442,15 @@ static int rd_nr;
442int rd_size = CONFIG_BLK_DEV_RAM_SIZE; 442int rd_size = CONFIG_BLK_DEV_RAM_SIZE;
443static int max_part; 443static int max_part;
444static int part_shift; 444static int part_shift;
445static int part_show = 0;
445module_param(rd_nr, int, S_IRUGO); 446module_param(rd_nr, int, S_IRUGO);
446MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices"); 447MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices");
447module_param(rd_size, int, S_IRUGO); 448module_param(rd_size, int, S_IRUGO);
448MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes."); 449MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");
449module_param(max_part, int, S_IRUGO); 450module_param(max_part, int, S_IRUGO);
450MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk"); 451MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk");
452module_param(part_show, int, S_IRUGO);
453MODULE_PARM_DESC(part_show, "Control RAM disk visibility in /proc/partitions");
451MODULE_LICENSE("GPL"); 454MODULE_LICENSE("GPL");
452MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR); 455MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
453MODULE_ALIAS("rd"); 456MODULE_ALIAS("rd");
@@ -501,7 +504,8 @@ static struct brd_device *brd_alloc(int i)
501 disk->fops = &brd_fops; 504 disk->fops = &brd_fops;
502 disk->private_data = brd; 505 disk->private_data = brd;
503 disk->queue = brd->brd_queue; 506 disk->queue = brd->brd_queue;
504 disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; 507 if (!part_show)
508 disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
505 sprintf(disk->disk_name, "ram%d", i); 509 sprintf(disk->disk_name, "ram%d", i);
506 set_capacity(disk, rd_size * 2); 510 set_capacity(disk, rd_size * 2);
507 511
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index ab3ea62e5dfc..c4328d9d9981 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -1203,7 +1203,6 @@ static struct platform_driver ace_platform_driver = {
1203 .probe = ace_probe, 1203 .probe = ace_probe,
1204 .remove = ace_remove, 1204 .remove = ace_remove,
1205 .driver = { 1205 .driver = {
1206 .owner = THIS_MODULE,
1207 .name = "xsysace", 1206 .name = "xsysace",
1208 .of_match_table = ace_of_match, 1207 .of_match_table = ace_of_match,
1209 }, 1208 },
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 2785007e0e46..cd15e0801228 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1688,6 +1688,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1688 unsigned int key_size, opt_params; 1688 unsigned int key_size, opt_params;
1689 unsigned long long tmpll; 1689 unsigned long long tmpll;
1690 int ret; 1690 int ret;
1691 size_t iv_size_padding;
1691 struct dm_arg_set as; 1692 struct dm_arg_set as;
1692 const char *opt_string; 1693 const char *opt_string;
1693 char dummy; 1694 char dummy;
@@ -1724,20 +1725,32 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1724 1725
1725 cc->dmreq_start = sizeof(struct ablkcipher_request); 1726 cc->dmreq_start = sizeof(struct ablkcipher_request);
1726 cc->dmreq_start += crypto_ablkcipher_reqsize(any_tfm(cc)); 1727 cc->dmreq_start += crypto_ablkcipher_reqsize(any_tfm(cc));
1727 cc->dmreq_start = ALIGN(cc->dmreq_start, crypto_tfm_ctx_alignment()); 1728 cc->dmreq_start = ALIGN(cc->dmreq_start, __alignof__(struct dm_crypt_request));
1728 cc->dmreq_start += crypto_ablkcipher_alignmask(any_tfm(cc)) & 1729
1729 ~(crypto_tfm_ctx_alignment() - 1); 1730 if (crypto_ablkcipher_alignmask(any_tfm(cc)) < CRYPTO_MINALIGN) {
1731 /* Allocate the padding exactly */
1732 iv_size_padding = -(cc->dmreq_start + sizeof(struct dm_crypt_request))
1733 & crypto_ablkcipher_alignmask(any_tfm(cc));
1734 } else {
1735 /*
1736 * If the cipher requires greater alignment than kmalloc
1737 * alignment, we don't know the exact position of the
1738 * initialization vector. We must assume worst case.
1739 */
1740 iv_size_padding = crypto_ablkcipher_alignmask(any_tfm(cc));
1741 }
1730 1742
1731 cc->req_pool = mempool_create_kmalloc_pool(MIN_IOS, cc->dmreq_start + 1743 cc->req_pool = mempool_create_kmalloc_pool(MIN_IOS, cc->dmreq_start +
1732 sizeof(struct dm_crypt_request) + cc->iv_size); 1744 sizeof(struct dm_crypt_request) + iv_size_padding + cc->iv_size);
1733 if (!cc->req_pool) { 1745 if (!cc->req_pool) {
1734 ti->error = "Cannot allocate crypt request mempool"; 1746 ti->error = "Cannot allocate crypt request mempool";
1735 goto bad; 1747 goto bad;
1736 } 1748 }
1737 1749
1738 cc->per_bio_data_size = ti->per_bio_data_size = 1750 cc->per_bio_data_size = ti->per_bio_data_size =
1739 sizeof(struct dm_crypt_io) + cc->dmreq_start + 1751 ALIGN(sizeof(struct dm_crypt_io) + cc->dmreq_start +
1740 sizeof(struct dm_crypt_request) + cc->iv_size; 1752 sizeof(struct dm_crypt_request) + iv_size_padding + cc->iv_size,
1753 ARCH_KMALLOC_MINALIGN);
1741 1754
1742 cc->page_pool = mempool_create_page_pool(MIN_POOL_PAGES, 0); 1755 cc->page_pool = mempool_create_page_pool(MIN_POOL_PAGES, 0);
1743 if (!cc->page_pool) { 1756 if (!cc->page_pool) {
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 324e1de93687..2da05c0e113d 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -601,6 +601,7 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)
601 cl->timer_count = MEI_CONNECT_TIMEOUT; 601 cl->timer_count = MEI_CONNECT_TIMEOUT;
602 list_add_tail(&cb->list, &dev->ctrl_rd_list.list); 602 list_add_tail(&cb->list, &dev->ctrl_rd_list.list);
603 } else { 603 } else {
604 cl->state = MEI_FILE_INITIALIZING;
604 list_add_tail(&cb->list, &dev->ctrl_wr_list.list); 605 list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
605 } 606 }
606 607
diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
index 3095fc514a65..5ccc23bc7690 100644
--- a/drivers/misc/mei/nfc.c
+++ b/drivers/misc/mei/nfc.c
@@ -342,9 +342,10 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
342 ndev = (struct mei_nfc_dev *) cldev->priv_data; 342 ndev = (struct mei_nfc_dev *) cldev->priv_data;
343 dev = ndev->cl->dev; 343 dev = ndev->cl->dev;
344 344
345 err = -ENOMEM;
345 mei_buf = kzalloc(length + MEI_NFC_HEADER_SIZE, GFP_KERNEL); 346 mei_buf = kzalloc(length + MEI_NFC_HEADER_SIZE, GFP_KERNEL);
346 if (!mei_buf) 347 if (!mei_buf)
347 return -ENOMEM; 348 goto out;
348 349
349 hdr = (struct mei_nfc_hci_hdr *) mei_buf; 350 hdr = (struct mei_nfc_hci_hdr *) mei_buf;
350 hdr->cmd = MEI_NFC_CMD_HCI_SEND; 351 hdr->cmd = MEI_NFC_CMD_HCI_SEND;
@@ -354,12 +355,9 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
354 hdr->data_size = length; 355 hdr->data_size = length;
355 356
356 memcpy(mei_buf + MEI_NFC_HEADER_SIZE, buf, length); 357 memcpy(mei_buf + MEI_NFC_HEADER_SIZE, buf, length);
357
358 err = __mei_cl_send(ndev->cl, mei_buf, length + MEI_NFC_HEADER_SIZE); 358 err = __mei_cl_send(ndev->cl, mei_buf, length + MEI_NFC_HEADER_SIZE);
359 if (err < 0) 359 if (err < 0)
360 return err; 360 goto out;
361
362 kfree(mei_buf);
363 361
364 if (!wait_event_interruptible_timeout(ndev->send_wq, 362 if (!wait_event_interruptible_timeout(ndev->send_wq,
365 ndev->recv_req_id == ndev->req_id, HZ)) { 363 ndev->recv_req_id == ndev->req_id, HZ)) {
@@ -368,7 +366,8 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
368 } else { 366 } else {
369 ndev->req_id++; 367 ndev->req_id++;
370 } 368 }
371 369out:
370 kfree(mei_buf);
372 return err; 371 return err;
373} 372}
374 373
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ce62e8798cc8..d837dc180522 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1808,7 +1808,6 @@ static int scsi_mq_prep_fn(struct request *req)
1808 1808
1809 cmd->tag = req->tag; 1809 cmd->tag = req->tag;
1810 1810
1811 req->cmd = req->__cmd;
1812 cmd->cmnd = req->cmd; 1811 cmd->cmnd = req->cmd;
1813 cmd->prot_op = SCSI_PROT_NORMAL; 1812 cmd->prot_op = SCSI_PROT_NORMAL;
1814 1813
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 2c486ea6236b..35b494f5667f 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -28,8 +28,6 @@ source "drivers/staging/et131x/Kconfig"
28 28
29source "drivers/staging/slicoss/Kconfig" 29source "drivers/staging/slicoss/Kconfig"
30 30
31source "drivers/staging/usbip/Kconfig"
32
33source "drivers/staging/wlan-ng/Kconfig" 31source "drivers/staging/wlan-ng/Kconfig"
34 32
35source "drivers/staging/comedi/Kconfig" 33source "drivers/staging/comedi/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 1e1a3a10faf7..e66a5dbd9b02 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -6,7 +6,6 @@ obj-$(CONFIG_STAGING) += staging.o
6obj-y += media/ 6obj-y += media/
7obj-$(CONFIG_ET131X) += et131x/ 7obj-$(CONFIG_ET131X) += et131x/
8obj-$(CONFIG_SLICOSS) += slicoss/ 8obj-$(CONFIG_SLICOSS) += slicoss/
9obj-$(CONFIG_USBIP_CORE) += usbip/
10obj-$(CONFIG_PRISM2_USB) += wlan-ng/ 9obj-$(CONFIG_PRISM2_USB) += wlan-ng/
11obj-$(CONFIG_COMEDI) += comedi/ 10obj-$(CONFIG_COMEDI) += comedi/
12obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/ 11obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/
diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c
index 9b47e66599a3..0bf0d24d12d5 100644
--- a/drivers/staging/android/logger.c
+++ b/drivers/staging/android/logger.c
@@ -790,7 +790,7 @@ static int __init create_log(char *log_name, int size)
790 if (unlikely(ret)) { 790 if (unlikely(ret)) {
791 pr_err("failed to register misc device for log '%s'!\n", 791 pr_err("failed to register misc device for log '%s'!\n",
792 log->misc.name); 792 log->misc.name);
793 goto out_free_log; 793 goto out_free_misc_name;
794 } 794 }
795 795
796 pr_info("created %luK log '%s'\n", 796 pr_info("created %luK log '%s'\n",
@@ -798,6 +798,9 @@ static int __init create_log(char *log_name, int size)
798 798
799 return 0; 799 return 0;
800 800
801out_free_misc_name:
802 kfree(log->misc.name);
803
801out_free_log: 804out_free_log:
802 kfree(log); 805 kfree(log);
803 806
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index 8bf1eb485163..831b7c6fe494 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -1421,22 +1421,16 @@ static int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value)
1421 * @reg: the register to read 1421 * @reg: the register to read
1422 * @value: 16-bit value to write 1422 * @value: 16-bit value to write
1423 */ 1423 */
1424static int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value) 1424static int et131x_mii_write(struct et131x_adapter *adapter, u8 addr, u8 reg,
1425 u16 value)
1425{ 1426{
1426 struct mac_regs __iomem *mac = &adapter->regs->mac; 1427 struct mac_regs __iomem *mac = &adapter->regs->mac;
1427 struct phy_device *phydev = adapter->phydev;
1428 int status = 0; 1428 int status = 0;
1429 u8 addr;
1430 u32 delay = 0; 1429 u32 delay = 0;
1431 u32 mii_addr; 1430 u32 mii_addr;
1432 u32 mii_cmd; 1431 u32 mii_cmd;
1433 u32 mii_indicator; 1432 u32 mii_indicator;
1434 1433
1435 if (!phydev)
1436 return -EIO;
1437
1438 addr = phydev->addr;
1439
1440 /* Save a local copy of the registers we are dealing with so we can 1434 /* Save a local copy of the registers we are dealing with so we can
1441 * set them back 1435 * set them back
1442 */ 1436 */
@@ -1631,17 +1625,7 @@ static int et131x_mdio_write(struct mii_bus *bus, int phy_addr,
1631 struct net_device *netdev = bus->priv; 1625 struct net_device *netdev = bus->priv;
1632 struct et131x_adapter *adapter = netdev_priv(netdev); 1626 struct et131x_adapter *adapter = netdev_priv(netdev);
1633 1627
1634 return et131x_mii_write(adapter, reg, value); 1628 return et131x_mii_write(adapter, phy_addr, reg, value);
1635}
1636
1637static int et131x_mdio_reset(struct mii_bus *bus)
1638{
1639 struct net_device *netdev = bus->priv;
1640 struct et131x_adapter *adapter = netdev_priv(netdev);
1641
1642 et131x_mii_write(adapter, MII_BMCR, BMCR_RESET);
1643
1644 return 0;
1645} 1629}
1646 1630
1647/* et1310_phy_power_switch - PHY power control 1631/* et1310_phy_power_switch - PHY power control
@@ -1656,18 +1640,20 @@ static int et131x_mdio_reset(struct mii_bus *bus)
1656static void et1310_phy_power_switch(struct et131x_adapter *adapter, bool down) 1640static void et1310_phy_power_switch(struct et131x_adapter *adapter, bool down)
1657{ 1641{
1658 u16 data; 1642 u16 data;
1643 struct phy_device *phydev = adapter->phydev;
1659 1644
1660 et131x_mii_read(adapter, MII_BMCR, &data); 1645 et131x_mii_read(adapter, MII_BMCR, &data);
1661 data &= ~BMCR_PDOWN; 1646 data &= ~BMCR_PDOWN;
1662 if (down) 1647 if (down)
1663 data |= BMCR_PDOWN; 1648 data |= BMCR_PDOWN;
1664 et131x_mii_write(adapter, MII_BMCR, data); 1649 et131x_mii_write(adapter, phydev->addr, MII_BMCR, data);
1665} 1650}
1666 1651
1667/* et131x_xcvr_init - Init the phy if we are setting it into force mode */ 1652/* et131x_xcvr_init - Init the phy if we are setting it into force mode */
1668static void et131x_xcvr_init(struct et131x_adapter *adapter) 1653static void et131x_xcvr_init(struct et131x_adapter *adapter)
1669{ 1654{
1670 u16 lcr2; 1655 u16 lcr2;
1656 struct phy_device *phydev = adapter->phydev;
1671 1657
1672 /* Set the LED behavior such that LED 1 indicates speed (off = 1658 /* Set the LED behavior such that LED 1 indicates speed (off =
1673 * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates 1659 * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates
@@ -1688,7 +1674,7 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter)
1688 else 1674 else
1689 lcr2 |= (LED_VAL_LINKON << LED_TXRX_SHIFT); 1675 lcr2 |= (LED_VAL_LINKON << LED_TXRX_SHIFT);
1690 1676
1691 et131x_mii_write(adapter, PHY_LED_2, lcr2); 1677 et131x_mii_write(adapter, phydev->addr, PHY_LED_2, lcr2);
1692 } 1678 }
1693} 1679}
1694 1680
@@ -3643,14 +3629,14 @@ static void et131x_adjust_link(struct net_device *netdev)
3643 3629
3644 et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, 3630 et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
3645 &register18); 3631 &register18);
3646 et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 3632 et131x_mii_write(adapter, phydev->addr,
3647 register18 | 0x4); 3633 PHY_MPHY_CONTROL_REG, register18 | 0x4);
3648 et131x_mii_write(adapter, PHY_INDEX_REG, 3634 et131x_mii_write(adapter, phydev->addr, PHY_INDEX_REG,
3649 register18 | 0x8402); 3635 register18 | 0x8402);
3650 et131x_mii_write(adapter, PHY_DATA_REG, 3636 et131x_mii_write(adapter, phydev->addr, PHY_DATA_REG,
3651 register18 | 511); 3637 register18 | 511);
3652 et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 3638 et131x_mii_write(adapter, phydev->addr,
3653 register18); 3639 PHY_MPHY_CONTROL_REG, register18);
3654 } 3640 }
3655 3641
3656 et1310_config_flow_control(adapter); 3642 et1310_config_flow_control(adapter);
@@ -3662,7 +3648,8 @@ static void et131x_adjust_link(struct net_device *netdev)
3662 et131x_mii_read(adapter, PHY_CONFIG, &reg); 3648 et131x_mii_read(adapter, PHY_CONFIG, &reg);
3663 reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH; 3649 reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH;
3664 reg |= ET_PHY_CONFIG_FIFO_DEPTH_32; 3650 reg |= ET_PHY_CONFIG_FIFO_DEPTH_32;
3665 et131x_mii_write(adapter, PHY_CONFIG, reg); 3651 et131x_mii_write(adapter, phydev->addr, PHY_CONFIG,
3652 reg);
3666 } 3653 }
3667 3654
3668 et131x_set_rx_dma_timer(adapter); 3655 et131x_set_rx_dma_timer(adapter);
@@ -3675,14 +3662,14 @@ static void et131x_adjust_link(struct net_device *netdev)
3675 3662
3676 et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, 3663 et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
3677 &register18); 3664 &register18);
3678 et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 3665 et131x_mii_write(adapter, phydev->addr,
3679 register18 | 0x4); 3666 PHY_MPHY_CONTROL_REG, register18 | 0x4);
3680 et131x_mii_write(adapter, PHY_INDEX_REG, 3667 et131x_mii_write(adapter, phydev->addr,
3681 register18 | 0x8402); 3668 PHY_INDEX_REG, register18 | 0x8402);
3682 et131x_mii_write(adapter, PHY_DATA_REG, 3669 et131x_mii_write(adapter, phydev->addr,
3683 register18 | 511); 3670 PHY_DATA_REG, register18 | 511);
3684 et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG, 3671 et131x_mii_write(adapter, phydev->addr,
3685 register18); 3672 PHY_MPHY_CONTROL_REG, register18);
3686 } 3673 }
3687 3674
3688 /* Free the packets being actively sent & stopped */ 3675 /* Free the packets being actively sent & stopped */
@@ -4644,10 +4631,6 @@ static int et131x_pci_setup(struct pci_dev *pdev,
4644 /* Copy address into the net_device struct */ 4631 /* Copy address into the net_device struct */
4645 memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN); 4632 memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN);
4646 4633
4647 /* Init variable for counting how long we do not have link status */
4648 adapter->boot_coma = 0;
4649 et1310_disable_phy_coma(adapter);
4650
4651 rc = -ENOMEM; 4634 rc = -ENOMEM;
4652 4635
4653 /* Setup the mii_bus struct */ 4636 /* Setup the mii_bus struct */
@@ -4663,7 +4646,6 @@ static int et131x_pci_setup(struct pci_dev *pdev,
4663 adapter->mii_bus->priv = netdev; 4646 adapter->mii_bus->priv = netdev;
4664 adapter->mii_bus->read = et131x_mdio_read; 4647 adapter->mii_bus->read = et131x_mdio_read;
4665 adapter->mii_bus->write = et131x_mdio_write; 4648 adapter->mii_bus->write = et131x_mdio_write;
4666 adapter->mii_bus->reset = et131x_mdio_reset;
4667 adapter->mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int), 4649 adapter->mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int),
4668 GFP_KERNEL); 4650 GFP_KERNEL);
4669 if (!adapter->mii_bus->irq) 4651 if (!adapter->mii_bus->irq)
@@ -4687,6 +4669,10 @@ static int et131x_pci_setup(struct pci_dev *pdev,
4687 /* Setup et1310 as per the documentation */ 4669 /* Setup et1310 as per the documentation */
4688 et131x_adapter_setup(adapter); 4670 et131x_adapter_setup(adapter);
4689 4671
4672 /* Init variable for counting how long we do not have link status */
4673 adapter->boot_coma = 0;
4674 et1310_disable_phy_coma(adapter);
4675
4690 /* We can enable interrupts now 4676 /* We can enable interrupts now
4691 * 4677 *
4692 * NOTE - Because registration of interrupt handler is done in the 4678 * NOTE - Because registration of interrupt handler is done in the
diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c
index 65629579bd7d..03ab9e046784 100644
--- a/drivers/staging/lustre/lustre/libcfs/workitem.c
+++ b/drivers/staging/lustre/lustre/libcfs/workitem.c
@@ -365,6 +365,7 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab,
365 return -ENOMEM; 365 return -ENOMEM;
366 366
367 strncpy(sched->ws_name, name, CFS_WS_NAME_LEN); 367 strncpy(sched->ws_name, name, CFS_WS_NAME_LEN);
368 sched->ws_name[CFS_WS_NAME_LEN - 1] = '\0';
368 sched->ws_cptab = cptab; 369 sched->ws_cptab = cptab;
369 sched->ws_cpt = cpt; 370 sched->ws_cpt = cpt;
370 371
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index 8b19f3caa68f..701c6a776524 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#define DEBUG_SUBSYSTEM S_CLASS 37#define DEBUG_SUBSYSTEM S_CLASS
38# include <asm/atomic.h> 38# include <linux/atomic.h>
39 39
40#include "../include/obd_support.h" 40#include "../include/obd_support.h"
41#include "../include/obd_class.h" 41#include "../include/obd_class.h"
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index b8676ac77b0c..407a318b09db 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -43,9 +43,11 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
43 {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */ 43 {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */
44 /*=== Customer ID ===*/ 44 /*=== Customer ID ===*/
45 /****** 8188EUS ********/ 45 /****** 8188EUS ********/
46 {USB_DEVICE(0x056e, 0x4008)}, /* Elecom WDC-150SU2M */
46 {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */ 47 {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */
47 {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ 48 {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
48 {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ 49 {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
50 {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
49 {} /* Terminating entry */ 51 {} /* Terminating entry */
50}; 52};
51 53
diff --git a/drivers/thunderbolt/path.c b/drivers/thunderbolt/path.c
index 8fcf8a7b6c22..9562cd026dc0 100644
--- a/drivers/thunderbolt/path.c
+++ b/drivers/thunderbolt/path.c
@@ -150,7 +150,26 @@ int tb_path_activate(struct tb_path *path)
150 150
151 /* Activate hops. */ 151 /* Activate hops. */
152 for (i = path->path_length - 1; i >= 0; i--) { 152 for (i = path->path_length - 1; i >= 0; i--) {
153 struct tb_regs_hop hop; 153 struct tb_regs_hop hop = { 0 };
154
155 /*
156 * We do (currently) not tear down paths setup by the firmeware.
157 * If a firmware device is unplugged and plugged in again then
158 * it can happen that we reuse some of the hops from the (now
159 * defunct) firmeware path. This causes the hotplug operation to
160 * fail (the pci device does not show up). Clearing the hop
161 * before overwriting it fixes the problem.
162 *
163 * Should be removed once we discover and tear down firmeware
164 * paths.
165 */
166 res = tb_port_write(path->hops[i].in_port, &hop, TB_CFG_HOPS,
167 2 * path->hops[i].in_hop_index, 2);
168 if (res) {
169 __tb_path_deactivate_hops(path, i);
170 __tb_path_deallocate_nfc(path, 0);
171 goto err;
172 }
154 173
155 /* dword 0 */ 174 /* dword 0 */
156 hop.next_hop = path->hops[i].next_hop_index; 175 hop.next_hop = path->hops[i].next_hop_index;
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index e0cad4418085..cf1b19bca306 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -92,6 +92,8 @@ source "drivers/usb/storage/Kconfig"
92 92
93source "drivers/usb/image/Kconfig" 93source "drivers/usb/image/Kconfig"
94 94
95source "drivers/usb/usbip/Kconfig"
96
95endif 97endif
96 98
97source "drivers/usb/musb/Kconfig" 99source "drivers/usb/musb/Kconfig"
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 3cba892b83a2..d7be71778059 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -60,3 +60,5 @@ obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs/
60obj-$(CONFIG_USB_GADGET) += gadget/ 60obj-$(CONFIG_USB_GADGET) += gadget/
61 61
62obj-$(CONFIG_USB_COMMON) += common/ 62obj-$(CONFIG_USB_COMMON) += common/
63
64obj-$(CONFIG_USBIP_CORE) += usbip/
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 8a4dcbc7a75f..46f5161c7891 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1728,8 +1728,14 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
1728 * - Change autosuspend delay of hub can avoid unnecessary auto 1728 * - Change autosuspend delay of hub can avoid unnecessary auto
1729 * suspend timer for hub, also may decrease power consumption 1729 * suspend timer for hub, also may decrease power consumption
1730 * of USB bus. 1730 * of USB bus.
1731 *
1732 * - If user has indicated to prevent autosuspend by passing
1733 * usbcore.autosuspend = -1 then keep autosuspend disabled.
1731 */ 1734 */
1732 pm_runtime_set_autosuspend_delay(&hdev->dev, 0); 1735#ifdef CONFIG_PM_RUNTIME
1736 if (hdev->dev.power.autosuspend_delay >= 0)
1737 pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
1738#endif
1733 1739
1734 /* 1740 /*
1735 * Hubs have proper suspend/resume support, except for root hubs 1741 * Hubs have proper suspend/resume support, except for root hubs
@@ -2107,8 +2113,8 @@ void usb_disconnect(struct usb_device **pdev)
2107{ 2113{
2108 struct usb_port *port_dev = NULL; 2114 struct usb_port *port_dev = NULL;
2109 struct usb_device *udev = *pdev; 2115 struct usb_device *udev = *pdev;
2110 struct usb_hub *hub; 2116 struct usb_hub *hub = NULL;
2111 int port1; 2117 int port1 = 1;
2112 2118
2113 /* mark the device as inactive, so any further urb submissions for 2119 /* mark the device as inactive, so any further urb submissions for
2114 * this device (and any of its children) will fail immediately. 2120 * this device (and any of its children) will fail immediately.
@@ -4631,9 +4637,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
4631 if (status != -ENODEV && 4637 if (status != -ENODEV &&
4632 port1 != unreliable_port && 4638 port1 != unreliable_port &&
4633 printk_ratelimit()) 4639 printk_ratelimit())
4634 dev_err(&udev->dev, "connect-debounce failed, port %d disabled\n", 4640 dev_err(&port_dev->dev, "connect-debounce failed\n");
4635 port1);
4636
4637 portstatus &= ~USB_PORT_STAT_CONNECTION; 4641 portstatus &= ~USB_PORT_STAT_CONNECTION;
4638 unreliable_port = port1; 4642 unreliable_port = port1;
4639 } else { 4643 } else {
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 0ba9c335b584..7c9618e916e2 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1901,7 +1901,7 @@ static void s3c_hsotg_epint(struct s3c_hsotg *hsotg, unsigned int idx,
1901static void s3c_hsotg_irq_enumdone(struct s3c_hsotg *hsotg) 1901static void s3c_hsotg_irq_enumdone(struct s3c_hsotg *hsotg)
1902{ 1902{
1903 u32 dsts = readl(hsotg->regs + DSTS); 1903 u32 dsts = readl(hsotg->regs + DSTS);
1904 int ep0_mps = 0, ep_mps; 1904 int ep0_mps = 0, ep_mps = 8;
1905 1905
1906 /* 1906 /*
1907 * This should signal the finish of the enumeration phase 1907 * This should signal the finish of the enumeration phase
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index ef4936ff626c..9dcfbe7cd5f5 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -425,7 +425,7 @@ static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap)
425 425
426static int dwc3_omap_extcon_register(struct dwc3_omap *omap) 426static int dwc3_omap_extcon_register(struct dwc3_omap *omap)
427{ 427{
428 u32 ret; 428 int ret;
429 struct device_node *node = omap->dev->of_node; 429 struct device_node *node = omap->dev->of_node;
430 struct extcon_dev *edev; 430 struct extcon_dev *edev;
431 431
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index a186afeaa700..9add915d41f7 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -3,7 +3,7 @@
3# 3#
4subdir-ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG 4subdir-ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
5subdir-ccflags-$(CONFIG_USB_GADGET_VERBOSE) += -DVERBOSE_DEBUG 5subdir-ccflags-$(CONFIG_USB_GADGET_VERBOSE) += -DVERBOSE_DEBUG
6ccflags-y += -I$(PWD)/drivers/usb/gadget/udc 6ccflags-y += -Idrivers/usb/gadget/udc
7 7
8obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o 8obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o
9libcomposite-y := usbstring.o config.o epautoconf.o 9libcomposite-y := usbstring.o config.o epautoconf.o
diff --git a/drivers/usb/gadget/function/Makefile b/drivers/usb/gadget/function/Makefile
index 6d91f21b52a6..83ae1065149d 100644
--- a/drivers/usb/gadget/function/Makefile
+++ b/drivers/usb/gadget/function/Makefile
@@ -2,8 +2,8 @@
2# USB peripheral controller drivers 2# USB peripheral controller drivers
3# 3#
4 4
5ccflags-y := -I$(PWD)/drivers/usb/gadget/ 5ccflags-y := -Idrivers/usb/gadget/
6ccflags-y += -I$(PWD)/drivers/usb/gadget/udc/ 6ccflags-y += -Idrivers/usb/gadget/udc/
7 7
8# USB Functions 8# USB Functions
9usb_f_acm-y := f_acm.o 9usb_f_acm-y := f_acm.o
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index d50adda913cf..6e6f87656e7b 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -1127,10 +1127,7 @@ void gether_disconnect(struct gether *link)
1127 1127
1128 DBG(dev, "%s\n", __func__); 1128 DBG(dev, "%s\n", __func__);
1129 1129
1130 netif_tx_lock(dev->net);
1131 netif_stop_queue(dev->net); 1130 netif_stop_queue(dev->net);
1132 netif_tx_unlock(dev->net);
1133
1134 netif_carrier_off(dev->net); 1131 netif_carrier_off(dev->net);
1135 1132
1136 /* disable endpoints, forcing (synchronous) completion 1133 /* disable endpoints, forcing (synchronous) completion
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index 71e896d4c5ae..a5eb9a3fbb7a 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -195,6 +195,7 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
195 printk(KERN_INFO "Failed to queue request (%d).\n", ret); 195 printk(KERN_INFO "Failed to queue request (%d).\n", ret);
196 usb_ep_set_halt(ep); 196 usb_ep_set_halt(ep);
197 spin_unlock_irqrestore(&video->queue.irqlock, flags); 197 spin_unlock_irqrestore(&video->queue.irqlock, flags);
198 uvc_queue_cancel(queue, 0);
198 goto requeue; 199 goto requeue;
199 } 200 }
200 spin_unlock_irqrestore(&video->queue.irqlock, flags); 201 spin_unlock_irqrestore(&video->queue.irqlock, flags);
@@ -281,6 +282,7 @@ error:
281static int 282static int
282uvc_video_pump(struct uvc_video *video) 283uvc_video_pump(struct uvc_video *video)
283{ 284{
285 struct uvc_video_queue *queue = &video->queue;
284 struct usb_request *req; 286 struct usb_request *req;
285 struct uvc_buffer *buf; 287 struct uvc_buffer *buf;
286 unsigned long flags; 288 unsigned long flags;
@@ -322,6 +324,7 @@ uvc_video_pump(struct uvc_video *video)
322 printk(KERN_INFO "Failed to queue request (%d)\n", ret); 324 printk(KERN_INFO "Failed to queue request (%d)\n", ret);
323 usb_ep_set_halt(video->ep); 325 usb_ep_set_halt(video->ep);
324 spin_unlock_irqrestore(&video->queue.irqlock, flags); 326 spin_unlock_irqrestore(&video->queue.irqlock, flags);
327 uvc_queue_cancel(queue, 0);
325 break; 328 break;
326 } 329 }
327 spin_unlock_irqrestore(&video->queue.irqlock, flags); 330 spin_unlock_irqrestore(&video->queue.irqlock, flags);
diff --git a/drivers/usb/gadget/legacy/Makefile b/drivers/usb/gadget/legacy/Makefile
index a11aad5635df..edba2d1ee0f3 100644
--- a/drivers/usb/gadget/legacy/Makefile
+++ b/drivers/usb/gadget/legacy/Makefile
@@ -2,9 +2,9 @@
2# USB gadget drivers 2# USB gadget drivers
3# 3#
4 4
5ccflags-y := -I$(PWD)/drivers/usb/gadget/ 5ccflags-y := -Idrivers/usb/gadget/
6ccflags-y += -I$(PWD)/drivers/usb/gadget/udc/ 6ccflags-y += -Idrivers/usb/gadget/udc/
7ccflags-y += -I$(PWD)/drivers/usb/gadget/function/ 7ccflags-y += -Idrivers/usb/gadget/function/
8 8
9g_zero-y := zero.o 9g_zero-y := zero.o
10g_audio-y := audio.o 10g_audio-y := audio.o
diff --git a/drivers/usb/gadget/legacy/dbgp.c b/drivers/usb/gadget/legacy/dbgp.c
index 986fc511a2ed..225e385a6160 100644
--- a/drivers/usb/gadget/legacy/dbgp.c
+++ b/drivers/usb/gadget/legacy/dbgp.c
@@ -222,10 +222,12 @@ static void dbgp_unbind(struct usb_gadget *gadget)
222{ 222{
223#ifdef CONFIG_USB_G_DBGP_SERIAL 223#ifdef CONFIG_USB_G_DBGP_SERIAL
224 kfree(dbgp.serial); 224 kfree(dbgp.serial);
225 dbgp.serial = NULL;
225#endif 226#endif
226 if (dbgp.req) { 227 if (dbgp.req) {
227 kfree(dbgp.req->buf); 228 kfree(dbgp.req->buf);
228 usb_ep_free_request(gadget->ep0, dbgp.req); 229 usb_ep_free_request(gadget->ep0, dbgp.req);
230 dbgp.req = NULL;
229 } 231 }
230 232
231 gadget->ep0->driver_data = NULL; 233 gadget->ep0->driver_data = NULL;
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index 2e4ce7704908..e96077b8bf79 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -440,7 +440,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
440 440
441 value = -ENOMEM; 441 value = -ENOMEM;
442 kbuf = memdup_user(buf, len); 442 kbuf = memdup_user(buf, len);
443 if (!kbuf) { 443 if (IS_ERR(kbuf)) {
444 value = PTR_ERR(kbuf); 444 value = PTR_ERR(kbuf);
445 goto free1; 445 goto free1;
446 } 446 }
diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index 5151f947a4f5..34ebaa68504c 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -332,7 +332,7 @@ config USB_GOKU
332 gadget drivers to also be dynamically linked. 332 gadget drivers to also be dynamically linked.
333 333
334config USB_EG20T 334config USB_EG20T
335 tristate "Intel EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7831) UDC" 335 tristate "Intel QUARK X1000/EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7831) UDC"
336 depends on PCI 336 depends on PCI
337 help 337 help
338 This is a USB device driver for EG20T PCH. 338 This is a USB device driver for EG20T PCH.
@@ -353,6 +353,7 @@ config USB_EG20T
353 ML7213/ML7831 is companion chip for Intel Atom E6xx series. 353 ML7213/ML7831 is companion chip for Intel Atom E6xx series.
354 ML7213/ML7831 is completely compatible for Intel EG20T PCH. 354 ML7213/ML7831 is completely compatible for Intel EG20T PCH.
355 355
356 This driver can be used with Intel's Quark X1000 SOC platform
356# 357#
357# LAST -- dummy/emulated controller 358# LAST -- dummy/emulated controller
358# 359#
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 906e65f0e4fa..c9fe67e29d35 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1661,7 +1661,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1661 if (dma_status) { 1661 if (dma_status) {
1662 int i; 1662 int i;
1663 1663
1664 for (i = 1; i < USBA_NR_DMAS; i++) 1664 for (i = 1; i <= USBA_NR_DMAS; i++)
1665 if (dma_status & (1 << i)) 1665 if (dma_status & (1 << i))
1666 usba_dma_irq(udc, &udc->usba_ep[i]); 1666 usba_dma_irq(udc, &udc->usba_ep[i]);
1667 } 1667 }
diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c
index d40255f784df..5c5d1adda7eb 100644
--- a/drivers/usb/gadget/udc/fusb300_udc.c
+++ b/drivers/usb/gadget/udc/fusb300_udc.c
@@ -1398,13 +1398,17 @@ static int fusb300_probe(struct platform_device *pdev)
1398 1398
1399 /* initialize udc */ 1399 /* initialize udc */
1400 fusb300 = kzalloc(sizeof(struct fusb300), GFP_KERNEL); 1400 fusb300 = kzalloc(sizeof(struct fusb300), GFP_KERNEL);
1401 if (fusb300 == NULL) 1401 if (fusb300 == NULL) {
1402 ret = -ENOMEM;
1402 goto clean_up; 1403 goto clean_up;
1404 }
1403 1405
1404 for (i = 0; i < FUSB300_MAX_NUM_EP; i++) { 1406 for (i = 0; i < FUSB300_MAX_NUM_EP; i++) {
1405 _ep[i] = kzalloc(sizeof(struct fusb300_ep), GFP_KERNEL); 1407 _ep[i] = kzalloc(sizeof(struct fusb300_ep), GFP_KERNEL);
1406 if (_ep[i] == NULL) 1408 if (_ep[i] == NULL) {
1409 ret = -ENOMEM;
1407 goto clean_up; 1410 goto clean_up;
1411 }
1408 fusb300->ep[i] = _ep[i]; 1412 fusb300->ep[i] = _ep[i];
1409 } 1413 }
1410 1414
diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index eb8c3bedb57a..460d953c91b6 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -343,6 +343,7 @@ struct pch_vbus_gpio_data {
343 * @setup_data: Received setup data 343 * @setup_data: Received setup data
344 * @phys_addr: of device memory 344 * @phys_addr: of device memory
345 * @base_addr: for mapped device memory 345 * @base_addr: for mapped device memory
346 * @bar: Indicates which PCI BAR for USB regs
346 * @irq: IRQ line for the device 347 * @irq: IRQ line for the device
347 * @cfg_data: current cfg, intf, and alt in use 348 * @cfg_data: current cfg, intf, and alt in use
348 * @vbus_gpio: GPIO informaton for detecting VBUS 349 * @vbus_gpio: GPIO informaton for detecting VBUS
@@ -370,14 +371,17 @@ struct pch_udc_dev {
370 struct usb_ctrlrequest setup_data; 371 struct usb_ctrlrequest setup_data;
371 unsigned long phys_addr; 372 unsigned long phys_addr;
372 void __iomem *base_addr; 373 void __iomem *base_addr;
374 unsigned bar;
373 unsigned irq; 375 unsigned irq;
374 struct pch_udc_cfg_data cfg_data; 376 struct pch_udc_cfg_data cfg_data;
375 struct pch_vbus_gpio_data vbus_gpio; 377 struct pch_vbus_gpio_data vbus_gpio;
376}; 378};
377#define to_pch_udc(g) (container_of((g), struct pch_udc_dev, gadget)) 379#define to_pch_udc(g) (container_of((g), struct pch_udc_dev, gadget))
378 380
381#define PCH_UDC_PCI_BAR_QUARK_X1000 0
379#define PCH_UDC_PCI_BAR 1 382#define PCH_UDC_PCI_BAR 1
380#define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808 383#define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808
384#define PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC 0x0939
381#define PCI_VENDOR_ID_ROHM 0x10DB 385#define PCI_VENDOR_ID_ROHM 0x10DB
382#define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D 386#define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D
383#define PCI_DEVICE_ID_ML7831_IOH_UDC 0x8808 387#define PCI_DEVICE_ID_ML7831_IOH_UDC 0x8808
@@ -3076,7 +3080,7 @@ static void pch_udc_remove(struct pci_dev *pdev)
3076 iounmap(dev->base_addr); 3080 iounmap(dev->base_addr);
3077 if (dev->mem_region) 3081 if (dev->mem_region)
3078 release_mem_region(dev->phys_addr, 3082 release_mem_region(dev->phys_addr,
3079 pci_resource_len(pdev, PCH_UDC_PCI_BAR)); 3083 pci_resource_len(pdev, dev->bar));
3080 if (dev->active) 3084 if (dev->active)
3081 pci_disable_device(pdev); 3085 pci_disable_device(pdev);
3082 kfree(dev); 3086 kfree(dev);
@@ -3144,9 +3148,15 @@ static int pch_udc_probe(struct pci_dev *pdev,
3144 dev->active = 1; 3148 dev->active = 1;
3145 pci_set_drvdata(pdev, dev); 3149 pci_set_drvdata(pdev, dev);
3146 3150
3151 /* Determine BAR based on PCI ID */
3152 if (id->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC)
3153 dev->bar = PCH_UDC_PCI_BAR_QUARK_X1000;
3154 else
3155 dev->bar = PCH_UDC_PCI_BAR;
3156
3147 /* PCI resource allocation */ 3157 /* PCI resource allocation */
3148 resource = pci_resource_start(pdev, 1); 3158 resource = pci_resource_start(pdev, dev->bar);
3149 len = pci_resource_len(pdev, 1); 3159 len = pci_resource_len(pdev, dev->bar);
3150 3160
3151 if (!request_mem_region(resource, len, KBUILD_MODNAME)) { 3161 if (!request_mem_region(resource, len, KBUILD_MODNAME)) {
3152 dev_err(&pdev->dev, "%s: pci device used already\n", __func__); 3162 dev_err(&pdev->dev, "%s: pci device used already\n", __func__);
@@ -3212,6 +3222,12 @@ finished:
3212 3222
3213static const struct pci_device_id pch_udc_pcidev_id[] = { 3223static const struct pci_device_id pch_udc_pcidev_id[] = {
3214 { 3224 {
3225 PCI_DEVICE(PCI_VENDOR_ID_INTEL,
3226 PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC),
3227 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
3228 .class_mask = 0xffffffff,
3229 },
3230 {
3215 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EG20T_UDC), 3231 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EG20T_UDC),
3216 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe, 3232 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
3217 .class_mask = 0xffffffff, 3233 .class_mask = 0xffffffff,
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
index 46008421c1ec..de2a8713b428 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.c
+++ b/drivers/usb/gadget/udc/r8a66597-udc.c
@@ -1868,8 +1868,8 @@ static int r8a66597_probe(struct platform_device *pdev)
1868 1868
1869 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1869 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1870 reg = devm_ioremap_resource(&pdev->dev, res); 1870 reg = devm_ioremap_resource(&pdev->dev, res);
1871 if (!reg) 1871 if (IS_ERR(reg))
1872 return -ENODEV; 1872 return PTR_ERR(reg);
1873 1873
1874 ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1874 ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1875 irq = ires->start; 1875 irq = ires->start;
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index cc305c71ac3d..6130b7574908 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -1230,7 +1230,7 @@ int ehci_hub_control(
1230 if (selector == EHSET_TEST_SINGLE_STEP_SET_FEATURE) { 1230 if (selector == EHSET_TEST_SINGLE_STEP_SET_FEATURE) {
1231 spin_unlock_irqrestore(&ehci->lock, flags); 1231 spin_unlock_irqrestore(&ehci->lock, flags);
1232 retval = ehset_single_step_set_feature(hcd, 1232 retval = ehset_single_step_set_feature(hcd,
1233 wIndex); 1233 wIndex + 1);
1234 spin_lock_irqsave(&ehci->lock, flags); 1234 spin_lock_irqsave(&ehci->lock, flags);
1235 break; 1235 break;
1236 } 1236 }
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 687d36608155..c22a3e15a16e 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -101,6 +101,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
101 /* AMD PLL quirk */ 101 /* AMD PLL quirk */
102 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info()) 102 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
103 xhci->quirks |= XHCI_AMD_PLL_FIX; 103 xhci->quirks |= XHCI_AMD_PLL_FIX;
104
105 if (pdev->vendor == PCI_VENDOR_ID_AMD)
106 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
107
104 if (pdev->vendor == PCI_VENDOR_ID_INTEL) { 108 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
105 xhci->quirks |= XHCI_LPM_SUPPORT; 109 xhci->quirks |= XHCI_LPM_SUPPORT;
106 xhci->quirks |= XHCI_INTEL_HOST; 110 xhci->quirks |= XHCI_INTEL_HOST;
@@ -151,6 +155,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
151 if (pdev->vendor == PCI_VENDOR_ID_VIA) 155 if (pdev->vendor == PCI_VENDOR_ID_VIA)
152 xhci->quirks |= XHCI_RESET_ON_RESUME; 156 xhci->quirks |= XHCI_RESET_ON_RESUME;
153 157
158 /* See https://bugzilla.kernel.org/show_bug.cgi?id=79511 */
159 if (pdev->vendor == PCI_VENDOR_ID_VIA &&
160 pdev->device == 0x3432)
161 xhci->quirks |= XHCI_BROKEN_STREAMS;
162
154 if (xhci->quirks & XHCI_RESET_ON_RESUME) 163 if (xhci->quirks & XHCI_RESET_ON_RESUME)
155 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, 164 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
156 "QUIRK: Resetting on resume"); 165 "QUIRK: Resetting on resume");
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 60fb52ae864b..abed30b82905 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -364,32 +364,6 @@ static void ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
364 } 364 }
365} 365}
366 366
367/*
368 * Find the segment that trb is in. Start searching in start_seg.
369 * If we must move past a segment that has a link TRB with a toggle cycle state
370 * bit set, then we will toggle the value pointed at by cycle_state.
371 */
372static struct xhci_segment *find_trb_seg(
373 struct xhci_segment *start_seg,
374 union xhci_trb *trb, int *cycle_state)
375{
376 struct xhci_segment *cur_seg = start_seg;
377 struct xhci_generic_trb *generic_trb;
378
379 while (cur_seg->trbs > trb ||
380 &cur_seg->trbs[TRBS_PER_SEGMENT - 1] < trb) {
381 generic_trb = &cur_seg->trbs[TRBS_PER_SEGMENT - 1].generic;
382 if (generic_trb->field[3] & cpu_to_le32(LINK_TOGGLE))
383 *cycle_state ^= 0x1;
384 cur_seg = cur_seg->next;
385 if (cur_seg == start_seg)
386 /* Looped over the entire list. Oops! */
387 return NULL;
388 }
389 return cur_seg;
390}
391
392
393static struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, 367static struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci,
394 unsigned int slot_id, unsigned int ep_index, 368 unsigned int slot_id, unsigned int ep_index,
395 unsigned int stream_id) 369 unsigned int stream_id)
@@ -459,9 +433,12 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
459 struct xhci_virt_device *dev = xhci->devs[slot_id]; 433 struct xhci_virt_device *dev = xhci->devs[slot_id];
460 struct xhci_virt_ep *ep = &dev->eps[ep_index]; 434 struct xhci_virt_ep *ep = &dev->eps[ep_index];
461 struct xhci_ring *ep_ring; 435 struct xhci_ring *ep_ring;
462 struct xhci_generic_trb *trb; 436 struct xhci_segment *new_seg;
437 union xhci_trb *new_deq;
463 dma_addr_t addr; 438 dma_addr_t addr;
464 u64 hw_dequeue; 439 u64 hw_dequeue;
440 bool cycle_found = false;
441 bool td_last_trb_found = false;
465 442
466 ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id, 443 ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id,
467 ep_index, stream_id); 444 ep_index, stream_id);
@@ -486,45 +463,45 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
486 hw_dequeue = le64_to_cpu(ep_ctx->deq); 463 hw_dequeue = le64_to_cpu(ep_ctx->deq);
487 } 464 }
488 465
489 /* Find virtual address and segment of hardware dequeue pointer */ 466 new_seg = ep_ring->deq_seg;
490 state->new_deq_seg = ep_ring->deq_seg; 467 new_deq = ep_ring->dequeue;
491 state->new_deq_ptr = ep_ring->dequeue; 468 state->new_cycle_state = hw_dequeue & 0x1;
492 while (xhci_trb_virt_to_dma(state->new_deq_seg, state->new_deq_ptr) 469
493 != (dma_addr_t)(hw_dequeue & ~0xf)) {
494 next_trb(xhci, ep_ring, &state->new_deq_seg,
495 &state->new_deq_ptr);
496 if (state->new_deq_ptr == ep_ring->dequeue) {
497 WARN_ON(1);
498 return;
499 }
500 }
501 /* 470 /*
502 * Find cycle state for last_trb, starting at old cycle state of 471 * We want to find the pointer, segment and cycle state of the new trb
503 * hw_dequeue. If there is only one segment ring, find_trb_seg() will 472 * (the one after current TD's last_trb). We know the cycle state at
504 * return immediately and cannot toggle the cycle state if this search 473 * hw_dequeue, so walk the ring until both hw_dequeue and last_trb are
505 * wraps around, so add one more toggle manually in that case. 474 * found.
506 */ 475 */
507 state->new_cycle_state = hw_dequeue & 0x1; 476 do {
508 if (ep_ring->first_seg == ep_ring->first_seg->next && 477 if (!cycle_found && xhci_trb_virt_to_dma(new_seg, new_deq)
509 cur_td->last_trb < state->new_deq_ptr) 478 == (dma_addr_t)(hw_dequeue & ~0xf)) {
510 state->new_cycle_state ^= 0x1; 479 cycle_found = true;
480 if (td_last_trb_found)
481 break;
482 }
483 if (new_deq == cur_td->last_trb)
484 td_last_trb_found = true;
511 485
512 state->new_deq_ptr = cur_td->last_trb; 486 if (cycle_found &&
513 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 487 TRB_TYPE_LINK_LE32(new_deq->generic.field[3]) &&
514 "Finding segment containing last TRB in TD."); 488 new_deq->generic.field[3] & cpu_to_le32(LINK_TOGGLE))
515 state->new_deq_seg = find_trb_seg(state->new_deq_seg, 489 state->new_cycle_state ^= 0x1;
516 state->new_deq_ptr, &state->new_cycle_state); 490
517 if (!state->new_deq_seg) { 491 next_trb(xhci, ep_ring, &new_seg, &new_deq);
518 WARN_ON(1); 492
519 return; 493 /* Search wrapped around, bail out */
520 } 494 if (new_deq == ep->ring->dequeue) {
495 xhci_err(xhci, "Error: Failed finding new dequeue state\n");
496 state->new_deq_seg = NULL;
497 state->new_deq_ptr = NULL;
498 return;
499 }
500
501 } while (!cycle_found || !td_last_trb_found);
521 502
522 /* Increment to find next TRB after last_trb. Cycle if appropriate. */ 503 state->new_deq_seg = new_seg;
523 trb = &state->new_deq_ptr->generic; 504 state->new_deq_ptr = new_deq;
524 if (TRB_TYPE_LINK_LE32(trb->field[3]) &&
525 (trb->field[3] & cpu_to_le32(LINK_TOGGLE)))
526 state->new_cycle_state ^= 0x1;
527 next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr);
528 505
529 /* Don't update the ring cycle state for the producer (us). */ 506 /* Don't update the ring cycle state for the producer (us). */
530 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 507 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
@@ -2487,7 +2464,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2487 * last TRB of the previous TD. The command completion handle 2464 * last TRB of the previous TD. The command completion handle
2488 * will take care the rest. 2465 * will take care the rest.
2489 */ 2466 */
2490 if (!event_seg && trb_comp_code == COMP_STOP_INVAL) { 2467 if (!event_seg && (trb_comp_code == COMP_STOP ||
2468 trb_comp_code == COMP_STOP_INVAL)) {
2491 ret = 0; 2469 ret = 0;
2492 goto cleanup; 2470 goto cleanup;
2493 } 2471 }
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index b6f21175b872..c020b094fe7d 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -2880,6 +2880,9 @@ void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
2880 ep_index, ep->stopped_stream, ep->stopped_td, 2880 ep_index, ep->stopped_stream, ep->stopped_td,
2881 &deq_state); 2881 &deq_state);
2882 2882
2883 if (!deq_state.new_deq_ptr || !deq_state.new_deq_seg)
2884 return;
2885
2883 /* HW with the reset endpoint quirk will use the saved dequeue state to 2886 /* HW with the reset endpoint quirk will use the saved dequeue state to
2884 * issue a configure endpoint command later. 2887 * issue a configure endpoint command later.
2885 */ 2888 */
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 06b5d77cd9ad..633caf643122 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -3250,6 +3250,7 @@ static const struct usb_device_id sisusb_table[] = {
3250 { USB_DEVICE(0x0711, 0x0918) }, 3250 { USB_DEVICE(0x0711, 0x0918) },
3251 { USB_DEVICE(0x0711, 0x0920) }, 3251 { USB_DEVICE(0x0711, 0x0920) },
3252 { USB_DEVICE(0x0711, 0x0950) }, 3252 { USB_DEVICE(0x0711, 0x0950) },
3253 { USB_DEVICE(0x0711, 0x5200) },
3253 { USB_DEVICE(0x182d, 0x021c) }, 3254 { USB_DEVICE(0x182d, 0x021c) },
3254 { USB_DEVICE(0x182d, 0x0269) }, 3255 { USB_DEVICE(0x182d, 0x0269) },
3255 { } 3256 { }
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index 9aad00f11bd5..221faed9f074 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -96,7 +96,7 @@ static bool ux500_configure_channel(struct dma_channel *channel,
96 struct musb *musb = ux500_channel->controller->private_data; 96 struct musb *musb = ux500_channel->controller->private_data;
97 97
98 dev_dbg(musb->controller, 98 dev_dbg(musb->controller,
99 "packet_sz=%d, mode=%d, dma_addr=0x%llu, len=%d is_tx=%d\n", 99 "packet_sz=%d, mode=%d, dma_addr=0x%llx, len=%d is_tx=%d\n",
100 packet_sz, mode, (unsigned long long) dma_addr, 100 packet_sz, mode, (unsigned long long) dma_addr,
101 len, ux500_channel->is_tx); 101 len, ux500_channel->is_tx);
102 102
diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
index ea9e705555df..f4b14bd97e14 100644
--- a/drivers/usb/phy/phy-gpio-vbus-usb.c
+++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
@@ -260,10 +260,8 @@ static int gpio_vbus_probe(struct platform_device *pdev)
260 260
261 gpio_vbus->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), 261 gpio_vbus->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg),
262 GFP_KERNEL); 262 GFP_KERNEL);
263 if (!gpio_vbus->phy.otg) { 263 if (!gpio_vbus->phy.otg)
264 kfree(gpio_vbus);
265 return -ENOMEM; 264 return -ENOMEM;
266 }
267 265
268 platform_set_drvdata(pdev, gpio_vbus); 266 platform_set_drvdata(pdev, gpio_vbus);
269 gpio_vbus->dev = &pdev->dev; 267 gpio_vbus->dev = &pdev->dev;
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index e4108eec5ef4..afc09087ec36 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1601,8 +1601,8 @@ static int msm_otg_probe(struct platform_device *pdev)
1601 */ 1601 */
1602 if (motg->phy_number) { 1602 if (motg->phy_number) {
1603 phy_select = devm_ioremap_nocache(&pdev->dev, USB2_PHY_SEL, 4); 1603 phy_select = devm_ioremap_nocache(&pdev->dev, USB2_PHY_SEL, 4);
1604 if (IS_ERR(phy_select)) 1604 if (!phy_select)
1605 return PTR_ERR(phy_select); 1605 return -ENOMEM;
1606 /* Enable second PHY with the OTG port */ 1606 /* Enable second PHY with the OTG port */
1607 writel(0x1, phy_select); 1607 writel(0x1, phy_select);
1608 } 1608 }
diff --git a/drivers/usb/phy/phy-samsung-usb.h b/drivers/usb/phy/phy-samsung-usb.h
index 68771bfd1825..80eedd45a20a 100644
--- a/drivers/usb/phy/phy-samsung-usb.h
+++ b/drivers/usb/phy/phy-samsung-usb.h
@@ -216,7 +216,7 @@
216 216
217#define EXYNOS5_DRD_PHYPARAM1 (0x20) 217#define EXYNOS5_DRD_PHYPARAM1 (0x20)
218 218
219#define PHYPARAM1_PCS_TXDEEMPH_MASK (0x1f << 0) 219#define PHYPARAM1_PCS_TXDEEMPH_MASK (0x3f << 0)
220#define PHYPARAM1_PCS_TXDEEMPH (0x1c) 220#define PHYPARAM1_PCS_TXDEEMPH (0x1c)
221 221
222#define EXYNOS5_DRD_PHYTERM (0x24) 222#define EXYNOS5_DRD_PHYTERM (0x24)
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 6d0f6080eceb..045cd309367a 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -232,6 +232,9 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index)
232 phy = __usb_find_phy_dev(dev, &phy_bind_list, index); 232 phy = __usb_find_phy_dev(dev, &phy_bind_list, index);
233 if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { 233 if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
234 dev_dbg(dev, "unable to find transceiver\n"); 234 dev_dbg(dev, "unable to find transceiver\n");
235 if (!IS_ERR(phy))
236 phy = ERR_PTR(-ENODEV);
237
235 goto err0; 238 goto err0;
236 } 239 }
237 240
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 216ce3078270..824ea5e7ec8b 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -146,6 +146,7 @@ static const struct usb_device_id id_table_combined[] = {
146 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) }, 146 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) },
147 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) }, 147 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) },
148 { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) }, 148 { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) },
149 { USB_DEVICE(FTDI_VID, FTDI_BM_ATOM_NANO_PID) },
149 { USB_DEVICE(FTDI_VID, FTDI_NXTCAM_PID) }, 150 { USB_DEVICE(FTDI_VID, FTDI_NXTCAM_PID) },
150 { USB_DEVICE(FTDI_VID, FTDI_EV3CON_PID) }, 151 { USB_DEVICE(FTDI_VID, FTDI_EV3CON_PID) },
151 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) }, 152 { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) },
@@ -934,6 +935,8 @@ static const struct usb_device_id id_table_combined[] = {
934 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_2_PID) }, 935 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_2_PID) },
935 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_3_PID) }, 936 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_3_PID) },
936 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_4_PID) }, 937 { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_4_PID) },
938 /* ekey Devices */
939 { USB_DEVICE(FTDI_VID, FTDI_EKEY_CONV_USB_PID) },
937 /* Infineon Devices */ 940 /* Infineon Devices */
938 { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) }, 941 { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) },
939 { } /* Terminating entry */ 942 { } /* Terminating entry */
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 1e58d90a0b6c..70b0b1d88ae9 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -42,6 +42,8 @@
42/* www.candapter.com Ewert Energy Systems CANdapter device */ 42/* www.candapter.com Ewert Energy Systems CANdapter device */
43#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */ 43#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
44 44
45#define FTDI_BM_ATOM_NANO_PID 0xa559 /* Basic Micro ATOM Nano USB2Serial */
46
45/* 47/*
46 * Texas Instruments XDS100v2 JTAG / BeagleBone A3 48 * Texas Instruments XDS100v2 JTAG / BeagleBone A3
47 * http://processors.wiki.ti.com/index.php/XDS100 49 * http://processors.wiki.ti.com/index.php/XDS100
@@ -1378,3 +1380,8 @@
1378#define BRAINBOXES_US_160_6_PID 0x9006 /* US-160 16xRS232 1Mbaud Port 11 and 12 */ 1380#define BRAINBOXES_US_160_6_PID 0x9006 /* US-160 16xRS232 1Mbaud Port 11 and 12 */
1379#define BRAINBOXES_US_160_7_PID 0x9007 /* US-160 16xRS232 1Mbaud Port 13 and 14 */ 1381#define BRAINBOXES_US_160_7_PID 0x9007 /* US-160 16xRS232 1Mbaud Port 13 and 14 */
1380#define BRAINBOXES_US_160_8_PID 0x9008 /* US-160 16xRS232 1Mbaud Port 15 and 16 */ 1382#define BRAINBOXES_US_160_8_PID 0x9008 /* US-160 16xRS232 1Mbaud Port 15 and 16 */
1383
1384/*
1385 * ekey biometric systems GmbH (http://ekey.net/)
1386 */
1387#define FTDI_EKEY_CONV_USB_PID 0xCB08 /* Converter USB */
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index a9688940543d..54a8120897a6 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -275,8 +275,12 @@ static void option_instat_callback(struct urb *urb);
275#define ZTE_PRODUCT_MF622 0x0001 275#define ZTE_PRODUCT_MF622 0x0001
276#define ZTE_PRODUCT_MF628 0x0015 276#define ZTE_PRODUCT_MF628 0x0015
277#define ZTE_PRODUCT_MF626 0x0031 277#define ZTE_PRODUCT_MF626 0x0031
278#define ZTE_PRODUCT_MC2718 0xffe8
279#define ZTE_PRODUCT_AC2726 0xfff1 278#define ZTE_PRODUCT_AC2726 0xfff1
279#define ZTE_PRODUCT_CDMA_TECH 0xfffe
280#define ZTE_PRODUCT_AC8710T 0xffff
281#define ZTE_PRODUCT_MC2718 0xffe8
282#define ZTE_PRODUCT_AD3812 0xffeb
283#define ZTE_PRODUCT_MC2716 0xffed
280 284
281#define BENQ_VENDOR_ID 0x04a5 285#define BENQ_VENDOR_ID 0x04a5
282#define BENQ_PRODUCT_H10 0x4068 286#define BENQ_PRODUCT_H10 0x4068
@@ -494,6 +498,10 @@ static void option_instat_callback(struct urb *urb);
494#define INOVIA_VENDOR_ID 0x20a6 498#define INOVIA_VENDOR_ID 0x20a6
495#define INOVIA_SEW858 0x1105 499#define INOVIA_SEW858 0x1105
496 500
501/* VIA Telecom */
502#define VIATELECOM_VENDOR_ID 0x15eb
503#define VIATELECOM_PRODUCT_CDS7 0x0001
504
497/* some devices interfaces need special handling due to a number of reasons */ 505/* some devices interfaces need special handling due to a number of reasons */
498enum option_blacklist_reason { 506enum option_blacklist_reason {
499 OPTION_BLACKLIST_NONE = 0, 507 OPTION_BLACKLIST_NONE = 0,
@@ -527,10 +535,18 @@ static const struct option_blacklist_info zte_k3765_z_blacklist = {
527 .reserved = BIT(4), 535 .reserved = BIT(4),
528}; 536};
529 537
538static const struct option_blacklist_info zte_ad3812_z_blacklist = {
539 .sendsetup = BIT(0) | BIT(1) | BIT(2),
540};
541
530static const struct option_blacklist_info zte_mc2718_z_blacklist = { 542static const struct option_blacklist_info zte_mc2718_z_blacklist = {
531 .sendsetup = BIT(1) | BIT(2) | BIT(3) | BIT(4), 543 .sendsetup = BIT(1) | BIT(2) | BIT(3) | BIT(4),
532}; 544};
533 545
546static const struct option_blacklist_info zte_mc2716_z_blacklist = {
547 .sendsetup = BIT(1) | BIT(2) | BIT(3),
548};
549
534static const struct option_blacklist_info huawei_cdc12_blacklist = { 550static const struct option_blacklist_info huawei_cdc12_blacklist = {
535 .reserved = BIT(1) | BIT(2), 551 .reserved = BIT(1) | BIT(2),
536}; 552};
@@ -1070,6 +1086,7 @@ static const struct usb_device_id option_ids[] = {
1070 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012, 0xff) }, 1086 { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012, 0xff) },
1071 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, 1087 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) },
1072 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 1088 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
1089 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */
1073 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 1090 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
1074 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */ 1091 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
1075 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ 1092 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
@@ -1544,13 +1561,18 @@ static const struct usb_device_id option_ids[] = {
1544 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) }, 1561 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) },
1545 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) }, 1562 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) },
1546 1563
1547 /* NOTE: most ZTE CDMA devices should be driven by zte_ev, not option */ 1564 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
1565 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
1566 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710T, 0xff, 0xff, 0xff) },
1548 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2718, 0xff, 0xff, 0xff), 1567 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2718, 0xff, 0xff, 0xff),
1549 .driver_info = (kernel_ulong_t)&zte_mc2718_z_blacklist }, 1568 .driver_info = (kernel_ulong_t)&zte_mc2718_z_blacklist },
1569 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AD3812, 0xff, 0xff, 0xff),
1570 .driver_info = (kernel_ulong_t)&zte_ad3812_z_blacklist },
1571 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2716, 0xff, 0xff, 0xff),
1572 .driver_info = (kernel_ulong_t)&zte_mc2716_z_blacklist },
1550 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) }, 1573 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) },
1551 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) }, 1574 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) },
1552 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) }, 1575 { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) },
1553 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
1554 1576
1555 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 1577 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
1556 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, 1578 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
@@ -1724,6 +1746,7 @@ static const struct usb_device_id option_ids[] = {
1724 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ 1746 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
1725 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ 1747 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
1726 { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, 1748 { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) },
1749 { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) },
1727 { } /* Terminating entry */ 1750 { } /* Terminating entry */
1728}; 1751};
1729MODULE_DEVICE_TABLE(usb, option_ids); 1752MODULE_DEVICE_TABLE(usb, option_ids);
@@ -1916,6 +1939,8 @@ static void option_instat_callback(struct urb *urb)
1916 dev_dbg(dev, "%s: type %x req %x\n", __func__, 1939 dev_dbg(dev, "%s: type %x req %x\n", __func__,
1917 req_pkt->bRequestType, req_pkt->bRequest); 1940 req_pkt->bRequestType, req_pkt->bRequest);
1918 } 1941 }
1942 } else if (status == -ENOENT || status == -ESHUTDOWN) {
1943 dev_dbg(dev, "%s: urb stopped: %d\n", __func__, status);
1919 } else 1944 } else
1920 dev_err(dev, "%s: error %d\n", __func__, status); 1945 dev_err(dev, "%s: error %d\n", __func__, status);
1921 1946
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index b3d5a35c0d4b..e9bad928039f 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -45,6 +45,7 @@ static const struct usb_device_id id_table[] = {
45 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) }, 45 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) },
46 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) }, 46 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) },
47 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) }, 47 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) },
48 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ZTEK) },
48 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, 49 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
49 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, 50 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
50 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, 51 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 42bc082896ac..71fd9da1d6e7 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -22,6 +22,7 @@
22#define PL2303_PRODUCT_ID_GPRS 0x0609 22#define PL2303_PRODUCT_ID_GPRS 0x0609
23#define PL2303_PRODUCT_ID_HCR331 0x331a 23#define PL2303_PRODUCT_ID_HCR331 0x331a
24#define PL2303_PRODUCT_ID_MOTOROLA 0x0307 24#define PL2303_PRODUCT_ID_MOTOROLA 0x0307
25#define PL2303_PRODUCT_ID_ZTEK 0xe1f1
25 26
26#define ATEN_VENDOR_ID 0x0557 27#define ATEN_VENDOR_ID 0x0557
27#define ATEN_VENDOR_ID2 0x0547 28#define ATEN_VENDOR_ID2 0x0547
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 02de3110fe94..475723c006f9 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -764,29 +764,39 @@ static int usb_serial_probe(struct usb_interface *interface,
764 if (usb_endpoint_is_bulk_in(endpoint)) { 764 if (usb_endpoint_is_bulk_in(endpoint)) {
765 /* we found a bulk in endpoint */ 765 /* we found a bulk in endpoint */
766 dev_dbg(ddev, "found bulk in on endpoint %d\n", i); 766 dev_dbg(ddev, "found bulk in on endpoint %d\n", i);
767 bulk_in_endpoint[num_bulk_in] = endpoint; 767 if (num_bulk_in < MAX_NUM_PORTS) {
768 ++num_bulk_in; 768 bulk_in_endpoint[num_bulk_in] = endpoint;
769 ++num_bulk_in;
770 }
769 } 771 }
770 772
771 if (usb_endpoint_is_bulk_out(endpoint)) { 773 if (usb_endpoint_is_bulk_out(endpoint)) {
772 /* we found a bulk out endpoint */ 774 /* we found a bulk out endpoint */
773 dev_dbg(ddev, "found bulk out on endpoint %d\n", i); 775 dev_dbg(ddev, "found bulk out on endpoint %d\n", i);
774 bulk_out_endpoint[num_bulk_out] = endpoint; 776 if (num_bulk_out < MAX_NUM_PORTS) {
775 ++num_bulk_out; 777 bulk_out_endpoint[num_bulk_out] = endpoint;
778 ++num_bulk_out;
779 }
776 } 780 }
777 781
778 if (usb_endpoint_is_int_in(endpoint)) { 782 if (usb_endpoint_is_int_in(endpoint)) {
779 /* we found a interrupt in endpoint */ 783 /* we found a interrupt in endpoint */
780 dev_dbg(ddev, "found interrupt in on endpoint %d\n", i); 784 dev_dbg(ddev, "found interrupt in on endpoint %d\n", i);
781 interrupt_in_endpoint[num_interrupt_in] = endpoint; 785 if (num_interrupt_in < MAX_NUM_PORTS) {
782 ++num_interrupt_in; 786 interrupt_in_endpoint[num_interrupt_in] =
787 endpoint;
788 ++num_interrupt_in;
789 }
783 } 790 }
784 791
785 if (usb_endpoint_is_int_out(endpoint)) { 792 if (usb_endpoint_is_int_out(endpoint)) {
786 /* we found an interrupt out endpoint */ 793 /* we found an interrupt out endpoint */
787 dev_dbg(ddev, "found interrupt out on endpoint %d\n", i); 794 dev_dbg(ddev, "found interrupt out on endpoint %d\n", i);
788 interrupt_out_endpoint[num_interrupt_out] = endpoint; 795 if (num_interrupt_out < MAX_NUM_PORTS) {
789 ++num_interrupt_out; 796 interrupt_out_endpoint[num_interrupt_out] =
797 endpoint;
798 ++num_interrupt_out;
799 }
790 } 800 }
791 } 801 }
792 802
@@ -809,8 +819,10 @@ static int usb_serial_probe(struct usb_interface *interface,
809 if (usb_endpoint_is_int_in(endpoint)) { 819 if (usb_endpoint_is_int_in(endpoint)) {
810 /* we found a interrupt in endpoint */ 820 /* we found a interrupt in endpoint */
811 dev_dbg(ddev, "found interrupt in for Prolific device on separate interface\n"); 821 dev_dbg(ddev, "found interrupt in for Prolific device on separate interface\n");
812 interrupt_in_endpoint[num_interrupt_in] = endpoint; 822 if (num_interrupt_in < MAX_NUM_PORTS) {
813 ++num_interrupt_in; 823 interrupt_in_endpoint[num_interrupt_in] = endpoint;
824 ++num_interrupt_in;
825 }
814 } 826 }
815 } 827 }
816 } 828 }
@@ -850,6 +862,11 @@ static int usb_serial_probe(struct usb_interface *interface,
850 num_ports = type->num_ports; 862 num_ports = type->num_ports;
851 } 863 }
852 864
865 if (num_ports > MAX_NUM_PORTS) {
866 dev_warn(ddev, "too many ports requested: %d\n", num_ports);
867 num_ports = MAX_NUM_PORTS;
868 }
869
853 serial->num_ports = num_ports; 870 serial->num_ports = num_ports;
854 serial->num_bulk_in = num_bulk_in; 871 serial->num_bulk_in = num_bulk_in;
855 serial->num_bulk_out = num_bulk_out; 872 serial->num_bulk_out = num_bulk_out;
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index e62f2dff8b7d..6c3734d2b45a 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -514,6 +514,10 @@ static void command_port_read_callback(struct urb *urb)
514 dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__); 514 dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__);
515 return; 515 return;
516 } 516 }
517 if (!urb->actual_length) {
518 dev_dbg(&urb->dev->dev, "%s - empty response, exiting.\n", __func__);
519 return;
520 }
517 if (status) { 521 if (status) {
518 dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status); 522 dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status);
519 if (status != -ENOENT) 523 if (status != -ENOENT)
@@ -534,7 +538,8 @@ static void command_port_read_callback(struct urb *urb)
534 /* These are unsolicited reports from the firmware, hence no 538 /* These are unsolicited reports from the firmware, hence no
535 waiting command to wakeup */ 539 waiting command to wakeup */
536 dev_dbg(&urb->dev->dev, "%s - event received\n", __func__); 540 dev_dbg(&urb->dev->dev, "%s - event received\n", __func__);
537 } else if (data[0] == WHITEHEAT_GET_DTR_RTS) { 541 } else if ((data[0] == WHITEHEAT_GET_DTR_RTS) &&
542 (urb->actual_length - 1 <= sizeof(command_info->result_buffer))) {
538 memcpy(command_info->result_buffer, &data[1], 543 memcpy(command_info->result_buffer, &data[1],
539 urb->actual_length - 1); 544 urb->actual_length - 1);
540 command_info->command_finished = WHITEHEAT_CMD_COMPLETE; 545 command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
diff --git a/drivers/usb/serial/zte_ev.c b/drivers/usb/serial/zte_ev.c
index e40ab739c4a6..1a132e9e947a 100644
--- a/drivers/usb/serial/zte_ev.c
+++ b/drivers/usb/serial/zte_ev.c
@@ -272,28 +272,8 @@ static void zte_ev_usb_serial_close(struct usb_serial_port *port)
272} 272}
273 273
274static const struct usb_device_id id_table[] = { 274static const struct usb_device_id id_table[] = {
275 /* AC8710, AC8710T */
276 { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xffff, 0xff, 0xff, 0xff) },
277 /* AC8700 */
278 { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xfffe, 0xff, 0xff, 0xff) },
279 /* MG880 */ 275 /* MG880 */
280 { USB_DEVICE(0x19d2, 0xfffd) }, 276 { USB_DEVICE(0x19d2, 0xfffd) },
281 { USB_DEVICE(0x19d2, 0xfffc) },
282 { USB_DEVICE(0x19d2, 0xfffb) },
283 /* AC8710_V3 */
284 { USB_DEVICE(0x19d2, 0xfff6) },
285 { USB_DEVICE(0x19d2, 0xfff7) },
286 { USB_DEVICE(0x19d2, 0xfff8) },
287 { USB_DEVICE(0x19d2, 0xfff9) },
288 { USB_DEVICE(0x19d2, 0xffee) },
289 /* AC2716, MC2716 */
290 { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xffed, 0xff, 0xff, 0xff) },
291 /* AD3812 */
292 { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xffeb, 0xff, 0xff, 0xff) },
293 { USB_DEVICE(0x19d2, 0xffec) },
294 { USB_DEVICE(0x05C6, 0x3197) },
295 { USB_DEVICE(0x05C6, 0x6000) },
296 { USB_DEVICE(0x05C6, 0x9008) },
297 { }, 277 { },
298}; 278};
299MODULE_DEVICE_TABLE(usb, id_table); 279MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 80a5b366255f..7ef99b2f3aaf 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -922,6 +922,12 @@ UNUSUAL_DEV( 0x069b, 0x3004, 0x0001, 0x0001,
922 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 922 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
923 US_FL_FIX_CAPACITY ), 923 US_FL_FIX_CAPACITY ),
924 924
925UNUSUAL_DEV( 0x06ca, 0x2003, 0x0100, 0x0100,
926 "Newer Technology",
927 "uSCSI",
928 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
929 US_FL_SCM_MULT_TARG ),
930
925/* Reported by Adrian Pilchowiec <adi1981@epf.pl> */ 931/* Reported by Adrian Pilchowiec <adi1981@epf.pl> */
926UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000, 932UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000,
927 "RockChip", 933 "RockChip",
diff --git a/drivers/staging/usbip/Kconfig b/drivers/usb/usbip/Kconfig
index bd99e9e47e50..bd99e9e47e50 100644
--- a/drivers/staging/usbip/Kconfig
+++ b/drivers/usb/usbip/Kconfig
diff --git a/drivers/staging/usbip/Makefile b/drivers/usb/usbip/Makefile
index 9ecd61545be1..9ecd61545be1 100644
--- a/drivers/staging/usbip/Makefile
+++ b/drivers/usb/usbip/Makefile
diff --git a/drivers/staging/usbip/README b/drivers/usb/usbip/README
index 41a2cf2e77a6..41a2cf2e77a6 100644
--- a/drivers/staging/usbip/README
+++ b/drivers/usb/usbip/README
diff --git a/drivers/staging/usbip/stub.h b/drivers/usb/usbip/stub.h
index 266e2b0ce9a8..266e2b0ce9a8 100644
--- a/drivers/staging/usbip/stub.h
+++ b/drivers/usb/usbip/stub.h
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index 51d0c7188738..fac20e0434c0 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -26,33 +26,6 @@
26#include "stub.h" 26#include "stub.h"
27 27
28/* 28/*
29 * Define device IDs here if you want to explicitly limit exportable devices.
30 * In most cases, wildcard matching will be okay because driver binding can be
31 * changed dynamically by a userland program.
32 */
33static struct usb_device_id stub_table[] = {
34#if 0
35 /* just an example */
36 { USB_DEVICE(0x05ac, 0x0301) }, /* Mac 1 button mouse */
37 { USB_DEVICE(0x0430, 0x0009) }, /* Plat Home Keyboard */
38 { USB_DEVICE(0x059b, 0x0001) }, /* Iomega USB Zip 100 */
39 { USB_DEVICE(0x04b3, 0x4427) }, /* IBM USB CD-ROM */
40 { USB_DEVICE(0x05a9, 0xa511) }, /* LifeView USB cam */
41 { USB_DEVICE(0x55aa, 0x0201) }, /* Imation card reader */
42 { USB_DEVICE(0x046d, 0x0870) }, /* Qcam Express(QV-30) */
43 { USB_DEVICE(0x04bb, 0x0101) }, /* IO-DATA HD 120GB */
44 { USB_DEVICE(0x04bb, 0x0904) }, /* IO-DATA USB-ET/TX */
45 { USB_DEVICE(0x04bb, 0x0201) }, /* IO-DATA USB-ET/TX */
46 { USB_DEVICE(0x08bb, 0x2702) }, /* ONKYO USB Speaker */
47 { USB_DEVICE(0x046d, 0x08b2) }, /* Logicool Qcam 4000 Pro */
48#endif
49 /* magic for wild card */
50 { .driver_info = 1 },
51 { 0, } /* Terminating entry */
52};
53MODULE_DEVICE_TABLE(usb, stub_table);
54
55/*
56 * usbip_status shows the status of usbip-host as long as this driver is bound 29 * usbip_status shows the status of usbip-host as long as this driver is bound
57 * to the target device. 30 * to the target device.
58 */ 31 */
diff --git a/drivers/staging/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c
index 44ab43fc4fcc..44ab43fc4fcc 100644
--- a/drivers/staging/usbip/stub_main.c
+++ b/drivers/usb/usbip/stub_main.c
diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c
index 00e475c51a12..00e475c51a12 100644
--- a/drivers/staging/usbip/stub_rx.c
+++ b/drivers/usb/usbip/stub_rx.c
diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/usb/usbip/stub_tx.c
index dbcabc9dbe0d..dbcabc9dbe0d 100644
--- a/drivers/staging/usbip/stub_tx.c
+++ b/drivers/usb/usbip/stub_tx.c
diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
index facaaf003f19..facaaf003f19 100644
--- a/drivers/staging/usbip/usbip_common.c
+++ b/drivers/usb/usbip/usbip_common.c
diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h
index 4da3866a037d..86b08475c254 100644
--- a/drivers/staging/usbip/usbip_common.h
+++ b/drivers/usb/usbip/usbip_common.h
@@ -29,7 +29,7 @@
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/usb.h> 30#include <linux/usb.h>
31#include <linux/wait.h> 31#include <linux/wait.h>
32#include "uapi/usbip.h" 32#include <uapi/linux/usbip.h>
33 33
34#define USBIP_VERSION "1.0.0" 34#define USBIP_VERSION "1.0.0"
35 35
diff --git a/drivers/staging/usbip/usbip_event.c b/drivers/usb/usbip/usbip_event.c
index 64933b993d7a..64933b993d7a 100644
--- a/drivers/staging/usbip/usbip_event.c
+++ b/drivers/usb/usbip/usbip_event.c
diff --git a/drivers/staging/usbip/usbip_protocol.txt b/drivers/usb/usbip/usbip_protocol.txt
index 16b6fe27284c..16b6fe27284c 100644
--- a/drivers/staging/usbip/usbip_protocol.txt
+++ b/drivers/usb/usbip/usbip_protocol.txt
diff --git a/drivers/staging/usbip/vhci.h b/drivers/usb/usbip/vhci.h
index a863a98a91ce..a863a98a91ce 100644
--- a/drivers/staging/usbip/vhci.h
+++ b/drivers/usb/usbip/vhci.h
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index c02374b6049c..c02374b6049c 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
index 00e4a54308e4..00e4a54308e4 100644
--- a/drivers/staging/usbip/vhci_rx.c
+++ b/drivers/usb/usbip/vhci_rx.c
diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
index 211f43f67ea2..211f43f67ea2 100644
--- a/drivers/staging/usbip/vhci_sysfs.c
+++ b/drivers/usb/usbip/vhci_sysfs.c
diff --git a/drivers/staging/usbip/vhci_tx.c b/drivers/usb/usbip/vhci_tx.c
index 409fd99f3257..409fd99f3257 100644
--- a/drivers/staging/usbip/vhci_tx.c
+++ b/drivers/usb/usbip/vhci_tx.c
diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
index 3e2e4ed20157..e279015be466 100644
--- a/drivers/usb/wusbcore/wa-xfer.c
+++ b/drivers/usb/wusbcore/wa-xfer.c
@@ -2602,6 +2602,7 @@ static void wa_buf_in_cb(struct urb *urb)
2602 dev = &wa->usb_iface->dev; 2602 dev = &wa->usb_iface->dev;
2603 --(wa->active_buf_in_urbs); 2603 --(wa->active_buf_in_urbs);
2604 active_buf_in_urbs = wa->active_buf_in_urbs; 2604 active_buf_in_urbs = wa->active_buf_in_urbs;
2605 rpipe = xfer->ep->hcpriv;
2605 2606
2606 if (usb_pipeisoc(xfer->urb->pipe)) { 2607 if (usb_pipeisoc(xfer->urb->pipe)) {
2607 struct usb_iso_packet_descriptor *iso_frame_desc = 2608 struct usb_iso_packet_descriptor *iso_frame_desc =
@@ -2659,7 +2660,6 @@ static void wa_buf_in_cb(struct urb *urb)
2659 resubmit_dti = (isoc_data_frame_count == 2660 resubmit_dti = (isoc_data_frame_count ==
2660 urb_frame_count); 2661 urb_frame_count);
2661 } else if (active_buf_in_urbs == 0) { 2662 } else if (active_buf_in_urbs == 0) {
2662 rpipe = xfer->ep->hcpriv;
2663 dev_dbg(dev, 2663 dev_dbg(dev,
2664 "xfer %p 0x%08X#%u: data in done (%zu bytes)\n", 2664 "xfer %p 0x%08X#%u: data in done (%zu bytes)\n",
2665 xfer, wa_xfer_id(xfer), seg->index, 2665 xfer, wa_xfer_id(xfer), seg->index,
@@ -2685,7 +2685,6 @@ static void wa_buf_in_cb(struct urb *urb)
2685 */ 2685 */
2686 resubmit_dti = wa->dti_state != WA_DTI_TRANSFER_RESULT_PENDING; 2686 resubmit_dti = wa->dti_state != WA_DTI_TRANSFER_RESULT_PENDING;
2687 spin_lock_irqsave(&xfer->lock, flags); 2687 spin_lock_irqsave(&xfer->lock, flags);
2688 rpipe = xfer->ep->hcpriv;
2689 if (printk_ratelimit()) 2688 if (printk_ratelimit())
2690 dev_err(dev, "xfer %p 0x%08X#%u: data in error %d\n", 2689 dev_err(dev, "xfer %p 0x%08X#%u: data in error %d\n",
2691 xfer, wa_xfer_id(xfer), seg->index, 2690 xfer, wa_xfer_id(xfer), seg->index,
diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
index beadd3edaa17..a7b6217ac87b 100644
--- a/drivers/video/fbdev/amba-clcd.c
+++ b/drivers/video/fbdev/amba-clcd.c
@@ -24,6 +24,7 @@
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/amba/bus.h> 25#include <linux/amba/bus.h>
26#include <linux/amba/clcd.h> 26#include <linux/amba/clcd.h>
27#include <linux/bitops.h>
27#include <linux/clk.h> 28#include <linux/clk.h>
28#include <linux/hardirq.h> 29#include <linux/hardirq.h>
29#include <linux/dma-mapping.h> 30#include <linux/dma-mapping.h>
@@ -650,6 +651,7 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
650{ 651{
651 struct device_node *endpoint; 652 struct device_node *endpoint;
652 int err; 653 int err;
654 unsigned int bpp;
653 u32 max_bandwidth; 655 u32 max_bandwidth;
654 u32 tft_r0b0g0[3]; 656 u32 tft_r0b0g0[3];
655 657
@@ -667,11 +669,22 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
667 669
668 err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth", 670 err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth",
669 &max_bandwidth); 671 &max_bandwidth);
670 if (!err) 672 if (!err) {
671 fb->panel->bpp = 8 * max_bandwidth / (fb->panel->mode.xres * 673 /*
672 fb->panel->mode.yres * fb->panel->mode.refresh); 674 * max_bandwidth is in bytes per second and pixclock in
673 else 675 * pico-seconds, so the maximum allowed bits per pixel is
674 fb->panel->bpp = 32; 676 * 8 * max_bandwidth / (PICOS2KHZ(pixclock) * 1000)
677 * Rearrange this calculation to avoid overflow and then ensure
678 * result is a valid format.
679 */
680 bpp = max_bandwidth / (1000 / 8)
681 / PICOS2KHZ(fb->panel->mode.pixclock);
682 bpp = rounddown_pow_of_two(bpp);
683 if (bpp > 32)
684 bpp = 32;
685 } else
686 bpp = 32;
687 fb->panel->bpp = bpp;
675 688
676#ifdef CONFIG_CPU_BIG_ENDIAN 689#ifdef CONFIG_CPU_BIG_ENDIAN
677 fb->panel->cntl |= CNTL_BEBO; 690 fb->panel->cntl |= CNTL_BEBO;
diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c
index 92640d46770a..1d8bdb92939b 100644
--- a/drivers/video/fbdev/atmel_lcdfb.c
+++ b/drivers/video/fbdev/atmel_lcdfb.c
@@ -1102,12 +1102,14 @@ static int atmel_lcdfb_of_init(struct atmel_lcdfb_info *sinfo)
1102 timings = of_get_display_timings(display_np); 1102 timings = of_get_display_timings(display_np);
1103 if (!timings) { 1103 if (!timings) {
1104 dev_err(dev, "failed to get display timings\n"); 1104 dev_err(dev, "failed to get display timings\n");
1105 ret = -EINVAL;
1105 goto put_display_node; 1106 goto put_display_node;
1106 } 1107 }
1107 1108
1108 timings_np = of_find_node_by_name(display_np, "display-timings"); 1109 timings_np = of_find_node_by_name(display_np, "display-timings");
1109 if (!timings_np) { 1110 if (!timings_np) {
1110 dev_err(dev, "failed to find display-timings node\n"); 1111 dev_err(dev, "failed to find display-timings node\n");
1112 ret = -ENODEV;
1111 goto put_display_node; 1113 goto put_display_node;
1112 } 1114 }
1113 1115
diff --git a/drivers/video/fbdev/chipsfb.c b/drivers/video/fbdev/chipsfb.c
index 206a66b61072..59abdc6a97f6 100644
--- a/drivers/video/fbdev/chipsfb.c
+++ b/drivers/video/fbdev/chipsfb.c
@@ -273,7 +273,7 @@ static struct chips_init_reg chips_init_xr[] = {
273 { 0xa8, 0x00 } 273 { 0xa8, 0x00 }
274}; 274};
275 275
276static void __init chips_hw_init(void) 276static void chips_hw_init(void)
277{ 277{
278 int i; 278 int i;
279 279
diff --git a/drivers/video/fbdev/da8xx-fb.c b/drivers/video/fbdev/da8xx-fb.c
index 788f6b37fce7..10c876c95772 100644
--- a/drivers/video/fbdev/da8xx-fb.c
+++ b/drivers/video/fbdev/da8xx-fb.c
@@ -419,7 +419,7 @@ static void lcd_cfg_horizontal_sync(int back_porch, int pulse_width,
419{ 419{
420 u32 reg; 420 u32 reg;
421 421
422 reg = lcdc_read(LCD_RASTER_TIMING_0_REG) & 0xf; 422 reg = lcdc_read(LCD_RASTER_TIMING_0_REG) & 0x3ff;
423 reg |= (((back_porch-1) & 0xff) << 24) 423 reg |= (((back_porch-1) & 0xff) << 24)
424 | (((front_porch-1) & 0xff) << 16) 424 | (((front_porch-1) & 0xff) << 16)
425 | (((pulse_width-1) & 0x3f) << 10); 425 | (((pulse_width-1) & 0x3f) << 10);
diff --git a/drivers/video/of_display_timing.c b/drivers/video/of_display_timing.c
index 987edf110038..5c098d5b4043 100644
--- a/drivers/video/of_display_timing.c
+++ b/drivers/video/of_display_timing.c
@@ -236,6 +236,7 @@ timingfail:
236 if (native_mode) 236 if (native_mode)
237 of_node_put(native_mode); 237 of_node_put(native_mode);
238 display_timings_release(disp); 238 display_timings_release(disp);
239 disp = NULL;
239entryfail: 240entryfail:
240 kfree(disp); 241 kfree(disp);
241dispfail: 242dispfail:
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 5b19760b1de5..b0c225cdb52c 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1825,7 +1825,7 @@ ext4_group_first_block_no(struct super_block *sb, ext4_group_t group_no)
1825/* 1825/*
1826 * Special error return code only used by dx_probe() and its callers. 1826 * Special error return code only used by dx_probe() and its callers.
1827 */ 1827 */
1828#define ERR_BAD_DX_DIR -75000 1828#define ERR_BAD_DX_DIR (-(MAX_ERRNO - 1))
1829 1829
1830/* 1830/*
1831 * Timeout and state flag for lazy initialization inode thread. 1831 * Timeout and state flag for lazy initialization inode thread.
@@ -2454,6 +2454,22 @@ static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
2454 up_write(&EXT4_I(inode)->i_data_sem); 2454 up_write(&EXT4_I(inode)->i_data_sem);
2455} 2455}
2456 2456
2457/* Update i_size, i_disksize. Requires i_mutex to avoid races with truncate */
2458static inline int ext4_update_inode_size(struct inode *inode, loff_t newsize)
2459{
2460 int changed = 0;
2461
2462 if (newsize > inode->i_size) {
2463 i_size_write(inode, newsize);
2464 changed = 1;
2465 }
2466 if (newsize > EXT4_I(inode)->i_disksize) {
2467 ext4_update_i_disksize(inode, newsize);
2468 changed |= 2;
2469 }
2470 return changed;
2471}
2472
2457struct ext4_group_info { 2473struct ext4_group_info {
2458 unsigned long bb_state; 2474 unsigned long bb_state;
2459 struct rb_root bb_free_root; 2475 struct rb_root bb_free_root;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 76c2df382b7d..74292a71b384 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4665,7 +4665,8 @@ retry:
4665} 4665}
4666 4666
4667static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset, 4667static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
4668 ext4_lblk_t len, int flags, int mode) 4668 ext4_lblk_t len, loff_t new_size,
4669 int flags, int mode)
4669{ 4670{
4670 struct inode *inode = file_inode(file); 4671 struct inode *inode = file_inode(file);
4671 handle_t *handle; 4672 handle_t *handle;
@@ -4674,8 +4675,10 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
4674 int retries = 0; 4675 int retries = 0;
4675 struct ext4_map_blocks map; 4676 struct ext4_map_blocks map;
4676 unsigned int credits; 4677 unsigned int credits;
4678 loff_t epos;
4677 4679
4678 map.m_lblk = offset; 4680 map.m_lblk = offset;
4681 map.m_len = len;
4679 /* 4682 /*
4680 * Don't normalize the request if it can fit in one extent so 4683 * Don't normalize the request if it can fit in one extent so
4681 * that it doesn't get unnecessarily split into multiple 4684 * that it doesn't get unnecessarily split into multiple
@@ -4690,9 +4693,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
4690 credits = ext4_chunk_trans_blocks(inode, len); 4693 credits = ext4_chunk_trans_blocks(inode, len);
4691 4694
4692retry: 4695retry:
4693 while (ret >= 0 && ret < len) { 4696 while (ret >= 0 && len) {
4694 map.m_lblk = map.m_lblk + ret;
4695 map.m_len = len = len - ret;
4696 handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS, 4697 handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS,
4697 credits); 4698 credits);
4698 if (IS_ERR(handle)) { 4699 if (IS_ERR(handle)) {
@@ -4709,6 +4710,21 @@ retry:
4709 ret2 = ext4_journal_stop(handle); 4710 ret2 = ext4_journal_stop(handle);
4710 break; 4711 break;
4711 } 4712 }
4713 map.m_lblk += ret;
4714 map.m_len = len = len - ret;
4715 epos = (loff_t)map.m_lblk << inode->i_blkbits;
4716 inode->i_ctime = ext4_current_time(inode);
4717 if (new_size) {
4718 if (epos > new_size)
4719 epos = new_size;
4720 if (ext4_update_inode_size(inode, epos) & 0x1)
4721 inode->i_mtime = inode->i_ctime;
4722 } else {
4723 if (epos > inode->i_size)
4724 ext4_set_inode_flag(inode,
4725 EXT4_INODE_EOFBLOCKS);
4726 }
4727 ext4_mark_inode_dirty(handle, inode);
4712 ret2 = ext4_journal_stop(handle); 4728 ret2 = ext4_journal_stop(handle);
4713 if (ret2) 4729 if (ret2)
4714 break; 4730 break;
@@ -4731,7 +4747,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4731 loff_t new_size = 0; 4747 loff_t new_size = 0;
4732 int ret = 0; 4748 int ret = 0;
4733 int flags; 4749 int flags;
4734 int partial; 4750 int credits;
4751 int partial_begin, partial_end;
4735 loff_t start, end; 4752 loff_t start, end;
4736 ext4_lblk_t lblk; 4753 ext4_lblk_t lblk;
4737 struct address_space *mapping = inode->i_mapping; 4754 struct address_space *mapping = inode->i_mapping;
@@ -4771,7 +4788,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4771 4788
4772 if (start < offset || end > offset + len) 4789 if (start < offset || end > offset + len)
4773 return -EINVAL; 4790 return -EINVAL;
4774 partial = (offset + len) & ((1 << blkbits) - 1); 4791 partial_begin = offset & ((1 << blkbits) - 1);
4792 partial_end = (offset + len) & ((1 << blkbits) - 1);
4775 4793
4776 lblk = start >> blkbits; 4794 lblk = start >> blkbits;
4777 max_blocks = (end >> blkbits); 4795 max_blocks = (end >> blkbits);
@@ -4805,7 +4823,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4805 * If we have a partial block after EOF we have to allocate 4823 * If we have a partial block after EOF we have to allocate
4806 * the entire block. 4824 * the entire block.
4807 */ 4825 */
4808 if (partial) 4826 if (partial_end)
4809 max_blocks += 1; 4827 max_blocks += 1;
4810 } 4828 }
4811 4829
@@ -4813,6 +4831,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4813 4831
4814 /* Now release the pages and zero block aligned part of pages*/ 4832 /* Now release the pages and zero block aligned part of pages*/
4815 truncate_pagecache_range(inode, start, end - 1); 4833 truncate_pagecache_range(inode, start, end - 1);
4834 inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
4816 4835
4817 /* Wait all existing dio workers, newcomers will block on i_mutex */ 4836 /* Wait all existing dio workers, newcomers will block on i_mutex */
4818 ext4_inode_block_unlocked_dio(inode); 4837 ext4_inode_block_unlocked_dio(inode);
@@ -4825,13 +4844,22 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4825 if (ret) 4844 if (ret)
4826 goto out_dio; 4845 goto out_dio;
4827 4846
4828 ret = ext4_alloc_file_blocks(file, lblk, max_blocks, flags, 4847 ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
4829 mode); 4848 flags, mode);
4830 if (ret) 4849 if (ret)
4831 goto out_dio; 4850 goto out_dio;
4832 } 4851 }
4852 if (!partial_begin && !partial_end)
4853 goto out_dio;
4833 4854
4834 handle = ext4_journal_start(inode, EXT4_HT_MISC, 4); 4855 /*
4856 * In worst case we have to writeout two nonadjacent unwritten
4857 * blocks and update the inode
4858 */
4859 credits = (2 * ext4_ext_index_trans_blocks(inode, 2)) + 1;
4860 if (ext4_should_journal_data(inode))
4861 credits += 2;
4862 handle = ext4_journal_start(inode, EXT4_HT_MISC, credits);
4835 if (IS_ERR(handle)) { 4863 if (IS_ERR(handle)) {
4836 ret = PTR_ERR(handle); 4864 ret = PTR_ERR(handle);
4837 ext4_std_error(inode->i_sb, ret); 4865 ext4_std_error(inode->i_sb, ret);
@@ -4839,12 +4867,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4839 } 4867 }
4840 4868
4841 inode->i_mtime = inode->i_ctime = ext4_current_time(inode); 4869 inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
4842
4843 if (new_size) { 4870 if (new_size) {
4844 if (new_size > i_size_read(inode)) 4871 ext4_update_inode_size(inode, new_size);
4845 i_size_write(inode, new_size);
4846 if (new_size > EXT4_I(inode)->i_disksize)
4847 ext4_update_i_disksize(inode, new_size);
4848 } else { 4872 } else {
4849 /* 4873 /*
4850 * Mark that we allocate beyond EOF so the subsequent truncate 4874 * Mark that we allocate beyond EOF so the subsequent truncate
@@ -4853,7 +4877,6 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4853 if ((offset + len) > i_size_read(inode)) 4877 if ((offset + len) > i_size_read(inode))
4854 ext4_set_inode_flag(inode, EXT4_INODE_EOFBLOCKS); 4878 ext4_set_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
4855 } 4879 }
4856
4857 ext4_mark_inode_dirty(handle, inode); 4880 ext4_mark_inode_dirty(handle, inode);
4858 4881
4859 /* Zero out partial block at the edges of the range */ 4882 /* Zero out partial block at the edges of the range */
@@ -4880,13 +4903,11 @@ out_mutex:
4880long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) 4903long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
4881{ 4904{
4882 struct inode *inode = file_inode(file); 4905 struct inode *inode = file_inode(file);
4883 handle_t *handle;
4884 loff_t new_size = 0; 4906 loff_t new_size = 0;
4885 unsigned int max_blocks; 4907 unsigned int max_blocks;
4886 int ret = 0; 4908 int ret = 0;
4887 int flags; 4909 int flags;
4888 ext4_lblk_t lblk; 4910 ext4_lblk_t lblk;
4889 struct timespec tv;
4890 unsigned int blkbits = inode->i_blkbits; 4911 unsigned int blkbits = inode->i_blkbits;
4891 4912
4892 /* Return error if mode is not supported */ 4913 /* Return error if mode is not supported */
@@ -4937,36 +4958,15 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
4937 goto out; 4958 goto out;
4938 } 4959 }
4939 4960
4940 ret = ext4_alloc_file_blocks(file, lblk, max_blocks, flags, mode); 4961 ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
4962 flags, mode);
4941 if (ret) 4963 if (ret)
4942 goto out; 4964 goto out;
4943 4965
4944 handle = ext4_journal_start(inode, EXT4_HT_INODE, 2); 4966 if (file->f_flags & O_SYNC && EXT4_SB(inode->i_sb)->s_journal) {
4945 if (IS_ERR(handle)) 4967 ret = jbd2_complete_transaction(EXT4_SB(inode->i_sb)->s_journal,
4946 goto out; 4968 EXT4_I(inode)->i_sync_tid);
4947
4948 tv = inode->i_ctime = ext4_current_time(inode);
4949
4950 if (new_size) {
4951 if (new_size > i_size_read(inode)) {
4952 i_size_write(inode, new_size);
4953 inode->i_mtime = tv;
4954 }
4955 if (new_size > EXT4_I(inode)->i_disksize)
4956 ext4_update_i_disksize(inode, new_size);
4957 } else {
4958 /*
4959 * Mark that we allocate beyond EOF so the subsequent truncate
4960 * can proceed even if the new size is the same as i_size.
4961 */
4962 if ((offset + len) > i_size_read(inode))
4963 ext4_set_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
4964 } 4969 }
4965 ext4_mark_inode_dirty(handle, inode);
4966 if (file->f_flags & O_SYNC)
4967 ext4_handle_sync(handle);
4968
4969 ext4_journal_stop(handle);
4970out: 4970out:
4971 mutex_unlock(&inode->i_mutex); 4971 mutex_unlock(&inode->i_mutex);
4972 trace_ext4_fallocate_exit(inode, offset, max_blocks, ret); 4972 trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 367a60c07cf0..3aa26e9117c4 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1055,27 +1055,11 @@ static int ext4_write_end(struct file *file,
1055 } else 1055 } else
1056 copied = block_write_end(file, mapping, pos, 1056 copied = block_write_end(file, mapping, pos,
1057 len, copied, page, fsdata); 1057 len, copied, page, fsdata);
1058
1059 /* 1058 /*
1060 * No need to use i_size_read() here, the i_size 1059 * it's important to update i_size while still holding page lock:
1061 * cannot change under us because we hole i_mutex.
1062 *
1063 * But it's important to update i_size while still holding page lock:
1064 * page writeout could otherwise come in and zero beyond i_size. 1060 * page writeout could otherwise come in and zero beyond i_size.
1065 */ 1061 */
1066 if (pos + copied > inode->i_size) { 1062 i_size_changed = ext4_update_inode_size(inode, pos + copied);
1067 i_size_write(inode, pos + copied);
1068 i_size_changed = 1;
1069 }
1070
1071 if (pos + copied > EXT4_I(inode)->i_disksize) {
1072 /* We need to mark inode dirty even if
1073 * new_i_size is less that inode->i_size
1074 * but greater than i_disksize. (hint delalloc)
1075 */
1076 ext4_update_i_disksize(inode, (pos + copied));
1077 i_size_changed = 1;
1078 }
1079 unlock_page(page); 1063 unlock_page(page);
1080 page_cache_release(page); 1064 page_cache_release(page);
1081 1065
@@ -1123,7 +1107,7 @@ static int ext4_journalled_write_end(struct file *file,
1123 int ret = 0, ret2; 1107 int ret = 0, ret2;
1124 int partial = 0; 1108 int partial = 0;
1125 unsigned from, to; 1109 unsigned from, to;
1126 loff_t new_i_size; 1110 int size_changed = 0;
1127 1111
1128 trace_ext4_journalled_write_end(inode, pos, len, copied); 1112 trace_ext4_journalled_write_end(inode, pos, len, copied);
1129 from = pos & (PAGE_CACHE_SIZE - 1); 1113 from = pos & (PAGE_CACHE_SIZE - 1);
@@ -1146,20 +1130,18 @@ static int ext4_journalled_write_end(struct file *file,
1146 if (!partial) 1130 if (!partial)
1147 SetPageUptodate(page); 1131 SetPageUptodate(page);
1148 } 1132 }
1149 new_i_size = pos + copied; 1133 size_changed = ext4_update_inode_size(inode, pos + copied);
1150 if (new_i_size > inode->i_size)
1151 i_size_write(inode, pos+copied);
1152 ext4_set_inode_state(inode, EXT4_STATE_JDATA); 1134 ext4_set_inode_state(inode, EXT4_STATE_JDATA);
1153 EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid; 1135 EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid;
1154 if (new_i_size > EXT4_I(inode)->i_disksize) { 1136 unlock_page(page);
1155 ext4_update_i_disksize(inode, new_i_size); 1137 page_cache_release(page);
1138
1139 if (size_changed) {
1156 ret2 = ext4_mark_inode_dirty(handle, inode); 1140 ret2 = ext4_mark_inode_dirty(handle, inode);
1157 if (!ret) 1141 if (!ret)
1158 ret = ret2; 1142 ret = ret2;
1159 } 1143 }
1160 1144
1161 unlock_page(page);
1162 page_cache_release(page);
1163 if (pos + len > inode->i_size && ext4_can_truncate(inode)) 1145 if (pos + len > inode->i_size && ext4_can_truncate(inode))
1164 /* if we have allocated more blocks and copied 1146 /* if we have allocated more blocks and copied
1165 * less. We will have blocks allocated outside 1147 * less. We will have blocks allocated outside
@@ -2095,6 +2077,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
2095 struct ext4_map_blocks *map = &mpd->map; 2077 struct ext4_map_blocks *map = &mpd->map;
2096 int err; 2078 int err;
2097 loff_t disksize; 2079 loff_t disksize;
2080 int progress = 0;
2098 2081
2099 mpd->io_submit.io_end->offset = 2082 mpd->io_submit.io_end->offset =
2100 ((loff_t)map->m_lblk) << inode->i_blkbits; 2083 ((loff_t)map->m_lblk) << inode->i_blkbits;
@@ -2111,8 +2094,11 @@ static int mpage_map_and_submit_extent(handle_t *handle,
2111 * is non-zero, a commit should free up blocks. 2094 * is non-zero, a commit should free up blocks.
2112 */ 2095 */
2113 if ((err == -ENOMEM) || 2096 if ((err == -ENOMEM) ||
2114 (err == -ENOSPC && ext4_count_free_clusters(sb))) 2097 (err == -ENOSPC && ext4_count_free_clusters(sb))) {
2098 if (progress)
2099 goto update_disksize;
2115 return err; 2100 return err;
2101 }
2116 ext4_msg(sb, KERN_CRIT, 2102 ext4_msg(sb, KERN_CRIT,
2117 "Delayed block allocation failed for " 2103 "Delayed block allocation failed for "
2118 "inode %lu at logical offset %llu with" 2104 "inode %lu at logical offset %llu with"
@@ -2129,15 +2115,17 @@ static int mpage_map_and_submit_extent(handle_t *handle,
2129 *give_up_on_write = true; 2115 *give_up_on_write = true;
2130 return err; 2116 return err;
2131 } 2117 }
2118 progress = 1;
2132 /* 2119 /*
2133 * Update buffer state, submit mapped pages, and get us new 2120 * Update buffer state, submit mapped pages, and get us new
2134 * extent to map 2121 * extent to map
2135 */ 2122 */
2136 err = mpage_map_and_submit_buffers(mpd); 2123 err = mpage_map_and_submit_buffers(mpd);
2137 if (err < 0) 2124 if (err < 0)
2138 return err; 2125 goto update_disksize;
2139 } while (map->m_len); 2126 } while (map->m_len);
2140 2127
2128update_disksize:
2141 /* 2129 /*
2142 * Update on-disk size after IO is submitted. Races with 2130 * Update on-disk size after IO is submitted. Races with
2143 * truncate are avoided by checking i_size under i_data_sem. 2131 * truncate are avoided by checking i_size under i_data_sem.
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 956027711faf..8b0f9ef517d6 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1412,6 +1412,8 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
1412 int last = first + count - 1; 1412 int last = first + count - 1;
1413 struct super_block *sb = e4b->bd_sb; 1413 struct super_block *sb = e4b->bd_sb;
1414 1414
1415 if (WARN_ON(count == 0))
1416 return;
1415 BUG_ON(last >= (sb->s_blocksize << 3)); 1417 BUG_ON(last >= (sb->s_blocksize << 3));
1416 assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group)); 1418 assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group));
1417 /* Don't bother if the block group is corrupt. */ 1419 /* Don't bother if the block group is corrupt. */
@@ -3221,6 +3223,8 @@ static void ext4_discard_allocated_blocks(struct ext4_allocation_context *ac)
3221 int err; 3223 int err;
3222 3224
3223 if (pa == NULL) { 3225 if (pa == NULL) {
3226 if (ac->ac_f_ex.fe_len == 0)
3227 return;
3224 err = ext4_mb_load_buddy(ac->ac_sb, ac->ac_f_ex.fe_group, &e4b); 3228 err = ext4_mb_load_buddy(ac->ac_sb, ac->ac_f_ex.fe_group, &e4b);
3225 if (err) { 3229 if (err) {
3226 /* 3230 /*
@@ -3235,6 +3239,7 @@ static void ext4_discard_allocated_blocks(struct ext4_allocation_context *ac)
3235 mb_free_blocks(ac->ac_inode, &e4b, ac->ac_f_ex.fe_start, 3239 mb_free_blocks(ac->ac_inode, &e4b, ac->ac_f_ex.fe_start,
3236 ac->ac_f_ex.fe_len); 3240 ac->ac_f_ex.fe_len);
3237 ext4_unlock_group(ac->ac_sb, ac->ac_f_ex.fe_group); 3241 ext4_unlock_group(ac->ac_sb, ac->ac_f_ex.fe_group);
3242 ext4_mb_unload_buddy(&e4b);
3238 return; 3243 return;
3239 } 3244 }
3240 if (pa->pa_type == MB_INODE_PA) 3245 if (pa->pa_type == MB_INODE_PA)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index b147a67baa0d..90a3cdca3f88 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1227,7 +1227,7 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
1227 buffer */ 1227 buffer */
1228 int num = 0; 1228 int num = 0;
1229 ext4_lblk_t nblocks; 1229 ext4_lblk_t nblocks;
1230 int i, err; 1230 int i, err = 0;
1231 int namelen; 1231 int namelen;
1232 1232
1233 *res_dir = NULL; 1233 *res_dir = NULL;
@@ -1264,7 +1264,11 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
1264 * return. Otherwise, fall back to doing a search the 1264 * return. Otherwise, fall back to doing a search the
1265 * old fashioned way. 1265 * old fashioned way.
1266 */ 1266 */
1267 if (bh || (err != ERR_BAD_DX_DIR)) 1267 if (err == -ENOENT)
1268 return NULL;
1269 if (err && err != ERR_BAD_DX_DIR)
1270 return ERR_PTR(err);
1271 if (bh)
1268 return bh; 1272 return bh;
1269 dxtrace(printk(KERN_DEBUG "ext4_find_entry: dx failed, " 1273 dxtrace(printk(KERN_DEBUG "ext4_find_entry: dx failed, "
1270 "falling back\n")); 1274 "falling back\n"));
@@ -1295,6 +1299,11 @@ restart:
1295 } 1299 }
1296 num++; 1300 num++;
1297 bh = ext4_getblk(NULL, dir, b++, 0, &err); 1301 bh = ext4_getblk(NULL, dir, b++, 0, &err);
1302 if (unlikely(err)) {
1303 if (ra_max == 0)
1304 return ERR_PTR(err);
1305 break;
1306 }
1298 bh_use[ra_max] = bh; 1307 bh_use[ra_max] = bh;
1299 if (bh) 1308 if (bh)
1300 ll_rw_block(READ | REQ_META | REQ_PRIO, 1309 ll_rw_block(READ | REQ_META | REQ_PRIO,
@@ -1417,6 +1426,8 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
1417 return ERR_PTR(-ENAMETOOLONG); 1426 return ERR_PTR(-ENAMETOOLONG);
1418 1427
1419 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL); 1428 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL);
1429 if (IS_ERR(bh))
1430 return (struct dentry *) bh;
1420 inode = NULL; 1431 inode = NULL;
1421 if (bh) { 1432 if (bh) {
1422 __u32 ino = le32_to_cpu(de->inode); 1433 __u32 ino = le32_to_cpu(de->inode);
@@ -1450,6 +1461,8 @@ struct dentry *ext4_get_parent(struct dentry *child)
1450 struct buffer_head *bh; 1461 struct buffer_head *bh;
1451 1462
1452 bh = ext4_find_entry(child->d_inode, &dotdot, &de, NULL); 1463 bh = ext4_find_entry(child->d_inode, &dotdot, &de, NULL);
1464 if (IS_ERR(bh))
1465 return (struct dentry *) bh;
1453 if (!bh) 1466 if (!bh)
1454 return ERR_PTR(-ENOENT); 1467 return ERR_PTR(-ENOENT);
1455 ino = le32_to_cpu(de->inode); 1468 ino = le32_to_cpu(de->inode);
@@ -2727,6 +2740,8 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
2727 2740
2728 retval = -ENOENT; 2741 retval = -ENOENT;
2729 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL); 2742 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL);
2743 if (IS_ERR(bh))
2744 return PTR_ERR(bh);
2730 if (!bh) 2745 if (!bh)
2731 goto end_rmdir; 2746 goto end_rmdir;
2732 2747
@@ -2794,6 +2809,8 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
2794 2809
2795 retval = -ENOENT; 2810 retval = -ENOENT;
2796 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL); 2811 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL);
2812 if (IS_ERR(bh))
2813 return PTR_ERR(bh);
2797 if (!bh) 2814 if (!bh)
2798 goto end_unlink; 2815 goto end_unlink;
2799 2816
@@ -3121,6 +3138,8 @@ static int ext4_find_delete_entry(handle_t *handle, struct inode *dir,
3121 struct ext4_dir_entry_2 *de; 3138 struct ext4_dir_entry_2 *de;
3122 3139
3123 bh = ext4_find_entry(dir, d_name, &de, NULL); 3140 bh = ext4_find_entry(dir, d_name, &de, NULL);
3141 if (IS_ERR(bh))
3142 return PTR_ERR(bh);
3124 if (bh) { 3143 if (bh) {
3125 retval = ext4_delete_entry(handle, dir, de, bh); 3144 retval = ext4_delete_entry(handle, dir, de, bh);
3126 brelse(bh); 3145 brelse(bh);
@@ -3128,7 +3147,8 @@ static int ext4_find_delete_entry(handle_t *handle, struct inode *dir,
3128 return retval; 3147 return retval;
3129} 3148}
3130 3149
3131static void ext4_rename_delete(handle_t *handle, struct ext4_renament *ent) 3150static void ext4_rename_delete(handle_t *handle, struct ext4_renament *ent,
3151 int force_reread)
3132{ 3152{
3133 int retval; 3153 int retval;
3134 /* 3154 /*
@@ -3140,7 +3160,8 @@ static void ext4_rename_delete(handle_t *handle, struct ext4_renament *ent)
3140 if (le32_to_cpu(ent->de->inode) != ent->inode->i_ino || 3160 if (le32_to_cpu(ent->de->inode) != ent->inode->i_ino ||
3141 ent->de->name_len != ent->dentry->d_name.len || 3161 ent->de->name_len != ent->dentry->d_name.len ||
3142 strncmp(ent->de->name, ent->dentry->d_name.name, 3162 strncmp(ent->de->name, ent->dentry->d_name.name,
3143 ent->de->name_len)) { 3163 ent->de->name_len) ||
3164 force_reread) {
3144 retval = ext4_find_delete_entry(handle, ent->dir, 3165 retval = ext4_find_delete_entry(handle, ent->dir,
3145 &ent->dentry->d_name); 3166 &ent->dentry->d_name);
3146 } else { 3167 } else {
@@ -3191,6 +3212,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3191 .dentry = new_dentry, 3212 .dentry = new_dentry,
3192 .inode = new_dentry->d_inode, 3213 .inode = new_dentry->d_inode,
3193 }; 3214 };
3215 int force_reread;
3194 int retval; 3216 int retval;
3195 3217
3196 dquot_initialize(old.dir); 3218 dquot_initialize(old.dir);
@@ -3202,6 +3224,8 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3202 dquot_initialize(new.inode); 3224 dquot_initialize(new.inode);
3203 3225
3204 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, NULL); 3226 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, NULL);
3227 if (IS_ERR(old.bh))
3228 return PTR_ERR(old.bh);
3205 /* 3229 /*
3206 * Check for inode number is _not_ due to possible IO errors. 3230 * Check for inode number is _not_ due to possible IO errors.
3207 * We might rmdir the source, keep it as pwd of some process 3231 * We might rmdir the source, keep it as pwd of some process
@@ -3214,6 +3238,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3214 3238
3215 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, 3239 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name,
3216 &new.de, &new.inlined); 3240 &new.de, &new.inlined);
3241 if (IS_ERR(new.bh)) {
3242 retval = PTR_ERR(new.bh);
3243 goto end_rename;
3244 }
3217 if (new.bh) { 3245 if (new.bh) {
3218 if (!new.inode) { 3246 if (!new.inode) {
3219 brelse(new.bh); 3247 brelse(new.bh);
@@ -3246,6 +3274,15 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3246 if (retval) 3274 if (retval)
3247 goto end_rename; 3275 goto end_rename;
3248 } 3276 }
3277 /*
3278 * If we're renaming a file within an inline_data dir and adding or
3279 * setting the new dirent causes a conversion from inline_data to
3280 * extents/blockmap, we need to force the dirent delete code to
3281 * re-read the directory, or else we end up trying to delete a dirent
3282 * from what is now the extent tree root (or a block map).
3283 */
3284 force_reread = (new.dir->i_ino == old.dir->i_ino &&
3285 ext4_test_inode_flag(new.dir, EXT4_INODE_INLINE_DATA));
3249 if (!new.bh) { 3286 if (!new.bh) {
3250 retval = ext4_add_entry(handle, new.dentry, old.inode); 3287 retval = ext4_add_entry(handle, new.dentry, old.inode);
3251 if (retval) 3288 if (retval)
@@ -3256,6 +3293,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3256 if (retval) 3293 if (retval)
3257 goto end_rename; 3294 goto end_rename;
3258 } 3295 }
3296 if (force_reread)
3297 force_reread = !ext4_test_inode_flag(new.dir,
3298 EXT4_INODE_INLINE_DATA);
3259 3299
3260 /* 3300 /*
3261 * Like most other Unix systems, set the ctime for inodes on a 3301 * Like most other Unix systems, set the ctime for inodes on a
@@ -3267,7 +3307,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3267 /* 3307 /*
3268 * ok, that's it 3308 * ok, that's it
3269 */ 3309 */
3270 ext4_rename_delete(handle, &old); 3310 ext4_rename_delete(handle, &old, force_reread);
3271 3311
3272 if (new.inode) { 3312 if (new.inode) {
3273 ext4_dec_count(handle, new.inode); 3313 ext4_dec_count(handle, new.inode);
@@ -3330,6 +3370,8 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
3330 3370
3331 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, 3371 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name,
3332 &old.de, &old.inlined); 3372 &old.de, &old.inlined);
3373 if (IS_ERR(old.bh))
3374 return PTR_ERR(old.bh);
3333 /* 3375 /*
3334 * Check for inode number is _not_ due to possible IO errors. 3376 * Check for inode number is _not_ due to possible IO errors.
3335 * We might rmdir the source, keep it as pwd of some process 3377 * We might rmdir the source, keep it as pwd of some process
@@ -3342,6 +3384,10 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
3342 3384
3343 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, 3385 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name,
3344 &new.de, &new.inlined); 3386 &new.de, &new.inlined);
3387 if (IS_ERR(new.bh)) {
3388 retval = PTR_ERR(new.bh);
3389 goto end_rename;
3390 }
3345 3391
3346 /* RENAME_EXCHANGE case: old *and* new must both exist */ 3392 /* RENAME_EXCHANGE case: old *and* new must both exist */
3347 if (!new.bh || le32_to_cpu(new.de->inode) != new.inode->i_ino) 3393 if (!new.bh || le32_to_cpu(new.de->inode) != new.inode->i_ino)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 32b43ad154b9..0b28b36e7915 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3181,9 +3181,9 @@ static int set_journal_csum_feature_set(struct super_block *sb)
3181 3181
3182 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 3182 if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
3183 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) { 3183 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
3184 /* journal checksum v2 */ 3184 /* journal checksum v3 */
3185 compat = 0; 3185 compat = 0;
3186 incompat = JBD2_FEATURE_INCOMPAT_CSUM_V2; 3186 incompat = JBD2_FEATURE_INCOMPAT_CSUM_V3;
3187 } else { 3187 } else {
3188 /* journal checksum v1 */ 3188 /* journal checksum v1 */
3189 compat = JBD2_FEATURE_COMPAT_CHECKSUM; 3189 compat = JBD2_FEATURE_COMPAT_CHECKSUM;
@@ -3205,6 +3205,7 @@ static int set_journal_csum_feature_set(struct super_block *sb)
3205 jbd2_journal_clear_features(sbi->s_journal, 3205 jbd2_journal_clear_features(sbi->s_journal,
3206 JBD2_FEATURE_COMPAT_CHECKSUM, 0, 3206 JBD2_FEATURE_COMPAT_CHECKSUM, 0,
3207 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | 3207 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT |
3208 JBD2_FEATURE_INCOMPAT_CSUM_V3 |
3208 JBD2_FEATURE_INCOMPAT_CSUM_V2); 3209 JBD2_FEATURE_INCOMPAT_CSUM_V2);
3209 } 3210 }
3210 3211
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 6fac74349856..b73e0215baa7 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -97,7 +97,7 @@ static void jbd2_commit_block_csum_set(journal_t *j, struct buffer_head *bh)
97 struct commit_header *h; 97 struct commit_header *h;
98 __u32 csum; 98 __u32 csum;
99 99
100 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 100 if (!jbd2_journal_has_csum_v2or3(j))
101 return; 101 return;
102 102
103 h = (struct commit_header *)(bh->b_data); 103 h = (struct commit_header *)(bh->b_data);
@@ -313,11 +313,11 @@ static __u32 jbd2_checksum_data(__u32 crc32_sum, struct buffer_head *bh)
313 return checksum; 313 return checksum;
314} 314}
315 315
316static void write_tag_block(int tag_bytes, journal_block_tag_t *tag, 316static void write_tag_block(journal_t *j, journal_block_tag_t *tag,
317 unsigned long long block) 317 unsigned long long block)
318{ 318{
319 tag->t_blocknr = cpu_to_be32(block & (u32)~0); 319 tag->t_blocknr = cpu_to_be32(block & (u32)~0);
320 if (tag_bytes > JBD2_TAG_SIZE32) 320 if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_64BIT))
321 tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1); 321 tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1);
322} 322}
323 323
@@ -327,7 +327,7 @@ static void jbd2_descr_block_csum_set(journal_t *j,
327 struct jbd2_journal_block_tail *tail; 327 struct jbd2_journal_block_tail *tail;
328 __u32 csum; 328 __u32 csum;
329 329
330 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 330 if (!jbd2_journal_has_csum_v2or3(j))
331 return; 331 return;
332 332
333 tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize - 333 tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize -
@@ -340,12 +340,13 @@ static void jbd2_descr_block_csum_set(journal_t *j,
340static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag, 340static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
341 struct buffer_head *bh, __u32 sequence) 341 struct buffer_head *bh, __u32 sequence)
342{ 342{
343 journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag;
343 struct page *page = bh->b_page; 344 struct page *page = bh->b_page;
344 __u8 *addr; 345 __u8 *addr;
345 __u32 csum32; 346 __u32 csum32;
346 __be32 seq; 347 __be32 seq;
347 348
348 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 349 if (!jbd2_journal_has_csum_v2or3(j))
349 return; 350 return;
350 351
351 seq = cpu_to_be32(sequence); 352 seq = cpu_to_be32(sequence);
@@ -355,8 +356,10 @@ static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
355 bh->b_size); 356 bh->b_size);
356 kunmap_atomic(addr); 357 kunmap_atomic(addr);
357 358
358 /* We only have space to store the lower 16 bits of the crc32c. */ 359 if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3))
359 tag->t_checksum = cpu_to_be16(csum32); 360 tag3->t_checksum = cpu_to_be32(csum32);
361 else
362 tag->t_checksum = cpu_to_be16(csum32);
360} 363}
361/* 364/*
362 * jbd2_journal_commit_transaction 365 * jbd2_journal_commit_transaction
@@ -396,7 +399,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
396 LIST_HEAD(io_bufs); 399 LIST_HEAD(io_bufs);
397 LIST_HEAD(log_bufs); 400 LIST_HEAD(log_bufs);
398 401
399 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 402 if (jbd2_journal_has_csum_v2or3(journal))
400 csum_size = sizeof(struct jbd2_journal_block_tail); 403 csum_size = sizeof(struct jbd2_journal_block_tail);
401 404
402 /* 405 /*
@@ -690,7 +693,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
690 tag_flag |= JBD2_FLAG_SAME_UUID; 693 tag_flag |= JBD2_FLAG_SAME_UUID;
691 694
692 tag = (journal_block_tag_t *) tagp; 695 tag = (journal_block_tag_t *) tagp;
693 write_tag_block(tag_bytes, tag, jh2bh(jh)->b_blocknr); 696 write_tag_block(journal, tag, jh2bh(jh)->b_blocknr);
694 tag->t_flags = cpu_to_be16(tag_flag); 697 tag->t_flags = cpu_to_be16(tag_flag);
695 jbd2_block_tag_csum_set(journal, tag, wbuf[bufs], 698 jbd2_block_tag_csum_set(journal, tag, wbuf[bufs],
696 commit_transaction->t_tid); 699 commit_transaction->t_tid);
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 67b8e303946c..19d74d86d99c 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -124,7 +124,7 @@ EXPORT_SYMBOL(__jbd2_debug);
124/* Checksumming functions */ 124/* Checksumming functions */
125static int jbd2_verify_csum_type(journal_t *j, journal_superblock_t *sb) 125static int jbd2_verify_csum_type(journal_t *j, journal_superblock_t *sb)
126{ 126{
127 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 127 if (!jbd2_journal_has_csum_v2or3(j))
128 return 1; 128 return 1;
129 129
130 return sb->s_checksum_type == JBD2_CRC32C_CHKSUM; 130 return sb->s_checksum_type == JBD2_CRC32C_CHKSUM;
@@ -145,7 +145,7 @@ static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb)
145 145
146static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb) 146static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb)
147{ 147{
148 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 148 if (!jbd2_journal_has_csum_v2or3(j))
149 return 1; 149 return 1;
150 150
151 return sb->s_checksum == jbd2_superblock_csum(j, sb); 151 return sb->s_checksum == jbd2_superblock_csum(j, sb);
@@ -153,7 +153,7 @@ static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb)
153 153
154static void jbd2_superblock_csum_set(journal_t *j, journal_superblock_t *sb) 154static void jbd2_superblock_csum_set(journal_t *j, journal_superblock_t *sb)
155{ 155{
156 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 156 if (!jbd2_journal_has_csum_v2or3(j))
157 return; 157 return;
158 158
159 sb->s_checksum = jbd2_superblock_csum(j, sb); 159 sb->s_checksum = jbd2_superblock_csum(j, sb);
@@ -1522,21 +1522,29 @@ static int journal_get_superblock(journal_t *journal)
1522 goto out; 1522 goto out;
1523 } 1523 }
1524 1524
1525 if (JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM) && 1525 if (jbd2_journal_has_csum_v2or3(journal) &&
1526 JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) { 1526 JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM)) {
1527 /* Can't have checksum v1 and v2 on at the same time! */ 1527 /* Can't have checksum v1 and v2 on at the same time! */
1528 printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2 " 1528 printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2 "
1529 "at the same time!\n"); 1529 "at the same time!\n");
1530 goto out; 1530 goto out;
1531 } 1531 }
1532 1532
1533 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) &&
1534 JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
1535 /* Can't have checksum v2 and v3 at the same time! */
1536 printk(KERN_ERR "JBD2: Can't enable checksumming v2 and v3 "
1537 "at the same time!\n");
1538 goto out;
1539 }
1540
1533 if (!jbd2_verify_csum_type(journal, sb)) { 1541 if (!jbd2_verify_csum_type(journal, sb)) {
1534 printk(KERN_ERR "JBD2: Unknown checksum type\n"); 1542 printk(KERN_ERR "JBD2: Unknown checksum type\n");
1535 goto out; 1543 goto out;
1536 } 1544 }
1537 1545
1538 /* Load the checksum driver */ 1546 /* Load the checksum driver */
1539 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) { 1547 if (jbd2_journal_has_csum_v2or3(journal)) {
1540 journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0); 1548 journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
1541 if (IS_ERR(journal->j_chksum_driver)) { 1549 if (IS_ERR(journal->j_chksum_driver)) {
1542 printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n"); 1550 printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n");
@@ -1553,7 +1561,7 @@ static int journal_get_superblock(journal_t *journal)
1553 } 1561 }
1554 1562
1555 /* Precompute checksum seed for all metadata */ 1563 /* Precompute checksum seed for all metadata */
1556 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 1564 if (jbd2_journal_has_csum_v2or3(journal))
1557 journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid, 1565 journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid,
1558 sizeof(sb->s_uuid)); 1566 sizeof(sb->s_uuid));
1559 1567
@@ -1813,8 +1821,14 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
1813 if (!jbd2_journal_check_available_features(journal, compat, ro, incompat)) 1821 if (!jbd2_journal_check_available_features(journal, compat, ro, incompat))
1814 return 0; 1822 return 0;
1815 1823
1816 /* Asking for checksumming v2 and v1? Only give them v2. */ 1824 /* If enabling v2 checksums, turn on v3 instead */
1817 if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V2 && 1825 if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V2) {
1826 incompat &= ~JBD2_FEATURE_INCOMPAT_CSUM_V2;
1827 incompat |= JBD2_FEATURE_INCOMPAT_CSUM_V3;
1828 }
1829
1830 /* Asking for checksumming v3 and v1? Only give them v3. */
1831 if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V3 &&
1818 compat & JBD2_FEATURE_COMPAT_CHECKSUM) 1832 compat & JBD2_FEATURE_COMPAT_CHECKSUM)
1819 compat &= ~JBD2_FEATURE_COMPAT_CHECKSUM; 1833 compat &= ~JBD2_FEATURE_COMPAT_CHECKSUM;
1820 1834
@@ -1823,8 +1837,8 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
1823 1837
1824 sb = journal->j_superblock; 1838 sb = journal->j_superblock;
1825 1839
1826 /* If enabling v2 checksums, update superblock */ 1840 /* If enabling v3 checksums, update superblock */
1827 if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V2)) { 1841 if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
1828 sb->s_checksum_type = JBD2_CRC32C_CHKSUM; 1842 sb->s_checksum_type = JBD2_CRC32C_CHKSUM;
1829 sb->s_feature_compat &= 1843 sb->s_feature_compat &=
1830 ~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM); 1844 ~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM);
@@ -1842,8 +1856,7 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
1842 } 1856 }
1843 1857
1844 /* Precompute checksum seed for all metadata */ 1858 /* Precompute checksum seed for all metadata */
1845 if (JBD2_HAS_INCOMPAT_FEATURE(journal, 1859 if (jbd2_journal_has_csum_v2or3(journal))
1846 JBD2_FEATURE_INCOMPAT_CSUM_V2))
1847 journal->j_csum_seed = jbd2_chksum(journal, ~0, 1860 journal->j_csum_seed = jbd2_chksum(journal, ~0,
1848 sb->s_uuid, 1861 sb->s_uuid,
1849 sizeof(sb->s_uuid)); 1862 sizeof(sb->s_uuid));
@@ -1852,7 +1865,8 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
1852 /* If enabling v1 checksums, downgrade superblock */ 1865 /* If enabling v1 checksums, downgrade superblock */
1853 if (COMPAT_FEATURE_ON(JBD2_FEATURE_COMPAT_CHECKSUM)) 1866 if (COMPAT_FEATURE_ON(JBD2_FEATURE_COMPAT_CHECKSUM))
1854 sb->s_feature_incompat &= 1867 sb->s_feature_incompat &=
1855 ~cpu_to_be32(JBD2_FEATURE_INCOMPAT_CSUM_V2); 1868 ~cpu_to_be32(JBD2_FEATURE_INCOMPAT_CSUM_V2 |
1869 JBD2_FEATURE_INCOMPAT_CSUM_V3);
1856 1870
1857 sb->s_feature_compat |= cpu_to_be32(compat); 1871 sb->s_feature_compat |= cpu_to_be32(compat);
1858 sb->s_feature_ro_compat |= cpu_to_be32(ro); 1872 sb->s_feature_ro_compat |= cpu_to_be32(ro);
@@ -2165,16 +2179,20 @@ int jbd2_journal_blocks_per_page(struct inode *inode)
2165 */ 2179 */
2166size_t journal_tag_bytes(journal_t *journal) 2180size_t journal_tag_bytes(journal_t *journal)
2167{ 2181{
2168 journal_block_tag_t tag; 2182 size_t sz;
2169 size_t x = 0; 2183
2184 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3))
2185 return sizeof(journal_block_tag3_t);
2186
2187 sz = sizeof(journal_block_tag_t);
2170 2188
2171 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 2189 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
2172 x += sizeof(tag.t_checksum); 2190 sz += sizeof(__u16);
2173 2191
2174 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT)) 2192 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
2175 return x + JBD2_TAG_SIZE64; 2193 return sz;
2176 else 2194 else
2177 return x + JBD2_TAG_SIZE32; 2195 return sz - sizeof(__u32);
2178} 2196}
2179 2197
2180/* 2198/*
diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
index 3b6bb19d60b1..9b329b55ffe3 100644
--- a/fs/jbd2/recovery.c
+++ b/fs/jbd2/recovery.c
@@ -181,7 +181,7 @@ static int jbd2_descr_block_csum_verify(journal_t *j,
181 __be32 provided; 181 __be32 provided;
182 __u32 calculated; 182 __u32 calculated;
183 183
184 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 184 if (!jbd2_journal_has_csum_v2or3(j))
185 return 1; 185 return 1;
186 186
187 tail = (struct jbd2_journal_block_tail *)(buf + j->j_blocksize - 187 tail = (struct jbd2_journal_block_tail *)(buf + j->j_blocksize -
@@ -205,7 +205,7 @@ static int count_tags(journal_t *journal, struct buffer_head *bh)
205 int nr = 0, size = journal->j_blocksize; 205 int nr = 0, size = journal->j_blocksize;
206 int tag_bytes = journal_tag_bytes(journal); 206 int tag_bytes = journal_tag_bytes(journal);
207 207
208 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 208 if (jbd2_journal_has_csum_v2or3(journal))
209 size -= sizeof(struct jbd2_journal_block_tail); 209 size -= sizeof(struct jbd2_journal_block_tail);
210 210
211 tagp = &bh->b_data[sizeof(journal_header_t)]; 211 tagp = &bh->b_data[sizeof(journal_header_t)];
@@ -338,10 +338,11 @@ int jbd2_journal_skip_recovery(journal_t *journal)
338 return err; 338 return err;
339} 339}
340 340
341static inline unsigned long long read_tag_block(int tag_bytes, journal_block_tag_t *tag) 341static inline unsigned long long read_tag_block(journal_t *journal,
342 journal_block_tag_t *tag)
342{ 343{
343 unsigned long long block = be32_to_cpu(tag->t_blocknr); 344 unsigned long long block = be32_to_cpu(tag->t_blocknr);
344 if (tag_bytes > JBD2_TAG_SIZE32) 345 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
345 block |= (u64)be32_to_cpu(tag->t_blocknr_high) << 32; 346 block |= (u64)be32_to_cpu(tag->t_blocknr_high) << 32;
346 return block; 347 return block;
347} 348}
@@ -384,7 +385,7 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf)
384 __be32 provided; 385 __be32 provided;
385 __u32 calculated; 386 __u32 calculated;
386 387
387 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 388 if (!jbd2_journal_has_csum_v2or3(j))
388 return 1; 389 return 1;
389 390
390 h = buf; 391 h = buf;
@@ -399,17 +400,21 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf)
399static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag, 400static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag,
400 void *buf, __u32 sequence) 401 void *buf, __u32 sequence)
401{ 402{
403 journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag;
402 __u32 csum32; 404 __u32 csum32;
403 __be32 seq; 405 __be32 seq;
404 406
405 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 407 if (!jbd2_journal_has_csum_v2or3(j))
406 return 1; 408 return 1;
407 409
408 seq = cpu_to_be32(sequence); 410 seq = cpu_to_be32(sequence);
409 csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq)); 411 csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
410 csum32 = jbd2_chksum(j, csum32, buf, j->j_blocksize); 412 csum32 = jbd2_chksum(j, csum32, buf, j->j_blocksize);
411 413
412 return tag->t_checksum == cpu_to_be16(csum32); 414 if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3))
415 return tag3->t_checksum == cpu_to_be32(csum32);
416 else
417 return tag->t_checksum == cpu_to_be16(csum32);
413} 418}
414 419
415static int do_one_pass(journal_t *journal, 420static int do_one_pass(journal_t *journal,
@@ -426,6 +431,7 @@ static int do_one_pass(journal_t *journal,
426 int tag_bytes = journal_tag_bytes(journal); 431 int tag_bytes = journal_tag_bytes(journal);
427 __u32 crc32_sum = ~0; /* Transactional Checksums */ 432 __u32 crc32_sum = ~0; /* Transactional Checksums */
428 int descr_csum_size = 0; 433 int descr_csum_size = 0;
434 int block_error = 0;
429 435
430 /* 436 /*
431 * First thing is to establish what we expect to find in the log 437 * First thing is to establish what we expect to find in the log
@@ -512,8 +518,7 @@ static int do_one_pass(journal_t *journal,
512 switch(blocktype) { 518 switch(blocktype) {
513 case JBD2_DESCRIPTOR_BLOCK: 519 case JBD2_DESCRIPTOR_BLOCK:
514 /* Verify checksum first */ 520 /* Verify checksum first */
515 if (JBD2_HAS_INCOMPAT_FEATURE(journal, 521 if (jbd2_journal_has_csum_v2or3(journal))
516 JBD2_FEATURE_INCOMPAT_CSUM_V2))
517 descr_csum_size = 522 descr_csum_size =
518 sizeof(struct jbd2_journal_block_tail); 523 sizeof(struct jbd2_journal_block_tail);
519 if (descr_csum_size > 0 && 524 if (descr_csum_size > 0 &&
@@ -574,7 +579,7 @@ static int do_one_pass(journal_t *journal,
574 unsigned long long blocknr; 579 unsigned long long blocknr;
575 580
576 J_ASSERT(obh != NULL); 581 J_ASSERT(obh != NULL);
577 blocknr = read_tag_block(tag_bytes, 582 blocknr = read_tag_block(journal,
578 tag); 583 tag);
579 584
580 /* If the block has been 585 /* If the block has been
@@ -598,7 +603,8 @@ static int do_one_pass(journal_t *journal,
598 "checksum recovering " 603 "checksum recovering "
599 "block %llu in log\n", 604 "block %llu in log\n",
600 blocknr); 605 blocknr);
601 continue; 606 block_error = 1;
607 goto skip_write;
602 } 608 }
603 609
604 /* Find a buffer for the new 610 /* Find a buffer for the new
@@ -797,7 +803,8 @@ static int do_one_pass(journal_t *journal,
797 success = -EIO; 803 success = -EIO;
798 } 804 }
799 } 805 }
800 806 if (block_error && success == 0)
807 success = -EIO;
801 return success; 808 return success;
802 809
803 failed: 810 failed:
@@ -811,7 +818,7 @@ static int jbd2_revoke_block_csum_verify(journal_t *j,
811 __be32 provided; 818 __be32 provided;
812 __u32 calculated; 819 __u32 calculated;
813 820
814 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 821 if (!jbd2_journal_has_csum_v2or3(j))
815 return 1; 822 return 1;
816 823
817 tail = (struct jbd2_journal_revoke_tail *)(buf + j->j_blocksize - 824 tail = (struct jbd2_journal_revoke_tail *)(buf + j->j_blocksize -
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index 198c9c10276d..d5e95a175c92 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -91,8 +91,8 @@
91#include <linux/list.h> 91#include <linux/list.h>
92#include <linux/init.h> 92#include <linux/init.h>
93#include <linux/bio.h> 93#include <linux/bio.h>
94#endif
95#include <linux/log2.h> 94#include <linux/log2.h>
95#endif
96 96
97static struct kmem_cache *jbd2_revoke_record_cache; 97static struct kmem_cache *jbd2_revoke_record_cache;
98static struct kmem_cache *jbd2_revoke_table_cache; 98static struct kmem_cache *jbd2_revoke_table_cache;
@@ -597,7 +597,7 @@ static void write_one_revoke_record(journal_t *journal,
597 offset = *offsetp; 597 offset = *offsetp;
598 598
599 /* Do we need to leave space at the end for a checksum? */ 599 /* Do we need to leave space at the end for a checksum? */
600 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 600 if (jbd2_journal_has_csum_v2or3(journal))
601 csum_size = sizeof(struct jbd2_journal_revoke_tail); 601 csum_size = sizeof(struct jbd2_journal_revoke_tail);
602 602
603 /* Make sure we have a descriptor with space left for the record */ 603 /* Make sure we have a descriptor with space left for the record */
@@ -644,7 +644,7 @@ static void jbd2_revoke_csum_set(journal_t *j, struct buffer_head *bh)
644 struct jbd2_journal_revoke_tail *tail; 644 struct jbd2_journal_revoke_tail *tail;
645 __u32 csum; 645 __u32 csum;
646 646
647 if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2)) 647 if (!jbd2_journal_has_csum_v2or3(j))
648 return; 648 return;
649 649
650 tail = (struct jbd2_journal_revoke_tail *)(bh->b_data + j->j_blocksize - 650 tail = (struct jbd2_journal_revoke_tail *)(bh->b_data + j->j_blocksize -
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
index d0fec260132a..24c6898159cc 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -129,7 +129,10 @@ static int __nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
129 .rpc_argp = &args, 129 .rpc_argp = &args,
130 .rpc_resp = &fattr, 130 .rpc_resp = &fattr,
131 }; 131 };
132 int status; 132 int status = 0;
133
134 if (acl == NULL && (!S_ISDIR(inode->i_mode) || dfacl == NULL))
135 goto out;
133 136
134 status = -EOPNOTSUPP; 137 status = -EOPNOTSUPP;
135 if (!nfs_server_capable(inode, NFS_CAP_ACLS)) 138 if (!nfs_server_capable(inode, NFS_CAP_ACLS))
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 75ae8d22f067..7dd8aca31c29 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2560,6 +2560,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
2560 struct nfs4_closedata *calldata = data; 2560 struct nfs4_closedata *calldata = data;
2561 struct nfs4_state *state = calldata->state; 2561 struct nfs4_state *state = calldata->state;
2562 struct nfs_server *server = NFS_SERVER(calldata->inode); 2562 struct nfs_server *server = NFS_SERVER(calldata->inode);
2563 nfs4_stateid *res_stateid = NULL;
2563 2564
2564 dprintk("%s: begin!\n", __func__); 2565 dprintk("%s: begin!\n", __func__);
2565 if (!nfs4_sequence_done(task, &calldata->res.seq_res)) 2566 if (!nfs4_sequence_done(task, &calldata->res.seq_res))
@@ -2570,12 +2571,12 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
2570 */ 2571 */
2571 switch (task->tk_status) { 2572 switch (task->tk_status) {
2572 case 0: 2573 case 0:
2573 if (calldata->roc) 2574 res_stateid = &calldata->res.stateid;
2575 if (calldata->arg.fmode == 0 && calldata->roc)
2574 pnfs_roc_set_barrier(state->inode, 2576 pnfs_roc_set_barrier(state->inode,
2575 calldata->roc_barrier); 2577 calldata->roc_barrier);
2576 nfs_clear_open_stateid(state, &calldata->res.stateid, 0);
2577 renew_lease(server, calldata->timestamp); 2578 renew_lease(server, calldata->timestamp);
2578 goto out_release; 2579 break;
2579 case -NFS4ERR_ADMIN_REVOKED: 2580 case -NFS4ERR_ADMIN_REVOKED:
2580 case -NFS4ERR_STALE_STATEID: 2581 case -NFS4ERR_STALE_STATEID:
2581 case -NFS4ERR_OLD_STATEID: 2582 case -NFS4ERR_OLD_STATEID:
@@ -2589,7 +2590,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
2589 goto out_release; 2590 goto out_release;
2590 } 2591 }
2591 } 2592 }
2592 nfs_clear_open_stateid(state, NULL, calldata->arg.fmode); 2593 nfs_clear_open_stateid(state, res_stateid, calldata->arg.fmode);
2593out_release: 2594out_release:
2594 nfs_release_seqid(calldata->arg.seqid); 2595 nfs_release_seqid(calldata->arg.seqid);
2595 nfs_refresh_inode(calldata->inode, calldata->res.fattr); 2596 nfs_refresh_inode(calldata->inode, calldata->res.fattr);
@@ -2601,6 +2602,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
2601 struct nfs4_closedata *calldata = data; 2602 struct nfs4_closedata *calldata = data;
2602 struct nfs4_state *state = calldata->state; 2603 struct nfs4_state *state = calldata->state;
2603 struct inode *inode = calldata->inode; 2604 struct inode *inode = calldata->inode;
2605 bool is_rdonly, is_wronly, is_rdwr;
2604 int call_close = 0; 2606 int call_close = 0;
2605 2607
2606 dprintk("%s: begin!\n", __func__); 2608 dprintk("%s: begin!\n", __func__);
@@ -2608,18 +2610,24 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
2608 goto out_wait; 2610 goto out_wait;
2609 2611
2610 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; 2612 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
2611 calldata->arg.fmode = FMODE_READ|FMODE_WRITE;
2612 spin_lock(&state->owner->so_lock); 2613 spin_lock(&state->owner->so_lock);
2614 is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags);
2615 is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags);
2616 is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags);
2617 /* Calculate the current open share mode */
2618 calldata->arg.fmode = 0;
2619 if (is_rdonly || is_rdwr)
2620 calldata->arg.fmode |= FMODE_READ;
2621 if (is_wronly || is_rdwr)
2622 calldata->arg.fmode |= FMODE_WRITE;
2613 /* Calculate the change in open mode */ 2623 /* Calculate the change in open mode */
2614 if (state->n_rdwr == 0) { 2624 if (state->n_rdwr == 0) {
2615 if (state->n_rdonly == 0) { 2625 if (state->n_rdonly == 0) {
2616 call_close |= test_bit(NFS_O_RDONLY_STATE, &state->flags); 2626 call_close |= is_rdonly || is_rdwr;
2617 call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
2618 calldata->arg.fmode &= ~FMODE_READ; 2627 calldata->arg.fmode &= ~FMODE_READ;
2619 } 2628 }
2620 if (state->n_wronly == 0) { 2629 if (state->n_wronly == 0) {
2621 call_close |= test_bit(NFS_O_WRONLY_STATE, &state->flags); 2630 call_close |= is_wronly || is_rdwr;
2622 call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
2623 calldata->arg.fmode &= ~FMODE_WRITE; 2631 calldata->arg.fmode &= ~FMODE_WRITE;
2624 } 2632 }
2625 } 2633 }
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index eb726b9c5762..a1e31f274fcd 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -127,10 +127,9 @@ enum {
127 BLK_MQ_RQ_QUEUE_ERROR = 2, /* end IO with error */ 127 BLK_MQ_RQ_QUEUE_ERROR = 2, /* end IO with error */
128 128
129 BLK_MQ_F_SHOULD_MERGE = 1 << 0, 129 BLK_MQ_F_SHOULD_MERGE = 1 << 0,
130 BLK_MQ_F_SHOULD_SORT = 1 << 1, 130 BLK_MQ_F_TAG_SHARED = 1 << 1,
131 BLK_MQ_F_TAG_SHARED = 1 << 2, 131 BLK_MQ_F_SG_MERGE = 1 << 2,
132 BLK_MQ_F_SG_MERGE = 1 << 3, 132 BLK_MQ_F_SYSFS_UP = 1 << 3,
133 BLK_MQ_F_SYSFS_UP = 1 << 4,
134 133
135 BLK_MQ_S_STOPPED = 0, 134 BLK_MQ_S_STOPPED = 0,
136 BLK_MQ_S_TAG_ACTIVE = 1, 135 BLK_MQ_S_TAG_ACTIVE = 1,
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index d5b50a19463c..0dae71e9971c 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -159,7 +159,11 @@ typedef struct journal_header_s
159 * journal_block_tag (in the descriptor). The other h_chksum* fields are 159 * journal_block_tag (in the descriptor). The other h_chksum* fields are
160 * not used. 160 * not used.
161 * 161 *
162 * Checksum v1 and v2 are mutually exclusive features. 162 * If FEATURE_INCOMPAT_CSUM_V3 is set, the descriptor block uses
163 * journal_block_tag3_t to store a full 32-bit checksum. Everything else
164 * is the same as v2.
165 *
166 * Checksum v1, v2, and v3 are mutually exclusive features.
163 */ 167 */
164struct commit_header { 168struct commit_header {
165 __be32 h_magic; 169 __be32 h_magic;
@@ -179,6 +183,14 @@ struct commit_header {
179 * raw struct shouldn't be used for pointer math or sizeof() - use 183 * raw struct shouldn't be used for pointer math or sizeof() - use
180 * journal_tag_bytes(journal) instead to compute this. 184 * journal_tag_bytes(journal) instead to compute this.
181 */ 185 */
186typedef struct journal_block_tag3_s
187{
188 __be32 t_blocknr; /* The on-disk block number */
189 __be32 t_flags; /* See below */
190 __be32 t_blocknr_high; /* most-significant high 32bits. */
191 __be32 t_checksum; /* crc32c(uuid+seq+block) */
192} journal_block_tag3_t;
193
182typedef struct journal_block_tag_s 194typedef struct journal_block_tag_s
183{ 195{
184 __be32 t_blocknr; /* The on-disk block number */ 196 __be32 t_blocknr; /* The on-disk block number */
@@ -187,9 +199,6 @@ typedef struct journal_block_tag_s
187 __be32 t_blocknr_high; /* most-significant high 32bits. */ 199 __be32 t_blocknr_high; /* most-significant high 32bits. */
188} journal_block_tag_t; 200} journal_block_tag_t;
189 201
190#define JBD2_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high))
191#define JBD2_TAG_SIZE64 (sizeof(journal_block_tag_t))
192
193/* Tail of descriptor block, for checksumming */ 202/* Tail of descriptor block, for checksumming */
194struct jbd2_journal_block_tail { 203struct jbd2_journal_block_tail {
195 __be32 t_checksum; /* crc32c(uuid+descr_block) */ 204 __be32 t_checksum; /* crc32c(uuid+descr_block) */
@@ -284,6 +293,7 @@ typedef struct journal_superblock_s
284#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002 293#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
285#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004 294#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
286#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008 295#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
296#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
287 297
288/* Features known to this kernel version: */ 298/* Features known to this kernel version: */
289#define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM 299#define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM
@@ -291,7 +301,8 @@ typedef struct journal_superblock_s
291#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \ 301#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \
292 JBD2_FEATURE_INCOMPAT_64BIT | \ 302 JBD2_FEATURE_INCOMPAT_64BIT | \
293 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \ 303 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \
294 JBD2_FEATURE_INCOMPAT_CSUM_V2) 304 JBD2_FEATURE_INCOMPAT_CSUM_V2 | \
305 JBD2_FEATURE_INCOMPAT_CSUM_V3)
295 306
296#ifdef __KERNEL__ 307#ifdef __KERNEL__
297 308
@@ -1296,6 +1307,15 @@ static inline int tid_geq(tid_t x, tid_t y)
1296extern int jbd2_journal_blocks_per_page(struct inode *inode); 1307extern int jbd2_journal_blocks_per_page(struct inode *inode);
1297extern size_t journal_tag_bytes(journal_t *journal); 1308extern size_t journal_tag_bytes(journal_t *journal);
1298 1309
1310static inline int jbd2_journal_has_csum_v2or3(journal_t *journal)
1311{
1312 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) ||
1313 JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3))
1314 return 1;
1315
1316 return 0;
1317}
1318
1299/* 1319/*
1300 * We reserve t_outstanding_credits >> JBD2_CONTROL_BLOCKS_SHIFT for 1320 * We reserve t_outstanding_credits >> JBD2_CONTROL_BLOCKS_SHIFT for
1301 * transaction control blocks. 1321 * transaction control blocks.
diff --git a/drivers/staging/usbip/uapi/usbip.h b/include/uapi/linux/usbip.h
index fa5db30ede36..fa5db30ede36 100644
--- a/drivers/staging/usbip/uapi/usbip.h
+++ b/include/uapi/linux/usbip.h
diff --git a/drivers/staging/usbip/userspace/.gitignore b/tools/usb/usbip/.gitignore
index 9aad9e30a8ba..9aad9e30a8ba 100644
--- a/drivers/staging/usbip/userspace/.gitignore
+++ b/tools/usb/usbip/.gitignore
diff --git a/drivers/staging/usbip/userspace/AUTHORS b/tools/usb/usbip/AUTHORS
index a27ea8d03aec..a27ea8d03aec 100644
--- a/drivers/staging/usbip/userspace/AUTHORS
+++ b/tools/usb/usbip/AUTHORS
diff --git a/drivers/staging/usbip/userspace/COPYING b/tools/usb/usbip/COPYING
index c5611e48a8e1..c5611e48a8e1 100644
--- a/drivers/staging/usbip/userspace/COPYING
+++ b/tools/usb/usbip/COPYING
diff --git a/drivers/staging/usbip/userspace/INSTALL b/tools/usb/usbip/INSTALL
index d3c5b40a9409..d3c5b40a9409 100644
--- a/drivers/staging/usbip/userspace/INSTALL
+++ b/tools/usb/usbip/INSTALL
diff --git a/drivers/staging/usbip/userspace/Makefile.am b/tools/usb/usbip/Makefile.am
index 66f8bf038c9f..66f8bf038c9f 100644
--- a/drivers/staging/usbip/userspace/Makefile.am
+++ b/tools/usb/usbip/Makefile.am
diff --git a/drivers/staging/usbip/userspace/README b/tools/usb/usbip/README
index 831f49fea3ce..831f49fea3ce 100644
--- a/drivers/staging/usbip/userspace/README
+++ b/tools/usb/usbip/README
diff --git a/drivers/staging/usbip/userspace/autogen.sh b/tools/usb/usbip/autogen.sh
index e1112d3fcbf6..e1112d3fcbf6 100755
--- a/drivers/staging/usbip/userspace/autogen.sh
+++ b/tools/usb/usbip/autogen.sh
diff --git a/drivers/staging/usbip/userspace/cleanup.sh b/tools/usb/usbip/cleanup.sh
index 955c3ccb729a..955c3ccb729a 100755
--- a/drivers/staging/usbip/userspace/cleanup.sh
+++ b/tools/usb/usbip/cleanup.sh
diff --git a/drivers/staging/usbip/userspace/configure.ac b/tools/usb/usbip/configure.ac
index 607d05c5ccfd..607d05c5ccfd 100644
--- a/drivers/staging/usbip/userspace/configure.ac
+++ b/tools/usb/usbip/configure.ac
diff --git a/drivers/staging/usbip/userspace/doc/usbip.8 b/tools/usb/usbip/doc/usbip.8
index a6097be25d28..a6097be25d28 100644
--- a/drivers/staging/usbip/userspace/doc/usbip.8
+++ b/tools/usb/usbip/doc/usbip.8
diff --git a/drivers/staging/usbip/userspace/doc/usbipd.8 b/tools/usb/usbip/doc/usbipd.8
index ac4635db3f03..ac4635db3f03 100644
--- a/drivers/staging/usbip/userspace/doc/usbipd.8
+++ b/tools/usb/usbip/doc/usbipd.8
diff --git a/drivers/staging/usbip/userspace/libsrc/Makefile.am b/tools/usb/usbip/libsrc/Makefile.am
index 7c8f8a4d54e4..7c8f8a4d54e4 100644
--- a/drivers/staging/usbip/userspace/libsrc/Makefile.am
+++ b/tools/usb/usbip/libsrc/Makefile.am
diff --git a/drivers/staging/usbip/userspace/libsrc/list.h b/tools/usb/usbip/libsrc/list.h
index 8d0c936e184f..8d0c936e184f 100644
--- a/drivers/staging/usbip/userspace/libsrc/list.h
+++ b/tools/usb/usbip/libsrc/list.h
diff --git a/drivers/staging/usbip/userspace/libsrc/names.c b/tools/usb/usbip/libsrc/names.c
index 81ff8522405c..81ff8522405c 100644
--- a/drivers/staging/usbip/userspace/libsrc/names.c
+++ b/tools/usb/usbip/libsrc/names.c
diff --git a/drivers/staging/usbip/userspace/libsrc/names.h b/tools/usb/usbip/libsrc/names.h
index 680926512de2..680926512de2 100644
--- a/drivers/staging/usbip/userspace/libsrc/names.h
+++ b/tools/usb/usbip/libsrc/names.h
diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c b/tools/usb/usbip/libsrc/sysfs_utils.c
index 36ac88ece0b8..36ac88ece0b8 100644
--- a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c
+++ b/tools/usb/usbip/libsrc/sysfs_utils.c
diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h b/tools/usb/usbip/libsrc/sysfs_utils.h
index 32ac1d105d18..32ac1d105d18 100644
--- a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h
+++ b/tools/usb/usbip/libsrc/sysfs_utils.h
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c
index ac73710473de..ac73710473de 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h b/tools/usb/usbip/libsrc/usbip_common.h
index 5a0e95edf4df..5a0e95edf4df 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h
+++ b/tools/usb/usbip/libsrc/usbip_common.h
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c b/tools/usb/usbip/libsrc/usbip_host_driver.c
index bef08d5c44e8..bef08d5c44e8 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.c
+++ b/tools/usb/usbip/libsrc/usbip_host_driver.c
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.h b/tools/usb/usbip/libsrc/usbip_host_driver.h
index 2a31f855c616..2a31f855c616 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_host_driver.h
+++ b/tools/usb/usbip/libsrc/usbip_host_driver.h
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c
index ad9204773533..ad9204773533 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/tools/usb/usbip/libsrc/vhci_driver.c
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h b/tools/usb/usbip/libsrc/vhci_driver.h
index fa2316cf2cac..fa2316cf2cac 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
+++ b/tools/usb/usbip/libsrc/vhci_driver.h
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/tools/usb/usbip/src/Makefile.am
index e81a4ebadeff..e81a4ebadeff 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/tools/usb/usbip/src/Makefile.am
diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/tools/usb/usbip/src/usbip.c
index d7599d943529..d7599d943529 100644
--- a/drivers/staging/usbip/userspace/src/usbip.c
+++ b/tools/usb/usbip/src/usbip.c
diff --git a/drivers/staging/usbip/userspace/src/usbip.h b/tools/usb/usbip/src/usbip.h
index 84fe66a9d8ad..84fe66a9d8ad 100644
--- a/drivers/staging/usbip/userspace/src/usbip.h
+++ b/tools/usb/usbip/src/usbip.h
diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/tools/usb/usbip/src/usbip_attach.c
index d58a14dfc094..d58a14dfc094 100644
--- a/drivers/staging/usbip/userspace/src/usbip_attach.c
+++ b/tools/usb/usbip/src/usbip_attach.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_bind.c b/tools/usb/usbip/src/usbip_bind.c
index fa46141ae68b..fa46141ae68b 100644
--- a/drivers/staging/usbip/userspace/src/usbip_bind.c
+++ b/tools/usb/usbip/src/usbip_bind.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_detach.c b/tools/usb/usbip/src/usbip_detach.c
index 05c6d15856eb..05c6d15856eb 100644
--- a/drivers/staging/usbip/userspace/src/usbip_detach.c
+++ b/tools/usb/usbip/src/usbip_detach.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c
index d5ce34a410e7..d5ce34a410e7 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/tools/usb/usbip/src/usbip_list.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.c b/tools/usb/usbip/src/usbip_network.c
index b4c37e76a6e0..b4c37e76a6e0 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.c
+++ b/tools/usb/usbip/src/usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.h b/tools/usb/usbip/src/usbip_network.h
index c1e875cf1078..c1e875cf1078 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.h
+++ b/tools/usb/usbip/src/usbip_network.h
diff --git a/drivers/staging/usbip/userspace/src/usbip_port.c b/tools/usb/usbip/src/usbip_port.c
index a2e884fd9226..a2e884fd9226 100644
--- a/drivers/staging/usbip/userspace/src/usbip_port.c
+++ b/tools/usb/usbip/src/usbip_port.c
diff --git a/drivers/staging/usbip/userspace/src/usbip_unbind.c b/tools/usb/usbip/src/usbip_unbind.c
index a4a496c9cbaf..a4a496c9cbaf 100644
--- a/drivers/staging/usbip/userspace/src/usbip_unbind.c
+++ b/tools/usb/usbip/src/usbip_unbind.c
diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/tools/usb/usbip/src/usbipd.c
index 2f87f2d348ba..2f87f2d348ba 100644
--- a/drivers/staging/usbip/userspace/src/usbipd.c
+++ b/tools/usb/usbip/src/usbipd.c
diff --git a/drivers/staging/usbip/userspace/src/utils.c b/tools/usb/usbip/src/utils.c
index 2b3d6d235015..2b3d6d235015 100644
--- a/drivers/staging/usbip/userspace/src/utils.c
+++ b/tools/usb/usbip/src/utils.c
diff --git a/drivers/staging/usbip/userspace/src/utils.h b/tools/usb/usbip/src/utils.h
index 5916fd3e02a6..5916fd3e02a6 100644
--- a/drivers/staging/usbip/userspace/src/utils.h
+++ b/tools/usb/usbip/src/utils.h