Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.14/0166-4.14.67-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3238 - (hide annotations) (download)
Fri Nov 9 12:14:58 2018 UTC (5 years, 7 months ago) by niro
File size: 219947 byte(s)
-added up to patches-4.14.79
1 niro 3238 diff --git a/Makefile b/Makefile
2     index e69d0d091742..4dad2d1c24ba 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,7 +1,7 @@
6     # SPDX-License-Identifier: GPL-2.0
7     VERSION = 4
8     PATCHLEVEL = 14
9     -SUBLEVEL = 66
10     +SUBLEVEL = 67
11     EXTRAVERSION =
12     NAME = Petit Gorille
13    
14     @@ -357,9 +357,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
15     else if [ -x /bin/bash ]; then echo /bin/bash; \
16     else echo sh; fi ; fi)
17    
18     -HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS)
19     -HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS)
20     -HOST_LFS_LIBS := $(shell getconf LFS_LIBS)
21     +HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
22     +HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
23     +HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
24    
25     HOSTCC = gcc
26     HOSTCXX = g++
27     diff --git a/arch/arc/Makefile b/arch/arc/Makefile
28     index d37f49d6a27f..6c1b20dd76ad 100644
29     --- a/arch/arc/Makefile
30     +++ b/arch/arc/Makefile
31     @@ -16,7 +16,7 @@ endif
32    
33     KBUILD_DEFCONFIG := nsim_700_defconfig
34    
35     -cflags-y += -fno-common -pipe -fno-builtin -D__linux__
36     +cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
37     cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7
38     cflags-$(CONFIG_ISA_ARCV2) += -mcpu=archs
39    
40     @@ -140,16 +140,3 @@ dtbs: scripts
41    
42     archclean:
43     $(Q)$(MAKE) $(clean)=$(boot)
44     -
45     -# Hacks to enable final link due to absence of link-time branch relexation
46     -# and gcc choosing optimal(shorter) branches at -O3
47     -#
48     -# vineetg Feb 2010: -mlong-calls switched off for overall kernel build
49     -# However lib/decompress_inflate.o (.init.text) calls
50     -# zlib_inflate_workspacesize (.text) causing relocation errors.
51     -# Thus forcing all exten calls in this file to be long calls
52     -export CFLAGS_decompress_inflate.o = -mmedium-calls
53     -export CFLAGS_initramfs.o = -mmedium-calls
54     -ifdef CONFIG_SMP
55     -export CFLAGS_core.o = -mmedium-calls
56     -endif
57     diff --git a/arch/arc/include/asm/mach_desc.h b/arch/arc/include/asm/mach_desc.h
58     index c28e6c347b49..871f3cb16af9 100644
59     --- a/arch/arc/include/asm/mach_desc.h
60     +++ b/arch/arc/include/asm/mach_desc.h
61     @@ -34,9 +34,7 @@ struct machine_desc {
62     const char *name;
63     const char **dt_compat;
64     void (*init_early)(void);
65     -#ifdef CONFIG_SMP
66     void (*init_per_cpu)(unsigned int);
67     -#endif
68     void (*init_machine)(void);
69     void (*init_late)(void);
70    
71     diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c
72     index 538b36afe89e..62b185057c04 100644
73     --- a/arch/arc/kernel/irq.c
74     +++ b/arch/arc/kernel/irq.c
75     @@ -31,10 +31,10 @@ void __init init_IRQ(void)
76     /* a SMP H/w block could do IPI IRQ request here */
77     if (plat_smp_ops.init_per_cpu)
78     plat_smp_ops.init_per_cpu(smp_processor_id());
79     +#endif
80    
81     if (machine_desc->init_per_cpu)
82     machine_desc->init_per_cpu(smp_processor_id());
83     -#endif
84     }
85    
86     /*
87     diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
88     index 5ac3b547453f..4674541eba3f 100644
89     --- a/arch/arc/kernel/process.c
90     +++ b/arch/arc/kernel/process.c
91     @@ -47,7 +47,8 @@ SYSCALL_DEFINE0(arc_gettls)
92     SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
93     {
94     struct pt_regs *regs = current_pt_regs();
95     - int uval = -EFAULT;
96     + u32 uval;
97     + int ret;
98    
99     /*
100     * This is only for old cores lacking LLOCK/SCOND, which by defintion
101     @@ -60,23 +61,47 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
102     /* Z indicates to userspace if operation succeded */
103     regs->status32 &= ~STATUS_Z_MASK;
104    
105     - if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
106     - return -EFAULT;
107     + ret = access_ok(VERIFY_WRITE, uaddr, sizeof(*uaddr));
108     + if (!ret)
109     + goto fail;
110    
111     +again:
112     preempt_disable();
113    
114     - if (__get_user(uval, uaddr))
115     - goto done;
116     + ret = __get_user(uval, uaddr);
117     + if (ret)
118     + goto fault;
119    
120     - if (uval == expected) {
121     - if (!__put_user(new, uaddr))
122     - regs->status32 |= STATUS_Z_MASK;
123     - }
124     + if (uval != expected)
125     + goto out;
126    
127     -done:
128     - preempt_enable();
129     + ret = __put_user(new, uaddr);
130     + if (ret)
131     + goto fault;
132     +
133     + regs->status32 |= STATUS_Z_MASK;
134    
135     +out:
136     + preempt_enable();
137     return uval;
138     +
139     +fault:
140     + preempt_enable();
141     +
142     + if (unlikely(ret != -EFAULT))
143     + goto fail;
144     +
145     + down_read(&current->mm->mmap_sem);
146     + ret = fixup_user_fault(current, current->mm, (unsigned long) uaddr,
147     + FAULT_FLAG_WRITE, NULL);
148     + up_read(&current->mm->mmap_sem);
149     +
150     + if (likely(!ret))
151     + goto again;
152     +
153     +fail:
154     + force_sig(SIGSEGV, current);
155     + return ret;
156     }
157    
158     #ifdef CONFIG_ISA_ARCV2
159     diff --git a/arch/arm/boot/dts/am3517.dtsi b/arch/arm/boot/dts/am3517.dtsi
160     index 00da3f2c4072..4b57094a0356 100644
161     --- a/arch/arm/boot/dts/am3517.dtsi
162     +++ b/arch/arm/boot/dts/am3517.dtsi
163     @@ -87,6 +87,11 @@
164     };
165     };
166    
167     +/* Table Table 5-79 of the TRM shows 480ab000 is reserved */
168     +&usb_otg_hs {
169     + status = "disabled";
170     +};
171     +
172     &iva {
173     status = "disabled";
174     };
175     diff --git a/arch/arm/boot/dts/am437x-sk-evm.dts b/arch/arm/boot/dts/am437x-sk-evm.dts
176     index 2c6bf0684f50..094fd0ea91a0 100644
177     --- a/arch/arm/boot/dts/am437x-sk-evm.dts
178     +++ b/arch/arm/boot/dts/am437x-sk-evm.dts
179     @@ -535,6 +535,8 @@
180    
181     touchscreen-size-x = <480>;
182     touchscreen-size-y = <272>;
183     +
184     + wakeup-source;
185     };
186    
187     tlv320aic3106: tlv320aic3106@1b {
188     diff --git a/arch/arm/boot/dts/armada-385-synology-ds116.dts b/arch/arm/boot/dts/armada-385-synology-ds116.dts
189     index 31510eb56f10..874189b4d218 100644
190     --- a/arch/arm/boot/dts/armada-385-synology-ds116.dts
191     +++ b/arch/arm/boot/dts/armada-385-synology-ds116.dts
192     @@ -170,7 +170,7 @@
193     3700 5
194     3900 6
195     4000 7>;
196     - cooling-cells = <2>;
197     + #cooling-cells = <2>;
198     };
199    
200     gpio-leds {
201     diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi b/arch/arm/boot/dts/bcm-cygnus.dtsi
202     index 9a9902974b1b..8b2c65cd61a2 100644
203     --- a/arch/arm/boot/dts/bcm-cygnus.dtsi
204     +++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
205     @@ -216,7 +216,7 @@
206     reg = <0x18008000 0x100>;
207     #address-cells = <1>;
208     #size-cells = <0>;
209     - interrupts = <GIC_SPI 85 IRQ_TYPE_NONE>;
210     + interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
211     clock-frequency = <100000>;
212     status = "disabled";
213     };
214     @@ -245,7 +245,7 @@
215     reg = <0x1800b000 0x100>;
216     #address-cells = <1>;
217     #size-cells = <0>;
218     - interrupts = <GIC_SPI 86 IRQ_TYPE_NONE>;
219     + interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
220     clock-frequency = <100000>;
221     status = "disabled";
222     };
223     @@ -256,7 +256,7 @@
224    
225     #interrupt-cells = <1>;
226     interrupt-map-mask = <0 0 0 0>;
227     - interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_NONE>;
228     + interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>;
229    
230     linux,pci-domain = <0>;
231    
232     @@ -278,10 +278,10 @@
233     compatible = "brcm,iproc-msi";
234     msi-controller;
235     interrupt-parent = <&gic>;
236     - interrupts = <GIC_SPI 96 IRQ_TYPE_NONE>,
237     - <GIC_SPI 97 IRQ_TYPE_NONE>,
238     - <GIC_SPI 98 IRQ_TYPE_NONE>,
239     - <GIC_SPI 99 IRQ_TYPE_NONE>;
240     + interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>,
241     + <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>,
242     + <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>,
243     + <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>;
244     };
245     };
246    
247     @@ -291,7 +291,7 @@
248    
249     #interrupt-cells = <1>;
250     interrupt-map-mask = <0 0 0 0>;
251     - interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_NONE>;
252     + interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
253    
254     linux,pci-domain = <1>;
255    
256     @@ -313,10 +313,10 @@
257     compatible = "brcm,iproc-msi";
258     msi-controller;
259     interrupt-parent = <&gic>;
260     - interrupts = <GIC_SPI 102 IRQ_TYPE_NONE>,
261     - <GIC_SPI 103 IRQ_TYPE_NONE>,
262     - <GIC_SPI 104 IRQ_TYPE_NONE>,
263     - <GIC_SPI 105 IRQ_TYPE_NONE>;
264     + interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>,
265     + <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
266     + <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>,
267     + <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>;
268     };
269     };
270    
271     diff --git a/arch/arm/boot/dts/bcm-nsp.dtsi b/arch/arm/boot/dts/bcm-nsp.dtsi
272     index d5f5e92e7488..1792192001a2 100644
273     --- a/arch/arm/boot/dts/bcm-nsp.dtsi
274     +++ b/arch/arm/boot/dts/bcm-nsp.dtsi
275     @@ -391,7 +391,7 @@
276     reg = <0x38000 0x50>;
277     #address-cells = <1>;
278     #size-cells = <0>;
279     - interrupts = <GIC_SPI 89 IRQ_TYPE_NONE>;
280     + interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
281     clock-frequency = <100000>;
282     dma-coherent;
283     status = "disabled";
284     @@ -496,7 +496,7 @@
285    
286     #interrupt-cells = <1>;
287     interrupt-map-mask = <0 0 0 0>;
288     - interrupt-map = <0 0 0 0 &gic GIC_SPI 131 IRQ_TYPE_NONE>;
289     + interrupt-map = <0 0 0 0 &gic GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
290    
291     linux,pci-domain = <0>;
292    
293     @@ -519,10 +519,10 @@
294     compatible = "brcm,iproc-msi";
295     msi-controller;
296     interrupt-parent = <&gic>;
297     - interrupts = <GIC_SPI 127 IRQ_TYPE_NONE>,
298     - <GIC_SPI 128 IRQ_TYPE_NONE>,
299     - <GIC_SPI 129 IRQ_TYPE_NONE>,
300     - <GIC_SPI 130 IRQ_TYPE_NONE>;
301     + interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>,
302     + <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>,
303     + <GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH>,
304     + <GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>;
305     brcm,pcie-msi-inten;
306     };
307     };
308     @@ -533,7 +533,7 @@
309    
310     #interrupt-cells = <1>;
311     interrupt-map-mask = <0 0 0 0>;
312     - interrupt-map = <0 0 0 0 &gic GIC_SPI 137 IRQ_TYPE_NONE>;
313     + interrupt-map = <0 0 0 0 &gic GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>;
314    
315     linux,pci-domain = <1>;
316    
317     @@ -556,10 +556,10 @@
318     compatible = "brcm,iproc-msi";
319     msi-controller;
320     interrupt-parent = <&gic>;
321     - interrupts = <GIC_SPI 133 IRQ_TYPE_NONE>,
322     - <GIC_SPI 134 IRQ_TYPE_NONE>,
323     - <GIC_SPI 135 IRQ_TYPE_NONE>,
324     - <GIC_SPI 136 IRQ_TYPE_NONE>;
325     + interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>,
326     + <GIC_SPI 134 IRQ_TYPE_LEVEL_HIGH>,
327     + <GIC_SPI 135 IRQ_TYPE_LEVEL_HIGH>,
328     + <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
329     brcm,pcie-msi-inten;
330     };
331     };
332     @@ -570,7 +570,7 @@
333    
334     #interrupt-cells = <1>;
335     interrupt-map-mask = <0 0 0 0>;
336     - interrupt-map = <0 0 0 0 &gic GIC_SPI 143 IRQ_TYPE_NONE>;
337     + interrupt-map = <0 0 0 0 &gic GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
338    
339     linux,pci-domain = <2>;
340    
341     @@ -593,10 +593,10 @@
342     compatible = "brcm,iproc-msi";
343     msi-controller;
344     interrupt-parent = <&gic>;
345     - interrupts = <GIC_SPI 139 IRQ_TYPE_NONE>,
346     - <GIC_SPI 140 IRQ_TYPE_NONE>,
347     - <GIC_SPI 141 IRQ_TYPE_NONE>,
348     - <GIC_SPI 142 IRQ_TYPE_NONE>;
349     + interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>,
350     + <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>,
351     + <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>,
352     + <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>;
353     brcm,pcie-msi-inten;
354     };
355     };
356     diff --git a/arch/arm/boot/dts/bcm5301x.dtsi b/arch/arm/boot/dts/bcm5301x.dtsi
357     index 045b9bb857f9..501877e87a5b 100644
358     --- a/arch/arm/boot/dts/bcm5301x.dtsi
359     +++ b/arch/arm/boot/dts/bcm5301x.dtsi
360     @@ -365,7 +365,7 @@
361     i2c0: i2c@18009000 {
362     compatible = "brcm,iproc-i2c";
363     reg = <0x18009000 0x50>;
364     - interrupts = <GIC_SPI 121 IRQ_TYPE_NONE>;
365     + interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
366     #address-cells = <1>;
367     #size-cells = <0>;
368     clock-frequency = <100000>;
369     diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
370     index 8a15f7193c82..77dd62e260db 100644
371     --- a/arch/arm/boot/dts/da850.dtsi
372     +++ b/arch/arm/boot/dts/da850.dtsi
373     @@ -518,11 +518,7 @@
374     gpio-controller;
375     #gpio-cells = <2>;
376     reg = <0x226000 0x1000>;
377     - interrupts = <42 IRQ_TYPE_EDGE_BOTH
378     - 43 IRQ_TYPE_EDGE_BOTH 44 IRQ_TYPE_EDGE_BOTH
379     - 45 IRQ_TYPE_EDGE_BOTH 46 IRQ_TYPE_EDGE_BOTH
380     - 47 IRQ_TYPE_EDGE_BOTH 48 IRQ_TYPE_EDGE_BOTH
381     - 49 IRQ_TYPE_EDGE_BOTH 50 IRQ_TYPE_EDGE_BOTH>;
382     + interrupts = <42 43 44 45 46 47 48 49 50>;
383     ti,ngpio = <144>;
384     ti,davinci-gpio-unbanked = <0>;
385     status = "disabled";
386     diff --git a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
387     index eeb7679fd348..849eb3443cde 100644
388     --- a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
389     +++ b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
390     @@ -644,7 +644,7 @@
391     dsa,member = <0 0>;
392     eeprom-length = <512>;
393     interrupt-parent = <&gpio6>;
394     - interrupts = <3 IRQ_TYPE_EDGE_FALLING>;
395     + interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
396     interrupt-controller;
397     #interrupt-cells = <2>;
398    
399     diff --git a/arch/arm/configs/imx_v4_v5_defconfig b/arch/arm/configs/imx_v4_v5_defconfig
400     index ca0f13cafe38..6e5a3d9c23e1 100644
401     --- a/arch/arm/configs/imx_v4_v5_defconfig
402     +++ b/arch/arm/configs/imx_v4_v5_defconfig
403     @@ -144,9 +144,11 @@ CONFIG_USB_STORAGE=y
404     CONFIG_USB_CHIPIDEA=y
405     CONFIG_USB_CHIPIDEA_UDC=y
406     CONFIG_USB_CHIPIDEA_HOST=y
407     +CONFIG_USB_CHIPIDEA_ULPI=y
408     CONFIG_NOP_USB_XCEIV=y
409     CONFIG_USB_GADGET=y
410     CONFIG_USB_ETH=m
411     +CONFIG_USB_ULPI_BUS=y
412     CONFIG_MMC=y
413     CONFIG_MMC_SDHCI=y
414     CONFIG_MMC_SDHCI_PLTFM=y
415     diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
416     index 32acac9ab81a..21ac9f02407e 100644
417     --- a/arch/arm/configs/imx_v6_v7_defconfig
418     +++ b/arch/arm/configs/imx_v6_v7_defconfig
419     @@ -289,6 +289,7 @@ CONFIG_USB_STORAGE=y
420     CONFIG_USB_CHIPIDEA=y
421     CONFIG_USB_CHIPIDEA_UDC=y
422     CONFIG_USB_CHIPIDEA_HOST=y
423     +CONFIG_USB_CHIPIDEA_ULPI=y
424     CONFIG_USB_SERIAL=m
425     CONFIG_USB_SERIAL_GENERIC=y
426     CONFIG_USB_SERIAL_FTDI_SIO=m
427     @@ -325,6 +326,7 @@ CONFIG_USB_GADGETFS=m
428     CONFIG_USB_FUNCTIONFS=m
429     CONFIG_USB_MASS_STORAGE=m
430     CONFIG_USB_G_SERIAL=m
431     +CONFIG_USB_ULPI_BUS=y
432     CONFIG_MMC=y
433     CONFIG_MMC_SDHCI=y
434     CONFIG_MMC_SDHCI_PLTFM=y
435     diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
436     index 25f12118c364..2f6ac1afa804 100644
437     --- a/arch/arm/mach-davinci/board-da850-evm.c
438     +++ b/arch/arm/mach-davinci/board-da850-evm.c
439     @@ -773,7 +773,7 @@ static struct gpiod_lookup_table mmc_gpios_table = {
440     GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_CD_PIN, "cd",
441     GPIO_ACTIVE_LOW),
442     GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_WP_PIN, "wp",
443     - GPIO_ACTIVE_LOW),
444     + GPIO_ACTIVE_HIGH),
445     },
446     };
447    
448     diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
449     index 69df3620eca5..1c73694c871a 100644
450     --- a/arch/arm/mach-omap2/omap-smp.c
451     +++ b/arch/arm/mach-omap2/omap-smp.c
452     @@ -109,6 +109,45 @@ void omap5_erratum_workaround_801819(void)
453     static inline void omap5_erratum_workaround_801819(void) { }
454     #endif
455    
456     +#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
457     +/*
458     + * Configure ACR and enable ACTLR[0] (Enable invalidates of BTB with
459     + * ICIALLU) to activate the workaround for secondary Core.
460     + * NOTE: it is assumed that the primary core's configuration is done
461     + * by the boot loader (kernel will detect a misconfiguration and complain
462     + * if this is not done).
463     + *
464     + * In General Purpose(GP) devices, ACR bit settings can only be done
465     + * by ROM code in "secure world" using the smc call and there is no
466     + * option to update the "firmware" on such devices. This also works for
467     + * High security(HS) devices, as a backup option in case the
468     + * "update" is not done in the "security firmware".
469     + */
470     +static void omap5_secondary_harden_predictor(void)
471     +{
472     + u32 acr, acr_mask;
473     +
474     + asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
475     +
476     + /*
477     + * ACTLR[0] (Enable invalidates of BTB with ICIALLU)
478     + */
479     + acr_mask = BIT(0);
480     +
481     + /* Do we already have it done.. if yes, skip expensive smc */
482     + if ((acr & acr_mask) == acr_mask)
483     + return;
484     +
485     + acr |= acr_mask;
486     + omap_smc1(OMAP5_DRA7_MON_SET_ACR_INDEX, acr);
487     +
488     + pr_debug("%s: ARM ACR setup for CVE_2017_5715 applied on CPU%d\n",
489     + __func__, smp_processor_id());
490     +}
491     +#else
492     +static inline void omap5_secondary_harden_predictor(void) { }
493     +#endif
494     +
495     static void omap4_secondary_init(unsigned int cpu)
496     {
497     /*
498     @@ -131,6 +170,8 @@ static void omap4_secondary_init(unsigned int cpu)
499     set_cntfreq();
500     /* Configure ACR to disable streaming WA for 801819 */
501     omap5_erratum_workaround_801819();
502     + /* Enable ACR to allow for ICUALLU workaround */
503     + omap5_secondary_harden_predictor();
504     }
505    
506     /*
507     diff --git a/arch/arm/mach-pxa/irq.c b/arch/arm/mach-pxa/irq.c
508     index 9c10248fadcc..4e8c2116808e 100644
509     --- a/arch/arm/mach-pxa/irq.c
510     +++ b/arch/arm/mach-pxa/irq.c
511     @@ -185,7 +185,7 @@ static int pxa_irq_suspend(void)
512     {
513     int i;
514    
515     - for (i = 0; i < pxa_internal_irq_nr / 32; i++) {
516     + for (i = 0; i < DIV_ROUND_UP(pxa_internal_irq_nr, 32); i++) {
517     void __iomem *base = irq_base(i);
518    
519     saved_icmr[i] = __raw_readl(base + ICMR);
520     @@ -204,7 +204,7 @@ static void pxa_irq_resume(void)
521     {
522     int i;
523    
524     - for (i = 0; i < pxa_internal_irq_nr / 32; i++) {
525     + for (i = 0; i < DIV_ROUND_UP(pxa_internal_irq_nr, 32); i++) {
526     void __iomem *base = irq_base(i);
527    
528     __raw_writel(saved_icmr[i], base + ICMR);
529     diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
530     index 0f6d1537f330..defb7fc26428 100644
531     --- a/arch/arm/mm/init.c
532     +++ b/arch/arm/mm/init.c
533     @@ -745,19 +745,28 @@ static int __mark_rodata_ro(void *unused)
534     return 0;
535     }
536    
537     +static int kernel_set_to_readonly __read_mostly;
538     +
539     void mark_rodata_ro(void)
540     {
541     + kernel_set_to_readonly = 1;
542     stop_machine(__mark_rodata_ro, NULL, NULL);
543     }
544    
545     void set_kernel_text_rw(void)
546     {
547     + if (!kernel_set_to_readonly)
548     + return;
549     +
550     set_section_perms(ro_perms, ARRAY_SIZE(ro_perms), false,
551     current->active_mm);
552     }
553    
554     void set_kernel_text_ro(void)
555     {
556     + if (!kernel_set_to_readonly)
557     + return;
558     +
559     set_section_perms(ro_perms, ARRAY_SIZE(ro_perms), true,
560     current->active_mm);
561     }
562     diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
563     index f06cc234693b..379abc3d82fe 100644
564     --- a/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
565     +++ b/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
566     @@ -7,7 +7,7 @@
567    
568     &apb {
569     mali: gpu@c0000 {
570     - compatible = "amlogic,meson-gxbb-mali", "arm,mali-450";
571     + compatible = "amlogic,meson-gxl-mali", "arm,mali-450";
572     reg = <0x0 0xc0000 0x0 0x40000>;
573     interrupts = <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
574     <GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>,
575     diff --git a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
576     index 35c8457e3d1f..0b72094bcf5a 100644
577     --- a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
578     +++ b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
579     @@ -118,7 +118,7 @@
580    
581     #interrupt-cells = <1>;
582     interrupt-map-mask = <0 0 0 0>;
583     - interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 281 IRQ_TYPE_NONE>;
584     + interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 281 IRQ_TYPE_LEVEL_HIGH>;
585    
586     linux,pci-domain = <0>;
587    
588     @@ -149,7 +149,7 @@
589    
590     #interrupt-cells = <1>;
591     interrupt-map-mask = <0 0 0 0>;
592     - interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 305 IRQ_TYPE_NONE>;
593     + interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 305 IRQ_TYPE_LEVEL_HIGH>;
594    
595     linux,pci-domain = <4>;
596    
597     @@ -566,7 +566,7 @@
598     reg = <0x66080000 0x100>;
599     #address-cells = <1>;
600     #size-cells = <0>;
601     - interrupts = <GIC_SPI 394 IRQ_TYPE_NONE>;
602     + interrupts = <GIC_SPI 394 IRQ_TYPE_LEVEL_HIGH>;
603     clock-frequency = <100000>;
604     status = "disabled";
605     };
606     @@ -594,7 +594,7 @@
607     reg = <0x660b0000 0x100>;
608     #address-cells = <1>;
609     #size-cells = <0>;
610     - interrupts = <GIC_SPI 395 IRQ_TYPE_NONE>;
611     + interrupts = <GIC_SPI 395 IRQ_TYPE_LEVEL_HIGH>;
612     clock-frequency = <100000>;
613     status = "disabled";
614     };
615     diff --git a/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts b/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
616     index eb6f08cdbd79..77efa28c4dd5 100644
617     --- a/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
618     +++ b/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
619     @@ -43,6 +43,10 @@
620     enet-phy-lane-swap;
621     };
622    
623     +&sdio0 {
624     + mmc-ddr-1_8v;
625     +};
626     +
627     &uart2 {
628     status = "okay";
629     };
630     diff --git a/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts b/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
631     index 5084b037320f..55ba495ef56e 100644
632     --- a/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
633     +++ b/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
634     @@ -42,3 +42,7 @@
635     &gphy0 {
636     enet-phy-lane-swap;
637     };
638     +
639     +&sdio0 {
640     + mmc-ddr-1_8v;
641     +};
642     diff --git a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
643     index e6f75c633623..2b76293b51c8 100644
644     --- a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
645     +++ b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
646     @@ -409,7 +409,7 @@
647     reg = <0x000b0000 0x100>;
648     #address-cells = <1>;
649     #size-cells = <0>;
650     - interrupts = <GIC_SPI 177 IRQ_TYPE_NONE>;
651     + interrupts = <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>;
652     clock-frequency = <100000>;
653     status = "disabled";
654     };
655     @@ -453,7 +453,7 @@
656     reg = <0x000e0000 0x100>;
657     #address-cells = <1>;
658     #size-cells = <0>;
659     - interrupts = <GIC_SPI 178 IRQ_TYPE_NONE>;
660     + interrupts = <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>;
661     clock-frequency = <100000>;
662     status = "disabled";
663     };
664     diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
665     index 61da6e65900b..3cc449425a03 100644
666     --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
667     +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
668     @@ -1132,14 +1132,14 @@
669    
670     port@0 {
671     reg = <0>;
672     - etf_out: endpoint {
673     + etf_in: endpoint {
674     slave-mode;
675     remote-endpoint = <&funnel0_out>;
676     };
677     };
678     port@1 {
679     reg = <0>;
680     - etf_in: endpoint {
681     + etf_out: endpoint {
682     remote-endpoint = <&replicator_in>;
683     };
684     };
685     diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
686     index 9f7195a5773e..b7ad41d7b6ee 100644
687     --- a/arch/arm64/kernel/smp.c
688     +++ b/arch/arm64/kernel/smp.c
689     @@ -214,7 +214,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
690     * This is the secondary CPU boot entry. We're using this CPUs
691     * idle thread stack, but a set of temporary page tables.
692     */
693     -asmlinkage void secondary_start_kernel(void)
694     +asmlinkage notrace void secondary_start_kernel(void)
695     {
696     struct mm_struct *mm = &init_mm;
697     unsigned int cpu;
698     diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
699     index 614af886b7ef..58470b151bc3 100644
700     --- a/arch/arm64/mm/dma-mapping.c
701     +++ b/arch/arm64/mm/dma-mapping.c
702     @@ -629,13 +629,14 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size,
703     size >> PAGE_SHIFT);
704     return NULL;
705     }
706     - if (!coherent)
707     - __dma_flush_area(page_to_virt(page), iosize);
708     -
709     addr = dma_common_contiguous_remap(page, size, VM_USERMAP,
710     prot,
711     __builtin_return_address(0));
712     - if (!addr) {
713     + if (addr) {
714     + memset(addr, 0, size);
715     + if (!coherent)
716     + __dma_flush_area(page_to_virt(page), iosize);
717     + } else {
718     iommu_dma_unmap_page(dev, *handle, iosize, 0, attrs);
719     dma_release_from_contiguous(dev, page,
720     size >> PAGE_SHIFT);
721     diff --git a/arch/m68k/include/asm/mcf_pgalloc.h b/arch/m68k/include/asm/mcf_pgalloc.h
722     index 8b707c249026..12fe700632f4 100644
723     --- a/arch/m68k/include/asm/mcf_pgalloc.h
724     +++ b/arch/m68k/include/asm/mcf_pgalloc.h
725     @@ -44,6 +44,7 @@ extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address)
726     static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page,
727     unsigned long address)
728     {
729     + pgtable_page_dtor(page);
730     __free_page(page);
731     }
732    
733     @@ -74,8 +75,9 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm,
734     return page;
735     }
736    
737     -extern inline void pte_free(struct mm_struct *mm, struct page *page)
738     +static inline void pte_free(struct mm_struct *mm, struct page *page)
739     {
740     + pgtable_page_dtor(page);
741     __free_page(page);
742     }
743    
744     diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
745     index 1b7160c79646..b16e95a4e875 100644
746     --- a/arch/openrisc/kernel/entry.S
747     +++ b/arch/openrisc/kernel/entry.S
748     @@ -221,12 +221,6 @@ EXCEPTION_ENTRY(_data_page_fault_handler)
749     l.addi r3,r1,0 // pt_regs
750     /* r4 set be EXCEPTION_HANDLE */ // effective address of fault
751    
752     - /*
753     - * __PHX__: TODO
754     - *
755     - * all this can be written much simpler. look at
756     - * DTLB miss handler in the CONFIG_GUARD_PROTECTED_CORE part
757     - */
758     #ifdef CONFIG_OPENRISC_NO_SPR_SR_DSX
759     l.lwz r6,PT_PC(r3) // address of an offending insn
760     l.lwz r6,0(r6) // instruction that caused pf
761     @@ -258,7 +252,7 @@ EXCEPTION_ENTRY(_data_page_fault_handler)
762    
763     #else
764    
765     - l.lwz r6,PT_SR(r3) // SR
766     + l.mfspr r6,r0,SPR_SR // SR
767     l.andi r6,r6,SPR_SR_DSX // check for delay slot exception
768     l.sfne r6,r0 // exception happened in delay slot
769     l.bnf 7f
770     diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S
771     index 1e87913576e3..90979acdf165 100644
772     --- a/arch/openrisc/kernel/head.S
773     +++ b/arch/openrisc/kernel/head.S
774     @@ -141,8 +141,7 @@
775     * r4 - EEAR exception EA
776     * r10 - current pointing to current_thread_info struct
777     * r12 - syscall 0, since we didn't come from syscall
778     - * r13 - temp it actually contains new SR, not needed anymore
779     - * r31 - handler address of the handler we'll jump to
780     + * r30 - handler address of the handler we'll jump to
781     *
782     * handler has to save remaining registers to the exception
783     * ksp frame *before* tainting them!
784     @@ -178,6 +177,7 @@
785     /* r1 is KSP, r30 is __pa(KSP) */ ;\
786     tophys (r30,r1) ;\
787     l.sw PT_GPR12(r30),r12 ;\
788     + /* r4 use for tmp before EA */ ;\
789     l.mfspr r12,r0,SPR_EPCR_BASE ;\
790     l.sw PT_PC(r30),r12 ;\
791     l.mfspr r12,r0,SPR_ESR_BASE ;\
792     @@ -197,7 +197,10 @@
793     /* r12 == 1 if we come from syscall */ ;\
794     CLEAR_GPR(r12) ;\
795     /* ----- turn on MMU ----- */ ;\
796     - l.ori r30,r0,(EXCEPTION_SR) ;\
797     + /* Carry DSX into exception SR */ ;\
798     + l.mfspr r30,r0,SPR_SR ;\
799     + l.andi r30,r30,SPR_SR_DSX ;\
800     + l.ori r30,r30,(EXCEPTION_SR) ;\
801     l.mtspr r0,r30,SPR_ESR_BASE ;\
802     /* r30: EA address of handler */ ;\
803     LOAD_SYMBOL_2_GPR(r30,handler) ;\
804     diff --git a/arch/openrisc/kernel/traps.c b/arch/openrisc/kernel/traps.c
805     index 8d8437169b5e..0d44e8007ad6 100644
806     --- a/arch/openrisc/kernel/traps.c
807     +++ b/arch/openrisc/kernel/traps.c
808     @@ -358,7 +358,7 @@ static inline int in_delay_slot(struct pt_regs *regs)
809     return 0;
810     }
811     #else
812     - return regs->sr & SPR_SR_DSX;
813     + return mfspr(SPR_SR) & SPR_SR_DSX;
814     #endif
815     }
816    
817     diff --git a/arch/parisc/include/asm/spinlock.h b/arch/parisc/include/asm/spinlock.h
818     index af03359e6ac5..a82776592c8e 100644
819     --- a/arch/parisc/include/asm/spinlock.h
820     +++ b/arch/parisc/include/asm/spinlock.h
821     @@ -20,7 +20,6 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *x,
822     {
823     volatile unsigned int *a;
824    
825     - mb();
826     a = __ldcw_align(x);
827     while (__ldcw(a) == 0)
828     while (*a == 0)
829     @@ -30,16 +29,15 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *x,
830     local_irq_disable();
831     } else
832     cpu_relax();
833     - mb();
834     }
835    
836     static inline void arch_spin_unlock(arch_spinlock_t *x)
837     {
838     volatile unsigned int *a;
839     - mb();
840     +
841     a = __ldcw_align(x);
842     - *a = 1;
843     mb();
844     + *a = 1;
845     }
846    
847     static inline int arch_spin_trylock(arch_spinlock_t *x)
848     @@ -47,10 +45,8 @@ static inline int arch_spin_trylock(arch_spinlock_t *x)
849     volatile unsigned int *a;
850     int ret;
851    
852     - mb();
853     a = __ldcw_align(x);
854     ret = __ldcw(a) != 0;
855     - mb();
856    
857     return ret;
858     }
859     diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
860     index 4886a6db42e9..5f7e57fcaeef 100644
861     --- a/arch/parisc/kernel/syscall.S
862     +++ b/arch/parisc/kernel/syscall.S
863     @@ -629,12 +629,12 @@ cas_action:
864     stw %r1, 4(%sr2,%r20)
865     #endif
866     /* The load and store could fail */
867     -1: ldw,ma 0(%r26), %r28
868     +1: ldw 0(%r26), %r28
869     sub,<> %r28, %r25, %r0
870     -2: stw,ma %r24, 0(%r26)
871     +2: stw %r24, 0(%r26)
872     /* Free lock */
873     sync
874     - stw,ma %r20, 0(%sr2,%r20)
875     + stw %r20, 0(%sr2,%r20)
876     #if ENABLE_LWS_DEBUG
877     /* Clear thread register indicator */
878     stw %r0, 4(%sr2,%r20)
879     @@ -798,30 +798,30 @@ cas2_action:
880     ldo 1(%r0),%r28
881    
882     /* 8bit CAS */
883     -13: ldb,ma 0(%r26), %r29
884     +13: ldb 0(%r26), %r29
885     sub,= %r29, %r25, %r0
886     b,n cas2_end
887     -14: stb,ma %r24, 0(%r26)
888     +14: stb %r24, 0(%r26)
889     b cas2_end
890     copy %r0, %r28
891     nop
892     nop
893    
894     /* 16bit CAS */
895     -15: ldh,ma 0(%r26), %r29
896     +15: ldh 0(%r26), %r29
897     sub,= %r29, %r25, %r0
898     b,n cas2_end
899     -16: sth,ma %r24, 0(%r26)
900     +16: sth %r24, 0(%r26)
901     b cas2_end
902     copy %r0, %r28
903     nop
904     nop
905    
906     /* 32bit CAS */
907     -17: ldw,ma 0(%r26), %r29
908     +17: ldw 0(%r26), %r29
909     sub,= %r29, %r25, %r0
910     b,n cas2_end
911     -18: stw,ma %r24, 0(%r26)
912     +18: stw %r24, 0(%r26)
913     b cas2_end
914     copy %r0, %r28
915     nop
916     @@ -829,10 +829,10 @@ cas2_action:
917    
918     /* 64bit CAS */
919     #ifdef CONFIG_64BIT
920     -19: ldd,ma 0(%r26), %r29
921     +19: ldd 0(%r26), %r29
922     sub,*= %r29, %r25, %r0
923     b,n cas2_end
924     -20: std,ma %r24, 0(%r26)
925     +20: std %r24, 0(%r26)
926     copy %r0, %r28
927     #else
928     /* Compare first word */
929     @@ -851,7 +851,7 @@ cas2_action:
930     cas2_end:
931     /* Free lock */
932     sync
933     - stw,ma %r20, 0(%sr2,%r20)
934     + stw %r20, 0(%sr2,%r20)
935     /* Enable interrupts */
936     ssm PSW_SM_I, %r0
937     /* Return to userspace, set no error */
938     diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
939     index 11cd151733d4..45f1ea117128 100644
940     --- a/arch/s390/net/bpf_jit_comp.c
941     +++ b/arch/s390/net/bpf_jit_comp.c
942     @@ -1403,6 +1403,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
943     goto free_addrs;
944     }
945     if (bpf_jit_prog(&jit, fp)) {
946     + bpf_jit_binary_free(header);
947     fp = orig_fp;
948     goto free_addrs;
949     }
950     diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
951     index 1c2cfa0644aa..97ccf4c3b45b 100644
952     --- a/arch/x86/kernel/cpu/microcode/intel.c
953     +++ b/arch/x86/kernel/cpu/microcode/intel.c
954     @@ -190,8 +190,11 @@ static void save_microcode_patch(void *data, unsigned int size)
955     p = memdup_patch(data, size);
956     if (!p)
957     pr_err("Error allocating buffer %p\n", data);
958     - else
959     + else {
960     list_replace(&iter->plist, &p->plist);
961     + kfree(iter->data);
962     + kfree(iter);
963     + }
964     }
965     }
966    
967     diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
968     index 5b609e28ce3f..48703d430a2f 100644
969     --- a/arch/x86/kernel/kvmclock.c
970     +++ b/arch/x86/kernel/kvmclock.c
971     @@ -143,6 +143,7 @@ static unsigned long kvm_get_tsc_khz(void)
972     src = &hv_clock[cpu].pvti;
973     tsc_khz = pvclock_tsc_khz(src);
974     put_cpu();
975     + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
976     return tsc_khz;
977     }
978    
979     diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
980     index 5ebb0dbcf4f7..30447d210f37 100644
981     --- a/arch/x86/kernel/smpboot.c
982     +++ b/arch/x86/kernel/smpboot.c
983     @@ -223,6 +223,11 @@ static void notrace start_secondary(void *unused)
984     #ifdef CONFIG_X86_32
985     /* switch away from the initial page table */
986     load_cr3(swapper_pg_dir);
987     + /*
988     + * Initialize the CR4 shadow before doing anything that could
989     + * try to read it.
990     + */
991     + cr4_init_shadow();
992     __flush_tlb_all();
993     #endif
994     load_current_idt();
995     diff --git a/block/sed-opal.c b/block/sed-opal.c
996     index 9ed51d0c6b1d..4f5e70d4abc3 100644
997     --- a/block/sed-opal.c
998     +++ b/block/sed-opal.c
999     @@ -877,7 +877,7 @@ static size_t response_get_string(const struct parsed_resp *resp, int n,
1000     return 0;
1001     }
1002    
1003     - if (n > resp->num) {
1004     + if (n >= resp->num) {
1005     pr_debug("Response has %d tokens. Can't access %d\n",
1006     resp->num, n);
1007     return 0;
1008     @@ -899,7 +899,7 @@ static u64 response_get_u64(const struct parsed_resp *resp, int n)
1009     return 0;
1010     }
1011    
1012     - if (n > resp->num) {
1013     + if (n >= resp->num) {
1014     pr_debug("Response has %d tokens. Can't access %d\n",
1015     resp->num, n);
1016     return 0;
1017     diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
1018     index 58bc28aff3aa..3d624c72c6c2 100644
1019     --- a/drivers/acpi/ec.c
1020     +++ b/drivers/acpi/ec.c
1021     @@ -2029,6 +2029,17 @@ static inline void acpi_ec_query_exit(void)
1022     }
1023     }
1024    
1025     +static const struct dmi_system_id acpi_ec_no_wakeup[] = {
1026     + {
1027     + .ident = "Thinkpad X1 Carbon 6th",
1028     + .matches = {
1029     + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1030     + DMI_MATCH(DMI_PRODUCT_FAMILY, "Thinkpad X1 Carbon 6th"),
1031     + },
1032     + },
1033     + { },
1034     +};
1035     +
1036     int __init acpi_ec_init(void)
1037     {
1038     int result;
1039     @@ -2039,6 +2050,15 @@ int __init acpi_ec_init(void)
1040     if (result)
1041     return result;
1042    
1043     + /*
1044     + * Disable EC wakeup on following systems to prevent periodic
1045     + * wakeup from EC GPE.
1046     + */
1047     + if (dmi_check_system(acpi_ec_no_wakeup)) {
1048     + ec_no_wakeup = true;
1049     + pr_debug("Disabling EC wakeup on suspend-to-idle\n");
1050     + }
1051     +
1052     /* Drivers must be started after acpi_ec_query_init() */
1053     dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver);
1054     /*
1055     diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
1056     index d56822f58ab1..8260b90eb64b 100644
1057     --- a/drivers/acpi/nfit/core.c
1058     +++ b/drivers/acpi/nfit/core.c
1059     @@ -224,6 +224,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
1060     const guid_t *guid;
1061     int rc, i;
1062    
1063     + if (cmd_rc)
1064     + *cmd_rc = -EINVAL;
1065     func = cmd;
1066     if (cmd == ND_CMD_CALL) {
1067     call_pkg = buf;
1068     @@ -314,6 +316,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
1069     * If we return an error (like elsewhere) then caller wouldn't
1070     * be able to rely upon data returned to make calculation.
1071     */
1072     + if (cmd_rc)
1073     + *cmd_rc = 0;
1074     return 0;
1075     }
1076    
1077     diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
1078     index 5ae268b8514e..bc562fd2b0a0 100644
1079     --- a/drivers/ata/libahci.c
1080     +++ b/drivers/ata/libahci.c
1081     @@ -35,6 +35,7 @@
1082     #include <linux/kernel.h>
1083     #include <linux/gfp.h>
1084     #include <linux/module.h>
1085     +#include <linux/nospec.h>
1086     #include <linux/blkdev.h>
1087     #include <linux/delay.h>
1088     #include <linux/interrupt.h>
1089     @@ -1135,10 +1136,12 @@ static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
1090    
1091     /* get the slot number from the message */
1092     pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
1093     - if (pmp < EM_MAX_SLOTS)
1094     + if (pmp < EM_MAX_SLOTS) {
1095     + pmp = array_index_nospec(pmp, EM_MAX_SLOTS);
1096     emp = &pp->em_priv[pmp];
1097     - else
1098     + } else {
1099     return -EINVAL;
1100     + }
1101    
1102     /* mask off the activity bits if we are in sw_activity
1103     * mode, user should turn off sw_activity before setting
1104     diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
1105     index de8566e55334..c72071c300bb 100644
1106     --- a/drivers/block/drbd/drbd_req.c
1107     +++ b/drivers/block/drbd/drbd_req.c
1108     @@ -1244,8 +1244,8 @@ drbd_request_prepare(struct drbd_device *device, struct bio *bio, unsigned long
1109     _drbd_start_io_acct(device, req);
1110    
1111     /* process discards always from our submitter thread */
1112     - if ((bio_op(bio) & REQ_OP_WRITE_ZEROES) ||
1113     - (bio_op(bio) & REQ_OP_DISCARD))
1114     + if (bio_op(bio) == REQ_OP_WRITE_ZEROES ||
1115     + bio_op(bio) == REQ_OP_DISCARD)
1116     goto queue_for_submitter_thread;
1117    
1118     if (rw == WRITE && req->private_bio && req->i.size
1119     diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
1120     index 6fb64e73bc96..5feba04ab940 100644
1121     --- a/drivers/block/nbd.c
1122     +++ b/drivers/block/nbd.c
1123     @@ -76,6 +76,7 @@ struct link_dead_args {
1124     #define NBD_HAS_CONFIG_REF 4
1125     #define NBD_BOUND 5
1126     #define NBD_DESTROY_ON_DISCONNECT 6
1127     +#define NBD_DISCONNECT_ON_CLOSE 7
1128    
1129     struct nbd_config {
1130     u32 flags;
1131     @@ -138,6 +139,7 @@ static void nbd_config_put(struct nbd_device *nbd);
1132     static void nbd_connect_reply(struct genl_info *info, int index);
1133     static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info);
1134     static void nbd_dead_link_work(struct work_struct *work);
1135     +static void nbd_disconnect_and_put(struct nbd_device *nbd);
1136    
1137     static inline struct device *nbd_to_dev(struct nbd_device *nbd)
1138     {
1139     @@ -1291,6 +1293,12 @@ out:
1140     static void nbd_release(struct gendisk *disk, fmode_t mode)
1141     {
1142     struct nbd_device *nbd = disk->private_data;
1143     + struct block_device *bdev = bdget_disk(disk, 0);
1144     +
1145     + if (test_bit(NBD_DISCONNECT_ON_CLOSE, &nbd->config->runtime_flags) &&
1146     + bdev->bd_openers == 0)
1147     + nbd_disconnect_and_put(nbd);
1148     +
1149     nbd_config_put(nbd);
1150     nbd_put(nbd);
1151     }
1152     @@ -1690,6 +1698,10 @@ again:
1153     &config->runtime_flags);
1154     put_dev = true;
1155     }
1156     + if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) {
1157     + set_bit(NBD_DISCONNECT_ON_CLOSE,
1158     + &config->runtime_flags);
1159     + }
1160     }
1161    
1162     if (info->attrs[NBD_ATTR_SOCKETS]) {
1163     @@ -1734,6 +1746,16 @@ out:
1164     return ret;
1165     }
1166    
1167     +static void nbd_disconnect_and_put(struct nbd_device *nbd)
1168     +{
1169     + mutex_lock(&nbd->config_lock);
1170     + nbd_disconnect(nbd);
1171     + mutex_unlock(&nbd->config_lock);
1172     + if (test_and_clear_bit(NBD_HAS_CONFIG_REF,
1173     + &nbd->config->runtime_flags))
1174     + nbd_config_put(nbd);
1175     +}
1176     +
1177     static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
1178     {
1179     struct nbd_device *nbd;
1180     @@ -1766,12 +1788,7 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
1181     nbd_put(nbd);
1182     return 0;
1183     }
1184     - mutex_lock(&nbd->config_lock);
1185     - nbd_disconnect(nbd);
1186     - mutex_unlock(&nbd->config_lock);
1187     - if (test_and_clear_bit(NBD_HAS_CONFIG_REF,
1188     - &nbd->config->runtime_flags))
1189     - nbd_config_put(nbd);
1190     + nbd_disconnect_and_put(nbd);
1191     nbd_config_put(nbd);
1192     nbd_put(nbd);
1193     return 0;
1194     @@ -1782,7 +1799,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1195     struct nbd_device *nbd = NULL;
1196     struct nbd_config *config;
1197     int index;
1198     - int ret = -EINVAL;
1199     + int ret = 0;
1200     bool put_dev = false;
1201    
1202     if (!netlink_capable(skb, CAP_SYS_ADMIN))
1203     @@ -1822,6 +1839,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1204     !nbd->task_recv) {
1205     dev_err(nbd_to_dev(nbd),
1206     "not configured, cannot reconfigure\n");
1207     + ret = -EINVAL;
1208     goto out;
1209     }
1210    
1211     @@ -1846,6 +1864,14 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1212     &config->runtime_flags))
1213     refcount_inc(&nbd->refs);
1214     }
1215     +
1216     + if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) {
1217     + set_bit(NBD_DISCONNECT_ON_CLOSE,
1218     + &config->runtime_flags);
1219     + } else {
1220     + clear_bit(NBD_DISCONNECT_ON_CLOSE,
1221     + &config->runtime_flags);
1222     + }
1223     }
1224    
1225     if (info->attrs[NBD_ATTR_SOCKETS]) {
1226     diff --git a/drivers/dax/device.c b/drivers/dax/device.c
1227     index 7b0bf825c4e7..050e299129ac 100644
1228     --- a/drivers/dax/device.c
1229     +++ b/drivers/dax/device.c
1230     @@ -188,14 +188,16 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma,
1231    
1232     /* prevent private mappings from being established */
1233     if ((vma->vm_flags & VM_MAYSHARE) != VM_MAYSHARE) {
1234     - dev_info(dev, "%s: %s: fail, attempted private mapping\n",
1235     + dev_info_ratelimited(dev,
1236     + "%s: %s: fail, attempted private mapping\n",
1237     current->comm, func);
1238     return -EINVAL;
1239     }
1240    
1241     mask = dax_region->align - 1;
1242     if (vma->vm_start & mask || vma->vm_end & mask) {
1243     - dev_info(dev, "%s: %s: fail, unaligned vma (%#lx - %#lx, %#lx)\n",
1244     + dev_info_ratelimited(dev,
1245     + "%s: %s: fail, unaligned vma (%#lx - %#lx, %#lx)\n",
1246     current->comm, func, vma->vm_start, vma->vm_end,
1247     mask);
1248     return -EINVAL;
1249     @@ -203,13 +205,15 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma,
1250    
1251     if ((dax_region->pfn_flags & (PFN_DEV|PFN_MAP)) == PFN_DEV
1252     && (vma->vm_flags & VM_DONTCOPY) == 0) {
1253     - dev_info(dev, "%s: %s: fail, dax range requires MADV_DONTFORK\n",
1254     + dev_info_ratelimited(dev,
1255     + "%s: %s: fail, dax range requires MADV_DONTFORK\n",
1256     current->comm, func);
1257     return -EINVAL;
1258     }
1259    
1260     if (!vma_is_dax(vma)) {
1261     - dev_info(dev, "%s: %s: fail, vma is not DAX capable\n",
1262     + dev_info_ratelimited(dev,
1263     + "%s: %s: fail, vma is not DAX capable\n",
1264     current->comm, func);
1265     return -EINVAL;
1266     }
1267     diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
1268     index 01d2a750a621..219ae3b545db 100644
1269     --- a/drivers/dma/k3dma.c
1270     +++ b/drivers/dma/k3dma.c
1271     @@ -787,7 +787,7 @@ static struct dma_chan *k3_of_dma_simple_xlate(struct of_phandle_args *dma_spec,
1272     struct k3_dma_dev *d = ofdma->of_dma_data;
1273     unsigned int request = dma_spec->args[0];
1274    
1275     - if (request > d->dma_requests)
1276     + if (request >= d->dma_requests)
1277     return NULL;
1278    
1279     return dma_get_slave_channel(&(d->chans[request].vc.chan));
1280     diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
1281     index 7432c8894e32..d19862f4dc9a 100644
1282     --- a/drivers/dma/pl330.c
1283     +++ b/drivers/dma/pl330.c
1284     @@ -2923,7 +2923,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
1285     pd->src_addr_widths = PL330_DMA_BUSWIDTHS;
1286     pd->dst_addr_widths = PL330_DMA_BUSWIDTHS;
1287     pd->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
1288     - pd->residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
1289     + pd->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
1290     pd->max_burst = ((pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) ?
1291     1 : PL330_MAX_BURST);
1292    
1293     diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
1294     index 480072139b7a..80801c616395 100644
1295     --- a/drivers/edac/edac_mc.c
1296     +++ b/drivers/edac/edac_mc.c
1297     @@ -215,6 +215,7 @@ const char * const edac_mem_types[] = {
1298     [MEM_LRDDR3] = "Load-Reduced DDR3 RAM",
1299     [MEM_DDR4] = "Unbuffered DDR4 RAM",
1300     [MEM_RDDR4] = "Registered DDR4 RAM",
1301     + [MEM_LRDDR4] = "Load-Reduced-DDR4-RAM",
1302     };
1303     EXPORT_SYMBOL_GPL(edac_mem_types);
1304    
1305     diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
1306     index 5183b46563f6..242dfb1433d2 100644
1307     --- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
1308     +++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
1309     @@ -899,7 +899,7 @@ static const struct amdgpu_ring_funcs vce_v3_0_ring_phys_funcs = {
1310     .emit_frame_size =
1311     4 + /* vce_v3_0_emit_pipeline_sync */
1312     6, /* amdgpu_vce_ring_emit_fence x1 no user fence */
1313     - .emit_ib_size = 5, /* vce_v3_0_ring_emit_ib */
1314     + .emit_ib_size = 4, /* amdgpu_vce_ring_emit_ib */
1315     .emit_ib = amdgpu_vce_ring_emit_ib,
1316     .emit_fence = amdgpu_vce_ring_emit_fence,
1317     .test_ring = amdgpu_vce_ring_test_ring,
1318     @@ -923,7 +923,7 @@ static const struct amdgpu_ring_funcs vce_v3_0_ring_vm_funcs = {
1319     6 + /* vce_v3_0_emit_vm_flush */
1320     4 + /* vce_v3_0_emit_pipeline_sync */
1321     6 + 6, /* amdgpu_vce_ring_emit_fence x2 vm fence */
1322     - .emit_ib_size = 4, /* amdgpu_vce_ring_emit_ib */
1323     + .emit_ib_size = 5, /* vce_v3_0_ring_emit_ib */
1324     .emit_ib = vce_v3_0_ring_emit_ib,
1325     .emit_vm_flush = vce_v3_0_emit_vm_flush,
1326     .emit_pipeline_sync = vce_v3_0_emit_pipeline_sync,
1327     diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c
1328     index 17bca99e8ac8..7e2c341dfe5f 100644
1329     --- a/drivers/gpu/drm/arm/malidp_hw.c
1330     +++ b/drivers/gpu/drm/arm/malidp_hw.c
1331     @@ -634,7 +634,8 @@ const struct malidp_hw_device malidp_device[MALIDP_MAX_DEVICES] = {
1332     .vsync_irq = MALIDP500_DE_IRQ_VSYNC,
1333     },
1334     .se_irq_map = {
1335     - .irq_mask = MALIDP500_SE_IRQ_CONF_MODE,
1336     + .irq_mask = MALIDP500_SE_IRQ_CONF_MODE |
1337     + MALIDP500_SE_IRQ_GLOBAL,
1338     .vsync_irq = 0,
1339     },
1340     .dc_irq_map = {
1341     diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
1342     index 94e7e3fa3408..16b8b310ae5c 100644
1343     --- a/drivers/gpu/drm/arm/malidp_planes.c
1344     +++ b/drivers/gpu/drm/arm/malidp_planes.c
1345     @@ -23,6 +23,7 @@
1346    
1347     /* Layer specific register offsets */
1348     #define MALIDP_LAYER_FORMAT 0x000
1349     +#define LAYER_FORMAT_MASK 0x3f
1350     #define MALIDP_LAYER_CONTROL 0x004
1351     #define LAYER_ENABLE (1 << 0)
1352     #define LAYER_FLOWCFG_MASK 7
1353     @@ -278,7 +279,9 @@ static void malidp_de_plane_update(struct drm_plane *plane,
1354     dest_w = plane->state->crtc_w;
1355     dest_h = plane->state->crtc_h;
1356    
1357     - malidp_hw_write(mp->hwdev, ms->format, mp->layer->base);
1358     + val = malidp_hw_read(mp->hwdev, mp->layer->base);
1359     + val = (val & ~LAYER_FORMAT_MASK) | ms->format;
1360     + malidp_hw_write(mp->hwdev, val, mp->layer->base);
1361    
1362     for (i = 0; i < ms->n_planes; i++) {
1363     /* calculate the offset for the layer's plane registers */
1364     diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
1365     index 79ce877bf45f..3039936f8f3f 100644
1366     --- a/drivers/gpu/drm/armada/armada_crtc.c
1367     +++ b/drivers/gpu/drm/armada/armada_crtc.c
1368     @@ -483,8 +483,9 @@ static irqreturn_t armada_drm_irq(int irq, void *arg)
1369     u32 v, stat = readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
1370    
1371     /*
1372     - * This is rediculous - rather than writing bits to clear, we
1373     - * have to set the actual status register value. This is racy.
1374     + * Reading the ISR appears to clear bits provided CLEAN_SPU_IRQ_ISR
1375     + * is set. Writing has some other effect to acknowledge the IRQ -
1376     + * without this, we only get a single IRQ.
1377     */
1378     writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
1379    
1380     @@ -1104,16 +1105,22 @@ armada_drm_crtc_set_property(struct drm_crtc *crtc,
1381     static int armada_drm_crtc_enable_vblank(struct drm_crtc *crtc)
1382     {
1383     struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
1384     + unsigned long flags;
1385    
1386     + spin_lock_irqsave(&dcrtc->irq_lock, flags);
1387     armada_drm_crtc_enable_irq(dcrtc, VSYNC_IRQ_ENA);
1388     + spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
1389     return 0;
1390     }
1391    
1392     static void armada_drm_crtc_disable_vblank(struct drm_crtc *crtc)
1393     {
1394     struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
1395     + unsigned long flags;
1396    
1397     + spin_lock_irqsave(&dcrtc->irq_lock, flags);
1398     armada_drm_crtc_disable_irq(dcrtc, VSYNC_IRQ_ENA);
1399     + spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
1400     }
1401    
1402     static const struct drm_crtc_funcs armada_crtc_funcs = {
1403     @@ -1221,6 +1228,7 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
1404     CFG_PDWN64x66, dcrtc->base + LCD_SPU_SRAM_PARA1);
1405     writel_relaxed(0x2032ff81, dcrtc->base + LCD_SPU_DMA_CTRL1);
1406     writel_relaxed(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
1407     + readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
1408     writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
1409    
1410     ret = devm_request_irq(dev, irq, armada_drm_irq, 0, "armada_drm_crtc",
1411     diff --git a/drivers/gpu/drm/armada/armada_hw.h b/drivers/gpu/drm/armada/armada_hw.h
1412     index 27319a8335e2..345dc4d0851e 100644
1413     --- a/drivers/gpu/drm/armada/armada_hw.h
1414     +++ b/drivers/gpu/drm/armada/armada_hw.h
1415     @@ -160,6 +160,7 @@ enum {
1416     CFG_ALPHAM_GRA = 0x1 << 16,
1417     CFG_ALPHAM_CFG = 0x2 << 16,
1418     CFG_ALPHA_MASK = 0xff << 8,
1419     +#define CFG_ALPHA(x) ((x) << 8)
1420     CFG_PIXCMD_MASK = 0xff,
1421     };
1422    
1423     diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
1424     index edc44910d79f..2076346b09ee 100644
1425     --- a/drivers/gpu/drm/armada/armada_overlay.c
1426     +++ b/drivers/gpu/drm/armada/armada_overlay.c
1427     @@ -28,6 +28,7 @@ struct armada_ovl_plane_properties {
1428     uint16_t contrast;
1429     uint16_t saturation;
1430     uint32_t colorkey_mode;
1431     + uint32_t colorkey_enable;
1432     };
1433    
1434     struct armada_ovl_plane {
1435     @@ -59,11 +60,13 @@ armada_ovl_update_attr(struct armada_ovl_plane_properties *prop,
1436     writel_relaxed(0x00002000, dcrtc->base + LCD_SPU_CBSH_HUE);
1437    
1438     spin_lock_irq(&dcrtc->irq_lock);
1439     - armada_updatel(prop->colorkey_mode | CFG_ALPHAM_GRA,
1440     - CFG_CKMODE_MASK | CFG_ALPHAM_MASK | CFG_ALPHA_MASK,
1441     - dcrtc->base + LCD_SPU_DMA_CTRL1);
1442     -
1443     - armada_updatel(ADV_GRACOLORKEY, 0, dcrtc->base + LCD_SPU_ADV_REG);
1444     + armada_updatel(prop->colorkey_mode,
1445     + CFG_CKMODE_MASK | CFG_ALPHAM_MASK | CFG_ALPHA_MASK,
1446     + dcrtc->base + LCD_SPU_DMA_CTRL1);
1447     + if (dcrtc->variant->has_spu_adv_reg)
1448     + armada_updatel(prop->colorkey_enable,
1449     + ADV_GRACOLORKEY | ADV_VIDCOLORKEY,
1450     + dcrtc->base + LCD_SPU_ADV_REG);
1451     spin_unlock_irq(&dcrtc->irq_lock);
1452     }
1453    
1454     @@ -339,8 +342,17 @@ static int armada_ovl_plane_set_property(struct drm_plane *plane,
1455     dplane->prop.colorkey_vb |= K2B(val);
1456     update_attr = true;
1457     } else if (property == priv->colorkey_mode_prop) {
1458     - dplane->prop.colorkey_mode &= ~CFG_CKMODE_MASK;
1459     - dplane->prop.colorkey_mode |= CFG_CKMODE(val);
1460     + if (val == CKMODE_DISABLE) {
1461     + dplane->prop.colorkey_mode =
1462     + CFG_CKMODE(CKMODE_DISABLE) |
1463     + CFG_ALPHAM_CFG | CFG_ALPHA(255);
1464     + dplane->prop.colorkey_enable = 0;
1465     + } else {
1466     + dplane->prop.colorkey_mode =
1467     + CFG_CKMODE(val) |
1468     + CFG_ALPHAM_GRA | CFG_ALPHA(0);
1469     + dplane->prop.colorkey_enable = ADV_GRACOLORKEY;
1470     + }
1471     update_attr = true;
1472     } else if (property == priv->brightness_prop) {
1473     dplane->prop.brightness = val - 256;
1474     @@ -470,7 +482,9 @@ int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs)
1475     dplane->prop.colorkey_yr = 0xfefefe00;
1476     dplane->prop.colorkey_ug = 0x01010100;
1477     dplane->prop.colorkey_vb = 0x01010100;
1478     - dplane->prop.colorkey_mode = CFG_CKMODE(CKMODE_RGB);
1479     + dplane->prop.colorkey_mode = CFG_CKMODE(CKMODE_RGB) |
1480     + CFG_ALPHAM_GRA | CFG_ALPHA(0);
1481     + dplane->prop.colorkey_enable = ADV_GRACOLORKEY;
1482     dplane->prop.brightness = 0;
1483     dplane->prop.contrast = 0x4000;
1484     dplane->prop.saturation = 0x4000;
1485     diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
1486     index 5131bfb94f06..0cb69ee94ac1 100644
1487     --- a/drivers/gpu/drm/bridge/sil-sii8620.c
1488     +++ b/drivers/gpu/drm/bridge/sil-sii8620.c
1489     @@ -788,6 +788,7 @@ static void sii8620_burst_rx_all(struct sii8620 *ctx)
1490     static void sii8620_fetch_edid(struct sii8620 *ctx)
1491     {
1492     u8 lm_ddc, ddc_cmd, int3, cbus;
1493     + unsigned long timeout;
1494     int fetched, i;
1495     int edid_len = EDID_LENGTH;
1496     u8 *edid;
1497     @@ -837,23 +838,31 @@ static void sii8620_fetch_edid(struct sii8620 *ctx)
1498     REG_DDC_CMD, ddc_cmd | VAL_DDC_CMD_ENH_DDC_READ_NO_ACK
1499     );
1500    
1501     - do {
1502     - int3 = sii8620_readb(ctx, REG_INTR3);
1503     + int3 = 0;
1504     + timeout = jiffies + msecs_to_jiffies(200);
1505     + for (;;) {
1506     cbus = sii8620_readb(ctx, REG_CBUS_STATUS);
1507     -
1508     - if (int3 & BIT_DDC_CMD_DONE)
1509     - break;
1510     -
1511     - if (!(cbus & BIT_CBUS_STATUS_CBUS_CONNECTED)) {
1512     + if (~cbus & BIT_CBUS_STATUS_CBUS_CONNECTED) {
1513     + kfree(edid);
1514     + edid = NULL;
1515     + goto end;
1516     + }
1517     + if (int3 & BIT_DDC_CMD_DONE) {
1518     + if (sii8620_readb(ctx, REG_DDC_DOUT_CNT)
1519     + >= FETCH_SIZE)
1520     + break;
1521     + } else {
1522     + int3 = sii8620_readb(ctx, REG_INTR3);
1523     + }
1524     + if (time_is_before_jiffies(timeout)) {
1525     + ctx->error = -ETIMEDOUT;
1526     + dev_err(ctx->dev, "timeout during EDID read\n");
1527     kfree(edid);
1528     edid = NULL;
1529     goto end;
1530     }
1531     - } while (1);
1532     -
1533     - sii8620_readb(ctx, REG_DDC_STATUS);
1534     - while (sii8620_readb(ctx, REG_DDC_DOUT_CNT) < FETCH_SIZE)
1535     usleep_range(10, 20);
1536     + }
1537    
1538     sii8620_read_buf(ctx, REG_DDC_DATA, edid + fetched, FETCH_SIZE);
1539     if (fetched + FETCH_SIZE == EDID_LENGTH) {
1540     @@ -1036,23 +1045,23 @@ static void sii8620_set_format(struct sii8620 *ctx)
1541     BIT_M3_P0CTRL_MHL3_P0_PIXEL_MODE_PACKED,
1542     ctx->use_packed_pixel ? ~0 : 0);
1543     } else {
1544     - if (ctx->use_packed_pixel)
1545     + if (ctx->use_packed_pixel) {
1546     sii8620_write_seq_static(ctx,
1547     REG_VID_MODE, BIT_VID_MODE_M1080P,
1548     REG_MHL_TOP_CTL, BIT_MHL_TOP_CTL_MHL_PP_SEL | 1,
1549     REG_MHLTX_CTL6, 0x60
1550     );
1551     - else
1552     + } else {
1553     sii8620_write_seq_static(ctx,
1554     REG_VID_MODE, 0,
1555     REG_MHL_TOP_CTL, 1,
1556     REG_MHLTX_CTL6, 0xa0
1557     );
1558     + }
1559     }
1560    
1561     if (ctx->use_packed_pixel)
1562     - out_fmt = VAL_TPI_FORMAT(YCBCR422, FULL) |
1563     - BIT_TPI_OUTPUT_CSCMODE709;
1564     + out_fmt = VAL_TPI_FORMAT(YCBCR422, FULL);
1565     else
1566     out_fmt = VAL_TPI_FORMAT(RGB, FULL);
1567    
1568     @@ -1187,7 +1196,7 @@ static void sii8620_start_hdmi(struct sii8620 *ctx)
1569     int clk = ctx->pixel_clock * (ctx->use_packed_pixel ? 2 : 3);
1570     int i;
1571    
1572     - for (i = 0; i < ARRAY_SIZE(clk_spec); ++i)
1573     + for (i = 0; i < ARRAY_SIZE(clk_spec) - 1; ++i)
1574     if (clk < clk_spec[i].max_clk)
1575     break;
1576    
1577     diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
1578     index 6be5b53c3b27..f905c214fdd0 100644
1579     --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
1580     +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
1581     @@ -261,7 +261,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win,
1582     unsigned long val;
1583    
1584     val = readl(ctx->addr + DECON_WINCONx(win));
1585     - val &= ~WINCONx_BPPMODE_MASK;
1586     + val &= WINCONx_ENWIN_F;
1587    
1588     switch (fb->format->format) {
1589     case DRM_FORMAT_XRGB1555:
1590     @@ -352,8 +352,8 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
1591     writel(val, ctx->addr + DECON_VIDOSDxB(win));
1592     }
1593    
1594     - val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
1595     - VIDOSD_Wx_ALPHA_B_F(0x0);
1596     + val = VIDOSD_Wx_ALPHA_R_F(0xff) | VIDOSD_Wx_ALPHA_G_F(0xff) |
1597     + VIDOSD_Wx_ALPHA_B_F(0xff);
1598     writel(val, ctx->addr + DECON_VIDOSDxC(win));
1599    
1600     val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
1601     diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
1602     index 0506b2b17ac1..48f913d8208c 100644
1603     --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
1604     +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
1605     @@ -532,21 +532,25 @@ static int gsc_src_set_fmt(struct device *dev, u32 fmt)
1606     GSC_IN_CHROMA_ORDER_CRCB);
1607     break;
1608     case DRM_FORMAT_NV21:
1609     + cfg |= (GSC_IN_CHROMA_ORDER_CRCB | GSC_IN_YUV420_2P);
1610     + break;
1611     case DRM_FORMAT_NV61:
1612     - cfg |= (GSC_IN_CHROMA_ORDER_CRCB |
1613     - GSC_IN_YUV420_2P);
1614     + cfg |= (GSC_IN_CHROMA_ORDER_CRCB | GSC_IN_YUV422_2P);
1615     break;
1616     case DRM_FORMAT_YUV422:
1617     cfg |= GSC_IN_YUV422_3P;
1618     break;
1619     case DRM_FORMAT_YUV420:
1620     + cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV420_3P);
1621     + break;
1622     case DRM_FORMAT_YVU420:
1623     - cfg |= GSC_IN_YUV420_3P;
1624     + cfg |= (GSC_IN_CHROMA_ORDER_CRCB | GSC_IN_YUV420_3P);
1625     break;
1626     case DRM_FORMAT_NV12:
1627     + cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV420_2P);
1628     + break;
1629     case DRM_FORMAT_NV16:
1630     - cfg |= (GSC_IN_CHROMA_ORDER_CBCR |
1631     - GSC_IN_YUV420_2P);
1632     + cfg |= (GSC_IN_CHROMA_ORDER_CBCR | GSC_IN_YUV422_2P);
1633     break;
1634     default:
1635     dev_err(ippdrv->dev, "invalid target yuv order 0x%x.\n", fmt);
1636     @@ -806,18 +810,25 @@ static int gsc_dst_set_fmt(struct device *dev, u32 fmt)
1637     GSC_OUT_CHROMA_ORDER_CRCB);
1638     break;
1639     case DRM_FORMAT_NV21:
1640     - case DRM_FORMAT_NV61:
1641     cfg |= (GSC_OUT_CHROMA_ORDER_CRCB | GSC_OUT_YUV420_2P);
1642     break;
1643     + case DRM_FORMAT_NV61:
1644     + cfg |= (GSC_OUT_CHROMA_ORDER_CRCB | GSC_OUT_YUV422_2P);
1645     + break;
1646     case DRM_FORMAT_YUV422:
1647     + cfg |= GSC_OUT_YUV422_3P;
1648     + break;
1649     case DRM_FORMAT_YUV420:
1650     + cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV420_3P);
1651     + break;
1652     case DRM_FORMAT_YVU420:
1653     - cfg |= GSC_OUT_YUV420_3P;
1654     + cfg |= (GSC_OUT_CHROMA_ORDER_CRCB | GSC_OUT_YUV420_3P);
1655     break;
1656     case DRM_FORMAT_NV12:
1657     + cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV420_2P);
1658     + break;
1659     case DRM_FORMAT_NV16:
1660     - cfg |= (GSC_OUT_CHROMA_ORDER_CBCR |
1661     - GSC_OUT_YUV420_2P);
1662     + cfg |= (GSC_OUT_CHROMA_ORDER_CBCR | GSC_OUT_YUV422_2P);
1663     break;
1664     default:
1665     dev_err(ippdrv->dev, "invalid target yuv order 0x%x.\n", fmt);
1666     diff --git a/drivers/gpu/drm/exynos/regs-gsc.h b/drivers/gpu/drm/exynos/regs-gsc.h
1667     index 4704a993cbb7..16b39734115c 100644
1668     --- a/drivers/gpu/drm/exynos/regs-gsc.h
1669     +++ b/drivers/gpu/drm/exynos/regs-gsc.h
1670     @@ -138,6 +138,7 @@
1671     #define GSC_OUT_YUV420_3P (3 << 4)
1672     #define GSC_OUT_YUV422_1P (4 << 4)
1673     #define GSC_OUT_YUV422_2P (5 << 4)
1674     +#define GSC_OUT_YUV422_3P (6 << 4)
1675     #define GSC_OUT_YUV444 (7 << 4)
1676     #define GSC_OUT_TILE_TYPE_MASK (1 << 2)
1677     #define GSC_OUT_TILE_C_16x8 (0 << 2)
1678     diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
1679     index 9bf4045cd679..73c672fc17c4 100644
1680     --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
1681     +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
1682     @@ -42,6 +42,8 @@
1683     #include <linux/vfio.h>
1684     #include <linux/mdev.h>
1685    
1686     +#include <linux/nospec.h>
1687     +
1688     #include "i915_drv.h"
1689     #include "gvt.h"
1690    
1691     @@ -953,7 +955,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
1692     } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) {
1693     struct vfio_region_info info;
1694     struct vfio_info_cap caps = { .buf = NULL, .size = 0 };
1695     - int i, ret;
1696     + unsigned int i;
1697     + int ret;
1698     struct vfio_region_info_cap_sparse_mmap *sparse = NULL;
1699     size_t size;
1700     int nr_areas = 1;
1701     @@ -1030,6 +1033,10 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
1702     if (info.index >= VFIO_PCI_NUM_REGIONS +
1703     vgpu->vdev.num_regions)
1704     return -EINVAL;
1705     + info.index =
1706     + array_index_nospec(info.index,
1707     + VFIO_PCI_NUM_REGIONS +
1708     + vgpu->vdev.num_regions);
1709    
1710     i = info.index - VFIO_PCI_NUM_REGIONS;
1711    
1712     diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
1713     index 2170534101ca..60ffb70bb908 100644
1714     --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
1715     +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
1716     @@ -599,7 +599,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
1717     struct nouveau_bo *nvbo;
1718     uint32_t data;
1719    
1720     - if (unlikely(r->bo_index > req->nr_buffers)) {
1721     + if (unlikely(r->bo_index >= req->nr_buffers)) {
1722     NV_PRINTK(err, cli, "reloc bo index invalid\n");
1723     ret = -EINVAL;
1724     break;
1725     @@ -609,7 +609,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
1726     if (b->presumed.valid)
1727     continue;
1728    
1729     - if (unlikely(r->reloc_bo_index > req->nr_buffers)) {
1730     + if (unlikely(r->reloc_bo_index >= req->nr_buffers)) {
1731     NV_PRINTK(err, cli, "reloc container bo index invalid\n");
1732     ret = -EINVAL;
1733     break;
1734     diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
1735     index 0598b4c18c25..75b1c8c03ce9 100644
1736     --- a/drivers/gpu/drm/tegra/drm.c
1737     +++ b/drivers/gpu/drm/tegra/drm.c
1738     @@ -470,7 +470,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
1739     * unaligned offset is malformed and cause commands stream
1740     * corruption on the buffer address relocation.
1741     */
1742     - if (offset & 3 || offset >= obj->gem.size) {
1743     + if (offset & 3 || offset > obj->gem.size) {
1744     err = -EINVAL;
1745     goto fail;
1746     }
1747     diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c
1748     index db509ab8874e..acd99783bbca 100644
1749     --- a/drivers/gpu/host1x/job.c
1750     +++ b/drivers/gpu/host1x/job.c
1751     @@ -686,7 +686,8 @@ void host1x_job_unpin(struct host1x_job *job)
1752     for (i = 0; i < job->num_unpins; i++) {
1753     struct host1x_job_unpin_data *unpin = &job->unpins[i];
1754    
1755     - if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) && host->domain) {
1756     + if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) &&
1757     + unpin->size && host->domain) {
1758     iommu_unmap(host->domain, job->addr_phys[i],
1759     unpin->size);
1760     free_iova(&host->iova,
1761     diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
1762     index c401b5b63f4c..4c72e68637c2 100644
1763     --- a/drivers/hid/wacom_wac.c
1764     +++ b/drivers/hid/wacom_wac.c
1765     @@ -3212,8 +3212,14 @@ void wacom_setup_device_quirks(struct wacom *wacom)
1766     if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
1767     features->device_type |= WACOM_DEVICETYPE_PAD;
1768    
1769     - features->x_max = 4096;
1770     - features->y_max = 4096;
1771     + if (features->type == INTUOSHT2) {
1772     + features->x_max = features->x_max / 10;
1773     + features->y_max = features->y_max / 10;
1774     + }
1775     + else {
1776     + features->x_max = 4096;
1777     + features->y_max = 4096;
1778     + }
1779     }
1780     else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
1781     features->device_type |= WACOM_DEVICETYPE_PAD;
1782     diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
1783     index f5f3f8cf57ea..5f87764d7015 100644
1784     --- a/drivers/hwmon/nct6775.c
1785     +++ b/drivers/hwmon/nct6775.c
1786     @@ -4107,7 +4107,7 @@ static int nct6775_probe(struct platform_device *pdev)
1787     * The temperature is already monitored if the respective bit in <mask>
1788     * is set.
1789     */
1790     - for (i = 0; i < 32; i++) {
1791     + for (i = 0; i < 31; i++) {
1792     if (!(data->temp_mask & BIT(i + 1)))
1793     continue;
1794     if (!reg_temp_alternate[i])
1795     diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
1796     index 75c6b98585ba..b73dd837fb53 100644
1797     --- a/drivers/i2c/busses/i2c-imx.c
1798     +++ b/drivers/i2c/busses/i2c-imx.c
1799     @@ -665,9 +665,6 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx,
1800     struct imx_i2c_dma *dma = i2c_imx->dma;
1801     struct device *dev = &i2c_imx->adapter.dev;
1802    
1803     - temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
1804     - temp |= I2CR_DMAEN;
1805     - imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
1806    
1807     dma->chan_using = dma->chan_rx;
1808     dma->dma_transfer_dir = DMA_DEV_TO_MEM;
1809     @@ -780,6 +777,7 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, bo
1810     int i, result;
1811     unsigned int temp;
1812     int block_data = msgs->flags & I2C_M_RECV_LEN;
1813     + int use_dma = i2c_imx->dma && msgs->len >= DMA_THRESHOLD && !block_data;
1814    
1815     dev_dbg(&i2c_imx->adapter.dev,
1816     "<%s> write slave address: addr=0x%x\n",
1817     @@ -806,12 +804,14 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, bo
1818     */
1819     if ((msgs->len - 1) || block_data)
1820     temp &= ~I2CR_TXAK;
1821     + if (use_dma)
1822     + temp |= I2CR_DMAEN;
1823     imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
1824     imx_i2c_read_reg(i2c_imx, IMX_I2C_I2DR); /* dummy read */
1825    
1826     dev_dbg(&i2c_imx->adapter.dev, "<%s> read data\n", __func__);
1827    
1828     - if (i2c_imx->dma && msgs->len >= DMA_THRESHOLD && !block_data)
1829     + if (use_dma)
1830     return i2c_imx_dma_read(i2c_imx, msgs, is_lastmsg);
1831    
1832     /* read data */
1833     diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
1834     index a9126b3cda61..847d9bf6744c 100644
1835     --- a/drivers/i2c/i2c-core-acpi.c
1836     +++ b/drivers/i2c/i2c-core-acpi.c
1837     @@ -475,11 +475,16 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
1838     msgs[0].buf = buffer;
1839    
1840     ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
1841     - if (ret < 0)
1842     - dev_err(&client->adapter->dev, "i2c write failed\n");
1843    
1844     kfree(buffer);
1845     - return ret;
1846     +
1847     + if (ret < 0) {
1848     + dev_err(&client->adapter->dev, "i2c write failed: %d\n", ret);
1849     + return ret;
1850     + }
1851     +
1852     + /* 1 transfer must have completed successfully */
1853     + return (ret == 1) ? 0 : -EIO;
1854     }
1855    
1856     static acpi_status
1857     diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
1858     index 8f26428804a2..5f625ffa2a88 100644
1859     --- a/drivers/iio/pressure/bmp280-core.c
1860     +++ b/drivers/iio/pressure/bmp280-core.c
1861     @@ -362,10 +362,9 @@ static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2)
1862     }
1863     comp_humidity = bmp280_compensate_humidity(data, adc_humidity);
1864    
1865     - *val = comp_humidity;
1866     - *val2 = 1024;
1867     + *val = comp_humidity * 1000 / 1024;
1868    
1869     - return IIO_VAL_FRACTIONAL;
1870     + return IIO_VAL_INT;
1871     }
1872    
1873     static int bmp280_read_raw(struct iio_dev *indio_dev,
1874     diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
1875     index 1587cedee13e..761d3ce6a63a 100644
1876     --- a/drivers/infiniband/hw/mlx4/mr.c
1877     +++ b/drivers/infiniband/hw/mlx4/mr.c
1878     @@ -247,8 +247,11 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
1879     }
1880    
1881     if (flags & IB_MR_REREG_ACCESS) {
1882     - if (ib_access_writable(mr_access_flags) && !mmr->umem->writable)
1883     - return -EPERM;
1884     + if (ib_access_writable(mr_access_flags) &&
1885     + !mmr->umem->writable) {
1886     + err = -EPERM;
1887     + goto release_mpt_entry;
1888     + }
1889    
1890     err = mlx4_mr_hw_change_access(dev->dev, *pmpt_entry,
1891     convert_access(mr_access_flags));
1892     diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
1893     index 3c7522d025f2..93d67d97c279 100644
1894     --- a/drivers/infiniband/hw/mlx5/srq.c
1895     +++ b/drivers/infiniband/hw/mlx5/srq.c
1896     @@ -266,18 +266,24 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
1897    
1898     desc_size = sizeof(struct mlx5_wqe_srq_next_seg) +
1899     srq->msrq.max_gs * sizeof(struct mlx5_wqe_data_seg);
1900     - if (desc_size == 0 || srq->msrq.max_gs > desc_size)
1901     - return ERR_PTR(-EINVAL);
1902     + if (desc_size == 0 || srq->msrq.max_gs > desc_size) {
1903     + err = -EINVAL;
1904     + goto err_srq;
1905     + }
1906     desc_size = roundup_pow_of_two(desc_size);
1907     desc_size = max_t(size_t, 32, desc_size);
1908     - if (desc_size < sizeof(struct mlx5_wqe_srq_next_seg))
1909     - return ERR_PTR(-EINVAL);
1910     + if (desc_size < sizeof(struct mlx5_wqe_srq_next_seg)) {
1911     + err = -EINVAL;
1912     + goto err_srq;
1913     + }
1914     srq->msrq.max_avail_gather = (desc_size - sizeof(struct mlx5_wqe_srq_next_seg)) /
1915     sizeof(struct mlx5_wqe_data_seg);
1916     srq->msrq.wqe_shift = ilog2(desc_size);
1917     buf_size = srq->msrq.max * desc_size;
1918     - if (buf_size < desc_size)
1919     - return ERR_PTR(-EINVAL);
1920     + if (buf_size < desc_size) {
1921     + err = -EINVAL;
1922     + goto err_srq;
1923     + }
1924     in.type = init_attr->srq_type;
1925    
1926     if (pd->uobject)
1927     diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c
1928     index 54cc9cb1e3b7..de853bcc2384 100644
1929     --- a/drivers/infiniband/sw/rxe/rxe_req.c
1930     +++ b/drivers/infiniband/sw/rxe/rxe_req.c
1931     @@ -645,6 +645,9 @@ next_wqe:
1932     } else {
1933     goto exit;
1934     }
1935     + if ((wqe->wr.send_flags & IB_SEND_SIGNALED) ||
1936     + qp->sq_sig_type == IB_SIGNAL_ALL_WR)
1937     + rxe_run_task(&qp->comp.task, 1);
1938     qp->req.wqe_index = next_index(qp->sq.queue,
1939     qp->req.wqe_index);
1940     goto next_wqe;
1941     diff --git a/drivers/input/rmi4/rmi_2d_sensor.c b/drivers/input/rmi4/rmi_2d_sensor.c
1942     index 8bb866c7b985..8eeffa066022 100644
1943     --- a/drivers/input/rmi4/rmi_2d_sensor.c
1944     +++ b/drivers/input/rmi4/rmi_2d_sensor.c
1945     @@ -32,15 +32,15 @@ void rmi_2d_sensor_abs_process(struct rmi_2d_sensor *sensor,
1946     if (obj->type == RMI_2D_OBJECT_NONE)
1947     return;
1948    
1949     - if (axis_align->swap_axes)
1950     - swap(obj->x, obj->y);
1951     -
1952     if (axis_align->flip_x)
1953     obj->x = sensor->max_x - obj->x;
1954    
1955     if (axis_align->flip_y)
1956     obj->y = sensor->max_y - obj->y;
1957    
1958     + if (axis_align->swap_axes)
1959     + swap(obj->x, obj->y);
1960     +
1961     /*
1962     * Here checking if X offset or y offset are specified is
1963     * redundant. We just add the offsets or clip the values.
1964     @@ -120,15 +120,15 @@ void rmi_2d_sensor_rel_report(struct rmi_2d_sensor *sensor, int x, int y)
1965     x = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)x));
1966     y = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)y));
1967    
1968     - if (axis_align->swap_axes)
1969     - swap(x, y);
1970     -
1971     if (axis_align->flip_x)
1972     x = min(RMI_2D_REL_POS_MAX, -x);
1973    
1974     if (axis_align->flip_y)
1975     y = min(RMI_2D_REL_POS_MAX, -y);
1976    
1977     + if (axis_align->swap_axes)
1978     + swap(x, y);
1979     +
1980     if (x || y) {
1981     input_report_rel(sensor->input, REL_X, x);
1982     input_report_rel(sensor->input, REL_Y, y);
1983     @@ -141,17 +141,10 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
1984     struct input_dev *input = sensor->input;
1985     int res_x;
1986     int res_y;
1987     + int max_x, max_y;
1988     int input_flags = 0;
1989    
1990     if (sensor->report_abs) {
1991     - if (sensor->axis_align.swap_axes) {
1992     - swap(sensor->max_x, sensor->max_y);
1993     - swap(sensor->axis_align.clip_x_low,
1994     - sensor->axis_align.clip_y_low);
1995     - swap(sensor->axis_align.clip_x_high,
1996     - sensor->axis_align.clip_y_high);
1997     - }
1998     -
1999     sensor->min_x = sensor->axis_align.clip_x_low;
2000     if (sensor->axis_align.clip_x_high)
2001     sensor->max_x = min(sensor->max_x,
2002     @@ -163,14 +156,19 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
2003     sensor->axis_align.clip_y_high);
2004    
2005     set_bit(EV_ABS, input->evbit);
2006     - input_set_abs_params(input, ABS_MT_POSITION_X, 0, sensor->max_x,
2007     - 0, 0);
2008     - input_set_abs_params(input, ABS_MT_POSITION_Y, 0, sensor->max_y,
2009     - 0, 0);
2010     +
2011     + max_x = sensor->max_x;
2012     + max_y = sensor->max_y;
2013     + if (sensor->axis_align.swap_axes)
2014     + swap(max_x, max_y);
2015     + input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_x, 0, 0);
2016     + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
2017    
2018     if (sensor->x_mm && sensor->y_mm) {
2019     res_x = (sensor->max_x - sensor->min_x) / sensor->x_mm;
2020     res_y = (sensor->max_y - sensor->min_y) / sensor->y_mm;
2021     + if (sensor->axis_align.swap_axes)
2022     + swap(res_x, res_y);
2023    
2024     input_abs_set_res(input, ABS_X, res_x);
2025     input_abs_set_res(input, ABS_Y, res_y);
2026     diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
2027     index b20c23f970f4..262a0f0f8fd5 100644
2028     --- a/drivers/md/raid10.c
2029     +++ b/drivers/md/raid10.c
2030     @@ -3754,6 +3754,13 @@ static int raid10_run(struct mddev *mddev)
2031     disk->rdev->saved_raid_disk < 0)
2032     conf->fullsync = 1;
2033     }
2034     +
2035     + if (disk->replacement &&
2036     + !test_bit(In_sync, &disk->replacement->flags) &&
2037     + disk->replacement->saved_raid_disk < 0) {
2038     + conf->fullsync = 1;
2039     + }
2040     +
2041     disk->recovery_disabled = mddev->recovery_disabled - 1;
2042     }
2043    
2044     diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
2045     index 5dc8bd042cc5..504e34f29518 100644
2046     --- a/drivers/mtd/devices/mtd_dataflash.c
2047     +++ b/drivers/mtd/devices/mtd_dataflash.c
2048     @@ -737,8 +737,8 @@ static struct flash_info dataflash_data[] = {
2049     { "AT45DB642x", 0x1f2800, 8192, 1056, 11, SUP_POW2PS},
2050     { "at45db642d", 0x1f2800, 8192, 1024, 10, SUP_POW2PS | IS_POW2PS},
2051    
2052     - { "AT45DB641E", 0x1f28000100, 32768, 264, 9, SUP_EXTID | SUP_POW2PS},
2053     - { "at45db641e", 0x1f28000100, 32768, 256, 8, SUP_EXTID | SUP_POW2PS | IS_POW2PS},
2054     + { "AT45DB641E", 0x1f28000100ULL, 32768, 264, 9, SUP_EXTID | SUP_POW2PS},
2055     + { "at45db641e", 0x1f28000100ULL, 32768, 256, 8, SUP_EXTID | SUP_POW2PS | IS_POW2PS},
2056     };
2057    
2058     static struct flash_info *jedec_lookup(struct spi_device *spi,
2059     diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
2060     index 352beff796ae..828e2e56b75e 100644
2061     --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
2062     +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
2063     @@ -1529,6 +1529,7 @@ struct bnx2x {
2064     struct link_vars link_vars;
2065     u32 link_cnt;
2066     struct bnx2x_link_report_data last_reported_link;
2067     + bool force_link_down;
2068    
2069     struct mdio_if_info mdio;
2070    
2071     diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
2072     index 6465414dad74..8498a357d389 100644
2073     --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
2074     +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
2075     @@ -1260,6 +1260,11 @@ void __bnx2x_link_report(struct bnx2x *bp)
2076     {
2077     struct bnx2x_link_report_data cur_data;
2078    
2079     + if (bp->force_link_down) {
2080     + bp->link_vars.link_up = 0;
2081     + return;
2082     + }
2083     +
2084     /* reread mf_cfg */
2085     if (IS_PF(bp) && !CHIP_IS_E1(bp))
2086     bnx2x_read_mf_cfg(bp);
2087     @@ -2817,6 +2822,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
2088     bp->pending_max = 0;
2089     }
2090    
2091     + bp->force_link_down = false;
2092     if (bp->port.pmf) {
2093     rc = bnx2x_initial_phy_init(bp, load_mode);
2094     if (rc)
2095     diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
2096     index e855a271db48..bd3e3f080ebf 100644
2097     --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
2098     +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
2099     @@ -10279,6 +10279,12 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work)
2100     bp->sp_rtnl_state = 0;
2101     smp_mb();
2102    
2103     + /* Immediately indicate link as down */
2104     + bp->link_vars.link_up = 0;
2105     + bp->force_link_down = true;
2106     + netif_carrier_off(bp->dev);
2107     + BNX2X_ERR("Indicating link is down due to Tx-timeout\n");
2108     +
2109     bnx2x_nic_unload(bp, UNLOAD_NORMAL, true);
2110     bnx2x_nic_load(bp, LOAD_NORMAL);
2111    
2112     diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2113     index 94931318587c..937db8019289 100644
2114     --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2115     +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
2116     @@ -6348,7 +6348,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
2117     rc = bnxt_request_irq(bp);
2118     if (rc) {
2119     netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc);
2120     - goto open_err;
2121     + goto open_err_irq;
2122     }
2123     }
2124    
2125     @@ -6386,6 +6386,8 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
2126    
2127     open_err:
2128     bnxt_disable_napi(bp);
2129     +
2130     +open_err_irq:
2131     bnxt_del_napi(bp);
2132    
2133     open_err_free_mem:
2134     @@ -7866,11 +7868,11 @@ int bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx, bool shared)
2135     int rx, tx, cp;
2136    
2137     _bnxt_get_max_rings(bp, &rx, &tx, &cp);
2138     + *max_rx = rx;
2139     + *max_tx = tx;
2140     if (!rx || !tx || !cp)
2141     return -ENOMEM;
2142    
2143     - *max_rx = rx;
2144     - *max_tx = tx;
2145     return bnxt_trim_rings(bp, max_rx, max_tx, cp, shared);
2146     }
2147    
2148     @@ -7884,8 +7886,11 @@ static int bnxt_get_dflt_rings(struct bnxt *bp, int *max_rx, int *max_tx,
2149     /* Not enough rings, try disabling agg rings. */
2150     bp->flags &= ~BNXT_FLAG_AGG_RINGS;
2151     rc = bnxt_get_max_rings(bp, max_rx, max_tx, shared);
2152     - if (rc)
2153     + if (rc) {
2154     + /* set BNXT_FLAG_AGG_RINGS back for consistency */
2155     + bp->flags |= BNXT_FLAG_AGG_RINGS;
2156     return rc;
2157     + }
2158     bp->flags |= BNXT_FLAG_NO_AGG_RINGS;
2159     bp->dev->hw_features &= ~NETIF_F_LRO;
2160     bp->dev->features &= ~NETIF_F_LRO;
2161     diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
2162     index 2887bcaf6af5..45c51277e0cf 100644
2163     --- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
2164     +++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
2165     @@ -643,13 +643,21 @@ static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr)
2166     static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
2167     {
2168     struct octeon_mgmt *p = netdev_priv(netdev);
2169     - int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM;
2170     + int max_packet = new_mtu + ETH_HLEN + ETH_FCS_LEN;
2171    
2172     netdev->mtu = new_mtu;
2173    
2174     - cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, size_without_fcs);
2175     + /* HW lifts the limit if the frame is VLAN tagged
2176     + * (+4 bytes per each tag, up to two tags)
2177     + */
2178     + cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, max_packet);
2179     + /* Set the hardware to truncate packets larger than the MTU. The jabber
2180     + * register must be set to a multiple of 8 bytes, so round up. JABBER is
2181     + * an unconditional limit, so we need to account for two possible VLAN
2182     + * tags.
2183     + */
2184     cvmx_write_csr(p->agl + AGL_GMX_RX_JABBER,
2185     - (size_without_fcs + 7) & 0xfff8);
2186     + (max_packet + 7 + VLAN_HLEN * 2) & 0xfff8);
2187    
2188     return 0;
2189     }
2190     diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2191     index 44a0d04dd8a0..74a42f12064b 100644
2192     --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2193     +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2194     @@ -253,7 +253,7 @@ static void dcb_tx_queue_prio_enable(struct net_device *dev, int enable)
2195     "Can't %s DCB Priority on port %d, TX Queue %d: err=%d\n",
2196     enable ? "set" : "unset", pi->port_id, i, -err);
2197     else
2198     - txq->dcb_prio = value;
2199     + txq->dcb_prio = enable ? value : 0;
2200     }
2201     }
2202    
2203     diff --git a/drivers/net/ethernet/cisco/enic/enic_clsf.c b/drivers/net/ethernet/cisco/enic/enic_clsf.c
2204     index 8dc21c9f9716..df613a87ccff 100644
2205     --- a/drivers/net/ethernet/cisco/enic/enic_clsf.c
2206     +++ b/drivers/net/ethernet/cisco/enic/enic_clsf.c
2207     @@ -79,7 +79,6 @@ void enic_rfs_flw_tbl_init(struct enic *enic)
2208     enic->rfs_h.max = enic->config.num_arfs;
2209     enic->rfs_h.free = enic->rfs_h.max;
2210     enic->rfs_h.toclean = 0;
2211     - enic_rfs_timer_start(enic);
2212     }
2213    
2214     void enic_rfs_flw_tbl_free(struct enic *enic)
2215     @@ -88,7 +87,6 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
2216    
2217     enic_rfs_timer_stop(enic);
2218     spin_lock_bh(&enic->rfs_h.lock);
2219     - enic->rfs_h.free = 0;
2220     for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) {
2221     struct hlist_head *hhead;
2222     struct hlist_node *tmp;
2223     @@ -99,6 +97,7 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
2224     enic_delfltr(enic, n->fltr_id);
2225     hlist_del(&n->node);
2226     kfree(n);
2227     + enic->rfs_h.free++;
2228     }
2229     }
2230     spin_unlock_bh(&enic->rfs_h.lock);
2231     diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
2232     index a03a32a4ffca..800edfbd36c1 100644
2233     --- a/drivers/net/ethernet/cisco/enic/enic_main.c
2234     +++ b/drivers/net/ethernet/cisco/enic/enic_main.c
2235     @@ -1930,7 +1930,7 @@ static int enic_open(struct net_device *netdev)
2236     vnic_intr_unmask(&enic->intr[i]);
2237    
2238     enic_notify_timer_start(enic);
2239     - enic_rfs_flw_tbl_init(enic);
2240     + enic_rfs_timer_start(enic);
2241    
2242     return 0;
2243    
2244     @@ -2854,6 +2854,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2245     enic->notify_timer.function = enic_notify_timer;
2246     enic->notify_timer.data = (unsigned long)enic;
2247    
2248     + enic_rfs_flw_tbl_init(enic);
2249     enic_set_rx_coal_setting(enic);
2250     INIT_WORK(&enic->reset, enic_reset);
2251     INIT_WORK(&enic->tx_hang_reset, enic_tx_hang_reset);
2252     diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
2253     index 519a021c0a25..a202c50d6fc7 100644
2254     --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
2255     +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
2256     @@ -125,6 +125,9 @@ MODULE_PARM_DESC(tx_timeout, "The Tx timeout in ms");
2257     /* Default alignment for start of data in an Rx FD */
2258     #define DPAA_FD_DATA_ALIGNMENT 16
2259    
2260     +/* The DPAA requires 256 bytes reserved and mapped for the SGT */
2261     +#define DPAA_SGT_SIZE 256
2262     +
2263     /* Values for the L3R field of the FM Parse Results
2264     */
2265     /* L3 Type field: First IP Present IPv4 */
2266     @@ -1622,8 +1625,8 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct dpaa_priv *priv,
2267    
2268     if (unlikely(qm_fd_get_format(fd) == qm_fd_sg)) {
2269     nr_frags = skb_shinfo(skb)->nr_frags;
2270     - dma_unmap_single(dev, addr, qm_fd_get_offset(fd) +
2271     - sizeof(struct qm_sg_entry) * (1 + nr_frags),
2272     + dma_unmap_single(dev, addr,
2273     + qm_fd_get_offset(fd) + DPAA_SGT_SIZE,
2274     dma_dir);
2275    
2276     /* The sgt buffer has been allocated with netdev_alloc_frag(),
2277     @@ -1907,8 +1910,7 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
2278     void *sgt_buf;
2279    
2280     /* get a page frag to store the SGTable */
2281     - sz = SKB_DATA_ALIGN(priv->tx_headroom +
2282     - sizeof(struct qm_sg_entry) * (1 + nr_frags));
2283     + sz = SKB_DATA_ALIGN(priv->tx_headroom + DPAA_SGT_SIZE);
2284     sgt_buf = netdev_alloc_frag(sz);
2285     if (unlikely(!sgt_buf)) {
2286     netdev_err(net_dev, "netdev_alloc_frag() failed for size %d\n",
2287     @@ -1976,9 +1978,8 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
2288     skbh = (struct sk_buff **)buffer_start;
2289     *skbh = skb;
2290    
2291     - addr = dma_map_single(dev, buffer_start, priv->tx_headroom +
2292     - sizeof(struct qm_sg_entry) * (1 + nr_frags),
2293     - dma_dir);
2294     + addr = dma_map_single(dev, buffer_start,
2295     + priv->tx_headroom + DPAA_SGT_SIZE, dma_dir);
2296     if (unlikely(dma_mapping_error(dev, addr))) {
2297     dev_err(dev, "DMA mapping failed");
2298     err = -EINVAL;
2299     diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c b/drivers/net/ethernet/freescale/fman/fman_port.c
2300     index 1789b206be58..495190764155 100644
2301     --- a/drivers/net/ethernet/freescale/fman/fman_port.c
2302     +++ b/drivers/net/ethernet/freescale/fman/fman_port.c
2303     @@ -324,6 +324,10 @@ struct fman_port_qmi_regs {
2304     #define HWP_HXS_PHE_REPORT 0x00000800
2305     #define HWP_HXS_PCAC_PSTAT 0x00000100
2306     #define HWP_HXS_PCAC_PSTOP 0x00000001
2307     +#define HWP_HXS_TCP_OFFSET 0xA
2308     +#define HWP_HXS_UDP_OFFSET 0xB
2309     +#define HWP_HXS_SH_PAD_REM 0x80000000
2310     +
2311     struct fman_port_hwp_regs {
2312     struct {
2313     u32 ssa; /* Soft Sequence Attachment */
2314     @@ -728,6 +732,10 @@ static void init_hwp(struct fman_port *port)
2315     iowrite32be(0xffffffff, &regs->pmda[i].lcv);
2316     }
2317    
2318     + /* Short packet padding removal from checksum calculation */
2319     + iowrite32be(HWP_HXS_SH_PAD_REM, &regs->pmda[HWP_HXS_TCP_OFFSET].ssa);
2320     + iowrite32be(HWP_HXS_SH_PAD_REM, &regs->pmda[HWP_HXS_UDP_OFFSET].ssa);
2321     +
2322     start_port_hwp(port);
2323     }
2324    
2325     diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
2326     index 98493be7b4af..046af22a37cb 100644
2327     --- a/drivers/net/ethernet/ibm/ibmvnic.c
2328     +++ b/drivers/net/ethernet/ibm/ibmvnic.c
2329     @@ -1463,8 +1463,8 @@ static int do_reset(struct ibmvnic_adapter *adapter,
2330    
2331     rc = ibmvnic_login(netdev);
2332     if (rc) {
2333     - adapter->state = VNIC_PROBED;
2334     - return 0;
2335     + adapter->state = reset_state;
2336     + return rc;
2337     }
2338    
2339     rc = reset_tx_pools(adapter);
2340     diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
2341     index 64429a14c630..815284fe9324 100644
2342     --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
2343     +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
2344     @@ -1895,7 +1895,12 @@ s32 ixgbe_set_rar_generic(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
2345     if (enable_addr != 0)
2346     rar_high |= IXGBE_RAH_AV;
2347    
2348     + /* Record lower 32 bits of MAC address and then make
2349     + * sure that write is flushed to hardware before writing
2350     + * the upper 16 bits and setting the valid bit.
2351     + */
2352     IXGBE_WRITE_REG(hw, IXGBE_RAL(index), rar_low);
2353     + IXGBE_WRITE_FLUSH(hw);
2354     IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
2355    
2356     return 0;
2357     @@ -1927,8 +1932,13 @@ s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index)
2358     rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));
2359     rar_high &= ~(0x0000FFFF | IXGBE_RAH_AV);
2360    
2361     - IXGBE_WRITE_REG(hw, IXGBE_RAL(index), 0);
2362     + /* Clear the address valid bit and upper 16 bits of the address
2363     + * before clearing the lower bits. This way we aren't updating
2364     + * a live filter.
2365     + */
2366     IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
2367     + IXGBE_WRITE_FLUSH(hw);
2368     + IXGBE_WRITE_REG(hw, IXGBE_RAL(index), 0);
2369    
2370     /* clear VMDq pool/queue selection for this RAR */
2371     hw->mac.ops.clear_vmdq(hw, index, IXGBE_CLEAR_VMDQ_ALL);
2372     diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
2373     index f697084937c3..de72b66df3e5 100644
2374     --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
2375     +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
2376     @@ -1525,17 +1525,15 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, int vport_num)
2377     }
2378    
2379     /* Public E-Switch API */
2380     -#define ESW_ALLOWED(esw) ((esw) && MLX5_VPORT_MANAGER((esw)->dev))
2381     +#define ESW_ALLOWED(esw) ((esw) && MLX5_ESWITCH_MANAGER((esw)->dev))
2382     +
2383    
2384     int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
2385     {
2386     int err;
2387     int i, enabled_events;
2388    
2389     - if (!ESW_ALLOWED(esw))
2390     - return 0;
2391     -
2392     - if (!MLX5_ESWITCH_MANAGER(esw->dev) ||
2393     + if (!ESW_ALLOWED(esw) ||
2394     !MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ft_support)) {
2395     esw_warn(esw->dev, "E-Switch FDB is not supported, aborting ...\n");
2396     return -EOPNOTSUPP;
2397     @@ -1728,7 +1726,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
2398     u64 node_guid;
2399     int err = 0;
2400    
2401     - if (!ESW_ALLOWED(esw))
2402     + if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
2403     return -EPERM;
2404     if (!LEGAL_VPORT(esw, vport) || is_multicast_ether_addr(mac))
2405     return -EINVAL;
2406     @@ -1805,7 +1803,7 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
2407     {
2408     struct mlx5_vport *evport;
2409    
2410     - if (!ESW_ALLOWED(esw))
2411     + if (!MLX5_CAP_GEN(esw->dev, vport_group_manager))
2412     return -EPERM;
2413     if (!LEGAL_VPORT(esw, vport))
2414     return -EINVAL;
2415     diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
2416     index 71153c0f1605..aa9a88e84e3b 100644
2417     --- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c
2418     +++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
2419     @@ -549,8 +549,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
2420     return -EINVAL;
2421     if (!MLX5_CAP_GEN(mdev, vport_group_manager))
2422     return -EACCES;
2423     - if (!MLX5_CAP_ESW(mdev, nic_vport_node_guid_modify))
2424     - return -EOPNOTSUPP;
2425    
2426     in = kvzalloc(inlen, GFP_KERNEL);
2427     if (!in)
2428     diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c
2429     index cd34097b79f1..37a6d7822a38 100644
2430     --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c
2431     +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c
2432     @@ -232,7 +232,7 @@ struct nfp_nffw_info *nfp_nffw_info_open(struct nfp_cpp *cpp)
2433     err = nfp_cpp_read(cpp, nfp_resource_cpp_id(state->res),
2434     nfp_resource_address(state->res),
2435     fwinf, sizeof(*fwinf));
2436     - if (err < sizeof(*fwinf))
2437     + if (err < (int)sizeof(*fwinf))
2438     goto err_release;
2439    
2440     if (!nffw_res_flg_init_get(fwinf))
2441     diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
2442     index b306961b02fd..d62dccb85539 100644
2443     --- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
2444     +++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
2445     @@ -255,9 +255,8 @@ qed_dcbx_get_app_protocol_type(struct qed_hwfn *p_hwfn,
2446     *type = DCBX_PROTOCOL_ROCE_V2;
2447     } else {
2448     *type = DCBX_MAX_PROTOCOL_TYPE;
2449     - DP_ERR(p_hwfn,
2450     - "No action required, App TLV id = 0x%x app_prio_bitmap = 0x%x\n",
2451     - id, app_prio_bitmap);
2452     + DP_ERR(p_hwfn, "No action required, App TLV entry = 0x%x\n",
2453     + app_prio_bitmap);
2454     return false;
2455     }
2456    
2457     @@ -1472,8 +1471,8 @@ static u8 qed_dcbnl_getcap(struct qed_dev *cdev, int capid, u8 *cap)
2458     *cap = 0x80;
2459     break;
2460     case DCB_CAP_ATTR_DCBX:
2461     - *cap = (DCB_CAP_DCBX_LLD_MANAGED | DCB_CAP_DCBX_VER_CEE |
2462     - DCB_CAP_DCBX_VER_IEEE | DCB_CAP_DCBX_STATIC);
2463     + *cap = (DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_VER_IEEE |
2464     + DCB_CAP_DCBX_STATIC);
2465     break;
2466     default:
2467     *cap = false;
2468     @@ -1541,8 +1540,6 @@ static u8 qed_dcbnl_getdcbx(struct qed_dev *cdev)
2469     if (!dcbx_info)
2470     return 0;
2471    
2472     - if (dcbx_info->operational.enabled)
2473     - mode |= DCB_CAP_DCBX_LLD_MANAGED;
2474     if (dcbx_info->operational.ieee)
2475     mode |= DCB_CAP_DCBX_VER_IEEE;
2476     if (dcbx_info->operational.cee)
2477     diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
2478     index c06ad4f0758e..5f52f14761a3 100644
2479     --- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
2480     +++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
2481     @@ -201,8 +201,9 @@ void qed_ll2b_complete_rx_packet(void *cxt, struct qed_ll2_comp_rx_data *data)
2482    
2483     skb = build_skb(buffer->data, 0);
2484     if (!skb) {
2485     - rc = -ENOMEM;
2486     - goto out_post;
2487     + DP_INFO(cdev, "Failed to build SKB\n");
2488     + kfree(buffer->data);
2489     + goto out_post1;
2490     }
2491    
2492     data->u.placement_offset += NET_SKB_PAD;
2493     @@ -224,8 +225,14 @@ void qed_ll2b_complete_rx_packet(void *cxt, struct qed_ll2_comp_rx_data *data)
2494     cdev->ll2->cbs->rx_cb(cdev->ll2->cb_cookie, skb,
2495     data->opaque_data_0,
2496     data->opaque_data_1);
2497     + } else {
2498     + DP_VERBOSE(p_hwfn, (NETIF_MSG_RX_STATUS | NETIF_MSG_PKTDATA |
2499     + QED_MSG_LL2 | QED_MSG_STORAGE),
2500     + "Dropping the packet\n");
2501     + kfree(buffer->data);
2502     }
2503    
2504     +out_post1:
2505     /* Update Buffer information and update FW producer */
2506     buffer->data = new_data;
2507     buffer->phys_addr = new_phys_addr;
2508     diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
2509     index 2c958921dfb3..954f7ce4cf28 100644
2510     --- a/drivers/net/ethernet/qlogic/qed/qed_main.c
2511     +++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
2512     @@ -565,8 +565,16 @@ static irqreturn_t qed_single_int(int irq, void *dev_instance)
2513     /* Fastpath interrupts */
2514     for (j = 0; j < 64; j++) {
2515     if ((0x2ULL << j) & status) {
2516     - hwfn->simd_proto_handler[j].func(
2517     - hwfn->simd_proto_handler[j].token);
2518     + struct qed_simd_fp_handler *p_handler =
2519     + &hwfn->simd_proto_handler[j];
2520     +
2521     + if (p_handler->func)
2522     + p_handler->func(p_handler->token);
2523     + else
2524     + DP_NOTICE(hwfn,
2525     + "Not calling fastpath handler as it is NULL [handler #%d, status 0x%llx]\n",
2526     + j, status);
2527     +
2528     status &= ~(0x2ULL << j);
2529     rc = IRQ_HANDLED;
2530     }
2531     diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
2532     index 287d89dd086f..9c94240bb05a 100644
2533     --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
2534     +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
2535     @@ -1128,6 +1128,8 @@ static ssize_t qlcnic_83xx_sysfs_flash_write_handler(struct file *filp,
2536     struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
2537    
2538     ret = kstrtoul(buf, 16, &data);
2539     + if (ret)
2540     + return ret;
2541    
2542     switch (data) {
2543     case QLC_83XX_FLASH_SECTOR_ERASE_CMD:
2544     diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
2545     index 9c236298fe21..b1f5f0b8e546 100644
2546     --- a/drivers/net/ethernet/qualcomm/qca_spi.c
2547     +++ b/drivers/net/ethernet/qualcomm/qca_spi.c
2548     @@ -658,7 +658,7 @@ qcaspi_netdev_open(struct net_device *dev)
2549     return ret;
2550     }
2551    
2552     - netif_start_queue(qca->net_dev);
2553     + /* SPI thread takes care of TX queue */
2554    
2555     return 0;
2556     }
2557     @@ -761,6 +761,9 @@ qcaspi_netdev_tx_timeout(struct net_device *dev)
2558     qca->net_dev->stats.tx_errors++;
2559     /* Trigger tx queue flush and QCA7000 reset */
2560     qca->sync = QCASPI_SYNC_UNKNOWN;
2561     +
2562     + if (qca->spi_thread)
2563     + wake_up_process(qca->spi_thread);
2564     }
2565    
2566     static int
2567     @@ -879,22 +882,22 @@ qca_spi_probe(struct spi_device *spi)
2568    
2569     if ((qcaspi_clkspeed < QCASPI_CLK_SPEED_MIN) ||
2570     (qcaspi_clkspeed > QCASPI_CLK_SPEED_MAX)) {
2571     - dev_info(&spi->dev, "Invalid clkspeed: %d\n",
2572     - qcaspi_clkspeed);
2573     + dev_err(&spi->dev, "Invalid clkspeed: %d\n",
2574     + qcaspi_clkspeed);
2575     return -EINVAL;
2576     }
2577    
2578     if ((qcaspi_burst_len < QCASPI_BURST_LEN_MIN) ||
2579     (qcaspi_burst_len > QCASPI_BURST_LEN_MAX)) {
2580     - dev_info(&spi->dev, "Invalid burst len: %d\n",
2581     - qcaspi_burst_len);
2582     + dev_err(&spi->dev, "Invalid burst len: %d\n",
2583     + qcaspi_burst_len);
2584     return -EINVAL;
2585     }
2586    
2587     if ((qcaspi_pluggable < QCASPI_PLUGGABLE_MIN) ||
2588     (qcaspi_pluggable > QCASPI_PLUGGABLE_MAX)) {
2589     - dev_info(&spi->dev, "Invalid pluggable: %d\n",
2590     - qcaspi_pluggable);
2591     + dev_err(&spi->dev, "Invalid pluggable: %d\n",
2592     + qcaspi_pluggable);
2593     return -EINVAL;
2594     }
2595    
2596     @@ -956,8 +959,8 @@ qca_spi_probe(struct spi_device *spi)
2597     }
2598    
2599     if (register_netdev(qcaspi_devs)) {
2600     - dev_info(&spi->dev, "Unable to register net device %s\n",
2601     - qcaspi_devs->name);
2602     + dev_err(&spi->dev, "Unable to register net device %s\n",
2603     + qcaspi_devs->name);
2604     free_netdev(qcaspi_devs);
2605     return -EFAULT;
2606     }
2607     diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
2608     index fdf30bfa403b..e87a779bfcfe 100644
2609     --- a/drivers/net/ethernet/renesas/ravb_main.c
2610     +++ b/drivers/net/ethernet/renesas/ravb_main.c
2611     @@ -959,6 +959,13 @@ static void ravb_adjust_link(struct net_device *ndev)
2612     struct ravb_private *priv = netdev_priv(ndev);
2613     struct phy_device *phydev = ndev->phydev;
2614     bool new_state = false;
2615     + unsigned long flags;
2616     +
2617     + spin_lock_irqsave(&priv->lock, flags);
2618     +
2619     + /* Disable TX and RX right over here, if E-MAC change is ignored */
2620     + if (priv->no_avb_link)
2621     + ravb_rcv_snd_disable(ndev);
2622    
2623     if (phydev->link) {
2624     if (phydev->duplex != priv->duplex) {
2625     @@ -976,18 +983,21 @@ static void ravb_adjust_link(struct net_device *ndev)
2626     ravb_modify(ndev, ECMR, ECMR_TXF, 0);
2627     new_state = true;
2628     priv->link = phydev->link;
2629     - if (priv->no_avb_link)
2630     - ravb_rcv_snd_enable(ndev);
2631     }
2632     } else if (priv->link) {
2633     new_state = true;
2634     priv->link = 0;
2635     priv->speed = 0;
2636     priv->duplex = -1;
2637     - if (priv->no_avb_link)
2638     - ravb_rcv_snd_disable(ndev);
2639     }
2640    
2641     + /* Enable TX and RX right over here, if E-MAC change is ignored */
2642     + if (priv->no_avb_link && phydev->link)
2643     + ravb_rcv_snd_enable(ndev);
2644     +
2645     + mmiowb();
2646     + spin_unlock_irqrestore(&priv->lock, flags);
2647     +
2648     if (new_state && netif_msg_link(priv))
2649     phy_print_status(phydev);
2650     }
2651     @@ -1094,52 +1104,18 @@ static int ravb_get_link_ksettings(struct net_device *ndev,
2652     static int ravb_set_link_ksettings(struct net_device *ndev,
2653     const struct ethtool_link_ksettings *cmd)
2654     {
2655     - struct ravb_private *priv = netdev_priv(ndev);
2656     - unsigned long flags;
2657     - int error;
2658     -
2659     if (!ndev->phydev)
2660     return -ENODEV;
2661    
2662     - spin_lock_irqsave(&priv->lock, flags);
2663     -
2664     - /* Disable TX and RX */
2665     - ravb_rcv_snd_disable(ndev);
2666     -
2667     - error = phy_ethtool_ksettings_set(ndev->phydev, cmd);
2668     - if (error)
2669     - goto error_exit;
2670     -
2671     - if (cmd->base.duplex == DUPLEX_FULL)
2672     - priv->duplex = 1;
2673     - else
2674     - priv->duplex = 0;
2675     -
2676     - ravb_set_duplex(ndev);
2677     -
2678     -error_exit:
2679     - mdelay(1);
2680     -
2681     - /* Enable TX and RX */
2682     - ravb_rcv_snd_enable(ndev);
2683     -
2684     - mmiowb();
2685     - spin_unlock_irqrestore(&priv->lock, flags);
2686     -
2687     - return error;
2688     + return phy_ethtool_ksettings_set(ndev->phydev, cmd);
2689     }
2690    
2691     static int ravb_nway_reset(struct net_device *ndev)
2692     {
2693     - struct ravb_private *priv = netdev_priv(ndev);
2694     int error = -ENODEV;
2695     - unsigned long flags;
2696    
2697     - if (ndev->phydev) {
2698     - spin_lock_irqsave(&priv->lock, flags);
2699     + if (ndev->phydev)
2700     error = phy_start_aneg(ndev->phydev);
2701     - spin_unlock_irqrestore(&priv->lock, flags);
2702     - }
2703    
2704     return error;
2705     }
2706     diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
2707     index 38080e95a82d..abfb9faadbc4 100644
2708     --- a/drivers/net/ethernet/renesas/sh_eth.c
2709     +++ b/drivers/net/ethernet/renesas/sh_eth.c
2710     @@ -1821,8 +1821,15 @@ static void sh_eth_adjust_link(struct net_device *ndev)
2711     {
2712     struct sh_eth_private *mdp = netdev_priv(ndev);
2713     struct phy_device *phydev = ndev->phydev;
2714     + unsigned long flags;
2715     int new_state = 0;
2716    
2717     + spin_lock_irqsave(&mdp->lock, flags);
2718     +
2719     + /* Disable TX and RX right over here, if E-MAC change is ignored */
2720     + if (mdp->cd->no_psr || mdp->no_ether_link)
2721     + sh_eth_rcv_snd_disable(ndev);
2722     +
2723     if (phydev->link) {
2724     if (phydev->duplex != mdp->duplex) {
2725     new_state = 1;
2726     @@ -1841,18 +1848,21 @@ static void sh_eth_adjust_link(struct net_device *ndev)
2727     sh_eth_modify(ndev, ECMR, ECMR_TXF, 0);
2728     new_state = 1;
2729     mdp->link = phydev->link;
2730     - if (mdp->cd->no_psr || mdp->no_ether_link)
2731     - sh_eth_rcv_snd_enable(ndev);
2732     }
2733     } else if (mdp->link) {
2734     new_state = 1;
2735     mdp->link = 0;
2736     mdp->speed = 0;
2737     mdp->duplex = -1;
2738     - if (mdp->cd->no_psr || mdp->no_ether_link)
2739     - sh_eth_rcv_snd_disable(ndev);
2740     }
2741    
2742     + /* Enable TX and RX right over here, if E-MAC change is ignored */
2743     + if ((mdp->cd->no_psr || mdp->no_ether_link) && phydev->link)
2744     + sh_eth_rcv_snd_enable(ndev);
2745     +
2746     + mmiowb();
2747     + spin_unlock_irqrestore(&mdp->lock, flags);
2748     +
2749     if (new_state && netif_msg_link(mdp))
2750     phy_print_status(phydev);
2751     }
2752     @@ -1933,39 +1943,10 @@ static int sh_eth_get_link_ksettings(struct net_device *ndev,
2753     static int sh_eth_set_link_ksettings(struct net_device *ndev,
2754     const struct ethtool_link_ksettings *cmd)
2755     {
2756     - struct sh_eth_private *mdp = netdev_priv(ndev);
2757     - unsigned long flags;
2758     - int ret;
2759     -
2760     if (!ndev->phydev)
2761     return -ENODEV;
2762    
2763     - spin_lock_irqsave(&mdp->lock, flags);
2764     -
2765     - /* disable tx and rx */
2766     - sh_eth_rcv_snd_disable(ndev);
2767     -
2768     - ret = phy_ethtool_ksettings_set(ndev->phydev, cmd);
2769     - if (ret)
2770     - goto error_exit;
2771     -
2772     - if (cmd->base.duplex == DUPLEX_FULL)
2773     - mdp->duplex = 1;
2774     - else
2775     - mdp->duplex = 0;
2776     -
2777     - if (mdp->cd->set_duplex)
2778     - mdp->cd->set_duplex(ndev);
2779     -
2780     -error_exit:
2781     - mdelay(1);
2782     -
2783     - /* enable tx and rx */
2784     - sh_eth_rcv_snd_enable(ndev);
2785     -
2786     - spin_unlock_irqrestore(&mdp->lock, flags);
2787     -
2788     - return ret;
2789     + return phy_ethtool_ksettings_set(ndev->phydev, cmd);
2790     }
2791    
2792     /* If it is ever necessary to increase SH_ETH_REG_DUMP_MAX_REGS, the
2793     @@ -2156,18 +2137,10 @@ static void sh_eth_get_regs(struct net_device *ndev, struct ethtool_regs *regs,
2794    
2795     static int sh_eth_nway_reset(struct net_device *ndev)
2796     {
2797     - struct sh_eth_private *mdp = netdev_priv(ndev);
2798     - unsigned long flags;
2799     - int ret;
2800     -
2801     if (!ndev->phydev)
2802     return -ENODEV;
2803    
2804     - spin_lock_irqsave(&mdp->lock, flags);
2805     - ret = phy_start_aneg(ndev->phydev);
2806     - spin_unlock_irqrestore(&mdp->lock, flags);
2807     -
2808     - return ret;
2809     + return phy_start_aneg(ndev->phydev);
2810     }
2811    
2812     static u32 sh_eth_get_msglevel(struct net_device *ndev)
2813     diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
2814     index 97035766c291..5790cd61436d 100644
2815     --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
2816     +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
2817     @@ -111,7 +111,7 @@ config DWMAC_ROCKCHIP
2818     config DWMAC_SOCFPGA
2819     tristate "SOCFPGA dwmac support"
2820     default ARCH_SOCFPGA
2821     - depends on OF && (ARCH_SOCFPGA || COMPILE_TEST)
2822     + depends on OF && (ARCH_SOCFPGA || ARCH_STRATIX10 || COMPILE_TEST)
2823     select MFD_SYSCON
2824     help
2825     Support for ethernet controller on Altera SOCFPGA
2826     diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
2827     index 6e359572b9f0..5b3b06a0a3bf 100644
2828     --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
2829     +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
2830     @@ -55,6 +55,7 @@ struct socfpga_dwmac {
2831     struct device *dev;
2832     struct regmap *sys_mgr_base_addr;
2833     struct reset_control *stmmac_rst;
2834     + struct reset_control *stmmac_ocp_rst;
2835     void __iomem *splitter_base;
2836     bool f2h_ptp_ref_clk;
2837     struct tse_pcs pcs;
2838     @@ -262,8 +263,8 @@ static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
2839     val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
2840    
2841     /* Assert reset to the enet controller before changing the phy mode */
2842     - if (dwmac->stmmac_rst)
2843     - reset_control_assert(dwmac->stmmac_rst);
2844     + reset_control_assert(dwmac->stmmac_ocp_rst);
2845     + reset_control_assert(dwmac->stmmac_rst);
2846    
2847     regmap_read(sys_mgr_base_addr, reg_offset, &ctrl);
2848     ctrl &= ~(SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << reg_shift);
2849     @@ -288,8 +289,8 @@ static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
2850     /* Deassert reset for the phy configuration to be sampled by
2851     * the enet controller, and operation to start in requested mode
2852     */
2853     - if (dwmac->stmmac_rst)
2854     - reset_control_deassert(dwmac->stmmac_rst);
2855     + reset_control_deassert(dwmac->stmmac_ocp_rst);
2856     + reset_control_deassert(dwmac->stmmac_rst);
2857     if (phymode == PHY_INTERFACE_MODE_SGMII) {
2858     if (tse_pcs_init(dwmac->pcs.tse_pcs_base, &dwmac->pcs) != 0) {
2859     dev_err(dwmac->dev, "Unable to initialize TSE PCS");
2860     @@ -324,6 +325,15 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
2861     goto err_remove_config_dt;
2862     }
2863    
2864     + dwmac->stmmac_ocp_rst = devm_reset_control_get_optional(dev, "stmmaceth-ocp");
2865     + if (IS_ERR(dwmac->stmmac_ocp_rst)) {
2866     + ret = PTR_ERR(dwmac->stmmac_ocp_rst);
2867     + dev_err(dev, "error getting reset control of ocp %d\n", ret);
2868     + goto err_remove_config_dt;
2869     + }
2870     +
2871     + reset_control_deassert(dwmac->stmmac_ocp_rst);
2872     +
2873     ret = socfpga_dwmac_parse_data(dwmac, dev);
2874     if (ret) {
2875     dev_err(dev, "Unable to parse OF data\n");
2876     diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
2877     index 4bb561856af5..47a096134043 100644
2878     --- a/drivers/net/ethernet/ti/davinci_emac.c
2879     +++ b/drivers/net/ethernet/ti/davinci_emac.c
2880     @@ -1387,6 +1387,10 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
2881    
2882     static int match_first_device(struct device *dev, void *data)
2883     {
2884     + if (dev->parent && dev->parent->of_node)
2885     + return of_device_is_compatible(dev->parent->of_node,
2886     + "ti,davinci_mdio");
2887     +
2888     return !strncmp(dev_name(dev), "davinci_mdio", 12);
2889     }
2890    
2891     diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
2892     index 78a6414c5fd9..7d94a7842557 100644
2893     --- a/drivers/net/hamradio/bpqether.c
2894     +++ b/drivers/net/hamradio/bpqether.c
2895     @@ -89,10 +89,6 @@
2896     static const char banner[] __initconst = KERN_INFO \
2897     "AX.25: bpqether driver version 004\n";
2898    
2899     -static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2900     -
2901     -static char bpq_eth_addr[6];
2902     -
2903     static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);
2904     static int bpq_device_event(struct notifier_block *, unsigned long, void *);
2905    
2906     @@ -515,8 +511,8 @@ static int bpq_new_device(struct net_device *edev)
2907     bpq->ethdev = edev;
2908     bpq->axdev = ndev;
2909    
2910     - memcpy(bpq->dest_addr, bcast_addr, sizeof(bpq_eth_addr));
2911     - memcpy(bpq->acpt_addr, bcast_addr, sizeof(bpq_eth_addr));
2912     + eth_broadcast_addr(bpq->dest_addr);
2913     + eth_broadcast_addr(bpq->acpt_addr);
2914    
2915     err = register_netdevice(ndev);
2916     if (err)
2917     diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
2918     index cb03a6ea076a..328c37e9096d 100644
2919     --- a/drivers/net/hyperv/rndis_filter.c
2920     +++ b/drivers/net/hyperv/rndis_filter.c
2921     @@ -1299,6 +1299,7 @@ out:
2922     /* setting up multiple channels failed */
2923     net_device->max_chn = 1;
2924     net_device->num_chn = 1;
2925     + return 0;
2926    
2927     err_dev_remv:
2928     rndis_filter_device_remove(dev, net_device);
2929     diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
2930     index 548d9d026a85..5c48bdb6f678 100644
2931     --- a/drivers/net/ieee802154/at86rf230.c
2932     +++ b/drivers/net/ieee802154/at86rf230.c
2933     @@ -940,7 +940,7 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
2934     static int
2935     at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
2936     {
2937     - BUG_ON(!level);
2938     + WARN_ON(!level);
2939     *level = 0xbe;
2940     return 0;
2941     }
2942     @@ -1121,8 +1121,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
2943     if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
2944     u16 addr = le16_to_cpu(filt->short_addr);
2945    
2946     - dev_vdbg(&lp->spi->dev,
2947     - "at86rf230_set_hw_addr_filt called for saddr\n");
2948     + dev_vdbg(&lp->spi->dev, "%s called for saddr\n", __func__);
2949     __at86rf230_write(lp, RG_SHORT_ADDR_0, addr);
2950     __at86rf230_write(lp, RG_SHORT_ADDR_1, addr >> 8);
2951     }
2952     @@ -1130,8 +1129,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
2953     if (changed & IEEE802154_AFILT_PANID_CHANGED) {
2954     u16 pan = le16_to_cpu(filt->pan_id);
2955    
2956     - dev_vdbg(&lp->spi->dev,
2957     - "at86rf230_set_hw_addr_filt called for pan id\n");
2958     + dev_vdbg(&lp->spi->dev, "%s called for pan id\n", __func__);
2959     __at86rf230_write(lp, RG_PAN_ID_0, pan);
2960     __at86rf230_write(lp, RG_PAN_ID_1, pan >> 8);
2961     }
2962     @@ -1140,15 +1138,13 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
2963     u8 i, addr[8];
2964    
2965     memcpy(addr, &filt->ieee_addr, 8);
2966     - dev_vdbg(&lp->spi->dev,
2967     - "at86rf230_set_hw_addr_filt called for IEEE addr\n");
2968     + dev_vdbg(&lp->spi->dev, "%s called for IEEE addr\n", __func__);
2969     for (i = 0; i < 8; i++)
2970     __at86rf230_write(lp, RG_IEEE_ADDR_0 + i, addr[i]);
2971     }
2972    
2973     if (changed & IEEE802154_AFILT_PANC_CHANGED) {
2974     - dev_vdbg(&lp->spi->dev,
2975     - "at86rf230_set_hw_addr_filt called for panc change\n");
2976     + dev_vdbg(&lp->spi->dev, "%s called for panc change\n", __func__);
2977     if (filt->pan_coord)
2978     at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1);
2979     else
2980     @@ -1252,7 +1248,6 @@ at86rf230_set_cca_mode(struct ieee802154_hw *hw,
2981     return at86rf230_write_subreg(lp, SR_CCA_MODE, val);
2982     }
2983    
2984     -
2985     static int
2986     at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
2987     {
2988     diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c
2989     index 0d673f7682ee..176395e4b7bb 100644
2990     --- a/drivers/net/ieee802154/fakelb.c
2991     +++ b/drivers/net/ieee802154/fakelb.c
2992     @@ -49,7 +49,7 @@ struct fakelb_phy {
2993    
2994     static int fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level)
2995     {
2996     - BUG_ON(!level);
2997     + WARN_ON(!level);
2998     *level = 0xbe;
2999    
3000     return 0;
3001     diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
3002     index e7f7a1a002ee..58133c9f701b 100644
3003     --- a/drivers/net/ipvlan/ipvlan_main.c
3004     +++ b/drivers/net/ipvlan/ipvlan_main.c
3005     @@ -73,10 +73,23 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval)
3006     {
3007     struct ipvl_dev *ipvlan;
3008     struct net_device *mdev = port->dev;
3009     - int err = 0;
3010     + unsigned int flags;
3011     + int err;
3012    
3013     ASSERT_RTNL();
3014     if (port->mode != nval) {
3015     + list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
3016     + flags = ipvlan->dev->flags;
3017     + if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S) {
3018     + err = dev_change_flags(ipvlan->dev,
3019     + flags | IFF_NOARP);
3020     + } else {
3021     + err = dev_change_flags(ipvlan->dev,
3022     + flags & ~IFF_NOARP);
3023     + }
3024     + if (unlikely(err))
3025     + goto fail;
3026     + }
3027     if (nval == IPVLAN_MODE_L3S) {
3028     /* New mode is L3S */
3029     err = ipvlan_register_nf_hook(read_pnet(&port->pnet));
3030     @@ -84,21 +97,28 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval)
3031     mdev->l3mdev_ops = &ipvl_l3mdev_ops;
3032     mdev->priv_flags |= IFF_L3MDEV_MASTER;
3033     } else
3034     - return err;
3035     + goto fail;
3036     } else if (port->mode == IPVLAN_MODE_L3S) {
3037     /* Old mode was L3S */
3038     mdev->priv_flags &= ~IFF_L3MDEV_MASTER;
3039     ipvlan_unregister_nf_hook(read_pnet(&port->pnet));
3040     mdev->l3mdev_ops = NULL;
3041     }
3042     - list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
3043     - if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S)
3044     - ipvlan->dev->flags |= IFF_NOARP;
3045     - else
3046     - ipvlan->dev->flags &= ~IFF_NOARP;
3047     - }
3048     port->mode = nval;
3049     }
3050     + return 0;
3051     +
3052     +fail:
3053     + /* Undo the flags changes that have been done so far. */
3054     + list_for_each_entry_continue_reverse(ipvlan, &port->ipvlans, pnode) {
3055     + flags = ipvlan->dev->flags;
3056     + if (port->mode == IPVLAN_MODE_L3 ||
3057     + port->mode == IPVLAN_MODE_L3S)
3058     + dev_change_flags(ipvlan->dev, flags | IFF_NOARP);
3059     + else
3060     + dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP);
3061     + }
3062     +
3063     return err;
3064     }
3065    
3066     diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
3067     index 5f565bd574da..48ba80a8ca5c 100644
3068     --- a/drivers/net/usb/rtl8150.c
3069     +++ b/drivers/net/usb/rtl8150.c
3070     @@ -681,7 +681,7 @@ static void rtl8150_set_multicast(struct net_device *netdev)
3071     (netdev->flags & IFF_ALLMULTI)) {
3072     rx_creg &= 0xfffe;
3073     rx_creg |= 0x0002;
3074     - dev_info(&netdev->dev, "%s: allmulti set\n", netdev->name);
3075     + dev_dbg(&netdev->dev, "%s: allmulti set\n", netdev->name);
3076     } else {
3077     /* ~RX_MULTICAST, ~RX_PROMISCUOUS */
3078     rx_creg &= 0x00fc;
3079     diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
3080     index 7a6a1fe79309..05553d252446 100644
3081     --- a/drivers/net/usb/smsc75xx.c
3082     +++ b/drivers/net/usb/smsc75xx.c
3083     @@ -82,6 +82,9 @@ static bool turbo_mode = true;
3084     module_param(turbo_mode, bool, 0644);
3085     MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
3086    
3087     +static int smsc75xx_link_ok_nopm(struct usbnet *dev);
3088     +static int smsc75xx_phy_gig_workaround(struct usbnet *dev);
3089     +
3090     static int __must_check __smsc75xx_read_reg(struct usbnet *dev, u32 index,
3091     u32 *data, int in_pm)
3092     {
3093     @@ -852,6 +855,9 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
3094     return -EIO;
3095     }
3096    
3097     + /* phy workaround for gig link */
3098     + smsc75xx_phy_gig_workaround(dev);
3099     +
3100     smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
3101     ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP |
3102     ADVERTISE_PAUSE_ASYM);
3103     @@ -987,6 +993,62 @@ static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm)
3104     return -EIO;
3105     }
3106    
3107     +static int smsc75xx_phy_gig_workaround(struct usbnet *dev)
3108     +{
3109     + struct mii_if_info *mii = &dev->mii;
3110     + int ret = 0, timeout = 0;
3111     + u32 buf, link_up = 0;
3112     +
3113     + /* Set the phy in Gig loopback */
3114     + smsc75xx_mdio_write(dev->net, mii->phy_id, MII_BMCR, 0x4040);
3115     +
3116     + /* Wait for the link up */
3117     + do {
3118     + link_up = smsc75xx_link_ok_nopm(dev);
3119     + usleep_range(10000, 20000);
3120     + timeout++;
3121     + } while ((!link_up) && (timeout < 1000));
3122     +
3123     + if (timeout >= 1000) {
3124     + netdev_warn(dev->net, "Timeout waiting for PHY link up\n");
3125     + return -EIO;
3126     + }
3127     +
3128     + /* phy reset */
3129     + ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
3130     + if (ret < 0) {
3131     + netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret);
3132     + return ret;
3133     + }
3134     +
3135     + buf |= PMT_CTL_PHY_RST;
3136     +
3137     + ret = smsc75xx_write_reg(dev, PMT_CTL, buf);
3138     + if (ret < 0) {
3139     + netdev_warn(dev->net, "Failed to write PMT_CTL: %d\n", ret);
3140     + return ret;
3141     + }
3142     +
3143     + timeout = 0;
3144     + do {
3145     + usleep_range(10000, 20000);
3146     + ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
3147     + if (ret < 0) {
3148     + netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n",
3149     + ret);
3150     + return ret;
3151     + }
3152     + timeout++;
3153     + } while ((buf & PMT_CTL_PHY_RST) && (timeout < 100));
3154     +
3155     + if (timeout >= 100) {
3156     + netdev_warn(dev->net, "timeout waiting for PHY Reset\n");
3157     + return -EIO;
3158     + }
3159     +
3160     + return 0;
3161     +}
3162     +
3163     static int smsc75xx_reset(struct usbnet *dev)
3164     {
3165     struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
3166     diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
3167     index df11bb449988..52ebed1f55a1 100644
3168     --- a/drivers/net/wireless/ath/ath10k/mac.c
3169     +++ b/drivers/net/wireless/ath/ath10k/mac.c
3170     @@ -5923,8 +5923,19 @@ static void ath10k_sta_rc_update_wk(struct work_struct *wk)
3171     ath10k_mac_max_vht_nss(vht_mcs_mask)));
3172    
3173     if (changed & IEEE80211_RC_BW_CHANGED) {
3174     - ath10k_dbg(ar, ATH10K_DBG_MAC, "mac update sta %pM peer bw %d\n",
3175     - sta->addr, bw);
3176     + enum wmi_phy_mode mode;
3177     +
3178     + mode = chan_to_phymode(&def);
3179     + ath10k_dbg(ar, ATH10K_DBG_MAC, "mac update sta %pM peer bw %d phymode %d\n",
3180     + sta->addr, bw, mode);
3181     +
3182     + err = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr,
3183     + WMI_PEER_PHYMODE, mode);
3184     + if (err) {
3185     + ath10k_warn(ar, "failed to update STA %pM peer phymode %d: %d\n",
3186     + sta->addr, mode, err);
3187     + goto exit;
3188     + }
3189    
3190     err = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr,
3191     WMI_PEER_CHAN_WIDTH, bw);
3192     @@ -5965,6 +5976,7 @@ static void ath10k_sta_rc_update_wk(struct work_struct *wk)
3193     sta->addr);
3194     }
3195    
3196     +exit:
3197     mutex_unlock(&ar->conf_mutex);
3198     }
3199    
3200     diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
3201     index bab876cf25fe..d0e05aa437e3 100644
3202     --- a/drivers/net/wireless/ath/ath10k/wmi.h
3203     +++ b/drivers/net/wireless/ath/ath10k/wmi.h
3204     @@ -6002,6 +6002,7 @@ enum wmi_peer_param {
3205     WMI_PEER_NSS = 0x5,
3206     WMI_PEER_USE_4ADDR = 0x6,
3207     WMI_PEER_DEBUG = 0xa,
3208     + WMI_PEER_PHYMODE = 0xd,
3209     WMI_PEER_DUMMY_VAR = 0xff, /* dummy parameter for STA PS workaround */
3210     };
3211    
3212     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
3213     index eccd25febfe6..4c28b04ea605 100644
3214     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
3215     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
3216     @@ -4245,6 +4245,13 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)
3217     brcmf_dbg(TRACE, "Enter\n");
3218    
3219     if (bus) {
3220     + /* Stop watchdog task */
3221     + if (bus->watchdog_tsk) {
3222     + send_sig(SIGTERM, bus->watchdog_tsk, 1);
3223     + kthread_stop(bus->watchdog_tsk);
3224     + bus->watchdog_tsk = NULL;
3225     + }
3226     +
3227     /* De-register interrupt handler */
3228     brcmf_sdiod_intr_unregister(bus->sdiodev);
3229    
3230     diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
3231     index d5553c47014f..5d823e965883 100644
3232     --- a/drivers/nfc/pn533/usb.c
3233     +++ b/drivers/nfc/pn533/usb.c
3234     @@ -74,7 +74,7 @@ static void pn533_recv_response(struct urb *urb)
3235     struct sk_buff *skb = NULL;
3236    
3237     if (!urb->status) {
3238     - skb = alloc_skb(urb->actual_length, GFP_KERNEL);
3239     + skb = alloc_skb(urb->actual_length, GFP_ATOMIC);
3240     if (!skb) {
3241     nfc_err(&phy->udev->dev, "failed to alloc memory\n");
3242     } else {
3243     @@ -186,7 +186,7 @@ static int pn533_usb_send_frame(struct pn533 *dev,
3244    
3245     if (dev->protocol_type == PN533_PROTO_REQ_RESP) {
3246     /* request for response for sent packet directly */
3247     - rc = pn533_submit_urb_for_response(phy, GFP_ATOMIC);
3248     + rc = pn533_submit_urb_for_response(phy, GFP_KERNEL);
3249     if (rc)
3250     goto error;
3251     } else if (dev->protocol_type == PN533_PROTO_REQ_ACK_RESP) {
3252     diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
3253     index 38c128f230e7..3a63d58d2ca9 100644
3254     --- a/drivers/nvme/host/core.c
3255     +++ b/drivers/nvme/host/core.c
3256     @@ -1016,7 +1016,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
3257    
3258     status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c,
3259     (void __user *)(uintptr_t)cmd.addr, cmd.data_len,
3260     - (void __user *)(uintptr_t)cmd.metadata, cmd.metadata,
3261     + (void __user *)(uintptr_t)cmd.metadata, cmd.metadata_len,
3262     0, &cmd.result, timeout);
3263     if (status >= 0) {
3264     if (put_user(cmd.result, &ucmd->result))
3265     diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
3266     index 240b0d628222..5fa7856f6b34 100644
3267     --- a/drivers/nvme/target/core.c
3268     +++ b/drivers/nvme/target/core.c
3269     @@ -598,6 +598,14 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)
3270     }
3271    
3272     ctrl->csts = NVME_CSTS_RDY;
3273     +
3274     + /*
3275     + * Controllers that are not yet enabled should not really enforce the
3276     + * keep alive timeout, but we still want to track a timeout and cleanup
3277     + * in case a host died before it enabled the controller. Hence, simply
3278     + * reset the keep alive timer when the controller is enabled.
3279     + */
3280     + mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
3281     }
3282    
3283     static void nvmet_clear_ctrl(struct nvmet_ctrl *ctrl)
3284     diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
3285     index 2afafd5d8915..635886e4835c 100644
3286     --- a/drivers/nvmem/core.c
3287     +++ b/drivers/nvmem/core.c
3288     @@ -865,6 +865,10 @@ struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *cell_id)
3289     return cell;
3290     }
3291    
3292     + /* NULL cell_id only allowed for device tree; invalid otherwise */
3293     + if (!cell_id)
3294     + return ERR_PTR(-EINVAL);
3295     +
3296     return nvmem_cell_get_from_list(cell_id);
3297     }
3298     EXPORT_SYMBOL_GPL(nvmem_cell_get);
3299     diff --git a/drivers/pci/host/pci-ftpci100.c b/drivers/pci/host/pci-ftpci100.c
3300     index 4ea7d2ebcc5c..4e6b21931514 100644
3301     --- a/drivers/pci/host/pci-ftpci100.c
3302     +++ b/drivers/pci/host/pci-ftpci100.c
3303     @@ -353,11 +353,13 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p)
3304     irq = of_irq_get(intc, 0);
3305     if (irq <= 0) {
3306     dev_err(p->dev, "failed to get parent IRQ\n");
3307     + of_node_put(intc);
3308     return irq ?: -EINVAL;
3309     }
3310    
3311     p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX,
3312     &faraday_pci_irqdomain_ops, p);
3313     + of_node_put(intc);
3314     if (!p->irqdomain) {
3315     dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n");
3316     return -EINVAL;
3317     diff --git a/drivers/pci/host/pci-host-common.c b/drivers/pci/host/pci-host-common.c
3318     index 44a47d4f0b8f..148896f73c06 100644
3319     --- a/drivers/pci/host/pci-host-common.c
3320     +++ b/drivers/pci/host/pci-host-common.c
3321     @@ -45,7 +45,7 @@ static int gen_pci_parse_request_of_pci_ranges(struct device *dev,
3322    
3323     switch (resource_type(res)) {
3324     case IORESOURCE_IO:
3325     - err = pci_remap_iospace(res, iobase);
3326     + err = devm_pci_remap_iospace(dev, res, iobase);
3327     if (err) {
3328     dev_warn(dev, "error %d: failed to map resource %pR\n",
3329     err, res);
3330     diff --git a/drivers/pci/host/pci-versatile.c b/drivers/pci/host/pci-versatile.c
3331     index d417acab0ecf..aff4cfb555fb 100644
3332     --- a/drivers/pci/host/pci-versatile.c
3333     +++ b/drivers/pci/host/pci-versatile.c
3334     @@ -89,7 +89,7 @@ static int versatile_pci_parse_request_of_pci_ranges(struct device *dev,
3335    
3336     switch (resource_type(res)) {
3337     case IORESOURCE_IO:
3338     - err = pci_remap_iospace(res, iobase);
3339     + err = devm_pci_remap_iospace(dev, res, iobase);
3340     if (err) {
3341     dev_warn(dev, "error %d: failed to map resource %pR\n",
3342     err, res);
3343     diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
3344     index 8f44a7d14bff..41edce16a07c 100644
3345     --- a/drivers/pci/host/pcie-rcar.c
3346     +++ b/drivers/pci/host/pcie-rcar.c
3347     @@ -1105,7 +1105,7 @@ static int rcar_pcie_parse_request_of_pci_ranges(struct rcar_pcie *pci)
3348     struct resource *res = win->res;
3349    
3350     if (resource_type(res) == IORESOURCE_IO) {
3351     - err = pci_remap_iospace(res, iobase);
3352     + err = devm_pci_remap_iospace(dev, res, iobase);
3353     if (err) {
3354     dev_warn(dev, "error %d: failed to map resource %pR\n",
3355     err, res);
3356     diff --git a/drivers/pci/host/pcie-xilinx-nwl.c b/drivers/pci/host/pcie-xilinx-nwl.c
3357     index 65dea98b2643..dd527ea558d7 100644
3358     --- a/drivers/pci/host/pcie-xilinx-nwl.c
3359     +++ b/drivers/pci/host/pcie-xilinx-nwl.c
3360     @@ -561,7 +561,7 @@ static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie)
3361     PCI_NUM_INTX,
3362     &legacy_domain_ops,
3363     pcie);
3364     -
3365     + of_node_put(legacy_intc_node);
3366     if (!pcie->legacy_irq_domain) {
3367     dev_err(dev, "failed to create IRQ domain\n");
3368     return -ENOMEM;
3369     diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c
3370     index 94e13cb8608f..29f024f0ed7f 100644
3371     --- a/drivers/pci/host/pcie-xilinx.c
3372     +++ b/drivers/pci/host/pcie-xilinx.c
3373     @@ -511,6 +511,7 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port)
3374     port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
3375     &intx_domain_ops,
3376     port);
3377     + of_node_put(pcie_intc_node);
3378     if (!port->leg_domain) {
3379     dev_err(dev, "Failed to get a INTx IRQ domain\n");
3380     return -ENODEV;
3381     diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
3382     index 7b0e97be9063..591f2e05ab1c 100644
3383     --- a/drivers/pci/hotplug/pci_hotplug_core.c
3384     +++ b/drivers/pci/hotplug/pci_hotplug_core.c
3385     @@ -452,8 +452,17 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
3386     list_add(&slot->slot_list, &pci_hotplug_slot_list);
3387    
3388     result = fs_add_slot(pci_slot);
3389     + if (result)
3390     + goto err_list_del;
3391     +
3392     kobject_uevent(&pci_slot->kobj, KOBJ_ADD);
3393     dbg("Added slot %s to the list\n", name);
3394     + goto out;
3395     +
3396     +err_list_del:
3397     + list_del(&slot->slot_list);
3398     + pci_slot->hotplug = NULL;
3399     + pci_destroy_slot(pci_slot);
3400     out:
3401     mutex_unlock(&pci_hp_mutex);
3402     return result;
3403     diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
3404     index e7d6cfaf3865..9fc4357c3db9 100644
3405     --- a/drivers/pci/hotplug/pciehp.h
3406     +++ b/drivers/pci/hotplug/pciehp.h
3407     @@ -132,6 +132,7 @@ int pciehp_unconfigure_device(struct slot *p_slot);
3408     void pciehp_queue_pushbutton_work(struct work_struct *work);
3409     struct controller *pcie_init(struct pcie_device *dev);
3410     int pcie_init_notification(struct controller *ctrl);
3411     +void pcie_shutdown_notification(struct controller *ctrl);
3412     int pciehp_enable_slot(struct slot *p_slot);
3413     int pciehp_disable_slot(struct slot *p_slot);
3414     void pcie_reenable_notification(struct controller *ctrl);
3415     diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
3416     index 1288289cc85d..c38e392d63e4 100644
3417     --- a/drivers/pci/hotplug/pciehp_core.c
3418     +++ b/drivers/pci/hotplug/pciehp_core.c
3419     @@ -76,6 +76,12 @@ static int reset_slot(struct hotplug_slot *slot, int probe);
3420     */
3421     static void release_slot(struct hotplug_slot *hotplug_slot)
3422     {
3423     + struct slot *slot = hotplug_slot->private;
3424     +
3425     + /* queued work needs hotplug_slot name */
3426     + cancel_delayed_work(&slot->work);
3427     + drain_workqueue(slot->wq);
3428     +
3429     kfree(hotplug_slot->ops);
3430     kfree(hotplug_slot->info);
3431     kfree(hotplug_slot);
3432     @@ -278,6 +284,7 @@ static void pciehp_remove(struct pcie_device *dev)
3433     {
3434     struct controller *ctrl = get_service_data(dev);
3435    
3436     + pcie_shutdown_notification(ctrl);
3437     cleanup_slot(ctrl);
3438     pciehp_release_ctrl(ctrl);
3439     }
3440     diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
3441     index 46c2ee2caf28..2fa830727362 100644
3442     --- a/drivers/pci/hotplug/pciehp_hpc.c
3443     +++ b/drivers/pci/hotplug/pciehp_hpc.c
3444     @@ -562,8 +562,6 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id)
3445     {
3446     struct controller *ctrl = (struct controller *)dev_id;
3447     struct pci_dev *pdev = ctrl_dev(ctrl);
3448     - struct pci_bus *subordinate = pdev->subordinate;
3449     - struct pci_dev *dev;
3450     struct slot *slot = ctrl->slot;
3451     u16 status, events;
3452     u8 present;
3453     @@ -611,14 +609,9 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id)
3454     wake_up(&ctrl->queue);
3455     }
3456    
3457     - if (subordinate) {
3458     - list_for_each_entry(dev, &subordinate->devices, bus_list) {
3459     - if (dev->ignore_hotplug) {
3460     - ctrl_dbg(ctrl, "ignoring hotplug event %#06x (%s requested no hotplug)\n",
3461     - events, pci_name(dev));
3462     - return IRQ_HANDLED;
3463     - }
3464     - }
3465     + if (pdev->ignore_hotplug) {
3466     + ctrl_dbg(ctrl, "ignoring hotplug event %#06x\n", events);
3467     + return IRQ_HANDLED;
3468     }
3469    
3470     /* Check Attention Button Pressed */
3471     @@ -789,7 +782,7 @@ int pcie_init_notification(struct controller *ctrl)
3472     return 0;
3473     }
3474    
3475     -static void pcie_shutdown_notification(struct controller *ctrl)
3476     +void pcie_shutdown_notification(struct controller *ctrl)
3477     {
3478     if (ctrl->notification_enabled) {
3479     pcie_disable_notification(ctrl);
3480     @@ -824,7 +817,7 @@ abort:
3481     static void pcie_cleanup_slot(struct controller *ctrl)
3482     {
3483     struct slot *slot = ctrl->slot;
3484     - cancel_delayed_work(&slot->work);
3485     +
3486     destroy_workqueue(slot->wq);
3487     kfree(slot);
3488     }
3489     @@ -912,7 +905,6 @@ abort:
3490    
3491     void pciehp_release_ctrl(struct controller *ctrl)
3492     {
3493     - pcie_shutdown_notification(ctrl);
3494     pcie_cleanup_slot(ctrl);
3495     kfree(ctrl);
3496     }
3497     diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
3498     index 62a0677b32f1..22924629e64a 100644
3499     --- a/drivers/pci/pci.c
3500     +++ b/drivers/pci/pci.c
3501     @@ -3446,6 +3446,44 @@ void pci_unmap_iospace(struct resource *res)
3502     }
3503     EXPORT_SYMBOL(pci_unmap_iospace);
3504    
3505     +static void devm_pci_unmap_iospace(struct device *dev, void *ptr)
3506     +{
3507     + struct resource **res = ptr;
3508     +
3509     + pci_unmap_iospace(*res);
3510     +}
3511     +
3512     +/**
3513     + * devm_pci_remap_iospace - Managed pci_remap_iospace()
3514     + * @dev: Generic device to remap IO address for
3515     + * @res: Resource describing the I/O space
3516     + * @phys_addr: physical address of range to be mapped
3517     + *
3518     + * Managed pci_remap_iospace(). Map is automatically unmapped on driver
3519     + * detach.
3520     + */
3521     +int devm_pci_remap_iospace(struct device *dev, const struct resource *res,
3522     + phys_addr_t phys_addr)
3523     +{
3524     + const struct resource **ptr;
3525     + int error;
3526     +
3527     + ptr = devres_alloc(devm_pci_unmap_iospace, sizeof(*ptr), GFP_KERNEL);
3528     + if (!ptr)
3529     + return -ENOMEM;
3530     +
3531     + error = pci_remap_iospace(res, phys_addr);
3532     + if (error) {
3533     + devres_free(ptr);
3534     + } else {
3535     + *ptr = res;
3536     + devres_add(dev, ptr);
3537     + }
3538     +
3539     + return error;
3540     +}
3541     +EXPORT_SYMBOL(devm_pci_remap_iospace);
3542     +
3543     /**
3544     * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace()
3545     * @dev: Generic device to remap IO address for
3546     diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
3547     index 4bccaf688aad..e23bfd9845b1 100644
3548     --- a/drivers/pci/probe.c
3549     +++ b/drivers/pci/probe.c
3550     @@ -1560,6 +1560,10 @@ static void pci_configure_mps(struct pci_dev *dev)
3551     if (!pci_is_pcie(dev) || !bridge || !pci_is_pcie(bridge))
3552     return;
3553    
3554     + /* MPS and MRRS fields are of type 'RsvdP' for VFs, short-circuit out */
3555     + if (dev->is_virtfn)
3556     + return;
3557     +
3558     mps = pcie_get_mps(dev);
3559     p_mps = pcie_get_mps(bridge);
3560    
3561     diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c
3562     index eb23311bc70c..8b79c2f7931f 100644
3563     --- a/drivers/perf/xgene_pmu.c
3564     +++ b/drivers/perf/xgene_pmu.c
3565     @@ -1463,7 +1463,7 @@ static char *xgene_pmu_dev_name(struct device *dev, u32 type, int id)
3566     case PMU_TYPE_IOB:
3567     return devm_kasprintf(dev, GFP_KERNEL, "iob%d", id);
3568     case PMU_TYPE_IOB_SLOW:
3569     - return devm_kasprintf(dev, GFP_KERNEL, "iob-slow%d", id);
3570     + return devm_kasprintf(dev, GFP_KERNEL, "iob_slow%d", id);
3571     case PMU_TYPE_MCB:
3572     return devm_kasprintf(dev, GFP_KERNEL, "mcb%d", id);
3573     case PMU_TYPE_MC:
3574     diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
3575     index 35c17653c694..87618a4e90e4 100644
3576     --- a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
3577     +++ b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
3578     @@ -460,8 +460,8 @@ static int nsp_pinmux_enable(struct pinctrl_dev *pctrl_dev,
3579     const struct nsp_pin_function *func;
3580     const struct nsp_pin_group *grp;
3581    
3582     - if (grp_select > pinctrl->num_groups ||
3583     - func_select > pinctrl->num_functions)
3584     + if (grp_select >= pinctrl->num_groups ||
3585     + func_select >= pinctrl->num_functions)
3586     return -EINVAL;
3587    
3588     func = &pinctrl->functions[func_select];
3589     @@ -577,6 +577,8 @@ static int nsp_pinmux_probe(struct platform_device *pdev)
3590     return PTR_ERR(pinctrl->base0);
3591    
3592     res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
3593     + if (!res)
3594     + return -EINVAL;
3595     pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start,
3596     resource_size(res));
3597     if (!pinctrl->base1) {
3598     diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
3599     index d84761822243..103aaab41357 100644
3600     --- a/drivers/pinctrl/pinctrl-ingenic.c
3601     +++ b/drivers/pinctrl/pinctrl-ingenic.c
3602     @@ -536,7 +536,7 @@ static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
3603     ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, input);
3604     } else {
3605     ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false);
3606     - ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, input);
3607     + ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input);
3608     ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false);
3609     }
3610    
3611     diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
3612     index 82f05c4b8c52..ae7a49ade414 100644
3613     --- a/drivers/s390/cio/vfio_ccw_drv.c
3614     +++ b/drivers/s390/cio/vfio_ccw_drv.c
3615     @@ -176,6 +176,7 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
3616     {
3617     struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev);
3618     unsigned long flags;
3619     + int rc = -EAGAIN;
3620    
3621     spin_lock_irqsave(sch->lock, flags);
3622     if (!device_is_registered(&sch->dev))
3623     @@ -186,6 +187,7 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
3624    
3625     if (cio_update_schib(sch)) {
3626     vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_NOT_OPER);
3627     + rc = 0;
3628     goto out_unlock;
3629     }
3630    
3631     @@ -194,11 +196,12 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
3632     private->state = private->mdev ? VFIO_CCW_STATE_IDLE :
3633     VFIO_CCW_STATE_STANDBY;
3634     }
3635     + rc = 0;
3636    
3637     out_unlock:
3638     spin_unlock_irqrestore(sch->lock, flags);
3639    
3640     - return 0;
3641     + return rc;
3642     }
3643    
3644     static struct css_device_id vfio_ccw_sch_ids[] = {
3645     diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
3646     index 382edb79a0de..56bcdd412d26 100644
3647     --- a/drivers/scsi/qedf/qedf_main.c
3648     +++ b/drivers/scsi/qedf/qedf_main.c
3649     @@ -3240,6 +3240,11 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
3650    
3651     init_completion(&qedf->flogi_compl);
3652    
3653     + status = qed_ops->common->update_drv_state(qedf->cdev, true);
3654     + if (status)
3655     + QEDF_ERR(&(qedf->dbg_ctx),
3656     + "Failed to send drv state to MFW.\n");
3657     +
3658     memset(&link_params, 0, sizeof(struct qed_link_params));
3659     link_params.link_up = true;
3660     status = qed_ops->common->set_link(qedf->cdev, &link_params);
3661     @@ -3288,6 +3293,7 @@ static int qedf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
3662     static void __qedf_remove(struct pci_dev *pdev, int mode)
3663     {
3664     struct qedf_ctx *qedf;
3665     + int rc;
3666    
3667     if (!pdev) {
3668     QEDF_ERR(NULL, "pdev is NULL.\n");
3669     @@ -3382,6 +3388,12 @@ static void __qedf_remove(struct pci_dev *pdev, int mode)
3670     qed_ops->common->set_power_state(qedf->cdev, PCI_D0);
3671     pci_set_drvdata(pdev, NULL);
3672     }
3673     +
3674     + rc = qed_ops->common->update_drv_state(qedf->cdev, false);
3675     + if (rc)
3676     + QEDF_ERR(&(qedf->dbg_ctx),
3677     + "Failed to send drv state to MFW.\n");
3678     +
3679     qed_ops->common->slowpath_stop(qedf->cdev);
3680     qed_ops->common->remove(qedf->cdev);
3681    
3682     diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
3683     index 1573749fe615..e7daadc089fc 100644
3684     --- a/drivers/scsi/qedi/qedi_main.c
3685     +++ b/drivers/scsi/qedi/qedi_main.c
3686     @@ -2087,6 +2087,7 @@ kset_free:
3687     static void __qedi_remove(struct pci_dev *pdev, int mode)
3688     {
3689     struct qedi_ctx *qedi = pci_get_drvdata(pdev);
3690     + int rval;
3691    
3692     if (qedi->tmf_thread) {
3693     flush_workqueue(qedi->tmf_thread);
3694     @@ -2116,6 +2117,10 @@ static void __qedi_remove(struct pci_dev *pdev, int mode)
3695     if (mode == QEDI_MODE_NORMAL)
3696     qedi_free_iscsi_pf_param(qedi);
3697    
3698     + rval = qedi_ops->common->update_drv_state(qedi->cdev, false);
3699     + if (rval)
3700     + QEDI_ERR(&qedi->dbg_ctx, "Failed to send drv state to MFW\n");
3701     +
3702     if (!test_bit(QEDI_IN_OFFLINE, &qedi->flags)) {
3703     qedi_ops->common->slowpath_stop(qedi->cdev);
3704     qedi_ops->common->remove(qedi->cdev);
3705     @@ -2390,6 +2395,12 @@ static int __qedi_probe(struct pci_dev *pdev, int mode)
3706     if (qedi_setup_boot_info(qedi))
3707     QEDI_ERR(&qedi->dbg_ctx,
3708     "No iSCSI boot target configured\n");
3709     +
3710     + rc = qedi_ops->common->update_drv_state(qedi->cdev, true);
3711     + if (rc)
3712     + QEDI_ERR(&qedi->dbg_ctx,
3713     + "Failed to send drv state to MFW\n");
3714     +
3715     }
3716    
3717     return 0;
3718     diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
3719     index 36f59a1be7e9..61389bdc7926 100644
3720     --- a/drivers/scsi/xen-scsifront.c
3721     +++ b/drivers/scsi/xen-scsifront.c
3722     @@ -654,10 +654,17 @@ static int scsifront_dev_reset_handler(struct scsi_cmnd *sc)
3723     static int scsifront_sdev_configure(struct scsi_device *sdev)
3724     {
3725     struct vscsifrnt_info *info = shost_priv(sdev->host);
3726     + int err;
3727    
3728     - if (info && current == info->curr)
3729     - xenbus_printf(XBT_NIL, info->dev->nodename,
3730     + if (info && current == info->curr) {
3731     + err = xenbus_printf(XBT_NIL, info->dev->nodename,
3732     info->dev_state_path, "%d", XenbusStateConnected);
3733     + if (err) {
3734     + xenbus_dev_error(info->dev, err,
3735     + "%s: writing dev_state_path", __func__);
3736     + return err;
3737     + }
3738     + }
3739    
3740     return 0;
3741     }
3742     @@ -665,10 +672,15 @@ static int scsifront_sdev_configure(struct scsi_device *sdev)
3743     static void scsifront_sdev_destroy(struct scsi_device *sdev)
3744     {
3745     struct vscsifrnt_info *info = shost_priv(sdev->host);
3746     + int err;
3747    
3748     - if (info && current == info->curr)
3749     - xenbus_printf(XBT_NIL, info->dev->nodename,
3750     + if (info && current == info->curr) {
3751     + err = xenbus_printf(XBT_NIL, info->dev->nodename,
3752     info->dev_state_path, "%d", XenbusStateClosed);
3753     + if (err)
3754     + xenbus_dev_error(info->dev, err,
3755     + "%s: writing dev_state_path", __func__);
3756     + }
3757     }
3758    
3759     static struct scsi_host_template scsifront_sht = {
3760     @@ -1003,9 +1015,12 @@ static void scsifront_do_lun_hotplug(struct vscsifrnt_info *info, int op)
3761    
3762     if (scsi_add_device(info->host, chn, tgt, lun)) {
3763     dev_err(&dev->dev, "scsi_add_device\n");
3764     - xenbus_printf(XBT_NIL, dev->nodename,
3765     + err = xenbus_printf(XBT_NIL, dev->nodename,
3766     info->dev_state_path,
3767     "%d", XenbusStateClosed);
3768     + if (err)
3769     + xenbus_dev_error(dev, err,
3770     + "%s: writing dev_state_path", __func__);
3771     }
3772     break;
3773     case VSCSIFRONT_OP_DEL_LUN:
3774     @@ -1019,10 +1034,14 @@ static void scsifront_do_lun_hotplug(struct vscsifrnt_info *info, int op)
3775     }
3776     break;
3777     case VSCSIFRONT_OP_READD_LUN:
3778     - if (device_state == XenbusStateConnected)
3779     - xenbus_printf(XBT_NIL, dev->nodename,
3780     + if (device_state == XenbusStateConnected) {
3781     + err = xenbus_printf(XBT_NIL, dev->nodename,
3782     info->dev_state_path,
3783     "%d", XenbusStateConnected);
3784     + if (err)
3785     + xenbus_dev_error(dev, err,
3786     + "%s: writing dev_state_path", __func__);
3787     + }
3788     break;
3789     default:
3790     break;
3791     diff --git a/drivers/soc/imx/gpc.c b/drivers/soc/imx/gpc.c
3792     index 1613ccf0c059..c54d229f8da4 100644
3793     --- a/drivers/soc/imx/gpc.c
3794     +++ b/drivers/soc/imx/gpc.c
3795     @@ -27,9 +27,16 @@
3796     #define GPC_PGC_SW2ISO_SHIFT 0x8
3797     #define GPC_PGC_SW_SHIFT 0x0
3798    
3799     +#define GPC_PGC_PCI_PDN 0x200
3800     +#define GPC_PGC_PCI_SR 0x20c
3801     +
3802     #define GPC_PGC_GPU_PDN 0x260
3803     #define GPC_PGC_GPU_PUPSCR 0x264
3804     #define GPC_PGC_GPU_PDNSCR 0x268
3805     +#define GPC_PGC_GPU_SR 0x26c
3806     +
3807     +#define GPC_PGC_DISP_PDN 0x240
3808     +#define GPC_PGC_DISP_SR 0x24c
3809    
3810     #define GPU_VPU_PUP_REQ BIT(1)
3811     #define GPU_VPU_PDN_REQ BIT(0)
3812     @@ -303,10 +310,24 @@ static const struct of_device_id imx_gpc_dt_ids[] = {
3813     { }
3814     };
3815    
3816     +static const struct regmap_range yes_ranges[] = {
3817     + regmap_reg_range(GPC_CNTR, GPC_CNTR),
3818     + regmap_reg_range(GPC_PGC_PCI_PDN, GPC_PGC_PCI_SR),
3819     + regmap_reg_range(GPC_PGC_GPU_PDN, GPC_PGC_GPU_SR),
3820     + regmap_reg_range(GPC_PGC_DISP_PDN, GPC_PGC_DISP_SR),
3821     +};
3822     +
3823     +static const struct regmap_access_table access_table = {
3824     + .yes_ranges = yes_ranges,
3825     + .n_yes_ranges = ARRAY_SIZE(yes_ranges),
3826     +};
3827     +
3828     static const struct regmap_config imx_gpc_regmap_config = {
3829     .reg_bits = 32,
3830     .val_bits = 32,
3831     .reg_stride = 4,
3832     + .rd_table = &access_table,
3833     + .wr_table = &access_table,
3834     .max_register = 0x2ac,
3835     };
3836    
3837     diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
3838     index f4e3bd40c72e..6ef18cf8f243 100644
3839     --- a/drivers/soc/imx/gpcv2.c
3840     +++ b/drivers/soc/imx/gpcv2.c
3841     @@ -39,10 +39,15 @@
3842    
3843     #define GPC_M4_PU_PDN_FLG 0x1bc
3844    
3845     -
3846     -#define PGC_MIPI 4
3847     -#define PGC_PCIE 5
3848     -#define PGC_USB_HSIC 8
3849     +/*
3850     + * The PGC offset values in Reference Manual
3851     + * (Rev. 1, 01/2018 and the older ones) GPC chapter's
3852     + * GPC_PGC memory map are incorrect, below offset
3853     + * values are from design RTL.
3854     + */
3855     +#define PGC_MIPI 16
3856     +#define PGC_PCIE 17
3857     +#define PGC_USB_HSIC 20
3858     #define GPC_PGC_CTRL(n) (0x800 + (n) * 0x40)
3859     #define GPC_PGC_SR(n) (GPC_PGC_CTRL(n) + 0xc)
3860    
3861     diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
3862     index 8af62e74d54c..f237e31926f4 100644
3863     --- a/drivers/staging/typec/tcpm.c
3864     +++ b/drivers/staging/typec/tcpm.c
3865     @@ -2479,7 +2479,8 @@ static void run_state_machine(struct tcpm_port *port)
3866     tcpm_port_is_sink(port) &&
3867     time_is_after_jiffies(port->delayed_runtime)) {
3868     tcpm_set_state(port, SNK_DISCOVERY,
3869     - port->delayed_runtime - jiffies);
3870     + jiffies_to_msecs(port->delayed_runtime -
3871     + jiffies));
3872     break;
3873     }
3874     tcpm_set_state(port, unattached_state(port), 0);
3875     diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
3876     index 899e8fe5e00f..9e26c530d2dd 100644
3877     --- a/drivers/tty/pty.c
3878     +++ b/drivers/tty/pty.c
3879     @@ -625,7 +625,7 @@ int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags)
3880     if (tty->driver != ptm_driver)
3881     return -EIO;
3882    
3883     - fd = get_unused_fd_flags(0);
3884     + fd = get_unused_fd_flags(flags);
3885     if (fd < 0) {
3886     retval = fd;
3887     goto err;
3888     diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
3889     index ec965ac5f1f5..3c0d386dc62f 100644
3890     --- a/drivers/usb/dwc2/core.h
3891     +++ b/drivers/usb/dwc2/core.h
3892     @@ -872,6 +872,7 @@ struct dwc2_hregs_backup {
3893     * @frame_list_sz: Frame list size
3894     * @desc_gen_cache: Kmem cache for generic descriptors
3895     * @desc_hsisoc_cache: Kmem cache for hs isochronous descriptors
3896     + * @unaligned_cache: Kmem cache for DMA mode to handle non-aligned buf
3897     *
3898     * These are for peripheral mode:
3899     *
3900     @@ -1004,6 +1005,8 @@ struct dwc2_hsotg {
3901     u32 frame_list_sz;
3902     struct kmem_cache *desc_gen_cache;
3903     struct kmem_cache *desc_hsisoc_cache;
3904     + struct kmem_cache *unaligned_cache;
3905     +#define DWC2_KMEM_UNALIGNED_BUF_SIZE 1024
3906    
3907     #ifdef DEBUG
3908     u32 frrem_samples;
3909     diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
3910     index 6ef001a83fe2..e164439b2154 100644
3911     --- a/drivers/usb/dwc2/gadget.c
3912     +++ b/drivers/usb/dwc2/gadget.c
3913     @@ -848,6 +848,7 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep,
3914     u32 index;
3915     u32 maxsize = 0;
3916     u32 mask = 0;
3917     + u8 pid = 0;
3918    
3919     maxsize = dwc2_gadget_get_desc_params(hs_ep, &mask);
3920     if (len > maxsize) {
3921     @@ -893,7 +894,11 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep,
3922     ((len << DEV_DMA_NBYTES_SHIFT) & mask));
3923    
3924     if (hs_ep->dir_in) {
3925     - desc->status |= ((hs_ep->mc << DEV_DMA_ISOC_PID_SHIFT) &
3926     + if (len)
3927     + pid = DIV_ROUND_UP(len, hs_ep->ep.maxpacket);
3928     + else
3929     + pid = 1;
3930     + desc->status |= ((pid << DEV_DMA_ISOC_PID_SHIFT) &
3931     DEV_DMA_ISOC_PID_MASK) |
3932     ((len % hs_ep->ep.maxpacket) ?
3933     DEV_DMA_SHORT : 0) |
3934     @@ -932,6 +937,7 @@ static void dwc2_gadget_start_isoc_ddma(struct dwc2_hsotg_ep *hs_ep)
3935     u32 ctrl;
3936    
3937     if (list_empty(&hs_ep->queue)) {
3938     + hs_ep->target_frame = TARGET_FRAME_INITIAL;
3939     dev_dbg(hsotg->dev, "%s: No requests in queue\n", __func__);
3940     return;
3941     }
3942     @@ -4716,9 +4722,11 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
3943     }
3944    
3945     ret = usb_add_gadget_udc(dev, &hsotg->gadget);
3946     - if (ret)
3947     + if (ret) {
3948     + dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep,
3949     + hsotg->ctrl_req);
3950     return ret;
3951     -
3952     + }
3953     dwc2_hsotg_dump(hsotg);
3954    
3955     return 0;
3956     @@ -4731,6 +4739,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
3957     int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg)
3958     {
3959     usb_del_gadget_udc(&hsotg->gadget);
3960     + dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep, hsotg->ctrl_req);
3961    
3962     return 0;
3963     }
3964     diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
3965     index 46d3b0fc00c5..fa20ec43a187 100644
3966     --- a/drivers/usb/dwc2/hcd.c
3967     +++ b/drivers/usb/dwc2/hcd.c
3968     @@ -1544,11 +1544,20 @@ static void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
3969     }
3970    
3971     if (hsotg->params.host_dma) {
3972     - dwc2_writel((u32)chan->xfer_dma,
3973     - hsotg->regs + HCDMA(chan->hc_num));
3974     + dma_addr_t dma_addr;
3975     +
3976     + if (chan->align_buf) {
3977     + if (dbg_hc(chan))
3978     + dev_vdbg(hsotg->dev, "align_buf\n");
3979     + dma_addr = chan->align_buf;
3980     + } else {
3981     + dma_addr = chan->xfer_dma;
3982     + }
3983     + dwc2_writel((u32)dma_addr, hsotg->regs + HCDMA(chan->hc_num));
3984     +
3985     if (dbg_hc(chan))
3986     dev_vdbg(hsotg->dev, "Wrote %08lx to HCDMA(%d)\n",
3987     - (unsigned long)chan->xfer_dma, chan->hc_num);
3988     + (unsigned long)dma_addr, chan->hc_num);
3989     }
3990    
3991     /* Start the split */
3992     @@ -2604,6 +2613,35 @@ static void dwc2_hc_init_xfer(struct dwc2_hsotg *hsotg,
3993     }
3994     }
3995    
3996     +static int dwc2_alloc_split_dma_aligned_buf(struct dwc2_hsotg *hsotg,
3997     + struct dwc2_qh *qh,
3998     + struct dwc2_host_chan *chan)
3999     +{
4000     + if (!hsotg->unaligned_cache ||
4001     + chan->max_packet > DWC2_KMEM_UNALIGNED_BUF_SIZE)
4002     + return -ENOMEM;
4003     +
4004     + if (!qh->dw_align_buf) {
4005     + qh->dw_align_buf = kmem_cache_alloc(hsotg->unaligned_cache,
4006     + GFP_ATOMIC | GFP_DMA);
4007     + if (!qh->dw_align_buf)
4008     + return -ENOMEM;
4009     + }
4010     +
4011     + qh->dw_align_buf_dma = dma_map_single(hsotg->dev, qh->dw_align_buf,
4012     + DWC2_KMEM_UNALIGNED_BUF_SIZE,
4013     + DMA_FROM_DEVICE);
4014     +
4015     + if (dma_mapping_error(hsotg->dev, qh->dw_align_buf_dma)) {
4016     + dev_err(hsotg->dev, "can't map align_buf\n");
4017     + chan->align_buf = 0;
4018     + return -EINVAL;
4019     + }
4020     +
4021     + chan->align_buf = qh->dw_align_buf_dma;
4022     + return 0;
4023     +}
4024     +
4025     #define DWC2_USB_DMA_ALIGN 4
4026    
4027     static void dwc2_free_dma_aligned_buffer(struct urb *urb)
4028     @@ -2783,6 +2821,32 @@ static int dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
4029     /* Set the transfer attributes */
4030     dwc2_hc_init_xfer(hsotg, chan, qtd);
4031    
4032     + /* For non-dword aligned buffers */
4033     + if (hsotg->params.host_dma && qh->do_split &&
4034     + chan->ep_is_in && (chan->xfer_dma & 0x3)) {
4035     + dev_vdbg(hsotg->dev, "Non-aligned buffer\n");
4036     + if (dwc2_alloc_split_dma_aligned_buf(hsotg, qh, chan)) {
4037     + dev_err(hsotg->dev,
4038     + "Failed to allocate memory to handle non-aligned buffer\n");
4039     + /* Add channel back to free list */
4040     + chan->align_buf = 0;
4041     + chan->multi_count = 0;
4042     + list_add_tail(&chan->hc_list_entry,
4043     + &hsotg->free_hc_list);
4044     + qtd->in_process = 0;
4045     + qh->channel = NULL;
4046     + return -ENOMEM;
4047     + }
4048     + } else {
4049     + /*
4050     + * We assume that DMA is always aligned in non-split
4051     + * case or split out case. Warn if not.
4052     + */
4053     + WARN_ON_ONCE(hsotg->params.host_dma &&
4054     + (chan->xfer_dma & 0x3));
4055     + chan->align_buf = 0;
4056     + }
4057     +
4058     if (chan->ep_type == USB_ENDPOINT_XFER_INT ||
4059     chan->ep_type == USB_ENDPOINT_XFER_ISOC)
4060     /*
4061     @@ -5277,6 +5341,19 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
4062     }
4063     }
4064    
4065     + if (hsotg->params.host_dma) {
4066     + /*
4067     + * Create kmem caches to handle non-aligned buffer
4068     + * in Buffer DMA mode.
4069     + */
4070     + hsotg->unaligned_cache = kmem_cache_create("dwc2-unaligned-dma",
4071     + DWC2_KMEM_UNALIGNED_BUF_SIZE, 4,
4072     + SLAB_CACHE_DMA, NULL);
4073     + if (!hsotg->unaligned_cache)
4074     + dev_err(hsotg->dev,
4075     + "unable to create dwc2 unaligned cache\n");
4076     + }
4077     +
4078     hsotg->otg_port = 1;
4079     hsotg->frame_list = NULL;
4080     hsotg->frame_list_dma = 0;
4081     @@ -5311,8 +5388,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
4082     return 0;
4083    
4084     error4:
4085     - kmem_cache_destroy(hsotg->desc_gen_cache);
4086     + kmem_cache_destroy(hsotg->unaligned_cache);
4087     kmem_cache_destroy(hsotg->desc_hsisoc_cache);
4088     + kmem_cache_destroy(hsotg->desc_gen_cache);
4089     error3:
4090     dwc2_hcd_release(hsotg);
4091     error2:
4092     @@ -5353,8 +5431,9 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
4093     usb_remove_hcd(hcd);
4094     hsotg->priv = NULL;
4095    
4096     - kmem_cache_destroy(hsotg->desc_gen_cache);
4097     + kmem_cache_destroy(hsotg->unaligned_cache);
4098     kmem_cache_destroy(hsotg->desc_hsisoc_cache);
4099     + kmem_cache_destroy(hsotg->desc_gen_cache);
4100    
4101     dwc2_hcd_release(hsotg);
4102     usb_put_hcd(hcd);
4103     diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
4104     index 11c3c145b793..461bdc67df6f 100644
4105     --- a/drivers/usb/dwc2/hcd.h
4106     +++ b/drivers/usb/dwc2/hcd.h
4107     @@ -75,6 +75,8 @@ struct dwc2_qh;
4108     * (micro)frame
4109     * @xfer_buf: Pointer to current transfer buffer position
4110     * @xfer_dma: DMA address of xfer_buf
4111     + * @align_buf: In Buffer DMA mode this will be used if xfer_buf is not
4112     + * DWORD aligned
4113     * @xfer_len: Total number of bytes to transfer
4114     * @xfer_count: Number of bytes transferred so far
4115     * @start_pkt_count: Packet count at start of transfer
4116     @@ -132,6 +134,7 @@ struct dwc2_host_chan {
4117    
4118     u8 *xfer_buf;
4119     dma_addr_t xfer_dma;
4120     + dma_addr_t align_buf;
4121     u32 xfer_len;
4122     u32 xfer_count;
4123     u16 start_pkt_count;
4124     @@ -302,6 +305,9 @@ struct dwc2_hs_transfer_time {
4125     * is tightly packed.
4126     * @ls_duration_us: Duration on the low speed bus schedule.
4127     * @ntd: Actual number of transfer descriptors in a list
4128     + * @dw_align_buf: Used instead of original buffer if its physical address
4129     + * is not dword-aligned
4130     + * @dw_align_buf_dma: DMA address for dw_align_buf
4131     * @qtd_list: List of QTDs for this QH
4132     * @channel: Host channel currently processing transfers for this QH
4133     * @qh_list_entry: Entry for QH in either the periodic or non-periodic
4134     @@ -345,6 +351,8 @@ struct dwc2_qh {
4135     struct dwc2_hs_transfer_time hs_transfers[DWC2_HS_SCHEDULE_UFRAMES];
4136     u32 ls_start_schedule_slice;
4137     u16 ntd;
4138     + u8 *dw_align_buf;
4139     + dma_addr_t dw_align_buf_dma;
4140     struct list_head qtd_list;
4141     struct dwc2_host_chan *channel;
4142     struct list_head qh_list_entry;
4143     diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
4144     index 28a8210710b1..17905ba1139c 100644
4145     --- a/drivers/usb/dwc2/hcd_intr.c
4146     +++ b/drivers/usb/dwc2/hcd_intr.c
4147     @@ -923,14 +923,21 @@ static int dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg *hsotg,
4148     frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index];
4149     len = dwc2_get_actual_xfer_length(hsotg, chan, chnum, qtd,
4150     DWC2_HC_XFER_COMPLETE, NULL);
4151     - if (!len) {
4152     + if (!len && !qtd->isoc_split_offset) {
4153     qtd->complete_split = 0;
4154     - qtd->isoc_split_offset = 0;
4155     return 0;
4156     }
4157    
4158     frame_desc->actual_length += len;
4159    
4160     + if (chan->align_buf) {
4161     + dev_vdbg(hsotg->dev, "non-aligned buffer\n");
4162     + dma_unmap_single(hsotg->dev, chan->qh->dw_align_buf_dma,
4163     + DWC2_KMEM_UNALIGNED_BUF_SIZE, DMA_FROM_DEVICE);
4164     + memcpy(qtd->urb->buf + (chan->xfer_dma - qtd->urb->dma),
4165     + chan->qh->dw_align_buf, len);
4166     + }
4167     +
4168     qtd->isoc_split_offset += len;
4169    
4170     hctsiz = dwc2_readl(hsotg->regs + HCTSIZ(chnum));
4171     diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
4172     index 7f51a77bc5cc..56e61220efc6 100644
4173     --- a/drivers/usb/dwc2/hcd_queue.c
4174     +++ b/drivers/usb/dwc2/hcd_queue.c
4175     @@ -1632,6 +1632,9 @@ void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
4176    
4177     if (qh->desc_list)
4178     dwc2_hcd_qh_free_ddma(hsotg, qh);
4179     + else if (hsotg->unaligned_cache && qh->dw_align_buf)
4180     + kmem_cache_free(hsotg->unaligned_cache, qh->dw_align_buf);
4181     +
4182     kfree(qh);
4183     }
4184    
4185     diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
4186     index fbfc09ebd2ec..acf41ba3638d 100644
4187     --- a/drivers/usb/dwc3/dwc3-of-simple.c
4188     +++ b/drivers/usb/dwc3/dwc3-of-simple.c
4189     @@ -132,8 +132,9 @@ static int dwc3_of_simple_remove(struct platform_device *pdev)
4190    
4191     of_platform_depopulate(dev);
4192    
4193     - pm_runtime_put_sync(dev);
4194     pm_runtime_disable(dev);
4195     + pm_runtime_put_noidle(dev);
4196     + pm_runtime_set_suspended(dev);
4197    
4198     return 0;
4199     }
4200     diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
4201     index bc5e91d4fac8..09c0454833ad 100644
4202     --- a/drivers/usb/dwc3/dwc3-pci.c
4203     +++ b/drivers/usb/dwc3/dwc3-pci.c
4204     @@ -41,6 +41,7 @@
4205     #define PCI_DEVICE_ID_INTEL_GLK 0x31aa
4206     #define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee
4207     #define PCI_DEVICE_ID_INTEL_CNPH 0xa36e
4208     +#define PCI_DEVICE_ID_INTEL_ICLLP 0x34ee
4209    
4210     #define PCI_INTEL_BXT_DSM_GUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
4211     #define PCI_INTEL_BXT_FUNC_PMU_PWR 4
4212     @@ -273,6 +274,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
4213     { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), },
4214     { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPLP), },
4215     { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPH), },
4216     + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICLLP), },
4217     { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
4218     { } /* Terminating Entry */
4219     };
4220     diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
4221     index 940de04ed72a..b805962f5154 100644
4222     --- a/drivers/usb/gadget/composite.c
4223     +++ b/drivers/usb/gadget/composite.c
4224     @@ -1720,6 +1720,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
4225     */
4226     if (w_value && !f->get_alt)
4227     break;
4228     +
4229     + spin_lock(&cdev->lock);
4230     value = f->set_alt(f, w_index, w_value);
4231     if (value == USB_GADGET_DELAYED_STATUS) {
4232     DBG(cdev,
4233     @@ -1729,6 +1731,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
4234     DBG(cdev, "delayed_status count %d\n",
4235     cdev->delayed_status);
4236     }
4237     + spin_unlock(&cdev->lock);
4238     break;
4239     case USB_REQ_GET_INTERFACE:
4240     if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE))
4241     diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
4242     index 52e6897fa35a..17467545391b 100644
4243     --- a/drivers/usb/gadget/function/f_fs.c
4244     +++ b/drivers/usb/gadget/function/f_fs.c
4245     @@ -219,6 +219,7 @@ struct ffs_io_data {
4246    
4247     struct mm_struct *mm;
4248     struct work_struct work;
4249     + struct work_struct cancellation_work;
4250    
4251     struct usb_ep *ep;
4252     struct usb_request *req;
4253     @@ -1073,22 +1074,31 @@ ffs_epfile_open(struct inode *inode, struct file *file)
4254     return 0;
4255     }
4256    
4257     +static void ffs_aio_cancel_worker(struct work_struct *work)
4258     +{
4259     + struct ffs_io_data *io_data = container_of(work, struct ffs_io_data,
4260     + cancellation_work);
4261     +
4262     + ENTER();
4263     +
4264     + usb_ep_dequeue(io_data->ep, io_data->req);
4265     +}
4266     +
4267     static int ffs_aio_cancel(struct kiocb *kiocb)
4268     {
4269     struct ffs_io_data *io_data = kiocb->private;
4270     - struct ffs_epfile *epfile = kiocb->ki_filp->private_data;
4271     + struct ffs_data *ffs = io_data->ffs;
4272     int value;
4273    
4274     ENTER();
4275    
4276     - spin_lock_irq(&epfile->ffs->eps_lock);
4277     -
4278     - if (likely(io_data && io_data->ep && io_data->req))
4279     - value = usb_ep_dequeue(io_data->ep, io_data->req);
4280     - else
4281     + if (likely(io_data && io_data->ep && io_data->req)) {
4282     + INIT_WORK(&io_data->cancellation_work, ffs_aio_cancel_worker);
4283     + queue_work(ffs->io_completion_wq, &io_data->cancellation_work);
4284     + value = -EINPROGRESS;
4285     + } else {
4286     value = -EINVAL;
4287     -
4288     - spin_unlock_irq(&epfile->ffs->eps_lock);
4289     + }
4290    
4291     return value;
4292     }
4293     diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
4294     index 74436f8ca538..32ddafe7af87 100644
4295     --- a/drivers/usb/host/xhci-tegra.c
4296     +++ b/drivers/usb/host/xhci-tegra.c
4297     @@ -482,7 +482,7 @@ static void tegra_xusb_mbox_handle(struct tegra_xusb *tegra,
4298     unsigned long mask;
4299     unsigned int port;
4300     bool idle, enable;
4301     - int err;
4302     + int err = 0;
4303    
4304     memset(&rsp, 0, sizeof(rsp));
4305    
4306     diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
4307     index fe84b36627ec..6b11fd9d8efe 100644
4308     --- a/drivers/usb/host/xhci.c
4309     +++ b/drivers/usb/host/xhci.c
4310     @@ -1024,8 +1024,13 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
4311     command = readl(&xhci->op_regs->command);
4312     command |= CMD_CRS;
4313     writel(command, &xhci->op_regs->command);
4314     + /*
4315     + * Some controllers take up to 55+ ms to complete the controller
4316     + * restore so setting the timeout to 100ms. Xhci specification
4317     + * doesn't mention any timeout value.
4318     + */
4319     if (xhci_handshake(&xhci->op_regs->status,
4320     - STS_RESTORE, 0, 10 * 1000)) {
4321     + STS_RESTORE, 0, 100 * 1000)) {
4322     xhci_warn(xhci, "WARN: xHC restore state timeout\n");
4323     spin_unlock_irq(&xhci->lock);
4324     return -ETIMEDOUT;
4325     diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
4326     index c425d03d37d2..587d12829925 100644
4327     --- a/drivers/xen/manage.c
4328     +++ b/drivers/xen/manage.c
4329     @@ -292,8 +292,15 @@ static void sysrq_handler(struct xenbus_watch *watch, const char *path,
4330     return;
4331     }
4332    
4333     - if (sysrq_key != '\0')
4334     - xenbus_printf(xbt, "control", "sysrq", "%c", '\0');
4335     + if (sysrq_key != '\0') {
4336     + err = xenbus_printf(xbt, "control", "sysrq", "%c", '\0');
4337     + if (err) {
4338     + pr_err("%s: Error %d writing sysrq in control/sysrq\n",
4339     + __func__, err);
4340     + xenbus_transaction_end(xbt, 1);
4341     + return;
4342     + }
4343     + }
4344    
4345     err = xenbus_transaction_end(xbt, 0);
4346     if (err == -EAGAIN)
4347     @@ -345,7 +352,12 @@ static int setup_shutdown_watcher(void)
4348     continue;
4349     snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
4350     shutdown_handlers[idx].command);
4351     - xenbus_printf(XBT_NIL, "control", node, "%u", 1);
4352     + err = xenbus_printf(XBT_NIL, "control", node, "%u", 1);
4353     + if (err) {
4354     + pr_err("%s: Error %d writing %s\n", __func__,
4355     + err, node);
4356     + return err;
4357     + }
4358     }
4359    
4360     return 0;
4361     diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
4362     index 7bc88fd43cfc..e2f3e8b0fba9 100644
4363     --- a/drivers/xen/xen-scsiback.c
4364     +++ b/drivers/xen/xen-scsiback.c
4365     @@ -1012,6 +1012,7 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
4366     {
4367     struct v2p_entry *entry;
4368     unsigned long flags;
4369     + int err;
4370    
4371     if (try) {
4372     spin_lock_irqsave(&info->v2p_lock, flags);
4373     @@ -1027,8 +1028,11 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
4374     scsiback_del_translation_entry(info, vir);
4375     }
4376     } else if (!try) {
4377     - xenbus_printf(XBT_NIL, info->dev->nodename, state,
4378     + err = xenbus_printf(XBT_NIL, info->dev->nodename, state,
4379     "%d", XenbusStateClosed);
4380     + if (err)
4381     + xenbus_dev_error(info->dev, err,
4382     + "%s: writing %s", __func__, state);
4383     }
4384     }
4385    
4386     @@ -1067,8 +1071,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
4387     snprintf(str, sizeof(str), "vscsi-devs/%s/p-dev", ent);
4388     val = xenbus_read(XBT_NIL, dev->nodename, str, NULL);
4389     if (IS_ERR(val)) {
4390     - xenbus_printf(XBT_NIL, dev->nodename, state,
4391     + err = xenbus_printf(XBT_NIL, dev->nodename, state,
4392     "%d", XenbusStateClosed);
4393     + if (err)
4394     + xenbus_dev_error(info->dev, err,
4395     + "%s: writing %s", __func__, state);
4396     return;
4397     }
4398     strlcpy(phy, val, VSCSI_NAMELEN);
4399     @@ -1079,8 +1086,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
4400     err = xenbus_scanf(XBT_NIL, dev->nodename, str, "%u:%u:%u:%u",
4401     &vir.hst, &vir.chn, &vir.tgt, &vir.lun);
4402     if (XENBUS_EXIST_ERR(err)) {
4403     - xenbus_printf(XBT_NIL, dev->nodename, state,
4404     + err = xenbus_printf(XBT_NIL, dev->nodename, state,
4405     "%d", XenbusStateClosed);
4406     + if (err)
4407     + xenbus_dev_error(info->dev, err,
4408     + "%s: writing %s", __func__, state);
4409     return;
4410     }
4411    
4412     diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
4413     index 936d58ca2b49..61192c536e6c 100644
4414     --- a/fs/btrfs/scrub.c
4415     +++ b/fs/btrfs/scrub.c
4416     @@ -1166,11 +1166,6 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
4417     return ret;
4418     }
4419    
4420     - if (sctx->is_dev_replace && !is_metadata && !have_csum) {
4421     - sblocks_for_recheck = NULL;
4422     - goto nodatasum_case;
4423     - }
4424     -
4425     /*
4426     * read all mirrors one after the other. This includes to
4427     * re-read the extent or metadata block that failed (that was
4428     @@ -1283,13 +1278,19 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
4429     goto out;
4430     }
4431    
4432     - if (!is_metadata && !have_csum) {
4433     + /*
4434     + * NOTE: Even for nodatasum case, it's still possible that it's a
4435     + * compressed data extent, thus scrub_fixup_nodatasum(), which write
4436     + * inode page cache onto disk, could cause serious data corruption.
4437     + *
4438     + * So here we could only read from disk, and hope our recovery could
4439     + * reach disk before the newer write.
4440     + */
4441     + if (0 && !is_metadata && !have_csum) {
4442     struct scrub_fixup_nodatasum *fixup_nodatasum;
4443    
4444     WARN_ON(sctx->is_dev_replace);
4445    
4446     -nodatasum_case:
4447     -
4448     /*
4449     * !is_metadata and !have_csum, this means that the data
4450     * might not be COWed, that it might be modified
4451     diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
4452     index f2550a076edc..d5124ed35154 100644
4453     --- a/fs/ceph/inode.c
4454     +++ b/fs/ceph/inode.c
4455     @@ -1087,6 +1087,7 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in)
4456     if (IS_ERR(realdn)) {
4457     pr_err("splice_dentry error %ld %p inode %p ino %llx.%llx\n",
4458     PTR_ERR(realdn), dn, in, ceph_vinop(in));
4459     + dput(dn);
4460     dn = realdn; /* note realdn contains the error */
4461     goto out;
4462     } else if (realdn) {
4463     diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
4464     index 048c586d9a8b..1792999eec91 100644
4465     --- a/fs/ext4/mballoc.c
4466     +++ b/fs/ext4/mballoc.c
4467     @@ -26,6 +26,7 @@
4468     #include <linux/log2.h>
4469     #include <linux/module.h>
4470     #include <linux/slab.h>
4471     +#include <linux/nospec.h>
4472     #include <linux/backing-dev.h>
4473     #include <trace/events/ext4.h>
4474    
4475     @@ -2152,7 +2153,8 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
4476     * This should tell if fe_len is exactly power of 2
4477     */
4478     if ((ac->ac_g_ex.fe_len & (~(1 << (i - 1)))) == 0)
4479     - ac->ac_2order = i - 1;
4480     + ac->ac_2order = array_index_nospec(i - 1,
4481     + sb->s_blocksize_bits + 2);
4482     }
4483    
4484     /* if stream allocation is enabled, use global goal */
4485     diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
4486     index 7c05bd4222b2..3c7bbbae0afa 100644
4487     --- a/fs/f2fs/segment.c
4488     +++ b/fs/f2fs/segment.c
4489     @@ -3240,7 +3240,7 @@ static int build_curseg(struct f2fs_sb_info *sbi)
4490     return restore_curseg_summaries(sbi);
4491     }
4492    
4493     -static void build_sit_entries(struct f2fs_sb_info *sbi)
4494     +static int build_sit_entries(struct f2fs_sb_info *sbi)
4495     {
4496     struct sit_info *sit_i = SIT_I(sbi);
4497     struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
4498     @@ -3250,6 +3250,8 @@ static void build_sit_entries(struct f2fs_sb_info *sbi)
4499     int sit_blk_cnt = SIT_BLK_CNT(sbi);
4500     unsigned int i, start, end;
4501     unsigned int readed, start_blk = 0;
4502     + int err = 0;
4503     + block_t total_node_blocks = 0;
4504    
4505     do {
4506     readed = ra_meta_pages(sbi, start_blk, BIO_MAX_PAGES,
4507     @@ -3268,8 +3270,12 @@ static void build_sit_entries(struct f2fs_sb_info *sbi)
4508     sit = sit_blk->entries[SIT_ENTRY_OFFSET(sit_i, start)];
4509     f2fs_put_page(page, 1);
4510    
4511     - check_block_count(sbi, start, &sit);
4512     + err = check_block_count(sbi, start, &sit);
4513     + if (err)
4514     + return err;
4515     seg_info_from_raw_sit(se, &sit);
4516     + if (IS_NODESEG(se->type))
4517     + total_node_blocks += se->valid_blocks;
4518    
4519     /* build discard map only one time */
4520     if (f2fs_discard_en(sbi)) {
4521     @@ -3302,9 +3308,15 @@ static void build_sit_entries(struct f2fs_sb_info *sbi)
4522     sit = sit_in_journal(journal, i);
4523    
4524     old_valid_blocks = se->valid_blocks;
4525     + if (IS_NODESEG(se->type))
4526     + total_node_blocks -= old_valid_blocks;
4527    
4528     - check_block_count(sbi, start, &sit);
4529     + err = check_block_count(sbi, start, &sit);
4530     + if (err)
4531     + break;
4532     seg_info_from_raw_sit(se, &sit);
4533     + if (IS_NODESEG(se->type))
4534     + total_node_blocks += se->valid_blocks;
4535    
4536     if (f2fs_discard_en(sbi)) {
4537     if (is_set_ckpt_flags(sbi, CP_TRIMMED_FLAG)) {
4538     @@ -3323,6 +3335,16 @@ static void build_sit_entries(struct f2fs_sb_info *sbi)
4539     se->valid_blocks - old_valid_blocks;
4540     }
4541     up_read(&curseg->journal_rwsem);
4542     +
4543     + if (!err && total_node_blocks != valid_node_count(sbi)) {
4544     + f2fs_msg(sbi->sb, KERN_ERR,
4545     + "SIT is corrupted node# %u vs %u",
4546     + total_node_blocks, valid_node_count(sbi));
4547     + set_sbi_flag(sbi, SBI_NEED_FSCK);
4548     + err = -EINVAL;
4549     + }
4550     +
4551     + return err;
4552     }
4553    
4554     static void init_free_segmap(struct f2fs_sb_info *sbi)
4555     @@ -3492,7 +3514,9 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
4556     return err;
4557    
4558     /* reinit free segmap based on SIT */
4559     - build_sit_entries(sbi);
4560     + err = build_sit_entries(sbi);
4561     + if (err)
4562     + return err;
4563    
4564     init_free_segmap(sbi);
4565     err = build_dirty_segmap(sbi);
4566     diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
4567     index e0a6cc23ace3..39ada30889b6 100644
4568     --- a/fs/f2fs/segment.h
4569     +++ b/fs/f2fs/segment.h
4570     @@ -625,7 +625,7 @@ static inline void verify_block_addr(struct f2fs_sb_info *sbi, block_t blk_addr)
4571     /*
4572     * Summary block is always treated as an invalid block
4573     */
4574     -static inline void check_block_count(struct f2fs_sb_info *sbi,
4575     +static inline int check_block_count(struct f2fs_sb_info *sbi,
4576     int segno, struct f2fs_sit_entry *raw_sit)
4577     {
4578     #ifdef CONFIG_F2FS_CHECK_FS
4579     @@ -647,11 +647,25 @@ static inline void check_block_count(struct f2fs_sb_info *sbi,
4580     cur_pos = next_pos;
4581     is_valid = !is_valid;
4582     } while (cur_pos < sbi->blocks_per_seg);
4583     - BUG_ON(GET_SIT_VBLOCKS(raw_sit) != valid_blocks);
4584     +
4585     + if (unlikely(GET_SIT_VBLOCKS(raw_sit) != valid_blocks)) {
4586     + f2fs_msg(sbi->sb, KERN_ERR,
4587     + "Mismatch valid blocks %d vs. %d",
4588     + GET_SIT_VBLOCKS(raw_sit), valid_blocks);
4589     + set_sbi_flag(sbi, SBI_NEED_FSCK);
4590     + return -EINVAL;
4591     + }
4592     #endif
4593     /* check segment usage, and check boundary of a given segment number */
4594     - f2fs_bug_on(sbi, GET_SIT_VBLOCKS(raw_sit) > sbi->blocks_per_seg
4595     - || segno > TOTAL_SEGS(sbi) - 1);
4596     + if (unlikely(GET_SIT_VBLOCKS(raw_sit) > sbi->blocks_per_seg
4597     + || segno > TOTAL_SEGS(sbi) - 1)) {
4598     + f2fs_msg(sbi->sb, KERN_ERR,
4599     + "Wrong valid blocks %d or segno %u",
4600     + GET_SIT_VBLOCKS(raw_sit), segno);
4601     + set_sbi_flag(sbi, SBI_NEED_FSCK);
4602     + return -EINVAL;
4603     + }
4604     + return 0;
4605     }
4606    
4607     static inline pgoff_t current_sit_addr(struct f2fs_sb_info *sbi,
4608     diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
4609     index 43fbf4495090..51deff8e1f86 100644
4610     --- a/fs/nfs/nfs4proc.c
4611     +++ b/fs/nfs/nfs4proc.c
4612     @@ -8429,6 +8429,8 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
4613    
4614     dprintk("--> %s tk_status => %d\n", __func__, -task->tk_status);
4615    
4616     + nfs4_sequence_free_slot(&lgp->res.seq_res);
4617     +
4618     switch (nfs4err) {
4619     case 0:
4620     goto out;
4621     @@ -8493,7 +8495,6 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
4622     goto out;
4623     }
4624    
4625     - nfs4_sequence_free_slot(&lgp->res.seq_res);
4626     err = nfs4_handle_exception(server, nfs4err, exception);
4627     if (!status) {
4628     if (exception->retry)
4629     @@ -8619,20 +8620,22 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout, gfp_t gfp_flags)
4630     if (IS_ERR(task))
4631     return ERR_CAST(task);
4632     status = rpc_wait_for_completion_task(task);
4633     - if (status == 0) {
4634     + if (status != 0)
4635     + goto out;
4636     +
4637     + /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */
4638     + if (task->tk_status < 0 || lgp->res.layoutp->len == 0) {
4639     status = nfs4_layoutget_handle_exception(task, lgp, &exception);
4640     *timeout = exception.timeout;
4641     - }
4642     -
4643     + } else
4644     + lseg = pnfs_layout_process(lgp);
4645     +out:
4646     trace_nfs4_layoutget(lgp->args.ctx,
4647     &lgp->args.range,
4648     &lgp->res.range,
4649     &lgp->res.stateid,
4650     status);
4651    
4652     - /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */
4653     - if (status == 0 && lgp->res.layoutp->len)
4654     - lseg = pnfs_layout_process(lgp);
4655     rpc_put_task(task);
4656     dprintk("<-- %s status=%d\n", __func__, status);
4657     if (status)
4658     diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
4659     index 46492fb37a4c..505f87a8c724 100644
4660     --- a/fs/reiserfs/xattr.c
4661     +++ b/fs/reiserfs/xattr.c
4662     @@ -792,8 +792,10 @@ static int listxattr_filler(struct dir_context *ctx, const char *name,
4663     return 0;
4664     size = namelen + 1;
4665     if (b->buf) {
4666     - if (size > b->size)
4667     + if (b->pos + size > b->size) {
4668     + b->pos = -ERANGE;
4669     return -ERANGE;
4670     + }
4671     memcpy(b->buf + b->pos, name, namelen);
4672     b->buf[b->pos + namelen] = 0;
4673     }
4674     diff --git a/include/linux/fsl/guts.h b/include/linux/fsl/guts.h
4675     index 3efa3b861d44..941b11811f85 100644
4676     --- a/include/linux/fsl/guts.h
4677     +++ b/include/linux/fsl/guts.h
4678     @@ -16,6 +16,7 @@
4679     #define __FSL_GUTS_H__
4680    
4681     #include <linux/types.h>
4682     +#include <linux/io.h>
4683    
4684     /**
4685     * Global Utility Registers.
4686     diff --git a/include/linux/pci.h b/include/linux/pci.h
4687     index 727e309baa5e..9d6fae809c09 100644
4688     --- a/include/linux/pci.h
4689     +++ b/include/linux/pci.h
4690     @@ -1235,6 +1235,8 @@ int pci_register_io_range(phys_addr_t addr, resource_size_t size);
4691     unsigned long pci_address_to_pio(phys_addr_t addr);
4692     phys_addr_t pci_pio_to_address(unsigned long pio);
4693     int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr);
4694     +int devm_pci_remap_iospace(struct device *dev, const struct resource *res,
4695     + phys_addr_t phys_addr);
4696     void pci_unmap_iospace(struct resource *res);
4697     void __iomem *devm_pci_remap_cfgspace(struct device *dev,
4698     resource_size_t offset,
4699     diff --git a/include/net/ipv6.h b/include/net/ipv6.h
4700     index e59f385da38e..f280c61e019a 100644
4701     --- a/include/net/ipv6.h
4702     +++ b/include/net/ipv6.h
4703     @@ -313,14 +313,7 @@ struct ipv6_txoptions *ipv6_dup_options(struct sock *sk,
4704     struct ipv6_txoptions *ipv6_renew_options(struct sock *sk,
4705     struct ipv6_txoptions *opt,
4706     int newtype,
4707     - struct ipv6_opt_hdr __user *newopt,
4708     - int newoptlen);
4709     -struct ipv6_txoptions *
4710     -ipv6_renew_options_kern(struct sock *sk,
4711     - struct ipv6_txoptions *opt,
4712     - int newtype,
4713     - struct ipv6_opt_hdr *newopt,
4714     - int newoptlen);
4715     + struct ipv6_opt_hdr *newopt);
4716     struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
4717     struct ipv6_txoptions *opt);
4718    
4719     diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
4720     index 049008493faf..f4bf75fac349 100644
4721     --- a/include/net/net_namespace.h
4722     +++ b/include/net/net_namespace.h
4723     @@ -120,6 +120,7 @@ struct net {
4724     #endif
4725     #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
4726     struct netns_nf_frag nf_frag;
4727     + struct ctl_table_header *nf_frag_frags_hdr;
4728     #endif
4729     struct sock *nfnl;
4730     struct sock *nfnl_stash;
4731     diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
4732     index dc825a5ddd7f..c004d051c2d3 100644
4733     --- a/include/net/netns/ipv6.h
4734     +++ b/include/net/netns/ipv6.h
4735     @@ -94,7 +94,6 @@ struct netns_ipv6 {
4736    
4737     #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
4738     struct netns_nf_frag {
4739     - struct netns_sysctl_ipv6 sysctl;
4740     struct netns_frags frags;
4741     };
4742     #endif
4743     diff --git a/include/net/tc_act/tc_tunnel_key.h b/include/net/tc_act/tc_tunnel_key.h
4744     index efef0b4b1b2b..46b8c7f1c8d5 100644
4745     --- a/include/net/tc_act/tc_tunnel_key.h
4746     +++ b/include/net/tc_act/tc_tunnel_key.h
4747     @@ -18,7 +18,6 @@
4748     struct tcf_tunnel_key_params {
4749     struct rcu_head rcu;
4750     int tcft_action;
4751     - int action;
4752     struct metadata_dst *tcft_enc_metadata;
4753     };
4754    
4755     diff --git a/include/net/tcp.h b/include/net/tcp.h
4756     index 686e33ea76e7..eca8d65cad1e 100644
4757     --- a/include/net/tcp.h
4758     +++ b/include/net/tcp.h
4759     @@ -938,8 +938,6 @@ enum tcp_ca_event {
4760     CA_EVENT_LOSS, /* loss timeout */
4761     CA_EVENT_ECN_NO_CE, /* ECT set, but not CE marked */
4762     CA_EVENT_ECN_IS_CE, /* received CE marked IP packet */
4763     - CA_EVENT_DELAYED_ACK, /* Delayed ack is sent */
4764     - CA_EVENT_NON_DELAYED_ACK,
4765     };
4766    
4767     /* Information about inbound ACK, passed to cong_ops->in_ack_event() */
4768     diff --git a/include/uapi/linux/nbd.h b/include/uapi/linux/nbd.h
4769     index 85a3fb65e40a..20d6cc91435d 100644
4770     --- a/include/uapi/linux/nbd.h
4771     +++ b/include/uapi/linux/nbd.h
4772     @@ -53,6 +53,9 @@ enum {
4773     /* These are client behavior specific flags. */
4774     #define NBD_CFLAG_DESTROY_ON_DISCONNECT (1 << 0) /* delete the nbd device on
4775     disconnect. */
4776     +#define NBD_CFLAG_DISCONNECT_ON_CLOSE (1 << 1) /* disconnect the nbd device on
4777     + * close by last opener.
4778     + */
4779    
4780     /* userspace doesn't need the nbd_device structure */
4781    
4782     diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
4783     index 6533f08d1238..3d0ecc273cc6 100644
4784     --- a/kernel/bpf/hashtab.c
4785     +++ b/kernel/bpf/hashtab.c
4786     @@ -730,13 +730,15 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
4787     * old element will be freed immediately.
4788     * Otherwise return an error
4789     */
4790     - atomic_dec(&htab->count);
4791     - return ERR_PTR(-E2BIG);
4792     + l_new = ERR_PTR(-E2BIG);
4793     + goto dec_count;
4794     }
4795     l_new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN,
4796     htab->map.numa_node);
4797     - if (!l_new)
4798     - return ERR_PTR(-ENOMEM);
4799     + if (!l_new) {
4800     + l_new = ERR_PTR(-ENOMEM);
4801     + goto dec_count;
4802     + }
4803     }
4804    
4805     memcpy(l_new->key, key, key_size);
4806     @@ -749,7 +751,8 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
4807     GFP_ATOMIC | __GFP_NOWARN);
4808     if (!pptr) {
4809     kfree(l_new);
4810     - return ERR_PTR(-ENOMEM);
4811     + l_new = ERR_PTR(-ENOMEM);
4812     + goto dec_count;
4813     }
4814     }
4815    
4816     @@ -763,6 +766,9 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
4817    
4818     l_new->hash = hash;
4819     return l_new;
4820     +dec_count:
4821     + atomic_dec(&htab->count);
4822     + return l_new;
4823     }
4824    
4825     static int check_flags(struct bpf_htab *htab, struct htab_elem *l_old,
4826     diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
4827     index 2f0f5720b123..d7c155048ea9 100644
4828     --- a/kernel/locking/lockdep.c
4829     +++ b/kernel/locking/lockdep.c
4830     @@ -1296,11 +1296,11 @@ unsigned long lockdep_count_forward_deps(struct lock_class *class)
4831     this.parent = NULL;
4832     this.class = class;
4833    
4834     - local_irq_save(flags);
4835     + raw_local_irq_save(flags);
4836     arch_spin_lock(&lockdep_lock);
4837     ret = __lockdep_count_forward_deps(&this);
4838     arch_spin_unlock(&lockdep_lock);
4839     - local_irq_restore(flags);
4840     + raw_local_irq_restore(flags);
4841    
4842     return ret;
4843     }
4844     @@ -1323,11 +1323,11 @@ unsigned long lockdep_count_backward_deps(struct lock_class *class)
4845     this.parent = NULL;
4846     this.class = class;
4847    
4848     - local_irq_save(flags);
4849     + raw_local_irq_save(flags);
4850     arch_spin_lock(&lockdep_lock);
4851     ret = __lockdep_count_backward_deps(&this);
4852     arch_spin_unlock(&lockdep_lock);
4853     - local_irq_restore(flags);
4854     + raw_local_irq_restore(flags);
4855    
4856     return ret;
4857     }
4858     @@ -4478,7 +4478,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
4859     if (unlikely(!debug_locks))
4860     return;
4861    
4862     - local_irq_save(flags);
4863     + raw_local_irq_save(flags);
4864     for (i = 0; i < curr->lockdep_depth; i++) {
4865     hlock = curr->held_locks + i;
4866    
4867     @@ -4489,7 +4489,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
4868     print_freed_lock_bug(curr, mem_from, mem_from + mem_len, hlock);
4869     break;
4870     }
4871     - local_irq_restore(flags);
4872     + raw_local_irq_restore(flags);
4873     }
4874     EXPORT_SYMBOL_GPL(debug_check_no_locks_freed);
4875    
4876     diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
4877     index 20919489883f..fbc75c84076e 100644
4878     --- a/kernel/trace/trace.c
4879     +++ b/kernel/trace/trace.c
4880     @@ -2958,6 +2958,7 @@ out_nobuffer:
4881     }
4882     EXPORT_SYMBOL_GPL(trace_vbprintk);
4883    
4884     +__printf(3, 0)
4885     static int
4886     __trace_array_vprintk(struct ring_buffer *buffer,
4887     unsigned long ip, const char *fmt, va_list args)
4888     @@ -3012,12 +3013,14 @@ out_nobuffer:
4889     return len;
4890     }
4891    
4892     +__printf(3, 0)
4893     int trace_array_vprintk(struct trace_array *tr,
4894     unsigned long ip, const char *fmt, va_list args)
4895     {
4896     return __trace_array_vprintk(tr->trace_buffer.buffer, ip, fmt, args);
4897     }
4898    
4899     +__printf(3, 0)
4900     int trace_array_printk(struct trace_array *tr,
4901     unsigned long ip, const char *fmt, ...)
4902     {
4903     @@ -3033,6 +3036,7 @@ int trace_array_printk(struct trace_array *tr,
4904     return ret;
4905     }
4906    
4907     +__printf(3, 4)
4908     int trace_array_printk_buf(struct ring_buffer *buffer,
4909     unsigned long ip, const char *fmt, ...)
4910     {
4911     @@ -3048,6 +3052,7 @@ int trace_array_printk_buf(struct ring_buffer *buffer,
4912     return ret;
4913     }
4914    
4915     +__printf(2, 0)
4916     int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
4917     {
4918     return trace_array_vprintk(&global_trace, ip, fmt, args);
4919     diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
4920     index d90f29a166d8..71a4319256b6 100644
4921     --- a/mm/kasan/kasan.c
4922     +++ b/mm/kasan/kasan.c
4923     @@ -613,12 +613,13 @@ void kasan_kfree_large(const void *ptr)
4924     int kasan_module_alloc(void *addr, size_t size)
4925     {
4926     void *ret;
4927     + size_t scaled_size;
4928     size_t shadow_size;
4929     unsigned long shadow_start;
4930    
4931     shadow_start = (unsigned long)kasan_mem_to_shadow(addr);
4932     - shadow_size = round_up(size >> KASAN_SHADOW_SCALE_SHIFT,
4933     - PAGE_SIZE);
4934     + scaled_size = (size + KASAN_SHADOW_MASK) >> KASAN_SHADOW_SCALE_SHIFT;
4935     + shadow_size = round_up(scaled_size, PAGE_SIZE);
4936    
4937     if (WARN_ON(!PAGE_ALIGNED(shadow_start)))
4938     return -EINVAL;
4939     diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
4940     index 71d8809fbe94..5bd9b389f8c9 100644
4941     --- a/net/batman-adv/bat_iv_ogm.c
4942     +++ b/net/batman-adv/bat_iv_ogm.c
4943     @@ -2718,7 +2718,7 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
4944     {
4945     struct batadv_neigh_ifinfo *router_ifinfo = NULL;
4946     struct batadv_neigh_node *router;
4947     - struct batadv_gw_node *curr_gw;
4948     + struct batadv_gw_node *curr_gw = NULL;
4949     int ret = 0;
4950     void *hdr;
4951    
4952     @@ -2766,6 +2766,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
4953     ret = 0;
4954    
4955     out:
4956     + if (curr_gw)
4957     + batadv_gw_node_put(curr_gw);
4958     if (router_ifinfo)
4959     batadv_neigh_ifinfo_put(router_ifinfo);
4960     if (router)
4961     diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
4962     index a8f4c3902cf5..371a1f1651b4 100644
4963     --- a/net/batman-adv/bat_v.c
4964     +++ b/net/batman-adv/bat_v.c
4965     @@ -929,7 +929,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
4966     {
4967     struct batadv_neigh_ifinfo *router_ifinfo = NULL;
4968     struct batadv_neigh_node *router;
4969     - struct batadv_gw_node *curr_gw;
4970     + struct batadv_gw_node *curr_gw = NULL;
4971     int ret = 0;
4972     void *hdr;
4973    
4974     @@ -997,6 +997,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
4975     ret = 0;
4976    
4977     out:
4978     + if (curr_gw)
4979     + batadv_gw_node_put(curr_gw);
4980     if (router_ifinfo)
4981     batadv_neigh_ifinfo_put(router_ifinfo);
4982     if (router)
4983     diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
4984     index 8a3ce79b1307..0f4d4eece3e4 100644
4985     --- a/net/batman-adv/translation-table.c
4986     +++ b/net/batman-adv/translation-table.c
4987     @@ -1679,7 +1679,9 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
4988     ether_addr_copy(common->addr, tt_addr);
4989     common->vid = vid;
4990    
4991     - common->flags = flags;
4992     + if (!is_multicast_ether_addr(common->addr))
4993     + common->flags = flags & (~BATADV_TT_SYNC_MASK);
4994     +
4995     tt_global_entry->roam_at = 0;
4996     /* node must store current time in case of roaming. This is
4997     * needed to purge this entry out on timeout (if nobody claims
4998     @@ -1742,7 +1744,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
4999     * TT_CLIENT_TEMP, therefore they have to be copied in the
5000     * client entry
5001     */
5002     - common->flags |= flags & (~BATADV_TT_SYNC_MASK);
5003     + if (!is_multicast_ether_addr(common->addr))
5004     + common->flags |= flags & (~BATADV_TT_SYNC_MASK);
5005    
5006     /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
5007     * one originator left in the list and we previously received a
5008     diff --git a/net/core/dev.c b/net/core/dev.c
5009     index 6ca771f2f25b..85f4a1047707 100644
5010     --- a/net/core/dev.c
5011     +++ b/net/core/dev.c
5012     @@ -8297,7 +8297,8 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
5013     /* We get here if we can't use the current device name */
5014     if (!pat)
5015     goto out;
5016     - if (dev_get_valid_name(net, dev, pat) < 0)
5017     + err = dev_get_valid_name(net, dev, pat);
5018     + if (err < 0)
5019     goto out;
5020     }
5021    
5022     @@ -8309,7 +8310,6 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
5023     dev_close(dev);
5024    
5025     /* And unlink it from device chain */
5026     - err = -ENODEV;
5027     unlist_netdevice(dev);
5028    
5029     synchronize_net();
5030     diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
5031     index e9f0489e4229..22db273f15ea 100644
5032     --- a/net/ieee802154/6lowpan/core.c
5033     +++ b/net/ieee802154/6lowpan/core.c
5034     @@ -90,12 +90,18 @@ static int lowpan_neigh_construct(struct net_device *dev, struct neighbour *n)
5035     return 0;
5036     }
5037    
5038     +static int lowpan_get_iflink(const struct net_device *dev)
5039     +{
5040     + return lowpan_802154_dev(dev)->wdev->ifindex;
5041     +}
5042     +
5043     static const struct net_device_ops lowpan_netdev_ops = {
5044     .ndo_init = lowpan_dev_init,
5045     .ndo_start_xmit = lowpan_xmit,
5046     .ndo_open = lowpan_open,
5047     .ndo_stop = lowpan_stop,
5048     .ndo_neigh_construct = lowpan_neigh_construct,
5049     + .ndo_get_iflink = lowpan_get_iflink,
5050     };
5051    
5052     static void lowpan_setup(struct net_device *ldev)
5053     diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
5054     index 114d4bef1bec..0d1a2cda1bfb 100644
5055     --- a/net/ipv4/netfilter/ip_tables.c
5056     +++ b/net/ipv4/netfilter/ip_tables.c
5057     @@ -1894,6 +1894,7 @@ static struct xt_match ipt_builtin_mt[] __read_mostly = {
5058     .checkentry = icmp_checkentry,
5059     .proto = IPPROTO_ICMP,
5060     .family = NFPROTO_IPV4,
5061     + .me = THIS_MODULE,
5062     },
5063     };
5064    
5065     diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
5066     index e81ff9d545a4..7462ec7587ce 100644
5067     --- a/net/ipv4/tcp.c
5068     +++ b/net/ipv4/tcp.c
5069     @@ -1837,7 +1837,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
5070     * shouldn't happen.
5071     */
5072     if (WARN(before(*seq, TCP_SKB_CB(skb)->seq),
5073     - "recvmsg bug: copied %X seq %X rcvnxt %X fl %X\n",
5074     + "TCP recvmsg seq # bug: copied %X, seq %X, rcvnxt %X, fl %X\n",
5075     *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt,
5076     flags))
5077     break;
5078     @@ -1852,7 +1852,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
5079     if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
5080     goto found_fin_ok;
5081     WARN(!(flags & MSG_PEEK),
5082     - "recvmsg bug 2: copied %X seq %X rcvnxt %X fl %X\n",
5083     + "TCP recvmsg seq # bug 2: copied %X, seq %X, rcvnxt %X, fl %X\n",
5084     *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt, flags);
5085     }
5086    
5087     diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
5088     index 1a9b88c8cf72..8b637f9f23a2 100644
5089     --- a/net/ipv4/tcp_dctcp.c
5090     +++ b/net/ipv4/tcp_dctcp.c
5091     @@ -55,7 +55,6 @@ struct dctcp {
5092     u32 dctcp_alpha;
5093     u32 next_seq;
5094     u32 ce_state;
5095     - u32 delayed_ack_reserved;
5096     u32 loss_cwnd;
5097     };
5098    
5099     @@ -96,7 +95,6 @@ static void dctcp_init(struct sock *sk)
5100    
5101     ca->dctcp_alpha = min(dctcp_alpha_on_init, DCTCP_MAX_ALPHA);
5102    
5103     - ca->delayed_ack_reserved = 0;
5104     ca->loss_cwnd = 0;
5105     ca->ce_state = 0;
5106    
5107     @@ -230,25 +228,6 @@ static void dctcp_state(struct sock *sk, u8 new_state)
5108     }
5109     }
5110    
5111     -static void dctcp_update_ack_reserved(struct sock *sk, enum tcp_ca_event ev)
5112     -{
5113     - struct dctcp *ca = inet_csk_ca(sk);
5114     -
5115     - switch (ev) {
5116     - case CA_EVENT_DELAYED_ACK:
5117     - if (!ca->delayed_ack_reserved)
5118     - ca->delayed_ack_reserved = 1;
5119     - break;
5120     - case CA_EVENT_NON_DELAYED_ACK:
5121     - if (ca->delayed_ack_reserved)
5122     - ca->delayed_ack_reserved = 0;
5123     - break;
5124     - default:
5125     - /* Don't care for the rest. */
5126     - break;
5127     - }
5128     -}
5129     -
5130     static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
5131     {
5132     switch (ev) {
5133     @@ -258,10 +237,6 @@ static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
5134     case CA_EVENT_ECN_NO_CE:
5135     dctcp_ce_state_1_to_0(sk);
5136     break;
5137     - case CA_EVENT_DELAYED_ACK:
5138     - case CA_EVENT_NON_DELAYED_ACK:
5139     - dctcp_update_ack_reserved(sk, ev);
5140     - break;
5141     default:
5142     /* Don't care for the rest. */
5143     break;
5144     diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
5145     index 3d8f6f342cb1..b2ead31afcba 100644
5146     --- a/net/ipv4/tcp_output.c
5147     +++ b/net/ipv4/tcp_output.c
5148     @@ -3513,8 +3513,6 @@ void tcp_send_delayed_ack(struct sock *sk)
5149     int ato = icsk->icsk_ack.ato;
5150     unsigned long timeout;
5151    
5152     - tcp_ca_event(sk, CA_EVENT_DELAYED_ACK);
5153     -
5154     if (ato > TCP_DELACK_MIN) {
5155     const struct tcp_sock *tp = tcp_sk(sk);
5156     int max_ato = HZ / 2;
5157     @@ -3571,8 +3569,6 @@ void __tcp_send_ack(struct sock *sk, u32 rcv_nxt)
5158     if (sk->sk_state == TCP_CLOSE)
5159     return;
5160    
5161     - tcp_ca_event(sk, CA_EVENT_NON_DELAYED_ACK);
5162     -
5163     /* We are not putting this on the write queue, so
5164     * tcp_transmit_skb() will set the ownership to this
5165     * sock.
5166     diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
5167     index 1323b9679cf7..1c0bb9fb76e6 100644
5168     --- a/net/ipv6/calipso.c
5169     +++ b/net/ipv6/calipso.c
5170     @@ -799,8 +799,7 @@ static int calipso_opt_update(struct sock *sk, struct ipv6_opt_hdr *hop)
5171     {
5172     struct ipv6_txoptions *old = txopt_get(inet6_sk(sk)), *txopts;
5173    
5174     - txopts = ipv6_renew_options_kern(sk, old, IPV6_HOPOPTS,
5175     - hop, hop ? ipv6_optlen(hop) : 0);
5176     + txopts = ipv6_renew_options(sk, old, IPV6_HOPOPTS, hop);
5177     txopt_put(old);
5178     if (IS_ERR(txopts))
5179     return PTR_ERR(txopts);
5180     @@ -1222,8 +1221,7 @@ static int calipso_req_setattr(struct request_sock *req,
5181     if (IS_ERR(new))
5182     return PTR_ERR(new);
5183    
5184     - txopts = ipv6_renew_options_kern(sk, req_inet->ipv6_opt, IPV6_HOPOPTS,
5185     - new, new ? ipv6_optlen(new) : 0);
5186     + txopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);
5187    
5188     kfree(new);
5189    
5190     @@ -1260,8 +1258,7 @@ static void calipso_req_delattr(struct request_sock *req)
5191     if (calipso_opt_del(req_inet->ipv6_opt->hopopt, &new))
5192     return; /* Nothing to do */
5193    
5194     - txopts = ipv6_renew_options_kern(sk, req_inet->ipv6_opt, IPV6_HOPOPTS,
5195     - new, new ? ipv6_optlen(new) : 0);
5196     + txopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);
5197    
5198     if (!IS_ERR(txopts)) {
5199     txopts = xchg(&req_inet->ipv6_opt, txopts);
5200     diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
5201     index d6189c2a35e4..47a5f8f88c70 100644
5202     --- a/net/ipv6/exthdrs.c
5203     +++ b/net/ipv6/exthdrs.c
5204     @@ -987,29 +987,21 @@ ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt)
5205     }
5206     EXPORT_SYMBOL_GPL(ipv6_dup_options);
5207    
5208     -static int ipv6_renew_option(void *ohdr,
5209     - struct ipv6_opt_hdr __user *newopt, int newoptlen,
5210     - int inherit,
5211     - struct ipv6_opt_hdr **hdr,
5212     - char **p)
5213     +static void ipv6_renew_option(int renewtype,
5214     + struct ipv6_opt_hdr **dest,
5215     + struct ipv6_opt_hdr *old,
5216     + struct ipv6_opt_hdr *new,
5217     + int newtype, char **p)
5218     {
5219     - if (inherit) {
5220     - if (ohdr) {
5221     - memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr));
5222     - *hdr = (struct ipv6_opt_hdr *)*p;
5223     - *p += CMSG_ALIGN(ipv6_optlen(*hdr));
5224     - }
5225     - } else {
5226     - if (newopt) {
5227     - if (copy_from_user(*p, newopt, newoptlen))
5228     - return -EFAULT;
5229     - *hdr = (struct ipv6_opt_hdr *)*p;
5230     - if (ipv6_optlen(*hdr) > newoptlen)
5231     - return -EINVAL;
5232     - *p += CMSG_ALIGN(newoptlen);
5233     - }
5234     - }
5235     - return 0;
5236     + struct ipv6_opt_hdr *src;
5237     +
5238     + src = (renewtype == newtype ? new : old);
5239     + if (!src)
5240     + return;
5241     +
5242     + memcpy(*p, src, ipv6_optlen(src));
5243     + *dest = (struct ipv6_opt_hdr *)*p;
5244     + *p += CMSG_ALIGN(ipv6_optlen(*dest));
5245     }
5246    
5247     /**
5248     @@ -1035,13 +1027,11 @@ static int ipv6_renew_option(void *ohdr,
5249     */
5250     struct ipv6_txoptions *
5251     ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
5252     - int newtype,
5253     - struct ipv6_opt_hdr __user *newopt, int newoptlen)
5254     + int newtype, struct ipv6_opt_hdr *newopt)
5255     {
5256     int tot_len = 0;
5257     char *p;
5258     struct ipv6_txoptions *opt2;
5259     - int err;
5260    
5261     if (opt) {
5262     if (newtype != IPV6_HOPOPTS && opt->hopopt)
5263     @@ -1054,8 +1044,8 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
5264     tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt));
5265     }
5266    
5267     - if (newopt && newoptlen)
5268     - tot_len += CMSG_ALIGN(newoptlen);
5269     + if (newopt)
5270     + tot_len += CMSG_ALIGN(ipv6_optlen(newopt));
5271    
5272     if (!tot_len)
5273     return NULL;
5274     @@ -1070,29 +1060,19 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
5275     opt2->tot_len = tot_len;
5276     p = (char *)(opt2 + 1);
5277    
5278     - err = ipv6_renew_option(opt ? opt->hopopt : NULL, newopt, newoptlen,
5279     - newtype != IPV6_HOPOPTS,
5280     - &opt2->hopopt, &p);
5281     - if (err)
5282     - goto out;
5283     -
5284     - err = ipv6_renew_option(opt ? opt->dst0opt : NULL, newopt, newoptlen,
5285     - newtype != IPV6_RTHDRDSTOPTS,
5286     - &opt2->dst0opt, &p);
5287     - if (err)
5288     - goto out;
5289     -
5290     - err = ipv6_renew_option(opt ? opt->srcrt : NULL, newopt, newoptlen,
5291     - newtype != IPV6_RTHDR,
5292     - (struct ipv6_opt_hdr **)&opt2->srcrt, &p);
5293     - if (err)
5294     - goto out;
5295     -
5296     - err = ipv6_renew_option(opt ? opt->dst1opt : NULL, newopt, newoptlen,
5297     - newtype != IPV6_DSTOPTS,
5298     - &opt2->dst1opt, &p);
5299     - if (err)
5300     - goto out;
5301     + ipv6_renew_option(IPV6_HOPOPTS, &opt2->hopopt,
5302     + (opt ? opt->hopopt : NULL),
5303     + newopt, newtype, &p);
5304     + ipv6_renew_option(IPV6_RTHDRDSTOPTS, &opt2->dst0opt,
5305     + (opt ? opt->dst0opt : NULL),
5306     + newopt, newtype, &p);
5307     + ipv6_renew_option(IPV6_RTHDR,
5308     + (struct ipv6_opt_hdr **)&opt2->srcrt,
5309     + (opt ? (struct ipv6_opt_hdr *)opt->srcrt : NULL),
5310     + newopt, newtype, &p);
5311     + ipv6_renew_option(IPV6_DSTOPTS, &opt2->dst1opt,
5312     + (opt ? opt->dst1opt : NULL),
5313     + newopt, newtype, &p);
5314    
5315     opt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) +
5316     (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) +
5317     @@ -1100,37 +1080,6 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
5318     opt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0);
5319    
5320     return opt2;
5321     -out:
5322     - sock_kfree_s(sk, opt2, opt2->tot_len);
5323     - return ERR_PTR(err);
5324     -}
5325     -
5326     -/**
5327     - * ipv6_renew_options_kern - replace a specific ext hdr with a new one.
5328     - *
5329     - * @sk: sock from which to allocate memory
5330     - * @opt: original options
5331     - * @newtype: option type to replace in @opt
5332     - * @newopt: new option of type @newtype to replace (kernel-mem)
5333     - * @newoptlen: length of @newopt
5334     - *
5335     - * See ipv6_renew_options(). The difference is that @newopt is
5336     - * kernel memory, rather than user memory.
5337     - */
5338     -struct ipv6_txoptions *
5339     -ipv6_renew_options_kern(struct sock *sk, struct ipv6_txoptions *opt,
5340     - int newtype, struct ipv6_opt_hdr *newopt,
5341     - int newoptlen)
5342     -{
5343     - struct ipv6_txoptions *ret_val;
5344     - const mm_segment_t old_fs = get_fs();
5345     -
5346     - set_fs(KERNEL_DS);
5347     - ret_val = ipv6_renew_options(sk, opt, newtype,
5348     - (struct ipv6_opt_hdr __user *)newopt,
5349     - newoptlen);
5350     - set_fs(old_fs);
5351     - return ret_val;
5352     }
5353    
5354     struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
5355     diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
5356     index 1276d5bd5675..5c91b05c8d8f 100644
5357     --- a/net/ipv6/ipv6_sockglue.c
5358     +++ b/net/ipv6/ipv6_sockglue.c
5359     @@ -390,6 +390,12 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
5360     case IPV6_DSTOPTS:
5361     {
5362     struct ipv6_txoptions *opt;
5363     + struct ipv6_opt_hdr *new = NULL;
5364     +
5365     + /* hop-by-hop / destination options are privileged option */
5366     + retv = -EPERM;
5367     + if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW))
5368     + break;
5369    
5370     /* remove any sticky options header with a zero option
5371     * length, per RFC3542.
5372     @@ -401,17 +407,22 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
5373     else if (optlen < sizeof(struct ipv6_opt_hdr) ||
5374     optlen & 0x7 || optlen > 8 * 255)
5375     goto e_inval;
5376     -
5377     - /* hop-by-hop / destination options are privileged option */
5378     - retv = -EPERM;
5379     - if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW))
5380     - break;
5381     + else {
5382     + new = memdup_user(optval, optlen);
5383     + if (IS_ERR(new)) {
5384     + retv = PTR_ERR(new);
5385     + break;
5386     + }
5387     + if (unlikely(ipv6_optlen(new) > optlen)) {
5388     + kfree(new);
5389     + goto e_inval;
5390     + }
5391     + }
5392    
5393     opt = rcu_dereference_protected(np->opt,
5394     lockdep_sock_is_held(sk));
5395     - opt = ipv6_renew_options(sk, opt, optname,
5396     - (struct ipv6_opt_hdr __user *)optval,
5397     - optlen);
5398     + opt = ipv6_renew_options(sk, opt, optname, new);
5399     + kfree(new);
5400     if (IS_ERR(opt)) {
5401     retv = PTR_ERR(opt);
5402     break;
5403     diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
5404     index 6fd913d63835..d112762b4cb8 100644
5405     --- a/net/ipv6/mcast.c
5406     +++ b/net/ipv6/mcast.c
5407     @@ -2083,7 +2083,8 @@ void ipv6_mc_dad_complete(struct inet6_dev *idev)
5408     mld_send_initial_cr(idev);
5409     idev->mc_dad_count--;
5410     if (idev->mc_dad_count)
5411     - mld_dad_start_timer(idev, idev->mc_maxdelay);
5412     + mld_dad_start_timer(idev,
5413     + unsolicited_report_interval(idev));
5414     }
5415     }
5416    
5417     @@ -2095,7 +2096,8 @@ static void mld_dad_timer_expire(unsigned long data)
5418     if (idev->mc_dad_count) {
5419     idev->mc_dad_count--;
5420     if (idev->mc_dad_count)
5421     - mld_dad_start_timer(idev, idev->mc_maxdelay);
5422     + mld_dad_start_timer(idev,
5423     + unsolicited_report_interval(idev));
5424     }
5425     in6_dev_put(idev);
5426     }
5427     @@ -2453,7 +2455,8 @@ static void mld_ifc_timer_expire(unsigned long data)
5428     if (idev->mc_ifc_count) {
5429     idev->mc_ifc_count--;
5430     if (idev->mc_ifc_count)
5431     - mld_ifc_start_timer(idev, idev->mc_maxdelay);
5432     + mld_ifc_start_timer(idev,
5433     + unsolicited_report_interval(idev));
5434     }
5435     in6_dev_put(idev);
5436     }
5437     diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
5438     index 2e51e0156903..90f5bf2502a7 100644
5439     --- a/net/ipv6/netfilter/ip6_tables.c
5440     +++ b/net/ipv6/netfilter/ip6_tables.c
5441     @@ -1907,6 +1907,7 @@ static struct xt_match ip6t_builtin_mt[] __read_mostly = {
5442     .checkentry = icmp6_checkentry,
5443     .proto = IPPROTO_ICMPV6,
5444     .family = NFPROTO_IPV6,
5445     + .me = THIS_MODULE,
5446     },
5447     };
5448    
5449     diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
5450     index 722a9db8c6a7..ee33a6743f3b 100644
5451     --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
5452     +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
5453     @@ -117,7 +117,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
5454     if (hdr == NULL)
5455     goto err_reg;
5456    
5457     - net->nf_frag.sysctl.frags_hdr = hdr;
5458     + net->nf_frag_frags_hdr = hdr;
5459     return 0;
5460    
5461     err_reg:
5462     @@ -131,8 +131,8 @@ static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)
5463     {
5464     struct ctl_table *table;
5465    
5466     - table = net->nf_frag.sysctl.frags_hdr->ctl_table_arg;
5467     - unregister_net_sysctl_table(net->nf_frag.sysctl.frags_hdr);
5468     + table = net->nf_frag_frags_hdr->ctl_table_arg;
5469     + unregister_net_sysctl_table(net->nf_frag_frags_hdr);
5470     if (!net_eq(net, &init_net))
5471     kfree(table);
5472     }
5473     diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
5474     index 01130392b7c0..a268acc48af0 100644
5475     --- a/net/netfilter/nf_conntrack_core.c
5476     +++ b/net/netfilter/nf_conntrack_core.c
5477     @@ -1949,7 +1949,7 @@ int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp)
5478     return -EOPNOTSUPP;
5479    
5480     /* On boot, we can set this without any fancy locking. */
5481     - if (!nf_conntrack_htable_size)
5482     + if (!nf_conntrack_hash)
5483     return param_set_uint(val, kp);
5484    
5485     rc = kstrtouint(val, 0, &hashsize);
5486     diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
5487     index 551a1eddf0fa..a75b11c39312 100644
5488     --- a/net/netfilter/nf_conntrack_helper.c
5489     +++ b/net/netfilter/nf_conntrack_helper.c
5490     @@ -465,6 +465,11 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)
5491    
5492     nf_ct_expect_iterate_destroy(expect_iter_me, NULL);
5493     nf_ct_iterate_destroy(unhelp, me);
5494     +
5495     + /* Maybe someone has gotten the helper already when unhelp above.
5496     + * So need to wait it.
5497     + */
5498     + synchronize_rcu();
5499     }
5500     EXPORT_SYMBOL_GPL(nf_conntrack_helper_unregister);
5501    
5502     diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
5503     index 0f5a4d79f6b8..812de5496b37 100644
5504     --- a/net/netfilter/nf_conntrack_proto_dccp.c
5505     +++ b/net/netfilter/nf_conntrack_proto_dccp.c
5506     @@ -243,14 +243,14 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][DCCP_PKT_SYNCACK + 1][CT_DCCP_MAX + 1] =
5507     * We currently ignore Sync packets
5508     *
5509     * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
5510     - sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5511     + sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5512     },
5513     [DCCP_PKT_SYNCACK] = {
5514     /*
5515     * We currently ignore SyncAck packets
5516     *
5517     * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
5518     - sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5519     + sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5520     },
5521     },
5522     [CT_DCCP_ROLE_SERVER] = {
5523     @@ -371,14 +371,14 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][DCCP_PKT_SYNCACK + 1][CT_DCCP_MAX + 1] =
5524     * We currently ignore Sync packets
5525     *
5526     * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
5527     - sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5528     + sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5529     },
5530     [DCCP_PKT_SYNCACK] = {
5531     /*
5532     * We currently ignore SyncAck packets
5533     *
5534     * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
5535     - sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5536     + sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
5537     },
5538     },
5539     };
5540     diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
5541     index 276324abfa60..cdc744aa5889 100644
5542     --- a/net/netfilter/nf_log.c
5543     +++ b/net/netfilter/nf_log.c
5544     @@ -440,6 +440,10 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
5545     if (write) {
5546     struct ctl_table tmp = *table;
5547    
5548     + /* proc_dostring() can append to existing strings, so we need to
5549     + * initialize it as an empty string.
5550     + */
5551     + buf[0] = '\0';
5552     tmp.data = buf;
5553     r = proc_dostring(&tmp, write, buffer, lenp, ppos);
5554     if (r)
5555     diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
5556     index 3bd637eadc42..6da1cec1494a 100644
5557     --- a/net/netfilter/nft_compat.c
5558     +++ b/net/netfilter/nft_compat.c
5559     @@ -825,10 +825,18 @@ nft_target_select_ops(const struct nft_ctx *ctx,
5560     rev = ntohl(nla_get_be32(tb[NFTA_TARGET_REV]));
5561     family = ctx->afi->family;
5562    
5563     + if (strcmp(tg_name, XT_ERROR_TARGET) == 0 ||
5564     + strcmp(tg_name, XT_STANDARD_TARGET) == 0 ||
5565     + strcmp(tg_name, "standard") == 0)
5566     + return ERR_PTR(-EINVAL);
5567     +
5568     /* Re-use the existing target if it's already loaded. */
5569     list_for_each_entry(nft_target, &nft_target_list, head) {
5570     struct xt_target *target = nft_target->ops.data;
5571    
5572     + if (!target->target)
5573     + continue;
5574     +
5575     if (nft_target_cmp(target, tg_name, rev, family))
5576     return &nft_target->ops;
5577     }
5578     @@ -837,6 +845,11 @@ nft_target_select_ops(const struct nft_ctx *ctx,
5579     if (IS_ERR(target))
5580     return ERR_PTR(-ENOENT);
5581    
5582     + if (!target->target) {
5583     + err = -EINVAL;
5584     + goto err;
5585     + }
5586     +
5587     if (target->targetsize > nla_len(tb[NFTA_TARGET_INFO])) {
5588     err = -EINVAL;
5589     goto err;
5590     diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
5591     index 27dafe36f29c..8833a58ca3ee 100644
5592     --- a/net/packet/af_packet.c
5593     +++ b/net/packet/af_packet.c
5594     @@ -2919,6 +2919,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
5595     goto out_free;
5596     } else if (reserve) {
5597     skb_reserve(skb, -reserve);
5598     + if (len < reserve)
5599     + skb_reset_network_header(skb);
5600     }
5601    
5602     /* Returns -EFAULT on error */
5603     @@ -4267,6 +4269,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
5604     }
5605    
5606     if (req->tp_block_nr) {
5607     + unsigned int min_frame_size;
5608     +
5609     /* Sanity tests and some calculations */
5610     err = -EBUSY;
5611     if (unlikely(rb->pg_vec))
5612     @@ -4289,12 +4293,12 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
5613     goto out;
5614     if (unlikely(!PAGE_ALIGNED(req->tp_block_size)))
5615     goto out;
5616     + min_frame_size = po->tp_hdrlen + po->tp_reserve;
5617     if (po->tp_version >= TPACKET_V3 &&
5618     - req->tp_block_size <=
5619     - BLK_PLUS_PRIV((u64)req_u->req3.tp_sizeof_priv) + sizeof(struct tpacket3_hdr))
5620     + req->tp_block_size <
5621     + BLK_PLUS_PRIV((u64)req_u->req3.tp_sizeof_priv) + min_frame_size)
5622     goto out;
5623     - if (unlikely(req->tp_frame_size < po->tp_hdrlen +
5624     - po->tp_reserve))
5625     + if (unlikely(req->tp_frame_size < min_frame_size))
5626     goto out;
5627     if (unlikely(req->tp_frame_size & (TPACKET_ALIGNMENT - 1)))
5628     goto out;
5629     diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
5630     index 78418f38464a..084adea6a818 100644
5631     --- a/net/qrtr/qrtr.c
5632     +++ b/net/qrtr/qrtr.c
5633     @@ -710,6 +710,10 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
5634     node = NULL;
5635     if (addr->sq_node == QRTR_NODE_BCAST) {
5636     enqueue_fn = qrtr_bcast_enqueue;
5637     + if (addr->sq_port != QRTR_PORT_CTRL) {
5638     + release_sock(sk);
5639     + return -ENOTCONN;
5640     + }
5641     } else if (addr->sq_node == ipc->us.sq_node) {
5642     enqueue_fn = qrtr_local_enqueue;
5643     } else {
5644     diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
5645     index 7cb63616805d..cd51f2ed55fa 100644
5646     --- a/net/sched/act_tunnel_key.c
5647     +++ b/net/sched/act_tunnel_key.c
5648     @@ -36,7 +36,7 @@ static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
5649    
5650     tcf_lastuse_update(&t->tcf_tm);
5651     bstats_cpu_update(this_cpu_ptr(t->common.cpu_bstats), skb);
5652     - action = params->action;
5653     + action = READ_ONCE(t->tcf_action);
5654    
5655     switch (params->tcft_action) {
5656     case TCA_TUNNEL_KEY_ACT_RELEASE:
5657     @@ -182,7 +182,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
5658    
5659     params_old = rtnl_dereference(t->params);
5660    
5661     - params_new->action = parm->action;
5662     + t->tcf_action = parm->action;
5663     params_new->tcft_action = parm->t_action;
5664     params_new->tcft_enc_metadata = metadata;
5665    
5666     @@ -254,13 +254,13 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
5667     .index = t->tcf_index,
5668     .refcnt = t->tcf_refcnt - ref,
5669     .bindcnt = t->tcf_bindcnt - bind,
5670     + .action = t->tcf_action,
5671     };
5672     struct tcf_t tm;
5673    
5674     params = rtnl_dereference(t->params);
5675    
5676     opt.t_action = params->tcft_action;
5677     - opt.action = params->action;
5678    
5679     if (nla_put(skb, TCA_TUNNEL_KEY_PARMS, sizeof(opt), &opt))
5680     goto nla_put_failure;
5681     diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
5682     index 3afac275ee82..acd9380a56fb 100644
5683     --- a/net/sctp/chunk.c
5684     +++ b/net/sctp/chunk.c
5685     @@ -230,7 +230,9 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
5686     /* Account for a different sized first fragment */
5687     if (msg_len >= first_len) {
5688     msg->can_delay = 0;
5689     - SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_FRAGUSRMSGS);
5690     + if (msg_len > first_len)
5691     + SCTP_INC_STATS(sock_net(asoc->base.sk),
5692     + SCTP_MIB_FRAGUSRMSGS);
5693     } else {
5694     /* Which may be the only one... */
5695     first_len = msg_len;
5696     diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
5697     index 654a81238406..43ef7be69428 100644
5698     --- a/net/smc/af_smc.c
5699     +++ b/net/smc/af_smc.c
5700     @@ -1180,8 +1180,7 @@ static int smc_shutdown(struct socket *sock, int how)
5701     lock_sock(sk);
5702    
5703     rc = -ENOTCONN;
5704     - if ((sk->sk_state != SMC_LISTEN) &&
5705     - (sk->sk_state != SMC_ACTIVE) &&
5706     + if ((sk->sk_state != SMC_ACTIVE) &&
5707     (sk->sk_state != SMC_PEERCLOSEWAIT1) &&
5708     (sk->sk_state != SMC_PEERCLOSEWAIT2) &&
5709     (sk->sk_state != SMC_APPCLOSEWAIT1) &&
5710     diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
5711     index ea28aa505302..4cd351b74e48 100644
5712     --- a/net/wireless/nl80211.c
5713     +++ b/net/wireless/nl80211.c
5714     @@ -5990,7 +5990,7 @@ do { \
5715     nl80211_check_s32);
5716     /*
5717     * Check HT operation mode based on
5718     - * IEEE 802.11 2012 8.4.2.59 HT Operation element.
5719     + * IEEE 802.11-2016 9.4.2.57 HT Operation element.
5720     */
5721     if (tb[NL80211_MESHCONF_HT_OPMODE]) {
5722     ht_opmode = nla_get_u16(tb[NL80211_MESHCONF_HT_OPMODE]);
5723     @@ -6000,22 +6000,9 @@ do { \
5724     IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
5725     return -EINVAL;
5726    
5727     - if ((ht_opmode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) &&
5728     - (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
5729     - return -EINVAL;
5730     + /* NON_HT_STA bit is reserved, but some programs set it */
5731     + ht_opmode &= ~IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
5732    
5733     - switch (ht_opmode & IEEE80211_HT_OP_MODE_PROTECTION) {
5734     - case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
5735     - case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
5736     - if (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)
5737     - return -EINVAL;
5738     - break;
5739     - case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
5740     - case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
5741     - if (!(ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
5742     - return -EINVAL;
5743     - break;
5744     - }
5745     cfg->ht_opmode = ht_opmode;
5746     mask |= (1 << (NL80211_MESHCONF_HT_OPMODE - 1));
5747     }
5748     @@ -10542,9 +10529,12 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
5749     rem) {
5750     u8 *mask_pat;
5751    
5752     - nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
5753     - nl80211_packet_pattern_policy,
5754     - info->extack);
5755     + err = nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
5756     + nl80211_packet_pattern_policy,
5757     + info->extack);
5758     + if (err)
5759     + goto error;
5760     +
5761     err = -EINVAL;
5762     if (!pat_tb[NL80211_PKTPAT_MASK] ||
5763     !pat_tb[NL80211_PKTPAT_PATTERN])
5764     @@ -10793,8 +10783,11 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
5765     rem) {
5766     u8 *mask_pat;
5767    
5768     - nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
5769     - nl80211_packet_pattern_policy, NULL);
5770     + err = nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
5771     + nl80211_packet_pattern_policy, NULL);
5772     + if (err)
5773     + return err;
5774     +
5775     if (!pat_tb[NL80211_PKTPAT_MASK] ||
5776     !pat_tb[NL80211_PKTPAT_PATTERN])
5777     return -EINVAL;
5778     diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
5779     index dbfcfefd6d69..dde40f995ac0 100644
5780     --- a/net/xfrm/xfrm_user.c
5781     +++ b/net/xfrm/xfrm_user.c
5782     @@ -1665,9 +1665,11 @@ static inline size_t userpolicy_type_attrsize(void)
5783     #ifdef CONFIG_XFRM_SUB_POLICY
5784     static int copy_to_user_policy_type(u8 type, struct sk_buff *skb)
5785     {
5786     - struct xfrm_userpolicy_type upt = {
5787     - .type = type,
5788     - };
5789     + struct xfrm_userpolicy_type upt;
5790     +
5791     + /* Sadly there are two holes in struct xfrm_userpolicy_type */
5792     + memset(&upt, 0, sizeof(upt));
5793     + upt.type = type;
5794    
5795     return nla_put(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt);
5796     }
5797     diff --git a/samples/bpf/parse_varlen.c b/samples/bpf/parse_varlen.c
5798     index 95c16324760c..0b6f22feb2c9 100644
5799     --- a/samples/bpf/parse_varlen.c
5800     +++ b/samples/bpf/parse_varlen.c
5801     @@ -6,6 +6,7 @@
5802     */
5803     #define KBUILD_MODNAME "foo"
5804     #include <linux/if_ether.h>
5805     +#include <linux/if_vlan.h>
5806     #include <linux/ip.h>
5807     #include <linux/ipv6.h>
5808     #include <linux/in.h>
5809     @@ -108,11 +109,6 @@ static int parse_ipv6(void *data, uint64_t nh_off, void *data_end)
5810     return 0;
5811     }
5812    
5813     -struct vlan_hdr {
5814     - uint16_t h_vlan_TCI;
5815     - uint16_t h_vlan_encapsulated_proto;
5816     -};
5817     -
5818     SEC("varlen")
5819     int handle_ingress(struct __sk_buff *skb)
5820     {
5821     diff --git a/samples/bpf/test_overhead_user.c b/samples/bpf/test_overhead_user.c
5822     index d291167fd3c7..7dad9a3168e1 100644
5823     --- a/samples/bpf/test_overhead_user.c
5824     +++ b/samples/bpf/test_overhead_user.c
5825     @@ -6,6 +6,7 @@
5826     */
5827     #define _GNU_SOURCE
5828     #include <sched.h>
5829     +#include <errno.h>
5830     #include <stdio.h>
5831     #include <sys/types.h>
5832     #include <asm/unistd.h>
5833     @@ -44,8 +45,13 @@ static void test_task_rename(int cpu)
5834     exit(1);
5835     }
5836     start_time = time_get_ns();
5837     - for (i = 0; i < MAX_CNT; i++)
5838     - write(fd, buf, sizeof(buf));
5839     + for (i = 0; i < MAX_CNT; i++) {
5840     + if (write(fd, buf, sizeof(buf)) < 0) {
5841     + printf("task rename failed: %s\n", strerror(errno));
5842     + close(fd);
5843     + return;
5844     + }
5845     + }
5846     printf("task_rename:%d: %lld events per sec\n",
5847     cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time));
5848     close(fd);
5849     @@ -63,8 +69,13 @@ static void test_urandom_read(int cpu)
5850     exit(1);
5851     }
5852     start_time = time_get_ns();
5853     - for (i = 0; i < MAX_CNT; i++)
5854     - read(fd, buf, sizeof(buf));
5855     + for (i = 0; i < MAX_CNT; i++) {
5856     + if (read(fd, buf, sizeof(buf)) < 0) {
5857     + printf("failed to read from /dev/urandom: %s\n", strerror(errno));
5858     + close(fd);
5859     + return;
5860     + }
5861     + }
5862     printf("urandom_read:%d: %lld events per sec\n",
5863     cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time));
5864     close(fd);
5865     diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
5866     index 7bd827b84a67..c7d525e5696e 100644
5867     --- a/samples/bpf/trace_event_user.c
5868     +++ b/samples/bpf/trace_event_user.c
5869     @@ -121,6 +121,16 @@ static void print_stacks(void)
5870     }
5871     }
5872    
5873     +static inline int generate_load(void)
5874     +{
5875     + if (system("dd if=/dev/zero of=/dev/null count=5000k status=none") < 0) {
5876     + printf("failed to generate some load with dd: %s\n", strerror(errno));
5877     + return -1;
5878     + }
5879     +
5880     + return 0;
5881     +}
5882     +
5883     static void test_perf_event_all_cpu(struct perf_event_attr *attr)
5884     {
5885     int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
5886     @@ -138,7 +148,11 @@ static void test_perf_event_all_cpu(struct perf_event_attr *attr)
5887     assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
5888     assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE) == 0);
5889     }
5890     - system("dd if=/dev/zero of=/dev/null count=5000k status=none");
5891     +
5892     + if (generate_load() < 0) {
5893     + error = 1;
5894     + goto all_cpu_err;
5895     + }
5896     print_stacks();
5897     all_cpu_err:
5898     for (i--; i >= 0; i--) {
5899     @@ -152,7 +166,7 @@ all_cpu_err:
5900    
5901     static void test_perf_event_task(struct perf_event_attr *attr)
5902     {
5903     - int pmu_fd;
5904     + int pmu_fd, error = 0;
5905    
5906     /* open task bound event */
5907     pmu_fd = sys_perf_event_open(attr, 0, -1, -1, 0);
5908     @@ -162,10 +176,17 @@ static void test_perf_event_task(struct perf_event_attr *attr)
5909     }
5910     assert(ioctl(pmu_fd, PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
5911     assert(ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE) == 0);
5912     - system("dd if=/dev/zero of=/dev/null count=5000k status=none");
5913     +
5914     + if (generate_load() < 0) {
5915     + error = 1;
5916     + goto err;
5917     + }
5918     print_stacks();
5919     +err:
5920     ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE);
5921     close(pmu_fd);
5922     + if (error)
5923     + int_exit(0);
5924     }
5925    
5926     static void test_bpf_perf_event(void)
5927     diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
5928     index 20d9caa4be99..126e3f2e1ed7 100644
5929     --- a/scripts/kconfig/zconf.y
5930     +++ b/scripts/kconfig/zconf.y
5931     @@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE];
5932     static struct menu *current_menu, *current_entry;
5933    
5934     %}
5935     -%expect 32
5936     +%expect 31
5937    
5938     %union
5939     {
5940     @@ -345,7 +345,7 @@ choice_block:
5941    
5942     /* if entry */
5943    
5944     -if_entry: T_IF expr nl
5945     +if_entry: T_IF expr T_EOL
5946     {
5947     printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
5948     menu_add_entry(NULL);
5949     diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
5950     index 286171a16ed2..fdf01bfd1b07 100644
5951     --- a/security/smack/smack_lsm.c
5952     +++ b/security/smack/smack_lsm.c
5953     @@ -2281,6 +2281,7 @@ static void smack_task_to_inode(struct task_struct *p, struct inode *inode)
5954     struct smack_known *skp = smk_of_task_struct(p);
5955    
5956     isp->smk_inode = skp;
5957     + isp->smk_flags |= SMK_INODE_INSTANT;
5958     }
5959    
5960     /*
5961     diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
5962     index a4c571cb3b87..350c33ec82b3 100644
5963     --- a/sound/core/seq/seq_clientmgr.c
5964     +++ b/sound/core/seq/seq_clientmgr.c
5965     @@ -2001,7 +2001,8 @@ static int snd_seq_ioctl_query_next_client(struct snd_seq_client *client,
5966     struct snd_seq_client *cptr = NULL;
5967    
5968     /* search for next client */
5969     - info->client++;
5970     + if (info->client < INT_MAX)
5971     + info->client++;
5972     if (info->client < 0)
5973     info->client = 0;
5974     for (; info->client < SNDRV_SEQ_MAX_CLIENTS; info->client++) {
5975     diff --git a/tools/build/Makefile b/tools/build/Makefile
5976     index 5eb4b5ad79cb..5edf65e684ab 100644
5977     --- a/tools/build/Makefile
5978     +++ b/tools/build/Makefile
5979     @@ -43,7 +43,7 @@ $(OUTPUT)fixdep-in.o: FORCE
5980     $(Q)$(MAKE) $(build)=fixdep
5981    
5982     $(OUTPUT)fixdep: $(OUTPUT)fixdep-in.o
5983     - $(QUIET_LINK)$(HOSTCC) $(LDFLAGS) -o $@ $<
5984     + $(QUIET_LINK)$(HOSTCC) $(HOSTLDFLAGS) -o $@ $<
5985    
5986     FORCE:
5987    
5988     diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
5989     index 4e60e105583e..0d1acb704f64 100644
5990     --- a/tools/objtool/elf.c
5991     +++ b/tools/objtool/elf.c
5992     @@ -302,19 +302,34 @@ static int read_symbols(struct elf *elf)
5993     continue;
5994     sym->pfunc = sym->cfunc = sym;
5995     coldstr = strstr(sym->name, ".cold.");
5996     - if (coldstr) {
5997     - coldstr[0] = '\0';
5998     - pfunc = find_symbol_by_name(elf, sym->name);
5999     - coldstr[0] = '.';
6000     -
6001     - if (!pfunc) {
6002     - WARN("%s(): can't find parent function",
6003     - sym->name);
6004     - goto err;
6005     - }
6006     -
6007     - sym->pfunc = pfunc;
6008     - pfunc->cfunc = sym;
6009     + if (!coldstr)
6010     + continue;
6011     +
6012     + coldstr[0] = '\0';
6013     + pfunc = find_symbol_by_name(elf, sym->name);
6014     + coldstr[0] = '.';
6015     +
6016     + if (!pfunc) {
6017     + WARN("%s(): can't find parent function",
6018     + sym->name);
6019     + goto err;
6020     + }
6021     +
6022     + sym->pfunc = pfunc;
6023     + pfunc->cfunc = sym;
6024     +
6025     + /*
6026     + * Unfortunately, -fnoreorder-functions puts the child
6027     + * inside the parent. Remove the overlap so we can
6028     + * have sane assumptions.
6029     + *
6030     + * Note that pfunc->len now no longer matches
6031     + * pfunc->sym.st_size.
6032     + */
6033     + if (sym->sec == pfunc->sec &&
6034     + sym->offset >= pfunc->offset &&
6035     + sym->offset + sym->len == pfunc->offset + pfunc->len) {
6036     + pfunc->len -= sym->len;
6037     }
6038     }
6039     }
6040     diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
6041     index 0c370f81e002..bd630c222e65 100644
6042     --- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
6043     +++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
6044     @@ -243,7 +243,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
6045     u64 ip;
6046     u64 skip_slot = -1;
6047    
6048     - if (chain->nr < 3)
6049     + if (!chain || chain->nr < 3)
6050     return skip_slot;
6051    
6052     ip = chain->ips[2];
6053     diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c
6054     index 4b2caf6d48e7..fead6b3b4206 100644
6055     --- a/tools/perf/arch/x86/util/perf_regs.c
6056     +++ b/tools/perf/arch/x86/util/perf_regs.c
6057     @@ -226,7 +226,7 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)
6058     else if (rm[2].rm_so != rm[2].rm_eo)
6059     prefix[0] = '+';
6060     else
6061     - strncpy(prefix, "+0", 2);
6062     + scnprintf(prefix, sizeof(prefix), "+0");
6063     }
6064    
6065     /* Rename register */
6066     diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
6067     index 944070e98a2c..0afcc7eccc61 100644
6068     --- a/tools/perf/bench/numa.c
6069     +++ b/tools/perf/bench/numa.c
6070     @@ -1098,7 +1098,7 @@ static void *worker_thread(void *__tdata)
6071     u8 *global_data;
6072     u8 *process_data;
6073     u8 *thread_data;
6074     - u64 bytes_done;
6075     + u64 bytes_done, secs;
6076     long work_done;
6077     u32 l;
6078     struct rusage rusage;
6079     @@ -1254,7 +1254,8 @@ static void *worker_thread(void *__tdata)
6080     timersub(&stop, &start0, &diff);
6081     td->runtime_ns = diff.tv_sec * NSEC_PER_SEC;
6082     td->runtime_ns += diff.tv_usec * NSEC_PER_USEC;
6083     - td->speed_gbs = bytes_done / (td->runtime_ns / NSEC_PER_SEC) / 1e9;
6084     + secs = td->runtime_ns / NSEC_PER_SEC;
6085     + td->speed_gbs = secs ? bytes_done / secs / 1e9 : 0;
6086    
6087     getrusage(RUSAGE_THREAD, &rusage);
6088     td->system_time_ns = rusage.ru_stime.tv_sec * NSEC_PER_SEC;
6089     diff --git a/tools/perf/jvmti/jvmti_agent.c b/tools/perf/jvmti/jvmti_agent.c
6090     index cf36de7ea255..c1d20d951434 100644
6091     --- a/tools/perf/jvmti/jvmti_agent.c
6092     +++ b/tools/perf/jvmti/jvmti_agent.c
6093     @@ -35,6 +35,7 @@
6094     #include <sys/mman.h>
6095     #include <syscall.h> /* for gettid() */
6096     #include <err.h>
6097     +#include <linux/kernel.h>
6098    
6099     #include "jvmti_agent.h"
6100     #include "../util/jitdump.h"
6101     @@ -249,7 +250,7 @@ void *jvmti_open(void)
6102     /*
6103     * jitdump file name
6104     */
6105     - snprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid());
6106     + scnprintf(dump_path, PATH_MAX, "%s/jit-%i.dump", jit_path, getpid());
6107    
6108     fd = open(dump_path, O_CREAT|O_TRUNC|O_RDWR, 0666);
6109     if (fd == -1)
6110     diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
6111     index 81ede20f49d7..4e9dad8c9763 100644
6112     --- a/tools/perf/tests/topology.c
6113     +++ b/tools/perf/tests/topology.c
6114     @@ -43,6 +43,7 @@ static int session_write_header(char *path)
6115    
6116     perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
6117     perf_header__set_feat(&session->header, HEADER_NRCPUS);
6118     + perf_header__set_feat(&session->header, HEADER_ARCH);
6119    
6120     session->header.data_size += DATA_SIZE;
6121    
6122     diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cpp
6123     index bf31ceab33bd..89512504551b 100644
6124     --- a/tools/perf/util/c++/clang.cpp
6125     +++ b/tools/perf/util/c++/clang.cpp
6126     @@ -146,8 +146,15 @@ getBPFObjectFromModule(llvm::Module *Module)
6127     raw_svector_ostream ostream(*Buffer);
6128    
6129     legacy::PassManager PM;
6130     - if (TargetMachine->addPassesToEmitFile(PM, ostream,
6131     - TargetMachine::CGFT_ObjectFile)) {
6132     + bool NotAdded;
6133     +#if CLANG_VERSION_MAJOR < 7
6134     + NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
6135     + TargetMachine::CGFT_ObjectFile);
6136     +#else
6137     + NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
6138     + TargetMachine::CGFT_ObjectFile);
6139     +#endif
6140     + if (NotAdded) {
6141     llvm::errs() << "TargetMachine can't emit a file of this type\n";
6142     return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr);;
6143     }
6144     diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
6145     index ba0cea8fef72..8a678a3d5a2a 100644
6146     --- a/tools/perf/util/header.c
6147     +++ b/tools/perf/util/header.c
6148     @@ -1824,6 +1824,7 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
6149     int cpu_nr = ff->ph->env.nr_cpus_avail;
6150     u64 size = 0;
6151     struct perf_header *ph = ff->ph;
6152     + bool do_core_id_test = true;
6153    
6154     ph->env.cpu = calloc(cpu_nr, sizeof(*ph->env.cpu));
6155     if (!ph->env.cpu)
6156     @@ -1878,6 +1879,13 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
6157     return 0;
6158     }
6159    
6160     + /* On s390 the socket_id number is not related to the numbers of cpus.
6161     + * The socket_id number might be higher than the numbers of cpus.
6162     + * This depends on the configuration.
6163     + */
6164     + if (ph->env.arch && !strncmp(ph->env.arch, "s390", 4))
6165     + do_core_id_test = false;
6166     +
6167     for (i = 0; i < (u32)cpu_nr; i++) {
6168     if (do_read_u32(ff, &nr))
6169     goto free_cpu;
6170     @@ -1887,7 +1895,7 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
6171     if (do_read_u32(ff, &nr))
6172     goto free_cpu;
6173    
6174     - if (nr != (u32)-1 && nr > (u32)cpu_nr) {
6175     + if (do_core_id_test && nr != (u32)-1 && nr > (u32)cpu_nr) {
6176     pr_debug("socket_id number is too big."
6177     "You may need to upgrade the perf tool.\n");
6178     goto free_cpu;
6179     diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
6180     index 4952b429caa7..2bdaac048a0a 100644
6181     --- a/tools/perf/util/llvm-utils.c
6182     +++ b/tools/perf/util/llvm-utils.c
6183     @@ -265,16 +265,16 @@ static const char *kinc_fetch_script =
6184     "#!/usr/bin/env sh\n"
6185     "if ! test -d \"$KBUILD_DIR\"\n"
6186     "then\n"
6187     -" exit -1\n"
6188     +" exit 1\n"
6189     "fi\n"
6190     "if ! test -f \"$KBUILD_DIR/include/generated/autoconf.h\"\n"
6191     "then\n"
6192     -" exit -1\n"
6193     +" exit 1\n"
6194     "fi\n"
6195     "TMPDIR=`mktemp -d`\n"
6196     "if test -z \"$TMPDIR\"\n"
6197     "then\n"
6198     -" exit -1\n"
6199     +" exit 1\n"
6200     "fi\n"
6201     "cat << EOF > $TMPDIR/Makefile\n"
6202     "obj-y := dummy.o\n"
6203     diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
6204     index 988310cd3049..b6115cbdf842 100644
6205     --- a/tools/perf/util/parse-events.y
6206     +++ b/tools/perf/util/parse-events.y
6207     @@ -226,11 +226,16 @@ event_def: event_pmu |
6208     event_pmu:
6209     PE_NAME opt_pmu_config
6210     {
6211     + struct parse_events_state *parse_state = _parse_state;
6212     + struct parse_events_error *error = parse_state->error;
6213     struct list_head *list, *orig_terms, *terms;
6214    
6215     if (parse_events_copy_term_list($2, &orig_terms))
6216     YYABORT;
6217    
6218     + if (error)
6219     + error->idx = @1.first_column;
6220     +
6221     ALLOC_LIST(list);
6222     if (parse_events_add_pmu(_parse_state, list, $1, $2)) {
6223     struct perf_pmu *pmu = NULL;
6224     diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
6225     index c7187f067d31..f03fa7a835a1 100644
6226     --- a/tools/perf/util/scripting-engines/trace-event-python.c
6227     +++ b/tools/perf/util/scripting-engines/trace-event-python.c
6228     @@ -643,14 +643,11 @@ static void python_process_tracepoint(struct perf_sample *sample,
6229     if (_PyTuple_Resize(&t, n) == -1)
6230     Py_FatalError("error resizing Python tuple");
6231    
6232     - if (!dict) {
6233     + if (!dict)
6234     call_object(handler, t, handler_name);
6235     - } else {
6236     + else
6237     call_object(handler, t, default_handler_name);
6238     - Py_DECREF(dict);
6239     - }
6240    
6241     - Py_XDECREF(all_entries_dict);
6242     Py_DECREF(t);
6243     }
6244    
6245     @@ -970,7 +967,6 @@ static void python_process_general_event(struct perf_sample *sample,
6246    
6247     call_object(handler, t, handler_name);
6248    
6249     - Py_DECREF(dict);
6250     Py_DECREF(t);
6251     }
6252    
6253     diff --git a/tools/testing/selftests/bpf/test_kmod.sh b/tools/testing/selftests/bpf/test_kmod.sh
6254     index ed4774d8d6ed..0f7b9aa9c6a5 100755
6255     --- a/tools/testing/selftests/bpf/test_kmod.sh
6256     +++ b/tools/testing/selftests/bpf/test_kmod.sh
6257     @@ -1,6 +1,15 @@
6258     #!/bin/sh
6259     # SPDX-License-Identifier: GPL-2.0
6260    
6261     +# Kselftest framework requirement - SKIP code is 4.
6262     +ksft_skip=4
6263     +
6264     +msg="skip all tests:"
6265     +if [ "$(id -u)" != "0" ]; then
6266     + echo $msg please run this as root >&2
6267     + exit $ksft_skip
6268     +fi
6269     +
6270     SRC_TREE=../../../../
6271    
6272     test_run()
6273     diff --git a/tools/testing/selftests/pstore/pstore_post_reboot_tests b/tools/testing/selftests/pstore/pstore_post_reboot_tests
6274     index 6ccb154cb4aa..22f8df1ad7d4 100755
6275     --- a/tools/testing/selftests/pstore/pstore_post_reboot_tests
6276     +++ b/tools/testing/selftests/pstore/pstore_post_reboot_tests
6277     @@ -7,13 +7,16 @@
6278     #
6279     # Released under the terms of the GPL v2.
6280    
6281     +# Kselftest framework requirement - SKIP code is 4.
6282     +ksft_skip=4
6283     +
6284     . ./common_tests
6285    
6286     if [ -e $REBOOT_FLAG ]; then
6287     rm $REBOOT_FLAG
6288     else
6289     prlog "pstore_crash_test has not been executed yet. we skip further tests."
6290     - exit 0
6291     + exit $ksft_skip
6292     fi
6293    
6294     prlog -n "Mounting pstore filesystem ... "
6295     diff --git a/tools/testing/selftests/static_keys/test_static_keys.sh b/tools/testing/selftests/static_keys/test_static_keys.sh
6296     index 24cff498b31a..fc9f8cde7d42 100755
6297     --- a/tools/testing/selftests/static_keys/test_static_keys.sh
6298     +++ b/tools/testing/selftests/static_keys/test_static_keys.sh
6299     @@ -2,6 +2,19 @@
6300     # SPDX-License-Identifier: GPL-2.0
6301     # Runs static keys kernel module tests
6302    
6303     +# Kselftest framework requirement - SKIP code is 4.
6304     +ksft_skip=4
6305     +
6306     +if ! /sbin/modprobe -q -n test_static_key_base; then
6307     + echo "static_key: module test_static_key_base is not found [SKIP]"
6308     + exit $ksft_skip
6309     +fi
6310     +
6311     +if ! /sbin/modprobe -q -n test_static_keys; then
6312     + echo "static_key: module test_static_keys is not found [SKIP]"
6313     + exit $ksft_skip
6314     +fi
6315     +
6316     if /sbin/modprobe -q test_static_key_base; then
6317     if /sbin/modprobe -q test_static_keys; then
6318     echo "static_key: ok"
6319     diff --git a/tools/testing/selftests/sync/config b/tools/testing/selftests/sync/config
6320     new file mode 100644
6321     index 000000000000..1ab7e8130db2
6322     --- /dev/null
6323     +++ b/tools/testing/selftests/sync/config
6324     @@ -0,0 +1,4 @@
6325     +CONFIG_STAGING=y
6326     +CONFIG_ANDROID=y
6327     +CONFIG_SYNC=y
6328     +CONFIG_SW_SYNC=y
6329     diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
6330     index ec232c3cfcaa..584eb8ea780a 100755
6331     --- a/tools/testing/selftests/sysctl/sysctl.sh
6332     +++ b/tools/testing/selftests/sysctl/sysctl.sh
6333     @@ -14,6 +14,9 @@
6334    
6335     # This performs a series tests against the proc sysctl interface.
6336    
6337     +# Kselftest framework requirement - SKIP code is 4.
6338     +ksft_skip=4
6339     +
6340     TEST_NAME="sysctl"
6341     TEST_DRIVER="test_${TEST_NAME}"
6342     TEST_DIR=$(dirname $0)
6343     @@ -41,7 +44,7 @@ test_modprobe()
6344     echo "$0: $DIR not present" >&2
6345     echo "You must have the following enabled in your kernel:" >&2
6346     cat $TEST_DIR/config >&2
6347     - exit 1
6348     + exit $ksft_skip
6349     fi
6350     }
6351    
6352     @@ -98,28 +101,30 @@ test_reqs()
6353     uid=$(id -u)
6354     if [ $uid -ne 0 ]; then
6355     echo $msg must be run as root >&2
6356     - exit 0
6357     + exit $ksft_skip
6358     fi
6359    
6360     if ! which perl 2> /dev/null > /dev/null; then
6361     echo "$0: You need perl installed"
6362     - exit 1
6363     + exit $ksft_skip
6364     fi
6365     if ! which getconf 2> /dev/null > /dev/null; then
6366     echo "$0: You need getconf installed"
6367     - exit 1
6368     + exit $ksft_skip
6369     fi
6370     if ! which diff 2> /dev/null > /dev/null; then
6371     echo "$0: You need diff installed"
6372     - exit 1
6373     + exit $ksft_skip
6374     fi
6375     }
6376    
6377     function load_req_mod()
6378     {
6379     - trap "test_modprobe" EXIT
6380     -
6381     if [ ! -d $DIR ]; then
6382     + if ! modprobe -q -n $TEST_DRIVER; then
6383     + echo "$0: module $TEST_DRIVER not found [SKIP]"
6384     + exit $ksft_skip
6385     + fi
6386     modprobe $TEST_DRIVER
6387     if [ $? -ne 0 ]; then
6388     exit
6389     @@ -765,6 +770,7 @@ function parse_args()
6390     test_reqs
6391     allow_user_defaults
6392     check_production_sysctl_writes_strict
6393     +test_modprobe
6394     load_req_mod
6395    
6396     trap "test_finish" EXIT
6397     diff --git a/tools/testing/selftests/user/test_user_copy.sh b/tools/testing/selftests/user/test_user_copy.sh
6398     index d60506fc77f8..f9b31a57439b 100755
6399     --- a/tools/testing/selftests/user/test_user_copy.sh
6400     +++ b/tools/testing/selftests/user/test_user_copy.sh
6401     @@ -2,6 +2,13 @@
6402     # SPDX-License-Identifier: GPL-2.0
6403     # Runs copy_to/from_user infrastructure using test_user_copy kernel module
6404    
6405     +# Kselftest framework requirement - SKIP code is 4.
6406     +ksft_skip=4
6407     +
6408     +if ! /sbin/modprobe -q -n test_user_copy; then
6409     + echo "user: module test_user_copy is not found [SKIP]"
6410     + exit $ksft_skip
6411     +fi
6412     if /sbin/modprobe -q test_user_copy; then
6413     /sbin/modprobe -q -r test_user_copy
6414     echo "user_copy: ok"
6415     diff --git a/tools/testing/selftests/vm/compaction_test.c b/tools/testing/selftests/vm/compaction_test.c
6416     index 1097f04e4d80..bcec71250873 100644
6417     --- a/tools/testing/selftests/vm/compaction_test.c
6418     +++ b/tools/testing/selftests/vm/compaction_test.c
6419     @@ -16,6 +16,8 @@
6420     #include <unistd.h>
6421     #include <string.h>
6422    
6423     +#include "../kselftest.h"
6424     +
6425     #define MAP_SIZE 1048576
6426    
6427     struct map_list {
6428     @@ -169,7 +171,7 @@ int main(int argc, char **argv)
6429     printf("Either the sysctl compact_unevictable_allowed is not\n"
6430     "set to 1 or couldn't read the proc file.\n"
6431     "Skipping the test\n");
6432     - return 0;
6433     + return KSFT_SKIP;
6434     }
6435    
6436     lim.rlim_cur = RLIM_INFINITY;
6437     diff --git a/tools/testing/selftests/vm/mlock2-tests.c b/tools/testing/selftests/vm/mlock2-tests.c
6438     index 4997b9222cfa..637b6d0ac0d0 100644
6439     --- a/tools/testing/selftests/vm/mlock2-tests.c
6440     +++ b/tools/testing/selftests/vm/mlock2-tests.c
6441     @@ -9,6 +9,8 @@
6442     #include <stdbool.h>
6443     #include "mlock2.h"
6444    
6445     +#include "../kselftest.h"
6446     +
6447     struct vm_boundaries {
6448     unsigned long start;
6449     unsigned long end;
6450     @@ -303,7 +305,7 @@ static int test_mlock_lock()
6451     if (mlock2_(map, 2 * page_size, 0)) {
6452     if (errno == ENOSYS) {
6453     printf("Cannot call new mlock family, skipping test\n");
6454     - _exit(0);
6455     + _exit(KSFT_SKIP);
6456     }
6457     perror("mlock2(0)");
6458     goto unmap;
6459     @@ -412,7 +414,7 @@ static int test_mlock_onfault()
6460     if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) {
6461     if (errno == ENOSYS) {
6462     printf("Cannot call new mlock family, skipping test\n");
6463     - _exit(0);
6464     + _exit(KSFT_SKIP);
6465     }
6466     perror("mlock2(MLOCK_ONFAULT)");
6467     goto unmap;
6468     @@ -425,7 +427,7 @@ static int test_mlock_onfault()
6469     if (munlock(map, 2 * page_size)) {
6470     if (errno == ENOSYS) {
6471     printf("Cannot call new mlock family, skipping test\n");
6472     - _exit(0);
6473     + _exit(KSFT_SKIP);
6474     }
6475     perror("munlock()");
6476     goto unmap;
6477     @@ -457,7 +459,7 @@ static int test_lock_onfault_of_present()
6478     if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) {
6479     if (errno == ENOSYS) {
6480     printf("Cannot call new mlock family, skipping test\n");
6481     - _exit(0);
6482     + _exit(KSFT_SKIP);
6483     }
6484     perror("mlock2(MLOCK_ONFAULT)");
6485     goto unmap;
6486     @@ -583,7 +585,7 @@ static int test_vma_management(bool call_mlock)
6487     if (call_mlock && mlock2_(map, 3 * page_size, MLOCK_ONFAULT)) {
6488     if (errno == ENOSYS) {
6489     printf("Cannot call new mlock family, skipping test\n");
6490     - _exit(0);
6491     + _exit(KSFT_SKIP);
6492     }
6493     perror("mlock(ONFAULT)\n");
6494     goto out;
6495     diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
6496     index 45708aa3ce47..57ab6ac0d4a4 100755
6497     --- a/tools/testing/selftests/vm/run_vmtests
6498     +++ b/tools/testing/selftests/vm/run_vmtests
6499     @@ -2,6 +2,9 @@
6500     # SPDX-License-Identifier: GPL-2.0
6501     #please run as root
6502    
6503     +# Kselftest framework requirement - SKIP code is 4.
6504     +ksft_skip=4
6505     +
6506     mnt=./huge
6507     exitcode=0
6508    
6509     @@ -36,7 +39,7 @@ if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
6510     echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
6511     if [ $? -ne 0 ]; then
6512     echo "Please run this test as root"
6513     - exit 1
6514     + exit $ksft_skip
6515     fi
6516     while read name size unit; do
6517     if [ "$name" = "HugePages_Free:" ]; then
6518     diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
6519     index de2f9ec8a87f..7b8171e3128a 100644
6520     --- a/tools/testing/selftests/vm/userfaultfd.c
6521     +++ b/tools/testing/selftests/vm/userfaultfd.c
6522     @@ -69,6 +69,8 @@
6523     #include <setjmp.h>
6524     #include <stdbool.h>
6525    
6526     +#include "../kselftest.h"
6527     +
6528     #ifdef __NR_userfaultfd
6529    
6530     static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
6531     @@ -1322,7 +1324,7 @@ int main(int argc, char **argv)
6532     int main(void)
6533     {
6534     printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n");
6535     - return 0;
6536     + return KSFT_SKIP;
6537     }
6538    
6539     #endif /* __NR_userfaultfd */
6540     diff --git a/tools/testing/selftests/x86/sigreturn.c b/tools/testing/selftests/x86/sigreturn.c
6541     index 246145b84a12..4d9dc3f2fd70 100644
6542     --- a/tools/testing/selftests/x86/sigreturn.c
6543     +++ b/tools/testing/selftests/x86/sigreturn.c
6544     @@ -610,21 +610,41 @@ static int test_valid_sigreturn(int cs_bits, bool use_16bit_ss, int force_ss)
6545     */
6546     for (int i = 0; i < NGREG; i++) {
6547     greg_t req = requested_regs[i], res = resulting_regs[i];
6548     +
6549     if (i == REG_TRAPNO || i == REG_IP)
6550     continue; /* don't care */
6551     - if (i == REG_SP) {
6552     - printf("\tSP: %llx -> %llx\n", (unsigned long long)req,
6553     - (unsigned long long)res);
6554    
6555     + if (i == REG_SP) {
6556     /*
6557     - * In many circumstances, the high 32 bits of rsp
6558     - * are zeroed. For example, we could be a real
6559     - * 32-bit program, or we could hit any of a number
6560     - * of poorly-documented IRET or segmented ESP
6561     - * oddities. If this happens, it's okay.
6562     + * If we were using a 16-bit stack segment, then
6563     + * the kernel is a bit stuck: IRET only restores
6564     + * the low 16 bits of ESP/RSP if SS is 16-bit.
6565     + * The kernel uses a hack to restore bits 31:16,
6566     + * but that hack doesn't help with bits 63:32.
6567     + * On Intel CPUs, bits 63:32 end up zeroed, and, on
6568     + * AMD CPUs, they leak the high bits of the kernel
6569     + * espfix64 stack pointer. There's very little that
6570     + * the kernel can do about it.
6571     + *
6572     + * Similarly, if we are returning to a 32-bit context,
6573     + * the CPU will often lose the high 32 bits of RSP.
6574     */
6575     - if (res == (req & 0xFFFFFFFF))
6576     - continue; /* OK; not expected to work */
6577     +
6578     + if (res == req)
6579     + continue;
6580     +
6581     + if (cs_bits != 64 && ((res ^ req) & 0xFFFFFFFF) == 0) {
6582     + printf("[NOTE]\tSP: %llx -> %llx\n",
6583     + (unsigned long long)req,
6584     + (unsigned long long)res);
6585     + continue;
6586     + }
6587     +
6588     + printf("[FAIL]\tSP mismatch: requested 0x%llx; got 0x%llx\n",
6589     + (unsigned long long)requested_regs[i],
6590     + (unsigned long long)resulting_regs[i]);
6591     + nerrs++;
6592     + continue;
6593     }
6594    
6595     bool ignore_reg = false;
6596     @@ -654,25 +674,18 @@ static int test_valid_sigreturn(int cs_bits, bool use_16bit_ss, int force_ss)
6597     #endif
6598    
6599     /* Sanity check on the kernel */
6600     - if (i == REG_CX && requested_regs[i] != resulting_regs[i]) {
6601     + if (i == REG_CX && req != res) {
6602     printf("[FAIL]\tCX (saved SP) mismatch: requested 0x%llx; got 0x%llx\n",
6603     - (unsigned long long)requested_regs[i],
6604     - (unsigned long long)resulting_regs[i]);
6605     + (unsigned long long)req,
6606     + (unsigned long long)res);
6607     nerrs++;
6608     continue;
6609     }
6610    
6611     - if (requested_regs[i] != resulting_regs[i] && !ignore_reg) {
6612     - /*
6613     - * SP is particularly interesting here. The
6614     - * usual cause of failures is that we hit the
6615     - * nasty IRET case of returning to a 16-bit SS,
6616     - * in which case bits 16:31 of the *kernel*
6617     - * stack pointer persist in ESP.
6618     - */
6619     + if (req != res && !ignore_reg) {
6620     printf("[FAIL]\tReg %d mismatch: requested 0x%llx; got 0x%llx\n",
6621     - i, (unsigned long long)requested_regs[i],
6622     - (unsigned long long)resulting_regs[i]);
6623     + i, (unsigned long long)req,
6624     + (unsigned long long)res);
6625     nerrs++;
6626     }
6627     }
6628     diff --git a/tools/testing/selftests/zram/zram.sh b/tools/testing/selftests/zram/zram.sh
6629     index 754de7da426a..232e958ec454 100755
6630     --- a/tools/testing/selftests/zram/zram.sh
6631     +++ b/tools/testing/selftests/zram/zram.sh
6632     @@ -2,6 +2,9 @@
6633     # SPDX-License-Identifier: GPL-2.0
6634     TCID="zram.sh"
6635    
6636     +# Kselftest framework requirement - SKIP code is 4.
6637     +ksft_skip=4
6638     +
6639     . ./zram_lib.sh
6640    
6641     run_zram () {
6642     @@ -24,5 +27,5 @@ elif [ -b /dev/zram0 ]; then
6643     else
6644     echo "$TCID : No zram.ko module or /dev/zram0 device file not found"
6645     echo "$TCID : CONFIG_ZRAM is not set"
6646     - exit 1
6647     + exit $ksft_skip
6648     fi
6649     diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh
6650     index f6a9c73e7a44..9e73a4fb9b0a 100755
6651     --- a/tools/testing/selftests/zram/zram_lib.sh
6652     +++ b/tools/testing/selftests/zram/zram_lib.sh
6653     @@ -18,6 +18,9 @@ MODULE=0
6654     dev_makeswap=-1
6655     dev_mounted=-1
6656    
6657     +# Kselftest framework requirement - SKIP code is 4.
6658     +ksft_skip=4
6659     +
6660     trap INT
6661    
6662     check_prereqs()
6663     @@ -27,7 +30,7 @@ check_prereqs()
6664    
6665     if [ $uid -ne 0 ]; then
6666     echo $msg must be run as root >&2
6667     - exit 0
6668     + exit $ksft_skip
6669     fi
6670     }
6671    
6672     diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
6673     index 6b4fcd52f14c..a37b03c25457 100644
6674     --- a/virt/kvm/arm/vgic/vgic-v3.c
6675     +++ b/virt/kvm/arm/vgic/vgic-v3.c
6676     @@ -492,11 +492,6 @@ int vgic_v3_probe(const struct gic_kvm_info *info)
6677     pr_warn("GICV physical address 0x%llx not page aligned\n",
6678     (unsigned long long)info->vcpu.start);
6679     kvm_vgic_global_state.vcpu_base = 0;
6680     - } else if (!PAGE_ALIGNED(resource_size(&info->vcpu))) {
6681     - pr_warn("GICV size 0x%llx not a multiple of page size 0x%lx\n",
6682     - (unsigned long long)resource_size(&info->vcpu),
6683     - PAGE_SIZE);
6684     - kvm_vgic_global_state.vcpu_base = 0;
6685     } else {
6686     kvm_vgic_global_state.vcpu_base = info->vcpu.start;
6687     kvm_vgic_global_state.can_emulate_gicv2 = true;
6688     diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
6689     index 58a9b31b0dd5..088734a700e9 100644
6690     --- a/virt/kvm/eventfd.c
6691     +++ b/virt/kvm/eventfd.c
6692     @@ -405,11 +405,6 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
6693     if (events & POLLIN)
6694     schedule_work(&irqfd->inject);
6695    
6696     - /*
6697     - * do not drop the file until the irqfd is fully initialized, otherwise
6698     - * we might race against the POLLHUP
6699     - */
6700     - fdput(f);
6701     #ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
6702     if (kvm_arch_has_irq_bypass()) {
6703     irqfd->consumer.token = (void *)irqfd->eventfd;
6704     @@ -425,6 +420,12 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
6705     #endif
6706    
6707     srcu_read_unlock(&kvm->irq_srcu, idx);
6708     +
6709     + /*
6710     + * do not drop the file until the irqfd is fully initialized, otherwise
6711     + * we might race against the POLLHUP
6712     + */
6713     + fdput(f);
6714     return 0;
6715    
6716     fail: