Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.17 commit in: /
Date: Tue, 03 Jul 2018 13:19:10
Message-Id: 1530623936.59757de106df0c4e1e658baa34090609c99946b5.mpagano@gentoo
1 commit: 59757de106df0c4e1e658baa34090609c99946b5
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jul 3 13:18:56 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 3 13:18:56 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=59757de1
7
8 Linux patch 4.17.4
9
10 0000_README | 4 +
11 1003_linux-4.17.4.patch | 6875 +++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 6879 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index af14401..f45eebe 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -55,6 +55,10 @@ Patch: 1002_linux-4.17.3.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.17.3
21
22 +Patch: 1003_linux-4.17.4.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.17.4
25 +
26 Patch: 1800_iommu-amd-dma-direct-revert.patch
27 From: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/patch/?id=e16c4790de39dc861b749674c2a9319507f6f64f
28 Desc: Revert iommu/amd_iommu: Use CONFIG_DMA_DIRECT_OPS=y and dma_direct_{alloc,free}(). See bug #658538.
29
30 diff --git a/1003_linux-4.17.4.patch b/1003_linux-4.17.4.patch
31 new file mode 100644
32 index 0000000..76692ff
33 --- /dev/null
34 +++ b/1003_linux-4.17.4.patch
35 @@ -0,0 +1,6875 @@
36 +diff --git a/Documentation/ABI/testing/sysfs-class-cxl b/Documentation/ABI/testing/sysfs-class-cxl
37 +index 8e69345c37cc..bbbabffc682a 100644
38 +--- a/Documentation/ABI/testing/sysfs-class-cxl
39 ++++ b/Documentation/ABI/testing/sysfs-class-cxl
40 +@@ -69,7 +69,9 @@ Date: September 2014
41 + Contact: linuxppc-dev@××××××××××××.org
42 + Description: read/write
43 + Set the mode for prefaulting in segments into the segment table
44 +- when performing the START_WORK ioctl. Possible values:
45 ++ when performing the START_WORK ioctl. Only applicable when
46 ++ running under hashed page table mmu.
47 ++ Possible values:
48 + none: No prefaulting (default)
49 + work_element_descriptor: Treat the work element
50 + descriptor as an effective address and
51 +diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
52 +index eb30efdd2e78..25dc591cb110 100644
53 +--- a/Documentation/core-api/printk-formats.rst
54 ++++ b/Documentation/core-api/printk-formats.rst
55 +@@ -419,11 +419,10 @@ struct clk
56 +
57 + %pC pll1
58 + %pCn pll1
59 +- %pCr 1560000000
60 +
61 + For printing struct clk structures. %pC and %pCn print the name
62 + (Common Clock Framework) or address (legacy clock framework) of the
63 +-structure; %pCr prints the current clock rate.
64 ++structure.
65 +
66 + Passed by reference.
67 +
68 +diff --git a/Makefile b/Makefile
69 +index 31dc3a08295a..1d740dbe676d 100644
70 +--- a/Makefile
71 ++++ b/Makefile
72 +@@ -1,7 +1,7 @@
73 + # SPDX-License-Identifier: GPL-2.0
74 + VERSION = 4
75 + PATCHLEVEL = 17
76 +-SUBLEVEL = 3
77 ++SUBLEVEL = 4
78 + EXTRAVERSION =
79 + NAME = Merciless Moray
80 +
81 +diff --git a/arch/arm/boot/dts/mt7623.dtsi b/arch/arm/boot/dts/mt7623.dtsi
82 +index e10c03496524..a115575b38bf 100644
83 +--- a/arch/arm/boot/dts/mt7623.dtsi
84 ++++ b/arch/arm/boot/dts/mt7623.dtsi
85 +@@ -22,11 +22,12 @@
86 + #include <dt-bindings/phy/phy.h>
87 + #include <dt-bindings/reset/mt2701-resets.h>
88 + #include <dt-bindings/thermal/thermal.h>
89 +-#include "skeleton64.dtsi"
90 +
91 + / {
92 + compatible = "mediatek,mt7623";
93 + interrupt-parent = <&sysirq>;
94 ++ #address-cells = <2>;
95 ++ #size-cells = <2>;
96 +
97 + cpu_opp_table: opp-table {
98 + compatible = "operating-points-v2";
99 +diff --git a/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts b/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
100 +index bbf56f855e46..5938e4c79deb 100644
101 +--- a/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
102 ++++ b/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
103 +@@ -109,6 +109,7 @@
104 + };
105 +
106 + memory@80000000 {
107 ++ device_type = "memory";
108 + reg = <0 0x80000000 0 0x40000000>;
109 + };
110 + };
111 +diff --git a/arch/arm/boot/dts/mt7623n-rfb.dtsi b/arch/arm/boot/dts/mt7623n-rfb.dtsi
112 +index 256c5fd947bf..43c9d7ca23a0 100644
113 +--- a/arch/arm/boot/dts/mt7623n-rfb.dtsi
114 ++++ b/arch/arm/boot/dts/mt7623n-rfb.dtsi
115 +@@ -47,6 +47,7 @@
116 + };
117 +
118 + memory@80000000 {
119 ++ device_type = "memory";
120 + reg = <0 0x80000000 0 0x40000000>;
121 + };
122 +
123 +diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
124 +index 486d4e7433ed..b38f8c240558 100644
125 +--- a/arch/arm/boot/dts/socfpga.dtsi
126 ++++ b/arch/arm/boot/dts/socfpga.dtsi
127 +@@ -748,13 +748,13 @@
128 + nand0: nand@ff900000 {
129 + #address-cells = <0x1>;
130 + #size-cells = <0x1>;
131 +- compatible = "denali,denali-nand-dt";
132 ++ compatible = "altr,socfpga-denali-nand";
133 + reg = <0xff900000 0x100000>,
134 + <0xffb80000 0x10000>;
135 + reg-names = "nand_data", "denali_reg";
136 + interrupts = <0x0 0x90 0x4>;
137 + dma-mask = <0xffffffff>;
138 +- clocks = <&nand_clk>;
139 ++ clocks = <&nand_x_clk>;
140 + status = "disabled";
141 + };
142 +
143 +diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi b/arch/arm/boot/dts/socfpga_arria10.dtsi
144 +index bead79e4b2aa..791ca15c799e 100644
145 +--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
146 ++++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
147 +@@ -593,8 +593,7 @@
148 + #size-cells = <0>;
149 + reg = <0xffda5000 0x100>;
150 + interrupts = <0 102 4>;
151 +- num-chipselect = <4>;
152 +- bus-num = <0>;
153 ++ num-cs = <4>;
154 + /*32bit_access;*/
155 + tx-dma-channel = <&pdma 16>;
156 + rx-dma-channel = <&pdma 17>;
157 +@@ -633,7 +632,7 @@
158 + nand: nand@ffb90000 {
159 + #address-cells = <1>;
160 + #size-cells = <1>;
161 +- compatible = "denali,denali-nand-dt", "altr,socfpga-denali-nand";
162 ++ compatible = "altr,socfpga-denali-nand";
163 + reg = <0xffb90000 0x72000>,
164 + <0xffb80000 0x10000>;
165 + reg-names = "nand_data", "denali_reg";
166 +diff --git a/arch/arm/boot/dts/sun8i-h3-libretech-all-h3-cc.dts b/arch/arm/boot/dts/sun8i-h3-libretech-all-h3-cc.dts
167 +index b20a710da7bc..7a4fca36c673 100644
168 +--- a/arch/arm/boot/dts/sun8i-h3-libretech-all-h3-cc.dts
169 ++++ b/arch/arm/boot/dts/sun8i-h3-libretech-all-h3-cc.dts
170 +@@ -62,8 +62,8 @@
171 + reg_vcc1v2: vcc1v2 {
172 + compatible = "regulator-fixed";
173 + regulator-name = "vcc1v2";
174 +- regulator-min-microvolt = <3300000>;
175 +- regulator-max-microvolt = <3300000>;
176 ++ regulator-min-microvolt = <1200000>;
177 ++ regulator-max-microvolt = <1200000>;
178 + regulator-always-on;
179 + regulator-boot-on;
180 + vin-supply = <&reg_vcc5v0>;
181 +@@ -113,8 +113,8 @@
182 + reg_vdd_cpux: vdd-cpux {
183 + compatible = "regulator-fixed";
184 + regulator-name = "vdd-cpux";
185 +- regulator-min-microvolt = <3300000>;
186 +- regulator-max-microvolt = <3300000>;
187 ++ regulator-min-microvolt = <1200000>;
188 ++ regulator-max-microvolt = <1200000>;
189 + regulator-always-on;
190 + regulator-boot-on;
191 + vin-supply = <&reg_vcc5v0>;
192 +diff --git a/arch/arm/include/asm/kgdb.h b/arch/arm/include/asm/kgdb.h
193 +index 3b73fdcf3627..8de1100d1067 100644
194 +--- a/arch/arm/include/asm/kgdb.h
195 ++++ b/arch/arm/include/asm/kgdb.h
196 +@@ -77,7 +77,7 @@ extern int kgdb_fault_expected;
197 +
198 + #define KGDB_MAX_NO_CPUS 1
199 + #define BUFMAX 400
200 +-#define NUMREGBYTES (DBG_MAX_REG_NUM << 2)
201 ++#define NUMREGBYTES (GDB_MAX_REGS << 2)
202 + #define NUMCRITREGBYTES (32 << 2)
203 +
204 + #define _R0 0
205 +diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
206 +index c89d0c307f8d..2c63e60754c5 100644
207 +--- a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
208 ++++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
209 +@@ -252,8 +252,7 @@
210 + interrupts = <0 99 4>;
211 + resets = <&rst SPIM0_RESET>;
212 + reg-io-width = <4>;
213 +- num-chipselect = <4>;
214 +- bus-num = <0>;
215 ++ num-cs = <4>;
216 + status = "disabled";
217 + };
218 +
219 +@@ -265,8 +264,7 @@
220 + interrupts = <0 100 4>;
221 + resets = <&rst SPIM1_RESET>;
222 + reg-io-width = <4>;
223 +- num-chipselect = <4>;
224 +- bus-num = <0>;
225 ++ num-cs = <4>;
226 + status = "disabled";
227 + };
228 +
229 +diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
230 +index 3c31e21cbed7..69693977fe07 100644
231 +--- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
232 ++++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
233 +@@ -35,6 +35,12 @@
234 + no-map;
235 + };
236 +
237 ++ /* Alternate 3 MiB reserved for ARM Trusted Firmware (BL31) */
238 ++ secmon_reserved_alt: secmon@5000000 {
239 ++ reg = <0x0 0x05000000 0x0 0x300000>;
240 ++ no-map;
241 ++ };
242 ++
243 + linux,cma {
244 + compatible = "shared-dma-pool";
245 + reusable;
246 +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts
247 +index 3e3eb31748a3..f63bceb88caa 100644
248 +--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts
249 ++++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts
250 +@@ -234,9 +234,6 @@
251 +
252 + bus-width = <4>;
253 + cap-sd-highspeed;
254 +- sd-uhs-sdr12;
255 +- sd-uhs-sdr25;
256 +- sd-uhs-sdr50;
257 + max-frequency = <100000000>;
258 + disable-wp;
259 +
260 +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
261 +index dba365ed4bd5..33c15f2a949e 100644
262 +--- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
263 ++++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
264 +@@ -13,14 +13,6 @@
265 + / {
266 + compatible = "amlogic,meson-gxl";
267 +
268 +- reserved-memory {
269 +- /* Alternate 3 MiB reserved for ARM Trusted Firmware (BL31) */
270 +- secmon_reserved_alt: secmon@5000000 {
271 +- reg = <0x0 0x05000000 0x0 0x300000>;
272 +- no-map;
273 +- };
274 +- };
275 +-
276 + soc {
277 + usb0: usb@c9000000 {
278 + status = "disabled";
279 +diff --git a/arch/arm64/boot/dts/marvell/armada-cp110.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110.dtsi
280 +index ed2f1237ea1e..8259b32f0ced 100644
281 +--- a/arch/arm64/boot/dts/marvell/armada-cp110.dtsi
282 ++++ b/arch/arm64/boot/dts/marvell/armada-cp110.dtsi
283 +@@ -149,7 +149,7 @@
284 +
285 + CP110_LABEL(icu): interrupt-controller@1e0000 {
286 + compatible = "marvell,cp110-icu";
287 +- reg = <0x1e0000 0x10>;
288 ++ reg = <0x1e0000 0x440>;
289 + #interrupt-cells = <3>;
290 + interrupt-controller;
291 + msi-parent = <&gicp>;
292 +diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c
293 +index 253188fb8cb0..e3e50950a863 100644
294 +--- a/arch/arm64/crypto/aes-glue.c
295 ++++ b/arch/arm64/crypto/aes-glue.c
296 +@@ -223,8 +223,8 @@ static int ctr_encrypt(struct skcipher_request *req)
297 + kernel_neon_begin();
298 + aes_ctr_encrypt(walk.dst.virt.addr, walk.src.virt.addr,
299 + (u8 *)ctx->key_enc, rounds, blocks, walk.iv);
300 +- err = skcipher_walk_done(&walk, walk.nbytes % AES_BLOCK_SIZE);
301 + kernel_neon_end();
302 ++ err = skcipher_walk_done(&walk, walk.nbytes % AES_BLOCK_SIZE);
303 + }
304 + if (walk.nbytes) {
305 + u8 __aligned(8) tail[AES_BLOCK_SIZE];
306 +diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
307 +index 9d1b06d67c53..df0bd090f0e4 100644
308 +--- a/arch/arm64/kernel/cpufeature.c
309 ++++ b/arch/arm64/kernel/cpufeature.c
310 +@@ -937,7 +937,7 @@ static int __init parse_kpti(char *str)
311 + __kpti_forced = enabled ? 1 : -1;
312 + return 0;
313 + }
314 +-__setup("kpti=", parse_kpti);
315 ++early_param("kpti", parse_kpti);
316 + #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */
317 +
318 + #ifdef CONFIG_ARM64_HW_AFDBM
319 +diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
320 +index 154b7d30145d..f21209064041 100644
321 +--- a/arch/arm64/kernel/signal.c
322 ++++ b/arch/arm64/kernel/signal.c
323 +@@ -830,11 +830,12 @@ static void do_signal(struct pt_regs *regs)
324 + unsigned long continue_addr = 0, restart_addr = 0;
325 + int retval = 0;
326 + struct ksignal ksig;
327 ++ bool syscall = in_syscall(regs);
328 +
329 + /*
330 + * If we were from a system call, check for system call restarting...
331 + */
332 +- if (in_syscall(regs)) {
333 ++ if (syscall) {
334 + continue_addr = regs->pc;
335 + restart_addr = continue_addr - (compat_thumb_mode(regs) ? 2 : 4);
336 + retval = regs->regs[0];
337 +@@ -886,7 +887,7 @@ static void do_signal(struct pt_regs *regs)
338 + * Handle restarting a different system call. As above, if a debugger
339 + * has chosen to restart at a different PC, ignore the restart.
340 + */
341 +- if (in_syscall(regs) && regs->pc == restart_addr) {
342 ++ if (syscall && regs->pc == restart_addr) {
343 + if (retval == -ERESTART_RESTARTBLOCK)
344 + setup_restart_syscall(regs);
345 + user_rewind_single_step(current);
346 +diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
347 +index 5f9a73a4452c..03646e6a2ef4 100644
348 +--- a/arch/arm64/mm/proc.S
349 ++++ b/arch/arm64/mm/proc.S
350 +@@ -217,8 +217,9 @@ ENDPROC(idmap_cpu_replace_ttbr1)
351 +
352 + .macro __idmap_kpti_put_pgtable_ent_ng, type
353 + orr \type, \type, #PTE_NG // Same bit for blocks and pages
354 +- str \type, [cur_\()\type\()p] // Update the entry and ensure it
355 +- dc civac, cur_\()\type\()p // is visible to all CPUs.
356 ++ str \type, [cur_\()\type\()p] // Update the entry and ensure
357 ++ dmb sy // that it is visible to all
358 ++ dc civac, cur_\()\type\()p // CPUs.
359 + .endm
360 +
361 + /*
362 +diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
363 +index 0c3275aa0197..e522307db47c 100644
364 +--- a/arch/m68k/mac/config.c
365 ++++ b/arch/m68k/mac/config.c
366 +@@ -1005,7 +1005,7 @@ int __init mac_platform_init(void)
367 + struct resource swim_rsrc = {
368 + .flags = IORESOURCE_MEM,
369 + .start = (resource_size_t)swim_base,
370 +- .end = (resource_size_t)swim_base + 0x2000,
371 ++ .end = (resource_size_t)swim_base + 0x1FFF,
372 + };
373 +
374 + platform_device_register_simple("swim", -1, &swim_rsrc, 1);
375 +diff --git a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
376 +index c2a38321c96d..3b420f6d8822 100644
377 +--- a/arch/m68k/mm/kmap.c
378 ++++ b/arch/m68k/mm/kmap.c
379 +@@ -89,7 +89,8 @@ static inline void free_io_area(void *addr)
380 + for (p = &iolist ; (tmp = *p) ; p = &tmp->next) {
381 + if (tmp->addr == addr) {
382 + *p = tmp->next;
383 +- __iounmap(tmp->addr, tmp->size);
384 ++ /* remove gap added in get_io_area() */
385 ++ __iounmap(tmp->addr, tmp->size - IO_SIZE);
386 + kfree(tmp);
387 + return;
388 + }
389 +diff --git a/arch/mips/ath79/mach-pb44.c b/arch/mips/ath79/mach-pb44.c
390 +index 6b2c6f3baefa..75fb96ca61db 100644
391 +--- a/arch/mips/ath79/mach-pb44.c
392 ++++ b/arch/mips/ath79/mach-pb44.c
393 +@@ -34,7 +34,7 @@
394 + #define PB44_KEYS_DEBOUNCE_INTERVAL (3 * PB44_KEYS_POLL_INTERVAL)
395 +
396 + static struct gpiod_lookup_table pb44_i2c_gpiod_table = {
397 +- .dev_id = "i2c-gpio",
398 ++ .dev_id = "i2c-gpio.0",
399 + .table = {
400 + GPIO_LOOKUP_IDX("ath79-gpio", PB44_GPIO_I2C_SDA,
401 + NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
402 +diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
403 +index 6054d49e608e..8c9cbf13d32a 100644
404 +--- a/arch/mips/bcm47xx/setup.c
405 ++++ b/arch/mips/bcm47xx/setup.c
406 +@@ -212,6 +212,12 @@ static int __init bcm47xx_cpu_fixes(void)
407 + */
408 + if (bcm47xx_bus.bcma.bus.chipinfo.id == BCMA_CHIP_ID_BCM4706)
409 + cpu_wait = NULL;
410 ++
411 ++ /*
412 ++ * BCM47XX Erratum "R10: PCIe Transactions Periodically Fail"
413 ++ * Enable ExternalSync for sync instruction to take effect
414 ++ */
415 ++ set_c0_config7(MIPS_CONF7_ES);
416 + break;
417 + #endif
418 + }
419 +diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
420 +index a7d0b836f2f7..cea8ad864b3f 100644
421 +--- a/arch/mips/include/asm/io.h
422 ++++ b/arch/mips/include/asm/io.h
423 +@@ -414,6 +414,8 @@ static inline type pfx##in##bwlq##p(unsigned long port) \
424 + __val = *__addr; \
425 + slow; \
426 + \
427 ++ /* prevent prefetching of coherent DMA data prematurely */ \
428 ++ rmb(); \
429 + return pfx##ioswab##bwlq(__addr, __val); \
430 + }
431 +
432 +diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
433 +index f65859784a4c..eeb131e2048e 100644
434 +--- a/arch/mips/include/asm/mipsregs.h
435 ++++ b/arch/mips/include/asm/mipsregs.h
436 +@@ -681,6 +681,8 @@
437 + #define MIPS_CONF7_WII (_ULCAST_(1) << 31)
438 +
439 + #define MIPS_CONF7_RPS (_ULCAST_(1) << 2)
440 ++/* ExternalSync */
441 ++#define MIPS_CONF7_ES (_ULCAST_(1) << 8)
442 +
443 + #define MIPS_CONF7_IAR (_ULCAST_(1) << 10)
444 + #define MIPS_CONF7_AR (_ULCAST_(1) << 16)
445 +@@ -2760,6 +2762,7 @@ __BUILD_SET_C0(status)
446 + __BUILD_SET_C0(cause)
447 + __BUILD_SET_C0(config)
448 + __BUILD_SET_C0(config5)
449 ++__BUILD_SET_C0(config7)
450 + __BUILD_SET_C0(intcontrol)
451 + __BUILD_SET_C0(intctl)
452 + __BUILD_SET_C0(srsmap)
453 +diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
454 +index f2ee7e1e3342..cff52b283e03 100644
455 +--- a/arch/mips/kernel/mcount.S
456 ++++ b/arch/mips/kernel/mcount.S
457 +@@ -119,10 +119,20 @@ NESTED(_mcount, PT_SIZE, ra)
458 + EXPORT_SYMBOL(_mcount)
459 + PTR_LA t1, ftrace_stub
460 + PTR_L t2, ftrace_trace_function /* Prepare t2 for (1) */
461 +- bne t1, t2, static_trace
462 ++ beq t1, t2, fgraph_trace
463 + nop
464 +
465 ++ MCOUNT_SAVE_REGS
466 ++
467 ++ move a0, ra /* arg1: self return address */
468 ++ jalr t2 /* (1) call *ftrace_trace_function */
469 ++ move a1, AT /* arg2: parent's return address */
470 ++
471 ++ MCOUNT_RESTORE_REGS
472 ++
473 ++fgraph_trace:
474 + #ifdef CONFIG_FUNCTION_GRAPH_TRACER
475 ++ PTR_LA t1, ftrace_stub
476 + PTR_L t3, ftrace_graph_return
477 + bne t1, t3, ftrace_graph_caller
478 + nop
479 +@@ -131,24 +141,11 @@ EXPORT_SYMBOL(_mcount)
480 + bne t1, t3, ftrace_graph_caller
481 + nop
482 + #endif
483 +- b ftrace_stub
484 +-#ifdef CONFIG_32BIT
485 +- addiu sp, sp, 8
486 +-#else
487 +- nop
488 +-#endif
489 +
490 +-static_trace:
491 +- MCOUNT_SAVE_REGS
492 +-
493 +- move a0, ra /* arg1: self return address */
494 +- jalr t2 /* (1) call *ftrace_trace_function */
495 +- move a1, AT /* arg2: parent's return address */
496 +-
497 +- MCOUNT_RESTORE_REGS
498 + #ifdef CONFIG_32BIT
499 + addiu sp, sp, 8
500 + #endif
501 ++
502 + .globl ftrace_stub
503 + ftrace_stub:
504 + RETURN_BACK
505 +diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
506 +index 95813df90801..bb2523b4bd8f 100644
507 +--- a/arch/powerpc/Makefile
508 ++++ b/arch/powerpc/Makefile
509 +@@ -251,6 +251,7 @@ cpu-as-$(CONFIG_4xx) += -Wa,-m405
510 + cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec)
511 + cpu-as-$(CONFIG_E200) += -Wa,-me200
512 + cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4
513 ++cpu-as-$(CONFIG_PPC_E500MC) += $(call as-option,-Wa$(comma)-me500mc)
514 +
515 + KBUILD_AFLAGS += $(cpu-as-y)
516 + KBUILD_CFLAGS += $(cpu-as-y)
517 +diff --git a/arch/powerpc/kernel/dt_cpu_ftrs.c b/arch/powerpc/kernel/dt_cpu_ftrs.c
518 +index c904477abaf3..d926100da914 100644
519 +--- a/arch/powerpc/kernel/dt_cpu_ftrs.c
520 ++++ b/arch/powerpc/kernel/dt_cpu_ftrs.c
521 +@@ -711,7 +711,8 @@ static __init void cpufeatures_cpu_quirks(void)
522 + cur_cpu_spec->cpu_features |= CPU_FTR_P9_TM_HV_ASSIST;
523 + cur_cpu_spec->cpu_features |= CPU_FTR_P9_TM_XER_SO_BUG;
524 + cur_cpu_spec->cpu_features |= CPU_FTR_POWER9_DD2_1;
525 +- } else /* DD2.1 and up have DD2_1 */
526 ++ } else if ((version & 0xffff0000) == 0x004e0000)
527 ++ /* DD2.1 and up have DD2_1 */
528 + cur_cpu_spec->cpu_features |= CPU_FTR_POWER9_DD2_1;
529 +
530 + if ((version & 0xffff0000) == 0x004e0000) {
531 +diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
532 +index 51695608c68b..3d1af55e09dc 100644
533 +--- a/arch/powerpc/kernel/entry_64.S
534 ++++ b/arch/powerpc/kernel/entry_64.S
535 +@@ -596,6 +596,7 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
536 + * actually hit this code path.
537 + */
538 +
539 ++ isync
540 + slbie r6
541 + slbie r6 /* Workaround POWER5 < DD2.1 issue */
542 + slbmte r7,r0
543 +diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
544 +index 3c2c2688918f..fe631022ea89 100644
545 +--- a/arch/powerpc/kernel/fadump.c
546 ++++ b/arch/powerpc/kernel/fadump.c
547 +@@ -1155,6 +1155,9 @@ void fadump_cleanup(void)
548 + init_fadump_mem_struct(&fdm,
549 + be64_to_cpu(fdm_active->cpu_state_data.destination_address));
550 + fadump_invalidate_dump(&fdm);
551 ++ } else if (fw_dump.dump_registered) {
552 ++ /* Un-register Firmware-assisted dump if it was registered. */
553 ++ fadump_unregister_dump(&fdm);
554 + }
555 + }
556 +
557 +diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
558 +index 4c1012b80d3b..80547dad37da 100644
559 +--- a/arch/powerpc/kernel/hw_breakpoint.c
560 ++++ b/arch/powerpc/kernel/hw_breakpoint.c
561 +@@ -178,8 +178,8 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
562 + if (cpu_has_feature(CPU_FTR_DAWR)) {
563 + length_max = 512 ; /* 64 doublewords */
564 + /* DAWR region can't cross 512 boundary */
565 +- if ((bp->attr.bp_addr >> 10) !=
566 +- ((bp->attr.bp_addr + bp->attr.bp_len - 1) >> 10))
567 ++ if ((bp->attr.bp_addr >> 9) !=
568 ++ ((bp->attr.bp_addr + bp->attr.bp_len - 1) >> 9))
569 + return -EINVAL;
570 + }
571 + if (info->len >
572 +diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
573 +index d23cf632edf0..0f63dd5972e9 100644
574 +--- a/arch/powerpc/kernel/ptrace.c
575 ++++ b/arch/powerpc/kernel/ptrace.c
576 +@@ -2443,6 +2443,7 @@ static int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
577 + /* Create a new breakpoint request if one doesn't exist already */
578 + hw_breakpoint_init(&attr);
579 + attr.bp_addr = hw_brk.address;
580 ++ attr.bp_len = 8;
581 + arch_bp_generic_fields(hw_brk.type,
582 + &attr.bp_type);
583 +
584 +diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c
585 +index 0eafdf01edc7..e6f500fabf5e 100644
586 +--- a/arch/powerpc/mm/pkeys.c
587 ++++ b/arch/powerpc/mm/pkeys.c
588 +@@ -383,9 +383,9 @@ int __arch_override_mprotect_pkey(struct vm_area_struct *vma, int prot,
589 + {
590 + /*
591 + * If the currently associated pkey is execute-only, but the requested
592 +- * protection requires read or write, move it back to the default pkey.
593 ++ * protection is not execute-only, move it back to the default pkey.
594 + */
595 +- if (vma_is_pkey_exec_only(vma) && (prot & (PROT_READ | PROT_WRITE)))
596 ++ if (vma_is_pkey_exec_only(vma) && (prot != PROT_EXEC))
597 + return 0;
598 +
599 + /*
600 +diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
601 +index a5d7309c2d05..465cb604b33a 100644
602 +--- a/arch/powerpc/mm/tlb-radix.c
603 ++++ b/arch/powerpc/mm/tlb-radix.c
604 +@@ -733,6 +733,8 @@ extern void radix_kvm_prefetch_workaround(struct mm_struct *mm)
605 + for (; sib <= cpu_last_thread_sibling(cpu) && !flush; sib++) {
606 + if (sib == cpu)
607 + continue;
608 ++ if (!cpu_possible(sib))
609 ++ continue;
610 + if (paca_ptrs[sib]->kvm_hstate.kvm_vcpu)
611 + flush = true;
612 + }
613 +diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
614 +index d7532e7b9ab5..75fb23c24ee8 100644
615 +--- a/arch/powerpc/perf/imc-pmu.c
616 ++++ b/arch/powerpc/perf/imc-pmu.c
617 +@@ -1146,7 +1146,7 @@ static int init_nest_pmu_ref(void)
618 +
619 + static void cleanup_all_core_imc_memory(void)
620 + {
621 +- int i, nr_cores = DIV_ROUND_UP(num_present_cpus(), threads_per_core);
622 ++ int i, nr_cores = DIV_ROUND_UP(num_possible_cpus(), threads_per_core);
623 + struct imc_mem_info *ptr = core_imc_pmu->mem_info;
624 + int size = core_imc_pmu->counter_mem_size;
625 +
626 +@@ -1264,7 +1264,7 @@ static int imc_mem_init(struct imc_pmu *pmu_ptr, struct device_node *parent,
627 + if (!pmu_ptr->pmu.name)
628 + return -ENOMEM;
629 +
630 +- nr_cores = DIV_ROUND_UP(num_present_cpus(), threads_per_core);
631 ++ nr_cores = DIV_ROUND_UP(num_possible_cpus(), threads_per_core);
632 + pmu_ptr->mem_info = kcalloc(nr_cores, sizeof(struct imc_mem_info),
633 + GFP_KERNEL);
634 +
635 +diff --git a/arch/powerpc/platforms/powernv/copy-paste.h b/arch/powerpc/platforms/powernv/copy-paste.h
636 +index c9a503623431..e9a6c35f8a29 100644
637 +--- a/arch/powerpc/platforms/powernv/copy-paste.h
638 ++++ b/arch/powerpc/platforms/powernv/copy-paste.h
639 +@@ -42,5 +42,6 @@ static inline int vas_paste(void *paste_address, int offset)
640 + : "b" (offset), "b" (paste_address)
641 + : "memory", "cr0");
642 +
643 +- return (cr >> CR0_SHIFT) & CR0_MASK;
644 ++ /* We mask with 0xE to ignore SO */
645 ++ return (cr >> CR0_SHIFT) & 0xE;
646 + }
647 +diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c
648 +index 1f12ab1e6030..1c5d0675b43c 100644
649 +--- a/arch/powerpc/platforms/powernv/idle.c
650 ++++ b/arch/powerpc/platforms/powernv/idle.c
651 +@@ -79,7 +79,7 @@ static int pnv_save_sprs_for_deep_states(void)
652 + uint64_t msr_val = MSR_IDLE;
653 + uint64_t psscr_val = pnv_deepest_stop_psscr_val;
654 +
655 +- for_each_possible_cpu(cpu) {
656 ++ for_each_present_cpu(cpu) {
657 + uint64_t pir = get_hard_smp_processor_id(cpu);
658 + uint64_t hsprg0_val = (uint64_t)paca_ptrs[cpu];
659 +
660 +@@ -814,7 +814,7 @@ static int __init pnv_init_idle_states(void)
661 + int cpu;
662 +
663 + pr_info("powernv: idle: Saving PACA pointers of all CPUs in their thread sibling PACA\n");
664 +- for_each_possible_cpu(cpu) {
665 ++ for_each_present_cpu(cpu) {
666 + int base_cpu = cpu_first_thread_sibling(cpu);
667 + int idx = cpu_thread_in_core(cpu);
668 + int i;
669 +diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
670 +index 3f9c69d7623a..f7d9b3433a29 100644
671 +--- a/arch/powerpc/platforms/powernv/pci-ioda.c
672 ++++ b/arch/powerpc/platforms/powernv/pci-ioda.c
673 +@@ -3642,7 +3642,6 @@ static void pnv_pci_ioda2_release_pe_dma(struct pnv_ioda_pe *pe)
674 + WARN_ON(pe->table_group.group);
675 + }
676 +
677 +- pnv_pci_ioda2_table_free_pages(tbl);
678 + iommu_tce_table_put(tbl);
679 + }
680 +
681 +diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
682 +index 02168fe25105..cf9bf9b43ec3 100644
683 +--- a/arch/um/drivers/vector_kern.c
684 ++++ b/arch/um/drivers/vector_kern.c
685 +@@ -188,7 +188,7 @@ static int get_transport_options(struct arglist *def)
686 + if (strncmp(transport, TRANS_TAP, TRANS_TAP_LEN) == 0)
687 + return (vec_rx | VECTOR_BPF);
688 + if (strncmp(transport, TRANS_RAW, TRANS_RAW_LEN) == 0)
689 +- return (vec_rx | vec_tx);
690 ++ return (vec_rx | vec_tx | VECTOR_QDISC_BYPASS);
691 + return (vec_rx | vec_tx);
692 + }
693 +
694 +@@ -504,15 +504,19 @@ static struct vector_queue *create_queue(
695 +
696 + result = kmalloc(sizeof(struct vector_queue), GFP_KERNEL);
697 + if (result == NULL)
698 +- goto out_fail;
699 ++ return NULL;
700 + result->max_depth = max_size;
701 + result->dev = vp->dev;
702 + result->mmsg_vector = kmalloc(
703 + (sizeof(struct mmsghdr) * max_size), GFP_KERNEL);
704 ++ if (result->mmsg_vector == NULL)
705 ++ goto out_mmsg_fail;
706 + result->skbuff_vector = kmalloc(
707 + (sizeof(void *) * max_size), GFP_KERNEL);
708 +- if (result->mmsg_vector == NULL || result->skbuff_vector == NULL)
709 +- goto out_fail;
710 ++ if (result->skbuff_vector == NULL)
711 ++ goto out_skb_fail;
712 ++
713 ++ /* further failures can be handled safely by destroy_queue*/
714 +
715 + mmsg_vector = result->mmsg_vector;
716 + for (i = 0; i < max_size; i++) {
717 +@@ -563,6 +567,11 @@ static struct vector_queue *create_queue(
718 + result->head = 0;
719 + result->tail = 0;
720 + return result;
721 ++out_skb_fail:
722 ++ kfree(result->mmsg_vector);
723 ++out_mmsg_fail:
724 ++ kfree(result);
725 ++ return NULL;
726 + out_fail:
727 + destroy_queue(result);
728 + return NULL;
729 +@@ -1232,9 +1241,8 @@ static int vector_net_open(struct net_device *dev)
730 +
731 + if ((vp->options & VECTOR_QDISC_BYPASS) != 0) {
732 + if (!uml_raw_enable_qdisc_bypass(vp->fds->rx_fd))
733 +- vp->options = vp->options | VECTOR_BPF;
734 ++ vp->options |= VECTOR_BPF;
735 + }
736 +-
737 + if ((vp->options & VECTOR_BPF) != 0)
738 + vp->bpf = uml_vector_default_bpf(vp->fds->rx_fd, dev->dev_addr);
739 +
740 +diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
741 +index 9de7f1e1dede..7d0df78db727 100644
742 +--- a/arch/x86/entry/entry_64_compat.S
743 ++++ b/arch/x86/entry/entry_64_compat.S
744 +@@ -84,13 +84,13 @@ ENTRY(entry_SYSENTER_compat)
745 + pushq %rdx /* pt_regs->dx */
746 + pushq %rcx /* pt_regs->cx */
747 + pushq $-ENOSYS /* pt_regs->ax */
748 +- pushq %r8 /* pt_regs->r8 */
749 ++ pushq $0 /* pt_regs->r8 = 0 */
750 + xorl %r8d, %r8d /* nospec r8 */
751 +- pushq %r9 /* pt_regs->r9 */
752 ++ pushq $0 /* pt_regs->r9 = 0 */
753 + xorl %r9d, %r9d /* nospec r9 */
754 +- pushq %r10 /* pt_regs->r10 */
755 ++ pushq $0 /* pt_regs->r10 = 0 */
756 + xorl %r10d, %r10d /* nospec r10 */
757 +- pushq %r11 /* pt_regs->r11 */
758 ++ pushq $0 /* pt_regs->r11 = 0 */
759 + xorl %r11d, %r11d /* nospec r11 */
760 + pushq %rbx /* pt_regs->rbx */
761 + xorl %ebx, %ebx /* nospec rbx */
762 +@@ -374,13 +374,13 @@ ENTRY(entry_INT80_compat)
763 + pushq %rcx /* pt_regs->cx */
764 + xorl %ecx, %ecx /* nospec cx */
765 + pushq $-ENOSYS /* pt_regs->ax */
766 +- pushq $0 /* pt_regs->r8 = 0 */
767 ++ pushq %r8 /* pt_regs->r8 */
768 + xorl %r8d, %r8d /* nospec r8 */
769 +- pushq $0 /* pt_regs->r9 = 0 */
770 ++ pushq %r9 /* pt_regs->r9 */
771 + xorl %r9d, %r9d /* nospec r9 */
772 +- pushq $0 /* pt_regs->r10 = 0 */
773 ++ pushq %r10 /* pt_regs->r10*/
774 + xorl %r10d, %r10d /* nospec r10 */
775 +- pushq $0 /* pt_regs->r11 = 0 */
776 ++ pushq %r11 /* pt_regs->r11 */
777 + xorl %r11d, %r11d /* nospec r11 */
778 + pushq %rbx /* pt_regs->rbx */
779 + xorl %ebx, %ebx /* nospec rbx */
780 +diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
781 +index 042b5e892ed1..14de0432d288 100644
782 +--- a/arch/x86/include/asm/barrier.h
783 ++++ b/arch/x86/include/asm/barrier.h
784 +@@ -38,7 +38,7 @@ static inline unsigned long array_index_mask_nospec(unsigned long index,
785 + {
786 + unsigned long mask;
787 +
788 +- asm ("cmp %1,%2; sbb %0,%0;"
789 ++ asm volatile ("cmp %1,%2; sbb %0,%0;"
790 + :"=r" (mask)
791 + :"g"(size),"r" (index)
792 + :"cc");
793 +diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
794 +index efaf2d4f9c3c..d492752f79e1 100644
795 +--- a/arch/x86/kernel/apic/x2apic_uv_x.c
796 ++++ b/arch/x86/kernel/apic/x2apic_uv_x.c
797 +@@ -26,6 +26,7 @@
798 + #include <linux/delay.h>
799 + #include <linux/crash_dump.h>
800 + #include <linux/reboot.h>
801 ++#include <linux/memory.h>
802 +
803 + #include <asm/uv/uv_mmrs.h>
804 + #include <asm/uv/uv_hub.h>
805 +@@ -392,6 +393,51 @@ extern int uv_hub_info_version(void)
806 + }
807 + EXPORT_SYMBOL(uv_hub_info_version);
808 +
809 ++/* Default UV memory block size is 2GB */
810 ++static unsigned long mem_block_size = (2UL << 30);
811 ++
812 ++/* Kernel parameter to specify UV mem block size */
813 ++static int parse_mem_block_size(char *ptr)
814 ++{
815 ++ unsigned long size = memparse(ptr, NULL);
816 ++
817 ++ /* Size will be rounded down by set_block_size() below */
818 ++ mem_block_size = size;
819 ++ return 0;
820 ++}
821 ++early_param("uv_memblksize", parse_mem_block_size);
822 ++
823 ++static __init int adj_blksize(u32 lgre)
824 ++{
825 ++ unsigned long base = (unsigned long)lgre << UV_GAM_RANGE_SHFT;
826 ++ unsigned long size;
827 ++
828 ++ for (size = mem_block_size; size > MIN_MEMORY_BLOCK_SIZE; size >>= 1)
829 ++ if (IS_ALIGNED(base, size))
830 ++ break;
831 ++
832 ++ if (size >= mem_block_size)
833 ++ return 0;
834 ++
835 ++ mem_block_size = size;
836 ++ return 1;
837 ++}
838 ++
839 ++static __init void set_block_size(void)
840 ++{
841 ++ unsigned int order = ffs(mem_block_size);
842 ++
843 ++ if (order) {
844 ++ /* adjust for ffs return of 1..64 */
845 ++ set_memory_block_size_order(order - 1);
846 ++ pr_info("UV: mem_block_size set to 0x%lx\n", mem_block_size);
847 ++ } else {
848 ++ /* bad or zero value, default to 1UL << 31 (2GB) */
849 ++ pr_err("UV: mem_block_size error with 0x%lx\n", mem_block_size);
850 ++ set_memory_block_size_order(31);
851 ++ }
852 ++}
853 ++
854 + /* Build GAM range lookup table: */
855 + static __init void build_uv_gr_table(void)
856 + {
857 +@@ -1180,23 +1226,30 @@ static void __init decode_gam_rng_tbl(unsigned long ptr)
858 + << UV_GAM_RANGE_SHFT);
859 + int order = 0;
860 + char suffix[] = " KMGTPE";
861 ++ int flag = ' ';
862 +
863 + while (size > 9999 && order < sizeof(suffix)) {
864 + size /= 1024;
865 + order++;
866 + }
867 +
868 ++ /* adjust max block size to current range start */
869 ++ if (gre->type == 1 || gre->type == 2)
870 ++ if (adj_blksize(lgre))
871 ++ flag = '*';
872 ++
873 + if (!index) {
874 + pr_info("UV: GAM Range Table...\n");
875 +- pr_info("UV: # %20s %14s %5s %4s %5s %3s %2s\n", "Range", "", "Size", "Type", "NASID", "SID", "PN");
876 ++ pr_info("UV: # %20s %14s %6s %4s %5s %3s %2s\n", "Range", "", "Size", "Type", "NASID", "SID", "PN");
877 + }
878 +- pr_info("UV: %2d: 0x%014lx-0x%014lx %5lu%c %3d %04x %02x %02x\n",
879 ++ pr_info("UV: %2d: 0x%014lx-0x%014lx%c %5lu%c %3d %04x %02x %02x\n",
880 + index++,
881 + (unsigned long)lgre << UV_GAM_RANGE_SHFT,
882 + (unsigned long)gre->limit << UV_GAM_RANGE_SHFT,
883 +- size, suffix[order],
884 ++ flag, size, suffix[order],
885 + gre->type, gre->nasid, gre->sockid, gre->pnode);
886 +
887 ++ /* update to next range start */
888 + lgre = gre->limit;
889 + if (sock_min > gre->sockid)
890 + sock_min = gre->sockid;
891 +@@ -1427,6 +1480,7 @@ static void __init uv_system_init_hub(void)
892 +
893 + build_socket_tables();
894 + build_uv_gr_table();
895 ++ set_block_size();
896 + uv_init_hub_info(&hub_info);
897 + uv_possible_blades = num_possible_nodes();
898 + if (!_node_to_pnode)
899 +diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c
900 +index 5bbd06f38ff6..f34d89c01edc 100644
901 +--- a/arch/x86/kernel/cpu/mcheck/mce-severity.c
902 ++++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c
903 +@@ -160,6 +160,11 @@ static struct severity {
904 + SER, MASK(MCI_STATUS_OVER|MCI_UC_SAR|MCI_ADDR|MCACOD, MCI_UC_SAR|MCI_ADDR|MCACOD_INSTR),
905 + USER
906 + ),
907 ++ MCESEV(
908 ++ PANIC, "Data load in unrecoverable area of kernel",
909 ++ SER, MASK(MCI_STATUS_OVER|MCI_UC_SAR|MCI_ADDR|MCACOD, MCI_UC_SAR|MCI_ADDR|MCACOD_DATA),
910 ++ KERNEL
911 ++ ),
912 + #endif
913 + MCESEV(
914 + PANIC, "Action required: unknown MCACOD",
915 +diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
916 +index 42cf2880d0ed..6f7eda9d5297 100644
917 +--- a/arch/x86/kernel/cpu/mcheck/mce.c
918 ++++ b/arch/x86/kernel/cpu/mcheck/mce.c
919 +@@ -772,23 +772,25 @@ EXPORT_SYMBOL_GPL(machine_check_poll);
920 + static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp,
921 + struct pt_regs *regs)
922 + {
923 +- int i, ret = 0;
924 + char *tmp;
925 ++ int i;
926 +
927 + for (i = 0; i < mca_cfg.banks; i++) {
928 + m->status = mce_rdmsrl(msr_ops.status(i));
929 +- if (m->status & MCI_STATUS_VAL) {
930 +- __set_bit(i, validp);
931 +- if (quirk_no_way_out)
932 +- quirk_no_way_out(i, m, regs);
933 +- }
934 ++ if (!(m->status & MCI_STATUS_VAL))
935 ++ continue;
936 ++
937 ++ __set_bit(i, validp);
938 ++ if (quirk_no_way_out)
939 ++ quirk_no_way_out(i, m, regs);
940 +
941 + if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) {
942 ++ mce_read_aux(m, i);
943 + *msg = tmp;
944 +- ret = 1;
945 ++ return 1;
946 + }
947 + }
948 +- return ret;
949 ++ return 0;
950 + }
951 +
952 + /*
953 +@@ -1205,13 +1207,18 @@ void do_machine_check(struct pt_regs *regs, long error_code)
954 + lmce = m.mcgstatus & MCG_STATUS_LMCES;
955 +
956 + /*
957 ++ * Local machine check may already know that we have to panic.
958 ++ * Broadcast machine check begins rendezvous in mce_start()
959 + * Go through all banks in exclusion of the other CPUs. This way we
960 + * don't report duplicated events on shared banks because the first one
961 +- * to see it will clear it. If this is a Local MCE, then no need to
962 +- * perform rendezvous.
963 ++ * to see it will clear it.
964 + */
965 +- if (!lmce)
966 ++ if (lmce) {
967 ++ if (no_way_out)
968 ++ mce_panic("Fatal local machine check", &m, msg);
969 ++ } else {
970 + order = mce_start(&no_way_out);
971 ++ }
972 +
973 + for (i = 0; i < cfg->banks; i++) {
974 + __clear_bit(i, toclear);
975 +@@ -1287,12 +1294,17 @@ void do_machine_check(struct pt_regs *regs, long error_code)
976 + no_way_out = worst >= MCE_PANIC_SEVERITY;
977 + } else {
978 + /*
979 +- * Local MCE skipped calling mce_reign()
980 +- * If we found a fatal error, we need to panic here.
981 ++ * If there was a fatal machine check we should have
982 ++ * already called mce_panic earlier in this function.
983 ++ * Since we re-read the banks, we might have found
984 ++ * something new. Check again to see if we found a
985 ++ * fatal error. We call "mce_severity()" again to
986 ++ * make sure we have the right "msg".
987 + */
988 +- if (worst >= MCE_PANIC_SEVERITY && mca_cfg.tolerant < 3)
989 +- mce_panic("Machine check from unknown source",
990 +- NULL, NULL);
991 ++ if (worst >= MCE_PANIC_SEVERITY && mca_cfg.tolerant < 3) {
992 ++ mce_severity(&m, cfg->tolerant, &msg, true);
993 ++ mce_panic("Local fatal machine check!", &m, msg);
994 ++ }
995 + }
996 +
997 + /*
998 +diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
999 +index 6a2cb1442e05..aec38a170dbc 100644
1000 +--- a/arch/x86/kernel/e820.c
1001 ++++ b/arch/x86/kernel/e820.c
1002 +@@ -1246,6 +1246,7 @@ void __init e820__memblock_setup(void)
1003 + {
1004 + int i;
1005 + u64 end;
1006 ++ u64 addr = 0;
1007 +
1008 + /*
1009 + * The bootstrap memblock region count maximum is 128 entries
1010 +@@ -1262,13 +1263,21 @@ void __init e820__memblock_setup(void)
1011 + struct e820_entry *entry = &e820_table->entries[i];
1012 +
1013 + end = entry->addr + entry->size;
1014 ++ if (addr < entry->addr)
1015 ++ memblock_reserve(addr, entry->addr - addr);
1016 ++ addr = end;
1017 + if (end != (resource_size_t)end)
1018 + continue;
1019 +
1020 ++ /*
1021 ++ * all !E820_TYPE_RAM ranges (including gap ranges) are put
1022 ++ * into memblock.reserved to make sure that struct pages in
1023 ++ * such regions are not left uninitialized after bootup.
1024 ++ */
1025 + if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN)
1026 +- continue;
1027 +-
1028 +- memblock_add(entry->addr, entry->size);
1029 ++ memblock_reserve(entry->addr, entry->size);
1030 ++ else
1031 ++ memblock_add(entry->addr, entry->size);
1032 + }
1033 +
1034 + /* Throw away partial pages: */
1035 +diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
1036 +index 697a4ce04308..736348ead421 100644
1037 +--- a/arch/x86/kernel/quirks.c
1038 ++++ b/arch/x86/kernel/quirks.c
1039 +@@ -645,12 +645,19 @@ static void quirk_intel_brickland_xeon_ras_cap(struct pci_dev *pdev)
1040 + /* Skylake */
1041 + static void quirk_intel_purley_xeon_ras_cap(struct pci_dev *pdev)
1042 + {
1043 +- u32 capid0;
1044 ++ u32 capid0, capid5;
1045 +
1046 + pci_read_config_dword(pdev, 0x84, &capid0);
1047 ++ pci_read_config_dword(pdev, 0x98, &capid5);
1048 +
1049 +- if ((capid0 & 0xc0) == 0xc0)
1050 ++ /*
1051 ++ * CAPID0{7:6} indicate whether this is an advanced RAS SKU
1052 ++ * CAPID5{8:5} indicate that various NVDIMM usage modes are
1053 ++ * enabled, so memory machine check recovery is also enabled.
1054 ++ */
1055 ++ if ((capid0 & 0xc0) == 0xc0 || (capid5 & 0x1e0))
1056 + static_branch_inc(&mcsafe_key);
1057 ++
1058 + }
1059 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x0ec3, quirk_intel_brickland_xeon_ras_cap);
1060 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2fc0, quirk_intel_brickland_xeon_ras_cap);
1061 +diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
1062 +index 03f3d7695dac..162a31d80ad5 100644
1063 +--- a/arch/x86/kernel/traps.c
1064 ++++ b/arch/x86/kernel/traps.c
1065 +@@ -834,16 +834,18 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)
1066 + char *str = (trapnr == X86_TRAP_MF) ? "fpu exception" :
1067 + "simd exception";
1068 +
1069 +- if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, SIGFPE) == NOTIFY_STOP)
1070 +- return;
1071 + cond_local_irq_enable(regs);
1072 +
1073 + if (!user_mode(regs)) {
1074 +- if (!fixup_exception(regs, trapnr)) {
1075 +- task->thread.error_code = error_code;
1076 +- task->thread.trap_nr = trapnr;
1077 ++ if (fixup_exception(regs, trapnr))
1078 ++ return;
1079 ++
1080 ++ task->thread.error_code = error_code;
1081 ++ task->thread.trap_nr = trapnr;
1082 ++
1083 ++ if (notify_die(DIE_TRAP, str, regs, error_code,
1084 ++ trapnr, SIGFPE) != NOTIFY_STOP)
1085 + die(str, regs, error_code);
1086 +- }
1087 + return;
1088 + }
1089 +
1090 +diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
1091 +index fec82b577c18..cee58a972cb2 100644
1092 +--- a/arch/x86/mm/init.c
1093 ++++ b/arch/x86/mm/init.c
1094 +@@ -706,7 +706,9 @@ void __init init_mem_mapping(void)
1095 + */
1096 + int devmem_is_allowed(unsigned long pagenr)
1097 + {
1098 +- if (page_is_ram(pagenr)) {
1099 ++ if (region_intersects(PFN_PHYS(pagenr), PAGE_SIZE,
1100 ++ IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE)
1101 ++ != REGION_DISJOINT) {
1102 + /*
1103 + * For disallowed memory regions in the low 1MB range,
1104 + * request that the page be shown as all zeros.
1105 +diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
1106 +index 0a400606dea0..20d8bf5fbceb 100644
1107 +--- a/arch/x86/mm/init_64.c
1108 ++++ b/arch/x86/mm/init_64.c
1109 +@@ -1350,16 +1350,28 @@ int kern_addr_valid(unsigned long addr)
1110 + /* Amount of ram needed to start using large blocks */
1111 + #define MEM_SIZE_FOR_LARGE_BLOCK (64UL << 30)
1112 +
1113 ++/* Adjustable memory block size */
1114 ++static unsigned long set_memory_block_size;
1115 ++int __init set_memory_block_size_order(unsigned int order)
1116 ++{
1117 ++ unsigned long size = 1UL << order;
1118 ++
1119 ++ if (size > MEM_SIZE_FOR_LARGE_BLOCK || size < MIN_MEMORY_BLOCK_SIZE)
1120 ++ return -EINVAL;
1121 ++
1122 ++ set_memory_block_size = size;
1123 ++ return 0;
1124 ++}
1125 ++
1126 + static unsigned long probe_memory_block_size(void)
1127 + {
1128 + unsigned long boot_mem_end = max_pfn << PAGE_SHIFT;
1129 + unsigned long bz;
1130 +
1131 +- /* If this is UV system, always set 2G block size */
1132 +- if (is_uv_system()) {
1133 +- bz = MAX_BLOCK_SIZE;
1134 ++ /* If memory block size has been set, then use it */
1135 ++ bz = set_memory_block_size;
1136 ++ if (bz)
1137 + goto done;
1138 +- }
1139 +
1140 + /* Use regular block if RAM is smaller than MEM_SIZE_FOR_LARGE_BLOCK */
1141 + if (boot_mem_end < MEM_SIZE_FOR_LARGE_BLOCK) {
1142 +diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
1143 +index bed7e7f4e44c..84fbfaba8404 100644
1144 +--- a/arch/x86/platform/efi/efi_64.c
1145 ++++ b/arch/x86/platform/efi/efi_64.c
1146 +@@ -166,14 +166,14 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
1147 + pgd = pgd_offset_k(pgd_idx * PGDIR_SIZE);
1148 + set_pgd(pgd_offset_k(pgd_idx * PGDIR_SIZE), save_pgd[pgd_idx]);
1149 +
1150 +- if (!(pgd_val(*pgd) & _PAGE_PRESENT))
1151 ++ if (!pgd_present(*pgd))
1152 + continue;
1153 +
1154 + for (i = 0; i < PTRS_PER_P4D; i++) {
1155 + p4d = p4d_offset(pgd,
1156 + pgd_idx * PGDIR_SIZE + i * P4D_SIZE);
1157 +
1158 +- if (!(p4d_val(*p4d) & _PAGE_PRESENT))
1159 ++ if (!p4d_present(*p4d))
1160 + continue;
1161 +
1162 + pud = (pud_t *)p4d_page_vaddr(*p4d);
1163 +diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
1164 +index 2e20ae2fa2d6..e3b18ad49889 100644
1165 +--- a/arch/x86/xen/smp_pv.c
1166 ++++ b/arch/x86/xen/smp_pv.c
1167 +@@ -32,6 +32,7 @@
1168 + #include <xen/interface/vcpu.h>
1169 + #include <xen/interface/xenpmu.h>
1170 +
1171 ++#include <asm/spec-ctrl.h>
1172 + #include <asm/xen/interface.h>
1173 + #include <asm/xen/hypercall.h>
1174 +
1175 +@@ -70,6 +71,8 @@ static void cpu_bringup(void)
1176 + cpu_data(cpu).x86_max_cores = 1;
1177 + set_cpu_sibling_map(cpu);
1178 +
1179 ++ speculative_store_bypass_ht_init();
1180 ++
1181 + xen_setup_cpu_clockevents();
1182 +
1183 + notify_cpu_starting(cpu);
1184 +@@ -250,6 +253,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned int max_cpus)
1185 + }
1186 + set_cpu_sibling_map(0);
1187 +
1188 ++ speculative_store_bypass_ht_init();
1189 ++
1190 + xen_pmu_init(0);
1191 +
1192 + if (xen_smp_intr_init(0) || xen_smp_intr_init_pv(0))
1193 +diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
1194 +index 32c5207f1226..84a70b8cbe33 100644
1195 +--- a/arch/xtensa/kernel/traps.c
1196 ++++ b/arch/xtensa/kernel/traps.c
1197 +@@ -338,7 +338,7 @@ do_unaligned_user (struct pt_regs *regs)
1198 + info.si_errno = 0;
1199 + info.si_code = BUS_ADRALN;
1200 + info.si_addr = (void *) regs->excvaddr;
1201 +- force_sig_info(SIGSEGV, &info, current);
1202 ++ force_sig_info(SIGBUS, &info, current);
1203 +
1204 + }
1205 + #endif
1206 +diff --git a/block/blk-core.c b/block/blk-core.c
1207 +index 85909b431eb0..b559b9d4f1a2 100644
1208 +--- a/block/blk-core.c
1209 ++++ b/block/blk-core.c
1210 +@@ -3487,6 +3487,10 @@ static void __blk_rq_prep_clone(struct request *dst, struct request *src)
1211 + dst->cpu = src->cpu;
1212 + dst->__sector = blk_rq_pos(src);
1213 + dst->__data_len = blk_rq_bytes(src);
1214 ++ if (src->rq_flags & RQF_SPECIAL_PAYLOAD) {
1215 ++ dst->rq_flags |= RQF_SPECIAL_PAYLOAD;
1216 ++ dst->special_vec = src->special_vec;
1217 ++ }
1218 + dst->nr_phys_segments = src->nr_phys_segments;
1219 + dst->ioprio = src->ioprio;
1220 + dst->extra_len = src->extra_len;
1221 +diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
1222 +index 7d81e6bb461a..b6cabac4b62b 100644
1223 +--- a/crypto/asymmetric_keys/x509_cert_parser.c
1224 ++++ b/crypto/asymmetric_keys/x509_cert_parser.c
1225 +@@ -249,6 +249,15 @@ int x509_note_signature(void *context, size_t hdrlen,
1226 + return -EINVAL;
1227 + }
1228 +
1229 ++ if (strcmp(ctx->cert->sig->pkey_algo, "rsa") == 0) {
1230 ++ /* Discard the BIT STRING metadata */
1231 ++ if (vlen < 1 || *(const u8 *)value != 0)
1232 ++ return -EBADMSG;
1233 ++
1234 ++ value++;
1235 ++ vlen--;
1236 ++ }
1237 ++
1238 + ctx->cert->raw_sig = value;
1239 + ctx->cert->raw_sig_size = vlen;
1240 + return 0;
1241 +diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
1242 +index 2bcffec8dbf0..eb091375c873 100644
1243 +--- a/drivers/acpi/acpi_lpss.c
1244 ++++ b/drivers/acpi/acpi_lpss.c
1245 +@@ -22,6 +22,7 @@
1246 + #include <linux/pm_domain.h>
1247 + #include <linux/pm_runtime.h>
1248 + #include <linux/pwm.h>
1249 ++#include <linux/suspend.h>
1250 + #include <linux/delay.h>
1251 +
1252 + #include "internal.h"
1253 +@@ -229,11 +230,13 @@ static const struct lpss_device_desc lpt_sdio_dev_desc = {
1254 +
1255 + static const struct lpss_device_desc byt_pwm_dev_desc = {
1256 + .flags = LPSS_SAVE_CTX,
1257 ++ .prv_offset = 0x800,
1258 + .setup = byt_pwm_setup,
1259 + };
1260 +
1261 + static const struct lpss_device_desc bsw_pwm_dev_desc = {
1262 + .flags = LPSS_SAVE_CTX | LPSS_NO_D3_DELAY,
1263 ++ .prv_offset = 0x800,
1264 + .setup = bsw_pwm_setup,
1265 + };
1266 +
1267 +@@ -940,9 +943,10 @@ static void lpss_iosf_exit_d3_state(void)
1268 + mutex_unlock(&lpss_iosf_mutex);
1269 + }
1270 +
1271 +-static int acpi_lpss_suspend(struct device *dev, bool wakeup)
1272 ++static int acpi_lpss_suspend(struct device *dev, bool runtime)
1273 + {
1274 + struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
1275 ++ bool wakeup = runtime || device_may_wakeup(dev);
1276 + int ret;
1277 +
1278 + if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
1279 +@@ -955,13 +959,14 @@ static int acpi_lpss_suspend(struct device *dev, bool wakeup)
1280 + * wrong status for devices being about to be powered off. See
1281 + * lpss_iosf_enter_d3_state() for further information.
1282 + */
1283 +- if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
1284 ++ if ((runtime || !pm_suspend_via_firmware()) &&
1285 ++ lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
1286 + lpss_iosf_enter_d3_state();
1287 +
1288 + return ret;
1289 + }
1290 +
1291 +-static int acpi_lpss_resume(struct device *dev)
1292 ++static int acpi_lpss_resume(struct device *dev, bool runtime)
1293 + {
1294 + struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
1295 + int ret;
1296 +@@ -970,7 +975,8 @@ static int acpi_lpss_resume(struct device *dev)
1297 + * This call is kept first to be in symmetry with
1298 + * acpi_lpss_runtime_suspend() one.
1299 + */
1300 +- if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
1301 ++ if ((runtime || !pm_resume_via_firmware()) &&
1302 ++ lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
1303 + lpss_iosf_exit_d3_state();
1304 +
1305 + ret = acpi_dev_resume(dev);
1306 +@@ -994,12 +1000,12 @@ static int acpi_lpss_suspend_late(struct device *dev)
1307 + return 0;
1308 +
1309 + ret = pm_generic_suspend_late(dev);
1310 +- return ret ? ret : acpi_lpss_suspend(dev, device_may_wakeup(dev));
1311 ++ return ret ? ret : acpi_lpss_suspend(dev, false);
1312 + }
1313 +
1314 + static int acpi_lpss_resume_early(struct device *dev)
1315 + {
1316 +- int ret = acpi_lpss_resume(dev);
1317 ++ int ret = acpi_lpss_resume(dev, false);
1318 +
1319 + return ret ? ret : pm_generic_resume_early(dev);
1320 + }
1321 +@@ -1014,7 +1020,7 @@ static int acpi_lpss_runtime_suspend(struct device *dev)
1322 +
1323 + static int acpi_lpss_runtime_resume(struct device *dev)
1324 + {
1325 +- int ret = acpi_lpss_resume(dev);
1326 ++ int ret = acpi_lpss_resume(dev, true);
1327 +
1328 + return ret ? ret : pm_generic_runtime_resume(dev);
1329 + }
1330 +diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
1331 +index 2c2ed9cf8796..f9413755177b 100644
1332 +--- a/drivers/auxdisplay/Kconfig
1333 ++++ b/drivers/auxdisplay/Kconfig
1334 +@@ -14,9 +14,6 @@ menuconfig AUXDISPLAY
1335 +
1336 + If you say N, all options in this submenu will be skipped and disabled.
1337 +
1338 +-config CHARLCD
1339 +- tristate "Character LCD core support" if COMPILE_TEST
1340 +-
1341 + if AUXDISPLAY
1342 +
1343 + config HD44780
1344 +@@ -157,8 +154,6 @@ config HT16K33
1345 + Say yes here to add support for Holtek HT16K33, RAM mapping 16*8
1346 + LED controller driver with keyscan.
1347 +
1348 +-endif # AUXDISPLAY
1349 +-
1350 + config ARM_CHARLCD
1351 + bool "ARM Ltd. Character LCD Driver"
1352 + depends on PLAT_VERSATILE
1353 +@@ -169,6 +164,8 @@ config ARM_CHARLCD
1354 + line and the Linux version on the second line, but that's
1355 + still useful.
1356 +
1357 ++endif # AUXDISPLAY
1358 ++
1359 + config PANEL
1360 + tristate "Parallel port LCD/Keypad Panel support"
1361 + depends on PARPORT
1362 +@@ -448,3 +445,6 @@ config PANEL_BOOT_MESSAGE
1363 + printf()-formatted message is valid with newline and escape codes.
1364 +
1365 + endif # PANEL
1366 ++
1367 ++config CHARLCD
1368 ++ tristate "Character LCD core support" if COMPILE_TEST
1369 +diff --git a/drivers/base/core.c b/drivers/base/core.c
1370 +index d680fd030316..f4ba878dd2dc 100644
1371 +--- a/drivers/base/core.c
1372 ++++ b/drivers/base/core.c
1373 +@@ -216,6 +216,13 @@ struct device_link *device_link_add(struct device *consumer,
1374 + link->rpm_active = true;
1375 + }
1376 + pm_runtime_new_link(consumer);
1377 ++ /*
1378 ++ * If the link is being added by the consumer driver at probe
1379 ++ * time, balance the decrementation of the supplier's runtime PM
1380 ++ * usage counter after consumer probe in driver_probe_device().
1381 ++ */
1382 ++ if (consumer->links.status == DL_DEV_PROBING)
1383 ++ pm_runtime_get_noresume(supplier);
1384 + }
1385 + get_device(supplier);
1386 + link->supplier = supplier;
1387 +@@ -235,12 +242,12 @@ struct device_link *device_link_add(struct device *consumer,
1388 + switch (consumer->links.status) {
1389 + case DL_DEV_PROBING:
1390 + /*
1391 +- * Balance the decrementation of the supplier's
1392 +- * runtime PM usage counter after consumer probe
1393 +- * in driver_probe_device().
1394 ++ * Some callers expect the link creation during
1395 ++ * consumer driver probe to resume the supplier
1396 ++ * even without DL_FLAG_RPM_ACTIVE.
1397 + */
1398 + if (flags & DL_FLAG_PM_RUNTIME)
1399 +- pm_runtime_get_sync(supplier);
1400 ++ pm_runtime_resume(supplier);
1401 +
1402 + link->status = DL_STATE_CONSUMER_PROBE;
1403 + break;
1404 +diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
1405 +index 1ea0e2502e8e..ef6cf3d5d2b5 100644
1406 +--- a/drivers/base/power/domain.c
1407 ++++ b/drivers/base/power/domain.c
1408 +@@ -2246,6 +2246,9 @@ int genpd_dev_pm_attach(struct device *dev)
1409 + genpd_lock(pd);
1410 + ret = genpd_power_on(pd, 0);
1411 + genpd_unlock(pd);
1412 ++
1413 ++ if (ret)
1414 ++ genpd_remove_device(pd, dev);
1415 + out:
1416 + return ret ? -EPROBE_DEFER : 0;
1417 + }
1418 +diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
1419 +index 33b36fea1d73..472afeed1d2f 100644
1420 +--- a/drivers/block/rbd.c
1421 ++++ b/drivers/block/rbd.c
1422 +@@ -3397,7 +3397,6 @@ static void cancel_tasks_sync(struct rbd_device *rbd_dev)
1423 + {
1424 + dout("%s rbd_dev %p\n", __func__, rbd_dev);
1425 +
1426 +- cancel_delayed_work_sync(&rbd_dev->watch_dwork);
1427 + cancel_work_sync(&rbd_dev->acquired_lock_work);
1428 + cancel_work_sync(&rbd_dev->released_lock_work);
1429 + cancel_delayed_work_sync(&rbd_dev->lock_dwork);
1430 +@@ -3415,6 +3414,7 @@ static void rbd_unregister_watch(struct rbd_device *rbd_dev)
1431 + rbd_dev->watch_state = RBD_WATCH_STATE_UNREGISTERED;
1432 + mutex_unlock(&rbd_dev->watch_mutex);
1433 +
1434 ++ cancel_delayed_work_sync(&rbd_dev->watch_dwork);
1435 + ceph_osdc_flush_notifies(&rbd_dev->rbd_client->client->osdc);
1436 + }
1437 +
1438 +diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
1439 +index 05ec530b8a3a..330e9b29e145 100644
1440 +--- a/drivers/bluetooth/hci_qca.c
1441 ++++ b/drivers/bluetooth/hci_qca.c
1442 +@@ -935,6 +935,12 @@ static int qca_setup(struct hci_uart *hu)
1443 + } else if (ret == -ENOENT) {
1444 + /* No patch/nvm-config found, run with original fw/config */
1445 + ret = 0;
1446 ++ } else if (ret == -EAGAIN) {
1447 ++ /*
1448 ++ * Userspace firmware loader will return -EAGAIN in case no
1449 ++ * patch/nvm-config is found, so run with original fw/config.
1450 ++ */
1451 ++ ret = 0;
1452 + }
1453 +
1454 + /* Setup bdaddr */
1455 +diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
1456 +index 91bb98c42a1c..aaf9e5afaad4 100644
1457 +--- a/drivers/char/hw_random/core.c
1458 ++++ b/drivers/char/hw_random/core.c
1459 +@@ -516,11 +516,18 @@ EXPORT_SYMBOL_GPL(hwrng_register);
1460 +
1461 + void hwrng_unregister(struct hwrng *rng)
1462 + {
1463 ++ int err;
1464 ++
1465 + mutex_lock(&rng_mutex);
1466 +
1467 + list_del(&rng->list);
1468 +- if (current_rng == rng)
1469 +- enable_best_rng();
1470 ++ if (current_rng == rng) {
1471 ++ err = enable_best_rng();
1472 ++ if (err) {
1473 ++ drop_current_rng();
1474 ++ cur_rng_set_by_user = 0;
1475 ++ }
1476 ++ }
1477 +
1478 + if (list_empty(&rng_list)) {
1479 + mutex_unlock(&rng_mutex);
1480 +diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
1481 +index fd4ea8d87d4b..a3397664f800 100644
1482 +--- a/drivers/char/ipmi/ipmi_bt_sm.c
1483 ++++ b/drivers/char/ipmi/ipmi_bt_sm.c
1484 +@@ -504,11 +504,12 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
1485 + if (status & BT_H_BUSY) /* clear a leftover H_BUSY */
1486 + BT_CONTROL(BT_H_BUSY);
1487 +
1488 ++ bt->timeout = bt->BT_CAP_req2rsp;
1489 ++
1490 + /* Read BT capabilities if it hasn't been done yet */
1491 + if (!bt->BT_CAP_outreqs)
1492 + BT_STATE_CHANGE(BT_STATE_CAPABILITIES_BEGIN,
1493 + SI_SM_CALL_WITHOUT_DELAY);
1494 +- bt->timeout = bt->BT_CAP_req2rsp;
1495 + BT_SI_SM_RETURN(SI_SM_IDLE);
1496 +
1497 + case BT_STATE_XACTION_START:
1498 +diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-common.c
1499 +index 230b99288024..e4a04b2d3c32 100644
1500 +--- a/drivers/char/tpm/tpm-dev-common.c
1501 ++++ b/drivers/char/tpm/tpm-dev-common.c
1502 +@@ -37,7 +37,7 @@ static void timeout_work(struct work_struct *work)
1503 + struct file_priv *priv = container_of(work, struct file_priv, work);
1504 +
1505 + mutex_lock(&priv->buffer_mutex);
1506 +- atomic_set(&priv->data_pending, 0);
1507 ++ priv->data_pending = 0;
1508 + memset(priv->data_buffer, 0, sizeof(priv->data_buffer));
1509 + mutex_unlock(&priv->buffer_mutex);
1510 + }
1511 +@@ -46,7 +46,6 @@ void tpm_common_open(struct file *file, struct tpm_chip *chip,
1512 + struct file_priv *priv)
1513 + {
1514 + priv->chip = chip;
1515 +- atomic_set(&priv->data_pending, 0);
1516 + mutex_init(&priv->buffer_mutex);
1517 + timer_setup(&priv->user_read_timer, user_reader_timeout, 0);
1518 + INIT_WORK(&priv->work, timeout_work);
1519 +@@ -58,29 +57,24 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
1520 + size_t size, loff_t *off)
1521 + {
1522 + struct file_priv *priv = file->private_data;
1523 +- ssize_t ret_size;
1524 +- ssize_t orig_ret_size;
1525 ++ ssize_t ret_size = 0;
1526 + int rc;
1527 +
1528 + del_singleshot_timer_sync(&priv->user_read_timer);
1529 + flush_work(&priv->work);
1530 +- ret_size = atomic_read(&priv->data_pending);
1531 +- if (ret_size > 0) { /* relay data */
1532 +- orig_ret_size = ret_size;
1533 +- if (size < ret_size)
1534 +- ret_size = size;
1535 ++ mutex_lock(&priv->buffer_mutex);
1536 +
1537 +- mutex_lock(&priv->buffer_mutex);
1538 ++ if (priv->data_pending) {
1539 ++ ret_size = min_t(ssize_t, size, priv->data_pending);
1540 + rc = copy_to_user(buf, priv->data_buffer, ret_size);
1541 +- memset(priv->data_buffer, 0, orig_ret_size);
1542 ++ memset(priv->data_buffer, 0, priv->data_pending);
1543 + if (rc)
1544 + ret_size = -EFAULT;
1545 +
1546 +- mutex_unlock(&priv->buffer_mutex);
1547 ++ priv->data_pending = 0;
1548 + }
1549 +
1550 +- atomic_set(&priv->data_pending, 0);
1551 +-
1552 ++ mutex_unlock(&priv->buffer_mutex);
1553 + return ret_size;
1554 + }
1555 +
1556 +@@ -91,17 +85,19 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
1557 + size_t in_size = size;
1558 + ssize_t out_size;
1559 +
1560 ++ if (in_size > TPM_BUFSIZE)
1561 ++ return -E2BIG;
1562 ++
1563 ++ mutex_lock(&priv->buffer_mutex);
1564 ++
1565 + /* Cannot perform a write until the read has cleared either via
1566 + * tpm_read or a user_read_timer timeout. This also prevents split
1567 + * buffered writes from blocking here.
1568 + */
1569 +- if (atomic_read(&priv->data_pending) != 0)
1570 ++ if (priv->data_pending != 0) {
1571 ++ mutex_unlock(&priv->buffer_mutex);
1572 + return -EBUSY;
1573 +-
1574 +- if (in_size > TPM_BUFSIZE)
1575 +- return -E2BIG;
1576 +-
1577 +- mutex_lock(&priv->buffer_mutex);
1578 ++ }
1579 +
1580 + if (copy_from_user
1581 + (priv->data_buffer, (void __user *) buf, in_size)) {
1582 +@@ -132,7 +128,7 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
1583 + return out_size;
1584 + }
1585 +
1586 +- atomic_set(&priv->data_pending, out_size);
1587 ++ priv->data_pending = out_size;
1588 + mutex_unlock(&priv->buffer_mutex);
1589 +
1590 + /* Set a timeout by which the reader must come claim the result */
1591 +@@ -149,5 +145,5 @@ void tpm_common_release(struct file *file, struct file_priv *priv)
1592 + del_singleshot_timer_sync(&priv->user_read_timer);
1593 + flush_work(&priv->work);
1594 + file->private_data = NULL;
1595 +- atomic_set(&priv->data_pending, 0);
1596 ++ priv->data_pending = 0;
1597 + }
1598 +diff --git a/drivers/char/tpm/tpm-dev.h b/drivers/char/tpm/tpm-dev.h
1599 +index ba3b6f9dacf7..b24cfb4d3ee1 100644
1600 +--- a/drivers/char/tpm/tpm-dev.h
1601 ++++ b/drivers/char/tpm/tpm-dev.h
1602 +@@ -8,7 +8,7 @@ struct file_priv {
1603 + struct tpm_chip *chip;
1604 +
1605 + /* Data passed to and from the tpm via the read/write calls */
1606 +- atomic_t data_pending;
1607 ++ size_t data_pending;
1608 + struct mutex buffer_mutex;
1609 +
1610 + struct timer_list user_read_timer; /* user needs to claim result */
1611 +diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
1612 +index 4e4014eabdb9..6122d3276f72 100644
1613 +--- a/drivers/char/tpm/tpm2-space.c
1614 ++++ b/drivers/char/tpm/tpm2-space.c
1615 +@@ -102,8 +102,9 @@ static int tpm2_load_context(struct tpm_chip *chip, u8 *buf,
1616 + * TPM_RC_REFERENCE_H0 means the session has been
1617 + * flushed outside the space
1618 + */
1619 +- rc = -ENOENT;
1620 ++ *handle = 0;
1621 + tpm_buf_destroy(&tbuf);
1622 ++ return -ENOENT;
1623 + } else if (rc > 0) {
1624 + dev_warn(&chip->dev, "%s: failed with a TPM error 0x%04X\n",
1625 + __func__, rc);
1626 +diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c
1627 +index 7d3223fc7161..72b6091eb7b9 100644
1628 +--- a/drivers/clk/at91/clk-pll.c
1629 ++++ b/drivers/clk/at91/clk-pll.c
1630 +@@ -132,19 +132,8 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,
1631 + unsigned long parent_rate)
1632 + {
1633 + struct clk_pll *pll = to_clk_pll(hw);
1634 +- unsigned int pllr;
1635 +- u16 mul;
1636 +- u8 div;
1637 +-
1638 +- regmap_read(pll->regmap, PLL_REG(pll->id), &pllr);
1639 +-
1640 +- div = PLL_DIV(pllr);
1641 +- mul = PLL_MUL(pllr, pll->layout);
1642 +-
1643 +- if (!div || !mul)
1644 +- return 0;
1645 +
1646 +- return (parent_rate / div) * (mul + 1);
1647 ++ return (parent_rate / pll->div) * (pll->mul + 1);
1648 + }
1649 +
1650 + static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate,
1651 +diff --git a/drivers/clk/clk-aspeed.c b/drivers/clk/clk-aspeed.c
1652 +index 5eb50c31e455..2c23e7d7ba28 100644
1653 +--- a/drivers/clk/clk-aspeed.c
1654 ++++ b/drivers/clk/clk-aspeed.c
1655 +@@ -88,7 +88,7 @@ static const struct aspeed_gate_data aspeed_gates[] = {
1656 + [ASPEED_CLK_GATE_GCLK] = { 1, 7, "gclk-gate", NULL, 0 }, /* 2D engine */
1657 + [ASPEED_CLK_GATE_MCLK] = { 2, -1, "mclk-gate", "mpll", CLK_IS_CRITICAL }, /* SDRAM */
1658 + [ASPEED_CLK_GATE_VCLK] = { 3, 6, "vclk-gate", NULL, 0 }, /* Video Capture */
1659 +- [ASPEED_CLK_GATE_BCLK] = { 4, 10, "bclk-gate", "bclk", 0 }, /* PCIe/PCI */
1660 ++ [ASPEED_CLK_GATE_BCLK] = { 4, 8, "bclk-gate", "bclk", 0 }, /* PCIe/PCI */
1661 + [ASPEED_CLK_GATE_DCLK] = { 5, -1, "dclk-gate", NULL, 0 }, /* DAC */
1662 + [ASPEED_CLK_GATE_REFCLK] = { 6, -1, "refclk-gate", "clkin", CLK_IS_CRITICAL },
1663 + [ASPEED_CLK_GATE_USBPORT2CLK] = { 7, 3, "usb-port2-gate", NULL, 0 }, /* USB2.0 Host port 2 */
1664 +@@ -297,7 +297,7 @@ static const u8 aspeed_resets[] = {
1665 + [ASPEED_RESET_JTAG_MASTER] = 22,
1666 + [ASPEED_RESET_MIC] = 18,
1667 + [ASPEED_RESET_PWM] = 9,
1668 +- [ASPEED_RESET_PCIVGA] = 8,
1669 ++ [ASPEED_RESET_PECI] = 10,
1670 + [ASPEED_RESET_I2C] = 2,
1671 + [ASPEED_RESET_AHB] = 1,
1672 + };
1673 +diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c
1674 +index d0524ec71aad..d0d320180c51 100644
1675 +--- a/drivers/clk/meson/meson8b.c
1676 ++++ b/drivers/clk/meson/meson8b.c
1677 +@@ -246,6 +246,13 @@ static struct clk_regmap meson8b_fclk_div2 = {
1678 + .ops = &clk_regmap_gate_ops,
1679 + .parent_names = (const char *[]){ "fclk_div2_div" },
1680 + .num_parents = 1,
1681 ++ /*
1682 ++ * FIXME: Ethernet with a RGMII PHYs is not working if
1683 ++ * fclk_div2 is disabled. it is currently unclear why this
1684 ++ * is. keep it enabled until the Ethernet driver knows how
1685 ++ * to manage this clock.
1686 ++ */
1687 ++ .flags = CLK_IS_CRITICAL,
1688 + },
1689 + };
1690 +
1691 +diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c
1692 +index 4e88e980fb76..69a7c756658b 100644
1693 +--- a/drivers/clk/renesas/renesas-cpg-mssr.c
1694 ++++ b/drivers/clk/renesas/renesas-cpg-mssr.c
1695 +@@ -258,8 +258,9 @@ struct clk *cpg_mssr_clk_src_twocell_get(struct of_phandle_args *clkspec,
1696 + dev_err(dev, "Cannot get %s clock %u: %ld", type, clkidx,
1697 + PTR_ERR(clk));
1698 + else
1699 +- dev_dbg(dev, "clock (%u, %u) is %pC at %pCr Hz\n",
1700 +- clkspec->args[0], clkspec->args[1], clk, clk);
1701 ++ dev_dbg(dev, "clock (%u, %u) is %pC at %lu Hz\n",
1702 ++ clkspec->args[0], clkspec->args[1], clk,
1703 ++ clk_get_rate(clk));
1704 + return clk;
1705 + }
1706 +
1707 +@@ -326,7 +327,7 @@ static void __init cpg_mssr_register_core_clk(const struct cpg_core_clk *core,
1708 + if (IS_ERR_OR_NULL(clk))
1709 + goto fail;
1710 +
1711 +- dev_dbg(dev, "Core clock %pC at %pCr Hz\n", clk, clk);
1712 ++ dev_dbg(dev, "Core clock %pC at %lu Hz\n", clk, clk_get_rate(clk));
1713 + priv->clks[id] = clk;
1714 + return;
1715 +
1716 +@@ -392,7 +393,7 @@ static void __init cpg_mssr_register_mod_clk(const struct mssr_mod_clk *mod,
1717 + if (IS_ERR(clk))
1718 + goto fail;
1719 +
1720 +- dev_dbg(dev, "Module clock %pC at %pCr Hz\n", clk, clk);
1721 ++ dev_dbg(dev, "Module clock %pC at %lu Hz\n", clk, clk_get_rate(clk));
1722 + priv->clks[id] = clk;
1723 + priv->smstpcr_saved[clock->index / 32].mask |= BIT(clock->index % 32);
1724 + return;
1725 +diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
1726 +index 17e566afbb41..bd3f0a9d5e60 100644
1727 +--- a/drivers/cpufreq/intel_pstate.c
1728 ++++ b/drivers/cpufreq/intel_pstate.c
1729 +@@ -284,6 +284,7 @@ struct pstate_funcs {
1730 + static struct pstate_funcs pstate_funcs __read_mostly;
1731 +
1732 + static int hwp_active __read_mostly;
1733 ++static int hwp_mode_bdw __read_mostly;
1734 + static bool per_cpu_limits __read_mostly;
1735 +
1736 + static struct cpufreq_driver *intel_pstate_driver __read_mostly;
1737 +@@ -1370,7 +1371,15 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
1738 + cpu->pstate.turbo_pstate = pstate_funcs.get_turbo();
1739 + cpu->pstate.scaling = pstate_funcs.get_scaling();
1740 + cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling;
1741 +- cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling;
1742 ++
1743 ++ if (hwp_active && !hwp_mode_bdw) {
1744 ++ unsigned int phy_max, current_max;
1745 ++
1746 ++ intel_pstate_get_hwp_max(cpu->cpu, &phy_max, &current_max);
1747 ++ cpu->pstate.turbo_freq = phy_max * cpu->pstate.scaling;
1748 ++ } else {
1749 ++ cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling;
1750 ++ }
1751 +
1752 + if (pstate_funcs.get_aperf_mperf_shift)
1753 + cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift();
1754 +@@ -2252,28 +2261,36 @@ static inline bool intel_pstate_has_acpi_ppc(void) { return false; }
1755 + static inline void intel_pstate_request_control_from_smm(void) {}
1756 + #endif /* CONFIG_ACPI */
1757 +
1758 ++#define INTEL_PSTATE_HWP_BROADWELL 0x01
1759 ++
1760 ++#define ICPU_HWP(model, hwp_mode) \
1761 ++ { X86_VENDOR_INTEL, 6, model, X86_FEATURE_HWP, hwp_mode }
1762 ++
1763 + static const struct x86_cpu_id hwp_support_ids[] __initconst = {
1764 +- { X86_VENDOR_INTEL, 6, X86_MODEL_ANY, X86_FEATURE_HWP },
1765 ++ ICPU_HWP(INTEL_FAM6_BROADWELL_X, INTEL_PSTATE_HWP_BROADWELL),
1766 ++ ICPU_HWP(INTEL_FAM6_BROADWELL_XEON_D, INTEL_PSTATE_HWP_BROADWELL),
1767 ++ ICPU_HWP(X86_MODEL_ANY, 0),
1768 + {}
1769 + };
1770 +
1771 + static int __init intel_pstate_init(void)
1772 + {
1773 ++ const struct x86_cpu_id *id;
1774 + int rc;
1775 +
1776 + if (no_load)
1777 + return -ENODEV;
1778 +
1779 +- if (x86_match_cpu(hwp_support_ids)) {
1780 ++ id = x86_match_cpu(hwp_support_ids);
1781 ++ if (id) {
1782 + copy_cpu_funcs(&core_funcs);
1783 + if (!no_hwp) {
1784 + hwp_active++;
1785 ++ hwp_mode_bdw = id->driver_data;
1786 + intel_pstate.attr = hwp_cpufreq_attrs;
1787 + goto hwp_cpu_matched;
1788 + }
1789 + } else {
1790 +- const struct x86_cpu_id *id;
1791 +-
1792 + id = x86_match_cpu(intel_pstate_cpu_ids);
1793 + if (!id)
1794 + return -ENODEV;
1795 +diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
1796 +index 1a8234e706bc..d29e4f041efe 100644
1797 +--- a/drivers/cpuidle/cpuidle-powernv.c
1798 ++++ b/drivers/cpuidle/cpuidle-powernv.c
1799 +@@ -43,9 +43,31 @@ struct stop_psscr_table {
1800 +
1801 + static struct stop_psscr_table stop_psscr_table[CPUIDLE_STATE_MAX] __read_mostly;
1802 +
1803 +-static u64 snooze_timeout __read_mostly;
1804 ++static u64 default_snooze_timeout __read_mostly;
1805 + static bool snooze_timeout_en __read_mostly;
1806 +
1807 ++static u64 get_snooze_timeout(struct cpuidle_device *dev,
1808 ++ struct cpuidle_driver *drv,
1809 ++ int index)
1810 ++{
1811 ++ int i;
1812 ++
1813 ++ if (unlikely(!snooze_timeout_en))
1814 ++ return default_snooze_timeout;
1815 ++
1816 ++ for (i = index + 1; i < drv->state_count; i++) {
1817 ++ struct cpuidle_state *s = &drv->states[i];
1818 ++ struct cpuidle_state_usage *su = &dev->states_usage[i];
1819 ++
1820 ++ if (s->disabled || su->disable)
1821 ++ continue;
1822 ++
1823 ++ return s->target_residency * tb_ticks_per_usec;
1824 ++ }
1825 ++
1826 ++ return default_snooze_timeout;
1827 ++}
1828 ++
1829 + static int snooze_loop(struct cpuidle_device *dev,
1830 + struct cpuidle_driver *drv,
1831 + int index)
1832 +@@ -56,7 +78,7 @@ static int snooze_loop(struct cpuidle_device *dev,
1833 +
1834 + local_irq_enable();
1835 +
1836 +- snooze_exit_time = get_tb() + snooze_timeout;
1837 ++ snooze_exit_time = get_tb() + get_snooze_timeout(dev, drv, index);
1838 + ppc64_runlatch_off();
1839 + HMT_very_low();
1840 + while (!need_resched()) {
1841 +@@ -465,11 +487,9 @@ static int powernv_idle_probe(void)
1842 + cpuidle_state_table = powernv_states;
1843 + /* Device tree can indicate more idle states */
1844 + max_idle_state = powernv_add_idle_states();
1845 +- if (max_idle_state > 1) {
1846 ++ default_snooze_timeout = TICK_USEC * tb_ticks_per_usec;
1847 ++ if (max_idle_state > 1)
1848 + snooze_timeout_en = true;
1849 +- snooze_timeout = powernv_states[1].target_residency *
1850 +- tb_ticks_per_usec;
1851 +- }
1852 + } else
1853 + return -ENODEV;
1854 +
1855 +diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c
1856 +index 9d08cea3f1b0..9f5f35362f27 100644
1857 +--- a/drivers/firmware/efi/libstub/tpm.c
1858 ++++ b/drivers/firmware/efi/libstub/tpm.c
1859 +@@ -64,7 +64,7 @@ void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg)
1860 + efi_guid_t tcg2_guid = EFI_TCG2_PROTOCOL_GUID;
1861 + efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID;
1862 + efi_status_t status;
1863 +- efi_physical_addr_t log_location, log_last_entry;
1864 ++ efi_physical_addr_t log_location = 0, log_last_entry = 0;
1865 + struct linux_efi_tpm_eventlog *log_tbl = NULL;
1866 + unsigned long first_entry_addr, last_entry_addr;
1867 + size_t log_size, last_entry_size;
1868 +diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
1869 +index 3b73dee6fdc6..e97105ae4158 100644
1870 +--- a/drivers/hwmon/k10temp.c
1871 ++++ b/drivers/hwmon/k10temp.c
1872 +@@ -37,6 +37,10 @@ MODULE_PARM_DESC(force, "force loading on processors with erratum 319");
1873 + /* Provide lock for writing to NB_SMU_IND_ADDR */
1874 + static DEFINE_MUTEX(nb_smu_ind_mutex);
1875 +
1876 ++#ifndef PCI_DEVICE_ID_AMD_15H_M70H_NB_F3
1877 ++#define PCI_DEVICE_ID_AMD_15H_M70H_NB_F3 0x15b3
1878 ++#endif
1879 ++
1880 + #ifndef PCI_DEVICE_ID_AMD_17H_DF_F3
1881 + #define PCI_DEVICE_ID_AMD_17H_DF_F3 0x1463
1882 + #endif
1883 +@@ -320,6 +324,7 @@ static const struct pci_device_id k10temp_id_table[] = {
1884 + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M10H_F3) },
1885 + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F3) },
1886 + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M60H_NB_F3) },
1887 ++ { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M70H_NB_F3) },
1888 + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
1889 + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
1890 + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
1891 +diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
1892 +index 3df0efd69ae3..1147bddb8b2c 100644
1893 +--- a/drivers/i2c/algos/i2c-algo-bit.c
1894 ++++ b/drivers/i2c/algos/i2c-algo-bit.c
1895 +@@ -649,11 +649,6 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap,
1896 + if (bit_adap->getscl == NULL)
1897 + adap->quirks = &i2c_bit_quirk_no_clk_stretch;
1898 +
1899 +- /* Bring bus to a known state. Looks like STOP if bus is not free yet */
1900 +- setscl(bit_adap, 1);
1901 +- udelay(bit_adap->udelay);
1902 +- setsda(bit_adap, 1);
1903 +-
1904 + ret = add_adapter(adap);
1905 + if (ret < 0)
1906 + return ret;
1907 +diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
1908 +index 58abb3eced58..20b81bec0b0b 100644
1909 +--- a/drivers/i2c/busses/i2c-gpio.c
1910 ++++ b/drivers/i2c/busses/i2c-gpio.c
1911 +@@ -279,9 +279,9 @@ static int i2c_gpio_probe(struct platform_device *pdev)
1912 + * required for an I2C bus.
1913 + */
1914 + if (pdata->scl_is_open_drain)
1915 +- gflags = GPIOD_OUT_LOW;
1916 ++ gflags = GPIOD_OUT_HIGH;
1917 + else
1918 +- gflags = GPIOD_OUT_LOW_OPEN_DRAIN;
1919 ++ gflags = GPIOD_OUT_HIGH_OPEN_DRAIN;
1920 + priv->scl = i2c_gpio_get_desc(dev, "scl", 1, gflags);
1921 + if (IS_ERR(priv->scl))
1922 + return PTR_ERR(priv->scl);
1923 +diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
1924 +index f33dadf7b262..562f125235db 100644
1925 +--- a/drivers/iio/accel/sca3000.c
1926 ++++ b/drivers/iio/accel/sca3000.c
1927 +@@ -1277,7 +1277,7 @@ static int sca3000_configure_ring(struct iio_dev *indio_dev)
1928 + {
1929 + struct iio_buffer *buffer;
1930 +
1931 +- buffer = iio_kfifo_allocate();
1932 ++ buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
1933 + if (!buffer)
1934 + return -ENOMEM;
1935 +
1936 +@@ -1287,11 +1287,6 @@ static int sca3000_configure_ring(struct iio_dev *indio_dev)
1937 + return 0;
1938 + }
1939 +
1940 +-static void sca3000_unconfigure_ring(struct iio_dev *indio_dev)
1941 +-{
1942 +- iio_kfifo_free(indio_dev->buffer);
1943 +-}
1944 +-
1945 + static inline
1946 + int __sca3000_hw_ring_state_set(struct iio_dev *indio_dev, bool state)
1947 + {
1948 +@@ -1546,8 +1541,6 @@ static int sca3000_remove(struct spi_device *spi)
1949 + if (spi->irq)
1950 + free_irq(spi->irq, indio_dev);
1951 +
1952 +- sca3000_unconfigure_ring(indio_dev);
1953 +-
1954 + return 0;
1955 + }
1956 +
1957 +diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c
1958 +index 70fbf92f9827..03a5f7d6cb0c 100644
1959 +--- a/drivers/iio/adc/ad7791.c
1960 ++++ b/drivers/iio/adc/ad7791.c
1961 +@@ -244,58 +244,9 @@ static int ad7791_read_raw(struct iio_dev *indio_dev,
1962 + return -EINVAL;
1963 + }
1964 +
1965 +-static const char * const ad7791_sample_freq_avail[] = {
1966 +- [AD7791_FILTER_RATE_120] = "120",
1967 +- [AD7791_FILTER_RATE_100] = "100",
1968 +- [AD7791_FILTER_RATE_33_3] = "33.3",
1969 +- [AD7791_FILTER_RATE_20] = "20",
1970 +- [AD7791_FILTER_RATE_16_6] = "16.6",
1971 +- [AD7791_FILTER_RATE_16_7] = "16.7",
1972 +- [AD7791_FILTER_RATE_13_3] = "13.3",
1973 +- [AD7791_FILTER_RATE_9_5] = "9.5",
1974 +-};
1975 +-
1976 +-static ssize_t ad7791_read_frequency(struct device *dev,
1977 +- struct device_attribute *attr, char *buf)
1978 +-{
1979 +- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
1980 +- struct ad7791_state *st = iio_priv(indio_dev);
1981 +- unsigned int rate = st->filter & AD7791_FILTER_RATE_MASK;
1982 +-
1983 +- return sprintf(buf, "%s\n", ad7791_sample_freq_avail[rate]);
1984 +-}
1985 +-
1986 +-static ssize_t ad7791_write_frequency(struct device *dev,
1987 +- struct device_attribute *attr, const char *buf, size_t len)
1988 +-{
1989 +- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
1990 +- struct ad7791_state *st = iio_priv(indio_dev);
1991 +- int i, ret;
1992 +-
1993 +- i = sysfs_match_string(ad7791_sample_freq_avail, buf);
1994 +- if (i < 0)
1995 +- return i;
1996 +-
1997 +- ret = iio_device_claim_direct_mode(indio_dev);
1998 +- if (ret)
1999 +- return ret;
2000 +- st->filter &= ~AD7791_FILTER_RATE_MASK;
2001 +- st->filter |= i;
2002 +- ad_sd_write_reg(&st->sd, AD7791_REG_FILTER, sizeof(st->filter),
2003 +- st->filter);
2004 +- iio_device_release_direct_mode(indio_dev);
2005 +-
2006 +- return len;
2007 +-}
2008 +-
2009 +-static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
2010 +- ad7791_read_frequency,
2011 +- ad7791_write_frequency);
2012 +-
2013 + static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("120 100 33.3 20 16.7 16.6 13.3 9.5");
2014 +
2015 + static struct attribute *ad7791_attributes[] = {
2016 +- &iio_dev_attr_sampling_frequency.dev_attr.attr,
2017 + &iio_const_attr_sampling_frequency_available.dev_attr.attr,
2018 + NULL
2019 + };
2020 +diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
2021 +index 2b6c9b516070..d76455edd292 100644
2022 +--- a/drivers/infiniband/core/umem.c
2023 ++++ b/drivers/infiniband/core/umem.c
2024 +@@ -119,16 +119,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
2025 + umem->length = size;
2026 + umem->address = addr;
2027 + umem->page_shift = PAGE_SHIFT;
2028 +- /*
2029 +- * We ask for writable memory if any of the following
2030 +- * access flags are set. "Local write" and "remote write"
2031 +- * obviously require write access. "Remote atomic" can do
2032 +- * things like fetch and add, which will modify memory, and
2033 +- * "MW bind" can change permissions by binding a window.
2034 +- */
2035 +- umem->writable = !!(access &
2036 +- (IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE |
2037 +- IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND));
2038 ++ umem->writable = ib_access_writable(access);
2039 +
2040 + if (access & IB_ACCESS_ON_DEMAND) {
2041 + ret = ib_umem_odp_get(context, umem, access);
2042 +diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
2043 +index 4445d8ee9314..2d34a9c827b7 100644
2044 +--- a/drivers/infiniband/core/uverbs_main.c
2045 ++++ b/drivers/infiniband/core/uverbs_main.c
2046 +@@ -734,10 +734,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
2047 + if (ret)
2048 + return ret;
2049 +
2050 +- if (!file->ucontext &&
2051 +- (command != IB_USER_VERBS_CMD_GET_CONTEXT || extended))
2052 +- return -EINVAL;
2053 +-
2054 + if (extended) {
2055 + if (count < (sizeof(hdr) + sizeof(ex_hdr)))
2056 + return -EINVAL;
2057 +@@ -757,6 +753,16 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
2058 + goto out;
2059 + }
2060 +
2061 ++ /*
2062 ++ * Must be after the ib_dev check, as once the RCU clears ib_dev ==
2063 ++ * NULL means ucontext == NULL
2064 ++ */
2065 ++ if (!file->ucontext &&
2066 ++ (command != IB_USER_VERBS_CMD_GET_CONTEXT || extended)) {
2067 ++ ret = -EINVAL;
2068 ++ goto out;
2069 ++ }
2070 ++
2071 + if (!verify_command_mask(ib_dev, command, extended)) {
2072 + ret = -EOPNOTSUPP;
2073 + goto out;
2074 +diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
2075 +index 6ddfb1fade79..def3bc1e6447 100644
2076 +--- a/drivers/infiniband/core/verbs.c
2077 ++++ b/drivers/infiniband/core/verbs.c
2078 +@@ -1562,11 +1562,12 @@ EXPORT_SYMBOL(ib_destroy_qp);
2079 +
2080 + /* Completion queues */
2081 +
2082 +-struct ib_cq *ib_create_cq(struct ib_device *device,
2083 +- ib_comp_handler comp_handler,
2084 +- void (*event_handler)(struct ib_event *, void *),
2085 +- void *cq_context,
2086 +- const struct ib_cq_init_attr *cq_attr)
2087 ++struct ib_cq *__ib_create_cq(struct ib_device *device,
2088 ++ ib_comp_handler comp_handler,
2089 ++ void (*event_handler)(struct ib_event *, void *),
2090 ++ void *cq_context,
2091 ++ const struct ib_cq_init_attr *cq_attr,
2092 ++ const char *caller)
2093 + {
2094 + struct ib_cq *cq;
2095 +
2096 +@@ -1580,12 +1581,13 @@ struct ib_cq *ib_create_cq(struct ib_device *device,
2097 + cq->cq_context = cq_context;
2098 + atomic_set(&cq->usecnt, 0);
2099 + cq->res.type = RDMA_RESTRACK_CQ;
2100 ++ cq->res.kern_name = caller;
2101 + rdma_restrack_add(&cq->res);
2102 + }
2103 +
2104 + return cq;
2105 + }
2106 +-EXPORT_SYMBOL(ib_create_cq);
2107 ++EXPORT_SYMBOL(__ib_create_cq);
2108 +
2109 + int rdma_set_cq_moderation(struct ib_cq *cq, u16 cq_count, u16 cq_period)
2110 + {
2111 +diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c
2112 +index e6bdd0c1e80a..ebccc4c84827 100644
2113 +--- a/drivers/infiniband/hw/hfi1/chip.c
2114 ++++ b/drivers/infiniband/hw/hfi1/chip.c
2115 +@@ -6829,7 +6829,7 @@ static void rxe_kernel_unfreeze(struct hfi1_devdata *dd)
2116 + }
2117 + rcvmask = HFI1_RCVCTRL_CTXT_ENB;
2118 + /* HFI1_RCVCTRL_TAILUPD_[ENB|DIS] needs to be set explicitly */
2119 +- rcvmask |= HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL) ?
2120 ++ rcvmask |= rcd->rcvhdrtail_kvaddr ?
2121 + HFI1_RCVCTRL_TAILUPD_ENB : HFI1_RCVCTRL_TAILUPD_DIS;
2122 + hfi1_rcvctrl(dd, rcvmask, rcd);
2123 + hfi1_rcd_put(rcd);
2124 +@@ -8355,7 +8355,7 @@ static inline int check_packet_present(struct hfi1_ctxtdata *rcd)
2125 + u32 tail;
2126 + int present;
2127 +
2128 +- if (!HFI1_CAP_IS_KSET(DMA_RTAIL))
2129 ++ if (!rcd->rcvhdrtail_kvaddr)
2130 + present = (rcd->seq_cnt ==
2131 + rhf_rcv_seq(rhf_to_cpu(get_rhf_addr(rcd))));
2132 + else /* is RDMA rtail */
2133 +@@ -11823,7 +11823,7 @@ void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op,
2134 + /* reset the tail and hdr addresses, and sequence count */
2135 + write_kctxt_csr(dd, ctxt, RCV_HDR_ADDR,
2136 + rcd->rcvhdrq_dma);
2137 +- if (HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL))
2138 ++ if (rcd->rcvhdrtail_kvaddr)
2139 + write_kctxt_csr(dd, ctxt, RCV_HDR_TAIL_ADDR,
2140 + rcd->rcvhdrqtailaddr_dma);
2141 + rcd->seq_cnt = 1;
2142 +@@ -11903,7 +11903,7 @@ void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op,
2143 + rcvctrl |= RCV_CTXT_CTRL_INTR_AVAIL_SMASK;
2144 + if (op & HFI1_RCVCTRL_INTRAVAIL_DIS)
2145 + rcvctrl &= ~RCV_CTXT_CTRL_INTR_AVAIL_SMASK;
2146 +- if (op & HFI1_RCVCTRL_TAILUPD_ENB && rcd->rcvhdrqtailaddr_dma)
2147 ++ if ((op & HFI1_RCVCTRL_TAILUPD_ENB) && rcd->rcvhdrtail_kvaddr)
2148 + rcvctrl |= RCV_CTXT_CTRL_TAIL_UPD_SMASK;
2149 + if (op & HFI1_RCVCTRL_TAILUPD_DIS) {
2150 + /* See comment on RcvCtxtCtrl.TailUpd above */
2151 +diff --git a/drivers/infiniband/hw/hfi1/debugfs.c b/drivers/infiniband/hw/hfi1/debugfs.c
2152 +index 852173bf05d0..5343960610fe 100644
2153 +--- a/drivers/infiniband/hw/hfi1/debugfs.c
2154 ++++ b/drivers/infiniband/hw/hfi1/debugfs.c
2155 +@@ -1227,7 +1227,8 @@ DEBUGFS_FILE_OPS(fault_stats);
2156 +
2157 + static void fault_exit_opcode_debugfs(struct hfi1_ibdev *ibd)
2158 + {
2159 +- debugfs_remove_recursive(ibd->fault_opcode->dir);
2160 ++ if (ibd->fault_opcode)
2161 ++ debugfs_remove_recursive(ibd->fault_opcode->dir);
2162 + kfree(ibd->fault_opcode);
2163 + ibd->fault_opcode = NULL;
2164 + }
2165 +@@ -1255,6 +1256,7 @@ static int fault_init_opcode_debugfs(struct hfi1_ibdev *ibd)
2166 + &ibd->fault_opcode->attr);
2167 + if (IS_ERR(ibd->fault_opcode->dir)) {
2168 + kfree(ibd->fault_opcode);
2169 ++ ibd->fault_opcode = NULL;
2170 + return -ENOENT;
2171 + }
2172 +
2173 +@@ -1278,7 +1280,8 @@ static int fault_init_opcode_debugfs(struct hfi1_ibdev *ibd)
2174 +
2175 + static void fault_exit_packet_debugfs(struct hfi1_ibdev *ibd)
2176 + {
2177 +- debugfs_remove_recursive(ibd->fault_packet->dir);
2178 ++ if (ibd->fault_packet)
2179 ++ debugfs_remove_recursive(ibd->fault_packet->dir);
2180 + kfree(ibd->fault_packet);
2181 + ibd->fault_packet = NULL;
2182 + }
2183 +@@ -1304,6 +1307,7 @@ static int fault_init_packet_debugfs(struct hfi1_ibdev *ibd)
2184 + &ibd->fault_opcode->attr);
2185 + if (IS_ERR(ibd->fault_packet->dir)) {
2186 + kfree(ibd->fault_packet);
2187 ++ ibd->fault_packet = NULL;
2188 + return -ENOENT;
2189 + }
2190 +
2191 +diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c
2192 +index da4aa1a95b11..cf25913bd81c 100644
2193 +--- a/drivers/infiniband/hw/hfi1/file_ops.c
2194 ++++ b/drivers/infiniband/hw/hfi1/file_ops.c
2195 +@@ -505,7 +505,7 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma)
2196 + ret = -EINVAL;
2197 + goto done;
2198 + }
2199 +- if (flags & VM_WRITE) {
2200 ++ if ((flags & VM_WRITE) || !uctxt->rcvhdrtail_kvaddr) {
2201 + ret = -EPERM;
2202 + goto done;
2203 + }
2204 +@@ -689,8 +689,8 @@ static int hfi1_file_close(struct inode *inode, struct file *fp)
2205 + * checks to default and disable the send context.
2206 + */
2207 + if (uctxt->sc) {
2208 +- set_pio_integrity(uctxt->sc);
2209 + sc_disable(uctxt->sc);
2210 ++ set_pio_integrity(uctxt->sc);
2211 + }
2212 +
2213 + hfi1_free_ctxt_rcv_groups(uctxt);
2214 +diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h
2215 +index cac2c62bc42d..9c97c180c35e 100644
2216 +--- a/drivers/infiniband/hw/hfi1/hfi.h
2217 ++++ b/drivers/infiniband/hw/hfi1/hfi.h
2218 +@@ -1856,6 +1856,7 @@ struct cc_state *get_cc_state_protected(struct hfi1_pportdata *ppd)
2219 + #define HFI1_HAS_SDMA_TIMEOUT 0x8
2220 + #define HFI1_HAS_SEND_DMA 0x10 /* Supports Send DMA */
2221 + #define HFI1_FORCED_FREEZE 0x80 /* driver forced freeze mode */
2222 ++#define HFI1_SHUTDOWN 0x100 /* device is shutting down */
2223 +
2224 + /* IB dword length mask in PBC (lower 11 bits); same for all chips */
2225 + #define HFI1_PBC_LENGTH_MASK ((1 << 11) - 1)
2226 +diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
2227 +index 6309edf811df..92e802a64fc4 100644
2228 +--- a/drivers/infiniband/hw/hfi1/init.c
2229 ++++ b/drivers/infiniband/hw/hfi1/init.c
2230 +@@ -1058,6 +1058,10 @@ static void shutdown_device(struct hfi1_devdata *dd)
2231 + unsigned pidx;
2232 + int i;
2233 +
2234 ++ if (dd->flags & HFI1_SHUTDOWN)
2235 ++ return;
2236 ++ dd->flags |= HFI1_SHUTDOWN;
2237 ++
2238 + for (pidx = 0; pidx < dd->num_pports; ++pidx) {
2239 + ppd = dd->pport + pidx;
2240 +
2241 +@@ -1391,6 +1395,7 @@ void hfi1_disable_after_error(struct hfi1_devdata *dd)
2242 +
2243 + static void remove_one(struct pci_dev *);
2244 + static int init_one(struct pci_dev *, const struct pci_device_id *);
2245 ++static void shutdown_one(struct pci_dev *);
2246 +
2247 + #define DRIVER_LOAD_MSG "Intel " DRIVER_NAME " loaded: "
2248 + #define PFX DRIVER_NAME ": "
2249 +@@ -1407,6 +1412,7 @@ static struct pci_driver hfi1_pci_driver = {
2250 + .name = DRIVER_NAME,
2251 + .probe = init_one,
2252 + .remove = remove_one,
2253 ++ .shutdown = shutdown_one,
2254 + .id_table = hfi1_pci_tbl,
2255 + .err_handler = &hfi1_pci_err_handler,
2256 + };
2257 +@@ -1816,6 +1822,13 @@ static void remove_one(struct pci_dev *pdev)
2258 + postinit_cleanup(dd);
2259 + }
2260 +
2261 ++static void shutdown_one(struct pci_dev *pdev)
2262 ++{
2263 ++ struct hfi1_devdata *dd = pci_get_drvdata(pdev);
2264 ++
2265 ++ shutdown_device(dd);
2266 ++}
2267 ++
2268 + /**
2269 + * hfi1_create_rcvhdrq - create a receive header queue
2270 + * @dd: the hfi1_ib device
2271 +@@ -1831,7 +1844,6 @@ int hfi1_create_rcvhdrq(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd)
2272 + u64 reg;
2273 +
2274 + if (!rcd->rcvhdrq) {
2275 +- dma_addr_t dma_hdrqtail;
2276 + gfp_t gfp_flags;
2277 +
2278 + /*
2279 +@@ -1856,13 +1868,13 @@ int hfi1_create_rcvhdrq(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd)
2280 + goto bail;
2281 + }
2282 +
2283 +- if (HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL)) {
2284 ++ if (HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL) ||
2285 ++ HFI1_CAP_UGET_MASK(rcd->flags, DMA_RTAIL)) {
2286 + rcd->rcvhdrtail_kvaddr = dma_zalloc_coherent(
2287 +- &dd->pcidev->dev, PAGE_SIZE, &dma_hdrqtail,
2288 +- gfp_flags);
2289 ++ &dd->pcidev->dev, PAGE_SIZE,
2290 ++ &rcd->rcvhdrqtailaddr_dma, gfp_flags);
2291 + if (!rcd->rcvhdrtail_kvaddr)
2292 + goto bail_free;
2293 +- rcd->rcvhdrqtailaddr_dma = dma_hdrqtail;
2294 + }
2295 +
2296 + rcd->rcvhdrq_size = amt;
2297 +diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c
2298 +index 40dac4d16eb8..9cac15d10c4f 100644
2299 +--- a/drivers/infiniband/hw/hfi1/pio.c
2300 ++++ b/drivers/infiniband/hw/hfi1/pio.c
2301 +@@ -50,8 +50,6 @@
2302 + #include "qp.h"
2303 + #include "trace.h"
2304 +
2305 +-#define SC_CTXT_PACKET_EGRESS_TIMEOUT 350 /* in chip cycles */
2306 +-
2307 + #define SC(name) SEND_CTXT_##name
2308 + /*
2309 + * Send Context functions
2310 +@@ -961,15 +959,40 @@ void sc_disable(struct send_context *sc)
2311 + }
2312 +
2313 + /* return SendEgressCtxtStatus.PacketOccupancy */
2314 +-#define packet_occupancy(r) \
2315 +- (((r) & SEND_EGRESS_CTXT_STATUS_CTXT_EGRESS_PACKET_OCCUPANCY_SMASK)\
2316 +- >> SEND_EGRESS_CTXT_STATUS_CTXT_EGRESS_PACKET_OCCUPANCY_SHIFT)
2317 ++static u64 packet_occupancy(u64 reg)
2318 ++{
2319 ++ return (reg &
2320 ++ SEND_EGRESS_CTXT_STATUS_CTXT_EGRESS_PACKET_OCCUPANCY_SMASK)
2321 ++ >> SEND_EGRESS_CTXT_STATUS_CTXT_EGRESS_PACKET_OCCUPANCY_SHIFT;
2322 ++}
2323 +
2324 + /* is egress halted on the context? */
2325 +-#define egress_halted(r) \
2326 +- ((r) & SEND_EGRESS_CTXT_STATUS_CTXT_EGRESS_HALT_STATUS_SMASK)
2327 ++static bool egress_halted(u64 reg)
2328 ++{
2329 ++ return !!(reg & SEND_EGRESS_CTXT_STATUS_CTXT_EGRESS_HALT_STATUS_SMASK);
2330 ++}
2331 +
2332 +-/* wait for packet egress, optionally pause for credit return */
2333 ++/* is the send context halted? */
2334 ++static bool is_sc_halted(struct hfi1_devdata *dd, u32 hw_context)
2335 ++{
2336 ++ return !!(read_kctxt_csr(dd, hw_context, SC(STATUS)) &
2337 ++ SC(STATUS_CTXT_HALTED_SMASK));
2338 ++}
2339 ++
2340 ++/**
2341 ++ * sc_wait_for_packet_egress
2342 ++ * @sc: valid send context
2343 ++ * @pause: wait for credit return
2344 ++ *
2345 ++ * Wait for packet egress, optionally pause for credit return
2346 ++ *
2347 ++ * Egress halt and Context halt are not necessarily the same thing, so
2348 ++ * check for both.
2349 ++ *
2350 ++ * NOTE: The context halt bit may not be set immediately. Because of this,
2351 ++ * it is necessary to check the SW SFC_HALTED bit (set in the IRQ) and the HW
2352 ++ * context bit to determine if the context is halted.
2353 ++ */
2354 + static void sc_wait_for_packet_egress(struct send_context *sc, int pause)
2355 + {
2356 + struct hfi1_devdata *dd = sc->dd;
2357 +@@ -981,8 +1004,9 @@ static void sc_wait_for_packet_egress(struct send_context *sc, int pause)
2358 + reg_prev = reg;
2359 + reg = read_csr(dd, sc->hw_context * 8 +
2360 + SEND_EGRESS_CTXT_STATUS);
2361 +- /* done if egress is stopped */
2362 +- if (egress_halted(reg))
2363 ++ /* done if any halt bits, SW or HW are set */
2364 ++ if (sc->flags & SCF_HALTED ||
2365 ++ is_sc_halted(dd, sc->hw_context) || egress_halted(reg))
2366 + break;
2367 + reg = packet_occupancy(reg);
2368 + if (reg == 0)
2369 +diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
2370 +index 0793a21d76f4..d604b3d5aa3e 100644
2371 +--- a/drivers/infiniband/hw/mlx4/mad.c
2372 ++++ b/drivers/infiniband/hw/mlx4/mad.c
2373 +@@ -1934,7 +1934,6 @@ static void mlx4_ib_sqp_comp_worker(struct work_struct *work)
2374 + "buf:%lld\n", wc.wr_id);
2375 + break;
2376 + default:
2377 +- BUG_ON(1);
2378 + break;
2379 + }
2380 + } else {
2381 +diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
2382 +index 61d8b06375bb..ed1f253faf97 100644
2383 +--- a/drivers/infiniband/hw/mlx4/mr.c
2384 ++++ b/drivers/infiniband/hw/mlx4/mr.c
2385 +@@ -367,6 +367,40 @@ int mlx4_ib_umem_calc_optimal_mtt_size(struct ib_umem *umem, u64 start_va,
2386 + return block_shift;
2387 + }
2388 +
2389 ++static struct ib_umem *mlx4_get_umem_mr(struct ib_ucontext *context, u64 start,
2390 ++ u64 length, u64 virt_addr,
2391 ++ int access_flags)
2392 ++{
2393 ++ /*
2394 ++ * Force registering the memory as writable if the underlying pages
2395 ++ * are writable. This is so rereg can change the access permissions
2396 ++ * from readable to writable without having to run through ib_umem_get
2397 ++ * again
2398 ++ */
2399 ++ if (!ib_access_writable(access_flags)) {
2400 ++ struct vm_area_struct *vma;
2401 ++
2402 ++ down_read(&current->mm->mmap_sem);
2403 ++ /*
2404 ++ * FIXME: Ideally this would iterate over all the vmas that
2405 ++ * cover the memory, but for now it requires a single vma to
2406 ++ * entirely cover the MR to support RO mappings.
2407 ++ */
2408 ++ vma = find_vma(current->mm, start);
2409 ++ if (vma && vma->vm_end >= start + length &&
2410 ++ vma->vm_start <= start) {
2411 ++ if (vma->vm_flags & VM_WRITE)
2412 ++ access_flags |= IB_ACCESS_LOCAL_WRITE;
2413 ++ } else {
2414 ++ access_flags |= IB_ACCESS_LOCAL_WRITE;
2415 ++ }
2416 ++
2417 ++ up_read(&current->mm->mmap_sem);
2418 ++ }
2419 ++
2420 ++ return ib_umem_get(context, start, length, access_flags, 0);
2421 ++}
2422 ++
2423 + struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
2424 + u64 virt_addr, int access_flags,
2425 + struct ib_udata *udata)
2426 +@@ -381,10 +415,8 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
2427 + if (!mr)
2428 + return ERR_PTR(-ENOMEM);
2429 +
2430 +- /* Force registering the memory as writable. */
2431 +- /* Used for memory re-registeration. HCA protects the access */
2432 +- mr->umem = ib_umem_get(pd->uobject->context, start, length,
2433 +- access_flags | IB_ACCESS_LOCAL_WRITE, 0);
2434 ++ mr->umem = mlx4_get_umem_mr(pd->uobject->context, start, length,
2435 ++ virt_addr, access_flags);
2436 + if (IS_ERR(mr->umem)) {
2437 + err = PTR_ERR(mr->umem);
2438 + goto err_free;
2439 +@@ -454,6 +486,9 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
2440 + }
2441 +
2442 + if (flags & IB_MR_REREG_ACCESS) {
2443 ++ if (ib_access_writable(mr_access_flags) && !mmr->umem->writable)
2444 ++ return -EPERM;
2445 ++
2446 + err = mlx4_mr_hw_change_access(dev->dev, *pmpt_entry,
2447 + convert_access(mr_access_flags));
2448 +
2449 +@@ -467,10 +502,9 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
2450 +
2451 + mlx4_mr_rereg_mem_cleanup(dev->dev, &mmr->mmr);
2452 + ib_umem_release(mmr->umem);
2453 +- mmr->umem = ib_umem_get(mr->uobject->context, start, length,
2454 +- mr_access_flags |
2455 +- IB_ACCESS_LOCAL_WRITE,
2456 +- 0);
2457 ++ mmr->umem =
2458 ++ mlx4_get_umem_mr(mr->uobject->context, start, length,
2459 ++ virt_addr, mr_access_flags);
2460 + if (IS_ERR(mmr->umem)) {
2461 + err = PTR_ERR(mmr->umem);
2462 + /* Prevent mlx4_ib_dereg_mr from free'ing invalid pointer */
2463 +diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c
2464 +index 77d257ec899b..9f6bc34cd4db 100644
2465 +--- a/drivers/infiniband/hw/mlx5/cq.c
2466 ++++ b/drivers/infiniband/hw/mlx5/cq.c
2467 +@@ -637,7 +637,7 @@ static int mlx5_poll_one(struct mlx5_ib_cq *cq,
2468 + }
2469 +
2470 + static int poll_soft_wc(struct mlx5_ib_cq *cq, int num_entries,
2471 +- struct ib_wc *wc)
2472 ++ struct ib_wc *wc, bool is_fatal_err)
2473 + {
2474 + struct mlx5_ib_dev *dev = to_mdev(cq->ibcq.device);
2475 + struct mlx5_ib_wc *soft_wc, *next;
2476 +@@ -650,6 +650,10 @@ static int poll_soft_wc(struct mlx5_ib_cq *cq, int num_entries,
2477 + mlx5_ib_dbg(dev, "polled software generated completion on CQ 0x%x\n",
2478 + cq->mcq.cqn);
2479 +
2480 ++ if (unlikely(is_fatal_err)) {
2481 ++ soft_wc->wc.status = IB_WC_WR_FLUSH_ERR;
2482 ++ soft_wc->wc.vendor_err = MLX5_CQE_SYNDROME_WR_FLUSH_ERR;
2483 ++ }
2484 + wc[npolled++] = soft_wc->wc;
2485 + list_del(&soft_wc->list);
2486 + kfree(soft_wc);
2487 +@@ -670,12 +674,17 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
2488 +
2489 + spin_lock_irqsave(&cq->lock, flags);
2490 + if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
2491 +- mlx5_ib_poll_sw_comp(cq, num_entries, wc, &npolled);
2492 ++ /* make sure no soft wqe's are waiting */
2493 ++ if (unlikely(!list_empty(&cq->wc_list)))
2494 ++ soft_polled = poll_soft_wc(cq, num_entries, wc, true);
2495 ++
2496 ++ mlx5_ib_poll_sw_comp(cq, num_entries - soft_polled,
2497 ++ wc + soft_polled, &npolled);
2498 + goto out;
2499 + }
2500 +
2501 + if (unlikely(!list_empty(&cq->wc_list)))
2502 +- soft_polled = poll_soft_wc(cq, num_entries, wc);
2503 ++ soft_polled = poll_soft_wc(cq, num_entries, wc, false);
2504 +
2505 + for (npolled = 0; npolled < num_entries - soft_polled; npolled++) {
2506 + if (mlx5_poll_one(cq, &cur_qp, wc + soft_polled + npolled))
2507 +diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
2508 +index 46072455130c..3461df002f81 100644
2509 +--- a/drivers/infiniband/hw/qib/qib.h
2510 ++++ b/drivers/infiniband/hw/qib/qib.h
2511 +@@ -1228,6 +1228,7 @@ static inline struct qib_ibport *to_iport(struct ib_device *ibdev, u8 port)
2512 + #define QIB_BADINTR 0x8000 /* severe interrupt problems */
2513 + #define QIB_DCA_ENABLED 0x10000 /* Direct Cache Access enabled */
2514 + #define QIB_HAS_QSFP 0x20000 /* device (card instance) has QSFP */
2515 ++#define QIB_SHUTDOWN 0x40000 /* device is shutting down */
2516 +
2517 + /*
2518 + * values for ppd->lflags (_ib_port_ related flags)
2519 +@@ -1423,8 +1424,7 @@ u64 qib_sps_ints(void);
2520 + /*
2521 + * dma_addr wrappers - all 0's invalid for hw
2522 + */
2523 +-dma_addr_t qib_map_page(struct pci_dev *, struct page *, unsigned long,
2524 +- size_t, int);
2525 ++int qib_map_page(struct pci_dev *d, struct page *p, dma_addr_t *daddr);
2526 + struct pci_dev *qib_get_pci_dev(struct rvt_dev_info *rdi);
2527 +
2528 + /*
2529 +diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c
2530 +index 6a8800b65047..49c8e926cc64 100644
2531 +--- a/drivers/infiniband/hw/qib/qib_file_ops.c
2532 ++++ b/drivers/infiniband/hw/qib/qib_file_ops.c
2533 +@@ -364,6 +364,8 @@ static int qib_tid_update(struct qib_ctxtdata *rcd, struct file *fp,
2534 + goto done;
2535 + }
2536 + for (i = 0; i < cnt; i++, vaddr += PAGE_SIZE) {
2537 ++ dma_addr_t daddr;
2538 ++
2539 + for (; ntids--; tid++) {
2540 + if (tid == tidcnt)
2541 + tid = 0;
2542 +@@ -380,12 +382,14 @@ static int qib_tid_update(struct qib_ctxtdata *rcd, struct file *fp,
2543 + ret = -ENOMEM;
2544 + break;
2545 + }
2546 ++ ret = qib_map_page(dd->pcidev, pagep[i], &daddr);
2547 ++ if (ret)
2548 ++ break;
2549 ++
2550 + tidlist[i] = tid + tidoff;
2551 + /* we "know" system pages and TID pages are same size */
2552 + dd->pageshadow[ctxttid + tid] = pagep[i];
2553 +- dd->physshadow[ctxttid + tid] =
2554 +- qib_map_page(dd->pcidev, pagep[i], 0, PAGE_SIZE,
2555 +- PCI_DMA_FROMDEVICE);
2556 ++ dd->physshadow[ctxttid + tid] = daddr;
2557 + /*
2558 + * don't need atomic or it's overhead
2559 + */
2560 +diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c
2561 +index 6c68f8a97018..015520289735 100644
2562 +--- a/drivers/infiniband/hw/qib/qib_init.c
2563 ++++ b/drivers/infiniband/hw/qib/qib_init.c
2564 +@@ -841,6 +841,10 @@ static void qib_shutdown_device(struct qib_devdata *dd)
2565 + struct qib_pportdata *ppd;
2566 + unsigned pidx;
2567 +
2568 ++ if (dd->flags & QIB_SHUTDOWN)
2569 ++ return;
2570 ++ dd->flags |= QIB_SHUTDOWN;
2571 ++
2572 + for (pidx = 0; pidx < dd->num_pports; ++pidx) {
2573 + ppd = dd->pport + pidx;
2574 +
2575 +@@ -1182,6 +1186,7 @@ void qib_disable_after_error(struct qib_devdata *dd)
2576 +
2577 + static void qib_remove_one(struct pci_dev *);
2578 + static int qib_init_one(struct pci_dev *, const struct pci_device_id *);
2579 ++static void qib_shutdown_one(struct pci_dev *);
2580 +
2581 + #define DRIVER_LOAD_MSG "Intel " QIB_DRV_NAME " loaded: "
2582 + #define PFX QIB_DRV_NAME ": "
2583 +@@ -1199,6 +1204,7 @@ static struct pci_driver qib_driver = {
2584 + .name = QIB_DRV_NAME,
2585 + .probe = qib_init_one,
2586 + .remove = qib_remove_one,
2587 ++ .shutdown = qib_shutdown_one,
2588 + .id_table = qib_pci_tbl,
2589 + .err_handler = &qib_pci_err_handler,
2590 + };
2591 +@@ -1549,6 +1555,13 @@ static void qib_remove_one(struct pci_dev *pdev)
2592 + qib_postinit_cleanup(dd);
2593 + }
2594 +
2595 ++static void qib_shutdown_one(struct pci_dev *pdev)
2596 ++{
2597 ++ struct qib_devdata *dd = pci_get_drvdata(pdev);
2598 ++
2599 ++ qib_shutdown_device(dd);
2600 ++}
2601 ++
2602 + /**
2603 + * qib_create_rcvhdrq - create a receive header queue
2604 + * @dd: the qlogic_ib device
2605 +diff --git a/drivers/infiniband/hw/qib/qib_user_pages.c b/drivers/infiniband/hw/qib/qib_user_pages.c
2606 +index ce83ba9a12ef..16543d5e80c3 100644
2607 +--- a/drivers/infiniband/hw/qib/qib_user_pages.c
2608 ++++ b/drivers/infiniband/hw/qib/qib_user_pages.c
2609 +@@ -99,23 +99,27 @@ static int __qib_get_user_pages(unsigned long start_page, size_t num_pages,
2610 + *
2611 + * I'm sure we won't be so lucky with other iommu's, so FIXME.
2612 + */
2613 +-dma_addr_t qib_map_page(struct pci_dev *hwdev, struct page *page,
2614 +- unsigned long offset, size_t size, int direction)
2615 ++int qib_map_page(struct pci_dev *hwdev, struct page *page, dma_addr_t *daddr)
2616 + {
2617 + dma_addr_t phys;
2618 +
2619 +- phys = pci_map_page(hwdev, page, offset, size, direction);
2620 ++ phys = pci_map_page(hwdev, page, 0, PAGE_SIZE, PCI_DMA_FROMDEVICE);
2621 ++ if (pci_dma_mapping_error(hwdev, phys))
2622 ++ return -ENOMEM;
2623 +
2624 +- if (phys == 0) {
2625 +- pci_unmap_page(hwdev, phys, size, direction);
2626 +- phys = pci_map_page(hwdev, page, offset, size, direction);
2627 ++ if (!phys) {
2628 ++ pci_unmap_page(hwdev, phys, PAGE_SIZE, PCI_DMA_FROMDEVICE);
2629 ++ phys = pci_map_page(hwdev, page, 0, PAGE_SIZE,
2630 ++ PCI_DMA_FROMDEVICE);
2631 ++ if (pci_dma_mapping_error(hwdev, phys))
2632 ++ return -ENOMEM;
2633 + /*
2634 + * FIXME: If we get 0 again, we should keep this page,
2635 + * map another, then free the 0 page.
2636 + */
2637 + }
2638 +-
2639 +- return phys;
2640 ++ *daddr = phys;
2641 ++ return 0;
2642 + }
2643 +
2644 + /**
2645 +diff --git a/drivers/infiniband/sw/rdmavt/cq.c b/drivers/infiniband/sw/rdmavt/cq.c
2646 +index fb52b669bfce..340c17aba3b0 100644
2647 +--- a/drivers/infiniband/sw/rdmavt/cq.c
2648 ++++ b/drivers/infiniband/sw/rdmavt/cq.c
2649 +@@ -120,17 +120,20 @@ void rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited)
2650 + if (cq->notify == IB_CQ_NEXT_COMP ||
2651 + (cq->notify == IB_CQ_SOLICITED &&
2652 + (solicited || entry->status != IB_WC_SUCCESS))) {
2653 ++ struct kthread_worker *worker;
2654 ++
2655 + /*
2656 + * This will cause send_complete() to be called in
2657 + * another thread.
2658 + */
2659 +- spin_lock(&cq->rdi->n_cqs_lock);
2660 +- if (likely(cq->rdi->worker)) {
2661 ++ rcu_read_lock();
2662 ++ worker = rcu_dereference(cq->rdi->worker);
2663 ++ if (likely(worker)) {
2664 + cq->notify = RVT_CQ_NONE;
2665 + cq->triggered++;
2666 +- kthread_queue_work(cq->rdi->worker, &cq->comptask);
2667 ++ kthread_queue_work(worker, &cq->comptask);
2668 + }
2669 +- spin_unlock(&cq->rdi->n_cqs_lock);
2670 ++ rcu_read_unlock();
2671 + }
2672 +
2673 + spin_unlock_irqrestore(&cq->lock, flags);
2674 +@@ -512,7 +515,7 @@ int rvt_driver_cq_init(struct rvt_dev_info *rdi)
2675 + int cpu;
2676 + struct kthread_worker *worker;
2677 +
2678 +- if (rdi->worker)
2679 ++ if (rcu_access_pointer(rdi->worker))
2680 + return 0;
2681 +
2682 + spin_lock_init(&rdi->n_cqs_lock);
2683 +@@ -524,7 +527,7 @@ int rvt_driver_cq_init(struct rvt_dev_info *rdi)
2684 + return PTR_ERR(worker);
2685 +
2686 + set_user_nice(worker->task, MIN_NICE);
2687 +- rdi->worker = worker;
2688 ++ RCU_INIT_POINTER(rdi->worker, worker);
2689 + return 0;
2690 + }
2691 +
2692 +@@ -536,15 +539,19 @@ void rvt_cq_exit(struct rvt_dev_info *rdi)
2693 + {
2694 + struct kthread_worker *worker;
2695 +
2696 +- /* block future queuing from send_complete() */
2697 +- spin_lock_irq(&rdi->n_cqs_lock);
2698 +- worker = rdi->worker;
2699 ++ if (!rcu_access_pointer(rdi->worker))
2700 ++ return;
2701 ++
2702 ++ spin_lock(&rdi->n_cqs_lock);
2703 ++ worker = rcu_dereference_protected(rdi->worker,
2704 ++ lockdep_is_held(&rdi->n_cqs_lock));
2705 + if (!worker) {
2706 +- spin_unlock_irq(&rdi->n_cqs_lock);
2707 ++ spin_unlock(&rdi->n_cqs_lock);
2708 + return;
2709 + }
2710 +- rdi->worker = NULL;
2711 +- spin_unlock_irq(&rdi->n_cqs_lock);
2712 ++ RCU_INIT_POINTER(rdi->worker, NULL);
2713 ++ spin_unlock(&rdi->n_cqs_lock);
2714 ++ synchronize_rcu();
2715 +
2716 + kthread_destroy_worker(worker);
2717 + }
2718 +diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
2719 +index fff40b097947..3130698fee70 100644
2720 +--- a/drivers/infiniband/ulp/isert/ib_isert.c
2721 ++++ b/drivers/infiniband/ulp/isert/ib_isert.c
2722 +@@ -886,15 +886,9 @@ isert_login_post_send(struct isert_conn *isert_conn, struct iser_tx_desc *tx_des
2723 + }
2724 +
2725 + static void
2726 +-isert_create_send_desc(struct isert_conn *isert_conn,
2727 +- struct isert_cmd *isert_cmd,
2728 +- struct iser_tx_desc *tx_desc)
2729 ++__isert_create_send_desc(struct isert_device *device,
2730 ++ struct iser_tx_desc *tx_desc)
2731 + {
2732 +- struct isert_device *device = isert_conn->device;
2733 +- struct ib_device *ib_dev = device->ib_device;
2734 +-
2735 +- ib_dma_sync_single_for_cpu(ib_dev, tx_desc->dma_addr,
2736 +- ISER_HEADERS_LEN, DMA_TO_DEVICE);
2737 +
2738 + memset(&tx_desc->iser_header, 0, sizeof(struct iser_ctrl));
2739 + tx_desc->iser_header.flags = ISCSI_CTRL;
2740 +@@ -907,6 +901,20 @@ isert_create_send_desc(struct isert_conn *isert_conn,
2741 + }
2742 + }
2743 +
2744 ++static void
2745 ++isert_create_send_desc(struct isert_conn *isert_conn,
2746 ++ struct isert_cmd *isert_cmd,
2747 ++ struct iser_tx_desc *tx_desc)
2748 ++{
2749 ++ struct isert_device *device = isert_conn->device;
2750 ++ struct ib_device *ib_dev = device->ib_device;
2751 ++
2752 ++ ib_dma_sync_single_for_cpu(ib_dev, tx_desc->dma_addr,
2753 ++ ISER_HEADERS_LEN, DMA_TO_DEVICE);
2754 ++
2755 ++ __isert_create_send_desc(device, tx_desc);
2756 ++}
2757 ++
2758 + static int
2759 + isert_init_tx_hdrs(struct isert_conn *isert_conn,
2760 + struct iser_tx_desc *tx_desc)
2761 +@@ -994,7 +1002,7 @@ isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,
2762 + struct iser_tx_desc *tx_desc = &isert_conn->login_tx_desc;
2763 + int ret;
2764 +
2765 +- isert_create_send_desc(isert_conn, NULL, tx_desc);
2766 ++ __isert_create_send_desc(device, tx_desc);
2767 +
2768 + memcpy(&tx_desc->iscsi_header, &login->rsp[0],
2769 + sizeof(struct iscsi_hdr));
2770 +@@ -2108,7 +2116,7 @@ isert_set_sig_attrs(struct se_cmd *se_cmd, struct ib_sig_attrs *sig_attrs)
2771 +
2772 + sig_attrs->check_mask =
2773 + (se_cmd->prot_checks & TARGET_DIF_CHECK_GUARD ? 0xc0 : 0) |
2774 +- (se_cmd->prot_checks & TARGET_DIF_CHECK_REFTAG ? 0x30 : 0) |
2775 ++ (se_cmd->prot_checks & TARGET_DIF_CHECK_APPTAG ? 0x30 : 0) |
2776 + (se_cmd->prot_checks & TARGET_DIF_CHECK_REFTAG ? 0x0f : 0);
2777 + return 0;
2778 + }
2779 +diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
2780 +index a89b81b35932..62f9c23d8a7f 100644
2781 +--- a/drivers/input/joystick/xpad.c
2782 ++++ b/drivers/input/joystick/xpad.c
2783 +@@ -123,7 +123,7 @@ static const struct xpad_device {
2784 + u8 mapping;
2785 + u8 xtype;
2786 + } xpad_device[] = {
2787 +- { 0x0079, 0x18d4, "GPD Win 2 Controller", 0, XTYPE_XBOX360 },
2788 ++ { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 },
2789 + { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX },
2790 + { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX },
2791 + { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
2792 +diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
2793 +index 599544c1a91c..243e0fa6e3e3 100644
2794 +--- a/drivers/input/mouse/elan_i2c.h
2795 ++++ b/drivers/input/mouse/elan_i2c.h
2796 +@@ -27,6 +27,8 @@
2797 + #define ETP_DISABLE_POWER 0x0001
2798 + #define ETP_PRESSURE_OFFSET 25
2799 +
2800 ++#define ETP_CALIBRATE_MAX_LEN 3
2801 ++
2802 + /* IAP Firmware handling */
2803 + #define ETP_PRODUCT_ID_FORMAT_STRING "%d.0"
2804 + #define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin"
2805 +diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
2806 +index 93967c8139e7..37f954b704a6 100644
2807 +--- a/drivers/input/mouse/elan_i2c_core.c
2808 ++++ b/drivers/input/mouse/elan_i2c_core.c
2809 +@@ -610,7 +610,7 @@ static ssize_t calibrate_store(struct device *dev,
2810 + int tries = 20;
2811 + int retval;
2812 + int error;
2813 +- u8 val[3];
2814 ++ u8 val[ETP_CALIBRATE_MAX_LEN];
2815 +
2816 + retval = mutex_lock_interruptible(&data->sysfs_mutex);
2817 + if (retval)
2818 +@@ -1263,6 +1263,7 @@ static const struct acpi_device_id elan_acpi_id[] = {
2819 + { "ELAN060C", 0 },
2820 + { "ELAN0611", 0 },
2821 + { "ELAN0612", 0 },
2822 ++ { "ELAN0618", 0 },
2823 + { "ELAN1000", 0 },
2824 + { }
2825 + };
2826 +diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
2827 +index cfcb32559925..c060d270bc4d 100644
2828 +--- a/drivers/input/mouse/elan_i2c_smbus.c
2829 ++++ b/drivers/input/mouse/elan_i2c_smbus.c
2830 +@@ -56,7 +56,7 @@
2831 + static int elan_smbus_initialize(struct i2c_client *client)
2832 + {
2833 + u8 check[ETP_SMBUS_HELLOPACKET_LEN] = { 0x55, 0x55, 0x55, 0x55, 0x55 };
2834 +- u8 values[ETP_SMBUS_HELLOPACKET_LEN] = { 0, 0, 0, 0, 0 };
2835 ++ u8 values[I2C_SMBUS_BLOCK_MAX] = {0};
2836 + int len, error;
2837 +
2838 + /* Get hello packet */
2839 +@@ -117,12 +117,16 @@ static int elan_smbus_calibrate(struct i2c_client *client)
2840 + static int elan_smbus_calibrate_result(struct i2c_client *client, u8 *val)
2841 + {
2842 + int error;
2843 ++ u8 buf[I2C_SMBUS_BLOCK_MAX] = {0};
2844 ++
2845 ++ BUILD_BUG_ON(ETP_CALIBRATE_MAX_LEN > sizeof(buf));
2846 +
2847 + error = i2c_smbus_read_block_data(client,
2848 +- ETP_SMBUS_CALIBRATE_QUERY, val);
2849 ++ ETP_SMBUS_CALIBRATE_QUERY, buf);
2850 + if (error < 0)
2851 + return error;
2852 +
2853 ++ memcpy(val, buf, ETP_CALIBRATE_MAX_LEN);
2854 + return 0;
2855 + }
2856 +
2857 +@@ -472,6 +476,8 @@ static int elan_smbus_get_report(struct i2c_client *client, u8 *report)
2858 + {
2859 + int len;
2860 +
2861 ++ BUILD_BUG_ON(I2C_SMBUS_BLOCK_MAX > ETP_SMBUS_REPORT_LEN);
2862 ++
2863 + len = i2c_smbus_read_block_data(client,
2864 + ETP_SMBUS_PACKET_QUERY,
2865 + &report[ETP_SMBUS_REPORT_OFFSET]);
2866 +diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
2867 +index db47a5e1d114..b68019109e99 100644
2868 +--- a/drivers/input/mouse/elantech.c
2869 ++++ b/drivers/input/mouse/elantech.c
2870 +@@ -796,7 +796,7 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
2871 + else if (ic_version == 7 && etd->samples[1] == 0x2A)
2872 + sanity_check = ((packet[3] & 0x1c) == 0x10);
2873 + else
2874 +- sanity_check = ((packet[0] & 0x0c) == 0x04 &&
2875 ++ sanity_check = ((packet[0] & 0x08) == 0x00 &&
2876 + (packet[3] & 0x1c) == 0x10);
2877 +
2878 + if (!sanity_check)
2879 +@@ -1169,6 +1169,12 @@ static const struct dmi_system_id elantech_dmi_has_middle_button[] = {
2880 + { }
2881 + };
2882 +
2883 ++static const char * const middle_button_pnp_ids[] = {
2884 ++ "LEN2131", /* ThinkPad P52 w/ NFC */
2885 ++ "LEN2132", /* ThinkPad P52 */
2886 ++ NULL
2887 ++};
2888 ++
2889 + /*
2890 + * Set the appropriate event bits for the input subsystem
2891 + */
2892 +@@ -1188,7 +1194,8 @@ static int elantech_set_input_params(struct psmouse *psmouse)
2893 + __clear_bit(EV_REL, dev->evbit);
2894 +
2895 + __set_bit(BTN_LEFT, dev->keybit);
2896 +- if (dmi_check_system(elantech_dmi_has_middle_button))
2897 ++ if (dmi_check_system(elantech_dmi_has_middle_button) ||
2898 ++ psmouse_matches_pnp_id(psmouse, middle_button_pnp_ids))
2899 + __set_bit(BTN_MIDDLE, dev->keybit);
2900 + __set_bit(BTN_RIGHT, dev->keybit);
2901 +
2902 +diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
2903 +index 8900c3166ebf..47ed5616d026 100644
2904 +--- a/drivers/input/mouse/psmouse-base.c
2905 ++++ b/drivers/input/mouse/psmouse-base.c
2906 +@@ -192,8 +192,8 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
2907 + else
2908 + input_report_rel(dev, REL_WHEEL, -wheel);
2909 +
2910 +- input_report_key(dev, BTN_SIDE, BIT(4));
2911 +- input_report_key(dev, BTN_EXTRA, BIT(5));
2912 ++ input_report_key(dev, BTN_SIDE, packet[3] & BIT(4));
2913 ++ input_report_key(dev, BTN_EXTRA, packet[3] & BIT(5));
2914 + break;
2915 + }
2916 + break;
2917 +@@ -203,13 +203,13 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
2918 + input_report_rel(dev, REL_WHEEL, -(s8) packet[3]);
2919 +
2920 + /* Extra buttons on Genius NewNet 3D */
2921 +- input_report_key(dev, BTN_SIDE, BIT(6));
2922 +- input_report_key(dev, BTN_EXTRA, BIT(7));
2923 ++ input_report_key(dev, BTN_SIDE, packet[0] & BIT(6));
2924 ++ input_report_key(dev, BTN_EXTRA, packet[0] & BIT(7));
2925 + break;
2926 +
2927 + case PSMOUSE_THINKPS:
2928 + /* Extra button on ThinkingMouse */
2929 +- input_report_key(dev, BTN_EXTRA, BIT(3));
2930 ++ input_report_key(dev, BTN_EXTRA, packet[0] & BIT(3));
2931 +
2932 + /*
2933 + * Without this bit of weirdness moving up gives wildly
2934 +@@ -223,7 +223,7 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
2935 + * Cortron PS2 Trackball reports SIDE button in the
2936 + * 4th bit of the first byte.
2937 + */
2938 +- input_report_key(dev, BTN_SIDE, BIT(3));
2939 ++ input_report_key(dev, BTN_SIDE, packet[0] & BIT(3));
2940 + packet[0] |= BIT(3);
2941 + break;
2942 +
2943 +diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
2944 +index ff7043f74a3d..d196ac3d8b8c 100644
2945 +--- a/drivers/input/touchscreen/silead.c
2946 ++++ b/drivers/input/touchscreen/silead.c
2947 +@@ -603,6 +603,7 @@ static const struct acpi_device_id silead_ts_acpi_match[] = {
2948 + { "GSL3692", 0 },
2949 + { "MSSL1680", 0 },
2950 + { "MSSL0001", 0 },
2951 ++ { "MSSL0002", 0 },
2952 + { }
2953 + };
2954 + MODULE_DEVICE_TABLE(acpi, silead_ts_acpi_match);
2955 +diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
2956 +index df171cb85822..b38798cc5288 100644
2957 +--- a/drivers/iommu/Kconfig
2958 ++++ b/drivers/iommu/Kconfig
2959 +@@ -107,7 +107,6 @@ config IOMMU_PGTABLES_L2
2960 + # AMD IOMMU support
2961 + config AMD_IOMMU
2962 + bool "AMD IOMMU support"
2963 +- select DMA_DIRECT_OPS
2964 + select SWIOTLB
2965 + select PCI_MSI
2966 + select PCI_ATS
2967 +diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
2968 +index b0b30a568db7..12c1491a1a9a 100644
2969 +--- a/drivers/iommu/amd_iommu.c
2970 ++++ b/drivers/iommu/amd_iommu.c
2971 +@@ -2593,32 +2593,51 @@ static void *alloc_coherent(struct device *dev, size_t size,
2972 + unsigned long attrs)
2973 + {
2974 + u64 dma_mask = dev->coherent_dma_mask;
2975 +- struct protection_domain *domain = get_domain(dev);
2976 +- bool is_direct = false;
2977 +- void *virt_addr;
2978 ++ struct protection_domain *domain;
2979 ++ struct dma_ops_domain *dma_dom;
2980 ++ struct page *page;
2981 ++
2982 ++ domain = get_domain(dev);
2983 ++ if (PTR_ERR(domain) == -EINVAL) {
2984 ++ page = alloc_pages(flag, get_order(size));
2985 ++ *dma_addr = page_to_phys(page);
2986 ++ return page_address(page);
2987 ++ } else if (IS_ERR(domain))
2988 ++ return NULL;
2989 +
2990 +- if (IS_ERR(domain)) {
2991 +- if (PTR_ERR(domain) != -EINVAL)
2992 ++ dma_dom = to_dma_ops_domain(domain);
2993 ++ size = PAGE_ALIGN(size);
2994 ++ dma_mask = dev->coherent_dma_mask;
2995 ++ flag &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
2996 ++ flag |= __GFP_ZERO;
2997 ++
2998 ++ page = alloc_pages(flag | __GFP_NOWARN, get_order(size));
2999 ++ if (!page) {
3000 ++ if (!gfpflags_allow_blocking(flag))
3001 + return NULL;
3002 +- is_direct = true;
3003 +- }
3004 +
3005 +- virt_addr = dma_direct_alloc(dev, size, dma_addr, flag, attrs);
3006 +- if (!virt_addr || is_direct)
3007 +- return virt_addr;
3008 ++ page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT,
3009 ++ get_order(size), flag);
3010 ++ if (!page)
3011 ++ return NULL;
3012 ++ }
3013 +
3014 + if (!dma_mask)
3015 + dma_mask = *dev->dma_mask;
3016 +
3017 +- *dma_addr = __map_single(dev, to_dma_ops_domain(domain),
3018 +- virt_to_phys(virt_addr), PAGE_ALIGN(size),
3019 +- DMA_BIDIRECTIONAL, dma_mask);
3020 ++ *dma_addr = __map_single(dev, dma_dom, page_to_phys(page),
3021 ++ size, DMA_BIDIRECTIONAL, dma_mask);
3022 ++
3023 + if (*dma_addr == AMD_IOMMU_MAPPING_ERROR)
3024 + goto out_free;
3025 +- return virt_addr;
3026 ++
3027 ++ return page_address(page);
3028 +
3029 + out_free:
3030 +- dma_direct_free(dev, size, virt_addr, *dma_addr, attrs);
3031 ++
3032 ++ if (!dma_release_from_contiguous(dev, page, size >> PAGE_SHIFT))
3033 ++ __free_pages(page, get_order(size));
3034 ++
3035 + return NULL;
3036 + }
3037 +
3038 +@@ -2629,17 +2648,24 @@ static void free_coherent(struct device *dev, size_t size,
3039 + void *virt_addr, dma_addr_t dma_addr,
3040 + unsigned long attrs)
3041 + {
3042 +- struct protection_domain *domain = get_domain(dev);
3043 ++ struct protection_domain *domain;
3044 ++ struct dma_ops_domain *dma_dom;
3045 ++ struct page *page;
3046 +
3047 ++ page = virt_to_page(virt_addr);
3048 + size = PAGE_ALIGN(size);
3049 +
3050 +- if (!IS_ERR(domain)) {
3051 +- struct dma_ops_domain *dma_dom = to_dma_ops_domain(domain);
3052 ++ domain = get_domain(dev);
3053 ++ if (IS_ERR(domain))
3054 ++ goto free_mem;
3055 +
3056 +- __unmap_single(dma_dom, dma_addr, size, DMA_BIDIRECTIONAL);
3057 +- }
3058 ++ dma_dom = to_dma_ops_domain(domain);
3059 ++
3060 ++ __unmap_single(dma_dom, dma_addr, size, DMA_BIDIRECTIONAL);
3061 +
3062 +- dma_direct_free(dev, size, virt_addr, dma_addr, attrs);
3063 ++free_mem:
3064 ++ if (!dma_release_from_contiguous(dev, page, size >> PAGE_SHIFT))
3065 ++ __free_pages(page, get_order(size));
3066 + }
3067 +
3068 + /*
3069 +diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
3070 +index 5416f2b2ac21..ab16968fced8 100644
3071 +--- a/drivers/irqchip/irq-gic-v3-its.c
3072 ++++ b/drivers/irqchip/irq-gic-v3-its.c
3073 +@@ -2309,7 +2309,14 @@ static int its_irq_domain_activate(struct irq_domain *domain,
3074 + cpu_mask = cpumask_of_node(its_dev->its->numa_node);
3075 +
3076 + /* Bind the LPI to the first possible CPU */
3077 +- cpu = cpumask_first(cpu_mask);
3078 ++ cpu = cpumask_first_and(cpu_mask, cpu_online_mask);
3079 ++ if (cpu >= nr_cpu_ids) {
3080 ++ if (its_dev->its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144)
3081 ++ return -EINVAL;
3082 ++
3083 ++ cpu = cpumask_first(cpu_online_mask);
3084 ++ }
3085 ++
3086 + its_dev->event_map.col_map[event] = cpu;
3087 + irq_data_update_effective_affinity(d, cpumask_of(cpu));
3088 +
3089 +diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
3090 +index b11107497d2e..19478c7b2268 100644
3091 +--- a/drivers/md/dm-thin.c
3092 ++++ b/drivers/md/dm-thin.c
3093 +@@ -1385,6 +1385,8 @@ static void schedule_external_copy(struct thin_c *tc, dm_block_t virt_block,
3094 +
3095 + static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
3096 +
3097 ++static void requeue_bios(struct pool *pool);
3098 ++
3099 + static void check_for_space(struct pool *pool)
3100 + {
3101 + int r;
3102 +@@ -1397,8 +1399,10 @@ static void check_for_space(struct pool *pool)
3103 + if (r)
3104 + return;
3105 +
3106 +- if (nr_free)
3107 ++ if (nr_free) {
3108 + set_pool_mode(pool, PM_WRITE);
3109 ++ requeue_bios(pool);
3110 ++ }
3111 + }
3112 +
3113 + /*
3114 +@@ -1475,7 +1479,10 @@ static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
3115 +
3116 + r = dm_pool_alloc_data_block(pool->pmd, result);
3117 + if (r) {
3118 +- metadata_operation_failed(pool, "dm_pool_alloc_data_block", r);
3119 ++ if (r == -ENOSPC)
3120 ++ set_pool_mode(pool, PM_OUT_OF_DATA_SPACE);
3121 ++ else
3122 ++ metadata_operation_failed(pool, "dm_pool_alloc_data_block", r);
3123 + return r;
3124 + }
3125 +
3126 +diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
3127 +index e73b0776683c..e302f1558fa0 100644
3128 +--- a/drivers/md/dm-zoned-target.c
3129 ++++ b/drivers/md/dm-zoned-target.c
3130 +@@ -788,7 +788,7 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv)
3131 +
3132 + /* Chunk BIO work */
3133 + mutex_init(&dmz->chunk_lock);
3134 +- INIT_RADIX_TREE(&dmz->chunk_rxtree, GFP_KERNEL);
3135 ++ INIT_RADIX_TREE(&dmz->chunk_rxtree, GFP_NOIO);
3136 + dmz->chunk_wq = alloc_workqueue("dmz_cwq_%s", WQ_MEM_RECLAIM | WQ_UNBOUND,
3137 + 0, dev->name);
3138 + if (!dmz->chunk_wq) {
3139 +diff --git a/drivers/md/dm.c b/drivers/md/dm.c
3140 +index 0a7b0107ca78..cabae3e280c2 100644
3141 +--- a/drivers/md/dm.c
3142 ++++ b/drivers/md/dm.c
3143 +@@ -1582,10 +1582,9 @@ static blk_qc_t __split_and_process_bio(struct mapped_device *md,
3144 + * the usage of io->orig_bio in dm_remap_zone_report()
3145 + * won't be affected by this reassignment.
3146 + */
3147 +- struct bio *b = bio_clone_bioset(bio, GFP_NOIO,
3148 +- md->queue->bio_split);
3149 ++ struct bio *b = bio_split(bio, bio_sectors(bio) - ci.sector_count,
3150 ++ GFP_NOIO, md->queue->bio_split);
3151 + ci.io->orig_bio = b;
3152 +- bio_advance(bio, (bio_sectors(bio) - ci.sector_count) << 9);
3153 + bio_chain(b, bio);
3154 + ret = generic_make_request(bio);
3155 + break;
3156 +diff --git a/drivers/md/md.c b/drivers/md/md.c
3157 +index c208c01f63a5..bac480d75d1d 100644
3158 +--- a/drivers/md/md.c
3159 ++++ b/drivers/md/md.c
3160 +@@ -2853,7 +2853,8 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
3161 + err = 0;
3162 + }
3163 + } else if (cmd_match(buf, "re-add")) {
3164 +- if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1)) {
3165 ++ if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1) &&
3166 ++ rdev->saved_raid_disk >= 0) {
3167 + /* clear_bit is performed _after_ all the devices
3168 + * have their local Faulty bit cleared. If any writes
3169 + * happen in the meantime in the local node, they
3170 +@@ -8641,6 +8642,7 @@ static int remove_and_add_spares(struct mddev *mddev,
3171 + if (mddev->pers->hot_remove_disk(
3172 + mddev, rdev) == 0) {
3173 + sysfs_unlink_rdev(mddev, rdev);
3174 ++ rdev->saved_raid_disk = rdev->raid_disk;
3175 + rdev->raid_disk = -1;
3176 + removed++;
3177 + }
3178 +diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
3179 +index e33414975065..a4ada1ccf0df 100644
3180 +--- a/drivers/media/dvb-core/dvb_frontend.c
3181 ++++ b/drivers/media/dvb-core/dvb_frontend.c
3182 +@@ -275,8 +275,20 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe,
3183 + wake_up_interruptible (&events->wait_queue);
3184 + }
3185 +
3186 ++static int dvb_frontend_test_event(struct dvb_frontend_private *fepriv,
3187 ++ struct dvb_fe_events *events)
3188 ++{
3189 ++ int ret;
3190 ++
3191 ++ up(&fepriv->sem);
3192 ++ ret = events->eventw != events->eventr;
3193 ++ down(&fepriv->sem);
3194 ++
3195 ++ return ret;
3196 ++}
3197 ++
3198 + static int dvb_frontend_get_event(struct dvb_frontend *fe,
3199 +- struct dvb_frontend_event *event, int flags)
3200 ++ struct dvb_frontend_event *event, int flags)
3201 + {
3202 + struct dvb_frontend_private *fepriv = fe->frontend_priv;
3203 + struct dvb_fe_events *events = &fepriv->events;
3204 +@@ -294,13 +306,8 @@ static int dvb_frontend_get_event(struct dvb_frontend *fe,
3205 + if (flags & O_NONBLOCK)
3206 + return -EWOULDBLOCK;
3207 +
3208 +- up(&fepriv->sem);
3209 +-
3210 +- ret = wait_event_interruptible (events->wait_queue,
3211 +- events->eventw != events->eventr);
3212 +-
3213 +- if (down_interruptible (&fepriv->sem))
3214 +- return -ERESTARTSYS;
3215 ++ ret = wait_event_interruptible(events->wait_queue,
3216 ++ dvb_frontend_test_event(fepriv, events));
3217 +
3218 + if (ret < 0)
3219 + return ret;
3220 +diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
3221 +index c2d3b8f0f487..93f69b3ac911 100644
3222 +--- a/drivers/media/platform/vsp1/vsp1_video.c
3223 ++++ b/drivers/media/platform/vsp1/vsp1_video.c
3224 +@@ -849,9 +849,8 @@ static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe)
3225 + return 0;
3226 + }
3227 +
3228 +-static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe)
3229 ++static void vsp1_video_release_buffers(struct vsp1_video *video)
3230 + {
3231 +- struct vsp1_video *video = pipe->output->video;
3232 + struct vsp1_vb2_buffer *buffer;
3233 + unsigned long flags;
3234 +
3235 +@@ -861,12 +860,18 @@ static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe)
3236 + vb2_buffer_done(&buffer->buf.vb2_buf, VB2_BUF_STATE_ERROR);
3237 + INIT_LIST_HEAD(&video->irqqueue);
3238 + spin_unlock_irqrestore(&video->irqlock, flags);
3239 ++}
3240 ++
3241 ++static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe)
3242 ++{
3243 ++ lockdep_assert_held(&pipe->lock);
3244 +
3245 + /* Release our partition table allocation */
3246 +- mutex_lock(&pipe->lock);
3247 + kfree(pipe->part_table);
3248 + pipe->part_table = NULL;
3249 +- mutex_unlock(&pipe->lock);
3250 ++
3251 ++ vsp1_dl_list_put(pipe->dl);
3252 ++ pipe->dl = NULL;
3253 + }
3254 +
3255 + static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
3256 +@@ -881,8 +886,9 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
3257 + if (pipe->stream_count == pipe->num_inputs) {
3258 + ret = vsp1_video_setup_pipeline(pipe);
3259 + if (ret < 0) {
3260 +- mutex_unlock(&pipe->lock);
3261 ++ vsp1_video_release_buffers(video);
3262 + vsp1_video_cleanup_pipeline(pipe);
3263 ++ mutex_unlock(&pipe->lock);
3264 + return ret;
3265 + }
3266 +
3267 +@@ -932,13 +938,12 @@ static void vsp1_video_stop_streaming(struct vb2_queue *vq)
3268 + if (ret == -ETIMEDOUT)
3269 + dev_err(video->vsp1->dev, "pipeline stop timeout\n");
3270 +
3271 +- vsp1_dl_list_put(pipe->dl);
3272 +- pipe->dl = NULL;
3273 ++ vsp1_video_cleanup_pipeline(pipe);
3274 + }
3275 + mutex_unlock(&pipe->lock);
3276 +
3277 + media_pipeline_stop(&video->video.entity);
3278 +- vsp1_video_cleanup_pipeline(pipe);
3279 ++ vsp1_video_release_buffers(video);
3280 + vsp1_video_pipeline_put(pipe);
3281 + }
3282 +
3283 +diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c
3284 +index c110984ca671..5478fe08f9d3 100644
3285 +--- a/drivers/media/rc/ir-mce_kbd-decoder.c
3286 ++++ b/drivers/media/rc/ir-mce_kbd-decoder.c
3287 +@@ -130,6 +130,8 @@ static void mce_kbd_rx_timeout(struct timer_list *t)
3288 +
3289 + for (i = 0; i < MCIR2_MASK_KEYS_START; i++)
3290 + input_report_key(raw->mce_kbd.idev, kbd_keycodes[i], 0);
3291 ++
3292 ++ input_sync(raw->mce_kbd.idev);
3293 + }
3294 +
3295 + static enum mce_kbd_mode mce_kbd_mode(struct mce_kbd_dec *data)
3296 +diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
3297 +index c76b2101193c..89795d4d0a71 100644
3298 +--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
3299 ++++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
3300 +@@ -1024,6 +1024,9 @@ struct usb_device_id cx231xx_id_table[] = {
3301 + .driver_info = CX231XX_BOARD_CNXT_RDE_250},
3302 + {USB_DEVICE(0x0572, 0x58A0),
3303 + .driver_info = CX231XX_BOARD_CNXT_RDU_250},
3304 ++ /* AverMedia DVD EZMaker 7 */
3305 ++ {USB_DEVICE(0x07ca, 0xc039),
3306 ++ .driver_info = CX231XX_BOARD_CNXT_VIDEO_GRABBER},
3307 + {USB_DEVICE(0x2040, 0xb110),
3308 + .driver_info = CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL},
3309 + {USB_DEVICE(0x2040, 0xb111),
3310 +diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
3311 +index 67ed66712d05..f31ffaf9d2f2 100644
3312 +--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
3313 ++++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
3314 +@@ -1151,7 +1151,7 @@ static int dvb_init(struct cx231xx *dev)
3315 + info.platform_data = &si2157_config;
3316 + request_module("si2157");
3317 +
3318 +- client = i2c_new_device(adapter, &info);
3319 ++ client = i2c_new_device(tuner_i2c, &info);
3320 + if (client == NULL || client->dev.driver == NULL) {
3321 + module_put(dvb->i2c_client_demod[0]->dev.driver->owner);
3322 + i2c_unregister_device(dvb->i2c_client_demod[0]);
3323 +diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
3324 +index aa0082fe5833..b28c997a7ab0 100644
3325 +--- a/drivers/media/usb/uvc/uvc_video.c
3326 ++++ b/drivers/media/usb/uvc/uvc_video.c
3327 +@@ -163,14 +163,27 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
3328 + }
3329 + }
3330 +
3331 ++static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
3332 ++{
3333 ++ /*
3334 ++ * Return the size of the video probe and commit controls, which depends
3335 ++ * on the protocol version.
3336 ++ */
3337 ++ if (stream->dev->uvc_version < 0x0110)
3338 ++ return 26;
3339 ++ else if (stream->dev->uvc_version < 0x0150)
3340 ++ return 34;
3341 ++ else
3342 ++ return 48;
3343 ++}
3344 ++
3345 + static int uvc_get_video_ctrl(struct uvc_streaming *stream,
3346 + struct uvc_streaming_control *ctrl, int probe, u8 query)
3347 + {
3348 ++ u16 size = uvc_video_ctrl_size(stream);
3349 + u8 *data;
3350 +- u16 size;
3351 + int ret;
3352 +
3353 +- size = stream->dev->uvc_version >= 0x0110 ? 34 : 26;
3354 + if ((stream->dev->quirks & UVC_QUIRK_PROBE_DEF) &&
3355 + query == UVC_GET_DEF)
3356 + return -EIO;
3357 +@@ -225,7 +238,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
3358 + ctrl->dwMaxVideoFrameSize = get_unaligned_le32(&data[18]);
3359 + ctrl->dwMaxPayloadTransferSize = get_unaligned_le32(&data[22]);
3360 +
3361 +- if (size == 34) {
3362 ++ if (size >= 34) {
3363 + ctrl->dwClockFrequency = get_unaligned_le32(&data[26]);
3364 + ctrl->bmFramingInfo = data[30];
3365 + ctrl->bPreferedVersion = data[31];
3366 +@@ -254,11 +267,10 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
3367 + static int uvc_set_video_ctrl(struct uvc_streaming *stream,
3368 + struct uvc_streaming_control *ctrl, int probe)
3369 + {
3370 ++ u16 size = uvc_video_ctrl_size(stream);
3371 + u8 *data;
3372 +- u16 size;
3373 + int ret;
3374 +
3375 +- size = stream->dev->uvc_version >= 0x0110 ? 34 : 26;
3376 + data = kzalloc(size, GFP_KERNEL);
3377 + if (data == NULL)
3378 + return -ENOMEM;
3379 +@@ -275,7 +287,7 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
3380 + put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]);
3381 + put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]);
3382 +
3383 +- if (size == 34) {
3384 ++ if (size >= 34) {
3385 + put_unaligned_le32(ctrl->dwClockFrequency, &data[26]);
3386 + data[30] = ctrl->bmFramingInfo;
3387 + data[31] = ctrl->bPreferedVersion;
3388 +diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
3389 +index 4312935f1dfc..d03a44d89649 100644
3390 +--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
3391 ++++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
3392 +@@ -871,7 +871,7 @@ static int put_v4l2_ext_controls32(struct file *file,
3393 + get_user(kcontrols, &kp->controls))
3394 + return -EFAULT;
3395 +
3396 +- if (!count)
3397 ++ if (!count || count > (U32_MAX/sizeof(*ucontrols)))
3398 + return 0;
3399 + if (get_user(p, &up->controls))
3400 + return -EFAULT;
3401 +diff --git a/drivers/mfd/intel-lpss-pci.c b/drivers/mfd/intel-lpss-pci.c
3402 +index d1c46de89eb4..d9ae983095c5 100644
3403 +--- a/drivers/mfd/intel-lpss-pci.c
3404 ++++ b/drivers/mfd/intel-lpss-pci.c
3405 +@@ -124,6 +124,11 @@ static const struct intel_lpss_platform_info apl_i2c_info = {
3406 + .properties = apl_i2c_properties,
3407 + };
3408 +
3409 ++static const struct intel_lpss_platform_info cnl_i2c_info = {
3410 ++ .clk_rate = 216000000,
3411 ++ .properties = spt_i2c_properties,
3412 ++};
3413 ++
3414 + static const struct pci_device_id intel_lpss_pci_ids[] = {
3415 + /* BXT A-Step */
3416 + { PCI_VDEVICE(INTEL, 0x0aac), (kernel_ulong_t)&bxt_i2c_info },
3417 +@@ -207,13 +212,13 @@ static const struct pci_device_id intel_lpss_pci_ids[] = {
3418 + { PCI_VDEVICE(INTEL, 0x9daa), (kernel_ulong_t)&spt_info },
3419 + { PCI_VDEVICE(INTEL, 0x9dab), (kernel_ulong_t)&spt_info },
3420 + { PCI_VDEVICE(INTEL, 0x9dfb), (kernel_ulong_t)&spt_info },
3421 +- { PCI_VDEVICE(INTEL, 0x9dc5), (kernel_ulong_t)&spt_i2c_info },
3422 +- { PCI_VDEVICE(INTEL, 0x9dc6), (kernel_ulong_t)&spt_i2c_info },
3423 ++ { PCI_VDEVICE(INTEL, 0x9dc5), (kernel_ulong_t)&cnl_i2c_info },
3424 ++ { PCI_VDEVICE(INTEL, 0x9dc6), (kernel_ulong_t)&cnl_i2c_info },
3425 + { PCI_VDEVICE(INTEL, 0x9dc7), (kernel_ulong_t)&spt_uart_info },
3426 +- { PCI_VDEVICE(INTEL, 0x9de8), (kernel_ulong_t)&spt_i2c_info },
3427 +- { PCI_VDEVICE(INTEL, 0x9de9), (kernel_ulong_t)&spt_i2c_info },
3428 +- { PCI_VDEVICE(INTEL, 0x9dea), (kernel_ulong_t)&spt_i2c_info },
3429 +- { PCI_VDEVICE(INTEL, 0x9deb), (kernel_ulong_t)&spt_i2c_info },
3430 ++ { PCI_VDEVICE(INTEL, 0x9de8), (kernel_ulong_t)&cnl_i2c_info },
3431 ++ { PCI_VDEVICE(INTEL, 0x9de9), (kernel_ulong_t)&cnl_i2c_info },
3432 ++ { PCI_VDEVICE(INTEL, 0x9dea), (kernel_ulong_t)&cnl_i2c_info },
3433 ++ { PCI_VDEVICE(INTEL, 0x9deb), (kernel_ulong_t)&cnl_i2c_info },
3434 + /* SPT-H */
3435 + { PCI_VDEVICE(INTEL, 0xa127), (kernel_ulong_t)&spt_uart_info },
3436 + { PCI_VDEVICE(INTEL, 0xa128), (kernel_ulong_t)&spt_uart_info },
3437 +@@ -240,10 +245,10 @@ static const struct pci_device_id intel_lpss_pci_ids[] = {
3438 + { PCI_VDEVICE(INTEL, 0xa32b), (kernel_ulong_t)&spt_info },
3439 + { PCI_VDEVICE(INTEL, 0xa37b), (kernel_ulong_t)&spt_info },
3440 + { PCI_VDEVICE(INTEL, 0xa347), (kernel_ulong_t)&spt_uart_info },
3441 +- { PCI_VDEVICE(INTEL, 0xa368), (kernel_ulong_t)&spt_i2c_info },
3442 +- { PCI_VDEVICE(INTEL, 0xa369), (kernel_ulong_t)&spt_i2c_info },
3443 +- { PCI_VDEVICE(INTEL, 0xa36a), (kernel_ulong_t)&spt_i2c_info },
3444 +- { PCI_VDEVICE(INTEL, 0xa36b), (kernel_ulong_t)&spt_i2c_info },
3445 ++ { PCI_VDEVICE(INTEL, 0xa368), (kernel_ulong_t)&cnl_i2c_info },
3446 ++ { PCI_VDEVICE(INTEL, 0xa369), (kernel_ulong_t)&cnl_i2c_info },
3447 ++ { PCI_VDEVICE(INTEL, 0xa36a), (kernel_ulong_t)&cnl_i2c_info },
3448 ++ { PCI_VDEVICE(INTEL, 0xa36b), (kernel_ulong_t)&cnl_i2c_info },
3449 + { }
3450 + };
3451 + MODULE_DEVICE_TABLE(pci, intel_lpss_pci_ids);
3452 +diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
3453 +index 9e545eb6e8b4..4bcf117a7ba8 100644
3454 +--- a/drivers/mfd/intel-lpss.c
3455 ++++ b/drivers/mfd/intel-lpss.c
3456 +@@ -275,11 +275,11 @@ static void intel_lpss_init_dev(const struct intel_lpss *lpss)
3457 +
3458 + intel_lpss_deassert_reset(lpss);
3459 +
3460 ++ intel_lpss_set_remap_addr(lpss);
3461 ++
3462 + if (!intel_lpss_has_idma(lpss))
3463 + return;
3464 +
3465 +- intel_lpss_set_remap_addr(lpss);
3466 +-
3467 + /* Make sure that SPI multiblock DMA transfers are re-enabled */
3468 + if (lpss->type == LPSS_DEV_SPI)
3469 + writel(value, lpss->priv + LPSS_PRIV_SSP_REG);
3470 +diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
3471 +index d3133a371e27..c649344fd7f2 100644
3472 +--- a/drivers/mfd/twl-core.c
3473 ++++ b/drivers/mfd/twl-core.c
3474 +@@ -1177,7 +1177,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
3475 + twl_priv->ready = true;
3476 +
3477 + /* setup clock framework */
3478 +- clocks_init(&pdev->dev, pdata ? pdata->clock : NULL);
3479 ++ clocks_init(&client->dev, pdata ? pdata->clock : NULL);
3480 +
3481 + /* read TWL IDCODE Register */
3482 + if (twl_class_is_4030()) {
3483 +diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
3484 +index 4d6736f9d463..429d6de1dde7 100644
3485 +--- a/drivers/misc/cxl/pci.c
3486 ++++ b/drivers/misc/cxl/pci.c
3487 +@@ -514,9 +514,9 @@ static int init_implementation_adapter_regs_psl9(struct cxl *adapter,
3488 + cxl_p1_write(adapter, CXL_PSL9_FIR_CNTL, psl_fircntl);
3489 +
3490 + /* Setup the PSL to transmit packets on the PCIe before the
3491 +- * CAPP is enabled
3492 ++ * CAPP is enabled. Make sure that CAPP virtual machines are disabled
3493 + */
3494 +- cxl_p1_write(adapter, CXL_PSL9_DSNDCTL, 0x0001001000002A10ULL);
3495 ++ cxl_p1_write(adapter, CXL_PSL9_DSNDCTL, 0x0001001000012A10ULL);
3496 +
3497 + /*
3498 + * A response to an ASB_Notify request is returned by the
3499 +diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c
3500 +index 4b5a4c5d3c01..629e2e156412 100644
3501 +--- a/drivers/misc/cxl/sysfs.c
3502 ++++ b/drivers/misc/cxl/sysfs.c
3503 +@@ -353,12 +353,20 @@ static ssize_t prefault_mode_store(struct device *device,
3504 + struct cxl_afu *afu = to_cxl_afu(device);
3505 + enum prefault_modes mode = -1;
3506 +
3507 +- if (!strncmp(buf, "work_element_descriptor", 23))
3508 +- mode = CXL_PREFAULT_WED;
3509 +- if (!strncmp(buf, "all", 3))
3510 +- mode = CXL_PREFAULT_ALL;
3511 + if (!strncmp(buf, "none", 4))
3512 + mode = CXL_PREFAULT_NONE;
3513 ++ else {
3514 ++ if (!radix_enabled()) {
3515 ++
3516 ++ /* only allowed when not in radix mode */
3517 ++ if (!strncmp(buf, "work_element_descriptor", 23))
3518 ++ mode = CXL_PREFAULT_WED;
3519 ++ if (!strncmp(buf, "all", 3))
3520 ++ mode = CXL_PREFAULT_ALL;
3521 ++ } else {
3522 ++ dev_err(device, "Cannot prefault with radix enabled\n");
3523 ++ }
3524 ++ }
3525 +
3526 + if (mode == -1)
3527 + return -EINVAL;
3528 +diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
3529 +index 51e01f03fb99..45c015da2e75 100644
3530 +--- a/drivers/mmc/host/renesas_sdhi_core.c
3531 ++++ b/drivers/mmc/host/renesas_sdhi_core.c
3532 +@@ -28,6 +28,7 @@
3533 + #include <linux/of_device.h>
3534 + #include <linux/platform_device.h>
3535 + #include <linux/mmc/host.h>
3536 ++#include <linux/mmc/slot-gpio.h>
3537 + #include <linux/mfd/tmio.h>
3538 + #include <linux/sh_dma.h>
3539 + #include <linux/delay.h>
3540 +@@ -534,6 +535,10 @@ int renesas_sdhi_probe(struct platform_device *pdev,
3541 + host->multi_io_quirk = renesas_sdhi_multi_io_quirk;
3542 + host->dma_ops = dma_ops;
3543 +
3544 ++ /* For some SoC, we disable internal WP. GPIO may override this */
3545 ++ if (mmc_can_gpio_ro(host->mmc))
3546 ++ mmc_data->capabilities2 &= ~MMC_CAP2_NO_WRITE_PROTECT;
3547 ++
3548 + /* SDR speeds are only available on Gen2+ */
3549 + if (mmc_data->flags & TMIO_MMC_MIN_RCAR2) {
3550 + /* card_busy caused issues on r8a73a4 (pre-Gen2) CD-less SDHI */
3551 +diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
3552 +index 6af946d16d24..eb027cdc8f24 100644
3553 +--- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c
3554 ++++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
3555 +@@ -87,6 +87,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = {
3556 + TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
3557 + .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
3558 + MMC_CAP_CMD23,
3559 ++ .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
3560 + .bus_shift = 2,
3561 + .scc_offset = 0x1000,
3562 + .taps = rcar_gen3_scc_taps,
3563 +diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c
3564 +index 848e50c1638a..4bb46c489d71 100644
3565 +--- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c
3566 ++++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c
3567 +@@ -42,6 +42,7 @@ static const struct renesas_sdhi_of_data of_rz_compatible = {
3568 + static const struct renesas_sdhi_of_data of_rcar_gen1_compatible = {
3569 + .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL,
3570 + .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
3571 ++ .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
3572 + };
3573 +
3574 + /* Definitions for sampling clocks */
3575 +@@ -61,6 +62,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen2_compatible = {
3576 + TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
3577 + .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
3578 + MMC_CAP_CMD23,
3579 ++ .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
3580 + .dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES,
3581 + .dma_rx_offset = 0x2000,
3582 + .scc_offset = 0x0300,
3583 +@@ -81,6 +83,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = {
3584 + TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
3585 + .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
3586 + MMC_CAP_CMD23,
3587 ++ .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
3588 + .bus_shift = 2,
3589 + .scc_offset = 0x1000,
3590 + .taps = rcar_gen3_scc_taps,
3591 +diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
3592 +index 692902df2598..3a8a88fa06aa 100644
3593 +--- a/drivers/mtd/chips/cfi_cmdset_0002.c
3594 ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c
3595 +@@ -1880,7 +1880,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
3596 + if (time_after(jiffies, timeo) && !chip_ready(map, adr))
3597 + break;
3598 +
3599 +- if (chip_ready(map, adr)) {
3600 ++ if (chip_good(map, adr, datum)) {
3601 + xip_enable(map, chip, adr);
3602 + goto op_done;
3603 + }
3604 +@@ -2515,7 +2515,7 @@ static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
3605 +
3606 + struct ppb_lock {
3607 + struct flchip *chip;
3608 +- loff_t offset;
3609 ++ unsigned long adr;
3610 + int locked;
3611 + };
3612 +
3613 +@@ -2533,8 +2533,9 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
3614 + unsigned long timeo;
3615 + int ret;
3616 +
3617 ++ adr += chip->start;
3618 + mutex_lock(&chip->mutex);
3619 +- ret = get_chip(map, chip, adr + chip->start, FL_LOCKING);
3620 ++ ret = get_chip(map, chip, adr, FL_LOCKING);
3621 + if (ret) {
3622 + mutex_unlock(&chip->mutex);
3623 + return ret;
3624 +@@ -2552,8 +2553,8 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
3625 +
3626 + if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) {
3627 + chip->state = FL_LOCKING;
3628 +- map_write(map, CMD(0xA0), chip->start + adr);
3629 +- map_write(map, CMD(0x00), chip->start + adr);
3630 ++ map_write(map, CMD(0xA0), adr);
3631 ++ map_write(map, CMD(0x00), adr);
3632 + } else if (thunk == DO_XXLOCK_ONEBLOCK_UNLOCK) {
3633 + /*
3634 + * Unlocking of one specific sector is not supported, so we
3635 +@@ -2591,7 +2592,7 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
3636 + map_write(map, CMD(0x00), chip->start);
3637 +
3638 + chip->state = FL_READY;
3639 +- put_chip(map, chip, adr + chip->start);
3640 ++ put_chip(map, chip, adr);
3641 + mutex_unlock(&chip->mutex);
3642 +
3643 + return ret;
3644 +@@ -2648,9 +2649,9 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
3645 + * sectors shall be unlocked, so lets keep their locking
3646 + * status at "unlocked" (locked=0) for the final re-locking.
3647 + */
3648 +- if ((adr < ofs) || (adr >= (ofs + len))) {
3649 ++ if ((offset < ofs) || (offset >= (ofs + len))) {
3650 + sect[sectors].chip = &cfi->chips[chipnum];
3651 +- sect[sectors].offset = offset;
3652 ++ sect[sectors].adr = adr;
3653 + sect[sectors].locked = do_ppb_xxlock(
3654 + map, &cfi->chips[chipnum], adr, 0,
3655 + DO_XXLOCK_ONEBLOCK_GETLOCK);
3656 +@@ -2664,6 +2665,8 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
3657 + i++;
3658 +
3659 + if (adr >> cfi->chipshift) {
3660 ++ if (offset >= (ofs + len))
3661 ++ break;
3662 + adr = 0;
3663 + chipnum++;
3664 +
3665 +@@ -2694,7 +2697,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
3666 + */
3667 + for (i = 0; i < sectors; i++) {
3668 + if (sect[i].locked)
3669 +- do_ppb_xxlock(map, sect[i].chip, sect[i].offset, 0,
3670 ++ do_ppb_xxlock(map, sect[i].chip, sect[i].adr, 0,
3671 + DO_XXLOCK_ONEBLOCK_LOCK);
3672 + }
3673 +
3674 +diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c
3675 +index cfd33e6ca77f..5869e90cc14b 100644
3676 +--- a/drivers/mtd/nand/raw/denali_dt.c
3677 ++++ b/drivers/mtd/nand/raw/denali_dt.c
3678 +@@ -123,7 +123,11 @@ static int denali_dt_probe(struct platform_device *pdev)
3679 + if (ret)
3680 + return ret;
3681 +
3682 +- denali->clk_x_rate = clk_get_rate(dt->clk);
3683 ++ /*
3684 ++ * Hardcode the clock rate for the backward compatibility.
3685 ++ * This works for both SOCFPGA and UniPhier.
3686 ++ */
3687 ++ denali->clk_x_rate = 200000000;
3688 +
3689 + ret = denali_init(denali);
3690 + if (ret)
3691 +diff --git a/drivers/mtd/nand/raw/mxc_nand.c b/drivers/mtd/nand/raw/mxc_nand.c
3692 +index 45786e707b7b..26cef218bb43 100644
3693 +--- a/drivers/mtd/nand/raw/mxc_nand.c
3694 ++++ b/drivers/mtd/nand/raw/mxc_nand.c
3695 +@@ -48,7 +48,7 @@
3696 + #define NFC_V1_V2_CONFIG (host->regs + 0x0a)
3697 + #define NFC_V1_V2_ECC_STATUS_RESULT (host->regs + 0x0c)
3698 + #define NFC_V1_V2_RSLTMAIN_AREA (host->regs + 0x0e)
3699 +-#define NFC_V1_V2_RSLTSPARE_AREA (host->regs + 0x10)
3700 ++#define NFC_V21_RSLTSPARE_AREA (host->regs + 0x10)
3701 + #define NFC_V1_V2_WRPROT (host->regs + 0x12)
3702 + #define NFC_V1_UNLOCKSTART_BLKADDR (host->regs + 0x14)
3703 + #define NFC_V1_UNLOCKEND_BLKADDR (host->regs + 0x16)
3704 +@@ -1274,6 +1274,9 @@ static void preset_v2(struct mtd_info *mtd)
3705 + writew(config1, NFC_V1_V2_CONFIG1);
3706 + /* preset operation */
3707 +
3708 ++ /* spare area size in 16-bit half-words */
3709 ++ writew(mtd->oobsize / 2, NFC_V21_RSLTSPARE_AREA);
3710 ++
3711 + /* Unlock the internal RAM Buffer */
3712 + writew(0x2, NFC_V1_V2_CONFIG);
3713 +
3714 +diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
3715 +index f28c3a555861..7a881000eeba 100644
3716 +--- a/drivers/mtd/nand/raw/nand_base.c
3717 ++++ b/drivers/mtd/nand/raw/nand_base.c
3718 +@@ -440,7 +440,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs)
3719 +
3720 + for (; page < page_end; page++) {
3721 + res = chip->ecc.read_oob(mtd, chip, page);
3722 +- if (res)
3723 ++ if (res < 0)
3724 + return res;
3725 +
3726 + bad = chip->oob_poi[chip->badblockpos];
3727 +@@ -2174,7 +2174,6 @@ static int nand_set_features_op(struct nand_chip *chip, u8 feature,
3728 + struct mtd_info *mtd = nand_to_mtd(chip);
3729 + const u8 *params = data;
3730 + int i, ret;
3731 +- u8 status;
3732 +
3733 + if (chip->exec_op) {
3734 + const struct nand_sdr_timings *sdr =
3735 +@@ -2188,26 +2187,18 @@ static int nand_set_features_op(struct nand_chip *chip, u8 feature,
3736 + };
3737 + struct nand_operation op = NAND_OPERATION(instrs);
3738 +
3739 +- ret = nand_exec_op(chip, &op);
3740 +- if (ret)
3741 +- return ret;
3742 +-
3743 +- ret = nand_status_op(chip, &status);
3744 +- if (ret)
3745 +- return ret;
3746 +- } else {
3747 +- chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, feature, -1);
3748 +- for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i)
3749 +- chip->write_byte(mtd, params[i]);
3750 ++ return nand_exec_op(chip, &op);
3751 ++ }
3752 +
3753 +- ret = chip->waitfunc(mtd, chip);
3754 +- if (ret < 0)
3755 +- return ret;
3756 ++ chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, feature, -1);
3757 ++ for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i)
3758 ++ chip->write_byte(mtd, params[i]);
3759 +
3760 +- status = ret;
3761 +- }
3762 ++ ret = chip->waitfunc(mtd, chip);
3763 ++ if (ret < 0)
3764 ++ return ret;
3765 +
3766 +- if (status & NAND_STATUS_FAIL)
3767 ++ if (ret & NAND_STATUS_FAIL)
3768 + return -EIO;
3769 +
3770 + return 0;
3771 +diff --git a/drivers/mtd/nand/raw/nand_macronix.c b/drivers/mtd/nand/raw/nand_macronix.c
3772 +index 7ed1f87e742a..49c546c97c6f 100644
3773 +--- a/drivers/mtd/nand/raw/nand_macronix.c
3774 ++++ b/drivers/mtd/nand/raw/nand_macronix.c
3775 +@@ -17,23 +17,47 @@
3776 +
3777 + #include <linux/mtd/rawnand.h>
3778 +
3779 ++/*
3780 ++ * Macronix AC series does not support using SET/GET_FEATURES to change
3781 ++ * the timings unlike what is declared in the parameter page. Unflag
3782 ++ * this feature to avoid unnecessary downturns.
3783 ++ */
3784 ++static void macronix_nand_fix_broken_get_timings(struct nand_chip *chip)
3785 ++{
3786 ++ unsigned int i;
3787 ++ static const char * const broken_get_timings[] = {
3788 ++ "MX30LF1G18AC",
3789 ++ "MX30LF1G28AC",
3790 ++ "MX30LF2G18AC",
3791 ++ "MX30LF2G28AC",
3792 ++ "MX30LF4G18AC",
3793 ++ "MX30LF4G28AC",
3794 ++ "MX60LF8G18AC",
3795 ++ };
3796 ++
3797 ++ if (!chip->parameters.supports_set_get_features)
3798 ++ return;
3799 ++
3800 ++ for (i = 0; i < ARRAY_SIZE(broken_get_timings); i++) {
3801 ++ if (!strcmp(broken_get_timings[i], chip->parameters.model))
3802 ++ break;
3803 ++ }
3804 ++
3805 ++ if (i == ARRAY_SIZE(broken_get_timings))
3806 ++ return;
3807 ++
3808 ++ bitmap_clear(chip->parameters.get_feature_list,
3809 ++ ONFI_FEATURE_ADDR_TIMING_MODE, 1);
3810 ++ bitmap_clear(chip->parameters.set_feature_list,
3811 ++ ONFI_FEATURE_ADDR_TIMING_MODE, 1);
3812 ++}
3813 ++
3814 + static int macronix_nand_init(struct nand_chip *chip)
3815 + {
3816 + if (nand_is_slc(chip))
3817 + chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
3818 +
3819 +- /*
3820 +- * MX30LF2G18AC chip does not support using SET/GET_FEATURES to change
3821 +- * the timings unlike what is declared in the parameter page. Unflag
3822 +- * this feature to avoid unnecessary downturns.
3823 +- */
3824 +- if (chip->parameters.supports_set_get_features &&
3825 +- !strcmp("MX30LF2G18AC", chip->parameters.model)) {
3826 +- bitmap_clear(chip->parameters.get_feature_list,
3827 +- ONFI_FEATURE_ADDR_TIMING_MODE, 1);
3828 +- bitmap_clear(chip->parameters.set_feature_list,
3829 +- ONFI_FEATURE_ADDR_TIMING_MODE, 1);
3830 +- }
3831 ++ macronix_nand_fix_broken_get_timings(chip);
3832 +
3833 + return 0;
3834 + }
3835 +diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c
3836 +index 0af45b134c0c..5ec4c90a637d 100644
3837 +--- a/drivers/mtd/nand/raw/nand_micron.c
3838 ++++ b/drivers/mtd/nand/raw/nand_micron.c
3839 +@@ -66,7 +66,9 @@ static int micron_nand_onfi_init(struct nand_chip *chip)
3840 +
3841 + if (p->supports_set_get_features) {
3842 + set_bit(ONFI_FEATURE_ADDR_READ_RETRY, p->set_feature_list);
3843 ++ set_bit(ONFI_FEATURE_ON_DIE_ECC, p->set_feature_list);
3844 + set_bit(ONFI_FEATURE_ADDR_READ_RETRY, p->get_feature_list);
3845 ++ set_bit(ONFI_FEATURE_ON_DIE_ECC, p->get_feature_list);
3846 + }
3847 +
3848 + return 0;
3849 +diff --git a/drivers/mtd/spi-nor/intel-spi.c b/drivers/mtd/spi-nor/intel-spi.c
3850 +index 699951523179..8e98f4ab87c1 100644
3851 +--- a/drivers/mtd/spi-nor/intel-spi.c
3852 ++++ b/drivers/mtd/spi-nor/intel-spi.c
3853 +@@ -136,6 +136,7 @@
3854 + * @swseq_reg: Use SW sequencer in register reads/writes
3855 + * @swseq_erase: Use SW sequencer in erase operation
3856 + * @erase_64k: 64k erase supported
3857 ++ * @atomic_preopcode: Holds preopcode when atomic sequence is requested
3858 + * @opcodes: Opcodes which are supported. This are programmed by BIOS
3859 + * before it locks down the controller.
3860 + */
3861 +@@ -153,6 +154,7 @@ struct intel_spi {
3862 + bool swseq_reg;
3863 + bool swseq_erase;
3864 + bool erase_64k;
3865 ++ u8 atomic_preopcode;
3866 + u8 opcodes[8];
3867 + };
3868 +
3869 +@@ -474,7 +476,7 @@ static int intel_spi_sw_cycle(struct intel_spi *ispi, u8 opcode, int len,
3870 + int optype)
3871 + {
3872 + u32 val = 0, status;
3873 +- u16 preop;
3874 ++ u8 atomic_preopcode;
3875 + int ret;
3876 +
3877 + ret = intel_spi_opcode_index(ispi, opcode, optype);
3878 +@@ -484,17 +486,42 @@ static int intel_spi_sw_cycle(struct intel_spi *ispi, u8 opcode, int len,
3879 + if (len > INTEL_SPI_FIFO_SZ)
3880 + return -EINVAL;
3881 +
3882 ++ /*
3883 ++ * Always clear it after each SW sequencer operation regardless
3884 ++ * of whether it is successful or not.
3885 ++ */
3886 ++ atomic_preopcode = ispi->atomic_preopcode;
3887 ++ ispi->atomic_preopcode = 0;
3888 ++
3889 + /* Only mark 'Data Cycle' bit when there is data to be transferred */
3890 + if (len > 0)
3891 + val = ((len - 1) << SSFSTS_CTL_DBC_SHIFT) | SSFSTS_CTL_DS;
3892 + val |= ret << SSFSTS_CTL_COP_SHIFT;
3893 + val |= SSFSTS_CTL_FCERR | SSFSTS_CTL_FDONE;
3894 + val |= SSFSTS_CTL_SCGO;
3895 +- preop = readw(ispi->sregs + PREOP_OPTYPE);
3896 +- if (preop) {
3897 +- val |= SSFSTS_CTL_ACS;
3898 +- if (preop >> 8)
3899 +- val |= SSFSTS_CTL_SPOP;
3900 ++ if (atomic_preopcode) {
3901 ++ u16 preop;
3902 ++
3903 ++ switch (optype) {
3904 ++ case OPTYPE_WRITE_NO_ADDR:
3905 ++ case OPTYPE_WRITE_WITH_ADDR:
3906 ++ /* Pick matching preopcode for the atomic sequence */
3907 ++ preop = readw(ispi->sregs + PREOP_OPTYPE);
3908 ++ if ((preop & 0xff) == atomic_preopcode)
3909 ++ ; /* Do nothing */
3910 ++ else if ((preop >> 8) == atomic_preopcode)
3911 ++ val |= SSFSTS_CTL_SPOP;
3912 ++ else
3913 ++ return -EINVAL;
3914 ++
3915 ++ /* Enable atomic sequence */
3916 ++ val |= SSFSTS_CTL_ACS;
3917 ++ break;
3918 ++
3919 ++ default:
3920 ++ return -EINVAL;
3921 ++ }
3922 ++
3923 + }
3924 + writel(val, ispi->sregs + SSFSTS_CTL);
3925 +
3926 +@@ -538,13 +565,31 @@ static int intel_spi_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
3927 +
3928 + /*
3929 + * This is handled with atomic operation and preop code in Intel
3930 +- * controller so skip it here now. If the controller is not locked,
3931 +- * program the opcode to the PREOP register for later use.
3932 ++ * controller so we only verify that it is available. If the
3933 ++ * controller is not locked, program the opcode to the PREOP
3934 ++ * register for later use.
3935 ++ *
3936 ++ * When hardware sequencer is used there is no need to program
3937 ++ * any opcodes (it handles them automatically as part of a command).
3938 + */
3939 + if (opcode == SPINOR_OP_WREN) {
3940 +- if (!ispi->locked)
3941 ++ u16 preop;
3942 ++
3943 ++ if (!ispi->swseq_reg)
3944 ++ return 0;
3945 ++
3946 ++ preop = readw(ispi->sregs + PREOP_OPTYPE);
3947 ++ if ((preop & 0xff) != opcode && (preop >> 8) != opcode) {
3948 ++ if (ispi->locked)
3949 ++ return -EINVAL;
3950 + writel(opcode, ispi->sregs + PREOP_OPTYPE);
3951 ++ }
3952 +
3953 ++ /*
3954 ++ * This enables atomic sequence on next SW sycle. Will
3955 ++ * be cleared after next operation.
3956 ++ */
3957 ++ ispi->atomic_preopcode = opcode;
3958 + return 0;
3959 + }
3960 +
3961 +@@ -569,6 +614,13 @@ static ssize_t intel_spi_read(struct spi_nor *nor, loff_t from, size_t len,
3962 + u32 val, status;
3963 + ssize_t ret;
3964 +
3965 ++ /*
3966 ++ * Atomic sequence is not expected with HW sequencer reads. Make
3967 ++ * sure it is cleared regardless.
3968 ++ */
3969 ++ if (WARN_ON_ONCE(ispi->atomic_preopcode))
3970 ++ ispi->atomic_preopcode = 0;
3971 ++
3972 + switch (nor->read_opcode) {
3973 + case SPINOR_OP_READ:
3974 + case SPINOR_OP_READ_FAST:
3975 +@@ -627,6 +679,9 @@ static ssize_t intel_spi_write(struct spi_nor *nor, loff_t to, size_t len,
3976 + u32 val, status;
3977 + ssize_t ret;
3978 +
3979 ++ /* Not needed with HW sequencer write, make sure it is cleared */
3980 ++ ispi->atomic_preopcode = 0;
3981 ++
3982 + while (len > 0) {
3983 + block_size = min_t(size_t, len, INTEL_SPI_FIFO_SZ);
3984 +
3985 +@@ -707,6 +762,9 @@ static int intel_spi_erase(struct spi_nor *nor, loff_t offs)
3986 + return 0;
3987 + }
3988 +
3989 ++ /* Not needed with HW sequencer erase, make sure it is cleared */
3990 ++ ispi->atomic_preopcode = 0;
3991 ++
3992 + while (len > 0) {
3993 + writel(offs, ispi->base + FADDR);
3994 +
3995 +diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
3996 +index 753494e042d5..74425af840d6 100644
3997 +--- a/drivers/mtd/ubi/build.c
3998 ++++ b/drivers/mtd/ubi/build.c
3999 +@@ -1091,6 +1091,9 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
4000 + if (ubi->bgt_thread)
4001 + kthread_stop(ubi->bgt_thread);
4002 +
4003 ++#ifdef CONFIG_MTD_UBI_FASTMAP
4004 ++ cancel_work_sync(&ubi->fm_work);
4005 ++#endif
4006 + ubi_debugfs_exit_dev(ubi);
4007 + uif_close(ubi);
4008 +
4009 +diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
4010 +index 250e30fac61b..593a4f9d97e3 100644
4011 +--- a/drivers/mtd/ubi/eba.c
4012 ++++ b/drivers/mtd/ubi/eba.c
4013 +@@ -490,6 +490,82 @@ int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol,
4014 + return err;
4015 + }
4016 +
4017 ++#ifdef CONFIG_MTD_UBI_FASTMAP
4018 ++/**
4019 ++ * check_mapping - check and fixup a mapping
4020 ++ * @ubi: UBI device description object
4021 ++ * @vol: volume description object
4022 ++ * @lnum: logical eraseblock number
4023 ++ * @pnum: physical eraseblock number
4024 ++ *
4025 ++ * Checks whether a given mapping is valid. Fastmap cannot track LEB unmap
4026 ++ * operations, if such an operation is interrupted the mapping still looks
4027 ++ * good, but upon first read an ECC is reported to the upper layer.
4028 ++ * Normaly during the full-scan at attach time this is fixed, for Fastmap
4029 ++ * we have to deal with it while reading.
4030 ++ * If the PEB behind a LEB shows this symthom we change the mapping to
4031 ++ * %UBI_LEB_UNMAPPED and schedule the PEB for erasure.
4032 ++ *
4033 ++ * Returns 0 on success, negative error code in case of failure.
4034 ++ */
4035 ++static int check_mapping(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
4036 ++ int *pnum)
4037 ++{
4038 ++ int err;
4039 ++ struct ubi_vid_io_buf *vidb;
4040 ++
4041 ++ if (!ubi->fast_attach)
4042 ++ return 0;
4043 ++
4044 ++ vidb = ubi_alloc_vid_buf(ubi, GFP_NOFS);
4045 ++ if (!vidb)
4046 ++ return -ENOMEM;
4047 ++
4048 ++ err = ubi_io_read_vid_hdr(ubi, *pnum, vidb, 0);
4049 ++ if (err > 0 && err != UBI_IO_BITFLIPS) {
4050 ++ int torture = 0;
4051 ++
4052 ++ switch (err) {
4053 ++ case UBI_IO_FF:
4054 ++ case UBI_IO_FF_BITFLIPS:
4055 ++ case UBI_IO_BAD_HDR:
4056 ++ case UBI_IO_BAD_HDR_EBADMSG:
4057 ++ break;
4058 ++ default:
4059 ++ ubi_assert(0);
4060 ++ }
4061 ++
4062 ++ if (err == UBI_IO_BAD_HDR_EBADMSG || err == UBI_IO_FF_BITFLIPS)
4063 ++ torture = 1;
4064 ++
4065 ++ down_read(&ubi->fm_eba_sem);
4066 ++ vol->eba_tbl->entries[lnum].pnum = UBI_LEB_UNMAPPED;
4067 ++ up_read(&ubi->fm_eba_sem);
4068 ++ ubi_wl_put_peb(ubi, vol->vol_id, lnum, *pnum, torture);
4069 ++
4070 ++ *pnum = UBI_LEB_UNMAPPED;
4071 ++ } else if (err < 0) {
4072 ++ ubi_err(ubi, "unable to read VID header back from PEB %i: %i",
4073 ++ *pnum, err);
4074 ++
4075 ++ goto out_free;
4076 ++ }
4077 ++
4078 ++ err = 0;
4079 ++
4080 ++out_free:
4081 ++ ubi_free_vid_buf(vidb);
4082 ++
4083 ++ return err;
4084 ++}
4085 ++#else
4086 ++static int check_mapping(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
4087 ++ int *pnum)
4088 ++{
4089 ++ return 0;
4090 ++}
4091 ++#endif
4092 ++
4093 + /**
4094 + * ubi_eba_read_leb - read data.
4095 + * @ubi: UBI device description object
4096 +@@ -522,7 +598,13 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
4097 + return err;
4098 +
4099 + pnum = vol->eba_tbl->entries[lnum].pnum;
4100 +- if (pnum < 0) {
4101 ++ if (pnum >= 0) {
4102 ++ err = check_mapping(ubi, vol, lnum, &pnum);
4103 ++ if (err < 0)
4104 ++ goto out_unlock;
4105 ++ }
4106 ++
4107 ++ if (pnum == UBI_LEB_UNMAPPED) {
4108 + /*
4109 + * The logical eraseblock is not mapped, fill the whole buffer
4110 + * with 0xFF bytes. The exception is static volumes for which
4111 +@@ -930,6 +1012,12 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
4112 + return err;
4113 +
4114 + pnum = vol->eba_tbl->entries[lnum].pnum;
4115 ++ if (pnum >= 0) {
4116 ++ err = check_mapping(ubi, vol, lnum, &pnum);
4117 ++ if (err < 0)
4118 ++ goto out;
4119 ++ }
4120 ++
4121 + if (pnum >= 0) {
4122 + dbg_eba("write %d bytes at offset %d of LEB %d:%d, PEB %d",
4123 + len, offset, vol_id, lnum, pnum);
4124 +diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
4125 +index 2052a647220e..f66b3b22f328 100644
4126 +--- a/drivers/mtd/ubi/wl.c
4127 ++++ b/drivers/mtd/ubi/wl.c
4128 +@@ -1505,6 +1505,7 @@ int ubi_thread(void *u)
4129 + }
4130 +
4131 + dbg_wl("background thread \"%s\" is killed", ubi->bgt_name);
4132 ++ ubi->thread_enabled = 0;
4133 + return 0;
4134 + }
4135 +
4136 +@@ -1514,9 +1515,6 @@ int ubi_thread(void *u)
4137 + */
4138 + static void shutdown_work(struct ubi_device *ubi)
4139 + {
4140 +-#ifdef CONFIG_MTD_UBI_FASTMAP
4141 +- flush_work(&ubi->fm_work);
4142 +-#endif
4143 + while (!list_empty(&ubi->works)) {
4144 + struct ubi_work *wrk;
4145 +
4146 +diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
4147 +index 38828ab77eb9..1480c094b57d 100644
4148 +--- a/drivers/net/ethernet/ti/davinci_emac.c
4149 ++++ b/drivers/net/ethernet/ti/davinci_emac.c
4150 +@@ -1385,6 +1385,11 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
4151 + return -EOPNOTSUPP;
4152 + }
4153 +
4154 ++static int match_first_device(struct device *dev, void *data)
4155 ++{
4156 ++ return !strncmp(dev_name(dev), "davinci_mdio", 12);
4157 ++}
4158 ++
4159 + /**
4160 + * emac_dev_open - EMAC device open
4161 + * @ndev: The DaVinci EMAC network adapter
4162 +@@ -1484,8 +1489,14 @@ static int emac_dev_open(struct net_device *ndev)
4163 +
4164 + /* use the first phy on the bus if pdata did not give us a phy id */
4165 + if (!phydev && !priv->phy_id) {
4166 +- phy = bus_find_device_by_name(&mdio_bus_type, NULL,
4167 +- "davinci_mdio");
4168 ++ /* NOTE: we can't use bus_find_device_by_name() here because
4169 ++ * the device name is not guaranteed to be 'davinci_mdio'. On
4170 ++ * some systems it can be 'davinci_mdio.0' so we need to use
4171 ++ * strncmp() against the first part of the string to correctly
4172 ++ * match it.
4173 ++ */
4174 ++ phy = bus_find_device(&mdio_bus_type, NULL, NULL,
4175 ++ match_first_device);
4176 + if (phy) {
4177 + priv->phy_id = dev_name(phy);
4178 + if (!priv->phy_id || !*priv->phy_id)
4179 +diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
4180 +index a64023690cad..b9e0d30e317a 100644
4181 +--- a/drivers/nvdimm/bus.c
4182 ++++ b/drivers/nvdimm/bus.c
4183 +@@ -566,14 +566,18 @@ int nvdimm_revalidate_disk(struct gendisk *disk)
4184 + {
4185 + struct device *dev = disk_to_dev(disk)->parent;
4186 + struct nd_region *nd_region = to_nd_region(dev->parent);
4187 +- const char *pol = nd_region->ro ? "only" : "write";
4188 ++ int disk_ro = get_disk_ro(disk);
4189 +
4190 +- if (nd_region->ro == get_disk_ro(disk))
4191 ++ /*
4192 ++ * Upgrade to read-only if the region is read-only preserve as
4193 ++ * read-only if the disk is already read-only.
4194 ++ */
4195 ++ if (disk_ro || nd_region->ro == disk_ro)
4196 + return 0;
4197 +
4198 +- dev_info(dev, "%s read-%s, marking %s read-%s\n",
4199 +- dev_name(&nd_region->dev), pol, disk->disk_name, pol);
4200 +- set_disk_ro(disk, nd_region->ro);
4201 ++ dev_info(dev, "%s read-only, marking %s read-only\n",
4202 ++ dev_name(&nd_region->dev), disk->disk_name);
4203 ++ set_disk_ro(disk, 1);
4204 +
4205 + return 0;
4206 +
4207 +diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
4208 +index 9d714926ecf5..d7193c4a6ee2 100644
4209 +--- a/drivers/nvdimm/pmem.c
4210 ++++ b/drivers/nvdimm/pmem.c
4211 +@@ -299,7 +299,7 @@ static int pmem_attach_disk(struct device *dev,
4212 + {
4213 + struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);
4214 + struct nd_region *nd_region = to_nd_region(dev->parent);
4215 +- int nid = dev_to_node(dev), fua, wbc;
4216 ++ int nid = dev_to_node(dev), fua;
4217 + struct resource *res = &nsio->res;
4218 + struct resource bb_res;
4219 + struct nd_pfn *nd_pfn = NULL;
4220 +@@ -335,7 +335,6 @@ static int pmem_attach_disk(struct device *dev,
4221 + dev_warn(dev, "unable to guarantee persistence of writes\n");
4222 + fua = 0;
4223 + }
4224 +- wbc = nvdimm_has_cache(nd_region);
4225 +
4226 + if (!devm_request_mem_region(dev, res->start, resource_size(res),
4227 + dev_name(&ndns->dev))) {
4228 +@@ -382,13 +381,14 @@ static int pmem_attach_disk(struct device *dev,
4229 + return PTR_ERR(addr);
4230 + pmem->virt_addr = addr;
4231 +
4232 +- blk_queue_write_cache(q, wbc, fua);
4233 ++ blk_queue_write_cache(q, true, fua);
4234 + blk_queue_make_request(q, pmem_make_request);
4235 + blk_queue_physical_block_size(q, PAGE_SIZE);
4236 + blk_queue_logical_block_size(q, pmem_sector_size(ndns));
4237 + blk_queue_max_hw_sectors(q, UINT_MAX);
4238 + blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
4239 +- blk_queue_flag_set(QUEUE_FLAG_DAX, q);
4240 ++ if (pmem->pfn_flags & PFN_MAP)
4241 ++ blk_queue_flag_set(QUEUE_FLAG_DAX, q);
4242 + q->queuedata = pmem;
4243 +
4244 + disk = alloc_disk_node(0, nid);
4245 +@@ -413,7 +413,7 @@ static int pmem_attach_disk(struct device *dev,
4246 + put_disk(disk);
4247 + return -ENOMEM;
4248 + }
4249 +- dax_write_cache(dax_dev, wbc);
4250 ++ dax_write_cache(dax_dev, nvdimm_has_cache(nd_region));
4251 + pmem->dax_dev = dax_dev;
4252 +
4253 + gendev = disk_to_dev(disk);
4254 +diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
4255 +index a612be6f019d..ec3543b83330 100644
4256 +--- a/drivers/nvdimm/region_devs.c
4257 ++++ b/drivers/nvdimm/region_devs.c
4258 +@@ -1132,7 +1132,8 @@ EXPORT_SYMBOL_GPL(nvdimm_has_flush);
4259 +
4260 + int nvdimm_has_cache(struct nd_region *nd_region)
4261 + {
4262 +- return is_nd_pmem(&nd_region->dev);
4263 ++ return is_nd_pmem(&nd_region->dev) &&
4264 ++ !test_bit(ND_REGION_PERSIST_CACHE, &nd_region->flags);
4265 + }
4266 + EXPORT_SYMBOL_GPL(nvdimm_has_cache);
4267 +
4268 +diff --git a/drivers/of/platform.c b/drivers/of/platform.c
4269 +index c00d81dfac0b..9c91f97ffbe1 100644
4270 +--- a/drivers/of/platform.c
4271 ++++ b/drivers/of/platform.c
4272 +@@ -537,6 +537,9 @@ int of_platform_device_destroy(struct device *dev, void *data)
4273 + if (of_node_check_flag(dev->of_node, OF_POPULATED_BUS))
4274 + device_for_each_child(dev, NULL, of_platform_device_destroy);
4275 +
4276 ++ of_node_clear_flag(dev->of_node, OF_POPULATED);
4277 ++ of_node_clear_flag(dev->of_node, OF_POPULATED_BUS);
4278 ++
4279 + if (dev->bus == &platform_bus_type)
4280 + platform_device_unregister(to_platform_device(dev));
4281 + #ifdef CONFIG_ARM_AMBA
4282 +@@ -544,8 +547,6 @@ int of_platform_device_destroy(struct device *dev, void *data)
4283 + amba_device_unregister(to_amba_device(dev));
4284 + #endif
4285 +
4286 +- of_node_clear_flag(dev->of_node, OF_POPULATED);
4287 +- of_node_clear_flag(dev->of_node, OF_POPULATED_BUS);
4288 + return 0;
4289 + }
4290 + EXPORT_SYMBOL_GPL(of_platform_device_destroy);
4291 +diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
4292 +index 65d0b7adfcd4..7edfac6f1914 100644
4293 +--- a/drivers/of/resolver.c
4294 ++++ b/drivers/of/resolver.c
4295 +@@ -122,6 +122,11 @@ static int update_usages_of_a_phandle_reference(struct device_node *overlay,
4296 + goto err_fail;
4297 + }
4298 +
4299 ++ if (offset < 0 || offset + sizeof(__be32) > prop->length) {
4300 ++ err = -EINVAL;
4301 ++ goto err_fail;
4302 ++ }
4303 ++
4304 + *(__be32 *)(prop->value + offset) = cpu_to_be32(phandle);
4305 + }
4306 +
4307 +diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
4308 +index 6bb37c18292a..ecee50d10d14 100644
4309 +--- a/drivers/of/unittest.c
4310 ++++ b/drivers/of/unittest.c
4311 +@@ -165,20 +165,20 @@ static void __init of_unittest_dynamic(void)
4312 + /* Add a new property - should pass*/
4313 + prop->name = "new-property";
4314 + prop->value = "new-property-data";
4315 +- prop->length = strlen(prop->value);
4316 ++ prop->length = strlen(prop->value) + 1;
4317 + unittest(of_add_property(np, prop) == 0, "Adding a new property failed\n");
4318 +
4319 + /* Try to add an existing property - should fail */
4320 + prop++;
4321 + prop->name = "new-property";
4322 + prop->value = "new-property-data-should-fail";
4323 +- prop->length = strlen(prop->value);
4324 ++ prop->length = strlen(prop->value) + 1;
4325 + unittest(of_add_property(np, prop) != 0,
4326 + "Adding an existing property should have failed\n");
4327 +
4328 + /* Try to modify an existing property - should pass */
4329 + prop->value = "modify-property-data-should-pass";
4330 +- prop->length = strlen(prop->value);
4331 ++ prop->length = strlen(prop->value) + 1;
4332 + unittest(of_update_property(np, prop) == 0,
4333 + "Updating an existing property should have passed\n");
4334 +
4335 +@@ -186,7 +186,7 @@ static void __init of_unittest_dynamic(void)
4336 + prop++;
4337 + prop->name = "modify-property";
4338 + prop->value = "modify-missing-property-data-should-pass";
4339 +- prop->length = strlen(prop->value);
4340 ++ prop->length = strlen(prop->value) + 1;
4341 + unittest(of_update_property(np, prop) == 0,
4342 + "Updating a missing property should have passed\n");
4343 +
4344 +diff --git a/drivers/opp/core.c b/drivers/opp/core.c
4345 +index 92fa94a6dcc1..9c3f5e3df232 100644
4346 +--- a/drivers/opp/core.c
4347 ++++ b/drivers/opp/core.c
4348 +@@ -591,7 +591,7 @@ static int _generic_set_opp_regulator(const struct opp_table *opp_table,
4349 + }
4350 +
4351 + /* Scaling up? Scale voltage before frequency */
4352 +- if (freq > old_freq) {
4353 ++ if (freq >= old_freq) {
4354 + ret = _set_opp_voltage(dev, reg, new_supply);
4355 + if (ret)
4356 + goto restore_voltage;
4357 +diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
4358 +index c75199538c05..da4b457a14e0 100644
4359 +--- a/drivers/pci/host/pci-hyperv.c
4360 ++++ b/drivers/pci/host/pci-hyperv.c
4361 +@@ -1596,17 +1596,6 @@ static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus,
4362 + get_pcichild(hpdev, hv_pcidev_ref_childlist);
4363 + spin_lock_irqsave(&hbus->device_list_lock, flags);
4364 +
4365 +- /*
4366 +- * When a device is being added to the bus, we set the PCI domain
4367 +- * number to be the device serial number, which is non-zero and
4368 +- * unique on the same VM. The serial numbers start with 1, and
4369 +- * increase by 1 for each device. So device names including this
4370 +- * can have shorter names than based on the bus instance UUID.
4371 +- * Only the first device serial number is used for domain, so the
4372 +- * domain number will not change after the first device is added.
4373 +- */
4374 +- if (list_empty(&hbus->children))
4375 +- hbus->sysdata.domain = desc->ser;
4376 + list_add_tail(&hpdev->list_entry, &hbus->children);
4377 + spin_unlock_irqrestore(&hbus->device_list_lock, flags);
4378 + return hpdev;
4379 +diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
4380 +index 88e917c9120f..5f892065585e 100644
4381 +--- a/drivers/pci/hotplug/pciehp.h
4382 ++++ b/drivers/pci/hotplug/pciehp.h
4383 +@@ -121,7 +121,7 @@ struct controller *pcie_init(struct pcie_device *dev);
4384 + int pcie_init_notification(struct controller *ctrl);
4385 + int pciehp_enable_slot(struct slot *p_slot);
4386 + int pciehp_disable_slot(struct slot *p_slot);
4387 +-void pcie_enable_notification(struct controller *ctrl);
4388 ++void pcie_reenable_notification(struct controller *ctrl);
4389 + int pciehp_power_on_slot(struct slot *slot);
4390 + void pciehp_power_off_slot(struct slot *slot);
4391 + void pciehp_get_power_status(struct slot *slot, u8 *status);
4392 +diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
4393 +index 332b723ff9e6..44a6a63802d5 100644
4394 +--- a/drivers/pci/hotplug/pciehp_core.c
4395 ++++ b/drivers/pci/hotplug/pciehp_core.c
4396 +@@ -283,7 +283,7 @@ static int pciehp_resume(struct pcie_device *dev)
4397 + ctrl = get_service_data(dev);
4398 +
4399 + /* reinitialize the chipset's event detection logic */
4400 +- pcie_enable_notification(ctrl);
4401 ++ pcie_reenable_notification(ctrl);
4402 +
4403 + slot = ctrl->slot;
4404 +
4405 +diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
4406 +index 18a42f8f5dc5..98ea75aa32c7 100644
4407 +--- a/drivers/pci/hotplug/pciehp_hpc.c
4408 ++++ b/drivers/pci/hotplug/pciehp_hpc.c
4409 +@@ -659,7 +659,7 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
4410 + return handled;
4411 + }
4412 +
4413 +-void pcie_enable_notification(struct controller *ctrl)
4414 ++static void pcie_enable_notification(struct controller *ctrl)
4415 + {
4416 + u16 cmd, mask;
4417 +
4418 +@@ -697,6 +697,17 @@ void pcie_enable_notification(struct controller *ctrl)
4419 + pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, cmd);
4420 + }
4421 +
4422 ++void pcie_reenable_notification(struct controller *ctrl)
4423 ++{
4424 ++ /*
4425 ++ * Clear both Presence and Data Link Layer Changed to make sure
4426 ++ * those events still fire after we have re-enabled them.
4427 ++ */
4428 ++ pcie_capability_write_word(ctrl->pcie->port, PCI_EXP_SLTSTA,
4429 ++ PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC);
4430 ++ pcie_enable_notification(ctrl);
4431 ++}
4432 ++
4433 + static void pcie_disable_notification(struct controller *ctrl)
4434 + {
4435 + u16 mask;
4436 +diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
4437 +index b9a131137e64..c816b0683a82 100644
4438 +--- a/drivers/pci/pci-driver.c
4439 ++++ b/drivers/pci/pci-driver.c
4440 +@@ -753,10 +753,11 @@ static int pci_pm_suspend(struct device *dev)
4441 + * better to resume the device from runtime suspend here.
4442 + */
4443 + if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND) ||
4444 +- !pci_dev_keep_suspended(pci_dev))
4445 ++ !pci_dev_keep_suspended(pci_dev)) {
4446 + pm_runtime_resume(dev);
4447 ++ pci_dev->state_saved = false;
4448 ++ }
4449 +
4450 +- pci_dev->state_saved = false;
4451 + if (pm->suspend) {
4452 + pci_power_t prev = pci_dev->current_state;
4453 + int error;
4454 +diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
4455 +index ac91b6fd0bcd..73ac02796ba9 100644
4456 +--- a/drivers/pci/probe.c
4457 ++++ b/drivers/pci/probe.c
4458 +@@ -2638,7 +2638,14 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,
4459 + for_each_pci_bridge(dev, bus) {
4460 + cmax = max;
4461 + max = pci_scan_bridge_extend(bus, dev, max, 0, 0);
4462 +- used_buses += cmax - max;
4463 ++
4464 ++ /*
4465 ++ * Reserve one bus for each bridge now to avoid extending
4466 ++ * hotplug bridges too much during the second scan below.
4467 ++ */
4468 ++ used_buses++;
4469 ++ if (cmax - max > 1)
4470 ++ used_buses += cmax - max - 1;
4471 + }
4472 +
4473 + /* Scan bridges that need to be reconfigured */
4474 +@@ -2661,12 +2668,14 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus,
4475 + * bridges if any.
4476 + */
4477 + buses = available_buses / hotplug_bridges;
4478 +- buses = min(buses, available_buses - used_buses);
4479 ++ buses = min(buses, available_buses - used_buses + 1);
4480 + }
4481 +
4482 + cmax = max;
4483 + max = pci_scan_bridge_extend(bus, dev, cmax, buses, 1);
4484 +- used_buses += max - cmax;
4485 ++ /* One bus is already accounted so don't add it again */
4486 ++ if (max - cmax > 1)
4487 ++ used_buses += max - cmax - 1;
4488 + }
4489 +
4490 + /*
4491 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
4492 +index 2990ad1e7c99..785a29ba4f51 100644
4493 +--- a/drivers/pci/quirks.c
4494 ++++ b/drivers/pci/quirks.c
4495 +@@ -4230,11 +4230,29 @@ static int pci_quirk_qcom_rp_acs(struct pci_dev *dev, u16 acs_flags)
4496 + * 0xa290-0xa29f PCI Express Root port #{0-16}
4497 + * 0xa2e7-0xa2ee PCI Express Root port #{17-24}
4498 + *
4499 ++ * Mobile chipsets are also affected, 7th & 8th Generation
4500 ++ * Specification update confirms ACS errata 22, status no fix: (7th Generation
4501 ++ * Intel Processor Family I/O for U/Y Platforms and 8th Generation Intel
4502 ++ * Processor Family I/O for U Quad Core Platforms Specification Update,
4503 ++ * August 2017, Revision 002, Document#: 334660-002)[6]
4504 ++ * Device IDs from I/O datasheet: (7th Generation Intel Processor Family I/O
4505 ++ * for U/Y Platforms and 8th Generation Intel ® Processor Family I/O for U
4506 ++ * Quad Core Platforms, Vol 1 of 2, August 2017, Document#: 334658-003)[7]
4507 ++ *
4508 ++ * 0x9d10-0x9d1b PCI Express Root port #{1-12}
4509 ++ *
4510 ++ * The 300 series chipset suffers from the same bug so include those root
4511 ++ * ports here as well.
4512 ++ *
4513 ++ * 0xa32c-0xa343 PCI Express Root port #{0-24}
4514 ++ *
4515 + * [1] http://www.intel.com/content/www/us/en/chipsets/100-series-chipset-datasheet-vol-2.html
4516 + * [2] http://www.intel.com/content/www/us/en/chipsets/100-series-chipset-datasheet-vol-1.html
4517 + * [3] http://www.intel.com/content/www/us/en/chipsets/100-series-chipset-spec-update.html
4518 + * [4] http://www.intel.com/content/www/us/en/chipsets/200-series-chipset-pch-spec-update.html
4519 + * [5] http://www.intel.com/content/www/us/en/chipsets/200-series-chipset-pch-datasheet-vol-1.html
4520 ++ * [6] https://www.intel.com/content/www/us/en/processors/core/7th-gen-core-family-mobile-u-y-processor-lines-i-o-spec-update.html
4521 ++ * [7] https://www.intel.com/content/www/us/en/processors/core/7th-gen-core-family-mobile-u-y-processor-lines-i-o-datasheet-vol-1.html
4522 + */
4523 + static bool pci_quirk_intel_spt_pch_acs_match(struct pci_dev *dev)
4524 + {
4525 +@@ -4244,6 +4262,8 @@ static bool pci_quirk_intel_spt_pch_acs_match(struct pci_dev *dev)
4526 + switch (dev->device) {
4527 + case 0xa110 ... 0xa11f: case 0xa167 ... 0xa16a: /* Sunrise Point */
4528 + case 0xa290 ... 0xa29f: case 0xa2e7 ... 0xa2ee: /* Union Point */
4529 ++ case 0x9d10 ... 0x9d1b: /* 7th & 8th Gen Mobile */
4530 ++ case 0xa32c ... 0xa343: /* 300 series */
4531 + return true;
4532 + }
4533 +
4534 +diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
4535 +index b601039d6c69..c4aa411f5935 100644
4536 +--- a/drivers/pinctrl/devicetree.c
4537 ++++ b/drivers/pinctrl/devicetree.c
4538 +@@ -101,10 +101,11 @@ struct pinctrl_dev *of_pinctrl_get(struct device_node *np)
4539 + }
4540 +
4541 + static int dt_to_map_one_config(struct pinctrl *p,
4542 +- struct pinctrl_dev *pctldev,
4543 ++ struct pinctrl_dev *hog_pctldev,
4544 + const char *statename,
4545 + struct device_node *np_config)
4546 + {
4547 ++ struct pinctrl_dev *pctldev = NULL;
4548 + struct device_node *np_pctldev;
4549 + const struct pinctrl_ops *ops;
4550 + int ret;
4551 +@@ -123,8 +124,10 @@ static int dt_to_map_one_config(struct pinctrl *p,
4552 + return -EPROBE_DEFER;
4553 + }
4554 + /* If we're creating a hog we can use the passed pctldev */
4555 +- if (pctldev && (np_pctldev == p->dev->of_node))
4556 ++ if (hog_pctldev && (np_pctldev == p->dev->of_node)) {
4557 ++ pctldev = hog_pctldev;
4558 + break;
4559 ++ }
4560 + pctldev = get_pinctrl_dev_from_of_node(np_pctldev);
4561 + if (pctldev)
4562 + break;
4563 +diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
4564 +index 5b63248c8209..7bef929bd7fe 100644
4565 +--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
4566 ++++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
4567 +@@ -679,12 +679,13 @@ static void armada_37xx_irq_handler(struct irq_desc *desc)
4568 + writel(1 << hwirq,
4569 + info->base +
4570 + IRQ_STATUS + 4 * i);
4571 +- continue;
4572 ++ goto update_status;
4573 + }
4574 + }
4575 +
4576 + generic_handle_irq(virq);
4577 +
4578 ++update_status:
4579 + /* Update status in case a new IRQ appears */
4580 + spin_lock_irqsave(&info->irq_lock, flags);
4581 + status = readl_relaxed(info->base +
4582 +diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
4583 +index 90c274490181..4f4ae66a0ee3 100644
4584 +--- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
4585 ++++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
4586 +@@ -105,12 +105,12 @@ static const struct samsung_pin_bank_data s5pv210_pin_bank[] __initconst = {
4587 + EXYNOS_PIN_BANK_EINTG(7, 0x1c0, "gpg1", 0x38),
4588 + EXYNOS_PIN_BANK_EINTG(7, 0x1e0, "gpg2", 0x3c),
4589 + EXYNOS_PIN_BANK_EINTG(7, 0x200, "gpg3", 0x40),
4590 +- EXYNOS_PIN_BANK_EINTN(7, 0x220, "gpi"),
4591 + EXYNOS_PIN_BANK_EINTG(8, 0x240, "gpj0", 0x44),
4592 + EXYNOS_PIN_BANK_EINTG(6, 0x260, "gpj1", 0x48),
4593 + EXYNOS_PIN_BANK_EINTG(8, 0x280, "gpj2", 0x4c),
4594 + EXYNOS_PIN_BANK_EINTG(8, 0x2a0, "gpj3", 0x50),
4595 + EXYNOS_PIN_BANK_EINTG(5, 0x2c0, "gpj4", 0x54),
4596 ++ EXYNOS_PIN_BANK_EINTN(7, 0x220, "gpi"),
4597 + EXYNOS_PIN_BANK_EINTN(8, 0x2e0, "mp01"),
4598 + EXYNOS_PIN_BANK_EINTN(4, 0x300, "mp02"),
4599 + EXYNOS_PIN_BANK_EINTN(8, 0x320, "mp03"),
4600 +@@ -630,7 +630,6 @@ static const struct samsung_pin_bank_data exynos5410_pin_banks0[] __initconst =
4601 + EXYNOS_PIN_BANK_EINTG(4, 0x100, "gpc3", 0x20),
4602 + EXYNOS_PIN_BANK_EINTG(7, 0x120, "gpc1", 0x24),
4603 + EXYNOS_PIN_BANK_EINTG(7, 0x140, "gpc2", 0x28),
4604 +- EXYNOS_PIN_BANK_EINTN(2, 0x160, "gpm5"),
4605 + EXYNOS_PIN_BANK_EINTG(8, 0x180, "gpd1", 0x2c),
4606 + EXYNOS_PIN_BANK_EINTG(8, 0x1A0, "gpe0", 0x30),
4607 + EXYNOS_PIN_BANK_EINTG(2, 0x1C0, "gpe1", 0x34),
4608 +@@ -641,6 +640,7 @@ static const struct samsung_pin_bank_data exynos5410_pin_banks0[] __initconst =
4609 + EXYNOS_PIN_BANK_EINTG(2, 0x260, "gpg2", 0x48),
4610 + EXYNOS_PIN_BANK_EINTG(4, 0x280, "gph0", 0x4c),
4611 + EXYNOS_PIN_BANK_EINTG(8, 0x2A0, "gph1", 0x50),
4612 ++ EXYNOS_PIN_BANK_EINTN(2, 0x160, "gpm5"),
4613 + EXYNOS_PIN_BANK_EINTN(8, 0x2C0, "gpm7"),
4614 + EXYNOS_PIN_BANK_EINTN(6, 0x2E0, "gpy0"),
4615 + EXYNOS_PIN_BANK_EINTN(4, 0x300, "gpy1"),
4616 +diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
4617 +index 3682e1539251..31c8b8c49e45 100644
4618 +--- a/drivers/platform/chrome/cros_ec_lpc.c
4619 ++++ b/drivers/platform/chrome/cros_ec_lpc.c
4620 +@@ -435,7 +435,13 @@ static int __init cros_ec_lpc_init(void)
4621 + int ret;
4622 + acpi_status status;
4623 +
4624 +- if (!dmi_check_system(cros_ec_lpc_dmi_table)) {
4625 ++ status = acpi_get_devices(ACPI_DRV_NAME, cros_ec_lpc_parse_device,
4626 ++ &cros_ec_lpc_acpi_device_found, NULL);
4627 ++ if (ACPI_FAILURE(status))
4628 ++ pr_warn(DRV_NAME ": Looking for %s failed\n", ACPI_DRV_NAME);
4629 ++
4630 ++ if (!cros_ec_lpc_acpi_device_found &&
4631 ++ !dmi_check_system(cros_ec_lpc_dmi_table)) {
4632 + pr_err(DRV_NAME ": unsupported system.\n");
4633 + return -ENODEV;
4634 + }
4635 +@@ -450,11 +456,6 @@ static int __init cros_ec_lpc_init(void)
4636 + return ret;
4637 + }
4638 +
4639 +- status = acpi_get_devices(ACPI_DRV_NAME, cros_ec_lpc_parse_device,
4640 +- &cros_ec_lpc_acpi_device_found, NULL);
4641 +- if (ACPI_FAILURE(status))
4642 +- pr_warn(DRV_NAME ": Looking for %s failed\n", ACPI_DRV_NAME);
4643 +-
4644 + if (!cros_ec_lpc_acpi_device_found) {
4645 + /* Register the device, and it'll get hooked up automatically */
4646 + ret = platform_device_register(&cros_ec_lpc_device);
4647 +diff --git a/drivers/pwm/pwm-lpss-platform.c b/drivers/pwm/pwm-lpss-platform.c
4648 +index 5d6ed1507d29..5561b9e190f8 100644
4649 +--- a/drivers/pwm/pwm-lpss-platform.c
4650 ++++ b/drivers/pwm/pwm-lpss-platform.c
4651 +@@ -74,6 +74,10 @@ static int pwm_lpss_remove_platform(struct platform_device *pdev)
4652 + return pwm_lpss_remove(lpwm);
4653 + }
4654 +
4655 ++static SIMPLE_DEV_PM_OPS(pwm_lpss_platform_pm_ops,
4656 ++ pwm_lpss_suspend,
4657 ++ pwm_lpss_resume);
4658 ++
4659 + static const struct acpi_device_id pwm_lpss_acpi_match[] = {
4660 + { "80860F09", (unsigned long)&pwm_lpss_byt_info },
4661 + { "80862288", (unsigned long)&pwm_lpss_bsw_info },
4662 +@@ -86,6 +90,7 @@ static struct platform_driver pwm_lpss_driver_platform = {
4663 + .driver = {
4664 + .name = "pwm-lpss",
4665 + .acpi_match_table = pwm_lpss_acpi_match,
4666 ++ .pm = &pwm_lpss_platform_pm_ops,
4667 + },
4668 + .probe = pwm_lpss_probe_platform,
4669 + .remove = pwm_lpss_remove_platform,
4670 +diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c
4671 +index 8db0d40ccacd..4721a264bac2 100644
4672 +--- a/drivers/pwm/pwm-lpss.c
4673 ++++ b/drivers/pwm/pwm-lpss.c
4674 +@@ -32,10 +32,13 @@
4675 + /* Size of each PWM register space if multiple */
4676 + #define PWM_SIZE 0x400
4677 +
4678 ++#define MAX_PWMS 4
4679 ++
4680 + struct pwm_lpss_chip {
4681 + struct pwm_chip chip;
4682 + void __iomem *regs;
4683 + const struct pwm_lpss_boardinfo *info;
4684 ++ u32 saved_ctrl[MAX_PWMS];
4685 + };
4686 +
4687 + static inline struct pwm_lpss_chip *to_lpwm(struct pwm_chip *chip)
4688 +@@ -177,6 +180,9 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
4689 + unsigned long c;
4690 + int ret;
4691 +
4692 ++ if (WARN_ON(info->npwm > MAX_PWMS))
4693 ++ return ERR_PTR(-ENODEV);
4694 ++
4695 + lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL);
4696 + if (!lpwm)
4697 + return ERR_PTR(-ENOMEM);
4698 +@@ -212,6 +218,30 @@ int pwm_lpss_remove(struct pwm_lpss_chip *lpwm)
4699 + }
4700 + EXPORT_SYMBOL_GPL(pwm_lpss_remove);
4701 +
4702 ++int pwm_lpss_suspend(struct device *dev)
4703 ++{
4704 ++ struct pwm_lpss_chip *lpwm = dev_get_drvdata(dev);
4705 ++ int i;
4706 ++
4707 ++ for (i = 0; i < lpwm->info->npwm; i++)
4708 ++ lpwm->saved_ctrl[i] = readl(lpwm->regs + i * PWM_SIZE + PWM);
4709 ++
4710 ++ return 0;
4711 ++}
4712 ++EXPORT_SYMBOL_GPL(pwm_lpss_suspend);
4713 ++
4714 ++int pwm_lpss_resume(struct device *dev)
4715 ++{
4716 ++ struct pwm_lpss_chip *lpwm = dev_get_drvdata(dev);
4717 ++ int i;
4718 ++
4719 ++ for (i = 0; i < lpwm->info->npwm; i++)
4720 ++ writel(lpwm->saved_ctrl[i], lpwm->regs + i * PWM_SIZE + PWM);
4721 ++
4722 ++ return 0;
4723 ++}
4724 ++EXPORT_SYMBOL_GPL(pwm_lpss_resume);
4725 ++
4726 + MODULE_DESCRIPTION("PWM driver for Intel LPSS");
4727 + MODULE_AUTHOR("Mika Westerberg <mika.westerberg@×××××××××××.com>");
4728 + MODULE_LICENSE("GPL v2");
4729 +diff --git a/drivers/pwm/pwm-lpss.h b/drivers/pwm/pwm-lpss.h
4730 +index 98306bb02cfe..7a4238ad1fcb 100644
4731 +--- a/drivers/pwm/pwm-lpss.h
4732 ++++ b/drivers/pwm/pwm-lpss.h
4733 +@@ -28,5 +28,7 @@ struct pwm_lpss_boardinfo {
4734 + struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
4735 + const struct pwm_lpss_boardinfo *info);
4736 + int pwm_lpss_remove(struct pwm_lpss_chip *lpwm);
4737 ++int pwm_lpss_suspend(struct device *dev);
4738 ++int pwm_lpss_resume(struct device *dev);
4739 +
4740 + #endif /* __PWM_LPSS_H */
4741 +diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c
4742 +index cbbafdcaaecb..56b14c27e275 100644
4743 +--- a/drivers/remoteproc/qcom_q6v5_pil.c
4744 ++++ b/drivers/remoteproc/qcom_q6v5_pil.c
4745 +@@ -761,13 +761,11 @@ static int q6v5_start(struct rproc *rproc)
4746 + }
4747 +
4748 + /* Assign MBA image access in DDR to q6 */
4749 +- xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true,
4750 +- qproc->mba_phys,
4751 +- qproc->mba_size);
4752 +- if (xfermemop_ret) {
4753 ++ ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true,
4754 ++ qproc->mba_phys, qproc->mba_size);
4755 ++ if (ret) {
4756 + dev_err(qproc->dev,
4757 +- "assigning Q6 access to mba memory failed: %d\n",
4758 +- xfermemop_ret);
4759 ++ "assigning Q6 access to mba memory failed: %d\n", ret);
4760 + goto disable_active_clks;
4761 + }
4762 +
4763 +diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
4764 +index 5ce9bf7b897d..f63adcd95eb0 100644
4765 +--- a/drivers/rpmsg/qcom_smd.c
4766 ++++ b/drivers/rpmsg/qcom_smd.c
4767 +@@ -1100,12 +1100,12 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
4768 + void *info;
4769 + int ret;
4770 +
4771 +- channel = devm_kzalloc(&edge->dev, sizeof(*channel), GFP_KERNEL);
4772 ++ channel = kzalloc(sizeof(*channel), GFP_KERNEL);
4773 + if (!channel)
4774 + return ERR_PTR(-ENOMEM);
4775 +
4776 + channel->edge = edge;
4777 +- channel->name = devm_kstrdup(&edge->dev, name, GFP_KERNEL);
4778 ++ channel->name = kstrdup(name, GFP_KERNEL);
4779 + if (!channel->name)
4780 + return ERR_PTR(-ENOMEM);
4781 +
4782 +@@ -1156,8 +1156,8 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
4783 + return channel;
4784 +
4785 + free_name_and_channel:
4786 +- devm_kfree(&edge->dev, channel->name);
4787 +- devm_kfree(&edge->dev, channel);
4788 ++ kfree(channel->name);
4789 ++ kfree(channel);
4790 +
4791 + return ERR_PTR(ret);
4792 + }
4793 +@@ -1378,13 +1378,13 @@ static int qcom_smd_parse_edge(struct device *dev,
4794 + */
4795 + static void qcom_smd_edge_release(struct device *dev)
4796 + {
4797 +- struct qcom_smd_channel *channel;
4798 ++ struct qcom_smd_channel *channel, *tmp;
4799 + struct qcom_smd_edge *edge = to_smd_edge(dev);
4800 +
4801 +- list_for_each_entry(channel, &edge->channels, list) {
4802 +- SET_RX_CHANNEL_INFO(channel, state, SMD_CHANNEL_CLOSED);
4803 +- SET_RX_CHANNEL_INFO(channel, head, 0);
4804 +- SET_RX_CHANNEL_INFO(channel, tail, 0);
4805 ++ list_for_each_entry_safe(channel, tmp, &edge->channels, list) {
4806 ++ list_del(&channel->list);
4807 ++ kfree(channel->name);
4808 ++ kfree(channel);
4809 + }
4810 +
4811 + kfree(edge);
4812 +diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
4813 +index 2e6fb275acc8..2cd5a7b1a2e3 100644
4814 +--- a/drivers/rtc/rtc-sun6i.c
4815 ++++ b/drivers/rtc/rtc-sun6i.c
4816 +@@ -74,7 +74,7 @@
4817 + #define SUN6I_ALARM_CONFIG_WAKEUP BIT(0)
4818 +
4819 + #define SUN6I_LOSC_OUT_GATING 0x0060
4820 +-#define SUN6I_LOSC_OUT_GATING_EN BIT(0)
4821 ++#define SUN6I_LOSC_OUT_GATING_EN_OFFSET 0
4822 +
4823 + /*
4824 + * Get date values
4825 +@@ -255,7 +255,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
4826 + &clkout_name);
4827 + rtc->ext_losc = clk_register_gate(NULL, clkout_name, rtc->hw.init->name,
4828 + 0, rtc->base + SUN6I_LOSC_OUT_GATING,
4829 +- SUN6I_LOSC_OUT_GATING_EN, 0,
4830 ++ SUN6I_LOSC_OUT_GATING_EN_OFFSET, 0,
4831 + &rtc->lock);
4832 + if (IS_ERR(rtc->ext_losc)) {
4833 + pr_crit("Couldn't register the LOSC external gate\n");
4834 +diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
4835 +index 18c4f933e8b9..b415ba42ca73 100644
4836 +--- a/drivers/s390/scsi/zfcp_dbf.c
4837 ++++ b/drivers/s390/scsi/zfcp_dbf.c
4838 +@@ -664,6 +664,46 @@ void zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *sc,
4839 + spin_unlock_irqrestore(&dbf->scsi_lock, flags);
4840 + }
4841 +
4842 ++/**
4843 ++ * zfcp_dbf_scsi_eh() - Trace event for special cases of scsi_eh callbacks.
4844 ++ * @tag: Identifier for event.
4845 ++ * @adapter: Pointer to zfcp adapter as context for this event.
4846 ++ * @scsi_id: SCSI ID/target to indicate scope of task management function (TMF).
4847 ++ * @ret: Return value of calling function.
4848 ++ *
4849 ++ * This SCSI trace variant does not depend on any of:
4850 ++ * scsi_cmnd, zfcp_fsf_req, scsi_device.
4851 ++ */
4852 ++void zfcp_dbf_scsi_eh(char *tag, struct zfcp_adapter *adapter,
4853 ++ unsigned int scsi_id, int ret)
4854 ++{
4855 ++ struct zfcp_dbf *dbf = adapter->dbf;
4856 ++ struct zfcp_dbf_scsi *rec = &dbf->scsi_buf;
4857 ++ unsigned long flags;
4858 ++ static int const level = 1;
4859 ++
4860 ++ if (unlikely(!debug_level_enabled(adapter->dbf->scsi, level)))
4861 ++ return;
4862 ++
4863 ++ spin_lock_irqsave(&dbf->scsi_lock, flags);
4864 ++ memset(rec, 0, sizeof(*rec));
4865 ++
4866 ++ memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
4867 ++ rec->id = ZFCP_DBF_SCSI_CMND;
4868 ++ rec->scsi_result = ret; /* re-use field, int is 4 bytes and fits */
4869 ++ rec->scsi_retries = ~0;
4870 ++ rec->scsi_allowed = ~0;
4871 ++ rec->fcp_rsp_info = ~0;
4872 ++ rec->scsi_id = scsi_id;
4873 ++ rec->scsi_lun = (u32)ZFCP_DBF_INVALID_LUN;
4874 ++ rec->scsi_lun_64_hi = (u32)(ZFCP_DBF_INVALID_LUN >> 32);
4875 ++ rec->host_scribble = ~0;
4876 ++ memset(rec->scsi_opcode, 0xff, ZFCP_DBF_SCSI_OPCODE);
4877 ++
4878 ++ debug_event(dbf->scsi, level, rec, sizeof(*rec));
4879 ++ spin_unlock_irqrestore(&dbf->scsi_lock, flags);
4880 ++}
4881 ++
4882 + static debug_info_t *zfcp_dbf_reg(const char *name, int size, int rec_size)
4883 + {
4884 + struct debug_info *d;
4885 +diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
4886 +index 1d91a32db08e..69dfb328dba4 100644
4887 +--- a/drivers/s390/scsi/zfcp_erp.c
4888 ++++ b/drivers/s390/scsi/zfcp_erp.c
4889 +@@ -35,11 +35,28 @@ enum zfcp_erp_steps {
4890 + ZFCP_ERP_STEP_LUN_OPENING = 0x2000,
4891 + };
4892 +
4893 ++/**
4894 ++ * enum zfcp_erp_act_type - Type of ERP action object.
4895 ++ * @ZFCP_ERP_ACTION_REOPEN_LUN: LUN recovery.
4896 ++ * @ZFCP_ERP_ACTION_REOPEN_PORT: Port recovery.
4897 ++ * @ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: Forced port recovery.
4898 ++ * @ZFCP_ERP_ACTION_REOPEN_ADAPTER: Adapter recovery.
4899 ++ * @ZFCP_ERP_ACTION_NONE: Eyecatcher pseudo flag to bitwise or-combine with
4900 ++ * either of the first four enum values.
4901 ++ * Used to indicate that an ERP action could not be
4902 ++ * set up despite a detected need for some recovery.
4903 ++ * @ZFCP_ERP_ACTION_FAILED: Eyecatcher pseudo flag to bitwise or-combine with
4904 ++ * either of the first four enum values.
4905 ++ * Used to indicate that ERP not needed because
4906 ++ * the object has ZFCP_STATUS_COMMON_ERP_FAILED.
4907 ++ */
4908 + enum zfcp_erp_act_type {
4909 + ZFCP_ERP_ACTION_REOPEN_LUN = 1,
4910 + ZFCP_ERP_ACTION_REOPEN_PORT = 2,
4911 + ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3,
4912 + ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4,
4913 ++ ZFCP_ERP_ACTION_NONE = 0xc0,
4914 ++ ZFCP_ERP_ACTION_FAILED = 0xe0,
4915 + };
4916 +
4917 + enum zfcp_erp_act_state {
4918 +@@ -126,6 +143,49 @@ static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)
4919 + }
4920 + }
4921 +
4922 ++static int zfcp_erp_handle_failed(int want, struct zfcp_adapter *adapter,
4923 ++ struct zfcp_port *port,
4924 ++ struct scsi_device *sdev)
4925 ++{
4926 ++ int need = want;
4927 ++ struct zfcp_scsi_dev *zsdev;
4928 ++
4929 ++ switch (want) {
4930 ++ case ZFCP_ERP_ACTION_REOPEN_LUN:
4931 ++ zsdev = sdev_to_zfcp(sdev);
4932 ++ if (atomic_read(&zsdev->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
4933 ++ need = 0;
4934 ++ break;
4935 ++ case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
4936 ++ if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
4937 ++ need = 0;
4938 ++ break;
4939 ++ case ZFCP_ERP_ACTION_REOPEN_PORT:
4940 ++ if (atomic_read(&port->status) &
4941 ++ ZFCP_STATUS_COMMON_ERP_FAILED) {
4942 ++ need = 0;
4943 ++ /* ensure propagation of failed status to new devices */
4944 ++ zfcp_erp_set_port_status(
4945 ++ port, ZFCP_STATUS_COMMON_ERP_FAILED);
4946 ++ }
4947 ++ break;
4948 ++ case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
4949 ++ if (atomic_read(&adapter->status) &
4950 ++ ZFCP_STATUS_COMMON_ERP_FAILED) {
4951 ++ need = 0;
4952 ++ /* ensure propagation of failed status to new devices */
4953 ++ zfcp_erp_set_adapter_status(
4954 ++ adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
4955 ++ }
4956 ++ break;
4957 ++ default:
4958 ++ need = 0;
4959 ++ break;
4960 ++ }
4961 ++
4962 ++ return need;
4963 ++}
4964 ++
4965 + static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter,
4966 + struct zfcp_port *port,
4967 + struct scsi_device *sdev)
4968 +@@ -249,16 +309,27 @@ static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter,
4969 + int retval = 1, need;
4970 + struct zfcp_erp_action *act;
4971 +
4972 +- if (!adapter->erp_thread)
4973 +- return -EIO;
4974 ++ need = zfcp_erp_handle_failed(want, adapter, port, sdev);
4975 ++ if (!need) {
4976 ++ need = ZFCP_ERP_ACTION_FAILED; /* marker for trace */
4977 ++ goto out;
4978 ++ }
4979 ++
4980 ++ if (!adapter->erp_thread) {
4981 ++ need = ZFCP_ERP_ACTION_NONE; /* marker for trace */
4982 ++ retval = -EIO;
4983 ++ goto out;
4984 ++ }
4985 +
4986 + need = zfcp_erp_required_act(want, adapter, port, sdev);
4987 + if (!need)
4988 + goto out;
4989 +
4990 + act = zfcp_erp_setup_act(need, act_status, adapter, port, sdev);
4991 +- if (!act)
4992 ++ if (!act) {
4993 ++ need |= ZFCP_ERP_ACTION_NONE; /* marker for trace */
4994 + goto out;
4995 ++ }
4996 + atomic_or(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status);
4997 + ++adapter->erp_total_count;
4998 + list_add_tail(&act->list, &adapter->erp_ready_head);
4999 +@@ -269,18 +340,32 @@ static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter,
5000 + return retval;
5001 + }
5002 +
5003 ++void zfcp_erp_port_forced_no_port_dbf(char *id, struct zfcp_adapter *adapter,
5004 ++ u64 port_name, u32 port_id)
5005 ++{
5006 ++ unsigned long flags;
5007 ++ static /* don't waste stack */ struct zfcp_port tmpport;
5008 ++
5009 ++ write_lock_irqsave(&adapter->erp_lock, flags);
5010 ++ /* Stand-in zfcp port with fields just good enough for
5011 ++ * zfcp_dbf_rec_trig() and zfcp_dbf_set_common().
5012 ++ * Under lock because tmpport is static.
5013 ++ */
5014 ++ atomic_set(&tmpport.status, -1); /* unknown */
5015 ++ tmpport.wwpn = port_name;
5016 ++ tmpport.d_id = port_id;
5017 ++ zfcp_dbf_rec_trig(id, adapter, &tmpport, NULL,
5018 ++ ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
5019 ++ ZFCP_ERP_ACTION_NONE);
5020 ++ write_unlock_irqrestore(&adapter->erp_lock, flags);
5021 ++}
5022 ++
5023 + static int _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter,
5024 + int clear_mask, char *id)
5025 + {
5026 + zfcp_erp_adapter_block(adapter, clear_mask);
5027 + zfcp_scsi_schedule_rports_block(adapter);
5028 +
5029 +- /* ensure propagation of failed status to new devices */
5030 +- if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
5031 +- zfcp_erp_set_adapter_status(adapter,
5032 +- ZFCP_STATUS_COMMON_ERP_FAILED);
5033 +- return -EIO;
5034 +- }
5035 + return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER,
5036 + adapter, NULL, NULL, id, 0);
5037 + }
5038 +@@ -299,12 +384,8 @@ void zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear, char *id)
5039 + zfcp_scsi_schedule_rports_block(adapter);
5040 +
5041 + write_lock_irqsave(&adapter->erp_lock, flags);
5042 +- if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
5043 +- zfcp_erp_set_adapter_status(adapter,
5044 +- ZFCP_STATUS_COMMON_ERP_FAILED);
5045 +- else
5046 +- zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, adapter,
5047 +- NULL, NULL, id, 0);
5048 ++ zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, adapter,
5049 ++ NULL, NULL, id, 0);
5050 + write_unlock_irqrestore(&adapter->erp_lock, flags);
5051 + }
5052 +
5053 +@@ -345,9 +426,6 @@ static void _zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear,
5054 + zfcp_erp_port_block(port, clear);
5055 + zfcp_scsi_schedule_rport_block(port);
5056 +
5057 +- if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
5058 +- return;
5059 +-
5060 + zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
5061 + port->adapter, port, NULL, id, 0);
5062 + }
5063 +@@ -373,12 +451,6 @@ static int _zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *id)
5064 + zfcp_erp_port_block(port, clear);
5065 + zfcp_scsi_schedule_rport_block(port);
5066 +
5067 +- if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
5068 +- /* ensure propagation of failed status to new devices */
5069 +- zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_ERP_FAILED);
5070 +- return -EIO;
5071 +- }
5072 +-
5073 + return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT,
5074 + port->adapter, port, NULL, id, 0);
5075 + }
5076 +@@ -418,9 +490,6 @@ static void _zfcp_erp_lun_reopen(struct scsi_device *sdev, int clear, char *id,
5077 +
5078 + zfcp_erp_lun_block(sdev, clear);
5079 +
5080 +- if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
5081 +- return;
5082 +-
5083 + zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_LUN, adapter,
5084 + zfcp_sdev->port, sdev, id, act_status);
5085 + }
5086 +diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
5087 +index e5eed8aac0ce..65d16747c301 100644
5088 +--- a/drivers/s390/scsi/zfcp_ext.h
5089 ++++ b/drivers/s390/scsi/zfcp_ext.h
5090 +@@ -52,10 +52,15 @@ extern void zfcp_dbf_san_res(char *, struct zfcp_fsf_req *);
5091 + extern void zfcp_dbf_san_in_els(char *, struct zfcp_fsf_req *);
5092 + extern void zfcp_dbf_scsi(char *, int, struct scsi_cmnd *,
5093 + struct zfcp_fsf_req *);
5094 ++extern void zfcp_dbf_scsi_eh(char *tag, struct zfcp_adapter *adapter,
5095 ++ unsigned int scsi_id, int ret);
5096 +
5097 + /* zfcp_erp.c */
5098 + extern void zfcp_erp_set_adapter_status(struct zfcp_adapter *, u32);
5099 + extern void zfcp_erp_clear_adapter_status(struct zfcp_adapter *, u32);
5100 ++extern void zfcp_erp_port_forced_no_port_dbf(char *id,
5101 ++ struct zfcp_adapter *adapter,
5102 ++ u64 port_name, u32 port_id);
5103 + extern void zfcp_erp_adapter_reopen(struct zfcp_adapter *, int, char *);
5104 + extern void zfcp_erp_adapter_shutdown(struct zfcp_adapter *, int, char *);
5105 + extern void zfcp_erp_set_port_status(struct zfcp_port *, u32);
5106 +diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
5107 +index 22f9562f415c..0b6f51424745 100644
5108 +--- a/drivers/s390/scsi/zfcp_scsi.c
5109 ++++ b/drivers/s390/scsi/zfcp_scsi.c
5110 +@@ -181,6 +181,7 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
5111 + if (abrt_req)
5112 + break;
5113 +
5114 ++ zfcp_dbf_scsi_abort("abrt_wt", scpnt, NULL);
5115 + zfcp_erp_wait(adapter);
5116 + ret = fc_block_scsi_eh(scpnt);
5117 + if (ret) {
5118 +@@ -277,6 +278,7 @@ static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags)
5119 + if (fsf_req)
5120 + break;
5121 +
5122 ++ zfcp_dbf_scsi_devreset("wait", scpnt, tm_flags, NULL);
5123 + zfcp_erp_wait(adapter);
5124 + ret = fc_block_scsi_eh(scpnt);
5125 + if (ret) {
5126 +@@ -323,15 +325,16 @@ static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
5127 + {
5128 + struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device);
5129 + struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
5130 +- int ret;
5131 ++ int ret = SUCCESS, fc_ret;
5132 +
5133 + zfcp_erp_adapter_reopen(adapter, 0, "schrh_1");
5134 + zfcp_erp_wait(adapter);
5135 +- ret = fc_block_scsi_eh(scpnt);
5136 +- if (ret)
5137 +- return ret;
5138 ++ fc_ret = fc_block_scsi_eh(scpnt);
5139 ++ if (fc_ret)
5140 ++ ret = fc_ret;
5141 +
5142 +- return SUCCESS;
5143 ++ zfcp_dbf_scsi_eh("schrh_r", adapter, ~0, ret);
5144 ++ return ret;
5145 + }
5146 +
5147 + struct scsi_transport_template *zfcp_scsi_transport_template;
5148 +@@ -602,6 +605,11 @@ static void zfcp_scsi_terminate_rport_io(struct fc_rport *rport)
5149 + if (port) {
5150 + zfcp_erp_port_forced_reopen(port, 0, "sctrpi1");
5151 + put_device(&port->dev);
5152 ++ } else {
5153 ++ zfcp_erp_port_forced_no_port_dbf(
5154 ++ "sctrpin", adapter,
5155 ++ rport->port_name /* zfcp_scsi_rport_register */,
5156 ++ rport->port_id /* zfcp_scsi_rport_register */);
5157 + }
5158 + }
5159 +
5160 +diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
5161 +index 3a9eca163db8..b92f86acb8bb 100644
5162 +--- a/drivers/scsi/hpsa.c
5163 ++++ b/drivers/scsi/hpsa.c
5164 +@@ -8869,7 +8869,7 @@ static void hpsa_disable_rld_caching(struct ctlr_info *h)
5165 + kfree(options);
5166 + }
5167 +
5168 +-static void hpsa_shutdown(struct pci_dev *pdev)
5169 ++static void __hpsa_shutdown(struct pci_dev *pdev)
5170 + {
5171 + struct ctlr_info *h;
5172 +
5173 +@@ -8884,6 +8884,12 @@ static void hpsa_shutdown(struct pci_dev *pdev)
5174 + hpsa_disable_interrupt_mode(h); /* pci_init 2 */
5175 + }
5176 +
5177 ++static void hpsa_shutdown(struct pci_dev *pdev)
5178 ++{
5179 ++ __hpsa_shutdown(pdev);
5180 ++ pci_disable_device(pdev);
5181 ++}
5182 ++
5183 + static void hpsa_free_device_info(struct ctlr_info *h)
5184 + {
5185 + int i;
5186 +@@ -8927,7 +8933,7 @@ static void hpsa_remove_one(struct pci_dev *pdev)
5187 + scsi_remove_host(h->scsi_host); /* init_one 8 */
5188 + /* includes hpsa_free_irqs - init_one 4 */
5189 + /* includes hpsa_disable_interrupt_mode - pci_init 2 */
5190 +- hpsa_shutdown(pdev);
5191 ++ __hpsa_shutdown(pdev);
5192 +
5193 + hpsa_free_device_info(h); /* scan */
5194 +
5195 +diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
5196 +index 9e914f9c3ffb..05abe5aaab7f 100644
5197 +--- a/drivers/scsi/qla2xxx/qla_gs.c
5198 ++++ b/drivers/scsi/qla2xxx/qla_gs.c
5199 +@@ -3915,7 +3915,6 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp)
5200 + if (memcmp(rp->port_name, fcport->port_name, WWN_SIZE))
5201 + continue;
5202 + fcport->scan_state = QLA_FCPORT_FOUND;
5203 +- fcport->d_id.b24 = rp->id.b24;
5204 + found = true;
5205 + /*
5206 + * If device was not a fabric device before.
5207 +@@ -3923,7 +3922,10 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp)
5208 + if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) {
5209 + qla2x00_clear_loop_id(fcport);
5210 + fcport->flags |= FCF_FABRIC_DEVICE;
5211 ++ } else if (fcport->d_id.b24 != rp->id.b24) {
5212 ++ qlt_schedule_sess_for_deletion(fcport);
5213 + }
5214 ++ fcport->d_id.b24 = rp->id.b24;
5215 + break;
5216 + }
5217 +
5218 +diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
5219 +index 8f55dd44adae..636960ad029a 100644
5220 +--- a/drivers/scsi/qla2xxx/qla_init.c
5221 ++++ b/drivers/scsi/qla2xxx/qla_init.c
5222 +@@ -5037,7 +5037,8 @@ qla2x00_iidma_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
5223 + return;
5224 +
5225 + if (fcport->fp_speed == PORT_SPEED_UNKNOWN ||
5226 +- fcport->fp_speed > ha->link_data_rate)
5227 ++ fcport->fp_speed > ha->link_data_rate ||
5228 ++ !ha->flags.gpsc_supported)
5229 + return;
5230 +
5231 + rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed,
5232 +diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
5233 +index a3dc83f9444d..68560a097ae1 100644
5234 +--- a/drivers/scsi/qla2xxx/qla_isr.c
5235 ++++ b/drivers/scsi/qla2xxx/qla_isr.c
5236 +@@ -2494,8 +2494,12 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
5237 + ox_id = le16_to_cpu(sts24->ox_id);
5238 + par_sense_len = sizeof(sts24->data);
5239 + /* Valid values of the retry delay timer are 0x1-0xffef */
5240 +- if (sts24->retry_delay > 0 && sts24->retry_delay < 0xfff1)
5241 +- retry_delay = sts24->retry_delay;
5242 ++ if (sts24->retry_delay > 0 && sts24->retry_delay < 0xfff1) {
5243 ++ retry_delay = sts24->retry_delay & 0x3fff;
5244 ++ ql_dbg(ql_dbg_io, sp->vha, 0x3033,
5245 ++ "%s: scope=%#x retry_delay=%#x\n", __func__,
5246 ++ sts24->retry_delay >> 14, retry_delay);
5247 ++ }
5248 + } else {
5249 + if (scsi_status & SS_SENSE_LEN_VALID)
5250 + sense_len = le16_to_cpu(sts->req_sense_length);
5251 +diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
5252 +index 025dc2d3f3de..0266c4d07bc9 100644
5253 +--- a/drivers/scsi/qla2xxx/qla_target.c
5254 ++++ b/drivers/scsi/qla2xxx/qla_target.c
5255 +@@ -1230,7 +1230,6 @@ static void qla24xx_chk_fcp_state(struct fc_port *sess)
5256 + void qlt_schedule_sess_for_deletion(struct fc_port *sess)
5257 + {
5258 + struct qla_tgt *tgt = sess->tgt;
5259 +- struct qla_hw_data *ha = sess->vha->hw;
5260 + unsigned long flags;
5261 +
5262 + if (sess->disc_state == DSC_DELETE_PEND)
5263 +@@ -1247,16 +1246,16 @@ void qlt_schedule_sess_for_deletion(struct fc_port *sess)
5264 + return;
5265 + }
5266 +
5267 +- spin_lock_irqsave(&ha->tgt.sess_lock, flags);
5268 + if (sess->deleted == QLA_SESS_DELETED)
5269 + sess->logout_on_delete = 0;
5270 +
5271 ++ spin_lock_irqsave(&sess->vha->work_lock, flags);
5272 + if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
5273 +- spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
5274 ++ spin_unlock_irqrestore(&sess->vha->work_lock, flags);
5275 + return;
5276 + }
5277 + sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
5278 +- spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
5279 ++ spin_unlock_irqrestore(&sess->vha->work_lock, flags);
5280 +
5281 + sess->disc_state = DSC_DELETE_PEND;
5282 +
5283 +diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
5284 +index 656c98e116a9..e086bb63da46 100644
5285 +--- a/drivers/scsi/scsi_debug.c
5286 ++++ b/drivers/scsi/scsi_debug.c
5287 +@@ -5506,9 +5506,9 @@ static void __exit scsi_debug_exit(void)
5288 + int k = sdebug_add_host;
5289 +
5290 + stop_all_queued();
5291 +- free_all_queued();
5292 + for (; k; k--)
5293 + sdebug_remove_adapter();
5294 ++ free_all_queued();
5295 + driver_unregister(&sdebug_driverfs_driver);
5296 + bus_unregister(&pseudo_lld_bus);
5297 + root_device_unregister(pseudo_primary);
5298 +diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c
5299 +index 53efc386b1ad..df7f30a425c6 100644
5300 +--- a/drivers/soc/rockchip/pm_domains.c
5301 ++++ b/drivers/soc/rockchip/pm_domains.c
5302 +@@ -255,7 +255,7 @@ static void rockchip_do_pmu_set_power_domain(struct rockchip_pm_domain *pd,
5303 + return;
5304 + else if (pd->info->pwr_w_mask)
5305 + regmap_write(pmu->regmap, pmu->info->pwr_offset,
5306 +- on ? pd->info->pwr_mask :
5307 ++ on ? pd->info->pwr_w_mask :
5308 + (pd->info->pwr_mask | pd->info->pwr_w_mask));
5309 + else
5310 + regmap_update_bits(pmu->regmap, pmu->info->pwr_offset,
5311 +diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c
5312 +index a4d6a0e2e993..23ad4f9f2143 100644
5313 +--- a/drivers/thermal/broadcom/bcm2835_thermal.c
5314 ++++ b/drivers/thermal/broadcom/bcm2835_thermal.c
5315 +@@ -213,8 +213,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
5316 + rate = clk_get_rate(data->clk);
5317 + if ((rate < 1920000) || (rate > 5000000))
5318 + dev_warn(&pdev->dev,
5319 +- "Clock %pCn running at %pCr Hz is outside of the recommended range: 1.92 to 5MHz\n",
5320 +- data->clk, data->clk);
5321 ++ "Clock %pCn running at %lu Hz is outside of the recommended range: 1.92 to 5MHz\n",
5322 ++ data->clk, rate);
5323 +
5324 + /* register of thermal sensor and get info from DT */
5325 + tz = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
5326 +diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
5327 +index a4f82ec665fe..2051a5309851 100644
5328 +--- a/drivers/tty/serial/sh-sci.c
5329 ++++ b/drivers/tty/serial/sh-sci.c
5330 +@@ -2890,16 +2890,15 @@ static void serial_console_write(struct console *co, const char *s,
5331 + unsigned long flags;
5332 + int locked = 1;
5333 +
5334 +- local_irq_save(flags);
5335 + #if defined(SUPPORT_SYSRQ)
5336 + if (port->sysrq)
5337 + locked = 0;
5338 + else
5339 + #endif
5340 + if (oops_in_progress)
5341 +- locked = spin_trylock(&port->lock);
5342 ++ locked = spin_trylock_irqsave(&port->lock, flags);
5343 + else
5344 +- spin_lock(&port->lock);
5345 ++ spin_lock_irqsave(&port->lock, flags);
5346 +
5347 + /* first save SCSCR then disable interrupts, keep clock source */
5348 + ctrl = serial_port_in(port, SCSCR);
5349 +@@ -2919,8 +2918,7 @@ static void serial_console_write(struct console *co, const char *s,
5350 + serial_port_out(port, SCSCR, ctrl);
5351 +
5352 + if (locked)
5353 +- spin_unlock(&port->lock);
5354 +- local_irq_restore(flags);
5355 ++ spin_unlock_irqrestore(&port->lock, flags);
5356 + }
5357 +
5358 + static int serial_console_setup(struct console *co, char *options)
5359 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
5360 +index aa9968d90a48..e3bf65e213cd 100644
5361 +--- a/drivers/usb/core/hub.c
5362 ++++ b/drivers/usb/core/hub.c
5363 +@@ -4551,7 +4551,9 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
5364 + * reset. But only on the first attempt,
5365 + * lest we get into a time out/reset loop
5366 + */
5367 +- if (r == 0 || (r == -ETIMEDOUT && retries == 0))
5368 ++ if (r == 0 || (r == -ETIMEDOUT &&
5369 ++ retries == 0 &&
5370 ++ udev->speed > USB_SPEED_FULL))
5371 + break;
5372 + }
5373 + udev->descriptor.bMaxPacketSize0 =
5374 +diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c
5375 +index 734a9158946b..e55304d5cf07 100644
5376 +--- a/drivers/video/backlight/as3711_bl.c
5377 ++++ b/drivers/video/backlight/as3711_bl.c
5378 +@@ -262,10 +262,10 @@ static int as3711_bl_register(struct platform_device *pdev,
5379 + static int as3711_backlight_parse_dt(struct device *dev)
5380 + {
5381 + struct as3711_bl_pdata *pdata = dev_get_platdata(dev);
5382 +- struct device_node *bl =
5383 +- of_find_node_by_name(dev->parent->of_node, "backlight"), *fb;
5384 ++ struct device_node *bl, *fb;
5385 + int ret;
5386 +
5387 ++ bl = of_get_child_by_name(dev->parent->of_node, "backlight");
5388 + if (!bl) {
5389 + dev_dbg(dev, "backlight node not found\n");
5390 + return -ENODEV;
5391 +@@ -279,7 +279,7 @@ static int as3711_backlight_parse_dt(struct device *dev)
5392 + if (pdata->su1_max_uA <= 0)
5393 + ret = -EINVAL;
5394 + if (ret < 0)
5395 +- return ret;
5396 ++ goto err_put_bl;
5397 + }
5398 +
5399 + fb = of_parse_phandle(bl, "su2-dev", 0);
5400 +@@ -292,7 +292,7 @@ static int as3711_backlight_parse_dt(struct device *dev)
5401 + if (pdata->su2_max_uA <= 0)
5402 + ret = -EINVAL;
5403 + if (ret < 0)
5404 +- return ret;
5405 ++ goto err_put_bl;
5406 +
5407 + if (of_find_property(bl, "su2-feedback-voltage", NULL)) {
5408 + pdata->su2_feedback = AS3711_SU2_VOLTAGE;
5409 +@@ -314,8 +314,10 @@ static int as3711_backlight_parse_dt(struct device *dev)
5410 + pdata->su2_feedback = AS3711_SU2_CURR_AUTO;
5411 + count++;
5412 + }
5413 +- if (count != 1)
5414 +- return -EINVAL;
5415 ++ if (count != 1) {
5416 ++ ret = -EINVAL;
5417 ++ goto err_put_bl;
5418 ++ }
5419 +
5420 + count = 0;
5421 + if (of_find_property(bl, "su2-fbprot-lx-sd4", NULL)) {
5422 +@@ -334,8 +336,10 @@ static int as3711_backlight_parse_dt(struct device *dev)
5423 + pdata->su2_fbprot = AS3711_SU2_GPIO4;
5424 + count++;
5425 + }
5426 +- if (count != 1)
5427 +- return -EINVAL;
5428 ++ if (count != 1) {
5429 ++ ret = -EINVAL;
5430 ++ goto err_put_bl;
5431 ++ }
5432 +
5433 + count = 0;
5434 + if (of_find_property(bl, "su2-auto-curr1", NULL)) {
5435 +@@ -355,11 +359,20 @@ static int as3711_backlight_parse_dt(struct device *dev)
5436 + * At least one su2-auto-curr* must be specified iff
5437 + * AS3711_SU2_CURR_AUTO is used
5438 + */
5439 +- if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO))
5440 +- return -EINVAL;
5441 ++ if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) {
5442 ++ ret = -EINVAL;
5443 ++ goto err_put_bl;
5444 ++ }
5445 + }
5446 +
5447 ++ of_node_put(bl);
5448 ++
5449 + return 0;
5450 ++
5451 ++err_put_bl:
5452 ++ of_node_put(bl);
5453 ++
5454 ++ return ret;
5455 + }
5456 +
5457 + static int as3711_backlight_probe(struct platform_device *pdev)
5458 +diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
5459 +index 7b738d60ecc2..f3aa6088f1d9 100644
5460 +--- a/drivers/video/backlight/max8925_bl.c
5461 ++++ b/drivers/video/backlight/max8925_bl.c
5462 +@@ -116,7 +116,7 @@ static void max8925_backlight_dt_init(struct platform_device *pdev)
5463 + if (!pdata)
5464 + return;
5465 +
5466 +- np = of_find_node_by_name(nproot, "backlight");
5467 ++ np = of_get_child_by_name(nproot, "backlight");
5468 + if (!np) {
5469 + dev_err(&pdev->dev, "failed to find backlight node\n");
5470 + return;
5471 +@@ -125,6 +125,8 @@ static void max8925_backlight_dt_init(struct platform_device *pdev)
5472 + if (!of_property_read_u32(np, "maxim,max8925-dual-string", &val))
5473 + pdata->dual_string = val;
5474 +
5475 ++ of_node_put(np);
5476 ++
5477 + pdev->dev.platform_data = pdata;
5478 + }
5479 +
5480 +diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c
5481 +index 380917c86276..762e3feed097 100644
5482 +--- a/drivers/video/backlight/tps65217_bl.c
5483 ++++ b/drivers/video/backlight/tps65217_bl.c
5484 +@@ -184,11 +184,11 @@ static struct tps65217_bl_pdata *
5485 + tps65217_bl_parse_dt(struct platform_device *pdev)
5486 + {
5487 + struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
5488 +- struct device_node *node = of_node_get(tps->dev->of_node);
5489 ++ struct device_node *node;
5490 + struct tps65217_bl_pdata *pdata, *err;
5491 + u32 val;
5492 +
5493 +- node = of_find_node_by_name(node, "backlight");
5494 ++ node = of_get_child_by_name(tps->dev->of_node, "backlight");
5495 + if (!node)
5496 + return ERR_PTR(-ENODEV);
5497 +
5498 +diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
5499 +index 73676eb0244a..c592ca513115 100644
5500 +--- a/drivers/video/fbdev/uvesafb.c
5501 ++++ b/drivers/video/fbdev/uvesafb.c
5502 +@@ -1044,7 +1044,8 @@ static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
5503 + info->cmap.len || cmap->start < info->cmap.start)
5504 + return -EINVAL;
5505 +
5506 +- entries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL);
5507 ++ entries = kmalloc_array(cmap->len, sizeof(*entries),
5508 ++ GFP_KERNEL);
5509 + if (!entries)
5510 + return -ENOMEM;
5511 +
5512 +diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
5513 +index 398d22693234..6e2a9619192d 100644
5514 +--- a/drivers/virt/vboxguest/vboxguest_linux.c
5515 ++++ b/drivers/virt/vboxguest/vboxguest_linux.c
5516 +@@ -121,7 +121,9 @@ static long vbg_misc_device_ioctl(struct file *filp, unsigned int req,
5517 + if (!buf)
5518 + return -ENOMEM;
5519 +
5520 +- if (copy_from_user(buf, (void *)arg, hdr.size_in)) {
5521 ++ *((struct vbg_ioctl_hdr *)buf) = hdr;
5522 ++ if (copy_from_user(buf + sizeof(hdr), (void *)arg + sizeof(hdr),
5523 ++ hdr.size_in - sizeof(hdr))) {
5524 + ret = -EFAULT;
5525 + goto out;
5526 + }
5527 +diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
5528 +index 80a778b02f28..caef0e0fd817 100644
5529 +--- a/drivers/w1/w1.c
5530 ++++ b/drivers/w1/w1.c
5531 +@@ -751,7 +751,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
5532 +
5533 + /* slave modules need to be loaded in a context with unlocked mutex */
5534 + mutex_unlock(&dev->mutex);
5535 +- request_module("w1-family-0x%02x", rn->family);
5536 ++ request_module("w1-family-0x%02X", rn->family);
5537 + mutex_lock(&dev->mutex);
5538 +
5539 + spin_lock(&w1_flock);
5540 +diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
5541 +index 762378f1811c..08e4af04d6f2 100644
5542 +--- a/drivers/xen/events/events_base.c
5543 ++++ b/drivers/xen/events/events_base.c
5544 +@@ -628,8 +628,6 @@ static void __unbind_from_irq(unsigned int irq)
5545 + xen_irq_info_cleanup(info);
5546 + }
5547 +
5548 +- BUG_ON(info_for_irq(irq)->type == IRQT_UNBOUND);
5549 +-
5550 + xen_free_irq(irq);
5551 + }
5552 +
5553 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
5554 +index 775a0f2d0b45..b54a55497216 100644
5555 +--- a/fs/btrfs/inode.c
5556 ++++ b/fs/btrfs/inode.c
5557 +@@ -9475,6 +9475,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
5558 + u64 new_idx = 0;
5559 + u64 root_objectid;
5560 + int ret;
5561 ++ int ret2;
5562 + bool root_log_pinned = false;
5563 + bool dest_log_pinned = false;
5564 +
5565 +@@ -9671,7 +9672,8 @@ static int btrfs_rename_exchange(struct inode *old_dir,
5566 + dest_log_pinned = false;
5567 + }
5568 + }
5569 +- ret = btrfs_end_transaction(trans);
5570 ++ ret2 = btrfs_end_transaction(trans);
5571 ++ ret = ret ? ret : ret2;
5572 + out_notrans:
5573 + if (new_ino == BTRFS_FIRST_FREE_OBJECTID)
5574 + up_read(&fs_info->subvol_sem);
5575 +diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
5576 +index bf779461df13..2e23b953d304 100644
5577 +--- a/fs/f2fs/checkpoint.c
5578 ++++ b/fs/f2fs/checkpoint.c
5579 +@@ -100,8 +100,10 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
5580 + * readonly and make sure do not write checkpoint with non-uptodate
5581 + * meta page.
5582 + */
5583 +- if (unlikely(!PageUptodate(page)))
5584 ++ if (unlikely(!PageUptodate(page))) {
5585 ++ memset(page_address(page), 0, PAGE_SIZE);
5586 + f2fs_stop_checkpoint(sbi, false);
5587 ++ }
5588 + out:
5589 + return page;
5590 + }
5591 +diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
5592 +index e0d9e8f27ed2..f8ef04c9f69d 100644
5593 +--- a/fs/f2fs/inode.c
5594 ++++ b/fs/f2fs/inode.c
5595 +@@ -320,10 +320,10 @@ struct inode *f2fs_iget(struct super_block *sb, unsigned long ino)
5596 + make_now:
5597 + if (ino == F2FS_NODE_INO(sbi)) {
5598 + inode->i_mapping->a_ops = &f2fs_node_aops;
5599 +- mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_ZERO);
5600 ++ mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
5601 + } else if (ino == F2FS_META_INO(sbi)) {
5602 + inode->i_mapping->a_ops = &f2fs_meta_aops;
5603 +- mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_ZERO);
5604 ++ mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
5605 + } else if (S_ISREG(inode->i_mode)) {
5606 + inode->i_op = &f2fs_file_inode_operations;
5607 + inode->i_fop = &f2fs_file_operations;
5608 +diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
5609 +index 5854cc4e1d67..be8d1b16b8d1 100644
5610 +--- a/fs/f2fs/segment.c
5611 ++++ b/fs/f2fs/segment.c
5612 +@@ -2020,6 +2020,7 @@ static void write_current_sum_page(struct f2fs_sb_info *sbi,
5613 + struct f2fs_summary_block *dst;
5614 +
5615 + dst = (struct f2fs_summary_block *)page_address(page);
5616 ++ memset(dst, 0, PAGE_SIZE);
5617 +
5618 + mutex_lock(&curseg->curseg_mutex);
5619 +
5620 +@@ -3116,6 +3117,7 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
5621 +
5622 + page = grab_meta_page(sbi, blkaddr++);
5623 + kaddr = (unsigned char *)page_address(page);
5624 ++ memset(kaddr, 0, PAGE_SIZE);
5625 +
5626 + /* Step 1: write nat cache */
5627 + seg_i = CURSEG_I(sbi, CURSEG_HOT_DATA);
5628 +@@ -3140,6 +3142,7 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
5629 + if (!page) {
5630 + page = grab_meta_page(sbi, blkaddr++);
5631 + kaddr = (unsigned char *)page_address(page);
5632 ++ memset(kaddr, 0, PAGE_SIZE);
5633 + written_size = 0;
5634 + }
5635 + summary = (struct f2fs_summary *)(kaddr + written_size);
5636 +diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
5637 +index 3325d0769723..492ad0c86fa9 100644
5638 +--- a/fs/f2fs/segment.h
5639 ++++ b/fs/f2fs/segment.h
5640 +@@ -375,6 +375,7 @@ static inline void seg_info_to_sit_page(struct f2fs_sb_info *sbi,
5641 + int i;
5642 +
5643 + raw_sit = (struct f2fs_sit_block *)page_address(page);
5644 ++ memset(raw_sit, 0, PAGE_SIZE);
5645 + for (i = 0; i < end - start; i++) {
5646 + rs = &raw_sit->entries[i];
5647 + se = get_seg_entry(sbi, start + i);
5648 +diff --git a/fs/fuse/control.c b/fs/fuse/control.c
5649 +index b9ea99c5b5b3..5be0339dcceb 100644
5650 +--- a/fs/fuse/control.c
5651 ++++ b/fs/fuse/control.c
5652 +@@ -211,10 +211,11 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
5653 + if (!dentry)
5654 + return NULL;
5655 +
5656 +- fc->ctl_dentry[fc->ctl_ndents++] = dentry;
5657 + inode = new_inode(fuse_control_sb);
5658 +- if (!inode)
5659 ++ if (!inode) {
5660 ++ dput(dentry);
5661 + return NULL;
5662 ++ }
5663 +
5664 + inode->i_ino = get_next_ino();
5665 + inode->i_mode = mode;
5666 +@@ -228,6 +229,9 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
5667 + set_nlink(inode, nlink);
5668 + inode->i_private = fc;
5669 + d_add(dentry, inode);
5670 ++
5671 ++ fc->ctl_dentry[fc->ctl_ndents++] = dentry;
5672 ++
5673 + return dentry;
5674 + }
5675 +
5676 +@@ -284,7 +288,10 @@ void fuse_ctl_remove_conn(struct fuse_conn *fc)
5677 + for (i = fc->ctl_ndents - 1; i >= 0; i--) {
5678 + struct dentry *dentry = fc->ctl_dentry[i];
5679 + d_inode(dentry)->i_private = NULL;
5680 +- d_drop(dentry);
5681 ++ if (!i) {
5682 ++ /* Get rid of submounts: */
5683 ++ d_invalidate(dentry);
5684 ++ }
5685 + dput(dentry);
5686 + }
5687 + drop_nlink(d_inode(fuse_control_sb->s_root));
5688 +diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
5689 +index 5d06384c2cae..ee6c9baf8158 100644
5690 +--- a/fs/fuse/dev.c
5691 ++++ b/fs/fuse/dev.c
5692 +@@ -381,8 +381,7 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req)
5693 + if (!fc->blocked && waitqueue_active(&fc->blocked_waitq))
5694 + wake_up(&fc->blocked_waitq);
5695 +
5696 +- if (fc->num_background == fc->congestion_threshold &&
5697 +- fc->connected && fc->sb) {
5698 ++ if (fc->num_background == fc->congestion_threshold && fc->sb) {
5699 + clear_bdi_congested(fc->sb->s_bdi, BLK_RW_SYNC);
5700 + clear_bdi_congested(fc->sb->s_bdi, BLK_RW_ASYNC);
5701 + }
5702 +diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
5703 +index 24967382a7b1..7a980b4462d9 100644
5704 +--- a/fs/fuse/dir.c
5705 ++++ b/fs/fuse/dir.c
5706 +@@ -1629,8 +1629,19 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
5707 + return err;
5708 +
5709 + if (attr->ia_valid & ATTR_OPEN) {
5710 +- if (fc->atomic_o_trunc)
5711 ++ /* This is coming from open(..., ... | O_TRUNC); */
5712 ++ WARN_ON(!(attr->ia_valid & ATTR_SIZE));
5713 ++ WARN_ON(attr->ia_size != 0);
5714 ++ if (fc->atomic_o_trunc) {
5715 ++ /*
5716 ++ * No need to send request to userspace, since actual
5717 ++ * truncation has already been done by OPEN. But still
5718 ++ * need to truncate page cache.
5719 ++ */
5720 ++ i_size_write(inode, 0);
5721 ++ truncate_pagecache(inode, 0);
5722 + return 0;
5723 ++ }
5724 + file = NULL;
5725 + }
5726 +
5727 +diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
5728 +index ef309958e060..9b37cf8142b5 100644
5729 +--- a/fs/fuse/inode.c
5730 ++++ b/fs/fuse/inode.c
5731 +@@ -1179,6 +1179,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
5732 + fuse_dev_free(fud);
5733 + err_put_conn:
5734 + fuse_conn_put(fc);
5735 ++ sb->s_fs_info = NULL;
5736 + err_fput:
5737 + fput(file);
5738 + err:
5739 +diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
5740 +index a50d7813e3ea..180b4b616725 100644
5741 +--- a/fs/nfs/callback_proc.c
5742 ++++ b/fs/nfs/callback_proc.c
5743 +@@ -420,11 +420,8 @@ validate_seqid(const struct nfs4_slot_table *tbl, const struct nfs4_slot *slot,
5744 + return htonl(NFS4ERR_SEQ_FALSE_RETRY);
5745 + }
5746 +
5747 +- /* Wraparound */
5748 +- if (unlikely(slot->seq_nr == 0xFFFFFFFFU)) {
5749 +- if (args->csa_sequenceid == 1)
5750 +- return htonl(NFS4_OK);
5751 +- } else if (likely(args->csa_sequenceid == slot->seq_nr + 1))
5752 ++ /* Note: wraparound relies on seq_nr being of type u32 */
5753 ++ if (likely(args->csa_sequenceid == slot->seq_nr + 1))
5754 + return htonl(NFS4_OK);
5755 +
5756 + /* Misordered request */
5757 +diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c
5758 +index 22dc30a679a0..b6f9d84ba19b 100644
5759 +--- a/fs/nfs/nfs4idmap.c
5760 ++++ b/fs/nfs/nfs4idmap.c
5761 +@@ -343,7 +343,7 @@ static ssize_t nfs_idmap_lookup_name(__u32 id, const char *type, char *buf,
5762 + int id_len;
5763 + ssize_t ret;
5764 +
5765 +- id_len = snprintf(id_str, sizeof(id_str), "%u", id);
5766 ++ id_len = nfs_map_numeric_to_string(id, id_str, sizeof(id_str));
5767 + ret = nfs_idmap_get_key(id_str, id_len, type, buf, buflen, idmap);
5768 + if (ret < 0)
5769 + return -EINVAL;
5770 +@@ -627,7 +627,8 @@ static int nfs_idmap_read_and_verify_message(struct idmap_msg *im,
5771 + if (strcmp(upcall->im_name, im->im_name) != 0)
5772 + break;
5773 + /* Note: here we store the NUL terminator too */
5774 +- len = sprintf(id_str, "%d", im->im_id) + 1;
5775 ++ len = 1 + nfs_map_numeric_to_string(im->im_id, id_str,
5776 ++ sizeof(id_str));
5777 + ret = nfs_idmap_instantiate(key, authkey, id_str, len);
5778 + break;
5779 + case IDMAP_CONV_IDTONAME:
5780 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
5781 +index b71757e85066..409acdda70dd 100644
5782 +--- a/fs/nfs/nfs4proc.c
5783 ++++ b/fs/nfs/nfs4proc.c
5784 +@@ -751,7 +751,7 @@ static int nfs41_sequence_process(struct rpc_task *task,
5785 + * The slot id we used was probably retired. Try again
5786 + * using a different slot id.
5787 + */
5788 +- if (slot->seq_nr < slot->table->target_highest_slotid)
5789 ++ if (slot->slot_nr < slot->table->target_highest_slotid)
5790 + goto session_recover;
5791 + goto retry_nowait;
5792 + case -NFS4ERR_SEQ_MISORDERED:
5793 +diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
5794 +index 1d048dd95464..cfe535c286c3 100644
5795 +--- a/fs/nfsd/nfs4xdr.c
5796 ++++ b/fs/nfsd/nfs4xdr.c
5797 +@@ -3651,7 +3651,8 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
5798 + nfserr = nfserr_resource;
5799 + goto err_no_verf;
5800 + }
5801 +- maxcount = min_t(u32, readdir->rd_maxcount, INT_MAX);
5802 ++ maxcount = svc_max_payload(resp->rqstp);
5803 ++ maxcount = min_t(u32, readdir->rd_maxcount, maxcount);
5804 + /*
5805 + * Note the rfc defines rd_maxcount as the size of the
5806 + * READDIR4resok structure, which includes the verifier above
5807 +@@ -3665,7 +3666,7 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
5808 +
5809 + /* RFC 3530 14.2.24 allows us to ignore dircount when it's 0: */
5810 + if (!readdir->rd_dircount)
5811 +- readdir->rd_dircount = INT_MAX;
5812 ++ readdir->rd_dircount = svc_max_payload(resp->rqstp);
5813 +
5814 + readdir->xdr = xdr;
5815 + readdir->rd_maxcount = maxcount;
5816 +diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
5817 +index 04c4ec6483e5..8ae1cd8611cc 100644
5818 +--- a/fs/ubifs/journal.c
5819 ++++ b/fs/ubifs/journal.c
5820 +@@ -1283,10 +1283,11 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
5821 + int *new_len)
5822 + {
5823 + void *buf;
5824 +- int err, dlen, compr_type, out_len, old_dlen;
5825 ++ int err, compr_type;
5826 ++ u32 dlen, out_len, old_dlen;
5827 +
5828 + out_len = le32_to_cpu(dn->size);
5829 +- buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS);
5830 ++ buf = kmalloc_array(out_len, WORST_COMPR_FACTOR, GFP_NOFS);
5831 + if (!buf)
5832 + return -ENOMEM;
5833 +
5834 +diff --git a/fs/udf/directory.c b/fs/udf/directory.c
5835 +index 0a98a2369738..3835f983cc99 100644
5836 +--- a/fs/udf/directory.c
5837 ++++ b/fs/udf/directory.c
5838 +@@ -152,6 +152,9 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
5839 + sizeof(struct fileIdentDesc));
5840 + }
5841 + }
5842 ++ /* Got last entry outside of dir size - fs is corrupted! */
5843 ++ if (*nf_pos > dir->i_size)
5844 ++ return NULL;
5845 + return fi;
5846 + }
5847 +
5848 +diff --git a/include/dt-bindings/clock/aspeed-clock.h b/include/dt-bindings/clock/aspeed-clock.h
5849 +index d3558d897a4d..8d69b9134bef 100644
5850 +--- a/include/dt-bindings/clock/aspeed-clock.h
5851 ++++ b/include/dt-bindings/clock/aspeed-clock.h
5852 +@@ -45,7 +45,7 @@
5853 + #define ASPEED_RESET_JTAG_MASTER 3
5854 + #define ASPEED_RESET_MIC 4
5855 + #define ASPEED_RESET_PWM 5
5856 +-#define ASPEED_RESET_PCIVGA 6
5857 ++#define ASPEED_RESET_PECI 6
5858 + #define ASPEED_RESET_I2C 7
5859 + #define ASPEED_RESET_AHB 8
5860 +
5861 +diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
5862 +index 5c4eee043191..7d047465dfc2 100644
5863 +--- a/include/linux/blkdev.h
5864 ++++ b/include/linux/blkdev.h
5865 +@@ -1124,8 +1124,8 @@ static inline unsigned int blk_max_size_offset(struct request_queue *q,
5866 + if (!q->limits.chunk_sectors)
5867 + return q->limits.max_sectors;
5868 +
5869 +- return q->limits.chunk_sectors -
5870 +- (offset & (q->limits.chunk_sectors - 1));
5871 ++ return min(q->limits.max_sectors, (unsigned int)(q->limits.chunk_sectors -
5872 ++ (offset & (q->limits.chunk_sectors - 1))));
5873 + }
5874 +
5875 + static inline unsigned int blk_rq_get_max_sectors(struct request *rq,
5876 +diff --git a/include/linux/compiler.h b/include/linux/compiler.h
5877 +index ab4711c63601..42506e4d1f53 100644
5878 +--- a/include/linux/compiler.h
5879 ++++ b/include/linux/compiler.h
5880 +@@ -21,7 +21,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
5881 + #define unlikely_notrace(x) __builtin_expect(!!(x), 0)
5882 +
5883 + #define __branch_check__(x, expect, is_constant) ({ \
5884 +- int ______r; \
5885 ++ long ______r; \
5886 + static struct ftrace_likely_data \
5887 + __attribute__((__aligned__(4))) \
5888 + __attribute__((section("_ftrace_annotated_branch"))) \
5889 +diff --git a/include/linux/memory.h b/include/linux/memory.h
5890 +index 31ca3e28b0eb..a6ddefc60517 100644
5891 +--- a/include/linux/memory.h
5892 ++++ b/include/linux/memory.h
5893 +@@ -38,6 +38,7 @@ struct memory_block {
5894 +
5895 + int arch_get_memory_phys_device(unsigned long start_pfn);
5896 + unsigned long memory_block_size_bytes(void);
5897 ++int set_memory_block_size_order(unsigned int order);
5898 +
5899 + /* These states are exposed to userspace as text strings in sysfs */
5900 + #define MEM_ONLINE (1<<0) /* exposed to userspace */
5901 +diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
5902 +index 3773e26c08c1..bb93a6c693e3 100644
5903 +--- a/include/linux/slub_def.h
5904 ++++ b/include/linux/slub_def.h
5905 +@@ -156,8 +156,12 @@ struct kmem_cache {
5906 +
5907 + #ifdef CONFIG_SYSFS
5908 + #define SLAB_SUPPORTS_SYSFS
5909 ++void sysfs_slab_unlink(struct kmem_cache *);
5910 + void sysfs_slab_release(struct kmem_cache *);
5911 + #else
5912 ++static inline void sysfs_slab_unlink(struct kmem_cache *s)
5913 ++{
5914 ++}
5915 + static inline void sysfs_slab_release(struct kmem_cache *s)
5916 + {
5917 + }
5918 +diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
5919 +index 9fc8a825aa28..ba015efb5312 100644
5920 +--- a/include/rdma/ib_verbs.h
5921 ++++ b/include/rdma/ib_verbs.h
5922 +@@ -3310,11 +3310,14 @@ int ib_process_cq_direct(struct ib_cq *cq, int budget);
5923 + *
5924 + * Users can examine the cq structure to determine the actual CQ size.
5925 + */
5926 +-struct ib_cq *ib_create_cq(struct ib_device *device,
5927 +- ib_comp_handler comp_handler,
5928 +- void (*event_handler)(struct ib_event *, void *),
5929 +- void *cq_context,
5930 +- const struct ib_cq_init_attr *cq_attr);
5931 ++struct ib_cq *__ib_create_cq(struct ib_device *device,
5932 ++ ib_comp_handler comp_handler,
5933 ++ void (*event_handler)(struct ib_event *, void *),
5934 ++ void *cq_context,
5935 ++ const struct ib_cq_init_attr *cq_attr,
5936 ++ const char *caller);
5937 ++#define ib_create_cq(device, cmp_hndlr, evt_hndlr, cq_ctxt, cq_attr) \
5938 ++ __ib_create_cq((device), (cmp_hndlr), (evt_hndlr), (cq_ctxt), (cq_attr), KBUILD_MODNAME)
5939 +
5940 + /**
5941 + * ib_resize_cq - Modifies the capacity of the CQ.
5942 +@@ -3734,6 +3737,20 @@ static inline int ib_check_mr_access(int flags)
5943 + return 0;
5944 + }
5945 +
5946 ++static inline bool ib_access_writable(int access_flags)
5947 ++{
5948 ++ /*
5949 ++ * We have writable memory backing the MR if any of the following
5950 ++ * access flags are set. "Local write" and "remote write" obviously
5951 ++ * require write access. "Remote atomic" can do things like fetch and
5952 ++ * add, which will modify memory, and "MW bind" can change permissions
5953 ++ * by binding a window.
5954 ++ */
5955 ++ return access_flags &
5956 ++ (IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE |
5957 ++ IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND);
5958 ++}
5959 ++
5960 + /**
5961 + * ib_check_mr_status: lightweight check of MR status.
5962 + * This routine may provide status checks on a selected
5963 +diff --git a/include/rdma/rdma_vt.h b/include/rdma/rdma_vt.h
5964 +index 3f4c187e435d..eec495e68823 100644
5965 +--- a/include/rdma/rdma_vt.h
5966 ++++ b/include/rdma/rdma_vt.h
5967 +@@ -402,7 +402,7 @@ struct rvt_dev_info {
5968 + spinlock_t pending_lock; /* protect pending mmap list */
5969 +
5970 + /* CQ */
5971 +- struct kthread_worker *worker; /* per device cq worker */
5972 ++ struct kthread_worker __rcu *worker; /* per device cq worker */
5973 + u32 n_cqs_allocated; /* number of CQs allocated for device */
5974 + spinlock_t n_cqs_lock; /* protect count of in use cqs */
5975 +
5976 +diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
5977 +index bc1e507be9ff..776308d2fa9e 100644
5978 +--- a/kernel/locking/rwsem.c
5979 ++++ b/kernel/locking/rwsem.c
5980 +@@ -181,6 +181,7 @@ void down_read_non_owner(struct rw_semaphore *sem)
5981 + might_sleep();
5982 +
5983 + __down_read(sem);
5984 ++ rwsem_set_reader_owned(sem);
5985 + }
5986 +
5987 + EXPORT_SYMBOL(down_read_non_owner);
5988 +diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
5989 +index 3e3c2004bb23..449d67edfa4b 100644
5990 +--- a/kernel/printk/printk_safe.c
5991 ++++ b/kernel/printk/printk_safe.c
5992 +@@ -82,6 +82,7 @@ static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s,
5993 + {
5994 + int add;
5995 + size_t len;
5996 ++ va_list ap;
5997 +
5998 + again:
5999 + len = atomic_read(&s->len);
6000 +@@ -100,7 +101,9 @@ static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s,
6001 + if (!len)
6002 + smp_rmb();
6003 +
6004 +- add = vscnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args);
6005 ++ va_copy(ap, args);
6006 ++ add = vscnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, ap);
6007 ++ va_end(ap);
6008 + if (!add)
6009 + return 0;
6010 +
6011 +diff --git a/kernel/softirq.c b/kernel/softirq.c
6012 +index 177de3640c78..8a040bcaa033 100644
6013 +--- a/kernel/softirq.c
6014 ++++ b/kernel/softirq.c
6015 +@@ -139,9 +139,13 @@ static void __local_bh_enable(unsigned int cnt)
6016 + {
6017 + lockdep_assert_irqs_disabled();
6018 +
6019 ++ if (preempt_count() == cnt)
6020 ++ trace_preempt_on(CALLER_ADDR0, get_lock_parent_ip());
6021 ++
6022 + if (softirq_count() == (cnt & SOFTIRQ_MASK))
6023 + trace_softirqs_on(_RET_IP_);
6024 +- preempt_count_sub(cnt);
6025 ++
6026 ++ __preempt_count_sub(cnt);
6027 + }
6028 +
6029 + /*
6030 +diff --git a/kernel/time/time.c b/kernel/time/time.c
6031 +index 3044d48ebe56..e8127f4e9e66 100644
6032 +--- a/kernel/time/time.c
6033 ++++ b/kernel/time/time.c
6034 +@@ -28,6 +28,7 @@
6035 + */
6036 +
6037 + #include <linux/export.h>
6038 ++#include <linux/kernel.h>
6039 + #include <linux/timex.h>
6040 + #include <linux/capability.h>
6041 + #include <linux/timekeeper_internal.h>
6042 +@@ -314,9 +315,10 @@ unsigned int jiffies_to_msecs(const unsigned long j)
6043 + return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);
6044 + #else
6045 + # if BITS_PER_LONG == 32
6046 +- return (HZ_TO_MSEC_MUL32 * j) >> HZ_TO_MSEC_SHR32;
6047 ++ return (HZ_TO_MSEC_MUL32 * j + (1ULL << HZ_TO_MSEC_SHR32) - 1) >>
6048 ++ HZ_TO_MSEC_SHR32;
6049 + # else
6050 +- return (j * HZ_TO_MSEC_NUM) / HZ_TO_MSEC_DEN;
6051 ++ return DIV_ROUND_UP(j * HZ_TO_MSEC_NUM, HZ_TO_MSEC_DEN);
6052 + # endif
6053 + #endif
6054 + }
6055 +diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
6056 +index 7d306b74230f..c44f74daefbf 100644
6057 +--- a/kernel/trace/trace_events_filter.c
6058 ++++ b/kernel/trace/trace_events_filter.c
6059 +@@ -78,7 +78,8 @@ static const char * ops[] = { OPS };
6060 + C(TOO_MANY_PREDS, "Too many terms in predicate expression"), \
6061 + C(INVALID_FILTER, "Meaningless filter expression"), \
6062 + C(IP_FIELD_ONLY, "Only 'ip' field is supported for function trace"), \
6063 +- C(INVALID_VALUE, "Invalid value (did you forget quotes)?"),
6064 ++ C(INVALID_VALUE, "Invalid value (did you forget quotes)?"), \
6065 ++ C(NO_FILTER, "No filter found"),
6066 +
6067 + #undef C
6068 + #define C(a, b) FILT_ERR_##a
6069 +@@ -550,6 +551,13 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,
6070 + goto out_free;
6071 + }
6072 +
6073 ++ if (!N) {
6074 ++ /* No program? */
6075 ++ ret = -EINVAL;
6076 ++ parse_error(pe, FILT_ERR_NO_FILTER, ptr - str);
6077 ++ goto out_free;
6078 ++ }
6079 ++
6080 + prog[N].pred = NULL; /* #13 */
6081 + prog[N].target = 1; /* TRUE */
6082 + prog[N+1].pred = NULL;
6083 +diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
6084 +index 3d35d062970d..c253c1b46c6b 100644
6085 +--- a/lib/Kconfig.kasan
6086 ++++ b/lib/Kconfig.kasan
6087 +@@ -6,6 +6,7 @@ if HAVE_ARCH_KASAN
6088 + config KASAN
6089 + bool "KASan: runtime memory debugger"
6090 + depends on SLUB || (SLAB && !DEBUG_SLAB)
6091 ++ select SLUB_DEBUG if SLUB
6092 + select CONSTRUCTORS
6093 + select STACKDEPOT
6094 + help
6095 +diff --git a/lib/vsprintf.c b/lib/vsprintf.c
6096 +index 23920c5ff728..91320e5bfd5b 100644
6097 +--- a/lib/vsprintf.c
6098 ++++ b/lib/vsprintf.c
6099 +@@ -1456,9 +1456,6 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
6100 + return string(buf, end, NULL, spec);
6101 +
6102 + switch (fmt[1]) {
6103 +- case 'r':
6104 +- return number(buf, end, clk_get_rate(clk), spec);
6105 +-
6106 + case 'n':
6107 + default:
6108 + #ifdef CONFIG_COMMON_CLK
6109 +diff --git a/mm/gup.c b/mm/gup.c
6110 +index 541904a7c60f..3d8472d48a0b 100644
6111 +--- a/mm/gup.c
6112 ++++ b/mm/gup.c
6113 +@@ -1459,32 +1459,48 @@ static int __gup_device_huge(unsigned long pfn, unsigned long addr,
6114 + return 1;
6115 + }
6116 +
6117 +-static int __gup_device_huge_pmd(pmd_t pmd, unsigned long addr,
6118 ++static int __gup_device_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr,
6119 + unsigned long end, struct page **pages, int *nr)
6120 + {
6121 + unsigned long fault_pfn;
6122 ++ int nr_start = *nr;
6123 ++
6124 ++ fault_pfn = pmd_pfn(orig) + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
6125 ++ if (!__gup_device_huge(fault_pfn, addr, end, pages, nr))
6126 ++ return 0;
6127 +
6128 +- fault_pfn = pmd_pfn(pmd) + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
6129 +- return __gup_device_huge(fault_pfn, addr, end, pages, nr);
6130 ++ if (unlikely(pmd_val(orig) != pmd_val(*pmdp))) {
6131 ++ undo_dev_pagemap(nr, nr_start, pages);
6132 ++ return 0;
6133 ++ }
6134 ++ return 1;
6135 + }
6136 +
6137 +-static int __gup_device_huge_pud(pud_t pud, unsigned long addr,
6138 ++static int __gup_device_huge_pud(pud_t orig, pud_t *pudp, unsigned long addr,
6139 + unsigned long end, struct page **pages, int *nr)
6140 + {
6141 + unsigned long fault_pfn;
6142 ++ int nr_start = *nr;
6143 ++
6144 ++ fault_pfn = pud_pfn(orig) + ((addr & ~PUD_MASK) >> PAGE_SHIFT);
6145 ++ if (!__gup_device_huge(fault_pfn, addr, end, pages, nr))
6146 ++ return 0;
6147 +
6148 +- fault_pfn = pud_pfn(pud) + ((addr & ~PUD_MASK) >> PAGE_SHIFT);
6149 +- return __gup_device_huge(fault_pfn, addr, end, pages, nr);
6150 ++ if (unlikely(pud_val(orig) != pud_val(*pudp))) {
6151 ++ undo_dev_pagemap(nr, nr_start, pages);
6152 ++ return 0;
6153 ++ }
6154 ++ return 1;
6155 + }
6156 + #else
6157 +-static int __gup_device_huge_pmd(pmd_t pmd, unsigned long addr,
6158 ++static int __gup_device_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr,
6159 + unsigned long end, struct page **pages, int *nr)
6160 + {
6161 + BUILD_BUG();
6162 + return 0;
6163 + }
6164 +
6165 +-static int __gup_device_huge_pud(pud_t pud, unsigned long addr,
6166 ++static int __gup_device_huge_pud(pud_t pud, pud_t *pudp, unsigned long addr,
6167 + unsigned long end, struct page **pages, int *nr)
6168 + {
6169 + BUILD_BUG();
6170 +@@ -1502,7 +1518,7 @@ static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr,
6171 + return 0;
6172 +
6173 + if (pmd_devmap(orig))
6174 +- return __gup_device_huge_pmd(orig, addr, end, pages, nr);
6175 ++ return __gup_device_huge_pmd(orig, pmdp, addr, end, pages, nr);
6176 +
6177 + refs = 0;
6178 + page = pmd_page(orig) + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
6179 +@@ -1540,7 +1556,7 @@ static int gup_huge_pud(pud_t orig, pud_t *pudp, unsigned long addr,
6180 + return 0;
6181 +
6182 + if (pud_devmap(orig))
6183 +- return __gup_device_huge_pud(orig, addr, end, pages, nr);
6184 ++ return __gup_device_huge_pud(orig, pudp, addr, end, pages, nr);
6185 +
6186 + refs = 0;
6187 + page = pud_page(orig) + ((addr & ~PUD_MASK) >> PAGE_SHIFT);
6188 +diff --git a/mm/ksm.c b/mm/ksm.c
6189 +index e3cbf9a92f3c..e6a9640580fc 100644
6190 +--- a/mm/ksm.c
6191 ++++ b/mm/ksm.c
6192 +@@ -199,6 +199,8 @@ struct rmap_item {
6193 + #define SEQNR_MASK 0x0ff /* low bits of unstable tree seqnr */
6194 + #define UNSTABLE_FLAG 0x100 /* is a node of the unstable tree */
6195 + #define STABLE_FLAG 0x200 /* is listed from the stable tree */
6196 ++#define KSM_FLAG_MASK (SEQNR_MASK|UNSTABLE_FLAG|STABLE_FLAG)
6197 ++ /* to mask all the flags */
6198 +
6199 + /* The stable and unstable tree heads */
6200 + static struct rb_root one_stable_tree[1] = { RB_ROOT };
6201 +@@ -2570,10 +2572,15 @@ void rmap_walk_ksm(struct page *page, struct rmap_walk_control *rwc)
6202 + anon_vma_lock_read(anon_vma);
6203 + anon_vma_interval_tree_foreach(vmac, &anon_vma->rb_root,
6204 + 0, ULONG_MAX) {
6205 ++ unsigned long addr;
6206 ++
6207 + cond_resched();
6208 + vma = vmac->vma;
6209 +- if (rmap_item->address < vma->vm_start ||
6210 +- rmap_item->address >= vma->vm_end)
6211 ++
6212 ++ /* Ignore the stable/unstable/sqnr flags */
6213 ++ addr = rmap_item->address & ~KSM_FLAG_MASK;
6214 ++
6215 ++ if (addr < vma->vm_start || addr >= vma->vm_end)
6216 + continue;
6217 + /*
6218 + * Initially we examine only the vma which covers this
6219 +@@ -2587,8 +2594,7 @@ void rmap_walk_ksm(struct page *page, struct rmap_walk_control *rwc)
6220 + if (rwc->invalid_vma && rwc->invalid_vma(vma, rwc->arg))
6221 + continue;
6222 +
6223 +- if (!rwc->rmap_one(page, vma,
6224 +- rmap_item->address, rwc->arg)) {
6225 ++ if (!rwc->rmap_one(page, vma, addr, rwc->arg)) {
6226 + anon_vma_unlock_read(anon_vma);
6227 + return;
6228 + }
6229 +diff --git a/mm/slab_common.c b/mm/slab_common.c
6230 +index 98dcdc352062..65408ced18f1 100644
6231 +--- a/mm/slab_common.c
6232 ++++ b/mm/slab_common.c
6233 +@@ -566,10 +566,14 @@ static int shutdown_cache(struct kmem_cache *s)
6234 + list_del(&s->list);
6235 +
6236 + if (s->flags & SLAB_TYPESAFE_BY_RCU) {
6237 ++#ifdef SLAB_SUPPORTS_SYSFS
6238 ++ sysfs_slab_unlink(s);
6239 ++#endif
6240 + list_add_tail(&s->list, &slab_caches_to_rcu_destroy);
6241 + schedule_work(&slab_caches_to_rcu_destroy_work);
6242 + } else {
6243 + #ifdef SLAB_SUPPORTS_SYSFS
6244 ++ sysfs_slab_unlink(s);
6245 + sysfs_slab_release(s);
6246 + #else
6247 + slab_kmem_cache_release(s);
6248 +diff --git a/mm/slub.c b/mm/slub.c
6249 +index 44aa7847324a..613c8dc2f409 100644
6250 +--- a/mm/slub.c
6251 ++++ b/mm/slub.c
6252 +@@ -5714,7 +5714,6 @@ static void sysfs_slab_remove_workfn(struct work_struct *work)
6253 + kset_unregister(s->memcg_kset);
6254 + #endif
6255 + kobject_uevent(&s->kobj, KOBJ_REMOVE);
6256 +- kobject_del(&s->kobj);
6257 + out:
6258 + kobject_put(&s->kobj);
6259 + }
6260 +@@ -5799,6 +5798,12 @@ static void sysfs_slab_remove(struct kmem_cache *s)
6261 + schedule_work(&s->kobj_remove_work);
6262 + }
6263 +
6264 ++void sysfs_slab_unlink(struct kmem_cache *s)
6265 ++{
6266 ++ if (slab_state >= FULL)
6267 ++ kobject_del(&s->kobj);
6268 ++}
6269 ++
6270 + void sysfs_slab_release(struct kmem_cache *s)
6271 + {
6272 + if (slab_state >= FULL)
6273 +diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
6274 +index e8adad33d0bb..8e531ac9bc87 100644
6275 +--- a/net/sunrpc/xprtrdma/rpc_rdma.c
6276 ++++ b/net/sunrpc/xprtrdma/rpc_rdma.c
6277 +@@ -230,7 +230,7 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf,
6278 + */
6279 + *ppages = alloc_page(GFP_ATOMIC);
6280 + if (!*ppages)
6281 +- return -EAGAIN;
6282 ++ return -ENOBUFS;
6283 + }
6284 + seg->mr_page = *ppages;
6285 + seg->mr_offset = (char *)page_base;
6286 +diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
6287 +index 245160373dab..cbf227d12c2b 100644
6288 +--- a/security/selinux/selinuxfs.c
6289 ++++ b/security/selinux/selinuxfs.c
6290 +@@ -435,22 +435,16 @@ static int sel_release_policy(struct inode *inode, struct file *filp)
6291 + static ssize_t sel_read_policy(struct file *filp, char __user *buf,
6292 + size_t count, loff_t *ppos)
6293 + {
6294 +- struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info;
6295 + struct policy_load_memory *plm = filp->private_data;
6296 + int ret;
6297 +
6298 +- mutex_lock(&fsi->mutex);
6299 +-
6300 + ret = avc_has_perm(&selinux_state,
6301 + current_sid(), SECINITSID_SECURITY,
6302 + SECCLASS_SECURITY, SECURITY__READ_POLICY, NULL);
6303 + if (ret)
6304 +- goto out;
6305 ++ return ret;
6306 +
6307 +- ret = simple_read_from_buffer(buf, count, ppos, plm->data, plm->len);
6308 +-out:
6309 +- mutex_unlock(&fsi->mutex);
6310 +- return ret;
6311 ++ return simple_read_from_buffer(buf, count, ppos, plm->data, plm->len);
6312 + }
6313 +
6314 + static int sel_mmap_policy_fault(struct vm_fault *vmf)
6315 +@@ -1182,25 +1176,29 @@ static ssize_t sel_read_bool(struct file *filep, char __user *buf,
6316 + ret = -EINVAL;
6317 + if (index >= fsi->bool_num || strcmp(name,
6318 + fsi->bool_pending_names[index]))
6319 +- goto out;
6320 ++ goto out_unlock;
6321 +
6322 + ret = -ENOMEM;
6323 + page = (char *)get_zeroed_page(GFP_KERNEL);
6324 + if (!page)
6325 +- goto out;
6326 ++ goto out_unlock;
6327 +
6328 + cur_enforcing = security_get_bool_value(fsi->state, index);
6329 + if (cur_enforcing < 0) {
6330 + ret = cur_enforcing;
6331 +- goto out;
6332 ++ goto out_unlock;
6333 + }
6334 + length = scnprintf(page, PAGE_SIZE, "%d %d", cur_enforcing,
6335 + fsi->bool_pending_values[index]);
6336 +- ret = simple_read_from_buffer(buf, count, ppos, page, length);
6337 +-out:
6338 + mutex_unlock(&fsi->mutex);
6339 ++ ret = simple_read_from_buffer(buf, count, ppos, page, length);
6340 ++out_free:
6341 + free_page((unsigned long)page);
6342 + return ret;
6343 ++
6344 ++out_unlock:
6345 ++ mutex_unlock(&fsi->mutex);
6346 ++ goto out_free;
6347 + }
6348 +
6349 + static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
6350 +@@ -1213,6 +1211,17 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
6351 + unsigned index = file_inode(filep)->i_ino & SEL_INO_MASK;
6352 + const char *name = filep->f_path.dentry->d_name.name;
6353 +
6354 ++ if (count >= PAGE_SIZE)
6355 ++ return -ENOMEM;
6356 ++
6357 ++ /* No partial writes. */
6358 ++ if (*ppos != 0)
6359 ++ return -EINVAL;
6360 ++
6361 ++ page = memdup_user_nul(buf, count);
6362 ++ if (IS_ERR(page))
6363 ++ return PTR_ERR(page);
6364 ++
6365 + mutex_lock(&fsi->mutex);
6366 +
6367 + length = avc_has_perm(&selinux_state,
6368 +@@ -1227,22 +1236,6 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
6369 + fsi->bool_pending_names[index]))
6370 + goto out;
6371 +
6372 +- length = -ENOMEM;
6373 +- if (count >= PAGE_SIZE)
6374 +- goto out;
6375 +-
6376 +- /* No partial writes. */
6377 +- length = -EINVAL;
6378 +- if (*ppos != 0)
6379 +- goto out;
6380 +-
6381 +- page = memdup_user_nul(buf, count);
6382 +- if (IS_ERR(page)) {
6383 +- length = PTR_ERR(page);
6384 +- page = NULL;
6385 +- goto out;
6386 +- }
6387 +-
6388 + length = -EINVAL;
6389 + if (sscanf(page, "%d", &new_value) != 1)
6390 + goto out;
6391 +@@ -1274,6 +1267,17 @@ static ssize_t sel_commit_bools_write(struct file *filep,
6392 + ssize_t length;
6393 + int new_value;
6394 +
6395 ++ if (count >= PAGE_SIZE)
6396 ++ return -ENOMEM;
6397 ++
6398 ++ /* No partial writes. */
6399 ++ if (*ppos != 0)
6400 ++ return -EINVAL;
6401 ++
6402 ++ page = memdup_user_nul(buf, count);
6403 ++ if (IS_ERR(page))
6404 ++ return PTR_ERR(page);
6405 ++
6406 + mutex_lock(&fsi->mutex);
6407 +
6408 + length = avc_has_perm(&selinux_state,
6409 +@@ -1283,22 +1287,6 @@ static ssize_t sel_commit_bools_write(struct file *filep,
6410 + if (length)
6411 + goto out;
6412 +
6413 +- length = -ENOMEM;
6414 +- if (count >= PAGE_SIZE)
6415 +- goto out;
6416 +-
6417 +- /* No partial writes. */
6418 +- length = -EINVAL;
6419 +- if (*ppos != 0)
6420 +- goto out;
6421 +-
6422 +- page = memdup_user_nul(buf, count);
6423 +- if (IS_ERR(page)) {
6424 +- length = PTR_ERR(page);
6425 +- page = NULL;
6426 +- goto out;
6427 +- }
6428 +-
6429 + length = -EINVAL;
6430 + if (sscanf(page, "%d", &new_value) != 1)
6431 + goto out;
6432 +diff --git a/sound/core/timer.c b/sound/core/timer.c
6433 +index 0ddcae495838..e9e73edb4bd8 100644
6434 +--- a/sound/core/timer.c
6435 ++++ b/sound/core/timer.c
6436 +@@ -1517,7 +1517,7 @@ static int snd_timer_user_next_device(struct snd_timer_id __user *_tid)
6437 + } else {
6438 + if (id.subdevice < 0)
6439 + id.subdevice = 0;
6440 +- else
6441 ++ else if (id.subdevice < INT_MAX)
6442 + id.subdevice++;
6443 + }
6444 + }
6445 +diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
6446 +index 5bc3a7468e17..4d26bb010ddf 100644
6447 +--- a/sound/pci/hda/hda_codec.c
6448 ++++ b/sound/pci/hda/hda_codec.c
6449 +@@ -2887,8 +2887,9 @@ static int hda_codec_runtime_suspend(struct device *dev)
6450 + list_for_each_entry(pcm, &codec->pcm_list_head, list)
6451 + snd_pcm_suspend_all(pcm->pcm);
6452 + state = hda_call_codec_suspend(codec);
6453 +- if (codec_has_clkstop(codec) && codec_has_epss(codec) &&
6454 +- (state & AC_PWRST_CLK_STOP_OK))
6455 ++ if (codec->link_down_at_suspend ||
6456 ++ (codec_has_clkstop(codec) && codec_has_epss(codec) &&
6457 ++ (state & AC_PWRST_CLK_STOP_OK)))
6458 + snd_hdac_codec_link_down(&codec->core);
6459 + snd_hdac_link_power(&codec->core, false);
6460 + return 0;
6461 +diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
6462 +index 681c360f29f9..a8b1b31f161c 100644
6463 +--- a/sound/pci/hda/hda_codec.h
6464 ++++ b/sound/pci/hda/hda_codec.h
6465 +@@ -258,6 +258,7 @@ struct hda_codec {
6466 + unsigned int power_save_node:1; /* advanced PM for each widget */
6467 + unsigned int auto_runtime_pm:1; /* enable automatic codec runtime pm */
6468 + unsigned int force_pin_prefix:1; /* Add location prefix */
6469 ++ unsigned int link_down_at_suspend:1; /* link down at runtime suspend */
6470 + #ifdef CONFIG_PM
6471 + unsigned long power_on_acct;
6472 + unsigned long power_off_acct;
6473 +diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
6474 +index 7d7eb1354eee..ed39a77f9253 100644
6475 +--- a/sound/pci/hda/patch_hdmi.c
6476 ++++ b/sound/pci/hda/patch_hdmi.c
6477 +@@ -3741,6 +3741,11 @@ static int patch_atihdmi(struct hda_codec *codec)
6478 +
6479 + spec->chmap.channels_max = max(spec->chmap.channels_max, 8u);
6480 +
6481 ++ /* AMD GPUs have neither EPSS nor CLKSTOP bits, hence preventing
6482 ++ * the link-down as is. Tell the core to allow it.
6483 ++ */
6484 ++ codec->link_down_at_suspend = 1;
6485 ++
6486 + return 0;
6487 + }
6488 +
6489 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
6490 +index 06c2c80a045b..cb9a977bf188 100644
6491 +--- a/sound/pci/hda/patch_realtek.c
6492 ++++ b/sound/pci/hda/patch_realtek.c
6493 +@@ -2542,6 +2542,7 @@ static const struct snd_pci_quirk alc262_fixup_tbl[] = {
6494 + SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
6495 + SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
6496 + SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
6497 ++ SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
6498 + SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
6499 + SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
6500 + SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
6501 +@@ -4985,7 +4986,6 @@ static void alc_fixup_tpt440_dock(struct hda_codec *codec,
6502 + struct alc_spec *spec = codec->spec;
6503 +
6504 + if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6505 +- spec->shutup = alc_no_shutup; /* reduce click noise */
6506 + spec->reboot_notify = alc_d3_at_reboot; /* reduce noise */
6507 + spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6508 + codec->power_save_node = 0; /* avoid click noises */
6509 +@@ -5384,6 +5384,13 @@ static void alc274_fixup_bind_dacs(struct hda_codec *codec,
6510 + /* for hda_fixup_thinkpad_acpi() */
6511 + #include "thinkpad_helper.c"
6512 +
6513 ++static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
6514 ++ const struct hda_fixup *fix, int action)
6515 ++{
6516 ++ alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
6517 ++ hda_fixup_thinkpad_acpi(codec, fix, action);
6518 ++}
6519 ++
6520 + /* for dell wmi mic mute led */
6521 + #include "dell_wmi_helper.c"
6522 +
6523 +@@ -5927,7 +5934,7 @@ static const struct hda_fixup alc269_fixups[] = {
6524 + },
6525 + [ALC269_FIXUP_THINKPAD_ACPI] = {
6526 + .type = HDA_FIXUP_FUNC,
6527 +- .v.func = hda_fixup_thinkpad_acpi,
6528 ++ .v.func = alc_fixup_thinkpad_acpi,
6529 + .chained = true,
6530 + .chain_id = ALC269_FIXUP_SKU_IGNORE,
6531 + },
6532 +@@ -6577,8 +6584,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
6533 + SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
6534 + SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
6535 + SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6536 ++ SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6537 + SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6538 +- SND_PCI_QUIRK(0x17aa, 0x3138, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6539 ++ SND_PCI_QUIRK(0x17aa, 0x3136, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6540 + SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6541 + SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
6542 + SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
6543 +@@ -6756,6 +6764,12 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
6544 + {0x14, 0x90170110},
6545 + {0x19, 0x02a11030},
6546 + {0x21, 0x02211020}),
6547 ++ SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
6548 ++ {0x14, 0x90170110},
6549 ++ {0x19, 0x02a11030},
6550 ++ {0x1a, 0x02a11040},
6551 ++ {0x1b, 0x01014020},
6552 ++ {0x21, 0x0221101f}),
6553 + SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6554 + {0x12, 0x90a60140},
6555 + {0x14, 0x90170110},
6556 +diff --git a/sound/soc/cirrus/edb93xx.c b/sound/soc/cirrus/edb93xx.c
6557 +index c53bd6f2c2d7..3d011abaa266 100644
6558 +--- a/sound/soc/cirrus/edb93xx.c
6559 ++++ b/sound/soc/cirrus/edb93xx.c
6560 +@@ -67,7 +67,7 @@ static struct snd_soc_dai_link edb93xx_dai = {
6561 + .cpu_dai_name = "ep93xx-i2s",
6562 + .codec_name = "spi0.0",
6563 + .codec_dai_name = "cs4271-hifi",
6564 +- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF |
6565 ++ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
6566 + SND_SOC_DAIFMT_CBS_CFS,
6567 + .ops = &edb93xx_ops,
6568 + };
6569 +diff --git a/sound/soc/cirrus/ep93xx-i2s.c b/sound/soc/cirrus/ep93xx-i2s.c
6570 +index 934f8aefdd90..0dc3852c4621 100644
6571 +--- a/sound/soc/cirrus/ep93xx-i2s.c
6572 ++++ b/sound/soc/cirrus/ep93xx-i2s.c
6573 +@@ -51,7 +51,9 @@
6574 + #define EP93XX_I2S_WRDLEN_24 (1 << 0)
6575 + #define EP93XX_I2S_WRDLEN_32 (2 << 0)
6576 +
6577 +-#define EP93XX_I2S_LINCTRLDATA_R_JUST (1 << 2) /* Right justify */
6578 ++#define EP93XX_I2S_RXLINCTRLDATA_R_JUST BIT(1) /* Right justify */
6579 ++
6580 ++#define EP93XX_I2S_TXLINCTRLDATA_R_JUST BIT(2) /* Right justify */
6581 +
6582 + #define EP93XX_I2S_CLKCFG_LRS (1 << 0) /* lrclk polarity */
6583 + #define EP93XX_I2S_CLKCFG_CKP (1 << 1) /* Bit clock polarity */
6584 +@@ -170,25 +172,25 @@ static int ep93xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
6585 + unsigned int fmt)
6586 + {
6587 + struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(cpu_dai);
6588 +- unsigned int clk_cfg, lin_ctrl;
6589 ++ unsigned int clk_cfg;
6590 ++ unsigned int txlin_ctrl = 0;
6591 ++ unsigned int rxlin_ctrl = 0;
6592 +
6593 + clk_cfg = ep93xx_i2s_read_reg(info, EP93XX_I2S_RXCLKCFG);
6594 +- lin_ctrl = ep93xx_i2s_read_reg(info, EP93XX_I2S_RXLINCTRLDATA);
6595 +
6596 + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
6597 + case SND_SOC_DAIFMT_I2S:
6598 + clk_cfg |= EP93XX_I2S_CLKCFG_REL;
6599 +- lin_ctrl &= ~EP93XX_I2S_LINCTRLDATA_R_JUST;
6600 + break;
6601 +
6602 + case SND_SOC_DAIFMT_LEFT_J:
6603 + clk_cfg &= ~EP93XX_I2S_CLKCFG_REL;
6604 +- lin_ctrl &= ~EP93XX_I2S_LINCTRLDATA_R_JUST;
6605 + break;
6606 +
6607 + case SND_SOC_DAIFMT_RIGHT_J:
6608 + clk_cfg &= ~EP93XX_I2S_CLKCFG_REL;
6609 +- lin_ctrl |= EP93XX_I2S_LINCTRLDATA_R_JUST;
6610 ++ rxlin_ctrl |= EP93XX_I2S_RXLINCTRLDATA_R_JUST;
6611 ++ txlin_ctrl |= EP93XX_I2S_TXLINCTRLDATA_R_JUST;
6612 + break;
6613 +
6614 + default:
6615 +@@ -213,32 +215,32 @@ static int ep93xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
6616 + switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
6617 + case SND_SOC_DAIFMT_NB_NF:
6618 + /* Negative bit clock, lrclk low on left word */
6619 +- clk_cfg &= ~(EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_REL);
6620 ++ clk_cfg &= ~(EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_LRS);
6621 + break;
6622 +
6623 + case SND_SOC_DAIFMT_NB_IF:
6624 + /* Negative bit clock, lrclk low on right word */
6625 + clk_cfg &= ~EP93XX_I2S_CLKCFG_CKP;
6626 +- clk_cfg |= EP93XX_I2S_CLKCFG_REL;
6627 ++ clk_cfg |= EP93XX_I2S_CLKCFG_LRS;
6628 + break;
6629 +
6630 + case SND_SOC_DAIFMT_IB_NF:
6631 + /* Positive bit clock, lrclk low on left word */
6632 + clk_cfg |= EP93XX_I2S_CLKCFG_CKP;
6633 +- clk_cfg &= ~EP93XX_I2S_CLKCFG_REL;
6634 ++ clk_cfg &= ~EP93XX_I2S_CLKCFG_LRS;
6635 + break;
6636 +
6637 + case SND_SOC_DAIFMT_IB_IF:
6638 + /* Positive bit clock, lrclk low on right word */
6639 +- clk_cfg |= EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_REL;
6640 ++ clk_cfg |= EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_LRS;
6641 + break;
6642 + }
6643 +
6644 + /* Write new register values */
6645 + ep93xx_i2s_write_reg(info, EP93XX_I2S_RXCLKCFG, clk_cfg);
6646 + ep93xx_i2s_write_reg(info, EP93XX_I2S_TXCLKCFG, clk_cfg);
6647 +- ep93xx_i2s_write_reg(info, EP93XX_I2S_RXLINCTRLDATA, lin_ctrl);
6648 +- ep93xx_i2s_write_reg(info, EP93XX_I2S_TXLINCTRLDATA, lin_ctrl);
6649 ++ ep93xx_i2s_write_reg(info, EP93XX_I2S_RXLINCTRLDATA, rxlin_ctrl);
6650 ++ ep93xx_i2s_write_reg(info, EP93XX_I2S_TXLINCTRLDATA, txlin_ctrl);
6651 + return 0;
6652 + }
6653 +
6654 +diff --git a/sound/soc/cirrus/snappercl15.c b/sound/soc/cirrus/snappercl15.c
6655 +index 2334ec19e7eb..11ff7b2672b2 100644
6656 +--- a/sound/soc/cirrus/snappercl15.c
6657 ++++ b/sound/soc/cirrus/snappercl15.c
6658 +@@ -72,7 +72,7 @@ static struct snd_soc_dai_link snappercl15_dai = {
6659 + .codec_dai_name = "tlv320aic23-hifi",
6660 + .codec_name = "tlv320aic23-codec.0-001a",
6661 + .platform_name = "ep93xx-i2s",
6662 +- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF |
6663 ++ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
6664 + SND_SOC_DAIFMT_CBS_CFS,
6665 + .ops = &snappercl15_ops,
6666 + };
6667 +diff --git a/sound/soc/codecs/cs35l35.c b/sound/soc/codecs/cs35l35.c
6668 +index a4a2cb171bdf..bd6226bde45f 100644
6669 +--- a/sound/soc/codecs/cs35l35.c
6670 ++++ b/sound/soc/codecs/cs35l35.c
6671 +@@ -1105,6 +1105,7 @@ static struct regmap_config cs35l35_regmap = {
6672 + .readable_reg = cs35l35_readable_register,
6673 + .precious_reg = cs35l35_precious_register,
6674 + .cache_type = REGCACHE_RBTREE,
6675 ++ .use_single_rw = true,
6676 + };
6677 +
6678 + static irqreturn_t cs35l35_irq(int irq, void *data)
6679 +diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
6680 +index 53215b52e4f2..f8a06709f76d 100644
6681 +--- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c
6682 ++++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
6683 +@@ -64,14 +64,14 @@ static const struct snd_pcm_ops mtk_afe_pcm_ops = {
6684 + static int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
6685 + {
6686 + size_t size;
6687 +- struct snd_card *card = rtd->card->snd_card;
6688 + struct snd_pcm *pcm = rtd->pcm;
6689 + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
6690 + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
6691 +
6692 + size = afe->mtk_afe_hardware->buffer_bytes_max;
6693 + return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
6694 +- card->dev, size, size);
6695 ++ rtd->platform->dev,
6696 ++ size, size);
6697 + }
6698 +
6699 + static void mtk_afe_pcm_free(struct snd_pcm *pcm)
6700 +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
6701 +index 2d9709104ec5..b2b501ef57d7 100644
6702 +--- a/sound/soc/soc-dapm.c
6703 ++++ b/sound/soc/soc-dapm.c
6704 +@@ -433,6 +433,8 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
6705 + static void dapm_kcontrol_free(struct snd_kcontrol *kctl)
6706 + {
6707 + struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl);
6708 ++
6709 ++ list_del(&data->paths);
6710 + kfree(data->wlist);
6711 + kfree(data);
6712 + }
6713 +diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
6714 +index 36ef45b2e89d..09c4a4a7b5dd 100644
6715 +--- a/tools/perf/util/dso.c
6716 ++++ b/tools/perf/util/dso.c
6717 +@@ -354,6 +354,8 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
6718 + if ((strncmp(name, "[kernel.kallsyms]", 17) == 0) ||
6719 + (strncmp(name, "[guest.kernel.kallsyms", 22) == 0) ||
6720 + (strncmp(name, "[vdso]", 6) == 0) ||
6721 ++ (strncmp(name, "[vdso32]", 8) == 0) ||
6722 ++ (strncmp(name, "[vdsox32]", 9) == 0) ||
6723 + (strncmp(name, "[vsyscall]", 10) == 0)) {
6724 + m->kmod = false;
6725 +
6726 +diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
6727 +index f9157aed1289..d404bed7003a 100644
6728 +--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
6729 ++++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
6730 +@@ -113,6 +113,7 @@ struct intel_pt_decoder {
6731 + bool have_cyc;
6732 + bool fixup_last_mtc;
6733 + bool have_last_ip;
6734 ++ enum intel_pt_param_flags flags;
6735 + uint64_t pos;
6736 + uint64_t last_ip;
6737 + uint64_t ip;
6738 +@@ -226,6 +227,8 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params)
6739 + decoder->return_compression = params->return_compression;
6740 + decoder->branch_enable = params->branch_enable;
6741 +
6742 ++ decoder->flags = params->flags;
6743 ++
6744 + decoder->period = params->period;
6745 + decoder->period_type = params->period_type;
6746 +
6747 +@@ -1097,6 +1100,15 @@ static bool intel_pt_fup_event(struct intel_pt_decoder *decoder)
6748 + return ret;
6749 + }
6750 +
6751 ++static inline bool intel_pt_fup_with_nlip(struct intel_pt_decoder *decoder,
6752 ++ struct intel_pt_insn *intel_pt_insn,
6753 ++ uint64_t ip, int err)
6754 ++{
6755 ++ return decoder->flags & INTEL_PT_FUP_WITH_NLIP && !err &&
6756 ++ intel_pt_insn->branch == INTEL_PT_BR_INDIRECT &&
6757 ++ ip == decoder->ip + intel_pt_insn->length;
6758 ++}
6759 ++
6760 + static int intel_pt_walk_fup(struct intel_pt_decoder *decoder)
6761 + {
6762 + struct intel_pt_insn intel_pt_insn;
6763 +@@ -1109,10 +1121,11 @@ static int intel_pt_walk_fup(struct intel_pt_decoder *decoder)
6764 + err = intel_pt_walk_insn(decoder, &intel_pt_insn, ip);
6765 + if (err == INTEL_PT_RETURN)
6766 + return 0;
6767 +- if (err == -EAGAIN) {
6768 ++ if (err == -EAGAIN ||
6769 ++ intel_pt_fup_with_nlip(decoder, &intel_pt_insn, ip, err)) {
6770 + if (intel_pt_fup_event(decoder))
6771 + return 0;
6772 +- return err;
6773 ++ return -EAGAIN;
6774 + }
6775 + decoder->set_fup_tx_flags = false;
6776 + if (err)
6777 +@@ -1376,7 +1389,6 @@ static int intel_pt_overflow(struct intel_pt_decoder *decoder)
6778 + {
6779 + intel_pt_log("ERROR: Buffer overflow\n");
6780 + intel_pt_clear_tx_flags(decoder);
6781 +- decoder->have_tma = false;
6782 + decoder->cbr = 0;
6783 + decoder->timestamp_insn_cnt = 0;
6784 + decoder->pkt_state = INTEL_PT_STATE_ERR_RESYNC;
6785 +@@ -1604,7 +1616,6 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)
6786 + case INTEL_PT_PSB:
6787 + case INTEL_PT_TSC:
6788 + case INTEL_PT_TMA:
6789 +- case INTEL_PT_CBR:
6790 + case INTEL_PT_MODE_TSX:
6791 + case INTEL_PT_BAD:
6792 + case INTEL_PT_PSBEND:
6793 +@@ -1620,6 +1631,10 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)
6794 + decoder->pkt_step = 0;
6795 + return -ENOENT;
6796 +
6797 ++ case INTEL_PT_CBR:
6798 ++ intel_pt_calc_cbr(decoder);
6799 ++ break;
6800 ++
6801 + case INTEL_PT_OVF:
6802 + return intel_pt_overflow(decoder);
6803 +
6804 +diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
6805 +index fc1752d50019..51c18d67f4ca 100644
6806 +--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
6807 ++++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
6808 +@@ -60,6 +60,14 @@ enum {
6809 + INTEL_PT_ERR_MAX,
6810 + };
6811 +
6812 ++enum intel_pt_param_flags {
6813 ++ /*
6814 ++ * FUP packet can contain next linear instruction pointer instead of
6815 ++ * current linear instruction pointer.
6816 ++ */
6817 ++ INTEL_PT_FUP_WITH_NLIP = 1 << 0,
6818 ++};
6819 ++
6820 + struct intel_pt_state {
6821 + enum intel_pt_sample_type type;
6822 + int err;
6823 +@@ -106,6 +114,7 @@ struct intel_pt_params {
6824 + unsigned int mtc_period;
6825 + uint32_t tsc_ctc_ratio_n;
6826 + uint32_t tsc_ctc_ratio_d;
6827 ++ enum intel_pt_param_flags flags;
6828 + };
6829 +
6830 + struct intel_pt_decoder;
6831 +diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
6832 +index ba4c9dd18643..d426761a549d 100644
6833 +--- a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
6834 ++++ b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
6835 +@@ -366,7 +366,7 @@ static int intel_pt_get_cyc(unsigned int byte, const unsigned char *buf,
6836 + if (len < offs)
6837 + return INTEL_PT_NEED_MORE_BYTES;
6838 + byte = buf[offs++];
6839 +- payload |= (byte >> 1) << shift;
6840 ++ payload |= ((uint64_t)byte >> 1) << shift;
6841 + }
6842 +
6843 + packet->type = INTEL_PT_CYC;
6844 +diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
6845 +index 0effaff57020..38b25e826a45 100644
6846 +--- a/tools/perf/util/intel-pt.c
6847 ++++ b/tools/perf/util/intel-pt.c
6848 +@@ -751,6 +751,7 @@ static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt,
6849 + unsigned int queue_nr)
6850 + {
6851 + struct intel_pt_params params = { .get_trace = 0, };
6852 ++ struct perf_env *env = pt->machine->env;
6853 + struct intel_pt_queue *ptq;
6854 +
6855 + ptq = zalloc(sizeof(struct intel_pt_queue));
6856 +@@ -832,6 +833,9 @@ static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt,
6857 + }
6858 + }
6859 +
6860 ++ if (env->cpuid && !strncmp(env->cpuid, "GenuineIntel,6,92,", 18))
6861 ++ params.flags |= INTEL_PT_FUP_WITH_NLIP;
6862 ++
6863 + ptq->decoder = intel_pt_decoder_new(&params);
6864 + if (!ptq->decoder)
6865 + goto out_free;
6866 +@@ -1523,6 +1527,7 @@ static int intel_pt_sample(struct intel_pt_queue *ptq)
6867 +
6868 + if (intel_pt_is_switch_ip(ptq, state->to_ip)) {
6869 + switch (ptq->switch_state) {
6870 ++ case INTEL_PT_SS_NOT_TRACING:
6871 + case INTEL_PT_SS_UNKNOWN:
6872 + case INTEL_PT_SS_EXPECTING_SWITCH_IP:
6873 + err = intel_pt_next_tid(pt, ptq);
6874 +diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
6875 +index 2a4f16fc9819..8393b1c06027 100644
6876 +--- a/tools/testing/selftests/ftrace/test.d/functions
6877 ++++ b/tools/testing/selftests/ftrace/test.d/functions
6878 +@@ -15,14 +15,29 @@ reset_tracer() { # reset the current tracer
6879 + echo nop > current_tracer
6880 + }
6881 +
6882 +-reset_trigger() { # reset all current setting triggers
6883 +- grep -v ^# events/*/*/trigger |
6884 ++reset_trigger_file() {
6885 ++ # remove action triggers first
6886 ++ grep -H ':on[^:]*(' $@ |
6887 ++ while read line; do
6888 ++ cmd=`echo $line | cut -f2- -d: | cut -f1 -d" "`
6889 ++ file=`echo $line | cut -f1 -d:`
6890 ++ echo "!$cmd" >> $file
6891 ++ done
6892 ++ grep -Hv ^# $@ |
6893 + while read line; do
6894 + cmd=`echo $line | cut -f2- -d: | cut -f1 -d" "`
6895 +- echo "!$cmd" > `echo $line | cut -f1 -d:`
6896 ++ file=`echo $line | cut -f1 -d:`
6897 ++ echo "!$cmd" > $file
6898 + done
6899 + }
6900 +
6901 ++reset_trigger() { # reset all current setting triggers
6902 ++ if [ -d events/synthetic ]; then
6903 ++ reset_trigger_file events/synthetic/*/trigger
6904 ++ fi
6905 ++ reset_trigger_file events/*/*/trigger
6906 ++}
6907 ++
6908 + reset_events_filter() { # reset all current setting filters
6909 + grep -v ^none events/*/*/filter |
6910 + while read line; do