aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLCPD Auto Merger2017-01-18 18:31:20 -0600
committerLCPD Auto Merger2017-01-18 18:31:20 -0600
commit1847109d68b37ca44d3258a8dc9ef6de5aad513d (patch)
treec9895fb8746e7b31687ddb7db4817d3c30d29408
parent7c580a51af521f320eb56717f291aa5b64c2f244 (diff)
parent90e3e814d73641b329d05759d67afc4a71aa21a4 (diff)
downloadkernel-omap-1847109d68b37ca44d3258a8dc9ef6de5aad513d.tar.gz
kernel-omap-1847109d68b37ca44d3258a8dc9ef6de5aad513d.tar.xz
kernel-omap-1847109d68b37ca44d3258a8dc9ef6de5aad513d.zip
Merge branch 'ti-linux-4.4.y' of git.ti.com:ti-linux-kernel/ti-linux-kernel into ti-lsk-linux-4.4.y
TI-Feature: ti_linux_base_lsk TI-Tree: git@git.ti.com:ti-linux-kernel/ti-linux-kernel.git TI-Branch: ti-linux-4.4.y * 'ti-linux-4.4.y' of git.ti.com:ti-linux-kernel/ti-linux-kernel: (132 commits) Linux 4.4.43 mm/init: fix zone boundary creation ALSA: usb-audio: Add a quirk for Plantronics BT600 spi: mvebu: fix baudrate calculation for armada variant ARM: OMAP4+: Fix bad fallthrough for cpuidle ARM: zynq: Reserve correct amount of non-DMA RAM powerpc: Fix build warning on 32-bit PPC ALSA: firewire-tascam: Fix to handle error from initialization of stream data HID: hid-cypress: validate length of report net: vrf: do not allow table id 0 net: ipv4: Fix multipath selection with vrf gro: Disable frag0 optimization on IPv6 ext headers gro: use min_t() in skb_gro_reset_offset() gro: Enter slow-path if there is no tailroom r8152: fix rx issue for runtime suspend r8152: split rtl8152_suspend function ipv4: Do not allow MAIN to be alias for new LOCAL w/ custom rules igmp: Make igmp group member RFC 3376 compliant drop_monitor: consider inserted data in genlmsg_end drop_monitor: add missing call to genlmsg_end ... Signed-off-by: LCPD Auto Merger <lcpd_integration@list.ti.com>
-rw-r--r--Makefile2
-rw-r--r--arch/arm/boot/dts/r8a7794.dtsi2
-rw-r--r--arch/arm/crypto/aes-ce-glue.c5
-rw-r--r--arch/arm/mach-davinci/da850.c12
-rw-r--r--arch/arm/mach-omap2/omap-mpuss-lowpower.c5
-rw-r--r--arch/arm/mach-zynq/common.c2
-rw-r--r--arch/arm64/crypto/aes-ce-ccm-core.S53
-rw-r--r--arch/arm64/crypto/aes-ce-cipher.c25
-rw-r--r--arch/arm64/crypto/aes-ce.S1
-rw-r--r--arch/arm64/crypto/aes-modes.S3
-rw-r--r--arch/arm64/crypto/aes-neon.S25
-rw-r--r--arch/arm64/crypto/ghash-ce-core.S6
-rw-r--r--arch/arm64/crypto/sha1-ce-core.S4
-rw-r--r--arch/arm64/crypto/sha2-ce-core.S4
-rw-r--r--arch/cris/boot/rescue/Makefile8
-rw-r--r--arch/mips/kvm/mips.c4
-rw-r--r--arch/powerpc/kernel/misc_32.S2
-rw-r--r--arch/s390/crypto/prng.c6
-rw-r--r--arch/x86/kvm/x86.c9
-rw-r--r--drivers/base/power/power.h19
-rw-r--r--drivers/base/power/runtime.c8
-rw-r--r--drivers/base/power/wakeirq.c76
-rw-r--r--drivers/clk/clk-wm831x.c2
-rw-r--r--drivers/clk/imx/clk-imx31.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_cursor.c6
-rw-r--r--drivers/hid/hid-cypress.c3
-rw-r--r--drivers/hwmon/amc6821.c4
-rw-r--r--drivers/hwmon/ds620.c2
-rw-r--r--drivers/hwmon/g762.c11
-rw-r--r--drivers/hwmon/nct7802.c8
-rw-r--r--drivers/hwmon/scpi-hwmon.c1
-rw-r--r--drivers/iommu/amd_iommu.c2
-rw-r--r--drivers/iommu/amd_iommu_v2.c4
-rw-r--r--drivers/iommu/intel-iommu.c42
-rw-r--r--drivers/irqchip/irq-bcm7038-l1.c26
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c4
-rw-r--r--drivers/md/md.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-dvb.c6
-rw-r--r--drivers/misc/mei/bus.c2
-rw-r--r--drivers/mmc/card/mmc_test.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c10
-rw-r--r--drivers/net/ethernet/neterion/vxge/vxge-main.c31
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c22
-rw-r--r--drivers/net/ethernet/ti/cpmac.c5
-rw-r--r--drivers/net/hyperv/netvsc_drv.c3
-rw-r--r--drivers/net/usb/r8152.c80
-rw-r--r--drivers/net/vrf.c8
-rw-r--r--drivers/net/wireless/ath/ath10k/spectral.c2
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c10
-rw-r--r--drivers/scsi/mvsas/mv_94xx.c2
-rw-r--r--drivers/spi/spi-orion.c83
-rw-r--r--drivers/staging/comedi/drivers/dt282x.c65
-rw-r--r--drivers/staging/iio/adc/ad7606_core.c2
-rw-r--r--drivers/target/iscsi/iscsi_target_tpg.c1
-rw-r--r--drivers/usb/core/config.c10
-rw-r--r--drivers/usb/core/hub.c59
-rw-r--r--drivers/usb/dwc3/core.h4
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c2
-rw-r--r--drivers/usb/dwc3/ep0.c50
-rw-r--r--drivers/usb/dwc3/gadget.c8
-rw-r--r--drivers/usb/gadget/composite.c14
-rw-r--r--drivers/usb/gadget/legacy/inode.c17
-rw-r--r--drivers/usb/gadget/udc/dummy_hcd.c6
-rw-r--r--drivers/usb/host/xhci-hub.c37
-rw-r--r--drivers/usb/host/xhci-mem.c50
-rw-r--r--drivers/usb/host/xhci-pci.c9
-rw-r--r--drivers/usb/host/xhci-ring.c219
-rw-r--r--drivers/usb/host/xhci.c4
-rw-r--r--drivers/usb/host/xhci.h8
-rw-r--r--drivers/usb/musb/blackfin.c1
-rw-r--r--drivers/usb/musb/musb_core.h7
-rw-r--r--drivers/usb/musb/musb_dsps.c12
-rw-r--r--drivers/usb/musb/musb_host.c10
-rw-r--r--drivers/usb/musb/musbhsdma.h2
-rw-r--r--drivers/usb/phy/phy-am335x-control.c2
-rw-r--r--drivers/usb/serial/cyberjack.c10
-rw-r--r--drivers/usb/serial/garmin_gps.c1
-rw-r--r--drivers/usb/serial/io_edgeport.c5
-rw-r--r--drivers/usb/serial/io_ti.c22
-rw-r--r--drivers/usb/serial/iuu_phoenix.c11
-rw-r--r--drivers/usb/serial/keyspan_pda.c14
-rw-r--r--drivers/usb/serial/kl5kusb105.c2
-rw-r--r--drivers/usb/serial/kobil_sct.c12
-rw-r--r--drivers/usb/serial/mos7720.c51
-rw-r--r--drivers/usb/serial/mos7840.c12
-rw-r--r--drivers/usb/serial/omninet.c13
-rw-r--r--drivers/usb/serial/oti6858.c16
-rw-r--r--drivers/usb/serial/pl2303.c8
-rw-r--r--drivers/usb/serial/quatech2.c4
-rw-r--r--drivers/usb/serial/spcp8x5.c14
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c7
-rw-r--r--drivers/usb/storage/unusual_devs.h7
-rw-r--r--include/linux/capability.h2
-rw-r--r--include/linux/cred.h5
-rw-r--r--include/linux/netdevice.h9
-rw-r--r--kernel/cpu.c9
-rw-r--r--kernel/time/tick-broadcast.c3
-rw-r--r--mm/page_alloc.c17
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/drop_monitor.c39
-rw-r--r--net/ipv4/fib_frontend.c2
-rw-r--r--net/ipv4/fib_semantics.c9
-rw-r--r--net/ipv4/igmp.c7
-rw-r--r--net/ipv6/ip6_offload.c1
-rw-r--r--net/ipv6/raw.c6
-rw-r--r--net/mac80211/tx.c3
-rw-r--r--net/sched/cls_api.c4
-rw-r--r--sound/firewire/tascam/tascam-stream.c2
-rw-r--r--sound/pci/hda/patch_realtek.c2
-rw-r--r--sound/soc/samsung/i2s.c5
-rw-r--r--sound/usb/card.c1
-rw-r--r--sound/usb/endpoint.c17
-rw-r--r--sound/usb/endpoint.h2
-rw-r--r--sound/usb/pcm.c10
-rw-r--r--sound/usb/quirks.c1
115 files changed, 1138 insertions, 498 deletions
diff --git a/Makefile b/Makefile
index 855e71066174..04a2186a4276 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 4 2PATCHLEVEL = 4
3SUBLEVEL = 41 3SUBLEVEL = 43
4EXTRAVERSION = 4EXTRAVERSION =
5NAME = Blurry Fish Butt 5NAME = Blurry Fish Butt
6 6
diff --git a/arch/arm/boot/dts/r8a7794.dtsi b/arch/arm/boot/dts/r8a7794.dtsi
index a9977d6ee81a..169653586a9f 100644
--- a/arch/arm/boot/dts/r8a7794.dtsi
+++ b/arch/arm/boot/dts/r8a7794.dtsi
@@ -1023,7 +1023,7 @@
1023 mstp7_clks: mstp7_clks@e615014c { 1023 mstp7_clks: mstp7_clks@e615014c {
1024 compatible = "renesas,r8a7794-mstp-clocks", "renesas,cpg-mstp-clocks"; 1024 compatible = "renesas,r8a7794-mstp-clocks", "renesas,cpg-mstp-clocks";
1025 reg = <0 0xe615014c 0 4>, <0 0xe61501c4 0 4>; 1025 reg = <0 0xe615014c 0 4>, <0 0xe61501c4 0 4>;
1026 clocks = <&mp_clk>, <&mp_clk>, 1026 clocks = <&mp_clk>, <&hp_clk>,
1027 <&zs_clk>, <&p_clk>, <&p_clk>, <&zs_clk>, 1027 <&zs_clk>, <&p_clk>, <&p_clk>, <&zs_clk>,
1028 <&zs_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>; 1028 <&zs_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>;
1029 #clock-cells = <1>; 1029 #clock-cells = <1>;
diff --git a/arch/arm/crypto/aes-ce-glue.c b/arch/arm/crypto/aes-ce-glue.c
index 593da7ffb449..679c589c4828 100644
--- a/arch/arm/crypto/aes-ce-glue.c
+++ b/arch/arm/crypto/aes-ce-glue.c
@@ -87,8 +87,13 @@ static int ce_aes_expandkey(struct crypto_aes_ctx *ctx, const u8 *in_key,
87 u32 *rki = ctx->key_enc + (i * kwords); 87 u32 *rki = ctx->key_enc + (i * kwords);
88 u32 *rko = rki + kwords; 88 u32 *rko = rki + kwords;
89 89
90#ifndef CONFIG_CPU_BIG_ENDIAN
90 rko[0] = ror32(ce_aes_sub(rki[kwords - 1]), 8); 91 rko[0] = ror32(ce_aes_sub(rki[kwords - 1]), 8);
91 rko[0] = rko[0] ^ rki[0] ^ rcon[i]; 92 rko[0] = rko[0] ^ rki[0] ^ rcon[i];
93#else
94 rko[0] = rol32(ce_aes_sub(rki[kwords - 1]), 8);
95 rko[0] = rko[0] ^ rki[0] ^ (rcon[i] << 24);
96#endif
92 rko[1] = rko[0] ^ rki[1]; 97 rko[1] = rko[0] ^ rki[1];
93 rko[2] = rko[1] ^ rki[2]; 98 rko[2] = rko[1] ^ rki[2];
94 rko[3] = rko[2] ^ rki[3]; 99 rko[3] = rko[2] ^ rki[3];
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 676997895e13..f5f81a107309 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -298,6 +298,16 @@ static struct clk emac_clk = {
298 .gpsc = 1, 298 .gpsc = 1,
299}; 299};
300 300
301/*
302 * In order to avoid adding the emac_clk to the clock lookup table twice (and
303 * screwing up the linked list in the process) create a separate clock for
304 * mdio inheriting the rate from emac_clk.
305 */
306static struct clk mdio_clk = {
307 .name = "mdio",
308 .parent = &emac_clk,
309};
310
301static struct clk mcasp_clk = { 311static struct clk mcasp_clk = {
302 .name = "mcasp", 312 .name = "mcasp",
303 .parent = &pll0_sysclk2, 313 .parent = &pll0_sysclk2,
@@ -462,7 +472,7 @@ static struct clk_lookup da850_clks[] = {
462 CLK(NULL, "arm", &arm_clk), 472 CLK(NULL, "arm", &arm_clk),
463 CLK(NULL, "rmii", &rmii_clk), 473 CLK(NULL, "rmii", &rmii_clk),
464 CLK("davinci_emac.1", NULL, &emac_clk), 474 CLK("davinci_emac.1", NULL, &emac_clk),
465 CLK("davinci_mdio.0", "fck", &emac_clk), 475 CLK("davinci_mdio.0", "fck", &mdio_clk),
466 CLK("davinci-mcasp.0", NULL, &mcasp_clk), 476 CLK("davinci-mcasp.0", NULL, &mcasp_clk),
467 CLK("da8xx_lcdc.0", "fck", &lcdc_clk), 477 CLK("da8xx_lcdc.0", "fck", &lcdc_clk),
468 CLK("da830-mmc.0", NULL, &mmcsd0_clk), 478 CLK("da830-mmc.0", NULL, &mmcsd0_clk),
diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
index 65024af169d3..d3c14da7d216 100644
--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
@@ -243,10 +243,9 @@ int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state)
243 save_state = 1; 243 save_state = 1;
244 break; 244 break;
245 case PWRDM_POWER_RET: 245 case PWRDM_POWER_RET:
246 if (IS_PM44XX_ERRATUM(PM_OMAP4_CPU_OSWR_DISABLE)) { 246 if (IS_PM44XX_ERRATUM(PM_OMAP4_CPU_OSWR_DISABLE))
247 save_state = 0; 247 save_state = 0;
248 break; 248 break;
249 }
250 default: 249 default:
251 /* 250 /*
252 * CPUx CSWR is invalid hardware state. Also CPUx OSWR 251 * CPUx CSWR is invalid hardware state. Also CPUx OSWR
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 6f39d03cc27e..0a43143e9ceb 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -59,7 +59,7 @@ void __iomem *zynq_scu_base;
59static void __init zynq_memory_init(void) 59static void __init zynq_memory_init(void)
60{ 60{
61 if (!__pa(PAGE_OFFSET)) 61 if (!__pa(PAGE_OFFSET))
62 memblock_reserve(__pa(PAGE_OFFSET), __pa(swapper_pg_dir)); 62 memblock_reserve(__pa(PAGE_OFFSET), 0x80000);
63} 63}
64 64
65static struct platform_device zynq_cpuidle_device = { 65static struct platform_device zynq_cpuidle_device = {
diff --git a/arch/arm64/crypto/aes-ce-ccm-core.S b/arch/arm64/crypto/aes-ce-ccm-core.S
index a2a7fbcacc14..3363560c79b7 100644
--- a/arch/arm64/crypto/aes-ce-ccm-core.S
+++ b/arch/arm64/crypto/aes-ce-ccm-core.S
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/linkage.h> 11#include <linux/linkage.h>
12#include <asm/assembler.h>
12 13
13 .text 14 .text
14 .arch armv8-a+crypto 15 .arch armv8-a+crypto
@@ -19,7 +20,7 @@
19 */ 20 */
20ENTRY(ce_aes_ccm_auth_data) 21ENTRY(ce_aes_ccm_auth_data)
21 ldr w8, [x3] /* leftover from prev round? */ 22 ldr w8, [x3] /* leftover from prev round? */
22 ld1 {v0.2d}, [x0] /* load mac */ 23 ld1 {v0.16b}, [x0] /* load mac */
23 cbz w8, 1f 24 cbz w8, 1f
24 sub w8, w8, #16 25 sub w8, w8, #16
25 eor v1.16b, v1.16b, v1.16b 26 eor v1.16b, v1.16b, v1.16b
@@ -31,7 +32,7 @@ ENTRY(ce_aes_ccm_auth_data)
31 beq 8f /* out of input? */ 32 beq 8f /* out of input? */
32 cbnz w8, 0b 33 cbnz w8, 0b
33 eor v0.16b, v0.16b, v1.16b 34 eor v0.16b, v0.16b, v1.16b
341: ld1 {v3.2d}, [x4] /* load first round key */ 351: ld1 {v3.16b}, [x4] /* load first round key */
35 prfm pldl1strm, [x1] 36 prfm pldl1strm, [x1]
36 cmp w5, #12 /* which key size? */ 37 cmp w5, #12 /* which key size? */
37 add x6, x4, #16 38 add x6, x4, #16
@@ -41,17 +42,17 @@ ENTRY(ce_aes_ccm_auth_data)
41 mov v5.16b, v3.16b 42 mov v5.16b, v3.16b
42 b 4f 43 b 4f
432: mov v4.16b, v3.16b 442: mov v4.16b, v3.16b
44 ld1 {v5.2d}, [x6], #16 /* load 2nd round key */ 45 ld1 {v5.16b}, [x6], #16 /* load 2nd round key */
453: aese v0.16b, v4.16b 463: aese v0.16b, v4.16b
46 aesmc v0.16b, v0.16b 47 aesmc v0.16b, v0.16b
474: ld1 {v3.2d}, [x6], #16 /* load next round key */ 484: ld1 {v3.16b}, [x6], #16 /* load next round key */
48 aese v0.16b, v5.16b 49 aese v0.16b, v5.16b
49 aesmc v0.16b, v0.16b 50 aesmc v0.16b, v0.16b
505: ld1 {v4.2d}, [x6], #16 /* load next round key */ 515: ld1 {v4.16b}, [x6], #16 /* load next round key */
51 subs w7, w7, #3 52 subs w7, w7, #3
52 aese v0.16b, v3.16b 53 aese v0.16b, v3.16b
53 aesmc v0.16b, v0.16b 54 aesmc v0.16b, v0.16b
54 ld1 {v5.2d}, [x6], #16 /* load next round key */ 55 ld1 {v5.16b}, [x6], #16 /* load next round key */
55 bpl 3b 56 bpl 3b
56 aese v0.16b, v4.16b 57 aese v0.16b, v4.16b
57 subs w2, w2, #16 /* last data? */ 58 subs w2, w2, #16 /* last data? */
@@ -60,7 +61,7 @@ ENTRY(ce_aes_ccm_auth_data)
60 ld1 {v1.16b}, [x1], #16 /* load next input block */ 61 ld1 {v1.16b}, [x1], #16 /* load next input block */
61 eor v0.16b, v0.16b, v1.16b /* xor with mac */ 62 eor v0.16b, v0.16b, v1.16b /* xor with mac */
62 bne 1b 63 bne 1b
636: st1 {v0.2d}, [x0] /* store mac */ 646: st1 {v0.16b}, [x0] /* store mac */
64 beq 10f 65 beq 10f
65 adds w2, w2, #16 66 adds w2, w2, #16
66 beq 10f 67 beq 10f
@@ -79,7 +80,7 @@ ENTRY(ce_aes_ccm_auth_data)
79 adds w7, w7, #1 80 adds w7, w7, #1
80 bne 9b 81 bne 9b
81 eor v0.16b, v0.16b, v1.16b 82 eor v0.16b, v0.16b, v1.16b
82 st1 {v0.2d}, [x0] 83 st1 {v0.16b}, [x0]
8310: str w8, [x3] 8410: str w8, [x3]
84 ret 85 ret
85ENDPROC(ce_aes_ccm_auth_data) 86ENDPROC(ce_aes_ccm_auth_data)
@@ -89,27 +90,27 @@ ENDPROC(ce_aes_ccm_auth_data)
89 * u32 rounds); 90 * u32 rounds);
90 */ 91 */
91ENTRY(ce_aes_ccm_final) 92ENTRY(ce_aes_ccm_final)
92 ld1 {v3.2d}, [x2], #16 /* load first round key */ 93 ld1 {v3.16b}, [x2], #16 /* load first round key */
93 ld1 {v0.2d}, [x0] /* load mac */ 94 ld1 {v0.16b}, [x0] /* load mac */
94 cmp w3, #12 /* which key size? */ 95 cmp w3, #12 /* which key size? */
95 sub w3, w3, #2 /* modified # of rounds */ 96 sub w3, w3, #2 /* modified # of rounds */
96 ld1 {v1.2d}, [x1] /* load 1st ctriv */ 97 ld1 {v1.16b}, [x1] /* load 1st ctriv */
97 bmi 0f 98 bmi 0f
98 bne 3f 99 bne 3f
99 mov v5.16b, v3.16b 100 mov v5.16b, v3.16b
100 b 2f 101 b 2f
1010: mov v4.16b, v3.16b 1020: mov v4.16b, v3.16b
1021: ld1 {v5.2d}, [x2], #16 /* load next round key */ 1031: ld1 {v5.16b}, [x2], #16 /* load next round key */
103 aese v0.16b, v4.16b 104 aese v0.16b, v4.16b
104 aesmc v0.16b, v0.16b 105 aesmc v0.16b, v0.16b
105 aese v1.16b, v4.16b 106 aese v1.16b, v4.16b
106 aesmc v1.16b, v1.16b 107 aesmc v1.16b, v1.16b
1072: ld1 {v3.2d}, [x2], #16 /* load next round key */ 1082: ld1 {v3.16b}, [x2], #16 /* load next round key */
108 aese v0.16b, v5.16b 109 aese v0.16b, v5.16b
109 aesmc v0.16b, v0.16b 110 aesmc v0.16b, v0.16b
110 aese v1.16b, v5.16b 111 aese v1.16b, v5.16b
111 aesmc v1.16b, v1.16b 112 aesmc v1.16b, v1.16b
1123: ld1 {v4.2d}, [x2], #16 /* load next round key */ 1133: ld1 {v4.16b}, [x2], #16 /* load next round key */
113 subs w3, w3, #3 114 subs w3, w3, #3
114 aese v0.16b, v3.16b 115 aese v0.16b, v3.16b
115 aesmc v0.16b, v0.16b 116 aesmc v0.16b, v0.16b
@@ -120,47 +121,47 @@ ENTRY(ce_aes_ccm_final)
120 aese v1.16b, v4.16b 121 aese v1.16b, v4.16b
121 /* final round key cancels out */ 122 /* final round key cancels out */
122 eor v0.16b, v0.16b, v1.16b /* en-/decrypt the mac */ 123 eor v0.16b, v0.16b, v1.16b /* en-/decrypt the mac */
123 st1 {v0.2d}, [x0] /* store result */ 124 st1 {v0.16b}, [x0] /* store result */
124 ret 125 ret
125ENDPROC(ce_aes_ccm_final) 126ENDPROC(ce_aes_ccm_final)
126 127
127 .macro aes_ccm_do_crypt,enc 128 .macro aes_ccm_do_crypt,enc
128 ldr x8, [x6, #8] /* load lower ctr */ 129 ldr x8, [x6, #8] /* load lower ctr */
129 ld1 {v0.2d}, [x5] /* load mac */ 130 ld1 {v0.16b}, [x5] /* load mac */
130 rev x8, x8 /* keep swabbed ctr in reg */ 131CPU_LE( rev x8, x8 ) /* keep swabbed ctr in reg */
1310: /* outer loop */ 1320: /* outer loop */
132 ld1 {v1.1d}, [x6] /* load upper ctr */ 133 ld1 {v1.8b}, [x6] /* load upper ctr */
133 prfm pldl1strm, [x1] 134 prfm pldl1strm, [x1]
134 add x8, x8, #1 135 add x8, x8, #1
135 rev x9, x8 136 rev x9, x8
136 cmp w4, #12 /* which key size? */ 137 cmp w4, #12 /* which key size? */
137 sub w7, w4, #2 /* get modified # of rounds */ 138 sub w7, w4, #2 /* get modified # of rounds */
138 ins v1.d[1], x9 /* no carry in lower ctr */ 139 ins v1.d[1], x9 /* no carry in lower ctr */
139 ld1 {v3.2d}, [x3] /* load first round key */ 140 ld1 {v3.16b}, [x3] /* load first round key */
140 add x10, x3, #16 141 add x10, x3, #16
141 bmi 1f 142 bmi 1f
142 bne 4f 143 bne 4f
143 mov v5.16b, v3.16b 144 mov v5.16b, v3.16b
144 b 3f 145 b 3f
1451: mov v4.16b, v3.16b 1461: mov v4.16b, v3.16b
146 ld1 {v5.2d}, [x10], #16 /* load 2nd round key */ 147 ld1 {v5.16b}, [x10], #16 /* load 2nd round key */
1472: /* inner loop: 3 rounds, 2x interleaved */ 1482: /* inner loop: 3 rounds, 2x interleaved */
148 aese v0.16b, v4.16b 149 aese v0.16b, v4.16b
149 aesmc v0.16b, v0.16b 150 aesmc v0.16b, v0.16b
150 aese v1.16b, v4.16b 151 aese v1.16b, v4.16b
151 aesmc v1.16b, v1.16b 152 aesmc v1.16b, v1.16b
1523: ld1 {v3.2d}, [x10], #16 /* load next round key */ 1533: ld1 {v3.16b}, [x10], #16 /* load next round key */
153 aese v0.16b, v5.16b 154 aese v0.16b, v5.16b
154 aesmc v0.16b, v0.16b 155 aesmc v0.16b, v0.16b
155 aese v1.16b, v5.16b 156 aese v1.16b, v5.16b
156 aesmc v1.16b, v1.16b 157 aesmc v1.16b, v1.16b
1574: ld1 {v4.2d}, [x10], #16 /* load next round key */ 1584: ld1 {v4.16b}, [x10], #16 /* load next round key */
158 subs w7, w7, #3 159 subs w7, w7, #3
159 aese v0.16b, v3.16b 160 aese v0.16b, v3.16b
160 aesmc v0.16b, v0.16b 161 aesmc v0.16b, v0.16b
161 aese v1.16b, v3.16b 162 aese v1.16b, v3.16b
162 aesmc v1.16b, v1.16b 163 aesmc v1.16b, v1.16b
163 ld1 {v5.2d}, [x10], #16 /* load next round key */ 164 ld1 {v5.16b}, [x10], #16 /* load next round key */
164 bpl 2b 165 bpl 2b
165 aese v0.16b, v4.16b 166 aese v0.16b, v4.16b
166 aese v1.16b, v4.16b 167 aese v1.16b, v4.16b
@@ -177,14 +178,14 @@ ENDPROC(ce_aes_ccm_final)
177 eor v0.16b, v0.16b, v2.16b /* xor mac with pt ^ rk[last] */ 178 eor v0.16b, v0.16b, v2.16b /* xor mac with pt ^ rk[last] */
178 st1 {v1.16b}, [x0], #16 /* write output block */ 179 st1 {v1.16b}, [x0], #16 /* write output block */
179 bne 0b 180 bne 0b
180 rev x8, x8 181CPU_LE( rev x8, x8 )
181 st1 {v0.2d}, [x5] /* store mac */ 182 st1 {v0.16b}, [x5] /* store mac */
182 str x8, [x6, #8] /* store lsb end of ctr (BE) */ 183 str x8, [x6, #8] /* store lsb end of ctr (BE) */
1835: ret 1845: ret
184 185
1856: eor v0.16b, v0.16b, v5.16b /* final round mac */ 1866: eor v0.16b, v0.16b, v5.16b /* final round mac */
186 eor v1.16b, v1.16b, v5.16b /* final round enc */ 187 eor v1.16b, v1.16b, v5.16b /* final round enc */
187 st1 {v0.2d}, [x5] /* store mac */ 188 st1 {v0.16b}, [x5] /* store mac */
188 add w2, w2, #16 /* process partial tail block */ 189 add w2, w2, #16 /* process partial tail block */
1897: ldrb w9, [x1], #1 /* get 1 byte of input */ 1907: ldrb w9, [x1], #1 /* get 1 byte of input */
190 umov w6, v1.b[0] /* get top crypted ctr byte */ 191 umov w6, v1.b[0] /* get top crypted ctr byte */
diff --git a/arch/arm64/crypto/aes-ce-cipher.c b/arch/arm64/crypto/aes-ce-cipher.c
index f7bd9bf0bbb3..50d9fe11d0c8 100644
--- a/arch/arm64/crypto/aes-ce-cipher.c
+++ b/arch/arm64/crypto/aes-ce-cipher.c
@@ -47,24 +47,24 @@ static void aes_cipher_encrypt(struct crypto_tfm *tfm, u8 dst[], u8 const src[])
47 kernel_neon_begin_partial(4); 47 kernel_neon_begin_partial(4);
48 48
49 __asm__(" ld1 {v0.16b}, %[in] ;" 49 __asm__(" ld1 {v0.16b}, %[in] ;"
50 " ld1 {v1.2d}, [%[key]], #16 ;" 50 " ld1 {v1.16b}, [%[key]], #16 ;"
51 " cmp %w[rounds], #10 ;" 51 " cmp %w[rounds], #10 ;"
52 " bmi 0f ;" 52 " bmi 0f ;"
53 " bne 3f ;" 53 " bne 3f ;"
54 " mov v3.16b, v1.16b ;" 54 " mov v3.16b, v1.16b ;"
55 " b 2f ;" 55 " b 2f ;"
56 "0: mov v2.16b, v1.16b ;" 56 "0: mov v2.16b, v1.16b ;"
57 " ld1 {v3.2d}, [%[key]], #16 ;" 57 " ld1 {v3.16b}, [%[key]], #16 ;"
58 "1: aese v0.16b, v2.16b ;" 58 "1: aese v0.16b, v2.16b ;"
59 " aesmc v0.16b, v0.16b ;" 59 " aesmc v0.16b, v0.16b ;"
60 "2: ld1 {v1.2d}, [%[key]], #16 ;" 60 "2: ld1 {v1.16b}, [%[key]], #16 ;"
61 " aese v0.16b, v3.16b ;" 61 " aese v0.16b, v3.16b ;"
62 " aesmc v0.16b, v0.16b ;" 62 " aesmc v0.16b, v0.16b ;"
63 "3: ld1 {v2.2d}, [%[key]], #16 ;" 63 "3: ld1 {v2.16b}, [%[key]], #16 ;"
64 " subs %w[rounds], %w[rounds], #3 ;" 64 " subs %w[rounds], %w[rounds], #3 ;"
65 " aese v0.16b, v1.16b ;" 65 " aese v0.16b, v1.16b ;"
66 " aesmc v0.16b, v0.16b ;" 66 " aesmc v0.16b, v0.16b ;"
67 " ld1 {v3.2d}, [%[key]], #16 ;" 67 " ld1 {v3.16b}, [%[key]], #16 ;"
68 " bpl 1b ;" 68 " bpl 1b ;"
69 " aese v0.16b, v2.16b ;" 69 " aese v0.16b, v2.16b ;"
70 " eor v0.16b, v0.16b, v3.16b ;" 70 " eor v0.16b, v0.16b, v3.16b ;"
@@ -92,24 +92,24 @@ static void aes_cipher_decrypt(struct crypto_tfm *tfm, u8 dst[], u8 const src[])
92 kernel_neon_begin_partial(4); 92 kernel_neon_begin_partial(4);
93 93
94 __asm__(" ld1 {v0.16b}, %[in] ;" 94 __asm__(" ld1 {v0.16b}, %[in] ;"
95 " ld1 {v1.2d}, [%[key]], #16 ;" 95 " ld1 {v1.16b}, [%[key]], #16 ;"
96 " cmp %w[rounds], #10 ;" 96 " cmp %w[rounds], #10 ;"
97 " bmi 0f ;" 97 " bmi 0f ;"
98 " bne 3f ;" 98 " bne 3f ;"
99 " mov v3.16b, v1.16b ;" 99 " mov v3.16b, v1.16b ;"
100 " b 2f ;" 100 " b 2f ;"
101 "0: mov v2.16b, v1.16b ;" 101 "0: mov v2.16b, v1.16b ;"
102 " ld1 {v3.2d}, [%[key]], #16 ;" 102 " ld1 {v3.16b}, [%[key]], #16 ;"
103 "1: aesd v0.16b, v2.16b ;" 103 "1: aesd v0.16b, v2.16b ;"
104 " aesimc v0.16b, v0.16b ;" 104 " aesimc v0.16b, v0.16b ;"
105 "2: ld1 {v1.2d}, [%[key]], #16 ;" 105 "2: ld1 {v1.16b}, [%[key]], #16 ;"
106 " aesd v0.16b, v3.16b ;" 106 " aesd v0.16b, v3.16b ;"
107 " aesimc v0.16b, v0.16b ;" 107 " aesimc v0.16b, v0.16b ;"
108 "3: ld1 {v2.2d}, [%[key]], #16 ;" 108 "3: ld1 {v2.16b}, [%[key]], #16 ;"
109 " subs %w[rounds], %w[rounds], #3 ;" 109 " subs %w[rounds], %w[rounds], #3 ;"
110 " aesd v0.16b, v1.16b ;" 110 " aesd v0.16b, v1.16b ;"
111 " aesimc v0.16b, v0.16b ;" 111 " aesimc v0.16b, v0.16b ;"
112 " ld1 {v3.2d}, [%[key]], #16 ;" 112 " ld1 {v3.16b}, [%[key]], #16 ;"
113 " bpl 1b ;" 113 " bpl 1b ;"
114 " aesd v0.16b, v2.16b ;" 114 " aesd v0.16b, v2.16b ;"
115 " eor v0.16b, v0.16b, v3.16b ;" 115 " eor v0.16b, v0.16b, v3.16b ;"
@@ -173,7 +173,12 @@ int ce_aes_expandkey(struct crypto_aes_ctx *ctx, const u8 *in_key,
173 u32 *rki = ctx->key_enc + (i * kwords); 173 u32 *rki = ctx->key_enc + (i * kwords);
174 u32 *rko = rki + kwords; 174 u32 *rko = rki + kwords;
175 175
176#ifndef CONFIG_CPU_BIG_ENDIAN
176 rko[0] = ror32(aes_sub(rki[kwords - 1]), 8) ^ rcon[i] ^ rki[0]; 177 rko[0] = ror32(aes_sub(rki[kwords - 1]), 8) ^ rcon[i] ^ rki[0];
178#else
179 rko[0] = rol32(aes_sub(rki[kwords - 1]), 8) ^ (rcon[i] << 24) ^
180 rki[0];
181#endif
177 rko[1] = rko[0] ^ rki[1]; 182 rko[1] = rko[0] ^ rki[1];
178 rko[2] = rko[1] ^ rki[2]; 183 rko[2] = rko[1] ^ rki[2];
179 rko[3] = rko[2] ^ rki[3]; 184 rko[3] = rko[2] ^ rki[3];
diff --git a/arch/arm64/crypto/aes-ce.S b/arch/arm64/crypto/aes-ce.S
index 78f3cfe92c08..b46093d567e5 100644
--- a/arch/arm64/crypto/aes-ce.S
+++ b/arch/arm64/crypto/aes-ce.S
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/linkage.h> 12#include <linux/linkage.h>
13#include <asm/assembler.h>
13 14
14#define AES_ENTRY(func) ENTRY(ce_ ## func) 15#define AES_ENTRY(func) ENTRY(ce_ ## func)
15#define AES_ENDPROC(func) ENDPROC(ce_ ## func) 16#define AES_ENDPROC(func) ENDPROC(ce_ ## func)
diff --git a/arch/arm64/crypto/aes-modes.S b/arch/arm64/crypto/aes-modes.S
index f6e372c528eb..c53dbeae79f2 100644
--- a/arch/arm64/crypto/aes-modes.S
+++ b/arch/arm64/crypto/aes-modes.S
@@ -386,7 +386,8 @@ AES_ENDPROC(aes_ctr_encrypt)
386 .endm 386 .endm
387 387
388.Lxts_mul_x: 388.Lxts_mul_x:
389 .word 1, 0, 0x87, 0 389CPU_LE( .quad 1, 0x87 )
390CPU_BE( .quad 0x87, 1 )
390 391
391AES_ENTRY(aes_xts_encrypt) 392AES_ENTRY(aes_xts_encrypt)
392 FRAME_PUSH 393 FRAME_PUSH
diff --git a/arch/arm64/crypto/aes-neon.S b/arch/arm64/crypto/aes-neon.S
index b93170e1cc93..85f07ead7c5c 100644
--- a/arch/arm64/crypto/aes-neon.S
+++ b/arch/arm64/crypto/aes-neon.S
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/linkage.h> 11#include <linux/linkage.h>
12#include <asm/assembler.h>
12 13
13#define AES_ENTRY(func) ENTRY(neon_ ## func) 14#define AES_ENTRY(func) ENTRY(neon_ ## func)
14#define AES_ENDPROC(func) ENDPROC(neon_ ## func) 15#define AES_ENDPROC(func) ENDPROC(neon_ ## func)
@@ -83,13 +84,13 @@
83 .endm 84 .endm
84 85
85 .macro do_block, enc, in, rounds, rk, rkp, i 86 .macro do_block, enc, in, rounds, rk, rkp, i
86 ld1 {v15.16b}, [\rk] 87 ld1 {v15.4s}, [\rk]
87 add \rkp, \rk, #16 88 add \rkp, \rk, #16
88 mov \i, \rounds 89 mov \i, \rounds
891111: eor \in\().16b, \in\().16b, v15.16b /* ^round key */ 901111: eor \in\().16b, \in\().16b, v15.16b /* ^round key */
90 tbl \in\().16b, {\in\().16b}, v13.16b /* ShiftRows */ 91 tbl \in\().16b, {\in\().16b}, v13.16b /* ShiftRows */
91 sub_bytes \in 92 sub_bytes \in
92 ld1 {v15.16b}, [\rkp], #16 93 ld1 {v15.4s}, [\rkp], #16
93 subs \i, \i, #1 94 subs \i, \i, #1
94 beq 2222f 95 beq 2222f
95 .if \enc == 1 96 .if \enc == 1
@@ -229,7 +230,7 @@
229 .endm 230 .endm
230 231
231 .macro do_block_2x, enc, in0, in1 rounds, rk, rkp, i 232 .macro do_block_2x, enc, in0, in1 rounds, rk, rkp, i
232 ld1 {v15.16b}, [\rk] 233 ld1 {v15.4s}, [\rk]
233 add \rkp, \rk, #16 234 add \rkp, \rk, #16
234 mov \i, \rounds 235 mov \i, \rounds
2351111: eor \in0\().16b, \in0\().16b, v15.16b /* ^round key */ 2361111: eor \in0\().16b, \in0\().16b, v15.16b /* ^round key */
@@ -237,7 +238,7 @@
237 sub_bytes_2x \in0, \in1 238 sub_bytes_2x \in0, \in1
238 tbl \in0\().16b, {\in0\().16b}, v13.16b /* ShiftRows */ 239 tbl \in0\().16b, {\in0\().16b}, v13.16b /* ShiftRows */
239 tbl \in1\().16b, {\in1\().16b}, v13.16b /* ShiftRows */ 240 tbl \in1\().16b, {\in1\().16b}, v13.16b /* ShiftRows */
240 ld1 {v15.16b}, [\rkp], #16 241 ld1 {v15.4s}, [\rkp], #16
241 subs \i, \i, #1 242 subs \i, \i, #1
242 beq 2222f 243 beq 2222f
243 .if \enc == 1 244 .if \enc == 1
@@ -254,7 +255,7 @@
254 .endm 255 .endm
255 256
256 .macro do_block_4x, enc, in0, in1, in2, in3, rounds, rk, rkp, i 257 .macro do_block_4x, enc, in0, in1, in2, in3, rounds, rk, rkp, i
257 ld1 {v15.16b}, [\rk] 258 ld1 {v15.4s}, [\rk]
258 add \rkp, \rk, #16 259 add \rkp, \rk, #16
259 mov \i, \rounds 260 mov \i, \rounds
2601111: eor \in0\().16b, \in0\().16b, v15.16b /* ^round key */ 2611111: eor \in0\().16b, \in0\().16b, v15.16b /* ^round key */
@@ -266,7 +267,7 @@
266 tbl \in1\().16b, {\in1\().16b}, v13.16b /* ShiftRows */ 267 tbl \in1\().16b, {\in1\().16b}, v13.16b /* ShiftRows */
267 tbl \in2\().16b, {\in2\().16b}, v13.16b /* ShiftRows */ 268 tbl \in2\().16b, {\in2\().16b}, v13.16b /* ShiftRows */
268 tbl \in3\().16b, {\in3\().16b}, v13.16b /* ShiftRows */ 269 tbl \in3\().16b, {\in3\().16b}, v13.16b /* ShiftRows */
269 ld1 {v15.16b}, [\rkp], #16 270 ld1 {v15.4s}, [\rkp], #16
270 subs \i, \i, #1 271 subs \i, \i, #1
271 beq 2222f 272 beq 2222f
272 .if \enc == 1 273 .if \enc == 1
@@ -306,12 +307,16 @@
306 .text 307 .text
307 .align 4 308 .align 4
308.LForward_ShiftRows: 309.LForward_ShiftRows:
309 .byte 0x0, 0x5, 0xa, 0xf, 0x4, 0x9, 0xe, 0x3 310CPU_LE( .byte 0x0, 0x5, 0xa, 0xf, 0x4, 0x9, 0xe, 0x3 )
310 .byte 0x8, 0xd, 0x2, 0x7, 0xc, 0x1, 0x6, 0xb 311CPU_LE( .byte 0x8, 0xd, 0x2, 0x7, 0xc, 0x1, 0x6, 0xb )
312CPU_BE( .byte 0xb, 0x6, 0x1, 0xc, 0x7, 0x2, 0xd, 0x8 )
313CPU_BE( .byte 0x3, 0xe, 0x9, 0x4, 0xf, 0xa, 0x5, 0x0 )
311 314
312.LReverse_ShiftRows: 315.LReverse_ShiftRows:
313 .byte 0x0, 0xd, 0xa, 0x7, 0x4, 0x1, 0xe, 0xb 316CPU_LE( .byte 0x0, 0xd, 0xa, 0x7, 0x4, 0x1, 0xe, 0xb )
314 .byte 0x8, 0x5, 0x2, 0xf, 0xc, 0x9, 0x6, 0x3 317CPU_LE( .byte 0x8, 0x5, 0x2, 0xf, 0xc, 0x9, 0x6, 0x3 )
318CPU_BE( .byte 0x3, 0x6, 0x9, 0xc, 0xf, 0x2, 0x5, 0x8 )
319CPU_BE( .byte 0xb, 0xe, 0x1, 0x4, 0x7, 0xa, 0xd, 0x0 )
315 320
316.LForward_Sbox: 321.LForward_Sbox:
317 .byte 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5 322 .byte 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5
diff --git a/arch/arm64/crypto/ghash-ce-core.S b/arch/arm64/crypto/ghash-ce-core.S
index dc457015884e..f0bb9f0b524f 100644
--- a/arch/arm64/crypto/ghash-ce-core.S
+++ b/arch/arm64/crypto/ghash-ce-core.S
@@ -29,8 +29,8 @@
29 * struct ghash_key const *k, const char *head) 29 * struct ghash_key const *k, const char *head)
30 */ 30 */
31ENTRY(pmull_ghash_update) 31ENTRY(pmull_ghash_update)
32 ld1 {SHASH.16b}, [x3] 32 ld1 {SHASH.2d}, [x3]
33 ld1 {XL.16b}, [x1] 33 ld1 {XL.2d}, [x1]
34 movi MASK.16b, #0xe1 34 movi MASK.16b, #0xe1
35 ext SHASH2.16b, SHASH.16b, SHASH.16b, #8 35 ext SHASH2.16b, SHASH.16b, SHASH.16b, #8
36 shl MASK.2d, MASK.2d, #57 36 shl MASK.2d, MASK.2d, #57
@@ -74,6 +74,6 @@ CPU_LE( rev64 T1.16b, T1.16b )
74 74
75 cbnz w0, 0b 75 cbnz w0, 0b
76 76
77 st1 {XL.16b}, [x1] 77 st1 {XL.2d}, [x1]
78 ret 78 ret
79ENDPROC(pmull_ghash_update) 79ENDPROC(pmull_ghash_update)
diff --git a/arch/arm64/crypto/sha1-ce-core.S b/arch/arm64/crypto/sha1-ce-core.S
index 033aae6d732a..c98e7e849f06 100644
--- a/arch/arm64/crypto/sha1-ce-core.S
+++ b/arch/arm64/crypto/sha1-ce-core.S
@@ -78,7 +78,7 @@ ENTRY(sha1_ce_transform)
78 ld1r {k3.4s}, [x6] 78 ld1r {k3.4s}, [x6]
79 79
80 /* load state */ 80 /* load state */
81 ldr dga, [x0] 81 ld1 {dgav.4s}, [x0]
82 ldr dgb, [x0, #16] 82 ldr dgb, [x0, #16]
83 83
84 /* load sha1_ce_state::finalize */ 84 /* load sha1_ce_state::finalize */
@@ -144,7 +144,7 @@ CPU_LE( rev32 v11.16b, v11.16b )
144 b 1b 144 b 1b
145 145
146 /* store new state */ 146 /* store new state */
1473: str dga, [x0] 1473: st1 {dgav.4s}, [x0]
148 str dgb, [x0, #16] 148 str dgb, [x0, #16]
149 ret 149 ret
150ENDPROC(sha1_ce_transform) 150ENDPROC(sha1_ce_transform)
diff --git a/arch/arm64/crypto/sha2-ce-core.S b/arch/arm64/crypto/sha2-ce-core.S
index 5df9d9d470ad..01cfee066837 100644
--- a/arch/arm64/crypto/sha2-ce-core.S
+++ b/arch/arm64/crypto/sha2-ce-core.S
@@ -85,7 +85,7 @@ ENTRY(sha2_ce_transform)
85 ld1 {v12.4s-v15.4s}, [x8] 85 ld1 {v12.4s-v15.4s}, [x8]
86 86
87 /* load state */ 87 /* load state */
88 ldp dga, dgb, [x0] 88 ld1 {dgav.4s, dgbv.4s}, [x0]
89 89
90 /* load sha256_ce_state::finalize */ 90 /* load sha256_ce_state::finalize */
91 ldr w4, [x0, #:lo12:sha256_ce_offsetof_finalize] 91 ldr w4, [x0, #:lo12:sha256_ce_offsetof_finalize]
@@ -148,6 +148,6 @@ CPU_LE( rev32 v19.16b, v19.16b )
148 b 1b 148 b 1b
149 149
150 /* store new state */ 150 /* store new state */
1513: stp dga, dgb, [x0] 1513: st1 {dgav.4s, dgbv.4s}, [x0]
152 ret 152 ret
153ENDPROC(sha2_ce_transform) 153ENDPROC(sha2_ce_transform)
diff --git a/arch/cris/boot/rescue/Makefile b/arch/cris/boot/rescue/Makefile
index 52bd0bd1dd22..d98edbb30a18 100644
--- a/arch/cris/boot/rescue/Makefile
+++ b/arch/cris/boot/rescue/Makefile
@@ -10,6 +10,9 @@
10 10
11asflags-y += $(LINUXINCLUDE) 11asflags-y += $(LINUXINCLUDE)
12ccflags-y += -O2 $(LINUXINCLUDE) 12ccflags-y += -O2 $(LINUXINCLUDE)
13
14ifdef CONFIG_ETRAX_AXISFLASHMAP
15
13arch-$(CONFIG_ETRAX_ARCH_V10) = v10 16arch-$(CONFIG_ETRAX_ARCH_V10) = v10
14arch-$(CONFIG_ETRAX_ARCH_V32) = v32 17arch-$(CONFIG_ETRAX_ARCH_V32) = v32
15 18
@@ -28,6 +31,11 @@ $(obj)/rescue.bin: $(obj)/rescue.o FORCE
28 $(call if_changed,objcopy) 31 $(call if_changed,objcopy)
29 cp -p $(obj)/rescue.bin $(objtree) 32 cp -p $(obj)/rescue.bin $(objtree)
30 33
34else
35$(obj)/rescue.bin:
36
37endif
38
31$(obj)/testrescue.bin: $(obj)/testrescue.o 39$(obj)/testrescue.bin: $(obj)/testrescue.o
32 $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/testrescue.o tr.bin 40 $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/testrescue.o tr.bin
33# Pad it to 784 bytes 41# Pad it to 784 bytes
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index e86b7499921a..a017b23ee4aa 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -324,8 +324,8 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
324#endif 324#endif
325 325
326 /* Invalidate the icache for these ranges */ 326 /* Invalidate the icache for these ranges */
327 local_flush_icache_range((unsigned long)gebase, 327 flush_icache_range((unsigned long)gebase,
328 (unsigned long)gebase + ALIGN(size, PAGE_SIZE)); 328 (unsigned long)gebase + ALIGN(size, PAGE_SIZE));
329 329
330 /* 330 /*
331 * Allocate comm page for guest kernel, a TLB will be reserved for 331 * Allocate comm page for guest kernel, a TLB will be reserved for
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index ed3ab509faca..df4efa304b2c 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -313,7 +313,7 @@ _GLOBAL(flush_instruction_cache)
313 lis r3, KERNELBASE@h 313 lis r3, KERNELBASE@h
314 iccci 0,r3 314 iccci 0,r3
315#endif 315#endif
316#elif CONFIG_FSL_BOOKE 316#elif defined(CONFIG_FSL_BOOKE)
317BEGIN_FTR_SECTION 317BEGIN_FTR_SECTION
318 mfspr r3,SPRN_L1CSR0 318 mfspr r3,SPRN_L1CSR0
319 ori r3,r3,L1CSR0_CFI|L1CSR0_CLFC 319 ori r3,r3,L1CSR0_CFI|L1CSR0_CLFC
diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
index d750cc0dfe30..683a966b5b16 100644
--- a/arch/s390/crypto/prng.c
+++ b/arch/s390/crypto/prng.c
@@ -565,8 +565,10 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
565 prng_data->prngws.byte_counter += n; 565 prng_data->prngws.byte_counter += n;
566 prng_data->prngws.reseed_counter += n; 566 prng_data->prngws.reseed_counter += n;
567 567
568 if (copy_to_user(ubuf, prng_data->buf, chunk)) 568 if (copy_to_user(ubuf, prng_data->buf, chunk)) {
569 return -EFAULT; 569 ret = -EFAULT;
570 break;
571 }
570 572
571 nbytes -= chunk; 573 nbytes -= chunk;
572 ret += chunk; 574 ret += chunk;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 7429d481a311..b3c2ae7aa213 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2949,6 +2949,8 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
2949 memset(&events->reserved, 0, sizeof(events->reserved)); 2949 memset(&events->reserved, 0, sizeof(events->reserved));
2950} 2950}
2951 2951
2952static void kvm_set_hflags(struct kvm_vcpu *vcpu, unsigned emul_flags);
2953
2952static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, 2954static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
2953 struct kvm_vcpu_events *events) 2955 struct kvm_vcpu_events *events)
2954{ 2956{
@@ -2981,10 +2983,13 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
2981 vcpu->arch.apic->sipi_vector = events->sipi_vector; 2983 vcpu->arch.apic->sipi_vector = events->sipi_vector;
2982 2984
2983 if (events->flags & KVM_VCPUEVENT_VALID_SMM) { 2985 if (events->flags & KVM_VCPUEVENT_VALID_SMM) {
2986 u32 hflags = vcpu->arch.hflags;
2984 if (events->smi.smm) 2987 if (events->smi.smm)
2985 vcpu->arch.hflags |= HF_SMM_MASK; 2988 hflags |= HF_SMM_MASK;
2986 else 2989 else
2987 vcpu->arch.hflags &= ~HF_SMM_MASK; 2990 hflags &= ~HF_SMM_MASK;
2991 kvm_set_hflags(vcpu, hflags);
2992
2988 vcpu->arch.smi_pending = events->smi.pending; 2993 vcpu->arch.smi_pending = events->smi.pending;
2989 if (events->smi.smm_inside_nmi) 2994 if (events->smi.smm_inside_nmi)
2990 vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK; 2995 vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK;
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index 998fa6b23084..01ac5b1aeaeb 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -20,14 +20,22 @@ static inline void pm_runtime_early_init(struct device *dev)
20extern void pm_runtime_init(struct device *dev); 20extern void pm_runtime_init(struct device *dev);
21extern void pm_runtime_remove(struct device *dev); 21extern void pm_runtime_remove(struct device *dev);
22 22
23#define WAKE_IRQ_DEDICATED_ALLOCATED BIT(0)
24#define WAKE_IRQ_DEDICATED_MANAGED BIT(1)
25#define WAKE_IRQ_DEDICATED_MASK (WAKE_IRQ_DEDICATED_ALLOCATED | \
26 WAKE_IRQ_DEDICATED_MANAGED)
27
23struct wake_irq { 28struct wake_irq {
24 struct device *dev; 29 struct device *dev;
30 unsigned int status;
25 int irq; 31 int irq;
26 bool dedicated_irq:1;
27}; 32};
28 33
29extern void dev_pm_arm_wake_irq(struct wake_irq *wirq); 34extern void dev_pm_arm_wake_irq(struct wake_irq *wirq);
30extern void dev_pm_disarm_wake_irq(struct wake_irq *wirq); 35extern void dev_pm_disarm_wake_irq(struct wake_irq *wirq);
36extern void dev_pm_enable_wake_irq_check(struct device *dev,
37 bool can_change_status);
38extern void dev_pm_disable_wake_irq_check(struct device *dev);
31 39
32#ifdef CONFIG_PM_SLEEP 40#ifdef CONFIG_PM_SLEEP
33 41
@@ -102,6 +110,15 @@ static inline void dev_pm_disarm_wake_irq(struct wake_irq *wirq)
102{ 110{
103} 111}
104 112
113static inline void dev_pm_enable_wake_irq_check(struct device *dev,
114 bool can_change_status)
115{
116}
117
118static inline void dev_pm_disable_wake_irq_check(struct device *dev)
119{
120}
121
105#endif 122#endif
106 123
107#ifdef CONFIG_PM_SLEEP 124#ifdef CONFIG_PM_SLEEP
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 9796a1a15ef6..3252429f96af 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -515,7 +515,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
515 515
516 callback = RPM_GET_CALLBACK(dev, runtime_suspend); 516 callback = RPM_GET_CALLBACK(dev, runtime_suspend);
517 517
518 dev_pm_enable_wake_irq(dev); 518 dev_pm_enable_wake_irq_check(dev, true);
519 retval = rpm_callback(callback, dev); 519 retval = rpm_callback(callback, dev);
520 if (retval) 520 if (retval)
521 goto fail; 521 goto fail;
@@ -554,7 +554,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
554 return retval; 554 return retval;
555 555
556 fail: 556 fail:
557 dev_pm_disable_wake_irq(dev); 557 dev_pm_disable_wake_irq_check(dev);
558 __update_runtime_status(dev, RPM_ACTIVE); 558 __update_runtime_status(dev, RPM_ACTIVE);
559 dev->power.deferred_resume = false; 559 dev->power.deferred_resume = false;
560 wake_up_all(&dev->power.wait_queue); 560 wake_up_all(&dev->power.wait_queue);
@@ -737,12 +737,12 @@ static int rpm_resume(struct device *dev, int rpmflags)
737 737
738 callback = RPM_GET_CALLBACK(dev, runtime_resume); 738 callback = RPM_GET_CALLBACK(dev, runtime_resume);
739 739
740 dev_pm_disable_wake_irq(dev); 740 dev_pm_disable_wake_irq_check(dev);
741 retval = rpm_callback(callback, dev); 741 retval = rpm_callback(callback, dev);
742 if (retval) { 742 if (retval) {
743 __update_runtime_status(dev, RPM_SUSPENDED); 743 __update_runtime_status(dev, RPM_SUSPENDED);
744 pm_runtime_cancel_pending(dev); 744 pm_runtime_cancel_pending(dev);
745 dev_pm_enable_wake_irq(dev); 745 dev_pm_enable_wake_irq_check(dev, false);
746 } else { 746 } else {
747 no_callback: 747 no_callback:
748 __update_runtime_status(dev, RPM_ACTIVE); 748 __update_runtime_status(dev, RPM_ACTIVE);
diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
index 0d77cd6fd8d1..404d94c6c8bc 100644
--- a/drivers/base/power/wakeirq.c
+++ b/drivers/base/power/wakeirq.c
@@ -110,8 +110,10 @@ void dev_pm_clear_wake_irq(struct device *dev)
110 dev->power.wakeirq = NULL; 110 dev->power.wakeirq = NULL;
111 spin_unlock_irqrestore(&dev->power.lock, flags); 111 spin_unlock_irqrestore(&dev->power.lock, flags);
112 112
113 if (wirq->dedicated_irq) 113 if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED) {
114 free_irq(wirq->irq, wirq); 114 free_irq(wirq->irq, wirq);
115 wirq->status &= ~WAKE_IRQ_DEDICATED_MASK;
116 }
115 kfree(wirq); 117 kfree(wirq);
116} 118}
117EXPORT_SYMBOL_GPL(dev_pm_clear_wake_irq); 119EXPORT_SYMBOL_GPL(dev_pm_clear_wake_irq);
@@ -179,7 +181,6 @@ int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
179 181
180 wirq->dev = dev; 182 wirq->dev = dev;
181 wirq->irq = irq; 183 wirq->irq = irq;
182 wirq->dedicated_irq = true;
183 irq_set_status_flags(irq, IRQ_NOAUTOEN); 184 irq_set_status_flags(irq, IRQ_NOAUTOEN);
184 185
185 /* 186 /*
@@ -195,6 +196,8 @@ int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
195 if (err) 196 if (err)
196 goto err_free_irq; 197 goto err_free_irq;
197 198
199 wirq->status = WAKE_IRQ_DEDICATED_ALLOCATED;
200
198 return err; 201 return err;
199 202
200err_free_irq: 203err_free_irq:
@@ -210,9 +213,9 @@ EXPORT_SYMBOL_GPL(dev_pm_set_dedicated_wake_irq);
210 * dev_pm_enable_wake_irq - Enable device wake-up interrupt 213 * dev_pm_enable_wake_irq - Enable device wake-up interrupt
211 * @dev: Device 214 * @dev: Device
212 * 215 *
213 * Called from the bus code or the device driver for 216 * Optionally called from the bus code or the device driver for
214 * runtime_suspend() to enable the wake-up interrupt while 217 * runtime_resume() to override the PM runtime core managed wake-up
215 * the device is running. 218 * interrupt handling to enable the wake-up interrupt.
216 * 219 *
217 * Note that for runtime_suspend()) the wake-up interrupts 220 * Note that for runtime_suspend()) the wake-up interrupts
218 * should be unconditionally enabled unlike for suspend() 221 * should be unconditionally enabled unlike for suspend()
@@ -222,7 +225,7 @@ void dev_pm_enable_wake_irq(struct device *dev)
222{ 225{
223 struct wake_irq *wirq = dev->power.wakeirq; 226 struct wake_irq *wirq = dev->power.wakeirq;
224 227
225 if (wirq && wirq->dedicated_irq) 228 if (wirq && (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED))
226 enable_irq(wirq->irq); 229 enable_irq(wirq->irq);
227} 230}
228EXPORT_SYMBOL_GPL(dev_pm_enable_wake_irq); 231EXPORT_SYMBOL_GPL(dev_pm_enable_wake_irq);
@@ -231,20 +234,73 @@ EXPORT_SYMBOL_GPL(dev_pm_enable_wake_irq);
231 * dev_pm_disable_wake_irq - Disable device wake-up interrupt 234 * dev_pm_disable_wake_irq - Disable device wake-up interrupt
232 * @dev: Device 235 * @dev: Device
233 * 236 *
234 * Called from the bus code or the device driver for 237 * Optionally called from the bus code or the device driver for
235 * runtime_resume() to disable the wake-up interrupt while 238 * runtime_suspend() to override the PM runtime core managed wake-up
236 * the device is running. 239 * interrupt handling to disable the wake-up interrupt.
237 */ 240 */
238void dev_pm_disable_wake_irq(struct device *dev) 241void dev_pm_disable_wake_irq(struct device *dev)
239{ 242{
240 struct wake_irq *wirq = dev->power.wakeirq; 243 struct wake_irq *wirq = dev->power.wakeirq;
241 244
242 if (wirq && wirq->dedicated_irq) 245 if (wirq && (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED))
243 disable_irq_nosync(wirq->irq); 246 disable_irq_nosync(wirq->irq);
244} 247}
245EXPORT_SYMBOL_GPL(dev_pm_disable_wake_irq); 248EXPORT_SYMBOL_GPL(dev_pm_disable_wake_irq);
246 249
247/** 250/**
251 * dev_pm_enable_wake_irq_check - Checks and enables wake-up interrupt
252 * @dev: Device
253 * @can_change_status: Can change wake-up interrupt status
254 *
255 * Enables wakeirq conditionally. We need to enable wake-up interrupt
256 * lazily on the first rpm_suspend(). This is needed as the consumer device
257 * starts in RPM_SUSPENDED state, and the the first pm_runtime_get() would
258 * otherwise try to disable already disabled wakeirq. The wake-up interrupt
259 * starts disabled with IRQ_NOAUTOEN set.
260 *
261 * Should be only called from rpm_suspend() and rpm_resume() path.
262 * Caller must hold &dev->power.lock to change wirq->status
263 */
264void dev_pm_enable_wake_irq_check(struct device *dev,
265 bool can_change_status)
266{
267 struct wake_irq *wirq = dev->power.wakeirq;
268
269 if (!wirq || !((wirq->status & WAKE_IRQ_DEDICATED_MASK)))
270 return;
271
272 if (likely(wirq->status & WAKE_IRQ_DEDICATED_MANAGED)) {
273 goto enable;
274 } else if (can_change_status) {
275 wirq->status |= WAKE_IRQ_DEDICATED_MANAGED;
276 goto enable;
277 }
278
279 return;
280
281enable:
282 enable_irq(wirq->irq);
283}
284
285/**
286 * dev_pm_disable_wake_irq_check - Checks and disables wake-up interrupt
287 * @dev: Device
288 *
289 * Disables wake-up interrupt conditionally based on status.
290 * Should be only called from rpm_suspend() and rpm_resume() path.
291 */
292void dev_pm_disable_wake_irq_check(struct device *dev)
293{
294 struct wake_irq *wirq = dev->power.wakeirq;
295
296 if (!wirq || !((wirq->status & WAKE_IRQ_DEDICATED_MASK)))
297 return;
298
299 if (wirq->status & WAKE_IRQ_DEDICATED_MANAGED)
300 disable_irq_nosync(wirq->irq);
301}
302
303/**
248 * dev_pm_arm_wake_irq - Arm device wake-up 304 * dev_pm_arm_wake_irq - Arm device wake-up
249 * @wirq: Device wake-up interrupt 305 * @wirq: Device wake-up interrupt
250 * 306 *
diff --git a/drivers/clk/clk-wm831x.c b/drivers/clk/clk-wm831x.c
index 43f9d15255f4..763aed2de893 100644
--- a/drivers/clk/clk-wm831x.c
+++ b/drivers/clk/clk-wm831x.c
@@ -247,7 +247,7 @@ static int wm831x_clkout_is_prepared(struct clk_hw *hw)
247 if (ret < 0) { 247 if (ret < 0) {
248 dev_err(wm831x->dev, "Unable to read CLOCK_CONTROL_1: %d\n", 248 dev_err(wm831x->dev, "Unable to read CLOCK_CONTROL_1: %d\n",
249 ret); 249 ret);
250 return true; 250 return false;
251 } 251 }
252 252
253 return (ret & WM831X_CLKOUT_ENA) != 0; 253 return (ret & WM831X_CLKOUT_ENA) != 0;
diff --git a/drivers/clk/imx/clk-imx31.c b/drivers/clk/imx/clk-imx31.c
index 6a964144a5b5..6a49ba2b9671 100644
--- a/drivers/clk/imx/clk-imx31.c
+++ b/drivers/clk/imx/clk-imx31.c
@@ -157,10 +157,8 @@ static void __init _mx31_clocks_init(unsigned long fref)
157 } 157 }
158} 158}
159 159
160int __init mx31_clocks_init(void) 160int __init mx31_clocks_init(unsigned long fref)
161{ 161{
162 u32 fref = 26000000; /* default */
163
164 _mx31_clocks_init(fref); 162 _mx31_clocks_init(fref);
165 163
166 clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0"); 164 clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0");
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
index b5b9cb911111..04cec0da5d1e 100644
--- a/drivers/gpu/drm/radeon/radeon_cursor.c
+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
@@ -146,6 +146,9 @@ static int radeon_cursor_move_locked(struct drm_crtc *crtc, int x, int y)
146 int xorigin = 0, yorigin = 0; 146 int xorigin = 0, yorigin = 0;
147 int w = radeon_crtc->cursor_width; 147 int w = radeon_crtc->cursor_width;
148 148
149 radeon_crtc->cursor_x = x;
150 radeon_crtc->cursor_y = y;
151
149 if (ASIC_IS_AVIVO(rdev)) { 152 if (ASIC_IS_AVIVO(rdev)) {
150 /* avivo cursor are offset into the total surface */ 153 /* avivo cursor are offset into the total surface */
151 x += crtc->x; 154 x += crtc->x;
@@ -240,9 +243,6 @@ static int radeon_cursor_move_locked(struct drm_crtc *crtc, int x, int y)
240 yorigin * 256); 243 yorigin * 256);
241 } 244 }
242 245
243 radeon_crtc->cursor_x = x;
244 radeon_crtc->cursor_y = y;
245
246 if (radeon_crtc->cursor_out_of_bounds) { 246 if (radeon_crtc->cursor_out_of_bounds) {
247 radeon_crtc->cursor_out_of_bounds = false; 247 radeon_crtc->cursor_out_of_bounds = false;
248 if (radeon_crtc->cursor_bo) 248 if (radeon_crtc->cursor_bo)
diff --git a/drivers/hid/hid-cypress.c b/drivers/hid/hid-cypress.c
index 1b764d1745f3..1689568b597d 100644
--- a/drivers/hid/hid-cypress.c
+++ b/drivers/hid/hid-cypress.c
@@ -39,6 +39,9 @@ static __u8 *cp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
39 if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX)) 39 if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX))
40 return rdesc; 40 return rdesc;
41 41
42 if (*rsize < 4)
43 return rdesc;
44
42 for (i = 0; i < *rsize - 4; i++) 45 for (i = 0; i < *rsize - 4; i++)
43 if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) { 46 if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) {
44 rdesc[i] = 0x19; 47 rdesc[i] = 0x19;
diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c
index 12e851a5af48..46b4e35fd555 100644
--- a/drivers/hwmon/amc6821.c
+++ b/drivers/hwmon/amc6821.c
@@ -188,8 +188,8 @@ static struct amc6821_data *amc6821_update_device(struct device *dev)
188 !data->valid) { 188 !data->valid) {
189 189
190 for (i = 0; i < TEMP_IDX_LEN; i++) 190 for (i = 0; i < TEMP_IDX_LEN; i++)
191 data->temp[i] = i2c_smbus_read_byte_data(client, 191 data->temp[i] = (int8_t)i2c_smbus_read_byte_data(
192 temp_reg[i]); 192 client, temp_reg[i]);
193 193
194 data->stat1 = i2c_smbus_read_byte_data(client, 194 data->stat1 = i2c_smbus_read_byte_data(client,
195 AMC6821_REG_STAT1); 195 AMC6821_REG_STAT1);
diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
index edf550fc4eef..0043a4c02b85 100644
--- a/drivers/hwmon/ds620.c
+++ b/drivers/hwmon/ds620.c
@@ -166,7 +166,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
166 if (res) 166 if (res)
167 return res; 167 return res;
168 168
169 val = (val * 10 / 625) * 8; 169 val = (clamp_val(val, -128000, 128000) * 10 / 625) * 8;
170 170
171 mutex_lock(&data->update_lock); 171 mutex_lock(&data->update_lock);
172 data->temp[attr->index] = val; 172 data->temp[attr->index] = val;
diff --git a/drivers/hwmon/g762.c b/drivers/hwmon/g762.c
index b96a2a9e4df7..628be9c95ff9 100644
--- a/drivers/hwmon/g762.c
+++ b/drivers/hwmon/g762.c
@@ -193,14 +193,17 @@ static inline unsigned int rpm_from_cnt(u8 cnt, u32 clk_freq, u16 p,
193 * Convert fan RPM value from sysfs into count value for fan controller 193 * Convert fan RPM value from sysfs into count value for fan controller
194 * register (FAN_SET_CNT). 194 * register (FAN_SET_CNT).
195 */ 195 */
196static inline unsigned char cnt_from_rpm(u32 rpm, u32 clk_freq, u16 p, 196static inline unsigned char cnt_from_rpm(unsigned long rpm, u32 clk_freq, u16 p,
197 u8 clk_div, u8 gear_mult) 197 u8 clk_div, u8 gear_mult)
198{ 198{
199 if (!rpm) /* to stop the fan, set cnt to 255 */ 199 unsigned long f1 = clk_freq * 30 * gear_mult;
200 unsigned long f2 = p * clk_div;
201
202 if (!rpm) /* to stop the fan, set cnt to 255 */
200 return 0xff; 203 return 0xff;
201 204
202 return clamp_val(((clk_freq * 30 * gear_mult) / (rpm * p * clk_div)), 205 rpm = clamp_val(rpm, f1 / (255 * f2), ULONG_MAX / f2);
203 0, 255); 206 return DIV_ROUND_CLOSEST(f1, rpm * f2);
204} 207}
205 208
206/* helper to grab and cache data, at most one time per second */ 209/* helper to grab and cache data, at most one time per second */
diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c
index 3ce33d244cc0..12b94b094c0d 100644
--- a/drivers/hwmon/nct7802.c
+++ b/drivers/hwmon/nct7802.c
@@ -259,13 +259,15 @@ static int nct7802_read_fan_min(struct nct7802_data *data, u8 reg_fan_low,
259 ret = 0; 259 ret = 0;
260 else if (ret) 260 else if (ret)
261 ret = DIV_ROUND_CLOSEST(1350000U, ret); 261 ret = DIV_ROUND_CLOSEST(1350000U, ret);
262 else
263 ret = 1350000U;
262abort: 264abort:
263 mutex_unlock(&data->access_lock); 265 mutex_unlock(&data->access_lock);
264 return ret; 266 return ret;
265} 267}
266 268
267static int nct7802_write_fan_min(struct nct7802_data *data, u8 reg_fan_low, 269static int nct7802_write_fan_min(struct nct7802_data *data, u8 reg_fan_low,
268 u8 reg_fan_high, unsigned int limit) 270 u8 reg_fan_high, unsigned long limit)
269{ 271{
270 int err; 272 int err;
271 273
@@ -326,8 +328,8 @@ static int nct7802_write_voltage(struct nct7802_data *data, int nr, int index,
326 int shift = 8 - REG_VOLTAGE_LIMIT_MSB_SHIFT[index - 1][nr]; 328 int shift = 8 - REG_VOLTAGE_LIMIT_MSB_SHIFT[index - 1][nr];
327 int err; 329 int err;
328 330
331 voltage = clamp_val(voltage, 0, 0x3ff * nct7802_vmul[nr]);
329 voltage = DIV_ROUND_CLOSEST(voltage, nct7802_vmul[nr]); 332 voltage = DIV_ROUND_CLOSEST(voltage, nct7802_vmul[nr]);
330 voltage = clamp_val(voltage, 0, 0x3ff);
331 333
332 mutex_lock(&data->access_lock); 334 mutex_lock(&data->access_lock);
333 err = regmap_write(data->regmap, 335 err = regmap_write(data->regmap,
@@ -402,7 +404,7 @@ static ssize_t store_temp(struct device *dev, struct device_attribute *attr,
402 if (err < 0) 404 if (err < 0)
403 return err; 405 return err;
404 406
405 val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -128, 127); 407 val = DIV_ROUND_CLOSEST(clamp_val(val, -128000, 127000), 1000);
406 408
407 err = regmap_write(data->regmap, nr, val & 0xff); 409 err = regmap_write(data->regmap, nr, val & 0xff);
408 return err ? : count; 410 return err ? : count;
diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c
index 7e20567bc369..6827169c82d4 100644
--- a/drivers/hwmon/scpi-hwmon.c
+++ b/drivers/hwmon/scpi-hwmon.c
@@ -272,6 +272,7 @@ static const struct of_device_id scpi_of_match[] = {
272 {.compatible = "arm,scpi-sensors"}, 272 {.compatible = "arm,scpi-sensors"},
273 {}, 273 {},
274}; 274};
275MODULE_DEVICE_TABLE(of, scpi_of_match);
275 276
276static struct platform_driver scpi_hwmon_platdrv = { 277static struct platform_driver scpi_hwmon_platdrv = {
277 .driver = { 278 .driver = {
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 5975d76ce755..a0ef57483ebb 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -926,7 +926,7 @@ again:
926 next_tail = (tail + sizeof(*cmd)) % CMD_BUFFER_SIZE; 926 next_tail = (tail + sizeof(*cmd)) % CMD_BUFFER_SIZE;
927 left = (head - next_tail) % CMD_BUFFER_SIZE; 927 left = (head - next_tail) % CMD_BUFFER_SIZE;
928 928
929 if (left <= 2) { 929 if (left <= 0x20) {
930 struct iommu_cmd sync_cmd; 930 struct iommu_cmd sync_cmd;
931 volatile u64 sem = 0; 931 volatile u64 sem = 0;
932 int ret; 932 int ret;
diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index 7caf2fa237f2..4831eb910fc7 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -809,8 +809,10 @@ int amd_iommu_init_device(struct pci_dev *pdev, int pasids)
809 goto out_free_domain; 809 goto out_free_domain;
810 810
811 group = iommu_group_get(&pdev->dev); 811 group = iommu_group_get(&pdev->dev);
812 if (!group) 812 if (!group) {
813 ret = -EINVAL;
813 goto out_free_domain; 814 goto out_free_domain;
815 }
814 816
815 ret = iommu_attach_group(dev_state->domain, group); 817 ret = iommu_attach_group(dev_state->domain, group);
816 if (ret != 0) 818 if (ret != 0)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 59e9abd3345e..9413b0726237 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1993,6 +1993,25 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
1993 if (context_present(context)) 1993 if (context_present(context))
1994 goto out_unlock; 1994 goto out_unlock;
1995 1995
1996 /*
1997 * For kdump cases, old valid entries may be cached due to the
1998 * in-flight DMA and copied pgtable, but there is no unmapping
1999 * behaviour for them, thus we need an explicit cache flush for
2000 * the newly-mapped device. For kdump, at this point, the device
2001 * is supposed to finish reset at its driver probe stage, so no
2002 * in-flight DMA will exist, and we don't need to worry anymore
2003 * hereafter.
2004 */
2005 if (context_copied(context)) {
2006 u16 did_old = context_domain_id(context);
2007
2008 if (did_old >= 0 && did_old < cap_ndoms(iommu->cap))
2009 iommu->flush.flush_context(iommu, did_old,
2010 (((u16)bus) << 8) | devfn,
2011 DMA_CCMD_MASK_NOBIT,
2012 DMA_CCMD_DEVICE_INVL);
2013 }
2014
1996 pgd = domain->pgd; 2015 pgd = domain->pgd;
1997 2016
1998 context_clear_entry(context); 2017 context_clear_entry(context);
@@ -5020,6 +5039,25 @@ static void intel_iommu_remove_device(struct device *dev)
5020} 5039}
5021 5040
5022#ifdef CONFIG_INTEL_IOMMU_SVM 5041#ifdef CONFIG_INTEL_IOMMU_SVM
5042#define MAX_NR_PASID_BITS (20)
5043static inline unsigned long intel_iommu_get_pts(struct intel_iommu *iommu)
5044{
5045 /*
5046 * Convert ecap_pss to extend context entry pts encoding, also
5047 * respect the soft pasid_max value set by the iommu.
5048 * - number of PASID bits = ecap_pss + 1
5049 * - number of PASID table entries = 2^(pts + 5)
5050 * Therefore, pts = ecap_pss - 4
5051 * e.g. KBL ecap_pss = 0x13, PASID has 20 bits, pts = 15
5052 */
5053 if (ecap_pss(iommu->ecap) < 5)
5054 return 0;
5055
5056 /* pasid_max is encoded as actual number of entries not the bits */
5057 return find_first_bit((unsigned long *)&iommu->pasid_max,
5058 MAX_NR_PASID_BITS) - 5;
5059}
5060
5023int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev) 5061int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev)
5024{ 5062{
5025 struct device_domain_info *info; 5063 struct device_domain_info *info;
@@ -5052,7 +5090,9 @@ int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sd
5052 5090
5053 if (!(ctx_lo & CONTEXT_PASIDE)) { 5091 if (!(ctx_lo & CONTEXT_PASIDE)) {
5054 context[1].hi = (u64)virt_to_phys(iommu->pasid_state_table); 5092 context[1].hi = (u64)virt_to_phys(iommu->pasid_state_table);
5055 context[1].lo = (u64)virt_to_phys(iommu->pasid_table) | ecap_pss(iommu->ecap); 5093 context[1].lo = (u64)virt_to_phys(iommu->pasid_table) |
5094 intel_iommu_get_pts(iommu);
5095
5056 wmb(); 5096 wmb();
5057 /* CONTEXT_TT_MULTI_LEVEL and CONTEXT_TT_DEV_IOTLB are both 5097 /* CONTEXT_TT_MULTI_LEVEL and CONTEXT_TT_DEV_IOTLB are both
5058 * extended to permit requests-with-PASID if the PASIDE bit 5098 * extended to permit requests-with-PASID if the PASIDE bit
diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index 0fea985ef1dc..d7af88534971 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -216,6 +216,31 @@ static int bcm7038_l1_set_affinity(struct irq_data *d,
216 return 0; 216 return 0;
217} 217}
218 218
219static void bcm7038_l1_cpu_offline(struct irq_data *d)
220{
221 struct cpumask *mask = irq_data_get_affinity_mask(d);
222 int cpu = smp_processor_id();
223 cpumask_t new_affinity;
224
225 /* This CPU was not on the affinity mask */
226 if (!cpumask_test_cpu(cpu, mask))
227 return;
228
229 if (cpumask_weight(mask) > 1) {
230 /*
231 * Multiple CPU affinity, remove this CPU from the affinity
232 * mask
233 */
234 cpumask_copy(&new_affinity, mask);
235 cpumask_clear_cpu(cpu, &new_affinity);
236 } else {
237 /* Only CPU, put on the lowest online CPU */
238 cpumask_clear(&new_affinity);
239 cpumask_set_cpu(cpumask_first(cpu_online_mask), &new_affinity);
240 }
241 irq_set_affinity_locked(d, &new_affinity, false);
242}
243
219static int __init bcm7038_l1_init_one(struct device_node *dn, 244static int __init bcm7038_l1_init_one(struct device_node *dn,
220 unsigned int idx, 245 unsigned int idx,
221 struct bcm7038_l1_chip *intc) 246 struct bcm7038_l1_chip *intc)
@@ -267,6 +292,7 @@ static struct irq_chip bcm7038_l1_irq_chip = {
267 .irq_mask = bcm7038_l1_mask, 292 .irq_mask = bcm7038_l1_mask,
268 .irq_unmask = bcm7038_l1_unmask, 293 .irq_unmask = bcm7038_l1_unmask,
269 .irq_set_affinity = bcm7038_l1_set_affinity, 294 .irq_set_affinity = bcm7038_l1_set_affinity,
295 .irq_cpu_offline = bcm7038_l1_cpu_offline,
270}; 296};
271 297
272static int bcm7038_l1_map(struct irq_domain *d, unsigned int virq, 298static int bcm7038_l1_map(struct irq_domain *d, unsigned int virq,
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index 2a506fe0c8a4..74bf1a17ae7c 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -762,8 +762,10 @@ static int __init ser_gigaset_init(void)
762 driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, 762 driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
763 GIGASET_MODULENAME, GIGASET_DEVNAME, 763 GIGASET_MODULENAME, GIGASET_DEVNAME,
764 &ops, THIS_MODULE); 764 &ops, THIS_MODULE);
765 if (!driver) 765 if (!driver) {
766 rc = -ENOMEM;
766 goto error; 767 goto error;
768 }
767 769
768 rc = tty_register_ldisc(N_GIGASET_M101, &gigaset_ldisc); 770 rc = tty_register_ldisc(N_GIGASET_M101, &gigaset_ldisc);
769 if (rc != 0) { 771 if (rc != 0) {
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c1c7d4fb4b77..eff554a12fb4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6771,7 +6771,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
6771 /* need to ensure recovery thread has run */ 6771 /* need to ensure recovery thread has run */
6772 wait_event_interruptible_timeout(mddev->sb_wait, 6772 wait_event_interruptible_timeout(mddev->sb_wait,
6773 !test_bit(MD_RECOVERY_NEEDED, 6773 !test_bit(MD_RECOVERY_NEEDED,
6774 &mddev->flags), 6774 &mddev->recovery),
6775 msecs_to_jiffies(5000)); 6775 msecs_to_jiffies(5000));
6776 if (cmd == STOP_ARRAY || cmd == STOP_ARRAY_RO) { 6776 if (cmd == STOP_ARRAY || cmd == STOP_ARRAY_RO) {
6777 /* Need to flush page cache, and ensure no-one else opens 6777 /* Need to flush page cache, and ensure no-one else opens
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index c4307ad8594c..e543cbbf2ec4 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -2168,11 +2168,12 @@ static int dvb_register(struct cx23885_tsport *port)
2168 } 2168 }
2169 port->i2c_client_tuner = client_tuner; 2169 port->i2c_client_tuner = client_tuner;
2170 break; 2170 break;
2171 case CX23885_BOARD_HAUPPAUGE_HVR5525: 2171 case CX23885_BOARD_HAUPPAUGE_HVR5525: {
2172 switch (port->nr) {
2173 struct m88rs6000t_config m88rs6000t_config; 2172 struct m88rs6000t_config m88rs6000t_config;
2174 struct a8293_platform_data a8293_pdata = {}; 2173 struct a8293_platform_data a8293_pdata = {};
2175 2174
2175 switch (port->nr) {
2176
2176 /* port b - satellite */ 2177 /* port b - satellite */
2177 case 1: 2178 case 1:
2178 /* attach frontend */ 2179 /* attach frontend */
@@ -2267,6 +2268,7 @@ static int dvb_register(struct cx23885_tsport *port)
2267 break; 2268 break;
2268 } 2269 }
2269 break; 2270 break;
2271 }
2270 default: 2272 default:
2271 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " 2273 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
2272 " isn't supported yet\n", 2274 " isn't supported yet\n",
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index e59838231703..be74a25708b2 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -399,7 +399,7 @@ bool mei_cldev_enabled(struct mei_cl_device *cldev)
399EXPORT_SYMBOL_GPL(mei_cldev_enabled); 399EXPORT_SYMBOL_GPL(mei_cldev_enabled);
400 400
401/** 401/**
402 * mei_cldev_enable_device - enable me client device 402 * mei_cldev_enable - enable me client device
403 * create connection with me client 403 * create connection with me client
404 * 404 *
405 * @cldev: me client device 405 * @cldev: me client device
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index 7fc9174d4619..9a11aaa6e985 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -791,7 +791,7 @@ static int mmc_test_nonblock_transfer(struct mmc_test_card *test,
791 struct mmc_async_req *cur_areq = &test_areq[0].areq; 791 struct mmc_async_req *cur_areq = &test_areq[0].areq;
792 struct mmc_async_req *other_areq = &test_areq[1].areq; 792 struct mmc_async_req *other_areq = &test_areq[1].areq;
793 int i; 793 int i;
794 int ret; 794 int ret = RESULT_OK;
795 795
796 test_areq[0].test = test; 796 test_areq[0].test = test;
797 test_areq[1].test = test; 797 test_areq[1].test = test;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 6cf6d93d8831..ba115ec7aa92 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -432,6 +432,13 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
432 MLX5_SET(cmd_hca_cap, set_hca_cap, pkey_table_size, 432 MLX5_SET(cmd_hca_cap, set_hca_cap, pkey_table_size,
433 to_fw_pkey_sz(128)); 433 to_fw_pkey_sz(128));
434 434
435 /* Check log_max_qp from HCA caps to set in current profile */
436 if (MLX5_CAP_GEN_MAX(dev, log_max_qp) < profile[prof_sel].log_max_qp) {
437 mlx5_core_warn(dev, "log_max_qp value in current profile is %d, changing it to HCA capability limit (%d)\n",
438 profile[prof_sel].log_max_qp,
439 MLX5_CAP_GEN_MAX(dev, log_max_qp));
440 profile[prof_sel].log_max_qp = MLX5_CAP_GEN_MAX(dev, log_max_qp);
441 }
435 if (prof->mask & MLX5_PROF_MASK_QP_SIZE) 442 if (prof->mask & MLX5_PROF_MASK_QP_SIZE)
436 MLX5_SET(cmd_hca_cap, set_hca_cap, log_max_qp, 443 MLX5_SET(cmd_hca_cap, set_hca_cap, log_max_qp,
437 prof->log_max_qp); 444 prof->log_max_qp);
@@ -505,7 +512,6 @@ static int mlx5_irq_set_affinity_hint(struct mlx5_core_dev *mdev, int i)
505 struct mlx5_priv *priv = &mdev->priv; 512 struct mlx5_priv *priv = &mdev->priv;
506 struct msix_entry *msix = priv->msix_arr; 513 struct msix_entry *msix = priv->msix_arr;
507 int irq = msix[i + MLX5_EQ_VEC_COMP_BASE].vector; 514 int irq = msix[i + MLX5_EQ_VEC_COMP_BASE].vector;
508 int numa_node = priv->numa_node;
509 int err; 515 int err;
510 516
511 if (!zalloc_cpumask_var(&priv->irq_info[i].mask, GFP_KERNEL)) { 517 if (!zalloc_cpumask_var(&priv->irq_info[i].mask, GFP_KERNEL)) {
@@ -513,7 +519,7 @@ static int mlx5_irq_set_affinity_hint(struct mlx5_core_dev *mdev, int i)
513 return -ENOMEM; 519 return -ENOMEM;
514 } 520 }
515 521
516 cpumask_set_cpu(cpumask_local_spread(i, numa_node), 522 cpumask_set_cpu(cpumask_local_spread(i, priv->numa_node),
517 priv->irq_info[i].mask); 523 priv->irq_info[i].mask);
518 524
519 err = irq_set_affinity_hint(irq, priv->irq_info[i].mask); 525 err = irq_set_affinity_hint(irq, priv->irq_info[i].mask);
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c
index 50d5604833ed..e0993eba5df3 100644
--- a/drivers/net/ethernet/neterion/vxge/vxge-main.c
+++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c
@@ -2223,8 +2223,6 @@ static irqreturn_t vxge_isr_napi(int irq, void *dev_id)
2223 return IRQ_NONE; 2223 return IRQ_NONE;
2224} 2224}
2225 2225
2226#ifdef CONFIG_PCI_MSI
2227
2228static irqreturn_t vxge_tx_msix_handle(int irq, void *dev_id) 2226static irqreturn_t vxge_tx_msix_handle(int irq, void *dev_id)
2229{ 2227{
2230 struct vxge_fifo *fifo = (struct vxge_fifo *)dev_id; 2228 struct vxge_fifo *fifo = (struct vxge_fifo *)dev_id;
@@ -2442,16 +2440,13 @@ static void vxge_rem_msix_isr(struct vxgedev *vdev)
2442 if (vdev->config.intr_type == MSI_X) 2440 if (vdev->config.intr_type == MSI_X)
2443 pci_disable_msix(vdev->pdev); 2441 pci_disable_msix(vdev->pdev);
2444} 2442}
2445#endif
2446 2443
2447static void vxge_rem_isr(struct vxgedev *vdev) 2444static void vxge_rem_isr(struct vxgedev *vdev)
2448{ 2445{
2449#ifdef CONFIG_PCI_MSI 2446 if (IS_ENABLED(CONFIG_PCI_MSI) &&
2450 if (vdev->config.intr_type == MSI_X) { 2447 vdev->config.intr_type == MSI_X) {
2451 vxge_rem_msix_isr(vdev); 2448 vxge_rem_msix_isr(vdev);
2452 } else 2449 } else if (vdev->config.intr_type == INTA) {
2453#endif
2454 if (vdev->config.intr_type == INTA) {
2455 synchronize_irq(vdev->pdev->irq); 2450 synchronize_irq(vdev->pdev->irq);
2456 free_irq(vdev->pdev->irq, vdev); 2451 free_irq(vdev->pdev->irq, vdev);
2457 } 2452 }
@@ -2460,11 +2455,10 @@ static void vxge_rem_isr(struct vxgedev *vdev)
2460static int vxge_add_isr(struct vxgedev *vdev) 2455static int vxge_add_isr(struct vxgedev *vdev)
2461{ 2456{
2462 int ret = 0; 2457 int ret = 0;
2463#ifdef CONFIG_PCI_MSI
2464 int vp_idx = 0, intr_idx = 0, intr_cnt = 0, msix_idx = 0, irq_req = 0; 2458 int vp_idx = 0, intr_idx = 0, intr_cnt = 0, msix_idx = 0, irq_req = 0;
2465 int pci_fun = PCI_FUNC(vdev->pdev->devfn); 2459 int pci_fun = PCI_FUNC(vdev->pdev->devfn);
2466 2460
2467 if (vdev->config.intr_type == MSI_X) 2461 if (IS_ENABLED(CONFIG_PCI_MSI) && vdev->config.intr_type == MSI_X)
2468 ret = vxge_enable_msix(vdev); 2462 ret = vxge_enable_msix(vdev);
2469 2463
2470 if (ret) { 2464 if (ret) {
@@ -2475,7 +2469,7 @@ static int vxge_add_isr(struct vxgedev *vdev)
2475 vdev->config.intr_type = INTA; 2469 vdev->config.intr_type = INTA;
2476 } 2470 }
2477 2471
2478 if (vdev->config.intr_type == MSI_X) { 2472 if (IS_ENABLED(CONFIG_PCI_MSI) && vdev->config.intr_type == MSI_X) {
2479 for (intr_idx = 0; 2473 for (intr_idx = 0;
2480 intr_idx < (vdev->no_of_vpath * 2474 intr_idx < (vdev->no_of_vpath *
2481 VXGE_HW_VPATH_MSIX_ACTIVE); intr_idx++) { 2475 VXGE_HW_VPATH_MSIX_ACTIVE); intr_idx++) {
@@ -2576,9 +2570,8 @@ static int vxge_add_isr(struct vxgedev *vdev)
2576 vdev->vxge_entries[intr_cnt].in_use = 1; 2570 vdev->vxge_entries[intr_cnt].in_use = 1;
2577 vdev->vxge_entries[intr_cnt].arg = &vdev->vpaths[0]; 2571 vdev->vxge_entries[intr_cnt].arg = &vdev->vpaths[0];
2578 } 2572 }
2579INTA_MODE:
2580#endif
2581 2573
2574INTA_MODE:
2582 if (vdev->config.intr_type == INTA) { 2575 if (vdev->config.intr_type == INTA) {
2583 snprintf(vdev->desc[0], VXGE_INTR_STRLEN, 2576 snprintf(vdev->desc[0], VXGE_INTR_STRLEN,
2584 "%s:vxge:INTA", vdev->ndev->name); 2577 "%s:vxge:INTA", vdev->ndev->name);
@@ -3889,12 +3882,12 @@ static void vxge_device_config_init(struct vxge_hw_device_config *device_config,
3889 if (max_mac_vpath > VXGE_MAX_MAC_ADDR_COUNT) 3882 if (max_mac_vpath > VXGE_MAX_MAC_ADDR_COUNT)
3890 max_mac_vpath = VXGE_MAX_MAC_ADDR_COUNT; 3883 max_mac_vpath = VXGE_MAX_MAC_ADDR_COUNT;
3891 3884
3892#ifndef CONFIG_PCI_MSI 3885 if (!IS_ENABLED(CONFIG_PCI_MSI)) {
3893 vxge_debug_init(VXGE_ERR, 3886 vxge_debug_init(VXGE_ERR,
3894 "%s: This Kernel does not support " 3887 "%s: This Kernel does not support "
3895 "MSI-X. Defaulting to INTA", VXGE_DRIVER_NAME); 3888 "MSI-X. Defaulting to INTA", VXGE_DRIVER_NAME);
3896 *intr_type = INTA; 3889 *intr_type = INTA;
3897#endif 3890 }
3898 3891
3899 /* Configure whether MSI-X or IRQL. */ 3892 /* Configure whether MSI-X or IRQL. */
3900 switch (*intr_type) { 3893 switch (*intr_type) {
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a5b869eb4678..4b100ef4af9f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2939,12 +2939,6 @@ int stmmac_dvr_probe(struct device *device,
2939 spin_lock_init(&priv->lock); 2939 spin_lock_init(&priv->lock);
2940 spin_lock_init(&priv->tx_lock); 2940 spin_lock_init(&priv->tx_lock);
2941 2941
2942 ret = register_netdev(ndev);
2943 if (ret) {
2944 pr_err("%s: ERROR %i registering the device\n", __func__, ret);
2945 goto error_netdev_register;
2946 }
2947
2948 /* If a specific clk_csr value is passed from the platform 2942 /* If a specific clk_csr value is passed from the platform
2949 * this means that the CSR Clock Range selection cannot be 2943 * this means that the CSR Clock Range selection cannot be
2950 * changed at run-time and it is fixed. Viceversa the driver'll try to 2944 * changed at run-time and it is fixed. Viceversa the driver'll try to
@@ -2969,11 +2963,21 @@ int stmmac_dvr_probe(struct device *device,
2969 } 2963 }
2970 } 2964 }
2971 2965
2972 return 0; 2966 ret = register_netdev(ndev);
2967 if (ret) {
2968 netdev_err(priv->dev, "%s: ERROR %i registering the device\n",
2969 __func__, ret);
2970 goto error_netdev_register;
2971 }
2972
2973 return ret;
2973 2974
2974error_mdio_register:
2975 unregister_netdev(ndev);
2976error_netdev_register: 2975error_netdev_register:
2976 if (priv->pcs != STMMAC_PCS_RGMII &&
2977 priv->pcs != STMMAC_PCS_TBI &&
2978 priv->pcs != STMMAC_PCS_RTBI)
2979 stmmac_mdio_unregister(ndev);
2980error_mdio_register:
2977 netif_napi_del(&priv->napi); 2981 netif_napi_del(&priv->napi);
2978error_hw_init: 2982error_hw_init:
2979 clk_disable_unprepare(priv->pclk); 2983 clk_disable_unprepare(priv->pclk);
diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c
index 77d26fe286c0..d52ea3008946 100644
--- a/drivers/net/ethernet/ti/cpmac.c
+++ b/drivers/net/ethernet/ti/cpmac.c
@@ -549,7 +549,8 @@ fatal_error:
549 549
550static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev) 550static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
551{ 551{
552 int queue, len; 552 int queue;
553 unsigned int len;
553 struct cpmac_desc *desc; 554 struct cpmac_desc *desc;
554 struct cpmac_priv *priv = netdev_priv(dev); 555 struct cpmac_priv *priv = netdev_priv(dev);
555 556
@@ -559,7 +560,7 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
559 if (unlikely(skb_padto(skb, ETH_ZLEN))) 560 if (unlikely(skb_padto(skb, ETH_ZLEN)))
560 return NETDEV_TX_OK; 561 return NETDEV_TX_OK;
561 562
562 len = max(skb->len, ETH_ZLEN); 563 len = max_t(unsigned int, skb->len, ETH_ZLEN);
563 queue = skb_get_queue_mapping(skb); 564 queue = skb_get_queue_mapping(skb);
564 netif_stop_subqueue(dev, queue); 565 netif_stop_subqueue(dev, queue);
565 566
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 409b48e1e589..7a601d8c615e 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -40,6 +40,8 @@
40 40
41#include "hyperv_net.h" 41#include "hyperv_net.h"
42 42
43/* Restrict GSO size to account for NVGRE */
44#define NETVSC_GSO_MAX_SIZE 62768
43 45
44#define RING_SIZE_MIN 64 46#define RING_SIZE_MIN 64
45static int ring_size = 128; 47static int ring_size = 128;
@@ -852,6 +854,7 @@ static int netvsc_set_channels(struct net_device *net,
852 } 854 }
853 goto recover; 855 goto recover;
854 } 856 }
857 netif_set_gso_max_size(net, NETVSC_GSO_MAX_SIZE);
855 858
856 out: 859 out:
857 netvsc_open(net); 860 netvsc_open(net);
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 2fb637ad594a..32b7ec976dcc 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3446,39 +3446,87 @@ static bool delay_autosuspend(struct r8152 *tp)
3446 return false; 3446 return false;
3447} 3447}
3448 3448
3449static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message) 3449static int rtl8152_rumtime_suspend(struct r8152 *tp)
3450{ 3450{
3451 struct r8152 *tp = usb_get_intfdata(intf);
3452 struct net_device *netdev = tp->netdev; 3451 struct net_device *netdev = tp->netdev;
3453 int ret = 0; 3452 int ret = 0;
3454 3453
3455 mutex_lock(&tp->control); 3454 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
3455 u32 rcr = 0;
3456 3456
3457 if (PMSG_IS_AUTO(message)) { 3457 if (delay_autosuspend(tp)) {
3458 if (netif_running(netdev) && delay_autosuspend(tp)) {
3459 ret = -EBUSY; 3458 ret = -EBUSY;
3460 goto out1; 3459 goto out1;
3461 } 3460 }
3462 3461
3463 set_bit(SELECTIVE_SUSPEND, &tp->flags); 3462 if (netif_carrier_ok(netdev)) {
3464 } else { 3463 u32 ocp_data;
3465 netif_device_detach(netdev); 3464
3465 rcr = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
3466 ocp_data = rcr & ~RCR_ACPT_ALL;
3467 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
3468 rxdy_gated_en(tp, true);
3469 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA,
3470 PLA_OOB_CTRL);
3471 if (!(ocp_data & RXFIFO_EMPTY)) {
3472 rxdy_gated_en(tp, false);
3473 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr);
3474 ret = -EBUSY;
3475 goto out1;
3476 }
3477 }
3478
3479 clear_bit(WORK_ENABLE, &tp->flags);
3480 usb_kill_urb(tp->intr_urb);
3481
3482 rtl_runtime_suspend_enable(tp, true);
3483
3484 if (netif_carrier_ok(netdev)) {
3485 napi_disable(&tp->napi);
3486 rtl_stop_rx(tp);
3487 rxdy_gated_en(tp, false);
3488 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr);
3489 napi_enable(&tp->napi);
3490 }
3466 } 3491 }
3467 3492
3493 set_bit(SELECTIVE_SUSPEND, &tp->flags);
3494
3495out1:
3496 return ret;
3497}
3498
3499static int rtl8152_system_suspend(struct r8152 *tp)
3500{
3501 struct net_device *netdev = tp->netdev;
3502 int ret = 0;
3503
3504 netif_device_detach(netdev);
3505
3468 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { 3506 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
3469 clear_bit(WORK_ENABLE, &tp->flags); 3507 clear_bit(WORK_ENABLE, &tp->flags);
3470 usb_kill_urb(tp->intr_urb); 3508 usb_kill_urb(tp->intr_urb);
3471 napi_disable(&tp->napi); 3509 napi_disable(&tp->napi);
3472 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { 3510 cancel_delayed_work_sync(&tp->schedule);
3473 rtl_stop_rx(tp); 3511 tp->rtl_ops.down(tp);
3474 rtl_runtime_suspend_enable(tp, true);
3475 } else {
3476 cancel_delayed_work_sync(&tp->schedule);
3477 tp->rtl_ops.down(tp);
3478 }
3479 napi_enable(&tp->napi); 3512 napi_enable(&tp->napi);
3480 } 3513 }
3481out1: 3514
3515 return ret;
3516}
3517
3518static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
3519{
3520 struct r8152 *tp = usb_get_intfdata(intf);
3521 int ret;
3522
3523 mutex_lock(&tp->control);
3524
3525 if (PMSG_IS_AUTO(message))
3526 ret = rtl8152_rumtime_suspend(tp);
3527 else
3528 ret = rtl8152_system_suspend(tp);
3529
3482 mutex_unlock(&tp->control); 3530 mutex_unlock(&tp->control);
3483 3531
3484 return ret; 3532 return ret;
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 903bda437839..d6b619667f1a 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -301,7 +301,9 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
301 .flowi4_tos = RT_TOS(ip4h->tos), 301 .flowi4_tos = RT_TOS(ip4h->tos),
302 .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_L3MDEV_SRC | 302 .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_L3MDEV_SRC |
303 FLOWI_FLAG_SKIP_NH_OIF, 303 FLOWI_FLAG_SKIP_NH_OIF,
304 .flowi4_proto = ip4h->protocol,
304 .daddr = ip4h->daddr, 305 .daddr = ip4h->daddr,
306 .saddr = ip4h->saddr,
305 }; 307 };
306 308
307 if (vrf_send_v4_prep(skb, &fl4, vrf_dev)) 309 if (vrf_send_v4_prep(skb, &fl4, vrf_dev))
@@ -410,6 +412,8 @@ static int vrf_finish_output6(struct net *net, struct sock *sk,
410 struct in6_addr *nexthop; 412 struct in6_addr *nexthop;
411 int ret; 413 int ret;
412 414
415 nf_reset(skb);
416
413 skb->protocol = htons(ETH_P_IPV6); 417 skb->protocol = htons(ETH_P_IPV6);
414 skb->dev = dev; 418 skb->dev = dev;
415 419
@@ -521,6 +525,8 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
521 u32 nexthop; 525 u32 nexthop;
522 int ret = -EINVAL; 526 int ret = -EINVAL;
523 527
528 nf_reset(skb);
529
524 /* Be paranoid, rather than too clever. */ 530 /* Be paranoid, rather than too clever. */
525 if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) { 531 if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) {
526 struct sk_buff *skb2; 532 struct sk_buff *skb2;
@@ -919,6 +925,8 @@ static int vrf_newlink(struct net *src_net, struct net_device *dev,
919 return -EINVAL; 925 return -EINVAL;
920 926
921 vrf->tb_id = nla_get_u32(data[IFLA_VRF_TABLE]); 927 vrf->tb_id = nla_get_u32(data[IFLA_VRF_TABLE]);
928 if (vrf->tb_id == RT_TABLE_UNSPEC)
929 return -EINVAL;
922 930
923 dev->priv_flags |= IFF_L3MDEV_MASTER; 931 dev->priv_flags |= IFF_L3MDEV_MASTER;
924 932
diff --git a/drivers/net/wireless/ath/ath10k/spectral.c b/drivers/net/wireless/ath/ath10k/spectral.c
index 4671cfbcd8f7..a0e7eebc206a 100644
--- a/drivers/net/wireless/ath/ath10k/spectral.c
+++ b/drivers/net/wireless/ath/ath10k/spectral.c
@@ -338,7 +338,7 @@ static ssize_t write_file_spec_scan_ctl(struct file *file,
338 } else { 338 } else {
339 res = -EINVAL; 339 res = -EINVAL;
340 } 340 }
341 } else if (strncmp("background", buf, 9) == 0) { 341 } else if (strncmp("background", buf, 10) == 0) {
342 res = ath10k_spectral_scan_config(ar, SPECTRAL_BACKGROUND); 342 res = ath10k_spectral_scan_config(ar, SPECTRAL_BACKGROUND);
343 } else if (strncmp("manual", buf, 6) == 0) { 343 } else if (strncmp("manual", buf, 6) == 0) {
344 res = ath10k_spectral_scan_config(ar, SPECTRAL_MANUAL); 344 res = ath10k_spectral_scan_config(ar, SPECTRAL_MANUAL);
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index e12bafdc42e0..f2fcbe944d94 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -258,8 +258,13 @@ static int dlpar_add_phb(char *drc_name, struct device_node *dn)
258 258
259static int dlpar_add_vio_slot(char *drc_name, struct device_node *dn) 259static int dlpar_add_vio_slot(char *drc_name, struct device_node *dn)
260{ 260{
261 if (vio_find_node(dn)) 261 struct vio_dev *vio_dev;
262
263 vio_dev = vio_find_node(dn);
264 if (vio_dev) {
265 put_device(&vio_dev->dev);
262 return -EINVAL; 266 return -EINVAL;
267 }
263 268
264 if (!vio_register_device_node(dn)) { 269 if (!vio_register_device_node(dn)) {
265 printk(KERN_ERR 270 printk(KERN_ERR
@@ -335,6 +340,9 @@ static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn)
335 return -EINVAL; 340 return -EINVAL;
336 341
337 vio_unregister_device(vio_dev); 342 vio_unregister_device(vio_dev);
343
344 put_device(&vio_dev->dev);
345
338 return 0; 346 return 0;
339} 347}
340 348
diff --git a/drivers/scsi/mvsas/mv_94xx.c b/drivers/scsi/mvsas/mv_94xx.c
index 9270d15ff1a4..7353ac8d0d39 100644
--- a/drivers/scsi/mvsas/mv_94xx.c
+++ b/drivers/scsi/mvsas/mv_94xx.c
@@ -621,7 +621,7 @@ static void mvs_94xx_command_active(struct mvs_info *mvi, u32 slot_idx)
621{ 621{
622 u32 tmp; 622 u32 tmp;
623 tmp = mvs_cr32(mvi, MVS_COMMAND_ACTIVE+(slot_idx >> 3)); 623 tmp = mvs_cr32(mvi, MVS_COMMAND_ACTIVE+(slot_idx >> 3));
624 if (tmp && 1 << (slot_idx % 32)) { 624 if (tmp & 1 << (slot_idx % 32)) {
625 mv_printk("command active %08X, slot [%x].\n", tmp, slot_idx); 625 mv_printk("command active %08X, slot [%x].\n", tmp, slot_idx);
626 mvs_cw32(mvi, MVS_COMMAND_ACTIVE + (slot_idx >> 3), 626 mvs_cw32(mvi, MVS_COMMAND_ACTIVE + (slot_idx >> 3),
627 1 << (slot_idx % 32)); 627 1 << (slot_idx % 32));
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index a87cfd4ba17b..61a86d391599 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -127,37 +127,62 @@ static int orion_spi_baudrate_set(struct spi_device *spi, unsigned int speed)
127 tclk_hz = clk_get_rate(orion_spi->clk); 127 tclk_hz = clk_get_rate(orion_spi->clk);
128 128
129 if (devdata->typ == ARMADA_SPI) { 129 if (devdata->typ == ARMADA_SPI) {
130 unsigned int clk, spr, sppr, sppr2, err; 130 /*
131 unsigned int best_spr, best_sppr, best_err; 131 * Given the core_clk (tclk_hz) and the target rate (speed) we
132 132 * determine the best values for SPR (in [0 .. 15]) and SPPR (in
133 best_err = speed; 133 * [0..7]) such that
134 best_spr = 0; 134 *
135 best_sppr = 0; 135 * core_clk / (SPR * 2 ** SPPR)
136 136 *
137 /* Iterate over the valid range looking for best fit */ 137 * is as big as possible but not bigger than speed.
138 for (sppr = 0; sppr < 8; sppr++) { 138 */
139 sppr2 = 0x1 << sppr;
140
141 spr = tclk_hz / sppr2;
142 spr = DIV_ROUND_UP(spr, speed);
143 if ((spr == 0) || (spr > 15))
144 continue;
145
146 clk = tclk_hz / (spr * sppr2);
147 err = speed - clk;
148
149 if (err < best_err) {
150 best_spr = spr;
151 best_sppr = sppr;
152 best_err = err;
153 }
154 }
155 139
156 if ((best_sppr == 0) && (best_spr == 0)) 140 /* best integer divider: */
157 return -EINVAL; 141 unsigned divider = DIV_ROUND_UP(tclk_hz, speed);
142 unsigned spr, sppr;
143
144 if (divider < 16) {
145 /* This is the easy case, divider is less than 16 */
146 spr = divider;
147 sppr = 0;
148
149 } else {
150 unsigned two_pow_sppr;
151 /*
152 * Find the highest bit set in divider. This and the
153 * three next bits define SPR (apart from rounding).
154 * SPPR is then the number of zero bits that must be
155 * appended:
156 */
157 sppr = fls(divider) - 4;
158
159 /*
160 * As SPR only has 4 bits, we have to round divider up
161 * to the next multiple of 2 ** sppr.
162 */
163 two_pow_sppr = 1 << sppr;
164 divider = (divider + two_pow_sppr - 1) & -two_pow_sppr;
165
166 /*
167 * recalculate sppr as rounding up divider might have
168 * increased it enough to change the position of the
169 * highest set bit. In this case the bit that now
170 * doesn't make it into SPR is 0, so there is no need to
171 * round again.
172 */
173 sppr = fls(divider) - 4;
174 spr = divider >> sppr;
175
176 /*
177 * Now do range checking. SPR is constructed to have a
178 * width of 4 bits, so this is fine for sure. So we
179 * still need to check for sppr to fit into 3 bits:
180 */
181 if (sppr > 7)
182 return -EINVAL;
183 }
158 184
159 prescale = ((best_sppr & 0x6) << 5) | 185 prescale = ((sppr & 0x6) << 5) | ((sppr & 0x1) << 4) | spr;
160 ((best_sppr & 0x1) << 4) | best_spr;
161 } else { 186 } else {
162 /* 187 /*
163 * the supported rates are: 4,6,8...30 188 * the supported rates are: 4,6,8...30
diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c
index 5a536a00066f..b63472de761a 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -69,48 +69,49 @@
69 * Register map 69 * Register map
70 */ 70 */
71#define DT2821_ADCSR_REG 0x00 71#define DT2821_ADCSR_REG 0x00
72#define DT2821_ADCSR_ADERR (1 << 15) 72#define DT2821_ADCSR_ADERR BIT(15)
73#define DT2821_ADCSR_ADCLK (1 << 9) 73#define DT2821_ADCSR_ADCLK BIT(9)
74#define DT2821_ADCSR_MUXBUSY (1 << 8) 74#define DT2821_ADCSR_MUXBUSY BIT(8)
75#define DT2821_ADCSR_ADDONE (1 << 7) 75#define DT2821_ADCSR_ADDONE BIT(7)
76#define DT2821_ADCSR_IADDONE (1 << 6) 76#define DT2821_ADCSR_IADDONE BIT(6)
77#define DT2821_ADCSR_GS(x) (((x) & 0x3) << 4) 77#define DT2821_ADCSR_GS(x) (((x) & 0x3) << 4)
78#define DT2821_ADCSR_CHAN(x) (((x) & 0xf) << 0) 78#define DT2821_ADCSR_CHAN(x) (((x) & 0xf) << 0)
79#define DT2821_CHANCSR_REG 0x02 79#define DT2821_CHANCSR_REG 0x02
80#define DT2821_CHANCSR_LLE (1 << 15) 80#define DT2821_CHANCSR_LLE BIT(15)
81#define DT2821_CHANCSR_PRESLA(x) (((x) & 0xf) >> 8) 81#define DT2821_CHANCSR_TO_PRESLA(x) (((x) >> 8) & 0xf)
82#define DT2821_CHANCSR_NUMB(x) ((((x) - 1) & 0xf) << 0) 82#define DT2821_CHANCSR_NUMB(x) ((((x) - 1) & 0xf) << 0)
83#define DT2821_ADDAT_REG 0x04 83#define DT2821_ADDAT_REG 0x04
84#define DT2821_DACSR_REG 0x06 84#define DT2821_DACSR_REG 0x06
85#define DT2821_DACSR_DAERR (1 << 15) 85#define DT2821_DACSR_DAERR BIT(15)
86#define DT2821_DACSR_YSEL(x) ((x) << 9) 86#define DT2821_DACSR_YSEL(x) ((x) << 9)
87#define DT2821_DACSR_SSEL (1 << 8) 87#define DT2821_DACSR_SSEL BIT(8)
88#define DT2821_DACSR_DACRDY (1 << 7) 88#define DT2821_DACSR_DACRDY BIT(7)
89#define DT2821_DACSR_IDARDY (1 << 6) 89#define DT2821_DACSR_IDARDY BIT(6)
90#define DT2821_DACSR_DACLK (1 << 5) 90#define DT2821_DACSR_DACLK BIT(5)
91#define DT2821_DACSR_HBOE (1 << 1) 91#define DT2821_DACSR_HBOE BIT(1)
92#define DT2821_DACSR_LBOE (1 << 0) 92#define DT2821_DACSR_LBOE BIT(0)
93#define DT2821_DADAT_REG 0x08 93#define DT2821_DADAT_REG 0x08
94#define DT2821_DIODAT_REG 0x0a 94#define DT2821_DIODAT_REG 0x0a
95#define DT2821_SUPCSR_REG 0x0c 95#define DT2821_SUPCSR_REG 0x0c
96#define DT2821_SUPCSR_DMAD (1 << 15) 96#define DT2821_SUPCSR_DMAD BIT(15)
97#define DT2821_SUPCSR_ERRINTEN (1 << 14) 97#define DT2821_SUPCSR_ERRINTEN BIT(14)
98#define DT2821_SUPCSR_CLRDMADNE (1 << 13) 98#define DT2821_SUPCSR_CLRDMADNE BIT(13)
99#define DT2821_SUPCSR_DDMA (1 << 12) 99#define DT2821_SUPCSR_DDMA BIT(12)
100#define DT2821_SUPCSR_DS_PIO (0 << 10) 100#define DT2821_SUPCSR_DS(x) (((x) & 0x3) << 10)
101#define DT2821_SUPCSR_DS_AD_CLK (1 << 10) 101#define DT2821_SUPCSR_DS_PIO DT2821_SUPCSR_DS(0)
102#define DT2821_SUPCSR_DS_DA_CLK (2 << 10) 102#define DT2821_SUPCSR_DS_AD_CLK DT2821_SUPCSR_DS(1)
103#define DT2821_SUPCSR_DS_AD_TRIG (3 << 10) 103#define DT2821_SUPCSR_DS_DA_CLK DT2821_SUPCSR_DS(2)
104#define DT2821_SUPCSR_BUFFB (1 << 9) 104#define DT2821_SUPCSR_DS_AD_TRIG DT2821_SUPCSR_DS(3)
105#define DT2821_SUPCSR_SCDN (1 << 8) 105#define DT2821_SUPCSR_BUFFB BIT(9)
106#define DT2821_SUPCSR_DACON (1 << 7) 106#define DT2821_SUPCSR_SCDN BIT(8)
107#define DT2821_SUPCSR_ADCINIT (1 << 6) 107#define DT2821_SUPCSR_DACON BIT(7)
108#define DT2821_SUPCSR_DACINIT (1 << 5) 108#define DT2821_SUPCSR_ADCINIT BIT(6)
109#define DT2821_SUPCSR_PRLD (1 << 4) 109#define DT2821_SUPCSR_DACINIT BIT(5)
110#define DT2821_SUPCSR_STRIG (1 << 3) 110#define DT2821_SUPCSR_PRLD BIT(4)
111#define DT2821_SUPCSR_XTRIG (1 << 2) 111#define DT2821_SUPCSR_STRIG BIT(3)
112#define DT2821_SUPCSR_XCLK (1 << 1) 112#define DT2821_SUPCSR_XTRIG BIT(2)
113#define DT2821_SUPCSR_BDINIT (1 << 0) 113#define DT2821_SUPCSR_XCLK BIT(1)
114#define DT2821_SUPCSR_BDINIT BIT(0)
114#define DT2821_TMRCTR_REG 0x0e 115#define DT2821_TMRCTR_REG 0x0e
115 116
116static const struct comedi_lrange range_dt282x_ai_lo_bipolar = { 117static const struct comedi_lrange range_dt282x_ai_lo_bipolar = {
diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
index 5796ed2409d0..39bbbaaff07c 100644
--- a/drivers/staging/iio/adc/ad7606_core.c
+++ b/drivers/staging/iio/adc/ad7606_core.c
@@ -189,7 +189,7 @@ static ssize_t ad7606_store_oversampling_ratio(struct device *dev,
189 mutex_lock(&indio_dev->mlock); 189 mutex_lock(&indio_dev->mlock);
190 gpio_set_value(st->pdata->gpio_os0, (ret >> 0) & 1); 190 gpio_set_value(st->pdata->gpio_os0, (ret >> 0) & 1);
191 gpio_set_value(st->pdata->gpio_os1, (ret >> 1) & 1); 191 gpio_set_value(st->pdata->gpio_os1, (ret >> 1) & 1);
192 gpio_set_value(st->pdata->gpio_os1, (ret >> 2) & 1); 192 gpio_set_value(st->pdata->gpio_os2, (ret >> 2) & 1);
193 st->oversampling = lval; 193 st->oversampling = lval;
194 mutex_unlock(&indio_dev->mlock); 194 mutex_unlock(&indio_dev->mlock);
195 195
diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
index 23c95cd14167..68261b7dcefe 100644
--- a/drivers/target/iscsi/iscsi_target_tpg.c
+++ b/drivers/target/iscsi/iscsi_target_tpg.c
@@ -260,7 +260,6 @@ err_out:
260 iscsi_release_param_list(tpg->param_list); 260 iscsi_release_param_list(tpg->param_list);
261 tpg->param_list = NULL; 261 tpg->param_list = NULL;
262 } 262 }
263 kfree(tpg);
264 return -ENOMEM; 263 return -ENOMEM;
265} 264}
266 265
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index ff44cfa26af8..ac30a051ad71 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -205,6 +205,16 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
205 if (ifp->desc.bNumEndpoints >= num_ep) 205 if (ifp->desc.bNumEndpoints >= num_ep)
206 goto skip_to_next_endpoint_or_interface_descriptor; 206 goto skip_to_next_endpoint_or_interface_descriptor;
207 207
208 /* Check for duplicate endpoint addresses */
209 for (i = 0; i < ifp->desc.bNumEndpoints; ++i) {
210 if (ifp->endpoint[i].desc.bEndpointAddress ==
211 d->bEndpointAddress) {
212 dev_warn(ddev, "config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n",
213 cfgno, inum, asnum, d->bEndpointAddress);
214 goto skip_to_next_endpoint_or_interface_descriptor;
215 }
216 }
217
208 endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; 218 endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints];
209 ++ifp->desc.bNumEndpoints; 219 ++ifp->desc.bNumEndpoints;
210 220
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 45fbf37b346e..2f1c4b22ae1c 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -101,8 +101,7 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem);
101 101
102static void hub_release(struct kref *kref); 102static void hub_release(struct kref *kref);
103static int usb_reset_and_verify_device(struct usb_device *udev); 103static int usb_reset_and_verify_device(struct usb_device *udev);
104static void hub_usb3_port_prepare_disable(struct usb_hub *hub, 104static int hub_port_disable(struct usb_hub *hub, int port1, int set_state);
105 struct usb_port *port_dev);
106 105
107static inline char *portspeed(struct usb_hub *hub, int portstatus) 106static inline char *portspeed(struct usb_hub *hub, int portstatus)
108{ 107{
@@ -885,34 +884,6 @@ static int hub_set_port_link_state(struct usb_hub *hub, int port1,
885} 884}
886 885
887/* 886/*
888 * USB-3 does not have a similar link state as USB-2 that will avoid negotiating
889 * a connection with a plugged-in cable but will signal the host when the cable
890 * is unplugged. Disable remote wake and set link state to U3 for USB-3 devices
891 */
892static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
893{
894 struct usb_port *port_dev = hub->ports[port1 - 1];
895 struct usb_device *hdev = hub->hdev;
896 int ret = 0;
897
898 if (!hub->error) {
899 if (hub_is_superspeed(hub->hdev)) {
900 hub_usb3_port_prepare_disable(hub, port_dev);
901 ret = hub_set_port_link_state(hub, port_dev->portnum,
902 USB_SS_PORT_LS_U3);
903 } else {
904 ret = usb_clear_port_feature(hdev, port1,
905 USB_PORT_FEAT_ENABLE);
906 }
907 }
908 if (port_dev->child && set_state)
909 usb_set_device_state(port_dev->child, USB_STATE_NOTATTACHED);
910 if (ret && ret != -ENODEV)
911 dev_err(&port_dev->dev, "cannot disable (err = %d)\n", ret);
912 return ret;
913}
914
915/*
916 * Disable a port and mark a logical connect-change event, so that some 887 * Disable a port and mark a logical connect-change event, so that some
917 * time later hub_wq will disconnect() any existing usb_device on the port 888 * time later hub_wq will disconnect() any existing usb_device on the port
918 * and will re-enumerate if there actually is a device attached. 889 * and will re-enumerate if there actually is a device attached.
@@ -4093,6 +4064,34 @@ static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port,
4093 4064
4094#endif /* CONFIG_PM */ 4065#endif /* CONFIG_PM */
4095 4066
4067/*
4068 * USB-3 does not have a similar link state as USB-2 that will avoid negotiating
4069 * a connection with a plugged-in cable but will signal the host when the cable
4070 * is unplugged. Disable remote wake and set link state to U3 for USB-3 devices
4071 */
4072static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
4073{
4074 struct usb_port *port_dev = hub->ports[port1 - 1];
4075 struct usb_device *hdev = hub->hdev;
4076 int ret = 0;
4077
4078 if (!hub->error) {
4079 if (hub_is_superspeed(hub->hdev)) {
4080 hub_usb3_port_prepare_disable(hub, port_dev);
4081 ret = hub_set_port_link_state(hub, port_dev->portnum,
4082 USB_SS_PORT_LS_U3);
4083 } else {
4084 ret = usb_clear_port_feature(hdev, port1,
4085 USB_PORT_FEAT_ENABLE);
4086 }
4087 }
4088 if (port_dev->child && set_state)
4089 usb_set_device_state(port_dev->child, USB_STATE_NOTATTACHED);
4090 if (ret && ret != -ENODEV)
4091 dev_err(&port_dev->dev, "cannot disable (err = %d)\n", ret);
4092 return ret;
4093}
4094
4096 4095
4097/* USB 2.0 spec, 7.1.7.3 / fig 7-29: 4096/* USB 2.0 spec, 7.1.7.3 / fig 7-29:
4098 * 4097 *
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 723db02a9b7c..40d45b3a8754 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -45,9 +45,7 @@
45#define DWC3_XHCI_RESOURCES_NUM 2 45#define DWC3_XHCI_RESOURCES_NUM 2
46 46
47#define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */ 47#define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */
48#define DWC3_EVENT_SIZE 4 /* bytes */ 48#define DWC3_EVENT_BUFFERS_SIZE 4096
49#define DWC3_EVENT_MAX_NUM 64 /* 2 events/endpoint */
50#define DWC3_EVENT_BUFFERS_SIZE (DWC3_EVENT_SIZE * DWC3_EVENT_MAX_NUM)
51#define DWC3_EVENT_TYPE_MASK 0xfe 49#define DWC3_EVENT_TYPE_MASK 0xfe
52 50
53#define DWC3_EVENT_TYPE_DEV 0 51#define DWC3_EVENT_TYPE_DEV 0
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 3d731d1b5c60..d2c0c1a8d979 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -37,6 +37,7 @@
37#define PCI_DEVICE_ID_INTEL_BXT 0x0aaa 37#define PCI_DEVICE_ID_INTEL_BXT 0x0aaa
38#define PCI_DEVICE_ID_INTEL_APL 0x5aaa 38#define PCI_DEVICE_ID_INTEL_APL 0x5aaa
39#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 39#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0
40#define PCI_DEVICE_ID_INTEL_GLK 0x31aa
40 41
41static const struct acpi_gpio_params reset_gpios = { 0, 0, false }; 42static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
42static const struct acpi_gpio_params cs_gpios = { 1, 0, false }; 43static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
@@ -216,6 +217,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
216 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), }, 217 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), },
217 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), }, 218 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
218 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), }, 219 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), },
220 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), },
219 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, 221 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
220 { } /* Terminating Entry */ 222 { } /* Terminating Entry */
221}; 223};
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index b13912d5fa99..f13e9e9fb834 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -55,20 +55,13 @@ static const char *dwc3_ep0_state_string(enum dwc3_ep0_state state)
55 } 55 }
56} 56}
57 57
58static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, 58static void dwc3_ep0_prepare_one_trb(struct dwc3 *dwc, u8 epnum,
59 u32 len, u32 type, bool chain) 59 dma_addr_t buf_dma, u32 len, u32 type, bool chain)
60{ 60{
61 struct dwc3_gadget_ep_cmd_params params;
62 struct dwc3_trb *trb; 61 struct dwc3_trb *trb;
63 struct dwc3_ep *dep; 62 struct dwc3_ep *dep;
64 63
65 int ret;
66
67 dep = dwc->eps[epnum]; 64 dep = dwc->eps[epnum];
68 if (dep->flags & DWC3_EP_BUSY) {
69 dwc3_trace(trace_dwc3_ep0, "%s still busy", dep->name);
70 return 0;
71 }
72 65
73 trb = &dwc->ep0_trb[dep->free_slot]; 66 trb = &dwc->ep0_trb[dep->free_slot];
74 67
@@ -89,15 +82,25 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,
89 trb->ctrl |= (DWC3_TRB_CTRL_IOC 82 trb->ctrl |= (DWC3_TRB_CTRL_IOC
90 | DWC3_TRB_CTRL_LST); 83 | DWC3_TRB_CTRL_LST);
91 84
92 if (chain) 85 trace_dwc3_prepare_trb(dep, trb);
86}
87
88static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum)
89{
90 struct dwc3_gadget_ep_cmd_params params;
91 struct dwc3_ep *dep;
92 int ret;
93
94 dep = dwc->eps[epnum];
95 if (dep->flags & DWC3_EP_BUSY) {
96 dwc3_trace(trace_dwc3_ep0, "%s still busy", dep->name);
93 return 0; 97 return 0;
98 }
94 99
95 memset(&params, 0, sizeof(params)); 100 memset(&params, 0, sizeof(params));
96 params.param0 = upper_32_bits(dwc->ep0_trb_addr); 101 params.param0 = upper_32_bits(dwc->ep0_trb_addr);
97 params.param1 = lower_32_bits(dwc->ep0_trb_addr); 102 params.param1 = lower_32_bits(dwc->ep0_trb_addr);
98 103
99 trace_dwc3_prepare_trb(dep, trb);
100
101 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, 104 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number,
102 DWC3_DEPCMD_STARTTRANSFER, &params); 105 DWC3_DEPCMD_STARTTRANSFER, &params);
103 if (ret < 0) { 106 if (ret < 0) {
@@ -311,8 +314,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc)
311{ 314{
312 int ret; 315 int ret;
313 316
314 ret = dwc3_ep0_start_trans(dwc, 0, dwc->ctrl_req_addr, 8, 317 dwc3_ep0_prepare_one_trb(dwc, 0, dwc->ctrl_req_addr, 8,
315 DWC3_TRBCTL_CONTROL_SETUP, false); 318 DWC3_TRBCTL_CONTROL_SETUP, false);
319 ret = dwc3_ep0_start_trans(dwc, 0);
316 WARN_ON(ret < 0); 320 WARN_ON(ret < 0);
317} 321}
318 322
@@ -871,9 +875,9 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
871 875
872 dwc->ep0_next_event = DWC3_EP0_COMPLETE; 876 dwc->ep0_next_event = DWC3_EP0_COMPLETE;
873 877
874 ret = dwc3_ep0_start_trans(dwc, epnum, 878 dwc3_ep0_prepare_one_trb(dwc, epnum, dwc->ctrl_req_addr,
875 dwc->ctrl_req_addr, 0, 879 0, DWC3_TRBCTL_CONTROL_DATA, false);
876 DWC3_TRBCTL_CONTROL_DATA, false); 880 ret = dwc3_ep0_start_trans(dwc, epnum);
877 WARN_ON(ret < 0); 881 WARN_ON(ret < 0);
878 } 882 }
879 } 883 }
@@ -955,9 +959,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
955 req->direction = !!dep->number; 959 req->direction = !!dep->number;
956 960
957 if (req->request.length == 0) { 961 if (req->request.length == 0) {
958 ret = dwc3_ep0_start_trans(dwc, dep->number, 962 dwc3_ep0_prepare_one_trb(dwc, dep->number,
959 dwc->ctrl_req_addr, 0, 963 dwc->ctrl_req_addr, 0,
960 DWC3_TRBCTL_CONTROL_DATA, false); 964 DWC3_TRBCTL_CONTROL_DATA, false);
965 ret = dwc3_ep0_start_trans(dwc, dep->number);
961 } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) 966 } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket)
962 && (dep->number == 0)) { 967 && (dep->number == 0)) {
963 u32 transfer_size = 0; 968 u32 transfer_size = 0;
@@ -975,7 +980,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
975 if (req->request.length > DWC3_EP0_BOUNCE_SIZE) { 980 if (req->request.length > DWC3_EP0_BOUNCE_SIZE) {
976 transfer_size = ALIGN(req->request.length - maxpacket, 981 transfer_size = ALIGN(req->request.length - maxpacket,
977 maxpacket); 982 maxpacket);
978 ret = dwc3_ep0_start_trans(dwc, dep->number, 983 dwc3_ep0_prepare_one_trb(dwc, dep->number,
979 req->request.dma, 984 req->request.dma,
980 transfer_size, 985 transfer_size,
981 DWC3_TRBCTL_CONTROL_DATA, 986 DWC3_TRBCTL_CONTROL_DATA,
@@ -987,9 +992,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
987 992
988 dwc->ep0_bounced = true; 993 dwc->ep0_bounced = true;
989 994
990 ret = dwc3_ep0_start_trans(dwc, dep->number, 995 dwc3_ep0_prepare_one_trb(dwc, dep->number,
991 dwc->ep0_bounce_addr, transfer_size, 996 dwc->ep0_bounce_addr, transfer_size,
992 DWC3_TRBCTL_CONTROL_DATA, false); 997 DWC3_TRBCTL_CONTROL_DATA, false);
998 ret = dwc3_ep0_start_trans(dwc, dep->number);
993 } else { 999 } else {
994 ret = usb_gadget_map_request(&dwc->gadget, &req->request, 1000 ret = usb_gadget_map_request(&dwc->gadget, &req->request,
995 dep->number); 1001 dep->number);
@@ -998,9 +1004,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
998 return; 1004 return;
999 } 1005 }
1000 1006
1001 ret = dwc3_ep0_start_trans(dwc, dep->number, req->request.dma, 1007 dwc3_ep0_prepare_one_trb(dwc, dep->number, req->request.dma,
1002 req->request.length, DWC3_TRBCTL_CONTROL_DATA, 1008 req->request.length, DWC3_TRBCTL_CONTROL_DATA,
1003 false); 1009 false);
1010 ret = dwc3_ep0_start_trans(dwc, dep->number);
1004 } 1011 }
1005 1012
1006 WARN_ON(ret < 0); 1013 WARN_ON(ret < 0);
@@ -1014,8 +1021,9 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep)
1014 type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3 1021 type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3
1015 : DWC3_TRBCTL_CONTROL_STATUS2; 1022 : DWC3_TRBCTL_CONTROL_STATUS2;
1016 1023
1017 return dwc3_ep0_start_trans(dwc, dep->number, 1024 dwc3_ep0_prepare_one_trb(dwc, dep->number,
1018 dwc->ctrl_req_addr, 0, type, false); 1025 dwc->ctrl_req_addr, 0, type, false);
1026 return dwc3_ep0_start_trans(dwc, dep->number);
1019} 1027}
1020 1028
1021static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) 1029static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 81624af1c8ca..fbb6da302319 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -262,11 +262,11 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
262 if (req->request.status == -EINPROGRESS) 262 if (req->request.status == -EINPROGRESS)
263 req->request.status = status; 263 req->request.status = status;
264 264
265 if (dwc->ep0_bounced && dep->number == 0) 265 if (dwc->ep0_bounced && dep->number <= 1)
266 dwc->ep0_bounced = false; 266 dwc->ep0_bounced = false;
267 else 267
268 usb_gadget_unmap_request(&dwc->gadget, &req->request, 268 usb_gadget_unmap_request(&dwc->gadget, &req->request,
269 req->direction); 269 req->direction);
270 270
271 dev_dbg(dwc->dev, "request %p from %s completed %d/%d ===> %d\n", 271 dev_dbg(dwc->dev, "request %p from %s completed %d/%d ===> %d\n",
272 req, dep->name, req->request.actual, 272 req, dep->name, req->request.actual,
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 739b5e2d8adb..e2641d4dfdd6 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -152,7 +152,7 @@ ep_found:
152 152
153 if (g->speed == USB_SPEED_HIGH && (usb_endpoint_xfer_isoc(_ep->desc) || 153 if (g->speed == USB_SPEED_HIGH && (usb_endpoint_xfer_isoc(_ep->desc) ||
154 usb_endpoint_xfer_int(_ep->desc))) 154 usb_endpoint_xfer_int(_ep->desc)))
155 _ep->mult = usb_endpoint_maxp(_ep->desc) & 0x7ff; 155 _ep->mult = ((usb_endpoint_maxp(_ep->desc) & 0x1800) >> 11) + 1;
156 156
157 if (!want_comp_desc) 157 if (!want_comp_desc)
158 return 0; 158 return 0;
@@ -1601,9 +1601,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1601 value = min(w_length, (u16) 1); 1601 value = min(w_length, (u16) 1);
1602 break; 1602 break;
1603 1603
1604 /* function drivers must handle get/set altsetting; if there's 1604 /* function drivers must handle get/set altsetting */
1605 * no get() method, we know only altsetting zero works.
1606 */
1607 case USB_REQ_SET_INTERFACE: 1605 case USB_REQ_SET_INTERFACE:
1608 if (ctrl->bRequestType != USB_RECIP_INTERFACE) 1606 if (ctrl->bRequestType != USB_RECIP_INTERFACE)
1609 goto unknown; 1607 goto unknown;
@@ -1612,7 +1610,13 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1612 f = cdev->config->interface[intf]; 1610 f = cdev->config->interface[intf];
1613 if (!f) 1611 if (!f)
1614 break; 1612 break;
1615 if (w_value && !f->set_alt) 1613
1614 /*
1615 * If there's no get_alt() method, we know only altsetting zero
1616 * works. There is no need to check if set_alt() is not NULL
1617 * as we check this in usb_add_function().
1618 */
1619 if (w_value && !f->get_alt)
1616 break; 1620 break;
1617 value = f->set_alt(f, w_index, w_value); 1621 value = f->set_alt(f, w_index, w_value);
1618 if (value == USB_GADGET_DELAYED_STATUS) { 1622 if (value == USB_GADGET_DELAYED_STATUS) {
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index e5ea6ba6f44c..684c2a85f29c 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1125,7 +1125,7 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1125 /* data and/or status stage for control request */ 1125 /* data and/or status stage for control request */
1126 } else if (dev->state == STATE_DEV_SETUP) { 1126 } else if (dev->state == STATE_DEV_SETUP) {
1127 1127
1128 /* IN DATA+STATUS caller makes len <= wLength */ 1128 len = min_t(size_t, len, dev->setup_wLength);
1129 if (dev->setup_in) { 1129 if (dev->setup_in) {
1130 retval = setup_req (dev->gadget->ep0, dev->req, len); 1130 retval = setup_req (dev->gadget->ep0, dev->req, len);
1131 if (retval == 0) { 1131 if (retval == 0) {
@@ -1754,10 +1754,12 @@ static struct usb_gadget_driver probe_driver = {
1754 * such as configuration notifications. 1754 * such as configuration notifications.
1755 */ 1755 */
1756 1756
1757static int is_valid_config (struct usb_config_descriptor *config) 1757static int is_valid_config(struct usb_config_descriptor *config,
1758 unsigned int total)
1758{ 1759{
1759 return config->bDescriptorType == USB_DT_CONFIG 1760 return config->bDescriptorType == USB_DT_CONFIG
1760 && config->bLength == USB_DT_CONFIG_SIZE 1761 && config->bLength == USB_DT_CONFIG_SIZE
1762 && total >= USB_DT_CONFIG_SIZE
1761 && config->bConfigurationValue != 0 1763 && config->bConfigurationValue != 0
1762 && (config->bmAttributes & USB_CONFIG_ATT_ONE) != 0 1764 && (config->bmAttributes & USB_CONFIG_ATT_ONE) != 0
1763 && (config->bmAttributes & USB_CONFIG_ATT_WAKEUP) == 0; 1765 && (config->bmAttributes & USB_CONFIG_ATT_WAKEUP) == 0;
@@ -1782,7 +1784,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1782 } 1784 }
1783 spin_unlock_irq(&dev->lock); 1785 spin_unlock_irq(&dev->lock);
1784 1786
1785 if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) 1787 if ((len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) ||
1788 (len > PAGE_SIZE * 4))
1786 return -EINVAL; 1789 return -EINVAL;
1787 1790
1788 /* we might need to change message format someday */ 1791 /* we might need to change message format someday */
@@ -1806,7 +1809,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1806 /* full or low speed config */ 1809 /* full or low speed config */
1807 dev->config = (void *) kbuf; 1810 dev->config = (void *) kbuf;
1808 total = le16_to_cpu(dev->config->wTotalLength); 1811 total = le16_to_cpu(dev->config->wTotalLength);
1809 if (!is_valid_config (dev->config) || total >= length) 1812 if (!is_valid_config(dev->config, total) ||
1813 total > length - USB_DT_DEVICE_SIZE)
1810 goto fail; 1814 goto fail;
1811 kbuf += total; 1815 kbuf += total;
1812 length -= total; 1816 length -= total;
@@ -1815,10 +1819,13 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1815 if (kbuf [1] == USB_DT_CONFIG) { 1819 if (kbuf [1] == USB_DT_CONFIG) {
1816 dev->hs_config = (void *) kbuf; 1820 dev->hs_config = (void *) kbuf;
1817 total = le16_to_cpu(dev->hs_config->wTotalLength); 1821 total = le16_to_cpu(dev->hs_config->wTotalLength);
1818 if (!is_valid_config (dev->hs_config) || total >= length) 1822 if (!is_valid_config(dev->hs_config, total) ||
1823 total > length - USB_DT_DEVICE_SIZE)
1819 goto fail; 1824 goto fail;
1820 kbuf += total; 1825 kbuf += total;
1821 length -= total; 1826 length -= total;
1827 } else {
1828 dev->hs_config = NULL;
1822 } 1829 }
1823 1830
1824 /* could support multiple configs, using another encoding! */ 1831 /* could support multiple configs, using another encoding! */
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index dde44450dfa9..22d067cd5aa3 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -330,7 +330,7 @@ static void nuke(struct dummy *dum, struct dummy_ep *ep)
330/* caller must hold lock */ 330/* caller must hold lock */
331static void stop_activity(struct dummy *dum) 331static void stop_activity(struct dummy *dum)
332{ 332{
333 struct dummy_ep *ep; 333 int i;
334 334
335 /* prevent any more requests */ 335 /* prevent any more requests */
336 dum->address = 0; 336 dum->address = 0;
@@ -338,8 +338,8 @@ static void stop_activity(struct dummy *dum)
338 /* The timer is left running so that outstanding URBs can fail */ 338 /* The timer is left running so that outstanding URBs can fail */
339 339
340 /* nuke any pending requests first, so driver i/o is quiesced */ 340 /* nuke any pending requests first, so driver i/o is quiesced */
341 list_for_each_entry(ep, &dum->gadget.ep_list, ep.ep_list) 341 for (i = 0; i < DUMMY_ENDPOINTS; ++i)
342 nuke(dum, ep); 342 nuke(dum, &dum->ep[i]);
343 343
344 /* driver now does any non-usb quiescing necessary */ 344 /* driver now does any non-usb quiescing necessary */
345} 345}
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 9b80889ebaa9..efd31d1d0727 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1352,6 +1352,35 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
1352 return 0; 1352 return 0;
1353} 1353}
1354 1354
1355/*
1356 * Workaround for missing Cold Attach Status (CAS) if device re-plugged in S3.
1357 * warm reset a USB3 device stuck in polling or compliance mode after resume.
1358 * See Intel 100/c230 series PCH specification update Doc #332692-006 Errata #8
1359 */
1360static bool xhci_port_missing_cas_quirk(int port_index,
1361 __le32 __iomem **port_array)
1362{
1363 u32 portsc;
1364
1365 portsc = readl(port_array[port_index]);
1366
1367 /* if any of these are set we are not stuck */
1368 if (portsc & (PORT_CONNECT | PORT_CAS))
1369 return false;
1370
1371 if (((portsc & PORT_PLS_MASK) != XDEV_POLLING) &&
1372 ((portsc & PORT_PLS_MASK) != XDEV_COMP_MODE))
1373 return false;
1374
1375 /* clear wakeup/change bits, and do a warm port reset */
1376 portsc &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);
1377 portsc |= PORT_WR;
1378 writel(portsc, port_array[port_index]);
1379 /* flush write */
1380 readl(port_array[port_index]);
1381 return true;
1382}
1383
1355int xhci_bus_resume(struct usb_hcd *hcd) 1384int xhci_bus_resume(struct usb_hcd *hcd)
1356{ 1385{
1357 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 1386 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
@@ -1389,6 +1418,14 @@ int xhci_bus_resume(struct usb_hcd *hcd)
1389 u32 temp; 1418 u32 temp;
1390 1419
1391 temp = readl(port_array[port_index]); 1420 temp = readl(port_array[port_index]);
1421
1422 /* warm reset CAS limited ports stuck in polling/compliance */
1423 if ((xhci->quirks & XHCI_MISSING_CAS) &&
1424 (hcd->speed >= HCD_USB3) &&
1425 xhci_port_missing_cas_quirk(port_index, port_array)) {
1426 xhci_dbg(xhci, "reset stuck port %d\n", port_index);
1427 continue;
1428 }
1392 if (DEV_SUPERSPEED_ANY(temp)) 1429 if (DEV_SUPERSPEED_ANY(temp))
1393 temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS); 1430 temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);
1394 else 1431 else
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 8ea2c05beca2..998a738e6359 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -964,6 +964,40 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
964 xhci->devs[slot_id] = NULL; 964 xhci->devs[slot_id] = NULL;
965} 965}
966 966
967/*
968 * Free a virt_device structure.
969 * If the virt_device added a tt_info (a hub) and has children pointing to
970 * that tt_info, then free the child first. Recursive.
971 * We can't rely on udev at this point to find child-parent relationships.
972 */
973void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
974{
975 struct xhci_virt_device *vdev;
976 struct list_head *tt_list_head;
977 struct xhci_tt_bw_info *tt_info, *next;
978 int i;
979
980 vdev = xhci->devs[slot_id];
981 if (!vdev)
982 return;
983
984 tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts);
985 list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
986 /* is this a hub device that added a tt_info to the tts list */
987 if (tt_info->slot_id == slot_id) {
988 /* are any devices using this tt_info? */
989 for (i = 1; i < HCS_MAX_SLOTS(xhci->hcs_params1); i++) {
990 vdev = xhci->devs[i];
991 if (vdev && (vdev->tt_info == tt_info))
992 xhci_free_virt_devices_depth_first(
993 xhci, i);
994 }
995 }
996 }
997 /* we are now at a leaf device */
998 xhci_free_virt_device(xhci, slot_id);
999}
1000
967int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, 1001int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
968 struct usb_device *udev, gfp_t flags) 1002 struct usb_device *udev, gfp_t flags)
969{ 1003{
@@ -1795,7 +1829,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1795 int size; 1829 int size;
1796 int i, j, num_ports; 1830 int i, j, num_ports;
1797 1831
1798 del_timer_sync(&xhci->cmd_timer); 1832 cancel_delayed_work_sync(&xhci->cmd_timer);
1799 1833
1800 /* Free the Event Ring Segment Table and the actual Event Ring */ 1834 /* Free the Event Ring Segment Table and the actual Event Ring */
1801 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); 1835 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
@@ -1828,8 +1862,8 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1828 } 1862 }
1829 } 1863 }
1830 1864
1831 for (i = 1; i < MAX_HC_SLOTS; ++i) 1865 for (i = HCS_MAX_SLOTS(xhci->hcs_params1); i > 0; i--)
1832 xhci_free_virt_device(xhci, i); 1866 xhci_free_virt_devices_depth_first(xhci, i);
1833 1867
1834 dma_pool_destroy(xhci->segment_pool); 1868 dma_pool_destroy(xhci->segment_pool);
1835 xhci->segment_pool = NULL; 1869 xhci->segment_pool = NULL;
@@ -2361,9 +2395,9 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2361 2395
2362 INIT_LIST_HEAD(&xhci->cmd_list); 2396 INIT_LIST_HEAD(&xhci->cmd_list);
2363 2397
2364 /* init command timeout timer */ 2398 /* init command timeout work */
2365 setup_timer(&xhci->cmd_timer, xhci_handle_command_timeout, 2399 INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout);
2366 (unsigned long)xhci); 2400 init_completion(&xhci->cmd_ring_stop_completion);
2367 2401
2368 page_size = readl(&xhci->op_regs->page_size); 2402 page_size = readl(&xhci->op_regs->page_size);
2369 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2403 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
@@ -2402,7 +2436,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2402 * "physically contiguous and 64-byte (cache line) aligned". 2436 * "physically contiguous and 64-byte (cache line) aligned".
2403 */ 2437 */
2404 xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa), &dma, 2438 xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa), &dma,
2405 GFP_KERNEL); 2439 flags);
2406 if (!xhci->dcbaa) 2440 if (!xhci->dcbaa)
2407 goto fail; 2441 goto fail;
2408 memset(xhci->dcbaa, 0, sizeof *(xhci->dcbaa)); 2442 memset(xhci->dcbaa, 0, sizeof *(xhci->dcbaa));
@@ -2498,7 +2532,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2498 2532
2499 xhci->erst.entries = dma_alloc_coherent(dev, 2533 xhci->erst.entries = dma_alloc_coherent(dev,
2500 sizeof(struct xhci_erst_entry) * ERST_NUM_SEGS, &dma, 2534 sizeof(struct xhci_erst_entry) * ERST_NUM_SEGS, &dma,
2501 GFP_KERNEL); 2535 flags);
2502 if (!xhci->erst.entries) 2536 if (!xhci->erst.entries)
2503 goto fail; 2537 goto fail;
2504 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2538 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index cf147ccac7d3..dd262f418140 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -51,6 +51,7 @@
51#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f 51#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f
52#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8 52#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8
53#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8 53#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8
54#define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8
54 55
55static const char hcd_name[] = "xhci_hcd"; 56static const char hcd_name[] = "xhci_hcd";
56 57
@@ -165,9 +166,15 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
165 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI || 166 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
166 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || 167 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
167 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI || 168 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI ||
168 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI)) { 169 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI ||
170 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) {
169 xhci->quirks |= XHCI_PME_STUCK_QUIRK; 171 xhci->quirks |= XHCI_PME_STUCK_QUIRK;
170 } 172 }
173 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
174 (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
175 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI))
176 xhci->quirks |= XHCI_MISSING_CAS;
177
171 if (pdev->vendor == PCI_VENDOR_ID_ETRON && 178 if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
172 pdev->device == PCI_DEVICE_ID_EJ168) { 179 pdev->device == PCI_DEVICE_ID_EJ168) {
173 xhci->quirks |= XHCI_RESET_ON_RESUME; 180 xhci->quirks |= XHCI_RESET_ON_RESUME;
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 62a5c8d5e028..fa5d8c2f6982 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -280,23 +280,76 @@ void xhci_ring_cmd_db(struct xhci_hcd *xhci)
280 readl(&xhci->dba->doorbell[0]); 280 readl(&xhci->dba->doorbell[0]);
281} 281}
282 282
283static int xhci_abort_cmd_ring(struct xhci_hcd *xhci) 283static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci, unsigned long delay)
284{
285 return mod_delayed_work(system_wq, &xhci->cmd_timer, delay);
286}
287
288static struct xhci_command *xhci_next_queued_cmd(struct xhci_hcd *xhci)
289{
290 return list_first_entry_or_null(&xhci->cmd_list, struct xhci_command,
291 cmd_list);
292}
293
294/*
295 * Turn all commands on command ring with status set to "aborted" to no-op trbs.
296 * If there are other commands waiting then restart the ring and kick the timer.
297 * This must be called with command ring stopped and xhci->lock held.
298 */
299static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,
300 struct xhci_command *cur_cmd)
301{
302 struct xhci_command *i_cmd;
303 u32 cycle_state;
304
305 /* Turn all aborted commands in list to no-ops, then restart */
306 list_for_each_entry(i_cmd, &xhci->cmd_list, cmd_list) {
307
308 if (i_cmd->status != COMP_CMD_ABORT)
309 continue;
310
311 i_cmd->status = COMP_CMD_STOP;
312
313 xhci_dbg(xhci, "Turn aborted command %p to no-op\n",
314 i_cmd->command_trb);
315 /* get cycle state from the original cmd trb */
316 cycle_state = le32_to_cpu(
317 i_cmd->command_trb->generic.field[3]) & TRB_CYCLE;
318 /* modify the command trb to no-op command */
319 i_cmd->command_trb->generic.field[0] = 0;
320 i_cmd->command_trb->generic.field[1] = 0;
321 i_cmd->command_trb->generic.field[2] = 0;
322 i_cmd->command_trb->generic.field[3] = cpu_to_le32(
323 TRB_TYPE(TRB_CMD_NOOP) | cycle_state);
324
325 /*
326 * caller waiting for completion is called when command
327 * completion event is received for these no-op commands
328 */
329 }
330
331 xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
332
333 /* ring command ring doorbell to restart the command ring */
334 if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) &&
335 !(xhci->xhc_state & XHCI_STATE_DYING)) {
336 xhci->current_cmd = cur_cmd;
337 xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
338 xhci_ring_cmd_db(xhci);
339 }
340}
341
342/* Must be called with xhci->lock held, releases and aquires lock back */
343static int xhci_abort_cmd_ring(struct xhci_hcd *xhci, unsigned long flags)
284{ 344{
285 u64 temp_64; 345 u64 temp_64;
286 int ret; 346 int ret;
287 347
288 xhci_dbg(xhci, "Abort command ring\n"); 348 xhci_dbg(xhci, "Abort command ring\n");
289 349
290 temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 350 reinit_completion(&xhci->cmd_ring_stop_completion);
291 xhci->cmd_ring_state = CMD_RING_STATE_ABORTED;
292 351
293 /* 352 temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
294 * Writing the CMD_RING_ABORT bit should cause a cmd completion event,
295 * however on some host hw the CMD_RING_RUNNING bit is correctly cleared
296 * but the completion event in never sent. Use the cmd timeout timer to
297 * handle those cases. Use twice the time to cover the bit polling retry
298 */
299 mod_timer(&xhci->cmd_timer, jiffies + (2 * XHCI_CMD_DEFAULT_TIMEOUT));
300 xhci_write_64(xhci, temp_64 | CMD_RING_ABORT, 353 xhci_write_64(xhci, temp_64 | CMD_RING_ABORT,
301 &xhci->op_regs->cmd_ring); 354 &xhci->op_regs->cmd_ring);
302 355
@@ -316,16 +369,30 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
316 udelay(1000); 369 udelay(1000);
317 ret = xhci_handshake(&xhci->op_regs->cmd_ring, 370 ret = xhci_handshake(&xhci->op_regs->cmd_ring,
318 CMD_RING_RUNNING, 0, 3 * 1000 * 1000); 371 CMD_RING_RUNNING, 0, 3 * 1000 * 1000);
319 if (ret == 0) 372 if (ret < 0) {
320 return 0; 373 xhci_err(xhci, "Stopped the command ring failed, "
321 374 "maybe the host is dead\n");
322 xhci_err(xhci, "Stopped the command ring failed, " 375 xhci->xhc_state |= XHCI_STATE_DYING;
323 "maybe the host is dead\n"); 376 xhci_quiesce(xhci);
324 del_timer(&xhci->cmd_timer); 377 xhci_halt(xhci);
325 xhci->xhc_state |= XHCI_STATE_DYING; 378 return -ESHUTDOWN;
326 xhci_quiesce(xhci); 379 }
327 xhci_halt(xhci); 380 }
328 return -ESHUTDOWN; 381 /*
382 * Writing the CMD_RING_ABORT bit should cause a cmd completion event,
383 * however on some host hw the CMD_RING_RUNNING bit is correctly cleared
384 * but the completion event in never sent. Wait 2 secs (arbitrary
385 * number) to handle those cases after negation of CMD_RING_RUNNING.
386 */
387 spin_unlock_irqrestore(&xhci->lock, flags);
388 ret = wait_for_completion_timeout(&xhci->cmd_ring_stop_completion,
389 msecs_to_jiffies(2000));
390 spin_lock_irqsave(&xhci->lock, flags);
391 if (!ret) {
392 xhci_dbg(xhci, "No stop event for abort, ring start fail?\n");
393 xhci_cleanup_command_queue(xhci);
394 } else {
395 xhci_handle_stopped_cmd_ring(xhci, xhci_next_queued_cmd(xhci));
329 } 396 }
330 397
331 return 0; 398 return 0;
@@ -1208,101 +1275,62 @@ void xhci_cleanup_command_queue(struct xhci_hcd *xhci)
1208 xhci_complete_del_and_free_cmd(cur_cmd, COMP_CMD_ABORT); 1275 xhci_complete_del_and_free_cmd(cur_cmd, COMP_CMD_ABORT);
1209} 1276}
1210 1277
1211/* 1278void xhci_handle_command_timeout(struct work_struct *work)
1212 * Turn all commands on command ring with status set to "aborted" to no-op trbs.
1213 * If there are other commands waiting then restart the ring and kick the timer.
1214 * This must be called with command ring stopped and xhci->lock held.
1215 */
1216static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,
1217 struct xhci_command *cur_cmd)
1218{
1219 struct xhci_command *i_cmd, *tmp_cmd;
1220 u32 cycle_state;
1221
1222 /* Turn all aborted commands in list to no-ops, then restart */
1223 list_for_each_entry_safe(i_cmd, tmp_cmd, &xhci->cmd_list,
1224 cmd_list) {
1225
1226 if (i_cmd->status != COMP_CMD_ABORT)
1227 continue;
1228
1229 i_cmd->status = COMP_CMD_STOP;
1230
1231 xhci_dbg(xhci, "Turn aborted command %p to no-op\n",
1232 i_cmd->command_trb);
1233 /* get cycle state from the original cmd trb */
1234 cycle_state = le32_to_cpu(
1235 i_cmd->command_trb->generic.field[3]) & TRB_CYCLE;
1236 /* modify the command trb to no-op command */
1237 i_cmd->command_trb->generic.field[0] = 0;
1238 i_cmd->command_trb->generic.field[1] = 0;
1239 i_cmd->command_trb->generic.field[2] = 0;
1240 i_cmd->command_trb->generic.field[3] = cpu_to_le32(
1241 TRB_TYPE(TRB_CMD_NOOP) | cycle_state);
1242
1243 /*
1244 * caller waiting for completion is called when command
1245 * completion event is received for these no-op commands
1246 */
1247 }
1248
1249 xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
1250
1251 /* ring command ring doorbell to restart the command ring */
1252 if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) &&
1253 !(xhci->xhc_state & XHCI_STATE_DYING)) {
1254 xhci->current_cmd = cur_cmd;
1255 mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT);
1256 xhci_ring_cmd_db(xhci);
1257 }
1258 return;
1259}
1260
1261
1262void xhci_handle_command_timeout(unsigned long data)
1263{ 1279{
1264 struct xhci_hcd *xhci; 1280 struct xhci_hcd *xhci;
1265 int ret; 1281 int ret;
1266 unsigned long flags; 1282 unsigned long flags;
1267 u64 hw_ring_state; 1283 u64 hw_ring_state;
1268 bool second_timeout = false;
1269 xhci = (struct xhci_hcd *) data;
1270 1284
1271 /* mark this command to be cancelled */ 1285 xhci = container_of(to_delayed_work(work), struct xhci_hcd, cmd_timer);
1286
1272 spin_lock_irqsave(&xhci->lock, flags); 1287 spin_lock_irqsave(&xhci->lock, flags);
1273 if (xhci->current_cmd) { 1288
1274 if (xhci->current_cmd->status == COMP_CMD_ABORT) 1289 /*
1275 second_timeout = true; 1290 * If timeout work is pending, or current_cmd is NULL, it means we
1276 xhci->current_cmd->status = COMP_CMD_ABORT; 1291 * raced with command completion. Command is handled so just return.
1292 */
1293 if (!xhci->current_cmd || delayed_work_pending(&xhci->cmd_timer)) {
1294 spin_unlock_irqrestore(&xhci->lock, flags);
1295 return;
1277 } 1296 }
1297 /* mark this command to be cancelled */
1298 xhci->current_cmd->status = COMP_CMD_ABORT;
1278 1299
1279 /* Make sure command ring is running before aborting it */ 1300 /* Make sure command ring is running before aborting it */
1280 hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 1301 hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
1281 if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) && 1302 if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) &&
1282 (hw_ring_state & CMD_RING_RUNNING)) { 1303 (hw_ring_state & CMD_RING_RUNNING)) {
1283 spin_unlock_irqrestore(&xhci->lock, flags); 1304 /* Prevent new doorbell, and start command abort */
1305 xhci->cmd_ring_state = CMD_RING_STATE_ABORTED;
1284 xhci_dbg(xhci, "Command timeout\n"); 1306 xhci_dbg(xhci, "Command timeout\n");
1285 ret = xhci_abort_cmd_ring(xhci); 1307 ret = xhci_abort_cmd_ring(xhci, flags);
1286 if (unlikely(ret == -ESHUTDOWN)) { 1308 if (unlikely(ret == -ESHUTDOWN)) {
1287 xhci_err(xhci, "Abort command ring failed\n"); 1309 xhci_err(xhci, "Abort command ring failed\n");
1288 xhci_cleanup_command_queue(xhci); 1310 xhci_cleanup_command_queue(xhci);
1311 spin_unlock_irqrestore(&xhci->lock, flags);
1289 usb_hc_died(xhci_to_hcd(xhci)->primary_hcd); 1312 usb_hc_died(xhci_to_hcd(xhci)->primary_hcd);
1290 xhci_dbg(xhci, "xHCI host controller is dead.\n"); 1313 xhci_dbg(xhci, "xHCI host controller is dead.\n");
1314
1315 return;
1291 } 1316 }
1292 return; 1317
1318 goto time_out_completed;
1293 } 1319 }
1294 1320
1295 /* command ring failed to restart, or host removed. Bail out */ 1321 /* host removed. Bail out */
1296 if (second_timeout || xhci->xhc_state & XHCI_STATE_REMOVING) { 1322 if (xhci->xhc_state & XHCI_STATE_REMOVING) {
1297 spin_unlock_irqrestore(&xhci->lock, flags); 1323 xhci_dbg(xhci, "host removed, ring start fail?\n");
1298 xhci_dbg(xhci, "command timed out twice, ring start fail?\n");
1299 xhci_cleanup_command_queue(xhci); 1324 xhci_cleanup_command_queue(xhci);
1300 return; 1325
1326 goto time_out_completed;
1301 } 1327 }
1302 1328
1303 /* command timeout on stopped ring, ring can't be aborted */ 1329 /* command timeout on stopped ring, ring can't be aborted */
1304 xhci_dbg(xhci, "Command timeout on stopped ring\n"); 1330 xhci_dbg(xhci, "Command timeout on stopped ring\n");
1305 xhci_handle_stopped_cmd_ring(xhci, xhci->current_cmd); 1331 xhci_handle_stopped_cmd_ring(xhci, xhci->current_cmd);
1332
1333time_out_completed:
1306 spin_unlock_irqrestore(&xhci->lock, flags); 1334 spin_unlock_irqrestore(&xhci->lock, flags);
1307 return; 1335 return;
1308} 1336}
@@ -1335,7 +1363,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1335 1363
1336 cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list); 1364 cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list);
1337 1365
1338 del_timer(&xhci->cmd_timer); 1366 cancel_delayed_work(&xhci->cmd_timer);
1339 1367
1340 trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event); 1368 trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event);
1341 1369
@@ -1343,7 +1371,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1343 1371
1344 /* If CMD ring stopped we own the trbs between enqueue and dequeue */ 1372 /* If CMD ring stopped we own the trbs between enqueue and dequeue */
1345 if (cmd_comp_code == COMP_CMD_STOP) { 1373 if (cmd_comp_code == COMP_CMD_STOP) {
1346 xhci_handle_stopped_cmd_ring(xhci, cmd); 1374 complete_all(&xhci->cmd_ring_stop_completion);
1347 return; 1375 return;
1348 } 1376 }
1349 1377
@@ -1361,8 +1389,11 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1361 */ 1389 */
1362 if (cmd_comp_code == COMP_CMD_ABORT) { 1390 if (cmd_comp_code == COMP_CMD_ABORT) {
1363 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; 1391 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED;
1364 if (cmd->status == COMP_CMD_ABORT) 1392 if (cmd->status == COMP_CMD_ABORT) {
1393 if (xhci->current_cmd == cmd)
1394 xhci->current_cmd = NULL;
1365 goto event_handled; 1395 goto event_handled;
1396 }
1366 } 1397 }
1367 1398
1368 cmd_type = TRB_FIELD_TO_TYPE(le32_to_cpu(cmd_trb->generic.field[3])); 1399 cmd_type = TRB_FIELD_TO_TYPE(le32_to_cpu(cmd_trb->generic.field[3]));
@@ -1423,7 +1454,9 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1423 if (cmd->cmd_list.next != &xhci->cmd_list) { 1454 if (cmd->cmd_list.next != &xhci->cmd_list) {
1424 xhci->current_cmd = list_entry(cmd->cmd_list.next, 1455 xhci->current_cmd = list_entry(cmd->cmd_list.next,
1425 struct xhci_command, cmd_list); 1456 struct xhci_command, cmd_list);
1426 mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT); 1457 xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
1458 } else if (xhci->current_cmd == cmd) {
1459 xhci->current_cmd = NULL;
1427 } 1460 }
1428 1461
1429event_handled: 1462event_handled:
@@ -4056,9 +4089,9 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
4056 4089
4057 /* if there are no other commands queued we start the timeout timer */ 4090 /* if there are no other commands queued we start the timeout timer */
4058 if (xhci->cmd_list.next == &cmd->cmd_list && 4091 if (xhci->cmd_list.next == &cmd->cmd_list &&
4059 !timer_pending(&xhci->cmd_timer)) { 4092 !delayed_work_pending(&xhci->cmd_timer)) {
4060 xhci->current_cmd = cmd; 4093 xhci->current_cmd = cmd;
4061 mod_timer(&xhci->cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT); 4094 xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
4062 } 4095 }
4063 4096
4064 queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, 4097 queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3,
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index c024ec27d4ba..4b361ad6c302 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3808,8 +3808,10 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
3808 3808
3809 mutex_lock(&xhci->mutex); 3809 mutex_lock(&xhci->mutex);
3810 3810
3811 if (xhci->xhc_state) /* dying, removing or halted */ 3811 if (xhci->xhc_state) { /* dying, removing or halted */
3812 ret = -ESHUTDOWN;
3812 goto out; 3813 goto out;
3814 }
3813 3815
3814 if (!udev->slot_id) { 3816 if (!udev->slot_id) {
3815 xhci_dbg_trace(xhci, trace_xhci_dbg_address, 3817 xhci_dbg_trace(xhci, trace_xhci_dbg_address,
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 53887dba0ce4..b7919c44f090 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -312,6 +312,8 @@ struct xhci_op_regs {
312#define XDEV_U2 (0x2 << 5) 312#define XDEV_U2 (0x2 << 5)
313#define XDEV_U3 (0x3 << 5) 313#define XDEV_U3 (0x3 << 5)
314#define XDEV_INACTIVE (0x6 << 5) 314#define XDEV_INACTIVE (0x6 << 5)
315#define XDEV_POLLING (0x7 << 5)
316#define XDEV_COMP_MODE (0xa << 5)
315#define XDEV_RESUME (0xf << 5) 317#define XDEV_RESUME (0xf << 5)
316/* true: port has power (see HCC_PPC) */ 318/* true: port has power (see HCC_PPC) */
317#define PORT_POWER (1 << 9) 319#define PORT_POWER (1 << 9)
@@ -1550,7 +1552,8 @@ struct xhci_hcd {
1550#define CMD_RING_STATE_STOPPED (1 << 2) 1552#define CMD_RING_STATE_STOPPED (1 << 2)
1551 struct list_head cmd_list; 1553 struct list_head cmd_list;
1552 unsigned int cmd_ring_reserved_trbs; 1554 unsigned int cmd_ring_reserved_trbs;
1553 struct timer_list cmd_timer; 1555 struct delayed_work cmd_timer;
1556 struct completion cmd_ring_stop_completion;
1554 struct xhci_command *current_cmd; 1557 struct xhci_command *current_cmd;
1555 struct xhci_ring *event_ring; 1558 struct xhci_ring *event_ring;
1556 struct xhci_erst erst; 1559 struct xhci_erst erst;
@@ -1633,6 +1636,7 @@ struct xhci_hcd {
1633#define XHCI_PME_STUCK_QUIRK (1 << 20) 1636#define XHCI_PME_STUCK_QUIRK (1 << 20)
1634/* For controller with a broken Port Disable implementation */ 1637/* For controller with a broken Port Disable implementation */
1635#define XHCI_BROKEN_PORT_PE (1 << 21) 1638#define XHCI_BROKEN_PORT_PE (1 << 21)
1639#define XHCI_MISSING_CAS (1 << 24)
1636 unsigned int num_active_eps; 1640 unsigned int num_active_eps;
1637 unsigned int limit_active_eps; 1641 unsigned int limit_active_eps;
1638 /* There are two roothubs to keep track of bus suspend info for */ 1642 /* There are two roothubs to keep track of bus suspend info for */
@@ -1914,7 +1918,7 @@ void xhci_queue_config_ep_quirk(struct xhci_hcd *xhci,
1914 unsigned int slot_id, unsigned int ep_index, 1918 unsigned int slot_id, unsigned int ep_index,
1915 struct xhci_dequeue_state *deq_state); 1919 struct xhci_dequeue_state *deq_state);
1916void xhci_stop_endpoint_command_watchdog(unsigned long arg); 1920void xhci_stop_endpoint_command_watchdog(unsigned long arg);
1917void xhci_handle_command_timeout(unsigned long data); 1921void xhci_handle_command_timeout(struct work_struct *work);
1918 1922
1919void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id, 1923void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id,
1920 unsigned int ep_index, unsigned int stream_id); 1924 unsigned int ep_index, unsigned int stream_id);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 310238c6b5cd..896798071817 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -469,6 +469,7 @@ static const struct musb_platform_ops bfin_ops = {
469 .init = bfin_musb_init, 469 .init = bfin_musb_init,
470 .exit = bfin_musb_exit, 470 .exit = bfin_musb_exit,
471 471
472 .fifo_offset = bfin_fifo_offset,
472 .readb = bfin_readb, 473 .readb = bfin_readb,
473 .writeb = bfin_writeb, 474 .writeb = bfin_writeb,
474 .readw = bfin_readw, 475 .readw = bfin_readw,
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 2337d7a7d62d..90de7900e4b8 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -214,6 +214,7 @@ struct musb_platform_ops {
214 dma_addr_t *dma_addr, u32 *len); 214 dma_addr_t *dma_addr, u32 *len);
215 void (*pre_root_reset_end)(struct musb *musb); 215 void (*pre_root_reset_end)(struct musb *musb);
216 void (*post_root_reset_end)(struct musb *musb); 216 void (*post_root_reset_end)(struct musb *musb);
217 void (*clear_ep_rxintr)(struct musb *musb, int epnum);
217}; 218};
218 219
219/* 220/*
@@ -612,4 +613,10 @@ static inline void musb_platform_post_root_reset_end(struct musb *musb)
612 musb->ops->post_root_reset_end(musb); 613 musb->ops->post_root_reset_end(musb);
613} 614}
614 615
616static inline void musb_platform_clear_ep_rxintr(struct musb *musb, int epnum)
617{
618 if (musb->ops->clear_ep_rxintr)
619 musb->ops->clear_ep_rxintr(musb, epnum);
620}
621
615#endif /* __MUSB_CORE_H__ */ 622#endif /* __MUSB_CORE_H__ */
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index eeb7d9ecf7df..5a021b26d7d2 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -301,6 +301,17 @@ static void otg_timer(unsigned long _musb)
301 spin_unlock_irqrestore(&musb->lock, flags); 301 spin_unlock_irqrestore(&musb->lock, flags);
302} 302}
303 303
304void dsps_musb_clear_ep_rxintr(struct musb *musb, int epnum)
305{
306 u32 epintr;
307 struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent);
308 const struct dsps_musb_wrapper *wrp = glue->wrp;
309
310 /* musb->lock might already been held */
311 epintr = (1 << epnum) << wrp->rxep_shift;
312 musb_writel(musb->ctrl_base, wrp->epintr_status, epintr);
313}
314
304static irqreturn_t dsps_interrupt(int irq, void *hci) 315static irqreturn_t dsps_interrupt(int irq, void *hci)
305{ 316{
306 struct musb *musb = hci; 317 struct musb *musb = hci;
@@ -647,6 +658,7 @@ static struct musb_platform_ops dsps_ops = {
647 .try_idle = dsps_musb_try_idle, 658 .try_idle = dsps_musb_try_idle,
648 .set_mode = dsps_musb_set_mode, 659 .set_mode = dsps_musb_set_mode,
649 .recover = dsps_musb_recover, 660 .recover = dsps_musb_recover,
661 .clear_ep_rxintr = dsps_musb_clear_ep_rxintr,
650}; 662};
651 663
652static u64 musb_dmamask = DMA_BIT_MASK(32); 664static u64 musb_dmamask = DMA_BIT_MASK(32);
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 09b7fbe2b307..fc25a140548a 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2399,12 +2399,11 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
2399 int is_in = usb_pipein(urb->pipe); 2399 int is_in = usb_pipein(urb->pipe);
2400 int status = 0; 2400 int status = 0;
2401 u16 csr; 2401 u16 csr;
2402 struct dma_channel *dma = NULL;
2402 2403
2403 musb_ep_select(regs, hw_end); 2404 musb_ep_select(regs, hw_end);
2404 2405
2405 if (is_dma_capable()) { 2406 if (is_dma_capable()) {
2406 struct dma_channel *dma;
2407
2408 dma = is_in ? ep->rx_channel : ep->tx_channel; 2407 dma = is_in ? ep->rx_channel : ep->tx_channel;
2409 if (dma) { 2408 if (dma) {
2410 status = ep->musb->dma_controller->channel_abort(dma); 2409 status = ep->musb->dma_controller->channel_abort(dma);
@@ -2421,10 +2420,9 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
2421 /* giveback saves bulk toggle */ 2420 /* giveback saves bulk toggle */
2422 csr = musb_h_flush_rxfifo(ep, 0); 2421 csr = musb_h_flush_rxfifo(ep, 0);
2423 2422
2424 /* REVISIT we still get an irq; should likely clear the 2423 /* clear the endpoint's irq status here to avoid bogus irqs */
2425 * endpoint's irq status here to avoid bogus irqs. 2424 if (is_dma_capable() && dma)
2426 * clearing that status is platform-specific... 2425 musb_platform_clear_ep_rxintr(musb, ep->epnum);
2427 */
2428 } else if (ep->epnum) { 2426 } else if (ep->epnum) {
2429 musb_h_tx_flush_fifo(ep); 2427 musb_h_tx_flush_fifo(ep);
2430 csr = musb_readw(epio, MUSB_TXCSR); 2428 csr = musb_readw(epio, MUSB_TXCSR);
diff --git a/drivers/usb/musb/musbhsdma.h b/drivers/usb/musb/musbhsdma.h
index f7b13fd25257..a3dcbd55e436 100644
--- a/drivers/usb/musb/musbhsdma.h
+++ b/drivers/usb/musb/musbhsdma.h
@@ -157,5 +157,5 @@ struct musb_dma_controller {
157 void __iomem *base; 157 void __iomem *base;
158 u8 channel_count; 158 u8 channel_count;
159 u8 used_channels; 159 u8 used_channels;
160 u8 irq; 160 int irq;
161}; 161};
diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c
index 42a1afe36a90..5f5f19813fde 100644
--- a/drivers/usb/phy/phy-am335x-control.c
+++ b/drivers/usb/phy/phy-am335x-control.c
@@ -134,10 +134,12 @@ struct phy_control *am335x_get_phy_control(struct device *dev)
134 return NULL; 134 return NULL;
135 135
136 dev = bus_find_device(&platform_bus_type, NULL, node, match); 136 dev = bus_find_device(&platform_bus_type, NULL, node, match);
137 of_node_put(node);
137 if (!dev) 138 if (!dev)
138 return NULL; 139 return NULL;
139 140
140 ctrl_usb = dev_get_drvdata(dev); 141 ctrl_usb = dev_get_drvdata(dev);
142 put_device(dev);
141 if (!ctrl_usb) 143 if (!ctrl_usb)
142 return NULL; 144 return NULL;
143 return &ctrl_usb->phy_ctrl; 145 return &ctrl_usb->phy_ctrl;
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 2916dea3ede8..8948f375e75d 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -50,6 +50,7 @@
50#define CYBERJACK_PRODUCT_ID 0x0100 50#define CYBERJACK_PRODUCT_ID 0x0100
51 51
52/* Function prototypes */ 52/* Function prototypes */
53static int cyberjack_attach(struct usb_serial *serial);
53static int cyberjack_port_probe(struct usb_serial_port *port); 54static int cyberjack_port_probe(struct usb_serial_port *port);
54static int cyberjack_port_remove(struct usb_serial_port *port); 55static int cyberjack_port_remove(struct usb_serial_port *port);
55static int cyberjack_open(struct tty_struct *tty, 56static int cyberjack_open(struct tty_struct *tty,
@@ -77,6 +78,7 @@ static struct usb_serial_driver cyberjack_device = {
77 .description = "Reiner SCT Cyberjack USB card reader", 78 .description = "Reiner SCT Cyberjack USB card reader",
78 .id_table = id_table, 79 .id_table = id_table,
79 .num_ports = 1, 80 .num_ports = 1,
81 .attach = cyberjack_attach,
80 .port_probe = cyberjack_port_probe, 82 .port_probe = cyberjack_port_probe,
81 .port_remove = cyberjack_port_remove, 83 .port_remove = cyberjack_port_remove,
82 .open = cyberjack_open, 84 .open = cyberjack_open,
@@ -100,6 +102,14 @@ struct cyberjack_private {
100 short wrsent; /* Data already sent */ 102 short wrsent; /* Data already sent */
101}; 103};
102 104
105static int cyberjack_attach(struct usb_serial *serial)
106{
107 if (serial->num_bulk_out < serial->num_ports)
108 return -ENODEV;
109
110 return 0;
111}
112
103static int cyberjack_port_probe(struct usb_serial_port *port) 113static int cyberjack_port_probe(struct usb_serial_port *port)
104{ 114{
105 struct cyberjack_private *priv; 115 struct cyberjack_private *priv;
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index db591d19d416..37d0e8cc7af6 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1044,6 +1044,7 @@ static int garmin_write_bulk(struct usb_serial_port *port,
1044 "%s - usb_submit_urb(write bulk) failed with status = %d\n", 1044 "%s - usb_submit_urb(write bulk) failed with status = %d\n",
1045 __func__, status); 1045 __func__, status);
1046 count = status; 1046 count = status;
1047 kfree(buffer);
1047 } 1048 }
1048 1049
1049 /* we are done with this urb, so let the host driver 1050 /* we are done with this urb, so let the host driver
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 1947ea0e0988..b63a6c3899c5 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -2761,6 +2761,11 @@ static int edge_startup(struct usb_serial *serial)
2761 EDGE_COMPATIBILITY_MASK1, 2761 EDGE_COMPATIBILITY_MASK1,
2762 EDGE_COMPATIBILITY_MASK2 }; 2762 EDGE_COMPATIBILITY_MASK2 };
2763 2763
2764 if (serial->num_bulk_in < 1 || serial->num_interrupt_in < 1) {
2765 dev_err(&serial->interface->dev, "missing endpoints\n");
2766 return -ENODEV;
2767 }
2768
2764 dev = serial->dev; 2769 dev = serial->dev;
2765 2770
2766 /* create our private serial structure */ 2771 /* create our private serial structure */
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index fce82fd79f77..c02808a30436 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -1499,8 +1499,7 @@ static int do_boot_mode(struct edgeport_serial *serial,
1499 1499
1500 dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__); 1500 dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__);
1501 1501
1502 /* return an error on purpose */ 1502 return 1;
1503 return -ENODEV;
1504 } 1503 }
1505 1504
1506stayinbootmode: 1505stayinbootmode:
@@ -1508,7 +1507,7 @@ stayinbootmode:
1508 dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__); 1507 dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__);
1509 serial->product_info.TiMode = TI_MODE_BOOT; 1508 serial->product_info.TiMode = TI_MODE_BOOT;
1510 1509
1511 return 0; 1510 return 1;
1512} 1511}
1513 1512
1514static int ti_do_config(struct edgeport_port *port, int feature, int on) 1513static int ti_do_config(struct edgeport_port *port, int feature, int on)
@@ -2549,6 +2548,13 @@ static int edge_startup(struct usb_serial *serial)
2549 int status; 2548 int status;
2550 u16 product_id; 2549 u16 product_id;
2551 2550
2551 /* Make sure we have the required endpoints when in download mode. */
2552 if (serial->interface->cur_altsetting->desc.bNumEndpoints > 1) {
2553 if (serial->num_bulk_in < serial->num_ports ||
2554 serial->num_bulk_out < serial->num_ports)
2555 return -ENODEV;
2556 }
2557
2552 /* create our private serial structure */ 2558 /* create our private serial structure */
2553 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); 2559 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
2554 if (!edge_serial) 2560 if (!edge_serial)
@@ -2556,14 +2562,18 @@ static int edge_startup(struct usb_serial *serial)
2556 2562
2557 mutex_init(&edge_serial->es_lock); 2563 mutex_init(&edge_serial->es_lock);
2558 edge_serial->serial = serial; 2564 edge_serial->serial = serial;
2565 INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work);
2559 usb_set_serial_data(serial, edge_serial); 2566 usb_set_serial_data(serial, edge_serial);
2560 2567
2561 status = download_fw(edge_serial); 2568 status = download_fw(edge_serial);
2562 if (status) { 2569 if (status < 0) {
2563 kfree(edge_serial); 2570 kfree(edge_serial);
2564 return status; 2571 return status;
2565 } 2572 }
2566 2573
2574 if (status > 0)
2575 return 1; /* bind but do not register any ports */
2576
2567 product_id = le16_to_cpu( 2577 product_id = le16_to_cpu(
2568 edge_serial->serial->dev->descriptor.idProduct); 2578 edge_serial->serial->dev->descriptor.idProduct);
2569 2579
@@ -2575,7 +2585,6 @@ static int edge_startup(struct usb_serial *serial)
2575 } 2585 }
2576 } 2586 }
2577 2587
2578 INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work);
2579 edge_heartbeat_schedule(edge_serial); 2588 edge_heartbeat_schedule(edge_serial);
2580 2589
2581 return 0; 2590 return 0;
@@ -2583,6 +2592,9 @@ static int edge_startup(struct usb_serial *serial)
2583 2592
2584static void edge_disconnect(struct usb_serial *serial) 2593static void edge_disconnect(struct usb_serial *serial)
2585{ 2594{
2595 struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
2596
2597 cancel_delayed_work_sync(&edge_serial->heartbeat_work);
2586} 2598}
2587 2599
2588static void edge_release(struct usb_serial *serial) 2600static void edge_release(struct usb_serial *serial)
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 5ad4a0fb4b26..7ed7d33d6c10 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -68,6 +68,16 @@ struct iuu_private {
68 u32 clk; 68 u32 clk;
69}; 69};
70 70
71static int iuu_attach(struct usb_serial *serial)
72{
73 unsigned char num_ports = serial->num_ports;
74
75 if (serial->num_bulk_in < num_ports || serial->num_bulk_out < num_ports)
76 return -ENODEV;
77
78 return 0;
79}
80
71static int iuu_port_probe(struct usb_serial_port *port) 81static int iuu_port_probe(struct usb_serial_port *port)
72{ 82{
73 struct iuu_private *priv; 83 struct iuu_private *priv;
@@ -1196,6 +1206,7 @@ static struct usb_serial_driver iuu_device = {
1196 .tiocmset = iuu_tiocmset, 1206 .tiocmset = iuu_tiocmset,
1197 .set_termios = iuu_set_termios, 1207 .set_termios = iuu_set_termios,
1198 .init_termios = iuu_init_termios, 1208 .init_termios = iuu_init_termios,
1209 .attach = iuu_attach,
1199 .port_probe = iuu_port_probe, 1210 .port_probe = iuu_port_probe,
1200 .port_remove = iuu_port_remove, 1211 .port_remove = iuu_port_remove,
1201}; 1212};
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 4f7e072e4e00..930be98d59b3 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -699,6 +699,19 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw");
699MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw"); 699MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
700#endif 700#endif
701 701
702static int keyspan_pda_attach(struct usb_serial *serial)
703{
704 unsigned char num_ports = serial->num_ports;
705
706 if (serial->num_bulk_out < num_ports ||
707 serial->num_interrupt_in < num_ports) {
708 dev_err(&serial->interface->dev, "missing endpoints\n");
709 return -ENODEV;
710 }
711
712 return 0;
713}
714
702static int keyspan_pda_port_probe(struct usb_serial_port *port) 715static int keyspan_pda_port_probe(struct usb_serial_port *port)
703{ 716{
704 717
@@ -776,6 +789,7 @@ static struct usb_serial_driver keyspan_pda_device = {
776 .break_ctl = keyspan_pda_break_ctl, 789 .break_ctl = keyspan_pda_break_ctl,
777 .tiocmget = keyspan_pda_tiocmget, 790 .tiocmget = keyspan_pda_tiocmget,
778 .tiocmset = keyspan_pda_tiocmset, 791 .tiocmset = keyspan_pda_tiocmset,
792 .attach = keyspan_pda_attach,
779 .port_probe = keyspan_pda_port_probe, 793 .port_probe = keyspan_pda_port_probe,
780 .port_remove = keyspan_pda_port_remove, 794 .port_remove = keyspan_pda_port_remove,
781}; 795};
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 53c90131764d..cd0322502ab1 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -311,6 +311,7 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
311 if (rc < 0) { 311 if (rc < 0) {
312 dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc); 312 dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc);
313 retval = rc; 313 retval = rc;
314 goto err_generic_close;
314 } else 315 } else
315 dev_dbg(&port->dev, "%s - enabled reading\n", __func__); 316 dev_dbg(&port->dev, "%s - enabled reading\n", __func__);
316 317
@@ -337,6 +338,7 @@ err_disable_read:
337 0, /* index */ 338 0, /* index */
338 NULL, 0, 339 NULL, 0,
339 KLSI_TIMEOUT); 340 KLSI_TIMEOUT);
341err_generic_close:
340 usb_serial_generic_close(port); 342 usb_serial_generic_close(port);
341err_free_cfg: 343err_free_cfg:
342 kfree(cfg); 344 kfree(cfg);
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 2363654cafc9..813035f51fe7 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -51,6 +51,7 @@
51 51
52 52
53/* Function prototypes */ 53/* Function prototypes */
54static int kobil_attach(struct usb_serial *serial);
54static int kobil_port_probe(struct usb_serial_port *probe); 55static int kobil_port_probe(struct usb_serial_port *probe);
55static int kobil_port_remove(struct usb_serial_port *probe); 56static int kobil_port_remove(struct usb_serial_port *probe);
56static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); 57static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
@@ -86,6 +87,7 @@ static struct usb_serial_driver kobil_device = {
86 .description = "KOBIL USB smart card terminal", 87 .description = "KOBIL USB smart card terminal",
87 .id_table = id_table, 88 .id_table = id_table,
88 .num_ports = 1, 89 .num_ports = 1,
90 .attach = kobil_attach,
89 .port_probe = kobil_port_probe, 91 .port_probe = kobil_port_probe,
90 .port_remove = kobil_port_remove, 92 .port_remove = kobil_port_remove,
91 .ioctl = kobil_ioctl, 93 .ioctl = kobil_ioctl,
@@ -113,6 +115,16 @@ struct kobil_private {
113}; 115};
114 116
115 117
118static int kobil_attach(struct usb_serial *serial)
119{
120 if (serial->num_interrupt_out < serial->num_ports) {
121 dev_err(&serial->interface->dev, "missing interrupt-out endpoint\n");
122 return -ENODEV;
123 }
124
125 return 0;
126}
127
116static int kobil_port_probe(struct usb_serial_port *port) 128static int kobil_port_probe(struct usb_serial_port *port)
117{ 129{
118 struct usb_serial *serial = port->serial; 130 struct usb_serial *serial = port->serial;
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 63db004af21f..e56cdb436de3 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -65,8 +65,6 @@ struct moschip_port {
65 struct urb *write_urb_pool[NUM_URBS]; 65 struct urb *write_urb_pool[NUM_URBS];
66}; 66};
67 67
68static struct usb_serial_driver moschip7720_2port_driver;
69
70#define USB_VENDOR_ID_MOSCHIP 0x9710 68#define USB_VENDOR_ID_MOSCHIP 0x9710
71#define MOSCHIP_DEVICE_ID_7720 0x7720 69#define MOSCHIP_DEVICE_ID_7720 0x7720
72#define MOSCHIP_DEVICE_ID_7715 0x7715 70#define MOSCHIP_DEVICE_ID_7715 0x7715
@@ -970,25 +968,6 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
970 tty_port_tty_wakeup(&mos7720_port->port->port); 968 tty_port_tty_wakeup(&mos7720_port->port->port);
971} 969}
972 970
973/*
974 * mos77xx_probe
975 * this function installs the appropriate read interrupt endpoint callback
976 * depending on whether the device is a 7720 or 7715, thus avoiding costly
977 * run-time checks in the high-frequency callback routine itself.
978 */
979static int mos77xx_probe(struct usb_serial *serial,
980 const struct usb_device_id *id)
981{
982 if (id->idProduct == MOSCHIP_DEVICE_ID_7715)
983 moschip7720_2port_driver.read_int_callback =
984 mos7715_interrupt_callback;
985 else
986 moschip7720_2port_driver.read_int_callback =
987 mos7720_interrupt_callback;
988
989 return 0;
990}
991
992static int mos77xx_calc_num_ports(struct usb_serial *serial) 971static int mos77xx_calc_num_ports(struct usb_serial *serial)
993{ 972{
994 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 973 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
@@ -1920,6 +1899,11 @@ static int mos7720_startup(struct usb_serial *serial)
1920 u16 product; 1899 u16 product;
1921 int ret_val; 1900 int ret_val;
1922 1901
1902 if (serial->num_bulk_in < 2 || serial->num_bulk_out < 2) {
1903 dev_err(&serial->interface->dev, "missing bulk endpoints\n");
1904 return -ENODEV;
1905 }
1906
1923 product = le16_to_cpu(serial->dev->descriptor.idProduct); 1907 product = le16_to_cpu(serial->dev->descriptor.idProduct);
1924 dev = serial->dev; 1908 dev = serial->dev;
1925 1909
@@ -1944,19 +1928,18 @@ static int mos7720_startup(struct usb_serial *serial)
1944 tmp->interrupt_in_endpointAddress; 1928 tmp->interrupt_in_endpointAddress;
1945 serial->port[1]->interrupt_in_urb = NULL; 1929 serial->port[1]->interrupt_in_urb = NULL;
1946 serial->port[1]->interrupt_in_buffer = NULL; 1930 serial->port[1]->interrupt_in_buffer = NULL;
1931
1932 if (serial->port[0]->interrupt_in_urb) {
1933 struct urb *urb = serial->port[0]->interrupt_in_urb;
1934
1935 urb->complete = mos7715_interrupt_callback;
1936 }
1947 } 1937 }
1948 1938
1949 /* setting configuration feature to one */ 1939 /* setting configuration feature to one */
1950 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 1940 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
1951 (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000); 1941 (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000);
1952 1942
1953 /* start the interrupt urb */
1954 ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL);
1955 if (ret_val)
1956 dev_err(&dev->dev,
1957 "%s - Error %d submitting control urb\n",
1958 __func__, ret_val);
1959
1960#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT 1943#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
1961 if (product == MOSCHIP_DEVICE_ID_7715) { 1944 if (product == MOSCHIP_DEVICE_ID_7715) {
1962 ret_val = mos7715_parport_init(serial); 1945 ret_val = mos7715_parport_init(serial);
@@ -1964,6 +1947,13 @@ static int mos7720_startup(struct usb_serial *serial)
1964 return ret_val; 1947 return ret_val;
1965 } 1948 }
1966#endif 1949#endif
1950 /* start the interrupt urb */
1951 ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL);
1952 if (ret_val) {
1953 dev_err(&dev->dev, "failed to submit interrupt urb: %d\n",
1954 ret_val);
1955 }
1956
1967 /* LSR For Port 1 */ 1957 /* LSR For Port 1 */
1968 read_mos_reg(serial, 0, MOS7720_LSR, &data); 1958 read_mos_reg(serial, 0, MOS7720_LSR, &data);
1969 dev_dbg(&dev->dev, "LSR:%x\n", data); 1959 dev_dbg(&dev->dev, "LSR:%x\n", data);
@@ -1973,6 +1963,8 @@ static int mos7720_startup(struct usb_serial *serial)
1973 1963
1974static void mos7720_release(struct usb_serial *serial) 1964static void mos7720_release(struct usb_serial *serial)
1975{ 1965{
1966 usb_kill_urb(serial->port[0]->interrupt_in_urb);
1967
1976#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT 1968#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
1977 /* close the parallel port */ 1969 /* close the parallel port */
1978 1970
@@ -2056,7 +2048,6 @@ static struct usb_serial_driver moschip7720_2port_driver = {
2056 .close = mos7720_close, 2048 .close = mos7720_close,
2057 .throttle = mos7720_throttle, 2049 .throttle = mos7720_throttle,
2058 .unthrottle = mos7720_unthrottle, 2050 .unthrottle = mos7720_unthrottle,
2059 .probe = mos77xx_probe,
2060 .attach = mos7720_startup, 2051 .attach = mos7720_startup,
2061 .release = mos7720_release, 2052 .release = mos7720_release,
2062 .port_probe = mos7720_port_probe, 2053 .port_probe = mos7720_port_probe,
@@ -2070,7 +2061,7 @@ static struct usb_serial_driver moschip7720_2port_driver = {
2070 .chars_in_buffer = mos7720_chars_in_buffer, 2061 .chars_in_buffer = mos7720_chars_in_buffer,
2071 .break_ctl = mos7720_break, 2062 .break_ctl = mos7720_break,
2072 .read_bulk_callback = mos7720_bulk_in_callback, 2063 .read_bulk_callback = mos7720_bulk_in_callback,
2073 .read_int_callback = NULL /* dynamically assigned in probe() */ 2064 .read_int_callback = mos7720_interrupt_callback,
2074}; 2065};
2075 2066
2076static struct usb_serial_driver * const serial_drivers[] = { 2067static struct usb_serial_driver * const serial_drivers[] = {
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 7f3ddd7ba2ce..97ea52b5cfd4 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2116,6 +2116,17 @@ static int mos7840_calc_num_ports(struct usb_serial *serial)
2116 return mos7840_num_ports; 2116 return mos7840_num_ports;
2117} 2117}
2118 2118
2119static int mos7840_attach(struct usb_serial *serial)
2120{
2121 if (serial->num_bulk_in < serial->num_ports ||
2122 serial->num_bulk_out < serial->num_ports) {
2123 dev_err(&serial->interface->dev, "missing endpoints\n");
2124 return -ENODEV;
2125 }
2126
2127 return 0;
2128}
2129
2119static int mos7840_port_probe(struct usb_serial_port *port) 2130static int mos7840_port_probe(struct usb_serial_port *port)
2120{ 2131{
2121 struct usb_serial *serial = port->serial; 2132 struct usb_serial *serial = port->serial;
@@ -2391,6 +2402,7 @@ static struct usb_serial_driver moschip7840_4port_device = {
2391 .tiocmset = mos7840_tiocmset, 2402 .tiocmset = mos7840_tiocmset,
2392 .tiocmiwait = usb_serial_generic_tiocmiwait, 2403 .tiocmiwait = usb_serial_generic_tiocmiwait,
2393 .get_icount = usb_serial_generic_get_icount, 2404 .get_icount = usb_serial_generic_get_icount,
2405 .attach = mos7840_attach,
2394 .port_probe = mos7840_port_probe, 2406 .port_probe = mos7840_port_probe,
2395 .port_remove = mos7840_port_remove, 2407 .port_remove = mos7840_port_remove,
2396 .read_bulk_callback = mos7840_bulk_in_callback, 2408 .read_bulk_callback = mos7840_bulk_in_callback,
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index f6c6900bccf0..a180b17d2432 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -38,6 +38,7 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
38 const unsigned char *buf, int count); 38 const unsigned char *buf, int count);
39static int omninet_write_room(struct tty_struct *tty); 39static int omninet_write_room(struct tty_struct *tty);
40static void omninet_disconnect(struct usb_serial *serial); 40static void omninet_disconnect(struct usb_serial *serial);
41static int omninet_attach(struct usb_serial *serial);
41static int omninet_port_probe(struct usb_serial_port *port); 42static int omninet_port_probe(struct usb_serial_port *port);
42static int omninet_port_remove(struct usb_serial_port *port); 43static int omninet_port_remove(struct usb_serial_port *port);
43 44
@@ -56,6 +57,7 @@ static struct usb_serial_driver zyxel_omninet_device = {
56 .description = "ZyXEL - omni.net lcd plus usb", 57 .description = "ZyXEL - omni.net lcd plus usb",
57 .id_table = id_table, 58 .id_table = id_table,
58 .num_ports = 1, 59 .num_ports = 1,
60 .attach = omninet_attach,
59 .port_probe = omninet_port_probe, 61 .port_probe = omninet_port_probe,
60 .port_remove = omninet_port_remove, 62 .port_remove = omninet_port_remove,
61 .open = omninet_open, 63 .open = omninet_open,
@@ -104,6 +106,17 @@ struct omninet_data {
104 __u8 od_outseq; /* Sequence number for bulk_out URBs */ 106 __u8 od_outseq; /* Sequence number for bulk_out URBs */
105}; 107};
106 108
109static int omninet_attach(struct usb_serial *serial)
110{
111 /* The second bulk-out endpoint is used for writing. */
112 if (serial->num_bulk_out < 2) {
113 dev_err(&serial->interface->dev, "missing endpoints\n");
114 return -ENODEV;
115 }
116
117 return 0;
118}
119
107static int omninet_port_probe(struct usb_serial_port *port) 120static int omninet_port_probe(struct usb_serial_port *port)
108{ 121{
109 struct omninet_data *od; 122 struct omninet_data *od;
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index a4b88bc038b6..b8bf52bf7a94 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -134,6 +134,7 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty);
134static int oti6858_tiocmget(struct tty_struct *tty); 134static int oti6858_tiocmget(struct tty_struct *tty);
135static int oti6858_tiocmset(struct tty_struct *tty, 135static int oti6858_tiocmset(struct tty_struct *tty,
136 unsigned int set, unsigned int clear); 136 unsigned int set, unsigned int clear);
137static int oti6858_attach(struct usb_serial *serial);
137static int oti6858_port_probe(struct usb_serial_port *port); 138static int oti6858_port_probe(struct usb_serial_port *port);
138static int oti6858_port_remove(struct usb_serial_port *port); 139static int oti6858_port_remove(struct usb_serial_port *port);
139 140
@@ -158,6 +159,7 @@ static struct usb_serial_driver oti6858_device = {
158 .write_bulk_callback = oti6858_write_bulk_callback, 159 .write_bulk_callback = oti6858_write_bulk_callback,
159 .write_room = oti6858_write_room, 160 .write_room = oti6858_write_room,
160 .chars_in_buffer = oti6858_chars_in_buffer, 161 .chars_in_buffer = oti6858_chars_in_buffer,
162 .attach = oti6858_attach,
161 .port_probe = oti6858_port_probe, 163 .port_probe = oti6858_port_probe,
162 .port_remove = oti6858_port_remove, 164 .port_remove = oti6858_port_remove,
163}; 165};
@@ -324,6 +326,20 @@ static void send_data(struct work_struct *work)
324 usb_serial_port_softint(port); 326 usb_serial_port_softint(port);
325} 327}
326 328
329static int oti6858_attach(struct usb_serial *serial)
330{
331 unsigned char num_ports = serial->num_ports;
332
333 if (serial->num_bulk_in < num_ports ||
334 serial->num_bulk_out < num_ports ||
335 serial->num_interrupt_in < num_ports) {
336 dev_err(&serial->interface->dev, "missing endpoints\n");
337 return -ENODEV;
338 }
339
340 return 0;
341}
342
327static int oti6858_port_probe(struct usb_serial_port *port) 343static int oti6858_port_probe(struct usb_serial_port *port)
328{ 344{
329 struct oti6858_private *priv; 345 struct oti6858_private *priv;
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index ae682e4eeaef..46fca6b75846 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -220,9 +220,17 @@ static int pl2303_probe(struct usb_serial *serial,
220static int pl2303_startup(struct usb_serial *serial) 220static int pl2303_startup(struct usb_serial *serial)
221{ 221{
222 struct pl2303_serial_private *spriv; 222 struct pl2303_serial_private *spriv;
223 unsigned char num_ports = serial->num_ports;
223 enum pl2303_type type = TYPE_01; 224 enum pl2303_type type = TYPE_01;
224 unsigned char *buf; 225 unsigned char *buf;
225 226
227 if (serial->num_bulk_in < num_ports ||
228 serial->num_bulk_out < num_ports ||
229 serial->num_interrupt_in < num_ports) {
230 dev_err(&serial->interface->dev, "missing endpoints\n");
231 return -ENODEV;
232 }
233
226 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); 234 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
227 if (!spriv) 235 if (!spriv)
228 return -ENOMEM; 236 return -ENOMEM;
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index b18974cbd995..a3ed07c58754 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -408,16 +408,12 @@ static void qt2_close(struct usb_serial_port *port)
408{ 408{
409 struct usb_serial *serial; 409 struct usb_serial *serial;
410 struct qt2_port_private *port_priv; 410 struct qt2_port_private *port_priv;
411 unsigned long flags;
412 int i; 411 int i;
413 412
414 serial = port->serial; 413 serial = port->serial;
415 port_priv = usb_get_serial_port_data(port); 414 port_priv = usb_get_serial_port_data(port);
416 415
417 spin_lock_irqsave(&port_priv->urb_lock, flags);
418 usb_kill_urb(port_priv->write_urb); 416 usb_kill_urb(port_priv->write_urb);
419 port_priv->urb_in_use = false;
420 spin_unlock_irqrestore(&port_priv->urb_lock, flags);
421 417
422 /* flush the port transmit buffer */ 418 /* flush the port transmit buffer */
423 i = usb_control_msg(serial->dev, 419 i = usb_control_msg(serial->dev,
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index ef0dbf0703c5..475e6c31b266 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -154,6 +154,19 @@ static int spcp8x5_probe(struct usb_serial *serial,
154 return 0; 154 return 0;
155} 155}
156 156
157static int spcp8x5_attach(struct usb_serial *serial)
158{
159 unsigned char num_ports = serial->num_ports;
160
161 if (serial->num_bulk_in < num_ports ||
162 serial->num_bulk_out < num_ports) {
163 dev_err(&serial->interface->dev, "missing endpoints\n");
164 return -ENODEV;
165 }
166
167 return 0;
168}
169
157static int spcp8x5_port_probe(struct usb_serial_port *port) 170static int spcp8x5_port_probe(struct usb_serial_port *port)
158{ 171{
159 const struct usb_device_id *id = usb_get_serial_data(port->serial); 172 const struct usb_device_id *id = usb_get_serial_data(port->serial);
@@ -477,6 +490,7 @@ static struct usb_serial_driver spcp8x5_device = {
477 .tiocmget = spcp8x5_tiocmget, 490 .tiocmget = spcp8x5_tiocmget,
478 .tiocmset = spcp8x5_tiocmset, 491 .tiocmset = spcp8x5_tiocmset,
479 .probe = spcp8x5_probe, 492 .probe = spcp8x5_probe,
493 .attach = spcp8x5_attach,
480 .port_probe = spcp8x5_port_probe, 494 .port_probe = spcp8x5_port_probe,
481 .port_remove = spcp8x5_port_remove, 495 .port_remove = spcp8x5_port_remove,
482}; 496};
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 2694df2f4559..535fcfafc097 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -339,6 +339,13 @@ static int ti_startup(struct usb_serial *serial)
339 goto free_tdev; 339 goto free_tdev;
340 } 340 }
341 341
342 if (serial->num_bulk_in < serial->num_ports ||
343 serial->num_bulk_out < serial->num_ports) {
344 dev_err(&serial->interface->dev, "missing endpoints\n");
345 status = -ENODEV;
346 goto free_tdev;
347 }
348
342 return 0; 349 return 0;
343 350
344free_tdev: 351free_tdev:
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 7ffe4209067b..640a2e2ec04d 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -2135,6 +2135,13 @@ UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001,
2135 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2135 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2136 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ), 2136 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ),
2137 2137
2138/* Reported-by George Cherian <george.cherian@cavium.com> */
2139UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999,
2140 "JMicron",
2141 "JMS56x",
2142 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2143 US_FL_NO_REPORT_OPCODES),
2144
2138/* 2145/*
2139 * Patch by Constantin Baranov <const@tltsu.ru> 2146 * Patch by Constantin Baranov <const@tltsu.ru>
2140 * Report by Andreas Koenecke. 2147 * Report by Andreas Koenecke.
diff --git a/include/linux/capability.h b/include/linux/capability.h
index 2654f75a4c46..b20ffe23a09b 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -40,8 +40,6 @@ struct inode;
40struct dentry; 40struct dentry;
41struct user_namespace; 41struct user_namespace;
42 42
43struct user_namespace *current_user_ns(void);
44
45extern const kernel_cap_t __cap_empty_set; 43extern const kernel_cap_t __cap_empty_set;
46extern const kernel_cap_t __cap_init_eff_set; 44extern const kernel_cap_t __cap_init_eff_set;
47 45
diff --git a/include/linux/cred.h b/include/linux/cred.h
index 8d70e1361ecd..257db64562e5 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -377,7 +377,10 @@ extern struct user_namespace init_user_ns;
377#ifdef CONFIG_USER_NS 377#ifdef CONFIG_USER_NS
378#define current_user_ns() (current_cred_xxx(user_ns)) 378#define current_user_ns() (current_cred_xxx(user_ns))
379#else 379#else
380#define current_user_ns() (&init_user_ns) 380static inline struct user_namespace *current_user_ns(void)
381{
382 return &init_user_ns;
383}
381#endif 384#endif
382 385
383 386
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9d6025703f73..93a6a2c66d15 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2325,14 +2325,19 @@ static inline int skb_gro_header_hard(struct sk_buff *skb, unsigned int hlen)
2325 return NAPI_GRO_CB(skb)->frag0_len < hlen; 2325 return NAPI_GRO_CB(skb)->frag0_len < hlen;
2326} 2326}
2327 2327
2328static inline void skb_gro_frag0_invalidate(struct sk_buff *skb)
2329{
2330 NAPI_GRO_CB(skb)->frag0 = NULL;
2331 NAPI_GRO_CB(skb)->frag0_len = 0;
2332}
2333
2328static inline void *skb_gro_header_slow(struct sk_buff *skb, unsigned int hlen, 2334static inline void *skb_gro_header_slow(struct sk_buff *skb, unsigned int hlen,
2329 unsigned int offset) 2335 unsigned int offset)
2330{ 2336{
2331 if (!pskb_may_pull(skb, hlen)) 2337 if (!pskb_may_pull(skb, hlen))
2332 return NULL; 2338 return NULL;
2333 2339
2334 NAPI_GRO_CB(skb)->frag0 = NULL; 2340 skb_gro_frag0_invalidate(skb);
2335 NAPI_GRO_CB(skb)->frag0_len = 0;
2336 return skb->data + offset; 2341 return skb->data + offset;
2337} 2342}
2338 2343
diff --git a/kernel/cpu.c b/kernel/cpu.c
index cd6d1258554e..40d20bf5de28 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -223,10 +223,6 @@ static int cpu_notify(unsigned long val, void *v)
223 return __cpu_notify(val, v, -1, NULL); 223 return __cpu_notify(val, v, -1, NULL);
224} 224}
225 225
226static void cpu_notify_nofail(unsigned long val, void *v)
227{
228 BUG_ON(cpu_notify(val, v));
229}
230EXPORT_SYMBOL(register_cpu_notifier); 226EXPORT_SYMBOL(register_cpu_notifier);
231EXPORT_SYMBOL(__register_cpu_notifier); 227EXPORT_SYMBOL(__register_cpu_notifier);
232 228
@@ -245,6 +241,11 @@ void __unregister_cpu_notifier(struct notifier_block *nb)
245EXPORT_SYMBOL(__unregister_cpu_notifier); 241EXPORT_SYMBOL(__unregister_cpu_notifier);
246 242
247#ifdef CONFIG_HOTPLUG_CPU 243#ifdef CONFIG_HOTPLUG_CPU
244static void cpu_notify_nofail(unsigned long val, void *v)
245{
246 BUG_ON(cpu_notify(val, v));
247}
248
248/** 249/**
249 * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU 250 * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU
250 * @cpu: a CPU id 251 * @cpu: a CPU id
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index f6aae7977824..d2a20e83ebae 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -871,6 +871,9 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
871{ 871{
872 int cpu = smp_processor_id(); 872 int cpu = smp_processor_id();
873 873
874 if (!bc)
875 return;
876
874 /* Set it up only once ! */ 877 /* Set it up only once ! */
875 if (bc->event_handler != tick_handle_oneshot_broadcast) { 878 if (bc->event_handler != tick_handle_oneshot_broadcast) {
876 int was_periodic = clockevent_state_periodic(bc); 879 int was_periodic = clockevent_state_periodic(bc);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b0ca09f607b4..ad092093e101 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5689,15 +5689,18 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn)
5689 sizeof(arch_zone_lowest_possible_pfn)); 5689 sizeof(arch_zone_lowest_possible_pfn));
5690 memset(arch_zone_highest_possible_pfn, 0, 5690 memset(arch_zone_highest_possible_pfn, 0,
5691 sizeof(arch_zone_highest_possible_pfn)); 5691 sizeof(arch_zone_highest_possible_pfn));
5692 arch_zone_lowest_possible_pfn[0] = find_min_pfn_with_active_regions(); 5692
5693 arch_zone_highest_possible_pfn[0] = max_zone_pfn[0]; 5693 start_pfn = find_min_pfn_with_active_regions();
5694 for (i = 1; i < MAX_NR_ZONES; i++) { 5694
5695 for (i = 0; i < MAX_NR_ZONES; i++) {
5695 if (i == ZONE_MOVABLE) 5696 if (i == ZONE_MOVABLE)
5696 continue; 5697 continue;
5697 arch_zone_lowest_possible_pfn[i] = 5698
5698 arch_zone_highest_possible_pfn[i-1]; 5699 end_pfn = max(max_zone_pfn[i], start_pfn);
5699 arch_zone_highest_possible_pfn[i] = 5700 arch_zone_lowest_possible_pfn[i] = start_pfn;
5700 max(max_zone_pfn[i], arch_zone_lowest_possible_pfn[i]); 5701 arch_zone_highest_possible_pfn[i] = end_pfn;
5702
5703 start_pfn = end_pfn;
5701 } 5704 }
5702 arch_zone_lowest_possible_pfn[ZONE_MOVABLE] = 0; 5705 arch_zone_lowest_possible_pfn[ZONE_MOVABLE] = 0;
5703 arch_zone_highest_possible_pfn[ZONE_MOVABLE] = 0; 5706 arch_zone_highest_possible_pfn[ZONE_MOVABLE] = 0;
diff --git a/net/core/dev.c b/net/core/dev.c
index 9ca749c81b6c..6f203c7fb166 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4187,7 +4187,9 @@ static void skb_gro_reset_offset(struct sk_buff *skb)
4187 pinfo->nr_frags && 4187 pinfo->nr_frags &&
4188 !PageHighMem(skb_frag_page(frag0))) { 4188 !PageHighMem(skb_frag_page(frag0))) {
4189 NAPI_GRO_CB(skb)->frag0 = skb_frag_address(frag0); 4189 NAPI_GRO_CB(skb)->frag0 = skb_frag_address(frag0);
4190 NAPI_GRO_CB(skb)->frag0_len = skb_frag_size(frag0); 4190 NAPI_GRO_CB(skb)->frag0_len = min_t(unsigned int,
4191 skb_frag_size(frag0),
4192 skb->end - skb->tail);
4191 } 4193 }
4192} 4194}
4193 4195
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 252e155c837b..a2270188b864 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -80,6 +80,7 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
80 struct nlattr *nla; 80 struct nlattr *nla;
81 struct sk_buff *skb; 81 struct sk_buff *skb;
82 unsigned long flags; 82 unsigned long flags;
83 void *msg_header;
83 84
84 al = sizeof(struct net_dm_alert_msg); 85 al = sizeof(struct net_dm_alert_msg);
85 al += dm_hit_limit * sizeof(struct net_dm_drop_point); 86 al += dm_hit_limit * sizeof(struct net_dm_drop_point);
@@ -87,21 +88,41 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
87 88
88 skb = genlmsg_new(al, GFP_KERNEL); 89 skb = genlmsg_new(al, GFP_KERNEL);
89 90
90 if (skb) { 91 if (!skb)
91 genlmsg_put(skb, 0, 0, &net_drop_monitor_family, 92 goto err;
92 0, NET_DM_CMD_ALERT); 93
93 nla = nla_reserve(skb, NLA_UNSPEC, 94 msg_header = genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
94 sizeof(struct net_dm_alert_msg)); 95 0, NET_DM_CMD_ALERT);
95 msg = nla_data(nla); 96 if (!msg_header) {
96 memset(msg, 0, al); 97 nlmsg_free(skb);
97 } else { 98 skb = NULL;
98 mod_timer(&data->send_timer, jiffies + HZ / 10); 99 goto err;
100 }
101 nla = nla_reserve(skb, NLA_UNSPEC,
102 sizeof(struct net_dm_alert_msg));
103 if (!nla) {
104 nlmsg_free(skb);
105 skb = NULL;
106 goto err;
99 } 107 }
108 msg = nla_data(nla);
109 memset(msg, 0, al);
110 goto out;
100 111
112err:
113 mod_timer(&data->send_timer, jiffies + HZ / 10);
114out:
101 spin_lock_irqsave(&data->lock, flags); 115 spin_lock_irqsave(&data->lock, flags);
102 swap(data->skb, skb); 116 swap(data->skb, skb);
103 spin_unlock_irqrestore(&data->lock, flags); 117 spin_unlock_irqrestore(&data->lock, flags);
104 118
119 if (skb) {
120 struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
121 struct genlmsghdr *gnlh = (struct genlmsghdr *)nlmsg_data(nlh);
122
123 genlmsg_end(skb, genlmsg_data(gnlh));
124 }
125
105 return skb; 126 return skb;
106} 127}
107 128
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 63566ec54794..4e60dae86df5 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -85,7 +85,7 @@ struct fib_table *fib_new_table(struct net *net, u32 id)
85 if (tb) 85 if (tb)
86 return tb; 86 return tb;
87 87
88 if (id == RT_TABLE_LOCAL) 88 if (id == RT_TABLE_LOCAL && !net->ipv4.fib_has_custom_rules)
89 alias = fib_new_table(net, RT_TABLE_MAIN); 89 alias = fib_new_table(net, RT_TABLE_MAIN);
90 90
91 tb = fib_trie_table(id, alias); 91 tb = fib_trie_table(id, alias);
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index ffe95d954007..840b450aab46 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1588,8 +1588,13 @@ void fib_select_multipath(struct fib_result *res, int hash)
1588void fib_select_path(struct net *net, struct fib_result *res, 1588void fib_select_path(struct net *net, struct fib_result *res,
1589 struct flowi4 *fl4, int mp_hash) 1589 struct flowi4 *fl4, int mp_hash)
1590{ 1590{
1591 bool oif_check;
1592
1593 oif_check = (fl4->flowi4_oif == 0 ||
1594 fl4->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF);
1595
1591#ifdef CONFIG_IP_ROUTE_MULTIPATH 1596#ifdef CONFIG_IP_ROUTE_MULTIPATH
1592 if (res->fi->fib_nhs > 1 && fl4->flowi4_oif == 0) { 1597 if (res->fi->fib_nhs > 1 && oif_check) {
1593 if (mp_hash < 0) 1598 if (mp_hash < 0)
1594 mp_hash = get_hash_from_flowi4(fl4) >> 1; 1599 mp_hash = get_hash_from_flowi4(fl4) >> 1;
1595 1600
@@ -1599,7 +1604,7 @@ void fib_select_path(struct net *net, struct fib_result *res,
1599#endif 1604#endif
1600 if (!res->prefixlen && 1605 if (!res->prefixlen &&
1601 res->table->tb_num_default > 1 && 1606 res->table->tb_num_default > 1 &&
1602 res->type == RTN_UNICAST && !fl4->flowi4_oif) 1607 res->type == RTN_UNICAST && oif_check)
1603 fib_select_default(fl4, res); 1608 fib_select_default(fl4, res);
1604 1609
1605 if (!fl4->saddr) 1610 if (!fl4->saddr)
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index b3086cf27027..17adfdaf5795 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -225,9 +225,14 @@ static void igmp_start_timer(struct ip_mc_list *im, int max_delay)
225static void igmp_gq_start_timer(struct in_device *in_dev) 225static void igmp_gq_start_timer(struct in_device *in_dev)
226{ 226{
227 int tv = prandom_u32() % in_dev->mr_maxdelay; 227 int tv = prandom_u32() % in_dev->mr_maxdelay;
228 unsigned long exp = jiffies + tv + 2;
229
230 if (in_dev->mr_gq_running &&
231 time_after_eq(exp, (in_dev->mr_gq_timer).expires))
232 return;
228 233
229 in_dev->mr_gq_running = 1; 234 in_dev->mr_gq_running = 1;
230 if (!mod_timer(&in_dev->mr_gq_timer, jiffies+tv+2)) 235 if (!mod_timer(&in_dev->mr_gq_timer, exp))
231 in_dev_hold(in_dev); 236 in_dev_hold(in_dev);
232} 237}
233 238
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index efe6268b8bc3..225f5f7f26ba 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -196,6 +196,7 @@ static struct sk_buff **ipv6_gro_receive(struct sk_buff **head,
196 ops = rcu_dereference(inet6_offloads[proto]); 196 ops = rcu_dereference(inet6_offloads[proto]);
197 if (!ops || !ops->callbacks.gro_receive) { 197 if (!ops || !ops->callbacks.gro_receive) {
198 __pskb_pull(skb, skb_gro_offset(skb)); 198 __pskb_pull(skb, skb_gro_offset(skb));
199 skb_gro_frag0_invalidate(skb);
199 proto = ipv6_gso_pull_exthdrs(skb, proto); 200 proto = ipv6_gso_pull_exthdrs(skb, proto);
200 skb_gro_pull(skb, -skb_transport_offset(skb)); 201 skb_gro_pull(skb, -skb_transport_offset(skb));
201 skb_reset_transport_header(skb); 202 skb_reset_transport_header(skb);
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 99140986e887..8bca90d6d915 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -589,7 +589,11 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6,
589 } 589 }
590 590
591 offset += skb_transport_offset(skb); 591 offset += skb_transport_offset(skb);
592 BUG_ON(skb_copy_bits(skb, offset, &csum, 2)); 592 err = skb_copy_bits(skb, offset, &csum, 2);
593 if (err < 0) {
594 ip6_flush_pending_frames(sk);
595 goto out;
596 }
593 597
594 /* in case cksum was not initialized */ 598 /* in case cksum was not initialized */
595 if (unlikely(csum)) 599 if (unlikely(csum))
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index e1225b395415..ea5dfefd765a 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2699,7 +2699,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
2699 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); 2699 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2);
2700 int hw_headroom = sdata->local->hw.extra_tx_headroom; 2700 int hw_headroom = sdata->local->hw.extra_tx_headroom;
2701 struct ethhdr eth; 2701 struct ethhdr eth;
2702 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 2702 struct ieee80211_tx_info *info;
2703 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; 2703 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr;
2704 struct ieee80211_tx_data tx; 2704 struct ieee80211_tx_data tx;
2705 ieee80211_tx_result r; 2705 ieee80211_tx_result r;
@@ -2761,6 +2761,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
2761 memcpy(skb->data + fast_tx->da_offs, eth.h_dest, ETH_ALEN); 2761 memcpy(skb->data + fast_tx->da_offs, eth.h_dest, ETH_ALEN);
2762 memcpy(skb->data + fast_tx->sa_offs, eth.h_source, ETH_ALEN); 2762 memcpy(skb->data + fast_tx->sa_offs, eth.h_source, ETH_ALEN);
2763 2763
2764 info = IEEE80211_SKB_CB(skb);
2764 memset(info, 0, sizeof(*info)); 2765 memset(info, 0, sizeof(*info));
2765 info->band = fast_tx->band; 2766 info->band = fast_tx->band;
2766 info->control.vif = &sdata->vif; 2767 info->control.vif = &sdata->vif;
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index ecc1904e454f..20b2f867c5a1 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -137,13 +137,15 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
137 unsigned long cl; 137 unsigned long cl;
138 unsigned long fh; 138 unsigned long fh;
139 int err; 139 int err;
140 int tp_created = 0; 140 int tp_created;
141 141
142 if ((n->nlmsg_type != RTM_GETTFILTER) && 142 if ((n->nlmsg_type != RTM_GETTFILTER) &&
143 !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) 143 !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
144 return -EPERM; 144 return -EPERM;
145 145
146replay: 146replay:
147 tp_created = 0;
148
147 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL); 149 err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL);
148 if (err < 0) 150 if (err < 0)
149 return err; 151 return err;
diff --git a/sound/firewire/tascam/tascam-stream.c b/sound/firewire/tascam/tascam-stream.c
index 0e6dd5c61f53..e4c306398b35 100644
--- a/sound/firewire/tascam/tascam-stream.c
+++ b/sound/firewire/tascam/tascam-stream.c
@@ -343,7 +343,7 @@ int snd_tscm_stream_init_duplex(struct snd_tscm *tscm)
343 if (err < 0) 343 if (err < 0)
344 amdtp_stream_destroy(&tscm->rx_stream); 344 amdtp_stream_destroy(&tscm->rx_stream);
345 345
346 return 0; 346 return err;
347} 347}
348 348
349/* At bus reset, streaming is stopped and some registers are clear. */ 349/* At bus reset, streaming is stopped and some registers are clear. */
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 3b2687889cd5..00c50d58f108 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2230,6 +2230,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2230 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), 2230 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2231 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), 2231 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2232 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS), 2232 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2233 SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
2233 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), 2234 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2234 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP), 2235 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2235 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP), 2236 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
@@ -6892,6 +6893,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
6892 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16), 6893 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
6893 SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51), 6894 SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
6894 SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51), 6895 SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
6896 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
6895 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16), 6897 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
6896 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP), 6898 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
6897 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), 6899 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index e163b0148c4b..fd6e247d9fd8 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -1027,12 +1027,13 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai)
1027static int samsung_i2s_dai_remove(struct snd_soc_dai *dai) 1027static int samsung_i2s_dai_remove(struct snd_soc_dai *dai)
1028{ 1028{
1029 struct i2s_dai *i2s = snd_soc_dai_get_drvdata(dai); 1029 struct i2s_dai *i2s = snd_soc_dai_get_drvdata(dai);
1030 unsigned long flags;
1030 1031
1031 if (!is_secondary(i2s)) { 1032 if (!is_secondary(i2s)) {
1032 if (i2s->quirks & QUIRK_NEED_RSTCLR) { 1033 if (i2s->quirks & QUIRK_NEED_RSTCLR) {
1033 spin_lock(i2s->lock); 1034 spin_lock_irqsave(i2s->lock, flags);
1034 writel(0, i2s->addr + I2SCON); 1035 writel(0, i2s->addr + I2SCON);
1035 spin_unlock(i2s->lock); 1036 spin_unlock_irqrestore(i2s->lock, flags);
1036 } 1037 }
1037 } 1038 }
1038 1039
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 1f09d9591276..a1cbaa5f7fc9 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -202,7 +202,6 @@ static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int int
202 if (! snd_usb_parse_audio_interface(chip, interface)) { 202 if (! snd_usb_parse_audio_interface(chip, interface)) {
203 usb_set_interface(dev, interface, 0); /* reset the current interface */ 203 usb_set_interface(dev, interface, 0); /* reset the current interface */
204 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); 204 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
205 return -EINVAL;
206 } 205 }
207 206
208 return 0; 207 return 0;
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index c07a7eda42a2..be1f511e4f54 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -538,6 +538,11 @@ static int wait_clear_urbs(struct snd_usb_endpoint *ep)
538 alive, ep->ep_num); 538 alive, ep->ep_num);
539 clear_bit(EP_FLAG_STOPPING, &ep->flags); 539 clear_bit(EP_FLAG_STOPPING, &ep->flags);
540 540
541 ep->data_subs = NULL;
542 ep->sync_slave = NULL;
543 ep->retire_data_urb = NULL;
544 ep->prepare_data_urb = NULL;
545
541 return 0; 546 return 0;
542} 547}
543 548
@@ -902,9 +907,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
902/** 907/**
903 * snd_usb_endpoint_start: start an snd_usb_endpoint 908 * snd_usb_endpoint_start: start an snd_usb_endpoint
904 * 909 *
905 * @ep: the endpoint to start 910 * @ep: the endpoint to start
906 * @can_sleep: flag indicating whether the operation is executed in
907 * non-atomic context
908 * 911 *
909 * A call to this function will increment the use count of the endpoint. 912 * A call to this function will increment the use count of the endpoint.
910 * In case it is not already running, the URBs for this endpoint will be 913 * In case it is not already running, the URBs for this endpoint will be
@@ -914,7 +917,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
914 * 917 *
915 * Returns an error if the URB submission failed, 0 in all other cases. 918 * Returns an error if the URB submission failed, 0 in all other cases.
916 */ 919 */
917int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep) 920int snd_usb_endpoint_start(struct snd_usb_endpoint *ep)
918{ 921{
919 int err; 922 int err;
920 unsigned int i; 923 unsigned int i;
@@ -928,8 +931,6 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep)
928 931
929 /* just to be sure */ 932 /* just to be sure */
930 deactivate_urbs(ep, false); 933 deactivate_urbs(ep, false);
931 if (can_sleep)
932 wait_clear_urbs(ep);
933 934
934 ep->active_mask = 0; 935 ep->active_mask = 0;
935 ep->unlink_mask = 0; 936 ep->unlink_mask = 0;
@@ -1010,10 +1011,6 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep)
1010 1011
1011 if (--ep->use_count == 0) { 1012 if (--ep->use_count == 0) {
1012 deactivate_urbs(ep, false); 1013 deactivate_urbs(ep, false);
1013 ep->data_subs = NULL;
1014 ep->sync_slave = NULL;
1015 ep->retire_data_urb = NULL;
1016 ep->prepare_data_urb = NULL;
1017 set_bit(EP_FLAG_STOPPING, &ep->flags); 1014 set_bit(EP_FLAG_STOPPING, &ep->flags);
1018 } 1015 }
1019} 1016}
diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h
index 6428392d8f62..584f295d7c77 100644
--- a/sound/usb/endpoint.h
+++ b/sound/usb/endpoint.h
@@ -18,7 +18,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
18 struct audioformat *fmt, 18 struct audioformat *fmt,
19 struct snd_usb_endpoint *sync_ep); 19 struct snd_usb_endpoint *sync_ep);
20 20
21int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep); 21int snd_usb_endpoint_start(struct snd_usb_endpoint *ep);
22void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep); 22void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep);
23void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep); 23void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep);
24int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); 24int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep);
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 44d178ee9177..48afae053c56 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -218,7 +218,7 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface,
218 } 218 }
219} 219}
220 220
221static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep) 221static int start_endpoints(struct snd_usb_substream *subs)
222{ 222{
223 int err; 223 int err;
224 224
@@ -231,7 +231,7 @@ static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep)
231 dev_dbg(&subs->dev->dev, "Starting data EP @%p\n", ep); 231 dev_dbg(&subs->dev->dev, "Starting data EP @%p\n", ep);
232 232
233 ep->data_subs = subs; 233 ep->data_subs = subs;
234 err = snd_usb_endpoint_start(ep, can_sleep); 234 err = snd_usb_endpoint_start(ep);
235 if (err < 0) { 235 if (err < 0) {
236 clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags); 236 clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags);
237 return err; 237 return err;
@@ -260,7 +260,7 @@ static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep)
260 dev_dbg(&subs->dev->dev, "Starting sync EP @%p\n", ep); 260 dev_dbg(&subs->dev->dev, "Starting sync EP @%p\n", ep);
261 261
262 ep->sync_slave = subs->data_endpoint; 262 ep->sync_slave = subs->data_endpoint;
263 err = snd_usb_endpoint_start(ep, can_sleep); 263 err = snd_usb_endpoint_start(ep);
264 if (err < 0) { 264 if (err < 0) {
265 clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); 265 clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags);
266 return err; 266 return err;
@@ -839,7 +839,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
839 /* for playback, submit the URBs now; otherwise, the first hwptr_done 839 /* for playback, submit the URBs now; otherwise, the first hwptr_done
840 * updates for all URBs would happen at the same time when starting */ 840 * updates for all URBs would happen at the same time when starting */
841 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) 841 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK)
842 ret = start_endpoints(subs, true); 842 ret = start_endpoints(subs);
843 843
844 unlock: 844 unlock:
845 snd_usb_unlock_shutdown(subs->stream->chip); 845 snd_usb_unlock_shutdown(subs->stream->chip);
@@ -1655,7 +1655,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream
1655 1655
1656 switch (cmd) { 1656 switch (cmd) {
1657 case SNDRV_PCM_TRIGGER_START: 1657 case SNDRV_PCM_TRIGGER_START:
1658 err = start_endpoints(subs, false); 1658 err = start_endpoints(subs);
1659 if (err < 0) 1659 if (err < 0)
1660 return err; 1660 return err;
1661 1661
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 3039e907f1f8..29f38e2b4ca9 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1136,6 +1136,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
1136 case USB_ID(0x045E, 0x076F): /* MS Lifecam HD-6000 */ 1136 case USB_ID(0x045E, 0x076F): /* MS Lifecam HD-6000 */
1137 case USB_ID(0x045E, 0x0772): /* MS Lifecam Studio */ 1137 case USB_ID(0x045E, 0x0772): /* MS Lifecam Studio */
1138 case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */ 1138 case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */
1139 case USB_ID(0x047F, 0x02F7): /* Plantronics BT-600 */
1139 case USB_ID(0x047F, 0x0415): /* Plantronics BT-300 */ 1140 case USB_ID(0x047F, 0x0415): /* Plantronics BT-300 */
1140 case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */ 1141 case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */
1141 case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */ 1142 case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */