Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0106-5.4.7-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3487 - (show annotations) (download)
Mon May 11 14:36:01 2020 UTC (4 years ago) by niro
File size: 474321 byte(s)
-linux-5.4.7
1 diff --git a/Makefile b/Makefile
2 index 20ec7c20279e..0e2e0a034064 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,7 +1,7 @@
6 # SPDX-License-Identifier: GPL-2.0
7 VERSION = 5
8 PATCHLEVEL = 4
9 -SUBLEVEL = 6
10 +SUBLEVEL = 7
11 EXTRAVERSION =
12 NAME = Kleptomaniac Octopus
13
14 diff --git a/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi b/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi
15 index d1eae47b83f6..82f7ae030600 100644
16 --- a/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi
17 +++ b/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi
18 @@ -160,12 +160,12 @@
19 regulator-enable-ramp-delay = <1000>;
20 };
21
22 - /* Used by DSS */
23 + /* Used by DSS and is the "zerov_regulator" trigger for SoC off mode */
24 vcsi: VCSI {
25 regulator-min-microvolt = <1800000>;
26 regulator-max-microvolt = <1800000>;
27 regulator-enable-ramp-delay = <1000>;
28 - regulator-boot-on;
29 + regulator-always-on;
30 };
31
32 vdac: VDAC {
33 diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c
34 index c9f72b2665f1..43ae4e0c968f 100644
35 --- a/arch/arm64/kernel/psci.c
36 +++ b/arch/arm64/kernel/psci.c
37 @@ -81,7 +81,8 @@ static void cpu_psci_cpu_die(unsigned int cpu)
38
39 static int cpu_psci_cpu_kill(unsigned int cpu)
40 {
41 - int err, i;
42 + int err;
43 + unsigned long start, end;
44
45 if (!psci_ops.affinity_info)
46 return 0;
47 @@ -91,16 +92,18 @@ static int cpu_psci_cpu_kill(unsigned int cpu)
48 * while it is dying. So, try again a few times.
49 */
50
51 - for (i = 0; i < 10; i++) {
52 + start = jiffies;
53 + end = start + msecs_to_jiffies(100);
54 + do {
55 err = psci_ops.affinity_info(cpu_logical_map(cpu), 0);
56 if (err == PSCI_0_2_AFFINITY_LEVEL_OFF) {
57 - pr_info("CPU%d killed.\n", cpu);
58 + pr_info("CPU%d killed (polled %d ms)\n", cpu,
59 + jiffies_to_msecs(jiffies - start));
60 return 0;
61 }
62
63 - msleep(10);
64 - pr_info("Retrying again to check for CPU kill\n");
65 - }
66 + usleep_range(100, 1000);
67 + } while (time_before(jiffies, end));
68
69 pr_warn("CPU%d may not have shut down cleanly (AFFINITY_INFO reports %d)\n",
70 cpu, err);
71 diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
72 index 46822afc57e0..01a515e0171e 100644
73 --- a/arch/arm64/kvm/sys_regs.c
74 +++ b/arch/arm64/kvm/sys_regs.c
75 @@ -2360,8 +2360,11 @@ static const struct sys_reg_desc *index_to_sys_reg_desc(struct kvm_vcpu *vcpu,
76 if ((id & KVM_REG_ARM_COPROC_MASK) != KVM_REG_ARM64_SYSREG)
77 return NULL;
78
79 + if (!index_to_params(id, &params))
80 + return NULL;
81 +
82 table = get_target_table(vcpu->arch.target, true, &num);
83 - r = find_reg_by_id(id, &params, table, num);
84 + r = find_reg(&params, table, num);
85 if (!r)
86 r = find_reg(&params, sys_reg_descs, ARRAY_SIZE(sys_reg_descs));
87
88 diff --git a/arch/mips/include/asm/barrier.h b/arch/mips/include/asm/barrier.h
89 index 9228f7386220..fb842965d541 100644
90 --- a/arch/mips/include/asm/barrier.h
91 +++ b/arch/mips/include/asm/barrier.h
92 @@ -218,13 +218,14 @@
93 * ordering will be done by smp_llsc_mb() and friends.
94 */
95 #if defined(CONFIG_WEAK_REORDERING_BEYOND_LLSC) && defined(CONFIG_SMP)
96 -#define __WEAK_LLSC_MB " sync \n"
97 -#define smp_llsc_mb() __asm__ __volatile__(__WEAK_LLSC_MB : : :"memory")
98 -#define __LLSC_CLOBBER
99 +# define __WEAK_LLSC_MB sync
100 +# define smp_llsc_mb() \
101 + __asm__ __volatile__(__stringify(__WEAK_LLSC_MB) : : :"memory")
102 +# define __LLSC_CLOBBER
103 #else
104 -#define __WEAK_LLSC_MB " \n"
105 -#define smp_llsc_mb() do { } while (0)
106 -#define __LLSC_CLOBBER "memory"
107 +# define __WEAK_LLSC_MB
108 +# define smp_llsc_mb() do { } while (0)
109 +# define __LLSC_CLOBBER "memory"
110 #endif
111
112 #ifdef CONFIG_CPU_CAVIUM_OCTEON
113 diff --git a/arch/mips/include/asm/futex.h b/arch/mips/include/asm/futex.h
114 index b83b0397462d..110220705e97 100644
115 --- a/arch/mips/include/asm/futex.h
116 +++ b/arch/mips/include/asm/futex.h
117 @@ -16,6 +16,7 @@
118 #include <asm/barrier.h>
119 #include <asm/compiler.h>
120 #include <asm/errno.h>
121 +#include <asm/sync.h>
122 #include <asm/war.h>
123
124 #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
125 @@ -32,7 +33,7 @@
126 " .set arch=r4000 \n" \
127 "2: sc $1, %2 \n" \
128 " beqzl $1, 1b \n" \
129 - __WEAK_LLSC_MB \
130 + __stringify(__WEAK_LLSC_MB) " \n" \
131 "3: \n" \
132 " .insn \n" \
133 " .set pop \n" \
134 @@ -50,19 +51,19 @@
135 "i" (-EFAULT) \
136 : "memory"); \
137 } else if (cpu_has_llsc) { \
138 - loongson_llsc_mb(); \
139 __asm__ __volatile__( \
140 " .set push \n" \
141 " .set noat \n" \
142 " .set push \n" \
143 " .set "MIPS_ISA_ARCH_LEVEL" \n" \
144 + " " __SYNC(full, loongson3_war) " \n" \
145 "1: "user_ll("%1", "%4")" # __futex_atomic_op\n" \
146 " .set pop \n" \
147 " " insn " \n" \
148 " .set "MIPS_ISA_ARCH_LEVEL" \n" \
149 "2: "user_sc("$1", "%2")" \n" \
150 " beqz $1, 1b \n" \
151 - __WEAK_LLSC_MB \
152 + __stringify(__WEAK_LLSC_MB) " \n" \
153 "3: \n" \
154 " .insn \n" \
155 " .set pop \n" \
156 @@ -147,7 +148,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
157 " .set arch=r4000 \n"
158 "2: sc $1, %2 \n"
159 " beqzl $1, 1b \n"
160 - __WEAK_LLSC_MB
161 + __stringify(__WEAK_LLSC_MB) " \n"
162 "3: \n"
163 " .insn \n"
164 " .set pop \n"
165 @@ -164,13 +165,13 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
166 "i" (-EFAULT)
167 : "memory");
168 } else if (cpu_has_llsc) {
169 - loongson_llsc_mb();
170 __asm__ __volatile__(
171 "# futex_atomic_cmpxchg_inatomic \n"
172 " .set push \n"
173 " .set noat \n"
174 " .set push \n"
175 " .set "MIPS_ISA_ARCH_LEVEL" \n"
176 + " " __SYNC(full, loongson3_war) " \n"
177 "1: "user_ll("%1", "%3")" \n"
178 " bne %1, %z4, 3f \n"
179 " .set pop \n"
180 @@ -178,8 +179,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
181 " .set "MIPS_ISA_ARCH_LEVEL" \n"
182 "2: "user_sc("$1", "%2")" \n"
183 " beqz $1, 1b \n"
184 - __WEAK_LLSC_MB
185 - "3: \n"
186 + "3: " __SYNC_ELSE(full, loongson3_war, __WEAK_LLSC_MB) "\n"
187 " .insn \n"
188 " .set pop \n"
189 " .section .fixup,\"ax\" \n"
190 @@ -194,7 +194,6 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
191 : GCC_OFF_SMALL_ASM() (*uaddr), "Jr" (oldval), "Jr" (newval),
192 "i" (-EFAULT)
193 : "memory");
194 - loongson_llsc_mb();
195 } else
196 return -ENOSYS;
197
198 diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
199 index 93a9dce31f25..813dfe5f45a5 100644
200 --- a/arch/mips/include/asm/pgtable-64.h
201 +++ b/arch/mips/include/asm/pgtable-64.h
202 @@ -18,10 +18,12 @@
203 #include <asm/fixmap.h>
204
205 #define __ARCH_USE_5LEVEL_HACK
206 -#if defined(CONFIG_PAGE_SIZE_64KB) && !defined(CONFIG_MIPS_VA_BITS_48)
207 +#if CONFIG_PGTABLE_LEVELS == 2
208 #include <asm-generic/pgtable-nopmd.h>
209 -#elif !(defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_MIPS_VA_BITS_48))
210 +#elif CONFIG_PGTABLE_LEVELS == 3
211 #include <asm-generic/pgtable-nopud.h>
212 +#else
213 +#include <asm-generic/5level-fixup.h>
214 #endif
215
216 /*
217 @@ -216,6 +218,9 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
218 return pgd_val(pgd);
219 }
220
221 +#define pgd_phys(pgd) virt_to_phys((void *)pgd_val(pgd))
222 +#define pgd_page(pgd) (pfn_to_page(pgd_phys(pgd) >> PAGE_SHIFT))
223 +
224 static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
225 {
226 return (pud_t *)pgd_page_vaddr(*pgd) + pud_index(address);
227 diff --git a/arch/mips/ralink/Kconfig b/arch/mips/ralink/Kconfig
228 index 1434fa60f3db..94e9ce994494 100644
229 --- a/arch/mips/ralink/Kconfig
230 +++ b/arch/mips/ralink/Kconfig
231 @@ -51,6 +51,7 @@ choice
232 select MIPS_GIC
233 select COMMON_CLK
234 select CLKSRC_MIPS_GIC
235 + select HAVE_PCI if PCI_MT7621
236 endchoice
237
238 choice
239 diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
240 index e9a960e28f3c..cac95a3f30c2 100644
241 --- a/arch/powerpc/include/asm/spinlock.h
242 +++ b/arch/powerpc/include/asm/spinlock.h
243 @@ -36,10 +36,12 @@
244 #endif
245
246 #ifdef CONFIG_PPC_PSERIES
247 +DECLARE_STATIC_KEY_FALSE(shared_processor);
248 +
249 #define vcpu_is_preempted vcpu_is_preempted
250 static inline bool vcpu_is_preempted(int cpu)
251 {
252 - if (!firmware_has_feature(FW_FEATURE_SPLPAR))
253 + if (!static_branch_unlikely(&shared_processor))
254 return false;
255 return !!(be32_to_cpu(lppaca_of(cpu).yield_count) & 1);
256 }
257 diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
258 index 5645bc9cbc09..add67498c126 100644
259 --- a/arch/powerpc/kernel/irq.c
260 +++ b/arch/powerpc/kernel/irq.c
261 @@ -619,8 +619,6 @@ void __do_irq(struct pt_regs *regs)
262
263 trace_irq_entry(regs);
264
265 - check_stack_overflow();
266 -
267 /*
268 * Query the platform PIC for the interrupt & ack it.
269 *
270 @@ -652,6 +650,8 @@ void do_IRQ(struct pt_regs *regs)
271 irqsp = hardirq_ctx[raw_smp_processor_id()];
272 sirqsp = softirq_ctx[raw_smp_processor_id()];
273
274 + check_stack_overflow();
275 +
276 /* Already there ? */
277 if (unlikely(cursp == irqsp || cursp == sirqsp)) {
278 __do_irq(regs);
279 diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
280 index 0496e66aaa56..c6fbbd29bd87 100644
281 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
282 +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
283 @@ -1117,7 +1117,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
284 ld r7, VCPU_GPR(R7)(r4)
285 bne ret_to_ultra
286
287 - lwz r0, VCPU_CR(r4)
288 + ld r0, VCPU_CR(r4)
289 mtcr r0
290
291 ld r0, VCPU_GPR(R0)(r4)
292 @@ -1137,7 +1137,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
293 * R3 = UV_RETURN
294 */
295 ret_to_ultra:
296 - lwz r0, VCPU_CR(r4)
297 + ld r0, VCPU_CR(r4)
298 mtcr r0
299
300 ld r0, VCPU_GPR(R3)(r4)
301 diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
302 index 0a40201f315f..0c8421dd01ab 100644
303 --- a/arch/powerpc/platforms/pseries/setup.c
304 +++ b/arch/powerpc/platforms/pseries/setup.c
305 @@ -74,6 +74,9 @@
306 #include "pseries.h"
307 #include "../../../../drivers/pci/pci.h"
308
309 +DEFINE_STATIC_KEY_FALSE(shared_processor);
310 +EXPORT_SYMBOL_GPL(shared_processor);
311 +
312 int CMO_PrPSP = -1;
313 int CMO_SecPSP = -1;
314 unsigned long CMO_PageSize = (ASM_CONST(1) << IOMMU_PAGE_SHIFT_4K);
315 @@ -758,6 +761,10 @@ static void __init pSeries_setup_arch(void)
316
317 if (firmware_has_feature(FW_FEATURE_LPAR)) {
318 vpa_init(boot_cpuid);
319 +
320 + if (lppaca_shared_proc(get_lppaca()))
321 + static_branch_enable(&shared_processor);
322 +
323 ppc_md.power_save = pseries_lpar_idle;
324 ppc_md.enable_pmcs = pseries_lpar_enable_pmcs;
325 #ifdef CONFIG_PCI_IOV
326 diff --git a/arch/s390/crypto/sha_common.c b/arch/s390/crypto/sha_common.c
327 index d39e0f079217..686fe7aa192f 100644
328 --- a/arch/s390/crypto/sha_common.c
329 +++ b/arch/s390/crypto/sha_common.c
330 @@ -74,14 +74,17 @@ int s390_sha_final(struct shash_desc *desc, u8 *out)
331 struct s390_sha_ctx *ctx = shash_desc_ctx(desc);
332 unsigned int bsize = crypto_shash_blocksize(desc->tfm);
333 u64 bits;
334 - unsigned int n, mbl_offset;
335 + unsigned int n;
336 + int mbl_offset;
337
338 n = ctx->count % bsize;
339 bits = ctx->count * 8;
340 - mbl_offset = s390_crypto_shash_parmsize(ctx->func) / sizeof(u32);
341 + mbl_offset = s390_crypto_shash_parmsize(ctx->func);
342 if (mbl_offset < 0)
343 return -EINVAL;
344
345 + mbl_offset = mbl_offset / sizeof(u32);
346 +
347 /* set total msg bit length (mbl) in CPACF parmblock */
348 switch (ctx->func) {
349 case CPACF_KLMD_SHA_1:
350 diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h
351 index bccb8f4a63e2..77606c4acd58 100644
352 --- a/arch/s390/include/asm/pgalloc.h
353 +++ b/arch/s390/include/asm/pgalloc.h
354 @@ -56,7 +56,12 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long address)
355 crst_table_init(table, _REGION2_ENTRY_EMPTY);
356 return (p4d_t *) table;
357 }
358 -#define p4d_free(mm, p4d) crst_table_free(mm, (unsigned long *) p4d)
359 +
360 +static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d)
361 +{
362 + if (!mm_p4d_folded(mm))
363 + crst_table_free(mm, (unsigned long *) p4d);
364 +}
365
366 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address)
367 {
368 @@ -65,7 +70,12 @@ static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address)
369 crst_table_init(table, _REGION3_ENTRY_EMPTY);
370 return (pud_t *) table;
371 }
372 -#define pud_free(mm, pud) crst_table_free(mm, (unsigned long *) pud)
373 +
374 +static inline void pud_free(struct mm_struct *mm, pud_t *pud)
375 +{
376 + if (!mm_pud_folded(mm))
377 + crst_table_free(mm, (unsigned long *) pud);
378 +}
379
380 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr)
381 {
382 @@ -83,6 +93,8 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr)
383
384 static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
385 {
386 + if (mm_pmd_folded(mm))
387 + return;
388 pgtable_pmd_page_dtor(virt_to_page(pmd));
389 crst_table_free(mm, (unsigned long *) pmd);
390 }
391 diff --git a/arch/s390/include/asm/timex.h b/arch/s390/include/asm/timex.h
392 index 64539c221672..2dc9eb4e1acc 100644
393 --- a/arch/s390/include/asm/timex.h
394 +++ b/arch/s390/include/asm/timex.h
395 @@ -10,8 +10,9 @@
396 #ifndef _ASM_S390_TIMEX_H
397 #define _ASM_S390_TIMEX_H
398
399 -#include <asm/lowcore.h>
400 +#include <linux/preempt.h>
401 #include <linux/time64.h>
402 +#include <asm/lowcore.h>
403
404 /* The value of the TOD clock for 1.1.1970. */
405 #define TOD_UNIX_EPOCH 0x7d91048bca000000ULL
406 @@ -186,15 +187,18 @@ extern unsigned char tod_clock_base[16] __aligned(8);
407 /**
408 * get_clock_monotonic - returns current time in clock rate units
409 *
410 - * The caller must ensure that preemption is disabled.
411 * The clock and tod_clock_base get changed via stop_machine.
412 - * Therefore preemption must be disabled when calling this
413 - * function, otherwise the returned value is not guaranteed to
414 - * be monotonic.
415 + * Therefore preemption must be disabled, otherwise the returned
416 + * value is not guaranteed to be monotonic.
417 */
418 static inline unsigned long long get_tod_clock_monotonic(void)
419 {
420 - return get_tod_clock() - *(unsigned long long *) &tod_clock_base[1];
421 + unsigned long long tod;
422 +
423 + preempt_disable_notrace();
424 + tod = get_tod_clock() - *(unsigned long long *) &tod_clock_base[1];
425 + preempt_enable_notrace();
426 + return tod;
427 }
428
429 /**
430 diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
431 index 7abe6ae261b4..f304802ecf7b 100644
432 --- a/arch/s390/kernel/dis.c
433 +++ b/arch/s390/kernel/dis.c
434 @@ -461,10 +461,11 @@ static int print_insn(char *buffer, unsigned char *code, unsigned long addr)
435 ptr += sprintf(ptr, "%%c%i", value);
436 else if (operand->flags & OPERAND_VR)
437 ptr += sprintf(ptr, "%%v%i", value);
438 - else if (operand->flags & OPERAND_PCREL)
439 - ptr += sprintf(ptr, "%lx", (signed int) value
440 - + addr);
441 - else if (operand->flags & OPERAND_SIGNED)
442 + else if (operand->flags & OPERAND_PCREL) {
443 + void *pcrel = (void *)((int)value + addr);
444 +
445 + ptr += sprintf(ptr, "%px", pcrel);
446 + } else if (operand->flags & OPERAND_SIGNED)
447 ptr += sprintf(ptr, "%i", value);
448 else
449 ptr += sprintf(ptr, "%u", value);
450 @@ -536,7 +537,7 @@ void show_code(struct pt_regs *regs)
451 else
452 *ptr++ = ' ';
453 addr = regs->psw.addr + start - 32;
454 - ptr += sprintf(ptr, "%016lx: ", addr);
455 + ptr += sprintf(ptr, "%px: ", (void *)addr);
456 if (start + opsize >= end)
457 break;
458 for (i = 0; i < opsize; i++)
459 @@ -564,7 +565,7 @@ void print_fn_code(unsigned char *code, unsigned long len)
460 opsize = insn_length(*code);
461 if (opsize > len)
462 break;
463 - ptr += sprintf(ptr, "%p: ", code);
464 + ptr += sprintf(ptr, "%px: ", code);
465 for (i = 0; i < opsize; i++)
466 ptr += sprintf(ptr, "%02x", code[i]);
467 *ptr++ = '\t';
468 diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c
469 index 48d48b6187c0..0eb1d1cc53a8 100644
470 --- a/arch/s390/kernel/perf_cpum_cf.c
471 +++ b/arch/s390/kernel/perf_cpum_cf.c
472 @@ -199,7 +199,7 @@ static const int cpumf_generic_events_user[] = {
473 [PERF_COUNT_HW_BUS_CYCLES] = -1,
474 };
475
476 -static int __hw_perf_event_init(struct perf_event *event)
477 +static int __hw_perf_event_init(struct perf_event *event, unsigned int type)
478 {
479 struct perf_event_attr *attr = &event->attr;
480 struct hw_perf_event *hwc = &event->hw;
481 @@ -207,7 +207,7 @@ static int __hw_perf_event_init(struct perf_event *event)
482 int err = 0;
483 u64 ev;
484
485 - switch (attr->type) {
486 + switch (type) {
487 case PERF_TYPE_RAW:
488 /* Raw events are used to access counters directly,
489 * hence do not permit excludes */
490 @@ -294,17 +294,16 @@ static int __hw_perf_event_init(struct perf_event *event)
491
492 static int cpumf_pmu_event_init(struct perf_event *event)
493 {
494 + unsigned int type = event->attr.type;
495 int err;
496
497 - switch (event->attr.type) {
498 - case PERF_TYPE_HARDWARE:
499 - case PERF_TYPE_HW_CACHE:
500 - case PERF_TYPE_RAW:
501 - err = __hw_perf_event_init(event);
502 - break;
503 - default:
504 + if (type == PERF_TYPE_HARDWARE || type == PERF_TYPE_RAW)
505 + err = __hw_perf_event_init(event, type);
506 + else if (event->pmu->type == type)
507 + /* Registered as unknown PMU */
508 + err = __hw_perf_event_init(event, PERF_TYPE_RAW);
509 + else
510 return -ENOENT;
511 - }
512
513 if (unlikely(err) && event->destroy)
514 event->destroy(event);
515 @@ -553,7 +552,7 @@ static int __init cpumf_pmu_init(void)
516 return -ENODEV;
517
518 cpumf_pmu.attr_groups = cpumf_cf_event_group();
519 - rc = perf_pmu_register(&cpumf_pmu, "cpum_cf", PERF_TYPE_RAW);
520 + rc = perf_pmu_register(&cpumf_pmu, "cpum_cf", -1);
521 if (rc)
522 pr_err("Registering the cpum_cf PMU failed with rc=%i\n", rc);
523 return rc;
524 diff --git a/arch/s390/kernel/perf_cpum_cf_diag.c b/arch/s390/kernel/perf_cpum_cf_diag.c
525 index 2654e348801a..e949ab832ed7 100644
526 --- a/arch/s390/kernel/perf_cpum_cf_diag.c
527 +++ b/arch/s390/kernel/perf_cpum_cf_diag.c
528 @@ -243,13 +243,13 @@ static int cf_diag_event_init(struct perf_event *event)
529 int err = -ENOENT;
530
531 debug_sprintf_event(cf_diag_dbg, 5,
532 - "%s event %p cpu %d config %#llx "
533 + "%s event %p cpu %d config %#llx type:%u "
534 "sample_type %#llx cf_diag_events %d\n", __func__,
535 - event, event->cpu, attr->config, attr->sample_type,
536 - atomic_read(&cf_diag_events));
537 + event, event->cpu, attr->config, event->pmu->type,
538 + attr->sample_type, atomic_read(&cf_diag_events));
539
540 if (event->attr.config != PERF_EVENT_CPUM_CF_DIAG ||
541 - event->attr.type != PERF_TYPE_RAW)
542 + event->attr.type != event->pmu->type)
543 goto out;
544
545 /* Raw events are used to access counters directly,
546 @@ -693,7 +693,7 @@ static int __init cf_diag_init(void)
547 }
548 debug_register_view(cf_diag_dbg, &debug_sprintf_view);
549
550 - rc = perf_pmu_register(&cf_diag, "cpum_cf_diag", PERF_TYPE_RAW);
551 + rc = perf_pmu_register(&cf_diag, "cpum_cf_diag", -1);
552 if (rc) {
553 debug_unregister_view(cf_diag_dbg, &debug_sprintf_view);
554 debug_unregister(cf_diag_dbg);
555 diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c
556 index fcb6c2e92b07..1e75cc983546 100644
557 --- a/arch/s390/kernel/perf_event.c
558 +++ b/arch/s390/kernel/perf_event.c
559 @@ -224,9 +224,13 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
560 struct pt_regs *regs)
561 {
562 struct unwind_state state;
563 + unsigned long addr;
564
565 - unwind_for_each_frame(&state, current, regs, 0)
566 - perf_callchain_store(entry, state.ip);
567 + unwind_for_each_frame(&state, current, regs, 0) {
568 + addr = unwind_get_return_address(&state);
569 + if (!addr || perf_callchain_store(entry, addr))
570 + return;
571 + }
572 }
573
574 /* Perf definitions for PMU event attributes in sysfs */
575 diff --git a/arch/s390/mm/maccess.c b/arch/s390/mm/maccess.c
576 index 1864a8bb9622..59ad7997fed1 100644
577 --- a/arch/s390/mm/maccess.c
578 +++ b/arch/s390/mm/maccess.c
579 @@ -70,7 +70,7 @@ void notrace s390_kernel_write(void *dst, const void *src, size_t size)
580 spin_unlock_irqrestore(&s390_kernel_write_lock, flags);
581 }
582
583 -static int __memcpy_real(void *dest, void *src, size_t count)
584 +static int __no_sanitize_address __memcpy_real(void *dest, void *src, size_t count)
585 {
586 register unsigned long _dest asm("2") = (unsigned long) dest;
587 register unsigned long _len1 asm("3") = (unsigned long) count;
588 @@ -91,19 +91,23 @@ static int __memcpy_real(void *dest, void *src, size_t count)
589 return rc;
590 }
591
592 -static unsigned long _memcpy_real(unsigned long dest, unsigned long src,
593 - unsigned long count)
594 +static unsigned long __no_sanitize_address _memcpy_real(unsigned long dest,
595 + unsigned long src,
596 + unsigned long count)
597 {
598 int irqs_disabled, rc;
599 unsigned long flags;
600
601 if (!count)
602 return 0;
603 - flags = __arch_local_irq_stnsm(0xf8UL);
604 + flags = arch_local_irq_save();
605 irqs_disabled = arch_irqs_disabled_flags(flags);
606 if (!irqs_disabled)
607 trace_hardirqs_off();
608 + __arch_local_irq_stnsm(0xf8); // disable DAT
609 rc = __memcpy_real((void *) dest, (void *) src, (size_t) count);
610 + if (flags & PSW_MASK_DAT)
611 + __arch_local_irq_stosm(0x04); // enable DAT
612 if (!irqs_disabled)
613 trace_hardirqs_on();
614 __arch_local_irq_ssm(flags);
615 diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
616 index ce88211b9c6c..c8c16b5eed6b 100644
617 --- a/arch/s390/net/bpf_jit_comp.c
618 +++ b/arch/s390/net/bpf_jit_comp.c
619 @@ -23,6 +23,7 @@
620 #include <linux/filter.h>
621 #include <linux/init.h>
622 #include <linux/bpf.h>
623 +#include <linux/mm.h>
624 #include <asm/cacheflush.h>
625 #include <asm/dis.h>
626 #include <asm/facility.h>
627 @@ -1369,7 +1370,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
628 }
629
630 memset(&jit, 0, sizeof(jit));
631 - jit.addrs = kcalloc(fp->len + 1, sizeof(*jit.addrs), GFP_KERNEL);
632 + jit.addrs = kvcalloc(fp->len + 1, sizeof(*jit.addrs), GFP_KERNEL);
633 if (jit.addrs == NULL) {
634 fp = orig_fp;
635 goto out;
636 @@ -1422,7 +1423,7 @@ skip_init_ctx:
637 if (!fp->is_func || extra_pass) {
638 bpf_prog_fill_jited_linfo(fp, jit.addrs + 1);
639 free_addrs:
640 - kfree(jit.addrs);
641 + kvfree(jit.addrs);
642 kfree(jit_data);
643 fp->aux->jit_data = NULL;
644 }
645 diff --git a/arch/sh/include/cpu-sh4/cpu/sh7734.h b/arch/sh/include/cpu-sh4/cpu/sh7734.h
646 index 96f0246ad2f2..82b63208135a 100644
647 --- a/arch/sh/include/cpu-sh4/cpu/sh7734.h
648 +++ b/arch/sh/include/cpu-sh4/cpu/sh7734.h
649 @@ -134,7 +134,7 @@ enum {
650 GPIO_FN_EX_WAIT1, GPIO_FN_SD1_DAT0_A, GPIO_FN_DREQ2, GPIO_FN_CAN1_TX_C,
651 GPIO_FN_ET0_LINK_C, GPIO_FN_ET0_ETXD5_A,
652 GPIO_FN_EX_WAIT0, GPIO_FN_TCLK1_B,
653 - GPIO_FN_RD_WR, GPIO_FN_TCLK0,
654 + GPIO_FN_RD_WR, GPIO_FN_TCLK0, GPIO_FN_CAN_CLK_B, GPIO_FN_ET0_ETXD4,
655 GPIO_FN_EX_CS5, GPIO_FN_SD1_CMD_A, GPIO_FN_ATADIR, GPIO_FN_QSSL_B,
656 GPIO_FN_ET0_ETXD3_A,
657 GPIO_FN_EX_CS4, GPIO_FN_SD1_WP_A, GPIO_FN_ATAWR, GPIO_FN_QMI_QIO1_B,
658 diff --git a/arch/x86/include/asm/crash.h b/arch/x86/include/asm/crash.h
659 index 0acf5ee45a21..ef5638f641f2 100644
660 --- a/arch/x86/include/asm/crash.h
661 +++ b/arch/x86/include/asm/crash.h
662 @@ -2,6 +2,8 @@
663 #ifndef _ASM_X86_CRASH_H
664 #define _ASM_X86_CRASH_H
665
666 +struct kimage;
667 +
668 int crash_load_segments(struct kimage *image);
669 int crash_copy_backup_region(struct kimage *image);
670 int crash_setup_memmap_entries(struct kimage *image,
671 diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
672 index 0c47aa82e2e2..28183ee3cc42 100644
673 --- a/arch/x86/include/asm/fixmap.h
674 +++ b/arch/x86/include/asm/fixmap.h
675 @@ -156,7 +156,7 @@ extern pte_t *kmap_pte;
676 extern pte_t *pkmap_page_table;
677
678 void __native_set_fixmap(enum fixed_addresses idx, pte_t pte);
679 -void native_set_fixmap(enum fixed_addresses idx,
680 +void native_set_fixmap(unsigned /* enum fixed_addresses */ idx,
681 phys_addr_t phys, pgprot_t flags);
682
683 #ifndef CONFIG_PARAVIRT_XXL
684 diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h
685 index e046a405743d..90eb70df0b18 100644
686 --- a/arch/x86/include/asm/syscall_wrapper.h
687 +++ b/arch/x86/include/asm/syscall_wrapper.h
688 @@ -48,12 +48,13 @@
689 * To keep the naming coherent, re-define SYSCALL_DEFINE0 to create an alias
690 * named __ia32_sys_*()
691 */
692 -#define SYSCALL_DEFINE0(sname) \
693 - SYSCALL_METADATA(_##sname, 0); \
694 - asmlinkage long __x64_sys_##sname(void); \
695 - ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \
696 - SYSCALL_ALIAS(__ia32_sys_##sname, __x64_sys_##sname); \
697 - asmlinkage long __x64_sys_##sname(void)
698 +
699 +#define SYSCALL_DEFINE0(sname) \
700 + SYSCALL_METADATA(_##sname, 0); \
701 + asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused);\
702 + ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \
703 + SYSCALL_ALIAS(__ia32_sys_##sname, __x64_sys_##sname); \
704 + asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused)
705
706 #define COND_SYSCALL(name) \
707 cond_syscall(__x64_sys_##name); \
708 @@ -181,11 +182,11 @@
709 * macros to work correctly.
710 */
711 #ifndef SYSCALL_DEFINE0
712 -#define SYSCALL_DEFINE0(sname) \
713 - SYSCALL_METADATA(_##sname, 0); \
714 - asmlinkage long __x64_sys_##sname(void); \
715 - ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \
716 - asmlinkage long __x64_sys_##sname(void)
717 +#define SYSCALL_DEFINE0(sname) \
718 + SYSCALL_METADATA(_##sname, 0); \
719 + asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused);\
720 + ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \
721 + asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused)
722 #endif
723
724 #ifndef COND_SYSCALL
725 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
726 index d6af97fd170a..f0262cb5657a 100644
727 --- a/arch/x86/kernel/apic/io_apic.c
728 +++ b/arch/x86/kernel/apic/io_apic.c
729 @@ -1727,9 +1727,10 @@ static bool io_apic_level_ack_pending(struct mp_chip_data *data)
730
731 static inline bool ioapic_irqd_mask(struct irq_data *data)
732 {
733 - /* If we are moving the irq we need to mask it */
734 + /* If we are moving the IRQ we need to mask it */
735 if (unlikely(irqd_is_setaffinity_pending(data))) {
736 - mask_ioapic_irq(data);
737 + if (!irqd_irq_masked(data))
738 + mask_ioapic_irq(data);
739 return true;
740 }
741 return false;
742 @@ -1766,7 +1767,9 @@ static inline void ioapic_irqd_unmask(struct irq_data *data, bool masked)
743 */
744 if (!io_apic_level_ack_pending(data->chip_data))
745 irq_move_masked_irq(data);
746 - unmask_ioapic_irq(data);
747 + /* If the IRQ is masked in the core, leave it: */
748 + if (!irqd_irq_masked(data))
749 + unmask_ioapic_irq(data);
750 }
751 }
752 #else
753 diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
754 index 6ea7fdc82f3c..259f3f4e2e5f 100644
755 --- a/arch/x86/kernel/cpu/mce/amd.c
756 +++ b/arch/x86/kernel/cpu/mce/amd.c
757 @@ -266,10 +266,10 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
758 smca_set_misc_banks_map(bank, cpu);
759
760 /* Return early if this bank was already initialized. */
761 - if (smca_banks[bank].hwid)
762 + if (smca_banks[bank].hwid && smca_banks[bank].hwid->hwid_mcatype != 0)
763 return;
764
765 - if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
766 + if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
767 pr_warn("Failed to read MCA_IPID for bank %d\n", bank);
768 return;
769 }
770 diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
771 index 743370ee4983..aecb15ba66cd 100644
772 --- a/arch/x86/kernel/cpu/mce/core.c
773 +++ b/arch/x86/kernel/cpu/mce/core.c
774 @@ -814,8 +814,8 @@ static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp,
775 if (quirk_no_way_out)
776 quirk_no_way_out(i, m, regs);
777
778 + m->bank = i;
779 if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) {
780 - m->bank = i;
781 mce_read_aux(m, i);
782 *msg = tmp;
783 return 1;
784 diff --git a/arch/x86/kernel/cpu/mce/therm_throt.c b/arch/x86/kernel/cpu/mce/therm_throt.c
785 index 6e2becf547c5..bc441d68d060 100644
786 --- a/arch/x86/kernel/cpu/mce/therm_throt.c
787 +++ b/arch/x86/kernel/cpu/mce/therm_throt.c
788 @@ -188,7 +188,7 @@ static void therm_throt_process(bool new_event, int event, int level)
789 /* if we just entered the thermal event */
790 if (new_event) {
791 if (event == THERMAL_THROTTLING_EVENT)
792 - pr_crit("CPU%d: %s temperature above threshold, cpu clock throttled (total events = %lu)\n",
793 + pr_warn("CPU%d: %s temperature above threshold, cpu clock throttled (total events = %lu)\n",
794 this_cpu,
795 level == CORE_LEVEL ? "Core" : "Package",
796 state->count);
797 diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
798 index 4cba91ec8049..606711f5ebf8 100644
799 --- a/arch/x86/kernel/early-quirks.c
800 +++ b/arch/x86/kernel/early-quirks.c
801 @@ -710,6 +710,8 @@ static struct chipset early_qrk[] __initdata = {
802 */
803 { PCI_VENDOR_ID_INTEL, 0x0f00,
804 PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, force_disable_hpet},
805 + { PCI_VENDOR_ID_INTEL, 0x3e20,
806 + PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, force_disable_hpet},
807 { PCI_VENDOR_ID_INTEL, 0x3ec4,
808 PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, force_disable_hpet},
809 { PCI_VENDOR_ID_BROADCOM, 0x4331,
810 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
811 index 53dbcca9af09..b1d5a8c94a57 100644
812 --- a/arch/x86/kvm/cpuid.c
813 +++ b/arch/x86/kvm/cpuid.c
814 @@ -402,7 +402,8 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index)
815 entry->edx |= F(SPEC_CTRL);
816 if (boot_cpu_has(X86_FEATURE_STIBP))
817 entry->edx |= F(INTEL_STIBP);
818 - if (boot_cpu_has(X86_FEATURE_SSBD))
819 + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) ||
820 + boot_cpu_has(X86_FEATURE_AMD_SSBD))
821 entry->edx |= F(SPEC_CTRL_SSBD);
822 /*
823 * We emulate ARCH_CAPABILITIES in software even
824 @@ -759,7 +760,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function,
825 entry->ebx |= F(AMD_IBRS);
826 if (boot_cpu_has(X86_FEATURE_STIBP))
827 entry->ebx |= F(AMD_STIBP);
828 - if (boot_cpu_has(X86_FEATURE_SSBD))
829 + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) ||
830 + boot_cpu_has(X86_FEATURE_AMD_SSBD))
831 entry->ebx |= F(AMD_SSBD);
832 if (!boot_cpu_has_bug(X86_BUG_SPEC_STORE_BYPASS))
833 entry->ebx |= F(AMD_SSB_NO);
834 diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt
835 index e0b85930dd77..0a0e9112f284 100644
836 --- a/arch/x86/lib/x86-opcode-map.txt
837 +++ b/arch/x86/lib/x86-opcode-map.txt
838 @@ -333,7 +333,7 @@ AVXcode: 1
839 06: CLTS
840 07: SYSRET (o64)
841 08: INVD
842 -09: WBINVD
843 +09: WBINVD | WBNOINVD (F3)
844 0a:
845 0b: UD2 (1B)
846 0c:
847 @@ -364,7 +364,7 @@ AVXcode: 1
848 # a ModR/M byte.
849 1a: BNDCL Gv,Ev (F3) | BNDCU Gv,Ev (F2) | BNDMOV Gv,Ev (66) | BNDLDX Gv,Ev
850 1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv
851 -1c:
852 +1c: Grp20 (1A),(1C)
853 1d:
854 1e:
855 1f: NOP Ev
856 @@ -792,6 +792,8 @@ f3: Grp17 (1A)
857 f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v)
858 f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v)
859 f7: BEXTR Gy,Ey,By (v) | SHLX Gy,Ey,By (66),(v) | SARX Gy,Ey,By (F3),(v) | SHRX Gy,Ey,By (F2),(v)
860 +f8: MOVDIR64B Gv,Mdqq (66) | ENQCMD Gv,Mdqq (F2) | ENQCMDS Gv,Mdqq (F3)
861 +f9: MOVDIRI My,Gy
862 EndTable
863
864 Table: 3-byte opcode 2 (0x0f 0x3a)
865 @@ -943,9 +945,9 @@ GrpTable: Grp6
866 EndTable
867
868 GrpTable: Grp7
869 -0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B)
870 -1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B)
871 -2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B)
872 +0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B) | PCONFIG (101),(11B) | ENCLV (000),(11B)
873 +1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B) | ENCLS (111),(11B)
874 +2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B) | ENCLU (111),(11B)
875 3: LIDT Ms
876 4: SMSW Mw/Rv
877 5: rdpkru (110),(11B) | wrpkru (111),(11B)
878 @@ -1020,7 +1022,7 @@ GrpTable: Grp15
879 3: vstmxcsr Md (v1) | WRGSBASE Ry (F3),(11B)
880 4: XSAVE | ptwrite Ey (F3),(11B)
881 5: XRSTOR | lfence (11B)
882 -6: XSAVEOPT | clwb (66) | mfence (11B)
883 +6: XSAVEOPT | clwb (66) | mfence (11B) | TPAUSE Rd (66),(11B) | UMONITOR Rv (F3),(11B) | UMWAIT Rd (F2),(11B)
884 7: clflush | clflushopt (66) | sfence (11B)
885 EndTable
886
887 @@ -1051,6 +1053,10 @@ GrpTable: Grp19
888 6: vscatterpf1qps/d Wx (66),(ev)
889 EndTable
890
891 +GrpTable: Grp20
892 +0: cldemote Mb
893 +EndTable
894 +
895 # AMD's Prefetch Group
896 GrpTable: GrpP
897 0: PREFETCH
898 diff --git a/arch/x86/math-emu/fpu_system.h b/arch/x86/math-emu/fpu_system.h
899 index f98a0c956764..9b41391867dc 100644
900 --- a/arch/x86/math-emu/fpu_system.h
901 +++ b/arch/x86/math-emu/fpu_system.h
902 @@ -107,6 +107,8 @@ static inline bool seg_writable(struct desc_struct *d)
903 #define FPU_access_ok(y,z) if ( !access_ok(y,z) ) \
904 math_abort(FPU_info,SIGSEGV)
905 #define FPU_abort math_abort(FPU_info, SIGSEGV)
906 +#define FPU_copy_from_user(to, from, n) \
907 + do { if (copy_from_user(to, from, n)) FPU_abort; } while (0)
908
909 #undef FPU_IGNORE_CODE_SEGV
910 #ifdef FPU_IGNORE_CODE_SEGV
911 @@ -122,7 +124,7 @@ static inline bool seg_writable(struct desc_struct *d)
912 #define FPU_code_access_ok(z) FPU_access_ok((void __user *)FPU_EIP,z)
913 #endif
914
915 -#define FPU_get_user(x,y) get_user((x),(y))
916 -#define FPU_put_user(x,y) put_user((x),(y))
917 +#define FPU_get_user(x,y) do { if (get_user((x),(y))) FPU_abort; } while (0)
918 +#define FPU_put_user(x,y) do { if (put_user((x),(y))) FPU_abort; } while (0)
919
920 #endif
921 diff --git a/arch/x86/math-emu/reg_ld_str.c b/arch/x86/math-emu/reg_ld_str.c
922 index f3779743d15e..fe6246ff9887 100644
923 --- a/arch/x86/math-emu/reg_ld_str.c
924 +++ b/arch/x86/math-emu/reg_ld_str.c
925 @@ -85,7 +85,7 @@ int FPU_load_extended(long double __user *s, int stnr)
926
927 RE_ENTRANT_CHECK_OFF;
928 FPU_access_ok(s, 10);
929 - __copy_from_user(sti_ptr, s, 10);
930 + FPU_copy_from_user(sti_ptr, s, 10);
931 RE_ENTRANT_CHECK_ON;
932
933 return FPU_tagof(sti_ptr);
934 @@ -1126,9 +1126,9 @@ void frstor(fpu_addr_modes addr_modes, u_char __user *data_address)
935 /* Copy all registers in stack order. */
936 RE_ENTRANT_CHECK_OFF;
937 FPU_access_ok(s, 80);
938 - __copy_from_user(register_base + offset, s, other);
939 + FPU_copy_from_user(register_base + offset, s, other);
940 if (offset)
941 - __copy_from_user(register_base, s + other, offset);
942 + FPU_copy_from_user(register_base, s + other, offset);
943 RE_ENTRANT_CHECK_ON;
944
945 for (i = 0; i < 8; i++) {
946 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
947 index 3e4b9035bb9a..7bd2c3a52297 100644
948 --- a/arch/x86/mm/pgtable.c
949 +++ b/arch/x86/mm/pgtable.c
950 @@ -643,8 +643,8 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
951 fixmaps_set++;
952 }
953
954 -void native_set_fixmap(enum fixed_addresses idx, phys_addr_t phys,
955 - pgprot_t flags)
956 +void native_set_fixmap(unsigned /* enum fixed_addresses */ idx,
957 + phys_addr_t phys, pgprot_t flags)
958 {
959 /* Sanitize 'prot' against any unsupported bits: */
960 pgprot_val(flags) &= __default_kernel_pte_mask;
961 diff --git a/block/blk-iocost.c b/block/blk-iocost.c
962 index e01267f99183..27ca68621137 100644
963 --- a/block/blk-iocost.c
964 +++ b/block/blk-iocost.c
965 @@ -1212,7 +1212,7 @@ static enum hrtimer_restart iocg_waitq_timer_fn(struct hrtimer *timer)
966 return HRTIMER_NORESTART;
967 }
968
969 -static void iocg_kick_delay(struct ioc_gq *iocg, struct ioc_now *now, u64 cost)
970 +static bool iocg_kick_delay(struct ioc_gq *iocg, struct ioc_now *now, u64 cost)
971 {
972 struct ioc *ioc = iocg->ioc;
973 struct blkcg_gq *blkg = iocg_to_blkg(iocg);
974 @@ -1229,11 +1229,11 @@ static void iocg_kick_delay(struct ioc_gq *iocg, struct ioc_now *now, u64 cost)
975 /* clear or maintain depending on the overage */
976 if (time_before_eq64(vtime, now->vnow)) {
977 blkcg_clear_delay(blkg);
978 - return;
979 + return false;
980 }
981 if (!atomic_read(&blkg->use_delay) &&
982 time_before_eq64(vtime, now->vnow + vmargin))
983 - return;
984 + return false;
985
986 /* use delay */
987 if (cost) {
988 @@ -1250,10 +1250,11 @@ static void iocg_kick_delay(struct ioc_gq *iocg, struct ioc_now *now, u64 cost)
989 oexpires = ktime_to_ns(hrtimer_get_softexpires(&iocg->delay_timer));
990 if (hrtimer_is_queued(&iocg->delay_timer) &&
991 abs(oexpires - expires) <= margin_ns / 4)
992 - return;
993 + return true;
994
995 hrtimer_start_range_ns(&iocg->delay_timer, ns_to_ktime(expires),
996 margin_ns / 4, HRTIMER_MODE_ABS);
997 + return true;
998 }
999
1000 static enum hrtimer_restart iocg_delay_timer_fn(struct hrtimer *timer)
1001 @@ -1739,7 +1740,9 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)
1002 */
1003 if (bio_issue_as_root_blkg(bio) || fatal_signal_pending(current)) {
1004 atomic64_add(abs_cost, &iocg->abs_vdebt);
1005 - iocg_kick_delay(iocg, &now, cost);
1006 + if (iocg_kick_delay(iocg, &now, cost))
1007 + blkcg_schedule_throttle(rqos->q,
1008 + (bio->bi_opf & REQ_SWAP) == REQ_SWAP);
1009 return;
1010 }
1011
1012 diff --git a/crypto/Kconfig b/crypto/Kconfig
1013 index 9e524044d312..29472fb795f3 100644
1014 --- a/crypto/Kconfig
1015 +++ b/crypto/Kconfig
1016 @@ -309,6 +309,7 @@ config CRYPTO_AEGIS128
1017 config CRYPTO_AEGIS128_SIMD
1018 bool "Support SIMD acceleration for AEGIS-128"
1019 depends on CRYPTO_AEGIS128 && ((ARM || ARM64) && KERNEL_MODE_NEON)
1020 + depends on !ARM || CC_IS_CLANG || GCC_VERSION >= 40800
1021 default y
1022
1023 config CRYPTO_AEGIS128_AESNI_SSE2
1024 diff --git a/crypto/Makefile b/crypto/Makefile
1025 index fcb1ee679782..aa740c8492b9 100644
1026 --- a/crypto/Makefile
1027 +++ b/crypto/Makefile
1028 @@ -93,7 +93,7 @@ obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o
1029 aegis128-y := aegis128-core.o
1030
1031 ifeq ($(ARCH),arm)
1032 -CFLAGS_aegis128-neon-inner.o += -ffreestanding -march=armv7-a -mfloat-abi=softfp
1033 +CFLAGS_aegis128-neon-inner.o += -ffreestanding -march=armv8-a -mfloat-abi=softfp
1034 CFLAGS_aegis128-neon-inner.o += -mfpu=crypto-neon-fp-armv8
1035 aegis128-$(CONFIG_CRYPTO_AEGIS128_SIMD) += aegis128-neon.o aegis128-neon-inner.o
1036 endif
1037 diff --git a/crypto/asymmetric_keys/asym_tpm.c b/crypto/asymmetric_keys/asym_tpm.c
1038 index 76d2ce3a1b5b..5154e280ada2 100644
1039 --- a/crypto/asymmetric_keys/asym_tpm.c
1040 +++ b/crypto/asymmetric_keys/asym_tpm.c
1041 @@ -486,6 +486,7 @@ static int tpm_key_encrypt(struct tpm_key *tk,
1042 if (ret < 0)
1043 goto error_free_tfm;
1044
1045 + ret = -ENOMEM;
1046 req = akcipher_request_alloc(tfm, GFP_KERNEL);
1047 if (!req)
1048 goto error_free_tfm;
1049 diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
1050 index 364b9df9d631..d7f43d4ea925 100644
1051 --- a/crypto/asymmetric_keys/public_key.c
1052 +++ b/crypto/asymmetric_keys/public_key.c
1053 @@ -184,6 +184,7 @@ static int software_key_eds_op(struct kernel_pkey_params *params,
1054 if (IS_ERR(tfm))
1055 return PTR_ERR(tfm);
1056
1057 + ret = -ENOMEM;
1058 req = akcipher_request_alloc(tfm, GFP_KERNEL);
1059 if (!req)
1060 goto error_free_tfm;
1061 diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
1062 index 4a2cde2c536a..ce93a355bd1c 100644
1063 --- a/drivers/acpi/button.c
1064 +++ b/drivers/acpi/button.c
1065 @@ -78,6 +78,17 @@ static const struct dmi_system_id lid_blacklst[] = {
1066 DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"),
1067 },
1068 },
1069 + {
1070 + /*
1071 + * Medion Akoya E2215T, notification of the LID device only
1072 + * happens on close, not on open and _LID always returns closed.
1073 + */
1074 + .matches = {
1075 + DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
1076 + DMI_MATCH(DMI_PRODUCT_NAME, "E2215T MD60198"),
1077 + },
1078 + .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN,
1079 + },
1080 {}
1081 };
1082
1083 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
1084 index 28c492be0a57..74c9b3032d46 100644
1085 --- a/drivers/ata/libata-core.c
1086 +++ b/drivers/ata/libata-core.c
1087 @@ -6708,6 +6708,9 @@ void ata_host_detach(struct ata_host *host)
1088 {
1089 int i;
1090
1091 + /* Ensure ata_port probe has completed */
1092 + async_synchronize_full();
1093 +
1094 for (i = 0; i < host->n_ports; i++)
1095 ata_port_detach(host->ports[i]);
1096
1097 diff --git a/drivers/base/firmware_loader/builtin/Makefile b/drivers/base/firmware_loader/builtin/Makefile
1098 index 37e5ae387400..4a66888e7253 100644
1099 --- a/drivers/base/firmware_loader/builtin/Makefile
1100 +++ b/drivers/base/firmware_loader/builtin/Makefile
1101 @@ -8,7 +8,8 @@ fwdir := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir))
1102 obj-y := $(addsuffix .gen.o, $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE)))
1103
1104 FWNAME = $(patsubst $(obj)/%.gen.S,%,$@)
1105 -FWSTR = $(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME))))
1106 +comma := ,
1107 +FWSTR = $(subst $(comma),_,$(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME)))))
1108 ASM_WORD = $(if $(CONFIG_64BIT),.quad,.long)
1109 ASM_ALIGN = $(if $(CONFIG_64BIT),3,2)
1110 PROGBITS = $(if $(CONFIG_ARM),%,@)progbits
1111 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
1112 index f6f77eaa7217..ef6e251857c8 100644
1113 --- a/drivers/block/loop.c
1114 +++ b/drivers/block/loop.c
1115 @@ -417,18 +417,20 @@ out_free_page:
1116 return ret;
1117 }
1118
1119 -static int lo_discard(struct loop_device *lo, struct request *rq, loff_t pos)
1120 +static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos,
1121 + int mode)
1122 {
1123 /*
1124 - * We use punch hole to reclaim the free space used by the
1125 - * image a.k.a. discard. However we do not support discard if
1126 - * encryption is enabled, because it may give an attacker
1127 - * useful information.
1128 + * We use fallocate to manipulate the space mappings used by the image
1129 + * a.k.a. discard/zerorange. However we do not support this if
1130 + * encryption is enabled, because it may give an attacker useful
1131 + * information.
1132 */
1133 struct file *file = lo->lo_backing_file;
1134 - int mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
1135 int ret;
1136
1137 + mode |= FALLOC_FL_KEEP_SIZE;
1138 +
1139 if ((!file->f_op->fallocate) || lo->lo_encrypt_key_size) {
1140 ret = -EOPNOTSUPP;
1141 goto out;
1142 @@ -596,9 +598,17 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
1143 switch (req_op(rq)) {
1144 case REQ_OP_FLUSH:
1145 return lo_req_flush(lo, rq);
1146 - case REQ_OP_DISCARD:
1147 case REQ_OP_WRITE_ZEROES:
1148 - return lo_discard(lo, rq, pos);
1149 + /*
1150 + * If the caller doesn't want deallocation, call zeroout to
1151 + * write zeroes the range. Otherwise, punch them out.
1152 + */
1153 + return lo_fallocate(lo, rq, pos,
1154 + (rq->cmd_flags & REQ_NOUNMAP) ?
1155 + FALLOC_FL_ZERO_RANGE :
1156 + FALLOC_FL_PUNCH_HOLE);
1157 + case REQ_OP_DISCARD:
1158 + return lo_fallocate(lo, rq, pos, FALLOC_FL_PUNCH_HOLE);
1159 case REQ_OP_WRITE:
1160 if (lo->transfer)
1161 return lo_write_transfer(lo, rq, pos);
1162 diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
1163 index 57532465fb83..b4607dd96185 100644
1164 --- a/drivers/block/nbd.c
1165 +++ b/drivers/block/nbd.c
1166 @@ -1296,10 +1296,10 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
1167 mutex_unlock(&nbd->config_lock);
1168 ret = wait_event_interruptible(config->recv_wq,
1169 atomic_read(&config->recv_threads) == 0);
1170 - if (ret) {
1171 + if (ret)
1172 sock_shutdown(nbd);
1173 - flush_workqueue(nbd->recv_workq);
1174 - }
1175 + flush_workqueue(nbd->recv_workq);
1176 +
1177 mutex_lock(&nbd->config_lock);
1178 nbd_bdev_reset(bdev);
1179 /* user requested, ignore socket errors */
1180 diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
1181 index a9c35ebb30f8..23e606aaaea4 100644
1182 --- a/drivers/bluetooth/btusb.c
1183 +++ b/drivers/bluetooth/btusb.c
1184 @@ -3807,8 +3807,8 @@ static int btusb_probe(struct usb_interface *intf,
1185 btusb_check_needs_reset_resume(intf);
1186 }
1187
1188 -#ifdef CONFIG_BT_HCIBTUSB_RTL
1189 - if (id->driver_info & BTUSB_REALTEK) {
1190 + if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) &&
1191 + (id->driver_info & BTUSB_REALTEK)) {
1192 hdev->setup = btrtl_setup_realtek;
1193 hdev->shutdown = btrtl_shutdown_realtek;
1194 hdev->cmd_timeout = btusb_rtl_cmd_timeout;
1195 @@ -3819,7 +3819,6 @@ static int btusb_probe(struct usb_interface *intf,
1196 */
1197 set_bit(BTUSB_WAKEUP_DISABLE, &data->flags);
1198 }
1199 -#endif
1200
1201 if (id->driver_info & BTUSB_AMP) {
1202 /* AMP controllers do not support SCO packets */
1203 diff --git a/drivers/char/hw_random/omap3-rom-rng.c b/drivers/char/hw_random/omap3-rom-rng.c
1204 index 38b719017186..648e39ce6bd9 100644
1205 --- a/drivers/char/hw_random/omap3-rom-rng.c
1206 +++ b/drivers/char/hw_random/omap3-rom-rng.c
1207 @@ -121,7 +121,8 @@ static int omap3_rom_rng_remove(struct platform_device *pdev)
1208 {
1209 cancel_delayed_work_sync(&idle_work);
1210 hwrng_unregister(&omap3_rom_rng_ops);
1211 - clk_disable_unprepare(rng_clk);
1212 + if (!rng_idle)
1213 + clk_disable_unprepare(rng_clk);
1214 return 0;
1215 }
1216
1217 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
1218 index 2aab80e19ae0..3c8a559506e8 100644
1219 --- a/drivers/char/ipmi/ipmi_msghandler.c
1220 +++ b/drivers/char/ipmi/ipmi_msghandler.c
1221 @@ -448,6 +448,8 @@ enum ipmi_stat_indexes {
1222
1223 #define IPMI_IPMB_NUM_SEQ 64
1224 struct ipmi_smi {
1225 + struct module *owner;
1226 +
1227 /* What interface number are we? */
1228 int intf_num;
1229
1230 @@ -1220,6 +1222,11 @@ int ipmi_create_user(unsigned int if_num,
1231 if (rv)
1232 goto out_kfree;
1233
1234 + if (!try_module_get(intf->owner)) {
1235 + rv = -ENODEV;
1236 + goto out_kfree;
1237 + }
1238 +
1239 /* Note that each existing user holds a refcount to the interface. */
1240 kref_get(&intf->refcount);
1241
1242 @@ -1349,6 +1356,7 @@ static void _ipmi_destroy_user(struct ipmi_user *user)
1243 }
1244
1245 kref_put(&intf->refcount, intf_free);
1246 + module_put(intf->owner);
1247 }
1248
1249 int ipmi_destroy_user(struct ipmi_user *user)
1250 @@ -2459,7 +2467,7 @@ static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc)
1251 * been recently fetched, this will just use the cached data. Otherwise
1252 * it will run a new fetch.
1253 *
1254 - * Except for the first time this is called (in ipmi_register_smi()),
1255 + * Except for the first time this is called (in ipmi_add_smi()),
1256 * this will always return good data;
1257 */
1258 static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
1259 @@ -3377,10 +3385,11 @@ static void redo_bmc_reg(struct work_struct *work)
1260 kref_put(&intf->refcount, intf_free);
1261 }
1262
1263 -int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
1264 - void *send_info,
1265 - struct device *si_dev,
1266 - unsigned char slave_addr)
1267 +int ipmi_add_smi(struct module *owner,
1268 + const struct ipmi_smi_handlers *handlers,
1269 + void *send_info,
1270 + struct device *si_dev,
1271 + unsigned char slave_addr)
1272 {
1273 int i, j;
1274 int rv;
1275 @@ -3406,7 +3415,7 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
1276 return rv;
1277 }
1278
1279 -
1280 + intf->owner = owner;
1281 intf->bmc = &intf->tmp_bmc;
1282 INIT_LIST_HEAD(&intf->bmc->intfs);
1283 mutex_init(&intf->bmc->dyn_mutex);
1284 @@ -3514,7 +3523,7 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
1285
1286 return rv;
1287 }
1288 -EXPORT_SYMBOL(ipmi_register_smi);
1289 +EXPORT_SYMBOL(ipmi_add_smi);
1290
1291 static void deliver_smi_err_response(struct ipmi_smi *intf,
1292 struct ipmi_smi_msg *msg,
1293 diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-common.c
1294 index 2ec47a69a2a6..b23b0b999232 100644
1295 --- a/drivers/char/tpm/tpm-dev-common.c
1296 +++ b/drivers/char/tpm/tpm-dev-common.c
1297 @@ -61,6 +61,12 @@ static void tpm_dev_async_work(struct work_struct *work)
1298
1299 mutex_lock(&priv->buffer_mutex);
1300 priv->command_enqueued = false;
1301 + ret = tpm_try_get_ops(priv->chip);
1302 + if (ret) {
1303 + priv->response_length = ret;
1304 + goto out;
1305 + }
1306 +
1307 ret = tpm_dev_transmit(priv->chip, priv->space, priv->data_buffer,
1308 sizeof(priv->data_buffer));
1309 tpm_put_ops(priv->chip);
1310 @@ -68,6 +74,7 @@ static void tpm_dev_async_work(struct work_struct *work)
1311 priv->response_length = ret;
1312 mod_timer(&priv->user_read_timer, jiffies + (120 * HZ));
1313 }
1314 +out:
1315 mutex_unlock(&priv->buffer_mutex);
1316 wake_up_interruptible(&priv->async_wait);
1317 }
1318 @@ -204,6 +211,7 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
1319 if (file->f_flags & O_NONBLOCK) {
1320 priv->command_enqueued = true;
1321 queue_work(tpm_dev_wq, &priv->async_work);
1322 + tpm_put_ops(priv->chip);
1323 mutex_unlock(&priv->buffer_mutex);
1324 return size;
1325 }
1326 diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
1327 index 270f43acbb77..f528fc39ea6b 100644
1328 --- a/drivers/char/tpm/tpm_tis_core.c
1329 +++ b/drivers/char/tpm/tpm_tis_core.c
1330 @@ -899,13 +899,13 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
1331
1332 if (wait_startup(chip, 0) != 0) {
1333 rc = -ENODEV;
1334 - goto out_err;
1335 + goto err_start;
1336 }
1337
1338 /* Take control of the TPM's interrupt hardware and shut it off */
1339 rc = tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask);
1340 if (rc < 0)
1341 - goto out_err;
1342 + goto err_start;
1343
1344 intmask |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT |
1345 TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT;
1346 @@ -914,21 +914,21 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
1347
1348 rc = tpm_chip_start(chip);
1349 if (rc)
1350 - goto out_err;
1351 + goto err_start;
1352 +
1353 rc = tpm2_probe(chip);
1354 - tpm_chip_stop(chip);
1355 if (rc)
1356 - goto out_err;
1357 + goto err_probe;
1358
1359 rc = tpm_tis_read32(priv, TPM_DID_VID(0), &vendor);
1360 if (rc < 0)
1361 - goto out_err;
1362 + goto err_probe;
1363
1364 priv->manufacturer_id = vendor;
1365
1366 rc = tpm_tis_read8(priv, TPM_RID(0), &rid);
1367 if (rc < 0)
1368 - goto out_err;
1369 + goto err_probe;
1370
1371 dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n",
1372 (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
1373 @@ -937,13 +937,13 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
1374 probe = probe_itpm(chip);
1375 if (probe < 0) {
1376 rc = -ENODEV;
1377 - goto out_err;
1378 + goto err_probe;
1379 }
1380
1381 /* Figure out the capabilities */
1382 rc = tpm_tis_read32(priv, TPM_INTF_CAPS(priv->locality), &intfcaps);
1383 if (rc < 0)
1384 - goto out_err;
1385 + goto err_probe;
1386
1387 dev_dbg(dev, "TPM interface capabilities (0x%x):\n",
1388 intfcaps);
1389 @@ -977,10 +977,9 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
1390 if (tpm_get_timeouts(chip)) {
1391 dev_err(dev, "Could not get TPM timeouts and durations\n");
1392 rc = -ENODEV;
1393 - goto out_err;
1394 + goto err_probe;
1395 }
1396
1397 - tpm_chip_start(chip);
1398 chip->flags |= TPM_CHIP_FLAG_IRQ;
1399 if (irq) {
1400 tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
1401 @@ -991,18 +990,20 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
1402 } else {
1403 tpm_tis_probe_irq(chip, intmask);
1404 }
1405 - tpm_chip_stop(chip);
1406 }
1407
1408 + tpm_chip_stop(chip);
1409 +
1410 rc = tpm_chip_register(chip);
1411 if (rc)
1412 - goto out_err;
1413 -
1414 - if (chip->ops->clk_enable != NULL)
1415 - chip->ops->clk_enable(chip, false);
1416 + goto err_start;
1417
1418 return 0;
1419 -out_err:
1420 +
1421 +err_probe:
1422 + tpm_chip_stop(chip);
1423 +
1424 +err_start:
1425 if ((chip->ops != NULL) && (chip->ops->clk_enable != NULL))
1426 chip->ops->clk_enable(chip, false);
1427
1428 diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c
1429 index 388bdb94f841..d3486ee79ab5 100644
1430 --- a/drivers/clk/imx/clk-composite-8m.c
1431 +++ b/drivers/clk/imx/clk-composite-8m.c
1432 @@ -142,6 +142,7 @@ struct clk *imx8m_clk_composite_flags(const char *name,
1433 mux->reg = reg;
1434 mux->shift = PCG_PCS_SHIFT;
1435 mux->mask = PCG_PCS_MASK;
1436 + mux->lock = &imx_ccm_lock;
1437
1438 div = kzalloc(sizeof(*div), GFP_KERNEL);
1439 if (!div)
1440 @@ -161,6 +162,7 @@ struct clk *imx8m_clk_composite_flags(const char *name,
1441 gate_hw = &gate->hw;
1442 gate->reg = reg;
1443 gate->bit_idx = PCG_CGC_SHIFT;
1444 + gate->lock = &imx_ccm_lock;
1445
1446 hw = clk_hw_register_composite(NULL, name, parent_names, num_parents,
1447 mux_hw, &clk_mux_ops, div_hw,
1448 diff --git a/drivers/clk/imx/clk-imx7ulp.c b/drivers/clk/imx/clk-imx7ulp.c
1449 index 2022d9bead91..a0f650150367 100644
1450 --- a/drivers/clk/imx/clk-imx7ulp.c
1451 +++ b/drivers/clk/imx/clk-imx7ulp.c
1452 @@ -40,6 +40,7 @@ static const struct clk_div_table ulp_div_table[] = {
1453 { .val = 5, .div = 16, },
1454 { .val = 6, .div = 32, },
1455 { .val = 7, .div = 64, },
1456 + { /* sentinel */ },
1457 };
1458
1459 static const int pcc2_uart_clk_ids[] __initconst = {
1460 diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c
1461 index 7a815ec76aa5..d43b4a3c0de8 100644
1462 --- a/drivers/clk/imx/clk-pll14xx.c
1463 +++ b/drivers/clk/imx/clk-pll14xx.c
1464 @@ -153,7 +153,7 @@ static int clk_pll14xx_wait_lock(struct clk_pll14xx *pll)
1465 {
1466 u32 val;
1467
1468 - return readl_poll_timeout(pll->base, val, val & LOCK_TIMEOUT_US, 0,
1469 + return readl_poll_timeout(pll->base, val, val & LOCK_STATUS, 0,
1470 LOCK_TIMEOUT_US);
1471 }
1472
1473 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
1474 index bc19d6c16aaa..a7db4f22a077 100644
1475 --- a/drivers/cpufreq/cpufreq.c
1476 +++ b/drivers/cpufreq/cpufreq.c
1477 @@ -2634,6 +2634,13 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
1478 if (cpufreq_disabled())
1479 return -ENODEV;
1480
1481 + /*
1482 + * The cpufreq core depends heavily on the availability of device
1483 + * structure, make sure they are available before proceeding further.
1484 + */
1485 + if (!get_cpu_device(0))
1486 + return -EPROBE_DEFER;
1487 +
1488 if (!driver_data || !driver_data->verify || !driver_data->init ||
1489 !(driver_data->setpolicy || driver_data->target_index ||
1490 driver_data->target) ||
1491 diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
1492 index eca32e443716..9907a165135b 100644
1493 --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
1494 +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
1495 @@ -25,7 +25,7 @@
1496 static struct platform_device *cpufreq_dt_pdev, *sun50i_cpufreq_pdev;
1497
1498 /**
1499 - * sun50i_cpufreq_get_efuse() - Parse and return efuse value present on SoC
1500 + * sun50i_cpufreq_get_efuse() - Determine speed grade from efuse value
1501 * @versions: Set to the value parsed from efuse
1502 *
1503 * Returns 0 if success.
1504 @@ -69,21 +69,16 @@ static int sun50i_cpufreq_get_efuse(u32 *versions)
1505 return PTR_ERR(speedbin);
1506
1507 efuse_value = (*speedbin >> NVMEM_SHIFT) & NVMEM_MASK;
1508 - switch (efuse_value) {
1509 - case 0b0001:
1510 - *versions = 1;
1511 - break;
1512 - case 0b0011:
1513 - *versions = 2;
1514 - break;
1515 - default:
1516 - /*
1517 - * For other situations, we treat it as bin0.
1518 - * This vf table can be run for any good cpu.
1519 - */
1520 +
1521 + /*
1522 + * We treat unexpected efuse values as if the SoC was from
1523 + * the slowest bin. Expected efuse values are 1-3, slowest
1524 + * to fastest.
1525 + */
1526 + if (efuse_value >= 1 && efuse_value <= 3)
1527 + *versions = efuse_value - 1;
1528 + else
1529 *versions = 0;
1530 - break;
1531 - }
1532
1533 kfree(speedbin);
1534 return 0;
1535 diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c
1536 index 00920a2b95ce..db99cee1991c 100644
1537 --- a/drivers/crypto/atmel-aes.c
1538 +++ b/drivers/crypto/atmel-aes.c
1539 @@ -145,7 +145,7 @@ struct atmel_aes_xts_ctx {
1540 u32 key2[AES_KEYSIZE_256 / sizeof(u32)];
1541 };
1542
1543 -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
1544 +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
1545 struct atmel_aes_authenc_ctx {
1546 struct atmel_aes_base_ctx base;
1547 struct atmel_sha_authenc_ctx *auth;
1548 @@ -157,7 +157,7 @@ struct atmel_aes_reqctx {
1549 u32 lastc[AES_BLOCK_SIZE / sizeof(u32)];
1550 };
1551
1552 -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
1553 +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
1554 struct atmel_aes_authenc_reqctx {
1555 struct atmel_aes_reqctx base;
1556
1557 @@ -486,7 +486,7 @@ static inline bool atmel_aes_is_encrypt(const struct atmel_aes_dev *dd)
1558 return (dd->flags & AES_FLAGS_ENCRYPT);
1559 }
1560
1561 -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
1562 +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
1563 static void atmel_aes_authenc_complete(struct atmel_aes_dev *dd, int err);
1564 #endif
1565
1566 @@ -515,7 +515,7 @@ static void atmel_aes_set_iv_as_last_ciphertext_block(struct atmel_aes_dev *dd)
1567
1568 static inline int atmel_aes_complete(struct atmel_aes_dev *dd, int err)
1569 {
1570 -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
1571 +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
1572 if (dd->ctx->is_aead)
1573 atmel_aes_authenc_complete(dd, err);
1574 #endif
1575 @@ -1980,7 +1980,7 @@ static struct crypto_alg aes_xts_alg = {
1576 }
1577 };
1578
1579 -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
1580 +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
1581 /* authenc aead functions */
1582
1583 static int atmel_aes_authenc_start(struct atmel_aes_dev *dd);
1584 @@ -2467,7 +2467,7 @@ static void atmel_aes_unregister_algs(struct atmel_aes_dev *dd)
1585 {
1586 int i;
1587
1588 -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
1589 +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
1590 if (dd->caps.has_authenc)
1591 for (i = 0; i < ARRAY_SIZE(aes_authenc_algs); i++)
1592 crypto_unregister_aead(&aes_authenc_algs[i]);
1593 @@ -2514,7 +2514,7 @@ static int atmel_aes_register_algs(struct atmel_aes_dev *dd)
1594 goto err_aes_xts_alg;
1595 }
1596
1597 -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
1598 +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
1599 if (dd->caps.has_authenc) {
1600 for (i = 0; i < ARRAY_SIZE(aes_authenc_algs); i++) {
1601 err = crypto_register_aead(&aes_authenc_algs[i]);
1602 @@ -2526,7 +2526,7 @@ static int atmel_aes_register_algs(struct atmel_aes_dev *dd)
1603
1604 return 0;
1605
1606 -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
1607 +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
1608 /* i = ARRAY_SIZE(aes_authenc_algs); */
1609 err_aes_authenc_alg:
1610 for (j = 0; j < i; j++)
1611 @@ -2716,7 +2716,7 @@ static int atmel_aes_probe(struct platform_device *pdev)
1612
1613 atmel_aes_get_cap(aes_dd);
1614
1615 -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
1616 +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
1617 if (aes_dd->caps.has_authenc && !atmel_sha_authenc_is_ready()) {
1618 err = -EPROBE_DEFER;
1619 goto iclk_unprepare;
1620 diff --git a/drivers/crypto/atmel-authenc.h b/drivers/crypto/atmel-authenc.h
1621 index cbd37a2edada..d6de810df44f 100644
1622 --- a/drivers/crypto/atmel-authenc.h
1623 +++ b/drivers/crypto/atmel-authenc.h
1624 @@ -12,7 +12,7 @@
1625 #ifndef __ATMEL_AUTHENC_H__
1626 #define __ATMEL_AUTHENC_H__
1627
1628 -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
1629 +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
1630
1631 #include <crypto/authenc.h>
1632 #include <crypto/hash.h>
1633 diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c
1634 index 84cb8748a795..d32626458e67 100644
1635 --- a/drivers/crypto/atmel-sha.c
1636 +++ b/drivers/crypto/atmel-sha.c
1637 @@ -2212,7 +2212,7 @@ static struct ahash_alg sha_hmac_algs[] = {
1638 },
1639 };
1640
1641 -#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
1642 +#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
1643 /* authenc functions */
1644
1645 static int atmel_sha_authenc_init2(struct atmel_sha_dev *dd);
1646 diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c
1647 index 294debd435b6..991a4425f006 100644
1648 --- a/drivers/crypto/inside-secure/safexcel.c
1649 +++ b/drivers/crypto/inside-secure/safexcel.c
1650 @@ -1120,6 +1120,8 @@ static int safexcel_request_ring_irq(void *pdev, int irqid,
1651 irq_name, irq);
1652 return irq;
1653 }
1654 + } else {
1655 + return -ENXIO;
1656 }
1657
1658 ret = devm_request_threaded_irq(dev, irq, handler,
1659 diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
1660 index 6536fd4bee65..7e5e092a23b3 100644
1661 --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
1662 +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
1663 @@ -72,7 +72,8 @@ static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq)
1664 oi = 0;
1665 oo = 0;
1666 do {
1667 - todo = min3(rx_cnt, ileft, (mi.length - oi) / 4);
1668 + todo = min(rx_cnt, ileft);
1669 + todo = min_t(size_t, todo, (mi.length - oi) / 4);
1670 if (todo) {
1671 ileft -= todo;
1672 writesl(ss->base + SS_RXFIFO, mi.addr + oi, todo);
1673 @@ -87,7 +88,8 @@ static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq)
1674 rx_cnt = SS_RXFIFO_SPACES(spaces);
1675 tx_cnt = SS_TXFIFO_SPACES(spaces);
1676
1677 - todo = min3(tx_cnt, oleft, (mo.length - oo) / 4);
1678 + todo = min(tx_cnt, oleft);
1679 + todo = min_t(size_t, todo, (mo.length - oo) / 4);
1680 if (todo) {
1681 oleft -= todo;
1682 readsl(ss->base + SS_TXFIFO, mo.addr + oo, todo);
1683 @@ -239,7 +241,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
1684 * todo is the number of consecutive 4byte word that we
1685 * can read from current SG
1686 */
1687 - todo = min3(rx_cnt, ileft / 4, (mi.length - oi) / 4);
1688 + todo = min(rx_cnt, ileft / 4);
1689 + todo = min_t(size_t, todo, (mi.length - oi) / 4);
1690 if (todo && !ob) {
1691 writesl(ss->base + SS_RXFIFO, mi.addr + oi,
1692 todo);
1693 @@ -253,8 +256,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
1694 * we need to be able to write all buf in one
1695 * pass, so it is why we min() with rx_cnt
1696 */
1697 - todo = min3(rx_cnt * 4 - ob, ileft,
1698 - mi.length - oi);
1699 + todo = min(rx_cnt * 4 - ob, ileft);
1700 + todo = min_t(size_t, todo, mi.length - oi);
1701 memcpy(buf + ob, mi.addr + oi, todo);
1702 ileft -= todo;
1703 oi += todo;
1704 @@ -274,7 +277,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
1705 spaces = readl(ss->base + SS_FCSR);
1706 rx_cnt = SS_RXFIFO_SPACES(spaces);
1707 tx_cnt = SS_TXFIFO_SPACES(spaces);
1708 - dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
1709 + dev_dbg(ss->dev,
1710 + "%x %u/%zu %u/%u cnt=%u %u/%zu %u/%u cnt=%u %u\n",
1711 mode,
1712 oi, mi.length, ileft, areq->cryptlen, rx_cnt,
1713 oo, mo.length, oleft, areq->cryptlen, tx_cnt, ob);
1714 @@ -282,7 +286,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
1715 if (!tx_cnt)
1716 continue;
1717 /* todo in 4bytes word */
1718 - todo = min3(tx_cnt, oleft / 4, (mo.length - oo) / 4);
1719 + todo = min(tx_cnt, oleft / 4);
1720 + todo = min_t(size_t, todo, (mo.length - oo) / 4);
1721 if (todo) {
1722 readsl(ss->base + SS_TXFIFO, mo.addr + oo, todo);
1723 oleft -= todo * 4;
1724 @@ -308,7 +313,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
1725 * no more than remaining buffer
1726 * no need to test against oleft
1727 */
1728 - todo = min(mo.length - oo, obl - obo);
1729 + todo = min_t(size_t,
1730 + mo.length - oo, obl - obo);
1731 memcpy(mo.addr + oo, bufo + obo, todo);
1732 oleft -= todo;
1733 obo += todo;
1734 diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
1735 index fcffba5ef927..1369c5fa3087 100644
1736 --- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
1737 +++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
1738 @@ -272,8 +272,8 @@ static int sun4i_hash(struct ahash_request *areq)
1739 */
1740 while (op->len < 64 && i < end) {
1741 /* how many bytes we can read from current SG */
1742 - in_r = min3(mi.length - in_i, end - i,
1743 - 64 - op->len);
1744 + in_r = min(end - i, 64 - op->len);
1745 + in_r = min_t(size_t, mi.length - in_i, in_r);
1746 memcpy(op->buf + op->len, mi.addr + in_i, in_r);
1747 op->len += in_r;
1748 i += in_r;
1749 @@ -293,8 +293,8 @@ static int sun4i_hash(struct ahash_request *areq)
1750 }
1751 if (mi.length - in_i > 3 && i < end) {
1752 /* how many bytes we can read from current SG */
1753 - in_r = min3(mi.length - in_i, areq->nbytes - i,
1754 - ((mi.length - in_i) / 4) * 4);
1755 + in_r = min_t(size_t, mi.length - in_i, areq->nbytes - i);
1756 + in_r = min_t(size_t, ((mi.length - in_i) / 4) * 4, in_r);
1757 /* how many bytes we can write in the device*/
1758 todo = min3((u32)(end - i) / 4, rx_cnt, (u32)in_r / 4);
1759 writesl(ss->base + SS_RXFIFO, mi.addr + in_i, todo);
1760 @@ -320,8 +320,8 @@ static int sun4i_hash(struct ahash_request *areq)
1761 if ((areq->nbytes - i) < 64) {
1762 while (i < areq->nbytes && in_i < mi.length && op->len < 64) {
1763 /* how many bytes we can read from current SG */
1764 - in_r = min3(mi.length - in_i, areq->nbytes - i,
1765 - 64 - op->len);
1766 + in_r = min(areq->nbytes - i, 64 - op->len);
1767 + in_r = min_t(size_t, mi.length - in_i, in_r);
1768 memcpy(op->buf + op->len, mi.addr + in_i, in_r);
1769 op->len += in_r;
1770 i += in_r;
1771 diff --git a/drivers/crypto/virtio/virtio_crypto_algs.c b/drivers/crypto/virtio/virtio_crypto_algs.c
1772 index 42d19205166b..673fb29fda53 100644
1773 --- a/drivers/crypto/virtio/virtio_crypto_algs.c
1774 +++ b/drivers/crypto/virtio/virtio_crypto_algs.c
1775 @@ -105,8 +105,6 @@ virtio_crypto_alg_validate_key(int key_len, uint32_t *alg)
1776 *alg = VIRTIO_CRYPTO_CIPHER_AES_CBC;
1777 break;
1778 default:
1779 - pr_err("virtio_crypto: Unsupported key length: %d\n",
1780 - key_len);
1781 return -EINVAL;
1782 }
1783 return 0;
1784 @@ -484,6 +482,11 @@ static int virtio_crypto_ablkcipher_encrypt(struct ablkcipher_request *req)
1785 /* Use the first data virtqueue as default */
1786 struct data_queue *data_vq = &vcrypto->data_vq[0];
1787
1788 + if (!req->nbytes)
1789 + return 0;
1790 + if (req->nbytes % AES_BLOCK_SIZE)
1791 + return -EINVAL;
1792 +
1793 vc_req->dataq = data_vq;
1794 vc_req->alg_cb = virtio_crypto_dataq_sym_callback;
1795 vc_sym_req->ablkcipher_ctx = ctx;
1796 @@ -504,6 +507,11 @@ static int virtio_crypto_ablkcipher_decrypt(struct ablkcipher_request *req)
1797 /* Use the first data virtqueue as default */
1798 struct data_queue *data_vq = &vcrypto->data_vq[0];
1799
1800 + if (!req->nbytes)
1801 + return 0;
1802 + if (req->nbytes % AES_BLOCK_SIZE)
1803 + return -EINVAL;
1804 +
1805 vc_req->dataq = data_vq;
1806 vc_req->alg_cb = virtio_crypto_dataq_sym_callback;
1807 vc_sym_req->ablkcipher_ctx = ctx;
1808 diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
1809 index cab32cfec9c4..709670d2b553 100644
1810 --- a/drivers/crypto/vmx/Makefile
1811 +++ b/drivers/crypto/vmx/Makefile
1812 @@ -3,13 +3,13 @@ obj-$(CONFIG_CRYPTO_DEV_VMX_ENCRYPT) += vmx-crypto.o
1813 vmx-crypto-objs := vmx.o aesp8-ppc.o ghashp8-ppc.o aes.o aes_cbc.o aes_ctr.o aes_xts.o ghash.o
1814
1815 ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
1816 -TARGET := linux-ppc64le
1817 +override flavour := linux-ppc64le
1818 else
1819 -TARGET := linux-ppc64
1820 +override flavour := linux-ppc64
1821 endif
1822
1823 quiet_cmd_perl = PERL $@
1824 - cmd_perl = $(PERL) $(<) $(TARGET) > $(@)
1825 + cmd_perl = $(PERL) $(<) $(flavour) > $(@)
1826
1827 targets += aesp8-ppc.S ghashp8-ppc.S
1828
1829 diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
1830 index c1d4536ae466..cc5e56d752c8 100644
1831 --- a/drivers/edac/amd64_edac.c
1832 +++ b/drivers/edac/amd64_edac.c
1833 @@ -2936,6 +2936,7 @@ static int init_csrows_df(struct mem_ctl_info *mci)
1834 dimm->mtype = pvt->dram_type;
1835 dimm->edac_mode = edac_mode;
1836 dimm->dtype = dev_type;
1837 + dimm->grain = 64;
1838 }
1839 }
1840
1841 @@ -3012,6 +3013,7 @@ static int init_csrows(struct mem_ctl_info *mci)
1842 dimm = csrow->channels[j]->dimm;
1843 dimm->mtype = pvt->dram_type;
1844 dimm->edac_mode = edac_mode;
1845 + dimm->grain = 64;
1846 }
1847 }
1848
1849 diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
1850 index 296e714bf553..523dd56a798c 100644
1851 --- a/drivers/edac/ghes_edac.c
1852 +++ b/drivers/edac/ghes_edac.c
1853 @@ -231,6 +231,7 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
1854 /* Cleans the error report buffer */
1855 memset(e, 0, sizeof (*e));
1856 e->error_count = 1;
1857 + e->grain = 1;
1858 strcpy(e->label, "unknown label");
1859 e->msg = pvt->msg;
1860 e->other_detail = pvt->other_detail;
1861 @@ -326,7 +327,7 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
1862
1863 /* Error grain */
1864 if (mem_err->validation_bits & CPER_MEM_VALID_PA_MASK)
1865 - e->grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK);
1866 + e->grain = ~mem_err->physical_addr_mask + 1;
1867
1868 /* Memory error location, mapped on e->location */
1869 p = e->location;
1870 @@ -442,8 +443,13 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
1871 if (p > pvt->other_detail)
1872 *(p - 1) = '\0';
1873
1874 + /* Sanity-check driver-supplied grain value. */
1875 + if (WARN_ON_ONCE(!e->grain))
1876 + e->grain = 1;
1877 +
1878 + grain_bits = fls_long(e->grain - 1);
1879 +
1880 /* Generate the trace event */
1881 - grain_bits = fls_long(e->grain);
1882 snprintf(pvt->detail_location, sizeof(pvt->detail_location),
1883 "APEI location: %s %s", e->location, e->other_detail);
1884 trace_mc_event(type, e->msg, e->label, e->error_count,
1885 diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c
1886 index dc43847ad2b0..b3d93baf4fc5 100644
1887 --- a/drivers/extcon/extcon-sm5502.c
1888 +++ b/drivers/extcon/extcon-sm5502.c
1889 @@ -65,6 +65,10 @@ struct sm5502_muic_info {
1890 /* Default value of SM5502 register to bring up MUIC device. */
1891 static struct reg_data sm5502_reg_data[] = {
1892 {
1893 + .reg = SM5502_REG_RESET,
1894 + .val = SM5502_REG_RESET_MASK,
1895 + .invert = true,
1896 + }, {
1897 .reg = SM5502_REG_CONTROL,
1898 .val = SM5502_REG_CONTROL_MASK_INT_MASK,
1899 .invert = false,
1900 diff --git a/drivers/extcon/extcon-sm5502.h b/drivers/extcon/extcon-sm5502.h
1901 index 9dbb634d213b..ce1f1ec310c4 100644
1902 --- a/drivers/extcon/extcon-sm5502.h
1903 +++ b/drivers/extcon/extcon-sm5502.h
1904 @@ -237,6 +237,8 @@ enum sm5502_reg {
1905 #define DM_DP_SWITCH_UART ((DM_DP_CON_SWITCH_UART <<SM5502_REG_MANUAL_SW1_DP_SHIFT) \
1906 | (DM_DP_CON_SWITCH_UART <<SM5502_REG_MANUAL_SW1_DM_SHIFT))
1907
1908 +#define SM5502_REG_RESET_MASK (0x1)
1909 +
1910 /* SM5502 Interrupts */
1911 enum sm5502_irq {
1912 /* INT1 */
1913 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
1914 index e98bbf8e56d9..34d41f67b54d 100644
1915 --- a/drivers/firmware/efi/efi.c
1916 +++ b/drivers/firmware/efi/efi.c
1917 @@ -970,6 +970,24 @@ static int __init efi_memreserve_map_root(void)
1918 return 0;
1919 }
1920
1921 +static int efi_mem_reserve_iomem(phys_addr_t addr, u64 size)
1922 +{
1923 + struct resource *res, *parent;
1924 +
1925 + res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
1926 + if (!res)
1927 + return -ENOMEM;
1928 +
1929 + res->name = "reserved";
1930 + res->flags = IORESOURCE_MEM;
1931 + res->start = addr;
1932 + res->end = addr + size - 1;
1933 +
1934 + /* we expect a conflict with a 'System RAM' region */
1935 + parent = request_resource_conflict(&iomem_resource, res);
1936 + return parent ? request_resource(parent, res) : 0;
1937 +}
1938 +
1939 int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size)
1940 {
1941 struct linux_efi_memreserve *rsv;
1942 @@ -994,7 +1012,7 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size)
1943 rsv->entry[index].size = size;
1944
1945 memunmap(rsv);
1946 - return 0;
1947 + return efi_mem_reserve_iomem(addr, size);
1948 }
1949 memunmap(rsv);
1950 }
1951 @@ -1004,6 +1022,12 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size)
1952 if (!rsv)
1953 return -ENOMEM;
1954
1955 + rc = efi_mem_reserve_iomem(__pa(rsv), SZ_4K);
1956 + if (rc) {
1957 + free_page((unsigned long)rsv);
1958 + return rc;
1959 + }
1960 +
1961 /*
1962 * The memremap() call above assumes that a linux_efi_memreserve entry
1963 * never crosses a page boundary, so let's ensure that this remains true
1964 @@ -1020,7 +1044,7 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size)
1965 efi_memreserve_root->next = __pa(rsv);
1966 spin_unlock(&efi_mem_reserve_persistent_lock);
1967
1968 - return 0;
1969 + return efi_mem_reserve_iomem(addr, size);
1970 }
1971
1972 static int __init efi_memreserve_root_init(void)
1973 diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
1974 index 1f76740f33b6..9282239b4d95 100644
1975 --- a/drivers/fsi/fsi-core.c
1976 +++ b/drivers/fsi/fsi-core.c
1977 @@ -544,6 +544,31 @@ static int fsi_slave_scan(struct fsi_slave *slave)
1978 return 0;
1979 }
1980
1981 +static unsigned long aligned_access_size(size_t offset, size_t count)
1982 +{
1983 + unsigned long offset_unit, count_unit;
1984 +
1985 + /* Criteria:
1986 + *
1987 + * 1. Access size must be less than or equal to the maximum access
1988 + * width or the highest power-of-two factor of offset
1989 + * 2. Access size must be less than or equal to the amount specified by
1990 + * count
1991 + *
1992 + * The access width is optimal if we can calculate 1 to be strictly
1993 + * equal while still satisfying 2.
1994 + */
1995 +
1996 + /* Find 1 by the bottom bit of offset (with a 4 byte access cap) */
1997 + offset_unit = BIT(__builtin_ctzl(offset | 4));
1998 +
1999 + /* Find 2 by the top bit of count */
2000 + count_unit = BIT(8 * sizeof(unsigned long) - 1 - __builtin_clzl(count));
2001 +
2002 + /* Constrain the maximum access width to the minimum of both criteria */
2003 + return BIT(__builtin_ctzl(offset_unit | count_unit));
2004 +}
2005 +
2006 static ssize_t fsi_slave_sysfs_raw_read(struct file *file,
2007 struct kobject *kobj, struct bin_attribute *attr, char *buf,
2008 loff_t off, size_t count)
2009 @@ -559,8 +584,7 @@ static ssize_t fsi_slave_sysfs_raw_read(struct file *file,
2010 return -EINVAL;
2011
2012 for (total_len = 0; total_len < count; total_len += read_len) {
2013 - read_len = min_t(size_t, count, 4);
2014 - read_len -= off & 0x3;
2015 + read_len = aligned_access_size(off, count - total_len);
2016
2017 rc = fsi_slave_read(slave, off, buf + total_len, read_len);
2018 if (rc)
2019 @@ -587,8 +611,7 @@ static ssize_t fsi_slave_sysfs_raw_write(struct file *file,
2020 return -EINVAL;
2021
2022 for (total_len = 0; total_len < count; total_len += write_len) {
2023 - write_len = min_t(size_t, count, 4);
2024 - write_len -= off & 0x3;
2025 + write_len = aligned_access_size(off, count - total_len);
2026
2027 rc = fsi_slave_write(slave, off, buf + total_len, write_len);
2028 if (rc)
2029 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
2030 index 5652cc72ed3a..81842ba8cd75 100644
2031 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
2032 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
2033 @@ -859,6 +859,9 @@ static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data)
2034 struct amdgpu_device *adev = dev->dev_private;
2035 int r = 0, i;
2036
2037 + /* Avoid accidently unparking the sched thread during GPU reset */
2038 + mutex_lock(&adev->lock_reset);
2039 +
2040 /* hold on the scheduler */
2041 for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
2042 struct amdgpu_ring *ring = adev->rings[i];
2043 @@ -884,6 +887,8 @@ static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data)
2044 kthread_unpark(ring->sched.thread);
2045 }
2046
2047 + mutex_unlock(&adev->lock_reset);
2048 +
2049 return 0;
2050 }
2051
2052 @@ -1036,6 +1041,9 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)
2053 if (!fences)
2054 return -ENOMEM;
2055
2056 + /* Avoid accidently unparking the sched thread during GPU reset */
2057 + mutex_lock(&adev->lock_reset);
2058 +
2059 /* stop the scheduler */
2060 kthread_park(ring->sched.thread);
2061
2062 @@ -1075,6 +1083,8 @@ failure:
2063 /* restart the scheduler */
2064 kthread_unpark(ring->sched.thread);
2065
2066 + mutex_unlock(&adev->lock_reset);
2067 +
2068 ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched);
2069
2070 if (fences)
2071 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
2072 index b66d29d5ffa2..b158230af8db 100644
2073 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
2074 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
2075 @@ -138,6 +138,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
2076 }
2077
2078 dma_fence_put(fence);
2079 + fence = NULL;
2080
2081 r = amdgpu_bo_kmap(vram_obj, &vram_map);
2082 if (r) {
2083 @@ -183,6 +184,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
2084 }
2085
2086 dma_fence_put(fence);
2087 + fence = NULL;
2088
2089 r = amdgpu_bo_kmap(gtt_obj[i], &gtt_map);
2090 if (r) {
2091 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
2092 index 77674a7b9616..91899d28fa72 100644
2093 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
2094 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
2095 @@ -170,7 +170,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,
2096 __field(unsigned int, context)
2097 __field(unsigned int, seqno)
2098 __field(struct dma_fence *, fence)
2099 - __field(char *, ring_name)
2100 + __string(ring, to_amdgpu_ring(job->base.sched)->name)
2101 __field(u32, num_ibs)
2102 ),
2103
2104 @@ -179,12 +179,12 @@ TRACE_EVENT(amdgpu_cs_ioctl,
2105 __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
2106 __entry->context = job->base.s_fence->finished.context;
2107 __entry->seqno = job->base.s_fence->finished.seqno;
2108 - __entry->ring_name = to_amdgpu_ring(job->base.sched)->name;
2109 + __assign_str(ring, to_amdgpu_ring(job->base.sched)->name)
2110 __entry->num_ibs = job->num_ibs;
2111 ),
2112 TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
2113 __entry->sched_job_id, __get_str(timeline), __entry->context,
2114 - __entry->seqno, __entry->ring_name, __entry->num_ibs)
2115 + __entry->seqno, __get_str(ring), __entry->num_ibs)
2116 );
2117
2118 TRACE_EVENT(amdgpu_sched_run_job,
2119 @@ -195,7 +195,7 @@ TRACE_EVENT(amdgpu_sched_run_job,
2120 __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
2121 __field(unsigned int, context)
2122 __field(unsigned int, seqno)
2123 - __field(char *, ring_name)
2124 + __string(ring, to_amdgpu_ring(job->base.sched)->name)
2125 __field(u32, num_ibs)
2126 ),
2127
2128 @@ -204,12 +204,12 @@ TRACE_EVENT(amdgpu_sched_run_job,
2129 __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
2130 __entry->context = job->base.s_fence->finished.context;
2131 __entry->seqno = job->base.s_fence->finished.seqno;
2132 - __entry->ring_name = to_amdgpu_ring(job->base.sched)->name;
2133 + __assign_str(ring, to_amdgpu_ring(job->base.sched)->name)
2134 __entry->num_ibs = job->num_ibs;
2135 ),
2136 TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
2137 __entry->sched_job_id, __get_str(timeline), __entry->context,
2138 - __entry->seqno, __entry->ring_name, __entry->num_ibs)
2139 + __entry->seqno, __get_str(ring), __entry->num_ibs)
2140 );
2141
2142
2143 @@ -468,7 +468,7 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
2144 TP_PROTO(struct amdgpu_job *sched_job, struct dma_fence *fence),
2145 TP_ARGS(sched_job, fence),
2146 TP_STRUCT__entry(
2147 - __field(const char *,name)
2148 + __string(ring, sched_job->base.sched->name);
2149 __field(uint64_t, id)
2150 __field(struct dma_fence *, fence)
2151 __field(uint64_t, ctx)
2152 @@ -476,14 +476,14 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
2153 ),
2154
2155 TP_fast_assign(
2156 - __entry->name = sched_job->base.sched->name;
2157 + __assign_str(ring, sched_job->base.sched->name)
2158 __entry->id = sched_job->base.id;
2159 __entry->fence = fence;
2160 __entry->ctx = fence->context;
2161 __entry->seqno = fence->seqno;
2162 ),
2163 TP_printk("job ring=%s, id=%llu, need pipe sync to fence=%p, context=%llu, seq=%u",
2164 - __entry->name, __entry->id,
2165 + __get_str(ring), __entry->id,
2166 __entry->fence, __entry->ctx,
2167 __entry->seqno)
2168 );
2169 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
2170 index 5251352f5922..c7514f743409 100644
2171 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
2172 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
2173 @@ -1034,10 +1034,8 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_
2174 id->oa_base != job->oa_base ||
2175 id->oa_size != job->oa_size);
2176 bool vm_flush_needed = job->vm_needs_flush;
2177 - bool pasid_mapping_needed = id->pasid != job->pasid ||
2178 - !id->pasid_mapping ||
2179 - !dma_fence_is_signaled(id->pasid_mapping);
2180 struct dma_fence *fence = NULL;
2181 + bool pasid_mapping_needed = false;
2182 unsigned patch_offset = 0;
2183 int r;
2184
2185 @@ -1047,6 +1045,12 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_
2186 pasid_mapping_needed = true;
2187 }
2188
2189 + mutex_lock(&id_mgr->lock);
2190 + if (id->pasid != job->pasid || !id->pasid_mapping ||
2191 + !dma_fence_is_signaled(id->pasid_mapping))
2192 + pasid_mapping_needed = true;
2193 + mutex_unlock(&id_mgr->lock);
2194 +
2195 gds_switch_needed &= !!ring->funcs->emit_gds_switch;
2196 vm_flush_needed &= !!ring->funcs->emit_vm_flush &&
2197 job->vm_pd_addr != AMDGPU_BO_INVALID_OFFSET;
2198 @@ -1086,9 +1090,11 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_
2199 }
2200
2201 if (pasid_mapping_needed) {
2202 + mutex_lock(&id_mgr->lock);
2203 id->pasid = job->pasid;
2204 dma_fence_put(id->pasid_mapping);
2205 id->pasid_mapping = dma_fence_get(fence);
2206 + mutex_unlock(&id_mgr->lock);
2207 }
2208 dma_fence_put(fence);
2209
2210 diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
2211 index 97cf0b536873..c9ba2ec6d038 100644
2212 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
2213 +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
2214 @@ -2930,7 +2930,8 @@ static void gfx_v9_0_init_pg(struct amdgpu_device *adev)
2215 * And it's needed by gfxoff feature.
2216 */
2217 if (adev->gfx.rlc.is_rlc_v2_1) {
2218 - gfx_v9_1_init_rlc_save_restore_list(adev);
2219 + if (adev->asic_type == CHIP_VEGA12)
2220 + gfx_v9_1_init_rlc_save_restore_list(adev);
2221 gfx_v9_0_enable_save_restore_machine(adev);
2222 }
2223
2224 diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
2225 index 10166104b8a3..d483684db95b 100644
2226 --- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
2227 +++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
2228 @@ -398,6 +398,34 @@ static bool psp_v11_0_support_vmr_ring(struct psp_context *psp)
2229 return false;
2230 }
2231
2232 +static int psp_v11_0_ring_stop(struct psp_context *psp,
2233 + enum psp_ring_type ring_type)
2234 +{
2235 + int ret = 0;
2236 + struct amdgpu_device *adev = psp->adev;
2237 +
2238 + /* Write the ring destroy command*/
2239 + if (psp_v11_0_support_vmr_ring(psp))
2240 + WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_101,
2241 + GFX_CTRL_CMD_ID_DESTROY_GPCOM_RING);
2242 + else
2243 + WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_64,
2244 + GFX_CTRL_CMD_ID_DESTROY_RINGS);
2245 +
2246 + /* there might be handshake issue with hardware which needs delay */
2247 + mdelay(20);
2248 +
2249 + /* Wait for response flag (bit 31) */
2250 + if (psp_v11_0_support_vmr_ring(psp))
2251 + ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_101),
2252 + 0x80000000, 0x80000000, false);
2253 + else
2254 + ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64),
2255 + 0x80000000, 0x80000000, false);
2256 +
2257 + return ret;
2258 +}
2259 +
2260 static int psp_v11_0_ring_create(struct psp_context *psp,
2261 enum psp_ring_type ring_type)
2262 {
2263 @@ -407,6 +435,12 @@ static int psp_v11_0_ring_create(struct psp_context *psp,
2264 struct amdgpu_device *adev = psp->adev;
2265
2266 if (psp_v11_0_support_vmr_ring(psp)) {
2267 + ret = psp_v11_0_ring_stop(psp, ring_type);
2268 + if (ret) {
2269 + DRM_ERROR("psp_v11_0_ring_stop_sriov failed!\n");
2270 + return ret;
2271 + }
2272 +
2273 /* Write low address of the ring to C2PMSG_102 */
2274 psp_ring_reg = lower_32_bits(ring->ring_mem_mc_addr);
2275 WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_102, psp_ring_reg);
2276 @@ -451,33 +485,6 @@ static int psp_v11_0_ring_create(struct psp_context *psp,
2277 return ret;
2278 }
2279
2280 -static int psp_v11_0_ring_stop(struct psp_context *psp,
2281 - enum psp_ring_type ring_type)
2282 -{
2283 - int ret = 0;
2284 - struct amdgpu_device *adev = psp->adev;
2285 -
2286 - /* Write the ring destroy command*/
2287 - if (psp_v11_0_support_vmr_ring(psp))
2288 - WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_101,
2289 - GFX_CTRL_CMD_ID_DESTROY_GPCOM_RING);
2290 - else
2291 - WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_64,
2292 - GFX_CTRL_CMD_ID_DESTROY_RINGS);
2293 -
2294 - /* there might be handshake issue with hardware which needs delay */
2295 - mdelay(20);
2296 -
2297 - /* Wait for response flag (bit 31) */
2298 - if (psp_v11_0_support_vmr_ring(psp))
2299 - ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_101),
2300 - 0x80000000, 0x80000000, false);
2301 - else
2302 - ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64),
2303 - 0x80000000, 0x80000000, false);
2304 -
2305 - return ret;
2306 -}
2307
2308 static int psp_v11_0_ring_destroy(struct psp_context *psp,
2309 enum psp_ring_type ring_type)
2310 diff --git a/drivers/gpu/drm/amd/amdgpu/si_ih.c b/drivers/gpu/drm/amd/amdgpu/si_ih.c
2311 index 57bb5f9e08b2..88ae27a5a03d 100644
2312 --- a/drivers/gpu/drm/amd/amdgpu/si_ih.c
2313 +++ b/drivers/gpu/drm/amd/amdgpu/si_ih.c
2314 @@ -64,7 +64,8 @@ static int si_ih_irq_init(struct amdgpu_device *adev)
2315 u32 interrupt_cntl, ih_cntl, ih_rb_cntl;
2316
2317 si_ih_disable_interrupts(adev);
2318 - WREG32(INTERRUPT_CNTL2, adev->irq.ih.gpu_addr >> 8);
2319 + /* set dummy read address to dummy page address */
2320 + WREG32(INTERRUPT_CNTL2, adev->dummy_page_addr >> 8);
2321 interrupt_cntl = RREG32(INTERRUPT_CNTL);
2322 interrupt_cntl &= ~IH_DUMMY_RD_OVERRIDE;
2323 interrupt_cntl &= ~IH_REQ_NONSNOOP_EN;
2324 diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
2325 index d985e31fcc1e..f335f73919d1 100644
2326 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
2327 +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
2328 @@ -1676,7 +1676,8 @@ static int allocate_hiq_sdma_mqd(struct device_queue_manager *dqm)
2329 struct kfd_dev *dev = dqm->dev;
2330 struct kfd_mem_obj *mem_obj = &dqm->hiq_sdma_mqd;
2331 uint32_t size = dqm->mqd_mgrs[KFD_MQD_TYPE_SDMA]->mqd_size *
2332 - dev->device_info->num_sdma_engines *
2333 + (dev->device_info->num_sdma_engines +
2334 + dev->device_info->num_xgmi_sdma_engines) *
2335 dev->device_info->num_sdma_queues_per_engine +
2336 dqm->mqd_mgrs[KFD_MQD_TYPE_HIQ]->mqd_size;
2337
2338 diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
2339 index c56ac47cd318..bc47f6a44456 100644
2340 --- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
2341 +++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
2342 @@ -62,6 +62,11 @@ int kfd_interrupt_init(struct kfd_dev *kfd)
2343 }
2344
2345 kfd->ih_wq = alloc_workqueue("KFD IH", WQ_HIGHPRI, 1);
2346 + if (unlikely(!kfd->ih_wq)) {
2347 + kfifo_free(&kfd->ih_fifo);
2348 + dev_err(kfd_chardev(), "Failed to allocate KFD IH workqueue\n");
2349 + return -ENOMEM;
2350 + }
2351 spin_lock_init(&kfd->interrupt_lock);
2352
2353 INIT_WORK(&kfd->interrupt_work, interrupt_wq);
2354 diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
2355 index 4139f129eafb..4e9c15c409ba 100644
2356 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
2357 +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
2358 @@ -940,6 +940,11 @@ static int dm_late_init(void *handle)
2359 params.backlight_lut_array_size = 16;
2360 params.backlight_lut_array = linear_lut;
2361
2362 + /* Min backlight level after ABM reduction, Don't allow below 1%
2363 + * 0xFFFF x 0.01 = 0x28F
2364 + */
2365 + params.min_abm_backlight = 0x28F;
2366 +
2367 /* todo will enable for navi10 */
2368 if (adev->asic_type <= CHIP_RAVEN) {
2369 ret = dmcu_load_iram(dmcu, params);
2370 diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
2371 index 3e8ac303bd52..23ec283eb07b 100644
2372 --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
2373 +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
2374 @@ -320,6 +320,8 @@ void dcn2_update_clocks_fpga(struct clk_mgr *clk_mgr,
2375 struct dc_state *context,
2376 bool safe_to_lower)
2377 {
2378 + struct clk_mgr_internal *clk_mgr_int = TO_CLK_MGR_INTERNAL(clk_mgr);
2379 +
2380 struct dc_clocks *new_clocks = &context->bw_ctx.bw.dcn.clk;
2381 /* Min fclk = 1.2GHz since all the extra scemi logic seems to run off of it */
2382 int fclk_adj = new_clocks->fclk_khz > 1200000 ? new_clocks->fclk_khz : 1200000;
2383 @@ -357,14 +359,18 @@ void dcn2_update_clocks_fpga(struct clk_mgr *clk_mgr,
2384 clk_mgr->clks.dispclk_khz = new_clocks->dispclk_khz;
2385 }
2386
2387 - /* Both fclk and dppclk ref are run on the same scemi clock so we
2388 - * need to keep the same value for both
2389 + /* Both fclk and ref_dppclk run on the same scemi clock.
2390 + * So take the higher value since the DPP DTO is typically programmed
2391 + * such that max dppclk is 1:1 with ref_dppclk.
2392 */
2393 if (clk_mgr->clks.fclk_khz > clk_mgr->clks.dppclk_khz)
2394 clk_mgr->clks.dppclk_khz = clk_mgr->clks.fclk_khz;
2395 if (clk_mgr->clks.dppclk_khz > clk_mgr->clks.fclk_khz)
2396 clk_mgr->clks.fclk_khz = clk_mgr->clks.dppclk_khz;
2397
2398 + // Both fclk and ref_dppclk run on the same scemi clock.
2399 + clk_mgr_int->dccg->ref_dppclk = clk_mgr->clks.fclk_khz;
2400 +
2401 dm_set_dcn_clocks(clk_mgr->ctx, &clk_mgr->clks);
2402 }
2403
2404 diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
2405 index 50984c1811bb..468c6bb0e311 100644
2406 --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
2407 +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
2408 @@ -33,7 +33,7 @@
2409 #include "mp/mp_12_0_0_sh_mask.h"
2410
2411 #define REG(reg_name) \
2412 - (MP1_BASE.instance[0].segment[mm ## reg_name ## _BASE_IDX] + mm ## reg_name)
2413 + (MP0_BASE.instance[0].segment[mm ## reg_name ## _BASE_IDX] + mm ## reg_name)
2414
2415 #define FN(reg_name, field) \
2416 FD(reg_name##__##field)
2417 diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
2418 index ca20b150afcc..067f5579f452 100644
2419 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
2420 +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
2421 @@ -2169,8 +2169,10 @@ static void disable_link(struct dc_link *link, enum signal_type signal)
2422 dp_set_fec_ready(link, false);
2423 }
2424 #endif
2425 - } else
2426 - link->link_enc->funcs->disable_output(link->link_enc, signal);
2427 + } else {
2428 + if (signal != SIGNAL_TYPE_VIRTUAL)
2429 + link->link_enc->funcs->disable_output(link->link_enc, signal);
2430 + }
2431
2432 if (signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
2433 /* MST disable link only when no stream use the link */
2434 @@ -2217,7 +2219,7 @@ static bool dp_active_dongle_validate_timing(
2435 break;
2436 }
2437
2438 - if (dongle_caps->dongle_type != DISPLAY_DONGLE_DP_HDMI_CONVERTER ||
2439 + if (dpcd_caps->dongle_type != DISPLAY_DONGLE_DP_HDMI_CONVERTER ||
2440 dongle_caps->extendedCapValid == false)
2441 return true;
2442
2443 @@ -2767,6 +2769,15 @@ void core_link_enable_stream(
2444 CONTROLLER_DP_TEST_PATTERN_VIDEOMODE,
2445 COLOR_DEPTH_UNDEFINED);
2446
2447 + /* This second call is needed to reconfigure the DIG
2448 + * as a workaround for the incorrect value being applied
2449 + * from transmitter control.
2450 + */
2451 + if (!dc_is_virtual_signal(pipe_ctx->stream->signal))
2452 + stream->link->link_enc->funcs->setup(
2453 + stream->link->link_enc,
2454 + pipe_ctx->stream->signal);
2455 +
2456 #ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
2457 if (pipe_ctx->stream->timing.flags.DSC) {
2458 if (dc_is_dp_signal(pipe_ctx->stream->signal) ||
2459 diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
2460 index f5742719b5d9..5a583707d198 100644
2461 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
2462 +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
2463 @@ -2545,6 +2545,7 @@ static void get_active_converter_info(
2464 uint8_t data, struct dc_link *link)
2465 {
2466 union dp_downstream_port_present ds_port = { .byte = data };
2467 + memset(&link->dpcd_caps.dongle_caps, 0, sizeof(link->dpcd_caps.dongle_caps));
2468
2469 /* decode converter info*/
2470 if (!ds_port.fields.PORT_PRESENT) {
2471 @@ -2691,6 +2692,7 @@ static void dp_wa_power_up_0010FA(struct dc_link *link, uint8_t *dpcd_data,
2472 * keep receiver powered all the time.*/
2473 case DP_BRANCH_DEVICE_ID_0010FA:
2474 case DP_BRANCH_DEVICE_ID_0080E1:
2475 + case DP_BRANCH_DEVICE_ID_00E04C:
2476 link->wa_flags.dp_keep_receiver_powered = true;
2477 break;
2478
2479 diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c
2480 index 79438c4f1e20..a519dbc5ecb6 100644
2481 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c
2482 +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c
2483 @@ -277,7 +277,8 @@ void dp_retrain_link_dp_test(struct dc_link *link,
2484 if (pipes[i].stream != NULL &&
2485 !pipes[i].top_pipe && !pipes[i].prev_odm_pipe &&
2486 pipes[i].stream->link != NULL &&
2487 - pipes[i].stream_res.stream_enc != NULL) {
2488 + pipes[i].stream_res.stream_enc != NULL &&
2489 + pipes[i].stream->link == link) {
2490 udelay(100);
2491
2492 pipes[i].stream_res.stream_enc->funcs->dp_blank(
2493 diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
2494 index bf1d7bb90e0f..bb09243758fe 100644
2495 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
2496 +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
2497 @@ -423,10 +423,10 @@ bool dc_stream_add_writeback(struct dc *dc,
2498
2499 if (dwb->funcs->is_enabled(dwb)) {
2500 /* writeback pipe already enabled, only need to update */
2501 - dc->hwss.update_writeback(dc, stream_status, wb_info);
2502 + dc->hwss.update_writeback(dc, stream_status, wb_info, dc->current_state);
2503 } else {
2504 /* Enable writeback pipe from scratch*/
2505 - dc->hwss.enable_writeback(dc, stream_status, wb_info);
2506 + dc->hwss.enable_writeback(dc, stream_status, wb_info, dc->current_state);
2507 }
2508 }
2509
2510 diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c b/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c
2511 index 58bd131d5b48..7700a855d77c 100644
2512 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c
2513 +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c
2514 @@ -77,6 +77,9 @@ static bool dce_abm_set_pipe(struct abm *abm, uint32_t controller_id)
2515 /* notifyDMCUMsg */
2516 REG_UPDATE(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 1);
2517
2518 + REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0,
2519 + 1, 80000);
2520 +
2521 return true;
2522 }
2523
2524 diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
2525 index b3ae1c41fc69..937a8ba81160 100644
2526 --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
2527 +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
2528 @@ -1356,7 +1356,8 @@ bool dcn20_update_bandwidth(
2529 static void dcn20_enable_writeback(
2530 struct dc *dc,
2531 const struct dc_stream_status *stream_status,
2532 - struct dc_writeback_info *wb_info)
2533 + struct dc_writeback_info *wb_info,
2534 + struct dc_state *context)
2535 {
2536 struct dwbc *dwb;
2537 struct mcif_wb *mcif_wb;
2538 @@ -1373,7 +1374,7 @@ static void dcn20_enable_writeback(
2539 optc->funcs->set_dwb_source(optc, wb_info->dwb_pipe_inst);
2540 /* set MCIF_WB buffer and arbitration configuration */
2541 mcif_wb->funcs->config_mcif_buf(mcif_wb, &wb_info->mcif_buf_params, wb_info->dwb_params.dest_height);
2542 - mcif_wb->funcs->config_mcif_arb(mcif_wb, &dc->current_state->bw_ctx.bw.dcn.bw_writeback.mcif_wb_arb[wb_info->dwb_pipe_inst]);
2543 + mcif_wb->funcs->config_mcif_arb(mcif_wb, &context->bw_ctx.bw.dcn.bw_writeback.mcif_wb_arb[wb_info->dwb_pipe_inst]);
2544 /* Enable MCIF_WB */
2545 mcif_wb->funcs->enable_mcif(mcif_wb);
2546 /* Enable DWB */
2547 diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c
2548 index 2137e2be2140..dda90995ba93 100644
2549 --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c
2550 +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c
2551 @@ -287,6 +287,10 @@ void optc2_get_optc_source(struct timing_generator *optc,
2552 *num_of_src_opp = 2;
2553 else
2554 *num_of_src_opp = 1;
2555 +
2556 + /* Work around VBIOS not updating OPTC_NUM_OF_INPUT_SEGMENT */
2557 + if (*src_opp_id_1 == 0xf)
2558 + *num_of_src_opp = 1;
2559 }
2560
2561 void optc2_set_dwb_source(struct timing_generator *optc,
2562 diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
2563 index 6b2f2f1a1c9c..78b2cc2e122f 100644
2564 --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
2565 +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
2566 @@ -1765,7 +1765,7 @@ int dcn20_populate_dml_pipes_from_context(
2567 pipe_cnt = i;
2568 continue;
2569 }
2570 - if (!resource_are_streams_timing_synchronizable(
2571 + if (dc->debug.disable_timing_sync || !resource_are_streams_timing_synchronizable(
2572 res_ctx->pipe_ctx[pipe_cnt].stream,
2573 res_ctx->pipe_ctx[i].stream)) {
2574 synchronized_vblank = false;
2575 @@ -2474,6 +2474,7 @@ bool dcn20_fast_validate_bw(
2576 &context->res_ctx, dc->res_pool,
2577 pipe, hsplit_pipe))
2578 goto validate_fail;
2579 + dcn20_build_mapped_resource(dc, context, pipe->stream);
2580 } else
2581 dcn20_split_stream_for_mpc(
2582 &context->res_ctx, dc->res_pool,
2583 @@ -3040,7 +3041,7 @@ static void cap_soc_clocks(
2584 static void update_bounding_box(struct dc *dc, struct _vcs_dpi_soc_bounding_box_st *bb,
2585 struct pp_smu_nv_clock_table *max_clocks, unsigned int *uclk_states, unsigned int num_states)
2586 {
2587 - struct _vcs_dpi_voltage_scaling_st calculated_states[MAX_CLOCK_LIMIT_STATES] = {0};
2588 + struct _vcs_dpi_voltage_scaling_st calculated_states[MAX_CLOCK_LIMIT_STATES];
2589 int i;
2590 int num_calculated_states = 0;
2591 int min_dcfclk = 0;
2592 @@ -3048,6 +3049,8 @@ static void update_bounding_box(struct dc *dc, struct _vcs_dpi_soc_bounding_box_
2593 if (num_states == 0)
2594 return;
2595
2596 + memset(calculated_states, 0, sizeof(calculated_states));
2597 +
2598 if (dc->bb_overrides.min_dcfclk_mhz > 0)
2599 min_dcfclk = dc->bb_overrides.min_dcfclk_mhz;
2600 else
2601 diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
2602 index d1266741763b..f5f6b4a0f0aa 100644
2603 --- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
2604 +++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
2605 @@ -22,6 +22,7 @@
2606 * Authors: AMD
2607 *
2608 */
2609 +#include <linux/delay.h>
2610 #include "dm_services.h"
2611 #include "dcn20/dcn20_hubbub.h"
2612 #include "dcn21_hubbub.h"
2613 @@ -71,30 +72,39 @@ static uint32_t convert_and_clamp(
2614 void dcn21_dchvm_init(struct hubbub *hubbub)
2615 {
2616 struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);
2617 + uint32_t riommu_active;
2618 + int i;
2619
2620 //Init DCHVM block
2621 REG_UPDATE(DCHVM_CTRL0, HOSTVM_INIT_REQ, 1);
2622
2623 //Poll until RIOMMU_ACTIVE = 1
2624 - //TODO: Figure out interval us and retry count
2625 - REG_WAIT(DCHVM_RIOMMU_STAT0, RIOMMU_ACTIVE, 1, 5, 100);
2626 + for (i = 0; i < 100; i++) {
2627 + REG_GET(DCHVM_RIOMMU_STAT0, RIOMMU_ACTIVE, &riommu_active);
2628
2629 - //Reflect the power status of DCHUBBUB
2630 - REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_POWERSTATUS, 1);
2631 + if (riommu_active)
2632 + break;
2633 + else
2634 + udelay(5);
2635 + }
2636 +
2637 + if (riommu_active) {
2638 + //Reflect the power status of DCHUBBUB
2639 + REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_POWERSTATUS, 1);
2640
2641 - //Start rIOMMU prefetching
2642 - REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_PREFETCH_REQ, 1);
2643 + //Start rIOMMU prefetching
2644 + REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_PREFETCH_REQ, 1);
2645
2646 - // Enable dynamic clock gating
2647 - REG_UPDATE_4(DCHVM_CLK_CTRL,
2648 - HVM_DISPCLK_R_GATE_DIS, 0,
2649 - HVM_DISPCLK_G_GATE_DIS, 0,
2650 - HVM_DCFCLK_R_GATE_DIS, 0,
2651 - HVM_DCFCLK_G_GATE_DIS, 0);
2652 + // Enable dynamic clock gating
2653 + REG_UPDATE_4(DCHVM_CLK_CTRL,
2654 + HVM_DISPCLK_R_GATE_DIS, 0,
2655 + HVM_DISPCLK_G_GATE_DIS, 0,
2656 + HVM_DCFCLK_R_GATE_DIS, 0,
2657 + HVM_DCFCLK_G_GATE_DIS, 0);
2658
2659 - //Poll until HOSTVM_PREFETCH_DONE = 1
2660 - //TODO: Figure out interval us and retry count
2661 - REG_WAIT(DCHVM_RIOMMU_STAT0, HOSTVM_PREFETCH_DONE, 1, 5, 100);
2662 + //Poll until HOSTVM_PREFETCH_DONE = 1
2663 + REG_WAIT(DCHVM_RIOMMU_STAT0, HOSTVM_PREFETCH_DONE, 1, 5, 100);
2664 + }
2665 }
2666
2667 static int hubbub21_init_dchub(struct hubbub *hubbub,
2668 diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h
2669 index 3a938cd414ea..f6cc2d6f576d 100644
2670 --- a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h
2671 +++ b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h
2672 @@ -321,10 +321,12 @@ struct hw_sequencer_funcs {
2673 struct dc_state *context);
2674 void (*update_writeback)(struct dc *dc,
2675 const struct dc_stream_status *stream_status,
2676 - struct dc_writeback_info *wb_info);
2677 + struct dc_writeback_info *wb_info,
2678 + struct dc_state *context);
2679 void (*enable_writeback)(struct dc *dc,
2680 const struct dc_stream_status *stream_status,
2681 - struct dc_writeback_info *wb_info);
2682 + struct dc_writeback_info *wb_info,
2683 + struct dc_state *context);
2684 void (*disable_writeback)(struct dc *dc,
2685 unsigned int dwb_pipe_inst);
2686 #endif
2687 diff --git a/drivers/gpu/drm/amd/display/include/ddc_service_types.h b/drivers/gpu/drm/amd/display/include/ddc_service_types.h
2688 index 18961707db23..9ad49da50a17 100644
2689 --- a/drivers/gpu/drm/amd/display/include/ddc_service_types.h
2690 +++ b/drivers/gpu/drm/amd/display/include/ddc_service_types.h
2691 @@ -31,6 +31,8 @@
2692 #define DP_BRANCH_DEVICE_ID_0022B9 0x0022B9
2693 #define DP_BRANCH_DEVICE_ID_00001A 0x00001A
2694 #define DP_BRANCH_DEVICE_ID_0080E1 0x0080e1
2695 +#define DP_BRANCH_DEVICE_ID_90CC24 0x90CC24
2696 +#define DP_BRANCH_DEVICE_ID_00E04C 0x00E04C
2697
2698 enum ddc_result {
2699 DDC_RESULT_UNKNOWN = 0,
2700 diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
2701 index ec70c9b12e1a..0978c698f0f8 100644
2702 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
2703 +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
2704 @@ -743,6 +743,10 @@ void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
2705 nominal_field_rate_in_uhz =
2706 mod_freesync_calc_nominal_field_rate(stream);
2707
2708 + /* Rounded to the nearest Hz */
2709 + nominal_field_rate_in_uhz = 1000000ULL *
2710 + div_u64(nominal_field_rate_in_uhz + 500000, 1000000);
2711 +
2712 min_refresh_in_uhz = in_config->min_refresh_in_uhz;
2713 max_refresh_in_uhz = in_config->max_refresh_in_uhz;
2714
2715 @@ -996,14 +1000,13 @@ unsigned long long mod_freesync_calc_nominal_field_rate(
2716 const struct dc_stream_state *stream)
2717 {
2718 unsigned long long nominal_field_rate_in_uhz = 0;
2719 + unsigned int total = stream->timing.h_total * stream->timing.v_total;
2720
2721 - /* Calculate nominal field rate for stream */
2722 + /* Calculate nominal field rate for stream, rounded up to nearest integer */
2723 nominal_field_rate_in_uhz = stream->timing.pix_clk_100hz / 10;
2724 nominal_field_rate_in_uhz *= 1000ULL * 1000ULL * 1000ULL;
2725 - nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz,
2726 - stream->timing.h_total);
2727 - nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz,
2728 - stream->timing.v_total);
2729 +
2730 + nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz, total);
2731
2732 return nominal_field_rate_in_uhz;
2733 }
2734 diff --git a/drivers/gpu/drm/amd/display/modules/power/power_helpers.c b/drivers/gpu/drm/amd/display/modules/power/power_helpers.c
2735 index 05e2be856037..ba1aafe40512 100644
2736 --- a/drivers/gpu/drm/amd/display/modules/power/power_helpers.c
2737 +++ b/drivers/gpu/drm/amd/display/modules/power/power_helpers.c
2738 @@ -115,7 +115,7 @@ static const struct abm_parameters * const abm_settings[] = {
2739 /* NOTE: iRAM is 256B in size */
2740 struct iram_table_v_2 {
2741 /* flags */
2742 - uint16_t flags; /* 0x00 U16 */
2743 + uint16_t min_abm_backlight; /* 0x00 U16 */
2744
2745 /* parameters for ABM2.0 algorithm */
2746 uint8_t min_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; /* 0x02 U0.8 */
2747 @@ -140,10 +140,10 @@ struct iram_table_v_2 {
2748
2749 /* For reading PSR State directly from IRAM */
2750 uint8_t psr_state; /* 0xf0 */
2751 - uint8_t dmcu_mcp_interface_version; /* 0xf1 */
2752 - uint8_t dmcu_abm_feature_version; /* 0xf2 */
2753 - uint8_t dmcu_psr_feature_version; /* 0xf3 */
2754 - uint16_t dmcu_version; /* 0xf4 */
2755 + uint8_t dmcu_mcp_interface_version; /* 0xf1 */
2756 + uint8_t dmcu_abm_feature_version; /* 0xf2 */
2757 + uint8_t dmcu_psr_feature_version; /* 0xf3 */
2758 + uint16_t dmcu_version; /* 0xf4 */
2759 uint8_t dmcu_state; /* 0xf6 */
2760
2761 uint16_t blRampReduction; /* 0xf7 */
2762 @@ -164,42 +164,43 @@ struct iram_table_v_2_2 {
2763 uint8_t max_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; /* 0x16 U0.8 */
2764 uint8_t bright_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; /* 0x2a U2.6 */
2765 uint8_t dark_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; /* 0x3e U2.6 */
2766 - uint8_t hybrid_factor[NUM_AGGR_LEVEL]; /* 0x52 U0.8 */
2767 - uint8_t contrast_factor[NUM_AGGR_LEVEL]; /* 0x56 U0.8 */
2768 - uint8_t deviation_gain[NUM_AGGR_LEVEL]; /* 0x5a U0.8 */
2769 - uint8_t iir_curve[NUM_AMBI_LEVEL]; /* 0x5e U0.8 */
2770 - uint8_t min_knee[NUM_AGGR_LEVEL]; /* 0x63 U0.8 */
2771 - uint8_t max_knee[NUM_AGGR_LEVEL]; /* 0x67 U0.8 */
2772 - uint8_t pad[21]; /* 0x6b U0.8 */
2773 + uint8_t hybrid_factor[NUM_AGGR_LEVEL]; /* 0x52 U0.8 */
2774 + uint8_t contrast_factor[NUM_AGGR_LEVEL]; /* 0x56 U0.8 */
2775 + uint8_t deviation_gain[NUM_AGGR_LEVEL]; /* 0x5a U0.8 */
2776 + uint8_t iir_curve[NUM_AMBI_LEVEL]; /* 0x5e U0.8 */
2777 + uint8_t min_knee[NUM_AGGR_LEVEL]; /* 0x63 U0.8 */
2778 + uint8_t max_knee[NUM_AGGR_LEVEL]; /* 0x67 U0.8 */
2779 + uint16_t min_abm_backlight; /* 0x6b U16 */
2780 + uint8_t pad[19]; /* 0x6d U0.8 */
2781
2782 /* parameters for crgb conversion */
2783 - uint16_t crgb_thresh[NUM_POWER_FN_SEGS]; /* 0x80 U3.13 */
2784 - uint16_t crgb_offset[NUM_POWER_FN_SEGS]; /* 0x90 U1.15 */
2785 - uint16_t crgb_slope[NUM_POWER_FN_SEGS]; /* 0xa0 U4.12 */
2786 + uint16_t crgb_thresh[NUM_POWER_FN_SEGS]; /* 0x80 U3.13 */
2787 + uint16_t crgb_offset[NUM_POWER_FN_SEGS]; /* 0x90 U1.15 */
2788 + uint16_t crgb_slope[NUM_POWER_FN_SEGS]; /* 0xa0 U4.12 */
2789
2790 /* parameters for custom curve */
2791 /* thresholds for brightness --> backlight */
2792 - uint16_t backlight_thresholds[NUM_BL_CURVE_SEGS]; /* 0xb0 U16.0 */
2793 + uint16_t backlight_thresholds[NUM_BL_CURVE_SEGS]; /* 0xb0 U16.0 */
2794 /* offsets for brightness --> backlight */
2795 - uint16_t backlight_offsets[NUM_BL_CURVE_SEGS]; /* 0xd0 U16.0 */
2796 + uint16_t backlight_offsets[NUM_BL_CURVE_SEGS]; /* 0xd0 U16.0 */
2797
2798 /* For reading PSR State directly from IRAM */
2799 - uint8_t psr_state; /* 0xf0 */
2800 - uint8_t dmcu_mcp_interface_version; /* 0xf1 */
2801 - uint8_t dmcu_abm_feature_version; /* 0xf2 */
2802 - uint8_t dmcu_psr_feature_version; /* 0xf3 */
2803 - uint16_t dmcu_version; /* 0xf4 */
2804 - uint8_t dmcu_state; /* 0xf6 */
2805 -
2806 - uint8_t dummy1; /* 0xf7 */
2807 - uint8_t dummy2; /* 0xf8 */
2808 - uint8_t dummy3; /* 0xf9 */
2809 - uint8_t dummy4; /* 0xfa */
2810 - uint8_t dummy5; /* 0xfb */
2811 - uint8_t dummy6; /* 0xfc */
2812 - uint8_t dummy7; /* 0xfd */
2813 - uint8_t dummy8; /* 0xfe */
2814 - uint8_t dummy9; /* 0xff */
2815 + uint8_t psr_state; /* 0xf0 */
2816 + uint8_t dmcu_mcp_interface_version; /* 0xf1 */
2817 + uint8_t dmcu_abm_feature_version; /* 0xf2 */
2818 + uint8_t dmcu_psr_feature_version; /* 0xf3 */
2819 + uint16_t dmcu_version; /* 0xf4 */
2820 + uint8_t dmcu_state; /* 0xf6 */
2821 +
2822 + uint8_t dummy1; /* 0xf7 */
2823 + uint8_t dummy2; /* 0xf8 */
2824 + uint8_t dummy3; /* 0xf9 */
2825 + uint8_t dummy4; /* 0xfa */
2826 + uint8_t dummy5; /* 0xfb */
2827 + uint8_t dummy6; /* 0xfc */
2828 + uint8_t dummy7; /* 0xfd */
2829 + uint8_t dummy8; /* 0xfe */
2830 + uint8_t dummy9; /* 0xff */
2831 };
2832 #pragma pack(pop)
2833
2834 @@ -271,7 +272,8 @@ void fill_iram_v_2(struct iram_table_v_2 *ram_table, struct dmcu_iram_parameters
2835 {
2836 unsigned int set = params.set;
2837
2838 - ram_table->flags = 0x0;
2839 + ram_table->min_abm_backlight =
2840 + cpu_to_be16(params.min_abm_backlight);
2841 ram_table->deviation_gain = 0xb3;
2842
2843 ram_table->blRampReduction =
2844 @@ -445,6 +447,9 @@ void fill_iram_v_2_2(struct iram_table_v_2_2 *ram_table, struct dmcu_iram_parame
2845
2846 ram_table->flags = 0x0;
2847
2848 + ram_table->min_abm_backlight =
2849 + cpu_to_be16(params.min_abm_backlight);
2850 +
2851 ram_table->deviation_gain[0] = 0xb3;
2852 ram_table->deviation_gain[1] = 0xa8;
2853 ram_table->deviation_gain[2] = 0x98;
2854 @@ -588,6 +593,10 @@ void fill_iram_v_2_3(struct iram_table_v_2_2 *ram_table, struct dmcu_iram_parame
2855 unsigned int set = params.set;
2856
2857 ram_table->flags = 0x0;
2858 +
2859 + ram_table->min_abm_backlight =
2860 + cpu_to_be16(params.min_abm_backlight);
2861 +
2862 for (i = 0; i < NUM_AGGR_LEVEL; i++) {
2863 ram_table->hybrid_factor[i] = abm_settings[set][i].brightness_gain;
2864 ram_table->contrast_factor[i] = abm_settings[set][i].contrast_factor;
2865 diff --git a/drivers/gpu/drm/amd/display/modules/power/power_helpers.h b/drivers/gpu/drm/amd/display/modules/power/power_helpers.h
2866 index da5df00fedce..e54157026330 100644
2867 --- a/drivers/gpu/drm/amd/display/modules/power/power_helpers.h
2868 +++ b/drivers/gpu/drm/amd/display/modules/power/power_helpers.h
2869 @@ -38,6 +38,7 @@ struct dmcu_iram_parameters {
2870 unsigned int backlight_lut_array_size;
2871 unsigned int backlight_ramping_reduction;
2872 unsigned int backlight_ramping_start;
2873 + unsigned int min_abm_backlight;
2874 unsigned int set;
2875 };
2876
2877 diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
2878 index 4acf139ea014..58c091ab67b2 100644
2879 --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
2880 +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
2881 @@ -1344,7 +1344,10 @@ static int smu_suspend(void *handle)
2882 int ret;
2883 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
2884 struct smu_context *smu = &adev->smu;
2885 - bool baco_feature_is_enabled = smu_feature_is_enabled(smu, SMU_FEATURE_BACO_BIT);
2886 + bool baco_feature_is_enabled = false;
2887 +
2888 + if(!(adev->flags & AMD_IS_APU))
2889 + baco_feature_is_enabled = smu_feature_is_enabled(smu, SMU_FEATURE_BACO_BIT);
2890
2891 ret = smu_system_features_control(smu, false);
2892 if (ret)
2893 diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_baco.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_baco.c
2894 index df6ff9252401..b068d1c7b44d 100644
2895 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_baco.c
2896 +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_baco.c
2897 @@ -29,7 +29,7 @@
2898 #include "vega20_baco.h"
2899 #include "vega20_smumgr.h"
2900
2901 -
2902 +#include "amdgpu_ras.h"
2903
2904 static const struct soc15_baco_cmd_entry clean_baco_tbl[] =
2905 {
2906 @@ -74,6 +74,7 @@ int vega20_baco_get_state(struct pp_hwmgr *hwmgr, enum BACO_STATE *state)
2907 int vega20_baco_set_state(struct pp_hwmgr *hwmgr, enum BACO_STATE state)
2908 {
2909 struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
2910 + struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
2911 enum BACO_STATE cur_state;
2912 uint32_t data;
2913
2914 @@ -84,10 +85,11 @@ int vega20_baco_set_state(struct pp_hwmgr *hwmgr, enum BACO_STATE state)
2915 return 0;
2916
2917 if (state == BACO_STATE_IN) {
2918 - data = RREG32_SOC15(THM, 0, mmTHM_BACO_CNTL);
2919 - data |= 0x80000000;
2920 - WREG32_SOC15(THM, 0, mmTHM_BACO_CNTL, data);
2921 -
2922 + if (!ras || !ras->supported) {
2923 + data = RREG32_SOC15(THM, 0, mmTHM_BACO_CNTL);
2924 + data |= 0x80000000;
2925 + WREG32_SOC15(THM, 0, mmTHM_BACO_CNTL, data);
2926 + }
2927
2928 if(smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_EnterBaco, 0))
2929 return -EINVAL;
2930 diff --git a/drivers/gpu/drm/amd/powerplay/renoir_ppt.c b/drivers/gpu/drm/amd/powerplay/renoir_ppt.c
2931 index e62bfba51562..e5283dafc414 100644
2932 --- a/drivers/gpu/drm/amd/powerplay/renoir_ppt.c
2933 +++ b/drivers/gpu/drm/amd/powerplay/renoir_ppt.c
2934 @@ -183,11 +183,13 @@ static int renoir_print_clk_levels(struct smu_context *smu,
2935 int i, size = 0, ret = 0;
2936 uint32_t cur_value = 0, value = 0, count = 0, min = 0, max = 0;
2937 DpmClocks_t *clk_table = smu->smu_table.clocks_table;
2938 - SmuMetrics_t metrics = {0};
2939 + SmuMetrics_t metrics;
2940
2941 if (!clk_table || clk_type >= SMU_CLK_COUNT)
2942 return -EINVAL;
2943
2944 + memset(&metrics, 0, sizeof(metrics));
2945 +
2946 ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, 0,
2947 (void *)&metrics, false);
2948 if (ret)
2949 diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
2950 index 624d257da20f..52c42569a111 100644
2951 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
2952 +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
2953 @@ -250,6 +250,7 @@ komeda_crtc_atomic_enable(struct drm_crtc *crtc,
2954 {
2955 komeda_crtc_prepare(to_kcrtc(crtc));
2956 drm_crtc_vblank_on(crtc);
2957 + WARN_ON(drm_crtc_vblank_get(crtc));
2958 komeda_crtc_do_flush(crtc, old);
2959 }
2960
2961 @@ -319,6 +320,7 @@ komeda_crtc_atomic_disable(struct drm_crtc *crtc,
2962 }
2963 }
2964
2965 + drm_crtc_vblank_put(crtc);
2966 drm_crtc_vblank_off(crtc);
2967 komeda_crtc_unprepare(kcrtc);
2968 }
2969 diff --git a/drivers/gpu/drm/bridge/analogix-anx78xx.c b/drivers/gpu/drm/bridge/analogix-anx78xx.c
2970 index 3c7cc5af735c..56df07cdab68 100644
2971 --- a/drivers/gpu/drm/bridge/analogix-anx78xx.c
2972 +++ b/drivers/gpu/drm/bridge/analogix-anx78xx.c
2973 @@ -715,7 +715,9 @@ static int anx78xx_init_pdata(struct anx78xx *anx78xx)
2974 /* 1.0V digital core power regulator */
2975 pdata->dvdd10 = devm_regulator_get(dev, "dvdd10");
2976 if (IS_ERR(pdata->dvdd10)) {
2977 - DRM_ERROR("DVDD10 regulator not found\n");
2978 + if (PTR_ERR(pdata->dvdd10) != -EPROBE_DEFER)
2979 + DRM_ERROR("DVDD10 regulator not found\n");
2980 +
2981 return PTR_ERR(pdata->dvdd10);
2982 }
2983
2984 @@ -1332,7 +1334,9 @@ static int anx78xx_i2c_probe(struct i2c_client *client,
2985
2986 err = anx78xx_init_pdata(anx78xx);
2987 if (err) {
2988 - DRM_ERROR("Failed to initialize pdata: %d\n", err);
2989 + if (err != -EPROBE_DEFER)
2990 + DRM_ERROR("Failed to initialize pdata: %d\n", err);
2991 +
2992 return err;
2993 }
2994
2995 diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
2996 index 521d689413c8..1326f2c734bf 100644
2997 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
2998 +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
2999 @@ -36,6 +36,7 @@
3000 #include "dw-hdmi-cec.h"
3001 #include "dw-hdmi.h"
3002
3003 +#define DDC_CI_ADDR 0x37
3004 #define DDC_SEGMENT_ADDR 0x30
3005
3006 #define HDMI_EDID_LEN 512
3007 @@ -398,6 +399,15 @@ static int dw_hdmi_i2c_xfer(struct i2c_adapter *adap,
3008 u8 addr = msgs[0].addr;
3009 int i, ret = 0;
3010
3011 + if (addr == DDC_CI_ADDR)
3012 + /*
3013 + * The internal I2C controller does not support the multi-byte
3014 + * read and write operations needed for DDC/CI.
3015 + * TOFIX: Blacklist the DDC/CI address until we filter out
3016 + * unsupported I2C operations.
3017 + */
3018 + return -EOPNOTSUPP;
3019 +
3020 dev_dbg(hdmi->dev, "xfer: num: %d, addr: %#x\n", num, addr);
3021
3022 for (i = 0; i < num; i++) {
3023 @@ -2023,7 +2033,7 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode)
3024
3025 /* HDMI Initialization Step E - Configure audio */
3026 hdmi_clk_regenerator_update_pixel_clock(hdmi);
3027 - hdmi_enable_audio_clk(hdmi, true);
3028 + hdmi_enable_audio_clk(hdmi, hdmi->audio_enable);
3029 }
3030
3031 /* not for DVI mode */
3032 diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
3033 index 6b0177112e18..3f50b8865db4 100644
3034 --- a/drivers/gpu/drm/drm_edid.c
3035 +++ b/drivers/gpu/drm/drm_edid.c
3036 @@ -3722,7 +3722,7 @@ cea_db_offsets(const u8 *cea, int *start, int *end)
3037 if (*end < 4 || *end > 127)
3038 return -ERANGE;
3039 } else {
3040 - return -ENOTSUPP;
3041 + return -EOPNOTSUPP;
3042 }
3043
3044 return 0;
3045 @@ -4191,7 +4191,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
3046
3047 if (cea_revision(cea) < 3) {
3048 DRM_DEBUG_KMS("SAD: wrong CEA revision\n");
3049 - return -ENOTSUPP;
3050 + return -EOPNOTSUPP;
3051 }
3052
3053 if (cea_db_offsets(cea, &start, &end)) {
3054 @@ -4252,7 +4252,7 @@ int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb)
3055
3056 if (cea_revision(cea) < 3) {
3057 DRM_DEBUG_KMS("SAD: wrong CEA revision\n");
3058 - return -ENOTSUPP;
3059 + return -EOPNOTSUPP;
3060 }
3061
3062 if (cea_db_offsets(cea, &start, &end)) {
3063 diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
3064 index 1961f713aaab..f8154316a3b0 100644
3065 --- a/drivers/gpu/drm/drm_mipi_dbi.c
3066 +++ b/drivers/gpu/drm/drm_mipi_dbi.c
3067 @@ -955,7 +955,7 @@ static int mipi_dbi_typec1_command(struct mipi_dbi *dbi, u8 *cmd,
3068 int ret;
3069
3070 if (mipi_dbi_command_is_read(dbi, *cmd))
3071 - return -ENOTSUPP;
3072 + return -EOPNOTSUPP;
3073
3074 MIPI_DBI_DEBUG_COMMAND(*cmd, parameters, num);
3075
3076 @@ -1187,8 +1187,7 @@ static ssize_t mipi_dbi_debugfs_command_write(struct file *file,
3077 struct mipi_dbi_dev *dbidev = m->private;
3078 u8 val, cmd = 0, parameters[64];
3079 char *buf, *pos, *token;
3080 - unsigned int i;
3081 - int ret, idx;
3082 + int i, ret, idx;
3083
3084 if (!drm_dev_enter(&dbidev->drm, &idx))
3085 return -ENODEV;
3086 diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
3087 index fd1fbc77871f..552ec82e9bc5 100644
3088 --- a/drivers/gpu/drm/drm_vblank.c
3089 +++ b/drivers/gpu/drm/drm_vblank.c
3090 @@ -1581,7 +1581,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
3091 unsigned int flags, pipe, high_pipe;
3092
3093 if (!dev->irq_enabled)
3094 - return -EINVAL;
3095 + return -EOPNOTSUPP;
3096
3097 if (vblwait->request.type & _DRM_VBLANK_SIGNAL)
3098 return -EINVAL;
3099 @@ -1838,7 +1838,7 @@ int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
3100 return -EOPNOTSUPP;
3101
3102 if (!dev->irq_enabled)
3103 - return -EINVAL;
3104 + return -EOPNOTSUPP;
3105
3106 crtc = drm_crtc_find(dev, file_priv, get_seq->crtc_id);
3107 if (!crtc)
3108 @@ -1896,7 +1896,7 @@ int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data,
3109 return -EOPNOTSUPP;
3110
3111 if (!dev->irq_enabled)
3112 - return -EINVAL;
3113 + return -EOPNOTSUPP;
3114
3115 crtc = drm_crtc_find(dev, file_priv, queue_seq->crtc_id);
3116 if (!crtc)
3117 diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
3118 index bc1565f1822a..09aa73c0f2ad 100644
3119 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
3120 +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
3121 @@ -852,6 +852,10 @@ static enum drm_connector_status hdmi_detect(struct drm_connector *connector,
3122
3123 static void hdmi_connector_destroy(struct drm_connector *connector)
3124 {
3125 + struct hdmi_context *hdata = connector_to_hdmi(connector);
3126 +
3127 + cec_notifier_conn_unregister(hdata->notifier);
3128 +
3129 drm_connector_unregister(connector);
3130 drm_connector_cleanup(connector);
3131 }
3132 @@ -935,6 +939,7 @@ static int hdmi_create_connector(struct drm_encoder *encoder)
3133 {
3134 struct hdmi_context *hdata = encoder_to_hdmi(encoder);
3135 struct drm_connector *connector = &hdata->connector;
3136 + struct cec_connector_info conn_info;
3137 int ret;
3138
3139 connector->interlace_allowed = true;
3140 @@ -957,6 +962,15 @@ static int hdmi_create_connector(struct drm_encoder *encoder)
3141 DRM_DEV_ERROR(hdata->dev, "Failed to attach bridge\n");
3142 }
3143
3144 + cec_fill_conn_info_from_drm(&conn_info, connector);
3145 +
3146 + hdata->notifier = cec_notifier_conn_register(hdata->dev, NULL,
3147 + &conn_info);
3148 + if (!hdata->notifier) {
3149 + ret = -ENOMEM;
3150 + DRM_DEV_ERROR(hdata->dev, "Failed to allocate CEC notifier\n");
3151 + }
3152 +
3153 return ret;
3154 }
3155
3156 @@ -1528,8 +1542,8 @@ static void hdmi_disable(struct drm_encoder *encoder)
3157 */
3158 mutex_unlock(&hdata->mutex);
3159 cancel_delayed_work(&hdata->hotplug_work);
3160 - cec_notifier_set_phys_addr(hdata->notifier,
3161 - CEC_PHYS_ADDR_INVALID);
3162 + if (hdata->notifier)
3163 + cec_notifier_phys_addr_invalidate(hdata->notifier);
3164 return;
3165 }
3166
3167 @@ -2006,12 +2020,6 @@ static int hdmi_probe(struct platform_device *pdev)
3168 }
3169 }
3170
3171 - hdata->notifier = cec_notifier_get(&pdev->dev);
3172 - if (hdata->notifier == NULL) {
3173 - ret = -ENOMEM;
3174 - goto err_hdmiphy;
3175 - }
3176 -
3177 pm_runtime_enable(dev);
3178
3179 audio_infoframe = &hdata->audio.infoframe;
3180 @@ -2023,7 +2031,7 @@ static int hdmi_probe(struct platform_device *pdev)
3181
3182 ret = hdmi_register_audio_device(hdata);
3183 if (ret)
3184 - goto err_notifier_put;
3185 + goto err_rpm_disable;
3186
3187 ret = component_add(&pdev->dev, &hdmi_component_ops);
3188 if (ret)
3189 @@ -2034,8 +2042,7 @@ static int hdmi_probe(struct platform_device *pdev)
3190 err_unregister_audio:
3191 platform_device_unregister(hdata->audio.pdev);
3192
3193 -err_notifier_put:
3194 - cec_notifier_put(hdata->notifier);
3195 +err_rpm_disable:
3196 pm_runtime_disable(dev);
3197
3198 err_hdmiphy:
3199 @@ -2054,12 +2061,10 @@ static int hdmi_remove(struct platform_device *pdev)
3200 struct hdmi_context *hdata = platform_get_drvdata(pdev);
3201
3202 cancel_delayed_work_sync(&hdata->hotplug_work);
3203 - cec_notifier_set_phys_addr(hdata->notifier, CEC_PHYS_ADDR_INVALID);
3204
3205 component_del(&pdev->dev, &hdmi_component_ops);
3206 platform_device_unregister(hdata->audio.pdev);
3207
3208 - cec_notifier_put(hdata->notifier);
3209 pm_runtime_disable(&pdev->dev);
3210
3211 if (!IS_ERR(hdata->reg_hdmi_en))
3212 diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
3213 index 167c10767dd4..900e5499249d 100644
3214 --- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
3215 +++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
3216 @@ -129,6 +129,7 @@ static bool mrst_sdvo_find_best_pll(const struct gma_limit_t *limit,
3217 s32 freq_error, min_error = 100000;
3218
3219 memset(best_clock, 0, sizeof(*best_clock));
3220 + memset(&clock, 0, sizeof(clock));
3221
3222 for (clock.m = limit->m.min; clock.m <= limit->m.max; clock.m++) {
3223 for (clock.n = limit->n.min; clock.n <= limit->n.max;
3224 @@ -185,6 +186,7 @@ static bool mrst_lvds_find_best_pll(const struct gma_limit_t *limit,
3225 int err = target;
3226
3227 memset(best_clock, 0, sizeof(*best_clock));
3228 + memset(&clock, 0, sizeof(clock));
3229
3230 for (clock.m = limit->m.min; clock.m <= limit->m.max; clock.m++) {
3231 for (clock.p1 = limit->p1.min; clock.p1 <= limit->p1.max;
3232 diff --git a/drivers/gpu/drm/meson/meson_vclk.c b/drivers/gpu/drm/meson/meson_vclk.c
3233 index ac491a781952..f690793ae2d5 100644
3234 --- a/drivers/gpu/drm/meson/meson_vclk.c
3235 +++ b/drivers/gpu/drm/meson/meson_vclk.c
3236 @@ -638,13 +638,18 @@ static bool meson_hdmi_pll_validate_params(struct meson_drm *priv,
3237 if (frac >= HDMI_FRAC_MAX_GXBB)
3238 return false;
3239 } else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXM) ||
3240 - meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXL) ||
3241 - meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
3242 + meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXL)) {
3243 /* Empiric supported min/max dividers */
3244 if (m < 106 || m > 247)
3245 return false;
3246 if (frac >= HDMI_FRAC_MAX_GXL)
3247 return false;
3248 + } else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
3249 + /* Empiric supported min/max dividers */
3250 + if (m < 106 || m > 247)
3251 + return false;
3252 + if (frac >= HDMI_FRAC_MAX_G12A)
3253 + return false;
3254 }
3255
3256 return true;
3257 diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
3258 index e686331fa089..691c1a277d91 100644
3259 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
3260 +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
3261 @@ -352,26 +352,26 @@ static void a6xx_get_debugbus(struct msm_gpu *gpu,
3262 cxdbg = ioremap(res->start, resource_size(res));
3263
3264 if (cxdbg) {
3265 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_CNTLT,
3266 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_CNTLT,
3267 A6XX_DBGC_CFG_DBGBUS_CNTLT_SEGT(0xf));
3268
3269 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_CNTLM,
3270 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_CNTLM,
3271 A6XX_DBGC_CFG_DBGBUS_CNTLM_ENABLE(0xf));
3272
3273 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_IVTL_0, 0);
3274 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_IVTL_1, 0);
3275 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_IVTL_2, 0);
3276 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_IVTL_3, 0);
3277 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_IVTL_0, 0);
3278 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_IVTL_1, 0);
3279 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_IVTL_2, 0);
3280 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_IVTL_3, 0);
3281
3282 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_BYTEL_0,
3283 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_BYTEL_0,
3284 0x76543210);
3285 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_BYTEL_1,
3286 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_BYTEL_1,
3287 0xFEDCBA98);
3288
3289 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_MASKL_0, 0);
3290 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_MASKL_1, 0);
3291 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_MASKL_2, 0);
3292 - cxdbg_write(cxdbg, REG_A6XX_DBGC_CFG_DBGBUS_MASKL_3, 0);
3293 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_MASKL_0, 0);
3294 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_MASKL_1, 0);
3295 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_MASKL_2, 0);
3296 + cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_MASKL_3, 0);
3297 }
3298
3299 a6xx_state->debugbus = state_kcalloc(a6xx_state,
3300 diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
3301 index 94dfa2e5a9ab..a442a955f98c 100644
3302 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c
3303 +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
3304 @@ -1131,6 +1131,16 @@ nouveau_connector_hotplug(struct nvif_notify *notify)
3305 const char *name = connector->name;
3306 struct nouveau_encoder *nv_encoder;
3307 int ret;
3308 + bool plugged = (rep->mask != NVIF_NOTIFY_CONN_V0_UNPLUG);
3309 +
3310 + if (rep->mask & NVIF_NOTIFY_CONN_V0_IRQ) {
3311 + NV_DEBUG(drm, "service %s\n", name);
3312 + drm_dp_cec_irq(&nv_connector->aux);
3313 + if ((nv_encoder = find_encoder(connector, DCB_OUTPUT_DP)))
3314 + nv50_mstm_service(nv_encoder->dp.mstm);
3315 +
3316 + return NVIF_NOTIFY_KEEP;
3317 + }
3318
3319 ret = pm_runtime_get(drm->dev->dev);
3320 if (ret == 0) {
3321 @@ -1151,25 +1161,16 @@ nouveau_connector_hotplug(struct nvif_notify *notify)
3322 return NVIF_NOTIFY_DROP;
3323 }
3324
3325 - if (rep->mask & NVIF_NOTIFY_CONN_V0_IRQ) {
3326 - NV_DEBUG(drm, "service %s\n", name);
3327 - drm_dp_cec_irq(&nv_connector->aux);
3328 - if ((nv_encoder = find_encoder(connector, DCB_OUTPUT_DP)))
3329 - nv50_mstm_service(nv_encoder->dp.mstm);
3330 - } else {
3331 - bool plugged = (rep->mask != NVIF_NOTIFY_CONN_V0_UNPLUG);
3332 -
3333 + if (!plugged)
3334 + drm_dp_cec_unset_edid(&nv_connector->aux);
3335 + NV_DEBUG(drm, "%splugged %s\n", plugged ? "" : "un", name);
3336 + if ((nv_encoder = find_encoder(connector, DCB_OUTPUT_DP))) {
3337 if (!plugged)
3338 - drm_dp_cec_unset_edid(&nv_connector->aux);
3339 - NV_DEBUG(drm, "%splugged %s\n", plugged ? "" : "un", name);
3340 - if ((nv_encoder = find_encoder(connector, DCB_OUTPUT_DP))) {
3341 - if (!plugged)
3342 - nv50_mstm_remove(nv_encoder->dp.mstm);
3343 - }
3344 -
3345 - drm_helper_hpd_irq_event(connector->dev);
3346 + nv50_mstm_remove(nv_encoder->dp.mstm);
3347 }
3348
3349 + drm_helper_hpd_irq_event(connector->dev);
3350 +
3351 pm_runtime_mark_last_busy(drm->dev->dev);
3352 pm_runtime_put_autosuspend(drm->dev->dev);
3353 return NVIF_NOTIFY_KEEP;
3354 diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
3355 index b5b14aa059ea..2aa89eaecf6f 100644
3356 --- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
3357 +++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
3358 @@ -426,6 +426,7 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c,
3359 return PTR_ERR(ts->dsi);
3360 }
3361
3362 + drm_panel_init(&ts->base);
3363 ts->base.dev = dev;
3364 ts->base.funcs = &rpi_touchscreen_funcs;
3365
3366 diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
3367 index 5e3e92ea9ea6..3b2612ae931e 100644
3368 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
3369 +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
3370 @@ -381,6 +381,7 @@ static int st7789v_probe(struct spi_device *spi)
3371 spi_set_drvdata(spi, ctx);
3372 ctx->spi = spi;
3373
3374 + drm_panel_init(&ctx->panel);
3375 ctx->panel.dev = &spi->dev;
3376 ctx->panel.funcs = &st7789v_drm_funcs;
3377
3378 diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
3379 index f39b97ed4ade..2af64459b3d7 100644
3380 --- a/drivers/gpu/drm/scheduler/sched_main.c
3381 +++ b/drivers/gpu/drm/scheduler/sched_main.c
3382 @@ -632,43 +632,41 @@ static void drm_sched_process_job(struct dma_fence *f, struct dma_fence_cb *cb)
3383 }
3384
3385 /**
3386 - * drm_sched_cleanup_jobs - destroy finished jobs
3387 + * drm_sched_get_cleanup_job - fetch the next finished job to be destroyed
3388 *
3389 * @sched: scheduler instance
3390 *
3391 - * Remove all finished jobs from the mirror list and destroy them.
3392 + * Returns the next finished job from the mirror list (if there is one)
3393 + * ready for it to be destroyed.
3394 */
3395 -static void drm_sched_cleanup_jobs(struct drm_gpu_scheduler *sched)
3396 +static struct drm_sched_job *
3397 +drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
3398 {
3399 + struct drm_sched_job *job;
3400 unsigned long flags;
3401
3402 /* Don't destroy jobs while the timeout worker is running */
3403 if (sched->timeout != MAX_SCHEDULE_TIMEOUT &&
3404 !cancel_delayed_work(&sched->work_tdr))
3405 - return;
3406 -
3407 + return NULL;
3408
3409 - while (!list_empty(&sched->ring_mirror_list)) {
3410 - struct drm_sched_job *job;
3411 + spin_lock_irqsave(&sched->job_list_lock, flags);
3412
3413 - job = list_first_entry(&sched->ring_mirror_list,
3414 + job = list_first_entry_or_null(&sched->ring_mirror_list,
3415 struct drm_sched_job, node);
3416 - if (!dma_fence_is_signaled(&job->s_fence->finished))
3417 - break;
3418
3419 - spin_lock_irqsave(&sched->job_list_lock, flags);
3420 + if (job && dma_fence_is_signaled(&job->s_fence->finished)) {
3421 /* remove job from ring_mirror_list */
3422 list_del_init(&job->node);
3423 - spin_unlock_irqrestore(&sched->job_list_lock, flags);
3424 -
3425 - sched->ops->free_job(job);
3426 + } else {
3427 + job = NULL;
3428 + /* queue timeout for next job */
3429 + drm_sched_start_timeout(sched);
3430 }
3431
3432 - /* queue timeout for next job */
3433 - spin_lock_irqsave(&sched->job_list_lock, flags);
3434 - drm_sched_start_timeout(sched);
3435 spin_unlock_irqrestore(&sched->job_list_lock, flags);
3436
3437 + return job;
3438 }
3439
3440 /**
3441 @@ -708,12 +706,19 @@ static int drm_sched_main(void *param)
3442 struct drm_sched_fence *s_fence;
3443 struct drm_sched_job *sched_job;
3444 struct dma_fence *fence;
3445 + struct drm_sched_job *cleanup_job = NULL;
3446
3447 wait_event_interruptible(sched->wake_up_worker,
3448 - (drm_sched_cleanup_jobs(sched),
3449 + (cleanup_job = drm_sched_get_cleanup_job(sched)) ||
3450 (!drm_sched_blocked(sched) &&
3451 (entity = drm_sched_select_entity(sched))) ||
3452 - kthread_should_stop()));
3453 + kthread_should_stop());
3454 +
3455 + if (cleanup_job) {
3456 + sched->ops->free_job(cleanup_job);
3457 + /* queue timeout for next job */
3458 + drm_sched_start_timeout(sched);
3459 + }
3460
3461 if (!entity)
3462 continue;
3463 diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
3464 index 1636344ba9ec..f83522717488 100644
3465 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
3466 +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
3467 @@ -437,9 +437,9 @@ static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi,
3468 SUN6I_DSI_BURST_LINE_SYNC_POINT(SUN6I_DSI_SYNC_POINT));
3469
3470 val = SUN6I_DSI_TCON_DRQ_ENABLE_MODE;
3471 - } else if ((mode->hsync_end - mode->hdisplay) > 20) {
3472 + } else if ((mode->hsync_start - mode->hdisplay) > 20) {
3473 /* Maaaaaagic */
3474 - u16 drq = (mode->hsync_end - mode->hdisplay) - 20;
3475 + u16 drq = (mode->hsync_start - mode->hdisplay) - 20;
3476
3477 drq *= mipi_dsi_pixel_format_to_bpp(device->format);
3478 drq /= 32;
3479 diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
3480 index e1669ada0a40..75e65d9536d5 100644
3481 --- a/drivers/gpu/drm/tegra/sor.c
3482 +++ b/drivers/gpu/drm/tegra/sor.c
3483 @@ -3200,6 +3200,11 @@ static int tegra_sor_parse_dt(struct tegra_sor *sor)
3484 * earlier
3485 */
3486 sor->pad = TEGRA_IO_PAD_HDMI_DP0 + sor->index;
3487 + } else {
3488 + if (sor->soc->supports_edp)
3489 + sor->index = 0;
3490 + else
3491 + sor->index = 1;
3492 }
3493
3494 err = of_property_read_u32_array(np, "nvidia,xbar-cfg", xbar_cfg, 5);
3495 diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
3496 index 98819462f025..f07803699809 100644
3497 --- a/drivers/gpu/drm/ttm/ttm_bo.c
3498 +++ b/drivers/gpu/drm/ttm/ttm_bo.c
3499 @@ -926,7 +926,8 @@ EXPORT_SYMBOL(ttm_bo_mem_put);
3500 */
3501 static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
3502 struct ttm_mem_type_manager *man,
3503 - struct ttm_mem_reg *mem)
3504 + struct ttm_mem_reg *mem,
3505 + bool no_wait_gpu)
3506 {
3507 struct dma_fence *fence;
3508 int ret;
3509 @@ -935,19 +936,22 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
3510 fence = dma_fence_get(man->move);
3511 spin_unlock(&man->move_lock);
3512
3513 - if (fence) {
3514 - dma_resv_add_shared_fence(bo->base.resv, fence);
3515 + if (!fence)
3516 + return 0;
3517
3518 - ret = dma_resv_reserve_shared(bo->base.resv, 1);
3519 - if (unlikely(ret)) {
3520 - dma_fence_put(fence);
3521 - return ret;
3522 - }
3523 + if (no_wait_gpu)
3524 + return -EBUSY;
3525 +
3526 + dma_resv_add_shared_fence(bo->base.resv, fence);
3527
3528 - dma_fence_put(bo->moving);
3529 - bo->moving = fence;
3530 + ret = dma_resv_reserve_shared(bo->base.resv, 1);
3531 + if (unlikely(ret)) {
3532 + dma_fence_put(fence);
3533 + return ret;
3534 }
3535
3536 + dma_fence_put(bo->moving);
3537 + bo->moving = fence;
3538 return 0;
3539 }
3540
3541 @@ -978,7 +982,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
3542 return ret;
3543 } while (1);
3544
3545 - return ttm_bo_add_move_fence(bo, man, mem);
3546 + return ttm_bo_add_move_fence(bo, man, mem, ctx->no_wait_gpu);
3547 }
3548
3549 static uint32_t ttm_bo_select_caching(struct ttm_mem_type_manager *man,
3550 @@ -1120,14 +1124,18 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
3551 if (unlikely(ret))
3552 goto error;
3553
3554 - if (mem->mm_node) {
3555 - ret = ttm_bo_add_move_fence(bo, man, mem);
3556 - if (unlikely(ret)) {
3557 - (*man->func->put_node)(man, mem);
3558 - goto error;
3559 - }
3560 - return 0;
3561 + if (!mem->mm_node)
3562 + continue;
3563 +
3564 + ret = ttm_bo_add_move_fence(bo, man, mem, ctx->no_wait_gpu);
3565 + if (unlikely(ret)) {
3566 + (*man->func->put_node)(man, mem);
3567 + if (ret == -EBUSY)
3568 + continue;
3569 +
3570 + goto error;
3571 }
3572 + return 0;
3573 }
3574
3575 for (i = 0; i < placement->num_busy_placement; ++i) {
3576 diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
3577 index ee7d4e7b0ee3..0853b980bcb3 100644
3578 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
3579 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
3580 @@ -1285,6 +1285,9 @@ static const struct cec_adap_ops vc4_hdmi_cec_adap_ops = {
3581
3582 static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
3583 {
3584 +#ifdef CONFIG_DRM_VC4_HDMI_CEC
3585 + struct cec_connector_info conn_info;
3586 +#endif
3587 struct platform_device *pdev = to_platform_device(dev);
3588 struct drm_device *drm = dev_get_drvdata(master);
3589 struct vc4_dev *vc4 = drm->dev_private;
3590 @@ -1403,13 +1406,15 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
3591 #ifdef CONFIG_DRM_VC4_HDMI_CEC
3592 hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops,
3593 vc4, "vc4",
3594 - CEC_CAP_TRANSMIT |
3595 - CEC_CAP_LOG_ADDRS |
3596 - CEC_CAP_PASSTHROUGH |
3597 - CEC_CAP_RC, 1);
3598 + CEC_CAP_DEFAULTS |
3599 + CEC_CAP_CONNECTOR_INFO, 1);
3600 ret = PTR_ERR_OR_ZERO(hdmi->cec_adap);
3601 if (ret < 0)
3602 goto err_destroy_conn;
3603 +
3604 + cec_fill_conn_info_from_drm(&conn_info, hdmi->connector);
3605 + cec_s_conn_info(hdmi->cec_adap, &conn_info);
3606 +
3607 HDMI_WRITE(VC4_HDMI_CPU_MASK_SET, 0xffffffff);
3608 value = HDMI_READ(VC4_HDMI_CEC_CNTRL_1);
3609 value &= ~VC4_HDMI_CEC_DIV_CLK_CNT_MASK;
3610 diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
3611 index 0a88ef11b9d3..a662394f6892 100644
3612 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
3613 +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
3614 @@ -463,25 +463,29 @@ out:
3615 }
3616
3617 static int virtio_gpu_wait_ioctl(struct drm_device *dev, void *data,
3618 - struct drm_file *file)
3619 + struct drm_file *file)
3620 {
3621 struct drm_virtgpu_3d_wait *args = data;
3622 - struct drm_gem_object *gobj = NULL;
3623 - struct virtio_gpu_object *qobj = NULL;
3624 + struct drm_gem_object *obj;
3625 + long timeout = 15 * HZ;
3626 int ret;
3627 - bool nowait = false;
3628
3629 - gobj = drm_gem_object_lookup(file, args->handle);
3630 - if (gobj == NULL)
3631 + obj = drm_gem_object_lookup(file, args->handle);
3632 + if (obj == NULL)
3633 return -ENOENT;
3634
3635 - qobj = gem_to_virtio_gpu_obj(gobj);
3636 -
3637 - if (args->flags & VIRTGPU_WAIT_NOWAIT)
3638 - nowait = true;
3639 - ret = virtio_gpu_object_wait(qobj, nowait);
3640 + if (args->flags & VIRTGPU_WAIT_NOWAIT) {
3641 + ret = dma_resv_test_signaled_rcu(obj->resv, true);
3642 + } else {
3643 + ret = dma_resv_wait_timeout_rcu(obj->resv, true, true,
3644 + timeout);
3645 + }
3646 + if (ret == 0)
3647 + ret = -EBUSY;
3648 + else if (ret > 0)
3649 + ret = 0;
3650
3651 - drm_gem_object_put_unlocked(gobj);
3652 + drm_gem_object_put_unlocked(obj);
3653 return ret;
3654 }
3655
3656 diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c
3657 index eaa5c3352c13..22559670faee 100644
3658 --- a/drivers/gpu/host1x/job.c
3659 +++ b/drivers/gpu/host1x/job.c
3660 @@ -436,7 +436,8 @@ out:
3661 return err;
3662 }
3663
3664 -static inline int copy_gathers(struct host1x_job *job, struct device *dev)
3665 +static inline int copy_gathers(struct device *host, struct host1x_job *job,
3666 + struct device *dev)
3667 {
3668 struct host1x_firewall fw;
3669 size_t size = 0;
3670 @@ -459,12 +460,12 @@ static inline int copy_gathers(struct host1x_job *job, struct device *dev)
3671 * Try a non-blocking allocation from a higher priority pools first,
3672 * as awaiting for the allocation here is a major performance hit.
3673 */
3674 - job->gather_copy_mapped = dma_alloc_wc(dev, size, &job->gather_copy,
3675 + job->gather_copy_mapped = dma_alloc_wc(host, size, &job->gather_copy,
3676 GFP_NOWAIT);
3677
3678 /* the higher priority allocation failed, try the generic-blocking */
3679 if (!job->gather_copy_mapped)
3680 - job->gather_copy_mapped = dma_alloc_wc(dev, size,
3681 + job->gather_copy_mapped = dma_alloc_wc(host, size,
3682 &job->gather_copy,
3683 GFP_KERNEL);
3684 if (!job->gather_copy_mapped)
3685 @@ -512,7 +513,7 @@ int host1x_job_pin(struct host1x_job *job, struct device *dev)
3686 goto out;
3687
3688 if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) {
3689 - err = copy_gathers(job, dev);
3690 + err = copy_gathers(host->dev, job, dev);
3691 if (err)
3692 goto out;
3693 }
3694 @@ -573,7 +574,7 @@ void host1x_job_unpin(struct host1x_job *job)
3695 job->num_unpins = 0;
3696
3697 if (job->gather_copy_size)
3698 - dma_free_wc(job->channel->dev, job->gather_copy_size,
3699 + dma_free_wc(host->dev, job->gather_copy_size,
3700 job->gather_copy_mapped, job->gather_copy);
3701 }
3702 EXPORT_SYMBOL(host1x_job_unpin);
3703 diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
3704 index 0dfd97bbde9e..ca232ec565e8 100644
3705 --- a/drivers/hwtracing/intel_th/core.c
3706 +++ b/drivers/hwtracing/intel_th/core.c
3707 @@ -834,9 +834,6 @@ static irqreturn_t intel_th_irq(int irq, void *data)
3708 ret |= d->irq(th->thdev[i]);
3709 }
3710
3711 - if (ret == IRQ_NONE)
3712 - pr_warn_ratelimited("nobody cared for irq\n");
3713 -
3714 return ret;
3715 }
3716
3717 @@ -887,6 +884,7 @@ intel_th_alloc(struct device *dev, struct intel_th_drvdata *drvdata,
3718
3719 if (th->irq == -1)
3720 th->irq = devres[r].start;
3721 + th->num_irqs++;
3722 break;
3723 default:
3724 dev_warn(dev, "Unknown resource type %lx\n",
3725 @@ -940,6 +938,9 @@ void intel_th_free(struct intel_th *th)
3726
3727 th->num_thdevs = 0;
3728
3729 + for (i = 0; i < th->num_irqs; i++)
3730 + devm_free_irq(th->dev, th->irq + i, th);
3731 +
3732 pm_runtime_get_sync(th->dev);
3733 pm_runtime_forbid(th->dev);
3734
3735 diff --git a/drivers/hwtracing/intel_th/intel_th.h b/drivers/hwtracing/intel_th/intel_th.h
3736 index 0df480072b6c..6f4f5486fe6d 100644
3737 --- a/drivers/hwtracing/intel_th/intel_th.h
3738 +++ b/drivers/hwtracing/intel_th/intel_th.h
3739 @@ -261,6 +261,7 @@ enum th_mmio_idx {
3740 * @num_thdevs: number of devices in the @thdev array
3741 * @num_resources: number of resources in the @resource array
3742 * @irq: irq number
3743 + * @num_irqs: number of IRQs is use
3744 * @id: this Intel TH controller's device ID in the system
3745 * @major: device node major for output devices
3746 */
3747 @@ -277,6 +278,7 @@ struct intel_th {
3748 unsigned int num_thdevs;
3749 unsigned int num_resources;
3750 int irq;
3751 + int num_irqs;
3752
3753 int id;
3754 int major;
3755 diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
3756 index 6d240dfae9d9..8e48c7458aa3 100644
3757 --- a/drivers/hwtracing/intel_th/msu.c
3758 +++ b/drivers/hwtracing/intel_th/msu.c
3759 @@ -1676,10 +1676,13 @@ static int intel_th_msc_init(struct msc *msc)
3760 return 0;
3761 }
3762
3763 -static void msc_win_switch(struct msc *msc)
3764 +static int msc_win_switch(struct msc *msc)
3765 {
3766 struct msc_window *first;
3767
3768 + if (list_empty(&msc->win_list))
3769 + return -EINVAL;
3770 +
3771 first = list_first_entry(&msc->win_list, struct msc_window, entry);
3772
3773 if (msc_is_last_win(msc->cur_win))
3774 @@ -1691,6 +1694,8 @@ static void msc_win_switch(struct msc *msc)
3775 msc->base_addr = msc_win_base_dma(msc->cur_win);
3776
3777 intel_th_trace_switch(msc->thdev);
3778 +
3779 + return 0;
3780 }
3781
3782 /**
3783 @@ -2025,16 +2030,15 @@ win_switch_store(struct device *dev, struct device_attribute *attr,
3784 if (val != 1)
3785 return -EINVAL;
3786
3787 + ret = -EINVAL;
3788 mutex_lock(&msc->buf_mutex);
3789 /*
3790 * Window switch can only happen in the "multi" mode.
3791 * If a external buffer is engaged, they have the full
3792 * control over window switching.
3793 */
3794 - if (msc->mode != MSC_MODE_MULTI || msc->mbuf)
3795 - ret = -ENOTSUPP;
3796 - else
3797 - msc_win_switch(msc);
3798 + if (msc->mode == MSC_MODE_MULTI && !msc->mbuf)
3799 + ret = msc_win_switch(msc);
3800 mutex_unlock(&msc->buf_mutex);
3801
3802 return ret ? ret : size;
3803 diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
3804 index ebf3e30e989a..e9d90b53bbc4 100644
3805 --- a/drivers/hwtracing/intel_th/pci.c
3806 +++ b/drivers/hwtracing/intel_th/pci.c
3807 @@ -204,6 +204,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
3808 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x06a6),
3809 .driver_data = (kernel_ulong_t)&intel_th_2x,
3810 },
3811 + {
3812 + /* Comet Lake PCH-V */
3813 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa3a6),
3814 + .driver_data = (kernel_ulong_t)&intel_th_2x,
3815 + },
3816 {
3817 /* Ice Lake NNPI */
3818 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x45c5),
3819 @@ -229,6 +234,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
3820 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4da6),
3821 .driver_data = (kernel_ulong_t)&intel_th_2x,
3822 },
3823 + {
3824 + /* Elkhart Lake */
3825 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4b26),
3826 + .driver_data = (kernel_ulong_t)&intel_th_2x,
3827 + },
3828 { 0 },
3829 };
3830
3831 diff --git a/drivers/iio/adc/dln2-adc.c b/drivers/iio/adc/dln2-adc.c
3832 index 5fa78c273a25..65c7c9329b1c 100644
3833 --- a/drivers/iio/adc/dln2-adc.c
3834 +++ b/drivers/iio/adc/dln2-adc.c
3835 @@ -524,6 +524,10 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
3836 u16 conflict;
3837 unsigned int trigger_chan;
3838
3839 + ret = iio_triggered_buffer_postenable(indio_dev);
3840 + if (ret)
3841 + return ret;
3842 +
3843 mutex_lock(&dln2->mutex);
3844
3845 /* Enable ADC */
3846 @@ -537,6 +541,7 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
3847 (int)conflict);
3848 ret = -EBUSY;
3849 }
3850 + iio_triggered_buffer_predisable(indio_dev);
3851 return ret;
3852 }
3853
3854 @@ -550,6 +555,7 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
3855 mutex_unlock(&dln2->mutex);
3856 if (ret < 0) {
3857 dev_dbg(&dln2->pdev->dev, "Problem in %s\n", __func__);
3858 + iio_triggered_buffer_predisable(indio_dev);
3859 return ret;
3860 }
3861 } else {
3862 @@ -557,12 +563,12 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
3863 mutex_unlock(&dln2->mutex);
3864 }
3865
3866 - return iio_triggered_buffer_postenable(indio_dev);
3867 + return 0;
3868 }
3869
3870 static int dln2_adc_triggered_buffer_predisable(struct iio_dev *indio_dev)
3871 {
3872 - int ret;
3873 + int ret, ret2;
3874 struct dln2_adc *dln2 = iio_priv(indio_dev);
3875
3876 mutex_lock(&dln2->mutex);
3877 @@ -577,12 +583,14 @@ static int dln2_adc_triggered_buffer_predisable(struct iio_dev *indio_dev)
3878 ret = dln2_adc_set_port_enabled(dln2, false, NULL);
3879
3880 mutex_unlock(&dln2->mutex);
3881 - if (ret < 0) {
3882 + if (ret < 0)
3883 dev_dbg(&dln2->pdev->dev, "Problem in %s\n", __func__);
3884 - return ret;
3885 - }
3886
3887 - return iio_triggered_buffer_predisable(indio_dev);
3888 + ret2 = iio_triggered_buffer_predisable(indio_dev);
3889 + if (ret == 0)
3890 + ret = ret2;
3891 +
3892 + return ret;
3893 }
3894
3895 static const struct iio_buffer_setup_ops dln2_adc_buffer_setup_ops = {
3896 diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
3897 index 214883458582..e3be8eedd773 100644
3898 --- a/drivers/iio/adc/max1027.c
3899 +++ b/drivers/iio/adc/max1027.c
3900 @@ -458,6 +458,14 @@ static int max1027_probe(struct spi_device *spi)
3901 return ret;
3902 }
3903
3904 + /* Internal reset */
3905 + st->reg = MAX1027_RST_REG;
3906 + ret = spi_write(st->spi, &st->reg, 1);
3907 + if (ret < 0) {
3908 + dev_err(&indio_dev->dev, "Failed to reset the ADC\n");
3909 + return ret;
3910 + }
3911 +
3912 /* Disable averaging */
3913 st->reg = MAX1027_AVG_REG;
3914 ret = spi_write(st->spi, &st->reg, 1);
3915 diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
3916 index cc42219a64f7..979070196da9 100644
3917 --- a/drivers/iio/dac/Kconfig
3918 +++ b/drivers/iio/dac/Kconfig
3919 @@ -60,8 +60,8 @@ config AD5446
3920 help
3921 Say yes here to build support for Analog Devices AD5300, AD5301, AD5310,
3922 AD5311, AD5320, AD5321, AD5444, AD5446, AD5450, AD5451, AD5452, AD5453,
3923 - AD5512A, AD5541A, AD5542A, AD5543, AD5553, AD5601, AD5602, AD5611, AD5612,
3924 - AD5620, AD5621, AD5622, AD5640, AD5641, AD5660, AD5662 DACs
3925 + AD5512A, AD5541A, AD5542A, AD5543, AD5553, AD5600, AD5601, AD5602, AD5611,
3926 + AD5612, AD5620, AD5621, AD5622, AD5640, AD5641, AD5660, AD5662 DACs
3927 as well as Texas Instruments DAC081S101, DAC101S101, DAC121S101.
3928
3929 To compile this driver as a module, choose M here: the
3930 diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c
3931 index 7df8b4cc295d..61c670f7fc5f 100644
3932 --- a/drivers/iio/dac/ad5446.c
3933 +++ b/drivers/iio/dac/ad5446.c
3934 @@ -327,6 +327,7 @@ enum ad5446_supported_spi_device_ids {
3935 ID_AD5541A,
3936 ID_AD5512A,
3937 ID_AD5553,
3938 + ID_AD5600,
3939 ID_AD5601,
3940 ID_AD5611,
3941 ID_AD5621,
3942 @@ -381,6 +382,10 @@ static const struct ad5446_chip_info ad5446_spi_chip_info[] = {
3943 .channel = AD5446_CHANNEL(14, 16, 0),
3944 .write = ad5446_write,
3945 },
3946 + [ID_AD5600] = {
3947 + .channel = AD5446_CHANNEL(16, 16, 0),
3948 + .write = ad5446_write,
3949 + },
3950 [ID_AD5601] = {
3951 .channel = AD5446_CHANNEL_POWERDOWN(8, 16, 6),
3952 .write = ad5446_write,
3953 @@ -448,6 +453,7 @@ static const struct spi_device_id ad5446_spi_ids[] = {
3954 {"ad5542a", ID_AD5541A}, /* ad5541a and ad5542a are compatible */
3955 {"ad5543", ID_AD5541A}, /* ad5541a and ad5543 are compatible */
3956 {"ad5553", ID_AD5553},
3957 + {"ad5600", ID_AD5600},
3958 {"ad5601", ID_AD5601},
3959 {"ad5611", ID_AD5611},
3960 {"ad5621", ID_AD5621},
3961 diff --git a/drivers/iio/light/bh1750.c b/drivers/iio/light/bh1750.c
3962 index 28347df78cff..adb5ab9e3439 100644
3963 --- a/drivers/iio/light/bh1750.c
3964 +++ b/drivers/iio/light/bh1750.c
3965 @@ -59,9 +59,9 @@ struct bh1750_chip_info {
3966
3967 u16 int_time_low_mask;
3968 u16 int_time_high_mask;
3969 -}
3970 +};
3971
3972 -static const bh1750_chip_info_tbl[] = {
3973 +static const struct bh1750_chip_info bh1750_chip_info_tbl[] = {
3974 [BH1710] = { 140, 1022, 300, 400, 250000000, 2, 0x001F, 0x03E0 },
3975 [BH1721] = { 140, 1020, 300, 400, 250000000, 2, 0x0010, 0x03E0 },
3976 [BH1750] = { 31, 254, 69, 1740, 57500000, 1, 0x001F, 0x00E0 },
3977 diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c
3978 index 2354302375de..52f53f3123b1 100644
3979 --- a/drivers/iio/pressure/cros_ec_baro.c
3980 +++ b/drivers/iio/pressure/cros_ec_baro.c
3981 @@ -114,6 +114,7 @@ static int cros_ec_baro_write(struct iio_dev *indio_dev,
3982 static const struct iio_info cros_ec_baro_info = {
3983 .read_raw = &cros_ec_baro_read,
3984 .write_raw = &cros_ec_baro_write,
3985 + .read_avail = &cros_ec_sensors_core_read_avail,
3986 };
3987
3988 static int cros_ec_baro_probe(struct platform_device *pdev)
3989 @@ -149,6 +150,8 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
3990 BIT(IIO_CHAN_INFO_SCALE) |
3991 BIT(IIO_CHAN_INFO_SAMP_FREQ) |
3992 BIT(IIO_CHAN_INFO_FREQUENCY);
3993 + channel->info_mask_shared_by_all_available =
3994 + BIT(IIO_CHAN_INFO_SAMP_FREQ);
3995 channel->scan_type.realbits = CROS_EC_SENSOR_BITS;
3996 channel->scan_type.storagebits = CROS_EC_SENSOR_BITS;
3997 channel->scan_type.shift = 0;
3998 diff --git a/drivers/iio/temperature/max31856.c b/drivers/iio/temperature/max31856.c
3999 index f184ba5601d9..73ed550e3fc9 100644
4000 --- a/drivers/iio/temperature/max31856.c
4001 +++ b/drivers/iio/temperature/max31856.c
4002 @@ -284,6 +284,8 @@ static int max31856_probe(struct spi_device *spi)
4003 spi_set_drvdata(spi, indio_dev);
4004
4005 indio_dev->info = &max31856_info;
4006 + indio_dev->dev.parent = &spi->dev;
4007 + indio_dev->dev.of_node = spi->dev.of_node;
4008 indio_dev->name = id->name;
4009 indio_dev->modes = INDIO_DIRECT_MODE;
4010 indio_dev->channels = max31856_channels;
4011 diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
4012 index 50a92442c4f7..2b5bd7206fc6 100644
4013 --- a/drivers/infiniband/core/device.c
4014 +++ b/drivers/infiniband/core/device.c
4015 @@ -1199,9 +1199,21 @@ static void setup_dma_device(struct ib_device *device)
4016 WARN_ON_ONCE(!parent);
4017 device->dma_device = parent;
4018 }
4019 - /* Setup default max segment size for all IB devices */
4020 - dma_set_max_seg_size(device->dma_device, SZ_2G);
4021
4022 + if (!device->dev.dma_parms) {
4023 + if (parent) {
4024 + /*
4025 + * The caller did not provide DMA parameters, so
4026 + * 'parent' probably represents a PCI device. The PCI
4027 + * core sets the maximum segment size to 64
4028 + * KB. Increase this parameter to 2 GB.
4029 + */
4030 + device->dev.dma_parms = parent->dma_parms;
4031 + dma_set_max_seg_size(device->dma_device, SZ_2G);
4032 + } else {
4033 + WARN_ON_ONCE(true);
4034 + }
4035 + }
4036 }
4037
4038 /*
4039 @@ -2397,8 +2409,12 @@ int ib_modify_port(struct ib_device *device,
4040 rc = device->ops.modify_port(device, port_num,
4041 port_modify_mask,
4042 port_modify);
4043 + else if (rdma_protocol_roce(device, port_num) &&
4044 + ((port_modify->set_port_cap_mask & ~IB_PORT_CM_SUP) == 0 ||
4045 + (port_modify->clr_port_cap_mask & ~IB_PORT_CM_SUP) == 0))
4046 + rc = 0;
4047 else
4048 - rc = rdma_protocol_roce(device, port_num) ? 0 : -ENOSYS;
4049 + rc = -EOPNOTSUPP;
4050 return rc;
4051 }
4052 EXPORT_SYMBOL(ib_modify_port);
4053 diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c
4054 index 30a54f8aa42c..27e2df44d043 100644
4055 --- a/drivers/infiniband/hw/bnxt_re/main.c
4056 +++ b/drivers/infiniband/hw/bnxt_re/main.c
4057 @@ -477,6 +477,7 @@ static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev,
4058 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_ALLOC, -1, -1);
4059 req.update_period_ms = cpu_to_le32(1000);
4060 req.stats_dma_addr = cpu_to_le64(dma_map);
4061 + req.stats_dma_length = cpu_to_le16(sizeof(struct ctx_hw_stats_ext));
4062 req.stat_ctx_flags = STAT_CTX_ALLOC_REQ_STAT_CTX_FLAGS_ROCE;
4063 bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
4064 sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
4065 @@ -1270,10 +1271,10 @@ static void bnxt_re_query_hwrm_intf_version(struct bnxt_re_dev *rdev)
4066 return;
4067 }
4068 rdev->qplib_ctx.hwrm_intf_ver =
4069 - (u64)resp.hwrm_intf_major << 48 |
4070 - (u64)resp.hwrm_intf_minor << 32 |
4071 - (u64)resp.hwrm_intf_build << 16 |
4072 - resp.hwrm_intf_patch;
4073 + (u64)le16_to_cpu(resp.hwrm_intf_major) << 48 |
4074 + (u64)le16_to_cpu(resp.hwrm_intf_minor) << 32 |
4075 + (u64)le16_to_cpu(resp.hwrm_intf_build) << 16 |
4076 + le16_to_cpu(resp.hwrm_intf_patch);
4077 }
4078
4079 static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev)
4080 diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.h b/drivers/infiniband/hw/bnxt_re/qplib_res.h
4081 index fbda11a7ab1a..aaa76d792185 100644
4082 --- a/drivers/infiniband/hw/bnxt_re/qplib_res.h
4083 +++ b/drivers/infiniband/hw/bnxt_re/qplib_res.h
4084 @@ -186,7 +186,9 @@ struct bnxt_qplib_chip_ctx {
4085 u8 chip_metal;
4086 };
4087
4088 -#define CHIP_NUM_57500 0x1750
4089 +#define CHIP_NUM_57508 0x1750
4090 +#define CHIP_NUM_57504 0x1751
4091 +#define CHIP_NUM_57502 0x1752
4092
4093 struct bnxt_qplib_res {
4094 struct pci_dev *pdev;
4095 @@ -203,7 +205,9 @@ struct bnxt_qplib_res {
4096
4097 static inline bool bnxt_qplib_is_chip_gen_p5(struct bnxt_qplib_chip_ctx *cctx)
4098 {
4099 - return (cctx->chip_num == CHIP_NUM_57500);
4100 + return (cctx->chip_num == CHIP_NUM_57508 ||
4101 + cctx->chip_num == CHIP_NUM_57504 ||
4102 + cctx->chip_num == CHIP_NUM_57502);
4103 }
4104
4105 static inline u8 bnxt_qplib_get_hwq_type(struct bnxt_qplib_res *res)
4106 diff --git a/drivers/infiniband/hw/efa/efa_com.c b/drivers/infiniband/hw/efa/efa_com.c
4107 index 3c412bc5b94f..0778f4f7dccd 100644
4108 --- a/drivers/infiniband/hw/efa/efa_com.c
4109 +++ b/drivers/infiniband/hw/efa/efa_com.c
4110 @@ -317,6 +317,7 @@ static struct efa_comp_ctx *__efa_com_submit_admin_cmd(struct efa_com_admin_queu
4111 struct efa_admin_acq_entry *comp,
4112 size_t comp_size_in_bytes)
4113 {
4114 + struct efa_admin_aq_entry *aqe;
4115 struct efa_comp_ctx *comp_ctx;
4116 u16 queue_size_mask;
4117 u16 cmd_id;
4118 @@ -350,7 +351,9 @@ static struct efa_comp_ctx *__efa_com_submit_admin_cmd(struct efa_com_admin_queu
4119
4120 reinit_completion(&comp_ctx->wait_event);
4121
4122 - memcpy(&aq->sq.entries[pi], cmd, cmd_size_in_bytes);
4123 + aqe = &aq->sq.entries[pi];
4124 + memset(aqe, 0, sizeof(*aqe));
4125 + memcpy(aqe, cmd, cmd_size_in_bytes);
4126
4127 aq->sq.pc++;
4128 atomic64_inc(&aq->stats.submitted_cmd);
4129 diff --git a/drivers/infiniband/hw/hns/hns_roce_restrack.c b/drivers/infiniband/hw/hns/hns_roce_restrack.c
4130 index 0a31d0a3d657..06871731ac43 100644
4131 --- a/drivers/infiniband/hw/hns/hns_roce_restrack.c
4132 +++ b/drivers/infiniband/hw/hns/hns_roce_restrack.c
4133 @@ -98,11 +98,15 @@ static int hns_roce_fill_res_cq_entry(struct sk_buff *msg,
4134 goto err;
4135
4136 table_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_DRIVER);
4137 - if (!table_attr)
4138 + if (!table_attr) {
4139 + ret = -EMSGSIZE;
4140 goto err;
4141 + }
4142
4143 - if (hns_roce_fill_cq(msg, context))
4144 + if (hns_roce_fill_cq(msg, context)) {
4145 + ret = -EMSGSIZE;
4146 goto err_cancel_table;
4147 + }
4148
4149 nla_nest_end(msg, table_attr);
4150 kfree(context);
4151 @@ -113,7 +117,7 @@ err_cancel_table:
4152 nla_nest_cancel(msg, table_attr);
4153 err:
4154 kfree(context);
4155 - return -EMSGSIZE;
4156 + return ret;
4157 }
4158
4159 int hns_roce_fill_res_entry(struct sk_buff *msg,
4160 diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
4161 index 43ea2c13b212..108667ae6b14 100644
4162 --- a/drivers/infiniband/hw/hns/hns_roce_srq.c
4163 +++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
4164 @@ -180,8 +180,7 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata,
4165 {
4166 struct hns_roce_dev *hr_dev = to_hr_dev(srq->ibsrq.device);
4167 struct hns_roce_ib_create_srq ucmd;
4168 - u32 page_shift;
4169 - u32 npages;
4170 + struct hns_roce_buf *buf;
4171 int ret;
4172
4173 if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd)))
4174 @@ -191,11 +190,13 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata,
4175 if (IS_ERR(srq->umem))
4176 return PTR_ERR(srq->umem);
4177
4178 - npages = (ib_umem_page_count(srq->umem) +
4179 - (1 << hr_dev->caps.srqwqe_buf_pg_sz) - 1) /
4180 - (1 << hr_dev->caps.srqwqe_buf_pg_sz);
4181 - page_shift = PAGE_SHIFT + hr_dev->caps.srqwqe_buf_pg_sz;
4182 - ret = hns_roce_mtt_init(hr_dev, npages, page_shift, &srq->mtt);
4183 + buf = &srq->buf;
4184 + buf->npages = (ib_umem_page_count(srq->umem) +
4185 + (1 << hr_dev->caps.srqwqe_buf_pg_sz) - 1) /
4186 + (1 << hr_dev->caps.srqwqe_buf_pg_sz);
4187 + buf->page_shift = PAGE_SHIFT + hr_dev->caps.srqwqe_buf_pg_sz;
4188 + ret = hns_roce_mtt_init(hr_dev, buf->npages, buf->page_shift,
4189 + &srq->mtt);
4190 if (ret)
4191 goto err_user_buf;
4192
4193 @@ -212,9 +213,12 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata,
4194 goto err_user_srq_mtt;
4195 }
4196
4197 - ret = hns_roce_mtt_init(hr_dev, ib_umem_page_count(srq->idx_que.umem),
4198 - PAGE_SHIFT, &srq->idx_que.mtt);
4199 -
4200 + buf = &srq->idx_que.idx_buf;
4201 + buf->npages = DIV_ROUND_UP(ib_umem_page_count(srq->idx_que.umem),
4202 + 1 << hr_dev->caps.idx_buf_pg_sz);
4203 + buf->page_shift = PAGE_SHIFT + hr_dev->caps.idx_buf_pg_sz;
4204 + ret = hns_roce_mtt_init(hr_dev, buf->npages, buf->page_shift,
4205 + &srq->idx_que.mtt);
4206 if (ret) {
4207 dev_err(hr_dev->dev, "hns_roce_mtt_init error for idx que\n");
4208 goto err_user_idx_mtt;
4209 diff --git a/drivers/infiniband/hw/qedr/main.c b/drivers/infiniband/hw/qedr/main.c
4210 index dc71b6e16a07..b462eaca1ee3 100644
4211 --- a/drivers/infiniband/hw/qedr/main.c
4212 +++ b/drivers/infiniband/hw/qedr/main.c
4213 @@ -357,6 +357,7 @@ static int qedr_alloc_resources(struct qedr_dev *dev)
4214 return -ENOMEM;
4215
4216 spin_lock_init(&dev->sgid_lock);
4217 + xa_init_flags(&dev->srqs, XA_FLAGS_LOCK_IRQ);
4218
4219 if (IS_IWARP(dev)) {
4220 xa_init_flags(&dev->qps, XA_FLAGS_LOCK_IRQ);
4221 diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
4222 index 6f3ce86019b7..a7ccca3c4f89 100644
4223 --- a/drivers/infiniband/hw/qedr/verbs.c
4224 +++ b/drivers/infiniband/hw/qedr/verbs.c
4225 @@ -1577,6 +1577,14 @@ static void qedr_cleanup_user(struct qedr_dev *dev, struct qedr_qp *qp)
4226
4227 ib_umem_release(qp->urq.umem);
4228 qp->urq.umem = NULL;
4229 +
4230 + if (rdma_protocol_roce(&dev->ibdev, 1)) {
4231 + qedr_free_pbl(dev, &qp->usq.pbl_info, qp->usq.pbl_tbl);
4232 + qedr_free_pbl(dev, &qp->urq.pbl_info, qp->urq.pbl_tbl);
4233 + } else {
4234 + kfree(qp->usq.pbl_tbl);
4235 + kfree(qp->urq.pbl_tbl);
4236 + }
4237 }
4238
4239 static int qedr_create_user_qp(struct qedr_dev *dev,
4240 @@ -2673,8 +2681,8 @@ int qedr_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)
4241
4242 dev->ops->rdma_free_tid(dev->rdma_ctx, mr->hw_mr.itid);
4243
4244 - if ((mr->type != QEDR_MR_DMA) && (mr->type != QEDR_MR_FRMR))
4245 - qedr_free_pbl(dev, &mr->info.pbl_info, mr->info.pbl_table);
4246 + if (mr->type != QEDR_MR_DMA)
4247 + free_mr_info(dev, &mr->info);
4248
4249 /* it could be user registered memory. */
4250 ib_umem_release(mr->umem);
4251 diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c
4252 index 05a92f997f60..fb01407a310f 100644
4253 --- a/drivers/infiniband/sw/siw/siw_main.c
4254 +++ b/drivers/infiniband/sw/siw/siw_main.c
4255 @@ -248,24 +248,6 @@ static struct ib_qp *siw_get_base_qp(struct ib_device *base_dev, int id)
4256 return NULL;
4257 }
4258
4259 -static void siw_verbs_sq_flush(struct ib_qp *base_qp)
4260 -{
4261 - struct siw_qp *qp = to_siw_qp(base_qp);
4262 -
4263 - down_write(&qp->state_lock);
4264 - siw_sq_flush(qp);
4265 - up_write(&qp->state_lock);
4266 -}
4267 -
4268 -static void siw_verbs_rq_flush(struct ib_qp *base_qp)
4269 -{
4270 - struct siw_qp *qp = to_siw_qp(base_qp);
4271 -
4272 - down_write(&qp->state_lock);
4273 - siw_rq_flush(qp);
4274 - up_write(&qp->state_lock);
4275 -}
4276 -
4277 static const struct ib_device_ops siw_device_ops = {
4278 .owner = THIS_MODULE,
4279 .uverbs_abi_ver = SIW_ABI_VERSION,
4280 @@ -284,8 +266,6 @@ static const struct ib_device_ops siw_device_ops = {
4281 .destroy_cq = siw_destroy_cq,
4282 .destroy_qp = siw_destroy_qp,
4283 .destroy_srq = siw_destroy_srq,
4284 - .drain_rq = siw_verbs_rq_flush,
4285 - .drain_sq = siw_verbs_sq_flush,
4286 .get_dma_mr = siw_get_dma_mr,
4287 .get_port_immutable = siw_get_port_immutable,
4288 .iw_accept = siw_accept,
4289 diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
4290 index b18a677832e1..1b1a40db529c 100644
4291 --- a/drivers/infiniband/sw/siw/siw_verbs.c
4292 +++ b/drivers/infiniband/sw/siw/siw_verbs.c
4293 @@ -685,6 +685,47 @@ static int siw_copy_inline_sgl(const struct ib_send_wr *core_wr,
4294 return bytes;
4295 }
4296
4297 +/* Complete SQ WR's without processing */
4298 +static int siw_sq_flush_wr(struct siw_qp *qp, const struct ib_send_wr *wr,
4299 + const struct ib_send_wr **bad_wr)
4300 +{
4301 + struct siw_sqe sqe = {};
4302 + int rv = 0;
4303 +
4304 + while (wr) {
4305 + sqe.id = wr->wr_id;
4306 + sqe.opcode = wr->opcode;
4307 + rv = siw_sqe_complete(qp, &sqe, 0, SIW_WC_WR_FLUSH_ERR);
4308 + if (rv) {
4309 + if (bad_wr)
4310 + *bad_wr = wr;
4311 + break;
4312 + }
4313 + wr = wr->next;
4314 + }
4315 + return rv;
4316 +}
4317 +
4318 +/* Complete RQ WR's without processing */
4319 +static int siw_rq_flush_wr(struct siw_qp *qp, const struct ib_recv_wr *wr,
4320 + const struct ib_recv_wr **bad_wr)
4321 +{
4322 + struct siw_rqe rqe = {};
4323 + int rv = 0;
4324 +
4325 + while (wr) {
4326 + rqe.id = wr->wr_id;
4327 + rv = siw_rqe_complete(qp, &rqe, 0, 0, SIW_WC_WR_FLUSH_ERR);
4328 + if (rv) {
4329 + if (bad_wr)
4330 + *bad_wr = wr;
4331 + break;
4332 + }
4333 + wr = wr->next;
4334 + }
4335 + return rv;
4336 +}
4337 +
4338 /*
4339 * siw_post_send()
4340 *
4341 @@ -703,26 +744,54 @@ int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,
4342 unsigned long flags;
4343 int rv = 0;
4344
4345 + if (wr && !qp->kernel_verbs) {
4346 + siw_dbg_qp(qp, "wr must be empty for user mapped sq\n");
4347 + *bad_wr = wr;
4348 + return -EINVAL;
4349 + }
4350 +
4351 /*
4352 * Try to acquire QP state lock. Must be non-blocking
4353 * to accommodate kernel clients needs.
4354 */
4355 if (!down_read_trylock(&qp->state_lock)) {
4356 - *bad_wr = wr;
4357 - siw_dbg_qp(qp, "QP locked, state %d\n", qp->attrs.state);
4358 - return -ENOTCONN;
4359 + if (qp->attrs.state == SIW_QP_STATE_ERROR) {
4360 + /*
4361 + * ERROR state is final, so we can be sure
4362 + * this state will not change as long as the QP
4363 + * exists.
4364 + *
4365 + * This handles an ib_drain_sq() call with
4366 + * a concurrent request to set the QP state
4367 + * to ERROR.
4368 + */
4369 + rv = siw_sq_flush_wr(qp, wr, bad_wr);
4370 + } else {
4371 + siw_dbg_qp(qp, "QP locked, state %d\n",
4372 + qp->attrs.state);
4373 + *bad_wr = wr;
4374 + rv = -ENOTCONN;
4375 + }
4376 + return rv;
4377 }
4378 if (unlikely(qp->attrs.state != SIW_QP_STATE_RTS)) {
4379 + if (qp->attrs.state == SIW_QP_STATE_ERROR) {
4380 + /*
4381 + * Immediately flush this WR to CQ, if QP
4382 + * is in ERROR state. SQ is guaranteed to
4383 + * be empty, so WR complets in-order.
4384 + *
4385 + * Typically triggered by ib_drain_sq().
4386 + */
4387 + rv = siw_sq_flush_wr(qp, wr, bad_wr);
4388 + } else {
4389 + siw_dbg_qp(qp, "QP out of state %d\n",
4390 + qp->attrs.state);
4391 + *bad_wr = wr;
4392 + rv = -ENOTCONN;
4393 + }
4394 up_read(&qp->state_lock);
4395 - *bad_wr = wr;
4396 - siw_dbg_qp(qp, "QP out of state %d\n", qp->attrs.state);
4397 - return -ENOTCONN;
4398 - }
4399 - if (wr && !qp->kernel_verbs) {
4400 - siw_dbg_qp(qp, "wr must be empty for user mapped sq\n");
4401 - up_read(&qp->state_lock);
4402 - *bad_wr = wr;
4403 - return -EINVAL;
4404 + return rv;
4405 }
4406 spin_lock_irqsave(&qp->sq_lock, flags);
4407
4408 @@ -917,24 +986,54 @@ int siw_post_receive(struct ib_qp *base_qp, const struct ib_recv_wr *wr,
4409 *bad_wr = wr;
4410 return -EOPNOTSUPP; /* what else from errno.h? */
4411 }
4412 + if (!qp->kernel_verbs) {
4413 + siw_dbg_qp(qp, "no kernel post_recv for user mapped sq\n");
4414 + *bad_wr = wr;
4415 + return -EINVAL;
4416 + }
4417 +
4418 /*
4419 * Try to acquire QP state lock. Must be non-blocking
4420 * to accommodate kernel clients needs.
4421 */
4422 if (!down_read_trylock(&qp->state_lock)) {
4423 - *bad_wr = wr;
4424 - return -ENOTCONN;
4425 - }
4426 - if (!qp->kernel_verbs) {
4427 - siw_dbg_qp(qp, "no kernel post_recv for user mapped sq\n");
4428 - up_read(&qp->state_lock);
4429 - *bad_wr = wr;
4430 - return -EINVAL;
4431 + if (qp->attrs.state == SIW_QP_STATE_ERROR) {
4432 + /*
4433 + * ERROR state is final, so we can be sure
4434 + * this state will not change as long as the QP
4435 + * exists.
4436 + *
4437 + * This handles an ib_drain_rq() call with
4438 + * a concurrent request to set the QP state
4439 + * to ERROR.
4440 + */
4441 + rv = siw_rq_flush_wr(qp, wr, bad_wr);
4442 + } else {
4443 + siw_dbg_qp(qp, "QP locked, state %d\n",
4444 + qp->attrs.state);
4445 + *bad_wr = wr;
4446 + rv = -ENOTCONN;
4447 + }
4448 + return rv;
4449 }
4450 if (qp->attrs.state > SIW_QP_STATE_RTS) {
4451 + if (qp->attrs.state == SIW_QP_STATE_ERROR) {
4452 + /*
4453 + * Immediately flush this WR to CQ, if QP
4454 + * is in ERROR state. RQ is guaranteed to
4455 + * be empty, so WR complets in-order.
4456 + *
4457 + * Typically triggered by ib_drain_rq().
4458 + */
4459 + rv = siw_rq_flush_wr(qp, wr, bad_wr);
4460 + } else {
4461 + siw_dbg_qp(qp, "QP out of state %d\n",
4462 + qp->attrs.state);
4463 + *bad_wr = wr;
4464 + rv = -ENOTCONN;
4465 + }
4466 up_read(&qp->state_lock);
4467 - *bad_wr = wr;
4468 - return -EINVAL;
4469 + return rv;
4470 }
4471 /*
4472 * Serialize potentially multiple producers.
4473 diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
4474 index 2e72fc5af157..c4c015c60446 100644
4475 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c
4476 +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
4477 @@ -646,6 +646,7 @@ iscsi_iser_session_create(struct iscsi_endpoint *ep,
4478 if (ib_conn->pi_support) {
4479 u32 sig_caps = ib_dev->attrs.sig_prot_cap;
4480
4481 + shost->sg_prot_tablesize = shost->sg_tablesize;
4482 scsi_host_set_prot(shost, iser_dif_prot_caps(sig_caps));
4483 scsi_host_set_guard(shost, SHOST_DIX_GUARD_IP |
4484 SHOST_DIX_GUARD_CRC);
4485 diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
4486 index 6db6d969e31c..4ce797d4259f 100644
4487 --- a/drivers/iommu/intel-iommu.c
4488 +++ b/drivers/iommu/intel-iommu.c
4489 @@ -5447,9 +5447,6 @@ static int intel_iommu_map(struct iommu_domain *domain,
4490 int prot = 0;
4491 int ret;
4492
4493 - if (dmar_domain->flags & DOMAIN_FLAG_LOSE_CHILDREN)
4494 - return -EINVAL;
4495 -
4496 if (iommu_prot & IOMMU_READ)
4497 prot |= DMA_PTE_READ;
4498 if (iommu_prot & IOMMU_WRITE)
4499 @@ -5492,8 +5489,6 @@ static size_t intel_iommu_unmap(struct iommu_domain *domain,
4500 /* Cope with horrid API which requires us to unmap more than the
4501 size argument if it happens to be a large-page mapping. */
4502 BUG_ON(!pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, &level));
4503 - if (dmar_domain->flags & DOMAIN_FLAG_LOSE_CHILDREN)
4504 - return 0;
4505
4506 if (size < VTD_PAGE_SIZE << level_to_offset_bits(level))
4507 size = VTD_PAGE_SIZE << level_to_offset_bits(level);
4508 @@ -5525,9 +5520,6 @@ static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain,
4509 int level = 0;
4510 u64 phys = 0;
4511
4512 - if (dmar_domain->flags & DOMAIN_FLAG_LOSE_CHILDREN)
4513 - return 0;
4514 -
4515 pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, &level);
4516 if (pte)
4517 phys = dma_pte_addr(pte);
4518 @@ -5705,8 +5697,8 @@ static void intel_iommu_get_resv_regions(struct device *device,
4519 struct pci_dev *pdev = to_pci_dev(device);
4520
4521 if ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) {
4522 - reg = iommu_alloc_resv_region(0, 1UL << 24, 0,
4523 - IOMMU_RESV_DIRECT);
4524 + reg = iommu_alloc_resv_region(0, 1UL << 24, prot,
4525 + IOMMU_RESV_DIRECT_RELAXABLE);
4526 if (reg)
4527 list_add_tail(&reg->list, head);
4528 }
4529 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
4530 index d658c7c6a2ab..24248aa8a7e5 100644
4531 --- a/drivers/iommu/iommu.c
4532 +++ b/drivers/iommu/iommu.c
4533 @@ -312,8 +312,8 @@ int iommu_insert_resv_region(struct iommu_resv_region *new,
4534 list_for_each_entry_safe(iter, tmp, regions, list) {
4535 phys_addr_t top_end, iter_end = iter->start + iter->length - 1;
4536
4537 - /* no merge needed on elements of different types than @nr */
4538 - if (iter->type != nr->type) {
4539 + /* no merge needed on elements of different types than @new */
4540 + if (iter->type != new->type) {
4541 list_move_tail(&iter->list, &stack);
4542 continue;
4543 }
4544 @@ -2221,13 +2221,13 @@ request_default_domain_for_dev(struct device *dev, unsigned long type)
4545 goto out;
4546 }
4547
4548 - iommu_group_create_direct_mappings(group, dev);
4549 -
4550 /* Make the domain the default for this group */
4551 if (group->default_domain)
4552 iommu_domain_free(group->default_domain);
4553 group->default_domain = domain;
4554
4555 + iommu_group_create_direct_mappings(group, dev);
4556 +
4557 dev_info(dev, "Using iommu %s mapping\n",
4558 type == IOMMU_DOMAIN_DMA ? "dma" : "direct");
4559
4560 diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
4561 index 6f776823b9ba..a1df0d95151c 100644
4562 --- a/drivers/md/bcache/alloc.c
4563 +++ b/drivers/md/bcache/alloc.c
4564 @@ -377,7 +377,10 @@ retry_invalidate:
4565 if (!fifo_full(&ca->free_inc))
4566 goto retry_invalidate;
4567
4568 - bch_prio_write(ca);
4569 + if (bch_prio_write(ca, false) < 0) {
4570 + ca->invalidate_needs_gc = 1;
4571 + wake_up_gc(ca->set);
4572 + }
4573 }
4574 }
4575 out:
4576 diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
4577 index 013e35a9e317..deb924e1d790 100644
4578 --- a/drivers/md/bcache/bcache.h
4579 +++ b/drivers/md/bcache/bcache.h
4580 @@ -977,7 +977,7 @@ bool bch_cached_dev_error(struct cached_dev *dc);
4581 __printf(2, 3)
4582 bool bch_cache_set_error(struct cache_set *c, const char *fmt, ...);
4583
4584 -void bch_prio_write(struct cache *ca);
4585 +int bch_prio_write(struct cache *ca, bool wait);
4586 void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent);
4587
4588 extern struct workqueue_struct *bcache_wq;
4589 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
4590 index 20ed838e9413..64999c7a8033 100644
4591 --- a/drivers/md/bcache/super.c
4592 +++ b/drivers/md/bcache/super.c
4593 @@ -529,12 +529,29 @@ static void prio_io(struct cache *ca, uint64_t bucket, int op,
4594 closure_sync(cl);
4595 }
4596
4597 -void bch_prio_write(struct cache *ca)
4598 +int bch_prio_write(struct cache *ca, bool wait)
4599 {
4600 int i;
4601 struct bucket *b;
4602 struct closure cl;
4603
4604 + pr_debug("free_prio=%zu, free_none=%zu, free_inc=%zu",
4605 + fifo_used(&ca->free[RESERVE_PRIO]),
4606 + fifo_used(&ca->free[RESERVE_NONE]),
4607 + fifo_used(&ca->free_inc));
4608 +
4609 + /*
4610 + * Pre-check if there are enough free buckets. In the non-blocking
4611 + * scenario it's better to fail early rather than starting to allocate
4612 + * buckets and do a cleanup later in case of failure.
4613 + */
4614 + if (!wait) {
4615 + size_t avail = fifo_used(&ca->free[RESERVE_PRIO]) +
4616 + fifo_used(&ca->free[RESERVE_NONE]);
4617 + if (prio_buckets(ca) > avail)
4618 + return -ENOMEM;
4619 + }
4620 +
4621 closure_init_stack(&cl);
4622
4623 lockdep_assert_held(&ca->set->bucket_lock);
4624 @@ -544,9 +561,6 @@ void bch_prio_write(struct cache *ca)
4625 atomic_long_add(ca->sb.bucket_size * prio_buckets(ca),
4626 &ca->meta_sectors_written);
4627
4628 - //pr_debug("free %zu, free_inc %zu, unused %zu", fifo_used(&ca->free),
4629 - // fifo_used(&ca->free_inc), fifo_used(&ca->unused));
4630 -
4631 for (i = prio_buckets(ca) - 1; i >= 0; --i) {
4632 long bucket;
4633 struct prio_set *p = ca->disk_buckets;
4634 @@ -564,7 +578,7 @@ void bch_prio_write(struct cache *ca)
4635 p->magic = pset_magic(&ca->sb);
4636 p->csum = bch_crc64(&p->magic, bucket_bytes(ca) - 8);
4637
4638 - bucket = bch_bucket_alloc(ca, RESERVE_PRIO, true);
4639 + bucket = bch_bucket_alloc(ca, RESERVE_PRIO, wait);
4640 BUG_ON(bucket == -1);
4641
4642 mutex_unlock(&ca->set->bucket_lock);
4643 @@ -593,6 +607,7 @@ void bch_prio_write(struct cache *ca)
4644
4645 ca->prio_last_buckets[i] = ca->prio_buckets[i];
4646 }
4647 + return 0;
4648 }
4649
4650 static void prio_read(struct cache *ca, uint64_t bucket)
4651 @@ -761,20 +776,28 @@ static inline int idx_to_first_minor(int idx)
4652
4653 static void bcache_device_free(struct bcache_device *d)
4654 {
4655 + struct gendisk *disk = d->disk;
4656 +
4657 lockdep_assert_held(&bch_register_lock);
4658
4659 - pr_info("%s stopped", d->disk->disk_name);
4660 + if (disk)
4661 + pr_info("%s stopped", disk->disk_name);
4662 + else
4663 + pr_err("bcache device (NULL gendisk) stopped");
4664
4665 if (d->c)
4666 bcache_device_detach(d);
4667 - if (d->disk && d->disk->flags & GENHD_FL_UP)
4668 - del_gendisk(d->disk);
4669 - if (d->disk && d->disk->queue)
4670 - blk_cleanup_queue(d->disk->queue);
4671 - if (d->disk) {
4672 +
4673 + if (disk) {
4674 + if (disk->flags & GENHD_FL_UP)
4675 + del_gendisk(disk);
4676 +
4677 + if (disk->queue)
4678 + blk_cleanup_queue(disk->queue);
4679 +
4680 ida_simple_remove(&bcache_device_idx,
4681 - first_minor_to_idx(d->disk->first_minor));
4682 - put_disk(d->disk);
4683 + first_minor_to_idx(disk->first_minor));
4684 + put_disk(disk);
4685 }
4686
4687 bioset_exit(&d->bio_split);
4688 @@ -1954,7 +1977,7 @@ static int run_cache_set(struct cache_set *c)
4689
4690 mutex_lock(&c->bucket_lock);
4691 for_each_cache(ca, c, i)
4692 - bch_prio_write(ca);
4693 + bch_prio_write(ca, true);
4694 mutex_unlock(&c->bucket_lock);
4695
4696 err = "cannot allocate new UUID bucket";
4697 diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
4698 index b092c7b5282f..3ad18246fcb3 100644
4699 --- a/drivers/md/md-bitmap.c
4700 +++ b/drivers/md/md-bitmap.c
4701 @@ -2139,6 +2139,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
4702 memcpy(page_address(store.sb_page),
4703 page_address(bitmap->storage.sb_page),
4704 sizeof(bitmap_super_t));
4705 + spin_lock_irq(&bitmap->counts.lock);
4706 md_bitmap_file_unmap(&bitmap->storage);
4707 bitmap->storage = store;
4708
4709 @@ -2154,7 +2155,6 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
4710 blocks = min(old_counts.chunks << old_counts.chunkshift,
4711 chunks << chunkshift);
4712
4713 - spin_lock_irq(&bitmap->counts.lock);
4714 /* For cluster raid, need to pre-allocate bitmap */
4715 if (mddev_is_clustered(bitmap->mddev)) {
4716 unsigned long page;
4717 diff --git a/drivers/md/md.c b/drivers/md/md.c
4718 index b8dd56b746da..805b33e27496 100644
4719 --- a/drivers/md/md.c
4720 +++ b/drivers/md/md.c
4721 @@ -1105,6 +1105,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
4722 char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
4723 mdp_super_t *sb;
4724 int ret;
4725 + bool spare_disk = true;
4726
4727 /*
4728 * Calculate the position of the superblock (512byte sectors),
4729 @@ -1155,8 +1156,18 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
4730 else
4731 rdev->desc_nr = sb->this_disk.number;
4732
4733 + /* not spare disk, or LEVEL_MULTIPATH */
4734 + if (sb->level == LEVEL_MULTIPATH ||
4735 + (rdev->desc_nr >= 0 &&
4736 + sb->disks[rdev->desc_nr].state &
4737 + ((1<<MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE))))
4738 + spare_disk = false;
4739 +
4740 if (!refdev) {
4741 - ret = 1;
4742 + if (!spare_disk)
4743 + ret = 1;
4744 + else
4745 + ret = 0;
4746 } else {
4747 __u64 ev1, ev2;
4748 mdp_super_t *refsb = page_address(refdev->sb_page);
4749 @@ -1172,7 +1183,8 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
4750 }
4751 ev1 = md_event(sb);
4752 ev2 = md_event(refsb);
4753 - if (ev1 > ev2)
4754 +
4755 + if (!spare_disk && ev1 > ev2)
4756 ret = 1;
4757 else
4758 ret = 0;
4759 @@ -1532,6 +1544,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
4760 sector_t sectors;
4761 char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
4762 int bmask;
4763 + bool spare_disk = true;
4764
4765 /*
4766 * Calculate the position of the superblock in 512byte sectors.
4767 @@ -1665,8 +1678,19 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
4768 sb->level != 0)
4769 return -EINVAL;
4770
4771 + /* not spare disk, or LEVEL_MULTIPATH */
4772 + if (sb->level == cpu_to_le32(LEVEL_MULTIPATH) ||
4773 + (rdev->desc_nr >= 0 &&
4774 + rdev->desc_nr < le32_to_cpu(sb->max_dev) &&
4775 + (le16_to_cpu(sb->dev_roles[rdev->desc_nr]) < MD_DISK_ROLE_MAX ||
4776 + le16_to_cpu(sb->dev_roles[rdev->desc_nr]) == MD_DISK_ROLE_JOURNAL)))
4777 + spare_disk = false;
4778 +
4779 if (!refdev) {
4780 - ret = 1;
4781 + if (!spare_disk)
4782 + ret = 1;
4783 + else
4784 + ret = 0;
4785 } else {
4786 __u64 ev1, ev2;
4787 struct mdp_superblock_1 *refsb = page_address(refdev->sb_page);
4788 @@ -1683,7 +1707,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
4789 ev1 = le64_to_cpu(sb->events);
4790 ev2 = le64_to_cpu(refsb->events);
4791
4792 - if (ev1 > ev2)
4793 + if (!spare_disk && ev1 > ev2)
4794 ret = 1;
4795 else
4796 ret = 0;
4797 @@ -3604,7 +3628,7 @@ abort_free:
4798 * Check a full RAID array for plausibility
4799 */
4800
4801 -static void analyze_sbs(struct mddev *mddev)
4802 +static int analyze_sbs(struct mddev *mddev)
4803 {
4804 int i;
4805 struct md_rdev *rdev, *freshest, *tmp;
4806 @@ -3625,6 +3649,12 @@ static void analyze_sbs(struct mddev *mddev)
4807 md_kick_rdev_from_array(rdev);
4808 }
4809
4810 + /* Cannot find a valid fresh disk */
4811 + if (!freshest) {
4812 + pr_warn("md: cannot find a valid disk\n");
4813 + return -EINVAL;
4814 + }
4815 +
4816 super_types[mddev->major_version].
4817 validate_super(mddev, freshest);
4818
4819 @@ -3659,6 +3689,8 @@ static void analyze_sbs(struct mddev *mddev)
4820 clear_bit(In_sync, &rdev->flags);
4821 }
4822 }
4823 +
4824 + return 0;
4825 }
4826
4827 /* Read a fixed-point number.
4828 @@ -5577,7 +5609,9 @@ int md_run(struct mddev *mddev)
4829 if (!mddev->raid_disks) {
4830 if (!mddev->persistent)
4831 return -EINVAL;
4832 - analyze_sbs(mddev);
4833 + err = analyze_sbs(mddev);
4834 + if (err)
4835 + return -EINVAL;
4836 }
4837
4838 if (mddev->level != LEVEL_NONE)
4839 diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
4840 index 7eee1812bba3..fcffcc31d168 100644
4841 --- a/drivers/media/i2c/Kconfig
4842 +++ b/drivers/media/i2c/Kconfig
4843 @@ -1113,6 +1113,7 @@ comment "SDR tuner chips"
4844 config SDR_MAX2175
4845 tristate "Maxim 2175 RF to Bits tuner"
4846 depends on VIDEO_V4L2 && MEDIA_SDR_SUPPORT && I2C
4847 + select REGMAP_I2C
4848 help
4849 Support for Maxim 2175 tuner. It is an advanced analog/digital
4850 radio receiver with RF-to-Bits front-end designed for SDR solutions.
4851 diff --git a/drivers/media/i2c/ad5820.c b/drivers/media/i2c/ad5820.c
4852 index 925c171e7797..7a49651f4d1f 100644
4853 --- a/drivers/media/i2c/ad5820.c
4854 +++ b/drivers/media/i2c/ad5820.c
4855 @@ -309,6 +309,7 @@ static int ad5820_probe(struct i2c_client *client,
4856 v4l2_i2c_subdev_init(&coil->subdev, client, &ad5820_ops);
4857 coil->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
4858 coil->subdev.internal_ops = &ad5820_internal_ops;
4859 + coil->subdev.entity.function = MEDIA_ENT_F_LENS;
4860 strscpy(coil->subdev.name, "ad5820 focus", sizeof(coil->subdev.name));
4861
4862 ret = media_entity_pads_init(&coil->subdev.entity, 0, NULL);
4863 diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
4864 index f4ded0669ff9..e1ff38009cf0 100644
4865 --- a/drivers/media/i2c/ov2659.c
4866 +++ b/drivers/media/i2c/ov2659.c
4867 @@ -419,10 +419,14 @@ static struct sensor_register ov2659_720p[] = {
4868 { REG_TIMING_YINC, 0x11 },
4869 { REG_TIMING_VERT_FORMAT, 0x80 },
4870 { REG_TIMING_HORIZ_FORMAT, 0x00 },
4871 + { 0x370a, 0x12 },
4872 { 0x3a03, 0xe8 },
4873 { 0x3a09, 0x6f },
4874 { 0x3a0b, 0x5d },
4875 { 0x3a15, 0x9a },
4876 + { REG_VFIFO_READ_START_H, 0x00 },
4877 + { REG_VFIFO_READ_START_L, 0x80 },
4878 + { REG_ISP_CTRL02, 0x00 },
4879 { REG_NULL, 0x00 },
4880 };
4881
4882 @@ -1201,11 +1205,15 @@ static int ov2659_s_stream(struct v4l2_subdev *sd, int on)
4883 goto unlock;
4884 }
4885
4886 - ov2659_set_pixel_clock(ov2659);
4887 - ov2659_set_frame_size(ov2659);
4888 - ov2659_set_format(ov2659);
4889 - ov2659_set_streaming(ov2659, 1);
4890 - ov2659->streaming = on;
4891 + ret = ov2659_set_pixel_clock(ov2659);
4892 + if (!ret)
4893 + ret = ov2659_set_frame_size(ov2659);
4894 + if (!ret)
4895 + ret = ov2659_set_format(ov2659);
4896 + if (!ret) {
4897 + ov2659_set_streaming(ov2659, 1);
4898 + ov2659->streaming = on;
4899 + }
4900
4901 unlock:
4902 mutex_unlock(&ov2659->lock);
4903 diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
4904 index 500d9bbff10b..18dd2d717088 100644
4905 --- a/drivers/media/i2c/ov5640.c
4906 +++ b/drivers/media/i2c/ov5640.c
4907 @@ -1611,6 +1611,11 @@ ov5640_find_mode(struct ov5640_dev *sensor, enum ov5640_frame_rate fr,
4908 !(mode->hact == 640 && mode->vact == 480))
4909 return NULL;
4910
4911 + /* 2592x1944 only works at 15fps max */
4912 + if ((mode->hact == 2592 && mode->vact == 1944) &&
4913 + fr > OV5640_15_FPS)
4914 + return NULL;
4915 +
4916 return mode;
4917 }
4918
4919 diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
4920 index 5b9af5e5b7f1..a5b2448c0abc 100644
4921 --- a/drivers/media/i2c/ov6650.c
4922 +++ b/drivers/media/i2c/ov6650.c
4923 @@ -130,6 +130,7 @@
4924 #define CLKRC_24MHz 0xc0
4925 #define CLKRC_DIV_MASK 0x3f
4926 #define GET_CLKRC_DIV(x) (((x) & CLKRC_DIV_MASK) + 1)
4927 +#define DEF_CLKRC 0x00
4928
4929 #define COMA_RESET BIT(7)
4930 #define COMA_QCIF BIT(5)
4931 @@ -465,38 +466,39 @@ static int ov6650_set_selection(struct v4l2_subdev *sd,
4932 {
4933 struct i2c_client *client = v4l2_get_subdevdata(sd);
4934 struct ov6650 *priv = to_ov6650(client);
4935 - struct v4l2_rect rect = sel->r;
4936 int ret;
4937
4938 if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE ||
4939 sel->target != V4L2_SEL_TGT_CROP)
4940 return -EINVAL;
4941
4942 - v4l_bound_align_image(&rect.width, 2, W_CIF, 1,
4943 - &rect.height, 2, H_CIF, 1, 0);
4944 - v4l_bound_align_image(&rect.left, DEF_HSTRT << 1,
4945 - (DEF_HSTRT << 1) + W_CIF - (__s32)rect.width, 1,
4946 - &rect.top, DEF_VSTRT << 1,
4947 - (DEF_VSTRT << 1) + H_CIF - (__s32)rect.height, 1,
4948 - 0);
4949 + v4l_bound_align_image(&sel->r.width, 2, W_CIF, 1,
4950 + &sel->r.height, 2, H_CIF, 1, 0);
4951 + v4l_bound_align_image(&sel->r.left, DEF_HSTRT << 1,
4952 + (DEF_HSTRT << 1) + W_CIF - (__s32)sel->r.width, 1,
4953 + &sel->r.top, DEF_VSTRT << 1,
4954 + (DEF_VSTRT << 1) + H_CIF - (__s32)sel->r.height,
4955 + 1, 0);
4956
4957 - ret = ov6650_reg_write(client, REG_HSTRT, rect.left >> 1);
4958 + ret = ov6650_reg_write(client, REG_HSTRT, sel->r.left >> 1);
4959 if (!ret) {
4960 - priv->rect.left = rect.left;
4961 + priv->rect.width += priv->rect.left - sel->r.left;
4962 + priv->rect.left = sel->r.left;
4963 ret = ov6650_reg_write(client, REG_HSTOP,
4964 - (rect.left + rect.width) >> 1);
4965 + (sel->r.left + sel->r.width) >> 1);
4966 }
4967 if (!ret) {
4968 - priv->rect.width = rect.width;
4969 - ret = ov6650_reg_write(client, REG_VSTRT, rect.top >> 1);
4970 + priv->rect.width = sel->r.width;
4971 + ret = ov6650_reg_write(client, REG_VSTRT, sel->r.top >> 1);
4972 }
4973 if (!ret) {
4974 - priv->rect.top = rect.top;
4975 + priv->rect.height += priv->rect.top - sel->r.top;
4976 + priv->rect.top = sel->r.top;
4977 ret = ov6650_reg_write(client, REG_VSTOP,
4978 - (rect.top + rect.height) >> 1);
4979 + (sel->r.top + sel->r.height) >> 1);
4980 }
4981 if (!ret)
4982 - priv->rect.height = rect.height;
4983 + priv->rect.height = sel->r.height;
4984
4985 return ret;
4986 }
4987 @@ -610,7 +612,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
4988 dev_err(&client->dev, "Pixel format not handled: 0x%x\n", code);
4989 return -EINVAL;
4990 }
4991 - priv->code = code;
4992
4993 if (code == MEDIA_BUS_FMT_Y8_1X8 ||
4994 code == MEDIA_BUS_FMT_SBGGR8_1X8) {
4995 @@ -636,7 +637,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
4996 dev_dbg(&client->dev, "max resolution: CIF\n");
4997 coma_mask |= COMA_QCIF;
4998 }
4999 - priv->half_scale = half_scale;
5000
5001 clkrc = CLKRC_12MHz;
5002 mclk = 12000000;
5003 @@ -654,8 +654,13 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
5004 ret = ov6650_reg_rmw(client, REG_COMA, coma_set, coma_mask);
5005 if (!ret)
5006 ret = ov6650_reg_write(client, REG_CLKRC, clkrc);
5007 - if (!ret)
5008 + if (!ret) {
5009 + priv->half_scale = half_scale;
5010 +
5011 ret = ov6650_reg_rmw(client, REG_COML, coml_set, coml_mask);
5012 + }
5013 + if (!ret)
5014 + priv->code = code;
5015
5016 if (!ret) {
5017 mf->colorspace = priv->colorspace;
5018 @@ -754,19 +759,17 @@ static int ov6650_s_frame_interval(struct v4l2_subdev *sd,
5019 else if (div > GET_CLKRC_DIV(CLKRC_DIV_MASK))
5020 div = GET_CLKRC_DIV(CLKRC_DIV_MASK);
5021
5022 - /*
5023 - * Keep result to be used as tpf limit
5024 - * for subsequent clock divider calculations
5025 - */
5026 - priv->tpf.numerator = div;
5027 - priv->tpf.denominator = FRAME_RATE_MAX;
5028 + tpf->numerator = div;
5029 + tpf->denominator = FRAME_RATE_MAX;
5030
5031 - clkrc = to_clkrc(&priv->tpf, priv->pclk_limit, priv->pclk_max);
5032 + clkrc = to_clkrc(tpf, priv->pclk_limit, priv->pclk_max);
5033
5034 ret = ov6650_reg_rmw(client, REG_CLKRC, clkrc, CLKRC_DIV_MASK);
5035 if (!ret) {
5036 - tpf->numerator = GET_CLKRC_DIV(clkrc);
5037 - tpf->denominator = FRAME_RATE_MAX;
5038 + priv->tpf.numerator = GET_CLKRC_DIV(clkrc);
5039 + priv->tpf.denominator = FRAME_RATE_MAX;
5040 +
5041 + *tpf = priv->tpf;
5042 }
5043
5044 return ret;
5045 @@ -989,8 +992,10 @@ static int ov6650_probe(struct i2c_client *client,
5046 V4L2_CID_GAMMA, 0, 0xff, 1, 0x12);
5047
5048 priv->subdev.ctrl_handler = &priv->hdl;
5049 - if (priv->hdl.error)
5050 - return priv->hdl.error;
5051 + if (priv->hdl.error) {
5052 + ret = priv->hdl.error;
5053 + goto ectlhdlfree;
5054 + }
5055
5056 v4l2_ctrl_auto_cluster(2, &priv->autogain, 0, true);
5057 v4l2_ctrl_auto_cluster(3, &priv->autowb, 0, true);
5058 @@ -1005,11 +1010,17 @@ static int ov6650_probe(struct i2c_client *client,
5059 priv->code = MEDIA_BUS_FMT_YUYV8_2X8;
5060 priv->colorspace = V4L2_COLORSPACE_JPEG;
5061
5062 + /* Hardware default frame interval */
5063 + priv->tpf.numerator = GET_CLKRC_DIV(DEF_CLKRC);
5064 + priv->tpf.denominator = FRAME_RATE_MAX;
5065 +
5066 priv->subdev.internal_ops = &ov6650_internal_ops;
5067
5068 ret = v4l2_async_register_subdev(&priv->subdev);
5069 - if (ret)
5070 - v4l2_ctrl_handler_free(&priv->hdl);
5071 + if (!ret)
5072 + return 0;
5073 +ectlhdlfree:
5074 + v4l2_ctrl_handler_free(&priv->hdl);
5075
5076 return ret;
5077 }
5078 diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
5079 index 9adf8e034e7d..42805dfbffeb 100644
5080 --- a/drivers/media/i2c/smiapp/smiapp-core.c
5081 +++ b/drivers/media/i2c/smiapp/smiapp-core.c
5082 @@ -3101,19 +3101,23 @@ static int smiapp_probe(struct i2c_client *client)
5083 if (rval < 0)
5084 goto out_media_entity_cleanup;
5085
5086 - rval = v4l2_async_register_subdev_sensor_common(&sensor->src->sd);
5087 - if (rval < 0)
5088 - goto out_media_entity_cleanup;
5089 -
5090 pm_runtime_set_active(&client->dev);
5091 pm_runtime_get_noresume(&client->dev);
5092 pm_runtime_enable(&client->dev);
5093 +
5094 + rval = v4l2_async_register_subdev_sensor_common(&sensor->src->sd);
5095 + if (rval < 0)
5096 + goto out_disable_runtime_pm;
5097 +
5098 pm_runtime_set_autosuspend_delay(&client->dev, 1000);
5099 pm_runtime_use_autosuspend(&client->dev);
5100 pm_runtime_put_autosuspend(&client->dev);
5101
5102 return 0;
5103
5104 +out_disable_runtime_pm:
5105 + pm_runtime_disable(&client->dev);
5106 +
5107 out_media_entity_cleanup:
5108 media_entity_cleanup(&sensor->src->sd.entity);
5109
5110 diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
5111 index 81285b8d5cfb..003ba22334cd 100644
5112 --- a/drivers/media/i2c/st-mipid02.c
5113 +++ b/drivers/media/i2c/st-mipid02.c
5114 @@ -971,6 +971,11 @@ static int mipid02_probe(struct i2c_client *client)
5115 bridge->reset_gpio = devm_gpiod_get_optional(dev, "reset",
5116 GPIOD_OUT_HIGH);
5117
5118 + if (IS_ERR(bridge->reset_gpio)) {
5119 + dev_err(dev, "failed to get reset GPIO\n");
5120 + return PTR_ERR(bridge->reset_gpio);
5121 + }
5122 +
5123 ret = mipid02_get_regulators(bridge);
5124 if (ret) {
5125 dev_err(dev, "failed to get regulators %d", ret);
5126 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
5127 index dcc0f02aeb70..b8abcd550604 100644
5128 --- a/drivers/media/pci/cx88/cx88-video.c
5129 +++ b/drivers/media/pci/cx88/cx88-video.c
5130 @@ -1277,7 +1277,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
5131 core = cx88_core_get(dev->pci);
5132 if (!core) {
5133 err = -EINVAL;
5134 - goto fail_free;
5135 + goto fail_disable;
5136 }
5137 dev->core = core;
5138
5139 @@ -1323,7 +1323,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
5140 cc->step, cc->default_value);
5141 if (!vc) {
5142 err = core->audio_hdl.error;
5143 - goto fail_core;
5144 + goto fail_irq;
5145 }
5146 vc->priv = (void *)cc;
5147 }
5148 @@ -1337,7 +1337,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
5149 cc->step, cc->default_value);
5150 if (!vc) {
5151 err = core->video_hdl.error;
5152 - goto fail_core;
5153 + goto fail_irq;
5154 }
5155 vc->priv = (void *)cc;
5156 if (vc->id == V4L2_CID_CHROMA_AGC)
5157 @@ -1509,11 +1509,14 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
5158
5159 fail_unreg:
5160 cx8800_unregister_video(dev);
5161 - free_irq(pci_dev->irq, dev);
5162 mutex_unlock(&core->lock);
5163 +fail_irq:
5164 + free_irq(pci_dev->irq, dev);
5165 fail_core:
5166 core->v4ldev = NULL;
5167 cx88_core_put(core, dev->pci);
5168 +fail_disable:
5169 + pci_disable_device(pci_dev);
5170 fail_free:
5171 kfree(dev);
5172 return err;
5173 diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
5174 index 2b42ba1f5949..e13dbf27a9c2 100644
5175 --- a/drivers/media/platform/am437x/am437x-vpfe.c
5176 +++ b/drivers/media/platform/am437x/am437x-vpfe.c
5177 @@ -1830,6 +1830,10 @@ static int vpfe_s_std(struct file *file, void *priv, v4l2_std_id std_id)
5178 if (!(sdinfo->inputs[0].capabilities & V4L2_IN_CAP_STD))
5179 return -ENODATA;
5180
5181 + /* if trying to set the same std then nothing to do */
5182 + if (vpfe_standards[vpfe->std_index].std_id == std_id)
5183 + return 0;
5184 +
5185 /* If streaming is started, return error */
5186 if (vb2_is_busy(&vpfe->buffer_queue)) {
5187 vpfe_err(vpfe, "%s device busy\n", __func__);
5188 diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
5189 index eb12f3793062..096a7c9a8963 100644
5190 --- a/drivers/media/platform/aspeed-video.c
5191 +++ b/drivers/media/platform/aspeed-video.c
5192 @@ -606,6 +606,16 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg)
5193 aspeed_video_start_frame(video);
5194 }
5195
5196 + /*
5197 + * CAPTURE_COMPLETE and FRAME_COMPLETE interrupts come even when these
5198 + * are disabled in the VE_INTERRUPT_CTRL register so clear them to
5199 + * prevent unnecessary interrupt calls.
5200 + */
5201 + if (sts & VE_INTERRUPT_CAPTURE_COMPLETE)
5202 + sts &= ~VE_INTERRUPT_CAPTURE_COMPLETE;
5203 + if (sts & VE_INTERRUPT_FRAME_COMPLETE)
5204 + sts &= ~VE_INTERRUPT_FRAME_COMPLETE;
5205 +
5206 return sts ? IRQ_NONE : IRQ_HANDLED;
5207 }
5208
5209 @@ -741,6 +751,8 @@ static void aspeed_video_get_resolution(struct aspeed_video *video)
5210 }
5211
5212 set_bit(VIDEO_RES_DETECT, &video->flags);
5213 + aspeed_video_update(video, VE_CTRL,
5214 + VE_CTRL_VSYNC_POL | VE_CTRL_HSYNC_POL, 0);
5215 aspeed_video_enable_mode_detect(video);
5216
5217 rc = wait_event_interruptible_timeout(video->wait,
5218 diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
5219 index a838189d4490..9aaf3b8060d5 100644
5220 --- a/drivers/media/platform/exynos4-is/media-dev.c
5221 +++ b/drivers/media/platform/exynos4-is/media-dev.c
5222 @@ -1457,12 +1457,12 @@ static int fimc_md_probe(struct platform_device *pdev)
5223 ret = v4l2_device_register(dev, &fmd->v4l2_dev);
5224 if (ret < 0) {
5225 v4l2_err(v4l2_dev, "Failed to register v4l2_device: %d\n", ret);
5226 - return ret;
5227 + goto err_md;
5228 }
5229
5230 ret = fimc_md_get_clocks(fmd);
5231 if (ret)
5232 - goto err_md;
5233 + goto err_v4l2dev;
5234
5235 ret = fimc_md_get_pinctrl(fmd);
5236 if (ret < 0) {
5237 @@ -1519,9 +1519,10 @@ err_m_ent:
5238 fimc_md_unregister_entities(fmd);
5239 err_clk:
5240 fimc_md_put_clocks(fmd);
5241 +err_v4l2dev:
5242 + v4l2_device_unregister(&fmd->v4l2_dev);
5243 err_md:
5244 media_device_cleanup(&fmd->media_dev);
5245 - v4l2_device_unregister(&fmd->v4l2_dev);
5246 return ret;
5247 }
5248
5249 diff --git a/drivers/media/platform/meson/ao-cec-g12a.c b/drivers/media/platform/meson/ao-cec-g12a.c
5250 index 3b39e875292e..3d8fe854feb0 100644
5251 --- a/drivers/media/platform/meson/ao-cec-g12a.c
5252 +++ b/drivers/media/platform/meson/ao-cec-g12a.c
5253 @@ -662,34 +662,27 @@ static int meson_ao_cec_g12a_probe(struct platform_device *pdev)
5254 if (IS_ERR(ao_cec->adap))
5255 return PTR_ERR(ao_cec->adap);
5256
5257 - ao_cec->notify = cec_notifier_cec_adap_register(hdmi_dev, NULL,
5258 - ao_cec->adap);
5259 - if (!ao_cec->notify) {
5260 - ret = -ENOMEM;
5261 - goto out_probe_adapter;
5262 - }
5263 -
5264 ao_cec->adap->owner = THIS_MODULE;
5265
5266 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
5267 base = devm_ioremap_resource(&pdev->dev, res);
5268 if (IS_ERR(base)) {
5269 ret = PTR_ERR(base);
5270 - goto out_probe_notify;
5271 + goto out_probe_adapter;
5272 }
5273
5274 ao_cec->regmap = devm_regmap_init_mmio(&pdev->dev, base,
5275 &meson_ao_cec_g12a_regmap_conf);
5276 if (IS_ERR(ao_cec->regmap)) {
5277 ret = PTR_ERR(ao_cec->regmap);
5278 - goto out_probe_notify;
5279 + goto out_probe_adapter;
5280 }
5281
5282 ao_cec->regmap_cec = devm_regmap_init(&pdev->dev, NULL, ao_cec,
5283 &meson_ao_cec_g12a_cec_regmap_conf);
5284 if (IS_ERR(ao_cec->regmap_cec)) {
5285 ret = PTR_ERR(ao_cec->regmap_cec);
5286 - goto out_probe_notify;
5287 + goto out_probe_adapter;
5288 }
5289
5290 irq = platform_get_irq(pdev, 0);
5291 @@ -699,45 +692,52 @@ static int meson_ao_cec_g12a_probe(struct platform_device *pdev)
5292 0, NULL, ao_cec);
5293 if (ret) {
5294 dev_err(&pdev->dev, "irq request failed\n");
5295 - goto out_probe_notify;
5296 + goto out_probe_adapter;
5297 }
5298
5299 ao_cec->oscin = devm_clk_get(&pdev->dev, "oscin");
5300 if (IS_ERR(ao_cec->oscin)) {
5301 dev_err(&pdev->dev, "oscin clock request failed\n");
5302 ret = PTR_ERR(ao_cec->oscin);
5303 - goto out_probe_notify;
5304 + goto out_probe_adapter;
5305 }
5306
5307 ret = meson_ao_cec_g12a_setup_clk(ao_cec);
5308 if (ret)
5309 - goto out_probe_notify;
5310 + goto out_probe_adapter;
5311
5312 ret = clk_prepare_enable(ao_cec->core);
5313 if (ret) {
5314 dev_err(&pdev->dev, "core clock enable failed\n");
5315 - goto out_probe_notify;
5316 + goto out_probe_adapter;
5317 }
5318
5319 device_reset_optional(&pdev->dev);
5320
5321 platform_set_drvdata(pdev, ao_cec);
5322
5323 + ao_cec->notify = cec_notifier_cec_adap_register(hdmi_dev, NULL,
5324 + ao_cec->adap);
5325 + if (!ao_cec->notify) {
5326 + ret = -ENOMEM;
5327 + goto out_probe_core_clk;
5328 + }
5329 +
5330 ret = cec_register_adapter(ao_cec->adap, &pdev->dev);
5331 if (ret < 0)
5332 - goto out_probe_core_clk;
5333 + goto out_probe_notify;
5334
5335 /* Setup Hardware */
5336 regmap_write(ao_cec->regmap, CECB_GEN_CNTL_REG, CECB_GEN_CNTL_RESET);
5337
5338 return 0;
5339
5340 -out_probe_core_clk:
5341 - clk_disable_unprepare(ao_cec->core);
5342 -
5343 out_probe_notify:
5344 cec_notifier_cec_adap_unregister(ao_cec->notify);
5345
5346 +out_probe_core_clk:
5347 + clk_disable_unprepare(ao_cec->core);
5348 +
5349 out_probe_adapter:
5350 cec_delete_adapter(ao_cec->adap);
5351
5352 diff --git a/drivers/media/platform/meson/ao-cec.c b/drivers/media/platform/meson/ao-cec.c
5353 index 64ed549bf012..03600e8b3ef0 100644
5354 --- a/drivers/media/platform/meson/ao-cec.c
5355 +++ b/drivers/media/platform/meson/ao-cec.c
5356 @@ -624,20 +624,13 @@ static int meson_ao_cec_probe(struct platform_device *pdev)
5357 if (IS_ERR(ao_cec->adap))
5358 return PTR_ERR(ao_cec->adap);
5359
5360 - ao_cec->notify = cec_notifier_cec_adap_register(hdmi_dev, NULL,
5361 - ao_cec->adap);
5362 - if (!ao_cec->notify) {
5363 - ret = -ENOMEM;
5364 - goto out_probe_adapter;
5365 - }
5366 -
5367 ao_cec->adap->owner = THIS_MODULE;
5368
5369 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
5370 ao_cec->base = devm_ioremap_resource(&pdev->dev, res);
5371 if (IS_ERR(ao_cec->base)) {
5372 ret = PTR_ERR(ao_cec->base);
5373 - goto out_probe_notify;
5374 + goto out_probe_adapter;
5375 }
5376
5377 irq = platform_get_irq(pdev, 0);
5378 @@ -647,20 +640,20 @@ static int meson_ao_cec_probe(struct platform_device *pdev)
5379 0, NULL, ao_cec);
5380 if (ret) {
5381 dev_err(&pdev->dev, "irq request failed\n");
5382 - goto out_probe_notify;
5383 + goto out_probe_adapter;
5384 }
5385
5386 ao_cec->core = devm_clk_get(&pdev->dev, "core");
5387 if (IS_ERR(ao_cec->core)) {
5388 dev_err(&pdev->dev, "core clock request failed\n");
5389 ret = PTR_ERR(ao_cec->core);
5390 - goto out_probe_notify;
5391 + goto out_probe_adapter;
5392 }
5393
5394 ret = clk_prepare_enable(ao_cec->core);
5395 if (ret) {
5396 dev_err(&pdev->dev, "core clock enable failed\n");
5397 - goto out_probe_notify;
5398 + goto out_probe_adapter;
5399 }
5400
5401 ret = clk_set_rate(ao_cec->core, CEC_CLK_RATE);
5402 @@ -674,9 +667,16 @@ static int meson_ao_cec_probe(struct platform_device *pdev)
5403 ao_cec->pdev = pdev;
5404 platform_set_drvdata(pdev, ao_cec);
5405
5406 + ao_cec->notify = cec_notifier_cec_adap_register(hdmi_dev, NULL,
5407 + ao_cec->adap);
5408 + if (!ao_cec->notify) {
5409 + ret = -ENOMEM;
5410 + goto out_probe_clk;
5411 + }
5412 +
5413 ret = cec_register_adapter(ao_cec->adap, &pdev->dev);
5414 if (ret < 0)
5415 - goto out_probe_clk;
5416 + goto out_probe_notify;
5417
5418 /* Setup Hardware */
5419 writel_relaxed(CEC_GEN_CNTL_RESET,
5420 @@ -684,12 +684,12 @@ static int meson_ao_cec_probe(struct platform_device *pdev)
5421
5422 return 0;
5423
5424 -out_probe_clk:
5425 - clk_disable_unprepare(ao_cec->core);
5426 -
5427 out_probe_notify:
5428 cec_notifier_cec_adap_unregister(ao_cec->notify);
5429
5430 +out_probe_clk:
5431 + clk_disable_unprepare(ao_cec->core);
5432 +
5433 out_probe_adapter:
5434 cec_delete_adapter(ao_cec->adap);
5435
5436 diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
5437 index e6eff512a8a1..84e982f259a0 100644
5438 --- a/drivers/media/platform/qcom/venus/core.c
5439 +++ b/drivers/media/platform/qcom/venus/core.c
5440 @@ -427,10 +427,11 @@ static const struct venus_resources msm8916_res = {
5441 };
5442
5443 static const struct freq_tbl msm8996_freq_table[] = {
5444 - { 1944000, 490000000 }, /* 4k UHD @ 60 */
5445 - { 972000, 320000000 }, /* 4k UHD @ 30 */
5446 - { 489600, 150000000 }, /* 1080p @ 60 */
5447 - { 244800, 75000000 }, /* 1080p @ 30 */
5448 + { 1944000, 520000000 }, /* 4k UHD @ 60 (decode only) */
5449 + { 972000, 520000000 }, /* 4k UHD @ 30 */
5450 + { 489600, 346666667 }, /* 1080p @ 60 */
5451 + { 244800, 150000000 }, /* 1080p @ 30 */
5452 + { 108000, 75000000 }, /* 720p @ 30 */
5453 };
5454
5455 static const struct reg_val msm8996_reg_preset[] = {
5456 diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
5457 index 7129a2aea09a..0d8855014ab3 100644
5458 --- a/drivers/media/platform/qcom/venus/hfi_venus.c
5459 +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
5460 @@ -1472,6 +1472,7 @@ static int venus_suspend_3xx(struct venus_core *core)
5461 {
5462 struct venus_hfi_device *hdev = to_hfi_priv(core);
5463 struct device *dev = core->dev;
5464 + u32 ctrl_status;
5465 bool val;
5466 int ret;
5467
5468 @@ -1487,6 +1488,10 @@ static int venus_suspend_3xx(struct venus_core *core)
5469 return -EINVAL;
5470 }
5471
5472 + ctrl_status = venus_readl(hdev, CPU_CS_SCIACMDARG0);
5473 + if (ctrl_status & CPU_CS_SCIACMDARG0_PC_READY)
5474 + goto power_off;
5475 +
5476 /*
5477 * Power collapse sequence for Venus 3xx and 4xx versions:
5478 * 1. Check for ARM9 and video core to be idle by checking WFI bit
5479 @@ -1511,6 +1516,7 @@ static int venus_suspend_3xx(struct venus_core *core)
5480 if (ret)
5481 return ret;
5482
5483 +power_off:
5484 mutex_lock(&hdev->lock);
5485
5486 ret = venus_power_off(hdev);
5487 diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
5488 index 608e5217ccd5..0f267a237b42 100644
5489 --- a/drivers/media/platform/rcar_drif.c
5490 +++ b/drivers/media/platform/rcar_drif.c
5491 @@ -912,6 +912,7 @@ static int rcar_drif_g_fmt_sdr_cap(struct file *file, void *priv,
5492 {
5493 struct rcar_drif_sdr *sdr = video_drvdata(file);
5494
5495 + memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
5496 f->fmt.sdr.pixelformat = sdr->fmt->pixelformat;
5497 f->fmt.sdr.buffersize = sdr->fmt->buffersize;
5498
5499 diff --git a/drivers/media/platform/seco-cec/seco-cec.c b/drivers/media/platform/seco-cec/seco-cec.c
5500 index 9cd60fe1867c..a86b6e8f9196 100644
5501 --- a/drivers/media/platform/seco-cec/seco-cec.c
5502 +++ b/drivers/media/platform/seco-cec/seco-cec.c
5503 @@ -675,6 +675,7 @@ err_notifier:
5504 err_delete_adapter:
5505 cec_delete_adapter(secocec->cec_adap);
5506 err:
5507 + release_region(BRA_SMB_BASE_ADDR, 7);
5508 dev_err(dev, "%s device probe failed\n", dev_name(dev));
5509
5510 return ret;
5511 diff --git a/drivers/media/platform/ti-vpe/vpdma.h b/drivers/media/platform/ti-vpe/vpdma.h
5512 index 28bc94129348..9bacfd603250 100644
5513 --- a/drivers/media/platform/ti-vpe/vpdma.h
5514 +++ b/drivers/media/platform/ti-vpe/vpdma.h
5515 @@ -57,6 +57,7 @@ struct vpdma_data_format {
5516 * line stride of source and dest
5517 * buffers should be 16 byte aligned
5518 */
5519 +#define VPDMA_MAX_STRIDE 65520 /* Max line stride 16 byte aligned */
5520 #define VPDMA_DTD_DESC_SIZE 32 /* 8 words */
5521 #define VPDMA_CFD_CTD_DESC_SIZE 16 /* 4 words */
5522
5523 diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
5524 index 60b575bb44c4..8b14ba4a3d9e 100644
5525 --- a/drivers/media/platform/ti-vpe/vpe.c
5526 +++ b/drivers/media/platform/ti-vpe/vpe.c
5527 @@ -338,20 +338,25 @@ enum {
5528 };
5529
5530 /* find our format description corresponding to the passed v4l2_format */
5531 -static struct vpe_fmt *find_format(struct v4l2_format *f)
5532 +static struct vpe_fmt *__find_format(u32 fourcc)
5533 {
5534 struct vpe_fmt *fmt;
5535 unsigned int k;
5536
5537 for (k = 0; k < ARRAY_SIZE(vpe_formats); k++) {
5538 fmt = &vpe_formats[k];
5539 - if (fmt->fourcc == f->fmt.pix.pixelformat)
5540 + if (fmt->fourcc == fourcc)
5541 return fmt;
5542 }
5543
5544 return NULL;
5545 }
5546
5547 +static struct vpe_fmt *find_format(struct v4l2_format *f)
5548 +{
5549 + return __find_format(f->fmt.pix.pixelformat);
5550 +}
5551 +
5552 /*
5553 * there is one vpe_dev structure in the driver, it is shared by
5554 * all instances.
5555 @@ -1013,11 +1018,14 @@ static void add_out_dtd(struct vpe_ctx *ctx, int port)
5556 dma_addr_t dma_addr;
5557 u32 flags = 0;
5558 u32 offset = 0;
5559 + u32 stride;
5560
5561 if (port == VPE_PORT_MV_OUT) {
5562 vpdma_fmt = &vpdma_misc_fmts[VPDMA_DATA_FMT_MV];
5563 dma_addr = ctx->mv_buf_dma[mv_buf_selector];
5564 q_data = &ctx->q_data[Q_DATA_SRC];
5565 + stride = ALIGN((q_data->width * vpdma_fmt->depth) >> 3,
5566 + VPDMA_STRIDE_ALIGN);
5567 } else {
5568 /* to incorporate interleaved formats */
5569 int plane = fmt->coplanar ? p_data->vb_part : 0;
5570 @@ -1044,6 +1052,7 @@ static void add_out_dtd(struct vpe_ctx *ctx, int port)
5571 }
5572 /* Apply the offset */
5573 dma_addr += offset;
5574 + stride = q_data->bytesperline[VPE_LUMA];
5575 }
5576
5577 if (q_data->flags & Q_DATA_FRAME_1D)
5578 @@ -1055,7 +1064,7 @@ static void add_out_dtd(struct vpe_ctx *ctx, int port)
5579 MAX_W, MAX_H);
5580
5581 vpdma_add_out_dtd(&ctx->desc_list, q_data->width,
5582 - q_data->bytesperline[VPE_LUMA], &q_data->c_rect,
5583 + stride, &q_data->c_rect,
5584 vpdma_fmt, dma_addr, MAX_OUT_WIDTH_REG1,
5585 MAX_OUT_HEIGHT_REG1, p_data->channel, flags);
5586 }
5587 @@ -1074,10 +1083,13 @@ static void add_in_dtd(struct vpe_ctx *ctx, int port)
5588 dma_addr_t dma_addr;
5589 u32 flags = 0;
5590 u32 offset = 0;
5591 + u32 stride;
5592
5593 if (port == VPE_PORT_MV_IN) {
5594 vpdma_fmt = &vpdma_misc_fmts[VPDMA_DATA_FMT_MV];
5595 dma_addr = ctx->mv_buf_dma[mv_buf_selector];
5596 + stride = ALIGN((q_data->width * vpdma_fmt->depth) >> 3,
5597 + VPDMA_STRIDE_ALIGN);
5598 } else {
5599 /* to incorporate interleaved formats */
5600 int plane = fmt->coplanar ? p_data->vb_part : 0;
5601 @@ -1104,6 +1116,7 @@ static void add_in_dtd(struct vpe_ctx *ctx, int port)
5602 }
5603 /* Apply the offset */
5604 dma_addr += offset;
5605 + stride = q_data->bytesperline[VPE_LUMA];
5606
5607 if (q_data->flags & Q_DATA_INTERLACED_SEQ_TB) {
5608 /*
5609 @@ -1139,10 +1152,10 @@ static void add_in_dtd(struct vpe_ctx *ctx, int port)
5610 if (p_data->vb_part && fmt->fourcc == V4L2_PIX_FMT_NV12)
5611 frame_height /= 2;
5612
5613 - vpdma_add_in_dtd(&ctx->desc_list, q_data->width,
5614 - q_data->bytesperline[VPE_LUMA], &q_data->c_rect,
5615 - vpdma_fmt, dma_addr, p_data->channel, field, flags, frame_width,
5616 - frame_height, 0, 0);
5617 + vpdma_add_in_dtd(&ctx->desc_list, q_data->width, stride,
5618 + &q_data->c_rect, vpdma_fmt, dma_addr,
5619 + p_data->channel, field, flags, frame_width,
5620 + frame_height, 0, 0);
5621 }
5622
5623 /*
5624 @@ -1391,9 +1404,6 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
5625 /* the previous dst mv buffer becomes the next src mv buffer */
5626 ctx->src_mv_buf_selector = !ctx->src_mv_buf_selector;
5627
5628 - if (ctx->aborting)
5629 - goto finished;
5630 -
5631 s_vb = ctx->src_vbs[0];
5632 d_vb = ctx->dst_vb;
5633
5634 @@ -1404,6 +1414,7 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
5635 d_vb->timecode = s_vb->timecode;
5636
5637 d_vb->sequence = ctx->sequence;
5638 + s_vb->sequence = ctx->sequence;
5639
5640 d_q_data = &ctx->q_data[Q_DATA_DST];
5641 if (d_q_data->flags & Q_IS_INTERLACED) {
5642 @@ -1457,6 +1468,9 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
5643 ctx->src_vbs[0] = NULL;
5644 ctx->dst_vb = NULL;
5645
5646 + if (ctx->aborting)
5647 + goto finished;
5648 +
5649 ctx->bufs_completed++;
5650 if (ctx->bufs_completed < ctx->bufs_per_job && job_ready(ctx)) {
5651 device_run(ctx);
5652 @@ -1566,9 +1580,9 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
5653 unsigned int stride = 0;
5654
5655 if (!fmt || !(fmt->types & type)) {
5656 - vpe_err(ctx->dev, "Fourcc format (0x%08x) invalid.\n",
5657 + vpe_dbg(ctx->dev, "Fourcc format (0x%08x) invalid.\n",
5658 pix->pixelformat);
5659 - return -EINVAL;
5660 + fmt = __find_format(V4L2_PIX_FMT_YUYV);
5661 }
5662
5663 if (pix->field != V4L2_FIELD_NONE && pix->field != V4L2_FIELD_ALTERNATE
5664 @@ -1615,7 +1629,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
5665 &pix->height, MIN_H, MAX_H, H_ALIGN,
5666 S_ALIGN);
5667
5668 - if (!pix->num_planes)
5669 + if (!pix->num_planes || pix->num_planes > 2)
5670 pix->num_planes = fmt->coplanar ? 2 : 1;
5671 else if (pix->num_planes > 1 && !fmt->coplanar)
5672 pix->num_planes = 1;
5673 @@ -1654,6 +1668,10 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
5674 if (stride > plane_fmt->bytesperline)
5675 plane_fmt->bytesperline = stride;
5676
5677 + plane_fmt->bytesperline = clamp_t(u32, plane_fmt->bytesperline,
5678 + stride,
5679 + VPDMA_MAX_STRIDE);
5680 +
5681 plane_fmt->bytesperline = ALIGN(plane_fmt->bytesperline,
5682 VPDMA_STRIDE_ALIGN);
5683
5684 @@ -2274,7 +2292,7 @@ static int vpe_open(struct file *file)
5685 v4l2_ctrl_handler_setup(hdl);
5686
5687 s_q_data = &ctx->q_data[Q_DATA_SRC];
5688 - s_q_data->fmt = &vpe_formats[2];
5689 + s_q_data->fmt = __find_format(V4L2_PIX_FMT_YUYV);
5690 s_q_data->width = 1920;
5691 s_q_data->height = 1080;
5692 s_q_data->nplanes = 1;
5693 @@ -2352,6 +2370,12 @@ static int vpe_release(struct file *file)
5694
5695 mutex_lock(&dev->dev_mutex);
5696 free_mv_buffers(ctx);
5697 +
5698 + vpdma_unmap_desc_buf(dev->vpdma, &ctx->desc_list.buf);
5699 + vpdma_unmap_desc_buf(dev->vpdma, &ctx->mmr_adb);
5700 + vpdma_unmap_desc_buf(dev->vpdma, &ctx->sc_coeff_h);
5701 + vpdma_unmap_desc_buf(dev->vpdma, &ctx->sc_coeff_v);
5702 +
5703 vpdma_free_desc_list(&ctx->desc_list);
5704 vpdma_free_desc_buf(&ctx->mmr_adb);
5705
5706 diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c
5707 index 0ee143ae0f6b..82350097503e 100644
5708 --- a/drivers/media/platform/vicodec/vicodec-core.c
5709 +++ b/drivers/media/platform/vicodec/vicodec-core.c
5710 @@ -2139,6 +2139,9 @@ static void vicodec_v4l2_dev_release(struct v4l2_device *v4l2_dev)
5711 v4l2_m2m_release(dev->stateful_enc.m2m_dev);
5712 v4l2_m2m_release(dev->stateful_dec.m2m_dev);
5713 v4l2_m2m_release(dev->stateless_dec.m2m_dev);
5714 +#ifdef CONFIG_MEDIA_CONTROLLER
5715 + media_device_cleanup(&dev->mdev);
5716 +#endif
5717 kfree(dev);
5718 }
5719
5720 @@ -2250,7 +2253,6 @@ static int vicodec_remove(struct platform_device *pdev)
5721 v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev);
5722 v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev);
5723 v4l2_m2m_unregister_media_controller(dev->stateless_dec.m2m_dev);
5724 - media_device_cleanup(&dev->mdev);
5725 #endif
5726
5727 video_unregister_device(&dev->stateful_enc.vfd);
5728 diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
5729 index acd3bd48c7e2..8d6b09623d88 100644
5730 --- a/drivers/media/platform/vim2m.c
5731 +++ b/drivers/media/platform/vim2m.c
5732 @@ -1073,6 +1073,9 @@ static int vim2m_start_streaming(struct vb2_queue *q, unsigned int count)
5733 if (!q_data)
5734 return -EINVAL;
5735
5736 + if (V4L2_TYPE_IS_OUTPUT(q->type))
5737 + ctx->aborting = 0;
5738 +
5739 q_data->sequence = 0;
5740 return 0;
5741 }
5742 @@ -1272,6 +1275,9 @@ static void vim2m_device_release(struct video_device *vdev)
5743
5744 v4l2_device_unregister(&dev->v4l2_dev);
5745 v4l2_m2m_release(dev->m2m_dev);
5746 +#ifdef CONFIG_MEDIA_CONTROLLER
5747 + media_device_cleanup(&dev->mdev);
5748 +#endif
5749 kfree(dev);
5750 }
5751
5752 @@ -1343,6 +1349,7 @@ static int vim2m_probe(struct platform_device *pdev)
5753 if (IS_ERR(dev->m2m_dev)) {
5754 v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem device\n");
5755 ret = PTR_ERR(dev->m2m_dev);
5756 + dev->m2m_dev = NULL;
5757 goto error_dev;
5758 }
5759
5760 @@ -1395,7 +1402,6 @@ static int vim2m_remove(struct platform_device *pdev)
5761 #ifdef CONFIG_MEDIA_CONTROLLER
5762 media_device_unregister(&dev->mdev);
5763 v4l2_m2m_unregister_media_controller(dev->m2m_dev);
5764 - media_device_cleanup(&dev->mdev);
5765 #endif
5766 video_unregister_device(&dev->vfd);
5767
5768 diff --git a/drivers/media/platform/vimc/vimc-common.c b/drivers/media/platform/vimc/vimc-common.c
5769 index 7e1ae0b12f1e..a3120f4f7a90 100644
5770 --- a/drivers/media/platform/vimc/vimc-common.c
5771 +++ b/drivers/media/platform/vimc/vimc-common.c
5772 @@ -375,7 +375,7 @@ int vimc_ent_sd_register(struct vimc_ent_device *ved,
5773 {
5774 int ret;
5775
5776 - /* Allocate the pads */
5777 + /* Allocate the pads. Should be released from the sd_int_op release */
5778 ved->pads = vimc_pads_init(num_pads, pads_flag);
5779 if (IS_ERR(ved->pads))
5780 return PTR_ERR(ved->pads);
5781 @@ -424,7 +424,6 @@ EXPORT_SYMBOL_GPL(vimc_ent_sd_register);
5782 void vimc_ent_sd_unregister(struct vimc_ent_device *ved, struct v4l2_subdev *sd)
5783 {
5784 media_entity_cleanup(ved->ent);
5785 - vimc_pads_cleanup(ved->pads);
5786 v4l2_device_unregister_subdev(sd);
5787 }
5788 EXPORT_SYMBOL_GPL(vimc_ent_sd_unregister);
5789 diff --git a/drivers/media/platform/vimc/vimc-debayer.c b/drivers/media/platform/vimc/vimc-debayer.c
5790 index b72b8385067b..baafd9d7fb2c 100644
5791 --- a/drivers/media/platform/vimc/vimc-debayer.c
5792 +++ b/drivers/media/platform/vimc/vimc-debayer.c
5793 @@ -484,6 +484,7 @@ static void vimc_deb_release(struct v4l2_subdev *sd)
5794 struct vimc_deb_device *vdeb =
5795 container_of(sd, struct vimc_deb_device, sd);
5796
5797 + vimc_pads_cleanup(vdeb->ved.pads);
5798 kfree(vdeb);
5799 }
5800
5801 diff --git a/drivers/media/platform/vimc/vimc-scaler.c b/drivers/media/platform/vimc/vimc-scaler.c
5802 index 49ab8d9dd9c9..c0d9f43d5777 100644
5803 --- a/drivers/media/platform/vimc/vimc-scaler.c
5804 +++ b/drivers/media/platform/vimc/vimc-scaler.c
5805 @@ -343,6 +343,7 @@ static void vimc_sca_release(struct v4l2_subdev *sd)
5806 struct vimc_sca_device *vsca =
5807 container_of(sd, struct vimc_sca_device, sd);
5808
5809 + vimc_pads_cleanup(vsca->ved.pads);
5810 kfree(vsca);
5811 }
5812
5813 diff --git a/drivers/media/platform/vimc/vimc-sensor.c b/drivers/media/platform/vimc/vimc-sensor.c
5814 index 4a6a7e8e66c2..420573e5f6d6 100644
5815 --- a/drivers/media/platform/vimc/vimc-sensor.c
5816 +++ b/drivers/media/platform/vimc/vimc-sensor.c
5817 @@ -292,6 +292,7 @@ static void vimc_sen_release(struct v4l2_subdev *sd)
5818
5819 v4l2_ctrl_handler_free(&vsen->hdl);
5820 tpg_free(&vsen->tpg);
5821 + vimc_pads_cleanup(vsen->ved.pads);
5822 kfree(vsen);
5823 }
5824
5825 diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c
5826 index 53315c8dd2bb..f6a5cdbd74e7 100644
5827 --- a/drivers/media/platform/vivid/vivid-core.c
5828 +++ b/drivers/media/platform/vivid/vivid-core.c
5829 @@ -616,6 +616,9 @@ static void vivid_dev_release(struct v4l2_device *v4l2_dev)
5830
5831 vivid_free_controls(dev);
5832 v4l2_device_unregister(&dev->v4l2_dev);
5833 +#ifdef CONFIG_MEDIA_CONTROLLER
5834 + media_device_cleanup(&dev->mdev);
5835 +#endif
5836 vfree(dev->scaled_line);
5837 vfree(dev->blended_line);
5838 vfree(dev->edid);
5839 @@ -1580,7 +1583,6 @@ static int vivid_remove(struct platform_device *pdev)
5840
5841 #ifdef CONFIG_MEDIA_CONTROLLER
5842 media_device_unregister(&dev->mdev);
5843 - media_device_cleanup(&dev->mdev);
5844 #endif
5845
5846 if (dev->has_vid_cap) {
5847 diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
5848 index 7541698a0be1..f491420d7b53 100644
5849 --- a/drivers/media/radio/si470x/radio-si470x-i2c.c
5850 +++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
5851 @@ -482,6 +482,8 @@ static int si470x_i2c_remove(struct i2c_client *client)
5852 if (radio->gpio_reset)
5853 gpiod_set_value(radio->gpio_reset, 0);
5854
5855 + v4l2_ctrl_handler_free(&radio->hdl);
5856 + v4l2_device_unregister(&radio->v4l2_dev);
5857 return 0;
5858 }
5859
5860 diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c
5861 index 1a801dc286f8..d1331f828108 100644
5862 --- a/drivers/media/usb/b2c2/flexcop-usb.c
5863 +++ b/drivers/media/usb/b2c2/flexcop-usb.c
5864 @@ -504,7 +504,13 @@ urb_error:
5865 static int flexcop_usb_init(struct flexcop_usb *fc_usb)
5866 {
5867 /* use the alternate setting with the larges buffer */
5868 - usb_set_interface(fc_usb->udev,0,1);
5869 + int ret = usb_set_interface(fc_usb->udev, 0, 1);
5870 +
5871 + if (ret) {
5872 + err("set interface failed.");
5873 + return ret;
5874 + }
5875 +
5876 switch (fc_usb->udev->speed) {
5877 case USB_SPEED_LOW:
5878 err("cannot handle USB speed because it is too slow.");
5879 diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
5880 index a34717eba409..eaa08c7999d4 100644
5881 --- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
5882 +++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
5883 @@ -898,8 +898,12 @@ static void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
5884 pvr2_v4l2_dev_disassociate_parent(vp->dev_video);
5885 pvr2_v4l2_dev_disassociate_parent(vp->dev_radio);
5886 if (!list_empty(&vp->dev_video->devbase.fh_list) ||
5887 - !list_empty(&vp->dev_radio->devbase.fh_list))
5888 + (vp->dev_radio &&
5889 + !list_empty(&vp->dev_radio->devbase.fh_list))) {
5890 + pvr2_trace(PVR2_TRACE_STRUCT,
5891 + "pvr2_v4l2 internal_check exit-empty id=%p", vp);
5892 return;
5893 + }
5894 pvr2_v4l2_destroy_no_lock(vp);
5895 }
5896
5897 @@ -935,7 +939,8 @@ static int pvr2_v4l2_release(struct file *file)
5898 kfree(fhp);
5899 if (vp->channel.mc_head->disconnect_flag &&
5900 list_empty(&vp->dev_video->devbase.fh_list) &&
5901 - list_empty(&vp->dev_radio->devbase.fh_list)) {
5902 + (!vp->dev_radio ||
5903 + list_empty(&vp->dev_radio->devbase.fh_list))) {
5904 pvr2_v4l2_destroy_no_lock(vp);
5905 }
5906 return 0;
5907 diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
5908 index 1d8f38824631..cd84dbbf6a89 100644
5909 --- a/drivers/media/v4l2-core/v4l2-ctrls.c
5910 +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
5911 @@ -3144,6 +3144,7 @@ static void v4l2_ctrl_request_queue(struct media_request_object *obj)
5912 struct v4l2_ctrl_handler *prev_hdl = NULL;
5913 struct v4l2_ctrl_ref *ref_ctrl, *ref_ctrl_prev = NULL;
5914
5915 + mutex_lock(main_hdl->lock);
5916 if (list_empty(&main_hdl->requests_queued))
5917 goto queue;
5918
5919 @@ -3175,18 +3176,22 @@ static void v4l2_ctrl_request_queue(struct media_request_object *obj)
5920 queue:
5921 list_add_tail(&hdl->requests_queued, &main_hdl->requests_queued);
5922 hdl->request_is_queued = true;
5923 + mutex_unlock(main_hdl->lock);
5924 }
5925
5926 static void v4l2_ctrl_request_unbind(struct media_request_object *obj)
5927 {
5928 struct v4l2_ctrl_handler *hdl =
5929 container_of(obj, struct v4l2_ctrl_handler, req_obj);
5930 + struct v4l2_ctrl_handler *main_hdl = obj->priv;
5931
5932 list_del_init(&hdl->requests);
5933 + mutex_lock(main_hdl->lock);
5934 if (hdl->request_is_queued) {
5935 list_del_init(&hdl->requests_queued);
5936 hdl->request_is_queued = false;
5937 }
5938 + mutex_unlock(main_hdl->lock);
5939 }
5940
5941 static void v4l2_ctrl_request_release(struct media_request_object *obj)
5942 @@ -4128,9 +4133,11 @@ void v4l2_ctrl_request_complete(struct media_request *req,
5943 v4l2_ctrl_unlock(ctrl);
5944 }
5945
5946 + mutex_lock(main_hdl->lock);
5947 WARN_ON(!hdl->request_is_queued);
5948 list_del_init(&hdl->requests_queued);
5949 hdl->request_is_queued = false;
5950 + mutex_unlock(main_hdl->lock);
5951 media_request_object_complete(obj);
5952 media_request_object_put(obj);
5953 }
5954 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
5955 index 51b912743f0f..21bb96ce4cd6 100644
5956 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
5957 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
5958 @@ -1466,10 +1466,26 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
5959 return ret;
5960 }
5961
5962 +static void v4l_pix_format_touch(struct v4l2_pix_format *p)
5963 +{
5964 + /*
5965 + * The v4l2_pix_format structure contains fields that make no sense for
5966 + * touch. Set them to default values in this case.
5967 + */
5968 +
5969 + p->field = V4L2_FIELD_NONE;
5970 + p->colorspace = V4L2_COLORSPACE_RAW;
5971 + p->flags = 0;
5972 + p->ycbcr_enc = 0;
5973 + p->quantization = 0;
5974 + p->xfer_func = 0;
5975 +}
5976 +
5977 static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
5978 struct file *file, void *fh, void *arg)
5979 {
5980 struct v4l2_format *p = arg;
5981 + struct video_device *vfd = video_devdata(file);
5982 int ret = check_fmt(file, p->type);
5983
5984 if (ret)
5985 @@ -1507,6 +1523,8 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
5986 ret = ops->vidioc_g_fmt_vid_cap(file, fh, arg);
5987 /* just in case the driver zeroed it again */
5988 p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
5989 + if (vfd->vfl_type == VFL_TYPE_TOUCH)
5990 + v4l_pix_format_touch(&p->fmt.pix);
5991 return ret;
5992 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
5993 return ops->vidioc_g_fmt_vid_cap_mplane(file, fh, arg);
5994 @@ -1544,21 +1562,6 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
5995 return -EINVAL;
5996 }
5997
5998 -static void v4l_pix_format_touch(struct v4l2_pix_format *p)
5999 -{
6000 - /*
6001 - * The v4l2_pix_format structure contains fields that make no sense for
6002 - * touch. Set them to default values in this case.
6003 - */
6004 -
6005 - p->field = V4L2_FIELD_NONE;
6006 - p->colorspace = V4L2_COLORSPACE_RAW;
6007 - p->flags = 0;
6008 - p->ycbcr_enc = 0;
6009 - p->quantization = 0;
6010 - p->xfer_func = 0;
6011 -}
6012 -
6013 static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
6014 struct file *file, void *fh, void *arg)
6015 {
6016 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
6017 index 1b1a794d639d..842f2210dc7e 100644
6018 --- a/drivers/misc/fastrpc.c
6019 +++ b/drivers/misc/fastrpc.c
6020 @@ -1430,8 +1430,8 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
6021 return -ENOMEM;
6022
6023 data->miscdev.minor = MISC_DYNAMIC_MINOR;
6024 - data->miscdev.name = kasprintf(GFP_KERNEL, "fastrpc-%s",
6025 - domains[domain_id]);
6026 + data->miscdev.name = devm_kasprintf(rdev, GFP_KERNEL, "fastrpc-%s",
6027 + domains[domain_id]);
6028 data->miscdev.fops = &fastrpc_fops;
6029 err = misc_register(&data->miscdev);
6030 if (err)
6031 diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
6032 index 2870c25da166..4d1b44de1492 100644
6033 --- a/drivers/misc/ocxl/file.c
6034 +++ b/drivers/misc/ocxl/file.c
6035 @@ -18,18 +18,15 @@ static struct class *ocxl_class;
6036 static struct mutex minors_idr_lock;
6037 static struct idr minors_idr;
6038
6039 -static struct ocxl_file_info *find_file_info(dev_t devno)
6040 +static struct ocxl_file_info *find_and_get_file_info(dev_t devno)
6041 {
6042 struct ocxl_file_info *info;
6043
6044 - /*
6045 - * We don't declare an RCU critical section here, as our AFU
6046 - * is protected by a reference counter on the device. By the time the
6047 - * info reference is removed from the idr, the ref count of
6048 - * the device is already at 0, so no user API will access that AFU and
6049 - * this function can't return it.
6050 - */
6051 + mutex_lock(&minors_idr_lock);
6052 info = idr_find(&minors_idr, MINOR(devno));
6053 + if (info)
6054 + get_device(&info->dev);
6055 + mutex_unlock(&minors_idr_lock);
6056 return info;
6057 }
6058
6059 @@ -58,14 +55,16 @@ static int afu_open(struct inode *inode, struct file *file)
6060
6061 pr_debug("%s for device %x\n", __func__, inode->i_rdev);
6062
6063 - info = find_file_info(inode->i_rdev);
6064 + info = find_and_get_file_info(inode->i_rdev);
6065 if (!info)
6066 return -ENODEV;
6067
6068 rc = ocxl_context_alloc(&ctx, info->afu, inode->i_mapping);
6069 - if (rc)
6070 + if (rc) {
6071 + put_device(&info->dev);
6072 return rc;
6073 -
6074 + }
6075 + put_device(&info->dev);
6076 file->private_data = ctx;
6077 return 0;
6078 }
6079 @@ -487,7 +486,6 @@ static void info_release(struct device *dev)
6080 {
6081 struct ocxl_file_info *info = container_of(dev, struct ocxl_file_info, dev);
6082
6083 - free_minor(info);
6084 ocxl_afu_put(info->afu);
6085 kfree(info);
6086 }
6087 @@ -577,6 +575,7 @@ void ocxl_file_unregister_afu(struct ocxl_afu *afu)
6088
6089 ocxl_file_make_invisible(info);
6090 ocxl_sysfs_unregister_afu(info);
6091 + free_minor(info);
6092 device_unregister(&info->dev);
6093 }
6094
6095 diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
6096 index 189e42674d85..010fe29a4888 100644
6097 --- a/drivers/mmc/host/mtk-sd.c
6098 +++ b/drivers/mmc/host/mtk-sd.c
6099 @@ -228,6 +228,7 @@
6100 #define MSDC_PATCH_BIT_SPCPUSH (0x1 << 29) /* RW */
6101 #define MSDC_PATCH_BIT_DECRCTMO (0x1 << 30) /* RW */
6102
6103 +#define MSDC_PATCH_BIT1_CMDTA (0x7 << 3) /* RW */
6104 #define MSDC_PATCH_BIT1_STOP_DLY (0xf << 8) /* RW */
6105
6106 #define MSDC_PATCH_BIT2_CFGRESP (0x1 << 15) /* RW */
6107 @@ -1881,6 +1882,7 @@ static int hs400_tune_response(struct mmc_host *mmc, u32 opcode)
6108
6109 /* select EMMC50 PAD CMD tune */
6110 sdr_set_bits(host->base + PAD_CMD_TUNE, BIT(0));
6111 + sdr_set_field(host->base + MSDC_PATCH_BIT1, MSDC_PATCH_BIT1_CMDTA, 2);
6112
6113 if (mmc->ios.timing == MMC_TIMING_MMC_HS200 ||
6114 mmc->ios.timing == MMC_TIMING_UHS_SDR104)
6115 diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
6116 index b75c82d8d6c1..3d0bb5e2e09b 100644
6117 --- a/drivers/mmc/host/sdhci-msm.c
6118 +++ b/drivers/mmc/host/sdhci-msm.c
6119 @@ -99,7 +99,7 @@
6120
6121 #define CORE_PWRSAVE_DLL BIT(3)
6122
6123 -#define DDR_CONFIG_POR_VAL 0x80040853
6124 +#define DDR_CONFIG_POR_VAL 0x80040873
6125
6126
6127 #define INVALID_TUNING_PHASE -1
6128 @@ -148,8 +148,9 @@ struct sdhci_msm_offset {
6129 u32 core_ddr_200_cfg;
6130 u32 core_vendor_spec3;
6131 u32 core_dll_config_2;
6132 + u32 core_dll_config_3;
6133 + u32 core_ddr_config_old; /* Applicable to sdcc minor ver < 0x49 */
6134 u32 core_ddr_config;
6135 - u32 core_ddr_config_2;
6136 };
6137
6138 static const struct sdhci_msm_offset sdhci_msm_v5_offset = {
6139 @@ -177,8 +178,8 @@ static const struct sdhci_msm_offset sdhci_msm_v5_offset = {
6140 .core_ddr_200_cfg = 0x224,
6141 .core_vendor_spec3 = 0x250,
6142 .core_dll_config_2 = 0x254,
6143 - .core_ddr_config = 0x258,
6144 - .core_ddr_config_2 = 0x25c,
6145 + .core_dll_config_3 = 0x258,
6146 + .core_ddr_config = 0x25c,
6147 };
6148
6149 static const struct sdhci_msm_offset sdhci_msm_mci_offset = {
6150 @@ -207,8 +208,8 @@ static const struct sdhci_msm_offset sdhci_msm_mci_offset = {
6151 .core_ddr_200_cfg = 0x184,
6152 .core_vendor_spec3 = 0x1b0,
6153 .core_dll_config_2 = 0x1b4,
6154 - .core_ddr_config = 0x1b8,
6155 - .core_ddr_config_2 = 0x1bc,
6156 + .core_ddr_config_old = 0x1b8,
6157 + .core_ddr_config = 0x1bc,
6158 };
6159
6160 struct sdhci_msm_variant_ops {
6161 @@ -253,6 +254,7 @@ struct sdhci_msm_host {
6162 const struct sdhci_msm_offset *offset;
6163 bool use_cdr;
6164 u32 transfer_mode;
6165 + bool updated_ddr_cfg;
6166 };
6167
6168 static const struct sdhci_msm_offset *sdhci_priv_msm_offset(struct sdhci_host *host)
6169 @@ -924,8 +926,10 @@ out:
6170 static int sdhci_msm_cm_dll_sdc4_calibration(struct sdhci_host *host)
6171 {
6172 struct mmc_host *mmc = host->mmc;
6173 - u32 dll_status, config;
6174 + u32 dll_status, config, ddr_cfg_offset;
6175 int ret;
6176 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
6177 + struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
6178 const struct sdhci_msm_offset *msm_offset =
6179 sdhci_priv_msm_offset(host);
6180
6181 @@ -938,8 +942,11 @@ static int sdhci_msm_cm_dll_sdc4_calibration(struct sdhci_host *host)
6182 * bootloaders. In the future, if this changes, then the desired
6183 * values will need to be programmed appropriately.
6184 */
6185 - writel_relaxed(DDR_CONFIG_POR_VAL, host->ioaddr +
6186 - msm_offset->core_ddr_config);
6187 + if (msm_host->updated_ddr_cfg)
6188 + ddr_cfg_offset = msm_offset->core_ddr_config;
6189 + else
6190 + ddr_cfg_offset = msm_offset->core_ddr_config_old;
6191 + writel_relaxed(DDR_CONFIG_POR_VAL, host->ioaddr + ddr_cfg_offset);
6192
6193 if (mmc->ios.enhanced_strobe) {
6194 config = readl_relaxed(host->ioaddr +
6195 @@ -1899,6 +1906,9 @@ static int sdhci_msm_probe(struct platform_device *pdev)
6196 msm_offset->core_vendor_spec_capabilities0);
6197 }
6198
6199 + if (core_major == 1 && core_minor >= 0x49)
6200 + msm_host->updated_ddr_cfg = true;
6201 +
6202 /*
6203 * Power on reset state may trigger power irq if previous status of
6204 * PWRCTL was either BUS_ON or IO_HIGH_V. So before enabling pwr irq
6205 diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
6206 index 1d1953dfc54b..889ed98ec0e7 100644
6207 --- a/drivers/mmc/host/sdhci-of-esdhc.c
6208 +++ b/drivers/mmc/host/sdhci-of-esdhc.c
6209 @@ -710,9 +710,6 @@ static void esdhc_reset(struct sdhci_host *host, u8 mask)
6210 sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
6211 sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
6212
6213 - if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc"))
6214 - mdelay(5);
6215 -
6216 if (mask & SDHCI_RESET_ALL) {
6217 val = sdhci_readl(host, ESDHC_TBCTL);
6218 val &= ~ESDHC_TB_EN;
6219 @@ -1126,8 +1123,8 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)
6220 host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ;
6221
6222 if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc")) {
6223 - host->quirks2 |= SDHCI_QUIRK_RESET_AFTER_REQUEST;
6224 - host->quirks2 |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
6225 + host->quirks |= SDHCI_QUIRK_RESET_AFTER_REQUEST;
6226 + host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
6227 }
6228
6229 if (of_device_is_compatible(np, "fsl,p5040-esdhc") ||
6230 diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
6231 index eaffa85bc728..642a9667db4d 100644
6232 --- a/drivers/mmc/host/sdhci-pci-core.c
6233 +++ b/drivers/mmc/host/sdhci-pci-core.c
6234 @@ -26,6 +26,7 @@
6235 #include <linux/mmc/slot-gpio.h>
6236 #include <linux/mmc/sdhci-pci-data.h>
6237 #include <linux/acpi.h>
6238 +#include <linux/dmi.h>
6239
6240 #ifdef CONFIG_X86
6241 #include <asm/iosf_mbi.h>
6242 @@ -782,11 +783,18 @@ static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
6243 return 0;
6244 }
6245
6246 +static bool glk_broken_cqhci(struct sdhci_pci_slot *slot)
6247 +{
6248 + return slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_GLK_EMMC &&
6249 + dmi_match(DMI_BIOS_VENDOR, "LENOVO");
6250 +}
6251 +
6252 static int glk_emmc_probe_slot(struct sdhci_pci_slot *slot)
6253 {
6254 int ret = byt_emmc_probe_slot(slot);
6255
6256 - slot->host->mmc->caps2 |= MMC_CAP2_CQE;
6257 + if (!glk_broken_cqhci(slot))
6258 + slot->host->mmc->caps2 |= MMC_CAP2_CQE;
6259
6260 if (slot->chip->pdev->device != PCI_DEVICE_ID_INTEL_GLK_EMMC) {
6261 slot->host->mmc->caps2 |= MMC_CAP2_HS400_ES,
6262 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
6263 index b056400e34b1..5f9df2dbde06 100644
6264 --- a/drivers/mmc/host/sdhci.c
6265 +++ b/drivers/mmc/host/sdhci.c
6266 @@ -1871,9 +1871,7 @@ void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
6267 ctrl_2 |= SDHCI_CTRL_UHS_SDR104;
6268 else if (timing == MMC_TIMING_UHS_SDR12)
6269 ctrl_2 |= SDHCI_CTRL_UHS_SDR12;
6270 - else if (timing == MMC_TIMING_SD_HS ||
6271 - timing == MMC_TIMING_MMC_HS ||
6272 - timing == MMC_TIMING_UHS_SDR25)
6273 + else if (timing == MMC_TIMING_UHS_SDR25)
6274 ctrl_2 |= SDHCI_CTRL_UHS_SDR25;
6275 else if (timing == MMC_TIMING_UHS_SDR50)
6276 ctrl_2 |= SDHCI_CTRL_UHS_SDR50;
6277 @@ -2408,8 +2406,8 @@ static int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
6278 sdhci_send_tuning(host, opcode);
6279
6280 if (!host->tuning_done) {
6281 - pr_info("%s: Tuning timeout, falling back to fixed sampling clock\n",
6282 - mmc_hostname(host->mmc));
6283 + pr_debug("%s: Tuning timeout, falling back to fixed sampling clock\n",
6284 + mmc_hostname(host->mmc));
6285 sdhci_abort_tuning(host, opcode);
6286 return -ETIMEDOUT;
6287 }
6288 @@ -3758,6 +3756,9 @@ int sdhci_setup_host(struct sdhci_host *host)
6289 mmc_hostname(mmc), host->version);
6290 }
6291
6292 + if (host->quirks & SDHCI_QUIRK_BROKEN_CQE)
6293 + mmc->caps2 &= ~MMC_CAP2_CQE;
6294 +
6295 if (host->quirks & SDHCI_QUIRK_FORCE_DMA)
6296 host->flags |= SDHCI_USE_SDMA;
6297 else if (!(host->caps & SDHCI_CAN_DO_SDMA))
6298 diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
6299 index 0ed3e0eaef5f..fe83ece6965b 100644
6300 --- a/drivers/mmc/host/sdhci.h
6301 +++ b/drivers/mmc/host/sdhci.h
6302 @@ -409,6 +409,8 @@ struct sdhci_host {
6303 #define SDHCI_QUIRK_BROKEN_CARD_DETECTION (1<<15)
6304 /* Controller reports inverted write-protect state */
6305 #define SDHCI_QUIRK_INVERTED_WRITE_PROTECT (1<<16)
6306 +/* Controller has unusable command queue engine */
6307 +#define SDHCI_QUIRK_BROKEN_CQE (1<<17)
6308 /* Controller does not like fast PIO transfers */
6309 #define SDHCI_QUIRK_PIO_NEEDS_DELAY (1<<18)
6310 /* Controller does not have a LED */
6311 diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
6312 index 9b6e1001e77c..dec5a99f52cf 100644
6313 --- a/drivers/mmc/host/tmio_mmc_core.c
6314 +++ b/drivers/mmc/host/tmio_mmc_core.c
6315 @@ -1184,7 +1184,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
6316 if (ret == -EPROBE_DEFER)
6317 return ret;
6318
6319 - mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities;
6320 + mmc->caps |= MMC_CAP_ERASE | MMC_CAP_4_BIT_DATA | pdata->capabilities;
6321 mmc->caps2 |= pdata->capabilities2;
6322 mmc->max_segs = pdata->max_segs ? : 32;
6323 mmc->max_blk_size = TMIO_MAX_BLK_SIZE;
6324 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
6325 index 62f65573eb04..face00c622ed 100644
6326 --- a/drivers/net/bonding/bond_main.c
6327 +++ b/drivers/net/bonding/bond_main.c
6328 @@ -3612,32 +3612,35 @@ static int bond_neigh_init(struct neighbour *n)
6329 const struct net_device_ops *slave_ops;
6330 struct neigh_parms parms;
6331 struct slave *slave;
6332 - int ret;
6333 + int ret = 0;
6334
6335 - slave = bond_first_slave(bond);
6336 + rcu_read_lock();
6337 + slave = bond_first_slave_rcu(bond);
6338 if (!slave)
6339 - return 0;
6340 + goto out;
6341 slave_ops = slave->dev->netdev_ops;
6342 if (!slave_ops->ndo_neigh_setup)
6343 - return 0;
6344 -
6345 - parms.neigh_setup = NULL;
6346 - parms.neigh_cleanup = NULL;
6347 - ret = slave_ops->ndo_neigh_setup(slave->dev, &parms);
6348 - if (ret)
6349 - return ret;
6350 + goto out;
6351
6352 - /* Assign slave's neigh_cleanup to neighbour in case cleanup is called
6353 - * after the last slave has been detached. Assumes that all slaves
6354 - * utilize the same neigh_cleanup (true at this writing as only user
6355 - * is ipoib).
6356 + /* TODO: find another way [1] to implement this.
6357 + * Passing a zeroed structure is fragile,
6358 + * but at least we do not pass garbage.
6359 + *
6360 + * [1] One way would be that ndo_neigh_setup() never touch
6361 + * struct neigh_parms, but propagate the new neigh_setup()
6362 + * back to ___neigh_create() / neigh_parms_alloc()
6363 */
6364 - n->parms->neigh_cleanup = parms.neigh_cleanup;
6365 + memset(&parms, 0, sizeof(parms));
6366 + ret = slave_ops->ndo_neigh_setup(slave->dev, &parms);
6367
6368 - if (!parms.neigh_setup)
6369 - return 0;
6370 + if (ret)
6371 + goto out;
6372
6373 - return parms.neigh_setup(n);
6374 + if (parms.neigh_setup)
6375 + ret = parms.neigh_setup(n);
6376 +out:
6377 + rcu_read_unlock();
6378 + return ret;
6379 }
6380
6381 /* The bonding ndo_neigh_setup is called at init time beofre any
6382 diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
6383 index 57f9a2f51085..e5c207ad3c77 100644
6384 --- a/drivers/net/can/flexcan.c
6385 +++ b/drivers/net/can/flexcan.c
6386 @@ -389,6 +389,34 @@ static struct flexcan_mb __iomem *flexcan_get_mb(const struct flexcan_priv *priv
6387 (&priv->regs->mb[bank][priv->mb_size * mb_index]);
6388 }
6389
6390 +static int flexcan_low_power_enter_ack(struct flexcan_priv *priv)
6391 +{
6392 + struct flexcan_regs __iomem *regs = priv->regs;
6393 + unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
6394 +
6395 + while (timeout-- && !(priv->read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK))
6396 + udelay(10);
6397 +
6398 + if (!(priv->read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK))
6399 + return -ETIMEDOUT;
6400 +
6401 + return 0;
6402 +}
6403 +
6404 +static int flexcan_low_power_exit_ack(struct flexcan_priv *priv)
6405 +{
6406 + struct flexcan_regs __iomem *regs = priv->regs;
6407 + unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
6408 +
6409 + while (timeout-- && (priv->read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK))
6410 + udelay(10);
6411 +
6412 + if (priv->read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK)
6413 + return -ETIMEDOUT;
6414 +
6415 + return 0;
6416 +}
6417 +
6418 static void flexcan_enable_wakeup_irq(struct flexcan_priv *priv, bool enable)
6419 {
6420 struct flexcan_regs __iomem *regs = priv->regs;
6421 @@ -407,7 +435,6 @@ static void flexcan_enable_wakeup_irq(struct flexcan_priv *priv, bool enable)
6422 static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
6423 {
6424 struct flexcan_regs __iomem *regs = priv->regs;
6425 - unsigned int ackval;
6426 u32 reg_mcr;
6427
6428 reg_mcr = priv->read(&regs->mcr);
6429 @@ -418,36 +445,24 @@ static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
6430 regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
6431 1 << priv->stm.req_bit, 1 << priv->stm.req_bit);
6432
6433 - /* get stop acknowledgment */
6434 - if (regmap_read_poll_timeout(priv->stm.gpr, priv->stm.ack_gpr,
6435 - ackval, ackval & (1 << priv->stm.ack_bit),
6436 - 0, FLEXCAN_TIMEOUT_US))
6437 - return -ETIMEDOUT;
6438 -
6439 - return 0;
6440 + return flexcan_low_power_enter_ack(priv);
6441 }
6442
6443 static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
6444 {
6445 struct flexcan_regs __iomem *regs = priv->regs;
6446 - unsigned int ackval;
6447 u32 reg_mcr;
6448
6449 /* remove stop request */
6450 regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
6451 1 << priv->stm.req_bit, 0);
6452
6453 - /* get stop acknowledgment */
6454 - if (regmap_read_poll_timeout(priv->stm.gpr, priv->stm.ack_gpr,
6455 - ackval, !(ackval & (1 << priv->stm.ack_bit)),
6456 - 0, FLEXCAN_TIMEOUT_US))
6457 - return -ETIMEDOUT;
6458
6459 reg_mcr = priv->read(&regs->mcr);
6460 reg_mcr &= ~FLEXCAN_MCR_SLF_WAK;
6461 priv->write(reg_mcr, &regs->mcr);
6462
6463 - return 0;
6464 + return flexcan_low_power_exit_ack(priv);
6465 }
6466
6467 static inline void flexcan_error_irq_enable(const struct flexcan_priv *priv)
6468 @@ -506,39 +521,25 @@ static inline int flexcan_transceiver_disable(const struct flexcan_priv *priv)
6469 static int flexcan_chip_enable(struct flexcan_priv *priv)
6470 {
6471 struct flexcan_regs __iomem *regs = priv->regs;
6472 - unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
6473 u32 reg;
6474
6475 reg = priv->read(&regs->mcr);
6476 reg &= ~FLEXCAN_MCR_MDIS;
6477 priv->write(reg, &regs->mcr);
6478
6479 - while (timeout-- && (priv->read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK))
6480 - udelay(10);
6481 -
6482 - if (priv->read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK)
6483 - return -ETIMEDOUT;
6484 -
6485 - return 0;
6486 + return flexcan_low_power_exit_ack(priv);
6487 }
6488
6489 static int flexcan_chip_disable(struct flexcan_priv *priv)
6490 {
6491 struct flexcan_regs __iomem *regs = priv->regs;
6492 - unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
6493 u32 reg;
6494
6495 reg = priv->read(&regs->mcr);
6496 reg |= FLEXCAN_MCR_MDIS;
6497 priv->write(reg, &regs->mcr);
6498
6499 - while (timeout-- && !(priv->read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK))
6500 - udelay(10);
6501 -
6502 - if (!(priv->read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK))
6503 - return -ETIMEDOUT;
6504 -
6505 - return 0;
6506 + return flexcan_low_power_enter_ack(priv);
6507 }
6508
6509 static int flexcan_chip_freeze(struct flexcan_priv *priv)
6510 @@ -1703,6 +1704,9 @@ static int __maybe_unused flexcan_resume(struct device *device)
6511 netif_start_queue(dev);
6512 if (device_may_wakeup(device)) {
6513 disable_irq_wake(dev->irq);
6514 + err = flexcan_exit_stop_mode(priv);
6515 + if (err)
6516 + return err;
6517 } else {
6518 err = pm_runtime_force_resume(device);
6519 if (err)
6520 @@ -1748,14 +1752,9 @@ static int __maybe_unused flexcan_noirq_resume(struct device *device)
6521 {
6522 struct net_device *dev = dev_get_drvdata(device);
6523 struct flexcan_priv *priv = netdev_priv(dev);
6524 - int err;
6525
6526 - if (netif_running(dev) && device_may_wakeup(device)) {
6527 + if (netif_running(dev) && device_may_wakeup(device))
6528 flexcan_enable_wakeup_irq(priv, false);
6529 - err = flexcan_exit_stop_mode(priv);
6530 - if (err)
6531 - return err;
6532 - }
6533
6534 return 0;
6535 }
6536 diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/tcan4x5x.c
6537 index 3db619209fe1..d5d4bfa9c8fd 100644
6538 --- a/drivers/net/can/m_can/tcan4x5x.c
6539 +++ b/drivers/net/can/m_can/tcan4x5x.c
6540 @@ -354,6 +354,8 @@ static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
6541 if (IS_ERR(tcan4x5x->reset_gpio))
6542 tcan4x5x->reset_gpio = NULL;
6543
6544 + usleep_range(700, 1000);
6545 +
6546 tcan4x5x->device_state_gpio = devm_gpiod_get_optional(cdev->dev,
6547 "device-state",
6548 GPIOD_IN);
6549 diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
6550 index 07d2f3aa2c02..ae4c37e1bb75 100644
6551 --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
6552 +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
6553 @@ -608,7 +608,7 @@ static int kvaser_usb_leaf_simple_cmd_async(struct kvaser_usb_net_priv *priv,
6554 struct kvaser_cmd *cmd;
6555 int err;
6556
6557 - cmd = kmalloc(sizeof(*cmd), GFP_ATOMIC);
6558 + cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC);
6559 if (!cmd)
6560 return -ENOMEM;
6561
6562 @@ -1140,7 +1140,7 @@ static int kvaser_usb_leaf_set_opt_mode(const struct kvaser_usb_net_priv *priv)
6563 struct kvaser_cmd *cmd;
6564 int rc;
6565
6566 - cmd = kmalloc(sizeof(*cmd), GFP_KERNEL);
6567 + cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
6568 if (!cmd)
6569 return -ENOMEM;
6570
6571 @@ -1206,7 +1206,7 @@ static int kvaser_usb_leaf_flush_queue(struct kvaser_usb_net_priv *priv)
6572 struct kvaser_cmd *cmd;
6573 int rc;
6574
6575 - cmd = kmalloc(sizeof(*cmd), GFP_KERNEL);
6576 + cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
6577 if (!cmd)
6578 return -ENOMEM;
6579
6580 diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
6581 index 7c482b2d78d2..2be846ee627d 100644
6582 --- a/drivers/net/can/xilinx_can.c
6583 +++ b/drivers/net/can/xilinx_can.c
6584 @@ -60,6 +60,8 @@ enum xcan_reg {
6585 XCAN_TXMSG_BASE_OFFSET = 0x0100, /* TX Message Space */
6586 XCAN_RXMSG_BASE_OFFSET = 0x1100, /* RX Message Space */
6587 XCAN_RXMSG_2_BASE_OFFSET = 0x2100, /* RX Message Space */
6588 + XCAN_AFR_2_MASK_OFFSET = 0x0A00, /* Acceptance Filter MASK */
6589 + XCAN_AFR_2_ID_OFFSET = 0x0A04, /* Acceptance Filter ID */
6590 };
6591
6592 #define XCAN_FRAME_ID_OFFSET(frame_base) ((frame_base) + 0x00)
6593 @@ -1803,6 +1805,11 @@ static int xcan_probe(struct platform_device *pdev)
6594
6595 pm_runtime_put(&pdev->dev);
6596
6597 + if (priv->devtype.flags & XCAN_FLAG_CANFD_2) {
6598 + priv->write_reg(priv, XCAN_AFR_2_ID_OFFSET, 0x00000000);
6599 + priv->write_reg(priv, XCAN_AFR_2_MASK_OFFSET, 0x00000000);
6600 + }
6601 +
6602 netdev_dbg(ndev, "reg_base=0x%p irq=%d clock=%d, tx buffers: actual %d, using %d\n",
6603 priv->reg_base, ndev->irq, priv->can.clock.freq,
6604 hw_tx_max, priv->tx_max);
6605 diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig
6606 index f6232ce8481f..685e12b05a7c 100644
6607 --- a/drivers/net/dsa/Kconfig
6608 +++ b/drivers/net/dsa/Kconfig
6609 @@ -77,6 +77,7 @@ config NET_DSA_REALTEK_SMI
6610 config NET_DSA_SMSC_LAN9303
6611 tristate
6612 select NET_DSA_TAG_LAN9303
6613 + select REGMAP
6614 ---help---
6615 This enables support for the SMSC/Microchip LAN9303 3 port ethernet
6616 switch chips.
6617 diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
6618 index cc3536315eff..a7132c1593c3 100644
6619 --- a/drivers/net/dsa/b53/b53_common.c
6620 +++ b/drivers/net/dsa/b53/b53_common.c
6621 @@ -347,7 +347,7 @@ static void b53_set_forwarding(struct b53_device *dev, int enable)
6622 * frames should be flooded or not.
6623 */
6624 b53_read8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, &mgmt);
6625 - mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN;
6626 + mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN | B53_IPMC_FWD_EN;
6627 b53_write8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, mgmt);
6628 }
6629
6630 @@ -526,6 +526,8 @@ int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
6631
6632 cpu_port = ds->ports[port].cpu_dp->index;
6633
6634 + b53_br_egress_floods(ds, port, true, true);
6635 +
6636 if (dev->ops->irq_enable)
6637 ret = dev->ops->irq_enable(dev, port);
6638 if (ret)
6639 @@ -641,6 +643,8 @@ static void b53_enable_cpu_port(struct b53_device *dev, int port)
6640 b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), port_ctrl);
6641
6642 b53_brcm_hdr_setup(dev->ds, port);
6643 +
6644 + b53_br_egress_floods(dev->ds, port, true, true);
6645 }
6646
6647 static void b53_enable_mib(struct b53_device *dev)
6648 @@ -1766,19 +1770,26 @@ int b53_br_egress_floods(struct dsa_switch *ds, int port,
6649 struct b53_device *dev = ds->priv;
6650 u16 uc, mc;
6651
6652 - b53_read16(dev, B53_CTRL_PAGE, B53_UC_FWD_EN, &uc);
6653 + b53_read16(dev, B53_CTRL_PAGE, B53_UC_FLOOD_MASK, &uc);
6654 if (unicast)
6655 uc |= BIT(port);
6656 else
6657 uc &= ~BIT(port);
6658 - b53_write16(dev, B53_CTRL_PAGE, B53_UC_FWD_EN, uc);
6659 + b53_write16(dev, B53_CTRL_PAGE, B53_UC_FLOOD_MASK, uc);
6660 +
6661 + b53_read16(dev, B53_CTRL_PAGE, B53_MC_FLOOD_MASK, &mc);
6662 + if (multicast)
6663 + mc |= BIT(port);
6664 + else
6665 + mc &= ~BIT(port);
6666 + b53_write16(dev, B53_CTRL_PAGE, B53_MC_FLOOD_MASK, mc);
6667
6668 - b53_read16(dev, B53_CTRL_PAGE, B53_MC_FWD_EN, &mc);
6669 + b53_read16(dev, B53_CTRL_PAGE, B53_IPMC_FLOOD_MASK, &mc);
6670 if (multicast)
6671 mc |= BIT(port);
6672 else
6673 mc &= ~BIT(port);
6674 - b53_write16(dev, B53_CTRL_PAGE, B53_MC_FWD_EN, mc);
6675 + b53_write16(dev, B53_CTRL_PAGE, B53_IPMC_FLOOD_MASK, mc);
6676
6677 return 0;
6678
6679 diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
6680 index aa140662c7c2..4e5a428ab1a4 100644
6681 --- a/drivers/net/dsa/sja1105/sja1105_main.c
6682 +++ b/drivers/net/dsa/sja1105/sja1105_main.c
6683 @@ -1389,6 +1389,8 @@ int sja1105_static_config_reload(struct sja1105_private *priv)
6684 int speed_mbps[SJA1105_NUM_PORTS];
6685 int rc, i;
6686
6687 + mutex_lock(&priv->mgmt_lock);
6688 +
6689 mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries;
6690
6691 /* Back up the dynamic link speed changed by sja1105_adjust_port_config
6692 @@ -1420,6 +1422,8 @@ int sja1105_static_config_reload(struct sja1105_private *priv)
6693 goto out;
6694 }
6695 out:
6696 + mutex_unlock(&priv->mgmt_lock);
6697 +
6698 return rc;
6699 }
6700
6701 diff --git a/drivers/net/ethernet/amazon/ena/ena_com.h b/drivers/net/ethernet/amazon/ena/ena_com.h
6702 index 7c941eba0bc9..0ce37d54ed10 100644
6703 --- a/drivers/net/ethernet/amazon/ena/ena_com.h
6704 +++ b/drivers/net/ethernet/amazon/ena/ena_com.h
6705 @@ -72,7 +72,7 @@
6706 /*****************************************************************************/
6707 /* ENA adaptive interrupt moderation settings */
6708
6709 -#define ENA_INTR_INITIAL_TX_INTERVAL_USECS 196
6710 +#define ENA_INTR_INITIAL_TX_INTERVAL_USECS 64
6711 #define ENA_INTR_INITIAL_RX_INTERVAL_USECS 0
6712 #define ENA_DEFAULT_INTR_DELAY_RESOLUTION 1
6713
6714 diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
6715 index 16553d92fad2..8c1c73b0ced7 100644
6716 --- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c
6717 +++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
6718 @@ -315,10 +315,9 @@ static int ena_get_coalesce(struct net_device *net_dev,
6719 ena_com_get_nonadaptive_moderation_interval_tx(ena_dev) *
6720 ena_dev->intr_delay_resolution;
6721
6722 - if (!ena_com_get_adaptive_moderation_enabled(ena_dev))
6723 - coalesce->rx_coalesce_usecs =
6724 - ena_com_get_nonadaptive_moderation_interval_rx(ena_dev)
6725 - * ena_dev->intr_delay_resolution;
6726 + coalesce->rx_coalesce_usecs =
6727 + ena_com_get_nonadaptive_moderation_interval_rx(ena_dev)
6728 + * ena_dev->intr_delay_resolution;
6729
6730 coalesce->use_adaptive_rx_coalesce =
6731 ena_com_get_adaptive_moderation_enabled(ena_dev);
6732 @@ -367,12 +366,6 @@ static int ena_set_coalesce(struct net_device *net_dev,
6733
6734 ena_update_tx_rings_intr_moderation(adapter);
6735
6736 - if (coalesce->use_adaptive_rx_coalesce) {
6737 - if (!ena_com_get_adaptive_moderation_enabled(ena_dev))
6738 - ena_com_enable_adaptive_moderation(ena_dev);
6739 - return 0;
6740 - }
6741 -
6742 rc = ena_com_update_nonadaptive_moderation_interval_rx(ena_dev,
6743 coalesce->rx_coalesce_usecs);
6744 if (rc)
6745 @@ -380,10 +373,13 @@ static int ena_set_coalesce(struct net_device *net_dev,
6746
6747 ena_update_rx_rings_intr_moderation(adapter);
6748
6749 - if (!coalesce->use_adaptive_rx_coalesce) {
6750 - if (ena_com_get_adaptive_moderation_enabled(ena_dev))
6751 - ena_com_disable_adaptive_moderation(ena_dev);
6752 - }
6753 + if (coalesce->use_adaptive_rx_coalesce &&
6754 + !ena_com_get_adaptive_moderation_enabled(ena_dev))
6755 + ena_com_enable_adaptive_moderation(ena_dev);
6756 +
6757 + if (!coalesce->use_adaptive_rx_coalesce &&
6758 + ena_com_get_adaptive_moderation_enabled(ena_dev))
6759 + ena_com_disable_adaptive_moderation(ena_dev);
6760
6761 return 0;
6762 }
6763 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
6764 index 0edbb0a76847..5097a44686b3 100644
6765 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
6766 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
6767 @@ -2397,15 +2397,21 @@ static int bnx2x_set_pf_tx_switching(struct bnx2x *bp, bool enable)
6768 /* send the ramrod on all the queues of the PF */
6769 for_each_eth_queue(bp, i) {
6770 struct bnx2x_fastpath *fp = &bp->fp[i];
6771 + int tx_idx;
6772
6773 /* Set the appropriate Queue object */
6774 q_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
6775
6776 - /* Update the Queue state */
6777 - rc = bnx2x_queue_state_change(bp, &q_params);
6778 - if (rc) {
6779 - BNX2X_ERR("Failed to configure Tx switching\n");
6780 - return rc;
6781 + for (tx_idx = FIRST_TX_COS_INDEX;
6782 + tx_idx < fp->max_cos; tx_idx++) {
6783 + q_params.params.update.cid_index = tx_idx;
6784 +
6785 + /* Update the Queue state */
6786 + rc = bnx2x_queue_state_change(bp, &q_params);
6787 + if (rc) {
6788 + BNX2X_ERR("Failed to configure Tx switching\n");
6789 + return rc;
6790 + }
6791 }
6792 }
6793
6794 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
6795 index 04ec909e06df..527e1bf93116 100644
6796 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
6797 +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
6798 @@ -1767,8 +1767,12 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
6799
6800 rc = -EIO;
6801 if (rx_err & RX_CMPL_ERRORS_BUFFER_ERROR_MASK) {
6802 - netdev_warn(bp->dev, "RX buffer error %x\n", rx_err);
6803 - bnxt_sched_reset(bp, rxr);
6804 + bnapi->cp_ring.rx_buf_errors++;
6805 + if (!(bp->flags & BNXT_FLAG_CHIP_P5)) {
6806 + netdev_warn(bp->dev, "RX buffer error %x\n",
6807 + rx_err);
6808 + bnxt_sched_reset(bp, rxr);
6809 + }
6810 }
6811 goto next_rx_no_len;
6812 }
6813 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
6814 index d333589811a5..5163bb848618 100644
6815 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
6816 +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
6817 @@ -927,6 +927,7 @@ struct bnxt_cp_ring_info {
6818 dma_addr_t hw_stats_map;
6819 u32 hw_stats_ctx_id;
6820 u64 rx_l4_csum_errors;
6821 + u64 rx_buf_errors;
6822 u64 missed_irqs;
6823
6824 struct bnxt_ring_struct cp_ring_struct;
6825 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
6826 index 7151244f8c7d..7d2cfea05737 100644
6827 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
6828 +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
6829 @@ -311,10 +311,17 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
6830 } else {
6831 rc = hwrm_send_message_silent(bp, msg, msg_len,
6832 HWRM_CMD_TIMEOUT);
6833 - if (!rc)
6834 + if (!rc) {
6835 bnxt_copy_from_nvm_data(val, data,
6836 nvm_param.nvm_num_bits,
6837 nvm_param.dl_num_bytes);
6838 + } else {
6839 + struct hwrm_err_output *resp = bp->hwrm_cmd_resp_addr;
6840 +
6841 + if (resp->cmd_err ==
6842 + NVM_GET_VARIABLE_CMD_ERR_CODE_VAR_NOT_EXIST)
6843 + rc = -EOPNOTSUPP;
6844 + }
6845 }
6846 dma_free_coherent(&bp->pdev->dev, sizeof(*data), data, data_dma_addr);
6847 if (rc == -EACCES)
6848 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
6849 index 51c140476717..89f95428556e 100644
6850 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
6851 +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
6852 @@ -173,6 +173,7 @@ static const char * const bnxt_ring_tpa2_stats_str[] = {
6853
6854 static const char * const bnxt_ring_sw_stats_str[] = {
6855 "rx_l4_csum_errors",
6856 + "rx_buf_errors",
6857 "missed_irqs",
6858 };
6859
6860 @@ -552,6 +553,7 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
6861 for (k = 0; k < stat_fields; j++, k++)
6862 buf[j] = le64_to_cpu(hw_stats[k]);
6863 buf[j++] = cpr->rx_l4_csum_errors;
6864 + buf[j++] = cpr->rx_buf_errors;
6865 buf[j++] = cpr->missed_irqs;
6866
6867 bnxt_sw_func_stats[RX_TOTAL_DISCARDS].counter +=
6868 diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
6869 index a8f4c69252ff..2814b96751b4 100644
6870 --- a/drivers/net/ethernet/cortina/gemini.c
6871 +++ b/drivers/net/ethernet/cortina/gemini.c
6872 @@ -576,6 +576,8 @@ static int gmac_setup_txqs(struct net_device *netdev)
6873
6874 if (port->txq_dma_base & ~DMA_Q_BASE_MASK) {
6875 dev_warn(geth->dev, "TX queue base is not aligned\n");
6876 + dma_free_coherent(geth->dev, len * sizeof(*desc_ring),
6877 + desc_ring, port->txq_dma_base);
6878 kfree(skb_tab);
6879 return -ENOMEM;
6880 }
6881 diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
6882 index a9503aea527f..6437fe6b9abf 100644
6883 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
6884 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
6885 @@ -160,10 +160,10 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)
6886 irq = mc_dev->irqs[0];
6887 ptp_qoriq->irq = irq->msi_desc->irq;
6888
6889 - err = devm_request_threaded_irq(dev, ptp_qoriq->irq, NULL,
6890 - dpaa2_ptp_irq_handler_thread,
6891 - IRQF_NO_SUSPEND | IRQF_ONESHOT,
6892 - dev_name(dev), ptp_qoriq);
6893 + err = request_threaded_irq(ptp_qoriq->irq, NULL,
6894 + dpaa2_ptp_irq_handler_thread,
6895 + IRQF_NO_SUSPEND | IRQF_ONESHOT,
6896 + dev_name(dev), ptp_qoriq);
6897 if (err < 0) {
6898 dev_err(dev, "devm_request_threaded_irq(): %d\n", err);
6899 goto err_free_mc_irq;
6900 @@ -173,18 +173,20 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)
6901 DPRTC_IRQ_INDEX, 1);
6902 if (err < 0) {
6903 dev_err(dev, "dprtc_set_irq_enable(): %d\n", err);
6904 - goto err_free_mc_irq;
6905 + goto err_free_threaded_irq;
6906 }
6907
6908 err = ptp_qoriq_init(ptp_qoriq, base, &dpaa2_ptp_caps);
6909 if (err)
6910 - goto err_free_mc_irq;
6911 + goto err_free_threaded_irq;
6912
6913 dpaa2_phc_index = ptp_qoriq->phc_index;
6914 dev_set_drvdata(dev, ptp_qoriq);
6915
6916 return 0;
6917
6918 +err_free_threaded_irq:
6919 + free_irq(ptp_qoriq->irq, ptp_qoriq);
6920 err_free_mc_irq:
6921 fsl_mc_free_irqs(mc_dev);
6922 err_unmap:
6923 diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c
6924 index 4606a7e4a6d1..2ffe035e96d6 100644
6925 --- a/drivers/net/ethernet/hisilicon/hip04_eth.c
6926 +++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
6927 @@ -543,9 +543,9 @@ hip04_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
6928 skb_tx_timestamp(skb);
6929
6930 hip04_set_xmit_desc(priv, phys);
6931 - priv->tx_head = TX_NEXT(tx_head);
6932 count++;
6933 netdev_sent_queue(ndev, skb->len);
6934 + priv->tx_head = TX_NEXT(tx_head);
6935
6936 stats->tx_bytes += skb->len;
6937 stats->tx_packets++;
6938 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
6939 index 616cad0faa21..84d8816c8681 100644
6940 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
6941 +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
6942 @@ -1692,6 +1692,9 @@ static bool hns3_get_tx_timeo_queue_info(struct net_device *ndev)
6943 time_after(jiffies,
6944 (trans_start + ndev->watchdog_timeo))) {
6945 timeout_queue = i;
6946 + netdev_info(ndev, "queue state: 0x%lx, delta msecs: %u\n",
6947 + q->state,
6948 + jiffies_to_msecs(jiffies - trans_start));
6949 break;
6950 }
6951 }
6952 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
6953 index c052bb33b3d3..162881005a6d 100644
6954 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
6955 +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
6956 @@ -9443,6 +9443,9 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev)
6957 return ret;
6958 }
6959
6960 + /* Log and clear the hw errors those already occurred */
6961 + hclge_handle_all_hns_hw_errors(ae_dev);
6962 +
6963 /* Re-enable the hw error interrupts because
6964 * the interrupts get disabled on global reset.
6965 */
6966 diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
6967 index 0686ded7ad3a..e1ab2feeae53 100644
6968 --- a/drivers/net/ethernet/ibm/ibmvnic.c
6969 +++ b/drivers/net/ethernet/ibm/ibmvnic.c
6970 @@ -176,7 +176,7 @@ static int alloc_long_term_buff(struct ibmvnic_adapter *adapter,
6971 ltb->map_id = adapter->map_id;
6972 adapter->map_id++;
6973
6974 - init_completion(&adapter->fw_done);
6975 + reinit_completion(&adapter->fw_done);
6976 rc = send_request_map(adapter, ltb->addr,
6977 ltb->size, ltb->map_id);
6978 if (rc) {
6979 @@ -215,7 +215,7 @@ static int reset_long_term_buff(struct ibmvnic_adapter *adapter,
6980
6981 memset(ltb->buff, 0, ltb->size);
6982
6983 - init_completion(&adapter->fw_done);
6984 + reinit_completion(&adapter->fw_done);
6985 rc = send_request_map(adapter, ltb->addr, ltb->size, ltb->map_id);
6986 if (rc)
6987 return rc;
6988 @@ -943,7 +943,7 @@ static int ibmvnic_get_vpd(struct ibmvnic_adapter *adapter)
6989 if (adapter->vpd->buff)
6990 len = adapter->vpd->len;
6991
6992 - init_completion(&adapter->fw_done);
6993 + reinit_completion(&adapter->fw_done);
6994 crq.get_vpd_size.first = IBMVNIC_CRQ_CMD;
6995 crq.get_vpd_size.cmd = GET_VPD_SIZE;
6996 rc = ibmvnic_send_crq(adapter, &crq);
6997 @@ -1689,7 +1689,7 @@ static int __ibmvnic_set_mac(struct net_device *netdev, u8 *dev_addr)
6998 crq.change_mac_addr.cmd = CHANGE_MAC_ADDR;
6999 ether_addr_copy(&crq.change_mac_addr.mac_addr[0], dev_addr);
7000
7001 - init_completion(&adapter->fw_done);
7002 + reinit_completion(&adapter->fw_done);
7003 rc = ibmvnic_send_crq(adapter, &crq);
7004 if (rc) {
7005 rc = -EIO;
7006 @@ -2316,7 +2316,7 @@ static int wait_for_reset(struct ibmvnic_adapter *adapter)
7007 adapter->fallback.rx_entries = adapter->req_rx_add_entries_per_subcrq;
7008 adapter->fallback.tx_entries = adapter->req_tx_entries_per_subcrq;
7009
7010 - init_completion(&adapter->reset_done);
7011 + reinit_completion(&adapter->reset_done);
7012 adapter->wait_for_reset = true;
7013 rc = ibmvnic_reset(adapter, VNIC_RESET_CHANGE_PARAM);
7014 if (rc)
7015 @@ -2332,7 +2332,7 @@ static int wait_for_reset(struct ibmvnic_adapter *adapter)
7016 adapter->desired.rx_entries = adapter->fallback.rx_entries;
7017 adapter->desired.tx_entries = adapter->fallback.tx_entries;
7018
7019 - init_completion(&adapter->reset_done);
7020 + reinit_completion(&adapter->reset_done);
7021 adapter->wait_for_reset = true;
7022 rc = ibmvnic_reset(adapter, VNIC_RESET_CHANGE_PARAM);
7023 if (rc)
7024 @@ -2603,7 +2603,7 @@ static void ibmvnic_get_ethtool_stats(struct net_device *dev,
7025 cpu_to_be32(sizeof(struct ibmvnic_statistics));
7026
7027 /* Wait for data to be written */
7028 - init_completion(&adapter->stats_done);
7029 + reinit_completion(&adapter->stats_done);
7030 rc = ibmvnic_send_crq(adapter, &crq);
7031 if (rc)
7032 return;
7033 @@ -4408,7 +4408,7 @@ static int send_query_phys_parms(struct ibmvnic_adapter *adapter)
7034 memset(&crq, 0, sizeof(crq));
7035 crq.query_phys_parms.first = IBMVNIC_CRQ_CMD;
7036 crq.query_phys_parms.cmd = QUERY_PHYS_PARMS;
7037 - init_completion(&adapter->fw_done);
7038 + reinit_completion(&adapter->fw_done);
7039 rc = ibmvnic_send_crq(adapter, &crq);
7040 if (rc)
7041 return rc;
7042 @@ -4960,6 +4960,9 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
7043 INIT_LIST_HEAD(&adapter->rwi_list);
7044 spin_lock_init(&adapter->rwi_lock);
7045 init_completion(&adapter->init_done);
7046 + init_completion(&adapter->fw_done);
7047 + init_completion(&adapter->reset_done);
7048 + init_completion(&adapter->stats_done);
7049 clear_bit(0, &adapter->resetting);
7050
7051 do {
7052 diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
7053 index 7560f06768e0..3160b5bbe672 100644
7054 --- a/drivers/net/ethernet/intel/i40e/i40e_common.c
7055 +++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
7056 @@ -2571,9 +2571,16 @@ noinline_for_stack i40e_status i40e_update_link_info(struct i40e_hw *hw)
7057 if (status)
7058 return status;
7059
7060 - hw->phy.link_info.req_fec_info =
7061 - abilities.fec_cfg_curr_mod_ext_info &
7062 - (I40E_AQ_REQUEST_FEC_KR | I40E_AQ_REQUEST_FEC_RS);
7063 + if (abilities.fec_cfg_curr_mod_ext_info &
7064 + I40E_AQ_ENABLE_FEC_AUTO)
7065 + hw->phy.link_info.req_fec_info =
7066 + (I40E_AQ_REQUEST_FEC_KR |
7067 + I40E_AQ_REQUEST_FEC_RS);
7068 + else
7069 + hw->phy.link_info.req_fec_info =
7070 + abilities.fec_cfg_curr_mod_ext_info &
7071 + (I40E_AQ_REQUEST_FEC_KR |
7072 + I40E_AQ_REQUEST_FEC_RS);
7073
7074 memcpy(hw->phy.link_info.module_type, &abilities.module_type,
7075 sizeof(hw->phy.link_info.module_type));
7076 diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
7077 index 41e1240acaea..b577e6adf3bf 100644
7078 --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
7079 +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
7080 @@ -722,7 +722,14 @@ static void i40e_get_settings_link_up_fec(u8 req_fec_info,
7081 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS);
7082 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER);
7083
7084 - if (I40E_AQ_SET_FEC_REQUEST_RS & req_fec_info) {
7085 + if ((I40E_AQ_SET_FEC_REQUEST_RS & req_fec_info) &&
7086 + (I40E_AQ_SET_FEC_REQUEST_KR & req_fec_info)) {
7087 + ethtool_link_ksettings_add_link_mode(ks, advertising,
7088 + FEC_NONE);
7089 + ethtool_link_ksettings_add_link_mode(ks, advertising,
7090 + FEC_BASER);
7091 + ethtool_link_ksettings_add_link_mode(ks, advertising, FEC_RS);
7092 + } else if (I40E_AQ_SET_FEC_REQUEST_RS & req_fec_info) {
7093 ethtool_link_ksettings_add_link_mode(ks, advertising, FEC_RS);
7094 } else if (I40E_AQ_SET_FEC_REQUEST_KR & req_fec_info) {
7095 ethtool_link_ksettings_add_link_mode(ks, advertising,
7096 @@ -730,12 +737,6 @@ static void i40e_get_settings_link_up_fec(u8 req_fec_info,
7097 } else {
7098 ethtool_link_ksettings_add_link_mode(ks, advertising,
7099 FEC_NONE);
7100 - if (I40E_AQ_SET_FEC_AUTO & req_fec_info) {
7101 - ethtool_link_ksettings_add_link_mode(ks, advertising,
7102 - FEC_RS);
7103 - ethtool_link_ksettings_add_link_mode(ks, advertising,
7104 - FEC_BASER);
7105 - }
7106 }
7107 }
7108
7109 @@ -1437,6 +1438,7 @@ static int i40e_get_fec_param(struct net_device *netdev,
7110 struct i40e_hw *hw = &pf->hw;
7111 i40e_status status = 0;
7112 int err = 0;
7113 + u8 fec_cfg;
7114
7115 /* Get the current phy config */
7116 memset(&abilities, 0, sizeof(abilities));
7117 @@ -1448,18 +1450,16 @@ static int i40e_get_fec_param(struct net_device *netdev,
7118 }
7119
7120 fecparam->fec = 0;
7121 - if (abilities.fec_cfg_curr_mod_ext_info & I40E_AQ_SET_FEC_AUTO)
7122 + fec_cfg = abilities.fec_cfg_curr_mod_ext_info;
7123 + if (fec_cfg & I40E_AQ_SET_FEC_AUTO)
7124 fecparam->fec |= ETHTOOL_FEC_AUTO;
7125 - if ((abilities.fec_cfg_curr_mod_ext_info &
7126 - I40E_AQ_SET_FEC_REQUEST_RS) ||
7127 - (abilities.fec_cfg_curr_mod_ext_info &
7128 - I40E_AQ_SET_FEC_ABILITY_RS))
7129 + else if (fec_cfg & (I40E_AQ_SET_FEC_REQUEST_RS |
7130 + I40E_AQ_SET_FEC_ABILITY_RS))
7131 fecparam->fec |= ETHTOOL_FEC_RS;
7132 - if ((abilities.fec_cfg_curr_mod_ext_info &
7133 - I40E_AQ_SET_FEC_REQUEST_KR) ||
7134 - (abilities.fec_cfg_curr_mod_ext_info & I40E_AQ_SET_FEC_ABILITY_KR))
7135 + else if (fec_cfg & (I40E_AQ_SET_FEC_REQUEST_KR |
7136 + I40E_AQ_SET_FEC_ABILITY_KR))
7137 fecparam->fec |= ETHTOOL_FEC_BASER;
7138 - if (abilities.fec_cfg_curr_mod_ext_info == 0)
7139 + if (fec_cfg == 0)
7140 fecparam->fec |= ETHTOOL_FEC_OFF;
7141
7142 if (hw->phy.link_info.fec_info & I40E_AQ_CONFIG_FEC_KR_ENA)
7143 diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
7144 index 6031223eafab..339925af0206 100644
7145 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
7146 +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
7147 @@ -3534,14 +3534,14 @@ static void i40e_vsi_configure_msix(struct i40e_vsi *vsi)
7148 q_vector->rx.target_itr =
7149 ITR_TO_REG(vsi->rx_rings[i]->itr_setting);
7150 wr32(hw, I40E_PFINT_ITRN(I40E_RX_ITR, vector - 1),
7151 - q_vector->rx.target_itr);
7152 + q_vector->rx.target_itr >> 1);
7153 q_vector->rx.current_itr = q_vector->rx.target_itr;
7154
7155 q_vector->tx.next_update = jiffies + 1;
7156 q_vector->tx.target_itr =
7157 ITR_TO_REG(vsi->tx_rings[i]->itr_setting);
7158 wr32(hw, I40E_PFINT_ITRN(I40E_TX_ITR, vector - 1),
7159 - q_vector->tx.target_itr);
7160 + q_vector->tx.target_itr >> 1);
7161 q_vector->tx.current_itr = q_vector->tx.target_itr;
7162
7163 wr32(hw, I40E_PFINT_RATEN(vector - 1),
7164 @@ -3646,11 +3646,11 @@ static void i40e_configure_msi_and_legacy(struct i40e_vsi *vsi)
7165 /* set the ITR configuration */
7166 q_vector->rx.next_update = jiffies + 1;
7167 q_vector->rx.target_itr = ITR_TO_REG(vsi->rx_rings[0]->itr_setting);
7168 - wr32(hw, I40E_PFINT_ITR0(I40E_RX_ITR), q_vector->rx.target_itr);
7169 + wr32(hw, I40E_PFINT_ITR0(I40E_RX_ITR), q_vector->rx.target_itr >> 1);
7170 q_vector->rx.current_itr = q_vector->rx.target_itr;
7171 q_vector->tx.next_update = jiffies + 1;
7172 q_vector->tx.target_itr = ITR_TO_REG(vsi->tx_rings[0]->itr_setting);
7173 - wr32(hw, I40E_PFINT_ITR0(I40E_TX_ITR), q_vector->tx.target_itr);
7174 + wr32(hw, I40E_PFINT_ITR0(I40E_TX_ITR), q_vector->tx.target_itr >> 1);
7175 q_vector->tx.current_itr = q_vector->tx.target_itr;
7176
7177 i40e_enable_misc_int_causes(pf);
7178 @@ -11396,7 +11396,7 @@ static int i40e_setup_misc_vector(struct i40e_pf *pf)
7179
7180 /* associate no queues to the misc vector */
7181 wr32(hw, I40E_PFINT_LNKLST0, I40E_QUEUE_END_OF_LIST);
7182 - wr32(hw, I40E_PFINT_ITR0(I40E_RX_ITR), I40E_ITR_8K);
7183 + wr32(hw, I40E_PFINT_ITR0(I40E_RX_ITR), I40E_ITR_8K >> 1);
7184
7185 i40e_flush(hw);
7186
7187 diff --git a/drivers/net/ethernet/intel/ice/ice_controlq.c b/drivers/net/ethernet/intel/ice/ice_controlq.c
7188 index 2353166c654e..c68709c7ef81 100644
7189 --- a/drivers/net/ethernet/intel/ice/ice_controlq.c
7190 +++ b/drivers/net/ethernet/intel/ice/ice_controlq.c
7191 @@ -948,7 +948,7 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
7192 if (ice_sq_done(hw, cq))
7193 break;
7194
7195 - mdelay(1);
7196 + udelay(ICE_CTL_Q_SQ_CMD_USEC);
7197 total_delay++;
7198 } while (total_delay < cq->sq_cmd_timeout);
7199
7200 diff --git a/drivers/net/ethernet/intel/ice/ice_controlq.h b/drivers/net/ethernet/intel/ice/ice_controlq.h
7201 index 44945c2165d8..4df9da359135 100644
7202 --- a/drivers/net/ethernet/intel/ice/ice_controlq.h
7203 +++ b/drivers/net/ethernet/intel/ice/ice_controlq.h
7204 @@ -31,8 +31,9 @@ enum ice_ctl_q {
7205 ICE_CTL_Q_MAILBOX,
7206 };
7207
7208 -/* Control Queue default settings */
7209 -#define ICE_CTL_Q_SQ_CMD_TIMEOUT 250 /* msecs */
7210 +/* Control Queue timeout settings - max delay 250ms */
7211 +#define ICE_CTL_Q_SQ_CMD_TIMEOUT 2500 /* Count 2500 times */
7212 +#define ICE_CTL_Q_SQ_CMD_USEC 100 /* Check every 100usec */
7213
7214 struct ice_ctl_q_ring {
7215 void *dma_head; /* Virtual address to DMA head */
7216 diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
7217 index 7e23034df955..1fe9f6050635 100644
7218 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
7219 +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
7220 @@ -3368,10 +3368,17 @@ __ice_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec,
7221 struct ice_vsi *vsi = np->vsi;
7222
7223 if (q_num < 0) {
7224 - int i;
7225 + int v_idx;
7226 +
7227 + ice_for_each_q_vector(vsi, v_idx) {
7228 + /* In some cases if DCB is configured the num_[rx|tx]q
7229 + * can be less than vsi->num_q_vectors. This check
7230 + * accounts for that so we don't report a false failure
7231 + */
7232 + if (v_idx >= vsi->num_rxq && v_idx >= vsi->num_txq)
7233 + goto set_complete;
7234
7235 - ice_for_each_q_vector(vsi, i) {
7236 - if (ice_set_q_coalesce(vsi, ec, i))
7237 + if (ice_set_q_coalesce(vsi, ec, v_idx))
7238 return -EINVAL;
7239 }
7240 goto set_complete;
7241 diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
7242 index 214cd6eca405..2408f0de95fc 100644
7243 --- a/drivers/net/ethernet/intel/ice/ice_main.c
7244 +++ b/drivers/net/ethernet/intel/ice/ice_main.c
7245 @@ -3970,8 +3970,13 @@ int ice_vsi_setup_tx_rings(struct ice_vsi *vsi)
7246 }
7247
7248 ice_for_each_txq(vsi, i) {
7249 - vsi->tx_rings[i]->netdev = vsi->netdev;
7250 - err = ice_setup_tx_ring(vsi->tx_rings[i]);
7251 + struct ice_ring *ring = vsi->tx_rings[i];
7252 +
7253 + if (!ring)
7254 + return -EINVAL;
7255 +
7256 + ring->netdev = vsi->netdev;
7257 + err = ice_setup_tx_ring(ring);
7258 if (err)
7259 break;
7260 }
7261 @@ -3996,8 +4001,13 @@ int ice_vsi_setup_rx_rings(struct ice_vsi *vsi)
7262 }
7263
7264 ice_for_each_rxq(vsi, i) {
7265 - vsi->rx_rings[i]->netdev = vsi->netdev;
7266 - err = ice_setup_rx_ring(vsi->rx_rings[i]);
7267 + struct ice_ring *ring = vsi->rx_rings[i];
7268 +
7269 + if (!ring)
7270 + return -EINVAL;
7271 +
7272 + ring->netdev = vsi->netdev;
7273 + err = ice_setup_rx_ring(ring);
7274 if (err)
7275 break;
7276 }
7277 diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
7278 index b45797f39b2f..c0637a0cbfe8 100644
7279 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
7280 +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
7281 @@ -317,8 +317,9 @@ void ice_free_vfs(struct ice_pf *pf)
7282 pf->num_alloc_vfs = 0;
7283 for (i = 0; i < tmp; i++) {
7284 if (test_bit(ICE_VF_STATE_INIT, pf->vf[i].vf_states)) {
7285 - /* disable VF qp mappings */
7286 + /* disable VF qp mappings and set VF disable state */
7287 ice_dis_vf_mappings(&pf->vf[i]);
7288 + set_bit(ICE_VF_STATE_DIS, pf->vf[i].vf_states);
7289 ice_free_vf_res(&pf->vf[i]);
7290 }
7291 }
7292 @@ -1287,9 +1288,12 @@ static void ice_vc_notify_vf_reset(struct ice_vf *vf)
7293 if (!vf || vf->vf_id >= vf->pf->num_alloc_vfs)
7294 return;
7295
7296 - /* verify if the VF is in either init or active before proceeding */
7297 - if (!test_bit(ICE_VF_STATE_INIT, vf->vf_states) &&
7298 - !test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
7299 + /* Bail out if VF is in disabled state, neither initialized, nor active
7300 + * state - otherwise proceed with notifications
7301 + */
7302 + if ((!test_bit(ICE_VF_STATE_INIT, vf->vf_states) &&
7303 + !test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) ||
7304 + test_bit(ICE_VF_STATE_DIS, vf->vf_states))
7305 return;
7306
7307 pfe.event = VIRTCHNL_EVENT_RESET_IMPENDING;
7308 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
7309 index 91b3780ddb04..1a7203fede12 100644
7310 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
7311 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
7312 @@ -8639,7 +8639,8 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
7313
7314 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
7315 adapter->ptp_clock) {
7316 - if (!test_and_set_bit_lock(__IXGBE_PTP_TX_IN_PROGRESS,
7317 + if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON &&
7318 + !test_and_set_bit_lock(__IXGBE_PTP_TX_IN_PROGRESS,
7319 &adapter->state)) {
7320 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
7321 tx_flags |= IXGBE_TX_FLAGS_TSTAMP;
7322 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
7323 index c2c7f214a56a..814a4ba4e7fa 100644
7324 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
7325 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
7326 @@ -3443,6 +3443,12 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
7327 attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
7328 }
7329
7330 + if (!(attr->action &
7331 + (MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | MLX5_FLOW_CONTEXT_ACTION_DROP))) {
7332 + NL_SET_ERR_MSG(extack, "Rule must have at least one forward/drop action");
7333 + return -EOPNOTSUPP;
7334 + }
7335 +
7336 if (attr->split_count > 0 && !mlx5_esw_has_fwd_fdb(priv->mdev)) {
7337 NL_SET_ERR_MSG_MOD(extack,
7338 "current firmware doesn't support split rule for port mirroring");
7339 diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
7340 index 39d600c8b92d..210ebc91d3d6 100644
7341 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
7342 +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
7343 @@ -5637,8 +5637,13 @@ static void mlxsw_sp_router_fib6_del(struct mlxsw_sp *mlxsw_sp,
7344 if (mlxsw_sp_fib6_rt_should_ignore(rt))
7345 return;
7346
7347 + /* Multipath routes are first added to the FIB trie and only then
7348 + * notified. If we vetoed the addition, we will get a delete
7349 + * notification for a route we do not have. Therefore, do not warn if
7350 + * route was not found.
7351 + */
7352 fib6_entry = mlxsw_sp_fib6_entry_lookup(mlxsw_sp, rt);
7353 - if (WARN_ON(!fib6_entry))
7354 + if (!fib6_entry)
7355 return;
7356
7357 /* If not all the nexthops are deleted, then only reduce the nexthop
7358 diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c
7359 index 7c4a15e967df..5defd31d481c 100644
7360 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c
7361 +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c
7362 @@ -65,17 +65,17 @@ static int nfp_get_stats_entry(struct nfp_app *app, u32 *stats_context_id)
7363 freed_stats_id = priv->stats_ring_size;
7364 /* Check for unallocated entries first. */
7365 if (priv->stats_ids.init_unalloc > 0) {
7366 - if (priv->active_mem_unit == priv->total_mem_units) {
7367 - priv->stats_ids.init_unalloc--;
7368 - priv->active_mem_unit = 0;
7369 - }
7370 -
7371 *stats_context_id =
7372 FIELD_PREP(NFP_FL_STAT_ID_STAT,
7373 priv->stats_ids.init_unalloc - 1) |
7374 FIELD_PREP(NFP_FL_STAT_ID_MU_NUM,
7375 priv->active_mem_unit);
7376 - priv->active_mem_unit++;
7377 +
7378 + if (++priv->active_mem_unit == priv->total_mem_units) {
7379 + priv->stats_ids.init_unalloc--;
7380 + priv->active_mem_unit = 0;
7381 + }
7382 +
7383 return 0;
7384 }
7385
7386 diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
7387 index 9a6a9a008714..c8bdbf057d5a 100644
7388 --- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
7389 +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
7390 @@ -1230,7 +1230,7 @@ qede_configure_mcast_filtering(struct net_device *ndev,
7391 netif_addr_lock_bh(ndev);
7392
7393 mc_count = netdev_mc_count(ndev);
7394 - if (mc_count < 64) {
7395 + if (mc_count <= 64) {
7396 netdev_for_each_mc_addr(ha, ndev) {
7397 ether_addr_copy(temp, ha->addr);
7398 temp += ETH_ALEN;
7399 diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
7400 index a220cc7c947a..ba53612ae0df 100644
7401 --- a/drivers/net/ethernet/qlogic/qede/qede_main.c
7402 +++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
7403 @@ -1406,6 +1406,7 @@ static int qede_alloc_mem_rxq(struct qede_dev *edev, struct qede_rx_queue *rxq)
7404 rxq->rx_buf_seg_size = roundup_pow_of_two(size);
7405 } else {
7406 rxq->rx_buf_seg_size = PAGE_SIZE;
7407 + edev->ndev->features &= ~NETIF_F_GRO_HW;
7408 }
7409
7410 /* Allocate the parallel driver ring for Rx buffers */
7411 @@ -1450,6 +1451,7 @@ static int qede_alloc_mem_rxq(struct qede_dev *edev, struct qede_rx_queue *rxq)
7412 }
7413 }
7414
7415 + edev->gro_disable = !(edev->ndev->features & NETIF_F_GRO_HW);
7416 if (!edev->gro_disable)
7417 qede_set_tpa_param(rxq);
7418 err:
7419 @@ -1702,8 +1704,6 @@ static void qede_init_fp(struct qede_dev *edev)
7420 snprintf(fp->name, sizeof(fp->name), "%s-fp-%d",
7421 edev->ndev->name, queue_id);
7422 }
7423 -
7424 - edev->gro_disable = !(edev->ndev->features & NETIF_F_GRO_HW);
7425 }
7426
7427 static int qede_set_real_num_queues(struct qede_dev *edev)
7428 diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c
7429 index b4b8ba00ee01..986f26578d34 100644
7430 --- a/drivers/net/ethernet/qlogic/qla3xxx.c
7431 +++ b/drivers/net/ethernet/qlogic/qla3xxx.c
7432 @@ -2756,6 +2756,9 @@ static int ql_alloc_large_buffers(struct ql3_adapter *qdev)
7433 int err;
7434
7435 for (i = 0; i < qdev->num_large_buffers; i++) {
7436 + lrg_buf_cb = &qdev->lrg_buf[i];
7437 + memset(lrg_buf_cb, 0, sizeof(struct ql_rcv_buf_cb));
7438 +
7439 skb = netdev_alloc_skb(qdev->ndev,
7440 qdev->lrg_buffer_len);
7441 if (unlikely(!skb)) {
7442 @@ -2766,11 +2769,7 @@ static int ql_alloc_large_buffers(struct ql3_adapter *qdev)
7443 ql_free_large_buffers(qdev);
7444 return -ENOMEM;
7445 } else {
7446 -
7447 - lrg_buf_cb = &qdev->lrg_buf[i];
7448 - memset(lrg_buf_cb, 0, sizeof(struct ql_rcv_buf_cb));
7449 lrg_buf_cb->index = i;
7450 - lrg_buf_cb->skb = skb;
7451 /*
7452 * We save some space to copy the ethhdr from first
7453 * buffer
7454 @@ -2792,6 +2791,7 @@ static int ql_alloc_large_buffers(struct ql3_adapter *qdev)
7455 return -ENOMEM;
7456 }
7457
7458 + lrg_buf_cb->skb = skb;
7459 dma_unmap_addr_set(lrg_buf_cb, mapaddr, map);
7460 dma_unmap_len_set(lrg_buf_cb, maplen,
7461 qdev->lrg_buffer_len -
7462 diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
7463 index 4fe0977d01fa..5ae0b5663d54 100644
7464 --- a/drivers/net/ethernet/realtek/r8169_main.c
7465 +++ b/drivers/net/ethernet/realtek/r8169_main.c
7466 @@ -680,6 +680,7 @@ struct rtl8169_private {
7467 struct rtl8169_counters *counters;
7468 struct rtl8169_tc_offsets tc_offset;
7469 u32 saved_wolopts;
7470 + int eee_adv;
7471
7472 const char *fw_name;
7473 struct rtl_fw *rtl_fw;
7474 @@ -2075,6 +2076,10 @@ static int rtl8169_set_eee(struct net_device *dev, struct ethtool_eee *data)
7475 }
7476
7477 ret = phy_ethtool_set_eee(tp->phydev, data);
7478 +
7479 + if (!ret)
7480 + tp->eee_adv = phy_read_mmd(dev->phydev, MDIO_MMD_AN,
7481 + MDIO_AN_EEE_ADV);
7482 out:
7483 pm_runtime_put_noidle(d);
7484 return ret;
7485 @@ -2105,10 +2110,16 @@ static const struct ethtool_ops rtl8169_ethtool_ops = {
7486 static void rtl_enable_eee(struct rtl8169_private *tp)
7487 {
7488 struct phy_device *phydev = tp->phydev;
7489 - int supported = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
7490 + int adv;
7491 +
7492 + /* respect EEE advertisement the user may have set */
7493 + if (tp->eee_adv >= 0)
7494 + adv = tp->eee_adv;
7495 + else
7496 + adv = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
7497
7498 - if (supported > 0)
7499 - phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, supported);
7500 + if (adv >= 0)
7501 + phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
7502 }
7503
7504 static void rtl8169_get_mac_version(struct rtl8169_private *tp)
7505 @@ -7064,6 +7075,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7506 tp->pci_dev = pdev;
7507 tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT);
7508 tp->supports_gmii = ent->driver_data == RTL_CFG_NO_GBIT ? 0 : 1;
7509 + tp->eee_adv = -1;
7510
7511 /* Get the *optional* external "ether_clk" used on some boards */
7512 rc = rtl_get_ether_clk(tp);
7513 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
7514 index 170c3a052b14..1f230bd854c4 100644
7515 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
7516 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
7517 @@ -320,7 +320,7 @@ out:
7518 static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
7519 struct device_node *np, struct device *dev)
7520 {
7521 - bool mdio = true;
7522 + bool mdio = false;
7523 static const struct of_device_id need_mdio_ids[] = {
7524 { .compatible = "snps,dwc-qos-ethernet-4.10" },
7525 {},
7526 diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
7527 index 834afca3a019..137632b09c72 100644
7528 --- a/drivers/net/ethernet/ti/Kconfig
7529 +++ b/drivers/net/ethernet/ti/Kconfig
7530 @@ -22,6 +22,7 @@ config TI_DAVINCI_EMAC
7531 depends on ARM && ( ARCH_DAVINCI || ARCH_OMAP3 ) || COMPILE_TEST
7532 select TI_DAVINCI_MDIO
7533 select PHYLIB
7534 + select GENERIC_ALLOCATOR
7535 ---help---
7536 This driver supports TI's DaVinci Ethernet .
7537
7538 diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
7539 index 84025dcc78d5..e7c24396933e 100644
7540 --- a/drivers/net/ethernet/ti/cpsw_ale.c
7541 +++ b/drivers/net/ethernet/ti/cpsw_ale.c
7542 @@ -779,6 +779,7 @@ void cpsw_ale_start(struct cpsw_ale *ale)
7543 void cpsw_ale_stop(struct cpsw_ale *ale)
7544 {
7545 del_timer_sync(&ale->timer);
7546 + cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1);
7547 cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0);
7548 }
7549
7550 @@ -862,6 +863,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
7551 ALE_UNKNOWNVLAN_FORCE_UNTAG_EGRESS;
7552 }
7553
7554 + cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1);
7555 return ale;
7556 }
7557
7558 diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
7559 index 37ba708ac781..6614fa3089b2 100644
7560 --- a/drivers/net/ethernet/ti/davinci_cpdma.c
7561 +++ b/drivers/net/ethernet/ti/davinci_cpdma.c
7562 @@ -1018,7 +1018,6 @@ static int cpdma_chan_submit_si(struct submit_info *si)
7563 struct cpdma_chan *chan = si->chan;
7564 struct cpdma_ctlr *ctlr = chan->ctlr;
7565 int len = si->len;
7566 - int swlen = len;
7567 struct cpdma_desc __iomem *desc;
7568 dma_addr_t buffer;
7569 u32 mode;
7570 @@ -1046,7 +1045,6 @@ static int cpdma_chan_submit_si(struct submit_info *si)
7571 if (si->data_dma) {
7572 buffer = si->data_dma;
7573 dma_sync_single_for_device(ctlr->dev, buffer, len, chan->dir);
7574 - swlen |= CPDMA_DMA_EXT_MAP;
7575 } else {
7576 buffer = dma_map_single(ctlr->dev, si->data_virt, len, chan->dir);
7577 ret = dma_mapping_error(ctlr->dev, buffer);
7578 @@ -1065,7 +1063,8 @@ static int cpdma_chan_submit_si(struct submit_info *si)
7579 writel_relaxed(mode | len, &desc->hw_mode);
7580 writel_relaxed((uintptr_t)si->token, &desc->sw_token);
7581 writel_relaxed(buffer, &desc->sw_buffer);
7582 - writel_relaxed(swlen, &desc->sw_len);
7583 + writel_relaxed(si->data_dma ? len | CPDMA_DMA_EXT_MAP : len,
7584 + &desc->sw_len);
7585 desc_read(desc, sw_len);
7586
7587 __cpdma_chan_submit(chan, desc);
7588 diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
7589 index b517c1af9de0..91a1059517f5 100644
7590 --- a/drivers/net/fjes/fjes_main.c
7591 +++ b/drivers/net/fjes/fjes_main.c
7592 @@ -166,6 +166,9 @@ static int fjes_acpi_add(struct acpi_device *device)
7593 /* create platform_device */
7594 plat_dev = platform_device_register_simple(DRV_NAME, 0, fjes_resource,
7595 ARRAY_SIZE(fjes_resource));
7596 + if (IS_ERR(plat_dev))
7597 + return PTR_ERR(plat_dev);
7598 +
7599 device->driver_data = plat_dev;
7600
7601 return 0;
7602 diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
7603 index 37fceaf9fa10..cf4455bbf888 100644
7604 --- a/drivers/net/phy/dp83867.c
7605 +++ b/drivers/net/phy/dp83867.c
7606 @@ -95,6 +95,10 @@
7607 #define DP83867_IO_MUX_CFG_CLK_O_SEL_MASK (0x1f << 8)
7608 #define DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT 8
7609
7610 +/* CFG3 bits */
7611 +#define DP83867_CFG3_INT_OE BIT(7)
7612 +#define DP83867_CFG3_ROBUST_AUTO_MDIX BIT(9)
7613 +
7614 /* CFG4 bits */
7615 #define DP83867_CFG4_PORT_MIRROR_EN BIT(0)
7616
7617 @@ -410,12 +414,13 @@ static int dp83867_config_init(struct phy_device *phydev)
7618 phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_SGMIICTL, val);
7619 }
7620
7621 + val = phy_read(phydev, DP83867_CFG3);
7622 /* Enable Interrupt output INT_OE in CFG3 register */
7623 - if (phy_interrupt_is_valid(phydev)) {
7624 - val = phy_read(phydev, DP83867_CFG3);
7625 - val |= BIT(7);
7626 - phy_write(phydev, DP83867_CFG3, val);
7627 - }
7628 + if (phy_interrupt_is_valid(phydev))
7629 + val |= DP83867_CFG3_INT_OE;
7630 +
7631 + val |= DP83867_CFG3_ROBUST_AUTO_MDIX;
7632 + phy_write(phydev, DP83867_CFG3, val);
7633
7634 if (dp83867->port_mirroring != DP83867_PORT_MIRROING_KEEP)
7635 dp83867_config_port_mirroring(phydev);
7636 diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
7637 index adb66a2fae18..2bf0fda209a8 100644
7638 --- a/drivers/net/phy/phy_device.c
7639 +++ b/drivers/net/phy/phy_device.c
7640 @@ -488,7 +488,7 @@ static int phy_bus_match(struct device *dev, struct device_driver *drv)
7641
7642 if (phydev->is_c45) {
7643 for (i = 1; i < num_ids; i++) {
7644 - if (!(phydev->c45_ids.devices_in_package & (1 << i)))
7645 + if (phydev->c45_ids.device_ids[i] == 0xffffffff)
7646 continue;
7647
7648 if ((phydrv->phy_id & phydrv->phy_id_mask) ==
7649 @@ -552,7 +552,7 @@ static const struct device_type mdio_bus_phy_type = {
7650 .pm = MDIO_BUS_PHY_PM_OPS,
7651 };
7652
7653 -static int phy_request_driver_module(struct phy_device *dev, int phy_id)
7654 +static int phy_request_driver_module(struct phy_device *dev, u32 phy_id)
7655 {
7656 int ret;
7657
7658 @@ -564,15 +564,15 @@ static int phy_request_driver_module(struct phy_device *dev, int phy_id)
7659 * then modprobe isn't available.
7660 */
7661 if (IS_ENABLED(CONFIG_MODULES) && ret < 0 && ret != -ENOENT) {
7662 - phydev_err(dev, "error %d loading PHY driver module for ID 0x%08x\n",
7663 - ret, phy_id);
7664 + phydev_err(dev, "error %d loading PHY driver module for ID 0x%08lx\n",
7665 + ret, (unsigned long)phy_id);
7666 return ret;
7667 }
7668
7669 return 0;
7670 }
7671
7672 -struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
7673 +struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
7674 bool is_c45,
7675 struct phy_c45_device_ids *c45_ids)
7676 {
7677 @@ -596,8 +596,8 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
7678 mdiodev->device_free = phy_mdio_device_free;
7679 mdiodev->device_remove = phy_mdio_device_remove;
7680
7681 - dev->speed = 0;
7682 - dev->duplex = -1;
7683 + dev->speed = SPEED_UNKNOWN;
7684 + dev->duplex = DUPLEX_UNKNOWN;
7685 dev->pause = 0;
7686 dev->asym_pause = 0;
7687 dev->link = 0;
7688 @@ -632,7 +632,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
7689 int i;
7690
7691 for (i = 1; i < num_ids; i++) {
7692 - if (!(c45_ids->devices_in_package & (1 << i)))
7693 + if (c45_ids->device_ids[i] == 0xffffffff)
7694 continue;
7695
7696 ret = phy_request_driver_module(dev,
7697 @@ -812,10 +812,13 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
7698 */
7699 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
7700 {
7701 - struct phy_c45_device_ids c45_ids = {0};
7702 + struct phy_c45_device_ids c45_ids;
7703 u32 phy_id = 0;
7704 int r;
7705
7706 + c45_ids.devices_in_package = 0;
7707 + memset(c45_ids.device_ids, 0xff, sizeof(c45_ids.device_ids));
7708 +
7709 r = get_phy_id(bus, addr, &phy_id, is_c45, &c45_ids);
7710 if (r)
7711 return ERR_PTR(r);
7712 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
7713 index 8156b33ee3e7..ca70a1d840eb 100644
7714 --- a/drivers/net/team/team.c
7715 +++ b/drivers/net/team/team.c
7716 @@ -2074,7 +2074,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev,
7717 cmd->base.duplex = DUPLEX_UNKNOWN;
7718 cmd->base.port = PORT_OTHER;
7719
7720 - list_for_each_entry(port, &team->port_list, list) {
7721 + rcu_read_lock();
7722 + list_for_each_entry_rcu(port, &team->port_list, list) {
7723 if (team_port_txable(port)) {
7724 if (port->state.speed != SPEED_UNKNOWN)
7725 speed += port->state.speed;
7726 @@ -2083,6 +2084,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev,
7727 cmd->base.duplex = port->state.duplex;
7728 }
7729 }
7730 + rcu_read_unlock();
7731 +
7732 cmd->base.speed = speed ? : SPEED_UNKNOWN;
7733
7734 return 0;
7735 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
7736 index a8d3141582a5..16564ebcde50 100644
7737 --- a/drivers/net/tun.c
7738 +++ b/drivers/net/tun.c
7739 @@ -313,8 +313,8 @@ static void tun_napi_init(struct tun_struct *tun, struct tun_file *tfile,
7740 tfile->napi_enabled = napi_en;
7741 tfile->napi_frags_enabled = napi_en && napi_frags;
7742 if (napi_en) {
7743 - netif_napi_add(tun->dev, &tfile->napi, tun_napi_poll,
7744 - NAPI_POLL_WEIGHT);
7745 + netif_tx_napi_add(tun->dev, &tfile->napi, tun_napi_poll,
7746 + NAPI_POLL_WEIGHT);
7747 napi_enable(&tfile->napi);
7748 }
7749 }
7750 diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
7751 index f24a1b0b801f..0becc79fd431 100644
7752 --- a/drivers/net/usb/lan78xx.c
7753 +++ b/drivers/net/usb/lan78xx.c
7754 @@ -1808,6 +1808,7 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev)
7755 dev->mdiobus->read = lan78xx_mdiobus_read;
7756 dev->mdiobus->write = lan78xx_mdiobus_write;
7757 dev->mdiobus->name = "lan78xx-mdiobus";
7758 + dev->mdiobus->parent = &dev->udev->dev;
7759
7760 snprintf(dev->mdiobus->id, MII_BUS_ID_SIZE, "usb-%03d:%03d",
7761 dev->udev->bus->busnum, dev->udev->devnum);
7762 diff --git a/drivers/net/wireless/ath/ath10k/coredump.c b/drivers/net/wireless/ath/ath10k/coredump.c
7763 index b6d2932383cf..1cfe75a2d0c3 100644
7764 --- a/drivers/net/wireless/ath/ath10k/coredump.c
7765 +++ b/drivers/net/wireless/ath/ath10k/coredump.c
7766 @@ -1208,9 +1208,11 @@ static struct ath10k_dump_file_data *ath10k_coredump_build(struct ath10k *ar)
7767 dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar);
7768 dump_tlv->type = cpu_to_le32(ATH10K_FW_CRASH_DUMP_RAM_DATA);
7769 dump_tlv->tlv_len = cpu_to_le32(crash_data->ramdump_buf_len);
7770 - memcpy(dump_tlv->tlv_data, crash_data->ramdump_buf,
7771 - crash_data->ramdump_buf_len);
7772 - sofar += sizeof(*dump_tlv) + crash_data->ramdump_buf_len;
7773 + if (crash_data->ramdump_buf_len) {
7774 + memcpy(dump_tlv->tlv_data, crash_data->ramdump_buf,
7775 + crash_data->ramdump_buf_len);
7776 + sofar += sizeof(*dump_tlv) + crash_data->ramdump_buf_len;
7777 + }
7778 }
7779
7780 mutex_unlock(&ar->dump_mutex);
7781 @@ -1257,6 +1259,9 @@ int ath10k_coredump_register(struct ath10k *ar)
7782 if (test_bit(ATH10K_FW_CRASH_DUMP_RAM_DATA, &ath10k_coredump_mask)) {
7783 crash_data->ramdump_buf_len = ath10k_coredump_get_ramdump_size(ar);
7784
7785 + if (!crash_data->ramdump_buf_len)
7786 + return 0;
7787 +
7788 crash_data->ramdump_buf = vzalloc(crash_data->ramdump_buf_len);
7789 if (!crash_data->ramdump_buf)
7790 return -ENOMEM;
7791 diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
7792 index 53f1095de8ff..9f0e7b4943ec 100644
7793 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c
7794 +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
7795 @@ -2726,7 +2726,7 @@ static void ath10k_htt_rx_tx_compl_ind(struct ath10k *ar,
7796 spin_lock_bh(&ar->data_lock);
7797
7798 peer = ath10k_peer_find_by_id(ar, peer_id);
7799 - if (!peer) {
7800 + if (!peer || !peer->sta) {
7801 spin_unlock_bh(&ar->data_lock);
7802 rcu_read_unlock();
7803 continue;
7804 diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
7805 index a6d21856b7e7..36d24ea126a2 100644
7806 --- a/drivers/net/wireless/ath/ath10k/mac.c
7807 +++ b/drivers/net/wireless/ath/ath10k/mac.c
7808 @@ -3708,7 +3708,7 @@ static int ath10k_mac_tx(struct ath10k *ar,
7809 struct ieee80211_vif *vif,
7810 enum ath10k_hw_txrx_mode txmode,
7811 enum ath10k_mac_tx_path txpath,
7812 - struct sk_buff *skb)
7813 + struct sk_buff *skb, bool noque_offchan)
7814 {
7815 struct ieee80211_hw *hw = ar->hw;
7816 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
7817 @@ -3738,10 +3738,10 @@ static int ath10k_mac_tx(struct ath10k *ar,
7818 }
7819 }
7820
7821 - if (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) {
7822 + if (!noque_offchan && info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) {
7823 if (!ath10k_mac_tx_frm_has_freq(ar)) {
7824 - ath10k_dbg(ar, ATH10K_DBG_MAC, "queued offchannel skb %pK\n",
7825 - skb);
7826 + ath10k_dbg(ar, ATH10K_DBG_MAC, "mac queued offchannel skb %pK len %d\n",
7827 + skb, skb->len);
7828
7829 skb_queue_tail(&ar->offchan_tx_queue, skb);
7830 ieee80211_queue_work(hw, &ar->offchan_tx_work);
7831 @@ -3803,8 +3803,8 @@ void ath10k_offchan_tx_work(struct work_struct *work)
7832
7833 mutex_lock(&ar->conf_mutex);
7834
7835 - ath10k_dbg(ar, ATH10K_DBG_MAC, "mac offchannel skb %pK\n",
7836 - skb);
7837 + ath10k_dbg(ar, ATH10K_DBG_MAC, "mac offchannel skb %pK len %d\n",
7838 + skb, skb->len);
7839
7840 hdr = (struct ieee80211_hdr *)skb->data;
7841 peer_addr = ieee80211_get_DA(hdr);
7842 @@ -3850,7 +3850,7 @@ void ath10k_offchan_tx_work(struct work_struct *work)
7843 txmode = ath10k_mac_tx_h_get_txmode(ar, vif, sta, skb);
7844 txpath = ath10k_mac_tx_h_get_txpath(ar, skb, txmode);
7845
7846 - ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb);
7847 + ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb, true);
7848 if (ret) {
7849 ath10k_warn(ar, "failed to transmit offchannel frame: %d\n",
7850 ret);
7851 @@ -3860,8 +3860,8 @@ void ath10k_offchan_tx_work(struct work_struct *work)
7852 time_left =
7853 wait_for_completion_timeout(&ar->offchan_tx_completed, 3 * HZ);
7854 if (time_left == 0)
7855 - ath10k_warn(ar, "timed out waiting for offchannel skb %pK\n",
7856 - skb);
7857 + ath10k_warn(ar, "timed out waiting for offchannel skb %pK, len: %d\n",
7858 + skb, skb->len);
7859
7860 if (!peer && tmp_peer_created) {
7861 ret = ath10k_peer_delete(ar, vdev_id, peer_addr);
7862 @@ -3903,8 +3903,10 @@ void ath10k_mgmt_over_wmi_tx_work(struct work_struct *work)
7863 ar->running_fw->fw_file.fw_features)) {
7864 paddr = dma_map_single(ar->dev, skb->data,
7865 skb->len, DMA_TO_DEVICE);
7866 - if (!paddr)
7867 + if (dma_mapping_error(ar->dev, paddr)) {
7868 + ieee80211_free_txskb(ar->hw, skb);
7869 continue;
7870 + }
7871 ret = ath10k_wmi_mgmt_tx_send(ar, skb, paddr);
7872 if (ret) {
7873 ath10k_warn(ar, "failed to transmit management frame by ref via WMI: %d\n",
7874 @@ -4097,7 +4099,7 @@ int ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,
7875 spin_unlock_bh(&ar->htt.tx_lock);
7876 }
7877
7878 - ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb);
7879 + ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb, false);
7880 if (unlikely(ret)) {
7881 ath10k_warn(ar, "failed to push frame: %d\n", ret);
7882
7883 @@ -4378,7 +4380,7 @@ static void ath10k_mac_op_tx(struct ieee80211_hw *hw,
7884 spin_unlock_bh(&ar->htt.tx_lock);
7885 }
7886
7887 - ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb);
7888 + ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb, false);
7889 if (ret) {
7890 ath10k_warn(ar, "failed to transmit frame: %d\n", ret);
7891 if (is_htt) {
7892 diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
7893 index 4102df016931..39abf8b12903 100644
7894 --- a/drivers/net/wireless/ath/ath10k/txrx.c
7895 +++ b/drivers/net/wireless/ath/ath10k/txrx.c
7896 @@ -95,6 +95,8 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt,
7897
7898 info = IEEE80211_SKB_CB(msdu);
7899 memset(&info->status, 0, sizeof(info->status));
7900 + info->status.rates[0].idx = -1;
7901 +
7902 trace_ath10k_txrx_tx_unref(ar, tx_done->msdu_id);
7903
7904 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
7905 diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
7906 index 406b367c284c..85cf96461dde 100644
7907 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
7908 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
7909 @@ -1350,6 +1350,11 @@ void brcmf_detach(struct device *dev)
7910 brcmf_fweh_detach(drvr);
7911 brcmf_proto_detach(drvr);
7912
7913 + if (drvr->mon_if) {
7914 + brcmf_net_detach(drvr->mon_if->ndev, false);
7915 + drvr->mon_if = NULL;
7916 + }
7917 +
7918 /* make sure primary interface removed last */
7919 for (i = BRCMF_MAX_IFS - 1; i > -1; i--) {
7920 if (drvr->iflist[i])
7921 diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/led.c b/drivers/net/wireless/intel/iwlwifi/dvm/led.c
7922 index dd387aba3317..e8a4d604b910 100644
7923 --- a/drivers/net/wireless/intel/iwlwifi/dvm/led.c
7924 +++ b/drivers/net/wireless/intel/iwlwifi/dvm/led.c
7925 @@ -171,6 +171,9 @@ void iwl_leds_init(struct iwl_priv *priv)
7926
7927 priv->led.name = kasprintf(GFP_KERNEL, "%s-led",
7928 wiphy_name(priv->hw->wiphy));
7929 + if (!priv->led.name)
7930 + return;
7931 +
7932 priv->led.brightness_set = iwl_led_brightness_set;
7933 priv->led.blink_set = iwl_led_blink_set;
7934 priv->led.max_brightness = 1;
7935 diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/led.c b/drivers/net/wireless/intel/iwlwifi/mvm/led.c
7936 index d104da9170ca..72c4b2b8399d 100644
7937 --- a/drivers/net/wireless/intel/iwlwifi/mvm/led.c
7938 +++ b/drivers/net/wireless/intel/iwlwifi/mvm/led.c
7939 @@ -129,6 +129,9 @@ int iwl_mvm_leds_init(struct iwl_mvm *mvm)
7940
7941 mvm->led.name = kasprintf(GFP_KERNEL, "%s-led",
7942 wiphy_name(mvm->hw->wiphy));
7943 + if (!mvm->led.name)
7944 + return -ENOMEM;
7945 +
7946 mvm->led.brightness_set = iwl_led_brightness_set;
7947 mvm->led.max_brightness = 1;
7948
7949 diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
7950 index 0ad8ed23a455..5ee33c8ae9d2 100644
7951 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
7952 +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
7953 @@ -60,6 +60,7 @@
7954 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7955 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7956 *****************************************************************************/
7957 +#include <asm/unaligned.h>
7958 #include <linux/etherdevice.h>
7959 #include <linux/skbuff.h>
7960 #include "iwl-trans.h"
7961 @@ -357,7 +358,7 @@ void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,
7962 rx_res = (struct iwl_rx_mpdu_res_start *)pkt->data;
7963 hdr = (struct ieee80211_hdr *)(pkt->data + sizeof(*rx_res));
7964 len = le16_to_cpu(rx_res->byte_count);
7965 - rx_pkt_status = le32_to_cpup((__le32 *)
7966 + rx_pkt_status = get_unaligned_le32((__le32 *)
7967 (pkt->data + sizeof(*rx_res) + len));
7968
7969 /* Dont use dev_alloc_skb(), we'll have enough headroom once
7970 diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
7971 index 19dd075f2f63..041dd75ac72b 100644
7972 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
7973 +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
7974 @@ -1429,6 +1429,7 @@ out_err:
7975 static void iwl_pcie_rx_handle(struct iwl_trans *trans, int queue)
7976 {
7977 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
7978 + struct napi_struct *napi;
7979 struct iwl_rxq *rxq;
7980 u32 r, i, count = 0;
7981 bool emergency = false;
7982 @@ -1534,8 +1535,16 @@ out:
7983 if (unlikely(emergency && count))
7984 iwl_pcie_rxq_alloc_rbs(trans, GFP_ATOMIC, rxq);
7985
7986 - if (rxq->napi.poll)
7987 - napi_gro_flush(&rxq->napi, false);
7988 + napi = &rxq->napi;
7989 + if (napi->poll) {
7990 + if (napi->rx_count) {
7991 + netif_receive_skb_list(&napi->rx_list);
7992 + INIT_LIST_HEAD(&napi->rx_list);
7993 + napi->rx_count = 0;
7994 + }
7995 +
7996 + napi_gro_flush(napi, false);
7997 + }
7998
7999 iwl_pcie_rxq_restock(trans, rxq);
8000 }
8001 diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
8002 index ca3bb4d65b00..df8455f14e4d 100644
8003 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
8004 +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
8005 @@ -57,24 +57,6 @@
8006 #include "internal.h"
8007 #include "fw/dbg.h"
8008
8009 -static int iwl_pcie_gen2_force_power_gating(struct iwl_trans *trans)
8010 -{
8011 - iwl_set_bits_prph(trans, HPM_HIPM_GEN_CFG,
8012 - HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE);
8013 - udelay(20);
8014 - iwl_set_bits_prph(trans, HPM_HIPM_GEN_CFG,
8015 - HPM_HIPM_GEN_CFG_CR_PG_EN |
8016 - HPM_HIPM_GEN_CFG_CR_SLP_EN);
8017 - udelay(20);
8018 - iwl_clear_bits_prph(trans, HPM_HIPM_GEN_CFG,
8019 - HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE);
8020 -
8021 - iwl_trans_sw_reset(trans);
8022 - iwl_clear_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
8023 -
8024 - return 0;
8025 -}
8026 -
8027 /*
8028 * Start up NIC's basic functionality after it has been reset
8029 * (e.g. after platform boot, or shutdown via iwl_pcie_apm_stop())
8030 @@ -110,13 +92,6 @@ int iwl_pcie_gen2_apm_init(struct iwl_trans *trans)
8031
8032 iwl_pcie_apm_config(trans);
8033
8034 - if (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_22000 &&
8035 - trans->cfg->integrated) {
8036 - ret = iwl_pcie_gen2_force_power_gating(trans);
8037 - if (ret)
8038 - return ret;
8039 - }
8040 -
8041 ret = iwl_finish_nic_init(trans, trans->trans_cfg);
8042 if (ret)
8043 return ret;
8044 diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
8045 index 6961f00ff812..d3db38c3095b 100644
8046 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
8047 +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
8048 @@ -1783,6 +1783,29 @@ static int iwl_trans_pcie_clear_persistence_bit(struct iwl_trans *trans)
8049 return 0;
8050 }
8051
8052 +static int iwl_pcie_gen2_force_power_gating(struct iwl_trans *trans)
8053 +{
8054 + int ret;
8055 +
8056 + ret = iwl_finish_nic_init(trans, trans->trans_cfg);
8057 + if (ret < 0)
8058 + return ret;
8059 +
8060 + iwl_set_bits_prph(trans, HPM_HIPM_GEN_CFG,
8061 + HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE);
8062 + udelay(20);
8063 + iwl_set_bits_prph(trans, HPM_HIPM_GEN_CFG,
8064 + HPM_HIPM_GEN_CFG_CR_PG_EN |
8065 + HPM_HIPM_GEN_CFG_CR_SLP_EN);
8066 + udelay(20);
8067 + iwl_clear_bits_prph(trans, HPM_HIPM_GEN_CFG,
8068 + HPM_HIPM_GEN_CFG_CR_FORCE_ACTIVE);
8069 +
8070 + iwl_trans_pcie_sw_reset(trans);
8071 +
8072 + return 0;
8073 +}
8074 +
8075 static int _iwl_trans_pcie_start_hw(struct iwl_trans *trans)
8076 {
8077 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
8078 @@ -1802,6 +1825,13 @@ static int _iwl_trans_pcie_start_hw(struct iwl_trans *trans)
8079
8080 iwl_trans_pcie_sw_reset(trans);
8081
8082 + if (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_22000 &&
8083 + trans->cfg->integrated) {
8084 + err = iwl_pcie_gen2_force_power_gating(trans);
8085 + if (err)
8086 + return err;
8087 + }
8088 +
8089 err = iwl_pcie_apm_init(trans);
8090 if (err)
8091 return err;
8092 diff --git a/drivers/net/wireless/marvell/libertas/if_sdio.c b/drivers/net/wireless/marvell/libertas/if_sdio.c
8093 index 242d8845da3f..30f1025ecb9b 100644
8094 --- a/drivers/net/wireless/marvell/libertas/if_sdio.c
8095 +++ b/drivers/net/wireless/marvell/libertas/if_sdio.c
8096 @@ -1179,6 +1179,10 @@ static int if_sdio_probe(struct sdio_func *func,
8097
8098 spin_lock_init(&card->lock);
8099 card->workqueue = alloc_workqueue("libertas_sdio", WQ_MEM_RECLAIM, 0);
8100 + if (unlikely(!card->workqueue)) {
8101 + ret = -ENOMEM;
8102 + goto err_queue;
8103 + }
8104 INIT_WORK(&card->packet_worker, if_sdio_host_to_card_worker);
8105 init_waitqueue_head(&card->pwron_waitq);
8106
8107 @@ -1230,6 +1234,7 @@ err_activate_card:
8108 lbs_remove_card(priv);
8109 free:
8110 destroy_workqueue(card->workqueue);
8111 +err_queue:
8112 while (card->packets) {
8113 packet = card->packets;
8114 card->packets = card->packets->next;
8115 diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
8116 index eff06d59e9df..096334e941a1 100644
8117 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
8118 +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
8119 @@ -687,8 +687,11 @@ static int mwifiex_pcie_init_evt_ring(struct mwifiex_adapter *adapter)
8120 skb_put(skb, MAX_EVENT_SIZE);
8121
8122 if (mwifiex_map_pci_memory(adapter, skb, MAX_EVENT_SIZE,
8123 - PCI_DMA_FROMDEVICE))
8124 + PCI_DMA_FROMDEVICE)) {
8125 + kfree_skb(skb);
8126 + kfree(card->evtbd_ring_vbase);
8127 return -1;
8128 + }
8129
8130 buf_pa = MWIFIEX_SKB_DMA_ADDR(skb);
8131
8132 diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
8133 index c328192307c4..ff3f3d98b625 100644
8134 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
8135 +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
8136 @@ -1032,8 +1032,10 @@ mt7603_fill_txs(struct mt7603_dev *dev, struct mt7603_sta *sta,
8137 if (idx && (cur_rate->idx != info->status.rates[i].idx ||
8138 cur_rate->flags != info->status.rates[i].flags)) {
8139 i++;
8140 - if (i == ARRAY_SIZE(info->status.rates))
8141 + if (i == ARRAY_SIZE(info->status.rates)) {
8142 + i--;
8143 break;
8144 + }
8145
8146 info->status.rates[i] = *cur_rate;
8147 info->status.rates[i].count = 0;
8148 diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
8149 index e07ce2c10013..111e38ff954a 100644
8150 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
8151 +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
8152 @@ -914,8 +914,10 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta,
8153 if (idx && (cur_rate->idx != info->status.rates[i].idx ||
8154 cur_rate->flags != info->status.rates[i].flags)) {
8155 i++;
8156 - if (i == ARRAY_SIZE(info->status.rates))
8157 + if (i == ARRAY_SIZE(info->status.rates)) {
8158 + i--;
8159 break;
8160 + }
8161
8162 info->status.rates[i] = *cur_rate;
8163 info->status.rates[i].count = 0;
8164 diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c
8165 index dc0c7244b60e..c0c32805fb8d 100644
8166 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
8167 +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
8168 @@ -83,6 +83,7 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
8169 struct qlink_cmd *cmd;
8170 struct qlink_resp *resp = NULL;
8171 struct sk_buff *resp_skb = NULL;
8172 + int resp_res = 0;
8173 u16 cmd_id;
8174 u8 mac_id;
8175 u8 vif_id;
8176 @@ -113,6 +114,7 @@ static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
8177 }
8178
8179 resp = (struct qlink_resp *)resp_skb->data;
8180 + resp_res = le16_to_cpu(resp->result);
8181 ret = qtnf_cmd_check_reply_header(resp, cmd_id, mac_id, vif_id,
8182 const_resp_size);
8183 if (ret)
8184 @@ -128,8 +130,8 @@ out:
8185 else
8186 consume_skb(resp_skb);
8187
8188 - if (!ret && resp)
8189 - return qtnf_cmd_resp_result_decode(le16_to_cpu(resp->result));
8190 + if (!ret)
8191 + return qtnf_cmd_resp_result_decode(resp_res);
8192
8193 pr_warn("VIF%u.%u: cmd 0x%.4X failed: %d\n",
8194 mac_id, vif_id, cmd_id, ret);
8195 diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.c b/drivers/net/wireless/quantenna/qtnfmac/event.c
8196 index b57c8c18a8d0..7846383c8828 100644
8197 --- a/drivers/net/wireless/quantenna/qtnfmac/event.c
8198 +++ b/drivers/net/wireless/quantenna/qtnfmac/event.c
8199 @@ -171,8 +171,9 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif,
8200 return -EPROTO;
8201 }
8202
8203 - pr_debug("VIF%u.%u: BSSID:%pM status:%u\n",
8204 - vif->mac->macid, vif->vifid, join_info->bssid, status);
8205 + pr_debug("VIF%u.%u: BSSID:%pM chan:%u status:%u\n",
8206 + vif->mac->macid, vif->vifid, join_info->bssid,
8207 + le16_to_cpu(join_info->chan.chan.center_freq), status);
8208
8209 if (status != WLAN_STATUS_SUCCESS)
8210 goto done;
8211 @@ -181,7 +182,7 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif,
8212 if (!cfg80211_chandef_valid(&chandef)) {
8213 pr_warn("MAC%u.%u: bad channel freq=%u cf1=%u cf2=%u bw=%u\n",
8214 vif->mac->macid, vif->vifid,
8215 - chandef.chan->center_freq,
8216 + chandef.chan ? chandef.chan->center_freq : 0,
8217 chandef.center_freq1,
8218 chandef.center_freq2,
8219 chandef.width);
8220 diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c
8221 index 8ae318b5fe54..4824be0c6231 100644
8222 --- a/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c
8223 +++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c
8224 @@ -130,6 +130,8 @@ static int qtnf_dbg_shm_stats(struct seq_file *s, void *data)
8225
8226 int qtnf_pcie_fw_boot_done(struct qtnf_bus *bus)
8227 {
8228 + struct qtnf_pcie_bus_priv *priv = get_bus_priv(bus);
8229 + char card_id[64];
8230 int ret;
8231
8232 bus->fw_state = QTNF_FW_STATE_BOOT_DONE;
8233 @@ -137,7 +139,9 @@ int qtnf_pcie_fw_boot_done(struct qtnf_bus *bus)
8234 if (ret) {
8235 pr_err("failed to attach core\n");
8236 } else {
8237 - qtnf_debugfs_init(bus, DRV_NAME);
8238 + snprintf(card_id, sizeof(card_id), "%s:%s",
8239 + DRV_NAME, pci_name(priv->pdev));
8240 + qtnf_debugfs_init(bus, card_id);
8241 qtnf_debugfs_add_entry(bus, "mps", qtnf_dbg_mps_show);
8242 qtnf_debugfs_add_entry(bus, "msi_enabled", qtnf_dbg_msi_show);
8243 qtnf_debugfs_add_entry(bus, "shm_stats", qtnf_dbg_shm_stats);
8244 diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
8245 index ade057d868f7..5e9ce03067de 100644
8246 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
8247 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
8248 @@ -1341,6 +1341,7 @@ struct rtl8xxxu_fileops {
8249 u8 has_s0s1:1;
8250 u8 has_tx_report:1;
8251 u8 gen2_thermal_meter:1;
8252 + u8 needs_full_init:1;
8253 u32 adda_1t_init;
8254 u32 adda_1t_path_on;
8255 u32 adda_2t_path_on_a;
8256 diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
8257 index ceffe05bd65b..f3cd314d1a9c 100644
8258 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
8259 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
8260 @@ -1670,6 +1670,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = {
8261 .has_s0s1 = 1,
8262 .has_tx_report = 1,
8263 .gen2_thermal_meter = 1,
8264 + .needs_full_init = 1,
8265 .adda_1t_init = 0x01c00014,
8266 .adda_1t_path_on = 0x01c00014,
8267 .adda_2t_path_on_a = 0x01c00014,
8268 diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
8269 index c6c41fb962ff..361248e97568 100644
8270 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
8271 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
8272 @@ -3902,6 +3902,9 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
8273 else
8274 macpower = true;
8275
8276 + if (fops->needs_full_init)
8277 + macpower = false;
8278 +
8279 ret = fops->power_on(priv);
8280 if (ret < 0) {
8281 dev_warn(dev, "%s: Failed power on\n", __func__);
8282 diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
8283 index 56cc3bc30860..f070f25bb735 100644
8284 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
8285 +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
8286 @@ -1540,6 +1540,8 @@ static bool usb_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
8287 * This is maybe necessary:
8288 * rtlpriv->cfg->ops->fill_tx_cmddesc(hw, buffer, 1, 1, skb);
8289 */
8290 + dev_kfree_skb(skb);
8291 +
8292 return true;
8293 }
8294
8295 diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
8296 index 4b59f3b46b28..348b0072cdd6 100644
8297 --- a/drivers/net/wireless/realtek/rtlwifi/usb.c
8298 +++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
8299 @@ -1021,8 +1021,10 @@ int rtl_usb_probe(struct usb_interface *intf,
8300 rtlpriv->hw = hw;
8301 rtlpriv->usb_data = kcalloc(RTL_USB_MAX_RX_COUNT, sizeof(u32),
8302 GFP_KERNEL);
8303 - if (!rtlpriv->usb_data)
8304 + if (!rtlpriv->usb_data) {
8305 + ieee80211_free_hw(hw);
8306 return -ENOMEM;
8307 + }
8308
8309 /* this spin lock must be initialized early */
8310 spin_lock_init(&rtlpriv->locks.usb_lock);
8311 @@ -1083,6 +1085,7 @@ error_out2:
8312 _rtl_usb_io_handler_release(hw);
8313 usb_put_dev(udev);
8314 complete(&rtlpriv->firmware_loading_complete);
8315 + kfree(rtlpriv->usb_data);
8316 return -ENODEV;
8317 }
8318 EXPORT_SYMBOL(rtl_usb_probe);
8319 diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c
8320 index 793b40bdbf7c..3e95ad198912 100644
8321 --- a/drivers/net/wireless/realtek/rtw88/coex.c
8322 +++ b/drivers/net/wireless/realtek/rtw88/coex.c
8323 @@ -1308,6 +1308,7 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev)
8324 struct rtw_chip_info *chip = rtwdev->chip;
8325 bool wl_hi_pri = false;
8326 u8 table_case, tdma_case;
8327 + u32 slot_type = 0;
8328
8329 if (coex_stat->wl_linkscan_proc || coex_stat->wl_hi_pri_task1 ||
8330 coex_stat->wl_hi_pri_task2)
8331 @@ -1318,14 +1319,16 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev)
8332 if (wl_hi_pri) {
8333 table_case = 15;
8334 if (coex_stat->bt_a2dp_exist &&
8335 - !coex_stat->bt_pan_exist)
8336 + !coex_stat->bt_pan_exist) {
8337 + slot_type = TDMA_4SLOT;
8338 tdma_case = 11;
8339 - else if (coex_stat->wl_hi_pri_task1)
8340 + } else if (coex_stat->wl_hi_pri_task1) {
8341 tdma_case = 6;
8342 - else if (!coex_stat->bt_page)
8343 + } else if (!coex_stat->bt_page) {
8344 tdma_case = 8;
8345 - else
8346 + } else {
8347 tdma_case = 9;
8348 + }
8349 } else if (coex_stat->wl_connected) {
8350 table_case = 10;
8351 tdma_case = 10;
8352 @@ -1361,7 +1364,7 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev)
8353 rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G);
8354 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]);
8355 rtw_coex_table(rtwdev, table_case);
8356 - rtw_coex_tdma(rtwdev, false, tdma_case);
8357 + rtw_coex_tdma(rtwdev, false, tdma_case | slot_type);
8358 }
8359
8360 static void rtw_coex_action_bt_hfp(struct rtw_dev *rtwdev)
8361 @@ -1475,13 +1478,13 @@ static void rtw_coex_action_bt_a2dp(struct rtw_dev *rtwdev)
8362
8363 if (efuse->share_ant) {
8364 /* Shared-Ant */
8365 + slot_type = TDMA_4SLOT;
8366 +
8367 if (coex_stat->wl_gl_busy && coex_stat->wl_noisy_level == 0)
8368 table_case = 10;
8369 else
8370 table_case = 9;
8371
8372 - slot_type = TDMA_4SLOT;
8373 -
8374 if (coex_stat->wl_gl_busy)
8375 tdma_case = 13;
8376 else
8377 @@ -1585,13 +1588,14 @@ static void rtw_coex_action_bt_a2dp_hid(struct rtw_dev *rtwdev)
8378
8379 if (efuse->share_ant) {
8380 /* Shared-Ant */
8381 + slot_type = TDMA_4SLOT;
8382 +
8383 if (coex_stat->bt_ble_exist)
8384 table_case = 26;
8385 else
8386 table_case = 9;
8387
8388 if (coex_stat->wl_gl_busy) {
8389 - slot_type = TDMA_4SLOT;
8390 tdma_case = 13;
8391 } else {
8392 tdma_case = 14;
8393 @@ -1794,10 +1798,12 @@ static void rtw_coex_action_wl_linkscan(struct rtw_dev *rtwdev)
8394 struct rtw_efuse *efuse = &rtwdev->efuse;
8395 struct rtw_chip_info *chip = rtwdev->chip;
8396 u8 table_case, tdma_case;
8397 + u32 slot_type = 0;
8398
8399 if (efuse->share_ant) {
8400 /* Shared-Ant */
8401 if (coex_stat->bt_a2dp_exist) {
8402 + slot_type = TDMA_4SLOT;
8403 table_case = 9;
8404 tdma_case = 11;
8405 } else {
8406 @@ -1818,7 +1824,7 @@ static void rtw_coex_action_wl_linkscan(struct rtw_dev *rtwdev)
8407 rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_2G);
8408 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]);
8409 rtw_coex_table(rtwdev, table_case);
8410 - rtw_coex_tdma(rtwdev, false, tdma_case);
8411 + rtw_coex_tdma(rtwdev, false, tdma_case | slot_type);
8412 }
8413
8414 static void rtw_coex_action_wl_not_connected(struct rtw_dev *rtwdev)
8415 diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
8416 index 6dd457741b15..7a3a4911bde2 100644
8417 --- a/drivers/net/wireless/realtek/rtw88/main.c
8418 +++ b/drivers/net/wireless/realtek/rtw88/main.c
8419 @@ -1020,7 +1020,8 @@ static int rtw_dump_hw_feature(struct rtw_dev *rtwdev)
8420
8421 rtw_hw_config_rf_ant_num(rtwdev, efuse->hw_cap.ant_num);
8422
8423 - if (efuse->hw_cap.nss == EFUSE_HW_CAP_IGNORE)
8424 + if (efuse->hw_cap.nss == EFUSE_HW_CAP_IGNORE ||
8425 + efuse->hw_cap.nss > rtwdev->hal.rf_path_num)
8426 efuse->hw_cap.nss = rtwdev->hal.rf_path_num;
8427
8428 rtw_dbg(rtwdev, RTW_DBG_EFUSE,
8429 diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
8430 index 4d1909aecd6c..9f60e4dc5a90 100644
8431 --- a/drivers/nfc/nxp-nci/i2c.c
8432 +++ b/drivers/nfc/nxp-nci/i2c.c
8433 @@ -278,7 +278,7 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
8434
8435 r = devm_acpi_dev_add_driver_gpios(dev, acpi_nxp_nci_gpios);
8436 if (r)
8437 - return r;
8438 + dev_dbg(dev, "Unable to add GPIO mapping table\n");
8439
8440 phy->gpiod_en = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
8441 if (IS_ERR(phy->gpiod_en)) {
8442 diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
8443 index af3212aec871..a6b7b242d516 100644
8444 --- a/drivers/nvme/host/core.c
8445 +++ b/drivers/nvme/host/core.c
8446 @@ -313,7 +313,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved)
8447 if (blk_mq_request_completed(req))
8448 return true;
8449
8450 - nvme_req(req)->status = NVME_SC_HOST_PATH_ERROR;
8451 + nvme_req(req)->status = NVME_SC_HOST_ABORTED_CMD;
8452 blk_mq_complete_request(req);
8453 return true;
8454 }
8455 @@ -611,8 +611,14 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req,
8456 struct nvme_dsm_range *range;
8457 struct bio *bio;
8458
8459 - range = kmalloc_array(segments, sizeof(*range),
8460 - GFP_ATOMIC | __GFP_NOWARN);
8461 + /*
8462 + * Some devices do not consider the DSM 'Number of Ranges' field when
8463 + * determining how much data to DMA. Always allocate memory for maximum
8464 + * number of segments to prevent device reading beyond end of buffer.
8465 + */
8466 + static const size_t alloc_size = sizeof(*range) * NVME_DSM_MAX_RANGES;
8467 +
8468 + range = kzalloc(alloc_size, GFP_ATOMIC | __GFP_NOWARN);
8469 if (!range) {
8470 /*
8471 * If we fail allocation our range, fallback to the controller
8472 @@ -652,7 +658,7 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req,
8473
8474 req->special_vec.bv_page = virt_to_page(range);
8475 req->special_vec.bv_offset = offset_in_page(range);
8476 - req->special_vec.bv_len = sizeof(*range) * segments;
8477 + req->special_vec.bv_len = alloc_size;
8478 req->rq_flags |= RQF_SPECIAL_PAYLOAD;
8479
8480 return BLK_STS_OK;
8481 diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
8482 index e0f064dcbd02..132ade51ee87 100644
8483 --- a/drivers/nvme/host/multipath.c
8484 +++ b/drivers/nvme/host/multipath.c
8485 @@ -95,6 +95,7 @@ void nvme_failover_req(struct request *req)
8486 }
8487 break;
8488 case NVME_SC_HOST_PATH_ERROR:
8489 + case NVME_SC_HOST_ABORTED_CMD:
8490 /*
8491 * Temporary transport disruption in talking to the controller.
8492 * Try to send on a new path.
8493 diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
8494 index dff2f3c357f5..fc40555ca4cd 100644
8495 --- a/drivers/nvmem/imx-ocotp.c
8496 +++ b/drivers/nvmem/imx-ocotp.c
8497 @@ -521,6 +521,10 @@ static int imx_ocotp_probe(struct platform_device *pdev)
8498 if (IS_ERR(priv->clk))
8499 return PTR_ERR(priv->clk);
8500
8501 + clk_prepare_enable(priv->clk);
8502 + imx_ocotp_clr_err_if_set(priv->base);
8503 + clk_disable_unprepare(priv->clk);
8504 +
8505 priv->params = of_device_get_match_data(&pdev->dev);
8506 imx_ocotp_nvmem_config.size = 4 * priv->params->nregs;
8507 imx_ocotp_nvmem_config.dev = dev;
8508 diff --git a/drivers/parport/share.c b/drivers/parport/share.c
8509 index 7b4ee33c1935..15c81cffd2de 100644
8510 --- a/drivers/parport/share.c
8511 +++ b/drivers/parport/share.c
8512 @@ -230,6 +230,18 @@ static int port_check(struct device *dev, void *dev_drv)
8513 return 0;
8514 }
8515
8516 +/*
8517 + * Iterates through all the devices connected to the bus and return 1
8518 + * if the device is a parallel port.
8519 + */
8520 +
8521 +static int port_detect(struct device *dev, void *dev_drv)
8522 +{
8523 + if (is_parport(dev))
8524 + return 1;
8525 + return 0;
8526 +}
8527 +
8528 /**
8529 * parport_register_driver - register a parallel port device driver
8530 * @drv: structure describing the driver
8531 @@ -282,6 +294,15 @@ int __parport_register_driver(struct parport_driver *drv, struct module *owner,
8532 if (ret)
8533 return ret;
8534
8535 + /*
8536 + * check if bus has any parallel port registered, if
8537 + * none is found then load the lowlevel driver.
8538 + */
8539 + ret = bus_for_each_dev(&parport_bus_type, NULL, NULL,
8540 + port_detect);
8541 + if (!ret)
8542 + get_lowlevel_driver();
8543 +
8544 mutex_lock(&registration_lock);
8545 if (drv->match_port)
8546 bus_for_each_dev(&parport_bus_type, NULL, drv,
8547 diff --git a/drivers/phy/qualcomm/phy-qcom-usb-hs.c b/drivers/phy/qualcomm/phy-qcom-usb-hs.c
8548 index b163b3a1558d..61054272a7c8 100644
8549 --- a/drivers/phy/qualcomm/phy-qcom-usb-hs.c
8550 +++ b/drivers/phy/qualcomm/phy-qcom-usb-hs.c
8551 @@ -158,8 +158,8 @@ static int qcom_usb_hs_phy_power_on(struct phy *phy)
8552 /* setup initial state */
8553 qcom_usb_hs_phy_vbus_notifier(&uphy->vbus_notify, state,
8554 uphy->vbus_edev);
8555 - ret = devm_extcon_register_notifier(&ulpi->dev, uphy->vbus_edev,
8556 - EXTCON_USB, &uphy->vbus_notify);
8557 + ret = extcon_register_notifier(uphy->vbus_edev, EXTCON_USB,
8558 + &uphy->vbus_notify);
8559 if (ret)
8560 goto err_ulpi;
8561 }
8562 @@ -180,6 +180,9 @@ static int qcom_usb_hs_phy_power_off(struct phy *phy)
8563 {
8564 struct qcom_usb_hs_phy *uphy = phy_get_drvdata(phy);
8565
8566 + if (uphy->vbus_edev)
8567 + extcon_unregister_notifier(uphy->vbus_edev, EXTCON_USB,
8568 + &uphy->vbus_notify);
8569 regulator_disable(uphy->v3p3);
8570 regulator_disable(uphy->v1p8);
8571 clk_disable_unprepare(uphy->sleep_clk);
8572 diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c
8573 index 2926e4937301..2e279ac0fa4d 100644
8574 --- a/drivers/phy/renesas/phy-rcar-gen2.c
8575 +++ b/drivers/phy/renesas/phy-rcar-gen2.c
8576 @@ -71,6 +71,7 @@ struct rcar_gen2_phy_driver {
8577 struct rcar_gen2_phy_data {
8578 const struct phy_ops *gen2_phy_ops;
8579 const u32 (*select_value)[PHYS_PER_CHANNEL];
8580 + const u32 num_channels;
8581 };
8582
8583 static int rcar_gen2_phy_init(struct phy *p)
8584 @@ -271,11 +272,13 @@ static const u32 usb20_select_value[][PHYS_PER_CHANNEL] = {
8585 static const struct rcar_gen2_phy_data rcar_gen2_usb_phy_data = {
8586 .gen2_phy_ops = &rcar_gen2_phy_ops,
8587 .select_value = pci_select_value,
8588 + .num_channels = ARRAY_SIZE(pci_select_value),
8589 };
8590
8591 static const struct rcar_gen2_phy_data rz_g1c_usb_phy_data = {
8592 .gen2_phy_ops = &rz_g1c_phy_ops,
8593 .select_value = usb20_select_value,
8594 + .num_channels = ARRAY_SIZE(usb20_select_value),
8595 };
8596
8597 static const struct of_device_id rcar_gen2_phy_match_table[] = {
8598 @@ -389,7 +392,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
8599 channel->selected_phy = -1;
8600
8601 error = of_property_read_u32(np, "reg", &channel_num);
8602 - if (error || channel_num > 2) {
8603 + if (error || channel_num >= data->num_channels) {
8604 dev_err(dev, "Invalid \"reg\" property\n");
8605 of_node_put(np);
8606 return error;
8607 diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
8608 index 5d6d8b1e9062..dbaacde1b36a 100644
8609 --- a/drivers/pinctrl/devicetree.c
8610 +++ b/drivers/pinctrl/devicetree.c
8611 @@ -29,6 +29,13 @@ struct pinctrl_dt_map {
8612 static void dt_free_map(struct pinctrl_dev *pctldev,
8613 struct pinctrl_map *map, unsigned num_maps)
8614 {
8615 + int i;
8616 +
8617 + for (i = 0; i < num_maps; ++i) {
8618 + kfree_const(map[i].dev_name);
8619 + map[i].dev_name = NULL;
8620 + }
8621 +
8622 if (pctldev) {
8623 const struct pinctrl_ops *ops = pctldev->desc->pctlops;
8624 if (ops->dt_free_map)
8625 @@ -63,7 +70,13 @@ static int dt_remember_or_free_map(struct pinctrl *p, const char *statename,
8626
8627 /* Initialize common mapping table entry fields */
8628 for (i = 0; i < num_maps; i++) {
8629 - map[i].dev_name = dev_name(p->dev);
8630 + const char *devname;
8631 +
8632 + devname = kstrdup_const(dev_name(p->dev), GFP_KERNEL);
8633 + if (!devname)
8634 + goto err_free_map;
8635 +
8636 + map[i].dev_name = devname;
8637 map[i].name = statename;
8638 if (pctldev)
8639 map[i].ctrl_dev_name = dev_name(pctldev->dev);
8640 @@ -71,10 +84,8 @@ static int dt_remember_or_free_map(struct pinctrl *p, const char *statename,
8641
8642 /* Remember the converted mapping table entries */
8643 dt_map = kzalloc(sizeof(*dt_map), GFP_KERNEL);
8644 - if (!dt_map) {
8645 - dt_free_map(pctldev, map, num_maps);
8646 - return -ENOMEM;
8647 - }
8648 + if (!dt_map)
8649 + goto err_free_map;
8650
8651 dt_map->pctldev = pctldev;
8652 dt_map->map = map;
8653 @@ -82,6 +93,10 @@ static int dt_remember_or_free_map(struct pinctrl *p, const char *statename,
8654 list_add_tail(&dt_map->node, &p->dt_maps);
8655
8656 return pinctrl_register_map(map, num_maps, false);
8657 +
8658 +err_free_map:
8659 + dt_free_map(pctldev, map, num_maps);
8660 + return -ENOMEM;
8661 }
8662
8663 struct pinctrl_dev *of_pinctrl_get(struct device_node *np)
8664 diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
8665 index 9ffb22211d2b..7d658e6627e7 100644
8666 --- a/drivers/pinctrl/intel/pinctrl-baytrail.c
8667 +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
8668 @@ -110,7 +110,6 @@ struct byt_gpio {
8669 struct platform_device *pdev;
8670 struct pinctrl_dev *pctl_dev;
8671 struct pinctrl_desc pctl_desc;
8672 - raw_spinlock_t lock;
8673 const struct intel_pinctrl_soc_data *soc_data;
8674 struct intel_community *communities_copy;
8675 struct byt_gpio_pin_context *saved_context;
8676 @@ -549,6 +548,8 @@ static const struct intel_pinctrl_soc_data *byt_soc_data[] = {
8677 NULL
8678 };
8679
8680 +static DEFINE_RAW_SPINLOCK(byt_lock);
8681 +
8682 static struct intel_community *byt_get_community(struct byt_gpio *vg,
8683 unsigned int pin)
8684 {
8685 @@ -658,7 +659,7 @@ static void byt_set_group_simple_mux(struct byt_gpio *vg,
8686 unsigned long flags;
8687 int i;
8688
8689 - raw_spin_lock_irqsave(&vg->lock, flags);
8690 + raw_spin_lock_irqsave(&byt_lock, flags);
8691
8692 for (i = 0; i < group.npins; i++) {
8693 void __iomem *padcfg0;
8694 @@ -678,7 +679,7 @@ static void byt_set_group_simple_mux(struct byt_gpio *vg,
8695 writel(value, padcfg0);
8696 }
8697
8698 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8699 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8700 }
8701
8702 static void byt_set_group_mixed_mux(struct byt_gpio *vg,
8703 @@ -688,7 +689,7 @@ static void byt_set_group_mixed_mux(struct byt_gpio *vg,
8704 unsigned long flags;
8705 int i;
8706
8707 - raw_spin_lock_irqsave(&vg->lock, flags);
8708 + raw_spin_lock_irqsave(&byt_lock, flags);
8709
8710 for (i = 0; i < group.npins; i++) {
8711 void __iomem *padcfg0;
8712 @@ -708,7 +709,7 @@ static void byt_set_group_mixed_mux(struct byt_gpio *vg,
8713 writel(value, padcfg0);
8714 }
8715
8716 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8717 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8718 }
8719
8720 static int byt_set_mux(struct pinctrl_dev *pctldev, unsigned int func_selector,
8721 @@ -749,11 +750,11 @@ static void byt_gpio_clear_triggering(struct byt_gpio *vg, unsigned int offset)
8722 unsigned long flags;
8723 u32 value;
8724
8725 - raw_spin_lock_irqsave(&vg->lock, flags);
8726 + raw_spin_lock_irqsave(&byt_lock, flags);
8727 value = readl(reg);
8728 value &= ~(BYT_TRIG_POS | BYT_TRIG_NEG | BYT_TRIG_LVL);
8729 writel(value, reg);
8730 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8731 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8732 }
8733
8734 static int byt_gpio_request_enable(struct pinctrl_dev *pctl_dev,
8735 @@ -765,7 +766,7 @@ static int byt_gpio_request_enable(struct pinctrl_dev *pctl_dev,
8736 u32 value, gpio_mux;
8737 unsigned long flags;
8738
8739 - raw_spin_lock_irqsave(&vg->lock, flags);
8740 + raw_spin_lock_irqsave(&byt_lock, flags);
8741
8742 /*
8743 * In most cases, func pin mux 000 means GPIO function.
8744 @@ -787,7 +788,7 @@ static int byt_gpio_request_enable(struct pinctrl_dev *pctl_dev,
8745 "pin %u forcibly re-configured as GPIO\n", offset);
8746 }
8747
8748 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8749 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8750
8751 pm_runtime_get(&vg->pdev->dev);
8752
8753 @@ -815,7 +816,7 @@ static int byt_gpio_set_direction(struct pinctrl_dev *pctl_dev,
8754 unsigned long flags;
8755 u32 value;
8756
8757 - raw_spin_lock_irqsave(&vg->lock, flags);
8758 + raw_spin_lock_irqsave(&byt_lock, flags);
8759
8760 value = readl(val_reg);
8761 value &= ~BYT_DIR_MASK;
8762 @@ -832,7 +833,7 @@ static int byt_gpio_set_direction(struct pinctrl_dev *pctl_dev,
8763 "Potential Error: Setting GPIO with direct_irq_en to output");
8764 writel(value, val_reg);
8765
8766 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8767 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8768
8769 return 0;
8770 }
8771 @@ -901,11 +902,11 @@ static int byt_pin_config_get(struct pinctrl_dev *pctl_dev, unsigned int offset,
8772 u32 conf, pull, val, debounce;
8773 u16 arg = 0;
8774
8775 - raw_spin_lock_irqsave(&vg->lock, flags);
8776 + raw_spin_lock_irqsave(&byt_lock, flags);
8777 conf = readl(conf_reg);
8778 pull = conf & BYT_PULL_ASSIGN_MASK;
8779 val = readl(val_reg);
8780 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8781 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8782
8783 switch (param) {
8784 case PIN_CONFIG_BIAS_DISABLE:
8785 @@ -932,9 +933,9 @@ static int byt_pin_config_get(struct pinctrl_dev *pctl_dev, unsigned int offset,
8786 if (!(conf & BYT_DEBOUNCE_EN))
8787 return -EINVAL;
8788
8789 - raw_spin_lock_irqsave(&vg->lock, flags);
8790 + raw_spin_lock_irqsave(&byt_lock, flags);
8791 debounce = readl(db_reg);
8792 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8793 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8794
8795 switch (debounce & BYT_DEBOUNCE_PULSE_MASK) {
8796 case BYT_DEBOUNCE_PULSE_375US:
8797 @@ -986,7 +987,7 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
8798 u32 conf, val, debounce;
8799 int i, ret = 0;
8800
8801 - raw_spin_lock_irqsave(&vg->lock, flags);
8802 + raw_spin_lock_irqsave(&byt_lock, flags);
8803
8804 conf = readl(conf_reg);
8805 val = readl(val_reg);
8806 @@ -1094,7 +1095,7 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
8807 if (!ret)
8808 writel(conf, conf_reg);
8809
8810 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8811 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8812
8813 return ret;
8814 }
8815 @@ -1119,9 +1120,9 @@ static int byt_gpio_get(struct gpio_chip *chip, unsigned int offset)
8816 unsigned long flags;
8817 u32 val;
8818
8819 - raw_spin_lock_irqsave(&vg->lock, flags);
8820 + raw_spin_lock_irqsave(&byt_lock, flags);
8821 val = readl(reg);
8822 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8823 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8824
8825 return !!(val & BYT_LEVEL);
8826 }
8827 @@ -1136,13 +1137,13 @@ static void byt_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
8828 if (!reg)
8829 return;
8830
8831 - raw_spin_lock_irqsave(&vg->lock, flags);
8832 + raw_spin_lock_irqsave(&byt_lock, flags);
8833 old_val = readl(reg);
8834 if (value)
8835 writel(old_val | BYT_LEVEL, reg);
8836 else
8837 writel(old_val & ~BYT_LEVEL, reg);
8838 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8839 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8840 }
8841
8842 static int byt_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
8843 @@ -1155,9 +1156,9 @@ static int byt_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
8844 if (!reg)
8845 return -EINVAL;
8846
8847 - raw_spin_lock_irqsave(&vg->lock, flags);
8848 + raw_spin_lock_irqsave(&byt_lock, flags);
8849 value = readl(reg);
8850 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8851 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8852
8853 if (!(value & BYT_OUTPUT_EN))
8854 return 0;
8855 @@ -1200,14 +1201,14 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
8856 const char *label;
8857 unsigned int pin;
8858
8859 - raw_spin_lock_irqsave(&vg->lock, flags);
8860 + raw_spin_lock_irqsave(&byt_lock, flags);
8861 pin = vg->soc_data->pins[i].number;
8862 reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG);
8863 if (!reg) {
8864 seq_printf(s,
8865 "Could not retrieve pin %i conf0 reg\n",
8866 pin);
8867 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8868 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8869 continue;
8870 }
8871 conf0 = readl(reg);
8872 @@ -1216,11 +1217,11 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
8873 if (!reg) {
8874 seq_printf(s,
8875 "Could not retrieve pin %i val reg\n", pin);
8876 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8877 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8878 continue;
8879 }
8880 val = readl(reg);
8881 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8882 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8883
8884 comm = byt_get_community(vg, pin);
8885 if (!comm) {
8886 @@ -1304,9 +1305,9 @@ static void byt_irq_ack(struct irq_data *d)
8887 if (!reg)
8888 return;
8889
8890 - raw_spin_lock(&vg->lock);
8891 + raw_spin_lock(&byt_lock);
8892 writel(BIT(offset % 32), reg);
8893 - raw_spin_unlock(&vg->lock);
8894 + raw_spin_unlock(&byt_lock);
8895 }
8896
8897 static void byt_irq_mask(struct irq_data *d)
8898 @@ -1330,7 +1331,7 @@ static void byt_irq_unmask(struct irq_data *d)
8899 if (!reg)
8900 return;
8901
8902 - raw_spin_lock_irqsave(&vg->lock, flags);
8903 + raw_spin_lock_irqsave(&byt_lock, flags);
8904 value = readl(reg);
8905
8906 switch (irqd_get_trigger_type(d)) {
8907 @@ -1353,7 +1354,7 @@ static void byt_irq_unmask(struct irq_data *d)
8908
8909 writel(value, reg);
8910
8911 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8912 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8913 }
8914
8915 static int byt_irq_type(struct irq_data *d, unsigned int type)
8916 @@ -1367,7 +1368,7 @@ static int byt_irq_type(struct irq_data *d, unsigned int type)
8917 if (!reg || offset >= vg->chip.ngpio)
8918 return -EINVAL;
8919
8920 - raw_spin_lock_irqsave(&vg->lock, flags);
8921 + raw_spin_lock_irqsave(&byt_lock, flags);
8922 value = readl(reg);
8923
8924 WARN(value & BYT_DIRECT_IRQ_EN,
8925 @@ -1389,7 +1390,7 @@ static int byt_irq_type(struct irq_data *d, unsigned int type)
8926 else if (type & IRQ_TYPE_LEVEL_MASK)
8927 irq_set_handler_locked(d, handle_level_irq);
8928
8929 - raw_spin_unlock_irqrestore(&vg->lock, flags);
8930 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8931
8932 return 0;
8933 }
8934 @@ -1425,9 +1426,9 @@ static void byt_gpio_irq_handler(struct irq_desc *desc)
8935 continue;
8936 }
8937
8938 - raw_spin_lock(&vg->lock);
8939 + raw_spin_lock(&byt_lock);
8940 pending = readl(reg);
8941 - raw_spin_unlock(&vg->lock);
8942 + raw_spin_unlock(&byt_lock);
8943 for_each_set_bit(pin, &pending, 32) {
8944 virq = irq_find_mapping(vg->chip.irq.domain, base + pin);
8945 generic_handle_irq(virq);
8946 @@ -1638,8 +1639,6 @@ static int byt_pinctrl_probe(struct platform_device *pdev)
8947 return PTR_ERR(vg->pctl_dev);
8948 }
8949
8950 - raw_spin_lock_init(&vg->lock);
8951 -
8952 ret = byt_gpio_probe(vg);
8953 if (ret)
8954 return ret;
8955 @@ -1654,8 +1653,11 @@ static int byt_pinctrl_probe(struct platform_device *pdev)
8956 static int byt_gpio_suspend(struct device *dev)
8957 {
8958 struct byt_gpio *vg = dev_get_drvdata(dev);
8959 + unsigned long flags;
8960 int i;
8961
8962 + raw_spin_lock_irqsave(&byt_lock, flags);
8963 +
8964 for (i = 0; i < vg->soc_data->npins; i++) {
8965 void __iomem *reg;
8966 u32 value;
8967 @@ -1676,14 +1678,18 @@ static int byt_gpio_suspend(struct device *dev)
8968 vg->saved_context[i].val = value;
8969 }
8970
8971 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8972 return 0;
8973 }
8974
8975 static int byt_gpio_resume(struct device *dev)
8976 {
8977 struct byt_gpio *vg = dev_get_drvdata(dev);
8978 + unsigned long flags;
8979 int i;
8980
8981 + raw_spin_lock_irqsave(&byt_lock, flags);
8982 +
8983 for (i = 0; i < vg->soc_data->npins; i++) {
8984 void __iomem *reg;
8985 u32 value;
8986 @@ -1721,6 +1727,7 @@ static int byt_gpio_resume(struct device *dev)
8987 }
8988 }
8989
8990 + raw_spin_unlock_irqrestore(&byt_lock, flags);
8991 return 0;
8992 }
8993 #endif
8994 diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
8995 index 2c61141519f8..eab078244a4c 100644
8996 --- a/drivers/pinctrl/pinctrl-amd.c
8997 +++ b/drivers/pinctrl/pinctrl-amd.c
8998 @@ -540,7 +540,8 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
8999 irqreturn_t ret = IRQ_NONE;
9000 unsigned int i, irqnr;
9001 unsigned long flags;
9002 - u32 *regs, regval;
9003 + u32 __iomem *regs;
9004 + u32 regval;
9005 u64 status, mask;
9006
9007 /* Read the wake status */
9008 diff --git a/drivers/pinctrl/qcom/pinctrl-sc7180.c b/drivers/pinctrl/qcom/pinctrl-sc7180.c
9009 index 6399c8a2bc22..d6cfad7417b1 100644
9010 --- a/drivers/pinctrl/qcom/pinctrl-sc7180.c
9011 +++ b/drivers/pinctrl/qcom/pinctrl-sc7180.c
9012 @@ -77,6 +77,7 @@ enum {
9013 .intr_cfg_reg = 0, \
9014 .intr_status_reg = 0, \
9015 .intr_target_reg = 0, \
9016 + .tile = SOUTH, \
9017 .mux_bit = -1, \
9018 .pull_bit = pull, \
9019 .drv_bit = drv, \
9020 @@ -102,6 +103,7 @@ enum {
9021 .intr_cfg_reg = 0, \
9022 .intr_status_reg = 0, \
9023 .intr_target_reg = 0, \
9024 + .tile = SOUTH, \
9025 .mux_bit = -1, \
9026 .pull_bit = 3, \
9027 .drv_bit = 0, \
9028 @@ -1087,14 +1089,14 @@ static const struct msm_pingroup sc7180_groups[] = {
9029 [116] = PINGROUP(116, WEST, qup04, qup04, _, _, _, _, _, _, _),
9030 [117] = PINGROUP(117, WEST, dp_hot, _, _, _, _, _, _, _, _),
9031 [118] = PINGROUP(118, WEST, _, _, _, _, _, _, _, _, _),
9032 - [119] = UFS_RESET(ufs_reset, 0x97f000),
9033 - [120] = SDC_QDSD_PINGROUP(sdc1_rclk, 0x97a000, 15, 0),
9034 - [121] = SDC_QDSD_PINGROUP(sdc1_clk, 0x97a000, 13, 6),
9035 - [122] = SDC_QDSD_PINGROUP(sdc1_cmd, 0x97a000, 11, 3),
9036 - [123] = SDC_QDSD_PINGROUP(sdc1_data, 0x97a000, 9, 0),
9037 - [124] = SDC_QDSD_PINGROUP(sdc2_clk, 0x97b000, 14, 6),
9038 - [125] = SDC_QDSD_PINGROUP(sdc2_cmd, 0x97b000, 11, 3),
9039 - [126] = SDC_QDSD_PINGROUP(sdc2_data, 0x97b000, 9, 0),
9040 + [119] = UFS_RESET(ufs_reset, 0x7f000),
9041 + [120] = SDC_QDSD_PINGROUP(sdc1_rclk, 0x7a000, 15, 0),
9042 + [121] = SDC_QDSD_PINGROUP(sdc1_clk, 0x7a000, 13, 6),
9043 + [122] = SDC_QDSD_PINGROUP(sdc1_cmd, 0x7a000, 11, 3),
9044 + [123] = SDC_QDSD_PINGROUP(sdc1_data, 0x7a000, 9, 0),
9045 + [124] = SDC_QDSD_PINGROUP(sdc2_clk, 0x7b000, 14, 6),
9046 + [125] = SDC_QDSD_PINGROUP(sdc2_cmd, 0x7b000, 11, 3),
9047 + [126] = SDC_QDSD_PINGROUP(sdc2_data, 0x7b000, 9, 0),
9048 };
9049
9050 static const struct msm_pinctrl_soc_data sc7180_pinctrl = {
9051 diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a77990.c b/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
9052 index 2dfb8d9cfda1..5200dadd6b3e 100644
9053 --- a/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
9054 +++ b/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
9055 @@ -448,6 +448,8 @@ FM(IP12_31_28) IP12_31_28 FM(IP13_31_28) IP13_31_28 FM(IP14_31_28) IP14_31_28 FM
9056 #define MOD_SEL0_1_0 REV4(FM(SEL_SPEED_PULSE_IF_0), FM(SEL_SPEED_PULSE_IF_1), FM(SEL_SPEED_PULSE_IF_2), F_(0, 0))
9057
9058 /* MOD_SEL1 */ /* 0 */ /* 1 */ /* 2 */ /* 3 */ /* 4 */ /* 5 */ /* 6 */ /* 7 */
9059 +#define MOD_SEL1_31 FM(SEL_SIMCARD_0) FM(SEL_SIMCARD_1)
9060 +#define MOD_SEL1_30 FM(SEL_SSI2_0) FM(SEL_SSI2_1)
9061 #define MOD_SEL1_29 FM(SEL_TIMER_TMU_0) FM(SEL_TIMER_TMU_1)
9062 #define MOD_SEL1_28 FM(SEL_USB_20_CH0_0) FM(SEL_USB_20_CH0_1)
9063 #define MOD_SEL1_26 FM(SEL_DRIF2_0) FM(SEL_DRIF2_1)
9064 @@ -468,7 +470,8 @@ FM(IP12_31_28) IP12_31_28 FM(IP13_31_28) IP13_31_28 FM(IP14_31_28) IP14_31_28 FM
9065
9066 #define PINMUX_MOD_SELS \
9067 \
9068 -MOD_SEL0_30_29 \
9069 + MOD_SEL1_31 \
9070 +MOD_SEL0_30_29 MOD_SEL1_30 \
9071 MOD_SEL1_29 \
9072 MOD_SEL0_28 MOD_SEL1_28 \
9073 MOD_SEL0_27_26 \
9074 @@ -1058,7 +1061,7 @@ static const u16 pinmux_data[] = {
9075 PINMUX_IPSR_MSEL(IP10_27_24, RIF0_CLK_B, SEL_DRIF0_1),
9076 PINMUX_IPSR_MSEL(IP10_27_24, SCL2_B, SEL_I2C2_1),
9077 PINMUX_IPSR_MSEL(IP10_27_24, TCLK1_A, SEL_TIMER_TMU_0),
9078 - PINMUX_IPSR_GPSR(IP10_27_24, SSI_SCK2_B),
9079 + PINMUX_IPSR_MSEL(IP10_27_24, SSI_SCK2_B, SEL_SSI2_1),
9080 PINMUX_IPSR_GPSR(IP10_27_24, TS_SCK0),
9081
9082 PINMUX_IPSR_GPSR(IP10_31_28, SD0_WP),
9083 @@ -1067,7 +1070,7 @@ static const u16 pinmux_data[] = {
9084 PINMUX_IPSR_MSEL(IP10_31_28, RIF0_D0_B, SEL_DRIF0_1),
9085 PINMUX_IPSR_MSEL(IP10_31_28, SDA2_B, SEL_I2C2_1),
9086 PINMUX_IPSR_MSEL(IP10_31_28, TCLK2_A, SEL_TIMER_TMU_0),
9087 - PINMUX_IPSR_GPSR(IP10_31_28, SSI_WS2_B),
9088 + PINMUX_IPSR_MSEL(IP10_31_28, SSI_WS2_B, SEL_SSI2_1),
9089 PINMUX_IPSR_GPSR(IP10_31_28, TS_SDAT0),
9090
9091 /* IPSR11 */
9092 @@ -1085,13 +1088,13 @@ static const u16 pinmux_data[] = {
9093
9094 PINMUX_IPSR_MSEL(IP11_11_8, RX0_A, SEL_SCIF0_0),
9095 PINMUX_IPSR_MSEL(IP11_11_8, HRX1_A, SEL_HSCIF1_0),
9096 - PINMUX_IPSR_GPSR(IP11_11_8, SSI_SCK2_A),
9097 + PINMUX_IPSR_MSEL(IP11_11_8, SSI_SCK2_A, SEL_SSI2_0),
9098 PINMUX_IPSR_GPSR(IP11_11_8, RIF1_SYNC),
9099 PINMUX_IPSR_GPSR(IP11_11_8, TS_SCK1),
9100
9101 PINMUX_IPSR_MSEL(IP11_15_12, TX0_A, SEL_SCIF0_0),
9102 PINMUX_IPSR_GPSR(IP11_15_12, HTX1_A),
9103 - PINMUX_IPSR_GPSR(IP11_15_12, SSI_WS2_A),
9104 + PINMUX_IPSR_MSEL(IP11_15_12, SSI_WS2_A, SEL_SSI2_0),
9105 PINMUX_IPSR_GPSR(IP11_15_12, RIF1_D0),
9106 PINMUX_IPSR_GPSR(IP11_15_12, TS_SDAT1),
9107
9108 @@ -1196,7 +1199,7 @@ static const u16 pinmux_data[] = {
9109 PINMUX_IPSR_MSEL(IP13_19_16, RIF0_D1_A, SEL_DRIF0_0),
9110 PINMUX_IPSR_MSEL(IP13_19_16, SDA1_B, SEL_I2C1_1),
9111 PINMUX_IPSR_MSEL(IP13_19_16, TCLK2_B, SEL_TIMER_TMU_1),
9112 - PINMUX_IPSR_GPSR(IP13_19_16, SIM0_D_A),
9113 + PINMUX_IPSR_MSEL(IP13_19_16, SIM0_D_A, SEL_SIMCARD_0),
9114
9115 PINMUX_IPSR_GPSR(IP13_23_20, MLB_DAT),
9116 PINMUX_IPSR_MSEL(IP13_23_20, TX0_B, SEL_SCIF0_1),
9117 @@ -1264,7 +1267,7 @@ static const u16 pinmux_data[] = {
9118 PINMUX_IPSR_GPSR(IP15_15_12, TPU0TO2),
9119 PINMUX_IPSR_MSEL(IP15_15_12, SDA1_D, SEL_I2C1_3),
9120 PINMUX_IPSR_MSEL(IP15_15_12, FSO_CFE_1_N_B, SEL_FSO_1),
9121 - PINMUX_IPSR_GPSR(IP15_15_12, SIM0_D_B),
9122 + PINMUX_IPSR_MSEL(IP15_15_12, SIM0_D_B, SEL_SIMCARD_1),
9123
9124 PINMUX_IPSR_GPSR(IP15_19_16, SSI_SDATA6),
9125 PINMUX_IPSR_MSEL(IP15_19_16, HRTS2_N_A, SEL_HSCIF2_0),
9126 @@ -4957,11 +4960,11 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
9127 MOD_SEL0_1_0 ))
9128 },
9129 { PINMUX_CFG_REG_VAR("MOD_SEL1", 0xe6060504, 32,
9130 - GROUP(2, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1,
9131 - 2, 2, 2, 1, 1, 2, 1, 4),
9132 + GROUP(1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1,
9133 + 1, 2, 2, 2, 1, 1, 2, 1, 4),
9134 GROUP(
9135 - /* RESERVED 31, 30 */
9136 - 0, 0, 0, 0,
9137 + MOD_SEL1_31
9138 + MOD_SEL1_30
9139 MOD_SEL1_29
9140 MOD_SEL1_28
9141 /* RESERVED 27 */
9142 diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7734.c b/drivers/pinctrl/sh-pfc/pfc-sh7734.c
9143 index 5dfd991ffdaa..dbc36079c381 100644
9144 --- a/drivers/pinctrl/sh-pfc/pfc-sh7734.c
9145 +++ b/drivers/pinctrl/sh-pfc/pfc-sh7734.c
9146 @@ -1450,7 +1450,7 @@ static const struct pinmux_func pinmux_func_gpios[] = {
9147 GPIO_FN(ET0_ETXD2_A),
9148 GPIO_FN(EX_CS5), GPIO_FN(SD1_CMD_A), GPIO_FN(ATADIR), GPIO_FN(QSSL_B),
9149 GPIO_FN(ET0_ETXD3_A),
9150 - GPIO_FN(RD_WR), GPIO_FN(TCLK1_B),
9151 + GPIO_FN(RD_WR), GPIO_FN(TCLK0), GPIO_FN(CAN_CLK_B), GPIO_FN(ET0_ETXD4),
9152 GPIO_FN(EX_WAIT0), GPIO_FN(TCLK1_B),
9153 GPIO_FN(EX_WAIT1), GPIO_FN(SD1_DAT0_A), GPIO_FN(DREQ2),
9154 GPIO_FN(CAN1_TX_C), GPIO_FN(ET0_LINK_C), GPIO_FN(ET0_ETXD5_A),
9155 @@ -1949,7 +1949,7 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
9156 /* IP3_20 [1] */
9157 FN_EX_WAIT0, FN_TCLK1_B,
9158 /* IP3_19_18 [2] */
9159 - FN_RD_WR, FN_TCLK1_B, 0, 0,
9160 + FN_RD_WR, FN_TCLK0, FN_CAN_CLK_B, FN_ET0_ETXD4,
9161 /* IP3_17_15 [3] */
9162 FN_EX_CS5, FN_SD1_CMD_A, FN_ATADIR, FN_QSSL_B,
9163 FN_ET0_ETXD3_A, 0, 0, 0,
9164 diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
9165 index 9579a706fc08..a881b709af25 100644
9166 --- a/drivers/platform/x86/hp-wmi.c
9167 +++ b/drivers/platform/x86/hp-wmi.c
9168 @@ -300,7 +300,7 @@ static int __init hp_wmi_bios_2008_later(void)
9169
9170 static int __init hp_wmi_bios_2009_later(void)
9171 {
9172 - int state = 0;
9173 + u8 state[128];
9174 int ret = hp_wmi_perform_query(HPWMI_FEATURE2_QUERY, HPWMI_READ, &state,
9175 sizeof(state), sizeof(state));
9176 if (!ret)
9177 diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
9178 index 61d6447d1966..00a96e4a1cdc 100644
9179 --- a/drivers/power/supply/cpcap-battery.c
9180 +++ b/drivers/power/supply/cpcap-battery.c
9181 @@ -562,12 +562,14 @@ static irqreturn_t cpcap_battery_irq_thread(int irq, void *data)
9182 switch (d->action) {
9183 case CPCAP_BATTERY_IRQ_ACTION_BATTERY_LOW:
9184 if (latest->current_ua >= 0)
9185 - dev_warn(ddata->dev, "Battery low at 3.3V!\n");
9186 + dev_warn(ddata->dev, "Battery low at %imV!\n",
9187 + latest->voltage / 1000);
9188 break;
9189 case CPCAP_BATTERY_IRQ_ACTION_POWEROFF:
9190 - if (latest->current_ua >= 0) {
9191 + if (latest->current_ua >= 0 && latest->voltage <= 3200000) {
9192 dev_emerg(ddata->dev,
9193 - "Battery empty at 3.1V, powering off\n");
9194 + "Battery empty at %imV, powering off\n",
9195 + latest->voltage / 1000);
9196 orderly_poweroff(true);
9197 }
9198 break;
9199 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
9200 index a46be221dbdc..87bc06b386a0 100644
9201 --- a/drivers/regulator/core.c
9202 +++ b/drivers/regulator/core.c
9203 @@ -1403,7 +1403,9 @@ static int set_machine_constraints(struct regulator_dev *rdev,
9204 rdev_err(rdev, "failed to enable\n");
9205 return ret;
9206 }
9207 - rdev->use_count++;
9208 +
9209 + if (rdev->constraints->always_on)
9210 + rdev->use_count++;
9211 }
9212
9213 print_constraints(rdev);
9214 @@ -5198,6 +5200,7 @@ unset_supplies:
9215 regulator_remove_coupling(rdev);
9216 mutex_unlock(&regulator_list_mutex);
9217 wash:
9218 + kfree(rdev->coupling_desc.coupled_rdevs);
9219 kfree(rdev->constraints);
9220 mutex_lock(&regulator_list_mutex);
9221 regulator_ena_gpio_free(rdev);
9222 diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c
9223 index 76152aaa330b..96dc0eea7659 100644
9224 --- a/drivers/regulator/max8907-regulator.c
9225 +++ b/drivers/regulator/max8907-regulator.c
9226 @@ -296,7 +296,10 @@ static int max8907_regulator_probe(struct platform_device *pdev)
9227 memcpy(pmic->desc, max8907_regulators, sizeof(pmic->desc));
9228
9229 /* Backwards compatibility with MAX8907B; SD1 uses different voltages */
9230 - regmap_read(max8907->regmap_gen, MAX8907_REG_II2RR, &val);
9231 + ret = regmap_read(max8907->regmap_gen, MAX8907_REG_II2RR, &val);
9232 + if (ret)
9233 + return ret;
9234 +
9235 if ((val & MAX8907_II2RR_VERSION_MASK) ==
9236 MAX8907_II2RR_VERSION_REV_B) {
9237 pmic->desc[MAX8907_SD1].min_uV = 637500;
9238 @@ -333,14 +336,20 @@ static int max8907_regulator_probe(struct platform_device *pdev)
9239 }
9240
9241 if (pmic->desc[i].ops == &max8907_ldo_ops) {
9242 - regmap_read(config.regmap, pmic->desc[i].enable_reg,
9243 + ret = regmap_read(config.regmap, pmic->desc[i].enable_reg,
9244 &val);
9245 + if (ret)
9246 + return ret;
9247 +
9248 if ((val & MAX8907_MASK_LDO_SEQ) !=
9249 MAX8907_MASK_LDO_SEQ)
9250 pmic->desc[i].ops = &max8907_ldo_hwctl_ops;
9251 } else if (pmic->desc[i].ops == &max8907_out5v_ops) {
9252 - regmap_read(config.regmap, pmic->desc[i].enable_reg,
9253 + ret = regmap_read(config.regmap, pmic->desc[i].enable_reg,
9254 &val);
9255 + if (ret)
9256 + return ret;
9257 +
9258 if ((val & (MAX8907_MASK_OUT5V_VINEN |
9259 MAX8907_MASK_OUT5V_ENSRC)) !=
9260 MAX8907_MASK_OUT5V_ENSRC)
9261 diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c
9262 index 13c54eac0cc3..d1839707128a 100644
9263 --- a/drivers/soundwire/intel.c
9264 +++ b/drivers/soundwire/intel.c
9265 @@ -479,7 +479,10 @@ intel_pdi_shim_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi)
9266 unsigned int link_id = sdw->instance;
9267 int pdi_conf = 0;
9268
9269 - pdi->intel_alh_id = (link_id * 16) + pdi->num + 5;
9270 + /* the Bulk and PCM streams are not contiguous */
9271 + pdi->intel_alh_id = (link_id * 16) + pdi->num + 3;
9272 + if (pdi->num >= 2)
9273 + pdi->intel_alh_id += 2;
9274
9275 /*
9276 * Program stream parameters to stream SHIM register
9277 @@ -508,7 +511,10 @@ intel_pdi_alh_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi)
9278 unsigned int link_id = sdw->instance;
9279 unsigned int conf;
9280
9281 - pdi->intel_alh_id = (link_id * 16) + pdi->num + 5;
9282 + /* the Bulk and PCM streams are not contiguous */
9283 + pdi->intel_alh_id = (link_id * 16) + pdi->num + 3;
9284 + if (pdi->num >= 2)
9285 + pdi->intel_alh_id += 2;
9286
9287 /* Program Stream config ALH register */
9288 conf = intel_readl(alh, SDW_ALH_STRMZCFG(pdi->intel_alh_id));
9289 diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
9290 index c36587b42e95..82a0ee09cbe1 100644
9291 --- a/drivers/spi/spi-cadence.c
9292 +++ b/drivers/spi/spi-cadence.c
9293 @@ -168,16 +168,16 @@ static void cdns_spi_init_hw(struct cdns_spi *xspi)
9294 /**
9295 * cdns_spi_chipselect - Select or deselect the chip select line
9296 * @spi: Pointer to the spi_device structure
9297 - * @enable: Select (1) or deselect (0) the chip select line
9298 + * @is_high: Select(0) or deselect (1) the chip select line
9299 */
9300 -static void cdns_spi_chipselect(struct spi_device *spi, bool enable)
9301 +static void cdns_spi_chipselect(struct spi_device *spi, bool is_high)
9302 {
9303 struct cdns_spi *xspi = spi_master_get_devdata(spi->master);
9304 u32 ctrl_reg;
9305
9306 ctrl_reg = cdns_spi_read(xspi, CDNS_SPI_CR);
9307
9308 - if (!enable) {
9309 + if (is_high) {
9310 /* Deselect the slave */
9311 ctrl_reg |= CDNS_SPI_CR_SSCTRL;
9312 } else {
9313 diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
9314 index 9a49e073e8b7..45972056ed8c 100644
9315 --- a/drivers/spi/spi-dw.c
9316 +++ b/drivers/spi/spi-dw.c
9317 @@ -129,10 +129,11 @@ void dw_spi_set_cs(struct spi_device *spi, bool enable)
9318 struct dw_spi *dws = spi_controller_get_devdata(spi->controller);
9319 struct chip_data *chip = spi_get_ctldata(spi);
9320
9321 + /* Chip select logic is inverted from spi_set_cs() */
9322 if (chip && chip->cs_control)
9323 - chip->cs_control(enable);
9324 + chip->cs_control(!enable);
9325
9326 - if (enable)
9327 + if (!enable)
9328 dw_writel(dws, DW_SPI_SER, BIT(spi->chip_select));
9329 else if (dws->cs_override)
9330 dw_writel(dws, DW_SPI_SER, 0);
9331 @@ -308,7 +309,8 @@ static int dw_spi_transfer_one(struct spi_controller *master,
9332 cr0 = (transfer->bits_per_word - 1)
9333 | (chip->type << SPI_FRF_OFFSET)
9334 | ((((spi->mode & SPI_CPOL) ? 1 : 0) << SPI_SCOL_OFFSET) |
9335 - (((spi->mode & SPI_CPHA) ? 1 : 0) << SPI_SCPH_OFFSET))
9336 + (((spi->mode & SPI_CPHA) ? 1 : 0) << SPI_SCPH_OFFSET) |
9337 + (((spi->mode & SPI_LOOP) ? 1 : 0) << SPI_SRL_OFFSET))
9338 | (chip->tmode << SPI_TMOD_OFFSET);
9339
9340 /*
9341 diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
9342 index 4b80ace1d137..2d563874b4ac 100644
9343 --- a/drivers/spi/spi-fsl-spi.c
9344 +++ b/drivers/spi/spi-fsl-spi.c
9345 @@ -736,9 +736,9 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
9346 if (ret)
9347 goto err;
9348
9349 - irq = irq_of_parse_and_map(np, 0);
9350 - if (!irq) {
9351 - ret = -EINVAL;
9352 + irq = platform_get_irq(ofdev, 0);
9353 + if (irq < 0) {
9354 + ret = irq;
9355 goto err;
9356 }
9357
9358 @@ -751,7 +751,6 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
9359 return 0;
9360
9361 err:
9362 - irq_dispose_mapping(irq);
9363 return ret;
9364 }
9365
9366 diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
9367 index 1d3e23ec20a6..f9c5bbb74714 100644
9368 --- a/drivers/spi/spi-gpio.c
9369 +++ b/drivers/spi/spi-gpio.c
9370 @@ -371,8 +371,10 @@ static int spi_gpio_probe(struct platform_device *pdev)
9371 return -ENOMEM;
9372
9373 status = devm_add_action_or_reset(&pdev->dev, spi_gpio_put, master);
9374 - if (status)
9375 + if (status) {
9376 + spi_master_put(master);
9377 return status;
9378 + }
9379
9380 if (of_id)
9381 status = spi_gpio_probe_dt(pdev, master);
9382 diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c
9383 index 439b01e4a2c8..f4a8f470aecc 100644
9384 --- a/drivers/spi/spi-img-spfi.c
9385 +++ b/drivers/spi/spi-img-spfi.c
9386 @@ -673,6 +673,8 @@ static int img_spfi_probe(struct platform_device *pdev)
9387 dma_release_channel(spfi->tx_ch);
9388 if (spfi->rx_ch)
9389 dma_release_channel(spfi->rx_ch);
9390 + spfi->tx_ch = NULL;
9391 + spfi->rx_ch = NULL;
9392 dev_warn(spfi->dev, "Failed to get DMA channels, falling back to PIO mode\n");
9393 } else {
9394 master->dma_tx = spfi->tx_ch;
9395 diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
9396 index bb6a14d1ab0f..2e73d75a6ac5 100644
9397 --- a/drivers/spi/spi-pxa2xx.c
9398 +++ b/drivers/spi/spi-pxa2xx.c
9399 @@ -1565,7 +1565,13 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
9400 #endif
9401
9402 ssp->clk = devm_clk_get(&pdev->dev, NULL);
9403 + if (IS_ERR(ssp->clk))
9404 + return NULL;
9405 +
9406 ssp->irq = platform_get_irq(pdev, 0);
9407 + if (ssp->irq < 0)
9408 + return NULL;
9409 +
9410 ssp->type = type;
9411 ssp->pdev = pdev;
9412 ssp->port_id = pxa2xx_spi_get_port_id(adev);
9413 diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c
9414 index 35254bdc42c4..f7c1e20432e0 100644
9415 --- a/drivers/spi/spi-sifive.c
9416 +++ b/drivers/spi/spi-sifive.c
9417 @@ -357,14 +357,14 @@ static int sifive_spi_probe(struct platform_device *pdev)
9418 if (!cs_bits) {
9419 dev_err(&pdev->dev, "Could not auto probe CS lines\n");
9420 ret = -EINVAL;
9421 - goto put_master;
9422 + goto disable_clk;
9423 }
9424
9425 num_cs = ilog2(cs_bits) + 1;
9426 if (num_cs > SIFIVE_SPI_MAX_CS) {
9427 dev_err(&pdev->dev, "Invalid number of spi slaves\n");
9428 ret = -EINVAL;
9429 - goto put_master;
9430 + goto disable_clk;
9431 }
9432
9433 /* Define our master */
9434 @@ -393,7 +393,7 @@ static int sifive_spi_probe(struct platform_device *pdev)
9435 dev_name(&pdev->dev), spi);
9436 if (ret) {
9437 dev_err(&pdev->dev, "Unable to bind to interrupt\n");
9438 - goto put_master;
9439 + goto disable_clk;
9440 }
9441
9442 dev_info(&pdev->dev, "mapped; irq=%d, cs=%d\n",
9443 @@ -402,11 +402,13 @@ static int sifive_spi_probe(struct platform_device *pdev)
9444 ret = devm_spi_register_master(&pdev->dev, master);
9445 if (ret < 0) {
9446 dev_err(&pdev->dev, "spi_register_master failed\n");
9447 - goto put_master;
9448 + goto disable_clk;
9449 }
9450
9451 return 0;
9452
9453 +disable_clk:
9454 + clk_disable_unprepare(spi->clk);
9455 put_master:
9456 spi_master_put(master);
9457
9458 @@ -420,6 +422,7 @@ static int sifive_spi_remove(struct platform_device *pdev)
9459
9460 /* Disable all the interrupts just in case */
9461 sifive_spi_write(spi, SIFIVE_SPI_REG_IE, 0);
9462 + clk_disable_unprepare(spi->clk);
9463
9464 return 0;
9465 }
9466 diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c
9467 index 9a051286f120..9613cfe3c0a2 100644
9468 --- a/drivers/spi/spi-sprd-adi.c
9469 +++ b/drivers/spi/spi-sprd-adi.c
9470 @@ -393,6 +393,9 @@ static int sprd_adi_restart_handler(struct notifier_block *this,
9471 val |= BIT_WDG_RUN | BIT_WDG_RST;
9472 sprd_adi_write(sadi, sadi->slave_pbase + REG_WDG_CTRL, val);
9473
9474 + /* Lock the watchdog */
9475 + sprd_adi_write(sadi, sadi->slave_pbase + REG_WDG_LOCK, ~WDG_UNLOCK_KEY);
9476 +
9477 mdelay(1000);
9478
9479 dev_emerg(sadi->dev, "Unable to restart system\n");
9480 diff --git a/drivers/spi/spi-st-ssc4.c b/drivers/spi/spi-st-ssc4.c
9481 index 0c24c494f386..77d26d64541a 100644
9482 --- a/drivers/spi/spi-st-ssc4.c
9483 +++ b/drivers/spi/spi-st-ssc4.c
9484 @@ -381,6 +381,7 @@ static int spi_st_probe(struct platform_device *pdev)
9485 return 0;
9486
9487 clk_disable:
9488 + pm_runtime_disable(&pdev->dev);
9489 clk_disable_unprepare(spi_st->clk);
9490 put_master:
9491 spi_master_put(master);
9492 @@ -392,6 +393,8 @@ static int spi_st_remove(struct platform_device *pdev)
9493 struct spi_master *master = platform_get_drvdata(pdev);
9494 struct spi_st *spi_st = spi_master_get_devdata(master);
9495
9496 + pm_runtime_disable(&pdev->dev);
9497 +
9498 clk_disable_unprepare(spi_st->clk);
9499
9500 pinctrl_pm_select_sleep_state(&pdev->dev);
9501 diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
9502 index 111fffc91435..374a2a32edcd 100644
9503 --- a/drivers/spi/spi-tegra20-slink.c
9504 +++ b/drivers/spi/spi-tegra20-slink.c
9505 @@ -1073,7 +1073,7 @@ static int tegra_slink_probe(struct platform_device *pdev)
9506 ret = clk_enable(tspi->clk);
9507 if (ret < 0) {
9508 dev_err(&pdev->dev, "Clock enable failed %d\n", ret);
9509 - goto exit_free_master;
9510 + goto exit_clk_unprepare;
9511 }
9512
9513 spi_irq = platform_get_irq(pdev, 0);
9514 @@ -1146,6 +1146,8 @@ exit_free_irq:
9515 free_irq(spi_irq, tspi);
9516 exit_clk_disable:
9517 clk_disable(tspi->clk);
9518 +exit_clk_unprepare:
9519 + clk_unprepare(tspi->clk);
9520 exit_free_master:
9521 spi_master_put(master);
9522 return ret;
9523 @@ -1159,6 +1161,7 @@ static int tegra_slink_remove(struct platform_device *pdev)
9524 free_irq(tspi->irq, tspi);
9525
9526 clk_disable(tspi->clk);
9527 + clk_unprepare(tspi->clk);
9528
9529 if (tspi->tx_dma_chan)
9530 tegra_slink_deinit_dma_param(tspi, false);
9531 diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
9532 index 255786f2e844..3ea9d8a3e6e8 100644
9533 --- a/drivers/spi/spidev.c
9534 +++ b/drivers/spi/spidev.c
9535 @@ -627,6 +627,9 @@ static int spidev_release(struct inode *inode, struct file *filp)
9536 if (dofree)
9537 kfree(spidev);
9538 }
9539 +#ifdef CONFIG_SPI_SLAVE
9540 + spi_slave_abort(spidev->spi);
9541 +#endif
9542 mutex_unlock(&device_list_lock);
9543
9544 return 0;
9545 diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c
9546 index 4bdf44d82879..dc62db1ee1dd 100644
9547 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c
9548 +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c
9549 @@ -623,6 +623,11 @@ static int gsc_hpdi_auto_attach(struct comedi_device *dev,
9550 dma_alloc_coherent(&pcidev->dev, DMA_BUFFER_SIZE,
9551 &devpriv->dio_buffer_phys_addr[i],
9552 GFP_KERNEL);
9553 + if (!devpriv->dio_buffer[i]) {
9554 + dev_warn(dev->class_dev,
9555 + "failed to allocate DMA buffer\n");
9556 + return -ENOMEM;
9557 + }
9558 }
9559 /* allocate dma descriptors */
9560 devpriv->dma_desc = dma_alloc_coherent(&pcidev->dev,
9561 @@ -630,6 +635,11 @@ static int gsc_hpdi_auto_attach(struct comedi_device *dev,
9562 NUM_DMA_DESCRIPTORS,
9563 &devpriv->dma_desc_phys_addr,
9564 GFP_KERNEL);
9565 + if (!devpriv->dma_desc) {
9566 + dev_warn(dev->class_dev,
9567 + "failed to allocate DMA descriptors\n");
9568 + return -ENOMEM;
9569 + }
9570 if (devpriv->dma_desc_phys_addr & 0xf) {
9571 dev_warn(dev->class_dev,
9572 " dma descriptors not quad-word aligned (bug)\n");
9573 diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
9574 index a0a67aa517f0..61f0286fb157 100644
9575 --- a/drivers/staging/fbtft/fbtft-core.c
9576 +++ b/drivers/staging/fbtft/fbtft-core.c
9577 @@ -666,7 +666,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
9578 fbdefio->deferred_io = fbtft_deferred_io;
9579 fb_deferred_io_init(info);
9580
9581 - strncpy(info->fix.id, dev->driver->name, 16);
9582 + snprintf(info->fix.id, sizeof(info->fix.id), "%s", dev->driver->name);
9583 info->fix.type = FB_TYPE_PACKED_PIXELS;
9584 info->fix.visual = FB_VISUAL_TRUECOLOR;
9585 info->fix.xpanstep = 0;
9586 diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
9587 index 038d6732c3fd..23026978a5a5 100644
9588 --- a/drivers/staging/iio/frequency/ad9834.c
9589 +++ b/drivers/staging/iio/frequency/ad9834.c
9590 @@ -417,6 +417,10 @@ static int ad9834_probe(struct spi_device *spi)
9591 st = iio_priv(indio_dev);
9592 mutex_init(&st->lock);
9593 st->mclk = devm_clk_get(&spi->dev, NULL);
9594 + if (IS_ERR(st->mclk)) {
9595 + ret = PTR_ERR(st->mclk);
9596 + goto error_disable_reg;
9597 + }
9598
9599 ret = clk_prepare_enable(st->mclk);
9600 if (ret) {
9601 diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
9602 index b33a07bc9105..46576e32581f 100644
9603 --- a/drivers/staging/media/imx/imx-media-capture.c
9604 +++ b/drivers/staging/media/imx/imx-media-capture.c
9605 @@ -26,6 +26,8 @@
9606 #include <media/imx.h>
9607 #include "imx-media.h"
9608
9609 +#define IMX_CAPTURE_NAME "imx-capture"
9610 +
9611 struct capture_priv {
9612 struct imx_media_video_dev vdev;
9613
9614 @@ -69,8 +71,8 @@ static int vidioc_querycap(struct file *file, void *fh,
9615 {
9616 struct capture_priv *priv = video_drvdata(file);
9617
9618 - strscpy(cap->driver, "imx-media-capture", sizeof(cap->driver));
9619 - strscpy(cap->card, "imx-media-capture", sizeof(cap->card));
9620 + strscpy(cap->driver, IMX_CAPTURE_NAME, sizeof(cap->driver));
9621 + strscpy(cap->card, IMX_CAPTURE_NAME, sizeof(cap->card));
9622 snprintf(cap->bus_info, sizeof(cap->bus_info),
9623 "platform:%s", priv->src_sd->name);
9624
9625 diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
9626 index 73d8354e618c..e50b1f88e25b 100644
9627 --- a/drivers/staging/media/imx/imx7-mipi-csis.c
9628 +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
9629 @@ -350,6 +350,8 @@ static void mipi_csis_sw_reset(struct csi_state *state)
9630 static int mipi_csis_phy_init(struct csi_state *state)
9631 {
9632 state->mipi_phy_regulator = devm_regulator_get(state->dev, "phy");
9633 + if (IS_ERR(state->mipi_phy_regulator))
9634 + return PTR_ERR(state->mipi_phy_regulator);
9635
9636 return regulator_set_voltage(state->mipi_phy_regulator, 1000000,
9637 1000000);
9638 @@ -966,7 +968,10 @@ static int mipi_csis_probe(struct platform_device *pdev)
9639 return ret;
9640 }
9641
9642 - mipi_csis_phy_init(state);
9643 + ret = mipi_csis_phy_init(state);
9644 + if (ret < 0)
9645 + return ret;
9646 +
9647 mipi_csis_phy_reset(state);
9648
9649 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
9650 diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
9651 index 2d3ea8b74dfd..3439f6ad6338 100644
9652 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c
9653 +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
9654 @@ -357,6 +357,8 @@ static int cedrus_probe(struct platform_device *pdev)
9655
9656 dev->mdev.dev = &pdev->dev;
9657 strscpy(dev->mdev.model, CEDRUS_NAME, sizeof(dev->mdev.model));
9658 + strscpy(dev->mdev.bus_info, "platform:" CEDRUS_NAME,
9659 + sizeof(dev->mdev.bus_info));
9660
9661 media_device_init(&dev->mdev);
9662 dev->mdev.ops = &cedrus_m2m_media_ops;
9663 diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h
9664 index 2f017a651848..3758a1c4e2d0 100644
9665 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h
9666 +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h
9667 @@ -179,12 +179,16 @@ static inline dma_addr_t cedrus_buf_addr(struct vb2_buffer *buf,
9668 static inline dma_addr_t cedrus_dst_buf_addr(struct cedrus_ctx *ctx,
9669 int index, unsigned int plane)
9670 {
9671 - struct vb2_buffer *buf;
9672 + struct vb2_buffer *buf = NULL;
9673 + struct vb2_queue *vq;
9674
9675 if (index < 0)
9676 return 0;
9677
9678 - buf = ctx->fh.m2m_ctx->cap_q_ctx.q.bufs[index];
9679 + vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
9680 + if (vq)
9681 + buf = vb2_get_buffer(vq, index);
9682 +
9683 return buf ? cedrus_buf_addr(buf, &ctx->dst_fmt, plane) : 0;
9684 }
9685
9686 diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
9687 index d6a782703c9b..08c6c9c410cc 100644
9688 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
9689 +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
9690 @@ -96,7 +96,7 @@ static void cedrus_write_frame_list(struct cedrus_ctx *ctx,
9691 const struct v4l2_ctrl_h264_decode_params *decode = run->h264.decode_params;
9692 const struct v4l2_ctrl_h264_slice_params *slice = run->h264.slice_params;
9693 const struct v4l2_ctrl_h264_sps *sps = run->h264.sps;
9694 - struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q;
9695 + struct vb2_queue *cap_q;
9696 struct cedrus_buffer *output_buf;
9697 struct cedrus_dev *dev = ctx->dev;
9698 unsigned long used_dpbs = 0;
9699 @@ -104,6 +104,8 @@ static void cedrus_write_frame_list(struct cedrus_ctx *ctx,
9700 unsigned int output = 0;
9701 unsigned int i;
9702
9703 + cap_q = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
9704 +
9705 memset(pic_list, 0, sizeof(pic_list));
9706
9707 for (i = 0; i < ARRAY_SIZE(decode->dpb); i++) {
9708 @@ -167,12 +169,14 @@ static void _cedrus_write_ref_list(struct cedrus_ctx *ctx,
9709 enum cedrus_h264_sram_off sram)
9710 {
9711 const struct v4l2_ctrl_h264_decode_params *decode = run->h264.decode_params;
9712 - struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q;
9713 + struct vb2_queue *cap_q;
9714 struct cedrus_dev *dev = ctx->dev;
9715 u8 sram_array[CEDRUS_MAX_REF_IDX];
9716 unsigned int i;
9717 size_t size;
9718
9719 + cap_q = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
9720 +
9721 memset(sram_array, 0, sizeof(sram_array));
9722
9723 for (i = 0; i < num_ref; i++) {
9724 diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_regs.h b/drivers/staging/media/sunxi/cedrus/cedrus_regs.h
9725 index ddd29788d685..f9dd8cbf3458 100644
9726 --- a/drivers/staging/media/sunxi/cedrus/cedrus_regs.h
9727 +++ b/drivers/staging/media/sunxi/cedrus/cedrus_regs.h
9728 @@ -10,6 +10,9 @@
9729 #ifndef _CEDRUS_REGS_H_
9730 #define _CEDRUS_REGS_H_
9731
9732 +#define SHIFT_AND_MASK_BITS(v, h, l) \
9733 + (((unsigned long)(v) << (l)) & GENMASK(h, l))
9734 +
9735 /*
9736 * Common acronyms and contractions used in register descriptions:
9737 * * VLD : Variable-Length Decoder
9738 @@ -37,8 +40,8 @@
9739 #define VE_PRIMARY_CHROMA_BUF_LEN 0xc4
9740 #define VE_PRIMARY_FB_LINE_STRIDE 0xc8
9741
9742 -#define VE_PRIMARY_FB_LINE_STRIDE_CHROMA(s) (((s) << 16) & GENMASK(31, 16))
9743 -#define VE_PRIMARY_FB_LINE_STRIDE_LUMA(s) (((s) << 0) & GENMASK(15, 0))
9744 +#define VE_PRIMARY_FB_LINE_STRIDE_CHROMA(s) SHIFT_AND_MASK_BITS(s, 31, 16)
9745 +#define VE_PRIMARY_FB_LINE_STRIDE_LUMA(s) SHIFT_AND_MASK_BITS(s, 15, 0)
9746
9747 #define VE_CHROMA_BUF_LEN 0xe8
9748
9749 @@ -46,7 +49,7 @@
9750 #define VE_SECONDARY_OUT_FMT_EXT (0x01 << 30)
9751 #define VE_SECONDARY_OUT_FMT_YU12 (0x02 << 30)
9752 #define VE_SECONDARY_OUT_FMT_YV12 (0x03 << 30)
9753 -#define VE_CHROMA_BUF_LEN_SDRT(l) ((l) & GENMASK(27, 0))
9754 +#define VE_CHROMA_BUF_LEN_SDRT(l) SHIFT_AND_MASK_BITS(l, 27, 0)
9755
9756 #define VE_PRIMARY_OUT_FMT 0xec
9757
9758 @@ -69,15 +72,15 @@
9759
9760 #define VE_DEC_MPEG_MP12HDR (VE_ENGINE_DEC_MPEG + 0x00)
9761
9762 -#define VE_DEC_MPEG_MP12HDR_SLICE_TYPE(t) (((t) << 28) & GENMASK(30, 28))
9763 +#define VE_DEC_MPEG_MP12HDR_SLICE_TYPE(t) SHIFT_AND_MASK_BITS(t, 30, 28)
9764 #define VE_DEC_MPEG_MP12HDR_F_CODE_SHIFT(x, y) (24 - 4 * (y) - 8 * (x))
9765 #define VE_DEC_MPEG_MP12HDR_F_CODE(__x, __y, __v) \
9766 - (((__v) & GENMASK(3, 0)) << VE_DEC_MPEG_MP12HDR_F_CODE_SHIFT(__x, __y))
9767 + (((unsigned long)(__v) & GENMASK(3, 0)) << VE_DEC_MPEG_MP12HDR_F_CODE_SHIFT(__x, __y))
9768
9769 #define VE_DEC_MPEG_MP12HDR_INTRA_DC_PRECISION(p) \
9770 - (((p) << 10) & GENMASK(11, 10))
9771 + SHIFT_AND_MASK_BITS(p, 11, 10)
9772 #define VE_DEC_MPEG_MP12HDR_INTRA_PICTURE_STRUCTURE(s) \
9773 - (((s) << 8) & GENMASK(9, 8))
9774 + SHIFT_AND_MASK_BITS(s, 9, 8)
9775 #define VE_DEC_MPEG_MP12HDR_TOP_FIELD_FIRST(v) \
9776 ((v) ? BIT(7) : 0)
9777 #define VE_DEC_MPEG_MP12HDR_FRAME_PRED_FRAME_DCT(v) \
9778 @@ -98,19 +101,19 @@
9779 #define VE_DEC_MPEG_PICCODEDSIZE (VE_ENGINE_DEC_MPEG + 0x08)
9780
9781 #define VE_DEC_MPEG_PICCODEDSIZE_WIDTH(w) \
9782 - ((DIV_ROUND_UP((w), 16) << 8) & GENMASK(15, 8))
9783 + SHIFT_AND_MASK_BITS(DIV_ROUND_UP((w), 16), 15, 8)
9784 #define VE_DEC_MPEG_PICCODEDSIZE_HEIGHT(h) \
9785 - ((DIV_ROUND_UP((h), 16) << 0) & GENMASK(7, 0))
9786 + SHIFT_AND_MASK_BITS(DIV_ROUND_UP((h), 16), 7, 0)
9787
9788 #define VE_DEC_MPEG_PICBOUNDSIZE (VE_ENGINE_DEC_MPEG + 0x0c)
9789
9790 -#define VE_DEC_MPEG_PICBOUNDSIZE_WIDTH(w) (((w) << 16) & GENMASK(27, 16))
9791 -#define VE_DEC_MPEG_PICBOUNDSIZE_HEIGHT(h) (((h) << 0) & GENMASK(11, 0))
9792 +#define VE_DEC_MPEG_PICBOUNDSIZE_WIDTH(w) SHIFT_AND_MASK_BITS(w, 27, 16)
9793 +#define VE_DEC_MPEG_PICBOUNDSIZE_HEIGHT(h) SHIFT_AND_MASK_BITS(h, 11, 0)
9794
9795 #define VE_DEC_MPEG_MBADDR (VE_ENGINE_DEC_MPEG + 0x10)
9796
9797 -#define VE_DEC_MPEG_MBADDR_X(w) (((w) << 8) & GENMASK(15, 8))
9798 -#define VE_DEC_MPEG_MBADDR_Y(h) (((h) << 0) & GENMASK(7, 0))
9799 +#define VE_DEC_MPEG_MBADDR_X(w) SHIFT_AND_MASK_BITS(w, 15, 8)
9800 +#define VE_DEC_MPEG_MBADDR_Y(h) SHIFT_AND_MASK_BITS(h, 7, 0)
9801
9802 #define VE_DEC_MPEG_CTRL (VE_ENGINE_DEC_MPEG + 0x14)
9803
9804 @@ -225,7 +228,7 @@
9805 #define VE_DEC_MPEG_IQMINPUT_FLAG_INTRA (0x01 << 14)
9806 #define VE_DEC_MPEG_IQMINPUT_FLAG_NON_INTRA (0x00 << 14)
9807 #define VE_DEC_MPEG_IQMINPUT_WEIGHT(i, v) \
9808 - (((v) & GENMASK(7, 0)) | (((i) << 8) & GENMASK(13, 8)))
9809 + (SHIFT_AND_MASK_BITS(i, 13, 8) | SHIFT_AND_MASK_BITS(v, 7, 0))
9810
9811 #define VE_DEC_MPEG_ERROR (VE_ENGINE_DEC_MPEG + 0xc4)
9812 #define VE_DEC_MPEG_CRTMBADDR (VE_ENGINE_DEC_MPEG + 0xc8)
9813 diff --git a/drivers/staging/mt7621-pci/Kconfig b/drivers/staging/mt7621-pci/Kconfig
9814 index af928b75a940..ce58042f2f21 100644
9815 --- a/drivers/staging/mt7621-pci/Kconfig
9816 +++ b/drivers/staging/mt7621-pci/Kconfig
9817 @@ -2,7 +2,6 @@
9818 config PCI_MT7621
9819 tristate "MediaTek MT7621 PCI Controller"
9820 depends on RALINK
9821 - depends on PCI
9822 select PCI_DRIVERS_GENERIC
9823 help
9824 This selects a driver for the MediaTek MT7621 PCI Controller.
9825 diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
9826 index 952f2ab51347..c37591657bac 100644
9827 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
9828 +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
9829 @@ -776,7 +776,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
9830 memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN);
9831 memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN);
9832
9833 - if (psta->qos_option)
9834 + if (psta && psta->qos_option)
9835 qos_option = true;
9836 } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
9837 check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
9838 @@ -784,7 +784,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
9839 memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
9840 memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN);
9841
9842 - if (psta->qos_option)
9843 + if (psta && psta->qos_option)
9844 qos_option = true;
9845 } else {
9846 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv)));
9847 diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
9848 index 2821411878ce..511136dce3a4 100644
9849 --- a/drivers/staging/rtl8192u/r8192U_core.c
9850 +++ b/drivers/staging/rtl8192u/r8192U_core.c
9851 @@ -1422,7 +1422,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
9852 (struct tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
9853 struct usb_device *udev = priv->udev;
9854 int pend;
9855 - int status;
9856 + int status, rt = -1;
9857 struct urb *tx_urb = NULL, *tx_urb_zero = NULL;
9858 unsigned int idx_pipe;
9859
9860 @@ -1566,8 +1566,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
9861 }
9862 if (bSend0Byte) {
9863 tx_urb_zero = usb_alloc_urb(0, GFP_ATOMIC);
9864 - if (!tx_urb_zero)
9865 - return -ENOMEM;
9866 + if (!tx_urb_zero) {
9867 + rt = -ENOMEM;
9868 + goto error;
9869 + }
9870 usb_fill_bulk_urb(tx_urb_zero, udev,
9871 usb_sndbulkpipe(udev, idx_pipe),
9872 &zero, 0, tx_zero_isr, dev);
9873 @@ -1577,7 +1579,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
9874 "Error TX URB for zero byte %d, error %d",
9875 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
9876 status);
9877 - return -1;
9878 + goto error;
9879 }
9880 }
9881 netif_trans_update(dev);
9882 @@ -1588,7 +1590,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
9883 RT_TRACE(COMP_ERR, "Error TX URB %d, error %d",
9884 atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
9885 status);
9886 - return -1;
9887 +
9888 +error:
9889 + dev_kfree_skb_any(skb);
9890 + usb_free_urb(tx_urb);
9891 + usb_free_urb(tx_urb_zero);
9892 + return rt;
9893 }
9894
9895 static short rtl8192_usb_initendpoints(struct net_device *dev)
9896 diff --git a/drivers/staging/wilc1000/wilc_hif.c b/drivers/staging/wilc1000/wilc_hif.c
9897 index d3d9ea284816..77d0732f451b 100644
9898 --- a/drivers/staging/wilc1000/wilc_hif.c
9899 +++ b/drivers/staging/wilc1000/wilc_hif.c
9900 @@ -473,6 +473,8 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
9901 rates_ie = cfg80211_find_ie(WLAN_EID_SUPP_RATES, ies->data, ies->len);
9902 if (rates_ie) {
9903 rates_len = rates_ie[1];
9904 + if (rates_len > WILC_MAX_RATES_SUPPORTED)
9905 + rates_len = WILC_MAX_RATES_SUPPORTED;
9906 param->supp_rates[0] = rates_len;
9907 memcpy(&param->supp_rates[1], rates_ie + 2, rates_len);
9908 }
9909 diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
9910 index 22f21831649b..c3cd6f389a98 100644
9911 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
9912 +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
9913 @@ -1419,8 +1419,10 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
9914 if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE)
9915 wilc_wfi_deinit_mon_interface(wl, true);
9916 vif->iftype = WILC_STATION_MODE;
9917 - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif),
9918 - WILC_STATION_MODE, vif->idx);
9919 +
9920 + if (wl->initialized)
9921 + wilc_set_operation_mode(vif, wilc_get_vif_idx(vif),
9922 + WILC_STATION_MODE, vif->idx);
9923
9924 memset(priv->assoc_stainfo.sta_associated_bss, 0,
9925 WILC_MAX_NUM_STA * ETH_ALEN);
9926 @@ -1432,8 +1434,10 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
9927 priv->wdev.iftype = type;
9928 vif->monitor_flag = 0;
9929 vif->iftype = WILC_CLIENT_MODE;
9930 - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif),
9931 - WILC_STATION_MODE, vif->idx);
9932 +
9933 + if (wl->initialized)
9934 + wilc_set_operation_mode(vif, wilc_get_vif_idx(vif),
9935 + WILC_STATION_MODE, vif->idx);
9936 break;
9937
9938 case NL80211_IFTYPE_AP:
9939 @@ -1450,8 +1454,10 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
9940 dev->ieee80211_ptr->iftype = type;
9941 priv->wdev.iftype = type;
9942 vif->iftype = WILC_GO_MODE;
9943 - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif),
9944 - WILC_AP_MODE, vif->idx);
9945 +
9946 + if (wl->initialized)
9947 + wilc_set_operation_mode(vif, wilc_get_vif_idx(vif),
9948 + WILC_AP_MODE, vif->idx);
9949 break;
9950
9951 default:
9952 diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
9953 index a8dc8af83f39..1ba9bc667e13 100644
9954 --- a/drivers/tty/serial/atmel_serial.c
9955 +++ b/drivers/tty/serial/atmel_serial.c
9956 @@ -2270,27 +2270,6 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
9957 mode |= ATMEL_US_USMODE_NORMAL;
9958 }
9959
9960 - /* set the mode, clock divisor, parity, stop bits and data size */
9961 - atmel_uart_writel(port, ATMEL_US_MR, mode);
9962 -
9963 - /*
9964 - * when switching the mode, set the RTS line state according to the
9965 - * new mode, otherwise keep the former state
9966 - */
9967 - if ((old_mode & ATMEL_US_USMODE) != (mode & ATMEL_US_USMODE)) {
9968 - unsigned int rts_state;
9969 -
9970 - if ((mode & ATMEL_US_USMODE) == ATMEL_US_USMODE_HWHS) {
9971 - /* let the hardware control the RTS line */
9972 - rts_state = ATMEL_US_RTSDIS;
9973 - } else {
9974 - /* force RTS line to low level */
9975 - rts_state = ATMEL_US_RTSEN;
9976 - }
9977 -
9978 - atmel_uart_writel(port, ATMEL_US_CR, rts_state);
9979 - }
9980 -
9981 /*
9982 * Set the baud rate:
9983 * Fractional baudrate allows to setup output frequency more
9984 @@ -2317,6 +2296,28 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
9985
9986 if (!(port->iso7816.flags & SER_ISO7816_ENABLED))
9987 atmel_uart_writel(port, ATMEL_US_BRGR, quot);
9988 +
9989 + /* set the mode, clock divisor, parity, stop bits and data size */
9990 + atmel_uart_writel(port, ATMEL_US_MR, mode);
9991 +
9992 + /*
9993 + * when switching the mode, set the RTS line state according to the
9994 + * new mode, otherwise keep the former state
9995 + */
9996 + if ((old_mode & ATMEL_US_USMODE) != (mode & ATMEL_US_USMODE)) {
9997 + unsigned int rts_state;
9998 +
9999 + if ((mode & ATMEL_US_USMODE) == ATMEL_US_USMODE_HWHS) {
10000 + /* let the hardware control the RTS line */
10001 + rts_state = ATMEL_US_RTSDIS;
10002 + } else {
10003 + /* force RTS line to low level */
10004 + rts_state = ATMEL_US_RTSEN;
10005 + }
10006 +
10007 + atmel_uart_writel(port, ATMEL_US_CR, rts_state);
10008 + }
10009 +
10010 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
10011 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
10012 atmel_port->tx_stopped = false;
10013 diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
10014 index 771d11196523..494e2672ebd7 100644
10015 --- a/drivers/tty/serial/sprd_serial.c
10016 +++ b/drivers/tty/serial/sprd_serial.c
10017 @@ -679,6 +679,9 @@ static irqreturn_t sprd_handle_irq(int irq, void *dev_id)
10018 if (ims & SPRD_IMSR_TIMEOUT)
10019 serial_out(port, SPRD_ICLR, SPRD_ICLR_TIMEOUT);
10020
10021 + if (ims & SPRD_IMSR_BREAK_DETECT)
10022 + serial_out(port, SPRD_ICLR, SPRD_IMSR_BREAK_DETECT);
10023 +
10024 if (ims & (SPRD_IMSR_RX_FIFO_FULL | SPRD_IMSR_BREAK_DETECT |
10025 SPRD_IMSR_TIMEOUT))
10026 sprd_rx(port);
10027 diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
10028 index 3f899552f6e3..6ca40d135430 100644
10029 --- a/drivers/usb/core/devio.c
10030 +++ b/drivers/usb/core/devio.c
10031 @@ -764,8 +764,15 @@ static int claimintf(struct usb_dev_state *ps, unsigned int ifnum)
10032 intf = usb_ifnum_to_if(dev, ifnum);
10033 if (!intf)
10034 err = -ENOENT;
10035 - else
10036 + else {
10037 + unsigned int old_suppress;
10038 +
10039 + /* suppress uevents while claiming interface */
10040 + old_suppress = dev_get_uevent_suppress(&intf->dev);
10041 + dev_set_uevent_suppress(&intf->dev, 1);
10042 err = usb_driver_claim_interface(&usbfs_driver, intf, ps);
10043 + dev_set_uevent_suppress(&intf->dev, old_suppress);
10044 + }
10045 if (err == 0)
10046 set_bit(ifnum, &ps->ifclaimed);
10047 return err;
10048 @@ -785,7 +792,13 @@ static int releaseintf(struct usb_dev_state *ps, unsigned int ifnum)
10049 if (!intf)
10050 err = -ENOENT;
10051 else if (test_and_clear_bit(ifnum, &ps->ifclaimed)) {
10052 + unsigned int old_suppress;
10053 +
10054 + /* suppress uevents while releasing interface */
10055 + old_suppress = dev_get_uevent_suppress(&intf->dev);
10056 + dev_set_uevent_suppress(&intf->dev, 1);
10057 usb_driver_release_interface(&usbfs_driver, intf);
10058 + dev_set_uevent_suppress(&intf->dev, old_suppress);
10059 err = 0;
10060 }
10061 return err;
10062 diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
10063 index aa2f77f1506d..8a5c9b3ebe1e 100644
10064 --- a/drivers/usb/host/ehci-q.c
10065 +++ b/drivers/usb/host/ehci-q.c
10066 @@ -27,6 +27,10 @@
10067
10068 /*-------------------------------------------------------------------------*/
10069
10070 +/* PID Codes that are used here, from EHCI specification, Table 3-16. */
10071 +#define PID_CODE_IN 1
10072 +#define PID_CODE_SETUP 2
10073 +
10074 /* fill a qtd, returning how much of the buffer we were able to queue up */
10075
10076 static int
10077 @@ -190,7 +194,7 @@ static int qtd_copy_status (
10078 int status = -EINPROGRESS;
10079
10080 /* count IN/OUT bytes, not SETUP (even short packets) */
10081 - if (likely (QTD_PID (token) != 2))
10082 + if (likely(QTD_PID(token) != PID_CODE_SETUP))
10083 urb->actual_length += length - QTD_LENGTH (token);
10084
10085 /* don't modify error codes */
10086 @@ -206,6 +210,13 @@ static int qtd_copy_status (
10087 if (token & QTD_STS_BABBLE) {
10088 /* FIXME "must" disable babbling device's port too */
10089 status = -EOVERFLOW;
10090 + /*
10091 + * When MMF is active and PID Code is IN, queue is halted.
10092 + * EHCI Specification, Table 4-13.
10093 + */
10094 + } else if ((token & QTD_STS_MMF) &&
10095 + (QTD_PID(token) == PID_CODE_IN)) {
10096 + status = -EPROTO;
10097 /* CERR nonzero + halt --> stall */
10098 } else if (QTD_CERR(token)) {
10099 status = -EPIPE;
10100 diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
10101 index 1904ef56f61c..4917c5b033fa 100644
10102 --- a/drivers/usb/host/xhci-pci.c
10103 +++ b/drivers/usb/host/xhci-pci.c
10104 @@ -48,6 +48,7 @@
10105 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_XHCI 0x15e9
10106 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_XHCI 0x15ec
10107 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI 0x15f0
10108 +#define PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI 0x8a13
10109
10110 #define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9
10111 #define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba
10112 @@ -212,7 +213,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
10113 pdev->device == PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_XHCI ||
10114 pdev->device == PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_XHCI ||
10115 pdev->device == PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_XHCI ||
10116 - pdev->device == PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI))
10117 + pdev->device == PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI ||
10118 + pdev->device == PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI))
10119 xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW;
10120
10121 if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
10122 @@ -517,7 +519,6 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
10123 retval = xhci_resume(xhci, hibernated);
10124 return retval;
10125 }
10126 -#endif /* CONFIG_PM */
10127
10128 static void xhci_pci_shutdown(struct usb_hcd *hcd)
10129 {
10130 @@ -530,6 +531,7 @@ static void xhci_pci_shutdown(struct usb_hcd *hcd)
10131 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
10132 pci_set_power_state(pdev, PCI_D3hot);
10133 }
10134 +#endif /* CONFIG_PM */
10135
10136 /*-------------------------------------------------------------------------*/
10137
10138 diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
10139 index 0824099b905e..ef1735d014da 100644
10140 --- a/drivers/usb/renesas_usbhs/common.h
10141 +++ b/drivers/usb/renesas_usbhs/common.h
10142 @@ -161,11 +161,12 @@ struct usbhs_priv;
10143 #define VBSTS (1 << 7) /* VBUS_0 and VBUSIN_0 Input Status */
10144 #define VALID (1 << 3) /* USB Request Receive */
10145
10146 -#define DVSQ_MASK (0x3 << 4) /* Device State */
10147 +#define DVSQ_MASK (0x7 << 4) /* Device State */
10148 #define POWER_STATE (0 << 4)
10149 #define DEFAULT_STATE (1 << 4)
10150 #define ADDRESS_STATE (2 << 4)
10151 #define CONFIGURATION_STATE (3 << 4)
10152 +#define SUSPENDED_STATE (4 << 4)
10153
10154 #define CTSQ_MASK (0x7) /* Control Transfer Stage */
10155 #define IDLE_SETUP_STAGE 0 /* Idle stage or setup stage */
10156 diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
10157 index cd38d74b3223..53489cafecc1 100644
10158 --- a/drivers/usb/renesas_usbhs/mod_gadget.c
10159 +++ b/drivers/usb/renesas_usbhs/mod_gadget.c
10160 @@ -457,12 +457,18 @@ static int usbhsg_irq_dev_state(struct usbhs_priv *priv,
10161 {
10162 struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
10163 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
10164 + int state = usbhs_status_get_device_state(irq_state);
10165
10166 gpriv->gadget.speed = usbhs_bus_get_speed(priv);
10167
10168 - dev_dbg(dev, "state = %x : speed : %d\n",
10169 - usbhs_status_get_device_state(irq_state),
10170 - gpriv->gadget.speed);
10171 + dev_dbg(dev, "state = %x : speed : %d\n", state, gpriv->gadget.speed);
10172 +
10173 + if (gpriv->gadget.speed != USB_SPEED_UNKNOWN &&
10174 + (state & SUSPENDED_STATE)) {
10175 + if (gpriv->driver && gpriv->driver->suspend)
10176 + gpriv->driver->suspend(&gpriv->gadget);
10177 + usb_gadget_set_state(&gpriv->gadget, USB_STATE_SUSPENDED);
10178 + }
10179
10180 return 0;
10181 }
10182 diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
10183 index 6532d68e8808..e4b96674c405 100644
10184 --- a/drivers/usb/usbip/usbip_common.c
10185 +++ b/drivers/usb/usbip/usbip_common.c
10186 @@ -727,6 +727,9 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb)
10187
10188 copy -= recv;
10189 ret += recv;
10190 +
10191 + if (!copy)
10192 + break;
10193 }
10194
10195 if (ret != size)
10196 diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
10197 index 33f8972ba842..00fc98741c5d 100644
10198 --- a/drivers/usb/usbip/vhci_rx.c
10199 +++ b/drivers/usb/usbip/vhci_rx.c
10200 @@ -77,16 +77,21 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
10201 usbip_pack_pdu(pdu, urb, USBIP_RET_SUBMIT, 0);
10202
10203 /* recv transfer buffer */
10204 - if (usbip_recv_xbuff(ud, urb) < 0)
10205 - return;
10206 + if (usbip_recv_xbuff(ud, urb) < 0) {
10207 + urb->status = -EPROTO;
10208 + goto error;
10209 + }
10210
10211 /* recv iso_packet_descriptor */
10212 - if (usbip_recv_iso(ud, urb) < 0)
10213 - return;
10214 + if (usbip_recv_iso(ud, urb) < 0) {
10215 + urb->status = -EPROTO;
10216 + goto error;
10217 + }
10218
10219 /* restore the padding in iso packets */
10220 usbip_pad_iso(ud, urb);
10221
10222 +error:
10223 if (usbip_dbg_flag_vhci_rx)
10224 usbip_dump_urb(urb);
10225
10226 diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
10227 index 79cc75096f42..a50dadd01093 100644
10228 --- a/drivers/xen/Kconfig
10229 +++ b/drivers/xen/Kconfig
10230 @@ -141,7 +141,8 @@ config XEN_GNTDEV
10231
10232 config XEN_GNTDEV_DMABUF
10233 bool "Add support for dma-buf grant access device driver extension"
10234 - depends on XEN_GNTDEV && XEN_GRANT_DMA_ALLOC && DMA_SHARED_BUFFER
10235 + depends on XEN_GNTDEV && XEN_GRANT_DMA_ALLOC
10236 + select DMA_SHARED_BUFFER
10237 help
10238 Allows userspace processes and kernel modules to use Xen backed
10239 dma-buf implementation. With this extension grant references to
10240 diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
10241 index 2e9e13ffbd08..10a04b99798a 100644
10242 --- a/fs/btrfs/async-thread.c
10243 +++ b/fs/btrfs/async-thread.c
10244 @@ -252,16 +252,17 @@ out:
10245 }
10246 }
10247
10248 -static void run_ordered_work(struct __btrfs_workqueue *wq)
10249 +static void run_ordered_work(struct __btrfs_workqueue *wq,
10250 + struct btrfs_work *self)
10251 {
10252 struct list_head *list = &wq->ordered_list;
10253 struct btrfs_work *work;
10254 spinlock_t *lock = &wq->list_lock;
10255 unsigned long flags;
10256 + void *wtag;
10257 + bool free_self = false;
10258
10259 while (1) {
10260 - void *wtag;
10261 -
10262 spin_lock_irqsave(lock, flags);
10263 if (list_empty(list))
10264 break;
10265 @@ -287,16 +288,47 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
10266 list_del(&work->ordered_list);
10267 spin_unlock_irqrestore(lock, flags);
10268
10269 - /*
10270 - * We don't want to call the ordered free functions with the
10271 - * lock held though. Save the work as tag for the trace event,
10272 - * because the callback could free the structure.
10273 - */
10274 - wtag = work;
10275 - work->ordered_free(work);
10276 - trace_btrfs_all_work_done(wq->fs_info, wtag);
10277 + if (work == self) {
10278 + /*
10279 + * This is the work item that the worker is currently
10280 + * executing.
10281 + *
10282 + * The kernel workqueue code guarantees non-reentrancy
10283 + * of work items. I.e., if a work item with the same
10284 + * address and work function is queued twice, the second
10285 + * execution is blocked until the first one finishes. A
10286 + * work item may be freed and recycled with the same
10287 + * work function; the workqueue code assumes that the
10288 + * original work item cannot depend on the recycled work
10289 + * item in that case (see find_worker_executing_work()).
10290 + *
10291 + * Note that the work of one Btrfs filesystem may depend
10292 + * on the work of another Btrfs filesystem via, e.g., a
10293 + * loop device. Therefore, we must not allow the current
10294 + * work item to be recycled until we are really done,
10295 + * otherwise we break the above assumption and can
10296 + * deadlock.
10297 + */
10298 + free_self = true;
10299 + } else {
10300 + /*
10301 + * We don't want to call the ordered free functions with
10302 + * the lock held though. Save the work as tag for the
10303 + * trace event, because the callback could free the
10304 + * structure.
10305 + */
10306 + wtag = work;
10307 + work->ordered_free(work);
10308 + trace_btrfs_all_work_done(wq->fs_info, wtag);
10309 + }
10310 }
10311 spin_unlock_irqrestore(lock, flags);
10312 +
10313 + if (free_self) {
10314 + wtag = self;
10315 + self->ordered_free(self);
10316 + trace_btrfs_all_work_done(wq->fs_info, wtag);
10317 + }
10318 }
10319
10320 static void normal_work_helper(struct btrfs_work *work)
10321 @@ -324,7 +356,7 @@ static void normal_work_helper(struct btrfs_work *work)
10322 work->func(work);
10323 if (need_order) {
10324 set_bit(WORK_DONE_BIT, &work->flags);
10325 - run_ordered_work(wq);
10326 + run_ordered_work(wq, work);
10327 }
10328 if (!need_order)
10329 trace_btrfs_all_work_done(wq->fs_info, wtag);
10330 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
10331 index e59cde204b2f..da9b0f060a9d 100644
10332 --- a/fs/btrfs/ctree.c
10333 +++ b/fs/btrfs/ctree.c
10334 @@ -383,7 +383,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
10335 for (node = rb_first(tm_root); node; node = next) {
10336 next = rb_next(node);
10337 tm = rb_entry(node, struct tree_mod_elem, node);
10338 - if (tm->seq > min_seq)
10339 + if (tm->seq >= min_seq)
10340 continue;
10341 rb_erase(node, tm_root);
10342 kfree(tm);
10343 diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
10344 index fe2b8765d9e6..5e9f80b28fcf 100644
10345 --- a/fs/btrfs/ctree.h
10346 +++ b/fs/btrfs/ctree.h
10347 @@ -2785,7 +2785,7 @@ struct btrfs_inode_extref *btrfs_find_name_in_ext_backref(
10348 /* file-item.c */
10349 struct btrfs_dio_private;
10350 int btrfs_del_csums(struct btrfs_trans_handle *trans,
10351 - struct btrfs_fs_info *fs_info, u64 bytenr, u64 len);
10352 + struct btrfs_root *root, u64 bytenr, u64 len);
10353 blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
10354 u8 *dst);
10355 blk_status_t btrfs_lookup_bio_sums_dio(struct inode *inode, struct bio *bio,
10356 diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
10357 index 402b61bf345c..3895c21853cc 100644
10358 --- a/fs/btrfs/disk-io.c
10359 +++ b/fs/btrfs/disk-io.c
10360 @@ -1657,8 +1657,8 @@ static void end_workqueue_fn(struct btrfs_work *work)
10361 bio->bi_status = end_io_wq->status;
10362 bio->bi_private = end_io_wq->private;
10363 bio->bi_end_io = end_io_wq->end_io;
10364 - kmem_cache_free(btrfs_end_io_wq_cache, end_io_wq);
10365 bio_endio(bio);
10366 + kmem_cache_free(btrfs_end_io_wq_cache, end_io_wq);
10367 }
10368
10369 static int cleaner_kthread(void *arg)
10370 diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
10371 index 49cb26fa7c63..eb95ed78a18e 100644
10372 --- a/fs/btrfs/extent-tree.c
10373 +++ b/fs/btrfs/extent-tree.c
10374 @@ -1848,8 +1848,8 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans,
10375 btrfs_pin_extent(fs_info, head->bytenr,
10376 head->num_bytes, 1);
10377 if (head->is_data) {
10378 - ret = btrfs_del_csums(trans, fs_info, head->bytenr,
10379 - head->num_bytes);
10380 + ret = btrfs_del_csums(trans, fs_info->csum_root,
10381 + head->bytenr, head->num_bytes);
10382 }
10383 }
10384
10385 @@ -3155,7 +3155,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
10386 btrfs_release_path(path);
10387
10388 if (is_data) {
10389 - ret = btrfs_del_csums(trans, info, bytenr, num_bytes);
10390 + ret = btrfs_del_csums(trans, info->csum_root, bytenr,
10391 + num_bytes);
10392 if (ret) {
10393 btrfs_abort_transaction(trans, ret);
10394 goto out;
10395 diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
10396 index 4905f48587df..be9dc78aa727 100644
10397 --- a/fs/btrfs/extent_io.c
10398 +++ b/fs/btrfs/extent_io.c
10399 @@ -5066,12 +5066,14 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
10400 return eb;
10401 eb = alloc_dummy_extent_buffer(fs_info, start);
10402 if (!eb)
10403 - return NULL;
10404 + return ERR_PTR(-ENOMEM);
10405 eb->fs_info = fs_info;
10406 again:
10407 ret = radix_tree_preload(GFP_NOFS);
10408 - if (ret)
10409 + if (ret) {
10410 + exists = ERR_PTR(ret);
10411 goto free_eb;
10412 + }
10413 spin_lock(&fs_info->buffer_lock);
10414 ret = radix_tree_insert(&fs_info->buffer_radix,
10415 start >> PAGE_SHIFT, eb);
10416 diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
10417 index 1a599f50837b..c878bc25d046 100644
10418 --- a/fs/btrfs/file-item.c
10419 +++ b/fs/btrfs/file-item.c
10420 @@ -590,9 +590,9 @@ static noinline void truncate_one_csum(struct btrfs_fs_info *fs_info,
10421 * range of bytes.
10422 */
10423 int btrfs_del_csums(struct btrfs_trans_handle *trans,
10424 - struct btrfs_fs_info *fs_info, u64 bytenr, u64 len)
10425 + struct btrfs_root *root, u64 bytenr, u64 len)
10426 {
10427 - struct btrfs_root *root = fs_info->csum_root;
10428 + struct btrfs_fs_info *fs_info = trans->fs_info;
10429 struct btrfs_path *path;
10430 struct btrfs_key key;
10431 u64 end_byte = bytenr + len;
10432 @@ -602,6 +602,9 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
10433 u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);
10434 int blocksize_bits = fs_info->sb->s_blocksize_bits;
10435
10436 + ASSERT(root == fs_info->csum_root ||
10437 + root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID);
10438 +
10439 path = btrfs_alloc_path();
10440 if (!path)
10441 return -ENOMEM;
10442 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
10443 index 10a01dd0c4e6..e5758f62e8d8 100644
10444 --- a/fs/btrfs/inode.c
10445 +++ b/fs/btrfs/inode.c
10446 @@ -5697,7 +5697,6 @@ static void inode_tree_add(struct inode *inode)
10447
10448 static void inode_tree_del(struct inode *inode)
10449 {
10450 - struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
10451 struct btrfs_root *root = BTRFS_I(inode)->root;
10452 int empty = 0;
10453
10454 @@ -5710,7 +5709,6 @@ static void inode_tree_del(struct inode *inode)
10455 spin_unlock(&root->inode_lock);
10456
10457 if (empty && btrfs_root_refs(&root->root_item) == 0) {
10458 - synchronize_srcu(&fs_info->subvol_srcu);
10459 spin_lock(&root->inode_lock);
10460 empty = RB_EMPTY_ROOT(&root->inode_tree);
10461 spin_unlock(&root->inode_lock);
10462 @@ -9535,9 +9533,8 @@ static int btrfs_rename_exchange(struct inode *old_dir,
10463 btrfs_init_log_ctx(&ctx_dest, new_inode);
10464
10465 /* close the race window with snapshot create/destroy ioctl */
10466 - if (old_ino == BTRFS_FIRST_FREE_OBJECTID)
10467 - down_read(&fs_info->subvol_sem);
10468 - if (new_ino == BTRFS_FIRST_FREE_OBJECTID)
10469 + if (old_ino == BTRFS_FIRST_FREE_OBJECTID ||
10470 + new_ino == BTRFS_FIRST_FREE_OBJECTID)
10471 down_read(&fs_info->subvol_sem);
10472
10473 /*
10474 @@ -9771,9 +9768,8 @@ out_fail:
10475 ret = ret ? ret : ret2;
10476 }
10477 out_notrans:
10478 - if (new_ino == BTRFS_FIRST_FREE_OBJECTID)
10479 - up_read(&fs_info->subvol_sem);
10480 - if (old_ino == BTRFS_FIRST_FREE_OBJECTID)
10481 + if (new_ino == BTRFS_FIRST_FREE_OBJECTID ||
10482 + old_ino == BTRFS_FIRST_FREE_OBJECTID)
10483 up_read(&fs_info->subvol_sem);
10484
10485 ASSERT(list_empty(&ctx_root.list));
10486 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
10487 index 23272d9154f3..a56dcc0c9c2a 100644
10488 --- a/fs/btrfs/ioctl.c
10489 +++ b/fs/btrfs/ioctl.c
10490 @@ -705,11 +705,17 @@ static noinline int create_subvol(struct inode *dir,
10491
10492 btrfs_i_size_write(BTRFS_I(dir), dir->i_size + namelen * 2);
10493 ret = btrfs_update_inode(trans, root, dir);
10494 - BUG_ON(ret);
10495 + if (ret) {
10496 + btrfs_abort_transaction(trans, ret);
10497 + goto fail;
10498 + }
10499
10500 ret = btrfs_add_root_ref(trans, objectid, root->root_key.objectid,
10501 btrfs_ino(BTRFS_I(dir)), index, name, namelen);
10502 - BUG_ON(ret);
10503 + if (ret) {
10504 + btrfs_abort_transaction(trans, ret);
10505 + goto fail;
10506 + }
10507
10508 ret = btrfs_uuid_tree_add(trans, root_item->uuid,
10509 BTRFS_UUID_KEY_SUBVOL, objectid);
10510 diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
10511 index ee6f60547a8d..dd4f9c2b7107 100644
10512 --- a/fs/btrfs/reada.c
10513 +++ b/fs/btrfs/reada.c
10514 @@ -752,21 +752,19 @@ static int reada_start_machine_dev(struct btrfs_device *dev)
10515 static void reada_start_machine_worker(struct btrfs_work *work)
10516 {
10517 struct reada_machine_work *rmw;
10518 - struct btrfs_fs_info *fs_info;
10519 int old_ioprio;
10520
10521 rmw = container_of(work, struct reada_machine_work, work);
10522 - fs_info = rmw->fs_info;
10523 -
10524 - kfree(rmw);
10525
10526 old_ioprio = IOPRIO_PRIO_VALUE(task_nice_ioclass(current),
10527 task_nice_ioprio(current));
10528 set_task_ioprio(current, BTRFS_IOPRIO_READA);
10529 - __reada_start_machine(fs_info);
10530 + __reada_start_machine(rmw->fs_info);
10531 set_task_ioprio(current, old_ioprio);
10532
10533 - atomic_dec(&fs_info->reada_works_cnt);
10534 + atomic_dec(&rmw->fs_info->reada_works_cnt);
10535 +
10536 + kfree(rmw);
10537 }
10538
10539 static void __reada_start_machine(struct btrfs_fs_info *fs_info)
10540 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
10541 index 5cd42b66818c..fd0f4c1696c8 100644
10542 --- a/fs/btrfs/relocation.c
10543 +++ b/fs/btrfs/relocation.c
10544 @@ -4555,6 +4555,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
10545 fs_root = read_fs_root(fs_info, reloc_root->root_key.offset);
10546 if (IS_ERR(fs_root)) {
10547 err = PTR_ERR(fs_root);
10548 + list_add_tail(&reloc_root->root_list, &reloc_roots);
10549 goto out_free;
10550 }
10551
10552 diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
10553 index f7d4e03f4c5d..a0770a6aee00 100644
10554 --- a/fs/btrfs/scrub.c
10555 +++ b/fs/btrfs/scrub.c
10556 @@ -2149,14 +2149,13 @@ static void scrub_missing_raid56_worker(struct btrfs_work *work)
10557 scrub_write_block_to_dev_replace(sblock);
10558 }
10559
10560 - scrub_block_put(sblock);
10561 -
10562 if (sctx->is_dev_replace && sctx->flush_all_writes) {
10563 mutex_lock(&sctx->wr_lock);
10564 scrub_wr_submit(sctx);
10565 mutex_unlock(&sctx->wr_lock);
10566 }
10567
10568 + scrub_block_put(sblock);
10569 scrub_pending_bio_dec(sctx);
10570 }
10571
10572 diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
10573 index 518ec1265a0c..3eb0fec2488a 100644
10574 --- a/fs/btrfs/send.c
10575 +++ b/fs/btrfs/send.c
10576 @@ -7075,12 +7075,6 @@ long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg)
10577 send_root->send_in_progress++;
10578 spin_unlock(&send_root->root_item_lock);
10579
10580 - /*
10581 - * This is done when we lookup the root, it should already be complete
10582 - * by the time we get here.
10583 - */
10584 - WARN_ON(send_root->orphan_cleanup_state != ORPHAN_CLEANUP_DONE);
10585 -
10586 /*
10587 * Userspace tools do the checks and warn the user if it's
10588 * not RO.
10589 diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
10590 index bc92df977630..6e774d055402 100644
10591 --- a/fs/btrfs/tests/free-space-tree-tests.c
10592 +++ b/fs/btrfs/tests/free-space-tree-tests.c
10593 @@ -463,9 +463,9 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
10594 root->fs_info->tree_root = root;
10595
10596 root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
10597 - if (!root->node) {
10598 + if (IS_ERR(root->node)) {
10599 test_std_err(TEST_ALLOC_EXTENT_BUFFER);
10600 - ret = -ENOMEM;
10601 + ret = PTR_ERR(root->node);
10602 goto out;
10603 }
10604 btrfs_set_header_level(root->node, 0);
10605 diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c
10606 index 09aaca1efd62..ac035a6fa003 100644
10607 --- a/fs/btrfs/tests/qgroup-tests.c
10608 +++ b/fs/btrfs/tests/qgroup-tests.c
10609 @@ -484,9 +484,9 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
10610 * *cough*backref walking code*cough*
10611 */
10612 root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
10613 - if (!root->node) {
10614 + if (IS_ERR(root->node)) {
10615 test_err("couldn't allocate dummy buffer");
10616 - ret = -ENOMEM;
10617 + ret = PTR_ERR(root->node);
10618 goto out;
10619 }
10620 btrfs_set_header_level(root->node, 0);
10621 diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
10622 index 076d5b8014fb..0e44db066641 100644
10623 --- a/fs/btrfs/tree-checker.c
10624 +++ b/fs/btrfs/tree-checker.c
10625 @@ -243,7 +243,7 @@ static int check_extent_data_item(struct extent_buffer *leaf,
10626 }
10627
10628 static int check_csum_item(struct extent_buffer *leaf, struct btrfs_key *key,
10629 - int slot)
10630 + int slot, struct btrfs_key *prev_key)
10631 {
10632 struct btrfs_fs_info *fs_info = leaf->fs_info;
10633 u32 sectorsize = fs_info->sectorsize;
10634 @@ -267,6 +267,20 @@ static int check_csum_item(struct extent_buffer *leaf, struct btrfs_key *key,
10635 btrfs_item_size_nr(leaf, slot), csumsize);
10636 return -EUCLEAN;
10637 }
10638 + if (slot > 0 && prev_key->type == BTRFS_EXTENT_CSUM_KEY) {
10639 + u64 prev_csum_end;
10640 + u32 prev_item_size;
10641 +
10642 + prev_item_size = btrfs_item_size_nr(leaf, slot - 1);
10643 + prev_csum_end = (prev_item_size / csumsize) * sectorsize;
10644 + prev_csum_end += prev_key->offset;
10645 + if (prev_csum_end > key->offset) {
10646 + generic_err(leaf, slot - 1,
10647 +"csum end range (%llu) goes beyond the start range (%llu) of the next csum item",
10648 + prev_csum_end, key->offset);
10649 + return -EUCLEAN;
10650 + }
10651 + }
10652 return 0;
10653 }
10654
10655 @@ -1239,7 +1253,7 @@ static int check_leaf_item(struct extent_buffer *leaf,
10656 ret = check_extent_data_item(leaf, key, slot, prev_key);
10657 break;
10658 case BTRFS_EXTENT_CSUM_KEY:
10659 - ret = check_csum_item(leaf, key, slot);
10660 + ret = check_csum_item(leaf, key, slot, prev_key);
10661 break;
10662 case BTRFS_DIR_ITEM_KEY:
10663 case BTRFS_DIR_INDEX_KEY:
10664 diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
10665 index 8a6cc600bf18..ab27e6cd9b3e 100644
10666 --- a/fs/btrfs/tree-log.c
10667 +++ b/fs/btrfs/tree-log.c
10668 @@ -808,7 +808,8 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
10669 struct btrfs_ordered_sum,
10670 list);
10671 if (!ret)
10672 - ret = btrfs_del_csums(trans, fs_info,
10673 + ret = btrfs_del_csums(trans,
10674 + fs_info->csum_root,
10675 sums->bytenr,
10676 sums->len);
10677 if (!ret)
10678 @@ -3927,6 +3928,28 @@ static int log_inode_item(struct btrfs_trans_handle *trans,
10679 return 0;
10680 }
10681
10682 +static int log_csums(struct btrfs_trans_handle *trans,
10683 + struct btrfs_root *log_root,
10684 + struct btrfs_ordered_sum *sums)
10685 +{
10686 + int ret;
10687 +
10688 + /*
10689 + * Due to extent cloning, we might have logged a csum item that covers a
10690 + * subrange of a cloned extent, and later we can end up logging a csum
10691 + * item for a larger subrange of the same extent or the entire range.
10692 + * This would leave csum items in the log tree that cover the same range
10693 + * and break the searches for checksums in the log tree, resulting in
10694 + * some checksums missing in the fs/subvolume tree. So just delete (or
10695 + * trim and adjust) any existing csum items in the log for this range.
10696 + */
10697 + ret = btrfs_del_csums(trans, log_root, sums->bytenr, sums->len);
10698 + if (ret)
10699 + return ret;
10700 +
10701 + return btrfs_csum_file_blocks(trans, log_root, sums);
10702 +}
10703 +
10704 static noinline int copy_items(struct btrfs_trans_handle *trans,
10705 struct btrfs_inode *inode,
10706 struct btrfs_path *dst_path,
10707 @@ -4072,7 +4095,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
10708 struct btrfs_ordered_sum,
10709 list);
10710 if (!ret)
10711 - ret = btrfs_csum_file_blocks(trans, log, sums);
10712 + ret = log_csums(trans, log, sums);
10713 list_del(&sums->list);
10714 kfree(sums);
10715 }
10716 @@ -4292,7 +4315,7 @@ static int log_extent_csums(struct btrfs_trans_handle *trans,
10717 struct btrfs_ordered_sum,
10718 list);
10719 if (!ret)
10720 - ret = btrfs_csum_file_blocks(trans, log_root, sums);
10721 + ret = log_csums(trans, log_root, sums);
10722 list_del(&sums->list);
10723 kfree(sums);
10724 }
10725 @@ -6314,9 +6337,28 @@ again:
10726 wc.replay_dest = btrfs_read_fs_root_no_name(fs_info, &tmp_key);
10727 if (IS_ERR(wc.replay_dest)) {
10728 ret = PTR_ERR(wc.replay_dest);
10729 +
10730 + /*
10731 + * We didn't find the subvol, likely because it was
10732 + * deleted. This is ok, simply skip this log and go to
10733 + * the next one.
10734 + *
10735 + * We need to exclude the root because we can't have
10736 + * other log replays overwriting this log as we'll read
10737 + * it back in a few more times. This will keep our
10738 + * block from being modified, and we'll just bail for
10739 + * each subsequent pass.
10740 + */
10741 + if (ret == -ENOENT)
10742 + ret = btrfs_pin_extent_for_log_replay(fs_info,
10743 + log->node->start,
10744 + log->node->len);
10745 free_extent_buffer(log->node);
10746 free_extent_buffer(log->commit_root);
10747 kfree(log);
10748 +
10749 + if (!ret)
10750 + goto next;
10751 btrfs_handle_fs_error(fs_info, ret,
10752 "Couldn't read target root for tree log recovery.");
10753 goto error;
10754 @@ -6348,7 +6390,6 @@ again:
10755 &root->highest_objectid);
10756 }
10757
10758 - key.offset = found_key.offset - 1;
10759 wc.replay_dest->log_root = NULL;
10760 free_extent_buffer(log->node);
10761 free_extent_buffer(log->commit_root);
10762 @@ -6356,9 +6397,10 @@ again:
10763
10764 if (ret)
10765 goto error;
10766 -
10767 +next:
10768 if (found_key.offset == 0)
10769 break;
10770 + key.offset = found_key.offset - 1;
10771 }
10772 btrfs_release_path(path);
10773
10774 diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
10775 index 91caab63bdf5..76b84f2397b1 100644
10776 --- a/fs/btrfs/uuid-tree.c
10777 +++ b/fs/btrfs/uuid-tree.c
10778 @@ -324,6 +324,8 @@ again_search_slot:
10779 }
10780 if (ret < 0 && ret != -ENOENT)
10781 goto out;
10782 + key.offset++;
10783 + goto again_search_slot;
10784 }
10785 item_size -= sizeof(subid_le);
10786 offset += sizeof(subid_le);
10787 diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
10788 index 9fdd2b269d61..6305d5ec25af 100644
10789 --- a/fs/ext4/dir.c
10790 +++ b/fs/ext4/dir.c
10791 @@ -81,6 +81,11 @@ int __ext4_check_dir_entry(const char *function, unsigned int line,
10792 error_msg = "rec_len is too small for name_len";
10793 else if (unlikely(((char *) de - buf) + rlen > size))
10794 error_msg = "directory entry overrun";
10795 + else if (unlikely(((char *) de - buf) + rlen >
10796 + size - EXT4_DIR_REC_LEN(1) &&
10797 + ((char *) de - buf) + rlen != size)) {
10798 + error_msg = "directory entry too close to block end";
10799 + }
10800 else if (unlikely(le32_to_cpu(de->inode) >
10801 le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count)))
10802 error_msg = "inode out of bounds";
10803 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
10804 index 91da21890360..53134e4509b8 100644
10805 --- a/fs/ext4/inode.c
10806 +++ b/fs/ext4/inode.c
10807 @@ -6035,7 +6035,7 @@ int ext4_expand_extra_isize(struct inode *inode,
10808 error = ext4_journal_get_write_access(handle, iloc->bh);
10809 if (error) {
10810 brelse(iloc->bh);
10811 - goto out_stop;
10812 + goto out_unlock;
10813 }
10814
10815 error = __ext4_expand_extra_isize(inode, new_extra_isize, iloc,
10816 @@ -6045,8 +6045,8 @@ int ext4_expand_extra_isize(struct inode *inode,
10817 if (!error)
10818 error = rc;
10819
10820 +out_unlock:
10821 ext4_write_unlock_xattr(inode, &no_expand);
10822 -out_stop:
10823 ext4_journal_stop(handle);
10824 return error;
10825 }
10826 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
10827 index 923476e3aefb..f56402e9c11c 100644
10828 --- a/fs/ext4/namei.c
10829 +++ b/fs/ext4/namei.c
10830 @@ -2808,7 +2808,7 @@ bool ext4_empty_dir(struct inode *inode)
10831 {
10832 unsigned int offset;
10833 struct buffer_head *bh;
10834 - struct ext4_dir_entry_2 *de, *de1;
10835 + struct ext4_dir_entry_2 *de;
10836 struct super_block *sb;
10837
10838 if (ext4_has_inline_data(inode)) {
10839 @@ -2833,19 +2833,25 @@ bool ext4_empty_dir(struct inode *inode)
10840 return true;
10841
10842 de = (struct ext4_dir_entry_2 *) bh->b_data;
10843 - de1 = ext4_next_entry(de, sb->s_blocksize);
10844 - if (le32_to_cpu(de->inode) != inode->i_ino ||
10845 - le32_to_cpu(de1->inode) == 0 ||
10846 - strcmp(".", de->name) || strcmp("..", de1->name)) {
10847 - ext4_warning_inode(inode, "directory missing '.' and/or '..'");
10848 + if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data, bh->b_size,
10849 + 0) ||
10850 + le32_to_cpu(de->inode) != inode->i_ino || strcmp(".", de->name)) {
10851 + ext4_warning_inode(inode, "directory missing '.'");
10852 + brelse(bh);
10853 + return true;
10854 + }
10855 + offset = ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize);
10856 + de = ext4_next_entry(de, sb->s_blocksize);
10857 + if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data, bh->b_size,
10858 + offset) ||
10859 + le32_to_cpu(de->inode) == 0 || strcmp("..", de->name)) {
10860 + ext4_warning_inode(inode, "directory missing '..'");
10861 brelse(bh);
10862 return true;
10863 }
10864 - offset = ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize) +
10865 - ext4_rec_len_from_disk(de1->rec_len, sb->s_blocksize);
10866 - de = ext4_next_entry(de1, sb->s_blocksize);
10867 + offset += ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize);
10868 while (offset < inode->i_size) {
10869 - if ((void *) de >= (void *) (bh->b_data+sb->s_blocksize)) {
10870 + if (!(offset & (sb->s_blocksize - 1))) {
10871 unsigned int lblock;
10872 brelse(bh);
10873 lblock = offset >> EXT4_BLOCK_SIZE_BITS(sb);
10874 @@ -2856,12 +2862,11 @@ bool ext4_empty_dir(struct inode *inode)
10875 }
10876 if (IS_ERR(bh))
10877 return true;
10878 - de = (struct ext4_dir_entry_2 *) bh->b_data;
10879 }
10880 + de = (struct ext4_dir_entry_2 *) (bh->b_data +
10881 + (offset & (sb->s_blocksize - 1)));
10882 if (ext4_check_dir_entry(inode, NULL, de, bh,
10883 bh->b_data, bh->b_size, offset)) {
10884 - de = (struct ext4_dir_entry_2 *)(bh->b_data +
10885 - sb->s_blocksize);
10886 offset = (offset | (sb->s_blocksize - 1)) + 1;
10887 continue;
10888 }
10889 @@ -2870,7 +2875,6 @@ bool ext4_empty_dir(struct inode *inode)
10890 return false;
10891 }
10892 offset += ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize);
10893 - de = ext4_next_entry(de, sb->s_blocksize);
10894 }
10895 brelse(bh);
10896 return true;
10897 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
10898 index 98d37b8d0050..66162b430edc 100644
10899 --- a/fs/ext4/super.c
10900 +++ b/fs/ext4/super.c
10901 @@ -1887,6 +1887,13 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
10902 }
10903 sbi->s_commit_interval = HZ * arg;
10904 } else if (token == Opt_debug_want_extra_isize) {
10905 + if ((arg & 1) ||
10906 + (arg < 4) ||
10907 + (arg > (sbi->s_inode_size - EXT4_GOOD_OLD_INODE_SIZE))) {
10908 + ext4_msg(sb, KERN_ERR,
10909 + "Invalid want_extra_isize %d", arg);
10910 + return -1;
10911 + }
10912 sbi->s_want_extra_isize = arg;
10913 } else if (token == Opt_max_batch_time) {
10914 sbi->s_max_batch_time = arg;
10915 @@ -3551,40 +3558,6 @@ int ext4_calculate_overhead(struct super_block *sb)
10916 return 0;
10917 }
10918
10919 -static void ext4_clamp_want_extra_isize(struct super_block *sb)
10920 -{
10921 - struct ext4_sb_info *sbi = EXT4_SB(sb);
10922 - struct ext4_super_block *es = sbi->s_es;
10923 - unsigned def_extra_isize = sizeof(struct ext4_inode) -
10924 - EXT4_GOOD_OLD_INODE_SIZE;
10925 -
10926 - if (sbi->s_inode_size == EXT4_GOOD_OLD_INODE_SIZE) {
10927 - sbi->s_want_extra_isize = 0;
10928 - return;
10929 - }
10930 - if (sbi->s_want_extra_isize < 4) {
10931 - sbi->s_want_extra_isize = def_extra_isize;
10932 - if (ext4_has_feature_extra_isize(sb)) {
10933 - if (sbi->s_want_extra_isize <
10934 - le16_to_cpu(es->s_want_extra_isize))
10935 - sbi->s_want_extra_isize =
10936 - le16_to_cpu(es->s_want_extra_isize);
10937 - if (sbi->s_want_extra_isize <
10938 - le16_to_cpu(es->s_min_extra_isize))
10939 - sbi->s_want_extra_isize =
10940 - le16_to_cpu(es->s_min_extra_isize);
10941 - }
10942 - }
10943 - /* Check if enough inode space is available */
10944 - if ((sbi->s_want_extra_isize > sbi->s_inode_size) ||
10945 - (EXT4_GOOD_OLD_INODE_SIZE + sbi->s_want_extra_isize >
10946 - sbi->s_inode_size)) {
10947 - sbi->s_want_extra_isize = def_extra_isize;
10948 - ext4_msg(sb, KERN_INFO,
10949 - "required extra inode space not available");
10950 - }
10951 -}
10952 -
10953 static void ext4_set_resv_clusters(struct super_block *sb)
10954 {
10955 ext4_fsblk_t resv_clusters;
10956 @@ -3792,6 +3765,68 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
10957 */
10958 sbi->s_li_wait_mult = EXT4_DEF_LI_WAIT_MULT;
10959
10960 + if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) {
10961 + sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE;
10962 + sbi->s_first_ino = EXT4_GOOD_OLD_FIRST_INO;
10963 + } else {
10964 + sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
10965 + sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
10966 + if (sbi->s_first_ino < EXT4_GOOD_OLD_FIRST_INO) {
10967 + ext4_msg(sb, KERN_ERR, "invalid first ino: %u",
10968 + sbi->s_first_ino);
10969 + goto failed_mount;
10970 + }
10971 + if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) ||
10972 + (!is_power_of_2(sbi->s_inode_size)) ||
10973 + (sbi->s_inode_size > blocksize)) {
10974 + ext4_msg(sb, KERN_ERR,
10975 + "unsupported inode size: %d",
10976 + sbi->s_inode_size);
10977 + goto failed_mount;
10978 + }
10979 + /*
10980 + * i_atime_extra is the last extra field available for
10981 + * [acm]times in struct ext4_inode. Checking for that
10982 + * field should suffice to ensure we have extra space
10983 + * for all three.
10984 + */
10985 + if (sbi->s_inode_size >= offsetof(struct ext4_inode, i_atime_extra) +
10986 + sizeof(((struct ext4_inode *)0)->i_atime_extra)) {
10987 + sb->s_time_gran = 1;
10988 + sb->s_time_max = EXT4_EXTRA_TIMESTAMP_MAX;
10989 + } else {
10990 + sb->s_time_gran = NSEC_PER_SEC;
10991 + sb->s_time_max = EXT4_NON_EXTRA_TIMESTAMP_MAX;
10992 + }
10993 + sb->s_time_min = EXT4_TIMESTAMP_MIN;
10994 + }
10995 + if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) {
10996 + sbi->s_want_extra_isize = sizeof(struct ext4_inode) -
10997 + EXT4_GOOD_OLD_INODE_SIZE;
10998 + if (ext4_has_feature_extra_isize(sb)) {
10999 + unsigned v, max = (sbi->s_inode_size -
11000 + EXT4_GOOD_OLD_INODE_SIZE);
11001 +
11002 + v = le16_to_cpu(es->s_want_extra_isize);
11003 + if (v > max) {
11004 + ext4_msg(sb, KERN_ERR,
11005 + "bad s_want_extra_isize: %d", v);
11006 + goto failed_mount;
11007 + }
11008 + if (sbi->s_want_extra_isize < v)
11009 + sbi->s_want_extra_isize = v;
11010 +
11011 + v = le16_to_cpu(es->s_min_extra_isize);
11012 + if (v > max) {
11013 + ext4_msg(sb, KERN_ERR,
11014 + "bad s_min_extra_isize: %d", v);
11015 + goto failed_mount;
11016 + }
11017 + if (sbi->s_want_extra_isize < v)
11018 + sbi->s_want_extra_isize = v;
11019 + }
11020 + }
11021 +
11022 if (sbi->s_es->s_mount_opts[0]) {
11023 char *s_mount_opts = kstrndup(sbi->s_es->s_mount_opts,
11024 sizeof(sbi->s_es->s_mount_opts),
11025 @@ -4030,42 +4065,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
11026 has_huge_files);
11027 sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files);
11028
11029 - if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) {
11030 - sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE;
11031 - sbi->s_first_ino = EXT4_GOOD_OLD_FIRST_INO;
11032 - } else {
11033 - sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
11034 - sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
11035 - if (sbi->s_first_ino < EXT4_GOOD_OLD_FIRST_INO) {
11036 - ext4_msg(sb, KERN_ERR, "invalid first ino: %u",
11037 - sbi->s_first_ino);
11038 - goto failed_mount;
11039 - }
11040 - if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) ||
11041 - (!is_power_of_2(sbi->s_inode_size)) ||
11042 - (sbi->s_inode_size > blocksize)) {
11043 - ext4_msg(sb, KERN_ERR,
11044 - "unsupported inode size: %d",
11045 - sbi->s_inode_size);
11046 - goto failed_mount;
11047 - }
11048 - /*
11049 - * i_atime_extra is the last extra field available for [acm]times in
11050 - * struct ext4_inode. Checking for that field should suffice to ensure
11051 - * we have extra space for all three.
11052 - */
11053 - if (sbi->s_inode_size >= offsetof(struct ext4_inode, i_atime_extra) +
11054 - sizeof(((struct ext4_inode *)0)->i_atime_extra)) {
11055 - sb->s_time_gran = 1;
11056 - sb->s_time_max = EXT4_EXTRA_TIMESTAMP_MAX;
11057 - } else {
11058 - sb->s_time_gran = NSEC_PER_SEC;
11059 - sb->s_time_max = EXT4_NON_EXTRA_TIMESTAMP_MAX;
11060 - }
11061 -
11062 - sb->s_time_min = EXT4_TIMESTAMP_MIN;
11063 - }
11064 -
11065 sbi->s_desc_size = le16_to_cpu(es->s_desc_size);
11066 if (ext4_has_feature_64bit(sb)) {
11067 if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT ||
11068 @@ -4521,8 +4520,6 @@ no_journal:
11069 } else if (ret)
11070 goto failed_mount4a;
11071
11072 - ext4_clamp_want_extra_isize(sb);
11073 -
11074 ext4_set_resv_clusters(sb);
11075
11076 err = ext4_setup_system_zone(sb);
11077 @@ -5310,8 +5307,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
11078 goto restore_opts;
11079 }
11080
11081 - ext4_clamp_want_extra_isize(sb);
11082 -
11083 if ((old_opts.s_mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) ^
11084 test_opt(sb, JOURNAL_CHECKSUM)) {
11085 ext4_msg(sb, KERN_ERR, "changing journal_checksum "
11086 diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
11087 index 2ba6253ea6d3..fc349204a71b 100644
11088 --- a/include/drm/drm_dp_mst_helper.h
11089 +++ b/include/drm/drm_dp_mst_helper.h
11090 @@ -334,7 +334,7 @@ struct drm_dp_resource_status_notify {
11091
11092 struct drm_dp_query_payload_ack_reply {
11093 u8 port_number;
11094 - u8 allocated_pbn;
11095 + u16 allocated_pbn;
11096 };
11097
11098 struct drm_dp_sideband_msg_req_body {
11099 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
11100 index 92d5fdc8154e..31b1b0e03df8 100644
11101 --- a/include/linux/cpufreq.h
11102 +++ b/include/linux/cpufreq.h
11103 @@ -595,17 +595,6 @@ struct governor_attr {
11104 size_t count);
11105 };
11106
11107 -static inline bool cpufreq_this_cpu_can_update(struct cpufreq_policy *policy)
11108 -{
11109 - /*
11110 - * Allow remote callbacks if:
11111 - * - dvfs_possible_from_any_cpu flag is set
11112 - * - the local and remote CPUs share cpufreq policy
11113 - */
11114 - return policy->dvfs_possible_from_any_cpu ||
11115 - cpumask_test_cpu(smp_processor_id(), policy->cpus);
11116 -}
11117 -
11118 /*********************************************************************
11119 * FREQUENCY TABLE HELPERS *
11120 *********************************************************************/
11121 diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h
11122 index 4dc66157d872..deec18b8944a 100644
11123 --- a/include/linux/ipmi_smi.h
11124 +++ b/include/linux/ipmi_smi.h
11125 @@ -224,10 +224,14 @@ static inline int ipmi_demangle_device_id(uint8_t netfn, uint8_t cmd,
11126 * is called, and the lower layer must get the interface from that
11127 * call.
11128 */
11129 -int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
11130 - void *send_info,
11131 - struct device *dev,
11132 - unsigned char slave_addr);
11133 +int ipmi_add_smi(struct module *owner,
11134 + const struct ipmi_smi_handlers *handlers,
11135 + void *send_info,
11136 + struct device *dev,
11137 + unsigned char slave_addr);
11138 +
11139 +#define ipmi_register_smi(handlers, send_info, dev, slave_addr) \
11140 + ipmi_add_smi(THIS_MODULE, handlers, send_info, dev, slave_addr)
11141
11142 /*
11143 * Remove a low-level interface from the IPMI driver. This will
11144 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
11145 index 5714fd35a83c..e3596db077dc 100644
11146 --- a/include/linux/mod_devicetable.h
11147 +++ b/include/linux/mod_devicetable.h
11148 @@ -587,9 +587,9 @@ struct platform_device_id {
11149 #define MDIO_NAME_SIZE 32
11150 #define MDIO_MODULE_PREFIX "mdio:"
11151
11152 -#define MDIO_ID_FMT "%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d"
11153 +#define MDIO_ID_FMT "%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u"
11154 #define MDIO_ID_ARGS(_id) \
11155 - (_id)>>31, ((_id)>>30) & 1, ((_id)>>29) & 1, ((_id)>>28) & 1, \
11156 + ((_id)>>31) & 1, ((_id)>>30) & 1, ((_id)>>29) & 1, ((_id)>>28) & 1, \
11157 ((_id)>>27) & 1, ((_id)>>26) & 1, ((_id)>>25) & 1, ((_id)>>24) & 1, \
11158 ((_id)>>23) & 1, ((_id)>>22) & 1, ((_id)>>21) & 1, ((_id)>>20) & 1, \
11159 ((_id)>>19) & 1, ((_id)>>18) & 1, ((_id)>>17) & 1, ((_id)>>16) & 1, \
11160 diff --git a/include/linux/nvme.h b/include/linux/nvme.h
11161 index f61d6906e59d..a260cd754f28 100644
11162 --- a/include/linux/nvme.h
11163 +++ b/include/linux/nvme.h
11164 @@ -1368,6 +1368,7 @@ enum {
11165 NVME_SC_ANA_INACCESSIBLE = 0x302,
11166 NVME_SC_ANA_TRANSITION = 0x303,
11167 NVME_SC_HOST_PATH_ERROR = 0x370,
11168 + NVME_SC_HOST_ABORTED_CMD = 0x371,
11169
11170 NVME_SC_CRD = 0x1800,
11171 NVME_SC_DNR = 0x4000,
11172 diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
11173 index 8f8be5b00060..5c17cb733224 100644
11174 --- a/include/linux/nvmem-consumer.h
11175 +++ b/include/linux/nvmem-consumer.h
11176 @@ -118,7 +118,7 @@ static inline void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
11177 }
11178
11179 static inline int nvmem_cell_write(struct nvmem_cell *cell,
11180 - const char *buf, size_t len)
11181 + void *buf, size_t len)
11182 {
11183 return -EOPNOTSUPP;
11184 }
11185 diff --git a/include/linux/phy.h b/include/linux/phy.h
11186 index 9a0e981df502..3d5d53313e6c 100644
11187 --- a/include/linux/phy.h
11188 +++ b/include/linux/phy.h
11189 @@ -993,7 +993,7 @@ int phy_modify_paged_changed(struct phy_device *phydev, int page, u32 regnum,
11190 int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum,
11191 u16 mask, u16 set);
11192
11193 -struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
11194 +struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
11195 bool is_c45,
11196 struct phy_c45_device_ids *c45_ids);
11197 #if IS_ENABLED(CONFIG_PHYLIB)
11198 diff --git a/include/linux/sched/cpufreq.h b/include/linux/sched/cpufreq.h
11199 index afa940cd50dc..cc6bcc1e96bc 100644
11200 --- a/include/linux/sched/cpufreq.h
11201 +++ b/include/linux/sched/cpufreq.h
11202 @@ -12,6 +12,8 @@
11203 #define SCHED_CPUFREQ_MIGRATION (1U << 1)
11204
11205 #ifdef CONFIG_CPU_FREQ
11206 +struct cpufreq_policy;
11207 +
11208 struct update_util_data {
11209 void (*func)(struct update_util_data *data, u64 time, unsigned int flags);
11210 };
11211 @@ -20,6 +22,7 @@ void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data,
11212 void (*func)(struct update_util_data *data, u64 time,
11213 unsigned int flags));
11214 void cpufreq_remove_update_util_hook(int cpu);
11215 +bool cpufreq_this_cpu_can_update(struct cpufreq_policy *policy);
11216
11217 static inline unsigned long map_util_freq(unsigned long util,
11218 unsigned long freq, unsigned long cap)
11219 diff --git a/include/net/arp.h b/include/net/arp.h
11220 index c8f580a0e6b1..4950191f6b2b 100644
11221 --- a/include/net/arp.h
11222 +++ b/include/net/arp.h
11223 @@ -57,8 +57,8 @@ static inline void __ipv4_confirm_neigh(struct net_device *dev, u32 key)
11224 unsigned long now = jiffies;
11225
11226 /* avoid dirtying neighbour */
11227 - if (n->confirmed != now)
11228 - n->confirmed = now;
11229 + if (READ_ONCE(n->confirmed) != now)
11230 + WRITE_ONCE(n->confirmed, now);
11231 }
11232 rcu_read_unlock_bh();
11233 }
11234 diff --git a/include/net/dst.h b/include/net/dst.h
11235 index fe62fe2eb781..8224dad2ae94 100644
11236 --- a/include/net/dst.h
11237 +++ b/include/net/dst.h
11238 @@ -82,7 +82,7 @@ struct dst_entry {
11239 struct dst_metrics {
11240 u32 metrics[RTAX_MAX];
11241 refcount_t refcnt;
11242 -};
11243 +} __aligned(4); /* Low pointer bits contain DST_METRICS_FLAGS */
11244 extern const struct dst_metrics dst_default_metrics;
11245
11246 u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old);
11247 diff --git a/include/net/ndisc.h b/include/net/ndisc.h
11248 index b2f715ca0567..b5ebeb3b0de0 100644
11249 --- a/include/net/ndisc.h
11250 +++ b/include/net/ndisc.h
11251 @@ -414,8 +414,8 @@ static inline void __ipv6_confirm_neigh(struct net_device *dev,
11252 unsigned long now = jiffies;
11253
11254 /* avoid dirtying neighbour */
11255 - if (n->confirmed != now)
11256 - n->confirmed = now;
11257 + if (READ_ONCE(n->confirmed) != now)
11258 + WRITE_ONCE(n->confirmed, now);
11259 }
11260 rcu_read_unlock_bh();
11261 }
11262 @@ -431,8 +431,8 @@ static inline void __ipv6_confirm_neigh_stub(struct net_device *dev,
11263 unsigned long now = jiffies;
11264
11265 /* avoid dirtying neighbour */
11266 - if (n->confirmed != now)
11267 - n->confirmed = now;
11268 + if (READ_ONCE(n->confirmed) != now)
11269 + WRITE_ONCE(n->confirmed, now);
11270 }
11271 rcu_read_unlock_bh();
11272 }
11273 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
11274 index b8452cc0e059..5e679c8dae0b 100644
11275 --- a/include/net/neighbour.h
11276 +++ b/include/net/neighbour.h
11277 @@ -72,7 +72,6 @@ struct neigh_parms {
11278 struct net_device *dev;
11279 struct list_head list;
11280 int (*neigh_setup)(struct neighbour *);
11281 - void (*neigh_cleanup)(struct neighbour *);
11282 struct neigh_table *tbl;
11283
11284 void *sysctl_table;
11285 diff --git a/include/net/sock.h b/include/net/sock.h
11286 index 718e62fbe869..013396e50b91 100644
11287 --- a/include/net/sock.h
11288 +++ b/include/net/sock.h
11289 @@ -1940,8 +1940,8 @@ struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie);
11290
11291 static inline void sk_dst_confirm(struct sock *sk)
11292 {
11293 - if (!sk->sk_dst_pending_confirm)
11294 - sk->sk_dst_pending_confirm = 1;
11295 + if (!READ_ONCE(sk->sk_dst_pending_confirm))
11296 + WRITE_ONCE(sk->sk_dst_pending_confirm, 1);
11297 }
11298
11299 static inline void sock_confirm_neigh(struct sk_buff *skb, struct neighbour *n)
11300 @@ -1951,10 +1951,10 @@ static inline void sock_confirm_neigh(struct sk_buff *skb, struct neighbour *n)
11301 unsigned long now = jiffies;
11302
11303 /* avoid dirtying neighbour */
11304 - if (n->confirmed != now)
11305 - n->confirmed = now;
11306 - if (sk && sk->sk_dst_pending_confirm)
11307 - sk->sk_dst_pending_confirm = 0;
11308 + if (READ_ONCE(n->confirmed) != now)
11309 + WRITE_ONCE(n->confirmed, now);
11310 + if (sk && READ_ONCE(sk->sk_dst_pending_confirm))
11311 + WRITE_ONCE(sk->sk_dst_pending_confirm, 0);
11312 }
11313 }
11314
11315 diff --git a/include/trace/events/wbt.h b/include/trace/events/wbt.h
11316 index b048694070e2..37342a13c9cb 100644
11317 --- a/include/trace/events/wbt.h
11318 +++ b/include/trace/events/wbt.h
11319 @@ -33,7 +33,8 @@ TRACE_EVENT(wbt_stat,
11320 ),
11321
11322 TP_fast_assign(
11323 - strncpy(__entry->name, dev_name(bdi->dev), 32);
11324 + strlcpy(__entry->name, dev_name(bdi->dev),
11325 + ARRAY_SIZE(__entry->name));
11326 __entry->rmean = stat[0].mean;
11327 __entry->rmin = stat[0].min;
11328 __entry->rmax = stat[0].max;
11329 @@ -67,7 +68,8 @@ TRACE_EVENT(wbt_lat,
11330 ),
11331
11332 TP_fast_assign(
11333 - strncpy(__entry->name, dev_name(bdi->dev), 32);
11334 + strlcpy(__entry->name, dev_name(bdi->dev),
11335 + ARRAY_SIZE(__entry->name));
11336 __entry->lat = div_u64(lat, 1000);
11337 ),
11338
11339 @@ -103,7 +105,8 @@ TRACE_EVENT(wbt_step,
11340 ),
11341
11342 TP_fast_assign(
11343 - strncpy(__entry->name, dev_name(bdi->dev), 32);
11344 + strlcpy(__entry->name, dev_name(bdi->dev),
11345 + ARRAY_SIZE(__entry->name));
11346 __entry->msg = msg;
11347 __entry->step = step;
11348 __entry->window = div_u64(window, 1000);
11349 @@ -138,7 +141,8 @@ TRACE_EVENT(wbt_timer,
11350 ),
11351
11352 TP_fast_assign(
11353 - strncpy(__entry->name, dev_name(bdi->dev), 32);
11354 + strlcpy(__entry->name, dev_name(bdi->dev),
11355 + ARRAY_SIZE(__entry->name));
11356 __entry->status = status;
11357 __entry->step = step;
11358 __entry->inflight = inflight;
11359 diff --git a/include/uapi/linux/cec-funcs.h b/include/uapi/linux/cec-funcs.h
11360 index 8997d5068c08..4511b85c84df 100644
11361 --- a/include/uapi/linux/cec-funcs.h
11362 +++ b/include/uapi/linux/cec-funcs.h
11363 @@ -923,7 +923,8 @@ static inline void cec_msg_give_deck_status(struct cec_msg *msg,
11364 msg->len = 3;
11365 msg->msg[1] = CEC_MSG_GIVE_DECK_STATUS;
11366 msg->msg[2] = status_req;
11367 - msg->reply = reply ? CEC_MSG_DECK_STATUS : 0;
11368 + msg->reply = (reply && status_req != CEC_OP_STATUS_REQ_OFF) ?
11369 + CEC_MSG_DECK_STATUS : 0;
11370 }
11371
11372 static inline void cec_ops_give_deck_status(const struct cec_msg *msg,
11373 @@ -1027,7 +1028,8 @@ static inline void cec_msg_give_tuner_device_status(struct cec_msg *msg,
11374 msg->len = 3;
11375 msg->msg[1] = CEC_MSG_GIVE_TUNER_DEVICE_STATUS;
11376 msg->msg[2] = status_req;
11377 - msg->reply = reply ? CEC_MSG_TUNER_DEVICE_STATUS : 0;
11378 + msg->reply = (reply && status_req != CEC_OP_STATUS_REQ_OFF) ?
11379 + CEC_MSG_TUNER_DEVICE_STATUS : 0;
11380 }
11381
11382 static inline void cec_ops_give_tuner_device_status(const struct cec_msg *msg,
11383 diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
11384 index 052580c33d26..173e983619d7 100644
11385 --- a/kernel/bpf/stackmap.c
11386 +++ b/kernel/bpf/stackmap.c
11387 @@ -287,7 +287,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
11388 bool irq_work_busy = false;
11389 struct stack_map_irq_work *work = NULL;
11390
11391 - if (in_nmi()) {
11392 + if (irqs_disabled()) {
11393 work = this_cpu_ptr(&up_read_work);
11394 if (work->irq_work.flags & IRQ_WORK_BUSY)
11395 /* cannot queue more up_read, fallback */
11396 @@ -295,8 +295,9 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
11397 }
11398
11399 /*
11400 - * We cannot do up_read() in nmi context. To do build_id lookup
11401 - * in nmi context, we need to run up_read() in irq_work. We use
11402 + * We cannot do up_read() when the irq is disabled, because of
11403 + * risk to deadlock with rq_lock. To do build_id lookup when the
11404 + * irqs are disabled, we need to run up_read() in irq_work. We use
11405 * a percpu variable to do the irq_work. If the irq_work is
11406 * already used by another lookup, we fall back to report ips.
11407 *
11408 diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
11409 index ffc3e53f5300..9e7cee5307e0 100644
11410 --- a/kernel/bpf/verifier.c
11411 +++ b/kernel/bpf/verifier.c
11412 @@ -978,6 +978,17 @@ static void __reg_bound_offset(struct bpf_reg_state *reg)
11413 reg->umax_value));
11414 }
11415
11416 +static void __reg_bound_offset32(struct bpf_reg_state *reg)
11417 +{
11418 + u64 mask = 0xffffFFFF;
11419 + struct tnum range = tnum_range(reg->umin_value & mask,
11420 + reg->umax_value & mask);
11421 + struct tnum lo32 = tnum_cast(reg->var_off, 4);
11422 + struct tnum hi32 = tnum_lshift(tnum_rshift(reg->var_off, 32), 32);
11423 +
11424 + reg->var_off = tnum_or(hi32, tnum_intersect(lo32, range));
11425 +}
11426 +
11427 /* Reset the min/max bounds of a register */
11428 static void __mark_reg_unbounded(struct bpf_reg_state *reg)
11429 {
11430 @@ -5433,6 +5444,10 @@ static void reg_set_min_max(struct bpf_reg_state *true_reg,
11431 /* We might have learned some bits from the bounds. */
11432 __reg_bound_offset(false_reg);
11433 __reg_bound_offset(true_reg);
11434 + if (is_jmp32) {
11435 + __reg_bound_offset32(false_reg);
11436 + __reg_bound_offset32(true_reg);
11437 + }
11438 /* Intersecting with the old var_off might have improved our bounds
11439 * slightly. e.g. if umax was 0x7f...f and var_off was (0; 0xf...fc),
11440 * then new var_off is (0; 0x7f...fc) which improves our umax.
11441 @@ -5542,6 +5557,10 @@ static void reg_set_min_max_inv(struct bpf_reg_state *true_reg,
11442 /* We might have learned some bits from the bounds. */
11443 __reg_bound_offset(false_reg);
11444 __reg_bound_offset(true_reg);
11445 + if (is_jmp32) {
11446 + __reg_bound_offset32(false_reg);
11447 + __reg_bound_offset32(true_reg);
11448 + }
11449 /* Intersecting with the old var_off might have improved our bounds
11450 * slightly. e.g. if umax was 0x7f...f and var_off was (0; 0xf...fc),
11451 * then new var_off is (0; 0x7f...fc) which improves our umax.
11452 diff --git a/kernel/cgroup/freezer.c b/kernel/cgroup/freezer.c
11453 index 8cf010680678..3984dd6b8ddb 100644
11454 --- a/kernel/cgroup/freezer.c
11455 +++ b/kernel/cgroup/freezer.c
11456 @@ -230,6 +230,15 @@ void cgroup_freezer_migrate_task(struct task_struct *task,
11457 if (task->flags & PF_KTHREAD)
11458 return;
11459
11460 + /*
11461 + * It's not necessary to do changes if both of the src and dst cgroups
11462 + * are not freezing and task is not frozen.
11463 + */
11464 + if (!test_bit(CGRP_FREEZE, &src->flags) &&
11465 + !test_bit(CGRP_FREEZE, &dst->flags) &&
11466 + !task->frozen)
11467 + return;
11468 +
11469 /*
11470 * Adjust counters of freezing and frozen tasks.
11471 * Note, that if the task is frozen, but the destination cgroup is not
11472 diff --git a/kernel/events/core.c b/kernel/events/core.c
11473 index 00a014670ed0..8f66a4833ded 100644
11474 --- a/kernel/events/core.c
11475 +++ b/kernel/events/core.c
11476 @@ -5607,10 +5607,8 @@ static void perf_mmap_close(struct vm_area_struct *vma)
11477 perf_pmu_output_stop(event);
11478
11479 /* now it's safe to free the pages */
11480 - if (!rb->aux_mmap_locked)
11481 - atomic_long_sub(rb->aux_nr_pages, &mmap_user->locked_vm);
11482 - else
11483 - atomic64_sub(rb->aux_mmap_locked, &vma->vm_mm->pinned_vm);
11484 + atomic_long_sub(rb->aux_nr_pages - rb->aux_mmap_locked, &mmap_user->locked_vm);
11485 + atomic64_sub(rb->aux_mmap_locked, &vma->vm_mm->pinned_vm);
11486
11487 /* this has to be the last one */
11488 rb_free_aux(rb);
11489 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
11490 index 44123b4d14e8..8dacda4b0362 100644
11491 --- a/kernel/sched/core.c
11492 +++ b/kernel/sched/core.c
11493 @@ -810,7 +810,7 @@ static inline unsigned int uclamp_bucket_base_value(unsigned int clamp_value)
11494 return UCLAMP_BUCKET_DELTA * uclamp_bucket_id(clamp_value);
11495 }
11496
11497 -static inline enum uclamp_id uclamp_none(enum uclamp_id clamp_id)
11498 +static inline unsigned int uclamp_none(enum uclamp_id clamp_id)
11499 {
11500 if (clamp_id == UCLAMP_MIN)
11501 return 0;
11502 @@ -853,7 +853,7 @@ static inline void uclamp_idle_reset(struct rq *rq, enum uclamp_id clamp_id,
11503 }
11504
11505 static inline
11506 -enum uclamp_id uclamp_rq_max_value(struct rq *rq, enum uclamp_id clamp_id,
11507 +unsigned int uclamp_rq_max_value(struct rq *rq, enum uclamp_id clamp_id,
11508 unsigned int clamp_value)
11509 {
11510 struct uclamp_bucket *bucket = rq->uclamp[clamp_id].bucket;
11511 @@ -918,7 +918,7 @@ uclamp_eff_get(struct task_struct *p, enum uclamp_id clamp_id)
11512 return uc_req;
11513 }
11514
11515 -enum uclamp_id uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id)
11516 +unsigned int uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id)
11517 {
11518 struct uclamp_se uc_eff;
11519
11520 diff --git a/kernel/sched/cpufreq.c b/kernel/sched/cpufreq.c
11521 index b5dcd1d83c7f..7c2fe50fd76d 100644
11522 --- a/kernel/sched/cpufreq.c
11523 +++ b/kernel/sched/cpufreq.c
11524 @@ -5,6 +5,8 @@
11525 * Copyright (C) 2016, Intel Corporation
11526 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
11527 */
11528 +#include <linux/cpufreq.h>
11529 +
11530 #include "sched.h"
11531
11532 DEFINE_PER_CPU(struct update_util_data __rcu *, cpufreq_update_util_data);
11533 @@ -57,3 +59,19 @@ void cpufreq_remove_update_util_hook(int cpu)
11534 rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), NULL);
11535 }
11536 EXPORT_SYMBOL_GPL(cpufreq_remove_update_util_hook);
11537 +
11538 +/**
11539 + * cpufreq_this_cpu_can_update - Check if cpufreq policy can be updated.
11540 + * @policy: cpufreq policy to check.
11541 + *
11542 + * Return 'true' if:
11543 + * - the local and remote CPUs share @policy,
11544 + * - dvfs_possible_from_any_cpu is set in @policy and the local CPU is not going
11545 + * offline (in which case it is not expected to run cpufreq updates any more).
11546 + */
11547 +bool cpufreq_this_cpu_can_update(struct cpufreq_policy *policy)
11548 +{
11549 + return cpumask_test_cpu(smp_processor_id(), policy->cpus) ||
11550 + (policy->dvfs_possible_from_any_cpu &&
11551 + rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data)));
11552 +}
11553 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
11554 index 86800b4d5453..b6f56e7c8dd1 100644
11555 --- a/kernel/sched/cpufreq_schedutil.c
11556 +++ b/kernel/sched/cpufreq_schedutil.c
11557 @@ -82,12 +82,10 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time)
11558 * by the hardware, as calculating the frequency is pointless if
11559 * we cannot in fact act on it.
11560 *
11561 - * For the slow switching platforms, the kthread is always scheduled on
11562 - * the right set of CPUs and any CPU can find the next frequency and
11563 - * schedule the kthread.
11564 + * This is needed on the slow switching platforms too to prevent CPUs
11565 + * going offline from leaving stale IRQ work items behind.
11566 */
11567 - if (sg_policy->policy->fast_switch_enabled &&
11568 - !cpufreq_this_cpu_can_update(sg_policy->policy))
11569 + if (!cpufreq_this_cpu_can_update(sg_policy->policy))
11570 return false;
11571
11572 if (unlikely(sg_policy->limits_changed)) {
11573 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
11574 index c8870c5bd7df..49ed949f850c 100644
11575 --- a/kernel/sched/sched.h
11576 +++ b/kernel/sched/sched.h
11577 @@ -2309,7 +2309,7 @@ static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) {}
11578 #endif /* CONFIG_CPU_FREQ */
11579
11580 #ifdef CONFIG_UCLAMP_TASK
11581 -enum uclamp_id uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id);
11582 +unsigned int uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id);
11583
11584 static __always_inline
11585 unsigned int uclamp_util_with(struct rq *rq, unsigned int util,
11586 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
11587 index 6a0ee9178365..2fa72419bbd7 100644
11588 --- a/kernel/trace/trace.c
11589 +++ b/kernel/trace/trace.c
11590 @@ -4609,7 +4609,7 @@ int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
11591
11592 if (mask == TRACE_ITER_RECORD_TGID) {
11593 if (!tgid_map)
11594 - tgid_map = kcalloc(PID_MAX_DEFAULT + 1,
11595 + tgid_map = kvcalloc(PID_MAX_DEFAULT + 1,
11596 sizeof(*tgid_map),
11597 GFP_KERNEL);
11598 if (!tgid_map) {
11599 diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
11600 index 1552a95c743b..7f890262c8a3 100644
11601 --- a/kernel/trace/trace_kprobe.c
11602 +++ b/kernel/trace/trace_kprobe.c
11603 @@ -435,11 +435,10 @@ static int disable_trace_kprobe(struct trace_event_call *call,
11604
11605 #if defined(CONFIG_KPROBES_ON_FTRACE) && \
11606 !defined(CONFIG_KPROBE_EVENTS_ON_NOTRACE)
11607 -static bool within_notrace_func(struct trace_kprobe *tk)
11608 +static bool __within_notrace_func(unsigned long addr)
11609 {
11610 - unsigned long offset, size, addr;
11611 + unsigned long offset, size;
11612
11613 - addr = trace_kprobe_address(tk);
11614 if (!addr || !kallsyms_lookup_size_offset(addr, &size, &offset))
11615 return false;
11616
11617 @@ -452,6 +451,28 @@ static bool within_notrace_func(struct trace_kprobe *tk)
11618 */
11619 return !ftrace_location_range(addr, addr + size - 1);
11620 }
11621 +
11622 +static bool within_notrace_func(struct trace_kprobe *tk)
11623 +{
11624 + unsigned long addr = addr = trace_kprobe_address(tk);
11625 + char symname[KSYM_NAME_LEN], *p;
11626 +
11627 + if (!__within_notrace_func(addr))
11628 + return false;
11629 +
11630 + /* Check if the address is on a suffixed-symbol */
11631 + if (!lookup_symbol_name(addr, symname)) {
11632 + p = strchr(symname, '.');
11633 + if (!p)
11634 + return true;
11635 + *p = '\0';
11636 + addr = (unsigned long)kprobe_lookup_name(symname, 0);
11637 + if (addr)
11638 + return __within_notrace_func(addr);
11639 + }
11640 +
11641 + return true;
11642 +}
11643 #else
11644 #define within_notrace_func(tk) (false)
11645 #endif
11646 diff --git a/lib/ubsan.c b/lib/ubsan.c
11647 index e7d31735950d..0c4681118fcd 100644
11648 --- a/lib/ubsan.c
11649 +++ b/lib/ubsan.c
11650 @@ -374,9 +374,10 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
11651 struct type_descriptor *lhs_type = data->lhs_type;
11652 char rhs_str[VALUE_LENGTH];
11653 char lhs_str[VALUE_LENGTH];
11654 + unsigned long ua_flags = user_access_save();
11655
11656 if (suppress_report(&data->location))
11657 - return;
11658 + goto out;
11659
11660 ubsan_prologue(&data->location, &flags);
11661
11662 @@ -402,6 +403,8 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
11663 lhs_type->type_name);
11664
11665 ubsan_epilogue(&flags);
11666 +out:
11667 + user_access_restore(ua_flags);
11668 }
11669 EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
11670
11671 diff --git a/mm/vmscan.c b/mm/vmscan.c
11672 index ee4eecc7e1c2..e7f10c4b40f0 100644
11673 --- a/mm/vmscan.c
11674 +++ b/mm/vmscan.c
11675 @@ -422,7 +422,7 @@ void register_shrinker_prepared(struct shrinker *shrinker)
11676 {
11677 down_write(&shrinker_rwsem);
11678 list_add_tail(&shrinker->list, &shrinker_list);
11679 -#ifdef CONFIG_MEMCG_KMEM
11680 +#ifdef CONFIG_MEMCG
11681 if (shrinker->flags & SHRINKER_MEMCG_AWARE)
11682 idr_replace(&shrinker_idr, shrinker, shrinker->id);
11683 #endif
11684 diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
11685 index ad5b0ac1f9ce..7ff92dd4c53c 100644
11686 --- a/net/bluetooth/hci_conn.c
11687 +++ b/net/bluetooth/hci_conn.c
11688 @@ -934,6 +934,14 @@ static void hci_req_directed_advertising(struct hci_request *req,
11689 return;
11690
11691 memset(&cp, 0, sizeof(cp));
11692 +
11693 + /* Some controllers might reject command if intervals are not
11694 + * within range for undirected advertising.
11695 + * BCM20702A0 is known to be affected by this.
11696 + */
11697 + cp.min_interval = cpu_to_le16(0x0020);
11698 + cp.max_interval = cpu_to_le16(0x0020);
11699 +
11700 cp.type = LE_ADV_DIRECT_IND;
11701 cp.own_address_type = own_addr_type;
11702 cp.direct_addr_type = conn->dst_type;
11703 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
11704 index 04bc79359a17..0cc9ce917222 100644
11705 --- a/net/bluetooth/hci_core.c
11706 +++ b/net/bluetooth/hci_core.c
11707 @@ -842,8 +842,8 @@ static int hci_init4_req(struct hci_request *req, unsigned long opt)
11708 if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) {
11709 struct hci_cp_le_write_def_data_len cp;
11710
11711 - cp.tx_len = hdev->le_max_tx_len;
11712 - cp.tx_time = hdev->le_max_tx_time;
11713 + cp.tx_len = cpu_to_le16(hdev->le_max_tx_len);
11714 + cp.tx_time = cpu_to_le16(hdev->le_max_tx_time);
11715 hci_req_add(req, HCI_OP_LE_WRITE_DEF_DATA_LEN, sizeof(cp), &cp);
11716 }
11717
11718 @@ -4440,7 +4440,14 @@ static void hci_rx_work(struct work_struct *work)
11719 hci_send_to_sock(hdev, skb);
11720 }
11721
11722 - if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) {
11723 + /* If the device has been opened in HCI_USER_CHANNEL,
11724 + * the userspace has exclusive access to device.
11725 + * When device is HCI_INIT, we still need to process
11726 + * the data packets to the driver in order
11727 + * to complete its setup().
11728 + */
11729 + if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
11730 + !test_bit(HCI_INIT, &hdev->flags)) {
11731 kfree_skb(skb);
11732 continue;
11733 }
11734 diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
11735 index 7f6a581b5b7e..3d25dbf10b26 100644
11736 --- a/net/bluetooth/hci_request.c
11737 +++ b/net/bluetooth/hci_request.c
11738 @@ -1273,6 +1273,14 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr)
11739
11740 instance_flags = get_adv_instance_flags(hdev, instance);
11741
11742 + /* If instance already has the flags set skip adding it once
11743 + * again.
11744 + */
11745 + if (adv_instance && eir_get_data(adv_instance->adv_data,
11746 + adv_instance->adv_data_len, EIR_FLAGS,
11747 + NULL))
11748 + goto skip_flags;
11749 +
11750 /* The Add Advertising command allows userspace to set both the general
11751 * and limited discoverable flags.
11752 */
11753 @@ -1305,6 +1313,7 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr)
11754 }
11755 }
11756
11757 +skip_flags:
11758 if (adv_instance) {
11759 memcpy(ptr, adv_instance->adv_data,
11760 adv_instance->adv_data_len);
11761 diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
11762 index de09b0a65791..f7587428febd 100644
11763 --- a/net/can/j1939/socket.c
11764 +++ b/net/can/j1939/socket.c
11765 @@ -423,9 +423,9 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len)
11766 {
11767 struct sockaddr_can *addr = (struct sockaddr_can *)uaddr;
11768 struct j1939_sock *jsk = j1939_sk(sock->sk);
11769 - struct j1939_priv *priv = jsk->priv;
11770 - struct sock *sk = sock->sk;
11771 - struct net *net = sock_net(sk);
11772 + struct j1939_priv *priv;
11773 + struct sock *sk;
11774 + struct net *net;
11775 int ret = 0;
11776
11777 ret = j1939_sk_sanity_check(addr, len);
11778 @@ -434,6 +434,10 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len)
11779
11780 lock_sock(sock->sk);
11781
11782 + priv = jsk->priv;
11783 + sk = sock->sk;
11784 + net = sock_net(sk);
11785 +
11786 /* Already bound to an interface? */
11787 if (jsk->state & J1939_SOCK_BOUND) {
11788 /* A re-bind() to a different interface is not
11789 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
11790 index 5480edff0c86..08ebc3ac5343 100644
11791 --- a/net/core/neighbour.c
11792 +++ b/net/core/neighbour.c
11793 @@ -98,9 +98,6 @@ static int neigh_blackhole(struct neighbour *neigh, struct sk_buff *skb)
11794
11795 static void neigh_cleanup_and_release(struct neighbour *neigh)
11796 {
11797 - if (neigh->parms->neigh_cleanup)
11798 - neigh->parms->neigh_cleanup(neigh);
11799 -
11800 trace_neigh_cleanup_and_release(neigh, 0);
11801 __neigh_notify(neigh, RTM_DELNEIGH, 0, 0);
11802 call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh);
11803 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
11804 index ae3bcb1540ec..b4db68e5caa9 100644
11805 --- a/net/core/net-sysfs.c
11806 +++ b/net/core/net-sysfs.c
11807 @@ -919,14 +919,17 @@ static int rx_queue_add_kobject(struct net_device *dev, int index)
11808 struct kobject *kobj = &queue->kobj;
11809 int error = 0;
11810
11811 + /* Kobject_put later will trigger rx_queue_release call which
11812 + * decreases dev refcount: Take that reference here
11813 + */
11814 + dev_hold(queue->dev);
11815 +
11816 kobj->kset = dev->queues_kset;
11817 error = kobject_init_and_add(kobj, &rx_queue_ktype, NULL,
11818 "rx-%u", index);
11819 if (error)
11820 goto err;
11821
11822 - dev_hold(queue->dev);
11823 -
11824 if (dev->sysfs_rx_queue_group) {
11825 error = sysfs_create_group(kobj, dev->sysfs_rx_queue_group);
11826 if (error)
11827 diff --git a/net/mac80211/status.c b/net/mac80211/status.c
11828 index ab8ba5835ca0..5a3d645fe1bc 100644
11829 --- a/net/mac80211/status.c
11830 +++ b/net/mac80211/status.c
11831 @@ -1030,7 +1030,8 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
11832 I802_DEBUG_INC(local->dot11FailedCount);
11833 }
11834
11835 - if (ieee80211_is_nullfunc(fc) && ieee80211_has_pm(fc) &&
11836 + if ((ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc)) &&
11837 + ieee80211_has_pm(fc) &&
11838 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS) &&
11839 !(info->flags & IEEE80211_TX_CTL_INJECTED) &&
11840 local->ps_sdata && !(local->scanning)) {
11841 diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c
11842 index 78fe622eba65..11b554ce07ff 100644
11843 --- a/net/nfc/nci/uart.c
11844 +++ b/net/nfc/nci/uart.c
11845 @@ -346,7 +346,7 @@ static int nci_uart_default_recv_buf(struct nci_uart *nu, const u8 *data,
11846 nu->rx_packet_len = -1;
11847 nu->rx_skb = nci_skb_alloc(nu->ndev,
11848 NCI_MAX_PACKET_SIZE,
11849 - GFP_KERNEL);
11850 + GFP_ATOMIC);
11851 if (!nu->rx_skb)
11852 return -ENOMEM;
11853 }
11854 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
11855 index 82a50e850245..529d4ce945db 100644
11856 --- a/net/packet/af_packet.c
11857 +++ b/net/packet/af_packet.c
11858 @@ -544,7 +544,8 @@ static int prb_calc_retire_blk_tmo(struct packet_sock *po,
11859 msec = 1;
11860 div = ecmd.base.speed / 1000;
11861 }
11862 - }
11863 + } else
11864 + return DEFAULT_PRB_RETIRE_TOV;
11865
11866 mbits = (blk_size_in_bytes * 8) / (1024 * 1024);
11867
11868 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
11869 index 08d14d86ecfb..681ffb3545db 100644
11870 --- a/net/sctp/protocol.c
11871 +++ b/net/sctp/protocol.c
11872 @@ -227,6 +227,7 @@ static void sctp_v4_from_skb(union sctp_addr *addr, struct sk_buff *skb,
11873 sa->sin_port = sh->dest;
11874 sa->sin_addr.s_addr = ip_hdr(skb)->daddr;
11875 }
11876 + memset(sa->sin_zero, 0, sizeof(sa->sin_zero));
11877 }
11878
11879 /* Initialize an sctp_addr from a socket. */
11880 @@ -235,6 +236,7 @@ static void sctp_v4_from_sk(union sctp_addr *addr, struct sock *sk)
11881 addr->v4.sin_family = AF_INET;
11882 addr->v4.sin_port = 0;
11883 addr->v4.sin_addr.s_addr = inet_sk(sk)->inet_rcv_saddr;
11884 + memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero));
11885 }
11886
11887 /* Initialize sk->sk_rcv_saddr from sctp_addr. */
11888 @@ -257,6 +259,7 @@ static void sctp_v4_from_addr_param(union sctp_addr *addr,
11889 addr->v4.sin_family = AF_INET;
11890 addr->v4.sin_port = port;
11891 addr->v4.sin_addr.s_addr = param->v4.addr.s_addr;
11892 + memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero));
11893 }
11894
11895 /* Initialize an address parameter from a sctp_addr and return the length
11896 @@ -281,6 +284,7 @@ static void sctp_v4_dst_saddr(union sctp_addr *saddr, struct flowi4 *fl4,
11897 saddr->v4.sin_family = AF_INET;
11898 saddr->v4.sin_port = port;
11899 saddr->v4.sin_addr.s_addr = fl4->saddr;
11900 + memset(saddr->v4.sin_zero, 0, sizeof(saddr->v4.sin_zero));
11901 }
11902
11903 /* Compare two addresses exactly. */
11904 @@ -303,6 +307,7 @@ static void sctp_v4_inaddr_any(union sctp_addr *addr, __be16 port)
11905 addr->v4.sin_family = AF_INET;
11906 addr->v4.sin_addr.s_addr = htonl(INADDR_ANY);
11907 addr->v4.sin_port = port;
11908 + memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero));
11909 }
11910
11911 /* Is this a wildcard address? */
11912 diff --git a/net/sctp/stream.c b/net/sctp/stream.c
11913 index e83cdaa2ab76..6a30392068a0 100644
11914 --- a/net/sctp/stream.c
11915 +++ b/net/sctp/stream.c
11916 @@ -84,8 +84,10 @@ static int sctp_stream_alloc_out(struct sctp_stream *stream, __u16 outcnt,
11917 return 0;
11918
11919 ret = genradix_prealloc(&stream->out, outcnt, gfp);
11920 - if (ret)
11921 + if (ret) {
11922 + genradix_free(&stream->out);
11923 return ret;
11924 + }
11925
11926 stream->outcnt = outcnt;
11927 return 0;
11928 @@ -100,8 +102,10 @@ static int sctp_stream_alloc_in(struct sctp_stream *stream, __u16 incnt,
11929 return 0;
11930
11931 ret = genradix_prealloc(&stream->in, incnt, gfp);
11932 - if (ret)
11933 + if (ret) {
11934 + genradix_free(&stream->in);
11935 return ret;
11936 + }
11937
11938 stream->incnt = incnt;
11939 return 0;
11940 diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
11941 index 2ba97ff325a5..0c5fcb8ed404 100644
11942 --- a/net/smc/smc_core.c
11943 +++ b/net/smc/smc_core.c
11944 @@ -231,10 +231,12 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
11945 lgr->conns_all = RB_ROOT;
11946 if (ini->is_smcd) {
11947 /* SMC-D specific settings */
11948 + get_device(&ini->ism_dev->dev);
11949 lgr->peer_gid = ini->ism_gid;
11950 lgr->smcd = ini->ism_dev;
11951 } else {
11952 /* SMC-R specific settings */
11953 + get_device(&ini->ib_dev->ibdev->dev);
11954 lgr->role = smc->listen_smc ? SMC_SERV : SMC_CLNT;
11955 memcpy(lgr->peer_systemid, ini->ib_lcl->id_for_peer,
11956 SMC_SYSTEMID_LEN);
11957 @@ -433,10 +435,13 @@ static void smc_lgr_free_bufs(struct smc_link_group *lgr)
11958 static void smc_lgr_free(struct smc_link_group *lgr)
11959 {
11960 smc_lgr_free_bufs(lgr);
11961 - if (lgr->is_smcd)
11962 + if (lgr->is_smcd) {
11963 smc_ism_put_vlan(lgr->smcd, lgr->vlan_id);
11964 - else
11965 + put_device(&lgr->smcd->dev);
11966 + } else {
11967 smc_link_clear(&lgr->lnk[SMC_SINGLE_LINK]);
11968 + put_device(&lgr->lnk[SMC_SINGLE_LINK].smcibdev->ibdev->dev);
11969 + }
11970 kfree(lgr);
11971 }
11972
11973 diff --git a/samples/pktgen/functions.sh b/samples/pktgen/functions.sh
11974 index 4af4046d71be..40873a5d1461 100644
11975 --- a/samples/pktgen/functions.sh
11976 +++ b/samples/pktgen/functions.sh
11977 @@ -5,6 +5,8 @@
11978 # Author: Jesper Dangaaard Brouer
11979 # License: GPL
11980
11981 +set -o errexit
11982 +
11983 ## -- General shell logging cmds --
11984 function err() {
11985 local exitcode=$1
11986 @@ -58,6 +60,7 @@ function pg_set() {
11987 function proc_cmd() {
11988 local result
11989 local proc_file=$1
11990 + local status=0
11991 # after shift, the remaining args are contained in $@
11992 shift
11993 local proc_ctrl=${PROC_DIR}/$proc_file
11994 @@ -73,13 +76,13 @@ function proc_cmd() {
11995 echo "cmd: $@ > $proc_ctrl"
11996 fi
11997 # Quoting of "$@" is important for space expansion
11998 - echo "$@" > "$proc_ctrl"
11999 - local status=$?
12000 + echo "$@" > "$proc_ctrl" || status=$?
12001
12002 - result=$(grep "Result: OK:" $proc_ctrl)
12003 - # Due to pgctrl, cannot use exit code $? from grep
12004 - if [[ "$result" == "" ]]; then
12005 - grep "Result:" $proc_ctrl >&2
12006 + if [[ "$proc_file" != "pgctrl" ]]; then
12007 + result=$(grep "Result: OK:" $proc_ctrl) || true
12008 + if [[ "$result" == "" ]]; then
12009 + grep "Result:" $proc_ctrl >&2
12010 + fi
12011 fi
12012 if (( $status != 0 )); then
12013 err 5 "Write error($status) occurred cmd: \"$@ > $proc_ctrl\""
12014 @@ -105,6 +108,8 @@ function pgset() {
12015 fi
12016 }
12017
12018 +[[ $EUID -eq 0 ]] && trap 'pg_ctrl "reset"' EXIT
12019 +
12020 ## -- General shell tricks --
12021
12022 function root_check_run_with_sudo() {
12023 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
12024 index 91c6ad58729f..d4280568a41e 100644
12025 --- a/sound/core/pcm_native.c
12026 +++ b/sound/core/pcm_native.c
12027 @@ -222,7 +222,8 @@ static bool hw_support_mmap(struct snd_pcm_substream *substream)
12028 return false;
12029
12030 if (substream->ops->mmap ||
12031 - substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_DEV)
12032 + (substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_DEV &&
12033 + substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_DEV_UC))
12034 return true;
12035
12036 return dma_can_mmap(substream->dma_buffer.dev.dev);
12037 @@ -705,6 +706,10 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
12038 while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size)
12039 runtime->boundary *= 2;
12040
12041 + /* clear the buffer for avoiding possible kernel info leaks */
12042 + if (runtime->dma_area && !substream->ops->copy_user)
12043 + memset(runtime->dma_area, 0, runtime->dma_bytes);
12044 +
12045 snd_pcm_timer_resolution_change(substream);
12046 snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP);
12047
12048 diff --git a/sound/core/timer.c b/sound/core/timer.c
12049 index 59ae21b0bb93..013f0e69ff0f 100644
12050 --- a/sound/core/timer.c
12051 +++ b/sound/core/timer.c
12052 @@ -74,6 +74,9 @@ static LIST_HEAD(snd_timer_slave_list);
12053 /* lock for slave active lists */
12054 static DEFINE_SPINLOCK(slave_active_lock);
12055
12056 +#define MAX_SLAVE_INSTANCES 1000
12057 +static int num_slaves;
12058 +
12059 static DEFINE_MUTEX(register_mutex);
12060
12061 static int snd_timer_free(struct snd_timer *timer);
12062 @@ -252,6 +255,10 @@ int snd_timer_open(struct snd_timer_instance **ti,
12063 err = -EINVAL;
12064 goto unlock;
12065 }
12066 + if (num_slaves >= MAX_SLAVE_INSTANCES) {
12067 + err = -EBUSY;
12068 + goto unlock;
12069 + }
12070 timeri = snd_timer_instance_new(owner, NULL);
12071 if (!timeri) {
12072 err = -ENOMEM;
12073 @@ -261,6 +268,7 @@ int snd_timer_open(struct snd_timer_instance **ti,
12074 timeri->slave_id = tid->device;
12075 timeri->flags |= SNDRV_TIMER_IFLG_SLAVE;
12076 list_add_tail(&timeri->open_list, &snd_timer_slave_list);
12077 + num_slaves++;
12078 err = snd_timer_check_slave(timeri);
12079 if (err < 0) {
12080 snd_timer_close_locked(timeri, &card_dev_to_put);
12081 @@ -356,6 +364,8 @@ static int snd_timer_close_locked(struct snd_timer_instance *timeri,
12082 }
12083
12084 list_del(&timeri->open_list);
12085 + if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE)
12086 + num_slaves--;
12087
12088 /* force to stop the timer */
12089 snd_timer_stop(timeri);
12090 diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
12091 index 6c1497d9f52b..ce07ea0d4e71 100644
12092 --- a/sound/firewire/bebob/bebob_stream.c
12093 +++ b/sound/firewire/bebob/bebob_stream.c
12094 @@ -415,15 +415,16 @@ static int make_both_connections(struct snd_bebob *bebob)
12095 return 0;
12096 }
12097
12098 -static void
12099 -break_both_connections(struct snd_bebob *bebob)
12100 +static void break_both_connections(struct snd_bebob *bebob)
12101 {
12102 cmp_connection_break(&bebob->in_conn);
12103 cmp_connection_break(&bebob->out_conn);
12104
12105 - /* These models seems to be in transition state for a longer time. */
12106 - if (bebob->maudio_special_quirk != NULL)
12107 - msleep(200);
12108 + // These models seem to be in transition state for a longer time. When
12109 + // accessing in the state, any transactions is corrupted. In the worst
12110 + // case, the device is going to reboot.
12111 + if (bebob->version < 2)
12112 + msleep(600);
12113 }
12114
12115 static int
12116 diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
12117 index b7a1abb3e231..32ed46464af7 100644
12118 --- a/sound/pci/hda/patch_ca0132.c
12119 +++ b/sound/pci/hda/patch_ca0132.c
12120 @@ -1809,13 +1809,14 @@ struct scp_msg {
12121
12122 static void dspio_clear_response_queue(struct hda_codec *codec)
12123 {
12124 + unsigned long timeout = jiffies + msecs_to_jiffies(1000);
12125 unsigned int dummy = 0;
12126 - int status = -1;
12127 + int status;
12128
12129 /* clear all from the response queue */
12130 do {
12131 status = dspio_read(codec, &dummy);
12132 - } while (status == 0);
12133 + } while (status == 0 && time_before(jiffies, timeout));
12134 }
12135
12136 static int dspio_get_response_data(struct hda_codec *codec)
12137 @@ -7588,12 +7589,14 @@ static void ca0132_process_dsp_response(struct hda_codec *codec,
12138 struct ca0132_spec *spec = codec->spec;
12139
12140 codec_dbg(codec, "ca0132_process_dsp_response\n");
12141 + snd_hda_power_up_pm(codec);
12142 if (spec->wait_scp) {
12143 if (dspio_get_response_data(codec) >= 0)
12144 spec->wait_scp = 0;
12145 }
12146
12147 dspio_clear_response_queue(codec);
12148 + snd_hda_power_down_pm(codec);
12149 }
12150
12151 static void hp_callback(struct hda_codec *codec, struct hda_jack_callback *cb)
12152 @@ -7604,11 +7607,10 @@ static void hp_callback(struct hda_codec *codec, struct hda_jack_callback *cb)
12153 /* Delay enabling the HP amp, to let the mic-detection
12154 * state machine run.
12155 */
12156 - cancel_delayed_work(&spec->unsol_hp_work);
12157 - schedule_delayed_work(&spec->unsol_hp_work, msecs_to_jiffies(500));
12158 tbl = snd_hda_jack_tbl_get(codec, cb->nid);
12159 if (tbl)
12160 tbl->block_report = 1;
12161 + schedule_delayed_work(&spec->unsol_hp_work, msecs_to_jiffies(500));
12162 }
12163
12164 static void amic_callback(struct hda_codec *codec, struct hda_jack_callback *cb)
12165 @@ -8454,12 +8456,25 @@ static void ca0132_reboot_notify(struct hda_codec *codec)
12166 codec->patch_ops.free(codec);
12167 }
12168
12169 +#ifdef CONFIG_PM
12170 +static int ca0132_suspend(struct hda_codec *codec)
12171 +{
12172 + struct ca0132_spec *spec = codec->spec;
12173 +
12174 + cancel_delayed_work_sync(&spec->unsol_hp_work);
12175 + return 0;
12176 +}
12177 +#endif
12178 +
12179 static const struct hda_codec_ops ca0132_patch_ops = {
12180 .build_controls = ca0132_build_controls,
12181 .build_pcms = ca0132_build_pcms,
12182 .init = ca0132_init,
12183 .free = ca0132_free,
12184 .unsol_event = snd_hda_jack_unsol_event,
12185 +#ifdef CONFIG_PM
12186 + .suspend = ca0132_suspend,
12187 +#endif
12188 .reboot_notify = ca0132_reboot_notify,
12189 };
12190
12191 diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
12192 index 315a3d39bc09..8bc9450da79c 100644
12193 --- a/sound/soc/codecs/rt5677.c
12194 +++ b/sound/soc/codecs/rt5677.c
12195 @@ -298,6 +298,7 @@ static bool rt5677_volatile_register(struct device *dev, unsigned int reg)
12196 case RT5677_I2C_MASTER_CTRL7:
12197 case RT5677_I2C_MASTER_CTRL8:
12198 case RT5677_HAP_GENE_CTRL2:
12199 + case RT5677_PWR_ANLG2: /* Modified by DSP firmware */
12200 case RT5677_PWR_DSP_ST:
12201 case RT5677_PRIV_DATA:
12202 case RT5677_ASRC_22:
12203 diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c
12204 index cf64e109c658..7b087d94141b 100644
12205 --- a/sound/soc/codecs/wm2200.c
12206 +++ b/sound/soc/codecs/wm2200.c
12207 @@ -2410,6 +2410,8 @@ static int wm2200_i2c_probe(struct i2c_client *i2c,
12208
12209 err_pm_runtime:
12210 pm_runtime_disable(&i2c->dev);
12211 + if (i2c->irq)
12212 + free_irq(i2c->irq, wm2200);
12213 err_reset:
12214 if (wm2200->pdata.reset)
12215 gpio_set_value_cansleep(wm2200->pdata.reset, 0);
12216 @@ -2426,12 +2428,15 @@ static int wm2200_i2c_remove(struct i2c_client *i2c)
12217 {
12218 struct wm2200_priv *wm2200 = i2c_get_clientdata(i2c);
12219
12220 + pm_runtime_disable(&i2c->dev);
12221 if (i2c->irq)
12222 free_irq(i2c->irq, wm2200);
12223 if (wm2200->pdata.reset)
12224 gpio_set_value_cansleep(wm2200->pdata.reset, 0);
12225 if (wm2200->pdata.ldo_ena)
12226 gpio_set_value_cansleep(wm2200->pdata.ldo_ena, 0);
12227 + regulator_bulk_disable(ARRAY_SIZE(wm2200->core_supplies),
12228 + wm2200->core_supplies);
12229
12230 return 0;
12231 }
12232 diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c
12233 index 4af0e519e623..91cc63c5a51f 100644
12234 --- a/sound/soc/codecs/wm5100.c
12235 +++ b/sound/soc/codecs/wm5100.c
12236 @@ -2617,6 +2617,7 @@ static int wm5100_i2c_probe(struct i2c_client *i2c,
12237 return ret;
12238
12239 err_reset:
12240 + pm_runtime_disable(&i2c->dev);
12241 if (i2c->irq)
12242 free_irq(i2c->irq, wm5100);
12243 wm5100_free_gpio(i2c);
12244 @@ -2640,6 +2641,7 @@ static int wm5100_i2c_remove(struct i2c_client *i2c)
12245 {
12246 struct wm5100_priv *wm5100 = i2c_get_clientdata(i2c);
12247
12248 + pm_runtime_disable(&i2c->dev);
12249 if (i2c->irq)
12250 free_irq(i2c->irq, wm5100);
12251 wm5100_free_gpio(i2c);
12252 diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
12253 index bcb3c9d5abf0..9e8c564f6e9c 100644
12254 --- a/sound/soc/codecs/wm8904.c
12255 +++ b/sound/soc/codecs/wm8904.c
12256 @@ -1917,6 +1917,7 @@ static int wm8904_set_bias_level(struct snd_soc_component *component,
12257 snd_soc_component_update_bits(component, WM8904_BIAS_CONTROL_0,
12258 WM8904_BIAS_ENA, 0);
12259
12260 + snd_soc_component_write(component, WM8904_SW_RESET_AND_ID, 0);
12261 regcache_cache_only(wm8904->regmap, true);
12262 regcache_mark_dirty(wm8904->regmap);
12263
12264 diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
12265 index 9c1aa4ec9cba..dd2b5ad08659 100644
12266 --- a/sound/soc/intel/boards/bytcr_rt5640.c
12267 +++ b/sound/soc/intel/boards/bytcr_rt5640.c
12268 @@ -405,10 +405,12 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
12269 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
12270 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
12271 },
12272 - .driver_data = (void *)(BYT_RT5640_IN1_MAP |
12273 - BYT_RT5640_MCLK_EN |
12274 - BYT_RT5640_SSP0_AIF1),
12275 -
12276 + .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
12277 + BYT_RT5640_JD_SRC_JD2_IN4N |
12278 + BYT_RT5640_OVCD_TH_2000UA |
12279 + BYT_RT5640_OVCD_SF_0P75 |
12280 + BYT_RT5640_SSP0_AIF1 |
12281 + BYT_RT5640_MCLK_EN),
12282 },
12283 {
12284 .matches = {
12285 diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
12286 index 74dda8784f1a..67b276a65a8d 100644
12287 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
12288 +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
12289 @@ -400,6 +400,9 @@ static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
12290 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
12291 dmic_constraints);
12292
12293 + runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
12294 + snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
12295 +
12296 return snd_pcm_hw_constraint_list(substream->runtime, 0,
12297 SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
12298 }
12299 diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
12300 index b600d3eaaf5c..a6e96cf1d8ff 100644
12301 --- a/sound/soc/soc-pcm.c
12302 +++ b/sound/soc/soc-pcm.c
12303 @@ -877,6 +877,11 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
12304 int i, ret = 0;
12305
12306 mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
12307 +
12308 + ret = soc_pcm_params_symmetry(substream, params);
12309 + if (ret)
12310 + goto out;
12311 +
12312 if (rtd->dai_link->ops->hw_params) {
12313 ret = rtd->dai_link->ops->hw_params(substream, params);
12314 if (ret < 0) {
12315 @@ -958,9 +963,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
12316 }
12317 component = NULL;
12318
12319 - ret = soc_pcm_params_symmetry(substream, params);
12320 - if (ret)
12321 - goto component_err;
12322 out:
12323 mutex_unlock(&rtd->card->pcm_mutex);
12324 return ret;
12325 @@ -1385,6 +1387,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,
12326 struct snd_soc_dapm_widget *widget;
12327 struct snd_soc_dai *dai;
12328 int prune = 0;
12329 + int do_prune;
12330
12331 /* Destroy any old FE <--> BE connections */
12332 for_each_dpcm_be(fe, stream, dpcm) {
12333 @@ -1398,13 +1401,16 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,
12334 continue;
12335
12336 /* is there a valid CODEC DAI widget for this BE */
12337 + do_prune = 1;
12338 for_each_rtd_codec_dai(dpcm->be, i, dai) {
12339 widget = dai_get_widget(dai, stream);
12340
12341 /* prune the BE if it's no longer in our active list */
12342 if (widget && widget_in_list(list, widget))
12343 - continue;
12344 + do_prune = 0;
12345 }
12346 + if (!do_prune)
12347 + continue;
12348
12349 dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n",
12350 stream ? "capture" : "playback",
12351 diff --git a/sound/soc/sof/imx/Kconfig b/sound/soc/sof/imx/Kconfig
12352 index 5acae75f5750..71f318bc2c74 100644
12353 --- a/sound/soc/sof/imx/Kconfig
12354 +++ b/sound/soc/sof/imx/Kconfig
12355 @@ -11,8 +11,8 @@ config SND_SOC_SOF_IMX_TOPLEVEL
12356
12357 if SND_SOC_SOF_IMX_TOPLEVEL
12358
12359 -config SND_SOC_SOF_IMX8
12360 - tristate "SOF support for i.MX8"
12361 +config SND_SOC_SOF_IMX8_SUPPORT
12362 + bool "SOF support for i.MX8"
12363 depends on IMX_SCU
12364 depends on IMX_DSP
12365 help
12366 @@ -20,4 +20,8 @@ config SND_SOC_SOF_IMX8
12367 Say Y if you have such a device.
12368 If unsure select "N".
12369
12370 +config SND_SOC_SOF_IMX8
12371 + def_tristate SND_SOC_SOF_OF
12372 + depends on SND_SOC_SOF_IMX8_SUPPORT
12373 +
12374 endif ## SND_SOC_SOF_IMX_IMX_TOPLEVEL
12375 diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
12376 index 06e84679087b..5a5163eef2ef 100644
12377 --- a/sound/soc/sof/intel/hda.c
12378 +++ b/sound/soc/sof/intel/hda.c
12379 @@ -268,6 +268,7 @@ static int hda_init(struct snd_sof_dev *sdev)
12380
12381 bus->use_posbuf = 1;
12382 bus->bdl_pos_adj = 0;
12383 + bus->sync_write = 1;
12384
12385 mutex_init(&hbus->prepare_mutex);
12386 hbus->pci = pci;
12387 diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
12388 index 4452594c2e17..fa299e078156 100644
12389 --- a/sound/soc/sof/topology.c
12390 +++ b/sound/soc/sof/topology.c
12391 @@ -2828,6 +2828,10 @@ static int sof_link_load(struct snd_soc_component *scomp, int index,
12392 if (!link->no_pcm) {
12393 link->nonatomic = true;
12394
12395 + /* set trigger order */
12396 + link->trigger[0] = SND_SOC_DPCM_TRIGGER_POST;
12397 + link->trigger[1] = SND_SOC_DPCM_TRIGGER_POST;
12398 +
12399 /* nothing more to do for FE dai links */
12400 return 0;
12401 }
12402 diff --git a/tools/arch/x86/lib/x86-opcode-map.txt b/tools/arch/x86/lib/x86-opcode-map.txt
12403 index e0b85930dd77..0a0e9112f284 100644
12404 --- a/tools/arch/x86/lib/x86-opcode-map.txt
12405 +++ b/tools/arch/x86/lib/x86-opcode-map.txt
12406 @@ -333,7 +333,7 @@ AVXcode: 1
12407 06: CLTS
12408 07: SYSRET (o64)
12409 08: INVD
12410 -09: WBINVD
12411 +09: WBINVD | WBNOINVD (F3)
12412 0a:
12413 0b: UD2 (1B)
12414 0c:
12415 @@ -364,7 +364,7 @@ AVXcode: 1
12416 # a ModR/M byte.
12417 1a: BNDCL Gv,Ev (F3) | BNDCU Gv,Ev (F2) | BNDMOV Gv,Ev (66) | BNDLDX Gv,Ev
12418 1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv
12419 -1c:
12420 +1c: Grp20 (1A),(1C)
12421 1d:
12422 1e:
12423 1f: NOP Ev
12424 @@ -792,6 +792,8 @@ f3: Grp17 (1A)
12425 f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v)
12426 f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v)
12427 f7: BEXTR Gy,Ey,By (v) | SHLX Gy,Ey,By (66),(v) | SARX Gy,Ey,By (F3),(v) | SHRX Gy,Ey,By (F2),(v)
12428 +f8: MOVDIR64B Gv,Mdqq (66) | ENQCMD Gv,Mdqq (F2) | ENQCMDS Gv,Mdqq (F3)
12429 +f9: MOVDIRI My,Gy
12430 EndTable
12431
12432 Table: 3-byte opcode 2 (0x0f 0x3a)
12433 @@ -943,9 +945,9 @@ GrpTable: Grp6
12434 EndTable
12435
12436 GrpTable: Grp7
12437 -0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B)
12438 -1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B)
12439 -2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B)
12440 +0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B) | PCONFIG (101),(11B) | ENCLV (000),(11B)
12441 +1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B) | ENCLS (111),(11B)
12442 +2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B) | ENCLU (111),(11B)
12443 3: LIDT Ms
12444 4: SMSW Mw/Rv
12445 5: rdpkru (110),(11B) | wrpkru (111),(11B)
12446 @@ -1020,7 +1022,7 @@ GrpTable: Grp15
12447 3: vstmxcsr Md (v1) | WRGSBASE Ry (F3),(11B)
12448 4: XSAVE | ptwrite Ey (F3),(11B)
12449 5: XRSTOR | lfence (11B)
12450 -6: XSAVEOPT | clwb (66) | mfence (11B)
12451 +6: XSAVEOPT | clwb (66) | mfence (11B) | TPAUSE Rd (66),(11B) | UMONITOR Rv (F3),(11B) | UMWAIT Rd (F2),(11B)
12452 7: clflush | clflushopt (66) | sfence (11B)
12453 EndTable
12454
12455 @@ -1051,6 +1053,10 @@ GrpTable: Grp19
12456 6: vscatterpf1qps/d Wx (66),(ev)
12457 EndTable
12458
12459 +GrpTable: Grp20
12460 +0: cldemote Mb
12461 +EndTable
12462 +
12463 # AMD's Prefetch Group
12464 GrpTable: GrpP
12465 0: PREFETCH
12466 diff --git a/tools/bpf/Makefile b/tools/bpf/Makefile
12467 index 5d1995fd369c..5535650800ab 100644
12468 --- a/tools/bpf/Makefile
12469 +++ b/tools/bpf/Makefile
12470 @@ -16,7 +16,13 @@ CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include
12471 # isn't set and when invoked from selftests build, where srctree
12472 # is set to ".". building_out_of_srctree is undefined for in srctree
12473 # builds
12474 +ifeq ($(srctree),)
12475 +update_srctree := 1
12476 +endif
12477 ifndef building_out_of_srctree
12478 +update_srctree := 1
12479 +endif
12480 +ifeq ($(update_srctree),1)
12481 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
12482 srctree := $(patsubst %/,%,$(dir $(srctree)))
12483 endif
12484 diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
12485 index ede55fec3618..87f27e2664c5 100644
12486 --- a/tools/lib/bpf/btf_dump.c
12487 +++ b/tools/lib/bpf/btf_dump.c
12488 @@ -876,7 +876,6 @@ static void btf_dump_emit_struct_def(struct btf_dump *d,
12489 __u16 vlen = btf_vlen(t);
12490
12491 packed = is_struct ? btf_is_struct_packed(d->btf, id, t) : 0;
12492 - align = packed ? 1 : btf_align_of(d->btf, id);
12493
12494 btf_dump_printf(d, "%s%s%s {",
12495 is_struct ? "struct" : "union",
12496 @@ -906,6 +905,13 @@ static void btf_dump_emit_struct_def(struct btf_dump *d,
12497 btf_dump_printf(d, ";");
12498 }
12499
12500 + /* pad at the end, if necessary */
12501 + if (is_struct) {
12502 + align = packed ? 1 : btf_align_of(d->btf, id);
12503 + btf_dump_emit_bit_padding(d, off, t->size * 8, 0, align,
12504 + lvl + 1);
12505 + }
12506 +
12507 if (vlen)
12508 btf_dump_printf(d, "\n");
12509 btf_dump_printf(d, "%s}", pfx(lvl));
12510 diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
12511 index e0276520171b..a267cd0c0ce2 100644
12512 --- a/tools/lib/bpf/libbpf.c
12513 +++ b/tools/lib/bpf/libbpf.c
12514 @@ -1897,16 +1897,22 @@ int bpf_map__reuse_fd(struct bpf_map *map, int fd)
12515 return -errno;
12516
12517 new_fd = open("/", O_RDONLY | O_CLOEXEC);
12518 - if (new_fd < 0)
12519 + if (new_fd < 0) {
12520 + err = -errno;
12521 goto err_free_new_name;
12522 + }
12523
12524 new_fd = dup3(fd, new_fd, O_CLOEXEC);
12525 - if (new_fd < 0)
12526 + if (new_fd < 0) {
12527 + err = -errno;
12528 goto err_close_new_fd;
12529 + }
12530
12531 err = zclose(map->fd);
12532 - if (err)
12533 + if (err) {
12534 + err = -errno;
12535 goto err_close_new_fd;
12536 + }
12537 free(map->name);
12538
12539 map->fd = new_fd;
12540 @@ -1925,7 +1931,7 @@ err_close_new_fd:
12541 close(new_fd);
12542 err_free_new_name:
12543 free(new_name);
12544 - return -errno;
12545 + return err;
12546 }
12547
12548 int bpf_map__resize(struct bpf_map *map, __u32 max_entries)
12549 diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
12550 index a902838f9fcc..70f9e10de286 100644
12551 --- a/tools/lib/bpf/xsk.c
12552 +++ b/tools/lib/bpf/xsk.c
12553 @@ -163,6 +163,7 @@ int xsk_umem__create_v0_0_4(struct xsk_umem **umem_ptr, void *umem_area,
12554 umem->umem_area = umem_area;
12555 xsk_set_umem_config(&umem->config, usr_config);
12556
12557 + memset(&mr, 0, sizeof(mr));
12558 mr.addr = (uintptr_t)umem_area;
12559 mr.len = size;
12560 mr.chunk_size = umem->config.frame_size;
12561 @@ -343,13 +344,18 @@ static int xsk_get_max_queues(struct xsk_socket *xsk)
12562 goto out;
12563 }
12564
12565 - if (err || channels.max_combined == 0)
12566 + if (err) {
12567 /* If the device says it has no channels, then all traffic
12568 * is sent to a single stream, so max queues = 1.
12569 */
12570 ret = 1;
12571 - else
12572 - ret = channels.max_combined;
12573 + } else {
12574 + /* Take the max of rx, tx, combined. Drivers return
12575 + * the number of channels in different ways.
12576 + */
12577 + ret = max(channels.max_rx, channels.max_tx);
12578 + ret = max(ret, (int)channels.max_combined);
12579 + }
12580
12581 out:
12582 close(fd);
12583 @@ -465,6 +471,8 @@ static int xsk_setup_xdp_prog(struct xsk_socket *xsk)
12584 }
12585 } else {
12586 xsk->prog_fd = bpf_prog_get_fd_by_id(prog_id);
12587 + if (xsk->prog_fd < 0)
12588 + return -errno;
12589 err = xsk_lookup_bpf_maps(xsk);
12590 if (err) {
12591 close(xsk->prog_fd);
12592 diff --git a/tools/lib/subcmd/Makefile b/tools/lib/subcmd/Makefile
12593 index 5b2cd5e58df0..5dbb0dde208c 100644
12594 --- a/tools/lib/subcmd/Makefile
12595 +++ b/tools/lib/subcmd/Makefile
12596 @@ -28,7 +28,9 @@ ifeq ($(DEBUG),0)
12597 endif
12598 endif
12599
12600 -ifeq ($(CC_NO_CLANG), 0)
12601 +ifeq ($(DEBUG),1)
12602 + CFLAGS += -O0
12603 +else ifeq ($(CC_NO_CLANG), 0)
12604 CFLAGS += -O3
12605 else
12606 CFLAGS += -O6
12607 diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
12608 index 552592d153fb..f3cbf86e51ac 100644
12609 --- a/tools/lib/traceevent/parse-filter.c
12610 +++ b/tools/lib/traceevent/parse-filter.c
12611 @@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
12612 if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
12613 /* Add trivial event */
12614 arg = allocate_arg();
12615 - if (arg == NULL)
12616 + if (arg == NULL) {
12617 + free(str);
12618 return -1;
12619 + }
12620
12621 arg->type = TEP_FILTER_ARG_BOOLEAN;
12622 if (strcmp(str, "TRUE") == 0)
12623 @@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
12624 arg->boolean.value = 0;
12625
12626 filter_type = add_filter_type(filter, event->id);
12627 - if (filter_type == NULL)
12628 + if (filter_type == NULL) {
12629 + free(str);
12630 + free_arg(arg);
12631 return -1;
12632 + }
12633
12634 filter_type->filter = arg;
12635
12636 diff --git a/tools/memory-model/linux-kernel.cat b/tools/memory-model/linux-kernel.cat
12637 index ea2ff4b94074..2a9b4fe4a84e 100644
12638 --- a/tools/memory-model/linux-kernel.cat
12639 +++ b/tools/memory-model/linux-kernel.cat
12640 @@ -197,7 +197,7 @@ empty (wr-incoh | rw-incoh | ww-incoh) as plain-coherence
12641 (* Actual races *)
12642 let ww-nonrace = ww-vis & ((Marked * W) | rw-xbstar) & ((W * Marked) | wr-vis)
12643 let ww-race = (pre-race & co) \ ww-nonrace
12644 -let wr-race = (pre-race & (co? ; rf)) \ wr-vis
12645 +let wr-race = (pre-race & (co? ; rf)) \ wr-vis \ rw-xbstar^-1
12646 let rw-race = (pre-race & fr) \ rw-xbstar
12647
12648 flag ~empty (ww-race | wr-race | rw-race) as data-race
12649 diff --git a/tools/objtool/check.c b/tools/objtool/check.c
12650 index 044c9a3cb247..f53d3c515cdc 100644
12651 --- a/tools/objtool/check.c
12652 +++ b/tools/objtool/check.c
12653 @@ -481,6 +481,7 @@ static const char *uaccess_safe_builtin[] = {
12654 "ubsan_type_mismatch_common",
12655 "__ubsan_handle_type_mismatch",
12656 "__ubsan_handle_type_mismatch_v1",
12657 + "__ubsan_handle_shift_out_of_bounds",
12658 /* misc */
12659 "csum_partial_copy_generic",
12660 "__memcpy_mcsafe",
12661 diff --git a/tools/perf/arch/arm64/util/sym-handling.c b/tools/perf/arch/arm64/util/sym-handling.c
12662 index 5df788985130..8dfa3e5229f1 100644
12663 --- a/tools/perf/arch/arm64/util/sym-handling.c
12664 +++ b/tools/perf/arch/arm64/util/sym-handling.c
12665 @@ -6,9 +6,10 @@
12666
12667 #include "symbol.h" // for the elf__needs_adjust_symbols() prototype
12668 #include <stdbool.h>
12669 -#include <gelf.h>
12670
12671 #ifdef HAVE_LIBELF_SUPPORT
12672 +#include <gelf.h>
12673 +
12674 bool elf__needs_adjust_symbols(GElf_Ehdr ehdr)
12675 {
12676 return ehdr.e_type == ET_EXEC ||
12677 diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
12678 index aae0e57c60fb..7accaf8ef689 100644
12679 --- a/tools/perf/builtin-report.c
12680 +++ b/tools/perf/builtin-report.c
12681 @@ -399,6 +399,13 @@ static int report__setup_sample_type(struct report *rep)
12682 PERF_SAMPLE_BRANCH_ANY))
12683 rep->nonany_branch_mode = true;
12684
12685 +#ifndef HAVE_LIBUNWIND_SUPPORT
12686 + if (dwarf_callchain_users) {
12687 + ui__warning("Please install libunwind development packages "
12688 + "during the perf build.\n");
12689 + }
12690 +#endif
12691 +
12692 return 0;
12693 }
12694
12695 diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json
12696 index 0d1556fcdffe..99f4fc425564 100644
12697 --- a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json
12698 +++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json
12699 @@ -15,7 +15,7 @@
12700 },
12701 {
12702 "EventCode": "0x04",
12703 - "EventName": "uncore_hisi_ddrc.flux_wr",
12704 + "EventName": "uncore_hisi_ddrc.pre_cmd",
12705 "BriefDescription": "DDRC precharge commands",
12706 "PublicDescription": "DDRC precharge commands",
12707 "Unit": "hisi_sccl,ddrc",
12708 diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
12709 index e2837260ca4d..99e3fd04a5cb 100644
12710 --- a/tools/perf/pmu-events/jevents.c
12711 +++ b/tools/perf/pmu-events/jevents.c
12712 @@ -758,6 +758,7 @@ static int process_mapfile(FILE *outfp, char *fpath)
12713 char *line, *p;
12714 int line_num;
12715 char *tblname;
12716 + int ret = 0;
12717
12718 pr_info("%s: Processing mapfile %s\n", prog, fpath);
12719
12720 @@ -769,6 +770,7 @@ static int process_mapfile(FILE *outfp, char *fpath)
12721 if (!mapfp) {
12722 pr_info("%s: Error %s opening %s\n", prog, strerror(errno),
12723 fpath);
12724 + free(line);
12725 return -1;
12726 }
12727
12728 @@ -795,7 +797,8 @@ static int process_mapfile(FILE *outfp, char *fpath)
12729 /* TODO Deal with lines longer than 16K */
12730 pr_info("%s: Mapfile %s: line %d too long, aborting\n",
12731 prog, fpath, line_num);
12732 - return -1;
12733 + ret = -1;
12734 + goto out;
12735 }
12736 line[strlen(line)-1] = '\0';
12737
12738 @@ -825,7 +828,9 @@ static int process_mapfile(FILE *outfp, char *fpath)
12739
12740 out:
12741 print_mapping_table_suffix(outfp);
12742 - return 0;
12743 + fclose(mapfp);
12744 + free(line);
12745 + return ret;
12746 }
12747
12748 /*
12749 @@ -1122,6 +1127,7 @@ int main(int argc, char *argv[])
12750 goto empty_map;
12751 } else if (rc < 0) {
12752 /* Make build fail */
12753 + fclose(eventsfp);
12754 free_arch_std_events();
12755 return 1;
12756 } else if (rc) {
12757 @@ -1134,6 +1140,7 @@ int main(int argc, char *argv[])
12758 goto empty_map;
12759 } else if (rc < 0) {
12760 /* Make build fail */
12761 + fclose(eventsfp);
12762 free_arch_std_events();
12763 return 1;
12764 } else if (rc) {
12765 @@ -1151,6 +1158,8 @@ int main(int argc, char *argv[])
12766 if (process_mapfile(eventsfp, mapfile)) {
12767 pr_info("%s: Error processing mapfile %s\n", prog, mapfile);
12768 /* Make build fail */
12769 + fclose(eventsfp);
12770 + free_arch_std_events();
12771 return 1;
12772 }
12773
12774 diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
12775 index c1c2c13de254..166f411568a5 100644
12776 --- a/tools/perf/tests/bp_signal.c
12777 +++ b/tools/perf/tests/bp_signal.c
12778 @@ -49,14 +49,6 @@ asm (
12779 "__test_function:\n"
12780 "incq (%rdi)\n"
12781 "ret\n");
12782 -#elif defined (__aarch64__)
12783 -extern void __test_function(volatile long *ptr);
12784 -asm (
12785 - ".globl __test_function\n"
12786 - "__test_function:\n"
12787 - "str x30, [x0]\n"
12788 - "ret\n");
12789 -
12790 #else
12791 static void __test_function(volatile long *ptr)
12792 {
12793 @@ -302,10 +294,15 @@ bool test__bp_signal_is_supported(void)
12794 * stepping into the SIGIO handler and getting stuck on the
12795 * breakpointed instruction.
12796 *
12797 + * Since arm64 has the same issue with arm for the single-step
12798 + * handling, this case also gets suck on the breakpointed
12799 + * instruction.
12800 + *
12801 * Just disable the test for these architectures until these
12802 * issues are resolved.
12803 */
12804 -#if defined(__powerpc__) || defined(__s390x__) || defined(__arm__)
12805 +#if defined(__powerpc__) || defined(__s390x__) || defined(__arm__) || \
12806 + defined(__aarch64__)
12807 return false;
12808 #else
12809 return true;
12810 diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
12811 index bce3a4cb4c89..d85c9f608564 100644
12812 --- a/tools/perf/tests/task-exit.c
12813 +++ b/tools/perf/tests/task-exit.c
12814 @@ -53,6 +53,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
12815 struct perf_cpu_map *cpus;
12816 struct perf_thread_map *threads;
12817 struct mmap *md;
12818 + int retry_count = 0;
12819
12820 signal(SIGCHLD, sig_handler);
12821
12822 @@ -110,6 +111,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
12823 if (evlist__mmap(evlist, 128) < 0) {
12824 pr_debug("failed to mmap events: %d (%s)\n", errno,
12825 str_error_r(errno, sbuf, sizeof(sbuf)));
12826 + err = -1;
12827 goto out_delete_evlist;
12828 }
12829
12830 @@ -131,6 +133,13 @@ retry:
12831 out_init:
12832 if (!exited || !nr_exit) {
12833 evlist__poll(evlist, -1);
12834 +
12835 + if (retry_count++ > 1000) {
12836 + pr_debug("Failed after retrying 1000 times\n");
12837 + err = -1;
12838 + goto out_free_maps;
12839 + }
12840 +
12841 goto retry;
12842 }
12843
12844 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
12845 index 4ba0f871f086..f5f855fff412 100644
12846 --- a/tools/perf/util/cs-etm.c
12847 +++ b/tools/perf/util/cs-etm.c
12848 @@ -110,7 +110,7 @@ static int cs_etm__decode_data_block(struct cs_etm_queue *etmq);
12849 * encode the etm queue number as the upper 16 bit and the channel as
12850 * the lower 16 bit.
12851 */
12852 -#define TO_CS_QUEUE_NR(queue_nr, trace_id_chan) \
12853 +#define TO_CS_QUEUE_NR(queue_nr, trace_chan_id) \
12854 (queue_nr << 16 | trace_chan_id)
12855 #define TO_QUEUE_NR(cs_queue_nr) (cs_queue_nr >> 16)
12856 #define TO_TRACE_CHAN_ID(cs_queue_nr) (cs_queue_nr & 0x0000ffff)
12857 @@ -819,7 +819,7 @@ static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm,
12858 * Note that packets decoded above are still in the traceID's packet
12859 * queue and will be processed in cs_etm__process_queues().
12860 */
12861 - cs_queue_nr = TO_CS_QUEUE_NR(queue_nr, trace_id_chan);
12862 + cs_queue_nr = TO_CS_QUEUE_NR(queue_nr, trace_chan_id);
12863 ret = auxtrace_heap__add(&etm->heap, cs_queue_nr, timestamp);
12864 out:
12865 return ret;
12866 diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
12867 index df6cee5c071f..5544bfbd0f6c 100644
12868 --- a/tools/perf/util/dwarf-aux.c
12869 +++ b/tools/perf/util/dwarf-aux.c
12870 @@ -307,21 +307,51 @@ bool die_is_func_def(Dwarf_Die *dw_die)
12871 dwarf_attr(dw_die, DW_AT_declaration, &attr) == NULL);
12872 }
12873
12874 +/**
12875 + * die_entrypc - Returns entry PC (the lowest address) of a DIE
12876 + * @dw_die: a DIE
12877 + * @addr: where to store entry PC
12878 + *
12879 + * Since dwarf_entrypc() does not return entry PC if the DIE has only address
12880 + * range, we have to use this to retrieve the lowest address from the address
12881 + * range attribute.
12882 + */
12883 +int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr)
12884 +{
12885 + Dwarf_Addr base, end;
12886 +
12887 + if (!addr)
12888 + return -EINVAL;
12889 +
12890 + if (dwarf_entrypc(dw_die, addr) == 0)
12891 + return 0;
12892 +
12893 + return dwarf_ranges(dw_die, 0, &base, addr, &end) < 0 ? -ENOENT : 0;
12894 +}
12895 +
12896 /**
12897 * die_is_func_instance - Ensure that this DIE is an instance of a subprogram
12898 * @dw_die: a DIE
12899 *
12900 * Ensure that this DIE is an instance (which has an entry address).
12901 - * This returns true if @dw_die is a function instance. If not, you need to
12902 - * call die_walk_instances() to find actual instances.
12903 + * This returns true if @dw_die is a function instance. If not, the @dw_die
12904 + * must be a prototype. You can use die_walk_instances() to find actual
12905 + * instances.
12906 **/
12907 bool die_is_func_instance(Dwarf_Die *dw_die)
12908 {
12909 Dwarf_Addr tmp;
12910 + Dwarf_Attribute attr_mem;
12911 + int tag = dwarf_tag(dw_die);
12912
12913 - /* Actually gcc optimizes non-inline as like as inlined */
12914 - return !dwarf_func_inline(dw_die) && dwarf_entrypc(dw_die, &tmp) == 0;
12915 + if (tag != DW_TAG_subprogram &&
12916 + tag != DW_TAG_inlined_subroutine)
12917 + return false;
12918 +
12919 + return dwarf_entrypc(dw_die, &tmp) == 0 ||
12920 + dwarf_attr(dw_die, DW_AT_ranges, &attr_mem) != NULL;
12921 }
12922 +
12923 /**
12924 * die_get_data_member_location - Get the data-member offset
12925 * @mb_die: a DIE of a member of a data structure
12926 @@ -598,6 +628,9 @@ static int __die_walk_instances_cb(Dwarf_Die *inst, void *data)
12927 Dwarf_Die *origin;
12928 int tmp;
12929
12930 + if (!die_is_func_instance(inst))
12931 + return DIE_FIND_CB_CONTINUE;
12932 +
12933 attr = dwarf_attr(inst, DW_AT_abstract_origin, &attr_mem);
12934 if (attr == NULL)
12935 return DIE_FIND_CB_CONTINUE;
12936 @@ -669,15 +702,14 @@ static int __die_walk_funclines_cb(Dwarf_Die *in_die, void *data)
12937 if (dwarf_tag(in_die) == DW_TAG_inlined_subroutine) {
12938 fname = die_get_call_file(in_die);
12939 lineno = die_get_call_lineno(in_die);
12940 - if (fname && lineno > 0 && dwarf_entrypc(in_die, &addr) == 0) {
12941 + if (fname && lineno > 0 && die_entrypc(in_die, &addr) == 0) {
12942 lw->retval = lw->callback(fname, lineno, addr, lw->data);
12943 if (lw->retval != 0)
12944 return DIE_FIND_CB_END;
12945 }
12946 + if (!lw->recursive)
12947 + return DIE_FIND_CB_SIBLING;
12948 }
12949 - if (!lw->recursive)
12950 - /* Don't need to search recursively */
12951 - return DIE_FIND_CB_SIBLING;
12952
12953 if (addr) {
12954 fname = dwarf_decl_file(in_die);
12955 @@ -710,7 +742,7 @@ static int __die_walk_funclines(Dwarf_Die *sp_die, bool recursive,
12956 /* Handle function declaration line */
12957 fname = dwarf_decl_file(sp_die);
12958 if (fname && dwarf_decl_line(sp_die, &lineno) == 0 &&
12959 - dwarf_entrypc(sp_die, &addr) == 0) {
12960 + die_entrypc(sp_die, &addr) == 0) {
12961 lw.retval = callback(fname, lineno, addr, data);
12962 if (lw.retval != 0)
12963 goto done;
12964 @@ -724,6 +756,10 @@ static int __die_walk_culines_cb(Dwarf_Die *sp_die, void *data)
12965 {
12966 struct __line_walk_param *lw = data;
12967
12968 + /*
12969 + * Since inlined function can include another inlined function in
12970 + * the same file, we need to walk in it recursively.
12971 + */
12972 lw->retval = __die_walk_funclines(sp_die, true, lw->callback, lw->data);
12973 if (lw->retval != 0)
12974 return DWARF_CB_ABORT;
12975 @@ -748,11 +784,12 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
12976 Dwarf_Lines *lines;
12977 Dwarf_Line *line;
12978 Dwarf_Addr addr;
12979 - const char *fname, *decf = NULL;
12980 + const char *fname, *decf = NULL, *inf = NULL;
12981 int lineno, ret = 0;
12982 int decl = 0, inl;
12983 Dwarf_Die die_mem, *cu_die;
12984 size_t nlines, i;
12985 + bool flag;
12986
12987 /* Get the CU die */
12988 if (dwarf_tag(rt_die) != DW_TAG_compile_unit) {
12989 @@ -783,6 +820,12 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
12990 "Possible error in debuginfo.\n");
12991 continue;
12992 }
12993 + /* Skip end-of-sequence */
12994 + if (dwarf_lineendsequence(line, &flag) != 0 || flag)
12995 + continue;
12996 + /* Skip Non statement line-info */
12997 + if (dwarf_linebeginstatement(line, &flag) != 0 || !flag)
12998 + continue;
12999 /* Filter lines based on address */
13000 if (rt_die != cu_die) {
13001 /*
13002 @@ -792,13 +835,21 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
13003 */
13004 if (!dwarf_haspc(rt_die, addr))
13005 continue;
13006 +
13007 if (die_find_inlinefunc(rt_die, addr, &die_mem)) {
13008 + /* Call-site check */
13009 + inf = die_get_call_file(&die_mem);
13010 + if ((inf && !strcmp(inf, decf)) &&
13011 + die_get_call_lineno(&die_mem) == lineno)
13012 + goto found;
13013 +
13014 dwarf_decl_line(&die_mem, &inl);
13015 if (inl != decl ||
13016 decf != dwarf_decl_file(&die_mem))
13017 continue;
13018 }
13019 }
13020 +found:
13021 /* Get source line */
13022 fname = dwarf_linesrc(line, NULL, NULL);
13023
13024 @@ -813,8 +864,9 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
13025 */
13026 if (rt_die != cu_die)
13027 /*
13028 - * Don't need walk functions recursively, because nested
13029 - * inlined functions don't have lines of the specified DIE.
13030 + * Don't need walk inlined functions recursively, because
13031 + * inner inlined functions don't have the lines of the
13032 + * specified function.
13033 */
13034 ret = __die_walk_funclines(rt_die, false, callback, data);
13035 else {
13036 @@ -989,7 +1041,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die,
13037 bool first = true;
13038 const char *name;
13039
13040 - ret = dwarf_entrypc(sp_die, &entry);
13041 + ret = die_entrypc(sp_die, &entry);
13042 if (ret)
13043 return ret;
13044
13045 @@ -1052,7 +1104,7 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)
13046 bool first = true;
13047 const char *name;
13048
13049 - ret = dwarf_entrypc(sp_die, &entry);
13050 + ret = die_entrypc(sp_die, &entry);
13051 if (ret)
13052 return ret;
13053
13054 diff --git a/tools/perf/util/dwarf-aux.h b/tools/perf/util/dwarf-aux.h
13055 index f204e5892403..506006e0cf66 100644
13056 --- a/tools/perf/util/dwarf-aux.h
13057 +++ b/tools/perf/util/dwarf-aux.h
13058 @@ -29,6 +29,9 @@ int cu_walk_functions_at(Dwarf_Die *cu_die, Dwarf_Addr addr,
13059 /* Get DW_AT_linkage_name (should be NULL for C binary) */
13060 const char *die_get_linkage_name(Dwarf_Die *dw_die);
13061
13062 +/* Get the lowest PC in DIE (including range list) */
13063 +int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr);
13064 +
13065 /* Ensure that this DIE is a subprogram and definition (not declaration) */
13066 bool die_is_func_def(Dwarf_Die *dw_die);
13067
13068 diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
13069 index b5e2adef49de..422ad1888e74 100644
13070 --- a/tools/perf/util/parse-events.c
13071 +++ b/tools/perf/util/parse-events.c
13072 @@ -1365,8 +1365,15 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
13073 if (get_config_terms(head_config, &config_terms))
13074 return -ENOMEM;
13075
13076 - if (perf_pmu__config(pmu, &attr, head_config, parse_state->error))
13077 + if (perf_pmu__config(pmu, &attr, head_config, parse_state->error)) {
13078 + struct perf_evsel_config_term *pos, *tmp;
13079 +
13080 + list_for_each_entry_safe(pos, tmp, &config_terms, list) {
13081 + list_del_init(&pos->list);
13082 + free(pos);
13083 + }
13084 return -EINVAL;
13085 + }
13086
13087 evsel = __add_event(list, &parse_state->idx, &attr,
13088 get_config_name(head_config), pmu,
13089 @@ -1927,15 +1934,20 @@ int parse_events(struct evlist *evlist, const char *str,
13090
13091 ret = parse_events__scanner(str, &parse_state, PE_START_EVENTS);
13092 perf_pmu__parse_cleanup();
13093 +
13094 + if (!ret && list_empty(&parse_state.list)) {
13095 + WARN_ONCE(true, "WARNING: event parser found nothing\n");
13096 + return -1;
13097 + }
13098 +
13099 + /*
13100 + * Add list to the evlist even with errors to allow callers to clean up.
13101 + */
13102 + perf_evlist__splice_list_tail(evlist, &parse_state.list);
13103 +
13104 if (!ret) {
13105 struct evsel *last;
13106
13107 - if (list_empty(&parse_state.list)) {
13108 - WARN_ONCE(true, "WARNING: event parser found nothing\n");
13109 - return -1;
13110 - }
13111 -
13112 - perf_evlist__splice_list_tail(evlist, &parse_state.list);
13113 evlist->nr_groups += parse_state.nr_groups;
13114 last = evlist__last(evlist);
13115 last->cmdline_group_boundary = true;
13116 diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
13117 index cd9f95e5044e..08cccd86447c 100644
13118 --- a/tools/perf/util/probe-finder.c
13119 +++ b/tools/perf/util/probe-finder.c
13120 @@ -756,6 +756,16 @@ static int find_best_scope_cb(Dwarf_Die *fn_die, void *data)
13121 return 0;
13122 }
13123
13124 +/* Return innermost DIE */
13125 +static int find_inner_scope_cb(Dwarf_Die *fn_die, void *data)
13126 +{
13127 + struct find_scope_param *fsp = data;
13128 +
13129 + memcpy(fsp->die_mem, fn_die, sizeof(Dwarf_Die));
13130 + fsp->found = true;
13131 + return 1;
13132 +}
13133 +
13134 /* Find an appropriate scope fits to given conditions */
13135 static Dwarf_Die *find_best_scope(struct probe_finder *pf, Dwarf_Die *die_mem)
13136 {
13137 @@ -767,8 +777,13 @@ static Dwarf_Die *find_best_scope(struct probe_finder *pf, Dwarf_Die *die_mem)
13138 .die_mem = die_mem,
13139 .found = false,
13140 };
13141 + int ret;
13142
13143 - cu_walk_functions_at(&pf->cu_die, pf->addr, find_best_scope_cb, &fsp);
13144 + ret = cu_walk_functions_at(&pf->cu_die, pf->addr, find_best_scope_cb,
13145 + &fsp);
13146 + if (!ret && !fsp.found)
13147 + cu_walk_functions_at(&pf->cu_die, pf->addr,
13148 + find_inner_scope_cb, &fsp);
13149
13150 return fsp.found ? die_mem : NULL;
13151 }
13152 @@ -942,7 +957,7 @@ static int probe_point_inline_cb(Dwarf_Die *in_die, void *data)
13153 ret = find_probe_point_lazy(in_die, pf);
13154 else {
13155 /* Get probe address */
13156 - if (dwarf_entrypc(in_die, &addr) != 0) {
13157 + if (die_entrypc(in_die, &addr) != 0) {
13158 pr_warning("Failed to get entry address of %s.\n",
13159 dwarf_diename(in_die));
13160 return -ENOENT;
13161 @@ -994,7 +1009,7 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data)
13162 param->retval = find_probe_point_by_line(pf);
13163 } else if (die_is_func_instance(sp_die)) {
13164 /* Instances always have the entry address */
13165 - dwarf_entrypc(sp_die, &pf->addr);
13166 + die_entrypc(sp_die, &pf->addr);
13167 /* But in some case the entry address is 0 */
13168 if (pf->addr == 0) {
13169 pr_debug("%s has no entry PC. Skipped\n",
13170 @@ -1425,6 +1440,18 @@ error:
13171 return DIE_FIND_CB_END;
13172 }
13173
13174 +static bool available_var_finder_overlap(struct available_var_finder *af)
13175 +{
13176 + int i;
13177 +
13178 + for (i = 0; i < af->nvls; i++) {
13179 + if (af->pf.addr == af->vls[i].point.address)
13180 + return true;
13181 + }
13182 + return false;
13183 +
13184 +}
13185 +
13186 /* Add a found vars into available variables list */
13187 static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
13188 {
13189 @@ -1435,6 +1462,14 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
13190 Dwarf_Die die_mem;
13191 int ret;
13192
13193 + /*
13194 + * For some reason (e.g. different column assigned to same address),
13195 + * this callback can be called with the address which already passed.
13196 + * Ignore it first.
13197 + */
13198 + if (available_var_finder_overlap(af))
13199 + return 0;
13200 +
13201 /* Check number of tevs */
13202 if (af->nvls == af->max_vls) {
13203 pr_warning("Too many( > %d) probe point found.\n", af->max_vls);
13204 @@ -1578,7 +1613,7 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
13205 /* Get function entry information */
13206 func = basefunc = dwarf_diename(&spdie);
13207 if (!func ||
13208 - dwarf_entrypc(&spdie, &baseaddr) != 0 ||
13209 + die_entrypc(&spdie, &baseaddr) != 0 ||
13210 dwarf_decl_line(&spdie, &baseline) != 0) {
13211 lineno = 0;
13212 goto post;
13213 @@ -1595,7 +1630,7 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
13214 while (die_find_top_inlinefunc(&spdie, (Dwarf_Addr)addr,
13215 &indie)) {
13216 /* There is an inline function */
13217 - if (dwarf_entrypc(&indie, &_addr) == 0 &&
13218 + if (die_entrypc(&indie, &_addr) == 0 &&
13219 _addr == addr) {
13220 /*
13221 * addr is at an inline function entry.
13222 diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
13223 index 061bb4d6a3f5..5c172845fa5a 100644
13224 --- a/tools/perf/util/session.c
13225 +++ b/tools/perf/util/session.c
13226 @@ -1954,8 +1954,8 @@ out_err:
13227 }
13228
13229 static union perf_event *
13230 -fetch_mmaped_event(struct perf_session *session,
13231 - u64 head, size_t mmap_size, char *buf)
13232 +prefetch_event(char *buf, u64 head, size_t mmap_size,
13233 + bool needs_swap, union perf_event *error)
13234 {
13235 union perf_event *event;
13236
13237 @@ -1967,20 +1967,32 @@ fetch_mmaped_event(struct perf_session *session,
13238 return NULL;
13239
13240 event = (union perf_event *)(buf + head);
13241 + if (needs_swap)
13242 + perf_event_header__bswap(&event->header);
13243
13244 - if (session->header.needs_swap)
13245 + if (head + event->header.size <= mmap_size)
13246 + return event;
13247 +
13248 + /* We're not fetching the event so swap back again */
13249 + if (needs_swap)
13250 perf_event_header__bswap(&event->header);
13251
13252 - if (head + event->header.size > mmap_size) {
13253 - /* We're not fetching the event so swap back again */
13254 - if (session->header.needs_swap)
13255 - perf_event_header__bswap(&event->header);
13256 - pr_debug("%s: head=%#" PRIx64 " event->header_size=%#x, mmap_size=%#zx: fuzzed perf.data?\n",
13257 - __func__, head, event->header.size, mmap_size);
13258 - return ERR_PTR(-EINVAL);
13259 - }
13260 + pr_debug("%s: head=%#" PRIx64 " event->header_size=%#x, mmap_size=%#zx:"
13261 + " fuzzed or compressed perf.data?\n",__func__, head, event->header.size, mmap_size);
13262
13263 - return event;
13264 + return error;
13265 +}
13266 +
13267 +static union perf_event *
13268 +fetch_mmaped_event(u64 head, size_t mmap_size, char *buf, bool needs_swap)
13269 +{
13270 + return prefetch_event(buf, head, mmap_size, needs_swap, ERR_PTR(-EINVAL));
13271 +}
13272 +
13273 +static union perf_event *
13274 +fetch_decomp_event(u64 head, size_t mmap_size, char *buf, bool needs_swap)
13275 +{
13276 + return prefetch_event(buf, head, mmap_size, needs_swap, NULL);
13277 }
13278
13279 static int __perf_session__process_decomp_events(struct perf_session *session)
13280 @@ -1993,10 +2005,8 @@ static int __perf_session__process_decomp_events(struct perf_session *session)
13281 return 0;
13282
13283 while (decomp->head < decomp->size && !session_done()) {
13284 - union perf_event *event = fetch_mmaped_event(session, decomp->head, decomp->size, decomp->data);
13285 -
13286 - if (IS_ERR(event))
13287 - return PTR_ERR(event);
13288 + union perf_event *event = fetch_decomp_event(decomp->head, decomp->size, decomp->data,
13289 + session->header.needs_swap);
13290
13291 if (!event)
13292 break;
13293 @@ -2096,7 +2106,7 @@ remap:
13294 }
13295
13296 more:
13297 - event = fetch_mmaped_event(session, head, mmap_size, buf);
13298 + event = fetch_mmaped_event(head, mmap_size, buf, session->header.needs_swap);
13299 if (IS_ERR(event))
13300 return PTR_ERR(event);
13301
13302 diff --git a/tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c b/tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c
13303 index 7c7451d3f494..58dbdfd4fa13 100644
13304 --- a/tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c
13305 +++ b/tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c
13306 @@ -39,7 +39,6 @@ static cstate_t hsw_ext_cstates[HSW_EXT_CSTATE_COUNT] = {
13307 {
13308 .name = "PC9",
13309 .desc = N_("Processor Package C9"),
13310 - .desc = N_("Processor Package C2"),
13311 .id = PC9,
13312 .range = RANGE_PACKAGE,
13313 .get_count_percent = hsw_ext_get_count_percent,
13314 diff --git a/tools/testing/selftests/bpf/cgroup_helpers.c b/tools/testing/selftests/bpf/cgroup_helpers.c
13315 index e95c33e333a4..b29a73fe64db 100644
13316 --- a/tools/testing/selftests/bpf/cgroup_helpers.c
13317 +++ b/tools/testing/selftests/bpf/cgroup_helpers.c
13318 @@ -98,7 +98,7 @@ int enable_all_controllers(char *cgroup_path)
13319 */
13320 int setup_cgroup_environment(void)
13321 {
13322 - char cgroup_workdir[PATH_MAX + 1];
13323 + char cgroup_workdir[PATH_MAX - 24];
13324
13325 format_cgroup_path(cgroup_workdir, "");
13326
13327 diff --git a/tools/testing/selftests/bpf/progs/btf_dump_test_case_padding.c b/tools/testing/selftests/bpf/progs/btf_dump_test_case_padding.c
13328 index 3a62119c7498..35c512818a56 100644
13329 --- a/tools/testing/selftests/bpf/progs/btf_dump_test_case_padding.c
13330 +++ b/tools/testing/selftests/bpf/progs/btf_dump_test_case_padding.c
13331 @@ -62,6 +62,10 @@ struct padded_a_lot {
13332 * long: 64;
13333 * long: 64;
13334 * int b;
13335 + * long: 32;
13336 + * long: 64;
13337 + * long: 64;
13338 + * long: 64;
13339 *};
13340 *
13341 */
13342 @@ -95,7 +99,6 @@ struct zone_padding {
13343 struct zone {
13344 int a;
13345 short b;
13346 - short: 16;
13347 struct zone_padding __pad__;
13348 };
13349
13350 diff --git a/tools/testing/selftests/bpf/progs/test_seg6_loop.c b/tools/testing/selftests/bpf/progs/test_seg6_loop.c
13351 index c4d104428643..69880c1e7700 100644
13352 --- a/tools/testing/selftests/bpf/progs/test_seg6_loop.c
13353 +++ b/tools/testing/selftests/bpf/progs/test_seg6_loop.c
13354 @@ -132,8 +132,10 @@ static __always_inline int is_valid_tlv_boundary(struct __sk_buff *skb,
13355 *pad_off = 0;
13356
13357 // we can only go as far as ~10 TLVs due to the BPF max stack size
13358 + // workaround: define induction variable "i" as "long" instead
13359 + // of "int" to prevent alu32 sub-register spilling.
13360 #pragma clang loop unroll(disable)
13361 - for (int i = 0; i < 100; i++) {
13362 + for (long i = 0; i < 100; i++) {
13363 struct sr6_tlv_t tlv;
13364
13365 if (cur_off == *tlv_off)
13366 diff --git a/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c b/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
13367 index 608a06871572..d22e438198cf 100644
13368 --- a/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
13369 +++ b/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
13370 @@ -44,7 +44,10 @@ int sysctl_tcp_mem(struct bpf_sysctl *ctx)
13371 unsigned long tcp_mem[TCP_MEM_LOOPS] = {};
13372 char value[MAX_VALUE_STR_LEN];
13373 unsigned char i, off = 0;
13374 - int ret;
13375 + /* a workaround to prevent compiler from generating
13376 + * codes verifier cannot handle yet.
13377 + */
13378 + volatile int ret;
13379
13380 if (ctx->write)
13381 return 0;
13382 diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
13383 index af75a1c7a458..3bf18364c67c 100644
13384 --- a/tools/testing/selftests/bpf/test_progs.c
13385 +++ b/tools/testing/selftests/bpf/test_progs.c
13386 @@ -20,7 +20,7 @@ struct prog_test_def {
13387 bool tested;
13388 bool need_cgroup_cleanup;
13389
13390 - const char *subtest_name;
13391 + char *subtest_name;
13392 int subtest_num;
13393
13394 /* store counts before subtest started */
13395 @@ -81,16 +81,17 @@ void test__end_subtest()
13396 fprintf(env.stdout, "#%d/%d %s:%s\n",
13397 test->test_num, test->subtest_num,
13398 test->subtest_name, sub_error_cnt ? "FAIL" : "OK");
13399 +
13400 + free(test->subtest_name);
13401 + test->subtest_name = NULL;
13402 }
13403
13404 bool test__start_subtest(const char *name)
13405 {
13406 struct prog_test_def *test = env.test;
13407
13408 - if (test->subtest_name) {
13409 + if (test->subtest_name)
13410 test__end_subtest();
13411 - test->subtest_name = NULL;
13412 - }
13413
13414 test->subtest_num++;
13415
13416 @@ -104,7 +105,13 @@ bool test__start_subtest(const char *name)
13417 if (!should_run(&env.subtest_selector, test->subtest_num, name))
13418 return false;
13419
13420 - test->subtest_name = name;
13421 + test->subtest_name = strdup(name);
13422 + if (!test->subtest_name) {
13423 + fprintf(env.stderr,
13424 + "Subtest #%d: failed to copy subtest name!\n",
13425 + test->subtest_num);
13426 + return false;
13427 + }
13428 env.test->old_error_cnt = env.test->error_cnt;
13429
13430 return true;
13431 diff --git a/tools/testing/selftests/bpf/test_tc_tunnel.sh b/tools/testing/selftests/bpf/test_tc_tunnel.sh
13432 index ff0d31d38061..7c76b841b17b 100755
13433 --- a/tools/testing/selftests/bpf/test_tc_tunnel.sh
13434 +++ b/tools/testing/selftests/bpf/test_tc_tunnel.sh
13435 @@ -62,6 +62,10 @@ cleanup() {
13436 if [[ -f "${infile}" ]]; then
13437 rm "${infile}"
13438 fi
13439 +
13440 + if [[ -n $server_pid ]]; then
13441 + kill $server_pid 2> /dev/null
13442 + fi
13443 }
13444
13445 server_listen() {
13446 @@ -77,6 +81,7 @@ client_connect() {
13447
13448 verify_data() {
13449 wait "${server_pid}"
13450 + server_pid=
13451 # sha1sum returns two fields [sha1] [filepath]
13452 # convert to bash array and access first elem
13453 insum=($(sha1sum ${infile}))
13454 diff --git a/tools/testing/selftests/net/forwarding/router_bridge_vlan.sh b/tools/testing/selftests/net/forwarding/router_bridge_vlan.sh
13455 index fef88eb4b873..fa6a88c50750 100755
13456 --- a/tools/testing/selftests/net/forwarding/router_bridge_vlan.sh
13457 +++ b/tools/testing/selftests/net/forwarding/router_bridge_vlan.sh
13458 @@ -36,7 +36,7 @@ h2_destroy()
13459 {
13460 ip -6 route del 2001:db8:1::/64 vrf v$h2
13461 ip -4 route del 192.0.2.0/28 vrf v$h2
13462 - simple_if_fini $h2 192.0.2.130/28
13463 + simple_if_fini $h2 192.0.2.130/28 2001:db8:2::2/64
13464 }
13465
13466 router_create()
13467 diff --git a/tools/testing/selftests/net/so_txtime.c b/tools/testing/selftests/net/so_txtime.c
13468 index 53f598f06647..34df4c8882af 100644
13469 --- a/tools/testing/selftests/net/so_txtime.c
13470 +++ b/tools/testing/selftests/net/so_txtime.c
13471 @@ -105,8 +105,8 @@ static void do_recv_one(int fdr, struct timed_send *ts)
13472 tstop = (gettime_ns() - glob_tstart) / 1000;
13473 texpect = ts->delay_us >= 0 ? ts->delay_us : 0;
13474
13475 - fprintf(stderr, "payload:%c delay:%ld expected:%ld (us)\n",
13476 - rbuf[0], tstop, texpect);
13477 + fprintf(stderr, "payload:%c delay:%lld expected:%lld (us)\n",
13478 + rbuf[0], (long long)tstop, (long long)texpect);
13479
13480 if (rbuf[0] != ts->data)
13481 error(1, 0, "payload mismatch. expected %c", ts->data);
13482 diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
13483 index 13e5ef615026..0ea44d975b6c 100644
13484 --- a/tools/testing/selftests/net/tls.c
13485 +++ b/tools/testing/selftests/net/tls.c
13486 @@ -722,34 +722,6 @@ TEST_F(tls, recv_lowat)
13487 EXPECT_EQ(memcmp(send_mem, recv_mem + 10, 5), 0);
13488 }
13489
13490 -TEST_F(tls, recv_rcvbuf)
13491 -{
13492 - char send_mem[4096];
13493 - char recv_mem[4096];
13494 - int rcv_buf = 1024;
13495 -
13496 - memset(send_mem, 0x1c, sizeof(send_mem));
13497 -
13498 - EXPECT_EQ(setsockopt(self->cfd, SOL_SOCKET, SO_RCVBUF,
13499 - &rcv_buf, sizeof(rcv_buf)), 0);
13500 -
13501 - EXPECT_EQ(send(self->fd, send_mem, 512, 0), 512);
13502 - memset(recv_mem, 0, sizeof(recv_mem));
13503 - EXPECT_EQ(recv(self->cfd, recv_mem, sizeof(recv_mem), 0), 512);
13504 - EXPECT_EQ(memcmp(send_mem, recv_mem, 512), 0);
13505 -
13506 - if (self->notls)
13507 - return;
13508 -
13509 - EXPECT_EQ(send(self->fd, send_mem, 4096, 0), 4096);
13510 - memset(recv_mem, 0, sizeof(recv_mem));
13511 - EXPECT_EQ(recv(self->cfd, recv_mem, sizeof(recv_mem), 0), -1);
13512 - EXPECT_EQ(errno, EMSGSIZE);
13513 -
13514 - EXPECT_EQ(recv(self->cfd, recv_mem, sizeof(recv_mem), 0), -1);
13515 - EXPECT_EQ(errno, EMSGSIZE);
13516 -}
13517 -
13518 TEST_F(tls, bidir)
13519 {
13520 char const *test_str = "test_read";
13521 diff --git a/tools/testing/selftests/net/udpgso.c b/tools/testing/selftests/net/udpgso.c
13522 index 614b31aad168..c66da6ffd6d8 100644
13523 --- a/tools/testing/selftests/net/udpgso.c
13524 +++ b/tools/testing/selftests/net/udpgso.c
13525 @@ -440,7 +440,8 @@ static bool __send_one(int fd, struct msghdr *msg, int flags)
13526 if (ret == -1)
13527 error(1, errno, "sendmsg");
13528 if (ret != msg->msg_iov->iov_len)
13529 - error(1, 0, "sendto: %d != %lu", ret, msg->msg_iov->iov_len);
13530 + error(1, 0, "sendto: %d != %llu", ret,
13531 + (unsigned long long)msg->msg_iov->iov_len);
13532 if (msg->msg_flags)
13533 error(1, 0, "sendmsg: return flags 0x%x\n", msg->msg_flags);
13534
13535 diff --git a/tools/testing/selftests/net/udpgso_bench_tx.c b/tools/testing/selftests/net/udpgso_bench_tx.c
13536 index ada99496634a..17512a43885e 100644
13537 --- a/tools/testing/selftests/net/udpgso_bench_tx.c
13538 +++ b/tools/testing/selftests/net/udpgso_bench_tx.c
13539 @@ -405,7 +405,8 @@ static int send_udp_segment(int fd, char *data)
13540 if (ret == -1)
13541 error(1, errno, "sendmsg");
13542 if (ret != iov.iov_len)
13543 - error(1, 0, "sendmsg: %u != %lu\n", ret, iov.iov_len);
13544 + error(1, 0, "sendmsg: %u != %llu\n", ret,
13545 + (unsigned long long)iov.iov_len);
13546
13547 return 1;
13548 }
13549 diff --git a/tools/testing/selftests/proc/proc-self-map-files-002.c b/tools/testing/selftests/proc/proc-self-map-files-002.c
13550 index 47b7473dedef..e6aa00a183bc 100644
13551 --- a/tools/testing/selftests/proc/proc-self-map-files-002.c
13552 +++ b/tools/testing/selftests/proc/proc-self-map-files-002.c
13553 @@ -47,7 +47,11 @@ static void fail(const char *fmt, unsigned long a, unsigned long b)
13554 int main(void)
13555 {
13556 const int PAGE_SIZE = sysconf(_SC_PAGESIZE);
13557 - const unsigned long va_max = 1UL << 32;
13558 + /*
13559 + * va_max must be enough bigger than vm.mmap_min_addr, which is
13560 + * 64KB/32KB by default. (depends on CONFIG_LSM_MMAP_MIN_ADDR)
13561 + */
13562 + const unsigned long va_max = 1UL << 20;
13563 unsigned long va;
13564 void *p;
13565 int fd;
13566 diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
13567 index 38b4c910b6c3..f23c9cd5684f 100644
13568 --- a/virt/kvm/arm/mmu.c
13569 +++ b/virt/kvm/arm/mmu.c
13570 @@ -38,6 +38,11 @@ static unsigned long io_map_base;
13571 #define KVM_S2PTE_FLAG_IS_IOMAP (1UL << 0)
13572 #define KVM_S2_FLAG_LOGGING_ACTIVE (1UL << 1)
13573
13574 +static bool is_iomap(unsigned long flags)
13575 +{
13576 + return flags & KVM_S2PTE_FLAG_IS_IOMAP;
13577 +}
13578 +
13579 static bool memslot_is_logging(struct kvm_memory_slot *memslot)
13580 {
13581 return memslot->dirty_bitmap && !(memslot->flags & KVM_MEM_READONLY);
13582 @@ -1698,6 +1703,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
13583
13584 vma_pagesize = vma_kernel_pagesize(vma);
13585 if (logging_active ||
13586 + (vma->vm_flags & VM_PFNMAP) ||
13587 !fault_supports_stage2_huge_mapping(memslot, hva, vma_pagesize)) {
13588 force_pte = true;
13589 vma_pagesize = PAGE_SIZE;
13590 @@ -1760,6 +1766,9 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
13591 writable = false;
13592 }
13593
13594 + if (exec_fault && is_iomap(flags))
13595 + return -ENOEXEC;
13596 +
13597 spin_lock(&kvm->mmu_lock);
13598 if (mmu_notifier_retry(kvm, mmu_seq))
13599 goto out_unlock;
13600 @@ -1781,7 +1790,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
13601 if (writable)
13602 kvm_set_pfn_dirty(pfn);
13603
13604 - if (fault_status != FSC_PERM)
13605 + if (fault_status != FSC_PERM && !is_iomap(flags))
13606 clean_dcache_guest_page(pfn, vma_pagesize);
13607
13608 if (exec_fault)
13609 @@ -1948,9 +1957,8 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run)
13610 if (kvm_is_error_hva(hva) || (write_fault && !writable)) {
13611 if (is_iabt) {
13612 /* Prefetch Abort on I/O address */
13613 - kvm_inject_pabt(vcpu, kvm_vcpu_get_hfar(vcpu));
13614 - ret = 1;
13615 - goto out_unlock;
13616 + ret = -ENOEXEC;
13617 + goto out;
13618 }
13619
13620 /*
13621 @@ -1992,6 +2000,11 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run)
13622 ret = user_mem_abort(vcpu, fault_ipa, memslot, hva, fault_status);
13623 if (ret == 0)
13624 ret = 1;
13625 +out:
13626 + if (ret == -ENOEXEC) {
13627 + kvm_inject_pabt(vcpu, kvm_vcpu_get_hfar(vcpu));
13628 + ret = 1;
13629 + }
13630 out_unlock:
13631 srcu_read_unlock(&vcpu->kvm->srcu, idx);
13632 return ret;