summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.mailmap1
-rw-r--r--Documentation/devicetree/bindings/arm/cpus.txt1
-rw-r--r--MAINTAINERS9
-rw-r--r--Makefile2
-rw-r--r--arch/arm/boot/dts/dra7.dtsi2
-rw-r--r--arch/arm/boot/dts/imx6qdl.dtsi8
-rw-r--r--arch/arm/boot/dts/k2e.dtsi15
-rw-r--r--arch/arm/boot/dts/k2hk.dtsi11
-rw-r--r--arch/arm/boot/dts/k2l.dtsi16
-rw-r--r--arch/arm/boot/dts/keystone.dtsi11
-rw-r--r--arch/arm/boot/dts/omap2430.dtsi3
-rw-r--r--arch/arm/boot/dts/omap4.dtsi3
-rw-r--r--arch/arm/boot/dts/omap5.dtsi3
-rw-r--r--arch/arm/boot/dts/ste-dbx5x0.dtsi53
-rw-r--r--arch/arm/kernel/entry-common.S1
-rw-r--r--arch/arm/kernel/head.S3
-rw-r--r--arch/arm/kernel/vdso.c7
-rw-r--r--arch/arm/mach-exynos/pm_domains.c3
-rw-r--r--arch/arm/vdso/Makefile2
-rw-r--r--arch/mips/kernel/scall64-64.S2
-rw-r--r--arch/mips/kernel/scall64-n32.S2
-rw-r--r--arch/x86/entry/entry_64_compat.S3
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c23
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_cqm.c8
-rw-r--r--arch/x86/kernel/step.c4
-rw-r--r--arch/x86/kvm/x86.c7
-rw-r--r--arch/x86/math-emu/fpu_entry.c3
-rw-r--r--arch/x86/math-emu/fpu_system.h21
-rw-r--r--arch/x86/math-emu/get_address.c3
-rw-r--r--arch/x86/xen/Kconfig4
-rw-r--r--block/blk-settings.c4
-rw-r--r--crypto/authencesn.c44
-rw-r--r--drivers/acpi/video_detect.c16
-rw-r--r--drivers/ata/ahci_brcmstb.c6
-rw-r--r--drivers/ata/libata-core.c24
-rw-r--r--drivers/ata/libata-eh.c105
-rw-r--r--drivers/ata/libata-scsi.c21
-rw-r--r--drivers/ata/libata.h6
-rw-r--r--drivers/ata/sata_sx4.c16
-rw-r--r--drivers/block/zram/zram_drv.c6
-rw-r--r--drivers/clk/pxa/clk-pxa3xx.c2
-rw-r--r--drivers/clocksource/sh_cmt.c6
-rw-r--r--drivers/cpufreq/exynos-cpufreq.c6
-rw-r--r--drivers/crypto/caam/caamhash.c7
-rw-r--r--drivers/crypto/nx/nx-sha256.c27
-rw-r--r--drivers/crypto/nx/nx-sha512.c28
-rw-r--r--drivers/dma/dmaengine.c4
-rw-r--r--drivers/gpu/drm/drm_dp_mst_topology.c19
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimc.c1
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_gsc.c6
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c7
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c21
-rw-r--r--drivers/gpu/drm/i915/intel_atomic.c45
-rw-r--r--drivers/gpu/drm/i915/intel_display.c59
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c29
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c4
-rw-r--r--drivers/infiniband/hw/cxgb4/cq.c2
-rw-r--r--drivers/memory/omap-gpmc.c6
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c4
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c5
-rw-r--r--drivers/net/ethernet/micrel/ks8842.c5
-rw-r--r--drivers/net/phy/phy.c16
-rw-r--r--drivers/net/phy/smsc.c31
-rw-r--r--drivers/net/ppp/ppp_generic.c78
-rw-r--r--drivers/net/usb/qmi_wwan.c1
-rw-r--r--drivers/scsi/libfc/fc_exch.c8
-rw-r--r--drivers/scsi/libfc/fc_fcp.c19
-rw-r--r--drivers/scsi/libiscsi.c25
-rw-r--r--drivers/scsi/scsi_error.c31
-rw-r--r--drivers/scsi/sd.c6
-rw-r--r--drivers/target/iscsi/iscsi_target.c4
-rw-r--r--drivers/target/target_core_configfs.c9
-rw-r--r--drivers/target/target_core_hba.c10
-rw-r--r--drivers/target/target_core_spc.c44
-rw-r--r--drivers/thermal/cpu_cooling.c73
-rw-r--r--drivers/thermal/power_allocator.c8
-rw-r--r--fs/fuse/dev.c10
-rw-r--r--include/drm/drm_crtc.h2
-rw-r--r--include/linux/ata.h18
-rw-r--r--include/scsi/scsi_eh.h1
-rw-r--r--include/sound/soc-topology.h12
-rw-r--r--include/uapi/sound/asoc.h6
-rw-r--r--ipc/sem.c47
-rw-r--r--kernel/cpuset.c2
-rw-r--r--kernel/events/core.c91
-rw-r--r--kernel/events/ring_buffer.c10
-rw-r--r--kernel/locking/qspinlock_paravirt.h11
-rw-r--r--mm/cma.h2
-rw-r--r--mm/kasan/kasan.c2
-rw-r--r--mm/kasan/report.c2
-rw-r--r--mm/memory-failure.c22
-rw-r--r--mm/memory_hotplug.c3
-rw-r--r--mm/page_alloc.c8
-rw-r--r--net/batman-adv/translation-table.c5
-rw-r--r--net/bridge/br_multicast.c4
-rw-r--r--net/core/skbuff.c37
-rw-r--r--net/ipv4/fib_trie.c2
-rw-r--r--net/ipv4/igmp.c33
-rw-r--r--net/ipv4/inet_connection_sock.c2
-rw-r--r--net/ipv4/sysctl_net_ipv4.c10
-rw-r--r--net/ipv6/ip6_fib.c2
-rw-r--r--net/ipv6/mcast_snoop.c33
-rw-r--r--net/ipv6/route.c79
-rw-r--r--net/mac80211/rc80211_minstrel.c11
-rw-r--r--sound/pci/hda/patch_realtek.c2
-rw-r--r--sound/soc/Kconfig3
-rw-r--r--sound/soc/Makefile3
-rw-r--r--sound/usb/card.c2
-rw-r--r--tools/perf/config/Makefile2
-rw-r--r--tools/perf/util/stat-shadow.c8
110 files changed, 840 insertions, 785 deletions
diff --git a/.mailmap b/.mailmap
index b4091b7a78fe..4b31af54ccd5 100644
--- a/.mailmap
+++ b/.mailmap
@@ -17,6 +17,7 @@ Aleksey Gorelov <aleksey_gorelov@phoenix.com>
17Al Viro <viro@ftp.linux.org.uk> 17Al Viro <viro@ftp.linux.org.uk>
18Al Viro <viro@zenIV.linux.org.uk> 18Al Viro <viro@zenIV.linux.org.uk>
19Andreas Herrmann <aherrman@de.ibm.com> 19Andreas Herrmann <aherrman@de.ibm.com>
20Andrey Ryabinin <ryabinin.a.a@gmail.com> <a.ryabinin@samsung.com>
20Andrew Morton <akpm@linux-foundation.org> 21Andrew Morton <akpm@linux-foundation.org>
21Andrew Vasquez <andrew.vasquez@qlogic.com> 22Andrew Vasquez <andrew.vasquez@qlogic.com>
22Andy Adamson <andros@citi.umich.edu> 23Andy Adamson <andros@citi.umich.edu>
diff --git a/Documentation/devicetree/bindings/arm/cpus.txt b/Documentation/devicetree/bindings/arm/cpus.txt
index d6b794cef0b8..91e6e5c478d0 100644
--- a/Documentation/devicetree/bindings/arm/cpus.txt
+++ b/Documentation/devicetree/bindings/arm/cpus.txt
@@ -199,6 +199,7 @@ nodes to be present and contain the properties described below.
199 "qcom,kpss-acc-v1" 199 "qcom,kpss-acc-v1"
200 "qcom,kpss-acc-v2" 200 "qcom,kpss-acc-v2"
201 "rockchip,rk3066-smp" 201 "rockchip,rk3066-smp"
202 "ste,dbx500-smp"
202 203
203 - cpu-release-addr 204 - cpu-release-addr
204 Usage: required for systems that have an "enable-method" 205 Usage: required for systems that have an "enable-method"
diff --git a/MAINTAINERS b/MAINTAINERS
index 7b528b8c73f8..7b1b552630b8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3588,6 +3588,15 @@ S: Maintained
3588F: drivers/gpu/drm/rockchip/ 3588F: drivers/gpu/drm/rockchip/
3589F: Documentation/devicetree/bindings/video/rockchip* 3589F: Documentation/devicetree/bindings/video/rockchip*
3590 3590
3591DRM DRIVERS FOR STI
3592M: Benjamin Gaignard <benjamin.gaignard@linaro.org>
3593M: Vincent Abriou <vincent.abriou@st.com>
3594L: dri-devel@lists.freedesktop.org
3595T: git http://git.linaro.org/people/benjamin.gaignard/kernel.git
3596S: Maintained
3597F: drivers/gpu/drm/sti
3598F: Documentation/devicetree/bindings/gpu/st,stih4xx.txt
3599
3591DSBR100 USB FM RADIO DRIVER 3600DSBR100 USB FM RADIO DRIVER
3592M: Alexey Klimov <klimov.linux@gmail.com> 3601M: Alexey Klimov <klimov.linux@gmail.com>
3593L: linux-media@vger.kernel.org 3602L: linux-media@vger.kernel.org
diff --git a/Makefile b/Makefile
index 35b4c196c171..6e88c371b32f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 2 2PATCHLEVEL = 2
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc6 4EXTRAVERSION = -rc7
5NAME = Hurr durr I'ma sheep 5NAME = Hurr durr I'ma sheep
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 0001e959bf49..6dbbc02d18b4 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -116,7 +116,7 @@
116 ranges = <0 0x2000 0x2000>; 116 ranges = <0 0x2000 0x2000>;
117 117
118 scm_conf: scm_conf@0 { 118 scm_conf: scm_conf@0 {
119 compatible = "syscon"; 119 compatible = "syscon", "simple-bus";
120 reg = <0x0 0x1400>; 120 reg = <0x0 0x1400>;
121 #address-cells = <1>; 121 #address-cells = <1>;
122 #size-cells = <1>; 122 #size-cells = <1>;
diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index e6d13592080d..b57033e8c633 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -181,10 +181,10 @@
181 interrupt-names = "msi"; 181 interrupt-names = "msi";
182 #interrupt-cells = <1>; 182 #interrupt-cells = <1>;
183 interrupt-map-mask = <0 0 0 0x7>; 183 interrupt-map-mask = <0 0 0 0x7>;
184 interrupt-map = <0 0 0 1 &intc GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>, 184 interrupt-map = <0 0 0 1 &gpc GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>,
185 <0 0 0 2 &intc GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>, 185 <0 0 0 2 &gpc GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
186 <0 0 0 3 &intc GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>, 186 <0 0 0 3 &gpc GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
187 <0 0 0 4 &intc GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>; 187 <0 0 0 4 &gpc GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
188 clocks = <&clks IMX6QDL_CLK_PCIE_AXI>, 188 clocks = <&clks IMX6QDL_CLK_PCIE_AXI>,
189 <&clks IMX6QDL_CLK_LVDS1_GATE>, 189 <&clks IMX6QDL_CLK_LVDS1_GATE>,
190 <&clks IMX6QDL_CLK_PCIE_REF_125M>; 190 <&clks IMX6QDL_CLK_PCIE_REF_125M>;
diff --git a/arch/arm/boot/dts/k2e.dtsi b/arch/arm/boot/dts/k2e.dtsi
index 1b6494fbdb91..675fb8e492c6 100644
--- a/arch/arm/boot/dts/k2e.dtsi
+++ b/arch/arm/boot/dts/k2e.dtsi
@@ -131,10 +131,17 @@
131 <GIC_SPI 376 IRQ_TYPE_EDGE_RISING>; 131 <GIC_SPI 376 IRQ_TYPE_EDGE_RISING>;
132 }; 132 };
133 }; 133 };
134
135 mdio: mdio@24200f00 {
136 compatible = "ti,keystone_mdio", "ti,davinci_mdio";
137 #address-cells = <1>;
138 #size-cells = <0>;
139 reg = <0x24200f00 0x100>;
140 status = "disabled";
141 clocks = <&clkcpgmac>;
142 clock-names = "fck";
143 bus_freq = <2500000>;
144 };
134 /include/ "k2e-netcp.dtsi" 145 /include/ "k2e-netcp.dtsi"
135 }; 146 };
136}; 147};
137
138&mdio {
139 reg = <0x24200f00 0x100>;
140};
diff --git a/arch/arm/boot/dts/k2hk.dtsi b/arch/arm/boot/dts/k2hk.dtsi
index ae6472407b22..d0810a5f2968 100644
--- a/arch/arm/boot/dts/k2hk.dtsi
+++ b/arch/arm/boot/dts/k2hk.dtsi
@@ -98,6 +98,17 @@
98 #gpio-cells = <2>; 98 #gpio-cells = <2>;
99 gpio,syscon-dev = <&devctrl 0x25c>; 99 gpio,syscon-dev = <&devctrl 0x25c>;
100 }; 100 };
101
102 mdio: mdio@02090300 {
103 compatible = "ti,keystone_mdio", "ti,davinci_mdio";
104 #address-cells = <1>;
105 #size-cells = <0>;
106 reg = <0x02090300 0x100>;
107 status = "disabled";
108 clocks = <&clkcpgmac>;
109 clock-names = "fck";
110 bus_freq = <2500000>;
111 };
101 /include/ "k2hk-netcp.dtsi" 112 /include/ "k2hk-netcp.dtsi"
102 }; 113 };
103}; 114};
diff --git a/arch/arm/boot/dts/k2l.dtsi b/arch/arm/boot/dts/k2l.dtsi
index 0e007483615e..49fd414f680c 100644
--- a/arch/arm/boot/dts/k2l.dtsi
+++ b/arch/arm/boot/dts/k2l.dtsi
@@ -29,7 +29,6 @@
29 }; 29 };
30 30
31 soc { 31 soc {
32
33 /include/ "k2l-clocks.dtsi" 32 /include/ "k2l-clocks.dtsi"
34 33
35 uart2: serial@02348400 { 34 uart2: serial@02348400 {
@@ -79,6 +78,17 @@
79 #gpio-cells = <2>; 78 #gpio-cells = <2>;
80 gpio,syscon-dev = <&devctrl 0x24c>; 79 gpio,syscon-dev = <&devctrl 0x24c>;
81 }; 80 };
81
82 mdio: mdio@26200f00 {
83 compatible = "ti,keystone_mdio", "ti,davinci_mdio";
84 #address-cells = <1>;
85 #size-cells = <0>;
86 reg = <0x26200f00 0x100>;
87 status = "disabled";
88 clocks = <&clkcpgmac>;
89 clock-names = "fck";
90 bus_freq = <2500000>;
91 };
82 /include/ "k2l-netcp.dtsi" 92 /include/ "k2l-netcp.dtsi"
83 }; 93 };
84}; 94};
@@ -96,7 +106,3 @@
96 /* Pin muxed. Enabled and configured by Bootloader */ 106 /* Pin muxed. Enabled and configured by Bootloader */
97 status = "disabled"; 107 status = "disabled";
98}; 108};
99
100&mdio {
101 reg = <0x26200f00 0x100>;
102};
diff --git a/arch/arm/boot/dts/keystone.dtsi b/arch/arm/boot/dts/keystone.dtsi
index e7a6f6deabb6..72816d65f7ec 100644
--- a/arch/arm/boot/dts/keystone.dtsi
+++ b/arch/arm/boot/dts/keystone.dtsi
@@ -267,17 +267,6 @@
267 1 0 0x21000A00 0x00000100>; 267 1 0 0x21000A00 0x00000100>;
268 }; 268 };
269 269
270 mdio: mdio@02090300 {
271 compatible = "ti,keystone_mdio", "ti,davinci_mdio";
272 #address-cells = <1>;
273 #size-cells = <0>;
274 reg = <0x02090300 0x100>;
275 status = "disabled";
276 clocks = <&clkpa>;
277 clock-names = "fck";
278 bus_freq = <2500000>;
279 };
280
281 kirq0: keystone_irq@26202a0 { 270 kirq0: keystone_irq@26202a0 {
282 compatible = "ti,keystone-irq"; 271 compatible = "ti,keystone-irq";
283 interrupts = <GIC_SPI 4 IRQ_TYPE_EDGE_RISING>; 272 interrupts = <GIC_SPI 4 IRQ_TYPE_EDGE_RISING>;
diff --git a/arch/arm/boot/dts/omap2430.dtsi b/arch/arm/boot/dts/omap2430.dtsi
index 11a7963be003..2390f387c271 100644
--- a/arch/arm/boot/dts/omap2430.dtsi
+++ b/arch/arm/boot/dts/omap2430.dtsi
@@ -51,7 +51,8 @@
51 }; 51 };
52 52
53 scm_conf: scm_conf@270 { 53 scm_conf: scm_conf@270 {
54 compatible = "syscon"; 54 compatible = "syscon",
55 "simple-bus";
55 reg = <0x270 0x240>; 56 reg = <0x270 0x240>;
56 #address-cells = <1>; 57 #address-cells = <1>;
57 #size-cells = <1>; 58 #size-cells = <1>;
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 7d31c6ff246f..abc4473e6f8a 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -191,7 +191,8 @@
191 }; 191 };
192 192
193 omap4_padconf_global: omap4_padconf_global@5a0 { 193 omap4_padconf_global: omap4_padconf_global@5a0 {
194 compatible = "syscon"; 194 compatible = "syscon",
195 "simple-bus";
195 reg = <0x5a0 0x170>; 196 reg = <0x5a0 0x170>;
196 #address-cells = <1>; 197 #address-cells = <1>;
197 #size-cells = <1>; 198 #size-cells = <1>;
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index c8fd648a7108..b1a1263e6001 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -180,7 +180,8 @@
180 }; 180 };
181 181
182 omap5_padconf_global: omap5_padconf_global@5a0 { 182 omap5_padconf_global: omap5_padconf_global@5a0 {
183 compatible = "syscon"; 183 compatible = "syscon",
184 "simple-bus";
184 reg = <0x5a0 0xec>; 185 reg = <0x5a0 0xec>;
185 #address-cells = <1>; 186 #address-cells = <1>;
186 #size-cells = <1>; 187 #size-cells = <1>;
diff --git a/arch/arm/boot/dts/ste-dbx5x0.dtsi b/arch/arm/boot/dts/ste-dbx5x0.dtsi
index a75f3289e653..b8f81fb418ce 100644
--- a/arch/arm/boot/dts/ste-dbx5x0.dtsi
+++ b/arch/arm/boot/dts/ste-dbx5x0.dtsi
@@ -15,6 +15,33 @@
15#include "skeleton.dtsi" 15#include "skeleton.dtsi"
16 16
17/ { 17/ {
18 cpus {
19 #address-cells = <1>;
20 #size-cells = <0>;
21 enable-method = "ste,dbx500-smp";
22
23 cpu-map {
24 cluster0 {
25 core0 {
26 cpu = <&CPU0>;
27 };
28 core1 {
29 cpu = <&CPU1>;
30 };
31 };
32 };
33 CPU0: cpu@300 {
34 device_type = "cpu";
35 compatible = "arm,cortex-a9";
36 reg = <0x300>;
37 };
38 CPU1: cpu@301 {
39 device_type = "cpu";
40 compatible = "arm,cortex-a9";
41 reg = <0x301>;
42 };
43 };
44
18 soc { 45 soc {
19 #address-cells = <1>; 46 #address-cells = <1>;
20 #size-cells = <1>; 47 #size-cells = <1>;
@@ -22,32 +49,6 @@
22 interrupt-parent = <&intc>; 49 interrupt-parent = <&intc>;
23 ranges; 50 ranges;
24 51
25 cpus {
26 #address-cells = <1>;
27 #size-cells = <0>;
28
29 cpu-map {
30 cluster0 {
31 core0 {
32 cpu = <&CPU0>;
33 };
34 core1 {
35 cpu = <&CPU1>;
36 };
37 };
38 };
39 CPU0: cpu@0 {
40 device_type = "cpu";
41 compatible = "arm,cortex-a9";
42 reg = <0>;
43 };
44 CPU1: cpu@1 {
45 device_type = "cpu";
46 compatible = "arm,cortex-a9";
47 reg = <1>;
48 };
49 };
50
51 ptm@801ae000 { 52 ptm@801ae000 {
52 compatible = "arm,coresight-etm3x", "arm,primecell"; 53 compatible = "arm,coresight-etm3x", "arm,primecell";
53 reg = <0x801ae000 0x1000>; 54 reg = <0x801ae000 0x1000>;
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 92828a1dec80..b48dd4f37f80 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -61,6 +61,7 @@ work_pending:
61 movlt scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE) 61 movlt scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE)
62 ldmia sp, {r0 - r6} @ have to reload r0 - r6 62 ldmia sp, {r0 - r6} @ have to reload r0 - r6
63 b local_restart @ ... and off we go 63 b local_restart @ ... and off we go
64ENDPROC(ret_fast_syscall)
64 65
65/* 66/*
66 * "slow" syscall return path. "why" tells us if this was a real syscall. 67 * "slow" syscall return path. "why" tells us if this was a real syscall.
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index bd755d97e459..29e2991465cb 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -399,6 +399,9 @@ ENTRY(secondary_startup)
399 sub lr, r4, r5 @ mmu has been enabled 399 sub lr, r4, r5 @ mmu has been enabled
400 add r3, r7, lr 400 add r3, r7, lr
401 ldrd r4, [r3, #0] @ get secondary_data.pgdir 401 ldrd r4, [r3, #0] @ get secondary_data.pgdir
402ARM_BE8(eor r4, r4, r5) @ Swap r5 and r4 in BE:
403ARM_BE8(eor r5, r4, r5) @ it can be done in 3 steps
404ARM_BE8(eor r4, r4, r5) @ without using a temp reg.
402 ldr r8, [r3, #8] @ get secondary_data.swapper_pg_dir 405 ldr r8, [r3, #8] @ get secondary_data.swapper_pg_dir
403 badr lr, __enable_mmu @ return address 406 badr lr, __enable_mmu @ return address
404 mov r13, r12 @ __secondary_switched address 407 mov r13, r12 @ __secondary_switched address
diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c
index efe17dd9b921..54a5aeab988d 100644
--- a/arch/arm/kernel/vdso.c
+++ b/arch/arm/kernel/vdso.c
@@ -296,7 +296,6 @@ static bool tk_is_cntvct(const struct timekeeper *tk)
296 */ 296 */
297void update_vsyscall(struct timekeeper *tk) 297void update_vsyscall(struct timekeeper *tk)
298{ 298{
299 struct timespec xtime_coarse;
300 struct timespec64 *wtm = &tk->wall_to_monotonic; 299 struct timespec64 *wtm = &tk->wall_to_monotonic;
301 300
302 if (!cntvct_ok) { 301 if (!cntvct_ok) {
@@ -308,10 +307,10 @@ void update_vsyscall(struct timekeeper *tk)
308 307
309 vdso_write_begin(vdso_data); 308 vdso_write_begin(vdso_data);
310 309
311 xtime_coarse = __current_kernel_time();
312 vdso_data->tk_is_cntvct = tk_is_cntvct(tk); 310 vdso_data->tk_is_cntvct = tk_is_cntvct(tk);
313 vdso_data->xtime_coarse_sec = xtime_coarse.tv_sec; 311 vdso_data->xtime_coarse_sec = tk->xtime_sec;
314 vdso_data->xtime_coarse_nsec = xtime_coarse.tv_nsec; 312 vdso_data->xtime_coarse_nsec = (u32)(tk->tkr_mono.xtime_nsec >>
313 tk->tkr_mono.shift);
315 vdso_data->wtm_clock_sec = wtm->tv_sec; 314 vdso_data->wtm_clock_sec = wtm->tv_sec;
316 vdso_data->wtm_clock_nsec = wtm->tv_nsec; 315 vdso_data->wtm_clock_nsec = wtm->tv_nsec;
317 316
diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c
index 6001f1c9d136..4a87e86dec45 100644
--- a/arch/arm/mach-exynos/pm_domains.c
+++ b/arch/arm/mach-exynos/pm_domains.c
@@ -146,9 +146,8 @@ static __init int exynos4_pm_init_power_domain(void)
146 pd->base = of_iomap(np, 0); 146 pd->base = of_iomap(np, 0);
147 if (!pd->base) { 147 if (!pd->base) {
148 pr_warn("%s: failed to map memory\n", __func__); 148 pr_warn("%s: failed to map memory\n", __func__);
149 kfree(pd->pd.name); 149 kfree_const(pd->pd.name);
150 kfree(pd); 150 kfree(pd);
151 of_node_put(np);
152 continue; 151 continue;
153 } 152 }
154 153
diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
index 9d259d94e429..1160434eece0 100644
--- a/arch/arm/vdso/Makefile
+++ b/arch/arm/vdso/Makefile
@@ -14,7 +14,7 @@ VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
14VDSO_LDFLAGS += -nostdlib -shared 14VDSO_LDFLAGS += -nostdlib -shared
15VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) 15VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
16VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--build-id) 16VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--build-id)
17VDSO_LDFLAGS += $(call cc-option, -fuse-ld=bfd) 17VDSO_LDFLAGS += $(call cc-ldoption, -fuse-ld=bfd)
18 18
19obj-$(CONFIG_VDSO) += vdso.o 19obj-$(CONFIG_VDSO) += vdso.o
20extra-$(CONFIG_VDSO) += vdso.lds 20extra-$(CONFIG_VDSO) += vdso.lds
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index ad4d44635c76..a6f6b762c47a 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -80,7 +80,7 @@ syscall_trace_entry:
80 SAVE_STATIC 80 SAVE_STATIC
81 move s0, t2 81 move s0, t2
82 move a0, sp 82 move a0, sp
83 daddiu a1, v0, __NR_64_Linux 83 move a1, v0
84 jal syscall_trace_enter 84 jal syscall_trace_enter
85 85
86 bltz v0, 2f # seccomp failed? Skip syscall 86 bltz v0, 2f # seccomp failed? Skip syscall
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 446cc654da56..4b2010654c46 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -72,7 +72,7 @@ n32_syscall_trace_entry:
72 SAVE_STATIC 72 SAVE_STATIC
73 move s0, t2 73 move s0, t2
74 move a0, sp 74 move a0, sp
75 daddiu a1, v0, __NR_N32_Linux 75 move a1, v0
76 jal syscall_trace_enter 76 jal syscall_trace_enter
77 77
78 bltz v0, 2f # seccomp failed? Skip syscall 78 bltz v0, 2f # seccomp failed? Skip syscall
diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
index 5a1844765a7a..a7e257d9cb90 100644
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -140,6 +140,7 @@ sysexit_from_sys_call:
140 */ 140 */
141 andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS) 141 andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
142 movl RIP(%rsp), %ecx /* User %eip */ 142 movl RIP(%rsp), %ecx /* User %eip */
143 movq RAX(%rsp), %rax
143 RESTORE_RSI_RDI 144 RESTORE_RSI_RDI
144 xorl %edx, %edx /* Do not leak kernel information */ 145 xorl %edx, %edx /* Do not leak kernel information */
145 xorq %r8, %r8 146 xorq %r8, %r8
@@ -219,7 +220,6 @@ sysexit_from_sys_call:
2191: setbe %al /* 1 if error, 0 if not */ 2201: setbe %al /* 1 if error, 0 if not */
220 movzbl %al, %edi /* zero-extend that into %edi */ 221 movzbl %al, %edi /* zero-extend that into %edi */
221 call __audit_syscall_exit 222 call __audit_syscall_exit
222 movq RAX(%rsp), %rax /* reload syscall return value */
223 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %edi 223 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %edi
224 DISABLE_INTERRUPTS(CLBR_NONE) 224 DISABLE_INTERRUPTS(CLBR_NONE)
225 TRACE_IRQS_OFF 225 TRACE_IRQS_OFF
@@ -368,6 +368,7 @@ sysretl_from_sys_call:
368 RESTORE_RSI_RDI_RDX 368 RESTORE_RSI_RDI_RDX
369 movl RIP(%rsp), %ecx 369 movl RIP(%rsp), %ecx
370 movl EFLAGS(%rsp), %r11d 370 movl EFLAGS(%rsp), %r11d
371 movq RAX(%rsp), %rax
371 xorq %r10, %r10 372 xorq %r10, %r10
372 xorq %r9, %r9 373 xorq %r9, %r9
373 xorq %r8, %r8 374 xorq %r8, %r8
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index b9826a981fb2..6326ae24e4d5 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -2534,7 +2534,7 @@ static int intel_pmu_cpu_prepare(int cpu)
2534 if (x86_pmu.extra_regs || x86_pmu.lbr_sel_map) { 2534 if (x86_pmu.extra_regs || x86_pmu.lbr_sel_map) {
2535 cpuc->shared_regs = allocate_shared_regs(cpu); 2535 cpuc->shared_regs = allocate_shared_regs(cpu);
2536 if (!cpuc->shared_regs) 2536 if (!cpuc->shared_regs)
2537 return NOTIFY_BAD; 2537 goto err;
2538 } 2538 }
2539 2539
2540 if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) { 2540 if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) {
@@ -2542,18 +2542,27 @@ static int intel_pmu_cpu_prepare(int cpu)
2542 2542
2543 cpuc->constraint_list = kzalloc(sz, GFP_KERNEL); 2543 cpuc->constraint_list = kzalloc(sz, GFP_KERNEL);
2544 if (!cpuc->constraint_list) 2544 if (!cpuc->constraint_list)
2545 return NOTIFY_BAD; 2545 goto err_shared_regs;
2546 2546
2547 cpuc->excl_cntrs = allocate_excl_cntrs(cpu); 2547 cpuc->excl_cntrs = allocate_excl_cntrs(cpu);
2548 if (!cpuc->excl_cntrs) { 2548 if (!cpuc->excl_cntrs)
2549 kfree(cpuc->constraint_list); 2549 goto err_constraint_list;
2550 kfree(cpuc->shared_regs); 2550
2551 return NOTIFY_BAD;
2552 }
2553 cpuc->excl_thread_id = 0; 2551 cpuc->excl_thread_id = 0;
2554 } 2552 }
2555 2553
2556 return NOTIFY_OK; 2554 return NOTIFY_OK;
2555
2556err_constraint_list:
2557 kfree(cpuc->constraint_list);
2558 cpuc->constraint_list = NULL;
2559
2560err_shared_regs:
2561 kfree(cpuc->shared_regs);
2562 cpuc->shared_regs = NULL;
2563
2564err:
2565 return NOTIFY_BAD;
2557} 2566}
2558 2567
2559static void intel_pmu_cpu_starting(int cpu) 2568static void intel_pmu_cpu_starting(int cpu)
diff --git a/arch/x86/kernel/cpu/perf_event_intel_cqm.c b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
index 63eb68b73589..377e8f8ed391 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_cqm.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
@@ -1255,7 +1255,7 @@ static inline void cqm_pick_event_reader(int cpu)
1255 cpumask_set_cpu(cpu, &cqm_cpumask); 1255 cpumask_set_cpu(cpu, &cqm_cpumask);
1256} 1256}
1257 1257
1258static void intel_cqm_cpu_prepare(unsigned int cpu) 1258static void intel_cqm_cpu_starting(unsigned int cpu)
1259{ 1259{
1260 struct intel_pqr_state *state = &per_cpu(pqr_state, cpu); 1260 struct intel_pqr_state *state = &per_cpu(pqr_state, cpu);
1261 struct cpuinfo_x86 *c = &cpu_data(cpu); 1261 struct cpuinfo_x86 *c = &cpu_data(cpu);
@@ -1296,13 +1296,11 @@ static int intel_cqm_cpu_notifier(struct notifier_block *nb,
1296 unsigned int cpu = (unsigned long)hcpu; 1296 unsigned int cpu = (unsigned long)hcpu;
1297 1297
1298 switch (action & ~CPU_TASKS_FROZEN) { 1298 switch (action & ~CPU_TASKS_FROZEN) {
1299 case CPU_UP_PREPARE:
1300 intel_cqm_cpu_prepare(cpu);
1301 break;
1302 case CPU_DOWN_PREPARE: 1299 case CPU_DOWN_PREPARE:
1303 intel_cqm_cpu_exit(cpu); 1300 intel_cqm_cpu_exit(cpu);
1304 break; 1301 break;
1305 case CPU_STARTING: 1302 case CPU_STARTING:
1303 intel_cqm_cpu_starting(cpu);
1306 cqm_pick_event_reader(cpu); 1304 cqm_pick_event_reader(cpu);
1307 break; 1305 break;
1308 } 1306 }
@@ -1373,7 +1371,7 @@ static int __init intel_cqm_init(void)
1373 goto out; 1371 goto out;
1374 1372
1375 for_each_online_cpu(i) { 1373 for_each_online_cpu(i) {
1376 intel_cqm_cpu_prepare(i); 1374 intel_cqm_cpu_starting(i);
1377 cqm_pick_event_reader(i); 1375 cqm_pick_event_reader(i);
1378 } 1376 }
1379 1377
diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
index 6273324186ac..0ccb53a9fcd9 100644
--- a/arch/x86/kernel/step.c
+++ b/arch/x86/kernel/step.c
@@ -28,11 +28,11 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
28 struct desc_struct *desc; 28 struct desc_struct *desc;
29 unsigned long base; 29 unsigned long base;
30 30
31 seg &= ~7UL; 31 seg >>= 3;
32 32
33 mutex_lock(&child->mm->context.lock); 33 mutex_lock(&child->mm->context.lock);
34 if (unlikely(!child->mm->context.ldt || 34 if (unlikely(!child->mm->context.ldt ||
35 (seg >> 3) >= child->mm->context.ldt->size)) 35 seg >= child->mm->context.ldt->size))
36 addr = -1L; /* bogus selector, access would fault */ 36 addr = -1L; /* bogus selector, access would fault */
37 else { 37 else {
38 desc = &child->mm->context.ldt->entries[seg]; 38 desc = &child->mm->context.ldt->entries[seg];
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 5ef2560075bf..8f0f6eca69da 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2105,7 +2105,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
2105 if (guest_cpuid_has_tsc_adjust(vcpu)) { 2105 if (guest_cpuid_has_tsc_adjust(vcpu)) {
2106 if (!msr_info->host_initiated) { 2106 if (!msr_info->host_initiated) {
2107 s64 adj = data - vcpu->arch.ia32_tsc_adjust_msr; 2107 s64 adj = data - vcpu->arch.ia32_tsc_adjust_msr;
2108 kvm_x86_ops->adjust_tsc_offset(vcpu, adj, true); 2108 adjust_tsc_offset_guest(vcpu, adj);
2109 } 2109 }
2110 vcpu->arch.ia32_tsc_adjust_msr = data; 2110 vcpu->arch.ia32_tsc_adjust_msr = data;
2111 } 2111 }
@@ -6327,6 +6327,7 @@ static void process_smi_save_state_64(struct kvm_vcpu *vcpu, char *buf)
6327static void process_smi(struct kvm_vcpu *vcpu) 6327static void process_smi(struct kvm_vcpu *vcpu)
6328{ 6328{
6329 struct kvm_segment cs, ds; 6329 struct kvm_segment cs, ds;
6330 struct desc_ptr dt;
6330 char buf[512]; 6331 char buf[512];
6331 u32 cr0; 6332 u32 cr0;
6332 6333
@@ -6359,6 +6360,10 @@ static void process_smi(struct kvm_vcpu *vcpu)
6359 6360
6360 kvm_x86_ops->set_cr4(vcpu, 0); 6361 kvm_x86_ops->set_cr4(vcpu, 0);
6361 6362
6363 /* Undocumented: IDT limit is set to zero on entry to SMM. */
6364 dt.address = dt.size = 0;
6365 kvm_x86_ops->set_idt(vcpu, &dt);
6366
6362 __kvm_set_dr(vcpu, 7, DR7_FIXED_1); 6367 __kvm_set_dr(vcpu, 7, DR7_FIXED_1);
6363 6368
6364 cs.selector = (vcpu->arch.smbase >> 4) & 0xffff; 6369 cs.selector = (vcpu->arch.smbase >> 4) & 0xffff;
diff --git a/arch/x86/math-emu/fpu_entry.c b/arch/x86/math-emu/fpu_entry.c
index f37e84ab49f3..3d8f2e421466 100644
--- a/arch/x86/math-emu/fpu_entry.c
+++ b/arch/x86/math-emu/fpu_entry.c
@@ -29,7 +29,6 @@
29 29
30#include <asm/uaccess.h> 30#include <asm/uaccess.h>
31#include <asm/traps.h> 31#include <asm/traps.h>
32#include <asm/desc.h>
33#include <asm/user.h> 32#include <asm/user.h>
34#include <asm/fpu/internal.h> 33#include <asm/fpu/internal.h>
35 34
@@ -181,7 +180,7 @@ void math_emulate(struct math_emu_info *info)
181 math_abort(FPU_info, SIGILL); 180 math_abort(FPU_info, SIGILL);
182 } 181 }
183 182
184 code_descriptor = LDT_DESCRIPTOR(FPU_CS); 183 code_descriptor = FPU_get_ldt_descriptor(FPU_CS);
185 if (SEG_D_SIZE(code_descriptor)) { 184 if (SEG_D_SIZE(code_descriptor)) {
186 /* The above test may be wrong, the book is not clear */ 185 /* The above test may be wrong, the book is not clear */
187 /* Segmented 32 bit protected mode */ 186 /* Segmented 32 bit protected mode */
diff --git a/arch/x86/math-emu/fpu_system.h b/arch/x86/math-emu/fpu_system.h
index 9ccecb61a4fa..5e044d506b7a 100644
--- a/arch/x86/math-emu/fpu_system.h
+++ b/arch/x86/math-emu/fpu_system.h
@@ -16,9 +16,24 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18 18
19/* s is always from a cpu register, and the cpu does bounds checking 19#include <asm/desc.h>
20 * during register load --> no further bounds checks needed */ 20#include <asm/mmu_context.h>
21#define LDT_DESCRIPTOR(s) (((struct desc_struct *)current->mm->context.ldt)[(s) >> 3]) 21
22static inline struct desc_struct FPU_get_ldt_descriptor(unsigned seg)
23{
24 static struct desc_struct zero_desc;
25 struct desc_struct ret = zero_desc;
26
27#ifdef CONFIG_MODIFY_LDT_SYSCALL
28 seg >>= 3;
29 mutex_lock(&current->mm->context.lock);
30 if (current->mm->context.ldt && seg < current->mm->context.ldt->size)
31 ret = current->mm->context.ldt->entries[seg];
32 mutex_unlock(&current->mm->context.lock);
33#endif
34 return ret;
35}
36
22#define SEG_D_SIZE(x) ((x).b & (3 << 21)) 37#define SEG_D_SIZE(x) ((x).b & (3 << 21))
23#define SEG_G_BIT(x) ((x).b & (1 << 23)) 38#define SEG_G_BIT(x) ((x).b & (1 << 23))
24#define SEG_GRANULARITY(x) (((x).b & (1 << 23)) ? 4096 : 1) 39#define SEG_GRANULARITY(x) (((x).b & (1 << 23)) ? 4096 : 1)
diff --git a/arch/x86/math-emu/get_address.c b/arch/x86/math-emu/get_address.c
index 6ef5e99380f9..8300db71c2a6 100644
--- a/arch/x86/math-emu/get_address.c
+++ b/arch/x86/math-emu/get_address.c
@@ -20,7 +20,6 @@
20#include <linux/stddef.h> 20#include <linux/stddef.h>
21 21
22#include <asm/uaccess.h> 22#include <asm/uaccess.h>
23#include <asm/desc.h>
24 23
25#include "fpu_system.h" 24#include "fpu_system.h"
26#include "exception.h" 25#include "exception.h"
@@ -158,7 +157,7 @@ static long pm_address(u_char FPU_modrm, u_char segment,
158 addr->selector = PM_REG_(segment); 157 addr->selector = PM_REG_(segment);
159 } 158 }
160 159
161 descriptor = LDT_DESCRIPTOR(PM_REG_(segment)); 160 descriptor = FPU_get_ldt_descriptor(addr->selector);
162 base_address = SEG_BASE_ADDR(descriptor); 161 base_address = SEG_BASE_ADDR(descriptor);
163 address = base_address + offset; 162 address = base_address + offset;
164 limit = base_address 163 limit = base_address
diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
index e88fda867a33..484145368a24 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -8,7 +8,7 @@ config XEN
8 select PARAVIRT_CLOCK 8 select PARAVIRT_CLOCK
9 select XEN_HAVE_PVMMU 9 select XEN_HAVE_PVMMU
10 depends on X86_64 || (X86_32 && X86_PAE) 10 depends on X86_64 || (X86_32 && X86_PAE)
11 depends on X86_TSC 11 depends on X86_LOCAL_APIC && X86_TSC
12 help 12 help
13 This is the Linux Xen port. Enabling this will allow the 13 This is the Linux Xen port. Enabling this will allow the
14 kernel to boot in a paravirtualized environment under the 14 kernel to boot in a paravirtualized environment under the
@@ -17,7 +17,7 @@ config XEN
17config XEN_DOM0 17config XEN_DOM0
18 def_bool y 18 def_bool y
19 depends on XEN && PCI_XEN && SWIOTLB_XEN 19 depends on XEN && PCI_XEN && SWIOTLB_XEN
20 depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI 20 depends on X86_IO_APIC && ACPI && PCI
21 21
22config XEN_PVHVM 22config XEN_PVHVM
23 def_bool y 23 def_bool y
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 12600bfffca9..e0057d035200 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -241,8 +241,8 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
241 * Description: 241 * Description:
242 * Enables a low level driver to set a hard upper limit, 242 * Enables a low level driver to set a hard upper limit,
243 * max_hw_sectors, on the size of requests. max_hw_sectors is set by 243 * max_hw_sectors, on the size of requests. max_hw_sectors is set by
244 * the device driver based upon the combined capabilities of I/O 244 * the device driver based upon the capabilities of the I/O
245 * controller and storage device. 245 * controller.
246 * 246 *
247 * max_sectors is a soft limit imposed by the block layer for 247 * max_sectors is a soft limit imposed by the block layer for
248 * filesystem type requests. This value can be overridden on a 248 * filesystem type requests. This value can be overridden on a
diff --git a/crypto/authencesn.c b/crypto/authencesn.c
index a3da6770bc9e..b8efe36ce114 100644
--- a/crypto/authencesn.c
+++ b/crypto/authencesn.c
@@ -393,8 +393,6 @@ static int crypto_authenc_esn_genicv(struct aead_request *req, u8 *iv,
393 struct scatterlist *cipher = areq_ctx->cipher; 393 struct scatterlist *cipher = areq_ctx->cipher;
394 struct scatterlist *hsg = areq_ctx->hsg; 394 struct scatterlist *hsg = areq_ctx->hsg;
395 struct scatterlist *tsg = areq_ctx->tsg; 395 struct scatterlist *tsg = areq_ctx->tsg;
396 struct scatterlist *assoc1;
397 struct scatterlist *assoc2;
398 unsigned int ivsize = crypto_aead_ivsize(authenc_esn); 396 unsigned int ivsize = crypto_aead_ivsize(authenc_esn);
399 unsigned int cryptlen = req->cryptlen; 397 unsigned int cryptlen = req->cryptlen;
400 struct page *dstp; 398 struct page *dstp;
@@ -412,27 +410,19 @@ static int crypto_authenc_esn_genicv(struct aead_request *req, u8 *iv,
412 cryptlen += ivsize; 410 cryptlen += ivsize;
413 } 411 }
414 412
415 if (sg_is_last(assoc)) 413 if (assoc->length < 12)
416 return -EINVAL;
417
418 assoc1 = assoc + 1;
419 if (sg_is_last(assoc1))
420 return -EINVAL;
421
422 assoc2 = assoc + 2;
423 if (!sg_is_last(assoc2))
424 return -EINVAL; 414 return -EINVAL;
425 415
426 sg_init_table(hsg, 2); 416 sg_init_table(hsg, 2);
427 sg_set_page(hsg, sg_page(assoc), assoc->length, assoc->offset); 417 sg_set_page(hsg, sg_page(assoc), 4, assoc->offset);
428 sg_set_page(hsg + 1, sg_page(assoc2), assoc2->length, assoc2->offset); 418 sg_set_page(hsg + 1, sg_page(assoc), 4, assoc->offset + 8);
429 419
430 sg_init_table(tsg, 1); 420 sg_init_table(tsg, 1);
431 sg_set_page(tsg, sg_page(assoc1), assoc1->length, assoc1->offset); 421 sg_set_page(tsg, sg_page(assoc), 4, assoc->offset + 4);
432 422
433 areq_ctx->cryptlen = cryptlen; 423 areq_ctx->cryptlen = cryptlen;
434 areq_ctx->headlen = assoc->length + assoc2->length; 424 areq_ctx->headlen = 8;
435 areq_ctx->trailen = assoc1->length; 425 areq_ctx->trailen = 4;
436 areq_ctx->sg = dst; 426 areq_ctx->sg = dst;
437 427
438 areq_ctx->complete = authenc_esn_geniv_ahash_done; 428 areq_ctx->complete = authenc_esn_geniv_ahash_done;
@@ -563,8 +553,6 @@ static int crypto_authenc_esn_iverify(struct aead_request *req, u8 *iv,
563 struct scatterlist *cipher = areq_ctx->cipher; 553 struct scatterlist *cipher = areq_ctx->cipher;
564 struct scatterlist *hsg = areq_ctx->hsg; 554 struct scatterlist *hsg = areq_ctx->hsg;
565 struct scatterlist *tsg = areq_ctx->tsg; 555 struct scatterlist *tsg = areq_ctx->tsg;
566 struct scatterlist *assoc1;
567 struct scatterlist *assoc2;
568 unsigned int ivsize = crypto_aead_ivsize(authenc_esn); 556 unsigned int ivsize = crypto_aead_ivsize(authenc_esn);
569 struct page *srcp; 557 struct page *srcp;
570 u8 *vsrc; 558 u8 *vsrc;
@@ -580,27 +568,19 @@ static int crypto_authenc_esn_iverify(struct aead_request *req, u8 *iv,
580 cryptlen += ivsize; 568 cryptlen += ivsize;
581 } 569 }
582 570
583 if (sg_is_last(assoc)) 571 if (assoc->length < 12)
584 return -EINVAL;
585
586 assoc1 = assoc + 1;
587 if (sg_is_last(assoc1))
588 return -EINVAL;
589
590 assoc2 = assoc + 2;
591 if (!sg_is_last(assoc2))
592 return -EINVAL; 572 return -EINVAL;
593 573
594 sg_init_table(hsg, 2); 574 sg_init_table(hsg, 2);
595 sg_set_page(hsg, sg_page(assoc), assoc->length, assoc->offset); 575 sg_set_page(hsg, sg_page(assoc), 4, assoc->offset);
596 sg_set_page(hsg + 1, sg_page(assoc2), assoc2->length, assoc2->offset); 576 sg_set_page(hsg + 1, sg_page(assoc), 4, assoc->offset + 8);
597 577
598 sg_init_table(tsg, 1); 578 sg_init_table(tsg, 1);
599 sg_set_page(tsg, sg_page(assoc1), assoc1->length, assoc1->offset); 579 sg_set_page(tsg, sg_page(assoc), 4, assoc->offset + 4);
600 580
601 areq_ctx->cryptlen = cryptlen; 581 areq_ctx->cryptlen = cryptlen;
602 areq_ctx->headlen = assoc->length + assoc2->length; 582 areq_ctx->headlen = 8;
603 areq_ctx->trailen = assoc1->length; 583 areq_ctx->trailen = 4;
604 areq_ctx->sg = src; 584 areq_ctx->sg = src;
605 585
606 areq_ctx->complete = authenc_esn_verify_ahash_done; 586 areq_ctx->complete = authenc_esn_verify_ahash_done;
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 815f75ef2411..2922f1f252d5 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -32,6 +32,7 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/workqueue.h>
35#include <acpi/video.h> 36#include <acpi/video.h>
36 37
37ACPI_MODULE_NAME("video"); 38ACPI_MODULE_NAME("video");
@@ -41,6 +42,7 @@ void acpi_video_unregister_backlight(void);
41 42
42static bool backlight_notifier_registered; 43static bool backlight_notifier_registered;
43static struct notifier_block backlight_nb; 44static struct notifier_block backlight_nb;
45static struct work_struct backlight_notify_work;
44 46
45static enum acpi_backlight_type acpi_backlight_cmdline = acpi_backlight_undef; 47static enum acpi_backlight_type acpi_backlight_cmdline = acpi_backlight_undef;
46static enum acpi_backlight_type acpi_backlight_dmi = acpi_backlight_undef; 48static enum acpi_backlight_type acpi_backlight_dmi = acpi_backlight_undef;
@@ -262,6 +264,13 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
262 { }, 264 { },
263}; 265};
264 266
267/* This uses a workqueue to avoid various locking ordering issues */
268static void acpi_video_backlight_notify_work(struct work_struct *work)
269{
270 if (acpi_video_get_backlight_type() != acpi_backlight_video)
271 acpi_video_unregister_backlight();
272}
273
265static int acpi_video_backlight_notify(struct notifier_block *nb, 274static int acpi_video_backlight_notify(struct notifier_block *nb,
266 unsigned long val, void *bd) 275 unsigned long val, void *bd)
267{ 276{
@@ -269,9 +278,8 @@ static int acpi_video_backlight_notify(struct notifier_block *nb,
269 278
270 /* A raw bl registering may change video -> native */ 279 /* A raw bl registering may change video -> native */
271 if (backlight->props.type == BACKLIGHT_RAW && 280 if (backlight->props.type == BACKLIGHT_RAW &&
272 val == BACKLIGHT_REGISTERED && 281 val == BACKLIGHT_REGISTERED)
273 acpi_video_get_backlight_type() != acpi_backlight_video) 282 schedule_work(&backlight_notify_work);
274 acpi_video_unregister_backlight();
275 283
276 return NOTIFY_OK; 284 return NOTIFY_OK;
277} 285}
@@ -304,6 +312,8 @@ enum acpi_backlight_type acpi_video_get_backlight_type(void)
304 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 312 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
305 ACPI_UINT32_MAX, find_video, NULL, 313 ACPI_UINT32_MAX, find_video, NULL,
306 &video_caps, NULL); 314 &video_caps, NULL);
315 INIT_WORK(&backlight_notify_work,
316 acpi_video_backlight_notify_work);
307 backlight_nb.notifier_call = acpi_video_backlight_notify; 317 backlight_nb.notifier_call = acpi_video_backlight_notify;
308 backlight_nb.priority = 0; 318 backlight_nb.priority = 0;
309 if (backlight_register_notifier(&backlight_nb) == 0) 319 if (backlight_register_notifier(&backlight_nb) == 0)
diff --git a/drivers/ata/ahci_brcmstb.c b/drivers/ata/ahci_brcmstb.c
index ce1e3a885981..14b7305d2ba0 100644
--- a/drivers/ata/ahci_brcmstb.c
+++ b/drivers/ata/ahci_brcmstb.c
@@ -92,7 +92,7 @@ static inline u32 brcm_sata_readreg(void __iomem *addr)
92 * Other architectures (e.g., ARM) either do not support big endian, or 92 * Other architectures (e.g., ARM) either do not support big endian, or
93 * else leave I/O in little endian mode. 93 * else leave I/O in little endian mode.
94 */ 94 */
95 if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) 95 if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
96 return __raw_readl(addr); 96 return __raw_readl(addr);
97 else 97 else
98 return readl_relaxed(addr); 98 return readl_relaxed(addr);
@@ -101,7 +101,7 @@ static inline u32 brcm_sata_readreg(void __iomem *addr)
101static inline void brcm_sata_writereg(u32 val, void __iomem *addr) 101static inline void brcm_sata_writereg(u32 val, void __iomem *addr)
102{ 102{
103 /* See brcm_sata_readreg() comments */ 103 /* See brcm_sata_readreg() comments */
104 if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) 104 if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
105 __raw_writel(val, addr); 105 __raw_writel(val, addr);
106 else 106 else
107 writel_relaxed(val, addr); 107 writel_relaxed(val, addr);
@@ -209,6 +209,7 @@ static void brcm_sata_init(struct brcm_ahci_priv *priv)
209 priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL); 209 priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL);
210} 210}
211 211
212#ifdef CONFIG_PM_SLEEP
212static int brcm_ahci_suspend(struct device *dev) 213static int brcm_ahci_suspend(struct device *dev)
213{ 214{
214 struct ata_host *host = dev_get_drvdata(dev); 215 struct ata_host *host = dev_get_drvdata(dev);
@@ -231,6 +232,7 @@ static int brcm_ahci_resume(struct device *dev)
231 brcm_sata_phys_enable(priv); 232 brcm_sata_phys_enable(priv);
232 return ahci_platform_resume(dev); 233 return ahci_platform_resume(dev);
233} 234}
235#endif
234 236
235static struct scsi_host_template ahci_platform_sht = { 237static struct scsi_host_template ahci_platform_sht = {
236 AHCI_SHT(DRV_NAME), 238 AHCI_SHT(DRV_NAME),
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index db5d9f79a247..19bcb80b2031 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -694,11 +694,11 @@ static int ata_rwcmd_protocol(struct ata_taskfile *tf, struct ata_device *dev)
694 * RETURNS: 694 * RETURNS:
695 * Block address read from @tf. 695 * Block address read from @tf.
696 */ 696 */
697u64 ata_tf_read_block(const struct ata_taskfile *tf, struct ata_device *dev) 697u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev)
698{ 698{
699 u64 block = 0; 699 u64 block = 0;
700 700
701 if (!dev || tf->flags & ATA_TFLAG_LBA) { 701 if (tf->flags & ATA_TFLAG_LBA) {
702 if (tf->flags & ATA_TFLAG_LBA48) { 702 if (tf->flags & ATA_TFLAG_LBA48) {
703 block |= (u64)tf->hob_lbah << 40; 703 block |= (u64)tf->hob_lbah << 40;
704 block |= (u64)tf->hob_lbam << 32; 704 block |= (u64)tf->hob_lbam << 32;
@@ -2147,24 +2147,6 @@ static int ata_dev_config_ncq(struct ata_device *dev,
2147 return 0; 2147 return 0;
2148} 2148}
2149 2149
2150static void ata_dev_config_sense_reporting(struct ata_device *dev)
2151{
2152 unsigned int err_mask;
2153
2154 if (!ata_id_has_sense_reporting(dev->id))
2155 return;
2156
2157 if (ata_id_sense_reporting_enabled(dev->id))
2158 return;
2159
2160 err_mask = ata_dev_set_feature(dev, SETFEATURE_SENSE_DATA, 0x1);
2161 if (err_mask) {
2162 ata_dev_dbg(dev,
2163 "failed to enable Sense Data Reporting, Emask 0x%x\n",
2164 err_mask);
2165 }
2166}
2167
2168/** 2150/**
2169 * ata_dev_configure - Configure the specified ATA/ATAPI device 2151 * ata_dev_configure - Configure the specified ATA/ATAPI device
2170 * @dev: Target device to configure 2152 * @dev: Target device to configure
@@ -2387,7 +2369,7 @@ int ata_dev_configure(struct ata_device *dev)
2387 dev->devslp_timing[i] = sata_setting[j]; 2369 dev->devslp_timing[i] = sata_setting[j];
2388 } 2370 }
2389 } 2371 }
2390 ata_dev_config_sense_reporting(dev); 2372
2391 dev->cdb_len = 16; 2373 dev->cdb_len = 16;
2392 } 2374 }
2393 2375
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 7465031a893c..cb0508af1459 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1592,8 +1592,6 @@ static int ata_eh_read_log_10h(struct ata_device *dev,
1592 tf->hob_lbah = buf[10]; 1592 tf->hob_lbah = buf[10];
1593 tf->nsect = buf[12]; 1593 tf->nsect = buf[12];
1594 tf->hob_nsect = buf[13]; 1594 tf->hob_nsect = buf[13];
1595 if (ata_id_has_ncq_autosense(dev->id))
1596 tf->auxiliary = buf[14] << 16 | buf[15] << 8 | buf[16];
1597 1595
1598 return 0; 1596 return 0;
1599} 1597}
@@ -1630,70 +1628,6 @@ unsigned int atapi_eh_tur(struct ata_device *dev, u8 *r_sense_key)
1630} 1628}
1631 1629
1632/** 1630/**
1633 * ata_eh_request_sense - perform REQUEST_SENSE_DATA_EXT
1634 * @dev: device to perform REQUEST_SENSE_SENSE_DATA_EXT to
1635 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long)
1636 * @dfl_sense_key: default sense key to use
1637 *
1638 * Perform REQUEST_SENSE_DATA_EXT after the device reported CHECK
1639 * SENSE. This function is EH helper.
1640 *
1641 * LOCKING:
1642 * Kernel thread context (may sleep).
1643 *
1644 * RETURNS:
1645 * encoded sense data on success, 0 on failure or if sense data
1646 * is not available.
1647 */
1648static u32 ata_eh_request_sense(struct ata_queued_cmd *qc,
1649 struct scsi_cmnd *cmd)
1650{
1651 struct ata_device *dev = qc->dev;
1652 struct ata_taskfile tf;
1653 unsigned int err_mask;
1654
1655 if (!cmd)
1656 return 0;
1657
1658 DPRINTK("ATA request sense\n");
1659 ata_dev_warn(dev, "request sense\n");
1660 if (!ata_id_sense_reporting_enabled(dev->id)) {
1661 ata_dev_warn(qc->dev, "sense data reporting disabled\n");
1662 return 0;
1663 }
1664 ata_tf_init(dev, &tf);
1665
1666 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1667 tf.flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
1668 tf.command = ATA_CMD_REQ_SENSE_DATA;
1669 tf.protocol = ATA_PROT_NODATA;
1670
1671 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
1672 /*
1673 * ACS-4 states:
1674 * The device may set the SENSE DATA AVAILABLE bit to one in the
1675 * STATUS field and clear the ERROR bit to zero in the STATUS field
1676 * to indicate that the command returned completion without an error
1677 * and the sense data described in table 306 is available.
1678 *
1679 * IOW the 'ATA_SENSE' bit might not be set even though valid
1680 * sense data is available.
1681 * So check for both.
1682 */
1683 if ((tf.command & ATA_SENSE) ||
1684 tf.lbah != 0 || tf.lbam != 0 || tf.lbal != 0) {
1685 ata_scsi_set_sense(cmd, tf.lbah, tf.lbam, tf.lbal);
1686 qc->flags |= ATA_QCFLAG_SENSE_VALID;
1687 ata_dev_warn(dev, "sense data %02x/%02x/%02x\n",
1688 tf.lbah, tf.lbam, tf.lbal);
1689 } else {
1690 ata_dev_warn(dev, "request sense failed stat %02x emask %x\n",
1691 tf.command, err_mask);
1692 }
1693 return err_mask;
1694}
1695
1696/**
1697 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE 1631 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE
1698 * @dev: device to perform REQUEST_SENSE to 1632 * @dev: device to perform REQUEST_SENSE to
1699 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long) 1633 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long)
@@ -1855,19 +1789,6 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
1855 memcpy(&qc->result_tf, &tf, sizeof(tf)); 1789 memcpy(&qc->result_tf, &tf, sizeof(tf));
1856 qc->result_tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_LBA | ATA_TFLAG_LBA48; 1790 qc->result_tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
1857 qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ; 1791 qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ;
1858 if (qc->result_tf.auxiliary) {
1859 char sense_key, asc, ascq;
1860
1861 sense_key = (qc->result_tf.auxiliary >> 16) & 0xff;
1862 asc = (qc->result_tf.auxiliary >> 8) & 0xff;
1863 ascq = qc->result_tf.auxiliary & 0xff;
1864 ata_dev_dbg(dev, "NCQ Autosense %02x/%02x/%02x\n",
1865 sense_key, asc, ascq);
1866 ata_scsi_set_sense(qc->scsicmd, sense_key, asc, ascq);
1867 ata_scsi_set_sense_information(qc->scsicmd, &qc->result_tf);
1868 qc->flags |= ATA_QCFLAG_SENSE_VALID;
1869 }
1870
1871 ehc->i.err_mask &= ~AC_ERR_DEV; 1792 ehc->i.err_mask &= ~AC_ERR_DEV;
1872} 1793}
1873 1794
@@ -1897,27 +1818,6 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
1897 return ATA_EH_RESET; 1818 return ATA_EH_RESET;
1898 } 1819 }
1899 1820
1900 /*
1901 * Sense data reporting does not work if the
1902 * device fault bit is set.
1903 */
1904 if ((stat & ATA_SENSE) && !(stat & ATA_DF) &&
1905 !(qc->flags & ATA_QCFLAG_SENSE_VALID)) {
1906 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) {
1907 tmp = ata_eh_request_sense(qc, qc->scsicmd);
1908 if (tmp)
1909 qc->err_mask |= tmp;
1910 else
1911 ata_scsi_set_sense_information(qc->scsicmd, tf);
1912 } else {
1913 ata_dev_warn(qc->dev, "sense data available but port frozen\n");
1914 }
1915 }
1916
1917 /* Set by NCQ autosense or request sense above */
1918 if (qc->flags & ATA_QCFLAG_SENSE_VALID)
1919 return 0;
1920
1921 if (stat & (ATA_ERR | ATA_DF)) 1821 if (stat & (ATA_ERR | ATA_DF))
1922 qc->err_mask |= AC_ERR_DEV; 1822 qc->err_mask |= AC_ERR_DEV;
1923 else 1823 else
@@ -2661,15 +2561,14 @@ static void ata_eh_link_report(struct ata_link *link)
2661 2561
2662#ifdef CONFIG_ATA_VERBOSE_ERROR 2562#ifdef CONFIG_ATA_VERBOSE_ERROR
2663 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | 2563 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ |
2664 ATA_SENSE | ATA_ERR)) { 2564 ATA_ERR)) {
2665 if (res->command & ATA_BUSY) 2565 if (res->command & ATA_BUSY)
2666 ata_dev_err(qc->dev, "status: { Busy }\n"); 2566 ata_dev_err(qc->dev, "status: { Busy }\n");
2667 else 2567 else
2668 ata_dev_err(qc->dev, "status: { %s%s%s%s%s}\n", 2568 ata_dev_err(qc->dev, "status: { %s%s%s%s}\n",
2669 res->command & ATA_DRDY ? "DRDY " : "", 2569 res->command & ATA_DRDY ? "DRDY " : "",
2670 res->command & ATA_DF ? "DF " : "", 2570 res->command & ATA_DF ? "DF " : "",
2671 res->command & ATA_DRQ ? "DRQ " : "", 2571 res->command & ATA_DRQ ? "DRQ " : "",
2672 res->command & ATA_SENSE ? "SENSE " : "",
2673 res->command & ATA_ERR ? "ERR " : ""); 2572 res->command & ATA_ERR ? "ERR " : "");
2674 } 2573 }
2675 2574
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 641a61a59e89..0d7f0da3a269 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -270,28 +270,13 @@ DEVICE_ATTR(unload_heads, S_IRUGO | S_IWUSR,
270 ata_scsi_park_show, ata_scsi_park_store); 270 ata_scsi_park_show, ata_scsi_park_store);
271EXPORT_SYMBOL_GPL(dev_attr_unload_heads); 271EXPORT_SYMBOL_GPL(dev_attr_unload_heads);
272 272
273void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq) 273static void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
274{ 274{
275 if (!cmd)
276 return;
277
278 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 275 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
279 276
280 scsi_build_sense_buffer(0, cmd->sense_buffer, sk, asc, ascq); 277 scsi_build_sense_buffer(0, cmd->sense_buffer, sk, asc, ascq);
281} 278}
282 279
283void ata_scsi_set_sense_information(struct scsi_cmnd *cmd,
284 const struct ata_taskfile *tf)
285{
286 u64 information;
287
288 if (!cmd)
289 return;
290
291 information = ata_tf_read_block(tf, NULL);
292 scsi_set_sense_information(cmd->sense_buffer, information);
293}
294
295static ssize_t 280static ssize_t
296ata_scsi_em_message_store(struct device *dev, struct device_attribute *attr, 281ata_scsi_em_message_store(struct device *dev, struct device_attribute *attr,
297 const char *buf, size_t count) 282 const char *buf, size_t count)
@@ -1792,9 +1777,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1792 ((cdb[2] & 0x20) || need_sense)) { 1777 ((cdb[2] & 0x20) || need_sense)) {
1793 ata_gen_passthru_sense(qc); 1778 ata_gen_passthru_sense(qc);
1794 } else { 1779 } else {
1795 if (qc->flags & ATA_QCFLAG_SENSE_VALID) { 1780 if (!need_sense) {
1796 cmd->result = SAM_STAT_CHECK_CONDITION;
1797 } else if (!need_sense) {
1798 cmd->result = SAM_STAT_GOOD; 1781 cmd->result = SAM_STAT_GOOD;
1799 } else { 1782 } else {
1800 /* TODO: decide which descriptor format to use 1783 /* TODO: decide which descriptor format to use
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index a998a175f9f1..f840ca18a7c0 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -67,8 +67,7 @@ extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag);
67extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, 67extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
68 u64 block, u32 n_block, unsigned int tf_flags, 68 u64 block, u32 n_block, unsigned int tf_flags,
69 unsigned int tag); 69 unsigned int tag);
70extern u64 ata_tf_read_block(const struct ata_taskfile *tf, 70extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev);
71 struct ata_device *dev);
72extern unsigned ata_exec_internal(struct ata_device *dev, 71extern unsigned ata_exec_internal(struct ata_device *dev,
73 struct ata_taskfile *tf, const u8 *cdb, 72 struct ata_taskfile *tf, const u8 *cdb,
74 int dma_dir, void *buf, unsigned int buflen, 73 int dma_dir, void *buf, unsigned int buflen,
@@ -138,9 +137,6 @@ extern int ata_scsi_add_hosts(struct ata_host *host,
138 struct scsi_host_template *sht); 137 struct scsi_host_template *sht);
139extern void ata_scsi_scan_host(struct ata_port *ap, int sync); 138extern void ata_scsi_scan_host(struct ata_port *ap, int sync);
140extern int ata_scsi_offline_dev(struct ata_device *dev); 139extern int ata_scsi_offline_dev(struct ata_device *dev);
141extern void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq);
142extern void ata_scsi_set_sense_information(struct scsi_cmnd *cmd,
143 const struct ata_taskfile *tf);
144extern void ata_scsi_media_change_notify(struct ata_device *dev); 140extern void ata_scsi_media_change_notify(struct ata_device *dev);
145extern void ata_scsi_hotplug(struct work_struct *work); 141extern void ata_scsi_hotplug(struct work_struct *work);
146extern void ata_schedule_scsi_eh(struct Scsi_Host *shost); 142extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index 3a18a8a719b4..fab504fd9cfd 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -1238,8 +1238,12 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host)
1238 readl(mmio + PDC_SDRAM_CONTROL); 1238 readl(mmio + PDC_SDRAM_CONTROL);
1239 1239
1240 /* Turn on for ECC */ 1240 /* Turn on for ECC */
1241 pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 1241 if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1242 PDC_DIMM_SPD_TYPE, &spd0); 1242 PDC_DIMM_SPD_TYPE, &spd0)) {
1243 pr_err("Failed in i2c read: device=%#x, subaddr=%#x\n",
1244 PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
1245 return 1;
1246 }
1243 if (spd0 == 0x02) { 1247 if (spd0 == 0x02) {
1244 data |= (0x01 << 16); 1248 data |= (0x01 << 16);
1245 writel(data, mmio + PDC_SDRAM_CONTROL); 1249 writel(data, mmio + PDC_SDRAM_CONTROL);
@@ -1380,8 +1384,12 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host)
1380 1384
1381 /* ECC initiliazation. */ 1385 /* ECC initiliazation. */
1382 1386
1383 pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 1387 if (!pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS,
1384 PDC_DIMM_SPD_TYPE, &spd0); 1388 PDC_DIMM_SPD_TYPE, &spd0)) {
1389 pr_err("Failed in i2c read: device=%#x, subaddr=%#x\n",
1390 PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_TYPE);
1391 return 1;
1392 }
1385 if (spd0 == 0x02) { 1393 if (spd0 == 0x02) {
1386 void *buf; 1394 void *buf;
1387 VPRINTK("Start ECC initialization\n"); 1395 VPRINTK("Start ECC initialization\n");
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index fb655e8d1e3b..763301c7828c 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -496,10 +496,9 @@ static void zram_meta_free(struct zram_meta *meta, u64 disksize)
496 kfree(meta); 496 kfree(meta);
497} 497}
498 498
499static struct zram_meta *zram_meta_alloc(int device_id, u64 disksize) 499static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize)
500{ 500{
501 size_t num_pages; 501 size_t num_pages;
502 char pool_name[8];
503 struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL); 502 struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL);
504 503
505 if (!meta) 504 if (!meta)
@@ -512,7 +511,6 @@ static struct zram_meta *zram_meta_alloc(int device_id, u64 disksize)
512 goto out_error; 511 goto out_error;
513 } 512 }
514 513
515 snprintf(pool_name, sizeof(pool_name), "zram%d", device_id);
516 meta->mem_pool = zs_create_pool(pool_name, GFP_NOIO | __GFP_HIGHMEM); 514 meta->mem_pool = zs_create_pool(pool_name, GFP_NOIO | __GFP_HIGHMEM);
517 if (!meta->mem_pool) { 515 if (!meta->mem_pool) {
518 pr_err("Error creating memory pool\n"); 516 pr_err("Error creating memory pool\n");
@@ -1031,7 +1029,7 @@ static ssize_t disksize_store(struct device *dev,
1031 return -EINVAL; 1029 return -EINVAL;
1032 1030
1033 disksize = PAGE_ALIGN(disksize); 1031 disksize = PAGE_ALIGN(disksize);
1034 meta = zram_meta_alloc(zram->disk->first_minor, disksize); 1032 meta = zram_meta_alloc(zram->disk->disk_name, disksize);
1035 if (!meta) 1033 if (!meta)
1036 return -ENOMEM; 1034 return -ENOMEM;
1037 1035
diff --git a/drivers/clk/pxa/clk-pxa3xx.c b/drivers/clk/pxa/clk-pxa3xx.c
index 4b93a1efb36d..ac03ba49e9d1 100644
--- a/drivers/clk/pxa/clk-pxa3xx.c
+++ b/drivers/clk/pxa/clk-pxa3xx.c
@@ -126,7 +126,7 @@ PARENTS(pxa3xx_ac97_bus) = { "ring_osc_60mhz", "ac97" };
126PARENTS(pxa3xx_sbus) = { "ring_osc_60mhz", "system_bus" }; 126PARENTS(pxa3xx_sbus) = { "ring_osc_60mhz", "system_bus" };
127PARENTS(pxa3xx_smemcbus) = { "ring_osc_60mhz", "smemc" }; 127PARENTS(pxa3xx_smemcbus) = { "ring_osc_60mhz", "smemc" };
128 128
129#define CKEN_AB(bit) ((CKEN_ ## bit > 31) ? &CKENA : &CKENB) 129#define CKEN_AB(bit) ((CKEN_ ## bit > 31) ? &CKENB : &CKENA)
130#define PXA3XX_CKEN(dev_id, con_id, parents, mult_lp, div_lp, mult_hp, \ 130#define PXA3XX_CKEN(dev_id, con_id, parents, mult_lp, div_lp, mult_hp, \
131 div_hp, bit, is_lp, flags) \ 131 div_hp, bit, is_lp, flags) \
132 PXA_CKEN(dev_id, con_id, bit, parents, mult_lp, div_lp, \ 132 PXA_CKEN(dev_id, con_id, bit, parents, mult_lp, div_lp, \
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index b8ff3c64cc45..c96de14036a0 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -661,6 +661,9 @@ static void sh_cmt_clocksource_suspend(struct clocksource *cs)
661{ 661{
662 struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); 662 struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
663 663
664 if (!ch->cs_enabled)
665 return;
666
664 sh_cmt_stop(ch, FLAG_CLOCKSOURCE); 667 sh_cmt_stop(ch, FLAG_CLOCKSOURCE);
665 pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev); 668 pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev);
666} 669}
@@ -669,6 +672,9 @@ static void sh_cmt_clocksource_resume(struct clocksource *cs)
669{ 672{
670 struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); 673 struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
671 674
675 if (!ch->cs_enabled)
676 return;
677
672 pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); 678 pm_genpd_syscore_poweron(&ch->cmt->pdev->dev);
673 sh_cmt_start(ch, FLAG_CLOCKSOURCE); 679 sh_cmt_start(ch, FLAG_CLOCKSOURCE);
674} 680}
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index ae5b2bd3a978..fa3dd840a837 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -180,7 +180,7 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
180 ret = exynos5250_cpufreq_init(exynos_info); 180 ret = exynos5250_cpufreq_init(exynos_info);
181 } else { 181 } else {
182 pr_err("%s: Unknown SoC type\n", __func__); 182 pr_err("%s: Unknown SoC type\n", __func__);
183 return -ENODEV; 183 ret = -ENODEV;
184 } 184 }
185 185
186 if (ret) 186 if (ret)
@@ -188,12 +188,14 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
188 188
189 if (exynos_info->set_freq == NULL) { 189 if (exynos_info->set_freq == NULL) {
190 dev_err(&pdev->dev, "No set_freq function (ERR)\n"); 190 dev_err(&pdev->dev, "No set_freq function (ERR)\n");
191 ret = -EINVAL;
191 goto err_vdd_arm; 192 goto err_vdd_arm;
192 } 193 }
193 194
194 arm_regulator = regulator_get(NULL, "vdd_arm"); 195 arm_regulator = regulator_get(NULL, "vdd_arm");
195 if (IS_ERR(arm_regulator)) { 196 if (IS_ERR(arm_regulator)) {
196 dev_err(&pdev->dev, "failed to get resource vdd_arm\n"); 197 dev_err(&pdev->dev, "failed to get resource vdd_arm\n");
198 ret = -EINVAL;
197 goto err_vdd_arm; 199 goto err_vdd_arm;
198 } 200 }
199 201
@@ -225,7 +227,7 @@ err_cpufreq_reg:
225 regulator_put(arm_regulator); 227 regulator_put(arm_regulator);
226err_vdd_arm: 228err_vdd_arm:
227 kfree(exynos_info); 229 kfree(exynos_info);
228 return -EINVAL; 230 return ret;
229} 231}
230 232
231static struct platform_driver exynos_cpufreq_platdrv = { 233static struct platform_driver exynos_cpufreq_platdrv = {
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index dae1e8099969..f9c78751989e 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -909,13 +909,14 @@ static int ahash_final_ctx(struct ahash_request *req)
909 state->buflen_1; 909 state->buflen_1;
910 u32 *sh_desc = ctx->sh_desc_fin, *desc; 910 u32 *sh_desc = ctx->sh_desc_fin, *desc;
911 dma_addr_t ptr = ctx->sh_desc_fin_dma; 911 dma_addr_t ptr = ctx->sh_desc_fin_dma;
912 int sec4_sg_bytes; 912 int sec4_sg_bytes, sec4_sg_src_index;
913 int digestsize = crypto_ahash_digestsize(ahash); 913 int digestsize = crypto_ahash_digestsize(ahash);
914 struct ahash_edesc *edesc; 914 struct ahash_edesc *edesc;
915 int ret = 0; 915 int ret = 0;
916 int sh_len; 916 int sh_len;
917 917
918 sec4_sg_bytes = (1 + (buflen ? 1 : 0)) * sizeof(struct sec4_sg_entry); 918 sec4_sg_src_index = 1 + (buflen ? 1 : 0);
919 sec4_sg_bytes = sec4_sg_src_index * sizeof(struct sec4_sg_entry);
919 920
920 /* allocate space for base edesc and hw desc commands, link tables */ 921 /* allocate space for base edesc and hw desc commands, link tables */
921 edesc = kmalloc(sizeof(struct ahash_edesc) + DESC_JOB_IO_LEN + 922 edesc = kmalloc(sizeof(struct ahash_edesc) + DESC_JOB_IO_LEN +
@@ -942,7 +943,7 @@ static int ahash_final_ctx(struct ahash_request *req)
942 state->buf_dma = try_buf_map_to_sec4_sg(jrdev, edesc->sec4_sg + 1, 943 state->buf_dma = try_buf_map_to_sec4_sg(jrdev, edesc->sec4_sg + 1,
943 buf, state->buf_dma, buflen, 944 buf, state->buf_dma, buflen,
944 last_buflen); 945 last_buflen);
945 (edesc->sec4_sg + sec4_sg_bytes - 1)->len |= SEC4_SG_LEN_FIN; 946 (edesc->sec4_sg + sec4_sg_src_index - 1)->len |= SEC4_SG_LEN_FIN;
946 947
947 edesc->sec4_sg_dma = dma_map_single(jrdev, edesc->sec4_sg, 948 edesc->sec4_sg_dma = dma_map_single(jrdev, edesc->sec4_sg,
948 sec4_sg_bytes, DMA_TO_DEVICE); 949 sec4_sg_bytes, DMA_TO_DEVICE);
diff --git a/drivers/crypto/nx/nx-sha256.c b/drivers/crypto/nx/nx-sha256.c
index 08f8d5cd6334..becb738c897b 100644
--- a/drivers/crypto/nx/nx-sha256.c
+++ b/drivers/crypto/nx/nx-sha256.c
@@ -71,7 +71,6 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data,
71 struct sha256_state *sctx = shash_desc_ctx(desc); 71 struct sha256_state *sctx = shash_desc_ctx(desc);
72 struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base); 72 struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
73 struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb; 73 struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb;
74 struct nx_sg *in_sg;
75 struct nx_sg *out_sg; 74 struct nx_sg *out_sg;
76 u64 to_process = 0, leftover, total; 75 u64 to_process = 0, leftover, total;
77 unsigned long irq_flags; 76 unsigned long irq_flags;
@@ -97,7 +96,6 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data,
97 NX_CPB_FDM(csbcpb) |= NX_FDM_INTERMEDIATE; 96 NX_CPB_FDM(csbcpb) |= NX_FDM_INTERMEDIATE;
98 NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION; 97 NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION;
99 98
100 in_sg = nx_ctx->in_sg;
101 max_sg_len = min_t(u64, nx_ctx->ap->sglen, 99 max_sg_len = min_t(u64, nx_ctx->ap->sglen,
102 nx_driver.of.max_sg_len/sizeof(struct nx_sg)); 100 nx_driver.of.max_sg_len/sizeof(struct nx_sg));
103 max_sg_len = min_t(u64, max_sg_len, 101 max_sg_len = min_t(u64, max_sg_len,
@@ -114,17 +112,12 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data,
114 } 112 }
115 113
116 do { 114 do {
117 /* 115 int used_sgs = 0;
118 * to_process: the SHA256_BLOCK_SIZE data chunk to process in 116 struct nx_sg *in_sg = nx_ctx->in_sg;
119 * this update. This value is also restricted by the sg list
120 * limits.
121 */
122 to_process = total - to_process;
123 to_process = to_process & ~(SHA256_BLOCK_SIZE - 1);
124 117
125 if (buf_len) { 118 if (buf_len) {
126 data_len = buf_len; 119 data_len = buf_len;
127 in_sg = nx_build_sg_list(nx_ctx->in_sg, 120 in_sg = nx_build_sg_list(in_sg,
128 (u8 *) sctx->buf, 121 (u8 *) sctx->buf,
129 &data_len, 122 &data_len,
130 max_sg_len); 123 max_sg_len);
@@ -133,15 +126,27 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data,
133 rc = -EINVAL; 126 rc = -EINVAL;
134 goto out; 127 goto out;
135 } 128 }
129 used_sgs = in_sg - nx_ctx->in_sg;
136 } 130 }
137 131
132 /* to_process: SHA256_BLOCK_SIZE aligned chunk to be
133 * processed in this iteration. This value is restricted
134 * by sg list limits and number of sgs we already used
135 * for leftover data. (see above)
136 * In ideal case, we could allow NX_PAGE_SIZE * max_sg_len,
137 * but because data may not be aligned, we need to account
138 * for that too. */
139 to_process = min_t(u64, total,
140 (max_sg_len - 1 - used_sgs) * NX_PAGE_SIZE);
141 to_process = to_process & ~(SHA256_BLOCK_SIZE - 1);
142
138 data_len = to_process - buf_len; 143 data_len = to_process - buf_len;
139 in_sg = nx_build_sg_list(in_sg, (u8 *) data, 144 in_sg = nx_build_sg_list(in_sg, (u8 *) data,
140 &data_len, max_sg_len); 145 &data_len, max_sg_len);
141 146
142 nx_ctx->op.inlen = (nx_ctx->in_sg - in_sg) * sizeof(struct nx_sg); 147 nx_ctx->op.inlen = (nx_ctx->in_sg - in_sg) * sizeof(struct nx_sg);
143 148
144 to_process = (data_len + buf_len); 149 to_process = data_len + buf_len;
145 leftover = total - to_process; 150 leftover = total - to_process;
146 151
147 /* 152 /*
diff --git a/drivers/crypto/nx/nx-sha512.c b/drivers/crypto/nx/nx-sha512.c
index aff0fe58eac0..b6e183d58d73 100644
--- a/drivers/crypto/nx/nx-sha512.c
+++ b/drivers/crypto/nx/nx-sha512.c
@@ -71,7 +71,6 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
71 struct sha512_state *sctx = shash_desc_ctx(desc); 71 struct sha512_state *sctx = shash_desc_ctx(desc);
72 struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base); 72 struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
73 struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb; 73 struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb;
74 struct nx_sg *in_sg;
75 struct nx_sg *out_sg; 74 struct nx_sg *out_sg;
76 u64 to_process, leftover = 0, total; 75 u64 to_process, leftover = 0, total;
77 unsigned long irq_flags; 76 unsigned long irq_flags;
@@ -97,7 +96,6 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
97 NX_CPB_FDM(csbcpb) |= NX_FDM_INTERMEDIATE; 96 NX_CPB_FDM(csbcpb) |= NX_FDM_INTERMEDIATE;
98 NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION; 97 NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION;
99 98
100 in_sg = nx_ctx->in_sg;
101 max_sg_len = min_t(u64, nx_ctx->ap->sglen, 99 max_sg_len = min_t(u64, nx_ctx->ap->sglen,
102 nx_driver.of.max_sg_len/sizeof(struct nx_sg)); 100 nx_driver.of.max_sg_len/sizeof(struct nx_sg));
103 max_sg_len = min_t(u64, max_sg_len, 101 max_sg_len = min_t(u64, max_sg_len,
@@ -114,18 +112,12 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
114 } 112 }
115 113
116 do { 114 do {
117 /* 115 int used_sgs = 0;
118 * to_process: the SHA512_BLOCK_SIZE data chunk to process in 116 struct nx_sg *in_sg = nx_ctx->in_sg;
119 * this update. This value is also restricted by the sg list
120 * limits.
121 */
122 to_process = total - leftover;
123 to_process = to_process & ~(SHA512_BLOCK_SIZE - 1);
124 leftover = total - to_process;
125 117
126 if (buf_len) { 118 if (buf_len) {
127 data_len = buf_len; 119 data_len = buf_len;
128 in_sg = nx_build_sg_list(nx_ctx->in_sg, 120 in_sg = nx_build_sg_list(in_sg,
129 (u8 *) sctx->buf, 121 (u8 *) sctx->buf,
130 &data_len, max_sg_len); 122 &data_len, max_sg_len);
131 123
@@ -133,8 +125,20 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
133 rc = -EINVAL; 125 rc = -EINVAL;
134 goto out; 126 goto out;
135 } 127 }
128 used_sgs = in_sg - nx_ctx->in_sg;
136 } 129 }
137 130
131 /* to_process: SHA512_BLOCK_SIZE aligned chunk to be
132 * processed in this iteration. This value is restricted
133 * by sg list limits and number of sgs we already used
134 * for leftover data. (see above)
135 * In ideal case, we could allow NX_PAGE_SIZE * max_sg_len,
136 * but because data may not be aligned, we need to account
137 * for that too. */
138 to_process = min_t(u64, total,
139 (max_sg_len - 1 - used_sgs) * NX_PAGE_SIZE);
140 to_process = to_process & ~(SHA512_BLOCK_SIZE - 1);
141
138 data_len = to_process - buf_len; 142 data_len = to_process - buf_len;
139 in_sg = nx_build_sg_list(in_sg, (u8 *) data, 143 in_sg = nx_build_sg_list(in_sg, (u8 *) data,
140 &data_len, max_sg_len); 144 &data_len, max_sg_len);
@@ -146,7 +150,7 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
146 goto out; 150 goto out;
147 } 151 }
148 152
149 to_process = (data_len + buf_len); 153 to_process = data_len + buf_len;
150 leftover = total - to_process; 154 leftover = total - to_process;
151 155
152 /* 156 /*
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 4a4cce15f25d..3ff284c8e3d5 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -689,6 +689,10 @@ struct dma_chan *dma_request_slave_channel(struct device *dev,
689 struct dma_chan *ch = dma_request_slave_channel_reason(dev, name); 689 struct dma_chan *ch = dma_request_slave_channel_reason(dev, name);
690 if (IS_ERR(ch)) 690 if (IS_ERR(ch))
691 return NULL; 691 return NULL;
692
693 dma_cap_set(DMA_PRIVATE, ch->device->cap_mask);
694 ch->device->privatecnt++;
695
692 return ch; 696 return ch;
693} 697}
694EXPORT_SYMBOL_GPL(dma_request_slave_channel); 698EXPORT_SYMBOL_GPL(dma_request_slave_channel);
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index b0487c9f018c..eb603f1defc2 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -873,9 +873,10 @@ static void drm_dp_destroy_port(struct kref *kref)
873 from an EDID retrieval */ 873 from an EDID retrieval */
874 if (port->connector) { 874 if (port->connector) {
875 mutex_lock(&mgr->destroy_connector_lock); 875 mutex_lock(&mgr->destroy_connector_lock);
876 list_add(&port->connector->destroy_list, &mgr->destroy_connector_list); 876 list_add(&port->next, &mgr->destroy_connector_list);
877 mutex_unlock(&mgr->destroy_connector_lock); 877 mutex_unlock(&mgr->destroy_connector_lock);
878 schedule_work(&mgr->destroy_connector_work); 878 schedule_work(&mgr->destroy_connector_work);
879 return;
879 } 880 }
880 drm_dp_port_teardown_pdt(port, port->pdt); 881 drm_dp_port_teardown_pdt(port, port->pdt);
881 882
@@ -2659,7 +2660,7 @@ static void drm_dp_tx_work(struct work_struct *work)
2659static void drm_dp_destroy_connector_work(struct work_struct *work) 2660static void drm_dp_destroy_connector_work(struct work_struct *work)
2660{ 2661{
2661 struct drm_dp_mst_topology_mgr *mgr = container_of(work, struct drm_dp_mst_topology_mgr, destroy_connector_work); 2662 struct drm_dp_mst_topology_mgr *mgr = container_of(work, struct drm_dp_mst_topology_mgr, destroy_connector_work);
2662 struct drm_connector *connector; 2663 struct drm_dp_mst_port *port;
2663 2664
2664 /* 2665 /*
2665 * Not a regular list traverse as we have to drop the destroy 2666 * Not a regular list traverse as we have to drop the destroy
@@ -2668,15 +2669,21 @@ static void drm_dp_destroy_connector_work(struct work_struct *work)
2668 */ 2669 */
2669 for (;;) { 2670 for (;;) {
2670 mutex_lock(&mgr->destroy_connector_lock); 2671 mutex_lock(&mgr->destroy_connector_lock);
2671 connector = list_first_entry_or_null(&mgr->destroy_connector_list, struct drm_connector, destroy_list); 2672 port = list_first_entry_or_null(&mgr->destroy_connector_list, struct drm_dp_mst_port, next);
2672 if (!connector) { 2673 if (!port) {
2673 mutex_unlock(&mgr->destroy_connector_lock); 2674 mutex_unlock(&mgr->destroy_connector_lock);
2674 break; 2675 break;
2675 } 2676 }
2676 list_del(&connector->destroy_list); 2677 list_del(&port->next);
2677 mutex_unlock(&mgr->destroy_connector_lock); 2678 mutex_unlock(&mgr->destroy_connector_lock);
2678 2679
2679 mgr->cbs->destroy_connector(mgr, connector); 2680 mgr->cbs->destroy_connector(mgr, port->connector);
2681
2682 drm_dp_port_teardown_pdt(port, port->pdt);
2683
2684 if (!port->input && port->vcpi.vcpi > 0)
2685 drm_dp_mst_put_payload_id(mgr, port->vcpi.vcpi);
2686 kfree(port);
2680 } 2687 }
2681} 2688}
2682 2689
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
index 842d6b8dc3c4..2a652359af64 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
@@ -1745,7 +1745,6 @@ static int fimc_probe(struct platform_device *pdev)
1745 spin_lock_init(&ctx->lock); 1745 spin_lock_init(&ctx->lock);
1746 platform_set_drvdata(pdev, ctx); 1746 platform_set_drvdata(pdev, ctx);
1747 1747
1748 pm_runtime_set_active(dev);
1749 pm_runtime_enable(dev); 1748 pm_runtime_enable(dev);
1750 1749
1751 ret = exynos_drm_ippdrv_register(ippdrv); 1750 ret = exynos_drm_ippdrv_register(ippdrv);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index 8040ed2a831f..f1c6b76c127f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -593,8 +593,7 @@ static int gsc_src_set_transf(struct device *dev,
593 593
594 gsc_write(cfg, GSC_IN_CON); 594 gsc_write(cfg, GSC_IN_CON);
595 595
596 ctx->rotation = cfg & 596 ctx->rotation = (cfg & GSC_IN_ROT_90) ? 1 : 0;
597 (GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
598 *swap = ctx->rotation; 597 *swap = ctx->rotation;
599 598
600 return 0; 599 return 0;
@@ -857,8 +856,7 @@ static int gsc_dst_set_transf(struct device *dev,
857 856
858 gsc_write(cfg, GSC_IN_CON); 857 gsc_write(cfg, GSC_IN_CON);
859 858
860 ctx->rotation = cfg & 859 ctx->rotation = (cfg & GSC_IN_ROT_90) ? 1 : 0;
861 (GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
862 *swap = ctx->rotation; 860 *swap = ctx->rotation;
863 861
864 return 0; 862 return 0;
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 99e286489031..4a00990e4ae4 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -1064,6 +1064,7 @@ static int hdmi_get_modes(struct drm_connector *connector)
1064{ 1064{
1065 struct hdmi_context *hdata = ctx_from_connector(connector); 1065 struct hdmi_context *hdata = ctx_from_connector(connector);
1066 struct edid *edid; 1066 struct edid *edid;
1067 int ret;
1067 1068
1068 if (!hdata->ddc_adpt) 1069 if (!hdata->ddc_adpt)
1069 return -ENODEV; 1070 return -ENODEV;
@@ -1079,7 +1080,11 @@ static int hdmi_get_modes(struct drm_connector *connector)
1079 1080
1080 drm_mode_connector_update_edid_property(connector, edid); 1081 drm_mode_connector_update_edid_property(connector, edid);
1081 1082
1082 return drm_add_edid_modes(connector, edid); 1083 ret = drm_add_edid_modes(connector, edid);
1084
1085 kfree(edid);
1086
1087 return ret;
1083} 1088}
1084 1089
1085static int hdmi_find_phy_conf(struct hdmi_context *hdata, u32 pixel_clock) 1090static int hdmi_find_phy_conf(struct hdmi_context *hdata, u32 pixel_clock)
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index cae98db33062..4706b56902b4 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -718,6 +718,10 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg)
718 718
719 /* handling VSYNC */ 719 /* handling VSYNC */
720 if (val & MXR_INT_STATUS_VSYNC) { 720 if (val & MXR_INT_STATUS_VSYNC) {
721 /* vsync interrupt use different bit for read and clear */
722 val |= MXR_INT_CLEAR_VSYNC;
723 val &= ~MXR_INT_STATUS_VSYNC;
724
721 /* interlace scan need to check shadow register */ 725 /* interlace scan need to check shadow register */
722 if (ctx->interlace) { 726 if (ctx->interlace) {
723 base = mixer_reg_read(res, MXR_GRAPHIC_BASE(0)); 727 base = mixer_reg_read(res, MXR_GRAPHIC_BASE(0));
@@ -743,11 +747,6 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg)
743 747
744out: 748out:
745 /* clear interrupts */ 749 /* clear interrupts */
746 if (~val & MXR_INT_EN_VSYNC) {
747 /* vsync interrupt use different bit for read and clear */
748 val &= ~MXR_INT_EN_VSYNC;
749 val |= MXR_INT_CLEAR_VSYNC;
750 }
751 mixer_reg_write(res, MXR_INT_STATUS, val); 750 mixer_reg_write(res, MXR_INT_STATUS, val);
752 751
753 spin_unlock(&res->reg_slock); 752 spin_unlock(&res->reg_slock);
@@ -907,8 +906,8 @@ static int mixer_enable_vblank(struct exynos_drm_crtc *crtc)
907 } 906 }
908 907
909 /* enable vsync interrupt */ 908 /* enable vsync interrupt */
910 mixer_reg_writemask(res, MXR_INT_EN, MXR_INT_EN_VSYNC, 909 mixer_reg_writemask(res, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC);
911 MXR_INT_EN_VSYNC); 910 mixer_reg_writemask(res, MXR_INT_EN, ~0, MXR_INT_EN_VSYNC);
912 911
913 return 0; 912 return 0;
914} 913}
@@ -918,7 +917,13 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc)
918 struct mixer_context *mixer_ctx = crtc->ctx; 917 struct mixer_context *mixer_ctx = crtc->ctx;
919 struct mixer_resources *res = &mixer_ctx->mixer_res; 918 struct mixer_resources *res = &mixer_ctx->mixer_res;
920 919
920 if (!mixer_ctx->powered) {
921 mixer_ctx->int_en &= MXR_INT_EN_VSYNC;
922 return;
923 }
924
921 /* disable vsync interrupt */ 925 /* disable vsync interrupt */
926 mixer_reg_writemask(res, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC);
922 mixer_reg_writemask(res, MXR_INT_EN, 0, MXR_INT_EN_VSYNC); 927 mixer_reg_writemask(res, MXR_INT_EN, 0, MXR_INT_EN_VSYNC);
923} 928}
924 929
@@ -1047,6 +1052,8 @@ static void mixer_enable(struct exynos_drm_crtc *crtc)
1047 1052
1048 mixer_reg_writemask(res, MXR_STATUS, ~0, MXR_STATUS_SOFT_RESET); 1053 mixer_reg_writemask(res, MXR_STATUS, ~0, MXR_STATUS_SOFT_RESET);
1049 1054
1055 if (ctx->int_en & MXR_INT_EN_VSYNC)
1056 mixer_reg_writemask(res, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC);
1050 mixer_reg_write(res, MXR_INT_EN, ctx->int_en); 1057 mixer_reg_write(res, MXR_INT_EN, ctx->int_en);
1051 mixer_win_reset(ctx); 1058 mixer_win_reset(ctx);
1052} 1059}
diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index 7ed8033aae60..8e35e0d013df 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -129,8 +129,9 @@ int intel_atomic_commit(struct drm_device *dev,
129 struct drm_atomic_state *state, 129 struct drm_atomic_state *state,
130 bool async) 130 bool async)
131{ 131{
132 int ret; 132 struct drm_crtc_state *crtc_state;
133 int i; 133 struct drm_crtc *crtc;
134 int ret, i;
134 135
135 if (async) { 136 if (async) {
136 DRM_DEBUG_KMS("i915 does not yet support async commit\n"); 137 DRM_DEBUG_KMS("i915 does not yet support async commit\n");
@@ -142,48 +143,18 @@ int intel_atomic_commit(struct drm_device *dev,
142 return ret; 143 return ret;
143 144
144 /* Point of no return */ 145 /* Point of no return */
145 146 drm_atomic_helper_swap_state(dev, state);
146 /*
147 * FIXME: The proper sequence here will eventually be:
148 *
149 * drm_atomic_helper_swap_state(dev, state)
150 * drm_atomic_helper_commit_modeset_disables(dev, state);
151 * drm_atomic_helper_commit_planes(dev, state);
152 * drm_atomic_helper_commit_modeset_enables(dev, state);
153 * drm_atomic_helper_wait_for_vblanks(dev, state);
154 * drm_atomic_helper_cleanup_planes(dev, state);
155 * drm_atomic_state_free(state);
156 *
157 * once we have full atomic modeset. For now, just manually update
158 * plane states to avoid clobbering good states with dummy states
159 * while nuclear pageflipping.
160 */
161 for (i = 0; i < dev->mode_config.num_total_plane; i++) {
162 struct drm_plane *plane = state->planes[i];
163
164 if (!plane)
165 continue;
166
167 plane->state->state = state;
168 swap(state->plane_states[i], plane->state);
169 plane->state->state = NULL;
170 }
171 147
172 /* swap crtc_scaler_state */ 148 /* swap crtc_scaler_state */
173 for (i = 0; i < dev->mode_config.num_crtc; i++) { 149 for_each_crtc_in_state(state, crtc, crtc_state, i) {
174 struct drm_crtc *crtc = state->crtcs[i]; 150 to_intel_crtc(crtc)->config = to_intel_crtc_state(crtc->state);
175 if (!crtc) {
176 continue;
177 }
178
179 to_intel_crtc(crtc)->config->scaler_state =
180 to_intel_crtc_state(state->crtc_states[i])->scaler_state;
181 151
182 if (INTEL_INFO(dev)->gen >= 9) 152 if (INTEL_INFO(dev)->gen >= 9)
183 skl_detach_scalers(to_intel_crtc(crtc)); 153 skl_detach_scalers(to_intel_crtc(crtc));
154
155 drm_atomic_helper_commit_planes_on_crtc(crtc_state);
184 } 156 }
185 157
186 drm_atomic_helper_commit_planes(dev, state);
187 drm_atomic_helper_wait_for_vblanks(dev, state); 158 drm_atomic_helper_wait_for_vblanks(dev, state);
188 drm_atomic_helper_cleanup_planes(dev, state); 159 drm_atomic_helper_cleanup_planes(dev, state);
189 drm_atomic_state_free(state); 160 drm_atomic_state_free(state);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 30e0f54ba19d..87476ff181dd 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11826,7 +11826,9 @@ encoder_retry:
11826 goto encoder_retry; 11826 goto encoder_retry;
11827 } 11827 }
11828 11828
11829 pipe_config->dither = pipe_config->pipe_bpp != base_bpp; 11829 /* Dithering seems to not pass-through bits correctly when it should, so
11830 * only enable it on 6bpc panels. */
11831 pipe_config->dither = pipe_config->pipe_bpp == 6*3;
11830 DRM_DEBUG_KMS("plane bpp: %i, pipe bpp: %i, dithering: %i\n", 11832 DRM_DEBUG_KMS("plane bpp: %i, pipe bpp: %i, dithering: %i\n",
11831 base_bpp, pipe_config->pipe_bpp, pipe_config->dither); 11833 base_bpp, pipe_config->pipe_bpp, pipe_config->dither);
11832 11834
@@ -12624,17 +12626,17 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc,
12624 12626
12625 modeset_update_crtc_power_domains(state); 12627 modeset_update_crtc_power_domains(state);
12626 12628
12627 drm_atomic_helper_commit_planes(dev, state);
12628
12629 /* Now enable the clocks, plane, pipe, and connectors that we set up. */ 12629 /* Now enable the clocks, plane, pipe, and connectors that we set up. */
12630 for_each_crtc_in_state(state, crtc, crtc_state, i) { 12630 for_each_crtc_in_state(state, crtc, crtc_state, i) {
12631 if (!needs_modeset(crtc->state) || !crtc->state->enable) 12631 if (!needs_modeset(crtc->state) || !crtc->state->enable) {
12632 drm_atomic_helper_commit_planes_on_crtc(crtc_state);
12632 continue; 12633 continue;
12634 }
12633 12635
12634 update_scanline_offset(to_intel_crtc(crtc)); 12636 update_scanline_offset(to_intel_crtc(crtc));
12635 12637
12636 dev_priv->display.crtc_enable(crtc); 12638 dev_priv->display.crtc_enable(crtc);
12637 intel_crtc_enable_planes(crtc); 12639 drm_atomic_helper_commit_planes_on_crtc(crtc_state);
12638 } 12640 }
12639 12641
12640 /* FIXME: add subpixel order */ 12642 /* FIXME: add subpixel order */
@@ -12891,20 +12893,11 @@ intel_modeset_stage_output_state(struct drm_device *dev,
12891 return 0; 12893 return 0;
12892} 12894}
12893 12895
12894static bool primary_plane_visible(struct drm_crtc *crtc)
12895{
12896 struct intel_plane_state *plane_state =
12897 to_intel_plane_state(crtc->primary->state);
12898
12899 return plane_state->visible;
12900}
12901
12902static int intel_crtc_set_config(struct drm_mode_set *set) 12896static int intel_crtc_set_config(struct drm_mode_set *set)
12903{ 12897{
12904 struct drm_device *dev; 12898 struct drm_device *dev;
12905 struct drm_atomic_state *state = NULL; 12899 struct drm_atomic_state *state = NULL;
12906 struct intel_crtc_state *pipe_config; 12900 struct intel_crtc_state *pipe_config;
12907 bool primary_plane_was_visible;
12908 int ret; 12901 int ret;
12909 12902
12910 BUG_ON(!set); 12903 BUG_ON(!set);
@@ -12943,38 +12936,8 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
12943 12936
12944 intel_update_pipe_size(to_intel_crtc(set->crtc)); 12937 intel_update_pipe_size(to_intel_crtc(set->crtc));
12945 12938
12946 primary_plane_was_visible = primary_plane_visible(set->crtc);
12947
12948 ret = intel_set_mode_with_config(set->crtc, pipe_config, true); 12939 ret = intel_set_mode_with_config(set->crtc, pipe_config, true);
12949 12940
12950 if (ret == 0 &&
12951 pipe_config->base.enable &&
12952 pipe_config->base.planes_changed &&
12953 !needs_modeset(&pipe_config->base)) {
12954 struct intel_crtc *intel_crtc = to_intel_crtc(set->crtc);
12955
12956 /*
12957 * We need to make sure the primary plane is re-enabled if it
12958 * has previously been turned off.
12959 */
12960 if (ret == 0 && !primary_plane_was_visible &&
12961 primary_plane_visible(set->crtc)) {
12962 WARN_ON(!intel_crtc->active);
12963 intel_post_enable_primary(set->crtc);
12964 }
12965
12966 /*
12967 * In the fastboot case this may be our only check of the
12968 * state after boot. It would be better to only do it on
12969 * the first update, but we don't have a nice way of doing that
12970 * (and really, set_config isn't used much for high freq page
12971 * flipping, so increasing its cost here shouldn't be a big
12972 * deal).
12973 */
12974 if (i915.fastboot && ret == 0)
12975 intel_modeset_check_state(set->crtc->dev);
12976 }
12977
12978 if (ret) { 12941 if (ret) {
12979 DRM_DEBUG_KMS("failed to set mode on [CRTC:%d], err = %d\n", 12942 DRM_DEBUG_KMS("failed to set mode on [CRTC:%d], err = %d\n",
12980 set->crtc->base.id, ret); 12943 set->crtc->base.id, ret);
@@ -13305,6 +13268,9 @@ intel_check_primary_plane(struct drm_plane *plane,
13305 */ 13268 */
13306 if (IS_BROADWELL(dev)) 13269 if (IS_BROADWELL(dev))
13307 intel_crtc->atomic.wait_vblank = true; 13270 intel_crtc->atomic.wait_vblank = true;
13271
13272 if (crtc_state)
13273 intel_crtc->atomic.post_enable_primary = true;
13308 } 13274 }
13309 13275
13310 /* 13276 /*
@@ -13317,6 +13283,10 @@ intel_check_primary_plane(struct drm_plane *plane,
13317 if (!state->visible || !fb) 13283 if (!state->visible || !fb)
13318 intel_crtc->atomic.disable_ips = true; 13284 intel_crtc->atomic.disable_ips = true;
13319 13285
13286 if (!state->visible && old_state->visible &&
13287 crtc_state && !needs_modeset(&crtc_state->base))
13288 intel_crtc->atomic.pre_disable_primary = true;
13289
13320 intel_crtc->atomic.fb_bits |= 13290 intel_crtc->atomic.fb_bits |=
13321 INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe); 13291 INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe);
13322 13292
@@ -15034,6 +15004,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
15034 struct intel_plane_state *plane_state; 15004 struct intel_plane_state *plane_state;
15035 15005
15036 memset(crtc->config, 0, sizeof(*crtc->config)); 15006 memset(crtc->config, 0, sizeof(*crtc->config));
15007 crtc->config->base.crtc = &crtc->base;
15037 15008
15038 crtc->config->quirks |= PIPE_CONFIG_QUIRK_INHERITED_MODE; 15009 crtc->config->quirks |= PIPE_CONFIG_QUIRK_INHERITED_MODE;
15039 15010
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
index 52c22b026005..e10f9644140f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
@@ -166,30 +166,14 @@ gk104_fifo_context_attach(struct nvkm_object *parent,
166} 166}
167 167
168static int 168static int
169gk104_fifo_chan_kick(struct gk104_fifo_chan *chan)
170{
171 struct nvkm_object *obj = (void *)chan;
172 struct gk104_fifo_priv *priv = (void *)obj->engine;
173
174 nv_wr32(priv, 0x002634, chan->base.chid);
175 if (!nv_wait(priv, 0x002634, 0x100000, 0x000000)) {
176 nv_error(priv, "channel %d [%s] kick timeout\n",
177 chan->base.chid, nvkm_client_name(chan));
178 return -EBUSY;
179 }
180
181 return 0;
182}
183
184static int
185gk104_fifo_context_detach(struct nvkm_object *parent, bool suspend, 169gk104_fifo_context_detach(struct nvkm_object *parent, bool suspend,
186 struct nvkm_object *object) 170 struct nvkm_object *object)
187{ 171{
188 struct nvkm_bar *bar = nvkm_bar(parent); 172 struct nvkm_bar *bar = nvkm_bar(parent);
173 struct gk104_fifo_priv *priv = (void *)parent->engine;
189 struct gk104_fifo_base *base = (void *)parent->parent; 174 struct gk104_fifo_base *base = (void *)parent->parent;
190 struct gk104_fifo_chan *chan = (void *)parent; 175 struct gk104_fifo_chan *chan = (void *)parent;
191 u32 addr; 176 u32 addr;
192 int ret;
193 177
194 switch (nv_engidx(object->engine)) { 178 switch (nv_engidx(object->engine)) {
195 case NVDEV_ENGINE_SW : return 0; 179 case NVDEV_ENGINE_SW : return 0;
@@ -204,9 +188,13 @@ gk104_fifo_context_detach(struct nvkm_object *parent, bool suspend,
204 return -EINVAL; 188 return -EINVAL;
205 } 189 }
206 190
207 ret = gk104_fifo_chan_kick(chan); 191 nv_wr32(priv, 0x002634, chan->base.chid);
208 if (ret && suspend) 192 if (!nv_wait(priv, 0x002634, 0xffffffff, chan->base.chid)) {
209 return ret; 193 nv_error(priv, "channel %d [%s] kick timeout\n",
194 chan->base.chid, nvkm_client_name(chan));
195 if (suspend)
196 return -EBUSY;
197 }
210 198
211 if (addr) { 199 if (addr) {
212 nv_wo32(base, addr + 0x00, 0x00000000); 200 nv_wo32(base, addr + 0x00, 0x00000000);
@@ -331,7 +319,6 @@ gk104_fifo_chan_fini(struct nvkm_object *object, bool suspend)
331 gk104_fifo_runlist_update(priv, chan->engine); 319 gk104_fifo_runlist_update(priv, chan->engine);
332 } 320 }
333 321
334 gk104_fifo_chan_kick(chan);
335 nv_wr32(priv, 0x800000 + (chid * 8), 0x00000000); 322 nv_wr32(priv, 0x800000 + (chid * 8), 0x00000000);
336 return nvkm_fifo_channel_fini(&chan->base, suspend); 323 return nvkm_fifo_channel_fini(&chan->base, suspend);
337} 324}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 654c8daeb5ab..97ad3bcb99a7 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -2492,7 +2492,7 @@ int vmw_execbuf_process(struct drm_file *file_priv,
2492 ret = ttm_eu_reserve_buffers(&ticket, &sw_context->validate_nodes, 2492 ret = ttm_eu_reserve_buffers(&ticket, &sw_context->validate_nodes,
2493 true, NULL); 2493 true, NULL);
2494 if (unlikely(ret != 0)) 2494 if (unlikely(ret != 0))
2495 goto out_err; 2495 goto out_err_nores;
2496 2496
2497 ret = vmw_validate_buffers(dev_priv, sw_context); 2497 ret = vmw_validate_buffers(dev_priv, sw_context);
2498 if (unlikely(ret != 0)) 2498 if (unlikely(ret != 0))
@@ -2536,6 +2536,7 @@ int vmw_execbuf_process(struct drm_file *file_priv,
2536 vmw_resource_relocations_free(&sw_context->res_relocations); 2536 vmw_resource_relocations_free(&sw_context->res_relocations);
2537 2537
2538 vmw_fifo_commit(dev_priv, command_size); 2538 vmw_fifo_commit(dev_priv, command_size);
2539 mutex_unlock(&dev_priv->binding_mutex);
2539 2540
2540 vmw_query_bo_switch_commit(dev_priv, sw_context); 2541 vmw_query_bo_switch_commit(dev_priv, sw_context);
2541 ret = vmw_execbuf_fence_commands(file_priv, dev_priv, 2542 ret = vmw_execbuf_fence_commands(file_priv, dev_priv,
@@ -2551,7 +2552,6 @@ int vmw_execbuf_process(struct drm_file *file_priv,
2551 DRM_ERROR("Fence submission error. Syncing.\n"); 2552 DRM_ERROR("Fence submission error. Syncing.\n");
2552 2553
2553 vmw_resource_list_unreserve(&sw_context->resource_list, false); 2554 vmw_resource_list_unreserve(&sw_context->resource_list, false);
2554 mutex_unlock(&dev_priv->binding_mutex);
2555 2555
2556 ttm_eu_fence_buffer_objects(&ticket, &sw_context->validate_nodes, 2556 ttm_eu_fence_buffer_objects(&ticket, &sw_context->validate_nodes,
2557 (void *) fence); 2557 (void *) fence);
diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index c7aab48f07cd..92d518382a9f 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -814,7 +814,7 @@ static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct ib_wc *wc)
814 printk(KERN_ERR MOD 814 printk(KERN_ERR MOD
815 "Unexpected cqe_status 0x%x for QPID=0x%0x\n", 815 "Unexpected cqe_status 0x%x for QPID=0x%0x\n",
816 CQE_STATUS(&cqe), CQE_QPID(&cqe)); 816 CQE_STATUS(&cqe), CQE_QPID(&cqe));
817 ret = -EINVAL; 817 wc->status = IB_WC_FATAL_ERR;
818 } 818 }
819 } 819 }
820out: 820out:
diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index 3a27a84ad3ec..9426276dbe14 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -2245,6 +2245,9 @@ void omap3_gpmc_save_context(void)
2245{ 2245{
2246 int i; 2246 int i;
2247 2247
2248 if (!gpmc_base)
2249 return;
2250
2248 gpmc_context.sysconfig = gpmc_read_reg(GPMC_SYSCONFIG); 2251 gpmc_context.sysconfig = gpmc_read_reg(GPMC_SYSCONFIG);
2249 gpmc_context.irqenable = gpmc_read_reg(GPMC_IRQENABLE); 2252 gpmc_context.irqenable = gpmc_read_reg(GPMC_IRQENABLE);
2250 gpmc_context.timeout_ctrl = gpmc_read_reg(GPMC_TIMEOUT_CONTROL); 2253 gpmc_context.timeout_ctrl = gpmc_read_reg(GPMC_TIMEOUT_CONTROL);
@@ -2277,6 +2280,9 @@ void omap3_gpmc_restore_context(void)
2277{ 2280{
2278 int i; 2281 int i;
2279 2282
2283 if (!gpmc_base)
2284 return;
2285
2280 gpmc_write_reg(GPMC_SYSCONFIG, gpmc_context.sysconfig); 2286 gpmc_write_reg(GPMC_SYSCONFIG, gpmc_context.sysconfig);
2281 gpmc_write_reg(GPMC_IRQENABLE, gpmc_context.irqenable); 2287 gpmc_write_reg(GPMC_IRQENABLE, gpmc_context.irqenable);
2282 gpmc_write_reg(GPMC_TIMEOUT_CONTROL, gpmc_context.timeout_ctrl); 2288 gpmc_write_reg(GPMC_TIMEOUT_CONTROL, gpmc_context.timeout_ctrl);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 15cc3a1f12ff..12687bf52b95 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -5173,7 +5173,7 @@ static void be_add_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
5173 struct device *dev = &adapter->pdev->dev; 5173 struct device *dev = &adapter->pdev->dev;
5174 int status; 5174 int status;
5175 5175
5176 if (lancer_chip(adapter) || BEx_chip(adapter)) 5176 if (lancer_chip(adapter) || BEx_chip(adapter) || be_is_mc(adapter))
5177 return; 5177 return;
5178 5178
5179 if (adapter->flags & BE_FLAGS_VXLAN_OFFLOADS) { 5179 if (adapter->flags & BE_FLAGS_VXLAN_OFFLOADS) {
@@ -5220,7 +5220,7 @@ static void be_del_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
5220{ 5220{
5221 struct be_adapter *adapter = netdev_priv(netdev); 5221 struct be_adapter *adapter = netdev_priv(netdev);
5222 5222
5223 if (lancer_chip(adapter) || BEx_chip(adapter)) 5223 if (lancer_chip(adapter) || BEx_chip(adapter) || be_is_mc(adapter))
5224 return; 5224 return;
5225 5225
5226 if (adapter->vxlan_port != port) 5226 if (adapter->vxlan_port != port)
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 087ffcdc48a3..4b69d061d90f 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -2067,6 +2067,11 @@ int startup_gfar(struct net_device *ndev)
2067 /* Start Rx/Tx DMA and enable the interrupts */ 2067 /* Start Rx/Tx DMA and enable the interrupts */
2068 gfar_start(priv); 2068 gfar_start(priv);
2069 2069
2070 /* force link state update after mac reset */
2071 priv->oldlink = 0;
2072 priv->oldspeed = 0;
2073 priv->oldduplex = -1;
2074
2070 phy_start(priv->phydev); 2075 phy_start(priv->phydev);
2071 2076
2072 enable_napi(priv); 2077 enable_napi(priv);
diff --git a/drivers/net/ethernet/micrel/ks8842.c b/drivers/net/ethernet/micrel/ks8842.c
index f78909a00f15..09d2e16fd6b0 100644
--- a/drivers/net/ethernet/micrel/ks8842.c
+++ b/drivers/net/ethernet/micrel/ks8842.c
@@ -952,9 +952,8 @@ static int ks8842_alloc_dma_bufs(struct net_device *netdev)
952 952
953 sg_dma_address(&tx_ctl->sg) = dma_map_single(adapter->dev, 953 sg_dma_address(&tx_ctl->sg) = dma_map_single(adapter->dev,
954 tx_ctl->buf, DMA_BUFFER_SIZE, DMA_TO_DEVICE); 954 tx_ctl->buf, DMA_BUFFER_SIZE, DMA_TO_DEVICE);
955 err = dma_mapping_error(adapter->dev, 955 if (dma_mapping_error(adapter->dev, sg_dma_address(&tx_ctl->sg))) {
956 sg_dma_address(&tx_ctl->sg)); 956 err = -ENOMEM;
957 if (err) {
958 sg_dma_address(&tx_ctl->sg) = 0; 957 sg_dma_address(&tx_ctl->sg) = 0;
959 goto err; 958 goto err;
960 } 959 }
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 84b1fba58ac3..d9728516dac3 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -814,6 +814,7 @@ void phy_state_machine(struct work_struct *work)
814 bool needs_aneg = false, do_suspend = false; 814 bool needs_aneg = false, do_suspend = false;
815 enum phy_state old_state; 815 enum phy_state old_state;
816 int err = 0; 816 int err = 0;
817 int old_link;
817 818
818 mutex_lock(&phydev->lock); 819 mutex_lock(&phydev->lock);
819 820
@@ -899,11 +900,18 @@ void phy_state_machine(struct work_struct *work)
899 phydev->adjust_link(phydev->attached_dev); 900 phydev->adjust_link(phydev->attached_dev);
900 break; 901 break;
901 case PHY_RUNNING: 902 case PHY_RUNNING:
902 /* Only register a CHANGE if we are 903 /* Only register a CHANGE if we are polling or ignoring
903 * polling or ignoring interrupts 904 * interrupts and link changed since latest checking.
904 */ 905 */
905 if (!phy_interrupt_is_valid(phydev)) 906 if (!phy_interrupt_is_valid(phydev)) {
906 phydev->state = PHY_CHANGELINK; 907 old_link = phydev->link;
908 err = phy_read_status(phydev);
909 if (err)
910 break;
911
912 if (old_link != phydev->link)
913 phydev->state = PHY_CHANGELINK;
914 }
907 break; 915 break;
908 case PHY_CHANGELINK: 916 case PHY_CHANGELINK:
909 err = phy_read_status(phydev); 917 err = phy_read_status(phydev);
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index c0f6479e19d4..70b08958763a 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -91,19 +91,18 @@ static int lan911x_config_init(struct phy_device *phydev)
91} 91}
92 92
93/* 93/*
94 * The LAN8710/LAN8720 requires a minimum of 2 link pulses within 64ms of each 94 * The LAN87xx suffers from rare absence of the ENERGYON-bit when Ethernet cable
95 * other in order to set the ENERGYON bit and exit EDPD mode. If a link partner 95 * plugs in while LAN87xx is in Energy Detect Power-Down mode. This leads to
96 * does send the pulses within this interval, the PHY will remained powered 96 * unstable detection of plugging in Ethernet cable.
97 * down. 97 * This workaround disables Energy Detect Power-Down mode and waiting for
98 * 98 * response on link pulses to detect presence of plugged Ethernet cable.
99 * This workaround will manually toggle the PHY on/off upon calls to read_status 99 * The Energy Detect Power-Down mode is enabled again in the end of procedure to
100 * in order to generate link test pulses if the link is down. If a link partner 100 * save approximately 220 mW of power if cable is unplugged.
101 * is present, it will respond to the pulses, which will cause the ENERGYON bit
102 * to be set and will cause the EDPD mode to be exited.
103 */ 101 */
104static int lan87xx_read_status(struct phy_device *phydev) 102static int lan87xx_read_status(struct phy_device *phydev)
105{ 103{
106 int err = genphy_read_status(phydev); 104 int err = genphy_read_status(phydev);
105 int i;
107 106
108 if (!phydev->link) { 107 if (!phydev->link) {
109 /* Disable EDPD to wake up PHY */ 108 /* Disable EDPD to wake up PHY */
@@ -116,8 +115,16 @@ static int lan87xx_read_status(struct phy_device *phydev)
116 if (rc < 0) 115 if (rc < 0)
117 return rc; 116 return rc;
118 117
119 /* Sleep 64 ms to allow ~5 link test pulses to be sent */ 118 /* Wait max 640 ms to detect energy */
120 msleep(64); 119 for (i = 0; i < 64; i++) {
120 /* Sleep to allow link test pulses to be sent */
121 msleep(10);
122 rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
123 if (rc < 0)
124 return rc;
125 if (rc & MII_LAN83C185_ENERGYON)
126 break;
127 }
121 128
122 /* Re-enable EDPD */ 129 /* Re-enable EDPD */
123 rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS); 130 rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
@@ -191,7 +198,7 @@ static struct phy_driver smsc_phy_driver[] = {
191 198
192 /* basic functions */ 199 /* basic functions */
193 .config_aneg = genphy_config_aneg, 200 .config_aneg = genphy_config_aneg,
194 .read_status = genphy_read_status, 201 .read_status = lan87xx_read_status,
195 .config_init = smsc_phy_config_init, 202 .config_init = smsc_phy_config_init,
196 .soft_reset = smsc_phy_reset, 203 .soft_reset = smsc_phy_reset,
197 204
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 9d15566521a7..fa8f5046afe9 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -269,9 +269,9 @@ static void ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound);
269static void ppp_ccp_closed(struct ppp *ppp); 269static void ppp_ccp_closed(struct ppp *ppp);
270static struct compressor *find_compressor(int type); 270static struct compressor *find_compressor(int type);
271static void ppp_get_stats(struct ppp *ppp, struct ppp_stats *st); 271static void ppp_get_stats(struct ppp *ppp, struct ppp_stats *st);
272static struct ppp *ppp_create_interface(struct net *net, int unit, int *retp); 272static struct ppp *ppp_create_interface(struct net *net, int unit,
273 struct file *file, int *retp);
273static void init_ppp_file(struct ppp_file *pf, int kind); 274static void init_ppp_file(struct ppp_file *pf, int kind);
274static void ppp_shutdown_interface(struct ppp *ppp);
275static void ppp_destroy_interface(struct ppp *ppp); 275static void ppp_destroy_interface(struct ppp *ppp);
276static struct ppp *ppp_find_unit(struct ppp_net *pn, int unit); 276static struct ppp *ppp_find_unit(struct ppp_net *pn, int unit);
277static struct channel *ppp_find_channel(struct ppp_net *pn, int unit); 277static struct channel *ppp_find_channel(struct ppp_net *pn, int unit);
@@ -392,8 +392,10 @@ static int ppp_release(struct inode *unused, struct file *file)
392 file->private_data = NULL; 392 file->private_data = NULL;
393 if (pf->kind == INTERFACE) { 393 if (pf->kind == INTERFACE) {
394 ppp = PF_TO_PPP(pf); 394 ppp = PF_TO_PPP(pf);
395 rtnl_lock();
395 if (file == ppp->owner) 396 if (file == ppp->owner)
396 ppp_shutdown_interface(ppp); 397 unregister_netdevice(ppp->dev);
398 rtnl_unlock();
397 } 399 }
398 if (atomic_dec_and_test(&pf->refcnt)) { 400 if (atomic_dec_and_test(&pf->refcnt)) {
399 switch (pf->kind) { 401 switch (pf->kind) {
@@ -593,8 +595,10 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
593 mutex_lock(&ppp_mutex); 595 mutex_lock(&ppp_mutex);
594 if (pf->kind == INTERFACE) { 596 if (pf->kind == INTERFACE) {
595 ppp = PF_TO_PPP(pf); 597 ppp = PF_TO_PPP(pf);
598 rtnl_lock();
596 if (file == ppp->owner) 599 if (file == ppp->owner)
597 ppp_shutdown_interface(ppp); 600 unregister_netdevice(ppp->dev);
601 rtnl_unlock();
598 } 602 }
599 if (atomic_long_read(&file->f_count) < 2) { 603 if (atomic_long_read(&file->f_count) < 2) {
600 ppp_release(NULL, file); 604 ppp_release(NULL, file);
@@ -838,11 +842,10 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
838 /* Create a new ppp unit */ 842 /* Create a new ppp unit */
839 if (get_user(unit, p)) 843 if (get_user(unit, p))
840 break; 844 break;
841 ppp = ppp_create_interface(net, unit, &err); 845 ppp = ppp_create_interface(net, unit, file, &err);
842 if (!ppp) 846 if (!ppp)
843 break; 847 break;
844 file->private_data = &ppp->file; 848 file->private_data = &ppp->file;
845 ppp->owner = file;
846 err = -EFAULT; 849 err = -EFAULT;
847 if (put_user(ppp->file.index, p)) 850 if (put_user(ppp->file.index, p))
848 break; 851 break;
@@ -916,6 +919,16 @@ static __net_init int ppp_init_net(struct net *net)
916static __net_exit void ppp_exit_net(struct net *net) 919static __net_exit void ppp_exit_net(struct net *net)
917{ 920{
918 struct ppp_net *pn = net_generic(net, ppp_net_id); 921 struct ppp_net *pn = net_generic(net, ppp_net_id);
922 struct ppp *ppp;
923 LIST_HEAD(list);
924 int id;
925
926 rtnl_lock();
927 idr_for_each_entry(&pn->units_idr, ppp, id)
928 unregister_netdevice_queue(ppp->dev, &list);
929
930 unregister_netdevice_many(&list);
931 rtnl_unlock();
919 932
920 idr_destroy(&pn->units_idr); 933 idr_destroy(&pn->units_idr);
921} 934}
@@ -1088,8 +1101,28 @@ static int ppp_dev_init(struct net_device *dev)
1088 return 0; 1101 return 0;
1089} 1102}
1090 1103
1104static void ppp_dev_uninit(struct net_device *dev)
1105{
1106 struct ppp *ppp = netdev_priv(dev);
1107 struct ppp_net *pn = ppp_pernet(ppp->ppp_net);
1108
1109 ppp_lock(ppp);
1110 ppp->closing = 1;
1111 ppp_unlock(ppp);
1112
1113 mutex_lock(&pn->all_ppp_mutex);
1114 unit_put(&pn->units_idr, ppp->file.index);
1115 mutex_unlock(&pn->all_ppp_mutex);
1116
1117 ppp->owner = NULL;
1118
1119 ppp->file.dead = 1;
1120 wake_up_interruptible(&ppp->file.rwait);
1121}
1122
1091static const struct net_device_ops ppp_netdev_ops = { 1123static const struct net_device_ops ppp_netdev_ops = {
1092 .ndo_init = ppp_dev_init, 1124 .ndo_init = ppp_dev_init,
1125 .ndo_uninit = ppp_dev_uninit,
1093 .ndo_start_xmit = ppp_start_xmit, 1126 .ndo_start_xmit = ppp_start_xmit,
1094 .ndo_do_ioctl = ppp_net_ioctl, 1127 .ndo_do_ioctl = ppp_net_ioctl,
1095 .ndo_get_stats64 = ppp_get_stats64, 1128 .ndo_get_stats64 = ppp_get_stats64,
@@ -2667,8 +2700,8 @@ ppp_get_stats(struct ppp *ppp, struct ppp_stats *st)
2667 * or if there is already a unit with the requested number. 2700 * or if there is already a unit with the requested number.
2668 * unit == -1 means allocate a new number. 2701 * unit == -1 means allocate a new number.
2669 */ 2702 */
2670static struct ppp * 2703static struct ppp *ppp_create_interface(struct net *net, int unit,
2671ppp_create_interface(struct net *net, int unit, int *retp) 2704 struct file *file, int *retp)
2672{ 2705{
2673 struct ppp *ppp; 2706 struct ppp *ppp;
2674 struct ppp_net *pn; 2707 struct ppp_net *pn;
@@ -2688,6 +2721,7 @@ ppp_create_interface(struct net *net, int unit, int *retp)
2688 ppp->mru = PPP_MRU; 2721 ppp->mru = PPP_MRU;
2689 init_ppp_file(&ppp->file, INTERFACE); 2722 init_ppp_file(&ppp->file, INTERFACE);
2690 ppp->file.hdrlen = PPP_HDRLEN - 2; /* don't count proto bytes */ 2723 ppp->file.hdrlen = PPP_HDRLEN - 2; /* don't count proto bytes */
2724 ppp->owner = file;
2691 for (i = 0; i < NUM_NP; ++i) 2725 for (i = 0; i < NUM_NP; ++i)
2692 ppp->npmode[i] = NPMODE_PASS; 2726 ppp->npmode[i] = NPMODE_PASS;
2693 INIT_LIST_HEAD(&ppp->channels); 2727 INIT_LIST_HEAD(&ppp->channels);
@@ -2776,34 +2810,6 @@ init_ppp_file(struct ppp_file *pf, int kind)
2776} 2810}
2777 2811
2778/* 2812/*
2779 * Take down a ppp interface unit - called when the owning file
2780 * (the one that created the unit) is closed or detached.
2781 */
2782static void ppp_shutdown_interface(struct ppp *ppp)
2783{
2784 struct ppp_net *pn;
2785
2786 pn = ppp_pernet(ppp->ppp_net);
2787 mutex_lock(&pn->all_ppp_mutex);
2788
2789 /* This will call dev_close() for us. */
2790 ppp_lock(ppp);
2791 if (!ppp->closing) {
2792 ppp->closing = 1;
2793 ppp_unlock(ppp);
2794 unregister_netdev(ppp->dev);
2795 unit_put(&pn->units_idr, ppp->file.index);
2796 } else
2797 ppp_unlock(ppp);
2798
2799 ppp->file.dead = 1;
2800 ppp->owner = NULL;
2801 wake_up_interruptible(&ppp->file.rwait);
2802
2803 mutex_unlock(&pn->all_ppp_mutex);
2804}
2805
2806/*
2807 * Free the memory used by a ppp unit. This is only called once 2813 * Free the memory used by a ppp unit. This is only called once
2808 * there are no channels connected to the unit and no file structs 2814 * there are no channels connected to the unit and no file structs
2809 * that reference the unit. 2815 * that reference the unit.
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 1f7a7cd97e50..6392ae3c4ab8 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -786,6 +786,7 @@ static const struct usb_device_id products[] = {
786 {QMI_FIXED_INTF(0x413c, 0x81a8, 8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */ 786 {QMI_FIXED_INTF(0x413c, 0x81a8, 8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */
787 {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */ 787 {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
788 {QMI_FIXED_INTF(0x413c, 0x81b1, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */ 788 {QMI_FIXED_INTF(0x413c, 0x81b1, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */
789 {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */
789 {QMI_FIXED_INTF(0x03f0, 0x581d, 4)}, /* HP lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */ 790 {QMI_FIXED_INTF(0x03f0, 0x581d, 4)}, /* HP lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */
790 791
791 /* 4. Gobi 1000 devices */ 792 /* 4. Gobi 1000 devices */
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 1b3a09473452..30f9ef0c0d4f 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -733,8 +733,6 @@ static bool fc_invoke_resp(struct fc_exch *ep, struct fc_seq *sp,
733 if (resp) { 733 if (resp) {
734 resp(sp, fp, arg); 734 resp(sp, fp, arg);
735 res = true; 735 res = true;
736 } else if (!IS_ERR(fp)) {
737 fc_frame_free(fp);
738 } 736 }
739 737
740 spin_lock_bh(&ep->ex_lock); 738 spin_lock_bh(&ep->ex_lock);
@@ -1596,7 +1594,8 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
1596 * If new exch resp handler is valid then call that 1594 * If new exch resp handler is valid then call that
1597 * first. 1595 * first.
1598 */ 1596 */
1599 fc_invoke_resp(ep, sp, fp); 1597 if (!fc_invoke_resp(ep, sp, fp))
1598 fc_frame_free(fp);
1600 1599
1601 fc_exch_release(ep); 1600 fc_exch_release(ep);
1602 return; 1601 return;
@@ -1695,7 +1694,8 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)
1695 fc_exch_hold(ep); 1694 fc_exch_hold(ep);
1696 if (!rc) 1695 if (!rc)
1697 fc_exch_delete(ep); 1696 fc_exch_delete(ep);
1698 fc_invoke_resp(ep, sp, fp); 1697 if (!fc_invoke_resp(ep, sp, fp))
1698 fc_frame_free(fp);
1699 if (has_rec) 1699 if (has_rec)
1700 fc_exch_timer_set(ep, ep->r_a_tov); 1700 fc_exch_timer_set(ep, ep->r_a_tov);
1701 fc_exch_release(ep); 1701 fc_exch_release(ep);
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index c6795941b45d..2d5909c4685c 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -1039,11 +1039,26 @@ restart:
1039 fc_fcp_pkt_hold(fsp); 1039 fc_fcp_pkt_hold(fsp);
1040 spin_unlock_irqrestore(&si->scsi_queue_lock, flags); 1040 spin_unlock_irqrestore(&si->scsi_queue_lock, flags);
1041 1041
1042 if (!fc_fcp_lock_pkt(fsp)) { 1042 spin_lock_bh(&fsp->scsi_pkt_lock);
1043 if (!(fsp->state & FC_SRB_COMPL)) {
1044 fsp->state |= FC_SRB_COMPL;
1045 /*
1046 * TODO: dropping scsi_pkt_lock and then reacquiring
1047 * again around fc_fcp_cleanup_cmd() is required,
1048 * since fc_fcp_cleanup_cmd() calls into
1049 * fc_seq_set_resp() and that func preempts cpu using
1050 * schedule. May be schedule and related code should be
1051 * removed instead of unlocking here to avoid scheduling
1052 * while atomic bug.
1053 */
1054 spin_unlock_bh(&fsp->scsi_pkt_lock);
1055
1043 fc_fcp_cleanup_cmd(fsp, error); 1056 fc_fcp_cleanup_cmd(fsp, error);
1057
1058 spin_lock_bh(&fsp->scsi_pkt_lock);
1044 fc_io_compl(fsp); 1059 fc_io_compl(fsp);
1045 fc_fcp_unlock_pkt(fsp);
1046 } 1060 }
1061 spin_unlock_bh(&fsp->scsi_pkt_lock);
1047 1062
1048 fc_fcp_pkt_release(fsp); 1063 fc_fcp_pkt_release(fsp);
1049 spin_lock_irqsave(&si->scsi_queue_lock, flags); 1064 spin_lock_irqsave(&si->scsi_queue_lock, flags);
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 8053f24f0349..98d9bb6ff725 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2941,10 +2941,10 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
2941{ 2941{
2942 struct iscsi_conn *conn = cls_conn->dd_data; 2942 struct iscsi_conn *conn = cls_conn->dd_data;
2943 struct iscsi_session *session = conn->session; 2943 struct iscsi_session *session = conn->session;
2944 unsigned long flags;
2945 2944
2946 del_timer_sync(&conn->transport_timer); 2945 del_timer_sync(&conn->transport_timer);
2947 2946
2947 mutex_lock(&session->eh_mutex);
2948 spin_lock_bh(&session->frwd_lock); 2948 spin_lock_bh(&session->frwd_lock);
2949 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT; 2949 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT;
2950 if (session->leadconn == conn) { 2950 if (session->leadconn == conn) {
@@ -2956,28 +2956,6 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
2956 } 2956 }
2957 spin_unlock_bh(&session->frwd_lock); 2957 spin_unlock_bh(&session->frwd_lock);
2958 2958
2959 /*
2960 * Block until all in-progress commands for this connection
2961 * time out or fail.
2962 */
2963 for (;;) {
2964 spin_lock_irqsave(session->host->host_lock, flags);
2965 if (!atomic_read(&session->host->host_busy)) { /* OK for ERL == 0 */
2966 spin_unlock_irqrestore(session->host->host_lock, flags);
2967 break;
2968 }
2969 spin_unlock_irqrestore(session->host->host_lock, flags);
2970 msleep_interruptible(500);
2971 iscsi_conn_printk(KERN_INFO, conn, "iscsi conn_destroy(): "
2972 "host_busy %d host_failed %d\n",
2973 atomic_read(&session->host->host_busy),
2974 session->host->host_failed);
2975 /*
2976 * force eh_abort() to unblock
2977 */
2978 wake_up(&conn->ehwait);
2979 }
2980
2981 /* flush queued up work because we free the connection below */ 2959 /* flush queued up work because we free the connection below */
2982 iscsi_suspend_tx(conn); 2960 iscsi_suspend_tx(conn);
2983 2961
@@ -2994,6 +2972,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
2994 if (session->leadconn == conn) 2972 if (session->leadconn == conn)
2995 session->leadconn = NULL; 2973 session->leadconn = NULL;
2996 spin_unlock_bh(&session->frwd_lock); 2974 spin_unlock_bh(&session->frwd_lock);
2975 mutex_unlock(&session->eh_mutex);
2997 2976
2998 iscsi_destroy_conn(cls_conn); 2977 iscsi_destroy_conn(cls_conn);
2999} 2978}
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index cfadccef045c..6457a8a0db9c 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -26,7 +26,6 @@
26#include <linux/blkdev.h> 26#include <linux/blkdev.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/jiffies.h> 28#include <linux/jiffies.h>
29#include <asm/unaligned.h>
30 29
31#include <scsi/scsi.h> 30#include <scsi/scsi.h>
32#include <scsi/scsi_cmnd.h> 31#include <scsi/scsi_cmnd.h>
@@ -2523,33 +2522,3 @@ void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq)
2523 } 2522 }
2524} 2523}
2525EXPORT_SYMBOL(scsi_build_sense_buffer); 2524EXPORT_SYMBOL(scsi_build_sense_buffer);
2526
2527/**
2528 * scsi_set_sense_information - set the information field in a
2529 * formatted sense data buffer
2530 * @buf: Where to build sense data
2531 * @info: 64-bit information value to be set
2532 *
2533 **/
2534void scsi_set_sense_information(u8 *buf, u64 info)
2535{
2536 if ((buf[0] & 0x7f) == 0x72) {
2537 u8 *ucp, len;
2538
2539 len = buf[7];
2540 ucp = (char *)scsi_sense_desc_find(buf, len + 8, 0);
2541 if (!ucp) {
2542 buf[7] = len + 0xa;
2543 ucp = buf + 8 + len;
2544 }
2545 ucp[0] = 0;
2546 ucp[1] = 0xa;
2547 ucp[2] = 0x80; /* Valid bit */
2548 ucp[3] = 0;
2549 put_unaligned_be64(info, &ucp[4]);
2550 } else if ((buf[0] & 0x7f) == 0x70) {
2551 buf[0] |= 0x80;
2552 put_unaligned_be64(info, &buf[3]);
2553 }
2554}
2555EXPORT_SYMBOL(scsi_set_sense_information);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3b2fcb4fada0..a20da8c25b4f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2770,9 +2770,9 @@ static int sd_revalidate_disk(struct gendisk *disk)
2770 max_xfer = sdkp->max_xfer_blocks; 2770 max_xfer = sdkp->max_xfer_blocks;
2771 max_xfer <<= ilog2(sdp->sector_size) - 9; 2771 max_xfer <<= ilog2(sdp->sector_size) - 9;
2772 2772
2773 max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), 2773 sdkp->disk->queue->limits.max_sectors =
2774 max_xfer); 2774 min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), max_xfer);
2775 blk_queue_max_hw_sectors(sdkp->disk->queue, max_xfer); 2775
2776 set_capacity(disk, sdkp->capacity); 2776 set_capacity(disk, sdkp->capacity);
2777 sd_config_write_same(sdkp); 2777 sd_config_write_same(sdkp);
2778 kfree(buffer); 2778 kfree(buffer);
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index cd77a064c772..fd092909a457 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -968,9 +968,9 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
968 cmd->cmd_flags |= ICF_NON_IMMEDIATE_UNSOLICITED_DATA; 968 cmd->cmd_flags |= ICF_NON_IMMEDIATE_UNSOLICITED_DATA;
969 969
970 conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; 970 conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt;
971 if (hdr->flags & ISCSI_FLAG_CMD_READ) { 971 if (hdr->flags & ISCSI_FLAG_CMD_READ)
972 cmd->targ_xfer_tag = session_get_next_ttt(conn->sess); 972 cmd->targ_xfer_tag = session_get_next_ttt(conn->sess);
973 } else if (hdr->flags & ISCSI_FLAG_CMD_WRITE) 973 else
974 cmd->targ_xfer_tag = 0xFFFFFFFF; 974 cmd->targ_xfer_tag = 0xFFFFFFFF;
975 cmd->cmd_sn = be32_to_cpu(hdr->cmdsn); 975 cmd->cmd_sn = be32_to_cpu(hdr->cmdsn);
976 cmd->exp_stat_sn = be32_to_cpu(hdr->exp_statsn); 976 cmd->exp_stat_sn = be32_to_cpu(hdr->exp_statsn);
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index c2e9fea90b4a..860e84046177 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -457,8 +457,15 @@ void target_unregister_template(const struct target_core_fabric_ops *fo)
457 if (!strcmp(t->tf_ops->name, fo->name)) { 457 if (!strcmp(t->tf_ops->name, fo->name)) {
458 BUG_ON(atomic_read(&t->tf_access_cnt)); 458 BUG_ON(atomic_read(&t->tf_access_cnt));
459 list_del(&t->tf_list); 459 list_del(&t->tf_list);
460 mutex_unlock(&g_tf_lock);
461 /*
462 * Wait for any outstanding fabric se_deve_entry->rcu_head
463 * callbacks to complete post kfree_rcu(), before allowing
464 * fabric driver unload of TFO->module to proceed.
465 */
466 rcu_barrier();
460 kfree(t); 467 kfree(t);
461 break; 468 return;
462 } 469 }
463 } 470 }
464 mutex_unlock(&g_tf_lock); 471 mutex_unlock(&g_tf_lock);
diff --git a/drivers/target/target_core_hba.c b/drivers/target/target_core_hba.c
index 62ea4e8e70a8..be9cefc07407 100644
--- a/drivers/target/target_core_hba.c
+++ b/drivers/target/target_core_hba.c
@@ -84,8 +84,16 @@ void target_backend_unregister(const struct target_backend_ops *ops)
84 list_for_each_entry(tb, &backend_list, list) { 84 list_for_each_entry(tb, &backend_list, list) {
85 if (tb->ops == ops) { 85 if (tb->ops == ops) {
86 list_del(&tb->list); 86 list_del(&tb->list);
87 mutex_unlock(&backend_mutex);
88 /*
89 * Wait for any outstanding backend driver ->rcu_head
90 * callbacks to complete post TBO->free_device() ->
91 * call_rcu(), before allowing backend driver module
92 * unload of target_backend_ops->owner to proceed.
93 */
94 rcu_barrier();
87 kfree(tb); 95 kfree(tb);
88 break; 96 return;
89 } 97 }
90 } 98 }
91 mutex_unlock(&backend_mutex); 99 mutex_unlock(&backend_mutex);
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index b5ba1ec3c354..f87d4cef6d39 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1203,17 +1203,13 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd)
1203 struct se_dev_entry *deve; 1203 struct se_dev_entry *deve;
1204 struct se_session *sess = cmd->se_sess; 1204 struct se_session *sess = cmd->se_sess;
1205 struct se_node_acl *nacl; 1205 struct se_node_acl *nacl;
1206 struct scsi_lun slun;
1206 unsigned char *buf; 1207 unsigned char *buf;
1207 u32 lun_count = 0, offset = 8; 1208 u32 lun_count = 0, offset = 8;
1208 1209 __be32 len;
1209 if (cmd->data_length < 16) {
1210 pr_warn("REPORT LUNS allocation length %u too small\n",
1211 cmd->data_length);
1212 return TCM_INVALID_CDB_FIELD;
1213 }
1214 1210
1215 buf = transport_kmap_data_sg(cmd); 1211 buf = transport_kmap_data_sg(cmd);
1216 if (!buf) 1212 if (cmd->data_length && !buf)
1217 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 1213 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
1218 1214
1219 /* 1215 /*
@@ -1221,11 +1217,9 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd)
1221 * coming via a target_core_mod PASSTHROUGH op, and not through 1217 * coming via a target_core_mod PASSTHROUGH op, and not through
1222 * a $FABRIC_MOD. In that case, report LUN=0 only. 1218 * a $FABRIC_MOD. In that case, report LUN=0 only.
1223 */ 1219 */
1224 if (!sess) { 1220 if (!sess)
1225 int_to_scsilun(0, (struct scsi_lun *)&buf[offset]);
1226 lun_count = 1;
1227 goto done; 1221 goto done;
1228 } 1222
1229 nacl = sess->se_node_acl; 1223 nacl = sess->se_node_acl;
1230 1224
1231 rcu_read_lock(); 1225 rcu_read_lock();
@@ -1236,10 +1230,12 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd)
1236 * See SPC2-R20 7.19. 1230 * See SPC2-R20 7.19.
1237 */ 1231 */
1238 lun_count++; 1232 lun_count++;
1239 if ((offset + 8) > cmd->data_length) 1233 if (offset >= cmd->data_length)
1240 continue; 1234 continue;
1241 1235
1242 int_to_scsilun(deve->mapped_lun, (struct scsi_lun *)&buf[offset]); 1236 int_to_scsilun(deve->mapped_lun, &slun);
1237 memcpy(buf + offset, &slun,
1238 min(8u, cmd->data_length - offset));
1243 offset += 8; 1239 offset += 8;
1244 } 1240 }
1245 rcu_read_unlock(); 1241 rcu_read_unlock();
@@ -1248,12 +1244,22 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd)
1248 * See SPC3 r07, page 159. 1244 * See SPC3 r07, page 159.
1249 */ 1245 */
1250done: 1246done:
1251 lun_count *= 8; 1247 /*
1252 buf[0] = ((lun_count >> 24) & 0xff); 1248 * If no LUNs are accessible, report virtual LUN 0.
1253 buf[1] = ((lun_count >> 16) & 0xff); 1249 */
1254 buf[2] = ((lun_count >> 8) & 0xff); 1250 if (lun_count == 0) {
1255 buf[3] = (lun_count & 0xff); 1251 int_to_scsilun(0, &slun);
1256 transport_kunmap_data_sg(cmd); 1252 if (cmd->data_length > 8)
1253 memcpy(buf + offset, &slun,
1254 min(8u, cmd->data_length - offset));
1255 lun_count = 1;
1256 }
1257
1258 if (buf) {
1259 len = cpu_to_be32(lun_count * 8);
1260 memcpy(buf, &len, min_t(int, sizeof len, cmd->data_length));
1261 transport_kunmap_data_sg(cmd);
1262 }
1257 1263
1258 target_complete_cmd_with_length(cmd, GOOD, 8 + lun_count * 8); 1264 target_complete_cmd_with_length(cmd, GOOD, 8 + lun_count * 8);
1259 return 0; 1265 return 0;
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 6509c61b9648..620dcd405ff6 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -68,7 +68,7 @@ struct power_table {
68 * registered cooling device. 68 * registered cooling device.
69 * @cpufreq_state: integer value representing the current state of cpufreq 69 * @cpufreq_state: integer value representing the current state of cpufreq
70 * cooling devices. 70 * cooling devices.
71 * @cpufreq_val: integer value representing the absolute value of the clipped 71 * @clipped_freq: integer value representing the absolute value of the clipped
72 * frequency. 72 * frequency.
73 * @max_level: maximum cooling level. One less than total number of valid 73 * @max_level: maximum cooling level. One less than total number of valid
74 * cpufreq frequencies. 74 * cpufreq frequencies.
@@ -91,7 +91,7 @@ struct cpufreq_cooling_device {
91 int id; 91 int id;
92 struct thermal_cooling_device *cool_dev; 92 struct thermal_cooling_device *cool_dev;
93 unsigned int cpufreq_state; 93 unsigned int cpufreq_state;
94 unsigned int cpufreq_val; 94 unsigned int clipped_freq;
95 unsigned int max_level; 95 unsigned int max_level;
96 unsigned int *freq_table; /* In descending order */ 96 unsigned int *freq_table; /* In descending order */
97 struct cpumask allowed_cpus; 97 struct cpumask allowed_cpus;
@@ -107,6 +107,9 @@ struct cpufreq_cooling_device {
107static DEFINE_IDR(cpufreq_idr); 107static DEFINE_IDR(cpufreq_idr);
108static DEFINE_MUTEX(cooling_cpufreq_lock); 108static DEFINE_MUTEX(cooling_cpufreq_lock);
109 109
110static unsigned int cpufreq_dev_count;
111
112static DEFINE_MUTEX(cooling_list_lock);
110static LIST_HEAD(cpufreq_dev_list); 113static LIST_HEAD(cpufreq_dev_list);
111 114
112/** 115/**
@@ -185,14 +188,14 @@ unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq)
185{ 188{
186 struct cpufreq_cooling_device *cpufreq_dev; 189 struct cpufreq_cooling_device *cpufreq_dev;
187 190
188 mutex_lock(&cooling_cpufreq_lock); 191 mutex_lock(&cooling_list_lock);
189 list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) { 192 list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) {
190 if (cpumask_test_cpu(cpu, &cpufreq_dev->allowed_cpus)) { 193 if (cpumask_test_cpu(cpu, &cpufreq_dev->allowed_cpus)) {
191 mutex_unlock(&cooling_cpufreq_lock); 194 mutex_unlock(&cooling_list_lock);
192 return get_level(cpufreq_dev, freq); 195 return get_level(cpufreq_dev, freq);
193 } 196 }
194 } 197 }
195 mutex_unlock(&cooling_cpufreq_lock); 198 mutex_unlock(&cooling_list_lock);
196 199
197 pr_err("%s: cpu:%d not part of any cooling device\n", __func__, cpu); 200 pr_err("%s: cpu:%d not part of any cooling device\n", __func__, cpu);
198 return THERMAL_CSTATE_INVALID; 201 return THERMAL_CSTATE_INVALID;
@@ -215,29 +218,35 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb,
215 unsigned long event, void *data) 218 unsigned long event, void *data)
216{ 219{
217 struct cpufreq_policy *policy = data; 220 struct cpufreq_policy *policy = data;
218 unsigned long max_freq = 0; 221 unsigned long clipped_freq;
219 struct cpufreq_cooling_device *cpufreq_dev; 222 struct cpufreq_cooling_device *cpufreq_dev;
220 223
221 switch (event) { 224 if (event != CPUFREQ_ADJUST)
225 return NOTIFY_DONE;
222 226
223 case CPUFREQ_ADJUST: 227 mutex_lock(&cooling_list_lock);
224 mutex_lock(&cooling_cpufreq_lock); 228 list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) {
225 list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) { 229 if (!cpumask_test_cpu(policy->cpu, &cpufreq_dev->allowed_cpus))
226 if (!cpumask_test_cpu(policy->cpu, 230 continue;
227 &cpufreq_dev->allowed_cpus))
228 continue;
229 231
230 max_freq = cpufreq_dev->cpufreq_val; 232 /*
233 * policy->max is the maximum allowed frequency defined by user
234 * and clipped_freq is the maximum that thermal constraints
235 * allow.
236 *
237 * If clipped_freq is lower than policy->max, then we need to
238 * readjust policy->max.
239 *
240 * But, if clipped_freq is greater than policy->max, we don't
241 * need to do anything.
242 */
243 clipped_freq = cpufreq_dev->clipped_freq;
231 244
232 if (policy->max != max_freq) 245 if (policy->max > clipped_freq)
233 cpufreq_verify_within_limits(policy, 0, 246 cpufreq_verify_within_limits(policy, 0, clipped_freq);
234 max_freq);
235 }
236 mutex_unlock(&cooling_cpufreq_lock);
237 break; 247 break;
238 default:
239 return NOTIFY_DONE;
240 } 248 }
249 mutex_unlock(&cooling_list_lock);
241 250
242 return NOTIFY_OK; 251 return NOTIFY_OK;
243} 252}
@@ -519,7 +528,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
519 528
520 clip_freq = cpufreq_device->freq_table[state]; 529 clip_freq = cpufreq_device->freq_table[state];
521 cpufreq_device->cpufreq_state = state; 530 cpufreq_device->cpufreq_state = state;
522 cpufreq_device->cpufreq_val = clip_freq; 531 cpufreq_device->clipped_freq = clip_freq;
523 532
524 cpufreq_update_policy(cpu); 533 cpufreq_update_policy(cpu);
525 534
@@ -861,17 +870,19 @@ __cpufreq_cooling_register(struct device_node *np,
861 pr_debug("%s: freq:%u KHz\n", __func__, freq); 870 pr_debug("%s: freq:%u KHz\n", __func__, freq);
862 } 871 }
863 872
864 cpufreq_dev->cpufreq_val = cpufreq_dev->freq_table[0]; 873 cpufreq_dev->clipped_freq = cpufreq_dev->freq_table[0];
865 cpufreq_dev->cool_dev = cool_dev; 874 cpufreq_dev->cool_dev = cool_dev;
866 875
867 mutex_lock(&cooling_cpufreq_lock); 876 mutex_lock(&cooling_cpufreq_lock);
868 877
878 mutex_lock(&cooling_list_lock);
879 list_add(&cpufreq_dev->node, &cpufreq_dev_list);
880 mutex_unlock(&cooling_list_lock);
881
869 /* Register the notifier for first cpufreq cooling device */ 882 /* Register the notifier for first cpufreq cooling device */
870 if (list_empty(&cpufreq_dev_list)) 883 if (!cpufreq_dev_count++)
871 cpufreq_register_notifier(&thermal_cpufreq_notifier_block, 884 cpufreq_register_notifier(&thermal_cpufreq_notifier_block,
872 CPUFREQ_POLICY_NOTIFIER); 885 CPUFREQ_POLICY_NOTIFIER);
873 list_add(&cpufreq_dev->node, &cpufreq_dev_list);
874
875 mutex_unlock(&cooling_cpufreq_lock); 886 mutex_unlock(&cooling_cpufreq_lock);
876 887
877 return cool_dev; 888 return cool_dev;
@@ -1013,13 +1024,17 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
1013 return; 1024 return;
1014 1025
1015 cpufreq_dev = cdev->devdata; 1026 cpufreq_dev = cdev->devdata;
1016 mutex_lock(&cooling_cpufreq_lock);
1017 list_del(&cpufreq_dev->node);
1018 1027
1019 /* Unregister the notifier for the last cpufreq cooling device */ 1028 /* Unregister the notifier for the last cpufreq cooling device */
1020 if (list_empty(&cpufreq_dev_list)) 1029 mutex_lock(&cooling_cpufreq_lock);
1030 if (!--cpufreq_dev_count)
1021 cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, 1031 cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block,
1022 CPUFREQ_POLICY_NOTIFIER); 1032 CPUFREQ_POLICY_NOTIFIER);
1033
1034 mutex_lock(&cooling_list_lock);
1035 list_del(&cpufreq_dev->node);
1036 mutex_unlock(&cooling_list_lock);
1037
1023 mutex_unlock(&cooling_cpufreq_lock); 1038 mutex_unlock(&cooling_cpufreq_lock);
1024 1039
1025 thermal_cooling_device_unregister(cpufreq_dev->cool_dev); 1040 thermal_cooling_device_unregister(cpufreq_dev->cool_dev);
diff --git a/drivers/thermal/power_allocator.c b/drivers/thermal/power_allocator.c
index 63a448f9d93b..7006860f2f36 100644
--- a/drivers/thermal/power_allocator.c
+++ b/drivers/thermal/power_allocator.c
@@ -334,7 +334,7 @@ static int allocate_power(struct thermal_zone_device *tz,
334 max_allocatable_power, current_temp, 334 max_allocatable_power, current_temp,
335 (s32)control_temp - (s32)current_temp); 335 (s32)control_temp - (s32)current_temp);
336 336
337 devm_kfree(&tz->device, req_power); 337 kfree(req_power);
338unlock: 338unlock:
339 mutex_unlock(&tz->lock); 339 mutex_unlock(&tz->lock);
340 340
@@ -426,7 +426,7 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
426 return -EINVAL; 426 return -EINVAL;
427 } 427 }
428 428
429 params = devm_kzalloc(&tz->device, sizeof(*params), GFP_KERNEL); 429 params = kzalloc(sizeof(*params), GFP_KERNEL);
430 if (!params) 430 if (!params)
431 return -ENOMEM; 431 return -ENOMEM;
432 432
@@ -468,14 +468,14 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
468 return 0; 468 return 0;
469 469
470free: 470free:
471 devm_kfree(&tz->device, params); 471 kfree(params);
472 return ret; 472 return ret;
473} 473}
474 474
475static void power_allocator_unbind(struct thermal_zone_device *tz) 475static void power_allocator_unbind(struct thermal_zone_device *tz)
476{ 476{
477 dev_dbg(&tz->device, "Unbinding from thermal zone %d\n", tz->id); 477 dev_dbg(&tz->device, "Unbinding from thermal zone %d\n", tz->id);
478 devm_kfree(&tz->device, tz->governor_data); 478 kfree(tz->governor_data);
479 tz->governor_data = NULL; 479 tz->governor_data = NULL;
480} 480}
481 481
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 80cc1b35d460..ebb5e37455a0 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -2246,7 +2246,15 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
2246 2246
2247 err = -EINVAL; 2247 err = -EINVAL;
2248 if (old) { 2248 if (old) {
2249 struct fuse_dev *fud = fuse_get_dev(old); 2249 struct fuse_dev *fud = NULL;
2250
2251 /*
2252 * Check against file->f_op because CUSE
2253 * uses the same ioctl handler.
2254 */
2255 if (old->f_op == file->f_op &&
2256 old->f_cred->user_ns == file->f_cred->user_ns)
2257 fud = fuse_get_dev(old);
2250 2258
2251 if (fud) { 2259 if (fud) {
2252 mutex_lock(&fuse_mutex); 2260 mutex_lock(&fuse_mutex);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 57ca8cc383a6..3b4d8a4a23fb 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -743,8 +743,6 @@ struct drm_connector {
743 uint8_t num_h_tile, num_v_tile; 743 uint8_t num_h_tile, num_v_tile;
744 uint8_t tile_h_loc, tile_v_loc; 744 uint8_t tile_h_loc, tile_v_loc;
745 uint16_t tile_h_size, tile_v_size; 745 uint16_t tile_h_size, tile_v_size;
746
747 struct list_head destroy_list;
748}; 746};
749 747
750/** 748/**
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 6c78956aa470..d2992bfa1706 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -385,8 +385,6 @@ enum {
385 SATA_SSP = 0x06, /* Software Settings Preservation */ 385 SATA_SSP = 0x06, /* Software Settings Preservation */
386 SATA_DEVSLP = 0x09, /* Device Sleep */ 386 SATA_DEVSLP = 0x09, /* Device Sleep */
387 387
388 SETFEATURE_SENSE_DATA = 0xC3, /* Sense Data Reporting feature */
389
390 /* feature values for SET_MAX */ 388 /* feature values for SET_MAX */
391 ATA_SET_MAX_ADDR = 0x00, 389 ATA_SET_MAX_ADDR = 0x00,
392 ATA_SET_MAX_PASSWD = 0x01, 390 ATA_SET_MAX_PASSWD = 0x01,
@@ -530,8 +528,6 @@ struct ata_bmdma_prd {
530#define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20) 528#define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20)
531#define ata_id_has_da(id) ((id)[ATA_ID_SATA_CAPABILITY_2] & (1 << 4)) 529#define ata_id_has_da(id) ((id)[ATA_ID_SATA_CAPABILITY_2] & (1 << 4))
532#define ata_id_has_devslp(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 8)) 530#define ata_id_has_devslp(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 8))
533#define ata_id_has_ncq_autosense(id) \
534 ((id)[ATA_ID_FEATURE_SUPP] & (1 << 7))
535 531
536static inline bool ata_id_has_hipm(const u16 *id) 532static inline bool ata_id_has_hipm(const u16 *id)
537{ 533{
@@ -720,20 +716,6 @@ static inline bool ata_id_has_read_log_dma_ext(const u16 *id)
720 return false; 716 return false;
721} 717}
722 718
723static inline bool ata_id_has_sense_reporting(const u16 *id)
724{
725 if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15)))
726 return false;
727 return id[ATA_ID_COMMAND_SET_3] & (1 << 6);
728}
729
730static inline bool ata_id_sense_reporting_enabled(const u16 *id)
731{
732 if (!(id[ATA_ID_CFS_ENABLE_2] & (1 << 15)))
733 return false;
734 return id[ATA_ID_COMMAND_SET_4] & (1 << 6);
735}
736
737/** 719/**
738 * ata_id_major_version - get ATA level of drive 720 * ata_id_major_version - get ATA level of drive
739 * @id: Identify data 721 * @id: Identify data
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 4942710ef720..8d1d7fa67ec4 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -28,7 +28,6 @@ extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len,
28 u64 * info_out); 28 u64 * info_out);
29 29
30extern void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq); 30extern void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq);
31extern void scsi_set_sense_information(u8 *buf, u64 info);
32 31
33extern int scsi_ioctl_reset(struct scsi_device *, int __user *); 32extern int scsi_ioctl_reset(struct scsi_device *, int __user *);
34 33
diff --git a/include/sound/soc-topology.h b/include/sound/soc-topology.h
index 865a141b118b..427bc41df3ae 100644
--- a/include/sound/soc-topology.h
+++ b/include/sound/soc-topology.h
@@ -141,6 +141,8 @@ struct snd_soc_tplg_ops {
141 int io_ops_count; 141 int io_ops_count;
142}; 142};
143 143
144#ifdef CONFIG_SND_SOC_TOPOLOGY
145
144/* gets a pointer to data from the firmware block header */ 146/* gets a pointer to data from the firmware block header */
145static inline const void *snd_soc_tplg_get_data(struct snd_soc_tplg_hdr *hdr) 147static inline const void *snd_soc_tplg_get_data(struct snd_soc_tplg_hdr *hdr)
146{ 148{
@@ -165,4 +167,14 @@ int snd_soc_tplg_widget_bind_event(struct snd_soc_dapm_widget *w,
165 const struct snd_soc_tplg_widget_events *events, int num_events, 167 const struct snd_soc_tplg_widget_events *events, int num_events,
166 u16 event_type); 168 u16 event_type);
167 169
170#else
171
172static inline int snd_soc_tplg_component_remove(struct snd_soc_component *comp,
173 u32 index)
174{
175 return 0;
176}
177
178#endif
179
168#endif 180#endif
diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index 51b8066a223b..247c50bd60f0 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -18,6 +18,12 @@
18#include <linux/types.h> 18#include <linux/types.h>
19#include <sound/asound.h> 19#include <sound/asound.h>
20 20
21#ifndef __KERNEL__
22#error This API is an early revision and not enabled in the current
23#error kernel release, it will be enabled in a future kernel version
24#error with incompatible changes to what is here.
25#endif
26
21/* 27/*
22 * Maximum number of channels topology kcontrol can represent. 28 * Maximum number of channels topology kcontrol can represent.
23 */ 29 */
diff --git a/ipc/sem.c b/ipc/sem.c
index bc3d530cb23e..b471e5a3863d 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -253,6 +253,16 @@ static void sem_rcu_free(struct rcu_head *head)
253} 253}
254 254
255/* 255/*
256 * spin_unlock_wait() and !spin_is_locked() are not memory barriers, they
257 * are only control barriers.
258 * The code must pair with spin_unlock(&sem->lock) or
259 * spin_unlock(&sem_perm.lock), thus just the control barrier is insufficient.
260 *
261 * smp_rmb() is sufficient, as writes cannot pass the control barrier.
262 */
263#define ipc_smp_acquire__after_spin_is_unlocked() smp_rmb()
264
265/*
256 * Wait until all currently ongoing simple ops have completed. 266 * Wait until all currently ongoing simple ops have completed.
257 * Caller must own sem_perm.lock. 267 * Caller must own sem_perm.lock.
258 * New simple ops cannot start, because simple ops first check 268 * New simple ops cannot start, because simple ops first check
@@ -275,6 +285,7 @@ static void sem_wait_array(struct sem_array *sma)
275 sem = sma->sem_base + i; 285 sem = sma->sem_base + i;
276 spin_unlock_wait(&sem->lock); 286 spin_unlock_wait(&sem->lock);
277 } 287 }
288 ipc_smp_acquire__after_spin_is_unlocked();
278} 289}
279 290
280/* 291/*
@@ -327,13 +338,12 @@ static inline int sem_lock(struct sem_array *sma, struct sembuf *sops,
327 /* Then check that the global lock is free */ 338 /* Then check that the global lock is free */
328 if (!spin_is_locked(&sma->sem_perm.lock)) { 339 if (!spin_is_locked(&sma->sem_perm.lock)) {
329 /* 340 /*
330 * The ipc object lock check must be visible on all 341 * We need a memory barrier with acquire semantics,
331 * cores before rechecking the complex count. Otherwise 342 * otherwise we can race with another thread that does:
332 * we can race with another thread that does:
333 * complex_count++; 343 * complex_count++;
334 * spin_unlock(sem_perm.lock); 344 * spin_unlock(sem_perm.lock);
335 */ 345 */
336 smp_rmb(); 346 ipc_smp_acquire__after_spin_is_unlocked();
337 347
338 /* 348 /*
339 * Now repeat the test of complex_count: 349 * Now repeat the test of complex_count:
@@ -2074,17 +2084,28 @@ void exit_sem(struct task_struct *tsk)
2074 rcu_read_lock(); 2084 rcu_read_lock();
2075 un = list_entry_rcu(ulp->list_proc.next, 2085 un = list_entry_rcu(ulp->list_proc.next,
2076 struct sem_undo, list_proc); 2086 struct sem_undo, list_proc);
2077 if (&un->list_proc == &ulp->list_proc) 2087 if (&un->list_proc == &ulp->list_proc) {
2078 semid = -1; 2088 /*
2079 else 2089 * We must wait for freeary() before freeing this ulp,
2080 semid = un->semid; 2090 * in case we raced with last sem_undo. There is a small
2091 * possibility where we exit while freeary() didn't
2092 * finish unlocking sem_undo_list.
2093 */
2094 spin_unlock_wait(&ulp->lock);
2095 rcu_read_unlock();
2096 break;
2097 }
2098 spin_lock(&ulp->lock);
2099 semid = un->semid;
2100 spin_unlock(&ulp->lock);
2081 2101
2102 /* exit_sem raced with IPC_RMID, nothing to do */
2082 if (semid == -1) { 2103 if (semid == -1) {
2083 rcu_read_unlock(); 2104 rcu_read_unlock();
2084 break; 2105 continue;
2085 } 2106 }
2086 2107
2087 sma = sem_obtain_object_check(tsk->nsproxy->ipc_ns, un->semid); 2108 sma = sem_obtain_object_check(tsk->nsproxy->ipc_ns, semid);
2088 /* exit_sem raced with IPC_RMID, nothing to do */ 2109 /* exit_sem raced with IPC_RMID, nothing to do */
2089 if (IS_ERR(sma)) { 2110 if (IS_ERR(sma)) {
2090 rcu_read_unlock(); 2111 rcu_read_unlock();
@@ -2112,9 +2133,11 @@ void exit_sem(struct task_struct *tsk)
2112 ipc_assert_locked_object(&sma->sem_perm); 2133 ipc_assert_locked_object(&sma->sem_perm);
2113 list_del(&un->list_id); 2134 list_del(&un->list_id);
2114 2135
2115 spin_lock(&ulp->lock); 2136 /* we are the last process using this ulp, acquiring ulp->lock
2137 * isn't required. Besides that, we are also protected against
2138 * IPC_RMID as we hold sma->sem_perm lock now
2139 */
2116 list_del_rcu(&un->list_proc); 2140 list_del_rcu(&un->list_proc);
2117 spin_unlock(&ulp->lock);
2118 2141
2119 /* perform adjustments registered in un */ 2142 /* perform adjustments registered in un */
2120 for (i = 0; i < sma->sem_nsems; i++) { 2143 for (i = 0; i < sma->sem_nsems; i++) {
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index ee14e3a35a29..f0acff0f66c9 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1223,7 +1223,7 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
1223 spin_unlock_irq(&callback_lock); 1223 spin_unlock_irq(&callback_lock);
1224 1224
1225 /* use trialcs->mems_allowed as a temp variable */ 1225 /* use trialcs->mems_allowed as a temp variable */
1226 update_nodemasks_hier(cs, &cs->mems_allowed); 1226 update_nodemasks_hier(cs, &trialcs->mems_allowed);
1227done: 1227done:
1228 return retval; 1228 return retval;
1229} 1229}
diff --git a/kernel/events/core.c b/kernel/events/core.c
index e2c6a8886d4d..a1339b13c578 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1868,8 +1868,6 @@ event_sched_in(struct perf_event *event,
1868 1868
1869 perf_pmu_disable(event->pmu); 1869 perf_pmu_disable(event->pmu);
1870 1870
1871 event->tstamp_running += tstamp - event->tstamp_stopped;
1872
1873 perf_set_shadow_time(event, ctx, tstamp); 1871 perf_set_shadow_time(event, ctx, tstamp);
1874 1872
1875 perf_log_itrace_start(event); 1873 perf_log_itrace_start(event);
@@ -1881,6 +1879,8 @@ event_sched_in(struct perf_event *event,
1881 goto out; 1879 goto out;
1882 } 1880 }
1883 1881
1882 event->tstamp_running += tstamp - event->tstamp_stopped;
1883
1884 if (!is_software_event(event)) 1884 if (!is_software_event(event))
1885 cpuctx->active_oncpu++; 1885 cpuctx->active_oncpu++;
1886 if (!ctx->nr_active++) 1886 if (!ctx->nr_active++)
@@ -4011,28 +4011,21 @@ static void perf_event_for_each(struct perf_event *event,
4011 perf_event_for_each_child(sibling, func); 4011 perf_event_for_each_child(sibling, func);
4012} 4012}
4013 4013
4014static int perf_event_period(struct perf_event *event, u64 __user *arg) 4014struct period_event {
4015{ 4015 struct perf_event *event;
4016 struct perf_event_context *ctx = event->ctx;
4017 int ret = 0, active;
4018 u64 value; 4016 u64 value;
4017};
4019 4018
4020 if (!is_sampling_event(event)) 4019static int __perf_event_period(void *info)
4021 return -EINVAL; 4020{
4022 4021 struct period_event *pe = info;
4023 if (copy_from_user(&value, arg, sizeof(value))) 4022 struct perf_event *event = pe->event;
4024 return -EFAULT; 4023 struct perf_event_context *ctx = event->ctx;
4025 4024 u64 value = pe->value;
4026 if (!value) 4025 bool active;
4027 return -EINVAL;
4028 4026
4029 raw_spin_lock_irq(&ctx->lock); 4027 raw_spin_lock(&ctx->lock);
4030 if (event->attr.freq) { 4028 if (event->attr.freq) {
4031 if (value > sysctl_perf_event_sample_rate) {
4032 ret = -EINVAL;
4033 goto unlock;
4034 }
4035
4036 event->attr.sample_freq = value; 4029 event->attr.sample_freq = value;
4037 } else { 4030 } else {
4038 event->attr.sample_period = value; 4031 event->attr.sample_period = value;
@@ -4051,11 +4044,53 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
4051 event->pmu->start(event, PERF_EF_RELOAD); 4044 event->pmu->start(event, PERF_EF_RELOAD);
4052 perf_pmu_enable(ctx->pmu); 4045 perf_pmu_enable(ctx->pmu);
4053 } 4046 }
4047 raw_spin_unlock(&ctx->lock);
4054 4048
4055unlock: 4049 return 0;
4050}
4051
4052static int perf_event_period(struct perf_event *event, u64 __user *arg)
4053{
4054 struct period_event pe = { .event = event, };
4055 struct perf_event_context *ctx = event->ctx;
4056 struct task_struct *task;
4057 u64 value;
4058
4059 if (!is_sampling_event(event))
4060 return -EINVAL;
4061
4062 if (copy_from_user(&value, arg, sizeof(value)))
4063 return -EFAULT;
4064
4065 if (!value)
4066 return -EINVAL;
4067
4068 if (event->attr.freq && value > sysctl_perf_event_sample_rate)
4069 return -EINVAL;
4070
4071 task = ctx->task;
4072 pe.value = value;
4073
4074 if (!task) {
4075 cpu_function_call(event->cpu, __perf_event_period, &pe);
4076 return 0;
4077 }
4078
4079retry:
4080 if (!task_function_call(task, __perf_event_period, &pe))
4081 return 0;
4082
4083 raw_spin_lock_irq(&ctx->lock);
4084 if (ctx->is_active) {
4085 raw_spin_unlock_irq(&ctx->lock);
4086 task = ctx->task;
4087 goto retry;
4088 }
4089
4090 __perf_event_period(&pe);
4056 raw_spin_unlock_irq(&ctx->lock); 4091 raw_spin_unlock_irq(&ctx->lock);
4057 4092
4058 return ret; 4093 return 0;
4059} 4094}
4060 4095
4061static const struct file_operations perf_fops; 4096static const struct file_operations perf_fops;
@@ -4793,12 +4828,20 @@ static const struct file_operations perf_fops = {
4793 * to user-space before waking everybody up. 4828 * to user-space before waking everybody up.
4794 */ 4829 */
4795 4830
4831static inline struct fasync_struct **perf_event_fasync(struct perf_event *event)
4832{
4833 /* only the parent has fasync state */
4834 if (event->parent)
4835 event = event->parent;
4836 return &event->fasync;
4837}
4838
4796void perf_event_wakeup(struct perf_event *event) 4839void perf_event_wakeup(struct perf_event *event)
4797{ 4840{
4798 ring_buffer_wakeup(event); 4841 ring_buffer_wakeup(event);
4799 4842
4800 if (event->pending_kill) { 4843 if (event->pending_kill) {
4801 kill_fasync(&event->fasync, SIGIO, event->pending_kill); 4844 kill_fasync(perf_event_fasync(event), SIGIO, event->pending_kill);
4802 event->pending_kill = 0; 4845 event->pending_kill = 0;
4803 } 4846 }
4804} 4847}
@@ -6177,7 +6220,7 @@ static int __perf_event_overflow(struct perf_event *event,
6177 else 6220 else
6178 perf_event_output(event, data, regs); 6221 perf_event_output(event, data, regs);
6179 6222
6180 if (event->fasync && event->pending_kill) { 6223 if (*perf_event_fasync(event) && event->pending_kill) {
6181 event->pending_wakeup = 1; 6224 event->pending_wakeup = 1;
6182 irq_work_queue(&event->pending); 6225 irq_work_queue(&event->pending);
6183 } 6226 }
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index b2be01b1aa9d..c8aa3f75bc4d 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -559,11 +559,13 @@ static void __rb_free_aux(struct ring_buffer *rb)
559 rb->aux_priv = NULL; 559 rb->aux_priv = NULL;
560 } 560 }
561 561
562 for (pg = 0; pg < rb->aux_nr_pages; pg++) 562 if (rb->aux_nr_pages) {
563 rb_free_aux_page(rb, pg); 563 for (pg = 0; pg < rb->aux_nr_pages; pg++)
564 rb_free_aux_page(rb, pg);
564 565
565 kfree(rb->aux_pages); 566 kfree(rb->aux_pages);
566 rb->aux_nr_pages = 0; 567 rb->aux_nr_pages = 0;
568 }
567} 569}
568 570
569void rb_free_aux(struct ring_buffer *rb) 571void rb_free_aux(struct ring_buffer *rb)
diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h
index 04ab18151cc8..df19ae4debd0 100644
--- a/kernel/locking/qspinlock_paravirt.h
+++ b/kernel/locking/qspinlock_paravirt.h
@@ -4,6 +4,7 @@
4 4
5#include <linux/hash.h> 5#include <linux/hash.h>
6#include <linux/bootmem.h> 6#include <linux/bootmem.h>
7#include <linux/debug_locks.h>
7 8
8/* 9/*
9 * Implement paravirt qspinlocks; the general idea is to halt the vcpus instead 10 * Implement paravirt qspinlocks; the general idea is to halt the vcpus instead
@@ -286,15 +287,23 @@ __visible void __pv_queued_spin_unlock(struct qspinlock *lock)
286{ 287{
287 struct __qspinlock *l = (void *)lock; 288 struct __qspinlock *l = (void *)lock;
288 struct pv_node *node; 289 struct pv_node *node;
290 u8 lockval = cmpxchg(&l->locked, _Q_LOCKED_VAL, 0);
289 291
290 /* 292 /*
291 * We must not unlock if SLOW, because in that case we must first 293 * We must not unlock if SLOW, because in that case we must first
292 * unhash. Otherwise it would be possible to have multiple @lock 294 * unhash. Otherwise it would be possible to have multiple @lock
293 * entries, which would be BAD. 295 * entries, which would be BAD.
294 */ 296 */
295 if (likely(cmpxchg(&l->locked, _Q_LOCKED_VAL, 0) == _Q_LOCKED_VAL)) 297 if (likely(lockval == _Q_LOCKED_VAL))
296 return; 298 return;
297 299
300 if (unlikely(lockval != _Q_SLOW_VAL)) {
301 if (debug_locks_silent)
302 return;
303 WARN(1, "pvqspinlock: lock %p has corrupted value 0x%x!\n", lock, atomic_read(&lock->val));
304 return;
305 }
306
298 /* 307 /*
299 * Since the above failed to release, this must be the SLOW path. 308 * Since the above failed to release, this must be the SLOW path.
300 * Therefore start by looking up the blocked node and unhashing it. 309 * Therefore start by looking up the blocked node and unhashing it.
diff --git a/mm/cma.h b/mm/cma.h
index 1132d733556d..17c75a4246c8 100644
--- a/mm/cma.h
+++ b/mm/cma.h
@@ -16,7 +16,7 @@ struct cma {
16extern struct cma cma_areas[MAX_CMA_AREAS]; 16extern struct cma cma_areas[MAX_CMA_AREAS];
17extern unsigned cma_area_count; 17extern unsigned cma_area_count;
18 18
19static unsigned long cma_bitmap_maxno(struct cma *cma) 19static inline unsigned long cma_bitmap_maxno(struct cma *cma)
20{ 20{
21 return cma->count >> cma->order_per_bit; 21 return cma->count >> cma->order_per_bit;
22} 22}
diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 6c513a63ea84..7b28e9cdf1c7 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -2,7 +2,7 @@
2 * This file contains shadow memory manipulation code. 2 * This file contains shadow memory manipulation code.
3 * 3 *
4 * Copyright (c) 2014 Samsung Electronics Co., Ltd. 4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5 * Author: Andrey Ryabinin <a.ryabinin@samsung.com> 5 * Author: Andrey Ryabinin <ryabinin.a.a@gmail.com>
6 * 6 *
7 * Some of code borrowed from https://github.com/xairy/linux by 7 * Some of code borrowed from https://github.com/xairy/linux by
8 * Andrey Konovalov <adech.fo@gmail.com> 8 * Andrey Konovalov <adech.fo@gmail.com>
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 680ceedf810a..e07c94fbd0ac 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -2,7 +2,7 @@
2 * This file contains error reporting code. 2 * This file contains error reporting code.
3 * 3 *
4 * Copyright (c) 2014 Samsung Electronics Co., Ltd. 4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5 * Author: Andrey Ryabinin <a.ryabinin@samsung.com> 5 * Author: Andrey Ryabinin <ryabinin.a.a@gmail.com>
6 * 6 *
7 * Some of code borrowed from https://github.com/xairy/linux by 7 * Some of code borrowed from https://github.com/xairy/linux by
8 * Andrey Konovalov <adech.fo@gmail.com> 8 * Andrey Konovalov <adech.fo@gmail.com>
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index ea5a93659488..1f4446a90cef 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1146,8 +1146,11 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
1146 } 1146 }
1147 1147
1148 if (!PageHuge(p) && PageTransHuge(hpage)) { 1148 if (!PageHuge(p) && PageTransHuge(hpage)) {
1149 if (unlikely(split_huge_page(hpage))) { 1149 if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
1150 pr_err("MCE: %#lx: thp split failed\n", pfn); 1150 if (!PageAnon(hpage))
1151 pr_err("MCE: %#lx: non anonymous thp\n", pfn);
1152 else
1153 pr_err("MCE: %#lx: thp split failed\n", pfn);
1151 if (TestClearPageHWPoison(p)) 1154 if (TestClearPageHWPoison(p))
1152 atomic_long_sub(nr_pages, &num_poisoned_pages); 1155 atomic_long_sub(nr_pages, &num_poisoned_pages);
1153 put_page(p); 1156 put_page(p);
@@ -1538,6 +1541,8 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags)
1538 */ 1541 */
1539 ret = __get_any_page(page, pfn, 0); 1542 ret = __get_any_page(page, pfn, 0);
1540 if (!PageLRU(page)) { 1543 if (!PageLRU(page)) {
1544 /* Drop page reference which is from __get_any_page() */
1545 put_page(page);
1541 pr_info("soft_offline: %#lx: unknown non LRU page type %lx\n", 1546 pr_info("soft_offline: %#lx: unknown non LRU page type %lx\n",
1542 pfn, page->flags); 1547 pfn, page->flags);
1543 return -EIO; 1548 return -EIO;
@@ -1567,13 +1572,12 @@ static int soft_offline_huge_page(struct page *page, int flags)
1567 unlock_page(hpage); 1572 unlock_page(hpage);
1568 1573
1569 ret = isolate_huge_page(hpage, &pagelist); 1574 ret = isolate_huge_page(hpage, &pagelist);
1570 if (ret) { 1575 /*
1571 /* 1576 * get_any_page() and isolate_huge_page() takes a refcount each,
1572 * get_any_page() and isolate_huge_page() takes a refcount each, 1577 * so need to drop one here.
1573 * so need to drop one here. 1578 */
1574 */ 1579 put_page(hpage);
1575 put_page(hpage); 1580 if (!ret) {
1576 } else {
1577 pr_info("soft offline: %#lx hugepage failed to isolate\n", pfn); 1581 pr_info("soft offline: %#lx hugepage failed to isolate\n", pfn);
1578 return -EBUSY; 1582 return -EBUSY;
1579 } 1583 }
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 003dbe4b060d..6da82bcb0a8b 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1277,6 +1277,7 @@ int __ref add_memory(int nid, u64 start, u64 size)
1277 1277
1278 /* create new memmap entry */ 1278 /* create new memmap entry */
1279 firmware_map_add_hotplug(start, start + size, "System RAM"); 1279 firmware_map_add_hotplug(start, start + size, "System RAM");
1280 memblock_add_node(start, size, nid);
1280 1281
1281 goto out; 1282 goto out;
1282 1283
@@ -2013,6 +2014,8 @@ void __ref remove_memory(int nid, u64 start, u64 size)
2013 2014
2014 /* remove memmap entry */ 2015 /* remove memmap entry */
2015 firmware_map_remove(start, start + size, "System RAM"); 2016 firmware_map_remove(start, start + size, "System RAM");
2017 memblock_free(start, size);
2018 memblock_remove(start, size);
2016 2019
2017 arch_remove_memory(start, size); 2020 arch_remove_memory(start, size);
2018 2021
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index beda41710802..df959b7d6085 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5060,6 +5060,10 @@ static unsigned long __meminit zone_spanned_pages_in_node(int nid,
5060{ 5060{
5061 unsigned long zone_start_pfn, zone_end_pfn; 5061 unsigned long zone_start_pfn, zone_end_pfn;
5062 5062
5063 /* When hotadd a new node, the node should be empty */
5064 if (!node_start_pfn && !node_end_pfn)
5065 return 0;
5066
5063 /* Get the start and end of the zone */ 5067 /* Get the start and end of the zone */
5064 zone_start_pfn = arch_zone_lowest_possible_pfn[zone_type]; 5068 zone_start_pfn = arch_zone_lowest_possible_pfn[zone_type];
5065 zone_end_pfn = arch_zone_highest_possible_pfn[zone_type]; 5069 zone_end_pfn = arch_zone_highest_possible_pfn[zone_type];
@@ -5123,6 +5127,10 @@ static unsigned long __meminit zone_absent_pages_in_node(int nid,
5123 unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type]; 5127 unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type];
5124 unsigned long zone_start_pfn, zone_end_pfn; 5128 unsigned long zone_start_pfn, zone_end_pfn;
5125 5129
5130 /* When hotadd a new node, the node should be empty */
5131 if (!node_start_pfn && !node_end_pfn)
5132 return 0;
5133
5126 zone_start_pfn = clamp(node_start_pfn, zone_low, zone_high); 5134 zone_start_pfn = clamp(node_start_pfn, zone_low, zone_high);
5127 zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high); 5135 zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high);
5128 5136
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index db06de20d996..c1eb7b72ab15 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -596,8 +596,11 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
596 /* increase the refcounter of the related vlan */ 596 /* increase the refcounter of the related vlan */
597 vlan = batadv_softif_vlan_get(bat_priv, vid); 597 vlan = batadv_softif_vlan_get(bat_priv, vid);
598 if (WARN(!vlan, "adding TT local entry %pM to non-existent VLAN %d", 598 if (WARN(!vlan, "adding TT local entry %pM to non-existent VLAN %d",
599 addr, BATADV_PRINT_VID(vid))) 599 addr, BATADV_PRINT_VID(vid))) {
600 kfree(tt_local);
601 tt_local = NULL;
600 goto out; 602 goto out;
603 }
601 604
602 batadv_dbg(BATADV_DBG_TT, bat_priv, 605 batadv_dbg(BATADV_DBG_TT, bat_priv,
603 "Creating new local tt entry: %pM (vid: %d, ttvn: %d)\n", 606 "Creating new local tt entry: %pM (vid: %d, ttvn: %d)\n",
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 0752796fe0ba..66efdc21f548 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1608,7 +1608,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br,
1608 break; 1608 break;
1609 } 1609 }
1610 1610
1611 if (skb_trimmed) 1611 if (skb_trimmed && skb_trimmed != skb)
1612 kfree_skb(skb_trimmed); 1612 kfree_skb(skb_trimmed);
1613 1613
1614 return err; 1614 return err;
@@ -1653,7 +1653,7 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
1653 break; 1653 break;
1654 } 1654 }
1655 1655
1656 if (skb_trimmed) 1656 if (skb_trimmed && skb_trimmed != skb)
1657 kfree_skb(skb_trimmed); 1657 kfree_skb(skb_trimmed);
1658 1658
1659 return err; 1659 return err;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index b6a19ca0f99e..bf9a5d93c2d1 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4022,8 +4022,8 @@ EXPORT_SYMBOL(skb_checksum_setup);
4022 * Otherwise returns the provided skb. Returns NULL in error cases 4022 * Otherwise returns the provided skb. Returns NULL in error cases
4023 * (e.g. transport_len exceeds skb length or out-of-memory). 4023 * (e.g. transport_len exceeds skb length or out-of-memory).
4024 * 4024 *
4025 * Caller needs to set the skb transport header and release the returned skb. 4025 * Caller needs to set the skb transport header and free any returned skb if it
4026 * Provided skb is consumed. 4026 * differs from the provided skb.
4027 */ 4027 */
4028static struct sk_buff *skb_checksum_maybe_trim(struct sk_buff *skb, 4028static struct sk_buff *skb_checksum_maybe_trim(struct sk_buff *skb,
4029 unsigned int transport_len) 4029 unsigned int transport_len)
@@ -4032,16 +4032,12 @@ static struct sk_buff *skb_checksum_maybe_trim(struct sk_buff *skb,
4032 unsigned int len = skb_transport_offset(skb) + transport_len; 4032 unsigned int len = skb_transport_offset(skb) + transport_len;
4033 int ret; 4033 int ret;
4034 4034
4035 if (skb->len < len) { 4035 if (skb->len < len)
4036 kfree_skb(skb);
4037 return NULL; 4036 return NULL;
4038 } else if (skb->len == len) { 4037 else if (skb->len == len)
4039 return skb; 4038 return skb;
4040 }
4041 4039
4042 skb_chk = skb_clone(skb, GFP_ATOMIC); 4040 skb_chk = skb_clone(skb, GFP_ATOMIC);
4043 kfree_skb(skb);
4044
4045 if (!skb_chk) 4041 if (!skb_chk)
4046 return NULL; 4042 return NULL;
4047 4043
@@ -4066,8 +4062,8 @@ static struct sk_buff *skb_checksum_maybe_trim(struct sk_buff *skb,
4066 * If the skb has data beyond the given transport length, then a 4062 * If the skb has data beyond the given transport length, then a
4067 * trimmed & cloned skb is checked and returned. 4063 * trimmed & cloned skb is checked and returned.
4068 * 4064 *
4069 * Caller needs to set the skb transport header and release the returned skb. 4065 * Caller needs to set the skb transport header and free any returned skb if it
4070 * Provided skb is consumed. 4066 * differs from the provided skb.
4071 */ 4067 */
4072struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb, 4068struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb,
4073 unsigned int transport_len, 4069 unsigned int transport_len,
@@ -4079,23 +4075,26 @@ struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb,
4079 4075
4080 skb_chk = skb_checksum_maybe_trim(skb, transport_len); 4076 skb_chk = skb_checksum_maybe_trim(skb, transport_len);
4081 if (!skb_chk) 4077 if (!skb_chk)
4082 return NULL; 4078 goto err;
4083 4079
4084 if (!pskb_may_pull(skb_chk, offset)) { 4080 if (!pskb_may_pull(skb_chk, offset))
4085 kfree_skb(skb_chk); 4081 goto err;
4086 return NULL;
4087 }
4088 4082
4089 __skb_pull(skb_chk, offset); 4083 __skb_pull(skb_chk, offset);
4090 ret = skb_chkf(skb_chk); 4084 ret = skb_chkf(skb_chk);
4091 __skb_push(skb_chk, offset); 4085 __skb_push(skb_chk, offset);
4092 4086
4093 if (ret) { 4087 if (ret)
4094 kfree_skb(skb_chk); 4088 goto err;
4095 return NULL;
4096 }
4097 4089
4098 return skb_chk; 4090 return skb_chk;
4091
4092err:
4093 if (skb_chk && skb_chk != skb)
4094 kfree_skb(skb_chk);
4095
4096 return NULL;
4097
4099} 4098}
4100EXPORT_SYMBOL(skb_checksum_trimmed); 4099EXPORT_SYMBOL(skb_checksum_trimmed);
4101 4100
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 1243c79cb5b0..5154f81c5326 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2468,7 +2468,7 @@ static struct key_vector *fib_route_get_idx(struct fib_route_iter *iter,
2468 key = l->key + 1; 2468 key = l->key + 1;
2469 iter->pos++; 2469 iter->pos++;
2470 2470
2471 if (pos-- <= 0) 2471 if (--pos <= 0)
2472 break; 2472 break;
2473 2473
2474 l = NULL; 2474 l = NULL;
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 651cdf648ec4..9fdfd9deac11 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1435,33 +1435,35 @@ static int __ip_mc_check_igmp(struct sk_buff *skb, struct sk_buff **skb_trimmed)
1435 struct sk_buff *skb_chk; 1435 struct sk_buff *skb_chk;
1436 unsigned int transport_len; 1436 unsigned int transport_len;
1437 unsigned int len = skb_transport_offset(skb) + sizeof(struct igmphdr); 1437 unsigned int len = skb_transport_offset(skb) + sizeof(struct igmphdr);
1438 int ret; 1438 int ret = -EINVAL;
1439 1439
1440 transport_len = ntohs(ip_hdr(skb)->tot_len) - ip_hdrlen(skb); 1440 transport_len = ntohs(ip_hdr(skb)->tot_len) - ip_hdrlen(skb);
1441 1441
1442 skb_get(skb);
1443 skb_chk = skb_checksum_trimmed(skb, transport_len, 1442 skb_chk = skb_checksum_trimmed(skb, transport_len,
1444 ip_mc_validate_checksum); 1443 ip_mc_validate_checksum);
1445 if (!skb_chk) 1444 if (!skb_chk)
1446 return -EINVAL; 1445 goto err;
1447 1446
1448 if (!pskb_may_pull(skb_chk, len)) { 1447 if (!pskb_may_pull(skb_chk, len))
1449 kfree_skb(skb_chk); 1448 goto err;
1450 return -EINVAL;
1451 }
1452 1449
1453 ret = ip_mc_check_igmp_msg(skb_chk); 1450 ret = ip_mc_check_igmp_msg(skb_chk);
1454 if (ret) { 1451 if (ret)
1455 kfree_skb(skb_chk); 1452 goto err;
1456 return ret;
1457 }
1458 1453
1459 if (skb_trimmed) 1454 if (skb_trimmed)
1460 *skb_trimmed = skb_chk; 1455 *skb_trimmed = skb_chk;
1461 else 1456 /* free now unneeded clone */
1457 else if (skb_chk != skb)
1462 kfree_skb(skb_chk); 1458 kfree_skb(skb_chk);
1463 1459
1464 return 0; 1460 ret = 0;
1461
1462err:
1463 if (ret && skb_chk && skb_chk != skb)
1464 kfree_skb(skb_chk);
1465
1466 return ret;
1465} 1467}
1466 1468
1467/** 1469/**
@@ -1470,7 +1472,7 @@ static int __ip_mc_check_igmp(struct sk_buff *skb, struct sk_buff **skb_trimmed)
1470 * @skb_trimmed: to store an skb pointer trimmed to IPv4 packet tail (optional) 1472 * @skb_trimmed: to store an skb pointer trimmed to IPv4 packet tail (optional)
1471 * 1473 *
1472 * Checks whether an IPv4 packet is a valid IGMP packet. If so sets 1474 * Checks whether an IPv4 packet is a valid IGMP packet. If so sets
1473 * skb network and transport headers accordingly and returns zero. 1475 * skb transport header accordingly and returns zero.
1474 * 1476 *
1475 * -EINVAL: A broken packet was detected, i.e. it violates some internet 1477 * -EINVAL: A broken packet was detected, i.e. it violates some internet
1476 * standard 1478 * standard
@@ -1485,7 +1487,8 @@ static int __ip_mc_check_igmp(struct sk_buff *skb, struct sk_buff **skb_trimmed)
1485 * to leave the original skb and its full frame unchanged (which might be 1487 * to leave the original skb and its full frame unchanged (which might be
1486 * desirable for layer 2 frame jugglers). 1488 * desirable for layer 2 frame jugglers).
1487 * 1489 *
1488 * The caller needs to release a reference count from any returned skb_trimmed. 1490 * Caller needs to set the skb network header and free any returned skb if it
1491 * differs from the provided skb.
1489 */ 1492 */
1490int ip_mc_check_igmp(struct sk_buff *skb, struct sk_buff **skb_trimmed) 1493int ip_mc_check_igmp(struct sk_buff *skb, struct sk_buff **skb_trimmed)
1491{ 1494{
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 05e3145f7dc3..134957159c27 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -593,7 +593,7 @@ static bool reqsk_queue_unlink(struct request_sock_queue *queue,
593 } 593 }
594 594
595 spin_unlock(&queue->syn_wait_lock); 595 spin_unlock(&queue->syn_wait_lock);
596 if (del_timer_sync(&req->rsk_timer)) 596 if (timer_pending(&req->rsk_timer) && del_timer_sync(&req->rsk_timer))
597 reqsk_put(req); 597 reqsk_put(req);
598 return found; 598 return found;
599} 599}
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 433231ccfb17..0330ab2e2b63 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -41,8 +41,6 @@ static int tcp_syn_retries_min = 1;
41static int tcp_syn_retries_max = MAX_TCP_SYNCNT; 41static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
42static int ip_ping_group_range_min[] = { 0, 0 }; 42static int ip_ping_group_range_min[] = { 0, 0 };
43static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX }; 43static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
44static int min_sndbuf = SOCK_MIN_SNDBUF;
45static int min_rcvbuf = SOCK_MIN_RCVBUF;
46 44
47/* Update system visible IP port range */ 45/* Update system visible IP port range */
48static void set_local_port_range(struct net *net, int range[2]) 46static void set_local_port_range(struct net *net, int range[2])
@@ -530,7 +528,7 @@ static struct ctl_table ipv4_table[] = {
530 .maxlen = sizeof(sysctl_tcp_wmem), 528 .maxlen = sizeof(sysctl_tcp_wmem),
531 .mode = 0644, 529 .mode = 0644,
532 .proc_handler = proc_dointvec_minmax, 530 .proc_handler = proc_dointvec_minmax,
533 .extra1 = &min_sndbuf, 531 .extra1 = &one,
534 }, 532 },
535 { 533 {
536 .procname = "tcp_notsent_lowat", 534 .procname = "tcp_notsent_lowat",
@@ -545,7 +543,7 @@ static struct ctl_table ipv4_table[] = {
545 .maxlen = sizeof(sysctl_tcp_rmem), 543 .maxlen = sizeof(sysctl_tcp_rmem),
546 .mode = 0644, 544 .mode = 0644,
547 .proc_handler = proc_dointvec_minmax, 545 .proc_handler = proc_dointvec_minmax,
548 .extra1 = &min_rcvbuf, 546 .extra1 = &one,
549 }, 547 },
550 { 548 {
551 .procname = "tcp_app_win", 549 .procname = "tcp_app_win",
@@ -758,7 +756,7 @@ static struct ctl_table ipv4_table[] = {
758 .maxlen = sizeof(sysctl_udp_rmem_min), 756 .maxlen = sizeof(sysctl_udp_rmem_min),
759 .mode = 0644, 757 .mode = 0644,
760 .proc_handler = proc_dointvec_minmax, 758 .proc_handler = proc_dointvec_minmax,
761 .extra1 = &min_rcvbuf, 759 .extra1 = &one
762 }, 760 },
763 { 761 {
764 .procname = "udp_wmem_min", 762 .procname = "udp_wmem_min",
@@ -766,7 +764,7 @@ static struct ctl_table ipv4_table[] = {
766 .maxlen = sizeof(sysctl_udp_wmem_min), 764 .maxlen = sizeof(sysctl_udp_wmem_min),
767 .mode = 0644, 765 .mode = 0644,
768 .proc_handler = proc_dointvec_minmax, 766 .proc_handler = proc_dointvec_minmax,
769 .extra1 = &min_sndbuf, 767 .extra1 = &one
770 }, 768 },
771 { } 769 { }
772}; 770};
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 865e777ae20c..418d9823692b 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -173,6 +173,8 @@ static void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
173 *ppcpu_rt = NULL; 173 *ppcpu_rt = NULL;
174 } 174 }
175 } 175 }
176
177 non_pcpu_rt->rt6i_pcpu = NULL;
176} 178}
177 179
178static void rt6_release(struct rt6_info *rt) 180static void rt6_release(struct rt6_info *rt)
diff --git a/net/ipv6/mcast_snoop.c b/net/ipv6/mcast_snoop.c
index df8afe5ab31e..9405b04eecc6 100644
--- a/net/ipv6/mcast_snoop.c
+++ b/net/ipv6/mcast_snoop.c
@@ -143,34 +143,36 @@ static int __ipv6_mc_check_mld(struct sk_buff *skb,
143 struct sk_buff *skb_chk = NULL; 143 struct sk_buff *skb_chk = NULL;
144 unsigned int transport_len; 144 unsigned int transport_len;
145 unsigned int len = skb_transport_offset(skb) + sizeof(struct mld_msg); 145 unsigned int len = skb_transport_offset(skb) + sizeof(struct mld_msg);
146 int ret; 146 int ret = -EINVAL;
147 147
148 transport_len = ntohs(ipv6_hdr(skb)->payload_len); 148 transport_len = ntohs(ipv6_hdr(skb)->payload_len);
149 transport_len -= skb_transport_offset(skb) - sizeof(struct ipv6hdr); 149 transport_len -= skb_transport_offset(skb) - sizeof(struct ipv6hdr);
150 150
151 skb_get(skb);
152 skb_chk = skb_checksum_trimmed(skb, transport_len, 151 skb_chk = skb_checksum_trimmed(skb, transport_len,
153 ipv6_mc_validate_checksum); 152 ipv6_mc_validate_checksum);
154 if (!skb_chk) 153 if (!skb_chk)
155 return -EINVAL; 154 goto err;
156 155
157 if (!pskb_may_pull(skb_chk, len)) { 156 if (!pskb_may_pull(skb_chk, len))
158 kfree_skb(skb_chk); 157 goto err;
159 return -EINVAL;
160 }
161 158
162 ret = ipv6_mc_check_mld_msg(skb_chk); 159 ret = ipv6_mc_check_mld_msg(skb_chk);
163 if (ret) { 160 if (ret)
164 kfree_skb(skb_chk); 161 goto err;
165 return ret;
166 }
167 162
168 if (skb_trimmed) 163 if (skb_trimmed)
169 *skb_trimmed = skb_chk; 164 *skb_trimmed = skb_chk;
170 else 165 /* free now unneeded clone */
166 else if (skb_chk != skb)
171 kfree_skb(skb_chk); 167 kfree_skb(skb_chk);
172 168
173 return 0; 169 ret = 0;
170
171err:
172 if (ret && skb_chk && skb_chk != skb)
173 kfree_skb(skb_chk);
174
175 return ret;
174} 176}
175 177
176/** 178/**
@@ -179,7 +181,7 @@ static int __ipv6_mc_check_mld(struct sk_buff *skb,
179 * @skb_trimmed: to store an skb pointer trimmed to IPv6 packet tail (optional) 181 * @skb_trimmed: to store an skb pointer trimmed to IPv6 packet tail (optional)
180 * 182 *
181 * Checks whether an IPv6 packet is a valid MLD packet. If so sets 183 * Checks whether an IPv6 packet is a valid MLD packet. If so sets
182 * skb network and transport headers accordingly and returns zero. 184 * skb transport header accordingly and returns zero.
183 * 185 *
184 * -EINVAL: A broken packet was detected, i.e. it violates some internet 186 * -EINVAL: A broken packet was detected, i.e. it violates some internet
185 * standard 187 * standard
@@ -194,7 +196,8 @@ static int __ipv6_mc_check_mld(struct sk_buff *skb,
194 * to leave the original skb and its full frame unchanged (which might be 196 * to leave the original skb and its full frame unchanged (which might be
195 * desirable for layer 2 frame jugglers). 197 * desirable for layer 2 frame jugglers).
196 * 198 *
197 * The caller needs to release a reference count from any returned skb_trimmed. 199 * Caller needs to set the skb network header and free any returned skb if it
200 * differs from the provided skb.
198 */ 201 */
199int ipv6_mc_check_mld(struct sk_buff *skb, struct sk_buff **skb_trimmed) 202int ipv6_mc_check_mld(struct sk_buff *skb, struct sk_buff **skb_trimmed)
200{ 203{
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 6c0fe4c7ce8d..e476f01add87 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -321,8 +321,7 @@ static const struct rt6_info ip6_blk_hole_entry_template = {
321/* allocate dst with ip6_dst_ops */ 321/* allocate dst with ip6_dst_ops */
322static struct rt6_info *__ip6_dst_alloc(struct net *net, 322static struct rt6_info *__ip6_dst_alloc(struct net *net,
323 struct net_device *dev, 323 struct net_device *dev,
324 int flags, 324 int flags)
325 struct fib6_table *table)
326{ 325{
327 struct rt6_info *rt = dst_alloc(&net->ipv6.ip6_dst_ops, dev, 326 struct rt6_info *rt = dst_alloc(&net->ipv6.ip6_dst_ops, dev,
328 0, DST_OBSOLETE_FORCE_CHK, flags); 327 0, DST_OBSOLETE_FORCE_CHK, flags);
@@ -339,10 +338,9 @@ static struct rt6_info *__ip6_dst_alloc(struct net *net,
339 338
340static struct rt6_info *ip6_dst_alloc(struct net *net, 339static struct rt6_info *ip6_dst_alloc(struct net *net,
341 struct net_device *dev, 340 struct net_device *dev,
342 int flags, 341 int flags)
343 struct fib6_table *table)
344{ 342{
345 struct rt6_info *rt = __ip6_dst_alloc(net, dev, flags, table); 343 struct rt6_info *rt = __ip6_dst_alloc(net, dev, flags);
346 344
347 if (rt) { 345 if (rt) {
348 rt->rt6i_pcpu = alloc_percpu_gfp(struct rt6_info *, GFP_ATOMIC); 346 rt->rt6i_pcpu = alloc_percpu_gfp(struct rt6_info *, GFP_ATOMIC);
@@ -959,8 +957,7 @@ static struct rt6_info *ip6_rt_cache_alloc(struct rt6_info *ort,
959 if (ort->rt6i_flags & (RTF_CACHE | RTF_PCPU)) 957 if (ort->rt6i_flags & (RTF_CACHE | RTF_PCPU))
960 ort = (struct rt6_info *)ort->dst.from; 958 ort = (struct rt6_info *)ort->dst.from;
961 959
962 rt = __ip6_dst_alloc(dev_net(ort->dst.dev), ort->dst.dev, 960 rt = __ip6_dst_alloc(dev_net(ort->dst.dev), ort->dst.dev, 0);
963 0, ort->rt6i_table);
964 961
965 if (!rt) 962 if (!rt)
966 return NULL; 963 return NULL;
@@ -992,8 +989,7 @@ static struct rt6_info *ip6_rt_pcpu_alloc(struct rt6_info *rt)
992 struct rt6_info *pcpu_rt; 989 struct rt6_info *pcpu_rt;
993 990
994 pcpu_rt = __ip6_dst_alloc(dev_net(rt->dst.dev), 991 pcpu_rt = __ip6_dst_alloc(dev_net(rt->dst.dev),
995 rt->dst.dev, rt->dst.flags, 992 rt->dst.dev, rt->dst.flags);
996 rt->rt6i_table);
997 993
998 if (!pcpu_rt) 994 if (!pcpu_rt)
999 return NULL; 995 return NULL;
@@ -1006,32 +1002,53 @@ static struct rt6_info *ip6_rt_pcpu_alloc(struct rt6_info *rt)
1006/* It should be called with read_lock_bh(&tb6_lock) acquired */ 1002/* It should be called with read_lock_bh(&tb6_lock) acquired */
1007static struct rt6_info *rt6_get_pcpu_route(struct rt6_info *rt) 1003static struct rt6_info *rt6_get_pcpu_route(struct rt6_info *rt)
1008{ 1004{
1009 struct rt6_info *pcpu_rt, *prev, **p; 1005 struct rt6_info *pcpu_rt, **p;
1010 1006
1011 p = this_cpu_ptr(rt->rt6i_pcpu); 1007 p = this_cpu_ptr(rt->rt6i_pcpu);
1012 pcpu_rt = *p; 1008 pcpu_rt = *p;
1013 1009
1014 if (pcpu_rt) 1010 if (pcpu_rt) {
1015 goto done; 1011 dst_hold(&pcpu_rt->dst);
1012 rt6_dst_from_metrics_check(pcpu_rt);
1013 }
1014 return pcpu_rt;
1015}
1016
1017static struct rt6_info *rt6_make_pcpu_route(struct rt6_info *rt)
1018{
1019 struct fib6_table *table = rt->rt6i_table;
1020 struct rt6_info *pcpu_rt, *prev, **p;
1016 1021
1017 pcpu_rt = ip6_rt_pcpu_alloc(rt); 1022 pcpu_rt = ip6_rt_pcpu_alloc(rt);
1018 if (!pcpu_rt) { 1023 if (!pcpu_rt) {
1019 struct net *net = dev_net(rt->dst.dev); 1024 struct net *net = dev_net(rt->dst.dev);
1020 1025
1021 pcpu_rt = net->ipv6.ip6_null_entry; 1026 dst_hold(&net->ipv6.ip6_null_entry->dst);
1022 goto done; 1027 return net->ipv6.ip6_null_entry;
1023 } 1028 }
1024 1029
1025 prev = cmpxchg(p, NULL, pcpu_rt); 1030 read_lock_bh(&table->tb6_lock);
1026 if (prev) { 1031 if (rt->rt6i_pcpu) {
1027 /* If someone did it before us, return prev instead */ 1032 p = this_cpu_ptr(rt->rt6i_pcpu);
1033 prev = cmpxchg(p, NULL, pcpu_rt);
1034 if (prev) {
1035 /* If someone did it before us, return prev instead */
1036 dst_destroy(&pcpu_rt->dst);
1037 pcpu_rt = prev;
1038 }
1039 } else {
1040 /* rt has been removed from the fib6 tree
1041 * before we have a chance to acquire the read_lock.
1042 * In this case, don't brother to create a pcpu rt
1043 * since rt is going away anyway. The next
1044 * dst_check() will trigger a re-lookup.
1045 */
1028 dst_destroy(&pcpu_rt->dst); 1046 dst_destroy(&pcpu_rt->dst);
1029 pcpu_rt = prev; 1047 pcpu_rt = rt;
1030 } 1048 }
1031
1032done:
1033 dst_hold(&pcpu_rt->dst); 1049 dst_hold(&pcpu_rt->dst);
1034 rt6_dst_from_metrics_check(pcpu_rt); 1050 rt6_dst_from_metrics_check(pcpu_rt);
1051 read_unlock_bh(&table->tb6_lock);
1035 return pcpu_rt; 1052 return pcpu_rt;
1036} 1053}
1037 1054
@@ -1106,9 +1123,22 @@ redo_rt6_select:
1106 rt->dst.lastuse = jiffies; 1123 rt->dst.lastuse = jiffies;
1107 rt->dst.__use++; 1124 rt->dst.__use++;
1108 pcpu_rt = rt6_get_pcpu_route(rt); 1125 pcpu_rt = rt6_get_pcpu_route(rt);
1109 read_unlock_bh(&table->tb6_lock); 1126
1127 if (pcpu_rt) {
1128 read_unlock_bh(&table->tb6_lock);
1129 } else {
1130 /* We have to do the read_unlock first
1131 * because rt6_make_pcpu_route() may trigger
1132 * ip6_dst_gc() which will take the write_lock.
1133 */
1134 dst_hold(&rt->dst);
1135 read_unlock_bh(&table->tb6_lock);
1136 pcpu_rt = rt6_make_pcpu_route(rt);
1137 dst_release(&rt->dst);
1138 }
1110 1139
1111 return pcpu_rt; 1140 return pcpu_rt;
1141
1112 } 1142 }
1113} 1143}
1114 1144
@@ -1569,7 +1599,7 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
1569 if (unlikely(!idev)) 1599 if (unlikely(!idev))
1570 return ERR_PTR(-ENODEV); 1600 return ERR_PTR(-ENODEV);
1571 1601
1572 rt = ip6_dst_alloc(net, dev, 0, NULL); 1602 rt = ip6_dst_alloc(net, dev, 0);
1573 if (unlikely(!rt)) { 1603 if (unlikely(!rt)) {
1574 in6_dev_put(idev); 1604 in6_dev_put(idev);
1575 dst = ERR_PTR(-ENOMEM); 1605 dst = ERR_PTR(-ENOMEM);
@@ -1756,7 +1786,8 @@ int ip6_route_add(struct fib6_config *cfg)
1756 if (!table) 1786 if (!table)
1757 goto out; 1787 goto out;
1758 1788
1759 rt = ip6_dst_alloc(net, NULL, (cfg->fc_flags & RTF_ADDRCONF) ? 0 : DST_NOCOUNT, table); 1789 rt = ip6_dst_alloc(net, NULL,
1790 (cfg->fc_flags & RTF_ADDRCONF) ? 0 : DST_NOCOUNT);
1760 1791
1761 if (!rt) { 1792 if (!rt) {
1762 err = -ENOMEM; 1793 err = -ENOMEM;
@@ -2432,7 +2463,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
2432{ 2463{
2433 struct net *net = dev_net(idev->dev); 2464 struct net *net = dev_net(idev->dev);
2434 struct rt6_info *rt = ip6_dst_alloc(net, net->loopback_dev, 2465 struct rt6_info *rt = ip6_dst_alloc(net, net->loopback_dev,
2435 DST_NOCOUNT, NULL); 2466 DST_NOCOUNT);
2436 if (!rt) 2467 if (!rt)
2437 return ERR_PTR(-ENOMEM); 2468 return ERR_PTR(-ENOMEM);
2438 2469
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 247552a7f6c2..3ece7d1034c8 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -92,14 +92,15 @@ int minstrel_get_tp_avg(struct minstrel_rate *mr, int prob_ewma)
92static inline void 92static inline void
93minstrel_sort_best_tp_rates(struct minstrel_sta_info *mi, int i, u8 *tp_list) 93minstrel_sort_best_tp_rates(struct minstrel_sta_info *mi, int i, u8 *tp_list)
94{ 94{
95 int j = MAX_THR_RATES; 95 int j;
96 struct minstrel_rate_stats *tmp_mrs = &mi->r[j - 1].stats; 96 struct minstrel_rate_stats *tmp_mrs;
97 struct minstrel_rate_stats *cur_mrs = &mi->r[i].stats; 97 struct minstrel_rate_stats *cur_mrs = &mi->r[i].stats;
98 98
99 while (j > 0 && (minstrel_get_tp_avg(&mi->r[i], cur_mrs->prob_ewma) > 99 for (j = MAX_THR_RATES; j > 0; --j) {
100 minstrel_get_tp_avg(&mi->r[tp_list[j - 1]], tmp_mrs->prob_ewma))) {
101 j--;
102 tmp_mrs = &mi->r[tp_list[j - 1]].stats; 100 tmp_mrs = &mi->r[tp_list[j - 1]].stats;
101 if (minstrel_get_tp_avg(&mi->r[i], cur_mrs->prob_ewma) <=
102 minstrel_get_tp_avg(&mi->r[tp_list[j - 1]], tmp_mrs->prob_ewma))
103 break;
103 } 104 }
104 105
105 if (j < MAX_THR_RATES - 1) 106 if (j < MAX_THR_RATES - 1)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 0b9847affbec..374ea53288ca 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5190,6 +5190,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5190 SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 5190 SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
5191 SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 5191 SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
5192 SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC292_FIXUP_DISABLE_AAMIX), 5192 SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC292_FIXUP_DISABLE_AAMIX),
5193 SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC292_FIXUP_DISABLE_AAMIX),
5193 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 5194 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
5194 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 5195 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
5195 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), 5196 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
@@ -5291,6 +5292,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5291 SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440_DOCK), 5292 SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440_DOCK),
5292 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK), 5293 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
5293 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK), 5294 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
5295 SND_PCI_QUIRK(0x17aa, 0x2211, "Thinkpad W541", ALC292_FIXUP_TPT440_DOCK),
5294 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK), 5296 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
5295 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK), 5297 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
5296 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 5298 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index 2ae9619443d1..1d651b8a8957 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -30,6 +30,9 @@ config SND_SOC_GENERIC_DMAENGINE_PCM
30 bool 30 bool
31 select SND_DMAENGINE_PCM 31 select SND_DMAENGINE_PCM
32 32
33config SND_SOC_TOPOLOGY
34 bool
35
33# All the supported SoCs 36# All the supported SoCs
34source "sound/soc/adi/Kconfig" 37source "sound/soc/adi/Kconfig"
35source "sound/soc/atmel/Kconfig" 38source "sound/soc/atmel/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index e189903fabf4..669648b41d30 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -1,6 +1,9 @@
1snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o 1snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o
2snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o soc-devres.o soc-ops.o 2snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o soc-devres.o soc-ops.o
3
4ifneq ($(CONFIG_SND_SOC_TOPOLOGY),)
3snd-soc-core-objs += soc-topology.o 5snd-soc-core-objs += soc-topology.o
6endif
4 7
5ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),) 8ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),)
6snd-soc-core-objs += soc-generic-dmaengine-pcm.o 9snd-soc-core-objs += soc-generic-dmaengine-pcm.o
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 1fab9778807a..0450593980fd 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -638,7 +638,7 @@ int snd_usb_autoresume(struct snd_usb_audio *chip)
638 int err = -ENODEV; 638 int err = -ENODEV;
639 639
640 down_read(&chip->shutdown_rwsem); 640 down_read(&chip->shutdown_rwsem);
641 if (chip->probing && chip->in_pm) 641 if (chip->probing || chip->in_pm)
642 err = 0; 642 err = 0;
643 else if (!chip->shutdown) 643 else if (!chip->shutdown)
644 err = usb_autopm_get_interface(chip->pm_intf); 644 err = usb_autopm_get_interface(chip->pm_intf);
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 094ddaee104c..d31fac19c30b 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -638,7 +638,7 @@ ifndef DESTDIR
638prefix ?= $(HOME) 638prefix ?= $(HOME)
639endif 639endif
640bindir_relative = bin 640bindir_relative = bin
641bindir = $(prefix)/$(bindir_relative) 641bindir = $(abspath $(prefix)/$(bindir_relative))
642mandir = share/man 642mandir = share/man
643infodir = share/info 643infodir = share/info
644perfexecdir = libexec/perf-core 644perfexecdir = libexec/perf-core
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 53e8bb7bc852..2a5d8d7698ae 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -85,7 +85,7 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,
85 else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) 85 else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
86 update_stats(&runtime_cycles_stats[ctx][cpu], count[0]); 86 update_stats(&runtime_cycles_stats[ctx][cpu], count[0]);
87 else if (perf_stat_evsel__is(counter, CYCLES_IN_TX)) 87 else if (perf_stat_evsel__is(counter, CYCLES_IN_TX))
88 update_stats(&runtime_transaction_stats[ctx][cpu], count[0]); 88 update_stats(&runtime_cycles_in_tx_stats[ctx][cpu], count[0]);
89 else if (perf_stat_evsel__is(counter, TRANSACTION_START)) 89 else if (perf_stat_evsel__is(counter, TRANSACTION_START))
90 update_stats(&runtime_transaction_stats[ctx][cpu], count[0]); 90 update_stats(&runtime_transaction_stats[ctx][cpu], count[0]);
91 else if (perf_stat_evsel__is(counter, ELISION_START)) 91 else if (perf_stat_evsel__is(counter, ELISION_START))
@@ -398,20 +398,18 @@ void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel,
398 " # %5.2f%% aborted cycles ", 398 " # %5.2f%% aborted cycles ",
399 100.0 * ((total2-avg) / total)); 399 100.0 * ((total2-avg) / total));
400 } else if (perf_stat_evsel__is(evsel, TRANSACTION_START) && 400 } else if (perf_stat_evsel__is(evsel, TRANSACTION_START) &&
401 avg > 0 &&
402 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) { 401 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) {
403 total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]); 402 total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]);
404 403
405 if (total) 404 if (avg)
406 ratio = total / avg; 405 ratio = total / avg;
407 406
408 fprintf(out, " # %8.0f cycles / transaction ", ratio); 407 fprintf(out, " # %8.0f cycles / transaction ", ratio);
409 } else if (perf_stat_evsel__is(evsel, ELISION_START) && 408 } else if (perf_stat_evsel__is(evsel, ELISION_START) &&
410 avg > 0 &&
411 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) { 409 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) {
412 total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]); 410 total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]);
413 411
414 if (total) 412 if (avg)
415 ratio = total / avg; 413 ratio = total / avg;
416 414
417 fprintf(out, " # %8.0f cycles / elision ", ratio); 415 fprintf(out, " # %8.0f cycles / elision ", ratio);