Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.14/0130-4.14.31-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3238 - (hide annotations) (download)
Fri Nov 9 12:14:58 2018 UTC (5 years, 7 months ago) by niro
File size: 134679 byte(s)
-added up to patches-4.14.79
1 niro 3238 diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
2     index 7eead5f97e02..64e65450f483 100644
3     --- a/Documentation/ABI/testing/sysfs-bus-iio
4     +++ b/Documentation/ABI/testing/sysfs-bus-iio
5     @@ -32,7 +32,7 @@ Description:
6     Description of the physical chip / device for device X.
7     Typically a part number.
8    
9     -What: /sys/bus/iio/devices/iio:deviceX/timestamp_clock
10     +What: /sys/bus/iio/devices/iio:deviceX/current_timestamp_clock
11     KernelVersion: 4.5
12     Contact: linux-iio@vger.kernel.org
13     Description:
14     diff --git a/Makefile b/Makefile
15     index 29fc3c91f3e4..99e31da48422 100644
16     --- a/Makefile
17     +++ b/Makefile
18     @@ -1,7 +1,7 @@
19     # SPDX-License-Identifier: GPL-2.0
20     VERSION = 4
21     PATCHLEVEL = 14
22     -SUBLEVEL = 30
23     +SUBLEVEL = 31
24     EXTRAVERSION =
25     NAME = Petit Gorille
26    
27     @@ -805,6 +805,15 @@ KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign)
28     # disable invalid "can't wrap" optimizations for signed / pointers
29     KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
30    
31     +# clang sets -fmerge-all-constants by default as optimization, but this
32     +# is non-conforming behavior for C and in fact breaks the kernel, so we
33     +# need to disable it here generally.
34     +KBUILD_CFLAGS += $(call cc-option,-fno-merge-all-constants)
35     +
36     +# for gcc -fno-merge-all-constants disables everything, but it is fine
37     +# to have actual conforming behavior enabled.
38     +KBUILD_CFLAGS += $(call cc-option,-fmerge-constants)
39     +
40     # Make sure -fstack-check isn't enabled (like gentoo apparently did)
41     KBUILD_CFLAGS += $(call cc-option,-fno-stack-check,)
42    
43     diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
44     index 01bc0688d47d..f6b877d2726d 100644
45     --- a/arch/arm64/mm/mmu.c
46     +++ b/arch/arm64/mm/mmu.c
47     @@ -937,3 +937,13 @@ int pmd_clear_huge(pmd_t *pmd)
48     pmd_clear(pmd);
49     return 1;
50     }
51     +
52     +int pud_free_pmd_page(pud_t *pud)
53     +{
54     + return pud_none(*pud);
55     +}
56     +
57     +int pmd_free_pte_page(pmd_t *pmd)
58     +{
59     + return pmd_none(*pmd);
60     +}
61     diff --git a/arch/h8300/include/asm/byteorder.h b/arch/h8300/include/asm/byteorder.h
62     index ecff2d1ca5a3..6eaa7ad5fc2c 100644
63     --- a/arch/h8300/include/asm/byteorder.h
64     +++ b/arch/h8300/include/asm/byteorder.h
65     @@ -2,7 +2,6 @@
66     #ifndef __H8300_BYTEORDER_H__
67     #define __H8300_BYTEORDER_H__
68    
69     -#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
70     #include <linux/byteorder/big_endian.h>
71    
72     #endif
73     diff --git a/arch/mips/lantiq/Kconfig b/arch/mips/lantiq/Kconfig
74     index 692ae85a3e3d..8e3a1fc2bc39 100644
75     --- a/arch/mips/lantiq/Kconfig
76     +++ b/arch/mips/lantiq/Kconfig
77     @@ -13,6 +13,8 @@ choice
78     config SOC_AMAZON_SE
79     bool "Amazon SE"
80     select SOC_TYPE_XWAY
81     + select MFD_SYSCON
82     + select MFD_CORE
83    
84     config SOC_XWAY
85     bool "XWAY"
86     diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c
87     index 7611c3013793..c05bed624075 100644
88     --- a/arch/mips/lantiq/xway/sysctrl.c
89     +++ b/arch/mips/lantiq/xway/sysctrl.c
90     @@ -551,9 +551,9 @@ void __init ltq_soc_init(void)
91     clkdev_add_static(ltq_ar9_cpu_hz(), ltq_ar9_fpi_hz(),
92     ltq_ar9_fpi_hz(), CLOCK_250M);
93     clkdev_add_pmu("1f203018.usb2-phy", "phy", 1, 0, PMU_USB0_P);
94     - clkdev_add_pmu("1e101000.usb", "otg", 1, 0, PMU_USB0);
95     + clkdev_add_pmu("1e101000.usb", "otg", 1, 0, PMU_USB0 | PMU_AHBM);
96     clkdev_add_pmu("1f203034.usb2-phy", "phy", 1, 0, PMU_USB1_P);
97     - clkdev_add_pmu("1e106000.usb", "otg", 1, 0, PMU_USB1);
98     + clkdev_add_pmu("1e106000.usb", "otg", 1, 0, PMU_USB1 | PMU_AHBM);
99     clkdev_add_pmu("1e180000.etop", "switch", 1, 0, PMU_SWITCH);
100     clkdev_add_pmu("1e103000.sdio", NULL, 1, 0, PMU_SDIO);
101     clkdev_add_pmu("1e103100.deu", NULL, 1, 0, PMU_DEU);
102     @@ -562,7 +562,7 @@ void __init ltq_soc_init(void)
103     } else {
104     clkdev_add_static(ltq_danube_cpu_hz(), ltq_danube_fpi_hz(),
105     ltq_danube_fpi_hz(), ltq_danube_pp32_hz());
106     - clkdev_add_pmu("1f203018.usb2-phy", "ctrl", 1, 0, PMU_USB0);
107     + clkdev_add_pmu("1e101000.usb", "otg", 1, 0, PMU_USB0 | PMU_AHBM);
108     clkdev_add_pmu("1f203018.usb2-phy", "phy", 1, 0, PMU_USB0_P);
109     clkdev_add_pmu("1e103000.sdio", NULL, 1, 0, PMU_SDIO);
110     clkdev_add_pmu("1e103100.deu", NULL, 1, 0, PMU_DEU);
111     diff --git a/arch/mips/ralink/mt7621.c b/arch/mips/ralink/mt7621.c
112     index 1b274742077d..d2718de60b9b 100644
113     --- a/arch/mips/ralink/mt7621.c
114     +++ b/arch/mips/ralink/mt7621.c
115     @@ -170,6 +170,28 @@ void prom_soc_init(struct ralink_soc_info *soc_info)
116     u32 n1;
117     u32 rev;
118    
119     + /* Early detection of CMP support */
120     + mips_cm_probe();
121     + mips_cpc_probe();
122     +
123     + if (mips_cps_numiocu(0)) {
124     + /*
125     + * mips_cm_probe() wipes out bootloader
126     + * config for CM regions and we have to configure them
127     + * again. This SoC cannot talk to pamlbus devices
128     + * witout proper iocu region set up.
129     + *
130     + * FIXME: it would be better to do this with values
131     + * from DT, but we need this very early because
132     + * without this we cannot talk to pretty much anything
133     + * including serial.
134     + */
135     + write_gcr_reg0_base(MT7621_PALMBUS_BASE);
136     + write_gcr_reg0_mask(~MT7621_PALMBUS_SIZE |
137     + CM_GCR_REGn_MASK_CMTGT_IOCU0);
138     + __sync();
139     + }
140     +
141     n0 = __raw_readl(sysc + SYSC_REG_CHIP_NAME0);
142     n1 = __raw_readl(sysc + SYSC_REG_CHIP_NAME1);
143    
144     @@ -194,26 +216,6 @@ void prom_soc_init(struct ralink_soc_info *soc_info)
145    
146     rt2880_pinmux_data = mt7621_pinmux_data;
147    
148     - /* Early detection of CMP support */
149     - mips_cm_probe();
150     - mips_cpc_probe();
151     -
152     - if (mips_cps_numiocu(0)) {
153     - /*
154     - * mips_cm_probe() wipes out bootloader
155     - * config for CM regions and we have to configure them
156     - * again. This SoC cannot talk to pamlbus devices
157     - * witout proper iocu region set up.
158     - *
159     - * FIXME: it would be better to do this with values
160     - * from DT, but we need this very early because
161     - * without this we cannot talk to pretty much anything
162     - * including serial.
163     - */
164     - write_gcr_reg0_base(MT7621_PALMBUS_BASE);
165     - write_gcr_reg0_mask(~MT7621_PALMBUS_SIZE |
166     - CM_GCR_REGn_MASK_CMTGT_IOCU0);
167     - }
168    
169     if (!register_cps_smp_ops())
170     return;
171     diff --git a/arch/mips/ralink/reset.c b/arch/mips/ralink/reset.c
172     index 64543d66e76b..e9531fea23a2 100644
173     --- a/arch/mips/ralink/reset.c
174     +++ b/arch/mips/ralink/reset.c
175     @@ -96,16 +96,9 @@ static void ralink_restart(char *command)
176     unreachable();
177     }
178    
179     -static void ralink_halt(void)
180     -{
181     - local_irq_disable();
182     - unreachable();
183     -}
184     -
185     static int __init mips_reboot_setup(void)
186     {
187     _machine_restart = ralink_restart;
188     - _machine_halt = ralink_halt;
189    
190     return 0;
191     }
192     diff --git a/arch/x86/Makefile b/arch/x86/Makefile
193     index 498c1b812300..1c4d012550ec 100644
194     --- a/arch/x86/Makefile
195     +++ b/arch/x86/Makefile
196     @@ -223,6 +223,15 @@ KBUILD_CFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr) $(avx_instr)
197    
198     LDFLAGS := -m elf_$(UTS_MACHINE)
199    
200     +#
201     +# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to
202     +# the linker to force 2MB page size regardless of the default page size used
203     +# by the linker.
204     +#
205     +ifdef CONFIG_X86_64
206     +LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
207     +endif
208     +
209     # Speed up the build
210     KBUILD_CFLAGS += -pipe
211     # Workaround for a gcc prelease that unfortunately was shipped in a suse release
212     diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
213     index 98761a1576ce..252fee320816 100644
214     --- a/arch/x86/boot/compressed/misc.c
215     +++ b/arch/x86/boot/compressed/misc.c
216     @@ -309,6 +309,10 @@ static void parse_elf(void *output)
217    
218     switch (phdr->p_type) {
219     case PT_LOAD:
220     +#ifdef CONFIG_X86_64
221     + if ((phdr->p_align % 0x200000) != 0)
222     + error("Alignment of LOAD segment isn't multiple of 2MB");
223     +#endif
224     #ifdef CONFIG_RELOCATABLE
225     dest = output;
226     dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
227     diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
228     index 6f3cc15e0c73..f7bfa701219b 100644
229     --- a/arch/x86/entry/entry_64.S
230     +++ b/arch/x86/entry/entry_64.S
231     @@ -1091,7 +1091,7 @@ apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
232     #endif /* CONFIG_HYPERV */
233    
234     idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
235     -idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
236     +idtentry int3 do_int3 has_error_code=0
237     idtentry stack_segment do_stack_segment has_error_code=1
238    
239     #ifdef CONFIG_XEN
240     diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c
241     index 577fa8adb785..542392b6aab6 100644
242     --- a/arch/x86/entry/vsyscall/vsyscall_64.c
243     +++ b/arch/x86/entry/vsyscall/vsyscall_64.c
244     @@ -355,7 +355,7 @@ void __init set_vsyscall_pgtable_user_bits(pgd_t *root)
245     set_pgd(pgd, __pgd(pgd_val(*pgd) | _PAGE_USER));
246     p4d = p4d_offset(pgd, VSYSCALL_ADDR);
247     #if CONFIG_PGTABLE_LEVELS >= 5
248     - p4d->p4d |= _PAGE_USER;
249     + set_p4d(p4d, __p4d(p4d_val(*p4d) | _PAGE_USER));
250     #endif
251     pud = pud_offset(p4d, VSYSCALL_ADDR);
252     set_pud(pud, __pud(pud_val(*pud) | _PAGE_USER));
253     diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
254     index 56457cb73448..9b18a227fff7 100644
255     --- a/arch/x86/events/intel/core.c
256     +++ b/arch/x86/events/intel/core.c
257     @@ -3194,7 +3194,7 @@ static unsigned bdw_limit_period(struct perf_event *event, unsigned left)
258     X86_CONFIG(.event=0xc0, .umask=0x01)) {
259     if (left < 128)
260     left = 128;
261     - left &= ~0x3fu;
262     + left &= ~0x3fULL;
263     }
264     return left;
265     }
266     diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
267     index 95cb19f4e06f..8243fdbb9b9c 100644
268     --- a/arch/x86/events/intel/uncore_snbep.c
269     +++ b/arch/x86/events/intel/uncore_snbep.c
270     @@ -3554,24 +3554,27 @@ static struct intel_uncore_type *skx_msr_uncores[] = {
271     NULL,
272     };
273    
274     +/*
275     + * To determine the number of CHAs, it should read bits 27:0 in the CAPID6
276     + * register which located at Device 30, Function 3, Offset 0x9C. PCI ID 0x2083.
277     + */
278     +#define SKX_CAPID6 0x9c
279     +#define SKX_CHA_BIT_MASK GENMASK(27, 0)
280     +
281     static int skx_count_chabox(void)
282     {
283     - struct pci_dev *chabox_dev = NULL;
284     - int bus, count = 0;
285     + struct pci_dev *dev = NULL;
286     + u32 val = 0;
287    
288     - while (1) {
289     - chabox_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x208d, chabox_dev);
290     - if (!chabox_dev)
291     - break;
292     - if (count == 0)
293     - bus = chabox_dev->bus->number;
294     - if (bus != chabox_dev->bus->number)
295     - break;
296     - count++;
297     - }
298     + dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x2083, dev);
299     + if (!dev)
300     + goto out;
301    
302     - pci_dev_put(chabox_dev);
303     - return count;
304     + pci_read_config_dword(dev, SKX_CAPID6, &val);
305     + val &= SKX_CHA_BIT_MASK;
306     +out:
307     + pci_dev_put(dev);
308     + return hweight32(val);
309     }
310    
311     void skx_uncore_cpu_init(void)
312     @@ -3598,7 +3601,7 @@ static struct intel_uncore_type skx_uncore_imc = {
313     };
314    
315     static struct attribute *skx_upi_uncore_formats_attr[] = {
316     - &format_attr_event_ext.attr,
317     + &format_attr_event.attr,
318     &format_attr_umask_ext.attr,
319     &format_attr_edge.attr,
320     &format_attr_inv.attr,
321     diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
322     index caec8417539f..7c300299e12e 100644
323     --- a/arch/x86/include/asm/vmx.h
324     +++ b/arch/x86/include/asm/vmx.h
325     @@ -352,6 +352,7 @@ enum vmcs_field {
326     #define INTR_TYPE_NMI_INTR (2 << 8) /* NMI */
327     #define INTR_TYPE_HARD_EXCEPTION (3 << 8) /* processor exception */
328     #define INTR_TYPE_SOFT_INTR (4 << 8) /* software interrupt */
329     +#define INTR_TYPE_PRIV_SW_EXCEPTION (5 << 8) /* ICE breakpoint - undocumented */
330     #define INTR_TYPE_SOFT_EXCEPTION (6 << 8) /* software exception */
331    
332     /* GUEST_INTERRUPTIBILITY_INFO flags. */
333     diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c
334     index 236917bac5f2..a59624080015 100644
335     --- a/arch/x86/kernel/idt.c
336     +++ b/arch/x86/kernel/idt.c
337     @@ -160,7 +160,6 @@ static const __initconst struct idt_data early_pf_idts[] = {
338     */
339     static const __initconst struct idt_data dbg_idts[] = {
340     INTG(X86_TRAP_DB, debug),
341     - INTG(X86_TRAP_BP, int3),
342     };
343     #endif
344    
345     @@ -183,7 +182,6 @@ gate_desc debug_idt_table[IDT_ENTRIES] __page_aligned_bss;
346     static const __initconst struct idt_data ist_idts[] = {
347     ISTG(X86_TRAP_DB, debug, DEBUG_STACK),
348     ISTG(X86_TRAP_NMI, nmi, NMI_STACK),
349     - SISTG(X86_TRAP_BP, int3, DEBUG_STACK),
350     ISTG(X86_TRAP_DF, double_fault, DOUBLEFAULT_STACK),
351     #ifdef CONFIG_X86_MCE
352     ISTG(X86_TRAP_MC, &machine_check, MCE_STACK),
353     diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
354     index a66428dc92ae..ef4efb931efa 100644
355     --- a/arch/x86/kernel/traps.c
356     +++ b/arch/x86/kernel/traps.c
357     @@ -571,7 +571,6 @@ do_general_protection(struct pt_regs *regs, long error_code)
358     }
359     NOKPROBE_SYMBOL(do_general_protection);
360    
361     -/* May run on IST stack. */
362     dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
363     {
364     #ifdef CONFIG_DYNAMIC_FTRACE
365     @@ -586,6 +585,13 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
366     if (poke_int3_handler(regs))
367     return;
368    
369     + /*
370     + * Use ist_enter despite the fact that we don't use an IST stack.
371     + * We can be called from a kprobe in non-CONTEXT_KERNEL kernel
372     + * mode or even during context tracking state changes.
373     + *
374     + * This means that we can't schedule. That's okay.
375     + */
376     ist_enter(regs);
377     RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
378     #ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
379     @@ -603,15 +609,10 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
380     SIGTRAP) == NOTIFY_STOP)
381     goto exit;
382    
383     - /*
384     - * Let others (NMI) know that the debug stack is in use
385     - * as we may switch to the interrupt stack.
386     - */
387     - debug_stack_usage_inc();
388     cond_local_irq_enable(regs);
389     do_trap(X86_TRAP_BP, SIGTRAP, "int3", regs, error_code, NULL);
390     cond_local_irq_disable(regs);
391     - debug_stack_usage_dec();
392     +
393     exit:
394     ist_exit(regs);
395     }
396     diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
397     index 315fccb2684b..ae4803b213d0 100644
398     --- a/arch/x86/kvm/vmx.c
399     +++ b/arch/x86/kvm/vmx.c
400     @@ -1071,6 +1071,13 @@ static inline bool is_machine_check(u32 intr_info)
401     (INTR_TYPE_HARD_EXCEPTION | MC_VECTOR | INTR_INFO_VALID_MASK);
402     }
403    
404     +/* Undocumented: icebp/int1 */
405     +static inline bool is_icebp(u32 intr_info)
406     +{
407     + return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VALID_MASK))
408     + == (INTR_TYPE_PRIV_SW_EXCEPTION | INTR_INFO_VALID_MASK);
409     +}
410     +
411     static inline bool cpu_has_vmx_msr_bitmap(void)
412     {
413     return vmcs_config.cpu_based_exec_ctrl & CPU_BASED_USE_MSR_BITMAPS;
414     @@ -6169,7 +6176,7 @@ static int handle_exception(struct kvm_vcpu *vcpu)
415     (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))) {
416     vcpu->arch.dr6 &= ~15;
417     vcpu->arch.dr6 |= dr6 | DR6_RTM;
418     - if (!(dr6 & ~DR6_RESERVED)) /* icebp */
419     + if (is_icebp(intr_info))
420     skip_emulated_instruction(vcpu);
421    
422     kvm_queue_exception(vcpu, DB_VECTOR);
423     diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
424     index 004abf9ebf12..34cda7e0551b 100644
425     --- a/arch/x86/mm/pgtable.c
426     +++ b/arch/x86/mm/pgtable.c
427     @@ -702,4 +702,52 @@ int pmd_clear_huge(pmd_t *pmd)
428    
429     return 0;
430     }
431     +
432     +/**
433     + * pud_free_pmd_page - Clear pud entry and free pmd page.
434     + * @pud: Pointer to a PUD.
435     + *
436     + * Context: The pud range has been unmaped and TLB purged.
437     + * Return: 1 if clearing the entry succeeded. 0 otherwise.
438     + */
439     +int pud_free_pmd_page(pud_t *pud)
440     +{
441     + pmd_t *pmd;
442     + int i;
443     +
444     + if (pud_none(*pud))
445     + return 1;
446     +
447     + pmd = (pmd_t *)pud_page_vaddr(*pud);
448     +
449     + for (i = 0; i < PTRS_PER_PMD; i++)
450     + if (!pmd_free_pte_page(&pmd[i]))
451     + return 0;
452     +
453     + pud_clear(pud);
454     + free_page((unsigned long)pmd);
455     +
456     + return 1;
457     +}
458     +
459     +/**
460     + * pmd_free_pte_page - Clear pmd entry and free pte page.
461     + * @pmd: Pointer to a PMD.
462     + *
463     + * Context: The pmd range has been unmaped and TLB purged.
464     + * Return: 1 if clearing the entry succeeded. 0 otherwise.
465     + */
466     +int pmd_free_pte_page(pmd_t *pmd)
467     +{
468     + pte_t *pte;
469     +
470     + if (pmd_none(*pmd))
471     + return 1;
472     +
473     + pte = (pte_t *)pmd_page_vaddr(*pmd);
474     + pmd_clear(pmd);
475     + free_page((unsigned long)pte);
476     +
477     + return 1;
478     +}
479     #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
480     diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
481     index 940aac70b4da..bb77606d04e0 100644
482     --- a/arch/x86/net/bpf_jit_comp.c
483     +++ b/arch/x86/net/bpf_jit_comp.c
484     @@ -1156,7 +1156,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
485     * may converge on the last pass. In such case do one more
486     * pass to emit the final image
487     */
488     - for (pass = 0; pass < 10 || image; pass++) {
489     + for (pass = 0; pass < 20 || image; pass++) {
490     proglen = do_jit(prog, addrs, image, oldproglen, &ctx);
491     if (proglen <= 0) {
492     image = NULL;
493     @@ -1183,6 +1183,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
494     }
495     }
496     oldproglen = proglen;
497     + cond_resched();
498     }
499    
500     if (bpf_jit_enable > 1)
501     diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
502     index ad5d9538f0f9..f7af598c4f55 100644
503     --- a/arch/x86/platform/efi/efi_64.c
504     +++ b/arch/x86/platform/efi/efi_64.c
505     @@ -227,7 +227,7 @@ int __init efi_alloc_page_tables(void)
506     if (!pud) {
507     if (CONFIG_PGTABLE_LEVELS > 4)
508     free_page((unsigned long) pgd_page_vaddr(*pgd));
509     - free_page((unsigned long)efi_pgd);
510     + free_pages((unsigned long)efi_pgd, PGD_ALLOCATION_ORDER);
511     return -ENOMEM;
512     }
513    
514     diff --git a/drivers/acpi/acpi_watchdog.c b/drivers/acpi/acpi_watchdog.c
515     index 11b113f8e367..ebb626ffb5fa 100644
516     --- a/drivers/acpi/acpi_watchdog.c
517     +++ b/drivers/acpi/acpi_watchdog.c
518     @@ -74,10 +74,10 @@ void __init acpi_watchdog_init(void)
519     res.start = gas->address;
520     if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
521     res.flags = IORESOURCE_MEM;
522     - res.end = res.start + ALIGN(gas->access_width, 4);
523     + res.end = res.start + ALIGN(gas->access_width, 4) - 1;
524     } else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
525     res.flags = IORESOURCE_IO;
526     - res.end = res.start + gas->access_width;
527     + res.end = res.start + gas->access_width - 1;
528     } else {
529     pr_warn("Unsupported address space: %u\n",
530     gas->space_id);
531     diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
532     index 917f1cc0fda4..8fb74d9011da 100644
533     --- a/drivers/acpi/numa.c
534     +++ b/drivers/acpi/numa.c
535     @@ -103,25 +103,27 @@ int acpi_map_pxm_to_node(int pxm)
536     */
537     int acpi_map_pxm_to_online_node(int pxm)
538     {
539     - int node, n, dist, min_dist;
540     + int node, min_node;
541    
542     node = acpi_map_pxm_to_node(pxm);
543    
544     if (node == NUMA_NO_NODE)
545     node = 0;
546    
547     + min_node = node;
548     if (!node_online(node)) {
549     - min_dist = INT_MAX;
550     + int min_dist = INT_MAX, dist, n;
551     +
552     for_each_online_node(n) {
553     dist = node_distance(node, n);
554     if (dist < min_dist) {
555     min_dist = dist;
556     - node = n;
557     + min_node = n;
558     }
559     }
560     }
561    
562     - return node;
563     + return min_node;
564     }
565     EXPORT_SYMBOL(acpi_map_pxm_to_online_node);
566    
567     diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
568     index bc013f757d5d..18391d0c0cd7 100644
569     --- a/drivers/ata/ahci.c
570     +++ b/drivers/ata/ahci.c
571     @@ -541,7 +541,9 @@ static const struct pci_device_id ahci_pci_tbl[] = {
572     .driver_data = board_ahci_yes_fbs },
573     { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230),
574     .driver_data = board_ahci_yes_fbs },
575     - { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0642),
576     + { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0642), /* highpoint rocketraid 642L */
577     + .driver_data = board_ahci_yes_fbs },
578     + { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0645), /* highpoint rocketraid 644L */
579     .driver_data = board_ahci_yes_fbs },
580    
581     /* Promise */
582     diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
583     index e7ded346d94b..c6fe2974b336 100644
584     --- a/drivers/ata/libata-core.c
585     +++ b/drivers/ata/libata-core.c
586     @@ -4520,6 +4520,25 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
587     { "PIONEER DVD-RW DVR-212D", NULL, ATA_HORKAGE_NOSETXFER },
588     { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER },
589    
590     + /* Crucial BX100 SSD 500GB has broken LPM support */
591     + { "CT500BX100SSD1", NULL, ATA_HORKAGE_NOLPM },
592     +
593     + /* 512GB MX100 with MU01 firmware has both queued TRIM and LPM issues */
594     + { "Crucial_CT512MX100*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM |
595     + ATA_HORKAGE_ZERO_AFTER_TRIM |
596     + ATA_HORKAGE_NOLPM, },
597     + /* 512GB MX100 with newer firmware has only LPM issues */
598     + { "Crucial_CT512MX100*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM |
599     + ATA_HORKAGE_NOLPM, },
600     +
601     + /* 480GB+ M500 SSDs have both queued TRIM and LPM issues */
602     + { "Crucial_CT480M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
603     + ATA_HORKAGE_ZERO_AFTER_TRIM |
604     + ATA_HORKAGE_NOLPM, },
605     + { "Crucial_CT960M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
606     + ATA_HORKAGE_ZERO_AFTER_TRIM |
607     + ATA_HORKAGE_NOLPM, },
608     +
609     /* devices that don't properly handle queued TRIM commands */
610     { "Micron_M500_*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
611     ATA_HORKAGE_ZERO_AFTER_TRIM, },
612     @@ -4531,7 +4550,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
613     ATA_HORKAGE_ZERO_AFTER_TRIM, },
614     { "Crucial_CT*MX100*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM |
615     ATA_HORKAGE_ZERO_AFTER_TRIM, },
616     - { "Samsung SSD 8*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
617     + { "Samsung SSD 840*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
618     + ATA_HORKAGE_ZERO_AFTER_TRIM, },
619     + { "Samsung SSD 850*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
620     ATA_HORKAGE_ZERO_AFTER_TRIM, },
621     { "FCCT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
622     ATA_HORKAGE_ZERO_AFTER_TRIM, },
623     @@ -5391,8 +5412,7 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
624     * We guarantee to LLDs that they will have at least one
625     * non-zero sg if the command is a data command.
626     */
627     - if (WARN_ON_ONCE(ata_is_data(prot) &&
628     - (!qc->sg || !qc->n_elem || !qc->nbytes)))
629     + if (ata_is_data(prot) && (!qc->sg || !qc->n_elem || !qc->nbytes))
630     goto sys_err;
631    
632     if (ata_is_dma(prot) || (ata_is_pio(prot) &&
633     diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
634     index 44ba292f2cd7..4ff69f508e95 100644
635     --- a/drivers/ata/libata-scsi.c
636     +++ b/drivers/ata/libata-scsi.c
637     @@ -3315,6 +3315,12 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
638     goto invalid_fld;
639     }
640    
641     + /* We may not issue NCQ commands to devices not supporting NCQ */
642     + if (ata_is_ncq(tf->protocol) && !ata_ncq_enabled(dev)) {
643     + fp = 1;
644     + goto invalid_fld;
645     + }
646     +
647     /* sanity check for pio multi commands */
648     if ((cdb[1] & 0xe0) && !is_multi_taskfile(tf)) {
649     fp = 1;
650     @@ -4308,7 +4314,9 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
651     if (likely((scsi_op != ATA_16) || !atapi_passthru16)) {
652     /* relay SCSI command to ATAPI device */
653     int len = COMMAND_SIZE(scsi_op);
654     - if (unlikely(len > scmd->cmd_len || len > dev->cdb_len))
655     + if (unlikely(len > scmd->cmd_len ||
656     + len > dev->cdb_len ||
657     + scmd->cmd_len > ATAPI_CDB_LEN))
658     goto bad_cdb_len;
659    
660     xlat_func = atapi_xlat;
661     diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
662     index 673698c7b143..b2c0306f97ed 100644
663     --- a/drivers/bluetooth/btusb.c
664     +++ b/drivers/bluetooth/btusb.c
665     @@ -235,7 +235,6 @@ static const struct usb_device_id blacklist_table[] = {
666     { USB_DEVICE(0x0930, 0x0227), .driver_info = BTUSB_ATH3012 },
667     { USB_DEVICE(0x0b05, 0x17d0), .driver_info = BTUSB_ATH3012 },
668     { USB_DEVICE(0x0cf3, 0x0036), .driver_info = BTUSB_ATH3012 },
669     - { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
670     { USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
671     { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
672     { USB_DEVICE(0x0cf3, 0x311e), .driver_info = BTUSB_ATH3012 },
673     @@ -268,6 +267,7 @@ static const struct usb_device_id blacklist_table[] = {
674     { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 },
675    
676     /* QCA ROME chipset */
677     + { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_QCA_ROME },
678     { USB_DEVICE(0x0cf3, 0xe007), .driver_info = BTUSB_QCA_ROME },
679     { USB_DEVICE(0x0cf3, 0xe009), .driver_info = BTUSB_QCA_ROME },
680     { USB_DEVICE(0x0cf3, 0xe300), .driver_info = BTUSB_QCA_ROME },
681     @@ -388,10 +388,10 @@ static const struct usb_device_id blacklist_table[] = {
682     */
683     static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
684     {
685     - /* Lenovo Yoga 920 (QCA Rome device 0cf3:e300) */
686     + /* Dell OptiPlex 3060 (QCA ROME device 0cf3:e007) */
687     .matches = {
688     - DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
689     - DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo YOGA 920"),
690     + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
691     + DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 3060"),
692     },
693     },
694     {}
695     diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
696     index 58ce6af8452d..eec52734d6ac 100644
697     --- a/drivers/clk/bcm/clk-bcm2835.c
698     +++ b/drivers/clk/bcm/clk-bcm2835.c
699     @@ -479,17 +479,17 @@ struct bcm2835_pll_ana_bits {
700     static const struct bcm2835_pll_ana_bits bcm2835_ana_default = {
701     .mask0 = 0,
702     .set0 = 0,
703     - .mask1 = (u32)~(A2W_PLL_KI_MASK | A2W_PLL_KP_MASK),
704     + .mask1 = A2W_PLL_KI_MASK | A2W_PLL_KP_MASK,
705     .set1 = (2 << A2W_PLL_KI_SHIFT) | (8 << A2W_PLL_KP_SHIFT),
706     - .mask3 = (u32)~A2W_PLL_KA_MASK,
707     + .mask3 = A2W_PLL_KA_MASK,
708     .set3 = (2 << A2W_PLL_KA_SHIFT),
709     .fb_prediv_mask = BIT(14),
710     };
711    
712     static const struct bcm2835_pll_ana_bits bcm2835_ana_pllh = {
713     - .mask0 = (u32)~(A2W_PLLH_KA_MASK | A2W_PLLH_KI_LOW_MASK),
714     + .mask0 = A2W_PLLH_KA_MASK | A2W_PLLH_KI_LOW_MASK,
715     .set0 = (2 << A2W_PLLH_KA_SHIFT) | (2 << A2W_PLLH_KI_LOW_SHIFT),
716     - .mask1 = (u32)~(A2W_PLLH_KI_HIGH_MASK | A2W_PLLH_KP_MASK),
717     + .mask1 = A2W_PLLH_KI_HIGH_MASK | A2W_PLLH_KP_MASK,
718     .set1 = (6 << A2W_PLLH_KP_SHIFT),
719     .mask3 = 0,
720     .set3 = 0,
721     @@ -653,8 +653,10 @@ static int bcm2835_pll_on(struct clk_hw *hw)
722     ~A2W_PLL_CTRL_PWRDN);
723    
724     /* Take the PLL out of reset. */
725     + spin_lock(&cprman->regs_lock);
726     cprman_write(cprman, data->cm_ctrl_reg,
727     cprman_read(cprman, data->cm_ctrl_reg) & ~CM_PLL_ANARST);
728     + spin_unlock(&cprman->regs_lock);
729    
730     /* Wait for the PLL to lock. */
731     timeout = ktime_add_ns(ktime_get(), LOCK_TIMEOUT_NS);
732     @@ -731,9 +733,11 @@ static int bcm2835_pll_set_rate(struct clk_hw *hw,
733     }
734    
735     /* Unmask the reference clock from the oscillator. */
736     + spin_lock(&cprman->regs_lock);
737     cprman_write(cprman, A2W_XOSC_CTRL,
738     cprman_read(cprman, A2W_XOSC_CTRL) |
739     data->reference_enable_mask);
740     + spin_unlock(&cprman->regs_lock);
741    
742     if (do_ana_setup_first)
743     bcm2835_pll_write_ana(cprman, data->ana_reg_base, ana);
744     diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
745     index 241fb13f1c06..40d5f74cb2ac 100644
746     --- a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
747     +++ b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
748     @@ -750,7 +750,7 @@ static struct ccu_mp out_a_clk = {
749     .features = CCU_FEATURE_FIXED_PREDIV,
750     .hw.init = CLK_HW_INIT_PARENTS("out-a",
751     clk_out_parents,
752     - &ccu_div_ops,
753     + &ccu_mp_ops,
754     0),
755     },
756     };
757     @@ -771,7 +771,7 @@ static struct ccu_mp out_b_clk = {
758     .features = CCU_FEATURE_FIXED_PREDIV,
759     .hw.init = CLK_HW_INIT_PARENTS("out-b",
760     clk_out_parents,
761     - &ccu_div_ops,
762     + &ccu_mp_ops,
763     0),
764     },
765     };
766     @@ -792,7 +792,7 @@ static struct ccu_mp out_c_clk = {
767     .features = CCU_FEATURE_FIXED_PREDIV,
768     .hw.init = CLK_HW_INIT_PARENTS("out-c",
769     clk_out_parents,
770     - &ccu_div_ops,
771     + &ccu_mp_ops,
772     0),
773     },
774     };
775     diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
776     index dd4727489b84..c21e10c780ac 100644
777     --- a/drivers/gpu/drm/drm_framebuffer.c
778     +++ b/drivers/gpu/drm/drm_framebuffer.c
779     @@ -458,6 +458,12 @@ int drm_mode_getfb(struct drm_device *dev,
780     if (!fb)
781     return -ENOENT;
782    
783     + /* Multi-planar framebuffers need getfb2. */
784     + if (fb->format->num_planes > 1) {
785     + ret = -EINVAL;
786     + goto out;
787     + }
788     +
789     r->height = fb->height;
790     r->width = fb->width;
791     r->depth = fb->format->depth;
792     @@ -481,6 +487,7 @@ int drm_mode_getfb(struct drm_device *dev,
793     ret = -ENODEV;
794     }
795    
796     +out:
797     drm_framebuffer_put(fb);
798    
799     return ret;
800     diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
801     index 0422b8c2c2e7..7bcf5702c91c 100644
802     --- a/drivers/gpu/drm/drm_syncobj.c
803     +++ b/drivers/gpu/drm/drm_syncobj.c
804     @@ -328,28 +328,11 @@ static const struct file_operations drm_syncobj_file_fops = {
805     .release = drm_syncobj_file_release,
806     };
807    
808     -static int drm_syncobj_alloc_file(struct drm_syncobj *syncobj)
809     -{
810     - struct file *file = anon_inode_getfile("syncobj_file",
811     - &drm_syncobj_file_fops,
812     - syncobj, 0);
813     - if (IS_ERR(file))
814     - return PTR_ERR(file);
815     -
816     - drm_syncobj_get(syncobj);
817     - if (cmpxchg(&syncobj->file, NULL, file)) {
818     - /* lost the race */
819     - fput(file);
820     - }
821     -
822     - return 0;
823     -}
824     -
825     static int drm_syncobj_handle_to_fd(struct drm_file *file_private,
826     u32 handle, int *p_fd)
827     {
828     struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
829     - int ret;
830     + struct file *file;
831     int fd;
832    
833     if (!syncobj)
834     @@ -361,46 +344,40 @@ static int drm_syncobj_handle_to_fd(struct drm_file *file_private,
835     return fd;
836     }
837    
838     - if (!syncobj->file) {
839     - ret = drm_syncobj_alloc_file(syncobj);
840     - if (ret)
841     - goto out_put_fd;
842     + file = anon_inode_getfile("syncobj_file",
843     + &drm_syncobj_file_fops,
844     + syncobj, 0);
845     + if (IS_ERR(file)) {
846     + put_unused_fd(fd);
847     + drm_syncobj_put(syncobj);
848     + return PTR_ERR(file);
849     }
850     - fd_install(fd, syncobj->file);
851     - drm_syncobj_put(syncobj);
852     +
853     + drm_syncobj_get(syncobj);
854     + fd_install(fd, file);
855     +
856     *p_fd = fd;
857     return 0;
858     -out_put_fd:
859     - put_unused_fd(fd);
860     - drm_syncobj_put(syncobj);
861     - return ret;
862     }
863    
864     -static struct drm_syncobj *drm_syncobj_fdget(int fd)
865     -{
866     - struct file *file = fget(fd);
867     -
868     - if (!file)
869     - return NULL;
870     - if (file->f_op != &drm_syncobj_file_fops)
871     - goto err;
872     -
873     - return file->private_data;
874     -err:
875     - fput(file);
876     - return NULL;
877     -};
878     -
879     static int drm_syncobj_fd_to_handle(struct drm_file *file_private,
880     int fd, u32 *handle)
881     {
882     - struct drm_syncobj *syncobj = drm_syncobj_fdget(fd);
883     + struct drm_syncobj *syncobj;
884     + struct file *file;
885     int ret;
886    
887     - if (!syncobj)
888     + file = fget(fd);
889     + if (!file)
890     + return -EINVAL;
891     +
892     + if (file->f_op != &drm_syncobj_file_fops) {
893     + fput(file);
894     return -EINVAL;
895     + }
896    
897     /* take a reference to put in the idr */
898     + syncobj = file->private_data;
899     drm_syncobj_get(syncobj);
900    
901     idr_preload(GFP_KERNEL);
902     @@ -409,12 +386,14 @@ static int drm_syncobj_fd_to_handle(struct drm_file *file_private,
903     spin_unlock(&file_private->syncobj_table_lock);
904     idr_preload_end();
905    
906     - if (ret < 0) {
907     - fput(syncobj->file);
908     - return ret;
909     - }
910     - *handle = ret;
911     - return 0;
912     + if (ret > 0) {
913     + *handle = ret;
914     + ret = 0;
915     + } else
916     + drm_syncobj_put(syncobj);
917     +
918     + fput(file);
919     + return ret;
920     }
921    
922     int drm_syncobj_import_sync_file_fence(struct drm_file *file_private,
923     diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
924     index c0da44742988..424cd1b66575 100644
925     --- a/drivers/gpu/drm/radeon/radeon_connectors.c
926     +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
927     @@ -90,25 +90,18 @@ void radeon_connector_hotplug(struct drm_connector *connector)
928     /* don't do anything if sink is not display port, i.e.,
929     * passive dp->(dvi|hdmi) adaptor
930     */
931     - if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) {
932     - int saved_dpms = connector->dpms;
933     - /* Only turn off the display if it's physically disconnected */
934     - if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
935     - drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
936     - } else if (radeon_dp_needs_link_train(radeon_connector)) {
937     - /* Don't try to start link training before we
938     - * have the dpcd */
939     - if (!radeon_dp_getdpcd(radeon_connector))
940     - return;
941     -
942     - /* set it to OFF so that drm_helper_connector_dpms()
943     - * won't return immediately since the current state
944     - * is ON at this point.
945     - */
946     - connector->dpms = DRM_MODE_DPMS_OFF;
947     - drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
948     - }
949     - connector->dpms = saved_dpms;
950     + if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT &&
951     + radeon_hpd_sense(rdev, radeon_connector->hpd.hpd) &&
952     + radeon_dp_needs_link_train(radeon_connector)) {
953     + /* Don't start link training before we have the DPCD */
954     + if (!radeon_dp_getdpcd(radeon_connector))
955     + return;
956     +
957     + /* Turn the connector off and back on immediately, which
958     + * will trigger link training
959     + */
960     + drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
961     + drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
962     }
963     }
964     }
965     diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
966     index b5b335c9b2bb..2ebdc6d5a76e 100644
967     --- a/drivers/gpu/drm/udl/udl_fb.c
968     +++ b/drivers/gpu/drm/udl/udl_fb.c
969     @@ -159,10 +159,15 @@ static int udl_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
970     {
971     unsigned long start = vma->vm_start;
972     unsigned long size = vma->vm_end - vma->vm_start;
973     - unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
974     + unsigned long offset;
975     unsigned long page, pos;
976    
977     - if (offset + size > info->fix.smem_len)
978     + if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
979     + return -EINVAL;
980     +
981     + offset = vma->vm_pgoff << PAGE_SHIFT;
982     +
983     + if (offset > info->fix.smem_len || size > info->fix.smem_len - offset)
984     return -EINVAL;
985    
986     pos = (unsigned long)info->fix.smem_start + offset;
987     diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
988     index 184340d486c3..86d25f18aa99 100644
989     --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
990     +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
991     @@ -1337,6 +1337,19 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)
992     */
993     void vmw_svga_disable(struct vmw_private *dev_priv)
994     {
995     + /*
996     + * Disabling SVGA will turn off device modesetting capabilities, so
997     + * notify KMS about that so that it doesn't cache atomic state that
998     + * isn't valid anymore, for example crtcs turned on.
999     + * Strictly we'd want to do this under the SVGA lock (or an SVGA mutex),
1000     + * but vmw_kms_lost_device() takes the reservation sem and thus we'll
1001     + * end up with lock order reversal. Thus, a master may actually perform
1002     + * a new modeset just after we call vmw_kms_lost_device() and race with
1003     + * vmw_svga_disable(), but that should at worst cause atomic KMS state
1004     + * to be inconsistent with the device, causing modesetting problems.
1005     + *
1006     + */
1007     + vmw_kms_lost_device(dev_priv->dev);
1008     ttm_write_lock(&dev_priv->reservation_sem, false);
1009     spin_lock(&dev_priv->svga_lock);
1010     if (dev_priv->bdev.man[TTM_PL_VRAM].use_type) {
1011     diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
1012     index 7e5f30e234b1..8c65cc3b0dda 100644
1013     --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
1014     +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
1015     @@ -938,6 +938,7 @@ int vmw_kms_present(struct vmw_private *dev_priv,
1016     int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
1017     struct drm_file *file_priv);
1018     void vmw_kms_legacy_hotspot_clear(struct vmw_private *dev_priv);
1019     +void vmw_kms_lost_device(struct drm_device *dev);
1020    
1021     int vmw_dumb_create(struct drm_file *file_priv,
1022     struct drm_device *dev,
1023     diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
1024     index 62c2f4be8012..9e010f8c36a1 100644
1025     --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
1026     +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
1027     @@ -31,7 +31,6 @@
1028     #include <drm/drm_atomic_helper.h>
1029     #include <drm/drm_rect.h>
1030    
1031     -
1032     /* Might need a hrtimer here? */
1033     #define VMWGFX_PRESENT_RATE ((HZ / 60 > 0) ? HZ / 60 : 1)
1034    
1035     @@ -2531,9 +2530,12 @@ void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv,
1036     * Helper to be used if an error forces the caller to undo the actions of
1037     * vmw_kms_helper_resource_prepare.
1038     */
1039     -void vmw_kms_helper_resource_revert(struct vmw_resource *res)
1040     +void vmw_kms_helper_resource_revert(struct vmw_validation_ctx *ctx)
1041     {
1042     - vmw_kms_helper_buffer_revert(res->backup);
1043     + struct vmw_resource *res = ctx->res;
1044     +
1045     + vmw_kms_helper_buffer_revert(ctx->buf);
1046     + vmw_dmabuf_unreference(&ctx->buf);
1047     vmw_resource_unreserve(res, false, NULL, 0);
1048     mutex_unlock(&res->dev_priv->cmdbuf_mutex);
1049     }
1050     @@ -2550,10 +2552,14 @@ void vmw_kms_helper_resource_revert(struct vmw_resource *res)
1051     * interrupted by a signal.
1052     */
1053     int vmw_kms_helper_resource_prepare(struct vmw_resource *res,
1054     - bool interruptible)
1055     + bool interruptible,
1056     + struct vmw_validation_ctx *ctx)
1057     {
1058     int ret = 0;
1059    
1060     + ctx->buf = NULL;
1061     + ctx->res = res;
1062     +
1063     if (interruptible)
1064     ret = mutex_lock_interruptible(&res->dev_priv->cmdbuf_mutex);
1065     else
1066     @@ -2572,6 +2578,8 @@ int vmw_kms_helper_resource_prepare(struct vmw_resource *res,
1067     res->dev_priv->has_mob);
1068     if (ret)
1069     goto out_unreserve;
1070     +
1071     + ctx->buf = vmw_dmabuf_reference(res->backup);
1072     }
1073     ret = vmw_resource_validate(res);
1074     if (ret)
1075     @@ -2579,7 +2587,7 @@ int vmw_kms_helper_resource_prepare(struct vmw_resource *res,
1076     return 0;
1077    
1078     out_revert:
1079     - vmw_kms_helper_buffer_revert(res->backup);
1080     + vmw_kms_helper_buffer_revert(ctx->buf);
1081     out_unreserve:
1082     vmw_resource_unreserve(res, false, NULL, 0);
1083     out_unlock:
1084     @@ -2595,11 +2603,13 @@ int vmw_kms_helper_resource_prepare(struct vmw_resource *res,
1085     * @out_fence: Optional pointer to a fence pointer. If non-NULL, a
1086     * ref-counted fence pointer is returned here.
1087     */
1088     -void vmw_kms_helper_resource_finish(struct vmw_resource *res,
1089     - struct vmw_fence_obj **out_fence)
1090     +void vmw_kms_helper_resource_finish(struct vmw_validation_ctx *ctx,
1091     + struct vmw_fence_obj **out_fence)
1092     {
1093     - if (res->backup || out_fence)
1094     - vmw_kms_helper_buffer_finish(res->dev_priv, NULL, res->backup,
1095     + struct vmw_resource *res = ctx->res;
1096     +
1097     + if (ctx->buf || out_fence)
1098     + vmw_kms_helper_buffer_finish(res->dev_priv, NULL, ctx->buf,
1099     out_fence, NULL);
1100    
1101     vmw_resource_unreserve(res, false, NULL, 0);
1102     @@ -2865,3 +2875,14 @@ int vmw_kms_set_config(struct drm_mode_set *set,
1103    
1104     return drm_atomic_helper_set_config(set, ctx);
1105     }
1106     +
1107     +
1108     +/**
1109     + * vmw_kms_lost_device - Notify kms that modesetting capabilities will be lost
1110     + *
1111     + * @dev: Pointer to the drm device
1112     + */
1113     +void vmw_kms_lost_device(struct drm_device *dev)
1114     +{
1115     + drm_atomic_helper_shutdown(dev);
1116     +}
1117     diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
1118     index cd9da2dd79af..3d2ca280eaa7 100644
1119     --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
1120     +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
1121     @@ -240,6 +240,11 @@ struct vmw_display_unit {
1122     int set_gui_y;
1123     };
1124    
1125     +struct vmw_validation_ctx {
1126     + struct vmw_resource *res;
1127     + struct vmw_dma_buffer *buf;
1128     +};
1129     +
1130     #define vmw_crtc_to_du(x) \
1131     container_of(x, struct vmw_display_unit, crtc)
1132     #define vmw_connector_to_du(x) \
1133     @@ -296,9 +301,10 @@ void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv,
1134     struct drm_vmw_fence_rep __user *
1135     user_fence_rep);
1136     int vmw_kms_helper_resource_prepare(struct vmw_resource *res,
1137     - bool interruptible);
1138     -void vmw_kms_helper_resource_revert(struct vmw_resource *res);
1139     -void vmw_kms_helper_resource_finish(struct vmw_resource *res,
1140     + bool interruptible,
1141     + struct vmw_validation_ctx *ctx);
1142     +void vmw_kms_helper_resource_revert(struct vmw_validation_ctx *ctx);
1143     +void vmw_kms_helper_resource_finish(struct vmw_validation_ctx *ctx,
1144     struct vmw_fence_obj **out_fence);
1145     int vmw_kms_readback(struct vmw_private *dev_priv,
1146     struct drm_file *file_priv,
1147     @@ -439,5 +445,4 @@ int vmw_kms_stdu_dma(struct vmw_private *dev_priv,
1148    
1149     int vmw_kms_set_config(struct drm_mode_set *set,
1150     struct drm_modeset_acquire_ctx *ctx);
1151     -
1152     #endif
1153     diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
1154     index 7ae38a67388c..aacce4753a62 100644
1155     --- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
1156     +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
1157     @@ -909,12 +909,13 @@ int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv,
1158     struct vmw_framebuffer_surface *vfbs =
1159     container_of(framebuffer, typeof(*vfbs), base);
1160     struct vmw_kms_sou_surface_dirty sdirty;
1161     + struct vmw_validation_ctx ctx;
1162     int ret;
1163    
1164     if (!srf)
1165     srf = &vfbs->surface->res;
1166    
1167     - ret = vmw_kms_helper_resource_prepare(srf, true);
1168     + ret = vmw_kms_helper_resource_prepare(srf, true, &ctx);
1169     if (ret)
1170     return ret;
1171    
1172     @@ -933,7 +934,7 @@ int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv,
1173     ret = vmw_kms_helper_dirty(dev_priv, framebuffer, clips, vclips,
1174     dest_x, dest_y, num_clips, inc,
1175     &sdirty.base);
1176     - vmw_kms_helper_resource_finish(srf, out_fence);
1177     + vmw_kms_helper_resource_finish(&ctx, out_fence);
1178    
1179     return ret;
1180     }
1181     diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
1182     index 4dee05b15552..6c576f8df4b2 100644
1183     --- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
1184     +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
1185     @@ -980,12 +980,13 @@ int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv,
1186     struct vmw_framebuffer_surface *vfbs =
1187     container_of(framebuffer, typeof(*vfbs), base);
1188     struct vmw_stdu_dirty sdirty;
1189     + struct vmw_validation_ctx ctx;
1190     int ret;
1191    
1192     if (!srf)
1193     srf = &vfbs->surface->res;
1194    
1195     - ret = vmw_kms_helper_resource_prepare(srf, true);
1196     + ret = vmw_kms_helper_resource_prepare(srf, true, &ctx);
1197     if (ret)
1198     return ret;
1199    
1200     @@ -1008,7 +1009,7 @@ int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv,
1201     dest_x, dest_y, num_clips, inc,
1202     &sdirty.base);
1203     out_finish:
1204     - vmw_kms_helper_resource_finish(srf, out_fence);
1205     + vmw_kms_helper_resource_finish(&ctx, out_fence);
1206    
1207     return ret;
1208     }
1209     diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
1210     index 12eb8caa4263..3f8dde8d59ba 100644
1211     --- a/drivers/hv/ring_buffer.c
1212     +++ b/drivers/hv/ring_buffer.c
1213     @@ -394,13 +394,24 @@ __hv_pkt_iter_next(struct vmbus_channel *channel,
1214     }
1215     EXPORT_SYMBOL_GPL(__hv_pkt_iter_next);
1216    
1217     +/* How many bytes were read in this iterator cycle */
1218     +static u32 hv_pkt_iter_bytes_read(const struct hv_ring_buffer_info *rbi,
1219     + u32 start_read_index)
1220     +{
1221     + if (rbi->priv_read_index >= start_read_index)
1222     + return rbi->priv_read_index - start_read_index;
1223     + else
1224     + return rbi->ring_datasize - start_read_index +
1225     + rbi->priv_read_index;
1226     +}
1227     +
1228     /*
1229     * Update host ring buffer after iterating over packets.
1230     */
1231     void hv_pkt_iter_close(struct vmbus_channel *channel)
1232     {
1233     struct hv_ring_buffer_info *rbi = &channel->inbound;
1234     - u32 orig_write_sz = hv_get_bytes_to_write(rbi);
1235     + u32 curr_write_sz, pending_sz, bytes_read, start_read_index;
1236    
1237     /*
1238     * Make sure all reads are done before we update the read index since
1239     @@ -408,8 +419,12 @@ void hv_pkt_iter_close(struct vmbus_channel *channel)
1240     * is updated.
1241     */
1242     virt_rmb();
1243     + start_read_index = rbi->ring_buffer->read_index;
1244     rbi->ring_buffer->read_index = rbi->priv_read_index;
1245    
1246     + if (!rbi->ring_buffer->feature_bits.feat_pending_send_sz)
1247     + return;
1248     +
1249     /*
1250     * Issue a full memory barrier before making the signaling decision.
1251     * Here is the reason for having this barrier:
1252     @@ -423,26 +438,29 @@ void hv_pkt_iter_close(struct vmbus_channel *channel)
1253     */
1254     virt_mb();
1255    
1256     - /* If host has disabled notifications then skip */
1257     - if (rbi->ring_buffer->interrupt_mask)
1258     + pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
1259     + if (!pending_sz)
1260     return;
1261    
1262     - if (rbi->ring_buffer->feature_bits.feat_pending_send_sz) {
1263     - u32 pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
1264     + /*
1265     + * Ensure the read of write_index in hv_get_bytes_to_write()
1266     + * happens after the read of pending_send_sz.
1267     + */
1268     + virt_rmb();
1269     + curr_write_sz = hv_get_bytes_to_write(rbi);
1270     + bytes_read = hv_pkt_iter_bytes_read(rbi, start_read_index);
1271    
1272     - /*
1273     - * If there was space before we began iteration,
1274     - * then host was not blocked. Also handles case where
1275     - * pending_sz is zero then host has nothing pending
1276     - * and does not need to be signaled.
1277     - */
1278     - if (orig_write_sz > pending_sz)
1279     - return;
1280     + /*
1281     + * If there was space before we began iteration,
1282     + * then host was not blocked.
1283     + */
1284    
1285     - /* If pending write will not fit, don't give false hope. */
1286     - if (hv_get_bytes_to_write(rbi) < pending_sz)
1287     - return;
1288     - }
1289     + if (curr_write_sz - bytes_read > pending_sz)
1290     + return;
1291     +
1292     + /* If pending write will not fit, don't give false hope. */
1293     + if (curr_write_sz <= pending_sz)
1294     + return;
1295    
1296     vmbus_setevent(channel);
1297     }
1298     diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
1299     index 379de1829cdb..bef1f96c177c 100644
1300     --- a/drivers/iio/accel/st_accel_core.c
1301     +++ b/drivers/iio/accel/st_accel_core.c
1302     @@ -794,7 +794,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev)
1303     if (!pdata)
1304     pdata = (struct st_sensors_platform_data *)&default_accel_pdata;
1305    
1306     - err = st_sensors_init_sensor(indio_dev, adata->dev->platform_data);
1307     + err = st_sensors_init_sensor(indio_dev, pdata);
1308     if (err < 0)
1309     goto st_accel_power_off;
1310    
1311     diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
1312     index 7dc7d297a0fc..11484cb38b84 100644
1313     --- a/drivers/iio/adc/meson_saradc.c
1314     +++ b/drivers/iio/adc/meson_saradc.c
1315     @@ -462,8 +462,10 @@ static int meson_sar_adc_lock(struct iio_dev *indio_dev)
1316     regmap_read(priv->regmap, MESON_SAR_ADC_DELAY, &val);
1317     } while (val & MESON_SAR_ADC_DELAY_BL30_BUSY && timeout--);
1318    
1319     - if (timeout < 0)
1320     + if (timeout < 0) {
1321     + mutex_unlock(&indio_dev->mlock);
1322     return -ETIMEDOUT;
1323     + }
1324     }
1325    
1326     return 0;
1327     diff --git a/drivers/iio/chemical/ccs811.c b/drivers/iio/chemical/ccs811.c
1328     index 8cfac6d1cec4..9dd0e1cd93dd 100644
1329     --- a/drivers/iio/chemical/ccs811.c
1330     +++ b/drivers/iio/chemical/ccs811.c
1331     @@ -128,6 +128,9 @@ static int ccs811_start_sensor_application(struct i2c_client *client)
1332     if (ret < 0)
1333     return ret;
1334    
1335     + if ((ret & CCS811_STATUS_FW_MODE_APPLICATION))
1336     + return 0;
1337     +
1338     if ((ret & CCS811_STATUS_APP_VALID_MASK) !=
1339     CCS811_STATUS_APP_VALID_LOADED)
1340     return -EIO;
1341     diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
1342     index b485540da89e..cce0c93accef 100644
1343     --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
1344     +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
1345     @@ -392,7 +392,7 @@ static int st_lsm6dsx_read_oneshot(struct st_lsm6dsx_sensor *sensor,
1346    
1347     st_lsm6dsx_sensor_disable(sensor);
1348    
1349     - *val = (s16)data;
1350     + *val = (s16)le16_to_cpu(data);
1351    
1352     return IIO_VAL_INT;
1353     }
1354     diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
1355     index ea075fcd5a6f..ec5ca03529b5 100644
1356     --- a/drivers/iio/pressure/st_pressure_core.c
1357     +++ b/drivers/iio/pressure/st_pressure_core.c
1358     @@ -617,7 +617,7 @@ int st_press_common_probe(struct iio_dev *indio_dev)
1359     if (!pdata && press_data->sensor_settings->drdy_irq.addr)
1360     pdata = (struct st_sensors_platform_data *)&default_press_pdata;
1361    
1362     - err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data);
1363     + err = st_sensors_init_sensor(indio_dev, pdata);
1364     if (err < 0)
1365     goto st_press_power_off;
1366    
1367     diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
1368     index cef05ab83496..6d48d8a93b62 100644
1369     --- a/drivers/infiniband/hw/mlx5/mr.c
1370     +++ b/drivers/infiniband/hw/mlx5/mr.c
1371     @@ -838,7 +838,8 @@ static int mr_umem_get(struct ib_pd *pd, u64 start, u64 length,
1372     *umem = ib_umem_get(pd->uobject->context, start, length,
1373     access_flags, 0);
1374     err = PTR_ERR_OR_ZERO(*umem);
1375     - if (err < 0) {
1376     + if (err) {
1377     + *umem = NULL;
1378     mlx5_ib_err(dev, "umem get failed (%d)\n", err);
1379     return err;
1380     }
1381     @@ -1415,6 +1416,7 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
1382     if (err) {
1383     mlx5_ib_warn(dev, "Failed to rereg UMR\n");
1384     ib_umem_release(mr->umem);
1385     + mr->umem = NULL;
1386     clean_mr(dev, mr);
1387     return err;
1388     }
1389     @@ -1498,14 +1500,11 @@ static int clean_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
1390     u32 key = mr->mmkey.key;
1391    
1392     err = destroy_mkey(dev, mr);
1393     - kfree(mr);
1394     if (err) {
1395     mlx5_ib_warn(dev, "failed to destroy mkey 0x%x (%d)\n",
1396     key, err);
1397     return err;
1398     }
1399     - } else {
1400     - mlx5_mr_cache_free(dev, mr);
1401     }
1402    
1403     return 0;
1404     @@ -1548,6 +1547,11 @@ static int dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
1405     atomic_sub(npages, &dev->mdev->priv.reg_pages);
1406     }
1407    
1408     + if (!mr->allocated_from_cache)
1409     + kfree(mr);
1410     + else
1411     + mlx5_mr_cache_free(dev, mr);
1412     +
1413     return 0;
1414     }
1415    
1416     diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
1417     index 9c6f2ce3b710..4281fdc0a13c 100644
1418     --- a/drivers/mmc/core/block.c
1419     +++ b/drivers/mmc/core/block.c
1420     @@ -65,6 +65,7 @@ MODULE_ALIAS("mmc:block");
1421     #define MMC_BLK_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */
1422     #define MMC_SANITIZE_REQ_TIMEOUT 240000
1423     #define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF0000) >> 16)
1424     +#define MMC_EXTRACT_VALUE_FROM_ARG(x) ((x & 0x0000FF00) >> 8)
1425    
1426     #define mmc_req_rel_wr(req) ((req->cmd_flags & REQ_FUA) && \
1427     (rq_data_dir(req) == WRITE))
1428     @@ -538,6 +539,24 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
1429     return data.error;
1430     }
1431    
1432     + /*
1433     + * Make sure the cache of the PARTITION_CONFIG register and
1434     + * PARTITION_ACCESS bits is updated in case the ioctl ext_csd write
1435     + * changed it successfully.
1436     + */
1437     + if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_PART_CONFIG) &&
1438     + (cmd.opcode == MMC_SWITCH)) {
1439     + struct mmc_blk_data *main_md = dev_get_drvdata(&card->dev);
1440     + u8 value = MMC_EXTRACT_VALUE_FROM_ARG(cmd.arg);
1441     +
1442     + /*
1443     + * Update cache so the next mmc_blk_part_switch call operates
1444     + * on up-to-date data.
1445     + */
1446     + card->ext_csd.part_config = value;
1447     + main_md->part_curr = value & EXT_CSD_PART_CONFIG_ACC_MASK;
1448     + }
1449     +
1450     /*
1451     * According to the SD specs, some commands require a delay after
1452     * issuing the command.
1453     diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h
1454     index 79a5b985ccf5..9c821eedd156 100644
1455     --- a/drivers/mmc/core/card.h
1456     +++ b/drivers/mmc/core/card.h
1457     @@ -82,6 +82,7 @@ struct mmc_fixup {
1458     #define CID_MANFID_APACER 0x27
1459     #define CID_MANFID_KINGSTON 0x70
1460     #define CID_MANFID_HYNIX 0x90
1461     +#define CID_MANFID_NUMONYX 0xFE
1462    
1463     #define END_FIXUP { NULL }
1464    
1465     diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h
1466     index 75d317623852..5153577754f0 100644
1467     --- a/drivers/mmc/core/quirks.h
1468     +++ b/drivers/mmc/core/quirks.h
1469     @@ -109,6 +109,12 @@ static const struct mmc_fixup mmc_ext_csd_fixups[] = {
1470     */
1471     MMC_FIXUP_EXT_CSD_REV(CID_NAME_ANY, CID_MANFID_HYNIX,
1472     0x014a, add_quirk, MMC_QUIRK_BROKEN_HPI, 5),
1473     + /*
1474     + * Certain Micron (Numonyx) eMMC 4.5 cards might get broken when HPI
1475     + * feature is used so disable the HPI feature for such buggy cards.
1476     + */
1477     + MMC_FIXUP_EXT_CSD_REV(CID_NAME_ANY, CID_MANFID_NUMONYX,
1478     + 0x014e, add_quirk, MMC_QUIRK_BROKEN_HPI, 6),
1479    
1480     END_FIXUP
1481     };
1482     diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
1483     index fa41d9422d57..a84aa3f1ae85 100644
1484     --- a/drivers/mmc/host/dw_mmc-exynos.c
1485     +++ b/drivers/mmc/host/dw_mmc-exynos.c
1486     @@ -165,9 +165,15 @@ static void dw_mci_exynos_set_clksel_timing(struct dw_mci *host, u32 timing)
1487     static int dw_mci_exynos_runtime_resume(struct device *dev)
1488     {
1489     struct dw_mci *host = dev_get_drvdata(dev);
1490     + int ret;
1491     +
1492     + ret = dw_mci_runtime_resume(dev);
1493     + if (ret)
1494     + return ret;
1495    
1496     dw_mci_exynos_config_smu(host);
1497     - return dw_mci_runtime_resume(dev);
1498     +
1499     + return ret;
1500     }
1501    
1502     /**
1503     diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
1504     index 60341a814055..de31e20dc56c 100644
1505     --- a/drivers/mmc/host/dw_mmc.c
1506     +++ b/drivers/mmc/host/dw_mmc.c
1507     @@ -413,7 +413,9 @@ static inline void dw_mci_set_cto(struct dw_mci *host)
1508     cto_div = (mci_readl(host, CLKDIV) & 0xff) * 2;
1509     if (cto_div == 0)
1510     cto_div = 1;
1511     - cto_ms = DIV_ROUND_UP(MSEC_PER_SEC * cto_clks * cto_div, host->bus_hz);
1512     +
1513     + cto_ms = DIV_ROUND_UP_ULL((u64)MSEC_PER_SEC * cto_clks * cto_div,
1514     + host->bus_hz);
1515    
1516     /* add a bit spare time */
1517     cto_ms += 10;
1518     @@ -562,6 +564,7 @@ static int dw_mci_idmac_init(struct dw_mci *host)
1519     (sizeof(struct idmac_desc_64addr) *
1520     (i + 1))) >> 32;
1521     /* Initialize reserved and buffer size fields to "0" */
1522     + p->des0 = 0;
1523     p->des1 = 0;
1524     p->des2 = 0;
1525     p->des3 = 0;
1526     @@ -584,6 +587,7 @@ static int dw_mci_idmac_init(struct dw_mci *host)
1527     i++, p++) {
1528     p->des3 = cpu_to_le32(host->sg_dma +
1529     (sizeof(struct idmac_desc) * (i + 1)));
1530     + p->des0 = 0;
1531     p->des1 = 0;
1532     }
1533    
1534     @@ -1799,8 +1803,8 @@ static bool dw_mci_reset(struct dw_mci *host)
1535     }
1536    
1537     if (host->use_dma == TRANS_MODE_IDMAC)
1538     - /* It is also recommended that we reset and reprogram idmac */
1539     - dw_mci_idmac_reset(host);
1540     + /* It is also required that we reinit idmac */
1541     + dw_mci_idmac_init(host);
1542    
1543     ret = true;
1544    
1545     @@ -1947,8 +1951,9 @@ static void dw_mci_set_drto(struct dw_mci *host)
1546     drto_div = (mci_readl(host, CLKDIV) & 0xff) * 2;
1547     if (drto_div == 0)
1548     drto_div = 1;
1549     - drto_ms = DIV_ROUND_UP(MSEC_PER_SEC * drto_clks * drto_div,
1550     - host->bus_hz);
1551     +
1552     + drto_ms = DIV_ROUND_UP_ULL((u64)MSEC_PER_SEC * drto_clks * drto_div,
1553     + host->bus_hz);
1554    
1555     /* add a bit spare time */
1556     drto_ms += 10;
1557     diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
1558     index 3568294d4854..b25f444c5914 100644
1559     --- a/drivers/mtd/mtdchar.c
1560     +++ b/drivers/mtd/mtdchar.c
1561     @@ -487,7 +487,7 @@ static int shrink_ecclayout(struct mtd_info *mtd,
1562     for (i = 0; i < MTD_MAX_ECCPOS_ENTRIES;) {
1563     u32 eccpos;
1564    
1565     - ret = mtd_ooblayout_ecc(mtd, section, &oobregion);
1566     + ret = mtd_ooblayout_ecc(mtd, section++, &oobregion);
1567     if (ret < 0) {
1568     if (ret != -ERANGE)
1569     return ret;
1570     @@ -534,7 +534,7 @@ static int get_oobinfo(struct mtd_info *mtd, struct nand_oobinfo *to)
1571     for (i = 0; i < ARRAY_SIZE(to->eccpos);) {
1572     u32 eccpos;
1573    
1574     - ret = mtd_ooblayout_ecc(mtd, section, &oobregion);
1575     + ret = mtd_ooblayout_ecc(mtd, section++, &oobregion);
1576     if (ret < 0) {
1577     if (ret != -ERANGE)
1578     return ret;
1579     diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
1580     index bbdd68a54d68..4005b427023c 100644
1581     --- a/drivers/mtd/nand/fsl_ifc_nand.c
1582     +++ b/drivers/mtd/nand/fsl_ifc_nand.c
1583     @@ -173,14 +173,9 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob)
1584    
1585     /* returns nonzero if entire page is blank */
1586     static int check_read_ecc(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl,
1587     - u32 *eccstat, unsigned int bufnum)
1588     + u32 eccstat, unsigned int bufnum)
1589     {
1590     - u32 reg = eccstat[bufnum / 4];
1591     - int errors;
1592     -
1593     - errors = (reg >> ((3 - bufnum % 4) * 8)) & 15;
1594     -
1595     - return errors;
1596     + return (eccstat >> ((3 - bufnum % 4) * 8)) & 15;
1597     }
1598    
1599     /*
1600     @@ -193,7 +188,7 @@ static void fsl_ifc_run_command(struct mtd_info *mtd)
1601     struct fsl_ifc_ctrl *ctrl = priv->ctrl;
1602     struct fsl_ifc_nand_ctrl *nctrl = ifc_nand_ctrl;
1603     struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
1604     - u32 eccstat[4];
1605     + u32 eccstat;
1606     int i;
1607    
1608     /* set the chip select for NAND Transaction */
1609     @@ -228,19 +223,17 @@ static void fsl_ifc_run_command(struct mtd_info *mtd)
1610     if (nctrl->eccread) {
1611     int errors;
1612     int bufnum = nctrl->page & priv->bufnum_mask;
1613     - int sector = bufnum * chip->ecc.steps;
1614     - int sector_end = sector + chip->ecc.steps - 1;
1615     + int sector_start = bufnum * chip->ecc.steps;
1616     + int sector_end = sector_start + chip->ecc.steps - 1;
1617     __be32 *eccstat_regs;
1618    
1619     - if (ctrl->version >= FSL_IFC_VERSION_2_0_0)
1620     - eccstat_regs = ifc->ifc_nand.v2_nand_eccstat;
1621     - else
1622     - eccstat_regs = ifc->ifc_nand.v1_nand_eccstat;
1623     + eccstat_regs = ifc->ifc_nand.nand_eccstat;
1624     + eccstat = ifc_in32(&eccstat_regs[sector_start / 4]);
1625    
1626     - for (i = sector / 4; i <= sector_end / 4; i++)
1627     - eccstat[i] = ifc_in32(&eccstat_regs[i]);
1628     + for (i = sector_start; i <= sector_end; i++) {
1629     + if (i != sector_start && !(i % 4))
1630     + eccstat = ifc_in32(&eccstat_regs[i / 4]);
1631    
1632     - for (i = sector; i <= sector_end; i++) {
1633     errors = check_read_ecc(mtd, ctrl, eccstat, i);
1634    
1635     if (errors == 15) {
1636     @@ -626,6 +619,7 @@ static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip)
1637     struct fsl_ifc_ctrl *ctrl = priv->ctrl;
1638     struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
1639     u32 nand_fsr;
1640     + int status;
1641    
1642     /* Use READ_STATUS command, but wait for the device to be ready */
1643     ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
1644     @@ -640,12 +634,12 @@ static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip)
1645     fsl_ifc_run_command(mtd);
1646    
1647     nand_fsr = ifc_in32(&ifc->ifc_nand.nand_fsr);
1648     -
1649     + status = nand_fsr >> 24;
1650     /*
1651     * The chip always seems to report that it is
1652     * write-protected, even when it is not.
1653     */
1654     - return nand_fsr | NAND_STATUS_WP;
1655     + return status | NAND_STATUS_WP;
1656     }
1657    
1658     /*
1659     diff --git a/drivers/net/can/cc770/cc770.c b/drivers/net/can/cc770/cc770.c
1660     index 1e37313054f3..6da69af103e6 100644
1661     --- a/drivers/net/can/cc770/cc770.c
1662     +++ b/drivers/net/can/cc770/cc770.c
1663     @@ -390,37 +390,23 @@ static int cc770_get_berr_counter(const struct net_device *dev,
1664     return 0;
1665     }
1666    
1667     -static netdev_tx_t cc770_start_xmit(struct sk_buff *skb, struct net_device *dev)
1668     +static void cc770_tx(struct net_device *dev, int mo)
1669     {
1670     struct cc770_priv *priv = netdev_priv(dev);
1671     - struct net_device_stats *stats = &dev->stats;
1672     - struct can_frame *cf = (struct can_frame *)skb->data;
1673     - unsigned int mo = obj2msgobj(CC770_OBJ_TX);
1674     + struct can_frame *cf = (struct can_frame *)priv->tx_skb->data;
1675     u8 dlc, rtr;
1676     u32 id;
1677     int i;
1678    
1679     - if (can_dropped_invalid_skb(dev, skb))
1680     - return NETDEV_TX_OK;
1681     -
1682     - if ((cc770_read_reg(priv,
1683     - msgobj[mo].ctrl1) & TXRQST_UNC) == TXRQST_SET) {
1684     - netdev_err(dev, "TX register is still occupied!\n");
1685     - return NETDEV_TX_BUSY;
1686     - }
1687     -
1688     - netif_stop_queue(dev);
1689     -
1690     dlc = cf->can_dlc;
1691     id = cf->can_id;
1692     - if (cf->can_id & CAN_RTR_FLAG)
1693     - rtr = 0;
1694     - else
1695     - rtr = MSGCFG_DIR;
1696     + rtr = cf->can_id & CAN_RTR_FLAG ? 0 : MSGCFG_DIR;
1697     +
1698     + cc770_write_reg(priv, msgobj[mo].ctrl0,
1699     + MSGVAL_RES | TXIE_RES | RXIE_RES | INTPND_RES);
1700     cc770_write_reg(priv, msgobj[mo].ctrl1,
1701     RMTPND_RES | TXRQST_RES | CPUUPD_SET | NEWDAT_RES);
1702     - cc770_write_reg(priv, msgobj[mo].ctrl0,
1703     - MSGVAL_SET | TXIE_SET | RXIE_RES | INTPND_RES);
1704     +
1705     if (id & CAN_EFF_FLAG) {
1706     id &= CAN_EFF_MASK;
1707     cc770_write_reg(priv, msgobj[mo].config,
1708     @@ -439,22 +425,30 @@ static netdev_tx_t cc770_start_xmit(struct sk_buff *skb, struct net_device *dev)
1709     for (i = 0; i < dlc; i++)
1710     cc770_write_reg(priv, msgobj[mo].data[i], cf->data[i]);
1711    
1712     - /* Store echo skb before starting the transfer */
1713     - can_put_echo_skb(skb, dev, 0);
1714     -
1715     cc770_write_reg(priv, msgobj[mo].ctrl1,
1716     - RMTPND_RES | TXRQST_SET | CPUUPD_RES | NEWDAT_UNC);
1717     + RMTPND_UNC | TXRQST_SET | CPUUPD_RES | NEWDAT_UNC);
1718     + cc770_write_reg(priv, msgobj[mo].ctrl0,
1719     + MSGVAL_SET | TXIE_SET | RXIE_SET | INTPND_UNC);
1720     +}
1721    
1722     - stats->tx_bytes += dlc;
1723     +static netdev_tx_t cc770_start_xmit(struct sk_buff *skb, struct net_device *dev)
1724     +{
1725     + struct cc770_priv *priv = netdev_priv(dev);
1726     + unsigned int mo = obj2msgobj(CC770_OBJ_TX);
1727    
1728     + if (can_dropped_invalid_skb(dev, skb))
1729     + return NETDEV_TX_OK;
1730    
1731     - /*
1732     - * HM: We had some cases of repeated IRQs so make sure the
1733     - * INT is acknowledged I know it's already further up, but
1734     - * doing again fixed the issue
1735     - */
1736     - cc770_write_reg(priv, msgobj[mo].ctrl0,
1737     - MSGVAL_UNC | TXIE_UNC | RXIE_UNC | INTPND_RES);
1738     + netif_stop_queue(dev);
1739     +
1740     + if ((cc770_read_reg(priv,
1741     + msgobj[mo].ctrl1) & TXRQST_UNC) == TXRQST_SET) {
1742     + netdev_err(dev, "TX register is still occupied!\n");
1743     + return NETDEV_TX_BUSY;
1744     + }
1745     +
1746     + priv->tx_skb = skb;
1747     + cc770_tx(dev, mo);
1748    
1749     return NETDEV_TX_OK;
1750     }
1751     @@ -680,19 +674,46 @@ static void cc770_tx_interrupt(struct net_device *dev, unsigned int o)
1752     struct cc770_priv *priv = netdev_priv(dev);
1753     struct net_device_stats *stats = &dev->stats;
1754     unsigned int mo = obj2msgobj(o);
1755     + struct can_frame *cf;
1756     + u8 ctrl1;
1757     +
1758     + ctrl1 = cc770_read_reg(priv, msgobj[mo].ctrl1);
1759    
1760     - /* Nothing more to send, switch off interrupts */
1761     cc770_write_reg(priv, msgobj[mo].ctrl0,
1762     MSGVAL_RES | TXIE_RES | RXIE_RES | INTPND_RES);
1763     - /*
1764     - * We had some cases of repeated IRQ so make sure the
1765     - * INT is acknowledged
1766     + cc770_write_reg(priv, msgobj[mo].ctrl1,
1767     + RMTPND_RES | TXRQST_RES | MSGLST_RES | NEWDAT_RES);
1768     +
1769     + if (unlikely(!priv->tx_skb)) {
1770     + netdev_err(dev, "missing tx skb in tx interrupt\n");
1771     + return;
1772     + }
1773     +
1774     + if (unlikely(ctrl1 & MSGLST_SET)) {
1775     + stats->rx_over_errors++;
1776     + stats->rx_errors++;
1777     + }
1778     +
1779     + /* When the CC770 is sending an RTR message and it receives a regular
1780     + * message that matches the id of the RTR message, it will overwrite the
1781     + * outgoing message in the TX register. When this happens we must
1782     + * process the received message and try to transmit the outgoing skb
1783     + * again.
1784     */
1785     - cc770_write_reg(priv, msgobj[mo].ctrl0,
1786     - MSGVAL_UNC | TXIE_UNC | RXIE_UNC | INTPND_RES);
1787     + if (unlikely(ctrl1 & NEWDAT_SET)) {
1788     + cc770_rx(dev, mo, ctrl1);
1789     + cc770_tx(dev, mo);
1790     + return;
1791     + }
1792    
1793     + cf = (struct can_frame *)priv->tx_skb->data;
1794     + stats->tx_bytes += cf->can_dlc;
1795     stats->tx_packets++;
1796     +
1797     + can_put_echo_skb(priv->tx_skb, dev, 0);
1798     can_get_echo_skb(dev, 0);
1799     + priv->tx_skb = NULL;
1800     +
1801     netif_wake_queue(dev);
1802     }
1803    
1804     @@ -804,6 +825,7 @@ struct net_device *alloc_cc770dev(int sizeof_priv)
1805     priv->can.do_set_bittiming = cc770_set_bittiming;
1806     priv->can.do_set_mode = cc770_set_mode;
1807     priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
1808     + priv->tx_skb = NULL;
1809    
1810     memcpy(priv->obj_flags, cc770_obj_flags, sizeof(cc770_obj_flags));
1811    
1812     diff --git a/drivers/net/can/cc770/cc770.h b/drivers/net/can/cc770/cc770.h
1813     index a1739db98d91..95752e1d1283 100644
1814     --- a/drivers/net/can/cc770/cc770.h
1815     +++ b/drivers/net/can/cc770/cc770.h
1816     @@ -193,6 +193,8 @@ struct cc770_priv {
1817     u8 cpu_interface; /* CPU interface register */
1818     u8 clkout; /* Clock out register */
1819     u8 bus_config; /* Bus conffiguration register */
1820     +
1821     + struct sk_buff *tx_skb;
1822     };
1823    
1824     struct net_device *alloc_cc770dev(int sizeof_priv);
1825     diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c
1826     index 2772d05ff11c..fedd927ba6ed 100644
1827     --- a/drivers/net/can/ifi_canfd/ifi_canfd.c
1828     +++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
1829     @@ -30,6 +30,7 @@
1830     #define IFI_CANFD_STCMD_ERROR_ACTIVE BIT(2)
1831     #define IFI_CANFD_STCMD_ERROR_PASSIVE BIT(3)
1832     #define IFI_CANFD_STCMD_BUSOFF BIT(4)
1833     +#define IFI_CANFD_STCMD_ERROR_WARNING BIT(5)
1834     #define IFI_CANFD_STCMD_BUSMONITOR BIT(16)
1835     #define IFI_CANFD_STCMD_LOOPBACK BIT(18)
1836     #define IFI_CANFD_STCMD_DISABLE_CANFD BIT(24)
1837     @@ -52,7 +53,10 @@
1838     #define IFI_CANFD_TXSTCMD_OVERFLOW BIT(13)
1839    
1840     #define IFI_CANFD_INTERRUPT 0xc
1841     +#define IFI_CANFD_INTERRUPT_ERROR_BUSOFF BIT(0)
1842     #define IFI_CANFD_INTERRUPT_ERROR_WARNING BIT(1)
1843     +#define IFI_CANFD_INTERRUPT_ERROR_STATE_CHG BIT(2)
1844     +#define IFI_CANFD_INTERRUPT_ERROR_REC_TEC_INC BIT(3)
1845     #define IFI_CANFD_INTERRUPT_ERROR_COUNTER BIT(10)
1846     #define IFI_CANFD_INTERRUPT_TXFIFO_EMPTY BIT(16)
1847     #define IFI_CANFD_INTERRUPT_TXFIFO_REMOVE BIT(22)
1848     @@ -61,6 +65,10 @@
1849     #define IFI_CANFD_INTERRUPT_SET_IRQ ((u32)BIT(31))
1850    
1851     #define IFI_CANFD_IRQMASK 0x10
1852     +#define IFI_CANFD_IRQMASK_ERROR_BUSOFF BIT(0)
1853     +#define IFI_CANFD_IRQMASK_ERROR_WARNING BIT(1)
1854     +#define IFI_CANFD_IRQMASK_ERROR_STATE_CHG BIT(2)
1855     +#define IFI_CANFD_IRQMASK_ERROR_REC_TEC_INC BIT(3)
1856     #define IFI_CANFD_IRQMASK_SET_ERR BIT(7)
1857     #define IFI_CANFD_IRQMASK_SET_TS BIT(15)
1858     #define IFI_CANFD_IRQMASK_TXFIFO_EMPTY BIT(16)
1859     @@ -136,6 +144,8 @@
1860     #define IFI_CANFD_SYSCLOCK 0x50
1861    
1862     #define IFI_CANFD_VER 0x54
1863     +#define IFI_CANFD_VER_REV_MASK 0xff
1864     +#define IFI_CANFD_VER_REV_MIN_SUPPORTED 0x15
1865    
1866     #define IFI_CANFD_IP_ID 0x58
1867     #define IFI_CANFD_IP_ID_VALUE 0xD073CAFD
1868     @@ -220,7 +230,10 @@ static void ifi_canfd_irq_enable(struct net_device *ndev, bool enable)
1869    
1870     if (enable) {
1871     enirq = IFI_CANFD_IRQMASK_TXFIFO_EMPTY |
1872     - IFI_CANFD_IRQMASK_RXFIFO_NEMPTY;
1873     + IFI_CANFD_IRQMASK_RXFIFO_NEMPTY |
1874     + IFI_CANFD_IRQMASK_ERROR_STATE_CHG |
1875     + IFI_CANFD_IRQMASK_ERROR_WARNING |
1876     + IFI_CANFD_IRQMASK_ERROR_BUSOFF;
1877     if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
1878     enirq |= IFI_CANFD_INTERRUPT_ERROR_COUNTER;
1879     }
1880     @@ -361,12 +374,13 @@ static int ifi_canfd_handle_lost_msg(struct net_device *ndev)
1881     return 1;
1882     }
1883    
1884     -static int ifi_canfd_handle_lec_err(struct net_device *ndev, const u32 errctr)
1885     +static int ifi_canfd_handle_lec_err(struct net_device *ndev)
1886     {
1887     struct ifi_canfd_priv *priv = netdev_priv(ndev);
1888     struct net_device_stats *stats = &ndev->stats;
1889     struct can_frame *cf;
1890     struct sk_buff *skb;
1891     + u32 errctr = readl(priv->base + IFI_CANFD_ERROR_CTR);
1892     const u32 errmask = IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST |
1893     IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST |
1894     IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST |
1895     @@ -449,6 +463,11 @@ static int ifi_canfd_handle_state_change(struct net_device *ndev,
1896    
1897     switch (new_state) {
1898     case CAN_STATE_ERROR_ACTIVE:
1899     + /* error active state */
1900     + priv->can.can_stats.error_warning++;
1901     + priv->can.state = CAN_STATE_ERROR_ACTIVE;
1902     + break;
1903     + case CAN_STATE_ERROR_WARNING:
1904     /* error warning state */
1905     priv->can.can_stats.error_warning++;
1906     priv->can.state = CAN_STATE_ERROR_WARNING;
1907     @@ -477,7 +496,7 @@ static int ifi_canfd_handle_state_change(struct net_device *ndev,
1908     ifi_canfd_get_berr_counter(ndev, &bec);
1909    
1910     switch (new_state) {
1911     - case CAN_STATE_ERROR_ACTIVE:
1912     + case CAN_STATE_ERROR_WARNING:
1913     /* error warning state */
1914     cf->can_id |= CAN_ERR_CRTL;
1915     cf->data[1] = (bec.txerr > bec.rxerr) ?
1916     @@ -510,22 +529,21 @@ static int ifi_canfd_handle_state_change(struct net_device *ndev,
1917     return 1;
1918     }
1919    
1920     -static int ifi_canfd_handle_state_errors(struct net_device *ndev, u32 stcmd)
1921     +static int ifi_canfd_handle_state_errors(struct net_device *ndev)
1922     {
1923     struct ifi_canfd_priv *priv = netdev_priv(ndev);
1924     + u32 stcmd = readl(priv->base + IFI_CANFD_STCMD);
1925     int work_done = 0;
1926     - u32 isr;
1927    
1928     - /*
1929     - * The ErrWarn condition is a little special, since the bit is
1930     - * located in the INTERRUPT register instead of STCMD register.
1931     - */
1932     - isr = readl(priv->base + IFI_CANFD_INTERRUPT);
1933     - if ((isr & IFI_CANFD_INTERRUPT_ERROR_WARNING) &&
1934     + if ((stcmd & IFI_CANFD_STCMD_ERROR_ACTIVE) &&
1935     + (priv->can.state != CAN_STATE_ERROR_ACTIVE)) {
1936     + netdev_dbg(ndev, "Error, entered active state\n");
1937     + work_done += ifi_canfd_handle_state_change(ndev,
1938     + CAN_STATE_ERROR_ACTIVE);
1939     + }
1940     +
1941     + if ((stcmd & IFI_CANFD_STCMD_ERROR_WARNING) &&
1942     (priv->can.state != CAN_STATE_ERROR_WARNING)) {
1943     - /* Clear the interrupt */
1944     - writel(IFI_CANFD_INTERRUPT_ERROR_WARNING,
1945     - priv->base + IFI_CANFD_INTERRUPT);
1946     netdev_dbg(ndev, "Error, entered warning state\n");
1947     work_done += ifi_canfd_handle_state_change(ndev,
1948     CAN_STATE_ERROR_WARNING);
1949     @@ -552,18 +570,11 @@ static int ifi_canfd_poll(struct napi_struct *napi, int quota)
1950     {
1951     struct net_device *ndev = napi->dev;
1952     struct ifi_canfd_priv *priv = netdev_priv(ndev);
1953     - const u32 stcmd_state_mask = IFI_CANFD_STCMD_ERROR_PASSIVE |
1954     - IFI_CANFD_STCMD_BUSOFF;
1955     - int work_done = 0;
1956     -
1957     - u32 stcmd = readl(priv->base + IFI_CANFD_STCMD);
1958     u32 rxstcmd = readl(priv->base + IFI_CANFD_RXSTCMD);
1959     - u32 errctr = readl(priv->base + IFI_CANFD_ERROR_CTR);
1960     + int work_done = 0;
1961    
1962     /* Handle bus state changes */
1963     - if ((stcmd & stcmd_state_mask) ||
1964     - ((stcmd & IFI_CANFD_STCMD_ERROR_ACTIVE) == 0))
1965     - work_done += ifi_canfd_handle_state_errors(ndev, stcmd);
1966     + work_done += ifi_canfd_handle_state_errors(ndev);
1967    
1968     /* Handle lost messages on RX */
1969     if (rxstcmd & IFI_CANFD_RXSTCMD_OVERFLOW)
1970     @@ -571,7 +582,7 @@ static int ifi_canfd_poll(struct napi_struct *napi, int quota)
1971    
1972     /* Handle lec errors on the bus */
1973     if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
1974     - work_done += ifi_canfd_handle_lec_err(ndev, errctr);
1975     + work_done += ifi_canfd_handle_lec_err(ndev);
1976    
1977     /* Handle normal messages on RX */
1978     if (!(rxstcmd & IFI_CANFD_RXSTCMD_EMPTY))
1979     @@ -592,12 +603,13 @@ static irqreturn_t ifi_canfd_isr(int irq, void *dev_id)
1980     struct net_device_stats *stats = &ndev->stats;
1981     const u32 rx_irq_mask = IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY |
1982     IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY_PER |
1983     + IFI_CANFD_INTERRUPT_ERROR_COUNTER |
1984     + IFI_CANFD_INTERRUPT_ERROR_STATE_CHG |
1985     IFI_CANFD_INTERRUPT_ERROR_WARNING |
1986     - IFI_CANFD_INTERRUPT_ERROR_COUNTER;
1987     + IFI_CANFD_INTERRUPT_ERROR_BUSOFF;
1988     const u32 tx_irq_mask = IFI_CANFD_INTERRUPT_TXFIFO_EMPTY |
1989     IFI_CANFD_INTERRUPT_TXFIFO_REMOVE;
1990     - const u32 clr_irq_mask = ~((u32)(IFI_CANFD_INTERRUPT_SET_IRQ |
1991     - IFI_CANFD_INTERRUPT_ERROR_WARNING));
1992     + const u32 clr_irq_mask = ~((u32)IFI_CANFD_INTERRUPT_SET_IRQ);
1993     u32 isr;
1994    
1995     isr = readl(priv->base + IFI_CANFD_INTERRUPT);
1996     @@ -933,7 +945,7 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev)
1997     struct resource *res;
1998     void __iomem *addr;
1999     int irq, ret;
2000     - u32 id;
2001     + u32 id, rev;
2002    
2003     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2004     addr = devm_ioremap_resource(dev, res);
2005     @@ -947,6 +959,13 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev)
2006     return -EINVAL;
2007     }
2008    
2009     + rev = readl(addr + IFI_CANFD_VER) & IFI_CANFD_VER_REV_MASK;
2010     + if (rev < IFI_CANFD_VER_REV_MIN_SUPPORTED) {
2011     + dev_err(dev, "This block is too old (rev %i), minimum supported is rev %i\n",
2012     + rev, IFI_CANFD_VER_REV_MIN_SUPPORTED);
2013     + return -EINVAL;
2014     + }
2015     +
2016     ndev = alloc_candev(sizeof(*priv), 1);
2017     if (!ndev)
2018     return -ENOMEM;
2019     diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c
2020     index 55513411a82e..ed8561d4a90f 100644
2021     --- a/drivers/net/can/peak_canfd/peak_canfd.c
2022     +++ b/drivers/net/can/peak_canfd/peak_canfd.c
2023     @@ -262,7 +262,6 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
2024    
2025     spin_lock_irqsave(&priv->echo_lock, flags);
2026     can_get_echo_skb(priv->ndev, msg->client);
2027     - spin_unlock_irqrestore(&priv->echo_lock, flags);
2028    
2029     /* count bytes of the echo instead of skb */
2030     stats->tx_bytes += cf_len;
2031     @@ -271,6 +270,7 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
2032     /* restart tx queue (a slot is free) */
2033     netif_wake_queue(priv->ndev);
2034    
2035     + spin_unlock_irqrestore(&priv->echo_lock, flags);
2036     return 0;
2037     }
2038    
2039     @@ -333,7 +333,6 @@ static int pucan_handle_status(struct peak_canfd_priv *priv,
2040    
2041     /* this STATUS is the CNF of the RX_BARRIER: Tx path can be setup */
2042     if (pucan_status_is_rx_barrier(msg)) {
2043     - unsigned long flags;
2044    
2045     if (priv->enable_tx_path) {
2046     int err = priv->enable_tx_path(priv);
2047     @@ -342,16 +341,8 @@ static int pucan_handle_status(struct peak_canfd_priv *priv,
2048     return err;
2049     }
2050    
2051     - /* restart network queue only if echo skb array is free */
2052     - spin_lock_irqsave(&priv->echo_lock, flags);
2053     -
2054     - if (!priv->can.echo_skb[priv->echo_idx]) {
2055     - spin_unlock_irqrestore(&priv->echo_lock, flags);
2056     -
2057     - netif_wake_queue(ndev);
2058     - } else {
2059     - spin_unlock_irqrestore(&priv->echo_lock, flags);
2060     - }
2061     + /* start network queue (echo_skb array is empty) */
2062     + netif_start_queue(ndev);
2063    
2064     return 0;
2065     }
2066     @@ -726,11 +717,6 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff *skb,
2067     */
2068     should_stop_tx_queue = !!(priv->can.echo_skb[priv->echo_idx]);
2069    
2070     - spin_unlock_irqrestore(&priv->echo_lock, flags);
2071     -
2072     - /* write the skb on the interface */
2073     - priv->write_tx_msg(priv, msg);
2074     -
2075     /* stop network tx queue if not enough room to save one more msg too */
2076     if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
2077     should_stop_tx_queue |= (room_left <
2078     @@ -742,6 +728,11 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff *skb,
2079     if (should_stop_tx_queue)
2080     netif_stop_queue(ndev);
2081    
2082     + spin_unlock_irqrestore(&priv->echo_lock, flags);
2083     +
2084     + /* write the skb on the interface */
2085     + priv->write_tx_msg(priv, msg);
2086     +
2087     return NETDEV_TX_OK;
2088     }
2089    
2090     diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c b/drivers/net/can/peak_canfd/peak_pciefd_main.c
2091     index 788c3464a3b0..3c51a884db87 100644
2092     --- a/drivers/net/can/peak_canfd/peak_pciefd_main.c
2093     +++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c
2094     @@ -349,8 +349,12 @@ static irqreturn_t pciefd_irq_handler(int irq, void *arg)
2095     priv->tx_pages_free++;
2096     spin_unlock_irqrestore(&priv->tx_lock, flags);
2097    
2098     - /* wake producer up */
2099     - netif_wake_queue(priv->ucan.ndev);
2100     + /* wake producer up (only if enough room in echo_skb array) */
2101     + spin_lock_irqsave(&priv->ucan.echo_lock, flags);
2102     + if (!priv->ucan.can.echo_skb[priv->ucan.echo_idx])
2103     + netif_wake_queue(priv->ucan.ndev);
2104     +
2105     + spin_unlock_irqrestore(&priv->ucan.echo_lock, flags);
2106     }
2107    
2108     /* re-enable Rx DMA transfer for this CAN */
2109     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
2110     index 2ce675ab40ef..450f2216fac2 100644
2111     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
2112     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
2113     @@ -462,25 +462,23 @@ static int brcmf_p2p_set_firmware(struct brcmf_if *ifp, u8 *p2p_mac)
2114     * @dev_addr: optional device address.
2115     *
2116     * P2P needs mac addresses for P2P device and interface. If no device
2117     - * address it specified, these are derived from the primary net device, ie.
2118     - * the permanent ethernet address of the device.
2119     + * address it specified, these are derived from a random ethernet
2120     + * address.
2121     */
2122     static void brcmf_p2p_generate_bss_mac(struct brcmf_p2p_info *p2p, u8 *dev_addr)
2123     {
2124     - struct brcmf_if *pri_ifp = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp;
2125     - bool local_admin = false;
2126     + bool random_addr = false;
2127    
2128     - if (!dev_addr || is_zero_ether_addr(dev_addr)) {
2129     - dev_addr = pri_ifp->mac_addr;
2130     - local_admin = true;
2131     - }
2132     + if (!dev_addr || is_zero_ether_addr(dev_addr))
2133     + random_addr = true;
2134    
2135     - /* Generate the P2P Device Address. This consists of the device's
2136     - * primary MAC address with the locally administered bit set.
2137     + /* Generate the P2P Device Address obtaining a random ethernet
2138     + * address with the locally administered bit set.
2139     */
2140     - memcpy(p2p->dev_addr, dev_addr, ETH_ALEN);
2141     - if (local_admin)
2142     - p2p->dev_addr[0] |= 0x02;
2143     + if (random_addr)
2144     + eth_random_addr(p2p->dev_addr);
2145     + else
2146     + memcpy(p2p->dev_addr, dev_addr, ETH_ALEN);
2147    
2148     /* Generate the P2P Interface Address. If the discovery and connection
2149     * BSSCFGs need to simultaneously co-exist, then this address must be
2150     diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
2151     index 4d47b97adfed..0034ebd3e5ba 100644
2152     --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
2153     +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
2154     @@ -1123,7 +1123,8 @@ static void _rtl8723be_enable_aspm_back_door(struct ieee80211_hw *hw)
2155    
2156     /* Configuration Space offset 0x70f BIT7 is used to control L0S */
2157     tmp8 = _rtl8723be_dbi_read(rtlpriv, 0x70f);
2158     - _rtl8723be_dbi_write(rtlpriv, 0x70f, tmp8 | BIT(7));
2159     + _rtl8723be_dbi_write(rtlpriv, 0x70f, tmp8 | BIT(7) |
2160     + ASPM_L1_LATENCY << 3);
2161    
2162     /* Configuration Space offset 0x719 Bit3 is for L1
2163     * BIT4 is for clock request
2164     diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c
2165     index 345acca576b3..1bd7b3734751 100644
2166     --- a/drivers/nvdimm/blk.c
2167     +++ b/drivers/nvdimm/blk.c
2168     @@ -278,8 +278,6 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk)
2169     disk->queue = q;
2170     disk->flags = GENHD_FL_EXT_DEVT;
2171     nvdimm_namespace_disk_name(&nsblk->common, disk->disk_name);
2172     - set_capacity(disk, 0);
2173     - device_add_disk(dev, disk);
2174    
2175     if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk))
2176     return -ENOMEM;
2177     @@ -292,6 +290,7 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk)
2178     }
2179    
2180     set_capacity(disk, available_disk_size >> SECTOR_SHIFT);
2181     + device_add_disk(dev, disk);
2182     revalidate_disk(disk);
2183     return 0;
2184     }
2185     diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
2186     index 09428ebd315b..b2feda35966b 100644
2187     --- a/drivers/nvdimm/btt.c
2188     +++ b/drivers/nvdimm/btt.c
2189     @@ -1542,8 +1542,6 @@ static int btt_blk_init(struct btt *btt)
2190     queue_flag_set_unlocked(QUEUE_FLAG_NONROT, btt->btt_queue);
2191     btt->btt_queue->queuedata = btt;
2192    
2193     - set_capacity(btt->btt_disk, 0);
2194     - device_add_disk(&btt->nd_btt->dev, btt->btt_disk);
2195     if (btt_meta_size(btt)) {
2196     int rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt));
2197    
2198     @@ -1555,6 +1553,7 @@ static int btt_blk_init(struct btt *btt)
2199     }
2200     }
2201     set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9);
2202     + device_add_disk(&btt->nd_btt->dev, btt->btt_disk);
2203     btt->nd_btt->size = btt->nlba * (u64)btt->sector_size;
2204     revalidate_disk(btt->btt_disk);
2205    
2206     diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
2207     index d18824772f6c..05fadcc4f9d2 100644
2208     --- a/drivers/pci/quirks.c
2209     +++ b/drivers/pci/quirks.c
2210     @@ -3899,6 +3899,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9230,
2211     quirk_dma_func1_alias);
2212     DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0642,
2213     quirk_dma_func1_alias);
2214     +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0645,
2215     + quirk_dma_func1_alias);
2216     /* https://bugs.gentoo.org/show_bug.cgi?id=497630 */
2217     DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_JMICRON,
2218     PCI_DEVICE_ID_JMICRON_JMB388_ESD,
2219     diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
2220     index 071084d3ee9c..92aeea174a56 100644
2221     --- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
2222     +++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
2223     @@ -129,7 +129,7 @@ static const struct samsung_pin_bank_data s5pv210_pin_bank[] __initconst = {
2224     EXYNOS_PIN_BANK_EINTW(8, 0xc60, "gph3", 0x0c),
2225     };
2226    
2227     -const struct samsung_pin_ctrl s5pv210_pin_ctrl[] __initconst = {
2228     +static const struct samsung_pin_ctrl s5pv210_pin_ctrl[] __initconst = {
2229     {
2230     /* pin-controller instance 0 data */
2231     .pin_banks = s5pv210_pin_bank,
2232     @@ -142,6 +142,11 @@ const struct samsung_pin_ctrl s5pv210_pin_ctrl[] __initconst = {
2233     },
2234     };
2235    
2236     +const struct samsung_pinctrl_of_match_data s5pv210_of_data __initconst = {
2237     + .ctrl = s5pv210_pin_ctrl,
2238     + .num_ctrl = ARRAY_SIZE(s5pv210_pin_ctrl),
2239     +};
2240     +
2241     /* Pad retention control code for accessing PMU regmap */
2242     static atomic_t exynos_shared_retention_refcnt;
2243    
2244     @@ -204,7 +209,7 @@ static const struct samsung_retention_data exynos3250_retention_data __initconst
2245     * Samsung pinctrl driver data for Exynos3250 SoC. Exynos3250 SoC includes
2246     * two gpio/pin-mux/pinconfig controllers.
2247     */
2248     -const struct samsung_pin_ctrl exynos3250_pin_ctrl[] __initconst = {
2249     +static const struct samsung_pin_ctrl exynos3250_pin_ctrl[] __initconst = {
2250     {
2251     /* pin-controller instance 0 data */
2252     .pin_banks = exynos3250_pin_banks0,
2253     @@ -225,6 +230,11 @@ const struct samsung_pin_ctrl exynos3250_pin_ctrl[] __initconst = {
2254     },
2255     };
2256    
2257     +const struct samsung_pinctrl_of_match_data exynos3250_of_data __initconst = {
2258     + .ctrl = exynos3250_pin_ctrl,
2259     + .num_ctrl = ARRAY_SIZE(exynos3250_pin_ctrl),
2260     +};
2261     +
2262     /* pin banks of exynos4210 pin-controller 0 */
2263     static const struct samsung_pin_bank_data exynos4210_pin_banks0[] __initconst = {
2264     EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00),
2265     @@ -308,7 +318,7 @@ static const struct samsung_retention_data exynos4_audio_retention_data __initco
2266     * Samsung pinctrl driver data for Exynos4210 SoC. Exynos4210 SoC includes
2267     * three gpio/pin-mux/pinconfig controllers.
2268     */
2269     -const struct samsung_pin_ctrl exynos4210_pin_ctrl[] __initconst = {
2270     +static const struct samsung_pin_ctrl exynos4210_pin_ctrl[] __initconst = {
2271     {
2272     /* pin-controller instance 0 data */
2273     .pin_banks = exynos4210_pin_banks0,
2274     @@ -334,6 +344,11 @@ const struct samsung_pin_ctrl exynos4210_pin_ctrl[] __initconst = {
2275     },
2276     };
2277    
2278     +const struct samsung_pinctrl_of_match_data exynos4210_of_data __initconst = {
2279     + .ctrl = exynos4210_pin_ctrl,
2280     + .num_ctrl = ARRAY_SIZE(exynos4210_pin_ctrl),
2281     +};
2282     +
2283     /* pin banks of exynos4x12 pin-controller 0 */
2284     static const struct samsung_pin_bank_data exynos4x12_pin_banks0[] __initconst = {
2285     EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00),
2286     @@ -396,7 +411,7 @@ static const struct samsung_pin_bank_data exynos4x12_pin_banks3[] __initconst =
2287     * Samsung pinctrl driver data for Exynos4x12 SoC. Exynos4x12 SoC includes
2288     * four gpio/pin-mux/pinconfig controllers.
2289     */
2290     -const struct samsung_pin_ctrl exynos4x12_pin_ctrl[] __initconst = {
2291     +static const struct samsung_pin_ctrl exynos4x12_pin_ctrl[] __initconst = {
2292     {
2293     /* pin-controller instance 0 data */
2294     .pin_banks = exynos4x12_pin_banks0,
2295     @@ -432,6 +447,11 @@ const struct samsung_pin_ctrl exynos4x12_pin_ctrl[] __initconst = {
2296     },
2297     };
2298    
2299     +const struct samsung_pinctrl_of_match_data exynos4x12_of_data __initconst = {
2300     + .ctrl = exynos4x12_pin_ctrl,
2301     + .num_ctrl = ARRAY_SIZE(exynos4x12_pin_ctrl),
2302     +};
2303     +
2304     /* pin banks of exynos5250 pin-controller 0 */
2305     static const struct samsung_pin_bank_data exynos5250_pin_banks0[] __initconst = {
2306     EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00),
2307     @@ -492,7 +512,7 @@ static const struct samsung_pin_bank_data exynos5250_pin_banks3[] __initconst =
2308     * Samsung pinctrl driver data for Exynos5250 SoC. Exynos5250 SoC includes
2309     * four gpio/pin-mux/pinconfig controllers.
2310     */
2311     -const struct samsung_pin_ctrl exynos5250_pin_ctrl[] __initconst = {
2312     +static const struct samsung_pin_ctrl exynos5250_pin_ctrl[] __initconst = {
2313     {
2314     /* pin-controller instance 0 data */
2315     .pin_banks = exynos5250_pin_banks0,
2316     @@ -528,6 +548,11 @@ const struct samsung_pin_ctrl exynos5250_pin_ctrl[] __initconst = {
2317     },
2318     };
2319    
2320     +const struct samsung_pinctrl_of_match_data exynos5250_of_data __initconst = {
2321     + .ctrl = exynos5250_pin_ctrl,
2322     + .num_ctrl = ARRAY_SIZE(exynos5250_pin_ctrl),
2323     +};
2324     +
2325     /* pin banks of exynos5260 pin-controller 0 */
2326     static const struct samsung_pin_bank_data exynos5260_pin_banks0[] __initconst = {
2327     EXYNOS_PIN_BANK_EINTG(4, 0x000, "gpa0", 0x00),
2328     @@ -572,7 +597,7 @@ static const struct samsung_pin_bank_data exynos5260_pin_banks2[] __initconst =
2329     * Samsung pinctrl driver data for Exynos5260 SoC. Exynos5260 SoC includes
2330     * three gpio/pin-mux/pinconfig controllers.
2331     */
2332     -const struct samsung_pin_ctrl exynos5260_pin_ctrl[] __initconst = {
2333     +static const struct samsung_pin_ctrl exynos5260_pin_ctrl[] __initconst = {
2334     {
2335     /* pin-controller instance 0 data */
2336     .pin_banks = exynos5260_pin_banks0,
2337     @@ -592,6 +617,11 @@ const struct samsung_pin_ctrl exynos5260_pin_ctrl[] __initconst = {
2338     },
2339     };
2340    
2341     +const struct samsung_pinctrl_of_match_data exynos5260_of_data __initconst = {
2342     + .ctrl = exynos5260_pin_ctrl,
2343     + .num_ctrl = ARRAY_SIZE(exynos5260_pin_ctrl),
2344     +};
2345     +
2346     /* pin banks of exynos5410 pin-controller 0 */
2347     static const struct samsung_pin_bank_data exynos5410_pin_banks0[] __initconst = {
2348     EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00),
2349     @@ -662,7 +692,7 @@ static const struct samsung_pin_bank_data exynos5410_pin_banks3[] __initconst =
2350     * Samsung pinctrl driver data for Exynos5410 SoC. Exynos5410 SoC includes
2351     * four gpio/pin-mux/pinconfig controllers.
2352     */
2353     -const struct samsung_pin_ctrl exynos5410_pin_ctrl[] __initconst = {
2354     +static const struct samsung_pin_ctrl exynos5410_pin_ctrl[] __initconst = {
2355     {
2356     /* pin-controller instance 0 data */
2357     .pin_banks = exynos5410_pin_banks0,
2358     @@ -695,6 +725,11 @@ const struct samsung_pin_ctrl exynos5410_pin_ctrl[] __initconst = {
2359     },
2360     };
2361    
2362     +const struct samsung_pinctrl_of_match_data exynos5410_of_data __initconst = {
2363     + .ctrl = exynos5410_pin_ctrl,
2364     + .num_ctrl = ARRAY_SIZE(exynos5410_pin_ctrl),
2365     +};
2366     +
2367     /* pin banks of exynos5420 pin-controller 0 */
2368     static const struct samsung_pin_bank_data exynos5420_pin_banks0[] __initconst = {
2369     EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpy7", 0x00),
2370     @@ -779,7 +814,7 @@ static const struct samsung_retention_data exynos5420_retention_data __initconst
2371     * Samsung pinctrl driver data for Exynos5420 SoC. Exynos5420 SoC includes
2372     * four gpio/pin-mux/pinconfig controllers.
2373     */
2374     -const struct samsung_pin_ctrl exynos5420_pin_ctrl[] __initconst = {
2375     +static const struct samsung_pin_ctrl exynos5420_pin_ctrl[] __initconst = {
2376     {
2377     /* pin-controller instance 0 data */
2378     .pin_banks = exynos5420_pin_banks0,
2379     @@ -813,3 +848,8 @@ const struct samsung_pin_ctrl exynos5420_pin_ctrl[] __initconst = {
2380     .retention_data = &exynos4_audio_retention_data,
2381     },
2382     };
2383     +
2384     +const struct samsung_pinctrl_of_match_data exynos5420_of_data __initconst = {
2385     + .ctrl = exynos5420_pin_ctrl,
2386     + .num_ctrl = ARRAY_SIZE(exynos5420_pin_ctrl),
2387     +};
2388     diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm64.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm64.c
2389     index 08e9fdb58fd2..0ab88fc268ea 100644
2390     --- a/drivers/pinctrl/samsung/pinctrl-exynos-arm64.c
2391     +++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm64.c
2392     @@ -180,7 +180,7 @@ static const struct samsung_retention_data exynos5433_fsys_retention_data __init
2393     * Samsung pinctrl driver data for Exynos5433 SoC. Exynos5433 SoC includes
2394     * ten gpio/pin-mux/pinconfig controllers.
2395     */
2396     -const struct samsung_pin_ctrl exynos5433_pin_ctrl[] __initconst = {
2397     +static const struct samsung_pin_ctrl exynos5433_pin_ctrl[] __initconst = {
2398     {
2399     /* pin-controller instance 0 data */
2400     .pin_banks = exynos5433_pin_banks0,
2401     @@ -265,6 +265,11 @@ const struct samsung_pin_ctrl exynos5433_pin_ctrl[] __initconst = {
2402     },
2403     };
2404    
2405     +const struct samsung_pinctrl_of_match_data exynos5433_of_data __initconst = {
2406     + .ctrl = exynos5433_pin_ctrl,
2407     + .num_ctrl = ARRAY_SIZE(exynos5433_pin_ctrl),
2408     +};
2409     +
2410     /* pin banks of exynos7 pin-controller - ALIVE */
2411     static const struct samsung_pin_bank_data exynos7_pin_banks0[] __initconst = {
2412     EXYNOS_PIN_BANK_EINTW(8, 0x000, "gpa0", 0x00),
2413     @@ -344,7 +349,7 @@ static const struct samsung_pin_bank_data exynos7_pin_banks9[] __initconst = {
2414     EXYNOS_PIN_BANK_EINTG(4, 0x020, "gpz1", 0x04),
2415     };
2416    
2417     -const struct samsung_pin_ctrl exynos7_pin_ctrl[] __initconst = {
2418     +static const struct samsung_pin_ctrl exynos7_pin_ctrl[] __initconst = {
2419     {
2420     /* pin-controller instance 0 Alive data */
2421     .pin_banks = exynos7_pin_banks0,
2422     @@ -397,3 +402,8 @@ const struct samsung_pin_ctrl exynos7_pin_ctrl[] __initconst = {
2423     .eint_gpio_init = exynos_eint_gpio_init,
2424     },
2425     };
2426     +
2427     +const struct samsung_pinctrl_of_match_data exynos7_of_data __initconst = {
2428     + .ctrl = exynos7_pin_ctrl,
2429     + .num_ctrl = ARRAY_SIZE(exynos7_pin_ctrl),
2430     +};
2431     diff --git a/drivers/pinctrl/samsung/pinctrl-s3c24xx.c b/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
2432     index edf27264b603..67da1cf18b68 100644
2433     --- a/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
2434     +++ b/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
2435     @@ -570,7 +570,7 @@ static const struct samsung_pin_bank_data s3c2412_pin_banks[] __initconst = {
2436     PIN_BANK_2BIT(13, 0x080, "gpj"),
2437     };
2438    
2439     -const struct samsung_pin_ctrl s3c2412_pin_ctrl[] __initconst = {
2440     +static const struct samsung_pin_ctrl s3c2412_pin_ctrl[] __initconst = {
2441     {
2442     .pin_banks = s3c2412_pin_banks,
2443     .nr_banks = ARRAY_SIZE(s3c2412_pin_banks),
2444     @@ -578,6 +578,11 @@ const struct samsung_pin_ctrl s3c2412_pin_ctrl[] __initconst = {
2445     },
2446     };
2447    
2448     +const struct samsung_pinctrl_of_match_data s3c2412_of_data __initconst = {
2449     + .ctrl = s3c2412_pin_ctrl,
2450     + .num_ctrl = ARRAY_SIZE(s3c2412_pin_ctrl),
2451     +};
2452     +
2453     static const struct samsung_pin_bank_data s3c2416_pin_banks[] __initconst = {
2454     PIN_BANK_A(27, 0x000, "gpa"),
2455     PIN_BANK_2BIT(11, 0x010, "gpb"),
2456     @@ -592,7 +597,7 @@ static const struct samsung_pin_bank_data s3c2416_pin_banks[] __initconst = {
2457     PIN_BANK_2BIT(2, 0x100, "gpm"),
2458     };
2459    
2460     -const struct samsung_pin_ctrl s3c2416_pin_ctrl[] __initconst = {
2461     +static const struct samsung_pin_ctrl s3c2416_pin_ctrl[] __initconst = {
2462     {
2463     .pin_banks = s3c2416_pin_banks,
2464     .nr_banks = ARRAY_SIZE(s3c2416_pin_banks),
2465     @@ -600,6 +605,11 @@ const struct samsung_pin_ctrl s3c2416_pin_ctrl[] __initconst = {
2466     },
2467     };
2468    
2469     +const struct samsung_pinctrl_of_match_data s3c2416_of_data __initconst = {
2470     + .ctrl = s3c2416_pin_ctrl,
2471     + .num_ctrl = ARRAY_SIZE(s3c2416_pin_ctrl),
2472     +};
2473     +
2474     static const struct samsung_pin_bank_data s3c2440_pin_banks[] __initconst = {
2475     PIN_BANK_A(25, 0x000, "gpa"),
2476     PIN_BANK_2BIT(11, 0x010, "gpb"),
2477     @@ -612,7 +622,7 @@ static const struct samsung_pin_bank_data s3c2440_pin_banks[] __initconst = {
2478     PIN_BANK_2BIT(13, 0x0d0, "gpj"),
2479     };
2480    
2481     -const struct samsung_pin_ctrl s3c2440_pin_ctrl[] __initconst = {
2482     +static const struct samsung_pin_ctrl s3c2440_pin_ctrl[] __initconst = {
2483     {
2484     .pin_banks = s3c2440_pin_banks,
2485     .nr_banks = ARRAY_SIZE(s3c2440_pin_banks),
2486     @@ -620,6 +630,11 @@ const struct samsung_pin_ctrl s3c2440_pin_ctrl[] __initconst = {
2487     },
2488     };
2489    
2490     +const struct samsung_pinctrl_of_match_data s3c2440_of_data __initconst = {
2491     + .ctrl = s3c2440_pin_ctrl,
2492     + .num_ctrl = ARRAY_SIZE(s3c2440_pin_ctrl),
2493     +};
2494     +
2495     static const struct samsung_pin_bank_data s3c2450_pin_banks[] __initconst = {
2496     PIN_BANK_A(28, 0x000, "gpa"),
2497     PIN_BANK_2BIT(11, 0x010, "gpb"),
2498     @@ -635,10 +650,15 @@ static const struct samsung_pin_bank_data s3c2450_pin_banks[] __initconst = {
2499     PIN_BANK_2BIT(2, 0x100, "gpm"),
2500     };
2501    
2502     -const struct samsung_pin_ctrl s3c2450_pin_ctrl[] __initconst = {
2503     +static const struct samsung_pin_ctrl s3c2450_pin_ctrl[] __initconst = {
2504     {
2505     .pin_banks = s3c2450_pin_banks,
2506     .nr_banks = ARRAY_SIZE(s3c2450_pin_banks),
2507     .eint_wkup_init = s3c24xx_eint_init,
2508     },
2509     };
2510     +
2511     +const struct samsung_pinctrl_of_match_data s3c2450_of_data __initconst = {
2512     + .ctrl = s3c2450_pin_ctrl,
2513     + .num_ctrl = ARRAY_SIZE(s3c2450_pin_ctrl),
2514     +};
2515     diff --git a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
2516     index e63663b32907..0bdc1e683181 100644
2517     --- a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
2518     +++ b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
2519     @@ -794,7 +794,7 @@ static const struct samsung_pin_bank_data s3c64xx_pin_banks0[] __initconst = {
2520     * Samsung pinctrl driver data for S3C64xx SoC. S3C64xx SoC includes
2521     * one gpio/pin-mux/pinconfig controller.
2522     */
2523     -const struct samsung_pin_ctrl s3c64xx_pin_ctrl[] __initconst = {
2524     +static const struct samsung_pin_ctrl s3c64xx_pin_ctrl[] __initconst = {
2525     {
2526     /* pin-controller instance 1 data */
2527     .pin_banks = s3c64xx_pin_banks0,
2528     @@ -803,3 +803,8 @@ const struct samsung_pin_ctrl s3c64xx_pin_ctrl[] __initconst = {
2529     .eint_wkup_init = s3c64xx_eint_eint0_init,
2530     },
2531     };
2532     +
2533     +const struct samsung_pinctrl_of_match_data s3c64xx_of_data __initconst = {
2534     + .ctrl = s3c64xx_pin_ctrl,
2535     + .num_ctrl = ARRAY_SIZE(s3c64xx_pin_ctrl),
2536     +};
2537     diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
2538     index e04f7fe0a65d..26e8fab736f1 100644
2539     --- a/drivers/pinctrl/samsung/pinctrl-samsung.c
2540     +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
2541     @@ -947,12 +947,33 @@ static int samsung_gpiolib_register(struct platform_device *pdev,
2542     return 0;
2543     }
2544    
2545     +static const struct samsung_pin_ctrl *
2546     +samsung_pinctrl_get_soc_data_for_of_alias(struct platform_device *pdev)
2547     +{
2548     + struct device_node *node = pdev->dev.of_node;
2549     + const struct samsung_pinctrl_of_match_data *of_data;
2550     + int id;
2551     +
2552     + id = of_alias_get_id(node, "pinctrl");
2553     + if (id < 0) {
2554     + dev_err(&pdev->dev, "failed to get alias id\n");
2555     + return NULL;
2556     + }
2557     +
2558     + of_data = of_device_get_match_data(&pdev->dev);
2559     + if (id >= of_data->num_ctrl) {
2560     + dev_err(&pdev->dev, "invalid alias id %d\n", id);
2561     + return NULL;
2562     + }
2563     +
2564     + return &(of_data->ctrl[id]);
2565     +}
2566     +
2567     /* retrieve the soc specific data */
2568     static const struct samsung_pin_ctrl *
2569     samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
2570     struct platform_device *pdev)
2571     {
2572     - int id;
2573     struct device_node *node = pdev->dev.of_node;
2574     struct device_node *np;
2575     const struct samsung_pin_bank_data *bdata;
2576     @@ -962,13 +983,9 @@ samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
2577     void __iomem *virt_base[SAMSUNG_PINCTRL_NUM_RESOURCES];
2578     unsigned int i;
2579    
2580     - id = of_alias_get_id(node, "pinctrl");
2581     - if (id < 0) {
2582     - dev_err(&pdev->dev, "failed to get alias id\n");
2583     + ctrl = samsung_pinctrl_get_soc_data_for_of_alias(pdev);
2584     + if (!ctrl)
2585     return ERR_PTR(-ENOENT);
2586     - }
2587     - ctrl = of_device_get_match_data(&pdev->dev);
2588     - ctrl += id;
2589    
2590     d->suspend = ctrl->suspend;
2591     d->resume = ctrl->resume;
2592     @@ -1193,41 +1210,41 @@ static int __maybe_unused samsung_pinctrl_resume(struct device *dev)
2593     static const struct of_device_id samsung_pinctrl_dt_match[] = {
2594     #ifdef CONFIG_PINCTRL_EXYNOS_ARM
2595     { .compatible = "samsung,exynos3250-pinctrl",
2596     - .data = exynos3250_pin_ctrl },
2597     + .data = &exynos3250_of_data },
2598     { .compatible = "samsung,exynos4210-pinctrl",
2599     - .data = exynos4210_pin_ctrl },
2600     + .data = &exynos4210_of_data },
2601     { .compatible = "samsung,exynos4x12-pinctrl",
2602     - .data = exynos4x12_pin_ctrl },
2603     + .data = &exynos4x12_of_data },
2604     { .compatible = "samsung,exynos5250-pinctrl",
2605     - .data = exynos5250_pin_ctrl },
2606     + .data = &exynos5250_of_data },
2607     { .compatible = "samsung,exynos5260-pinctrl",
2608     - .data = exynos5260_pin_ctrl },
2609     + .data = &exynos5260_of_data },
2610     { .compatible = "samsung,exynos5410-pinctrl",
2611     - .data = exynos5410_pin_ctrl },
2612     + .data = &exynos5410_of_data },
2613     { .compatible = "samsung,exynos5420-pinctrl",
2614     - .data = exynos5420_pin_ctrl },
2615     + .data = &exynos5420_of_data },
2616     { .compatible = "samsung,s5pv210-pinctrl",
2617     - .data = s5pv210_pin_ctrl },
2618     + .data = &s5pv210_of_data },
2619     #endif
2620     #ifdef CONFIG_PINCTRL_EXYNOS_ARM64
2621     { .compatible = "samsung,exynos5433-pinctrl",
2622     - .data = exynos5433_pin_ctrl },
2623     + .data = &exynos5433_of_data },
2624     { .compatible = "samsung,exynos7-pinctrl",
2625     - .data = exynos7_pin_ctrl },
2626     + .data = &exynos7_of_data },
2627     #endif
2628     #ifdef CONFIG_PINCTRL_S3C64XX
2629     { .compatible = "samsung,s3c64xx-pinctrl",
2630     - .data = s3c64xx_pin_ctrl },
2631     + .data = &s3c64xx_of_data },
2632     #endif
2633     #ifdef CONFIG_PINCTRL_S3C24XX
2634     { .compatible = "samsung,s3c2412-pinctrl",
2635     - .data = s3c2412_pin_ctrl },
2636     + .data = &s3c2412_of_data },
2637     { .compatible = "samsung,s3c2416-pinctrl",
2638     - .data = s3c2416_pin_ctrl },
2639     + .data = &s3c2416_of_data },
2640     { .compatible = "samsung,s3c2440-pinctrl",
2641     - .data = s3c2440_pin_ctrl },
2642     + .data = &s3c2440_of_data },
2643     { .compatible = "samsung,s3c2450-pinctrl",
2644     - .data = s3c2450_pin_ctrl },
2645     + .data = &s3c2450_of_data },
2646     #endif
2647     {},
2648     };
2649     diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.h b/drivers/pinctrl/samsung/pinctrl-samsung.h
2650     index 9af07af6cad6..ae932e0c05f2 100644
2651     --- a/drivers/pinctrl/samsung/pinctrl-samsung.h
2652     +++ b/drivers/pinctrl/samsung/pinctrl-samsung.h
2653     @@ -285,6 +285,16 @@ struct samsung_pinctrl_drv_data {
2654     void (*resume)(struct samsung_pinctrl_drv_data *);
2655     };
2656    
2657     +/**
2658     + * struct samsung_pinctrl_of_match_data: OF match device specific configuration data.
2659     + * @ctrl: array of pin controller data.
2660     + * @num_ctrl: size of array @ctrl.
2661     + */
2662     +struct samsung_pinctrl_of_match_data {
2663     + const struct samsung_pin_ctrl *ctrl;
2664     + unsigned int num_ctrl;
2665     +};
2666     +
2667     /**
2668     * struct samsung_pin_group: represent group of pins of a pinmux function.
2669     * @name: name of the pin group, used to lookup the group.
2670     @@ -313,20 +323,20 @@ struct samsung_pmx_func {
2671     };
2672    
2673     /* list of all exported SoC specific data */
2674     -extern const struct samsung_pin_ctrl exynos3250_pin_ctrl[];
2675     -extern const struct samsung_pin_ctrl exynos4210_pin_ctrl[];
2676     -extern const struct samsung_pin_ctrl exynos4x12_pin_ctrl[];
2677     -extern const struct samsung_pin_ctrl exynos5250_pin_ctrl[];
2678     -extern const struct samsung_pin_ctrl exynos5260_pin_ctrl[];
2679     -extern const struct samsung_pin_ctrl exynos5410_pin_ctrl[];
2680     -extern const struct samsung_pin_ctrl exynos5420_pin_ctrl[];
2681     -extern const struct samsung_pin_ctrl exynos5433_pin_ctrl[];
2682     -extern const struct samsung_pin_ctrl exynos7_pin_ctrl[];
2683     -extern const struct samsung_pin_ctrl s3c64xx_pin_ctrl[];
2684     -extern const struct samsung_pin_ctrl s3c2412_pin_ctrl[];
2685     -extern const struct samsung_pin_ctrl s3c2416_pin_ctrl[];
2686     -extern const struct samsung_pin_ctrl s3c2440_pin_ctrl[];
2687     -extern const struct samsung_pin_ctrl s3c2450_pin_ctrl[];
2688     -extern const struct samsung_pin_ctrl s5pv210_pin_ctrl[];
2689     +extern const struct samsung_pinctrl_of_match_data exynos3250_of_data;
2690     +extern const struct samsung_pinctrl_of_match_data exynos4210_of_data;
2691     +extern const struct samsung_pinctrl_of_match_data exynos4x12_of_data;
2692     +extern const struct samsung_pinctrl_of_match_data exynos5250_of_data;
2693     +extern const struct samsung_pinctrl_of_match_data exynos5260_of_data;
2694     +extern const struct samsung_pinctrl_of_match_data exynos5410_of_data;
2695     +extern const struct samsung_pinctrl_of_match_data exynos5420_of_data;
2696     +extern const struct samsung_pinctrl_of_match_data exynos5433_of_data;
2697     +extern const struct samsung_pinctrl_of_match_data exynos7_of_data;
2698     +extern const struct samsung_pinctrl_of_match_data s3c64xx_of_data;
2699     +extern const struct samsung_pinctrl_of_match_data s3c2412_of_data;
2700     +extern const struct samsung_pinctrl_of_match_data s3c2416_of_data;
2701     +extern const struct samsung_pinctrl_of_match_data s3c2440_of_data;
2702     +extern const struct samsung_pinctrl_of_match_data s3c2450_of_data;
2703     +extern const struct samsung_pinctrl_of_match_data s5pv210_of_data;
2704    
2705     #endif /* __PINCTRL_SAMSUNG_H */
2706     diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c
2707     index 86196ffd2faf..fa3e4b7e0c9f 100644
2708     --- a/drivers/staging/android/ion/ion_cma_heap.c
2709     +++ b/drivers/staging/android/ion/ion_cma_heap.c
2710     @@ -21,6 +21,7 @@
2711     #include <linux/err.h>
2712     #include <linux/cma.h>
2713     #include <linux/scatterlist.h>
2714     +#include <linux/highmem.h>
2715    
2716     #include "ion.h"
2717    
2718     @@ -51,6 +52,22 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer,
2719     if (!pages)
2720     return -ENOMEM;
2721    
2722     + if (PageHighMem(pages)) {
2723     + unsigned long nr_clear_pages = nr_pages;
2724     + struct page *page = pages;
2725     +
2726     + while (nr_clear_pages > 0) {
2727     + void *vaddr = kmap_atomic(page);
2728     +
2729     + memset(vaddr, 0, PAGE_SIZE);
2730     + kunmap_atomic(vaddr);
2731     + page++;
2732     + nr_clear_pages--;
2733     + }
2734     + } else {
2735     + memset(page_address(pages), 0, size);
2736     + }
2737     +
2738     table = kmalloc(sizeof(*table), GFP_KERNEL);
2739     if (!table)
2740     goto err;
2741     diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c
2742     index cd7a5391a574..0a3f832095ea 100644
2743     --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
2744     +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
2745     @@ -847,7 +847,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req)
2746     if (req->rq_pool || !req->rq_reqbuf)
2747     return;
2748    
2749     - kfree(req->rq_reqbuf);
2750     + kvfree(req->rq_reqbuf);
2751     req->rq_reqbuf = NULL;
2752     req->rq_reqbuf_len = 0;
2753     }
2754     diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
2755     index 2ebaba16f785..5a5813d01cf8 100644
2756     --- a/drivers/tty/vt/vt.c
2757     +++ b/drivers/tty/vt/vt.c
2758     @@ -1725,7 +1725,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear)
2759     default_attr(vc);
2760     update_attr(vc);
2761    
2762     - vc->vc_tab_stop[0] = 0x01010100;
2763     + vc->vc_tab_stop[0] =
2764     vc->vc_tab_stop[1] =
2765     vc->vc_tab_stop[2] =
2766     vc->vc_tab_stop[3] =
2767     @@ -1769,7 +1769,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
2768     vc->vc_pos -= (vc->vc_x << 1);
2769     while (vc->vc_x < vc->vc_cols - 1) {
2770     vc->vc_x++;
2771     - if (vc->vc_tab_stop[vc->vc_x >> 5] & (1 << (vc->vc_x & 31)))
2772     + if (vc->vc_tab_stop[7 & (vc->vc_x >> 5)] & (1 << (vc->vc_x & 31)))
2773     break;
2774     }
2775     vc->vc_pos += (vc->vc_x << 1);
2776     @@ -1829,7 +1829,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
2777     lf(vc);
2778     return;
2779     case 'H':
2780     - vc->vc_tab_stop[vc->vc_x >> 5] |= (1 << (vc->vc_x & 31));
2781     + vc->vc_tab_stop[7 & (vc->vc_x >> 5)] |= (1 << (vc->vc_x & 31));
2782     return;
2783     case 'Z':
2784     respond_ID(tty);
2785     @@ -2022,7 +2022,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
2786     return;
2787     case 'g':
2788     if (!vc->vc_par[0])
2789     - vc->vc_tab_stop[vc->vc_x >> 5] &= ~(1 << (vc->vc_x & 31));
2790     + vc->vc_tab_stop[7 & (vc->vc_x >> 5)] &= ~(1 << (vc->vc_x & 31));
2791     else if (vc->vc_par[0] == 3) {
2792     vc->vc_tab_stop[0] =
2793     vc->vc_tab_stop[1] =
2794     diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
2795     index a2336deb5e36..9762333d8d7f 100644
2796     --- a/drivers/usb/host/xhci-hub.c
2797     +++ b/drivers/usb/host/xhci-hub.c
2798     @@ -634,7 +634,10 @@ static int xhci_enter_test_mode(struct xhci_hcd *xhci,
2799     xhci_dbg(xhci, "Disable all slots\n");
2800     spin_unlock_irqrestore(&xhci->lock, *flags);
2801     for (i = 1; i <= HCS_MAX_SLOTS(xhci->hcs_params1); i++) {
2802     - retval = xhci_disable_slot(xhci, NULL, i);
2803     + if (!xhci->devs[i])
2804     + continue;
2805     +
2806     + retval = xhci_disable_slot(xhci, i);
2807     if (retval)
2808     xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n",
2809     i, retval);
2810     diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
2811     index bad76a7c7f2f..bcf315b32bff 100644
2812     --- a/drivers/usb/host/xhci.c
2813     +++ b/drivers/usb/host/xhci.c
2814     @@ -3523,11 +3523,6 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
2815     struct xhci_virt_device *virt_dev;
2816     struct xhci_slot_ctx *slot_ctx;
2817     int i, ret;
2818     - struct xhci_command *command;
2819     -
2820     - command = xhci_alloc_command(xhci, false, false, GFP_KERNEL);
2821     - if (!command)
2822     - return;
2823    
2824     #ifndef CONFIG_USB_DEFAULT_PERSIST
2825     /*
2826     @@ -3543,10 +3538,8 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
2827     /* If the host is halted due to driver unload, we still need to free the
2828     * device.
2829     */
2830     - if (ret <= 0 && ret != -ENODEV) {
2831     - kfree(command);
2832     + if (ret <= 0 && ret != -ENODEV)
2833     return;
2834     - }
2835    
2836     virt_dev = xhci->devs[udev->slot_id];
2837     slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx);
2838     @@ -3558,26 +3551,21 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
2839     del_timer_sync(&virt_dev->eps[i].stop_cmd_timer);
2840     }
2841    
2842     - xhci_disable_slot(xhci, command, udev->slot_id);
2843     + xhci_disable_slot(xhci, udev->slot_id);
2844     /*
2845     * Event command completion handler will free any data structures
2846     * associated with the slot. XXX Can free sleep?
2847     */
2848     }
2849    
2850     -int xhci_disable_slot(struct xhci_hcd *xhci, struct xhci_command *command,
2851     - u32 slot_id)
2852     +int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id)
2853     {
2854     + struct xhci_command *command;
2855     unsigned long flags;
2856     u32 state;
2857     int ret = 0;
2858     - struct xhci_virt_device *virt_dev;
2859    
2860     - virt_dev = xhci->devs[slot_id];
2861     - if (!virt_dev)
2862     - return -EINVAL;
2863     - if (!command)
2864     - command = xhci_alloc_command(xhci, false, false, GFP_KERNEL);
2865     + command = xhci_alloc_command(xhci, false, false, GFP_KERNEL);
2866     if (!command)
2867     return -ENOMEM;
2868    
2869     @@ -3595,7 +3583,7 @@ int xhci_disable_slot(struct xhci_hcd *xhci, struct xhci_command *command,
2870     slot_id);
2871     if (ret) {
2872     spin_unlock_irqrestore(&xhci->lock, flags);
2873     - xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
2874     + kfree(command);
2875     return ret;
2876     }
2877     xhci_ring_cmd_db(xhci);
2878     @@ -3670,6 +3658,8 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
2879     return 0;
2880     }
2881    
2882     + xhci_free_command(xhci, command);
2883     +
2884     if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) {
2885     spin_lock_irqsave(&xhci->lock, flags);
2886     ret = xhci_reserve_host_control_ep_resources(xhci);
2887     @@ -3705,18 +3695,12 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
2888     pm_runtime_get_noresume(hcd->self.controller);
2889     #endif
2890    
2891     -
2892     - xhci_free_command(xhci, command);
2893     /* Is this a LS or FS device under a HS hub? */
2894     /* Hub or peripherial? */
2895     return 1;
2896    
2897     disable_slot:
2898     - /* Disable slot, if we can do it without mem alloc */
2899     - kfree(command->completion);
2900     - command->completion = NULL;
2901     - command->status = 0;
2902     - return xhci_disable_slot(xhci, command, udev->slot_id);
2903     + return xhci_disable_slot(xhci, udev->slot_id);
2904     }
2905    
2906     /*
2907     diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
2908     index 2eaf6e1f12ee..f5fb1f4a092c 100644
2909     --- a/drivers/usb/host/xhci.h
2910     +++ b/drivers/usb/host/xhci.h
2911     @@ -2014,8 +2014,7 @@ int xhci_run(struct usb_hcd *hcd);
2912     int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
2913     void xhci_init_driver(struct hc_driver *drv,
2914     const struct xhci_driver_overrides *over);
2915     -int xhci_disable_slot(struct xhci_hcd *xhci,
2916     - struct xhci_command *command, u32 slot_id);
2917     +int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id);
2918    
2919     int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup);
2920     int xhci_resume(struct xhci_hcd *xhci, bool hibernated);
2921     diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c
2922     index 6d1fbda0f461..0da9943d405f 100644
2923     --- a/drivers/watchdog/wdat_wdt.c
2924     +++ b/drivers/watchdog/wdat_wdt.c
2925     @@ -392,7 +392,7 @@ static int wdat_wdt_probe(struct platform_device *pdev)
2926    
2927     memset(&r, 0, sizeof(r));
2928     r.start = gas->address;
2929     - r.end = r.start + gas->access_width;
2930     + r.end = r.start + gas->access_width - 1;
2931     if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
2932     r.flags = IORESOURCE_MEM;
2933     } else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
2934     diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
2935     index ed113ea17aff..3b293d0d1785 100644
2936     --- a/fs/hugetlbfs/inode.c
2937     +++ b/fs/hugetlbfs/inode.c
2938     @@ -118,6 +118,16 @@ static void huge_pagevec_release(struct pagevec *pvec)
2939     pagevec_reinit(pvec);
2940     }
2941    
2942     +/*
2943     + * Mask used when checking the page offset value passed in via system
2944     + * calls. This value will be converted to a loff_t which is signed.
2945     + * Therefore, we want to check the upper PAGE_SHIFT + 1 bits of the
2946     + * value. The extra bit (- 1 in the shift value) is to take the sign
2947     + * bit into account.
2948     + */
2949     +#define PGOFF_LOFFT_MAX \
2950     + (((1UL << (PAGE_SHIFT + 1)) - 1) << (BITS_PER_LONG - (PAGE_SHIFT + 1)))
2951     +
2952     static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
2953     {
2954     struct inode *inode = file_inode(file);
2955     @@ -137,12 +147,13 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
2956     vma->vm_ops = &hugetlb_vm_ops;
2957    
2958     /*
2959     - * Offset passed to mmap (before page shift) could have been
2960     - * negative when represented as a (l)off_t.
2961     + * page based offset in vm_pgoff could be sufficiently large to
2962     + * overflow a (l)off_t when converted to byte offset.
2963     */
2964     - if (((loff_t)vma->vm_pgoff << PAGE_SHIFT) < 0)
2965     + if (vma->vm_pgoff & PGOFF_LOFFT_MAX)
2966     return -EINVAL;
2967    
2968     + /* must be huge page aligned */
2969     if (vma->vm_pgoff & (~huge_page_mask(h) >> PAGE_SHIFT))
2970     return -EINVAL;
2971    
2972     diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c
2973     index 804adfebba2f..3e047eb4cc7c 100644
2974     --- a/fs/ncpfs/ncplib_kernel.c
2975     +++ b/fs/ncpfs/ncplib_kernel.c
2976     @@ -981,6 +981,10 @@ ncp_read_kernel(struct ncp_server *server, const char *file_id,
2977     goto out;
2978     }
2979     *bytes_read = ncp_reply_be16(server, 0);
2980     + if (*bytes_read > to_read) {
2981     + result = -EINVAL;
2982     + goto out;
2983     + }
2984     source = ncp_reply_data(server, 2 + (offset & 1));
2985    
2986     memcpy(target, source, *bytes_read);
2987     diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
2988     index d89e6ccd33ba..3cef6bfa09d4 100644
2989     --- a/fs/nfsd/nfs4state.c
2990     +++ b/fs/nfsd/nfs4state.c
2991     @@ -263,6 +263,35 @@ free_blocked_lock(struct nfsd4_blocked_lock *nbl)
2992     kfree(nbl);
2993     }
2994    
2995     +static void
2996     +remove_blocked_locks(struct nfs4_lockowner *lo)
2997     +{
2998     + struct nfs4_client *clp = lo->lo_owner.so_client;
2999     + struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
3000     + struct nfsd4_blocked_lock *nbl;
3001     + LIST_HEAD(reaplist);
3002     +
3003     + /* Dequeue all blocked locks */
3004     + spin_lock(&nn->blocked_locks_lock);
3005     + while (!list_empty(&lo->lo_blocked)) {
3006     + nbl = list_first_entry(&lo->lo_blocked,
3007     + struct nfsd4_blocked_lock,
3008     + nbl_list);
3009     + list_del_init(&nbl->nbl_list);
3010     + list_move(&nbl->nbl_lru, &reaplist);
3011     + }
3012     + spin_unlock(&nn->blocked_locks_lock);
3013     +
3014     + /* Now free them */
3015     + while (!list_empty(&reaplist)) {
3016     + nbl = list_first_entry(&reaplist, struct nfsd4_blocked_lock,
3017     + nbl_lru);
3018     + list_del_init(&nbl->nbl_lru);
3019     + posix_unblock_lock(&nbl->nbl_lock);
3020     + free_blocked_lock(nbl);
3021     + }
3022     +}
3023     +
3024     static int
3025     nfsd4_cb_notify_lock_done(struct nfsd4_callback *cb, struct rpc_task *task)
3026     {
3027     @@ -1854,6 +1883,7 @@ static __be32 mark_client_expired_locked(struct nfs4_client *clp)
3028     static void
3029     __destroy_client(struct nfs4_client *clp)
3030     {
3031     + int i;
3032     struct nfs4_openowner *oo;
3033     struct nfs4_delegation *dp;
3034     struct list_head reaplist;
3035     @@ -1883,6 +1913,16 @@ __destroy_client(struct nfs4_client *clp)
3036     nfs4_get_stateowner(&oo->oo_owner);
3037     release_openowner(oo);
3038     }
3039     + for (i = 0; i < OWNER_HASH_SIZE; i++) {
3040     + struct nfs4_stateowner *so, *tmp;
3041     +
3042     + list_for_each_entry_safe(so, tmp, &clp->cl_ownerstr_hashtbl[i],
3043     + so_strhash) {
3044     + /* Should be no openowners at this point */
3045     + WARN_ON_ONCE(so->so_is_open_owner);
3046     + remove_blocked_locks(lockowner(so));
3047     + }
3048     + }
3049     nfsd4_return_all_client_layouts(clp);
3050     nfsd4_shutdown_callback(clp);
3051     if (clp->cl_cb_conn.cb_xprt)
3052     @@ -6275,6 +6315,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
3053     }
3054     spin_unlock(&clp->cl_lock);
3055     free_ol_stateid_reaplist(&reaplist);
3056     + remove_blocked_locks(lo);
3057     nfs4_put_stateowner(&lo->lo_owner);
3058    
3059     return status;
3060     @@ -7060,6 +7101,8 @@ nfs4_state_destroy_net(struct net *net)
3061     }
3062     }
3063    
3064     + WARN_ON(!list_empty(&nn->blocked_locks_lru));
3065     +
3066     for (i = 0; i < CLIENT_HASH_SIZE; i++) {
3067     while (!list_empty(&nn->unconf_id_hashtbl[i])) {
3068     clp = list_entry(nn->unconf_id_hashtbl[i].next, struct nfs4_client, cl_idhash);
3069     @@ -7126,7 +7169,6 @@ nfs4_state_shutdown_net(struct net *net)
3070     struct nfs4_delegation *dp = NULL;
3071     struct list_head *pos, *next, reaplist;
3072     struct nfsd_net *nn = net_generic(net, nfsd_net_id);
3073     - struct nfsd4_blocked_lock *nbl;
3074    
3075     cancel_delayed_work_sync(&nn->laundromat_work);
3076     locks_end_grace(&nn->nfsd4_manager);
3077     @@ -7147,24 +7189,6 @@ nfs4_state_shutdown_net(struct net *net)
3078     nfs4_put_stid(&dp->dl_stid);
3079     }
3080    
3081     - BUG_ON(!list_empty(&reaplist));
3082     - spin_lock(&nn->blocked_locks_lock);
3083     - while (!list_empty(&nn->blocked_locks_lru)) {
3084     - nbl = list_first_entry(&nn->blocked_locks_lru,
3085     - struct nfsd4_blocked_lock, nbl_lru);
3086     - list_move(&nbl->nbl_lru, &reaplist);
3087     - list_del_init(&nbl->nbl_list);
3088     - }
3089     - spin_unlock(&nn->blocked_locks_lock);
3090     -
3091     - while (!list_empty(&reaplist)) {
3092     - nbl = list_first_entry(&reaplist,
3093     - struct nfsd4_blocked_lock, nbl_lru);
3094     - list_del_init(&nbl->nbl_lru);
3095     - posix_unblock_lock(&nbl->nbl_lock);
3096     - free_blocked_lock(nbl);
3097     - }
3098     -
3099     nfsd4_client_tracking_exit(net);
3100     nfs4_state_destroy_net(net);
3101     }
3102     diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
3103     index 045a7f52ab3a..77b891a8f191 100644
3104     --- a/include/asm-generic/pgtable.h
3105     +++ b/include/asm-generic/pgtable.h
3106     @@ -976,6 +976,8 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot);
3107     int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot);
3108     int pud_clear_huge(pud_t *pud);
3109     int pmd_clear_huge(pmd_t *pmd);
3110     +int pud_free_pmd_page(pud_t *pud);
3111     +int pmd_free_pte_page(pmd_t *pmd);
3112     #else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
3113     static inline int p4d_set_huge(p4d_t *p4d, phys_addr_t addr, pgprot_t prot)
3114     {
3115     @@ -1001,6 +1003,14 @@ static inline int pmd_clear_huge(pmd_t *pmd)
3116     {
3117     return 0;
3118     }
3119     +static inline int pud_free_pmd_page(pud_t *pud)
3120     +{
3121     + return 0;
3122     +}
3123     +static inline int pmd_free_pte_page(pmd_t *pmd)
3124     +{
3125     + return 0;
3126     +}
3127     #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
3128    
3129     #ifndef __HAVE_ARCH_FLUSH_PMD_TLB_RANGE
3130     diff --git a/include/drm/drm_syncobj.h b/include/drm/drm_syncobj.h
3131     index c00fee539822..6d45aae47b2e 100644
3132     --- a/include/drm/drm_syncobj.h
3133     +++ b/include/drm/drm_syncobj.h
3134     @@ -60,11 +60,6 @@ struct drm_syncobj {
3135     * locks cb_list and write-locks fence.
3136     */
3137     spinlock_t lock;
3138     - /**
3139     - * @file:
3140     - * a file backing for this syncobj.
3141     - */
3142     - struct file *file;
3143     };
3144    
3145     typedef void (*drm_syncobj_func_t)(struct drm_syncobj *syncobj,
3146     diff --git a/include/linux/fsl_ifc.h b/include/linux/fsl_ifc.h
3147     index c332f0a45607..3fdfede2f0f3 100644
3148     --- a/include/linux/fsl_ifc.h
3149     +++ b/include/linux/fsl_ifc.h
3150     @@ -734,11 +734,7 @@ struct fsl_ifc_nand {
3151     u32 res19[0x10];
3152     __be32 nand_fsr;
3153     u32 res20;
3154     - /* The V1 nand_eccstat is actually 4 words that overlaps the
3155     - * V2 nand_eccstat.
3156     - */
3157     - __be32 v1_nand_eccstat[2];
3158     - __be32 v2_nand_eccstat[6];
3159     + __be32 nand_eccstat[8];
3160     u32 res21[0x1c];
3161     __be32 nanndcr;
3162     u32 res22[0x2];
3163     diff --git a/include/linux/memblock.h b/include/linux/memblock.h
3164     index bae11c7e7bf3..2dec2d4b469b 100644
3165     --- a/include/linux/memblock.h
3166     +++ b/include/linux/memblock.h
3167     @@ -187,7 +187,6 @@ int memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn,
3168     unsigned long *end_pfn);
3169     void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn,
3170     unsigned long *out_end_pfn, int *out_nid);
3171     -unsigned long memblock_next_valid_pfn(unsigned long pfn, unsigned long max_pfn);
3172    
3173     /**
3174     * for_each_mem_pfn_range - early memory pfn range iterator
3175     diff --git a/include/trace/events/mmc.h b/include/trace/events/mmc.h
3176     index 200f731be557..7b706ff21335 100644
3177     --- a/include/trace/events/mmc.h
3178     +++ b/include/trace/events/mmc.h
3179     @@ -86,8 +86,8 @@ TRACE_EVENT(mmc_request_start,
3180     __entry->stop_flags, __entry->stop_retries,
3181     __entry->sbc_opcode, __entry->sbc_arg,
3182     __entry->sbc_flags, __entry->sbc_retries,
3183     - __entry->blocks, __entry->blk_addr,
3184     - __entry->blksz, __entry->data_flags, __entry->tag,
3185     + __entry->blocks, __entry->blksz,
3186     + __entry->blk_addr, __entry->data_flags, __entry->tag,
3187     __entry->can_retune, __entry->doing_retune,
3188     __entry->retune_now, __entry->need_retune,
3189     __entry->hold_retune, __entry->retune_period)
3190     diff --git a/include/uapi/linux/usb/audio.h b/include/uapi/linux/usb/audio.h
3191     index 17a022c5b414..da3315ed1bcd 100644
3192     --- a/include/uapi/linux/usb/audio.h
3193     +++ b/include/uapi/linux/usb/audio.h
3194     @@ -370,7 +370,7 @@ static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_d
3195     {
3196     return (protocol == UAC_VERSION_1) ?
3197     desc->baSourceID[desc->bNrInPins + 4] :
3198     - desc->baSourceID[desc->bNrInPins + 6];
3199     + 2; /* in UAC2, this value is constant */
3200     }
3201    
3202     static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
3203     @@ -378,7 +378,7 @@ static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_de
3204     {
3205     return (protocol == UAC_VERSION_1) ?
3206     &desc->baSourceID[desc->bNrInPins + 5] :
3207     - &desc->baSourceID[desc->bNrInPins + 7];
3208     + &desc->baSourceID[desc->bNrInPins + 6];
3209     }
3210    
3211     static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
3212     diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
3213     index 25d074920a00..4e933219fec6 100644
3214     --- a/kernel/bpf/syscall.c
3215     +++ b/kernel/bpf/syscall.c
3216     @@ -1455,7 +1455,7 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, siz
3217     union bpf_attr attr = {};
3218     int err;
3219    
3220     - if (!capable(CAP_SYS_ADMIN) && sysctl_unprivileged_bpf_disabled)
3221     + if (sysctl_unprivileged_bpf_disabled && !capable(CAP_SYS_ADMIN))
3222     return -EPERM;
3223    
3224     err = check_uarg_tail_zero(uattr, sizeof(attr), size);
3225     diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
3226     index 030e4286f14c..76c0ef2cb509 100644
3227     --- a/kernel/cgroup/cgroup.c
3228     +++ b/kernel/cgroup/cgroup.c
3229     @@ -3148,6 +3148,16 @@ static int cgroup_enable_threaded(struct cgroup *cgrp)
3230     if (cgroup_is_threaded(cgrp))
3231     return 0;
3232    
3233     + /*
3234     + * If @cgroup is populated or has domain controllers enabled, it
3235     + * can't be switched. While the below cgroup_can_be_thread_root()
3236     + * test can catch the same conditions, that's only when @parent is
3237     + * not mixable, so let's check it explicitly.
3238     + */
3239     + if (cgroup_is_populated(cgrp) ||
3240     + cgrp->subtree_control & ~cgrp_dfl_threaded_ss_mask)
3241     + return -EOPNOTSUPP;
3242     +
3243     /* we're joining the parent's domain, ensure its validity */
3244     if (!cgroup_is_valid_domain(dom_cgrp) ||
3245     !cgroup_can_be_thread_root(dom_cgrp))
3246     diff --git a/kernel/events/core.c b/kernel/events/core.c
3247     index f42f7c7a8f84..cecd72eb09b8 100644
3248     --- a/kernel/events/core.c
3249     +++ b/kernel/events/core.c
3250     @@ -2322,7 +2322,7 @@ static void ctx_resched(struct perf_cpu_context *cpuctx,
3251     struct perf_event_context *task_ctx,
3252     enum event_type_t event_type)
3253     {
3254     - enum event_type_t ctx_event_type = event_type & EVENT_ALL;
3255     + enum event_type_t ctx_event_type;
3256     bool cpu_event = !!(event_type & EVENT_CPU);
3257    
3258     /*
3259     @@ -2332,6 +2332,8 @@ static void ctx_resched(struct perf_cpu_context *cpuctx,
3260     if (event_type & EVENT_PINNED)
3261     event_type |= EVENT_FLEXIBLE;
3262    
3263     + ctx_event_type = event_type & EVENT_ALL;
3264     +
3265     perf_pmu_disable(cpuctx->ctx.pmu);
3266     if (task_ctx)
3267     task_ctx_sched_out(cpuctx, task_ctx, event_type);
3268     diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
3269     index ec999f32c840..708992708332 100644
3270     --- a/kernel/time/posix-timers.c
3271     +++ b/kernel/time/posix-timers.c
3272     @@ -50,6 +50,7 @@
3273     #include <linux/export.h>
3274     #include <linux/hashtable.h>
3275     #include <linux/compat.h>
3276     +#include <linux/nospec.h>
3277    
3278     #include "timekeeping.h"
3279     #include "posix-timers.h"
3280     @@ -1346,11 +1347,15 @@ static const struct k_clock * const posix_clocks[] = {
3281    
3282     static const struct k_clock *clockid_to_kclock(const clockid_t id)
3283     {
3284     - if (id < 0)
3285     + clockid_t idx = id;
3286     +
3287     + if (id < 0) {
3288     return (id & CLOCKFD_MASK) == CLOCKFD ?
3289     &clock_posix_dynamic : &clock_posix_cpu;
3290     + }
3291    
3292     - if (id >= ARRAY_SIZE(posix_clocks) || !posix_clocks[id])
3293     + if (id >= ARRAY_SIZE(posix_clocks))
3294     return NULL;
3295     - return posix_clocks[id];
3296     +
3297     + return posix_clocks[array_index_nospec(idx, ARRAY_SIZE(posix_clocks))];
3298     }
3299     diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
3300     index 8a907e12b6b9..f8d3bd974bcc 100644
3301     --- a/kernel/trace/trace_kprobe.c
3302     +++ b/kernel/trace/trace_kprobe.c
3303     @@ -635,7 +635,7 @@ static int create_trace_kprobe(int argc, char **argv)
3304     char *symbol = NULL, *event = NULL, *group = NULL;
3305     int maxactive = 0;
3306     char *arg;
3307     - unsigned long offset = 0;
3308     + long offset = 0;
3309     void *addr = NULL;
3310     char buf[MAX_EVENT_NAME_LEN];
3311    
3312     @@ -723,7 +723,7 @@ static int create_trace_kprobe(int argc, char **argv)
3313     symbol = argv[1];
3314     /* TODO: support .init module functions */
3315     ret = traceprobe_split_symbol_offset(symbol, &offset);
3316     - if (ret) {
3317     + if (ret || offset < 0 || offset > UINT_MAX) {
3318     pr_info("Failed to parse either an address or a symbol.\n");
3319     return ret;
3320     }
3321     diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
3322     index 52478f033f88..fe4513330412 100644
3323     --- a/kernel/trace/trace_probe.c
3324     +++ b/kernel/trace/trace_probe.c
3325     @@ -320,7 +320,7 @@ static fetch_func_t get_fetch_size_function(const struct fetch_type *type,
3326     }
3327    
3328     /* Split symbol and offset. */
3329     -int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset)
3330     +int traceprobe_split_symbol_offset(char *symbol, long *offset)
3331     {
3332     char *tmp;
3333     int ret;
3334     @@ -328,13 +328,11 @@ int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset)
3335     if (!offset)
3336     return -EINVAL;
3337    
3338     - tmp = strchr(symbol, '+');
3339     + tmp = strpbrk(symbol, "+-");
3340     if (tmp) {
3341     - /* skip sign because kstrtoul doesn't accept '+' */
3342     - ret = kstrtoul(tmp + 1, 0, offset);
3343     + ret = kstrtol(tmp, 0, offset);
3344     if (ret)
3345     return ret;
3346     -
3347     *tmp = '\0';
3348     } else
3349     *offset = 0;
3350     diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
3351     index 903273c93e61..dc39472ca9e4 100644
3352     --- a/kernel/trace/trace_probe.h
3353     +++ b/kernel/trace/trace_probe.h
3354     @@ -354,7 +354,7 @@ extern int traceprobe_conflict_field_name(const char *name,
3355     extern void traceprobe_update_arg(struct probe_arg *arg);
3356     extern void traceprobe_free_probe_arg(struct probe_arg *arg);
3357    
3358     -extern int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset);
3359     +extern int traceprobe_split_symbol_offset(char *symbol, long *offset);
3360    
3361     extern ssize_t traceprobe_probes_write(struct file *file,
3362     const char __user *buffer, size_t count, loff_t *ppos,
3363     diff --git a/lib/ioremap.c b/lib/ioremap.c
3364     index b808a390e4c3..54e5bbaa3200 100644
3365     --- a/lib/ioremap.c
3366     +++ b/lib/ioremap.c
3367     @@ -91,7 +91,8 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
3368    
3369     if (ioremap_pmd_enabled() &&
3370     ((next - addr) == PMD_SIZE) &&
3371     - IS_ALIGNED(phys_addr + addr, PMD_SIZE)) {
3372     + IS_ALIGNED(phys_addr + addr, PMD_SIZE) &&
3373     + pmd_free_pte_page(pmd)) {
3374     if (pmd_set_huge(pmd, phys_addr + addr, prot))
3375     continue;
3376     }
3377     @@ -117,7 +118,8 @@ static inline int ioremap_pud_range(p4d_t *p4d, unsigned long addr,
3378    
3379     if (ioremap_pud_enabled() &&
3380     ((next - addr) == PUD_SIZE) &&
3381     - IS_ALIGNED(phys_addr + addr, PUD_SIZE)) {
3382     + IS_ALIGNED(phys_addr + addr, PUD_SIZE) &&
3383     + pud_free_pmd_page(pud)) {
3384     if (pud_set_huge(pud, phys_addr + addr, prot))
3385     continue;
3386     }
3387     diff --git a/mm/huge_memory.c b/mm/huge_memory.c
3388     index eba34cdfc3e5..a403d29da6fd 100644
3389     --- a/mm/huge_memory.c
3390     +++ b/mm/huge_memory.c
3391     @@ -2739,11 +2739,13 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
3392    
3393     list_for_each_safe(pos, next, &list) {
3394     page = list_entry((void *)pos, struct page, mapping);
3395     - lock_page(page);
3396     + if (!trylock_page(page))
3397     + goto next;
3398     /* split_huge_page() removes page from list on success */
3399     if (!split_huge_page(page))
3400     split++;
3401     unlock_page(page);
3402     +next:
3403     put_page(page);
3404     }
3405    
3406     diff --git a/mm/hugetlb.c b/mm/hugetlb.c
3407     index c539941671b4..b1f841a9edd4 100644
3408     --- a/mm/hugetlb.c
3409     +++ b/mm/hugetlb.c
3410     @@ -18,6 +18,7 @@
3411     #include <linux/bootmem.h>
3412     #include <linux/sysfs.h>
3413     #include <linux/slab.h>
3414     +#include <linux/mmdebug.h>
3415     #include <linux/sched/signal.h>
3416     #include <linux/rmap.h>
3417     #include <linux/string_helpers.h>
3418     @@ -4344,6 +4345,12 @@ int hugetlb_reserve_pages(struct inode *inode,
3419     struct resv_map *resv_map;
3420     long gbl_reserve;
3421    
3422     + /* This should never happen */
3423     + if (from > to) {
3424     + VM_WARN(1, "%s called with a negative range\n", __func__);
3425     + return -EINVAL;
3426     + }
3427     +
3428     /*
3429     * Only apply hugepage reservation if asked. At fault time, an
3430     * attempt will be made for VM_NORESERVE to allocate a page
3431     diff --git a/mm/khugepaged.c b/mm/khugepaged.c
3432     index 43cb3043311b..2fe26634e1a2 100644
3433     --- a/mm/khugepaged.c
3434     +++ b/mm/khugepaged.c
3435     @@ -530,7 +530,12 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
3436     goto out;
3437     }
3438    
3439     - VM_BUG_ON_PAGE(PageCompound(page), page);
3440     + /* TODO: teach khugepaged to collapse THP mapped with pte */
3441     + if (PageCompound(page)) {
3442     + result = SCAN_PAGE_COMPOUND;
3443     + goto out;
3444     + }
3445     +
3446     VM_BUG_ON_PAGE(!PageAnon(page), page);
3447    
3448     /*
3449     diff --git a/mm/memblock.c b/mm/memblock.c
3450     index 6dd303717a4d..e81d12c544e9 100644
3451     --- a/mm/memblock.c
3452     +++ b/mm/memblock.c
3453     @@ -1101,34 +1101,6 @@ void __init_memblock __next_mem_pfn_range(int *idx, int nid,
3454     *out_nid = r->nid;
3455     }
3456    
3457     -unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn,
3458     - unsigned long max_pfn)
3459     -{
3460     - struct memblock_type *type = &memblock.memory;
3461     - unsigned int right = type->cnt;
3462     - unsigned int mid, left = 0;
3463     - phys_addr_t addr = PFN_PHYS(++pfn);
3464     -
3465     - do {
3466     - mid = (right + left) / 2;
3467     -
3468     - if (addr < type->regions[mid].base)
3469     - right = mid;
3470     - else if (addr >= (type->regions[mid].base +
3471     - type->regions[mid].size))
3472     - left = mid + 1;
3473     - else {
3474     - /* addr is within the region, so pfn is valid */
3475     - return pfn;
3476     - }
3477     - } while (left < right);
3478     -
3479     - if (right == type->cnt)
3480     - return -1UL;
3481     - else
3482     - return PHYS_PFN(type->regions[right].base);
3483     -}
3484     -
3485     /**
3486     * memblock_set_node - set node ID on memblock regions
3487     * @base: base of area to set node ID for
3488     diff --git a/mm/page_alloc.c b/mm/page_alloc.c
3489     index 6627caeeaf82..1d7693c35424 100644
3490     --- a/mm/page_alloc.c
3491     +++ b/mm/page_alloc.c
3492     @@ -3532,7 +3532,7 @@ static bool __need_fs_reclaim(gfp_t gfp_mask)
3493     return false;
3494    
3495     /* this guy won't enter reclaim */
3496     - if ((current->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC))
3497     + if (current->flags & PF_MEMALLOC)
3498     return false;
3499    
3500     /* We're only interested __GFP_FS allocations for now */
3501     @@ -5302,17 +5302,8 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
3502     if (context != MEMMAP_EARLY)
3503     goto not_early;
3504    
3505     - if (!early_pfn_valid(pfn)) {
3506     -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
3507     - /*
3508     - * Skip to the pfn preceding the next valid one (or
3509     - * end_pfn), such that we hit a valid pfn (or end_pfn)
3510     - * on our next iteration of the loop.
3511     - */
3512     - pfn = memblock_next_valid_pfn(pfn, end_pfn) - 1;
3513     -#endif
3514     + if (!early_pfn_valid(pfn))
3515     continue;
3516     - }
3517     if (!early_pfn_in_nid(pfn, nid))
3518     continue;
3519     if (!update_defer_init(pgdat, pfn, end_pfn, &nr_initialised))
3520     diff --git a/mm/shmem.c b/mm/shmem.c
3521     index 07a1d22807be..f383298b7280 100644
3522     --- a/mm/shmem.c
3523     +++ b/mm/shmem.c
3524     @@ -493,36 +493,45 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
3525     info = list_entry(pos, struct shmem_inode_info, shrinklist);
3526     inode = &info->vfs_inode;
3527    
3528     - if (nr_to_split && split >= nr_to_split) {
3529     - iput(inode);
3530     - continue;
3531     - }
3532     + if (nr_to_split && split >= nr_to_split)
3533     + goto leave;
3534    
3535     - page = find_lock_page(inode->i_mapping,
3536     + page = find_get_page(inode->i_mapping,
3537     (inode->i_size & HPAGE_PMD_MASK) >> PAGE_SHIFT);
3538     if (!page)
3539     goto drop;
3540    
3541     + /* No huge page at the end of the file: nothing to split */
3542     if (!PageTransHuge(page)) {
3543     - unlock_page(page);
3544     put_page(page);
3545     goto drop;
3546     }
3547    
3548     + /*
3549     + * Leave the inode on the list if we failed to lock
3550     + * the page at this time.
3551     + *
3552     + * Waiting for the lock may lead to deadlock in the
3553     + * reclaim path.
3554     + */
3555     + if (!trylock_page(page)) {
3556     + put_page(page);
3557     + goto leave;
3558     + }
3559     +
3560     ret = split_huge_page(page);
3561     unlock_page(page);
3562     put_page(page);
3563    
3564     - if (ret) {
3565     - /* split failed: leave it on the list */
3566     - iput(inode);
3567     - continue;
3568     - }
3569     + /* If split failed leave the inode on the list */
3570     + if (ret)
3571     + goto leave;
3572    
3573     split++;
3574     drop:
3575     list_del_init(&info->shrinklist);
3576     removed++;
3577     +leave:
3578     iput(inode);
3579     }
3580    
3581     diff --git a/mm/vmscan.c b/mm/vmscan.c
3582     index 441f346fb5e2..a8a3729bfaa9 100644
3583     --- a/mm/vmscan.c
3584     +++ b/mm/vmscan.c
3585     @@ -1846,6 +1846,20 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,
3586     if (stat.nr_writeback && stat.nr_writeback == nr_taken)
3587     set_bit(PGDAT_WRITEBACK, &pgdat->flags);
3588    
3589     + /*
3590     + * If dirty pages are scanned that are not queued for IO, it
3591     + * implies that flushers are not doing their job. This can
3592     + * happen when memory pressure pushes dirty pages to the end of
3593     + * the LRU before the dirty limits are breached and the dirty
3594     + * data has expired. It can also happen when the proportion of
3595     + * dirty pages grows not through writes but through memory
3596     + * pressure reclaiming all the clean cache. And in some cases,
3597     + * the flushers simply cannot keep up with the allocation
3598     + * rate. Nudge the flusher threads in case they are asleep.
3599     + */
3600     + if (stat.nr_unqueued_dirty == nr_taken)
3601     + wakeup_flusher_threads(0, WB_REASON_VMSCAN);
3602     +
3603     /*
3604     * Legacy memcg will stall in page writeback so avoid forcibly
3605     * stalling here.
3606     @@ -1858,22 +1872,9 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,
3607     if (stat.nr_dirty && stat.nr_dirty == stat.nr_congested)
3608     set_bit(PGDAT_CONGESTED, &pgdat->flags);
3609    
3610     - /*
3611     - * If dirty pages are scanned that are not queued for IO, it
3612     - * implies that flushers are not doing their job. This can
3613     - * happen when memory pressure pushes dirty pages to the end of
3614     - * the LRU before the dirty limits are breached and the dirty
3615     - * data has expired. It can also happen when the proportion of
3616     - * dirty pages grows not through writes but through memory
3617     - * pressure reclaiming all the clean cache. And in some cases,
3618     - * the flushers simply cannot keep up with the allocation
3619     - * rate. Nudge the flusher threads in case they are asleep, but
3620     - * also allow kswapd to start writing pages during reclaim.
3621     - */
3622     - if (stat.nr_unqueued_dirty == nr_taken) {
3623     - wakeup_flusher_threads(0, WB_REASON_VMSCAN);
3624     + /* Allow kswapd to start writing pages during reclaim. */
3625     + if (stat.nr_unqueued_dirty == nr_taken)
3626     set_bit(PGDAT_DIRTY, &pgdat->flags);
3627     - }
3628    
3629     /*
3630     * If kswapd scans pages marked marked for immediate
3631     diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
3632     index 386ee829c655..829e2f6bfb73 100644
3633     --- a/sound/drivers/aloop.c
3634     +++ b/sound/drivers/aloop.c
3635     @@ -192,6 +192,11 @@ static inline void loopback_timer_stop(struct loopback_pcm *dpcm)
3636     dpcm->timer.expires = 0;
3637     }
3638    
3639     +static inline void loopback_timer_stop_sync(struct loopback_pcm *dpcm)
3640     +{
3641     + del_timer_sync(&dpcm->timer);
3642     +}
3643     +
3644     #define CABLE_VALID_PLAYBACK (1 << SNDRV_PCM_STREAM_PLAYBACK)
3645     #define CABLE_VALID_CAPTURE (1 << SNDRV_PCM_STREAM_CAPTURE)
3646     #define CABLE_VALID_BOTH (CABLE_VALID_PLAYBACK|CABLE_VALID_CAPTURE)
3647     @@ -326,6 +331,8 @@ static int loopback_prepare(struct snd_pcm_substream *substream)
3648     struct loopback_cable *cable = dpcm->cable;
3649     int bps, salign;
3650    
3651     + loopback_timer_stop_sync(dpcm);
3652     +
3653     salign = (snd_pcm_format_width(runtime->format) *
3654     runtime->channels) / 8;
3655     bps = salign * runtime->rate;
3656     @@ -659,7 +666,9 @@ static void free_cable(struct snd_pcm_substream *substream)
3657     return;
3658     if (cable->streams[!substream->stream]) {
3659     /* other stream is still alive */
3660     + spin_lock_irq(&cable->lock);
3661     cable->streams[substream->stream] = NULL;
3662     + spin_unlock_irq(&cable->lock);
3663     } else {
3664     /* free the cable */
3665     loopback->cables[substream->number][dev] = NULL;
3666     @@ -699,7 +708,6 @@ static int loopback_open(struct snd_pcm_substream *substream)
3667     loopback->cables[substream->number][dev] = cable;
3668     }
3669     dpcm->cable = cable;
3670     - cable->streams[substream->stream] = dpcm;
3671    
3672     snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
3673    
3674     @@ -731,6 +739,11 @@ static int loopback_open(struct snd_pcm_substream *substream)
3675     runtime->hw = loopback_pcm_hardware;
3676     else
3677     runtime->hw = cable->hw;
3678     +
3679     + spin_lock_irq(&cable->lock);
3680     + cable->streams[substream->stream] = dpcm;
3681     + spin_unlock_irq(&cable->lock);
3682     +
3683     unlock:
3684     if (err < 0) {
3685     free_cable(substream);
3686     @@ -745,7 +758,7 @@ static int loopback_close(struct snd_pcm_substream *substream)
3687     struct loopback *loopback = substream->private_data;
3688     struct loopback_pcm *dpcm = substream->runtime->private_data;
3689    
3690     - loopback_timer_stop(dpcm);
3691     + loopback_timer_stop_sync(dpcm);
3692     mutex_lock(&loopback->cable_lock);
3693     free_cable(substream);
3694     mutex_unlock(&loopback->cable_lock);
3695     diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
3696     index d5017adf9feb..c507c69029e3 100644
3697     --- a/sound/pci/hda/hda_intel.c
3698     +++ b/sound/pci/hda/hda_intel.c
3699     @@ -375,6 +375,7 @@ enum {
3700     ((pci)->device == 0x160c))
3701    
3702     #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
3703     +#define IS_CFL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa348)
3704    
3705     static char *driver_short_names[] = {
3706     [AZX_DRIVER_ICH] = "HDA Intel",
3707     @@ -1744,6 +1745,10 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
3708     else
3709     chip->bdl_pos_adj = bdl_pos_adj[dev];
3710    
3711     + /* Workaround for a communication error on CFL (bko#199007) */
3712     + if (IS_CFL(pci))
3713     + chip->polling_mode = 1;
3714     +
3715     err = azx_bus_init(chip, model[dev], &pci_hda_io_ops);
3716     if (err < 0) {
3717     kfree(hda);
3718     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
3719     index 3d19efd2783a..e44a9758f2eb 100644
3720     --- a/sound/pci/hda/patch_realtek.c
3721     +++ b/sound/pci/hda/patch_realtek.c
3722     @@ -3107,6 +3107,8 @@ static void alc256_init(struct hda_codec *codec)
3723    
3724     alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3725     alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3726     + alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3727     + alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3728     }
3729    
3730     static void alc256_shutup(struct hda_codec *codec)
3731     @@ -3486,8 +3488,12 @@ static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
3732     pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3733     pinval &= ~AC_PINCTL_VREFEN;
3734     pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
3735     - if (spec->mute_led_nid)
3736     + if (spec->mute_led_nid) {
3737     + /* temporarily power up/down for setting VREF */
3738     + snd_hda_power_up_pm(codec);
3739     snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
3740     + snd_hda_power_down_pm(codec);
3741     + }
3742     }
3743    
3744     /* Make sure the led works even in runtime suspend */
3745     @@ -5352,6 +5358,7 @@ enum {
3746     ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
3747     ALC298_FIXUP_TPT470_DOCK,
3748     ALC255_FIXUP_DUMMY_LINEOUT_VERB,
3749     + ALC255_FIXUP_DELL_HEADSET_MIC,
3750     };
3751    
3752     static const struct hda_fixup alc269_fixups[] = {
3753     @@ -6212,6 +6219,13 @@ static const struct hda_fixup alc269_fixups[] = {
3754     .chained = true,
3755     .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
3756     },
3757     + [ALC255_FIXUP_DELL_HEADSET_MIC] = {
3758     + .type = HDA_FIXUP_PINS,
3759     + .v.pins = (const struct hda_pintbl[]) {
3760     + { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
3761     + { }
3762     + },
3763     + },
3764     };
3765    
3766     static const struct snd_pci_quirk alc269_fixup_tbl[] = {
3767     @@ -6266,6 +6280,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
3768     SND_PCI_QUIRK(0x1028, 0x082a, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
3769     SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
3770     SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
3771     + SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
3772     + SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
3773     SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
3774     SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
3775     SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
3776     @@ -7004,6 +7020,8 @@ static int patch_alc269(struct hda_codec *codec)
3777     break;
3778     case 0x10ec0257:
3779     spec->codec_variant = ALC269_TYPE_ALC257;
3780     + spec->shutup = alc256_shutup;
3781     + spec->init_hook = alc256_init;
3782     spec->gen.mixer_nid = 0;
3783     break;
3784     case 0x10ec0215:
3785     diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
3786     index 69523ed55894..9df0af17e9c2 100644
3787     --- a/tools/perf/builtin-stat.c
3788     +++ b/tools/perf/builtin-stat.c
3789     @@ -922,7 +922,7 @@ static void print_metric_csv(void *ctx,
3790     char buf[64], *vals, *ends;
3791    
3792     if (unit == NULL || fmt == NULL) {
3793     - fprintf(out, "%s%s%s%s", csv_sep, csv_sep, csv_sep, csv_sep);
3794     + fprintf(out, "%s%s", csv_sep, csv_sep);
3795     return;
3796     }
3797     snprintf(buf, sizeof(buf), fmt, val);
3798     diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c
3799     index 6cbb83b47150..f15aa5a76fe3 100644
3800     --- a/tools/testing/selftests/x86/protection_keys.c
3801     +++ b/tools/testing/selftests/x86/protection_keys.c
3802     @@ -250,7 +250,7 @@ void signal_handler(int signum, siginfo_t *si, void *vucontext)
3803     unsigned long ip;
3804     char *fpregs;
3805     u32 *pkru_ptr;
3806     - u64 si_pkey;
3807     + u64 siginfo_pkey;
3808     u32 *si_pkey_ptr;
3809     int pkru_offset;
3810     fpregset_t fpregset;
3811     @@ -292,9 +292,9 @@ void signal_handler(int signum, siginfo_t *si, void *vucontext)
3812     si_pkey_ptr = (u32 *)(((u8 *)si) + si_pkey_offset);
3813     dprintf1("si_pkey_ptr: %p\n", si_pkey_ptr);
3814     dump_mem(si_pkey_ptr - 8, 24);
3815     - si_pkey = *si_pkey_ptr;
3816     - pkey_assert(si_pkey < NR_PKEYS);
3817     - last_si_pkey = si_pkey;
3818     + siginfo_pkey = *si_pkey_ptr;
3819     + pkey_assert(siginfo_pkey < NR_PKEYS);
3820     + last_si_pkey = siginfo_pkey;
3821    
3822     if ((si->si_code == SEGV_MAPERR) ||
3823     (si->si_code == SEGV_ACCERR) ||
3824     @@ -306,7 +306,7 @@ void signal_handler(int signum, siginfo_t *si, void *vucontext)
3825     dprintf1("signal pkru from xsave: %08x\n", *pkru_ptr);
3826     /* need __rdpkru() version so we do not do shadow_pkru checking */
3827     dprintf1("signal pkru from pkru: %08x\n", __rdpkru());
3828     - dprintf1("si_pkey from siginfo: %jx\n", si_pkey);
3829     + dprintf1("pkey from siginfo: %jx\n", siginfo_pkey);
3830     *(u64 *)pkru_ptr = 0x00000000;
3831     dprintf1("WARNING: set PRKU=0 to allow faulting instruction to continue\n");
3832     pkru_faults++;
3833     diff --git a/tools/testing/selftests/x86/ptrace_syscall.c b/tools/testing/selftests/x86/ptrace_syscall.c
3834     index 1ae1c5a7392e..6f22238f3217 100644
3835     --- a/tools/testing/selftests/x86/ptrace_syscall.c
3836     +++ b/tools/testing/selftests/x86/ptrace_syscall.c
3837     @@ -183,8 +183,10 @@ static void test_ptrace_syscall_restart(void)
3838     if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0)
3839     err(1, "PTRACE_TRACEME");
3840    
3841     + pid_t pid = getpid(), tid = syscall(SYS_gettid);
3842     +
3843     printf("\tChild will make one syscall\n");
3844     - raise(SIGSTOP);
3845     + syscall(SYS_tgkill, pid, tid, SIGSTOP);
3846    
3847     syscall(SYS_gettid, 10, 11, 12, 13, 14, 15);
3848     _exit(0);
3849     @@ -301,9 +303,11 @@ static void test_restart_under_ptrace(void)
3850     if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0)
3851     err(1, "PTRACE_TRACEME");
3852    
3853     + pid_t pid = getpid(), tid = syscall(SYS_gettid);
3854     +
3855     printf("\tChild will take a nap until signaled\n");
3856     setsigign(SIGUSR1, SA_RESTART);
3857     - raise(SIGSTOP);
3858     + syscall(SYS_tgkill, pid, tid, SIGSTOP);
3859    
3860     syscall(SYS_pause, 0, 0, 0, 0, 0, 0);
3861     _exit(0);