Magellan Linux

Contents of /trunk/kernel-alx/patches-4.19/0120-4.19.21-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3399 - (show annotations) (download)
Fri Aug 2 11:47:32 2019 UTC (4 years, 8 months ago) by niro
File size: 326682 byte(s)
-linux-4.19.21
1 diff --git a/Makefile b/Makefile
2 index f1859811dca1..ba5f14d38d8e 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,7 +1,7 @@
6 # SPDX-License-Identifier: GPL-2.0
7 VERSION = 4
8 PATCHLEVEL = 19
9 -SUBLEVEL = 20
10 +SUBLEVEL = 21
11 EXTRAVERSION =
12 NAME = "People's Front"
13
14 diff --git a/arch/arm/boot/dts/aspeed-bmc-arm-centriq2400-rep.dts b/arch/arm/boot/dts/aspeed-bmc-arm-centriq2400-rep.dts
15 index df1227613d48..c2ece0b91885 100644
16 --- a/arch/arm/boot/dts/aspeed-bmc-arm-centriq2400-rep.dts
17 +++ b/arch/arm/boot/dts/aspeed-bmc-arm-centriq2400-rep.dts
18 @@ -13,7 +13,7 @@
19 bootargs = "console=ttyS4,115200 earlyprintk";
20 };
21
22 - memory {
23 + memory@80000000 {
24 reg = <0x80000000 0x40000000>;
25 };
26
27 diff --git a/arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts b/arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts
28 index 7a291de02543..22dade6393d0 100644
29 --- a/arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts
30 +++ b/arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts
31 @@ -13,7 +13,7 @@
32 bootargs = "earlyprintk";
33 };
34
35 - memory {
36 + memory@80000000 {
37 reg = <0x80000000 0x20000000>;
38 };
39
40 diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts b/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts
41 index d598b6391362..024e52a6cd0f 100644
42 --- a/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts
43 +++ b/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts
44 @@ -14,7 +14,7 @@
45 bootargs = "console=ttyS4,115200 earlyprintk";
46 };
47
48 - memory {
49 + memory@80000000 {
50 reg = <0x80000000 0x40000000>;
51 };
52
53 @@ -322,4 +322,3 @@
54 &adc {
55 status = "okay";
56 };
57 -
58 diff --git a/arch/arm/boot/dts/aspeed-bmc-portwell-neptune.dts b/arch/arm/boot/dts/aspeed-bmc-portwell-neptune.dts
59 index 43ed13963d35..33d704541de6 100644
60 --- a/arch/arm/boot/dts/aspeed-bmc-portwell-neptune.dts
61 +++ b/arch/arm/boot/dts/aspeed-bmc-portwell-neptune.dts
62 @@ -17,7 +17,7 @@
63 bootargs = "console=ttyS4,115200 earlyprintk";
64 };
65
66 - memory {
67 + memory@80000000 {
68 reg = <0x80000000 0x20000000>;
69 };
70
71 diff --git a/arch/arm/boot/dts/gemini-dlink-dir-685.dts b/arch/arm/boot/dts/gemini-dlink-dir-685.dts
72 index 6f258b50eb44..502a361d1fe9 100644
73 --- a/arch/arm/boot/dts/gemini-dlink-dir-685.dts
74 +++ b/arch/arm/boot/dts/gemini-dlink-dir-685.dts
75 @@ -274,20 +274,16 @@
76 read-only;
77 };
78 /*
79 - * Between the boot loader and the rootfs is the kernel
80 - * in a custom Storlink format flashed from the boot
81 - * menu. The rootfs is in squashfs format.
82 + * This firmware image contains the kernel catenated
83 + * with the squashfs root filesystem. For some reason
84 + * this is called "upgrade" on the vendor system.
85 */
86 - partition@1800c0 {
87 - label = "rootfs";
88 - reg = <0x001800c0 0x01dbff40>;
89 - read-only;
90 - };
91 - partition@1f40000 {
92 + partition@40000 {
93 label = "upgrade";
94 - reg = <0x01f40000 0x00040000>;
95 + reg = <0x00040000 0x01f40000>;
96 read-only;
97 };
98 + /* RGDB, Residental Gateway Database? */
99 partition@1f80000 {
100 label = "rgdb";
101 reg = <0x01f80000 0x00040000>;
102 diff --git a/arch/arm/boot/dts/imx51-zii-rdu1.dts b/arch/arm/boot/dts/imx51-zii-rdu1.dts
103 index 469cce2c0357..6e80254c4562 100644
104 --- a/arch/arm/boot/dts/imx51-zii-rdu1.dts
105 +++ b/arch/arm/boot/dts/imx51-zii-rdu1.dts
106 @@ -477,6 +477,15 @@
107 };
108
109 &gpio1 {
110 + gpio-line-names = "", "", "", "",
111 + "", "", "", "",
112 + "", "hp-amp-shutdown-b", "", "",
113 + "", "", "", "",
114 + "", "", "", "",
115 + "", "", "", "",
116 + "", "", "", "",
117 + "", "", "", "";
118 +
119 unused-sd3-wp-gpio {
120 /*
121 * See pinctrl_esdhc1 below for more details on this
122 @@ -501,9 +510,6 @@
123 hpa1: amp@60 {
124 compatible = "ti,tpa6130a2";
125 reg = <0x60>;
126 - pinctrl-names = "default";
127 - pinctrl-0 = <&pinctrl_ampgpio>;
128 - power-gpio = <&gpio1 9 GPIO_ACTIVE_HIGH>;
129 Vdd-supply = <&reg_3p3v>;
130 };
131
132 @@ -677,7 +683,10 @@
133 };
134
135 &iomuxc {
136 - pinctrl_ampgpio: ampgpiogrp {
137 + pinctrl-names = "default";
138 + pinctrl-0 = <&pinctrl_hog>;
139 +
140 + pinctrl_hog: hoggrp {
141 fsl,pins = <
142 MX51_PAD_GPIO1_9__GPIO1_9 0x5e
143 >;
144 diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
145 index 766bbb8495b6..47e5b63339d1 100644
146 --- a/arch/arm/boot/dts/mmp2.dtsi
147 +++ b/arch/arm/boot/dts/mmp2.dtsi
148 @@ -220,12 +220,15 @@
149 status = "disabled";
150 };
151
152 - twsi2: i2c@d4025000 {
153 + twsi2: i2c@d4031000 {
154 compatible = "mrvl,mmp-twsi";
155 - reg = <0xd4025000 0x1000>;
156 - interrupts = <58>;
157 + reg = <0xd4031000 0x1000>;
158 + interrupt-parent = <&intcmux17>;
159 + interrupts = <0>;
160 clocks = <&soc_clocks MMP2_CLK_TWSI1>;
161 resets = <&soc_clocks MMP2_CLK_TWSI1>;
162 + #address-cells = <1>;
163 + #size-cells = <0>;
164 status = "disabled";
165 };
166
167 diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
168 index 490726b52216..9dc7ec7655cb 100644
169 --- a/arch/arm/boot/dts/omap4-sdp.dts
170 +++ b/arch/arm/boot/dts/omap4-sdp.dts
171 @@ -33,6 +33,7 @@
172 gpio = <&gpio2 16 GPIO_ACTIVE_HIGH>; /* gpio line 48 */
173 enable-active-high;
174 regulator-boot-on;
175 + startup-delay-us = <25000>;
176 };
177
178 vbat: fixedregulator-vbat {
179 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
180 index 0978282d5fc2..f574a5e0d589 100644
181 --- a/arch/arm/kernel/smp.c
182 +++ b/arch/arm/kernel/smp.c
183 @@ -693,6 +693,21 @@ void smp_send_stop(void)
184 pr_warn("SMP: failed to stop secondary CPUs\n");
185 }
186
187 +/* In case panic() and panic() called at the same time on CPU1 and CPU2,
188 + * and CPU 1 calls panic_smp_self_stop() before crash_smp_send_stop()
189 + * CPU1 can't receive the ipi irqs from CPU2, CPU1 will be always online,
190 + * kdump fails. So split out the panic_smp_self_stop() and add
191 + * set_cpu_online(smp_processor_id(), false).
192 + */
193 +void panic_smp_self_stop(void)
194 +{
195 + pr_debug("CPU %u will stop doing anything useful since another CPU has paniced\n",
196 + smp_processor_id());
197 + set_cpu_online(smp_processor_id(), false);
198 + while (1)
199 + cpu_relax();
200 +}
201 +
202 /*
203 * not supported here
204 */
205 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
206 index cd65ea4e9c54..ec3789ba17b8 100644
207 --- a/arch/arm/mach-omap2/omap_hwmod.c
208 +++ b/arch/arm/mach-omap2/omap_hwmod.c
209 @@ -2397,7 +2397,7 @@ static int __init _init(struct omap_hwmod *oh, void *data)
210 * a stub; implementing this properly requires iclk autoidle usecounting in
211 * the clock code. No return value.
212 */
213 -static void __init _setup_iclk_autoidle(struct omap_hwmod *oh)
214 +static void _setup_iclk_autoidle(struct omap_hwmod *oh)
215 {
216 struct omap_hwmod_ocp_if *os;
217
218 @@ -2428,7 +2428,7 @@ static void __init _setup_iclk_autoidle(struct omap_hwmod *oh)
219 * reset. Returns 0 upon success or a negative error code upon
220 * failure.
221 */
222 -static int __init _setup_reset(struct omap_hwmod *oh)
223 +static int _setup_reset(struct omap_hwmod *oh)
224 {
225 int r;
226
227 @@ -2489,7 +2489,7 @@ static int __init _setup_reset(struct omap_hwmod *oh)
228 *
229 * No return value.
230 */
231 -static void __init _setup_postsetup(struct omap_hwmod *oh)
232 +static void _setup_postsetup(struct omap_hwmod *oh)
233 {
234 u8 postsetup_state;
235
236 diff --git a/arch/arm/mach-pxa/cm-x300.c b/arch/arm/mach-pxa/cm-x300.c
237 index c5c0ab8ac9f9..024c1fbcc55a 100644
238 --- a/arch/arm/mach-pxa/cm-x300.c
239 +++ b/arch/arm/mach-pxa/cm-x300.c
240 @@ -558,7 +558,7 @@ static struct pxa3xx_u2d_platform_data cm_x300_u2d_platform_data = {
241 .exit = cm_x300_u2d_exit,
242 };
243
244 -static void cm_x300_init_u2d(void)
245 +static void __init cm_x300_init_u2d(void)
246 {
247 pxa3xx_set_u2d_info(&cm_x300_u2d_platform_data);
248 }
249 diff --git a/arch/arm/mach-pxa/littleton.c b/arch/arm/mach-pxa/littleton.c
250 index 9e132b3e48c6..9960ea158829 100644
251 --- a/arch/arm/mach-pxa/littleton.c
252 +++ b/arch/arm/mach-pxa/littleton.c
253 @@ -184,7 +184,7 @@ static struct pxafb_mach_info littleton_lcd_info = {
254 .lcd_conn = LCD_COLOR_TFT_16BPP,
255 };
256
257 -static void littleton_init_lcd(void)
258 +static void __init littleton_init_lcd(void)
259 {
260 pxa_set_fb_info(NULL, &littleton_lcd_info);
261 }
262 diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c
263 index e3851795d6d7..68a536de542d 100644
264 --- a/arch/arm/mach-pxa/zeus.c
265 +++ b/arch/arm/mach-pxa/zeus.c
266 @@ -559,7 +559,7 @@ static struct pxaohci_platform_data zeus_ohci_platform_data = {
267 .flags = ENABLE_PORT_ALL | POWER_SENSE_LOW,
268 };
269
270 -static void zeus_register_ohci(void)
271 +static void __init zeus_register_ohci(void)
272 {
273 /* Port 2 is shared between host and client interface. */
274 UP2OCR = UP2OCR_HXOE | UP2OCR_HXS | UP2OCR_DMPDE | UP2OCR_DPPDE;
275 diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
276 index 35b2e50f17fb..49bb9a020a09 100644
277 --- a/arch/arm64/include/asm/io.h
278 +++ b/arch/arm64/include/asm/io.h
279 @@ -106,7 +106,23 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
280 }
281
282 /* IO barriers */
283 -#define __iormb() rmb()
284 +#define __iormb(v) \
285 +({ \
286 + unsigned long tmp; \
287 + \
288 + rmb(); \
289 + \
290 + /* \
291 + * Create a dummy control dependency from the IO read to any \
292 + * later instructions. This ensures that a subsequent call to \
293 + * udelay() will be ordered due to the ISB in get_cycles(). \
294 + */ \
295 + asm volatile("eor %0, %1, %1\n" \
296 + "cbnz %0, ." \
297 + : "=r" (tmp) : "r" ((unsigned long)(v)) \
298 + : "memory"); \
299 +})
300 +
301 #define __iowmb() wmb()
302
303 #define mmiowb() do { } while (0)
304 @@ -131,10 +147,10 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
305 * following Normal memory access. Writes are ordered relative to any prior
306 * Normal memory access.
307 */
308 -#define readb(c) ({ u8 __v = readb_relaxed(c); __iormb(); __v; })
309 -#define readw(c) ({ u16 __v = readw_relaxed(c); __iormb(); __v; })
310 -#define readl(c) ({ u32 __v = readl_relaxed(c); __iormb(); __v; })
311 -#define readq(c) ({ u64 __v = readq_relaxed(c); __iormb(); __v; })
312 +#define readb(c) ({ u8 __v = readb_relaxed(c); __iormb(__v); __v; })
313 +#define readw(c) ({ u16 __v = readw_relaxed(c); __iormb(__v); __v; })
314 +#define readl(c) ({ u32 __v = readl_relaxed(c); __iormb(__v); __v; })
315 +#define readq(c) ({ u64 __v = readq_relaxed(c); __iormb(__v); __v; })
316
317 #define writeb(v,c) ({ __iowmb(); writeb_relaxed((v),(c)); })
318 #define writew(v,c) ({ __iowmb(); writew_relaxed((v),(c)); })
319 @@ -185,9 +201,9 @@ extern void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size);
320 /*
321 * io{read,write}{16,32,64}be() macros
322 */
323 -#define ioread16be(p) ({ __u16 __v = be16_to_cpu((__force __be16)__raw_readw(p)); __iormb(); __v; })
324 -#define ioread32be(p) ({ __u32 __v = be32_to_cpu((__force __be32)__raw_readl(p)); __iormb(); __v; })
325 -#define ioread64be(p) ({ __u64 __v = be64_to_cpu((__force __be64)__raw_readq(p)); __iormb(); __v; })
326 +#define ioread16be(p) ({ __u16 __v = be16_to_cpu((__force __be16)__raw_readw(p)); __iormb(__v); __v; })
327 +#define ioread32be(p) ({ __u32 __v = be32_to_cpu((__force __be32)__raw_readl(p)); __iormb(__v); __v; })
328 +#define ioread64be(p) ({ __u64 __v = be64_to_cpu((__force __be64)__raw_readq(p)); __iormb(__v); __v; })
329
330 #define iowrite16be(v,p) ({ __iowmb(); __raw_writew((__force __u16)cpu_to_be16(v), p); })
331 #define iowrite32be(v,p) ({ __iowmb(); __raw_writel((__force __u32)cpu_to_be32(v), p); })
332 diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h
333 index 98c4ce55d9c3..ad64d2c92ef5 100644
334 --- a/arch/arm64/include/uapi/asm/ptrace.h
335 +++ b/arch/arm64/include/uapi/asm/ptrace.h
336 @@ -130,7 +130,7 @@ struct user_sve_header {
337
338 /* Offset from the start of struct user_sve_header to the register data */
339 #define SVE_PT_REGS_OFFSET \
340 - ((sizeof(struct sve_context) + (SVE_VQ_BYTES - 1)) \
341 + ((sizeof(struct user_sve_header) + (SVE_VQ_BYTES - 1)) \
342 / SVE_VQ_BYTES * SVE_VQ_BYTES)
343
344 /*
345 diff --git a/arch/arm64/kernel/entry-ftrace.S b/arch/arm64/kernel/entry-ftrace.S
346 index 1175f5827ae1..295951f3172e 100644
347 --- a/arch/arm64/kernel/entry-ftrace.S
348 +++ b/arch/arm64/kernel/entry-ftrace.S
349 @@ -79,7 +79,6 @@
350 .macro mcount_get_lr reg
351 ldr \reg, [x29]
352 ldr \reg, [\reg, #8]
353 - mcount_adjust_addr \reg, \reg
354 .endm
355
356 .macro mcount_get_lr_addr reg
357 diff --git a/arch/mips/boot/dts/img/boston.dts b/arch/mips/boot/dts/img/boston.dts
358 index 65af3f6ba81c..84328afa3a55 100644
359 --- a/arch/mips/boot/dts/img/boston.dts
360 +++ b/arch/mips/boot/dts/img/boston.dts
361 @@ -141,6 +141,12 @@
362 #size-cells = <2>;
363 #interrupt-cells = <1>;
364
365 + eg20t_phub@2,0,0 {
366 + compatible = "pci8086,8801";
367 + reg = <0x00020000 0 0 0 0>;
368 + intel,eg20t-prefetch = <0>;
369 + };
370 +
371 eg20t_mac@2,0,1 {
372 compatible = "pci8086,8802";
373 reg = <0x00020100 0 0 0 0>;
374 diff --git a/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h b/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h
375 index e9cc62cfac99..ff50aeb1a933 100644
376 --- a/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h
377 +++ b/arch/mips/include/asm/mach-jz4740/jz4740_mmc.h
378 @@ -4,8 +4,6 @@
379
380 struct jz4740_mmc_platform_data {
381 int gpio_power;
382 - int gpio_card_detect;
383 - int gpio_read_only;
384 unsigned card_detect_active_low:1;
385 unsigned read_only_active_low:1;
386 unsigned power_active_low:1;
387 diff --git a/arch/mips/include/uapi/asm/inst.h b/arch/mips/include/uapi/asm/inst.h
388 index c05dcf5ab414..273ef58f4d43 100644
389 --- a/arch/mips/include/uapi/asm/inst.h
390 +++ b/arch/mips/include/uapi/asm/inst.h
391 @@ -369,8 +369,8 @@ enum mm_32a_minor_op {
392 mm_ext_op = 0x02c,
393 mm_pool32axf_op = 0x03c,
394 mm_srl32_op = 0x040,
395 + mm_srlv32_op = 0x050,
396 mm_sra_op = 0x080,
397 - mm_srlv32_op = 0x090,
398 mm_rotr_op = 0x0c0,
399 mm_lwxs_op = 0x118,
400 mm_addu32_op = 0x150,
401 diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
402 index af0c8ace0141..705593d40d12 100644
403 --- a/arch/mips/jz4740/board-qi_lb60.c
404 +++ b/arch/mips/jz4740/board-qi_lb60.c
405 @@ -43,7 +43,6 @@
406 #include "clock.h"
407
408 /* GPIOs */
409 -#define QI_LB60_GPIO_SD_CD JZ_GPIO_PORTD(0)
410 #define QI_LB60_GPIO_SD_VCC_EN_N JZ_GPIO_PORTD(2)
411
412 #define QI_LB60_GPIO_KEYOUT(x) (JZ_GPIO_PORTC(10) + (x))
413 @@ -386,12 +385,18 @@ static struct platform_device qi_lb60_gpio_keys = {
414 };
415
416 static struct jz4740_mmc_platform_data qi_lb60_mmc_pdata = {
417 - .gpio_card_detect = QI_LB60_GPIO_SD_CD,
418 - .gpio_read_only = -1,
419 .gpio_power = QI_LB60_GPIO_SD_VCC_EN_N,
420 .power_active_low = 1,
421 };
422
423 +static struct gpiod_lookup_table qi_lb60_mmc_gpio_table = {
424 + .dev_id = "jz4740-mmc.0",
425 + .table = {
426 + GPIO_LOOKUP("GPIOD", 0, "cd", GPIO_ACTIVE_HIGH),
427 + { },
428 + },
429 +};
430 +
431 /* beeper */
432 static struct pwm_lookup qi_lb60_pwm_lookup[] = {
433 PWM_LOOKUP("jz4740-pwm", 4, "pwm-beeper", NULL, 0,
434 @@ -500,6 +505,7 @@ static int __init qi_lb60_init_platform_devices(void)
435 gpiod_add_lookup_table(&qi_lb60_audio_gpio_table);
436 gpiod_add_lookup_table(&qi_lb60_nand_gpio_table);
437 gpiod_add_lookup_table(&qi_lb60_spigpio_gpio_table);
438 + gpiod_add_lookup_table(&qi_lb60_mmc_gpio_table);
439
440 spi_register_board_info(qi_lb60_spi_board_info,
441 ARRAY_SIZE(qi_lb60_spi_board_info));
442 diff --git a/arch/mips/ralink/Kconfig b/arch/mips/ralink/Kconfig
443 index 1f9cb0e3c79a..613d61763433 100644
444 --- a/arch/mips/ralink/Kconfig
445 +++ b/arch/mips/ralink/Kconfig
446 @@ -38,6 +38,7 @@ choice
447
448 config SOC_MT7620
449 bool "MT7620/8"
450 + select CPU_MIPSR2_IRQ_VI
451 select HW_HAS_PCI
452
453 config SOC_MT7621
454 diff --git a/arch/nds32/mm/Makefile b/arch/nds32/mm/Makefile
455 index 6b6855852223..7c5c15ad854a 100644
456 --- a/arch/nds32/mm/Makefile
457 +++ b/arch/nds32/mm/Makefile
458 @@ -4,4 +4,8 @@ obj-y := extable.o tlb.o \
459
460 obj-$(CONFIG_ALIGNMENT_TRAP) += alignment.o
461 obj-$(CONFIG_HIGHMEM) += highmem.o
462 -CFLAGS_proc-n13.o += -fomit-frame-pointer
463 +
464 +ifdef CONFIG_FUNCTION_TRACER
465 +CFLAGS_REMOVE_proc.o = $(CC_FLAGS_FTRACE)
466 +endif
467 +CFLAGS_proc.o += -fomit-frame-pointer
468 diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h
469 index 1e7a33592e29..15bc07a31c46 100644
470 --- a/arch/powerpc/include/asm/fadump.h
471 +++ b/arch/powerpc/include/asm/fadump.h
472 @@ -200,7 +200,7 @@ struct fad_crash_memory_ranges {
473 unsigned long long size;
474 };
475
476 -extern int is_fadump_boot_memory_area(u64 addr, ulong size);
477 +extern int is_fadump_memory_area(u64 addr, ulong size);
478 extern int early_init_dt_scan_fw_dump(unsigned long node,
479 const char *uname, int depth, void *data);
480 extern int fadump_reserve_mem(void);
481 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
482 index bac225bb7f64..23bea99bf8d5 100644
483 --- a/arch/powerpc/include/asm/uaccess.h
484 +++ b/arch/powerpc/include/asm/uaccess.h
485 @@ -63,7 +63,7 @@ static inline int __access_ok(unsigned long addr, unsigned long size,
486 #endif
487
488 #define access_ok(type, addr, size) \
489 - (__chk_user_ptr(addr), \
490 + (__chk_user_ptr(addr), (void)(type), \
491 __access_ok((__force unsigned long)(addr), (size), get_fs()))
492
493 /*
494 diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
495 index a711d22339ea..c02c95287a5f 100644
496 --- a/arch/powerpc/kernel/fadump.c
497 +++ b/arch/powerpc/kernel/fadump.c
498 @@ -118,13 +118,19 @@ int __init early_init_dt_scan_fw_dump(unsigned long node,
499
500 /*
501 * If fadump is registered, check if the memory provided
502 - * falls within boot memory area.
503 + * falls within boot memory area and reserved memory area.
504 */
505 -int is_fadump_boot_memory_area(u64 addr, ulong size)
506 +int is_fadump_memory_area(u64 addr, ulong size)
507 {
508 + u64 d_start = fw_dump.reserve_dump_area_start;
509 + u64 d_end = d_start + fw_dump.reserve_dump_area_size;
510 +
511 if (!fw_dump.dump_registered)
512 return 0;
513
514 + if (((addr + size) > d_start) && (addr <= d_end))
515 + return 1;
516 +
517 return (addr + size) > RMA_START && addr <= fw_dump.boot_memory_size;
518 }
519
520 diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
521 index 07ae018e550e..53016c753f3c 100644
522 --- a/arch/powerpc/kernel/vmlinux.lds.S
523 +++ b/arch/powerpc/kernel/vmlinux.lds.S
524 @@ -296,6 +296,10 @@ SECTIONS
525 #ifdef CONFIG_PPC32
526 .data : AT(ADDR(.data) - LOAD_OFFSET) {
527 DATA_DATA
528 +#ifdef CONFIG_UBSAN
529 + *(.data..Lubsan_data*)
530 + *(.data..Lubsan_type*)
531 +#endif
532 *(.data.rel*)
533 *(SDATA_MAIN)
534 *(.sdata2)
535 diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
536 index eba5756d5b41..79b79408d92e 100644
537 --- a/arch/powerpc/kvm/powerpc.c
538 +++ b/arch/powerpc/kvm/powerpc.c
539 @@ -543,8 +543,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
540 #ifdef CONFIG_PPC_BOOK3S_64
541 case KVM_CAP_SPAPR_TCE:
542 case KVM_CAP_SPAPR_TCE_64:
543 - /* fallthrough */
544 + r = 1;
545 + break;
546 case KVM_CAP_SPAPR_TCE_VFIO:
547 + r = !!cpu_has_feature(CPU_FTR_HVMODE);
548 + break;
549 case KVM_CAP_PPC_RTAS:
550 case KVM_CAP_PPC_FIXUP_HCALL:
551 case KVM_CAP_PPC_ENABLE_HCALL:
552 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
553 index d51cf5f4e45e..365526ee29b8 100644
554 --- a/arch/powerpc/mm/fault.c
555 +++ b/arch/powerpc/mm/fault.c
556 @@ -221,7 +221,9 @@ static int mm_fault_error(struct pt_regs *regs, unsigned long addr,
557 static bool bad_kernel_fault(bool is_exec, unsigned long error_code,
558 unsigned long address)
559 {
560 - if (is_exec && (error_code & (DSISR_NOEXEC_OR_G | DSISR_KEYFAULT))) {
561 + /* NX faults set DSISR_PROTFAULT on the 8xx, DSISR_NOEXEC_OR_G on others */
562 + if (is_exec && (error_code & (DSISR_NOEXEC_OR_G | DSISR_KEYFAULT |
563 + DSISR_PROTFAULT))) {
564 printk_ratelimited(KERN_CRIT "kernel tried to execute"
565 " exec-protected page (%lx) -"
566 "exploit attempt? (uid: %d)\n",
567 diff --git a/arch/powerpc/perf/isa207-common.c b/arch/powerpc/perf/isa207-common.c
568 index 177de814286f..6a2f65d3d088 100644
569 --- a/arch/powerpc/perf/isa207-common.c
570 +++ b/arch/powerpc/perf/isa207-common.c
571 @@ -226,8 +226,13 @@ void isa207_get_mem_weight(u64 *weight)
572 u64 mmcra = mfspr(SPRN_MMCRA);
573 u64 exp = MMCRA_THR_CTR_EXP(mmcra);
574 u64 mantissa = MMCRA_THR_CTR_MANT(mmcra);
575 + u64 sier = mfspr(SPRN_SIER);
576 + u64 val = (sier & ISA207_SIER_TYPE_MASK) >> ISA207_SIER_TYPE_SHIFT;
577
578 - *weight = mantissa << (2 * exp);
579 + if (val == 0 || val == 7)
580 + *weight = 0;
581 + else
582 + *weight = mantissa << (2 * exp);
583 }
584
585 int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp)
586 diff --git a/arch/powerpc/platforms/powernv/pci-ioda-tce.c b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
587 index fe9691040f54..7639b2168755 100644
588 --- a/arch/powerpc/platforms/powernv/pci-ioda-tce.c
589 +++ b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
590 @@ -299,7 +299,7 @@ long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
591 if (alloc_userspace_copy) {
592 offset = 0;
593 uas = pnv_pci_ioda2_table_do_alloc_pages(nid, level_shift,
594 - levels, tce_table_size, &offset,
595 + tmplevels, tce_table_size, &offset,
596 &total_allocated_uas);
597 if (!uas)
598 goto free_tces_exit;
599 diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
600 index a0b20c03f078..e3010b14aea5 100644
601 --- a/arch/powerpc/platforms/pseries/dlpar.c
602 +++ b/arch/powerpc/platforms/pseries/dlpar.c
603 @@ -272,6 +272,8 @@ int dlpar_detach_node(struct device_node *dn)
604 if (rc)
605 return rc;
606
607 + of_node_put(dn);
608 +
609 return 0;
610 }
611
612 diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
613 index c1578f54c626..e4c658cda3a7 100644
614 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c
615 +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
616 @@ -389,8 +389,11 @@ static bool lmb_is_removable(struct drmem_lmb *lmb)
617 phys_addr = lmb->base_addr;
618
619 #ifdef CONFIG_FA_DUMP
620 - /* Don't hot-remove memory that falls in fadump boot memory area */
621 - if (is_fadump_boot_memory_area(phys_addr, block_sz))
622 + /*
623 + * Don't hot-remove memory that falls in fadump boot memory area
624 + * and memory that is reserved for capturing old kernel memory.
625 + */
626 + if (is_fadump_memory_area(phys_addr, block_sz))
627 return false;
628 #endif
629
630 diff --git a/arch/s390/include/uapi/asm/zcrypt.h b/arch/s390/include/uapi/asm/zcrypt.h
631 index 2bb1f3bb98ac..48c784f2101a 100644
632 --- a/arch/s390/include/uapi/asm/zcrypt.h
633 +++ b/arch/s390/include/uapi/asm/zcrypt.h
634 @@ -147,8 +147,8 @@ struct ica_xcRB {
635 * @cprb_len: CPRB header length [0x0020]
636 * @cprb_ver_id: CPRB version id. [0x04]
637 * @pad_000: Alignment pad bytes
638 - * @flags: Admin cmd [0x80] or functional cmd [0x00]
639 - * @func_id: Function id / subtype [0x5434]
640 + * @flags: Admin bit [0x80], Special bit [0x20]
641 + * @func_id: Function id / subtype [0x5434] "T4"
642 * @source_id: Source id [originator id]
643 * @target_id: Target id [usage/ctrl domain id]
644 * @ret_code: Return code
645 diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c
646 index e59c577ed871..c70bc7809dda 100644
647 --- a/arch/sh/boards/mach-kfr2r09/setup.c
648 +++ b/arch/sh/boards/mach-kfr2r09/setup.c
649 @@ -25,7 +25,6 @@
650 #include <linux/memblock.h>
651 #include <linux/mfd/tmio.h>
652 #include <linux/mmc/host.h>
653 -#include <linux/mtd/onenand.h>
654 #include <linux/mtd/physmap.h>
655 #include <linux/platform_data/lv5207lp.h>
656 #include <linux/platform_device.h>
657 diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h
658 index 7485398d0737..9c04562310b3 100644
659 --- a/arch/um/include/asm/pgtable.h
660 +++ b/arch/um/include/asm/pgtable.h
661 @@ -197,12 +197,17 @@ static inline pte_t pte_mkold(pte_t pte)
662
663 static inline pte_t pte_wrprotect(pte_t pte)
664 {
665 - pte_clear_bits(pte, _PAGE_RW);
666 + if (likely(pte_get_bits(pte, _PAGE_RW)))
667 + pte_clear_bits(pte, _PAGE_RW);
668 + else
669 + return pte;
670 return(pte_mknewprot(pte));
671 }
672
673 static inline pte_t pte_mkread(pte_t pte)
674 {
675 + if (unlikely(pte_get_bits(pte, _PAGE_USER)))
676 + return pte;
677 pte_set_bits(pte, _PAGE_USER);
678 return(pte_mknewprot(pte));
679 }
680 @@ -221,6 +226,8 @@ static inline pte_t pte_mkyoung(pte_t pte)
681
682 static inline pte_t pte_mkwrite(pte_t pte)
683 {
684 + if (unlikely(pte_get_bits(pte, _PAGE_RW)))
685 + return pte;
686 pte_set_bits(pte, _PAGE_RW);
687 return(pte_mknewprot(pte));
688 }
689 diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
690 index 155fa4b53c56..d0b186264941 100644
691 --- a/arch/x86/events/intel/core.c
692 +++ b/arch/x86/events/intel/core.c
693 @@ -3439,6 +3439,11 @@ static void free_excl_cntrs(int cpu)
694 }
695
696 static void intel_pmu_cpu_dying(int cpu)
697 +{
698 + fini_debug_store_on_cpu(cpu);
699 +}
700 +
701 +static void intel_pmu_cpu_dead(int cpu)
702 {
703 struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
704 struct intel_shared_regs *pc;
705 @@ -3451,8 +3456,6 @@ static void intel_pmu_cpu_dying(int cpu)
706 }
707
708 free_excl_cntrs(cpu);
709 -
710 - fini_debug_store_on_cpu(cpu);
711 }
712
713 static void intel_pmu_sched_task(struct perf_event_context *ctx,
714 @@ -3541,6 +3544,7 @@ static __initconst const struct x86_pmu core_pmu = {
715 .cpu_prepare = intel_pmu_cpu_prepare,
716 .cpu_starting = intel_pmu_cpu_starting,
717 .cpu_dying = intel_pmu_cpu_dying,
718 + .cpu_dead = intel_pmu_cpu_dead,
719 };
720
721 static struct attribute *intel_pmu_attrs[];
722 @@ -3581,6 +3585,8 @@ static __initconst const struct x86_pmu intel_pmu = {
723 .cpu_prepare = intel_pmu_cpu_prepare,
724 .cpu_starting = intel_pmu_cpu_starting,
725 .cpu_dying = intel_pmu_cpu_dying,
726 + .cpu_dead = intel_pmu_cpu_dead,
727 +
728 .guest_get_msrs = intel_guest_get_msrs,
729 .sched_task = intel_pmu_sched_task,
730 };
731 diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
732 index c07bee31abe8..b10e04387f38 100644
733 --- a/arch/x86/events/intel/uncore_snbep.c
734 +++ b/arch/x86/events/intel/uncore_snbep.c
735 @@ -1222,6 +1222,8 @@ static struct pci_driver snbep_uncore_pci_driver = {
736 .id_table = snbep_uncore_pci_ids,
737 };
738
739 +#define NODE_ID_MASK 0x7
740 +
741 /*
742 * build pci bus to socket mapping
743 */
744 @@ -1243,7 +1245,7 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
745 err = pci_read_config_dword(ubox_dev, nodeid_loc, &config);
746 if (err)
747 break;
748 - nodeid = config;
749 + nodeid = config & NODE_ID_MASK;
750 /* get the Node ID mapping */
751 err = pci_read_config_dword(ubox_dev, idmap_loc, &config);
752 if (err)
753 diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
754 index 69dcdf195b61..fa2c93cb42a2 100644
755 --- a/arch/x86/include/asm/fpu/internal.h
756 +++ b/arch/x86/include/asm/fpu/internal.h
757 @@ -106,6 +106,9 @@ extern void fpstate_sanitize_xstate(struct fpu *fpu);
758 #define user_insn(insn, output, input...) \
759 ({ \
760 int err; \
761 + \
762 + might_fault(); \
763 + \
764 asm volatile(ASM_STAC "\n" \
765 "1:" #insn "\n\t" \
766 "2: " ASM_CLAC "\n" \
767 diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
768 index 807d06a7acac..1e0c4c74195c 100644
769 --- a/arch/x86/kernel/cpu/bugs.c
770 +++ b/arch/x86/kernel/cpu/bugs.c
771 @@ -69,7 +69,7 @@ void __init check_bugs(void)
772 * identify_boot_cpu() initialized SMT support information, let the
773 * core code know.
774 */
775 - cpu_smt_check_topology_early();
776 + cpu_smt_check_topology();
777
778 if (!IS_ENABLED(CONFIG_SMP)) {
779 pr_info("CPU: ");
780 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
781 index cdbedeb3f3db..f9e7096b1804 100644
782 --- a/arch/x86/kernel/cpu/mcheck/mce.c
783 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
784 @@ -783,6 +783,7 @@ static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp,
785 quirk_no_way_out(i, m, regs);
786
787 if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) {
788 + m->bank = i;
789 mce_read_aux(m, i);
790 *msg = tmp;
791 return 1;
792 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
793 index f1d3fe5a0c65..02ac8fa0cd6d 100644
794 --- a/arch/x86/kvm/svm.c
795 +++ b/arch/x86/kvm/svm.c
796 @@ -5837,6 +5837,13 @@ static bool svm_cpu_has_accelerated_tpr(void)
797
798 static bool svm_has_emulated_msr(int index)
799 {
800 + switch (index) {
801 + case MSR_IA32_MCG_EXT_CTL:
802 + return false;
803 + default:
804 + break;
805 + }
806 +
807 return true;
808 }
809
810 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
811 index 39a0e34ff676..0b2e13dd517b 100644
812 --- a/arch/x86/kvm/vmx.c
813 +++ b/arch/x86/kvm/vmx.c
814 @@ -27,6 +27,7 @@
815 #include <linux/mm.h>
816 #include <linux/highmem.h>
817 #include <linux/sched.h>
818 +#include <linux/sched/smt.h>
819 #include <linux/moduleparam.h>
820 #include <linux/mod_devicetable.h>
821 #include <linux/trace_events.h>
822 @@ -8469,6 +8470,7 @@ static void free_nested(struct vcpu_vmx *vmx)
823 if (!vmx->nested.vmxon && !vmx->nested.smm.vmxon)
824 return;
825
826 + hrtimer_cancel(&vmx->nested.preemption_timer);
827 vmx->nested.vmxon = false;
828 vmx->nested.smm.vmxon = false;
829 free_vpid(vmx->nested.vpid02);
830 @@ -11128,7 +11130,7 @@ static int vmx_vm_init(struct kvm *kvm)
831 * Warn upon starting the first VM in a potentially
832 * insecure environment.
833 */
834 - if (cpu_smt_control == CPU_SMT_ENABLED)
835 + if (sched_smt_active())
836 pr_warn_once(L1TF_MSG_SMT);
837 if (l1tf_vmx_mitigation == VMENTER_L1D_FLUSH_NEVER)
838 pr_warn_once(L1TF_MSG_L1D);
839 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
840 index 5a9a3ebe8fba..3a7cf7c6b28a 100644
841 --- a/arch/x86/kvm/x86.c
842 +++ b/arch/x86/kvm/x86.c
843 @@ -4904,6 +4904,13 @@ int kvm_read_guest_virt(struct kvm_vcpu *vcpu,
844 {
845 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0;
846
847 + /*
848 + * FIXME: this should call handle_emulation_failure if X86EMUL_IO_NEEDED
849 + * is returned, but our callers are not ready for that and they blindly
850 + * call kvm_inject_page_fault. Ensure that they at least do not leak
851 + * uninitialized kernel stack memory into cr2 and error code.
852 + */
853 + memset(exception, 0, sizeof(*exception));
854 return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, access,
855 exception);
856 }
857 diff --git a/arch/x86/pci/broadcom_bus.c b/arch/x86/pci/broadcom_bus.c
858 index 526536c81ddc..ca1e8e6dccc8 100644
859 --- a/arch/x86/pci/broadcom_bus.c
860 +++ b/arch/x86/pci/broadcom_bus.c
861 @@ -50,8 +50,8 @@ static void __init cnb20le_res(u8 bus, u8 slot, u8 func)
862 word1 = read_pci_config_16(bus, slot, func, 0xc0);
863 word2 = read_pci_config_16(bus, slot, func, 0xc2);
864 if (word1 != word2) {
865 - res.start = (word1 << 16) | 0x0000;
866 - res.end = (word2 << 16) | 0xffff;
867 + res.start = ((resource_size_t) word1 << 16) | 0x0000;
868 + res.end = ((resource_size_t) word2 << 16) | 0xffff;
869 res.flags = IORESOURCE_MEM;
870 update_res(info, res.start, res.end, res.flags, 0);
871 }
872 diff --git a/arch/xtensa/boot/dts/xtfpga.dtsi b/arch/xtensa/boot/dts/xtfpga.dtsi
873 index 1090528825ec..e46ae07bab05 100644
874 --- a/arch/xtensa/boot/dts/xtfpga.dtsi
875 +++ b/arch/xtensa/boot/dts/xtfpga.dtsi
876 @@ -103,7 +103,7 @@
877 };
878 };
879
880 - spi0: spi-master@0d0a0000 {
881 + spi0: spi@0d0a0000 {
882 compatible = "cdns,xtfpga-spi";
883 #address-cells = <1>;
884 #size-cells = <0>;
885 diff --git a/crypto/Kconfig b/crypto/Kconfig
886 index 59e32623a7ce..0fb9586766a7 100644
887 --- a/crypto/Kconfig
888 +++ b/crypto/Kconfig
889 @@ -1056,7 +1056,8 @@ config CRYPTO_AES_TI
890 8 for decryption), this implementation only uses just two S-boxes of
891 256 bytes each, and attempts to eliminate data dependent latencies by
892 prefetching the entire table into the cache at the start of each
893 - block.
894 + block. Interrupts are also disabled to avoid races where cachelines
895 + are evicted when the CPU is interrupted to do something else.
896
897 config CRYPTO_AES_586
898 tristate "AES cipher algorithms (i586)"
899 diff --git a/crypto/aes_ti.c b/crypto/aes_ti.c
900 index 03023b2290e8..1ff9785b30f5 100644
901 --- a/crypto/aes_ti.c
902 +++ b/crypto/aes_ti.c
903 @@ -269,6 +269,7 @@ static void aesti_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
904 const u32 *rkp = ctx->key_enc + 4;
905 int rounds = 6 + ctx->key_length / 4;
906 u32 st0[4], st1[4];
907 + unsigned long flags;
908 int round;
909
910 st0[0] = ctx->key_enc[0] ^ get_unaligned_le32(in);
911 @@ -276,6 +277,12 @@ static void aesti_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
912 st0[2] = ctx->key_enc[2] ^ get_unaligned_le32(in + 8);
913 st0[3] = ctx->key_enc[3] ^ get_unaligned_le32(in + 12);
914
915 + /*
916 + * Temporarily disable interrupts to avoid races where cachelines are
917 + * evicted when the CPU is interrupted to do something else.
918 + */
919 + local_irq_save(flags);
920 +
921 st0[0] ^= __aesti_sbox[ 0] ^ __aesti_sbox[128];
922 st0[1] ^= __aesti_sbox[32] ^ __aesti_sbox[160];
923 st0[2] ^= __aesti_sbox[64] ^ __aesti_sbox[192];
924 @@ -300,6 +307,8 @@ static void aesti_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
925 put_unaligned_le32(subshift(st1, 1) ^ rkp[5], out + 4);
926 put_unaligned_le32(subshift(st1, 2) ^ rkp[6], out + 8);
927 put_unaligned_le32(subshift(st1, 3) ^ rkp[7], out + 12);
928 +
929 + local_irq_restore(flags);
930 }
931
932 static void aesti_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
933 @@ -308,6 +317,7 @@ static void aesti_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
934 const u32 *rkp = ctx->key_dec + 4;
935 int rounds = 6 + ctx->key_length / 4;
936 u32 st0[4], st1[4];
937 + unsigned long flags;
938 int round;
939
940 st0[0] = ctx->key_dec[0] ^ get_unaligned_le32(in);
941 @@ -315,6 +325,12 @@ static void aesti_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
942 st0[2] = ctx->key_dec[2] ^ get_unaligned_le32(in + 8);
943 st0[3] = ctx->key_dec[3] ^ get_unaligned_le32(in + 12);
944
945 + /*
946 + * Temporarily disable interrupts to avoid races where cachelines are
947 + * evicted when the CPU is interrupted to do something else.
948 + */
949 + local_irq_save(flags);
950 +
951 st0[0] ^= __aesti_inv_sbox[ 0] ^ __aesti_inv_sbox[128];
952 st0[1] ^= __aesti_inv_sbox[32] ^ __aesti_inv_sbox[160];
953 st0[2] ^= __aesti_inv_sbox[64] ^ __aesti_inv_sbox[192];
954 @@ -339,6 +355,8 @@ static void aesti_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
955 put_unaligned_le32(inv_subshift(st1, 1) ^ rkp[5], out + 4);
956 put_unaligned_le32(inv_subshift(st1, 2) ^ rkp[6], out + 8);
957 put_unaligned_le32(inv_subshift(st1, 3) ^ rkp[7], out + 12);
958 +
959 + local_irq_restore(flags);
960 }
961
962 static struct crypto_alg aes_alg = {
963 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
964 index 02c6fd9caff7..f008ba7c9ced 100644
965 --- a/drivers/acpi/apei/ghes.c
966 +++ b/drivers/acpi/apei/ghes.c
967 @@ -691,6 +691,8 @@ static void __ghes_panic(struct ghes *ghes)
968 {
969 __ghes_print_estatus(KERN_EMERG, ghes->generic, ghes->estatus);
970
971 + ghes_clear_estatus(ghes);
972 +
973 /* reboot to log the error! */
974 if (!panic_timeout)
975 panic_timeout = ghes_panic_timeout;
976 diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c
977 index 9d52743080a4..c336784d0bcb 100644
978 --- a/drivers/acpi/spcr.c
979 +++ b/drivers/acpi/spcr.c
980 @@ -148,6 +148,13 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)
981 }
982
983 switch (table->baud_rate) {
984 + case 0:
985 + /*
986 + * SPCR 1.04 defines 0 as a preconfigured state of UART.
987 + * Assume firmware or bootloader configures console correctly.
988 + */
989 + baud_rate = 0;
990 + break;
991 case 3:
992 baud_rate = 9600;
993 break;
994 @@ -196,6 +203,10 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)
995 * UART so don't attempt to change to the baud rate state
996 * in the table because driver cannot calculate the dividers
997 */
998 + baud_rate = 0;
999 + }
1000 +
1001 + if (!baud_rate) {
1002 snprintf(opts, sizeof(opts), "%s,%s,0x%llx", uart, iotype,
1003 table->serial_port.address);
1004 } else {
1005 diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c
1006 index 10ecb232245d..03867f539f3a 100644
1007 --- a/drivers/ata/sata_rcar.c
1008 +++ b/drivers/ata/sata_rcar.c
1009 @@ -895,7 +895,9 @@ static int sata_rcar_probe(struct platform_device *pdev)
1010 int ret = 0;
1011
1012 irq = platform_get_irq(pdev, 0);
1013 - if (irq <= 0)
1014 + if (irq < 0)
1015 + return irq;
1016 + if (!irq)
1017 return -EINVAL;
1018
1019 priv = devm_kzalloc(dev, sizeof(struct sata_rcar_priv), GFP_KERNEL);
1020 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
1021 index 585e2e1c9c8f..e06a57936cc9 100644
1022 --- a/drivers/base/bus.c
1023 +++ b/drivers/base/bus.c
1024 @@ -614,8 +614,10 @@ static void remove_probe_files(struct bus_type *bus)
1025 static ssize_t uevent_store(struct device_driver *drv, const char *buf,
1026 size_t count)
1027 {
1028 - kobject_synth_uevent(&drv->p->kobj, buf, count);
1029 - return count;
1030 + int rc;
1031 +
1032 + rc = kobject_synth_uevent(&drv->p->kobj, buf, count);
1033 + return rc ? rc : count;
1034 }
1035 static DRIVER_ATTR_WO(uevent);
1036
1037 @@ -831,8 +833,10 @@ static void klist_devices_put(struct klist_node *n)
1038 static ssize_t bus_uevent_store(struct bus_type *bus,
1039 const char *buf, size_t count)
1040 {
1041 - kobject_synth_uevent(&bus->p->subsys.kobj, buf, count);
1042 - return count;
1043 + int rc;
1044 +
1045 + rc = kobject_synth_uevent(&bus->p->subsys.kobj, buf, count);
1046 + return rc ? rc : count;
1047 }
1048 static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store);
1049
1050 diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
1051 index 5d5b5988e88b..dd6a6850cb45 100644
1052 --- a/drivers/base/cacheinfo.c
1053 +++ b/drivers/base/cacheinfo.c
1054 @@ -79,8 +79,7 @@ static void cache_size(struct cacheinfo *this_leaf, struct device_node *np)
1055 ct_idx = get_cacheinfo_idx(this_leaf->type);
1056 propname = cache_type_info[ct_idx].size_prop;
1057
1058 - if (of_property_read_u32(np, propname, &this_leaf->size))
1059 - this_leaf->size = 0;
1060 + of_property_read_u32(np, propname, &this_leaf->size);
1061 }
1062
1063 /* not cache_line_size() because that's a macro in include/linux/cache.h */
1064 @@ -114,8 +113,7 @@ static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np)
1065 ct_idx = get_cacheinfo_idx(this_leaf->type);
1066 propname = cache_type_info[ct_idx].nr_sets_prop;
1067
1068 - if (of_property_read_u32(np, propname, &this_leaf->number_of_sets))
1069 - this_leaf->number_of_sets = 0;
1070 + of_property_read_u32(np, propname, &this_leaf->number_of_sets);
1071 }
1072
1073 static void cache_associativity(struct cacheinfo *this_leaf)
1074 diff --git a/drivers/base/core.c b/drivers/base/core.c
1075 index 04bbcd779e11..92e2c32c2227 100644
1076 --- a/drivers/base/core.c
1077 +++ b/drivers/base/core.c
1078 @@ -1067,8 +1067,14 @@ out:
1079 static ssize_t uevent_store(struct device *dev, struct device_attribute *attr,
1080 const char *buf, size_t count)
1081 {
1082 - if (kobject_synth_uevent(&dev->kobj, buf, count))
1083 + int rc;
1084 +
1085 + rc = kobject_synth_uevent(&dev->kobj, buf, count);
1086 +
1087 + if (rc) {
1088 dev_err(dev, "uevent: failed to send synthetic uevent\n");
1089 + return rc;
1090 + }
1091
1092 return count;
1093 }
1094 diff --git a/drivers/base/dd.c b/drivers/base/dd.c
1095 index 2607f859881a..7caa1adaf62a 100644
1096 --- a/drivers/base/dd.c
1097 +++ b/drivers/base/dd.c
1098 @@ -926,9 +926,6 @@ static void __device_release_driver(struct device *dev, struct device *parent)
1099
1100 drv = dev->driver;
1101 if (drv) {
1102 - if (driver_allows_async_probing(drv))
1103 - async_synchronize_full();
1104 -
1105 while (device_links_busy(dev)) {
1106 device_unlock(dev);
1107 if (parent && dev->bus->need_parent_lock)
1108 @@ -1034,6 +1031,9 @@ void driver_detach(struct device_driver *drv)
1109 struct device_private *dev_prv;
1110 struct device *dev;
1111
1112 + if (driver_allows_async_probing(drv))
1113 + async_synchronize_full();
1114 +
1115 for (;;) {
1116 spin_lock(&drv->p->klist_devices.k_lock);
1117 if (list_empty(&drv->p->klist_devices.k_list)) {
1118 diff --git a/drivers/base/devres.c b/drivers/base/devres.c
1119 index f98a097e73f2..d68b52cf9225 100644
1120 --- a/drivers/base/devres.c
1121 +++ b/drivers/base/devres.c
1122 @@ -24,8 +24,14 @@ struct devres_node {
1123
1124 struct devres {
1125 struct devres_node node;
1126 - /* -- 3 pointers */
1127 - unsigned long long data[]; /* guarantee ull alignment */
1128 + /*
1129 + * Some archs want to perform DMA into kmalloc caches
1130 + * and need a guaranteed alignment larger than
1131 + * the alignment of a 64-bit integer.
1132 + * Thus we use ARCH_KMALLOC_MINALIGN here and get exactly the same
1133 + * buffer alignment as if it was allocated by plain kmalloc().
1134 + */
1135 + u8 __aligned(ARCH_KMALLOC_MINALIGN) data[];
1136 };
1137
1138 struct devres_group {
1139 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
1140 index b4f02768ba47..319fabdd63a3 100644
1141 --- a/drivers/block/drbd/drbd_nl.c
1142 +++ b/drivers/block/drbd/drbd_nl.c
1143 @@ -668,14 +668,15 @@ drbd_set_role(struct drbd_device *const device, enum drbd_role new_role, int for
1144 if (rv == SS_TWO_PRIMARIES) {
1145 /* Maybe the peer is detected as dead very soon...
1146 retry at most once more in this case. */
1147 - int timeo;
1148 - rcu_read_lock();
1149 - nc = rcu_dereference(connection->net_conf);
1150 - timeo = nc ? (nc->ping_timeo + 1) * HZ / 10 : 1;
1151 - rcu_read_unlock();
1152 - schedule_timeout_interruptible(timeo);
1153 - if (try < max_tries)
1154 + if (try < max_tries) {
1155 + int timeo;
1156 try = max_tries - 1;
1157 + rcu_read_lock();
1158 + nc = rcu_dereference(connection->net_conf);
1159 + timeo = nc ? (nc->ping_timeo + 1) * HZ / 10 : 1;
1160 + rcu_read_unlock();
1161 + schedule_timeout_interruptible(timeo);
1162 + }
1163 continue;
1164 }
1165 if (rv < SS_SUCCESS) {
1166 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
1167 index 75f6b47169e6..cb919b964066 100644
1168 --- a/drivers/block/drbd/drbd_receiver.c
1169 +++ b/drivers/block/drbd/drbd_receiver.c
1170 @@ -3364,7 +3364,7 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device,
1171 enum drbd_conns rv = C_MASK;
1172 enum drbd_disk_state mydisk;
1173 struct net_conf *nc;
1174 - int hg, rule_nr, rr_conflict, tentative;
1175 + int hg, rule_nr, rr_conflict, tentative, always_asbp;
1176
1177 mydisk = device->state.disk;
1178 if (mydisk == D_NEGOTIATING)
1179 @@ -3415,8 +3415,12 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device,
1180
1181 rcu_read_lock();
1182 nc = rcu_dereference(peer_device->connection->net_conf);
1183 + always_asbp = nc->always_asbp;
1184 + rr_conflict = nc->rr_conflict;
1185 + tentative = nc->tentative;
1186 + rcu_read_unlock();
1187
1188 - if (hg == 100 || (hg == -100 && nc->always_asbp)) {
1189 + if (hg == 100 || (hg == -100 && always_asbp)) {
1190 int pcount = (device->state.role == R_PRIMARY)
1191 + (peer_role == R_PRIMARY);
1192 int forced = (hg == -100);
1193 @@ -3455,9 +3459,6 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device,
1194 "Sync from %s node\n",
1195 (hg < 0) ? "peer" : "this");
1196 }
1197 - rr_conflict = nc->rr_conflict;
1198 - tentative = nc->tentative;
1199 - rcu_read_unlock();
1200
1201 if (hg == -100) {
1202 /* FIXME this log message is not correct if we end up here
1203 @@ -4141,7 +4142,7 @@ static int receive_uuids(struct drbd_connection *connection, struct packet_info
1204 kfree(device->p_uuid);
1205 device->p_uuid = p_uuid;
1206
1207 - if (device->state.conn < C_CONNECTED &&
1208 + if ((device->state.conn < C_CONNECTED || device->state.pdsk == D_DISKLESS) &&
1209 device->state.disk < D_INCONSISTENT &&
1210 device->state.role == R_PRIMARY &&
1211 (device->ed_uuid & ~((u64)1)) != (p_uuid[UI_CURRENT] & ~((u64)1))) {
1212 diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
1213 index f68e9baffad7..5d7024057540 100644
1214 --- a/drivers/block/sunvdc.c
1215 +++ b/drivers/block/sunvdc.c
1216 @@ -45,6 +45,8 @@ MODULE_VERSION(DRV_MODULE_VERSION);
1217 #define WAITING_FOR_GEN_CMD 0x04
1218 #define WAITING_FOR_ANY -1
1219
1220 +#define VDC_MAX_RETRIES 10
1221 +
1222 static struct workqueue_struct *sunvdc_wq;
1223
1224 struct vdc_req_entry {
1225 @@ -431,6 +433,7 @@ static int __vdc_tx_trigger(struct vdc_port *port)
1226 .end_idx = dr->prod,
1227 };
1228 int err, delay;
1229 + int retries = 0;
1230
1231 hdr.seq = dr->snd_nxt;
1232 delay = 1;
1233 @@ -443,6 +446,8 @@ static int __vdc_tx_trigger(struct vdc_port *port)
1234 udelay(delay);
1235 if ((delay <<= 1) > 128)
1236 delay = 128;
1237 + if (retries++ > VDC_MAX_RETRIES)
1238 + break;
1239 } while (err == -EAGAIN);
1240
1241 if (err == -ENOTCONN)
1242 diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
1243 index 469541c1e51e..20907a0a043b 100644
1244 --- a/drivers/block/swim3.c
1245 +++ b/drivers/block/swim3.c
1246 @@ -1026,7 +1026,11 @@ static void floppy_release(struct gendisk *disk, fmode_t mode)
1247 struct swim3 __iomem *sw = fs->swim3;
1248
1249 mutex_lock(&swim3_mutex);
1250 - if (fs->ref_count > 0 && --fs->ref_count == 0) {
1251 + if (fs->ref_count > 0)
1252 + --fs->ref_count;
1253 + else if (fs->ref_count == -1)
1254 + fs->ref_count = 0;
1255 + if (fs->ref_count == 0) {
1256 swim3_action(fs, MOTOR_OFF);
1257 out_8(&sw->control_bic, 0xff);
1258 swim3_select(fs, RELAX);
1259 diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
1260 index e19bf0a750cf..a65505db09e5 100644
1261 --- a/drivers/block/zram/zram_drv.c
1262 +++ b/drivers/block/zram/zram_drv.c
1263 @@ -53,6 +53,11 @@ static size_t huge_class_size;
1264
1265 static void zram_free_page(struct zram *zram, size_t index);
1266
1267 +static int zram_slot_trylock(struct zram *zram, u32 index)
1268 +{
1269 + return bit_spin_trylock(ZRAM_LOCK, &zram->table[index].value);
1270 +}
1271 +
1272 static void zram_slot_lock(struct zram *zram, u32 index)
1273 {
1274 bit_spin_lock(ZRAM_LOCK, &zram->table[index].value);
1275 @@ -401,7 +406,6 @@ static ssize_t backing_dev_store(struct device *dev,
1276 goto out;
1277
1278 reset_bdev(zram);
1279 - spin_lock_init(&zram->bitmap_lock);
1280
1281 zram->old_block_size = old_block_size;
1282 zram->bdev = bdev;
1283 @@ -445,29 +449,24 @@ out:
1284
1285 static unsigned long get_entry_bdev(struct zram *zram)
1286 {
1287 - unsigned long entry;
1288 -
1289 - spin_lock(&zram->bitmap_lock);
1290 + unsigned long blk_idx = 1;
1291 +retry:
1292 /* skip 0 bit to confuse zram.handle = 0 */
1293 - entry = find_next_zero_bit(zram->bitmap, zram->nr_pages, 1);
1294 - if (entry == zram->nr_pages) {
1295 - spin_unlock(&zram->bitmap_lock);
1296 + blk_idx = find_next_zero_bit(zram->bitmap, zram->nr_pages, blk_idx);
1297 + if (blk_idx == zram->nr_pages)
1298 return 0;
1299 - }
1300
1301 - set_bit(entry, zram->bitmap);
1302 - spin_unlock(&zram->bitmap_lock);
1303 + if (test_and_set_bit(blk_idx, zram->bitmap))
1304 + goto retry;
1305
1306 - return entry;
1307 + return blk_idx;
1308 }
1309
1310 static void put_entry_bdev(struct zram *zram, unsigned long entry)
1311 {
1312 int was_set;
1313
1314 - spin_lock(&zram->bitmap_lock);
1315 was_set = test_and_clear_bit(entry, zram->bitmap);
1316 - spin_unlock(&zram->bitmap_lock);
1317 WARN_ON_ONCE(!was_set);
1318 }
1319
1320 @@ -888,9 +887,10 @@ static ssize_t debug_stat_show(struct device *dev,
1321
1322 down_read(&zram->init_lock);
1323 ret = scnprintf(buf, PAGE_SIZE,
1324 - "version: %d\n%8llu\n",
1325 + "version: %d\n%8llu %8llu\n",
1326 version,
1327 - (u64)atomic64_read(&zram->stats.writestall));
1328 + (u64)atomic64_read(&zram->stats.writestall),
1329 + (u64)atomic64_read(&zram->stats.miss_free));
1330 up_read(&zram->init_lock);
1331
1332 return ret;
1333 @@ -1402,10 +1402,14 @@ static void zram_slot_free_notify(struct block_device *bdev,
1334
1335 zram = bdev->bd_disk->private_data;
1336
1337 - zram_slot_lock(zram, index);
1338 + atomic64_inc(&zram->stats.notify_free);
1339 + if (!zram_slot_trylock(zram, index)) {
1340 + atomic64_inc(&zram->stats.miss_free);
1341 + return;
1342 + }
1343 +
1344 zram_free_page(zram, index);
1345 zram_slot_unlock(zram, index);
1346 - atomic64_inc(&zram->stats.notify_free);
1347 }
1348
1349 static int zram_rw_page(struct block_device *bdev, sector_t sector,
1350 diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
1351 index 72c8584b6dff..d1095dfdffa8 100644
1352 --- a/drivers/block/zram/zram_drv.h
1353 +++ b/drivers/block/zram/zram_drv.h
1354 @@ -79,6 +79,7 @@ struct zram_stats {
1355 atomic64_t pages_stored; /* no. of pages currently stored */
1356 atomic_long_t max_used_pages; /* no. of maximum pages stored */
1357 atomic64_t writestall; /* no. of write slow paths */
1358 + atomic64_t miss_free; /* no. of missed free */
1359 };
1360
1361 struct zram {
1362 @@ -110,7 +111,6 @@ struct zram {
1363 unsigned int old_block_size;
1364 unsigned long *bitmap;
1365 unsigned long nr_pages;
1366 - spinlock_t bitmap_lock;
1367 #endif
1368 #ifdef CONFIG_ZRAM_MEMORY_TRACKING
1369 struct dentry *debugfs_dir;
1370 diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
1371 index ddbd8c6a0ceb..800132369134 100644
1372 --- a/drivers/bluetooth/hci_bcm.c
1373 +++ b/drivers/bluetooth/hci_bcm.c
1374 @@ -907,6 +907,10 @@ static int bcm_get_resources(struct bcm_device *dev)
1375
1376 dev->clk = devm_clk_get(dev->dev, NULL);
1377
1378 + /* Handle deferred probing */
1379 + if (dev->clk == ERR_PTR(-EPROBE_DEFER))
1380 + return PTR_ERR(dev->clk);
1381 +
1382 dev->device_wakeup = devm_gpiod_get_optional(dev->dev, "device-wakeup",
1383 GPIOD_OUT_LOW);
1384 if (IS_ERR(dev->device_wakeup))
1385 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
1386 index ae3a7537cf0f..72cd96a8eb19 100644
1387 --- a/drivers/cdrom/gdrom.c
1388 +++ b/drivers/cdrom/gdrom.c
1389 @@ -889,6 +889,7 @@ static void __exit exit_gdrom(void)
1390 platform_device_unregister(pd);
1391 platform_driver_unregister(&gdrom_driver);
1392 kfree(gd.toc);
1393 + kfree(gd.cd_info);
1394 }
1395
1396 module_init(init_gdrom);
1397 diff --git a/drivers/clk/imgtec/clk-boston.c b/drivers/clk/imgtec/clk-boston.c
1398 index 15af423cc0c9..f5d54a64d33c 100644
1399 --- a/drivers/clk/imgtec/clk-boston.c
1400 +++ b/drivers/clk/imgtec/clk-boston.c
1401 @@ -73,27 +73,32 @@ static void __init clk_boston_setup(struct device_node *np)
1402 hw = clk_hw_register_fixed_rate(NULL, "input", NULL, 0, in_freq);
1403 if (IS_ERR(hw)) {
1404 pr_err("failed to register input clock: %ld\n", PTR_ERR(hw));
1405 - return;
1406 + goto error;
1407 }
1408 onecell->hws[BOSTON_CLK_INPUT] = hw;
1409
1410 hw = clk_hw_register_fixed_rate(NULL, "sys", "input", 0, sys_freq);
1411 if (IS_ERR(hw)) {
1412 pr_err("failed to register sys clock: %ld\n", PTR_ERR(hw));
1413 - return;
1414 + goto error;
1415 }
1416 onecell->hws[BOSTON_CLK_SYS] = hw;
1417
1418 hw = clk_hw_register_fixed_rate(NULL, "cpu", "input", 0, cpu_freq);
1419 if (IS_ERR(hw)) {
1420 pr_err("failed to register cpu clock: %ld\n", PTR_ERR(hw));
1421 - return;
1422 + goto error;
1423 }
1424 onecell->hws[BOSTON_CLK_CPU] = hw;
1425
1426 err = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, onecell);
1427 if (err)
1428 pr_err("failed to add DT provider: %d\n", err);
1429 +
1430 + return;
1431 +
1432 +error:
1433 + kfree(onecell);
1434 }
1435
1436 /*
1437 diff --git a/drivers/clk/imx/clk-imx6sl.c b/drivers/clk/imx/clk-imx6sl.c
1438 index eb6bcbf345a3..390e3e0ecc45 100644
1439 --- a/drivers/clk/imx/clk-imx6sl.c
1440 +++ b/drivers/clk/imx/clk-imx6sl.c
1441 @@ -17,6 +17,8 @@
1442
1443 #include "clk.h"
1444
1445 +#define CCDR 0x4
1446 +#define BM_CCM_CCDR_MMDC_CH0_MASK (1 << 17)
1447 #define CCSR 0xc
1448 #define BM_CCSR_PLL1_SW_CLK_SEL (1 << 2)
1449 #define CACRR 0x10
1450 @@ -409,6 +411,10 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)
1451 clks[IMX6SL_CLK_USDHC3] = imx_clk_gate2("usdhc3", "usdhc3_podf", base + 0x80, 6);
1452 clks[IMX6SL_CLK_USDHC4] = imx_clk_gate2("usdhc4", "usdhc4_podf", base + 0x80, 8);
1453
1454 + /* Ensure the MMDC CH0 handshake is bypassed */
1455 + writel_relaxed(readl_relaxed(base + CCDR) |
1456 + BM_CCM_CCDR_MMDC_CH0_MASK, base + CCDR);
1457 +
1458 imx_check_clocks(clks, ARRAY_SIZE(clks));
1459
1460 clk_data.clks = clks;
1461 diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c
1462 index 50060e895e7a..9d79ff857d83 100644
1463 --- a/drivers/clk/meson/meson8b.c
1464 +++ b/drivers/clk/meson/meson8b.c
1465 @@ -583,7 +583,7 @@ static struct clk_regmap meson8b_cpu_scale_div = {
1466 .data = &(struct clk_regmap_div_data){
1467 .offset = HHI_SYS_CPU_CLK_CNTL1,
1468 .shift = 20,
1469 - .width = 9,
1470 + .width = 10,
1471 .table = cpu_scale_table,
1472 .flags = CLK_DIVIDER_ALLOW_ZERO,
1473 },
1474 @@ -596,20 +596,27 @@ static struct clk_regmap meson8b_cpu_scale_div = {
1475 },
1476 };
1477
1478 +static u32 mux_table_cpu_scale_out_sel[] = { 0, 1, 3 };
1479 static struct clk_regmap meson8b_cpu_scale_out_sel = {
1480 .data = &(struct clk_regmap_mux_data){
1481 .offset = HHI_SYS_CPU_CLK_CNTL0,
1482 .mask = 0x3,
1483 .shift = 2,
1484 + .table = mux_table_cpu_scale_out_sel,
1485 },
1486 .hw.init = &(struct clk_init_data){
1487 .name = "cpu_scale_out_sel",
1488 .ops = &clk_regmap_mux_ro_ops,
1489 + /*
1490 + * NOTE: We are skipping the parent with value 0x2 (which is
1491 + * "cpu_div3") because it results in a duty cycle of 33% which
1492 + * makes the system unstable and can result in a lockup of the
1493 + * whole system.
1494 + */
1495 .parent_names = (const char *[]) { "cpu_in_sel",
1496 "cpu_div2",
1497 - "cpu_div3",
1498 "cpu_scale_div" },
1499 - .num_parents = 4,
1500 + .num_parents = 3,
1501 .flags = CLK_SET_RATE_PARENT,
1502 },
1503 };
1504 @@ -627,7 +634,8 @@ static struct clk_regmap meson8b_cpu_clk = {
1505 "cpu_scale_out_sel" },
1506 .num_parents = 2,
1507 .flags = (CLK_SET_RATE_PARENT |
1508 - CLK_SET_RATE_NO_REPARENT),
1509 + CLK_SET_RATE_NO_REPARENT |
1510 + CLK_IS_CRITICAL),
1511 },
1512 };
1513
1514 diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
1515 index 13eb5b23c5e7..c40d572a7602 100644
1516 --- a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
1517 +++ b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
1518 @@ -366,10 +366,10 @@ static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4,
1519 static const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x",
1520 "pll-audio-2x", "pll-audio" };
1521 static SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents,
1522 - 0x0b0, 16, 2, BIT(31), 0);
1523 + 0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
1524
1525 static SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents,
1526 - 0x0b4, 16, 2, BIT(31), 0);
1527 + 0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
1528
1529 /* TODO: the parent for most of the USB clocks is not known */
1530 static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M",
1531 @@ -446,7 +446,7 @@ static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve",
1532 static SUNXI_CCU_GATE(ac_dig_clk, "ac-dig", "pll-audio",
1533 0x140, BIT(31), CLK_SET_RATE_PARENT);
1534 static SUNXI_CCU_GATE(ac_dig_4x_clk, "ac-dig-4x", "pll-audio-4x",
1535 - 0x140, BIT(30), 0);
1536 + 0x140, BIT(30), CLK_SET_RATE_PARENT);
1537 static SUNXI_CCU_GATE(avs_clk, "avs", "osc24M",
1538 0x144, BIT(31), 0);
1539
1540 diff --git a/drivers/cpuidle/cpuidle-big_little.c b/drivers/cpuidle/cpuidle-big_little.c
1541 index db2ede565f1a..b44476a1b7ad 100644
1542 --- a/drivers/cpuidle/cpuidle-big_little.c
1543 +++ b/drivers/cpuidle/cpuidle-big_little.c
1544 @@ -167,6 +167,7 @@ static int __init bl_idle_init(void)
1545 {
1546 int ret;
1547 struct device_node *root = of_find_node_by_path("/");
1548 + const struct of_device_id *match_id;
1549
1550 if (!root)
1551 return -ENODEV;
1552 @@ -174,7 +175,11 @@ static int __init bl_idle_init(void)
1553 /*
1554 * Initialize the driver just for a compliant set of machines
1555 */
1556 - if (!of_match_node(compatible_machine_match, root))
1557 + match_id = of_match_node(compatible_machine_match, root);
1558 +
1559 + of_node_put(root);
1560 +
1561 + if (!match_id)
1562 return -ENODEV;
1563
1564 if (!mcpm_is_available())
1565 diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c
1566 index d2663a4e1f5e..a92a66b1ff46 100644
1567 --- a/drivers/crypto/ux500/cryp/cryp_core.c
1568 +++ b/drivers/crypto/ux500/cryp/cryp_core.c
1569 @@ -556,7 +556,7 @@ static int cryp_set_dma_transfer(struct cryp_ctx *ctx,
1570 desc = dmaengine_prep_slave_sg(channel,
1571 ctx->device->dma.sg_src,
1572 ctx->device->dma.sg_src_len,
1573 - direction, DMA_CTRL_ACK);
1574 + DMA_MEM_TO_DEV, DMA_CTRL_ACK);
1575 break;
1576
1577 case DMA_FROM_DEVICE:
1578 @@ -580,7 +580,7 @@ static int cryp_set_dma_transfer(struct cryp_ctx *ctx,
1579 desc = dmaengine_prep_slave_sg(channel,
1580 ctx->device->dma.sg_dst,
1581 ctx->device->dma.sg_dst_len,
1582 - direction,
1583 + DMA_DEV_TO_MEM,
1584 DMA_CTRL_ACK |
1585 DMA_PREP_INTERRUPT);
1586
1587 diff --git a/drivers/crypto/ux500/hash/hash_core.c b/drivers/crypto/ux500/hash/hash_core.c
1588 index 633321a8dd03..a0bb8a6eec3f 100644
1589 --- a/drivers/crypto/ux500/hash/hash_core.c
1590 +++ b/drivers/crypto/ux500/hash/hash_core.c
1591 @@ -166,7 +166,7 @@ static int hash_set_dma_transfer(struct hash_ctx *ctx, struct scatterlist *sg,
1592 __func__);
1593 desc = dmaengine_prep_slave_sg(channel,
1594 ctx->device->dma.sg, ctx->device->dma.sg_len,
1595 - direction, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
1596 + DMA_MEM_TO_DEV, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
1597 if (!desc) {
1598 dev_err(ctx->device->dev,
1599 "%s: dmaengine_prep_slave_sg() failed!\n", __func__);
1600 diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
1601 index 847f84a41a69..2b11d967acd0 100644
1602 --- a/drivers/dma/bcm2835-dma.c
1603 +++ b/drivers/dma/bcm2835-dma.c
1604 @@ -415,38 +415,32 @@ static void bcm2835_dma_fill_cb_chain_with_sg(
1605 }
1606 }
1607
1608 -static int bcm2835_dma_abort(void __iomem *chan_base)
1609 +static int bcm2835_dma_abort(struct bcm2835_chan *c)
1610 {
1611 - unsigned long cs;
1612 + void __iomem *chan_base = c->chan_base;
1613 long int timeout = 10000;
1614
1615 - cs = readl(chan_base + BCM2835_DMA_CS);
1616 - if (!(cs & BCM2835_DMA_ACTIVE))
1617 + /*
1618 + * A zero control block address means the channel is idle.
1619 + * (The ACTIVE flag in the CS register is not a reliable indicator.)
1620 + */
1621 + if (!readl(chan_base + BCM2835_DMA_ADDR))
1622 return 0;
1623
1624 /* Write 0 to the active bit - Pause the DMA */
1625 writel(0, chan_base + BCM2835_DMA_CS);
1626
1627 /* Wait for any current AXI transfer to complete */
1628 - while ((cs & BCM2835_DMA_ISPAUSED) && --timeout) {
1629 + while ((readl(chan_base + BCM2835_DMA_CS) &
1630 + BCM2835_DMA_WAITING_FOR_WRITES) && --timeout)
1631 cpu_relax();
1632 - cs = readl(chan_base + BCM2835_DMA_CS);
1633 - }
1634
1635 - /* We'll un-pause when we set of our next DMA */
1636 + /* Peripheral might be stuck and fail to signal AXI write responses */
1637 if (!timeout)
1638 - return -ETIMEDOUT;
1639 -
1640 - if (!(cs & BCM2835_DMA_ACTIVE))
1641 - return 0;
1642 -
1643 - /* Terminate the control block chain */
1644 - writel(0, chan_base + BCM2835_DMA_NEXTCB);
1645 -
1646 - /* Abort the whole DMA */
1647 - writel(BCM2835_DMA_ABORT | BCM2835_DMA_ACTIVE,
1648 - chan_base + BCM2835_DMA_CS);
1649 + dev_err(c->vc.chan.device->dev,
1650 + "failed to complete outstanding writes\n");
1651
1652 + writel(BCM2835_DMA_RESET, chan_base + BCM2835_DMA_CS);
1653 return 0;
1654 }
1655
1656 @@ -485,8 +479,15 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data)
1657
1658 spin_lock_irqsave(&c->vc.lock, flags);
1659
1660 - /* Acknowledge interrupt */
1661 - writel(BCM2835_DMA_INT, c->chan_base + BCM2835_DMA_CS);
1662 + /*
1663 + * Clear the INT flag to receive further interrupts. Keep the channel
1664 + * active in case the descriptor is cyclic or in case the client has
1665 + * already terminated the descriptor and issued a new one. (May happen
1666 + * if this IRQ handler is threaded.) If the channel is finished, it
1667 + * will remain idle despite the ACTIVE flag being set.
1668 + */
1669 + writel(BCM2835_DMA_INT | BCM2835_DMA_ACTIVE,
1670 + c->chan_base + BCM2835_DMA_CS);
1671
1672 d = c->desc;
1673
1674 @@ -494,11 +495,7 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data)
1675 if (d->cyclic) {
1676 /* call the cyclic callback */
1677 vchan_cyclic_callback(&d->vd);
1678 -
1679 - /* Keep the DMA engine running */
1680 - writel(BCM2835_DMA_ACTIVE,
1681 - c->chan_base + BCM2835_DMA_CS);
1682 - } else {
1683 + } else if (!readl(c->chan_base + BCM2835_DMA_ADDR)) {
1684 vchan_cookie_complete(&c->desc->vd);
1685 bcm2835_dma_start_desc(c);
1686 }
1687 @@ -796,7 +793,6 @@ static int bcm2835_dma_terminate_all(struct dma_chan *chan)
1688 struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
1689 struct bcm2835_dmadev *d = to_bcm2835_dma_dev(c->vc.chan.device);
1690 unsigned long flags;
1691 - int timeout = 10000;
1692 LIST_HEAD(head);
1693
1694 spin_lock_irqsave(&c->vc.lock, flags);
1695 @@ -806,27 +802,11 @@ static int bcm2835_dma_terminate_all(struct dma_chan *chan)
1696 list_del_init(&c->node);
1697 spin_unlock(&d->lock);
1698
1699 - /*
1700 - * Stop DMA activity: we assume the callback will not be called
1701 - * after bcm_dma_abort() returns (even if it does, it will see
1702 - * c->desc is NULL and exit.)
1703 - */
1704 + /* stop DMA activity */
1705 if (c->desc) {
1706 vchan_terminate_vdesc(&c->desc->vd);
1707 c->desc = NULL;
1708 - bcm2835_dma_abort(c->chan_base);
1709 -
1710 - /* Wait for stopping */
1711 - while (--timeout) {
1712 - if (!(readl(c->chan_base + BCM2835_DMA_CS) &
1713 - BCM2835_DMA_ACTIVE))
1714 - break;
1715 -
1716 - cpu_relax();
1717 - }
1718 -
1719 - if (!timeout)
1720 - dev_err(d->ddev.dev, "DMA transfer could not be terminated\n");
1721 + bcm2835_dma_abort(c);
1722 }
1723
1724 vchan_get_all_descriptors(&c->vc, &head);
1725 diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
1726 index 75b6ff0415ee..118d371a2a4a 100644
1727 --- a/drivers/dma/imx-dma.c
1728 +++ b/drivers/dma/imx-dma.c
1729 @@ -617,7 +617,7 @@ static void imxdma_tasklet(unsigned long data)
1730 {
1731 struct imxdma_channel *imxdmac = (void *)data;
1732 struct imxdma_engine *imxdma = imxdmac->imxdma;
1733 - struct imxdma_desc *desc;
1734 + struct imxdma_desc *desc, *next_desc;
1735 unsigned long flags;
1736
1737 spin_lock_irqsave(&imxdma->lock, flags);
1738 @@ -647,10 +647,10 @@ static void imxdma_tasklet(unsigned long data)
1739 list_move_tail(imxdmac->ld_active.next, &imxdmac->ld_free);
1740
1741 if (!list_empty(&imxdmac->ld_queue)) {
1742 - desc = list_first_entry(&imxdmac->ld_queue, struct imxdma_desc,
1743 - node);
1744 + next_desc = list_first_entry(&imxdmac->ld_queue,
1745 + struct imxdma_desc, node);
1746 list_move_tail(imxdmac->ld_queue.next, &imxdmac->ld_active);
1747 - if (imxdma_xfer_desc(desc) < 0)
1748 + if (imxdma_xfer_desc(next_desc) < 0)
1749 dev_warn(imxdma->dev, "%s: channel: %d couldn't xfer desc\n",
1750 __func__, imxdmac->channel);
1751 }
1752 diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
1753 index c74a88b65039..73de6a6179fc 100644
1754 --- a/drivers/dma/xilinx/zynqmp_dma.c
1755 +++ b/drivers/dma/xilinx/zynqmp_dma.c
1756 @@ -163,7 +163,7 @@ struct zynqmp_dma_desc_ll {
1757 u32 ctrl;
1758 u64 nxtdscraddr;
1759 u64 rsvd;
1760 -}; __aligned(64)
1761 +};
1762
1763 /**
1764 * struct zynqmp_dma_desc_sw - Per Transaction structure
1765 diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
1766 index 9336ffdf6e2c..fceaafd67ec6 100644
1767 --- a/drivers/firmware/efi/vars.c
1768 +++ b/drivers/firmware/efi/vars.c
1769 @@ -318,7 +318,12 @@ EXPORT_SYMBOL_GPL(efivar_variable_is_removable);
1770 static efi_status_t
1771 check_var_size(u32 attributes, unsigned long size)
1772 {
1773 - const struct efivar_operations *fops = __efivars->ops;
1774 + const struct efivar_operations *fops;
1775 +
1776 + if (!__efivars)
1777 + return EFI_UNSUPPORTED;
1778 +
1779 + fops = __efivars->ops;
1780
1781 if (!fops->query_variable_store)
1782 return EFI_UNSUPPORTED;
1783 @@ -329,7 +334,12 @@ check_var_size(u32 attributes, unsigned long size)
1784 static efi_status_t
1785 check_var_size_nonblocking(u32 attributes, unsigned long size)
1786 {
1787 - const struct efivar_operations *fops = __efivars->ops;
1788 + const struct efivar_operations *fops;
1789 +
1790 + if (!__efivars)
1791 + return EFI_UNSUPPORTED;
1792 +
1793 + fops = __efivars->ops;
1794
1795 if (!fops->query_variable_store)
1796 return EFI_UNSUPPORTED;
1797 @@ -429,13 +439,18 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid,
1798 int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
1799 void *data, bool duplicates, struct list_head *head)
1800 {
1801 - const struct efivar_operations *ops = __efivars->ops;
1802 + const struct efivar_operations *ops;
1803 unsigned long variable_name_size = 1024;
1804 efi_char16_t *variable_name;
1805 efi_status_t status;
1806 efi_guid_t vendor_guid;
1807 int err = 0;
1808
1809 + if (!__efivars)
1810 + return -EFAULT;
1811 +
1812 + ops = __efivars->ops;
1813 +
1814 variable_name = kzalloc(variable_name_size, GFP_KERNEL);
1815 if (!variable_name) {
1816 printk(KERN_ERR "efivars: Memory allocation failed.\n");
1817 @@ -583,12 +598,14 @@ static void efivar_entry_list_del_unlock(struct efivar_entry *entry)
1818 */
1819 int __efivar_entry_delete(struct efivar_entry *entry)
1820 {
1821 - const struct efivar_operations *ops = __efivars->ops;
1822 efi_status_t status;
1823
1824 - status = ops->set_variable(entry->var.VariableName,
1825 - &entry->var.VendorGuid,
1826 - 0, 0, NULL);
1827 + if (!__efivars)
1828 + return -EINVAL;
1829 +
1830 + status = __efivars->ops->set_variable(entry->var.VariableName,
1831 + &entry->var.VendorGuid,
1832 + 0, 0, NULL);
1833
1834 return efi_status_to_err(status);
1835 }
1836 @@ -607,12 +624,17 @@ EXPORT_SYMBOL_GPL(__efivar_entry_delete);
1837 */
1838 int efivar_entry_delete(struct efivar_entry *entry)
1839 {
1840 - const struct efivar_operations *ops = __efivars->ops;
1841 + const struct efivar_operations *ops;
1842 efi_status_t status;
1843
1844 if (down_interruptible(&efivars_lock))
1845 return -EINTR;
1846
1847 + if (!__efivars) {
1848 + up(&efivars_lock);
1849 + return -EINVAL;
1850 + }
1851 + ops = __efivars->ops;
1852 status = ops->set_variable(entry->var.VariableName,
1853 &entry->var.VendorGuid,
1854 0, 0, NULL);
1855 @@ -650,13 +672,19 @@ EXPORT_SYMBOL_GPL(efivar_entry_delete);
1856 int efivar_entry_set(struct efivar_entry *entry, u32 attributes,
1857 unsigned long size, void *data, struct list_head *head)
1858 {
1859 - const struct efivar_operations *ops = __efivars->ops;
1860 + const struct efivar_operations *ops;
1861 efi_status_t status;
1862 efi_char16_t *name = entry->var.VariableName;
1863 efi_guid_t vendor = entry->var.VendorGuid;
1864
1865 if (down_interruptible(&efivars_lock))
1866 return -EINTR;
1867 +
1868 + if (!__efivars) {
1869 + up(&efivars_lock);
1870 + return -EINVAL;
1871 + }
1872 + ops = __efivars->ops;
1873 if (head && efivar_entry_find(name, vendor, head, false)) {
1874 up(&efivars_lock);
1875 return -EEXIST;
1876 @@ -687,12 +715,17 @@ static int
1877 efivar_entry_set_nonblocking(efi_char16_t *name, efi_guid_t vendor,
1878 u32 attributes, unsigned long size, void *data)
1879 {
1880 - const struct efivar_operations *ops = __efivars->ops;
1881 + const struct efivar_operations *ops;
1882 efi_status_t status;
1883
1884 if (down_trylock(&efivars_lock))
1885 return -EBUSY;
1886
1887 + if (!__efivars) {
1888 + up(&efivars_lock);
1889 + return -EINVAL;
1890 + }
1891 +
1892 status = check_var_size_nonblocking(attributes,
1893 size + ucs2_strsize(name, 1024));
1894 if (status != EFI_SUCCESS) {
1895 @@ -700,6 +733,7 @@ efivar_entry_set_nonblocking(efi_char16_t *name, efi_guid_t vendor,
1896 return -ENOSPC;
1897 }
1898
1899 + ops = __efivars->ops;
1900 status = ops->set_variable_nonblocking(name, &vendor, attributes,
1901 size, data);
1902
1903 @@ -727,9 +761,13 @@ efivar_entry_set_nonblocking(efi_char16_t *name, efi_guid_t vendor,
1904 int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
1905 bool block, unsigned long size, void *data)
1906 {
1907 - const struct efivar_operations *ops = __efivars->ops;
1908 + const struct efivar_operations *ops;
1909 efi_status_t status;
1910
1911 + if (!__efivars)
1912 + return -EINVAL;
1913 +
1914 + ops = __efivars->ops;
1915 if (!ops->query_variable_store)
1916 return -ENOSYS;
1917
1918 @@ -829,13 +867,18 @@ EXPORT_SYMBOL_GPL(efivar_entry_find);
1919 */
1920 int efivar_entry_size(struct efivar_entry *entry, unsigned long *size)
1921 {
1922 - const struct efivar_operations *ops = __efivars->ops;
1923 + const struct efivar_operations *ops;
1924 efi_status_t status;
1925
1926 *size = 0;
1927
1928 if (down_interruptible(&efivars_lock))
1929 return -EINTR;
1930 + if (!__efivars) {
1931 + up(&efivars_lock);
1932 + return -EINVAL;
1933 + }
1934 + ops = __efivars->ops;
1935 status = ops->get_variable(entry->var.VariableName,
1936 &entry->var.VendorGuid, NULL, size, NULL);
1937 up(&efivars_lock);
1938 @@ -861,12 +904,14 @@ EXPORT_SYMBOL_GPL(efivar_entry_size);
1939 int __efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
1940 unsigned long *size, void *data)
1941 {
1942 - const struct efivar_operations *ops = __efivars->ops;
1943 efi_status_t status;
1944
1945 - status = ops->get_variable(entry->var.VariableName,
1946 - &entry->var.VendorGuid,
1947 - attributes, size, data);
1948 + if (!__efivars)
1949 + return -EINVAL;
1950 +
1951 + status = __efivars->ops->get_variable(entry->var.VariableName,
1952 + &entry->var.VendorGuid,
1953 + attributes, size, data);
1954
1955 return efi_status_to_err(status);
1956 }
1957 @@ -882,14 +927,19 @@ EXPORT_SYMBOL_GPL(__efivar_entry_get);
1958 int efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
1959 unsigned long *size, void *data)
1960 {
1961 - const struct efivar_operations *ops = __efivars->ops;
1962 efi_status_t status;
1963
1964 if (down_interruptible(&efivars_lock))
1965 return -EINTR;
1966 - status = ops->get_variable(entry->var.VariableName,
1967 - &entry->var.VendorGuid,
1968 - attributes, size, data);
1969 +
1970 + if (!__efivars) {
1971 + up(&efivars_lock);
1972 + return -EINVAL;
1973 + }
1974 +
1975 + status = __efivars->ops->get_variable(entry->var.VariableName,
1976 + &entry->var.VendorGuid,
1977 + attributes, size, data);
1978 up(&efivars_lock);
1979
1980 return efi_status_to_err(status);
1981 @@ -921,7 +971,7 @@ EXPORT_SYMBOL_GPL(efivar_entry_get);
1982 int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
1983 unsigned long *size, void *data, bool *set)
1984 {
1985 - const struct efivar_operations *ops = __efivars->ops;
1986 + const struct efivar_operations *ops;
1987 efi_char16_t *name = entry->var.VariableName;
1988 efi_guid_t *vendor = &entry->var.VendorGuid;
1989 efi_status_t status;
1990 @@ -940,6 +990,11 @@ int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
1991 if (down_interruptible(&efivars_lock))
1992 return -EINTR;
1993
1994 + if (!__efivars) {
1995 + err = -EINVAL;
1996 + goto out;
1997 + }
1998 +
1999 /*
2000 * Ensure that the available space hasn't shrunk below the safe level
2001 */
2002 @@ -956,6 +1011,8 @@ int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
2003 }
2004 }
2005
2006 + ops = __efivars->ops;
2007 +
2008 status = ops->set_variable(name, vendor, attributes, *size, data);
2009 if (status != EFI_SUCCESS) {
2010 err = efi_status_to_err(status);
2011 diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
2012 index 68e4b2b98c8f..7a42c194b944 100644
2013 --- a/drivers/fpga/altera-cvp.c
2014 +++ b/drivers/fpga/altera-cvp.c
2015 @@ -403,6 +403,7 @@ static int altera_cvp_probe(struct pci_dev *pdev,
2016 struct altera_cvp_conf *conf;
2017 struct fpga_manager *mgr;
2018 u16 cmd, val;
2019 + u32 regval;
2020 int ret;
2021
2022 /*
2023 @@ -416,6 +417,14 @@ static int altera_cvp_probe(struct pci_dev *pdev,
2024 return -ENODEV;
2025 }
2026
2027 + pci_read_config_dword(pdev, VSE_CVP_STATUS, &regval);
2028 + if (!(regval & VSE_CVP_STATUS_CVP_EN)) {
2029 + dev_err(&pdev->dev,
2030 + "CVP is disabled for this device: CVP_STATUS Reg 0x%x\n",
2031 + regval);
2032 + return -ENODEV;
2033 + }
2034 +
2035 conf = devm_kzalloc(&pdev->dev, sizeof(*conf), GFP_KERNEL);
2036 if (!conf)
2037 return -ENOMEM;
2038 @@ -471,7 +480,8 @@ static int altera_cvp_probe(struct pci_dev *pdev,
2039 return 0;
2040
2041 err_unmap:
2042 - pci_iounmap(pdev, conf->map);
2043 + if (conf->map)
2044 + pci_iounmap(pdev, conf->map);
2045 pci_release_region(pdev, CVP_BAR);
2046 err_disable:
2047 cmd &= ~PCI_COMMAND_MEMORY;
2048 @@ -486,7 +496,8 @@ static void altera_cvp_remove(struct pci_dev *pdev)
2049 u16 cmd;
2050
2051 fpga_mgr_unregister(mgr);
2052 - pci_iounmap(pdev, conf->map);
2053 + if (conf->map)
2054 + pci_iounmap(pdev, conf->map);
2055 pci_release_region(pdev, CVP_BAR);
2056 pci_read_config_word(pdev, PCI_COMMAND, &cmd);
2057 cmd &= ~PCI_COMMAND_MEMORY;
2058 diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c
2059 index d72af6f6cdbd..00e954f22bc9 100644
2060 --- a/drivers/gpio/gpio-mt7621.c
2061 +++ b/drivers/gpio/gpio-mt7621.c
2062 @@ -244,6 +244,8 @@ mediatek_gpio_bank_probe(struct device *dev,
2063 rg->chip.of_xlate = mediatek_gpio_xlate;
2064 rg->chip.label = devm_kasprintf(dev, GFP_KERNEL, "%s-bank%d",
2065 dev_name(dev), bank);
2066 + if (!rg->chip.label)
2067 + return -ENOMEM;
2068
2069 ret = devm_gpiochip_add_data(dev, &rg->chip, mtk);
2070 if (ret < 0) {
2071 @@ -295,6 +297,7 @@ mediatek_gpio_probe(struct platform_device *pdev)
2072 struct device_node *np = dev->of_node;
2073 struct mtk *mtk;
2074 int i;
2075 + int ret;
2076
2077 mtk = devm_kzalloc(dev, sizeof(*mtk), GFP_KERNEL);
2078 if (!mtk)
2079 @@ -309,8 +312,11 @@ mediatek_gpio_probe(struct platform_device *pdev)
2080 platform_set_drvdata(pdev, mtk);
2081 mediatek_gpio_irq_chip.name = dev_name(dev);
2082
2083 - for (i = 0; i < MTK_BANK_CNT; i++)
2084 - mediatek_gpio_bank_probe(dev, np, i);
2085 + for (i = 0; i < MTK_BANK_CNT; i++) {
2086 + ret = mediatek_gpio_bank_probe(dev, np, i);
2087 + if (ret)
2088 + return ret;
2089 + }
2090
2091 return 0;
2092 }
2093 diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
2094 index b3ab6c428423..fd713326dcfc 100644
2095 --- a/drivers/gpio/gpiolib.c
2096 +++ b/drivers/gpio/gpiolib.c
2097 @@ -2279,6 +2279,12 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
2098 unsigned long flags;
2099 unsigned offset;
2100
2101 + if (label) {
2102 + label = kstrdup_const(label, GFP_KERNEL);
2103 + if (!label)
2104 + return -ENOMEM;
2105 + }
2106 +
2107 spin_lock_irqsave(&gpio_lock, flags);
2108
2109 /* NOTE: gpio_request() can be called in early boot,
2110 @@ -2289,6 +2295,7 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
2111 desc_set_label(desc, label ? : "?");
2112 status = 0;
2113 } else {
2114 + kfree_const(label);
2115 status = -EBUSY;
2116 goto done;
2117 }
2118 @@ -2305,6 +2312,7 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
2119
2120 if (status < 0) {
2121 desc_set_label(desc, NULL);
2122 + kfree_const(label);
2123 clear_bit(FLAG_REQUESTED, &desc->flags);
2124 goto done;
2125 }
2126 @@ -2400,6 +2408,7 @@ static bool gpiod_free_commit(struct gpio_desc *desc)
2127 chip->free(chip, gpio_chip_hwgpio(desc));
2128 spin_lock_irqsave(&gpio_lock, flags);
2129 }
2130 + kfree_const(desc->label);
2131 desc_set_label(desc, NULL);
2132 clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
2133 clear_bit(FLAG_REQUESTED, &desc->flags);
2134 @@ -3221,11 +3230,19 @@ EXPORT_SYMBOL_GPL(gpiod_cansleep);
2135 * @desc: gpio to set the consumer name on
2136 * @name: the new consumer name
2137 */
2138 -void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name)
2139 +int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name)
2140 {
2141 - VALIDATE_DESC_VOID(desc);
2142 - /* Just overwrite whatever the previous name was */
2143 - desc->label = name;
2144 + VALIDATE_DESC(desc);
2145 + if (name) {
2146 + name = kstrdup_const(name, GFP_KERNEL);
2147 + if (!name)
2148 + return -ENOMEM;
2149 + }
2150 +
2151 + kfree_const(desc->label);
2152 + desc_set_label(desc, name);
2153 +
2154 + return 0;
2155 }
2156 EXPORT_SYMBOL_GPL(gpiod_set_consumer_name);
2157
2158 diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
2159 index 7c89785fd731..23a7ef97afdd 100644
2160 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
2161 +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
2162 @@ -324,7 +324,7 @@ bool dc_link_is_dp_sink_present(struct dc_link *link)
2163 {
2164 enum gpio_result gpio_result;
2165 uint32_t clock_pin = 0;
2166 -
2167 + uint8_t retry = 0;
2168 struct ddc *ddc;
2169
2170 enum connector_id connector_id =
2171 @@ -353,11 +353,22 @@ bool dc_link_is_dp_sink_present(struct dc_link *link)
2172 return present;
2173 }
2174
2175 - /* Read GPIO: DP sink is present if both clock and data pins are zero */
2176 - /* [anaumov] in DAL2, there was no check for GPIO failure */
2177 -
2178 - gpio_result = dal_gpio_get_value(ddc->pin_clock, &clock_pin);
2179 - ASSERT(gpio_result == GPIO_RESULT_OK);
2180 + /*
2181 + * Read GPIO: DP sink is present if both clock and data pins are zero
2182 + *
2183 + * [W/A] plug-unplug DP cable, sometimes customer board has
2184 + * one short pulse on clk_pin(1V, < 1ms). DP will be config to HDMI/DVI
2185 + * then monitor can't br light up. Add retry 3 times
2186 + * But in real passive dongle, it need additional 3ms to detect
2187 + */
2188 + do {
2189 + gpio_result = dal_gpio_get_value(ddc->pin_clock, &clock_pin);
2190 + ASSERT(gpio_result == GPIO_RESULT_OK);
2191 + if (clock_pin)
2192 + udelay(1000);
2193 + else
2194 + break;
2195 + } while (retry++ < 3);
2196
2197 present = (gpio_result == GPIO_RESULT_OK) && !clock_pin;
2198
2199 diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
2200 index a7553b6d59c2..05840f5bddd5 100644
2201 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
2202 +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
2203 @@ -2240,7 +2240,8 @@ static void get_active_converter_info(
2204 translate_dpcd_max_bpc(
2205 hdmi_color_caps.bits.MAX_BITS_PER_COLOR_COMPONENT);
2206
2207 - link->dpcd_caps.dongle_caps.extendedCapValid = true;
2208 + if (link->dpcd_caps.dongle_caps.dp_hdmi_max_pixel_clk != 0)
2209 + link->dpcd_caps.dongle_caps.extendedCapValid = true;
2210 }
2211
2212 break;
2213 diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
2214 index ea6beccfd89d..87bf422f16be 100644
2215 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
2216 +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
2217 @@ -1917,6 +1917,8 @@ enum dc_status resource_map_pool_resources(
2218 }
2219 */
2220
2221 + calculate_phy_pix_clks(stream);
2222 +
2223 /* acquire new resources */
2224 pipe_idx = acquire_first_free_pipe(&context->res_ctx, pool, stream);
2225
2226 diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
2227 index 0941f3c689bc..580e7e82034f 100644
2228 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
2229 +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
2230 @@ -1268,10 +1268,19 @@ static void program_scaler(const struct dc *dc,
2231 pipe_ctx->plane_res.scl_data.lb_params.depth,
2232 &pipe_ctx->stream->bit_depth_params);
2233
2234 - if (pipe_ctx->stream_res.tg->funcs->set_overscan_blank_color)
2235 + if (pipe_ctx->stream_res.tg->funcs->set_overscan_blank_color) {
2236 + /*
2237 + * The way 420 is packed, 2 channels carry Y component, 1 channel
2238 + * alternate between Cb and Cr, so both channels need the pixel
2239 + * value for Y
2240 + */
2241 + if (pipe_ctx->stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR420)
2242 + color.color_r_cr = color.color_g_y;
2243 +
2244 pipe_ctx->stream_res.tg->funcs->set_overscan_blank_color(
2245 pipe_ctx->stream_res.tg,
2246 &color);
2247 + }
2248
2249 pipe_ctx->plane_res.xfm->funcs->transform_set_scaler(pipe_ctx->plane_res.xfm,
2250 &pipe_ctx->plane_res.scl_data);
2251 diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
2252 index cfcc54f2ce65..4058b59d9bea 100644
2253 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
2254 +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
2255 @@ -1190,7 +1190,8 @@ static bool dcn10_set_input_transfer_func(struct pipe_ctx *pipe_ctx,
2256 tf = plane_state->in_transfer_func;
2257
2258 if (plane_state->gamma_correction &&
2259 - !plane_state->gamma_correction->is_identity
2260 + !dpp_base->ctx->dc->debug.always_use_regamma
2261 + && !plane_state->gamma_correction->is_identity
2262 && dce_use_lut(plane_state->format))
2263 dpp_base->funcs->dpp_program_input_lut(dpp_base, plane_state->gamma_correction);
2264
2265 @@ -2120,6 +2121,15 @@ static void dcn10_blank_pixel_data(
2266 color_space = stream->output_color_space;
2267 color_space_to_black_color(dc, color_space, &black_color);
2268
2269 + /*
2270 + * The way 420 is packed, 2 channels carry Y component, 1 channel
2271 + * alternate between Cb and Cr, so both channels need the pixel
2272 + * value for Y
2273 + */
2274 + if (stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR420)
2275 + black_color.color_r_cr = black_color.color_g_y;
2276 +
2277 +
2278 if (stream_res->tg->funcs->set_blank_color)
2279 stream_res->tg->funcs->set_blank_color(
2280 stream_res->tg,
2281 diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
2282 index 5b67f575cd34..45629f26dbc2 100644
2283 --- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
2284 +++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
2285 @@ -1528,8 +1528,21 @@ static int polaris10_populate_clock_stretcher_data_table(struct pp_hwmgr *hwmgr)
2286 efuse = efuse >> 24;
2287
2288 if (hwmgr->chip_id == CHIP_POLARIS10) {
2289 - min = 1000;
2290 - max = 2300;
2291 + if (hwmgr->is_kicker) {
2292 + min = 1200;
2293 + max = 2500;
2294 + } else {
2295 + min = 1000;
2296 + max = 2300;
2297 + }
2298 + } else if (hwmgr->chip_id == CHIP_POLARIS11) {
2299 + if (hwmgr->is_kicker) {
2300 + min = 900;
2301 + max = 2100;
2302 + } else {
2303 + min = 1100;
2304 + max = 2100;
2305 + }
2306 } else {
2307 min = 1100;
2308 max = 2100;
2309 diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
2310 index f77bff5aa307..23397c08be11 100644
2311 --- a/drivers/gpu/drm/drm_atomic_helper.c
2312 +++ b/drivers/gpu/drm/drm_atomic_helper.c
2313 @@ -3192,7 +3192,7 @@ EXPORT_SYMBOL(drm_atomic_helper_suspend);
2314 int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
2315 struct drm_modeset_acquire_ctx *ctx)
2316 {
2317 - int i;
2318 + int i, ret;
2319 struct drm_plane *plane;
2320 struct drm_plane_state *new_plane_state;
2321 struct drm_connector *connector;
2322 @@ -3211,7 +3211,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
2323 for_each_new_connector_in_state(state, connector, new_conn_state, i)
2324 state->connectors[i].old_state = connector->state;
2325
2326 - return drm_atomic_commit(state);
2327 + ret = drm_atomic_commit(state);
2328 +
2329 + state->acquire_ctx = NULL;
2330 +
2331 + return ret;
2332 }
2333 EXPORT_SYMBOL(drm_atomic_helper_commit_duplicated_state);
2334
2335 diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
2336 index ba8cfe65c65b..e2f775d1c112 100644
2337 --- a/drivers/gpu/drm/drm_bufs.c
2338 +++ b/drivers/gpu/drm/drm_bufs.c
2339 @@ -36,6 +36,8 @@
2340 #include <drm/drmP.h>
2341 #include "drm_legacy.h"
2342
2343 +#include <linux/nospec.h>
2344 +
2345 static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
2346 struct drm_local_map *map)
2347 {
2348 @@ -1417,6 +1419,7 @@ int drm_legacy_freebufs(struct drm_device *dev, void *data,
2349 idx, dma->buf_count - 1);
2350 return -EINVAL;
2351 }
2352 + idx = array_index_nospec(idx, dma->buf_count);
2353 buf = dma->buflist[idx];
2354 if (buf->file_priv != file_priv) {
2355 DRM_ERROR("Process %d freeing buffer not owned\n",
2356 diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
2357 index 14fc7c2a6bb7..c9962a36b86b 100644
2358 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
2359 +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
2360 @@ -331,7 +331,7 @@ static void dpu_encoder_phys_vid_vblank_irq(void *arg, int irq_idx)
2361 if (hw_ctl && hw_ctl->ops.get_flush_register)
2362 flush_register = hw_ctl->ops.get_flush_register(hw_ctl);
2363
2364 - if (flush_register == 0)
2365 + if (!(flush_register & hw_ctl->ops.get_pending_flush(hw_ctl)))
2366 new_cnt = atomic_add_unless(&phys_enc->pending_kickoff_cnt,
2367 -1, 0);
2368 spin_unlock_irqrestore(phys_enc->enc_spinlock, lock_flags);
2369 diff --git a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
2370 index 41bec570c518..31205625c734 100644
2371 --- a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
2372 +++ b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
2373 @@ -17,7 +17,7 @@
2374 * | |
2375 * | |
2376 * +---------+ | +----------+ | +----+
2377 - * dsi0vco_clk ---| out_div |--o--| divl_3_0 |--o--| /8 |-- dsi0pllbyte
2378 + * dsi0vco_clk ---| out_div |--o--| divl_3_0 |--o--| /8 |-- dsi0_phy_pll_out_byteclk
2379 * +---------+ | +----------+ | +----+
2380 * | |
2381 * | | dsi0_pll_by_2_bit_clk
2382 @@ -25,7 +25,7 @@
2383 * | | +----+ | |\ dsi0_pclk_mux
2384 * | |--| /2 |--o--| \ |
2385 * | | +----+ | \ | +---------+
2386 - * | --------------| |--o--| div_7_4 |-- dsi0pll
2387 + * | --------------| |--o--| div_7_4 |-- dsi0_phy_pll_out_dsiclk
2388 * |------------------------------| / +---------+
2389 * | +-----+ | /
2390 * -----------| /4? |--o----------|/
2391 @@ -690,7 +690,7 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
2392
2393 hws[num++] = hw;
2394
2395 - snprintf(clk_name, 32, "dsi%dpllbyte", pll_10nm->id);
2396 + snprintf(clk_name, 32, "dsi%d_phy_pll_out_byteclk", pll_10nm->id);
2397 snprintf(parent, 32, "dsi%d_pll_bit_clk", pll_10nm->id);
2398
2399 /* DSI Byte clock = VCO_CLK / OUT_DIV / BIT_DIV / 8 */
2400 @@ -739,7 +739,7 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
2401
2402 hws[num++] = hw;
2403
2404 - snprintf(clk_name, 32, "dsi%dpll", pll_10nm->id);
2405 + snprintf(clk_name, 32, "dsi%d_phy_pll_out_dsiclk", pll_10nm->id);
2406 snprintf(parent, 32, "dsi%d_pclk_mux", pll_10nm->id);
2407
2408 /* PIX CLK DIV : DIV_CTRL_7_4*/
2409 diff --git a/drivers/gpu/drm/rockchip/cdn-dp-reg.c b/drivers/gpu/drm/rockchip/cdn-dp-reg.c
2410 index 3105965fc260..5a485489a1e2 100644
2411 --- a/drivers/gpu/drm/rockchip/cdn-dp-reg.c
2412 +++ b/drivers/gpu/drm/rockchip/cdn-dp-reg.c
2413 @@ -147,7 +147,7 @@ static int cdn_dp_mailbox_validate_receive(struct cdn_dp_device *dp,
2414 }
2415
2416 static int cdn_dp_mailbox_read_receive(struct cdn_dp_device *dp,
2417 - u8 *buff, u8 buff_size)
2418 + u8 *buff, u16 buff_size)
2419 {
2420 u32 i;
2421 int ret;
2422 diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
2423 index d5240b777a8f..adcdf946c365 100644
2424 --- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
2425 +++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
2426 @@ -168,6 +168,13 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
2427 goto err_assert_reset;
2428 }
2429
2430 + /*
2431 + * At least on H6, some registers have some bits set by default
2432 + * which may cause issues. Clear them here.
2433 + */
2434 + writel(0, regs + TCON_TOP_PORT_SEL_REG);
2435 + writel(0, regs + TCON_TOP_GATE_SRC_REG);
2436 +
2437 /*
2438 * TCON TOP has two muxes, which select parent clock for each TCON TV
2439 * channel clock. Parent could be either TCON TV or TVE clock. For now
2440 diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c
2441 index 54d96518a131..a08766d39eab 100644
2442 --- a/drivers/gpu/drm/v3d/v3d_bo.c
2443 +++ b/drivers/gpu/drm/v3d/v3d_bo.c
2444 @@ -293,6 +293,7 @@ v3d_prime_import_sg_table(struct drm_device *dev,
2445 bo->resv = attach->dmabuf->resv;
2446
2447 bo->sgt = sgt;
2448 + obj->import_attach = attach;
2449 v3d_bo_get_pages(bo);
2450
2451 v3d_mmu_insert_ptes(bo);
2452 diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
2453 index 629f40424bba..ab39315c9078 100644
2454 --- a/drivers/gpu/drm/vc4/vc4_plane.c
2455 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
2456 @@ -315,12 +315,14 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
2457 vc4_get_scaling_mode(vc4_state->src_h[1],
2458 vc4_state->crtc_h);
2459
2460 - /* YUV conversion requires that horizontal scaling be enabled,
2461 - * even on a plane that's otherwise 1:1. Looks like only PPF
2462 - * works in that case, so let's pick that one.
2463 + /* YUV conversion requires that horizontal scaling be enabled
2464 + * on the UV plane even if vc4_get_scaling_mode() returned
2465 + * VC4_SCALING_NONE (which can happen when the down-scaling
2466 + * ratio is 0.5). Let's force it to VC4_SCALING_PPF in this
2467 + * case.
2468 */
2469 - if (vc4_state->is_unity)
2470 - vc4_state->x_scaling[0] = VC4_SCALING_PPF;
2471 + if (vc4_state->x_scaling[1] == VC4_SCALING_NONE)
2472 + vc4_state->x_scaling[1] = VC4_SCALING_PPF;
2473 } else {
2474 vc4_state->is_yuv = false;
2475 vc4_state->x_scaling[1] = VC4_SCALING_NONE;
2476 diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
2477 index 0e5620f76ee0..6887db878b38 100644
2478 --- a/drivers/gpu/drm/vgem/vgem_drv.c
2479 +++ b/drivers/gpu/drm/vgem/vgem_drv.c
2480 @@ -471,31 +471,31 @@ static int __init vgem_init(void)
2481 if (!vgem_device)
2482 return -ENOMEM;
2483
2484 - ret = drm_dev_init(&vgem_device->drm, &vgem_driver, NULL);
2485 - if (ret)
2486 - goto out_free;
2487 -
2488 vgem_device->platform =
2489 platform_device_register_simple("vgem", -1, NULL, 0);
2490 if (IS_ERR(vgem_device->platform)) {
2491 ret = PTR_ERR(vgem_device->platform);
2492 - goto out_fini;
2493 + goto out_free;
2494 }
2495
2496 dma_coerce_mask_and_coherent(&vgem_device->platform->dev,
2497 DMA_BIT_MASK(64));
2498 + ret = drm_dev_init(&vgem_device->drm, &vgem_driver,
2499 + &vgem_device->platform->dev);
2500 + if (ret)
2501 + goto out_unregister;
2502
2503 /* Final step: expose the device/driver to userspace */
2504 ret = drm_dev_register(&vgem_device->drm, 0);
2505 if (ret)
2506 - goto out_unregister;
2507 + goto out_fini;
2508
2509 return 0;
2510
2511 -out_unregister:
2512 - platform_device_unregister(vgem_device->platform);
2513 out_fini:
2514 drm_dev_fini(&vgem_device->drm);
2515 +out_unregister:
2516 + platform_device_unregister(vgem_device->platform);
2517 out_free:
2518 kfree(vgem_device);
2519 return ret;
2520 diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c b/drivers/gpu/ipu-v3/ipu-image-convert.c
2521 index f4081962784c..91653adc41cc 100644
2522 --- a/drivers/gpu/ipu-v3/ipu-image-convert.c
2523 +++ b/drivers/gpu/ipu-v3/ipu-image-convert.c
2524 @@ -1524,7 +1524,7 @@ unlock:
2525 EXPORT_SYMBOL_GPL(ipu_image_convert_queue);
2526
2527 /* Abort any active or pending conversions for this context */
2528 -void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx)
2529 +static void __ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx)
2530 {
2531 struct ipu_image_convert_chan *chan = ctx->chan;
2532 struct ipu_image_convert_priv *priv = chan->priv;
2533 @@ -1551,7 +1551,7 @@ void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx)
2534
2535 need_abort = (run_count || active_run);
2536
2537 - ctx->aborting = need_abort;
2538 + ctx->aborting = true;
2539
2540 spin_unlock_irqrestore(&chan->irqlock, flags);
2541
2542 @@ -1572,7 +1572,11 @@ void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx)
2543 dev_warn(priv->ipu->dev, "%s: timeout\n", __func__);
2544 force_abort(ctx);
2545 }
2546 +}
2547
2548 +void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx)
2549 +{
2550 + __ipu_image_convert_abort(ctx);
2551 ctx->aborting = false;
2552 }
2553 EXPORT_SYMBOL_GPL(ipu_image_convert_abort);
2554 @@ -1586,7 +1590,7 @@ void ipu_image_convert_unprepare(struct ipu_image_convert_ctx *ctx)
2555 bool put_res;
2556
2557 /* make sure no runs are hanging around */
2558 - ipu_image_convert_abort(ctx);
2559 + __ipu_image_convert_abort(ctx);
2560
2561 dev_dbg(priv->ipu->dev, "%s: task %u: removing ctx %p\n", __func__,
2562 chan->ic_task, ctx);
2563 diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
2564 index b48100236df8..ebc9ffde41e9 100644
2565 --- a/drivers/hid/hid-debug.c
2566 +++ b/drivers/hid/hid-debug.c
2567 @@ -30,6 +30,7 @@
2568
2569 #include <linux/debugfs.h>
2570 #include <linux/seq_file.h>
2571 +#include <linux/kfifo.h>
2572 #include <linux/sched/signal.h>
2573 #include <linux/export.h>
2574 #include <linux/slab.h>
2575 @@ -661,17 +662,12 @@ EXPORT_SYMBOL_GPL(hid_dump_device);
2576 /* enqueue string to 'events' ring buffer */
2577 void hid_debug_event(struct hid_device *hdev, char *buf)
2578 {
2579 - unsigned i;
2580 struct hid_debug_list *list;
2581 unsigned long flags;
2582
2583 spin_lock_irqsave(&hdev->debug_list_lock, flags);
2584 - list_for_each_entry(list, &hdev->debug_list, node) {
2585 - for (i = 0; buf[i]; i++)
2586 - list->hid_debug_buf[(list->tail + i) % HID_DEBUG_BUFSIZE] =
2587 - buf[i];
2588 - list->tail = (list->tail + i) % HID_DEBUG_BUFSIZE;
2589 - }
2590 + list_for_each_entry(list, &hdev->debug_list, node)
2591 + kfifo_in(&list->hid_debug_fifo, buf, strlen(buf));
2592 spin_unlock_irqrestore(&hdev->debug_list_lock, flags);
2593
2594 wake_up_interruptible(&hdev->debug_wait);
2595 @@ -722,8 +718,7 @@ void hid_dump_input(struct hid_device *hdev, struct hid_usage *usage, __s32 valu
2596 hid_debug_event(hdev, buf);
2597
2598 kfree(buf);
2599 - wake_up_interruptible(&hdev->debug_wait);
2600 -
2601 + wake_up_interruptible(&hdev->debug_wait);
2602 }
2603 EXPORT_SYMBOL_GPL(hid_dump_input);
2604
2605 @@ -1088,8 +1083,8 @@ static int hid_debug_events_open(struct inode *inode, struct file *file)
2606 goto out;
2607 }
2608
2609 - if (!(list->hid_debug_buf = kzalloc(HID_DEBUG_BUFSIZE, GFP_KERNEL))) {
2610 - err = -ENOMEM;
2611 + err = kfifo_alloc(&list->hid_debug_fifo, HID_DEBUG_FIFOSIZE, GFP_KERNEL);
2612 + if (err) {
2613 kfree(list);
2614 goto out;
2615 }
2616 @@ -1109,77 +1104,57 @@ static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,
2617 size_t count, loff_t *ppos)
2618 {
2619 struct hid_debug_list *list = file->private_data;
2620 - int ret = 0, len;
2621 + int ret = 0, copied;
2622 DECLARE_WAITQUEUE(wait, current);
2623
2624 mutex_lock(&list->read_mutex);
2625 - while (ret == 0) {
2626 - if (list->head == list->tail) {
2627 - add_wait_queue(&list->hdev->debug_wait, &wait);
2628 - set_current_state(TASK_INTERRUPTIBLE);
2629 -
2630 - while (list->head == list->tail) {
2631 - if (file->f_flags & O_NONBLOCK) {
2632 - ret = -EAGAIN;
2633 - break;
2634 - }
2635 - if (signal_pending(current)) {
2636 - ret = -ERESTARTSYS;
2637 - break;
2638 - }
2639 + if (kfifo_is_empty(&list->hid_debug_fifo)) {
2640 + add_wait_queue(&list->hdev->debug_wait, &wait);
2641 + set_current_state(TASK_INTERRUPTIBLE);
2642 +
2643 + while (kfifo_is_empty(&list->hid_debug_fifo)) {
2644 + if (file->f_flags & O_NONBLOCK) {
2645 + ret = -EAGAIN;
2646 + break;
2647 + }
2648
2649 - if (!list->hdev || !list->hdev->debug) {
2650 - ret = -EIO;
2651 - set_current_state(TASK_RUNNING);
2652 - goto out;
2653 - }
2654 + if (signal_pending(current)) {
2655 + ret = -ERESTARTSYS;
2656 + break;
2657 + }
2658
2659 - /* allow O_NONBLOCK from other threads */
2660 - mutex_unlock(&list->read_mutex);
2661 - schedule();
2662 - mutex_lock(&list->read_mutex);
2663 - set_current_state(TASK_INTERRUPTIBLE);
2664 + /* if list->hdev is NULL we cannot remove_wait_queue().
2665 + * if list->hdev->debug is 0 then hid_debug_unregister()
2666 + * was already called and list->hdev is being destroyed.
2667 + * if we add remove_wait_queue() here we can hit a race.
2668 + */
2669 + if (!list->hdev || !list->hdev->debug) {
2670 + ret = -EIO;
2671 + set_current_state(TASK_RUNNING);
2672 + goto out;
2673 }
2674
2675 - set_current_state(TASK_RUNNING);
2676 - remove_wait_queue(&list->hdev->debug_wait, &wait);
2677 + /* allow O_NONBLOCK from other threads */
2678 + mutex_unlock(&list->read_mutex);
2679 + schedule();
2680 + mutex_lock(&list->read_mutex);
2681 + set_current_state(TASK_INTERRUPTIBLE);
2682 }
2683
2684 - if (ret)
2685 - goto out;
2686 + __set_current_state(TASK_RUNNING);
2687 + remove_wait_queue(&list->hdev->debug_wait, &wait);
2688
2689 - /* pass the ringbuffer contents to userspace */
2690 -copy_rest:
2691 - if (list->tail == list->head)
2692 + if (ret)
2693 goto out;
2694 - if (list->tail > list->head) {
2695 - len = list->tail - list->head;
2696 - if (len > count)
2697 - len = count;
2698 -
2699 - if (copy_to_user(buffer + ret, &list->hid_debug_buf[list->head], len)) {
2700 - ret = -EFAULT;
2701 - goto out;
2702 - }
2703 - ret += len;
2704 - list->head += len;
2705 - } else {
2706 - len = HID_DEBUG_BUFSIZE - list->head;
2707 - if (len > count)
2708 - len = count;
2709 -
2710 - if (copy_to_user(buffer, &list->hid_debug_buf[list->head], len)) {
2711 - ret = -EFAULT;
2712 - goto out;
2713 - }
2714 - list->head = 0;
2715 - ret += len;
2716 - count -= len;
2717 - if (count > 0)
2718 - goto copy_rest;
2719 - }
2720 -
2721 }
2722 +
2723 + /* pass the fifo content to userspace, locking is not needed with only
2724 + * one concurrent reader and one concurrent writer
2725 + */
2726 + ret = kfifo_to_user(&list->hid_debug_fifo, buffer, count, &copied);
2727 + if (ret)
2728 + goto out;
2729 + ret = copied;
2730 out:
2731 mutex_unlock(&list->read_mutex);
2732 return ret;
2733 @@ -1190,7 +1165,7 @@ static __poll_t hid_debug_events_poll(struct file *file, poll_table *wait)
2734 struct hid_debug_list *list = file->private_data;
2735
2736 poll_wait(file, &list->hdev->debug_wait, wait);
2737 - if (list->head != list->tail)
2738 + if (!kfifo_is_empty(&list->hid_debug_fifo))
2739 return EPOLLIN | EPOLLRDNORM;
2740 if (!list->hdev->debug)
2741 return EPOLLERR | EPOLLHUP;
2742 @@ -1205,7 +1180,7 @@ static int hid_debug_events_release(struct inode *inode, struct file *file)
2743 spin_lock_irqsave(&list->hdev->debug_list_lock, flags);
2744 list_del(&list->node);
2745 spin_unlock_irqrestore(&list->hdev->debug_list_lock, flags);
2746 - kfree(list->hid_debug_buf);
2747 + kfifo_free(&list->hid_debug_fifo);
2748 kfree(list);
2749
2750 return 0;
2751 @@ -1256,4 +1231,3 @@ void hid_debug_exit(void)
2752 {
2753 debugfs_remove_recursive(hid_debug_root);
2754 }
2755 -
2756 diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
2757 index 643b6eb54442..eacc76d2ab96 100644
2758 --- a/drivers/hid/hid-lenovo.c
2759 +++ b/drivers/hid/hid-lenovo.c
2760 @@ -743,7 +743,9 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
2761 data_pointer->led_mute.brightness_get = lenovo_led_brightness_get_tpkbd;
2762 data_pointer->led_mute.brightness_set = lenovo_led_brightness_set_tpkbd;
2763 data_pointer->led_mute.dev = dev;
2764 - led_classdev_register(dev, &data_pointer->led_mute);
2765 + ret = led_classdev_register(dev, &data_pointer->led_mute);
2766 + if (ret < 0)
2767 + goto err;
2768
2769 data_pointer->led_micmute.name = name_micmute;
2770 data_pointer->led_micmute.brightness_get =
2771 @@ -751,7 +753,11 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
2772 data_pointer->led_micmute.brightness_set =
2773 lenovo_led_brightness_set_tpkbd;
2774 data_pointer->led_micmute.dev = dev;
2775 - led_classdev_register(dev, &data_pointer->led_micmute);
2776 + ret = led_classdev_register(dev, &data_pointer->led_micmute);
2777 + if (ret < 0) {
2778 + led_classdev_unregister(&data_pointer->led_mute);
2779 + goto err;
2780 + }
2781
2782 lenovo_features_set_tpkbd(hdev);
2783
2784 diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
2785 index 08e3945a6fbf..0e30fa00204c 100644
2786 --- a/drivers/hwmon/lm80.c
2787 +++ b/drivers/hwmon/lm80.c
2788 @@ -360,9 +360,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
2789 struct i2c_client *client = data->client;
2790 unsigned long min, val;
2791 u8 reg;
2792 - int err = kstrtoul(buf, 10, &val);
2793 - if (err < 0)
2794 - return err;
2795 + int rv;
2796 +
2797 + rv = kstrtoul(buf, 10, &val);
2798 + if (rv < 0)
2799 + return rv;
2800
2801 /* Save fan_min */
2802 mutex_lock(&data->update_lock);
2803 @@ -390,8 +392,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
2804 return -EINVAL;
2805 }
2806
2807 - reg = (lm80_read_value(client, LM80_REG_FANDIV) &
2808 - ~(3 << (2 * (nr + 1)))) | (data->fan_div[nr] << (2 * (nr + 1)));
2809 + rv = lm80_read_value(client, LM80_REG_FANDIV);
2810 + if (rv < 0)
2811 + return rv;
2812 + reg = (rv & ~(3 << (2 * (nr + 1))))
2813 + | (data->fan_div[nr] << (2 * (nr + 1)));
2814 lm80_write_value(client, LM80_REG_FANDIV, reg);
2815
2816 /* Restore fan_min */
2817 @@ -623,6 +628,7 @@ static int lm80_probe(struct i2c_client *client,
2818 struct device *dev = &client->dev;
2819 struct device *hwmon_dev;
2820 struct lm80_data *data;
2821 + int rv;
2822
2823 data = devm_kzalloc(dev, sizeof(struct lm80_data), GFP_KERNEL);
2824 if (!data)
2825 @@ -635,8 +641,14 @@ static int lm80_probe(struct i2c_client *client,
2826 lm80_init_client(client);
2827
2828 /* A few vars need to be filled upon startup */
2829 - data->fan[f_min][0] = lm80_read_value(client, LM80_REG_FAN_MIN(1));
2830 - data->fan[f_min][1] = lm80_read_value(client, LM80_REG_FAN_MIN(2));
2831 + rv = lm80_read_value(client, LM80_REG_FAN_MIN(1));
2832 + if (rv < 0)
2833 + return rv;
2834 + data->fan[f_min][0] = rv;
2835 + rv = lm80_read_value(client, LM80_REG_FAN_MIN(2));
2836 + if (rv < 0)
2837 + return rv;
2838 + data->fan[f_min][1] = rv;
2839
2840 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
2841 data, lm80_groups);
2842 diff --git a/drivers/i2c/busses/i2c-axxia.c b/drivers/i2c/busses/i2c-axxia.c
2843 index 51d34959709b..fb5bac079e83 100644
2844 --- a/drivers/i2c/busses/i2c-axxia.c
2845 +++ b/drivers/i2c/busses/i2c-axxia.c
2846 @@ -296,22 +296,7 @@ static irqreturn_t axxia_i2c_isr(int irq, void *_dev)
2847 i2c_int_disable(idev, MST_STATUS_TFL);
2848 }
2849
2850 - if (status & MST_STATUS_SCC) {
2851 - /* Stop completed */
2852 - i2c_int_disable(idev, ~MST_STATUS_TSS);
2853 - complete(&idev->msg_complete);
2854 - } else if (status & MST_STATUS_SNS) {
2855 - /* Transfer done */
2856 - i2c_int_disable(idev, ~MST_STATUS_TSS);
2857 - if (i2c_m_rd(idev->msg) && idev->msg_xfrd < idev->msg->len)
2858 - axxia_i2c_empty_rx_fifo(idev);
2859 - complete(&idev->msg_complete);
2860 - } else if (status & MST_STATUS_TSS) {
2861 - /* Transfer timeout */
2862 - idev->msg_err = -ETIMEDOUT;
2863 - i2c_int_disable(idev, ~MST_STATUS_TSS);
2864 - complete(&idev->msg_complete);
2865 - } else if (unlikely(status & MST_STATUS_ERR)) {
2866 + if (unlikely(status & MST_STATUS_ERR)) {
2867 /* Transfer error */
2868 i2c_int_disable(idev, ~0);
2869 if (status & MST_STATUS_AL)
2870 @@ -328,6 +313,21 @@ static irqreturn_t axxia_i2c_isr(int irq, void *_dev)
2871 readl(idev->base + MST_TX_BYTES_XFRD),
2872 readl(idev->base + MST_TX_XFER));
2873 complete(&idev->msg_complete);
2874 + } else if (status & MST_STATUS_SCC) {
2875 + /* Stop completed */
2876 + i2c_int_disable(idev, ~MST_STATUS_TSS);
2877 + complete(&idev->msg_complete);
2878 + } else if (status & MST_STATUS_SNS) {
2879 + /* Transfer done */
2880 + i2c_int_disable(idev, ~MST_STATUS_TSS);
2881 + if (i2c_m_rd(idev->msg) && idev->msg_xfrd < idev->msg->len)
2882 + axxia_i2c_empty_rx_fifo(idev);
2883 + complete(&idev->msg_complete);
2884 + } else if (status & MST_STATUS_TSS) {
2885 + /* Transfer timeout */
2886 + idev->msg_err = -ETIMEDOUT;
2887 + i2c_int_disable(idev, ~MST_STATUS_TSS);
2888 + complete(&idev->msg_complete);
2889 }
2890
2891 out:
2892 diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
2893 index 818cab14e87c..ddcfb6d349d1 100644
2894 --- a/drivers/i2c/busses/i2c-sh_mobile.c
2895 +++ b/drivers/i2c/busses/i2c-sh_mobile.c
2896 @@ -800,6 +800,7 @@ static const struct sh_mobile_dt_config r8a7740_dt_config = {
2897 static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
2898 { .compatible = "renesas,iic-r8a73a4", .data = &fast_clock_dt_config },
2899 { .compatible = "renesas,iic-r8a7740", .data = &r8a7740_dt_config },
2900 + { .compatible = "renesas,iic-r8a774c0", .data = &fast_clock_dt_config },
2901 { .compatible = "renesas,iic-r8a7790", .data = &v2_freq_calc_dt_config },
2902 { .compatible = "renesas,iic-r8a7791", .data = &fast_clock_dt_config },
2903 { .compatible = "renesas,iic-r8a7792", .data = &fast_clock_dt_config },
2904 @@ -808,6 +809,7 @@ static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
2905 { .compatible = "renesas,rcar-gen2-iic", .data = &fast_clock_dt_config },
2906 { .compatible = "renesas,iic-r8a7795", .data = &fast_clock_dt_config },
2907 { .compatible = "renesas,rcar-gen3-iic", .data = &fast_clock_dt_config },
2908 + { .compatible = "renesas,iic-r8a77990", .data = &fast_clock_dt_config },
2909 { .compatible = "renesas,iic-sh73a0", .data = &fast_clock_dt_config },
2910 { .compatible = "renesas,rmobile-iic", .data = &default_dt_config },
2911 {},
2912 diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
2913 index af53a1084ee5..471caa5323e4 100644
2914 --- a/drivers/iio/accel/kxcjk-1013.c
2915 +++ b/drivers/iio/accel/kxcjk-1013.c
2916 @@ -1490,6 +1490,7 @@ static const struct acpi_device_id kx_acpi_match[] = {
2917 {"KXCJ1008", KXCJ91008},
2918 {"KXCJ9000", KXCJ91008},
2919 {"KIOX000A", KXCJ91008},
2920 + {"KIOX010A", KXCJ91008}, /* KXCJ91008 inside the display of a 2-in-1 */
2921 {"KXTJ1009", KXTJ21009},
2922 {"SMO8500", KXCJ91008},
2923 { },
2924 diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
2925 index da2d16dfa63e..5dd104cf0939 100644
2926 --- a/drivers/iio/adc/meson_saradc.c
2927 +++ b/drivers/iio/adc/meson_saradc.c
2928 @@ -587,8 +587,11 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev,
2929 struct clk_init_data init;
2930 const char *clk_parents[1];
2931
2932 - init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%pOF#adc_div",
2933 - indio_dev->dev.of_node);
2934 + init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%s#adc_div",
2935 + dev_name(indio_dev->dev.parent));
2936 + if (!init.name)
2937 + return -ENOMEM;
2938 +
2939 init.flags = 0;
2940 init.ops = &clk_divider_ops;
2941 clk_parents[0] = __clk_get_name(priv->clkin);
2942 @@ -606,8 +609,11 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev,
2943 if (WARN_ON(IS_ERR(priv->adc_div_clk)))
2944 return PTR_ERR(priv->adc_div_clk);
2945
2946 - init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%pOF#adc_en",
2947 - indio_dev->dev.of_node);
2948 + init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%s#adc_en",
2949 + dev_name(indio_dev->dev.parent));
2950 + if (!init.name)
2951 + return -ENOMEM;
2952 +
2953 init.flags = CLK_SET_RATE_PARENT;
2954 init.ops = &clk_gate_ops;
2955 clk_parents[0] = __clk_get_name(priv->adc_div_clk);
2956 diff --git a/drivers/infiniband/hw/hfi1/rc.c b/drivers/infiniband/hw/hfi1/rc.c
2957 index 9bd63abb2dfe..6f013a565353 100644
2958 --- a/drivers/infiniband/hw/hfi1/rc.c
2959 +++ b/drivers/infiniband/hw/hfi1/rc.c
2960 @@ -1157,6 +1157,7 @@ void hfi1_rc_send_complete(struct rvt_qp *qp, struct hfi1_opa_header *opah)
2961 if (cmp_psn(wqe->lpsn, qp->s_sending_psn) >= 0 &&
2962 cmp_psn(qp->s_sending_psn, qp->s_sending_hpsn) <= 0)
2963 break;
2964 + rvt_qp_wqe_unreserve(qp, wqe);
2965 s_last = qp->s_last;
2966 trace_hfi1_qp_send_completion(qp, wqe, s_last);
2967 if (++s_last >= qp->s_size)
2968 @@ -1209,6 +1210,7 @@ static struct rvt_swqe *do_rc_completion(struct rvt_qp *qp,
2969 u32 s_last;
2970
2971 rvt_put_swqe(wqe);
2972 + rvt_qp_wqe_unreserve(qp, wqe);
2973 s_last = qp->s_last;
2974 trace_hfi1_qp_send_completion(qp, wqe, s_last);
2975 if (++s_last >= qp->s_size)
2976 diff --git a/drivers/infiniband/hw/hfi1/ruc.c b/drivers/infiniband/hw/hfi1/ruc.c
2977 index 5f56f3c1b4c4..62a3832a1ebb 100644
2978 --- a/drivers/infiniband/hw/hfi1/ruc.c
2979 +++ b/drivers/infiniband/hw/hfi1/ruc.c
2980 @@ -278,6 +278,8 @@ send:
2981 goto op_err;
2982 if (!ret)
2983 goto rnr_nak;
2984 + if (wqe->length > qp->r_len)
2985 + goto inv_err;
2986 break;
2987
2988 case IB_WR_RDMA_WRITE_WITH_IMM:
2989 @@ -445,7 +447,10 @@ op_err:
2990 goto err;
2991
2992 inv_err:
2993 - send_status = IB_WC_REM_INV_REQ_ERR;
2994 + send_status =
2995 + sqp->ibqp.qp_type == IB_QPT_RC ?
2996 + IB_WC_REM_INV_REQ_ERR :
2997 + IB_WC_SUCCESS;
2998 wc.status = IB_WC_LOC_QP_OP_ERR;
2999 goto err;
3000
3001 diff --git a/drivers/infiniband/hw/qib/qib_ruc.c b/drivers/infiniband/hw/qib/qib_ruc.c
3002 index f8a7de795beb..563f71e6d1d3 100644
3003 --- a/drivers/infiniband/hw/qib/qib_ruc.c
3004 +++ b/drivers/infiniband/hw/qib/qib_ruc.c
3005 @@ -274,6 +274,8 @@ again:
3006 goto op_err;
3007 if (!ret)
3008 goto rnr_nak;
3009 + if (wqe->length > qp->r_len)
3010 + goto inv_err;
3011 break;
3012
3013 case IB_WR_RDMA_WRITE_WITH_IMM:
3014 @@ -434,7 +436,10 @@ op_err:
3015 goto err;
3016
3017 inv_err:
3018 - send_status = IB_WC_REM_INV_REQ_ERR;
3019 + send_status =
3020 + sqp->ibqp.qp_type == IB_QPT_RC ?
3021 + IB_WC_REM_INV_REQ_ERR :
3022 + IB_WC_SUCCESS;
3023 wc.status = IB_WC_LOC_QP_OP_ERR;
3024 goto err;
3025
3026 diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
3027 index bee0dfb7b93b..34c9aa76a7bd 100644
3028 --- a/drivers/iommu/amd_iommu.c
3029 +++ b/drivers/iommu/amd_iommu.c
3030 @@ -438,7 +438,14 @@ static int iommu_init_device(struct device *dev)
3031
3032 dev_data->alias = get_alias(dev);
3033
3034 - if (dev_is_pci(dev) && pci_iommuv2_capable(to_pci_dev(dev))) {
3035 + /*
3036 + * By default we use passthrough mode for IOMMUv2 capable device.
3037 + * But if amd_iommu=force_isolation is set (e.g. to debug DMA to
3038 + * invalid address), we ignore the capability for the device so
3039 + * it'll be forced to go into translation mode.
3040 + */
3041 + if ((iommu_pass_through || !amd_iommu_force_isolation) &&
3042 + dev_is_pci(dev) && pci_iommuv2_capable(to_pci_dev(dev))) {
3043 struct amd_iommu *iommu;
3044
3045 iommu = amd_iommu_rlookup_table[dev_data->devid];
3046 diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
3047 index 3e02aace38b1..9ae3678844eb 100644
3048 --- a/drivers/iommu/arm-smmu-v3.c
3049 +++ b/drivers/iommu/arm-smmu-v3.c
3050 @@ -586,7 +586,11 @@ struct arm_smmu_device {
3051
3052 struct arm_smmu_strtab_cfg strtab_cfg;
3053
3054 - u32 sync_count;
3055 + /* Hi16xx adds an extra 32 bits of goodness to its MSI payload */
3056 + union {
3057 + u32 sync_count;
3058 + u64 padding;
3059 + };
3060
3061 /* IOMMU core code handle */
3062 struct iommu_device iommu;
3063 @@ -684,7 +688,13 @@ static void queue_inc_cons(struct arm_smmu_queue *q)
3064 u32 cons = (Q_WRP(q, q->cons) | Q_IDX(q, q->cons)) + 1;
3065
3066 q->cons = Q_OVF(q, q->cons) | Q_WRP(q, cons) | Q_IDX(q, cons);
3067 - writel(q->cons, q->cons_reg);
3068 +
3069 + /*
3070 + * Ensure that all CPU accesses (reads and writes) to the queue
3071 + * are complete before we update the cons pointer.
3072 + */
3073 + mb();
3074 + writel_relaxed(q->cons, q->cons_reg);
3075 }
3076
3077 static int queue_sync_prod(struct arm_smmu_queue *q)
3078 diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
3079 index e7cbf4fcf61d..ce119cb279c3 100644
3080 --- a/drivers/iommu/arm-smmu.c
3081 +++ b/drivers/iommu/arm-smmu.c
3082 @@ -118,6 +118,7 @@ enum arm_smmu_implementation {
3083 GENERIC_SMMU,
3084 ARM_MMU500,
3085 CAVIUM_SMMUV2,
3086 + QCOM_SMMUV2,
3087 };
3088
3089 struct arm_smmu_s2cr {
3090 @@ -1912,6 +1913,7 @@ ARM_SMMU_MATCH_DATA(smmu_generic_v2, ARM_SMMU_V2, GENERIC_SMMU);
3091 ARM_SMMU_MATCH_DATA(arm_mmu401, ARM_SMMU_V1_64K, GENERIC_SMMU);
3092 ARM_SMMU_MATCH_DATA(arm_mmu500, ARM_SMMU_V2, ARM_MMU500);
3093 ARM_SMMU_MATCH_DATA(cavium_smmuv2, ARM_SMMU_V2, CAVIUM_SMMUV2);
3094 +ARM_SMMU_MATCH_DATA(qcom_smmuv2, ARM_SMMU_V2, QCOM_SMMUV2);
3095
3096 static const struct of_device_id arm_smmu_of_match[] = {
3097 { .compatible = "arm,smmu-v1", .data = &smmu_generic_v1 },
3098 @@ -1920,6 +1922,7 @@ static const struct of_device_id arm_smmu_of_match[] = {
3099 { .compatible = "arm,mmu-401", .data = &arm_mmu401 },
3100 { .compatible = "arm,mmu-500", .data = &arm_mmu500 },
3101 { .compatible = "cavium,smmu-v2", .data = &cavium_smmuv2 },
3102 + { .compatible = "qcom,smmu-v2", .data = &qcom_smmuv2 },
3103 { },
3104 };
3105 MODULE_DEVICE_TABLE(of, arm_smmu_of_match);
3106 diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
3107 index cf3abb8d284f..4c2246fe5dbe 100644
3108 --- a/drivers/irqchip/irq-gic-v3-its.c
3109 +++ b/drivers/irqchip/irq-gic-v3-its.c
3110 @@ -93,9 +93,14 @@ struct its_device;
3111 * The ITS structure - contains most of the infrastructure, with the
3112 * top-level MSI domain, the command queue, the collections, and the
3113 * list of devices writing to it.
3114 + *
3115 + * dev_alloc_lock has to be taken for device allocations, while the
3116 + * spinlock must be taken to parse data structures such as the device
3117 + * list.
3118 */
3119 struct its_node {
3120 raw_spinlock_t lock;
3121 + struct mutex dev_alloc_lock;
3122 struct list_head entry;
3123 void __iomem *base;
3124 phys_addr_t phys_base;
3125 @@ -152,6 +157,7 @@ struct its_device {
3126 void *itt;
3127 u32 nr_ites;
3128 u32 device_id;
3129 + bool shared;
3130 };
3131
3132 static struct {
3133 @@ -2290,6 +2296,7 @@ static int its_msi_prepare(struct irq_domain *domain, struct device *dev,
3134 struct its_device *its_dev;
3135 struct msi_domain_info *msi_info;
3136 u32 dev_id;
3137 + int err = 0;
3138
3139 /*
3140 * We ignore "dev" entierely, and rely on the dev_id that has
3141 @@ -2312,6 +2319,7 @@ static int its_msi_prepare(struct irq_domain *domain, struct device *dev,
3142 return -EINVAL;
3143 }
3144
3145 + mutex_lock(&its->dev_alloc_lock);
3146 its_dev = its_find_device(its, dev_id);
3147 if (its_dev) {
3148 /*
3149 @@ -2319,18 +2327,22 @@ static int its_msi_prepare(struct irq_domain *domain, struct device *dev,
3150 * another alias (PCI bridge of some sort). No need to
3151 * create the device.
3152 */
3153 + its_dev->shared = true;
3154 pr_debug("Reusing ITT for devID %x\n", dev_id);
3155 goto out;
3156 }
3157
3158 its_dev = its_create_device(its, dev_id, nvec, true);
3159 - if (!its_dev)
3160 - return -ENOMEM;
3161 + if (!its_dev) {
3162 + err = -ENOMEM;
3163 + goto out;
3164 + }
3165
3166 pr_debug("ITT %d entries, %d bits\n", nvec, ilog2(nvec));
3167 out:
3168 + mutex_unlock(&its->dev_alloc_lock);
3169 info->scratchpad[0].ptr = its_dev;
3170 - return 0;
3171 + return err;
3172 }
3173
3174 static struct msi_domain_ops its_msi_domain_ops = {
3175 @@ -2434,6 +2446,7 @@ static void its_irq_domain_free(struct irq_domain *domain, unsigned int virq,
3176 {
3177 struct irq_data *d = irq_domain_get_irq_data(domain, virq);
3178 struct its_device *its_dev = irq_data_get_irq_chip_data(d);
3179 + struct its_node *its = its_dev->its;
3180 int i;
3181
3182 for (i = 0; i < nr_irqs; i++) {
3183 @@ -2448,8 +2461,14 @@ static void its_irq_domain_free(struct irq_domain *domain, unsigned int virq,
3184 irq_domain_reset_irq_data(data);
3185 }
3186
3187 - /* If all interrupts have been freed, start mopping the floor */
3188 - if (bitmap_empty(its_dev->event_map.lpi_map,
3189 + mutex_lock(&its->dev_alloc_lock);
3190 +
3191 + /*
3192 + * If all interrupts have been freed, start mopping the
3193 + * floor. This is conditionned on the device not being shared.
3194 + */
3195 + if (!its_dev->shared &&
3196 + bitmap_empty(its_dev->event_map.lpi_map,
3197 its_dev->event_map.nr_lpis)) {
3198 its_lpi_free(its_dev->event_map.lpi_map,
3199 its_dev->event_map.lpi_base,
3200 @@ -2461,6 +2480,8 @@ static void its_irq_domain_free(struct irq_domain *domain, unsigned int virq,
3201 its_free_device(its_dev);
3202 }
3203
3204 + mutex_unlock(&its->dev_alloc_lock);
3205 +
3206 irq_domain_free_irqs_parent(domain, virq, nr_irqs);
3207 }
3208
3209 @@ -3385,6 +3406,7 @@ static int __init its_probe_one(struct resource *res,
3210 }
3211
3212 raw_spin_lock_init(&its->lock);
3213 + mutex_init(&its->dev_alloc_lock);
3214 INIT_LIST_HEAD(&its->entry);
3215 INIT_LIST_HEAD(&its->its_device_list);
3216 typer = gic_read_typer(its_base + GITS_TYPER);
3217 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
3218 index 8e5b03161b2f..64a63711fd95 100644
3219 --- a/drivers/isdn/hisax/hfc_pci.c
3220 +++ b/drivers/isdn/hisax/hfc_pci.c
3221 @@ -1170,11 +1170,13 @@ HFCPCI_l1hw(struct PStack *st, int pr, void *arg)
3222 if (cs->debug & L1_DEB_LAPD)
3223 debugl1(cs, "-> PH_REQUEST_PULL");
3224 #endif
3225 + spin_lock_irqsave(&cs->lock, flags);
3226 if (!cs->tx_skb) {
3227 test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
3228 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
3229 } else
3230 test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
3231 + spin_unlock_irqrestore(&cs->lock, flags);
3232 break;
3233 case (HW_RESET | REQUEST):
3234 spin_lock_irqsave(&cs->lock, flags);
3235 diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
3236 index 2940cdc87af1..95be6e36c7dd 100644
3237 --- a/drivers/lightnvm/pblk-core.c
3238 +++ b/drivers/lightnvm/pblk-core.c
3239 @@ -1252,15 +1252,22 @@ int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line)
3240
3241 ret = pblk_line_alloc_bitmaps(pblk, line);
3242 if (ret)
3243 - return ret;
3244 + goto fail;
3245
3246 if (!pblk_line_init_bb(pblk, line, 0)) {
3247 - list_add(&line->list, &l_mg->free_list);
3248 - return -EINTR;
3249 + ret = -EINTR;
3250 + goto fail;
3251 }
3252
3253 pblk_rl_free_lines_dec(&pblk->rl, line, true);
3254 return 0;
3255 +
3256 +fail:
3257 + spin_lock(&l_mg->free_lock);
3258 + list_add(&line->list, &l_mg->free_list);
3259 + spin_unlock(&l_mg->free_lock);
3260 +
3261 + return ret;
3262 }
3263
3264 void pblk_line_recov_close(struct pblk *pblk, struct pblk_line *line)
3265 diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
3266 index 879227d584e7..c3e038d4b22e 100644
3267 --- a/drivers/lightnvm/pblk-write.c
3268 +++ b/drivers/lightnvm/pblk-write.c
3269 @@ -158,9 +158,11 @@ static void pblk_prepare_resubmit(struct pblk *pblk, unsigned int sentry,
3270 w_ctx = &entry->w_ctx;
3271
3272 /* Check if the lba has been overwritten */
3273 - ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba);
3274 - if (!pblk_ppa_comp(ppa_l2p, entry->cacheline))
3275 - w_ctx->lba = ADDR_EMPTY;
3276 + if (w_ctx->lba != ADDR_EMPTY) {
3277 + ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba);
3278 + if (!pblk_ppa_comp(ppa_l2p, entry->cacheline))
3279 + w_ctx->lba = ADDR_EMPTY;
3280 + }
3281
3282 /* Mark up the entry as submittable again */
3283 flags = READ_ONCE(w_ctx->flags);
3284 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
3285 index 811427e53126..7033a2880771 100644
3286 --- a/drivers/md/raid10.c
3287 +++ b/drivers/md/raid10.c
3288 @@ -1208,7 +1208,9 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
3289 struct bio *split = bio_split(bio, max_sectors,
3290 gfp, &conf->bio_split);
3291 bio_chain(split, bio);
3292 + allow_barrier(conf);
3293 generic_make_request(bio);
3294 + wait_barrier(conf);
3295 bio = split;
3296 r10_bio->master_bio = bio;
3297 r10_bio->sectors = max_sectors;
3298 @@ -1513,7 +1515,9 @@ retry_write:
3299 struct bio *split = bio_split(bio, r10_bio->sectors,
3300 GFP_NOIO, &conf->bio_split);
3301 bio_chain(split, bio);
3302 + allow_barrier(conf);
3303 generic_make_request(bio);
3304 + wait_barrier(conf);
3305 bio = split;
3306 r10_bio->master_bio = bio;
3307 }
3308 diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
3309 index 82af97430e5b..63c9ac2c6a5f 100644
3310 --- a/drivers/media/i2c/Kconfig
3311 +++ b/drivers/media/i2c/Kconfig
3312 @@ -61,6 +61,7 @@ config VIDEO_TDA1997X
3313 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
3314 depends on SND_SOC
3315 select SND_PCM
3316 + select HDMI
3317 ---help---
3318 V4L2 subdevice driver for the NXP TDA1997x HDMI receivers.
3319
3320 @@ -610,6 +611,7 @@ config VIDEO_IMX274
3321 tristate "Sony IMX274 sensor support"
3322 depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
3323 depends on MEDIA_CAMERA_SUPPORT
3324 + select REGMAP_I2C
3325 ---help---
3326 This is a V4L2 sensor driver for the Sony IMX274
3327 CMOS image sensor.
3328 diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
3329 index 5b008b0002c0..aa8b04cfed0f 100644
3330 --- a/drivers/media/i2c/ad9389b.c
3331 +++ b/drivers/media/i2c/ad9389b.c
3332 @@ -578,7 +578,7 @@ static const struct v4l2_dv_timings_cap ad9389b_timings_cap = {
3333 .type = V4L2_DV_BT_656_1120,
3334 /* keep this initialization for compatibility with GCC < 4.4.6 */
3335 .reserved = { 0 },
3336 - V4L2_INIT_BT_TIMINGS(0, 1920, 0, 1200, 25000000, 170000000,
3337 + V4L2_INIT_BT_TIMINGS(640, 1920, 350, 1200, 25000000, 170000000,
3338 V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
3339 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
3340 V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_REDUCED_BLANKING |
3341 diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
3342 index f3899cc84e27..88349b5053cc 100644
3343 --- a/drivers/media/i2c/adv7511.c
3344 +++ b/drivers/media/i2c/adv7511.c
3345 @@ -130,7 +130,7 @@ static const struct v4l2_dv_timings_cap adv7511_timings_cap = {
3346 .type = V4L2_DV_BT_656_1120,
3347 /* keep this initialization for compatibility with GCC < 4.4.6 */
3348 .reserved = { 0 },
3349 - V4L2_INIT_BT_TIMINGS(0, ADV7511_MAX_WIDTH, 0, ADV7511_MAX_HEIGHT,
3350 + V4L2_INIT_BT_TIMINGS(640, ADV7511_MAX_WIDTH, 350, ADV7511_MAX_HEIGHT,
3351 ADV7511_MIN_PIXELCLOCK, ADV7511_MAX_PIXELCLOCK,
3352 V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
3353 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
3354 diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
3355 index c78698199ac5..f01964c36ad5 100644
3356 --- a/drivers/media/i2c/adv7604.c
3357 +++ b/drivers/media/i2c/adv7604.c
3358 @@ -766,7 +766,7 @@ static const struct v4l2_dv_timings_cap adv7604_timings_cap_analog = {
3359 .type = V4L2_DV_BT_656_1120,
3360 /* keep this initialization for compatibility with GCC < 4.4.6 */
3361 .reserved = { 0 },
3362 - V4L2_INIT_BT_TIMINGS(0, 1920, 0, 1200, 25000000, 170000000,
3363 + V4L2_INIT_BT_TIMINGS(640, 1920, 350, 1200, 25000000, 170000000,
3364 V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
3365 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
3366 V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_REDUCED_BLANKING |
3367 @@ -777,7 +777,7 @@ static const struct v4l2_dv_timings_cap adv76xx_timings_cap_digital = {
3368 .type = V4L2_DV_BT_656_1120,
3369 /* keep this initialization for compatibility with GCC < 4.4.6 */
3370 .reserved = { 0 },
3371 - V4L2_INIT_BT_TIMINGS(0, 1920, 0, 1200, 25000000, 225000000,
3372 + V4L2_INIT_BT_TIMINGS(640, 1920, 350, 1200, 25000000, 225000000,
3373 V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
3374 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
3375 V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_REDUCED_BLANKING |
3376 diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
3377 index 71fe56565f75..bb43a75ed6d0 100644
3378 --- a/drivers/media/i2c/adv7842.c
3379 +++ b/drivers/media/i2c/adv7842.c
3380 @@ -663,7 +663,7 @@ static const struct v4l2_dv_timings_cap adv7842_timings_cap_analog = {
3381 .type = V4L2_DV_BT_656_1120,
3382 /* keep this initialization for compatibility with GCC < 4.4.6 */
3383 .reserved = { 0 },
3384 - V4L2_INIT_BT_TIMINGS(0, 1920, 0, 1200, 25000000, 170000000,
3385 + V4L2_INIT_BT_TIMINGS(640, 1920, 350, 1200, 25000000, 170000000,
3386 V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
3387 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
3388 V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_REDUCED_BLANKING |
3389 @@ -674,7 +674,7 @@ static const struct v4l2_dv_timings_cap adv7842_timings_cap_digital = {
3390 .type = V4L2_DV_BT_656_1120,
3391 /* keep this initialization for compatibility with GCC < 4.4.6 */
3392 .reserved = { 0 },
3393 - V4L2_INIT_BT_TIMINGS(0, 1920, 0, 1200, 25000000, 225000000,
3394 + V4L2_INIT_BT_TIMINGS(640, 1920, 350, 1200, 25000000, 225000000,
3395 V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
3396 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
3397 V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_REDUCED_BLANKING |
3398 diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
3399 index ff25ea9aca48..26070fb6ce4e 100644
3400 --- a/drivers/media/i2c/tc358743.c
3401 +++ b/drivers/media/i2c/tc358743.c
3402 @@ -59,7 +59,7 @@ static const struct v4l2_dv_timings_cap tc358743_timings_cap = {
3403 /* keep this initialization for compatibility with GCC < 4.4.6 */
3404 .reserved = { 0 },
3405 /* Pixel clock from REF_01 p. 20. Min/max height/width are unknown */
3406 - V4L2_INIT_BT_TIMINGS(1, 10000, 1, 10000, 0, 165000000,
3407 + V4L2_INIT_BT_TIMINGS(640, 1920, 350, 1200, 13000000, 165000000,
3408 V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
3409 V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
3410 V4L2_DV_BT_CAP_PROGRESSIVE |
3411 diff --git a/drivers/media/i2c/ths8200.c b/drivers/media/i2c/ths8200.c
3412 index 498ad2368cbc..f5ee28058ea2 100644
3413 --- a/drivers/media/i2c/ths8200.c
3414 +++ b/drivers/media/i2c/ths8200.c
3415 @@ -49,7 +49,7 @@ static const struct v4l2_dv_timings_cap ths8200_timings_cap = {
3416 .type = V4L2_DV_BT_656_1120,
3417 /* keep this initialization for compatibility with GCC < 4.4.6 */
3418 .reserved = { 0 },
3419 - V4L2_INIT_BT_TIMINGS(0, 1920, 0, 1080, 25000000, 148500000,
3420 + V4L2_INIT_BT_TIMINGS(640, 1920, 350, 1080, 25000000, 148500000,
3421 V4L2_DV_BT_STD_CEA861, V4L2_DV_BT_CAP_PROGRESSIVE)
3422 };
3423
3424 diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
3425 index 06d29d8f6be8..f27d294dcbef 100644
3426 --- a/drivers/media/i2c/video-i2c.c
3427 +++ b/drivers/media/i2c/video-i2c.c
3428 @@ -510,7 +510,12 @@ static const struct v4l2_ioctl_ops video_i2c_ioctl_ops = {
3429
3430 static void video_i2c_release(struct video_device *vdev)
3431 {
3432 - kfree(video_get_drvdata(vdev));
3433 + struct video_i2c_data *data = video_get_drvdata(vdev);
3434 +
3435 + v4l2_device_unregister(&data->v4l2_dev);
3436 + mutex_destroy(&data->lock);
3437 + mutex_destroy(&data->queue_lock);
3438 + kfree(data);
3439 }
3440
3441 static int video_i2c_probe(struct i2c_client *client,
3442 @@ -608,10 +613,6 @@ static int video_i2c_remove(struct i2c_client *client)
3443 struct video_i2c_data *data = i2c_get_clientdata(client);
3444
3445 video_unregister_device(&data->vdev);
3446 - v4l2_device_unregister(&data->v4l2_dev);
3447 -
3448 - mutex_destroy(&data->lock);
3449 - mutex_destroy(&data->queue_lock);
3450
3451 return 0;
3452 }
3453 diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
3454 index d26c2d85a009..d20d3df5778b 100644
3455 --- a/drivers/media/platform/coda/coda-bit.c
3456 +++ b/drivers/media/platform/coda/coda-bit.c
3457 @@ -991,16 +991,15 @@ static int coda_start_encoding(struct coda_ctx *ctx)
3458 else
3459 coda_write(dev, CODA_STD_H264,
3460 CODA_CMD_ENC_SEQ_COD_STD);
3461 - if (ctx->params.h264_deblk_enabled) {
3462 - value = ((ctx->params.h264_deblk_alpha &
3463 - CODA_264PARAM_DEBLKFILTEROFFSETALPHA_MASK) <<
3464 - CODA_264PARAM_DEBLKFILTEROFFSETALPHA_OFFSET) |
3465 - ((ctx->params.h264_deblk_beta &
3466 - CODA_264PARAM_DEBLKFILTEROFFSETBETA_MASK) <<
3467 - CODA_264PARAM_DEBLKFILTEROFFSETBETA_OFFSET);
3468 - } else {
3469 - value = 1 << CODA_264PARAM_DISABLEDEBLK_OFFSET;
3470 - }
3471 + value = ((ctx->params.h264_disable_deblocking_filter_idc &
3472 + CODA_264PARAM_DISABLEDEBLK_MASK) <<
3473 + CODA_264PARAM_DISABLEDEBLK_OFFSET) |
3474 + ((ctx->params.h264_slice_alpha_c0_offset_div2 &
3475 + CODA_264PARAM_DEBLKFILTEROFFSETALPHA_MASK) <<
3476 + CODA_264PARAM_DEBLKFILTEROFFSETALPHA_OFFSET) |
3477 + ((ctx->params.h264_slice_beta_offset_div2 &
3478 + CODA_264PARAM_DEBLKFILTEROFFSETBETA_MASK) <<
3479 + CODA_264PARAM_DEBLKFILTEROFFSETBETA_OFFSET);
3480 coda_write(dev, value, CODA_CMD_ENC_SEQ_264_PARA);
3481 break;
3482 case V4L2_PIX_FMT_JPEG:
3483 diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
3484 index bf7b8417c27f..19d92edcc981 100644
3485 --- a/drivers/media/platform/coda/coda-common.c
3486 +++ b/drivers/media/platform/coda/coda-common.c
3487 @@ -1793,14 +1793,13 @@ static int coda_s_ctrl(struct v4l2_ctrl *ctrl)
3488 ctx->params.h264_max_qp = ctrl->val;
3489 break;
3490 case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA:
3491 - ctx->params.h264_deblk_alpha = ctrl->val;
3492 + ctx->params.h264_slice_alpha_c0_offset_div2 = ctrl->val;
3493 break;
3494 case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA:
3495 - ctx->params.h264_deblk_beta = ctrl->val;
3496 + ctx->params.h264_slice_beta_offset_div2 = ctrl->val;
3497 break;
3498 case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE:
3499 - ctx->params.h264_deblk_enabled = (ctrl->val ==
3500 - V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED);
3501 + ctx->params.h264_disable_deblocking_filter_idc = ctrl->val;
3502 break;
3503 case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
3504 /* TODO: switch between baseline and constrained baseline */
3505 @@ -1882,13 +1881,13 @@ static void coda_encode_ctrls(struct coda_ctx *ctx)
3506 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
3507 V4L2_CID_MPEG_VIDEO_H264_MAX_QP, 0, 51, 1, 51);
3508 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
3509 - V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA, 0, 15, 1, 0);
3510 + V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA, -6, 6, 1, 0);
3511 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
3512 - V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA, 0, 15, 1, 0);
3513 + V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA, -6, 6, 1, 0);
3514 v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops,
3515 V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE,
3516 - V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED, 0x0,
3517 - V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED);
3518 + V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY,
3519 + 0x0, V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED);
3520 v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops,
3521 V4L2_CID_MPEG_VIDEO_H264_PROFILE,
3522 V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, 0x0,
3523 diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h
3524 index 19ac0b9dc6eb..2469ca1dc598 100644
3525 --- a/drivers/media/platform/coda/coda.h
3526 +++ b/drivers/media/platform/coda/coda.h
3527 @@ -115,9 +115,9 @@ struct coda_params {
3528 u8 h264_inter_qp;
3529 u8 h264_min_qp;
3530 u8 h264_max_qp;
3531 - u8 h264_deblk_enabled;
3532 - u8 h264_deblk_alpha;
3533 - u8 h264_deblk_beta;
3534 + u8 h264_disable_deblocking_filter_idc;
3535 + s8 h264_slice_alpha_c0_offset_div2;
3536 + s8 h264_slice_beta_offset_div2;
3537 u8 h264_profile_idc;
3538 u8 h264_level_idc;
3539 u8 mpeg4_intra_qp;
3540 diff --git a/drivers/media/platform/coda/coda_regs.h b/drivers/media/platform/coda/coda_regs.h
3541 index 5e7b00a97671..e675e38f3475 100644
3542 --- a/drivers/media/platform/coda/coda_regs.h
3543 +++ b/drivers/media/platform/coda/coda_regs.h
3544 @@ -292,7 +292,7 @@
3545 #define CODA_264PARAM_DEBLKFILTEROFFSETALPHA_OFFSET 8
3546 #define CODA_264PARAM_DEBLKFILTEROFFSETALPHA_MASK 0x0f
3547 #define CODA_264PARAM_DISABLEDEBLK_OFFSET 6
3548 -#define CODA_264PARAM_DISABLEDEBLK_MASK 0x01
3549 +#define CODA_264PARAM_DISABLEDEBLK_MASK 0x03
3550 #define CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_OFFSET 5
3551 #define CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_MASK 0x01
3552 #define CODA_264PARAM_CHROMAQPOFFSET_OFFSET 0
3553 diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
3554 index 18c035ef84cf..df1ae6b5c854 100644
3555 --- a/drivers/media/platform/davinci/vpbe.c
3556 +++ b/drivers/media/platform/davinci/vpbe.c
3557 @@ -740,7 +740,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
3558 if (ret) {
3559 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default output %s",
3560 def_output);
3561 - return ret;
3562 + goto fail_kfree_amp;
3563 }
3564
3565 printk(KERN_NOTICE "Setting default mode to %s\n", def_mode);
3566 @@ -748,12 +748,15 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
3567 if (ret) {
3568 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default mode %s",
3569 def_mode);
3570 - return ret;
3571 + goto fail_kfree_amp;
3572 }
3573 vpbe_dev->initialized = 1;
3574 /* TBD handling of bootargs for default output and mode */
3575 return 0;
3576
3577 +fail_kfree_amp:
3578 + mutex_lock(&vpbe_dev->lock);
3579 + kfree(vpbe_dev->amp);
3580 fail_kfree_encoders:
3581 kfree(vpbe_dev->encoders);
3582 fail_dev_unregister:
3583 diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
3584 index 3e73e9db781f..7c025045ea90 100644
3585 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
3586 +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
3587 @@ -41,25 +41,27 @@ int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
3588 node = of_parse_phandle(dev->of_node, "mediatek,larb", 0);
3589 if (!node) {
3590 mtk_v4l2_err("no mediatek,larb found");
3591 - return -1;
3592 + return -ENODEV;
3593 }
3594 pdev = of_find_device_by_node(node);
3595 + of_node_put(node);
3596 if (!pdev) {
3597 mtk_v4l2_err("no mediatek,larb device found");
3598 - return -1;
3599 + return -ENODEV;
3600 }
3601 pm->larbvenc = &pdev->dev;
3602
3603 node = of_parse_phandle(dev->of_node, "mediatek,larb", 1);
3604 if (!node) {
3605 mtk_v4l2_err("no mediatek,larb found");
3606 - return -1;
3607 + return -ENODEV;
3608 }
3609
3610 pdev = of_find_device_by_node(node);
3611 + of_node_put(node);
3612 if (!pdev) {
3613 mtk_v4l2_err("no mediatek,larb device found");
3614 - return -1;
3615 + return -ENODEV;
3616 }
3617
3618 pm->larbvenclt = &pdev->dev;
3619 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
3620 index 8b2c16dd58bd..0f218afdadaa 100644
3621 --- a/drivers/media/rc/rc-main.c
3622 +++ b/drivers/media/rc/rc-main.c
3623 @@ -1956,6 +1956,8 @@ void rc_unregister_device(struct rc_dev *dev)
3624 rc_free_rx_device(dev);
3625
3626 mutex_lock(&dev->lock);
3627 + if (dev->users && dev->close)
3628 + dev->close(dev);
3629 dev->registered = false;
3630 mutex_unlock(&dev->lock);
3631
3632 diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
3633 index 76382c858c35..1246d69ba187 100644
3634 --- a/drivers/memstick/core/memstick.c
3635 +++ b/drivers/memstick/core/memstick.c
3636 @@ -18,6 +18,7 @@
3637 #include <linux/delay.h>
3638 #include <linux/slab.h>
3639 #include <linux/module.h>
3640 +#include <linux/pm_runtime.h>
3641
3642 #define DRIVER_NAME "memstick"
3643
3644 @@ -436,6 +437,7 @@ static void memstick_check(struct work_struct *work)
3645 struct memstick_dev *card;
3646
3647 dev_dbg(&host->dev, "memstick_check started\n");
3648 + pm_runtime_get_noresume(host->dev.parent);
3649 mutex_lock(&host->lock);
3650 if (!host->card) {
3651 if (memstick_power_on(host))
3652 @@ -479,6 +481,7 @@ out_power_off:
3653 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
3654
3655 mutex_unlock(&host->lock);
3656 + pm_runtime_put(host->dev.parent);
3657 dev_dbg(&host->dev, "memstick_check finished\n");
3658 }
3659
3660 diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
3661 index 0d3b7473bc21..5301302fb531 100644
3662 --- a/drivers/mmc/host/bcm2835.c
3663 +++ b/drivers/mmc/host/bcm2835.c
3664 @@ -286,6 +286,7 @@ static void bcm2835_reset(struct mmc_host *mmc)
3665
3666 if (host->dma_chan)
3667 dmaengine_terminate_sync(host->dma_chan);
3668 + host->dma_chan = NULL;
3669 bcm2835_reset_internal(host);
3670 }
3671
3672 @@ -772,6 +773,8 @@ static void bcm2835_finish_command(struct bcm2835_host *host)
3673
3674 if (!(sdhsts & SDHSTS_CRC7_ERROR) ||
3675 (host->cmd->opcode != MMC_SEND_OP_COND)) {
3676 + u32 edm, fsm;
3677 +
3678 if (sdhsts & SDHSTS_CMD_TIME_OUT) {
3679 host->cmd->error = -ETIMEDOUT;
3680 } else {
3681 @@ -780,6 +783,13 @@ static void bcm2835_finish_command(struct bcm2835_host *host)
3682 bcm2835_dumpregs(host);
3683 host->cmd->error = -EILSEQ;
3684 }
3685 + edm = readl(host->ioaddr + SDEDM);
3686 + fsm = edm & SDEDM_FSM_MASK;
3687 + if (fsm == SDEDM_FSM_READWAIT ||
3688 + fsm == SDEDM_FSM_WRITESTART1)
3689 + /* Kick the FSM out of its wait */
3690 + writel(edm | SDEDM_FORCE_DATA_MODE,
3691 + host->ioaddr + SDEDM);
3692 bcm2835_finish_request(host);
3693 return;
3694 }
3695 @@ -837,6 +847,8 @@ static void bcm2835_timeout(struct work_struct *work)
3696 dev_err(dev, "timeout waiting for hardware interrupt.\n");
3697 bcm2835_dumpregs(host);
3698
3699 + bcm2835_reset(host->mmc);
3700 +
3701 if (host->data) {
3702 host->data->error = -ETIMEDOUT;
3703 bcm2835_finish_data(host);
3704 diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
3705 index 993386c9ea50..864338e308e2 100644
3706 --- a/drivers/mmc/host/jz4740_mmc.c
3707 +++ b/drivers/mmc/host/jz4740_mmc.c
3708 @@ -983,17 +983,17 @@ static int jz4740_mmc_request_gpios(struct mmc_host *mmc,
3709 if (!pdata->read_only_active_low)
3710 mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
3711
3712 - if (gpio_is_valid(pdata->gpio_card_detect)) {
3713 - ret = mmc_gpio_request_cd(mmc, pdata->gpio_card_detect, 0);
3714 - if (ret)
3715 - return ret;
3716 - }
3717 + /*
3718 + * Get optional card detect and write protect GPIOs,
3719 + * only back out on probe deferral.
3720 + */
3721 + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL);
3722 + if (ret == -EPROBE_DEFER)
3723 + return ret;
3724
3725 - if (gpio_is_valid(pdata->gpio_read_only)) {
3726 - ret = mmc_gpio_request_ro(mmc, pdata->gpio_read_only);
3727 - if (ret)
3728 - return ret;
3729 - }
3730 + ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL);
3731 + if (ret == -EPROBE_DEFER)
3732 + return ret;
3733
3734 return jz4740_mmc_request_gpio(&pdev->dev, pdata->gpio_power,
3735 "MMC read only", true, pdata->power_active_low);
3736 diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c
3737 index 2cfec33178c1..9841b447ccde 100644
3738 --- a/drivers/mmc/host/meson-mx-sdio.c
3739 +++ b/drivers/mmc/host/meson-mx-sdio.c
3740 @@ -596,6 +596,9 @@ static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host)
3741 init.name = devm_kasprintf(host->controller_dev, GFP_KERNEL,
3742 "%s#fixed_factor",
3743 dev_name(host->controller_dev));
3744 + if (!init.name)
3745 + return -ENOMEM;
3746 +
3747 init.ops = &clk_fixed_factor_ops;
3748 init.flags = 0;
3749 init.parent_names = &clk_fixed_factor_parent;
3750 @@ -612,6 +615,9 @@ static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host)
3751 clk_div_parent = __clk_get_name(host->fixed_factor_clk);
3752 init.name = devm_kasprintf(host->controller_dev, GFP_KERNEL,
3753 "%s#div", dev_name(host->controller_dev));
3754 + if (!init.name)
3755 + return -ENOMEM;
3756 +
3757 init.ops = &clk_divider_ops;
3758 init.flags = CLK_SET_RATE_PARENT;
3759 init.parent_names = &clk_div_parent;
3760 diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
3761 index 9cb7554a463d..a7bf8515116f 100644
3762 --- a/drivers/mmc/host/sdhci-of-esdhc.c
3763 +++ b/drivers/mmc/host/sdhci-of-esdhc.c
3764 @@ -526,8 +526,12 @@ static void esdhc_clock_enable(struct sdhci_host *host, bool enable)
3765 /* Wait max 20 ms */
3766 timeout = ktime_add_ms(ktime_get(), 20);
3767 val = ESDHC_CLOCK_STABLE;
3768 - while (!(sdhci_readl(host, ESDHC_PRSSTAT) & val)) {
3769 - if (ktime_after(ktime_get(), timeout)) {
3770 + while (1) {
3771 + bool timedout = ktime_after(ktime_get(), timeout);
3772 +
3773 + if (sdhci_readl(host, ESDHC_PRSSTAT) & val)
3774 + break;
3775 + if (timedout) {
3776 pr_err("%s: Internal clock never stabilised.\n",
3777 mmc_hostname(host->mmc));
3778 break;
3779 @@ -591,8 +595,12 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
3780
3781 /* Wait max 20 ms */
3782 timeout = ktime_add_ms(ktime_get(), 20);
3783 - while (!(sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)) {
3784 - if (ktime_after(ktime_get(), timeout)) {
3785 + while (1) {
3786 + bool timedout = ktime_after(ktime_get(), timeout);
3787 +
3788 + if (sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)
3789 + break;
3790 + if (timedout) {
3791 pr_err("%s: Internal clock never stabilised.\n",
3792 mmc_hostname(host->mmc));
3793 return;
3794 diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
3795 index d264391616f9..d02f5cf76b3d 100644
3796 --- a/drivers/mmc/host/sdhci-omap.c
3797 +++ b/drivers/mmc/host/sdhci-omap.c
3798 @@ -220,8 +220,12 @@ static void sdhci_omap_conf_bus_power(struct sdhci_omap_host *omap_host,
3799
3800 /* wait 1ms */
3801 timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT);
3802 - while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP)) {
3803 - if (WARN_ON(ktime_after(ktime_get(), timeout)))
3804 + while (1) {
3805 + bool timedout = ktime_after(ktime_get(), timeout);
3806 +
3807 + if (sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP)
3808 + break;
3809 + if (WARN_ON(timedout))
3810 return;
3811 usleep_range(5, 10);
3812 }
3813 @@ -653,8 +657,12 @@ static void sdhci_omap_init_74_clocks(struct sdhci_host *host, u8 power_mode)
3814
3815 /* wait 1ms */
3816 timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT);
3817 - while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN)) {
3818 - if (WARN_ON(ktime_after(ktime_get(), timeout)))
3819 + while (1) {
3820 + bool timedout = ktime_after(ktime_get(), timeout);
3821 +
3822 + if (sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN)
3823 + break;
3824 + if (WARN_ON(timedout))
3825 return;
3826 usleep_range(5, 10);
3827 }
3828 diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c
3829 index c335052d0c02..caccedc836dc 100644
3830 --- a/drivers/mmc/host/sdhci-xenon-phy.c
3831 +++ b/drivers/mmc/host/sdhci-xenon-phy.c
3832 @@ -357,9 +357,13 @@ static int xenon_emmc_phy_enable_dll(struct sdhci_host *host)
3833
3834 /* Wait max 32 ms */
3835 timeout = ktime_add_ms(ktime_get(), 32);
3836 - while (!(sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) &
3837 - XENON_DLL_LOCK_STATE)) {
3838 - if (ktime_after(ktime_get(), timeout)) {
3839 + while (1) {
3840 + bool timedout = ktime_after(ktime_get(), timeout);
3841 +
3842 + if (sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) &
3843 + XENON_DLL_LOCK_STATE)
3844 + break;
3845 + if (timedout) {
3846 dev_err(mmc_dev(host->mmc), "Wait for DLL Lock time-out\n");
3847 return -ETIMEDOUT;
3848 }
3849 diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
3850 index 4d0791f6ec23..a0b5089b3274 100644
3851 --- a/drivers/mmc/host/sdhci-xenon.c
3852 +++ b/drivers/mmc/host/sdhci-xenon.c
3853 @@ -34,9 +34,13 @@ static int xenon_enable_internal_clk(struct sdhci_host *host)
3854 sdhci_writel(host, reg, SDHCI_CLOCK_CONTROL);
3855 /* Wait max 20 ms */
3856 timeout = ktime_add_ms(ktime_get(), 20);
3857 - while (!((reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
3858 - & SDHCI_CLOCK_INT_STABLE)) {
3859 - if (ktime_after(ktime_get(), timeout)) {
3860 + while (1) {
3861 + bool timedout = ktime_after(ktime_get(), timeout);
3862 +
3863 + reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
3864 + if (reg & SDHCI_CLOCK_INT_STABLE)
3865 + break;
3866 + if (timedout) {
3867 dev_err(mmc_dev(host->mmc), "Internal clock never stabilised.\n");
3868 return -ETIMEDOUT;
3869 }
3870 diff --git a/drivers/net/dsa/mv88e6xxx/global1_atu.c b/drivers/net/dsa/mv88e6xxx/global1_atu.c
3871 index 5200e4bdce93..ea243840ee0f 100644
3872 --- a/drivers/net/dsa/mv88e6xxx/global1_atu.c
3873 +++ b/drivers/net/dsa/mv88e6xxx/global1_atu.c
3874 @@ -314,6 +314,7 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
3875 {
3876 struct mv88e6xxx_chip *chip = dev_id;
3877 struct mv88e6xxx_atu_entry entry;
3878 + int spid;
3879 int err;
3880 u16 val;
3881
3882 @@ -336,6 +337,8 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
3883 if (err)
3884 goto out;
3885
3886 + spid = entry.state;
3887 +
3888 if (val & MV88E6XXX_G1_ATU_OP_AGE_OUT_VIOLATION) {
3889 dev_err_ratelimited(chip->dev,
3890 "ATU age out violation for %pM\n",
3891 @@ -344,23 +347,23 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
3892
3893 if (val & MV88E6XXX_G1_ATU_OP_MEMBER_VIOLATION) {
3894 dev_err_ratelimited(chip->dev,
3895 - "ATU member violation for %pM portvec %x\n",
3896 - entry.mac, entry.portvec);
3897 - chip->ports[entry.portvec].atu_member_violation++;
3898 + "ATU member violation for %pM portvec %x spid %d\n",
3899 + entry.mac, entry.portvec, spid);
3900 + chip->ports[spid].atu_member_violation++;
3901 }
3902
3903 if (val & MV88E6XXX_G1_ATU_OP_MISS_VIOLATION) {
3904 dev_err_ratelimited(chip->dev,
3905 - "ATU miss violation for %pM portvec %x\n",
3906 - entry.mac, entry.portvec);
3907 - chip->ports[entry.portvec].atu_miss_violation++;
3908 + "ATU miss violation for %pM portvec %x spid %d\n",
3909 + entry.mac, entry.portvec, spid);
3910 + chip->ports[spid].atu_miss_violation++;
3911 }
3912
3913 if (val & MV88E6XXX_G1_ATU_OP_FULL_VIOLATION) {
3914 dev_err_ratelimited(chip->dev,
3915 - "ATU full violation for %pM portvec %x\n",
3916 - entry.mac, entry.portvec);
3917 - chip->ports[entry.portvec].atu_full_violation++;
3918 + "ATU full violation for %pM portvec %x spid %d\n",
3919 + entry.mac, entry.portvec, spid);
3920 + chip->ports[spid].atu_full_violation++;
3921 }
3922 mutex_unlock(&chip->reg_lock);
3923
3924 diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
3925 index c965e65d07db..9939ccaeb125 100644
3926 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
3927 +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
3928 @@ -262,6 +262,8 @@ int hw_atl_utils_soft_reset(struct aq_hw_s *self)
3929 AQ_HW_WAIT_FOR((aq_hw_read_reg(self, HW_ATL_MPI_STATE_ADR) &
3930 HW_ATL_MPI_STATE_MSK) == MPI_DEINIT,
3931 10, 1000U);
3932 + if (err)
3933 + return err;
3934 }
3935
3936 if (self->rbl_enabled)
3937 diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
3938 index 7b6859e4924e..fc16b2b0d0e9 100644
3939 --- a/drivers/net/ethernet/broadcom/bcmsysport.c
3940 +++ b/drivers/net/ethernet/broadcom/bcmsysport.c
3941 @@ -519,7 +519,6 @@ static void bcm_sysport_get_wol(struct net_device *dev,
3942 struct ethtool_wolinfo *wol)
3943 {
3944 struct bcm_sysport_priv *priv = netdev_priv(dev);
3945 - u32 reg;
3946
3947 wol->supported = WAKE_MAGIC | WAKE_MAGICSECURE | WAKE_FILTER;
3948 wol->wolopts = priv->wolopts;
3949 @@ -527,11 +526,7 @@ static void bcm_sysport_get_wol(struct net_device *dev,
3950 if (!(priv->wolopts & WAKE_MAGICSECURE))
3951 return;
3952
3953 - /* Return the programmed SecureOn password */
3954 - reg = umac_readl(priv, UMAC_PSW_MS);
3955 - put_unaligned_be16(reg, &wol->sopass[0]);
3956 - reg = umac_readl(priv, UMAC_PSW_LS);
3957 - put_unaligned_be32(reg, &wol->sopass[2]);
3958 + memcpy(wol->sopass, priv->sopass, sizeof(priv->sopass));
3959 }
3960
3961 static int bcm_sysport_set_wol(struct net_device *dev,
3962 @@ -547,13 +542,8 @@ static int bcm_sysport_set_wol(struct net_device *dev,
3963 if (wol->wolopts & ~supported)
3964 return -EINVAL;
3965
3966 - /* Program the SecureOn password */
3967 - if (wol->wolopts & WAKE_MAGICSECURE) {
3968 - umac_writel(priv, get_unaligned_be16(&wol->sopass[0]),
3969 - UMAC_PSW_MS);
3970 - umac_writel(priv, get_unaligned_be32(&wol->sopass[2]),
3971 - UMAC_PSW_LS);
3972 - }
3973 + if (wol->wolopts & WAKE_MAGICSECURE)
3974 + memcpy(priv->sopass, wol->sopass, sizeof(priv->sopass));
3975
3976 /* Flag the device and relevant IRQ as wakeup capable */
3977 if (wol->wolopts) {
3978 @@ -2588,13 +2578,18 @@ static int bcm_sysport_suspend_to_wol(struct bcm_sysport_priv *priv)
3979 unsigned int index, i = 0;
3980 u32 reg;
3981
3982 - /* Password has already been programmed */
3983 reg = umac_readl(priv, UMAC_MPD_CTRL);
3984 if (priv->wolopts & (WAKE_MAGIC | WAKE_MAGICSECURE))
3985 reg |= MPD_EN;
3986 reg &= ~PSW_EN;
3987 - if (priv->wolopts & WAKE_MAGICSECURE)
3988 + if (priv->wolopts & WAKE_MAGICSECURE) {
3989 + /* Program the SecureOn password */
3990 + umac_writel(priv, get_unaligned_be16(&priv->sopass[0]),
3991 + UMAC_PSW_MS);
3992 + umac_writel(priv, get_unaligned_be32(&priv->sopass[2]),
3993 + UMAC_PSW_LS);
3994 reg |= PSW_EN;
3995 + }
3996 umac_writel(priv, reg, UMAC_MPD_CTRL);
3997
3998 if (priv->wolopts & WAKE_FILTER) {
3999 diff --git a/drivers/net/ethernet/broadcom/bcmsysport.h b/drivers/net/ethernet/broadcom/bcmsysport.h
4000 index 046c6c1d97fd..36e0adf5c9b8 100644
4001 --- a/drivers/net/ethernet/broadcom/bcmsysport.h
4002 +++ b/drivers/net/ethernet/broadcom/bcmsysport.h
4003 @@ -12,6 +12,7 @@
4004 #define __BCM_SYSPORT_H
4005
4006 #include <linux/bitmap.h>
4007 +#include <linux/ethtool.h>
4008 #include <linux/if_vlan.h>
4009 #include <linux/net_dim.h>
4010
4011 @@ -776,6 +777,7 @@ struct bcm_sysport_priv {
4012 unsigned int crc_fwd:1;
4013 u16 rev;
4014 u32 wolopts;
4015 + u8 sopass[SOPASS_MAX];
4016 unsigned int wol_irq_disabled:1;
4017
4018 /* MIB related fields */
4019 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
4020 index e2d92548226a..034f57500f00 100644
4021 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
4022 +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
4023 @@ -6073,23 +6073,26 @@ static void bnxt_clear_int_mode(struct bnxt *bp)
4024 int bnxt_reserve_rings(struct bnxt *bp)
4025 {
4026 int tcs = netdev_get_num_tc(bp->dev);
4027 + bool reinit_irq = false;
4028 int rc;
4029
4030 if (!bnxt_need_reserve_rings(bp))
4031 return 0;
4032
4033 - rc = __bnxt_reserve_rings(bp);
4034 - if (rc) {
4035 - netdev_err(bp->dev, "ring reservation failure rc: %d\n", rc);
4036 - return rc;
4037 - }
4038 if (BNXT_NEW_RM(bp) && (bnxt_get_num_msix(bp) != bp->total_irqs)) {
4039 bnxt_ulp_irq_stop(bp);
4040 bnxt_clear_int_mode(bp);
4041 - rc = bnxt_init_int_mode(bp);
4042 + reinit_irq = true;
4043 + }
4044 + rc = __bnxt_reserve_rings(bp);
4045 + if (reinit_irq) {
4046 + if (!rc)
4047 + rc = bnxt_init_int_mode(bp);
4048 bnxt_ulp_irq_restart(bp, rc);
4049 - if (rc)
4050 - return rc;
4051 + }
4052 + if (rc) {
4053 + netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc);
4054 + return rc;
4055 }
4056 if (tcs && (bp->tx_nr_rings_per_tc * tcs != bp->tx_nr_rings)) {
4057 netdev_err(bp->dev, "tx ring reservation failure\n");
4058 diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
4059 index 60641e202534..9a7f70db20c7 100644
4060 --- a/drivers/net/ethernet/cisco/enic/enic_main.c
4061 +++ b/drivers/net/ethernet/cisco/enic/enic_main.c
4062 @@ -1434,7 +1434,8 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,
4063 * csum is correct or is zero.
4064 */
4065 if ((netdev->features & NETIF_F_RXCSUM) && !csum_not_calc &&
4066 - tcp_udp_csum_ok && ipv4_csum_ok && outer_csum_ok) {
4067 + tcp_udp_csum_ok && outer_csum_ok &&
4068 + (ipv4_csum_ok || ipv6)) {
4069 skb->ip_summed = CHECKSUM_UNNECESSARY;
4070 skb->csum_level = encap;
4071 }
4072 diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c
4073 index bc6eb30aa20f..41c6fa200e74 100644
4074 --- a/drivers/net/ethernet/freescale/fman/fman_memac.c
4075 +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
4076 @@ -928,7 +928,7 @@ int memac_add_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr)
4077 hash = get_mac_addr_hash_code(addr) & HASH_CTRL_ADDR_MASK;
4078
4079 /* Create element to be added to the driver hash table */
4080 - hash_entry = kmalloc(sizeof(*hash_entry), GFP_KERNEL);
4081 + hash_entry = kmalloc(sizeof(*hash_entry), GFP_ATOMIC);
4082 if (!hash_entry)
4083 return -ENOMEM;
4084 hash_entry->addr = addr;
4085 diff --git a/drivers/net/ethernet/freescale/fman/fman_tgec.c b/drivers/net/ethernet/freescale/fman/fman_tgec.c
4086 index 40705938eecc..f75b9c11b2d2 100644
4087 --- a/drivers/net/ethernet/freescale/fman/fman_tgec.c
4088 +++ b/drivers/net/ethernet/freescale/fman/fman_tgec.c
4089 @@ -553,7 +553,7 @@ int tgec_add_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr)
4090 hash = (crc >> TGEC_HASH_MCAST_SHIFT) & TGEC_HASH_ADR_MSK;
4091
4092 /* Create element to be added to the driver hash table */
4093 - hash_entry = kmalloc(sizeof(*hash_entry), GFP_KERNEL);
4094 + hash_entry = kmalloc(sizeof(*hash_entry), GFP_ATOMIC);
4095 if (!hash_entry)
4096 return -ENOMEM;
4097 hash_entry->addr = addr;
4098 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
4099 index b7b2f8254ce1..0ccfa6a84535 100644
4100 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
4101 +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
4102 @@ -2691,6 +2691,8 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv)
4103
4104 static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv)
4105 {
4106 +#define HNS3_VECTOR_PF_MAX_NUM 64
4107 +
4108 struct hnae3_handle *h = priv->ae_handle;
4109 struct hns3_enet_tqp_vector *tqp_vector;
4110 struct hnae3_vector_info *vector;
4111 @@ -2703,6 +2705,8 @@ static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv)
4112 /* RSS size, cpu online and vector_num should be the same */
4113 /* Should consider 2p/4p later */
4114 vector_num = min_t(u16, num_online_cpus(), tqp_num);
4115 + vector_num = min_t(u16, vector_num, HNS3_VECTOR_PF_MAX_NUM);
4116 +
4117 vector = devm_kcalloc(&pdev->dev, vector_num, sizeof(*vector),
4118 GFP_KERNEL);
4119 if (!vector)
4120 @@ -2760,12 +2764,12 @@ static int hns3_nic_uninit_vector_data(struct hns3_nic_priv *priv)
4121
4122 hns3_free_vector_ring_chain(tqp_vector, &vector_ring_chain);
4123
4124 - if (priv->tqp_vector[i].irq_init_flag == HNS3_VECTOR_INITED) {
4125 - (void)irq_set_affinity_hint(
4126 - priv->tqp_vector[i].vector_irq,
4127 - NULL);
4128 - free_irq(priv->tqp_vector[i].vector_irq,
4129 - &priv->tqp_vector[i]);
4130 + if (tqp_vector->irq_init_flag == HNS3_VECTOR_INITED) {
4131 + irq_set_affinity_notifier(tqp_vector->vector_irq,
4132 + NULL);
4133 + irq_set_affinity_hint(tqp_vector->vector_irq, NULL);
4134 + free_irq(tqp_vector->vector_irq, tqp_vector);
4135 + tqp_vector->irq_init_flag = HNS3_VECTOR_NOT_INITED;
4136 }
4137
4138 priv->ring_data[i].ring->irq_init_flag = HNS3_VECTOR_NOT_INITED;
4139 diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
4140 index 7a80652e2500..f84e2c2d02c0 100644
4141 --- a/drivers/net/ethernet/intel/i40e/i40e.h
4142 +++ b/drivers/net/ethernet/intel/i40e/i40e.h
4143 @@ -122,6 +122,7 @@ enum i40e_state_t {
4144 __I40E_MDD_EVENT_PENDING,
4145 __I40E_VFLR_EVENT_PENDING,
4146 __I40E_RESET_RECOVERY_PENDING,
4147 + __I40E_TIMEOUT_RECOVERY_PENDING,
4148 __I40E_MISC_IRQ_REQUESTED,
4149 __I40E_RESET_INTR_RECEIVED,
4150 __I40E_REINIT_REQUESTED,
4151 diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
4152 index ed9d3fc4aaba..41fa22c562c1 100644
4153 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
4154 +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
4155 @@ -336,6 +336,10 @@ static void i40e_tx_timeout(struct net_device *netdev)
4156 (pf->tx_timeout_last_recovery + netdev->watchdog_timeo)))
4157 return; /* don't do any new action before the next timeout */
4158
4159 + /* don't kick off another recovery if one is already pending */
4160 + if (test_and_set_bit(__I40E_TIMEOUT_RECOVERY_PENDING, pf->state))
4161 + return;
4162 +
4163 if (tx_ring) {
4164 head = i40e_get_head(tx_ring);
4165 /* Read interrupt register */
4166 @@ -9566,6 +9570,7 @@ end_core_reset:
4167 clear_bit(__I40E_RESET_FAILED, pf->state);
4168 clear_recovery:
4169 clear_bit(__I40E_RESET_RECOVERY_PENDING, pf->state);
4170 + clear_bit(__I40E_TIMEOUT_RECOVERY_PENDING, pf->state);
4171 }
4172
4173 /**
4174 @@ -12011,6 +12016,9 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
4175 ether_addr_copy(netdev->dev_addr, mac_addr);
4176 ether_addr_copy(netdev->perm_addr, mac_addr);
4177
4178 + /* i40iw_net_event() reads 16 bytes from neigh->primary_key */
4179 + netdev->neigh_priv_len = sizeof(u32) * 4;
4180 +
4181 netdev->priv_flags |= IFF_UNICAST_FLT;
4182 netdev->priv_flags |= IFF_SUPP_NOFCS;
4183 /* Setup netdev TC information */
4184 diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
4185 index 3f047bb43348..db1543bca701 100644
4186 --- a/drivers/net/ethernet/intel/ice/ice_main.c
4187 +++ b/drivers/net/ethernet/intel/ice/ice_main.c
4188 @@ -4333,8 +4333,12 @@ static void ice_napi_enable_all(struct ice_vsi *vsi)
4189 if (!vsi->netdev)
4190 return;
4191
4192 - for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++)
4193 - napi_enable(&vsi->q_vectors[q_idx]->napi);
4194 + for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++) {
4195 + struct ice_q_vector *q_vector = vsi->q_vectors[q_idx];
4196 +
4197 + if (q_vector->rx.ring || q_vector->tx.ring)
4198 + napi_enable(&q_vector->napi);
4199 + }
4200 }
4201
4202 /**
4203 @@ -4817,8 +4821,12 @@ static void ice_napi_disable_all(struct ice_vsi *vsi)
4204 if (!vsi->netdev)
4205 return;
4206
4207 - for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++)
4208 - napi_disable(&vsi->q_vectors[q_idx]->napi);
4209 + for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++) {
4210 + struct ice_q_vector *q_vector = vsi->q_vectors[q_idx];
4211 +
4212 + if (q_vector->rx.ring || q_vector->tx.ring)
4213 + napi_disable(&q_vector->napi);
4214 + }
4215 }
4216
4217 /**
4218 diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
4219 index 0796cef96fa3..ffaa6e031632 100644
4220 --- a/drivers/net/ethernet/intel/igb/igb_main.c
4221 +++ b/drivers/net/ethernet/intel/igb/igb_main.c
4222 @@ -8770,9 +8770,11 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
4223 rtnl_unlock();
4224
4225 #ifdef CONFIG_PM
4226 - retval = pci_save_state(pdev);
4227 - if (retval)
4228 - return retval;
4229 + if (!runtime) {
4230 + retval = pci_save_state(pdev);
4231 + if (retval)
4232 + return retval;
4233 + }
4234 #endif
4235
4236 status = rd32(E1000_STATUS);
4237 diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
4238 index 9c08c3650c02..15dea48e0195 100644
4239 --- a/drivers/net/ethernet/marvell/skge.c
4240 +++ b/drivers/net/ethernet/marvell/skge.c
4241 @@ -152,8 +152,10 @@ static void skge_get_regs(struct net_device *dev, struct ethtool_regs *regs,
4242 memset(p, 0, regs->len);
4243 memcpy_fromio(p, io, B3_RAM_ADDR);
4244
4245 - memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1,
4246 - regs->len - B3_RI_WTO_R1);
4247 + if (regs->len > B3_RI_WTO_R1) {
4248 + memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1,
4249 + regs->len - B3_RI_WTO_R1);
4250 + }
4251 }
4252
4253 /* Wake on Lan only supported on Yukon chips with rev 1 or above */
4254 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
4255 index 7365899c3ac9..944f21f99d43 100644
4256 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
4257 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
4258 @@ -1758,7 +1758,7 @@ static void mlx5e_close_cq(struct mlx5e_cq *cq)
4259
4260 static int mlx5e_get_cpu(struct mlx5e_priv *priv, int ix)
4261 {
4262 - return cpumask_first(priv->mdev->priv.irq_info[ix].mask);
4263 + return cpumask_first(priv->mdev->priv.irq_info[ix + MLX5_EQ_VEC_COMP_BASE].mask);
4264 }
4265
4266 static int mlx5e_open_tx_cqs(struct mlx5e_channel *c,
4267 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
4268 index 8262f093fec4..d3f794d4fb96 100644
4269 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
4270 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
4271 @@ -707,6 +707,8 @@ static u32 mlx5e_get_fcs(const struct sk_buff *skb)
4272 return __get_unaligned_cpu32(fcs_bytes);
4273 }
4274
4275 +#define short_frame(size) ((size) <= ETH_ZLEN + ETH_FCS_LEN)
4276 +
4277 static inline void mlx5e_handle_csum(struct net_device *netdev,
4278 struct mlx5_cqe64 *cqe,
4279 struct mlx5e_rq *rq,
4280 @@ -725,6 +727,17 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
4281 return;
4282 }
4283
4284 + /* CQE csum doesn't cover padding octets in short ethernet
4285 + * frames. And the pad field is appended prior to calculating
4286 + * and appending the FCS field.
4287 + *
4288 + * Detecting these padded frames requires to verify and parse
4289 + * IP headers, so we simply force all those small frames to be
4290 + * CHECKSUM_UNNECESSARY even if they are not padded.
4291 + */
4292 + if (short_frame(skb->len))
4293 + goto csum_unnecessary;
4294 +
4295 if (likely(is_last_ethertype_ip(skb, &network_depth))) {
4296 skb->ip_summed = CHECKSUM_COMPLETE;
4297 skb->csum = csum_unfold((__force __sum16)cqe->check_sum);
4298 @@ -744,6 +757,7 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
4299 return;
4300 }
4301
4302 +csum_unnecessary:
4303 if (likely((cqe->hds_ip_ext & CQE_L3_OK) &&
4304 (cqe->hds_ip_ext & CQE_L4_OK))) {
4305 skb->ip_summed = CHECKSUM_UNNECESSARY;
4306 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
4307 index 6dacaeba2fbf..0b03d65474e9 100644
4308 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
4309 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
4310 @@ -387,8 +387,14 @@ netdev_tx_t mlx5e_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
4311 num_wqebbs = DIV_ROUND_UP(ds_cnt, MLX5_SEND_WQEBB_NUM_DS);
4312 contig_wqebbs_room = mlx5_wq_cyc_get_contig_wqebbs(wq, pi);
4313 if (unlikely(contig_wqebbs_room < num_wqebbs)) {
4314 +#ifdef CONFIG_MLX5_EN_IPSEC
4315 + struct mlx5_wqe_eth_seg cur_eth = wqe->eth;
4316 +#endif
4317 mlx5e_fill_sq_frag_edge(sq, wq, pi, contig_wqebbs_room);
4318 mlx5e_sq_fetch_wqe(sq, &wqe, &pi);
4319 +#ifdef CONFIG_MLX5_EN_IPSEC
4320 + wqe->eth = cur_eth;
4321 +#endif
4322 }
4323
4324 /* fill wqe */
4325 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
4326 index 3f767cde4c1d..54f1a40a68ed 100644
4327 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
4328 +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
4329 @@ -511,14 +511,14 @@ void mlx5_init_clock(struct mlx5_core_dev *mdev)
4330 ktime_to_ns(ktime_get_real()));
4331
4332 /* Calculate period in seconds to call the overflow watchdog - to make
4333 - * sure counter is checked at least once every wrap around.
4334 + * sure counter is checked at least twice every wrap around.
4335 * The period is calculated as the minimum between max HW cycles count
4336 * (The clock source mask) and max amount of cycles that can be
4337 * multiplied by clock multiplier where the result doesn't exceed
4338 * 64bits.
4339 */
4340 overflow_cycles = div64_u64(~0ULL >> 1, clock->cycles.mult);
4341 - overflow_cycles = min(overflow_cycles, clock->cycles.mask >> 1);
4342 + overflow_cycles = min(overflow_cycles, div_u64(clock->cycles.mask, 3));
4343
4344 ns = cyclecounter_cyc2ns(&clock->cycles, overflow_cycles,
4345 frac, &frac);
4346 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
4347 index b5e9f664fc66..563ce3fedab4 100644
4348 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
4349 +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
4350 @@ -640,18 +640,19 @@ u64 mlx5_read_internal_timer(struct mlx5_core_dev *dev)
4351 static int mlx5_irq_set_affinity_hint(struct mlx5_core_dev *mdev, int i)
4352 {
4353 struct mlx5_priv *priv = &mdev->priv;
4354 - int irq = pci_irq_vector(mdev->pdev, MLX5_EQ_VEC_COMP_BASE + i);
4355 + int vecidx = MLX5_EQ_VEC_COMP_BASE + i;
4356 + int irq = pci_irq_vector(mdev->pdev, vecidx);
4357
4358 - if (!zalloc_cpumask_var(&priv->irq_info[i].mask, GFP_KERNEL)) {
4359 + if (!zalloc_cpumask_var(&priv->irq_info[vecidx].mask, GFP_KERNEL)) {
4360 mlx5_core_warn(mdev, "zalloc_cpumask_var failed");
4361 return -ENOMEM;
4362 }
4363
4364 cpumask_set_cpu(cpumask_local_spread(i, priv->numa_node),
4365 - priv->irq_info[i].mask);
4366 + priv->irq_info[vecidx].mask);
4367
4368 if (IS_ENABLED(CONFIG_SMP) &&
4369 - irq_set_affinity_hint(irq, priv->irq_info[i].mask))
4370 + irq_set_affinity_hint(irq, priv->irq_info[vecidx].mask))
4371 mlx5_core_warn(mdev, "irq_set_affinity_hint failed, irq 0x%.4x", irq);
4372
4373 return 0;
4374 @@ -659,11 +660,12 @@ static int mlx5_irq_set_affinity_hint(struct mlx5_core_dev *mdev, int i)
4375
4376 static void mlx5_irq_clear_affinity_hint(struct mlx5_core_dev *mdev, int i)
4377 {
4378 + int vecidx = MLX5_EQ_VEC_COMP_BASE + i;
4379 struct mlx5_priv *priv = &mdev->priv;
4380 - int irq = pci_irq_vector(mdev->pdev, MLX5_EQ_VEC_COMP_BASE + i);
4381 + int irq = pci_irq_vector(mdev->pdev, vecidx);
4382
4383 irq_set_affinity_hint(irq, NULL);
4384 - free_cpumask_var(priv->irq_info[i].mask);
4385 + free_cpumask_var(priv->irq_info[vecidx].mask);
4386 }
4387
4388 static int mlx5_irq_set_affinity_hints(struct mlx5_core_dev *mdev)
4389 diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
4390 index de821a9fdfaf..d64cd8d44d83 100644
4391 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
4392 +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
4393 @@ -4235,6 +4235,25 @@ void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port)
4394 dev_put(mlxsw_sp_port->dev);
4395 }
4396
4397 +static void
4398 +mlxsw_sp_port_lag_uppers_cleanup(struct mlxsw_sp_port *mlxsw_sp_port,
4399 + struct net_device *lag_dev)
4400 +{
4401 + struct net_device *br_dev = netdev_master_upper_dev_get(lag_dev);
4402 + struct net_device *upper_dev;
4403 + struct list_head *iter;
4404 +
4405 + if (netif_is_bridge_port(lag_dev))
4406 + mlxsw_sp_port_bridge_leave(mlxsw_sp_port, lag_dev, br_dev);
4407 +
4408 + netdev_for_each_upper_dev_rcu(lag_dev, upper_dev, iter) {
4409 + if (!netif_is_bridge_port(upper_dev))
4410 + continue;
4411 + br_dev = netdev_master_upper_dev_get(upper_dev);
4412 + mlxsw_sp_port_bridge_leave(mlxsw_sp_port, upper_dev, br_dev);
4413 + }
4414 +}
4415 +
4416 static int mlxsw_sp_lag_create(struct mlxsw_sp *mlxsw_sp, u16 lag_id)
4417 {
4418 char sldr_pl[MLXSW_REG_SLDR_LEN];
4419 @@ -4427,6 +4446,10 @@ static void mlxsw_sp_port_lag_leave(struct mlxsw_sp_port *mlxsw_sp_port,
4420
4421 /* Any VLANs configured on the port are no longer valid */
4422 mlxsw_sp_port_vlan_flush(mlxsw_sp_port);
4423 + /* Make the LAG and its directly linked uppers leave bridges they
4424 + * are memeber in
4425 + */
4426 + mlxsw_sp_port_lag_uppers_cleanup(mlxsw_sp_port, lag_dev);
4427
4428 if (lag->ref_count == 1)
4429 mlxsw_sp_lag_destroy(mlxsw_sp, lag_id);
4430 diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
4431 index e171513bb32a..30931a2c025b 100644
4432 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
4433 +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
4434 @@ -95,8 +95,9 @@ int mlxsw_sp_acl_tcam_priority_get(struct mlxsw_sp *mlxsw_sp,
4435 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, KVD_SIZE))
4436 return -EIO;
4437
4438 - max_priority = MLXSW_CORE_RES_GET(mlxsw_sp->core, KVD_SIZE);
4439 - if (rulei->priority > max_priority)
4440 + /* Priority range is 1..cap_kvd_size-1. */
4441 + max_priority = MLXSW_CORE_RES_GET(mlxsw_sp->core, KVD_SIZE) - 1;
4442 + if (rulei->priority >= max_priority)
4443 return -EINVAL;
4444
4445 /* Unlike in TC, in HW, higher number means higher priority. */
4446 diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
4447 index 0d9ea37c5d21..cdec48bcc6ad 100644
4448 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
4449 +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
4450 @@ -282,30 +282,6 @@ mlxsw_sp_bridge_port_destroy(struct mlxsw_sp_bridge_port *bridge_port)
4451 kfree(bridge_port);
4452 }
4453
4454 -static bool
4455 -mlxsw_sp_bridge_port_should_destroy(const struct mlxsw_sp_bridge_port *
4456 - bridge_port)
4457 -{
4458 - struct net_device *dev = bridge_port->dev;
4459 - struct mlxsw_sp *mlxsw_sp;
4460 -
4461 - if (is_vlan_dev(dev))
4462 - mlxsw_sp = mlxsw_sp_lower_get(vlan_dev_real_dev(dev));
4463 - else
4464 - mlxsw_sp = mlxsw_sp_lower_get(dev);
4465 -
4466 - /* In case ports were pulled from out of a bridged LAG, then
4467 - * it's possible the reference count isn't zero, yet the bridge
4468 - * port should be destroyed, as it's no longer an upper of ours.
4469 - */
4470 - if (!mlxsw_sp && list_empty(&bridge_port->vlans_list))
4471 - return true;
4472 - else if (bridge_port->ref_count == 0)
4473 - return true;
4474 - else
4475 - return false;
4476 -}
4477 -
4478 static struct mlxsw_sp_bridge_port *
4479 mlxsw_sp_bridge_port_get(struct mlxsw_sp_bridge *bridge,
4480 struct net_device *brport_dev)
4481 @@ -343,8 +319,7 @@ static void mlxsw_sp_bridge_port_put(struct mlxsw_sp_bridge *bridge,
4482 {
4483 struct mlxsw_sp_bridge_device *bridge_device;
4484
4485 - bridge_port->ref_count--;
4486 - if (!mlxsw_sp_bridge_port_should_destroy(bridge_port))
4487 + if (--bridge_port->ref_count != 0)
4488 return;
4489 bridge_device = bridge_port->bridge_device;
4490 mlxsw_sp_bridge_port_destroy(bridge_port);
4491 diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
4492 index 9319d84bf49f..d84501441edd 100644
4493 --- a/drivers/net/ethernet/sun/niu.c
4494 +++ b/drivers/net/ethernet/sun/niu.c
4495 @@ -8100,6 +8100,8 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
4496 start += 3;
4497
4498 prop_len = niu_pci_eeprom_read(np, start + 4);
4499 + if (prop_len < 0)
4500 + return prop_len;
4501 err = niu_pci_vpd_get_propname(np, start + 5, namebuf, 64);
4502 if (err < 0)
4503 return err;
4504 @@ -8144,8 +8146,12 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
4505 netif_printk(np, probe, KERN_DEBUG, np->dev,
4506 "VPD_SCAN: Reading in property [%s] len[%d]\n",
4507 namebuf, prop_len);
4508 - for (i = 0; i < prop_len; i++)
4509 - *prop_buf++ = niu_pci_eeprom_read(np, off + i);
4510 + for (i = 0; i < prop_len; i++) {
4511 + err = niu_pci_eeprom_read(np, off + i);
4512 + if (err >= 0)
4513 + *prop_buf = err;
4514 + ++prop_buf;
4515 + }
4516 }
4517
4518 start += len;
4519 diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
4520 index 29aa8d772b0c..59b3f1fbabd4 100644
4521 --- a/drivers/net/phy/dp83640.c
4522 +++ b/drivers/net/phy/dp83640.c
4523 @@ -896,14 +896,14 @@ static void decode_txts(struct dp83640_private *dp83640,
4524 struct phy_txts *phy_txts)
4525 {
4526 struct skb_shared_hwtstamps shhwtstamps;
4527 + struct dp83640_skb_info *skb_info;
4528 struct sk_buff *skb;
4529 - u64 ns;
4530 u8 overflow;
4531 + u64 ns;
4532
4533 /* We must already have the skb that triggered this. */
4534 -
4535 +again:
4536 skb = skb_dequeue(&dp83640->tx_queue);
4537 -
4538 if (!skb) {
4539 pr_debug("have timestamp but tx_queue empty\n");
4540 return;
4541 @@ -918,6 +918,11 @@ static void decode_txts(struct dp83640_private *dp83640,
4542 }
4543 return;
4544 }
4545 + skb_info = (struct dp83640_skb_info *)skb->cb;
4546 + if (time_after(jiffies, skb_info->tmo)) {
4547 + kfree_skb(skb);
4548 + goto again;
4549 + }
4550
4551 ns = phy2txts(phy_txts);
4552 memset(&shhwtstamps, 0, sizeof(shhwtstamps));
4553 @@ -1470,6 +1475,7 @@ static bool dp83640_rxtstamp(struct phy_device *phydev,
4554 static void dp83640_txtstamp(struct phy_device *phydev,
4555 struct sk_buff *skb, int type)
4556 {
4557 + struct dp83640_skb_info *skb_info = (struct dp83640_skb_info *)skb->cb;
4558 struct dp83640_private *dp83640 = phydev->priv;
4559
4560 switch (dp83640->hwts_tx_en) {
4561 @@ -1482,6 +1488,7 @@ static void dp83640_txtstamp(struct phy_device *phydev,
4562 /* fall through */
4563 case HWTSTAMP_TX_ON:
4564 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
4565 + skb_info->tmo = jiffies + SKB_TIMESTAMP_TIMEOUT;
4566 skb_queue_tail(&dp83640->tx_queue, skb);
4567 break;
4568
4569 diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
4570 index d71be15c8c69..73813c7afa49 100644
4571 --- a/drivers/net/phy/marvell.c
4572 +++ b/drivers/net/phy/marvell.c
4573 @@ -868,8 +868,6 @@ static int m88e1510_config_init(struct phy_device *phydev)
4574
4575 /* SGMII-to-Copper mode initialization */
4576 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
4577 - u32 pause;
4578 -
4579 /* Select page 18 */
4580 err = marvell_set_page(phydev, 18);
4581 if (err < 0)
4582 @@ -892,16 +890,6 @@ static int m88e1510_config_init(struct phy_device *phydev)
4583 err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE);
4584 if (err < 0)
4585 return err;
4586 -
4587 - /* There appears to be a bug in the 88e1512 when used in
4588 - * SGMII to copper mode, where the AN advertisement register
4589 - * clears the pause bits each time a negotiation occurs.
4590 - * This means we can never be truely sure what was advertised,
4591 - * so disable Pause support.
4592 - */
4593 - pause = SUPPORTED_Pause | SUPPORTED_Asym_Pause;
4594 - phydev->supported &= ~pause;
4595 - phydev->advertising &= ~pause;
4596 }
4597
4598 return m88e1318_config_init(phydev);
4599 diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
4600 index f2d01cb6f958..6e971628bb50 100644
4601 --- a/drivers/net/usb/smsc95xx.c
4602 +++ b/drivers/net/usb/smsc95xx.c
4603 @@ -1295,6 +1295,7 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
4604 dev->net->features |= NETIF_F_RXCSUM;
4605
4606 dev->net->hw_features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
4607 + set_bit(EVENT_NO_IP_ALIGN, &dev->flags);
4608
4609 smsc95xx_init_mac_address(dev);
4610
4611 diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
4612 index 42feaa4d2916..c88ee376a2eb 100644
4613 --- a/drivers/net/virtio_net.c
4614 +++ b/drivers/net/virtio_net.c
4615 @@ -502,6 +502,8 @@ static int virtnet_xdp_xmit(struct net_device *dev,
4616 struct bpf_prog *xdp_prog;
4617 struct send_queue *sq;
4618 unsigned int len;
4619 + int packets = 0;
4620 + int bytes = 0;
4621 int drops = 0;
4622 int kicks = 0;
4623 int ret, err;
4624 @@ -525,10 +527,18 @@ static int virtnet_xdp_xmit(struct net_device *dev,
4625
4626 /* Free up any pending old buffers before queueing new ones. */
4627 while ((ptr = virtqueue_get_buf(sq->vq, &len)) != NULL) {
4628 - if (likely(is_xdp_frame(ptr)))
4629 - xdp_return_frame(ptr_to_xdp(ptr));
4630 - else
4631 - napi_consume_skb(ptr, false);
4632 + if (likely(is_xdp_frame(ptr))) {
4633 + struct xdp_frame *frame = ptr_to_xdp(ptr);
4634 +
4635 + bytes += frame->len;
4636 + xdp_return_frame(frame);
4637 + } else {
4638 + struct sk_buff *skb = ptr;
4639 +
4640 + bytes += skb->len;
4641 + napi_consume_skb(skb, false);
4642 + }
4643 + packets++;
4644 }
4645
4646 for (i = 0; i < n; i++) {
4647 @@ -548,6 +558,8 @@ static int virtnet_xdp_xmit(struct net_device *dev,
4648 }
4649 out:
4650 u64_stats_update_begin(&sq->stats.syncp);
4651 + sq->stats.bytes += bytes;
4652 + sq->stats.packets += packets;
4653 sq->stats.xdp_tx += n;
4654 sq->stats.xdp_tx_drops += drops;
4655 sq->stats.kicks += kicks;
4656 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
4657 index c40cd129afe7..5210cffb5344 100644
4658 --- a/drivers/net/wireless/ath/ath10k/core.c
4659 +++ b/drivers/net/wireless/ath/ath10k/core.c
4660 @@ -532,6 +532,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
4661 .hw_ops = &wcn3990_ops,
4662 .decap_align_bytes = 1,
4663 .num_peers = TARGET_HL_10_TLV_NUM_PEERS,
4664 + .n_cipher_suites = 8,
4665 .ast_skid_limit = TARGET_HL_10_TLV_AST_SKID_LIMIT,
4666 .num_wds_entries = TARGET_HL_10_TLV_NUM_WDS_ENTRIES,
4667 .target_64bit = true,
4668 diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
4669 index 21ba20981a80..0fca44e91a71 100644
4670 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
4671 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
4672 @@ -272,7 +272,7 @@ struct ath_node {
4673 #endif
4674 u8 key_idx[4];
4675
4676 - u32 ackto;
4677 + int ackto;
4678 struct list_head list;
4679 };
4680
4681 diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
4682 index 7334c9b09e82..6e236a485431 100644
4683 --- a/drivers/net/wireless/ath/ath9k/dynack.c
4684 +++ b/drivers/net/wireless/ath/ath9k/dynack.c
4685 @@ -29,9 +29,13 @@
4686 * ath_dynack_ewma - EWMA (Exponentially Weighted Moving Average) calculation
4687 *
4688 */
4689 -static inline u32 ath_dynack_ewma(u32 old, u32 new)
4690 +static inline int ath_dynack_ewma(int old, int new)
4691 {
4692 - return (new * (EWMA_DIV - EWMA_LEVEL) + old * EWMA_LEVEL) / EWMA_DIV;
4693 + if (old > 0)
4694 + return (new * (EWMA_DIV - EWMA_LEVEL) +
4695 + old * EWMA_LEVEL) / EWMA_DIV;
4696 + else
4697 + return new;
4698 }
4699
4700 /**
4701 @@ -82,10 +86,10 @@ static inline bool ath_dynack_bssidmask(struct ath_hw *ah, const u8 *mac)
4702 */
4703 static void ath_dynack_compute_ackto(struct ath_hw *ah)
4704 {
4705 - struct ath_node *an;
4706 - u32 to = 0;
4707 - struct ath_dynack *da = &ah->dynack;
4708 struct ath_common *common = ath9k_hw_common(ah);
4709 + struct ath_dynack *da = &ah->dynack;
4710 + struct ath_node *an;
4711 + int to = 0;
4712
4713 list_for_each_entry(an, &da->nodes, list)
4714 if (an->ackto > to)
4715 @@ -144,7 +148,8 @@ static void ath_dynack_compute_to(struct ath_hw *ah)
4716 an->ackto = ath_dynack_ewma(an->ackto,
4717 ackto);
4718 ath_dbg(ath9k_hw_common(ah), DYNACK,
4719 - "%pM to %u\n", dst, an->ackto);
4720 + "%pM to %d [%u]\n", dst,
4721 + an->ackto, ackto);
4722 if (time_is_before_jiffies(da->lto)) {
4723 ath_dynack_compute_ackto(ah);
4724 da->lto = jiffies + COMPUTE_TO;
4725 @@ -166,10 +171,12 @@ static void ath_dynack_compute_to(struct ath_hw *ah)
4726 * @ah: ath hw
4727 * @skb: socket buffer
4728 * @ts: tx status info
4729 + * @sta: station pointer
4730 *
4731 */
4732 void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
4733 - struct ath_tx_status *ts)
4734 + struct ath_tx_status *ts,
4735 + struct ieee80211_sta *sta)
4736 {
4737 u8 ridx;
4738 struct ieee80211_hdr *hdr;
4739 @@ -177,7 +184,7 @@ void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
4740 struct ath_common *common = ath9k_hw_common(ah);
4741 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
4742
4743 - if ((info->flags & IEEE80211_TX_CTL_NO_ACK) || !da->enabled)
4744 + if (!da->enabled || (info->flags & IEEE80211_TX_CTL_NO_ACK))
4745 return;
4746
4747 spin_lock_bh(&da->qlock);
4748 @@ -187,11 +194,19 @@ void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
4749 /* late ACK */
4750 if (ts->ts_status & ATH9K_TXERR_XRETRY) {
4751 if (ieee80211_is_assoc_req(hdr->frame_control) ||
4752 - ieee80211_is_assoc_resp(hdr->frame_control)) {
4753 + ieee80211_is_assoc_resp(hdr->frame_control) ||
4754 + ieee80211_is_auth(hdr->frame_control)) {
4755 ath_dbg(common, DYNACK, "late ack\n");
4756 +
4757 ath9k_hw_setslottime(ah, (LATEACK_TO - 3) / 2);
4758 ath9k_hw_set_ack_timeout(ah, LATEACK_TO);
4759 ath9k_hw_set_cts_timeout(ah, LATEACK_TO);
4760 + if (sta) {
4761 + struct ath_node *an;
4762 +
4763 + an = (struct ath_node *)sta->drv_priv;
4764 + an->ackto = -1;
4765 + }
4766 da->lto = jiffies + LATEACK_DELAY;
4767 }
4768
4769 @@ -251,7 +266,7 @@ void ath_dynack_sample_ack_ts(struct ath_hw *ah, struct sk_buff *skb,
4770 struct ath_common *common = ath9k_hw_common(ah);
4771 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
4772
4773 - if (!ath_dynack_bssidmask(ah, hdr->addr1) || !da->enabled)
4774 + if (!da->enabled || !ath_dynack_bssidmask(ah, hdr->addr1))
4775 return;
4776
4777 spin_lock_bh(&da->qlock);
4778 diff --git a/drivers/net/wireless/ath/ath9k/dynack.h b/drivers/net/wireless/ath/ath9k/dynack.h
4779 index 6d7bef976742..cf60224d40df 100644
4780 --- a/drivers/net/wireless/ath/ath9k/dynack.h
4781 +++ b/drivers/net/wireless/ath/ath9k/dynack.h
4782 @@ -86,7 +86,8 @@ void ath_dynack_node_deinit(struct ath_hw *ah, struct ath_node *an);
4783 void ath_dynack_init(struct ath_hw *ah);
4784 void ath_dynack_sample_ack_ts(struct ath_hw *ah, struct sk_buff *skb, u32 ts);
4785 void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
4786 - struct ath_tx_status *ts);
4787 + struct ath_tx_status *ts,
4788 + struct ieee80211_sta *sta);
4789 #else
4790 static inline void ath_dynack_init(struct ath_hw *ah) {}
4791 static inline void ath_dynack_node_init(struct ath_hw *ah,
4792 @@ -97,7 +98,8 @@ static inline void ath_dynack_sample_ack_ts(struct ath_hw *ah,
4793 struct sk_buff *skb, u32 ts) {}
4794 static inline void ath_dynack_sample_tx_ts(struct ath_hw *ah,
4795 struct sk_buff *skb,
4796 - struct ath_tx_status *ts) {}
4797 + struct ath_tx_status *ts,
4798 + struct ieee80211_sta *sta) {}
4799 #endif
4800
4801 #endif /* DYNACK_H */
4802 diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
4803 index 43b6c8508e49..4b7a7fc2a0fe 100644
4804 --- a/drivers/net/wireless/ath/ath9k/xmit.c
4805 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
4806 @@ -629,7 +629,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
4807 if (bf == bf->bf_lastbf)
4808 ath_dynack_sample_tx_ts(sc->sc_ah,
4809 bf->bf_mpdu,
4810 - ts);
4811 + ts, sta);
4812 }
4813
4814 ath_tx_complete_buf(sc, bf, txq, &bf_head, sta, ts,
4815 @@ -773,7 +773,8 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
4816 memcpy(info->control.rates, bf->rates,
4817 sizeof(info->control.rates));
4818 ath_tx_rc_status(sc, bf, ts, 1, txok ? 0 : 1, txok);
4819 - ath_dynack_sample_tx_ts(sc->sc_ah, bf->bf_mpdu, ts);
4820 + ath_dynack_sample_tx_ts(sc->sc_ah, bf->bf_mpdu, ts,
4821 + sta);
4822 }
4823 ath_tx_complete_buf(sc, bf, txq, bf_head, sta, ts, txok);
4824 } else
4825 diff --git a/drivers/net/wireless/ath/wil6210/main.c b/drivers/net/wireless/ath/wil6210/main.c
4826 index 7debed6bec06..a0fe8cbad104 100644
4827 --- a/drivers/net/wireless/ath/wil6210/main.c
4828 +++ b/drivers/net/wireless/ath/wil6210/main.c
4829 @@ -995,10 +995,13 @@ static int wil_target_reset(struct wil6210_priv *wil, int no_flash)
4830
4831 wil_dbg_misc(wil, "Resetting \"%s\"...\n", wil->hw_name);
4832
4833 - /* Clear MAC link up */
4834 - wil_s(wil, RGF_HP_CTRL, BIT(15));
4835 - wil_s(wil, RGF_USER_CLKS_CTL_SW_RST_MASK_0, BIT_HPAL_PERST_FROM_PAD);
4836 - wil_s(wil, RGF_USER_CLKS_CTL_SW_RST_MASK_0, BIT_CAR_PERST_RST);
4837 + if (wil->hw_version < HW_VER_TALYN) {
4838 + /* Clear MAC link up */
4839 + wil_s(wil, RGF_HP_CTRL, BIT(15));
4840 + wil_s(wil, RGF_USER_CLKS_CTL_SW_RST_MASK_0,
4841 + BIT_HPAL_PERST_FROM_PAD);
4842 + wil_s(wil, RGF_USER_CLKS_CTL_SW_RST_MASK_0, BIT_CAR_PERST_RST);
4843 + }
4844
4845 wil_halt_cpu(wil);
4846
4847 diff --git a/drivers/net/wireless/ath/wil6210/txrx.c b/drivers/net/wireless/ath/wil6210/txrx.c
4848 index 6a7943e487fb..75c8aa297107 100644
4849 --- a/drivers/net/wireless/ath/wil6210/txrx.c
4850 +++ b/drivers/net/wireless/ath/wil6210/txrx.c
4851 @@ -1313,6 +1313,8 @@ found:
4852 wil_dbg_txrx(wil, "BCAST DUP -> ring %d\n", i);
4853 wil_set_da_for_vring(wil, skb2, i);
4854 wil_tx_ring(wil, vif, v2, skb2);
4855 + /* successful call to wil_tx_ring takes skb2 ref */
4856 + dev_kfree_skb_any(skb2);
4857 } else {
4858 wil_err(wil, "skb_copy failed\n");
4859 }
4860 diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h b/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h
4861 index 55594c93b014..47dbd2d3e3b4 100644
4862 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h
4863 +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h
4864 @@ -442,7 +442,7 @@ struct iwl_he_backoff_conf {
4865 * Support for Nss x BW (or RU) matrix:
4866 * (0=SISO, 1=MIMO2) x (0-20MHz, 1-40MHz, 2-80MHz, 3-160MHz)
4867 * Each entry contains 2 QAM thresholds for 8us and 16us:
4868 - * 0=BPSK, 1=QPSK, 2=16QAM, 3=64QAM, 4=256QAM, 5=1024QAM, 6/7=RES
4869 + * 0=BPSK, 1=QPSK, 2=16QAM, 3=64QAM, 4=256QAM, 5=1024QAM, 6=RES, 7=NONE
4870 * i.e. QAM_th1 < QAM_th2 such if TX uses QAM_tx:
4871 * QAM_tx < QAM_th1 --> PPE=0us
4872 * QAM_th1 <= QAM_tx < QAM_th2 --> PPE=8us
4873 diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
4874 index 9a764af30f36..0f357e8c4f94 100644
4875 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
4876 +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
4877 @@ -1997,7 +1997,13 @@ static void iwl_mvm_cfg_he_sta(struct iwl_mvm *mvm,
4878 if (sta->he_cap.he_cap_elem.mac_cap_info[4] & IEEE80211_HE_MAC_CAP4_BQR)
4879 sta_ctxt_cmd.htc_flags |= cpu_to_le32(IWL_HE_HTC_BQR_SUPP);
4880
4881 - /* If PPE Thresholds exist, parse them into a FW-familiar format */
4882 + /*
4883 + * Initialize the PPE thresholds to "None" (7), as described in Table
4884 + * 9-262ac of 80211.ax/D3.0.
4885 + */
4886 + memset(&sta_ctxt_cmd.pkt_ext, 7, sizeof(sta_ctxt_cmd.pkt_ext));
4887 +
4888 + /* If PPE Thresholds exist, parse them into a FW-familiar format. */
4889 if (sta->he_cap.he_cap_elem.phy_cap_info[6] &
4890 IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) {
4891 u8 nss = (sta->he_cap.ppe_thres[0] &
4892 diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
4893 index 8169d1450b3b..d1c1a8069c7e 100644
4894 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
4895 +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
4896 @@ -98,8 +98,12 @@ static u8 rs_fw_sgi_cw_support(struct ieee80211_sta *sta)
4897 {
4898 struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
4899 struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
4900 + struct ieee80211_sta_he_cap *he_cap = &sta->he_cap;
4901 u8 supp = 0;
4902
4903 + if (he_cap && he_cap->has_he)
4904 + return 0;
4905 +
4906 if (ht_cap->cap & IEEE80211_HT_CAP_SGI_20)
4907 supp |= BIT(IWL_TLC_MNG_CH_WIDTH_20MHZ);
4908 if (ht_cap->cap & IEEE80211_HT_CAP_SGI_40)
4909 diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_dfs.c b/drivers/net/wireless/mediatek/mt76/mt76x2_dfs.c
4910 index 374cc655c11d..16e6b6970e28 100644
4911 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_dfs.c
4912 +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_dfs.c
4913 @@ -799,7 +799,7 @@ static void mt76x2_dfs_set_bbp_params(struct mt76x2_dev *dev)
4914
4915 /* enable detection*/
4916 mt76_wr(dev, MT_BBP(DFS, 0), MT_DFS_CH_EN << 16);
4917 - mt76_wr(dev, 0x212c, 0x0c350001);
4918 + mt76_wr(dev, MT_BBP(IBI, 11), 0x0c350001);
4919 }
4920
4921 void mt76x2_dfs_adjust_agc(struct mt76x2_dev *dev)
4922 @@ -842,7 +842,11 @@ void mt76x2_dfs_init_params(struct mt76x2_dev *dev)
4923 mt76_wr(dev, MT_BBP(DFS, 0), 0);
4924 /* clear detector status */
4925 mt76_wr(dev, MT_BBP(DFS, 1), 0xf);
4926 - mt76_wr(dev, 0x212c, 0);
4927 + if (mt76_chip(&dev->mt76) == 0x7610 ||
4928 + mt76_chip(&dev->mt76) == 0x7630)
4929 + mt76_wr(dev, MT_BBP(IBI, 11), 0xfde8081);
4930 + else
4931 + mt76_wr(dev, MT_BBP(IBI, 11), 0);
4932
4933 mt76x2_irq_disable(dev, MT_INT_GPTIMER);
4934 mt76_rmw_field(dev, MT_INT_TIMER_EN,
4935 diff --git a/drivers/net/wireless/st/cw1200/scan.c b/drivers/net/wireless/st/cw1200/scan.c
4936 index 67213f11acbd..0a9eac93dd01 100644
4937 --- a/drivers/net/wireless/st/cw1200/scan.c
4938 +++ b/drivers/net/wireless/st/cw1200/scan.c
4939 @@ -78,6 +78,10 @@ int cw1200_hw_scan(struct ieee80211_hw *hw,
4940 if (req->n_ssids > WSM_SCAN_MAX_NUM_OF_SSIDS)
4941 return -EINVAL;
4942
4943 + /* will be unlocked in cw1200_scan_work() */
4944 + down(&priv->scan.lock);
4945 + mutex_lock(&priv->conf_mutex);
4946 +
4947 frame.skb = ieee80211_probereq_get(hw, priv->vif->addr, NULL, 0,
4948 req->ie_len);
4949 if (!frame.skb)
4950 @@ -86,19 +90,15 @@ int cw1200_hw_scan(struct ieee80211_hw *hw,
4951 if (req->ie_len)
4952 skb_put_data(frame.skb, req->ie, req->ie_len);
4953
4954 - /* will be unlocked in cw1200_scan_work() */
4955 - down(&priv->scan.lock);
4956 - mutex_lock(&priv->conf_mutex);
4957 -
4958 ret = wsm_set_template_frame(priv, &frame);
4959 if (!ret) {
4960 /* Host want to be the probe responder. */
4961 ret = wsm_set_probe_responder(priv, true);
4962 }
4963 if (ret) {
4964 + dev_kfree_skb(frame.skb);
4965 mutex_unlock(&priv->conf_mutex);
4966 up(&priv->scan.lock);
4967 - dev_kfree_skb(frame.skb);
4968 return ret;
4969 }
4970
4971 @@ -120,10 +120,9 @@ int cw1200_hw_scan(struct ieee80211_hw *hw,
4972 ++priv->scan.n_ssids;
4973 }
4974
4975 - mutex_unlock(&priv->conf_mutex);
4976 -
4977 if (frame.skb)
4978 dev_kfree_skb(frame.skb);
4979 + mutex_unlock(&priv->conf_mutex);
4980 queue_work(priv->workqueue, &priv->scan.work);
4981 return 0;
4982 }
4983 diff --git a/drivers/opp/core.c b/drivers/opp/core.c
4984 index 31ff03dbeb83..f3433bf47b10 100644
4985 --- a/drivers/opp/core.c
4986 +++ b/drivers/opp/core.c
4987 @@ -191,12 +191,12 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
4988 if (IS_ERR(opp_table))
4989 return 0;
4990
4991 - count = opp_table->regulator_count;
4992 -
4993 /* Regulator may not be required for the device */
4994 - if (!count)
4995 + if (!opp_table->regulators)
4996 goto put_opp_table;
4997
4998 + count = opp_table->regulator_count;
4999 +
5000 uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL);
5001 if (!uV)
5002 goto put_opp_table;
5003 @@ -976,6 +976,9 @@ static bool _opp_supported_by_regulators(struct dev_pm_opp *opp,
5004 struct regulator *reg;
5005 int i;
5006
5007 + if (!opp_table->regulators)
5008 + return true;
5009 +
5010 for (i = 0; i < opp_table->regulator_count; i++) {
5011 reg = opp_table->regulators[i];
5012
5013 @@ -1263,7 +1266,7 @@ static int _allocate_set_opp_data(struct opp_table *opp_table)
5014 struct dev_pm_set_opp_data *data;
5015 int len, count = opp_table->regulator_count;
5016
5017 - if (WARN_ON(!count))
5018 + if (WARN_ON(!opp_table->regulators))
5019 return -EINVAL;
5020
5021 /* space for set_opp_data */
5022 diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
5023 index 975050a69494..3826b444298c 100644
5024 --- a/drivers/pci/controller/dwc/pci-imx6.c
5025 +++ b/drivers/pci/controller/dwc/pci-imx6.c
5026 @@ -66,6 +66,7 @@ struct imx6_pcie {
5027 #define PHY_PLL_LOCK_WAIT_USLEEP_MAX 200
5028
5029 /* PCIe Root Complex registers (memory-mapped) */
5030 +#define PCIE_RC_IMX6_MSI_CAP 0x50
5031 #define PCIE_RC_LCR 0x7c
5032 #define PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN1 0x1
5033 #define PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN2 0x2
5034 @@ -682,6 +683,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
5035 struct resource *dbi_base;
5036 struct device_node *node = dev->of_node;
5037 int ret;
5038 + u16 val;
5039
5040 imx6_pcie = devm_kzalloc(dev, sizeof(*imx6_pcie), GFP_KERNEL);
5041 if (!imx6_pcie)
5042 @@ -816,6 +818,14 @@ static int imx6_pcie_probe(struct platform_device *pdev)
5043 if (ret < 0)
5044 return ret;
5045
5046 + if (pci_msi_enabled()) {
5047 + val = dw_pcie_readw_dbi(pci, PCIE_RC_IMX6_MSI_CAP +
5048 + PCI_MSI_FLAGS);
5049 + val |= PCI_MSI_FLAGS_ENABLE;
5050 + dw_pcie_writew_dbi(pci, PCIE_RC_IMX6_MSI_CAP + PCI_MSI_FLAGS,
5051 + val);
5052 + }
5053 +
5054 return 0;
5055 }
5056
5057 diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
5058 index 54a8b30dda38..37d0c15c9eeb 100644
5059 --- a/drivers/pci/switch/switchtec.c
5060 +++ b/drivers/pci/switch/switchtec.c
5061 @@ -800,6 +800,7 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev,
5062 {
5063 int ret;
5064 int nr_idxs;
5065 + unsigned int event_flags;
5066 struct switchtec_ioctl_event_ctl ctl;
5067
5068 if (copy_from_user(&ctl, uctl, sizeof(ctl)))
5069 @@ -821,7 +822,9 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev,
5070 else
5071 return -EINVAL;
5072
5073 + event_flags = ctl.flags;
5074 for (ctl.index = 0; ctl.index < nr_idxs; ctl.index++) {
5075 + ctl.flags = event_flags;
5076 ret = event_ctl(stdev, &ctl);
5077 if (ret < 0)
5078 return ret;
5079 diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
5080 index 54ec278d2fc4..e1a77b2de78a 100644
5081 --- a/drivers/perf/arm_spe_pmu.c
5082 +++ b/drivers/perf/arm_spe_pmu.c
5083 @@ -927,6 +927,11 @@ static int arm_spe_pmu_perf_init(struct arm_spe_pmu *spe_pmu)
5084
5085 idx = atomic_inc_return(&pmu_idx);
5086 name = devm_kasprintf(dev, GFP_KERNEL, "%s_%d", PMUNAME, idx);
5087 + if (!name) {
5088 + dev_err(dev, "failed to allocate name for pmu %d\n", idx);
5089 + return -ENOMEM;
5090 + }
5091 +
5092 return perf_pmu_register(&spe_pmu->pmu, name, -1);
5093 }
5094
5095 diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
5096 index d4dcd39b8d76..881078ff73f6 100644
5097 --- a/drivers/phy/allwinner/phy-sun4i-usb.c
5098 +++ b/drivers/phy/allwinner/phy-sun4i-usb.c
5099 @@ -126,6 +126,7 @@ struct sun4i_usb_phy_cfg {
5100 bool dedicated_clocks;
5101 bool enable_pmu_unk1;
5102 bool phy0_dual_route;
5103 + int missing_phys;
5104 };
5105
5106 struct sun4i_usb_phy_data {
5107 @@ -646,6 +647,9 @@ static struct phy *sun4i_usb_phy_xlate(struct device *dev,
5108 if (args->args[0] >= data->cfg->num_phys)
5109 return ERR_PTR(-ENODEV);
5110
5111 + if (data->cfg->missing_phys & BIT(args->args[0]))
5112 + return ERR_PTR(-ENODEV);
5113 +
5114 return data->phys[args->args[0]].phy;
5115 }
5116
5117 @@ -741,6 +745,9 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
5118 struct sun4i_usb_phy *phy = data->phys + i;
5119 char name[16];
5120
5121 + if (data->cfg->missing_phys & BIT(i))
5122 + continue;
5123 +
5124 snprintf(name, sizeof(name), "usb%d_vbus", i);
5125 phy->vbus = devm_regulator_get_optional(dev, name);
5126 if (IS_ERR(phy->vbus)) {
5127 diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
5128 index fa530913a2c8..08925d24180b 100644
5129 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
5130 +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
5131 @@ -90,7 +90,7 @@ struct bcm2835_pinctrl {
5132 struct gpio_chip gpio_chip;
5133 struct pinctrl_gpio_range gpio_range;
5134
5135 - spinlock_t irq_lock[BCM2835_NUM_BANKS];
5136 + raw_spinlock_t irq_lock[BCM2835_NUM_BANKS];
5137 };
5138
5139 /* pins are just named GPIO0..GPIO53 */
5140 @@ -461,10 +461,10 @@ static void bcm2835_gpio_irq_enable(struct irq_data *data)
5141 unsigned bank = GPIO_REG_OFFSET(gpio);
5142 unsigned long flags;
5143
5144 - spin_lock_irqsave(&pc->irq_lock[bank], flags);
5145 + raw_spin_lock_irqsave(&pc->irq_lock[bank], flags);
5146 set_bit(offset, &pc->enabled_irq_map[bank]);
5147 bcm2835_gpio_irq_config(pc, gpio, true);
5148 - spin_unlock_irqrestore(&pc->irq_lock[bank], flags);
5149 + raw_spin_unlock_irqrestore(&pc->irq_lock[bank], flags);
5150 }
5151
5152 static void bcm2835_gpio_irq_disable(struct irq_data *data)
5153 @@ -476,12 +476,12 @@ static void bcm2835_gpio_irq_disable(struct irq_data *data)
5154 unsigned bank = GPIO_REG_OFFSET(gpio);
5155 unsigned long flags;
5156
5157 - spin_lock_irqsave(&pc->irq_lock[bank], flags);
5158 + raw_spin_lock_irqsave(&pc->irq_lock[bank], flags);
5159 bcm2835_gpio_irq_config(pc, gpio, false);
5160 /* Clear events that were latched prior to clearing event sources */
5161 bcm2835_gpio_set_bit(pc, GPEDS0, gpio);
5162 clear_bit(offset, &pc->enabled_irq_map[bank]);
5163 - spin_unlock_irqrestore(&pc->irq_lock[bank], flags);
5164 + raw_spin_unlock_irqrestore(&pc->irq_lock[bank], flags);
5165 }
5166
5167 static int __bcm2835_gpio_irq_set_type_disabled(struct bcm2835_pinctrl *pc,
5168 @@ -584,7 +584,7 @@ static int bcm2835_gpio_irq_set_type(struct irq_data *data, unsigned int type)
5169 unsigned long flags;
5170 int ret;
5171
5172 - spin_lock_irqsave(&pc->irq_lock[bank], flags);
5173 + raw_spin_lock_irqsave(&pc->irq_lock[bank], flags);
5174
5175 if (test_bit(offset, &pc->enabled_irq_map[bank]))
5176 ret = __bcm2835_gpio_irq_set_type_enabled(pc, gpio, type);
5177 @@ -596,7 +596,7 @@ static int bcm2835_gpio_irq_set_type(struct irq_data *data, unsigned int type)
5178 else
5179 irq_set_handler_locked(data, handle_level_irq);
5180
5181 - spin_unlock_irqrestore(&pc->irq_lock[bank], flags);
5182 + raw_spin_unlock_irqrestore(&pc->irq_lock[bank], flags);
5183
5184 return ret;
5185 }
5186 @@ -1047,7 +1047,7 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
5187 for_each_set_bit(offset, &events, 32)
5188 bcm2835_gpio_wr(pc, GPEDS0 + i * 4, BIT(offset));
5189
5190 - spin_lock_init(&pc->irq_lock[i]);
5191 + raw_spin_lock_init(&pc->irq_lock[i]);
5192 }
5193
5194 err = gpiochip_add_data(&pc->gpio_chip, pc);
5195 diff --git a/drivers/pinctrl/meson/pinctrl-meson8.c b/drivers/pinctrl/meson/pinctrl-meson8.c
5196 index 86466173114d..e482672e833a 100644
5197 --- a/drivers/pinctrl/meson/pinctrl-meson8.c
5198 +++ b/drivers/pinctrl/meson/pinctrl-meson8.c
5199 @@ -807,7 +807,9 @@ static const char * const gpio_groups[] = {
5200 "BOOT_5", "BOOT_6", "BOOT_7", "BOOT_8", "BOOT_9",
5201 "BOOT_10", "BOOT_11", "BOOT_12", "BOOT_13", "BOOT_14",
5202 "BOOT_15", "BOOT_16", "BOOT_17", "BOOT_18",
5203 +};
5204
5205 +static const char * const gpio_aobus_groups[] = {
5206 "GPIOAO_0", "GPIOAO_1", "GPIOAO_2", "GPIOAO_3",
5207 "GPIOAO_4", "GPIOAO_5", "GPIOAO_6", "GPIOAO_7",
5208 "GPIOAO_8", "GPIOAO_9", "GPIOAO_10", "GPIOAO_11",
5209 @@ -1030,6 +1032,7 @@ static struct meson_pmx_func meson8_cbus_functions[] = {
5210 };
5211
5212 static struct meson_pmx_func meson8_aobus_functions[] = {
5213 + FUNCTION(gpio_aobus),
5214 FUNCTION(uart_ao),
5215 FUNCTION(remote),
5216 FUNCTION(i2c_slave_ao),
5217 diff --git a/drivers/pinctrl/meson/pinctrl-meson8b.c b/drivers/pinctrl/meson/pinctrl-meson8b.c
5218 index 647ad15d5c3c..91cffc051055 100644
5219 --- a/drivers/pinctrl/meson/pinctrl-meson8b.c
5220 +++ b/drivers/pinctrl/meson/pinctrl-meson8b.c
5221 @@ -646,16 +646,18 @@ static const char * const gpio_groups[] = {
5222 "BOOT_10", "BOOT_11", "BOOT_12", "BOOT_13", "BOOT_14",
5223 "BOOT_15", "BOOT_16", "BOOT_17", "BOOT_18",
5224
5225 - "GPIOAO_0", "GPIOAO_1", "GPIOAO_2", "GPIOAO_3",
5226 - "GPIOAO_4", "GPIOAO_5", "GPIOAO_6", "GPIOAO_7",
5227 - "GPIOAO_8", "GPIOAO_9", "GPIOAO_10", "GPIOAO_11",
5228 - "GPIOAO_12", "GPIOAO_13", "GPIO_BSD_EN", "GPIO_TEST_N",
5229 -
5230 "DIF_0_P", "DIF_0_N", "DIF_1_P", "DIF_1_N",
5231 "DIF_2_P", "DIF_2_N", "DIF_3_P", "DIF_3_N",
5232 "DIF_4_P", "DIF_4_N"
5233 };
5234
5235 +static const char * const gpio_aobus_groups[] = {
5236 + "GPIOAO_0", "GPIOAO_1", "GPIOAO_2", "GPIOAO_3",
5237 + "GPIOAO_4", "GPIOAO_5", "GPIOAO_6", "GPIOAO_7",
5238 + "GPIOAO_8", "GPIOAO_9", "GPIOAO_10", "GPIOAO_11",
5239 + "GPIOAO_12", "GPIOAO_13", "GPIO_BSD_EN", "GPIO_TEST_N"
5240 +};
5241 +
5242 static const char * const sd_a_groups[] = {
5243 "sd_d0_a", "sd_d1_a", "sd_d2_a", "sd_d3_a", "sd_clk_a",
5244 "sd_cmd_a"
5245 @@ -871,6 +873,7 @@ static struct meson_pmx_func meson8b_cbus_functions[] = {
5246 };
5247
5248 static struct meson_pmx_func meson8b_aobus_functions[] = {
5249 + FUNCTION(gpio_aobus),
5250 FUNCTION(uart_ao),
5251 FUNCTION(uart_ao_b),
5252 FUNCTION(i2c_slave_ao),
5253 diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c
5254 index cbf58a10113d..4d87d75b9c6e 100644
5255 --- a/drivers/pinctrl/pinctrl-sx150x.c
5256 +++ b/drivers/pinctrl/pinctrl-sx150x.c
5257 @@ -1166,7 +1166,6 @@ static int sx150x_probe(struct i2c_client *client,
5258 }
5259
5260 /* Register GPIO controller */
5261 - pctl->gpio.label = devm_kstrdup(dev, client->name, GFP_KERNEL);
5262 pctl->gpio.base = -1;
5263 pctl->gpio.ngpio = pctl->data->npins;
5264 pctl->gpio.get_direction = sx150x_gpio_get_direction;
5265 @@ -1180,6 +1179,10 @@ static int sx150x_probe(struct i2c_client *client,
5266 pctl->gpio.of_node = dev->of_node;
5267 #endif
5268 pctl->gpio.can_sleep = true;
5269 + pctl->gpio.label = devm_kstrdup(dev, client->name, GFP_KERNEL);
5270 + if (!pctl->gpio.label)
5271 + return -ENOMEM;
5272 +
5273 /*
5274 * Setting multiple pins is not safe when all pins are not
5275 * handled by the same regmap register. The oscio pin (present
5276 @@ -1200,13 +1203,15 @@ static int sx150x_probe(struct i2c_client *client,
5277
5278 /* Add Interrupt support if an irq is specified */
5279 if (client->irq > 0) {
5280 - pctl->irq_chip.name = devm_kstrdup(dev, client->name,
5281 - GFP_KERNEL);
5282 pctl->irq_chip.irq_mask = sx150x_irq_mask;
5283 pctl->irq_chip.irq_unmask = sx150x_irq_unmask;
5284 pctl->irq_chip.irq_set_type = sx150x_irq_set_type;
5285 pctl->irq_chip.irq_bus_lock = sx150x_irq_bus_lock;
5286 pctl->irq_chip.irq_bus_sync_unlock = sx150x_irq_bus_sync_unlock;
5287 + pctl->irq_chip.name = devm_kstrdup(dev, client->name,
5288 + GFP_KERNEL);
5289 + if (!pctl->irq_chip.name)
5290 + return -ENOMEM;
5291
5292 pctl->irq.masked = ~0;
5293 pctl->irq.sense = 0;
5294 diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
5295 index b6fd4838f60f..e5d5b1adb5a9 100644
5296 --- a/drivers/platform/chrome/cros_ec_proto.c
5297 +++ b/drivers/platform/chrome/cros_ec_proto.c
5298 @@ -575,6 +575,7 @@ static int get_keyboard_state_event(struct cros_ec_device *ec_dev)
5299
5300 int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event)
5301 {
5302 + u8 event_type;
5303 u32 host_event;
5304 int ret;
5305
5306 @@ -594,11 +595,22 @@ int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event)
5307 return ret;
5308
5309 if (wake_event) {
5310 + event_type = ec_dev->event_data.event_type;
5311 host_event = cros_ec_get_host_event(ec_dev);
5312
5313 - /* Consider non-host_event as wake event */
5314 - *wake_event = !host_event ||
5315 - !!(host_event & ec_dev->host_event_wake_mask);
5316 + /*
5317 + * Sensor events need to be parsed by the sensor sub-device.
5318 + * Defer them, and don't report the wakeup here.
5319 + */
5320 + if (event_type == EC_MKBP_EVENT_SENSOR_FIFO)
5321 + *wake_event = false;
5322 + /* Masked host-events should not count as wake events. */
5323 + else if (host_event &&
5324 + !(host_event & ec_dev->host_event_wake_mask))
5325 + *wake_event = false;
5326 + /* Consider all other events as wake events. */
5327 + else
5328 + *wake_event = true;
5329 }
5330
5331 return ret;
5332 diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c
5333 index d89936c93ba0..78b4aa4410fb 100644
5334 --- a/drivers/platform/x86/mlx-platform.c
5335 +++ b/drivers/platform/x86/mlx-platform.c
5336 @@ -83,12 +83,12 @@
5337 #define MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET 0xe7
5338 #define MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET 0xe8
5339 #define MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET 0xe9
5340 -#define MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET 0xea
5341 -#define MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET 0xeb
5342 -#define MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET 0xec
5343 -#define MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET 0xed
5344 -#define MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET 0xee
5345 -#define MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET 0xef
5346 +#define MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET 0xeb
5347 +#define MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET 0xec
5348 +#define MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET 0xed
5349 +#define MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET 0xee
5350 +#define MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET 0xef
5351 +#define MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET 0xf0
5352 #define MLXPLAT_CPLD_LPC_IO_RANGE 0x100
5353 #define MLXPLAT_CPLD_LPC_I2C_CH1_OFF 0xdb
5354 #define MLXPLAT_CPLD_LPC_I2C_CH2_OFF 0xda
5355 diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
5356 index 2012551d93e0..796eeffdf93b 100644
5357 --- a/drivers/ptp/ptp_chardev.c
5358 +++ b/drivers/ptp/ptp_chardev.c
5359 @@ -228,7 +228,9 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
5360 pct->sec = ts.tv_sec;
5361 pct->nsec = ts.tv_nsec;
5362 pct++;
5363 - ptp->info->gettime64(ptp->info, &ts);
5364 + err = ptp->info->gettime64(ptp->info, &ts);
5365 + if (err)
5366 + goto out;
5367 pct->sec = ts.tv_sec;
5368 pct->nsec = ts.tv_nsec;
5369 pct++;
5370 @@ -281,6 +283,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
5371 break;
5372 }
5373
5374 +out:
5375 kfree(sysoff);
5376 return err;
5377 }
5378 diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
5379 index 7eacc1c4b3b1..c64903a5978f 100644
5380 --- a/drivers/ptp/ptp_clock.c
5381 +++ b/drivers/ptp/ptp_clock.c
5382 @@ -253,8 +253,10 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
5383 ptp->dev = device_create_with_groups(ptp_class, parent, ptp->devid,
5384 ptp, ptp->pin_attr_groups,
5385 "ptp%d", ptp->index);
5386 - if (IS_ERR(ptp->dev))
5387 + if (IS_ERR(ptp->dev)) {
5388 + err = PTR_ERR(ptp->dev);
5389 goto no_device;
5390 + }
5391
5392 /* Register a new PPS source. */
5393 if (info->pps) {
5394 @@ -265,6 +267,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
5395 pps.owner = info->owner;
5396 ptp->pps_source = pps_register_source(&pps, PTP_PPS_DEFAULTS);
5397 if (!ptp->pps_source) {
5398 + err = -EINVAL;
5399 pr_err("failed to register pps source\n");
5400 goto no_pps;
5401 }
5402 diff --git a/drivers/s390/crypto/zcrypt_error.h b/drivers/s390/crypto/zcrypt_error.h
5403 index 6f7ebc1dbe10..2e1a27bd97d1 100644
5404 --- a/drivers/s390/crypto/zcrypt_error.h
5405 +++ b/drivers/s390/crypto/zcrypt_error.h
5406 @@ -52,6 +52,7 @@ struct error_hdr {
5407 #define REP82_ERROR_FORMAT_FIELD 0x29
5408 #define REP82_ERROR_INVALID_COMMAND 0x30
5409 #define REP82_ERROR_MALFORMED_MSG 0x40
5410 +#define REP82_ERROR_INVALID_SPECIAL_CMD 0x41
5411 #define REP82_ERROR_INVALID_DOMAIN_PRECHECK 0x42
5412 #define REP82_ERROR_RESERVED_FIELDO 0x50 /* old value */
5413 #define REP82_ERROR_WORD_ALIGNMENT 0x60
5414 @@ -90,6 +91,7 @@ static inline int convert_error(struct zcrypt_queue *zq,
5415 case REP88_ERROR_MESSAGE_MALFORMD:
5416 case REP82_ERROR_INVALID_DOMAIN_PRECHECK:
5417 case REP82_ERROR_INVALID_DOMAIN_PENDING:
5418 + case REP82_ERROR_INVALID_SPECIAL_CMD:
5419 // REP88_ERROR_INVALID_KEY // '82' CEX2A
5420 // REP88_ERROR_OPERAND // '84' CEX2A
5421 // REP88_ERROR_OPERAND_EVEN_MOD // '85' CEX2A
5422 diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
5423 index 1391e5f35918..702da909cee5 100644
5424 --- a/drivers/scsi/aic94xx/aic94xx_init.c
5425 +++ b/drivers/scsi/aic94xx/aic94xx_init.c
5426 @@ -281,7 +281,7 @@ static ssize_t asd_show_dev_rev(struct device *dev,
5427 return snprintf(buf, PAGE_SIZE, "%s\n",
5428 asd_dev_rev[asd_ha->revision_id]);
5429 }
5430 -static DEVICE_ATTR(revision, S_IRUGO, asd_show_dev_rev, NULL);
5431 +static DEVICE_ATTR(aic_revision, S_IRUGO, asd_show_dev_rev, NULL);
5432
5433 static ssize_t asd_show_dev_bios_build(struct device *dev,
5434 struct device_attribute *attr,char *buf)
5435 @@ -478,7 +478,7 @@ static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha)
5436 {
5437 int err;
5438
5439 - err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_revision);
5440 + err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision);
5441 if (err)
5442 return err;
5443
5444 @@ -500,13 +500,13 @@ err_update_bios:
5445 err_biosb:
5446 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build);
5447 err_rev:
5448 - device_remove_file(&asd_ha->pcidev->dev, &dev_attr_revision);
5449 + device_remove_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision);
5450 return err;
5451 }
5452
5453 static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha)
5454 {
5455 - device_remove_file(&asd_ha->pcidev->dev, &dev_attr_revision);
5456 + device_remove_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision);
5457 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build);
5458 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn);
5459 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_update_bios);
5460 diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
5461 index 6637116529aa..f987c40c47a1 100644
5462 --- a/drivers/scsi/cxlflash/main.c
5463 +++ b/drivers/scsi/cxlflash/main.c
5464 @@ -3694,6 +3694,7 @@ static int cxlflash_probe(struct pci_dev *pdev,
5465 host->max_cmd_len = CXLFLASH_MAX_CDB_LEN;
5466
5467 cfg = shost_priv(host);
5468 + cfg->state = STATE_PROBING;
5469 cfg->host = host;
5470 rc = alloc_mem(cfg);
5471 if (rc) {
5472 @@ -3782,6 +3783,7 @@ out:
5473 return rc;
5474
5475 out_remove:
5476 + cfg->state = STATE_PROBED;
5477 cxlflash_remove(pdev);
5478 goto out;
5479 }
5480 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
5481 index 687ff61bba9f..3922b17e2ea3 100644
5482 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
5483 +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
5484 @@ -492,7 +492,7 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba)
5485 hisi_sas_phy_write32(hisi_hba, i, PHYCTRL_OOB_RESTART_MSK, 0x1);
5486 hisi_sas_phy_write32(hisi_hba, i, STP_LINK_TIMER, 0x7f7a120);
5487 hisi_sas_phy_write32(hisi_hba, i, CON_CFG_DRIVER, 0x2a0a01);
5488 -
5489 + hisi_sas_phy_write32(hisi_hba, i, SAS_SSP_CON_TIMER_CFG, 0x32);
5490 /* used for 12G negotiate */
5491 hisi_sas_phy_write32(hisi_hba, i, COARSETUNE_TIME, 0x1e);
5492 }
5493 diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
5494 index 4dda969e947c..0d214e6b8e9a 100644
5495 --- a/drivers/scsi/lpfc/lpfc_els.c
5496 +++ b/drivers/scsi/lpfc/lpfc_els.c
5497 @@ -242,6 +242,8 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp,
5498 icmd->ulpCommand = CMD_ELS_REQUEST64_CR;
5499 if (elscmd == ELS_CMD_FLOGI)
5500 icmd->ulpTimeout = FF_DEF_RATOV * 2;
5501 + else if (elscmd == ELS_CMD_LOGO)
5502 + icmd->ulpTimeout = phba->fc_ratov;
5503 else
5504 icmd->ulpTimeout = phba->fc_ratov * 2;
5505 } else {
5506 @@ -2682,16 +2684,15 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
5507 goto out;
5508 }
5509
5510 + /* The LOGO will not be retried on failure. A LOGO was
5511 + * issued to the remote rport and a ACC or RJT or no Answer are
5512 + * all acceptable. Note the failure and move forward with
5513 + * discovery. The PLOGI will retry.
5514 + */
5515 if (irsp->ulpStatus) {
5516 - /* Check for retry */
5517 - if (lpfc_els_retry(phba, cmdiocb, rspiocb)) {
5518 - /* ELS command is being retried */
5519 - skip_recovery = 1;
5520 - goto out;
5521 - }
5522 /* LOGO failed */
5523 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
5524 - "2756 LOGO failure DID:%06X Status:x%x/x%x\n",
5525 + "2756 LOGO failure, No Retry DID:%06X Status:x%x/x%x\n",
5526 ndlp->nlp_DID, irsp->ulpStatus,
5527 irsp->un.ulpWord[4]);
5528 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */
5529 @@ -2737,7 +2738,8 @@ out:
5530 * For any other port type, the rpi is unregistered as an implicit
5531 * LOGO.
5532 */
5533 - if ((ndlp->nlp_type & NLP_FCP_TARGET) && (skip_recovery == 0)) {
5534 + if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET) &&
5535 + skip_recovery == 0) {
5536 lpfc_cancel_retry_delay_tmo(vport, ndlp);
5537 spin_lock_irqsave(shost->host_lock, flags);
5538 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
5539 @@ -2770,6 +2772,8 @@ out:
5540 * will be stored into the context1 field of the IOCB for the completion
5541 * callback function to the LOGO ELS command.
5542 *
5543 + * Callers of this routine are expected to unregister the RPI first
5544 + *
5545 * Return code
5546 * 0 - successfully issued logo
5547 * 1 - failed to issue logo
5548 @@ -2811,22 +2815,6 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
5549 "Issue LOGO: did:x%x",
5550 ndlp->nlp_DID, 0, 0);
5551
5552 - /*
5553 - * If we are issuing a LOGO, we may try to recover the remote NPort
5554 - * by issuing a PLOGI later. Even though we issue ELS cmds by the
5555 - * VPI, if we have a valid RPI, and that RPI gets unreg'ed while
5556 - * that ELS command is in-flight, the HBA returns a IOERR_INVALID_RPI
5557 - * for that ELS cmd. To avoid this situation, lets get rid of the
5558 - * RPI right now, before any ELS cmds are sent.
5559 - */
5560 - spin_lock_irq(shost->host_lock);
5561 - ndlp->nlp_flag |= NLP_ISSUE_LOGO;
5562 - spin_unlock_irq(shost->host_lock);
5563 - if (lpfc_unreg_rpi(vport, ndlp)) {
5564 - lpfc_els_free_iocb(phba, elsiocb);
5565 - return 0;
5566 - }
5567 -
5568 phba->fc_stat.elsXmitLOGO++;
5569 elsiocb->iocb_cmpl = lpfc_cmpl_els_logo;
5570 spin_lock_irq(shost->host_lock);
5571 @@ -2834,7 +2822,6 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
5572 ndlp->nlp_flag &= ~NLP_ISSUE_LOGO;
5573 spin_unlock_irq(shost->host_lock);
5574 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
5575 -
5576 if (rc == IOCB_ERROR) {
5577 spin_lock_irq(shost->host_lock);
5578 ndlp->nlp_flag &= ~NLP_LOGO_SND;
5579 @@ -2842,6 +2829,11 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
5580 lpfc_els_free_iocb(phba, elsiocb);
5581 return 1;
5582 }
5583 +
5584 + spin_lock_irq(shost->host_lock);
5585 + ndlp->nlp_prev_state = ndlp->nlp_state;
5586 + spin_unlock_irq(shost->host_lock);
5587 + lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE);
5588 return 0;
5589 }
5590
5591 @@ -5701,6 +5693,9 @@ error:
5592 stat = (struct ls_rjt *)(pcmd + sizeof(uint32_t));
5593 stat->un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
5594
5595 + if (shdr_add_status == ADD_STATUS_OPERATION_ALREADY_ACTIVE)
5596 + stat->un.b.lsRjtRsnCodeExp = LSEXP_CMD_IN_PROGRESS;
5597 +
5598 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
5599 phba->fc_stat.elsXmitLSRJT++;
5600 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
5601 @@ -9502,7 +9497,8 @@ lpfc_sli_abts_recover_port(struct lpfc_vport *vport,
5602 "rport in state 0x%x\n", ndlp->nlp_state);
5603 return;
5604 }
5605 - lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
5606 + lpfc_printf_log(phba, KERN_ERR,
5607 + LOG_ELS | LOG_FCP_ERROR | LOG_NVME_IOERR,
5608 "3094 Start rport recovery on shost id 0x%x "
5609 "fc_id 0x%06x vpi 0x%x rpi 0x%x state 0x%x "
5610 "flags 0x%x\n",
5611 @@ -9515,8 +9511,8 @@ lpfc_sli_abts_recover_port(struct lpfc_vport *vport,
5612 */
5613 spin_lock_irqsave(shost->host_lock, flags);
5614 ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
5615 + ndlp->nlp_flag |= NLP_ISSUE_LOGO;
5616 spin_unlock_irqrestore(shost->host_lock, flags);
5617 - lpfc_issue_els_logo(vport, ndlp, 0);
5618 - lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE);
5619 + lpfc_unreg_rpi(vport, ndlp);
5620 }
5621
5622 diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
5623 index bd9bce9d9974..a6619fd8238c 100644
5624 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c
5625 +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
5626 @@ -836,7 +836,9 @@ lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
5627 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
5628
5629 if (!(ndlp->nlp_flag & NLP_RPI_REGISTERED)) {
5630 + spin_lock_irq(shost->host_lock);
5631 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
5632 + spin_unlock_irq(shost->host_lock);
5633 return 0;
5634 }
5635
5636 @@ -851,7 +853,10 @@ lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
5637 return 1;
5638 }
5639 }
5640 +
5641 + spin_lock_irq(shost->host_lock);
5642 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
5643 + spin_unlock_irq(shost->host_lock);
5644 lpfc_unreg_rpi(vport, ndlp);
5645 return 0;
5646 }
5647 diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
5648 index 53133cfd420f..622832e55211 100644
5649 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
5650 +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
5651 @@ -9809,6 +9809,7 @@ static void scsih_remove(struct pci_dev *pdev)
5652
5653 /* release all the volumes */
5654 _scsih_ir_shutdown(ioc);
5655 + sas_remove_host(shost);
5656 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list,
5657 list) {
5658 if (raid_device->starget) {
5659 @@ -9851,7 +9852,6 @@ static void scsih_remove(struct pci_dev *pdev)
5660 ioc->sas_hba.num_phys = 0;
5661 }
5662
5663 - sas_remove_host(shost);
5664 mpt3sas_base_detach(ioc);
5665 spin_lock(&gioc_lock);
5666 list_del(&ioc->list);
5667 diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c
5668 index f8cc2677c1cd..20d36061c217 100644
5669 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c
5670 +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c
5671 @@ -834,10 +834,13 @@ mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
5672 mpt3sas_port->remote_identify.sas_address,
5673 mpt3sas_phy->phy_id);
5674 mpt3sas_phy->phy_belongs_to_port = 0;
5675 - sas_port_delete_phy(mpt3sas_port->port, mpt3sas_phy->phy);
5676 + if (!ioc->remove_host)
5677 + sas_port_delete_phy(mpt3sas_port->port,
5678 + mpt3sas_phy->phy);
5679 list_del(&mpt3sas_phy->port_siblings);
5680 }
5681 - sas_port_delete(mpt3sas_port->port);
5682 + if (!ioc->remove_host)
5683 + sas_port_delete(mpt3sas_port->port);
5684 kfree(mpt3sas_port);
5685 }
5686
5687 diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
5688 index 8c1a232ac6bf..3781e8109dd7 100644
5689 --- a/drivers/scsi/smartpqi/smartpqi_init.c
5690 +++ b/drivers/scsi/smartpqi/smartpqi_init.c
5691 @@ -653,6 +653,7 @@ struct bmic_host_wellness_driver_version {
5692 u8 driver_version_tag[2];
5693 __le16 driver_version_length;
5694 char driver_version[32];
5695 + u8 dont_write_tag[2];
5696 u8 end_tag[2];
5697 };
5698
5699 @@ -682,6 +683,8 @@ static int pqi_write_driver_version_to_host_wellness(
5700 strncpy(buffer->driver_version, "Linux " DRIVER_VERSION,
5701 sizeof(buffer->driver_version) - 1);
5702 buffer->driver_version[sizeof(buffer->driver_version) - 1] = '\0';
5703 + buffer->dont_write_tag[0] = 'D';
5704 + buffer->dont_write_tag[1] = 'W';
5705 buffer->end_tag[0] = 'Z';
5706 buffer->end_tag[1] = 'Z';
5707
5708 @@ -1181,6 +1184,9 @@ static void pqi_get_volume_status(struct pqi_ctrl_info *ctrl_info,
5709 if (rc)
5710 goto out;
5711
5712 + if (vpd->page_code != CISS_VPD_LV_STATUS)
5713 + goto out;
5714 +
5715 page_length = offsetof(struct ciss_vpd_logical_volume_status,
5716 volume_status) + vpd->page_length;
5717 if (page_length < sizeof(*vpd))
5718 diff --git a/drivers/scsi/smartpqi/smartpqi_sis.c b/drivers/scsi/smartpqi/smartpqi_sis.c
5719 index 5141bd4c9f06..ca7dfb3a520f 100644
5720 --- a/drivers/scsi/smartpqi/smartpqi_sis.c
5721 +++ b/drivers/scsi/smartpqi/smartpqi_sis.c
5722 @@ -59,7 +59,7 @@
5723
5724 #define SIS_CTRL_KERNEL_UP 0x80
5725 #define SIS_CTRL_KERNEL_PANIC 0x100
5726 -#define SIS_CTRL_READY_TIMEOUT_SECS 30
5727 +#define SIS_CTRL_READY_TIMEOUT_SECS 180
5728 #define SIS_CTRL_READY_RESUME_TIMEOUT_SECS 90
5729 #define SIS_CTRL_READY_POLL_INTERVAL_MSECS 10
5730
5731 diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c
5732 index 14185451901d..bf9123f727e8 100644
5733 --- a/drivers/soc/bcm/brcmstb/common.c
5734 +++ b/drivers/soc/bcm/brcmstb/common.c
5735 @@ -31,13 +31,17 @@ static const struct of_device_id brcmstb_machine_match[] = {
5736
5737 bool soc_is_brcmstb(void)
5738 {
5739 + const struct of_device_id *match;
5740 struct device_node *root;
5741
5742 root = of_find_node_by_path("/");
5743 if (!root)
5744 return false;
5745
5746 - return of_match_node(brcmstb_machine_match, root) != NULL;
5747 + match = of_match_node(brcmstb_machine_match, root);
5748 + of_node_put(root);
5749 +
5750 + return match != NULL;
5751 }
5752
5753 u32 brcmstb_get_family_id(void)
5754 diff --git a/drivers/soc/tegra/common.c b/drivers/soc/tegra/common.c
5755 index cd8f41351add..7bfb154d6fa5 100644
5756 --- a/drivers/soc/tegra/common.c
5757 +++ b/drivers/soc/tegra/common.c
5758 @@ -22,11 +22,15 @@ static const struct of_device_id tegra_machine_match[] = {
5759
5760 bool soc_is_tegra(void)
5761 {
5762 + const struct of_device_id *match;
5763 struct device_node *root;
5764
5765 root = of_find_node_by_path("/");
5766 if (!root)
5767 return false;
5768
5769 - return of_match_node(tegra_machine_match, root) != NULL;
5770 + match = of_match_node(tegra_machine_match, root);
5771 + of_node_put(root);
5772 +
5773 + return match != NULL;
5774 }
5775 diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
5776 index 367b39fe46e5..e6313c54e3ad 100644
5777 --- a/drivers/staging/erofs/internal.h
5778 +++ b/drivers/staging/erofs/internal.h
5779 @@ -39,7 +39,7 @@
5780 #define debugln(x, ...) ((void)0)
5781
5782 #define dbg_might_sleep() ((void)0)
5783 -#define DBG_BUGON(...) ((void)0)
5784 +#define DBG_BUGON(x) ((void)(x))
5785 #endif
5786
5787 #ifdef CONFIG_EROFS_FAULT_INJECTION
5788 diff --git a/drivers/staging/fsl-dpaa2/rtc/rtc.c b/drivers/staging/fsl-dpaa2/rtc/rtc.c
5789 index 0d52cb85441f..318a33c2f7a7 100644
5790 --- a/drivers/staging/fsl-dpaa2/rtc/rtc.c
5791 +++ b/drivers/staging/fsl-dpaa2/rtc/rtc.c
5792 @@ -142,7 +142,10 @@ static int rtc_probe(struct fsl_mc_device *mc_dev)
5793
5794 err = fsl_mc_portal_allocate(mc_dev, 0, &mc_dev->mc_io);
5795 if (err) {
5796 - dev_err(dev, "fsl_mc_portal_allocate err %d\n", err);
5797 + if (err == -ENXIO)
5798 + err = -EPROBE_DEFER;
5799 + else
5800 + dev_err(dev, "fsl_mc_portal_allocate err %d\n", err);
5801 goto err_exit;
5802 }
5803
5804 diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
5805 index b736275c10f5..6a48ad067a8b 100644
5806 --- a/drivers/staging/iio/adc/ad7280a.c
5807 +++ b/drivers/staging/iio/adc/ad7280a.c
5808 @@ -256,7 +256,9 @@ static int ad7280_read(struct ad7280_state *st, unsigned int devaddr,
5809 if (ret)
5810 return ret;
5811
5812 - __ad7280_read32(st, &tmp);
5813 + ret = __ad7280_read32(st, &tmp);
5814 + if (ret)
5815 + return ret;
5816
5817 if (ad7280_check_crc(st, tmp))
5818 return -EIO;
5819 @@ -294,7 +296,9 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned int devaddr,
5820
5821 ad7280_delay(st);
5822
5823 - __ad7280_read32(st, &tmp);
5824 + ret = __ad7280_read32(st, &tmp);
5825 + if (ret)
5826 + return ret;
5827
5828 if (ad7280_check_crc(st, tmp))
5829 return -EIO;
5830 @@ -327,7 +331,9 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned int cnt,
5831 ad7280_delay(st);
5832
5833 for (i = 0; i < cnt; i++) {
5834 - __ad7280_read32(st, &tmp);
5835 + ret = __ad7280_read32(st, &tmp);
5836 + if (ret)
5837 + return ret;
5838
5839 if (ad7280_check_crc(st, tmp))
5840 return -EIO;
5841 @@ -370,7 +376,10 @@ static int ad7280_chain_setup(struct ad7280_state *st)
5842 return ret;
5843
5844 for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
5845 - __ad7280_read32(st, &val);
5846 + ret = __ad7280_read32(st, &val);
5847 + if (ret)
5848 + return ret;
5849 +
5850 if (val == 0)
5851 return n - 1;
5852
5853 diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
5854 index 16d72072c076..8bcb5d5de749 100644
5855 --- a/drivers/staging/iio/adc/ad7780.c
5856 +++ b/drivers/staging/iio/adc/ad7780.c
5857 @@ -87,12 +87,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
5858 long m)
5859 {
5860 struct ad7780_state *st = iio_priv(indio_dev);
5861 + int voltage_uv;
5862
5863 switch (m) {
5864 case IIO_CHAN_INFO_RAW:
5865 return ad_sigma_delta_single_conversion(indio_dev, chan, val);
5866 case IIO_CHAN_INFO_SCALE:
5867 - *val = st->int_vref_mv * st->gain;
5868 + voltage_uv = regulator_get_voltage(st->reg);
5869 + if (voltage_uv < 0)
5870 + return voltage_uv;
5871 + *val = (voltage_uv / 1000) * st->gain;
5872 *val2 = chan->scan_type.realbits - 1;
5873 return IIO_VAL_FRACTIONAL_LOG2;
5874 case IIO_CHAN_INFO_OFFSET:
5875 diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
5876 index 59586947a936..51cda9151412 100644
5877 --- a/drivers/staging/iio/resolver/ad2s90.c
5878 +++ b/drivers/staging/iio/resolver/ad2s90.c
5879 @@ -85,7 +85,12 @@ static int ad2s90_probe(struct spi_device *spi)
5880 /* need 600ns between CS and the first falling edge of SCLK */
5881 spi->max_speed_hz = 830000;
5882 spi->mode = SPI_MODE_3;
5883 - spi_setup(spi);
5884 + ret = spi_setup(spi);
5885 +
5886 + if (ret < 0) {
5887 + dev_err(&spi->dev, "spi_setup failed!\n");
5888 + return ret;
5889 + }
5890
5891 return 0;
5892 }
5893 diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
5894 index c85a805a1243..a497ec197872 100644
5895 --- a/drivers/staging/pi433/pi433_if.c
5896 +++ b/drivers/staging/pi433/pi433_if.c
5897 @@ -1255,6 +1255,10 @@ static int pi433_probe(struct spi_device *spi)
5898
5899 /* create cdev */
5900 device->cdev = cdev_alloc();
5901 + if (!device->cdev) {
5902 + dev_dbg(device->dev, "allocation of cdev failed");
5903 + goto cdev_failed;
5904 + }
5905 device->cdev->owner = THIS_MODULE;
5906 cdev_init(device->cdev, &pi433_fops);
5907 retval = cdev_add(device->cdev, device->devt, 1);
5908 diff --git a/drivers/staging/speakup/spk_ttyio.c b/drivers/staging/speakup/spk_ttyio.c
5909 index eac63aab8162..93742dbdee77 100644
5910 --- a/drivers/staging/speakup/spk_ttyio.c
5911 +++ b/drivers/staging/speakup/spk_ttyio.c
5912 @@ -265,7 +265,8 @@ static void spk_ttyio_send_xchar(char ch)
5913 return;
5914 }
5915
5916 - speakup_tty->ops->send_xchar(speakup_tty, ch);
5917 + if (speakup_tty->ops->send_xchar)
5918 + speakup_tty->ops->send_xchar(speakup_tty, ch);
5919 mutex_unlock(&speakup_tty_mutex);
5920 }
5921
5922 @@ -277,7 +278,8 @@ static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear)
5923 return;
5924 }
5925
5926 - speakup_tty->ops->tiocmset(speakup_tty, set, clear);
5927 + if (speakup_tty->ops->tiocmset)
5928 + speakup_tty->ops->tiocmset(speakup_tty, set, clear);
5929 mutex_unlock(&speakup_tty_mutex);
5930 }
5931
5932 diff --git a/drivers/tee/optee/supp.c b/drivers/tee/optee/supp.c
5933 index df35fc01fd3e..43626e15703a 100644
5934 --- a/drivers/tee/optee/supp.c
5935 +++ b/drivers/tee/optee/supp.c
5936 @@ -19,7 +19,7 @@
5937 struct optee_supp_req {
5938 struct list_head link;
5939
5940 - bool busy;
5941 + bool in_queue;
5942 u32 func;
5943 u32 ret;
5944 size_t num_params;
5945 @@ -54,7 +54,6 @@ void optee_supp_release(struct optee_supp *supp)
5946
5947 /* Abort all request retrieved by supplicant */
5948 idr_for_each_entry(&supp->idr, req, id) {
5949 - req->busy = false;
5950 idr_remove(&supp->idr, id);
5951 req->ret = TEEC_ERROR_COMMUNICATION;
5952 complete(&req->c);
5953 @@ -63,6 +62,7 @@ void optee_supp_release(struct optee_supp *supp)
5954 /* Abort all queued requests */
5955 list_for_each_entry_safe(req, req_tmp, &supp->reqs, link) {
5956 list_del(&req->link);
5957 + req->in_queue = false;
5958 req->ret = TEEC_ERROR_COMMUNICATION;
5959 complete(&req->c);
5960 }
5961 @@ -103,6 +103,7 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
5962 /* Insert the request in the request list */
5963 mutex_lock(&supp->mutex);
5964 list_add_tail(&req->link, &supp->reqs);
5965 + req->in_queue = true;
5966 mutex_unlock(&supp->mutex);
5967
5968 /* Tell an eventual waiter there's a new request */
5969 @@ -130,9 +131,10 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
5970 * will serve all requests in a timely manner and
5971 * interrupting then wouldn't make sense.
5972 */
5973 - interruptable = !req->busy;
5974 - if (!req->busy)
5975 + if (req->in_queue) {
5976 list_del(&req->link);
5977 + req->in_queue = false;
5978 + }
5979 }
5980 mutex_unlock(&supp->mutex);
5981
5982 @@ -176,7 +178,7 @@ static struct optee_supp_req *supp_pop_entry(struct optee_supp *supp,
5983 return ERR_PTR(-ENOMEM);
5984
5985 list_del(&req->link);
5986 - req->busy = true;
5987 + req->in_queue = false;
5988
5989 return req;
5990 }
5991 @@ -318,7 +320,6 @@ static struct optee_supp_req *supp_pop_req(struct optee_supp *supp,
5992 if ((num_params - nm) != req->num_params)
5993 return ERR_PTR(-EINVAL);
5994
5995 - req->busy = false;
5996 idr_remove(&supp->idr, id);
5997 supp->req_id = -1;
5998 *num_meta = nm;
5999 diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c
6000 index 23ad4f9f2143..24b006a95142 100644
6001 --- a/drivers/thermal/broadcom/bcm2835_thermal.c
6002 +++ b/drivers/thermal/broadcom/bcm2835_thermal.c
6003 @@ -27,6 +27,8 @@
6004 #include <linux/platform_device.h>
6005 #include <linux/thermal.h>
6006
6007 +#include "../thermal_hwmon.h"
6008 +
6009 #define BCM2835_TS_TSENSCTL 0x00
6010 #define BCM2835_TS_TSENSSTAT 0x04
6011
6012 @@ -275,6 +277,15 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
6013
6014 platform_set_drvdata(pdev, tz);
6015
6016 + /*
6017 + * Thermal_zone doesn't enable hwmon as default,
6018 + * enable it here
6019 + */
6020 + tz->tzp->no_hwmon = false;
6021 + err = thermal_add_hwmon_sysfs(tz);
6022 + if (err)
6023 + goto err_tz;
6024 +
6025 bcm2835_thermal_debugfs(pdev);
6026
6027 return 0;
6028 diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c
6029 index bf1c628d4a7a..e22fc60ad36d 100644
6030 --- a/drivers/thermal/thermal-generic-adc.c
6031 +++ b/drivers/thermal/thermal-generic-adc.c
6032 @@ -26,7 +26,7 @@ struct gadc_thermal_info {
6033
6034 static int gadc_thermal_adc_to_temp(struct gadc_thermal_info *gti, int val)
6035 {
6036 - int temp, adc_hi, adc_lo;
6037 + int temp, temp_hi, temp_lo, adc_hi, adc_lo;
6038 int i;
6039
6040 for (i = 0; i < gti->nlookup_table; i++) {
6041 @@ -36,13 +36,17 @@ static int gadc_thermal_adc_to_temp(struct gadc_thermal_info *gti, int val)
6042
6043 if (i == 0) {
6044 temp = gti->lookup_table[0];
6045 - } else if (i >= (gti->nlookup_table - 1)) {
6046 + } else if (i >= gti->nlookup_table) {
6047 temp = gti->lookup_table[2 * (gti->nlookup_table - 1)];
6048 } else {
6049 adc_hi = gti->lookup_table[2 * i - 1];
6050 adc_lo = gti->lookup_table[2 * i + 1];
6051 - temp = gti->lookup_table[2 * i];
6052 - temp -= ((val - adc_lo) * 1000) / (adc_hi - adc_lo);
6053 +
6054 + temp_hi = gti->lookup_table[2 * i - 2];
6055 + temp_lo = gti->lookup_table[2 * i];
6056 +
6057 + temp = temp_hi + mult_frac(temp_lo - temp_hi, val - adc_hi,
6058 + adc_lo - adc_hi);
6059 }
6060
6061 return temp;
6062 diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
6063 index 441778100887..bf9721fc2824 100644
6064 --- a/drivers/thermal/thermal_core.c
6065 +++ b/drivers/thermal/thermal_core.c
6066 @@ -451,16 +451,20 @@ static void update_temperature(struct thermal_zone_device *tz)
6067 tz->last_temperature, tz->temperature);
6068 }
6069
6070 -static void thermal_zone_device_reset(struct thermal_zone_device *tz)
6071 +static void thermal_zone_device_init(struct thermal_zone_device *tz)
6072 {
6073 struct thermal_instance *pos;
6074 -
6075 tz->temperature = THERMAL_TEMP_INVALID;
6076 - tz->passive = 0;
6077 list_for_each_entry(pos, &tz->thermal_instances, tz_node)
6078 pos->initialized = false;
6079 }
6080
6081 +static void thermal_zone_device_reset(struct thermal_zone_device *tz)
6082 +{
6083 + tz->passive = 0;
6084 + thermal_zone_device_init(tz);
6085 +}
6086 +
6087 void thermal_zone_device_update(struct thermal_zone_device *tz,
6088 enum thermal_notify_event event)
6089 {
6090 @@ -1502,7 +1506,7 @@ static int thermal_pm_notify(struct notifier_block *nb,
6091 case PM_POST_SUSPEND:
6092 atomic_set(&in_suspend, 0);
6093 list_for_each_entry(tz, &thermal_tz_list, node) {
6094 - thermal_zone_device_reset(tz);
6095 + thermal_zone_device_init(tz);
6096 thermal_zone_device_update(tz,
6097 THERMAL_EVENT_UNSPECIFIED);
6098 }
6099 diff --git a/drivers/thermal/thermal_hwmon.h b/drivers/thermal/thermal_hwmon.h
6100 index 019f6f88224e..a160b9d62dd0 100644
6101 --- a/drivers/thermal/thermal_hwmon.h
6102 +++ b/drivers/thermal/thermal_hwmon.h
6103 @@ -19,13 +19,13 @@
6104 int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz);
6105 void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz);
6106 #else
6107 -static int
6108 +static inline int
6109 thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
6110 {
6111 return 0;
6112 }
6113
6114 -static void
6115 +static inline void
6116 thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
6117 {
6118 }
6119 diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
6120 index 2241ceae7d7f..aa99edb4dff7 100644
6121 --- a/drivers/thermal/thermal_sysfs.c
6122 +++ b/drivers/thermal/thermal_sysfs.c
6123 @@ -712,11 +712,14 @@ cur_state_store(struct device *dev, struct device_attribute *attr,
6124 if ((long)state < 0)
6125 return -EINVAL;
6126
6127 + mutex_lock(&cdev->lock);
6128 +
6129 result = cdev->ops->set_cur_state(cdev, state);
6130 - if (result)
6131 - return result;
6132 - thermal_cooling_device_stats_update(cdev, state);
6133 - return count;
6134 + if (!result)
6135 + thermal_cooling_device_stats_update(cdev, state);
6136 +
6137 + mutex_unlock(&cdev->lock);
6138 + return result ? result : count;
6139 }
6140
6141 static struct device_attribute
6142 diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
6143 index f80a300b5d68..48bd694a5fa1 100644
6144 --- a/drivers/tty/serial/8250/8250_pci.c
6145 +++ b/drivers/tty/serial/8250/8250_pci.c
6146 @@ -3420,6 +3420,11 @@ static int
6147 serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board)
6148 {
6149 int num_iomem, num_port, first_port = -1, i;
6150 + int rc;
6151 +
6152 + rc = serial_pci_is_class_communication(dev);
6153 + if (rc)
6154 + return rc;
6155
6156 /*
6157 * Should we try to make guesses for multiport serial devices later?
6158 @@ -3647,10 +3652,6 @@ pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
6159
6160 board = &pci_boards[ent->driver_data];
6161
6162 - rc = serial_pci_is_class_communication(dev);
6163 - if (rc)
6164 - return rc;
6165 -
6166 rc = serial_pci_is_blacklisted(dev);
6167 if (rc)
6168 return rc;
6169 diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
6170 index 3f8d1274fc85..7d030c2e42ff 100644
6171 --- a/drivers/tty/serial/fsl_lpuart.c
6172 +++ b/drivers/tty/serial/fsl_lpuart.c
6173 @@ -1477,6 +1477,8 @@ lpuart_set_termios(struct uart_port *port, struct ktermios *termios,
6174 else
6175 cr1 &= ~UARTCR1_PT;
6176 }
6177 + } else {
6178 + cr1 &= ~UARTCR1_PE;
6179 }
6180
6181 /* ask the core to calculate the divisor */
6182 @@ -1688,6 +1690,8 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
6183 else
6184 ctrl &= ~UARTCTRL_PT;
6185 }
6186 + } else {
6187 + ctrl &= ~UARTCTRL_PE;
6188 }
6189
6190 /* ask the core to calculate the divisor */
6191 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
6192 index 2f8fa184aafa..c6058b52d5d5 100644
6193 --- a/drivers/tty/serial/samsung.c
6194 +++ b/drivers/tty/serial/samsung.c
6195 @@ -1365,11 +1365,14 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
6196 wr_regl(port, S3C2410_ULCON, ulcon);
6197 wr_regl(port, S3C2410_UBRDIV, quot);
6198
6199 + port->status &= ~UPSTAT_AUTOCTS;
6200 +
6201 umcon = rd_regl(port, S3C2410_UMCON);
6202 if (termios->c_cflag & CRTSCTS) {
6203 umcon |= S3C2410_UMCOM_AFC;
6204 /* Disable RTS when RX FIFO contains 63 bytes */
6205 umcon &= ~S3C2412_UMCON_AFC_8;
6206 + port->status = UPSTAT_AUTOCTS;
6207 } else {
6208 umcon &= ~S3C2410_UMCOM_AFC;
6209 }
6210 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
6211 index 7fe679413188..f0b354b65a0e 100644
6212 --- a/drivers/tty/serial/serial_core.c
6213 +++ b/drivers/tty/serial/serial_core.c
6214 @@ -130,6 +130,9 @@ static void uart_start(struct tty_struct *tty)
6215 struct uart_port *port;
6216 unsigned long flags;
6217
6218 + if (!state)
6219 + return;
6220 +
6221 port = uart_port_lock(state, flags);
6222 __uart_start(tty);
6223 uart_port_unlock(port, flags);
6224 @@ -727,6 +730,9 @@ static void uart_unthrottle(struct tty_struct *tty)
6225 upstat_t mask = UPSTAT_SYNC_FIFO;
6226 struct uart_port *port;
6227
6228 + if (!state)
6229 + return;
6230 +
6231 port = uart_port_ref(state);
6232 if (!port)
6233 return;
6234 diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
6235 index effba6ce0caa..859b173e3b82 100644
6236 --- a/drivers/tty/serial/sh-sci.c
6237 +++ b/drivers/tty/serial/sh-sci.c
6238 @@ -1331,7 +1331,7 @@ static void sci_tx_dma_release(struct sci_port *s)
6239 dma_release_channel(chan);
6240 }
6241
6242 -static void sci_submit_rx(struct sci_port *s)
6243 +static int sci_submit_rx(struct sci_port *s, bool port_lock_held)
6244 {
6245 struct dma_chan *chan = s->chan_rx;
6246 struct uart_port *port = &s->port;
6247 @@ -1359,19 +1359,22 @@ static void sci_submit_rx(struct sci_port *s)
6248 s->active_rx = s->cookie_rx[0];
6249
6250 dma_async_issue_pending(chan);
6251 - return;
6252 + return 0;
6253
6254 fail:
6255 + /* Switch to PIO */
6256 + if (!port_lock_held)
6257 + spin_lock_irqsave(&port->lock, flags);
6258 if (i)
6259 dmaengine_terminate_async(chan);
6260 for (i = 0; i < 2; i++)
6261 s->cookie_rx[i] = -EINVAL;
6262 s->active_rx = -EINVAL;
6263 - /* Switch to PIO */
6264 - spin_lock_irqsave(&port->lock, flags);
6265 s->chan_rx = NULL;
6266 sci_start_rx(port);
6267 - spin_unlock_irqrestore(&port->lock, flags);
6268 + if (!port_lock_held)
6269 + spin_unlock_irqrestore(&port->lock, flags);
6270 + return -EAGAIN;
6271 }
6272
6273 static void work_fn_tx(struct work_struct *work)
6274 @@ -1491,7 +1494,7 @@ static enum hrtimer_restart rx_timer_fn(struct hrtimer *t)
6275 }
6276
6277 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
6278 - sci_submit_rx(s);
6279 + sci_submit_rx(s, true);
6280
6281 /* Direct new serial port interrupts back to CPU */
6282 scr = serial_port_in(port, SCSCR);
6283 @@ -1617,7 +1620,7 @@ static void sci_request_dma(struct uart_port *port)
6284 s->chan_rx_saved = s->chan_rx = chan;
6285
6286 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
6287 - sci_submit_rx(s);
6288 + sci_submit_rx(s, false);
6289 }
6290 }
6291
6292 @@ -1666,8 +1669,10 @@ static irqreturn_t sci_rx_interrupt(int irq, void *ptr)
6293 disable_irq_nosync(irq);
6294 scr |= SCSCR_RDRQE;
6295 } else {
6296 + if (sci_submit_rx(s, false) < 0)
6297 + goto handle_pio;
6298 +
6299 scr &= ~SCSCR_RIE;
6300 - sci_submit_rx(s);
6301 }
6302 serial_port_out(port, SCSCR, scr);
6303 /* Clear current interrupt */
6304 @@ -1679,6 +1684,8 @@ static irqreturn_t sci_rx_interrupt(int irq, void *ptr)
6305
6306 return IRQ_HANDLED;
6307 }
6308 +
6309 +handle_pio:
6310 #endif
6311
6312 if (s->rx_trigger > 1 && s->rx_fifo_timeout > 0) {
6313 @@ -1914,7 +1921,7 @@ out_nomem:
6314
6315 static void sci_free_irq(struct sci_port *port)
6316 {
6317 - int i;
6318 + int i, j;
6319
6320 /*
6321 * Intentionally in reverse order so we iterate over the muxed
6322 @@ -1930,6 +1937,13 @@ static void sci_free_irq(struct sci_port *port)
6323 if (unlikely(irq < 0))
6324 continue;
6325
6326 + /* Check if already freed (irq was muxed) */
6327 + for (j = 0; j < i; j++)
6328 + if (port->irqs[j] == irq)
6329 + j = i + 1;
6330 + if (j > i)
6331 + continue;
6332 +
6333 free_irq(port->irqs[i], port);
6334 kfree(port->irqstr[i]);
6335
6336 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
6337 index cc62707c0251..3adff4da2ee1 100644
6338 --- a/drivers/usb/core/hub.c
6339 +++ b/drivers/usb/core/hub.c
6340 @@ -1111,6 +1111,16 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
6341 USB_PORT_FEAT_ENABLE);
6342 }
6343
6344 + /*
6345 + * Add debounce if USB3 link is in polling/link training state.
6346 + * Link will automatically transition to Enabled state after
6347 + * link training completes.
6348 + */
6349 + if (hub_is_superspeed(hdev) &&
6350 + ((portstatus & USB_PORT_STAT_LINK_STATE) ==
6351 + USB_SS_PORT_LS_POLLING))
6352 + need_debounce_delay = true;
6353 +
6354 /* Clear status-change flags; we'll debounce later */
6355 if (portchange & USB_PORT_STAT_C_CONNECTION) {
6356 need_debounce_delay = true;
6357 diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
6358 index ef2c199e6059..dff2c6e8d797 100644
6359 --- a/drivers/usb/dwc2/params.c
6360 +++ b/drivers/usb/dwc2/params.c
6361 @@ -71,6 +71,13 @@ static void dwc2_set_his_params(struct dwc2_hsotg *hsotg)
6362 p->power_down = false;
6363 }
6364
6365 +static void dwc2_set_s3c6400_params(struct dwc2_hsotg *hsotg)
6366 +{
6367 + struct dwc2_core_params *p = &hsotg->params;
6368 +
6369 + p->power_down = 0;
6370 +}
6371 +
6372 static void dwc2_set_rk_params(struct dwc2_hsotg *hsotg)
6373 {
6374 struct dwc2_core_params *p = &hsotg->params;
6375 @@ -151,7 +158,8 @@ const struct of_device_id dwc2_of_match_table[] = {
6376 { .compatible = "lantiq,arx100-usb", .data = dwc2_set_ltq_params },
6377 { .compatible = "lantiq,xrx200-usb", .data = dwc2_set_ltq_params },
6378 { .compatible = "snps,dwc2" },
6379 - { .compatible = "samsung,s3c6400-hsotg" },
6380 + { .compatible = "samsung,s3c6400-hsotg",
6381 + .data = dwc2_set_s3c6400_params },
6382 { .compatible = "amlogic,meson8-usb",
6383 .data = dwc2_set_amlogic_params },
6384 { .compatible = "amlogic,meson8b-usb",
6385 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
6386 index d8bf9307901e..0db90f6f4aa8 100644
6387 --- a/drivers/usb/dwc3/gadget.c
6388 +++ b/drivers/usb/dwc3/gadget.c
6389 @@ -912,8 +912,6 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb,
6390 struct usb_gadget *gadget = &dwc->gadget;
6391 enum usb_device_speed speed = gadget->speed;
6392
6393 - dwc3_ep_inc_enq(dep);
6394 -
6395 trb->size = DWC3_TRB_SIZE_LENGTH(length);
6396 trb->bpl = lower_32_bits(dma);
6397 trb->bph = upper_32_bits(dma);
6398 @@ -983,16 +981,20 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb,
6399 usb_endpoint_type(dep->endpoint.desc));
6400 }
6401
6402 - /* always enable Continue on Short Packet */
6403 + /*
6404 + * Enable Continue on Short Packet
6405 + * when endpoint is not a stream capable
6406 + */
6407 if (usb_endpoint_dir_out(dep->endpoint.desc)) {
6408 - trb->ctrl |= DWC3_TRB_CTRL_CSP;
6409 + if (!dep->stream_capable)
6410 + trb->ctrl |= DWC3_TRB_CTRL_CSP;
6411
6412 if (short_not_ok)
6413 trb->ctrl |= DWC3_TRB_CTRL_ISP_IMI;
6414 }
6415
6416 if ((!no_interrupt && !chain) ||
6417 - (dwc3_calc_trbs_left(dep) == 0))
6418 + (dwc3_calc_trbs_left(dep) == 1))
6419 trb->ctrl |= DWC3_TRB_CTRL_IOC;
6420
6421 if (chain)
6422 @@ -1003,6 +1005,8 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb,
6423
6424 trb->ctrl |= DWC3_TRB_CTRL_HWO;
6425
6426 + dwc3_ep_inc_enq(dep);
6427 +
6428 trace_dwc3_prepare_trb(dep, trb);
6429 }
6430
6431 @@ -1106,7 +1110,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
6432 unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
6433 unsigned int rem = length % maxp;
6434
6435 - if (rem && usb_endpoint_dir_out(dep->endpoint.desc)) {
6436 + if ((!length || rem) && usb_endpoint_dir_out(dep->endpoint.desc)) {
6437 struct dwc3 *dwc = dep->dwc;
6438 struct dwc3_trb *trb;
6439
6440 diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h
6441 index f22714cce070..f27c5cbe285c 100644
6442 --- a/drivers/usb/dwc3/trace.h
6443 +++ b/drivers/usb/dwc3/trace.h
6444 @@ -251,9 +251,11 @@ DECLARE_EVENT_CLASS(dwc3_log_trb,
6445 s = "2x ";
6446 break;
6447 case 3:
6448 + default:
6449 s = "3x ";
6450 break;
6451 }
6452 + break;
6453 default:
6454 s = "";
6455 } s; }),
6456 diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c
6457 index 660878a19505..b77f3126580e 100644
6458 --- a/drivers/usb/gadget/udc/net2272.c
6459 +++ b/drivers/usb/gadget/udc/net2272.c
6460 @@ -2083,7 +2083,7 @@ static irqreturn_t net2272_irq(int irq, void *_dev)
6461 #if defined(PLX_PCI_RDK2)
6462 /* see if PCI int for us by checking irqstat */
6463 intcsr = readl(dev->rdk2.fpga_base_addr + RDK2_IRQSTAT);
6464 - if (!intcsr & (1 << NET2272_PCI_IRQ)) {
6465 + if (!(intcsr & (1 << NET2272_PCI_IRQ))) {
6466 spin_unlock(&dev->lock);
6467 return IRQ_NONE;
6468 }
6469 diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
6470 index d045d8458f81..48d10a61e271 100644
6471 --- a/drivers/usb/mtu3/mtu3_core.c
6472 +++ b/drivers/usb/mtu3/mtu3_core.c
6473 @@ -578,8 +578,10 @@ static void mtu3_regs_init(struct mtu3 *mtu)
6474 if (mtu->is_u3_ip) {
6475 /* disable LGO_U1/U2 by default */
6476 mtu3_clrbits(mbase, U3D_LINK_POWER_CONTROL,
6477 - SW_U1_ACCEPT_ENABLE | SW_U2_ACCEPT_ENABLE |
6478 SW_U1_REQUEST_ENABLE | SW_U2_REQUEST_ENABLE);
6479 + /* enable accept LGO_U1/U2 link command from host */
6480 + mtu3_setbits(mbase, U3D_LINK_POWER_CONTROL,
6481 + SW_U1_ACCEPT_ENABLE | SW_U2_ACCEPT_ENABLE);
6482 /* device responses to u3_exit from host automatically */
6483 mtu3_clrbits(mbase, U3D_LTSSM_CTRL, SOFT_U3_EXIT_EN);
6484 /* automatically build U2 link when U3 detect fail */
6485 diff --git a/drivers/usb/mtu3/mtu3_gadget_ep0.c b/drivers/usb/mtu3/mtu3_gadget_ep0.c
6486 index 25216e79cd6e..3c464d8ae023 100644
6487 --- a/drivers/usb/mtu3/mtu3_gadget_ep0.c
6488 +++ b/drivers/usb/mtu3/mtu3_gadget_ep0.c
6489 @@ -336,9 +336,9 @@ static int ep0_handle_feature_dev(struct mtu3 *mtu,
6490
6491 lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL);
6492 if (set)
6493 - lpc |= SW_U1_ACCEPT_ENABLE;
6494 + lpc |= SW_U1_REQUEST_ENABLE;
6495 else
6496 - lpc &= ~SW_U1_ACCEPT_ENABLE;
6497 + lpc &= ~SW_U1_REQUEST_ENABLE;
6498 mtu3_writel(mbase, U3D_LINK_POWER_CONTROL, lpc);
6499
6500 mtu->u1_enable = !!set;
6501 @@ -351,9 +351,9 @@ static int ep0_handle_feature_dev(struct mtu3 *mtu,
6502
6503 lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL);
6504 if (set)
6505 - lpc |= SW_U2_ACCEPT_ENABLE;
6506 + lpc |= SW_U2_REQUEST_ENABLE;
6507 else
6508 - lpc &= ~SW_U2_ACCEPT_ENABLE;
6509 + lpc &= ~SW_U2_REQUEST_ENABLE;
6510 mtu3_writel(mbase, U3D_LINK_POWER_CONTROL, lpc);
6511
6512 mtu->u2_enable = !!set;
6513 diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
6514 index 23a0df79ef21..403eb97915f8 100644
6515 --- a/drivers/usb/musb/musb_dsps.c
6516 +++ b/drivers/usb/musb/musb_dsps.c
6517 @@ -181,9 +181,11 @@ static void dsps_musb_enable(struct musb *musb)
6518
6519 musb_writel(reg_base, wrp->epintr_set, epmask);
6520 musb_writel(reg_base, wrp->coreintr_set, coremask);
6521 - /* start polling for ID change in dual-role idle mode */
6522 - if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
6523 - musb->port_mode == MUSB_OTG)
6524 + /*
6525 + * start polling for runtime PM active and idle,
6526 + * and for ID change in dual-role idle mode.
6527 + */
6528 + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
6529 dsps_mod_timer(glue, -1);
6530 }
6531
6532 @@ -227,8 +229,13 @@ static int dsps_check_status(struct musb *musb, void *unused)
6533
6534 switch (musb->xceiv->otg->state) {
6535 case OTG_STATE_A_WAIT_VRISE:
6536 - dsps_mod_timer_optional(glue);
6537 - break;
6538 + if (musb->port_mode == MUSB_HOST) {
6539 + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
6540 + dsps_mod_timer_optional(glue);
6541 + break;
6542 + }
6543 + /* fall through */
6544 +
6545 case OTG_STATE_A_WAIT_BCON:
6546 /* keep VBUS on for host-only mode */
6547 if (musb->port_mode == MUSB_HOST) {
6548 @@ -249,6 +256,10 @@ static int dsps_check_status(struct musb *musb, void *unused)
6549 musb->xceiv->otg->state = OTG_STATE_A_IDLE;
6550 MUSB_HST_MODE(musb);
6551 }
6552 +
6553 + if (musb->port_mode == MUSB_PERIPHERAL)
6554 + skip_session = 1;
6555 +
6556 if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
6557 musb_writeb(mregs, MUSB_DEVCTL,
6558 MUSB_DEVCTL_SESSION);
6559 diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
6560 index eae8b1b1b45b..ffe462a657b1 100644
6561 --- a/drivers/usb/musb/musb_gadget.c
6562 +++ b/drivers/usb/musb/musb_gadget.c
6563 @@ -452,13 +452,10 @@ void musb_g_tx(struct musb *musb, u8 epnum)
6564 }
6565
6566 if (request) {
6567 - u8 is_dma = 0;
6568 - bool short_packet = false;
6569
6570 trace_musb_req_tx(req);
6571
6572 if (dma && (csr & MUSB_TXCSR_DMAENAB)) {
6573 - is_dma = 1;
6574 csr |= MUSB_TXCSR_P_WZC_BITS;
6575 csr &= ~(MUSB_TXCSR_DMAENAB | MUSB_TXCSR_P_UNDERRUN |
6576 MUSB_TXCSR_TXPKTRDY | MUSB_TXCSR_AUTOSET);
6577 @@ -476,16 +473,8 @@ void musb_g_tx(struct musb *musb, u8 epnum)
6578 */
6579 if ((request->zero && request->length)
6580 && (request->length % musb_ep->packet_sz == 0)
6581 - && (request->actual == request->length))
6582 - short_packet = true;
6583 + && (request->actual == request->length)) {
6584
6585 - if ((musb_dma_inventra(musb) || musb_dma_ux500(musb)) &&
6586 - (is_dma && (!dma->desired_mode ||
6587 - (request->actual &
6588 - (musb_ep->packet_sz - 1)))))
6589 - short_packet = true;
6590 -
6591 - if (short_packet) {
6592 /*
6593 * On DMA completion, FIFO may not be
6594 * available yet...
6595 diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
6596 index a688f7f87829..5fc6825745f2 100644
6597 --- a/drivers/usb/musb/musbhsdma.c
6598 +++ b/drivers/usb/musb/musbhsdma.c
6599 @@ -346,12 +346,10 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
6600 channel->status = MUSB_DMA_STATUS_FREE;
6601
6602 /* completed */
6603 - if ((devctl & MUSB_DEVCTL_HM)
6604 - && (musb_channel->transmit)
6605 - && ((channel->desired_mode == 0)
6606 - || (channel->actual_len &
6607 - (musb_channel->max_packet_sz - 1)))
6608 - ) {
6609 + if (musb_channel->transmit &&
6610 + (!channel->desired_mode ||
6611 + (channel->actual_len %
6612 + musb_channel->max_packet_sz))) {
6613 u8 epnum = musb_channel->epnum;
6614 int offset = musb->io.ep_offset(epnum,
6615 MUSB_TXCSR);
6616 @@ -363,11 +361,14 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
6617 */
6618 musb_ep_select(mbase, epnum);
6619 txcsr = musb_readw(mbase, offset);
6620 - txcsr &= ~(MUSB_TXCSR_DMAENAB
6621 + if (channel->desired_mode == 1) {
6622 + txcsr &= ~(MUSB_TXCSR_DMAENAB
6623 | MUSB_TXCSR_AUTOSET);
6624 - musb_writew(mbase, offset, txcsr);
6625 - /* Send out the packet */
6626 - txcsr &= ~MUSB_TXCSR_DMAMODE;
6627 + musb_writew(mbase, offset, txcsr);
6628 + /* Send out the packet */
6629 + txcsr &= ~MUSB_TXCSR_DMAMODE;
6630 + txcsr |= MUSB_TXCSR_DMAENAB;
6631 + }
6632 txcsr |= MUSB_TXCSR_TXPKTRDY;
6633 musb_writew(mbase, offset, txcsr);
6634 }
6635 diff --git a/drivers/usb/phy/phy-am335x.c b/drivers/usb/phy/phy-am335x.c
6636 index 27bdb7222527..f5f0568d8533 100644
6637 --- a/drivers/usb/phy/phy-am335x.c
6638 +++ b/drivers/usb/phy/phy-am335x.c
6639 @@ -61,9 +61,6 @@ static int am335x_phy_probe(struct platform_device *pdev)
6640 if (ret)
6641 return ret;
6642
6643 - ret = usb_add_phy_dev(&am_phy->usb_phy_gen.phy);
6644 - if (ret)
6645 - return ret;
6646 am_phy->usb_phy_gen.phy.init = am335x_init;
6647 am_phy->usb_phy_gen.phy.shutdown = am335x_shutdown;
6648
6649 @@ -82,7 +79,7 @@ static int am335x_phy_probe(struct platform_device *pdev)
6650 device_set_wakeup_enable(dev, false);
6651 phy_ctrl_power(am_phy->phy_ctrl, am_phy->id, am_phy->dr_mode, false);
6652
6653 - return 0;
6654 + return usb_add_phy_dev(&am_phy->usb_phy_gen.phy);
6655 }
6656
6657 static int am335x_phy_remove(struct platform_device *pdev)
6658 diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
6659 index 4310df46639d..b0792585d5bc 100644
6660 --- a/drivers/usb/renesas_usbhs/common.c
6661 +++ b/drivers/usb/renesas_usbhs/common.c
6662 @@ -457,6 +457,10 @@ static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)
6663 * platform functions
6664 */
6665 static const struct of_device_id usbhs_of_match[] = {
6666 + {
6667 + .compatible = "renesas,usbhs-r8a774c0",
6668 + .data = (void *)USBHS_TYPE_RCAR_GEN3_WITH_PLL,
6669 + },
6670 {
6671 .compatible = "renesas,usbhs-r8a7790",
6672 .data = (void *)USBHS_TYPE_RCAR_GEN2,
6673 diff --git a/drivers/video/fbdev/clps711x-fb.c b/drivers/video/fbdev/clps711x-fb.c
6674 index ff561073ee4e..42f909618f04 100644
6675 --- a/drivers/video/fbdev/clps711x-fb.c
6676 +++ b/drivers/video/fbdev/clps711x-fb.c
6677 @@ -287,14 +287,17 @@ static int clps711x_fb_probe(struct platform_device *pdev)
6678 }
6679
6680 ret = of_get_fb_videomode(disp, &cfb->mode, OF_USE_NATIVE_MODE);
6681 - if (ret)
6682 + if (ret) {
6683 + of_node_put(disp);
6684 goto out_fb_release;
6685 + }
6686
6687 of_property_read_u32(disp, "ac-prescale", &cfb->ac_prescale);
6688 cfb->cmap_invert = of_property_read_bool(disp, "cmap-invert");
6689
6690 ret = of_property_read_u32(disp, "bits-per-pixel",
6691 &info->var.bits_per_pixel);
6692 + of_node_put(disp);
6693 if (ret)
6694 goto out_fb_release;
6695
6696 diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
6697 index 75ebbbf0a1fb..5d961e3ac66e 100644
6698 --- a/drivers/video/fbdev/core/fbcon.c
6699 +++ b/drivers/video/fbdev/core/fbcon.c
6700 @@ -3066,7 +3066,7 @@ static int fbcon_fb_unbind(int idx)
6701 for (i = first_fb_vc; i <= last_fb_vc; i++) {
6702 if (con2fb_map[i] != idx &&
6703 con2fb_map[i] != -1) {
6704 - new_idx = i;
6705 + new_idx = con2fb_map[i];
6706 break;
6707 }
6708 }
6709 diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
6710 index 20405421a5ed..77cee99fc36c 100644
6711 --- a/drivers/video/fbdev/core/fbmem.c
6712 +++ b/drivers/video/fbdev/core/fbmem.c
6713 @@ -435,7 +435,9 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
6714 image->dx += image->width + 8;
6715 }
6716 } else if (rotate == FB_ROTATE_UD) {
6717 - for (x = 0; x < num; x++) {
6718 + u32 dx = image->dx;
6719 +
6720 + for (x = 0; x < num && image->dx <= dx; x++) {
6721 info->fbops->fb_imageblit(info, image);
6722 image->dx -= image->width + 8;
6723 }
6724 @@ -447,7 +449,9 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
6725 image->dy += image->height + 8;
6726 }
6727 } else if (rotate == FB_ROTATE_CCW) {
6728 - for (x = 0; x < num; x++) {
6729 + u32 dy = image->dy;
6730 +
6731 + for (x = 0; x < num && image->dy <= dy; x++) {
6732 info->fbops->fb_imageblit(info, image);
6733 image->dy -= image->height + 8;
6734 }
6735 diff --git a/drivers/virt/vboxguest/vboxguest_core.c b/drivers/virt/vboxguest/vboxguest_core.c
6736 index 3093655c7b92..1475ed5ffcde 100644
6737 --- a/drivers/virt/vboxguest/vboxguest_core.c
6738 +++ b/drivers/virt/vboxguest/vboxguest_core.c
6739 @@ -1312,7 +1312,7 @@ static int vbg_ioctl_hgcm_call(struct vbg_dev *gdev,
6740 return -EINVAL;
6741 }
6742
6743 - if (f32bit)
6744 + if (IS_ENABLED(CONFIG_COMPAT) && f32bit)
6745 ret = vbg_hgcm_call32(gdev, client_id,
6746 call->function, call->timeout_ms,
6747 VBG_IOCTL_HGCM_CALL_PARMS32(call),
6748 diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c
6749 index 88d81feba4e6..d01efd342dc0 100644
6750 --- a/drivers/watchdog/renesas_wdt.c
6751 +++ b/drivers/watchdog/renesas_wdt.c
6752 @@ -77,12 +77,17 @@ static int rwdt_init_timeout(struct watchdog_device *wdev)
6753 static int rwdt_start(struct watchdog_device *wdev)
6754 {
6755 struct rwdt_priv *priv = watchdog_get_drvdata(wdev);
6756 + u8 val;
6757
6758 pm_runtime_get_sync(wdev->parent);
6759
6760 - rwdt_write(priv, 0, RWTCSRB);
6761 - rwdt_write(priv, priv->cks, RWTCSRA);
6762 + /* Stop the timer before we modify any register */
6763 + val = readb_relaxed(priv->base + RWTCSRA) & ~RWTCSRA_TME;
6764 + rwdt_write(priv, val, RWTCSRA);
6765 +
6766 rwdt_init_timeout(wdev);
6767 + rwdt_write(priv, priv->cks, RWTCSRA);
6768 + rwdt_write(priv, 0, RWTCSRB);
6769
6770 while (readb_relaxed(priv->base + RWTCSRA) & RWTCSRA_WRFLG)
6771 cpu_relax();
6772 diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c
6773 index 7cde3f46ad26..d0078cbb718b 100644
6774 --- a/fs/binfmt_script.c
6775 +++ b/fs/binfmt_script.c
6776 @@ -42,10 +42,14 @@ static int load_script(struct linux_binprm *bprm)
6777 fput(bprm->file);
6778 bprm->file = NULL;
6779
6780 - bprm->buf[BINPRM_BUF_SIZE - 1] = '\0';
6781 - if ((cp = strchr(bprm->buf, '\n')) == NULL)
6782 - cp = bprm->buf+BINPRM_BUF_SIZE-1;
6783 + for (cp = bprm->buf+2;; cp++) {
6784 + if (cp >= bprm->buf + BINPRM_BUF_SIZE)
6785 + return -ENOEXEC;
6786 + if (!*cp || (*cp == '\n'))
6787 + break;
6788 + }
6789 *cp = '\0';
6790 +
6791 while (cp > bprm->buf) {
6792 cp--;
6793 if ((*cp == ' ') || (*cp == '\t'))
6794 diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
6795 index 7177d1d33584..45f5cf9cd203 100644
6796 --- a/fs/btrfs/btrfs_inode.h
6797 +++ b/fs/btrfs/btrfs_inode.h
6798 @@ -29,6 +29,7 @@ enum {
6799 BTRFS_INODE_IN_DELALLOC_LIST,
6800 BTRFS_INODE_READDIO_NEED_LOCK,
6801 BTRFS_INODE_HAS_PROPS,
6802 + BTRFS_INODE_SNAPSHOT_FLUSH,
6803 };
6804
6805 /* in memory btrfs inode */
6806 diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
6807 index 2cddfe7806a4..82682da5a40d 100644
6808 --- a/fs/btrfs/ctree.h
6809 +++ b/fs/btrfs/ctree.h
6810 @@ -3155,7 +3155,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
6811 struct inode *inode, u64 new_size,
6812 u32 min_type);
6813
6814 -int btrfs_start_delalloc_inodes(struct btrfs_root *root);
6815 +int btrfs_start_delalloc_snapshot(struct btrfs_root *root);
6816 int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int nr);
6817 int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,
6818 unsigned int extra_bits,
6819 diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
6820 index 4dd6faab02bb..79f82f2ec4d5 100644
6821 --- a/fs/btrfs/extent_io.c
6822 +++ b/fs/btrfs/extent_io.c
6823 @@ -3928,12 +3928,25 @@ static int extent_write_cache_pages(struct address_space *mapping,
6824 range_whole = 1;
6825 scanned = 1;
6826 }
6827 - if (wbc->sync_mode == WB_SYNC_ALL)
6828 +
6829 + /*
6830 + * We do the tagged writepage as long as the snapshot flush bit is set
6831 + * and we are the first one who do the filemap_flush() on this inode.
6832 + *
6833 + * The nr_to_write == LONG_MAX is needed to make sure other flushers do
6834 + * not race in and drop the bit.
6835 + */
6836 + if (range_whole && wbc->nr_to_write == LONG_MAX &&
6837 + test_and_clear_bit(BTRFS_INODE_SNAPSHOT_FLUSH,
6838 + &BTRFS_I(inode)->runtime_flags))
6839 + wbc->tagged_writepages = 1;
6840 +
6841 + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
6842 tag = PAGECACHE_TAG_TOWRITE;
6843 else
6844 tag = PAGECACHE_TAG_DIRTY;
6845 retry:
6846 - if (wbc->sync_mode == WB_SYNC_ALL)
6847 + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
6848 tag_pages_for_writeback(mapping, index, end);
6849 done_index = index;
6850 while (!done && !nr_to_write_done && (index <= end) &&
6851 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
6852 index 83b3a626c796..59f361f7d0c1 100644
6853 --- a/fs/btrfs/inode.c
6854 +++ b/fs/btrfs/inode.c
6855 @@ -10005,7 +10005,7 @@ static struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode
6856 * some fairly slow code that needs optimization. This walks the list
6857 * of all the inodes with pending delalloc and forces them to disk.
6858 */
6859 -static int start_delalloc_inodes(struct btrfs_root *root, int nr)
6860 +static int start_delalloc_inodes(struct btrfs_root *root, int nr, bool snapshot)
6861 {
6862 struct btrfs_inode *binode;
6863 struct inode *inode;
6864 @@ -10033,6 +10033,9 @@ static int start_delalloc_inodes(struct btrfs_root *root, int nr)
6865 }
6866 spin_unlock(&root->delalloc_lock);
6867
6868 + if (snapshot)
6869 + set_bit(BTRFS_INODE_SNAPSHOT_FLUSH,
6870 + &binode->runtime_flags);
6871 work = btrfs_alloc_delalloc_work(inode);
6872 if (!work) {
6873 iput(inode);
6874 @@ -10066,7 +10069,7 @@ out:
6875 return ret;
6876 }
6877
6878 -int btrfs_start_delalloc_inodes(struct btrfs_root *root)
6879 +int btrfs_start_delalloc_snapshot(struct btrfs_root *root)
6880 {
6881 struct btrfs_fs_info *fs_info = root->fs_info;
6882 int ret;
6883 @@ -10074,7 +10077,7 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root)
6884 if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state))
6885 return -EROFS;
6886
6887 - ret = start_delalloc_inodes(root, -1);
6888 + ret = start_delalloc_inodes(root, -1, true);
6889 if (ret > 0)
6890 ret = 0;
6891 return ret;
6892 @@ -10103,7 +10106,7 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int nr)
6893 &fs_info->delalloc_roots);
6894 spin_unlock(&fs_info->delalloc_root_lock);
6895
6896 - ret = start_delalloc_inodes(root, nr);
6897 + ret = start_delalloc_inodes(root, nr, false);
6898 btrfs_put_fs_root(root);
6899 if (ret < 0)
6900 goto out;
6901 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
6902 index c9152155fcbf..8bf9cce11213 100644
6903 --- a/fs/btrfs/ioctl.c
6904 +++ b/fs/btrfs/ioctl.c
6905 @@ -778,7 +778,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
6906 wait_event(root->subv_writers->wait,
6907 percpu_counter_sum(&root->subv_writers->counter) == 0);
6908
6909 - ret = btrfs_start_delalloc_inodes(root);
6910 + ret = btrfs_start_delalloc_snapshot(root);
6911 if (ret)
6912 goto dec_and_free;
6913
6914 diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
6915 index 0ee1cd4b56fb..285f64f2de5f 100644
6916 --- a/fs/btrfs/volumes.c
6917 +++ b/fs/btrfs/volumes.c
6918 @@ -850,6 +850,35 @@ static noinline struct btrfs_device *device_list_add(const char *path,
6919 return ERR_PTR(-EEXIST);
6920 }
6921
6922 + /*
6923 + * We are going to replace the device path for a given devid,
6924 + * make sure it's the same device if the device is mounted
6925 + */
6926 + if (device->bdev) {
6927 + struct block_device *path_bdev;
6928 +
6929 + path_bdev = lookup_bdev(path);
6930 + if (IS_ERR(path_bdev)) {
6931 + mutex_unlock(&fs_devices->device_list_mutex);
6932 + return ERR_CAST(path_bdev);
6933 + }
6934 +
6935 + if (device->bdev != path_bdev) {
6936 + bdput(path_bdev);
6937 + mutex_unlock(&fs_devices->device_list_mutex);
6938 + btrfs_warn_in_rcu(device->fs_info,
6939 + "duplicate device fsid:devid for %pU:%llu old:%s new:%s",
6940 + disk_super->fsid, devid,
6941 + rcu_str_deref(device->name), path);
6942 + return ERR_PTR(-EEXIST);
6943 + }
6944 + bdput(path_bdev);
6945 + btrfs_info_in_rcu(device->fs_info,
6946 + "device fsid %pU devid %llu moved old:%s new:%s",
6947 + disk_super->fsid, devid,
6948 + rcu_str_deref(device->name), path);
6949 + }
6950 +
6951 name = rcu_string_strdup(path, GFP_NOFS);
6952 if (!name) {
6953 mutex_unlock(&fs_devices->device_list_mutex);
6954 diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
6955 index e169e1a5fd35..3925a7bfc74d 100644
6956 --- a/fs/cifs/readdir.c
6957 +++ b/fs/cifs/readdir.c
6958 @@ -655,7 +655,14 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
6959 /* scan and find it */
6960 int i;
6961 char *cur_ent;
6962 - char *end_of_smb = cfile->srch_inf.ntwrk_buf_start +
6963 + char *end_of_smb;
6964 +
6965 + if (cfile->srch_inf.ntwrk_buf_start == NULL) {
6966 + cifs_dbg(VFS, "ntwrk_buf_start is NULL during readdir\n");
6967 + return -EIO;
6968 + }
6969 +
6970 + end_of_smb = cfile->srch_inf.ntwrk_buf_start +
6971 server->ops->calc_smb_size(
6972 cfile->srch_inf.ntwrk_buf_start,
6973 server);
6974 diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c
6975 index 562fa8c3edff..47ee66d70109 100644
6976 --- a/fs/dlm/ast.c
6977 +++ b/fs/dlm/ast.c
6978 @@ -292,6 +292,8 @@ void dlm_callback_suspend(struct dlm_ls *ls)
6979 flush_workqueue(ls->ls_callback_wq);
6980 }
6981
6982 +#define MAX_CB_QUEUE 25
6983 +
6984 void dlm_callback_resume(struct dlm_ls *ls)
6985 {
6986 struct dlm_lkb *lkb, *safe;
6987 @@ -302,15 +304,23 @@ void dlm_callback_resume(struct dlm_ls *ls)
6988 if (!ls->ls_callback_wq)
6989 return;
6990
6991 +more:
6992 mutex_lock(&ls->ls_cb_mutex);
6993 list_for_each_entry_safe(lkb, safe, &ls->ls_cb_delay, lkb_cb_list) {
6994 list_del_init(&lkb->lkb_cb_list);
6995 queue_work(ls->ls_callback_wq, &lkb->lkb_cb_work);
6996 count++;
6997 + if (count == MAX_CB_QUEUE)
6998 + break;
6999 }
7000 mutex_unlock(&ls->ls_cb_mutex);
7001
7002 if (count)
7003 log_rinfo(ls, "dlm_callback_resume %d", count);
7004 + if (count == MAX_CB_QUEUE) {
7005 + count = 0;
7006 + cond_resched();
7007 + goto more;
7008 + }
7009 }
7010
7011 diff --git a/fs/eventpoll.c b/fs/eventpoll.c
7012 index 42bbe6824b4b..58f48ea0db23 100644
7013 --- a/fs/eventpoll.c
7014 +++ b/fs/eventpoll.c
7015 @@ -1154,7 +1154,7 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v
7016 * semantics). All the events that happen during that period of time are
7017 * chained in ep->ovflist and requeued later on.
7018 */
7019 - if (unlikely(ep->ovflist != EP_UNACTIVE_PTR)) {
7020 + if (ep->ovflist != EP_UNACTIVE_PTR) {
7021 if (epi->next == EP_UNACTIVE_PTR) {
7022 epi->next = ep->ovflist;
7023 ep->ovflist = epi;
7024 diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
7025 index 111824199a88..b9fe937a3c70 100644
7026 --- a/fs/f2fs/acl.c
7027 +++ b/fs/f2fs/acl.c
7028 @@ -352,12 +352,14 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,
7029 return PTR_ERR(p);
7030
7031 clone = f2fs_acl_clone(p, GFP_NOFS);
7032 - if (!clone)
7033 - goto no_mem;
7034 + if (!clone) {
7035 + ret = -ENOMEM;
7036 + goto release_acl;
7037 + }
7038
7039 ret = f2fs_acl_create_masq(clone, mode);
7040 if (ret < 0)
7041 - goto no_mem_clone;
7042 + goto release_clone;
7043
7044 if (ret == 0)
7045 posix_acl_release(clone);
7046 @@ -371,11 +373,11 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,
7047
7048 return 0;
7049
7050 -no_mem_clone:
7051 +release_clone:
7052 posix_acl_release(clone);
7053 -no_mem:
7054 +release_acl:
7055 posix_acl_release(p);
7056 - return -ENOMEM;
7057 + return ret;
7058 }
7059
7060 int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
7061 diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
7062 index 11f28342f641..08314fb42652 100644
7063 --- a/fs/f2fs/data.c
7064 +++ b/fs/f2fs/data.c
7065 @@ -2259,6 +2259,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,
7066 bool locked = false;
7067 struct extent_info ei = {0,0,0};
7068 int err = 0;
7069 + int flag;
7070
7071 /*
7072 * we already allocated all the blocks, so we don't need to get
7073 @@ -2268,9 +2269,15 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,
7074 !is_inode_flag_set(inode, FI_NO_PREALLOC))
7075 return 0;
7076
7077 + /* f2fs_lock_op avoids race between write CP and convert_inline_page */
7078 + if (f2fs_has_inline_data(inode) && pos + len > MAX_INLINE_DATA(inode))
7079 + flag = F2FS_GET_BLOCK_DEFAULT;
7080 + else
7081 + flag = F2FS_GET_BLOCK_PRE_AIO;
7082 +
7083 if (f2fs_has_inline_data(inode) ||
7084 (pos & PAGE_MASK) >= i_size_read(inode)) {
7085 - __do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, true);
7086 + __do_map_lock(sbi, flag, true);
7087 locked = true;
7088 }
7089 restart:
7090 @@ -2308,6 +2315,7 @@ restart:
7091 f2fs_put_dnode(&dn);
7092 __do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO,
7093 true);
7094 + WARN_ON(flag != F2FS_GET_BLOCK_PRE_AIO);
7095 locked = true;
7096 goto restart;
7097 }
7098 @@ -2321,7 +2329,7 @@ out:
7099 f2fs_put_dnode(&dn);
7100 unlock_out:
7101 if (locked)
7102 - __do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false);
7103 + __do_map_lock(sbi, flag, false);
7104 return err;
7105 }
7106
7107 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
7108 index ecb735142276..42aef5c94927 100644
7109 --- a/fs/f2fs/f2fs.h
7110 +++ b/fs/f2fs/f2fs.h
7111 @@ -2613,10 +2613,19 @@ static inline bool is_dot_dotdot(const struct qstr *str)
7112
7113 static inline bool f2fs_may_extent_tree(struct inode *inode)
7114 {
7115 - if (!test_opt(F2FS_I_SB(inode), EXTENT_CACHE) ||
7116 + struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
7117 +
7118 + if (!test_opt(sbi, EXTENT_CACHE) ||
7119 is_inode_flag_set(inode, FI_NO_EXTENT))
7120 return false;
7121
7122 + /*
7123 + * for recovered files during mount do not create extents
7124 + * if shrinker is not registered.
7125 + */
7126 + if (list_empty(&sbi->s_list))
7127 + return false;
7128 +
7129 return S_ISREG(inode->i_mode);
7130 }
7131
7132 diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
7133 index 5474aaa274b9..fd36aa6569dc 100644
7134 --- a/fs/f2fs/file.c
7135 +++ b/fs/f2fs/file.c
7136 @@ -220,6 +220,9 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
7137
7138 trace_f2fs_sync_file_enter(inode);
7139
7140 + if (S_ISDIR(inode->i_mode))
7141 + goto go_write;
7142 +
7143 /* if fdatasync is triggered, let's do in-place-update */
7144 if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)
7145 set_inode_flag(inode, FI_NEED_IPU);
7146 diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
7147 index 36cfd816c160..29042e6d5126 100644
7148 --- a/fs/f2fs/shrinker.c
7149 +++ b/fs/f2fs/shrinker.c
7150 @@ -138,6 +138,6 @@ void f2fs_leave_shrinker(struct f2fs_sb_info *sbi)
7151 f2fs_shrink_extent_tree(sbi, __count_extent_cache(sbi));
7152
7153 spin_lock(&f2fs_list_lock);
7154 - list_del(&sbi->s_list);
7155 + list_del_init(&sbi->s_list);
7156 spin_unlock(&f2fs_list_lock);
7157 }
7158 diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
7159 index 338138b34993..c9639ef0e8d5 100644
7160 --- a/fs/f2fs/super.c
7161 +++ b/fs/f2fs/super.c
7162 @@ -1039,9 +1039,6 @@ static void f2fs_put_super(struct super_block *sb)
7163 f2fs_write_checkpoint(sbi, &cpc);
7164 }
7165
7166 - /* f2fs_write_checkpoint can update stat informaion */
7167 - f2fs_destroy_stats(sbi);
7168 -
7169 /*
7170 * normally superblock is clean, so we need to release this.
7171 * In addition, EIO will skip do checkpoint, we need this as well.
7172 @@ -1061,6 +1058,12 @@ static void f2fs_put_super(struct super_block *sb)
7173 iput(sbi->node_inode);
7174 iput(sbi->meta_inode);
7175
7176 + /*
7177 + * iput() can update stat information, if f2fs_write_checkpoint()
7178 + * above failed with error.
7179 + */
7180 + f2fs_destroy_stats(sbi);
7181 +
7182 /* destroy f2fs internal modules */
7183 f2fs_destroy_node_manager(sbi);
7184 f2fs_destroy_segment_manager(sbi);
7185 @@ -2980,30 +2983,30 @@ try_onemore:
7186
7187 f2fs_build_gc_manager(sbi);
7188
7189 + err = f2fs_build_stats(sbi);
7190 + if (err)
7191 + goto free_nm;
7192 +
7193 /* get an inode for node space */
7194 sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi));
7195 if (IS_ERR(sbi->node_inode)) {
7196 f2fs_msg(sb, KERN_ERR, "Failed to read node inode");
7197 err = PTR_ERR(sbi->node_inode);
7198 - goto free_nm;
7199 + goto free_stats;
7200 }
7201
7202 - err = f2fs_build_stats(sbi);
7203 - if (err)
7204 - goto free_node_inode;
7205 -
7206 /* read root inode and dentry */
7207 root = f2fs_iget(sb, F2FS_ROOT_INO(sbi));
7208 if (IS_ERR(root)) {
7209 f2fs_msg(sb, KERN_ERR, "Failed to read root inode");
7210 err = PTR_ERR(root);
7211 - goto free_stats;
7212 + goto free_node_inode;
7213 }
7214 if (!S_ISDIR(root->i_mode) || !root->i_blocks ||
7215 !root->i_size || !root->i_nlink) {
7216 iput(root);
7217 err = -EINVAL;
7218 - goto free_stats;
7219 + goto free_node_inode;
7220 }
7221
7222 sb->s_root = d_make_root(root); /* allocate root dentry */
7223 @@ -3121,12 +3124,12 @@ free_sysfs:
7224 free_root_inode:
7225 dput(sb->s_root);
7226 sb->s_root = NULL;
7227 -free_stats:
7228 - f2fs_destroy_stats(sbi);
7229 free_node_inode:
7230 f2fs_release_ino_entry(sbi, true);
7231 truncate_inode_pages_final(NODE_MAPPING(sbi));
7232 iput(sbi->node_inode);
7233 +free_stats:
7234 + f2fs_destroy_stats(sbi);
7235 free_nm:
7236 f2fs_destroy_node_manager(sbi);
7237 free_sm:
7238 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
7239 index bf0da0382c9e..baaed4d05b22 100644
7240 --- a/fs/fuse/dev.c
7241 +++ b/fs/fuse/dev.c
7242 @@ -1698,7 +1698,6 @@ static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode,
7243 req->in.h.nodeid = outarg->nodeid;
7244 req->in.numargs = 2;
7245 req->in.argpages = 1;
7246 - req->page_descs[0].offset = offset;
7247 req->end = fuse_retrieve_end;
7248
7249 index = outarg->offset >> PAGE_SHIFT;
7250 @@ -1713,6 +1712,7 @@ static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode,
7251
7252 this_num = min_t(unsigned, num, PAGE_SIZE - offset);
7253 req->pages[req->num_pages] = page;
7254 + req->page_descs[req->num_pages].offset = offset;
7255 req->page_descs[req->num_pages].length = this_num;
7256 req->num_pages++;
7257
7258 @@ -2032,8 +2032,10 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe,
7259
7260 ret = fuse_dev_do_write(fud, &cs, len);
7261
7262 + pipe_lock(pipe);
7263 for (idx = 0; idx < nbuf; idx++)
7264 pipe_buf_release(pipe, &bufs[idx]);
7265 + pipe_unlock(pipe);
7266
7267 out:
7268 kvfree(bufs);
7269 diff --git a/fs/fuse/file.c b/fs/fuse/file.c
7270 index fbd6978479cb..bd500c3b7858 100644
7271 --- a/fs/fuse/file.c
7272 +++ b/fs/fuse/file.c
7273 @@ -1778,7 +1778,7 @@ static bool fuse_writepage_in_flight(struct fuse_req *new_req,
7274 spin_unlock(&fc->lock);
7275
7276 dec_wb_stat(&bdi->wb, WB_WRITEBACK);
7277 - dec_node_page_state(page, NR_WRITEBACK_TEMP);
7278 + dec_node_page_state(new_req->pages[0], NR_WRITEBACK_TEMP);
7279 wb_writeout_inc(&bdi->wb);
7280 fuse_writepage_free(fc, new_req);
7281 fuse_request_free(new_req);
7282 diff --git a/fs/nfs/super.c b/fs/nfs/super.c
7283 index ac4b2f005778..5ef2c71348bd 100644
7284 --- a/fs/nfs/super.c
7285 +++ b/fs/nfs/super.c
7286 @@ -2409,8 +2409,7 @@ static int nfs_compare_mount_options(const struct super_block *s, const struct n
7287 goto Ebusy;
7288 if (a->acdirmax != b->acdirmax)
7289 goto Ebusy;
7290 - if (b->auth_info.flavor_len > 0 &&
7291 - clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor)
7292 + if (clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor)
7293 goto Ebusy;
7294 return 1;
7295 Ebusy:
7296 diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
7297 index 7fb9f7c667b1..899174c7a8ae 100644
7298 --- a/fs/nfsd/nfsctl.c
7299 +++ b/fs/nfsd/nfsctl.c
7300 @@ -1126,6 +1126,8 @@ static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size)
7301 case 'Y':
7302 case 'y':
7303 case '1':
7304 + if (nn->nfsd_serv)
7305 + return -EBUSY;
7306 nfsd4_end_grace(nn);
7307 break;
7308 default:
7309 diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
7310 index 99ee093182cb..cc9b32b9db7c 100644
7311 --- a/fs/ocfs2/Makefile
7312 +++ b/fs/ocfs2/Makefile
7313 @@ -1,5 +1,5 @@
7314 # SPDX-License-Identifier: GPL-2.0
7315 -ccflags-y := -Ifs/ocfs2
7316 +ccflags-y := -I$(src)
7317
7318 obj-$(CONFIG_OCFS2_FS) += \
7319 ocfs2.o \
7320 diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
7321 index 1d098c3c00e0..9f8250df99f1 100644
7322 --- a/fs/ocfs2/buffer_head_io.c
7323 +++ b/fs/ocfs2/buffer_head_io.c
7324 @@ -152,7 +152,6 @@ int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
7325 #endif
7326 }
7327
7328 - clear_buffer_uptodate(bh);
7329 get_bh(bh); /* for end_buffer_read_sync() */
7330 bh->b_end_io = end_buffer_read_sync;
7331 submit_bh(REQ_OP_READ, 0, bh);
7332 @@ -306,7 +305,6 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
7333 continue;
7334 }
7335
7336 - clear_buffer_uptodate(bh);
7337 get_bh(bh); /* for end_buffer_read_sync() */
7338 if (validate)
7339 set_buffer_needs_validate(bh);
7340 diff --git a/fs/ocfs2/dlm/Makefile b/fs/ocfs2/dlm/Makefile
7341 index bd1aab1f49a4..ef2854422a6e 100644
7342 --- a/fs/ocfs2/dlm/Makefile
7343 +++ b/fs/ocfs2/dlm/Makefile
7344 @@ -1,4 +1,4 @@
7345 -ccflags-y := -Ifs/ocfs2
7346 +ccflags-y := -I$(src)/..
7347
7348 obj-$(CONFIG_OCFS2_FS_O2CB) += ocfs2_dlm.o
7349
7350 diff --git a/fs/ocfs2/dlmfs/Makefile b/fs/ocfs2/dlmfs/Makefile
7351 index eed3db8c5b49..33431a0296a3 100644
7352 --- a/fs/ocfs2/dlmfs/Makefile
7353 +++ b/fs/ocfs2/dlmfs/Makefile
7354 @@ -1,4 +1,4 @@
7355 -ccflags-y := -Ifs/ocfs2
7356 +ccflags-y := -I$(src)/..
7357
7358 obj-$(CONFIG_OCFS2_FS) += ocfs2_dlmfs.o
7359
7360 diff --git a/fs/udf/inode.c b/fs/udf/inode.c
7361 index 5df554a9f9c9..ae796e10f68b 100644
7362 --- a/fs/udf/inode.c
7363 +++ b/fs/udf/inode.c
7364 @@ -1357,6 +1357,12 @@ reread:
7365
7366 iinfo->i_alloc_type = le16_to_cpu(fe->icbTag.flags) &
7367 ICBTAG_FLAG_AD_MASK;
7368 + if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_SHORT &&
7369 + iinfo->i_alloc_type != ICBTAG_FLAG_AD_LONG &&
7370 + iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
7371 + ret = -EIO;
7372 + goto out;
7373 + }
7374 iinfo->i_unique = 0;
7375 iinfo->i_lenEAttr = 0;
7376 iinfo->i_lenExtents = 0;
7377 diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
7378 index 6fc5425b1474..2652d00842d6 100644
7379 --- a/fs/xfs/libxfs/xfs_attr_leaf.c
7380 +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
7381 @@ -243,7 +243,7 @@ xfs_attr3_leaf_verify(
7382 struct xfs_mount *mp = bp->b_target->bt_mount;
7383 struct xfs_attr_leafblock *leaf = bp->b_addr;
7384 struct xfs_attr_leaf_entry *entries;
7385 - uint16_t end;
7386 + uint32_t end; /* must be 32bit - see below */
7387 int i;
7388
7389 xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &ichdr, leaf);
7390 @@ -293,6 +293,11 @@ xfs_attr3_leaf_verify(
7391 /*
7392 * Quickly check the freemap information. Attribute data has to be
7393 * aligned to 4-byte boundaries, and likewise for the free space.
7394 + *
7395 + * Note that for 64k block size filesystems, the freemap entries cannot
7396 + * overflow as they are only be16 fields. However, when checking end
7397 + * pointer of the freemap, we have to be careful to detect overflows and
7398 + * so use uint32_t for those checks.
7399 */
7400 for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; i++) {
7401 if (ichdr.freemap[i].base > mp->m_attr_geo->blksize)
7402 @@ -303,7 +308,9 @@ xfs_attr3_leaf_verify(
7403 return __this_address;
7404 if (ichdr.freemap[i].size & 0x3)
7405 return __this_address;
7406 - end = ichdr.freemap[i].base + ichdr.freemap[i].size;
7407 +
7408 + /* be care of 16 bit overflows here */
7409 + end = (uint32_t)ichdr.freemap[i].base + ichdr.freemap[i].size;
7410 if (end < ichdr.freemap[i].base)
7411 return __this_address;
7412 if (end > mp->m_attr_geo->blksize)
7413 diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
7414 index a47670332326..3a496ffe6551 100644
7415 --- a/fs/xfs/libxfs/xfs_bmap.c
7416 +++ b/fs/xfs/libxfs/xfs_bmap.c
7417 @@ -1683,10 +1683,13 @@ xfs_bmap_add_extent_delay_real(
7418 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
7419 /*
7420 * Filling in all of a previously delayed allocation extent.
7421 - * The right neighbor is contiguous, the left is not.
7422 + * The right neighbor is contiguous, the left is not. Take care
7423 + * with delay -> unwritten extent allocation here because the
7424 + * delalloc record we are overwriting is always written.
7425 */
7426 PREV.br_startblock = new->br_startblock;
7427 PREV.br_blockcount += RIGHT.br_blockcount;
7428 + PREV.br_state = new->br_state;
7429
7430 xfs_iext_next(ifp, &bma->icur);
7431 xfs_iext_remove(bma->ip, &bma->icur, state);
7432 diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
7433 index 34c6d7bd4d18..bbdae2b4559f 100644
7434 --- a/fs/xfs/libxfs/xfs_btree.c
7435 +++ b/fs/xfs/libxfs/xfs_btree.c
7436 @@ -330,7 +330,7 @@ xfs_btree_sblock_verify_crc(
7437
7438 if (xfs_sb_version_hascrc(&mp->m_sb)) {
7439 if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.s.bb_lsn)))
7440 - return __this_address;
7441 + return false;
7442 return xfs_buf_verify_cksum(bp, XFS_BTREE_SBLOCK_CRC_OFF);
7443 }
7444
7445 diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
7446 index 49f5f5896a43..b697866946d2 100644
7447 --- a/fs/xfs/xfs_aops.c
7448 +++ b/fs/xfs/xfs_aops.c
7449 @@ -449,6 +449,7 @@ xfs_map_blocks(
7450 }
7451
7452 wpc->imap = imap;
7453 + xfs_trim_extent_eof(&wpc->imap, ip);
7454 trace_xfs_map_blocks_found(ip, offset, count, wpc->io_type, &imap);
7455 return 0;
7456 allocate_blocks:
7457 @@ -459,6 +460,7 @@ allocate_blocks:
7458 ASSERT(whichfork == XFS_COW_FORK || cow_fsb == NULLFILEOFF ||
7459 imap.br_startoff + imap.br_blockcount <= cow_fsb);
7460 wpc->imap = imap;
7461 + xfs_trim_extent_eof(&wpc->imap, ip);
7462 trace_xfs_map_blocks_alloc(ip, offset, count, wpc->io_type, &imap);
7463 return 0;
7464 }
7465 diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
7466 index 6de8d90041ff..211b06e4702e 100644
7467 --- a/fs/xfs/xfs_bmap_util.c
7468 +++ b/fs/xfs/xfs_bmap_util.c
7469 @@ -1175,9 +1175,9 @@ xfs_free_file_space(
7470 * page could be mmap'd and iomap_zero_range doesn't do that for us.
7471 * Writeback of the eof page will do this, albeit clumsily.
7472 */
7473 - if (offset + len >= XFS_ISIZE(ip) && ((offset + len) & PAGE_MASK)) {
7474 + if (offset + len >= XFS_ISIZE(ip) && offset_in_page(offset + len) > 0) {
7475 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
7476 - (offset + len) & ~PAGE_MASK, LLONG_MAX);
7477 + round_down(offset + len, PAGE_SIZE), LLONG_MAX);
7478 }
7479
7480 return error;
7481 @@ -1824,6 +1824,12 @@ xfs_swap_extents(
7482 if (error)
7483 goto out_unlock;
7484
7485 + if (xfs_inode_has_cow_data(tip)) {
7486 + error = xfs_reflink_cancel_cow_range(tip, 0, NULLFILEOFF, true);
7487 + if (error)
7488 + return error;
7489 + }
7490 +
7491 /*
7492 * Extent "swapping" with rmap requires a permanent reservation and
7493 * a block reservation because it's really just a remap operation
7494 diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
7495 index 12d8455bfbb2..010db5f8fb00 100644
7496 --- a/fs/xfs/xfs_buf_item.c
7497 +++ b/fs/xfs/xfs_buf_item.c
7498 @@ -1233,9 +1233,23 @@ xfs_buf_iodone(
7499 }
7500
7501 /*
7502 - * Requeue a failed buffer for writeback
7503 + * Requeue a failed buffer for writeback.
7504 *
7505 - * Return true if the buffer has been re-queued properly, false otherwise
7506 + * We clear the log item failed state here as well, but we have to be careful
7507 + * about reference counts because the only active reference counts on the buffer
7508 + * may be the failed log items. Hence if we clear the log item failed state
7509 + * before queuing the buffer for IO we can release all active references to
7510 + * the buffer and free it, leading to use after free problems in
7511 + * xfs_buf_delwri_queue. It makes no difference to the buffer or log items which
7512 + * order we process them in - the buffer is locked, and we own the buffer list
7513 + * so nothing on them is going to change while we are performing this action.
7514 + *
7515 + * Hence we can safely queue the buffer for IO before we clear the failed log
7516 + * item state, therefore always having an active reference to the buffer and
7517 + * avoiding the transient zero-reference state that leads to use-after-free.
7518 + *
7519 + * Return true if the buffer was added to the buffer list, false if it was
7520 + * already on the buffer list.
7521 */
7522 bool
7523 xfs_buf_resubmit_failed_buffers(
7524 @@ -1243,16 +1257,16 @@ xfs_buf_resubmit_failed_buffers(
7525 struct list_head *buffer_list)
7526 {
7527 struct xfs_log_item *lip;
7528 + bool ret;
7529 +
7530 + ret = xfs_buf_delwri_queue(bp, buffer_list);
7531
7532 /*
7533 - * Clear XFS_LI_FAILED flag from all items before resubmit
7534 - *
7535 - * XFS_LI_FAILED set/clear is protected by ail_lock, caller this
7536 + * XFS_LI_FAILED set/clear is protected by ail_lock, caller of this
7537 * function already have it acquired
7538 */
7539 list_for_each_entry(lip, &bp->b_li_list, li_bio_list)
7540 xfs_clear_li_failed(lip);
7541
7542 - /* Add this buffer back to the delayed write list */
7543 - return xfs_buf_delwri_queue(bp, buffer_list);
7544 + return ret;
7545 }
7546 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
7547 index 0ef5ece5634c..bad90479ade2 100644
7548 --- a/fs/xfs/xfs_ioctl.c
7549 +++ b/fs/xfs/xfs_ioctl.c
7550 @@ -1616,7 +1616,7 @@ xfs_ioc_getbmap(
7551 error = 0;
7552 out_free_buf:
7553 kmem_free(buf);
7554 - return 0;
7555 + return error;
7556 }
7557
7558 struct getfsmap_info {
7559 diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c
7560 index 73a1d77ec187..3091e4bc04ef 100644
7561 --- a/fs/xfs/xfs_qm_bhv.c
7562 +++ b/fs/xfs/xfs_qm_bhv.c
7563 @@ -40,7 +40,7 @@ xfs_fill_statvfs_from_dquot(
7564 statp->f_files = limit;
7565 statp->f_ffree =
7566 (statp->f_files > dqp->q_res_icount) ?
7567 - (statp->f_ffree - dqp->q_res_icount) : 0;
7568 + (statp->f_files - dqp->q_res_icount) : 0;
7569 }
7570 }
7571
7572 diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
7573 index 42ea7bab9144..7088f44c0c59 100644
7574 --- a/fs/xfs/xfs_reflink.c
7575 +++ b/fs/xfs/xfs_reflink.c
7576 @@ -302,6 +302,7 @@ xfs_reflink_reserve_cow(
7577 if (error)
7578 return error;
7579
7580 + xfs_trim_extent(imap, got.br_startoff, got.br_blockcount);
7581 trace_xfs_reflink_cow_alloc(ip, &got);
7582 return 0;
7583 }
7584 diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
7585 index 4e4423153071..740ac9674848 100644
7586 --- a/fs/xfs/xfs_stats.c
7587 +++ b/fs/xfs/xfs_stats.c
7588 @@ -119,7 +119,7 @@ static int xqmstat_proc_show(struct seq_file *m, void *v)
7589 int j;
7590
7591 seq_printf(m, "qm");
7592 - for (j = XFSSTAT_END_IBT_V2; j < XFSSTAT_END_XQMSTAT; j++)
7593 + for (j = XFSSTAT_END_REFCOUNT; j < XFSSTAT_END_XQMSTAT; j++)
7594 seq_printf(m, " %u", counter_val(xfsstats.xs_stats, j));
7595 seq_putc(m, '\n');
7596 return 0;
7597 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
7598 index 218df7f4d3e1..5041357d0297 100644
7599 --- a/include/linux/cpu.h
7600 +++ b/include/linux/cpu.h
7601 @@ -180,12 +180,10 @@ enum cpuhp_smt_control {
7602 #if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
7603 extern enum cpuhp_smt_control cpu_smt_control;
7604 extern void cpu_smt_disable(bool force);
7605 -extern void cpu_smt_check_topology_early(void);
7606 extern void cpu_smt_check_topology(void);
7607 #else
7608 # define cpu_smt_control (CPU_SMT_ENABLED)
7609 static inline void cpu_smt_disable(bool force) { }
7610 -static inline void cpu_smt_check_topology_early(void) { }
7611 static inline void cpu_smt_check_topology(void) { }
7612 #endif
7613
7614 diff --git a/include/linux/genl_magic_struct.h b/include/linux/genl_magic_struct.h
7615 index 5972e4969197..eeae59d3ceb7 100644
7616 --- a/include/linux/genl_magic_struct.h
7617 +++ b/include/linux/genl_magic_struct.h
7618 @@ -191,6 +191,7 @@ static inline void ct_assert_unique_operations(void)
7619 {
7620 switch (0) {
7621 #include GENL_MAGIC_INCLUDE_FILE
7622 + case 0:
7623 ;
7624 }
7625 }
7626 @@ -209,6 +210,7 @@ static inline void ct_assert_unique_top_level_attributes(void)
7627 {
7628 switch (0) {
7629 #include GENL_MAGIC_INCLUDE_FILE
7630 + case 0:
7631 ;
7632 }
7633 }
7634 @@ -218,7 +220,8 @@ static inline void ct_assert_unique_top_level_attributes(void)
7635 static inline void ct_assert_unique_ ## s_name ## _attributes(void) \
7636 { \
7637 switch (0) { \
7638 - s_fields \
7639 + s_fields \
7640 + case 0: \
7641 ; \
7642 } \
7643 }
7644 diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
7645 index 21ddbe440030..acc4279ad5e3 100644
7646 --- a/include/linux/gpio/consumer.h
7647 +++ b/include/linux/gpio/consumer.h
7648 @@ -142,7 +142,7 @@ int gpiod_is_active_low(const struct gpio_desc *desc);
7649 int gpiod_cansleep(const struct gpio_desc *desc);
7650
7651 int gpiod_to_irq(const struct gpio_desc *desc);
7652 -void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name);
7653 +int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name);
7654
7655 /* Convert between the old gpio_ and new gpiod_ interfaces */
7656 struct gpio_desc *gpio_to_desc(unsigned gpio);
7657 @@ -465,10 +465,12 @@ static inline int gpiod_to_irq(const struct gpio_desc *desc)
7658 return -EINVAL;
7659 }
7660
7661 -static inline void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name)
7662 +static inline int gpiod_set_consumer_name(struct gpio_desc *desc,
7663 + const char *name)
7664 {
7665 /* GPIO can never have been requested */
7666 WARN_ON(1);
7667 + return -EINVAL;
7668 }
7669
7670 static inline struct gpio_desc *gpio_to_desc(unsigned gpio)
7671 diff --git a/include/linux/hid-debug.h b/include/linux/hid-debug.h
7672 index 8663f216c563..2d6100edf204 100644
7673 --- a/include/linux/hid-debug.h
7674 +++ b/include/linux/hid-debug.h
7675 @@ -24,7 +24,10 @@
7676
7677 #ifdef CONFIG_DEBUG_FS
7678
7679 +#include <linux/kfifo.h>
7680 +
7681 #define HID_DEBUG_BUFSIZE 512
7682 +#define HID_DEBUG_FIFOSIZE 512
7683
7684 void hid_dump_input(struct hid_device *, struct hid_usage *, __s32);
7685 void hid_dump_report(struct hid_device *, int , u8 *, int);
7686 @@ -37,11 +40,8 @@ void hid_debug_init(void);
7687 void hid_debug_exit(void);
7688 void hid_debug_event(struct hid_device *, char *);
7689
7690 -
7691 struct hid_debug_list {
7692 - char *hid_debug_buf;
7693 - int head;
7694 - int tail;
7695 + DECLARE_KFIFO_PTR(hid_debug_fifo, char);
7696 struct fasync_struct *fasync;
7697 struct hid_device *hdev;
7698 struct list_head node;
7699 @@ -64,4 +64,3 @@ struct hid_debug_list {
7700 #endif
7701
7702 #endif
7703 -
7704 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
7705 index c926698040e0..a03d5e264e5e 100644
7706 --- a/include/linux/kvm_host.h
7707 +++ b/include/linux/kvm_host.h
7708 @@ -694,7 +694,8 @@ int kvm_write_guest(struct kvm *kvm, gpa_t gpa, const void *data,
7709 int kvm_write_guest_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
7710 void *data, unsigned long len);
7711 int kvm_write_guest_offset_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
7712 - void *data, int offset, unsigned long len);
7713 + void *data, unsigned int offset,
7714 + unsigned long len);
7715 int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
7716 gpa_t gpa, unsigned long len);
7717 int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);
7718 diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
7719 index 88a041b73abf..bbcfe2e5fd91 100644
7720 --- a/include/linux/mlx5/driver.h
7721 +++ b/include/linux/mlx5/driver.h
7722 @@ -1321,7 +1321,7 @@ enum {
7723 static inline const struct cpumask *
7724 mlx5_get_vector_affinity_hint(struct mlx5_core_dev *dev, int vector)
7725 {
7726 - return dev->priv.irq_info[vector].mask;
7727 + return dev->priv.irq_info[vector + MLX5_EQ_VEC_COMP_BASE].mask;
7728 }
7729
7730 #endif /* MLX5_DRIVER_H */
7731 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
7732 index ea8c93bbb0e0..e87f2d5b3cc6 100644
7733 --- a/include/sound/compress_driver.h
7734 +++ b/include/sound/compress_driver.h
7735 @@ -171,7 +171,11 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream)
7736 if (snd_BUG_ON(!stream))
7737 return;
7738
7739 - stream->runtime->state = SNDRV_PCM_STATE_SETUP;
7740 + if (stream->direction == SND_COMPRESS_PLAYBACK)
7741 + stream->runtime->state = SNDRV_PCM_STATE_SETUP;
7742 + else
7743 + stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
7744 +
7745 wake_up(&stream->runtime->sleep);
7746 }
7747
7748 diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
7749 index 1aa517908561..e578c3999970 100644
7750 --- a/kernel/cgroup/cgroup.c
7751 +++ b/kernel/cgroup/cgroup.c
7752 @@ -1743,7 +1743,7 @@ static int parse_cgroup_root_flags(char *data, unsigned int *root_flags)
7753
7754 *root_flags = 0;
7755
7756 - if (!data)
7757 + if (!data || *data == '\0')
7758 return 0;
7759
7760 while ((token = strsep(&data, ",")) != NULL) {
7761 diff --git a/kernel/cpu.c b/kernel/cpu.c
7762 index 1699ff68c412..56f657adcf03 100644
7763 --- a/kernel/cpu.c
7764 +++ b/kernel/cpu.c
7765 @@ -355,9 +355,6 @@ void __weak arch_smt_update(void) { }
7766
7767 #ifdef CONFIG_HOTPLUG_SMT
7768 enum cpuhp_smt_control cpu_smt_control __read_mostly = CPU_SMT_ENABLED;
7769 -EXPORT_SYMBOL_GPL(cpu_smt_control);
7770 -
7771 -static bool cpu_smt_available __read_mostly;
7772
7773 void __init cpu_smt_disable(bool force)
7774 {
7775 @@ -375,25 +372,11 @@ void __init cpu_smt_disable(bool force)
7776
7777 /*
7778 * The decision whether SMT is supported can only be done after the full
7779 - * CPU identification. Called from architecture code before non boot CPUs
7780 - * are brought up.
7781 - */
7782 -void __init cpu_smt_check_topology_early(void)
7783 -{
7784 - if (!topology_smt_supported())
7785 - cpu_smt_control = CPU_SMT_NOT_SUPPORTED;
7786 -}
7787 -
7788 -/*
7789 - * If SMT was disabled by BIOS, detect it here, after the CPUs have been
7790 - * brought online. This ensures the smt/l1tf sysfs entries are consistent
7791 - * with reality. cpu_smt_available is set to true during the bringup of non
7792 - * boot CPUs when a SMT sibling is detected. Note, this may overwrite
7793 - * cpu_smt_control's previous setting.
7794 + * CPU identification. Called from architecture code.
7795 */
7796 void __init cpu_smt_check_topology(void)
7797 {
7798 - if (!cpu_smt_available)
7799 + if (!topology_smt_supported())
7800 cpu_smt_control = CPU_SMT_NOT_SUPPORTED;
7801 }
7802
7803 @@ -406,18 +389,10 @@ early_param("nosmt", smt_cmdline_disable);
7804
7805 static inline bool cpu_smt_allowed(unsigned int cpu)
7806 {
7807 - if (topology_is_primary_thread(cpu))
7808 + if (cpu_smt_control == CPU_SMT_ENABLED)
7809 return true;
7810
7811 - /*
7812 - * If the CPU is not a 'primary' thread and the booted_once bit is
7813 - * set then the processor has SMT support. Store this information
7814 - * for the late check of SMT support in cpu_smt_check_topology().
7815 - */
7816 - if (per_cpu(cpuhp_state, cpu).booted_once)
7817 - cpu_smt_available = true;
7818 -
7819 - if (cpu_smt_control == CPU_SMT_ENABLED)
7820 + if (topology_is_primary_thread(cpu))
7821 return true;
7822
7823 /*
7824 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
7825 index 65c0f1363788..94aa9ae0007a 100644
7826 --- a/kernel/debug/debug_core.c
7827 +++ b/kernel/debug/debug_core.c
7828 @@ -535,6 +535,8 @@ return_normal:
7829 arch_kgdb_ops.correct_hw_break();
7830 if (trace_on)
7831 tracing_on();
7832 + kgdb_info[cpu].debuggerinfo = NULL;
7833 + kgdb_info[cpu].task = NULL;
7834 kgdb_info[cpu].exception_state &=
7835 ~(DCPU_WANT_MASTER | DCPU_IS_SLAVE);
7836 kgdb_info[cpu].enter_kgdb--;
7837 @@ -667,6 +669,8 @@ kgdb_restore:
7838 if (trace_on)
7839 tracing_on();
7840
7841 + kgdb_info[cpu].debuggerinfo = NULL;
7842 + kgdb_info[cpu].task = NULL;
7843 kgdb_info[cpu].exception_state &=
7844 ~(DCPU_WANT_MASTER | DCPU_IS_SLAVE);
7845 kgdb_info[cpu].enter_kgdb--;
7846 diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c
7847 index 7921ae4fca8d..7e2379aa0a1e 100644
7848 --- a/kernel/debug/kdb/kdb_bt.c
7849 +++ b/kernel/debug/kdb/kdb_bt.c
7850 @@ -186,7 +186,16 @@ kdb_bt(int argc, const char **argv)
7851 kdb_printf("btc: cpu status: ");
7852 kdb_parse("cpu\n");
7853 for_each_online_cpu(cpu) {
7854 - sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu));
7855 + void *kdb_tsk = KDB_TSK(cpu);
7856 +
7857 + /* If a CPU failed to round up we could be here */
7858 + if (!kdb_tsk) {
7859 + kdb_printf("WARNING: no task for cpu %ld\n",
7860 + cpu);
7861 + continue;
7862 + }
7863 +
7864 + sprintf(buf, "btt 0x%px\n", kdb_tsk);
7865 kdb_parse(buf);
7866 touch_nmi_watchdog();
7867 }
7868 diff --git a/kernel/debug/kdb/kdb_debugger.c b/kernel/debug/kdb/kdb_debugger.c
7869 index 15e1a7af5dd0..53a0df6e4d92 100644
7870 --- a/kernel/debug/kdb/kdb_debugger.c
7871 +++ b/kernel/debug/kdb/kdb_debugger.c
7872 @@ -118,13 +118,6 @@ int kdb_stub(struct kgdb_state *ks)
7873 kdb_bp_remove();
7874 KDB_STATE_CLEAR(DOING_SS);
7875 KDB_STATE_SET(PAGER);
7876 - /* zero out any offline cpu data */
7877 - for_each_present_cpu(i) {
7878 - if (!cpu_online(i)) {
7879 - kgdb_info[i].debuggerinfo = NULL;
7880 - kgdb_info[i].task = NULL;
7881 - }
7882 - }
7883 if (ks->err_code == DIE_OOPS || reason == KDB_REASON_OOPS) {
7884 ks->pass_exception = 1;
7885 KDB_FLAG_SET(CATASTROPHIC);
7886 diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
7887 index 5d3cf407e374..51386d9105fa 100644
7888 --- a/kernel/events/ring_buffer.c
7889 +++ b/kernel/events/ring_buffer.c
7890 @@ -724,6 +724,9 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags)
7891 size = sizeof(struct ring_buffer);
7892 size += nr_pages * sizeof(void *);
7893
7894 + if (order_base_2(size) >= MAX_ORDER)
7895 + goto fail;
7896 +
7897 rb = kzalloc(size, GFP_KERNEL);
7898 if (!rb)
7899 goto fail;
7900 diff --git a/kernel/futex.c b/kernel/futex.c
7901 index f89abca89513..d7c465fd687c 100644
7902 --- a/kernel/futex.c
7903 +++ b/kernel/futex.c
7904 @@ -2850,35 +2850,39 @@ retry_private:
7905 * and BUG when futex_unlock_pi() interleaves with this.
7906 *
7907 * Therefore acquire wait_lock while holding hb->lock, but drop the
7908 - * latter before calling rt_mutex_start_proxy_lock(). This still fully
7909 - * serializes against futex_unlock_pi() as that does the exact same
7910 - * lock handoff sequence.
7911 + * latter before calling __rt_mutex_start_proxy_lock(). This
7912 + * interleaves with futex_unlock_pi() -- which does a similar lock
7913 + * handoff -- such that the latter can observe the futex_q::pi_state
7914 + * before __rt_mutex_start_proxy_lock() is done.
7915 */
7916 raw_spin_lock_irq(&q.pi_state->pi_mutex.wait_lock);
7917 spin_unlock(q.lock_ptr);
7918 + /*
7919 + * __rt_mutex_start_proxy_lock() unconditionally enqueues the @rt_waiter
7920 + * such that futex_unlock_pi() is guaranteed to observe the waiter when
7921 + * it sees the futex_q::pi_state.
7922 + */
7923 ret = __rt_mutex_start_proxy_lock(&q.pi_state->pi_mutex, &rt_waiter, current);
7924 raw_spin_unlock_irq(&q.pi_state->pi_mutex.wait_lock);
7925
7926 if (ret) {
7927 if (ret == 1)
7928 ret = 0;
7929 -
7930 - spin_lock(q.lock_ptr);
7931 - goto no_block;
7932 + goto cleanup;
7933 }
7934
7935 -
7936 if (unlikely(to))
7937 hrtimer_start_expires(&to->timer, HRTIMER_MODE_ABS);
7938
7939 ret = rt_mutex_wait_proxy_lock(&q.pi_state->pi_mutex, to, &rt_waiter);
7940
7941 +cleanup:
7942 spin_lock(q.lock_ptr);
7943 /*
7944 - * If we failed to acquire the lock (signal/timeout), we must
7945 + * If we failed to acquire the lock (deadlock/signal/timeout), we must
7946 * first acquire the hb->lock before removing the lock from the
7947 - * rt_mutex waitqueue, such that we can keep the hb and rt_mutex
7948 - * wait lists consistent.
7949 + * rt_mutex waitqueue, such that we can keep the hb and rt_mutex wait
7950 + * lists consistent.
7951 *
7952 * In particular; it is important that futex_unlock_pi() can not
7953 * observe this inconsistency.
7954 @@ -3002,6 +3006,10 @@ retry:
7955 * there is no point where we hold neither; and therefore
7956 * wake_futex_pi() must observe a state consistent with what we
7957 * observed.
7958 + *
7959 + * In particular; this forces __rt_mutex_start_proxy() to
7960 + * complete such that we're guaranteed to observe the
7961 + * rt_waiter. Also see the WARN in wake_futex_pi().
7962 */
7963 raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);
7964 spin_unlock(&hb->lock);
7965 diff --git a/kernel/hung_task.c b/kernel/hung_task.c
7966 index b9132d1269ef..9eca2371f189 100644
7967 --- a/kernel/hung_task.c
7968 +++ b/kernel/hung_task.c
7969 @@ -33,7 +33,7 @@ int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT;
7970 * is disabled during the critical section. It also controls the size of
7971 * the RCU grace period. So it needs to be upper-bound.
7972 */
7973 -#define HUNG_TASK_BATCHING 1024
7974 +#define HUNG_TASK_LOCK_BREAK (HZ / 10)
7975
7976 /*
7977 * Zero means infinite timeout - no checking done:
7978 @@ -111,8 +111,11 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
7979
7980 trace_sched_process_hang(t);
7981
7982 - if (!sysctl_hung_task_warnings && !sysctl_hung_task_panic)
7983 - return;
7984 + if (sysctl_hung_task_panic) {
7985 + console_verbose();
7986 + hung_task_show_lock = true;
7987 + hung_task_call_panic = true;
7988 + }
7989
7990 /*
7991 * Ok, the task did not get scheduled for more than 2 minutes,
7992 @@ -134,11 +137,6 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
7993 }
7994
7995 touch_nmi_watchdog();
7996 -
7997 - if (sysctl_hung_task_panic) {
7998 - hung_task_show_lock = true;
7999 - hung_task_call_panic = true;
8000 - }
8001 }
8002
8003 /*
8004 @@ -172,7 +170,7 @@ static bool rcu_lock_break(struct task_struct *g, struct task_struct *t)
8005 static void check_hung_uninterruptible_tasks(unsigned long timeout)
8006 {
8007 int max_count = sysctl_hung_task_check_count;
8008 - int batch_count = HUNG_TASK_BATCHING;
8009 + unsigned long last_break = jiffies;
8010 struct task_struct *g, *t;
8011
8012 /*
8013 @@ -187,10 +185,10 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
8014 for_each_process_thread(g, t) {
8015 if (!max_count--)
8016 goto unlock;
8017 - if (!--batch_count) {
8018 - batch_count = HUNG_TASK_BATCHING;
8019 + if (time_after(jiffies, last_break + HUNG_TASK_LOCK_BREAK)) {
8020 if (!rcu_lock_break(g, t))
8021 goto unlock;
8022 + last_break = jiffies;
8023 }
8024 /* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */
8025 if (t->state == TASK_UNINTERRUPTIBLE)
8026 diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c
8027 index f4f29b9d90ee..e12cdf637c71 100644
8028 --- a/kernel/irq/affinity.c
8029 +++ b/kernel/irq/affinity.c
8030 @@ -117,12 +117,11 @@ static int irq_build_affinity_masks(const struct irq_affinity *affd,
8031 */
8032 if (numvecs <= nodes) {
8033 for_each_node_mask(n, nodemsk) {
8034 - cpumask_copy(masks + curvec, node_to_cpumask[n]);
8035 - if (++done == numvecs)
8036 - break;
8037 + cpumask_or(masks + curvec, masks + curvec, node_to_cpumask[n]);
8038 if (++curvec == last_affv)
8039 curvec = affd->pre_vectors;
8040 }
8041 + done = numvecs;
8042 goto out;
8043 }
8044
8045 diff --git a/kernel/kcov.c b/kernel/kcov.c
8046 index 97959d7b77e2..c2277dbdbfb1 100644
8047 --- a/kernel/kcov.c
8048 +++ b/kernel/kcov.c
8049 @@ -112,7 +112,7 @@ void notrace __sanitizer_cov_trace_pc(void)
8050 EXPORT_SYMBOL(__sanitizer_cov_trace_pc);
8051
8052 #ifdef CONFIG_KCOV_ENABLE_COMPARISONS
8053 -static void write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip)
8054 +static void notrace write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip)
8055 {
8056 struct task_struct *t;
8057 u64 *area;
8058 diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
8059 index 2823d4163a37..9562aaa2afdc 100644
8060 --- a/kernel/locking/rtmutex.c
8061 +++ b/kernel/locking/rtmutex.c
8062 @@ -1726,12 +1726,33 @@ void rt_mutex_proxy_unlock(struct rt_mutex *lock,
8063 rt_mutex_set_owner(lock, NULL);
8064 }
8065
8066 +/**
8067 + * __rt_mutex_start_proxy_lock() - Start lock acquisition for another task
8068 + * @lock: the rt_mutex to take
8069 + * @waiter: the pre-initialized rt_mutex_waiter
8070 + * @task: the task to prepare
8071 + *
8072 + * Starts the rt_mutex acquire; it enqueues the @waiter and does deadlock
8073 + * detection. It does not wait, see rt_mutex_wait_proxy_lock() for that.
8074 + *
8075 + * NOTE: does _NOT_ remove the @waiter on failure; must either call
8076 + * rt_mutex_wait_proxy_lock() or rt_mutex_cleanup_proxy_lock() after this.
8077 + *
8078 + * Returns:
8079 + * 0 - task blocked on lock
8080 + * 1 - acquired the lock for task, caller should wake it up
8081 + * <0 - error
8082 + *
8083 + * Special API call for PI-futex support.
8084 + */
8085 int __rt_mutex_start_proxy_lock(struct rt_mutex *lock,
8086 struct rt_mutex_waiter *waiter,
8087 struct task_struct *task)
8088 {
8089 int ret;
8090
8091 + lockdep_assert_held(&lock->wait_lock);
8092 +
8093 if (try_to_take_rt_mutex(lock, task, NULL))
8094 return 1;
8095
8096 @@ -1749,9 +1770,6 @@ int __rt_mutex_start_proxy_lock(struct rt_mutex *lock,
8097 ret = 0;
8098 }
8099
8100 - if (unlikely(ret))
8101 - remove_waiter(lock, waiter);
8102 -
8103 debug_rt_mutex_print_deadlock(waiter);
8104
8105 return ret;
8106 @@ -1763,12 +1781,18 @@ int __rt_mutex_start_proxy_lock(struct rt_mutex *lock,
8107 * @waiter: the pre-initialized rt_mutex_waiter
8108 * @task: the task to prepare
8109 *
8110 + * Starts the rt_mutex acquire; it enqueues the @waiter and does deadlock
8111 + * detection. It does not wait, see rt_mutex_wait_proxy_lock() for that.
8112 + *
8113 + * NOTE: unlike __rt_mutex_start_proxy_lock this _DOES_ remove the @waiter
8114 + * on failure.
8115 + *
8116 * Returns:
8117 * 0 - task blocked on lock
8118 * 1 - acquired the lock for task, caller should wake it up
8119 * <0 - error
8120 *
8121 - * Special API call for FUTEX_REQUEUE_PI support.
8122 + * Special API call for PI-futex support.
8123 */
8124 int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
8125 struct rt_mutex_waiter *waiter,
8126 @@ -1778,6 +1802,8 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
8127
8128 raw_spin_lock_irq(&lock->wait_lock);
8129 ret = __rt_mutex_start_proxy_lock(lock, waiter, task);
8130 + if (unlikely(ret))
8131 + remove_waiter(lock, waiter);
8132 raw_spin_unlock_irq(&lock->wait_lock);
8133
8134 return ret;
8135 @@ -1845,7 +1871,8 @@ int rt_mutex_wait_proxy_lock(struct rt_mutex *lock,
8136 * @lock: the rt_mutex we were woken on
8137 * @waiter: the pre-initialized rt_mutex_waiter
8138 *
8139 - * Attempt to clean up after a failed rt_mutex_wait_proxy_lock().
8140 + * Attempt to clean up after a failed __rt_mutex_start_proxy_lock() or
8141 + * rt_mutex_wait_proxy_lock().
8142 *
8143 * Unless we acquired the lock; we're still enqueued on the wait-list and can
8144 * in fact still be granted ownership until we're removed. Therefore we can
8145 diff --git a/kernel/module.c b/kernel/module.c
8146 index 6746c85511fe..38bf28b5cc20 100644
8147 --- a/kernel/module.c
8148 +++ b/kernel/module.c
8149 @@ -1207,8 +1207,10 @@ static ssize_t store_uevent(struct module_attribute *mattr,
8150 struct module_kobject *mk,
8151 const char *buffer, size_t count)
8152 {
8153 - kobject_synth_uevent(&mk->kobj, buffer, count);
8154 - return count;
8155 + int rc;
8156 +
8157 + rc = kobject_synth_uevent(&mk->kobj, buffer, count);
8158 + return rc ? rc : count;
8159 }
8160
8161 struct module_attribute module_uevent =
8162 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
8163 index 7137bc343b4a..f7c375d1e601 100644
8164 --- a/kernel/sched/fair.c
8165 +++ b/kernel/sched/fair.c
8166 @@ -5932,6 +5932,7 @@ static inline int find_idlest_cpu(struct sched_domain *sd, struct task_struct *p
8167
8168 #ifdef CONFIG_SCHED_SMT
8169 DEFINE_STATIC_KEY_FALSE(sched_smt_present);
8170 +EXPORT_SYMBOL_GPL(sched_smt_present);
8171
8172 static inline void set_idle_cores(int cpu, int val)
8173 {
8174 diff --git a/kernel/smp.c b/kernel/smp.c
8175 index d86eec5f51c1..084c8b3a2681 100644
8176 --- a/kernel/smp.c
8177 +++ b/kernel/smp.c
8178 @@ -584,8 +584,6 @@ void __init smp_init(void)
8179 num_nodes, (num_nodes > 1 ? "s" : ""),
8180 num_cpus, (num_cpus > 1 ? "s" : ""));
8181
8182 - /* Final decision about SMT support */
8183 - cpu_smt_check_topology();
8184 /* Any cleanup work */
8185 smp_cpus_done(setup_max_cpus);
8186 }
8187 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
8188 index cc02050fd0c4..32dea29d05a0 100644
8189 --- a/kernel/sysctl.c
8190 +++ b/kernel/sysctl.c
8191 @@ -2767,6 +2767,8 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
8192 bool neg;
8193
8194 left -= proc_skip_spaces(&p);
8195 + if (!left)
8196 + break;
8197
8198 err = proc_get_long(&p, &left, &val, &neg,
8199 proc_wspace_sep,
8200 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
8201 index f3b22f456fac..7846ce24ecc0 100644
8202 --- a/kernel/time/timekeeping.c
8203 +++ b/kernel/time/timekeeping.c
8204 @@ -50,7 +50,9 @@ enum timekeeping_adv_mode {
8205 static struct {
8206 seqcount_t seq;
8207 struct timekeeper timekeeper;
8208 -} tk_core ____cacheline_aligned;
8209 +} tk_core ____cacheline_aligned = {
8210 + .seq = SEQCNT_ZERO(tk_core.seq),
8211 +};
8212
8213 static DEFINE_RAW_SPINLOCK(timekeeper_lock);
8214 static struct timekeeper shadow_timekeeper;
8215 diff --git a/lib/seq_buf.c b/lib/seq_buf.c
8216 index 11f2ae0f9099..6aabb609dd87 100644
8217 --- a/lib/seq_buf.c
8218 +++ b/lib/seq_buf.c
8219 @@ -144,9 +144,13 @@ int seq_buf_puts(struct seq_buf *s, const char *str)
8220
8221 WARN_ON(s->size == 0);
8222
8223 + /* Add 1 to len for the trailing null byte which must be there */
8224 + len += 1;
8225 +
8226 if (seq_buf_can_fit(s, len)) {
8227 memcpy(s->buffer + s->len, str, len);
8228 - s->len += len;
8229 + /* Don't count the trailing null byte against the capacity */
8230 + s->len += len - 1;
8231 return 0;
8232 }
8233 seq_buf_set_overflow(s);
8234 diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
8235 index 82ac39ce5310..aecc0996628f 100644
8236 --- a/lib/test_rhashtable.c
8237 +++ b/lib/test_rhashtable.c
8238 @@ -541,38 +541,45 @@ static unsigned int __init print_ht(struct rhltable *rhlt)
8239 static int __init test_insert_dup(struct test_obj_rhl *rhl_test_objects,
8240 int cnt, bool slow)
8241 {
8242 - struct rhltable rhlt;
8243 + struct rhltable *rhlt;
8244 unsigned int i, ret;
8245 const char *key;
8246 int err = 0;
8247
8248 - err = rhltable_init(&rhlt, &test_rht_params_dup);
8249 - if (WARN_ON(err))
8250 + rhlt = kmalloc(sizeof(*rhlt), GFP_KERNEL);
8251 + if (WARN_ON(!rhlt))
8252 + return -EINVAL;
8253 +
8254 + err = rhltable_init(rhlt, &test_rht_params_dup);
8255 + if (WARN_ON(err)) {
8256 + kfree(rhlt);
8257 return err;
8258 + }
8259
8260 for (i = 0; i < cnt; i++) {
8261 rhl_test_objects[i].value.tid = i;
8262 - key = rht_obj(&rhlt.ht, &rhl_test_objects[i].list_node.rhead);
8263 + key = rht_obj(&rhlt->ht, &rhl_test_objects[i].list_node.rhead);
8264 key += test_rht_params_dup.key_offset;
8265
8266 if (slow) {
8267 - err = PTR_ERR(rhashtable_insert_slow(&rhlt.ht, key,
8268 + err = PTR_ERR(rhashtable_insert_slow(&rhlt->ht, key,
8269 &rhl_test_objects[i].list_node.rhead));
8270 if (err == -EAGAIN)
8271 err = 0;
8272 } else
8273 - err = rhltable_insert(&rhlt,
8274 + err = rhltable_insert(rhlt,
8275 &rhl_test_objects[i].list_node,
8276 test_rht_params_dup);
8277 if (WARN(err, "error %d on element %d/%d (%s)\n", err, i, cnt, slow? "slow" : "fast"))
8278 goto skip_print;
8279 }
8280
8281 - ret = print_ht(&rhlt);
8282 + ret = print_ht(rhlt);
8283 WARN(ret != cnt, "missing rhltable elements (%d != %d, %s)\n", ret, cnt, slow? "slow" : "fast");
8284
8285 skip_print:
8286 - rhltable_destroy(&rhlt);
8287 + rhltable_destroy(rhlt);
8288 + kfree(rhlt);
8289
8290 return 0;
8291 }
8292 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
8293 index 9e45553cabd6..a9de1dbb9a6c 100644
8294 --- a/mm/page_alloc.c
8295 +++ b/mm/page_alloc.c
8296 @@ -294,6 +294,32 @@ EXPORT_SYMBOL(nr_online_nodes);
8297 int page_group_by_mobility_disabled __read_mostly;
8298
8299 #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
8300 +/*
8301 + * During boot we initialize deferred pages on-demand, as needed, but once
8302 + * page_alloc_init_late() has finished, the deferred pages are all initialized,
8303 + * and we can permanently disable that path.
8304 + */
8305 +static DEFINE_STATIC_KEY_TRUE(deferred_pages);
8306 +
8307 +/*
8308 + * Calling kasan_free_pages() only after deferred memory initialization
8309 + * has completed. Poisoning pages during deferred memory init will greatly
8310 + * lengthen the process and cause problem in large memory systems as the
8311 + * deferred pages initialization is done with interrupt disabled.
8312 + *
8313 + * Assuming that there will be no reference to those newly initialized
8314 + * pages before they are ever allocated, this should have no effect on
8315 + * KASAN memory tracking as the poison will be properly inserted at page
8316 + * allocation time. The only corner case is when pages are allocated by
8317 + * on-demand allocation and then freed again before the deferred pages
8318 + * initialization is done, but this is not likely to happen.
8319 + */
8320 +static inline void kasan_free_nondeferred_pages(struct page *page, int order)
8321 +{
8322 + if (!static_branch_unlikely(&deferred_pages))
8323 + kasan_free_pages(page, order);
8324 +}
8325 +
8326 /* Returns true if the struct page for the pfn is uninitialised */
8327 static inline bool __meminit early_page_uninitialised(unsigned long pfn)
8328 {
8329 @@ -326,6 +352,8 @@ static inline bool update_defer_init(pg_data_t *pgdat,
8330 return true;
8331 }
8332 #else
8333 +#define kasan_free_nondeferred_pages(p, o) kasan_free_pages(p, o)
8334 +
8335 static inline bool early_page_uninitialised(unsigned long pfn)
8336 {
8337 return false;
8338 @@ -1030,7 +1058,7 @@ static __always_inline bool free_pages_prepare(struct page *page,
8339 arch_free_page(page, order);
8340 kernel_poison_pages(page, 1 << order, 0);
8341 kernel_map_pages(page, 1 << order, 0);
8342 - kasan_free_pages(page, order);
8343 + kasan_free_nondeferred_pages(page, order);
8344
8345 return true;
8346 }
8347 @@ -1593,13 +1621,6 @@ static int __init deferred_init_memmap(void *data)
8348 return 0;
8349 }
8350
8351 -/*
8352 - * During boot we initialize deferred pages on-demand, as needed, but once
8353 - * page_alloc_init_late() has finished, the deferred pages are all initialized,
8354 - * and we can permanently disable that path.
8355 - */
8356 -static DEFINE_STATIC_KEY_TRUE(deferred_pages);
8357 -
8358 /*
8359 * If this zone has deferred pages, try to grow it by initializing enough
8360 * deferred pages to satisfy the allocation specified by order, rounded up to
8361 diff --git a/mm/percpu-km.c b/mm/percpu-km.c
8362 index 38de70ab1a0d..0f643dc2dc65 100644
8363 --- a/mm/percpu-km.c
8364 +++ b/mm/percpu-km.c
8365 @@ -50,6 +50,7 @@ static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp)
8366 const int nr_pages = pcpu_group_sizes[0] >> PAGE_SHIFT;
8367 struct pcpu_chunk *chunk;
8368 struct page *pages;
8369 + unsigned long flags;
8370 int i;
8371
8372 chunk = pcpu_alloc_chunk(gfp);
8373 @@ -68,9 +69,9 @@ static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp)
8374 chunk->data = pages;
8375 chunk->base_addr = page_address(pages) - pcpu_group_offsets[0];
8376
8377 - spin_lock_irq(&pcpu_lock);
8378 + spin_lock_irqsave(&pcpu_lock, flags);
8379 pcpu_chunk_populated(chunk, 0, nr_pages, false);
8380 - spin_unlock_irq(&pcpu_lock);
8381 + spin_unlock_irqrestore(&pcpu_lock, flags);
8382
8383 pcpu_stats_chunk_alloc();
8384 trace_percpu_create_chunk(chunk->base_addr);
8385 diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
8386 index 6eb837a47b5c..baaaeb2b2c42 100644
8387 --- a/net/dccp/ccid.h
8388 +++ b/net/dccp/ccid.h
8389 @@ -202,7 +202,7 @@ static inline void ccid_hc_tx_packet_recv(struct ccid *ccid, struct sock *sk,
8390 static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
8391 u8 pkt, u8 opt, u8 *val, u8 len)
8392 {
8393 - if (ccid->ccid_ops->ccid_hc_tx_parse_options == NULL)
8394 + if (!ccid || !ccid->ccid_ops->ccid_hc_tx_parse_options)
8395 return 0;
8396 return ccid->ccid_ops->ccid_hc_tx_parse_options(sk, pkt, opt, val, len);
8397 }
8398 @@ -214,7 +214,7 @@ static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
8399 static inline int ccid_hc_rx_parse_options(struct ccid *ccid, struct sock *sk,
8400 u8 pkt, u8 opt, u8 *val, u8 len)
8401 {
8402 - if (ccid->ccid_ops->ccid_hc_rx_parse_options == NULL)
8403 + if (!ccid || !ccid->ccid_ops->ccid_hc_rx_parse_options)
8404 return 0;
8405 return ccid->ccid_ops->ccid_hc_rx_parse_options(sk, pkt, opt, val, len);
8406 }
8407 diff --git a/net/dsa/master.c b/net/dsa/master.c
8408 index c90ee3227dea..aae478d61101 100644
8409 --- a/net/dsa/master.c
8410 +++ b/net/dsa/master.c
8411 @@ -158,6 +158,8 @@ static void dsa_master_ethtool_teardown(struct net_device *dev)
8412 cpu_dp->orig_ethtool_ops = NULL;
8413 }
8414
8415 +static struct lock_class_key dsa_master_addr_list_lock_key;
8416 +
8417 int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
8418 {
8419 /* If we use a tagging format that doesn't have an ethertype
8420 @@ -167,6 +169,8 @@ int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
8421 wmb();
8422
8423 dev->dsa_ptr = cpu_dp;
8424 + lockdep_set_class(&dev->addr_list_lock,
8425 + &dsa_master_addr_list_lock_key);
8426
8427 return dsa_master_ethtool_setup(dev);
8428 }
8429 diff --git a/net/dsa/slave.c b/net/dsa/slave.c
8430 index 1c45c1d6d241..b39720d0995d 100644
8431 --- a/net/dsa/slave.c
8432 +++ b/net/dsa/slave.c
8433 @@ -140,11 +140,14 @@ static int dsa_slave_close(struct net_device *dev)
8434 static void dsa_slave_change_rx_flags(struct net_device *dev, int change)
8435 {
8436 struct net_device *master = dsa_slave_to_master(dev);
8437 -
8438 - if (change & IFF_ALLMULTI)
8439 - dev_set_allmulti(master, dev->flags & IFF_ALLMULTI ? 1 : -1);
8440 - if (change & IFF_PROMISC)
8441 - dev_set_promiscuity(master, dev->flags & IFF_PROMISC ? 1 : -1);
8442 + if (dev->flags & IFF_UP) {
8443 + if (change & IFF_ALLMULTI)
8444 + dev_set_allmulti(master,
8445 + dev->flags & IFF_ALLMULTI ? 1 : -1);
8446 + if (change & IFF_PROMISC)
8447 + dev_set_promiscuity(master,
8448 + dev->flags & IFF_PROMISC ? 1 : -1);
8449 + }
8450 }
8451
8452 static void dsa_slave_set_rx_mode(struct net_device *dev)
8453 @@ -639,7 +642,7 @@ static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e)
8454 int ret;
8455
8456 /* Port's PHY and MAC both need to be EEE capable */
8457 - if (!dev->phydev && !dp->pl)
8458 + if (!dev->phydev || !dp->pl)
8459 return -ENODEV;
8460
8461 if (!ds->ops->set_mac_eee)
8462 @@ -659,7 +662,7 @@ static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e)
8463 int ret;
8464
8465 /* Port's PHY and MAC both need to be EEE capable */
8466 - if (!dev->phydev && !dp->pl)
8467 + if (!dev->phydev || !dp->pl)
8468 return -ENODEV;
8469
8470 if (!ds->ops->get_mac_eee)
8471 diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
8472 index 4a46df8441c9..f5b4febeaa25 100644
8473 --- a/net/ipv6/xfrm6_tunnel.c
8474 +++ b/net/ipv6/xfrm6_tunnel.c
8475 @@ -144,6 +144,9 @@ static u32 __xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr)
8476 index = __xfrm6_tunnel_spi_check(net, spi);
8477 if (index >= 0)
8478 goto alloc_spi;
8479 +
8480 + if (spi == XFRM6_TUNNEL_SPI_MAX)
8481 + break;
8482 }
8483 for (spi = XFRM6_TUNNEL_SPI_MIN; spi < xfrm6_tn->spi; spi++) {
8484 index = __xfrm6_tunnel_spi_check(net, spi);
8485 diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
8486 index 5e2b4a41acf1..51ad330bf8e8 100644
8487 --- a/net/mac80211/rx.c
8488 +++ b/net/mac80211/rx.c
8489 @@ -142,6 +142,9 @@ ieee80211_rx_radiotap_hdrlen(struct ieee80211_local *local,
8490 /* allocate extra bitmaps */
8491 if (status->chains)
8492 len += 4 * hweight8(status->chains);
8493 + /* vendor presence bitmap */
8494 + if (status->flag & RX_FLAG_RADIOTAP_VENDOR_DATA)
8495 + len += 4;
8496
8497 if (ieee80211_have_rx_timestamp(status)) {
8498 len = ALIGN(len, 8);
8499 @@ -197,8 +200,6 @@ ieee80211_rx_radiotap_hdrlen(struct ieee80211_local *local,
8500 if (status->flag & RX_FLAG_RADIOTAP_VENDOR_DATA) {
8501 struct ieee80211_vendor_radiotap *rtap = (void *)skb->data;
8502
8503 - /* vendor presence bitmap */
8504 - len += 4;
8505 /* alignment for fixed 6-byte vendor data header */
8506 len = ALIGN(len, 2);
8507 /* vendor data header */
8508 diff --git a/net/rds/bind.c b/net/rds/bind.c
8509 index 762d2c6788a3..17c9d9f0c848 100644
8510 --- a/net/rds/bind.c
8511 +++ b/net/rds/bind.c
8512 @@ -78,10 +78,10 @@ struct rds_sock *rds_find_bound(const struct in6_addr *addr, __be16 port,
8513 __rds_create_bind_key(key, addr, port, scope_id);
8514 rcu_read_lock();
8515 rs = rhashtable_lookup(&bind_hash_table, key, ht_parms);
8516 - if (rs && !sock_flag(rds_rs_to_sk(rs), SOCK_DEAD))
8517 - rds_sock_addref(rs);
8518 - else
8519 + if (rs && (sock_flag(rds_rs_to_sk(rs), SOCK_DEAD) ||
8520 + !refcount_inc_not_zero(&rds_rs_to_sk(rs)->sk_refcnt)))
8521 rs = NULL;
8522 +
8523 rcu_read_unlock();
8524
8525 rdsdebug("returning rs %p for %pI6c:%u\n", rs, addr,
8526 diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c
8527 index 816b19a78809..0374b0623c8b 100644
8528 --- a/net/rxrpc/recvmsg.c
8529 +++ b/net/rxrpc/recvmsg.c
8530 @@ -596,6 +596,7 @@ error_requeue_call:
8531 }
8532 error_no_call:
8533 release_sock(&rx->sk);
8534 +error_trace:
8535 trace_rxrpc_recvmsg(call, rxrpc_recvmsg_return, 0, 0, 0, ret);
8536 return ret;
8537
8538 @@ -604,7 +605,7 @@ wait_interrupted:
8539 wait_error:
8540 finish_wait(sk_sleep(&rx->sk), &wait);
8541 call = NULL;
8542 - goto error_no_call;
8543 + goto error_trace;
8544 }
8545
8546 /**
8547 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
8548 index 876393cf5ed6..e5e70cff5bb3 100644
8549 --- a/net/sctp/socket.c
8550 +++ b/net/sctp/socket.c
8551 @@ -2045,7 +2045,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
8552 struct sctp_endpoint *ep = sctp_sk(sk)->ep;
8553 struct sctp_transport *transport = NULL;
8554 struct sctp_sndrcvinfo _sinfo, *sinfo;
8555 - struct sctp_association *asoc;
8556 + struct sctp_association *asoc, *tmp;
8557 struct sctp_cmsgs cmsgs;
8558 union sctp_addr *daddr;
8559 bool new = false;
8560 @@ -2071,7 +2071,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
8561
8562 /* SCTP_SENDALL process */
8563 if ((sflags & SCTP_SENDALL) && sctp_style(sk, UDP)) {
8564 - list_for_each_entry(asoc, &ep->asocs, asocs) {
8565 + list_for_each_entry_safe(asoc, tmp, &ep->asocs, asocs) {
8566 err = sctp_sendmsg_check_sflags(asoc, sflags, msg,
8567 msg_len);
8568 if (err == 0)
8569 diff --git a/net/sctp/stream.c b/net/sctp/stream.c
8570 index 80e0ae5534ec..f24633114dfd 100644
8571 --- a/net/sctp/stream.c
8572 +++ b/net/sctp/stream.c
8573 @@ -84,6 +84,19 @@ static void fa_zero(struct flex_array *fa, size_t index, size_t count)
8574 }
8575 }
8576
8577 +static size_t fa_index(struct flex_array *fa, void *elem, size_t count)
8578 +{
8579 + size_t index = 0;
8580 +
8581 + while (count--) {
8582 + if (elem == flex_array_get(fa, index))
8583 + break;
8584 + index++;
8585 + }
8586 +
8587 + return index;
8588 +}
8589 +
8590 /* Migrates chunks from stream queues to new stream queues if needed,
8591 * but not across associations. Also, removes those chunks to streams
8592 * higher than the new max.
8593 @@ -147,6 +160,13 @@ static int sctp_stream_alloc_out(struct sctp_stream *stream, __u16 outcnt,
8594
8595 if (stream->out) {
8596 fa_copy(out, stream->out, 0, min(outcnt, stream->outcnt));
8597 + if (stream->out_curr) {
8598 + size_t index = fa_index(stream->out, stream->out_curr,
8599 + stream->outcnt);
8600 +
8601 + BUG_ON(index == stream->outcnt);
8602 + stream->out_curr = flex_array_get(out, index);
8603 + }
8604 fa_free(stream->out);
8605 }
8606
8607 diff --git a/net/tipc/node.c b/net/tipc/node.c
8608 index 488019766433..32556f480a60 100644
8609 --- a/net/tipc/node.c
8610 +++ b/net/tipc/node.c
8611 @@ -624,6 +624,12 @@ static void tipc_node_timeout(struct timer_list *t)
8612
8613 __skb_queue_head_init(&xmitq);
8614
8615 + /* Initial node interval to value larger (10 seconds), then it will be
8616 + * recalculated with link lowest tolerance
8617 + */
8618 + tipc_node_read_lock(n);
8619 + n->keepalive_intv = 10000;
8620 + tipc_node_read_unlock(n);
8621 for (bearer_id = 0; remains && (bearer_id < MAX_BEARERS); bearer_id++) {
8622 tipc_node_read_lock(n);
8623 le = &n->links[bearer_id];
8624 diff --git a/samples/livepatch/livepatch-shadow-fix1.c b/samples/livepatch/livepatch-shadow-fix1.c
8625 index 49b13553eaae..e8f1bd6b29b1 100644
8626 --- a/samples/livepatch/livepatch-shadow-fix1.c
8627 +++ b/samples/livepatch/livepatch-shadow-fix1.c
8628 @@ -89,6 +89,11 @@ struct dummy *livepatch_fix1_dummy_alloc(void)
8629 * pointer to handle resource release.
8630 */
8631 leak = kzalloc(sizeof(int), GFP_KERNEL);
8632 + if (!leak) {
8633 + kfree(d);
8634 + return NULL;
8635 + }
8636 +
8637 klp_shadow_alloc(d, SV_LEAK, sizeof(leak), GFP_KERNEL,
8638 shadow_leak_ctor, leak);
8639
8640 diff --git a/samples/livepatch/livepatch-shadow-mod.c b/samples/livepatch/livepatch-shadow-mod.c
8641 index 4c54b250332d..4aa8a88d3cd6 100644
8642 --- a/samples/livepatch/livepatch-shadow-mod.c
8643 +++ b/samples/livepatch/livepatch-shadow-mod.c
8644 @@ -118,6 +118,10 @@ noinline struct dummy *dummy_alloc(void)
8645
8646 /* Oops, forgot to save leak! */
8647 leak = kzalloc(sizeof(int), GFP_KERNEL);
8648 + if (!leak) {
8649 + kfree(d);
8650 + return NULL;
8651 + }
8652
8653 pr_info("%s: dummy @ %p, expires @ %lx\n",
8654 __func__, d, d->jiffies_expire);
8655 diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
8656 index 64220e36ce3b..98a7d63a723e 100755
8657 --- a/scripts/decode_stacktrace.sh
8658 +++ b/scripts/decode_stacktrace.sh
8659 @@ -78,7 +78,7 @@ parse_symbol() {
8660 fi
8661
8662 # Strip out the base of the path
8663 - code=${code//$basepath/""}
8664 + code=${code//^$basepath/""}
8665
8666 # In the case of inlines, move everything to same line
8667 code=${code//$'\n'/' '}
8668 diff --git a/scripts/gdb/linux/proc.py b/scripts/gdb/linux/proc.py
8669 index 086d27223c0c..0aebd7565b03 100644
8670 --- a/scripts/gdb/linux/proc.py
8671 +++ b/scripts/gdb/linux/proc.py
8672 @@ -41,7 +41,7 @@ class LxVersion(gdb.Command):
8673
8674 def invoke(self, arg, from_tty):
8675 # linux_banner should contain a newline
8676 - gdb.write(gdb.parse_and_eval("linux_banner").string())
8677 + gdb.write(gdb.parse_and_eval("(char *)linux_banner").string())
8678
8679 LxVersion()
8680
8681 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
8682 index 5a5b3780456f..5a77efd39b3f 100644
8683 --- a/scripts/mod/modpost.c
8684 +++ b/scripts/mod/modpost.c
8685 @@ -1204,6 +1204,30 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
8686 return 1;
8687 }
8688
8689 +static inline int is_arm_mapping_symbol(const char *str)
8690 +{
8691 + return str[0] == '$' && strchr("axtd", str[1])
8692 + && (str[2] == '\0' || str[2] == '.');
8693 +}
8694 +
8695 +/*
8696 + * If there's no name there, ignore it; likewise, ignore it if it's
8697 + * one of the magic symbols emitted used by current ARM tools.
8698 + *
8699 + * Otherwise if find_symbols_between() returns those symbols, they'll
8700 + * fail the whitelist tests and cause lots of false alarms ... fixable
8701 + * only by merging __exit and __init sections into __text, bloating
8702 + * the kernel (which is especially evil on embedded platforms).
8703 + */
8704 +static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym)
8705 +{
8706 + const char *name = elf->strtab + sym->st_name;
8707 +
8708 + if (!name || !strlen(name))
8709 + return 0;
8710 + return !is_arm_mapping_symbol(name);
8711 +}
8712 +
8713 /**
8714 * Find symbol based on relocation record info.
8715 * In some cases the symbol supplied is a valid symbol so
8716 @@ -1229,6 +1253,8 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
8717 continue;
8718 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
8719 continue;
8720 + if (!is_valid_name(elf, sym))
8721 + continue;
8722 if (sym->st_value == addr)
8723 return sym;
8724 /* Find a symbol nearby - addr are maybe negative */
8725 @@ -1247,30 +1273,6 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
8726 return NULL;
8727 }
8728
8729 -static inline int is_arm_mapping_symbol(const char *str)
8730 -{
8731 - return str[0] == '$' && strchr("axtd", str[1])
8732 - && (str[2] == '\0' || str[2] == '.');
8733 -}
8734 -
8735 -/*
8736 - * If there's no name there, ignore it; likewise, ignore it if it's
8737 - * one of the magic symbols emitted used by current ARM tools.
8738 - *
8739 - * Otherwise if find_symbols_between() returns those symbols, they'll
8740 - * fail the whitelist tests and cause lots of false alarms ... fixable
8741 - * only by merging __exit and __init sections into __text, bloating
8742 - * the kernel (which is especially evil on embedded platforms).
8743 - */
8744 -static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym)
8745 -{
8746 - const char *name = elf->strtab + sym->st_name;
8747 -
8748 - if (!name || !strlen(name))
8749 - return 0;
8750 - return !is_arm_mapping_symbol(name);
8751 -}
8752 -
8753 /*
8754 * Find symbols before or equal addr and after addr - in the section sec.
8755 * If we find two symbols with equal offset prefer one with a valid name.
8756 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
8757 index 70d3066e69fe..017c47eb795e 100644
8758 --- a/security/smack/smack_lsm.c
8759 +++ b/security/smack/smack_lsm.c
8760 @@ -4333,6 +4333,12 @@ static int smack_key_permission(key_ref_t key_ref,
8761 int request = 0;
8762 int rc;
8763
8764 + /*
8765 + * Validate requested permissions
8766 + */
8767 + if (perm & ~KEY_NEED_ALL)
8768 + return -EINVAL;
8769 +
8770 keyp = key_ref_to_ptr(key_ref);
8771 if (keyp == NULL)
8772 return -EINVAL;
8773 @@ -4356,10 +4362,10 @@ static int smack_key_permission(key_ref_t key_ref,
8774 ad.a.u.key_struct.key = keyp->serial;
8775 ad.a.u.key_struct.key_desc = keyp->description;
8776 #endif
8777 - if (perm & KEY_NEED_READ)
8778 - request = MAY_READ;
8779 + if (perm & (KEY_NEED_READ | KEY_NEED_SEARCH | KEY_NEED_VIEW))
8780 + request |= MAY_READ;
8781 if (perm & (KEY_NEED_WRITE | KEY_NEED_LINK | KEY_NEED_SETATTR))
8782 - request = MAY_WRITE;
8783 + request |= MAY_WRITE;
8784 rc = smk_access(tkp, keyp->security, request, &ad);
8785 rc = smk_bu_note("key access", tkp, keyp->security, request, rc);
8786 return rc;
8787 diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c
8788 index d361bb77ca00..8db1890605f6 100644
8789 --- a/sound/pci/hda/hda_bind.c
8790 +++ b/sound/pci/hda/hda_bind.c
8791 @@ -109,7 +109,8 @@ static int hda_codec_driver_probe(struct device *dev)
8792 err = snd_hda_codec_build_controls(codec);
8793 if (err < 0)
8794 goto error_module;
8795 - if (codec->card->registered) {
8796 + /* only register after the bus probe finished; otherwise it's racy */
8797 + if (!codec->bus->bus_probing && codec->card->registered) {
8798 err = snd_card_register(codec->card);
8799 if (err < 0)
8800 goto error_module;
8801 diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
8802 index 0d98bb9068b1..acacc1900265 100644
8803 --- a/sound/pci/hda/hda_codec.h
8804 +++ b/sound/pci/hda/hda_codec.h
8805 @@ -68,6 +68,7 @@ struct hda_bus {
8806 unsigned int response_reset:1; /* controller was reset */
8807 unsigned int in_reset:1; /* during reset operation */
8808 unsigned int no_response_fallback:1; /* don't fallback at RIRB error */
8809 + unsigned int bus_probing :1; /* during probing process */
8810
8811 int primary_dig_out_type; /* primary digital out PCM type */
8812 unsigned int mixer_assigned; /* codec addr for mixer name */
8813 diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
8814 index 1ddeebc373b3..1bb7613701ac 100644
8815 --- a/sound/pci/hda/hda_intel.c
8816 +++ b/sound/pci/hda/hda_intel.c
8817 @@ -2315,6 +2315,7 @@ static int azx_probe_continue(struct azx *chip)
8818 int dev = chip->dev_index;
8819 int err;
8820
8821 + to_hda_bus(bus)->bus_probing = 1;
8822 hda->probe_continued = 1;
8823
8824 /* bind with i915 if needed */
8825 @@ -2410,6 +2411,7 @@ i915_power_fail:
8826 if (err < 0)
8827 hda->init_failed = 1;
8828 complete_all(&hda->probe_wait);
8829 + to_hda_bus(bus)->bus_probing = 0;
8830 return err;
8831 }
8832
8833 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
8834 index dbb38fe2da7d..9199d91d0a59 100644
8835 --- a/sound/pci/hda/patch_realtek.c
8836 +++ b/sound/pci/hda/patch_realtek.c
8837 @@ -515,6 +515,15 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
8838 }
8839 }
8840
8841 +/* get a primary headphone pin if available */
8842 +static hda_nid_t alc_get_hp_pin(struct alc_spec *spec)
8843 +{
8844 + if (spec->gen.autocfg.hp_pins[0])
8845 + return spec->gen.autocfg.hp_pins[0];
8846 + if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
8847 + return spec->gen.autocfg.line_out_pins[0];
8848 + return 0;
8849 +}
8850
8851 /*
8852 * Realtek SSID verification
8853 @@ -725,9 +734,7 @@ do_sku:
8854 * 15 : 1 --> enable the function "Mute internal speaker
8855 * when the external headphone out jack is plugged"
8856 */
8857 - if (!spec->gen.autocfg.hp_pins[0] &&
8858 - !(spec->gen.autocfg.line_out_pins[0] &&
8859 - spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
8860 + if (!alc_get_hp_pin(spec)) {
8861 hda_nid_t nid;
8862 tmp = (ass >> 11) & 0x3; /* HP to chassis */
8863 nid = ports[tmp];
8864 @@ -2959,7 +2966,7 @@ static void alc282_restore_default_value(struct hda_codec *codec)
8865 static void alc282_init(struct hda_codec *codec)
8866 {
8867 struct alc_spec *spec = codec->spec;
8868 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8869 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8870 bool hp_pin_sense;
8871 int coef78;
8872
8873 @@ -2996,7 +3003,7 @@ static void alc282_init(struct hda_codec *codec)
8874 static void alc282_shutup(struct hda_codec *codec)
8875 {
8876 struct alc_spec *spec = codec->spec;
8877 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8878 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8879 bool hp_pin_sense;
8880 int coef78;
8881
8882 @@ -3074,14 +3081,9 @@ static void alc283_restore_default_value(struct hda_codec *codec)
8883 static void alc283_init(struct hda_codec *codec)
8884 {
8885 struct alc_spec *spec = codec->spec;
8886 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8887 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8888 bool hp_pin_sense;
8889
8890 - if (!spec->gen.autocfg.hp_outs) {
8891 - if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
8892 - hp_pin = spec->gen.autocfg.line_out_pins[0];
8893 - }
8894 -
8895 alc283_restore_default_value(codec);
8896
8897 if (!hp_pin)
8898 @@ -3115,14 +3117,9 @@ static void alc283_init(struct hda_codec *codec)
8899 static void alc283_shutup(struct hda_codec *codec)
8900 {
8901 struct alc_spec *spec = codec->spec;
8902 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8903 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8904 bool hp_pin_sense;
8905
8906 - if (!spec->gen.autocfg.hp_outs) {
8907 - if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
8908 - hp_pin = spec->gen.autocfg.line_out_pins[0];
8909 - }
8910 -
8911 if (!hp_pin) {
8912 alc269_shutup(codec);
8913 return;
8914 @@ -3156,7 +3153,7 @@ static void alc283_shutup(struct hda_codec *codec)
8915 static void alc256_init(struct hda_codec *codec)
8916 {
8917 struct alc_spec *spec = codec->spec;
8918 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8919 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8920 bool hp_pin_sense;
8921
8922 if (!hp_pin)
8923 @@ -3192,7 +3189,7 @@ static void alc256_init(struct hda_codec *codec)
8924 static void alc256_shutup(struct hda_codec *codec)
8925 {
8926 struct alc_spec *spec = codec->spec;
8927 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8928 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8929 bool hp_pin_sense;
8930
8931 if (!hp_pin) {
8932 @@ -3228,7 +3225,7 @@ static void alc256_shutup(struct hda_codec *codec)
8933 static void alc225_init(struct hda_codec *codec)
8934 {
8935 struct alc_spec *spec = codec->spec;
8936 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8937 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8938 bool hp1_pin_sense, hp2_pin_sense;
8939
8940 if (!hp_pin)
8941 @@ -3271,7 +3268,7 @@ static void alc225_init(struct hda_codec *codec)
8942 static void alc225_shutup(struct hda_codec *codec)
8943 {
8944 struct alc_spec *spec = codec->spec;
8945 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8946 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8947 bool hp1_pin_sense, hp2_pin_sense;
8948
8949 if (!hp_pin) {
8950 @@ -3315,7 +3312,7 @@ static void alc225_shutup(struct hda_codec *codec)
8951 static void alc_default_init(struct hda_codec *codec)
8952 {
8953 struct alc_spec *spec = codec->spec;
8954 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8955 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8956 bool hp_pin_sense;
8957
8958 if (!hp_pin)
8959 @@ -3344,7 +3341,7 @@ static void alc_default_init(struct hda_codec *codec)
8960 static void alc_default_shutup(struct hda_codec *codec)
8961 {
8962 struct alc_spec *spec = codec->spec;
8963 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8964 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8965 bool hp_pin_sense;
8966
8967 if (!hp_pin) {
8968 @@ -3376,7 +3373,7 @@ static void alc_default_shutup(struct hda_codec *codec)
8969 static void alc294_hp_init(struct hda_codec *codec)
8970 {
8971 struct alc_spec *spec = codec->spec;
8972 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8973 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8974 int i, val;
8975
8976 if (!hp_pin)
8977 @@ -4780,7 +4777,7 @@ static void alc_update_headset_mode(struct hda_codec *codec)
8978 struct alc_spec *spec = codec->spec;
8979
8980 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
8981 - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
8982 + hda_nid_t hp_pin = alc_get_hp_pin(spec);
8983
8984 int new_headset_mode;
8985
8986 @@ -5059,7 +5056,7 @@ static void alc_fixup_tpt470_dock(struct hda_codec *codec,
8987 static void alc_shutup_dell_xps13(struct hda_codec *codec)
8988 {
8989 struct alc_spec *spec = codec->spec;
8990 - int hp_pin = spec->gen.autocfg.hp_pins[0];
8991 + int hp_pin = alc_get_hp_pin(spec);
8992
8993 /* Prevent pop noises when headphones are plugged in */
8994 snd_hda_codec_write(codec, hp_pin, 0,
8995 @@ -5152,7 +5149,7 @@ static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
8996
8997 if (action == HDA_FIXUP_ACT_PROBE) {
8998 int mic_pin = find_ext_mic_pin(codec);
8999 - int hp_pin = spec->gen.autocfg.hp_pins[0];
9000 + int hp_pin = alc_get_hp_pin(spec);
9001
9002 if (snd_BUG_ON(!mic_pin || !hp_pin))
9003 return;
9004 @@ -5575,6 +5572,7 @@ enum {
9005 ALC294_FIXUP_ASUS_MIC,
9006 ALC294_FIXUP_ASUS_HEADSET_MIC,
9007 ALC294_FIXUP_ASUS_SPK,
9008 + ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
9009 };
9010
9011 static const struct hda_fixup alc269_fixups[] = {
9012 @@ -6499,6 +6497,15 @@ static const struct hda_fixup alc269_fixups[] = {
9013 .chained = true,
9014 .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
9015 },
9016 + [ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
9017 + .type = HDA_FIXUP_PINS,
9018 + .v.pins = (const struct hda_pintbl[]) {
9019 + { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
9020 + { }
9021 + },
9022 + .chained = true,
9023 + .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
9024 + },
9025 };
9026
9027 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
9028 @@ -6677,6 +6684,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
9029 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
9030 SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
9031 SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
9032 + SND_PCI_QUIRK(0x1558, 0x1325, "System76 Darter Pro (darp5)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9033 SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
9034 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
9035 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
9036 diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
9037 index 6ec19fb4a934..2e75b5bc5f1d 100644
9038 --- a/sound/soc/fsl/Kconfig
9039 +++ b/sound/soc/fsl/Kconfig
9040 @@ -221,7 +221,7 @@ config SND_SOC_PHYCORE_AC97
9041
9042 config SND_SOC_EUKREA_TLV320
9043 tristate "Eukrea TLV320"
9044 - depends on ARCH_MXC && I2C
9045 + depends on ARCH_MXC && !ARM64 && I2C
9046 select SND_SOC_TLV320AIC23_I2C
9047 select SND_SOC_IMX_AUDMUX
9048 select SND_SOC_IMX_SSI
9049 diff --git a/sound/soc/intel/atom/sst/sst_loader.c b/sound/soc/intel/atom/sst/sst_loader.c
9050 index 27413ebae956..b8c456753f01 100644
9051 --- a/sound/soc/intel/atom/sst/sst_loader.c
9052 +++ b/sound/soc/intel/atom/sst/sst_loader.c
9053 @@ -354,14 +354,14 @@ static int sst_request_fw(struct intel_sst_drv *sst)
9054 const struct firmware *fw;
9055
9056 retval = request_firmware(&fw, sst->firmware_name, sst->dev);
9057 - if (fw == NULL) {
9058 - dev_err(sst->dev, "fw is returning as null\n");
9059 - return -EINVAL;
9060 - }
9061 if (retval) {
9062 dev_err(sst->dev, "request fw failed %d\n", retval);
9063 return retval;
9064 }
9065 + if (fw == NULL) {
9066 + dev_err(sst->dev, "fw is returning as null\n");
9067 + return -EINVAL;
9068 + }
9069 mutex_lock(&sst->sst_lock);
9070 retval = sst_cache_and_parse_fw(sst, fw);
9071 mutex_unlock(&sst->sst_lock);
9072 diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
9073 index 7e93686a430a..d71e01954975 100644
9074 --- a/sound/usb/quirks.c
9075 +++ b/sound/usb/quirks.c
9076 @@ -1448,6 +1448,7 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
9077 case 0x20b1: /* XMOS based devices */
9078 case 0x152a: /* Thesycon devices */
9079 case 0x25ce: /* Mytek devices */
9080 + case 0x2ab6: /* T+A devices */
9081 if (fp->dsd_raw)
9082 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
9083 break;
9084 diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
9085 index f216b2f5c3d7..42a787856cd8 100644
9086 --- a/tools/build/Makefile.feature
9087 +++ b/tools/build/Makefile.feature
9088 @@ -79,8 +79,8 @@ FEATURE_TESTS_EXTRA := \
9089 cplus-demangle \
9090 hello \
9091 libbabeltrace \
9092 - liberty \
9093 - liberty-z \
9094 + libbfd-liberty \
9095 + libbfd-liberty-z \
9096 libunwind-debug-frame \
9097 libunwind-debug-frame-arm \
9098 libunwind-debug-frame-aarch64 \
9099 diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
9100 index 0516259be70f..bf8a8ebcca1e 100644
9101 --- a/tools/build/feature/Makefile
9102 +++ b/tools/build/feature/Makefile
9103 @@ -15,8 +15,8 @@ FILES= \
9104 test-libbfd.bin \
9105 test-disassembler-four-args.bin \
9106 test-reallocarray.bin \
9107 - test-liberty.bin \
9108 - test-liberty-z.bin \
9109 + test-libbfd-liberty.bin \
9110 + test-libbfd-liberty-z.bin \
9111 test-cplus-demangle.bin \
9112 test-libelf.bin \
9113 test-libelf-getphdrnum.bin \
9114 @@ -200,7 +200,7 @@ $(OUTPUT)test-libpython-version.bin:
9115 $(BUILD)
9116
9117 $(OUTPUT)test-libbfd.bin:
9118 - $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
9119 + $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
9120
9121 $(OUTPUT)test-disassembler-four-args.bin:
9122 $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
9123 @@ -208,10 +208,10 @@ $(OUTPUT)test-disassembler-four-args.bin:
9124 $(OUTPUT)test-reallocarray.bin:
9125 $(BUILD)
9126
9127 -$(OUTPUT)test-liberty.bin:
9128 +$(OUTPUT)test-libbfd-liberty.bin:
9129 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
9130
9131 -$(OUTPUT)test-liberty-z.bin:
9132 +$(OUTPUT)test-libbfd-liberty-z.bin:
9133 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
9134
9135 $(OUTPUT)test-cplus-demangle.bin:
9136 diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
9137 index bbb2a8ef367c..d7e06fe0270e 100644
9138 --- a/tools/hv/hv_kvp_daemon.c
9139 +++ b/tools/hv/hv_kvp_daemon.c
9140 @@ -1178,6 +1178,7 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
9141 FILE *file;
9142 char cmd[PATH_MAX];
9143 char *mac_addr;
9144 + int str_len;
9145
9146 /*
9147 * Set the configuration for the specified interface with
9148 @@ -1301,8 +1302,18 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
9149 * invoke the external script to do its magic.
9150 */
9151
9152 - snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s",
9153 - "hv_set_ifconfig", if_file);
9154 + str_len = snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s",
9155 + "hv_set_ifconfig", if_file);
9156 + /*
9157 + * This is a little overcautious, but it's necessary to suppress some
9158 + * false warnings from gcc 8.0.1.
9159 + */
9160 + if (str_len <= 0 || (unsigned int)str_len >= sizeof(cmd)) {
9161 + syslog(LOG_ERR, "Cmd '%s' (len=%d) may be too long",
9162 + cmd, str_len);
9163 + return HV_E_FAIL;
9164 + }
9165 +
9166 if (system(cmd)) {
9167 syslog(LOG_ERR, "Failed to execute cmd '%s'; error: %d %s",
9168 cmd, errno, strerror(errno));
9169 diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
9170 index 60aa4ca8b2c5..7a0014794bff 100644
9171 --- a/tools/lib/bpf/bpf.c
9172 +++ b/tools/lib/bpf/bpf.c
9173 @@ -77,6 +77,7 @@ int bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr)
9174 {
9175 __u32 name_len = create_attr->name ? strlen(create_attr->name) : 0;
9176 union bpf_attr attr;
9177 + int ret;
9178
9179 memset(&attr, '\0', sizeof(attr));
9180
9181 @@ -94,7 +95,15 @@ int bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr)
9182 attr.map_ifindex = create_attr->map_ifindex;
9183 attr.inner_map_fd = create_attr->inner_map_fd;
9184
9185 - return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
9186 + ret = sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
9187 + if (ret < 0 && errno == EINVAL && create_attr->name) {
9188 + /* Retry the same syscall, but without the name.
9189 + * Pre v4.14 kernels don't support map names.
9190 + */
9191 + memset(attr.map_name, 0, sizeof(attr.map_name));
9192 + return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
9193 + }
9194 + return ret;
9195 }
9196
9197 int bpf_create_map_node(enum bpf_map_type map_type, const char *name,
9198 diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
9199 index f00ea77f5f08..849b3be15bd8 100644
9200 --- a/tools/perf/Makefile.config
9201 +++ b/tools/perf/Makefile.config
9202 @@ -688,18 +688,20 @@ endif
9203
9204 ifeq ($(feature-libbfd), 1)
9205 EXTLIBS += -lbfd
9206 +else
9207 + # we are on a system that requires -liberty and (maybe) -lz
9208 + # to link against -lbfd; test each case individually here
9209
9210 # call all detections now so we get correct
9211 # status in VF output
9212 - $(call feature_check,liberty)
9213 - $(call feature_check,liberty-z)
9214 - $(call feature_check,cplus-demangle)
9215 + $(call feature_check,libbfd-liberty)
9216 + $(call feature_check,libbfd-liberty-z)
9217
9218 - ifeq ($(feature-liberty), 1)
9219 - EXTLIBS += -liberty
9220 + ifeq ($(feature-libbfd-liberty), 1)
9221 + EXTLIBS += -lbfd -liberty
9222 else
9223 - ifeq ($(feature-liberty-z), 1)
9224 - EXTLIBS += -liberty -lz
9225 + ifeq ($(feature-libbfd-liberty-z), 1)
9226 + EXTLIBS += -lbfd -liberty -lz
9227 endif
9228 endif
9229 endif
9230 @@ -709,24 +711,24 @@ ifdef NO_DEMANGLE
9231 else
9232 ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
9233 EXTLIBS += -liberty
9234 - CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
9235 else
9236 - ifneq ($(feature-libbfd), 1)
9237 - ifneq ($(feature-liberty), 1)
9238 - ifneq ($(feature-liberty-z), 1)
9239 - # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
9240 - # or any of 'bfd iberty z' trinity
9241 - ifeq ($(feature-cplus-demangle), 1)
9242 - EXTLIBS += -liberty
9243 - CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
9244 - else
9245 - msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
9246 - CFLAGS += -DNO_DEMANGLE
9247 - endif
9248 - endif
9249 + ifeq ($(filter -liberty,$(EXTLIBS)),)
9250 + $(call feature_check,cplus-demangle)
9251 +
9252 + # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
9253 + # or any of 'bfd iberty z' trinity
9254 + ifeq ($(feature-cplus-demangle), 1)
9255 + EXTLIBS += -liberty
9256 + else
9257 + msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
9258 + CFLAGS += -DNO_DEMANGLE
9259 endif
9260 endif
9261 endif
9262 +
9263 + ifneq ($(filter -liberty,$(EXTLIBS)),)
9264 + CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
9265 + endif
9266 endif
9267
9268 ifneq ($(filter -lbfd,$(EXTLIBS)),)
9269 diff --git a/tools/perf/arch/x86/util/kvm-stat.c b/tools/perf/arch/x86/util/kvm-stat.c
9270 index b32409a0e546..081353d7b095 100644
9271 --- a/tools/perf/arch/x86/util/kvm-stat.c
9272 +++ b/tools/perf/arch/x86/util/kvm-stat.c
9273 @@ -156,7 +156,7 @@ int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid)
9274 if (strstr(cpuid, "Intel")) {
9275 kvm->exit_reasons = vmx_exit_reasons;
9276 kvm->exit_reasons_isa = "VMX";
9277 - } else if (strstr(cpuid, "AMD")) {
9278 + } else if (strstr(cpuid, "AMD") || strstr(cpuid, "Hygon")) {
9279 kvm->exit_reasons = svm_exit_reasons;
9280 kvm->exit_reasons_isa = "SVM";
9281 } else
9282 diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py
9283 index ff9b60b99f52..44090a9a19f3 100644
9284 --- a/tools/perf/tests/attr.py
9285 +++ b/tools/perf/tests/attr.py
9286 @@ -116,7 +116,7 @@ class Event(dict):
9287 if not self.has_key(t) or not other.has_key(t):
9288 continue
9289 if not data_equal(self[t], other[t]):
9290 - log.warning("expected %s=%s, got %s" % (t, self[t], other[t]))
9291 + log.warning("expected %s=%s, got %s" % (t, self[t], other[t]))
9292
9293 # Test file description needs to have following sections:
9294 # [config]
9295 diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
9296 index 699561fa512c..67bcbf876776 100644
9297 --- a/tools/perf/tests/evsel-tp-sched.c
9298 +++ b/tools/perf/tests/evsel-tp-sched.c
9299 @@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
9300 return -1;
9301 }
9302
9303 - is_signed = !!(field->flags | FIELD_IS_SIGNED);
9304 + is_signed = !!(field->flags & FIELD_IS_SIGNED);
9305 if (should_be_signed && !is_signed) {
9306 pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
9307 evsel->name, name, is_signed, should_be_signed);
9308 diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
9309 index bbed90e5d9bb..cee717a3794f 100644
9310 --- a/tools/perf/util/dso.c
9311 +++ b/tools/perf/util/dso.c
9312 @@ -295,7 +295,7 @@ static int decompress_kmodule(struct dso *dso, const char *name,
9313 unlink(tmpbuf);
9314
9315 if (pathname && (fd >= 0))
9316 - strncpy(pathname, tmpbuf, len);
9317 + strlcpy(pathname, tmpbuf, len);
9318
9319 return fd;
9320 }
9321 diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
9322 index 3cadc252dd89..bd9226bc5945 100644
9323 --- a/tools/perf/util/header.c
9324 +++ b/tools/perf/util/header.c
9325 @@ -2636,6 +2636,7 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)
9326 struct perf_header *header = &session->header;
9327 int fd = perf_data__fd(session->data);
9328 struct stat st;
9329 + time_t stctime;
9330 int ret, bit;
9331
9332 hd.fp = fp;
9333 @@ -2645,7 +2646,8 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)
9334 if (ret == -1)
9335 return -1;
9336
9337 - fprintf(fp, "# captured on : %s", ctime(&st.st_ctime));
9338 + stctime = st.st_ctime;
9339 + fprintf(fp, "# captured on : %s", ctime(&stctime));
9340
9341 fprintf(fp, "# header version : %u\n", header->version);
9342 fprintf(fp, "# data offset : %" PRIu64 "\n", header->data_offset);
9343 @@ -3521,7 +3523,7 @@ perf_event__synthesize_event_update_unit(struct perf_tool *tool,
9344 if (ev == NULL)
9345 return -ENOMEM;
9346
9347 - strncpy(ev->data, evsel->unit, size);
9348 + strlcpy(ev->data, evsel->unit, size + 1);
9349 err = process(tool, (union perf_event *)ev, NULL, NULL);
9350 free(ev);
9351 return err;
9352 diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
9353 index b76088fadf3d..6a6548890d5a 100644
9354 --- a/tools/perf/util/probe-file.c
9355 +++ b/tools/perf/util/probe-file.c
9356 @@ -424,7 +424,7 @@ static int probe_cache__open(struct probe_cache *pcache, const char *target,
9357
9358 if (target && build_id_cache__cached(target)) {
9359 /* This is a cached buildid */
9360 - strncpy(sbuildid, target, SBUILD_ID_SIZE);
9361 + strlcpy(sbuildid, target, SBUILD_ID_SIZE);
9362 dir_name = build_id_cache__linkname(sbuildid, NULL, 0);
9363 goto found;
9364 }
9365 diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
9366 index ce501ba14b08..69f5f6142dcf 100644
9367 --- a/tools/perf/util/python.c
9368 +++ b/tools/perf/util/python.c
9369 @@ -939,7 +939,8 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist,
9370
9371 file = PyFile_FromFile(fp, "perf", "r", NULL);
9372 #else
9373 - file = PyFile_FromFd(evlist->pollfd.entries[i].fd, "perf", "r", -1, NULL, NULL, NULL, 1);
9374 + file = PyFile_FromFd(evlist->pollfd.entries[i].fd, "perf", "r", -1,
9375 + NULL, NULL, NULL, 0);
9376 #endif
9377 if (file == NULL)
9378 goto free_list;
9379 diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c
9380 index d2c78ffd9fee..aa7f8c11fbb7 100644
9381 --- a/tools/perf/util/s390-cpumsf.c
9382 +++ b/tools/perf/util/s390-cpumsf.c
9383 @@ -499,7 +499,7 @@ static int s390_cpumsf_samples(struct s390_cpumsf_queue *sfq, u64 *ts)
9384 aux_ts = get_trailer_time(buf);
9385 if (!aux_ts) {
9386 pr_err("[%#08" PRIx64 "] Invalid AUX trailer entry TOD clock base\n",
9387 - sfq->buffer->data_offset);
9388 + (s64)sfq->buffer->data_offset);
9389 aux_ts = ~0ULL;
9390 goto out;
9391 }
9392 diff --git a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
9393 index 84e2b648e622..2fa3c5757bcb 100755
9394 --- a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
9395 +++ b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
9396 @@ -585,9 +585,9 @@ current_max_cpu = 0
9397
9398 read_trace_data(filename)
9399
9400 -clear_trace_file()
9401 -# Free the memory
9402 if interval:
9403 + clear_trace_file()
9404 + # Free the memory
9405 free_trace_buffer()
9406
9407 if graph_data_present == False:
9408 diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
9409 index 0ef68204c84b..d029cad08cbd 100644
9410 --- a/tools/testing/selftests/bpf/test_progs.c
9411 +++ b/tools/testing/selftests/bpf/test_progs.c
9412 @@ -51,10 +51,10 @@ static struct {
9413 struct iphdr iph;
9414 struct tcphdr tcp;
9415 } __packed pkt_v4 = {
9416 - .eth.h_proto = bpf_htons(ETH_P_IP),
9417 + .eth.h_proto = __bpf_constant_htons(ETH_P_IP),
9418 .iph.ihl = 5,
9419 .iph.protocol = 6,
9420 - .iph.tot_len = bpf_htons(MAGIC_BYTES),
9421 + .iph.tot_len = __bpf_constant_htons(MAGIC_BYTES),
9422 .tcp.urg_ptr = 123,
9423 };
9424
9425 @@ -64,9 +64,9 @@ static struct {
9426 struct ipv6hdr iph;
9427 struct tcphdr tcp;
9428 } __packed pkt_v6 = {
9429 - .eth.h_proto = bpf_htons(ETH_P_IPV6),
9430 + .eth.h_proto = __bpf_constant_htons(ETH_P_IPV6),
9431 .iph.nexthdr = 6,
9432 - .iph.payload_len = bpf_htons(MAGIC_BYTES),
9433 + .iph.payload_len = __bpf_constant_htons(MAGIC_BYTES),
9434 .tcp.urg_ptr = 123,
9435 };
9436
9437 diff --git a/virt/kvm/arm/mmio.c b/virt/kvm/arm/mmio.c
9438 index dac7ceb1a677..08443a15e6be 100644
9439 --- a/virt/kvm/arm/mmio.c
9440 +++ b/virt/kvm/arm/mmio.c
9441 @@ -117,6 +117,12 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run)
9442 vcpu_set_reg(vcpu, vcpu->arch.mmio_decode.rt, data);
9443 }
9444
9445 + /*
9446 + * The MMIO instruction is emulated and should not be re-executed
9447 + * in the guest.
9448 + */
9449 + kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
9450 +
9451 return 0;
9452 }
9453
9454 @@ -144,11 +150,6 @@ static int decode_hsr(struct kvm_vcpu *vcpu, bool *is_write, int *len)
9455 vcpu->arch.mmio_decode.sign_extend = sign_extend;
9456 vcpu->arch.mmio_decode.rt = rt;
9457
9458 - /*
9459 - * The MMIO instruction is emulated and should not be re-executed
9460 - * in the guest.
9461 - */
9462 - kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
9463 return 0;
9464 }
9465
9466 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
9467 index f986e31fa68c..0ffb02ff5234 100644
9468 --- a/virt/kvm/kvm_main.c
9469 +++ b/virt/kvm/kvm_main.c
9470 @@ -1959,7 +1959,8 @@ int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
9471 EXPORT_SYMBOL_GPL(kvm_gfn_to_hva_cache_init);
9472
9473 int kvm_write_guest_offset_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
9474 - void *data, int offset, unsigned long len)
9475 + void *data, unsigned int offset,
9476 + unsigned long len)
9477 {
9478 struct kvm_memslots *slots = kvm_memslots(kvm);
9479 int r;
9480 @@ -2912,8 +2913,10 @@ static int kvm_ioctl_create_device(struct kvm *kvm,
9481 if (ops->init)
9482 ops->init(dev);
9483
9484 + kvm_get_kvm(kvm);
9485 ret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC);
9486 if (ret < 0) {
9487 + kvm_put_kvm(kvm);
9488 mutex_lock(&kvm->lock);
9489 list_del(&dev->vm_node);
9490 mutex_unlock(&kvm->lock);
9491 @@ -2921,7 +2924,6 @@ static int kvm_ioctl_create_device(struct kvm *kvm,
9492 return ret;
9493 }
9494
9495 - kvm_get_kvm(kvm);
9496 cd->fd = ret;
9497 return 0;
9498 }