Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Fri, 26 Nov 2021 12:01:01
Message-Id: 1637928042.327d60d57bb5b15ebd173069acab8bc6879f6c62.mpagano@gentoo
1 commit: 327d60d57bb5b15ebd173069acab8bc6879f6c62
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Nov 26 12:00:42 2021 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri Nov 26 12:00:42 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=327d60d5
7
8 Linux patch 4.14.256
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1255_linux-4.14.256.patch | 7692 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 7696 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 5c9d9f3b..c9e02ac7 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -1067,6 +1067,10 @@ Patch: 1254_linux-4.14.255.patch
21 From: https://www.kernel.org
22 Desc: Linux 4.14.255
23
24 +Patch: 1255_linux-4.14.256.patch
25 +From: https://www.kernel.org
26 +Desc: Linux 4.14.256
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1255_linux-4.14.256.patch b/1255_linux-4.14.256.patch
33 new file mode 100644
34 index 00000000..3f38f263
35 --- /dev/null
36 +++ b/1255_linux-4.14.256.patch
37 @@ -0,0 +1,7692 @@
38 +diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
39 +index 3a1507362eb1e..6de214080bbfa 100644
40 +--- a/Documentation/admin-guide/kernel-parameters.txt
41 ++++ b/Documentation/admin-guide/kernel-parameters.txt
42 +@@ -5030,6 +5030,13 @@
43 + Disables the PV optimizations forcing the HVM guest to
44 + run as generic HVM guest with no PV drivers.
45 +
46 ++ xen.balloon_boot_timeout= [XEN]
47 ++ The time (in seconds) to wait before giving up to boot
48 ++ in case initial ballooning fails to free enough memory.
49 ++ Applies only when running as HVM or PVH guest and
50 ++ started with less memory configured than allowed at
51 ++ max. Default is 180.
52 ++
53 + xen.event_eoi_delay= [XEN]
54 + How long to delay EOI handling in case of event
55 + storms (jiffies). Default is 10.
56 +diff --git a/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt b/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt
57 +index 093edda0c8dfc..6cd83d920155f 100644
58 +--- a/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt
59 ++++ b/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt
60 +@@ -13,6 +13,14 @@ common regulator binding documented in:
61 +
62 +
63 + Required properties of the main device node (the parent!):
64 ++ - s5m8767,pmic-buck-ds-gpios: GPIO specifiers for three host gpio's used
65 ++ for selecting GPIO DVS lines. It is one-to-one mapped to dvs gpio lines.
66 ++
67 ++ [1] If either of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional
68 ++ property is specified, then all the eight voltage values for the
69 ++ 's5m8767,pmic-buck[2/3/4]-dvs-voltage' should be specified.
70 ++
71 ++Optional properties of the main device node (the parent!):
72 + - s5m8767,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt (uV)
73 + units for buck2 when changing voltage using gpio dvs. Refer to [1] below
74 + for additional information.
75 +@@ -25,26 +33,13 @@ Required properties of the main device node (the parent!):
76 + units for buck4 when changing voltage using gpio dvs. Refer to [1] below
77 + for additional information.
78 +
79 +- - s5m8767,pmic-buck-ds-gpios: GPIO specifiers for three host gpio's used
80 +- for selecting GPIO DVS lines. It is one-to-one mapped to dvs gpio lines.
81 +-
82 +- [1] If none of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional
83 +- property is specified, the 's5m8767,pmic-buck[2/3/4]-dvs-voltage'
84 +- property should specify atleast one voltage level (which would be a
85 +- safe operating voltage).
86 +-
87 +- If either of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional
88 +- property is specified, then all the eight voltage values for the
89 +- 's5m8767,pmic-buck[2/3/4]-dvs-voltage' should be specified.
90 +-
91 +-Optional properties of the main device node (the parent!):
92 + - s5m8767,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs.
93 + - s5m8767,pmic-buck3-uses-gpio-dvs: 'buck3' can be controlled by gpio dvs.
94 + - s5m8767,pmic-buck4-uses-gpio-dvs: 'buck4' can be controlled by gpio dvs.
95 +
96 + Additional properties required if either of the optional properties are used:
97 +
98 +- - s5m8767,pmic-buck234-default-dvs-idx: Default voltage setting selected from
99 ++ - s5m8767,pmic-buck-default-dvs-idx: Default voltage setting selected from
100 + the possible 8 options selectable by the dvs gpios. The value of this
101 + property should be between 0 and 7. If not specified or if out of range, the
102 + default value of this property is set to 0.
103 +diff --git a/Makefile b/Makefile
104 +index 552f17dd25b41..dd00bb6d79ef7 100644
105 +--- a/Makefile
106 ++++ b/Makefile
107 +@@ -1,7 +1,7 @@
108 + # SPDX-License-Identifier: GPL-2.0
109 + VERSION = 4
110 + PATCHLEVEL = 14
111 +-SUBLEVEL = 255
112 ++SUBLEVEL = 256
113 + EXTRAVERSION =
114 + NAME = Petit Gorille
115 +
116 +diff --git a/arch/arm/Makefile b/arch/arm/Makefile
117 +index e7455058416ef..ce4ba57d4a65c 100644
118 +--- a/arch/arm/Makefile
119 ++++ b/arch/arm/Makefile
120 +@@ -66,15 +66,15 @@ KBUILD_CFLAGS += $(call cc-option,-fno-ipa-sra)
121 + # Note that GCC does not numerically define an architecture version
122 + # macro, but instead defines a whole series of macros which makes
123 + # testing for a specific architecture or later rather impossible.
124 +-arch-$(CONFIG_CPU_32v7M) =-D__LINUX_ARM_ARCH__=7 -march=armv7-m -Wa,-march=armv7-m
125 +-arch-$(CONFIG_CPU_32v7) =-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a)
126 +-arch-$(CONFIG_CPU_32v6) =-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6)
127 ++arch-$(CONFIG_CPU_32v7M) =-D__LINUX_ARM_ARCH__=7 -march=armv7-m
128 ++arch-$(CONFIG_CPU_32v7) =-D__LINUX_ARM_ARCH__=7 -march=armv7-a
129 ++arch-$(CONFIG_CPU_32v6) =-D__LINUX_ARM_ARCH__=6 -march=armv6
130 + # Only override the compiler option if ARMv6. The ARMv6K extensions are
131 + # always available in ARMv7
132 + ifeq ($(CONFIG_CPU_32v6),y)
133 +-arch-$(CONFIG_CPU_32v6K) =-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6k,-march=armv5t -Wa$(comma)-march=armv6k)
134 ++arch-$(CONFIG_CPU_32v6K) =-D__LINUX_ARM_ARCH__=6 -march=armv6k
135 + endif
136 +-arch-$(CONFIG_CPU_32v5) =-D__LINUX_ARM_ARCH__=5 $(call cc-option,-march=armv5te,-march=armv4t)
137 ++arch-$(CONFIG_CPU_32v5) =-D__LINUX_ARM_ARCH__=5 -march=armv5te
138 + arch-$(CONFIG_CPU_32v4T) =-D__LINUX_ARM_ARCH__=4 -march=armv4t
139 + arch-$(CONFIG_CPU_32v4) =-D__LINUX_ARM_ARCH__=4 -march=armv4
140 + arch-$(CONFIG_CPU_32v3) =-D__LINUX_ARM_ARCH__=3 -march=armv3
141 +@@ -88,7 +88,7 @@ tune-$(CONFIG_CPU_ARM720T) =-mtune=arm7tdmi
142 + tune-$(CONFIG_CPU_ARM740T) =-mtune=arm7tdmi
143 + tune-$(CONFIG_CPU_ARM9TDMI) =-mtune=arm9tdmi
144 + tune-$(CONFIG_CPU_ARM940T) =-mtune=arm9tdmi
145 +-tune-$(CONFIG_CPU_ARM946E) =$(call cc-option,-mtune=arm9e,-mtune=arm9tdmi)
146 ++tune-$(CONFIG_CPU_ARM946E) =-mtune=arm9e
147 + tune-$(CONFIG_CPU_ARM920T) =-mtune=arm9tdmi
148 + tune-$(CONFIG_CPU_ARM922T) =-mtune=arm9tdmi
149 + tune-$(CONFIG_CPU_ARM925T) =-mtune=arm9tdmi
150 +@@ -96,11 +96,11 @@ tune-$(CONFIG_CPU_ARM926T) =-mtune=arm9tdmi
151 + tune-$(CONFIG_CPU_FA526) =-mtune=arm9tdmi
152 + tune-$(CONFIG_CPU_SA110) =-mtune=strongarm110
153 + tune-$(CONFIG_CPU_SA1100) =-mtune=strongarm1100
154 +-tune-$(CONFIG_CPU_XSCALE) =$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale
155 +-tune-$(CONFIG_CPU_XSC3) =$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale
156 +-tune-$(CONFIG_CPU_FEROCEON) =$(call cc-option,-mtune=marvell-f,-mtune=xscale)
157 +-tune-$(CONFIG_CPU_V6) =$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
158 +-tune-$(CONFIG_CPU_V6K) =$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
159 ++tune-$(CONFIG_CPU_XSCALE) =-mtune=xscale
160 ++tune-$(CONFIG_CPU_XSC3) =-mtune=xscale
161 ++tune-$(CONFIG_CPU_FEROCEON) =-mtune=xscale
162 ++tune-$(CONFIG_CPU_V6) =-mtune=arm1136j-s
163 ++tune-$(CONFIG_CPU_V6K) =-mtune=arm1136j-s
164 +
165 + # Evaluate tune cc-option calls now
166 + tune-y := $(tune-y)
167 +diff --git a/arch/arm/boot/dts/at91-tse850-3.dts b/arch/arm/boot/dts/at91-tse850-3.dts
168 +index 4ef80a703eda3..d31a4e633fb4a 100644
169 +--- a/arch/arm/boot/dts/at91-tse850-3.dts
170 ++++ b/arch/arm/boot/dts/at91-tse850-3.dts
171 +@@ -267,7 +267,7 @@
172 + &macb1 {
173 + status = "okay";
174 +
175 +- phy-mode = "rgmii";
176 ++ phy-mode = "rmii";
177 +
178 + #address-cells = <1>;
179 + #size-cells = <0>;
180 +diff --git a/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi b/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi
181 +index 7f6aefd134514..e7534fe9c53cf 100644
182 +--- a/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi
183 ++++ b/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi
184 +@@ -29,7 +29,7 @@
185 + compatible = "smsc,lan9221","smsc,lan9115";
186 + bank-width = <2>;
187 +
188 +- gpmc,mux-add-data;
189 ++ gpmc,mux-add-data = <0>;
190 + gpmc,cs-on-ns = <0>;
191 + gpmc,cs-rd-off-ns = <42>;
192 + gpmc,cs-wr-off-ns = <36>;
193 +diff --git a/arch/arm/boot/dts/omap3-gta04.dtsi b/arch/arm/boot/dts/omap3-gta04.dtsi
194 +index e83d0619b3b7c..ee028aa663fa6 100644
195 +--- a/arch/arm/boot/dts/omap3-gta04.dtsi
196 ++++ b/arch/arm/boot/dts/omap3-gta04.dtsi
197 +@@ -353,7 +353,7 @@
198 + compatible = "bosch,bma180";
199 + reg = <0x41>;
200 + pinctrl-names = "default";
201 +- pintcrl-0 = <&bma180_pins>;
202 ++ pinctrl-0 = <&bma180_pins>;
203 + interrupt-parent = <&gpio4>;
204 + interrupts = <19 IRQ_TYPE_LEVEL_HIGH>; /* GPIO_115 */
205 + };
206 +diff --git a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
207 +index 82e98ee3023ad..3dbeb7a6c569c 100644
208 +--- a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
209 ++++ b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
210 +@@ -25,7 +25,7 @@
211 + compatible = "smsc,lan9221","smsc,lan9115";
212 + bank-width = <2>;
213 +
214 +- gpmc,mux-add-data;
215 ++ gpmc,mux-add-data = <0>;
216 + gpmc,cs-on-ns = <0>;
217 + gpmc,cs-rd-off-ns = <42>;
218 + gpmc,cs-wr-off-ns = <36>;
219 +diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
220 +index ba9b9a77bcd2c..31af81d46aaed 100644
221 +--- a/arch/arm/kernel/stacktrace.c
222 ++++ b/arch/arm/kernel/stacktrace.c
223 +@@ -52,8 +52,7 @@ int notrace unwind_frame(struct stackframe *frame)
224 +
225 + frame->sp = frame->fp;
226 + frame->fp = *(unsigned long *)(fp);
227 +- frame->pc = frame->lr;
228 +- frame->lr = *(unsigned long *)(fp + 4);
229 ++ frame->pc = *(unsigned long *)(fp + 4);
230 + #else
231 + /* check current frame pointer is within bounds */
232 + if (fp < low + 12 || fp > high - 4)
233 +diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
234 +index 50e0b45a22dba..77fd4446b5fc8 100644
235 +--- a/arch/arm/mm/Kconfig
236 ++++ b/arch/arm/mm/Kconfig
237 +@@ -757,7 +757,7 @@ config CPU_BIG_ENDIAN
238 + config CPU_ENDIAN_BE8
239 + bool
240 + depends on CPU_BIG_ENDIAN
241 +- default CPU_V6 || CPU_V6K || CPU_V7
242 ++ default CPU_V6 || CPU_V6K || CPU_V7 || CPU_V7M
243 + help
244 + Support for the BE-8 (big-endian) mode on ARMv6 and ARMv7 processors.
245 +
246 +diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
247 +index d8cbe772f6901..4c417f3cbfd52 100644
248 +--- a/arch/arm/mm/mmu.c
249 ++++ b/arch/arm/mm/mmu.c
250 +@@ -416,9 +416,9 @@ void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot)
251 + FIXADDR_END);
252 + BUG_ON(idx >= __end_of_fixed_addresses);
253 +
254 +- /* we only support device mappings until pgprot_kernel has been set */
255 ++ /* We support only device mappings before pgprot_kernel is set. */
256 + if (WARN_ON(pgprot_val(prot) != pgprot_val(FIXMAP_PAGE_IO) &&
257 +- pgprot_val(pgprot_kernel) == 0))
258 ++ pgprot_val(prot) && pgprot_val(pgprot_kernel) == 0))
259 + return;
260 +
261 + if (pgprot_val(prot))
262 +diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
263 +index 0531843117f46..58028f23ad9aa 100644
264 +--- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
265 ++++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
266 +@@ -573,7 +573,7 @@
267 + };
268 +
269 + uart0: serial@ff000000 {
270 +- compatible = "cdns,uart-r1p12", "xlnx,xuartps";
271 ++ compatible = "xlnx,zynqmp-uart", "cdns,uart-r1p12";
272 + status = "disabled";
273 + interrupt-parent = <&gic>;
274 + interrupts = <0 21 4>;
275 +@@ -582,7 +582,7 @@
276 + };
277 +
278 + uart1: serial@ff010000 {
279 +- compatible = "cdns,uart-r1p12", "xlnx,xuartps";
280 ++ compatible = "xlnx,zynqmp-uart", "cdns,uart-r1p12";
281 + status = "disabled";
282 + interrupt-parent = <&gic>;
283 + interrupts = <0 22 4>;
284 +diff --git a/arch/hexagon/lib/io.c b/arch/hexagon/lib/io.c
285 +index 885c9626d5e08..e5dfed1cf151b 100644
286 +--- a/arch/hexagon/lib/io.c
287 ++++ b/arch/hexagon/lib/io.c
288 +@@ -40,6 +40,7 @@ void __raw_readsw(const void __iomem *addr, void *data, int len)
289 + *dst++ = *src;
290 +
291 + }
292 ++EXPORT_SYMBOL(__raw_readsw);
293 +
294 + /*
295 + * __raw_writesw - read words a short at a time
296 +@@ -60,6 +61,7 @@ void __raw_writesw(void __iomem *addr, const void *data, int len)
297 +
298 +
299 + }
300 ++EXPORT_SYMBOL(__raw_writesw);
301 +
302 + /* Pretty sure len is pre-adjusted for the length of the access already */
303 + void __raw_readsl(const void __iomem *addr, void *data, int len)
304 +@@ -75,6 +77,7 @@ void __raw_readsl(const void __iomem *addr, void *data, int len)
305 +
306 +
307 + }
308 ++EXPORT_SYMBOL(__raw_readsl);
309 +
310 + void __raw_writesl(void __iomem *addr, const void *data, int len)
311 + {
312 +@@ -89,3 +92,4 @@ void __raw_writesl(void __iomem *addr, const void *data, int len)
313 +
314 +
315 + }
316 ++EXPORT_SYMBOL(__raw_writesl);
317 +diff --git a/arch/ia64/Kconfig.debug b/arch/ia64/Kconfig.debug
318 +index 677c409425df2..c27c13ca77f47 100644
319 +--- a/arch/ia64/Kconfig.debug
320 ++++ b/arch/ia64/Kconfig.debug
321 +@@ -42,7 +42,7 @@ config DISABLE_VHPT
322 +
323 + config IA64_DEBUG_CMPXCHG
324 + bool "Turn on compare-and-exchange bug checking (slow!)"
325 +- depends on DEBUG_KERNEL
326 ++ depends on DEBUG_KERNEL && PRINTK
327 + help
328 + Selecting this option turns on bug checking for the IA-64
329 + compare-and-exchange instructions. This is slow! Itaniums
330 +diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine
331 +index 5cd57b4d36156..4a1697fa9a37d 100644
332 +--- a/arch/m68k/Kconfig.machine
333 ++++ b/arch/m68k/Kconfig.machine
334 +@@ -185,6 +185,7 @@ config INIT_LCD
335 + config MEMORY_RESERVE
336 + int "Memory reservation (MiB)"
337 + depends on (UCSIMM || UCDIMM)
338 ++ default 0
339 + help
340 + Reserve certain memory regions on 68x328 based boards.
341 +
342 +diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
343 +index 49c540790fd2d..85afd6b4297b2 100644
344 +--- a/arch/mips/Kconfig
345 ++++ b/arch/mips/Kconfig
346 +@@ -273,6 +273,9 @@ config BCM63XX
347 + select SYS_SUPPORTS_32BIT_KERNEL
348 + select SYS_SUPPORTS_BIG_ENDIAN
349 + select SYS_HAS_EARLY_PRINTK
350 ++ select SYS_HAS_CPU_BMIPS32_3300
351 ++ select SYS_HAS_CPU_BMIPS4350
352 ++ select SYS_HAS_CPU_BMIPS4380
353 + select SWAP_IO_SPACE
354 + select GPIOLIB
355 + select HAVE_CLK
356 +@@ -1383,6 +1386,7 @@ config CPU_LOONGSON3
357 + select WEAK_REORDERING_BEYOND_LLSC
358 + select MIPS_PGD_C0_CONTEXT
359 + select MIPS_L1_CACHE_SHIFT_6
360 ++ select MIPS_FP_SUPPORT
361 + select GPIOLIB
362 + help
363 + The Loongson 3 processor implements the MIPS64R2 instruction
364 +diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c
365 +index 19577f771c1f0..d2a5054b0492b 100644
366 +--- a/arch/mips/bcm63xx/clk.c
367 ++++ b/arch/mips/bcm63xx/clk.c
368 +@@ -337,6 +337,12 @@ void clk_disable(struct clk *clk)
369 +
370 + EXPORT_SYMBOL(clk_disable);
371 +
372 ++struct clk *clk_get_parent(struct clk *clk)
373 ++{
374 ++ return NULL;
375 ++}
376 ++EXPORT_SYMBOL(clk_get_parent);
377 ++
378 + unsigned long clk_get_rate(struct clk *clk)
379 + {
380 + if (!clk)
381 +diff --git a/arch/mips/generic/yamon-dt.c b/arch/mips/generic/yamon-dt.c
382 +index b408dac722ac7..e5fcaafea3a42 100644
383 +--- a/arch/mips/generic/yamon-dt.c
384 ++++ b/arch/mips/generic/yamon-dt.c
385 +@@ -81,7 +81,7 @@ static unsigned int __init gen_fdt_mem_array(
386 + __init int yamon_dt_append_memory(void *fdt,
387 + const struct yamon_mem_region *regions)
388 + {
389 +- unsigned long phys_memsize, memsize;
390 ++ unsigned long phys_memsize = 0, memsize;
391 + __be32 mem_array[2 * MAX_MEM_ARRAY_ENTRIES];
392 + unsigned int mem_entries;
393 + int i, err, mem_off;
394 +diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h
395 +index 8bc5df49b0e1d..890e51b159e06 100644
396 +--- a/arch/mips/include/asm/mips-cm.h
397 ++++ b/arch/mips/include/asm/mips-cm.h
398 +@@ -15,6 +15,7 @@
399 + #ifndef __MIPS_ASM_MIPS_CM_H__
400 + #define __MIPS_ASM_MIPS_CM_H__
401 +
402 ++#include <linux/bitfield.h>
403 + #include <linux/bitops.h>
404 + #include <linux/errno.h>
405 +
406 +@@ -157,8 +158,8 @@ GCR_ACCESSOR_RO(32, 0x030, rev)
407 + #define CM_GCR_REV_MINOR GENMASK(7, 0)
408 +
409 + #define CM_ENCODE_REV(major, minor) \
410 +- (((major) << __ffs(CM_GCR_REV_MAJOR)) | \
411 +- ((minor) << __ffs(CM_GCR_REV_MINOR)))
412 ++ (FIELD_PREP(CM_GCR_REV_MAJOR, major) | \
413 ++ FIELD_PREP(CM_GCR_REV_MINOR, minor))
414 +
415 + #define CM_REV_CM2 CM_ENCODE_REV(6, 0)
416 + #define CM_REV_CM2_5 CM_ENCODE_REV(7, 0)
417 +@@ -366,10 +367,10 @@ static inline int mips_cm_revision(void)
418 + static inline unsigned int mips_cm_max_vp_width(void)
419 + {
420 + extern int smp_num_siblings;
421 +- uint32_t cfg;
422 +
423 + if (mips_cm_revision() >= CM_REV_CM3)
424 +- return read_gcr_sys_config2() & CM_GCR_SYS_CONFIG2_MAXVPW;
425 ++ return FIELD_GET(CM_GCR_SYS_CONFIG2_MAXVPW,
426 ++ read_gcr_sys_config2());
427 +
428 + if (mips_cm_present()) {
429 + /*
430 +@@ -377,8 +378,7 @@ static inline unsigned int mips_cm_max_vp_width(void)
431 + * number of VP(E)s, and if that ever changes then this will
432 + * need revisiting.
433 + */
434 +- cfg = read_gcr_cl_config() & CM_GCR_Cx_CONFIG_PVPE;
435 +- return (cfg >> __ffs(CM_GCR_Cx_CONFIG_PVPE)) + 1;
436 ++ return FIELD_GET(CM_GCR_Cx_CONFIG_PVPE, read_gcr_cl_config()) + 1;
437 + }
438 +
439 + if (IS_ENABLED(CONFIG_SMP))
440 +diff --git a/arch/mips/kernel/mips-cm.c b/arch/mips/kernel/mips-cm.c
441 +index 50d3d74001cbe..51cfcb44e6703 100644
442 +--- a/arch/mips/kernel/mips-cm.c
443 ++++ b/arch/mips/kernel/mips-cm.c
444 +@@ -183,8 +183,7 @@ static void mips_cm_probe_l2sync(void)
445 + phys_addr_t addr;
446 +
447 + /* L2-only sync was introduced with CM major revision 6 */
448 +- major_rev = (read_gcr_rev() & CM_GCR_REV_MAJOR) >>
449 +- __ffs(CM_GCR_REV_MAJOR);
450 ++ major_rev = FIELD_GET(CM_GCR_REV_MAJOR, read_gcr_rev());
451 + if (major_rev < 6)
452 + return;
453 +
454 +@@ -267,13 +266,13 @@ void mips_cm_lock_other(unsigned int cluster, unsigned int core,
455 + preempt_disable();
456 +
457 + if (cm_rev >= CM_REV_CM3) {
458 +- val = core << __ffs(CM3_GCR_Cx_OTHER_CORE);
459 +- val |= vp << __ffs(CM3_GCR_Cx_OTHER_VP);
460 ++ val = FIELD_PREP(CM3_GCR_Cx_OTHER_CORE, core) |
461 ++ FIELD_PREP(CM3_GCR_Cx_OTHER_VP, vp);
462 +
463 + if (cm_rev >= CM_REV_CM3_5) {
464 + val |= CM_GCR_Cx_OTHER_CLUSTER_EN;
465 +- val |= cluster << __ffs(CM_GCR_Cx_OTHER_CLUSTER);
466 +- val |= block << __ffs(CM_GCR_Cx_OTHER_BLOCK);
467 ++ val |= FIELD_PREP(CM_GCR_Cx_OTHER_CLUSTER, cluster);
468 ++ val |= FIELD_PREP(CM_GCR_Cx_OTHER_BLOCK, block);
469 + } else {
470 + WARN_ON(cluster != 0);
471 + WARN_ON(block != CM_GCR_Cx_OTHER_BLOCK_LOCAL);
472 +@@ -303,7 +302,7 @@ void mips_cm_lock_other(unsigned int cluster, unsigned int core,
473 + spin_lock_irqsave(&per_cpu(cm_core_lock, curr_core),
474 + per_cpu(cm_core_lock_flags, curr_core));
475 +
476 +- val = core << __ffs(CM_GCR_Cx_OTHER_CORENUM);
477 ++ val = FIELD_PREP(CM_GCR_Cx_OTHER_CORENUM, core);
478 + }
479 +
480 + write_gcr_cl_other(val);
481 +@@ -347,8 +346,8 @@ void mips_cm_error_report(void)
482 + cm_other = read_gcr_error_mult();
483 +
484 + if (revision < CM_REV_CM3) { /* CM2 */
485 +- cause = cm_error >> __ffs(CM_GCR_ERROR_CAUSE_ERRTYPE);
486 +- ocause = cm_other >> __ffs(CM_GCR_ERROR_MULT_ERR2ND);
487 ++ cause = FIELD_GET(CM_GCR_ERROR_CAUSE_ERRTYPE, cm_error);
488 ++ ocause = FIELD_GET(CM_GCR_ERROR_MULT_ERR2ND, cm_other);
489 +
490 + if (!cause)
491 + return;
492 +@@ -390,8 +389,8 @@ void mips_cm_error_report(void)
493 + ulong core_id_bits, vp_id_bits, cmd_bits, cmd_group_bits;
494 + ulong cm3_cca_bits, mcp_bits, cm3_tr_bits, sched_bit;
495 +
496 +- cause = cm_error >> __ffs64(CM3_GCR_ERROR_CAUSE_ERRTYPE);
497 +- ocause = cm_other >> __ffs(CM_GCR_ERROR_MULT_ERR2ND);
498 ++ cause = FIELD_GET(CM3_GCR_ERROR_CAUSE_ERRTYPE, cm_error);
499 ++ ocause = FIELD_GET(CM_GCR_ERROR_MULT_ERR2ND, cm_other);
500 +
501 + if (!cause)
502 + return;
503 +diff --git a/arch/mips/kernel/r2300_fpu.S b/arch/mips/kernel/r2300_fpu.S
504 +index 3062ba66c5635..f7ce7b3971a4b 100644
505 +--- a/arch/mips/kernel/r2300_fpu.S
506 ++++ b/arch/mips/kernel/r2300_fpu.S
507 +@@ -29,8 +29,8 @@
508 + #define EX2(a,b) \
509 + 9: a,##b; \
510 + .section __ex_table,"a"; \
511 +- PTR 9b,bad_stack; \
512 +- PTR 9b+4,bad_stack; \
513 ++ PTR 9b,fault; \
514 ++ PTR 9b+4,fault; \
515 + .previous
516 +
517 + .set mips1
518 +diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
519 +index 58c6f634b5506..d25b8566af98f 100644
520 +--- a/arch/mips/kernel/syscall.c
521 ++++ b/arch/mips/kernel/syscall.c
522 +@@ -233,12 +233,3 @@ SYSCALL_DEFINE3(cachectl, char *, addr, int, nbytes, int, op)
523 + {
524 + return -ENOSYS;
525 + }
526 +-
527 +-/*
528 +- * If we ever come here the user sp is bad. Zap the process right away.
529 +- * Due to the bad stack signaling wouldn't work.
530 +- */
531 +-asmlinkage void bad_stack(void)
532 +-{
533 +- do_exit(SIGSEGV);
534 +-}
535 +diff --git a/arch/mips/lantiq/clk.c b/arch/mips/lantiq/clk.c
536 +index a263d1b751ffe..a8e309dcd38d7 100644
537 +--- a/arch/mips/lantiq/clk.c
538 ++++ b/arch/mips/lantiq/clk.c
539 +@@ -160,6 +160,12 @@ void clk_deactivate(struct clk *clk)
540 + }
541 + EXPORT_SYMBOL(clk_deactivate);
542 +
543 ++struct clk *clk_get_parent(struct clk *clk)
544 ++{
545 ++ return NULL;
546 ++}
547 ++EXPORT_SYMBOL(clk_get_parent);
548 ++
549 + static inline u32 get_counter_resolution(void)
550 + {
551 + u32 res;
552 +diff --git a/arch/mips/lantiq/xway/dma.c b/arch/mips/lantiq/xway/dma.c
553 +index 805b3a6ab2d60..0de61165ef6e4 100644
554 +--- a/arch/mips/lantiq/xway/dma.c
555 ++++ b/arch/mips/lantiq/xway/dma.c
556 +@@ -22,6 +22,7 @@
557 + #include <linux/export.h>
558 + #include <linux/spinlock.h>
559 + #include <linux/clk.h>
560 ++#include <linux/delay.h>
561 + #include <linux/err.h>
562 +
563 + #include <lantiq_soc.h>
564 +@@ -40,6 +41,7 @@
565 + #define LTQ_DMA_PCTRL 0x44
566 + #define LTQ_DMA_IRNEN 0xf4
567 +
568 ++#define DMA_ID_CHNR GENMASK(26, 20) /* channel number */
569 + #define DMA_DESCPT BIT(3) /* descriptor complete irq */
570 + #define DMA_TX BIT(8) /* TX channel direction */
571 + #define DMA_CHAN_ON BIT(0) /* channel on / off bit */
572 +@@ -50,7 +52,6 @@
573 + #define DMA_POLL BIT(31) /* turn on channel polling */
574 + #define DMA_CLK_DIV4 BIT(6) /* polling clock divider */
575 + #define DMA_2W_BURST BIT(1) /* 2 word burst length */
576 +-#define DMA_MAX_CHANNEL 20 /* the soc has 20 channels */
577 + #define DMA_ETOP_ENDIANNESS (0xf << 8) /* endianness swap etop channels */
578 + #define DMA_WEIGHT (BIT(17) | BIT(16)) /* default channel wheight */
579 +
580 +@@ -218,7 +219,7 @@ ltq_dma_init(struct platform_device *pdev)
581 + {
582 + struct clk *clk;
583 + struct resource *res;
584 +- unsigned id;
585 ++ unsigned int id, nchannels;
586 + int i;
587 +
588 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
589 +@@ -234,21 +235,24 @@ ltq_dma_init(struct platform_device *pdev)
590 + clk_enable(clk);
591 + ltq_dma_w32_mask(0, DMA_RESET, LTQ_DMA_CTRL);
592 +
593 ++ usleep_range(1, 10);
594 ++
595 + /* disable all interrupts */
596 + ltq_dma_w32(0, LTQ_DMA_IRNEN);
597 +
598 + /* reset/configure each channel */
599 +- for (i = 0; i < DMA_MAX_CHANNEL; i++) {
600 ++ id = ltq_dma_r32(LTQ_DMA_ID);
601 ++ nchannels = ((id & DMA_ID_CHNR) >> 20);
602 ++ for (i = 0; i < nchannels; i++) {
603 + ltq_dma_w32(i, LTQ_DMA_CS);
604 + ltq_dma_w32(DMA_CHAN_RST, LTQ_DMA_CCTRL);
605 + ltq_dma_w32(DMA_POLL | DMA_CLK_DIV4, LTQ_DMA_CPOLL);
606 + ltq_dma_w32_mask(DMA_CHAN_ON, 0, LTQ_DMA_CCTRL);
607 + }
608 +
609 +- id = ltq_dma_r32(LTQ_DMA_ID);
610 + dev_info(&pdev->dev,
611 + "Init done - hw rev: %X, ports: %d, channels: %d\n",
612 +- id & 0x1f, (id >> 16) & 0xf, id >> 20);
613 ++ id & 0x1f, (id >> 16) & 0xf, nchannels);
614 +
615 + return 0;
616 + }
617 +diff --git a/arch/mips/sni/time.c b/arch/mips/sni/time.c
618 +index 0eb7d1e8821be..d741e24a21879 100644
619 +--- a/arch/mips/sni/time.c
620 ++++ b/arch/mips/sni/time.c
621 +@@ -18,14 +18,14 @@ static int a20r_set_periodic(struct clock_event_device *evt)
622 + {
623 + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0x34;
624 + wmb();
625 +- *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV;
626 ++ *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV & 0xff;
627 + wmb();
628 + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV >> 8;
629 + wmb();
630 +
631 + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0xb4;
632 + wmb();
633 +- *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV;
634 ++ *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV & 0xff;
635 + wmb();
636 + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV >> 8;
637 + wmb();
638 +diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
639 +index 843825a7e6e2a..0f2b4355064fa 100644
640 +--- a/arch/parisc/kernel/entry.S
641 ++++ b/arch/parisc/kernel/entry.S
642 +@@ -1849,8 +1849,8 @@ syscall_restore:
643 + LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1
644 +
645 + /* Are we being ptraced? */
646 +- ldw TASK_FLAGS(%r1),%r19
647 +- ldi _TIF_SYSCALL_TRACE_MASK,%r2
648 ++ LDREG TI_FLAGS-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r19
649 ++ ldi _TIF_SINGLESTEP|_TIF_BLOCKSTEP,%r2
650 + and,COND(=) %r19,%r2,%r0
651 + b,n syscall_restore_rfi
652 +
653 +diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
654 +index ab4d5580bb02b..45e3aadcecd2f 100644
655 +--- a/arch/parisc/kernel/smp.c
656 ++++ b/arch/parisc/kernel/smp.c
657 +@@ -32,6 +32,7 @@
658 + #include <linux/bitops.h>
659 + #include <linux/ftrace.h>
660 + #include <linux/cpu.h>
661 ++#include <linux/kgdb.h>
662 +
663 + #include <linux/atomic.h>
664 + #include <asm/current.h>
665 +@@ -74,7 +75,10 @@ enum ipi_message_type {
666 + IPI_CALL_FUNC,
667 + IPI_CPU_START,
668 + IPI_CPU_STOP,
669 +- IPI_CPU_TEST
670 ++ IPI_CPU_TEST,
671 ++#ifdef CONFIG_KGDB
672 ++ IPI_ENTER_KGDB,
673 ++#endif
674 + };
675 +
676 +
677 +@@ -170,7 +174,12 @@ ipi_interrupt(int irq, void *dev_id)
678 + case IPI_CPU_TEST:
679 + smp_debug(100, KERN_DEBUG "CPU%d is alive!\n", this_cpu);
680 + break;
681 +-
682 ++#ifdef CONFIG_KGDB
683 ++ case IPI_ENTER_KGDB:
684 ++ smp_debug(100, KERN_DEBUG "CPU%d ENTER_KGDB\n", this_cpu);
685 ++ kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs());
686 ++ break;
687 ++#endif
688 + default:
689 + printk(KERN_CRIT "Unknown IPI num on CPU%d: %lu\n",
690 + this_cpu, which);
691 +@@ -226,6 +235,12 @@ send_IPI_allbutself(enum ipi_message_type op)
692 + }
693 + }
694 +
695 ++#ifdef CONFIG_KGDB
696 ++void kgdb_roundup_cpus(void)
697 ++{
698 ++ send_IPI_allbutself(IPI_ENTER_KGDB);
699 ++}
700 ++#endif
701 +
702 + inline void
703 + smp_send_stop(void) { send_IPI_allbutself(IPI_CPU_STOP); }
704 +diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
705 +index 8be075f81ce66..c8af5296cfd24 100644
706 +--- a/arch/parisc/mm/init.c
707 ++++ b/arch/parisc/mm/init.c
708 +@@ -895,9 +895,9 @@ void flush_tlb_all(void)
709 + {
710 + int do_recycle;
711 +
712 +- __inc_irq_stat(irq_tlb_count);
713 + do_recycle = 0;
714 + spin_lock(&sid_lock);
715 ++ __inc_irq_stat(irq_tlb_count);
716 + if (dirty_space_ids > RECYCLE_THRESHOLD) {
717 + BUG_ON(recycle_inuse); /* FIXME: Use a semaphore/wait queue here */
718 + get_dirty_sids(&recycle_ndirty,recycle_dirty_array);
719 +@@ -916,8 +916,8 @@ void flush_tlb_all(void)
720 + #else
721 + void flush_tlb_all(void)
722 + {
723 +- __inc_irq_stat(irq_tlb_count);
724 + spin_lock(&sid_lock);
725 ++ __inc_irq_stat(irq_tlb_count);
726 + flush_tlb_all_local(NULL);
727 + recycle_sids();
728 + spin_unlock(&sid_lock);
729 +diff --git a/arch/powerpc/boot/dts/charon.dts b/arch/powerpc/boot/dts/charon.dts
730 +index 0e00e508eaa6a..1c8fe20752e6a 100644
731 +--- a/arch/powerpc/boot/dts/charon.dts
732 ++++ b/arch/powerpc/boot/dts/charon.dts
733 +@@ -39,7 +39,7 @@
734 + };
735 + };
736 +
737 +- memory {
738 ++ memory@0 {
739 + device_type = "memory";
740 + reg = <0x00000000 0x08000000>; // 128MB
741 + };
742 +diff --git a/arch/powerpc/boot/dts/digsy_mtc.dts b/arch/powerpc/boot/dts/digsy_mtc.dts
743 +index c280e75c86bfd..d4a0a367ed66b 100644
744 +--- a/arch/powerpc/boot/dts/digsy_mtc.dts
745 ++++ b/arch/powerpc/boot/dts/digsy_mtc.dts
746 +@@ -20,7 +20,7 @@
747 + model = "intercontrol,digsy-mtc";
748 + compatible = "intercontrol,digsy-mtc";
749 +
750 +- memory {
751 ++ memory@0 {
752 + reg = <0x00000000 0x02000000>; // 32MB
753 + };
754 +
755 +diff --git a/arch/powerpc/boot/dts/lite5200.dts b/arch/powerpc/boot/dts/lite5200.dts
756 +index 179a1785d6454..18d137a3393f0 100644
757 +--- a/arch/powerpc/boot/dts/lite5200.dts
758 ++++ b/arch/powerpc/boot/dts/lite5200.dts
759 +@@ -36,7 +36,7 @@
760 + };
761 + };
762 +
763 +- memory {
764 ++ memory@0 {
765 + device_type = "memory";
766 + reg = <0x00000000 0x04000000>; // 64MB
767 + };
768 +diff --git a/arch/powerpc/boot/dts/lite5200b.dts b/arch/powerpc/boot/dts/lite5200b.dts
769 +index 5abb46c5cc951..29419cf81e044 100644
770 +--- a/arch/powerpc/boot/dts/lite5200b.dts
771 ++++ b/arch/powerpc/boot/dts/lite5200b.dts
772 +@@ -35,7 +35,7 @@
773 + led4 { gpios = <&gpio_simple 2 1>; };
774 + };
775 +
776 +- memory {
777 ++ memory@0 {
778 + reg = <0x00000000 0x10000000>; // 256MB
779 + };
780 +
781 +diff --git a/arch/powerpc/boot/dts/media5200.dts b/arch/powerpc/boot/dts/media5200.dts
782 +index b5413cb85f134..3d57463bc49da 100644
783 +--- a/arch/powerpc/boot/dts/media5200.dts
784 ++++ b/arch/powerpc/boot/dts/media5200.dts
785 +@@ -36,7 +36,7 @@
786 + };
787 + };
788 +
789 +- memory {
790 ++ memory@0 {
791 + reg = <0x00000000 0x08000000>; // 128MB RAM
792 + };
793 +
794 +diff --git a/arch/powerpc/boot/dts/mpc5200b.dtsi b/arch/powerpc/boot/dts/mpc5200b.dtsi
795 +index 969b2200b2f97..ecfba675b5611 100644
796 +--- a/arch/powerpc/boot/dts/mpc5200b.dtsi
797 ++++ b/arch/powerpc/boot/dts/mpc5200b.dtsi
798 +@@ -37,7 +37,7 @@
799 + };
800 + };
801 +
802 +- memory: memory {
803 ++ memory: memory@0 {
804 + device_type = "memory";
805 + reg = <0x00000000 0x04000000>; // 64MB
806 + };
807 +diff --git a/arch/powerpc/boot/dts/o2d.dts b/arch/powerpc/boot/dts/o2d.dts
808 +index 9f6dd4d889b32..5a676e8141caf 100644
809 +--- a/arch/powerpc/boot/dts/o2d.dts
810 ++++ b/arch/powerpc/boot/dts/o2d.dts
811 +@@ -16,7 +16,7 @@
812 + model = "ifm,o2d";
813 + compatible = "ifm,o2d";
814 +
815 +- memory {
816 ++ memory@0 {
817 + reg = <0x00000000 0x08000000>; // 128MB
818 + };
819 +
820 +diff --git a/arch/powerpc/boot/dts/o2d.dtsi b/arch/powerpc/boot/dts/o2d.dtsi
821 +index cf073e693f24d..1b4df5f64b580 100644
822 +--- a/arch/powerpc/boot/dts/o2d.dtsi
823 ++++ b/arch/powerpc/boot/dts/o2d.dtsi
824 +@@ -23,7 +23,7 @@
825 + model = "ifm,o2d";
826 + compatible = "ifm,o2d";
827 +
828 +- memory {
829 ++ memory@0 {
830 + reg = <0x00000000 0x04000000>; // 64MB
831 + };
832 +
833 +diff --git a/arch/powerpc/boot/dts/o2dnt2.dts b/arch/powerpc/boot/dts/o2dnt2.dts
834 +index a0f5b97a4f06e..5184c461a205f 100644
835 +--- a/arch/powerpc/boot/dts/o2dnt2.dts
836 ++++ b/arch/powerpc/boot/dts/o2dnt2.dts
837 +@@ -16,7 +16,7 @@
838 + model = "ifm,o2dnt2";
839 + compatible = "ifm,o2d";
840 +
841 +- memory {
842 ++ memory@0 {
843 + reg = <0x00000000 0x08000000>; // 128MB
844 + };
845 +
846 +diff --git a/arch/powerpc/boot/dts/o3dnt.dts b/arch/powerpc/boot/dts/o3dnt.dts
847 +index acce49326491b..045b901719245 100644
848 +--- a/arch/powerpc/boot/dts/o3dnt.dts
849 ++++ b/arch/powerpc/boot/dts/o3dnt.dts
850 +@@ -16,7 +16,7 @@
851 + model = "ifm,o3dnt";
852 + compatible = "ifm,o2d";
853 +
854 +- memory {
855 ++ memory@0 {
856 + reg = <0x00000000 0x04000000>; // 64MB
857 + };
858 +
859 +diff --git a/arch/powerpc/boot/dts/pcm032.dts b/arch/powerpc/boot/dts/pcm032.dts
860 +index 576249bf2fb91..637e14286dde5 100644
861 +--- a/arch/powerpc/boot/dts/pcm032.dts
862 ++++ b/arch/powerpc/boot/dts/pcm032.dts
863 +@@ -26,7 +26,7 @@
864 + model = "phytec,pcm032";
865 + compatible = "phytec,pcm032";
866 +
867 +- memory {
868 ++ memory@0 {
869 + reg = <0x00000000 0x08000000>; // 128MB
870 + };
871 +
872 +diff --git a/arch/powerpc/boot/dts/tqm5200.dts b/arch/powerpc/boot/dts/tqm5200.dts
873 +index 1db07f6cf133c..68b9e8240fb5b 100644
874 +--- a/arch/powerpc/boot/dts/tqm5200.dts
875 ++++ b/arch/powerpc/boot/dts/tqm5200.dts
876 +@@ -36,7 +36,7 @@
877 + };
878 + };
879 +
880 +- memory {
881 ++ memory@0 {
882 + device_type = "memory";
883 + reg = <0x00000000 0x04000000>; // 64MB
884 + };
885 +diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h
886 +index ae6d4f3a1f481..fcfefb4dda794 100644
887 +--- a/arch/powerpc/include/asm/code-patching.h
888 ++++ b/arch/powerpc/include/asm/code-patching.h
889 +@@ -25,6 +25,7 @@
890 + #define BRANCH_ABSOLUTE 0x2
891 +
892 + bool is_offset_in_branch_range(long offset);
893 ++bool is_offset_in_cond_branch_range(long offset);
894 + unsigned int create_branch(const unsigned int *addr,
895 + unsigned long target, int flags);
896 + unsigned int create_cond_branch(const unsigned int *addr,
897 +diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
898 +index c5154817178be..85f84b45d3a0a 100644
899 +--- a/arch/powerpc/lib/code-patching.c
900 ++++ b/arch/powerpc/lib/code-patching.c
901 +@@ -244,6 +244,11 @@ bool is_offset_in_branch_range(long offset)
902 + return (offset >= -0x2000000 && offset <= 0x1fffffc && !(offset & 0x3));
903 + }
904 +
905 ++bool is_offset_in_cond_branch_range(long offset)
906 ++{
907 ++ return offset >= -0x8000 && offset <= 0x7fff && !(offset & 0x3);
908 ++}
909 ++
910 + /*
911 + * Helper to check if a given instruction is a conditional branch
912 + * Derived from the conditional checks in analyse_instr()
913 +@@ -297,7 +302,7 @@ unsigned int create_cond_branch(const unsigned int *addr,
914 + offset = offset - (unsigned long)addr;
915 +
916 + /* Check we can represent the target in the instruction format */
917 +- if (offset < -0x8000 || offset > 0x7FFF || offset & 0x3)
918 ++ if (!is_offset_in_cond_branch_range(offset))
919 + return 0;
920 +
921 + /* Mask out the flags and target, so they don't step on each other. */
922 +diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
923 +index e5c1d30ee968b..5a0af7d8d2242 100644
924 +--- a/arch/powerpc/net/bpf_jit.h
925 ++++ b/arch/powerpc/net/bpf_jit.h
926 +@@ -15,6 +15,7 @@
927 + #ifndef __ASSEMBLY__
928 +
929 + #include <asm/types.h>
930 ++#include <asm/code-patching.h>
931 +
932 + #ifdef PPC64_ELF_ABI_v1
933 + #define FUNCTION_DESCR_SIZE 24
934 +@@ -176,13 +177,26 @@
935 + #define PPC_NEG(d, a) EMIT(PPC_INST_NEG | ___PPC_RT(d) | ___PPC_RA(a))
936 +
937 + /* Long jump; (unconditional 'branch') */
938 +-#define PPC_JMP(dest) EMIT(PPC_INST_BRANCH | \
939 +- (((dest) - (ctx->idx * 4)) & 0x03fffffc))
940 ++#define PPC_JMP(dest) \
941 ++ do { \
942 ++ long offset = (long)(dest) - (ctx->idx * 4); \
943 ++ if (!is_offset_in_branch_range(offset)) { \
944 ++ pr_err_ratelimited("Branch offset 0x%lx (@%u) out of range\n", offset, ctx->idx); \
945 ++ return -ERANGE; \
946 ++ } \
947 ++ EMIT(PPC_INST_BRANCH | (offset & 0x03fffffc)); \
948 ++ } while (0)
949 + /* "cond" here covers BO:BI fields. */
950 +-#define PPC_BCC_SHORT(cond, dest) EMIT(PPC_INST_BRANCH_COND | \
951 +- (((cond) & 0x3ff) << 16) | \
952 +- (((dest) - (ctx->idx * 4)) & \
953 +- 0xfffc))
954 ++#define PPC_BCC_SHORT(cond, dest) \
955 ++ do { \
956 ++ long offset = (long)(dest) - (ctx->idx * 4); \
957 ++ if (!is_offset_in_cond_branch_range(offset)) { \
958 ++ pr_err_ratelimited("Conditional branch offset 0x%lx (@%u) out of range\n", offset, ctx->idx); \
959 ++ return -ERANGE; \
960 ++ } \
961 ++ EMIT(PPC_INST_BRANCH_COND | (((cond) & 0x3ff) << 16) | (offset & 0xfffc)); \
962 ++ } while (0)
963 ++
964 + /* Sign-extended 32-bit immediate load */
965 + #define PPC_LI32(d, i) do { \
966 + if ((int)(uintptr_t)(i) >= -32768 && \
967 +@@ -221,11 +235,6 @@
968 + #define PPC_FUNC_ADDR(d,i) do { PPC_LI32(d, i); } while(0)
969 + #endif
970 +
971 +-static inline bool is_nearbranch(int offset)
972 +-{
973 +- return (offset < 32768) && (offset >= -32768);
974 +-}
975 +-
976 + /*
977 + * The fly in the ointment of code size changing from pass to pass is
978 + * avoided by padding the short branch case with a NOP. If code size differs
979 +@@ -234,7 +243,7 @@ static inline bool is_nearbranch(int offset)
980 + * state.
981 + */
982 + #define PPC_BCC(cond, dest) do { \
983 +- if (is_nearbranch((dest) - (ctx->idx * 4))) { \
984 ++ if (is_offset_in_cond_branch_range((long)(dest) - (ctx->idx * 4))) { \
985 + PPC_BCC_SHORT(cond, dest); \
986 + PPC_NOP(); \
987 + } else { \
988 +diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
989 +index b6374f6831a27..c504d5bc7d432 100644
990 +--- a/arch/powerpc/net/bpf_jit_comp64.c
991 ++++ b/arch/powerpc/net/bpf_jit_comp64.c
992 +@@ -235,7 +235,7 @@ static void bpf_jit_emit_func_call(u32 *image, struct codegen_context *ctx, u64
993 + PPC_BLRL();
994 + }
995 +
996 +-static void bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 out)
997 ++static int bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 out)
998 + {
999 + /*
1000 + * By now, the eBPF program has already setup parameters in r3, r4 and r5
1001 +@@ -296,7 +296,9 @@ static void bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32
1002 + bpf_jit_emit_common_epilogue(image, ctx);
1003 +
1004 + PPC_BCTR();
1005 ++
1006 + /* out: */
1007 ++ return 0;
1008 + }
1009 +
1010 + /* Assemble the body code between the prologue & epilogue */
1011 +@@ -306,7 +308,7 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
1012 + {
1013 + const struct bpf_insn *insn = fp->insnsi;
1014 + int flen = fp->len;
1015 +- int i;
1016 ++ int i, ret;
1017 +
1018 + /* Start of epilogue code - will only be valid 2nd pass onwards */
1019 + u32 exit_addr = addrs[flen];
1020 +@@ -357,18 +359,25 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
1021 + PPC_SUB(dst_reg, dst_reg, src_reg);
1022 + goto bpf_alu32_trunc;
1023 + case BPF_ALU | BPF_ADD | BPF_K: /* (u32) dst += (u32) imm */
1024 +- case BPF_ALU | BPF_SUB | BPF_K: /* (u32) dst -= (u32) imm */
1025 + case BPF_ALU64 | BPF_ADD | BPF_K: /* dst += imm */
1026 ++ if (!imm) {
1027 ++ goto bpf_alu32_trunc;
1028 ++ } else if (imm >= -32768 && imm < 32768) {
1029 ++ PPC_ADDI(dst_reg, dst_reg, IMM_L(imm));
1030 ++ } else {
1031 ++ PPC_LI32(b2p[TMP_REG_1], imm);
1032 ++ PPC_ADD(dst_reg, dst_reg, b2p[TMP_REG_1]);
1033 ++ }
1034 ++ goto bpf_alu32_trunc;
1035 ++ case BPF_ALU | BPF_SUB | BPF_K: /* (u32) dst -= (u32) imm */
1036 + case BPF_ALU64 | BPF_SUB | BPF_K: /* dst -= imm */
1037 +- if (BPF_OP(code) == BPF_SUB)
1038 +- imm = -imm;
1039 +- if (imm) {
1040 +- if (imm >= -32768 && imm < 32768)
1041 +- PPC_ADDI(dst_reg, dst_reg, IMM_L(imm));
1042 +- else {
1043 +- PPC_LI32(b2p[TMP_REG_1], imm);
1044 +- PPC_ADD(dst_reg, dst_reg, b2p[TMP_REG_1]);
1045 +- }
1046 ++ if (!imm) {
1047 ++ goto bpf_alu32_trunc;
1048 ++ } else if (imm > -32768 && imm <= 32768) {
1049 ++ PPC_ADDI(dst_reg, dst_reg, IMM_L(-imm));
1050 ++ } else {
1051 ++ PPC_LI32(b2p[TMP_REG_1], imm);
1052 ++ PPC_SUB(dst_reg, dst_reg, b2p[TMP_REG_1]);
1053 + }
1054 + goto bpf_alu32_trunc;
1055 + case BPF_ALU | BPF_MUL | BPF_X: /* (u32) dst *= (u32) src */
1056 +@@ -956,7 +965,9 @@ common_load:
1057 + */
1058 + case BPF_JMP | BPF_TAIL_CALL:
1059 + ctx->seen |= SEEN_TAILCALL;
1060 +- bpf_jit_emit_tail_call(image, ctx, addrs[i + 1]);
1061 ++ ret = bpf_jit_emit_tail_call(image, ctx, addrs[i + 1]);
1062 ++ if (ret < 0)
1063 ++ return ret;
1064 + break;
1065 +
1066 + default:
1067 +diff --git a/arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c b/arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c
1068 +index f05325f0cc03b..ddd2953965aa1 100644
1069 +--- a/arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c
1070 ++++ b/arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c
1071 +@@ -98,9 +98,8 @@ int __init mpc85xx_setup_pmc(void)
1072 + pr_err("Could not map guts node address\n");
1073 + return -ENOMEM;
1074 + }
1075 ++ qoriq_pm_ops = &mpc85xx_pm_ops;
1076 + }
1077 +
1078 +- qoriq_pm_ops = &mpc85xx_pm_ops;
1079 +-
1080 + return 0;
1081 + }
1082 +diff --git a/arch/powerpc/sysdev/dcr-low.S b/arch/powerpc/sysdev/dcr-low.S
1083 +index e687bb2003ff0..5589fbe48bbdc 100644
1084 +--- a/arch/powerpc/sysdev/dcr-low.S
1085 ++++ b/arch/powerpc/sysdev/dcr-low.S
1086 +@@ -15,7 +15,7 @@
1087 + #include <asm/export.h>
1088 +
1089 + #define DCR_ACCESS_PROLOG(table) \
1090 +- cmpli cr0,r3,1024; \
1091 ++ cmplwi cr0,r3,1024; \
1092 + rlwinm r3,r3,4,18,27; \
1093 + lis r5,table@h; \
1094 + ori r5,r5,table@l; \
1095 +diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
1096 +index a29d2e88b00ef..fb121440b1c87 100644
1097 +--- a/arch/s390/mm/gmap.c
1098 ++++ b/arch/s390/mm/gmap.c
1099 +@@ -665,9 +665,10 @@ void __gmap_zap(struct gmap *gmap, unsigned long gaddr)
1100 + vmaddr |= gaddr & ~PMD_MASK;
1101 + /* Get pointer to the page table entry */
1102 + ptep = get_locked_pte(gmap->mm, vmaddr, &ptl);
1103 +- if (likely(ptep))
1104 ++ if (likely(ptep)) {
1105 + ptep_zap_unused(gmap->mm, vmaddr, ptep, 0);
1106 +- pte_unmap_unlock(ptep, ptl);
1107 ++ pte_unmap_unlock(ptep, ptl);
1108 ++ }
1109 + }
1110 + }
1111 + EXPORT_SYMBOL_GPL(__gmap_zap);
1112 +diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug
1113 +index d0767672640d8..4209405179262 100644
1114 +--- a/arch/sh/Kconfig.debug
1115 ++++ b/arch/sh/Kconfig.debug
1116 +@@ -61,6 +61,7 @@ config DUMP_CODE
1117 +
1118 + config DWARF_UNWINDER
1119 + bool "Enable the DWARF unwinder for stacktraces"
1120 ++ depends on DEBUG_KERNEL
1121 + select FRAME_POINTER
1122 + depends on SUPERH32
1123 + default n
1124 +diff --git a/arch/sh/include/asm/sfp-machine.h b/arch/sh/include/asm/sfp-machine.h
1125 +index d3c548443f2a6..dd195c6f3b9d8 100644
1126 +--- a/arch/sh/include/asm/sfp-machine.h
1127 ++++ b/arch/sh/include/asm/sfp-machine.h
1128 +@@ -25,6 +25,14 @@
1129 + #ifndef _SFP_MACHINE_H
1130 + #define _SFP_MACHINE_H
1131 +
1132 ++#ifdef __BIG_ENDIAN__
1133 ++#define __BYTE_ORDER __BIG_ENDIAN
1134 ++#define __LITTLE_ENDIAN 0
1135 ++#else
1136 ++#define __BYTE_ORDER __LITTLE_ENDIAN
1137 ++#define __BIG_ENDIAN 0
1138 ++#endif
1139 ++
1140 + #define _FP_W_TYPE_SIZE 32
1141 + #define _FP_W_TYPE unsigned long
1142 + #define _FP_WS_TYPE signed long
1143 +diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
1144 +index 0d3637c494bfe..c1f66c35e0c12 100644
1145 +--- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
1146 ++++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
1147 +@@ -76,8 +76,9 @@ static void shx3_prepare_cpus(unsigned int max_cpus)
1148 + BUILD_BUG_ON(SMP_MSG_NR >= 8);
1149 +
1150 + for (i = 0; i < SMP_MSG_NR; i++)
1151 +- request_irq(104 + i, ipi_interrupt_handler,
1152 +- IRQF_PERCPU, "IPI", (void *)(long)i);
1153 ++ if (request_irq(104 + i, ipi_interrupt_handler,
1154 ++ IRQF_PERCPU, "IPI", (void *)(long)i))
1155 ++ pr_err("Failed to request irq %d\n", i);
1156 +
1157 + for (i = 0; i < max_cpus; i++)
1158 + set_cpu_present(i, true);
1159 +diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
1160 +index 6b66285c6cede..b039d416fef34 100644
1161 +--- a/arch/x86/events/intel/uncore_snbep.c
1162 ++++ b/arch/x86/events/intel/uncore_snbep.c
1163 +@@ -3383,6 +3383,9 @@ static int skx_cha_hw_config(struct intel_uncore_box *box, struct perf_event *ev
1164 + struct hw_perf_event_extra *reg1 = &event->hw.extra_reg;
1165 + struct extra_reg *er;
1166 + int idx = 0;
1167 ++ /* Any of the CHA events may be filtered by Thread/Core-ID.*/
1168 ++ if (event->hw.config & SNBEP_CBO_PMON_CTL_TID_EN)
1169 ++ idx = SKX_CHA_MSR_PMON_BOX_FILTER_TID;
1170 +
1171 + for (er = skx_uncore_cha_extra_regs; er->msr; er++) {
1172 + if (er->event != (event->hw.config & er->config_mask))
1173 +@@ -3450,6 +3453,7 @@ static struct event_constraint skx_uncore_iio_constraints[] = {
1174 + UNCORE_EVENT_CONSTRAINT(0xc0, 0xc),
1175 + UNCORE_EVENT_CONSTRAINT(0xc5, 0xc),
1176 + UNCORE_EVENT_CONSTRAINT(0xd4, 0xc),
1177 ++ UNCORE_EVENT_CONSTRAINT(0xd5, 0xc),
1178 + EVENT_CONSTRAINT_END
1179 + };
1180 +
1181 +diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
1182 +index 50c8baaca4b06..4c807635e6244 100644
1183 +--- a/arch/x86/include/asm/page_64_types.h
1184 ++++ b/arch/x86/include/asm/page_64_types.h
1185 +@@ -20,7 +20,7 @@
1186 + #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
1187 + #define CURRENT_MASK (~(THREAD_SIZE - 1))
1188 +
1189 +-#define EXCEPTION_STACK_ORDER (0 + KASAN_STACK_ORDER)
1190 ++#define EXCEPTION_STACK_ORDER (1 + KASAN_STACK_ORDER)
1191 + #define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
1192 +
1193 + #define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
1194 +diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
1195 +index 3c2326b598208..fbcc303fb1f94 100644
1196 +--- a/arch/x86/kernel/irq.c
1197 ++++ b/arch/x86/kernel/irq.c
1198 +@@ -274,8 +274,10 @@ void kvm_set_posted_intr_wakeup_handler(void (*handler)(void))
1199 + {
1200 + if (handler)
1201 + kvm_posted_intr_wakeup_handler = handler;
1202 +- else
1203 ++ else {
1204 + kvm_posted_intr_wakeup_handler = dummy_handler;
1205 ++ synchronize_rcu();
1206 ++ }
1207 + }
1208 + EXPORT_SYMBOL_GPL(kvm_set_posted_intr_wakeup_handler);
1209 +
1210 +diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
1211 +index 85082574c5154..62e11835f220e 100644
1212 +--- a/crypto/pcrypt.c
1213 ++++ b/crypto/pcrypt.c
1214 +@@ -138,12 +138,14 @@ static void pcrypt_aead_enc(struct padata_priv *padata)
1215 + {
1216 + struct pcrypt_request *preq = pcrypt_padata_request(padata);
1217 + struct aead_request *req = pcrypt_request_ctx(preq);
1218 ++ int ret;
1219 +
1220 +- padata->info = crypto_aead_encrypt(req);
1221 ++ ret = crypto_aead_encrypt(req);
1222 +
1223 +- if (padata->info == -EINPROGRESS)
1224 ++ if (ret == -EINPROGRESS)
1225 + return;
1226 +
1227 ++ padata->info = ret;
1228 + padata_do_serial(padata);
1229 + }
1230 +
1231 +@@ -180,12 +182,14 @@ static void pcrypt_aead_dec(struct padata_priv *padata)
1232 + {
1233 + struct pcrypt_request *preq = pcrypt_padata_request(padata);
1234 + struct aead_request *req = pcrypt_request_ctx(preq);
1235 ++ int ret;
1236 +
1237 +- padata->info = crypto_aead_decrypt(req);
1238 ++ ret = crypto_aead_decrypt(req);
1239 +
1240 +- if (padata->info == -EINPROGRESS)
1241 ++ if (ret == -EINPROGRESS)
1242 + return;
1243 +
1244 ++ padata->info = ret;
1245 + padata_do_serial(padata);
1246 + }
1247 +
1248 +diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
1249 +index 95eed442703f2..2f4a3fee69e70 100644
1250 +--- a/drivers/acpi/acpica/acglobal.h
1251 ++++ b/drivers/acpi/acpica/acglobal.h
1252 +@@ -255,6 +255,8 @@ extern struct acpi_bit_register_info
1253 +
1254 + ACPI_GLOBAL(u8, acpi_gbl_sleep_type_a);
1255 + ACPI_GLOBAL(u8, acpi_gbl_sleep_type_b);
1256 ++ACPI_GLOBAL(u8, acpi_gbl_sleep_type_a_s0);
1257 ++ACPI_GLOBAL(u8, acpi_gbl_sleep_type_b_s0);
1258 +
1259 + /*****************************************************************************
1260 + *
1261 +diff --git a/drivers/acpi/acpica/hwesleep.c b/drivers/acpi/acpica/hwesleep.c
1262 +index 12626d021a9b5..7f8c57177819f 100644
1263 +--- a/drivers/acpi/acpica/hwesleep.c
1264 ++++ b/drivers/acpi/acpica/hwesleep.c
1265 +@@ -181,17 +181,13 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state)
1266 +
1267 + acpi_status acpi_hw_extended_wake_prep(u8 sleep_state)
1268 + {
1269 +- acpi_status status;
1270 + u8 sleep_type_value;
1271 +
1272 + ACPI_FUNCTION_TRACE(hw_extended_wake_prep);
1273 +
1274 +- status = acpi_get_sleep_type_data(ACPI_STATE_S0,
1275 +- &acpi_gbl_sleep_type_a,
1276 +- &acpi_gbl_sleep_type_b);
1277 +- if (ACPI_SUCCESS(status)) {
1278 ++ if (acpi_gbl_sleep_type_a_s0 != ACPI_SLEEP_TYPE_INVALID) {
1279 + sleep_type_value =
1280 +- ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) &
1281 ++ ((acpi_gbl_sleep_type_a_s0 << ACPI_X_SLEEP_TYPE_POSITION) &
1282 + ACPI_X_SLEEP_TYPE_MASK);
1283 +
1284 + (void)acpi_write((u64)(sleep_type_value | ACPI_X_SLEEP_ENABLE),
1285 +diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
1286 +index 1fe7387a00e67..2c54d08b20ca6 100644
1287 +--- a/drivers/acpi/acpica/hwsleep.c
1288 ++++ b/drivers/acpi/acpica/hwsleep.c
1289 +@@ -218,7 +218,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
1290 +
1291 + acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
1292 + {
1293 +- acpi_status status;
1294 ++ acpi_status status = AE_OK;
1295 + struct acpi_bit_register_info *sleep_type_reg_info;
1296 + struct acpi_bit_register_info *sleep_enable_reg_info;
1297 + u32 pm1a_control;
1298 +@@ -231,10 +231,7 @@ acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
1299 + * This is unclear from the ACPI Spec, but it is required
1300 + * by some machines.
1301 + */
1302 +- status = acpi_get_sleep_type_data(ACPI_STATE_S0,
1303 +- &acpi_gbl_sleep_type_a,
1304 +- &acpi_gbl_sleep_type_b);
1305 +- if (ACPI_SUCCESS(status)) {
1306 ++ if (acpi_gbl_sleep_type_a_s0 != ACPI_SLEEP_TYPE_INVALID) {
1307 + sleep_type_reg_info =
1308 + acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
1309 + sleep_enable_reg_info =
1310 +@@ -255,9 +252,9 @@ acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
1311 +
1312 + /* Insert the SLP_TYP bits */
1313 +
1314 +- pm1a_control |= (acpi_gbl_sleep_type_a <<
1315 ++ pm1a_control |= (acpi_gbl_sleep_type_a_s0 <<
1316 + sleep_type_reg_info->bit_position);
1317 +- pm1b_control |= (acpi_gbl_sleep_type_b <<
1318 ++ pm1b_control |= (acpi_gbl_sleep_type_b_s0 <<
1319 + sleep_type_reg_info->bit_position);
1320 +
1321 + /* Write the control registers and ignore any errors */
1322 +diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
1323 +index e5c095ca6083a..827c3242225d9 100644
1324 +--- a/drivers/acpi/acpica/hwxfsleep.c
1325 ++++ b/drivers/acpi/acpica/hwxfsleep.c
1326 +@@ -322,6 +322,13 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
1327 + return_ACPI_STATUS(status);
1328 + }
1329 +
1330 ++ status = acpi_get_sleep_type_data(ACPI_STATE_S0,
1331 ++ &acpi_gbl_sleep_type_a_s0,
1332 ++ &acpi_gbl_sleep_type_b_s0);
1333 ++ if (ACPI_FAILURE(status)) {
1334 ++ acpi_gbl_sleep_type_a_s0 = ACPI_SLEEP_TYPE_INVALID;
1335 ++ }
1336 ++
1337 + /* Execute the _PTS method (Prepare To Sleep) */
1338 +
1339 + arg_list.count = 1;
1340 +diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
1341 +index 13e7b56e33aeb..30996effc491b 100644
1342 +--- a/drivers/acpi/battery.c
1343 ++++ b/drivers/acpi/battery.c
1344 +@@ -193,7 +193,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)
1345 + return 1;
1346 +
1347 + /* fallback to using design values for broken batteries */
1348 +- if (battery->design_capacity == battery->capacity_now)
1349 ++ if (battery->design_capacity <= battery->capacity_now)
1350 + return 1;
1351 +
1352 + /* we don't do any sort of metric based on percentages */
1353 +diff --git a/drivers/acpi/pmic/intel_pmic.c b/drivers/acpi/pmic/intel_pmic.c
1354 +index ca18e0d23df97..db63d3463617a 100644
1355 +--- a/drivers/acpi/pmic/intel_pmic.c
1356 ++++ b/drivers/acpi/pmic/intel_pmic.c
1357 +@@ -216,31 +216,36 @@ static acpi_status intel_pmic_regs_handler(u32 function,
1358 + void *handler_context, void *region_context)
1359 + {
1360 + struct intel_pmic_opregion *opregion = region_context;
1361 +- int result = 0;
1362 ++ int result = -EINVAL;
1363 ++
1364 ++ if (function == ACPI_WRITE) {
1365 ++ switch (address) {
1366 ++ case 0:
1367 ++ return AE_OK;
1368 ++ case 1:
1369 ++ opregion->ctx.addr |= (*value64 & 0xff) << 8;
1370 ++ return AE_OK;
1371 ++ case 2:
1372 ++ opregion->ctx.addr |= *value64 & 0xff;
1373 ++ return AE_OK;
1374 ++ case 3:
1375 ++ opregion->ctx.val = *value64 & 0xff;
1376 ++ return AE_OK;
1377 ++ case 4:
1378 ++ if (*value64) {
1379 ++ result = regmap_write(opregion->regmap, opregion->ctx.addr,
1380 ++ opregion->ctx.val);
1381 ++ } else {
1382 ++ result = regmap_read(opregion->regmap, opregion->ctx.addr,
1383 ++ &opregion->ctx.val);
1384 ++ }
1385 ++ opregion->ctx.addr = 0;
1386 ++ }
1387 ++ }
1388 +
1389 +- switch (address) {
1390 +- case 0:
1391 +- return AE_OK;
1392 +- case 1:
1393 +- opregion->ctx.addr |= (*value64 & 0xff) << 8;
1394 ++ if (function == ACPI_READ && address == 3) {
1395 ++ *value64 = opregion->ctx.val;
1396 + return AE_OK;
1397 +- case 2:
1398 +- opregion->ctx.addr |= *value64 & 0xff;
1399 +- return AE_OK;
1400 +- case 3:
1401 +- opregion->ctx.val = *value64 & 0xff;
1402 +- return AE_OK;
1403 +- case 4:
1404 +- if (*value64) {
1405 +- result = regmap_write(opregion->regmap, opregion->ctx.addr,
1406 +- opregion->ctx.val);
1407 +- } else {
1408 +- result = regmap_read(opregion->regmap, opregion->ctx.addr,
1409 +- &opregion->ctx.val);
1410 +- if (result == 0)
1411 +- *value64 = opregion->ctx.val;
1412 +- }
1413 +- memset(&opregion->ctx, 0x00, sizeof(opregion->ctx));
1414 + }
1415 +
1416 + if (result < 0) {
1417 +diff --git a/drivers/android/binder.c b/drivers/android/binder.c
1418 +index 0db4b56460363..c5fd7908fc913 100644
1419 +--- a/drivers/android/binder.c
1420 ++++ b/drivers/android/binder.c
1421 +@@ -484,6 +484,9 @@ enum binder_deferred_state {
1422 + * @files files_struct for process
1423 + * (protected by @files_lock)
1424 + * @files_lock mutex to protect @files
1425 ++ * @cred struct cred associated with the `struct file`
1426 ++ * in binder_open()
1427 ++ * (invariant after initialized)
1428 + * @deferred_work_node: element for binder_deferred_list
1429 + * (protected by binder_deferred_lock)
1430 + * @deferred_work: bitmap of deferred work to perform
1431 +@@ -532,6 +535,7 @@ struct binder_proc {
1432 + struct task_struct *tsk;
1433 + struct files_struct *files;
1434 + struct mutex files_lock;
1435 ++ const struct cred *cred;
1436 + struct hlist_node deferred_work_node;
1437 + int deferred_work;
1438 + bool is_dead;
1439 +@@ -2281,7 +2285,7 @@ static int binder_translate_binder(struct flat_binder_object *fp,
1440 + ret = -EINVAL;
1441 + goto done;
1442 + }
1443 +- if (security_binder_transfer_binder(proc->tsk, target_proc->tsk)) {
1444 ++ if (security_binder_transfer_binder(proc->cred, target_proc->cred)) {
1445 + ret = -EPERM;
1446 + goto done;
1447 + }
1448 +@@ -2327,7 +2331,7 @@ static int binder_translate_handle(struct flat_binder_object *fp,
1449 + proc->pid, thread->pid, fp->handle);
1450 + return -EINVAL;
1451 + }
1452 +- if (security_binder_transfer_binder(proc->tsk, target_proc->tsk)) {
1453 ++ if (security_binder_transfer_binder(proc->cred, target_proc->cred)) {
1454 + ret = -EPERM;
1455 + goto done;
1456 + }
1457 +@@ -2411,7 +2415,7 @@ static int binder_translate_fd(int fd,
1458 + ret = -EBADF;
1459 + goto err_fget;
1460 + }
1461 +- ret = security_binder_transfer_file(proc->tsk, target_proc->tsk, file);
1462 ++ ret = security_binder_transfer_file(proc->cred, target_proc->cred, file);
1463 + if (ret < 0) {
1464 + ret = -EPERM;
1465 + goto err_security;
1466 +@@ -2798,8 +2802,8 @@ static void binder_transaction(struct binder_proc *proc,
1467 + return_error_line = __LINE__;
1468 + goto err_invalid_target_handle;
1469 + }
1470 +- if (security_binder_transaction(proc->tsk,
1471 +- target_proc->tsk) < 0) {
1472 ++ if (security_binder_transaction(proc->cred,
1473 ++ target_proc->cred) < 0) {
1474 + return_error = BR_FAILED_REPLY;
1475 + return_error_param = -EPERM;
1476 + return_error_line = __LINE__;
1477 +@@ -2890,7 +2894,7 @@ static void binder_transaction(struct binder_proc *proc,
1478 + t->from = thread;
1479 + else
1480 + t->from = NULL;
1481 +- t->sender_euid = task_euid(proc->tsk);
1482 ++ t->sender_euid = proc->cred->euid;
1483 + t->to_proc = target_proc;
1484 + t->to_thread = target_thread;
1485 + t->code = tr->code;
1486 +@@ -4261,6 +4265,7 @@ static void binder_free_proc(struct binder_proc *proc)
1487 + BUG_ON(!list_empty(&proc->delivered_death));
1488 + binder_alloc_deferred_release(&proc->alloc);
1489 + put_task_struct(proc->tsk);
1490 ++ put_cred(proc->cred);
1491 + binder_stats_deleted(BINDER_STAT_PROC);
1492 + kfree(proc);
1493 + }
1494 +@@ -4464,7 +4469,7 @@ static int binder_ioctl_set_ctx_mgr(struct file *filp)
1495 + ret = -EBUSY;
1496 + goto out;
1497 + }
1498 +- ret = security_binder_set_context_mgr(proc->tsk);
1499 ++ ret = security_binder_set_context_mgr(proc->cred);
1500 + if (ret < 0)
1501 + goto out;
1502 + if (uid_valid(context->binder_context_mgr_uid)) {
1503 +@@ -4717,6 +4722,7 @@ static int binder_open(struct inode *nodp, struct file *filp)
1504 + get_task_struct(current->group_leader);
1505 + proc->tsk = current->group_leader;
1506 + mutex_init(&proc->files_lock);
1507 ++ proc->cred = get_cred(filp->f_cred);
1508 + INIT_LIST_HEAD(&proc->todo);
1509 + proc->default_priority = task_nice(current);
1510 + binder_dev = container_of(filp->private_data, struct binder_device,
1511 +diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
1512 +index 61dbe6fc29b91..2ae72f31cbe3c 100644
1513 +--- a/drivers/ata/libata-core.c
1514 ++++ b/drivers/ata/libata-core.c
1515 +@@ -2081,7 +2081,7 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
1516 +
1517 + retry:
1518 + ata_tf_init(dev, &tf);
1519 +- if (dev->dma_mode && ata_id_has_read_log_dma_ext(dev->id) &&
1520 ++ if (ata_dma_enabled(dev) && ata_id_has_read_log_dma_ext(dev->id) &&
1521 + !(dev->horkage & ATA_HORKAGE_NO_DMA_LOG)) {
1522 + tf.command = ATA_CMD_READ_LOG_DMA_EXT;
1523 + tf.protocol = ATA_PROT_DMA;
1524 +diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
1525 +index c398be4b17971..88a74ba4bd6ee 100644
1526 +--- a/drivers/ata/libata-eh.c
1527 ++++ b/drivers/ata/libata-eh.c
1528 +@@ -114,6 +114,12 @@ static const unsigned long ata_eh_identify_timeouts[] = {
1529 + ULONG_MAX,
1530 + };
1531 +
1532 ++static const unsigned long ata_eh_revalidate_timeouts[] = {
1533 ++ 15000, /* Some drives are slow to read log pages when waking-up */
1534 ++ 15000, /* combined time till here is enough even for media access */
1535 ++ ULONG_MAX,
1536 ++};
1537 ++
1538 + static const unsigned long ata_eh_flush_timeouts[] = {
1539 + 15000, /* be generous with flush */
1540 + 15000, /* ditto */
1541 +@@ -150,6 +156,8 @@ static const struct ata_eh_cmd_timeout_ent
1542 + ata_eh_cmd_timeout_table[ATA_EH_CMD_TIMEOUT_TABLE_SIZE] = {
1543 + { .commands = CMDS(ATA_CMD_ID_ATA, ATA_CMD_ID_ATAPI),
1544 + .timeouts = ata_eh_identify_timeouts, },
1545 ++ { .commands = CMDS(ATA_CMD_READ_LOG_EXT, ATA_CMD_READ_LOG_DMA_EXT),
1546 ++ .timeouts = ata_eh_revalidate_timeouts, },
1547 + { .commands = CMDS(ATA_CMD_READ_NATIVE_MAX, ATA_CMD_READ_NATIVE_MAX_EXT),
1548 + .timeouts = ata_eh_other_timeouts, },
1549 + { .commands = CMDS(ATA_CMD_SET_MAX, ATA_CMD_SET_MAX_EXT),
1550 +diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c
1551 +index eec69213dad4f..f35b7ff29efd2 100644
1552 +--- a/drivers/auxdisplay/ht16k33.c
1553 ++++ b/drivers/auxdisplay/ht16k33.c
1554 +@@ -227,6 +227,15 @@ static const struct backlight_ops ht16k33_bl_ops = {
1555 + .check_fb = ht16k33_bl_check_fb,
1556 + };
1557 +
1558 ++/*
1559 ++ * Blank events will be passed to the actual device handling the backlight when
1560 ++ * we return zero here.
1561 ++ */
1562 ++static int ht16k33_blank(int blank, struct fb_info *info)
1563 ++{
1564 ++ return 0;
1565 ++}
1566 ++
1567 + static int ht16k33_mmap(struct fb_info *info, struct vm_area_struct *vma)
1568 + {
1569 + struct ht16k33_priv *priv = info->par;
1570 +@@ -239,6 +248,7 @@ static struct fb_ops ht16k33_fb_ops = {
1571 + .owner = THIS_MODULE,
1572 + .fb_read = fb_sys_read,
1573 + .fb_write = fb_sys_write,
1574 ++ .fb_blank = ht16k33_blank,
1575 + .fb_fillrect = sys_fillrect,
1576 + .fb_copyarea = sys_copyarea,
1577 + .fb_imageblit = sys_imageblit,
1578 +@@ -426,6 +436,33 @@ static int ht16k33_probe(struct i2c_client *client,
1579 + if (err)
1580 + return err;
1581 +
1582 ++ /* Backlight */
1583 ++ memset(&bl_props, 0, sizeof(struct backlight_properties));
1584 ++ bl_props.type = BACKLIGHT_RAW;
1585 ++ bl_props.max_brightness = MAX_BRIGHTNESS;
1586 ++
1587 ++ bl = devm_backlight_device_register(&client->dev, DRIVER_NAME"-bl",
1588 ++ &client->dev, priv,
1589 ++ &ht16k33_bl_ops, &bl_props);
1590 ++ if (IS_ERR(bl)) {
1591 ++ dev_err(&client->dev, "failed to register backlight\n");
1592 ++ return PTR_ERR(bl);
1593 ++ }
1594 ++
1595 ++ err = of_property_read_u32(node, "default-brightness-level",
1596 ++ &dft_brightness);
1597 ++ if (err) {
1598 ++ dft_brightness = MAX_BRIGHTNESS;
1599 ++ } else if (dft_brightness > MAX_BRIGHTNESS) {
1600 ++ dev_warn(&client->dev,
1601 ++ "invalid default brightness level: %u, using %u\n",
1602 ++ dft_brightness, MAX_BRIGHTNESS);
1603 ++ dft_brightness = MAX_BRIGHTNESS;
1604 ++ }
1605 ++
1606 ++ bl->props.brightness = dft_brightness;
1607 ++ ht16k33_bl_update_status(bl);
1608 ++
1609 + /* Framebuffer (2 bytes per column) */
1610 + BUILD_BUG_ON(PAGE_SIZE < HT16K33_FB_SIZE);
1611 + fbdev->buffer = (unsigned char *) get_zeroed_page(GFP_KERNEL);
1612 +@@ -458,6 +495,7 @@ static int ht16k33_probe(struct i2c_client *client,
1613 + fbdev->info->screen_size = HT16K33_FB_SIZE;
1614 + fbdev->info->fix = ht16k33_fb_fix;
1615 + fbdev->info->var = ht16k33_fb_var;
1616 ++ fbdev->info->bl_dev = bl;
1617 + fbdev->info->pseudo_palette = NULL;
1618 + fbdev->info->flags = FBINFO_FLAG_DEFAULT;
1619 + fbdev->info->par = priv;
1620 +@@ -470,34 +508,6 @@ static int ht16k33_probe(struct i2c_client *client,
1621 + if (err)
1622 + goto err_fbdev_unregister;
1623 +
1624 +- /* Backlight */
1625 +- memset(&bl_props, 0, sizeof(struct backlight_properties));
1626 +- bl_props.type = BACKLIGHT_RAW;
1627 +- bl_props.max_brightness = MAX_BRIGHTNESS;
1628 +-
1629 +- bl = devm_backlight_device_register(&client->dev, DRIVER_NAME"-bl",
1630 +- &client->dev, priv,
1631 +- &ht16k33_bl_ops, &bl_props);
1632 +- if (IS_ERR(bl)) {
1633 +- dev_err(&client->dev, "failed to register backlight\n");
1634 +- err = PTR_ERR(bl);
1635 +- goto err_fbdev_unregister;
1636 +- }
1637 +-
1638 +- err = of_property_read_u32(node, "default-brightness-level",
1639 +- &dft_brightness);
1640 +- if (err) {
1641 +- dft_brightness = MAX_BRIGHTNESS;
1642 +- } else if (dft_brightness > MAX_BRIGHTNESS) {
1643 +- dev_warn(&client->dev,
1644 +- "invalid default brightness level: %u, using %u\n",
1645 +- dft_brightness, MAX_BRIGHTNESS);
1646 +- dft_brightness = MAX_BRIGHTNESS;
1647 +- }
1648 +-
1649 +- bl->props.brightness = dft_brightness;
1650 +- ht16k33_bl_update_status(bl);
1651 +-
1652 + ht16k33_fb_queue(priv);
1653 + return 0;
1654 +
1655 +diff --git a/drivers/auxdisplay/img-ascii-lcd.c b/drivers/auxdisplay/img-ascii-lcd.c
1656 +index 58403052514f0..4d57185037a0d 100644
1657 +--- a/drivers/auxdisplay/img-ascii-lcd.c
1658 ++++ b/drivers/auxdisplay/img-ascii-lcd.c
1659 +@@ -284,6 +284,16 @@ static int img_ascii_lcd_display(struct img_ascii_lcd_ctx *ctx,
1660 + if (msg[count - 1] == '\n')
1661 + count--;
1662 +
1663 ++ if (!count) {
1664 ++ /* clear the LCD */
1665 ++ devm_kfree(&ctx->pdev->dev, ctx->message);
1666 ++ ctx->message = NULL;
1667 ++ ctx->message_len = 0;
1668 ++ memset(ctx->curr, ' ', ctx->cfg->num_chars);
1669 ++ ctx->cfg->update(ctx);
1670 ++ return 0;
1671 ++ }
1672 ++
1673 + new_msg = devm_kmalloc(&ctx->pdev->dev, count + 1, GFP_KERNEL);
1674 + if (!new_msg)
1675 + return -ENOMEM;
1676 +diff --git a/drivers/char/hw_random/mtk-rng.c b/drivers/char/hw_random/mtk-rng.c
1677 +index 8da7bcf54105f..41f7d893dfef2 100644
1678 +--- a/drivers/char/hw_random/mtk-rng.c
1679 ++++ b/drivers/char/hw_random/mtk-rng.c
1680 +@@ -181,8 +181,13 @@ static int mtk_rng_runtime_resume(struct device *dev)
1681 + return mtk_rng_init(&priv->rng);
1682 + }
1683 +
1684 +-static UNIVERSAL_DEV_PM_OPS(mtk_rng_pm_ops, mtk_rng_runtime_suspend,
1685 +- mtk_rng_runtime_resume, NULL);
1686 ++static const struct dev_pm_ops mtk_rng_pm_ops = {
1687 ++ SET_RUNTIME_PM_OPS(mtk_rng_runtime_suspend,
1688 ++ mtk_rng_runtime_resume, NULL)
1689 ++ SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
1690 ++ pm_runtime_force_resume)
1691 ++};
1692 ++
1693 + #define MTK_RNG_PM_OPS (&mtk_rng_pm_ops)
1694 + #else /* CONFIG_PM */
1695 + #define MTK_RNG_PM_OPS NULL
1696 +diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
1697 +index 115f0fb32179f..c7763a96cbaf3 100644
1698 +--- a/drivers/char/tpm/tpm2-space.c
1699 ++++ b/drivers/char/tpm/tpm2-space.c
1700 +@@ -422,6 +422,9 @@ static int tpm2_map_response_body(struct tpm_chip *chip, u32 cc, u8 *rsp,
1701 + if (be32_to_cpu(data->capability) != TPM2_CAP_HANDLES)
1702 + return 0;
1703 +
1704 ++ if (be32_to_cpu(data->count) > (UINT_MAX - TPM_HEADER_SIZE - 9) / 4)
1705 ++ return -EFAULT;
1706 ++
1707 + if (len != TPM_HEADER_SIZE + 9 + 4 * be32_to_cpu(data->count))
1708 + return -EFAULT;
1709 +
1710 +diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
1711 +index 909bd2255978b..a29d7a6e68487 100644
1712 +--- a/drivers/cpuidle/sysfs.c
1713 ++++ b/drivers/cpuidle/sysfs.c
1714 +@@ -415,6 +415,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device)
1715 + &kdev->kobj, "state%d", i);
1716 + if (ret) {
1717 + kobject_put(&kobj->kobj);
1718 ++ kfree(kobj);
1719 + goto error_state;
1720 + }
1721 + kobject_uevent(&kobj->kobj, KOBJ_ADD);
1722 +@@ -545,6 +546,7 @@ static int cpuidle_add_driver_sysfs(struct cpuidle_device *dev)
1723 + &kdev->kobj, "driver");
1724 + if (ret) {
1725 + kobject_put(&kdrv->kobj);
1726 ++ kfree(kdrv);
1727 + return ret;
1728 + }
1729 +
1730 +@@ -631,7 +633,6 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
1731 + if (!kdev)
1732 + return -ENOMEM;
1733 + kdev->dev = dev;
1734 +- dev->kobj_dev = kdev;
1735 +
1736 + init_completion(&kdev->kobj_unregister);
1737 +
1738 +@@ -639,9 +640,11 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
1739 + "cpuidle");
1740 + if (error) {
1741 + kobject_put(&kdev->kobj);
1742 ++ kfree(kdev);
1743 + return error;
1744 + }
1745 +
1746 ++ dev->kobj_dev = kdev;
1747 + kobject_uevent(&kdev->kobj, KOBJ_ADD);
1748 +
1749 + return 0;
1750 +diff --git a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
1751 +index c64481160b711..180016e157771 100644
1752 +--- a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
1753 ++++ b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
1754 +@@ -195,6 +195,13 @@ static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
1755 + val = ADF_CSR_RD(pmisc_bar_addr, pf2vf_offset);
1756 + } while ((val & int_bit) && (count++ < ADF_IOV_MSG_ACK_MAX_RETRY));
1757 +
1758 ++ if (val != msg) {
1759 ++ dev_dbg(&GET_DEV(accel_dev),
1760 ++ "Collision - PFVF CSR overwritten by remote function\n");
1761 ++ ret = -EIO;
1762 ++ goto out;
1763 ++ }
1764 ++
1765 + if (val & int_bit) {
1766 + dev_dbg(&GET_DEV(accel_dev), "ACK not received from remote\n");
1767 + val &= ~int_bit;
1768 +@@ -243,6 +250,11 @@ void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)
1769 +
1770 + /* Read message from the VF */
1771 + msg = ADF_CSR_RD(pmisc_addr, hw_data->get_pf2vf_offset(vf_nr));
1772 ++ if (!(msg & ADF_VF2PF_INT)) {
1773 ++ dev_info(&GET_DEV(accel_dev),
1774 ++ "Spurious VF2PF interrupt, msg %X. Ignored\n", msg);
1775 ++ goto out;
1776 ++ }
1777 +
1778 + /* To ACK, clear the VF2PFINT bit */
1779 + msg &= ~ADF_VF2PF_INT;
1780 +@@ -326,6 +338,7 @@ void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)
1781 + if (resp && adf_iov_putmsg(accel_dev, resp, vf_nr))
1782 + dev_err(&GET_DEV(accel_dev), "Failed to send response to VF\n");
1783 +
1784 ++out:
1785 + /* re-enable interrupt on PF from this VF */
1786 + adf_enable_vf2pf_interrupts(accel_dev, (1 << vf_nr));
1787 + return;
1788 +diff --git a/drivers/crypto/qat/qat_common/adf_vf_isr.c b/drivers/crypto/qat/qat_common/adf_vf_isr.c
1789 +index ef90902c8200d..86274e3c6781d 100644
1790 +--- a/drivers/crypto/qat/qat_common/adf_vf_isr.c
1791 ++++ b/drivers/crypto/qat/qat_common/adf_vf_isr.c
1792 +@@ -123,6 +123,11 @@ static void adf_pf2vf_bh_handler(void *data)
1793 +
1794 + /* Read the message from PF */
1795 + msg = ADF_CSR_RD(pmisc_bar_addr, hw_data->get_pf2vf_offset(0));
1796 ++ if (!(msg & ADF_PF2VF_INT)) {
1797 ++ dev_info(&GET_DEV(accel_dev),
1798 ++ "Spurious PF2VF interrupt, msg %X. Ignored\n", msg);
1799 ++ goto out;
1800 ++ }
1801 +
1802 + if (!(msg & ADF_PF2VF_MSGORIGIN_SYSTEM))
1803 + /* Ignore legacy non-system (non-kernel) PF2VF messages */
1804 +@@ -171,6 +176,7 @@ static void adf_pf2vf_bh_handler(void *data)
1805 + msg &= ~ADF_PF2VF_INT;
1806 + ADF_CSR_WR(pmisc_bar_addr, hw_data->get_pf2vf_offset(0), msg);
1807 +
1808 ++out:
1809 + /* Re-enable PF2VF interrupts */
1810 + adf_enable_pf2vf_interrupts(accel_dev);
1811 + return;
1812 +diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
1813 +index 22764cd30cc39..8c2da523a8ff6 100644
1814 +--- a/drivers/dma/at_xdmac.c
1815 ++++ b/drivers/dma/at_xdmac.c
1816 +@@ -156,7 +156,7 @@
1817 + #define AT_XDMAC_CC_WRIP (0x1 << 23) /* Write in Progress (read only) */
1818 + #define AT_XDMAC_CC_WRIP_DONE (0x0 << 23)
1819 + #define AT_XDMAC_CC_WRIP_IN_PROGRESS (0x1 << 23)
1820 +-#define AT_XDMAC_CC_PERID(i) (0x7f & (i) << 24) /* Channel Peripheral Identifier */
1821 ++#define AT_XDMAC_CC_PERID(i) ((0x7f & (i)) << 24) /* Channel Peripheral Identifier */
1822 + #define AT_XDMAC_CDS_MSP 0x2C /* Channel Data Stride Memory Set Pattern */
1823 + #define AT_XDMAC_CSUS 0x30 /* Channel Source Microblock Stride */
1824 + #define AT_XDMAC_CDUS 0x34 /* Channel Destination Microblock Stride */
1825 +diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h
1826 +index 501c0b063f852..302f13efd35d9 100644
1827 +--- a/drivers/dma/dmaengine.h
1828 ++++ b/drivers/dma/dmaengine.h
1829 +@@ -168,7 +168,7 @@ dmaengine_desc_get_callback_invoke(struct dma_async_tx_descriptor *tx,
1830 + static inline bool
1831 + dmaengine_desc_callback_valid(struct dmaengine_desc_callback *cb)
1832 + {
1833 +- return (cb->callback) ? true : false;
1834 ++ return cb->callback || cb->callback_result;
1835 + }
1836 +
1837 + #endif
1838 +diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
1839 +index ddd5990211f8a..3dcc075813e72 100644
1840 +--- a/drivers/edac/sb_edac.c
1841 ++++ b/drivers/edac/sb_edac.c
1842 +@@ -1014,7 +1014,7 @@ static u64 haswell_get_tohm(struct sbridge_pvt *pvt)
1843 + pci_read_config_dword(pvt->info.pci_vtd, HASWELL_TOHM_1, &reg);
1844 + rc = ((reg << 6) | rc) << 26;
1845 +
1846 +- return rc | 0x1ffffff;
1847 ++ return rc | 0x3ffffff;
1848 + }
1849 +
1850 + static u64 knl_get_tolm(struct sbridge_pvt *pvt)
1851 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1852 +index 3992e1cbb61ca..54f414279037e 100644
1853 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1854 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1855 +@@ -844,6 +844,7 @@ static int amdgpu_connector_vga_get_modes(struct drm_connector *connector)
1856 +
1857 + amdgpu_connector_get_edid(connector);
1858 + ret = amdgpu_connector_ddc_get_modes(connector);
1859 ++ amdgpu_get_native_mode(connector);
1860 +
1861 + return ret;
1862 + }
1863 +diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
1864 +index 06aee1741e96a..6d57bc01b531f 100644
1865 +--- a/drivers/gpu/drm/drm_plane_helper.c
1866 ++++ b/drivers/gpu/drm/drm_plane_helper.c
1867 +@@ -243,7 +243,6 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
1868 + .crtc_w = drm_rect_width(dst),
1869 + .crtc_h = drm_rect_height(dst),
1870 + .rotation = rotation,
1871 +- .visible = *visible,
1872 + };
1873 + int ret;
1874 +
1875 +diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
1876 +index b9403851f37f3..072a5f150dd61 100644
1877 +--- a/drivers/gpu/drm/msm/msm_gem.c
1878 ++++ b/drivers/gpu/drm/msm/msm_gem.c
1879 +@@ -959,7 +959,7 @@ static struct drm_gem_object *_msm_gem_new(struct drm_device *dev,
1880 +
1881 + ret = msm_gem_new_impl(dev, size, flags, NULL, &obj, struct_mutex_locked);
1882 + if (ret)
1883 +- goto fail;
1884 ++ return ERR_PTR(ret);
1885 +
1886 + if (use_vram) {
1887 + struct msm_gem_vma *vma;
1888 +@@ -1029,7 +1029,7 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,
1889 +
1890 + ret = msm_gem_new_impl(dev, size, MSM_BO_WC, dmabuf->resv, &obj, false);
1891 + if (ret)
1892 +- goto fail;
1893 ++ return ERR_PTR(ret);
1894 +
1895 + drm_gem_private_object_init(dev, obj, size);
1896 +
1897 +diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
1898 +index 9f9a49748d176..4588e773469d5 100644
1899 +--- a/drivers/gpu/drm/udl/udl_connector.c
1900 ++++ b/drivers/gpu/drm/udl/udl_connector.c
1901 +@@ -37,7 +37,7 @@ static u8 *udl_get_edid(struct udl_device *udl)
1902 + ret = usb_control_msg(udl->udev,
1903 + usb_rcvctrlpipe(udl->udev, 0), (0x02),
1904 + (0x80 | (0x02 << 5)), i << 8, 0xA1, rbuf, 2,
1905 +- HZ);
1906 ++ 1000);
1907 + if (ret < 1) {
1908 + DRM_ERROR("Read EDID byte %d failed err %x\n", i, ret);
1909 + goto error;
1910 +diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
1911 +index a166de6efd99c..0996a246c80bb 100644
1912 +--- a/drivers/hv/hyperv_vmbus.h
1913 ++++ b/drivers/hv/hyperv_vmbus.h
1914 +@@ -26,6 +26,7 @@
1915 + #define _HYPERV_VMBUS_H
1916 +
1917 + #include <linux/list.h>
1918 ++#include <linux/bitops.h>
1919 + #include <asm/sync_bitops.h>
1920 + #include <linux/atomic.h>
1921 + #include <linux/hyperv.h>
1922 +diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
1923 +index 652973d83a07e..b1b5c1e97a430 100644
1924 +--- a/drivers/hwmon/hwmon.c
1925 ++++ b/drivers/hwmon/hwmon.c
1926 +@@ -627,8 +627,10 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
1927 + dev_set_drvdata(hdev, drvdata);
1928 + dev_set_name(hdev, HWMON_ID_FORMAT, id);
1929 + err = device_register(hdev);
1930 +- if (err)
1931 +- goto free_hwmon;
1932 ++ if (err) {
1933 ++ put_device(hdev);
1934 ++ goto ida_remove;
1935 ++ }
1936 +
1937 + if (dev && dev->of_node && chip && chip->ops->read &&
1938 + chip->info[0]->type == hwmon_chip &&
1939 +diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
1940 +index 10d17fb8f2836..ac2dd6cef0662 100644
1941 +--- a/drivers/hwmon/pmbus/lm25066.c
1942 ++++ b/drivers/hwmon/pmbus/lm25066.c
1943 +@@ -69,22 +69,27 @@ static struct __coeff lm25066_coeff[6][PSC_NUM_CLASSES + 2] = {
1944 + [lm25056] = {
1945 + [PSC_VOLTAGE_IN] = {
1946 + .m = 16296,
1947 ++ .b = 1343,
1948 + .R = -2,
1949 + },
1950 + [PSC_CURRENT_IN] = {
1951 + .m = 13797,
1952 ++ .b = -1833,
1953 + .R = -2,
1954 + },
1955 + [PSC_CURRENT_IN_L] = {
1956 + .m = 6726,
1957 ++ .b = -537,
1958 + .R = -2,
1959 + },
1960 + [PSC_POWER] = {
1961 + .m = 5501,
1962 ++ .b = -2908,
1963 + .R = -3,
1964 + },
1965 + [PSC_POWER_L] = {
1966 + .m = 26882,
1967 ++ .b = -5646,
1968 + .R = -4,
1969 + },
1970 + [PSC_TEMPERATURE] = {
1971 +@@ -96,26 +101,32 @@ static struct __coeff lm25066_coeff[6][PSC_NUM_CLASSES + 2] = {
1972 + [lm25066] = {
1973 + [PSC_VOLTAGE_IN] = {
1974 + .m = 22070,
1975 ++ .b = -1800,
1976 + .R = -2,
1977 + },
1978 + [PSC_VOLTAGE_OUT] = {
1979 + .m = 22070,
1980 ++ .b = -1800,
1981 + .R = -2,
1982 + },
1983 + [PSC_CURRENT_IN] = {
1984 + .m = 13661,
1985 ++ .b = -5200,
1986 + .R = -2,
1987 + },
1988 + [PSC_CURRENT_IN_L] = {
1989 + .m = 6852,
1990 ++ .b = -3100,
1991 + .R = -2,
1992 + },
1993 + [PSC_POWER] = {
1994 + .m = 736,
1995 ++ .b = -3300,
1996 + .R = -2,
1997 + },
1998 + [PSC_POWER_L] = {
1999 + .m = 369,
2000 ++ .b = -1900,
2001 + .R = -2,
2002 + },
2003 + [PSC_TEMPERATURE] = {
2004 +@@ -155,26 +166,32 @@ static struct __coeff lm25066_coeff[6][PSC_NUM_CLASSES + 2] = {
2005 + [lm5064] = {
2006 + [PSC_VOLTAGE_IN] = {
2007 + .m = 4611,
2008 ++ .b = -642,
2009 + .R = -2,
2010 + },
2011 + [PSC_VOLTAGE_OUT] = {
2012 + .m = 4621,
2013 ++ .b = 423,
2014 + .R = -2,
2015 + },
2016 + [PSC_CURRENT_IN] = {
2017 + .m = 10742,
2018 ++ .b = 1552,
2019 + .R = -2,
2020 + },
2021 + [PSC_CURRENT_IN_L] = {
2022 + .m = 5456,
2023 ++ .b = 2118,
2024 + .R = -2,
2025 + },
2026 + [PSC_POWER] = {
2027 + .m = 1204,
2028 ++ .b = 8524,
2029 + .R = -3,
2030 + },
2031 + [PSC_POWER_L] = {
2032 + .m = 612,
2033 ++ .b = 11202,
2034 + .R = -3,
2035 + },
2036 + [PSC_TEMPERATURE] = {
2037 +@@ -184,26 +201,32 @@ static struct __coeff lm25066_coeff[6][PSC_NUM_CLASSES + 2] = {
2038 + [lm5066] = {
2039 + [PSC_VOLTAGE_IN] = {
2040 + .m = 4587,
2041 ++ .b = -1200,
2042 + .R = -2,
2043 + },
2044 + [PSC_VOLTAGE_OUT] = {
2045 + .m = 4587,
2046 ++ .b = -2400,
2047 + .R = -2,
2048 + },
2049 + [PSC_CURRENT_IN] = {
2050 + .m = 10753,
2051 ++ .b = -1200,
2052 + .R = -2,
2053 + },
2054 + [PSC_CURRENT_IN_L] = {
2055 + .m = 5405,
2056 ++ .b = -600,
2057 + .R = -2,
2058 + },
2059 + [PSC_POWER] = {
2060 + .m = 1204,
2061 ++ .b = -6000,
2062 + .R = -3,
2063 + },
2064 + [PSC_POWER_L] = {
2065 + .m = 605,
2066 ++ .b = -8000,
2067 + .R = -3,
2068 + },
2069 + [PSC_TEMPERATURE] = {
2070 +diff --git a/drivers/i2c/busses/i2c-xlr.c b/drivers/i2c/busses/i2c-xlr.c
2071 +index 484bfa15d58ee..dc9e20941efd1 100644
2072 +--- a/drivers/i2c/busses/i2c-xlr.c
2073 ++++ b/drivers/i2c/busses/i2c-xlr.c
2074 +@@ -434,11 +434,15 @@ static int xlr_i2c_probe(struct platform_device *pdev)
2075 + i2c_set_adapdata(&priv->adap, priv);
2076 + ret = i2c_add_numbered_adapter(&priv->adap);
2077 + if (ret < 0)
2078 +- return ret;
2079 ++ goto err_unprepare_clk;
2080 +
2081 + platform_set_drvdata(pdev, priv);
2082 + dev_info(&priv->adap.dev, "Added I2C Bus.\n");
2083 + return 0;
2084 ++
2085 ++err_unprepare_clk:
2086 ++ clk_unprepare(clk);
2087 ++ return ret;
2088 + }
2089 +
2090 + static int xlr_i2c_remove(struct platform_device *pdev)
2091 +diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c
2092 +index b555552a0d803..d3a3d62869d83 100644
2093 +--- a/drivers/iio/dac/ad5446.c
2094 ++++ b/drivers/iio/dac/ad5446.c
2095 +@@ -510,8 +510,15 @@ static int ad5622_write(struct ad5446_state *st, unsigned val)
2096 + {
2097 + struct i2c_client *client = to_i2c_client(st->dev);
2098 + __be16 data = cpu_to_be16(val);
2099 ++ int ret;
2100 ++
2101 ++ ret = i2c_master_send(client, (char *)&data, sizeof(data));
2102 ++ if (ret < 0)
2103 ++ return ret;
2104 ++ if (ret != sizeof(data))
2105 ++ return -EIO;
2106 +
2107 +- return i2c_master_send(client, (char *)&data, sizeof(data));
2108 ++ return 0;
2109 + }
2110 +
2111 + /**
2112 +diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
2113 +index df1ecd29057f8..8862eb9a6fe43 100644
2114 +--- a/drivers/infiniband/hw/mlx4/qp.c
2115 ++++ b/drivers/infiniband/hw/mlx4/qp.c
2116 +@@ -1144,8 +1144,10 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
2117 + if (dev->steering_support ==
2118 + MLX4_STEERING_MODE_DEVICE_MANAGED)
2119 + qp->flags |= MLX4_IB_QP_NETIF;
2120 +- else
2121 ++ else {
2122 ++ err = -EINVAL;
2123 + goto err;
2124 ++ }
2125 + }
2126 +
2127 + memcpy(&backup_cap, &init_attr->cap, sizeof(backup_cap));
2128 +diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
2129 +index 6ae72accae3db..990e652cb4ca2 100644
2130 +--- a/drivers/infiniband/hw/qedr/verbs.c
2131 ++++ b/drivers/infiniband/hw/qedr/verbs.c
2132 +@@ -2045,15 +2045,18 @@ int qedr_query_qp(struct ib_qp *ibqp,
2133 + int rc = 0;
2134 +
2135 + memset(&params, 0, sizeof(params));
2136 +-
2137 +- rc = dev->ops->rdma_query_qp(dev->rdma_ctx, qp->qed_qp, &params);
2138 +- if (rc)
2139 +- goto err;
2140 +-
2141 + memset(qp_attr, 0, sizeof(*qp_attr));
2142 + memset(qp_init_attr, 0, sizeof(*qp_init_attr));
2143 +
2144 +- qp_attr->qp_state = qedr_get_ibqp_state(params.state);
2145 ++ if (qp->qp_type != IB_QPT_GSI) {
2146 ++ rc = dev->ops->rdma_query_qp(dev->rdma_ctx, qp->qed_qp, &params);
2147 ++ if (rc)
2148 ++ goto err;
2149 ++ qp_attr->qp_state = qedr_get_ibqp_state(params.state);
2150 ++ } else {
2151 ++ qp_attr->qp_state = qedr_get_ibqp_state(QED_ROCE_QP_STATE_RTS);
2152 ++ }
2153 ++
2154 + qp_attr->cur_qp_state = qedr_get_ibqp_state(params.state);
2155 + qp_attr->path_mtu = ib_mtu_int_to_enum(params.mtu);
2156 + qp_attr->path_mig_state = IB_MIG_MIGRATED;
2157 +diff --git a/drivers/infiniband/sw/rxe/rxe_param.h b/drivers/infiniband/sw/rxe/rxe_param.h
2158 +index 1b596fbbe2516..77ac3fa756c25 100644
2159 +--- a/drivers/infiniband/sw/rxe/rxe_param.h
2160 ++++ b/drivers/infiniband/sw/rxe/rxe_param.h
2161 +@@ -143,7 +143,7 @@ enum rxe_port_param {
2162 + RXE_PORT_MAX_MTU = IB_MTU_4096,
2163 + RXE_PORT_ACTIVE_MTU = IB_MTU_256,
2164 + RXE_PORT_GID_TBL_LEN = 1024,
2165 +- RXE_PORT_PORT_CAP_FLAGS = RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP,
2166 ++ RXE_PORT_PORT_CAP_FLAGS = IB_PORT_CM_SUP,
2167 + RXE_PORT_MAX_MSG_SZ = 0x800000,
2168 + RXE_PORT_BAD_PKEY_CNTR = 0,
2169 + RXE_PORT_QKEY_VIOL_CNTR = 0,
2170 +diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
2171 +index ab4888d043f0c..b27a91fee7f76 100644
2172 +--- a/drivers/input/mouse/elantech.c
2173 ++++ b/drivers/input/mouse/elantech.c
2174 +@@ -431,6 +431,19 @@ static void elantech_report_trackpoint(struct psmouse *psmouse,
2175 + case 0x16008020U:
2176 + case 0x26800010U:
2177 + case 0x36808000U:
2178 ++
2179 ++ /*
2180 ++ * This firmware misreport coordinates for trackpoint
2181 ++ * occasionally. Discard packets outside of [-127, 127] range
2182 ++ * to prevent cursor jumps.
2183 ++ */
2184 ++ if (packet[4] == 0x80 || packet[5] == 0x80 ||
2185 ++ packet[1] >> 7 == packet[4] >> 7 ||
2186 ++ packet[2] >> 7 == packet[5] >> 7) {
2187 ++ elantech_debug("discarding packet [%6ph]\n", packet);
2188 ++ break;
2189 ++
2190 ++ }
2191 + x = packet[4] - (int)((packet[1]^0x80) << 1);
2192 + y = (int)((packet[2]^0x80) << 1) - packet[5];
2193 +
2194 +diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
2195 +index f20e54f41dde9..c218e107c0c8f 100644
2196 +--- a/drivers/input/serio/i8042-x86ia64io.h
2197 ++++ b/drivers/input/serio/i8042-x86ia64io.h
2198 +@@ -276,6 +276,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
2199 + DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
2200 + },
2201 + },
2202 ++ {
2203 ++ /* Fujitsu Lifebook T725 laptop */
2204 ++ .matches = {
2205 ++ DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
2206 ++ DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T725"),
2207 ++ },
2208 ++ },
2209 + {
2210 + /* Fujitsu Lifebook U745 */
2211 + .matches = {
2212 +@@ -844,6 +851,13 @@ static const struct dmi_system_id __initconst i8042_dmi_notimeout_table[] = {
2213 + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK AH544"),
2214 + },
2215 + },
2216 ++ {
2217 ++ /* Fujitsu Lifebook T725 laptop */
2218 ++ .matches = {
2219 ++ DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
2220 ++ DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T725"),
2221 ++ },
2222 ++ },
2223 + {
2224 + /* Fujitsu U574 laptop */
2225 + /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
2226 +diff --git a/drivers/irqchip/irq-bcm6345-l1.c b/drivers/irqchip/irq-bcm6345-l1.c
2227 +index 43f8abe40878a..31ea6332ecb83 100644
2228 +--- a/drivers/irqchip/irq-bcm6345-l1.c
2229 ++++ b/drivers/irqchip/irq-bcm6345-l1.c
2230 +@@ -143,7 +143,7 @@ static void bcm6345_l1_irq_handle(struct irq_desc *desc)
2231 + for_each_set_bit(hwirq, &pending, IRQS_PER_WORD) {
2232 + irq = irq_linear_revmap(intc->domain, base + hwirq);
2233 + if (irq)
2234 +- do_IRQ(irq);
2235 ++ generic_handle_irq(irq);
2236 + else
2237 + spurious_interrupt();
2238 + }
2239 +diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c
2240 +index c25ce5af091ad..e92ab62cc87d9 100644
2241 +--- a/drivers/irqchip/irq-s3c24xx.c
2242 ++++ b/drivers/irqchip/irq-s3c24xx.c
2243 +@@ -368,11 +368,25 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc,
2244 + asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs)
2245 + {
2246 + do {
2247 +- if (likely(s3c_intc[0]))
2248 +- if (s3c24xx_handle_intc(s3c_intc[0], regs, 0))
2249 +- continue;
2250 ++ /*
2251 ++ * For platform based machines, neither ERR nor NULL can happen here.
2252 ++ * The s3c24xx_handle_irq() will be set as IRQ handler iff this succeeds:
2253 ++ *
2254 ++ * s3c_intc[0] = s3c24xx_init_intc()
2255 ++ *
2256 ++ * If this fails, the next calls to s3c24xx_init_intc() won't be executed.
2257 ++ *
2258 ++ * For DT machine, s3c_init_intc_of() could set the IRQ handler without
2259 ++ * setting s3c_intc[0] only if it was called with num_ctrl=0. There is no
2260 ++ * such code path, so again the s3c_intc[0] will have a valid pointer if
2261 ++ * set_handle_irq() is called.
2262 ++ *
2263 ++ * Therefore in s3c24xx_handle_irq(), the s3c_intc[0] is always something.
2264 ++ */
2265 ++ if (s3c24xx_handle_intc(s3c_intc[0], regs, 0))
2266 ++ continue;
2267 +
2268 +- if (s3c_intc[2])
2269 ++ if (!IS_ERR_OR_NULL(s3c_intc[2]))
2270 + if (s3c24xx_handle_intc(s3c_intc[2], regs, 64))
2271 + continue;
2272 +
2273 +diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
2274 +index 91d822fc4443a..8e6ad6a6e68cb 100644
2275 +--- a/drivers/media/i2c/mt9p031.c
2276 ++++ b/drivers/media/i2c/mt9p031.c
2277 +@@ -81,7 +81,9 @@
2278 + #define MT9P031_PIXEL_CLOCK_INVERT (1 << 15)
2279 + #define MT9P031_PIXEL_CLOCK_SHIFT(n) ((n) << 8)
2280 + #define MT9P031_PIXEL_CLOCK_DIVIDE(n) ((n) << 0)
2281 +-#define MT9P031_FRAME_RESTART 0x0b
2282 ++#define MT9P031_RESTART 0x0b
2283 ++#define MT9P031_FRAME_PAUSE_RESTART (1 << 1)
2284 ++#define MT9P031_FRAME_RESTART (1 << 0)
2285 + #define MT9P031_SHUTTER_DELAY 0x0c
2286 + #define MT9P031_RST 0x0d
2287 + #define MT9P031_RST_ENABLE 1
2288 +@@ -448,9 +450,23 @@ static int mt9p031_set_params(struct mt9p031 *mt9p031)
2289 + static int mt9p031_s_stream(struct v4l2_subdev *subdev, int enable)
2290 + {
2291 + struct mt9p031 *mt9p031 = to_mt9p031(subdev);
2292 ++ struct i2c_client *client = v4l2_get_subdevdata(subdev);
2293 ++ int val;
2294 + int ret;
2295 +
2296 + if (!enable) {
2297 ++ /* enable pause restart */
2298 ++ val = MT9P031_FRAME_PAUSE_RESTART;
2299 ++ ret = mt9p031_write(client, MT9P031_RESTART, val);
2300 ++ if (ret < 0)
2301 ++ return ret;
2302 ++
2303 ++ /* enable restart + keep pause restart set */
2304 ++ val |= MT9P031_FRAME_RESTART;
2305 ++ ret = mt9p031_write(client, MT9P031_RESTART, val);
2306 ++ if (ret < 0)
2307 ++ return ret;
2308 ++
2309 + /* Stop sensor readout */
2310 + ret = mt9p031_set_output_control(mt9p031,
2311 + MT9P031_OUTPUT_CONTROL_CEN, 0);
2312 +@@ -470,6 +486,16 @@ static int mt9p031_s_stream(struct v4l2_subdev *subdev, int enable)
2313 + if (ret < 0)
2314 + return ret;
2315 +
2316 ++ /*
2317 ++ * - clear pause restart
2318 ++ * - don't clear restart as clearing restart manually can cause
2319 ++ * undefined behavior
2320 ++ */
2321 ++ val = MT9P031_FRAME_RESTART;
2322 ++ ret = mt9p031_write(client, MT9P031_RESTART, val);
2323 ++ if (ret < 0)
2324 ++ return ret;
2325 ++
2326 + return mt9p031_pll_enable(mt9p031);
2327 + }
2328 +
2329 +diff --git a/drivers/media/pci/cx23885/cx23885-alsa.c b/drivers/media/pci/cx23885/cx23885-alsa.c
2330 +index d8c3637e492e3..a7f34af6c65b0 100644
2331 +--- a/drivers/media/pci/cx23885/cx23885-alsa.c
2332 ++++ b/drivers/media/pci/cx23885/cx23885-alsa.c
2333 +@@ -560,7 +560,7 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev)
2334 + SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
2335 + THIS_MODULE, sizeof(struct cx23885_audio_dev), &card);
2336 + if (err < 0)
2337 +- goto error;
2338 ++ goto error_msg;
2339 +
2340 + chip = (struct cx23885_audio_dev *) card->private_data;
2341 + chip->dev = dev;
2342 +@@ -586,6 +586,7 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev)
2343 +
2344 + error:
2345 + snd_card_free(card);
2346 ++error_msg:
2347 + pr_err("%s(): Failed to register analog audio adapter\n",
2348 + __func__);
2349 +
2350 +diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
2351 +index 60e6cd5b3a032..03239fba87bf2 100644
2352 +--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
2353 ++++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
2354 +@@ -267,19 +267,24 @@ static irqreturn_t netup_unidvb_isr(int irq, void *dev_id)
2355 + if ((reg40 & AVL_IRQ_ASSERTED) != 0) {
2356 + /* IRQ is being signaled */
2357 + reg_isr = readw(ndev->bmmio0 + REG_ISR);
2358 +- if (reg_isr & NETUP_UNIDVB_IRQ_I2C0) {
2359 +- iret = netup_i2c_interrupt(&ndev->i2c[0]);
2360 +- } else if (reg_isr & NETUP_UNIDVB_IRQ_I2C1) {
2361 +- iret = netup_i2c_interrupt(&ndev->i2c[1]);
2362 +- } else if (reg_isr & NETUP_UNIDVB_IRQ_SPI) {
2363 ++ if (reg_isr & NETUP_UNIDVB_IRQ_SPI)
2364 + iret = netup_spi_interrupt(ndev->spi);
2365 +- } else if (reg_isr & NETUP_UNIDVB_IRQ_DMA1) {
2366 +- iret = netup_dma_interrupt(&ndev->dma[0]);
2367 +- } else if (reg_isr & NETUP_UNIDVB_IRQ_DMA2) {
2368 +- iret = netup_dma_interrupt(&ndev->dma[1]);
2369 +- } else if (reg_isr & NETUP_UNIDVB_IRQ_CI) {
2370 +- iret = netup_ci_interrupt(ndev);
2371 ++ else if (!ndev->old_fw) {
2372 ++ if (reg_isr & NETUP_UNIDVB_IRQ_I2C0) {
2373 ++ iret = netup_i2c_interrupt(&ndev->i2c[0]);
2374 ++ } else if (reg_isr & NETUP_UNIDVB_IRQ_I2C1) {
2375 ++ iret = netup_i2c_interrupt(&ndev->i2c[1]);
2376 ++ } else if (reg_isr & NETUP_UNIDVB_IRQ_DMA1) {
2377 ++ iret = netup_dma_interrupt(&ndev->dma[0]);
2378 ++ } else if (reg_isr & NETUP_UNIDVB_IRQ_DMA2) {
2379 ++ iret = netup_dma_interrupt(&ndev->dma[1]);
2380 ++ } else if (reg_isr & NETUP_UNIDVB_IRQ_CI) {
2381 ++ iret = netup_ci_interrupt(ndev);
2382 ++ } else {
2383 ++ goto err;
2384 ++ }
2385 + } else {
2386 ++err:
2387 + dev_err(&pci_dev->dev,
2388 + "%s(): unknown interrupt 0x%x\n",
2389 + __func__, reg_isr);
2390 +diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c b/drivers/media/platform/mtk-vpu/mtk_vpu.c
2391 +index 853d598937f69..019a5e7e1a402 100644
2392 +--- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
2393 ++++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
2394 +@@ -817,7 +817,8 @@ static int mtk_vpu_probe(struct platform_device *pdev)
2395 + vpu->wdt.wq = create_singlethread_workqueue("vpu_wdt");
2396 + if (!vpu->wdt.wq) {
2397 + dev_err(dev, "initialize wdt workqueue failed\n");
2398 +- return -ENOMEM;
2399 ++ ret = -ENOMEM;
2400 ++ goto clk_unprepare;
2401 + }
2402 + INIT_WORK(&vpu->wdt.ws, vpu_wdt_reset_func);
2403 + mutex_init(&vpu->vpu_mutex);
2404 +@@ -916,6 +917,8 @@ disable_vpu_clk:
2405 + vpu_clock_disable(vpu);
2406 + workqueue_destroy:
2407 + destroy_workqueue(vpu->wdt.wq);
2408 ++clk_unprepare:
2409 ++ clk_unprepare(vpu->clk);
2410 +
2411 + return ret;
2412 + }
2413 +diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
2414 +index 9942932ecbf9c..75be40608bae8 100644
2415 +--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
2416 ++++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
2417 +@@ -1280,11 +1280,15 @@ static int s5p_mfc_probe(struct platform_device *pdev)
2418 + spin_lock_init(&dev->condlock);
2419 + dev->plat_dev = pdev;
2420 + if (!dev->plat_dev) {
2421 +- dev_err(&pdev->dev, "No platform data specified\n");
2422 ++ mfc_err("No platform data specified\n");
2423 + return -ENODEV;
2424 + }
2425 +
2426 + dev->variant = of_device_get_match_data(&pdev->dev);
2427 ++ if (!dev->variant) {
2428 ++ dev_err(&pdev->dev, "Failed to get device MFC hardware variant information\n");
2429 ++ return -ENOENT;
2430 ++ }
2431 +
2432 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2433 + dev->regs_base = devm_ioremap_resource(&pdev->dev, res);
2434 +diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
2435 +index 5275356143429..7e7fa23e17961 100644
2436 +--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
2437 ++++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
2438 +@@ -20,7 +20,7 @@
2439 +
2440 + /* driver definitions */
2441 + #define DRIVER_AUTHOR "Joonyoung Shim <jy0922.shim@×××××××.com>";
2442 +-#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver"
2443 ++#define DRIVER_CARD "Silicon Labs Si470x FM Radio"
2444 + #define DRIVER_DESC "I2C radio driver for Si470x FM Radio Receivers"
2445 + #define DRIVER_VERSION "1.0.2"
2446 +
2447 +diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
2448 +index aec528f52ca12..95581a8476191 100644
2449 +--- a/drivers/media/radio/si470x/radio-si470x-usb.c
2450 ++++ b/drivers/media/radio/si470x/radio-si470x-usb.c
2451 +@@ -25,7 +25,7 @@
2452 +
2453 + /* driver definitions */
2454 + #define DRIVER_AUTHOR "Tobias Lorenz <tobias.lorenz@×××.net>"
2455 +-#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver"
2456 ++#define DRIVER_CARD "Silicon Labs Si470x FM Radio"
2457 + #define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers"
2458 + #define DRIVER_VERSION "1.0.10"
2459 +
2460 +diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
2461 +index c7eea16225e7b..7bc38e805acb2 100644
2462 +--- a/drivers/media/rc/ite-cir.c
2463 ++++ b/drivers/media/rc/ite-cir.c
2464 +@@ -292,7 +292,7 @@ static irqreturn_t ite_cir_isr(int irq, void *data)
2465 + }
2466 +
2467 + /* check for the receive interrupt */
2468 +- if (iflags & ITE_IRQ_RX_FIFO) {
2469 ++ if (iflags & (ITE_IRQ_RX_FIFO | ITE_IRQ_RX_FIFO_OVERRUN)) {
2470 + /* read the FIFO bytes */
2471 + rx_bytes =
2472 + dev->params.get_rx_bytes(dev, rx_buf,
2473 +diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
2474 +index bbbbfd697f9c4..035b2455b26aa 100644
2475 +--- a/drivers/media/rc/mceusb.c
2476 ++++ b/drivers/media/rc/mceusb.c
2477 +@@ -1080,6 +1080,7 @@ static void mceusb_dev_recv(struct urb *urb)
2478 + case -ECONNRESET:
2479 + case -ENOENT:
2480 + case -EILSEQ:
2481 ++ case -EPROTO:
2482 + case -ESHUTDOWN:
2483 + usb_unlink_urb(urb);
2484 + return;
2485 +diff --git a/drivers/media/usb/dvb-usb/az6027.c b/drivers/media/usb/dvb-usb/az6027.c
2486 +index 2e711362847e4..382c8075ef524 100644
2487 +--- a/drivers/media/usb/dvb-usb/az6027.c
2488 ++++ b/drivers/media/usb/dvb-usb/az6027.c
2489 +@@ -394,6 +394,7 @@ static struct rc_map_table rc_map_az6027_table[] = {
2490 + /* remote control stuff (does not work with my box) */
2491 + static int az6027_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
2492 + {
2493 ++ *state = REMOTE_NO_KEY_PRESSED;
2494 + return 0;
2495 + }
2496 +
2497 +diff --git a/drivers/media/usb/dvb-usb/dibusb-common.c b/drivers/media/usb/dvb-usb/dibusb-common.c
2498 +index bcacb0f220282..3e45642ae186b 100644
2499 +--- a/drivers/media/usb/dvb-usb/dibusb-common.c
2500 ++++ b/drivers/media/usb/dvb-usb/dibusb-common.c
2501 +@@ -226,7 +226,7 @@ int dibusb_read_eeprom_byte(struct dvb_usb_device *d, u8 offs, u8 *val)
2502 + u8 *buf;
2503 + int rc;
2504 +
2505 +- buf = kmalloc(2, GFP_KERNEL);
2506 ++ buf = kzalloc(2, GFP_KERNEL);
2507 + if (!buf)
2508 + return -ENOMEM;
2509 +
2510 +diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
2511 +index fae811b9cde96..2b0ca32d71965 100644
2512 +--- a/drivers/media/usb/uvc/uvc_v4l2.c
2513 ++++ b/drivers/media/usb/uvc/uvc_v4l2.c
2514 +@@ -446,10 +446,13 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,
2515 + uvc_simplify_fraction(&timeperframe.numerator,
2516 + &timeperframe.denominator, 8, 333);
2517 +
2518 +- if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
2519 ++ if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
2520 + parm->parm.capture.timeperframe = timeperframe;
2521 +- else
2522 ++ parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
2523 ++ } else {
2524 + parm->parm.output.timeperframe = timeperframe;
2525 ++ parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
2526 ++ }
2527 +
2528 + return 0;
2529 + }
2530 +diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
2531 +index 38b945eb410f3..9c0e70b047c39 100644
2532 +--- a/drivers/memory/fsl_ifc.c
2533 ++++ b/drivers/memory/fsl_ifc.c
2534 +@@ -276,7 +276,7 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
2535 +
2536 + ret = fsl_ifc_ctrl_init(fsl_ifc_ctrl_dev);
2537 + if (ret < 0)
2538 +- goto err;
2539 ++ goto err_unmap_nandirq;
2540 +
2541 + init_waitqueue_head(&fsl_ifc_ctrl_dev->nand_wait);
2542 +
2543 +@@ -285,7 +285,7 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
2544 + if (ret != 0) {
2545 + dev_err(&dev->dev, "failed to install irq (%d)\n",
2546 + fsl_ifc_ctrl_dev->irq);
2547 +- goto err_irq;
2548 ++ goto err_unmap_nandirq;
2549 + }
2550 +
2551 + if (fsl_ifc_ctrl_dev->nand_irq) {
2552 +@@ -294,17 +294,16 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
2553 + if (ret != 0) {
2554 + dev_err(&dev->dev, "failed to install irq (%d)\n",
2555 + fsl_ifc_ctrl_dev->nand_irq);
2556 +- goto err_nandirq;
2557 ++ goto err_free_irq;
2558 + }
2559 + }
2560 +
2561 + return 0;
2562 +
2563 +-err_nandirq:
2564 +- free_irq(fsl_ifc_ctrl_dev->nand_irq, fsl_ifc_ctrl_dev);
2565 +- irq_dispose_mapping(fsl_ifc_ctrl_dev->nand_irq);
2566 +-err_irq:
2567 ++err_free_irq:
2568 + free_irq(fsl_ifc_ctrl_dev->irq, fsl_ifc_ctrl_dev);
2569 ++err_unmap_nandirq:
2570 ++ irq_dispose_mapping(fsl_ifc_ctrl_dev->nand_irq);
2571 + irq_dispose_mapping(fsl_ifc_ctrl_dev->irq);
2572 + err:
2573 + iounmap(fsl_ifc_ctrl_dev->gregs);
2574 +diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
2575 +index 22de7f5ed0323..ffe8757406713 100644
2576 +--- a/drivers/memstick/core/ms_block.c
2577 ++++ b/drivers/memstick/core/ms_block.c
2578 +@@ -1730,7 +1730,7 @@ static int msb_init_card(struct memstick_dev *card)
2579 + msb->pages_in_block = boot_block->attr.block_size * 2;
2580 + msb->block_size = msb->page_size * msb->pages_in_block;
2581 +
2582 +- if (msb->page_size > PAGE_SIZE) {
2583 ++ if ((size_t)msb->page_size > PAGE_SIZE) {
2584 + /* this isn't supported by linux at all, anyway*/
2585 + dbg("device page %d size isn't supported", msb->page_size);
2586 + return -EINVAL;
2587 +diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c
2588 +index 08fa6400d2558..ba6cd576e9979 100644
2589 +--- a/drivers/memstick/host/jmb38x_ms.c
2590 ++++ b/drivers/memstick/host/jmb38x_ms.c
2591 +@@ -905,7 +905,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
2592 +
2593 + iounmap(host->addr);
2594 + err_out_free:
2595 +- kfree(msh);
2596 ++ memstick_free_host(msh);
2597 + return NULL;
2598 + }
2599 +
2600 +diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
2601 +index 2539984c1db1c..256634ec58b63 100644
2602 +--- a/drivers/memstick/host/r592.c
2603 ++++ b/drivers/memstick/host/r592.c
2604 +@@ -841,15 +841,15 @@ static void r592_remove(struct pci_dev *pdev)
2605 + }
2606 + memstick_remove_host(dev->host);
2607 +
2608 ++ if (dev->dummy_dma_page)
2609 ++ dma_free_coherent(&pdev->dev, PAGE_SIZE, dev->dummy_dma_page,
2610 ++ dev->dummy_dma_page_physical_address);
2611 ++
2612 + free_irq(dev->irq, dev);
2613 + iounmap(dev->mmio);
2614 + pci_release_regions(pdev);
2615 + pci_disable_device(pdev);
2616 + memstick_free_host(dev->host);
2617 +-
2618 +- if (dev->dummy_dma_page)
2619 +- dma_free_coherent(&pdev->dev, PAGE_SIZE, dev->dummy_dma_page,
2620 +- dev->dummy_dma_page_physical_address);
2621 + }
2622 +
2623 + #ifdef CONFIG_PM_SLEEP
2624 +diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
2625 +index 9ed786935a306..61c022db0e96b 100644
2626 +--- a/drivers/mmc/host/Kconfig
2627 ++++ b/drivers/mmc/host/Kconfig
2628 +@@ -397,7 +397,7 @@ config MMC_OMAP_HS
2629 +
2630 + config MMC_WBSD
2631 + tristate "Winbond W83L51xD SD/MMC Card Interface support"
2632 +- depends on ISA_DMA_API
2633 ++ depends on ISA_DMA_API && !M68K
2634 + help
2635 + This selects the Winbond(R) W83L51xD Secure digital and
2636 + Multimedia card Interface.
2637 +diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
2638 +index 44d317d71b4ce..6026b0b3ddcea 100644
2639 +--- a/drivers/mmc/host/dw_mmc.c
2640 ++++ b/drivers/mmc/host/dw_mmc.c
2641 +@@ -2047,7 +2047,8 @@ static void dw_mci_tasklet_func(unsigned long priv)
2642 + * delayed. Allowing the transfer to take place
2643 + * avoids races and keeps things simple.
2644 + */
2645 +- if (err != -ETIMEDOUT) {
2646 ++ if (err != -ETIMEDOUT &&
2647 ++ host->dir_status == DW_MCI_RECV_STATUS) {
2648 + state = STATE_SENDING_DATA;
2649 + continue;
2650 + }
2651 +diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
2652 +index 7125687faf76a..d7601dc5e85dc 100644
2653 +--- a/drivers/mmc/host/mxs-mmc.c
2654 ++++ b/drivers/mmc/host/mxs-mmc.c
2655 +@@ -579,6 +579,11 @@ static const struct of_device_id mxs_mmc_dt_ids[] = {
2656 + };
2657 + MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
2658 +
2659 ++static void mxs_mmc_regulator_disable(void *regulator)
2660 ++{
2661 ++ regulator_disable(regulator);
2662 ++}
2663 ++
2664 + static int mxs_mmc_probe(struct platform_device *pdev)
2665 + {
2666 + const struct of_device_id *of_id =
2667 +@@ -622,6 +627,11 @@ static int mxs_mmc_probe(struct platform_device *pdev)
2668 + "Failed to enable vmmc regulator: %d\n", ret);
2669 + goto out_mmc_free;
2670 + }
2671 ++
2672 ++ ret = devm_add_action_or_reset(&pdev->dev, mxs_mmc_regulator_disable,
2673 ++ reg_vmmc);
2674 ++ if (ret)
2675 ++ goto out_mmc_free;
2676 + }
2677 +
2678 + ssp->clk = devm_clk_get(&pdev->dev, NULL);
2679 +diff --git a/drivers/mtd/spi-nor/hisi-sfc.c b/drivers/mtd/spi-nor/hisi-sfc.c
2680 +index 9209d225e3152..e84a310dcc6cb 100644
2681 +--- a/drivers/mtd/spi-nor/hisi-sfc.c
2682 ++++ b/drivers/mtd/spi-nor/hisi-sfc.c
2683 +@@ -485,7 +485,6 @@ static int hisi_spi_nor_remove(struct platform_device *pdev)
2684 +
2685 + hisi_spi_nor_unregister_all(host);
2686 + mutex_destroy(&host->lock);
2687 +- clk_disable_unprepare(host->clk);
2688 + return 0;
2689 + }
2690 +
2691 +diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c
2692 +index 68bbac4715c35..1e1e77a40f182 100644
2693 +--- a/drivers/net/bonding/bond_sysfs_slave.c
2694 ++++ b/drivers/net/bonding/bond_sysfs_slave.c
2695 +@@ -112,15 +112,15 @@ static ssize_t ad_partner_oper_port_state_show(struct slave *slave, char *buf)
2696 + }
2697 + static SLAVE_ATTR_RO(ad_partner_oper_port_state);
2698 +
2699 +-static const struct slave_attribute *slave_attrs[] = {
2700 +- &slave_attr_state,
2701 +- &slave_attr_mii_status,
2702 +- &slave_attr_link_failure_count,
2703 +- &slave_attr_perm_hwaddr,
2704 +- &slave_attr_queue_id,
2705 +- &slave_attr_ad_aggregator_id,
2706 +- &slave_attr_ad_actor_oper_port_state,
2707 +- &slave_attr_ad_partner_oper_port_state,
2708 ++static const struct attribute *slave_attrs[] = {
2709 ++ &slave_attr_state.attr,
2710 ++ &slave_attr_mii_status.attr,
2711 ++ &slave_attr_link_failure_count.attr,
2712 ++ &slave_attr_perm_hwaddr.attr,
2713 ++ &slave_attr_queue_id.attr,
2714 ++ &slave_attr_ad_aggregator_id.attr,
2715 ++ &slave_attr_ad_actor_oper_port_state.attr,
2716 ++ &slave_attr_ad_partner_oper_port_state.attr,
2717 + NULL
2718 + };
2719 +
2720 +@@ -141,24 +141,10 @@ const struct sysfs_ops slave_sysfs_ops = {
2721 +
2722 + int bond_sysfs_slave_add(struct slave *slave)
2723 + {
2724 +- const struct slave_attribute **a;
2725 +- int err;
2726 +-
2727 +- for (a = slave_attrs; *a; ++a) {
2728 +- err = sysfs_create_file(&slave->kobj, &((*a)->attr));
2729 +- if (err) {
2730 +- kobject_put(&slave->kobj);
2731 +- return err;
2732 +- }
2733 +- }
2734 +-
2735 +- return 0;
2736 ++ return sysfs_create_files(&slave->kobj, slave_attrs);
2737 + }
2738 +
2739 + void bond_sysfs_slave_del(struct slave *slave)
2740 + {
2741 +- const struct slave_attribute **a;
2742 +-
2743 +- for (a = slave_attrs; *a; ++a)
2744 +- sysfs_remove_file(&slave->kobj, &((*a)->attr));
2745 ++ sysfs_remove_files(&slave->kobj, slave_attrs);
2746 + }
2747 +diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-common.h b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
2748 +index b2cd3bdba9f89..533b8519ec352 100644
2749 +--- a/drivers/net/ethernet/amd/xgbe/xgbe-common.h
2750 ++++ b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
2751 +@@ -1331,6 +1331,10 @@
2752 + #define MDIO_VEND2_PMA_CDR_CONTROL 0x8056
2753 + #endif
2754 +
2755 ++#ifndef MDIO_VEND2_PMA_MISC_CTRL0
2756 ++#define MDIO_VEND2_PMA_MISC_CTRL0 0x8090
2757 ++#endif
2758 ++
2759 + #ifndef MDIO_CTRL1_SPEED1G
2760 + #define MDIO_CTRL1_SPEED1G (MDIO_CTRL1_SPEED10G & ~BMCR_SPEED100)
2761 + #endif
2762 +@@ -1389,6 +1393,10 @@
2763 + #define XGBE_PMA_RX_RST_0_RESET_ON 0x10
2764 + #define XGBE_PMA_RX_RST_0_RESET_OFF 0x00
2765 +
2766 ++#define XGBE_PMA_PLL_CTRL_MASK BIT(15)
2767 ++#define XGBE_PMA_PLL_CTRL_ENABLE BIT(15)
2768 ++#define XGBE_PMA_PLL_CTRL_DISABLE 0x0000
2769 ++
2770 + /* Bit setting and getting macros
2771 + * The get macro will extract the current bit field value from within
2772 + * the variable
2773 +diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
2774 +index bb6f0dcea6eab..4a4370a470fd1 100644
2775 +--- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
2776 ++++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
2777 +@@ -1803,12 +1803,26 @@ static void xgbe_phy_rx_reset(struct xgbe_prv_data *pdata)
2778 + }
2779 + }
2780 +
2781 ++static void xgbe_phy_pll_ctrl(struct xgbe_prv_data *pdata, bool enable)
2782 ++{
2783 ++ XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_VEND2_PMA_MISC_CTRL0,
2784 ++ XGBE_PMA_PLL_CTRL_MASK,
2785 ++ enable ? XGBE_PMA_PLL_CTRL_ENABLE
2786 ++ : XGBE_PMA_PLL_CTRL_DISABLE);
2787 ++
2788 ++ /* Wait for command to complete */
2789 ++ usleep_range(100, 200);
2790 ++}
2791 ++
2792 + static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata,
2793 + unsigned int cmd, unsigned int sub_cmd)
2794 + {
2795 + unsigned int s0 = 0;
2796 + unsigned int wait;
2797 +
2798 ++ /* Disable PLL re-initialization during FW command processing */
2799 ++ xgbe_phy_pll_ctrl(pdata, false);
2800 ++
2801 + /* Log if a previous command did not complete */
2802 + if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) {
2803 + netif_dbg(pdata, link, pdata->netdev,
2804 +@@ -1829,7 +1843,7 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata,
2805 + wait = XGBE_RATECHANGE_COUNT;
2806 + while (wait--) {
2807 + if (!XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS))
2808 +- return;
2809 ++ goto reenable_pll;
2810 +
2811 + usleep_range(1000, 2000);
2812 + }
2813 +@@ -1839,6 +1853,10 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata,
2814 +
2815 + /* Reset on error */
2816 + xgbe_phy_rx_reset(pdata);
2817 ++
2818 ++reenable_pll:
2819 ++ /* Enable PLL re-initialization */
2820 ++ xgbe_phy_pll_ctrl(pdata, true);
2821 + }
2822 +
2823 + static void xgbe_phy_rrc(struct xgbe_prv_data *pdata)
2824 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
2825 +index 1835d2e451c01..fc7fce642666c 100644
2826 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
2827 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
2828 +@@ -635,11 +635,13 @@ static int bnx2x_ilt_client_mem_op(struct bnx2x *bp, int cli_num,
2829 + {
2830 + int i, rc;
2831 + struct bnx2x_ilt *ilt = BP_ILT(bp);
2832 +- struct ilt_client_info *ilt_cli = &ilt->clients[cli_num];
2833 ++ struct ilt_client_info *ilt_cli;
2834 +
2835 + if (!ilt || !ilt->lines)
2836 + return -1;
2837 +
2838 ++ ilt_cli = &ilt->clients[cli_num];
2839 ++
2840 + if (ilt_cli->flags & (ILT_CLIENT_SKIP_INIT | ILT_CLIENT_SKIP_MEM))
2841 + return 0;
2842 +
2843 +diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c b/drivers/net/ethernet/cavium/thunder/nic_main.c
2844 +index 819f38a3225db..7f8ea16ad0d0a 100644
2845 +--- a/drivers/net/ethernet/cavium/thunder/nic_main.c
2846 ++++ b/drivers/net/ethernet/cavium/thunder/nic_main.c
2847 +@@ -1128,7 +1128,7 @@ static int nic_register_interrupts(struct nicpf *nic)
2848 + dev_err(&nic->pdev->dev,
2849 + "Request for #%d msix vectors failed, returned %d\n",
2850 + nic->num_vec, ret);
2851 +- return 1;
2852 ++ return ret;
2853 + }
2854 +
2855 + /* Register mailbox interrupt handler */
2856 +diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
2857 +index 98734a37b6f64..df1c4ba7e0c97 100644
2858 +--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
2859 ++++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
2860 +@@ -1152,7 +1152,7 @@ static int nicvf_register_misc_interrupt(struct nicvf *nic)
2861 + if (ret < 0) {
2862 + netdev_err(nic->netdev,
2863 + "Req for #%d msix vectors failed\n", nic->num_vec);
2864 +- return 1;
2865 ++ return ret;
2866 + }
2867 +
2868 + sprintf(nic->irq_name[irq], "%s Mbox", "NICVF");
2869 +@@ -1171,7 +1171,7 @@ static int nicvf_register_misc_interrupt(struct nicvf *nic)
2870 + if (!nicvf_check_pf_ready(nic)) {
2871 + nicvf_disable_intr(nic, NICVF_INTR_MBOX, 0);
2872 + nicvf_unregister_interrupts(nic);
2873 +- return 1;
2874 ++ return -EIO;
2875 + }
2876 +
2877 + return 0;
2878 +diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
2879 +index 76ab6c0d40cf5..4befc885efb8d 100644
2880 +--- a/drivers/net/ethernet/ibm/ibmvnic.c
2881 ++++ b/drivers/net/ethernet/ibm/ibmvnic.c
2882 +@@ -3835,6 +3835,9 @@ static int init_crq_queue(struct ibmvnic_adapter *adapter)
2883 + crq->cur = 0;
2884 + spin_lock_init(&crq->lock);
2885 +
2886 ++ /* process any CRQs that were queued before we enabled interrupts */
2887 ++ tasklet_schedule(&adapter->tasklet);
2888 ++
2889 + return retrc;
2890 +
2891 + req_irq_failed:
2892 +diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
2893 +index d0c1bf5441d84..438e2675bc132 100644
2894 +--- a/drivers/net/ethernet/intel/i40e/i40e.h
2895 ++++ b/drivers/net/ethernet/intel/i40e/i40e.h
2896 +@@ -163,6 +163,7 @@ enum i40e_vsi_state_t {
2897 + __I40E_VSI_OVERFLOW_PROMISC,
2898 + __I40E_VSI_REINIT_REQUESTED,
2899 + __I40E_VSI_DOWN_REQUESTED,
2900 ++ __I40E_VSI_RELEASING,
2901 + /* This must be last as it determines the size of the BITMAP */
2902 + __I40E_VSI_STATE_SIZE__,
2903 + };
2904 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
2905 +index 1555d32ddb962..44a9c8aa3067a 100644
2906 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
2907 ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
2908 +@@ -2415,7 +2415,8 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)
2909 +
2910 + for (v = 0; v < pf->num_alloc_vsi; v++) {
2911 + if (pf->vsi[v] &&
2912 +- (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED)) {
2913 ++ (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED) &&
2914 ++ !test_bit(__I40E_VSI_RELEASING, pf->vsi[v]->state)) {
2915 + int ret = i40e_sync_vsi_filters(pf->vsi[v]);
2916 +
2917 + if (ret) {
2918 +@@ -10098,7 +10099,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
2919 + dev_info(&pf->pdev->dev, "Can't remove PF VSI\n");
2920 + return -ENODEV;
2921 + }
2922 +-
2923 ++ set_bit(__I40E_VSI_RELEASING, vsi->state);
2924 + uplink_seid = vsi->uplink_seid;
2925 + if (vsi->type != I40E_VSI_SRIOV) {
2926 + if (vsi->netdev_registered) {
2927 +diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
2928 +index ad2dd5b747b23..6bc772401cff2 100644
2929 +--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
2930 ++++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
2931 +@@ -2027,7 +2027,7 @@ static void i40evf_adminq_task(struct work_struct *work)
2932 +
2933 + /* check for error indications */
2934 + val = rd32(hw, hw->aq.arq.len);
2935 +- if (val == 0xdeadbeef) /* indicates device in reset */
2936 ++ if (val == 0xdeadbeef || val == 0xffffffff) /* device in reset */
2937 + goto freedom;
2938 + oldval = val;
2939 + if (val & I40E_VF_ARQLEN1_ARQVFE_MASK) {
2940 +diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
2941 +index f226907926977..c50c1892e88da 100644
2942 +--- a/drivers/net/ethernet/sfc/ptp.c
2943 ++++ b/drivers/net/ethernet/sfc/ptp.c
2944 +@@ -494,7 +494,7 @@ static int efx_ptp_get_attributes(struct efx_nic *efx)
2945 + } else if (rc == -EINVAL) {
2946 + fmt = MC_CMD_PTP_OUT_GET_ATTRIBUTES_SECONDS_NANOSECONDS;
2947 + } else if (rc == -EPERM) {
2948 +- netif_info(efx, probe, efx->net_dev, "no PTP support\n");
2949 ++ pci_info(efx->pci_dev, "no PTP support\n");
2950 + return rc;
2951 + } else {
2952 + efx_mcdi_display_error(efx, MC_CMD_PTP, sizeof(inbuf),
2953 +@@ -613,7 +613,7 @@ static int efx_ptp_disable(struct efx_nic *efx)
2954 + * should only have been called during probe.
2955 + */
2956 + if (rc == -ENOSYS || rc == -EPERM)
2957 +- netif_info(efx, probe, efx->net_dev, "no PTP support\n");
2958 ++ pci_info(efx->pci_dev, "no PTP support\n");
2959 + else if (rc)
2960 + efx_mcdi_display_error(efx, MC_CMD_PTP,
2961 + MC_CMD_PTP_IN_DISABLE_LEN,
2962 +diff --git a/drivers/net/ethernet/sfc/siena_sriov.c b/drivers/net/ethernet/sfc/siena_sriov.c
2963 +index da7b94f346049..30d58f72725df 100644
2964 +--- a/drivers/net/ethernet/sfc/siena_sriov.c
2965 ++++ b/drivers/net/ethernet/sfc/siena_sriov.c
2966 +@@ -1059,7 +1059,7 @@ void efx_siena_sriov_probe(struct efx_nic *efx)
2967 + return;
2968 +
2969 + if (efx_siena_sriov_cmd(efx, false, &efx->vi_scale, &count)) {
2970 +- netif_info(efx, probe, efx->net_dev, "no SR-IOV VFs probed\n");
2971 ++ pci_info(efx->pci_dev, "no SR-IOV VFs probed\n");
2972 + return;
2973 + }
2974 + if (count > 0 && count > max_vfs)
2975 +diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
2976 +index e1ee9da38df7e..da536385075aa 100644
2977 +--- a/drivers/net/ethernet/ti/davinci_emac.c
2978 ++++ b/drivers/net/ethernet/ti/davinci_emac.c
2979 +@@ -426,8 +426,20 @@ static int emac_set_coalesce(struct net_device *ndev,
2980 + u32 int_ctrl, num_interrupts = 0;
2981 + u32 prescale = 0, addnl_dvdr = 1, coal_intvl = 0;
2982 +
2983 +- if (!coal->rx_coalesce_usecs)
2984 +- return -EINVAL;
2985 ++ if (!coal->rx_coalesce_usecs) {
2986 ++ priv->coal_intvl = 0;
2987 ++
2988 ++ switch (priv->version) {
2989 ++ case EMAC_VERSION_2:
2990 ++ emac_ctrl_write(EMAC_DM646X_CMINTCTRL, 0);
2991 ++ break;
2992 ++ default:
2993 ++ emac_ctrl_write(EMAC_CTRL_EWINTTCNT, 0);
2994 ++ break;
2995 ++ }
2996 ++
2997 ++ return 0;
2998 ++ }
2999 +
3000 + coal_intvl = coal->rx_coalesce_usecs;
3001 +
3002 +diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
3003 +index ef5e5b621ec59..755aa67412923 100644
3004 +--- a/drivers/net/phy/micrel.c
3005 ++++ b/drivers/net/phy/micrel.c
3006 +@@ -876,8 +876,9 @@ static struct phy_driver ksphy_driver[] = {
3007 + .get_sset_count = kszphy_get_sset_count,
3008 + .get_strings = kszphy_get_strings,
3009 + .get_stats = kszphy_get_stats,
3010 +- .suspend = genphy_suspend,
3011 +- .resume = genphy_resume,
3012 ++ /* No suspend/resume callbacks because of errata DS80000700A,
3013 ++ * receiver error following software power down.
3014 ++ */
3015 + }, {
3016 + .phy_id = PHY_ID_KSZ8041RNLI,
3017 + .phy_id_mask = MICREL_PHY_ID_MASK,
3018 +diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
3019 +index 17acecfda5420..89d8efe8753e5 100644
3020 +--- a/drivers/net/phy/phylink.c
3021 ++++ b/drivers/net/phy/phylink.c
3022 +@@ -1022,7 +1022,7 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
3023 + return -EOPNOTSUPP;
3024 +
3025 + if (!phylink_test(pl->supported, Asym_Pause) &&
3026 +- !pause->autoneg && pause->rx_pause != pause->tx_pause)
3027 ++ pause->rx_pause != pause->tx_pause)
3028 + return -EINVAL;
3029 +
3030 + config->pause &= ~(MLO_PAUSE_AN | MLO_PAUSE_TXRX_MASK);
3031 +diff --git a/drivers/net/tun.c b/drivers/net/tun.c
3032 +index 2bf58239bd4b4..b616961267d09 100644
3033 +--- a/drivers/net/tun.c
3034 ++++ b/drivers/net/tun.c
3035 +@@ -858,6 +858,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
3036 + {
3037 + struct tun_struct *tun = netdev_priv(dev);
3038 + int txq = skb->queue_mapping;
3039 ++ struct netdev_queue *queue;
3040 + struct tun_file *tfile;
3041 + u32 numqueues = 0;
3042 +
3043 +@@ -916,6 +917,10 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
3044 + if (skb_array_produce(&tfile->tx_array, skb))
3045 + goto drop;
3046 +
3047 ++ /* NETIF_F_LLTX requires to do our own update of trans_start */
3048 ++ queue = netdev_get_tx_queue(dev, txq);
3049 ++ queue->trans_start = jiffies;
3050 ++
3051 + /* Notify and wake up reader process */
3052 + if (tfile->flags & TUN_FASYNC)
3053 + kill_fasync(&tfile->fasync, SIGIO, POLL_IN);
3054 +diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
3055 +index 3628fd7e606fd..98fc34ea78ffe 100644
3056 +--- a/drivers/net/vmxnet3/vmxnet3_drv.c
3057 ++++ b/drivers/net/vmxnet3/vmxnet3_drv.c
3058 +@@ -3623,7 +3623,6 @@ vmxnet3_suspend(struct device *device)
3059 + vmxnet3_free_intr_resources(adapter);
3060 +
3061 + netif_device_detach(netdev);
3062 +- netif_tx_stop_all_queues(netdev);
3063 +
3064 + /* Create wake-up filters. */
3065 + pmConf = adapter->pm_conf;
3066 +diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
3067 +index e42546bc99efb..41ae999c685b8 100644
3068 +--- a/drivers/net/wireless/ath/ath10k/mac.c
3069 ++++ b/drivers/net/wireless/ath/ath10k/mac.c
3070 +@@ -990,7 +990,7 @@ static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
3071 + arg.channel.min_power = 0;
3072 + arg.channel.max_power = channel->max_power * 2;
3073 + arg.channel.max_reg_power = channel->max_reg_power * 2;
3074 +- arg.channel.max_antenna_gain = channel->max_antenna_gain * 2;
3075 ++ arg.channel.max_antenna_gain = channel->max_antenna_gain;
3076 +
3077 + reinit_completion(&ar->vdev_setup_done);
3078 +
3079 +@@ -1432,7 +1432,7 @@ static int ath10k_vdev_start_restart(struct ath10k_vif *arvif,
3080 + arg.channel.min_power = 0;
3081 + arg.channel.max_power = chandef->chan->max_power * 2;
3082 + arg.channel.max_reg_power = chandef->chan->max_reg_power * 2;
3083 +- arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain * 2;
3084 ++ arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain;
3085 +
3086 + if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
3087 + arg.ssid = arvif->u.ap.ssid;
3088 +@@ -3091,7 +3091,7 @@ static int ath10k_update_channel_list(struct ath10k *ar)
3089 + ch->min_power = 0;
3090 + ch->max_power = channel->max_power * 2;
3091 + ch->max_reg_power = channel->max_reg_power * 2;
3092 +- ch->max_antenna_gain = channel->max_antenna_gain * 2;
3093 ++ ch->max_antenna_gain = channel->max_antenna_gain;
3094 + ch->reg_class_id = 0; /* FIXME */
3095 +
3096 + /* FIXME: why use only legacy modes, why not any
3097 +diff --git a/drivers/net/wireless/ath/ath10k/usb.c b/drivers/net/wireless/ath/ath10k/usb.c
3098 +index 16d5fe6d1e2e4..0a76991d0c6cd 100644
3099 +--- a/drivers/net/wireless/ath/ath10k/usb.c
3100 ++++ b/drivers/net/wireless/ath/ath10k/usb.c
3101 +@@ -536,7 +536,7 @@ static int ath10k_usb_submit_ctrl_in(struct ath10k *ar,
3102 + req,
3103 + USB_DIR_IN | USB_TYPE_VENDOR |
3104 + USB_RECIP_DEVICE, value, index, buf,
3105 +- size, 2 * HZ);
3106 ++ size, 2000);
3107 +
3108 + if (ret < 0) {
3109 + ath10k_warn(ar, "Failed to read usb control message: %d\n",
3110 +@@ -875,6 +875,11 @@ static int ath10k_usb_setup_pipe_resources(struct ath10k *ar,
3111 + le16_to_cpu(endpoint->wMaxPacketSize),
3112 + endpoint->bInterval);
3113 + }
3114 ++
3115 ++ /* Ignore broken descriptors. */
3116 ++ if (usb_endpoint_maxp(endpoint) == 0)
3117 ++ continue;
3118 ++
3119 + urbcount = 0;
3120 +
3121 + pipe_num =
3122 +diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
3123 +index 947b74c64fec0..621f5597a3693 100644
3124 +--- a/drivers/net/wireless/ath/ath10k/wmi.h
3125 ++++ b/drivers/net/wireless/ath/ath10k/wmi.h
3126 +@@ -1945,7 +1945,9 @@ struct wmi_channel {
3127 + union {
3128 + __le32 reginfo1;
3129 + struct {
3130 ++ /* note: power unit is 1 dBm */
3131 + u8 antenna_max;
3132 ++ /* note: power unit is 0.5 dBm */
3133 + u8 max_tx_power;
3134 + } __packed;
3135 + } __packed;
3136 +@@ -1965,6 +1967,7 @@ struct wmi_channel_arg {
3137 + u32 min_power;
3138 + u32 max_power;
3139 + u32 max_reg_power;
3140 ++ /* note: power unit is 1 dBm */
3141 + u32 max_antenna_gain;
3142 + u32 reg_class_id;
3143 + enum wmi_phy_mode mode;
3144 +diff --git a/drivers/net/wireless/ath/ath6kl/usb.c b/drivers/net/wireless/ath/ath6kl/usb.c
3145 +index 53b66e9434c99..8b24964304b1f 100644
3146 +--- a/drivers/net/wireless/ath/ath6kl/usb.c
3147 ++++ b/drivers/net/wireless/ath/ath6kl/usb.c
3148 +@@ -340,6 +340,11 @@ static int ath6kl_usb_setup_pipe_resources(struct ath6kl_usb *ar_usb)
3149 + le16_to_cpu(endpoint->wMaxPacketSize),
3150 + endpoint->bInterval);
3151 + }
3152 ++
3153 ++ /* Ignore broken descriptors. */
3154 ++ if (usb_endpoint_maxp(endpoint) == 0)
3155 ++ continue;
3156 ++
3157 + urbcount = 0;
3158 +
3159 + pipe_num =
3160 +@@ -907,7 +912,7 @@ static int ath6kl_usb_submit_ctrl_in(struct ath6kl_usb *ar_usb,
3161 + req,
3162 + USB_DIR_IN | USB_TYPE_VENDOR |
3163 + USB_RECIP_DEVICE, value, index, buf,
3164 +- size, 2 * HZ);
3165 ++ size, 2000);
3166 +
3167 + if (ret < 0) {
3168 + ath6kl_warn("Failed to read usb control message: %d\n", ret);
3169 +diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
3170 +index 173960682ea06..507d8c5149686 100644
3171 +--- a/drivers/net/wireless/ath/ath9k/main.c
3172 ++++ b/drivers/net/wireless/ath/ath9k/main.c
3173 +@@ -529,8 +529,10 @@ irqreturn_t ath_isr(int irq, void *dev)
3174 + ath9k_debug_sync_cause(sc, sync_cause);
3175 + status &= ah->imask; /* discard unasked-for bits */
3176 +
3177 +- if (test_bit(ATH_OP_HW_RESET, &common->op_flags))
3178 ++ if (test_bit(ATH_OP_HW_RESET, &common->op_flags)) {
3179 ++ ath9k_hw_kill_interrupts(sc->sc_ah);
3180 + return IRQ_HANDLED;
3181 ++ }
3182 +
3183 + /*
3184 + * If there are no status bits set, then this interrupt was not
3185 +diff --git a/drivers/net/wireless/ath/dfs_pattern_detector.c b/drivers/net/wireless/ath/dfs_pattern_detector.c
3186 +index 78146607f16e8..acd85e5069346 100644
3187 +--- a/drivers/net/wireless/ath/dfs_pattern_detector.c
3188 ++++ b/drivers/net/wireless/ath/dfs_pattern_detector.c
3189 +@@ -182,10 +182,12 @@ static void channel_detector_exit(struct dfs_pattern_detector *dpd,
3190 + if (cd == NULL)
3191 + return;
3192 + list_del(&cd->head);
3193 +- for (i = 0; i < dpd->num_radar_types; i++) {
3194 +- struct pri_detector *de = cd->detectors[i];
3195 +- if (de != NULL)
3196 +- de->exit(de);
3197 ++ if (cd->detectors) {
3198 ++ for (i = 0; i < dpd->num_radar_types; i++) {
3199 ++ struct pri_detector *de = cd->detectors[i];
3200 ++ if (de != NULL)
3201 ++ de->exit(de);
3202 ++ }
3203 + }
3204 + kfree(cd->detectors);
3205 + kfree(cd);
3206 +diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
3207 +index 2450f5f7f79f3..0dae1627ac0df 100644
3208 +--- a/drivers/net/wireless/ath/wcn36xx/main.c
3209 ++++ b/drivers/net/wireless/ath/wcn36xx/main.c
3210 +@@ -133,7 +133,9 @@ static struct ieee80211_supported_band wcn_band_2ghz = {
3211 + .cap = IEEE80211_HT_CAP_GRN_FLD |
3212 + IEEE80211_HT_CAP_SGI_20 |
3213 + IEEE80211_HT_CAP_DSSSCCK40 |
3214 +- IEEE80211_HT_CAP_LSIG_TXOP_PROT,
3215 ++ IEEE80211_HT_CAP_LSIG_TXOP_PROT |
3216 ++ IEEE80211_HT_CAP_SGI_40 |
3217 ++ IEEE80211_HT_CAP_SUP_WIDTH_20_40,
3218 + .ht_supported = true,
3219 + .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
3220 + .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
3221 +diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
3222 +index 9c6590d5348ad..c5b5fbcd2066c 100644
3223 +--- a/drivers/net/wireless/ath/wcn36xx/smd.c
3224 ++++ b/drivers/net/wireless/ath/wcn36xx/smd.c
3225 +@@ -2082,30 +2082,52 @@ static int wcn36xx_smd_delete_sta_context_ind(struct wcn36xx *wcn,
3226 + size_t len)
3227 + {
3228 + struct wcn36xx_hal_delete_sta_context_ind_msg *rsp = buf;
3229 +- struct wcn36xx_vif *tmp;
3230 ++ struct wcn36xx_vif *vif_priv;
3231 ++ struct ieee80211_vif *vif;
3232 ++ struct ieee80211_bss_conf *bss_conf;
3233 + struct ieee80211_sta *sta;
3234 ++ bool found = false;
3235 +
3236 + if (len != sizeof(*rsp)) {
3237 + wcn36xx_warn("Corrupted delete sta indication\n");
3238 + return -EIO;
3239 + }
3240 +
3241 +- wcn36xx_dbg(WCN36XX_DBG_HAL, "delete station indication %pM index %d\n",
3242 +- rsp->addr2, rsp->sta_id);
3243 ++ wcn36xx_dbg(WCN36XX_DBG_HAL,
3244 ++ "delete station indication %pM index %d reason %d\n",
3245 ++ rsp->addr2, rsp->sta_id, rsp->reason_code);
3246 +
3247 +- list_for_each_entry(tmp, &wcn->vif_list, list) {
3248 ++ list_for_each_entry(vif_priv, &wcn->vif_list, list) {
3249 + rcu_read_lock();
3250 +- sta = ieee80211_find_sta(wcn36xx_priv_to_vif(tmp), rsp->addr2);
3251 +- if (sta)
3252 +- ieee80211_report_low_ack(sta, 0);
3253 ++ vif = wcn36xx_priv_to_vif(vif_priv);
3254 ++
3255 ++ if (vif->type == NL80211_IFTYPE_STATION) {
3256 ++ /* We could call ieee80211_find_sta too, but checking
3257 ++ * bss_conf is clearer.
3258 ++ */
3259 ++ bss_conf = &vif->bss_conf;
3260 ++ if (vif_priv->sta_assoc &&
3261 ++ !memcmp(bss_conf->bssid, rsp->addr2, ETH_ALEN)) {
3262 ++ found = true;
3263 ++ wcn36xx_dbg(WCN36XX_DBG_HAL,
3264 ++ "connection loss bss_index %d\n",
3265 ++ vif_priv->bss_index);
3266 ++ ieee80211_connection_loss(vif);
3267 ++ }
3268 ++ } else {
3269 ++ sta = ieee80211_find_sta(vif, rsp->addr2);
3270 ++ if (sta) {
3271 ++ found = true;
3272 ++ ieee80211_report_low_ack(sta, 0);
3273 ++ }
3274 ++ }
3275 ++
3276 + rcu_read_unlock();
3277 +- if (sta)
3278 ++ if (found)
3279 + return 0;
3280 + }
3281 +
3282 +- wcn36xx_warn("STA with addr %pM and index %d not found\n",
3283 +- rsp->addr2,
3284 +- rsp->sta_id);
3285 ++ wcn36xx_warn("BSS or STA with addr %pM not found\n", rsp->addr2);
3286 + return -ENOENT;
3287 + }
3288 +
3289 +diff --git a/drivers/net/wireless/broadcom/b43/phy_g.c b/drivers/net/wireless/broadcom/b43/phy_g.c
3290 +index 822dcaa8ace63..35ff139b1496e 100644
3291 +--- a/drivers/net/wireless/broadcom/b43/phy_g.c
3292 ++++ b/drivers/net/wireless/broadcom/b43/phy_g.c
3293 +@@ -2310,7 +2310,7 @@ static u8 b43_gphy_aci_scan(struct b43_wldev *dev)
3294 + b43_phy_mask(dev, B43_PHY_G_CRS, 0x7FFF);
3295 + b43_set_all_gains(dev, 3, 8, 1);
3296 +
3297 +- start = (channel - 5 > 0) ? channel - 5 : 1;
3298 ++ start = (channel > 5) ? channel - 5 : 1;
3299 + end = (channel + 5 < 14) ? channel + 5 : 13;
3300 +
3301 + for (i = start; i <= end; i++) {
3302 +diff --git a/drivers/net/wireless/broadcom/b43legacy/radio.c b/drivers/net/wireless/broadcom/b43legacy/radio.c
3303 +index 9501420340a91..5b1e8890305c1 100644
3304 +--- a/drivers/net/wireless/broadcom/b43legacy/radio.c
3305 ++++ b/drivers/net/wireless/broadcom/b43legacy/radio.c
3306 +@@ -299,7 +299,7 @@ u8 b43legacy_radio_aci_scan(struct b43legacy_wldev *dev)
3307 + & 0x7FFF);
3308 + b43legacy_set_all_gains(dev, 3, 8, 1);
3309 +
3310 +- start = (channel - 5 > 0) ? channel - 5 : 1;
3311 ++ start = (channel > 5) ? channel - 5 : 1;
3312 + end = (channel + 5 < 14) ? channel + 5 : 13;
3313 +
3314 + for (i = start; i <= end; i++) {
3315 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
3316 +index d2cada0ab4264..3303fc85d76f5 100644
3317 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
3318 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
3319 +@@ -1029,6 +1029,9 @@ bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm)
3320 +
3321 + lockdep_assert_held(&mvm->mutex);
3322 +
3323 ++ if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM)
3324 ++ return false;
3325 ++
3326 + if (num_of_ant(iwl_mvm_get_valid_rx_ant(mvm)) == 1)
3327 + return false;
3328 +
3329 +diff --git a/drivers/net/wireless/marvell/libertas/if_usb.c b/drivers/net/wireless/marvell/libertas/if_usb.c
3330 +index aad82ff568835..bbfc89d9d65ab 100644
3331 +--- a/drivers/net/wireless/marvell/libertas/if_usb.c
3332 ++++ b/drivers/net/wireless/marvell/libertas/if_usb.c
3333 +@@ -288,6 +288,7 @@ err_add_card:
3334 + if_usb_reset_device(cardp);
3335 + dealloc:
3336 + if_usb_free(cardp);
3337 ++ kfree(cardp);
3338 +
3339 + error:
3340 + return r;
3341 +@@ -312,6 +313,7 @@ static void if_usb_disconnect(struct usb_interface *intf)
3342 +
3343 + /* Unlink and free urb */
3344 + if_usb_free(cardp);
3345 ++ kfree(cardp);
3346 +
3347 + usb_set_intfdata(intf, NULL);
3348 + usb_put_dev(interface_to_usbdev(intf));
3349 +diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
3350 +index cae95362efd5b..ddc5f0de09606 100644
3351 +--- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c
3352 ++++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
3353 +@@ -234,6 +234,7 @@ static int if_usb_probe(struct usb_interface *intf,
3354 +
3355 + dealloc:
3356 + if_usb_free(cardp);
3357 ++ kfree(cardp);
3358 + error:
3359 + lbtf_deb_leave(LBTF_DEB_MAIN);
3360 + return -ENOMEM;
3361 +@@ -258,6 +259,7 @@ static void if_usb_disconnect(struct usb_interface *intf)
3362 +
3363 + /* Unlink and free urb */
3364 + if_usb_free(cardp);
3365 ++ kfree(cardp);
3366 +
3367 + usb_set_intfdata(intf, NULL);
3368 + usb_put_dev(interface_to_usbdev(intf));
3369 +diff --git a/drivers/net/wireless/marvell/mwifiex/11n.c b/drivers/net/wireless/marvell/mwifiex/11n.c
3370 +index 7252069149115..2844f937cc659 100644
3371 +--- a/drivers/net/wireless/marvell/mwifiex/11n.c
3372 ++++ b/drivers/net/wireless/marvell/mwifiex/11n.c
3373 +@@ -632,14 +632,15 @@ int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
3374 + uint16_t del_ba_param_set;
3375 +
3376 + memset(&delba, 0, sizeof(delba));
3377 +- delba.del_ba_param_set = cpu_to_le16(tid << DELBA_TID_POS);
3378 +
3379 +- del_ba_param_set = le16_to_cpu(delba.del_ba_param_set);
3380 ++ del_ba_param_set = tid << DELBA_TID_POS;
3381 ++
3382 + if (initiator)
3383 + del_ba_param_set |= IEEE80211_DELBA_PARAM_INITIATOR_MASK;
3384 + else
3385 + del_ba_param_set &= ~IEEE80211_DELBA_PARAM_INITIATOR_MASK;
3386 +
3387 ++ delba.del_ba_param_set = cpu_to_le16(del_ba_param_set);
3388 + memcpy(&delba.peer_mac_addr, peer_mac, ETH_ALEN);
3389 +
3390 + /* We don't wait for the response of this command */
3391 +diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
3392 +index 79c50aebffc4b..a88bddc383894 100644
3393 +--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
3394 ++++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
3395 +@@ -898,16 +898,20 @@ mwifiex_init_new_priv_params(struct mwifiex_private *priv,
3396 + switch (type) {
3397 + case NL80211_IFTYPE_STATION:
3398 + case NL80211_IFTYPE_ADHOC:
3399 +- priv->bss_role = MWIFIEX_BSS_ROLE_STA;
3400 ++ priv->bss_role = MWIFIEX_BSS_ROLE_STA;
3401 ++ priv->bss_type = MWIFIEX_BSS_TYPE_STA;
3402 + break;
3403 + case NL80211_IFTYPE_P2P_CLIENT:
3404 +- priv->bss_role = MWIFIEX_BSS_ROLE_STA;
3405 ++ priv->bss_role = MWIFIEX_BSS_ROLE_STA;
3406 ++ priv->bss_type = MWIFIEX_BSS_TYPE_P2P;
3407 + break;
3408 + case NL80211_IFTYPE_P2P_GO:
3409 +- priv->bss_role = MWIFIEX_BSS_ROLE_UAP;
3410 ++ priv->bss_role = MWIFIEX_BSS_ROLE_UAP;
3411 ++ priv->bss_type = MWIFIEX_BSS_TYPE_P2P;
3412 + break;
3413 + case NL80211_IFTYPE_AP:
3414 + priv->bss_role = MWIFIEX_BSS_ROLE_UAP;
3415 ++ priv->bss_type = MWIFIEX_BSS_TYPE_UAP;
3416 + break;
3417 + default:
3418 + mwifiex_dbg(adapter, ERROR,
3419 +@@ -1217,29 +1221,15 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
3420 + break;
3421 + case NL80211_IFTYPE_P2P_CLIENT:
3422 + case NL80211_IFTYPE_P2P_GO:
3423 ++ if (mwifiex_cfg80211_deinit_p2p(priv))
3424 ++ return -EFAULT;
3425 ++
3426 + switch (type) {
3427 +- case NL80211_IFTYPE_STATION:
3428 +- if (mwifiex_cfg80211_deinit_p2p(priv))
3429 +- return -EFAULT;
3430 +- priv->adapter->curr_iface_comb.p2p_intf--;
3431 +- priv->adapter->curr_iface_comb.sta_intf++;
3432 +- dev->ieee80211_ptr->iftype = type;
3433 +- if (mwifiex_deinit_priv_params(priv))
3434 +- return -1;
3435 +- if (mwifiex_init_new_priv_params(priv, dev, type))
3436 +- return -1;
3437 +- if (mwifiex_sta_init_cmd(priv, false, false))
3438 +- return -1;
3439 +- break;
3440 + case NL80211_IFTYPE_ADHOC:
3441 +- if (mwifiex_cfg80211_deinit_p2p(priv))
3442 +- return -EFAULT;
3443 ++ case NL80211_IFTYPE_STATION:
3444 + return mwifiex_change_vif_to_sta_adhoc(dev, curr_iftype,
3445 + type, params);
3446 +- break;
3447 + case NL80211_IFTYPE_AP:
3448 +- if (mwifiex_cfg80211_deinit_p2p(priv))
3449 +- return -EFAULT;
3450 + return mwifiex_change_vif_to_ap(dev, curr_iftype, type,
3451 + params);
3452 + case NL80211_IFTYPE_UNSPECIFIED:
3453 +diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
3454 +index 5b12d5191acc5..9fcd070f2463c 100644
3455 +--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
3456 ++++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
3457 +@@ -1316,6 +1316,14 @@ mwifiex_pcie_send_data(struct mwifiex_adapter *adapter, struct sk_buff *skb,
3458 + ret = -1;
3459 + goto done_unmap;
3460 + }
3461 ++
3462 ++ /* The firmware (latest version 15.68.19.p21) of the 88W8897 PCIe+USB card
3463 ++ * seems to crash randomly after setting the TX ring write pointer when
3464 ++ * ASPM powersaving is enabled. A workaround seems to be keeping the bus
3465 ++ * busy by reading a random register afterwards.
3466 ++ */
3467 ++ mwifiex_read_reg(adapter, PCI_VENDOR_ID, &rx_val);
3468 ++
3469 + if ((mwifiex_pcie_txbd_not_full(card)) &&
3470 + tx_param->next_pkt_len) {
3471 + /* have more packets and TxBD still can hold more */
3472 +diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
3473 +index 44d5005188c93..202ce83cb7948 100644
3474 +--- a/drivers/net/wireless/marvell/mwifiex/usb.c
3475 ++++ b/drivers/net/wireless/marvell/mwifiex/usb.c
3476 +@@ -491,6 +491,22 @@ static int mwifiex_usb_probe(struct usb_interface *intf,
3477 + }
3478 + }
3479 +
3480 ++ switch (card->usb_boot_state) {
3481 ++ case USB8XXX_FW_DNLD:
3482 ++ /* Reject broken descriptors. */
3483 ++ if (!card->rx_cmd_ep || !card->tx_cmd_ep)
3484 ++ return -ENODEV;
3485 ++ if (card->bulk_out_maxpktsize == 0)
3486 ++ return -ENODEV;
3487 ++ break;
3488 ++ case USB8XXX_FW_READY:
3489 ++ /* Assume the driver can handle missing endpoints for now. */
3490 ++ break;
3491 ++ default:
3492 ++ WARN_ON(1);
3493 ++ return -ENODEV;
3494 ++ }
3495 ++
3496 + usb_set_intfdata(intf, card);
3497 +
3498 + ret = mwifiex_add_card(card, &card->fw_done, &usb_ops,
3499 +diff --git a/drivers/net/wireless/marvell/mwl8k.c b/drivers/net/wireless/marvell/mwl8k.c
3500 +index e39aaee92addb..d5f766044221a 100644
3501 +--- a/drivers/net/wireless/marvell/mwl8k.c
3502 ++++ b/drivers/net/wireless/marvell/mwl8k.c
3503 +@@ -5788,8 +5788,8 @@ static void mwl8k_fw_state_machine(const struct firmware *fw, void *context)
3504 + fail:
3505 + priv->fw_state = FW_STATE_ERROR;
3506 + complete(&priv->firmware_loading_complete);
3507 +- device_release_driver(&priv->pdev->dev);
3508 + mwl8k_release_firmware(priv);
3509 ++ device_release_driver(&priv->pdev->dev);
3510 + }
3511 +
3512 + #define MAX_RESTART_ATTEMPTS 1
3513 +diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8187/rtl8225.c b/drivers/net/wireless/realtek/rtl818x/rtl8187/rtl8225.c
3514 +index e6668ffb77e65..49fb8bba3d91a 100644
3515 +--- a/drivers/net/wireless/realtek/rtl818x/rtl8187/rtl8225.c
3516 ++++ b/drivers/net/wireless/realtek/rtl818x/rtl8187/rtl8225.c
3517 +@@ -31,7 +31,7 @@ u8 rtl818x_ioread8_idx(struct rtl8187_priv *priv,
3518 + usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0),
3519 + RTL8187_REQ_GET_REG, RTL8187_REQT_READ,
3520 + (unsigned long)addr, idx & 0x03,
3521 +- &priv->io_dmabuf->bits8, sizeof(val), HZ / 2);
3522 ++ &priv->io_dmabuf->bits8, sizeof(val), 500);
3523 +
3524 + val = priv->io_dmabuf->bits8;
3525 + mutex_unlock(&priv->io_mutex);
3526 +@@ -48,7 +48,7 @@ u16 rtl818x_ioread16_idx(struct rtl8187_priv *priv,
3527 + usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0),
3528 + RTL8187_REQ_GET_REG, RTL8187_REQT_READ,
3529 + (unsigned long)addr, idx & 0x03,
3530 +- &priv->io_dmabuf->bits16, sizeof(val), HZ / 2);
3531 ++ &priv->io_dmabuf->bits16, sizeof(val), 500);
3532 +
3533 + val = priv->io_dmabuf->bits16;
3534 + mutex_unlock(&priv->io_mutex);
3535 +@@ -65,7 +65,7 @@ u32 rtl818x_ioread32_idx(struct rtl8187_priv *priv,
3536 + usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0),
3537 + RTL8187_REQ_GET_REG, RTL8187_REQT_READ,
3538 + (unsigned long)addr, idx & 0x03,
3539 +- &priv->io_dmabuf->bits32, sizeof(val), HZ / 2);
3540 ++ &priv->io_dmabuf->bits32, sizeof(val), 500);
3541 +
3542 + val = priv->io_dmabuf->bits32;
3543 + mutex_unlock(&priv->io_mutex);
3544 +@@ -82,7 +82,7 @@ void rtl818x_iowrite8_idx(struct rtl8187_priv *priv,
3545 + usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0),
3546 + RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE,
3547 + (unsigned long)addr, idx & 0x03,
3548 +- &priv->io_dmabuf->bits8, sizeof(val), HZ / 2);
3549 ++ &priv->io_dmabuf->bits8, sizeof(val), 500);
3550 +
3551 + mutex_unlock(&priv->io_mutex);
3552 + }
3553 +@@ -96,7 +96,7 @@ void rtl818x_iowrite16_idx(struct rtl8187_priv *priv,
3554 + usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0),
3555 + RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE,
3556 + (unsigned long)addr, idx & 0x03,
3557 +- &priv->io_dmabuf->bits16, sizeof(val), HZ / 2);
3558 ++ &priv->io_dmabuf->bits16, sizeof(val), 500);
3559 +
3560 + mutex_unlock(&priv->io_mutex);
3561 + }
3562 +@@ -110,7 +110,7 @@ void rtl818x_iowrite32_idx(struct rtl8187_priv *priv,
3563 + usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0),
3564 + RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE,
3565 + (unsigned long)addr, idx & 0x03,
3566 +- &priv->io_dmabuf->bits32, sizeof(val), HZ / 2);
3567 ++ &priv->io_dmabuf->bits32, sizeof(val), 500);
3568 +
3569 + mutex_unlock(&priv->io_mutex);
3570 + }
3571 +@@ -186,7 +186,7 @@ static void rtl8225_write_8051(struct ieee80211_hw *dev, u8 addr, __le16 data)
3572 + usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0),
3573 + RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE,
3574 + addr, 0x8225, &priv->io_dmabuf->bits16, sizeof(data),
3575 +- HZ / 2);
3576 ++ 500);
3577 +
3578 + mutex_unlock(&priv->io_mutex);
3579 +
3580 +diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
3581 +index 1131397454bd4..89e6a50b53da5 100644
3582 +--- a/drivers/net/xen-netfront.c
3583 ++++ b/drivers/net/xen-netfront.c
3584 +@@ -1441,6 +1441,10 @@ static int netfront_resume(struct xenbus_device *dev)
3585 +
3586 + dev_dbg(&dev->dev, "%s\n", dev->nodename);
3587 +
3588 ++ netif_tx_lock_bh(info->netdev);
3589 ++ netif_device_detach(info->netdev);
3590 ++ netif_tx_unlock_bh(info->netdev);
3591 ++
3592 + xennet_disconnect_backend(info);
3593 + return 0;
3594 + }
3595 +@@ -1990,6 +1994,10 @@ static int xennet_connect(struct net_device *dev)
3596 + * domain a kick because we've probably just requeued some
3597 + * packets.
3598 + */
3599 ++ netif_tx_lock_bh(np->netdev);
3600 ++ netif_device_attach(np->netdev);
3601 ++ netif_tx_unlock_bh(np->netdev);
3602 ++
3603 + netif_carrier_on(np->netdev);
3604 + for (j = 0; j < num_queues; ++j) {
3605 + queue = &np->queues[j];
3606 +diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
3607 +index e3026e20f1696..52a1a2cae6c74 100644
3608 +--- a/drivers/nfc/pn533/pn533.c
3609 ++++ b/drivers/nfc/pn533/pn533.c
3610 +@@ -2084,7 +2084,7 @@ static int pn533_fill_fragment_skbs(struct pn533 *dev, struct sk_buff *skb)
3611 + frag = pn533_alloc_skb(dev, frag_size);
3612 + if (!frag) {
3613 + skb_queue_purge(&dev->fragment_skb);
3614 +- break;
3615 ++ return -ENOMEM;
3616 + }
3617 +
3618 + if (!dev->tgt_mode) {
3619 +@@ -2154,7 +2154,7 @@ static int pn533_transceive(struct nfc_dev *nfc_dev,
3620 + /* jumbo frame ? */
3621 + if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
3622 + rc = pn533_fill_fragment_skbs(dev, skb);
3623 +- if (rc <= 0)
3624 ++ if (rc < 0)
3625 + goto error;
3626 +
3627 + skb = skb_dequeue(&dev->fragment_skb);
3628 +@@ -2226,7 +2226,7 @@ static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)
3629 + /* let's split in multiple chunks if size's too big */
3630 + if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
3631 + rc = pn533_fill_fragment_skbs(dev, skb);
3632 +- if (rc <= 0)
3633 ++ if (rc < 0)
3634 + goto error;
3635 +
3636 + /* get the first skb */
3637 +diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
3638 +index 4214f66d405be..a572b2fb7af81 100644
3639 +--- a/drivers/pci/host/pci-aardvark.c
3640 ++++ b/drivers/pci/host/pci-aardvark.c
3641 +@@ -100,18 +100,19 @@
3642 + #define PCIE_ISR0_MSI_INT_PENDING BIT(24)
3643 + #define PCIE_ISR0_INTX_ASSERT(val) BIT(16 + (val))
3644 + #define PCIE_ISR0_INTX_DEASSERT(val) BIT(20 + (val))
3645 +-#define PCIE_ISR0_ALL_MASK GENMASK(26, 0)
3646 ++#define PCIE_ISR0_ALL_MASK GENMASK(31, 0)
3647 + #define PCIE_ISR1_REG (CONTROL_BASE_ADDR + 0x48)
3648 + #define PCIE_ISR1_MASK_REG (CONTROL_BASE_ADDR + 0x4C)
3649 + #define PCIE_ISR1_POWER_STATE_CHANGE BIT(4)
3650 + #define PCIE_ISR1_FLUSH BIT(5)
3651 + #define PCIE_ISR1_INTX_ASSERT(val) BIT(8 + (val))
3652 +-#define PCIE_ISR1_ALL_MASK GENMASK(11, 4)
3653 ++#define PCIE_ISR1_ALL_MASK GENMASK(31, 0)
3654 + #define PCIE_MSI_ADDR_LOW_REG (CONTROL_BASE_ADDR + 0x50)
3655 + #define PCIE_MSI_ADDR_HIGH_REG (CONTROL_BASE_ADDR + 0x54)
3656 + #define PCIE_MSI_STATUS_REG (CONTROL_BASE_ADDR + 0x58)
3657 + #define PCIE_MSI_MASK_REG (CONTROL_BASE_ADDR + 0x5C)
3658 + #define PCIE_MSI_PAYLOAD_REG (CONTROL_BASE_ADDR + 0x9C)
3659 ++#define PCIE_MSI_DATA_MASK GENMASK(15, 0)
3660 +
3661 + /* PCIe window configuration */
3662 + #define OB_WIN_BASE_ADDR 0x4c00
3663 +@@ -169,7 +170,7 @@
3664 + #define PCIE_IRQ_MSI_INT2_DET BIT(21)
3665 + #define PCIE_IRQ_RC_DBELL_DET BIT(22)
3666 + #define PCIE_IRQ_EP_STATUS BIT(23)
3667 +-#define PCIE_IRQ_ALL_MASK 0xfff0fb
3668 ++#define PCIE_IRQ_ALL_MASK GENMASK(31, 0)
3669 + #define PCIE_IRQ_ENABLE_INTS_MASK PCIE_IRQ_CORE_INT
3670 +
3671 + /* Transaction types */
3672 +@@ -447,7 +448,7 @@ static int advk_pcie_check_pio_status(struct advk_pcie *pcie, u32 *val)
3673 + else
3674 + str_posted = "Posted";
3675 +
3676 +- dev_err(dev, "%s PIO Response Status: %s, %#x @ %#x\n",
3677 ++ dev_dbg(dev, "%s PIO Response Status: %s, %#x @ %#x\n",
3678 + str_posted, strcomp_status, reg, advk_readl(pcie, PIO_ADDR_LS));
3679 +
3680 + return -EFAULT;
3681 +@@ -662,7 +663,7 @@ static int advk_msi_irq_domain_alloc(struct irq_domain *domain,
3682 + domain->host_data, handle_simple_irq,
3683 + NULL, NULL);
3684 +
3685 +- return hwirq;
3686 ++ return 0;
3687 + }
3688 +
3689 + static void advk_msi_irq_domain_free(struct irq_domain *domain,
3690 +@@ -840,8 +841,12 @@ static void advk_pcie_handle_msi(struct advk_pcie *pcie)
3691 + if (!(BIT(msi_idx) & msi_status))
3692 + continue;
3693 +
3694 ++ /*
3695 ++ * msi_idx contains bits [4:0] of the msi_data and msi_data
3696 ++ * contains 16bit MSI interrupt number
3697 ++ */
3698 + advk_writel(pcie, BIT(msi_idx), PCIE_MSI_STATUS_REG);
3699 +- msi_data = advk_readl(pcie, PCIE_MSI_PAYLOAD_REG) & 0xFF;
3700 ++ msi_data = advk_readl(pcie, PCIE_MSI_PAYLOAD_REG) & PCIE_MSI_DATA_MASK;
3701 + generic_handle_irq(msi_data);
3702 + }
3703 +
3704 +@@ -863,12 +868,6 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie)
3705 + isr1_mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
3706 + isr1_status = isr1_val & ((~isr1_mask) & PCIE_ISR1_ALL_MASK);
3707 +
3708 +- if (!isr0_status && !isr1_status) {
3709 +- advk_writel(pcie, isr0_val, PCIE_ISR0_REG);
3710 +- advk_writel(pcie, isr1_val, PCIE_ISR1_REG);
3711 +- return;
3712 +- }
3713 +-
3714 + /* Process MSI interrupts */
3715 + if (isr0_status & PCIE_ISR0_MSI_INT_PENDING)
3716 + advk_pcie_handle_msi(pcie);
3717 +diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
3718 +index 2d7b06cfc6064..2c000b9b0a42e 100644
3719 +--- a/drivers/pci/msi.c
3720 ++++ b/drivers/pci/msi.c
3721 +@@ -372,18 +372,6 @@ static void free_msi_irqs(struct pci_dev *dev)
3722 + for (i = 0; i < entry->nvec_used; i++)
3723 + BUG_ON(irq_has_action(entry->irq + i));
3724 +
3725 +- pci_msi_teardown_msi_irqs(dev);
3726 +-
3727 +- list_for_each_entry_safe(entry, tmp, msi_list, list) {
3728 +- if (entry->msi_attrib.is_msix) {
3729 +- if (list_is_last(&entry->list, msi_list))
3730 +- iounmap(entry->mask_base);
3731 +- }
3732 +-
3733 +- list_del(&entry->list);
3734 +- free_msi_entry(entry);
3735 +- }
3736 +-
3737 + if (dev->msi_irq_groups) {
3738 + sysfs_remove_groups(&dev->dev.kobj, dev->msi_irq_groups);
3739 + msi_attrs = dev->msi_irq_groups[0]->attrs;
3740 +@@ -399,6 +387,18 @@ static void free_msi_irqs(struct pci_dev *dev)
3741 + kfree(dev->msi_irq_groups);
3742 + dev->msi_irq_groups = NULL;
3743 + }
3744 ++
3745 ++ pci_msi_teardown_msi_irqs(dev);
3746 ++
3747 ++ list_for_each_entry_safe(entry, tmp, msi_list, list) {
3748 ++ if (entry->msi_attrib.is_msix) {
3749 ++ if (list_is_last(&entry->list, msi_list))
3750 ++ iounmap(entry->mask_base);
3751 ++ }
3752 ++
3753 ++ list_del(&entry->list);
3754 ++ free_msi_entry(entry);
3755 ++ }
3756 + }
3757 +
3758 + static void pci_intx_for_msi(struct pci_dev *dev, int enable)
3759 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
3760 +index eff361af792ad..1bfc24654b581 100644
3761 +--- a/drivers/pci/quirks.c
3762 ++++ b/drivers/pci/quirks.c
3763 +@@ -3414,6 +3414,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0032, quirk_no_bus_reset);
3764 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x003c, quirk_no_bus_reset);
3765 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0033, quirk_no_bus_reset);
3766 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0034, quirk_no_bus_reset);
3767 ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x003e, quirk_no_bus_reset);
3768 +
3769 + /*
3770 + * Some TI KeyStone C667X devices do not support bus/hot reset. The PCIESS
3771 +diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
3772 +index 08ea74177de29..83f439906d316 100644
3773 +--- a/drivers/pinctrl/core.c
3774 ++++ b/drivers/pinctrl/core.c
3775 +@@ -2061,6 +2061,8 @@ int pinctrl_enable(struct pinctrl_dev *pctldev)
3776 + if (error) {
3777 + dev_err(pctldev->dev, "could not claim hogs: %i\n",
3778 + error);
3779 ++ pinctrl_free_pindescs(pctldev, pctldev->desc->pins,
3780 ++ pctldev->desc->npins);
3781 + mutex_destroy(&pctldev->mutex);
3782 + kfree(pctldev);
3783 +
3784 +diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
3785 +index 9c3c83ef445bf..075332c6890d0 100644
3786 +--- a/drivers/platform/x86/hp_accel.c
3787 ++++ b/drivers/platform/x86/hp_accel.c
3788 +@@ -383,9 +383,11 @@ static int lis3lv02d_add(struct acpi_device *device)
3789 + INIT_WORK(&hpled_led.work, delayed_set_status_worker);
3790 + ret = led_classdev_register(NULL, &hpled_led.led_classdev);
3791 + if (ret) {
3792 ++ i8042_remove_filter(hp_accel_i8042_filter);
3793 + lis3lv02d_joystick_disable(&lis3_dev);
3794 + lis3lv02d_poweroff(&lis3_dev);
3795 + flush_work(&hpled_led.work);
3796 ++ lis3lv02d_remove_fs(&lis3_dev);
3797 + return ret;
3798 + }
3799 +
3800 +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
3801 +index 30bc952ea5529..9d836d779d475 100644
3802 +--- a/drivers/platform/x86/thinkpad_acpi.c
3803 ++++ b/drivers/platform/x86/thinkpad_acpi.c
3804 +@@ -8978,7 +8978,7 @@ static int fan_write_cmd_level(const char *cmd, int *rc)
3805 +
3806 + if (strlencmp(cmd, "level auto") == 0)
3807 + level = TP_EC_FAN_AUTO;
3808 +- else if ((strlencmp(cmd, "level disengaged") == 0) |
3809 ++ else if ((strlencmp(cmd, "level disengaged") == 0) ||
3810 + (strlencmp(cmd, "level full-speed") == 0))
3811 + level = TP_EC_FAN_FULLSPEED;
3812 + else if (sscanf(cmd, "level %d", &level) != 1)
3813 +diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
3814 +index a56e997816b23..07c1e0829b19a 100644
3815 +--- a/drivers/platform/x86/wmi.c
3816 ++++ b/drivers/platform/x86/wmi.c
3817 +@@ -307,7 +307,14 @@ static acpi_status __query_block(struct wmi_block *wblock, u8 instance,
3818 + * the WQxx method failed - we should disable collection anyway.
3819 + */
3820 + if ((block->flags & ACPI_WMI_EXPENSIVE) && ACPI_SUCCESS(wc_status)) {
3821 +- status = acpi_execute_simple_method(handle, wc_method, 0);
3822 ++ /*
3823 ++ * Ignore whether this WCxx call succeeds or not since
3824 ++ * the previously executed WQxx method call might have
3825 ++ * succeeded, and returning the failing status code
3826 ++ * of this call would throw away the result of the WQxx
3827 ++ * call, potentially leaking memory.
3828 ++ */
3829 ++ acpi_execute_simple_method(handle, wc_method, 0);
3830 + }
3831 +
3832 + return status;
3833 +diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
3834 +index 0b11ed472f338..12ffe62caa17b 100644
3835 +--- a/drivers/power/supply/bq27xxx_battery_i2c.c
3836 ++++ b/drivers/power/supply/bq27xxx_battery_i2c.c
3837 +@@ -195,7 +195,8 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client,
3838 + dev_err(&client->dev,
3839 + "Unable to register IRQ %d error %d\n",
3840 + client->irq, ret);
3841 +- return ret;
3842 ++ bq27xxx_battery_teardown(di);
3843 ++ goto err_failed;
3844 + }
3845 + }
3846 +
3847 +diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
3848 +index fe5331b23a948..4c8c86f8de3ed 100644
3849 +--- a/drivers/power/supply/max17042_battery.c
3850 ++++ b/drivers/power/supply/max17042_battery.c
3851 +@@ -303,7 +303,10 @@ static int max17042_get_property(struct power_supply *psy,
3852 + val->intval = data * 625 / 8;
3853 + break;
3854 + case POWER_SUPPLY_PROP_CAPACITY:
3855 +- ret = regmap_read(map, MAX17042_RepSOC, &data);
3856 ++ if (chip->pdata->enable_current_sense)
3857 ++ ret = regmap_read(map, MAX17042_RepSOC, &data);
3858 ++ else
3859 ++ ret = regmap_read(map, MAX17042_VFSOC, &data);
3860 + if (ret < 0)
3861 + return ret;
3862 +
3863 +@@ -825,7 +828,8 @@ static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off)
3864 + regmap_read(map, MAX17042_RepSOC, &soc);
3865 + soc >>= 8;
3866 + soc_tr = (soc + off) << 8;
3867 +- soc_tr |= (soc - off);
3868 ++ if (off < soc)
3869 ++ soc_tr |= soc - off;
3870 + regmap_write(map, MAX17042_SALRT_Th, soc_tr);
3871 + }
3872 +
3873 +diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c
3874 +index 9310b85f3405e..7eec7014086d8 100644
3875 +--- a/drivers/power/supply/rt5033_battery.c
3876 ++++ b/drivers/power/supply/rt5033_battery.c
3877 +@@ -63,7 +63,7 @@ static int rt5033_battery_get_watt_prop(struct i2c_client *client,
3878 + regmap_read(battery->regmap, regh, &msb);
3879 + regmap_read(battery->regmap, regl, &lsb);
3880 +
3881 +- ret = ((msb << 4) + (lsb >> 4)) * 1250 / 1000;
3882 ++ ret = ((msb << 4) + (lsb >> 4)) * 1250;
3883 +
3884 + return ret;
3885 + }
3886 +diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
3887 +index 4836947e1521d..d558f806a4705 100644
3888 +--- a/drivers/regulator/s5m8767.c
3889 ++++ b/drivers/regulator/s5m8767.c
3890 +@@ -845,18 +845,15 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
3891 + /* DS4 GPIO */
3892 + gpio_direction_output(pdata->buck_ds[2], 0x0);
3893 +
3894 +- if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs ||
3895 +- pdata->buck4_gpiodvs) {
3896 +- regmap_update_bits(s5m8767->iodev->regmap_pmic,
3897 +- S5M8767_REG_BUCK2CTRL, 1 << 1,
3898 +- (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1));
3899 +- regmap_update_bits(s5m8767->iodev->regmap_pmic,
3900 +- S5M8767_REG_BUCK3CTRL, 1 << 1,
3901 +- (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1));
3902 +- regmap_update_bits(s5m8767->iodev->regmap_pmic,
3903 +- S5M8767_REG_BUCK4CTRL, 1 << 1,
3904 +- (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1));
3905 +- }
3906 ++ regmap_update_bits(s5m8767->iodev->regmap_pmic,
3907 ++ S5M8767_REG_BUCK2CTRL, 1 << 1,
3908 ++ (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1));
3909 ++ regmap_update_bits(s5m8767->iodev->regmap_pmic,
3910 ++ S5M8767_REG_BUCK3CTRL, 1 << 1,
3911 ++ (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1));
3912 ++ regmap_update_bits(s5m8767->iodev->regmap_pmic,
3913 ++ S5M8767_REG_BUCK4CTRL, 1 << 1,
3914 ++ (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1));
3915 +
3916 + /* Initialize GPIO DVS registers */
3917 + for (i = 0; i < 8; i++) {
3918 +diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
3919 +index 435e804b6b8b1..cf00baa3142f4 100644
3920 +--- a/drivers/s390/cio/css.c
3921 ++++ b/drivers/s390/cio/css.c
3922 +@@ -337,8 +337,8 @@ static ssize_t dev_busid_show(struct device *dev,
3923 + struct subchannel *sch = to_subchannel(dev);
3924 + struct pmcw *pmcw = &sch->schib.pmcw;
3925 +
3926 +- if ((pmcw->st == SUBCHANNEL_TYPE_IO ||
3927 +- pmcw->st == SUBCHANNEL_TYPE_MSG) && pmcw->dnv)
3928 ++ if ((pmcw->st == SUBCHANNEL_TYPE_IO && pmcw->dnv) ||
3929 ++ (pmcw->st == SUBCHANNEL_TYPE_MSG && pmcw->w))
3930 + return sysfs_emit(buf, "0.%x.%04x\n", sch->schid.ssid,
3931 + pmcw->dev);
3932 + else
3933 +diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
3934 +index 24e57e770432b..6efd17692a55a 100644
3935 +--- a/drivers/scsi/advansys.c
3936 ++++ b/drivers/scsi/advansys.c
3937 +@@ -3370,8 +3370,8 @@ static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost)
3938 + shost->host_no);
3939 +
3940 + seq_printf(m,
3941 +- " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
3942 +- (unsigned long)v->iop_base,
3943 ++ " iop_base 0x%p, cable_detect: %X, err_code %u\n",
3944 ++ v->iop_base,
3945 + AdvReadWordRegister(iop_base,IOPW_SCSI_CFG1) & CABLE_DETECT,
3946 + v->err_code);
3947 +
3948 +diff --git a/drivers/scsi/csiostor/csio_lnode.c b/drivers/scsi/csiostor/csio_lnode.c
3949 +index 957767d383610..d1df694d9ed00 100644
3950 +--- a/drivers/scsi/csiostor/csio_lnode.c
3951 ++++ b/drivers/scsi/csiostor/csio_lnode.c
3952 +@@ -611,7 +611,7 @@ csio_ln_vnp_read_cbfn(struct csio_hw *hw, struct csio_mb *mbp)
3953 + struct fc_els_csp *csp;
3954 + struct fc_els_cssp *clsp;
3955 + enum fw_retval retval;
3956 +- __be32 nport_id;
3957 ++ __be32 nport_id = 0;
3958 +
3959 + retval = FW_CMD_RETVAL_G(ntohl(rsp->alloc_to_len16));
3960 + if (retval != FW_SUCCESS) {
3961 +diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
3962 +index 830b2d2dcf206..8490d0ff04ca7 100644
3963 +--- a/drivers/scsi/dc395x.c
3964 ++++ b/drivers/scsi/dc395x.c
3965 +@@ -4809,6 +4809,7 @@ static int dc395x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
3966 + /* initialise the adapter and everything we need */
3967 + if (adapter_init(acb, io_port_base, io_port_len, irq)) {
3968 + dprintkl(KERN_INFO, "adapter init failed\n");
3969 ++ acb = NULL;
3970 + goto fail;
3971 + }
3972 +
3973 +diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
3974 +index 20deb6715c36e..6f9ba3272721a 100644
3975 +--- a/drivers/scsi/lpfc/lpfc_sli.c
3976 ++++ b/drivers/scsi/lpfc/lpfc_sli.c
3977 +@@ -18777,6 +18777,7 @@ lpfc_drain_txq(struct lpfc_hba *phba)
3978 + fail_msg,
3979 + piocbq->iotag, piocbq->sli4_xritag);
3980 + list_add_tail(&piocbq->list, &completions);
3981 ++ fail_msg = NULL;
3982 + }
3983 + spin_unlock_irqrestore(&pring->ring_lock, iflags);
3984 + }
3985 +diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
3986 +index 89706341514e2..a9df91f7c1543 100644
3987 +--- a/drivers/scsi/qla2xxx/qla_gbl.h
3988 ++++ b/drivers/scsi/qla2xxx/qla_gbl.h
3989 +@@ -132,7 +132,6 @@ extern int ql2xasynctmfenable;
3990 + extern int ql2xgffidenable;
3991 + extern int ql2xenabledif;
3992 + extern int ql2xenablehba_err_chk;
3993 +-extern int ql2xtargetreset;
3994 + extern int ql2xdontresethba;
3995 + extern uint64_t ql2xmaxlun;
3996 + extern int ql2xmdcapmask;
3997 +@@ -724,7 +723,6 @@ extern void qlafx00_abort_iocb(srb_t *, struct abort_iocb_entry_fx00 *);
3998 + extern void qlafx00_fxdisc_iocb(srb_t *, struct fxdisc_entry_fx00 *);
3999 + extern void qlafx00_timer_routine(scsi_qla_host_t *);
4000 + extern int qlafx00_rescan_isp(scsi_qla_host_t *);
4001 +-extern int qlafx00_loop_reset(scsi_qla_host_t *vha);
4002 +
4003 + /* qla82xx related functions */
4004 +
4005 +diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c
4006 +index e23a3d4c36f39..66ee206026612 100644
4007 +--- a/drivers/scsi/qla2xxx/qla_mr.c
4008 ++++ b/drivers/scsi/qla2xxx/qla_mr.c
4009 +@@ -739,29 +739,6 @@ qlafx00_lun_reset(fc_port_t *fcport, uint64_t l, int tag)
4010 + return qla2x00_async_tm_cmd(fcport, TCF_LUN_RESET, l, tag);
4011 + }
4012 +
4013 +-int
4014 +-qlafx00_loop_reset(scsi_qla_host_t *vha)
4015 +-{
4016 +- int ret;
4017 +- struct fc_port *fcport;
4018 +- struct qla_hw_data *ha = vha->hw;
4019 +-
4020 +- if (ql2xtargetreset) {
4021 +- list_for_each_entry(fcport, &vha->vp_fcports, list) {
4022 +- if (fcport->port_type != FCT_TARGET)
4023 +- continue;
4024 +-
4025 +- ret = ha->isp_ops->target_reset(fcport, 0, 0);
4026 +- if (ret != QLA_SUCCESS) {
4027 +- ql_dbg(ql_dbg_taskm, vha, 0x803d,
4028 +- "Bus Reset failed: Reset=%d "
4029 +- "d_id=%x.\n", ret, fcport->d_id.b24);
4030 +- }
4031 +- }
4032 +- }
4033 +- return QLA_SUCCESS;
4034 +-}
4035 +-
4036 + int
4037 + qlafx00_iospace_config(struct qla_hw_data *ha)
4038 + {
4039 +diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
4040 +index ea60c6e603c06..d0f52c123bfb3 100644
4041 +--- a/drivers/scsi/qla2xxx/qla_os.c
4042 ++++ b/drivers/scsi/qla2xxx/qla_os.c
4043 +@@ -188,12 +188,6 @@ MODULE_PARM_DESC(ql2xdbwr,
4044 + " 0 -- Regular doorbell.\n"
4045 + " 1 -- CAMRAM doorbell (faster).\n");
4046 +
4047 +-int ql2xtargetreset = 1;
4048 +-module_param(ql2xtargetreset, int, S_IRUGO);
4049 +-MODULE_PARM_DESC(ql2xtargetreset,
4050 +- "Enable target reset."
4051 +- "Default is 1 - use hw defaults.");
4052 +-
4053 + int ql2xgffidenable;
4054 + module_param(ql2xgffidenable, int, S_IRUGO);
4055 + MODULE_PARM_DESC(ql2xgffidenable,
4056 +@@ -1652,27 +1646,10 @@ int
4057 + qla2x00_loop_reset(scsi_qla_host_t *vha)
4058 + {
4059 + int ret;
4060 +- struct fc_port *fcport;
4061 + struct qla_hw_data *ha = vha->hw;
4062 +
4063 +- if (IS_QLAFX00(ha)) {
4064 +- return qlafx00_loop_reset(vha);
4065 +- }
4066 +-
4067 +- if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) {
4068 +- list_for_each_entry(fcport, &vha->vp_fcports, list) {
4069 +- if (fcport->port_type != FCT_TARGET)
4070 +- continue;
4071 +-
4072 +- ret = ha->isp_ops->target_reset(fcport, 0, 0);
4073 +- if (ret != QLA_SUCCESS) {
4074 +- ql_dbg(ql_dbg_taskm, vha, 0x802c,
4075 +- "Bus Reset failed: Reset=%d "
4076 +- "d_id=%x.\n", ret, fcport->d_id.b24);
4077 +- }
4078 +- }
4079 +- }
4080 +-
4081 ++ if (IS_QLAFX00(ha))
4082 ++ return QLA_SUCCESS;
4083 +
4084 + if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) {
4085 + atomic_set(&vha->loop_state, LOOP_DOWN);
4086 +diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
4087 +index bd8f9b03386ad..cb2db1c1e9f2a 100644
4088 +--- a/drivers/scsi/qla2xxx/qla_target.c
4089 ++++ b/drivers/scsi/qla2xxx/qla_target.c
4090 +@@ -3095,8 +3095,7 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type,
4091 + "RESET-RSP online/active/old-count/new-count = %d/%d/%d/%d.\n",
4092 + vha->flags.online, qla2x00_reset_active(vha),
4093 + cmd->reset_count, qpair->chip_reset);
4094 +- spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
4095 +- return 0;
4096 ++ goto out_unmap_unlock;
4097 + }
4098 +
4099 + /* Does F/W have an IOCBs for this request */
4100 +@@ -3218,10 +3217,6 @@ int qlt_rdy_to_xfer(struct qla_tgt_cmd *cmd)
4101 + prm.sg = NULL;
4102 + prm.req_cnt = 1;
4103 +
4104 +- /* Calculate number of entries and segments required */
4105 +- if (qlt_pci_map_calc_cnt(&prm) != 0)
4106 +- return -EAGAIN;
4107 +-
4108 + if (!qpair->fw_started || (cmd->reset_count != qpair->chip_reset) ||
4109 + (cmd->sess && cmd->sess->deleted)) {
4110 + /*
4111 +@@ -3237,6 +3232,10 @@ int qlt_rdy_to_xfer(struct qla_tgt_cmd *cmd)
4112 + return 0;
4113 + }
4114 +
4115 ++ /* Calculate number of entries and segments required */
4116 ++ if (qlt_pci_map_calc_cnt(&prm) != 0)
4117 ++ return -EAGAIN;
4118 ++
4119 + spin_lock_irqsave(qpair->qp_lock_ptr, flags);
4120 + /* Does F/W have an IOCBs for this request */
4121 + res = qlt_check_reserve_free_req(qpair, prm.req_cnt);
4122 +@@ -3671,9 +3670,6 @@ void qlt_free_cmd(struct qla_tgt_cmd *cmd)
4123 +
4124 + BUG_ON(cmd->cmd_in_wq);
4125 +
4126 +- if (cmd->sg_mapped)
4127 +- qlt_unmap_sg(cmd->vha, cmd);
4128 +-
4129 + if (!cmd->q_full)
4130 + qlt_decr_num_pend_cmds(cmd->vha);
4131 +
4132 +diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
4133 +index bec81c2404f78..1682fa3671bc3 100644
4134 +--- a/drivers/sh/maple/maple.c
4135 ++++ b/drivers/sh/maple/maple.c
4136 +@@ -835,8 +835,10 @@ static int __init maple_bus_init(void)
4137 +
4138 + maple_queue_cache = KMEM_CACHE(maple_buffer, SLAB_HWCACHE_ALIGN);
4139 +
4140 +- if (!maple_queue_cache)
4141 ++ if (!maple_queue_cache) {
4142 ++ retval = -ENOMEM;
4143 + goto cleanup_bothirqs;
4144 ++ }
4145 +
4146 + INIT_LIST_HEAD(&maple_waitq);
4147 + INIT_LIST_HEAD(&maple_sentq);
4148 +@@ -849,6 +851,7 @@ static int __init maple_bus_init(void)
4149 + if (!mdev[i]) {
4150 + while (i-- > 0)
4151 + maple_free_dev(mdev[i]);
4152 ++ retval = -ENOMEM;
4153 + goto cleanup_cache;
4154 + }
4155 + baseunits[i] = mdev[i];
4156 +diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
4157 +index 2422ed56895af..3574021a0a369 100644
4158 +--- a/drivers/soc/tegra/pmc.c
4159 ++++ b/drivers/soc/tegra/pmc.c
4160 +@@ -395,7 +395,7 @@ static int tegra_powergate_power_up(struct tegra_powergate *pg,
4161 +
4162 + err = tegra_powergate_enable_clocks(pg);
4163 + if (err)
4164 +- goto disable_clks;
4165 ++ goto powergate_off;
4166 +
4167 + usleep_range(10, 20);
4168 +
4169 +@@ -407,7 +407,7 @@ static int tegra_powergate_power_up(struct tegra_powergate *pg,
4170 +
4171 + err = tegra_powergate_reset_deassert(pg);
4172 + if (err)
4173 +- goto powergate_off;
4174 ++ goto disable_clks;
4175 +
4176 + usleep_range(10, 20);
4177 +
4178 +diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c
4179 +index 11adc2c13a74c..298b1dd463800 100644
4180 +--- a/drivers/spi/spi-bcm-qspi.c
4181 ++++ b/drivers/spi/spi-bcm-qspi.c
4182 +@@ -1301,7 +1301,7 @@ int bcm_qspi_probe(struct platform_device *pdev,
4183 + &qspi->dev_ids[val]);
4184 + if (ret < 0) {
4185 + dev_err(&pdev->dev, "IRQ %s not found\n", name);
4186 +- goto qspi_probe_err;
4187 ++ goto qspi_unprepare_err;
4188 + }
4189 +
4190 + qspi->dev_ids[val].dev = qspi;
4191 +@@ -1316,7 +1316,7 @@ int bcm_qspi_probe(struct platform_device *pdev,
4192 + if (!num_ints) {
4193 + dev_err(&pdev->dev, "no IRQs registered, cannot init driver\n");
4194 + ret = -EINVAL;
4195 +- goto qspi_probe_err;
4196 ++ goto qspi_unprepare_err;
4197 + }
4198 +
4199 + /*
4200 +@@ -1367,6 +1367,7 @@ int bcm_qspi_probe(struct platform_device *pdev,
4201 +
4202 + qspi_reg_err:
4203 + bcm_qspi_hw_uninit(qspi);
4204 ++qspi_unprepare_err:
4205 + clk_disable_unprepare(qspi->clk);
4206 + qspi_probe_err:
4207 + kfree(qspi->dev_ids);
4208 +diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
4209 +index 4797c57f42630..6d849945e87a2 100644
4210 +--- a/drivers/spi/spi-pl022.c
4211 ++++ b/drivers/spi/spi-pl022.c
4212 +@@ -1703,12 +1703,13 @@ static int verify_controller_parameters(struct pl022 *pl022,
4213 + return -EINVAL;
4214 + }
4215 + } else {
4216 +- if (chip_info->duplex != SSP_MICROWIRE_CHANNEL_FULL_DUPLEX)
4217 ++ if (chip_info->duplex != SSP_MICROWIRE_CHANNEL_FULL_DUPLEX) {
4218 + dev_err(&pl022->adev->dev,
4219 + "Microwire half duplex mode requested,"
4220 + " but this is only available in the"
4221 + " ST version of PL022\n");
4222 +- return -EINVAL;
4223 ++ return -EINVAL;
4224 ++ }
4225 + }
4226 + }
4227 + return 0;
4228 +diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
4229 +index 928127642574b..18e67230fc6a3 100644
4230 +--- a/drivers/target/target_core_alua.c
4231 ++++ b/drivers/target/target_core_alua.c
4232 +@@ -1711,7 +1711,6 @@ int core_alua_set_tg_pt_gp_id(
4233 + pr_err("Maximum ALUA alua_tg_pt_gps_count:"
4234 + " 0x0000ffff reached\n");
4235 + spin_unlock(&dev->t10_alua.tg_pt_gps_lock);
4236 +- kmem_cache_free(t10_alua_tg_pt_gp_cache, tg_pt_gp);
4237 + return -ENOSPC;
4238 + }
4239 + again:
4240 +diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
4241 +index cebef8e5a43d1..68b2fa562201c 100644
4242 +--- a/drivers/target/target_core_device.c
4243 ++++ b/drivers/target/target_core_device.c
4244 +@@ -791,6 +791,8 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
4245 + INIT_LIST_HEAD(&dev->t10_alua.lba_map_list);
4246 + spin_lock_init(&dev->t10_alua.lba_map_lock);
4247 +
4248 ++ INIT_WORK(&dev->delayed_cmd_work, target_do_delayed_work);
4249 ++
4250 + dev->t10_wwn.t10_dev = dev;
4251 + dev->t10_alua.t10_dev = dev;
4252 +
4253 +diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
4254 +index 18e3eb16e7567..7060be69dc6a3 100644
4255 +--- a/drivers/target/target_core_internal.h
4256 ++++ b/drivers/target/target_core_internal.h
4257 +@@ -149,6 +149,7 @@ void transport_clear_lun_ref(struct se_lun *);
4258 + void transport_send_task_abort(struct se_cmd *);
4259 + sense_reason_t target_cmd_size_check(struct se_cmd *cmd, unsigned int size);
4260 + void target_qf_do_work(struct work_struct *work);
4261 ++void target_do_delayed_work(struct work_struct *work);
4262 + bool target_check_wce(struct se_device *dev);
4263 + bool target_check_fua(struct se_device *dev);
4264 + void __target_execute_cmd(struct se_cmd *, bool);
4265 +diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
4266 +index 852680e859217..c20997bf314e9 100644
4267 +--- a/drivers/target/target_core_transport.c
4268 ++++ b/drivers/target/target_core_transport.c
4269 +@@ -1914,32 +1914,35 @@ static bool target_handle_task_attr(struct se_cmd *cmd)
4270 + */
4271 + switch (cmd->sam_task_attr) {
4272 + case TCM_HEAD_TAG:
4273 ++ atomic_inc_mb(&dev->non_ordered);
4274 + pr_debug("Added HEAD_OF_QUEUE for CDB: 0x%02x\n",
4275 + cmd->t_task_cdb[0]);
4276 + return false;
4277 + case TCM_ORDERED_TAG:
4278 +- atomic_inc_mb(&dev->dev_ordered_sync);
4279 ++ atomic_inc_mb(&dev->delayed_cmd_count);
4280 +
4281 + pr_debug("Added ORDERED for CDB: 0x%02x to ordered list\n",
4282 + cmd->t_task_cdb[0]);
4283 +-
4284 +- /*
4285 +- * Execute an ORDERED command if no other older commands
4286 +- * exist that need to be completed first.
4287 +- */
4288 +- if (!atomic_read(&dev->simple_cmds))
4289 +- return false;
4290 + break;
4291 + default:
4292 + /*
4293 + * For SIMPLE and UNTAGGED Task Attribute commands
4294 + */
4295 +- atomic_inc_mb(&dev->simple_cmds);
4296 ++ atomic_inc_mb(&dev->non_ordered);
4297 ++
4298 ++ if (atomic_read(&dev->delayed_cmd_count) == 0)
4299 ++ return false;
4300 + break;
4301 + }
4302 +
4303 +- if (atomic_read(&dev->dev_ordered_sync) == 0)
4304 +- return false;
4305 ++ if (cmd->sam_task_attr != TCM_ORDERED_TAG) {
4306 ++ atomic_inc_mb(&dev->delayed_cmd_count);
4307 ++ /*
4308 ++ * We will account for this when we dequeue from the delayed
4309 ++ * list.
4310 ++ */
4311 ++ atomic_dec_mb(&dev->non_ordered);
4312 ++ }
4313 +
4314 + spin_lock(&dev->delayed_cmd_lock);
4315 + list_add_tail(&cmd->se_delayed_node, &dev->delayed_cmd_list);
4316 +@@ -1947,6 +1950,12 @@ static bool target_handle_task_attr(struct se_cmd *cmd)
4317 +
4318 + pr_debug("Added CDB: 0x%02x Task Attr: 0x%02x to delayed CMD listn",
4319 + cmd->t_task_cdb[0], cmd->sam_task_attr);
4320 ++ /*
4321 ++ * We may have no non ordered cmds when this function started or we
4322 ++ * could have raced with the last simple/head cmd completing, so kick
4323 ++ * the delayed handler here.
4324 ++ */
4325 ++ schedule_work(&dev->delayed_cmd_work);
4326 + return true;
4327 + }
4328 +
4329 +@@ -1997,29 +2006,48 @@ EXPORT_SYMBOL(target_execute_cmd);
4330 + * Process all commands up to the last received ORDERED task attribute which
4331 + * requires another blocking boundary
4332 + */
4333 +-static void target_restart_delayed_cmds(struct se_device *dev)
4334 ++void target_do_delayed_work(struct work_struct *work)
4335 + {
4336 +- for (;;) {
4337 ++ struct se_device *dev = container_of(work, struct se_device,
4338 ++ delayed_cmd_work);
4339 ++
4340 ++ spin_lock(&dev->delayed_cmd_lock);
4341 ++ while (!dev->ordered_sync_in_progress) {
4342 + struct se_cmd *cmd;
4343 +
4344 +- spin_lock(&dev->delayed_cmd_lock);
4345 +- if (list_empty(&dev->delayed_cmd_list)) {
4346 +- spin_unlock(&dev->delayed_cmd_lock);
4347 ++ if (list_empty(&dev->delayed_cmd_list))
4348 + break;
4349 +- }
4350 +
4351 + cmd = list_entry(dev->delayed_cmd_list.next,
4352 + struct se_cmd, se_delayed_node);
4353 ++
4354 ++ if (cmd->sam_task_attr == TCM_ORDERED_TAG) {
4355 ++ /*
4356 ++ * Check if we started with:
4357 ++ * [ordered] [simple] [ordered]
4358 ++ * and we are now at the last ordered so we have to wait
4359 ++ * for the simple cmd.
4360 ++ */
4361 ++ if (atomic_read(&dev->non_ordered) > 0)
4362 ++ break;
4363 ++
4364 ++ dev->ordered_sync_in_progress = true;
4365 ++ }
4366 ++
4367 + list_del(&cmd->se_delayed_node);
4368 ++ atomic_dec_mb(&dev->delayed_cmd_count);
4369 + spin_unlock(&dev->delayed_cmd_lock);
4370 +
4371 ++ if (cmd->sam_task_attr != TCM_ORDERED_TAG)
4372 ++ atomic_inc_mb(&dev->non_ordered);
4373 ++
4374 + cmd->transport_state |= CMD_T_SENT;
4375 +
4376 + __target_execute_cmd(cmd, true);
4377 +
4378 +- if (cmd->sam_task_attr == TCM_ORDERED_TAG)
4379 +- break;
4380 ++ spin_lock(&dev->delayed_cmd_lock);
4381 + }
4382 ++ spin_unlock(&dev->delayed_cmd_lock);
4383 + }
4384 +
4385 + /*
4386 +@@ -2037,14 +2065,17 @@ static void transport_complete_task_attr(struct se_cmd *cmd)
4387 + goto restart;
4388 +
4389 + if (cmd->sam_task_attr == TCM_SIMPLE_TAG) {
4390 +- atomic_dec_mb(&dev->simple_cmds);
4391 ++ atomic_dec_mb(&dev->non_ordered);
4392 + dev->dev_cur_ordered_id++;
4393 + } else if (cmd->sam_task_attr == TCM_HEAD_TAG) {
4394 ++ atomic_dec_mb(&dev->non_ordered);
4395 + dev->dev_cur_ordered_id++;
4396 + pr_debug("Incremented dev_cur_ordered_id: %u for HEAD_OF_QUEUE\n",
4397 + dev->dev_cur_ordered_id);
4398 + } else if (cmd->sam_task_attr == TCM_ORDERED_TAG) {
4399 +- atomic_dec_mb(&dev->dev_ordered_sync);
4400 ++ spin_lock(&dev->delayed_cmd_lock);
4401 ++ dev->ordered_sync_in_progress = false;
4402 ++ spin_unlock(&dev->delayed_cmd_lock);
4403 +
4404 + dev->dev_cur_ordered_id++;
4405 + pr_debug("Incremented dev_cur_ordered_id: %u for ORDERED\n",
4406 +@@ -2053,7 +2084,8 @@ static void transport_complete_task_attr(struct se_cmd *cmd)
4407 + cmd->se_cmd_flags &= ~SCF_TASK_ATTR_SET;
4408 +
4409 + restart:
4410 +- target_restart_delayed_cmds(dev);
4411 ++ if (atomic_read(&dev->delayed_cmd_count) > 0)
4412 ++ schedule_work(&dev->delayed_cmd_work);
4413 + }
4414 +
4415 + static void transport_complete_qf(struct se_cmd *cmd)
4416 +diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
4417 +index 4ca46aa64699d..8db5883803c9a 100644
4418 +--- a/drivers/tty/serial/8250/8250_dw.c
4419 ++++ b/drivers/tty/serial/8250/8250_dw.c
4420 +@@ -683,7 +683,7 @@ static struct platform_driver dw8250_platform_driver = {
4421 + .name = "dw-apb-uart",
4422 + .pm = &dw8250_pm_ops,
4423 + .of_match_table = dw8250_of_match,
4424 +- .acpi_match_table = ACPI_PTR(dw8250_acpi_match),
4425 ++ .acpi_match_table = dw8250_acpi_match,
4426 + },
4427 + .probe = dw8250_probe,
4428 + .remove = dw8250_remove,
4429 +diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
4430 +index 3a9e27dd171eb..599d8a4f124a6 100644
4431 +--- a/drivers/tty/serial/serial_core.c
4432 ++++ b/drivers/tty/serial/serial_core.c
4433 +@@ -232,7 +232,11 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
4434 + if (retval == 0) {
4435 + if (uart_console(uport) && uport->cons->cflag) {
4436 + tty->termios.c_cflag = uport->cons->cflag;
4437 ++ tty->termios.c_ispeed = uport->cons->ispeed;
4438 ++ tty->termios.c_ospeed = uport->cons->ospeed;
4439 + uport->cons->cflag = 0;
4440 ++ uport->cons->ispeed = 0;
4441 ++ uport->cons->ospeed = 0;
4442 + }
4443 + /*
4444 + * Initialise the hardware port settings.
4445 +@@ -300,8 +304,11 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
4446 + /*
4447 + * Turn off DTR and RTS early.
4448 + */
4449 +- if (uport && uart_console(uport) && tty)
4450 ++ if (uport && uart_console(uport) && tty) {
4451 + uport->cons->cflag = tty->termios.c_cflag;
4452 ++ uport->cons->ispeed = tty->termios.c_ispeed;
4453 ++ uport->cons->ospeed = tty->termios.c_ospeed;
4454 ++ }
4455 +
4456 + if (!tty || C_HUPCL(tty))
4457 + uart_port_dtr_rts(uport, 0);
4458 +@@ -2076,8 +2083,11 @@ uart_set_options(struct uart_port *port, struct console *co,
4459 + * Allow the setting of the UART parameters with a NULL console
4460 + * too:
4461 + */
4462 +- if (co)
4463 ++ if (co) {
4464 + co->cflag = termios.c_cflag;
4465 ++ co->ispeed = termios.c_ispeed;
4466 ++ co->ospeed = termios.c_ospeed;
4467 ++ }
4468 +
4469 + return 0;
4470 + }
4471 +@@ -2211,6 +2221,8 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
4472 + */
4473 + memset(&termios, 0, sizeof(struct ktermios));
4474 + termios.c_cflag = uport->cons->cflag;
4475 ++ termios.c_ispeed = uport->cons->ispeed;
4476 ++ termios.c_ospeed = uport->cons->ospeed;
4477 +
4478 + /*
4479 + * If that's unset, use the tty termios setting.
4480 +diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
4481 +index 00a740b8ad273..cdd81c28893a0 100644
4482 +--- a/drivers/tty/serial/xilinx_uartps.c
4483 ++++ b/drivers/tty/serial/xilinx_uartps.c
4484 +@@ -595,9 +595,10 @@ static void cdns_uart_start_tx(struct uart_port *port)
4485 + if (uart_circ_empty(&port->state->xmit))
4486 + return;
4487 +
4488 ++ writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_ISR);
4489 ++
4490 + cdns_uart_handle_tx(port);
4491 +
4492 +- writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_ISR);
4493 + /* Enable the TX Empty interrupt */
4494 + writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IER);
4495 + }
4496 +diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
4497 +index cf11882d26025..a5b32dd056bef 100644
4498 +--- a/drivers/tty/tty_buffer.c
4499 ++++ b/drivers/tty/tty_buffer.c
4500 +@@ -528,6 +528,9 @@ static void flush_to_ldisc(struct work_struct *work)
4501 + if (!count)
4502 + break;
4503 + head->read += count;
4504 ++
4505 ++ if (need_resched())
4506 ++ cond_resched();
4507 + }
4508 +
4509 + mutex_unlock(&buf->lock);
4510 +diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
4511 +index 77410fb42eab0..7142baf654bc9 100644
4512 +--- a/drivers/usb/chipidea/core.c
4513 ++++ b/drivers/usb/chipidea/core.c
4514 +@@ -535,7 +535,7 @@ int hw_device_reset(struct ci_hdrc *ci)
4515 + return 0;
4516 + }
4517 +
4518 +-static irqreturn_t ci_irq(int irq, void *data)
4519 ++static irqreturn_t ci_irq_handler(int irq, void *data)
4520 + {
4521 + struct ci_hdrc *ci = data;
4522 + irqreturn_t ret = IRQ_NONE;
4523 +@@ -588,6 +588,15 @@ static irqreturn_t ci_irq(int irq, void *data)
4524 + return ret;
4525 + }
4526 +
4527 ++static void ci_irq(struct ci_hdrc *ci)
4528 ++{
4529 ++ unsigned long flags;
4530 ++
4531 ++ local_irq_save(flags);
4532 ++ ci_irq_handler(ci->irq, ci);
4533 ++ local_irq_restore(flags);
4534 ++}
4535 ++
4536 + static int ci_cable_notifier(struct notifier_block *nb, unsigned long event,
4537 + void *ptr)
4538 + {
4539 +@@ -597,7 +606,7 @@ static int ci_cable_notifier(struct notifier_block *nb, unsigned long event,
4540 + cbl->connected = event;
4541 + cbl->changed = true;
4542 +
4543 +- ci_irq(ci->irq, ci);
4544 ++ ci_irq(ci);
4545 + return NOTIFY_DONE;
4546 + }
4547 +
4548 +@@ -1051,7 +1060,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
4549 + }
4550 + }
4551 +
4552 +- ret = devm_request_irq(dev, ci->irq, ci_irq, IRQF_SHARED,
4553 ++ ret = devm_request_irq(dev, ci->irq, ci_irq_handler, IRQF_SHARED,
4554 + ci->platdata->name, ci);
4555 + if (ret)
4556 + goto stop;
4557 +@@ -1175,11 +1184,11 @@ static void ci_extcon_wakeup_int(struct ci_hdrc *ci)
4558 +
4559 + if (!IS_ERR(cable_id->edev) && ci->is_otg &&
4560 + (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS))
4561 +- ci_irq(ci->irq, ci);
4562 ++ ci_irq(ci);
4563 +
4564 + if (!IS_ERR(cable_vbus->edev) && ci->is_otg &&
4565 + (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS))
4566 +- ci_irq(ci->irq, ci);
4567 ++ ci_irq(ci);
4568 + }
4569 +
4570 + static int ci_controller_resume(struct device *dev)
4571 +diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
4572 +index cccbb948821b2..a55d3761d777c 100644
4573 +--- a/drivers/usb/gadget/legacy/hid.c
4574 ++++ b/drivers/usb/gadget/legacy/hid.c
4575 +@@ -103,8 +103,10 @@ static int do_config(struct usb_configuration *c)
4576 +
4577 + list_for_each_entry(e, &hidg_func_list, node) {
4578 + e->f = usb_get_function(e->fi);
4579 +- if (IS_ERR(e->f))
4580 ++ if (IS_ERR(e->f)) {
4581 ++ status = PTR_ERR(e->f);
4582 + goto put;
4583 ++ }
4584 + status = usb_add_function(c, e->f);
4585 + if (status < 0) {
4586 + usb_put_function(e->f);
4587 +diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
4588 +index 1c047f28c88e4..2471c703d1fc1 100644
4589 +--- a/drivers/usb/host/max3421-hcd.c
4590 ++++ b/drivers/usb/host/max3421-hcd.c
4591 +@@ -121,8 +121,6 @@ struct max3421_hcd {
4592 +
4593 + struct task_struct *spi_thread;
4594 +
4595 +- struct max3421_hcd *next;
4596 +-
4597 + enum max3421_rh_state rh_state;
4598 + /* lower 16 bits contain port status, upper 16 bits the change mask: */
4599 + u32 port_status;
4600 +@@ -170,8 +168,6 @@ struct max3421_ep {
4601 + u8 retransmit; /* packet needs retransmission */
4602 + };
4603 +
4604 +-static struct max3421_hcd *max3421_hcd_list;
4605 +-
4606 + #define MAX3421_FIFO_SIZE 64
4607 +
4608 + #define MAX3421_SPI_DIR_RD 0 /* read register from MAX3421 */
4609 +@@ -1835,9 +1831,8 @@ max3421_probe(struct spi_device *spi)
4610 + }
4611 + set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
4612 + max3421_hcd = hcd_to_max3421(hcd);
4613 +- max3421_hcd->next = max3421_hcd_list;
4614 +- max3421_hcd_list = max3421_hcd;
4615 + INIT_LIST_HEAD(&max3421_hcd->ep_list);
4616 ++ spi_set_drvdata(spi, max3421_hcd);
4617 +
4618 + max3421_hcd->tx = kmalloc(sizeof(*max3421_hcd->tx), GFP_KERNEL);
4619 + if (!max3421_hcd->tx)
4620 +@@ -1882,28 +1877,18 @@ error:
4621 + static int
4622 + max3421_remove(struct spi_device *spi)
4623 + {
4624 +- struct max3421_hcd *max3421_hcd = NULL, **prev;
4625 +- struct usb_hcd *hcd = NULL;
4626 ++ struct max3421_hcd *max3421_hcd;
4627 ++ struct usb_hcd *hcd;
4628 + unsigned long flags;
4629 +
4630 +- for (prev = &max3421_hcd_list; *prev; prev = &(*prev)->next) {
4631 +- max3421_hcd = *prev;
4632 +- hcd = max3421_to_hcd(max3421_hcd);
4633 +- if (hcd->self.controller == &spi->dev)
4634 +- break;
4635 +- }
4636 +- if (!max3421_hcd) {
4637 +- dev_err(&spi->dev, "no MAX3421 HCD found for SPI device %p\n",
4638 +- spi);
4639 +- return -ENODEV;
4640 +- }
4641 ++ max3421_hcd = spi_get_drvdata(spi);
4642 ++ hcd = max3421_to_hcd(max3421_hcd);
4643 +
4644 + usb_remove_hcd(hcd);
4645 +
4646 + spin_lock_irqsave(&max3421_hcd->lock, flags);
4647 +
4648 + kthread_stop(max3421_hcd->spi_thread);
4649 +- *prev = max3421_hcd->next;
4650 +
4651 + spin_unlock_irqrestore(&max3421_hcd->lock, flags);
4652 +
4653 +diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
4654 +index 0cf4b6dc89720..4c7846dc5eed1 100644
4655 +--- a/drivers/usb/host/ohci-tmio.c
4656 ++++ b/drivers/usb/host/ohci-tmio.c
4657 +@@ -199,7 +199,7 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev)
4658 + if (usb_disabled())
4659 + return -ENODEV;
4660 +
4661 +- if (!cell)
4662 ++ if (!cell || !regs || !config || !sram)
4663 + return -EINVAL;
4664 +
4665 + if (irq < 0)
4666 +diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
4667 +index 65a930b3722eb..ad82d10d9cf5f 100644
4668 +--- a/drivers/usb/host/xhci-hub.c
4669 ++++ b/drivers/usb/host/xhci-hub.c
4670 +@@ -174,7 +174,6 @@ static void xhci_common_hub_descriptor(struct xhci_hcd *xhci,
4671 + {
4672 + u16 temp;
4673 +
4674 +- desc->bPwrOn2PwrGood = 10; /* xhci section 5.4.9 says 20ms max */
4675 + desc->bHubContrCurrent = 0;
4676 +
4677 + desc->bNbrPorts = ports;
4678 +@@ -208,6 +207,7 @@ static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
4679 + desc->bDescriptorType = USB_DT_HUB;
4680 + temp = 1 + (ports / 8);
4681 + desc->bDescLength = USB_DT_HUB_NONVAR_SIZE + 2 * temp;
4682 ++ desc->bPwrOn2PwrGood = 10; /* xhci section 5.4.8 says 20ms */
4683 +
4684 + /* The Device Removable bits are reported on a byte granularity.
4685 + * If the port doesn't exist within that byte, the bit is set to 0.
4686 +@@ -258,6 +258,7 @@ static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
4687 + xhci_common_hub_descriptor(xhci, desc, ports);
4688 + desc->bDescriptorType = USB_DT_SS_HUB;
4689 + desc->bDescLength = USB_DT_SS_HUB_SIZE;
4690 ++ desc->bPwrOn2PwrGood = 50; /* usb 3.1 may fail if less than 100ms */
4691 +
4692 + /* header decode latency should be zero for roothubs,
4693 + * see section 4.23.5.2.
4694 +diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
4695 +index 27e1ab9e1b079..2f13be1e3b8d3 100644
4696 +--- a/drivers/usb/misc/iowarrior.c
4697 ++++ b/drivers/usb/misc/iowarrior.c
4698 +@@ -103,10 +103,6 @@ struct iowarrior {
4699 + /* globals */
4700 + /*--------------*/
4701 +
4702 +-/*
4703 +- * USB spec identifies 5 second timeouts.
4704 +- */
4705 +-#define GET_TIMEOUT 5
4706 + #define USB_REQ_GET_REPORT 0x01
4707 + //#if 0
4708 + static int usb_get_report(struct usb_device *dev,
4709 +@@ -118,7 +114,7 @@ static int usb_get_report(struct usb_device *dev,
4710 + USB_DIR_IN | USB_TYPE_CLASS |
4711 + USB_RECIP_INTERFACE, (type << 8) + id,
4712 + inter->desc.bInterfaceNumber, buf, size,
4713 +- GET_TIMEOUT*HZ);
4714 ++ USB_CTRL_GET_TIMEOUT);
4715 + }
4716 + //#endif
4717 +
4718 +@@ -133,7 +129,7 @@ static int usb_set_report(struct usb_interface *intf, unsigned char type,
4719 + USB_TYPE_CLASS | USB_RECIP_INTERFACE,
4720 + (type << 8) + id,
4721 + intf->cur_altsetting->desc.bInterfaceNumber, buf,
4722 +- size, HZ);
4723 ++ size, 1000);
4724 + }
4725 +
4726 + /*---------------------*/
4727 +diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
4728 +index 7d7cb1c5ec808..9a7b5b2d7ccc7 100644
4729 +--- a/drivers/usb/musb/tusb6010.c
4730 ++++ b/drivers/usb/musb/tusb6010.c
4731 +@@ -1108,6 +1108,11 @@ static int tusb_musb_init(struct musb *musb)
4732 +
4733 + /* dma address for async dma */
4734 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
4735 ++ if (!mem) {
4736 ++ pr_debug("no async dma resource?\n");
4737 ++ ret = -ENODEV;
4738 ++ goto done;
4739 ++ }
4740 + musb->async = mem->start;
4741 +
4742 + /* dma address for sync dma */
4743 +diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
4744 +index 55a7684879906..ce5431bb42165 100644
4745 +--- a/drivers/usb/serial/keyspan.c
4746 ++++ b/drivers/usb/serial/keyspan.c
4747 +@@ -2914,22 +2914,22 @@ static int keyspan_port_probe(struct usb_serial_port *port)
4748 + for (i = 0; i < ARRAY_SIZE(p_priv->in_buffer); ++i) {
4749 + p_priv->in_buffer[i] = kzalloc(IN_BUFLEN, GFP_KERNEL);
4750 + if (!p_priv->in_buffer[i])
4751 +- goto err_in_buffer;
4752 ++ goto err_free_in_buffer;
4753 + }
4754 +
4755 + for (i = 0; i < ARRAY_SIZE(p_priv->out_buffer); ++i) {
4756 + p_priv->out_buffer[i] = kzalloc(OUT_BUFLEN, GFP_KERNEL);
4757 + if (!p_priv->out_buffer[i])
4758 +- goto err_out_buffer;
4759 ++ goto err_free_out_buffer;
4760 + }
4761 +
4762 + p_priv->inack_buffer = kzalloc(INACK_BUFLEN, GFP_KERNEL);
4763 + if (!p_priv->inack_buffer)
4764 +- goto err_inack_buffer;
4765 ++ goto err_free_out_buffer;
4766 +
4767 + p_priv->outcont_buffer = kzalloc(OUTCONT_BUFLEN, GFP_KERNEL);
4768 + if (!p_priv->outcont_buffer)
4769 +- goto err_outcont_buffer;
4770 ++ goto err_free_inack_buffer;
4771 +
4772 + p_priv->device_details = d_details;
4773 +
4774 +@@ -2975,15 +2975,14 @@ static int keyspan_port_probe(struct usb_serial_port *port)
4775 +
4776 + return 0;
4777 +
4778 +-err_outcont_buffer:
4779 ++err_free_inack_buffer:
4780 + kfree(p_priv->inack_buffer);
4781 +-err_inack_buffer:
4782 ++err_free_out_buffer:
4783 + for (i = 0; i < ARRAY_SIZE(p_priv->out_buffer); ++i)
4784 + kfree(p_priv->out_buffer[i]);
4785 +-err_out_buffer:
4786 ++err_free_in_buffer:
4787 + for (i = 0; i < ARRAY_SIZE(p_priv->in_buffer); ++i)
4788 + kfree(p_priv->in_buffer[i]);
4789 +-err_in_buffer:
4790 + kfree(p_priv);
4791 +
4792 + return -ENOMEM;
4793 +diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
4794 +index 79c9bd8d30254..559a7305cadaa 100644
4795 +--- a/drivers/video/console/sticon.c
4796 ++++ b/drivers/video/console/sticon.c
4797 +@@ -291,13 +291,13 @@ static unsigned long sticon_getxy(struct vc_data *conp, unsigned long pos,
4798 + static u8 sticon_build_attr(struct vc_data *conp, u8 color, u8 intens,
4799 + u8 blink, u8 underline, u8 reverse, u8 italic)
4800 + {
4801 +- u8 attr = ((color & 0x70) >> 1) | ((color & 7));
4802 ++ u8 fg = color & 7;
4803 ++ u8 bg = (color & 0x70) >> 4;
4804 +
4805 +- if (reverse) {
4806 +- color = ((color >> 3) & 0x7) | ((color & 0x7) << 3);
4807 +- }
4808 +-
4809 +- return attr;
4810 ++ if (reverse)
4811 ++ return (fg << 3) | bg;
4812 ++ else
4813 ++ return (bg << 3) | fg;
4814 + }
4815 +
4816 + static void sticon_invert_region(struct vc_data *conp, u16 *p, int count)
4817 +diff --git a/drivers/video/fbdev/chipsfb.c b/drivers/video/fbdev/chipsfb.c
4818 +index f9b366d175875..413b465e69d8e 100644
4819 +--- a/drivers/video/fbdev/chipsfb.c
4820 ++++ b/drivers/video/fbdev/chipsfb.c
4821 +@@ -332,7 +332,7 @@ static const struct fb_var_screeninfo chipsfb_var = {
4822 +
4823 + static void init_chips(struct fb_info *p, unsigned long addr)
4824 + {
4825 +- memset(p->screen_base, 0, 0x100000);
4826 ++ fb_memset(p->screen_base, 0, 0x100000);
4827 +
4828 + p->fix = chipsfb_fix;
4829 + p->fix.smem_start = addr;
4830 +diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
4831 +index de228669a2c8b..8cb663ecbacc6 100644
4832 +--- a/drivers/watchdog/Kconfig
4833 ++++ b/drivers/watchdog/Kconfig
4834 +@@ -1499,7 +1499,7 @@ config SIBYTE_WDOG
4835 +
4836 + config AR7_WDT
4837 + tristate "TI AR7 Watchdog Timer"
4838 +- depends on AR7 || (MIPS && COMPILE_TEST)
4839 ++ depends on AR7 || (MIPS && 32BIT && COMPILE_TEST)
4840 + help
4841 + Hardware driver for the TI AR7 Watchdog Timer.
4842 +
4843 +diff --git a/drivers/watchdog/f71808e_wdt.c b/drivers/watchdog/f71808e_wdt.c
4844 +index ae4974701e5c7..6fe9daf2367b5 100644
4845 +--- a/drivers/watchdog/f71808e_wdt.c
4846 ++++ b/drivers/watchdog/f71808e_wdt.c
4847 +@@ -237,15 +237,17 @@ static int watchdog_set_timeout(int timeout)
4848 +
4849 + mutex_lock(&watchdog.lock);
4850 +
4851 +- watchdog.timeout = timeout;
4852 + if (timeout > 0xff) {
4853 + watchdog.timer_val = DIV_ROUND_UP(timeout, 60);
4854 + watchdog.minutes_mode = true;
4855 ++ timeout = watchdog.timer_val * 60;
4856 + } else {
4857 + watchdog.timer_val = timeout;
4858 + watchdog.minutes_mode = false;
4859 + }
4860 +
4861 ++ watchdog.timeout = timeout;
4862 ++
4863 + mutex_unlock(&watchdog.lock);
4864 +
4865 + return 0;
4866 +diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
4867 +index 1b02bfa81b296..40c006ee8492d 100644
4868 +--- a/drivers/watchdog/omap_wdt.c
4869 ++++ b/drivers/watchdog/omap_wdt.c
4870 +@@ -271,8 +271,12 @@ static int omap_wdt_probe(struct platform_device *pdev)
4871 + wdev->wdog.bootstatus = WDIOF_CARDRESET;
4872 + }
4873 +
4874 +- if (!early_enable)
4875 ++ if (early_enable) {
4876 ++ omap_wdt_start(&wdev->wdog);
4877 ++ set_bit(WDOG_HW_RUNNING, &wdev->wdog.status);
4878 ++ } else {
4879 + omap_wdt_disable(wdev);
4880 ++ }
4881 +
4882 + ret = watchdog_register_device(&wdev->wdog);
4883 + if (ret) {
4884 +diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
4885 +index 92bb71c040f97..f2b06fdb06017 100644
4886 +--- a/drivers/xen/balloon.c
4887 ++++ b/drivers/xen/balloon.c
4888 +@@ -58,6 +58,7 @@
4889 + #include <linux/percpu-defs.h>
4890 + #include <linux/slab.h>
4891 + #include <linux/sysctl.h>
4892 ++#include <linux/moduleparam.h>
4893 +
4894 + #include <asm/page.h>
4895 + #include <asm/pgalloc.h>
4896 +@@ -74,6 +75,12 @@
4897 + #include <xen/features.h>
4898 + #include <xen/page.h>
4899 +
4900 ++#undef MODULE_PARAM_PREFIX
4901 ++#define MODULE_PARAM_PREFIX "xen."
4902 ++
4903 ++static uint __read_mostly balloon_boot_timeout = 180;
4904 ++module_param(balloon_boot_timeout, uint, 0444);
4905 ++
4906 + static int xen_hotplug_unpopulated;
4907 +
4908 + #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
4909 +@@ -129,12 +136,12 @@ static struct ctl_table xen_root[] = {
4910 + * BP_ECANCELED: error, balloon operation canceled.
4911 + */
4912 +
4913 +-enum bp_state {
4914 ++static enum bp_state {
4915 + BP_DONE,
4916 + BP_WAIT,
4917 + BP_EAGAIN,
4918 + BP_ECANCELED
4919 +-};
4920 ++} balloon_state = BP_DONE;
4921 +
4922 + /* Main waiting point for xen-balloon thread. */
4923 + static DECLARE_WAIT_QUEUE_HEAD(balloon_thread_wq);
4924 +@@ -212,18 +219,15 @@ static struct page *balloon_next_page(struct page *page)
4925 + return list_entry(next, struct page, lru);
4926 + }
4927 +
4928 +-static enum bp_state update_schedule(enum bp_state state)
4929 ++static void update_schedule(void)
4930 + {
4931 +- if (state == BP_WAIT)
4932 +- return BP_WAIT;
4933 +-
4934 +- if (state == BP_ECANCELED)
4935 +- return BP_ECANCELED;
4936 ++ if (balloon_state == BP_WAIT || balloon_state == BP_ECANCELED)
4937 ++ return;
4938 +
4939 +- if (state == BP_DONE) {
4940 ++ if (balloon_state == BP_DONE) {
4941 + balloon_stats.schedule_delay = 1;
4942 + balloon_stats.retry_count = 1;
4943 +- return BP_DONE;
4944 ++ return;
4945 + }
4946 +
4947 + ++balloon_stats.retry_count;
4948 +@@ -232,7 +236,8 @@ static enum bp_state update_schedule(enum bp_state state)
4949 + balloon_stats.retry_count > balloon_stats.max_retry_count) {
4950 + balloon_stats.schedule_delay = 1;
4951 + balloon_stats.retry_count = 1;
4952 +- return BP_ECANCELED;
4953 ++ balloon_state = BP_ECANCELED;
4954 ++ return;
4955 + }
4956 +
4957 + balloon_stats.schedule_delay <<= 1;
4958 +@@ -240,7 +245,7 @@ static enum bp_state update_schedule(enum bp_state state)
4959 + if (balloon_stats.schedule_delay > balloon_stats.max_schedule_delay)
4960 + balloon_stats.schedule_delay = balloon_stats.max_schedule_delay;
4961 +
4962 +- return BP_EAGAIN;
4963 ++ balloon_state = BP_EAGAIN;
4964 + }
4965 +
4966 + #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
4967 +@@ -574,9 +579,9 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
4968 + * Stop waiting if either state is BP_DONE and ballooning action is
4969 + * needed, or if the credit has changed while state is not BP_DONE.
4970 + */
4971 +-static bool balloon_thread_cond(enum bp_state state, long credit)
4972 ++static bool balloon_thread_cond(long credit)
4973 + {
4974 +- if (state == BP_DONE)
4975 ++ if (balloon_state == BP_DONE)
4976 + credit = 0;
4977 +
4978 + return current_credit() != credit || kthread_should_stop();
4979 +@@ -590,13 +595,12 @@ static bool balloon_thread_cond(enum bp_state state, long credit)
4980 + */
4981 + static int balloon_thread(void *unused)
4982 + {
4983 +- enum bp_state state = BP_DONE;
4984 + long credit;
4985 + unsigned long timeout;
4986 +
4987 + set_freezable();
4988 + for (;;) {
4989 +- switch (state) {
4990 ++ switch (balloon_state) {
4991 + case BP_DONE:
4992 + case BP_ECANCELED:
4993 + timeout = 3600 * HZ;
4994 +@@ -612,7 +616,7 @@ static int balloon_thread(void *unused)
4995 + credit = current_credit();
4996 +
4997 + wait_event_freezable_timeout(balloon_thread_wq,
4998 +- balloon_thread_cond(state, credit), timeout);
4999 ++ balloon_thread_cond(credit), timeout);
5000 +
5001 + if (kthread_should_stop())
5002 + return 0;
5003 +@@ -623,22 +627,23 @@ static int balloon_thread(void *unused)
5004 +
5005 + if (credit > 0) {
5006 + if (balloon_is_inflated())
5007 +- state = increase_reservation(credit);
5008 ++ balloon_state = increase_reservation(credit);
5009 + else
5010 +- state = reserve_additional_memory();
5011 ++ balloon_state = reserve_additional_memory();
5012 + }
5013 +
5014 + if (credit < 0) {
5015 + long n_pages;
5016 +
5017 + n_pages = min(-credit, si_mem_available());
5018 +- state = decrease_reservation(n_pages, GFP_BALLOON);
5019 +- if (state == BP_DONE && n_pages != -credit &&
5020 ++ balloon_state = decrease_reservation(n_pages,
5021 ++ GFP_BALLOON);
5022 ++ if (balloon_state == BP_DONE && n_pages != -credit &&
5023 + n_pages < totalreserve_pages)
5024 +- state = BP_EAGAIN;
5025 ++ balloon_state = BP_EAGAIN;
5026 + }
5027 +
5028 +- state = update_schedule(state);
5029 ++ update_schedule();
5030 +
5031 + mutex_unlock(&balloon_mutex);
5032 +
5033 +@@ -847,3 +852,38 @@ static int __init balloon_init(void)
5034 + return 0;
5035 + }
5036 + subsys_initcall(balloon_init);
5037 ++
5038 ++static int __init balloon_wait_finish(void)
5039 ++{
5040 ++ long credit, last_credit = 0;
5041 ++ unsigned long last_changed = 0;
5042 ++
5043 ++ if (!xen_domain())
5044 ++ return -ENODEV;
5045 ++
5046 ++ /* PV guests don't need to wait. */
5047 ++ if (xen_pv_domain() || !current_credit())
5048 ++ return 0;
5049 ++
5050 ++ pr_notice("Waiting for initial ballooning down having finished.\n");
5051 ++
5052 ++ while ((credit = current_credit()) < 0) {
5053 ++ if (credit != last_credit) {
5054 ++ last_changed = jiffies;
5055 ++ last_credit = credit;
5056 ++ }
5057 ++ if (balloon_state == BP_ECANCELED) {
5058 ++ pr_warn_once("Initial ballooning failed, %ld pages need to be freed.\n",
5059 ++ -credit);
5060 ++ if (jiffies - last_changed >= HZ * balloon_boot_timeout)
5061 ++ panic("Initial ballooning failed!\n");
5062 ++ }
5063 ++
5064 ++ schedule_timeout_interruptible(HZ / 10);
5065 ++ }
5066 ++
5067 ++ pr_notice("Initial ballooning down finished.\n");
5068 ++
5069 ++ return 0;
5070 ++}
5071 ++late_initcall_sync(balloon_wait_finish);
5072 +diff --git a/drivers/xen/xen-pciback/conf_space_capability.c b/drivers/xen/xen-pciback/conf_space_capability.c
5073 +index e5694133ebe57..42f0f64fcba47 100644
5074 +--- a/drivers/xen/xen-pciback/conf_space_capability.c
5075 ++++ b/drivers/xen/xen-pciback/conf_space_capability.c
5076 +@@ -160,7 +160,7 @@ static void *pm_ctrl_init(struct pci_dev *dev, int offset)
5077 + }
5078 +
5079 + out:
5080 +- return ERR_PTR(err);
5081 ++ return err ? ERR_PTR(err) : NULL;
5082 + }
5083 +
5084 + static const struct config_field caplist_pm[] = {
5085 +diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
5086 +index 92615badc1734..3dfe8d35235e1 100644
5087 +--- a/fs/btrfs/async-thread.c
5088 ++++ b/fs/btrfs/async-thread.c
5089 +@@ -283,6 +283,13 @@ static void run_ordered_work(struct __btrfs_workqueue *wq,
5090 + ordered_list);
5091 + if (!test_bit(WORK_DONE_BIT, &work->flags))
5092 + break;
5093 ++ /*
5094 ++ * Orders all subsequent loads after reading WORK_DONE_BIT,
5095 ++ * paired with the smp_mb__before_atomic in btrfs_work_helper
5096 ++ * this guarantees that the ordered function will see all
5097 ++ * updates from ordinary work function.
5098 ++ */
5099 ++ smp_rmb();
5100 +
5101 + /*
5102 + * we are going to call the ordered done function, but
5103 +@@ -368,6 +375,13 @@ static void normal_work_helper(struct btrfs_work *work)
5104 + thresh_exec_hook(wq);
5105 + work->func(work);
5106 + if (need_order) {
5107 ++ /*
5108 ++ * Ensures all memory accesses done in the work function are
5109 ++ * ordered before setting the WORK_DONE_BIT. Ensuring the thread
5110 ++ * which is going to executed the ordered work sees them.
5111 ++ * Pairs with the smp_rmb in run_ordered_work.
5112 ++ */
5113 ++ smp_mb__before_atomic();
5114 + set_bit(WORK_DONE_BIT, &work->flags);
5115 + run_ordered_work(wq, work);
5116 + }
5117 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
5118 +index 372a10130ced1..8f2c7aa2e91a1 100644
5119 +--- a/fs/btrfs/tree-log.c
5120 ++++ b/fs/btrfs/tree-log.c
5121 +@@ -2286,7 +2286,9 @@ again:
5122 + else {
5123 + ret = find_dir_range(log, path, dirid, key_type,
5124 + &range_start, &range_end);
5125 +- if (ret != 0)
5126 ++ if (ret < 0)
5127 ++ goto out;
5128 ++ else if (ret > 0)
5129 + break;
5130 + }
5131 +
5132 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
5133 +index 660469befb7f8..105334ebc102d 100644
5134 +--- a/fs/ext4/super.c
5135 ++++ b/fs/ext4/super.c
5136 +@@ -2952,8 +2952,8 @@ static int ext4_run_li_request(struct ext4_li_request *elr)
5137 + struct ext4_group_desc *gdp = NULL;
5138 + ext4_group_t group, ngroups;
5139 + struct super_block *sb;
5140 +- unsigned long timeout = 0;
5141 + int ret = 0;
5142 ++ u64 start_time;
5143 +
5144 + sb = elr->lr_super;
5145 + ngroups = EXT4_SB(sb)->s_groups_count;
5146 +@@ -2973,13 +2973,12 @@ static int ext4_run_li_request(struct ext4_li_request *elr)
5147 + ret = 1;
5148 +
5149 + if (!ret) {
5150 +- timeout = jiffies;
5151 ++ start_time = ktime_get_real_ns();
5152 + ret = ext4_init_inode_table(sb, group,
5153 + elr->lr_timeout ? 0 : 1);
5154 + if (elr->lr_timeout == 0) {
5155 +- timeout = (jiffies - timeout) *
5156 +- elr->lr_sbi->s_li_wait_mult;
5157 +- elr->lr_timeout = timeout;
5158 ++ elr->lr_timeout = nsecs_to_jiffies((ktime_get_real_ns() - start_time) *
5159 ++ elr->lr_sbi->s_li_wait_mult);
5160 + }
5161 + elr->lr_next_sched = jiffies + elr->lr_timeout;
5162 + elr->lr_next_group = group + 1;
5163 +diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
5164 +index b5214c9ac47ac..f1a705d159043 100644
5165 +--- a/fs/jfs/jfs_mount.c
5166 ++++ b/fs/jfs/jfs_mount.c
5167 +@@ -93,14 +93,14 @@ int jfs_mount(struct super_block *sb)
5168 + * (initialize mount inode from the superblock)
5169 + */
5170 + if ((rc = chkSuper(sb))) {
5171 +- goto errout20;
5172 ++ goto out;
5173 + }
5174 +
5175 + ipaimap = diReadSpecial(sb, AGGREGATE_I, 0);
5176 + if (ipaimap == NULL) {
5177 + jfs_err("jfs_mount: Failed to read AGGREGATE_I");
5178 + rc = -EIO;
5179 +- goto errout20;
5180 ++ goto out;
5181 + }
5182 + sbi->ipaimap = ipaimap;
5183 +
5184 +@@ -111,7 +111,7 @@ int jfs_mount(struct super_block *sb)
5185 + */
5186 + if ((rc = diMount(ipaimap))) {
5187 + jfs_err("jfs_mount: diMount(ipaimap) failed w/rc = %d", rc);
5188 +- goto errout21;
5189 ++ goto err_ipaimap;
5190 + }
5191 +
5192 + /*
5193 +@@ -120,7 +120,7 @@ int jfs_mount(struct super_block *sb)
5194 + ipbmap = diReadSpecial(sb, BMAP_I, 0);
5195 + if (ipbmap == NULL) {
5196 + rc = -EIO;
5197 +- goto errout22;
5198 ++ goto err_umount_ipaimap;
5199 + }
5200 +
5201 + jfs_info("jfs_mount: ipbmap:0x%p", ipbmap);
5202 +@@ -132,7 +132,7 @@ int jfs_mount(struct super_block *sb)
5203 + */
5204 + if ((rc = dbMount(ipbmap))) {
5205 + jfs_err("jfs_mount: dbMount failed w/rc = %d", rc);
5206 +- goto errout22;
5207 ++ goto err_ipbmap;
5208 + }
5209 +
5210 + /*
5211 +@@ -151,7 +151,7 @@ int jfs_mount(struct super_block *sb)
5212 + if (!ipaimap2) {
5213 + jfs_err("jfs_mount: Failed to read AGGREGATE_I");
5214 + rc = -EIO;
5215 +- goto errout35;
5216 ++ goto err_umount_ipbmap;
5217 + }
5218 + sbi->ipaimap2 = ipaimap2;
5219 +
5220 +@@ -163,7 +163,7 @@ int jfs_mount(struct super_block *sb)
5221 + if ((rc = diMount(ipaimap2))) {
5222 + jfs_err("jfs_mount: diMount(ipaimap2) failed, rc = %d",
5223 + rc);
5224 +- goto errout35;
5225 ++ goto err_ipaimap2;
5226 + }
5227 + } else
5228 + /* Secondary aggregate inode table is not valid */
5229 +@@ -180,7 +180,7 @@ int jfs_mount(struct super_block *sb)
5230 + jfs_err("jfs_mount: Failed to read FILESYSTEM_I");
5231 + /* open fileset secondary inode allocation map */
5232 + rc = -EIO;
5233 +- goto errout40;
5234 ++ goto err_umount_ipaimap2;
5235 + }
5236 + jfs_info("jfs_mount: ipimap:0x%p", ipimap);
5237 +
5238 +@@ -190,41 +190,34 @@ int jfs_mount(struct super_block *sb)
5239 + /* initialize fileset inode allocation map */
5240 + if ((rc = diMount(ipimap))) {
5241 + jfs_err("jfs_mount: diMount failed w/rc = %d", rc);
5242 +- goto errout41;
5243 ++ goto err_ipimap;
5244 + }
5245 +
5246 +- goto out;
5247 ++ return rc;
5248 +
5249 + /*
5250 + * unwind on error
5251 + */
5252 +- errout41: /* close fileset inode allocation map inode */
5253 ++err_ipimap:
5254 ++ /* close fileset inode allocation map inode */
5255 + diFreeSpecial(ipimap);
5256 +-
5257 +- errout40: /* fileset closed */
5258 +-
5259 ++err_umount_ipaimap2:
5260 + /* close secondary aggregate inode allocation map */
5261 +- if (ipaimap2) {
5262 ++ if (ipaimap2)
5263 + diUnmount(ipaimap2, 1);
5264 ++err_ipaimap2:
5265 ++ /* close aggregate inodes */
5266 ++ if (ipaimap2)
5267 + diFreeSpecial(ipaimap2);
5268 +- }
5269 +-
5270 +- errout35:
5271 +-
5272 +- /* close aggregate block allocation map */
5273 ++err_umount_ipbmap: /* close aggregate block allocation map */
5274 + dbUnmount(ipbmap, 1);
5275 ++err_ipbmap: /* close aggregate inodes */
5276 + diFreeSpecial(ipbmap);
5277 +-
5278 +- errout22: /* close aggregate inode allocation map */
5279 +-
5280 ++err_umount_ipaimap: /* close aggregate inode allocation map */
5281 + diUnmount(ipaimap, 1);
5282 +-
5283 +- errout21: /* close aggregate inodes */
5284 ++err_ipaimap: /* close aggregate inodes */
5285 + diFreeSpecial(ipaimap);
5286 +- errout20: /* aggregate closed */
5287 +-
5288 +- out:
5289 +-
5290 ++out:
5291 + if (rc)
5292 + jfs_err("Mount JFS Failure: %d", rc);
5293 +
5294 +diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
5295 +index 2464b9b806988..17dee8fd9834f 100644
5296 +--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
5297 ++++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
5298 +@@ -428,10 +428,10 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx,
5299 + goto out_fail;
5300 +
5301 + ds = mirror->mirror_ds->ds;
5302 ++ if (READ_ONCE(ds->ds_clp))
5303 ++ goto out;
5304 + /* matching smp_wmb() in _nfs4_pnfs_v3/4_ds_connect */
5305 + smp_rmb();
5306 +- if (ds->ds_clp)
5307 +- goto out;
5308 +
5309 + /* FIXME: For now we assume the server sent only one version of NFS
5310 + * to use for the DS.
5311 +diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
5312 +index 29bdf1525d82b..5d7a69ffaaa29 100644
5313 +--- a/fs/nfs/pnfs_nfs.c
5314 ++++ b/fs/nfs/pnfs_nfs.c
5315 +@@ -635,7 +635,7 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv,
5316 + }
5317 +
5318 + smp_wmb();
5319 +- ds->ds_clp = clp;
5320 ++ WRITE_ONCE(ds->ds_clp, clp);
5321 + dprintk("%s [new] addr: %s\n", __func__, ds->ds_remotestr);
5322 + out:
5323 + return status;
5324 +@@ -708,7 +708,7 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv,
5325 + }
5326 +
5327 + smp_wmb();
5328 +- ds->ds_clp = clp;
5329 ++ WRITE_ONCE(ds->ds_clp, clp);
5330 + dprintk("%s [new] addr: %s\n", __func__, ds->ds_remotestr);
5331 + out:
5332 + return status;
5333 +diff --git a/fs/nfs/write.c b/fs/nfs/write.c
5334 +index 767e46c09074b..010733c8bdcd3 100644
5335 +--- a/fs/nfs/write.c
5336 ++++ b/fs/nfs/write.c
5337 +@@ -1037,25 +1037,11 @@ nfs_scan_commit_list(struct list_head *src, struct list_head *dst,
5338 + struct nfs_page *req, *tmp;
5339 + int ret = 0;
5340 +
5341 +-restart:
5342 + list_for_each_entry_safe(req, tmp, src, wb_list) {
5343 + kref_get(&req->wb_kref);
5344 + if (!nfs_lock_request(req)) {
5345 +- int status;
5346 +-
5347 +- /* Prevent deadlock with nfs_lock_and_join_requests */
5348 +- if (!list_empty(dst)) {
5349 +- nfs_release_request(req);
5350 +- continue;
5351 +- }
5352 +- /* Ensure we make progress to prevent livelock */
5353 +- mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
5354 +- status = nfs_wait_on_request(req);
5355 + nfs_release_request(req);
5356 +- mutex_lock(&NFS_I(cinfo->inode)->commit_mutex);
5357 +- if (status < 0)
5358 +- break;
5359 +- goto restart;
5360 ++ continue;
5361 + }
5362 + nfs_request_remove_commit_list(req, cinfo);
5363 + clear_bit(PG_COMMIT_TO_DS, &req->wb_flags);
5364 +@@ -1904,6 +1890,7 @@ static int __nfs_commit_inode(struct inode *inode, int how,
5365 + int may_wait = how & FLUSH_SYNC;
5366 + int ret, nscan;
5367 +
5368 ++ how &= ~FLUSH_SYNC;
5369 + nfs_init_cinfo_from_inode(&cinfo, inode);
5370 + nfs_commit_begin(cinfo.mds);
5371 + for (;;) {
5372 +diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
5373 +index 6a809517ca500..e671fbdd4b863 100644
5374 +--- a/fs/ocfs2/file.c
5375 ++++ b/fs/ocfs2/file.c
5376 +@@ -490,10 +490,11 @@ int ocfs2_truncate_file(struct inode *inode,
5377 + * greater than page size, so we have to truncate them
5378 + * anyway.
5379 + */
5380 +- unmap_mapping_range(inode->i_mapping, new_i_size + PAGE_SIZE - 1, 0, 1);
5381 +- truncate_inode_pages(inode->i_mapping, new_i_size);
5382 +
5383 + if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
5384 ++ unmap_mapping_range(inode->i_mapping,
5385 ++ new_i_size + PAGE_SIZE - 1, 0, 1);
5386 ++ truncate_inode_pages(inode->i_mapping, new_i_size);
5387 + status = ocfs2_truncate_inline(inode, di_bh, new_i_size,
5388 + i_size_read(inode), 1);
5389 + if (status)
5390 +@@ -512,6 +513,9 @@ int ocfs2_truncate_file(struct inode *inode,
5391 + goto bail_unlock_sem;
5392 + }
5393 +
5394 ++ unmap_mapping_range(inode->i_mapping, new_i_size + PAGE_SIZE - 1, 0, 1);
5395 ++ truncate_inode_pages(inode->i_mapping, new_i_size);
5396 ++
5397 + status = ocfs2_commit_truncate(osb, inode, di_bh);
5398 + if (status < 0) {
5399 + mlog_errno(status);
5400 +diff --git a/fs/orangefs/dcache.c b/fs/orangefs/dcache.c
5401 +index ae782df5c063e..f764f4ba2411c 100644
5402 +--- a/fs/orangefs/dcache.c
5403 ++++ b/fs/orangefs/dcache.c
5404 +@@ -26,8 +26,10 @@ static int orangefs_revalidate_lookup(struct dentry *dentry)
5405 + gossip_debug(GOSSIP_DCACHE_DEBUG, "%s: attempting lookup.\n", __func__);
5406 +
5407 + new_op = op_alloc(ORANGEFS_VFS_OP_LOOKUP);
5408 +- if (!new_op)
5409 ++ if (!new_op) {
5410 ++ ret = -ENOMEM;
5411 + goto out_put_parent;
5412 ++ }
5413 +
5414 + new_op->upcall.req.lookup.sym_follow = ORANGEFS_LOOKUP_LINK_NO_FOLLOW;
5415 + new_op->upcall.req.lookup.parent_refn = parent->refn;
5416 +diff --git a/fs/quota/quota_tree.c b/fs/quota/quota_tree.c
5417 +index 656f9ff63edda..833cd3e3758bf 100644
5418 +--- a/fs/quota/quota_tree.c
5419 ++++ b/fs/quota/quota_tree.c
5420 +@@ -422,6 +422,7 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot,
5421 + quota_error(dquot->dq_sb, "Quota structure has offset to "
5422 + "other block (%u) than it should (%u)", blk,
5423 + (uint)(dquot->dq_off >> info->dqi_blocksize_bits));
5424 ++ ret = -EIO;
5425 + goto out_buf;
5426 + }
5427 + ret = read_blk(info, blk, buf);
5428 +@@ -487,6 +488,13 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
5429 + goto out_buf;
5430 + }
5431 + newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
5432 ++ if (newblk < QT_TREEOFF || newblk >= info->dqi_blocks) {
5433 ++ quota_error(dquot->dq_sb, "Getting block too big (%u >= %u)",
5434 ++ newblk, info->dqi_blocks);
5435 ++ ret = -EUCLEAN;
5436 ++ goto out_buf;
5437 ++ }
5438 ++
5439 + if (depth == info->dqi_qtree_depth - 1) {
5440 + ret = free_dqentry(info, dquot, newblk);
5441 + newblk = 0;
5442 +@@ -586,6 +594,13 @@ static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info,
5443 + blk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
5444 + if (!blk) /* No reference? */
5445 + goto out_buf;
5446 ++ if (blk < QT_TREEOFF || blk >= info->dqi_blocks) {
5447 ++ quota_error(dquot->dq_sb, "Getting block too big (%u >= %u)",
5448 ++ blk, info->dqi_blocks);
5449 ++ ret = -EUCLEAN;
5450 ++ goto out_buf;
5451 ++ }
5452 ++
5453 + if (depth < info->dqi_qtree_depth - 1)
5454 + ret = find_tree_dqentry(info, dquot, blk, depth+1);
5455 + else
5456 +diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
5457 +index bea8ad876bf9a..0c123c5e70e08 100644
5458 +--- a/fs/tracefs/inode.c
5459 ++++ b/fs/tracefs/inode.c
5460 +@@ -427,7 +427,8 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,
5461 + if (unlikely(!inode))
5462 + return failed_creating(dentry);
5463 +
5464 +- inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
5465 ++ /* Do not set bits for OTH */
5466 ++ inode->i_mode = S_IFDIR | S_IRWXU | S_IRUSR| S_IRGRP | S_IXUSR | S_IXGRP;
5467 + inode->i_op = ops;
5468 + inode->i_fop = &simple_dir_operations;
5469 +
5470 +diff --git a/include/linux/console.h b/include/linux/console.h
5471 +index b8920a031a3e3..beed8b1cb7e5c 100644
5472 +--- a/include/linux/console.h
5473 ++++ b/include/linux/console.h
5474 +@@ -145,6 +145,8 @@ struct console {
5475 + short flags;
5476 + short index;
5477 + int cflag;
5478 ++ uint ispeed;
5479 ++ uint ospeed;
5480 + void *data;
5481 + struct console *next;
5482 + };
5483 +diff --git a/include/linux/filter.h b/include/linux/filter.h
5484 +index 5ca676d646529..7c0e616362f05 100644
5485 +--- a/include/linux/filter.h
5486 ++++ b/include/linux/filter.h
5487 +@@ -730,6 +730,7 @@ extern int bpf_jit_enable;
5488 + extern int bpf_jit_harden;
5489 + extern int bpf_jit_kallsyms;
5490 + extern long bpf_jit_limit;
5491 ++extern long bpf_jit_limit_max;
5492 +
5493 + typedef void (*bpf_jit_fill_hole_t)(void *area, unsigned int size);
5494 +
5495 +diff --git a/include/linux/libata.h b/include/linux/libata.h
5496 +index 23bc460e6d863..0e9f8fd37eb9d 100644
5497 +--- a/include/linux/libata.h
5498 ++++ b/include/linux/libata.h
5499 +@@ -409,7 +409,7 @@ enum {
5500 + /* This should match the actual table size of
5501 + * ata_eh_cmd_timeout_table in libata-eh.c.
5502 + */
5503 +- ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 6,
5504 ++ ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 7,
5505 +
5506 + /* Horkage types. May be set by libata or controller on drives
5507 + (some horkage may be drive/controller pair dependent */
5508 +diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
5509 +index c9258124e4175..569debc49f3d7 100644
5510 +--- a/include/linux/lsm_hooks.h
5511 ++++ b/include/linux/lsm_hooks.h
5512 +@@ -1170,22 +1170,22 @@
5513 + *
5514 + * @binder_set_context_mgr:
5515 + * Check whether @mgr is allowed to be the binder context manager.
5516 +- * @mgr contains the task_struct for the task being registered.
5517 ++ * @mgr contains the struct cred for the current binder process.
5518 + * Return 0 if permission is granted.
5519 + * @binder_transaction:
5520 + * Check whether @from is allowed to invoke a binder transaction call
5521 + * to @to.
5522 +- * @from contains the task_struct for the sending task.
5523 +- * @to contains the task_struct for the receiving task.
5524 ++ * @from contains the struct cred for the sending process.
5525 ++ * @to contains the struct cred for the receiving process.
5526 + * @binder_transfer_binder:
5527 + * Check whether @from is allowed to transfer a binder reference to @to.
5528 +- * @from contains the task_struct for the sending task.
5529 +- * @to contains the task_struct for the receiving task.
5530 ++ * @from contains the struct cred for the sending process.
5531 ++ * @to contains the struct cred for the receiving process.
5532 + * @binder_transfer_file:
5533 + * Check whether @from is allowed to transfer @file to @to.
5534 +- * @from contains the task_struct for the sending task.
5535 ++ * @from contains the struct cred for the sending process.
5536 + * @file contains the struct file being transferred.
5537 +- * @to contains the task_struct for the receiving task.
5538 ++ * @to contains the struct cred for the receiving process.
5539 + *
5540 + * @ptrace_access_check:
5541 + * Check permission before allowing the current process to trace the
5542 +@@ -1353,13 +1353,13 @@
5543 + * @ctxlen points to the place to put the length of @ctx.
5544 + */
5545 + union security_list_options {
5546 +- int (*binder_set_context_mgr)(struct task_struct *mgr);
5547 +- int (*binder_transaction)(struct task_struct *from,
5548 +- struct task_struct *to);
5549 +- int (*binder_transfer_binder)(struct task_struct *from,
5550 +- struct task_struct *to);
5551 +- int (*binder_transfer_file)(struct task_struct *from,
5552 +- struct task_struct *to,
5553 ++ int (*binder_set_context_mgr)(const struct cred *mgr);
5554 ++ int (*binder_transaction)(const struct cred *from,
5555 ++ const struct cred *to);
5556 ++ int (*binder_transfer_binder)(const struct cred *from,
5557 ++ const struct cred *to);
5558 ++ int (*binder_transfer_file)(const struct cred *from,
5559 ++ const struct cred *to,
5560 + struct file *file);
5561 +
5562 + int (*ptrace_access_check)(struct task_struct *child,
5563 +diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h
5564 +index 10d6ae8bbb7df..1ab79e8dc0b8f 100644
5565 +--- a/include/linux/rpmsg.h
5566 ++++ b/include/linux/rpmsg.h
5567 +@@ -202,7 +202,7 @@ static inline struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev
5568 + /* This shouldn't be possible */
5569 + WARN_ON(1);
5570 +
5571 +- return ERR_PTR(-ENXIO);
5572 ++ return NULL;
5573 + }
5574 +
5575 + static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len)
5576 +diff --git a/include/linux/sched/task_stack.h b/include/linux/sched/task_stack.h
5577 +index cb4828aaa34fd..3461beb89b040 100644
5578 +--- a/include/linux/sched/task_stack.h
5579 ++++ b/include/linux/sched/task_stack.h
5580 +@@ -25,7 +25,11 @@ static inline void *task_stack_page(const struct task_struct *task)
5581 +
5582 + static inline unsigned long *end_of_stack(const struct task_struct *task)
5583 + {
5584 ++#ifdef CONFIG_STACK_GROWSUP
5585 ++ return (unsigned long *)((unsigned long)task->stack + THREAD_SIZE) - 1;
5586 ++#else
5587 + return task->stack;
5588 ++#endif
5589 + }
5590 +
5591 + #elif !defined(__HAVE_THREAD_FUNCTIONS)
5592 +diff --git a/include/linux/security.h b/include/linux/security.h
5593 +index dab093af4ee8d..1c8968a267c2b 100644
5594 +--- a/include/linux/security.h
5595 ++++ b/include/linux/security.h
5596 +@@ -197,13 +197,13 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
5597 + extern int security_init(void);
5598 +
5599 + /* Security operations */
5600 +-int security_binder_set_context_mgr(struct task_struct *mgr);
5601 +-int security_binder_transaction(struct task_struct *from,
5602 +- struct task_struct *to);
5603 +-int security_binder_transfer_binder(struct task_struct *from,
5604 +- struct task_struct *to);
5605 +-int security_binder_transfer_file(struct task_struct *from,
5606 +- struct task_struct *to, struct file *file);
5607 ++int security_binder_set_context_mgr(const struct cred *mgr);
5608 ++int security_binder_transaction(const struct cred *from,
5609 ++ const struct cred *to);
5610 ++int security_binder_transfer_binder(const struct cred *from,
5611 ++ const struct cred *to);
5612 ++int security_binder_transfer_file(const struct cred *from,
5613 ++ const struct cred *to, struct file *file);
5614 + int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
5615 + int security_ptrace_traceme(struct task_struct *parent);
5616 + int security_capget(struct task_struct *target,
5617 +@@ -424,25 +424,25 @@ static inline int security_init(void)
5618 + return 0;
5619 + }
5620 +
5621 +-static inline int security_binder_set_context_mgr(struct task_struct *mgr)
5622 ++static inline int security_binder_set_context_mgr(const struct cred *mgr)
5623 + {
5624 + return 0;
5625 + }
5626 +
5627 +-static inline int security_binder_transaction(struct task_struct *from,
5628 +- struct task_struct *to)
5629 ++static inline int security_binder_transaction(const struct cred *from,
5630 ++ const struct cred *to)
5631 + {
5632 + return 0;
5633 + }
5634 +
5635 +-static inline int security_binder_transfer_binder(struct task_struct *from,
5636 +- struct task_struct *to)
5637 ++static inline int security_binder_transfer_binder(const struct cred *from,
5638 ++ const struct cred *to)
5639 + {
5640 + return 0;
5641 + }
5642 +
5643 +-static inline int security_binder_transfer_file(struct task_struct *from,
5644 +- struct task_struct *to,
5645 ++static inline int security_binder_transfer_file(const struct cred *from,
5646 ++ const struct cred *to,
5647 + struct file *file)
5648 + {
5649 + return 0;
5650 +diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
5651 +index ca68826d84495..162761f72c142 100644
5652 +--- a/include/linux/virtio_net.h
5653 ++++ b/include/linux/virtio_net.h
5654 +@@ -118,10 +118,15 @@ retry:
5655 +
5656 + if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
5657 + u16 gso_size = __virtio16_to_cpu(little_endian, hdr->gso_size);
5658 ++ unsigned int nh_off = p_off;
5659 + struct skb_shared_info *shinfo = skb_shinfo(skb);
5660 +
5661 ++ /* UFO may not include transport header in gso_size. */
5662 ++ if (gso_type & SKB_GSO_UDP)
5663 ++ nh_off -= thlen;
5664 ++
5665 + /* Too small packets are not really GSO ones. */
5666 +- if (skb->len - p_off > gso_size) {
5667 ++ if (skb->len - nh_off > gso_size) {
5668 + shinfo->gso_size = gso_size;
5669 + shinfo->gso_type = gso_type;
5670 +
5671 +diff --git a/include/net/llc.h b/include/net/llc.h
5672 +index df282d9b40170..9c10b121b49b0 100644
5673 +--- a/include/net/llc.h
5674 ++++ b/include/net/llc.h
5675 +@@ -72,7 +72,9 @@ struct llc_sap {
5676 + static inline
5677 + struct hlist_head *llc_sk_dev_hash(struct llc_sap *sap, int ifindex)
5678 + {
5679 +- return &sap->sk_dev_hash[ifindex % LLC_SK_DEV_HASH_ENTRIES];
5680 ++ u32 bucket = hash_32(ifindex, LLC_SK_DEV_HASH_BITS);
5681 ++
5682 ++ return &sap->sk_dev_hash[bucket];
5683 + }
5684 +
5685 + static inline
5686 +diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
5687 +index c369703fcd69c..36cdc17de6909 100644
5688 +--- a/include/rdma/rdma_netlink.h
5689 ++++ b/include/rdma/rdma_netlink.h
5690 +@@ -24,7 +24,7 @@ enum rdma_nl_flags {
5691 + * constant as well and the compiler checks they are the same.
5692 + */
5693 + #define MODULE_ALIAS_RDMA_NETLINK(_index, _val) \
5694 +- static inline void __chk_##_index(void) \
5695 ++ static inline void __maybe_unused __chk_##_index(void) \
5696 + { \
5697 + BUILD_BUG_ON(_index != _val); \
5698 + } \
5699 +diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
5700 +index 0d924e968c94b..336c9f71b750a 100644
5701 +--- a/include/target/target_core_base.h
5702 ++++ b/include/target/target_core_base.h
5703 +@@ -771,8 +771,9 @@ struct se_device {
5704 + atomic_long_t read_bytes;
5705 + atomic_long_t write_bytes;
5706 + /* Active commands on this virtual SE device */
5707 +- atomic_t simple_cmds;
5708 +- atomic_t dev_ordered_sync;
5709 ++ atomic_t non_ordered;
5710 ++ bool ordered_sync_in_progress;
5711 ++ atomic_t delayed_cmd_count;
5712 + atomic_t dev_qf_count;
5713 + u32 export_count;
5714 + spinlock_t delayed_cmd_lock;
5715 +@@ -795,6 +796,7 @@ struct se_device {
5716 + struct list_head dev_tmr_list;
5717 + struct workqueue_struct *tmr_wq;
5718 + struct work_struct qf_work_queue;
5719 ++ struct work_struct delayed_cmd_work;
5720 + struct list_head delayed_cmd_list;
5721 + struct list_head state_list;
5722 + struct list_head qf_cmd_list;
5723 +diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
5724 +index 87c2c840b27d4..c843929e0c4fe 100644
5725 +--- a/include/uapi/linux/pci_regs.h
5726 ++++ b/include/uapi/linux/pci_regs.h
5727 +@@ -497,6 +497,12 @@
5728 + #define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */
5729 + #define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */
5730 + #define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */
5731 ++#define PCI_EXP_DEVCTL_PAYLOAD_128B 0x0000 /* 128 Bytes */
5732 ++#define PCI_EXP_DEVCTL_PAYLOAD_256B 0x0020 /* 256 Bytes */
5733 ++#define PCI_EXP_DEVCTL_PAYLOAD_512B 0x0040 /* 512 Bytes */
5734 ++#define PCI_EXP_DEVCTL_PAYLOAD_1024B 0x0060 /* 1024 Bytes */
5735 ++#define PCI_EXP_DEVCTL_PAYLOAD_2048B 0x0080 /* 2048 Bytes */
5736 ++#define PCI_EXP_DEVCTL_PAYLOAD_4096B 0x00a0 /* 4096 Bytes */
5737 + #define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */
5738 + #define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */
5739 + #define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */
5740 +diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
5741 +index e7211b0fa27cf..485e319ba742a 100644
5742 +--- a/kernel/bpf/core.c
5743 ++++ b/kernel/bpf/core.c
5744 +@@ -295,6 +295,7 @@ int bpf_jit_enable __read_mostly = IS_BUILTIN(CONFIG_BPF_JIT_ALWAYS_ON);
5745 + int bpf_jit_harden __read_mostly;
5746 + int bpf_jit_kallsyms __read_mostly;
5747 + long bpf_jit_limit __read_mostly;
5748 ++long bpf_jit_limit_max __read_mostly;
5749 +
5750 + static __always_inline void
5751 + bpf_get_prog_addr_region(const struct bpf_prog *prog,
5752 +@@ -508,7 +509,8 @@ u64 __weak bpf_jit_alloc_exec_limit(void)
5753 + static int __init bpf_jit_charge_init(void)
5754 + {
5755 + /* Only used as heuristic here to derive limit. */
5756 +- bpf_jit_limit = min_t(u64, round_up(bpf_jit_alloc_exec_limit() >> 2,
5757 ++ bpf_jit_limit_max = bpf_jit_alloc_exec_limit();
5758 ++ bpf_jit_limit = min_t(u64, round_up(bpf_jit_limit_max >> 2,
5759 + PAGE_SIZE), LONG_MAX);
5760 + return 0;
5761 + }
5762 +diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
5763 +index 99783685f3d90..d5044ca33bd0b 100644
5764 +--- a/kernel/cgroup/cgroup.c
5765 ++++ b/kernel/cgroup/cgroup.c
5766 +@@ -1599,6 +1599,7 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
5767 + struct cgroup *dcgrp = &dst_root->cgrp;
5768 + struct cgroup_subsys *ss;
5769 + int ssid, i, ret;
5770 ++ u16 dfl_disable_ss_mask = 0;
5771 +
5772 + lockdep_assert_held(&cgroup_mutex);
5773 +
5774 +@@ -1615,8 +1616,28 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
5775 + /* can't move between two non-dummy roots either */
5776 + if (ss->root != &cgrp_dfl_root && dst_root != &cgrp_dfl_root)
5777 + return -EBUSY;
5778 ++
5779 ++ /*
5780 ++ * Collect ssid's that need to be disabled from default
5781 ++ * hierarchy.
5782 ++ */
5783 ++ if (ss->root == &cgrp_dfl_root)
5784 ++ dfl_disable_ss_mask |= 1 << ssid;
5785 ++
5786 + } while_each_subsys_mask();
5787 +
5788 ++ if (dfl_disable_ss_mask) {
5789 ++ struct cgroup *scgrp = &cgrp_dfl_root.cgrp;
5790 ++
5791 ++ /*
5792 ++ * Controllers from default hierarchy that need to be rebound
5793 ++ * are all disabled together in one go.
5794 ++ */
5795 ++ cgrp_dfl_root.subsys_mask &= ~dfl_disable_ss_mask;
5796 ++ WARN_ON(cgroup_apply_control(scgrp));
5797 ++ cgroup_finalize_control(scgrp, 0);
5798 ++ }
5799 ++
5800 + do_each_subsys_mask(ss, ssid, ss_mask) {
5801 + struct cgroup_root *src_root = ss->root;
5802 + struct cgroup *scgrp = &src_root->cgrp;
5803 +@@ -1625,10 +1646,12 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
5804 +
5805 + WARN_ON(!css || cgroup_css(dcgrp, ss));
5806 +
5807 +- /* disable from the source */
5808 +- src_root->subsys_mask &= ~(1 << ssid);
5809 +- WARN_ON(cgroup_apply_control(scgrp));
5810 +- cgroup_finalize_control(scgrp, 0);
5811 ++ if (src_root != &cgrp_dfl_root) {
5812 ++ /* disable from the source */
5813 ++ src_root->subsys_mask &= ~(1 << ssid);
5814 ++ WARN_ON(cgroup_apply_control(scgrp));
5815 ++ cgroup_finalize_control(scgrp, 0);
5816 ++ }
5817 +
5818 + /* rebind */
5819 + RCU_INIT_POINTER(scgrp->subsys[ssid], NULL);
5820 +diff --git a/kernel/events/core.c b/kernel/events/core.c
5821 +index 236e7900e3fca..0736508d595b2 100644
5822 +--- a/kernel/events/core.c
5823 ++++ b/kernel/events/core.c
5824 +@@ -6110,7 +6110,6 @@ void perf_output_sample(struct perf_output_handle *handle,
5825 + static u64 perf_virt_to_phys(u64 virt)
5826 + {
5827 + u64 phys_addr = 0;
5828 +- struct page *p = NULL;
5829 +
5830 + if (!virt)
5831 + return 0;
5832 +@@ -6129,14 +6128,15 @@ static u64 perf_virt_to_phys(u64 virt)
5833 + * If failed, leave phys_addr as 0.
5834 + */
5835 + if (current->mm != NULL) {
5836 ++ struct page *p;
5837 ++
5838 + pagefault_disable();
5839 +- if (__get_user_pages_fast(virt, 1, 0, &p) == 1)
5840 ++ if (__get_user_pages_fast(virt, 1, 0, &p) == 1) {
5841 + phys_addr = page_to_phys(p) + virt % PAGE_SIZE;
5842 ++ put_page(p);
5843 ++ }
5844 + pagefault_enable();
5845 + }
5846 +-
5847 +- if (p)
5848 +- put_page(p);
5849 + }
5850 +
5851 + return phys_addr;
5852 +diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
5853 +index 03e3ab61a2edd..ac0725b1ada75 100644
5854 +--- a/kernel/locking/lockdep.c
5855 ++++ b/kernel/locking/lockdep.c
5856 +@@ -713,7 +713,7 @@ look_up_lock_class(struct lockdep_map *lock, unsigned int subclass)
5857 + if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
5858 + return NULL;
5859 +
5860 +- hlist_for_each_entry_rcu(class, hash_head, hash_entry) {
5861 ++ hlist_for_each_entry_rcu_notrace(class, hash_head, hash_entry) {
5862 + if (class->key == key) {
5863 + /*
5864 + * Huh! same key, different name? Did someone trample
5865 +diff --git a/kernel/power/swap.c b/kernel/power/swap.c
5866 +index d7cdc426ee380..8b37085a66903 100644
5867 +--- a/kernel/power/swap.c
5868 ++++ b/kernel/power/swap.c
5869 +@@ -292,7 +292,7 @@ static int hib_submit_io(int op, int op_flags, pgoff_t page_off, void *addr,
5870 + return error;
5871 + }
5872 +
5873 +-static blk_status_t hib_wait_io(struct hib_bio_batch *hb)
5874 ++static int hib_wait_io(struct hib_bio_batch *hb)
5875 + {
5876 + wait_event(hb->wait, atomic_read(&hb->count) == 0);
5877 + return blk_status_to_errno(hb->error);
5878 +@@ -1526,9 +1526,10 @@ end:
5879 + int swsusp_check(void)
5880 + {
5881 + int error;
5882 ++ void *holder;
5883 +
5884 + hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device,
5885 +- FMODE_READ, NULL);
5886 ++ FMODE_READ | FMODE_EXCL, &holder);
5887 + if (!IS_ERR(hib_resume_bdev)) {
5888 + set_blocksize(hib_resume_bdev, PAGE_SIZE);
5889 + clear_page(swsusp_header);
5890 +@@ -1550,7 +1551,7 @@ int swsusp_check(void)
5891 +
5892 + put:
5893 + if (error)
5894 +- blkdev_put(hib_resume_bdev, FMODE_READ);
5895 ++ blkdev_put(hib_resume_bdev, FMODE_READ | FMODE_EXCL);
5896 + else
5897 + pr_debug("PM: Image signature found, resuming\n");
5898 + } else {
5899 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
5900 +index 7cedada731c1b..544a1cb66d90d 100644
5901 +--- a/kernel/sched/core.c
5902 ++++ b/kernel/sched/core.c
5903 +@@ -1852,6 +1852,9 @@ out:
5904 +
5905 + bool cpus_share_cache(int this_cpu, int that_cpu)
5906 + {
5907 ++ if (this_cpu == that_cpu)
5908 ++ return true;
5909 ++
5910 + return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
5911 + }
5912 + #endif /* CONFIG_SMP */
5913 +diff --git a/kernel/signal.c b/kernel/signal.c
5914 +index deb36b35c30be..3619ab24644f5 100644
5915 +--- a/kernel/signal.c
5916 ++++ b/kernel/signal.c
5917 +@@ -1838,16 +1838,6 @@ static inline int may_ptrace_stop(void)
5918 + return 1;
5919 + }
5920 +
5921 +-/*
5922 +- * Return non-zero if there is a SIGKILL that should be waking us up.
5923 +- * Called with the siglock held.
5924 +- */
5925 +-static int sigkill_pending(struct task_struct *tsk)
5926 +-{
5927 +- return sigismember(&tsk->pending.signal, SIGKILL) ||
5928 +- sigismember(&tsk->signal->shared_pending.signal, SIGKILL);
5929 +-}
5930 +-
5931 + /*
5932 + * This must be called with current->sighand->siglock held.
5933 + *
5934 +@@ -1873,17 +1863,16 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info)
5935 + * calling arch_ptrace_stop, so we must release it now.
5936 + * To preserve proper semantics, we must do this before
5937 + * any signal bookkeeping like checking group_stop_count.
5938 +- * Meanwhile, a SIGKILL could come in before we retake the
5939 +- * siglock. That must prevent us from sleeping in TASK_TRACED.
5940 +- * So after regaining the lock, we must check for SIGKILL.
5941 + */
5942 + spin_unlock_irq(&current->sighand->siglock);
5943 + arch_ptrace_stop(exit_code, info);
5944 + spin_lock_irq(&current->sighand->siglock);
5945 +- if (sigkill_pending(current))
5946 +- return;
5947 + }
5948 +
5949 ++ /*
5950 ++ * schedule() will not sleep if there is a pending signal that
5951 ++ * can awaken the task.
5952 ++ */
5953 + set_special_state(TASK_TRACED);
5954 +
5955 + /*
5956 +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
5957 +index 552104837845f..cb4f6f9e27059 100644
5958 +--- a/kernel/trace/trace.c
5959 ++++ b/kernel/trace/trace.c
5960 +@@ -1723,8 +1723,15 @@ void tracing_reset_all_online_cpus(void)
5961 + }
5962 + }
5963 +
5964 ++/*
5965 ++ * The tgid_map array maps from pid to tgid; i.e. the value stored at index i
5966 ++ * is the tgid last observed corresponding to pid=i.
5967 ++ */
5968 + static int *tgid_map;
5969 +
5970 ++/* The maximum valid index into tgid_map. */
5971 ++static size_t tgid_map_max;
5972 ++
5973 + #define SAVED_CMDLINES_DEFAULT 128
5974 + #define NO_CMDLINE_MAP UINT_MAX
5975 + static arch_spinlock_t trace_cmdline_lock = __ARCH_SPIN_LOCK_UNLOCKED;
5976 +@@ -1996,24 +2003,41 @@ void trace_find_cmdline(int pid, char comm[])
5977 + preempt_enable();
5978 + }
5979 +
5980 ++static int *trace_find_tgid_ptr(int pid)
5981 ++{
5982 ++ /*
5983 ++ * Pairs with the smp_store_release in set_tracer_flag() to ensure that
5984 ++ * if we observe a non-NULL tgid_map then we also observe the correct
5985 ++ * tgid_map_max.
5986 ++ */
5987 ++ int *map = smp_load_acquire(&tgid_map);
5988 ++
5989 ++ if (unlikely(!map || pid > tgid_map_max))
5990 ++ return NULL;
5991 ++
5992 ++ return &map[pid];
5993 ++}
5994 ++
5995 + int trace_find_tgid(int pid)
5996 + {
5997 +- if (unlikely(!tgid_map || !pid || pid > PID_MAX_DEFAULT))
5998 +- return 0;
5999 ++ int *ptr = trace_find_tgid_ptr(pid);
6000 +
6001 +- return tgid_map[pid];
6002 ++ return ptr ? *ptr : 0;
6003 + }
6004 +
6005 + static int trace_save_tgid(struct task_struct *tsk)
6006 + {
6007 ++ int *ptr;
6008 ++
6009 + /* treat recording of idle task as a success */
6010 + if (!tsk->pid)
6011 + return 1;
6012 +
6013 +- if (unlikely(!tgid_map || tsk->pid > PID_MAX_DEFAULT))
6014 ++ ptr = trace_find_tgid_ptr(tsk->pid);
6015 ++ if (!ptr)
6016 + return 0;
6017 +
6018 +- tgid_map[tsk->pid] = tsk->tgid;
6019 ++ *ptr = tsk->tgid;
6020 + return 1;
6021 + }
6022 +
6023 +@@ -4353,6 +4377,8 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
6024 +
6025 + int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
6026 + {
6027 ++ int *map;
6028 ++
6029 + if ((mask == TRACE_ITER_RECORD_TGID) ||
6030 + (mask == TRACE_ITER_RECORD_CMD))
6031 + lockdep_assert_held(&event_mutex);
6032 +@@ -4375,9 +4401,19 @@ int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
6033 + trace_event_enable_cmd_record(enabled);
6034 +
6035 + if (mask == TRACE_ITER_RECORD_TGID) {
6036 +- if (!tgid_map)
6037 +- tgid_map = kzalloc((PID_MAX_DEFAULT + 1) * sizeof(*tgid_map),
6038 +- GFP_KERNEL);
6039 ++ if (!tgid_map) {
6040 ++ tgid_map_max = pid_max;
6041 ++ map = kzalloc((tgid_map_max + 1) * sizeof(*tgid_map),
6042 ++ GFP_KERNEL);
6043 ++
6044 ++ /*
6045 ++ * Pairs with smp_load_acquire() in
6046 ++ * trace_find_tgid_ptr() to ensure that if it observes
6047 ++ * the tgid_map we just allocated then it also observes
6048 ++ * the corresponding tgid_map_max value.
6049 ++ */
6050 ++ smp_store_release(&tgid_map, map);
6051 ++ }
6052 + if (!tgid_map) {
6053 + tr->trace_flags &= ~TRACE_ITER_RECORD_TGID;
6054 + return -ENOMEM;
6055 +@@ -4752,18 +4788,14 @@ static void *saved_tgids_next(struct seq_file *m, void *v, loff_t *pos)
6056 + {
6057 + int pid = ++(*pos);
6058 +
6059 +- if (pid > PID_MAX_DEFAULT)
6060 +- return NULL;
6061 +-
6062 +- return &tgid_map[pid];
6063 ++ return trace_find_tgid_ptr(pid);
6064 + }
6065 +
6066 + static void *saved_tgids_start(struct seq_file *m, loff_t *pos)
6067 + {
6068 +- if (!tgid_map || *pos > PID_MAX_DEFAULT)
6069 +- return NULL;
6070 ++ int pid = *pos;
6071 +
6072 +- return &tgid_map[*pos];
6073 ++ return trace_find_tgid_ptr(pid);
6074 + }
6075 +
6076 + static void saved_tgids_stop(struct seq_file *m, void *v)
6077 +diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c
6078 +index 35b2ba07f3c6f..379db35838b64 100644
6079 +--- a/kernel/trace/tracing_map.c
6080 ++++ b/kernel/trace/tracing_map.c
6081 +@@ -703,29 +703,35 @@ int tracing_map_init(struct tracing_map *map)
6082 + return err;
6083 + }
6084 +
6085 +-static int cmp_entries_dup(const struct tracing_map_sort_entry **a,
6086 +- const struct tracing_map_sort_entry **b)
6087 ++static int cmp_entries_dup(const void *A, const void *B)
6088 + {
6089 ++ const struct tracing_map_sort_entry *a, *b;
6090 + int ret = 0;
6091 +
6092 +- if (memcmp((*a)->key, (*b)->key, (*a)->elt->map->key_size))
6093 ++ a = *(const struct tracing_map_sort_entry **)A;
6094 ++ b = *(const struct tracing_map_sort_entry **)B;
6095 ++
6096 ++ if (memcmp(a->key, b->key, a->elt->map->key_size))
6097 + ret = 1;
6098 +
6099 + return ret;
6100 + }
6101 +
6102 +-static int cmp_entries_sum(const struct tracing_map_sort_entry **a,
6103 +- const struct tracing_map_sort_entry **b)
6104 ++static int cmp_entries_sum(const void *A, const void *B)
6105 + {
6106 + const struct tracing_map_elt *elt_a, *elt_b;
6107 ++ const struct tracing_map_sort_entry *a, *b;
6108 + struct tracing_map_sort_key *sort_key;
6109 + struct tracing_map_field *field;
6110 + tracing_map_cmp_fn_t cmp_fn;
6111 + void *val_a, *val_b;
6112 + int ret = 0;
6113 +
6114 +- elt_a = (*a)->elt;
6115 +- elt_b = (*b)->elt;
6116 ++ a = *(const struct tracing_map_sort_entry **)A;
6117 ++ b = *(const struct tracing_map_sort_entry **)B;
6118 ++
6119 ++ elt_a = a->elt;
6120 ++ elt_b = b->elt;
6121 +
6122 + sort_key = &elt_a->map->sort_key;
6123 +
6124 +@@ -742,18 +748,21 @@ static int cmp_entries_sum(const struct tracing_map_sort_entry **a,
6125 + return ret;
6126 + }
6127 +
6128 +-static int cmp_entries_key(const struct tracing_map_sort_entry **a,
6129 +- const struct tracing_map_sort_entry **b)
6130 ++static int cmp_entries_key(const void *A, const void *B)
6131 + {
6132 + const struct tracing_map_elt *elt_a, *elt_b;
6133 ++ const struct tracing_map_sort_entry *a, *b;
6134 + struct tracing_map_sort_key *sort_key;
6135 + struct tracing_map_field *field;
6136 + tracing_map_cmp_fn_t cmp_fn;
6137 + void *val_a, *val_b;
6138 + int ret = 0;
6139 +
6140 +- elt_a = (*a)->elt;
6141 +- elt_b = (*b)->elt;
6142 ++ a = *(const struct tracing_map_sort_entry **)A;
6143 ++ b = *(const struct tracing_map_sort_entry **)B;
6144 ++
6145 ++ elt_a = a->elt;
6146 ++ elt_b = b->elt;
6147 +
6148 + sort_key = &elt_a->map->sort_key;
6149 +
6150 +@@ -926,10 +935,8 @@ static void sort_secondary(struct tracing_map *map,
6151 + struct tracing_map_sort_key *primary_key,
6152 + struct tracing_map_sort_key *secondary_key)
6153 + {
6154 +- int (*primary_fn)(const struct tracing_map_sort_entry **,
6155 +- const struct tracing_map_sort_entry **);
6156 +- int (*secondary_fn)(const struct tracing_map_sort_entry **,
6157 +- const struct tracing_map_sort_entry **);
6158 ++ int (*primary_fn)(const void *, const void *);
6159 ++ int (*secondary_fn)(const void *, const void *);
6160 + unsigned i, start = 0, n_sub = 1;
6161 +
6162 + if (is_key(map, primary_key->field_idx))
6163 +@@ -998,8 +1005,7 @@ int tracing_map_sort_entries(struct tracing_map *map,
6164 + unsigned int n_sort_keys,
6165 + struct tracing_map_sort_entry ***sort_entries)
6166 + {
6167 +- int (*cmp_entries_fn)(const struct tracing_map_sort_entry **,
6168 +- const struct tracing_map_sort_entry **);
6169 ++ int (*cmp_entries_fn)(const void *, const void *);
6170 + struct tracing_map_sort_entry *sort_entry, **entries;
6171 + int i, n_entries, ret;
6172 +
6173 +diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
6174 +index 25d59a95bd668..abea25310ac73 100644
6175 +--- a/lib/decompress_unxz.c
6176 ++++ b/lib/decompress_unxz.c
6177 +@@ -167,7 +167,7 @@
6178 + * memeq and memzero are not used much and any remotely sane implementation
6179 + * is fast enough. memcpy/memmove speed matters in multi-call mode, but
6180 + * the kernel image is decompressed in single-call mode, in which only
6181 +- * memcpy speed can matter and only if there is a lot of uncompressible data
6182 ++ * memmove speed can matter and only if there is a lot of uncompressible data
6183 + * (LZMA2 stores uncompressible chunks in uncompressed form). Thus, the
6184 + * functions below should just be kept small; it's probably not worth
6185 + * optimizing for speed.
6186 +diff --git a/lib/xz/xz_dec_lzma2.c b/lib/xz/xz_dec_lzma2.c
6187 +index 08c3c80499983..2c5197d6b944d 100644
6188 +--- a/lib/xz/xz_dec_lzma2.c
6189 ++++ b/lib/xz/xz_dec_lzma2.c
6190 +@@ -387,7 +387,14 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,
6191 +
6192 + *left -= copy_size;
6193 +
6194 +- memcpy(dict->buf + dict->pos, b->in + b->in_pos, copy_size);
6195 ++ /*
6196 ++ * If doing in-place decompression in single-call mode and the
6197 ++ * uncompressed size of the file is larger than the caller
6198 ++ * thought (i.e. it is invalid input!), the buffers below may
6199 ++ * overlap and cause undefined behavior with memcpy().
6200 ++ * With valid inputs memcpy() would be fine here.
6201 ++ */
6202 ++ memmove(dict->buf + dict->pos, b->in + b->in_pos, copy_size);
6203 + dict->pos += copy_size;
6204 +
6205 + if (dict->full < dict->pos)
6206 +@@ -397,7 +404,11 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,
6207 + if (dict->pos == dict->end)
6208 + dict->pos = 0;
6209 +
6210 +- memcpy(b->out + b->out_pos, b->in + b->in_pos,
6211 ++ /*
6212 ++ * Like above but for multi-call mode: use memmove()
6213 ++ * to avoid undefined behavior with invalid input.
6214 ++ */
6215 ++ memmove(b->out + b->out_pos, b->in + b->in_pos,
6216 + copy_size);
6217 + }
6218 +
6219 +@@ -421,6 +432,12 @@ static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b)
6220 + if (dict->pos == dict->end)
6221 + dict->pos = 0;
6222 +
6223 ++ /*
6224 ++ * These buffers cannot overlap even if doing in-place
6225 ++ * decompression because in multi-call mode dict->buf
6226 ++ * has been allocated by us in this file; it's not
6227 ++ * provided by the caller like in single-call mode.
6228 ++ */
6229 + memcpy(b->out + b->out_pos, dict->buf + dict->start,
6230 + copy_size);
6231 + }
6232 +diff --git a/lib/xz/xz_dec_stream.c b/lib/xz/xz_dec_stream.c
6233 +index ac809b1e64f78..9e5b9ab537fea 100644
6234 +--- a/lib/xz/xz_dec_stream.c
6235 ++++ b/lib/xz/xz_dec_stream.c
6236 +@@ -402,12 +402,12 @@ static enum xz_ret dec_stream_header(struct xz_dec *s)
6237 + * we will accept other check types too, but then the check won't
6238 + * be verified and a warning (XZ_UNSUPPORTED_CHECK) will be given.
6239 + */
6240 ++ if (s->temp.buf[HEADER_MAGIC_SIZE + 1] > XZ_CHECK_MAX)
6241 ++ return XZ_OPTIONS_ERROR;
6242 ++
6243 + s->check_type = s->temp.buf[HEADER_MAGIC_SIZE + 1];
6244 +
6245 + #ifdef XZ_DEC_ANY_CHECK
6246 +- if (s->check_type > XZ_CHECK_MAX)
6247 +- return XZ_OPTIONS_ERROR;
6248 +-
6249 + if (s->check_type > XZ_CHECK_CRC32)
6250 + return XZ_UNSUPPORTED_CHECK;
6251 + #else
6252 +diff --git a/mm/oom_kill.c b/mm/oom_kill.c
6253 +index 6f1bed2111226..1fbed138554fe 100644
6254 +--- a/mm/oom_kill.c
6255 ++++ b/mm/oom_kill.c
6256 +@@ -1095,25 +1095,22 @@ bool out_of_memory(struct oom_control *oc)
6257 + }
6258 +
6259 + /*
6260 +- * The pagefault handler calls here because it is out of memory, so kill a
6261 +- * memory-hogging task. If oom_lock is held by somebody else, a parallel oom
6262 +- * killing is already in progress so do nothing.
6263 ++ * The pagefault handler calls here because some allocation has failed. We have
6264 ++ * to take care of the memcg OOM here because this is the only safe context without
6265 ++ * any locks held but let the oom killer triggered from the allocation context care
6266 ++ * about the global OOM.
6267 + */
6268 + void pagefault_out_of_memory(void)
6269 + {
6270 +- struct oom_control oc = {
6271 +- .zonelist = NULL,
6272 +- .nodemask = NULL,
6273 +- .memcg = NULL,
6274 +- .gfp_mask = 0,
6275 +- .order = 0,
6276 +- };
6277 ++ static DEFINE_RATELIMIT_STATE(pfoom_rs, DEFAULT_RATELIMIT_INTERVAL,
6278 ++ DEFAULT_RATELIMIT_BURST);
6279 +
6280 + if (mem_cgroup_oom_synchronize(true))
6281 + return;
6282 +
6283 +- if (!mutex_trylock(&oom_lock))
6284 ++ if (fatal_signal_pending(current))
6285 + return;
6286 +- out_of_memory(&oc);
6287 +- mutex_unlock(&oom_lock);
6288 ++
6289 ++ if (__ratelimit(&pfoom_rs))
6290 ++ pr_warn("Huh VM_FAULT_OOM leaked out to the #PF handler. Retrying PF\n");
6291 + }
6292 +diff --git a/mm/slab.h b/mm/slab.h
6293 +index 485d9fbb8802f..93a2c91f5b43c 100644
6294 +--- a/mm/slab.h
6295 ++++ b/mm/slab.h
6296 +@@ -146,7 +146,7 @@ static inline unsigned long kmem_cache_flags(unsigned long object_size,
6297 + #define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE | SLAB_RECLAIM_ACCOUNT | \
6298 + SLAB_TEMPORARY | SLAB_ACCOUNT)
6299 + #else
6300 +-#define SLAB_CACHE_FLAGS (0)
6301 ++#define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE)
6302 + #endif
6303 +
6304 + /* Common flags available with current configuration */
6305 +diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
6306 +index 633ebcac82f8d..6cdb49ae00010 100644
6307 +--- a/mm/zsmalloc.c
6308 ++++ b/mm/zsmalloc.c
6309 +@@ -1901,10 +1901,11 @@ static inline void zs_pool_dec_isolated(struct zs_pool *pool)
6310 + VM_BUG_ON(atomic_long_read(&pool->isolated_pages) <= 0);
6311 + atomic_long_dec(&pool->isolated_pages);
6312 + /*
6313 +- * There's no possibility of racing, since wait_for_isolated_drain()
6314 +- * checks the isolated count under &class->lock after enqueuing
6315 +- * on migration_wait.
6316 ++ * Checking pool->destroying must happen after atomic_long_dec()
6317 ++ * for pool->isolated_pages above. Paired with the smp_mb() in
6318 ++ * zs_unregister_migration().
6319 + */
6320 ++ smp_mb__after_atomic();
6321 + if (atomic_long_read(&pool->isolated_pages) == 0 && pool->destroying)
6322 + wake_up_all(&pool->migration_wait);
6323 + }
6324 +diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
6325 +index 12ecde765003f..89afb90458f41 100644
6326 +--- a/net/batman-adv/bridge_loop_avoidance.c
6327 ++++ b/net/batman-adv/bridge_loop_avoidance.c
6328 +@@ -1598,13 +1598,16 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
6329 + }
6330 +
6331 + /**
6332 +- * batadv_bla_check_bcast_duplist - Check if a frame is in the broadcast dup.
6333 ++ * batadv_bla_check_duplist() - Check if a frame is in the broadcast dup.
6334 + * @bat_priv: the bat priv with all the soft interface information
6335 +- * @skb: contains the bcast_packet to be checked
6336 ++ * @skb: contains the multicast packet to be checked
6337 ++ * @payload_ptr: pointer to position inside the head buffer of the skb
6338 ++ * marking the start of the data to be CRC'ed
6339 ++ * @orig: originator mac address, NULL if unknown
6340 + *
6341 +- * check if it is on our broadcast list. Another gateway might
6342 +- * have sent the same packet because it is connected to the same backbone,
6343 +- * so we have to remove this duplicate.
6344 ++ * Check if it is on our broadcast list. Another gateway might have sent the
6345 ++ * same packet because it is connected to the same backbone, so we have to
6346 ++ * remove this duplicate.
6347 + *
6348 + * This is performed by checking the CRC, which will tell us
6349 + * with a good chance that it is the same packet. If it is furthermore
6350 +@@ -1613,19 +1616,17 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
6351 + *
6352 + * Return: true if a packet is in the duplicate list, false otherwise.
6353 + */
6354 +-bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
6355 +- struct sk_buff *skb)
6356 ++static bool batadv_bla_check_duplist(struct batadv_priv *bat_priv,
6357 ++ struct sk_buff *skb, u8 *payload_ptr,
6358 ++ const u8 *orig)
6359 + {
6360 +- int i, curr;
6361 +- __be32 crc;
6362 +- struct batadv_bcast_packet *bcast_packet;
6363 + struct batadv_bcast_duplist_entry *entry;
6364 + bool ret = false;
6365 +-
6366 +- bcast_packet = (struct batadv_bcast_packet *)skb->data;
6367 ++ int i, curr;
6368 ++ __be32 crc;
6369 +
6370 + /* calculate the crc ... */
6371 +- crc = batadv_skb_crc32(skb, (u8 *)(bcast_packet + 1));
6372 ++ crc = batadv_skb_crc32(skb, payload_ptr);
6373 +
6374 + spin_lock_bh(&bat_priv->bla.bcast_duplist_lock);
6375 +
6376 +@@ -1644,8 +1645,21 @@ bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
6377 + if (entry->crc != crc)
6378 + continue;
6379 +
6380 +- if (batadv_compare_eth(entry->orig, bcast_packet->orig))
6381 +- continue;
6382 ++ /* are the originators both known and not anonymous? */
6383 ++ if (orig && !is_zero_ether_addr(orig) &&
6384 ++ !is_zero_ether_addr(entry->orig)) {
6385 ++ /* If known, check if the new frame came from
6386 ++ * the same originator:
6387 ++ * We are safe to take identical frames from the
6388 ++ * same orig, if known, as multiplications in
6389 ++ * the mesh are detected via the (orig, seqno) pair.
6390 ++ * So we can be a bit more liberal here and allow
6391 ++ * identical frames from the same orig which the source
6392 ++ * host might have sent multiple times on purpose.
6393 ++ */
6394 ++ if (batadv_compare_eth(entry->orig, orig))
6395 ++ continue;
6396 ++ }
6397 +
6398 + /* this entry seems to match: same crc, not too old,
6399 + * and from another gw. therefore return true to forbid it.
6400 +@@ -1661,7 +1675,14 @@ bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
6401 + entry = &bat_priv->bla.bcast_duplist[curr];
6402 + entry->crc = crc;
6403 + entry->entrytime = jiffies;
6404 +- ether_addr_copy(entry->orig, bcast_packet->orig);
6405 ++
6406 ++ /* known originator */
6407 ++ if (orig)
6408 ++ ether_addr_copy(entry->orig, orig);
6409 ++ /* anonymous originator */
6410 ++ else
6411 ++ eth_zero_addr(entry->orig);
6412 ++
6413 + bat_priv->bla.bcast_duplist_curr = curr;
6414 +
6415 + out:
6416 +@@ -1670,6 +1691,48 @@ out:
6417 + return ret;
6418 + }
6419 +
6420 ++/**
6421 ++ * batadv_bla_check_ucast_duplist() - Check if a frame is in the broadcast dup.
6422 ++ * @bat_priv: the bat priv with all the soft interface information
6423 ++ * @skb: contains the multicast packet to be checked, decapsulated from a
6424 ++ * unicast_packet
6425 ++ *
6426 ++ * Check if it is on our broadcast list. Another gateway might have sent the
6427 ++ * same packet because it is connected to the same backbone, so we have to
6428 ++ * remove this duplicate.
6429 ++ *
6430 ++ * Return: true if a packet is in the duplicate list, false otherwise.
6431 ++ */
6432 ++static bool batadv_bla_check_ucast_duplist(struct batadv_priv *bat_priv,
6433 ++ struct sk_buff *skb)
6434 ++{
6435 ++ return batadv_bla_check_duplist(bat_priv, skb, (u8 *)skb->data, NULL);
6436 ++}
6437 ++
6438 ++/**
6439 ++ * batadv_bla_check_bcast_duplist() - Check if a frame is in the broadcast dup.
6440 ++ * @bat_priv: the bat priv with all the soft interface information
6441 ++ * @skb: contains the bcast_packet to be checked
6442 ++ *
6443 ++ * Check if it is on our broadcast list. Another gateway might have sent the
6444 ++ * same packet because it is connected to the same backbone, so we have to
6445 ++ * remove this duplicate.
6446 ++ *
6447 ++ * Return: true if a packet is in the duplicate list, false otherwise.
6448 ++ */
6449 ++bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
6450 ++ struct sk_buff *skb)
6451 ++{
6452 ++ struct batadv_bcast_packet *bcast_packet;
6453 ++ u8 *payload_ptr;
6454 ++
6455 ++ bcast_packet = (struct batadv_bcast_packet *)skb->data;
6456 ++ payload_ptr = (u8 *)(bcast_packet + 1);
6457 ++
6458 ++ return batadv_bla_check_duplist(bat_priv, skb, payload_ptr,
6459 ++ bcast_packet->orig);
6460 ++}
6461 ++
6462 + /**
6463 + * batadv_bla_is_backbone_gw_orig - Check if the originator is a gateway for
6464 + * the VLAN identified by vid.
6465 +@@ -1884,6 +1947,14 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
6466 + packet_type == BATADV_UNICAST)
6467 + goto handled;
6468 +
6469 ++ /* potential duplicates from foreign BLA backbone gateways via
6470 ++ * multicast-in-unicast packets
6471 ++ */
6472 ++ if (is_multicast_ether_addr(ethhdr->h_dest) &&
6473 ++ packet_type == BATADV_UNICAST &&
6474 ++ batadv_bla_check_ucast_duplist(bat_priv, skb))
6475 ++ goto handled;
6476 ++
6477 + ether_addr_copy(search_claim.addr, ethhdr->h_source);
6478 + search_claim.vid = vid;
6479 + claim = batadv_claim_hash_find(bat_priv, &search_claim);
6480 +diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
6481 +index 788d62073964b..4842436c55f32 100644
6482 +--- a/net/batman-adv/fragmentation.c
6483 ++++ b/net/batman-adv/fragmentation.c
6484 +@@ -402,6 +402,7 @@ out:
6485 +
6486 + /**
6487 + * batadv_frag_create - create a fragment from skb
6488 ++ * @net_dev: outgoing device for fragment
6489 + * @skb: skb to create fragment from
6490 + * @frag_head: header to use in new fragment
6491 + * @fragment_size: size of new fragment
6492 +@@ -412,22 +413,25 @@ out:
6493 + *
6494 + * Return: the new fragment, NULL on error.
6495 + */
6496 +-static struct sk_buff *batadv_frag_create(struct sk_buff *skb,
6497 ++static struct sk_buff *batadv_frag_create(struct net_device *net_dev,
6498 ++ struct sk_buff *skb,
6499 + struct batadv_frag_packet *frag_head,
6500 + unsigned int fragment_size)
6501 + {
6502 ++ unsigned int ll_reserved = LL_RESERVED_SPACE(net_dev);
6503 ++ unsigned int tailroom = net_dev->needed_tailroom;
6504 + struct sk_buff *skb_fragment;
6505 + unsigned int header_size = sizeof(*frag_head);
6506 + unsigned int mtu = fragment_size + header_size;
6507 +
6508 +- skb_fragment = netdev_alloc_skb(NULL, mtu + ETH_HLEN);
6509 ++ skb_fragment = dev_alloc_skb(ll_reserved + mtu + tailroom);
6510 + if (!skb_fragment)
6511 + goto err;
6512 +
6513 + skb_fragment->priority = skb->priority;
6514 +
6515 + /* Eat the last mtu-bytes of the skb */
6516 +- skb_reserve(skb_fragment, header_size + ETH_HLEN);
6517 ++ skb_reserve(skb_fragment, ll_reserved + header_size);
6518 + skb_split(skb, skb_fragment, skb->len - fragment_size);
6519 +
6520 + /* Add the header */
6521 +@@ -450,11 +454,12 @@ int batadv_frag_send_packet(struct sk_buff *skb,
6522 + struct batadv_orig_node *orig_node,
6523 + struct batadv_neigh_node *neigh_node)
6524 + {
6525 ++ struct net_device *net_dev = neigh_node->if_incoming->net_dev;
6526 + struct batadv_priv *bat_priv;
6527 + struct batadv_hard_iface *primary_if = NULL;
6528 + struct batadv_frag_packet frag_header;
6529 + struct sk_buff *skb_fragment;
6530 +- unsigned int mtu = neigh_node->if_incoming->net_dev->mtu;
6531 ++ unsigned int mtu = net_dev->mtu;
6532 + unsigned int header_size = sizeof(frag_header);
6533 + unsigned int max_fragment_size, num_fragments;
6534 + int ret;
6535 +@@ -514,7 +519,7 @@ int batadv_frag_send_packet(struct sk_buff *skb,
6536 + goto put_primary_if;
6537 + }
6538 +
6539 +- skb_fragment = batadv_frag_create(skb, &frag_header,
6540 ++ skb_fragment = batadv_frag_create(net_dev, skb, &frag_header,
6541 + max_fragment_size);
6542 + if (!skb_fragment) {
6543 + ret = -ENOMEM;
6544 +@@ -533,13 +538,14 @@ int batadv_frag_send_packet(struct sk_buff *skb,
6545 + frag_header.no++;
6546 + }
6547 +
6548 +- /* Make room for the fragment header. */
6549 +- if (batadv_skb_head_push(skb, header_size) < 0 ||
6550 +- pskb_expand_head(skb, header_size + ETH_HLEN, 0, GFP_ATOMIC) < 0) {
6551 +- ret = -ENOMEM;
6552 ++ /* make sure that there is at least enough head for the fragmentation
6553 ++ * and ethernet headers
6554 ++ */
6555 ++ ret = skb_cow_head(skb, ETH_HLEN + header_size);
6556 ++ if (ret < 0)
6557 + goto put_primary_if;
6558 +- }
6559 +
6560 ++ skb_push(skb, header_size);
6561 + memcpy(skb->data, &frag_header, header_size);
6562 +
6563 + /* Send the last fragment */
6564 +diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
6565 +index 9fdfa9984f024..7bdc5f26442ef 100644
6566 +--- a/net/batman-adv/hard-interface.c
6567 ++++ b/net/batman-adv/hard-interface.c
6568 +@@ -558,6 +558,9 @@ static void batadv_hardif_recalc_extra_skbroom(struct net_device *soft_iface)
6569 + needed_headroom = lower_headroom + (lower_header_len - ETH_HLEN);
6570 + needed_headroom += batadv_max_header_len();
6571 +
6572 ++ /* fragmentation headers don't strip the unicast/... header */
6573 ++ needed_headroom += sizeof(struct batadv_frag_packet);
6574 ++
6575 + soft_iface->needed_headroom = needed_headroom;
6576 + soft_iface->needed_tailroom = lower_tailroom;
6577 + }
6578 +diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
6579 +index d47865e0e6978..fc62f325f9ec3 100644
6580 +--- a/net/batman-adv/multicast.c
6581 ++++ b/net/batman-adv/multicast.c
6582 +@@ -55,10 +55,12 @@
6583 + #include <net/ip.h>
6584 + #include <net/ipv6.h>
6585 +
6586 ++#include "bridge_loop_avoidance.h"
6587 + #include "hard-interface.h"
6588 + #include "hash.h"
6589 + #include "log.h"
6590 + #include "packet.h"
6591 ++#include "send.h"
6592 + #include "translation-table.h"
6593 + #include "tvlv.h"
6594 +
6595 +@@ -1290,6 +1292,35 @@ void batadv_mcast_free(struct batadv_priv *bat_priv)
6596 + batadv_mcast_mla_tt_retract(bat_priv, NULL);
6597 + }
6598 +
6599 ++/**
6600 ++ * batadv_mcast_forw_send_orig() - send a multicast packet to an originator
6601 ++ * @bat_priv: the bat priv with all the soft interface information
6602 ++ * @skb: the multicast packet to send
6603 ++ * @vid: the vlan identifier
6604 ++ * @orig_node: the originator to send the packet to
6605 ++ *
6606 ++ * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
6607 ++ */
6608 ++int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
6609 ++ struct sk_buff *skb,
6610 ++ unsigned short vid,
6611 ++ struct batadv_orig_node *orig_node)
6612 ++{
6613 ++ /* Avoid sending multicast-in-unicast packets to other BLA
6614 ++ * gateways - they already got the frame from the LAN side
6615 ++ * we share with them.
6616 ++ * TODO: Refactor to take BLA into account earlier, to avoid
6617 ++ * reducing the mcast_fanout count.
6618 ++ */
6619 ++ if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, vid)) {
6620 ++ dev_kfree_skb(skb);
6621 ++ return NET_XMIT_SUCCESS;
6622 ++ }
6623 ++
6624 ++ return batadv_send_skb_unicast(bat_priv, skb, BATADV_UNICAST, 0,
6625 ++ orig_node, vid);
6626 ++}
6627 ++
6628 + /**
6629 + * batadv_mcast_purge_orig - reset originator global mcast state modifications
6630 + * @orig: the originator which is going to get purged
6631 +diff --git a/net/batman-adv/multicast.h b/net/batman-adv/multicast.h
6632 +index 2a78cddab0e97..8faf4f4e0c75b 100644
6633 +--- a/net/batman-adv/multicast.h
6634 ++++ b/net/batman-adv/multicast.h
6635 +@@ -43,6 +43,11 @@ enum batadv_forw_mode
6636 + batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
6637 + struct batadv_orig_node **mcast_single_orig);
6638 +
6639 ++int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
6640 ++ struct sk_buff *skb,
6641 ++ unsigned short vid,
6642 ++ struct batadv_orig_node *orig_node);
6643 ++
6644 + void batadv_mcast_init(struct batadv_priv *bat_priv);
6645 +
6646 + int batadv_mcast_flags_seq_print_text(struct seq_file *seq, void *offset);
6647 +@@ -65,6 +70,16 @@ static inline int batadv_mcast_init(struct batadv_priv *bat_priv)
6648 + return 0;
6649 + }
6650 +
6651 ++static inline int
6652 ++batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
6653 ++ struct sk_buff *skb,
6654 ++ unsigned short vid,
6655 ++ struct batadv_orig_node *orig_node)
6656 ++{
6657 ++ kfree_skb(skb);
6658 ++ return NET_XMIT_DROP;
6659 ++}
6660 ++
6661 + static inline void batadv_mcast_free(struct batadv_priv *bat_priv)
6662 + {
6663 + }
6664 +diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
6665 +index ba9dce04343a3..7a04ac96b121a 100644
6666 +--- a/net/batman-adv/soft-interface.c
6667 ++++ b/net/batman-adv/soft-interface.c
6668 +@@ -359,9 +359,8 @@ send:
6669 + goto dropped;
6670 + ret = batadv_send_skb_via_gw(bat_priv, skb, vid);
6671 + } else if (mcast_single_orig) {
6672 +- ret = batadv_send_skb_unicast(bat_priv, skb,
6673 +- BATADV_UNICAST, 0,
6674 +- mcast_single_orig, vid);
6675 ++ ret = batadv_mcast_forw_send_orig(bat_priv, skb, vid,
6676 ++ mcast_single_orig);
6677 + } else {
6678 + if (batadv_dat_snoop_outgoing_arp_request(bat_priv,
6679 + skb))
6680 +diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
6681 +index 3905af1d300f7..13d070e7738db 100644
6682 +--- a/net/bluetooth/l2cap_sock.c
6683 ++++ b/net/bluetooth/l2cap_sock.c
6684 +@@ -1329,6 +1329,9 @@ static void l2cap_sock_close_cb(struct l2cap_chan *chan)
6685 + {
6686 + struct sock *sk = chan->data;
6687 +
6688 ++ if (!sk)
6689 ++ return;
6690 ++
6691 + l2cap_sock_kill(sk);
6692 + }
6693 +
6694 +@@ -1337,6 +1340,9 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err)
6695 + struct sock *sk = chan->data;
6696 + struct sock *parent;
6697 +
6698 ++ if (!sk)
6699 ++ return;
6700 ++
6701 + BT_DBG("chan %p state %s", chan, state_to_string(chan->state));
6702 +
6703 + /* This callback can be called both for server (BT_LISTEN)
6704 +@@ -1520,8 +1526,10 @@ static void l2cap_sock_destruct(struct sock *sk)
6705 + {
6706 + BT_DBG("sk %p", sk);
6707 +
6708 +- if (l2cap_pi(sk)->chan)
6709 ++ if (l2cap_pi(sk)->chan) {
6710 ++ l2cap_pi(sk)->chan->data = NULL;
6711 + l2cap_chan_put(l2cap_pi(sk)->chan);
6712 ++ }
6713 +
6714 + if (l2cap_pi(sk)->rx_busy_skb) {
6715 + kfree_skb(l2cap_pi(sk)->rx_busy_skb);
6716 +diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
6717 +index f681e7ce89457..a5cc8942fc3f8 100644
6718 +--- a/net/bluetooth/sco.c
6719 ++++ b/net/bluetooth/sco.c
6720 +@@ -255,7 +255,8 @@ static int sco_connect(struct hci_dev *hdev, struct sock *sk)
6721 + return err;
6722 + }
6723 +
6724 +-static int sco_send_frame(struct sock *sk, struct msghdr *msg, int len)
6725 ++static int sco_send_frame(struct sock *sk, void *buf, int len,
6726 ++ unsigned int msg_flags)
6727 + {
6728 + struct sco_conn *conn = sco_pi(sk)->conn;
6729 + struct sk_buff *skb;
6730 +@@ -267,15 +268,11 @@ static int sco_send_frame(struct sock *sk, struct msghdr *msg, int len)
6731 +
6732 + BT_DBG("sk %p len %d", sk, len);
6733 +
6734 +- skb = bt_skb_send_alloc(sk, len, msg->msg_flags & MSG_DONTWAIT, &err);
6735 ++ skb = bt_skb_send_alloc(sk, len, msg_flags & MSG_DONTWAIT, &err);
6736 + if (!skb)
6737 + return err;
6738 +
6739 +- if (memcpy_from_msg(skb_put(skb, len), msg, len)) {
6740 +- kfree_skb(skb);
6741 +- return -EFAULT;
6742 +- }
6743 +-
6744 ++ memcpy(skb_put(skb, len), buf, len);
6745 + hci_send_sco(conn->hcon, skb);
6746 +
6747 + return len;
6748 +@@ -692,6 +689,7 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
6749 + size_t len)
6750 + {
6751 + struct sock *sk = sock->sk;
6752 ++ void *buf;
6753 + int err;
6754 +
6755 + BT_DBG("sock %p, sk %p", sock, sk);
6756 +@@ -703,14 +701,24 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
6757 + if (msg->msg_flags & MSG_OOB)
6758 + return -EOPNOTSUPP;
6759 +
6760 ++ buf = kmalloc(len, GFP_KERNEL);
6761 ++ if (!buf)
6762 ++ return -ENOMEM;
6763 ++
6764 ++ if (memcpy_from_msg(buf, msg, len)) {
6765 ++ kfree(buf);
6766 ++ return -EFAULT;
6767 ++ }
6768 ++
6769 + lock_sock(sk);
6770 +
6771 + if (sk->sk_state == BT_CONNECTED)
6772 +- err = sco_send_frame(sk, msg, len);
6773 ++ err = sco_send_frame(sk, buf, len, msg->msg_flags);
6774 + else
6775 + err = -ENOTCONN;
6776 +
6777 + release_sock(sk);
6778 ++ kfree(buf);
6779 + return err;
6780 + }
6781 +
6782 +diff --git a/net/core/stream.c b/net/core/stream.c
6783 +index 31839fb06d88c..cbe52b1690707 100644
6784 +--- a/net/core/stream.c
6785 ++++ b/net/core/stream.c
6786 +@@ -195,9 +195,6 @@ void sk_stream_kill_queues(struct sock *sk)
6787 + /* First the read buffer. */
6788 + __skb_queue_purge(&sk->sk_receive_queue);
6789 +
6790 +- /* Next, the error queue. */
6791 +- __skb_queue_purge(&sk->sk_error_queue);
6792 +-
6793 + /* Next, the write queue. */
6794 + WARN_ON(!skb_queue_empty(&sk->sk_write_queue));
6795 +
6796 +diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
6797 +index 069e3c4fcc447..ac1a32d5cad3c 100644
6798 +--- a/net/core/sysctl_net_core.c
6799 ++++ b/net/core/sysctl_net_core.c
6800 +@@ -410,7 +410,7 @@ static struct ctl_table net_core_table[] = {
6801 + .mode = 0600,
6802 + .proc_handler = proc_dolongvec_minmax_bpf_restricted,
6803 + .extra1 = &long_one,
6804 +- .extra2 = &long_max,
6805 ++ .extra2 = &bpf_jit_limit_max,
6806 + },
6807 + #endif
6808 + {
6809 +diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
6810 +index e47d5047d5373..178a3b26f9d2c 100644
6811 +--- a/net/ipv6/addrconf.c
6812 ++++ b/net/ipv6/addrconf.c
6813 +@@ -2996,6 +2996,9 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
6814 + memcpy(&addr.s6_addr32[3], idev->dev->dev_addr, 4);
6815 +
6816 + if (idev->dev->flags&IFF_POINTOPOINT) {
6817 ++ if (idev->cnf.addr_gen_mode == IN6_ADDR_GEN_MODE_NONE)
6818 ++ return;
6819 ++
6820 + addr.s6_addr32[0] = htonl(0xfe800000);
6821 + scope = IFA_LINK;
6822 + plen = 64;
6823 +diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
6824 +index 02bbc2f9f1f1e..13e67eb75d841 100644
6825 +--- a/net/netfilter/nfnetlink_queue.c
6826 ++++ b/net/netfilter/nfnetlink_queue.c
6827 +@@ -543,7 +543,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
6828 + goto nla_put_failure;
6829 +
6830 + if (indev && entskb->dev &&
6831 +- entskb->mac_header != entskb->network_header) {
6832 ++ skb_mac_header_was_set(entskb)) {
6833 + struct nfqnl_msg_packet_hw phw;
6834 + int len;
6835 +
6836 +diff --git a/net/nfc/core.c b/net/nfc/core.c
6837 +index c699d64a0753a..32a2dfc08f480 100644
6838 +--- a/net/nfc/core.c
6839 ++++ b/net/nfc/core.c
6840 +@@ -106,13 +106,13 @@ int nfc_dev_up(struct nfc_dev *dev)
6841 +
6842 + device_lock(&dev->dev);
6843 +
6844 +- if (dev->rfkill && rfkill_blocked(dev->rfkill)) {
6845 +- rc = -ERFKILL;
6846 ++ if (!device_is_registered(&dev->dev)) {
6847 ++ rc = -ENODEV;
6848 + goto error;
6849 + }
6850 +
6851 +- if (!device_is_registered(&dev->dev)) {
6852 +- rc = -ENODEV;
6853 ++ if (dev->rfkill && rfkill_blocked(dev->rfkill)) {
6854 ++ rc = -ERFKILL;
6855 + goto error;
6856 + }
6857 +
6858 +@@ -1133,11 +1133,7 @@ int nfc_register_device(struct nfc_dev *dev)
6859 + if (rc)
6860 + pr_err("Could not register llcp device\n");
6861 +
6862 +- rc = nfc_genl_device_added(dev);
6863 +- if (rc)
6864 +- pr_debug("The userspace won't be notified that the device %s was added\n",
6865 +- dev_name(&dev->dev));
6866 +-
6867 ++ device_lock(&dev->dev);
6868 + dev->rfkill = rfkill_alloc(dev_name(&dev->dev), &dev->dev,
6869 + RFKILL_TYPE_NFC, &nfc_rfkill_ops, dev);
6870 + if (dev->rfkill) {
6871 +@@ -1146,6 +1142,12 @@ int nfc_register_device(struct nfc_dev *dev)
6872 + dev->rfkill = NULL;
6873 + }
6874 + }
6875 ++ device_unlock(&dev->dev);
6876 ++
6877 ++ rc = nfc_genl_device_added(dev);
6878 ++ if (rc)
6879 ++ pr_debug("The userspace won't be notified that the device %s was added\n",
6880 ++ dev_name(&dev->dev));
6881 +
6882 + return 0;
6883 + }
6884 +@@ -1162,10 +1164,17 @@ void nfc_unregister_device(struct nfc_dev *dev)
6885 +
6886 + pr_debug("dev_name=%s\n", dev_name(&dev->dev));
6887 +
6888 ++ rc = nfc_genl_device_removed(dev);
6889 ++ if (rc)
6890 ++ pr_debug("The userspace won't be notified that the device %s "
6891 ++ "was removed\n", dev_name(&dev->dev));
6892 ++
6893 ++ device_lock(&dev->dev);
6894 + if (dev->rfkill) {
6895 + rfkill_unregister(dev->rfkill);
6896 + rfkill_destroy(dev->rfkill);
6897 + }
6898 ++ device_unlock(&dev->dev);
6899 +
6900 + if (dev->ops->check_presence) {
6901 + device_lock(&dev->dev);
6902 +@@ -1175,11 +1184,6 @@ void nfc_unregister_device(struct nfc_dev *dev)
6903 + cancel_work_sync(&dev->check_pres_work);
6904 + }
6905 +
6906 +- rc = nfc_genl_device_removed(dev);
6907 +- if (rc)
6908 +- pr_debug("The userspace won't be notified that the device %s "
6909 +- "was removed\n", dev_name(&dev->dev));
6910 +-
6911 + nfc_llcp_unregister_device(dev);
6912 +
6913 + mutex_lock(&nfc_devlist_mutex);
6914 +diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
6915 +index d3b7419f8b8f0..c73651faa5494 100644
6916 +--- a/net/nfc/nci/core.c
6917 ++++ b/net/nfc/nci/core.c
6918 +@@ -156,12 +156,15 @@ inline int nci_request(struct nci_dev *ndev,
6919 + {
6920 + int rc;
6921 +
6922 +- if (!test_bit(NCI_UP, &ndev->flags))
6923 +- return -ENETDOWN;
6924 +-
6925 + /* Serialize all requests */
6926 + mutex_lock(&ndev->req_lock);
6927 +- rc = __nci_request(ndev, req, opt, timeout);
6928 ++ /* check the state after obtaing the lock against any races
6929 ++ * from nci_close_device when the device gets removed.
6930 ++ */
6931 ++ if (test_bit(NCI_UP, &ndev->flags))
6932 ++ rc = __nci_request(ndev, req, opt, timeout);
6933 ++ else
6934 ++ rc = -ENETDOWN;
6935 + mutex_unlock(&ndev->req_lock);
6936 +
6937 + return rc;
6938 +diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
6939 +index 02a171916dd2b..8b211d164beea 100644
6940 +--- a/net/vmw_vsock/af_vsock.c
6941 ++++ b/net/vmw_vsock/af_vsock.c
6942 +@@ -1166,6 +1166,8 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr,
6943 + * non-blocking call.
6944 + */
6945 + err = -EALREADY;
6946 ++ if (flags & O_NONBLOCK)
6947 ++ goto out;
6948 + break;
6949 + default:
6950 + if ((sk->sk_state == TCP_LISTEN) ||
6951 +diff --git a/net/wireless/util.c b/net/wireless/util.c
6952 +index bf4dd297a4db4..94849702b518e 100644
6953 +--- a/net/wireless/util.c
6954 ++++ b/net/wireless/util.c
6955 +@@ -1026,6 +1026,7 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
6956 +
6957 + switch (otype) {
6958 + case NL80211_IFTYPE_AP:
6959 ++ case NL80211_IFTYPE_P2P_GO:
6960 + cfg80211_stop_ap(rdev, dev, true);
6961 + break;
6962 + case NL80211_IFTYPE_ADHOC:
6963 +diff --git a/samples/kprobes/kretprobe_example.c b/samples/kprobes/kretprobe_example.c
6964 +index 7f9060f435cde..da6de5e78e1dd 100644
6965 +--- a/samples/kprobes/kretprobe_example.c
6966 ++++ b/samples/kprobes/kretprobe_example.c
6967 +@@ -83,7 +83,7 @@ static int __init kretprobe_init(void)
6968 + ret = register_kretprobe(&my_kretprobe);
6969 + if (ret < 0) {
6970 + pr_err("register_kretprobe failed, returned %d\n", ret);
6971 +- return -1;
6972 ++ return ret;
6973 + }
6974 + pr_info("Planted return probe at %s: %p\n",
6975 + my_kretprobe.kp.symbol_name, my_kretprobe.kp.addr);
6976 +diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
6977 +index 2977371b29563..de5196c08943a 100755
6978 +--- a/scripts/leaking_addresses.pl
6979 ++++ b/scripts/leaking_addresses.pl
6980 +@@ -262,8 +262,9 @@ sub parse_file
6981 +
6982 + open my $fh, "<", $file or return;
6983 + while ( <$fh> ) {
6984 ++ chomp;
6985 + if (may_leak_address($_)) {
6986 +- print $file . ': ' . $_;
6987 ++ printf("$file: $_\n");
6988 + }
6989 + }
6990 + close $fh;
6991 +diff --git a/security/apparmor/label.c b/security/apparmor/label.c
6992 +index 212a0f39ddae8..4e5450dee28a3 100644
6993 +--- a/security/apparmor/label.c
6994 ++++ b/security/apparmor/label.c
6995 +@@ -1431,7 +1431,7 @@ bool aa_update_label_name(struct aa_ns *ns, struct aa_label *label, gfp_t gfp)
6996 + if (label->hname || labels_ns(label) != ns)
6997 + return res;
6998 +
6999 +- if (aa_label_acntsxprint(&name, ns, label, FLAGS_NONE, gfp) == -1)
7000 ++ if (aa_label_acntsxprint(&name, ns, label, FLAGS_NONE, gfp) < 0)
7001 + return res;
7002 +
7003 + ls = labels_set(label);
7004 +@@ -1681,7 +1681,7 @@ int aa_label_asxprint(char **strp, struct aa_ns *ns, struct aa_label *label,
7005 +
7006 + /**
7007 + * aa_label_acntsxprint - allocate a __counted string buffer and print label
7008 +- * @strp: buffer to write to. (MAY BE NULL if @size == 0)
7009 ++ * @strp: buffer to write to.
7010 + * @ns: namespace profile is being viewed from
7011 + * @label: label to view (NOT NULL)
7012 + * @flags: flags controlling what label info is printed
7013 +diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
7014 +index 1d1a7053144b4..6e761b07cb3f0 100644
7015 +--- a/security/integrity/evm/evm_main.c
7016 ++++ b/security/integrity/evm/evm_main.c
7017 +@@ -56,7 +56,7 @@ char *evm_config_xattrnames[] = {
7018 + NULL
7019 + };
7020 +
7021 +-static int evm_fixmode;
7022 ++static int evm_fixmode __ro_after_init;
7023 + static int __init evm_set_fixmode(char *str)
7024 + {
7025 + if (strncmp(str, "fix", 3) == 0)
7026 +diff --git a/security/security.c b/security/security.c
7027 +index 4fbe4e495c021..737a5985343cd 100644
7028 +--- a/security/security.c
7029 ++++ b/security/security.c
7030 +@@ -222,25 +222,25 @@ EXPORT_SYMBOL(unregister_lsm_notifier);
7031 +
7032 + /* Security operations */
7033 +
7034 +-int security_binder_set_context_mgr(struct task_struct *mgr)
7035 ++int security_binder_set_context_mgr(const struct cred *mgr)
7036 + {
7037 + return call_int_hook(binder_set_context_mgr, 0, mgr);
7038 + }
7039 +
7040 +-int security_binder_transaction(struct task_struct *from,
7041 +- struct task_struct *to)
7042 ++int security_binder_transaction(const struct cred *from,
7043 ++ const struct cred *to)
7044 + {
7045 + return call_int_hook(binder_transaction, 0, from, to);
7046 + }
7047 +
7048 +-int security_binder_transfer_binder(struct task_struct *from,
7049 +- struct task_struct *to)
7050 ++int security_binder_transfer_binder(const struct cred *from,
7051 ++ const struct cred *to)
7052 + {
7053 + return call_int_hook(binder_transfer_binder, 0, from, to);
7054 + }
7055 +
7056 +-int security_binder_transfer_file(struct task_struct *from,
7057 +- struct task_struct *to, struct file *file)
7058 ++int security_binder_transfer_file(const struct cred *from,
7059 ++ const struct cred *to, struct file *file)
7060 + {
7061 + return call_int_hook(binder_transfer_file, 0, from, to, file);
7062 + }
7063 +diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
7064 +index 895d369bc4103..9bb1d492f7047 100644
7065 +--- a/security/selinux/hooks.c
7066 ++++ b/security/selinux/hooks.c
7067 +@@ -2136,21 +2136,18 @@ static inline u32 open_file_to_av(struct file *file)
7068 +
7069 + /* Hook functions begin here. */
7070 +
7071 +-static int selinux_binder_set_context_mgr(struct task_struct *mgr)
7072 ++static int selinux_binder_set_context_mgr(const struct cred *mgr)
7073 + {
7074 +- u32 mysid = current_sid();
7075 +- u32 mgrsid = task_sid(mgr);
7076 +-
7077 +- return avc_has_perm(mysid, mgrsid, SECCLASS_BINDER,
7078 ++ return avc_has_perm(current_sid(), cred_sid(mgr), SECCLASS_BINDER,
7079 + BINDER__SET_CONTEXT_MGR, NULL);
7080 + }
7081 +
7082 +-static int selinux_binder_transaction(struct task_struct *from,
7083 +- struct task_struct *to)
7084 ++static int selinux_binder_transaction(const struct cred *from,
7085 ++ const struct cred *to)
7086 + {
7087 + u32 mysid = current_sid();
7088 +- u32 fromsid = task_sid(from);
7089 +- u32 tosid = task_sid(to);
7090 ++ u32 fromsid = cred_sid(from);
7091 ++ u32 tosid = cred_sid(to);
7092 + int rc;
7093 +
7094 + if (mysid != fromsid) {
7095 +@@ -2164,21 +2161,19 @@ static int selinux_binder_transaction(struct task_struct *from,
7096 + NULL);
7097 + }
7098 +
7099 +-static int selinux_binder_transfer_binder(struct task_struct *from,
7100 +- struct task_struct *to)
7101 ++static int selinux_binder_transfer_binder(const struct cred *from,
7102 ++ const struct cred *to)
7103 + {
7104 +- u32 fromsid = task_sid(from);
7105 +- u32 tosid = task_sid(to);
7106 +-
7107 +- return avc_has_perm(fromsid, tosid, SECCLASS_BINDER, BINDER__TRANSFER,
7108 ++ return avc_has_perm(cred_sid(from), cred_sid(to),
7109 ++ SECCLASS_BINDER, BINDER__TRANSFER,
7110 + NULL);
7111 + }
7112 +
7113 +-static int selinux_binder_transfer_file(struct task_struct *from,
7114 +- struct task_struct *to,
7115 ++static int selinux_binder_transfer_file(const struct cred *from,
7116 ++ const struct cred *to,
7117 + struct file *file)
7118 + {
7119 +- u32 sid = task_sid(to);
7120 ++ u32 sid = cred_sid(to);
7121 + struct file_security_struct *fsec = file->f_security;
7122 + struct dentry *dentry = file->f_path.dentry;
7123 + struct inode_security_struct *isec;
7124 +diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
7125 +index 009e83ee2d002..a9c516362170a 100644
7126 +--- a/security/smack/smackfs.c
7127 ++++ b/security/smack/smackfs.c
7128 +@@ -721,9 +721,7 @@ static void smk_cipso_doi(void)
7129 + printk(KERN_WARNING "%s:%d remove rc = %d\n",
7130 + __func__, __LINE__, rc);
7131 +
7132 +- doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL);
7133 +- if (doip == NULL)
7134 +- panic("smack: Failed to initialize cipso DOI.\n");
7135 ++ doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL | __GFP_NOFAIL);
7136 + doip->map.std = NULL;
7137 + doip->doi = smk_cipso_doi_value;
7138 + doip->type = CIPSO_V4_MAP_PASS;
7139 +@@ -742,7 +740,7 @@ static void smk_cipso_doi(void)
7140 + if (rc != 0) {
7141 + printk(KERN_WARNING "%s:%d map add rc = %d\n",
7142 + __func__, __LINE__, rc);
7143 +- kfree(doip);
7144 ++ netlbl_cfg_cipsov4_del(doip->doi, &nai);
7145 + return;
7146 + }
7147 + }
7148 +@@ -859,6 +857,7 @@ static int smk_open_cipso(struct inode *inode, struct file *file)
7149 + static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
7150 + size_t count, loff_t *ppos, int format)
7151 + {
7152 ++ struct netlbl_lsm_catmap *old_cat;
7153 + struct smack_known *skp;
7154 + struct netlbl_lsm_secattr ncats;
7155 + char mapcatset[SMK_CIPSOLEN];
7156 +@@ -948,9 +947,11 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
7157 +
7158 + rc = smk_netlbl_mls(maplevel, mapcatset, &ncats, SMK_CIPSOLEN);
7159 + if (rc >= 0) {
7160 +- netlbl_catmap_free(skp->smk_netlabel.attr.mls.cat);
7161 ++ old_cat = skp->smk_netlabel.attr.mls.cat;
7162 + skp->smk_netlabel.attr.mls.cat = ncats.attr.mls.cat;
7163 + skp->smk_netlabel.attr.mls.lvl = ncats.attr.mls.lvl;
7164 ++ synchronize_rcu();
7165 ++ netlbl_catmap_free(old_cat);
7166 + rc = count;
7167 + }
7168 +
7169 +diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
7170 +index 379bf486ccc74..c91048fd28223 100644
7171 +--- a/sound/core/oss/mixer_oss.c
7172 ++++ b/sound/core/oss/mixer_oss.c
7173 +@@ -145,11 +145,13 @@ static int snd_mixer_oss_devmask(struct snd_mixer_oss_file *fmixer)
7174 +
7175 + if (mixer == NULL)
7176 + return -EIO;
7177 ++ mutex_lock(&mixer->reg_mutex);
7178 + for (chn = 0; chn < 31; chn++) {
7179 + pslot = &mixer->slots[chn];
7180 + if (pslot->put_volume || pslot->put_recsrc)
7181 + result |= 1 << chn;
7182 + }
7183 ++ mutex_unlock(&mixer->reg_mutex);
7184 + return result;
7185 + }
7186 +
7187 +@@ -161,11 +163,13 @@ static int snd_mixer_oss_stereodevs(struct snd_mixer_oss_file *fmixer)
7188 +
7189 + if (mixer == NULL)
7190 + return -EIO;
7191 ++ mutex_lock(&mixer->reg_mutex);
7192 + for (chn = 0; chn < 31; chn++) {
7193 + pslot = &mixer->slots[chn];
7194 + if (pslot->put_volume && pslot->stereo)
7195 + result |= 1 << chn;
7196 + }
7197 ++ mutex_unlock(&mixer->reg_mutex);
7198 + return result;
7199 + }
7200 +
7201 +@@ -176,6 +180,7 @@ static int snd_mixer_oss_recmask(struct snd_mixer_oss_file *fmixer)
7202 +
7203 + if (mixer == NULL)
7204 + return -EIO;
7205 ++ mutex_lock(&mixer->reg_mutex);
7206 + if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */
7207 + result = mixer->mask_recsrc;
7208 + } else {
7209 +@@ -187,6 +192,7 @@ static int snd_mixer_oss_recmask(struct snd_mixer_oss_file *fmixer)
7210 + result |= 1 << chn;
7211 + }
7212 + }
7213 ++ mutex_unlock(&mixer->reg_mutex);
7214 + return result;
7215 + }
7216 +
7217 +@@ -197,11 +203,12 @@ static int snd_mixer_oss_get_recsrc(struct snd_mixer_oss_file *fmixer)
7218 +
7219 + if (mixer == NULL)
7220 + return -EIO;
7221 ++ mutex_lock(&mixer->reg_mutex);
7222 + if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */
7223 +- int err;
7224 + unsigned int index;
7225 +- if ((err = mixer->get_recsrc(fmixer, &index)) < 0)
7226 +- return err;
7227 ++ result = mixer->get_recsrc(fmixer, &index);
7228 ++ if (result < 0)
7229 ++ goto unlock;
7230 + result = 1 << index;
7231 + } else {
7232 + struct snd_mixer_oss_slot *pslot;
7233 +@@ -216,7 +223,10 @@ static int snd_mixer_oss_get_recsrc(struct snd_mixer_oss_file *fmixer)
7234 + }
7235 + }
7236 + }
7237 +- return mixer->oss_recsrc = result;
7238 ++ mixer->oss_recsrc = result;
7239 ++ unlock:
7240 ++ mutex_unlock(&mixer->reg_mutex);
7241 ++ return result;
7242 + }
7243 +
7244 + static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsrc)
7245 +@@ -229,6 +239,7 @@ static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsr
7246 +
7247 + if (mixer == NULL)
7248 + return -EIO;
7249 ++ mutex_lock(&mixer->reg_mutex);
7250 + if (mixer->get_recsrc && mixer->put_recsrc) { /* exclusive input */
7251 + if (recsrc & ~mixer->oss_recsrc)
7252 + recsrc &= ~mixer->oss_recsrc;
7253 +@@ -254,6 +265,7 @@ static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsr
7254 + }
7255 + }
7256 + }
7257 ++ mutex_unlock(&mixer->reg_mutex);
7258 + return result;
7259 + }
7260 +
7261 +@@ -265,6 +277,7 @@ static int snd_mixer_oss_get_volume(struct snd_mixer_oss_file *fmixer, int slot)
7262 +
7263 + if (mixer == NULL || slot > 30)
7264 + return -EIO;
7265 ++ mutex_lock(&mixer->reg_mutex);
7266 + pslot = &mixer->slots[slot];
7267 + left = pslot->volume[0];
7268 + right = pslot->volume[1];
7269 +@@ -272,15 +285,21 @@ static int snd_mixer_oss_get_volume(struct snd_mixer_oss_file *fmixer, int slot)
7270 + result = pslot->get_volume(fmixer, pslot, &left, &right);
7271 + if (!pslot->stereo)
7272 + right = left;
7273 +- if (snd_BUG_ON(left < 0 || left > 100))
7274 +- return -EIO;
7275 +- if (snd_BUG_ON(right < 0 || right > 100))
7276 +- return -EIO;
7277 ++ if (snd_BUG_ON(left < 0 || left > 100)) {
7278 ++ result = -EIO;
7279 ++ goto unlock;
7280 ++ }
7281 ++ if (snd_BUG_ON(right < 0 || right > 100)) {
7282 ++ result = -EIO;
7283 ++ goto unlock;
7284 ++ }
7285 + if (result >= 0) {
7286 + pslot->volume[0] = left;
7287 + pslot->volume[1] = right;
7288 + result = (left & 0xff) | ((right & 0xff) << 8);
7289 + }
7290 ++ unlock:
7291 ++ mutex_unlock(&mixer->reg_mutex);
7292 + return result;
7293 + }
7294 +
7295 +@@ -293,6 +312,7 @@ static int snd_mixer_oss_set_volume(struct snd_mixer_oss_file *fmixer,
7296 +
7297 + if (mixer == NULL || slot > 30)
7298 + return -EIO;
7299 ++ mutex_lock(&mixer->reg_mutex);
7300 + pslot = &mixer->slots[slot];
7301 + if (left > 100)
7302 + left = 100;
7303 +@@ -303,10 +323,13 @@ static int snd_mixer_oss_set_volume(struct snd_mixer_oss_file *fmixer,
7304 + if (pslot->put_volume)
7305 + result = pslot->put_volume(fmixer, pslot, left, right);
7306 + if (result < 0)
7307 +- return result;
7308 ++ goto unlock;
7309 + pslot->volume[0] = left;
7310 + pslot->volume[1] = right;
7311 +- return (left & 0xff) | ((right & 0xff) << 8);
7312 ++ result = (left & 0xff) | ((right & 0xff) << 8);
7313 ++ unlock:
7314 ++ mutex_unlock(&mixer->reg_mutex);
7315 ++ return result;
7316 + }
7317 +
7318 + static int snd_mixer_oss_ioctl1(struct snd_mixer_oss_file *fmixer, unsigned int cmd, unsigned long arg)
7319 +diff --git a/sound/core/timer.c b/sound/core/timer.c
7320 +index eb31c13c8ed0d..c333ceb80d5f3 100644
7321 +--- a/sound/core/timer.c
7322 ++++ b/sound/core/timer.c
7323 +@@ -583,13 +583,13 @@ static int snd_timer_stop1(struct snd_timer_instance *timeri, bool stop)
7324 + if (!timer)
7325 + return -EINVAL;
7326 + spin_lock_irqsave(&timer->lock, flags);
7327 ++ list_del_init(&timeri->ack_list);
7328 ++ list_del_init(&timeri->active_list);
7329 + if (!(timeri->flags & (SNDRV_TIMER_IFLG_RUNNING |
7330 + SNDRV_TIMER_IFLG_START))) {
7331 + result = -EBUSY;
7332 + goto unlock;
7333 + }
7334 +- list_del_init(&timeri->ack_list);
7335 +- list_del_init(&timeri->active_list);
7336 + if (timer->card && timer->card->shutdown)
7337 + goto unlock;
7338 + if (stop) {
7339 +@@ -624,23 +624,22 @@ static int snd_timer_stop1(struct snd_timer_instance *timeri, bool stop)
7340 + static int snd_timer_stop_slave(struct snd_timer_instance *timeri, bool stop)
7341 + {
7342 + unsigned long flags;
7343 ++ bool running;
7344 +
7345 + spin_lock_irqsave(&slave_active_lock, flags);
7346 +- if (!(timeri->flags & SNDRV_TIMER_IFLG_RUNNING)) {
7347 +- spin_unlock_irqrestore(&slave_active_lock, flags);
7348 +- return -EBUSY;
7349 +- }
7350 ++ running = timeri->flags & SNDRV_TIMER_IFLG_RUNNING;
7351 + timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
7352 + if (timeri->timer) {
7353 + spin_lock(&timeri->timer->lock);
7354 + list_del_init(&timeri->ack_list);
7355 + list_del_init(&timeri->active_list);
7356 +- snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP :
7357 +- SNDRV_TIMER_EVENT_PAUSE);
7358 ++ if (running)
7359 ++ snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP :
7360 ++ SNDRV_TIMER_EVENT_PAUSE);
7361 + spin_unlock(&timeri->timer->lock);
7362 + }
7363 + spin_unlock_irqrestore(&slave_active_lock, flags);
7364 +- return 0;
7365 ++ return running ? 0 : -EBUSY;
7366 + }
7367 +
7368 + /*
7369 +diff --git a/sound/isa/gus/gus_dma.c b/sound/isa/gus/gus_dma.c
7370 +index 36c27c8323601..2e27cd3427c87 100644
7371 +--- a/sound/isa/gus/gus_dma.c
7372 ++++ b/sound/isa/gus/gus_dma.c
7373 +@@ -141,6 +141,8 @@ static void snd_gf1_dma_interrupt(struct snd_gus_card * gus)
7374 + }
7375 + block = snd_gf1_dma_next_block(gus);
7376 + spin_unlock(&gus->dma_lock);
7377 ++ if (!block)
7378 ++ return;
7379 + snd_gf1_dma_program(gus, block->addr, block->buf_addr, block->count, (unsigned short) block->cmd);
7380 + kfree(block);
7381 + #if 0
7382 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
7383 +index e399c5718ee60..de090a3d2b384 100644
7384 +--- a/sound/pci/hda/hda_intel.c
7385 ++++ b/sound/pci/hda/hda_intel.c
7386 +@@ -742,13 +742,17 @@ static int azx_intel_link_power(struct azx *chip, bool enable)
7387 + * the update-IRQ timing. The IRQ is issued before actually the
7388 + * data is processed. So, we need to process it afterwords in a
7389 + * workqueue.
7390 ++ *
7391 ++ * Returns 1 if OK to proceed, 0 for delay handling, -1 for skipping update
7392 + */
7393 + static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
7394 + {
7395 + struct snd_pcm_substream *substream = azx_dev->core.substream;
7396 ++ struct snd_pcm_runtime *runtime = substream->runtime;
7397 + int stream = substream->stream;
7398 + u32 wallclk;
7399 + unsigned int pos;
7400 ++ snd_pcm_uframes_t hwptr, target;
7401 +
7402 + wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk;
7403 + if (wallclk < (azx_dev->core.period_wallclk * 2) / 3)
7404 +@@ -785,6 +789,24 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
7405 + /* NG - it's below the first next period boundary */
7406 + return chip->bdl_pos_adj ? 0 : -1;
7407 + azx_dev->core.start_wallclk += wallclk;
7408 ++
7409 ++ if (azx_dev->core.no_period_wakeup)
7410 ++ return 1; /* OK, no need to check period boundary */
7411 ++
7412 ++ if (runtime->hw_ptr_base != runtime->hw_ptr_interrupt)
7413 ++ return 1; /* OK, already in hwptr updating process */
7414 ++
7415 ++ /* check whether the period gets really elapsed */
7416 ++ pos = bytes_to_frames(runtime, pos);
7417 ++ hwptr = runtime->hw_ptr_base + pos;
7418 ++ if (hwptr < runtime->status->hw_ptr)
7419 ++ hwptr += runtime->buffer_size;
7420 ++ target = runtime->hw_ptr_interrupt + runtime->period_size;
7421 ++ if (hwptr < target) {
7422 ++ /* too early wakeup, process it later */
7423 ++ return chip->bdl_pos_adj ? 0 : -1;
7424 ++ }
7425 ++
7426 + return 1; /* OK, it's fine */
7427 + }
7428 +
7429 +@@ -982,11 +1004,7 @@ static unsigned int azx_get_pos_skl(struct azx *chip, struct azx_dev *azx_dev)
7430 + if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
7431 + return azx_skl_get_dpib_pos(chip, azx_dev);
7432 +
7433 +- /* For capture, we need to read posbuf, but it requires a delay
7434 +- * for the possible boundary overlap; the read of DPIB fetches the
7435 +- * actual posbuf
7436 +- */
7437 +- udelay(20);
7438 ++ /* read of DPIB fetches the actual posbuf */
7439 + azx_skl_get_dpib_pos(chip, azx_dev);
7440 + return azx_get_pos_posbuf(chip, azx_dev);
7441 + }
7442 +diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
7443 +index e6eeecc5446ef..7ff8b9f269713 100644
7444 +--- a/sound/soc/codecs/cs42l42.c
7445 ++++ b/sound/soc/codecs/cs42l42.c
7446 +@@ -95,7 +95,7 @@ static const struct reg_default cs42l42_reg_defaults[] = {
7447 + { CS42L42_ASP_RX_INT_MASK, 0x1F },
7448 + { CS42L42_ASP_TX_INT_MASK, 0x0F },
7449 + { CS42L42_CODEC_INT_MASK, 0x03 },
7450 +- { CS42L42_SRCPL_INT_MASK, 0xFF },
7451 ++ { CS42L42_SRCPL_INT_MASK, 0x7F },
7452 + { CS42L42_VPMON_INT_MASK, 0x01 },
7453 + { CS42L42_PLL_LOCK_INT_MASK, 0x01 },
7454 + { CS42L42_TSRS_PLUG_INT_MASK, 0x0F },
7455 +@@ -132,7 +132,7 @@ static const struct reg_default cs42l42_reg_defaults[] = {
7456 + { CS42L42_MIXER_CHA_VOL, 0x3F },
7457 + { CS42L42_MIXER_ADC_VOL, 0x3F },
7458 + { CS42L42_MIXER_CHB_VOL, 0x3F },
7459 +- { CS42L42_EQ_COEF_IN0, 0x22 },
7460 ++ { CS42L42_EQ_COEF_IN0, 0x00 },
7461 + { CS42L42_EQ_COEF_IN1, 0x00 },
7462 + { CS42L42_EQ_COEF_IN2, 0x00 },
7463 + { CS42L42_EQ_COEF_IN3, 0x00 },
7464 +@@ -1805,8 +1805,9 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client,
7465 + NULL, cs42l42_irq_thread,
7466 + IRQF_ONESHOT | IRQF_TRIGGER_LOW,
7467 + "cs42l42", cs42l42);
7468 +-
7469 +- if (ret != 0)
7470 ++ if (ret == -EPROBE_DEFER)
7471 ++ goto err_disable;
7472 ++ else if (ret != 0)
7473 + dev_err(&i2c_client->dev,
7474 + "Failed to request IRQ: %d\n", ret);
7475 +
7476 +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
7477 +index 7c013d237ea19..f72fe0cba30d8 100644
7478 +--- a/sound/soc/soc-dapm.c
7479 ++++ b/sound/soc/soc-dapm.c
7480 +@@ -2491,8 +2491,13 @@ static struct snd_soc_dapm_widget *dapm_find_widget(
7481 + return NULL;
7482 + }
7483 +
7484 +-static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
7485 +- const char *pin, int status)
7486 ++/*
7487 ++ * set the DAPM pin status:
7488 ++ * returns 1 when the value has been updated, 0 when unchanged, or a negative
7489 ++ * error code; called from kcontrol put callback
7490 ++ */
7491 ++static int __snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
7492 ++ const char *pin, int status)
7493 + {
7494 + struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
7495 + int ret = 0;
7496 +@@ -2518,6 +2523,18 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
7497 + return ret;
7498 + }
7499 +
7500 ++/*
7501 ++ * similar as __snd_soc_dapm_set_pin(), but returns 0 when successful;
7502 ++ * called from several API functions below
7503 ++ */
7504 ++static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
7505 ++ const char *pin, int status)
7506 ++{
7507 ++ int ret = __snd_soc_dapm_set_pin(dapm, pin, status);
7508 ++
7509 ++ return ret < 0 ? ret : 0;
7510 ++}
7511 ++
7512 + /**
7513 + * snd_soc_dapm_sync_unlocked - scan and power dapm paths
7514 + * @dapm: DAPM context
7515 +@@ -3445,10 +3462,10 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
7516 + const char *pin = (const char *)kcontrol->private_value;
7517 + int ret;
7518 +
7519 +- if (ucontrol->value.integer.value[0])
7520 +- ret = snd_soc_dapm_enable_pin(&card->dapm, pin);
7521 +- else
7522 +- ret = snd_soc_dapm_disable_pin(&card->dapm, pin);
7523 ++ mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
7524 ++ ret = __snd_soc_dapm_set_pin(&card->dapm, pin,
7525 ++ !!ucontrol->value.integer.value[0]);
7526 ++ mutex_unlock(&card->dapm_mutex);
7527 +
7528 + snd_soc_dapm_sync(&card->dapm);
7529 + return ret;
7530 +diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c
7531 +index b9981e8c00272..82b587afa6158 100644
7532 +--- a/sound/synth/emux/emux.c
7533 ++++ b/sound/synth/emux/emux.c
7534 +@@ -101,7 +101,7 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch
7535 + emu->name = kstrdup(name, GFP_KERNEL);
7536 + emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice),
7537 + GFP_KERNEL);
7538 +- if (emu->voices == NULL)
7539 ++ if (emu->name == NULL || emu->voices == NULL)
7540 + return -ENOMEM;
7541 +
7542 + /* create soundfont list */
7543 +diff --git a/sound/usb/6fire/comm.c b/sound/usb/6fire/comm.c
7544 +index 161215d78d952..f29c115b9d564 100644
7545 +--- a/sound/usb/6fire/comm.c
7546 ++++ b/sound/usb/6fire/comm.c
7547 +@@ -99,7 +99,7 @@ static int usb6fire_comm_send_buffer(u8 *buffer, struct usb_device *dev)
7548 + int actual_len;
7549 +
7550 + ret = usb_interrupt_msg(dev, usb_sndintpipe(dev, COMM_EP),
7551 +- buffer, buffer[1] + 2, &actual_len, HZ);
7552 ++ buffer, buffer[1] + 2, &actual_len, 1000);
7553 + if (ret < 0)
7554 + return ret;
7555 + else if (actual_len != buffer[1] + 2)
7556 +diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c
7557 +index 9520b4cd70385..7a89111041edc 100644
7558 +--- a/sound/usb/6fire/firmware.c
7559 ++++ b/sound/usb/6fire/firmware.c
7560 +@@ -166,7 +166,7 @@ static int usb6fire_fw_ezusb_write(struct usb_device *device,
7561 +
7562 + ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), type,
7563 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
7564 +- value, 0, data, len, HZ);
7565 ++ value, 0, data, len, 1000);
7566 + if (ret < 0)
7567 + return ret;
7568 + else if (ret != len)
7569 +@@ -179,7 +179,7 @@ static int usb6fire_fw_ezusb_read(struct usb_device *device,
7570 + {
7571 + int ret = usb_control_msg(device, usb_rcvctrlpipe(device, 0), type,
7572 + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value,
7573 +- 0, data, len, HZ);
7574 ++ 0, data, len, 1000);
7575 + if (ret < 0)
7576 + return ret;
7577 + else if (ret != len)
7578 +@@ -194,7 +194,7 @@ static int usb6fire_fw_fpga_write(struct usb_device *device,
7579 + int ret;
7580 +
7581 + ret = usb_bulk_msg(device, usb_sndbulkpipe(device, FPGA_EP), data, len,
7582 +- &actual_len, HZ);
7583 ++ &actual_len, 1000);
7584 + if (ret < 0)
7585 + return ret;
7586 + else if (actual_len != len)
7587 +diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
7588 +index 40ddfcd4e8e99..c629a2bf6d2ce 100644
7589 +--- a/sound/usb/line6/driver.c
7590 ++++ b/sound/usb/line6/driver.c
7591 +@@ -117,12 +117,12 @@ static int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
7592 + retval = usb_interrupt_msg(line6->usbdev,
7593 + usb_sndintpipe(line6->usbdev, properties->ep_ctrl_w),
7594 + (char *)frag_buf, frag_size,
7595 +- &partial, LINE6_TIMEOUT * HZ);
7596 ++ &partial, LINE6_TIMEOUT);
7597 + } else {
7598 + retval = usb_bulk_msg(line6->usbdev,
7599 + usb_sndbulkpipe(line6->usbdev, properties->ep_ctrl_w),
7600 + (char *)frag_buf, frag_size,
7601 +- &partial, LINE6_TIMEOUT * HZ);
7602 ++ &partial, LINE6_TIMEOUT);
7603 + }
7604 +
7605 + if (retval) {
7606 +@@ -358,7 +358,7 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data,
7607 + ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
7608 + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
7609 + (datalen << 8) | 0x21, address,
7610 +- NULL, 0, LINE6_TIMEOUT * HZ);
7611 ++ NULL, 0, LINE6_TIMEOUT);
7612 +
7613 + if (ret < 0) {
7614 + dev_err(line6->ifcdev, "read request failed (error %d)\n", ret);
7615 +@@ -373,7 +373,7 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data,
7616 + USB_TYPE_VENDOR | USB_RECIP_DEVICE |
7617 + USB_DIR_IN,
7618 + 0x0012, 0x0000, len, 1,
7619 +- LINE6_TIMEOUT * HZ);
7620 ++ LINE6_TIMEOUT);
7621 + if (ret < 0) {
7622 + dev_err(line6->ifcdev,
7623 + "receive length failed (error %d)\n", ret);
7624 +@@ -401,7 +401,7 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data,
7625 + ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
7626 + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
7627 + 0x0013, 0x0000, data, datalen,
7628 +- LINE6_TIMEOUT * HZ);
7629 ++ LINE6_TIMEOUT);
7630 +
7631 + if (ret < 0)
7632 + dev_err(line6->ifcdev, "read failed (error %d)\n", ret);
7633 +@@ -433,7 +433,7 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data,
7634 + ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
7635 + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
7636 + 0x0022, address, data, datalen,
7637 +- LINE6_TIMEOUT * HZ);
7638 ++ LINE6_TIMEOUT);
7639 +
7640 + if (ret < 0) {
7641 + dev_err(line6->ifcdev,
7642 +@@ -449,7 +449,7 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data,
7643 + USB_TYPE_VENDOR | USB_RECIP_DEVICE |
7644 + USB_DIR_IN,
7645 + 0x0012, 0x0000,
7646 +- status, 1, LINE6_TIMEOUT * HZ);
7647 ++ status, 1, LINE6_TIMEOUT);
7648 +
7649 + if (ret < 0) {
7650 + dev_err(line6->ifcdev,
7651 +diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h
7652 +index dc97895547be4..80598698d7063 100644
7653 +--- a/sound/usb/line6/driver.h
7654 ++++ b/sound/usb/line6/driver.h
7655 +@@ -31,7 +31,7 @@
7656 + #define LINE6_FALLBACK_INTERVAL 10
7657 + #define LINE6_FALLBACK_MAXPACKETSIZE 16
7658 +
7659 +-#define LINE6_TIMEOUT 1
7660 ++#define LINE6_TIMEOUT 1000
7661 + #define LINE6_BUFSIZE_LISTEN 64
7662 + #define LINE6_MIDI_MESSAGE_MAXLEN 256
7663 +
7664 +diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c
7665 +index 1513fbaf70c2e..b5573eb49cb45 100644
7666 +--- a/sound/usb/line6/podhd.c
7667 ++++ b/sound/usb/line6/podhd.c
7668 +@@ -235,7 +235,7 @@ static int podhd_dev_start(struct usb_line6_podhd *pod)
7669 + ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0),
7670 + 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
7671 + 0x11, 0,
7672 +- NULL, 0, LINE6_TIMEOUT * HZ);
7673 ++ NULL, 0, LINE6_TIMEOUT);
7674 + if (ret < 0) {
7675 + dev_err(pod->line6.ifcdev, "read request failed (error %d)\n", ret);
7676 + goto exit;
7677 +@@ -245,7 +245,7 @@ static int podhd_dev_start(struct usb_line6_podhd *pod)
7678 + ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
7679 + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
7680 + 0x11, 0x0,
7681 +- init_bytes, 3, LINE6_TIMEOUT * HZ);
7682 ++ init_bytes, 3, LINE6_TIMEOUT);
7683 + if (ret < 0) {
7684 + dev_err(pod->line6.ifcdev,
7685 + "receive length failed (error %d)\n", ret);
7686 +@@ -265,7 +265,7 @@ static int podhd_dev_start(struct usb_line6_podhd *pod)
7687 + USB_REQ_SET_FEATURE,
7688 + USB_TYPE_STANDARD | USB_RECIP_DEVICE | USB_DIR_OUT,
7689 + 1, 0,
7690 +- NULL, 0, LINE6_TIMEOUT * HZ);
7691 ++ NULL, 0, LINE6_TIMEOUT);
7692 + exit:
7693 + kfree(init_bytes);
7694 + return ret;
7695 +diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c
7696 +index 4bdedfa87487a..a4fc8dc2baf39 100644
7697 +--- a/sound/usb/line6/toneport.c
7698 ++++ b/sound/usb/line6/toneport.c
7699 +@@ -133,7 +133,7 @@ static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2)
7700 +
7701 + ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
7702 + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
7703 +- cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ);
7704 ++ cmd1, cmd2, NULL, 0, LINE6_TIMEOUT);
7705 +
7706 + if (ret < 0) {
7707 + dev_err(&usbdev->dev, "send failed (error %d)\n", ret);
7708 +diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c
7709 +index 386fbfd5c6176..1aeddab02aad1 100644
7710 +--- a/sound/usb/misc/ua101.c
7711 ++++ b/sound/usb/misc/ua101.c
7712 +@@ -1032,7 +1032,7 @@ static int detect_usb_format(struct ua101 *ua)
7713 + fmt_playback->bSubframeSize * ua->playback.channels;
7714 +
7715 + epd = &ua->intf[INTF_CAPTURE]->altsetting[1].endpoint[0].desc;
7716 +- if (!usb_endpoint_is_isoc_in(epd)) {
7717 ++ if (!usb_endpoint_is_isoc_in(epd) || usb_endpoint_maxp(epd) == 0) {
7718 + dev_err(&ua->dev->dev, "invalid capture endpoint\n");
7719 + return -ENXIO;
7720 + }
7721 +@@ -1040,7 +1040,7 @@ static int detect_usb_format(struct ua101 *ua)
7722 + ua->capture.max_packet_bytes = usb_endpoint_maxp(epd);
7723 +
7724 + epd = &ua->intf[INTF_PLAYBACK]->altsetting[1].endpoint[0].desc;
7725 +- if (!usb_endpoint_is_isoc_out(epd)) {
7726 ++ if (!usb_endpoint_is_isoc_out(epd) || usb_endpoint_maxp(epd) == 0) {
7727 + dev_err(&ua->dev->dev, "invalid playback endpoint\n");
7728 + return -ENXIO;
7729 + }