aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/usb/dwc2.txt2
-rw-r--r--Documentation/devicetree/bindings/usb/renesas_usb3.txt1
-rw-r--r--Documentation/devicetree/bindings/usb/renesas_usbhs.txt1
-rw-r--r--Documentation/devicetree/bindings/usb/usb-xhci.txt1
-rw-r--r--MAINTAINERS8
-rw-r--r--arch/sparc/mm/tlb.c19
-rw-r--r--drivers/auxdisplay/img-ascii-lcd.c6
-rw-r--r--drivers/auxdisplay/panel.c6
-rw-r--r--drivers/firmware/dcdbas.c2
-rw-r--r--drivers/infiniband/sw/rdmavt/mr.c10
-rw-r--r--drivers/md/dm-mpath.c43
-rw-r--r--drivers/phy/qualcomm/phy-qcom-ufs.c5
-rw-r--r--drivers/platform/x86/Kconfig7
-rw-r--r--drivers/platform/x86/dell-smbios-base.c2
-rw-r--r--drivers/platform/x86/dell-wmi.c2
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_scsih.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c59
-rw-r--r--drivers/scsi/sd.c3
-rw-r--r--drivers/scsi/sd_zbc.c35
-rw-r--r--drivers/staging/android/ashmem.c23
-rw-r--r--drivers/staging/comedi/drivers.c3
-rw-r--r--drivers/tty/n_tty.c6
-rw-r--r--drivers/tty/serial/8250/8250_pci.c21
-rw-r--r--drivers/tty/serial/atmel_serial.c1
-rw-r--r--drivers/tty/serial/earlycon.c3
-rw-r--r--drivers/tty/serial/imx.c2
-rw-r--r--drivers/tty/serial/serial_core.c2
-rw-r--r--drivers/tty/serial/sh-sci.c2
-rw-r--r--drivers/tty/tty_io.c9
-rw-r--r--drivers/usb/core/message.c4
-rw-r--r--drivers/usb/core/quirks.c3
-rw-r--r--drivers/usb/dwc2/params.c6
-rw-r--r--drivers/usb/dwc3/core.c2
-rw-r--r--drivers/usb/gadget/function/f_fs.c1
-rw-r--r--drivers/usb/host/ohci-hcd.c3
-rw-r--r--drivers/usb/host/xhci-dbgcap.c20
-rw-r--r--drivers/usb/host/xhci-dbgtty.c20
-rw-r--r--drivers/usb/host/xhci-pci.c3
-rw-r--r--drivers/usb/host/xhci-plat.c11
-rw-r--r--drivers/usb/host/xhci-rcar.c4
-rw-r--r--drivers/usb/host/xhci.c3
-rw-r--r--drivers/usb/host/xhci.h23
-rw-r--r--drivers/usb/mon/mon_text.c126
-rw-r--r--drivers/usb/musb/musb_core.c4
-rw-r--r--drivers/usb/storage/uas.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h7
-rw-r--r--drivers/usb/typec/fusb302/fusb302.c3
-rw-r--r--drivers/usb/typec/tcpm.c163
-rw-r--r--drivers/usb/usbip/vudc_sysfs.c8
-rw-r--r--fs/aio.c44
-rw-r--r--fs/dcache.c21
-rw-r--r--fs/namei.c5
-rw-r--r--fs/nfs/direct.c2
-rw-r--r--fs/nfs/pnfs.c13
-rw-r--r--fs/nfs/super.c2
-rw-r--r--fs/nfs/write.c83
-rw-r--r--include/linux/fs.h1
-rw-r--r--include/linux/tty.h1
-rw-r--r--include/linux/usb/quirks.h3
-rw-r--r--lib/btree.c10
-rw-r--r--mm/page_alloc.c13
-rw-r--r--sound/core/oss/pcm_oss.c10
-rw-r--r--sound/core/seq/seq_clientmgr.c4
-rw-r--r--sound/core/seq/seq_prioq.c28
-rw-r--r--sound/core/seq/seq_prioq.h6
-rw-r--r--sound/core/seq/seq_queue.c28
-rw-r--r--sound/pci/hda/hda_intel.c9
-rw-r--r--sound/soc/amd/acp-pcm-dma.c16
-rw-r--r--sound/soc/amd/acp.h2
-rw-r--r--sound/soc/codecs/hdmi-codec.c7
-rw-r--r--sound/soc/codecs/rt5651.c1
-rw-r--r--sound/soc/codecs/sgtl5000.c26
-rw-r--r--sound/soc/codecs/wm_adsp.c14
-rw-r--r--sound/soc/sunxi/sun4i-i2s.c2
74 files changed, 581 insertions, 472 deletions
diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt
index e64d903bcbe8..46da5f184460 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -19,7 +19,7 @@ Required properties:
19 configured in FS mode; 19 configured in FS mode;
20 - "st,stm32f4x9-hsotg": The DWC2 USB HS controller instance in STM32F4x9 SoCs 20 - "st,stm32f4x9-hsotg": The DWC2 USB HS controller instance in STM32F4x9 SoCs
21 configured in HS mode; 21 configured in HS mode;
22 - "st,stm32f7xx-hsotg": The DWC2 USB HS controller instance in STM32F7xx SoCs 22 - "st,stm32f7-hsotg": The DWC2 USB HS controller instance in STM32F7 SoCs
23 configured in HS mode; 23 configured in HS mode;
24- reg : Should contain 1 register range (address and length) 24- reg : Should contain 1 register range (address and length)
25- interrupts : Should contain 1 interrupt 25- interrupts : Should contain 1 interrupt
diff --git a/Documentation/devicetree/bindings/usb/renesas_usb3.txt b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
index 87a45e2f9b7f..2c071bb5801e 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usb3.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
@@ -4,6 +4,7 @@ Required properties:
4 - compatible: Must contain one of the following: 4 - compatible: Must contain one of the following:
5 - "renesas,r8a7795-usb3-peri" 5 - "renesas,r8a7795-usb3-peri"
6 - "renesas,r8a7796-usb3-peri" 6 - "renesas,r8a7796-usb3-peri"
7 - "renesas,r8a77965-usb3-peri"
7 - "renesas,rcar-gen3-usb3-peri" for a generic R-Car Gen3 compatible 8 - "renesas,rcar-gen3-usb3-peri" for a generic R-Car Gen3 compatible
8 device 9 device
9 10
diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
index d060172f1529..43960faf5a88 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
@@ -12,6 +12,7 @@ Required properties:
12 - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device 12 - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device
13 - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device 13 - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device
14 - "renesas,usbhs-r8a7796" for r8a7796 (R-Car M3-W) compatible device 14 - "renesas,usbhs-r8a7796" for r8a7796 (R-Car M3-W) compatible device
15 - "renesas,usbhs-r8a77965" for r8a77965 (R-Car M3-N) compatible device
15 - "renesas,usbhs-r8a77995" for r8a77995 (R-Car D3) compatible device 16 - "renesas,usbhs-r8a77995" for r8a77995 (R-Car D3) compatible device
16 - "renesas,usbhs-r7s72100" for r7s72100 (RZ/A1) compatible device 17 - "renesas,usbhs-r7s72100" for r7s72100 (RZ/A1) compatible device
17 - "renesas,rcar-gen2-usbhs" for R-Car Gen2 or RZ/G1 compatible devices 18 - "renesas,rcar-gen2-usbhs" for R-Car Gen2 or RZ/G1 compatible devices
diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index e2ea59bbca93..1651483a7048 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -13,6 +13,7 @@ Required properties:
13 - "renesas,xhci-r8a7793" for r8a7793 SoC 13 - "renesas,xhci-r8a7793" for r8a7793 SoC
14 - "renesas,xhci-r8a7795" for r8a7795 SoC 14 - "renesas,xhci-r8a7795" for r8a7795 SoC
15 - "renesas,xhci-r8a7796" for r8a7796 SoC 15 - "renesas,xhci-r8a7796" for r8a7796 SoC
16 - "renesas,xhci-r8a77965" for r8a77965 SoC
16 - "renesas,rcar-gen2-xhci" for a generic R-Car Gen2 or RZ/G1 compatible 17 - "renesas,rcar-gen2-xhci" for a generic R-Car Gen2 or RZ/G1 compatible
17 device 18 device
18 - "renesas,rcar-gen3-xhci" for a generic R-Car Gen3 compatible device 19 - "renesas,rcar-gen3-xhci" for a generic R-Car Gen3 compatible device
diff --git a/MAINTAINERS b/MAINTAINERS
index 4623caf8d72d..205c8fc12a9c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9925,6 +9925,13 @@ F: Documentation/ABI/stable/sysfs-bus-nvmem
9925F: include/linux/nvmem-consumer.h 9925F: include/linux/nvmem-consumer.h
9926F: include/linux/nvmem-provider.h 9926F: include/linux/nvmem-provider.h
9927 9927
9928NXP SGTL5000 DRIVER
9929M: Fabio Estevam <fabio.estevam@nxp.com>
9930L: alsa-devel@alsa-project.org (moderated for non-subscribers)
9931S: Maintained
9932F: Documentation/devicetree/bindings/sound/sgtl5000.txt
9933F: sound/soc/codecs/sgtl5000*
9934
9928NXP TDA998X DRM DRIVER 9935NXP TDA998X DRM DRIVER
9929M: Russell King <linux@armlinux.org.uk> 9936M: Russell King <linux@armlinux.org.uk>
9930S: Supported 9937S: Supported
@@ -12107,6 +12114,7 @@ M: Sylwester Nawrocki <s.nawrocki@samsung.com>
12107L: alsa-devel@alsa-project.org (moderated for non-subscribers) 12114L: alsa-devel@alsa-project.org (moderated for non-subscribers)
12108S: Supported 12115S: Supported
12109F: sound/soc/samsung/ 12116F: sound/soc/samsung/
12117F: Documentation/devicetree/bindings/sound/samsung*
12110 12118
12111SAMSUNG EXYNOS PSEUDO RANDOM NUMBER GENERATOR (RNG) DRIVER 12119SAMSUNG EXYNOS PSEUDO RANDOM NUMBER GENERATOR (RNG) DRIVER
12112M: Krzysztof Kozlowski <krzk@kernel.org> 12120M: Krzysztof Kozlowski <krzk@kernel.org>
diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
index 847ddffbf38a..b5cfab711651 100644
--- a/arch/sparc/mm/tlb.c
+++ b/arch/sparc/mm/tlb.c
@@ -163,13 +163,10 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr,
163 pte_unmap(pte); 163 pte_unmap(pte);
164} 164}
165 165
166void set_pmd_at(struct mm_struct *mm, unsigned long addr,
167 pmd_t *pmdp, pmd_t pmd)
168{
169 pmd_t orig = *pmdp;
170
171 *pmdp = pmd;
172 166
167static void __set_pmd_acct(struct mm_struct *mm, unsigned long addr,
168 pmd_t orig, pmd_t pmd)
169{
173 if (mm == &init_mm) 170 if (mm == &init_mm)
174 return; 171 return;
175 172
@@ -219,6 +216,15 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr,
219 } 216 }
220} 217}
221 218
219void set_pmd_at(struct mm_struct *mm, unsigned long addr,
220 pmd_t *pmdp, pmd_t pmd)
221{
222 pmd_t orig = *pmdp;
223
224 *pmdp = pmd;
225 __set_pmd_acct(mm, addr, orig, pmd);
226}
227
222static inline pmd_t pmdp_establish(struct vm_area_struct *vma, 228static inline pmd_t pmdp_establish(struct vm_area_struct *vma,
223 unsigned long address, pmd_t *pmdp, pmd_t pmd) 229 unsigned long address, pmd_t *pmdp, pmd_t pmd)
224{ 230{
@@ -227,6 +233,7 @@ static inline pmd_t pmdp_establish(struct vm_area_struct *vma,
227 do { 233 do {
228 old = *pmdp; 234 old = *pmdp;
229 } while (cmpxchg64(&pmdp->pmd, old.pmd, pmd.pmd) != old.pmd); 235 } while (cmpxchg64(&pmdp->pmd, old.pmd, pmd.pmd) != old.pmd);
236 __set_pmd_acct(vma->vm_mm, address, old, pmd);
230 237
231 return old; 238 return old;
232} 239}
diff --git a/drivers/auxdisplay/img-ascii-lcd.c b/drivers/auxdisplay/img-ascii-lcd.c
index 9180b9bd5821..834509506ef6 100644
--- a/drivers/auxdisplay/img-ascii-lcd.c
+++ b/drivers/auxdisplay/img-ascii-lcd.c
@@ -97,7 +97,7 @@ static struct img_ascii_lcd_config boston_config = {
97static void malta_update(struct img_ascii_lcd_ctx *ctx) 97static void malta_update(struct img_ascii_lcd_ctx *ctx)
98{ 98{
99 unsigned int i; 99 unsigned int i;
100 int err; 100 int err = 0;
101 101
102 for (i = 0; i < ctx->cfg->num_chars; i++) { 102 for (i = 0; i < ctx->cfg->num_chars; i++) {
103 err = regmap_write(ctx->regmap, 103 err = regmap_write(ctx->regmap,
@@ -180,7 +180,7 @@ static int sead3_wait_lcd_idle(struct img_ascii_lcd_ctx *ctx)
180static void sead3_update(struct img_ascii_lcd_ctx *ctx) 180static void sead3_update(struct img_ascii_lcd_ctx *ctx)
181{ 181{
182 unsigned int i; 182 unsigned int i;
183 int err; 183 int err = 0;
184 184
185 for (i = 0; i < ctx->cfg->num_chars; i++) { 185 for (i = 0; i < ctx->cfg->num_chars; i++) {
186 err = sead3_wait_lcd_idle(ctx); 186 err = sead3_wait_lcd_idle(ctx);
@@ -224,7 +224,7 @@ MODULE_DEVICE_TABLE(of, img_ascii_lcd_matches);
224 224
225/** 225/**
226 * img_ascii_lcd_scroll() - scroll the display by a character 226 * img_ascii_lcd_scroll() - scroll the display by a character
227 * @arg: really a pointer to the private data structure 227 * @t: really a pointer to the private data structure
228 * 228 *
229 * Scroll the current message along the LCD by one character, rearming the 229 * Scroll the current message along the LCD by one character, rearming the
230 * timer if required. 230 * timer if required.
diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c
index ea7869c0d7f9..ec5e8800f8ad 100644
--- a/drivers/auxdisplay/panel.c
+++ b/drivers/auxdisplay/panel.c
@@ -1372,7 +1372,7 @@ static void panel_process_inputs(void)
1372 break; 1372 break;
1373 input->rise_timer = 0; 1373 input->rise_timer = 0;
1374 input->state = INPUT_ST_RISING; 1374 input->state = INPUT_ST_RISING;
1375 /* no break here, fall through */ 1375 /* fall through */
1376 case INPUT_ST_RISING: 1376 case INPUT_ST_RISING:
1377 if ((phys_curr & input->mask) != input->value) { 1377 if ((phys_curr & input->mask) != input->value) {
1378 input->state = INPUT_ST_LOW; 1378 input->state = INPUT_ST_LOW;
@@ -1385,11 +1385,11 @@ static void panel_process_inputs(void)
1385 } 1385 }
1386 input->high_timer = 0; 1386 input->high_timer = 0;
1387 input->state = INPUT_ST_HIGH; 1387 input->state = INPUT_ST_HIGH;
1388 /* no break here, fall through */ 1388 /* fall through */
1389 case INPUT_ST_HIGH: 1389 case INPUT_ST_HIGH:
1390 if (input_state_high(input)) 1390 if (input_state_high(input))
1391 break; 1391 break;
1392 /* no break here, fall through */ 1392 /* fall through */
1393 case INPUT_ST_FALLING: 1393 case INPUT_ST_FALLING:
1394 input_state_falling(input); 1394 input_state_falling(input);
1395 } 1395 }
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index c16600f30611..0bdea60c65dd 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -639,7 +639,7 @@ static void __exit dcdbas_exit(void)
639 platform_driver_unregister(&dcdbas_driver); 639 platform_driver_unregister(&dcdbas_driver);
640} 640}
641 641
642module_init(dcdbas_init); 642subsys_initcall_sync(dcdbas_init);
643module_exit(dcdbas_exit); 643module_exit(dcdbas_exit);
644 644
645MODULE_DESCRIPTION(DRIVER_DESCRIPTION " (version " DRIVER_VERSION ")"); 645MODULE_DESCRIPTION(DRIVER_DESCRIPTION " (version " DRIVER_VERSION ")");
diff --git a/drivers/infiniband/sw/rdmavt/mr.c b/drivers/infiniband/sw/rdmavt/mr.c
index 1b2e5362a3ff..cc429b567d0a 100644
--- a/drivers/infiniband/sw/rdmavt/mr.c
+++ b/drivers/infiniband/sw/rdmavt/mr.c
@@ -489,11 +489,13 @@ static int rvt_check_refs(struct rvt_mregion *mr, const char *t)
489 unsigned long timeout; 489 unsigned long timeout;
490 struct rvt_dev_info *rdi = ib_to_rvt(mr->pd->device); 490 struct rvt_dev_info *rdi = ib_to_rvt(mr->pd->device);
491 491
492 if (percpu_ref_is_zero(&mr->refcount)) 492 if (mr->lkey) {
493 return 0; 493 /* avoid dma mr */
494 /* avoid dma mr */
495 if (mr->lkey)
496 rvt_dereg_clean_qps(mr); 494 rvt_dereg_clean_qps(mr);
495 /* @mr was indexed on rcu protected @lkey_table */
496 synchronize_rcu();
497 }
498
497 timeout = wait_for_completion_timeout(&mr->comp, 5 * HZ); 499 timeout = wait_for_completion_timeout(&mr->comp, 5 * HZ);
498 if (!timeout) { 500 if (!timeout) {
499 rvt_pr_err(rdi, 501 rvt_pr_err(rdi,
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 3fde9e9faddd..a05a560d3cba 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -22,7 +22,6 @@
22#include <linux/time.h> 22#include <linux/time.h>
23#include <linux/workqueue.h> 23#include <linux/workqueue.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <scsi/scsi_device.h>
26#include <scsi/scsi_dh.h> 25#include <scsi/scsi_dh.h>
27#include <linux/atomic.h> 26#include <linux/atomic.h>
28#include <linux/blk-mq.h> 27#include <linux/blk-mq.h>
@@ -223,6 +222,16 @@ static int alloc_multipath_stage2(struct dm_target *ti, struct multipath *m)
223 222
224 dm_table_set_type(ti->table, m->queue_mode); 223 dm_table_set_type(ti->table, m->queue_mode);
225 224
225 /*
226 * Init fields that are only used when a scsi_dh is attached
227 * - must do this unconditionally (really doesn't hurt non-SCSI uses)
228 */
229 set_bit(MPATHF_QUEUE_IO, &m->flags);
230 atomic_set(&m->pg_init_in_progress, 0);
231 atomic_set(&m->pg_init_count, 0);
232 m->pg_init_delay_msecs = DM_PG_INIT_DELAY_DEFAULT;
233 init_waitqueue_head(&m->pg_init_wait);
234
226 return 0; 235 return 0;
227} 236}
228 237
@@ -331,7 +340,6 @@ static void __switch_pg(struct multipath *m, struct priority_group *pg)
331 set_bit(MPATHF_PG_INIT_REQUIRED, &m->flags); 340 set_bit(MPATHF_PG_INIT_REQUIRED, &m->flags);
332 set_bit(MPATHF_QUEUE_IO, &m->flags); 341 set_bit(MPATHF_QUEUE_IO, &m->flags);
333 } else { 342 } else {
334 /* FIXME: not needed if no scsi_dh is attached */
335 clear_bit(MPATHF_PG_INIT_REQUIRED, &m->flags); 343 clear_bit(MPATHF_PG_INIT_REQUIRED, &m->flags);
336 clear_bit(MPATHF_QUEUE_IO, &m->flags); 344 clear_bit(MPATHF_QUEUE_IO, &m->flags);
337 } 345 }
@@ -796,15 +804,14 @@ static int parse_path_selector(struct dm_arg_set *as, struct priority_group *pg,
796 return 0; 804 return 0;
797} 805}
798 806
799static int setup_scsi_dh(struct block_device *bdev, struct multipath *m, char **error) 807static int setup_scsi_dh(struct block_device *bdev, struct multipath *m,
808 const char *attached_handler_name, char **error)
800{ 809{
801 struct request_queue *q = bdev_get_queue(bdev); 810 struct request_queue *q = bdev_get_queue(bdev);
802 const char *attached_handler_name;
803 int r; 811 int r;
804 812
805 if (test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags)) { 813 if (test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags)) {
806retain: 814retain:
807 attached_handler_name = scsi_dh_attached_handler_name(q, GFP_KERNEL);
808 if (attached_handler_name) { 815 if (attached_handler_name) {
809 /* 816 /*
810 * Clear any hw_handler_params associated with a 817 * Clear any hw_handler_params associated with a
@@ -823,16 +830,6 @@ retain:
823 */ 830 */
824 kfree(m->hw_handler_name); 831 kfree(m->hw_handler_name);
825 m->hw_handler_name = attached_handler_name; 832 m->hw_handler_name = attached_handler_name;
826
827 /*
828 * Init fields that are only used when a scsi_dh is attached
829 */
830 if (!test_and_set_bit(MPATHF_QUEUE_IO, &m->flags)) {
831 atomic_set(&m->pg_init_in_progress, 0);
832 atomic_set(&m->pg_init_count, 0);
833 m->pg_init_delay_msecs = DM_PG_INIT_DELAY_DEFAULT;
834 init_waitqueue_head(&m->pg_init_wait);
835 }
836 } 833 }
837 } 834 }
838 835
@@ -868,7 +865,8 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
868 int r; 865 int r;
869 struct pgpath *p; 866 struct pgpath *p;
870 struct multipath *m = ti->private; 867 struct multipath *m = ti->private;
871 struct scsi_device *sdev; 868 struct request_queue *q;
869 const char *attached_handler_name;
872 870
873 /* we need at least a path arg */ 871 /* we need at least a path arg */
874 if (as->argc < 1) { 872 if (as->argc < 1) {
@@ -887,11 +885,11 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
887 goto bad; 885 goto bad;
888 } 886 }
889 887
890 sdev = scsi_device_from_queue(bdev_get_queue(p->path.dev->bdev)); 888 q = bdev_get_queue(p->path.dev->bdev);
891 if (sdev) { 889 attached_handler_name = scsi_dh_attached_handler_name(q, GFP_KERNEL);
892 put_device(&sdev->sdev_gendev); 890 if (attached_handler_name) {
893 INIT_DELAYED_WORK(&p->activate_path, activate_path_work); 891 INIT_DELAYED_WORK(&p->activate_path, activate_path_work);
894 r = setup_scsi_dh(p->path.dev->bdev, m, &ti->error); 892 r = setup_scsi_dh(p->path.dev->bdev, m, attached_handler_name, &ti->error);
895 if (r) { 893 if (r) {
896 dm_put_device(ti, p->path.dev); 894 dm_put_device(ti, p->path.dev);
897 goto bad; 895 goto bad;
@@ -2022,8 +2020,9 @@ static int multipath_busy(struct dm_target *ti)
2022 *---------------------------------------------------------------*/ 2020 *---------------------------------------------------------------*/
2023static struct target_type multipath_target = { 2021static struct target_type multipath_target = {
2024 .name = "multipath", 2022 .name = "multipath",
2025 .version = {1, 12, 0}, 2023 .version = {1, 13, 0},
2026 .features = DM_TARGET_SINGLETON | DM_TARGET_IMMUTABLE, 2024 .features = DM_TARGET_SINGLETON | DM_TARGET_IMMUTABLE |
2025 DM_TARGET_PASSES_INTEGRITY,
2027 .module = THIS_MODULE, 2026 .module = THIS_MODULE,
2028 .ctr = multipath_ctr, 2027 .ctr = multipath_ctr,
2029 .dtr = multipath_dtr, 2028 .dtr = multipath_dtr,
diff --git a/drivers/phy/qualcomm/phy-qcom-ufs.c b/drivers/phy/qualcomm/phy-qcom-ufs.c
index c5ff4525edef..c5493ea51282 100644
--- a/drivers/phy/qualcomm/phy-qcom-ufs.c
+++ b/drivers/phy/qualcomm/phy-qcom-ufs.c
@@ -675,3 +675,8 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy)
675 return 0; 675 return 0;
676} 676}
677EXPORT_SYMBOL_GPL(ufs_qcom_phy_power_off); 677EXPORT_SYMBOL_GPL(ufs_qcom_phy_power_off);
678
679MODULE_AUTHOR("Yaniv Gardi <ygardi@codeaurora.org>");
680MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>");
681MODULE_DESCRIPTION("Universal Flash Storage (UFS) QCOM PHY");
682MODULE_LICENSE("GPL v2");
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index d10ffe51da24..51ebc5a6053f 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -106,13 +106,14 @@ config ASUS_LAPTOP
106 If you have an ACPI-compatible ASUS laptop, say Y or M here. 106 If you have an ACPI-compatible ASUS laptop, say Y or M here.
107 107
108# 108#
109# If the DELL_SMBIOS_SMM feature is enabled, the DELL_SMBIOS driver 109# The DELL_SMBIOS driver depends on ACPI_WMI and/or DCDBAS if those
110# becomes dependent on the DCDBAS driver. The "depends" line prevents a 110# backends are selected. The "depends" line prevents a configuration
111# configuration where DELL_SMBIOS=y while DCDBAS=m. 111# where DELL_SMBIOS=y while either of those dependencies =m.
112# 112#
113config DELL_SMBIOS 113config DELL_SMBIOS
114 tristate "Dell SMBIOS driver" 114 tristate "Dell SMBIOS driver"
115 depends on DCDBAS || DCDBAS=n 115 depends on DCDBAS || DCDBAS=n
116 depends on ACPI_WMI || ACPI_WMI=n
116 ---help--- 117 ---help---
117 This provides support for the Dell SMBIOS calling interface. 118 This provides support for the Dell SMBIOS calling interface.
118 If you have a Dell computer you should enable this option. 119 If you have a Dell computer you should enable this option.
diff --git a/drivers/platform/x86/dell-smbios-base.c b/drivers/platform/x86/dell-smbios-base.c
index 5bcf8a18f785..2485c80a9fdd 100644
--- a/drivers/platform/x86/dell-smbios-base.c
+++ b/drivers/platform/x86/dell-smbios-base.c
@@ -637,7 +637,7 @@ static void __exit dell_smbios_exit(void)
637 mutex_unlock(&smbios_mutex); 637 mutex_unlock(&smbios_mutex);
638} 638}
639 639
640subsys_initcall(dell_smbios_init); 640module_init(dell_smbios_init);
641module_exit(dell_smbios_exit); 641module_exit(dell_smbios_exit);
642 642
643MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>"); 643MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c
index 2c9927430d85..8d102195a392 100644
--- a/drivers/platform/x86/dell-wmi.c
+++ b/drivers/platform/x86/dell-wmi.c
@@ -714,7 +714,7 @@ static int __init dell_wmi_init(void)
714 714
715 return wmi_driver_register(&dell_wmi_driver); 715 return wmi_driver_register(&dell_wmi_driver);
716} 716}
717module_init(dell_wmi_init); 717late_initcall(dell_wmi_init);
718 718
719static void __exit dell_wmi_exit(void) 719static void __exit dell_wmi_exit(void)
720{ 720{
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index c2ea13c7e37e..a1cb0236c550 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -10558,7 +10558,7 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
10558 snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name), 10558 snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name),
10559 "fw_event_%s%d", ioc->driver_name, ioc->id); 10559 "fw_event_%s%d", ioc->driver_name, ioc->id);
10560 ioc->firmware_event_thread = alloc_ordered_workqueue( 10560 ioc->firmware_event_thread = alloc_ordered_workqueue(
10561 ioc->firmware_event_name, WQ_MEM_RECLAIM); 10561 ioc->firmware_event_name, 0);
10562 if (!ioc->firmware_event_thread) { 10562 if (!ioc->firmware_event_thread) {
10563 pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n", 10563 pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
10564 ioc->name, __FILE__, __LINE__, __func__); 10564 ioc->name, __FILE__, __LINE__, __func__);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 285911e81728..5c5dcca4d1da 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -454,7 +454,7 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req,
454 ha->req_q_map[0] = req; 454 ha->req_q_map[0] = req;
455 set_bit(0, ha->rsp_qid_map); 455 set_bit(0, ha->rsp_qid_map);
456 set_bit(0, ha->req_qid_map); 456 set_bit(0, ha->req_qid_map);
457 return 1; 457 return 0;
458 458
459fail_qpair_map: 459fail_qpair_map:
460 kfree(ha->base_qpair); 460 kfree(ha->base_qpair);
@@ -471,6 +471,9 @@ fail_req_map:
471 471
472static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req) 472static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req)
473{ 473{
474 if (!ha->req_q_map)
475 return;
476
474 if (IS_QLAFX00(ha)) { 477 if (IS_QLAFX00(ha)) {
475 if (req && req->ring_fx00) 478 if (req && req->ring_fx00)
476 dma_free_coherent(&ha->pdev->dev, 479 dma_free_coherent(&ha->pdev->dev,
@@ -481,14 +484,17 @@ static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req)
481 (req->length + 1) * sizeof(request_t), 484 (req->length + 1) * sizeof(request_t),
482 req->ring, req->dma); 485 req->ring, req->dma);
483 486
484 if (req) 487 if (req) {
485 kfree(req->outstanding_cmds); 488 kfree(req->outstanding_cmds);
486 489 kfree(req);
487 kfree(req); 490 }
488} 491}
489 492
490static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) 493static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp)
491{ 494{
495 if (!ha->rsp_q_map)
496 return;
497
492 if (IS_QLAFX00(ha)) { 498 if (IS_QLAFX00(ha)) {
493 if (rsp && rsp->ring) 499 if (rsp && rsp->ring)
494 dma_free_coherent(&ha->pdev->dev, 500 dma_free_coherent(&ha->pdev->dev,
@@ -499,7 +505,8 @@ static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp)
499 (rsp->length + 1) * sizeof(response_t), 505 (rsp->length + 1) * sizeof(response_t),
500 rsp->ring, rsp->dma); 506 rsp->ring, rsp->dma);
501 } 507 }
502 kfree(rsp); 508 if (rsp)
509 kfree(rsp);
503} 510}
504 511
505static void qla2x00_free_queues(struct qla_hw_data *ha) 512static void qla2x00_free_queues(struct qla_hw_data *ha)
@@ -1723,6 +1730,8 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)
1723 struct qla_tgt_cmd *cmd; 1730 struct qla_tgt_cmd *cmd;
1724 uint8_t trace = 0; 1731 uint8_t trace = 0;
1725 1732
1733 if (!ha->req_q_map)
1734 return;
1726 spin_lock_irqsave(qp->qp_lock_ptr, flags); 1735 spin_lock_irqsave(qp->qp_lock_ptr, flags);
1727 req = qp->req; 1736 req = qp->req;
1728 for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { 1737 for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) {
@@ -3095,14 +3104,14 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
3095 /* Set up the irqs */ 3104 /* Set up the irqs */
3096 ret = qla2x00_request_irqs(ha, rsp); 3105 ret = qla2x00_request_irqs(ha, rsp);
3097 if (ret) 3106 if (ret)
3098 goto probe_hw_failed; 3107 goto probe_failed;
3099 3108
3100 /* Alloc arrays of request and response ring ptrs */ 3109 /* Alloc arrays of request and response ring ptrs */
3101 if (!qla2x00_alloc_queues(ha, req, rsp)) { 3110 if (qla2x00_alloc_queues(ha, req, rsp)) {
3102 ql_log(ql_log_fatal, base_vha, 0x003d, 3111 ql_log(ql_log_fatal, base_vha, 0x003d,
3103 "Failed to allocate memory for queue pointers..." 3112 "Failed to allocate memory for queue pointers..."
3104 "aborting.\n"); 3113 "aborting.\n");
3105 goto probe_init_failed; 3114 goto probe_failed;
3106 } 3115 }
3107 3116
3108 if (ha->mqenable && shost_use_blk_mq(host)) { 3117 if (ha->mqenable && shost_use_blk_mq(host)) {
@@ -3387,15 +3396,6 @@ skip_dpc:
3387 3396
3388 return 0; 3397 return 0;
3389 3398
3390probe_init_failed:
3391 qla2x00_free_req_que(ha, req);
3392 ha->req_q_map[0] = NULL;
3393 clear_bit(0, ha->req_qid_map);
3394 qla2x00_free_rsp_que(ha, rsp);
3395 ha->rsp_q_map[0] = NULL;
3396 clear_bit(0, ha->rsp_qid_map);
3397 ha->max_req_queues = ha->max_rsp_queues = 0;
3398
3399probe_failed: 3399probe_failed:
3400 if (base_vha->timer_active) 3400 if (base_vha->timer_active)
3401 qla2x00_stop_timer(base_vha); 3401 qla2x00_stop_timer(base_vha);
@@ -4508,11 +4508,17 @@ qla2x00_mem_free(struct qla_hw_data *ha)
4508 if (ha->init_cb) 4508 if (ha->init_cb)
4509 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, 4509 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size,
4510 ha->init_cb, ha->init_cb_dma); 4510 ha->init_cb, ha->init_cb_dma);
4511 vfree(ha->optrom_buffer); 4511
4512 kfree(ha->nvram); 4512 if (ha->optrom_buffer)
4513 kfree(ha->npiv_info); 4513 vfree(ha->optrom_buffer);
4514 kfree(ha->swl); 4514 if (ha->nvram)
4515 kfree(ha->loop_id_map); 4515 kfree(ha->nvram);
4516 if (ha->npiv_info)
4517 kfree(ha->npiv_info);
4518 if (ha->swl)
4519 kfree(ha->swl);
4520 if (ha->loop_id_map)
4521 kfree(ha->loop_id_map);
4516 4522
4517 ha->srb_mempool = NULL; 4523 ha->srb_mempool = NULL;
4518 ha->ctx_mempool = NULL; 4524 ha->ctx_mempool = NULL;
@@ -4528,6 +4534,15 @@ qla2x00_mem_free(struct qla_hw_data *ha)
4528 ha->ex_init_cb_dma = 0; 4534 ha->ex_init_cb_dma = 0;
4529 ha->async_pd = NULL; 4535 ha->async_pd = NULL;
4530 ha->async_pd_dma = 0; 4536 ha->async_pd_dma = 0;
4537 ha->loop_id_map = NULL;
4538 ha->npiv_info = NULL;
4539 ha->optrom_buffer = NULL;
4540 ha->swl = NULL;
4541 ha->nvram = NULL;
4542 ha->mctp_dump = NULL;
4543 ha->dcbx_tlv = NULL;
4544 ha->xgmac_data = NULL;
4545 ha->sfp_data = NULL;
4531 4546
4532 ha->s_dma_pool = NULL; 4547 ha->s_dma_pool = NULL;
4533 ha->dl_dma_pool = NULL; 4548 ha->dl_dma_pool = NULL;
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index bff21e636ddd..3541caf3fceb 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2595,6 +2595,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
2595 int res; 2595 int res;
2596 struct scsi_device *sdp = sdkp->device; 2596 struct scsi_device *sdp = sdkp->device;
2597 struct scsi_mode_data data; 2597 struct scsi_mode_data data;
2598 int disk_ro = get_disk_ro(sdkp->disk);
2598 int old_wp = sdkp->write_prot; 2599 int old_wp = sdkp->write_prot;
2599 2600
2600 set_disk_ro(sdkp->disk, 0); 2601 set_disk_ro(sdkp->disk, 0);
@@ -2635,7 +2636,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
2635 "Test WP failed, assume Write Enabled\n"); 2636 "Test WP failed, assume Write Enabled\n");
2636 } else { 2637 } else {
2637 sdkp->write_prot = ((data.device_specific & 0x80) != 0); 2638 sdkp->write_prot = ((data.device_specific & 0x80) != 0);
2638 set_disk_ro(sdkp->disk, sdkp->write_prot); 2639 set_disk_ro(sdkp->disk, sdkp->write_prot || disk_ro);
2639 if (sdkp->first_scan || old_wp != sdkp->write_prot) { 2640 if (sdkp->first_scan || old_wp != sdkp->write_prot) {
2640 sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n", 2641 sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
2641 sdkp->write_prot ? "on" : "off"); 2642 sdkp->write_prot ? "on" : "off");
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 6c348a211ebb..89cf4498f535 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -403,7 +403,7 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf)
403 */ 403 */
404static int sd_zbc_check_zone_size(struct scsi_disk *sdkp) 404static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
405{ 405{
406 u64 zone_blocks; 406 u64 zone_blocks = 0;
407 sector_t block = 0; 407 sector_t block = 0;
408 unsigned char *buf; 408 unsigned char *buf;
409 unsigned char *rec; 409 unsigned char *rec;
@@ -421,10 +421,8 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
421 421
422 /* Do a report zone to get the same field */ 422 /* Do a report zone to get the same field */
423 ret = sd_zbc_report_zones(sdkp, buf, SD_ZBC_BUF_SIZE, 0); 423 ret = sd_zbc_report_zones(sdkp, buf, SD_ZBC_BUF_SIZE, 0);
424 if (ret) { 424 if (ret)
425 zone_blocks = 0; 425 goto out_free;
426 goto out;
427 }
428 426
429 same = buf[4] & 0x0f; 427 same = buf[4] & 0x0f;
430 if (same > 0) { 428 if (same > 0) {
@@ -464,7 +462,7 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
464 ret = sd_zbc_report_zones(sdkp, buf, 462 ret = sd_zbc_report_zones(sdkp, buf,
465 SD_ZBC_BUF_SIZE, block); 463 SD_ZBC_BUF_SIZE, block);
466 if (ret) 464 if (ret)
467 return ret; 465 goto out_free;
468 } 466 }
469 467
470 } while (block < sdkp->capacity); 468 } while (block < sdkp->capacity);
@@ -472,35 +470,32 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
472 zone_blocks = sdkp->zone_blocks; 470 zone_blocks = sdkp->zone_blocks;
473 471
474out: 472out:
475 kfree(buf);
476
477 if (!zone_blocks) { 473 if (!zone_blocks) {
478 if (sdkp->first_scan) 474 if (sdkp->first_scan)
479 sd_printk(KERN_NOTICE, sdkp, 475 sd_printk(KERN_NOTICE, sdkp,
480 "Devices with non constant zone " 476 "Devices with non constant zone "
481 "size are not supported\n"); 477 "size are not supported\n");
482 return -ENODEV; 478 ret = -ENODEV;
483 } 479 } else if (!is_power_of_2(zone_blocks)) {
484
485 if (!is_power_of_2(zone_blocks)) {
486 if (sdkp->first_scan) 480 if (sdkp->first_scan)
487 sd_printk(KERN_NOTICE, sdkp, 481 sd_printk(KERN_NOTICE, sdkp,
488 "Devices with non power of 2 zone " 482 "Devices with non power of 2 zone "
489 "size are not supported\n"); 483 "size are not supported\n");
490 return -ENODEV; 484 ret = -ENODEV;
491 } 485 } else if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) {
492
493 if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) {
494 if (sdkp->first_scan) 486 if (sdkp->first_scan)
495 sd_printk(KERN_NOTICE, sdkp, 487 sd_printk(KERN_NOTICE, sdkp,
496 "Zone size too large\n"); 488 "Zone size too large\n");
497 return -ENODEV; 489 ret = -ENODEV;
490 } else {
491 sdkp->zone_blocks = zone_blocks;
492 sdkp->zone_shift = ilog2(zone_blocks);
498 } 493 }
499 494
500 sdkp->zone_blocks = zone_blocks; 495out_free:
501 sdkp->zone_shift = ilog2(zone_blocks); 496 kfree(buf);
502 497
503 return 0; 498 return ret;
504} 499}
505 500
506/** 501/**
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 6dbba5aff191..86580b6df33d 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -326,24 +326,23 @@ static loff_t ashmem_llseek(struct file *file, loff_t offset, int origin)
326 mutex_lock(&ashmem_mutex); 326 mutex_lock(&ashmem_mutex);
327 327
328 if (asma->size == 0) { 328 if (asma->size == 0) {
329 ret = -EINVAL; 329 mutex_unlock(&ashmem_mutex);
330 goto out; 330 return -EINVAL;
331 } 331 }
332 332
333 if (!asma->file) { 333 if (!asma->file) {
334 ret = -EBADF; 334 mutex_unlock(&ashmem_mutex);
335 goto out; 335 return -EBADF;
336 } 336 }
337 337
338 mutex_unlock(&ashmem_mutex);
339
338 ret = vfs_llseek(asma->file, offset, origin); 340 ret = vfs_llseek(asma->file, offset, origin);
339 if (ret < 0) 341 if (ret < 0)
340 goto out; 342 return ret;
341 343
342 /** Copy f_pos from backing file, since f_ops->llseek() sets it */ 344 /** Copy f_pos from backing file, since f_ops->llseek() sets it */
343 file->f_pos = asma->file->f_pos; 345 file->f_pos = asma->file->f_pos;
344
345out:
346 mutex_unlock(&ashmem_mutex);
347 return ret; 346 return ret;
348} 347}
349 348
@@ -702,16 +701,14 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd,
702 size_t pgstart, pgend; 701 size_t pgstart, pgend;
703 int ret = -EINVAL; 702 int ret = -EINVAL;
704 703
704 if (unlikely(copy_from_user(&pin, p, sizeof(pin))))
705 return -EFAULT;
706
705 mutex_lock(&ashmem_mutex); 707 mutex_lock(&ashmem_mutex);
706 708
707 if (unlikely(!asma->file)) 709 if (unlikely(!asma->file))
708 goto out_unlock; 710 goto out_unlock;
709 711
710 if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) {
711 ret = -EFAULT;
712 goto out_unlock;
713 }
714
715 /* per custom, you can pass zero for len to mean "everything onward" */ 712 /* per custom, you can pass zero for len to mean "everything onward" */
716 if (!pin.len) 713 if (!pin.len)
717 pin.len = PAGE_ALIGN(asma->size) - pin.offset; 714 pin.len = PAGE_ALIGN(asma->size) - pin.offset;
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index e618a87521a3..9d733471ca2e 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -475,8 +475,7 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s,
475 struct comedi_cmd *cmd = &async->cmd; 475 struct comedi_cmd *cmd = &async->cmd;
476 476
477 if (cmd->stop_src == TRIG_COUNT) { 477 if (cmd->stop_src == TRIG_COUNT) {
478 unsigned int nscans = nsamples / cmd->scan_end_arg; 478 unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg);
479 unsigned int scans_left = __comedi_nscans_left(s, nscans);
480 unsigned int scan_pos = 479 unsigned int scan_pos =
481 comedi_bytes_to_samples(s, async->scan_progress); 480 comedi_bytes_to_samples(s, async->scan_progress);
482 unsigned long long samples_left = 0; 481 unsigned long long samples_left = 0;
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 5c0e59e8fe46..cbe98bc2b998 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -2180,6 +2180,12 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
2180 } 2180 }
2181 if (tty_hung_up_p(file)) 2181 if (tty_hung_up_p(file))
2182 break; 2182 break;
2183 /*
2184 * Abort readers for ttys which never actually
2185 * get hung up. See __tty_hangup().
2186 */
2187 if (test_bit(TTY_HUPPING, &tty->flags))
2188 break;
2183 if (!timeout) 2189 if (!timeout)
2184 break; 2190 break;
2185 if (file->f_flags & O_NONBLOCK) { 2191 if (file->f_flags & O_NONBLOCK) {
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 54adf8d56350..a93f77ab3da0 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -3387,11 +3387,9 @@ static int serial_pci_is_class_communication(struct pci_dev *dev)
3387 /* 3387 /*
3388 * If it is not a communications device or the programming 3388 * If it is not a communications device or the programming
3389 * interface is greater than 6, give up. 3389 * interface is greater than 6, give up.
3390 *
3391 * (Should we try to make guesses for multiport serial devices
3392 * later?)
3393 */ 3390 */
3394 if ((((dev->class >> 8) != PCI_CLASS_COMMUNICATION_SERIAL) && 3391 if ((((dev->class >> 8) != PCI_CLASS_COMMUNICATION_SERIAL) &&
3392 ((dev->class >> 8) != PCI_CLASS_COMMUNICATION_MULTISERIAL) &&
3395 ((dev->class >> 8) != PCI_CLASS_COMMUNICATION_MODEM)) || 3393 ((dev->class >> 8) != PCI_CLASS_COMMUNICATION_MODEM)) ||
3396 (dev->class & 0xff) > 6) 3394 (dev->class & 0xff) > 6)
3397 return -ENODEV; 3395 return -ENODEV;
@@ -3428,6 +3426,12 @@ serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board)
3428{ 3426{
3429 int num_iomem, num_port, first_port = -1, i; 3427 int num_iomem, num_port, first_port = -1, i;
3430 3428
3429 /*
3430 * Should we try to make guesses for multiport serial devices later?
3431 */
3432 if ((dev->class >> 8) == PCI_CLASS_COMMUNICATION_MULTISERIAL)
3433 return -ENODEV;
3434
3431 num_iomem = num_port = 0; 3435 num_iomem = num_port = 0;
3432 for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) { 3436 for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) {
3433 if (pci_resource_flags(dev, i) & IORESOURCE_IO) { 3437 if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
@@ -4699,6 +4703,17 @@ static const struct pci_device_id serial_pci_tbl[] = {
4699 PCI_ANY_ID, PCI_ANY_ID, 0, 0, /* 135a.0dc0 */ 4703 PCI_ANY_ID, PCI_ANY_ID, 0, 0, /* 135a.0dc0 */
4700 pbn_b2_4_115200 }, 4704 pbn_b2_4_115200 },
4701 /* 4705 /*
4706 * BrainBoxes UC-260
4707 */
4708 { PCI_VENDOR_ID_INTASHIELD, 0x0D21,
4709 PCI_ANY_ID, PCI_ANY_ID,
4710 PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00,
4711 pbn_b2_4_115200 },
4712 { PCI_VENDOR_ID_INTASHIELD, 0x0E34,
4713 PCI_ANY_ID, PCI_ANY_ID,
4714 PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00,
4715 pbn_b2_4_115200 },
4716 /*
4702 * Perle PCI-RAS cards 4717 * Perle PCI-RAS cards
4703 */ 4718 */
4704 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, 4719 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030,
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index df46a9e88c34..e287fe8f10fc 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1734,6 +1734,7 @@ static void atmel_get_ip_name(struct uart_port *port)
1734 switch (version) { 1734 switch (version) {
1735 case 0x302: 1735 case 0x302:
1736 case 0x10213: 1736 case 0x10213:
1737 case 0x10302:
1737 dev_dbg(port->dev, "This version is usart\n"); 1738 dev_dbg(port->dev, "This version is usart\n");
1738 atmel_port->has_frac_baudrate = true; 1739 atmel_port->has_frac_baudrate = true;
1739 atmel_port->has_hw_timer = true; 1740 atmel_port->has_hw_timer = true;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 870e84fb6e39..a24278380fec 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -245,11 +245,12 @@ int __init of_setup_earlycon(const struct earlycon_id *match,
245 } 245 }
246 port->mapbase = addr; 246 port->mapbase = addr;
247 port->uartclk = BASE_BAUD * 16; 247 port->uartclk = BASE_BAUD * 16;
248 port->membase = earlycon_map(port->mapbase, SZ_4K);
249 248
250 val = of_get_flat_dt_prop(node, "reg-offset", NULL); 249 val = of_get_flat_dt_prop(node, "reg-offset", NULL);
251 if (val) 250 if (val)
252 port->mapbase += be32_to_cpu(*val); 251 port->mapbase += be32_to_cpu(*val);
252 port->membase = earlycon_map(port->mapbase, SZ_4K);
253
253 val = of_get_flat_dt_prop(node, "reg-shift", NULL); 254 val = of_get_flat_dt_prop(node, "reg-shift", NULL);
254 if (val) 255 if (val)
255 port->regshift = be32_to_cpu(*val); 256 port->regshift = be32_to_cpu(*val);
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1d7ca382bc12..a33c685af990 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -2093,7 +2093,7 @@ static int serial_imx_probe(struct platform_device *pdev)
2093 uart_get_rs485_mode(&pdev->dev, &sport->port.rs485); 2093 uart_get_rs485_mode(&pdev->dev, &sport->port.rs485);
2094 2094
2095 if (sport->port.rs485.flags & SER_RS485_ENABLED && 2095 if (sport->port.rs485.flags & SER_RS485_ENABLED &&
2096 (!sport->have_rtscts || !sport->have_rtsgpio)) 2096 (!sport->have_rtscts && !sport->have_rtsgpio))
2097 dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); 2097 dev_err(&pdev->dev, "no RTS control, disabling rs485\n");
2098 2098
2099 imx_rs485_config(&sport->port, &sport->port.rs485); 2099 imx_rs485_config(&sport->port, &sport->port.rs485);
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index c8dde56b532b..35b9201db3b4 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1144,6 +1144,8 @@ static int uart_do_autoconfig(struct tty_struct *tty,struct uart_state *state)
1144 uport->ops->config_port(uport, flags); 1144 uport->ops->config_port(uport, flags);
1145 1145
1146 ret = uart_startup(tty, state, 1); 1146 ret = uart_startup(tty, state, 1);
1147 if (ret == 0)
1148 tty_port_set_initialized(port, true);
1147 if (ret > 0) 1149 if (ret > 0)
1148 ret = 0; 1150 ret = 0;
1149 } 1151 }
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 7257c078e155..44adf9db38f8 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -885,6 +885,8 @@ static void sci_receive_chars(struct uart_port *port)
885 /* Tell the rest of the system the news. New characters! */ 885 /* Tell the rest of the system the news. New characters! */
886 tty_flip_buffer_push(tport); 886 tty_flip_buffer_push(tport);
887 } else { 887 } else {
888 /* TTY buffers full; read from RX reg to prevent lockup */
889 serial_port_in(port, SCxRDR);
888 serial_port_in(port, SCxSR); /* dummy read */ 890 serial_port_in(port, SCxSR); /* dummy read */
889 sci_clear_SCxSR(port, SCxSR_RDxF_CLEAR(port)); 891 sci_clear_SCxSR(port, SCxSR_RDxF_CLEAR(port));
890 } 892 }
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index eb9133b472f4..63114ea35ec1 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -586,6 +586,14 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)
586 return; 586 return;
587 } 587 }
588 588
589 /*
590 * Some console devices aren't actually hung up for technical and
591 * historical reasons, which can lead to indefinite interruptible
592 * sleep in n_tty_read(). The following explicitly tells
593 * n_tty_read() to abort readers.
594 */
595 set_bit(TTY_HUPPING, &tty->flags);
596
589 /* inuse_filps is protected by the single tty lock, 597 /* inuse_filps is protected by the single tty lock,
590 this really needs to change if we want to flush the 598 this really needs to change if we want to flush the
591 workqueue with the lock held */ 599 workqueue with the lock held */
@@ -640,6 +648,7 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)
640 * from the ldisc side, which is now guaranteed. 648 * from the ldisc side, which is now guaranteed.
641 */ 649 */
642 set_bit(TTY_HUPPED, &tty->flags); 650 set_bit(TTY_HUPPED, &tty->flags);
651 clear_bit(TTY_HUPPING, &tty->flags);
643 tty_unlock(tty); 652 tty_unlock(tty);
644 653
645 if (f) 654 if (f)
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index c64cf6c4a83d..0c11d40a12bc 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -151,6 +151,10 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
151 151
152 ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); 152 ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout);
153 153
154 /* Linger a bit, prior to the next control message. */
155 if (dev->quirks & USB_QUIRK_DELAY_CTRL_MSG)
156 msleep(200);
157
154 kfree(dr); 158 kfree(dr);
155 159
156 return ret; 160 return ret;
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index f4a548471f0f..54b019e267c5 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -230,7 +230,8 @@ static const struct usb_device_id usb_quirk_list[] = {
230 { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT }, 230 { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT },
231 231
232 /* Corsair Strafe RGB */ 232 /* Corsair Strafe RGB */
233 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, 233 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT |
234 USB_QUIRK_DELAY_CTRL_MSG },
234 235
235 /* Corsair K70 LUX */ 236 /* Corsair K70 LUX */
236 { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT }, 237 { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 03fd20f0b496..c4a47496d2fb 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -137,7 +137,7 @@ static void dwc2_set_stm32f4x9_fsotg_params(struct dwc2_hsotg *hsotg)
137 p->activate_stm_fs_transceiver = true; 137 p->activate_stm_fs_transceiver = true;
138} 138}
139 139
140static void dwc2_set_stm32f7xx_hsotg_params(struct dwc2_hsotg *hsotg) 140static void dwc2_set_stm32f7_hsotg_params(struct dwc2_hsotg *hsotg)
141{ 141{
142 struct dwc2_core_params *p = &hsotg->params; 142 struct dwc2_core_params *p = &hsotg->params;
143 143
@@ -164,8 +164,8 @@ const struct of_device_id dwc2_of_match_table[] = {
164 { .compatible = "st,stm32f4x9-fsotg", 164 { .compatible = "st,stm32f4x9-fsotg",
165 .data = dwc2_set_stm32f4x9_fsotg_params }, 165 .data = dwc2_set_stm32f4x9_fsotg_params },
166 { .compatible = "st,stm32f4x9-hsotg" }, 166 { .compatible = "st,stm32f4x9-hsotg" },
167 { .compatible = "st,stm32f7xx-hsotg", 167 { .compatible = "st,stm32f7-hsotg",
168 .data = dwc2_set_stm32f7xx_hsotg_params }, 168 .data = dwc2_set_stm32f7_hsotg_params },
169 {}, 169 {},
170}; 170};
171MODULE_DEVICE_TABLE(of, dwc2_of_match_table); 171MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index f1d838a4acd6..e94bf91cc58a 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -175,7 +175,7 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
175 dwc->desired_dr_role = mode; 175 dwc->desired_dr_role = mode;
176 spin_unlock_irqrestore(&dwc->lock, flags); 176 spin_unlock_irqrestore(&dwc->lock, flags);
177 177
178 queue_work(system_power_efficient_wq, &dwc->drd_work); 178 queue_work(system_freezable_wq, &dwc->drd_work);
179} 179}
180 180
181u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type) 181u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index c2592d883f67..d2428a9e8900 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1538,7 +1538,6 @@ ffs_fs_kill_sb(struct super_block *sb)
1538 if (sb->s_fs_info) { 1538 if (sb->s_fs_info) {
1539 ffs_release_dev(sb->s_fs_info); 1539 ffs_release_dev(sb->s_fs_info);
1540 ffs_data_closed(sb->s_fs_info); 1540 ffs_data_closed(sb->s_fs_info);
1541 ffs_data_put(sb->s_fs_info);
1542 } 1541 }
1543} 1542}
1544 1543
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 84f88fa411cd..d088c340e4d0 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -447,7 +447,8 @@ static int ohci_init (struct ohci_hcd *ohci)
447 struct usb_hcd *hcd = ohci_to_hcd(ohci); 447 struct usb_hcd *hcd = ohci_to_hcd(ohci);
448 448
449 /* Accept arbitrarily long scatter-gather lists */ 449 /* Accept arbitrarily long scatter-gather lists */
450 hcd->self.sg_tablesize = ~0; 450 if (!(hcd->driver->flags & HCD_LOCAL_MEM))
451 hcd->self.sg_tablesize = ~0;
451 452
452 if (distrust_firmware) 453 if (distrust_firmware)
453 ohci->flags |= OHCI_QUIRK_HUB_POWER; 454 ohci->flags |= OHCI_QUIRK_HUB_POWER;
diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c
index a1ab8acf39ba..c359bae7b754 100644
--- a/drivers/usb/host/xhci-dbgcap.c
+++ b/drivers/usb/host/xhci-dbgcap.c
@@ -328,13 +328,14 @@ dbc_ep_do_queue(struct dbc_ep *dep, struct dbc_request *req)
328int dbc_ep_queue(struct dbc_ep *dep, struct dbc_request *req, 328int dbc_ep_queue(struct dbc_ep *dep, struct dbc_request *req,
329 gfp_t gfp_flags) 329 gfp_t gfp_flags)
330{ 330{
331 unsigned long flags;
331 struct xhci_dbc *dbc = dep->dbc; 332 struct xhci_dbc *dbc = dep->dbc;
332 int ret = -ESHUTDOWN; 333 int ret = -ESHUTDOWN;
333 334
334 spin_lock(&dbc->lock); 335 spin_lock_irqsave(&dbc->lock, flags);
335 if (dbc->state == DS_CONFIGURED) 336 if (dbc->state == DS_CONFIGURED)
336 ret = dbc_ep_do_queue(dep, req); 337 ret = dbc_ep_do_queue(dep, req);
337 spin_unlock(&dbc->lock); 338 spin_unlock_irqrestore(&dbc->lock, flags);
338 339
339 mod_delayed_work(system_wq, &dbc->event_work, 0); 340 mod_delayed_work(system_wq, &dbc->event_work, 0);
340 341
@@ -521,15 +522,16 @@ static void xhci_do_dbc_stop(struct xhci_hcd *xhci)
521static int xhci_dbc_start(struct xhci_hcd *xhci) 522static int xhci_dbc_start(struct xhci_hcd *xhci)
522{ 523{
523 int ret; 524 int ret;
525 unsigned long flags;
524 struct xhci_dbc *dbc = xhci->dbc; 526 struct xhci_dbc *dbc = xhci->dbc;
525 527
526 WARN_ON(!dbc); 528 WARN_ON(!dbc);
527 529
528 pm_runtime_get_sync(xhci_to_hcd(xhci)->self.controller); 530 pm_runtime_get_sync(xhci_to_hcd(xhci)->self.controller);
529 531
530 spin_lock(&dbc->lock); 532 spin_lock_irqsave(&dbc->lock, flags);
531 ret = xhci_do_dbc_start(xhci); 533 ret = xhci_do_dbc_start(xhci);
532 spin_unlock(&dbc->lock); 534 spin_unlock_irqrestore(&dbc->lock, flags);
533 535
534 if (ret) { 536 if (ret) {
535 pm_runtime_put(xhci_to_hcd(xhci)->self.controller); 537 pm_runtime_put(xhci_to_hcd(xhci)->self.controller);
@@ -541,6 +543,7 @@ static int xhci_dbc_start(struct xhci_hcd *xhci)
541 543
542static void xhci_dbc_stop(struct xhci_hcd *xhci) 544static void xhci_dbc_stop(struct xhci_hcd *xhci)
543{ 545{
546 unsigned long flags;
544 struct xhci_dbc *dbc = xhci->dbc; 547 struct xhci_dbc *dbc = xhci->dbc;
545 struct dbc_port *port = &dbc->port; 548 struct dbc_port *port = &dbc->port;
546 549
@@ -551,9 +554,9 @@ static void xhci_dbc_stop(struct xhci_hcd *xhci)
551 if (port->registered) 554 if (port->registered)
552 xhci_dbc_tty_unregister_device(xhci); 555 xhci_dbc_tty_unregister_device(xhci);
553 556
554 spin_lock(&dbc->lock); 557 spin_lock_irqsave(&dbc->lock, flags);
555 xhci_do_dbc_stop(xhci); 558 xhci_do_dbc_stop(xhci);
556 spin_unlock(&dbc->lock); 559 spin_unlock_irqrestore(&dbc->lock, flags);
557 560
558 pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller); 561 pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller);
559} 562}
@@ -779,14 +782,15 @@ static void xhci_dbc_handle_events(struct work_struct *work)
779 int ret; 782 int ret;
780 enum evtreturn evtr; 783 enum evtreturn evtr;
781 struct xhci_dbc *dbc; 784 struct xhci_dbc *dbc;
785 unsigned long flags;
782 struct xhci_hcd *xhci; 786 struct xhci_hcd *xhci;
783 787
784 dbc = container_of(to_delayed_work(work), struct xhci_dbc, event_work); 788 dbc = container_of(to_delayed_work(work), struct xhci_dbc, event_work);
785 xhci = dbc->xhci; 789 xhci = dbc->xhci;
786 790
787 spin_lock(&dbc->lock); 791 spin_lock_irqsave(&dbc->lock, flags);
788 evtr = xhci_dbc_do_handle_events(dbc); 792 evtr = xhci_dbc_do_handle_events(dbc);
789 spin_unlock(&dbc->lock); 793 spin_unlock_irqrestore(&dbc->lock, flags);
790 794
791 switch (evtr) { 795 switch (evtr) {
792 case EVT_GSER: 796 case EVT_GSER:
diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
index 8d47b6fbf973..75f0b92694ba 100644
--- a/drivers/usb/host/xhci-dbgtty.c
+++ b/drivers/usb/host/xhci-dbgtty.c
@@ -92,21 +92,23 @@ static void dbc_start_rx(struct dbc_port *port)
92static void 92static void
93dbc_read_complete(struct xhci_hcd *xhci, struct dbc_request *req) 93dbc_read_complete(struct xhci_hcd *xhci, struct dbc_request *req)
94{ 94{
95 unsigned long flags;
95 struct xhci_dbc *dbc = xhci->dbc; 96 struct xhci_dbc *dbc = xhci->dbc;
96 struct dbc_port *port = &dbc->port; 97 struct dbc_port *port = &dbc->port;
97 98
98 spin_lock(&port->port_lock); 99 spin_lock_irqsave(&port->port_lock, flags);
99 list_add_tail(&req->list_pool, &port->read_queue); 100 list_add_tail(&req->list_pool, &port->read_queue);
100 tasklet_schedule(&port->push); 101 tasklet_schedule(&port->push);
101 spin_unlock(&port->port_lock); 102 spin_unlock_irqrestore(&port->port_lock, flags);
102} 103}
103 104
104static void dbc_write_complete(struct xhci_hcd *xhci, struct dbc_request *req) 105static void dbc_write_complete(struct xhci_hcd *xhci, struct dbc_request *req)
105{ 106{
107 unsigned long flags;
106 struct xhci_dbc *dbc = xhci->dbc; 108 struct xhci_dbc *dbc = xhci->dbc;
107 struct dbc_port *port = &dbc->port; 109 struct dbc_port *port = &dbc->port;
108 110
109 spin_lock(&port->port_lock); 111 spin_lock_irqsave(&port->port_lock, flags);
110 list_add(&req->list_pool, &port->write_pool); 112 list_add(&req->list_pool, &port->write_pool);
111 switch (req->status) { 113 switch (req->status) {
112 case 0: 114 case 0:
@@ -119,7 +121,7 @@ static void dbc_write_complete(struct xhci_hcd *xhci, struct dbc_request *req)
119 req->status); 121 req->status);
120 break; 122 break;
121 } 123 }
122 spin_unlock(&port->port_lock); 124 spin_unlock_irqrestore(&port->port_lock, flags);
123} 125}
124 126
125static void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req) 127static void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req)
@@ -327,12 +329,13 @@ static void dbc_rx_push(unsigned long _port)
327{ 329{
328 struct dbc_request *req; 330 struct dbc_request *req;
329 struct tty_struct *tty; 331 struct tty_struct *tty;
332 unsigned long flags;
330 bool do_push = false; 333 bool do_push = false;
331 bool disconnect = false; 334 bool disconnect = false;
332 struct dbc_port *port = (void *)_port; 335 struct dbc_port *port = (void *)_port;
333 struct list_head *queue = &port->read_queue; 336 struct list_head *queue = &port->read_queue;
334 337
335 spin_lock_irq(&port->port_lock); 338 spin_lock_irqsave(&port->port_lock, flags);
336 tty = port->port.tty; 339 tty = port->port.tty;
337 while (!list_empty(queue)) { 340 while (!list_empty(queue)) {
338 req = list_first_entry(queue, struct dbc_request, list_pool); 341 req = list_first_entry(queue, struct dbc_request, list_pool);
@@ -392,16 +395,17 @@ static void dbc_rx_push(unsigned long _port)
392 if (!disconnect) 395 if (!disconnect)
393 dbc_start_rx(port); 396 dbc_start_rx(port);
394 397
395 spin_unlock_irq(&port->port_lock); 398 spin_unlock_irqrestore(&port->port_lock, flags);
396} 399}
397 400
398static int dbc_port_activate(struct tty_port *_port, struct tty_struct *tty) 401static int dbc_port_activate(struct tty_port *_port, struct tty_struct *tty)
399{ 402{
403 unsigned long flags;
400 struct dbc_port *port = container_of(_port, struct dbc_port, port); 404 struct dbc_port *port = container_of(_port, struct dbc_port, port);
401 405
402 spin_lock_irq(&port->port_lock); 406 spin_lock_irqsave(&port->port_lock, flags);
403 dbc_start_rx(port); 407 dbc_start_rx(port);
404 spin_unlock_irq(&port->port_lock); 408 spin_unlock_irqrestore(&port->port_lock, flags);
405 409
406 return 0; 410 return 0;
407} 411}
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 5262fa571a5d..d9f831b67e57 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -126,6 +126,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
126 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info()) 126 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
127 xhci->quirks |= XHCI_AMD_PLL_FIX; 127 xhci->quirks |= XHCI_AMD_PLL_FIX;
128 128
129 if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x43bb)
130 xhci->quirks |= XHCI_SUSPEND_DELAY;
131
129 if (pdev->vendor == PCI_VENDOR_ID_AMD) 132 if (pdev->vendor == PCI_VENDOR_ID_AMD)
130 xhci->quirks |= XHCI_TRUST_TX_LENGTH; 133 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
131 134
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 6f038306c14d..6652e2d5bd2e 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -360,7 +360,6 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
360{ 360{
361 struct usb_hcd *hcd = dev_get_drvdata(dev); 361 struct usb_hcd *hcd = dev_get_drvdata(dev);
362 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 362 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
363 int ret;
364 363
365 /* 364 /*
366 * xhci_suspend() needs `do_wakeup` to know whether host is allowed 365 * xhci_suspend() needs `do_wakeup` to know whether host is allowed
@@ -370,12 +369,7 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
370 * reconsider this when xhci_plat_suspend enlarges its scope, e.g., 369 * reconsider this when xhci_plat_suspend enlarges its scope, e.g.,
371 * also applies to runtime suspend. 370 * also applies to runtime suspend.
372 */ 371 */
373 ret = xhci_suspend(xhci, device_may_wakeup(dev)); 372 return xhci_suspend(xhci, device_may_wakeup(dev));
374
375 if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
376 clk_disable_unprepare(xhci->clk);
377
378 return ret;
379} 373}
380 374
381static int __maybe_unused xhci_plat_resume(struct device *dev) 375static int __maybe_unused xhci_plat_resume(struct device *dev)
@@ -384,9 +378,6 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
384 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 378 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
385 int ret; 379 int ret;
386 380
387 if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
388 clk_prepare_enable(xhci->clk);
389
390 ret = xhci_priv_resume_quirk(hcd); 381 ret = xhci_priv_resume_quirk(hcd);
391 if (ret) 382 if (ret)
392 return ret; 383 return ret;
diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
index f0b559660007..f33ffc2bc4ed 100644
--- a/drivers/usb/host/xhci-rcar.c
+++ b/drivers/usb/host/xhci-rcar.c
@@ -83,6 +83,10 @@ static const struct soc_device_attribute rcar_quirks_match[] = {
83 .soc_id = "r8a7796", 83 .soc_id = "r8a7796",
84 .data = (void *)RCAR_XHCI_FIRMWARE_V3, 84 .data = (void *)RCAR_XHCI_FIRMWARE_V3,
85 }, 85 },
86 {
87 .soc_id = "r8a77965",
88 .data = (void *)RCAR_XHCI_FIRMWARE_V3,
89 },
86 { /* sentinel */ }, 90 { /* sentinel */ },
87}; 91};
88 92
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 25d4b748a56f..5d37700ae4b0 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -877,6 +877,9 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
877 clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); 877 clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
878 del_timer_sync(&xhci->shared_hcd->rh_timer); 878 del_timer_sync(&xhci->shared_hcd->rh_timer);
879 879
880 if (xhci->quirks & XHCI_SUSPEND_DELAY)
881 usleep_range(1000, 1500);
882
880 spin_lock_irq(&xhci->lock); 883 spin_lock_irq(&xhci->lock);
881 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 884 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
882 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); 885 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index e4d7d3d06a75..866e141d4972 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -718,11 +718,12 @@ struct xhci_ep_ctx {
718/* bits 10:14 are Max Primary Streams */ 718/* bits 10:14 are Max Primary Streams */
719/* bit 15 is Linear Stream Array */ 719/* bit 15 is Linear Stream Array */
720/* Interval - period between requests to an endpoint - 125u increments. */ 720/* Interval - period between requests to an endpoint - 125u increments. */
721#define EP_INTERVAL(p) (((p) & 0xff) << 16) 721#define EP_INTERVAL(p) (((p) & 0xff) << 16)
722#define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff)) 722#define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff))
723#define CTX_TO_EP_INTERVAL(p) (((p) >> 16) & 0xff) 723#define CTX_TO_EP_INTERVAL(p) (((p) >> 16) & 0xff)
724#define EP_MAXPSTREAMS_MASK (0x1f << 10) 724#define EP_MAXPSTREAMS_MASK (0x1f << 10)
725#define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK) 725#define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK)
726#define CTX_TO_EP_MAXPSTREAMS(p) (((p) & EP_MAXPSTREAMS_MASK) >> 10)
726/* Endpoint is set up with a Linear Stream Array (vs. Secondary Stream Array) */ 727/* Endpoint is set up with a Linear Stream Array (vs. Secondary Stream Array) */
727#define EP_HAS_LSA (1 << 15) 728#define EP_HAS_LSA (1 << 15)
728/* hosts with LEC=1 use bits 31:24 as ESIT high bits. */ 729/* hosts with LEC=1 use bits 31:24 as ESIT high bits. */
@@ -1825,6 +1826,7 @@ struct xhci_hcd {
1825#define XHCI_U2_DISABLE_WAKE (1 << 27) 1826#define XHCI_U2_DISABLE_WAKE (1 << 27)
1826#define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28) 1827#define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28)
1827#define XHCI_HW_LPM_DISABLE (1 << 29) 1828#define XHCI_HW_LPM_DISABLE (1 << 29)
1829#define XHCI_SUSPEND_DELAY (1 << 30)
1828 1830
1829 unsigned int num_active_eps; 1831 unsigned int num_active_eps;
1830 unsigned int limit_active_eps; 1832 unsigned int limit_active_eps;
@@ -2549,21 +2551,22 @@ static inline const char *xhci_decode_ep_context(u32 info, u32 info2, u64 deq,
2549 u8 burst; 2551 u8 burst;
2550 u8 cerr; 2552 u8 cerr;
2551 u8 mult; 2553 u8 mult;
2552 u8 lsa; 2554
2553 u8 hid; 2555 bool lsa;
2556 bool hid;
2554 2557
2555 esit = CTX_TO_MAX_ESIT_PAYLOAD_HI(info) << 16 | 2558 esit = CTX_TO_MAX_ESIT_PAYLOAD_HI(info) << 16 |
2556 CTX_TO_MAX_ESIT_PAYLOAD(tx_info); 2559 CTX_TO_MAX_ESIT_PAYLOAD(tx_info);
2557 2560
2558 ep_state = info & EP_STATE_MASK; 2561 ep_state = info & EP_STATE_MASK;
2559 max_pstr = info & EP_MAXPSTREAMS_MASK; 2562 max_pstr = CTX_TO_EP_MAXPSTREAMS(info);
2560 interval = CTX_TO_EP_INTERVAL(info); 2563 interval = CTX_TO_EP_INTERVAL(info);
2561 mult = CTX_TO_EP_MULT(info) + 1; 2564 mult = CTX_TO_EP_MULT(info) + 1;
2562 lsa = info & EP_HAS_LSA; 2565 lsa = !!(info & EP_HAS_LSA);
2563 2566
2564 cerr = (info2 & (3 << 1)) >> 1; 2567 cerr = (info2 & (3 << 1)) >> 1;
2565 ep_type = CTX_TO_EP_TYPE(info2); 2568 ep_type = CTX_TO_EP_TYPE(info2);
2566 hid = info2 & (1 << 7); 2569 hid = !!(info2 & (1 << 7));
2567 burst = CTX_TO_MAX_BURST(info2); 2570 burst = CTX_TO_MAX_BURST(info2);
2568 maxp = MAX_PACKET_DECODED(info2); 2571 maxp = MAX_PACKET_DECODED(info2);
2569 2572
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index f5e1bb5e5217..984f7e12a6a5 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -85,6 +85,8 @@ struct mon_reader_text {
85 85
86 wait_queue_head_t wait; 86 wait_queue_head_t wait;
87 int printf_size; 87 int printf_size;
88 size_t printf_offset;
89 size_t printf_togo;
88 char *printf_buf; 90 char *printf_buf;
89 struct mutex printf_lock; 91 struct mutex printf_lock;
90 92
@@ -376,75 +378,103 @@ err_alloc:
376 return rc; 378 return rc;
377} 379}
378 380
379/* 381static ssize_t mon_text_copy_to_user(struct mon_reader_text *rp,
380 * For simplicity, we read one record in one system call and throw out 382 char __user * const buf, const size_t nbytes)
381 * what does not fit. This means that the following does not work: 383{
382 * dd if=/dbg/usbmon/0t bs=10 384 const size_t togo = min(nbytes, rp->printf_togo);
383 * Also, we do not allow seeks and do not bother advancing the offset. 385
384 */ 386 if (copy_to_user(buf, &rp->printf_buf[rp->printf_offset], togo))
387 return -EFAULT;
388 rp->printf_togo -= togo;
389 rp->printf_offset += togo;
390 return togo;
391}
392
393/* ppos is not advanced since the llseek operation is not permitted. */
385static ssize_t mon_text_read_t(struct file *file, char __user *buf, 394static ssize_t mon_text_read_t(struct file *file, char __user *buf,
386 size_t nbytes, loff_t *ppos) 395 size_t nbytes, loff_t *ppos)
387{ 396{
388 struct mon_reader_text *rp = file->private_data; 397 struct mon_reader_text *rp = file->private_data;
389 struct mon_event_text *ep; 398 struct mon_event_text *ep;
390 struct mon_text_ptr ptr; 399 struct mon_text_ptr ptr;
400 ssize_t ret;
391 401
392 ep = mon_text_read_wait(rp, file);
393 if (IS_ERR(ep))
394 return PTR_ERR(ep);
395 mutex_lock(&rp->printf_lock); 402 mutex_lock(&rp->printf_lock);
396 ptr.cnt = 0; 403
397 ptr.pbuf = rp->printf_buf; 404 if (rp->printf_togo == 0) {
398 ptr.limit = rp->printf_size; 405
399 406 ep = mon_text_read_wait(rp, file);
400 mon_text_read_head_t(rp, &ptr, ep); 407 if (IS_ERR(ep)) {
401 mon_text_read_statset(rp, &ptr, ep); 408 mutex_unlock(&rp->printf_lock);
402 ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, 409 return PTR_ERR(ep);
403 " %d", ep->length); 410 }
404 mon_text_read_data(rp, &ptr, ep); 411 ptr.cnt = 0;
405 412 ptr.pbuf = rp->printf_buf;
406 if (copy_to_user(buf, rp->printf_buf, ptr.cnt)) 413 ptr.limit = rp->printf_size;
407 ptr.cnt = -EFAULT; 414
415 mon_text_read_head_t(rp, &ptr, ep);
416 mon_text_read_statset(rp, &ptr, ep);
417 ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt,
418 " %d", ep->length);
419 mon_text_read_data(rp, &ptr, ep);
420
421 rp->printf_togo = ptr.cnt;
422 rp->printf_offset = 0;
423
424 kmem_cache_free(rp->e_slab, ep);
425 }
426
427 ret = mon_text_copy_to_user(rp, buf, nbytes);
408 mutex_unlock(&rp->printf_lock); 428 mutex_unlock(&rp->printf_lock);
409 kmem_cache_free(rp->e_slab, ep); 429 return ret;
410 return ptr.cnt;
411} 430}
412 431
432/* ppos is not advanced since the llseek operation is not permitted. */
413static ssize_t mon_text_read_u(struct file *file, char __user *buf, 433static ssize_t mon_text_read_u(struct file *file, char __user *buf,
414 size_t nbytes, loff_t *ppos) 434 size_t nbytes, loff_t *ppos)
415{ 435{
416 struct mon_reader_text *rp = file->private_data; 436 struct mon_reader_text *rp = file->private_data;
417 struct mon_event_text *ep; 437 struct mon_event_text *ep;
418 struct mon_text_ptr ptr; 438 struct mon_text_ptr ptr;
439 ssize_t ret;
419 440
420 ep = mon_text_read_wait(rp, file);
421 if (IS_ERR(ep))
422 return PTR_ERR(ep);
423 mutex_lock(&rp->printf_lock); 441 mutex_lock(&rp->printf_lock);
424 ptr.cnt = 0;
425 ptr.pbuf = rp->printf_buf;
426 ptr.limit = rp->printf_size;
427 442
428 mon_text_read_head_u(rp, &ptr, ep); 443 if (rp->printf_togo == 0) {
429 if (ep->type == 'E') { 444
430 mon_text_read_statset(rp, &ptr, ep); 445 ep = mon_text_read_wait(rp, file);
431 } else if (ep->xfertype == USB_ENDPOINT_XFER_ISOC) { 446 if (IS_ERR(ep)) {
432 mon_text_read_isostat(rp, &ptr, ep); 447 mutex_unlock(&rp->printf_lock);
433 mon_text_read_isodesc(rp, &ptr, ep); 448 return PTR_ERR(ep);
434 } else if (ep->xfertype == USB_ENDPOINT_XFER_INT) { 449 }
435 mon_text_read_intstat(rp, &ptr, ep); 450 ptr.cnt = 0;
436 } else { 451 ptr.pbuf = rp->printf_buf;
437 mon_text_read_statset(rp, &ptr, ep); 452 ptr.limit = rp->printf_size;
453
454 mon_text_read_head_u(rp, &ptr, ep);
455 if (ep->type == 'E') {
456 mon_text_read_statset(rp, &ptr, ep);
457 } else if (ep->xfertype == USB_ENDPOINT_XFER_ISOC) {
458 mon_text_read_isostat(rp, &ptr, ep);
459 mon_text_read_isodesc(rp, &ptr, ep);
460 } else if (ep->xfertype == USB_ENDPOINT_XFER_INT) {
461 mon_text_read_intstat(rp, &ptr, ep);
462 } else {
463 mon_text_read_statset(rp, &ptr, ep);
464 }
465 ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt,
466 " %d", ep->length);
467 mon_text_read_data(rp, &ptr, ep);
468
469 rp->printf_togo = ptr.cnt;
470 rp->printf_offset = 0;
471
472 kmem_cache_free(rp->e_slab, ep);
438 } 473 }
439 ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt,
440 " %d", ep->length);
441 mon_text_read_data(rp, &ptr, ep);
442 474
443 if (copy_to_user(buf, rp->printf_buf, ptr.cnt)) 475 ret = mon_text_copy_to_user(rp, buf, nbytes);
444 ptr.cnt = -EFAULT;
445 mutex_unlock(&rp->printf_lock); 476 mutex_unlock(&rp->printf_lock);
446 kmem_cache_free(rp->e_slab, ep); 477 return ret;
447 return ptr.cnt;
448} 478}
449 479
450static struct mon_event_text *mon_text_read_wait(struct mon_reader_text *rp, 480static struct mon_event_text *mon_text_read_wait(struct mon_reader_text *rp,
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index eef4ad578b31..4d723077be2b 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1756,6 +1756,7 @@ vbus_show(struct device *dev, struct device_attribute *attr, char *buf)
1756 int vbus; 1756 int vbus;
1757 u8 devctl; 1757 u8 devctl;
1758 1758
1759 pm_runtime_get_sync(dev);
1759 spin_lock_irqsave(&musb->lock, flags); 1760 spin_lock_irqsave(&musb->lock, flags);
1760 val = musb->a_wait_bcon; 1761 val = musb->a_wait_bcon;
1761 vbus = musb_platform_get_vbus_status(musb); 1762 vbus = musb_platform_get_vbus_status(musb);
@@ -1769,6 +1770,7 @@ vbus_show(struct device *dev, struct device_attribute *attr, char *buf)
1769 vbus = 0; 1770 vbus = 0;
1770 } 1771 }
1771 spin_unlock_irqrestore(&musb->lock, flags); 1772 spin_unlock_irqrestore(&musb->lock, flags);
1773 pm_runtime_put_sync(dev);
1772 1774
1773 return sprintf(buf, "Vbus %s, timeout %lu msec\n", 1775 return sprintf(buf, "Vbus %s, timeout %lu msec\n",
1774 vbus ? "on" : "off", val); 1776 vbus ? "on" : "off", val);
@@ -2471,11 +2473,11 @@ static int musb_remove(struct platform_device *pdev)
2471 musb_disable_interrupts(musb); 2473 musb_disable_interrupts(musb);
2472 musb_writeb(musb->mregs, MUSB_DEVCTL, 0); 2474 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
2473 spin_unlock_irqrestore(&musb->lock, flags); 2475 spin_unlock_irqrestore(&musb->lock, flags);
2476 musb_platform_exit(musb);
2474 2477
2475 pm_runtime_dont_use_autosuspend(musb->controller); 2478 pm_runtime_dont_use_autosuspend(musb->controller);
2476 pm_runtime_put_sync(musb->controller); 2479 pm_runtime_put_sync(musb->controller);
2477 pm_runtime_disable(musb->controller); 2480 pm_runtime_disable(musb->controller);
2478 musb_platform_exit(musb);
2479 musb_phy_callback = NULL; 2481 musb_phy_callback = NULL;
2480 if (musb->dma_controller) 2482 if (musb->dma_controller)
2481 musb_dma_controller_destroy(musb->dma_controller); 2483 musb_dma_controller_destroy(musb->dma_controller);
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 3b1b9695177a..6034c39b67d1 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -1076,7 +1076,7 @@ static int uas_post_reset(struct usb_interface *intf)
1076 return 0; 1076 return 0;
1077 1077
1078 err = uas_configure_endpoints(devinfo); 1078 err = uas_configure_endpoints(devinfo);
1079 if (err && err != ENODEV) 1079 if (err && err != -ENODEV)
1080 shost_printk(KERN_ERR, shost, 1080 shost_printk(KERN_ERR, shost,
1081 "%s: alloc streams error %d after reset", 1081 "%s: alloc streams error %d after reset",
1082 __func__, err); 1082 __func__, err);
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 264af199aec8..747d3a9596d9 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -2118,6 +2118,13 @@ UNUSUAL_DEV( 0x152d, 0x2566, 0x0114, 0x0114,
2118 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2118 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2119 US_FL_BROKEN_FUA ), 2119 US_FL_BROKEN_FUA ),
2120 2120
2121/* Reported by Teijo Kinnunen <teijo.kinnunen@code-q.fi> */
2122UNUSUAL_DEV( 0x152d, 0x2567, 0x0117, 0x0117,
2123 "JMicron",
2124 "USB to ATA/ATAPI Bridge",
2125 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2126 US_FL_BROKEN_FUA ),
2127
2121/* Reported-by George Cherian <george.cherian@cavium.com> */ 2128/* Reported-by George Cherian <george.cherian@cavium.com> */
2122UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999, 2129UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999,
2123 "JMicron", 2130 "JMicron",
diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
index 9ce4756adad6..dcd8ef085b30 100644
--- a/drivers/usb/typec/fusb302/fusb302.c
+++ b/drivers/usb/typec/fusb302/fusb302.c
@@ -1857,7 +1857,8 @@ static int fusb302_probe(struct i2c_client *client,
1857 chip->tcpm_port = tcpm_register_port(&client->dev, &chip->tcpc_dev); 1857 chip->tcpm_port = tcpm_register_port(&client->dev, &chip->tcpc_dev);
1858 if (IS_ERR(chip->tcpm_port)) { 1858 if (IS_ERR(chip->tcpm_port)) {
1859 ret = PTR_ERR(chip->tcpm_port); 1859 ret = PTR_ERR(chip->tcpm_port);
1860 dev_err(dev, "cannot register tcpm port, ret=%d", ret); 1860 if (ret != -EPROBE_DEFER)
1861 dev_err(dev, "cannot register tcpm port, ret=%d", ret);
1861 goto destroy_workqueue; 1862 goto destroy_workqueue;
1862 } 1863 }
1863 1864
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index f4d563ee7690..8b637a4b474b 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -252,9 +252,6 @@ struct tcpm_port {
252 unsigned int nr_src_pdo; 252 unsigned int nr_src_pdo;
253 u32 snk_pdo[PDO_MAX_OBJECTS]; 253 u32 snk_pdo[PDO_MAX_OBJECTS];
254 unsigned int nr_snk_pdo; 254 unsigned int nr_snk_pdo;
255 unsigned int nr_fixed; /* number of fixed sink PDOs */
256 unsigned int nr_var; /* number of variable sink PDOs */
257 unsigned int nr_batt; /* number of battery sink PDOs */
258 u32 snk_vdo[VDO_MAX_OBJECTS]; 255 u32 snk_vdo[VDO_MAX_OBJECTS];
259 unsigned int nr_snk_vdo; 256 unsigned int nr_snk_vdo;
260 257
@@ -1770,90 +1767,39 @@ static int tcpm_pd_check_request(struct tcpm_port *port)
1770 return 0; 1767 return 0;
1771} 1768}
1772 1769
1773#define min_power(x, y) min(pdo_max_power(x), pdo_max_power(y)) 1770static int tcpm_pd_select_pdo(struct tcpm_port *port)
1774#define min_current(x, y) min(pdo_max_current(x), pdo_max_current(y))
1775
1776static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
1777 int *src_pdo)
1778{ 1771{
1779 unsigned int i, j, max_mw = 0, max_mv = 0, mw = 0, mv = 0, ma = 0; 1772 unsigned int i, max_mw = 0, max_mv = 0;
1780 int ret = -EINVAL; 1773 int ret = -EINVAL;
1781 1774
1782 /* 1775 /*
1783 * Select the source PDO providing the most power which has a 1776 * Select the source PDO providing the most power while staying within
1784 * matchig sink cap. 1777 * the board's voltage limits. Prefer PDO providing exp
1785 */ 1778 */
1786 for (i = 0; i < port->nr_source_caps; i++) { 1779 for (i = 0; i < port->nr_source_caps; i++) {
1787 u32 pdo = port->source_caps[i]; 1780 u32 pdo = port->source_caps[i];
1788 enum pd_pdo_type type = pdo_type(pdo); 1781 enum pd_pdo_type type = pdo_type(pdo);
1782 unsigned int mv, ma, mw;
1789 1783
1790 if (type == PDO_TYPE_FIXED) { 1784 if (type == PDO_TYPE_FIXED)
1791 for (j = 0; j < port->nr_fixed; j++) { 1785 mv = pdo_fixed_voltage(pdo);
1792 if (pdo_fixed_voltage(pdo) == 1786 else
1793 pdo_fixed_voltage(port->snk_pdo[j])) { 1787 mv = pdo_min_voltage(pdo);
1794 ma = min_current(pdo, port->snk_pdo[j]); 1788
1795 mv = pdo_fixed_voltage(pdo); 1789 if (type == PDO_TYPE_BATT) {
1796 mw = ma * mv / 1000; 1790 mw = pdo_max_power(pdo);
1797 if (mw > max_mw || 1791 } else {
1798 (mw == max_mw && mv > max_mv)) { 1792 ma = min(pdo_max_current(pdo),
1799 ret = 0; 1793 port->max_snk_ma);
1800 *src_pdo = i; 1794 mw = ma * mv / 1000;
1801 *sink_pdo = j; 1795 }
1802 max_mw = mw; 1796
1803 max_mv = mv; 1797 /* Perfer higher voltages if available */
1804 } 1798 if ((mw > max_mw || (mw == max_mw && mv > max_mv)) &&
1805 /* There could only be one fixed pdo 1799 mv <= port->max_snk_mv) {
1806 * at a specific voltage level. 1800 ret = i;
1807 * So breaking here. 1801 max_mw = mw;
1808 */ 1802 max_mv = mv;
1809 break;
1810 }
1811 }
1812 } else if (type == PDO_TYPE_BATT) {
1813 for (j = port->nr_fixed;
1814 j < port->nr_fixed +
1815 port->nr_batt;
1816 j++) {
1817 if (pdo_min_voltage(pdo) >=
1818 pdo_min_voltage(port->snk_pdo[j]) &&
1819 pdo_max_voltage(pdo) <=
1820 pdo_max_voltage(port->snk_pdo[j])) {
1821 mw = min_power(pdo, port->snk_pdo[j]);
1822 mv = pdo_min_voltage(pdo);
1823 if (mw > max_mw ||
1824 (mw == max_mw && mv > max_mv)) {
1825 ret = 0;
1826 *src_pdo = i;
1827 *sink_pdo = j;
1828 max_mw = mw;
1829 max_mv = mv;
1830 }
1831 }
1832 }
1833 } else if (type == PDO_TYPE_VAR) {
1834 for (j = port->nr_fixed +
1835 port->nr_batt;
1836 j < port->nr_fixed +
1837 port->nr_batt +
1838 port->nr_var;
1839 j++) {
1840 if (pdo_min_voltage(pdo) >=
1841 pdo_min_voltage(port->snk_pdo[j]) &&
1842 pdo_max_voltage(pdo) <=
1843 pdo_max_voltage(port->snk_pdo[j])) {
1844 ma = min_current(pdo, port->snk_pdo[j]);
1845 mv = pdo_min_voltage(pdo);
1846 mw = ma * mv / 1000;
1847 if (mw > max_mw ||
1848 (mw == max_mw && mv > max_mv)) {
1849 ret = 0;
1850 *src_pdo = i;
1851 *sink_pdo = j;
1852 max_mw = mw;
1853 max_mv = mv;
1854 }
1855 }
1856 }
1857 } 1803 }
1858 } 1804 }
1859 1805
@@ -1865,14 +1811,13 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo)
1865 unsigned int mv, ma, mw, flags; 1811 unsigned int mv, ma, mw, flags;
1866 unsigned int max_ma, max_mw; 1812 unsigned int max_ma, max_mw;
1867 enum pd_pdo_type type; 1813 enum pd_pdo_type type;
1868 int src_pdo_index, snk_pdo_index; 1814 int index;
1869 u32 pdo, matching_snk_pdo; 1815 u32 pdo;
1870 1816
1871 if (tcpm_pd_select_pdo(port, &snk_pdo_index, &src_pdo_index) < 0) 1817 index = tcpm_pd_select_pdo(port);
1818 if (index < 0)
1872 return -EINVAL; 1819 return -EINVAL;
1873 1820 pdo = port->source_caps[index];
1874 pdo = port->source_caps[src_pdo_index];
1875 matching_snk_pdo = port->snk_pdo[snk_pdo_index];
1876 type = pdo_type(pdo); 1821 type = pdo_type(pdo);
1877 1822
1878 if (type == PDO_TYPE_FIXED) 1823 if (type == PDO_TYPE_FIXED)
@@ -1880,28 +1825,26 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo)
1880 else 1825 else
1881 mv = pdo_min_voltage(pdo); 1826 mv = pdo_min_voltage(pdo);
1882 1827
1883 /* Select maximum available current within the sink pdo's limit */ 1828 /* Select maximum available current within the board's power limit */
1884 if (type == PDO_TYPE_BATT) { 1829 if (type == PDO_TYPE_BATT) {
1885 mw = min_power(pdo, matching_snk_pdo); 1830 mw = pdo_max_power(pdo);
1886 ma = 1000 * mw / mv; 1831 ma = 1000 * min(mw, port->max_snk_mw) / mv;
1887 } else { 1832 } else {
1888 ma = min_current(pdo, matching_snk_pdo); 1833 ma = min(pdo_max_current(pdo),
1889 mw = ma * mv / 1000; 1834 1000 * port->max_snk_mw / mv);
1890 } 1835 }
1836 ma = min(ma, port->max_snk_ma);
1891 1837
1892 flags = RDO_USB_COMM | RDO_NO_SUSPEND; 1838 flags = RDO_USB_COMM | RDO_NO_SUSPEND;
1893 1839
1894 /* Set mismatch bit if offered power is less than operating power */ 1840 /* Set mismatch bit if offered power is less than operating power */
1841 mw = ma * mv / 1000;
1895 max_ma = ma; 1842 max_ma = ma;
1896 max_mw = mw; 1843 max_mw = mw;
1897 if (mw < port->operating_snk_mw) { 1844 if (mw < port->operating_snk_mw) {
1898 flags |= RDO_CAP_MISMATCH; 1845 flags |= RDO_CAP_MISMATCH;
1899 if (type == PDO_TYPE_BATT && 1846 max_mw = port->operating_snk_mw;
1900 (pdo_max_power(matching_snk_pdo) > pdo_max_power(pdo))) 1847 max_ma = max_mw * 1000 / mv;
1901 max_mw = pdo_max_power(matching_snk_pdo);
1902 else if (pdo_max_current(matching_snk_pdo) >
1903 pdo_max_current(pdo))
1904 max_ma = pdo_max_current(matching_snk_pdo);
1905 } 1848 }
1906 1849
1907 tcpm_log(port, "cc=%d cc1=%d cc2=%d vbus=%d vconn=%s polarity=%d", 1850 tcpm_log(port, "cc=%d cc1=%d cc2=%d vbus=%d vconn=%s polarity=%d",
@@ -1910,16 +1853,16 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo)
1910 port->polarity); 1853 port->polarity);
1911 1854
1912 if (type == PDO_TYPE_BATT) { 1855 if (type == PDO_TYPE_BATT) {
1913 *rdo = RDO_BATT(src_pdo_index + 1, mw, max_mw, flags); 1856 *rdo = RDO_BATT(index + 1, mw, max_mw, flags);
1914 1857
1915 tcpm_log(port, "Requesting PDO %d: %u mV, %u mW%s", 1858 tcpm_log(port, "Requesting PDO %d: %u mV, %u mW%s",
1916 src_pdo_index, mv, mw, 1859 index, mv, mw,
1917 flags & RDO_CAP_MISMATCH ? " [mismatch]" : ""); 1860 flags & RDO_CAP_MISMATCH ? " [mismatch]" : "");
1918 } else { 1861 } else {
1919 *rdo = RDO_FIXED(src_pdo_index + 1, ma, max_ma, flags); 1862 *rdo = RDO_FIXED(index + 1, ma, max_ma, flags);
1920 1863
1921 tcpm_log(port, "Requesting PDO %d: %u mV, %u mA%s", 1864 tcpm_log(port, "Requesting PDO %d: %u mV, %u mA%s",
1922 src_pdo_index, mv, ma, 1865 index, mv, ma,
1923 flags & RDO_CAP_MISMATCH ? " [mismatch]" : ""); 1866 flags & RDO_CAP_MISMATCH ? " [mismatch]" : "");
1924 } 1867 }
1925 1868
@@ -3650,19 +3593,6 @@ int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
3650} 3593}
3651EXPORT_SYMBOL_GPL(tcpm_update_sink_capabilities); 3594EXPORT_SYMBOL_GPL(tcpm_update_sink_capabilities);
3652 3595
3653static int nr_type_pdos(const u32 *pdo, unsigned int nr_pdo,
3654 enum pd_pdo_type type)
3655{
3656 int count = 0;
3657 int i;
3658
3659 for (i = 0; i < nr_pdo; i++) {
3660 if (pdo_type(pdo[i]) == type)
3661 count++;
3662 }
3663 return count;
3664}
3665
3666struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) 3596struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
3667{ 3597{
3668 struct tcpm_port *port; 3598 struct tcpm_port *port;
@@ -3708,15 +3638,6 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
3708 tcpc->config->nr_src_pdo); 3638 tcpc->config->nr_src_pdo);
3709 port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo, 3639 port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo,
3710 tcpc->config->nr_snk_pdo); 3640 tcpc->config->nr_snk_pdo);
3711 port->nr_fixed = nr_type_pdos(port->snk_pdo,
3712 port->nr_snk_pdo,
3713 PDO_TYPE_FIXED);
3714 port->nr_var = nr_type_pdos(port->snk_pdo,
3715 port->nr_snk_pdo,
3716 PDO_TYPE_VAR);
3717 port->nr_batt = nr_type_pdos(port->snk_pdo,
3718 port->nr_snk_pdo,
3719 PDO_TYPE_BATT);
3720 port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo, 3641 port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo,
3721 tcpc->config->nr_snk_vdo); 3642 tcpc->config->nr_snk_vdo);
3722 3643
diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
index d86f72bbbb91..6dcd3ff655c3 100644
--- a/drivers/usb/usbip/vudc_sysfs.c
+++ b/drivers/usb/usbip/vudc_sysfs.c
@@ -105,10 +105,14 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
105 if (rv != 0) 105 if (rv != 0)
106 return -EINVAL; 106 return -EINVAL;
107 107
108 if (!udc) {
109 dev_err(dev, "no device");
110 return -ENODEV;
111 }
108 spin_lock_irqsave(&udc->lock, flags); 112 spin_lock_irqsave(&udc->lock, flags);
109 /* Don't export what we don't have */ 113 /* Don't export what we don't have */
110 if (!udc || !udc->driver || !udc->pullup) { 114 if (!udc->driver || !udc->pullup) {
111 dev_err(dev, "no device or gadget not bound"); 115 dev_err(dev, "gadget not bound");
112 ret = -ENODEV; 116 ret = -ENODEV;
113 goto unlock; 117 goto unlock;
114 } 118 }
diff --git a/fs/aio.c b/fs/aio.c
index a062d75109cb..6bcd3fb5265a 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -68,9 +68,9 @@ struct aio_ring {
68#define AIO_RING_PAGES 8 68#define AIO_RING_PAGES 8
69 69
70struct kioctx_table { 70struct kioctx_table {
71 struct rcu_head rcu; 71 struct rcu_head rcu;
72 unsigned nr; 72 unsigned nr;
73 struct kioctx *table[]; 73 struct kioctx __rcu *table[];
74}; 74};
75 75
76struct kioctx_cpu { 76struct kioctx_cpu {
@@ -115,7 +115,8 @@ struct kioctx {
115 struct page **ring_pages; 115 struct page **ring_pages;
116 long nr_pages; 116 long nr_pages;
117 117
118 struct work_struct free_work; 118 struct rcu_head free_rcu;
119 struct work_struct free_work; /* see free_ioctx() */
119 120
120 /* 121 /*
121 * signals when all in-flight requests are done 122 * signals when all in-flight requests are done
@@ -329,7 +330,7 @@ static int aio_ring_mremap(struct vm_area_struct *vma)
329 for (i = 0; i < table->nr; i++) { 330 for (i = 0; i < table->nr; i++) {
330 struct kioctx *ctx; 331 struct kioctx *ctx;
331 332
332 ctx = table->table[i]; 333 ctx = rcu_dereference(table->table[i]);
333 if (ctx && ctx->aio_ring_file == file) { 334 if (ctx && ctx->aio_ring_file == file) {
334 if (!atomic_read(&ctx->dead)) { 335 if (!atomic_read(&ctx->dead)) {
335 ctx->user_id = ctx->mmap_base = vma->vm_start; 336 ctx->user_id = ctx->mmap_base = vma->vm_start;
@@ -588,6 +589,12 @@ static int kiocb_cancel(struct aio_kiocb *kiocb)
588 return cancel(&kiocb->common); 589 return cancel(&kiocb->common);
589} 590}
590 591
592/*
593 * free_ioctx() should be RCU delayed to synchronize against the RCU
594 * protected lookup_ioctx() and also needs process context to call
595 * aio_free_ring(), so the double bouncing through kioctx->free_rcu and
596 * ->free_work.
597 */
591static void free_ioctx(struct work_struct *work) 598static void free_ioctx(struct work_struct *work)
592{ 599{
593 struct kioctx *ctx = container_of(work, struct kioctx, free_work); 600 struct kioctx *ctx = container_of(work, struct kioctx, free_work);
@@ -601,6 +608,14 @@ static void free_ioctx(struct work_struct *work)
601 kmem_cache_free(kioctx_cachep, ctx); 608 kmem_cache_free(kioctx_cachep, ctx);
602} 609}
603 610
611static void free_ioctx_rcufn(struct rcu_head *head)
612{
613 struct kioctx *ctx = container_of(head, struct kioctx, free_rcu);
614
615 INIT_WORK(&ctx->free_work, free_ioctx);
616 schedule_work(&ctx->free_work);
617}
618
604static void free_ioctx_reqs(struct percpu_ref *ref) 619static void free_ioctx_reqs(struct percpu_ref *ref)
605{ 620{
606 struct kioctx *ctx = container_of(ref, struct kioctx, reqs); 621 struct kioctx *ctx = container_of(ref, struct kioctx, reqs);
@@ -609,8 +624,8 @@ static void free_ioctx_reqs(struct percpu_ref *ref)
609 if (ctx->rq_wait && atomic_dec_and_test(&ctx->rq_wait->count)) 624 if (ctx->rq_wait && atomic_dec_and_test(&ctx->rq_wait->count))
610 complete(&ctx->rq_wait->comp); 625 complete(&ctx->rq_wait->comp);
611 626
612 INIT_WORK(&ctx->free_work, free_ioctx); 627 /* Synchronize against RCU protected table->table[] dereferences */
613 schedule_work(&ctx->free_work); 628 call_rcu(&ctx->free_rcu, free_ioctx_rcufn);
614} 629}
615 630
616/* 631/*
@@ -651,9 +666,9 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
651 while (1) { 666 while (1) {
652 if (table) 667 if (table)
653 for (i = 0; i < table->nr; i++) 668 for (i = 0; i < table->nr; i++)
654 if (!table->table[i]) { 669 if (!rcu_access_pointer(table->table[i])) {
655 ctx->id = i; 670 ctx->id = i;
656 table->table[i] = ctx; 671 rcu_assign_pointer(table->table[i], ctx);
657 spin_unlock(&mm->ioctx_lock); 672 spin_unlock(&mm->ioctx_lock);
658 673
659 /* While kioctx setup is in progress, 674 /* While kioctx setup is in progress,
@@ -834,11 +849,11 @@ static int kill_ioctx(struct mm_struct *mm, struct kioctx *ctx,
834 } 849 }
835 850
836 table = rcu_dereference_raw(mm->ioctx_table); 851 table = rcu_dereference_raw(mm->ioctx_table);
837 WARN_ON(ctx != table->table[ctx->id]); 852 WARN_ON(ctx != rcu_access_pointer(table->table[ctx->id]));
838 table->table[ctx->id] = NULL; 853 RCU_INIT_POINTER(table->table[ctx->id], NULL);
839 spin_unlock(&mm->ioctx_lock); 854 spin_unlock(&mm->ioctx_lock);
840 855
841 /* percpu_ref_kill() will do the necessary call_rcu() */ 856 /* free_ioctx_reqs() will do the necessary RCU synchronization */
842 wake_up_all(&ctx->wait); 857 wake_up_all(&ctx->wait);
843 858
844 /* 859 /*
@@ -880,7 +895,8 @@ void exit_aio(struct mm_struct *mm)
880 895
881 skipped = 0; 896 skipped = 0;
882 for (i = 0; i < table->nr; ++i) { 897 for (i = 0; i < table->nr; ++i) {
883 struct kioctx *ctx = table->table[i]; 898 struct kioctx *ctx =
899 rcu_dereference_protected(table->table[i], true);
884 900
885 if (!ctx) { 901 if (!ctx) {
886 skipped++; 902 skipped++;
@@ -1069,7 +1085,7 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id)
1069 if (!table || id >= table->nr) 1085 if (!table || id >= table->nr)
1070 goto out; 1086 goto out;
1071 1087
1072 ctx = table->table[id]; 1088 ctx = rcu_dereference(table->table[id]);
1073 if (ctx && ctx->user_id == ctx_id) { 1089 if (ctx && ctx->user_id == ctx_id) {
1074 percpu_ref_get(&ctx->users); 1090 percpu_ref_get(&ctx->users);
1075 ret = ctx; 1091 ret = ctx;
diff --git a/fs/dcache.c b/fs/dcache.c
index 7c38f39958bc..8945e6cabd93 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -647,11 +647,16 @@ again:
647 spin_unlock(&parent->d_lock); 647 spin_unlock(&parent->d_lock);
648 goto again; 648 goto again;
649 } 649 }
650 rcu_read_unlock(); 650 if (parent != dentry) {
651 if (parent != dentry)
652 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); 651 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
653 else 652 if (unlikely(dentry->d_lockref.count < 0)) {
653 spin_unlock(&parent->d_lock);
654 parent = NULL;
655 }
656 } else {
654 parent = NULL; 657 parent = NULL;
658 }
659 rcu_read_unlock();
655 return parent; 660 return parent;
656} 661}
657 662
@@ -2474,7 +2479,7 @@ struct dentry *d_alloc_parallel(struct dentry *parent,
2474 2479
2475retry: 2480retry:
2476 rcu_read_lock(); 2481 rcu_read_lock();
2477 seq = smp_load_acquire(&parent->d_inode->i_dir_seq) & ~1; 2482 seq = smp_load_acquire(&parent->d_inode->i_dir_seq);
2478 r_seq = read_seqbegin(&rename_lock); 2483 r_seq = read_seqbegin(&rename_lock);
2479 dentry = __d_lookup_rcu(parent, name, &d_seq); 2484 dentry = __d_lookup_rcu(parent, name, &d_seq);
2480 if (unlikely(dentry)) { 2485 if (unlikely(dentry)) {
@@ -2495,8 +2500,14 @@ retry:
2495 rcu_read_unlock(); 2500 rcu_read_unlock();
2496 goto retry; 2501 goto retry;
2497 } 2502 }
2503
2504 if (unlikely(seq & 1)) {
2505 rcu_read_unlock();
2506 goto retry;
2507 }
2508
2498 hlist_bl_lock(b); 2509 hlist_bl_lock(b);
2499 if (unlikely(parent->d_inode->i_dir_seq != seq)) { 2510 if (unlikely(READ_ONCE(parent->d_inode->i_dir_seq) != seq)) {
2500 hlist_bl_unlock(b); 2511 hlist_bl_unlock(b);
2501 rcu_read_unlock(); 2512 rcu_read_unlock();
2502 goto retry; 2513 goto retry;
diff --git a/fs/namei.c b/fs/namei.c
index 921ae32dbc80..cafa365eeb70 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -559,9 +559,10 @@ static int __nd_alloc_stack(struct nameidata *nd)
559static bool path_connected(const struct path *path) 559static bool path_connected(const struct path *path)
560{ 560{
561 struct vfsmount *mnt = path->mnt; 561 struct vfsmount *mnt = path->mnt;
562 struct super_block *sb = mnt->mnt_sb;
562 563
563 /* Only bind mounts can have disconnected paths */ 564 /* Bind mounts and multi-root filesystems can have disconnected paths */
564 if (mnt->mnt_root == mnt->mnt_sb->s_root) 565 if (!(sb->s_iflags & SB_I_MULTIROOT) && (mnt->mnt_root == sb->s_root))
565 return true; 566 return true;
566 567
567 return is_subdir(path->dentry, mnt->mnt_root); 568 return is_subdir(path->dentry, mnt->mnt_root);
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 8c10b0562e75..621c517b325c 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -86,10 +86,10 @@ struct nfs_direct_req {
86 struct nfs_direct_mirror mirrors[NFS_PAGEIO_DESCRIPTOR_MIRROR_MAX]; 86 struct nfs_direct_mirror mirrors[NFS_PAGEIO_DESCRIPTOR_MIRROR_MAX];
87 int mirror_count; 87 int mirror_count;
88 88
89 loff_t io_start; /* Start offset for I/O */
89 ssize_t count, /* bytes actually processed */ 90 ssize_t count, /* bytes actually processed */
90 max_count, /* max expected count */ 91 max_count, /* max expected count */
91 bytes_left, /* bytes left to be sent */ 92 bytes_left, /* bytes left to be sent */
92 io_start, /* start of IO */
93 error; /* any reported error */ 93 error; /* any reported error */
94 struct completion completion; /* wait for i/o completion */ 94 struct completion completion; /* wait for i/o completion */
95 95
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index c13e826614b5..ee723aa153a3 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -292,8 +292,11 @@ pnfs_detach_layout_hdr(struct pnfs_layout_hdr *lo)
292void 292void
293pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo) 293pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
294{ 294{
295 struct inode *inode = lo->plh_inode; 295 struct inode *inode;
296 296
297 if (!lo)
298 return;
299 inode = lo->plh_inode;
297 pnfs_layoutreturn_before_put_layout_hdr(lo); 300 pnfs_layoutreturn_before_put_layout_hdr(lo);
298 301
299 if (refcount_dec_and_lock(&lo->plh_refcount, &inode->i_lock)) { 302 if (refcount_dec_and_lock(&lo->plh_refcount, &inode->i_lock)) {
@@ -1241,10 +1244,12 @@ retry:
1241 spin_lock(&ino->i_lock); 1244 spin_lock(&ino->i_lock);
1242 lo = nfsi->layout; 1245 lo = nfsi->layout;
1243 if (!lo || !pnfs_layout_is_valid(lo) || 1246 if (!lo || !pnfs_layout_is_valid(lo) ||
1244 test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) 1247 test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) {
1248 lo = NULL;
1245 goto out_noroc; 1249 goto out_noroc;
1250 }
1251 pnfs_get_layout_hdr(lo);
1246 if (test_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags)) { 1252 if (test_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags)) {
1247 pnfs_get_layout_hdr(lo);
1248 spin_unlock(&ino->i_lock); 1253 spin_unlock(&ino->i_lock);
1249 wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN, 1254 wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN,
1250 TASK_UNINTERRUPTIBLE); 1255 TASK_UNINTERRUPTIBLE);
@@ -1312,10 +1317,12 @@ out_noroc:
1312 struct pnfs_layoutdriver_type *ld = NFS_SERVER(ino)->pnfs_curr_ld; 1317 struct pnfs_layoutdriver_type *ld = NFS_SERVER(ino)->pnfs_curr_ld;
1313 if (ld->prepare_layoutreturn) 1318 if (ld->prepare_layoutreturn)
1314 ld->prepare_layoutreturn(args); 1319 ld->prepare_layoutreturn(args);
1320 pnfs_put_layout_hdr(lo);
1315 return true; 1321 return true;
1316 } 1322 }
1317 if (layoutreturn) 1323 if (layoutreturn)
1318 pnfs_send_layoutreturn(lo, &stateid, iomode, true); 1324 pnfs_send_layoutreturn(lo, &stateid, iomode, true);
1325 pnfs_put_layout_hdr(lo);
1319 return false; 1326 return false;
1320} 1327}
1321 1328
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 29bacdc56f6a..5e470e233c83 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2631,6 +2631,8 @@ struct dentry *nfs_fs_mount_common(struct nfs_server *server,
2631 /* initial superblock/root creation */ 2631 /* initial superblock/root creation */
2632 mount_info->fill_super(s, mount_info); 2632 mount_info->fill_super(s, mount_info);
2633 nfs_get_cache_cookie(s, mount_info->parsed, mount_info->cloned); 2633 nfs_get_cache_cookie(s, mount_info->parsed, mount_info->cloned);
2634 if (!(server->flags & NFS_MOUNT_UNSHARED))
2635 s->s_iflags |= SB_I_MULTIROOT;
2634 } 2636 }
2635 2637
2636 mntroot = nfs_get_root(s, mount_info->mntfh, dev_name); 2638 mntroot = nfs_get_root(s, mount_info->mntfh, dev_name);
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 7428a669d7a7..e7d8ceae8f26 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1876,40 +1876,43 @@ int nfs_generic_commit_list(struct inode *inode, struct list_head *head,
1876 return status; 1876 return status;
1877} 1877}
1878 1878
1879int nfs_commit_inode(struct inode *inode, int how) 1879static int __nfs_commit_inode(struct inode *inode, int how,
1880 struct writeback_control *wbc)
1880{ 1881{
1881 LIST_HEAD(head); 1882 LIST_HEAD(head);
1882 struct nfs_commit_info cinfo; 1883 struct nfs_commit_info cinfo;
1883 int may_wait = how & FLUSH_SYNC; 1884 int may_wait = how & FLUSH_SYNC;
1884 int error = 0; 1885 int ret, nscan;
1885 int res;
1886 1886
1887 nfs_init_cinfo_from_inode(&cinfo, inode); 1887 nfs_init_cinfo_from_inode(&cinfo, inode);
1888 nfs_commit_begin(cinfo.mds); 1888 nfs_commit_begin(cinfo.mds);
1889 res = nfs_scan_commit(inode, &head, &cinfo); 1889 for (;;) {
1890 if (res) 1890 ret = nscan = nfs_scan_commit(inode, &head, &cinfo);
1891 error = nfs_generic_commit_list(inode, &head, how, &cinfo); 1891 if (ret <= 0)
1892 break;
1893 ret = nfs_generic_commit_list(inode, &head, how, &cinfo);
1894 if (ret < 0)
1895 break;
1896 ret = 0;
1897 if (wbc && wbc->sync_mode == WB_SYNC_NONE) {
1898 if (nscan < wbc->nr_to_write)
1899 wbc->nr_to_write -= nscan;
1900 else
1901 wbc->nr_to_write = 0;
1902 }
1903 if (nscan < INT_MAX)
1904 break;
1905 cond_resched();
1906 }
1892 nfs_commit_end(cinfo.mds); 1907 nfs_commit_end(cinfo.mds);
1893 if (res == 0) 1908 if (ret || !may_wait)
1894 return res; 1909 return ret;
1895 if (error < 0) 1910 return wait_on_commit(cinfo.mds);
1896 goto out_error; 1911}
1897 if (!may_wait) 1912
1898 goto out_mark_dirty; 1913int nfs_commit_inode(struct inode *inode, int how)
1899 error = wait_on_commit(cinfo.mds); 1914{
1900 if (error < 0) 1915 return __nfs_commit_inode(inode, how, NULL);
1901 return error;
1902 return res;
1903out_error:
1904 res = error;
1905 /* Note: If we exit without ensuring that the commit is complete,
1906 * we must mark the inode as dirty. Otherwise, future calls to
1907 * sync_inode() with the WB_SYNC_ALL flag set will fail to ensure
1908 * that the data is on the disk.
1909 */
1910out_mark_dirty:
1911 __mark_inode_dirty(inode, I_DIRTY_DATASYNC);
1912 return res;
1913} 1916}
1914EXPORT_SYMBOL_GPL(nfs_commit_inode); 1917EXPORT_SYMBOL_GPL(nfs_commit_inode);
1915 1918
@@ -1919,11 +1922,11 @@ int nfs_write_inode(struct inode *inode, struct writeback_control *wbc)
1919 int flags = FLUSH_SYNC; 1922 int flags = FLUSH_SYNC;
1920 int ret = 0; 1923 int ret = 0;
1921 1924
1922 /* no commits means nothing needs to be done */
1923 if (!atomic_long_read(&nfsi->commit_info.ncommit))
1924 return ret;
1925
1926 if (wbc->sync_mode == WB_SYNC_NONE) { 1925 if (wbc->sync_mode == WB_SYNC_NONE) {
1926 /* no commits means nothing needs to be done */
1927 if (!atomic_long_read(&nfsi->commit_info.ncommit))
1928 goto check_requests_outstanding;
1929
1927 /* Don't commit yet if this is a non-blocking flush and there 1930 /* Don't commit yet if this is a non-blocking flush and there
1928 * are a lot of outstanding writes for this mapping. 1931 * are a lot of outstanding writes for this mapping.
1929 */ 1932 */
@@ -1934,16 +1937,16 @@ int nfs_write_inode(struct inode *inode, struct writeback_control *wbc)
1934 flags = 0; 1937 flags = 0;
1935 } 1938 }
1936 1939
1937 ret = nfs_commit_inode(inode, flags); 1940 ret = __nfs_commit_inode(inode, flags, wbc);
1938 if (ret >= 0) { 1941 if (!ret) {
1939 if (wbc->sync_mode == WB_SYNC_NONE) { 1942 if (flags & FLUSH_SYNC)
1940 if (ret < wbc->nr_to_write) 1943 return 0;
1941 wbc->nr_to_write -= ret; 1944 } else if (atomic_long_read(&nfsi->commit_info.ncommit))
1942 else 1945 goto out_mark_dirty;
1943 wbc->nr_to_write = 0; 1946
1944 } 1947check_requests_outstanding:
1945 return 0; 1948 if (!atomic_read(&nfsi->commit_info.rpcs_out))
1946 } 1949 return ret;
1947out_mark_dirty: 1950out_mark_dirty:
1948 __mark_inode_dirty(inode, I_DIRTY_DATASYNC); 1951 __mark_inode_dirty(inode, I_DIRTY_DATASYNC);
1949 return ret; 1952 return ret;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 79c413985305..c6baf767619e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1317,6 +1317,7 @@ extern int send_sigurg(struct fown_struct *fown);
1317#define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */ 1317#define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */
1318#define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */ 1318#define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */
1319#define SB_I_NODEV 0x00000004 /* Ignore devices on this fs */ 1319#define SB_I_NODEV 0x00000004 /* Ignore devices on this fs */
1320#define SB_I_MULTIROOT 0x00000008 /* Multiple roots to the dentry tree */
1320 1321
1321/* sb->s_iflags to limit user namespace mounts */ 1322/* sb->s_iflags to limit user namespace mounts */
1322#define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */ 1323#define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 0a6c71e0ad01..47f8af22f216 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -364,6 +364,7 @@ struct tty_file_private {
364#define TTY_PTY_LOCK 16 /* pty private */ 364#define TTY_PTY_LOCK 16 /* pty private */
365#define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */ 365#define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */
366#define TTY_HUPPED 18 /* Post driver->hangup() */ 366#define TTY_HUPPED 18 /* Post driver->hangup() */
367#define TTY_HUPPING 19 /* Hangup in progress */
367#define TTY_LDISC_HALTED 22 /* Line discipline is halted */ 368#define TTY_LDISC_HALTED 22 /* Line discipline is halted */
368 369
369/* Values for tty->flow_change */ 370/* Values for tty->flow_change */
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
index f1fcec2fd5f8..b7a99ce56bc9 100644
--- a/include/linux/usb/quirks.h
+++ b/include/linux/usb/quirks.h
@@ -63,4 +63,7 @@
63 */ 63 */
64#define USB_QUIRK_DISCONNECT_SUSPEND BIT(12) 64#define USB_QUIRK_DISCONNECT_SUSPEND BIT(12)
65 65
66/* Device needs a pause after every control message. */
67#define USB_QUIRK_DELAY_CTRL_MSG BIT(13)
68
66#endif /* __LINUX_USB_QUIRKS_H */ 69#endif /* __LINUX_USB_QUIRKS_H */
diff --git a/lib/btree.c b/lib/btree.c
index f93a945274af..590facba2c50 100644
--- a/lib/btree.c
+++ b/lib/btree.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * As should be obvious for Linux kernel code, license is GPLv2 4 * As should be obvious for Linux kernel code, license is GPLv2
5 * 5 *
6 * Copyright (c) 2007-2008 Joern Engel <joern@logfs.org> 6 * Copyright (c) 2007-2008 Joern Engel <joern@purestorage.com>
7 * Bits and pieces stolen from Peter Zijlstra's code, which is 7 * Bits and pieces stolen from Peter Zijlstra's code, which is
8 * Copyright 2007, Red Hat Inc. Peter Zijlstra 8 * Copyright 2007, Red Hat Inc. Peter Zijlstra
9 * GPLv2 9 * GPLv2
@@ -76,6 +76,8 @@ struct btree_geo btree_geo128 = {
76}; 76};
77EXPORT_SYMBOL_GPL(btree_geo128); 77EXPORT_SYMBOL_GPL(btree_geo128);
78 78
79#define MAX_KEYLEN (2 * LONG_PER_U64)
80
79static struct kmem_cache *btree_cachep; 81static struct kmem_cache *btree_cachep;
80 82
81void *btree_alloc(gfp_t gfp_mask, void *pool_data) 83void *btree_alloc(gfp_t gfp_mask, void *pool_data)
@@ -313,7 +315,7 @@ void *btree_get_prev(struct btree_head *head, struct btree_geo *geo,
313{ 315{
314 int i, height; 316 int i, height;
315 unsigned long *node, *oldnode; 317 unsigned long *node, *oldnode;
316 unsigned long *retry_key = NULL, key[geo->keylen]; 318 unsigned long *retry_key = NULL, key[MAX_KEYLEN];
317 319
318 if (keyzero(geo, __key)) 320 if (keyzero(geo, __key))
319 return NULL; 321 return NULL;
@@ -639,8 +641,8 @@ EXPORT_SYMBOL_GPL(btree_remove);
639int btree_merge(struct btree_head *target, struct btree_head *victim, 641int btree_merge(struct btree_head *target, struct btree_head *victim,
640 struct btree_geo *geo, gfp_t gfp) 642 struct btree_geo *geo, gfp_t gfp)
641{ 643{
642 unsigned long key[geo->keylen]; 644 unsigned long key[MAX_KEYLEN];
643 unsigned long dup[geo->keylen]; 645 unsigned long dup[MAX_KEYLEN];
644 void *val; 646 void *val;
645 int err; 647 int err;
646 648
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3d974cb2a1a1..635d7dd29d7f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1910,7 +1910,9 @@ static int move_freepages(struct zone *zone,
1910 * Remove at a later date when no bug reports exist related to 1910 * Remove at a later date when no bug reports exist related to
1911 * grouping pages by mobility 1911 * grouping pages by mobility
1912 */ 1912 */
1913 VM_BUG_ON(page_zone(start_page) != page_zone(end_page)); 1913 VM_BUG_ON(pfn_valid(page_to_pfn(start_page)) &&
1914 pfn_valid(page_to_pfn(end_page)) &&
1915 page_zone(start_page) != page_zone(end_page));
1914#endif 1916#endif
1915 1917
1916 if (num_movable) 1918 if (num_movable)
@@ -5359,14 +5361,9 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
5359 /* 5361 /*
5360 * Skip to the pfn preceding the next valid one (or 5362 * Skip to the pfn preceding the next valid one (or
5361 * end_pfn), such that we hit a valid pfn (or end_pfn) 5363 * end_pfn), such that we hit a valid pfn (or end_pfn)
5362 * on our next iteration of the loop. Note that it needs 5364 * on our next iteration of the loop.
5363 * to be pageblock aligned even when the region itself
5364 * is not. move_freepages_block() can shift ahead of
5365 * the valid region but still depends on correct page
5366 * metadata.
5367 */ 5365 */
5368 pfn = (memblock_next_valid_pfn(pfn, end_pfn) & 5366 pfn = memblock_next_valid_pfn(pfn, end_pfn) - 1;
5369 ~(pageblock_nr_pages-1)) - 1;
5370#endif 5367#endif
5371 continue; 5368 continue;
5372 } 5369 }
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index b044c0a5a674..02298c9c6020 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1762,10 +1762,9 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
1762 return -ENOMEM; 1762 return -ENOMEM;
1763 _snd_pcm_hw_params_any(params); 1763 _snd_pcm_hw_params_any(params);
1764 err = snd_pcm_hw_refine(substream, params); 1764 err = snd_pcm_hw_refine(substream, params);
1765 format_mask = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT);
1766 kfree(params);
1767 if (err < 0) 1765 if (err < 0)
1768 return err; 1766 goto error;
1767 format_mask = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT);
1769 for (fmt = 0; fmt < 32; ++fmt) { 1768 for (fmt = 0; fmt < 32; ++fmt) {
1770 if (snd_mask_test(format_mask, fmt)) { 1769 if (snd_mask_test(format_mask, fmt)) {
1771 int f = snd_pcm_oss_format_to(fmt); 1770 int f = snd_pcm_oss_format_to(fmt);
@@ -1773,7 +1772,10 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
1773 formats |= f; 1772 formats |= f;
1774 } 1773 }
1775 } 1774 }
1776 return formats; 1775
1776 error:
1777 kfree(params);
1778 return err < 0 ? err : formats;
1777} 1779}
1778 1780
1779static int snd_pcm_oss_set_format(struct snd_pcm_oss_file *pcm_oss_file, int format) 1781static int snd_pcm_oss_set_format(struct snd_pcm_oss_file *pcm_oss_file, int format)
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 918338dea5b9..61a07fe34cd2 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -255,12 +255,12 @@ static int seq_free_client1(struct snd_seq_client *client)
255 255
256 if (!client) 256 if (!client)
257 return 0; 257 return 0;
258 snd_seq_delete_all_ports(client);
259 snd_seq_queue_client_leave(client->number);
260 spin_lock_irqsave(&clients_lock, flags); 258 spin_lock_irqsave(&clients_lock, flags);
261 clienttablock[client->number] = 1; 259 clienttablock[client->number] = 1;
262 clienttab[client->number] = NULL; 260 clienttab[client->number] = NULL;
263 spin_unlock_irqrestore(&clients_lock, flags); 261 spin_unlock_irqrestore(&clients_lock, flags);
262 snd_seq_delete_all_ports(client);
263 snd_seq_queue_client_leave(client->number);
264 snd_use_lock_sync(&client->use_lock); 264 snd_use_lock_sync(&client->use_lock);
265 snd_seq_queue_client_termination(client->number); 265 snd_seq_queue_client_termination(client->number);
266 if (client->pool) 266 if (client->pool)
diff --git a/sound/core/seq/seq_prioq.c b/sound/core/seq/seq_prioq.c
index bc1c8488fc2a..2bc6759e4adc 100644
--- a/sound/core/seq/seq_prioq.c
+++ b/sound/core/seq/seq_prioq.c
@@ -87,7 +87,7 @@ void snd_seq_prioq_delete(struct snd_seq_prioq **fifo)
87 if (f->cells > 0) { 87 if (f->cells > 0) {
88 /* drain prioQ */ 88 /* drain prioQ */
89 while (f->cells > 0) 89 while (f->cells > 0)
90 snd_seq_cell_free(snd_seq_prioq_cell_out(f)); 90 snd_seq_cell_free(snd_seq_prioq_cell_out(f, NULL));
91 } 91 }
92 92
93 kfree(f); 93 kfree(f);
@@ -214,8 +214,18 @@ int snd_seq_prioq_cell_in(struct snd_seq_prioq * f,
214 return 0; 214 return 0;
215} 215}
216 216
217/* return 1 if the current time >= event timestamp */
218static int event_is_ready(struct snd_seq_event *ev, void *current_time)
219{
220 if ((ev->flags & SNDRV_SEQ_TIME_STAMP_MASK) == SNDRV_SEQ_TIME_STAMP_TICK)
221 return snd_seq_compare_tick_time(current_time, &ev->time.tick);
222 else
223 return snd_seq_compare_real_time(current_time, &ev->time.time);
224}
225
217/* dequeue cell from prioq */ 226/* dequeue cell from prioq */
218struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f) 227struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f,
228 void *current_time)
219{ 229{
220 struct snd_seq_event_cell *cell; 230 struct snd_seq_event_cell *cell;
221 unsigned long flags; 231 unsigned long flags;
@@ -227,6 +237,8 @@ struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f)
227 spin_lock_irqsave(&f->lock, flags); 237 spin_lock_irqsave(&f->lock, flags);
228 238
229 cell = f->head; 239 cell = f->head;
240 if (cell && current_time && !event_is_ready(&cell->event, current_time))
241 cell = NULL;
230 if (cell) { 242 if (cell) {
231 f->head = cell->next; 243 f->head = cell->next;
232 244
@@ -252,18 +264,6 @@ int snd_seq_prioq_avail(struct snd_seq_prioq * f)
252 return f->cells; 264 return f->cells;
253} 265}
254 266
255
256/* peek at cell at the head of the prioq */
257struct snd_seq_event_cell *snd_seq_prioq_cell_peek(struct snd_seq_prioq * f)
258{
259 if (f == NULL) {
260 pr_debug("ALSA: seq: snd_seq_prioq_cell_in() called with NULL prioq\n");
261 return NULL;
262 }
263 return f->head;
264}
265
266
267static inline int prioq_match(struct snd_seq_event_cell *cell, 267static inline int prioq_match(struct snd_seq_event_cell *cell,
268 int client, int timestamp) 268 int client, int timestamp)
269{ 269{
diff --git a/sound/core/seq/seq_prioq.h b/sound/core/seq/seq_prioq.h
index d38bb78d9345..2c315ca10fc4 100644
--- a/sound/core/seq/seq_prioq.h
+++ b/sound/core/seq/seq_prioq.h
@@ -44,14 +44,12 @@ void snd_seq_prioq_delete(struct snd_seq_prioq **fifo);
44int snd_seq_prioq_cell_in(struct snd_seq_prioq *f, struct snd_seq_event_cell *cell); 44int snd_seq_prioq_cell_in(struct snd_seq_prioq *f, struct snd_seq_event_cell *cell);
45 45
46/* dequeue cell from prioq */ 46/* dequeue cell from prioq */
47struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f); 47struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f,
48 void *current_time);
48 49
49/* return number of events available in prioq */ 50/* return number of events available in prioq */
50int snd_seq_prioq_avail(struct snd_seq_prioq *f); 51int snd_seq_prioq_avail(struct snd_seq_prioq *f);
51 52
52/* peek at cell at the head of the prioq */
53struct snd_seq_event_cell *snd_seq_prioq_cell_peek(struct snd_seq_prioq *f);
54
55/* client left queue */ 53/* client left queue */
56void snd_seq_prioq_leave(struct snd_seq_prioq *f, int client, int timestamp); 54void snd_seq_prioq_leave(struct snd_seq_prioq *f, int client, int timestamp);
57 55
diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c
index 0428e9061b47..b377f5048352 100644
--- a/sound/core/seq/seq_queue.c
+++ b/sound/core/seq/seq_queue.c
@@ -277,30 +277,20 @@ void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop)
277 277
278 __again: 278 __again:
279 /* Process tick queue... */ 279 /* Process tick queue... */
280 while ((cell = snd_seq_prioq_cell_peek(q->tickq)) != NULL) { 280 for (;;) {
281 if (snd_seq_compare_tick_time(&q->timer->tick.cur_tick, 281 cell = snd_seq_prioq_cell_out(q->tickq,
282 &cell->event.time.tick)) { 282 &q->timer->tick.cur_tick);
283 cell = snd_seq_prioq_cell_out(q->tickq); 283 if (!cell)
284 if (cell)
285 snd_seq_dispatch_event(cell, atomic, hop);
286 } else {
287 /* event remains in the queue */
288 break; 284 break;
289 } 285 snd_seq_dispatch_event(cell, atomic, hop);
290 } 286 }
291 287
292
293 /* Process time queue... */ 288 /* Process time queue... */
294 while ((cell = snd_seq_prioq_cell_peek(q->timeq)) != NULL) { 289 for (;;) {
295 if (snd_seq_compare_real_time(&q->timer->cur_time, 290 cell = snd_seq_prioq_cell_out(q->timeq, &q->timer->cur_time);
296 &cell->event.time.time)) { 291 if (!cell)
297 cell = snd_seq_prioq_cell_out(q->timeq);
298 if (cell)
299 snd_seq_dispatch_event(cell, atomic, hop);
300 } else {
301 /* event remains in the queue */
302 break; 292 break;
303 } 293 snd_seq_dispatch_event(cell, atomic, hop);
304 } 294 }
305 295
306 /* free lock */ 296 /* free lock */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 96143df19b21..d5017adf9feb 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -181,11 +181,15 @@ static const struct kernel_param_ops param_ops_xint = {
181}; 181};
182#define param_check_xint param_check_int 182#define param_check_xint param_check_int
183 183
184static int power_save = -1; 184static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
185module_param(power_save, xint, 0644); 185module_param(power_save, xint, 0644);
186MODULE_PARM_DESC(power_save, "Automatic power-saving timeout " 186MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
187 "(in second, 0 = disable)."); 187 "(in second, 0 = disable).");
188 188
189static bool pm_blacklist = true;
190module_param(pm_blacklist, bool, 0644);
191MODULE_PARM_DESC(pm_blacklist, "Enable power-management blacklist");
192
189/* reset the HD-audio controller in power save mode. 193/* reset the HD-audio controller in power save mode.
190 * this may give more power-saving, but will take longer time to 194 * this may give more power-saving, but will take longer time to
191 * wake up. 195 * wake up.
@@ -2300,10 +2304,9 @@ static int azx_probe_continue(struct azx *chip)
2300 2304
2301 val = power_save; 2305 val = power_save;
2302#ifdef CONFIG_PM 2306#ifdef CONFIG_PM
2303 if (val == -1) { 2307 if (pm_blacklist) {
2304 const struct snd_pci_quirk *q; 2308 const struct snd_pci_quirk *q;
2305 2309
2306 val = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
2307 q = snd_pci_quirk_lookup(chip->pci, power_save_blacklist); 2310 q = snd_pci_quirk_lookup(chip->pci, power_save_blacklist);
2308 if (q && val) { 2311 if (q && val) {
2309 dev_info(chip->card->dev, "device %04x:%04x is on the power_save blacklist, forcing power_save to 0\n", 2312 dev_info(chip->card->dev, "device %04x:%04x is on the power_save blacklist, forcing power_save to 0\n",
diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
index c33a512283a4..9fb356db3ab2 100644
--- a/sound/soc/amd/acp-pcm-dma.c
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -579,13 +579,6 @@ static int acp_init(void __iomem *acp_mmio, u32 asic_type)
579 for (bank = 1; bank < 48; bank++) 579 for (bank = 1; bank < 48; bank++)
580 acp_set_sram_bank_state(acp_mmio, bank, false); 580 acp_set_sram_bank_state(acp_mmio, bank, false);
581 } 581 }
582
583 /* Stoney supports 16bit resolution */
584 if (asic_type == CHIP_STONEY) {
585 val = acp_reg_read(acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN);
586 val |= 0x03;
587 acp_reg_write(val, acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN);
588 }
589 return 0; 582 return 0;
590} 583}
591 584
@@ -774,6 +767,7 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream,
774{ 767{
775 int status; 768 int status;
776 uint64_t size; 769 uint64_t size;
770 u32 val = 0;
777 struct page *pg; 771 struct page *pg;
778 struct snd_pcm_runtime *runtime; 772 struct snd_pcm_runtime *runtime;
779 struct audio_substream_data *rtd; 773 struct audio_substream_data *rtd;
@@ -786,6 +780,14 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream,
786 if (WARN_ON(!rtd)) 780 if (WARN_ON(!rtd))
787 return -EINVAL; 781 return -EINVAL;
788 782
783 if (adata->asic_type == CHIP_STONEY) {
784 val = acp_reg_read(adata->acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN);
785 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
786 val |= ACP_I2S_SP_16BIT_RESOLUTION_EN;
787 else
788 val |= ACP_I2S_MIC_16BIT_RESOLUTION_EN;
789 acp_reg_write(val, adata->acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN);
790 }
789 size = params_buffer_bytes(params); 791 size = params_buffer_bytes(params);
790 status = snd_pcm_lib_malloc_pages(substream, size); 792 status = snd_pcm_lib_malloc_pages(substream, size);
791 if (status < 0) 793 if (status < 0)
diff --git a/sound/soc/amd/acp.h b/sound/soc/amd/acp.h
index ecb458935d1e..9293f179f272 100644
--- a/sound/soc/amd/acp.h
+++ b/sound/soc/amd/acp.h
@@ -70,6 +70,8 @@
70#define CAPTURE_END_DMA_DESCR_CH15 7 70#define CAPTURE_END_DMA_DESCR_CH15 7
71 71
72#define mmACP_I2S_16BIT_RESOLUTION_EN 0x5209 72#define mmACP_I2S_16BIT_RESOLUTION_EN 0x5209
73#define ACP_I2S_MIC_16BIT_RESOLUTION_EN 0x01
74#define ACP_I2S_SP_16BIT_RESOLUTION_EN 0x02
73enum acp_dma_priority_level { 75enum acp_dma_priority_level {
74 /* 0x0 Specifies the DMA channel is given normal priority */ 76 /* 0x0 Specifies the DMA channel is given normal priority */
75 ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0, 77 ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0,
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index 5672e516bec3..c1830ccd3bb8 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -798,12 +798,7 @@ static int hdmi_codec_probe(struct platform_device *pdev)
798 798
799static int hdmi_codec_remove(struct platform_device *pdev) 799static int hdmi_codec_remove(struct platform_device *pdev)
800{ 800{
801 struct device *dev = &pdev->dev; 801 snd_soc_unregister_codec(&pdev->dev);
802 struct hdmi_codec_priv *hcp;
803
804 hcp = dev_get_drvdata(dev);
805 kfree(hcp->chmap_info);
806 snd_soc_unregister_codec(dev);
807 802
808 return 0; 803 return 0;
809} 804}
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c
index 831b297978a4..45a73049cf64 100644
--- a/sound/soc/codecs/rt5651.c
+++ b/sound/soc/codecs/rt5651.c
@@ -1722,6 +1722,7 @@ static const struct regmap_config rt5651_regmap = {
1722 .num_reg_defaults = ARRAY_SIZE(rt5651_reg), 1722 .num_reg_defaults = ARRAY_SIZE(rt5651_reg),
1723 .ranges = rt5651_ranges, 1723 .ranges = rt5651_ranges,
1724 .num_ranges = ARRAY_SIZE(rt5651_ranges), 1724 .num_ranges = ARRAY_SIZE(rt5651_ranges),
1725 .use_single_rw = true,
1725}; 1726};
1726 1727
1727#if defined(CONFIG_OF) 1728#if defined(CONFIG_OF)
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index e1ab5537d27a..c5c76ab8ccf1 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -529,10 +529,15 @@ static const struct snd_kcontrol_new sgtl5000_snd_controls[] = {
529static int sgtl5000_digital_mute(struct snd_soc_dai *codec_dai, int mute) 529static int sgtl5000_digital_mute(struct snd_soc_dai *codec_dai, int mute)
530{ 530{
531 struct snd_soc_codec *codec = codec_dai->codec; 531 struct snd_soc_codec *codec = codec_dai->codec;
532 u16 adcdac_ctrl = SGTL5000_DAC_MUTE_LEFT | SGTL5000_DAC_MUTE_RIGHT; 532 u16 i2s_pwr = SGTL5000_I2S_IN_POWERUP;
533 533
534 snd_soc_update_bits(codec, SGTL5000_CHIP_ADCDAC_CTRL, 534 /*
535 adcdac_ctrl, mute ? adcdac_ctrl : 0); 535 * During 'digital mute' do not mute DAC
536 * because LINE_IN would be muted aswell. We want to mute
537 * only I2S block - this can be done by powering it off
538 */
539 snd_soc_update_bits(codec, SGTL5000_CHIP_DIG_POWER,
540 i2s_pwr, mute ? 0 : i2s_pwr);
536 541
537 return 0; 542 return 0;
538} 543}
@@ -871,15 +876,26 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream,
871static int sgtl5000_set_bias_level(struct snd_soc_codec *codec, 876static int sgtl5000_set_bias_level(struct snd_soc_codec *codec,
872 enum snd_soc_bias_level level) 877 enum snd_soc_bias_level level)
873{ 878{
879 struct sgtl5000_priv *sgtl = snd_soc_codec_get_drvdata(codec);
880 int ret;
881
874 switch (level) { 882 switch (level) {
875 case SND_SOC_BIAS_ON: 883 case SND_SOC_BIAS_ON:
876 case SND_SOC_BIAS_PREPARE: 884 case SND_SOC_BIAS_PREPARE:
877 case SND_SOC_BIAS_STANDBY: 885 case SND_SOC_BIAS_STANDBY:
886 regcache_cache_only(sgtl->regmap, false);
887 ret = regcache_sync(sgtl->regmap);
888 if (ret) {
889 regcache_cache_only(sgtl->regmap, true);
890 return ret;
891 }
892
878 snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, 893 snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
879 SGTL5000_REFTOP_POWERUP, 894 SGTL5000_REFTOP_POWERUP,
880 SGTL5000_REFTOP_POWERUP); 895 SGTL5000_REFTOP_POWERUP);
881 break; 896 break;
882 case SND_SOC_BIAS_OFF: 897 case SND_SOC_BIAS_OFF:
898 regcache_cache_only(sgtl->regmap, true);
883 snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, 899 snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
884 SGTL5000_REFTOP_POWERUP, 0); 900 SGTL5000_REFTOP_POWERUP, 0);
885 break; 901 break;
@@ -1237,6 +1253,10 @@ static int sgtl5000_probe(struct snd_soc_codec *codec)
1237 */ 1253 */
1238 snd_soc_write(codec, SGTL5000_DAP_CTRL, 0); 1254 snd_soc_write(codec, SGTL5000_DAP_CTRL, 0);
1239 1255
1256 /* Unmute DAC after start */
1257 snd_soc_update_bits(codec, SGTL5000_CHIP_ADCDAC_CTRL,
1258 SGTL5000_DAC_MUTE_LEFT | SGTL5000_DAC_MUTE_RIGHT, 0);
1259
1240 return 0; 1260 return 0;
1241 1261
1242err: 1262err:
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 66e32f5d2917..989d093abda7 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -1204,12 +1204,14 @@ static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl)
1204 kcontrol->put = wm_coeff_put_acked; 1204 kcontrol->put = wm_coeff_put_acked;
1205 break; 1205 break;
1206 default: 1206 default:
1207 kcontrol->get = wm_coeff_get; 1207 if (kcontrol->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
1208 kcontrol->put = wm_coeff_put; 1208 ctl->bytes_ext.max = ctl->len;
1209 1209 ctl->bytes_ext.get = wm_coeff_tlv_get;
1210 ctl->bytes_ext.max = ctl->len; 1210 ctl->bytes_ext.put = wm_coeff_tlv_put;
1211 ctl->bytes_ext.get = wm_coeff_tlv_get; 1211 } else {
1212 ctl->bytes_ext.put = wm_coeff_tlv_put; 1212 kcontrol->get = wm_coeff_get;
1213 kcontrol->put = wm_coeff_put;
1214 }
1213 break; 1215 break;
1214 } 1216 }
1215 1217
diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index dca1143c1150..a4aa931ebfae 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -104,7 +104,7 @@
104 104
105#define SUN8I_I2S_CHAN_CFG_REG 0x30 105#define SUN8I_I2S_CHAN_CFG_REG 0x30
106#define SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM_MASK GENMASK(6, 4) 106#define SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM_MASK GENMASK(6, 4)
107#define SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM(chan) (chan - 1) 107#define SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM(chan) ((chan - 1) << 4)
108#define SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM_MASK GENMASK(2, 0) 108#define SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM_MASK GENMASK(2, 0)
109#define SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM(chan) (chan - 1) 109#define SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM(chan) (chan - 1)
110 110