Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.9/0216-4.9.117-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3193 - (hide annotations) (download)
Wed Aug 8 14:17:42 2018 UTC (5 years, 9 months ago) by niro
File size: 121182 byte(s)
-linux-4.9.117
1 niro 3193 diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.txt b/Documentation/devicetree/bindings/net/dsa/qca8k.txt
2     index 9c67ee4890d7..bbcb255c3150 100644
3     --- a/Documentation/devicetree/bindings/net/dsa/qca8k.txt
4     +++ b/Documentation/devicetree/bindings/net/dsa/qca8k.txt
5     @@ -2,7 +2,10 @@
6    
7     Required properties:
8    
9     -- compatible: should be "qca,qca8337"
10     +- compatible: should be one of:
11     + "qca,qca8334"
12     + "qca,qca8337"
13     +
14     - #size-cells: must be 0
15     - #address-cells: must be 1
16    
17     @@ -14,6 +17,20 @@ port and PHY id, each subnode describing a port needs to have a valid phandle
18     referencing the internal PHY connected to it. The CPU port of this switch is
19     always port 0.
20    
21     +A CPU port node has the following optional node:
22     +
23     +- fixed-link : Fixed-link subnode describing a link to a non-MDIO
24     + managed entity. See
25     + Documentation/devicetree/bindings/net/fixed-link.txt
26     + for details.
27     +
28     +For QCA8K the 'fixed-link' sub-node supports only the following properties:
29     +
30     +- 'speed' (integer, mandatory), to indicate the link speed. Accepted
31     + values are 10, 100 and 1000
32     +- 'full-duplex' (boolean, optional), to indicate that full duplex is
33     + used. When absent, half duplex is assumed.
34     +
35     Example:
36    
37    
38     @@ -53,6 +70,10 @@ Example:
39     label = "cpu";
40     ethernet = <&gmac1>;
41     phy-mode = "rgmii";
42     + fixed-link {
43     + speed = 1000;
44     + full-duplex;
45     + };
46     };
47    
48     port@1 {
49     diff --git a/Documentation/devicetree/bindings/net/meson-dwmac.txt b/Documentation/devicetree/bindings/net/meson-dwmac.txt
50     index 89e62ddc69ca..da37da0fdd3f 100644
51     --- a/Documentation/devicetree/bindings/net/meson-dwmac.txt
52     +++ b/Documentation/devicetree/bindings/net/meson-dwmac.txt
53     @@ -10,6 +10,7 @@ Required properties on all platforms:
54     - "amlogic,meson6-dwmac"
55     - "amlogic,meson8b-dwmac"
56     - "amlogic,meson-gxbb-dwmac"
57     + - "amlogic,meson-axg-dwmac"
58     Additionally "snps,dwmac" and any applicable more
59     detailed version number described in net/stmmac.txt
60     should be used.
61     diff --git a/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
62     index fe7fe0b03cfb..1b9881786ce9 100644
63     --- a/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
64     +++ b/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
65     @@ -3,8 +3,10 @@
66     Required properties for the root node:
67     - compatible: one of "amlogic,meson8-cbus-pinctrl"
68     "amlogic,meson8b-cbus-pinctrl"
69     + "amlogic,meson8m2-cbus-pinctrl"
70     "amlogic,meson8-aobus-pinctrl"
71     "amlogic,meson8b-aobus-pinctrl"
72     + "amlogic,meson8m2-aobus-pinctrl"
73     "amlogic,meson-gxbb-periphs-pinctrl"
74     "amlogic,meson-gxbb-aobus-pinctrl"
75     - reg: address and size of registers controlling irq functionality
76     diff --git a/Makefile b/Makefile
77     index a6b011778960..773c26c95d98 100644
78     --- a/Makefile
79     +++ b/Makefile
80     @@ -1,6 +1,6 @@
81     VERSION = 4
82     PATCHLEVEL = 9
83     -SUBLEVEL = 116
84     +SUBLEVEL = 117
85     EXTRAVERSION =
86     NAME = Roaring Lionus
87    
88     diff --git a/arch/arm/boot/dts/emev2.dtsi b/arch/arm/boot/dts/emev2.dtsi
89     index cd119400f440..fd6f9ce9206a 100644
90     --- a/arch/arm/boot/dts/emev2.dtsi
91     +++ b/arch/arm/boot/dts/emev2.dtsi
92     @@ -30,13 +30,13 @@
93     #address-cells = <1>;
94     #size-cells = <0>;
95    
96     - cpu@0 {
97     + cpu0: cpu@0 {
98     device_type = "cpu";
99     compatible = "arm,cortex-a9";
100     reg = <0>;
101     clock-frequency = <533000000>;
102     };
103     - cpu@1 {
104     + cpu1: cpu@1 {
105     device_type = "cpu";
106     compatible = "arm,cortex-a9";
107     reg = <1>;
108     @@ -56,6 +56,7 @@
109     compatible = "arm,cortex-a9-pmu";
110     interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>,
111     <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
112     + interrupt-affinity = <&cpu0>, <&cpu1>;
113     };
114    
115     clocks@e0110000 {
116     diff --git a/arch/arm/boot/dts/sh73a0.dtsi b/arch/arm/boot/dts/sh73a0.dtsi
117     index 032fe2f14b16..6b0cc225149c 100644
118     --- a/arch/arm/boot/dts/sh73a0.dtsi
119     +++ b/arch/arm/boot/dts/sh73a0.dtsi
120     @@ -22,7 +22,7 @@
121     #address-cells = <1>;
122     #size-cells = <0>;
123    
124     - cpu@0 {
125     + cpu0: cpu@0 {
126     device_type = "cpu";
127     compatible = "arm,cortex-a9";
128     reg = <0>;
129     @@ -30,7 +30,7 @@
130     power-domains = <&pd_a2sl>;
131     next-level-cache = <&L2>;
132     };
133     - cpu@1 {
134     + cpu1: cpu@1 {
135     device_type = "cpu";
136     compatible = "arm,cortex-a9";
137     reg = <1>;
138     @@ -89,6 +89,7 @@
139     compatible = "arm,cortex-a9-pmu";
140     interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
141     <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>;
142     + interrupt-affinity = <&cpu0>, <&cpu1>;
143     };
144    
145     cmt1: timer@e6138000 {
146     diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
147     index dab2cb0c1f1c..b4c4d823569a 100644
148     --- a/arch/arm64/configs/defconfig
149     +++ b/arch/arm64/configs/defconfig
150     @@ -260,6 +260,8 @@ CONFIG_GPIO_XGENE=y
151     CONFIG_GPIO_PCA953X=y
152     CONFIG_GPIO_PCA953X_IRQ=y
153     CONFIG_GPIO_MAX77620=y
154     +CONFIG_POWER_AVS=y
155     +CONFIG_ROCKCHIP_IODOMAIN=y
156     CONFIG_POWER_RESET_MSM=y
157     CONFIG_BATTERY_BQ27XXX=y
158     CONFIG_POWER_RESET_XGENE=y
159     diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h
160     index ae852add053d..0f2e1ab5e166 100644
161     --- a/arch/arm64/include/asm/cmpxchg.h
162     +++ b/arch/arm64/include/asm/cmpxchg.h
163     @@ -229,7 +229,9 @@ static inline void __cmpwait_case_##name(volatile void *ptr, \
164     unsigned long tmp; \
165     \
166     asm volatile( \
167     - " ldxr" #sz "\t%" #w "[tmp], %[v]\n" \
168     + " sevl\n" \
169     + " wfe\n" \
170     + " ldxr" #sz "\t%" #w "[tmp], %[v]\n" \
171     " eor %" #w "[tmp], %" #w "[tmp], %" #w "[val]\n" \
172     " cbnz %" #w "[tmp], 1f\n" \
173     " wfe\n" \
174     diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
175     index 9b8b477c363d..9d07b421f090 100644
176     --- a/arch/arm64/mm/init.c
177     +++ b/arch/arm64/mm/init.c
178     @@ -468,11 +468,13 @@ void __init mem_init(void)
179     BUILD_BUG_ON(TASK_SIZE_32 > TASK_SIZE_64);
180     #endif
181    
182     +#ifdef CONFIG_SPARSEMEM_VMEMMAP
183     /*
184     * Make sure we chose the upper bound of sizeof(struct page)
185     - * correctly.
186     + * correctly when sizing the VMEMMAP array.
187     */
188     BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT));
189     +#endif
190    
191     if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
192     extern int sysctl_overcommit_memory;
193     diff --git a/arch/microblaze/boot/Makefile b/arch/microblaze/boot/Makefile
194     index 91d2068da1b9..0f3fe6a151dc 100644
195     --- a/arch/microblaze/boot/Makefile
196     +++ b/arch/microblaze/boot/Makefile
197     @@ -21,17 +21,19 @@ $(obj)/linux.bin.gz: $(obj)/linux.bin FORCE
198     quiet_cmd_cp = CP $< $@$2
199     cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false)
200    
201     -quiet_cmd_strip = STRIP $@
202     +quiet_cmd_strip = STRIP $< $@$2
203     cmd_strip = $(STRIP) -K microblaze_start -K _end -K __log_buf \
204     - -K _fdt_start vmlinux -o $@
205     + -K _fdt_start $< -o $@$2
206    
207     UIMAGE_LOADADDR = $(CONFIG_KERNEL_BASE_ADDR)
208     +UIMAGE_IN = $@
209     +UIMAGE_OUT = $@.ub
210    
211     $(obj)/simpleImage.%: vmlinux FORCE
212     $(call if_changed,cp,.unstrip)
213     $(call if_changed,objcopy)
214     $(call if_changed,uimage)
215     - $(call if_changed,strip)
216     - @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
217     + $(call if_changed,strip,.strip)
218     + @echo 'Kernel: $(UIMAGE_OUT) is ready' ' (#'`cat .version`')'
219    
220     clean-files += simpleImage.*.unstrip linux.bin.ub dts/*.dtb
221     diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
222     index 27843665da9e..620e08d4eb6e 100644
223     --- a/arch/powerpc/kernel/eeh_driver.c
224     +++ b/arch/powerpc/kernel/eeh_driver.c
225     @@ -450,9 +450,11 @@ static void *eeh_add_virt_device(void *data, void *userdata)
226    
227     driver = eeh_pcid_get(dev);
228     if (driver) {
229     - eeh_pcid_put(dev);
230     - if (driver->err_handler)
231     + if (driver->err_handler) {
232     + eeh_pcid_put(dev);
233     return NULL;
234     + }
235     + eeh_pcid_put(dev);
236     }
237    
238     #ifdef CONFIG_PPC_POWERNV
239     @@ -489,17 +491,19 @@ static void *eeh_rmv_device(void *data, void *userdata)
240     if (eeh_dev_removed(edev))
241     return NULL;
242    
243     - driver = eeh_pcid_get(dev);
244     - if (driver) {
245     - eeh_pcid_put(dev);
246     - if (removed &&
247     - eeh_pe_passed(edev->pe))
248     - return NULL;
249     - if (removed &&
250     - driver->err_handler &&
251     - driver->err_handler->error_detected &&
252     - driver->err_handler->slot_reset)
253     + if (removed) {
254     + if (eeh_pe_passed(edev->pe))
255     return NULL;
256     + driver = eeh_pcid_get(dev);
257     + if (driver) {
258     + if (driver->err_handler &&
259     + driver->err_handler->error_detected &&
260     + driver->err_handler->slot_reset) {
261     + eeh_pcid_put(dev);
262     + return NULL;
263     + }
264     + eeh_pcid_put(dev);
265     + }
266     }
267    
268     /* Remove it from PCI subsystem */
269     diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
270     index fb133a163263..2274be535dda 100644
271     --- a/arch/powerpc/kernel/head_8xx.S
272     +++ b/arch/powerpc/kernel/head_8xx.S
273     @@ -769,7 +769,7 @@ start_here:
274     tovirt(r6,r6)
275     lis r5, abatron_pteptrs@h
276     ori r5, r5, abatron_pteptrs@l
277     - stw r5, 0xf0(r0) /* Must match your Abatron config file */
278     + stw r5, 0xf0(0) /* Must match your Abatron config file */
279     tophys(r5,r5)
280     stw r6, 0(r5)
281    
282     diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
283     index 678f87a63645..97b02b8c4f10 100644
284     --- a/arch/powerpc/kernel/pci_32.c
285     +++ b/arch/powerpc/kernel/pci_32.c
286     @@ -11,6 +11,7 @@
287     #include <linux/sched.h>
288     #include <linux/errno.h>
289     #include <linux/bootmem.h>
290     +#include <linux/syscalls.h>
291     #include <linux/irq.h>
292     #include <linux/list.h>
293     #include <linux/of.h>
294     diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
295     index 48fc28bab544..64c9a91773af 100644
296     --- a/arch/powerpc/mm/slb.c
297     +++ b/arch/powerpc/mm/slb.c
298     @@ -68,14 +68,14 @@ static inline void slb_shadow_update(unsigned long ea, int ssize,
299     * updating it. No write barriers are needed here, provided
300     * we only update the current CPU's SLB shadow buffer.
301     */
302     - p->save_area[index].esid = 0;
303     - p->save_area[index].vsid = cpu_to_be64(mk_vsid_data(ea, ssize, flags));
304     - p->save_area[index].esid = cpu_to_be64(mk_esid_data(ea, ssize, index));
305     + WRITE_ONCE(p->save_area[index].esid, 0);
306     + WRITE_ONCE(p->save_area[index].vsid, cpu_to_be64(mk_vsid_data(ea, ssize, flags)));
307     + WRITE_ONCE(p->save_area[index].esid, cpu_to_be64(mk_esid_data(ea, ssize, index)));
308     }
309    
310     static inline void slb_shadow_clear(enum slb_index index)
311     {
312     - get_slb_shadow()->save_area[index].esid = 0;
313     + WRITE_ONCE(get_slb_shadow()->save_area[index].esid, 0);
314     }
315    
316     static inline void create_shadowed_slbe(unsigned long ea, int ssize,
317     diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
318     index be9d968244ad..c0e817f35e69 100644
319     --- a/arch/powerpc/net/bpf_jit_comp64.c
320     +++ b/arch/powerpc/net/bpf_jit_comp64.c
321     @@ -207,25 +207,37 @@ static void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx)
322    
323     static void bpf_jit_emit_func_call(u32 *image, struct codegen_context *ctx, u64 func)
324     {
325     + unsigned int i, ctx_idx = ctx->idx;
326     +
327     + /* Load function address into r12 */
328     + PPC_LI64(12, func);
329     +
330     + /* For bpf-to-bpf function calls, the callee's address is unknown
331     + * until the last extra pass. As seen above, we use PPC_LI64() to
332     + * load the callee's address, but this may optimize the number of
333     + * instructions required based on the nature of the address.
334     + *
335     + * Since we don't want the number of instructions emitted to change,
336     + * we pad the optimized PPC_LI64() call with NOPs to guarantee that
337     + * we always have a five-instruction sequence, which is the maximum
338     + * that PPC_LI64() can emit.
339     + */
340     + for (i = ctx->idx - ctx_idx; i < 5; i++)
341     + PPC_NOP();
342     +
343     #ifdef PPC64_ELF_ABI_v1
344     - /* func points to the function descriptor */
345     - PPC_LI64(b2p[TMP_REG_2], func);
346     - /* Load actual entry point from function descriptor */
347     - PPC_BPF_LL(b2p[TMP_REG_1], b2p[TMP_REG_2], 0);
348     - /* ... and move it to LR */
349     - PPC_MTLR(b2p[TMP_REG_1]);
350     /*
351     * Load TOC from function descriptor at offset 8.
352     * We can clobber r2 since we get called through a
353     * function pointer (so caller will save/restore r2)
354     * and since we don't use a TOC ourself.
355     */
356     - PPC_BPF_LL(2, b2p[TMP_REG_2], 8);
357     -#else
358     - /* We can clobber r12 */
359     - PPC_FUNC_ADDR(12, func);
360     - PPC_MTLR(12);
361     + PPC_BPF_LL(2, 12, 8);
362     + /* Load actual entry point from function descriptor */
363     + PPC_BPF_LL(12, 12, 0);
364     #endif
365     +
366     + PPC_MTLR(12);
367     PPC_BLRL();
368     }
369    
370     diff --git a/arch/powerpc/platforms/chrp/time.c b/arch/powerpc/platforms/chrp/time.c
371     index f803f4b8ab6f..8608e358217f 100644
372     --- a/arch/powerpc/platforms/chrp/time.c
373     +++ b/arch/powerpc/platforms/chrp/time.c
374     @@ -27,6 +27,8 @@
375     #include <asm/sections.h>
376     #include <asm/time.h>
377    
378     +#include <platforms/chrp/chrp.h>
379     +
380     extern spinlock_t rtc_lock;
381    
382     #define NVRAM_AS0 0x74
383     @@ -62,7 +64,7 @@ long __init chrp_time_init(void)
384     return 0;
385     }
386    
387     -int chrp_cmos_clock_read(int addr)
388     +static int chrp_cmos_clock_read(int addr)
389     {
390     if (nvram_as1 != 0)
391     outb(addr>>8, nvram_as1);
392     @@ -70,7 +72,7 @@ int chrp_cmos_clock_read(int addr)
393     return (inb(nvram_data));
394     }
395    
396     -void chrp_cmos_clock_write(unsigned long val, int addr)
397     +static void chrp_cmos_clock_write(unsigned long val, int addr)
398     {
399     if (nvram_as1 != 0)
400     outb(addr>>8, nvram_as1);
401     diff --git a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
402     index 89c54de88b7a..bf4a125faec6 100644
403     --- a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
404     +++ b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
405     @@ -35,6 +35,8 @@
406     */
407     #define HW_BROADWAY_ICR 0x00
408     #define HW_BROADWAY_IMR 0x04
409     +#define HW_STARLET_ICR 0x08
410     +#define HW_STARLET_IMR 0x0c
411    
412    
413     /*
414     @@ -74,6 +76,9 @@ static void hlwd_pic_unmask(struct irq_data *d)
415     void __iomem *io_base = irq_data_get_irq_chip_data(d);
416    
417     setbits32(io_base + HW_BROADWAY_IMR, 1 << irq);
418     +
419     + /* Make sure the ARM (aka. Starlet) doesn't handle this interrupt. */
420     + clrbits32(io_base + HW_STARLET_IMR, 1 << irq);
421     }
422    
423    
424     diff --git a/arch/powerpc/platforms/powermac/bootx_init.c b/arch/powerpc/platforms/powermac/bootx_init.c
425     index c3c9bbb3573a..ba0964c17620 100644
426     --- a/arch/powerpc/platforms/powermac/bootx_init.c
427     +++ b/arch/powerpc/platforms/powermac/bootx_init.c
428     @@ -468,7 +468,7 @@ void __init bootx_init(unsigned long r3, unsigned long r4)
429     boot_infos_t *bi = (boot_infos_t *) r4;
430     unsigned long hdr;
431     unsigned long space;
432     - unsigned long ptr, x;
433     + unsigned long ptr;
434     char *model;
435     unsigned long offset = reloc_offset();
436    
437     @@ -562,6 +562,8 @@ void __init bootx_init(unsigned long r3, unsigned long r4)
438     * MMU switched OFF, so this should not be useful anymore.
439     */
440     if (bi->version < 4) {
441     + unsigned long x __maybe_unused;
442     +
443     bootx_printf("Touching pages...\n");
444    
445     /*
446     diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
447     index 6b4e9d181126..4929dd4b165e 100644
448     --- a/arch/powerpc/platforms/powermac/setup.c
449     +++ b/arch/powerpc/platforms/powermac/setup.c
450     @@ -352,6 +352,7 @@ static int pmac_late_init(void)
451     }
452     machine_late_initcall(powermac, pmac_late_init);
453    
454     +void note_bootable_part(dev_t dev, int part, int goodness);
455     /*
456     * This is __ref because we check for "initializing" before
457     * touching any of the __init sensitive things and "initializing"
458     diff --git a/arch/s390/include/asm/cpu_mf.h b/arch/s390/include/asm/cpu_mf.h
459     index 03516476127b..ee64e624c511 100644
460     --- a/arch/s390/include/asm/cpu_mf.h
461     +++ b/arch/s390/include/asm/cpu_mf.h
462     @@ -113,7 +113,7 @@ struct hws_basic_entry {
463    
464     struct hws_diag_entry {
465     unsigned int def:16; /* 0-15 Data Entry Format */
466     - unsigned int R:14; /* 16-19 and 20-30 reserved */
467     + unsigned int R:15; /* 16-19 and 20-30 reserved */
468     unsigned int I:1; /* 31 entry valid or invalid */
469     u8 data[]; /* Machine-dependent sample data */
470     } __packed;
471     @@ -129,7 +129,9 @@ struct hws_trailer_entry {
472     unsigned int f:1; /* 0 - Block Full Indicator */
473     unsigned int a:1; /* 1 - Alert request control */
474     unsigned int t:1; /* 2 - Timestamp format */
475     - unsigned long long:61; /* 3 - 63: Reserved */
476     + unsigned int :29; /* 3 - 31: Reserved */
477     + unsigned int bsdes:16; /* 32-47: size of basic SDE */
478     + unsigned int dsdes:16; /* 48-63: size of diagnostic SDE */
479     };
480     unsigned long long flags; /* 0 - 63: All indicators */
481     };
482     diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
483     index aec6cc925af8..4f365267b12f 100644
484     --- a/arch/x86/events/intel/uncore.c
485     +++ b/arch/x86/events/intel/uncore.c
486     @@ -212,7 +212,7 @@ void uncore_perf_event_update(struct intel_uncore_box *box, struct perf_event *e
487     u64 prev_count, new_count, delta;
488     int shift;
489    
490     - if (event->hw.idx >= UNCORE_PMC_IDX_FIXED)
491     + if (event->hw.idx == UNCORE_PMC_IDX_FIXED)
492     shift = 64 - uncore_fixed_ctr_bits(box);
493     else
494     shift = 64 - uncore_perf_ctr_bits(box);
495     diff --git a/arch/x86/events/intel/uncore_nhmex.c b/arch/x86/events/intel/uncore_nhmex.c
496     index cda569332005..83e2188adac4 100644
497     --- a/arch/x86/events/intel/uncore_nhmex.c
498     +++ b/arch/x86/events/intel/uncore_nhmex.c
499     @@ -245,7 +245,7 @@ static void nhmex_uncore_msr_enable_event(struct intel_uncore_box *box, struct p
500     {
501     struct hw_perf_event *hwc = &event->hw;
502    
503     - if (hwc->idx >= UNCORE_PMC_IDX_FIXED)
504     + if (hwc->idx == UNCORE_PMC_IDX_FIXED)
505     wrmsrl(hwc->config_base, NHMEX_PMON_CTL_EN_BIT0);
506     else if (box->pmu->type->event_mask & NHMEX_PMON_CTL_EN_BIT0)
507     wrmsrl(hwc->config_base, hwc->config | NHMEX_PMON_CTL_EN_BIT22);
508     diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
509     index a16c06604a56..8a4d6bc8fed0 100644
510     --- a/arch/x86/kvm/mmu.c
511     +++ b/arch/x86/kvm/mmu.c
512     @@ -698,7 +698,7 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
513     if (cache->nobjs >= min)
514     return 0;
515     while (cache->nobjs < ARRAY_SIZE(cache->objects)) {
516     - page = (void *)__get_free_page(GFP_KERNEL);
517     + page = (void *)__get_free_page(GFP_KERNEL_ACCOUNT);
518     if (!page)
519     return -ENOMEM;
520     cache->objects[cache->nobjs++] = page;
521     diff --git a/crypto/authenc.c b/crypto/authenc.c
522     index a7e1ac786c5d..c3180eb6d1ee 100644
523     --- a/crypto/authenc.c
524     +++ b/crypto/authenc.c
525     @@ -108,6 +108,7 @@ static int crypto_authenc_setkey(struct crypto_aead *authenc, const u8 *key,
526     CRYPTO_TFM_RES_MASK);
527    
528     out:
529     + memzero_explicit(&keys, sizeof(keys));
530     return err;
531    
532     badkey:
533     diff --git a/crypto/authencesn.c b/crypto/authencesn.c
534     index 18c94e1c31d1..49e7e85a23d5 100644
535     --- a/crypto/authencesn.c
536     +++ b/crypto/authencesn.c
537     @@ -90,6 +90,7 @@ static int crypto_authenc_esn_setkey(struct crypto_aead *authenc_esn, const u8 *
538     CRYPTO_TFM_RES_MASK);
539    
540     out:
541     + memzero_explicit(&keys, sizeof(keys));
542     return err;
543    
544     badkey:
545     diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
546     index bf601d4df8cf..b66815f35be6 100644
547     --- a/drivers/acpi/pci_root.c
548     +++ b/drivers/acpi/pci_root.c
549     @@ -472,9 +472,11 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm)
550     }
551    
552     control = OSC_PCI_EXPRESS_CAPABILITY_CONTROL
553     - | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
554     | OSC_PCI_EXPRESS_PME_CONTROL;
555    
556     + if (IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))
557     + control |= OSC_PCI_EXPRESS_NATIVE_HP_CONTROL;
558     +
559     if (pci_aer_available()) {
560     if (aer_acpi_firmware_first())
561     dev_info(&device->dev,
562     diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
563     index 6475a1343483..90c38778bc1f 100644
564     --- a/drivers/ata/libata-eh.c
565     +++ b/drivers/ata/libata-eh.c
566     @@ -2282,12 +2282,16 @@ static void ata_eh_link_autopsy(struct ata_link *link)
567     if (qc->err_mask & ~AC_ERR_OTHER)
568     qc->err_mask &= ~AC_ERR_OTHER;
569    
570     - /* SENSE_VALID trumps dev/unknown error and revalidation */
571     + /*
572     + * SENSE_VALID trumps dev/unknown error and revalidation. Upper
573     + * layers will determine whether the command is worth retrying
574     + * based on the sense data and device class/type. Otherwise,
575     + * determine directly if the command is worth retrying using its
576     + * error mask and flags.
577     + */
578     if (qc->flags & ATA_QCFLAG_SENSE_VALID)
579     qc->err_mask &= ~(AC_ERR_DEV | AC_ERR_OTHER);
580     -
581     - /* determine whether the command is worth retrying */
582     - if (ata_eh_worth_retry(qc))
583     + else if (ata_eh_worth_retry(qc))
584     qc->flags |= ATA_QCFLAG_RETRY;
585    
586     /* accumulate error info */
587     diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
588     index bff67c5a5fe7..44bccb1afa06 100644
589     --- a/drivers/bluetooth/btusb.c
590     +++ b/drivers/bluetooth/btusb.c
591     @@ -348,6 +348,9 @@ static const struct usb_device_id blacklist_table[] = {
592     /* Additional Realtek 8723BU Bluetooth devices */
593     { USB_DEVICE(0x7392, 0xa611), .driver_info = BTUSB_REALTEK },
594    
595     + /* Additional Realtek 8723DE Bluetooth devices */
596     + { USB_DEVICE(0x2ff8, 0xb011), .driver_info = BTUSB_REALTEK },
597     +
598     /* Additional Realtek 8821AE Bluetooth devices */
599     { USB_DEVICE(0x0b05, 0x17dc), .driver_info = BTUSB_REALTEK },
600     { USB_DEVICE(0x13d3, 0x3414), .driver_info = BTUSB_REALTEK },
601     diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
602     index 3a8b9aef96a6..0986c324459f 100644
603     --- a/drivers/bluetooth/hci_qca.c
604     +++ b/drivers/bluetooth/hci_qca.c
605     @@ -884,7 +884,7 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
606     */
607     set_current_state(TASK_UNINTERRUPTIBLE);
608     schedule_timeout(msecs_to_jiffies(BAUDRATE_SETTLE_TIMEOUT_MS));
609     - set_current_state(TASK_INTERRUPTIBLE);
610     + set_current_state(TASK_RUNNING);
611    
612     return 0;
613     }
614     diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c
615     index 45d7ecc66b22..4e9e9e618c9f 100644
616     --- a/drivers/bus/arm-ccn.c
617     +++ b/drivers/bus/arm-ccn.c
618     @@ -736,7 +736,7 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
619     ccn = pmu_to_arm_ccn(event->pmu);
620    
621     if (hw->sample_period) {
622     - dev_warn(ccn->dev, "Sampling not supported!\n");
623     + dev_dbg(ccn->dev, "Sampling not supported!\n");
624     return -EOPNOTSUPP;
625     }
626    
627     @@ -744,12 +744,12 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
628     event->attr.exclude_kernel || event->attr.exclude_hv ||
629     event->attr.exclude_idle || event->attr.exclude_host ||
630     event->attr.exclude_guest) {
631     - dev_warn(ccn->dev, "Can't exclude execution levels!\n");
632     + dev_dbg(ccn->dev, "Can't exclude execution levels!\n");
633     return -EINVAL;
634     }
635    
636     if (event->cpu < 0) {
637     - dev_warn(ccn->dev, "Can't provide per-task data!\n");
638     + dev_dbg(ccn->dev, "Can't provide per-task data!\n");
639     return -EOPNOTSUPP;
640     }
641     /*
642     @@ -771,13 +771,13 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
643     switch (type) {
644     case CCN_TYPE_MN:
645     if (node_xp != ccn->mn_id) {
646     - dev_warn(ccn->dev, "Invalid MN ID %d!\n", node_xp);
647     + dev_dbg(ccn->dev, "Invalid MN ID %d!\n", node_xp);
648     return -EINVAL;
649     }
650     break;
651     case CCN_TYPE_XP:
652     if (node_xp >= ccn->num_xps) {
653     - dev_warn(ccn->dev, "Invalid XP ID %d!\n", node_xp);
654     + dev_dbg(ccn->dev, "Invalid XP ID %d!\n", node_xp);
655     return -EINVAL;
656     }
657     break;
658     @@ -785,11 +785,11 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
659     break;
660     default:
661     if (node_xp >= ccn->num_nodes) {
662     - dev_warn(ccn->dev, "Invalid node ID %d!\n", node_xp);
663     + dev_dbg(ccn->dev, "Invalid node ID %d!\n", node_xp);
664     return -EINVAL;
665     }
666     if (!arm_ccn_pmu_type_eq(type, ccn->node[node_xp].type)) {
667     - dev_warn(ccn->dev, "Invalid type 0x%x for node %d!\n",
668     + dev_dbg(ccn->dev, "Invalid type 0x%x for node %d!\n",
669     type, node_xp);
670     return -EINVAL;
671     }
672     @@ -808,19 +808,19 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
673     if (event_id != e->event)
674     continue;
675     if (e->num_ports && port >= e->num_ports) {
676     - dev_warn(ccn->dev, "Invalid port %d for node/XP %d!\n",
677     + dev_dbg(ccn->dev, "Invalid port %d for node/XP %d!\n",
678     port, node_xp);
679     return -EINVAL;
680     }
681     if (e->num_vcs && vc >= e->num_vcs) {
682     - dev_warn(ccn->dev, "Invalid vc %d for node/XP %d!\n",
683     + dev_dbg(ccn->dev, "Invalid vc %d for node/XP %d!\n",
684     vc, node_xp);
685     return -EINVAL;
686     }
687     valid = 1;
688     }
689     if (!valid) {
690     - dev_warn(ccn->dev, "Invalid event 0x%x for node/XP %d!\n",
691     + dev_dbg(ccn->dev, "Invalid event 0x%x for node/XP %d!\n",
692     event_id, node_xp);
693     return -EINVAL;
694     }
695     diff --git a/drivers/char/random.c b/drivers/char/random.c
696     index ddeac4eefd0a..81b65d0e7563 100644
697     --- a/drivers/char/random.c
698     +++ b/drivers/char/random.c
699     @@ -1826,14 +1826,22 @@ static int
700     write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
701     {
702     size_t bytes;
703     - __u32 buf[16];
704     + __u32 t, buf[16];
705     const char __user *p = buffer;
706    
707     while (count > 0) {
708     + int b, i = 0;
709     +
710     bytes = min(count, sizeof(buf));
711     if (copy_from_user(&buf, p, bytes))
712     return -EFAULT;
713    
714     + for (b = bytes ; b > 0 ; b -= sizeof(__u32), i++) {
715     + if (!arch_get_random_int(&t))
716     + break;
717     + buf[i] ^= t;
718     + }
719     +
720     count -= bytes;
721     p += bytes;
722    
723     diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
724     index 61262a7a5c3a..b0bd0f64d8f2 100644
725     --- a/drivers/edac/altera_edac.c
726     +++ b/drivers/edac/altera_edac.c
727     @@ -1111,7 +1111,7 @@ static void *ocram_alloc_mem(size_t size, void **other)
728    
729     static void ocram_free_mem(void *p, size_t size, void *other)
730     {
731     - gen_pool_free((struct gen_pool *)other, (u32)p, size);
732     + gen_pool_free((struct gen_pool *)other, (unsigned long)p, size);
733     }
734    
735     static const struct edac_device_prv_data ocramecc_data = {
736     diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
737     index 34adde169a78..dd6fff1c98d6 100644
738     --- a/drivers/gpu/drm/drm_atomic.c
739     +++ b/drivers/gpu/drm/drm_atomic.c
740     @@ -1091,7 +1091,9 @@ drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
741     {
742     struct drm_plane *plane = plane_state->plane;
743     struct drm_crtc_state *crtc_state;
744     -
745     + /* Nothing to do for same crtc*/
746     + if (plane_state->crtc == crtc)
747     + return 0;
748     if (plane_state->crtc) {
749     crtc_state = drm_atomic_get_crtc_state(plane_state->state,
750     plane_state->crtc);
751     diff --git a/drivers/gpu/drm/gma500/psb_intel_drv.h b/drivers/gpu/drm/gma500/psb_intel_drv.h
752     index 2a3b7c684db2..fbd3fa340c4f 100644
753     --- a/drivers/gpu/drm/gma500/psb_intel_drv.h
754     +++ b/drivers/gpu/drm/gma500/psb_intel_drv.h
755     @@ -255,7 +255,7 @@ extern int intelfb_remove(struct drm_device *dev,
756     extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
757     const struct drm_display_mode *mode,
758     struct drm_display_mode *adjusted_mode);
759     -extern int psb_intel_lvds_mode_valid(struct drm_connector *connector,
760     +extern enum drm_mode_status psb_intel_lvds_mode_valid(struct drm_connector *connector,
761     struct drm_display_mode *mode);
762     extern int psb_intel_lvds_set_property(struct drm_connector *connector,
763     struct drm_property *property,
764     diff --git a/drivers/gpu/drm/gma500/psb_intel_lvds.c b/drivers/gpu/drm/gma500/psb_intel_lvds.c
765     index 79e9d3690667..e2c6ba3eded4 100644
766     --- a/drivers/gpu/drm/gma500/psb_intel_lvds.c
767     +++ b/drivers/gpu/drm/gma500/psb_intel_lvds.c
768     @@ -343,7 +343,7 @@ static void psb_intel_lvds_restore(struct drm_connector *connector)
769     }
770     }
771    
772     -int psb_intel_lvds_mode_valid(struct drm_connector *connector,
773     +enum drm_mode_status psb_intel_lvds_mode_valid(struct drm_connector *connector,
774     struct drm_display_mode *mode)
775     {
776     struct drm_psb_private *dev_priv = connector->dev->dev_private;
777     diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
778     index f416f5c2e8e9..c5e1aa5f1d8e 100644
779     --- a/drivers/gpu/drm/radeon/radeon_connectors.c
780     +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
781     @@ -850,7 +850,7 @@ static int radeon_lvds_get_modes(struct drm_connector *connector)
782     return ret;
783     }
784    
785     -static int radeon_lvds_mode_valid(struct drm_connector *connector,
786     +static enum drm_mode_status radeon_lvds_mode_valid(struct drm_connector *connector,
787     struct drm_display_mode *mode)
788     {
789     struct drm_encoder *encoder = radeon_best_single_encoder(connector);
790     @@ -1010,7 +1010,7 @@ static int radeon_vga_get_modes(struct drm_connector *connector)
791     return ret;
792     }
793    
794     -static int radeon_vga_mode_valid(struct drm_connector *connector,
795     +static enum drm_mode_status radeon_vga_mode_valid(struct drm_connector *connector,
796     struct drm_display_mode *mode)
797     {
798     struct drm_device *dev = connector->dev;
799     @@ -1154,7 +1154,7 @@ static int radeon_tv_get_modes(struct drm_connector *connector)
800     return 1;
801     }
802    
803     -static int radeon_tv_mode_valid(struct drm_connector *connector,
804     +static enum drm_mode_status radeon_tv_mode_valid(struct drm_connector *connector,
805     struct drm_display_mode *mode)
806     {
807     if ((mode->hdisplay > 1024) || (mode->vdisplay > 768))
808     @@ -1496,7 +1496,7 @@ static void radeon_dvi_force(struct drm_connector *connector)
809     radeon_connector->use_digital = true;
810     }
811    
812     -static int radeon_dvi_mode_valid(struct drm_connector *connector,
813     +static enum drm_mode_status radeon_dvi_mode_valid(struct drm_connector *connector,
814     struct drm_display_mode *mode)
815     {
816     struct drm_device *dev = connector->dev;
817     @@ -1798,7 +1798,7 @@ out:
818     return ret;
819     }
820    
821     -static int radeon_dp_mode_valid(struct drm_connector *connector,
822     +static enum drm_mode_status radeon_dp_mode_valid(struct drm_connector *connector,
823     struct drm_display_mode *mode)
824     {
825     struct drm_device *dev = connector->dev;
826     diff --git a/drivers/hid/hid-plantronics.c b/drivers/hid/hid-plantronics.c
827     index febb21ee190e..584b10d3fc3d 100644
828     --- a/drivers/hid/hid-plantronics.c
829     +++ b/drivers/hid/hid-plantronics.c
830     @@ -2,7 +2,7 @@
831     * Plantronics USB HID Driver
832     *
833     * Copyright (c) 2014 JD Cole <jd.cole@plantronics.com>
834     - * Copyright (c) 2015 Terry Junge <terry.junge@plantronics.com>
835     + * Copyright (c) 2015-2018 Terry Junge <terry.junge@plantronics.com>
836     */
837    
838     /*
839     @@ -48,6 +48,10 @@ static int plantronics_input_mapping(struct hid_device *hdev,
840     unsigned short mapped_key;
841     unsigned long plt_type = (unsigned long)hid_get_drvdata(hdev);
842    
843     + /* special case for PTT products */
844     + if (field->application == HID_GD_JOYSTICK)
845     + goto defaulted;
846     +
847     /* handle volume up/down mapping */
848     /* non-standard types or multi-HID interfaces - plt_type is PID */
849     if (!(plt_type & HID_USAGE_PAGE)) {
850     diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
851     index 00bce002b357..ce2b80009c19 100644
852     --- a/drivers/hid/i2c-hid/i2c-hid.c
853     +++ b/drivers/hid/i2c-hid/i2c-hid.c
854     @@ -1101,6 +1101,14 @@ static int i2c_hid_probe(struct i2c_client *client,
855     pm_runtime_enable(&client->dev);
856     device_enable_async_suspend(&client->dev);
857    
858     + /* Make sure there is something at this address */
859     + ret = i2c_smbus_read_byte(client);
860     + if (ret < 0) {
861     + dev_dbg(&client->dev, "nothing at this address: %d\n", ret);
862     + ret = -ENXIO;
863     + goto err_pm;
864     + }
865     +
866     ret = i2c_hid_fetch_hid_descriptor(ihid);
867     if (ret < 0)
868     goto err_pm;
869     diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
870     index 2395fe2021c9..3e2ab04201e2 100644
871     --- a/drivers/infiniband/core/mad.c
872     +++ b/drivers/infiniband/core/mad.c
873     @@ -1549,7 +1549,8 @@ static int add_oui_reg_req(struct ib_mad_reg_req *mad_reg_req,
874     mad_reg_req->oui, 3)) {
875     method = &(*vendor_table)->vendor_class[
876     vclass]->method_table[i];
877     - BUG_ON(!*method);
878     + if (!*method)
879     + goto error3;
880     goto check_in_use;
881     }
882     }
883     @@ -1559,10 +1560,12 @@ static int add_oui_reg_req(struct ib_mad_reg_req *mad_reg_req,
884     vclass]->oui[i])) {
885     method = &(*vendor_table)->vendor_class[
886     vclass]->method_table[i];
887     - BUG_ON(*method);
888     /* Allocate method table for this OUI */
889     - if ((ret = allocate_method_table(method)))
890     - goto error3;
891     + if (!*method) {
892     + ret = allocate_method_table(method);
893     + if (ret)
894     + goto error3;
895     + }
896     memcpy((*vendor_table)->vendor_class[vclass]->oui[i],
897     mad_reg_req->oui, 3);
898     goto check_in_use;
899     diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
900     index a036d7087ddf..3bef6d4ffe6f 100644
901     --- a/drivers/infiniband/core/ucma.c
902     +++ b/drivers/infiniband/core/ucma.c
903     @@ -218,7 +218,7 @@ static struct ucma_multicast* ucma_alloc_multicast(struct ucma_context *ctx)
904     return NULL;
905    
906     mutex_lock(&mut);
907     - mc->id = idr_alloc(&multicast_idr, mc, 0, 0, GFP_KERNEL);
908     + mc->id = idr_alloc(&multicast_idr, NULL, 0, 0, GFP_KERNEL);
909     mutex_unlock(&mut);
910     if (mc->id < 0)
911     goto error;
912     @@ -1385,6 +1385,10 @@ static ssize_t ucma_process_join(struct ucma_file *file,
913     goto err3;
914     }
915    
916     + mutex_lock(&mut);
917     + idr_replace(&multicast_idr, mc, mc->id);
918     + mutex_unlock(&mut);
919     +
920     mutex_unlock(&file->mut);
921     ucma_put_ctx(ctx);
922     return 0;
923     diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
924     index 4b717cf50d27..6f875bf9cc9d 100644
925     --- a/drivers/infiniband/core/uverbs_cmd.c
926     +++ b/drivers/infiniband/core/uverbs_cmd.c
927     @@ -3725,6 +3725,11 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
928     goto err_uobj;
929     }
930    
931     + if (qp->qp_type != IB_QPT_UD && qp->qp_type != IB_QPT_RAW_PACKET) {
932     + err = -EINVAL;
933     + goto err_put;
934     + }
935     +
936     flow_attr = kzalloc(sizeof(*flow_attr) + cmd.flow_attr.num_of_specs *
937     sizeof(union ib_flow_spec), GFP_KERNEL);
938     if (!flow_attr) {
939     diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
940     index 97f6e05cffce..a716482774db 100644
941     --- a/drivers/input/mouse/elan_i2c_core.c
942     +++ b/drivers/input/mouse/elan_i2c_core.c
943     @@ -1251,6 +1251,8 @@ static const struct acpi_device_id elan_acpi_id[] = {
944     { "ELAN0611", 0 },
945     { "ELAN0612", 0 },
946     { "ELAN0618", 0 },
947     + { "ELAN061D", 0 },
948     + { "ELAN0622", 0 },
949     { "ELAN1000", 0 },
950     { }
951     };
952     diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
953     index e484ea2dc787..34be09651ee8 100644
954     --- a/drivers/input/serio/i8042-x86ia64io.h
955     +++ b/drivers/input/serio/i8042-x86ia64io.h
956     @@ -527,6 +527,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
957     DMI_MATCH(DMI_PRODUCT_NAME, "N24_25BU"),
958     },
959     },
960     + {
961     + /* Lenovo LaVie Z */
962     + .matches = {
963     + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
964     + DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo LaVie Z"),
965     + },
966     + },
967     { }
968     };
969    
970     diff --git a/drivers/md/md.c b/drivers/md/md.c
971     index 3bb985679f34..a7a0e3acdb2f 100644
972     --- a/drivers/md/md.c
973     +++ b/drivers/md/md.c
974     @@ -6192,6 +6192,9 @@ static int hot_remove_disk(struct mddev *mddev, dev_t dev)
975     char b[BDEVNAME_SIZE];
976     struct md_rdev *rdev;
977    
978     + if (!mddev->pers)
979     + return -ENODEV;
980     +
981     rdev = find_rdev(mddev, dev);
982     if (!rdev)
983     return -ENXIO;
984     diff --git a/drivers/media/common/siano/smsendian.c b/drivers/media/common/siano/smsendian.c
985     index bfe831c10b1c..b95a631f23f9 100644
986     --- a/drivers/media/common/siano/smsendian.c
987     +++ b/drivers/media/common/siano/smsendian.c
988     @@ -35,7 +35,7 @@ void smsendian_handle_tx_message(void *buffer)
989     switch (msg->x_msg_header.msg_type) {
990     case MSG_SMS_DATA_DOWNLOAD_REQ:
991     {
992     - msg->msg_data[0] = le32_to_cpu(msg->msg_data[0]);
993     + msg->msg_data[0] = le32_to_cpu((__force __le32)(msg->msg_data[0]));
994     break;
995     }
996    
997     @@ -44,7 +44,7 @@ void smsendian_handle_tx_message(void *buffer)
998     sizeof(struct sms_msg_hdr))/4;
999    
1000     for (i = 0; i < msg_words; i++)
1001     - msg->msg_data[i] = le32_to_cpu(msg->msg_data[i]);
1002     + msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
1003    
1004     break;
1005     }
1006     @@ -64,7 +64,7 @@ void smsendian_handle_rx_message(void *buffer)
1007     {
1008     struct sms_version_res *ver =
1009     (struct sms_version_res *) msg;
1010     - ver->chip_model = le16_to_cpu(ver->chip_model);
1011     + ver->chip_model = le16_to_cpu((__force __le16)ver->chip_model);
1012     break;
1013     }
1014    
1015     @@ -81,7 +81,7 @@ void smsendian_handle_rx_message(void *buffer)
1016     sizeof(struct sms_msg_hdr))/4;
1017    
1018     for (i = 0; i < msg_words; i++)
1019     - msg->msg_data[i] = le32_to_cpu(msg->msg_data[i]);
1020     + msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
1021    
1022     break;
1023     }
1024     @@ -95,9 +95,9 @@ void smsendian_handle_message_header(void *msg)
1025     #ifdef __BIG_ENDIAN
1026     struct sms_msg_hdr *phdr = (struct sms_msg_hdr *)msg;
1027    
1028     - phdr->msg_type = le16_to_cpu(phdr->msg_type);
1029     - phdr->msg_length = le16_to_cpu(phdr->msg_length);
1030     - phdr->msg_flags = le16_to_cpu(phdr->msg_flags);
1031     + phdr->msg_type = le16_to_cpu((__force __le16)phdr->msg_type);
1032     + phdr->msg_length = le16_to_cpu((__force __le16)phdr->msg_length);
1033     + phdr->msg_flags = le16_to_cpu((__force __le16)phdr->msg_flags);
1034     #endif /* __BIG_ENDIAN */
1035     }
1036     EXPORT_SYMBOL_GPL(smsendian_handle_message_header);
1037     diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
1038     index 44f8c7e10a35..8ffa13f39a86 100644
1039     --- a/drivers/media/i2c/smiapp/smiapp-core.c
1040     +++ b/drivers/media/i2c/smiapp/smiapp-core.c
1041     @@ -991,7 +991,7 @@ static int smiapp_read_nvm(struct smiapp_sensor *sensor,
1042     if (rval)
1043     goto out;
1044    
1045     - for (i = 0; i < 1000; i++) {
1046     + for (i = 1000; i > 0; i--) {
1047     rval = smiapp_read(
1048     sensor,
1049     SMIAPP_REG_U8_DATA_TRANSFER_IF_1_STATUS, &s);
1050     @@ -1002,11 +1002,10 @@ static int smiapp_read_nvm(struct smiapp_sensor *sensor,
1051     if (s & SMIAPP_DATA_TRANSFER_IF_1_STATUS_RD_READY)
1052     break;
1053    
1054     - if (--i == 0) {
1055     - rval = -ETIMEDOUT;
1056     - goto out;
1057     - }
1058     -
1059     + }
1060     + if (!i) {
1061     + rval = -ETIMEDOUT;
1062     + goto out;
1063     }
1064    
1065     for (i = 0; i < SMIAPP_NVM_PAGE_SIZE; i++) {
1066     diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
1067     index 4462d8c69d57..6f46c59415fe 100644
1068     --- a/drivers/media/media-device.c
1069     +++ b/drivers/media/media-device.c
1070     @@ -58,9 +58,10 @@ static int media_device_close(struct file *filp)
1071     return 0;
1072     }
1073    
1074     -static int media_device_get_info(struct media_device *dev,
1075     - struct media_device_info *info)
1076     +static long media_device_get_info(struct media_device *dev, void *arg)
1077     {
1078     + struct media_device_info *info = arg;
1079     +
1080     memset(info, 0, sizeof(*info));
1081    
1082     if (dev->driver_name[0])
1083     @@ -97,9 +98,9 @@ static struct media_entity *find_entity(struct media_device *mdev, u32 id)
1084     return NULL;
1085     }
1086    
1087     -static long media_device_enum_entities(struct media_device *mdev,
1088     - struct media_entity_desc *entd)
1089     +static long media_device_enum_entities(struct media_device *mdev, void *arg)
1090     {
1091     + struct media_entity_desc *entd = arg;
1092     struct media_entity *ent;
1093    
1094     ent = find_entity(mdev, entd->id);
1095     @@ -150,9 +151,9 @@ static void media_device_kpad_to_upad(const struct media_pad *kpad,
1096     upad->flags = kpad->flags;
1097     }
1098    
1099     -static long media_device_enum_links(struct media_device *mdev,
1100     - struct media_links_enum *links)
1101     +static long media_device_enum_links(struct media_device *mdev, void *arg)
1102     {
1103     + struct media_links_enum *links = arg;
1104     struct media_entity *entity;
1105    
1106     entity = find_entity(mdev, links->entity);
1107     @@ -198,9 +199,9 @@ static long media_device_enum_links(struct media_device *mdev,
1108     return 0;
1109     }
1110    
1111     -static long media_device_setup_link(struct media_device *mdev,
1112     - struct media_link_desc *linkd)
1113     +static long media_device_setup_link(struct media_device *mdev, void *arg)
1114     {
1115     + struct media_link_desc *linkd = arg;
1116     struct media_link *link = NULL;
1117     struct media_entity *source;
1118     struct media_entity *sink;
1119     @@ -226,9 +227,9 @@ static long media_device_setup_link(struct media_device *mdev,
1120     return __media_entity_setup_link(link, linkd->flags);
1121     }
1122    
1123     -static long media_device_get_topology(struct media_device *mdev,
1124     - struct media_v2_topology *topo)
1125     +static long media_device_get_topology(struct media_device *mdev, void *arg)
1126     {
1127     + struct media_v2_topology *topo = arg;
1128     struct media_entity *entity;
1129     struct media_interface *intf;
1130     struct media_pad *pad;
1131     diff --git a/drivers/media/pci/saa7164/saa7164-fw.c b/drivers/media/pci/saa7164/saa7164-fw.c
1132     index 269e0782c7b6..93d53195e8ca 100644
1133     --- a/drivers/media/pci/saa7164/saa7164-fw.c
1134     +++ b/drivers/media/pci/saa7164/saa7164-fw.c
1135     @@ -430,7 +430,8 @@ int saa7164_downloadfirmware(struct saa7164_dev *dev)
1136     __func__, fw->size);
1137    
1138     if (fw->size != fwlength) {
1139     - printk(KERN_ERR "xc5000: firmware incorrect size\n");
1140     + printk(KERN_ERR "saa7164: firmware incorrect size %zu != %u\n",
1141     + fw->size, fwlength);
1142     ret = -ENOMEM;
1143     goto out;
1144     }
1145     diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c
1146     index c3fafa97b2d0..0ea8dd44026c 100644
1147     --- a/drivers/media/pci/tw686x/tw686x-video.c
1148     +++ b/drivers/media/pci/tw686x/tw686x-video.c
1149     @@ -1228,7 +1228,8 @@ int tw686x_video_init(struct tw686x_dev *dev)
1150     vc->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1151     vc->vidq.min_buffers_needed = 2;
1152     vc->vidq.lock = &vc->vb_mutex;
1153     - vc->vidq.gfp_flags = GFP_DMA32;
1154     + vc->vidq.gfp_flags = dev->dma_mode != TW686X_DMA_MODE_MEMCPY ?
1155     + GFP_DMA32 : 0;
1156     vc->vidq.dev = &dev->pci_dev->dev;
1157    
1158     err = vb2_queue_init(&vc->vidq);
1159     diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
1160     index 0321d84addc7..15a86bb4e61c 100644
1161     --- a/drivers/media/platform/omap3isp/isp.c
1162     +++ b/drivers/media/platform/omap3isp/isp.c
1163     @@ -1941,6 +1941,7 @@ error_csiphy:
1164    
1165     static void isp_detach_iommu(struct isp_device *isp)
1166     {
1167     + arm_iommu_detach_device(isp->dev);
1168     arm_iommu_release_mapping(isp->mapping);
1169     isp->mapping = NULL;
1170     iommu_group_remove_device(isp->dev);
1171     @@ -1974,8 +1975,7 @@ static int isp_attach_iommu(struct isp_device *isp)
1172     mapping = arm_iommu_create_mapping(&platform_bus_type, SZ_1G, SZ_2G);
1173     if (IS_ERR(mapping)) {
1174     dev_err(isp->dev, "failed to create ARM IOMMU mapping\n");
1175     - ret = PTR_ERR(mapping);
1176     - goto error;
1177     + return PTR_ERR(mapping);
1178     }
1179    
1180     isp->mapping = mapping;
1181     @@ -1990,7 +1990,8 @@ static int isp_attach_iommu(struct isp_device *isp)
1182     return 0;
1183    
1184     error:
1185     - isp_detach_iommu(isp);
1186     + arm_iommu_release_mapping(isp->mapping);
1187     + isp->mapping = NULL;
1188     return ret;
1189     }
1190    
1191     diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c
1192     index d1746ecc645d..db1110a492e0 100644
1193     --- a/drivers/media/platform/rcar_jpu.c
1194     +++ b/drivers/media/platform/rcar_jpu.c
1195     @@ -1280,7 +1280,7 @@ static int jpu_open(struct file *file)
1196     /* ...issue software reset */
1197     ret = jpu_reset(jpu);
1198     if (ret)
1199     - goto device_prepare_rollback;
1200     + goto jpu_reset_rollback;
1201     }
1202    
1203     jpu->ref_count++;
1204     @@ -1288,6 +1288,8 @@ static int jpu_open(struct file *file)
1205     mutex_unlock(&jpu->mutex);
1206     return 0;
1207    
1208     +jpu_reset_rollback:
1209     + clk_disable_unprepare(jpu->clk);
1210     device_prepare_rollback:
1211     mutex_unlock(&jpu->mutex);
1212     v4l_prepare_rollback:
1213     diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
1214     index ee0470a3196b..f218886c504d 100644
1215     --- a/drivers/media/radio/si470x/radio-si470x-i2c.c
1216     +++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
1217     @@ -96,7 +96,7 @@ MODULE_PARM_DESC(max_rds_errors, "RDS maximum block errors: *1*");
1218     */
1219     int si470x_get_register(struct si470x_device *radio, int regnr)
1220     {
1221     - u16 buf[READ_REG_NUM];
1222     + __be16 buf[READ_REG_NUM];
1223     struct i2c_msg msgs[1] = {
1224     {
1225     .addr = radio->client->addr,
1226     @@ -121,7 +121,7 @@ int si470x_get_register(struct si470x_device *radio, int regnr)
1227     int si470x_set_register(struct si470x_device *radio, int regnr)
1228     {
1229     int i;
1230     - u16 buf[WRITE_REG_NUM];
1231     + __be16 buf[WRITE_REG_NUM];
1232     struct i2c_msg msgs[1] = {
1233     {
1234     .addr = radio->client->addr,
1235     @@ -151,7 +151,7 @@ int si470x_set_register(struct si470x_device *radio, int regnr)
1236     static int si470x_get_all_registers(struct si470x_device *radio)
1237     {
1238     int i;
1239     - u16 buf[READ_REG_NUM];
1240     + __be16 buf[READ_REG_NUM];
1241     struct i2c_msg msgs[1] = {
1242     {
1243     .addr = radio->client->addr,
1244     diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
1245     index 4299ce06c25b..b3a9fa75e8e7 100644
1246     --- a/drivers/media/v4l2-core/videobuf2-core.c
1247     +++ b/drivers/media/v4l2-core/videobuf2-core.c
1248     @@ -914,9 +914,12 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
1249     dprintk(4, "done processing on buffer %d, state: %d\n",
1250     vb->index, state);
1251    
1252     - /* sync buffers */
1253     - for (plane = 0; plane < vb->num_planes; ++plane)
1254     - call_void_memop(vb, finish, vb->planes[plane].mem_priv);
1255     + if (state != VB2_BUF_STATE_QUEUED &&
1256     + state != VB2_BUF_STATE_REQUEUEING) {
1257     + /* sync buffers */
1258     + for (plane = 0; plane < vb->num_planes; ++plane)
1259     + call_void_memop(vb, finish, vb->planes[plane].mem_priv);
1260     + }
1261    
1262     spin_lock_irqsave(&q->done_lock, flags);
1263     if (state == VB2_BUF_STATE_QUEUED ||
1264     diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
1265     index a4803ac192bb..1d49a8dd4a37 100644
1266     --- a/drivers/memory/tegra/mc.c
1267     +++ b/drivers/memory/tegra/mc.c
1268     @@ -20,14 +20,6 @@
1269     #include "mc.h"
1270    
1271     #define MC_INTSTATUS 0x000
1272     -#define MC_INT_DECERR_MTS (1 << 16)
1273     -#define MC_INT_SECERR_SEC (1 << 13)
1274     -#define MC_INT_DECERR_VPR (1 << 12)
1275     -#define MC_INT_INVALID_APB_ASID_UPDATE (1 << 11)
1276     -#define MC_INT_INVALID_SMMU_PAGE (1 << 10)
1277     -#define MC_INT_ARBITRATION_EMEM (1 << 9)
1278     -#define MC_INT_SECURITY_VIOLATION (1 << 8)
1279     -#define MC_INT_DECERR_EMEM (1 << 6)
1280    
1281     #define MC_INTMASK 0x004
1282    
1283     @@ -248,12 +240,13 @@ static const char *const error_names[8] = {
1284     static irqreturn_t tegra_mc_irq(int irq, void *data)
1285     {
1286     struct tegra_mc *mc = data;
1287     - unsigned long status, mask;
1288     + unsigned long status;
1289     unsigned int bit;
1290    
1291     /* mask all interrupts to avoid flooding */
1292     - status = mc_readl(mc, MC_INTSTATUS);
1293     - mask = mc_readl(mc, MC_INTMASK);
1294     + status = mc_readl(mc, MC_INTSTATUS) & mc->soc->intmask;
1295     + if (!status)
1296     + return IRQ_NONE;
1297    
1298     for_each_set_bit(bit, &status, 32) {
1299     const char *error = status_names[bit] ?: "unknown";
1300     @@ -346,7 +339,6 @@ static int tegra_mc_probe(struct platform_device *pdev)
1301     const struct of_device_id *match;
1302     struct resource *res;
1303     struct tegra_mc *mc;
1304     - u32 value;
1305     int err;
1306    
1307     match = of_match_node(tegra_mc_of_match, pdev->dev.of_node);
1308     @@ -414,11 +406,7 @@ static int tegra_mc_probe(struct platform_device *pdev)
1309    
1310     WARN(!mc->soc->client_id_mask, "Missing client ID mask for this SoC\n");
1311    
1312     - value = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
1313     - MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
1314     - MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM;
1315     -
1316     - mc_writel(mc, value, MC_INTMASK);
1317     + mc_writel(mc, mc->soc->intmask, MC_INTMASK);
1318    
1319     return 0;
1320     }
1321     diff --git a/drivers/memory/tegra/mc.h b/drivers/memory/tegra/mc.h
1322     index ddb16676c3af..24e020b4609b 100644
1323     --- a/drivers/memory/tegra/mc.h
1324     +++ b/drivers/memory/tegra/mc.h
1325     @@ -14,6 +14,15 @@
1326    
1327     #include <soc/tegra/mc.h>
1328    
1329     +#define MC_INT_DECERR_MTS (1 << 16)
1330     +#define MC_INT_SECERR_SEC (1 << 13)
1331     +#define MC_INT_DECERR_VPR (1 << 12)
1332     +#define MC_INT_INVALID_APB_ASID_UPDATE (1 << 11)
1333     +#define MC_INT_INVALID_SMMU_PAGE (1 << 10)
1334     +#define MC_INT_ARBITRATION_EMEM (1 << 9)
1335     +#define MC_INT_SECURITY_VIOLATION (1 << 8)
1336     +#define MC_INT_DECERR_EMEM (1 << 6)
1337     +
1338     static inline u32 mc_readl(struct tegra_mc *mc, unsigned long offset)
1339     {
1340     return readl(mc->regs + offset);
1341     diff --git a/drivers/memory/tegra/tegra114.c b/drivers/memory/tegra/tegra114.c
1342     index ba8fff3d66a6..6d2a5a849d92 100644
1343     --- a/drivers/memory/tegra/tegra114.c
1344     +++ b/drivers/memory/tegra/tegra114.c
1345     @@ -930,4 +930,6 @@ const struct tegra_mc_soc tegra114_mc_soc = {
1346     .atom_size = 32,
1347     .client_id_mask = 0x7f,
1348     .smmu = &tegra114_smmu_soc,
1349     + .intmask = MC_INT_INVALID_SMMU_PAGE | MC_INT_SECURITY_VIOLATION |
1350     + MC_INT_DECERR_EMEM,
1351     };
1352     diff --git a/drivers/memory/tegra/tegra124.c b/drivers/memory/tegra/tegra124.c
1353     index 5a58e440f4a7..9f68a56f2727 100644
1354     --- a/drivers/memory/tegra/tegra124.c
1355     +++ b/drivers/memory/tegra/tegra124.c
1356     @@ -1020,6 +1020,9 @@ const struct tegra_mc_soc tegra124_mc_soc = {
1357     .smmu = &tegra124_smmu_soc,
1358     .emem_regs = tegra124_mc_emem_regs,
1359     .num_emem_regs = ARRAY_SIZE(tegra124_mc_emem_regs),
1360     + .intmask = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
1361     + MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
1362     + MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM,
1363     };
1364     #endif /* CONFIG_ARCH_TEGRA_124_SOC */
1365    
1366     @@ -1042,5 +1045,8 @@ const struct tegra_mc_soc tegra132_mc_soc = {
1367     .atom_size = 32,
1368     .client_id_mask = 0x7f,
1369     .smmu = &tegra132_smmu_soc,
1370     + .intmask = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
1371     + MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
1372     + MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM,
1373     };
1374     #endif /* CONFIG_ARCH_TEGRA_132_SOC */
1375     diff --git a/drivers/memory/tegra/tegra210.c b/drivers/memory/tegra/tegra210.c
1376     index 5e144abe4c18..47c78a6d8f00 100644
1377     --- a/drivers/memory/tegra/tegra210.c
1378     +++ b/drivers/memory/tegra/tegra210.c
1379     @@ -1077,4 +1077,7 @@ const struct tegra_mc_soc tegra210_mc_soc = {
1380     .atom_size = 64,
1381     .client_id_mask = 0xff,
1382     .smmu = &tegra210_smmu_soc,
1383     + .intmask = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
1384     + MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
1385     + MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM,
1386     };
1387     diff --git a/drivers/memory/tegra/tegra30.c b/drivers/memory/tegra/tegra30.c
1388     index b44737840e70..d0689428ea1a 100644
1389     --- a/drivers/memory/tegra/tegra30.c
1390     +++ b/drivers/memory/tegra/tegra30.c
1391     @@ -952,4 +952,6 @@ const struct tegra_mc_soc tegra30_mc_soc = {
1392     .atom_size = 16,
1393     .client_id_mask = 0x7f,
1394     .smmu = &tegra30_smmu_soc,
1395     + .intmask = MC_INT_INVALID_SMMU_PAGE | MC_INT_SECURITY_VIOLATION |
1396     + MC_INT_DECERR_EMEM,
1397     };
1398     diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
1399     index abd83424b498..3e18d2595b6d 100644
1400     --- a/drivers/mfd/cros_ec.c
1401     +++ b/drivers/mfd/cros_ec.c
1402     @@ -86,7 +86,11 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
1403    
1404     mutex_init(&ec_dev->lock);
1405    
1406     - cros_ec_query_all(ec_dev);
1407     + err = cros_ec_query_all(ec_dev);
1408     + if (err) {
1409     + dev_err(dev, "Cannot identify the EC: error %d\n", err);
1410     + return err;
1411     + }
1412    
1413     if (ec_dev->irq) {
1414     err = request_threaded_irq(ec_dev->irq, NULL, ec_irq_thread,
1415     diff --git a/drivers/mmc/core/pwrseq_simple.c b/drivers/mmc/core/pwrseq_simple.c
1416     index 1304160de168..8cd9ddf1fab9 100644
1417     --- a/drivers/mmc/core/pwrseq_simple.c
1418     +++ b/drivers/mmc/core/pwrseq_simple.c
1419     @@ -39,14 +39,18 @@ static void mmc_pwrseq_simple_set_gpios_value(struct mmc_pwrseq_simple *pwrseq,
1420     struct gpio_descs *reset_gpios = pwrseq->reset_gpios;
1421    
1422     if (!IS_ERR(reset_gpios)) {
1423     - int i;
1424     - int values[reset_gpios->ndescs];
1425     + int i, *values;
1426     + int nvalues = reset_gpios->ndescs;
1427    
1428     - for (i = 0; i < reset_gpios->ndescs; i++)
1429     + values = kmalloc_array(nvalues, sizeof(int), GFP_KERNEL);
1430     + if (!values)
1431     + return;
1432     +
1433     + for (i = 0; i < nvalues; i++)
1434     values[i] = value;
1435    
1436     - gpiod_set_array_value_cansleep(
1437     - reset_gpios->ndescs, reset_gpios->desc, values);
1438     + gpiod_set_array_value_cansleep(nvalues, reset_gpios->desc, values);
1439     + kfree(values);
1440     }
1441     }
1442    
1443     diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
1444     index 1a1501fde010..e10a00d0d44d 100644
1445     --- a/drivers/mmc/host/dw_mmc.c
1446     +++ b/drivers/mmc/host/dw_mmc.c
1447     @@ -1164,6 +1164,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
1448     if (host->state == STATE_WAITING_CMD11_DONE)
1449     sdmmc_cmd_bits |= SDMMC_CMD_VOLT_SWITCH;
1450    
1451     + slot->mmc->actual_clock = 0;
1452     +
1453     if (!clock) {
1454     mci_writel(host, CLKENA, 0);
1455     mci_send_cmd(slot, sdmmc_cmd_bits, 0);
1456     @@ -1209,6 +1211,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
1457    
1458     /* keep the last clock value that was requested from core */
1459     slot->__clk_old = clock;
1460     + slot->mmc->actual_clock = div ? ((host->bus_hz / div) >> 1) :
1461     + host->bus_hz;
1462     }
1463    
1464     host->current_speed = clock;
1465     diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
1466     index 2f6b55229d5b..4c3b986dd74d 100644
1467     --- a/drivers/mtd/nand/fsl_ifc_nand.c
1468     +++ b/drivers/mtd/nand/fsl_ifc_nand.c
1469     @@ -372,9 +372,16 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command,
1470    
1471     case NAND_CMD_READID:
1472     case NAND_CMD_PARAM: {
1473     + /*
1474     + * For READID, read 8 bytes that are currently used.
1475     + * For PARAM, read all 3 copies of 256-bytes pages.
1476     + */
1477     + int len = 8;
1478     int timing = IFC_FIR_OP_RB;
1479     - if (command == NAND_CMD_PARAM)
1480     + if (command == NAND_CMD_PARAM) {
1481     timing = IFC_FIR_OP_RBCD;
1482     + len = 256 * 3;
1483     + }
1484    
1485     ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
1486     (IFC_FIR_OP_UA << IFC_NAND_FIR0_OP1_SHIFT) |
1487     @@ -384,12 +391,8 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command,
1488     &ifc->ifc_nand.nand_fcr0);
1489     ifc_out32(column, &ifc->ifc_nand.row3);
1490    
1491     - /*
1492     - * although currently it's 8 bytes for READID, we always read
1493     - * the maximum 256 bytes(for PARAM)
1494     - */
1495     - ifc_out32(256, &ifc->ifc_nand.nand_fbcr);
1496     - ifc_nand_ctrl->read_bytes = 256;
1497     + ifc_out32(len, &ifc->ifc_nand.nand_fbcr);
1498     + ifc_nand_ctrl->read_bytes = len;
1499    
1500     set_addr(mtd, 0, 0, 0);
1501     fsl_ifc_run_command(mtd);
1502     diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
1503     index b3df70d07ff6..7f64a76acd37 100644
1504     --- a/drivers/net/dsa/qca8k.c
1505     +++ b/drivers/net/dsa/qca8k.c
1506     @@ -474,7 +474,7 @@ qca8k_set_pad_ctrl(struct qca8k_priv *priv, int port, int mode)
1507     static void
1508     qca8k_port_set_status(struct qca8k_priv *priv, int port, int enable)
1509     {
1510     - u32 mask = QCA8K_PORT_STATUS_TXMAC;
1511     + u32 mask = QCA8K_PORT_STATUS_TXMAC | QCA8K_PORT_STATUS_RXMAC;
1512    
1513     /* Port 0 and 6 have no internal PHY */
1514     if ((port > 0) && (port < 6))
1515     @@ -491,6 +491,7 @@ qca8k_setup(struct dsa_switch *ds)
1516     {
1517     struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
1518     int ret, i, phy_mode = -1;
1519     + u32 mask;
1520    
1521     /* Make sure that port 0 is the cpu port */
1522     if (!dsa_is_cpu_port(ds, 0)) {
1523     @@ -516,7 +517,10 @@ qca8k_setup(struct dsa_switch *ds)
1524     if (ret < 0)
1525     return ret;
1526    
1527     - /* Enable CPU Port */
1528     + /* Enable CPU Port, force it to maximum bandwidth and full-duplex */
1529     + mask = QCA8K_PORT_STATUS_SPEED_1000 | QCA8K_PORT_STATUS_TXFLOW |
1530     + QCA8K_PORT_STATUS_RXFLOW | QCA8K_PORT_STATUS_DUPLEX;
1531     + qca8k_write(priv, QCA8K_REG_PORT_STATUS(QCA8K_CPU_PORT), mask);
1532     qca8k_reg_set(priv, QCA8K_REG_GLOBAL_FW_CTRL0,
1533     QCA8K_GLOBAL_FW_CTRL0_CPU_PORT_EN);
1534     qca8k_port_set_status(priv, QCA8K_CPU_PORT, 1);
1535     @@ -585,6 +589,47 @@ qca8k_setup(struct dsa_switch *ds)
1536     return 0;
1537     }
1538    
1539     +static void
1540     +qca8k_adjust_link(struct dsa_switch *ds, int port, struct phy_device *phy)
1541     +{
1542     + struct qca8k_priv *priv = ds->priv;
1543     + u32 reg;
1544     +
1545     + /* Force fixed-link setting for CPU port, skip others. */
1546     + if (!phy_is_pseudo_fixed_link(phy))
1547     + return;
1548     +
1549     + /* Set port speed */
1550     + switch (phy->speed) {
1551     + case 10:
1552     + reg = QCA8K_PORT_STATUS_SPEED_10;
1553     + break;
1554     + case 100:
1555     + reg = QCA8K_PORT_STATUS_SPEED_100;
1556     + break;
1557     + case 1000:
1558     + reg = QCA8K_PORT_STATUS_SPEED_1000;
1559     + break;
1560     + default:
1561     + dev_dbg(priv->dev, "port%d link speed %dMbps not supported.\n",
1562     + port, phy->speed);
1563     + return;
1564     + }
1565     +
1566     + /* Set duplex mode */
1567     + if (phy->duplex == DUPLEX_FULL)
1568     + reg |= QCA8K_PORT_STATUS_DUPLEX;
1569     +
1570     + /* Force flow control */
1571     + if (dsa_is_cpu_port(ds, port))
1572     + reg |= QCA8K_PORT_STATUS_RXFLOW | QCA8K_PORT_STATUS_TXFLOW;
1573     +
1574     + /* Force link down before changing MAC options */
1575     + qca8k_port_set_status(priv, port, 0);
1576     + qca8k_write(priv, QCA8K_REG_PORT_STATUS(port), reg);
1577     + qca8k_port_set_status(priv, port, 1);
1578     +}
1579     +
1580     static int
1581     qca8k_phy_read(struct dsa_switch *ds, int phy, int regnum)
1582     {
1583     @@ -914,6 +959,7 @@ qca8k_get_tag_protocol(struct dsa_switch *ds)
1584     static struct dsa_switch_ops qca8k_switch_ops = {
1585     .get_tag_protocol = qca8k_get_tag_protocol,
1586     .setup = qca8k_setup,
1587     + .adjust_link = qca8k_adjust_link,
1588     .get_strings = qca8k_get_strings,
1589     .phy_read = qca8k_phy_read,
1590     .phy_write = qca8k_phy_write,
1591     @@ -946,6 +992,7 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
1592     return -ENOMEM;
1593    
1594     priv->bus = mdiodev->bus;
1595     + priv->dev = &mdiodev->dev;
1596    
1597     /* read the switches ID register */
1598     id = qca8k_read(priv, QCA8K_REG_MASK_CTRL);
1599     @@ -1018,6 +1065,7 @@ static SIMPLE_DEV_PM_OPS(qca8k_pm_ops,
1600     qca8k_suspend, qca8k_resume);
1601    
1602     static const struct of_device_id qca8k_of_match[] = {
1603     + { .compatible = "qca,qca8334" },
1604     { .compatible = "qca,qca8337" },
1605     { /* sentinel */ },
1606     };
1607     diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h
1608     index 201464719531..9c22bc3210cd 100644
1609     --- a/drivers/net/dsa/qca8k.h
1610     +++ b/drivers/net/dsa/qca8k.h
1611     @@ -51,8 +51,10 @@
1612     #define QCA8K_GOL_MAC_ADDR0 0x60
1613     #define QCA8K_GOL_MAC_ADDR1 0x64
1614     #define QCA8K_REG_PORT_STATUS(_i) (0x07c + (_i) * 4)
1615     -#define QCA8K_PORT_STATUS_SPEED GENMASK(2, 0)
1616     -#define QCA8K_PORT_STATUS_SPEED_S 0
1617     +#define QCA8K_PORT_STATUS_SPEED GENMASK(1, 0)
1618     +#define QCA8K_PORT_STATUS_SPEED_10 0
1619     +#define QCA8K_PORT_STATUS_SPEED_100 0x1
1620     +#define QCA8K_PORT_STATUS_SPEED_1000 0x2
1621     #define QCA8K_PORT_STATUS_TXMAC BIT(2)
1622     #define QCA8K_PORT_STATUS_RXMAC BIT(3)
1623     #define QCA8K_PORT_STATUS_TXFLOW BIT(4)
1624     @@ -167,6 +169,7 @@ struct qca8k_priv {
1625     struct ar8xxx_port_status port_sts[QCA8K_NUM_PORTS];
1626     struct dsa_switch *ds;
1627     struct mutex reg_mutex;
1628     + struct device *dev;
1629     };
1630    
1631     struct qca8k_mib_desc {
1632     diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
1633     index ca57eb56c717..8777c3a4c095 100644
1634     --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
1635     +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
1636     @@ -5257,6 +5257,9 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state)
1637     }
1638     mutex_unlock(&bp->hwrm_cmd_lock);
1639    
1640     + if (!BNXT_SINGLE_PF(bp))
1641     + return 0;
1642     +
1643     diff = link_info->support_auto_speeds ^ link_info->advertising;
1644     if ((link_info->support_auto_speeds | diff) !=
1645     link_info->support_auto_speeds) {
1646     diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1647     index 1499ce2bf9f6..029513294984 100644
1648     --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1649     +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1650     @@ -3729,6 +3729,7 @@ static int ixgbevf_set_mac(struct net_device *netdev, void *p)
1651     return -EPERM;
1652    
1653     ether_addr_copy(hw->mac.addr, addr->sa_data);
1654     + ether_addr_copy(hw->mac.perm_addr, addr->sa_data);
1655     ether_addr_copy(netdev->dev_addr, addr->sa_data);
1656    
1657     return 0;
1658     diff --git a/drivers/net/ethernet/ti/cpsw-phy-sel.c b/drivers/net/ethernet/ti/cpsw-phy-sel.c
1659     index 18013645e76c..0c1adad7415d 100644
1660     --- a/drivers/net/ethernet/ti/cpsw-phy-sel.c
1661     +++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c
1662     @@ -177,12 +177,18 @@ void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave)
1663     }
1664    
1665     dev = bus_find_device(&platform_bus_type, NULL, node, match);
1666     - of_node_put(node);
1667     + if (!dev) {
1668     + dev_err(dev, "unable to find platform device for %pOF\n", node);
1669     + goto out;
1670     + }
1671     +
1672     priv = dev_get_drvdata(dev);
1673    
1674     priv->cpsw_phy_sel(priv, phy_mode, slave);
1675    
1676     put_device(dev);
1677     +out:
1678     + of_node_put(node);
1679     }
1680     EXPORT_SYMBOL_GPL(cpsw_phy_sel);
1681    
1682     diff --git a/drivers/net/wireless/ath/regd.h b/drivers/net/wireless/ath/regd.h
1683     index 565d3075f06e..8553ab44d930 100644
1684     --- a/drivers/net/wireless/ath/regd.h
1685     +++ b/drivers/net/wireless/ath/regd.h
1686     @@ -68,12 +68,14 @@ enum CountryCode {
1687     CTRY_AUSTRALIA = 36,
1688     CTRY_AUSTRIA = 40,
1689     CTRY_AZERBAIJAN = 31,
1690     + CTRY_BAHAMAS = 44,
1691     CTRY_BAHRAIN = 48,
1692     CTRY_BANGLADESH = 50,
1693     CTRY_BARBADOS = 52,
1694     CTRY_BELARUS = 112,
1695     CTRY_BELGIUM = 56,
1696     CTRY_BELIZE = 84,
1697     + CTRY_BERMUDA = 60,
1698     CTRY_BOLIVIA = 68,
1699     CTRY_BOSNIA_HERZ = 70,
1700     CTRY_BRAZIL = 76,
1701     @@ -159,6 +161,7 @@ enum CountryCode {
1702     CTRY_ROMANIA = 642,
1703     CTRY_RUSSIA = 643,
1704     CTRY_SAUDI_ARABIA = 682,
1705     + CTRY_SERBIA = 688,
1706     CTRY_SERBIA_MONTENEGRO = 891,
1707     CTRY_SINGAPORE = 702,
1708     CTRY_SLOVAKIA = 703,
1709     @@ -170,11 +173,13 @@ enum CountryCode {
1710     CTRY_SWITZERLAND = 756,
1711     CTRY_SYRIA = 760,
1712     CTRY_TAIWAN = 158,
1713     + CTRY_TANZANIA = 834,
1714     CTRY_THAILAND = 764,
1715     CTRY_TRINIDAD_Y_TOBAGO = 780,
1716     CTRY_TUNISIA = 788,
1717     CTRY_TURKEY = 792,
1718     CTRY_UAE = 784,
1719     + CTRY_UGANDA = 800,
1720     CTRY_UKRAINE = 804,
1721     CTRY_UNITED_KINGDOM = 826,
1722     CTRY_UNITED_STATES = 840,
1723     diff --git a/drivers/net/wireless/ath/regd_common.h b/drivers/net/wireless/ath/regd_common.h
1724     index bdd2b4d61f2f..15bbd1e0d912 100644
1725     --- a/drivers/net/wireless/ath/regd_common.h
1726     +++ b/drivers/net/wireless/ath/regd_common.h
1727     @@ -35,6 +35,7 @@ enum EnumRd {
1728     FRANCE_RES = 0x31,
1729     FCC3_FCCA = 0x3A,
1730     FCC3_WORLD = 0x3B,
1731     + FCC3_ETSIC = 0x3F,
1732    
1733     ETSI1_WORLD = 0x37,
1734     ETSI3_ETSIA = 0x32,
1735     @@ -44,6 +45,7 @@ enum EnumRd {
1736     ETSI4_ETSIC = 0x38,
1737     ETSI5_WORLD = 0x39,
1738     ETSI6_WORLD = 0x34,
1739     + ETSI8_WORLD = 0x3D,
1740     ETSI_RESERVED = 0x33,
1741    
1742     MKK1_MKKA = 0x40,
1743     @@ -59,6 +61,7 @@ enum EnumRd {
1744     MKK1_MKKA1 = 0x4A,
1745     MKK1_MKKA2 = 0x4B,
1746     MKK1_MKKC = 0x4C,
1747     + APL2_FCCA = 0x4D,
1748    
1749     APL3_FCCA = 0x50,
1750     APL1_WORLD = 0x52,
1751     @@ -67,6 +70,7 @@ enum EnumRd {
1752     APL1_ETSIC = 0x55,
1753     APL2_ETSIC = 0x56,
1754     APL5_WORLD = 0x58,
1755     + APL13_WORLD = 0x5A,
1756     APL6_WORLD = 0x5B,
1757     APL7_FCCA = 0x5C,
1758     APL8_WORLD = 0x5D,
1759     @@ -168,6 +172,7 @@ static struct reg_dmn_pair_mapping regDomainPairs[] = {
1760     {FCC2_ETSIC, CTL_FCC, CTL_ETSI},
1761     {FCC3_FCCA, CTL_FCC, CTL_FCC},
1762     {FCC3_WORLD, CTL_FCC, CTL_ETSI},
1763     + {FCC3_ETSIC, CTL_FCC, CTL_ETSI},
1764     {FCC4_FCCA, CTL_FCC, CTL_FCC},
1765     {FCC5_FCCA, CTL_FCC, CTL_FCC},
1766     {FCC6_FCCA, CTL_FCC, CTL_FCC},
1767     @@ -179,6 +184,7 @@ static struct reg_dmn_pair_mapping regDomainPairs[] = {
1768     {ETSI4_WORLD, CTL_ETSI, CTL_ETSI},
1769     {ETSI5_WORLD, CTL_ETSI, CTL_ETSI},
1770     {ETSI6_WORLD, CTL_ETSI, CTL_ETSI},
1771     + {ETSI8_WORLD, CTL_ETSI, CTL_ETSI},
1772    
1773     /* XXX: For ETSI3_ETSIA, Was NO_CTL meant for the 2 GHz band ? */
1774     {ETSI3_ETSIA, CTL_ETSI, CTL_ETSI},
1775     @@ -188,9 +194,11 @@ static struct reg_dmn_pair_mapping regDomainPairs[] = {
1776     {FCC1_FCCA, CTL_FCC, CTL_FCC},
1777     {APL1_WORLD, CTL_FCC, CTL_ETSI},
1778     {APL2_WORLD, CTL_FCC, CTL_ETSI},
1779     + {APL2_FCCA, CTL_FCC, CTL_FCC},
1780     {APL3_WORLD, CTL_FCC, CTL_ETSI},
1781     {APL4_WORLD, CTL_FCC, CTL_ETSI},
1782     {APL5_WORLD, CTL_FCC, CTL_ETSI},
1783     + {APL13_WORLD, CTL_ETSI, CTL_ETSI},
1784     {APL6_WORLD, CTL_ETSI, CTL_ETSI},
1785     {APL8_WORLD, CTL_ETSI, CTL_ETSI},
1786     {APL9_WORLD, CTL_ETSI, CTL_ETSI},
1787     @@ -298,6 +306,7 @@ static struct country_code_to_enum_rd allCountries[] = {
1788     {CTRY_AUSTRALIA2, FCC6_WORLD, "AU"},
1789     {CTRY_AUSTRIA, ETSI1_WORLD, "AT"},
1790     {CTRY_AZERBAIJAN, ETSI4_WORLD, "AZ"},
1791     + {CTRY_BAHAMAS, FCC3_WORLD, "BS"},
1792     {CTRY_BAHRAIN, APL6_WORLD, "BH"},
1793     {CTRY_BANGLADESH, NULL1_WORLD, "BD"},
1794     {CTRY_BARBADOS, FCC2_WORLD, "BB"},
1795     @@ -305,6 +314,7 @@ static struct country_code_to_enum_rd allCountries[] = {
1796     {CTRY_BELGIUM, ETSI1_WORLD, "BE"},
1797     {CTRY_BELGIUM2, ETSI4_WORLD, "BL"},
1798     {CTRY_BELIZE, APL1_ETSIC, "BZ"},
1799     + {CTRY_BERMUDA, FCC3_FCCA, "BM"},
1800     {CTRY_BOLIVIA, APL1_ETSIC, "BO"},
1801     {CTRY_BOSNIA_HERZ, ETSI1_WORLD, "BA"},
1802     {CTRY_BRAZIL, FCC3_WORLD, "BR"},
1803     @@ -444,6 +454,7 @@ static struct country_code_to_enum_rd allCountries[] = {
1804     {CTRY_ROMANIA, NULL1_WORLD, "RO"},
1805     {CTRY_RUSSIA, NULL1_WORLD, "RU"},
1806     {CTRY_SAUDI_ARABIA, NULL1_WORLD, "SA"},
1807     + {CTRY_SERBIA, ETSI1_WORLD, "RS"},
1808     {CTRY_SERBIA_MONTENEGRO, ETSI1_WORLD, "CS"},
1809     {CTRY_SINGAPORE, APL6_WORLD, "SG"},
1810     {CTRY_SLOVAKIA, ETSI1_WORLD, "SK"},
1811     @@ -455,10 +466,12 @@ static struct country_code_to_enum_rd allCountries[] = {
1812     {CTRY_SWITZERLAND, ETSI1_WORLD, "CH"},
1813     {CTRY_SYRIA, NULL1_WORLD, "SY"},
1814     {CTRY_TAIWAN, APL3_FCCA, "TW"},
1815     + {CTRY_TANZANIA, APL1_WORLD, "TZ"},
1816     {CTRY_THAILAND, FCC3_WORLD, "TH"},
1817     {CTRY_TRINIDAD_Y_TOBAGO, FCC3_WORLD, "TT"},
1818     {CTRY_TUNISIA, ETSI3_WORLD, "TN"},
1819     {CTRY_TURKEY, ETSI3_WORLD, "TR"},
1820     + {CTRY_UGANDA, FCC3_WORLD, "UG"},
1821     {CTRY_UKRAINE, NULL1_WORLD, "UA"},
1822     {CTRY_UAE, NULL1_WORLD, "AE"},
1823     {CTRY_UNITED_KINGDOM, ETSI1_WORLD, "GB"},
1824     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
1825     index 746f8c9a891d..e69cf0ef9574 100644
1826     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
1827     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
1828     @@ -1099,6 +1099,7 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = {
1829     BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_43340),
1830     BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_43341),
1831     BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_43362),
1832     + BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_43364),
1833     BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_4335_4339),
1834     BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_4339),
1835     BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_43430),
1836     diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
1837     index 6fe5546dc773..996a928142ad 100644
1838     --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
1839     +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
1840     @@ -898,6 +898,8 @@ int iwl_pcie_rx_init(struct iwl_trans *trans)
1841     WQ_HIGHPRI | WQ_UNBOUND, 1);
1842     INIT_WORK(&rba->rx_alloc, iwl_pcie_rx_allocator_work);
1843    
1844     + cancel_work_sync(&rba->rx_alloc);
1845     +
1846     spin_lock(&rba->lock);
1847     atomic_set(&rba->req_pending, 0);
1848     atomic_set(&rba->req_ready, 0);
1849     diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
1850     index 73eb0846db21..09185a1f7379 100644
1851     --- a/drivers/net/wireless/marvell/mwifiex/usb.c
1852     +++ b/drivers/net/wireless/marvell/mwifiex/usb.c
1853     @@ -624,6 +624,9 @@ static void mwifiex_usb_disconnect(struct usb_interface *intf)
1854     MWIFIEX_FUNC_SHUTDOWN);
1855     }
1856    
1857     + if (adapter->workqueue)
1858     + flush_workqueue(adapter->workqueue);
1859     +
1860     mwifiex_usb_free(card);
1861    
1862     mwifiex_dbg(adapter, FATAL,
1863     diff --git a/drivers/net/wireless/marvell/mwifiex/util.c b/drivers/net/wireless/marvell/mwifiex/util.c
1864     index 18fbb96a46e9..d75756c68e16 100644
1865     --- a/drivers/net/wireless/marvell/mwifiex/util.c
1866     +++ b/drivers/net/wireless/marvell/mwifiex/util.c
1867     @@ -723,12 +723,14 @@ void mwifiex_hist_data_set(struct mwifiex_private *priv, u8 rx_rate, s8 snr,
1868     s8 nflr)
1869     {
1870     struct mwifiex_histogram_data *phist_data = priv->hist_data;
1871     + s8 nf = -nflr;
1872     + s8 rssi = snr - nflr;
1873    
1874     atomic_inc(&phist_data->num_samples);
1875     atomic_inc(&phist_data->rx_rate[rx_rate]);
1876     - atomic_inc(&phist_data->snr[snr]);
1877     - atomic_inc(&phist_data->noise_flr[128 + nflr]);
1878     - atomic_inc(&phist_data->sig_str[nflr - snr]);
1879     + atomic_inc(&phist_data->snr[snr + 128]);
1880     + atomic_inc(&phist_data->noise_flr[nf + 128]);
1881     + atomic_inc(&phist_data->sig_str[rssi + 128]);
1882     }
1883    
1884     /* function to reset histogram data during init/reset */
1885     diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c
1886     index 8428858204a6..fc895b466ebb 100644
1887     --- a/drivers/net/wireless/rsi/rsi_91x_sdio.c
1888     +++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c
1889     @@ -155,7 +155,6 @@ static void rsi_reset_card(struct sdio_func *pfunction)
1890     int err;
1891     struct mmc_card *card = pfunction->card;
1892     struct mmc_host *host = card->host;
1893     - s32 bit = (fls(host->ocr_avail) - 1);
1894     u8 cmd52_resp;
1895     u32 clock, resp, i;
1896     u16 rca;
1897     @@ -175,7 +174,6 @@ static void rsi_reset_card(struct sdio_func *pfunction)
1898     msleep(20);
1899    
1900     /* Initialize the SDIO card */
1901     - host->ios.vdd = bit;
1902     host->ios.chip_select = MMC_CS_DONTCARE;
1903     host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
1904     host->ios.power_mode = MMC_POWER_UP;
1905     diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c
1906     index 47fe7f96a242..6921cb0bf563 100644
1907     --- a/drivers/net/wireless/ti/wlcore/sdio.c
1908     +++ b/drivers/net/wireless/ti/wlcore/sdio.c
1909     @@ -404,6 +404,11 @@ static int wl1271_suspend(struct device *dev)
1910     mmc_pm_flag_t sdio_flags;
1911     int ret = 0;
1912    
1913     + if (!wl) {
1914     + dev_err(dev, "no wilink module was probed\n");
1915     + goto out;
1916     + }
1917     +
1918     dev_dbg(dev, "wl1271 suspend. wow_enabled: %d\n",
1919     wl->wow_enabled);
1920    
1921     diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
1922     index 520050eae836..a5908e4c06cb 100644
1923     --- a/drivers/net/xen-netfront.c
1924     +++ b/drivers/net/xen-netfront.c
1925     @@ -238,7 +238,7 @@ static void rx_refill_timeout(unsigned long data)
1926     static int netfront_tx_slot_available(struct netfront_queue *queue)
1927     {
1928     return (queue->tx.req_prod_pvt - queue->tx.rsp_cons) <
1929     - (NET_TX_RING_SIZE - MAX_SKB_FRAGS - 2);
1930     + (NET_TX_RING_SIZE - XEN_NETIF_NR_SLOTS_MIN - 1);
1931     }
1932    
1933     static void xennet_maybe_wake_tx(struct netfront_queue *queue)
1934     @@ -789,7 +789,7 @@ static int xennet_get_responses(struct netfront_queue *queue,
1935     RING_IDX cons = queue->rx.rsp_cons;
1936     struct sk_buff *skb = xennet_get_rx_skb(queue, cons);
1937     grant_ref_t ref = xennet_get_rx_ref(queue, cons);
1938     - int max = MAX_SKB_FRAGS + (rx->status <= RX_COPY_THRESHOLD);
1939     + int max = XEN_NETIF_NR_SLOTS_MIN + (rx->status <= RX_COPY_THRESHOLD);
1940     int slots = 1;
1941     int err = 0;
1942     unsigned long ret;
1943     diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
1944     index 1b4d93e9157e..824e282cd80e 100644
1945     --- a/drivers/nvmem/core.c
1946     +++ b/drivers/nvmem/core.c
1947     @@ -1031,6 +1031,8 @@ static inline void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
1948    
1949     /* setup the first byte with lsb bits from nvmem */
1950     rc = nvmem_reg_read(nvmem, cell->offset, &v, 1);
1951     + if (rc)
1952     + goto err;
1953     *b++ |= GENMASK(bit_offset - 1, 0) & v;
1954    
1955     /* setup rest of the byte if any */
1956     @@ -1049,11 +1051,16 @@ static inline void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
1957     /* setup the last byte with msb bits from nvmem */
1958     rc = nvmem_reg_read(nvmem,
1959     cell->offset + cell->bytes - 1, &v, 1);
1960     + if (rc)
1961     + goto err;
1962     *p |= GENMASK(7, (nbits + bit_offset) % BITS_PER_BYTE) & v;
1963    
1964     }
1965    
1966     return buf;
1967     +err:
1968     + kfree(buf);
1969     + return ERR_PTR(rc);
1970     }
1971    
1972     /**
1973     diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
1974     index f9f4d1c18eb2..e5d8e2e2bd30 100644
1975     --- a/drivers/pci/pci-sysfs.c
1976     +++ b/drivers/pci/pci-sysfs.c
1977     @@ -180,13 +180,16 @@ static ssize_t enable_store(struct device *dev, struct device_attribute *attr,
1978     if (!capable(CAP_SYS_ADMIN))
1979     return -EPERM;
1980    
1981     - if (!val) {
1982     - if (pci_is_enabled(pdev))
1983     - pci_disable_device(pdev);
1984     - else
1985     - result = -EIO;
1986     - } else
1987     + device_lock(dev);
1988     + if (dev->driver)
1989     + result = -EBUSY;
1990     + else if (val)
1991     result = pci_enable_device(pdev);
1992     + else if (pci_is_enabled(pdev))
1993     + pci_disable_device(pdev);
1994     + else
1995     + result = -EIO;
1996     + device_unlock(dev);
1997    
1998     return result < 0 ? result : count;
1999     }
2000     diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
2001     index 28bbc1bb9e6c..88ba9c50cc8e 100644
2002     --- a/drivers/pinctrl/pinctrl-at91-pio4.c
2003     +++ b/drivers/pinctrl/pinctrl-at91-pio4.c
2004     @@ -573,8 +573,10 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
2005     for_each_child_of_node(np_config, np) {
2006     ret = atmel_pctl_dt_subnode_to_map(pctldev, np, map,
2007     &reserved_maps, num_maps);
2008     - if (ret < 0)
2009     + if (ret < 0) {
2010     + of_node_put(np);
2011     break;
2012     + }
2013     }
2014     }
2015    
2016     diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
2017     index cb18b5c4f2db..86b348740fcd 100644
2018     --- a/drivers/regulator/pfuze100-regulator.c
2019     +++ b/drivers/regulator/pfuze100-regulator.c
2020     @@ -153,6 +153,7 @@ static struct regulator_ops pfuze100_sw_regulator_ops = {
2021     static struct regulator_ops pfuze100_swb_regulator_ops = {
2022     .enable = regulator_enable_regmap,
2023     .disable = regulator_disable_regmap,
2024     + .is_enabled = regulator_is_enabled_regmap,
2025     .list_voltage = regulator_list_voltage_table,
2026     .map_voltage = regulator_map_voltage_ascend,
2027     .set_voltage_sel = regulator_set_voltage_sel_regmap,
2028     diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
2029     index 25cf3069e2e7..4131bfb2cc61 100644
2030     --- a/drivers/rtc/interface.c
2031     +++ b/drivers/rtc/interface.c
2032     @@ -359,6 +359,11 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
2033     {
2034     int err;
2035    
2036     + if (!rtc->ops)
2037     + return -ENODEV;
2038     + else if (!rtc->ops->set_alarm)
2039     + return -EINVAL;
2040     +
2041     err = rtc_valid_tm(&alarm->time);
2042     if (err != 0)
2043     return err;
2044     diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
2045     index a56a7b243e91..5466246c69b4 100644
2046     --- a/drivers/scsi/3w-9xxx.c
2047     +++ b/drivers/scsi/3w-9xxx.c
2048     @@ -889,6 +889,11 @@ static int twa_chrdev_open(struct inode *inode, struct file *file)
2049     unsigned int minor_number;
2050     int retval = TW_IOCTL_ERROR_OS_ENODEV;
2051    
2052     + if (!capable(CAP_SYS_ADMIN)) {
2053     + retval = -EACCES;
2054     + goto out;
2055     + }
2056     +
2057     minor_number = iminor(inode);
2058     if (minor_number >= twa_device_extension_count)
2059     goto out;
2060     diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
2061     index 25aba1613e21..24ac19e31003 100644
2062     --- a/drivers/scsi/3w-xxxx.c
2063     +++ b/drivers/scsi/3w-xxxx.c
2064     @@ -1034,6 +1034,9 @@ static int tw_chrdev_open(struct inode *inode, struct file *file)
2065    
2066     dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n");
2067    
2068     + if (!capable(CAP_SYS_ADMIN))
2069     + return -EACCES;
2070     +
2071     minor_number = iminor(inode);
2072     if (minor_number >= tw_device_extension_count)
2073     return -ENODEV;
2074     diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
2075     index 9d05302a3bcd..19bffe0b2cc0 100644
2076     --- a/drivers/scsi/megaraid.c
2077     +++ b/drivers/scsi/megaraid.c
2078     @@ -4197,6 +4197,9 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2079     int irq, i, j;
2080     int error = -ENODEV;
2081    
2082     + if (hba_count >= MAX_CONTROLLERS)
2083     + goto out;
2084     +
2085     if (pci_enable_device(pdev))
2086     goto out;
2087     pci_set_master(pdev);
2088     diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
2089     index a156451553a7..f722a0e6caa4 100644
2090     --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
2091     +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
2092     @@ -2031,6 +2031,9 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
2093     pRAID_Context->timeoutValue = cpu_to_le16(os_timeout_value);
2094     pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id);
2095     } else {
2096     + if (os_timeout_value)
2097     + os_timeout_value++;
2098     +
2099     /* system pd Fast Path */
2100     io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
2101     timeout_limit = (scmd->device->type == TYPE_DISK) ?
2102     diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
2103     index a5e30e9449ef..375cede0c534 100644
2104     --- a/drivers/scsi/scsi_dh.c
2105     +++ b/drivers/scsi/scsi_dh.c
2106     @@ -58,7 +58,10 @@ static const struct scsi_dh_blist scsi_dh_blist[] = {
2107     {"IBM", "3526", "rdac", },
2108     {"IBM", "3542", "rdac", },
2109     {"IBM", "3552", "rdac", },
2110     - {"SGI", "TP9", "rdac", },
2111     + {"SGI", "TP9300", "rdac", },
2112     + {"SGI", "TP9400", "rdac", },
2113     + {"SGI", "TP9500", "rdac", },
2114     + {"SGI", "TP9700", "rdac", },
2115     {"SGI", "IS", "rdac", },
2116     {"STK", "OPENstorage", "rdac", },
2117     {"STK", "FLEXLINE 380", "rdac", },
2118     diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
2119     index 86a3110c6d75..f857086ce2fa 100644
2120     --- a/drivers/scsi/ufs/ufshcd.c
2121     +++ b/drivers/scsi/ufs/ufshcd.c
2122     @@ -4012,6 +4012,7 @@ static void ufshcd_exception_event_handler(struct work_struct *work)
2123     hba = container_of(work, struct ufs_hba, eeh_work);
2124    
2125     pm_runtime_get_sync(hba->dev);
2126     + scsi_block_requests(hba->host);
2127     err = ufshcd_get_ee_status(hba, &status);
2128     if (err) {
2129     dev_err(hba->dev, "%s: failed to get exception status %d\n",
2130     @@ -4025,6 +4026,7 @@ static void ufshcd_exception_event_handler(struct work_struct *work)
2131     ufshcd_bkops_exception_event_handler(hba);
2132    
2133     out:
2134     + scsi_unblock_requests(hba->host);
2135     pm_runtime_put_sync(hba->dev);
2136     return;
2137     }
2138     diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
2139     index ea9a0c21d29d..4ff293129675 100644
2140     --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
2141     +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
2142     @@ -1299,11 +1299,6 @@ kiblnd_connect_peer(struct kib_peer *peer)
2143     goto failed2;
2144     }
2145    
2146     - LASSERT(cmid->device);
2147     - CDEBUG(D_NET, "%s: connection bound to %s:%pI4h:%s\n",
2148     - libcfs_nid2str(peer->ibp_nid), dev->ibd_ifname,
2149     - &dev->ibd_ifip, cmid->device->name);
2150     -
2151     return;
2152    
2153     failed2:
2154     @@ -3005,8 +3000,19 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
2155     } else {
2156     rc = rdma_resolve_route(
2157     cmid, *kiblnd_tunables.kib_timeout * 1000);
2158     - if (!rc)
2159     + if (!rc) {
2160     + struct kib_net *net = peer->ibp_ni->ni_data;
2161     + struct kib_dev *dev = net->ibn_dev;
2162     +
2163     + CDEBUG(D_NET, "%s: connection bound to "\
2164     + "%s:%pI4h:%s\n",
2165     + libcfs_nid2str(peer->ibp_nid),
2166     + dev->ibd_ifname,
2167     + &dev->ibd_ifip, cmid->device->name);
2168     +
2169     return 0;
2170     + }
2171     +
2172     /* Can't initiate route resolution */
2173     CERROR("Can't resolve route for %s: %d\n",
2174     libcfs_nid2str(peer->ibp_nid), rc);
2175     diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
2176     index d18ab3f28c70..9addcdbe9374 100644
2177     --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
2178     +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
2179     @@ -1489,8 +1489,10 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
2180     return ERR_CAST(res);
2181    
2182     lock = ldlm_lock_new(res);
2183     - if (!lock)
2184     + if (!lock) {
2185     + ldlm_resource_putref(res);
2186     return ERR_PTR(-ENOMEM);
2187     + }
2188    
2189     lock->l_req_mode = mode;
2190     lock->l_ast_data = data;
2191     @@ -1533,6 +1535,8 @@ out:
2192     return ERR_PTR(rc);
2193     }
2194    
2195     +
2196     +
2197     /**
2198     * Enqueue (request) a lock.
2199     * On the client this is called from ldlm_cli_enqueue_fini
2200     diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
2201     index e070adb7a3cc..57121fd5f050 100644
2202     --- a/drivers/staging/lustre/lustre/llite/xattr.c
2203     +++ b/drivers/staging/lustre/lustre/llite/xattr.c
2204     @@ -103,7 +103,11 @@ ll_xattr_set_common(const struct xattr_handler *handler,
2205     __u64 valid;
2206     int rc;
2207    
2208     - if (flags == XATTR_REPLACE) {
2209     + /* When setxattr() is called with a size of 0 the value is
2210     + * unconditionally replaced by "". When removexattr() is
2211     + * called we get a NULL value and XATTR_REPLACE for flags.
2212     + */
2213     + if (!value && flags == XATTR_REPLACE) {
2214     ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_REMOVEXATTR, 1);
2215     valid = OBD_MD_FLXATTRRM;
2216     } else {
2217     diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
2218     index a45810b43f70..c974cb5fb958 100644
2219     --- a/drivers/thermal/samsung/exynos_tmu.c
2220     +++ b/drivers/thermal/samsung/exynos_tmu.c
2221     @@ -598,6 +598,7 @@ static int exynos5433_tmu_initialize(struct platform_device *pdev)
2222     threshold_code = temp_to_code(data, temp);
2223    
2224     rising_threshold = readl(data->base + rising_reg_offset);
2225     + rising_threshold &= ~(0xff << j * 8);
2226     rising_threshold |= (threshold_code << j * 8);
2227     writel(rising_threshold, data->base + rising_reg_offset);
2228    
2229     diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
2230     index 510799311099..1fc5d5b82778 100644
2231     --- a/drivers/tty/hvc/hvc_opal.c
2232     +++ b/drivers/tty/hvc/hvc_opal.c
2233     @@ -332,7 +332,6 @@ static void udbg_init_opal_common(void)
2234     udbg_putc = udbg_opal_putc;
2235     udbg_getc = udbg_opal_getc;
2236     udbg_getc_poll = udbg_opal_getc_poll;
2237     - tb_ticks_per_usec = 0x200; /* Make udelay not suck */
2238     }
2239    
2240     void __init hvc_opal_init_early(void)
2241     diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
2242     index 2b907385b4a8..171130a9ecc8 100644
2243     --- a/drivers/tty/pty.c
2244     +++ b/drivers/tty/pty.c
2245     @@ -106,16 +106,19 @@ static void pty_unthrottle(struct tty_struct *tty)
2246     static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
2247     {
2248     struct tty_struct *to = tty->link;
2249     + unsigned long flags;
2250    
2251     if (tty->stopped)
2252     return 0;
2253    
2254     if (c > 0) {
2255     + spin_lock_irqsave(&to->port->lock, flags);
2256     /* Stuff the data into the input queue of the other end */
2257     c = tty_insert_flip_string(to->port, buf, c);
2258     /* And shovel */
2259     if (c)
2260     tty_flip_buffer_push(to->port);
2261     + spin_unlock_irqrestore(&to->port->lock, flags);
2262     }
2263     return c;
2264     }
2265     diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
2266     index bdb19db542a4..7aee55244b4a 100644
2267     --- a/drivers/usb/core/hub.c
2268     +++ b/drivers/usb/core/hub.c
2269     @@ -3363,6 +3363,10 @@ static int wait_for_connected(struct usb_device *udev,
2270     while (delay_ms < 2000) {
2271     if (status || *portstatus & USB_PORT_STAT_CONNECTION)
2272     break;
2273     + if (!port_is_power_on(hub, *portstatus)) {
2274     + status = -ENODEV;
2275     + break;
2276     + }
2277     msleep(20);
2278     delay_ms += 20;
2279     status = hub_port_status(hub, *port1, portstatus, portchange);
2280     diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
2281     index 0a0cf154814b..984d6aae7529 100644
2282     --- a/drivers/usb/dwc2/hcd.c
2283     +++ b/drivers/usb/dwc2/hcd.c
2284     @@ -2544,34 +2544,29 @@ static void dwc2_hc_init_xfer(struct dwc2_hsotg *hsotg,
2285    
2286     #define DWC2_USB_DMA_ALIGN 4
2287    
2288     -struct dma_aligned_buffer {
2289     - void *kmalloc_ptr;
2290     - void *old_xfer_buffer;
2291     - u8 data[0];
2292     -};
2293     -
2294     static void dwc2_free_dma_aligned_buffer(struct urb *urb)
2295     {
2296     - struct dma_aligned_buffer *temp;
2297     + void *stored_xfer_buffer;
2298    
2299     if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
2300     return;
2301    
2302     - temp = container_of(urb->transfer_buffer,
2303     - struct dma_aligned_buffer, data);
2304     + /* Restore urb->transfer_buffer from the end of the allocated area */
2305     + memcpy(&stored_xfer_buffer, urb->transfer_buffer +
2306     + urb->transfer_buffer_length, sizeof(urb->transfer_buffer));
2307    
2308     if (usb_urb_dir_in(urb))
2309     - memcpy(temp->old_xfer_buffer, temp->data,
2310     + memcpy(stored_xfer_buffer, urb->transfer_buffer,
2311     urb->transfer_buffer_length);
2312     - urb->transfer_buffer = temp->old_xfer_buffer;
2313     - kfree(temp->kmalloc_ptr);
2314     + kfree(urb->transfer_buffer);
2315     + urb->transfer_buffer = stored_xfer_buffer;
2316    
2317     urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER;
2318     }
2319    
2320     static int dwc2_alloc_dma_aligned_buffer(struct urb *urb, gfp_t mem_flags)
2321     {
2322     - struct dma_aligned_buffer *temp, *kmalloc_ptr;
2323     + void *kmalloc_ptr;
2324     size_t kmalloc_size;
2325    
2326     if (urb->num_sgs || urb->sg ||
2327     @@ -2579,22 +2574,29 @@ static int dwc2_alloc_dma_aligned_buffer(struct urb *urb, gfp_t mem_flags)
2328     !((uintptr_t)urb->transfer_buffer & (DWC2_USB_DMA_ALIGN - 1)))
2329     return 0;
2330    
2331     - /* Allocate a buffer with enough padding for alignment */
2332     + /*
2333     + * Allocate a buffer with enough padding for original transfer_buffer
2334     + * pointer. This allocation is guaranteed to be aligned properly for
2335     + * DMA
2336     + */
2337     kmalloc_size = urb->transfer_buffer_length +
2338     - sizeof(struct dma_aligned_buffer) + DWC2_USB_DMA_ALIGN - 1;
2339     + sizeof(urb->transfer_buffer);
2340    
2341     kmalloc_ptr = kmalloc(kmalloc_size, mem_flags);
2342     if (!kmalloc_ptr)
2343     return -ENOMEM;
2344    
2345     - /* Position our struct dma_aligned_buffer such that data is aligned */
2346     - temp = PTR_ALIGN(kmalloc_ptr + 1, DWC2_USB_DMA_ALIGN) - 1;
2347     - temp->kmalloc_ptr = kmalloc_ptr;
2348     - temp->old_xfer_buffer = urb->transfer_buffer;
2349     + /*
2350     + * Position value of original urb->transfer_buffer pointer to the end
2351     + * of allocation for later referencing
2352     + */
2353     + memcpy(kmalloc_ptr + urb->transfer_buffer_length,
2354     + &urb->transfer_buffer, sizeof(urb->transfer_buffer));
2355     +
2356     if (usb_urb_dir_out(urb))
2357     - memcpy(temp->data, urb->transfer_buffer,
2358     + memcpy(kmalloc_ptr, urb->transfer_buffer,
2359     urb->transfer_buffer_length);
2360     - urb->transfer_buffer = temp->data;
2361     + urb->transfer_buffer = kmalloc_ptr;
2362    
2363     urb->transfer_flags |= URB_ALIGNED_TEMP_BUFFER;
2364    
2365     diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
2366     index d78142830754..d143d08c4f0f 100644
2367     --- a/drivers/vfio/platform/vfio_platform_common.c
2368     +++ b/drivers/vfio/platform/vfio_platform_common.c
2369     @@ -696,18 +696,23 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
2370     group = vfio_iommu_group_get(dev);
2371     if (!group) {
2372     pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
2373     - return -EINVAL;
2374     + ret = -EINVAL;
2375     + goto put_reset;
2376     }
2377    
2378     ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
2379     - if (ret) {
2380     - vfio_iommu_group_put(group, dev);
2381     - return ret;
2382     - }
2383     + if (ret)
2384     + goto put_iommu;
2385    
2386     mutex_init(&vdev->igate);
2387    
2388     return 0;
2389     +
2390     +put_iommu:
2391     + vfio_iommu_group_put(group, dev);
2392     +put_reset:
2393     + vfio_platform_put_reset(vdev);
2394     + return ret;
2395     }
2396     EXPORT_SYMBOL_GPL(vfio_platform_probe_common);
2397    
2398     diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
2399     index dfd99867ff4d..9afad8c14220 100644
2400     --- a/fs/btrfs/qgroup.c
2401     +++ b/fs/btrfs/qgroup.c
2402     @@ -2236,6 +2236,21 @@ void assert_qgroups_uptodate(struct btrfs_trans_handle *trans)
2403     BUG();
2404     }
2405    
2406     +/*
2407     + * Check if the leaf is the last leaf. Which means all node pointers
2408     + * are at their last position.
2409     + */
2410     +static bool is_last_leaf(struct btrfs_path *path)
2411     +{
2412     + int i;
2413     +
2414     + for (i = 1; i < BTRFS_MAX_LEVEL && path->nodes[i]; i++) {
2415     + if (path->slots[i] != btrfs_header_nritems(path->nodes[i]) - 1)
2416     + return false;
2417     + }
2418     + return true;
2419     +}
2420     +
2421     /*
2422     * returns < 0 on error, 0 when more leafs are to be scanned.
2423     * returns 1 when done.
2424     @@ -2249,6 +2264,7 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
2425     struct ulist *roots = NULL;
2426     struct seq_list tree_mod_seq_elem = SEQ_LIST_INIT(tree_mod_seq_elem);
2427     u64 num_bytes;
2428     + bool done;
2429     int slot;
2430     int ret;
2431    
2432     @@ -2277,6 +2293,7 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
2433     mutex_unlock(&fs_info->qgroup_rescan_lock);
2434     return ret;
2435     }
2436     + done = is_last_leaf(path);
2437    
2438     btrfs_item_key_to_cpu(path->nodes[0], &found,
2439     btrfs_header_nritems(path->nodes[0]) - 1);
2440     @@ -2323,6 +2340,8 @@ out:
2441     }
2442     btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem);
2443    
2444     + if (done && !ret)
2445     + ret = 1;
2446     return ret;
2447     }
2448    
2449     diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
2450     index 44d34923de9c..44966fd00790 100644
2451     --- a/fs/btrfs/tree-log.c
2452     +++ b/fs/btrfs/tree-log.c
2453     @@ -2979,8 +2979,11 @@ out_wake_log_root:
2454     mutex_unlock(&log_root_tree->log_mutex);
2455    
2456     /*
2457     - * The barrier before waitqueue_active is implied by mutex_unlock
2458     + * The barrier before waitqueue_active is needed so all the updates
2459     + * above are seen by the woken threads. It might not be necessary, but
2460     + * proving that seems to be hard.
2461     */
2462     + smp_mb();
2463     if (waitqueue_active(&log_root_tree->log_commit_wait[index2]))
2464     wake_up(&log_root_tree->log_commit_wait[index2]);
2465     out:
2466     @@ -2991,8 +2994,11 @@ out:
2467     mutex_unlock(&root->log_mutex);
2468    
2469     /*
2470     - * The barrier before waitqueue_active is implied by mutex_unlock
2471     + * The barrier before waitqueue_active is needed so all the updates
2472     + * above are seen by the woken threads. It might not be necessary, but
2473     + * proving that seems to be hard.
2474     */
2475     + smp_mb();
2476     if (waitqueue_active(&root->log_commit_wait[index1]))
2477     wake_up(&root->log_commit_wait[index1]);
2478     return ret;
2479     diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
2480     index 73de1446c8d4..1a8962569b5c 100644
2481     --- a/fs/crypto/crypto.c
2482     +++ b/fs/crypto/crypto.c
2483     @@ -517,8 +517,17 @@ EXPORT_SYMBOL(fscrypt_initialize);
2484     */
2485     static int __init fscrypt_init(void)
2486     {
2487     + /*
2488     + * Use an unbound workqueue to allow bios to be decrypted in parallel
2489     + * even when they happen to complete on the same CPU. This sacrifices
2490     + * locality, but it's worthwhile since decryption is CPU-intensive.
2491     + *
2492     + * Also use a high-priority workqueue to prioritize decryption work,
2493     + * which blocks reads from completing, over regular application tasks.
2494     + */
2495     fscrypt_read_workqueue = alloc_workqueue("fscrypt_read_queue",
2496     - WQ_HIGHPRI, 0);
2497     + WQ_UNBOUND | WQ_HIGHPRI,
2498     + num_online_cpus());
2499     if (!fscrypt_read_workqueue)
2500     goto fail;
2501    
2502     diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
2503     index ad13f07cf0d3..2455fe1446d6 100644
2504     --- a/fs/ext4/balloc.c
2505     +++ b/fs/ext4/balloc.c
2506     @@ -378,6 +378,8 @@ static int ext4_validate_block_bitmap(struct super_block *sb,
2507     return -EFSCORRUPTED;
2508    
2509     ext4_lock_group(sb, block_group);
2510     + if (buffer_verified(bh))
2511     + goto verified;
2512     if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group,
2513     desc, bh))) {
2514     ext4_unlock_group(sb, block_group);
2515     @@ -400,6 +402,7 @@ static int ext4_validate_block_bitmap(struct super_block *sb,
2516     return -EFSCORRUPTED;
2517     }
2518     set_buffer_verified(bh);
2519     +verified:
2520     ext4_unlock_group(sb, block_group);
2521     return 0;
2522     }
2523     diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
2524     index 460866b2166d..ffaf66a51de3 100644
2525     --- a/fs/ext4/ialloc.c
2526     +++ b/fs/ext4/ialloc.c
2527     @@ -88,6 +88,8 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
2528     return -EFSCORRUPTED;
2529    
2530     ext4_lock_group(sb, block_group);
2531     + if (buffer_verified(bh))
2532     + goto verified;
2533     blk = ext4_inode_bitmap(sb, desc);
2534     if (!ext4_inode_bitmap_csum_verify(sb, block_group, desc, bh,
2535     EXT4_INODES_PER_GROUP(sb) / 8)) {
2536     @@ -105,6 +107,7 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
2537     return -EFSBADCRC;
2538     }
2539     set_buffer_verified(bh);
2540     +verified:
2541     ext4_unlock_group(sb, block_group);
2542     return 0;
2543     }
2544     diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
2545     index e6ac24de119d..436baf7cdca3 100644
2546     --- a/fs/ext4/inline.c
2547     +++ b/fs/ext4/inline.c
2548     @@ -679,6 +679,10 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
2549     goto convert;
2550     }
2551    
2552     + ret = ext4_journal_get_write_access(handle, iloc.bh);
2553     + if (ret)
2554     + goto out;
2555     +
2556     flags |= AOP_FLAG_NOFS;
2557    
2558     page = grab_cache_page_write_begin(mapping, 0, flags);
2559     @@ -707,7 +711,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
2560     out_up_read:
2561     up_read(&EXT4_I(inode)->xattr_sem);
2562     out:
2563     - if (handle)
2564     + if (handle && (ret != 1))
2565     ext4_journal_stop(handle);
2566     brelse(iloc.bh);
2567     return ret;
2568     @@ -749,6 +753,7 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
2569    
2570     ext4_write_unlock_xattr(inode, &no_expand);
2571     brelse(iloc.bh);
2572     + mark_inode_dirty(inode);
2573     out:
2574     return copied;
2575     }
2576     @@ -895,7 +900,6 @@ retry_journal:
2577     goto out;
2578     }
2579    
2580     -
2581     page = grab_cache_page_write_begin(mapping, 0, flags);
2582     if (!page) {
2583     ret = -ENOMEM;
2584     @@ -913,6 +917,9 @@ retry_journal:
2585     if (ret < 0)
2586     goto out_release_page;
2587     }
2588     + ret = ext4_journal_get_write_access(handle, iloc.bh);
2589     + if (ret)
2590     + goto out_release_page;
2591    
2592     up_read(&EXT4_I(inode)->xattr_sem);
2593     *pagep = page;
2594     @@ -933,7 +940,6 @@ int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
2595     unsigned len, unsigned copied,
2596     struct page *page)
2597     {
2598     - int i_size_changed = 0;
2599     int ret;
2600    
2601     ret = ext4_write_inline_data_end(inode, pos, len, copied, page);
2602     @@ -951,10 +957,8 @@ int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
2603     * But it's important to update i_size while still holding page lock:
2604     * page writeout could otherwise come in and zero beyond i_size.
2605     */
2606     - if (pos+copied > inode->i_size) {
2607     + if (pos+copied > inode->i_size)
2608     i_size_write(inode, pos+copied);
2609     - i_size_changed = 1;
2610     - }
2611     unlock_page(page);
2612     put_page(page);
2613    
2614     @@ -964,8 +968,7 @@ int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
2615     * ordering of page lock and transaction start for journaling
2616     * filesystems.
2617     */
2618     - if (i_size_changed)
2619     - mark_inode_dirty(inode);
2620     + mark_inode_dirty(inode);
2621    
2622     return copied;
2623     }
2624     diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
2625     index 5c4c9af4aaf4..f62eca8cbde0 100644
2626     --- a/fs/ext4/inode.c
2627     +++ b/fs/ext4/inode.c
2628     @@ -1318,9 +1318,10 @@ static int ext4_write_end(struct file *file,
2629     loff_t old_size = inode->i_size;
2630     int ret = 0, ret2;
2631     int i_size_changed = 0;
2632     + int inline_data = ext4_has_inline_data(inode);
2633    
2634     trace_ext4_write_end(inode, pos, len, copied);
2635     - if (ext4_has_inline_data(inode)) {
2636     + if (inline_data) {
2637     ret = ext4_write_inline_data_end(inode, pos, len,
2638     copied, page);
2639     if (ret < 0) {
2640     @@ -1348,7 +1349,7 @@ static int ext4_write_end(struct file *file,
2641     * ordering of page lock and transaction start for journaling
2642     * filesystems.
2643     */
2644     - if (i_size_changed)
2645     + if (i_size_changed || inline_data)
2646     ext4_mark_inode_dirty(handle, inode);
2647    
2648     if (pos + len > inode->i_size && ext4_can_truncate(inode))
2649     @@ -1422,6 +1423,7 @@ static int ext4_journalled_write_end(struct file *file,
2650     int partial = 0;
2651     unsigned from, to;
2652     int size_changed = 0;
2653     + int inline_data = ext4_has_inline_data(inode);
2654    
2655     trace_ext4_journalled_write_end(inode, pos, len, copied);
2656     from = pos & (PAGE_SIZE - 1);
2657     @@ -1429,7 +1431,7 @@ static int ext4_journalled_write_end(struct file *file,
2658    
2659     BUG_ON(!ext4_handle_valid(handle));
2660    
2661     - if (ext4_has_inline_data(inode)) {
2662     + if (inline_data) {
2663     ret = ext4_write_inline_data_end(inode, pos, len,
2664     copied, page);
2665     if (ret < 0) {
2666     @@ -1460,7 +1462,7 @@ static int ext4_journalled_write_end(struct file *file,
2667     if (old_size < pos)
2668     pagecache_isize_extended(inode, old_size, pos);
2669    
2670     - if (size_changed) {
2671     + if (size_changed || inline_data) {
2672     ret2 = ext4_mark_inode_dirty(handle, inode);
2673     if (!ret)
2674     ret = ret2;
2675     @@ -1958,11 +1960,7 @@ static int __ext4_journalled_writepage(struct page *page,
2676     }
2677    
2678     if (inline_data) {
2679     - BUFFER_TRACE(inode_bh, "get write access");
2680     - ret = ext4_journal_get_write_access(handle, inode_bh);
2681     -
2682     - err = ext4_handle_dirty_metadata(handle, inode, inode_bh);
2683     -
2684     + ret = ext4_mark_inode_dirty(handle, inode);
2685     } else {
2686     ret = ext4_walk_page_buffers(handle, page_bufs, 0, len, NULL,
2687     do_journal_get_write_access);
2688     diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
2689     index 801111e1f8ef..7d0e8d6bf009 100644
2690     --- a/fs/f2fs/file.c
2691     +++ b/fs/f2fs/file.c
2692     @@ -1512,6 +1512,8 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
2693    
2694     inode_lock(inode);
2695    
2696     + down_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
2697     +
2698     if (f2fs_is_atomic_file(inode))
2699     goto out;
2700    
2701     @@ -1532,6 +1534,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
2702     if (ret)
2703     clear_inode_flag(inode, FI_ATOMIC_FILE);
2704     out:
2705     + up_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
2706     inode_unlock(inode);
2707     mnt_drop_write_file(filp);
2708     return ret;
2709     @@ -1670,9 +1673,11 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
2710     if (get_user(in, (__u32 __user *)arg))
2711     return -EFAULT;
2712    
2713     - ret = mnt_want_write_file(filp);
2714     - if (ret)
2715     - return ret;
2716     + if (in != F2FS_GOING_DOWN_FULLSYNC) {
2717     + ret = mnt_want_write_file(filp);
2718     + if (ret)
2719     + return ret;
2720     + }
2721    
2722     switch (in) {
2723     case F2FS_GOING_DOWN_FULLSYNC:
2724     @@ -1700,7 +1705,8 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
2725     }
2726     f2fs_update_time(sbi, REQ_TIME);
2727     out:
2728     - mnt_drop_write_file(filp);
2729     + if (in != F2FS_GOING_DOWN_FULLSYNC)
2730     + mnt_drop_write_file(filp);
2731     return ret;
2732     }
2733    
2734     diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
2735     index 17ab23f64bba..ad4dfd29d923 100644
2736     --- a/fs/f2fs/gc.c
2737     +++ b/fs/f2fs/gc.c
2738     @@ -688,9 +688,14 @@ retry:
2739     set_cold_data(page);
2740    
2741     err = do_write_data_page(&fio);
2742     - if (err == -ENOMEM && is_dirty) {
2743     - congestion_wait(BLK_RW_ASYNC, HZ/50);
2744     - goto retry;
2745     + if (err) {
2746     + clear_cold_data(page);
2747     + if (err == -ENOMEM) {
2748     + congestion_wait(BLK_RW_ASYNC, HZ/50);
2749     + goto retry;
2750     + }
2751     + if (is_dirty)
2752     + set_page_dirty(page);
2753     }
2754    
2755     clear_cold_data(page);
2756     diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
2757     index e10f61684ea4..35d48ef0573c 100644
2758     --- a/fs/f2fs/segment.c
2759     +++ b/fs/f2fs/segment.c
2760     @@ -207,6 +207,8 @@ static int __revoke_inmem_pages(struct inode *inode,
2761    
2762     lock_page(page);
2763    
2764     + f2fs_wait_on_page_writeback(page, DATA, true);
2765     +
2766     if (recover) {
2767     struct dnode_of_data dn;
2768     struct node_info ni;
2769     @@ -369,6 +371,9 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
2770    
2771     void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
2772     {
2773     + if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
2774     + return;
2775     +
2776     /* try to shrink extent cache when there is no enough memory */
2777     if (!available_free_memory(sbi, EXTENT_CACHE))
2778     f2fs_shrink_extent_tree(sbi, EXTENT_CACHE_SHRINK_NUMBER);
2779     diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
2780     index eb20b8767f3c..e627671f0183 100644
2781     --- a/fs/f2fs/super.c
2782     +++ b/fs/f2fs/super.c
2783     @@ -1980,6 +1980,12 @@ static int __init init_f2fs_fs(void)
2784     {
2785     int err;
2786    
2787     + if (PAGE_SIZE != F2FS_BLKSIZE) {
2788     + printk("F2FS not supported on PAGE_SIZE(%lu) != %d\n",
2789     + PAGE_SIZE, F2FS_BLKSIZE);
2790     + return -EINVAL;
2791     + }
2792     +
2793     f2fs_build_trace_ios();
2794    
2795     err = init_inodecache();
2796     diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
2797     index 91e017ca7072..cf5fdc25289a 100644
2798     --- a/fs/nfs/nfs4proc.c
2799     +++ b/fs/nfs/nfs4proc.c
2800     @@ -2701,7 +2701,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
2801     if (ret != 0)
2802     goto out;
2803    
2804     - state = nfs4_opendata_to_nfs4_state(opendata);
2805     + state = _nfs4_opendata_to_nfs4_state(opendata);
2806     ret = PTR_ERR(state);
2807     if (IS_ERR(state))
2808     goto out;
2809     @@ -2737,6 +2737,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
2810     nfs4_schedule_stateid_recovery(server, state);
2811     }
2812     out:
2813     + nfs4_sequence_free_slot(&opendata->o_res.seq_res);
2814     return ret;
2815     }
2816    
2817     diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
2818     index bdbd9e6d1ace..b16a6c036352 100644
2819     --- a/fs/nfsd/nfs4xdr.c
2820     +++ b/fs/nfsd/nfs4xdr.c
2821     @@ -1536,6 +1536,8 @@ nfsd4_decode_getdeviceinfo(struct nfsd4_compoundargs *argp,
2822     gdev->gd_maxcount = be32_to_cpup(p++);
2823     num = be32_to_cpup(p++);
2824     if (num) {
2825     + if (num > 1000)
2826     + goto xdr_error;
2827     READ_BUF(4 * num);
2828     gdev->gd_notify_types = be32_to_cpup(p++);
2829     for (i = 1; i < num; i++) {
2830     diff --git a/fs/squashfs/cache.c b/fs/squashfs/cache.c
2831     index 23813c078cc9..0839efa720b3 100644
2832     --- a/fs/squashfs/cache.c
2833     +++ b/fs/squashfs/cache.c
2834     @@ -350,6 +350,9 @@ int squashfs_read_metadata(struct super_block *sb, void *buffer,
2835    
2836     TRACE("Entered squashfs_read_metadata [%llx:%x]\n", *block, *offset);
2837    
2838     + if (unlikely(length < 0))
2839     + return -EIO;
2840     +
2841     while (length) {
2842     entry = squashfs_cache_get(sb, msblk->block_cache, *block, 0);
2843     if (entry->error) {
2844     diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
2845     index 13d80947bf9e..fcff2e0487fe 100644
2846     --- a/fs/squashfs/file.c
2847     +++ b/fs/squashfs/file.c
2848     @@ -194,7 +194,11 @@ static long long read_indexes(struct super_block *sb, int n,
2849     }
2850    
2851     for (i = 0; i < blocks; i++) {
2852     - int size = le32_to_cpu(blist[i]);
2853     + int size = squashfs_block_size(blist[i]);
2854     + if (size < 0) {
2855     + err = size;
2856     + goto failure;
2857     + }
2858     block += SQUASHFS_COMPRESSED_SIZE_BLOCK(size);
2859     }
2860     n -= blocks;
2861     @@ -367,7 +371,7 @@ static int read_blocklist(struct inode *inode, int index, u64 *block)
2862     sizeof(size));
2863     if (res < 0)
2864     return res;
2865     - return le32_to_cpu(size);
2866     + return squashfs_block_size(size);
2867     }
2868    
2869     /* Copy data into page cache */
2870     diff --git a/fs/squashfs/fragment.c b/fs/squashfs/fragment.c
2871     index 0ed6edbc5c71..86ad9a4b8c36 100644
2872     --- a/fs/squashfs/fragment.c
2873     +++ b/fs/squashfs/fragment.c
2874     @@ -61,9 +61,7 @@ int squashfs_frag_lookup(struct super_block *sb, unsigned int fragment,
2875     return size;
2876    
2877     *fragment_block = le64_to_cpu(fragment_entry.start_block);
2878     - size = le32_to_cpu(fragment_entry.size);
2879     -
2880     - return size;
2881     + return squashfs_block_size(fragment_entry.size);
2882     }
2883    
2884    
2885     diff --git a/fs/squashfs/squashfs_fs.h b/fs/squashfs/squashfs_fs.h
2886     index 506f4ba5b983..e66486366f02 100644
2887     --- a/fs/squashfs/squashfs_fs.h
2888     +++ b/fs/squashfs/squashfs_fs.h
2889     @@ -129,6 +129,12 @@
2890    
2891     #define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
2892    
2893     +static inline int squashfs_block_size(__le32 raw)
2894     +{
2895     + u32 size = le32_to_cpu(raw);
2896     + return (size >> 25) ? -EIO : size;
2897     +}
2898     +
2899     /*
2900     * Inode number ops. Inodes consist of a compressed block number, and an
2901     * uncompressed offset within that block
2902     diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
2903     index 2a79882cb68e..2fff10de317d 100644
2904     --- a/include/drm/drm_dp_helper.h
2905     +++ b/include/drm/drm_dp_helper.h
2906     @@ -345,6 +345,7 @@
2907     # define DP_PSR_FRAME_CAPTURE (1 << 3)
2908     # define DP_PSR_SELECTIVE_UPDATE (1 << 4)
2909     # define DP_PSR_IRQ_HPD_WITH_CRC_ERRORS (1 << 5)
2910     +# define DP_PSR_ENABLE_PSR2 (1 << 6) /* eDP 1.4a */
2911    
2912     #define DP_ADAPTER_CTRL 0x1a0
2913     # define DP_ADAPTER_CTRL_FORCE_LOAD_SENSE (1 << 0)
2914     diff --git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h
2915     index 32c589062bd9..f30d23011060 100644
2916     --- a/include/linux/dma-iommu.h
2917     +++ b/include/linux/dma-iommu.h
2918     @@ -17,6 +17,7 @@
2919     #define __DMA_IOMMU_H
2920    
2921     #ifdef __KERNEL__
2922     +#include <linux/types.h>
2923     #include <asm/errno.h>
2924    
2925     #ifdef CONFIG_IOMMU_DMA
2926     diff --git a/include/linux/mmc/sdio_ids.h b/include/linux/mmc/sdio_ids.h
2927     index d43ef96bf075..3e4d4f4bccd3 100644
2928     --- a/include/linux/mmc/sdio_ids.h
2929     +++ b/include/linux/mmc/sdio_ids.h
2930     @@ -34,6 +34,7 @@
2931     #define SDIO_DEVICE_ID_BROADCOM_4335_4339 0x4335
2932     #define SDIO_DEVICE_ID_BROADCOM_4339 0x4339
2933     #define SDIO_DEVICE_ID_BROADCOM_43362 0xa962
2934     +#define SDIO_DEVICE_ID_BROADCOM_43364 0xa9a4
2935     #define SDIO_DEVICE_ID_BROADCOM_43430 0xa9a6
2936     #define SDIO_DEVICE_ID_BROADCOM_4345 0x4345
2937     #define SDIO_DEVICE_ID_BROADCOM_4354 0x4354
2938     diff --git a/include/linux/netfilter/ipset/ip_set_timeout.h b/include/linux/netfilter/ipset/ip_set_timeout.h
2939     index 1d6a935c1ac5..8793f5a7b820 100644
2940     --- a/include/linux/netfilter/ipset/ip_set_timeout.h
2941     +++ b/include/linux/netfilter/ipset/ip_set_timeout.h
2942     @@ -65,8 +65,14 @@ ip_set_timeout_set(unsigned long *timeout, u32 value)
2943     static inline u32
2944     ip_set_timeout_get(unsigned long *timeout)
2945     {
2946     - return *timeout == IPSET_ELEM_PERMANENT ? 0 :
2947     - jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
2948     + u32 t;
2949     +
2950     + if (*timeout == IPSET_ELEM_PERMANENT)
2951     + return 0;
2952     +
2953     + t = jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
2954     + /* Zero value in userspace means no timeout */
2955     + return t == 0 ? 1 : t;
2956     }
2957    
2958     #endif /* __KERNEL__ */
2959     diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
2960     index 7b16c5322673..eb4f6456521e 100644
2961     --- a/include/linux/serial_core.h
2962     +++ b/include/linux/serial_core.h
2963     @@ -344,7 +344,8 @@ struct earlycon_device {
2964     };
2965    
2966     struct earlycon_id {
2967     - char name[16];
2968     + char name[15];
2969     + char name_term; /* In case compiler didn't '\0' term name */
2970     char compatible[128];
2971     int (*setup)(struct earlycon_device *, const char *options);
2972     };
2973     diff --git a/include/soc/tegra/mc.h b/include/soc/tegra/mc.h
2974     index 44202ff897fd..f759e0918037 100644
2975     --- a/include/soc/tegra/mc.h
2976     +++ b/include/soc/tegra/mc.h
2977     @@ -99,6 +99,8 @@ struct tegra_mc_soc {
2978     u8 client_id_mask;
2979    
2980     const struct tegra_smmu_soc *smmu;
2981     +
2982     + u32 intmask;
2983     };
2984    
2985     struct tegra_mc {
2986     diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
2987     index 85d9cac497e4..cd4f41397c7e 100644
2988     --- a/kernel/auditfilter.c
2989     +++ b/kernel/auditfilter.c
2990     @@ -406,7 +406,7 @@ static int audit_field_valid(struct audit_entry *entry, struct audit_field *f)
2991     return -EINVAL;
2992     break;
2993     case AUDIT_EXE:
2994     - if (f->op != Audit_equal)
2995     + if (f->op != Audit_not_equal && f->op != Audit_equal)
2996     return -EINVAL;
2997     if (entry->rule.listnr != AUDIT_FILTER_EXIT)
2998     return -EINVAL;
2999     diff --git a/kernel/auditsc.c b/kernel/auditsc.c
3000     index 2cd5256dbff7..c2aaf539728f 100644
3001     --- a/kernel/auditsc.c
3002     +++ b/kernel/auditsc.c
3003     @@ -469,6 +469,8 @@ static int audit_filter_rules(struct task_struct *tsk,
3004     break;
3005     case AUDIT_EXE:
3006     result = audit_exe_compare(tsk, rule->exe);
3007     + if (f->op == Audit_not_equal)
3008     + result = !result;
3009     break;
3010     case AUDIT_UID:
3011     result = audit_uid_comparator(cred->uid, f->op, f->uid);
3012     diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
3013     index 076e4a0ff95e..dafa2708ce9e 100644
3014     --- a/kernel/bpf/verifier.c
3015     +++ b/kernel/bpf/verifier.c
3016     @@ -3225,7 +3225,7 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
3017     /* hold the map. If the program is rejected by verifier,
3018     * the map will be released by release_maps() or it
3019     * will be used by the valid program until it's unloaded
3020     - * and all maps are released in free_bpf_prog_info()
3021     + * and all maps are released in free_used_maps()
3022     */
3023     map = bpf_map_inc(map, false);
3024     if (IS_ERR(map)) {
3025     @@ -3629,7 +3629,7 @@ free_log_buf:
3026     vfree(log_buf);
3027     if (!env->prog->aux->used_maps)
3028     /* if we didn't copy map pointers into bpf_prog_info, release
3029     - * them now. Otherwise free_bpf_prog_info() will release them.
3030     + * them now. Otherwise free_used_maps() will release them.
3031     */
3032     release_maps(env);
3033     *prog = env->prog;
3034     diff --git a/kernel/kcov.c b/kernel/kcov.c
3035     index 3883df58aa12..b0ec31493fdc 100644
3036     --- a/kernel/kcov.c
3037     +++ b/kernel/kcov.c
3038     @@ -103,7 +103,8 @@ static void kcov_put(struct kcov *kcov)
3039    
3040     void kcov_task_init(struct task_struct *t)
3041     {
3042     - t->kcov_mode = KCOV_MODE_DISABLED;
3043     + WRITE_ONCE(t->kcov_mode, KCOV_MODE_DISABLED);
3044     + barrier();
3045     t->kcov_size = 0;
3046     t->kcov_area = NULL;
3047     t->kcov = NULL;
3048     diff --git a/kernel/kthread.c b/kernel/kthread.c
3049     index c2c911a106cf..fbc230e41969 100644
3050     --- a/kernel/kthread.c
3051     +++ b/kernel/kthread.c
3052     @@ -290,8 +290,14 @@ static struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
3053     task = create->result;
3054     if (!IS_ERR(task)) {
3055     static const struct sched_param param = { .sched_priority = 0 };
3056     + char name[TASK_COMM_LEN];
3057    
3058     - vsnprintf(task->comm, sizeof(task->comm), namefmt, args);
3059     + /*
3060     + * task is already visible to other tasks, so updating
3061     + * COMM must be protected.
3062     + */
3063     + vsnprintf(name, sizeof(name), namefmt, args);
3064     + set_task_comm(task, name);
3065     /*
3066     * root may have changed our (kthreadd's) priority or CPU mask.
3067     * The kernel thread should not inherit these properties.
3068     diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
3069     index ec9ab2f01489..9b8cd7ebf27b 100644
3070     --- a/kernel/stop_machine.c
3071     +++ b/kernel/stop_machine.c
3072     @@ -36,7 +36,7 @@ struct cpu_stop_done {
3073     struct cpu_stopper {
3074     struct task_struct *thread;
3075    
3076     - spinlock_t lock;
3077     + raw_spinlock_t lock;
3078     bool enabled; /* is this stopper enabled? */
3079     struct list_head works; /* list of pending works */
3080    
3081     @@ -78,13 +78,13 @@ static bool cpu_stop_queue_work(unsigned int cpu, struct cpu_stop_work *work)
3082     unsigned long flags;
3083     bool enabled;
3084    
3085     - spin_lock_irqsave(&stopper->lock, flags);
3086     + raw_spin_lock_irqsave(&stopper->lock, flags);
3087     enabled = stopper->enabled;
3088     if (enabled)
3089     __cpu_stop_queue_work(stopper, work);
3090     else if (work->done)
3091     cpu_stop_signal_done(work->done);
3092     - spin_unlock_irqrestore(&stopper->lock, flags);
3093     + raw_spin_unlock_irqrestore(&stopper->lock, flags);
3094    
3095     return enabled;
3096     }
3097     @@ -231,8 +231,8 @@ static int cpu_stop_queue_two_works(int cpu1, struct cpu_stop_work *work1,
3098     struct cpu_stopper *stopper2 = per_cpu_ptr(&cpu_stopper, cpu2);
3099     int err;
3100     retry:
3101     - spin_lock_irq(&stopper1->lock);
3102     - spin_lock_nested(&stopper2->lock, SINGLE_DEPTH_NESTING);
3103     + raw_spin_lock_irq(&stopper1->lock);
3104     + raw_spin_lock_nested(&stopper2->lock, SINGLE_DEPTH_NESTING);
3105    
3106     err = -ENOENT;
3107     if (!stopper1->enabled || !stopper2->enabled)
3108     @@ -255,8 +255,8 @@ retry:
3109     __cpu_stop_queue_work(stopper1, work1);
3110     __cpu_stop_queue_work(stopper2, work2);
3111     unlock:
3112     - spin_unlock(&stopper2->lock);
3113     - spin_unlock_irq(&stopper1->lock);
3114     + raw_spin_unlock(&stopper2->lock);
3115     + raw_spin_unlock_irq(&stopper1->lock);
3116    
3117     if (unlikely(err == -EDEADLK)) {
3118     while (stop_cpus_in_progress)
3119     @@ -448,9 +448,9 @@ static int cpu_stop_should_run(unsigned int cpu)
3120     unsigned long flags;
3121     int run;
3122    
3123     - spin_lock_irqsave(&stopper->lock, flags);
3124     + raw_spin_lock_irqsave(&stopper->lock, flags);
3125     run = !list_empty(&stopper->works);
3126     - spin_unlock_irqrestore(&stopper->lock, flags);
3127     + raw_spin_unlock_irqrestore(&stopper->lock, flags);
3128     return run;
3129     }
3130    
3131     @@ -461,13 +461,13 @@ static void cpu_stopper_thread(unsigned int cpu)
3132    
3133     repeat:
3134     work = NULL;
3135     - spin_lock_irq(&stopper->lock);
3136     + raw_spin_lock_irq(&stopper->lock);
3137     if (!list_empty(&stopper->works)) {
3138     work = list_first_entry(&stopper->works,
3139     struct cpu_stop_work, list);
3140     list_del_init(&work->list);
3141     }
3142     - spin_unlock_irq(&stopper->lock);
3143     + raw_spin_unlock_irq(&stopper->lock);
3144    
3145     if (work) {
3146     cpu_stop_fn_t fn = work->fn;
3147     @@ -541,7 +541,7 @@ static int __init cpu_stop_init(void)
3148     for_each_possible_cpu(cpu) {
3149     struct cpu_stopper *stopper = &per_cpu(cpu_stopper, cpu);
3150    
3151     - spin_lock_init(&stopper->lock);
3152     + raw_spin_lock_init(&stopper->lock);
3153     INIT_LIST_HEAD(&stopper->works);
3154     }
3155    
3156     diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
3157     index 88f398af57fa..8819944bbcbf 100644
3158     --- a/kernel/trace/trace_events_trigger.c
3159     +++ b/kernel/trace/trace_events_trigger.c
3160     @@ -678,6 +678,8 @@ event_trigger_callback(struct event_command *cmd_ops,
3161     goto out_free;
3162    
3163     out_reg:
3164     + /* Up the trigger_data count to make sure reg doesn't free it on failure */
3165     + event_trigger_init(trigger_ops, trigger_data);
3166     ret = cmd_ops->reg(glob, trigger_ops, trigger_data, file);
3167     /*
3168     * The above returns on success the # of functions enabled,
3169     @@ -685,11 +687,13 @@ event_trigger_callback(struct event_command *cmd_ops,
3170     * Consider no functions a failure too.
3171     */
3172     if (!ret) {
3173     + cmd_ops->unreg(glob, trigger_ops, trigger_data, file);
3174     ret = -ENOENT;
3175     - goto out_free;
3176     - } else if (ret < 0)
3177     - goto out_free;
3178     - ret = 0;
3179     + } else if (ret > 0)
3180     + ret = 0;
3181     +
3182     + /* Down the counter of trigger_data or free it if not used anymore */
3183     + event_trigger_free(trigger_ops, trigger_data);
3184     out:
3185     return ret;
3186    
3187     @@ -1385,6 +1389,9 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
3188     goto out;
3189     }
3190    
3191     + /* Up the trigger_data count to make sure nothing frees it on failure */
3192     + event_trigger_init(trigger_ops, trigger_data);
3193     +
3194     if (trigger) {
3195     number = strsep(&trigger, ":");
3196    
3197     @@ -1435,6 +1442,7 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
3198     goto out_disable;
3199     /* Just return zero, not the number of enabled functions */
3200     ret = 0;
3201     + event_trigger_free(trigger_ops, trigger_data);
3202     out:
3203     return ret;
3204    
3205     @@ -1445,7 +1453,7 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
3206     out_free:
3207     if (cmd_ops->set_filter)
3208     cmd_ops->set_filter(NULL, trigger_data, NULL);
3209     - kfree(trigger_data);
3210     + event_trigger_free(trigger_ops, trigger_data);
3211     kfree(enable_data);
3212     goto out;
3213     }
3214     diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
3215     index ea3ed03fed7e..3b4cd44ad323 100644
3216     --- a/kernel/trace/trace_kprobe.c
3217     +++ b/kernel/trace/trace_kprobe.c
3218     @@ -359,11 +359,10 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
3219     static int
3220     enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
3221     {
3222     + struct event_file_link *link = NULL;
3223     int ret = 0;
3224    
3225     if (file) {
3226     - struct event_file_link *link;
3227     -
3228     link = kmalloc(sizeof(*link), GFP_KERNEL);
3229     if (!link) {
3230     ret = -ENOMEM;
3231     @@ -383,6 +382,18 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
3232     else
3233     ret = enable_kprobe(&tk->rp.kp);
3234     }
3235     +
3236     + if (ret) {
3237     + if (file) {
3238     + /* Notice the if is true on not WARN() */
3239     + if (!WARN_ON_ONCE(!link))
3240     + list_del_rcu(&link->list);
3241     + kfree(link);
3242     + tk->tp.flags &= ~TP_FLAG_TRACE;
3243     + } else {
3244     + tk->tp.flags &= ~TP_FLAG_PROFILE;
3245     + }
3246     + }
3247     out:
3248     return ret;
3249     }
3250     diff --git a/mm/slub.c b/mm/slub.c
3251     index edc79ca3c6d5..e0ce5dec84ba 100644
3252     --- a/mm/slub.c
3253     +++ b/mm/slub.c
3254     @@ -673,7 +673,7 @@ void object_err(struct kmem_cache *s, struct page *page,
3255     print_trailer(s, page, object);
3256     }
3257    
3258     -static void slab_err(struct kmem_cache *s, struct page *page,
3259     +static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page,
3260     const char *fmt, ...)
3261     {
3262     va_list args;
3263     diff --git a/mm/vmalloc.c b/mm/vmalloc.c
3264     index 195de42bea1f..fa598162dbf0 100644
3265     --- a/mm/vmalloc.c
3266     +++ b/mm/vmalloc.c
3267     @@ -1494,7 +1494,7 @@ static void __vunmap(const void *addr, int deallocate_pages)
3268     addr))
3269     return;
3270    
3271     - area = remove_vm_area(addr);
3272     + area = find_vmap_area((unsigned long)addr)->vm;
3273     if (unlikely(!area)) {
3274     WARN(1, KERN_ERR "Trying to vfree() nonexistent vm area (%p)\n",
3275     addr);
3276     @@ -1504,6 +1504,7 @@ static void __vunmap(const void *addr, int deallocate_pages)
3277     debug_check_no_locks_freed(addr, get_vm_area_size(area));
3278     debug_check_no_obj_freed(addr, get_vm_area_size(area));
3279    
3280     + remove_vm_area(addr);
3281     if (deallocate_pages) {
3282     int i;
3283    
3284     diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
3285     index b23464d9c538..d278b06459ac 100644
3286     --- a/net/ipv4/ipconfig.c
3287     +++ b/net/ipv4/ipconfig.c
3288     @@ -779,6 +779,11 @@ static void __init ic_bootp_init_ext(u8 *e)
3289     */
3290     static inline void __init ic_bootp_init(void)
3291     {
3292     + /* Re-initialise all name servers to NONE, in case any were set via the
3293     + * "ip=" or "nfsaddrs=" kernel command line parameters: any IP addresses
3294     + * specified there will already have been decoded but are no longer
3295     + * needed
3296     + */
3297     ic_nameservers_predef();
3298    
3299     dev_add_pack(&bootp_packet_type);
3300     @@ -1401,6 +1406,13 @@ static int __init ip_auto_config(void)
3301     int err;
3302     unsigned int i;
3303    
3304     + /* Initialise all name servers to NONE (but only if the "ip=" or
3305     + * "nfsaddrs=" kernel command line parameters weren't decoded, otherwise
3306     + * we'll overwrite the IP addresses specified there)
3307     + */
3308     + if (ic_set_manually == 0)
3309     + ic_nameservers_predef();
3310     +
3311     #ifdef CONFIG_PROC_FS
3312     proc_create("pnp", S_IRUGO, init_net.proc_net, &pnp_seq_fops);
3313     #endif /* CONFIG_PROC_FS */
3314     @@ -1621,6 +1633,7 @@ static int __init ip_auto_config_setup(char *addrs)
3315     return 1;
3316     }
3317    
3318     + /* Initialise all name servers to NONE */
3319     ic_nameservers_predef();
3320    
3321     /* Parse string for static IP assignment. */
3322     diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
3323     index 762f31fb5b67..a3fb30f5a1a9 100644
3324     --- a/net/netfilter/nf_tables_api.c
3325     +++ b/net/netfilter/nf_tables_api.c
3326     @@ -2476,12 +2476,13 @@ struct nft_set *nf_tables_set_lookup_byid(const struct net *net,
3327     u32 id = ntohl(nla_get_be32(nla));
3328    
3329     list_for_each_entry(trans, &net->nft.commit_list, list) {
3330     - struct nft_set *set = nft_trans_set(trans);
3331     + if (trans->msg_type == NFT_MSG_NEWSET) {
3332     + struct nft_set *set = nft_trans_set(trans);
3333    
3334     - if (trans->msg_type == NFT_MSG_NEWSET &&
3335     - id == nft_trans_set_id(trans) &&
3336     - nft_active_genmask(set, genmask))
3337     - return set;
3338     + if (id == nft_trans_set_id(trans) &&
3339     + nft_active_genmask(set, genmask))
3340     + return set;
3341     + }
3342     }
3343     return ERR_PTR(-ENOENT);
3344     }
3345     diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
3346     index a71f906b4f7a..9652541c4d43 100644
3347     --- a/security/integrity/ima/ima_main.c
3348     +++ b/security/integrity/ima/ima_main.c
3349     @@ -379,6 +379,7 @@ int ima_read_file(struct file *file, enum kernel_read_file_id read_id)
3350    
3351     static int read_idmap[READING_MAX_ID] = {
3352     [READING_FIRMWARE] = FIRMWARE_CHECK,
3353     + [READING_FIRMWARE_PREALLOC_BUFFER] = FIRMWARE_CHECK,
3354     [READING_MODULE] = MODULE_CHECK,
3355     [READING_KEXEC_IMAGE] = KEXEC_KERNEL_CHECK,
3356     [READING_KEXEC_INITRAMFS] = KEXEC_INITRAMFS_CHECK,
3357     diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
3358     index 37be1e14d756..0d2bb30d9f7e 100644
3359     --- a/sound/pci/emu10k1/emupcm.c
3360     +++ b/sound/pci/emu10k1/emupcm.c
3361     @@ -1850,7 +1850,9 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device)
3362     if (!kctl)
3363     return -ENOMEM;
3364     kctl->id.device = device;
3365     - snd_ctl_add(emu->card, kctl);
3366     + err = snd_ctl_add(emu->card, kctl);
3367     + if (err < 0)
3368     + return err;
3369    
3370     snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024);
3371    
3372     diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c
3373     index 4f1f69be1865..8c778fa33031 100644
3374     --- a/sound/pci/emu10k1/memory.c
3375     +++ b/sound/pci/emu10k1/memory.c
3376     @@ -237,13 +237,13 @@ __found_pages:
3377     static int is_valid_page(struct snd_emu10k1 *emu, dma_addr_t addr)
3378     {
3379     if (addr & ~emu->dma_mask) {
3380     - dev_err(emu->card->dev,
3381     + dev_err_ratelimited(emu->card->dev,
3382     "max memory size is 0x%lx (addr = 0x%lx)!!\n",
3383     emu->dma_mask, (unsigned long)addr);
3384     return 0;
3385     }
3386     if (addr & (EMUPAGESIZE-1)) {
3387     - dev_err(emu->card->dev, "page is not aligned\n");
3388     + dev_err_ratelimited(emu->card->dev, "page is not aligned\n");
3389     return 0;
3390     }
3391     return 1;
3392     @@ -334,7 +334,7 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst
3393     else
3394     addr = snd_pcm_sgbuf_get_addr(substream, ofs);
3395     if (! is_valid_page(emu, addr)) {
3396     - dev_err(emu->card->dev,
3397     + dev_err_ratelimited(emu->card->dev,
3398     "emu: failure page = %d\n", idx);
3399     mutex_unlock(&hdr->block_mutex);
3400     return NULL;
3401     diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
3402     index a178e0d03088..8561f60b4284 100644
3403     --- a/sound/pci/fm801.c
3404     +++ b/sound/pci/fm801.c
3405     @@ -1068,11 +1068,19 @@ static int snd_fm801_mixer(struct fm801 *chip)
3406     if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97_sec)) < 0)
3407     return err;
3408     }
3409     - for (i = 0; i < FM801_CONTROLS; i++)
3410     - snd_ctl_add(chip->card, snd_ctl_new1(&snd_fm801_controls[i], chip));
3411     + for (i = 0; i < FM801_CONTROLS; i++) {
3412     + err = snd_ctl_add(chip->card,
3413     + snd_ctl_new1(&snd_fm801_controls[i], chip));
3414     + if (err < 0)
3415     + return err;
3416     + }
3417     if (chip->multichannel) {
3418     - for (i = 0; i < FM801_CONTROLS_MULTI; i++)
3419     - snd_ctl_add(chip->card, snd_ctl_new1(&snd_fm801_controls_multi[i], chip));
3420     + for (i = 0; i < FM801_CONTROLS_MULTI; i++) {
3421     + err = snd_ctl_add(chip->card,
3422     + snd_ctl_new1(&snd_fm801_controls_multi[i], chip));
3423     + if (err < 0)
3424     + return err;
3425     + }
3426     }
3427     return 0;
3428     }
3429     diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
3430     index 9ec4dba8a793..280999961226 100644
3431     --- a/sound/pci/hda/patch_ca0132.c
3432     +++ b/sound/pci/hda/patch_ca0132.c
3433     @@ -38,6 +38,10 @@
3434     /* Enable this to see controls for tuning purpose. */
3435     /*#define ENABLE_TUNING_CONTROLS*/
3436    
3437     +#ifdef ENABLE_TUNING_CONTROLS
3438     +#include <sound/tlv.h>
3439     +#endif
3440     +
3441     #define FLOAT_ZERO 0x00000000
3442     #define FLOAT_ONE 0x3f800000
3443     #define FLOAT_TWO 0x40000000
3444     @@ -3067,8 +3071,8 @@ static int equalizer_ctl_put(struct snd_kcontrol *kcontrol,
3445     return 1;
3446     }
3447    
3448     -static const DECLARE_TLV_DB_SCALE(voice_focus_db_scale, 2000, 100, 0);
3449     -static const DECLARE_TLV_DB_SCALE(eq_db_scale, -2400, 100, 0);
3450     +static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(voice_focus_db_scale, 2000, 100, 0);
3451     +static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(eq_db_scale, -2400, 100, 0);
3452    
3453     static int add_tuning_control(struct hda_codec *codec,
3454     hda_nid_t pnid, hda_nid_t nid,
3455     diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
3456     index 80088c98ce27..20680a490897 100644
3457     --- a/sound/soc/soc-pcm.c
3458     +++ b/sound/soc/soc-pcm.c
3459     @@ -1793,8 +1793,10 @@ int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream)
3460     continue;
3461    
3462     if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) &&
3463     - (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN))
3464     - continue;
3465     + (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN)) {
3466     + soc_pcm_hw_free(be_substream);
3467     + be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE;
3468     + }
3469    
3470     dev_dbg(be->dev, "ASoC: close BE %s\n",
3471     be->dai_link->name);
3472     diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
3473     index c5dfe82beb24..e6ac7b9b4648 100644
3474     --- a/sound/usb/pcm.c
3475     +++ b/sound/usb/pcm.c
3476     @@ -1310,7 +1310,7 @@ static void retire_capture_urb(struct snd_usb_substream *subs,
3477     if (bytes % (runtime->sample_bits >> 3) != 0) {
3478     int oldbytes = bytes;
3479     bytes = frames * stride;
3480     - dev_warn(&subs->dev->dev,
3481     + dev_warn_ratelimited(&subs->dev->dev,
3482     "Corrected urb data len. %d->%d\n",
3483     oldbytes, bytes);
3484     }
3485     diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
3486     index 879115f93edc..98a4205a5f8a 100644
3487     --- a/tools/perf/util/parse-events.y
3488     +++ b/tools/perf/util/parse-events.y
3489     @@ -68,6 +68,7 @@ static void inc_group_count(struct list_head *list,
3490     %type <num> value_sym
3491     %type <head> event_config
3492     %type <head> opt_event_config
3493     +%type <head> opt_pmu_config
3494     %type <term> event_term
3495     %type <head> event_pmu
3496     %type <head> event_legacy_symbol
3497     @@ -219,7 +220,7 @@ event_def: event_pmu |
3498     event_bpf_file
3499    
3500     event_pmu:
3501     -PE_NAME opt_event_config
3502     +PE_NAME opt_pmu_config
3503     {
3504     struct parse_events_evlist *data = _data;
3505     struct list_head *list;
3506     @@ -482,6 +483,17 @@ opt_event_config:
3507     $$ = NULL;
3508     }
3509    
3510     +opt_pmu_config:
3511     +'/' event_config '/'
3512     +{
3513     + $$ = $2;
3514     +}
3515     +|
3516     +'/' '/'
3517     +{
3518     + $$ = NULL;
3519     +}
3520     +
3521     start_terms: event_config
3522     {
3523     struct parse_events_terms *data = _data;
3524     diff --git a/tools/testing/selftests/intel_pstate/run.sh b/tools/testing/selftests/intel_pstate/run.sh
3525     index 7868c106b8b1..b62876f41eca 100755
3526     --- a/tools/testing/selftests/intel_pstate/run.sh
3527     +++ b/tools/testing/selftests/intel_pstate/run.sh
3528     @@ -48,11 +48,12 @@ function run_test () {
3529    
3530     echo "sleeping for 5 seconds"
3531     sleep 5
3532     - num_freqs=$(cat /proc/cpuinfo | grep MHz | sort -u | wc -l)
3533     - if [ $num_freqs -le 2 ]; then
3534     - cat /proc/cpuinfo | grep MHz | sort -u | tail -1 > /tmp/result.$1
3535     + grep MHz /proc/cpuinfo | sort -u > /tmp/result.freqs
3536     + num_freqs=$(wc -l /tmp/result.freqs | awk ' { print $1 } ')
3537     + if [ $num_freqs -ge 2 ]; then
3538     + tail -n 1 /tmp/result.freqs > /tmp/result.$1
3539     else
3540     - cat /proc/cpuinfo | grep MHz | sort -u > /tmp/result.$1
3541     + cp /tmp/result.freqs /tmp/result.$1
3542     fi
3543     ./msr 0 >> /tmp/result.$1
3544    
3545     @@ -82,21 +83,20 @@ _max_freq=$(cpupower frequency-info -l | tail -1 | awk ' { print $2 } ')
3546     max_freq=$(($_max_freq / 1000))
3547    
3548    
3549     -for freq in `seq $max_freq -100 $min_freq`
3550     +[ $EVALUATE_ONLY -eq 0 ] && for freq in `seq $max_freq -100 $min_freq`
3551     do
3552     echo "Setting maximum frequency to $freq"
3553     cpupower frequency-set -g powersave --max=${freq}MHz >& /dev/null
3554     - [ $EVALUATE_ONLY -eq 0 ] && run_test $freq
3555     + run_test $freq
3556     done
3557    
3558     -echo "=============================================================================="
3559     +[ $EVALUATE_ONLY -eq 0 ] && cpupower frequency-set -g powersave --max=${max_freq}MHz >& /dev/null
3560    
3561     +echo "=============================================================================="
3562     echo "The marketing frequency of the cpu is $mkt_freq MHz"
3563     echo "The maximum frequency of the cpu is $max_freq MHz"
3564     echo "The minimum frequency of the cpu is $min_freq MHz"
3565    
3566     -cpupower frequency-set -g powersave --max=${max_freq}MHz >& /dev/null
3567     -
3568     # make a pretty table
3569     echo "Target Actual Difference MSR(0x199) max_perf_pct"
3570     for freq in `seq $max_freq -100 $min_freq`
3571     @@ -104,10 +104,6 @@ do
3572     result_freq=$(cat /tmp/result.${freq} | grep "cpu MHz" | awk ' { print $4 } ' | awk -F "." ' { print $1 } ')
3573     msr=$(cat /tmp/result.${freq} | grep "msr" | awk ' { print $3 } ')
3574     max_perf_pct=$(cat /tmp/result.${freq} | grep "max_perf_pct" | awk ' { print $2 } ' )
3575     - if [ $result_freq -eq $freq ]; then
3576     - echo " $freq $result_freq 0 $msr $(($max_perf_pct*3300))"
3577     - else
3578     - echo " $freq $result_freq $(($result_freq-$freq)) $msr $(($max_perf_pct*$max_freq))"
3579     - fi
3580     + echo " $freq $result_freq $(($result_freq-$freq)) $msr $(($max_perf_pct*$max_freq))"
3581     done
3582     exit 0
3583     diff --git a/tools/usb/usbip/src/usbip_detach.c b/tools/usb/usbip/src/usbip_detach.c
3584     index 9db9d21bb2ec..6a8db858caa5 100644
3585     --- a/tools/usb/usbip/src/usbip_detach.c
3586     +++ b/tools/usb/usbip/src/usbip_detach.c
3587     @@ -43,7 +43,7 @@ void usbip_detach_usage(void)
3588    
3589     static int detach_port(char *port)
3590     {
3591     - int ret;
3592     + int ret = 0;
3593     uint8_t portnum;
3594     char path[PATH_MAX+1];
3595    
3596     @@ -73,9 +73,12 @@ static int detach_port(char *port)
3597     }
3598    
3599     ret = usbip_vhci_detach_device(portnum);
3600     - if (ret < 0)
3601     - return -1;
3602     + if (ret < 0) {
3603     + ret = -1;
3604     + goto call_driver_close;
3605     + }
3606    
3607     +call_driver_close:
3608     usbip_vhci_driver_close();
3609    
3610     return ret;