Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.4 commit in: /
Date: Wed, 14 Jul 2021 16:22:54
Message-Id: 1626279757.eedf65eda4a8688c2333cd822650a02289b905ea.mpagano@gentoo
1 commit: eedf65eda4a8688c2333cd822650a02289b905ea
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jul 14 16:22:37 2021 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Jul 14 16:22:37 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=eedf65ed
7
8 Linux patch 5.4.132
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1131_linux-5.4.132.patch | 10846 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 10850 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 4eacdd9..747a850 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -567,6 +567,10 @@ Patch: 1130_linux-5.4.131.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.4.131
23
24 +Patch: 1131_linux-5.4.132.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.4.132
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1131_linux-5.4.132.patch b/1131_linux-5.4.132.patch
33 new file mode 100644
34 index 0000000..0cce417
35 --- /dev/null
36 +++ b/1131_linux-5.4.132.patch
37 @@ -0,0 +1,10846 @@
38 +diff --git a/Documentation/ABI/testing/evm b/Documentation/ABI/testing/evm
39 +index 201d10319fa18..1df1177df68ad 100644
40 +--- a/Documentation/ABI/testing/evm
41 ++++ b/Documentation/ABI/testing/evm
42 +@@ -42,8 +42,30 @@ Description:
43 + modification of EVM-protected metadata and
44 + disable all further modification of policy
45 +
46 +- Note that once a key has been loaded, it will no longer be
47 +- possible to enable metadata modification.
48 ++ Echoing a value is additive, the new value is added to the
49 ++ existing initialization flags.
50 ++
51 ++ For example, after::
52 ++
53 ++ echo 2 ><securityfs>/evm
54 ++
55 ++ another echo can be performed::
56 ++
57 ++ echo 1 ><securityfs>/evm
58 ++
59 ++ and the resulting value will be 3.
60 ++
61 ++ Note that once an HMAC key has been loaded, it will no longer
62 ++ be possible to enable metadata modification. Signaling that an
63 ++ HMAC key has been loaded will clear the corresponding flag.
64 ++ For example, if the current value is 6 (2 and 4 set)::
65 ++
66 ++ echo 1 ><securityfs>/evm
67 ++
68 ++ will set the new value to 3 (4 cleared).
69 ++
70 ++ Loading an HMAC key is the only way to disable metadata
71 ++ modification.
72 +
73 + Until key loading has been signaled EVM can not create
74 + or validate the 'security.evm' xattr, but returns
75 +diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
76 +index a19ae163c0589..dbb68067ba4ea 100644
77 +--- a/Documentation/admin-guide/kernel-parameters.txt
78 ++++ b/Documentation/admin-guide/kernel-parameters.txt
79 +@@ -567,6 +567,12 @@
80 + loops can be debugged more effectively on production
81 + systems.
82 +
83 ++ clocksource.max_cswd_read_retries= [KNL]
84 ++ Number of clocksource_watchdog() retries due to
85 ++ external delays before the clock will be marked
86 ++ unstable. Defaults to three retries, that is,
87 ++ four attempts to read the clock under test.
88 ++
89 + clearcpuid=BITNUM[,BITNUM...] [X86]
90 + Disable CPUID feature X for the kernel. See
91 + arch/x86/include/asm/cpufeatures.h for the valid bit
92 +diff --git a/Documentation/hwmon/max31790.rst b/Documentation/hwmon/max31790.rst
93 +index 84c62a12ef3a8..f4749c44cfb8b 100644
94 +--- a/Documentation/hwmon/max31790.rst
95 ++++ b/Documentation/hwmon/max31790.rst
96 +@@ -38,6 +38,7 @@ Sysfs entries
97 + fan[1-12]_input RO fan tachometer speed in RPM
98 + fan[1-12]_fault RO fan experienced fault
99 + fan[1-6]_target RW desired fan speed in RPM
100 +-pwm[1-6]_enable RW regulator mode, 0=disabled, 1=manual mode, 2=rpm mode
101 +-pwm[1-6] RW fan target duty cycle (0-255)
102 ++pwm[1-6]_enable RW regulator mode, 0=disabled (duty cycle=0%), 1=manual mode, 2=rpm mode
103 ++pwm[1-6] RW read: current pwm duty cycle,
104 ++ write: target pwm duty cycle (0-255)
105 + ================== === =======================================================
106 +diff --git a/Makefile b/Makefile
107 +index 5e8716dbbadca..58ea876fa1834 100644
108 +--- a/Makefile
109 ++++ b/Makefile
110 +@@ -1,7 +1,7 @@
111 + # SPDX-License-Identifier: GPL-2.0
112 + VERSION = 5
113 + PATCHLEVEL = 4
114 +-SUBLEVEL = 131
115 ++SUBLEVEL = 132
116 + EXTRAVERSION =
117 + NAME = Kleptomaniac Octopus
118 +
119 +@@ -937,7 +937,7 @@ LDFLAGS_vmlinux += $(call ld-option, -X,)
120 + endif
121 +
122 + ifeq ($(CONFIG_RELR),y)
123 +-LDFLAGS_vmlinux += --pack-dyn-relocs=relr
124 ++LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags
125 + endif
126 +
127 + # make the checker run with the right architecture
128 +diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
129 +index 6ab27a7b388d4..a4cef07c38cbd 100644
130 +--- a/arch/arm/boot/dts/sama5d4.dtsi
131 ++++ b/arch/arm/boot/dts/sama5d4.dtsi
132 +@@ -914,7 +914,7 @@
133 + 0xffffffff 0x3ffcfe7c 0x1c010101 /* pioA */
134 + 0x7fffffff 0xfffccc3a 0x3f00cc3a /* pioB */
135 + 0xffffffff 0x3ff83fff 0xff00ffff /* pioC */
136 +- 0x0003ff00 0x8002a800 0x00000000 /* pioD */
137 ++ 0xb003ff00 0x8002a800 0x00000000 /* pioD */
138 + 0xffffffff 0x7fffffff 0x76fff1bf /* pioE */
139 + >;
140 +
141 +diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
142 +index 2924d7910b106..eb2190477da10 100644
143 +--- a/arch/arm/kernel/perf_event_v7.c
144 ++++ b/arch/arm/kernel/perf_event_v7.c
145 +@@ -773,10 +773,10 @@ static inline void armv7pmu_write_counter(struct perf_event *event, u64 value)
146 + pr_err("CPU%u writing wrong counter %d\n",
147 + smp_processor_id(), idx);
148 + } else if (idx == ARMV7_IDX_CYCLE_COUNTER) {
149 +- asm volatile("mcr p15, 0, %0, c9, c13, 0" : : "r" (value));
150 ++ asm volatile("mcr p15, 0, %0, c9, c13, 0" : : "r" ((u32)value));
151 + } else {
152 + armv7_pmnc_select_counter(idx);
153 +- asm volatile("mcr p15, 0, %0, c9, c13, 2" : : "r" (value));
154 ++ asm volatile("mcr p15, 0, %0, c9, c13, 2" : : "r" ((u32)value));
155 + }
156 + }
157 +
158 +diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
159 +index 28ad59ee6c34b..6cb1278613c5e 100644
160 +--- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
161 ++++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
162 +@@ -134,7 +134,7 @@
163 +
164 + uart0: serial@12000 {
165 + compatible = "marvell,armada-3700-uart";
166 +- reg = <0x12000 0x200>;
167 ++ reg = <0x12000 0x18>;
168 + clocks = <&xtalclk>;
169 + interrupts =
170 + <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
171 +diff --git a/arch/arm64/include/asm/asm-uaccess.h b/arch/arm64/include/asm/asm-uaccess.h
172 +index c764cc8fb3b6a..9bf56e30f4a8d 100644
173 +--- a/arch/arm64/include/asm/asm-uaccess.h
174 ++++ b/arch/arm64/include/asm/asm-uaccess.h
175 +@@ -15,10 +15,10 @@
176 + .macro __uaccess_ttbr0_disable, tmp1
177 + mrs \tmp1, ttbr1_el1 // swapper_pg_dir
178 + bic \tmp1, \tmp1, #TTBR_ASID_MASK
179 +- sub \tmp1, \tmp1, #RESERVED_TTBR0_SIZE // reserved_ttbr0 just before swapper_pg_dir
180 ++ sub \tmp1, \tmp1, #PAGE_SIZE // reserved_pg_dir just before swapper_pg_dir
181 + msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1
182 + isb
183 +- add \tmp1, \tmp1, #RESERVED_TTBR0_SIZE
184 ++ add \tmp1, \tmp1, #PAGE_SIZE
185 + msr ttbr1_el1, \tmp1 // set reserved ASID
186 + isb
187 + .endm
188 +diff --git a/arch/arm64/include/asm/kernel-pgtable.h b/arch/arm64/include/asm/kernel-pgtable.h
189 +index a6e5da7553597..817efd95d539f 100644
190 +--- a/arch/arm64/include/asm/kernel-pgtable.h
191 ++++ b/arch/arm64/include/asm/kernel-pgtable.h
192 +@@ -89,12 +89,6 @@
193 + #define INIT_DIR_SIZE (PAGE_SIZE * EARLY_PAGES(KIMAGE_VADDR + TEXT_OFFSET, _end))
194 + #define IDMAP_DIR_SIZE (IDMAP_PGTABLE_LEVELS * PAGE_SIZE)
195 +
196 +-#ifdef CONFIG_ARM64_SW_TTBR0_PAN
197 +-#define RESERVED_TTBR0_SIZE (PAGE_SIZE)
198 +-#else
199 +-#define RESERVED_TTBR0_SIZE (0)
200 +-#endif
201 +-
202 + /* Initial memory map size */
203 + #if ARM64_SWAPPER_USES_SECTION_MAPS
204 + #define SWAPPER_BLOCK_SHIFT SECTION_SHIFT
205 +diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h
206 +index 3a5d9f1c91b6d..fb564de90aa7e 100644
207 +--- a/arch/arm64/include/asm/mmu_context.h
208 ++++ b/arch/arm64/include/asm/mmu_context.h
209 +@@ -36,11 +36,11 @@ static inline void contextidr_thread_switch(struct task_struct *next)
210 + }
211 +
212 + /*
213 +- * Set TTBR0 to empty_zero_page. No translations will be possible via TTBR0.
214 ++ * Set TTBR0 to reserved_pg_dir. No translations will be possible via TTBR0.
215 + */
216 + static inline void cpu_set_reserved_ttbr0(void)
217 + {
218 +- unsigned long ttbr = phys_to_ttbr(__pa_symbol(empty_zero_page));
219 ++ unsigned long ttbr = phys_to_ttbr(__pa_symbol(reserved_pg_dir));
220 +
221 + write_sysreg(ttbr, ttbr0_el1);
222 + isb();
223 +@@ -184,9 +184,9 @@ static inline void update_saved_ttbr0(struct task_struct *tsk,
224 + return;
225 +
226 + if (mm == &init_mm)
227 +- ttbr = __pa_symbol(empty_zero_page);
228 ++ ttbr = phys_to_ttbr(__pa_symbol(reserved_pg_dir));
229 + else
230 +- ttbr = virt_to_phys(mm->pgd) | ASID(mm) << 48;
231 ++ ttbr = phys_to_ttbr(virt_to_phys(mm->pgd)) | ASID(mm) << 48;
232 +
233 + WRITE_ONCE(task_thread_info(tsk)->ttbr0, ttbr);
234 + }
235 +diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
236 +index 8c420f916fe2e..a92a187ec8919 100644
237 +--- a/arch/arm64/include/asm/pgtable.h
238 ++++ b/arch/arm64/include/asm/pgtable.h
239 +@@ -466,6 +466,7 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
240 + extern pgd_t idmap_pg_dir[PTRS_PER_PGD];
241 + extern pgd_t idmap_pg_end[];
242 + extern pgd_t tramp_pg_dir[PTRS_PER_PGD];
243 ++extern pgd_t reserved_pg_dir[PTRS_PER_PGD];
244 +
245 + extern void set_swapper_pgd(pgd_t *pgdp, pgd_t pgd);
246 +
247 +diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
248 +index 32fc8061aa76f..b9a37a415bf9c 100644
249 +--- a/arch/arm64/include/asm/uaccess.h
250 ++++ b/arch/arm64/include/asm/uaccess.h
251 +@@ -112,8 +112,8 @@ static inline void __uaccess_ttbr0_disable(void)
252 + local_irq_save(flags);
253 + ttbr = read_sysreg(ttbr1_el1);
254 + ttbr &= ~TTBR_ASID_MASK;
255 +- /* reserved_ttbr0 placed before swapper_pg_dir */
256 +- write_sysreg(ttbr - RESERVED_TTBR0_SIZE, ttbr0_el1);
257 ++ /* reserved_pg_dir placed before swapper_pg_dir */
258 ++ write_sysreg(ttbr - PAGE_SIZE, ttbr0_el1);
259 + isb();
260 + /* Set reserved ASID */
261 + write_sysreg(ttbr, ttbr1_el1);
262 +diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
263 +index cf3bd2976e574..db137746c6fa3 100644
264 +--- a/arch/arm64/kernel/entry.S
265 ++++ b/arch/arm64/kernel/entry.S
266 +@@ -1018,9 +1018,10 @@ ENDPROC(el0_svc)
267 + */
268 + .pushsection ".entry.tramp.text", "ax"
269 +
270 ++ // Move from tramp_pg_dir to swapper_pg_dir
271 + .macro tramp_map_kernel, tmp
272 + mrs \tmp, ttbr1_el1
273 +- add \tmp, \tmp, #(PAGE_SIZE + RESERVED_TTBR0_SIZE)
274 ++ add \tmp, \tmp, #(2 * PAGE_SIZE)
275 + bic \tmp, \tmp, #USER_ASID_FLAG
276 + msr ttbr1_el1, \tmp
277 + #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003
278 +@@ -1037,9 +1038,10 @@ alternative_else_nop_endif
279 + #endif /* CONFIG_QCOM_FALKOR_ERRATUM_1003 */
280 + .endm
281 +
282 ++ // Move from swapper_pg_dir to tramp_pg_dir
283 + .macro tramp_unmap_kernel, tmp
284 + mrs \tmp, ttbr1_el1
285 +- sub \tmp, \tmp, #(PAGE_SIZE + RESERVED_TTBR0_SIZE)
286 ++ sub \tmp, \tmp, #(2 * PAGE_SIZE)
287 + orr \tmp, \tmp, #USER_ASID_FLAG
288 + msr ttbr1_el1, \tmp
289 + /*
290 +diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
291 +index d98987b82874f..f55f4a15a905e 100644
292 +--- a/arch/arm64/kernel/setup.c
293 ++++ b/arch/arm64/kernel/setup.c
294 +@@ -356,7 +356,7 @@ void __init setup_arch(char **cmdline_p)
295 + * faults in case uaccess_enable() is inadvertently called by the init
296 + * thread.
297 + */
298 +- init_task.thread_info.ttbr0 = __pa_symbol(empty_zero_page);
299 ++ init_task.thread_info.ttbr0 = phys_to_ttbr(__pa_symbol(reserved_pg_dir));
300 + #endif
301 +
302 + #ifdef CONFIG_VT
303 +diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
304 +index 0bab37b1acbe9..1f82cf631c3c4 100644
305 +--- a/arch/arm64/kernel/vmlinux.lds.S
306 ++++ b/arch/arm64/kernel/vmlinux.lds.S
307 +@@ -157,13 +157,11 @@ SECTIONS
308 + . += PAGE_SIZE;
309 + #endif
310 +
311 +-#ifdef CONFIG_ARM64_SW_TTBR0_PAN
312 +- reserved_ttbr0 = .;
313 +- . += RESERVED_TTBR0_SIZE;
314 +-#endif
315 ++ reserved_pg_dir = .;
316 ++ . += PAGE_SIZE;
317 ++
318 + swapper_pg_dir = .;
319 + . += PAGE_SIZE;
320 +- swapper_pg_end = .;
321 +
322 + . = ALIGN(SEGMENT_ALIGN);
323 + __init_begin = .;
324 +diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
325 +index a1e0592d1fbcd..13e78a5d86905 100644
326 +--- a/arch/arm64/mm/proc.S
327 ++++ b/arch/arm64/mm/proc.S
328 +@@ -166,7 +166,7 @@ ENDPROC(cpu_do_switch_mm)
329 + .pushsection ".idmap.text", "awx"
330 +
331 + .macro __idmap_cpu_set_reserved_ttbr1, tmp1, tmp2
332 +- adrp \tmp1, empty_zero_page
333 ++ adrp \tmp1, reserved_pg_dir
334 + phys_to_ttbr \tmp2, \tmp1
335 + offset_ttbr1 \tmp2, \tmp1
336 + msr ttbr1_el1, \tmp2
337 +diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c
338 +index 4d0ab323dee8c..2a40268c3d494 100644
339 +--- a/arch/ia64/kernel/mca_drv.c
340 ++++ b/arch/ia64/kernel/mca_drv.c
341 +@@ -343,7 +343,7 @@ init_record_index_pools(void)
342 +
343 + /* - 2 - */
344 + sect_min_size = sal_log_sect_min_sizes[0];
345 +- for (i = 1; i < sizeof sal_log_sect_min_sizes/sizeof(size_t); i++)
346 ++ for (i = 1; i < ARRAY_SIZE(sal_log_sect_min_sizes); i++)
347 + if (sect_min_size > sal_log_sect_min_sizes[i])
348 + sect_min_size = sal_log_sect_min_sizes[i];
349 +
350 +diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine
351 +index c01e103492fdc..1bbe0dd0c4fe5 100644
352 +--- a/arch/m68k/Kconfig.machine
353 ++++ b/arch/m68k/Kconfig.machine
354 +@@ -23,6 +23,9 @@ config ATARI
355 + this kernel on an Atari, say Y here and browse the material
356 + available in <file:Documentation/m68k>; otherwise say N.
357 +
358 ++config ATARI_KBD_CORE
359 ++ bool
360 ++
361 + config MAC
362 + bool "Macintosh support"
363 + depends on MMU
364 +diff --git a/arch/mips/include/asm/highmem.h b/arch/mips/include/asm/highmem.h
365 +index 9d84aafc33d05..9a6bf4f011b5f 100644
366 +--- a/arch/mips/include/asm/highmem.h
367 ++++ b/arch/mips/include/asm/highmem.h
368 +@@ -36,7 +36,7 @@ extern pte_t *pkmap_page_table;
369 + * easily, subsequent pte tables have to be allocated in one physical
370 + * chunk of RAM.
371 + */
372 +-#ifdef CONFIG_PHYS_ADDR_T_64BIT
373 ++#if defined(CONFIG_PHYS_ADDR_T_64BIT) || defined(CONFIG_MIPS_HUGE_TLB_SUPPORT)
374 + #define LAST_PKMAP 512
375 + #else
376 + #define LAST_PKMAP 1024
377 +diff --git a/arch/powerpc/include/asm/cputhreads.h b/arch/powerpc/include/asm/cputhreads.h
378 +index deb99fd6e060f..51f533b6ece02 100644
379 +--- a/arch/powerpc/include/asm/cputhreads.h
380 ++++ b/arch/powerpc/include/asm/cputhreads.h
381 +@@ -99,6 +99,36 @@ static inline int cpu_last_thread_sibling(int cpu)
382 + return cpu | (threads_per_core - 1);
383 + }
384 +
385 ++/*
386 ++ * tlb_thread_siblings are siblings which share a TLB. This is not
387 ++ * architected, is not something a hypervisor could emulate and a future
388 ++ * CPU may change behaviour even in compat mode, so this should only be
389 ++ * used on PowerNV, and only with care.
390 ++ */
391 ++static inline int cpu_first_tlb_thread_sibling(int cpu)
392 ++{
393 ++ if (cpu_has_feature(CPU_FTR_ARCH_300) && (threads_per_core == 8))
394 ++ return cpu & ~0x6; /* Big Core */
395 ++ else
396 ++ return cpu_first_thread_sibling(cpu);
397 ++}
398 ++
399 ++static inline int cpu_last_tlb_thread_sibling(int cpu)
400 ++{
401 ++ if (cpu_has_feature(CPU_FTR_ARCH_300) && (threads_per_core == 8))
402 ++ return cpu | 0x6; /* Big Core */
403 ++ else
404 ++ return cpu_last_thread_sibling(cpu);
405 ++}
406 ++
407 ++static inline int cpu_tlb_thread_sibling_step(void)
408 ++{
409 ++ if (cpu_has_feature(CPU_FTR_ARCH_300) && (threads_per_core == 8))
410 ++ return 2; /* Big Core */
411 ++ else
412 ++ return 1;
413 ++}
414 ++
415 + static inline u32 get_tensr(void)
416 + {
417 + #ifdef CONFIG_BOOKE
418 +diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
419 +index b24d860bbab9b..c06cac543f188 100644
420 +--- a/arch/powerpc/kernel/smp.c
421 ++++ b/arch/powerpc/kernel/smp.c
422 +@@ -588,6 +588,8 @@ static void nmi_stop_this_cpu(struct pt_regs *regs)
423 + /*
424 + * IRQs are already hard disabled by the smp_handle_nmi_ipi.
425 + */
426 ++ set_cpu_online(smp_processor_id(), false);
427 ++
428 + spin_begin();
429 + while (1)
430 + spin_cpu_relax();
431 +@@ -603,6 +605,15 @@ void smp_send_stop(void)
432 + static void stop_this_cpu(void *dummy)
433 + {
434 + hard_irq_disable();
435 ++
436 ++ /*
437 ++ * Offlining CPUs in stop_this_cpu can result in scheduler warnings,
438 ++ * (see commit de6e5d38417e), but printk_safe_flush_on_panic() wants
439 ++ * to know other CPUs are offline before it breaks locks to flush
440 ++ * printk buffers, in case we panic()ed while holding the lock.
441 ++ */
442 ++ set_cpu_online(smp_processor_id(), false);
443 ++
444 + spin_begin();
445 + while (1)
446 + spin_cpu_relax();
447 +diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
448 +index e2a46cfed5fd1..b13c6213b0d9b 100644
449 +--- a/arch/powerpc/kernel/stacktrace.c
450 ++++ b/arch/powerpc/kernel/stacktrace.c
451 +@@ -19,6 +19,7 @@
452 + #include <asm/ptrace.h>
453 + #include <asm/processor.h>
454 + #include <linux/ftrace.h>
455 ++#include <linux/delay.h>
456 + #include <asm/kprobes.h>
457 +
458 + #include <asm/paca.h>
459 +@@ -230,17 +231,31 @@ static void handle_backtrace_ipi(struct pt_regs *regs)
460 +
461 + static void raise_backtrace_ipi(cpumask_t *mask)
462 + {
463 ++ struct paca_struct *p;
464 + unsigned int cpu;
465 ++ u64 delay_us;
466 +
467 + for_each_cpu(cpu, mask) {
468 +- if (cpu == smp_processor_id())
469 ++ if (cpu == smp_processor_id()) {
470 + handle_backtrace_ipi(NULL);
471 +- else
472 +- smp_send_safe_nmi_ipi(cpu, handle_backtrace_ipi, 5 * USEC_PER_SEC);
473 +- }
474 ++ continue;
475 ++ }
476 +
477 +- for_each_cpu(cpu, mask) {
478 +- struct paca_struct *p = paca_ptrs[cpu];
479 ++ delay_us = 5 * USEC_PER_SEC;
480 ++
481 ++ if (smp_send_safe_nmi_ipi(cpu, handle_backtrace_ipi, delay_us)) {
482 ++ // Now wait up to 5s for the other CPU to do its backtrace
483 ++ while (cpumask_test_cpu(cpu, mask) && delay_us) {
484 ++ udelay(1);
485 ++ delay_us--;
486 ++ }
487 ++
488 ++ // Other CPU cleared itself from the mask
489 ++ if (delay_us)
490 ++ continue;
491 ++ }
492 ++
493 ++ p = paca_ptrs[cpu];
494 +
495 + cpumask_clear_cpu(cpu, mask);
496 +
497 +diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
498 +index 6938b793a0150..9011857c0434d 100644
499 +--- a/arch/powerpc/kvm/book3s_hv.c
500 ++++ b/arch/powerpc/kvm/book3s_hv.c
501 +@@ -2536,7 +2536,7 @@ static void radix_flush_cpu(struct kvm *kvm, int cpu, struct kvm_vcpu *vcpu)
502 + cpumask_t *cpu_in_guest;
503 + int i;
504 +
505 +- cpu = cpu_first_thread_sibling(cpu);
506 ++ cpu = cpu_first_tlb_thread_sibling(cpu);
507 + if (nested) {
508 + cpumask_set_cpu(cpu, &nested->need_tlb_flush);
509 + cpu_in_guest = &nested->cpu_in_guest;
510 +@@ -2550,9 +2550,10 @@ static void radix_flush_cpu(struct kvm *kvm, int cpu, struct kvm_vcpu *vcpu)
511 + * the other side is the first smp_mb() in kvmppc_run_core().
512 + */
513 + smp_mb();
514 +- for (i = 0; i < threads_per_core; ++i)
515 +- if (cpumask_test_cpu(cpu + i, cpu_in_guest))
516 +- smp_call_function_single(cpu + i, do_nothing, NULL, 1);
517 ++ for (i = cpu; i <= cpu_last_tlb_thread_sibling(cpu);
518 ++ i += cpu_tlb_thread_sibling_step())
519 ++ if (cpumask_test_cpu(i, cpu_in_guest))
520 ++ smp_call_function_single(i, do_nothing, NULL, 1);
521 + }
522 +
523 + static void kvmppc_prepare_radix_vcpu(struct kvm_vcpu *vcpu, int pcpu)
524 +@@ -2583,8 +2584,8 @@ static void kvmppc_prepare_radix_vcpu(struct kvm_vcpu *vcpu, int pcpu)
525 + */
526 + if (prev_cpu != pcpu) {
527 + if (prev_cpu >= 0 &&
528 +- cpu_first_thread_sibling(prev_cpu) !=
529 +- cpu_first_thread_sibling(pcpu))
530 ++ cpu_first_tlb_thread_sibling(prev_cpu) !=
531 ++ cpu_first_tlb_thread_sibling(pcpu))
532 + radix_flush_cpu(kvm, prev_cpu, vcpu);
533 + if (nested)
534 + nested->prev_cpu[vcpu->arch.nested_vcpu_id] = pcpu;
535 +diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c
536 +index 7c1909657b556..4a91b543a8540 100644
537 +--- a/arch/powerpc/kvm/book3s_hv_builtin.c
538 ++++ b/arch/powerpc/kvm/book3s_hv_builtin.c
539 +@@ -847,7 +847,7 @@ void kvmppc_check_need_tlb_flush(struct kvm *kvm, int pcpu,
540 + * Thus we make all 4 threads use the same bit.
541 + */
542 + if (cpu_has_feature(CPU_FTR_ARCH_300))
543 +- pcpu = cpu_first_thread_sibling(pcpu);
544 ++ pcpu = cpu_first_tlb_thread_sibling(pcpu);
545 +
546 + if (nested)
547 + need_tlb_flush = &nested->need_tlb_flush;
548 +diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c
549 +index cdf30c6eaf542..66fa2c7590aa0 100644
550 +--- a/arch/powerpc/kvm/book3s_hv_nested.c
551 ++++ b/arch/powerpc/kvm/book3s_hv_nested.c
552 +@@ -51,7 +51,8 @@ void kvmhv_save_hv_regs(struct kvm_vcpu *vcpu, struct hv_guest_state *hr)
553 + hr->ppr = vcpu->arch.ppr;
554 + }
555 +
556 +-static void byteswap_pt_regs(struct pt_regs *regs)
557 ++/* Use noinline_for_stack due to https://bugs.llvm.org/show_bug.cgi?id=49610 */
558 ++static noinline_for_stack void byteswap_pt_regs(struct pt_regs *regs)
559 + {
560 + unsigned long *addr = (unsigned long *) regs;
561 +
562 +diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
563 +index 220305454c23c..9bf3be438ac58 100644
564 +--- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
565 ++++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
566 +@@ -67,7 +67,7 @@ static int global_invalidates(struct kvm *kvm)
567 + * so use the bit for the first thread to represent the core.
568 + */
569 + if (cpu_has_feature(CPU_FTR_ARCH_300))
570 +- cpu = cpu_first_thread_sibling(cpu);
571 ++ cpu = cpu_first_tlb_thread_sibling(cpu);
572 + cpumask_clear_cpu(cpu, &kvm->arch.need_tlb_flush);
573 + }
574 +
575 +diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
576 +index 43a81d0ad5074..0023b78391f14 100644
577 +--- a/arch/s390/Kconfig
578 ++++ b/arch/s390/Kconfig
579 +@@ -920,7 +920,7 @@ config CMM_IUCV
580 + config APPLDATA_BASE
581 + def_bool n
582 + prompt "Linux - VM Monitor Stream, base infrastructure"
583 +- depends on PROC_FS
584 ++ depends on PROC_SYSCTL
585 + help
586 + This provides a kernel interface for creating and updating z/VM APPLDATA
587 + monitor records. The monitor records are updated at certain time
588 +diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
589 +index d08e13c6dc982..20ba8537dbcc2 100644
590 +--- a/arch/s390/kvm/kvm-s390.c
591 ++++ b/arch/s390/kvm/kvm-s390.c
592 +@@ -318,31 +318,31 @@ static void allow_cpu_feat(unsigned long nr)
593 +
594 + static inline int plo_test_bit(unsigned char nr)
595 + {
596 +- register unsigned long r0 asm("0") = (unsigned long) nr | 0x100;
597 ++ unsigned long function = (unsigned long)nr | 0x100;
598 + int cc;
599 +
600 + asm volatile(
601 ++ " lgr 0,%[function]\n"
602 + /* Parameter registers are ignored for "test bit" */
603 + " plo 0,0,0,0(0)\n"
604 + " ipm %0\n"
605 + " srl %0,28\n"
606 + : "=d" (cc)
607 +- : "d" (r0)
608 +- : "cc");
609 ++ : [function] "d" (function)
610 ++ : "cc", "0");
611 + return cc == 0;
612 + }
613 +
614 + static __always_inline void __insn32_query(unsigned int opcode, u8 *query)
615 + {
616 +- register unsigned long r0 asm("0") = 0; /* query function */
617 +- register unsigned long r1 asm("1") = (unsigned long) query;
618 +-
619 + asm volatile(
620 +- /* Parameter regs are ignored */
621 ++ " lghi 0,0\n"
622 ++ " lgr 1,%[query]\n"
623 ++ /* Parameter registers are ignored */
624 + " .insn rrf,%[opc] << 16,2,4,6,0\n"
625 + :
626 +- : "d" (r0), "a" (r1), [opc] "i" (opcode)
627 +- : "cc", "memory");
628 ++ : [query] "d" ((unsigned long)query), [opc] "i" (opcode)
629 ++ : "cc", "memory", "0", "1");
630 + }
631 +
632 + #define INSN_SORTL 0xb938
633 +diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
634 +index 3f63bd7421aca..023bd3e1aa0d2 100644
635 +--- a/arch/x86/kvm/vmx/nested.c
636 ++++ b/arch/x86/kvm/vmx/nested.c
637 +@@ -5099,7 +5099,7 @@ static int handle_vmfunc(struct kvm_vcpu *vcpu)
638 + }
639 +
640 + vmcs12 = get_vmcs12(vcpu);
641 +- if ((vmcs12->vm_function_control & (1 << function)) == 0)
642 ++ if (!(vmcs12->vm_function_control & BIT_ULL(function)))
643 + goto fail;
644 +
645 + switch (function) {
646 +diff --git a/block/blk-merge.c b/block/blk-merge.c
647 +index 03959bfe961cf..4b022f0c49d20 100644
648 +--- a/block/blk-merge.c
649 ++++ b/block/blk-merge.c
650 +@@ -571,10 +571,14 @@ static inline unsigned int blk_rq_get_max_segments(struct request *rq)
651 + static inline int ll_new_hw_segment(struct request *req, struct bio *bio,
652 + unsigned int nr_phys_segs)
653 + {
654 +- if (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req))
655 ++ if (blk_integrity_merge_bio(req->q, req, bio) == false)
656 + goto no_merge;
657 +
658 +- if (blk_integrity_merge_bio(req->q, req, bio) == false)
659 ++ /* discard request merge won't add new segment */
660 ++ if (req_op(req) == REQ_OP_DISCARD)
661 ++ return 1;
662 ++
663 ++ if (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req))
664 + goto no_merge;
665 +
666 + /*
667 +diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h
668 +index 2bc43e94f4c40..2bcb3495e376b 100644
669 +--- a/block/blk-rq-qos.h
670 ++++ b/block/blk-rq-qos.h
671 +@@ -7,6 +7,7 @@
672 + #include <linux/blk_types.h>
673 + #include <linux/atomic.h>
674 + #include <linux/wait.h>
675 ++#include <linux/blk-mq.h>
676 +
677 + #include "blk-mq-debugfs.h"
678 +
679 +@@ -99,8 +100,21 @@ static inline void rq_wait_init(struct rq_wait *rq_wait)
680 +
681 + static inline void rq_qos_add(struct request_queue *q, struct rq_qos *rqos)
682 + {
683 ++ /*
684 ++ * No IO can be in-flight when adding rqos, so freeze queue, which
685 ++ * is fine since we only support rq_qos for blk-mq queue.
686 ++ *
687 ++ * Reuse ->queue_lock for protecting against other concurrent
688 ++ * rq_qos adding/deleting
689 ++ */
690 ++ blk_mq_freeze_queue(q);
691 ++
692 ++ spin_lock_irq(&q->queue_lock);
693 + rqos->next = q->rq_qos;
694 + q->rq_qos = rqos;
695 ++ spin_unlock_irq(&q->queue_lock);
696 ++
697 ++ blk_mq_unfreeze_queue(q);
698 +
699 + if (rqos->ops->debugfs_attrs)
700 + blk_mq_debugfs_register_rqos(rqos);
701 +@@ -110,12 +124,22 @@ static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos)
702 + {
703 + struct rq_qos **cur;
704 +
705 ++ /*
706 ++ * See comment in rq_qos_add() about freezing queue & using
707 ++ * ->queue_lock.
708 ++ */
709 ++ blk_mq_freeze_queue(q);
710 ++
711 ++ spin_lock_irq(&q->queue_lock);
712 + for (cur = &q->rq_qos; *cur; cur = &(*cur)->next) {
713 + if (*cur == rqos) {
714 + *cur = rqos->next;
715 + break;
716 + }
717 + }
718 ++ spin_unlock_irq(&q->queue_lock);
719 ++
720 ++ blk_mq_unfreeze_queue(q);
721 +
722 + blk_mq_debugfs_unregister_rqos(rqos);
723 + }
724 +diff --git a/block/blk-wbt.c b/block/blk-wbt.c
725 +index 8641ba9793c5f..ee708c1bc3523 100644
726 +--- a/block/blk-wbt.c
727 ++++ b/block/blk-wbt.c
728 +@@ -77,7 +77,8 @@ enum {
729 +
730 + static inline bool rwb_enabled(struct rq_wb *rwb)
731 + {
732 +- return rwb && rwb->wb_normal != 0;
733 ++ return rwb && rwb->enable_state != WBT_STATE_OFF_DEFAULT &&
734 ++ rwb->wb_normal != 0;
735 + }
736 +
737 + static void wb_timestamp(struct rq_wb *rwb, unsigned long *var)
738 +@@ -644,9 +645,13 @@ void wbt_set_write_cache(struct request_queue *q, bool write_cache_on)
739 + void wbt_enable_default(struct request_queue *q)
740 + {
741 + struct rq_qos *rqos = wbt_rq_qos(q);
742 ++
743 + /* Throttling already enabled? */
744 +- if (rqos)
745 ++ if (rqos) {
746 ++ if (RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT)
747 ++ RQWB(rqos)->enable_state = WBT_STATE_ON_DEFAULT;
748 + return;
749 ++ }
750 +
751 + /* Queue not registered? Maybe shutting down... */
752 + if (!blk_queue_registered(q))
753 +@@ -710,7 +715,7 @@ void wbt_disable_default(struct request_queue *q)
754 + rwb = RQWB(rqos);
755 + if (rwb->enable_state == WBT_STATE_ON_DEFAULT) {
756 + blk_stat_deactivate(rwb->cb);
757 +- rwb->wb_normal = 0;
758 ++ rwb->enable_state = WBT_STATE_OFF_DEFAULT;
759 + }
760 + }
761 + EXPORT_SYMBOL_GPL(wbt_disable_default);
762 +diff --git a/block/blk-wbt.h b/block/blk-wbt.h
763 +index 8e4e376609710..d8d9f41b42f9a 100644
764 +--- a/block/blk-wbt.h
765 ++++ b/block/blk-wbt.h
766 +@@ -34,6 +34,7 @@ enum {
767 + enum {
768 + WBT_STATE_ON_DEFAULT = 1,
769 + WBT_STATE_ON_MANUAL = 2,
770 ++ WBT_STATE_OFF_DEFAULT
771 + };
772 +
773 + struct rq_wb {
774 +diff --git a/crypto/shash.c b/crypto/shash.c
775 +index e83c5124f6eb1..9c4cdfd8550ef 100644
776 +--- a/crypto/shash.c
777 ++++ b/crypto/shash.c
778 +@@ -20,12 +20,24 @@
779 +
780 + static const struct crypto_type crypto_shash_type;
781 +
782 +-int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
783 +- unsigned int keylen)
784 ++static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
785 ++ unsigned int keylen)
786 + {
787 + return -ENOSYS;
788 + }
789 +-EXPORT_SYMBOL_GPL(shash_no_setkey);
790 ++
791 ++/*
792 ++ * Check whether an shash algorithm has a setkey function.
793 ++ *
794 ++ * For CFI compatibility, this must not be an inline function. This is because
795 ++ * when CFI is enabled, modules won't get the same address for shash_no_setkey
796 ++ * (if it were exported, which inlining would require) as the core kernel will.
797 ++ */
798 ++bool crypto_shash_alg_has_setkey(struct shash_alg *alg)
799 ++{
800 ++ return alg->setkey != shash_no_setkey;
801 ++}
802 ++EXPORT_SYMBOL_GPL(crypto_shash_alg_has_setkey);
803 +
804 + static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
805 + unsigned int keylen)
806 +diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
807 +index ef1ac4d127dab..1c81504046d4d 100644
808 +--- a/drivers/acpi/Makefile
809 ++++ b/drivers/acpi/Makefile
810 +@@ -8,6 +8,11 @@ ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
811 + #
812 + # ACPI Boot-Time Table Parsing
813 + #
814 ++ifeq ($(CONFIG_ACPI_CUSTOM_DSDT),y)
815 ++tables.o: $(src)/../../include/$(subst $\",,$(CONFIG_ACPI_CUSTOM_DSDT_FILE)) ;
816 ++
817 ++endif
818 ++
819 + obj-$(CONFIG_ACPI) += tables.o
820 + obj-$(CONFIG_X86) += blacklist.o
821 +
822 +diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
823 +index e7dc0133f8173..c11d736a8db7e 100644
824 +--- a/drivers/acpi/acpi_pad.c
825 ++++ b/drivers/acpi/acpi_pad.c
826 +@@ -262,7 +262,7 @@ static uint32_t acpi_pad_idle_cpus_num(void)
827 + return ps_tsk_num;
828 + }
829 +
830 +-static ssize_t acpi_pad_rrtime_store(struct device *dev,
831 ++static ssize_t rrtime_store(struct device *dev,
832 + struct device_attribute *attr, const char *buf, size_t count)
833 + {
834 + unsigned long num;
835 +@@ -276,16 +276,14 @@ static ssize_t acpi_pad_rrtime_store(struct device *dev,
836 + return count;
837 + }
838 +
839 +-static ssize_t acpi_pad_rrtime_show(struct device *dev,
840 ++static ssize_t rrtime_show(struct device *dev,
841 + struct device_attribute *attr, char *buf)
842 + {
843 + return scnprintf(buf, PAGE_SIZE, "%d\n", round_robin_time);
844 + }
845 +-static DEVICE_ATTR(rrtime, S_IRUGO|S_IWUSR,
846 +- acpi_pad_rrtime_show,
847 +- acpi_pad_rrtime_store);
848 ++static DEVICE_ATTR_RW(rrtime);
849 +
850 +-static ssize_t acpi_pad_idlepct_store(struct device *dev,
851 ++static ssize_t idlepct_store(struct device *dev,
852 + struct device_attribute *attr, const char *buf, size_t count)
853 + {
854 + unsigned long num;
855 +@@ -299,16 +297,14 @@ static ssize_t acpi_pad_idlepct_store(struct device *dev,
856 + return count;
857 + }
858 +
859 +-static ssize_t acpi_pad_idlepct_show(struct device *dev,
860 ++static ssize_t idlepct_show(struct device *dev,
861 + struct device_attribute *attr, char *buf)
862 + {
863 + return scnprintf(buf, PAGE_SIZE, "%d\n", idle_pct);
864 + }
865 +-static DEVICE_ATTR(idlepct, S_IRUGO|S_IWUSR,
866 +- acpi_pad_idlepct_show,
867 +- acpi_pad_idlepct_store);
868 ++static DEVICE_ATTR_RW(idlepct);
869 +
870 +-static ssize_t acpi_pad_idlecpus_store(struct device *dev,
871 ++static ssize_t idlecpus_store(struct device *dev,
872 + struct device_attribute *attr, const char *buf, size_t count)
873 + {
874 + unsigned long num;
875 +@@ -320,16 +316,14 @@ static ssize_t acpi_pad_idlecpus_store(struct device *dev,
876 + return count;
877 + }
878 +
879 +-static ssize_t acpi_pad_idlecpus_show(struct device *dev,
880 ++static ssize_t idlecpus_show(struct device *dev,
881 + struct device_attribute *attr, char *buf)
882 + {
883 + return cpumap_print_to_pagebuf(false, buf,
884 + to_cpumask(pad_busy_cpus_bits));
885 + }
886 +
887 +-static DEVICE_ATTR(idlecpus, S_IRUGO|S_IWUSR,
888 +- acpi_pad_idlecpus_show,
889 +- acpi_pad_idlecpus_store);
890 ++static DEVICE_ATTR_RW(idlecpus);
891 +
892 + static int acpi_pad_add_sysfs(struct acpi_device *device)
893 + {
894 +diff --git a/drivers/acpi/acpi_tad.c b/drivers/acpi/acpi_tad.c
895 +index 33a4bcdaa4d79..bab8583443a61 100644
896 +--- a/drivers/acpi/acpi_tad.c
897 ++++ b/drivers/acpi/acpi_tad.c
898 +@@ -237,7 +237,7 @@ static ssize_t time_show(struct device *dev, struct device_attribute *attr,
899 + rt.tz, rt.daylight);
900 + }
901 +
902 +-static DEVICE_ATTR(time, S_IRUSR | S_IWUSR, time_show, time_store);
903 ++static DEVICE_ATTR_RW(time);
904 +
905 + static struct attribute *acpi_tad_time_attrs[] = {
906 + &dev_attr_time.attr,
907 +@@ -446,7 +446,7 @@ static ssize_t ac_alarm_show(struct device *dev, struct device_attribute *attr,
908 + return acpi_tad_alarm_read(dev, buf, ACPI_TAD_AC_TIMER);
909 + }
910 +
911 +-static DEVICE_ATTR(ac_alarm, S_IRUSR | S_IWUSR, ac_alarm_show, ac_alarm_store);
912 ++static DEVICE_ATTR_RW(ac_alarm);
913 +
914 + static ssize_t ac_policy_store(struct device *dev, struct device_attribute *attr,
915 + const char *buf, size_t count)
916 +@@ -462,7 +462,7 @@ static ssize_t ac_policy_show(struct device *dev, struct device_attribute *attr,
917 + return acpi_tad_policy_read(dev, buf, ACPI_TAD_AC_TIMER);
918 + }
919 +
920 +-static DEVICE_ATTR(ac_policy, S_IRUSR | S_IWUSR, ac_policy_show, ac_policy_store);
921 ++static DEVICE_ATTR_RW(ac_policy);
922 +
923 + static ssize_t ac_status_store(struct device *dev, struct device_attribute *attr,
924 + const char *buf, size_t count)
925 +@@ -478,7 +478,7 @@ static ssize_t ac_status_show(struct device *dev, struct device_attribute *attr,
926 + return acpi_tad_status_read(dev, buf, ACPI_TAD_AC_TIMER);
927 + }
928 +
929 +-static DEVICE_ATTR(ac_status, S_IRUSR | S_IWUSR, ac_status_show, ac_status_store);
930 ++static DEVICE_ATTR_RW(ac_status);
931 +
932 + static struct attribute *acpi_tad_attrs[] = {
933 + &dev_attr_caps.attr,
934 +@@ -505,7 +505,7 @@ static ssize_t dc_alarm_show(struct device *dev, struct device_attribute *attr,
935 + return acpi_tad_alarm_read(dev, buf, ACPI_TAD_DC_TIMER);
936 + }
937 +
938 +-static DEVICE_ATTR(dc_alarm, S_IRUSR | S_IWUSR, dc_alarm_show, dc_alarm_store);
939 ++static DEVICE_ATTR_RW(dc_alarm);
940 +
941 + static ssize_t dc_policy_store(struct device *dev, struct device_attribute *attr,
942 + const char *buf, size_t count)
943 +@@ -521,7 +521,7 @@ static ssize_t dc_policy_show(struct device *dev, struct device_attribute *attr,
944 + return acpi_tad_policy_read(dev, buf, ACPI_TAD_DC_TIMER);
945 + }
946 +
947 +-static DEVICE_ATTR(dc_policy, S_IRUSR | S_IWUSR, dc_policy_show, dc_policy_store);
948 ++static DEVICE_ATTR_RW(dc_policy);
949 +
950 + static ssize_t dc_status_store(struct device *dev, struct device_attribute *attr,
951 + const char *buf, size_t count)
952 +@@ -537,7 +537,7 @@ static ssize_t dc_status_show(struct device *dev, struct device_attribute *attr,
953 + return acpi_tad_status_read(dev, buf, ACPI_TAD_DC_TIMER);
954 + }
955 +
956 +-static DEVICE_ATTR(dc_status, S_IRUSR | S_IWUSR, dc_status_show, dc_status_store);
957 ++static DEVICE_ATTR_RW(dc_status);
958 +
959 + static struct attribute *acpi_tad_dc_attrs[] = {
960 + &dev_attr_dc_alarm.attr,
961 +diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
962 +index 663d85e0adba9..b7c408ce340c9 100644
963 +--- a/drivers/acpi/acpica/nsrepair2.c
964 ++++ b/drivers/acpi/acpica/nsrepair2.c
965 +@@ -375,6 +375,13 @@ acpi_ns_repair_CID(struct acpi_evaluate_info *info,
966 +
967 + (*element_ptr)->common.reference_count =
968 + original_ref_count;
969 ++
970 ++ /*
971 ++ * The original_element holds a reference from the package object
972 ++ * that represents _HID. Since a new element was created by _HID,
973 ++ * remove the reference from the _CID package.
974 ++ */
975 ++ acpi_ut_remove_reference(original_element);
976 + }
977 +
978 + element_ptr++;
979 +diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
980 +index 251f961c28cc4..e0d14017706ea 100644
981 +--- a/drivers/acpi/bgrt.c
982 ++++ b/drivers/acpi/bgrt.c
983 +@@ -15,40 +15,19 @@
984 + static void *bgrt_image;
985 + static struct kobject *bgrt_kobj;
986 +
987 +-static ssize_t show_version(struct device *dev,
988 +- struct device_attribute *attr, char *buf)
989 +-{
990 +- return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.version);
991 +-}
992 +-static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
993 +-
994 +-static ssize_t show_status(struct device *dev,
995 +- struct device_attribute *attr, char *buf)
996 +-{
997 +- return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.status);
998 +-}
999 +-static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
1000 +-
1001 +-static ssize_t show_type(struct device *dev,
1002 +- struct device_attribute *attr, char *buf)
1003 +-{
1004 +- return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.image_type);
1005 +-}
1006 +-static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
1007 +-
1008 +-static ssize_t show_xoffset(struct device *dev,
1009 +- struct device_attribute *attr, char *buf)
1010 +-{
1011 +- return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.image_offset_x);
1012 +-}
1013 +-static DEVICE_ATTR(xoffset, S_IRUGO, show_xoffset, NULL);
1014 +-
1015 +-static ssize_t show_yoffset(struct device *dev,
1016 +- struct device_attribute *attr, char *buf)
1017 +-{
1018 +- return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.image_offset_y);
1019 +-}
1020 +-static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL);
1021 ++#define BGRT_SHOW(_name, _member) \
1022 ++ static ssize_t _name##_show(struct kobject *kobj, \
1023 ++ struct kobj_attribute *attr, char *buf) \
1024 ++ { \
1025 ++ return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab._member); \
1026 ++ } \
1027 ++ struct kobj_attribute bgrt_attr_##_name = __ATTR_RO(_name)
1028 ++
1029 ++BGRT_SHOW(version, version);
1030 ++BGRT_SHOW(status, status);
1031 ++BGRT_SHOW(type, image_type);
1032 ++BGRT_SHOW(xoffset, image_offset_x);
1033 ++BGRT_SHOW(yoffset, image_offset_y);
1034 +
1035 + static ssize_t image_read(struct file *file, struct kobject *kobj,
1036 + struct bin_attribute *attr, char *buf, loff_t off, size_t count)
1037 +@@ -60,11 +39,11 @@ static ssize_t image_read(struct file *file, struct kobject *kobj,
1038 + static BIN_ATTR_RO(image, 0); /* size gets filled in later */
1039 +
1040 + static struct attribute *bgrt_attributes[] = {
1041 +- &dev_attr_version.attr,
1042 +- &dev_attr_status.attr,
1043 +- &dev_attr_type.attr,
1044 +- &dev_attr_xoffset.attr,
1045 +- &dev_attr_yoffset.attr,
1046 ++ &bgrt_attr_version.attr,
1047 ++ &bgrt_attr_status.attr,
1048 ++ &bgrt_attr_type.attr,
1049 ++ &bgrt_attr_xoffset.attr,
1050 ++ &bgrt_attr_yoffset.attr,
1051 + NULL,
1052 + };
1053 +
1054 +diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
1055 +index 54002670cb7a1..bbd9c93fc4c26 100644
1056 +--- a/drivers/acpi/bus.c
1057 ++++ b/drivers/acpi/bus.c
1058 +@@ -1240,6 +1240,7 @@ static int __init acpi_init(void)
1059 +
1060 + result = acpi_bus_init();
1061 + if (result) {
1062 ++ kobject_put(acpi_kobj);
1063 + disable_acpi();
1064 + return result;
1065 + }
1066 +diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
1067 +index bfca116482b8b..fe8c7e79f4726 100644
1068 +--- a/drivers/acpi/device_sysfs.c
1069 ++++ b/drivers/acpi/device_sysfs.c
1070 +@@ -325,11 +325,11 @@ int acpi_device_modalias(struct device *dev, char *buf, int size)
1071 + EXPORT_SYMBOL_GPL(acpi_device_modalias);
1072 +
1073 + static ssize_t
1074 +-acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
1075 ++modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
1076 + {
1077 + return __acpi_device_modalias(to_acpi_device(dev), buf, 1024);
1078 + }
1079 +-static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
1080 ++static DEVICE_ATTR_RO(modalias);
1081 +
1082 + static ssize_t real_power_state_show(struct device *dev,
1083 + struct device_attribute *attr, char *buf)
1084 +@@ -358,8 +358,8 @@ static ssize_t power_state_show(struct device *dev,
1085 + static DEVICE_ATTR_RO(power_state);
1086 +
1087 + static ssize_t
1088 +-acpi_eject_store(struct device *d, struct device_attribute *attr,
1089 +- const char *buf, size_t count)
1090 ++eject_store(struct device *d, struct device_attribute *attr,
1091 ++ const char *buf, size_t count)
1092 + {
1093 + struct acpi_device *acpi_device = to_acpi_device(d);
1094 + acpi_object_type not_used;
1095 +@@ -387,28 +387,28 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
1096 + return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN;
1097 + }
1098 +
1099 +-static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
1100 ++static DEVICE_ATTR_WO(eject);
1101 +
1102 + static ssize_t
1103 +-acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf)
1104 ++hid_show(struct device *dev, struct device_attribute *attr, char *buf)
1105 + {
1106 + struct acpi_device *acpi_dev = to_acpi_device(dev);
1107 +
1108 + return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev));
1109 + }
1110 +-static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
1111 ++static DEVICE_ATTR_RO(hid);
1112 +
1113 +-static ssize_t acpi_device_uid_show(struct device *dev,
1114 +- struct device_attribute *attr, char *buf)
1115 ++static ssize_t uid_show(struct device *dev,
1116 ++ struct device_attribute *attr, char *buf)
1117 + {
1118 + struct acpi_device *acpi_dev = to_acpi_device(dev);
1119 +
1120 + return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
1121 + }
1122 +-static DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL);
1123 ++static DEVICE_ATTR_RO(uid);
1124 +
1125 +-static ssize_t acpi_device_adr_show(struct device *dev,
1126 +- struct device_attribute *attr, char *buf)
1127 ++static ssize_t adr_show(struct device *dev,
1128 ++ struct device_attribute *attr, char *buf)
1129 + {
1130 + struct acpi_device *acpi_dev = to_acpi_device(dev);
1131 +
1132 +@@ -417,16 +417,16 @@ static ssize_t acpi_device_adr_show(struct device *dev,
1133 + else
1134 + return sprintf(buf, "0x%08llx\n", acpi_dev->pnp.bus_address);
1135 + }
1136 +-static DEVICE_ATTR(adr, 0444, acpi_device_adr_show, NULL);
1137 ++static DEVICE_ATTR_RO(adr);
1138 +
1139 +-static ssize_t acpi_device_path_show(struct device *dev,
1140 +- struct device_attribute *attr, char *buf)
1141 ++static ssize_t path_show(struct device *dev,
1142 ++ struct device_attribute *attr, char *buf)
1143 + {
1144 + struct acpi_device *acpi_dev = to_acpi_device(dev);
1145 +
1146 + return acpi_object_path(acpi_dev->handle, buf);
1147 + }
1148 +-static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL);
1149 ++static DEVICE_ATTR_RO(path);
1150 +
1151 + /* sysfs file that shows description text from the ACPI _STR method */
1152 + static ssize_t description_show(struct device *dev,
1153 +@@ -446,7 +446,7 @@ static ssize_t description_show(struct device *dev,
1154 + (wchar_t *)acpi_dev->pnp.str_obj->buffer.pointer,
1155 + acpi_dev->pnp.str_obj->buffer.length,
1156 + UTF16_LITTLE_ENDIAN, buf,
1157 +- PAGE_SIZE);
1158 ++ PAGE_SIZE - 1);
1159 +
1160 + buf[result++] = '\n';
1161 +
1162 +@@ -455,8 +455,8 @@ static ssize_t description_show(struct device *dev,
1163 + static DEVICE_ATTR_RO(description);
1164 +
1165 + static ssize_t
1166 +-acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
1167 +- char *buf) {
1168 ++sun_show(struct device *dev, struct device_attribute *attr,
1169 ++ char *buf) {
1170 + struct acpi_device *acpi_dev = to_acpi_device(dev);
1171 + acpi_status status;
1172 + unsigned long long sun;
1173 +@@ -467,11 +467,11 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
1174 +
1175 + return sprintf(buf, "%llu\n", sun);
1176 + }
1177 +-static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
1178 ++static DEVICE_ATTR_RO(sun);
1179 +
1180 + static ssize_t
1181 +-acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
1182 +- char *buf) {
1183 ++hrv_show(struct device *dev, struct device_attribute *attr,
1184 ++ char *buf) {
1185 + struct acpi_device *acpi_dev = to_acpi_device(dev);
1186 + acpi_status status;
1187 + unsigned long long hrv;
1188 +@@ -482,7 +482,7 @@ acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
1189 +
1190 + return sprintf(buf, "%llu\n", hrv);
1191 + }
1192 +-static DEVICE_ATTR(hrv, 0444, acpi_device_hrv_show, NULL);
1193 ++static DEVICE_ATTR_RO(hrv);
1194 +
1195 + static ssize_t status_show(struct device *dev, struct device_attribute *attr,
1196 + char *buf) {
1197 +diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
1198 +index e3414131bfcab..9bb42a772bee3 100644
1199 +--- a/drivers/acpi/dock.c
1200 ++++ b/drivers/acpi/dock.c
1201 +@@ -485,7 +485,7 @@ int dock_notify(struct acpi_device *adev, u32 event)
1202 + /*
1203 + * show_docked - read method for "docked" file in sysfs
1204 + */
1205 +-static ssize_t show_docked(struct device *dev,
1206 ++static ssize_t docked_show(struct device *dev,
1207 + struct device_attribute *attr, char *buf)
1208 + {
1209 + struct dock_station *dock_station = dev->platform_data;
1210 +@@ -494,25 +494,25 @@ static ssize_t show_docked(struct device *dev,
1211 + acpi_bus_get_device(dock_station->handle, &adev);
1212 + return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
1213 + }
1214 +-static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
1215 ++static DEVICE_ATTR_RO(docked);
1216 +
1217 + /*
1218 + * show_flags - read method for flags file in sysfs
1219 + */
1220 +-static ssize_t show_flags(struct device *dev,
1221 ++static ssize_t flags_show(struct device *dev,
1222 + struct device_attribute *attr, char *buf)
1223 + {
1224 + struct dock_station *dock_station = dev->platform_data;
1225 + return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
1226 +
1227 + }
1228 +-static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
1229 ++static DEVICE_ATTR_RO(flags);
1230 +
1231 + /*
1232 + * write_undock - write method for "undock" file in sysfs
1233 + */
1234 +-static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
1235 +- const char *buf, size_t count)
1236 ++static ssize_t undock_store(struct device *dev, struct device_attribute *attr,
1237 ++ const char *buf, size_t count)
1238 + {
1239 + int ret;
1240 + struct dock_station *dock_station = dev->platform_data;
1241 +@@ -526,13 +526,13 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
1242 + acpi_scan_lock_release();
1243 + return ret ? ret: count;
1244 + }
1245 +-static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
1246 ++static DEVICE_ATTR_WO(undock);
1247 +
1248 + /*
1249 + * show_dock_uid - read method for "uid" file in sysfs
1250 + */
1251 +-static ssize_t show_dock_uid(struct device *dev,
1252 +- struct device_attribute *attr, char *buf)
1253 ++static ssize_t uid_show(struct device *dev,
1254 ++ struct device_attribute *attr, char *buf)
1255 + {
1256 + unsigned long long lbuf;
1257 + struct dock_station *dock_station = dev->platform_data;
1258 +@@ -543,10 +543,10 @@ static ssize_t show_dock_uid(struct device *dev,
1259 +
1260 + return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
1261 + }
1262 +-static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
1263 ++static DEVICE_ATTR_RO(uid);
1264 +
1265 +-static ssize_t show_dock_type(struct device *dev,
1266 +- struct device_attribute *attr, char *buf)
1267 ++static ssize_t type_show(struct device *dev,
1268 ++ struct device_attribute *attr, char *buf)
1269 + {
1270 + struct dock_station *dock_station = dev->platform_data;
1271 + char *type;
1272 +@@ -562,7 +562,7 @@ static ssize_t show_dock_type(struct device *dev,
1273 +
1274 + return snprintf(buf, PAGE_SIZE, "%s\n", type);
1275 + }
1276 +-static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
1277 ++static DEVICE_ATTR_RO(type);
1278 +
1279 + static struct attribute *dock_attributes[] = {
1280 + &dev_attr_docked.attr,
1281 +diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
1282 +index c64001e789ed7..258a8df235cfb 100644
1283 +--- a/drivers/acpi/ec.c
1284 ++++ b/drivers/acpi/ec.c
1285 +@@ -1826,6 +1826,22 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = {
1286 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
1287 + DMI_MATCH(DMI_PRODUCT_NAME, "GL702VMK"),}, NULL},
1288 + {
1289 ++ ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X505BA", {
1290 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
1291 ++ DMI_MATCH(DMI_PRODUCT_NAME, "X505BA"),}, NULL},
1292 ++ {
1293 ++ ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X505BP", {
1294 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
1295 ++ DMI_MATCH(DMI_PRODUCT_NAME, "X505BP"),}, NULL},
1296 ++ {
1297 ++ ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X542BA", {
1298 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
1299 ++ DMI_MATCH(DMI_PRODUCT_NAME, "X542BA"),}, NULL},
1300 ++ {
1301 ++ ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X542BP", {
1302 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
1303 ++ DMI_MATCH(DMI_PRODUCT_NAME, "X542BP"),}, NULL},
1304 ++ {
1305 + ec_honor_ecdt_gpe, "ASUS X550VXK", {
1306 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
1307 + DMI_MATCH(DMI_PRODUCT_NAME, "X550VXK"),}, NULL},
1308 +diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
1309 +index fe1e7bc91a5ea..3261cffdd5e05 100644
1310 +--- a/drivers/acpi/power.c
1311 ++++ b/drivers/acpi/power.c
1312 +@@ -888,15 +888,16 @@ static void acpi_release_power_resource(struct device *dev)
1313 + kfree(resource);
1314 + }
1315 +
1316 +-static ssize_t acpi_power_in_use_show(struct device *dev,
1317 +- struct device_attribute *attr,
1318 +- char *buf) {
1319 ++static ssize_t resource_in_use_show(struct device *dev,
1320 ++ struct device_attribute *attr,
1321 ++ char *buf)
1322 ++{
1323 + struct acpi_power_resource *resource;
1324 +
1325 + resource = to_power_resource(to_acpi_device(dev));
1326 + return sprintf(buf, "%u\n", !!resource->ref_count);
1327 + }
1328 +-static DEVICE_ATTR(resource_in_use, 0444, acpi_power_in_use_show, NULL);
1329 ++static DEVICE_ATTR_RO(resource_in_use);
1330 +
1331 + static void acpi_power_sysfs_remove(struct acpi_device *device)
1332 + {
1333 +diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
1334 +index ed56c6d20b084..53ae679c00f01 100644
1335 +--- a/drivers/acpi/processor_idle.c
1336 ++++ b/drivers/acpi/processor_idle.c
1337 +@@ -16,6 +16,7 @@
1338 + #include <linux/acpi.h>
1339 + #include <linux/dmi.h>
1340 + #include <linux/sched.h> /* need_resched() */
1341 ++#include <linux/sort.h>
1342 + #include <linux/tick.h>
1343 + #include <linux/cpuidle.h>
1344 + #include <linux/cpu.h>
1345 +@@ -540,10 +541,37 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
1346 + return;
1347 + }
1348 +
1349 ++static int acpi_cst_latency_cmp(const void *a, const void *b)
1350 ++{
1351 ++ const struct acpi_processor_cx *x = a, *y = b;
1352 ++
1353 ++ if (!(x->valid && y->valid))
1354 ++ return 0;
1355 ++ if (x->latency > y->latency)
1356 ++ return 1;
1357 ++ if (x->latency < y->latency)
1358 ++ return -1;
1359 ++ return 0;
1360 ++}
1361 ++static void acpi_cst_latency_swap(void *a, void *b, int n)
1362 ++{
1363 ++ struct acpi_processor_cx *x = a, *y = b;
1364 ++ u32 tmp;
1365 ++
1366 ++ if (!(x->valid && y->valid))
1367 ++ return;
1368 ++ tmp = x->latency;
1369 ++ x->latency = y->latency;
1370 ++ y->latency = tmp;
1371 ++}
1372 ++
1373 + static int acpi_processor_power_verify(struct acpi_processor *pr)
1374 + {
1375 + unsigned int i;
1376 + unsigned int working = 0;
1377 ++ unsigned int last_latency = 0;
1378 ++ unsigned int last_type = 0;
1379 ++ bool buggy_latency = false;
1380 +
1381 + pr->power.timer_broadcast_on_state = INT_MAX;
1382 +
1383 +@@ -567,12 +595,24 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
1384 + }
1385 + if (!cx->valid)
1386 + continue;
1387 ++ if (cx->type >= last_type && cx->latency < last_latency)
1388 ++ buggy_latency = true;
1389 ++ last_latency = cx->latency;
1390 ++ last_type = cx->type;
1391 +
1392 + lapic_timer_check_state(i, pr, cx);
1393 + tsc_check_state(cx->type);
1394 + working++;
1395 + }
1396 +
1397 ++ if (buggy_latency) {
1398 ++ pr_notice("FW issue: working around C-state latencies out of order\n");
1399 ++ sort(&pr->power.states[1], max_cstate,
1400 ++ sizeof(struct acpi_processor_cx),
1401 ++ acpi_cst_latency_cmp,
1402 ++ acpi_cst_latency_swap);
1403 ++ }
1404 ++
1405 + lapic_timer_propagate_broadcast(pr);
1406 +
1407 + return (working);
1408 +diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
1409 +index 48ca9a844f06b..55c57b703ea3c 100644
1410 +--- a/drivers/acpi/resource.c
1411 ++++ b/drivers/acpi/resource.c
1412 +@@ -430,6 +430,13 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi,
1413 + }
1414 + }
1415 +
1416 ++static bool irq_is_legacy(struct acpi_resource_irq *irq)
1417 ++{
1418 ++ return irq->triggering == ACPI_EDGE_SENSITIVE &&
1419 ++ irq->polarity == ACPI_ACTIVE_HIGH &&
1420 ++ irq->shareable == ACPI_EXCLUSIVE;
1421 ++}
1422 ++
1423 + /**
1424 + * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information.
1425 + * @ares: Input ACPI resource object.
1426 +@@ -468,7 +475,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
1427 + }
1428 + acpi_dev_get_irqresource(res, irq->interrupts[index],
1429 + irq->triggering, irq->polarity,
1430 +- irq->shareable, true);
1431 ++ irq->shareable, irq_is_legacy(irq));
1432 + break;
1433 + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
1434 + ext_irq = &ares->data.extended_irq;
1435 +diff --git a/drivers/ata/pata_ep93xx.c b/drivers/ata/pata_ep93xx.c
1436 +index badab67088935..46208ececbb6a 100644
1437 +--- a/drivers/ata/pata_ep93xx.c
1438 ++++ b/drivers/ata/pata_ep93xx.c
1439 +@@ -928,7 +928,7 @@ static int ep93xx_pata_probe(struct platform_device *pdev)
1440 + /* INT[3] (IRQ_EP93XX_EXT3) line connected as pull down */
1441 + irq = platform_get_irq(pdev, 0);
1442 + if (irq < 0) {
1443 +- err = -ENXIO;
1444 ++ err = irq;
1445 + goto err_rel_gpio;
1446 + }
1447 +
1448 +diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
1449 +index d3d851b014a37..ac3b1fda820ff 100644
1450 +--- a/drivers/ata/pata_octeon_cf.c
1451 ++++ b/drivers/ata/pata_octeon_cf.c
1452 +@@ -898,10 +898,11 @@ static int octeon_cf_probe(struct platform_device *pdev)
1453 + return -EINVAL;
1454 + }
1455 +
1456 +- irq_handler = octeon_cf_interrupt;
1457 + i = platform_get_irq(dma_dev, 0);
1458 +- if (i > 0)
1459 ++ if (i > 0) {
1460 + irq = i;
1461 ++ irq_handler = octeon_cf_interrupt;
1462 ++ }
1463 + }
1464 + of_node_put(dma_node);
1465 + }
1466 +diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
1467 +index deae466395de1..1e6d61dc966ad 100644
1468 +--- a/drivers/ata/pata_rb532_cf.c
1469 ++++ b/drivers/ata/pata_rb532_cf.c
1470 +@@ -115,10 +115,12 @@ static int rb532_pata_driver_probe(struct platform_device *pdev)
1471 + }
1472 +
1473 + irq = platform_get_irq(pdev, 0);
1474 +- if (irq <= 0) {
1475 ++ if (irq < 0) {
1476 + dev_err(&pdev->dev, "no IRQ resource found\n");
1477 +- return -ENOENT;
1478 ++ return irq;
1479 + }
1480 ++ if (!irq)
1481 ++ return -EINVAL;
1482 +
1483 + gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_IN);
1484 + if (IS_ERR(gpiod)) {
1485 +diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
1486 +index ad3893c62572d..bcf705f512f0f 100644
1487 +--- a/drivers/ata/sata_highbank.c
1488 ++++ b/drivers/ata/sata_highbank.c
1489 +@@ -469,10 +469,12 @@ static int ahci_highbank_probe(struct platform_device *pdev)
1490 + }
1491 +
1492 + irq = platform_get_irq(pdev, 0);
1493 +- if (irq <= 0) {
1494 ++ if (irq < 0) {
1495 + dev_err(dev, "no irq\n");
1496 +- return -EINVAL;
1497 ++ return irq;
1498 + }
1499 ++ if (!irq)
1500 ++ return -EINVAL;
1501 +
1502 + hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
1503 + if (!hpriv) {
1504 +diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
1505 +index b4b52ab23b6b1..b4e931dbff664 100644
1506 +--- a/drivers/char/hw_random/exynos-trng.c
1507 ++++ b/drivers/char/hw_random/exynos-trng.c
1508 +@@ -134,7 +134,7 @@ static int exynos_trng_probe(struct platform_device *pdev)
1509 + return PTR_ERR(trng->mem);
1510 +
1511 + pm_runtime_enable(&pdev->dev);
1512 +- ret = pm_runtime_get_sync(&pdev->dev);
1513 ++ ret = pm_runtime_resume_and_get(&pdev->dev);
1514 + if (ret < 0) {
1515 + dev_err(&pdev->dev, "Could not get runtime PM.\n");
1516 + goto err_pm_get;
1517 +@@ -167,7 +167,7 @@ err_register:
1518 + clk_disable_unprepare(trng->clk);
1519 +
1520 + err_clock:
1521 +- pm_runtime_put_sync(&pdev->dev);
1522 ++ pm_runtime_put_noidle(&pdev->dev);
1523 +
1524 + err_pm_get:
1525 + pm_runtime_disable(&pdev->dev);
1526 +diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
1527 +index 15bf585af5d38..44117169db919 100644
1528 +--- a/drivers/char/pcmcia/cm4000_cs.c
1529 ++++ b/drivers/char/pcmcia/cm4000_cs.c
1530 +@@ -544,6 +544,10 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
1531 + io_read_num_rec_bytes(iobase, &num_bytes_read);
1532 + if (num_bytes_read >= 4) {
1533 + DEBUGP(2, dev, "NumRecBytes = %i\n", num_bytes_read);
1534 ++ if (num_bytes_read > 4) {
1535 ++ rc = -EIO;
1536 ++ goto exit_setprotocol;
1537 ++ }
1538 + break;
1539 + }
1540 + usleep_range(10000, 11000);
1541 +diff --git a/drivers/clk/actions/owl-s500.c b/drivers/clk/actions/owl-s500.c
1542 +index 0eb83a0b70bcc..0528536ed9eb7 100644
1543 +--- a/drivers/clk/actions/owl-s500.c
1544 ++++ b/drivers/clk/actions/owl-s500.c
1545 +@@ -125,8 +125,7 @@ static struct clk_factor_table sd_factor_table[] = {
1546 + { 12, 1, 13 }, { 13, 1, 14 }, { 14, 1, 15 }, { 15, 1, 16 },
1547 + { 16, 1, 17 }, { 17, 1, 18 }, { 18, 1, 19 }, { 19, 1, 20 },
1548 + { 20, 1, 21 }, { 21, 1, 22 }, { 22, 1, 23 }, { 23, 1, 24 },
1549 +- { 24, 1, 25 }, { 25, 1, 26 }, { 26, 1, 27 }, { 27, 1, 28 },
1550 +- { 28, 1, 29 }, { 29, 1, 30 }, { 30, 1, 31 }, { 31, 1, 32 },
1551 ++ { 24, 1, 25 },
1552 +
1553 + /* bit8: /128 */
1554 + { 256, 1, 1 * 128 }, { 257, 1, 2 * 128 }, { 258, 1, 3 * 128 }, { 259, 1, 4 * 128 },
1555 +@@ -135,14 +134,20 @@ static struct clk_factor_table sd_factor_table[] = {
1556 + { 268, 1, 13 * 128 }, { 269, 1, 14 * 128 }, { 270, 1, 15 * 128 }, { 271, 1, 16 * 128 },
1557 + { 272, 1, 17 * 128 }, { 273, 1, 18 * 128 }, { 274, 1, 19 * 128 }, { 275, 1, 20 * 128 },
1558 + { 276, 1, 21 * 128 }, { 277, 1, 22 * 128 }, { 278, 1, 23 * 128 }, { 279, 1, 24 * 128 },
1559 +- { 280, 1, 25 * 128 }, { 281, 1, 26 * 128 }, { 282, 1, 27 * 128 }, { 283, 1, 28 * 128 },
1560 +- { 284, 1, 29 * 128 }, { 285, 1, 30 * 128 }, { 286, 1, 31 * 128 }, { 287, 1, 32 * 128 },
1561 ++ { 280, 1, 25 * 128 },
1562 + { 0, 0, 0 },
1563 + };
1564 +
1565 +-static struct clk_factor_table bisp_factor_table[] = {
1566 +- { 0, 1, 1 }, { 1, 1, 2 }, { 2, 1, 3 }, { 3, 1, 4 },
1567 +- { 4, 1, 5 }, { 5, 1, 6 }, { 6, 1, 7 }, { 7, 1, 8 },
1568 ++static struct clk_factor_table de_factor_table[] = {
1569 ++ { 0, 1, 1 }, { 1, 2, 3 }, { 2, 1, 2 }, { 3, 2, 5 },
1570 ++ { 4, 1, 3 }, { 5, 1, 4 }, { 6, 1, 6 }, { 7, 1, 8 },
1571 ++ { 8, 1, 12 },
1572 ++ { 0, 0, 0 },
1573 ++};
1574 ++
1575 ++static struct clk_factor_table hde_factor_table[] = {
1576 ++ { 0, 1, 1 }, { 1, 2, 3 }, { 2, 1, 2 }, { 3, 2, 5 },
1577 ++ { 4, 1, 3 }, { 5, 1, 4 }, { 6, 1, 6 }, { 7, 1, 8 },
1578 + { 0, 0, 0 },
1579 + };
1580 +
1581 +@@ -156,6 +161,13 @@ static struct clk_div_table rmii_ref_div_table[] = {
1582 + { 0, 0 },
1583 + };
1584 +
1585 ++static struct clk_div_table std12rate_div_table[] = {
1586 ++ { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 4 },
1587 ++ { 4, 5 }, { 5, 6 }, { 6, 7 }, { 7, 8 },
1588 ++ { 8, 9 }, { 9, 10 }, { 10, 11 }, { 11, 12 },
1589 ++ { 0, 0 },
1590 ++};
1591 ++
1592 + static struct clk_div_table i2s_div_table[] = {
1593 + { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 4 },
1594 + { 4, 6 }, { 5, 8 }, { 6, 12 }, { 7, 16 },
1595 +@@ -188,39 +200,39 @@ static OWL_DIVIDER(rmii_ref_clk, "rmii_ref_clk", "ethernet_pll_clk", CMU_ETHERNE
1596 +
1597 + /* factor clocks */
1598 + static OWL_FACTOR(ahb_clk, "ahb_clk", "h_clk", CMU_BUSCLK1, 2, 2, ahb_factor_table, 0, 0);
1599 +-static OWL_FACTOR(de1_clk, "de_clk1", "de_clk", CMU_DECLK, 0, 3, bisp_factor_table, 0, 0);
1600 +-static OWL_FACTOR(de2_clk, "de_clk2", "de_clk", CMU_DECLK, 4, 3, bisp_factor_table, 0, 0);
1601 ++static OWL_FACTOR(de1_clk, "de_clk1", "de_clk", CMU_DECLK, 0, 4, de_factor_table, 0, 0);
1602 ++static OWL_FACTOR(de2_clk, "de_clk2", "de_clk", CMU_DECLK, 4, 4, de_factor_table, 0, 0);
1603 +
1604 + /* composite clocks */
1605 + static OWL_COMP_FACTOR(vce_clk, "vce_clk", hde_clk_mux_p,
1606 + OWL_MUX_HW(CMU_VCECLK, 4, 2),
1607 + OWL_GATE_HW(CMU_DEVCLKEN0, 26, 0),
1608 +- OWL_FACTOR_HW(CMU_VCECLK, 0, 3, 0, bisp_factor_table),
1609 ++ OWL_FACTOR_HW(CMU_VCECLK, 0, 3, 0, hde_factor_table),
1610 + 0);
1611 +
1612 + static OWL_COMP_FACTOR(vde_clk, "vde_clk", hde_clk_mux_p,
1613 + OWL_MUX_HW(CMU_VDECLK, 4, 2),
1614 + OWL_GATE_HW(CMU_DEVCLKEN0, 25, 0),
1615 +- OWL_FACTOR_HW(CMU_VDECLK, 0, 3, 0, bisp_factor_table),
1616 ++ OWL_FACTOR_HW(CMU_VDECLK, 0, 3, 0, hde_factor_table),
1617 + 0);
1618 +
1619 +-static OWL_COMP_FACTOR(bisp_clk, "bisp_clk", bisp_clk_mux_p,
1620 ++static OWL_COMP_DIV(bisp_clk, "bisp_clk", bisp_clk_mux_p,
1621 + OWL_MUX_HW(CMU_BISPCLK, 4, 1),
1622 + OWL_GATE_HW(CMU_DEVCLKEN0, 14, 0),
1623 +- OWL_FACTOR_HW(CMU_BISPCLK, 0, 3, 0, bisp_factor_table),
1624 ++ OWL_DIVIDER_HW(CMU_BISPCLK, 0, 4, 0, std12rate_div_table),
1625 + 0);
1626 +
1627 +-static OWL_COMP_FACTOR(sensor0_clk, "sensor0_clk", sensor_clk_mux_p,
1628 ++static OWL_COMP_DIV(sensor0_clk, "sensor0_clk", sensor_clk_mux_p,
1629 + OWL_MUX_HW(CMU_SENSORCLK, 4, 1),
1630 + OWL_GATE_HW(CMU_DEVCLKEN0, 14, 0),
1631 +- OWL_FACTOR_HW(CMU_SENSORCLK, 0, 3, 0, bisp_factor_table),
1632 +- CLK_IGNORE_UNUSED);
1633 ++ OWL_DIVIDER_HW(CMU_SENSORCLK, 0, 4, 0, std12rate_div_table),
1634 ++ 0);
1635 +
1636 +-static OWL_COMP_FACTOR(sensor1_clk, "sensor1_clk", sensor_clk_mux_p,
1637 ++static OWL_COMP_DIV(sensor1_clk, "sensor1_clk", sensor_clk_mux_p,
1638 + OWL_MUX_HW(CMU_SENSORCLK, 4, 1),
1639 + OWL_GATE_HW(CMU_DEVCLKEN0, 14, 0),
1640 +- OWL_FACTOR_HW(CMU_SENSORCLK, 8, 3, 0, bisp_factor_table),
1641 +- CLK_IGNORE_UNUSED);
1642 ++ OWL_DIVIDER_HW(CMU_SENSORCLK, 8, 4, 0, std12rate_div_table),
1643 ++ 0);
1644 +
1645 + static OWL_COMP_FACTOR(sd0_clk, "sd0_clk", sd_clk_mux_p,
1646 + OWL_MUX_HW(CMU_SD0CLK, 9, 1),
1647 +@@ -300,7 +312,7 @@ static OWL_COMP_FIXED_FACTOR(i2c3_clk, "i2c3_clk", "ethernet_pll_clk",
1648 + static OWL_COMP_DIV(uart0_clk, "uart0_clk", uart_clk_mux_p,
1649 + OWL_MUX_HW(CMU_UART0CLK, 16, 1),
1650 + OWL_GATE_HW(CMU_DEVCLKEN1, 6, 0),
1651 +- OWL_DIVIDER_HW(CMU_UART1CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1652 ++ OWL_DIVIDER_HW(CMU_UART0CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1653 + CLK_IGNORE_UNUSED);
1654 +
1655 + static OWL_COMP_DIV(uart1_clk, "uart1_clk", uart_clk_mux_p,
1656 +@@ -312,31 +324,31 @@ static OWL_COMP_DIV(uart1_clk, "uart1_clk", uart_clk_mux_p,
1657 + static OWL_COMP_DIV(uart2_clk, "uart2_clk", uart_clk_mux_p,
1658 + OWL_MUX_HW(CMU_UART2CLK, 16, 1),
1659 + OWL_GATE_HW(CMU_DEVCLKEN1, 8, 0),
1660 +- OWL_DIVIDER_HW(CMU_UART1CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1661 ++ OWL_DIVIDER_HW(CMU_UART2CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1662 + CLK_IGNORE_UNUSED);
1663 +
1664 + static OWL_COMP_DIV(uart3_clk, "uart3_clk", uart_clk_mux_p,
1665 + OWL_MUX_HW(CMU_UART3CLK, 16, 1),
1666 + OWL_GATE_HW(CMU_DEVCLKEN1, 19, 0),
1667 +- OWL_DIVIDER_HW(CMU_UART1CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1668 ++ OWL_DIVIDER_HW(CMU_UART3CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1669 + CLK_IGNORE_UNUSED);
1670 +
1671 + static OWL_COMP_DIV(uart4_clk, "uart4_clk", uart_clk_mux_p,
1672 + OWL_MUX_HW(CMU_UART4CLK, 16, 1),
1673 + OWL_GATE_HW(CMU_DEVCLKEN1, 20, 0),
1674 +- OWL_DIVIDER_HW(CMU_UART1CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1675 ++ OWL_DIVIDER_HW(CMU_UART4CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1676 + CLK_IGNORE_UNUSED);
1677 +
1678 + static OWL_COMP_DIV(uart5_clk, "uart5_clk", uart_clk_mux_p,
1679 + OWL_MUX_HW(CMU_UART5CLK, 16, 1),
1680 + OWL_GATE_HW(CMU_DEVCLKEN1, 21, 0),
1681 +- OWL_DIVIDER_HW(CMU_UART1CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1682 ++ OWL_DIVIDER_HW(CMU_UART5CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1683 + CLK_IGNORE_UNUSED);
1684 +
1685 + static OWL_COMP_DIV(uart6_clk, "uart6_clk", uart_clk_mux_p,
1686 + OWL_MUX_HW(CMU_UART6CLK, 16, 1),
1687 + OWL_GATE_HW(CMU_DEVCLKEN1, 18, 0),
1688 +- OWL_DIVIDER_HW(CMU_UART1CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1689 ++ OWL_DIVIDER_HW(CMU_UART6CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
1690 + CLK_IGNORE_UNUSED);
1691 +
1692 + static OWL_COMP_DIV(i2srx_clk, "i2srx_clk", i2s_clk_mux_p,
1693 +diff --git a/drivers/clk/clk-si5341.c b/drivers/clk/clk-si5341.c
1694 +index 6e780c2a9e6ba..8f9f3d4a54fd2 100644
1695 +--- a/drivers/clk/clk-si5341.c
1696 ++++ b/drivers/clk/clk-si5341.c
1697 +@@ -304,6 +304,8 @@ static const struct si5341_reg_default si5341_reg_defaults[] = {
1698 + { 0x094A, 0x00 }, /* INx_TO_PFD_EN (disabled) */
1699 + { 0x0A02, 0x00 }, /* Not in datasheet */
1700 + { 0x0B44, 0x0F }, /* PDIV_ENB (datasheet does not mention what it is) */
1701 ++ { 0x0B57, 0x10 }, /* VCO_RESET_CALCODE (not described in datasheet) */
1702 ++ { 0x0B58, 0x05 }, /* VCO_RESET_CALCODE (not described in datasheet) */
1703 + };
1704 +
1705 + /* Read and interpret a 44-bit followed by a 32-bit value in the regmap */
1706 +@@ -482,6 +484,9 @@ static unsigned long si5341_synth_clk_recalc_rate(struct clk_hw *hw,
1707 + SI5341_SYNTH_N_NUM(synth->index), &n_num, &n_den);
1708 + if (err < 0)
1709 + return err;
1710 ++ /* Check for bogus/uninitialized settings */
1711 ++ if (!n_num || !n_den)
1712 ++ return 0;
1713 +
1714 + /*
1715 + * n_num and n_den are shifted left as much as possible, so to prevent
1716 +@@ -665,6 +670,9 @@ static long si5341_output_clk_round_rate(struct clk_hw *hw, unsigned long rate,
1717 + {
1718 + unsigned long r;
1719 +
1720 ++ if (!rate)
1721 ++ return 0;
1722 ++
1723 + r = *parent_rate >> 1;
1724 +
1725 + /* If rate is an even divisor, no changes to parent required */
1726 +@@ -693,11 +701,16 @@ static int si5341_output_clk_set_rate(struct clk_hw *hw, unsigned long rate,
1727 + unsigned long parent_rate)
1728 + {
1729 + struct clk_si5341_output *output = to_clk_si5341_output(hw);
1730 +- /* Frequency divider is (r_div + 1) * 2 */
1731 +- u32 r_div = (parent_rate / rate) >> 1;
1732 ++ u32 r_div;
1733 + int err;
1734 + u8 r[3];
1735 +
1736 ++ if (!rate)
1737 ++ return -EINVAL;
1738 ++
1739 ++ /* Frequency divider is (r_div + 1) * 2 */
1740 ++ r_div = (parent_rate / rate) >> 1;
1741 ++
1742 + if (r_div <= 1)
1743 + r_div = 0;
1744 + else if (r_div >= BIT(24))
1745 +@@ -924,7 +937,7 @@ static const struct si5341_reg_default si5341_preamble[] = {
1746 + { 0x0B25, 0x00 },
1747 + { 0x0502, 0x01 },
1748 + { 0x0505, 0x03 },
1749 +- { 0x0957, 0x1F },
1750 ++ { 0x0957, 0x17 },
1751 + { 0x0B4E, 0x1A },
1752 + };
1753 +
1754 +diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
1755 +index 3143e16065de6..a55b22ebf103c 100644
1756 +--- a/drivers/clk/meson/g12a.c
1757 ++++ b/drivers/clk/meson/g12a.c
1758 +@@ -1602,7 +1602,7 @@ static struct clk_regmap g12b_cpub_clk_trace = {
1759 + };
1760 +
1761 + static const struct pll_mult_range g12a_gp0_pll_mult_range = {
1762 +- .min = 55,
1763 ++ .min = 125,
1764 + .max = 255,
1765 + };
1766 +
1767 +diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
1768 +index 194a6587a1de1..c4e928375c40d 100644
1769 +--- a/drivers/cpufreq/cpufreq.c
1770 ++++ b/drivers/cpufreq/cpufreq.c
1771 +@@ -1361,9 +1361,14 @@ static int cpufreq_online(unsigned int cpu)
1772 + goto out_free_policy;
1773 + }
1774 +
1775 ++ /*
1776 ++ * The initialization has succeeded and the policy is online.
1777 ++ * If there is a problem with its frequency table, take it
1778 ++ * offline and drop it.
1779 ++ */
1780 + ret = cpufreq_table_validate_and_sort(policy);
1781 + if (ret)
1782 +- goto out_exit_policy;
1783 ++ goto out_offline_policy;
1784 +
1785 + /* related_cpus should at least include policy->cpus. */
1786 + cpumask_copy(policy->related_cpus, policy->cpus);
1787 +@@ -1507,6 +1512,10 @@ out_destroy_policy:
1788 +
1789 + up_write(&policy->rwsem);
1790 +
1791 ++out_offline_policy:
1792 ++ if (cpufreq_driver->offline)
1793 ++ cpufreq_driver->offline(policy);
1794 ++
1795 + out_exit_policy:
1796 + if (cpufreq_driver->exit)
1797 + cpufreq_driver->exit(policy);
1798 +diff --git a/drivers/crypto/cavium/nitrox/nitrox_isr.c b/drivers/crypto/cavium/nitrox/nitrox_isr.c
1799 +index 3dec570a190ad..10e3408bf704c 100644
1800 +--- a/drivers/crypto/cavium/nitrox/nitrox_isr.c
1801 ++++ b/drivers/crypto/cavium/nitrox/nitrox_isr.c
1802 +@@ -306,6 +306,10 @@ int nitrox_register_interrupts(struct nitrox_device *ndev)
1803 + * Entry 192: NPS_CORE_INT_ACTIVE
1804 + */
1805 + nr_vecs = pci_msix_vec_count(pdev);
1806 ++ if (nr_vecs < 0) {
1807 ++ dev_err(DEV(ndev), "Error in getting vec count %d\n", nr_vecs);
1808 ++ return nr_vecs;
1809 ++ }
1810 +
1811 + /* Enable MSI-X */
1812 + ret = pci_alloc_irq_vectors(pdev, nr_vecs, nr_vecs, PCI_IRQ_MSIX);
1813 +diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
1814 +index b29d2e663e104..f607b19ff4d23 100644
1815 +--- a/drivers/crypto/ccp/sp-pci.c
1816 ++++ b/drivers/crypto/ccp/sp-pci.c
1817 +@@ -213,7 +213,7 @@ static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1818 + if (ret) {
1819 + dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n",
1820 + ret);
1821 +- goto e_err;
1822 ++ goto free_irqs;
1823 + }
1824 + }
1825 +
1826 +@@ -221,10 +221,12 @@ static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1827 +
1828 + ret = sp_init(sp);
1829 + if (ret)
1830 +- goto e_err;
1831 ++ goto free_irqs;
1832 +
1833 + return 0;
1834 +
1835 ++free_irqs:
1836 ++ sp_free_irqs(sp);
1837 + e_err:
1838 + dev_notice(dev, "initialization failed\n");
1839 + return ret;
1840 +diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
1841 +index acaa504d5a798..e02ff2b205d01 100644
1842 +--- a/drivers/crypto/ixp4xx_crypto.c
1843 ++++ b/drivers/crypto/ixp4xx_crypto.c
1844 +@@ -329,7 +329,7 @@ static void free_buf_chain(struct device *dev, struct buffer_desc *buf,
1845 +
1846 + buf1 = buf->next;
1847 + phys1 = buf->phys_next;
1848 +- dma_unmap_single(dev, buf->phys_next, buf->buf_len, buf->dir);
1849 ++ dma_unmap_single(dev, buf->phys_addr, buf->buf_len, buf->dir);
1850 + dma_pool_free(buffer_pool, buf, phys);
1851 + buf = buf1;
1852 + phys = phys1;
1853 +diff --git a/drivers/crypto/nx/nx-842-pseries.c b/drivers/crypto/nx/nx-842-pseries.c
1854 +index 2de5e3672e423..c5ec50a28f30d 100644
1855 +--- a/drivers/crypto/nx/nx-842-pseries.c
1856 ++++ b/drivers/crypto/nx/nx-842-pseries.c
1857 +@@ -538,13 +538,15 @@ static int nx842_OF_set_defaults(struct nx842_devdata *devdata)
1858 + * The status field indicates if the device is enabled when the status
1859 + * is 'okay'. Otherwise the device driver will be disabled.
1860 + *
1861 +- * @prop - struct property point containing the maxsyncop for the update
1862 ++ * @devdata: struct nx842_devdata to use for dev_info
1863 ++ * @prop: struct property point containing the maxsyncop for the update
1864 + *
1865 + * Returns:
1866 + * 0 - Device is available
1867 + * -ENODEV - Device is not available
1868 + */
1869 +-static int nx842_OF_upd_status(struct property *prop)
1870 ++static int nx842_OF_upd_status(struct nx842_devdata *devdata,
1871 ++ struct property *prop)
1872 + {
1873 + const char *status = (const char *)prop->value;
1874 +
1875 +@@ -758,7 +760,7 @@ static int nx842_OF_upd(struct property *new_prop)
1876 + goto out;
1877 +
1878 + /* Perform property updates */
1879 +- ret = nx842_OF_upd_status(status);
1880 ++ ret = nx842_OF_upd_status(new_devdata, status);
1881 + if (ret)
1882 + goto error_out;
1883 +
1884 +@@ -1071,6 +1073,7 @@ static const struct vio_device_id nx842_vio_driver_ids[] = {
1885 + {"ibm,compression-v1", "ibm,compression"},
1886 + {"", ""},
1887 + };
1888 ++MODULE_DEVICE_TABLE(vio, nx842_vio_driver_ids);
1889 +
1890 + static struct vio_driver nx842_vio_driver = {
1891 + .name = KBUILD_MODNAME,
1892 +diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
1893 +index d7c0c982ba433..f80db1eb29945 100644
1894 +--- a/drivers/crypto/omap-sham.c
1895 ++++ b/drivers/crypto/omap-sham.c
1896 +@@ -364,7 +364,7 @@ static int omap_sham_hw_init(struct omap_sham_dev *dd)
1897 + {
1898 + int err;
1899 +
1900 +- err = pm_runtime_get_sync(dd->dev);
1901 ++ err = pm_runtime_resume_and_get(dd->dev);
1902 + if (err < 0) {
1903 + dev_err(dd->dev, "failed to get sync: %d\n", err);
1904 + return err;
1905 +@@ -2236,7 +2236,7 @@ static int omap_sham_suspend(struct device *dev)
1906 +
1907 + static int omap_sham_resume(struct device *dev)
1908 + {
1909 +- int err = pm_runtime_get_sync(dev);
1910 ++ int err = pm_runtime_resume_and_get(dev);
1911 + if (err < 0) {
1912 + dev_err(dev, "failed to get sync: %d\n", err);
1913 + return err;
1914 +diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c
1915 +index dac130bb807ae..eda692271f0c7 100644
1916 +--- a/drivers/crypto/qat/qat_common/qat_hal.c
1917 ++++ b/drivers/crypto/qat/qat_common/qat_hal.c
1918 +@@ -1256,7 +1256,11 @@ static int qat_hal_put_rel_wr_xfer(struct icp_qat_fw_loader_handle *handle,
1919 + pr_err("QAT: bad xfrAddr=0x%x\n", xfr_addr);
1920 + return -EINVAL;
1921 + }
1922 +- qat_hal_rd_rel_reg(handle, ae, ctx, ICP_GPB_REL, gprnum, &gprval);
1923 ++ status = qat_hal_rd_rel_reg(handle, ae, ctx, ICP_GPB_REL, gprnum, &gprval);
1924 ++ if (status) {
1925 ++ pr_err("QAT: failed to read register");
1926 ++ return status;
1927 ++ }
1928 + gpr_addr = qat_hal_get_reg_addr(ICP_GPB_REL, gprnum);
1929 + data16low = 0xffff & data;
1930 + data16hi = 0xffff & (data >> 0x10);
1931 +diff --git a/drivers/crypto/qat/qat_common/qat_uclo.c b/drivers/crypto/qat/qat_common/qat_uclo.c
1932 +index aeb03081415cb..9542423bb7ca5 100644
1933 +--- a/drivers/crypto/qat/qat_common/qat_uclo.c
1934 ++++ b/drivers/crypto/qat/qat_common/qat_uclo.c
1935 +@@ -385,7 +385,6 @@ static int qat_uclo_init_umem_seg(struct icp_qat_fw_loader_handle *handle,
1936 + return 0;
1937 + }
1938 +
1939 +-#define ICP_DH895XCC_PESRAM_BAR_SIZE 0x80000
1940 + static int qat_uclo_init_ae_memory(struct icp_qat_fw_loader_handle *handle,
1941 + struct icp_qat_uof_initmem *init_mem)
1942 + {
1943 +diff --git a/drivers/crypto/ux500/hash/hash_core.c b/drivers/crypto/ux500/hash/hash_core.c
1944 +index c172a69534777..38a66aceca2a7 100644
1945 +--- a/drivers/crypto/ux500/hash/hash_core.c
1946 ++++ b/drivers/crypto/ux500/hash/hash_core.c
1947 +@@ -1009,6 +1009,7 @@ static int hash_hw_final(struct ahash_request *req)
1948 + goto out;
1949 + }
1950 + } else if (req->nbytes == 0 && ctx->keylen > 0) {
1951 ++ ret = -EPERM;
1952 + dev_err(device_data->dev, "%s: Empty message with keylength > 0, NOT supported\n",
1953 + __func__);
1954 + goto out;
1955 +diff --git a/drivers/edac/i10nm_base.c b/drivers/edac/i10nm_base.c
1956 +index dfcde7ed95006..f72be5f94e6fa 100644
1957 +--- a/drivers/edac/i10nm_base.c
1958 ++++ b/drivers/edac/i10nm_base.c
1959 +@@ -249,6 +249,9 @@ static int __init i10nm_init(void)
1960 + if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR)))
1961 + return -EBUSY;
1962 +
1963 ++ if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
1964 ++ return -ENODEV;
1965 ++
1966 + id = x86_match_cpu(i10nm_cpuids);
1967 + if (!id)
1968 + return -ENODEV;
1969 +diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c
1970 +index dac45e2071b3f..e054eb0389037 100644
1971 +--- a/drivers/edac/pnd2_edac.c
1972 ++++ b/drivers/edac/pnd2_edac.c
1973 +@@ -1555,6 +1555,9 @@ static int __init pnd2_init(void)
1974 + if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR)))
1975 + return -EBUSY;
1976 +
1977 ++ if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
1978 ++ return -ENODEV;
1979 ++
1980 + id = x86_match_cpu(pnd2_cpuids);
1981 + if (!id)
1982 + return -ENODEV;
1983 +diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
1984 +index b557a53c75c46..d39f5bfb8bd92 100644
1985 +--- a/drivers/edac/sb_edac.c
1986 ++++ b/drivers/edac/sb_edac.c
1987 +@@ -3512,6 +3512,9 @@ static int __init sbridge_init(void)
1988 + if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR)))
1989 + return -EBUSY;
1990 +
1991 ++ if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
1992 ++ return -ENODEV;
1993 ++
1994 + id = x86_match_cpu(sbridge_cpuids);
1995 + if (!id)
1996 + return -ENODEV;
1997 +diff --git a/drivers/edac/skx_base.c b/drivers/edac/skx_base.c
1998 +index 77cd370bd62fe..b1d717cb8df9f 100644
1999 +--- a/drivers/edac/skx_base.c
2000 ++++ b/drivers/edac/skx_base.c
2001 +@@ -605,6 +605,9 @@ static int __init skx_init(void)
2002 + if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR)))
2003 + return -EBUSY;
2004 +
2005 ++ if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
2006 ++ return -ENODEV;
2007 ++
2008 + id = x86_match_cpu(skx_cpuids);
2009 + if (!id)
2010 + return -ENODEV;
2011 +diff --git a/drivers/edac/ti_edac.c b/drivers/edac/ti_edac.c
2012 +index 3247689467435..9ab9fa0a911bd 100644
2013 +--- a/drivers/edac/ti_edac.c
2014 ++++ b/drivers/edac/ti_edac.c
2015 +@@ -197,6 +197,7 @@ static const struct of_device_id ti_edac_of_match[] = {
2016 + { .compatible = "ti,emif-dra7xx", .data = (void *)EMIF_TYPE_DRA7 },
2017 + {},
2018 + };
2019 ++MODULE_DEVICE_TABLE(of, ti_edac_of_match);
2020 +
2021 + static int _emif_get_id(struct device_node *node)
2022 + {
2023 +diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
2024 +index 172e116ac1ced..cac36ef59e452 100644
2025 +--- a/drivers/extcon/extcon-max8997.c
2026 ++++ b/drivers/extcon/extcon-max8997.c
2027 +@@ -729,7 +729,7 @@ static int max8997_muic_probe(struct platform_device *pdev)
2028 + 2, info->status);
2029 + if (ret) {
2030 + dev_err(info->dev, "failed to read MUIC register\n");
2031 +- return ret;
2032 ++ goto err_irq;
2033 + }
2034 + cable_type = max8997_muic_get_cable_type(info,
2035 + MAX8997_CABLE_GROUP_ADC, &attached);
2036 +@@ -784,3 +784,4 @@ module_platform_driver(max8997_muic_driver);
2037 + MODULE_DESCRIPTION("Maxim MAX8997 Extcon driver");
2038 + MODULE_AUTHOR("Donggeun Kim <dg77.kim@×××××××.com>");
2039 + MODULE_LICENSE("GPL");
2040 ++MODULE_ALIAS("platform:max8997-muic");
2041 +diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c
2042 +index b3d93baf4fc58..f883992800b35 100644
2043 +--- a/drivers/extcon/extcon-sm5502.c
2044 ++++ b/drivers/extcon/extcon-sm5502.c
2045 +@@ -88,7 +88,6 @@ static struct reg_data sm5502_reg_data[] = {
2046 + | SM5502_REG_INTM2_MHL_MASK,
2047 + .invert = true,
2048 + },
2049 +- { }
2050 + };
2051 +
2052 + /* List of detectable cables */
2053 +diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
2054 +index b485321189e11..b2b4ba240fb11 100644
2055 +--- a/drivers/firmware/stratix10-svc.c
2056 ++++ b/drivers/firmware/stratix10-svc.c
2057 +@@ -1026,24 +1026,32 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
2058 +
2059 + /* add svc client device(s) */
2060 + svc = devm_kzalloc(dev, sizeof(*svc), GFP_KERNEL);
2061 +- if (!svc)
2062 +- return -ENOMEM;
2063 ++ if (!svc) {
2064 ++ ret = -ENOMEM;
2065 ++ goto err_free_kfifo;
2066 ++ }
2067 +
2068 + svc->stratix10_svc_rsu = platform_device_alloc(STRATIX10_RSU, 0);
2069 + if (!svc->stratix10_svc_rsu) {
2070 + dev_err(dev, "failed to allocate %s device\n", STRATIX10_RSU);
2071 +- return -ENOMEM;
2072 ++ ret = -ENOMEM;
2073 ++ goto err_free_kfifo;
2074 + }
2075 +
2076 + ret = platform_device_add(svc->stratix10_svc_rsu);
2077 +- if (ret) {
2078 +- platform_device_put(svc->stratix10_svc_rsu);
2079 +- return ret;
2080 +- }
2081 ++ if (ret)
2082 ++ goto err_put_device;
2083 ++
2084 + dev_set_drvdata(dev, svc);
2085 +
2086 + pr_info("Intel Service Layer Driver Initialized\n");
2087 +
2088 ++ return 0;
2089 ++
2090 ++err_put_device:
2091 ++ platform_device_put(svc->stratix10_svc_rsu);
2092 ++err_free_kfifo:
2093 ++ kfifo_free(&controller->svc_fifo);
2094 + return ret;
2095 + }
2096 +
2097 +diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
2098 +index 9282239b4d959..cb980a60af0e8 100644
2099 +--- a/drivers/fsi/fsi-core.c
2100 ++++ b/drivers/fsi/fsi-core.c
2101 +@@ -718,7 +718,7 @@ static ssize_t cfam_read(struct file *filep, char __user *buf, size_t count,
2102 + rc = count;
2103 + fail:
2104 + *offset = off;
2105 +- return count;
2106 ++ return rc;
2107 + }
2108 +
2109 + static ssize_t cfam_write(struct file *filep, const char __user *buf,
2110 +@@ -755,7 +755,7 @@ static ssize_t cfam_write(struct file *filep, const char __user *buf,
2111 + rc = count;
2112 + fail:
2113 + *offset = off;
2114 +- return count;
2115 ++ return rc;
2116 + }
2117 +
2118 + static loff_t cfam_llseek(struct file *file, loff_t offset, int whence)
2119 +diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c
2120 +index 7da9c81759ac0..8f16448045705 100644
2121 +--- a/drivers/fsi/fsi-occ.c
2122 ++++ b/drivers/fsi/fsi-occ.c
2123 +@@ -445,6 +445,7 @@ int fsi_occ_submit(struct device *dev, const void *request, size_t req_len,
2124 + goto done;
2125 +
2126 + if (resp->return_status == OCC_RESP_CMD_IN_PRG ||
2127 ++ resp->return_status == OCC_RESP_CRIT_INIT ||
2128 + resp->seq_no != seq_no) {
2129 + rc = -ETIMEDOUT;
2130 +
2131 +diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
2132 +index f54df9ebc8b30..c8ccc99e214fa 100644
2133 +--- a/drivers/fsi/fsi-sbefifo.c
2134 ++++ b/drivers/fsi/fsi-sbefifo.c
2135 +@@ -325,7 +325,8 @@ static int sbefifo_up_write(struct sbefifo *sbefifo, __be32 word)
2136 + static int sbefifo_request_reset(struct sbefifo *sbefifo)
2137 + {
2138 + struct device *dev = &sbefifo->fsi_dev->dev;
2139 +- u32 status, timeout;
2140 ++ unsigned long end_time;
2141 ++ u32 status;
2142 + int rc;
2143 +
2144 + dev_dbg(dev, "Requesting FIFO reset\n");
2145 +@@ -341,7 +342,8 @@ static int sbefifo_request_reset(struct sbefifo *sbefifo)
2146 + }
2147 +
2148 + /* Wait for it to complete */
2149 +- for (timeout = 0; timeout < SBEFIFO_RESET_TIMEOUT; timeout++) {
2150 ++ end_time = jiffies + msecs_to_jiffies(SBEFIFO_RESET_TIMEOUT);
2151 ++ while (!time_after(jiffies, end_time)) {
2152 + rc = sbefifo_regr(sbefifo, SBEFIFO_UP | SBEFIFO_STS, &status);
2153 + if (rc) {
2154 + dev_err(dev, "Failed to read UP fifo status during reset"
2155 +@@ -355,7 +357,7 @@ static int sbefifo_request_reset(struct sbefifo *sbefifo)
2156 + return 0;
2157 + }
2158 +
2159 +- msleep(1);
2160 ++ cond_resched();
2161 + }
2162 + dev_err(dev, "FIFO reset timed out\n");
2163 +
2164 +@@ -400,7 +402,7 @@ static int sbefifo_cleanup_hw(struct sbefifo *sbefifo)
2165 + /* The FIFO already contains a reset request from the SBE ? */
2166 + if (down_status & SBEFIFO_STS_RESET_REQ) {
2167 + dev_info(dev, "Cleanup: FIFO reset request set, resetting\n");
2168 +- rc = sbefifo_regw(sbefifo, SBEFIFO_UP, SBEFIFO_PERFORM_RESET);
2169 ++ rc = sbefifo_regw(sbefifo, SBEFIFO_DOWN, SBEFIFO_PERFORM_RESET);
2170 + if (rc) {
2171 + sbefifo->broken = true;
2172 + dev_err(dev, "Cleanup: Reset reg write failed, rc=%d\n", rc);
2173 +diff --git a/drivers/fsi/fsi-scom.c b/drivers/fsi/fsi-scom.c
2174 +index 004dc03ccf09c..918367621086c 100644
2175 +--- a/drivers/fsi/fsi-scom.c
2176 ++++ b/drivers/fsi/fsi-scom.c
2177 +@@ -38,9 +38,10 @@
2178 + #define SCOM_STATUS_PIB_RESP_MASK 0x00007000
2179 + #define SCOM_STATUS_PIB_RESP_SHIFT 12
2180 +
2181 +-#define SCOM_STATUS_ANY_ERR (SCOM_STATUS_PROTECTION | \
2182 +- SCOM_STATUS_PARITY | \
2183 +- SCOM_STATUS_PIB_ABORT | \
2184 ++#define SCOM_STATUS_FSI2PIB_ERROR (SCOM_STATUS_PROTECTION | \
2185 ++ SCOM_STATUS_PARITY | \
2186 ++ SCOM_STATUS_PIB_ABORT)
2187 ++#define SCOM_STATUS_ANY_ERR (SCOM_STATUS_FSI2PIB_ERROR | \
2188 + SCOM_STATUS_PIB_RESP_MASK)
2189 + /* SCOM address encodings */
2190 + #define XSCOM_ADDR_IND_FLAG BIT_ULL(63)
2191 +@@ -240,13 +241,14 @@ static int handle_fsi2pib_status(struct scom_device *scom, uint32_t status)
2192 + {
2193 + uint32_t dummy = -1;
2194 +
2195 +- if (status & SCOM_STATUS_PROTECTION)
2196 +- return -EPERM;
2197 +- if (status & SCOM_STATUS_PARITY) {
2198 ++ if (status & SCOM_STATUS_FSI2PIB_ERROR)
2199 + fsi_device_write(scom->fsi_dev, SCOM_FSI2PIB_RESET_REG, &dummy,
2200 + sizeof(uint32_t));
2201 ++
2202 ++ if (status & SCOM_STATUS_PROTECTION)
2203 ++ return -EPERM;
2204 ++ if (status & SCOM_STATUS_PARITY)
2205 + return -EIO;
2206 +- }
2207 + /* Return -EBUSY on PIB abort to force a retry */
2208 + if (status & SCOM_STATUS_PIB_ABORT)
2209 + return -EBUSY;
2210 +diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
2211 +index 272d19b677d8f..4a0dc13480973 100644
2212 +--- a/drivers/gpu/drm/qxl/qxl_dumb.c
2213 ++++ b/drivers/gpu/drm/qxl/qxl_dumb.c
2214 +@@ -58,6 +58,8 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,
2215 + surf.height = args->height;
2216 + surf.stride = pitch;
2217 + surf.format = format;
2218 ++ surf.data = 0;
2219 ++
2220 + r = qxl_gem_object_create_with_handle(qdev, file_priv,
2221 + QXL_GEM_DOMAIN_SURFACE,
2222 + args->size, &surf, &qobj,
2223 +diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c
2224 +index d505ea7d5384f..8f299d76b69b8 100644
2225 +--- a/drivers/gpu/drm/rockchip/cdn-dp-core.c
2226 ++++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
2227 +@@ -72,6 +72,7 @@ static int cdn_dp_grf_write(struct cdn_dp_device *dp,
2228 + ret = regmap_write(dp->grf, reg, val);
2229 + if (ret) {
2230 + DRM_DEV_ERROR(dp->dev, "Could not write to GRF: %d\n", ret);
2231 ++ clk_disable_unprepare(dp->grf_clk);
2232 + return ret;
2233 + }
2234 +
2235 +diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
2236 +index bc073ec5c1839..ecb59dc6c8b8b 100644
2237 +--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
2238 ++++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
2239 +@@ -564,13 +564,8 @@ static const struct dw_mipi_dsi_phy_ops dw_mipi_dsi_rockchip_phy_ops = {
2240 + .get_lane_mbps = dw_mipi_dsi_get_lane_mbps,
2241 + };
2242 +
2243 +-static void dw_mipi_dsi_rockchip_config(struct dw_mipi_dsi_rockchip *dsi,
2244 +- int mux)
2245 ++static void dw_mipi_dsi_rockchip_config(struct dw_mipi_dsi_rockchip *dsi)
2246 + {
2247 +- if (dsi->cdata->lcdsel_grf_reg)
2248 +- regmap_write(dsi->grf_regmap, dsi->cdata->lcdsel_grf_reg,
2249 +- mux ? dsi->cdata->lcdsel_lit : dsi->cdata->lcdsel_big);
2250 +-
2251 + if (dsi->cdata->lanecfg1_grf_reg)
2252 + regmap_write(dsi->grf_regmap, dsi->cdata->lanecfg1_grf_reg,
2253 + dsi->cdata->lanecfg1);
2254 +@@ -584,6 +579,13 @@ static void dw_mipi_dsi_rockchip_config(struct dw_mipi_dsi_rockchip *dsi,
2255 + dsi->cdata->enable);
2256 + }
2257 +
2258 ++static void dw_mipi_dsi_rockchip_set_lcdsel(struct dw_mipi_dsi_rockchip *dsi,
2259 ++ int mux)
2260 ++{
2261 ++ regmap_write(dsi->grf_regmap, dsi->cdata->lcdsel_grf_reg,
2262 ++ mux ? dsi->cdata->lcdsel_lit : dsi->cdata->lcdsel_big);
2263 ++}
2264 ++
2265 + static int
2266 + dw_mipi_dsi_encoder_atomic_check(struct drm_encoder *encoder,
2267 + struct drm_crtc_state *crtc_state,
2268 +@@ -639,9 +641,9 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)
2269 + return;
2270 + }
2271 +
2272 +- dw_mipi_dsi_rockchip_config(dsi, mux);
2273 ++ dw_mipi_dsi_rockchip_set_lcdsel(dsi, mux);
2274 + if (dsi->slave)
2275 +- dw_mipi_dsi_rockchip_config(dsi->slave, mux);
2276 ++ dw_mipi_dsi_rockchip_set_lcdsel(dsi->slave, mux);
2277 +
2278 + clk_disable_unprepare(dsi->grf_clk);
2279 + }
2280 +@@ -800,6 +802,24 @@ static int dw_mipi_dsi_rockchip_bind(struct device *dev,
2281 + return ret;
2282 + }
2283 +
2284 ++ /*
2285 ++ * With the GRF clock running, write lane and dual-mode configurations
2286 ++ * that won't change immediately. If we waited until enable() to do
2287 ++ * this, things like panel preparation would not be able to send
2288 ++ * commands over DSI.
2289 ++ */
2290 ++ ret = clk_prepare_enable(dsi->grf_clk);
2291 ++ if (ret) {
2292 ++ DRM_DEV_ERROR(dsi->dev, "Failed to enable grf_clk: %d\n", ret);
2293 ++ return ret;
2294 ++ }
2295 ++
2296 ++ dw_mipi_dsi_rockchip_config(dsi);
2297 ++ if (dsi->slave)
2298 ++ dw_mipi_dsi_rockchip_config(dsi->slave);
2299 ++
2300 ++ clk_disable_unprepare(dsi->grf_clk);
2301 ++
2302 + ret = rockchip_dsi_drm_create_encoder(dsi, drm_dev);
2303 + if (ret) {
2304 + DRM_DEV_ERROR(dev, "Failed to create drm encoder\n");
2305 +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
2306 +index 550fff6e41eca..b6740ad773ee7 100644
2307 +--- a/drivers/hid/hid-core.c
2308 ++++ b/drivers/hid/hid-core.c
2309 +@@ -2299,12 +2299,8 @@ static int hid_device_remove(struct device *dev)
2310 + {
2311 + struct hid_device *hdev = to_hid_device(dev);
2312 + struct hid_driver *hdrv;
2313 +- int ret = 0;
2314 +
2315 +- if (down_interruptible(&hdev->driver_input_lock)) {
2316 +- ret = -EINTR;
2317 +- goto end;
2318 +- }
2319 ++ down(&hdev->driver_input_lock);
2320 + hdev->io_started = false;
2321 +
2322 + hdrv = hdev->driver;
2323 +@@ -2319,8 +2315,8 @@ static int hid_device_remove(struct device *dev)
2324 +
2325 + if (!hdev->io_started)
2326 + up(&hdev->driver_input_lock);
2327 +-end:
2328 +- return ret;
2329 ++
2330 ++ return 0;
2331 + }
2332 +
2333 + static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
2334 +diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
2335 +index 195910dd2154e..e3835407e8d23 100644
2336 +--- a/drivers/hid/wacom_wac.h
2337 ++++ b/drivers/hid/wacom_wac.h
2338 +@@ -122,7 +122,7 @@
2339 + #define WACOM_HID_WD_TOUCHONOFF (WACOM_HID_UP_WACOMDIGITIZER | 0x0454)
2340 + #define WACOM_HID_WD_BATTERY_LEVEL (WACOM_HID_UP_WACOMDIGITIZER | 0x043b)
2341 + #define WACOM_HID_WD_EXPRESSKEY00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0910)
2342 +-#define WACOM_HID_WD_EXPRESSKEYCAP00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0950)
2343 ++#define WACOM_HID_WD_EXPRESSKEYCAP00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0940)
2344 + #define WACOM_HID_WD_MODE_CHANGE (WACOM_HID_UP_WACOMDIGITIZER | 0x0980)
2345 + #define WACOM_HID_WD_MUTE_DEVICE (WACOM_HID_UP_WACOMDIGITIZER | 0x0981)
2346 + #define WACOM_HID_WD_CONTROLPANEL (WACOM_HID_UP_WACOMDIGITIZER | 0x0982)
2347 +diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
2348 +index e32681ee7b9f6..1671f6f9ea80c 100644
2349 +--- a/drivers/hv/hv_util.c
2350 ++++ b/drivers/hv/hv_util.c
2351 +@@ -537,8 +537,8 @@ static int hv_timesync_init(struct hv_util_service *srv)
2352 + */
2353 + hv_ptp_clock = ptp_clock_register(&ptp_hyperv_info, NULL);
2354 + if (IS_ERR_OR_NULL(hv_ptp_clock)) {
2355 +- pr_err("cannot register PTP clock: %ld\n",
2356 +- PTR_ERR(hv_ptp_clock));
2357 ++ pr_err("cannot register PTP clock: %d\n",
2358 ++ PTR_ERR_OR_ZERO(hv_ptp_clock));
2359 + hv_ptp_clock = NULL;
2360 + }
2361 +
2362 +diff --git a/drivers/hwmon/max31722.c b/drivers/hwmon/max31722.c
2363 +index 062eceb7be0db..613338cbcb170 100644
2364 +--- a/drivers/hwmon/max31722.c
2365 ++++ b/drivers/hwmon/max31722.c
2366 +@@ -6,7 +6,6 @@
2367 + * Copyright (c) 2016, Intel Corporation.
2368 + */
2369 +
2370 +-#include <linux/acpi.h>
2371 + #include <linux/hwmon.h>
2372 + #include <linux/hwmon-sysfs.h>
2373 + #include <linux/kernel.h>
2374 +@@ -133,20 +132,12 @@ static const struct spi_device_id max31722_spi_id[] = {
2375 + {"max31723", 0},
2376 + {}
2377 + };
2378 +-
2379 +-static const struct acpi_device_id __maybe_unused max31722_acpi_id[] = {
2380 +- {"MAX31722", 0},
2381 +- {"MAX31723", 0},
2382 +- {}
2383 +-};
2384 +-
2385 + MODULE_DEVICE_TABLE(spi, max31722_spi_id);
2386 +
2387 + static struct spi_driver max31722_driver = {
2388 + .driver = {
2389 + .name = "max31722",
2390 + .pm = &max31722_pm_ops,
2391 +- .acpi_match_table = ACPI_PTR(max31722_acpi_id),
2392 + },
2393 + .probe = max31722_probe,
2394 + .remove = max31722_remove,
2395 +diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c
2396 +index 117fb79ef294c..2baf88ead0aa8 100644
2397 +--- a/drivers/hwmon/max31790.c
2398 ++++ b/drivers/hwmon/max31790.c
2399 +@@ -27,6 +27,7 @@
2400 +
2401 + /* Fan Config register bits */
2402 + #define MAX31790_FAN_CFG_RPM_MODE 0x80
2403 ++#define MAX31790_FAN_CFG_CTRL_MON 0x10
2404 + #define MAX31790_FAN_CFG_TACH_INPUT_EN 0x08
2405 + #define MAX31790_FAN_CFG_TACH_INPUT 0x01
2406 +
2407 +@@ -104,7 +105,7 @@ static struct max31790_data *max31790_update_device(struct device *dev)
2408 + data->tach[NR_CHANNEL + i] = rv;
2409 + } else {
2410 + rv = i2c_smbus_read_word_swapped(client,
2411 +- MAX31790_REG_PWMOUT(i));
2412 ++ MAX31790_REG_PWM_DUTY_CYCLE(i));
2413 + if (rv < 0)
2414 + goto abort;
2415 + data->pwm[i] = rv;
2416 +@@ -170,7 +171,7 @@ static int max31790_read_fan(struct device *dev, u32 attr, int channel,
2417 +
2418 + switch (attr) {
2419 + case hwmon_fan_input:
2420 +- sr = get_tach_period(data->fan_dynamics[channel]);
2421 ++ sr = get_tach_period(data->fan_dynamics[channel % NR_CHANNEL]);
2422 + rpm = RPM_FROM_REG(data->tach[channel], sr);
2423 + *val = rpm;
2424 + return 0;
2425 +@@ -271,12 +272,12 @@ static int max31790_read_pwm(struct device *dev, u32 attr, int channel,
2426 + *val = data->pwm[channel] >> 8;
2427 + return 0;
2428 + case hwmon_pwm_enable:
2429 +- if (fan_config & MAX31790_FAN_CFG_RPM_MODE)
2430 ++ if (fan_config & MAX31790_FAN_CFG_CTRL_MON)
2431 ++ *val = 0;
2432 ++ else if (fan_config & MAX31790_FAN_CFG_RPM_MODE)
2433 + *val = 2;
2434 +- else if (fan_config & MAX31790_FAN_CFG_TACH_INPUT_EN)
2435 +- *val = 1;
2436 + else
2437 +- *val = 0;
2438 ++ *val = 1;
2439 + return 0;
2440 + default:
2441 + return -EOPNOTSUPP;
2442 +@@ -299,31 +300,41 @@ static int max31790_write_pwm(struct device *dev, u32 attr, int channel,
2443 + err = -EINVAL;
2444 + break;
2445 + }
2446 +- data->pwm[channel] = val << 8;
2447 ++ data->valid = false;
2448 + err = i2c_smbus_write_word_swapped(client,
2449 + MAX31790_REG_PWMOUT(channel),
2450 +- data->pwm[channel]);
2451 ++ val << 8);
2452 + break;
2453 + case hwmon_pwm_enable:
2454 + fan_config = data->fan_config[channel];
2455 + if (val == 0) {
2456 +- fan_config &= ~(MAX31790_FAN_CFG_TACH_INPUT_EN |
2457 +- MAX31790_FAN_CFG_RPM_MODE);
2458 ++ fan_config |= MAX31790_FAN_CFG_CTRL_MON;
2459 ++ /*
2460 ++ * Disable RPM mode; otherwise disabling fan speed
2461 ++ * monitoring is not possible.
2462 ++ */
2463 ++ fan_config &= ~MAX31790_FAN_CFG_RPM_MODE;
2464 + } else if (val == 1) {
2465 +- fan_config = (fan_config |
2466 +- MAX31790_FAN_CFG_TACH_INPUT_EN) &
2467 +- ~MAX31790_FAN_CFG_RPM_MODE;
2468 ++ fan_config &= ~(MAX31790_FAN_CFG_CTRL_MON | MAX31790_FAN_CFG_RPM_MODE);
2469 + } else if (val == 2) {
2470 +- fan_config |= MAX31790_FAN_CFG_TACH_INPUT_EN |
2471 +- MAX31790_FAN_CFG_RPM_MODE;
2472 ++ fan_config &= ~MAX31790_FAN_CFG_CTRL_MON;
2473 ++ /*
2474 ++ * The chip sets MAX31790_FAN_CFG_TACH_INPUT_EN on its
2475 ++ * own if MAX31790_FAN_CFG_RPM_MODE is set.
2476 ++ * Do it here as well to reflect the actual register
2477 ++ * value in the cache.
2478 ++ */
2479 ++ fan_config |= (MAX31790_FAN_CFG_RPM_MODE | MAX31790_FAN_CFG_TACH_INPUT_EN);
2480 + } else {
2481 + err = -EINVAL;
2482 + break;
2483 + }
2484 +- data->fan_config[channel] = fan_config;
2485 +- err = i2c_smbus_write_byte_data(client,
2486 +- MAX31790_REG_FAN_CONFIG(channel),
2487 +- fan_config);
2488 ++ if (fan_config != data->fan_config[channel]) {
2489 ++ err = i2c_smbus_write_byte_data(client, MAX31790_REG_FAN_CONFIG(channel),
2490 ++ fan_config);
2491 ++ if (!err)
2492 ++ data->fan_config[channel] = fan_config;
2493 ++ }
2494 + break;
2495 + default:
2496 + err = -EOPNOTSUPP;
2497 +diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
2498 +index 1574e4604a4fa..aa301c6063467 100644
2499 +--- a/drivers/iio/accel/bma180.c
2500 ++++ b/drivers/iio/accel/bma180.c
2501 +@@ -119,7 +119,11 @@ struct bma180_data {
2502 + int scale;
2503 + int bw;
2504 + bool pmode;
2505 +- u8 buff[16]; /* 3x 16-bit + 8-bit + padding + timestamp */
2506 ++ /* Ensure timestamp is naturally aligned */
2507 ++ struct {
2508 ++ s16 chan[4];
2509 ++ s64 timestamp __aligned(8);
2510 ++ } scan;
2511 + };
2512 +
2513 + enum bma180_chan {
2514 +@@ -675,12 +679,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
2515 + mutex_unlock(&data->mutex);
2516 + goto err;
2517 + }
2518 +- ((s16 *)data->buff)[i++] = ret;
2519 ++ data->scan.chan[i++] = ret;
2520 + }
2521 +
2522 + mutex_unlock(&data->mutex);
2523 +
2524 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buff, time_ns);
2525 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, time_ns);
2526 + err:
2527 + iio_trigger_notify_done(indio_dev->trig);
2528 +
2529 +diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
2530 +index cae905039cb62..71ee42b0266de 100644
2531 +--- a/drivers/iio/accel/bma220_spi.c
2532 ++++ b/drivers/iio/accel/bma220_spi.c
2533 +@@ -73,7 +73,11 @@ static const int bma220_scale_table[][4] = {
2534 + struct bma220_data {
2535 + struct spi_device *spi_device;
2536 + struct mutex lock;
2537 +- s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 8x8 timestamp */
2538 ++ struct {
2539 ++ s8 chans[3];
2540 ++ /* Ensure timestamp is naturally aligned. */
2541 ++ s64 timestamp __aligned(8);
2542 ++ } scan;
2543 + u8 tx_buf[2] ____cacheline_aligned;
2544 + };
2545 +
2546 +@@ -104,12 +108,12 @@ static irqreturn_t bma220_trigger_handler(int irq, void *p)
2547 +
2548 + mutex_lock(&data->lock);
2549 + data->tx_buf[0] = BMA220_REG_ACCEL_X | BMA220_READ_MASK;
2550 +- ret = spi_write_then_read(spi, data->tx_buf, 1, data->buffer,
2551 ++ ret = spi_write_then_read(spi, data->tx_buf, 1, &data->scan.chans,
2552 + ARRAY_SIZE(bma220_channels) - 1);
2553 + if (ret < 0)
2554 + goto err;
2555 +
2556 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
2557 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
2558 + pf->timestamp);
2559 + err:
2560 + mutex_unlock(&data->lock);
2561 +diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
2562 +index 0d9e2def2b257..f908476fa095d 100644
2563 +--- a/drivers/iio/accel/hid-sensor-accel-3d.c
2564 ++++ b/drivers/iio/accel/hid-sensor-accel-3d.c
2565 +@@ -29,8 +29,11 @@ struct accel_3d_state {
2566 + struct hid_sensor_hub_callbacks callbacks;
2567 + struct hid_sensor_common common_attributes;
2568 + struct hid_sensor_hub_attribute_info accel[ACCEL_3D_CHANNEL_MAX];
2569 +- /* Reserve for 3 channels + padding + timestamp */
2570 +- u32 accel_val[ACCEL_3D_CHANNEL_MAX + 3];
2571 ++ /* Ensure timestamp is naturally aligned */
2572 ++ struct {
2573 ++ u32 accel_val[3];
2574 ++ s64 timestamp __aligned(8);
2575 ++ } scan;
2576 + int scale_pre_decml;
2577 + int scale_post_decml;
2578 + int scale_precision;
2579 +@@ -241,8 +244,8 @@ static int accel_3d_proc_event(struct hid_sensor_hub_device *hsdev,
2580 + accel_state->timestamp = iio_get_time_ns(indio_dev);
2581 +
2582 + hid_sensor_push_data(indio_dev,
2583 +- accel_state->accel_val,
2584 +- sizeof(accel_state->accel_val),
2585 ++ &accel_state->scan,
2586 ++ sizeof(accel_state->scan),
2587 + accel_state->timestamp);
2588 +
2589 + accel_state->timestamp = 0;
2590 +@@ -267,7 +270,7 @@ static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
2591 + case HID_USAGE_SENSOR_ACCEL_Y_AXIS:
2592 + case HID_USAGE_SENSOR_ACCEL_Z_AXIS:
2593 + offset = usage_id - HID_USAGE_SENSOR_ACCEL_X_AXIS;
2594 +- accel_state->accel_val[CHANNEL_SCAN_INDEX_X + offset] =
2595 ++ accel_state->scan.accel_val[CHANNEL_SCAN_INDEX_X + offset] =
2596 + *(u32 *)raw_data;
2597 + ret = 0;
2598 + break;
2599 +diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
2600 +index da9452e811056..57db60bf2d4ca 100644
2601 +--- a/drivers/iio/accel/kxcjk-1013.c
2602 ++++ b/drivers/iio/accel/kxcjk-1013.c
2603 +@@ -132,12 +132,23 @@ enum kx_acpi_type {
2604 + ACPI_KIOX010A,
2605 + };
2606 +
2607 ++enum kxcjk1013_axis {
2608 ++ AXIS_X,
2609 ++ AXIS_Y,
2610 ++ AXIS_Z,
2611 ++ AXIS_MAX
2612 ++};
2613 ++
2614 + struct kxcjk1013_data {
2615 + struct i2c_client *client;
2616 + struct iio_trigger *dready_trig;
2617 + struct iio_trigger *motion_trig;
2618 + struct mutex mutex;
2619 +- s16 buffer[8];
2620 ++ /* Ensure timestamp naturally aligned */
2621 ++ struct {
2622 ++ s16 chans[AXIS_MAX];
2623 ++ s64 timestamp __aligned(8);
2624 ++ } scan;
2625 + u8 odr_bits;
2626 + u8 range;
2627 + int wake_thres;
2628 +@@ -151,13 +162,6 @@ struct kxcjk1013_data {
2629 + enum kx_acpi_type acpi_type;
2630 + };
2631 +
2632 +-enum kxcjk1013_axis {
2633 +- AXIS_X,
2634 +- AXIS_Y,
2635 +- AXIS_Z,
2636 +- AXIS_MAX,
2637 +-};
2638 +-
2639 + enum kxcjk1013_mode {
2640 + STANDBY,
2641 + OPERATION,
2642 +@@ -1078,12 +1082,12 @@ static irqreturn_t kxcjk1013_trigger_handler(int irq, void *p)
2643 + ret = i2c_smbus_read_i2c_block_data_or_emulated(data->client,
2644 + KXCJK1013_REG_XOUT_L,
2645 + AXIS_MAX * 2,
2646 +- (u8 *)data->buffer);
2647 ++ (u8 *)data->scan.chans);
2648 + mutex_unlock(&data->mutex);
2649 + if (ret < 0)
2650 + goto err;
2651 +
2652 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
2653 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
2654 + data->timestamp);
2655 + err:
2656 + iio_trigger_notify_done(indio_dev->trig);
2657 +diff --git a/drivers/iio/accel/mxc4005.c b/drivers/iio/accel/mxc4005.c
2658 +index 3d5bea651923e..d81b02642a0b3 100644
2659 +--- a/drivers/iio/accel/mxc4005.c
2660 ++++ b/drivers/iio/accel/mxc4005.c
2661 +@@ -56,7 +56,11 @@ struct mxc4005_data {
2662 + struct mutex mutex;
2663 + struct regmap *regmap;
2664 + struct iio_trigger *dready_trig;
2665 +- __be16 buffer[8];
2666 ++ /* Ensure timestamp is naturally aligned */
2667 ++ struct {
2668 ++ __be16 chans[3];
2669 ++ s64 timestamp __aligned(8);
2670 ++ } scan;
2671 + bool trigger_enabled;
2672 + };
2673 +
2674 +@@ -135,7 +139,7 @@ static int mxc4005_read_xyz(struct mxc4005_data *data)
2675 + int ret;
2676 +
2677 + ret = regmap_bulk_read(data->regmap, MXC4005_REG_XOUT_UPPER,
2678 +- (u8 *) data->buffer, sizeof(data->buffer));
2679 ++ data->scan.chans, sizeof(data->scan.chans));
2680 + if (ret < 0) {
2681 + dev_err(data->dev, "failed to read axes\n");
2682 + return ret;
2683 +@@ -150,7 +154,7 @@ static int mxc4005_read_axis(struct mxc4005_data *data,
2684 + __be16 reg;
2685 + int ret;
2686 +
2687 +- ret = regmap_bulk_read(data->regmap, addr, (u8 *) &reg, sizeof(reg));
2688 ++ ret = regmap_bulk_read(data->regmap, addr, &reg, sizeof(reg));
2689 + if (ret < 0) {
2690 + dev_err(data->dev, "failed to read reg %02x\n", addr);
2691 + return ret;
2692 +@@ -301,7 +305,7 @@ static irqreturn_t mxc4005_trigger_handler(int irq, void *private)
2693 + if (ret < 0)
2694 + goto err;
2695 +
2696 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
2697 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
2698 + pf->timestamp);
2699 +
2700 + err:
2701 +diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
2702 +index 58c160ccdee71..be66b85239778 100644
2703 +--- a/drivers/iio/accel/stk8312.c
2704 ++++ b/drivers/iio/accel/stk8312.c
2705 +@@ -103,7 +103,11 @@ struct stk8312_data {
2706 + u8 mode;
2707 + struct iio_trigger *dready_trig;
2708 + bool dready_trigger_on;
2709 +- s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 64-bit timestamp */
2710 ++ /* Ensure timestamp is naturally aligned */
2711 ++ struct {
2712 ++ s8 chans[3];
2713 ++ s64 timestamp __aligned(8);
2714 ++ } scan;
2715 + };
2716 +
2717 + static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL);
2718 +@@ -438,7 +442,7 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p)
2719 + ret = i2c_smbus_read_i2c_block_data(data->client,
2720 + STK8312_REG_XOUT,
2721 + STK8312_ALL_CHANNEL_SIZE,
2722 +- data->buffer);
2723 ++ data->scan.chans);
2724 + if (ret < STK8312_ALL_CHANNEL_SIZE) {
2725 + dev_err(&data->client->dev, "register read failed\n");
2726 + mutex_unlock(&data->lock);
2727 +@@ -452,12 +456,12 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p)
2728 + mutex_unlock(&data->lock);
2729 + goto err;
2730 + }
2731 +- data->buffer[i++] = ret;
2732 ++ data->scan.chans[i++] = ret;
2733 + }
2734 + }
2735 + mutex_unlock(&data->lock);
2736 +
2737 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
2738 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
2739 + pf->timestamp);
2740 + err:
2741 + iio_trigger_notify_done(indio_dev->trig);
2742 +diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
2743 +index c70ddec29eb49..edba3c13a979f 100644
2744 +--- a/drivers/iio/accel/stk8ba50.c
2745 ++++ b/drivers/iio/accel/stk8ba50.c
2746 +@@ -91,12 +91,11 @@ struct stk8ba50_data {
2747 + u8 sample_rate_idx;
2748 + struct iio_trigger *dready_trig;
2749 + bool dready_trigger_on;
2750 +- /*
2751 +- * 3 x 16-bit channels (10-bit data, 6-bit padding) +
2752 +- * 1 x 16 padding +
2753 +- * 4 x 16 64-bit timestamp
2754 +- */
2755 +- s16 buffer[8];
2756 ++ /* Ensure timestamp is naturally aligned */
2757 ++ struct {
2758 ++ s16 chans[3];
2759 ++ s64 timetamp __aligned(8);
2760 ++ } scan;
2761 + };
2762 +
2763 + #define STK8BA50_ACCEL_CHANNEL(index, reg, axis) { \
2764 +@@ -324,7 +323,7 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p)
2765 + ret = i2c_smbus_read_i2c_block_data(data->client,
2766 + STK8BA50_REG_XOUT,
2767 + STK8BA50_ALL_CHANNEL_SIZE,
2768 +- (u8 *)data->buffer);
2769 ++ (u8 *)data->scan.chans);
2770 + if (ret < STK8BA50_ALL_CHANNEL_SIZE) {
2771 + dev_err(&data->client->dev, "register read failed\n");
2772 + goto err;
2773 +@@ -337,10 +336,10 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p)
2774 + if (ret < 0)
2775 + goto err;
2776 +
2777 +- data->buffer[i++] = ret;
2778 ++ data->scan.chans[i++] = ret;
2779 + }
2780 + }
2781 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
2782 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
2783 + pf->timestamp);
2784 + err:
2785 + mutex_unlock(&data->lock);
2786 +diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
2787 +index 2c01963a6a5cf..def4abeb47cae 100644
2788 +--- a/drivers/iio/adc/at91-sama5d2_adc.c
2789 ++++ b/drivers/iio/adc/at91-sama5d2_adc.c
2790 +@@ -399,7 +399,9 @@ struct at91_adc_state {
2791 + wait_queue_head_t wq_data_available;
2792 + struct at91_adc_dma dma_st;
2793 + struct at91_adc_touch touch_st;
2794 +- u16 buffer[AT91_BUFFER_MAX_HWORDS];
2795 ++ struct iio_dev *indio_dev;
2796 ++ /* Ensure naturally aligned timestamp */
2797 ++ u16 buffer[AT91_BUFFER_MAX_HWORDS] __aligned(8);
2798 + /*
2799 + * lock to prevent concurrent 'single conversion' requests through
2800 + * sysfs.
2801 +@@ -624,13 +626,13 @@ static u16 at91_adc_touch_pos(struct at91_adc_state *st, int reg)
2802 + /* first half of register is the x or y, second half is the scale */
2803 + val = at91_adc_readl(st, reg);
2804 + if (!val)
2805 +- dev_dbg(&iio_priv_to_dev(st)->dev, "pos is 0\n");
2806 ++ dev_dbg(&st->indio_dev->dev, "pos is 0\n");
2807 +
2808 + pos = val & AT91_SAMA5D2_XYZ_MASK;
2809 + result = (pos << AT91_SAMA5D2_MAX_POS_BITS) - pos;
2810 + scale = (val >> 16) & AT91_SAMA5D2_XYZ_MASK;
2811 + if (scale == 0) {
2812 +- dev_err(&iio_priv_to_dev(st)->dev, "scale is 0\n");
2813 ++ dev_err(&st->indio_dev->dev, "scale is 0\n");
2814 + return 0;
2815 + }
2816 + result /= scale;
2817 +@@ -1154,9 +1156,9 @@ static unsigned at91_adc_startup_time(unsigned startup_time_min,
2818 + return i;
2819 + }
2820 +
2821 +-static void at91_adc_setup_samp_freq(struct at91_adc_state *st, unsigned freq)
2822 ++static void at91_adc_setup_samp_freq(struct iio_dev *indio_dev, unsigned freq)
2823 + {
2824 +- struct iio_dev *indio_dev = iio_priv_to_dev(st);
2825 ++ struct at91_adc_state *st = iio_priv(indio_dev);
2826 + unsigned f_per, prescal, startup, mr;
2827 +
2828 + f_per = clk_get_rate(st->per_clk);
2829 +@@ -1225,9 +1227,9 @@ static void at91_adc_pen_detect_interrupt(struct at91_adc_state *st)
2830 + st->touch_st.touching = true;
2831 + }
2832 +
2833 +-static void at91_adc_no_pen_detect_interrupt(struct at91_adc_state *st)
2834 ++static void at91_adc_no_pen_detect_interrupt(struct iio_dev *indio_dev)
2835 + {
2836 +- struct iio_dev *indio_dev = iio_priv_to_dev(st);
2837 ++ struct at91_adc_state *st = iio_priv(indio_dev);
2838 +
2839 + at91_adc_writel(st, AT91_SAMA5D2_TRGR,
2840 + AT91_SAMA5D2_TRGR_TRGMOD_NO_TRIGGER);
2841 +@@ -1247,7 +1249,7 @@ static void at91_adc_workq_handler(struct work_struct *workq)
2842 + struct at91_adc_touch, workq);
2843 + struct at91_adc_state *st = container_of(touch_st,
2844 + struct at91_adc_state, touch_st);
2845 +- struct iio_dev *indio_dev = iio_priv_to_dev(st);
2846 ++ struct iio_dev *indio_dev = st->indio_dev;
2847 +
2848 + iio_push_to_buffers(indio_dev, st->buffer);
2849 + }
2850 +@@ -1268,7 +1270,7 @@ static irqreturn_t at91_adc_interrupt(int irq, void *private)
2851 + at91_adc_pen_detect_interrupt(st);
2852 + } else if ((status & AT91_SAMA5D2_IER_NOPEN)) {
2853 + /* nopen detected IRQ */
2854 +- at91_adc_no_pen_detect_interrupt(st);
2855 ++ at91_adc_no_pen_detect_interrupt(indio);
2856 + } else if ((status & AT91_SAMA5D2_ISR_PENS) &&
2857 + ((status & rdy_mask) == rdy_mask)) {
2858 + /* periodic trigger IRQ - during pen sense */
2859 +@@ -1435,7 +1437,7 @@ static int at91_adc_write_raw(struct iio_dev *indio_dev,
2860 + val > st->soc_info.max_sample_rate)
2861 + return -EINVAL;
2862 +
2863 +- at91_adc_setup_samp_freq(st, val);
2864 ++ at91_adc_setup_samp_freq(indio_dev, val);
2865 + return 0;
2866 + default:
2867 + return -EINVAL;
2868 +@@ -1573,8 +1575,10 @@ static int at91_adc_update_scan_mode(struct iio_dev *indio_dev,
2869 + return 0;
2870 + }
2871 +
2872 +-static void at91_adc_hw_init(struct at91_adc_state *st)
2873 ++static void at91_adc_hw_init(struct iio_dev *indio_dev)
2874 + {
2875 ++ struct at91_adc_state *st = iio_priv(indio_dev);
2876 ++
2877 + at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_SWRST);
2878 + at91_adc_writel(st, AT91_SAMA5D2_IDR, 0xffffffff);
2879 + /*
2880 +@@ -1584,7 +1588,7 @@ static void at91_adc_hw_init(struct at91_adc_state *st)
2881 + at91_adc_writel(st, AT91_SAMA5D2_MR,
2882 + AT91_SAMA5D2_MR_TRANSFER(2) | AT91_SAMA5D2_MR_ANACH);
2883 +
2884 +- at91_adc_setup_samp_freq(st, st->soc_info.min_sample_rate);
2885 ++ at91_adc_setup_samp_freq(indio_dev, st->soc_info.min_sample_rate);
2886 +
2887 + /* configure extended mode register */
2888 + at91_adc_config_emr(st);
2889 +@@ -1667,6 +1671,7 @@ static int at91_adc_probe(struct platform_device *pdev)
2890 + indio_dev->num_channels = ARRAY_SIZE(at91_adc_channels);
2891 +
2892 + st = iio_priv(indio_dev);
2893 ++ st->indio_dev = indio_dev;
2894 +
2895 + bitmap_set(&st->touch_st.channels_bitmask,
2896 + AT91_SAMA5D2_TOUCH_X_CHAN_IDX, 1);
2897 +@@ -1778,7 +1783,7 @@ static int at91_adc_probe(struct platform_device *pdev)
2898 + goto vref_disable;
2899 + }
2900 +
2901 +- at91_adc_hw_init(st);
2902 ++ at91_adc_hw_init(indio_dev);
2903 +
2904 + ret = clk_prepare_enable(st->per_clk);
2905 + if (ret)
2906 +@@ -1894,7 +1899,7 @@ static __maybe_unused int at91_adc_resume(struct device *dev)
2907 + if (ret)
2908 + goto vref_disable_resume;
2909 +
2910 +- at91_adc_hw_init(st);
2911 ++ at91_adc_hw_init(indio_dev);
2912 +
2913 + /* reconfiguring trigger hardware state */
2914 + if (!iio_buffer_enabled(indio_dev))
2915 +diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c
2916 +index 62e6c8badd22a..a3265166fd835 100644
2917 +--- a/drivers/iio/adc/hx711.c
2918 ++++ b/drivers/iio/adc/hx711.c
2919 +@@ -85,9 +85,9 @@ struct hx711_data {
2920 + struct mutex lock;
2921 + /*
2922 + * triggered buffer
2923 +- * 2x32-bit channel + 64-bit timestamp
2924 ++ * 2x32-bit channel + 64-bit naturally aligned timestamp
2925 + */
2926 +- u32 buffer[4];
2927 ++ u32 buffer[4] __aligned(8);
2928 + /*
2929 + * delay after a rising edge on SCK until the data is ready DOUT
2930 + * this is dependent on the hx711 where the datasheet tells a
2931 +diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c
2932 +index 9d2f74c2489a8..01f85bbe6a2e5 100644
2933 +--- a/drivers/iio/adc/mxs-lradc-adc.c
2934 ++++ b/drivers/iio/adc/mxs-lradc-adc.c
2935 +@@ -115,7 +115,8 @@ struct mxs_lradc_adc {
2936 + struct device *dev;
2937 +
2938 + void __iomem *base;
2939 +- u32 buffer[10];
2940 ++ /* Maximum of 8 channels + 8 byte ts */
2941 ++ u32 buffer[10] __aligned(8);
2942 + struct iio_trigger *trig;
2943 + struct completion completion;
2944 + spinlock_t lock;
2945 +diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
2946 +index 871690a476610..7929891f568eb 100644
2947 +--- a/drivers/iio/adc/ti-ads1015.c
2948 ++++ b/drivers/iio/adc/ti-ads1015.c
2949 +@@ -388,10 +388,14 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p)
2950 + struct iio_poll_func *pf = p;
2951 + struct iio_dev *indio_dev = pf->indio_dev;
2952 + struct ads1015_data *data = iio_priv(indio_dev);
2953 +- s16 buf[8]; /* 1x s16 ADC val + 3x s16 padding + 4x s16 timestamp */
2954 ++ /* Ensure natural alignment of timestamp */
2955 ++ struct {
2956 ++ s16 chan;
2957 ++ s64 timestamp __aligned(8);
2958 ++ } scan;
2959 + int chan, ret, res;
2960 +
2961 +- memset(buf, 0, sizeof(buf));
2962 ++ memset(&scan, 0, sizeof(scan));
2963 +
2964 + mutex_lock(&data->lock);
2965 + chan = find_first_bit(indio_dev->active_scan_mask,
2966 +@@ -402,10 +406,10 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p)
2967 + goto err;
2968 + }
2969 +
2970 +- buf[0] = res;
2971 ++ scan.chan = res;
2972 + mutex_unlock(&data->lock);
2973 +
2974 +- iio_push_to_buffers_with_timestamp(indio_dev, buf,
2975 ++ iio_push_to_buffers_with_timestamp(indio_dev, &scan,
2976 + iio_get_time_ns(indio_dev));
2977 +
2978 + err:
2979 +diff --git a/drivers/iio/adc/ti-ads8688.c b/drivers/iio/adc/ti-ads8688.c
2980 +index 14fe7c320b522..55a2d619d6dda 100644
2981 +--- a/drivers/iio/adc/ti-ads8688.c
2982 ++++ b/drivers/iio/adc/ti-ads8688.c
2983 +@@ -383,7 +383,8 @@ static irqreturn_t ads8688_trigger_handler(int irq, void *p)
2984 + {
2985 + struct iio_poll_func *pf = p;
2986 + struct iio_dev *indio_dev = pf->indio_dev;
2987 +- u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)];
2988 ++ /* Ensure naturally aligned timestamp */
2989 ++ u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)] __aligned(8);
2990 + int i, j = 0;
2991 +
2992 + for (i = 0; i < indio_dev->masklength; i++) {
2993 +diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
2994 +index 98b30475bbc6a..0d29fe974d70e 100644
2995 +--- a/drivers/iio/adc/vf610_adc.c
2996 ++++ b/drivers/iio/adc/vf610_adc.c
2997 +@@ -167,7 +167,11 @@ struct vf610_adc {
2998 + u32 sample_freq_avail[5];
2999 +
3000 + struct completion completion;
3001 +- u16 buffer[8];
3002 ++ /* Ensure the timestamp is naturally aligned */
3003 ++ struct {
3004 ++ u16 chan;
3005 ++ s64 timestamp __aligned(8);
3006 ++ } scan;
3007 + };
3008 +
3009 + static const u32 vf610_hw_avgs[] = { 1, 4, 8, 16, 32 };
3010 +@@ -579,9 +583,9 @@ static irqreturn_t vf610_adc_isr(int irq, void *dev_id)
3011 + if (coco & VF610_ADC_HS_COCO0) {
3012 + info->value = vf610_adc_read_data(info);
3013 + if (iio_buffer_enabled(indio_dev)) {
3014 +- info->buffer[0] = info->value;
3015 ++ info->scan.chan = info->value;
3016 + iio_push_to_buffers_with_timestamp(indio_dev,
3017 +- info->buffer,
3018 ++ &info->scan,
3019 + iio_get_time_ns(indio_dev));
3020 + iio_trigger_notify_done(indio_dev->trig);
3021 + } else
3022 +diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
3023 +index 428ddfc13acb9..276bed47e8d66 100644
3024 +--- a/drivers/iio/gyro/bmg160_core.c
3025 ++++ b/drivers/iio/gyro/bmg160_core.c
3026 +@@ -96,7 +96,11 @@ struct bmg160_data {
3027 + struct iio_trigger *motion_trig;
3028 + struct iio_mount_matrix orientation;
3029 + struct mutex mutex;
3030 +- s16 buffer[8];
3031 ++ /* Ensure naturally aligned timestamp */
3032 ++ struct {
3033 ++ s16 chans[3];
3034 ++ s64 timestamp __aligned(8);
3035 ++ } scan;
3036 + u32 dps_range;
3037 + int ev_enable_state;
3038 + int slope_thres;
3039 +@@ -880,12 +884,12 @@ static irqreturn_t bmg160_trigger_handler(int irq, void *p)
3040 +
3041 + mutex_lock(&data->mutex);
3042 + ret = regmap_bulk_read(data->regmap, BMG160_REG_XOUT_L,
3043 +- data->buffer, AXIS_MAX * 2);
3044 ++ data->scan.chans, AXIS_MAX * 2);
3045 + mutex_unlock(&data->mutex);
3046 + if (ret < 0)
3047 + goto err;
3048 +
3049 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
3050 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
3051 + pf->timestamp);
3052 + err:
3053 + iio_trigger_notify_done(indio_dev->trig);
3054 +diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c
3055 +index 3bac98e731d9c..894922a315fe6 100644
3056 +--- a/drivers/iio/humidity/am2315.c
3057 ++++ b/drivers/iio/humidity/am2315.c
3058 +@@ -33,7 +33,11 @@
3059 + struct am2315_data {
3060 + struct i2c_client *client;
3061 + struct mutex lock;
3062 +- s16 buffer[8]; /* 2x16-bit channels + 2x16 padding + 4x16 timestamp */
3063 ++ /* Ensure timestamp is naturally aligned */
3064 ++ struct {
3065 ++ s16 chans[2];
3066 ++ s64 timestamp __aligned(8);
3067 ++ } scan;
3068 + };
3069 +
3070 + struct am2315_sensor_data {
3071 +@@ -167,20 +171,20 @@ static irqreturn_t am2315_trigger_handler(int irq, void *p)
3072 +
3073 + mutex_lock(&data->lock);
3074 + if (*(indio_dev->active_scan_mask) == AM2315_ALL_CHANNEL_MASK) {
3075 +- data->buffer[0] = sensor_data.hum_data;
3076 +- data->buffer[1] = sensor_data.temp_data;
3077 ++ data->scan.chans[0] = sensor_data.hum_data;
3078 ++ data->scan.chans[1] = sensor_data.temp_data;
3079 + } else {
3080 + i = 0;
3081 + for_each_set_bit(bit, indio_dev->active_scan_mask,
3082 + indio_dev->masklength) {
3083 +- data->buffer[i] = (bit ? sensor_data.temp_data :
3084 +- sensor_data.hum_data);
3085 ++ data->scan.chans[i] = (bit ? sensor_data.temp_data :
3086 ++ sensor_data.hum_data);
3087 + i++;
3088 + }
3089 + }
3090 + mutex_unlock(&data->lock);
3091 +
3092 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
3093 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
3094 + pf->timestamp);
3095 + err:
3096 + iio_trigger_notify_done(indio_dev->trig);
3097 +diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c
3098 +index 59e33302042c5..afa9d26362da2 100644
3099 +--- a/drivers/iio/imu/adis16400.c
3100 ++++ b/drivers/iio/imu/adis16400.c
3101 +@@ -651,9 +651,6 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p)
3102 + void *buffer;
3103 + int ret;
3104 +
3105 +- if (!adis->buffer)
3106 +- return -ENOMEM;
3107 +-
3108 + if (!(st->variant->flags & ADIS16400_NO_BURST) &&
3109 + st->adis.spi->max_speed_hz > ADIS16400_SPI_BURST) {
3110 + st->adis.spi->max_speed_hz = ADIS16400_SPI_BURST;
3111 +diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c
3112 +index 4998a89d083d5..8f8c1a87567b2 100644
3113 +--- a/drivers/iio/imu/adis_buffer.c
3114 ++++ b/drivers/iio/imu/adis_buffer.c
3115 +@@ -125,9 +125,6 @@ static irqreturn_t adis_trigger_handler(int irq, void *p)
3116 + struct adis *adis = iio_device_get_drvdata(indio_dev);
3117 + int ret;
3118 +
3119 +- if (!adis->buffer)
3120 +- return -ENOMEM;
3121 +-
3122 + if (adis->data->has_paging) {
3123 + mutex_lock(&adis->txrx_lock);
3124 + if (adis->current_page != 0) {
3125 +diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
3126 +index e37894f0ae0b6..15906925e588b 100644
3127 +--- a/drivers/iio/light/isl29125.c
3128 ++++ b/drivers/iio/light/isl29125.c
3129 +@@ -51,7 +51,11 @@
3130 + struct isl29125_data {
3131 + struct i2c_client *client;
3132 + u8 conf1;
3133 +- u16 buffer[8]; /* 3x 16-bit, padding, 8 bytes timestamp */
3134 ++ /* Ensure timestamp is naturally aligned */
3135 ++ struct {
3136 ++ u16 chans[3];
3137 ++ s64 timestamp __aligned(8);
3138 ++ } scan;
3139 + };
3140 +
3141 + #define ISL29125_CHANNEL(_color, _si) { \
3142 +@@ -184,10 +188,10 @@ static irqreturn_t isl29125_trigger_handler(int irq, void *p)
3143 + if (ret < 0)
3144 + goto done;
3145 +
3146 +- data->buffer[j++] = ret;
3147 ++ data->scan.chans[j++] = ret;
3148 + }
3149 +
3150 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
3151 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
3152 + iio_get_time_ns(indio_dev));
3153 +
3154 + done:
3155 +diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
3156 +index ceddb6a3b61bb..8bc01e8a424b0 100644
3157 +--- a/drivers/iio/light/ltr501.c
3158 ++++ b/drivers/iio/light/ltr501.c
3159 +@@ -32,9 +32,12 @@
3160 + #define LTR501_PART_ID 0x86
3161 + #define LTR501_MANUFAC_ID 0x87
3162 + #define LTR501_ALS_DATA1 0x88 /* 16-bit, little endian */
3163 ++#define LTR501_ALS_DATA1_UPPER 0x89 /* upper 8 bits of LTR501_ALS_DATA1 */
3164 + #define LTR501_ALS_DATA0 0x8a /* 16-bit, little endian */
3165 ++#define LTR501_ALS_DATA0_UPPER 0x8b /* upper 8 bits of LTR501_ALS_DATA0 */
3166 + #define LTR501_ALS_PS_STATUS 0x8c
3167 + #define LTR501_PS_DATA 0x8d /* 16-bit, little endian */
3168 ++#define LTR501_PS_DATA_UPPER 0x8e /* upper 8 bits of LTR501_PS_DATA */
3169 + #define LTR501_INTR 0x8f /* output mode, polarity, mode */
3170 + #define LTR501_PS_THRESH_UP 0x90 /* 11 bit, ps upper threshold */
3171 + #define LTR501_PS_THRESH_LOW 0x92 /* 11 bit, ps lower threshold */
3172 +@@ -405,18 +408,19 @@ static int ltr501_read_als(struct ltr501_data *data, __le16 buf[2])
3173 +
3174 + static int ltr501_read_ps(struct ltr501_data *data)
3175 + {
3176 +- int ret, status;
3177 ++ __le16 status;
3178 ++ int ret;
3179 +
3180 + ret = ltr501_drdy(data, LTR501_STATUS_PS_RDY);
3181 + if (ret < 0)
3182 + return ret;
3183 +
3184 + ret = regmap_bulk_read(data->regmap, LTR501_PS_DATA,
3185 +- &status, 2);
3186 ++ &status, sizeof(status));
3187 + if (ret < 0)
3188 + return ret;
3189 +
3190 +- return status;
3191 ++ return le16_to_cpu(status);
3192 + }
3193 +
3194 + static int ltr501_read_intr_prst(struct ltr501_data *data,
3195 +@@ -1204,7 +1208,7 @@ static struct ltr501_chip_info ltr501_chip_info_tbl[] = {
3196 + .als_gain_tbl_size = ARRAY_SIZE(ltr559_als_gain_tbl),
3197 + .ps_gain = ltr559_ps_gain_tbl,
3198 + .ps_gain_tbl_size = ARRAY_SIZE(ltr559_ps_gain_tbl),
3199 +- .als_mode_active = BIT(1),
3200 ++ .als_mode_active = BIT(0),
3201 + .als_gain_mask = BIT(2) | BIT(3) | BIT(4),
3202 + .als_gain_shift = 2,
3203 + .info = &ltr501_info,
3204 +@@ -1353,9 +1357,12 @@ static bool ltr501_is_volatile_reg(struct device *dev, unsigned int reg)
3205 + {
3206 + switch (reg) {
3207 + case LTR501_ALS_DATA1:
3208 ++ case LTR501_ALS_DATA1_UPPER:
3209 + case LTR501_ALS_DATA0:
3210 ++ case LTR501_ALS_DATA0_UPPER:
3211 + case LTR501_ALS_PS_STATUS:
3212 + case LTR501_PS_DATA:
3213 ++ case LTR501_PS_DATA_UPPER:
3214 + return true;
3215 + default:
3216 + return false;
3217 +diff --git a/drivers/iio/light/tcs3414.c b/drivers/iio/light/tcs3414.c
3218 +index 7c0291c5fe76e..85bfe3b63f4fe 100644
3219 +--- a/drivers/iio/light/tcs3414.c
3220 ++++ b/drivers/iio/light/tcs3414.c
3221 +@@ -53,7 +53,11 @@ struct tcs3414_data {
3222 + u8 control;
3223 + u8 gain;
3224 + u8 timing;
3225 +- u16 buffer[8]; /* 4x 16-bit + 8 bytes timestamp */
3226 ++ /* Ensure timestamp is naturally aligned */
3227 ++ struct {
3228 ++ u16 chans[4];
3229 ++ s64 timestamp __aligned(8);
3230 ++ } scan;
3231 + };
3232 +
3233 + #define TCS3414_CHANNEL(_color, _si, _addr) { \
3234 +@@ -209,10 +213,10 @@ static irqreturn_t tcs3414_trigger_handler(int irq, void *p)
3235 + if (ret < 0)
3236 + goto done;
3237 +
3238 +- data->buffer[j++] = ret;
3239 ++ data->scan.chans[j++] = ret;
3240 + }
3241 +
3242 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
3243 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
3244 + iio_get_time_ns(indio_dev));
3245 +
3246 + done:
3247 +diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c
3248 +index 12ad344410103..9ea543c5cf5e6 100644
3249 +--- a/drivers/iio/light/tcs3472.c
3250 ++++ b/drivers/iio/light/tcs3472.c
3251 +@@ -64,7 +64,11 @@ struct tcs3472_data {
3252 + u8 control;
3253 + u8 atime;
3254 + u8 apers;
3255 +- u16 buffer[8]; /* 4 16-bit channels + 64-bit timestamp */
3256 ++ /* Ensure timestamp is naturally aligned */
3257 ++ struct {
3258 ++ u16 chans[4];
3259 ++ s64 timestamp __aligned(8);
3260 ++ } scan;
3261 + };
3262 +
3263 + static const struct iio_event_spec tcs3472_events[] = {
3264 +@@ -386,10 +390,10 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p)
3265 + if (ret < 0)
3266 + goto done;
3267 +
3268 +- data->buffer[j++] = ret;
3269 ++ data->scan.chans[j++] = ret;
3270 + }
3271 +
3272 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
3273 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
3274 + iio_get_time_ns(indio_dev));
3275 +
3276 + done:
3277 +@@ -532,7 +536,8 @@ static int tcs3472_probe(struct i2c_client *client,
3278 + return 0;
3279 +
3280 + free_irq:
3281 +- free_irq(client->irq, indio_dev);
3282 ++ if (client->irq)
3283 ++ free_irq(client->irq, indio_dev);
3284 + buffer_cleanup:
3285 + iio_triggered_buffer_cleanup(indio_dev);
3286 + return ret;
3287 +@@ -560,7 +565,8 @@ static int tcs3472_remove(struct i2c_client *client)
3288 + struct iio_dev *indio_dev = i2c_get_clientdata(client);
3289 +
3290 + iio_device_unregister(indio_dev);
3291 +- free_irq(client->irq, indio_dev);
3292 ++ if (client->irq)
3293 ++ free_irq(client->irq, indio_dev);
3294 + iio_triggered_buffer_cleanup(indio_dev);
3295 + tcs3472_powerdown(iio_priv(indio_dev));
3296 +
3297 +diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c
3298 +index cca4db312bd3f..234623ab38177 100644
3299 +--- a/drivers/iio/light/vcnl4035.c
3300 ++++ b/drivers/iio/light/vcnl4035.c
3301 +@@ -102,7 +102,8 @@ static irqreturn_t vcnl4035_trigger_consumer_handler(int irq, void *p)
3302 + struct iio_poll_func *pf = p;
3303 + struct iio_dev *indio_dev = pf->indio_dev;
3304 + struct vcnl4035_data *data = iio_priv(indio_dev);
3305 +- u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)];
3306 ++ /* Ensure naturally aligned timestamp */
3307 ++ u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)] __aligned(8);
3308 + int ret;
3309 +
3310 + ret = regmap_read(data->regmap, VCNL4035_ALS_DATA, (int *)buffer);
3311 +diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c
3312 +index d4de16750b107..48685d785c1b6 100644
3313 +--- a/drivers/iio/magnetometer/bmc150_magn.c
3314 ++++ b/drivers/iio/magnetometer/bmc150_magn.c
3315 +@@ -136,8 +136,11 @@ struct bmc150_magn_data {
3316 + struct mutex mutex;
3317 + struct regmap *regmap;
3318 + struct iio_mount_matrix orientation;
3319 +- /* 4 x 32 bits for x, y z, 4 bytes align, 64 bits timestamp */
3320 +- s32 buffer[6];
3321 ++ /* Ensure timestamp is naturally aligned */
3322 ++ struct {
3323 ++ s32 chans[3];
3324 ++ s64 timestamp __aligned(8);
3325 ++ } scan;
3326 + struct iio_trigger *dready_trig;
3327 + bool dready_trigger_on;
3328 + int max_odr;
3329 +@@ -673,11 +676,11 @@ static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p)
3330 + int ret;
3331 +
3332 + mutex_lock(&data->mutex);
3333 +- ret = bmc150_magn_read_xyz(data, data->buffer);
3334 ++ ret = bmc150_magn_read_xyz(data, data->scan.chans);
3335 + if (ret < 0)
3336 + goto err;
3337 +
3338 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
3339 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
3340 + pf->timestamp);
3341 +
3342 + err:
3343 +diff --git a/drivers/iio/magnetometer/hmc5843.h b/drivers/iio/magnetometer/hmc5843.h
3344 +index b0dee87a8b20e..b68bb55909e13 100644
3345 +--- a/drivers/iio/magnetometer/hmc5843.h
3346 ++++ b/drivers/iio/magnetometer/hmc5843.h
3347 +@@ -33,7 +33,8 @@ enum hmc5843_ids {
3348 + * @lock: update and read regmap data
3349 + * @regmap: hardware access register maps
3350 + * @variant: describe chip variants
3351 +- * @buffer: 3x 16-bit channels + padding + 64-bit timestamp
3352 ++ * @scan: buffer to pack data for passing to
3353 ++ * iio_push_to_buffers_with_timestamp()
3354 + */
3355 + struct hmc5843_data {
3356 + struct device *dev;
3357 +@@ -41,7 +42,10 @@ struct hmc5843_data {
3358 + struct regmap *regmap;
3359 + const struct hmc5843_chip_info *variant;
3360 + struct iio_mount_matrix orientation;
3361 +- __be16 buffer[8];
3362 ++ struct {
3363 ++ __be16 chans[3];
3364 ++ s64 timestamp __aligned(8);
3365 ++ } scan;
3366 + };
3367 +
3368 + int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
3369 +diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c
3370 +index c44a4292da924..aef78275260f7 100644
3371 +--- a/drivers/iio/magnetometer/hmc5843_core.c
3372 ++++ b/drivers/iio/magnetometer/hmc5843_core.c
3373 +@@ -446,13 +446,13 @@ static irqreturn_t hmc5843_trigger_handler(int irq, void *p)
3374 + }
3375 +
3376 + ret = regmap_bulk_read(data->regmap, HMC5843_DATA_OUT_MSB_REGS,
3377 +- data->buffer, 3 * sizeof(__be16));
3378 ++ data->scan.chans, sizeof(data->scan.chans));
3379 +
3380 + mutex_unlock(&data->lock);
3381 + if (ret < 0)
3382 + goto done;
3383 +
3384 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
3385 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
3386 + iio_get_time_ns(indio_dev));
3387 +
3388 + done:
3389 +diff --git a/drivers/iio/magnetometer/rm3100-core.c b/drivers/iio/magnetometer/rm3100-core.c
3390 +index 7c20918d81086..f31ff225fe616 100644
3391 +--- a/drivers/iio/magnetometer/rm3100-core.c
3392 ++++ b/drivers/iio/magnetometer/rm3100-core.c
3393 +@@ -76,7 +76,8 @@ struct rm3100_data {
3394 + bool use_interrupt;
3395 + int conversion_time;
3396 + int scale;
3397 +- u8 buffer[RM3100_SCAN_BYTES];
3398 ++ /* Ensure naturally aligned timestamp */
3399 ++ u8 buffer[RM3100_SCAN_BYTES] __aligned(8);
3400 + struct iio_trigger *drdy_trig;
3401 +
3402 + /*
3403 +diff --git a/drivers/iio/potentiostat/lmp91000.c b/drivers/iio/potentiostat/lmp91000.c
3404 +index a0e5f530faa9b..d6db07264a7b3 100644
3405 +--- a/drivers/iio/potentiostat/lmp91000.c
3406 ++++ b/drivers/iio/potentiostat/lmp91000.c
3407 +@@ -71,8 +71,8 @@ struct lmp91000_data {
3408 +
3409 + struct completion completion;
3410 + u8 chan_select;
3411 +-
3412 +- u32 buffer[4]; /* 64-bit data + 64-bit timestamp */
3413 ++ /* 64-bit data + 64-bit naturally aligned timestamp */
3414 ++ u32 buffer[4] __aligned(8);
3415 + };
3416 +
3417 + static const struct iio_chan_spec lmp91000_channels[] = {
3418 +diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
3419 +index b591c63bd6c49..718150a931337 100644
3420 +--- a/drivers/iio/proximity/as3935.c
3421 ++++ b/drivers/iio/proximity/as3935.c
3422 +@@ -61,7 +61,11 @@ struct as3935_state {
3423 + unsigned long noise_tripped;
3424 + u32 tune_cap;
3425 + u32 nflwdth_reg;
3426 +- u8 buffer[16]; /* 8-bit data + 56-bit padding + 64-bit timestamp */
3427 ++ /* Ensure timestamp is naturally aligned */
3428 ++ struct {
3429 ++ u8 chan;
3430 ++ s64 timestamp __aligned(8);
3431 ++ } scan;
3432 + u8 buf[2] ____cacheline_aligned;
3433 + };
3434 +
3435 +@@ -227,8 +231,8 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private)
3436 + if (ret)
3437 + goto err_read;
3438 +
3439 +- st->buffer[0] = val & AS3935_DATA_MASK;
3440 +- iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer,
3441 ++ st->scan.chan = val & AS3935_DATA_MASK;
3442 ++ iio_push_to_buffers_with_timestamp(indio_dev, &st->scan,
3443 + iio_get_time_ns(indio_dev));
3444 + err_read:
3445 + iio_trigger_notify_done(indio_dev->trig);
3446 +diff --git a/drivers/iio/proximity/isl29501.c b/drivers/iio/proximity/isl29501.c
3447 +index 5ae549075b27c..56d6e9f927f40 100644
3448 +--- a/drivers/iio/proximity/isl29501.c
3449 ++++ b/drivers/iio/proximity/isl29501.c
3450 +@@ -938,7 +938,7 @@ static irqreturn_t isl29501_trigger_handler(int irq, void *p)
3451 + struct iio_dev *indio_dev = pf->indio_dev;
3452 + struct isl29501_private *isl29501 = iio_priv(indio_dev);
3453 + const unsigned long *active_mask = indio_dev->active_scan_mask;
3454 +- u32 buffer[4] = {}; /* 1x16-bit + ts */
3455 ++ u32 buffer[4] __aligned(8) = {}; /* 1x16-bit + naturally aligned ts */
3456 +
3457 + if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask))
3458 + isl29501_register_read(isl29501, REG_DISTANCE, buffer);
3459 +diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
3460 +index 67f85268b63db..0c76170224071 100644
3461 +--- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
3462 ++++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
3463 +@@ -43,7 +43,11 @@ struct lidar_data {
3464 + int (*xfer)(struct lidar_data *data, u8 reg, u8 *val, int len);
3465 + int i2c_enabled;
3466 +
3467 +- u16 buffer[8]; /* 2 byte distance + 8 byte timestamp */
3468 ++ /* Ensure timestamp is naturally aligned */
3469 ++ struct {
3470 ++ u16 chan;
3471 ++ s64 timestamp __aligned(8);
3472 ++ } scan;
3473 + };
3474 +
3475 + static const struct iio_chan_spec lidar_channels[] = {
3476 +@@ -228,9 +232,9 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private)
3477 + struct lidar_data *data = iio_priv(indio_dev);
3478 + int ret;
3479 +
3480 +- ret = lidar_get_measurement(data, data->buffer);
3481 ++ ret = lidar_get_measurement(data, &data->scan.chan);
3482 + if (!ret) {
3483 +- iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
3484 ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
3485 + iio_get_time_ns(indio_dev));
3486 + } else if (ret != -EINVAL) {
3487 + dev_err(&data->client->dev, "cannot read LIDAR measurement");
3488 +diff --git a/drivers/iio/proximity/srf08.c b/drivers/iio/proximity/srf08.c
3489 +index b23ce446b7be6..c99bc514c5e1e 100644
3490 +--- a/drivers/iio/proximity/srf08.c
3491 ++++ b/drivers/iio/proximity/srf08.c
3492 +@@ -63,11 +63,11 @@ struct srf08_data {
3493 + int range_mm;
3494 + struct mutex lock;
3495 +
3496 +- /*
3497 +- * triggered buffer
3498 +- * 1x16-bit channel + 3x16 padding + 4x16 timestamp
3499 +- */
3500 +- s16 buffer[8];
3501 ++ /* Ensure timestamp is naturally aligned */
3502 ++ struct {
3503 ++ s16 chan;
3504 ++ s64 timestamp __aligned(8);
3505 ++ } scan;
3506 +
3507 + /* Sensor-Type */
3508 + enum srf08_sensor_type sensor_type;
3509 +@@ -190,9 +190,9 @@ static irqreturn_t srf08_trigger_handler(int irq, void *p)
3510 +
3511 + mutex_lock(&data->lock);
3512 +
3513 +- data->buffer[0] = sensor_data;
3514 ++ data->scan.chan = sensor_data;
3515 + iio_push_to_buffers_with_timestamp(indio_dev,
3516 +- data->buffer, pf->timestamp);
3517 ++ &data->scan, pf->timestamp);
3518 +
3519 + mutex_unlock(&data->lock);
3520 + err:
3521 +diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
3522 +index c398d1a64614c..d413dafb9211d 100644
3523 +--- a/drivers/infiniband/core/uverbs_cmd.c
3524 ++++ b/drivers/infiniband/core/uverbs_cmd.c
3525 +@@ -3031,12 +3031,29 @@ static int ib_uverbs_ex_modify_wq(struct uverbs_attr_bundle *attrs)
3526 + if (!wq)
3527 + return -EINVAL;
3528 +
3529 +- wq_attr.curr_wq_state = cmd.curr_wq_state;
3530 +- wq_attr.wq_state = cmd.wq_state;
3531 + if (cmd.attr_mask & IB_WQ_FLAGS) {
3532 + wq_attr.flags = cmd.flags;
3533 + wq_attr.flags_mask = cmd.flags_mask;
3534 + }
3535 ++
3536 ++ if (cmd.attr_mask & IB_WQ_CUR_STATE) {
3537 ++ if (cmd.curr_wq_state > IB_WQS_ERR)
3538 ++ return -EINVAL;
3539 ++
3540 ++ wq_attr.curr_wq_state = cmd.curr_wq_state;
3541 ++ } else {
3542 ++ wq_attr.curr_wq_state = wq->state;
3543 ++ }
3544 ++
3545 ++ if (cmd.attr_mask & IB_WQ_STATE) {
3546 ++ if (cmd.wq_state > IB_WQS_ERR)
3547 ++ return -EINVAL;
3548 ++
3549 ++ wq_attr.wq_state = cmd.wq_state;
3550 ++ } else {
3551 ++ wq_attr.wq_state = wq_attr.curr_wq_state;
3552 ++ }
3553 ++
3554 + ret = wq->device->ops.modify_wq(wq, &wq_attr, cmd.attr_mask,
3555 + &attrs->driver_udata);
3556 + uobj_put_obj_read(wq);
3557 +diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
3558 +index 6e2b3e2f83f16..17ce928e41bde 100644
3559 +--- a/drivers/infiniband/hw/mlx4/qp.c
3560 ++++ b/drivers/infiniband/hw/mlx4/qp.c
3561 +@@ -4294,13 +4294,8 @@ int mlx4_ib_modify_wq(struct ib_wq *ibwq, struct ib_wq_attr *wq_attr,
3562 + if (wq_attr_mask & IB_WQ_FLAGS)
3563 + return -EOPNOTSUPP;
3564 +
3565 +- cur_state = wq_attr_mask & IB_WQ_CUR_STATE ? wq_attr->curr_wq_state :
3566 +- ibwq->state;
3567 +- new_state = wq_attr_mask & IB_WQ_STATE ? wq_attr->wq_state : cur_state;
3568 +-
3569 +- if (cur_state < IB_WQS_RESET || cur_state > IB_WQS_ERR ||
3570 +- new_state < IB_WQS_RESET || new_state > IB_WQS_ERR)
3571 +- return -EINVAL;
3572 ++ cur_state = wq_attr->curr_wq_state;
3573 ++ new_state = wq_attr->wq_state;
3574 +
3575 + if ((new_state == IB_WQS_RDY) && (cur_state == IB_WQS_ERR))
3576 + return -EINVAL;
3577 +diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
3578 +index a173737cb0222..9025086a8932d 100644
3579 +--- a/drivers/infiniband/hw/mlx5/main.c
3580 ++++ b/drivers/infiniband/hw/mlx5/main.c
3581 +@@ -5871,8 +5871,6 @@ static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev,
3582 +
3583 + port->mp.mpi = NULL;
3584 +
3585 +- list_add_tail(&mpi->list, &mlx5_ib_unaffiliated_port_list);
3586 +-
3587 + spin_unlock(&port->mp.mpi_lock);
3588 +
3589 + err = mlx5_nic_vport_unaffiliate_multiport(mpi->mdev);
3590 +@@ -6025,6 +6023,8 @@ static void mlx5_ib_cleanup_multiport_master(struct mlx5_ib_dev *dev)
3591 + dev->port[i].mp.mpi = NULL;
3592 + } else {
3593 + mlx5_ib_dbg(dev, "unbinding port_num: %d\n", i + 1);
3594 ++ list_add_tail(&dev->port[i].mp.mpi->list,
3595 ++ &mlx5_ib_unaffiliated_port_list);
3596 + mlx5_ib_unbind_slave_port(dev, dev->port[i].mp.mpi);
3597 + }
3598 + }
3599 +diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
3600 +index 09e29c6cb66dc..4540835e05bda 100644
3601 +--- a/drivers/infiniband/hw/mlx5/qp.c
3602 ++++ b/drivers/infiniband/hw/mlx5/qp.c
3603 +@@ -6317,10 +6317,8 @@ int mlx5_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
3604 +
3605 + rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
3606 +
3607 +- curr_wq_state = (wq_attr_mask & IB_WQ_CUR_STATE) ?
3608 +- wq_attr->curr_wq_state : wq->state;
3609 +- wq_state = (wq_attr_mask & IB_WQ_STATE) ?
3610 +- wq_attr->wq_state : curr_wq_state;
3611 ++ curr_wq_state = wq_attr->curr_wq_state;
3612 ++ wq_state = wq_attr->wq_state;
3613 + if (curr_wq_state == IB_WQS_ERR)
3614 + curr_wq_state = MLX5_RQC_STATE_ERR;
3615 + if (wq_state == IB_WQS_ERR)
3616 +diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
3617 +index d411356828911..7d1df737c6558 100644
3618 +--- a/drivers/infiniband/sw/rxe/rxe_net.c
3619 ++++ b/drivers/infiniband/sw/rxe/rxe_net.c
3620 +@@ -251,10 +251,8 @@ static struct socket *rxe_setup_udp_tunnel(struct net *net, __be16 port,
3621 +
3622 + /* Create UDP socket */
3623 + err = udp_sock_create(net, &udp_cfg, &sock);
3624 +- if (err < 0) {
3625 +- pr_err("failed to create udp socket. err = %d\n", err);
3626 ++ if (err < 0)
3627 + return ERR_PTR(err);
3628 +- }
3629 +
3630 + tnl_cfg.encap_type = 1;
3631 + tnl_cfg.encap_rcv = rxe_udp_encap_recv;
3632 +@@ -660,6 +658,12 @@ static int rxe_net_ipv6_init(void)
3633 +
3634 + recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
3635 + htons(ROCE_V2_UDP_DPORT), true);
3636 ++ if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT) {
3637 ++ recv_sockets.sk6 = NULL;
3638 ++ pr_warn("IPv6 is not supported, can not create a UDPv6 socket\n");
3639 ++ return 0;
3640 ++ }
3641 ++
3642 + if (IS_ERR(recv_sockets.sk6)) {
3643 + recv_sockets.sk6 = NULL;
3644 + pr_err("Failed to create IPv6 UDP tunnel\n");
3645 +diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c
3646 +index d427a343c09f6..53166b9ae67e5 100644
3647 +--- a/drivers/infiniband/sw/rxe/rxe_qp.c
3648 ++++ b/drivers/infiniband/sw/rxe/rxe_qp.c
3649 +@@ -152,7 +152,6 @@ static void free_rd_atomic_resources(struct rxe_qp *qp)
3650 + void free_rd_atomic_resource(struct rxe_qp *qp, struct resp_res *res)
3651 + {
3652 + if (res->type == RXE_ATOMIC_MASK) {
3653 +- rxe_drop_ref(qp);
3654 + kfree_skb(res->atomic.skb);
3655 + } else if (res->type == RXE_READ_MASK) {
3656 + if (res->read.mr)
3657 +diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
3658 +index c4a8195bf6709..186152bf79514 100644
3659 +--- a/drivers/infiniband/sw/rxe/rxe_resp.c
3660 ++++ b/drivers/infiniband/sw/rxe/rxe_resp.c
3661 +@@ -993,8 +993,6 @@ static int send_atomic_ack(struct rxe_qp *qp, struct rxe_pkt_info *pkt,
3662 + goto out;
3663 + }
3664 +
3665 +- rxe_add_ref(qp);
3666 +-
3667 + res = &qp->resp.resources[qp->resp.res_head];
3668 + free_rd_atomic_resource(qp, res);
3669 + rxe_advance_resp_resource(qp);
3670 +diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
3671 +index 430dc69750048..675fcd0952a2d 100644
3672 +--- a/drivers/input/joydev.c
3673 ++++ b/drivers/input/joydev.c
3674 +@@ -500,7 +500,7 @@ static int joydev_handle_JSIOCSBTNMAP(struct joydev *joydev,
3675 + memcpy(joydev->keypam, keypam, len);
3676 +
3677 + for (i = 0; i < joydev->nkey; i++)
3678 +- joydev->keymap[keypam[i] - BTN_MISC] = i;
3679 ++ joydev->keymap[joydev->keypam[i] - BTN_MISC] = i;
3680 +
3681 + out:
3682 + kfree(keypam);
3683 +diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
3684 +index 8911bc2ec42a8..ae0bdc4391059 100644
3685 +--- a/drivers/input/keyboard/Kconfig
3686 ++++ b/drivers/input/keyboard/Kconfig
3687 +@@ -68,9 +68,6 @@ config KEYBOARD_AMIGA
3688 + To compile this driver as a module, choose M here: the
3689 + module will be called amikbd.
3690 +
3691 +-config ATARI_KBD_CORE
3692 +- bool
3693 +-
3694 + config KEYBOARD_APPLESPI
3695 + tristate "Apple SPI keyboard and trackpad"
3696 + depends on ACPI && EFI
3697 +diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c
3698 +index bb29a7c9a1c0c..54afb38601b9f 100644
3699 +--- a/drivers/input/keyboard/hil_kbd.c
3700 ++++ b/drivers/input/keyboard/hil_kbd.c
3701 +@@ -512,6 +512,7 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv)
3702 + HIL_IDD_NUM_AXES_PER_SET(*idd)) {
3703 + printk(KERN_INFO PREFIX
3704 + "combo devices are not supported.\n");
3705 ++ error = -EINVAL;
3706 + goto bail1;
3707 + }
3708 +
3709 +diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
3710 +index 397cb1d3f481b..544a8f40b81f1 100644
3711 +--- a/drivers/input/touchscreen/usbtouchscreen.c
3712 ++++ b/drivers/input/touchscreen/usbtouchscreen.c
3713 +@@ -251,7 +251,7 @@ static int e2i_init(struct usbtouch_usb *usbtouch)
3714 + int ret;
3715 + struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
3716 +
3717 +- ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
3718 ++ ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
3719 + 0x01, 0x02, 0x0000, 0x0081,
3720 + NULL, 0, USB_CTRL_SET_TIMEOUT);
3721 +
3722 +@@ -531,7 +531,7 @@ static int mtouch_init(struct usbtouch_usb *usbtouch)
3723 + if (ret)
3724 + return ret;
3725 +
3726 +- ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
3727 ++ ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
3728 + MTOUCHUSB_RESET,
3729 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
3730 + 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
3731 +@@ -543,7 +543,7 @@ static int mtouch_init(struct usbtouch_usb *usbtouch)
3732 + msleep(150);
3733 +
3734 + for (i = 0; i < 3; i++) {
3735 +- ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
3736 ++ ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
3737 + MTOUCHUSB_ASYNC_REPORT,
3738 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
3739 + 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
3740 +@@ -722,7 +722,7 @@ static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
3741 + }
3742 +
3743 + /* start sending data */
3744 +- ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
3745 ++ ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
3746 + TSC10_CMD_DATA1,
3747 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
3748 + 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
3749 +diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
3750 +index 76bd2309e0234..9c3e630c6c4c8 100644
3751 +--- a/drivers/iommu/dma-iommu.c
3752 ++++ b/drivers/iommu/dma-iommu.c
3753 +@@ -216,9 +216,11 @@ resv_iova:
3754 + lo = iova_pfn(iovad, start);
3755 + hi = iova_pfn(iovad, end);
3756 + reserve_iova(iovad, lo, hi);
3757 +- } else {
3758 ++ } else if (end < start) {
3759 + /* dma_ranges list should be sorted */
3760 +- dev_err(&dev->dev, "Failed to reserve IOVA\n");
3761 ++ dev_err(&dev->dev,
3762 ++ "Failed to reserve IOVA [%pa-%pa]\n",
3763 ++ &start, &end);
3764 + return -EINVAL;
3765 + }
3766 +
3767 +diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
3768 +index 1988de1d64c05..2cbf66d1c3000 100644
3769 +--- a/drivers/leds/Kconfig
3770 ++++ b/drivers/leds/Kconfig
3771 +@@ -144,6 +144,7 @@ config LEDS_LM3530
3772 +
3773 + config LEDS_LM3532
3774 + tristate "LCD Backlight driver for LM3532"
3775 ++ select REGMAP_I2C
3776 + depends on LEDS_CLASS
3777 + depends on I2C
3778 + help
3779 +diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
3780 +index b7e0ae1af8fa5..1dc6f1b24ddb5 100644
3781 +--- a/drivers/leds/leds-as3645a.c
3782 ++++ b/drivers/leds/leds-as3645a.c
3783 +@@ -544,6 +544,7 @@ static int as3645a_parse_node(struct as3645a *flash,
3784 + if (!flash->indicator_node) {
3785 + dev_warn(&flash->client->dev,
3786 + "can't find indicator node\n");
3787 ++ rval = -ENODEV;
3788 + goto out_err;
3789 + }
3790 +
3791 +diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c
3792 +index 670efee9b1317..cd30b3b46e76c 100644
3793 +--- a/drivers/leds/leds-ktd2692.c
3794 ++++ b/drivers/leds/leds-ktd2692.c
3795 +@@ -256,6 +256,17 @@ static void ktd2692_setup(struct ktd2692_context *led)
3796 + | KTD2692_REG_FLASH_CURRENT_BASE);
3797 + }
3798 +
3799 ++static void regulator_disable_action(void *_data)
3800 ++{
3801 ++ struct device *dev = _data;
3802 ++ struct ktd2692_context *led = dev_get_drvdata(dev);
3803 ++ int ret;
3804 ++
3805 ++ ret = regulator_disable(led->regulator);
3806 ++ if (ret)
3807 ++ dev_err(dev, "Failed to disable supply: %d\n", ret);
3808 ++}
3809 ++
3810 + static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
3811 + struct ktd2692_led_config_data *cfg)
3812 + {
3813 +@@ -286,8 +297,14 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
3814 +
3815 + if (led->regulator) {
3816 + ret = regulator_enable(led->regulator);
3817 +- if (ret)
3818 ++ if (ret) {
3819 + dev_err(dev, "Failed to enable supply: %d\n", ret);
3820 ++ } else {
3821 ++ ret = devm_add_action_or_reset(dev,
3822 ++ regulator_disable_action, dev);
3823 ++ if (ret)
3824 ++ return ret;
3825 ++ }
3826 + }
3827 +
3828 + child_node = of_get_next_available_child(np, NULL);
3829 +@@ -377,17 +394,9 @@ static int ktd2692_probe(struct platform_device *pdev)
3830 + static int ktd2692_remove(struct platform_device *pdev)
3831 + {
3832 + struct ktd2692_context *led = platform_get_drvdata(pdev);
3833 +- int ret;
3834 +
3835 + led_classdev_flash_unregister(&led->fled_cdev);
3836 +
3837 +- if (led->regulator) {
3838 +- ret = regulator_disable(led->regulator);
3839 +- if (ret)
3840 +- dev_err(&pdev->dev,
3841 +- "Failed to disable supply: %d\n", ret);
3842 +- }
3843 +-
3844 + mutex_destroy(&led->lock);
3845 +
3846 + return 0;
3847 +diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c
3848 +index db842eeb7ca20..6c143551f10a6 100644
3849 +--- a/drivers/leds/leds-lm36274.c
3850 ++++ b/drivers/leds/leds-lm36274.c
3851 +@@ -41,37 +41,36 @@ struct lm36274 {
3852 + };
3853 +
3854 + static int lm36274_brightness_set(struct led_classdev *led_cdev,
3855 +- enum led_brightness brt_val)
3856 ++ enum led_brightness brt_val)
3857 + {
3858 +- struct lm36274 *led = container_of(led_cdev, struct lm36274, led_dev);
3859 ++ struct lm36274 *chip = container_of(led_cdev, struct lm36274, led_dev);
3860 +
3861 +- return ti_lmu_common_set_brightness(&led->lmu_data, brt_val);
3862 ++ return ti_lmu_common_set_brightness(&chip->lmu_data, brt_val);
3863 + }
3864 +
3865 +-static int lm36274_init(struct lm36274 *lm36274_data)
3866 ++static int lm36274_init(struct lm36274 *chip)
3867 + {
3868 + int enable_val = 0;
3869 + int i;
3870 +
3871 +- for (i = 0; i < lm36274_data->num_leds; i++)
3872 +- enable_val |= (1 << lm36274_data->led_sources[i]);
3873 ++ for (i = 0; i < chip->num_leds; i++)
3874 ++ enable_val |= (1 << chip->led_sources[i]);
3875 +
3876 + if (!enable_val) {
3877 +- dev_err(lm36274_data->dev, "No LEDs were enabled\n");
3878 ++ dev_err(chip->dev, "No LEDs were enabled\n");
3879 + return -EINVAL;
3880 + }
3881 +
3882 + enable_val |= LM36274_BL_EN;
3883 +
3884 +- return regmap_write(lm36274_data->regmap, LM36274_REG_BL_EN,
3885 +- enable_val);
3886 ++ return regmap_write(chip->regmap, LM36274_REG_BL_EN, enable_val);
3887 + }
3888 +
3889 +-static int lm36274_parse_dt(struct lm36274 *lm36274_data)
3890 ++static int lm36274_parse_dt(struct lm36274 *chip)
3891 + {
3892 + struct fwnode_handle *child = NULL;
3893 + char label[LED_MAX_NAME_SIZE];
3894 +- struct device *dev = &lm36274_data->pdev->dev;
3895 ++ struct device *dev = &chip->pdev->dev;
3896 + const char *name;
3897 + int child_cnt;
3898 + int ret = -EINVAL;
3899 +@@ -84,37 +83,37 @@ static int lm36274_parse_dt(struct lm36274 *lm36274_data)
3900 + device_for_each_child_node(dev, child) {
3901 + ret = fwnode_property_read_string(child, "label", &name);
3902 + if (ret)
3903 +- snprintf(label, sizeof(label),
3904 +- "%s::", lm36274_data->pdev->name);
3905 ++ snprintf(label, sizeof(label), "%s::",
3906 ++ chip->pdev->name);
3907 + else
3908 +- snprintf(label, sizeof(label),
3909 +- "%s:%s", lm36274_data->pdev->name, name);
3910 ++ snprintf(label, sizeof(label), "%s:%s",
3911 ++ chip->pdev->name, name);
3912 +
3913 +- lm36274_data->num_leds = fwnode_property_count_u32(child, "led-sources");
3914 +- if (lm36274_data->num_leds <= 0)
3915 ++ chip->num_leds = fwnode_property_count_u32(child, "led-sources");
3916 ++ if (chip->num_leds <= 0)
3917 + return -ENODEV;
3918 +
3919 + ret = fwnode_property_read_u32_array(child, "led-sources",
3920 +- lm36274_data->led_sources,
3921 +- lm36274_data->num_leds);
3922 ++ chip->led_sources,
3923 ++ chip->num_leds);
3924 + if (ret) {
3925 + dev_err(dev, "led-sources property missing\n");
3926 + return ret;
3927 + }
3928 +
3929 + fwnode_property_read_string(child, "linux,default-trigger",
3930 +- &lm36274_data->led_dev.default_trigger);
3931 ++ &chip->led_dev.default_trigger);
3932 +
3933 + }
3934 +
3935 +- lm36274_data->lmu_data.regmap = lm36274_data->regmap;
3936 +- lm36274_data->lmu_data.max_brightness = MAX_BRIGHTNESS_11BIT;
3937 +- lm36274_data->lmu_data.msb_brightness_reg = LM36274_REG_BRT_MSB;
3938 +- lm36274_data->lmu_data.lsb_brightness_reg = LM36274_REG_BRT_LSB;
3939 ++ chip->lmu_data.regmap = chip->regmap;
3940 ++ chip->lmu_data.max_brightness = MAX_BRIGHTNESS_11BIT;
3941 ++ chip->lmu_data.msb_brightness_reg = LM36274_REG_BRT_MSB;
3942 ++ chip->lmu_data.lsb_brightness_reg = LM36274_REG_BRT_LSB;
3943 +
3944 +- lm36274_data->led_dev.name = label;
3945 +- lm36274_data->led_dev.max_brightness = MAX_BRIGHTNESS_11BIT;
3946 +- lm36274_data->led_dev.brightness_set_blocking = lm36274_brightness_set;
3947 ++ chip->led_dev.name = label;
3948 ++ chip->led_dev.max_brightness = MAX_BRIGHTNESS_11BIT;
3949 ++ chip->led_dev.brightness_set_blocking = lm36274_brightness_set;
3950 +
3951 + return 0;
3952 + }
3953 +@@ -122,39 +121,38 @@ static int lm36274_parse_dt(struct lm36274 *lm36274_data)
3954 + static int lm36274_probe(struct platform_device *pdev)
3955 + {
3956 + struct ti_lmu *lmu = dev_get_drvdata(pdev->dev.parent);
3957 +- struct lm36274 *lm36274_data;
3958 ++ struct lm36274 *chip;
3959 + int ret;
3960 +
3961 +- lm36274_data = devm_kzalloc(&pdev->dev, sizeof(*lm36274_data),
3962 +- GFP_KERNEL);
3963 +- if (!lm36274_data)
3964 ++ chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
3965 ++ if (!chip)
3966 + return -ENOMEM;
3967 +
3968 +- lm36274_data->pdev = pdev;
3969 +- lm36274_data->dev = lmu->dev;
3970 +- lm36274_data->regmap = lmu->regmap;
3971 +- platform_set_drvdata(pdev, lm36274_data);
3972 ++ chip->pdev = pdev;
3973 ++ chip->dev = lmu->dev;
3974 ++ chip->regmap = lmu->regmap;
3975 ++ platform_set_drvdata(pdev, chip);
3976 +
3977 +- ret = lm36274_parse_dt(lm36274_data);
3978 ++ ret = lm36274_parse_dt(chip);
3979 + if (ret) {
3980 +- dev_err(lm36274_data->dev, "Failed to parse DT node\n");
3981 ++ dev_err(chip->dev, "Failed to parse DT node\n");
3982 + return ret;
3983 + }
3984 +
3985 +- ret = lm36274_init(lm36274_data);
3986 ++ ret = lm36274_init(chip);
3987 + if (ret) {
3988 +- dev_err(lm36274_data->dev, "Failed to init the device\n");
3989 ++ dev_err(chip->dev, "Failed to init the device\n");
3990 + return ret;
3991 + }
3992 +
3993 +- return led_classdev_register(lm36274_data->dev, &lm36274_data->led_dev);
3994 ++ return led_classdev_register(chip->dev, &chip->led_dev);
3995 + }
3996 +
3997 + static int lm36274_remove(struct platform_device *pdev)
3998 + {
3999 +- struct lm36274 *lm36274_data = platform_get_drvdata(pdev);
4000 ++ struct lm36274 *chip = platform_get_drvdata(pdev);
4001 +
4002 +- led_classdev_unregister(&lm36274_data->led_dev);
4003 ++ led_classdev_unregister(&chip->led_dev);
4004 +
4005 + return 0;
4006 + }
4007 +diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
4008 +index 1ac9a44570eed..cc77ea048d9be 100644
4009 +--- a/drivers/leds/leds-lm3692x.c
4010 ++++ b/drivers/leds/leds-lm3692x.c
4011 +@@ -358,6 +358,7 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
4012 +
4013 + ret = fwnode_property_read_u32(child, "reg", &led->led_enable);
4014 + if (ret) {
4015 ++ fwnode_handle_put(child);
4016 + dev_err(&led->client->dev, "reg DT property missing\n");
4017 + return ret;
4018 + }
4019 +@@ -368,12 +369,11 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
4020 +
4021 + ret = devm_led_classdev_register_ext(&led->client->dev, &led->led_dev,
4022 + &init_data);
4023 +- if (ret) {
4024 ++ if (ret)
4025 + dev_err(&led->client->dev, "led register err: %d\n", ret);
4026 +- return ret;
4027 +- }
4028 +
4029 +- return 0;
4030 ++ fwnode_handle_put(init_data.fwnode);
4031 ++ return ret;
4032 + }
4033 +
4034 + static int lm3692x_probe(struct i2c_client *client,
4035 +diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
4036 +index 0ba51dacc5808..ce94b5205fd6e 100644
4037 +--- a/drivers/media/common/siano/smscoreapi.c
4038 ++++ b/drivers/media/common/siano/smscoreapi.c
4039 +@@ -908,7 +908,7 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
4040 + void *buffer, size_t size)
4041 + {
4042 + struct sms_firmware *firmware = (struct sms_firmware *) buffer;
4043 +- struct sms_msg_data4 *msg;
4044 ++ struct sms_msg_data5 *msg;
4045 + u32 mem_address, calc_checksum = 0;
4046 + u32 i, *ptr;
4047 + u8 *payload = firmware->payload;
4048 +@@ -989,24 +989,20 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
4049 + goto exit_fw_download;
4050 +
4051 + if (coredev->mode == DEVICE_MODE_NONE) {
4052 +- struct sms_msg_data *trigger_msg =
4053 +- (struct sms_msg_data *) msg;
4054 +-
4055 + pr_debug("sending MSG_SMS_SWDOWNLOAD_TRIGGER_REQ\n");
4056 + SMS_INIT_MSG(&msg->x_msg_header,
4057 + MSG_SMS_SWDOWNLOAD_TRIGGER_REQ,
4058 +- sizeof(struct sms_msg_hdr) +
4059 +- sizeof(u32) * 5);
4060 ++ sizeof(*msg));
4061 +
4062 +- trigger_msg->msg_data[0] = firmware->start_address;
4063 ++ msg->msg_data[0] = firmware->start_address;
4064 + /* Entry point */
4065 +- trigger_msg->msg_data[1] = 6; /* Priority */
4066 +- trigger_msg->msg_data[2] = 0x200; /* Stack size */
4067 +- trigger_msg->msg_data[3] = 0; /* Parameter */
4068 +- trigger_msg->msg_data[4] = 4; /* Task ID */
4069 ++ msg->msg_data[1] = 6; /* Priority */
4070 ++ msg->msg_data[2] = 0x200; /* Stack size */
4071 ++ msg->msg_data[3] = 0; /* Parameter */
4072 ++ msg->msg_data[4] = 4; /* Task ID */
4073 +
4074 +- rc = smscore_sendrequest_and_wait(coredev, trigger_msg,
4075 +- trigger_msg->x_msg_header.msg_length,
4076 ++ rc = smscore_sendrequest_and_wait(coredev, msg,
4077 ++ msg->x_msg_header.msg_length,
4078 + &coredev->trigger_done);
4079 + } else {
4080 + SMS_INIT_MSG(&msg->x_msg_header, MSG_SW_RELOAD_EXEC_REQ,
4081 +diff --git a/drivers/media/common/siano/smscoreapi.h b/drivers/media/common/siano/smscoreapi.h
4082 +index a2f95f4899c22..cd6c981eb1f96 100644
4083 +--- a/drivers/media/common/siano/smscoreapi.h
4084 ++++ b/drivers/media/common/siano/smscoreapi.h
4085 +@@ -629,9 +629,9 @@ struct sms_msg_data2 {
4086 + u32 msg_data[2];
4087 + };
4088 +
4089 +-struct sms_msg_data4 {
4090 ++struct sms_msg_data5 {
4091 + struct sms_msg_hdr x_msg_header;
4092 +- u32 msg_data[4];
4093 ++ u32 msg_data[5];
4094 + };
4095 +
4096 + struct sms_data_download {
4097 +diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
4098 +index ae17407e477a4..7cc654bc52d37 100644
4099 +--- a/drivers/media/common/siano/smsdvb-main.c
4100 ++++ b/drivers/media/common/siano/smsdvb-main.c
4101 +@@ -1176,6 +1176,10 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
4102 + return 0;
4103 +
4104 + media_graph_error:
4105 ++ mutex_lock(&g_smsdvb_clientslock);
4106 ++ list_del(&client->entry);
4107 ++ mutex_unlock(&g_smsdvb_clientslock);
4108 ++
4109 + smsdvb_debugfs_release(client);
4110 +
4111 + client_error:
4112 +diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
4113 +index 630509ecee205..9fed06ba88efb 100644
4114 +--- a/drivers/media/dvb-core/dvb_net.c
4115 ++++ b/drivers/media/dvb-core/dvb_net.c
4116 +@@ -45,6 +45,7 @@
4117 + #include <linux/module.h>
4118 + #include <linux/kernel.h>
4119 + #include <linux/netdevice.h>
4120 ++#include <linux/nospec.h>
4121 + #include <linux/etherdevice.h>
4122 + #include <linux/dvb/net.h>
4123 + #include <linux/uio.h>
4124 +@@ -1462,14 +1463,20 @@ static int dvb_net_do_ioctl(struct file *file,
4125 + struct net_device *netdev;
4126 + struct dvb_net_priv *priv_data;
4127 + struct dvb_net_if *dvbnetif = parg;
4128 ++ int if_num = dvbnetif->if_num;
4129 +
4130 +- if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX ||
4131 +- !dvbnet->state[dvbnetif->if_num]) {
4132 ++ if (if_num >= DVB_NET_DEVICES_MAX) {
4133 + ret = -EINVAL;
4134 + goto ioctl_error;
4135 + }
4136 ++ if_num = array_index_nospec(if_num, DVB_NET_DEVICES_MAX);
4137 +
4138 +- netdev = dvbnet->device[dvbnetif->if_num];
4139 ++ if (!dvbnet->state[if_num]) {
4140 ++ ret = -EINVAL;
4141 ++ goto ioctl_error;
4142 ++ }
4143 ++
4144 ++ netdev = dvbnet->device[if_num];
4145 +
4146 + priv_data = netdev_priv(netdev);
4147 + dvbnetif->pid=priv_data->pid;
4148 +@@ -1522,14 +1529,20 @@ static int dvb_net_do_ioctl(struct file *file,
4149 + struct net_device *netdev;
4150 + struct dvb_net_priv *priv_data;
4151 + struct __dvb_net_if_old *dvbnetif = parg;
4152 ++ int if_num = dvbnetif->if_num;
4153 ++
4154 ++ if (if_num >= DVB_NET_DEVICES_MAX) {
4155 ++ ret = -EINVAL;
4156 ++ goto ioctl_error;
4157 ++ }
4158 ++ if_num = array_index_nospec(if_num, DVB_NET_DEVICES_MAX);
4159 +
4160 +- if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX ||
4161 +- !dvbnet->state[dvbnetif->if_num]) {
4162 ++ if (!dvbnet->state[if_num]) {
4163 + ret = -EINVAL;
4164 + goto ioctl_error;
4165 + }
4166 +
4167 +- netdev = dvbnet->device[dvbnetif->if_num];
4168 ++ netdev = dvbnet->device[if_num];
4169 +
4170 + priv_data = netdev_priv(netdev);
4171 + dvbnetif->pid=priv_data->pid;
4172 +diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
4173 +index e8119ad0bc71d..92376592455ee 100644
4174 +--- a/drivers/media/i2c/ir-kbd-i2c.c
4175 ++++ b/drivers/media/i2c/ir-kbd-i2c.c
4176 +@@ -678,8 +678,8 @@ static int zilog_tx(struct rc_dev *rcdev, unsigned int *txbuf,
4177 + goto out_unlock;
4178 + }
4179 +
4180 +- i = i2c_master_recv(ir->tx_c, buf, 1);
4181 +- if (i != 1) {
4182 ++ ret = i2c_master_recv(ir->tx_c, buf, 1);
4183 ++ if (ret != 1) {
4184 + dev_err(&ir->rc->dev, "i2c_master_recv failed with %d\n", ret);
4185 + ret = -EIO;
4186 + goto out_unlock;
4187 +diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
4188 +index 5b4c4a3547c93..71804a70bc6d7 100644
4189 +--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
4190 ++++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
4191 +@@ -1386,7 +1386,7 @@ static int __s5c73m3_power_on(struct s5c73m3 *state)
4192 + s5c73m3_gpio_deassert(state, STBY);
4193 + usleep_range(100, 200);
4194 +
4195 +- s5c73m3_gpio_deassert(state, RST);
4196 ++ s5c73m3_gpio_deassert(state, RSET);
4197 + usleep_range(50, 100);
4198 +
4199 + return 0;
4200 +@@ -1401,7 +1401,7 @@ static int __s5c73m3_power_off(struct s5c73m3 *state)
4201 + {
4202 + int i, ret;
4203 +
4204 +- if (s5c73m3_gpio_assert(state, RST))
4205 ++ if (s5c73m3_gpio_assert(state, RSET))
4206 + usleep_range(10, 50);
4207 +
4208 + if (s5c73m3_gpio_assert(state, STBY))
4209 +@@ -1606,7 +1606,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
4210 +
4211 + state->mclk_frequency = pdata->mclk_frequency;
4212 + state->gpio[STBY] = pdata->gpio_stby;
4213 +- state->gpio[RST] = pdata->gpio_reset;
4214 ++ state->gpio[RSET] = pdata->gpio_reset;
4215 + return 0;
4216 + }
4217 +
4218 +diff --git a/drivers/media/i2c/s5c73m3/s5c73m3.h b/drivers/media/i2c/s5c73m3/s5c73m3.h
4219 +index ef7e85b34263b..c3fcfdd3ea66d 100644
4220 +--- a/drivers/media/i2c/s5c73m3/s5c73m3.h
4221 ++++ b/drivers/media/i2c/s5c73m3/s5c73m3.h
4222 +@@ -353,7 +353,7 @@ struct s5c73m3_ctrls {
4223 +
4224 + enum s5c73m3_gpio_id {
4225 + STBY,
4226 +- RST,
4227 ++ RSET,
4228 + GPIO_NUM,
4229 + };
4230 +
4231 +diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
4232 +index b2d53417badf6..4e97309a67f41 100644
4233 +--- a/drivers/media/i2c/s5k4ecgx.c
4234 ++++ b/drivers/media/i2c/s5k4ecgx.c
4235 +@@ -173,7 +173,7 @@ static const char * const s5k4ecgx_supply_names[] = {
4236 +
4237 + enum s5k4ecgx_gpio_id {
4238 + STBY,
4239 +- RST,
4240 ++ RSET,
4241 + GPIO_NUM,
4242 + };
4243 +
4244 +@@ -476,7 +476,7 @@ static int __s5k4ecgx_power_on(struct s5k4ecgx *priv)
4245 + if (s5k4ecgx_gpio_set_value(priv, STBY, priv->gpio[STBY].level))
4246 + usleep_range(30, 50);
4247 +
4248 +- if (s5k4ecgx_gpio_set_value(priv, RST, priv->gpio[RST].level))
4249 ++ if (s5k4ecgx_gpio_set_value(priv, RSET, priv->gpio[RSET].level))
4250 + usleep_range(30, 50);
4251 +
4252 + return 0;
4253 +@@ -484,7 +484,7 @@ static int __s5k4ecgx_power_on(struct s5k4ecgx *priv)
4254 +
4255 + static int __s5k4ecgx_power_off(struct s5k4ecgx *priv)
4256 + {
4257 +- if (s5k4ecgx_gpio_set_value(priv, RST, !priv->gpio[RST].level))
4258 ++ if (s5k4ecgx_gpio_set_value(priv, RSET, !priv->gpio[RSET].level))
4259 + usleep_range(30, 50);
4260 +
4261 + if (s5k4ecgx_gpio_set_value(priv, STBY, !priv->gpio[STBY].level))
4262 +@@ -872,7 +872,7 @@ static int s5k4ecgx_config_gpios(struct s5k4ecgx *priv,
4263 + int ret;
4264 +
4265 + priv->gpio[STBY].gpio = -EINVAL;
4266 +- priv->gpio[RST].gpio = -EINVAL;
4267 ++ priv->gpio[RSET].gpio = -EINVAL;
4268 +
4269 + ret = s5k4ecgx_config_gpio(gpio->gpio, gpio->level, "S5K4ECGX_STBY");
4270 +
4271 +@@ -891,7 +891,7 @@ static int s5k4ecgx_config_gpios(struct s5k4ecgx *priv,
4272 + s5k4ecgx_free_gpios(priv);
4273 + return ret;
4274 + }
4275 +- priv->gpio[RST] = *gpio;
4276 ++ priv->gpio[RSET] = *gpio;
4277 + if (gpio_is_valid(gpio->gpio))
4278 + gpio_set_value(gpio->gpio, 0);
4279 +
4280 +diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
4281 +index cdfe008ba39f8..ac5ab3392073a 100644
4282 +--- a/drivers/media/i2c/s5k5baf.c
4283 ++++ b/drivers/media/i2c/s5k5baf.c
4284 +@@ -235,7 +235,7 @@ struct s5k5baf_gpio {
4285 +
4286 + enum s5k5baf_gpio_id {
4287 + STBY,
4288 +- RST,
4289 ++ RSET,
4290 + NUM_GPIOS,
4291 + };
4292 +
4293 +@@ -970,7 +970,7 @@ static int s5k5baf_power_on(struct s5k5baf *state)
4294 +
4295 + s5k5baf_gpio_deassert(state, STBY);
4296 + usleep_range(50, 100);
4297 +- s5k5baf_gpio_deassert(state, RST);
4298 ++ s5k5baf_gpio_deassert(state, RSET);
4299 + return 0;
4300 +
4301 + err_reg_dis:
4302 +@@ -988,7 +988,7 @@ static int s5k5baf_power_off(struct s5k5baf *state)
4303 + state->apply_cfg = 0;
4304 + state->apply_crop = 0;
4305 +
4306 +- s5k5baf_gpio_assert(state, RST);
4307 ++ s5k5baf_gpio_assert(state, RSET);
4308 + s5k5baf_gpio_assert(state, STBY);
4309 +
4310 + if (!IS_ERR(state->clock))
4311 +diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
4312 +index 72439fae7968b..6516e205e9a3d 100644
4313 +--- a/drivers/media/i2c/s5k6aa.c
4314 ++++ b/drivers/media/i2c/s5k6aa.c
4315 +@@ -177,7 +177,7 @@ static const char * const s5k6aa_supply_names[] = {
4316 +
4317 + enum s5k6aa_gpio_id {
4318 + STBY,
4319 +- RST,
4320 ++ RSET,
4321 + GPIO_NUM,
4322 + };
4323 +
4324 +@@ -841,7 +841,7 @@ static int __s5k6aa_power_on(struct s5k6aa *s5k6aa)
4325 + ret = s5k6aa->s_power(1);
4326 + usleep_range(4000, 5000);
4327 +
4328 +- if (s5k6aa_gpio_deassert(s5k6aa, RST))
4329 ++ if (s5k6aa_gpio_deassert(s5k6aa, RSET))
4330 + msleep(20);
4331 +
4332 + return ret;
4333 +@@ -851,7 +851,7 @@ static int __s5k6aa_power_off(struct s5k6aa *s5k6aa)
4334 + {
4335 + int ret;
4336 +
4337 +- if (s5k6aa_gpio_assert(s5k6aa, RST))
4338 ++ if (s5k6aa_gpio_assert(s5k6aa, RSET))
4339 + usleep_range(100, 150);
4340 +
4341 + if (s5k6aa->s_power) {
4342 +@@ -1510,7 +1510,7 @@ static int s5k6aa_configure_gpios(struct s5k6aa *s5k6aa,
4343 + int ret;
4344 +
4345 + s5k6aa->gpio[STBY].gpio = -EINVAL;
4346 +- s5k6aa->gpio[RST].gpio = -EINVAL;
4347 ++ s5k6aa->gpio[RSET].gpio = -EINVAL;
4348 +
4349 + gpio = &pdata->gpio_stby;
4350 + if (gpio_is_valid(gpio->gpio)) {
4351 +@@ -1533,7 +1533,7 @@ static int s5k6aa_configure_gpios(struct s5k6aa *s5k6aa,
4352 + if (ret < 0)
4353 + return ret;
4354 +
4355 +- s5k6aa->gpio[RST] = *gpio;
4356 ++ s5k6aa->gpio[RSET] = *gpio;
4357 + }
4358 +
4359 + return 0;
4360 +diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
4361 +index 114c084c4aec1..76c443067ec2d 100644
4362 +--- a/drivers/media/i2c/tc358743.c
4363 ++++ b/drivers/media/i2c/tc358743.c
4364 +@@ -1973,6 +1973,7 @@ static int tc358743_probe_of(struct tc358743_state *state)
4365 + bps_pr_lane = 2 * endpoint.link_frequencies[0];
4366 + if (bps_pr_lane < 62500000U || bps_pr_lane > 1000000000U) {
4367 + dev_err(dev, "unsupported bps per lane: %u bps\n", bps_pr_lane);
4368 ++ ret = -EINVAL;
4369 + goto disable_clk;
4370 + }
4371 +
4372 +diff --git a/drivers/media/mc/Makefile b/drivers/media/mc/Makefile
4373 +index 119037f0e686d..2b7af42ba59c1 100644
4374 +--- a/drivers/media/mc/Makefile
4375 ++++ b/drivers/media/mc/Makefile
4376 +@@ -3,7 +3,7 @@
4377 + mc-objs := mc-device.o mc-devnode.o mc-entity.o \
4378 + mc-request.o
4379 +
4380 +-ifeq ($(CONFIG_USB),y)
4381 ++ifneq ($(CONFIG_USB),)
4382 + mc-objs += mc-dev-allocator.o
4383 + endif
4384 +
4385 +diff --git a/drivers/media/pci/bt8xx/bt878.c b/drivers/media/pci/bt8xx/bt878.c
4386 +index 53af26ad1dfb5..1a741b47eaa19 100644
4387 +--- a/drivers/media/pci/bt8xx/bt878.c
4388 ++++ b/drivers/media/pci/bt8xx/bt878.c
4389 +@@ -477,6 +477,9 @@ static int bt878_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4390 + btwrite(0, BT878_AINT_MASK);
4391 + bt878_num++;
4392 +
4393 ++ if (!bt->tasklet.func)
4394 ++ tasklet_disable(&bt->tasklet);
4395 ++
4396 + return 0;
4397 +
4398 + fail2:
4399 +diff --git a/drivers/media/pci/cobalt/cobalt-driver.c b/drivers/media/pci/cobalt/cobalt-driver.c
4400 +index 0695078ef8125..1bd8bbe57a30e 100644
4401 +--- a/drivers/media/pci/cobalt/cobalt-driver.c
4402 ++++ b/drivers/media/pci/cobalt/cobalt-driver.c
4403 +@@ -667,6 +667,7 @@ static int cobalt_probe(struct pci_dev *pci_dev,
4404 + return -ENOMEM;
4405 + cobalt->pci_dev = pci_dev;
4406 + cobalt->instance = i;
4407 ++ mutex_init(&cobalt->pci_lock);
4408 +
4409 + retval = v4l2_device_register(&pci_dev->dev, &cobalt->v4l2_dev);
4410 + if (retval) {
4411 +diff --git a/drivers/media/pci/cobalt/cobalt-driver.h b/drivers/media/pci/cobalt/cobalt-driver.h
4412 +index bca68572b3242..12c33e035904c 100644
4413 +--- a/drivers/media/pci/cobalt/cobalt-driver.h
4414 ++++ b/drivers/media/pci/cobalt/cobalt-driver.h
4415 +@@ -251,6 +251,8 @@ struct cobalt {
4416 + int instance;
4417 + struct pci_dev *pci_dev;
4418 + struct v4l2_device v4l2_dev;
4419 ++ /* serialize PCI access in cobalt_s_bit_sysctrl() */
4420 ++ struct mutex pci_lock;
4421 +
4422 + void __iomem *bar0, *bar1;
4423 +
4424 +@@ -320,10 +322,13 @@ static inline u32 cobalt_g_sysctrl(struct cobalt *cobalt)
4425 + static inline void cobalt_s_bit_sysctrl(struct cobalt *cobalt,
4426 + int bit, int val)
4427 + {
4428 +- u32 ctrl = cobalt_read_bar1(cobalt, COBALT_SYS_CTRL_BASE);
4429 ++ u32 ctrl;
4430 +
4431 ++ mutex_lock(&cobalt->pci_lock);
4432 ++ ctrl = cobalt_read_bar1(cobalt, COBALT_SYS_CTRL_BASE);
4433 + cobalt_write_bar1(cobalt, COBALT_SYS_CTRL_BASE,
4434 + (ctrl & ~(1UL << bit)) | (val << bit));
4435 ++ mutex_unlock(&cobalt->pci_lock);
4436 + }
4437 +
4438 + static inline u32 cobalt_g_sysstat(struct cobalt *cobalt)
4439 +diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
4440 +index 35a1d0d6dd660..42d1e4496efa1 100644
4441 +--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
4442 ++++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
4443 +@@ -56,10 +56,8 @@ static void __gsc_m2m_job_abort(struct gsc_ctx *ctx)
4444 + static int gsc_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
4445 + {
4446 + struct gsc_ctx *ctx = q->drv_priv;
4447 +- int ret;
4448 +
4449 +- ret = pm_runtime_get_sync(&ctx->gsc_dev->pdev->dev);
4450 +- return ret > 0 ? 0 : ret;
4451 ++ return pm_runtime_resume_and_get(&ctx->gsc_dev->pdev->dev);
4452 + }
4453 +
4454 + static void __gsc_m2m_cleanup_queue(struct gsc_ctx *ctx)
4455 +diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c
4456 +index d2cbcdca0463d..370cdf0070128 100644
4457 +--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
4458 ++++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
4459 +@@ -305,17 +305,20 @@ static int isp_video_release(struct file *file)
4460 + struct fimc_is_video *ivc = &isp->video_capture;
4461 + struct media_entity *entity = &ivc->ve.vdev.entity;
4462 + struct media_device *mdev = entity->graph_obj.mdev;
4463 ++ bool is_singular_file;
4464 +
4465 + mutex_lock(&isp->video_lock);
4466 +
4467 +- if (v4l2_fh_is_singular_file(file) && ivc->streaming) {
4468 ++ is_singular_file = v4l2_fh_is_singular_file(file);
4469 ++
4470 ++ if (is_singular_file && ivc->streaming) {
4471 + media_pipeline_stop(entity);
4472 + ivc->streaming = 0;
4473 + }
4474 +
4475 + _vb2_fop_release(file, NULL);
4476 +
4477 +- if (v4l2_fh_is_singular_file(file)) {
4478 ++ if (is_singular_file) {
4479 + fimc_pipeline_call(&ivc->ve, close);
4480 +
4481 + mutex_lock(&mdev->graph_mutex);
4482 +diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
4483 +index 7c9e2d69e21a0..34bc2949e1d67 100644
4484 +--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
4485 ++++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
4486 +@@ -402,12 +402,12 @@ static int mtk_mdp_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
4487 + struct mtk_mdp_ctx *ctx = q->drv_priv;
4488 + int ret;
4489 +
4490 +- ret = pm_runtime_get_sync(&ctx->mdp_dev->pdev->dev);
4491 ++ ret = pm_runtime_resume_and_get(&ctx->mdp_dev->pdev->dev);
4492 + if (ret < 0)
4493 +- mtk_mdp_dbg(1, "[%d] pm_runtime_get_sync failed:%d",
4494 ++ mtk_mdp_dbg(1, "[%d] pm_runtime_resume_and_get failed:%d",
4495 + ctx->id, ret);
4496 +
4497 +- return 0;
4498 ++ return ret;
4499 + }
4500 +
4501 + static void *mtk_mdp_m2m_buf_remove(struct mtk_mdp_ctx *ctx,
4502 +diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
4503 +index 00d090df11bbe..4cde1a54e7252 100644
4504 +--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
4505 ++++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
4506 +@@ -142,7 +142,9 @@ static int fops_vcodec_open(struct file *file)
4507 + mtk_vcodec_dec_set_default_params(ctx);
4508 +
4509 + if (v4l2_fh_is_singular(&ctx->fh)) {
4510 +- mtk_vcodec_dec_pw_on(&dev->pm);
4511 ++ ret = mtk_vcodec_dec_pw_on(&dev->pm);
4512 ++ if (ret < 0)
4513 ++ goto err_load_fw;
4514 + /*
4515 + * vpu_load_firmware checks if it was loaded already and
4516 + * does nothing in that case
4517 +diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
4518 +index f9bbd0000bf3e..34e9e067de206 100644
4519 +--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
4520 ++++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
4521 +@@ -89,13 +89,15 @@ void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev)
4522 + put_device(dev->pm.larbvdec);
4523 + }
4524 +
4525 +-void mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
4526 ++int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
4527 + {
4528 + int ret;
4529 +
4530 +- ret = pm_runtime_get_sync(pm->dev);
4531 ++ ret = pm_runtime_resume_and_get(pm->dev);
4532 + if (ret)
4533 +- mtk_v4l2_err("pm_runtime_get_sync fail %d", ret);
4534 ++ mtk_v4l2_err("pm_runtime_resume_and_get fail %d", ret);
4535 ++
4536 ++ return ret;
4537 + }
4538 +
4539 + void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm)
4540 +diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
4541 +index 872d8bf8cfaf3..280aeaefdb651 100644
4542 +--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
4543 ++++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
4544 +@@ -12,7 +12,7 @@
4545 + int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *dev);
4546 + void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev);
4547 +
4548 +-void mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm);
4549 ++int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm);
4550 + void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm);
4551 + void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm);
4552 + void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm);
4553 +diff --git a/drivers/media/platform/s5p-cec/s5p_cec.c b/drivers/media/platform/s5p-cec/s5p_cec.c
4554 +index 6ddcc35b0bbda..828792b854f5c 100644
4555 +--- a/drivers/media/platform/s5p-cec/s5p_cec.c
4556 ++++ b/drivers/media/platform/s5p-cec/s5p_cec.c
4557 +@@ -35,10 +35,13 @@ MODULE_PARM_DESC(debug, "debug level (0-2)");
4558 +
4559 + static int s5p_cec_adap_enable(struct cec_adapter *adap, bool enable)
4560 + {
4561 ++ int ret;
4562 + struct s5p_cec_dev *cec = cec_get_drvdata(adap);
4563 +
4564 + if (enable) {
4565 +- pm_runtime_get_sync(cec->dev);
4566 ++ ret = pm_runtime_resume_and_get(cec->dev);
4567 ++ if (ret < 0)
4568 ++ return ret;
4569 +
4570 + s5p_cec_reset(cec);
4571 +
4572 +@@ -51,7 +54,7 @@ static int s5p_cec_adap_enable(struct cec_adapter *adap, bool enable)
4573 + } else {
4574 + s5p_cec_mask_tx_interrupts(cec);
4575 + s5p_cec_mask_rx_interrupts(cec);
4576 +- pm_runtime_disable(cec->dev);
4577 ++ pm_runtime_put(cec->dev);
4578 + }
4579 +
4580 + return 0;
4581 +diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
4582 +index f5f05ea9f5213..6cfc2debfd9a0 100644
4583 +--- a/drivers/media/platform/s5p-g2d/g2d.c
4584 ++++ b/drivers/media/platform/s5p-g2d/g2d.c
4585 +@@ -276,6 +276,9 @@ static int g2d_release(struct file *file)
4586 + struct g2d_dev *dev = video_drvdata(file);
4587 + struct g2d_ctx *ctx = fh2ctx(file->private_data);
4588 +
4589 ++ mutex_lock(&dev->mutex);
4590 ++ v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
4591 ++ mutex_unlock(&dev->mutex);
4592 + v4l2_ctrl_handler_free(&ctx->ctrl_handler);
4593 + v4l2_fh_del(&ctx->fh);
4594 + v4l2_fh_exit(&ctx->fh);
4595 +diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
4596 +index 8dbbd5f2a40a0..06e17946bbb64 100644
4597 +--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
4598 ++++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
4599 +@@ -2579,11 +2579,8 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb)
4600 + static int s5p_jpeg_start_streaming(struct vb2_queue *q, unsigned int count)
4601 + {
4602 + struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(q);
4603 +- int ret;
4604 +-
4605 +- ret = pm_runtime_get_sync(ctx->jpeg->dev);
4606 +
4607 +- return ret > 0 ? 0 : ret;
4608 ++ return pm_runtime_resume_and_get(ctx->jpeg->dev);
4609 + }
4610 +
4611 + static void s5p_jpeg_stop_streaming(struct vb2_queue *q)
4612 +diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
4613 +index 2236702c21b43..84c4b19fb107f 100644
4614 +--- a/drivers/media/platform/sh_vou.c
4615 ++++ b/drivers/media/platform/sh_vou.c
4616 +@@ -1133,7 +1133,11 @@ static int sh_vou_open(struct file *file)
4617 + if (v4l2_fh_is_singular_file(file) &&
4618 + vou_dev->status == SH_VOU_INITIALISING) {
4619 + /* First open */
4620 +- pm_runtime_get_sync(vou_dev->v4l2_dev.dev);
4621 ++ err = pm_runtime_resume_and_get(vou_dev->v4l2_dev.dev);
4622 ++ if (err < 0) {
4623 ++ v4l2_fh_release(file);
4624 ++ goto done_open;
4625 ++ }
4626 + err = sh_vou_hw_init(vou_dev);
4627 + if (err < 0) {
4628 + pm_runtime_put(vou_dev->v4l2_dev.dev);
4629 +diff --git a/drivers/media/platform/sti/bdisp/Makefile b/drivers/media/platform/sti/bdisp/Makefile
4630 +index caf7ccd193eaa..39ade0a347236 100644
4631 +--- a/drivers/media/platform/sti/bdisp/Makefile
4632 ++++ b/drivers/media/platform/sti/bdisp/Makefile
4633 +@@ -1,4 +1,4 @@
4634 + # SPDX-License-Identifier: GPL-2.0-only
4635 +-obj-$(CONFIG_VIDEO_STI_BDISP) := bdisp.o
4636 ++obj-$(CONFIG_VIDEO_STI_BDISP) += bdisp.o
4637 +
4638 + bdisp-objs := bdisp-v4l2.o bdisp-hw.o bdisp-debug.o
4639 +diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
4640 +index a55ddf8d185d5..16a097f93b423 100644
4641 +--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
4642 ++++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
4643 +@@ -499,7 +499,7 @@ static int bdisp_start_streaming(struct vb2_queue *q, unsigned int count)
4644 + {
4645 + struct bdisp_ctx *ctx = q->drv_priv;
4646 + struct vb2_v4l2_buffer *buf;
4647 +- int ret = pm_runtime_get_sync(ctx->bdisp_dev->dev);
4648 ++ int ret = pm_runtime_resume_and_get(ctx->bdisp_dev->dev);
4649 +
4650 + if (ret < 0) {
4651 + dev_err(ctx->bdisp_dev->dev, "failed to set runtime PM\n");
4652 +@@ -1364,10 +1364,10 @@ static int bdisp_probe(struct platform_device *pdev)
4653 +
4654 + /* Power management */
4655 + pm_runtime_enable(dev);
4656 +- ret = pm_runtime_get_sync(dev);
4657 ++ ret = pm_runtime_resume_and_get(dev);
4658 + if (ret < 0) {
4659 + dev_err(dev, "failed to set PM\n");
4660 +- goto err_pm;
4661 ++ goto err_remove;
4662 + }
4663 +
4664 + /* Filters */
4665 +@@ -1395,6 +1395,7 @@ err_filter:
4666 + bdisp_hw_free_filters(bdisp->dev);
4667 + err_pm:
4668 + pm_runtime_put(dev);
4669 ++err_remove:
4670 + bdisp_debugfs_remove(bdisp);
4671 + err_v4l2:
4672 + v4l2_device_unregister(&bdisp->v4l2_dev);
4673 +diff --git a/drivers/media/platform/sti/delta/Makefile b/drivers/media/platform/sti/delta/Makefile
4674 +index 92b37e216f004..32412fa4c6328 100644
4675 +--- a/drivers/media/platform/sti/delta/Makefile
4676 ++++ b/drivers/media/platform/sti/delta/Makefile
4677 +@@ -1,5 +1,5 @@
4678 + # SPDX-License-Identifier: GPL-2.0-only
4679 +-obj-$(CONFIG_VIDEO_STI_DELTA_DRIVER) := st-delta.o
4680 ++obj-$(CONFIG_VIDEO_STI_DELTA_DRIVER) += st-delta.o
4681 + st-delta-y := delta-v4l2.o delta-mem.o delta-ipc.o delta-debug.o
4682 +
4683 + # MJPEG support
4684 +diff --git a/drivers/media/platform/sti/hva/Makefile b/drivers/media/platform/sti/hva/Makefile
4685 +index 74b41ec52f976..b5a5478bdd016 100644
4686 +--- a/drivers/media/platform/sti/hva/Makefile
4687 ++++ b/drivers/media/platform/sti/hva/Makefile
4688 +@@ -1,4 +1,4 @@
4689 + # SPDX-License-Identifier: GPL-2.0-only
4690 +-obj-$(CONFIG_VIDEO_STI_HVA) := st-hva.o
4691 ++obj-$(CONFIG_VIDEO_STI_HVA) += st-hva.o
4692 + st-hva-y := hva-v4l2.o hva-hw.o hva-mem.o hva-h264.o
4693 + st-hva-$(CONFIG_VIDEO_STI_HVA_DEBUGFS) += hva-debugfs.o
4694 +diff --git a/drivers/media/platform/sti/hva/hva-hw.c b/drivers/media/platform/sti/hva/hva-hw.c
4695 +index 43f279e2a6a38..cf4c891bf619a 100644
4696 +--- a/drivers/media/platform/sti/hva/hva-hw.c
4697 ++++ b/drivers/media/platform/sti/hva/hva-hw.c
4698 +@@ -130,8 +130,7 @@ static irqreturn_t hva_hw_its_irq_thread(int irq, void *arg)
4699 + ctx_id = (hva->sts_reg & 0xFF00) >> 8;
4700 + if (ctx_id >= HVA_MAX_INSTANCES) {
4701 + dev_err(dev, "%s %s: bad context identifier: %d\n",
4702 +- ctx->name, __func__, ctx_id);
4703 +- ctx->hw_err = true;
4704 ++ HVA_PREFIX, __func__, ctx_id);
4705 + goto out;
4706 + }
4707 +
4708 +diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
4709 +index a8a72d5fbd129..caefac07af927 100644
4710 +--- a/drivers/media/usb/au0828/au0828-core.c
4711 ++++ b/drivers/media/usb/au0828/au0828-core.c
4712 +@@ -199,8 +199,8 @@ static int au0828_media_device_init(struct au0828_dev *dev,
4713 + struct media_device *mdev;
4714 +
4715 + mdev = media_device_usb_allocate(udev, KBUILD_MODNAME, THIS_MODULE);
4716 +- if (!mdev)
4717 +- return -ENOMEM;
4718 ++ if (IS_ERR(mdev))
4719 ++ return PTR_ERR(mdev);
4720 +
4721 + dev->media_dev = mdev;
4722 + #endif
4723 +diff --git a/drivers/media/usb/cpia2/cpia2.h b/drivers/media/usb/cpia2/cpia2.h
4724 +index 50835f5f7512c..57b7f1ea68da5 100644
4725 +--- a/drivers/media/usb/cpia2/cpia2.h
4726 ++++ b/drivers/media/usb/cpia2/cpia2.h
4727 +@@ -429,6 +429,7 @@ int cpia2_send_command(struct camera_data *cam, struct cpia2_command *cmd);
4728 + int cpia2_do_command(struct camera_data *cam,
4729 + unsigned int command,
4730 + unsigned char direction, unsigned char param);
4731 ++void cpia2_deinit_camera_struct(struct camera_data *cam, struct usb_interface *intf);
4732 + struct camera_data *cpia2_init_camera_struct(struct usb_interface *intf);
4733 + int cpia2_init_camera(struct camera_data *cam);
4734 + int cpia2_allocate_buffers(struct camera_data *cam);
4735 +diff --git a/drivers/media/usb/cpia2/cpia2_core.c b/drivers/media/usb/cpia2/cpia2_core.c
4736 +index 20c50c2d042e6..f8c6e0b211a51 100644
4737 +--- a/drivers/media/usb/cpia2/cpia2_core.c
4738 ++++ b/drivers/media/usb/cpia2/cpia2_core.c
4739 +@@ -2163,6 +2163,18 @@ static void reset_camera_struct(struct camera_data *cam)
4740 + cam->height = cam->params.roi.height;
4741 + }
4742 +
4743 ++/******************************************************************************
4744 ++ *
4745 ++ * cpia2_init_camera_struct
4746 ++ *
4747 ++ * Deinitialize camera struct
4748 ++ *****************************************************************************/
4749 ++void cpia2_deinit_camera_struct(struct camera_data *cam, struct usb_interface *intf)
4750 ++{
4751 ++ v4l2_device_unregister(&cam->v4l2_dev);
4752 ++ kfree(cam);
4753 ++}
4754 ++
4755 + /******************************************************************************
4756 + *
4757 + * cpia2_init_camera_struct
4758 +diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
4759 +index 3ab80a7b44985..76aac06f9fb8e 100644
4760 +--- a/drivers/media/usb/cpia2/cpia2_usb.c
4761 ++++ b/drivers/media/usb/cpia2/cpia2_usb.c
4762 +@@ -844,15 +844,13 @@ static int cpia2_usb_probe(struct usb_interface *intf,
4763 + ret = set_alternate(cam, USBIF_CMDONLY);
4764 + if (ret < 0) {
4765 + ERR("%s: usb_set_interface error (ret = %d)\n", __func__, ret);
4766 +- kfree(cam);
4767 +- return ret;
4768 ++ goto alt_err;
4769 + }
4770 +
4771 +
4772 + if((ret = cpia2_init_camera(cam)) < 0) {
4773 + ERR("%s: failed to initialize cpia2 camera (ret = %d)\n", __func__, ret);
4774 +- kfree(cam);
4775 +- return ret;
4776 ++ goto alt_err;
4777 + }
4778 + LOG(" CPiA Version: %d.%02d (%d.%d)\n",
4779 + cam->params.version.firmware_revision_hi,
4780 +@@ -872,11 +870,14 @@ static int cpia2_usb_probe(struct usb_interface *intf,
4781 + ret = cpia2_register_camera(cam);
4782 + if (ret < 0) {
4783 + ERR("%s: Failed to register cpia2 camera (ret = %d)\n", __func__, ret);
4784 +- kfree(cam);
4785 +- return ret;
4786 ++ goto alt_err;
4787 + }
4788 +
4789 + return 0;
4790 ++
4791 ++alt_err:
4792 ++ cpia2_deinit_camera_struct(cam, intf);
4793 ++ return ret;
4794 + }
4795 +
4796 + /******************************************************************************
4797 +diff --git a/drivers/media/usb/dvb-usb/cinergyT2-core.c b/drivers/media/usb/dvb-usb/cinergyT2-core.c
4798 +index 969a7ec71dff7..4116ba5c45fcb 100644
4799 +--- a/drivers/media/usb/dvb-usb/cinergyT2-core.c
4800 ++++ b/drivers/media/usb/dvb-usb/cinergyT2-core.c
4801 +@@ -78,6 +78,8 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
4802 +
4803 + ret = dvb_usb_generic_rw(d, st->data, 1, st->data, 3, 0);
4804 + if (ret < 0) {
4805 ++ if (adap->fe_adap[0].fe)
4806 ++ adap->fe_adap[0].fe->ops.release(adap->fe_adap[0].fe);
4807 + deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep state info\n");
4808 + }
4809 + mutex_unlock(&d->data_mutex);
4810 +diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
4811 +index fac19ec460895..06bd827ef4619 100644
4812 +--- a/drivers/media/usb/dvb-usb/cxusb.c
4813 ++++ b/drivers/media/usb/dvb-usb/cxusb.c
4814 +@@ -1950,7 +1950,7 @@ static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
4815 +
4816 + .size_of_priv = sizeof(struct cxusb_state),
4817 +
4818 +- .num_adapters = 2,
4819 ++ .num_adapters = 1,
4820 + .adapter = {
4821 + {
4822 + .num_frontends = 1,
4823 +diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
4824 +index 5aa15a7a49def..59529cbf9cd0b 100644
4825 +--- a/drivers/media/usb/em28xx/em28xx-input.c
4826 ++++ b/drivers/media/usb/em28xx/em28xx-input.c
4827 +@@ -720,7 +720,8 @@ static int em28xx_ir_init(struct em28xx *dev)
4828 + dev->board.has_ir_i2c = 0;
4829 + dev_warn(&dev->intf->dev,
4830 + "No i2c IR remote control device found.\n");
4831 +- return -ENODEV;
4832 ++ err = -ENODEV;
4833 ++ goto ref_put;
4834 + }
4835 + }
4836 +
4837 +@@ -735,7 +736,7 @@ static int em28xx_ir_init(struct em28xx *dev)
4838 +
4839 + ir = kzalloc(sizeof(*ir), GFP_KERNEL);
4840 + if (!ir)
4841 +- return -ENOMEM;
4842 ++ goto ref_put;
4843 + rc = rc_allocate_device(RC_DRIVER_SCANCODE);
4844 + if (!rc)
4845 + goto error;
4846 +@@ -839,6 +840,9 @@ error:
4847 + dev->ir = NULL;
4848 + rc_free_device(rc);
4849 + kfree(ir);
4850 ++ref_put:
4851 ++ em28xx_shutdown_buttons(dev);
4852 ++ kref_put(&dev->ref, em28xx_free_device);
4853 + return err;
4854 + }
4855 +
4856 +diff --git a/drivers/media/usb/gspca/gl860/gl860.c b/drivers/media/usb/gspca/gl860/gl860.c
4857 +index 2c05ea2598e76..ce4ee8bc75c85 100644
4858 +--- a/drivers/media/usb/gspca/gl860/gl860.c
4859 ++++ b/drivers/media/usb/gspca/gl860/gl860.c
4860 +@@ -561,8 +561,8 @@ int gl860_RTx(struct gspca_dev *gspca_dev,
4861 + len, 400 + 200 * (len > 1));
4862 + memcpy(pdata, gspca_dev->usb_buf, len);
4863 + } else {
4864 +- r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
4865 +- req, pref, val, index, NULL, len, 400);
4866 ++ gspca_err(gspca_dev, "zero-length read request\n");
4867 ++ r = -EINVAL;
4868 + }
4869 + }
4870 +
4871 +diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
4872 +index 1cfb7cf64131a..4c991eae53cdf 100644
4873 +--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
4874 ++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
4875 +@@ -2677,9 +2677,8 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
4876 + pvr2_stream_destroy(hdw->vid_stream);
4877 + hdw->vid_stream = NULL;
4878 + }
4879 +- pvr2_i2c_core_done(hdw);
4880 + v4l2_device_unregister(&hdw->v4l2_dev);
4881 +- pvr2_hdw_remove_usb_stuff(hdw);
4882 ++ pvr2_hdw_disconnect(hdw);
4883 + mutex_lock(&pvr2_unit_mtx);
4884 + do {
4885 + if ((hdw->unit_number >= 0) &&
4886 +@@ -2706,6 +2705,7 @@ void pvr2_hdw_disconnect(struct pvr2_hdw *hdw)
4887 + {
4888 + pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_disconnect(hdw=%p)",hdw);
4889 + LOCK_TAKE(hdw->big_lock);
4890 ++ pvr2_i2c_core_done(hdw);
4891 + LOCK_TAKE(hdw->ctl_lock);
4892 + pvr2_hdw_remove_usb_stuff(hdw);
4893 + LOCK_GIVE(hdw->ctl_lock);
4894 +diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
4895 +index 684574f58e82d..90eec79ee995a 100644
4896 +--- a/drivers/media/v4l2-core/v4l2-fh.c
4897 ++++ b/drivers/media/v4l2-core/v4l2-fh.c
4898 +@@ -96,6 +96,7 @@ int v4l2_fh_release(struct file *filp)
4899 + v4l2_fh_del(fh);
4900 + v4l2_fh_exit(fh);
4901 + kfree(fh);
4902 ++ filp->private_data = NULL;
4903 + }
4904 + return 0;
4905 + }
4906 +diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c
4907 +index 102dbb8080da5..29271ad4728a2 100644
4908 +--- a/drivers/memstick/host/rtsx_usb_ms.c
4909 ++++ b/drivers/memstick/host/rtsx_usb_ms.c
4910 +@@ -799,9 +799,9 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)
4911 +
4912 + return 0;
4913 + err_out:
4914 +- memstick_free_host(msh);
4915 + pm_runtime_disable(ms_dev(host));
4916 + pm_runtime_put_noidle(ms_dev(host));
4917 ++ memstick_free_host(msh);
4918 + return err;
4919 + }
4920 +
4921 +@@ -828,9 +828,6 @@ static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)
4922 + }
4923 + mutex_unlock(&host->host_mutex);
4924 +
4925 +- memstick_remove_host(msh);
4926 +- memstick_free_host(msh);
4927 +-
4928 + /* Balance possible unbalanced usage count
4929 + * e.g. unconditional module removal
4930 + */
4931 +@@ -838,10 +835,11 @@ static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)
4932 + pm_runtime_put(ms_dev(host));
4933 +
4934 + pm_runtime_disable(ms_dev(host));
4935 +- platform_set_drvdata(pdev, NULL);
4936 +-
4937 ++ memstick_remove_host(msh);
4938 + dev_dbg(ms_dev(host),
4939 + ": Realtek USB Memstick controller has been removed\n");
4940 ++ memstick_free_host(msh);
4941 ++ platform_set_drvdata(pdev, NULL);
4942 +
4943 + return 0;
4944 + }
4945 +diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
4946 +index 81c70e5bc168f..3e4a594c110b3 100644
4947 +--- a/drivers/misc/eeprom/idt_89hpesx.c
4948 ++++ b/drivers/misc/eeprom/idt_89hpesx.c
4949 +@@ -1126,11 +1126,10 @@ static void idt_get_fw_data(struct idt_89hpesx_dev *pdev)
4950 +
4951 + device_for_each_child_node(dev, fwnode) {
4952 + ee_id = idt_ee_match_id(fwnode);
4953 +- if (!ee_id) {
4954 +- dev_warn(dev, "Skip unsupported EEPROM device");
4955 +- continue;
4956 +- } else
4957 ++ if (ee_id)
4958 + break;
4959 ++
4960 ++ dev_warn(dev, "Skip unsupported EEPROM device %pfw\n", fwnode);
4961 + }
4962 +
4963 + /* If there is no fwnode EEPROM device, then set zero size */
4964 +@@ -1161,6 +1160,7 @@ static void idt_get_fw_data(struct idt_89hpesx_dev *pdev)
4965 + else /* if (!fwnode_property_read_bool(node, "read-only")) */
4966 + pdev->eero = false;
4967 +
4968 ++ fwnode_handle_put(fwnode);
4969 + dev_info(dev, "EEPROM of %d bytes found by 0x%x",
4970 + pdev->eesize, pdev->eeaddr);
4971 + }
4972 +diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
4973 +index 39f2864455a60..8322d22a59c45 100644
4974 +--- a/drivers/mmc/core/block.c
4975 ++++ b/drivers/mmc/core/block.c
4976 +@@ -1053,6 +1053,12 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
4977 +
4978 + switch (mq_rq->drv_op) {
4979 + case MMC_DRV_OP_IOCTL:
4980 ++ if (card->ext_csd.cmdq_en) {
4981 ++ ret = mmc_cmdq_disable(card);
4982 ++ if (ret)
4983 ++ break;
4984 ++ }
4985 ++ fallthrough;
4986 + case MMC_DRV_OP_IOCTL_RPMB:
4987 + idata = mq_rq->drv_op_data;
4988 + for (i = 0, ret = 0; i < mq_rq->ioc_count; i++) {
4989 +@@ -1063,6 +1069,8 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
4990 + /* Always switch back to main area after RPMB access */
4991 + if (rpmb_ioctl)
4992 + mmc_blk_part_switch(card, 0);
4993 ++ else if (card->reenable_cmdq && !card->ext_csd.cmdq_en)
4994 ++ mmc_cmdq_enable(card);
4995 + break;
4996 + case MMC_DRV_OP_BOOT_WP:
4997 + ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP,
4998 +diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
4999 +index 10705e5fa90ee..a999d2089d3de 100644
5000 +--- a/drivers/mmc/host/sdhci-sprd.c
5001 ++++ b/drivers/mmc/host/sdhci-sprd.c
5002 +@@ -382,6 +382,7 @@ static unsigned int sdhci_sprd_get_ro(struct sdhci_host *host)
5003 + static struct sdhci_ops sdhci_sprd_ops = {
5004 + .read_l = sdhci_sprd_readl,
5005 + .write_l = sdhci_sprd_writel,
5006 ++ .write_w = sdhci_sprd_writew,
5007 + .write_b = sdhci_sprd_writeb,
5008 + .set_clock = sdhci_sprd_set_clock,
5009 + .get_max_clock = sdhci_sprd_get_max_clock,
5010 +diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
5011 +index 6eba2441c7efd..96b0f81a20322 100644
5012 +--- a/drivers/mmc/host/usdhi6rol0.c
5013 ++++ b/drivers/mmc/host/usdhi6rol0.c
5014 +@@ -1803,6 +1803,7 @@ static int usdhi6_probe(struct platform_device *pdev)
5015 +
5016 + version = usdhi6_read(host, USDHI6_VERSION);
5017 + if ((version & 0xfff) != 0xa0d) {
5018 ++ ret = -EPERM;
5019 + dev_err(dev, "Version not recognized %x\n", version);
5020 + goto e_clk_off;
5021 + }
5022 +diff --git a/drivers/mmc/host/via-sdmmc.c b/drivers/mmc/host/via-sdmmc.c
5023 +index d12a068b0f9ed..721e5dd1eb7de 100644
5024 +--- a/drivers/mmc/host/via-sdmmc.c
5025 ++++ b/drivers/mmc/host/via-sdmmc.c
5026 +@@ -857,6 +857,9 @@ static void via_sdc_data_isr(struct via_crdr_mmc_host *host, u16 intmask)
5027 + {
5028 + BUG_ON(intmask == 0);
5029 +
5030 ++ if (!host->data)
5031 ++ return;
5032 ++
5033 + if (intmask & VIA_CRDR_SDSTS_DT)
5034 + host->data->error = -ETIMEDOUT;
5035 + else if (intmask & (VIA_CRDR_SDSTS_RC | VIA_CRDR_SDSTS_WC))
5036 +diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c
5037 +index a3680c9006892..156046e56a584 100644
5038 +--- a/drivers/mmc/host/vub300.c
5039 ++++ b/drivers/mmc/host/vub300.c
5040 +@@ -2286,7 +2286,7 @@ static int vub300_probe(struct usb_interface *interface,
5041 + if (retval < 0)
5042 + goto error5;
5043 + retval =
5044 +- usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0),
5045 ++ usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
5046 + SET_ROM_WAIT_STATES,
5047 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
5048 + firmware_rom_wait_states, 0x0000, NULL, 0, HZ);
5049 +diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
5050 +index ee4afa17d8a3a..ef163ff1edf76 100644
5051 +--- a/drivers/mtd/nand/raw/marvell_nand.c
5052 ++++ b/drivers/mtd/nand/raw/marvell_nand.c
5053 +@@ -2980,8 +2980,10 @@ static int __maybe_unused marvell_nfc_resume(struct device *dev)
5054 + return ret;
5055 +
5056 + ret = clk_prepare_enable(nfc->reg_clk);
5057 +- if (ret < 0)
5058 ++ if (ret < 0) {
5059 ++ clk_disable_unprepare(nfc->core_clk);
5060 + return ret;
5061 ++ }
5062 +
5063 + /*
5064 + * Reset nfc->selected_chip so the next command will cause the timing
5065 +diff --git a/drivers/mtd/parsers/redboot.c b/drivers/mtd/parsers/redboot.c
5066 +index 91146bdc47132..3ccd6363ee8cb 100644
5067 +--- a/drivers/mtd/parsers/redboot.c
5068 ++++ b/drivers/mtd/parsers/redboot.c
5069 +@@ -45,6 +45,7 @@ static inline int redboot_checksum(struct fis_image_desc *img)
5070 + static void parse_redboot_of(struct mtd_info *master)
5071 + {
5072 + struct device_node *np;
5073 ++ struct device_node *npart;
5074 + u32 dirblock;
5075 + int ret;
5076 +
5077 +@@ -52,7 +53,11 @@ static void parse_redboot_of(struct mtd_info *master)
5078 + if (!np)
5079 + return;
5080 +
5081 +- ret = of_property_read_u32(np, "fis-index-block", &dirblock);
5082 ++ npart = of_get_child_by_name(np, "partitions");
5083 ++ if (!npart)
5084 ++ return;
5085 ++
5086 ++ ret = of_property_read_u32(npart, "fis-index-block", &dirblock);
5087 + if (ret)
5088 + return;
5089 +
5090 +diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c
5091 +index 91b156b2123a3..d0bdcc43b8eeb 100644
5092 +--- a/drivers/net/can/peak_canfd/peak_canfd.c
5093 ++++ b/drivers/net/can/peak_canfd/peak_canfd.c
5094 +@@ -338,8 +338,8 @@ static int pucan_handle_status(struct peak_canfd_priv *priv,
5095 + return err;
5096 + }
5097 +
5098 +- /* start network queue (echo_skb array is empty) */
5099 +- netif_start_queue(ndev);
5100 ++ /* wake network queue up (echo_skb array is empty) */
5101 ++ netif_wake_queue(ndev);
5102 +
5103 + return 0;
5104 + }
5105 +diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
5106 +index 4f52810bebf89..db9f15f17610b 100644
5107 +--- a/drivers/net/can/usb/ems_usb.c
5108 ++++ b/drivers/net/can/usb/ems_usb.c
5109 +@@ -1053,7 +1053,6 @@ static void ems_usb_disconnect(struct usb_interface *intf)
5110 +
5111 + if (dev) {
5112 + unregister_netdev(dev->netdev);
5113 +- free_candev(dev->netdev);
5114 +
5115 + unlink_all_urbs(dev);
5116 +
5117 +@@ -1061,6 +1060,8 @@ static void ems_usb_disconnect(struct usb_interface *intf)
5118 +
5119 + kfree(dev->intr_in_buffer);
5120 + kfree(dev->tx_msg_buffer);
5121 ++
5122 ++ free_candev(dev->netdev);
5123 + }
5124 + }
5125 +
5126 +diff --git a/drivers/net/ethernet/aeroflex/greth.c b/drivers/net/ethernet/aeroflex/greth.c
5127 +index 2a9f8643629c0..907904c0a2888 100644
5128 +--- a/drivers/net/ethernet/aeroflex/greth.c
5129 ++++ b/drivers/net/ethernet/aeroflex/greth.c
5130 +@@ -1541,10 +1541,11 @@ static int greth_of_remove(struct platform_device *of_dev)
5131 + mdiobus_unregister(greth->mdio);
5132 +
5133 + unregister_netdev(ndev);
5134 +- free_netdev(ndev);
5135 +
5136 + of_iounmap(&of_dev->resource[0], greth->regs, resource_size(&of_dev->resource[0]));
5137 +
5138 ++ free_netdev(ndev);
5139 ++
5140 + return 0;
5141 + }
5142 +
5143 +diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
5144 +index b27da024aa9d9..21669a42718c8 100644
5145 +--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
5146 ++++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
5147 +@@ -3741,3 +3741,4 @@ MODULE_AUTHOR("Broadcom Corporation");
5148 + MODULE_DESCRIPTION("Broadcom GENET Ethernet controller driver");
5149 + MODULE_ALIAS("platform:bcmgenet");
5150 + MODULE_LICENSE("GPL");
5151 ++MODULE_SOFTDEP("pre: mdio-bcm-unimac");
5152 +diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
5153 +index 701c12c9e0337..649c5c429bd7c 100644
5154 +--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
5155 ++++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
5156 +@@ -550,7 +550,7 @@ int be_process_mcc(struct be_adapter *adapter)
5157 + int num = 0, status = 0;
5158 + struct be_mcc_obj *mcc_obj = &adapter->mcc_obj;
5159 +
5160 +- spin_lock_bh(&adapter->mcc_cq_lock);
5161 ++ spin_lock(&adapter->mcc_cq_lock);
5162 +
5163 + while ((compl = be_mcc_compl_get(adapter))) {
5164 + if (compl->flags & CQE_FLAGS_ASYNC_MASK) {
5165 +@@ -566,7 +566,7 @@ int be_process_mcc(struct be_adapter *adapter)
5166 + if (num)
5167 + be_cq_notify(adapter, mcc_obj->cq.id, mcc_obj->rearm_cq, num);
5168 +
5169 +- spin_unlock_bh(&adapter->mcc_cq_lock);
5170 ++ spin_unlock(&adapter->mcc_cq_lock);
5171 + return status;
5172 + }
5173 +
5174 +@@ -581,7 +581,9 @@ static int be_mcc_wait_compl(struct be_adapter *adapter)
5175 + if (be_check_error(adapter, BE_ERROR_ANY))
5176 + return -EIO;
5177 +
5178 ++ local_bh_disable();
5179 + status = be_process_mcc(adapter);
5180 ++ local_bh_enable();
5181 +
5182 + if (atomic_read(&mcc_obj->q.used) == 0)
5183 + break;
5184 +diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
5185 +index 9aebb121365f5..552877590a8ab 100644
5186 +--- a/drivers/net/ethernet/emulex/benet/be_main.c
5187 ++++ b/drivers/net/ethernet/emulex/benet/be_main.c
5188 +@@ -5631,7 +5631,9 @@ static void be_worker(struct work_struct *work)
5189 + * mcc completions
5190 + */
5191 + if (!netif_running(adapter->netdev)) {
5192 ++ local_bh_disable();
5193 + be_process_mcc(adapter);
5194 ++ local_bh_enable();
5195 + goto reschedule;
5196 + }
5197 +
5198 +diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c
5199 +index 815fb62c4b02e..3d74401b4f102 100644
5200 +--- a/drivers/net/ethernet/ezchip/nps_enet.c
5201 ++++ b/drivers/net/ethernet/ezchip/nps_enet.c
5202 +@@ -610,7 +610,7 @@ static s32 nps_enet_probe(struct platform_device *pdev)
5203 +
5204 + /* Get IRQ number */
5205 + priv->irq = platform_get_irq(pdev, 0);
5206 +- if (!priv->irq) {
5207 ++ if (priv->irq < 0) {
5208 + dev_err(dev, "failed to retrieve <irq Rx-Tx> value from device tree\n");
5209 + err = -ENODEV;
5210 + goto out_netdev;
5211 +@@ -645,8 +645,8 @@ static s32 nps_enet_remove(struct platform_device *pdev)
5212 + struct nps_enet_priv *priv = netdev_priv(ndev);
5213 +
5214 + unregister_netdev(ndev);
5215 +- free_netdev(ndev);
5216 + netif_napi_del(&priv->napi);
5217 ++ free_netdev(ndev);
5218 +
5219 + return 0;
5220 + }
5221 +diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
5222 +index 4050f81f788c3..2c06cdcd3e751 100644
5223 +--- a/drivers/net/ethernet/faraday/ftgmac100.c
5224 ++++ b/drivers/net/ethernet/faraday/ftgmac100.c
5225 +@@ -1821,14 +1821,17 @@ static int ftgmac100_probe(struct platform_device *pdev)
5226 + if (np && of_get_property(np, "use-ncsi", NULL)) {
5227 + if (!IS_ENABLED(CONFIG_NET_NCSI)) {
5228 + dev_err(&pdev->dev, "NCSI stack not enabled\n");
5229 ++ err = -EINVAL;
5230 + goto err_ncsi_dev;
5231 + }
5232 +
5233 + dev_info(&pdev->dev, "Using NCSI interface\n");
5234 + priv->use_ncsi = true;
5235 + priv->ndev = ncsi_register_dev(netdev, ftgmac100_ncsi_handler);
5236 +- if (!priv->ndev)
5237 ++ if (!priv->ndev) {
5238 ++ err = -EINVAL;
5239 + goto err_ncsi_dev;
5240 ++ }
5241 + } else if (np && of_get_property(np, "phy-handle", NULL)) {
5242 + struct phy_device *phy;
5243 +
5244 +@@ -1836,6 +1839,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
5245 + &ftgmac100_adjust_link);
5246 + if (!phy) {
5247 + dev_err(&pdev->dev, "Failed to connect to phy\n");
5248 ++ err = -EINVAL;
5249 + goto err_setup_mdio;
5250 + }
5251 +
5252 +diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
5253 +index 6ea0975d74a1f..1c4b35b1b3590 100644
5254 +--- a/drivers/net/ethernet/google/gve/gve_main.c
5255 ++++ b/drivers/net/ethernet/google/gve/gve_main.c
5256 +@@ -1118,8 +1118,8 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
5257 +
5258 + gve_write_version(&reg_bar->driver_version);
5259 + /* Get max queues to alloc etherdev */
5260 +- max_rx_queues = ioread32be(&reg_bar->max_tx_queues);
5261 +- max_tx_queues = ioread32be(&reg_bar->max_rx_queues);
5262 ++ max_tx_queues = ioread32be(&reg_bar->max_tx_queues);
5263 ++ max_rx_queues = ioread32be(&reg_bar->max_rx_queues);
5264 + /* Alloc and setup the netdev and priv */
5265 + dev = alloc_etherdev_mqs(sizeof(*priv), max_tx_queues, max_rx_queues);
5266 + if (!dev) {
5267 +diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c
5268 +index 13e30eba5349e..1fd2b84e2e912 100644
5269 +--- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
5270 ++++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
5271 +@@ -2617,10 +2617,8 @@ static int ehea_restart_qps(struct net_device *dev)
5272 + u16 dummy16 = 0;
5273 +
5274 + cb0 = (void *)get_zeroed_page(GFP_KERNEL);
5275 +- if (!cb0) {
5276 +- ret = -ENOMEM;
5277 +- goto out;
5278 +- }
5279 ++ if (!cb0)
5280 ++ return -ENOMEM;
5281 +
5282 + for (i = 0; i < (port->num_def_qps); i++) {
5283 + struct ehea_port_res *pr = &port->port_res[i];
5284 +@@ -2640,6 +2638,7 @@ static int ehea_restart_qps(struct net_device *dev)
5285 + cb0);
5286 + if (hret != H_SUCCESS) {
5287 + netdev_err(dev, "query_ehea_qp failed (1)\n");
5288 ++ ret = -EFAULT;
5289 + goto out;
5290 + }
5291 +
5292 +@@ -2652,6 +2651,7 @@ static int ehea_restart_qps(struct net_device *dev)
5293 + &dummy64, &dummy16, &dummy16);
5294 + if (hret != H_SUCCESS) {
5295 + netdev_err(dev, "modify_ehea_qp failed (1)\n");
5296 ++ ret = -EFAULT;
5297 + goto out;
5298 + }
5299 +
5300 +@@ -2660,6 +2660,7 @@ static int ehea_restart_qps(struct net_device *dev)
5301 + cb0);
5302 + if (hret != H_SUCCESS) {
5303 + netdev_err(dev, "query_ehea_qp failed (2)\n");
5304 ++ ret = -EFAULT;
5305 + goto out;
5306 + }
5307 +
5308 +diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
5309 +index a2b7b982ee290..ecfe588f330ef 100644
5310 +--- a/drivers/net/ethernet/ibm/ibmvnic.c
5311 ++++ b/drivers/net/ethernet/ibm/ibmvnic.c
5312 +@@ -694,8 +694,11 @@ static int init_tx_pools(struct net_device *netdev)
5313 +
5314 + adapter->tso_pool = kcalloc(tx_subcrqs,
5315 + sizeof(struct ibmvnic_tx_pool), GFP_KERNEL);
5316 +- if (!adapter->tso_pool)
5317 ++ if (!adapter->tso_pool) {
5318 ++ kfree(adapter->tx_pool);
5319 ++ adapter->tx_pool = NULL;
5320 + return -1;
5321 ++ }
5322 +
5323 + adapter->num_active_tx_pools = tx_subcrqs;
5324 +
5325 +@@ -1088,6 +1091,11 @@ static int __ibmvnic_open(struct net_device *netdev)
5326 +
5327 + netif_tx_start_all_queues(netdev);
5328 +
5329 ++ if (prev_state == VNIC_CLOSED) {
5330 ++ for (i = 0; i < adapter->req_rx_queues; i++)
5331 ++ napi_schedule(&adapter->napi[i]);
5332 ++ }
5333 ++
5334 + adapter->state = VNIC_OPEN;
5335 + return rc;
5336 + }
5337 +diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
5338 +index c2feedfd321dc..a06d514215ede 100644
5339 +--- a/drivers/net/ethernet/intel/e1000e/netdev.c
5340 ++++ b/drivers/net/ethernet/intel/e1000e/netdev.c
5341 +@@ -5199,18 +5199,20 @@ static void e1000_watchdog_task(struct work_struct *work)
5342 + pm_runtime_resume(netdev->dev.parent);
5343 +
5344 + /* Checking if MAC is in DMoff state*/
5345 +- pcim_state = er32(STATUS);
5346 +- while (pcim_state & E1000_STATUS_PCIM_STATE) {
5347 +- if (tries++ == dmoff_exit_timeout) {
5348 +- e_dbg("Error in exiting dmoff\n");
5349 +- break;
5350 +- }
5351 +- usleep_range(10000, 20000);
5352 ++ if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID) {
5353 + pcim_state = er32(STATUS);
5354 +-
5355 +- /* Checking if MAC exited DMoff state */
5356 +- if (!(pcim_state & E1000_STATUS_PCIM_STATE))
5357 +- e1000_phy_hw_reset(&adapter->hw);
5358 ++ while (pcim_state & E1000_STATUS_PCIM_STATE) {
5359 ++ if (tries++ == dmoff_exit_timeout) {
5360 ++ e_dbg("Error in exiting dmoff\n");
5361 ++ break;
5362 ++ }
5363 ++ usleep_range(10000, 20000);
5364 ++ pcim_state = er32(STATUS);
5365 ++
5366 ++ /* Checking if MAC exited DMoff state */
5367 ++ if (!(pcim_state & E1000_STATUS_PCIM_STATE))
5368 ++ e1000_phy_hw_reset(&adapter->hw);
5369 ++ }
5370 + }
5371 +
5372 + /* update snapshot of PHY registers on LSC */
5373 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
5374 +index e4d0b7747e84d..2288a3855e522 100644
5375 +--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
5376 ++++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
5377 +@@ -1259,8 +1259,7 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
5378 + if (ethtool_link_ksettings_test_link_mode(&safe_ks,
5379 + supported,
5380 + Autoneg) &&
5381 +- hw->phy.link_info.phy_type !=
5382 +- I40E_PHY_TYPE_10GBASE_T) {
5383 ++ hw->phy.media_type != I40E_MEDIA_TYPE_BASET) {
5384 + netdev_info(netdev, "Autoneg cannot be disabled on this phy\n");
5385 + err = -EINVAL;
5386 + goto done;
5387 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
5388 +index a1b4e995f2b7e..4f4ec1f166ef4 100644
5389 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
5390 ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
5391 +@@ -8292,6 +8292,8 @@ int i40e_vsi_open(struct i40e_vsi *vsi)
5392 + dev_driver_string(&pf->pdev->dev),
5393 + dev_name(&pf->pdev->dev));
5394 + err = i40e_vsi_request_irq(vsi, int_name);
5395 ++ if (err)
5396 ++ goto err_setup_rx;
5397 +
5398 + } else {
5399 + err = -EINVAL;
5400 +diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
5401 +index 491bcfd36ac25..7857ebff92e82 100644
5402 +--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
5403 ++++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
5404 +@@ -5910,6 +5910,8 @@ static int mvpp2_probe(struct platform_device *pdev)
5405 + return 0;
5406 +
5407 + err_port_probe:
5408 ++ fwnode_handle_put(port_fwnode);
5409 ++
5410 + i = 0;
5411 + fwnode_for_each_available_child_node(fwnode, port_fwnode) {
5412 + if (priv->port_list[i])
5413 +diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
5414 +index 18e6d87c607bd..f1269fe4ac721 100644
5415 +--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
5416 ++++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
5417 +@@ -2535,9 +2535,13 @@ static int pch_gbe_probe(struct pci_dev *pdev,
5418 + adapter->pdev = pdev;
5419 + adapter->hw.back = adapter;
5420 + adapter->hw.reg = pcim_iomap_table(pdev)[PCH_GBE_PCI_BAR];
5421 ++
5422 + adapter->pdata = (struct pch_gbe_privdata *)pci_id->driver_data;
5423 +- if (adapter->pdata && adapter->pdata->platform_init)
5424 +- adapter->pdata->platform_init(pdev);
5425 ++ if (adapter->pdata && adapter->pdata->platform_init) {
5426 ++ ret = adapter->pdata->platform_init(pdev);
5427 ++ if (ret)
5428 ++ goto err_free_netdev;
5429 ++ }
5430 +
5431 + adapter->ptp_pdev =
5432 + pci_get_domain_bus_and_slot(pci_domain_nr(adapter->pdev->bus),
5433 +@@ -2632,7 +2636,7 @@ err_free_netdev:
5434 + */
5435 + static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
5436 + {
5437 +- unsigned long flags = GPIOF_DIR_OUT | GPIOF_INIT_HIGH | GPIOF_EXPORT;
5438 ++ unsigned long flags = GPIOF_OUT_INIT_HIGH;
5439 + unsigned gpio = MINNOW_PHY_RESET_GPIO;
5440 + int ret;
5441 +
5442 +diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
5443 +index c20e7ef18bc95..79d74763cf24a 100644
5444 +--- a/drivers/net/ieee802154/mac802154_hwsim.c
5445 ++++ b/drivers/net/ieee802154/mac802154_hwsim.c
5446 +@@ -480,7 +480,7 @@ static int hwsim_del_edge_nl(struct sk_buff *msg, struct genl_info *info)
5447 + struct hwsim_edge *e;
5448 + u32 v0, v1;
5449 +
5450 +- if (!info->attrs[MAC802154_HWSIM_ATTR_RADIO_ID] &&
5451 ++ if (!info->attrs[MAC802154_HWSIM_ATTR_RADIO_ID] ||
5452 + !info->attrs[MAC802154_HWSIM_ATTR_RADIO_EDGE])
5453 + return -EINVAL;
5454 +
5455 +@@ -715,6 +715,8 @@ static int hwsim_subscribe_all_others(struct hwsim_phy *phy)
5456 +
5457 + return 0;
5458 +
5459 ++sub_fail:
5460 ++ hwsim_edge_unsubscribe_me(phy);
5461 + me_fail:
5462 + rcu_read_lock();
5463 + list_for_each_entry_rcu(e, &phy->edges, list) {
5464 +@@ -722,8 +724,6 @@ me_fail:
5465 + hwsim_free_edge(e);
5466 + }
5467 + rcu_read_unlock();
5468 +-sub_fail:
5469 +- hwsim_edge_unsubscribe_me(phy);
5470 + return -ENOMEM;
5471 + }
5472 +
5473 +@@ -824,12 +824,17 @@ err_pib:
5474 + static void hwsim_del(struct hwsim_phy *phy)
5475 + {
5476 + struct hwsim_pib *pib;
5477 ++ struct hwsim_edge *e;
5478 +
5479 + hwsim_edge_unsubscribe_me(phy);
5480 +
5481 + list_del(&phy->list);
5482 +
5483 + rcu_read_lock();
5484 ++ list_for_each_entry_rcu(e, &phy->edges, list) {
5485 ++ list_del_rcu(&e->list);
5486 ++ hwsim_free_edge(e);
5487 ++ }
5488 + pib = rcu_dereference(phy->pib);
5489 + rcu_read_unlock();
5490 +
5491 +diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
5492 +index 1267786d2931b..f08ed52d51f3f 100644
5493 +--- a/drivers/net/vrf.c
5494 ++++ b/drivers/net/vrf.c
5495 +@@ -1035,22 +1035,22 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device *vrf_dev,
5496 + int orig_iif = skb->skb_iif;
5497 + bool need_strict = rt6_need_strict(&ipv6_hdr(skb)->daddr);
5498 + bool is_ndisc = ipv6_ndisc_frame(skb);
5499 +- bool is_ll_src;
5500 +
5501 + /* loopback, multicast & non-ND link-local traffic; do not push through
5502 + * packet taps again. Reset pkt_type for upper layers to process skb.
5503 +- * for packets with lladdr src, however, skip so that the dst can be
5504 +- * determine at input using original ifindex in the case that daddr
5505 +- * needs strict
5506 ++ * For strict packets with a source LLA, determine the dst using the
5507 ++ * original ifindex.
5508 + */
5509 +- is_ll_src = ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL;
5510 +- if (skb->pkt_type == PACKET_LOOPBACK ||
5511 +- (need_strict && !is_ndisc && !is_ll_src)) {
5512 ++ if (skb->pkt_type == PACKET_LOOPBACK || (need_strict && !is_ndisc)) {
5513 + skb->dev = vrf_dev;
5514 + skb->skb_iif = vrf_dev->ifindex;
5515 + IP6CB(skb)->flags |= IP6SKB_L3SLAVE;
5516 ++
5517 + if (skb->pkt_type == PACKET_LOOPBACK)
5518 + skb->pkt_type = PACKET_HOST;
5519 ++ else if (ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)
5520 ++ vrf_ip6_input_dst(skb, vrf_dev, orig_iif);
5521 ++
5522 + goto out;
5523 + }
5524 +
5525 +diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
5526 +index 8443df79fabc7..c5991e31c557e 100644
5527 +--- a/drivers/net/vxlan.c
5528 ++++ b/drivers/net/vxlan.c
5529 +@@ -1995,6 +1995,7 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
5530 + struct neighbour *n;
5531 + struct nd_msg *msg;
5532 +
5533 ++ rcu_read_lock();
5534 + in6_dev = __in6_dev_get(dev);
5535 + if (!in6_dev)
5536 + goto out;
5537 +@@ -2046,6 +2047,7 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
5538 + }
5539 +
5540 + out:
5541 ++ rcu_read_unlock();
5542 + consume_skb(skb);
5543 + return NETDEV_TX_OK;
5544 + }
5545 +diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
5546 +index 47b733fdf4fcb..20e248fd43642 100644
5547 +--- a/drivers/net/wireless/ath/ath10k/mac.c
5548 ++++ b/drivers/net/wireless/ath/ath10k/mac.c
5549 +@@ -5267,6 +5267,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
5550 +
5551 + if (arvif->nohwcrypt &&
5552 + !test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags)) {
5553 ++ ret = -EINVAL;
5554 + ath10k_warn(ar, "cryptmode module param needed for sw crypto\n");
5555 + goto err;
5556 + }
5557 +diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
5558 +index fd49d3419e791..0f055e5777490 100644
5559 +--- a/drivers/net/wireless/ath/ath10k/pci.c
5560 ++++ b/drivers/net/wireless/ath/ath10k/pci.c
5561 +@@ -3647,8 +3647,10 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
5562 + ath10k_pci_soc_read32(ar, SOC_CHIP_ID_ADDRESS);
5563 + if (bus_params.chip_id != 0xffffffff) {
5564 + if (!ath10k_pci_chip_is_supported(pdev->device,
5565 +- bus_params.chip_id))
5566 ++ bus_params.chip_id)) {
5567 ++ ret = -ENODEV;
5568 + goto err_unsupported;
5569 ++ }
5570 + }
5571 + }
5572 +
5573 +@@ -3659,11 +3661,15 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
5574 + }
5575 +
5576 + bus_params.chip_id = ath10k_pci_soc_read32(ar, SOC_CHIP_ID_ADDRESS);
5577 +- if (bus_params.chip_id == 0xffffffff)
5578 ++ if (bus_params.chip_id == 0xffffffff) {
5579 ++ ret = -ENODEV;
5580 + goto err_unsupported;
5581 ++ }
5582 +
5583 +- if (!ath10k_pci_chip_is_supported(pdev->device, bus_params.chip_id))
5584 +- goto err_free_irq;
5585 ++ if (!ath10k_pci_chip_is_supported(pdev->device, bus_params.chip_id)) {
5586 ++ ret = -ENODEV;
5587 ++ goto err_unsupported;
5588 ++ }
5589 +
5590 + ret = ath10k_core_register(ar, &bus_params);
5591 + if (ret) {
5592 +diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
5593 +index bd7e757a0f92d..d14e01da3c312 100644
5594 +--- a/drivers/net/wireless/ath/ath9k/main.c
5595 ++++ b/drivers/net/wireless/ath/ath9k/main.c
5596 +@@ -304,6 +304,11 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan)
5597 + hchan = ah->curchan;
5598 + }
5599 +
5600 ++ if (!hchan) {
5601 ++ fastcc = false;
5602 ++ hchan = ath9k_cmn_get_channel(sc->hw, ah, &sc->cur_chan->chandef);
5603 ++ }
5604 ++
5605 + if (!ath_prepare_reset(sc))
5606 + fastcc = false;
5607 +
5608 +diff --git a/drivers/net/wireless/ath/carl9170/Kconfig b/drivers/net/wireless/ath/carl9170/Kconfig
5609 +index b1bce7aad3999..c2641edab0bcb 100644
5610 +--- a/drivers/net/wireless/ath/carl9170/Kconfig
5611 ++++ b/drivers/net/wireless/ath/carl9170/Kconfig
5612 +@@ -16,13 +16,11 @@ config CARL9170
5613 +
5614 + config CARL9170_LEDS
5615 + bool "SoftLED Support"
5616 +- depends on CARL9170
5617 +- select MAC80211_LEDS
5618 +- select LEDS_CLASS
5619 +- select NEW_LEDS
5620 + default y
5621 ++ depends on CARL9170
5622 ++ depends on MAC80211_LEDS
5623 + help
5624 +- This option is necessary, if you want your device' LEDs to blink
5625 ++ This option is necessary, if you want your device's LEDs to blink.
5626 +
5627 + Say Y, unless you need the LEDs for firmware debugging.
5628 +
5629 +diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
5630 +index 46ae4ec4ad47d..556ba3c6c5d8e 100644
5631 +--- a/drivers/net/wireless/ath/wcn36xx/main.c
5632 ++++ b/drivers/net/wireless/ath/wcn36xx/main.c
5633 +@@ -293,23 +293,16 @@ static int wcn36xx_start(struct ieee80211_hw *hw)
5634 + goto out_free_dxe_pool;
5635 + }
5636 +
5637 +- wcn->hal_buf = kmalloc(WCN36XX_HAL_BUF_SIZE, GFP_KERNEL);
5638 +- if (!wcn->hal_buf) {
5639 +- wcn36xx_err("Failed to allocate smd buf\n");
5640 +- ret = -ENOMEM;
5641 +- goto out_free_dxe_ctl;
5642 +- }
5643 +-
5644 + ret = wcn36xx_smd_load_nv(wcn);
5645 + if (ret) {
5646 + wcn36xx_err("Failed to push NV to chip\n");
5647 +- goto out_free_smd_buf;
5648 ++ goto out_free_dxe_ctl;
5649 + }
5650 +
5651 + ret = wcn36xx_smd_start(wcn);
5652 + if (ret) {
5653 + wcn36xx_err("Failed to start chip\n");
5654 +- goto out_free_smd_buf;
5655 ++ goto out_free_dxe_ctl;
5656 + }
5657 +
5658 + if (!wcn36xx_is_fw_version(wcn, 1, 2, 2, 24)) {
5659 +@@ -336,8 +329,6 @@ static int wcn36xx_start(struct ieee80211_hw *hw)
5660 +
5661 + out_smd_stop:
5662 + wcn36xx_smd_stop(wcn);
5663 +-out_free_smd_buf:
5664 +- kfree(wcn->hal_buf);
5665 + out_free_dxe_ctl:
5666 + wcn36xx_dxe_free_ctl_blks(wcn);
5667 + out_free_dxe_pool:
5668 +@@ -374,8 +365,6 @@ static void wcn36xx_stop(struct ieee80211_hw *hw)
5669 +
5670 + wcn36xx_dxe_free_mem_pools(wcn);
5671 + wcn36xx_dxe_free_ctl_blks(wcn);
5672 +-
5673 +- kfree(wcn->hal_buf);
5674 + }
5675 +
5676 + static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed)
5677 +@@ -1322,6 +1311,12 @@ static int wcn36xx_probe(struct platform_device *pdev)
5678 + mutex_init(&wcn->hal_mutex);
5679 + mutex_init(&wcn->scan_lock);
5680 +
5681 ++ wcn->hal_buf = devm_kmalloc(wcn->dev, WCN36XX_HAL_BUF_SIZE, GFP_KERNEL);
5682 ++ if (!wcn->hal_buf) {
5683 ++ ret = -ENOMEM;
5684 ++ goto out_wq;
5685 ++ }
5686 ++
5687 + ret = dma_set_mask_and_coherent(wcn->dev, DMA_BIT_MASK(32));
5688 + if (ret < 0) {
5689 + wcn36xx_err("failed to set DMA mask: %d\n", ret);
5690 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
5691 +index cd813c69a1781..6439adcd2f995 100644
5692 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
5693 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
5694 +@@ -2612,8 +2612,9 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev,
5695 + struct brcmf_sta_info_le sta_info_le;
5696 + u32 sta_flags;
5697 + u32 is_tdls_peer;
5698 +- s32 total_rssi;
5699 +- s32 count_rssi;
5700 ++ s32 total_rssi_avg = 0;
5701 ++ s32 total_rssi = 0;
5702 ++ s32 count_rssi = 0;
5703 + int rssi;
5704 + u32 i;
5705 +
5706 +@@ -2679,25 +2680,27 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev,
5707 + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES);
5708 + sinfo->rx_bytes = le64_to_cpu(sta_info_le.rx_tot_bytes);
5709 + }
5710 +- total_rssi = 0;
5711 +- count_rssi = 0;
5712 + for (i = 0; i < BRCMF_ANT_MAX; i++) {
5713 +- if (sta_info_le.rssi[i]) {
5714 +- sinfo->chain_signal_avg[count_rssi] =
5715 +- sta_info_le.rssi[i];
5716 +- sinfo->chain_signal[count_rssi] =
5717 +- sta_info_le.rssi[i];
5718 +- total_rssi += sta_info_le.rssi[i];
5719 +- count_rssi++;
5720 +- }
5721 ++ if (sta_info_le.rssi[i] == 0 ||
5722 ++ sta_info_le.rx_lastpkt_rssi[i] == 0)
5723 ++ continue;
5724 ++ sinfo->chains |= BIT(count_rssi);
5725 ++ sinfo->chain_signal[count_rssi] =
5726 ++ sta_info_le.rx_lastpkt_rssi[i];
5727 ++ sinfo->chain_signal_avg[count_rssi] =
5728 ++ sta_info_le.rssi[i];
5729 ++ total_rssi += sta_info_le.rx_lastpkt_rssi[i];
5730 ++ total_rssi_avg += sta_info_le.rssi[i];
5731 ++ count_rssi++;
5732 + }
5733 + if (count_rssi) {
5734 +- sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);
5735 +- sinfo->chains = count_rssi;
5736 +-
5737 + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
5738 +- total_rssi /= count_rssi;
5739 +- sinfo->signal = total_rssi;
5740 ++ sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
5741 ++ sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);
5742 ++ sinfo->filled |=
5743 ++ BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG);
5744 ++ sinfo->signal = total_rssi / count_rssi;
5745 ++ sinfo->signal_avg = total_rssi_avg / count_rssi;
5746 + } else if (test_bit(BRCMF_VIF_STATUS_CONNECTED,
5747 + &ifp->vif->sme_state)) {
5748 + memset(&scb_val, 0, sizeof(scb_val));
5749 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
5750 +index 6188275b17e5a..288d4d4d44548 100644
5751 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
5752 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
5753 +@@ -1223,6 +1223,7 @@ static int brcms_bcma_probe(struct bcma_device *pdev)
5754 + {
5755 + struct brcms_info *wl;
5756 + struct ieee80211_hw *hw;
5757 ++ int ret;
5758 +
5759 + dev_info(&pdev->dev, "mfg %x core %x rev %d class %d irq %d\n",
5760 + pdev->id.manuf, pdev->id.id, pdev->id.rev, pdev->id.class,
5761 +@@ -1247,11 +1248,16 @@ static int brcms_bcma_probe(struct bcma_device *pdev)
5762 + wl = brcms_attach(pdev);
5763 + if (!wl) {
5764 + pr_err("%s: brcms_attach failed!\n", __func__);
5765 +- return -ENODEV;
5766 ++ ret = -ENODEV;
5767 ++ goto err_free_ieee80211;
5768 + }
5769 + brcms_led_register(wl);
5770 +
5771 + return 0;
5772 ++
5773 ++err_free_ieee80211:
5774 ++ ieee80211_free_hw(hw);
5775 ++ return ret;
5776 + }
5777 +
5778 + static int brcms_suspend(struct bcma_device *pdev)
5779 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
5780 +index 2b92980a49e68..d46e606b7b025 100644
5781 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
5782 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
5783 +@@ -1091,6 +1091,9 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,
5784 + if (WARN_ON_ONCE(mvmsta->sta_id == IWL_MVM_INVALID_STA))
5785 + return -1;
5786 +
5787 ++ if (unlikely(ieee80211_is_any_nullfunc(fc)) && sta->he_cap.has_he)
5788 ++ return -1;
5789 ++
5790 + if (unlikely(ieee80211_is_probe_resp(fc)))
5791 + iwl_mvm_probe_resp_set_noa(mvm, skb);
5792 +
5793 +diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
5794 +index 58c9623c3a916..bc46a0aa06eb7 100644
5795 +--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
5796 ++++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
5797 +@@ -1080,7 +1080,7 @@ static int mwifiex_pcie_delete_cmdrsp_buf(struct mwifiex_adapter *adapter)
5798 + static int mwifiex_pcie_alloc_sleep_cookie_buf(struct mwifiex_adapter *adapter)
5799 + {
5800 + struct pcie_service_card *card = adapter->card;
5801 +- u32 tmp;
5802 ++ u32 *cookie;
5803 +
5804 + card->sleep_cookie_vbase = pci_alloc_consistent(card->dev, sizeof(u32),
5805 + &card->sleep_cookie_pbase);
5806 +@@ -1089,13 +1089,11 @@ static int mwifiex_pcie_alloc_sleep_cookie_buf(struct mwifiex_adapter *adapter)
5807 + "pci_alloc_consistent failed!\n");
5808 + return -ENOMEM;
5809 + }
5810 ++ cookie = (u32 *)card->sleep_cookie_vbase;
5811 + /* Init val of Sleep Cookie */
5812 +- tmp = FW_AWAKE_COOKIE;
5813 +- put_unaligned(tmp, card->sleep_cookie_vbase);
5814 ++ *cookie = FW_AWAKE_COOKIE;
5815 +
5816 +- mwifiex_dbg(adapter, INFO,
5817 +- "alloc_scook: sleep cookie=0x%x\n",
5818 +- get_unaligned(card->sleep_cookie_vbase));
5819 ++ mwifiex_dbg(adapter, INFO, "alloc_scook: sleep cookie=0x%x\n", *cookie);
5820 +
5821 + return 0;
5822 + }
5823 +diff --git a/drivers/net/wireless/rsi/rsi_91x_hal.c b/drivers/net/wireless/rsi/rsi_91x_hal.c
5824 +index a07304405b2cc..03791f3fe480c 100644
5825 +--- a/drivers/net/wireless/rsi/rsi_91x_hal.c
5826 ++++ b/drivers/net/wireless/rsi/rsi_91x_hal.c
5827 +@@ -203,7 +203,7 @@ int rsi_prepare_data_desc(struct rsi_common *common, struct sk_buff *skb)
5828 + wh->frame_control |= cpu_to_le16(RSI_SET_PS_ENABLE);
5829 +
5830 + if ((!(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) &&
5831 +- (common->secinfo.security_enable)) {
5832 ++ info->control.hw_key) {
5833 + if (rsi_is_cipher_wep(common))
5834 + ieee80211_size += 4;
5835 + else
5836 +@@ -470,9 +470,9 @@ int rsi_prepare_beacon(struct rsi_common *common, struct sk_buff *skb)
5837 + }
5838 +
5839 + if (common->band == NL80211_BAND_2GHZ)
5840 +- bcn_frm->bbp_info |= cpu_to_le16(RSI_RATE_1);
5841 ++ bcn_frm->rate_info |= cpu_to_le16(RSI_RATE_1);
5842 + else
5843 +- bcn_frm->bbp_info |= cpu_to_le16(RSI_RATE_6);
5844 ++ bcn_frm->rate_info |= cpu_to_le16(RSI_RATE_6);
5845 +
5846 + if (mac_bcn->data[tim_offset + 2] == 0)
5847 + bcn_frm->frame_info |= cpu_to_le16(RSI_DATA_DESC_DTIM_BEACON);
5848 +diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
5849 +index ce5e92d82efc8..ca1e609f637e4 100644
5850 +--- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
5851 ++++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
5852 +@@ -1027,7 +1027,6 @@ static int rsi_mac80211_set_key(struct ieee80211_hw *hw,
5853 + mutex_lock(&common->mutex);
5854 + switch (cmd) {
5855 + case SET_KEY:
5856 +- secinfo->security_enable = true;
5857 + status = rsi_hal_key_config(hw, vif, key, sta);
5858 + if (status) {
5859 + mutex_unlock(&common->mutex);
5860 +@@ -1046,8 +1045,6 @@ static int rsi_mac80211_set_key(struct ieee80211_hw *hw,
5861 + break;
5862 +
5863 + case DISABLE_KEY:
5864 +- if (vif->type == NL80211_IFTYPE_STATION)
5865 +- secinfo->security_enable = false;
5866 + rsi_dbg(ERR_ZONE, "%s: RSI del key\n", __func__);
5867 + memset(key, 0, sizeof(struct ieee80211_key_conf));
5868 + status = rsi_hal_key_config(hw, vif, key, sta);
5869 +diff --git a/drivers/net/wireless/rsi/rsi_91x_mgmt.c b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
5870 +index 9cc8a335d519d..ed67f65986775 100644
5871 +--- a/drivers/net/wireless/rsi/rsi_91x_mgmt.c
5872 ++++ b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
5873 +@@ -1788,8 +1788,7 @@ int rsi_send_wowlan_request(struct rsi_common *common, u16 flags,
5874 + RSI_WIFI_MGMT_Q);
5875 + cmd_frame->desc.desc_dword0.frame_type = WOWLAN_CONFIG_PARAMS;
5876 + cmd_frame->host_sleep_status = sleep_status;
5877 +- if (common->secinfo.security_enable &&
5878 +- common->secinfo.gtk_cipher)
5879 ++ if (common->secinfo.gtk_cipher)
5880 + flags |= RSI_WOW_GTK_REKEY;
5881 + if (sleep_status)
5882 + cmd_frame->wow_flags = flags;
5883 +diff --git a/drivers/net/wireless/rsi/rsi_main.h b/drivers/net/wireless/rsi/rsi_main.h
5884 +index 73a19e43106b1..b3e25bc28682c 100644
5885 +--- a/drivers/net/wireless/rsi/rsi_main.h
5886 ++++ b/drivers/net/wireless/rsi/rsi_main.h
5887 +@@ -151,7 +151,6 @@ enum edca_queue {
5888 + };
5889 +
5890 + struct security_info {
5891 +- bool security_enable;
5892 + u32 ptk_cipher;
5893 + u32 gtk_cipher;
5894 + };
5895 +diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
5896 +index fc35f7ae67b0a..9b07e8c7689ab 100644
5897 +--- a/drivers/nvme/target/fc.c
5898 ++++ b/drivers/nvme/target/fc.c
5899 +@@ -2151,13 +2151,6 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport,
5900 + u32 xfrlen = be32_to_cpu(cmdiu->data_len);
5901 + int ret;
5902 +
5903 +- /*
5904 +- * if there is no nvmet mapping to the targetport there
5905 +- * shouldn't be requests. just terminate them.
5906 +- */
5907 +- if (!tgtport->pe)
5908 +- goto transport_error;
5909 +-
5910 + /*
5911 + * Fused commands are currently not supported in the linux
5912 + * implementation.
5913 +@@ -2185,7 +2178,8 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport,
5914 +
5915 + fod->req.cmd = &fod->cmdiubuf.sqe;
5916 + fod->req.cqe = &fod->rspiubuf.cqe;
5917 +- fod->req.port = tgtport->pe->port;
5918 ++ if (tgtport->pe)
5919 ++ fod->req.port = tgtport->pe->port;
5920 +
5921 + /* clear any response payload */
5922 + memset(&fod->rspiubuf, 0, sizeof(fod->rspiubuf));
5923 +diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
5924 +index 223d617ecfe17..943d2a60bfdf9 100644
5925 +--- a/drivers/of/fdt.c
5926 ++++ b/drivers/of/fdt.c
5927 +@@ -501,11 +501,11 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,
5928 +
5929 + if (size &&
5930 + early_init_dt_reserve_memory_arch(base, size, nomap) == 0)
5931 +- pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %ld MiB\n",
5932 +- uname, &base, (unsigned long)size / SZ_1M);
5933 ++ pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %lu MiB\n",
5934 ++ uname, &base, (unsigned long)(size / SZ_1M));
5935 + else
5936 +- pr_info("Reserved memory: failed to reserve memory for node '%s': base %pa, size %ld MiB\n",
5937 +- uname, &base, (unsigned long)size / SZ_1M);
5938 ++ pr_info("Reserved memory: failed to reserve memory for node '%s': base %pa, size %lu MiB\n",
5939 ++ uname, &base, (unsigned long)(size / SZ_1M));
5940 +
5941 + len -= t_len;
5942 + if (first) {
5943 +diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
5944 +index 3fb5d8caffd53..6ed3ffd0a6295 100644
5945 +--- a/drivers/of/of_reserved_mem.c
5946 ++++ b/drivers/of/of_reserved_mem.c
5947 +@@ -134,9 +134,9 @@ static int __init __reserved_mem_alloc_size(unsigned long node,
5948 + ret = early_init_dt_alloc_reserved_memory_arch(size,
5949 + align, start, end, nomap, &base);
5950 + if (ret == 0) {
5951 +- pr_debug("allocated memory for '%s' node: base %pa, size %ld MiB\n",
5952 ++ pr_debug("allocated memory for '%s' node: base %pa, size %lu MiB\n",
5953 + uname, &base,
5954 +- (unsigned long)size / SZ_1M);
5955 ++ (unsigned long)(size / SZ_1M));
5956 + break;
5957 + }
5958 + len -= t_len;
5959 +@@ -146,8 +146,8 @@ static int __init __reserved_mem_alloc_size(unsigned long node,
5960 + ret = early_init_dt_alloc_reserved_memory_arch(size, align,
5961 + 0, 0, nomap, &base);
5962 + if (ret == 0)
5963 +- pr_debug("allocated memory for '%s' node: base %pa, size %ld MiB\n",
5964 +- uname, &base, (unsigned long)size / SZ_1M);
5965 ++ pr_debug("allocated memory for '%s' node: base %pa, size %lu MiB\n",
5966 ++ uname, &base, (unsigned long)(size / SZ_1M));
5967 + }
5968 +
5969 + if (base == 0) {
5970 +diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
5971 +index f1f300218fab8..8c45d6c32c30e 100644
5972 +--- a/drivers/pci/controller/pci-hyperv.c
5973 ++++ b/drivers/pci/controller/pci-hyperv.c
5974 +@@ -3121,6 +3121,9 @@ static void __exit exit_hv_pci_drv(void)
5975 +
5976 + static int __init init_hv_pci_drv(void)
5977 + {
5978 ++ if (!hv_is_hyperv_initialized())
5979 ++ return -ENODEV;
5980 ++
5981 + /* Set the invalid domain number's bit, so it will not be used */
5982 + set_bit(HVPCI_DOM_INVALID, hvpci_dom_map);
5983 +
5984 +diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
5985 +index 9cdd89b29334e..6a3fa1f69e68a 100644
5986 +--- a/drivers/perf/arm_smmuv3_pmu.c
5987 ++++ b/drivers/perf/arm_smmuv3_pmu.c
5988 +@@ -275,7 +275,7 @@ static int smmu_pmu_apply_event_filter(struct smmu_pmu *smmu_pmu,
5989 + struct perf_event *event, int idx)
5990 + {
5991 + u32 span, sid;
5992 +- unsigned int num_ctrs = smmu_pmu->num_counters;
5993 ++ unsigned int cur_idx, num_ctrs = smmu_pmu->num_counters;
5994 + bool filter_en = !!get_filter_enable(event);
5995 +
5996 + span = filter_en ? get_filter_span(event) :
5997 +@@ -283,17 +283,19 @@ static int smmu_pmu_apply_event_filter(struct smmu_pmu *smmu_pmu,
5998 + sid = filter_en ? get_filter_stream_id(event) :
5999 + SMMU_PMCG_DEFAULT_FILTER_SID;
6000 +
6001 +- /* Support individual filter settings */
6002 +- if (!smmu_pmu->global_filter) {
6003 ++ cur_idx = find_first_bit(smmu_pmu->used_counters, num_ctrs);
6004 ++ /*
6005 ++ * Per-counter filtering, or scheduling the first globally-filtered
6006 ++ * event into an empty PMU so idx == 0 and it works out equivalent.
6007 ++ */
6008 ++ if (!smmu_pmu->global_filter || cur_idx == num_ctrs) {
6009 + smmu_pmu_set_event_filter(event, idx, span, sid);
6010 + return 0;
6011 + }
6012 +
6013 +- /* Requested settings same as current global settings*/
6014 +- idx = find_first_bit(smmu_pmu->used_counters, num_ctrs);
6015 +- if (idx == num_ctrs ||
6016 +- smmu_pmu_check_global_filter(smmu_pmu->events[idx], event)) {
6017 +- smmu_pmu_set_event_filter(event, 0, span, sid);
6018 ++ /* Otherwise, must match whatever's currently scheduled */
6019 ++ if (smmu_pmu_check_global_filter(smmu_pmu->events[cur_idx], event)) {
6020 ++ smmu_pmu_set_evtyper(smmu_pmu, idx, get_event(event));
6021 + return 0;
6022 + }
6023 +
6024 +diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c
6025 +index 09f44c6e2eaf6..726ed8f59868c 100644
6026 +--- a/drivers/perf/fsl_imx8_ddr_perf.c
6027 ++++ b/drivers/perf/fsl_imx8_ddr_perf.c
6028 +@@ -562,8 +562,10 @@ static int ddr_perf_probe(struct platform_device *pdev)
6029 +
6030 + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, DDR_PERF_DEV_NAME "%d",
6031 + num);
6032 +- if (!name)
6033 +- return -ENOMEM;
6034 ++ if (!name) {
6035 ++ ret = -ENOMEM;
6036 ++ goto cpuhp_state_err;
6037 ++ }
6038 +
6039 + pmu->devtype_data = of_device_get_match_data(&pdev->dev);
6040 +
6041 +diff --git a/drivers/phy/socionext/phy-uniphier-pcie.c b/drivers/phy/socionext/phy-uniphier-pcie.c
6042 +index 93ffbd2940fa4..0bad0e01279a1 100644
6043 +--- a/drivers/phy/socionext/phy-uniphier-pcie.c
6044 ++++ b/drivers/phy/socionext/phy-uniphier-pcie.c
6045 +@@ -20,11 +20,13 @@
6046 +
6047 + /* PHY */
6048 + #define PCL_PHY_TEST_I 0x2000
6049 +-#define PCL_PHY_TEST_O 0x2004
6050 + #define TESTI_DAT_MASK GENMASK(13, 6)
6051 + #define TESTI_ADR_MASK GENMASK(5, 1)
6052 + #define TESTI_WR_EN BIT(0)
6053 +
6054 ++#define PCL_PHY_TEST_O 0x2004
6055 ++#define TESTO_DAT_MASK GENMASK(7, 0)
6056 ++
6057 + #define PCL_PHY_RESET 0x200c
6058 + #define PCL_PHY_RESET_N_MNMODE BIT(8) /* =1:manual */
6059 + #define PCL_PHY_RESET_N BIT(0) /* =1:deasssert */
6060 +@@ -72,11 +74,12 @@ static void uniphier_pciephy_set_param(struct uniphier_pciephy_priv *priv,
6061 + val = FIELD_PREP(TESTI_DAT_MASK, 1);
6062 + val |= FIELD_PREP(TESTI_ADR_MASK, reg);
6063 + uniphier_pciephy_testio_write(priv, val);
6064 +- val = readl(priv->base + PCL_PHY_TEST_O);
6065 ++ val = readl(priv->base + PCL_PHY_TEST_O) & TESTO_DAT_MASK;
6066 +
6067 + /* update value */
6068 +- val &= ~FIELD_PREP(TESTI_DAT_MASK, mask);
6069 +- val = FIELD_PREP(TESTI_DAT_MASK, mask & param);
6070 ++ val &= ~mask;
6071 ++ val |= mask & param;
6072 ++ val = FIELD_PREP(TESTI_DAT_MASK, val);
6073 + val |= FIELD_PREP(TESTI_ADR_MASK, reg);
6074 + uniphier_pciephy_testio_write(priv, val);
6075 + uniphier_pciephy_testio_write(priv, val | TESTI_WR_EN);
6076 +diff --git a/drivers/phy/ti/phy-dm816x-usb.c b/drivers/phy/ti/phy-dm816x-usb.c
6077 +index cbcce7cf0028e..2ed5fe20d7792 100644
6078 +--- a/drivers/phy/ti/phy-dm816x-usb.c
6079 ++++ b/drivers/phy/ti/phy-dm816x-usb.c
6080 +@@ -246,19 +246,28 @@ static int dm816x_usb_phy_probe(struct platform_device *pdev)
6081 +
6082 + pm_runtime_enable(phy->dev);
6083 + generic_phy = devm_phy_create(phy->dev, NULL, &ops);
6084 +- if (IS_ERR(generic_phy))
6085 +- return PTR_ERR(generic_phy);
6086 ++ if (IS_ERR(generic_phy)) {
6087 ++ error = PTR_ERR(generic_phy);
6088 ++ goto clk_unprepare;
6089 ++ }
6090 +
6091 + phy_set_drvdata(generic_phy, phy);
6092 +
6093 + phy_provider = devm_of_phy_provider_register(phy->dev,
6094 + of_phy_simple_xlate);
6095 +- if (IS_ERR(phy_provider))
6096 +- return PTR_ERR(phy_provider);
6097 ++ if (IS_ERR(phy_provider)) {
6098 ++ error = PTR_ERR(phy_provider);
6099 ++ goto clk_unprepare;
6100 ++ }
6101 +
6102 + usb_add_phy_dev(&phy->phy);
6103 +
6104 + return 0;
6105 ++
6106 ++clk_unprepare:
6107 ++ pm_runtime_disable(phy->dev);
6108 ++ clk_unprepare(phy->refclk);
6109 ++ return error;
6110 + }
6111 +
6112 + static int dm816x_usb_phy_remove(struct platform_device *pdev)
6113 +diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7796.c b/drivers/pinctrl/sh-pfc/pfc-r8a7796.c
6114 +index 61db7c7a35ec9..60d35a2c14ba5 100644
6115 +--- a/drivers/pinctrl/sh-pfc/pfc-r8a7796.c
6116 ++++ b/drivers/pinctrl/sh-pfc/pfc-r8a7796.c
6117 +@@ -68,6 +68,7 @@
6118 + PIN_NOGP_CFG(QSPI1_MOSI_IO0, "QSPI1_MOSI_IO0", fn, CFG_FLAGS), \
6119 + PIN_NOGP_CFG(QSPI1_SPCLK, "QSPI1_SPCLK", fn, CFG_FLAGS), \
6120 + PIN_NOGP_CFG(QSPI1_SSL, "QSPI1_SSL", fn, CFG_FLAGS), \
6121 ++ PIN_NOGP_CFG(PRESET_N, "PRESET#", fn, SH_PFC_PIN_CFG_PULL_DOWN),\
6122 + PIN_NOGP_CFG(RPC_INT_N, "RPC_INT#", fn, CFG_FLAGS), \
6123 + PIN_NOGP_CFG(RPC_RESET_N, "RPC_RESET#", fn, CFG_FLAGS), \
6124 + PIN_NOGP_CFG(RPC_WP_N, "RPC_WP#", fn, CFG_FLAGS), \
6125 +@@ -6109,7 +6110,7 @@ static const struct pinmux_bias_reg pinmux_bias_regs[] = {
6126 + [ 4] = RCAR_GP_PIN(6, 29), /* USB30_OVC */
6127 + [ 5] = RCAR_GP_PIN(6, 30), /* GP6_30 */
6128 + [ 6] = RCAR_GP_PIN(6, 31), /* GP6_31 */
6129 +- [ 7] = SH_PFC_PIN_NONE,
6130 ++ [ 7] = PIN_PRESET_N, /* PRESET# */
6131 + [ 8] = SH_PFC_PIN_NONE,
6132 + [ 9] = SH_PFC_PIN_NONE,
6133 + [10] = SH_PFC_PIN_NONE,
6134 +diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a77990.c b/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
6135 +index 5200dadd6b3ef..f4b51e5e7e020 100644
6136 +--- a/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
6137 ++++ b/drivers/pinctrl/sh-pfc/pfc-r8a77990.c
6138 +@@ -54,10 +54,10 @@
6139 + PIN_NOGP_CFG(FSCLKST_N, "FSCLKST_N", fn, CFG_FLAGS), \
6140 + PIN_NOGP_CFG(MLB_REF, "MLB_REF", fn, CFG_FLAGS), \
6141 + PIN_NOGP_CFG(PRESETOUT_N, "PRESETOUT_N", fn, CFG_FLAGS), \
6142 +- PIN_NOGP_CFG(TCK, "TCK", fn, CFG_FLAGS), \
6143 +- PIN_NOGP_CFG(TDI, "TDI", fn, CFG_FLAGS), \
6144 +- PIN_NOGP_CFG(TMS, "TMS", fn, CFG_FLAGS), \
6145 +- PIN_NOGP_CFG(TRST_N, "TRST_N", fn, CFG_FLAGS)
6146 ++ PIN_NOGP_CFG(TCK, "TCK", fn, SH_PFC_PIN_CFG_PULL_UP), \
6147 ++ PIN_NOGP_CFG(TDI, "TDI", fn, SH_PFC_PIN_CFG_PULL_UP), \
6148 ++ PIN_NOGP_CFG(TMS, "TMS", fn, SH_PFC_PIN_CFG_PULL_UP), \
6149 ++ PIN_NOGP_CFG(TRST_N, "TRST_N", fn, SH_PFC_PIN_CFG_PULL_UP)
6150 +
6151 + /*
6152 + * F_() : just information
6153 +diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
6154 +index 71a969fc3b206..f202fc0dd1ff2 100644
6155 +--- a/drivers/platform/x86/toshiba_acpi.c
6156 ++++ b/drivers/platform/x86/toshiba_acpi.c
6157 +@@ -2841,6 +2841,7 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
6158 +
6159 + if (!dev->info_supported && !dev->system_event_supported) {
6160 + pr_warn("No hotkey query interface found\n");
6161 ++ error = -EINVAL;
6162 + goto err_remove_filter;
6163 + }
6164 +
6165 +diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
6166 +index e18d291c7f21c..23fa429ebe760 100644
6167 +--- a/drivers/regulator/da9052-regulator.c
6168 ++++ b/drivers/regulator/da9052-regulator.c
6169 +@@ -250,7 +250,8 @@ static int da9052_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
6170 + case DA9052_ID_BUCK3:
6171 + case DA9052_ID_LDO2:
6172 + case DA9052_ID_LDO3:
6173 +- ret = (new_sel - old_sel) * info->step_uV / 6250;
6174 ++ ret = DIV_ROUND_UP(abs(new_sel - old_sel) * info->step_uV,
6175 ++ 6250);
6176 + break;
6177 + }
6178 +
6179 +diff --git a/drivers/regulator/hi655x-regulator.c b/drivers/regulator/hi655x-regulator.c
6180 +index ac2ee2030211a..b44f492a2b832 100644
6181 +--- a/drivers/regulator/hi655x-regulator.c
6182 ++++ b/drivers/regulator/hi655x-regulator.c
6183 +@@ -72,7 +72,7 @@ enum hi655x_regulator_id {
6184 + static int hi655x_is_enabled(struct regulator_dev *rdev)
6185 + {
6186 + unsigned int value = 0;
6187 +- struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
6188 ++ const struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
6189 +
6190 + regmap_read(rdev->regmap, regulator->status_reg, &value);
6191 + return (value & rdev->desc->enable_mask);
6192 +@@ -80,7 +80,7 @@ static int hi655x_is_enabled(struct regulator_dev *rdev)
6193 +
6194 + static int hi655x_disable(struct regulator_dev *rdev)
6195 + {
6196 +- struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
6197 ++ const struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
6198 +
6199 + return regmap_write(rdev->regmap, regulator->disable_reg,
6200 + rdev->desc->enable_mask);
6201 +@@ -169,7 +169,6 @@ static const struct hi655x_regulator regulators[] = {
6202 + static int hi655x_regulator_probe(struct platform_device *pdev)
6203 + {
6204 + unsigned int i;
6205 +- struct hi655x_regulator *regulator;
6206 + struct hi655x_pmic *pmic;
6207 + struct regulator_config config = { };
6208 + struct regulator_dev *rdev;
6209 +@@ -180,22 +179,17 @@ static int hi655x_regulator_probe(struct platform_device *pdev)
6210 + return -ENODEV;
6211 + }
6212 +
6213 +- regulator = devm_kzalloc(&pdev->dev, sizeof(*regulator), GFP_KERNEL);
6214 +- if (!regulator)
6215 +- return -ENOMEM;
6216 +-
6217 +- platform_set_drvdata(pdev, regulator);
6218 +-
6219 + config.dev = pdev->dev.parent;
6220 + config.regmap = pmic->regmap;
6221 +- config.driver_data = regulator;
6222 + for (i = 0; i < ARRAY_SIZE(regulators); i++) {
6223 ++ config.driver_data = (void *) &regulators[i];
6224 ++
6225 + rdev = devm_regulator_register(&pdev->dev,
6226 + &regulators[i].rdesc,
6227 + &config);
6228 + if (IS_ERR(rdev)) {
6229 + dev_err(&pdev->dev, "failed to register regulator %s\n",
6230 +- regulator->rdesc.name);
6231 ++ regulators[i].rdesc.name);
6232 + return PTR_ERR(rdev);
6233 + }
6234 + }
6235 +diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt6358-regulator.c
6236 +index ba42682e06f36..40e09b1d323dd 100644
6237 +--- a/drivers/regulator/mt6358-regulator.c
6238 ++++ b/drivers/regulator/mt6358-regulator.c
6239 +@@ -457,7 +457,7 @@ static struct mt6358_regulator_info mt6358_regulators[] = {
6240 + MT6358_REG_FIXED("ldo_vaud28", VAUD28,
6241 + MT6358_LDO_VAUD28_CON0, 0, 2800000),
6242 + MT6358_LDO("ldo_vdram2", VDRAM2, vdram2_voltages, vdram2_idx,
6243 +- MT6358_LDO_VDRAM2_CON0, 0, MT6358_LDO_VDRAM2_ELR0, 0x10, 0),
6244 ++ MT6358_LDO_VDRAM2_CON0, 0, MT6358_LDO_VDRAM2_ELR0, 0xf, 0),
6245 + MT6358_LDO("ldo_vsim1", VSIM1, vsim_voltages, vsim_idx,
6246 + MT6358_LDO_VSIM1_CON0, 0, MT6358_VSIM1_ANA_CON0, 0xf00, 8),
6247 + MT6358_LDO("ldo_vibr", VIBR, vibr_voltages, vibr_idx,
6248 +diff --git a/drivers/regulator/uniphier-regulator.c b/drivers/regulator/uniphier-regulator.c
6249 +index 2311924c31039..2904c7bb4767c 100644
6250 +--- a/drivers/regulator/uniphier-regulator.c
6251 ++++ b/drivers/regulator/uniphier-regulator.c
6252 +@@ -203,6 +203,7 @@ static const struct of_device_id uniphier_regulator_match[] = {
6253 + },
6254 + { /* Sentinel */ },
6255 + };
6256 ++MODULE_DEVICE_TABLE(of, uniphier_regulator_match);
6257 +
6258 + static struct platform_driver uniphier_regulator_driver = {
6259 + .probe = uniphier_regulator_probe,
6260 +diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c
6261 +index 2999e33a7e376..d28e7597dc050 100644
6262 +--- a/drivers/rtc/rtc-stm32.c
6263 ++++ b/drivers/rtc/rtc-stm32.c
6264 +@@ -756,7 +756,7 @@ static int stm32_rtc_probe(struct platform_device *pdev)
6265 +
6266 + ret = clk_prepare_enable(rtc->rtc_ck);
6267 + if (ret)
6268 +- goto err;
6269 ++ goto err_no_rtc_ck;
6270 +
6271 + if (rtc->data->need_dbp)
6272 + regmap_update_bits(rtc->dbp, rtc->dbp_reg,
6273 +@@ -832,10 +832,12 @@ static int stm32_rtc_probe(struct platform_device *pdev)
6274 + }
6275 +
6276 + return 0;
6277 ++
6278 + err:
6279 ++ clk_disable_unprepare(rtc->rtc_ck);
6280 ++err_no_rtc_ck:
6281 + if (rtc->data->has_pclk)
6282 + clk_disable_unprepare(rtc->pclk);
6283 +- clk_disable_unprepare(rtc->rtc_ck);
6284 +
6285 + if (rtc->data->need_dbp)
6286 + regmap_update_bits(rtc->dbp, rtc->dbp_reg, rtc->dbp_mask, 0);
6287 +diff --git a/drivers/s390/cio/chp.c b/drivers/s390/cio/chp.c
6288 +index 51038ec309c12..1fd982b4d64bd 100644
6289 +--- a/drivers/s390/cio/chp.c
6290 ++++ b/drivers/s390/cio/chp.c
6291 +@@ -255,6 +255,9 @@ static ssize_t chp_status_write(struct device *dev,
6292 + if (!num_args)
6293 + return count;
6294 +
6295 ++ /* Wait until previous actions have settled. */
6296 ++ css_wait_for_slow_path();
6297 ++
6298 + if (!strncasecmp(cmd, "on", 2) || !strcmp(cmd, "1")) {
6299 + mutex_lock(&cp->lock);
6300 + error = s390_vary_chpid(cp->chpid, 1);
6301 +diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
6302 +index 6392a1b95b028..980a78d3d81b6 100644
6303 +--- a/drivers/s390/cio/chsc.c
6304 ++++ b/drivers/s390/cio/chsc.c
6305 +@@ -753,8 +753,6 @@ int chsc_chp_vary(struct chp_id chpid, int on)
6306 + {
6307 + struct channel_path *chp = chpid_to_chp(chpid);
6308 +
6309 +- /* Wait until previous actions have settled. */
6310 +- css_wait_for_slow_path();
6311 + /*
6312 + * Redo PathVerification on the devices the chpid connects to
6313 + */
6314 +diff --git a/drivers/scsi/FlashPoint.c b/drivers/scsi/FlashPoint.c
6315 +index 0f17bd51088ac..3b15fb25b5e69 100644
6316 +--- a/drivers/scsi/FlashPoint.c
6317 ++++ b/drivers/scsi/FlashPoint.c
6318 +@@ -40,7 +40,7 @@ struct sccb_mgr_info {
6319 + u16 si_per_targ_ultra_nego;
6320 + u16 si_per_targ_no_disc;
6321 + u16 si_per_targ_wide_nego;
6322 +- u16 si_flags;
6323 ++ u16 si_mflags;
6324 + unsigned char si_card_family;
6325 + unsigned char si_bustype;
6326 + unsigned char si_card_model[3];
6327 +@@ -1070,22 +1070,22 @@ static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo)
6328 + ScamFlg =
6329 + (unsigned char)FPT_utilEERead(ioport, SCAM_CONFIG / 2);
6330 +
6331 +- pCardInfo->si_flags = 0x0000;
6332 ++ pCardInfo->si_mflags = 0x0000;
6333 +
6334 + if (i & 0x01)
6335 +- pCardInfo->si_flags |= SCSI_PARITY_ENA;
6336 ++ pCardInfo->si_mflags |= SCSI_PARITY_ENA;
6337 +
6338 + if (!(i & 0x02))
6339 +- pCardInfo->si_flags |= SOFT_RESET;
6340 ++ pCardInfo->si_mflags |= SOFT_RESET;
6341 +
6342 + if (i & 0x10)
6343 +- pCardInfo->si_flags |= EXTENDED_TRANSLATION;
6344 ++ pCardInfo->si_mflags |= EXTENDED_TRANSLATION;
6345 +
6346 + if (ScamFlg & SCAM_ENABLED)
6347 +- pCardInfo->si_flags |= FLAG_SCAM_ENABLED;
6348 ++ pCardInfo->si_mflags |= FLAG_SCAM_ENABLED;
6349 +
6350 + if (ScamFlg & SCAM_LEVEL2)
6351 +- pCardInfo->si_flags |= FLAG_SCAM_LEVEL2;
6352 ++ pCardInfo->si_mflags |= FLAG_SCAM_LEVEL2;
6353 +
6354 + j = (RD_HARPOON(ioport + hp_bm_ctrl) & ~SCSI_TERM_ENA_L);
6355 + if (i & 0x04) {
6356 +@@ -1101,7 +1101,7 @@ static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo)
6357 +
6358 + if (!(RD_HARPOON(ioport + hp_page_ctrl) & NARROW_SCSI_CARD))
6359 +
6360 +- pCardInfo->si_flags |= SUPPORT_16TAR_32LUN;
6361 ++ pCardInfo->si_mflags |= SUPPORT_16TAR_32LUN;
6362 +
6363 + pCardInfo->si_card_family = HARPOON_FAMILY;
6364 + pCardInfo->si_bustype = BUSTYPE_PCI;
6365 +@@ -1137,15 +1137,15 @@ static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo)
6366 +
6367 + if (pCardInfo->si_card_model[1] == '3') {
6368 + if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7))
6369 +- pCardInfo->si_flags |= LOW_BYTE_TERM;
6370 ++ pCardInfo->si_mflags |= LOW_BYTE_TERM;
6371 + } else if (pCardInfo->si_card_model[2] == '0') {
6372 + temp = RD_HARPOON(ioport + hp_xfer_pad);
6373 + WR_HARPOON(ioport + hp_xfer_pad, (temp & ~BIT(4)));
6374 + if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7))
6375 +- pCardInfo->si_flags |= LOW_BYTE_TERM;
6376 ++ pCardInfo->si_mflags |= LOW_BYTE_TERM;
6377 + WR_HARPOON(ioport + hp_xfer_pad, (temp | BIT(4)));
6378 + if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7))
6379 +- pCardInfo->si_flags |= HIGH_BYTE_TERM;
6380 ++ pCardInfo->si_mflags |= HIGH_BYTE_TERM;
6381 + WR_HARPOON(ioport + hp_xfer_pad, temp);
6382 + } else {
6383 + temp = RD_HARPOON(ioport + hp_ee_ctrl);
6384 +@@ -1163,9 +1163,9 @@ static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo)
6385 + WR_HARPOON(ioport + hp_ee_ctrl, temp);
6386 + WR_HARPOON(ioport + hp_xfer_pad, temp2);
6387 + if (!(temp3 & BIT(7)))
6388 +- pCardInfo->si_flags |= LOW_BYTE_TERM;
6389 ++ pCardInfo->si_mflags |= LOW_BYTE_TERM;
6390 + if (!(temp3 & BIT(6)))
6391 +- pCardInfo->si_flags |= HIGH_BYTE_TERM;
6392 ++ pCardInfo->si_mflags |= HIGH_BYTE_TERM;
6393 + }
6394 +
6395 + ARAM_ACCESS(ioport);
6396 +@@ -1272,7 +1272,7 @@ static void *FlashPoint_HardwareResetHostAdapter(struct sccb_mgr_info
6397 + WR_HARPOON(ioport + hp_arb_id, pCardInfo->si_id);
6398 + CurrCard->ourId = pCardInfo->si_id;
6399 +
6400 +- i = (unsigned char)pCardInfo->si_flags;
6401 ++ i = (unsigned char)pCardInfo->si_mflags;
6402 + if (i & SCSI_PARITY_ENA)
6403 + WR_HARPOON(ioport + hp_portctrl_1, (HOST_MODE8 | CHK_SCSI_P));
6404 +
6405 +@@ -1286,14 +1286,14 @@ static void *FlashPoint_HardwareResetHostAdapter(struct sccb_mgr_info
6406 + j |= SCSI_TERM_ENA_H;
6407 + WR_HARPOON(ioport + hp_ee_ctrl, j);
6408 +
6409 +- if (!(pCardInfo->si_flags & SOFT_RESET)) {
6410 ++ if (!(pCardInfo->si_mflags & SOFT_RESET)) {
6411 +
6412 + FPT_sresb(ioport, thisCard);
6413 +
6414 + FPT_scini(thisCard, pCardInfo->si_id, 0);
6415 + }
6416 +
6417 +- if (pCardInfo->si_flags & POST_ALL_UNDERRRUNS)
6418 ++ if (pCardInfo->si_mflags & POST_ALL_UNDERRRUNS)
6419 + CurrCard->globalFlags |= F_NO_FILTER;
6420 +
6421 + if (pCurrNvRam) {
6422 +diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
6423 +index aff630fccb07e..3654cfc4376fa 100644
6424 +--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
6425 ++++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
6426 +@@ -5728,8 +5728,10 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle)
6427 + handle, parent_handle,
6428 + (u64)sas_expander->sas_address, sas_expander->num_phys);
6429 +
6430 +- if (!sas_expander->num_phys)
6431 ++ if (!sas_expander->num_phys) {
6432 ++ rc = -1;
6433 + goto out_fail;
6434 ++ }
6435 + sas_expander->phy = kcalloc(sas_expander->num_phys,
6436 + sizeof(struct _sas_phy), GFP_KERNEL);
6437 + if (!sas_expander->phy) {
6438 +diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
6439 +index b5867e1566f42..8e6d7ba95df14 100644
6440 +--- a/drivers/scsi/scsi_lib.c
6441 ++++ b/drivers/scsi/scsi_lib.c
6442 +@@ -762,6 +762,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
6443 + case 0x07: /* operation in progress */
6444 + case 0x08: /* Long write in progress */
6445 + case 0x09: /* self test in progress */
6446 ++ case 0x11: /* notify (enable spinup) required */
6447 + case 0x14: /* space allocation in progress */
6448 + case 0x1a: /* start stop unit in progress */
6449 + case 0x1b: /* sanitize in progress */
6450 +diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
6451 +index 23accfedbf4d1..f7ca1f7a68f00 100644
6452 +--- a/drivers/soundwire/stream.c
6453 ++++ b/drivers/soundwire/stream.c
6454 +@@ -420,7 +420,6 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
6455 + struct completion *port_ready;
6456 + struct sdw_dpn_prop *dpn_prop;
6457 + struct sdw_prepare_ch prep_ch;
6458 +- unsigned int time_left;
6459 + bool intr = false;
6460 + int ret = 0, val;
6461 + u32 addr;
6462 +@@ -477,15 +476,15 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
6463 +
6464 + /* Wait for completion on port ready */
6465 + port_ready = &s_rt->slave->port_ready[prep_ch.num];
6466 +- time_left = wait_for_completion_timeout(port_ready,
6467 +- msecs_to_jiffies(dpn_prop->ch_prep_timeout));
6468 ++ wait_for_completion_timeout(port_ready,
6469 ++ msecs_to_jiffies(dpn_prop->ch_prep_timeout));
6470 +
6471 + val = sdw_read(s_rt->slave, SDW_DPN_PREPARESTATUS(p_rt->num));
6472 +- val &= p_rt->ch_mask;
6473 +- if (!time_left || val) {
6474 ++ if ((val < 0) || (val & p_rt->ch_mask)) {
6475 ++ ret = (val < 0) ? val : -ETIMEDOUT;
6476 + dev_err(&s_rt->slave->dev,
6477 +- "Chn prep failed for port:%d\n", prep_ch.num);
6478 +- return -ETIMEDOUT;
6479 ++ "Chn prep failed for port %d: %d\n", prep_ch.num, ret);
6480 ++ return ret;
6481 + }
6482 + }
6483 +
6484 +diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c
6485 +index 51633b2b64371..69a9df2cbbcf2 100644
6486 +--- a/drivers/spi/spi-loopback-test.c
6487 ++++ b/drivers/spi/spi-loopback-test.c
6488 +@@ -868,7 +868,7 @@ static int spi_test_run_iter(struct spi_device *spi,
6489 + test.transfers[i].len = len;
6490 + if (test.transfers[i].tx_buf)
6491 + test.transfers[i].tx_buf += tx_off;
6492 +- if (test.transfers[i].tx_buf)
6493 ++ if (test.transfers[i].rx_buf)
6494 + test.transfers[i].rx_buf += rx_off;
6495 + }
6496 +
6497 +diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c
6498 +index b8e201c094843..f64d030c760ae 100644
6499 +--- a/drivers/spi/spi-omap-100k.c
6500 ++++ b/drivers/spi/spi-omap-100k.c
6501 +@@ -242,7 +242,7 @@ static int omap1_spi100k_setup_transfer(struct spi_device *spi,
6502 + else
6503 + word_len = spi->bits_per_word;
6504 +
6505 +- if (spi->bits_per_word > 32)
6506 ++ if (word_len > 32)
6507 + return -EINVAL;
6508 + cs->word_len = word_len;
6509 +
6510 +diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
6511 +index 956df79035d56..3a8acd78308f6 100644
6512 +--- a/drivers/spi/spi-sun6i.c
6513 ++++ b/drivers/spi/spi-sun6i.c
6514 +@@ -297,6 +297,10 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
6515 + }
6516 +
6517 + sun6i_spi_write(sspi, SUN6I_CLK_CTL_REG, reg);
6518 ++ /* Finally enable the bus - doing so before might raise SCK to HIGH */
6519 ++ reg = sun6i_spi_read(sspi, SUN6I_GBL_CTL_REG);
6520 ++ reg |= SUN6I_GBL_CTL_BUS_ENABLE;
6521 ++ sun6i_spi_write(sspi, SUN6I_GBL_CTL_REG, reg);
6522 +
6523 + /* Setup the transfer now... */
6524 + if (sspi->tx_buf)
6525 +@@ -405,7 +409,7 @@ static int sun6i_spi_runtime_resume(struct device *dev)
6526 + }
6527 +
6528 + sun6i_spi_write(sspi, SUN6I_GBL_CTL_REG,
6529 +- SUN6I_GBL_CTL_BUS_ENABLE | SUN6I_GBL_CTL_MASTER | SUN6I_GBL_CTL_TP);
6530 ++ SUN6I_GBL_CTL_MASTER | SUN6I_GBL_CTL_TP);
6531 +
6532 + return 0;
6533 +
6534 +diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
6535 +index f88cbb94ce122..181ea30c416a2 100644
6536 +--- a/drivers/spi/spi-topcliff-pch.c
6537 ++++ b/drivers/spi/spi-topcliff-pch.c
6538 +@@ -576,8 +576,10 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
6539 + data->pkt_tx_buff = kzalloc(size, GFP_KERNEL);
6540 + if (data->pkt_tx_buff != NULL) {
6541 + data->pkt_rx_buff = kzalloc(size, GFP_KERNEL);
6542 +- if (!data->pkt_rx_buff)
6543 ++ if (!data->pkt_rx_buff) {
6544 + kfree(data->pkt_tx_buff);
6545 ++ data->pkt_tx_buff = NULL;
6546 ++ }
6547 + }
6548 +
6549 + if (!data->pkt_rx_buff) {
6550 +diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
6551 +index f8f3434d5ab1e..ac05c9c864884 100644
6552 +--- a/drivers/spi/spi.c
6553 ++++ b/drivers/spi/spi.c
6554 +@@ -1849,6 +1849,7 @@ of_register_spi_device(struct spi_controller *ctlr, struct device_node *nc)
6555 + /* Store a pointer to the node in the device structure */
6556 + of_node_get(nc);
6557 + spi->dev.of_node = nc;
6558 ++ spi->dev.fwnode = of_fwnode_handle(nc);
6559 +
6560 + /* Register the new device */
6561 + rc = spi_add_device(spi);
6562 +diff --git a/drivers/ssb/scan.c b/drivers/ssb/scan.c
6563 +index 6ceee98ed6ff2..5c7e61cafd195 100644
6564 +--- a/drivers/ssb/scan.c
6565 ++++ b/drivers/ssb/scan.c
6566 +@@ -325,6 +325,7 @@ int ssb_bus_scan(struct ssb_bus *bus,
6567 + if (bus->nr_devices > ARRAY_SIZE(bus->devices)) {
6568 + pr_err("More than %d ssb cores found (%d)\n",
6569 + SSB_MAX_NR_CORES, bus->nr_devices);
6570 ++ err = -EINVAL;
6571 + goto err_unmap;
6572 + }
6573 + if (bus->bustype == SSB_BUSTYPE_SSB) {
6574 +diff --git a/drivers/ssb/sdio.c b/drivers/ssb/sdio.c
6575 +index 7fe0afb42234f..66c5c2169704b 100644
6576 +--- a/drivers/ssb/sdio.c
6577 ++++ b/drivers/ssb/sdio.c
6578 +@@ -411,7 +411,6 @@ static void ssb_sdio_block_write(struct ssb_device *dev, const void *buffer,
6579 + sdio_claim_host(bus->host_sdio);
6580 + if (unlikely(ssb_sdio_switch_core(bus, dev))) {
6581 + error = -EIO;
6582 +- memset((void *)buffer, 0xff, count);
6583 + goto err_out;
6584 + }
6585 + offset |= bus->sdio_sbaddr & 0xffff;
6586 +diff --git a/drivers/staging/fbtft/fb_agm1264k-fl.c b/drivers/staging/fbtft/fb_agm1264k-fl.c
6587 +index eeeeec97ad278..b545c2ca80a41 100644
6588 +--- a/drivers/staging/fbtft/fb_agm1264k-fl.c
6589 ++++ b/drivers/staging/fbtft/fb_agm1264k-fl.c
6590 +@@ -84,9 +84,9 @@ static void reset(struct fbtft_par *par)
6591 +
6592 + dev_dbg(par->info->device, "%s()\n", __func__);
6593 +
6594 +- gpiod_set_value(par->gpio.reset, 0);
6595 +- udelay(20);
6596 + gpiod_set_value(par->gpio.reset, 1);
6597 ++ udelay(20);
6598 ++ gpiod_set_value(par->gpio.reset, 0);
6599 + mdelay(120);
6600 + }
6601 +
6602 +@@ -194,12 +194,12 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
6603 + /* select chip */
6604 + if (*buf) {
6605 + /* cs1 */
6606 +- gpiod_set_value(par->CS0, 1);
6607 +- gpiod_set_value(par->CS1, 0);
6608 +- } else {
6609 +- /* cs0 */
6610 + gpiod_set_value(par->CS0, 0);
6611 + gpiod_set_value(par->CS1, 1);
6612 ++ } else {
6613 ++ /* cs0 */
6614 ++ gpiod_set_value(par->CS0, 1);
6615 ++ gpiod_set_value(par->CS1, 0);
6616 + }
6617 +
6618 + gpiod_set_value(par->RS, 0); /* RS->0 (command mode) */
6619 +@@ -397,8 +397,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
6620 + }
6621 + kfree(convert_buf);
6622 +
6623 +- gpiod_set_value(par->CS0, 1);
6624 +- gpiod_set_value(par->CS1, 1);
6625 ++ gpiod_set_value(par->CS0, 0);
6626 ++ gpiod_set_value(par->CS1, 0);
6627 +
6628 + return ret;
6629 + }
6630 +@@ -419,10 +419,10 @@ static int write(struct fbtft_par *par, void *buf, size_t len)
6631 + for (i = 0; i < 8; ++i)
6632 + gpiod_set_value(par->gpio.db[i], data & (1 << i));
6633 + /* set E */
6634 +- gpiod_set_value(par->EPIN, 1);
6635 ++ gpiod_set_value(par->EPIN, 0);
6636 + udelay(5);
6637 + /* unset E - write */
6638 +- gpiod_set_value(par->EPIN, 0);
6639 ++ gpiod_set_value(par->EPIN, 1);
6640 + udelay(1);
6641 + }
6642 +
6643 +diff --git a/drivers/staging/fbtft/fb_bd663474.c b/drivers/staging/fbtft/fb_bd663474.c
6644 +index e2c7646588f8c..1629c2c440a97 100644
6645 +--- a/drivers/staging/fbtft/fb_bd663474.c
6646 ++++ b/drivers/staging/fbtft/fb_bd663474.c
6647 +@@ -12,7 +12,6 @@
6648 + #include <linux/module.h>
6649 + #include <linux/kernel.h>
6650 + #include <linux/init.h>
6651 +-#include <linux/gpio/consumer.h>
6652 + #include <linux/delay.h>
6653 +
6654 + #include "fbtft.h"
6655 +@@ -24,9 +23,6 @@
6656 +
6657 + static int init_display(struct fbtft_par *par)
6658 + {
6659 +- if (par->gpio.cs)
6660 +- gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
6661 +-
6662 + par->fbtftops.reset(par);
6663 +
6664 + /* Initialization sequence from Lib_UTFT */
6665 +diff --git a/drivers/staging/fbtft/fb_ili9163.c b/drivers/staging/fbtft/fb_ili9163.c
6666 +index 05648c3ffe474..6582a2c90aafc 100644
6667 +--- a/drivers/staging/fbtft/fb_ili9163.c
6668 ++++ b/drivers/staging/fbtft/fb_ili9163.c
6669 +@@ -11,7 +11,6 @@
6670 + #include <linux/module.h>
6671 + #include <linux/kernel.h>
6672 + #include <linux/init.h>
6673 +-#include <linux/gpio/consumer.h>
6674 + #include <linux/delay.h>
6675 + #include <video/mipi_display.h>
6676 +
6677 +@@ -77,9 +76,6 @@ static int init_display(struct fbtft_par *par)
6678 + {
6679 + par->fbtftops.reset(par);
6680 +
6681 +- if (par->gpio.cs)
6682 +- gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
6683 +-
6684 + write_reg(par, MIPI_DCS_SOFT_RESET); /* software reset */
6685 + mdelay(500);
6686 + write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE); /* exit sleep */
6687 +diff --git a/drivers/staging/fbtft/fb_ili9320.c b/drivers/staging/fbtft/fb_ili9320.c
6688 +index f2e72d14431db..a8f4c618b754c 100644
6689 +--- a/drivers/staging/fbtft/fb_ili9320.c
6690 ++++ b/drivers/staging/fbtft/fb_ili9320.c
6691 +@@ -8,7 +8,6 @@
6692 + #include <linux/module.h>
6693 + #include <linux/kernel.h>
6694 + #include <linux/init.h>
6695 +-#include <linux/gpio/consumer.h>
6696 + #include <linux/spi/spi.h>
6697 + #include <linux/delay.h>
6698 +
6699 +diff --git a/drivers/staging/fbtft/fb_ili9325.c b/drivers/staging/fbtft/fb_ili9325.c
6700 +index c9aa4cb431236..16d3b17ca2798 100644
6701 +--- a/drivers/staging/fbtft/fb_ili9325.c
6702 ++++ b/drivers/staging/fbtft/fb_ili9325.c
6703 +@@ -10,7 +10,6 @@
6704 + #include <linux/module.h>
6705 + #include <linux/kernel.h>
6706 + #include <linux/init.h>
6707 +-#include <linux/gpio/consumer.h>
6708 + #include <linux/delay.h>
6709 +
6710 + #include "fbtft.h"
6711 +@@ -85,9 +84,6 @@ static int init_display(struct fbtft_par *par)
6712 + {
6713 + par->fbtftops.reset(par);
6714 +
6715 +- if (par->gpio.cs)
6716 +- gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
6717 +-
6718 + bt &= 0x07;
6719 + vc &= 0x07;
6720 + vrh &= 0x0f;
6721 +diff --git a/drivers/staging/fbtft/fb_ili9340.c b/drivers/staging/fbtft/fb_ili9340.c
6722 +index 415183c7054a8..704236bcaf3ff 100644
6723 +--- a/drivers/staging/fbtft/fb_ili9340.c
6724 ++++ b/drivers/staging/fbtft/fb_ili9340.c
6725 +@@ -8,7 +8,6 @@
6726 + #include <linux/module.h>
6727 + #include <linux/kernel.h>
6728 + #include <linux/init.h>
6729 +-#include <linux/gpio/consumer.h>
6730 + #include <linux/delay.h>
6731 + #include <video/mipi_display.h>
6732 +
6733 +diff --git a/drivers/staging/fbtft/fb_s6d1121.c b/drivers/staging/fbtft/fb_s6d1121.c
6734 +index 8c7de32903434..62f27172f8449 100644
6735 +--- a/drivers/staging/fbtft/fb_s6d1121.c
6736 ++++ b/drivers/staging/fbtft/fb_s6d1121.c
6737 +@@ -12,7 +12,6 @@
6738 + #include <linux/module.h>
6739 + #include <linux/kernel.h>
6740 + #include <linux/init.h>
6741 +-#include <linux/gpio/consumer.h>
6742 + #include <linux/delay.h>
6743 +
6744 + #include "fbtft.h"
6745 +@@ -29,9 +28,6 @@ static int init_display(struct fbtft_par *par)
6746 + {
6747 + par->fbtftops.reset(par);
6748 +
6749 +- if (par->gpio.cs)
6750 +- gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
6751 +-
6752 + /* Initialization sequence from Lib_UTFT */
6753 +
6754 + write_reg(par, 0x0011, 0x2004);
6755 +diff --git a/drivers/staging/fbtft/fb_sh1106.c b/drivers/staging/fbtft/fb_sh1106.c
6756 +index 6f7249493ea3b..7b9ab39e1c1a8 100644
6757 +--- a/drivers/staging/fbtft/fb_sh1106.c
6758 ++++ b/drivers/staging/fbtft/fb_sh1106.c
6759 +@@ -9,7 +9,6 @@
6760 + #include <linux/module.h>
6761 + #include <linux/kernel.h>
6762 + #include <linux/init.h>
6763 +-#include <linux/gpio/consumer.h>
6764 + #include <linux/delay.h>
6765 +
6766 + #include "fbtft.h"
6767 +diff --git a/drivers/staging/fbtft/fb_ssd1289.c b/drivers/staging/fbtft/fb_ssd1289.c
6768 +index 7a3fe022cc69d..f27bab38b3ec4 100644
6769 +--- a/drivers/staging/fbtft/fb_ssd1289.c
6770 ++++ b/drivers/staging/fbtft/fb_ssd1289.c
6771 +@@ -10,7 +10,6 @@
6772 + #include <linux/module.h>
6773 + #include <linux/kernel.h>
6774 + #include <linux/init.h>
6775 +-#include <linux/gpio/consumer.h>
6776 +
6777 + #include "fbtft.h"
6778 +
6779 +@@ -28,9 +27,6 @@ static int init_display(struct fbtft_par *par)
6780 + {
6781 + par->fbtftops.reset(par);
6782 +
6783 +- if (par->gpio.cs)
6784 +- gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
6785 +-
6786 + write_reg(par, 0x00, 0x0001);
6787 + write_reg(par, 0x03, 0xA8A4);
6788 + write_reg(par, 0x0C, 0x0000);
6789 +diff --git a/drivers/staging/fbtft/fb_ssd1325.c b/drivers/staging/fbtft/fb_ssd1325.c
6790 +index 8a3140d41d8bb..796a2ac3e1948 100644
6791 +--- a/drivers/staging/fbtft/fb_ssd1325.c
6792 ++++ b/drivers/staging/fbtft/fb_ssd1325.c
6793 +@@ -35,8 +35,6 @@ static int init_display(struct fbtft_par *par)
6794 + {
6795 + par->fbtftops.reset(par);
6796 +
6797 +- gpiod_set_value(par->gpio.cs, 0);
6798 +-
6799 + write_reg(par, 0xb3);
6800 + write_reg(par, 0xf0);
6801 + write_reg(par, 0xae);
6802 +diff --git a/drivers/staging/fbtft/fb_ssd1331.c b/drivers/staging/fbtft/fb_ssd1331.c
6803 +index 37622c9462aa7..ec5eced7f8cbd 100644
6804 +--- a/drivers/staging/fbtft/fb_ssd1331.c
6805 ++++ b/drivers/staging/fbtft/fb_ssd1331.c
6806 +@@ -81,8 +81,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
6807 + va_start(args, len);
6808 +
6809 + *buf = (u8)va_arg(args, unsigned int);
6810 +- if (par->gpio.dc)
6811 +- gpiod_set_value(par->gpio.dc, 0);
6812 ++ gpiod_set_value(par->gpio.dc, 0);
6813 + ret = par->fbtftops.write(par, par->buf, sizeof(u8));
6814 + if (ret < 0) {
6815 + va_end(args);
6816 +@@ -104,8 +103,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
6817 + return;
6818 + }
6819 + }
6820 +- if (par->gpio.dc)
6821 +- gpiod_set_value(par->gpio.dc, 1);
6822 ++ gpiod_set_value(par->gpio.dc, 1);
6823 + va_end(args);
6824 + }
6825 +
6826 +diff --git a/drivers/staging/fbtft/fb_ssd1351.c b/drivers/staging/fbtft/fb_ssd1351.c
6827 +index 900b28d826b28..cf263a58a1489 100644
6828 +--- a/drivers/staging/fbtft/fb_ssd1351.c
6829 ++++ b/drivers/staging/fbtft/fb_ssd1351.c
6830 +@@ -2,7 +2,6 @@
6831 + #include <linux/module.h>
6832 + #include <linux/kernel.h>
6833 + #include <linux/init.h>
6834 +-#include <linux/gpio/consumer.h>
6835 + #include <linux/spi/spi.h>
6836 + #include <linux/delay.h>
6837 +
6838 +diff --git a/drivers/staging/fbtft/fb_upd161704.c b/drivers/staging/fbtft/fb_upd161704.c
6839 +index c77832ae5e5ba..c680160d63807 100644
6840 +--- a/drivers/staging/fbtft/fb_upd161704.c
6841 ++++ b/drivers/staging/fbtft/fb_upd161704.c
6842 +@@ -12,7 +12,6 @@
6843 + #include <linux/module.h>
6844 + #include <linux/kernel.h>
6845 + #include <linux/init.h>
6846 +-#include <linux/gpio/consumer.h>
6847 + #include <linux/delay.h>
6848 +
6849 + #include "fbtft.h"
6850 +@@ -26,9 +25,6 @@ static int init_display(struct fbtft_par *par)
6851 + {
6852 + par->fbtftops.reset(par);
6853 +
6854 +- if (par->gpio.cs)
6855 +- gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
6856 +-
6857 + /* Initialization sequence from Lib_UTFT */
6858 +
6859 + /* register reset */
6860 +diff --git a/drivers/staging/fbtft/fb_watterott.c b/drivers/staging/fbtft/fb_watterott.c
6861 +index 27cc8eabcbe9d..fc65ce8761558 100644
6862 +--- a/drivers/staging/fbtft/fb_watterott.c
6863 ++++ b/drivers/staging/fbtft/fb_watterott.c
6864 +@@ -8,7 +8,6 @@
6865 + #include <linux/module.h>
6866 + #include <linux/kernel.h>
6867 + #include <linux/init.h>
6868 +-#include <linux/gpio/consumer.h>
6869 + #include <linux/delay.h>
6870 +
6871 + #include "fbtft.h"
6872 +diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c
6873 +index 63c65dd67b175..3d422bc116411 100644
6874 +--- a/drivers/staging/fbtft/fbtft-bus.c
6875 ++++ b/drivers/staging/fbtft/fbtft-bus.c
6876 +@@ -135,8 +135,7 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
6877 + remain = len / 2;
6878 + vmem16 = (u16 *)(par->info->screen_buffer + offset);
6879 +
6880 +- if (par->gpio.dc)
6881 +- gpiod_set_value(par->gpio.dc, 1);
6882 ++ gpiod_set_value(par->gpio.dc, 1);
6883 +
6884 + /* non buffered write */
6885 + if (!par->txbuf.buf)
6886 +diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
6887 +index 61f0286fb157e..bc53d68bfcaa3 100644
6888 +--- a/drivers/staging/fbtft/fbtft-core.c
6889 ++++ b/drivers/staging/fbtft/fbtft-core.c
6890 +@@ -37,8 +37,7 @@ int fbtft_write_buf_dc(struct fbtft_par *par, void *buf, size_t len, int dc)
6891 + {
6892 + int ret;
6893 +
6894 +- if (par->gpio.dc)
6895 +- gpiod_set_value(par->gpio.dc, dc);
6896 ++ gpiod_set_value(par->gpio.dc, dc);
6897 +
6898 + ret = par->fbtftops.write(par, buf, len);
6899 + if (ret < 0)
6900 +@@ -79,7 +78,7 @@ static int fbtft_request_one_gpio(struct fbtft_par *par,
6901 + int ret = 0;
6902 +
6903 + *gpiop = devm_gpiod_get_index_optional(dev, name, index,
6904 +- GPIOD_OUT_HIGH);
6905 ++ GPIOD_OUT_LOW);
6906 + if (IS_ERR(*gpiop)) {
6907 + ret = PTR_ERR(*gpiop);
6908 + dev_err(dev,
6909 +@@ -230,11 +229,15 @@ static void fbtft_reset(struct fbtft_par *par)
6910 + {
6911 + if (!par->gpio.reset)
6912 + return;
6913 ++
6914 + fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
6915 ++
6916 + gpiod_set_value_cansleep(par->gpio.reset, 1);
6917 + usleep_range(20, 40);
6918 + gpiod_set_value_cansleep(par->gpio.reset, 0);
6919 + msleep(120);
6920 ++
6921 ++ gpiod_set_value_cansleep(par->gpio.cs, 1); /* Activate chip */
6922 + }
6923 +
6924 + static void fbtft_update_display(struct fbtft_par *par, unsigned int start_line,
6925 +@@ -921,8 +924,6 @@ static int fbtft_init_display_dt(struct fbtft_par *par)
6926 + return -EINVAL;
6927 +
6928 + par->fbtftops.reset(par);
6929 +- if (par->gpio.cs)
6930 +- gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
6931 +
6932 + while (p) {
6933 + if (val & FBTFT_OF_INIT_CMD) {
6934 +@@ -1012,8 +1013,6 @@ int fbtft_init_display(struct fbtft_par *par)
6935 + }
6936 +
6937 + par->fbtftops.reset(par);
6938 +- if (par->gpio.cs)
6939 +- gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
6940 +
6941 + i = 0;
6942 + while (i < FBTFT_MAX_INIT_SEQUENCE) {
6943 +diff --git a/drivers/staging/fbtft/fbtft-io.c b/drivers/staging/fbtft/fbtft-io.c
6944 +index 0863d257d7620..de1904a443c27 100644
6945 +--- a/drivers/staging/fbtft/fbtft-io.c
6946 ++++ b/drivers/staging/fbtft/fbtft-io.c
6947 +@@ -142,12 +142,12 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len)
6948 + data = *(u8 *)buf;
6949 +
6950 + /* Start writing by pulling down /WR */
6951 +- gpiod_set_value(par->gpio.wr, 0);
6952 ++ gpiod_set_value(par->gpio.wr, 1);
6953 +
6954 + /* Set data */
6955 + #ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO
6956 + if (data == prev_data) {
6957 +- gpiod_set_value(par->gpio.wr, 0); /* used as delay */
6958 ++ gpiod_set_value(par->gpio.wr, 1); /* used as delay */
6959 + } else {
6960 + for (i = 0; i < 8; i++) {
6961 + if ((data & 1) != (prev_data & 1))
6962 +@@ -165,7 +165,7 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len)
6963 + #endif
6964 +
6965 + /* Pullup /WR */
6966 +- gpiod_set_value(par->gpio.wr, 1);
6967 ++ gpiod_set_value(par->gpio.wr, 0);
6968 +
6969 + #ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO
6970 + prev_data = *(u8 *)buf;
6971 +@@ -192,12 +192,12 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len)
6972 + data = *(u16 *)buf;
6973 +
6974 + /* Start writing by pulling down /WR */
6975 +- gpiod_set_value(par->gpio.wr, 0);
6976 ++ gpiod_set_value(par->gpio.wr, 1);
6977 +
6978 + /* Set data */
6979 + #ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO
6980 + if (data == prev_data) {
6981 +- gpiod_set_value(par->gpio.wr, 0); /* used as delay */
6982 ++ gpiod_set_value(par->gpio.wr, 1); /* used as delay */
6983 + } else {
6984 + for (i = 0; i < 16; i++) {
6985 + if ((data & 1) != (prev_data & 1))
6986 +@@ -215,7 +215,7 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len)
6987 + #endif
6988 +
6989 + /* Pullup /WR */
6990 +- gpiod_set_value(par->gpio.wr, 1);
6991 ++ gpiod_set_value(par->gpio.wr, 0);
6992 +
6993 + #ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO
6994 + prev_data = *(u16 *)buf;
6995 +diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c
6996 +index db11498f6fc7d..8093d06086388 100644
6997 +--- a/drivers/staging/gdm724x/gdm_lte.c
6998 ++++ b/drivers/staging/gdm724x/gdm_lte.c
6999 +@@ -611,10 +611,12 @@ static void gdm_lte_netif_rx(struct net_device *dev, char *buf,
7000 + * bytes (99,130,83,99 dec)
7001 + */
7002 + } __packed;
7003 +- void *addr = buf + sizeof(struct iphdr) +
7004 +- sizeof(struct udphdr) +
7005 +- offsetof(struct dhcp_packet, chaddr);
7006 +- ether_addr_copy(nic->dest_mac_addr, addr);
7007 ++ int offset = sizeof(struct iphdr) +
7008 ++ sizeof(struct udphdr) +
7009 ++ offsetof(struct dhcp_packet, chaddr);
7010 ++ if (offset + ETH_ALEN > len)
7011 ++ return;
7012 ++ ether_addr_copy(nic->dest_mac_addr, buf + offset);
7013 + }
7014 + }
7015 +
7016 +@@ -677,6 +679,7 @@ static void gdm_lte_multi_sdu_pkt(struct phy_dev *phy_dev, char *buf, int len)
7017 + struct sdu *sdu = NULL;
7018 + u8 endian = phy_dev->get_endian(phy_dev->priv_dev);
7019 + u8 *data = (u8 *)multi_sdu->data;
7020 ++ int copied;
7021 + u16 i = 0;
7022 + u16 num_packet;
7023 + u16 hci_len;
7024 +@@ -688,6 +691,12 @@ static void gdm_lte_multi_sdu_pkt(struct phy_dev *phy_dev, char *buf, int len)
7025 + num_packet = gdm_dev16_to_cpu(endian, multi_sdu->num_packet);
7026 +
7027 + for (i = 0; i < num_packet; i++) {
7028 ++ copied = data - multi_sdu->data;
7029 ++ if (len < copied + sizeof(*sdu)) {
7030 ++ pr_err("rx prevent buffer overflow");
7031 ++ return;
7032 ++ }
7033 ++
7034 + sdu = (struct sdu *)data;
7035 +
7036 + cmd_evt = gdm_dev16_to_cpu(endian, sdu->cmd_evt);
7037 +@@ -698,7 +707,8 @@ static void gdm_lte_multi_sdu_pkt(struct phy_dev *phy_dev, char *buf, int len)
7038 + pr_err("rx sdu wrong hci %04x\n", cmd_evt);
7039 + return;
7040 + }
7041 +- if (hci_len < 12) {
7042 ++ if (hci_len < 12 ||
7043 ++ len < copied + sizeof(*sdu) + (hci_len - 12)) {
7044 + pr_err("rx sdu invalid len %d\n", hci_len);
7045 + return;
7046 + }
7047 +diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
7048 +index 367e39f5b382b..40b7e60f4a472 100644
7049 +--- a/drivers/staging/media/imx/imx-media-csi.c
7050 ++++ b/drivers/staging/media/imx/imx-media-csi.c
7051 +@@ -753,9 +753,10 @@ static int csi_setup(struct csi_priv *priv)
7052 +
7053 + static int csi_start(struct csi_priv *priv)
7054 + {
7055 +- struct v4l2_fract *output_fi;
7056 ++ struct v4l2_fract *input_fi, *output_fi;
7057 + int ret;
7058 +
7059 ++ input_fi = &priv->frame_interval[CSI_SINK_PAD];
7060 + output_fi = &priv->frame_interval[priv->active_output_pad];
7061 +
7062 + /* start upstream */
7063 +@@ -764,6 +765,17 @@ static int csi_start(struct csi_priv *priv)
7064 + if (ret)
7065 + return ret;
7066 +
7067 ++ /* Skip first few frames from a BT.656 source */
7068 ++ if (priv->upstream_ep.bus_type == V4L2_MBUS_BT656) {
7069 ++ u32 delay_usec, bad_frames = 20;
7070 ++
7071 ++ delay_usec = DIV_ROUND_UP_ULL((u64)USEC_PER_SEC *
7072 ++ input_fi->numerator * bad_frames,
7073 ++ input_fi->denominator);
7074 ++
7075 ++ usleep_range(delay_usec, delay_usec + 1000);
7076 ++ }
7077 ++
7078 + if (priv->dest == IPU_CSI_DEST_IDMAC) {
7079 + ret = csi_idmac_start(priv);
7080 + if (ret)
7081 +diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
7082 +index 021bbd4203907..63bc78e4cac8f 100644
7083 +--- a/drivers/staging/media/imx/imx7-mipi-csis.c
7084 ++++ b/drivers/staging/media/imx/imx7-mipi-csis.c
7085 +@@ -528,13 +528,15 @@ static void mipi_csis_clear_counters(struct csi_state *state)
7086 +
7087 + static void mipi_csis_log_counters(struct csi_state *state, bool non_errors)
7088 + {
7089 +- int i = non_errors ? MIPI_CSIS_NUM_EVENTS : MIPI_CSIS_NUM_EVENTS - 4;
7090 ++ unsigned int num_events = non_errors ? MIPI_CSIS_NUM_EVENTS
7091 ++ : MIPI_CSIS_NUM_EVENTS - 6;
7092 + struct device *dev = &state->pdev->dev;
7093 + unsigned long flags;
7094 ++ unsigned int i;
7095 +
7096 + spin_lock_irqsave(&state->slock, flags);
7097 +
7098 +- for (i--; i >= 0; i--) {
7099 ++ for (i = 0; i < num_events; ++i) {
7100 + if (state->events[i].counter > 0 || state->debug)
7101 + dev_info(dev, "%s events: %d\n", state->events[i].name,
7102 + state->events[i].counter);
7103 +diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi
7104 +index a4c08110094b3..5ca8607c5dbbe 100644
7105 +--- a/drivers/staging/mt7621-dts/mt7621.dtsi
7106 ++++ b/drivers/staging/mt7621-dts/mt7621.dtsi
7107 +@@ -520,7 +520,7 @@
7108 +
7109 + bus-range = <0 255>;
7110 + ranges = <
7111 +- 0x02000000 0 0x00000000 0x60000000 0 0x10000000 /* pci memory */
7112 ++ 0x02000000 0 0x60000000 0x60000000 0 0x10000000 /* pci memory */
7113 + 0x01000000 0 0x00000000 0x1e160000 0 0x00010000 /* io space */
7114 + >;
7115 +
7116 +diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
7117 +index 42c0a3c947f19..301b99060bc27 100644
7118 +--- a/drivers/staging/rtl8712/hal_init.c
7119 ++++ b/drivers/staging/rtl8712/hal_init.c
7120 +@@ -40,7 +40,10 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
7121 + dev_err(&udev->dev, "r8712u: Firmware request failed\n");
7122 + usb_put_dev(udev);
7123 + usb_set_intfdata(usb_intf, NULL);
7124 ++ r8712_free_drv_sw(adapter);
7125 ++ adapter->dvobj_deinit(adapter);
7126 + complete(&adapter->rtl8712_fw_ready);
7127 ++ free_netdev(adapter->pnetdev);
7128 + return;
7129 + }
7130 + adapter->fw = firmware;
7131 +diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
7132 +index 2fcd65260f4c1..bc421925e84c2 100644
7133 +--- a/drivers/staging/rtl8712/usb_intf.c
7134 ++++ b/drivers/staging/rtl8712/usb_intf.c
7135 +@@ -380,13 +380,11 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
7136 + /* step 3.
7137 + * initialize the dvobj_priv
7138 + */
7139 +- if (!padapter->dvobj_init) {
7140 ++
7141 ++ status = padapter->dvobj_init(padapter);
7142 ++ if (status != _SUCCESS)
7143 + goto error;
7144 +- } else {
7145 +- status = padapter->dvobj_init(padapter);
7146 +- if (status != _SUCCESS)
7147 +- goto error;
7148 +- }
7149 ++
7150 + /* step 4. */
7151 + status = r8712_init_drv_sw(padapter);
7152 + if (status)
7153 +diff --git a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c
7154 +index 54bb1ebd8eb5c..1814c19f5bf62 100644
7155 +--- a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c
7156 ++++ b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c
7157 +@@ -265,12 +265,13 @@ void cxgbit_unmap_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
7158 + struct cxgbit_cmd *ccmd = iscsit_priv_cmd(cmd);
7159 +
7160 + if (ccmd->release) {
7161 +- struct cxgbi_task_tag_info *ttinfo = &ccmd->ttinfo;
7162 +-
7163 +- if (ttinfo->sgl) {
7164 ++ if (cmd->se_cmd.se_cmd_flags & SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC) {
7165 ++ put_page(sg_page(&ccmd->sg));
7166 ++ } else {
7167 + struct cxgbit_sock *csk = conn->context;
7168 + struct cxgbit_device *cdev = csk->com.cdev;
7169 + struct cxgbi_ppm *ppm = cdev2ppm(cdev);
7170 ++ struct cxgbi_task_tag_info *ttinfo = &ccmd->ttinfo;
7171 +
7172 + /* Abort the TCP conn if DDP is not complete to
7173 + * avoid any possibility of DDP after freeing
7174 +@@ -280,14 +281,14 @@ void cxgbit_unmap_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
7175 + cmd->se_cmd.data_length))
7176 + cxgbit_abort_conn(csk);
7177 +
7178 ++ if (unlikely(ttinfo->sgl)) {
7179 ++ dma_unmap_sg(&ppm->pdev->dev, ttinfo->sgl,
7180 ++ ttinfo->nents, DMA_FROM_DEVICE);
7181 ++ ttinfo->nents = 0;
7182 ++ ttinfo->sgl = NULL;
7183 ++ }
7184 + cxgbi_ppm_ppod_release(ppm, ttinfo->idx);
7185 +-
7186 +- dma_unmap_sg(&ppm->pdev->dev, ttinfo->sgl,
7187 +- ttinfo->nents, DMA_FROM_DEVICE);
7188 +- } else {
7189 +- put_page(sg_page(&ccmd->sg));
7190 + }
7191 +-
7192 + ccmd->release = false;
7193 + }
7194 + }
7195 +diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c
7196 +index 45a1bfa2f7351..c083a69105be6 100644
7197 +--- a/drivers/target/iscsi/cxgbit/cxgbit_target.c
7198 ++++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c
7199 +@@ -1013,17 +1013,18 @@ static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk)
7200 + struct scatterlist *sg_start;
7201 + struct iscsi_conn *conn = csk->conn;
7202 + struct iscsi_cmd *cmd = NULL;
7203 ++ struct cxgbit_cmd *ccmd;
7204 ++ struct cxgbi_task_tag_info *ttinfo;
7205 + struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
7206 + struct iscsi_data *hdr = (struct iscsi_data *)pdu_cb->hdr;
7207 + u32 data_offset = be32_to_cpu(hdr->offset);
7208 +- u32 data_len = pdu_cb->dlen;
7209 ++ u32 data_len = ntoh24(hdr->dlength);
7210 + int rc, sg_nents, sg_off;
7211 + bool dcrc_err = false;
7212 +
7213 + if (pdu_cb->flags & PDUCBF_RX_DDP_CMP) {
7214 + u32 offset = be32_to_cpu(hdr->offset);
7215 + u32 ddp_data_len;
7216 +- u32 payload_length = ntoh24(hdr->dlength);
7217 + bool success = false;
7218 +
7219 + cmd = iscsit_find_cmd_from_itt_or_dump(conn, hdr->itt, 0);
7220 +@@ -1038,7 +1039,7 @@ static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk)
7221 + cmd->data_sn = be32_to_cpu(hdr->datasn);
7222 +
7223 + rc = __iscsit_check_dataout_hdr(conn, (unsigned char *)hdr,
7224 +- cmd, payload_length, &success);
7225 ++ cmd, data_len, &success);
7226 + if (rc < 0)
7227 + return rc;
7228 + else if (!success)
7229 +@@ -1076,6 +1077,20 @@ static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk)
7230 + cxgbit_skb_copy_to_sg(csk->skb, sg_start, sg_nents, skip);
7231 + }
7232 +
7233 ++ ccmd = iscsit_priv_cmd(cmd);
7234 ++ ttinfo = &ccmd->ttinfo;
7235 ++
7236 ++ if (ccmd->release && ttinfo->sgl &&
7237 ++ (cmd->se_cmd.data_length == (cmd->write_data_done + data_len))) {
7238 ++ struct cxgbit_device *cdev = csk->com.cdev;
7239 ++ struct cxgbi_ppm *ppm = cdev2ppm(cdev);
7240 ++
7241 ++ dma_unmap_sg(&ppm->pdev->dev, ttinfo->sgl, ttinfo->nents,
7242 ++ DMA_FROM_DEVICE);
7243 ++ ttinfo->nents = 0;
7244 ++ ttinfo->sgl = NULL;
7245 ++ }
7246 ++
7247 + check_payload:
7248 +
7249 + rc = iscsit_check_dataout_payload(cmd, hdr, dcrc_err);
7250 +diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
7251 +index ed99948f3b7f7..af9b00918e4eb 100644
7252 +--- a/drivers/tty/nozomi.c
7253 ++++ b/drivers/tty/nozomi.c
7254 +@@ -1395,7 +1395,7 @@ static int nozomi_card_init(struct pci_dev *pdev,
7255 + NOZOMI_NAME, dc);
7256 + if (unlikely(ret)) {
7257 + dev_err(&pdev->dev, "can't request irq %d\n", pdev->irq);
7258 +- goto err_free_kfifo;
7259 ++ goto err_free_all_kfifo;
7260 + }
7261 +
7262 + DBG1("base_addr: %p", dc->base_addr);
7263 +@@ -1433,12 +1433,15 @@ static int nozomi_card_init(struct pci_dev *pdev,
7264 + return 0;
7265 +
7266 + err_free_tty:
7267 +- for (i = 0; i < MAX_PORT; ++i) {
7268 ++ for (i--; i >= 0; i--) {
7269 + tty_unregister_device(ntty_driver, dc->index_start + i);
7270 + tty_port_destroy(&dc->port[i].port);
7271 + }
7272 ++ free_irq(pdev->irq, dc);
7273 ++err_free_all_kfifo:
7274 ++ i = MAX_PORT;
7275 + err_free_kfifo:
7276 +- for (i = 0; i < MAX_PORT; i++)
7277 ++ for (i--; i >= PORT_MDM; i--)
7278 + kfifo_free(&dc->port[i].fifo_ul);
7279 + err_free_sbuf:
7280 + kfree(dc->send_buf);
7281 +diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
7282 +index 5b673077639ba..6e93aa3623d9b 100644
7283 +--- a/drivers/tty/serial/8250/8250_port.c
7284 ++++ b/drivers/tty/serial/8250/8250_port.c
7285 +@@ -2557,6 +2557,21 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port,
7286 + struct ktermios *old)
7287 + {
7288 + unsigned int tolerance = port->uartclk / 100;
7289 ++ unsigned int min;
7290 ++ unsigned int max;
7291 ++
7292 ++ /*
7293 ++ * Handle magic divisors for baud rates above baud_base on SMSC
7294 ++ * Super I/O chips. Enable custom rates of clk/4 and clk/8, but
7295 ++ * disable divisor values beyond 32767, which are unavailable.
7296 ++ */
7297 ++ if (port->flags & UPF_MAGIC_MULTIPLIER) {
7298 ++ min = port->uartclk / 16 / UART_DIV_MAX >> 1;
7299 ++ max = (port->uartclk + tolerance) / 4;
7300 ++ } else {
7301 ++ min = port->uartclk / 16 / UART_DIV_MAX;
7302 ++ max = (port->uartclk + tolerance) / 16;
7303 ++ }
7304 +
7305 + /*
7306 + * Ask the core to calculate the divisor for us.
7307 +@@ -2564,9 +2579,7 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port,
7308 + * slower than nominal still match standard baud rates without
7309 + * causing transmission errors.
7310 + */
7311 +- return uart_get_baud_rate(port, termios, old,
7312 +- port->uartclk / 16 / UART_DIV_MAX,
7313 +- (port->uartclk + tolerance) / 16);
7314 ++ return uart_get_baud_rate(port, termios, old, min, max);
7315 + }
7316 +
7317 + void
7318 +diff --git a/drivers/tty/serial/8250/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c
7319 +index c8186a05a453c..ccd1a615305b5 100644
7320 +--- a/drivers/tty/serial/8250/serial_cs.c
7321 ++++ b/drivers/tty/serial/8250/serial_cs.c
7322 +@@ -780,6 +780,7 @@ static const struct pcmcia_device_id serial_ids[] = {
7323 + PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT2834LT", 0x5f73be51, 0x4cd7c09e),
7324 + PCMCIA_DEVICE_PROD_ID12("OEM ", "C288MX ", 0xb572d360, 0xd2385b7a),
7325 + PCMCIA_DEVICE_PROD_ID12("Option International", "V34bis GSM/PSTN Data/Fax Modem", 0x9d7cd6f5, 0x5cb8bf41),
7326 ++ PCMCIA_DEVICE_PROD_ID12("Option International", "GSM-Ready 56K/ISDN", 0x9d7cd6f5, 0xb23844aa),
7327 + PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab),
7328 + PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f),
7329 + PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "Dual RS-232 Serial Port PC Card", 0xc4420b35, 0x031a380d),
7330 +@@ -807,7 +808,6 @@ static const struct pcmcia_device_id serial_ids[] = {
7331 + PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "cis/COMpad4.cis"),
7332 + PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "cis/COMpad2.cis"),
7333 + PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "cis/RS-COM-2P.cis"),
7334 +- PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "cis/GLOBETROTTER.cis"),
7335 + PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.", "SERIAL CARD: SL100 1.00.", 0x19ca78af, 0xf964f42b),
7336 + PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.", "SERIAL CARD: SL100", 0x19ca78af, 0x71d98e83),
7337 + PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.", "SERIAL CARD: SL232 1.00.", 0x19ca78af, 0x69fb7490),
7338 +diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
7339 +index 5e6f661943eb1..51b4d8d1dcaca 100644
7340 +--- a/drivers/tty/serial/mvebu-uart.c
7341 ++++ b/drivers/tty/serial/mvebu-uart.c
7342 +@@ -445,12 +445,11 @@ static void mvebu_uart_shutdown(struct uart_port *port)
7343 +
7344 + static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud)
7345 + {
7346 +- struct mvebu_uart *mvuart = to_mvuart(port);
7347 + unsigned int d_divisor, m_divisor;
7348 + u32 brdv, osamp;
7349 +
7350 +- if (IS_ERR(mvuart->clk))
7351 +- return -PTR_ERR(mvuart->clk);
7352 ++ if (!port->uartclk)
7353 ++ return -EOPNOTSUPP;
7354 +
7355 + /*
7356 + * The baudrate is derived from the UART clock thanks to two divisors:
7357 +@@ -463,7 +462,7 @@ static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud)
7358 + * makes use of D to configure the desired baudrate.
7359 + */
7360 + m_divisor = OSAMP_DEFAULT_DIVISOR;
7361 +- d_divisor = DIV_ROUND_UP(port->uartclk, baud * m_divisor);
7362 ++ d_divisor = DIV_ROUND_CLOSEST(port->uartclk, baud * m_divisor);
7363 +
7364 + brdv = readl(port->membase + UART_BRDV);
7365 + brdv &= ~BRDV_BAUD_MASK;
7366 +@@ -482,7 +481,7 @@ static void mvebu_uart_set_termios(struct uart_port *port,
7367 + struct ktermios *old)
7368 + {
7369 + unsigned long flags;
7370 +- unsigned int baud;
7371 ++ unsigned int baud, min_baud, max_baud;
7372 +
7373 + spin_lock_irqsave(&port->lock, flags);
7374 +
7375 +@@ -501,16 +500,21 @@ static void mvebu_uart_set_termios(struct uart_port *port,
7376 + port->ignore_status_mask |= STAT_RX_RDY(port) | STAT_BRK_ERR;
7377 +
7378 + /*
7379 ++ * Maximal divisor is 1023 * 16 when using default (x16) scheme.
7380 + * Maximum achievable frequency with simple baudrate divisor is 230400.
7381 + * Since the error per bit frame would be of more than 15%, achieving
7382 + * higher frequencies would require to implement the fractional divisor
7383 + * feature.
7384 + */
7385 +- baud = uart_get_baud_rate(port, termios, old, 0, 230400);
7386 ++ min_baud = DIV_ROUND_UP(port->uartclk, 1023 * 16);
7387 ++ max_baud = 230400;
7388 ++
7389 ++ baud = uart_get_baud_rate(port, termios, old, min_baud, max_baud);
7390 + if (mvebu_uart_baud_rate_set(port, baud)) {
7391 + /* No clock available, baudrate cannot be changed */
7392 + if (old)
7393 +- baud = uart_get_baud_rate(port, old, NULL, 0, 230400);
7394 ++ baud = uart_get_baud_rate(port, old, NULL,
7395 ++ min_baud, max_baud);
7396 + } else {
7397 + tty_termios_encode_baud_rate(termios, baud, baud);
7398 + uart_update_timeout(port, termios->c_cflag, baud);
7399 +diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
7400 +index de86e9021a8ff..97ee1fc1cd247 100644
7401 +--- a/drivers/tty/serial/sh-sci.c
7402 ++++ b/drivers/tty/serial/sh-sci.c
7403 +@@ -613,6 +613,14 @@ static void sci_stop_tx(struct uart_port *port)
7404 + ctrl &= ~SCSCR_TIE;
7405 +
7406 + serial_port_out(port, SCSCR, ctrl);
7407 ++
7408 ++#ifdef CONFIG_SERIAL_SH_SCI_DMA
7409 ++ if (to_sci_port(port)->chan_tx &&
7410 ++ !dma_submit_error(to_sci_port(port)->cookie_tx)) {
7411 ++ dmaengine_terminate_async(to_sci_port(port)->chan_tx);
7412 ++ to_sci_port(port)->cookie_tx = -EINVAL;
7413 ++ }
7414 ++#endif
7415 + }
7416 +
7417 + static void sci_start_rx(struct uart_port *port)
7418 +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
7419 +index 1e9aab6118f51..c0604c60ebd01 100644
7420 +--- a/drivers/usb/class/cdc-acm.c
7421 ++++ b/drivers/usb/class/cdc-acm.c
7422 +@@ -1960,6 +1960,11 @@ static const struct usb_device_id acm_ids[] = {
7423 + .driver_info = IGNORE_DEVICE,
7424 + },
7425 +
7426 ++ /* Exclude Heimann Sensor GmbH USB appset demo */
7427 ++ { USB_DEVICE(0x32a7, 0x0000),
7428 ++ .driver_info = IGNORE_DEVICE,
7429 ++ },
7430 ++
7431 + /* control interfaces without any protocol set */
7432 + { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
7433 + USB_CDC_PROTO_NONE) },
7434 +diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
7435 +index 78a4925aa1185..093980481c4d6 100644
7436 +--- a/drivers/usb/dwc2/core.c
7437 ++++ b/drivers/usb/dwc2/core.c
7438 +@@ -1152,15 +1152,6 @@ static int dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, bool select_phy)
7439 + usbcfg &= ~(GUSBCFG_ULPI_UTMI_SEL | GUSBCFG_PHYIF16);
7440 + if (hsotg->params.phy_utmi_width == 16)
7441 + usbcfg |= GUSBCFG_PHYIF16;
7442 +-
7443 +- /* Set turnaround time */
7444 +- if (dwc2_is_device_mode(hsotg)) {
7445 +- usbcfg &= ~GUSBCFG_USBTRDTIM_MASK;
7446 +- if (hsotg->params.phy_utmi_width == 16)
7447 +- usbcfg |= 5 << GUSBCFG_USBTRDTIM_SHIFT;
7448 +- else
7449 +- usbcfg |= 9 << GUSBCFG_USBTRDTIM_SHIFT;
7450 +- }
7451 + break;
7452 + default:
7453 + dev_err(hsotg->dev, "FS PHY selected at HS!\n");
7454 +@@ -1182,6 +1173,24 @@ static int dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, bool select_phy)
7455 + return retval;
7456 + }
7457 +
7458 ++static void dwc2_set_turnaround_time(struct dwc2_hsotg *hsotg)
7459 ++{
7460 ++ u32 usbcfg;
7461 ++
7462 ++ if (hsotg->params.phy_type != DWC2_PHY_TYPE_PARAM_UTMI)
7463 ++ return;
7464 ++
7465 ++ usbcfg = dwc2_readl(hsotg, GUSBCFG);
7466 ++
7467 ++ usbcfg &= ~GUSBCFG_USBTRDTIM_MASK;
7468 ++ if (hsotg->params.phy_utmi_width == 16)
7469 ++ usbcfg |= 5 << GUSBCFG_USBTRDTIM_SHIFT;
7470 ++ else
7471 ++ usbcfg |= 9 << GUSBCFG_USBTRDTIM_SHIFT;
7472 ++
7473 ++ dwc2_writel(hsotg, usbcfg, GUSBCFG);
7474 ++}
7475 ++
7476 + int dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy)
7477 + {
7478 + u32 usbcfg;
7479 +@@ -1199,6 +1208,9 @@ int dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy)
7480 + retval = dwc2_hs_phy_init(hsotg, select_phy);
7481 + if (retval)
7482 + return retval;
7483 ++
7484 ++ if (dwc2_is_device_mode(hsotg))
7485 ++ dwc2_set_turnaround_time(hsotg);
7486 + }
7487 +
7488 + if (hsotg->hw_params.hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI &&
7489 +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
7490 +index b9d4fc636b329..2c68ec60d39a3 100644
7491 +--- a/drivers/usb/dwc3/core.c
7492 ++++ b/drivers/usb/dwc3/core.c
7493 +@@ -1523,17 +1523,18 @@ static int dwc3_probe(struct platform_device *pdev)
7494 + }
7495 +
7496 + dwc3_check_params(dwc);
7497 ++ dwc3_debugfs_init(dwc);
7498 +
7499 + ret = dwc3_core_init_mode(dwc);
7500 + if (ret)
7501 + goto err5;
7502 +
7503 +- dwc3_debugfs_init(dwc);
7504 + pm_runtime_put(dev);
7505 +
7506 + return 0;
7507 +
7508 + err5:
7509 ++ dwc3_debugfs_exit(dwc);
7510 + dwc3_event_buffers_cleanup(dwc);
7511 +
7512 + usb_phy_shutdown(dwc->usb2_phy);
7513 +diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c
7514 +index 801090de1f7b3..95ef8bc726868 100644
7515 +--- a/drivers/usb/gadget/function/f_eem.c
7516 ++++ b/drivers/usb/gadget/function/f_eem.c
7517 +@@ -30,6 +30,11 @@ struct f_eem {
7518 + u8 ctrl_id;
7519 + };
7520 +
7521 ++struct in_context {
7522 ++ struct sk_buff *skb;
7523 ++ struct usb_ep *ep;
7524 ++};
7525 ++
7526 + static inline struct f_eem *func_to_eem(struct usb_function *f)
7527 + {
7528 + return container_of(f, struct f_eem, port.func);
7529 +@@ -322,9 +327,12 @@ fail:
7530 +
7531 + static void eem_cmd_complete(struct usb_ep *ep, struct usb_request *req)
7532 + {
7533 +- struct sk_buff *skb = (struct sk_buff *)req->context;
7534 ++ struct in_context *ctx = req->context;
7535 +
7536 +- dev_kfree_skb_any(skb);
7537 ++ dev_kfree_skb_any(ctx->skb);
7538 ++ kfree(req->buf);
7539 ++ usb_ep_free_request(ctx->ep, req);
7540 ++ kfree(ctx);
7541 + }
7542 +
7543 + /*
7544 +@@ -412,7 +420,9 @@ static int eem_unwrap(struct gether *port,
7545 + * b15: bmType (0 == data, 1 == command)
7546 + */
7547 + if (header & BIT(15)) {
7548 +- struct usb_request *req = cdev->req;
7549 ++ struct usb_request *req;
7550 ++ struct in_context *ctx;
7551 ++ struct usb_ep *ep;
7552 + u16 bmEEMCmd;
7553 +
7554 + /* EEM command packet format:
7555 +@@ -441,11 +451,36 @@ static int eem_unwrap(struct gether *port,
7556 + skb_trim(skb2, len);
7557 + put_unaligned_le16(BIT(15) | BIT(11) | len,
7558 + skb_push(skb2, 2));
7559 ++
7560 ++ ep = port->in_ep;
7561 ++ req = usb_ep_alloc_request(ep, GFP_ATOMIC);
7562 ++ if (!req) {
7563 ++ dev_kfree_skb_any(skb2);
7564 ++ goto next;
7565 ++ }
7566 ++
7567 ++ req->buf = kmalloc(skb2->len, GFP_KERNEL);
7568 ++ if (!req->buf) {
7569 ++ usb_ep_free_request(ep, req);
7570 ++ dev_kfree_skb_any(skb2);
7571 ++ goto next;
7572 ++ }
7573 ++
7574 ++ ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
7575 ++ if (!ctx) {
7576 ++ kfree(req->buf);
7577 ++ usb_ep_free_request(ep, req);
7578 ++ dev_kfree_skb_any(skb2);
7579 ++ goto next;
7580 ++ }
7581 ++ ctx->skb = skb2;
7582 ++ ctx->ep = ep;
7583 ++
7584 + skb_copy_bits(skb2, 0, req->buf, skb2->len);
7585 + req->length = skb2->len;
7586 + req->complete = eem_cmd_complete;
7587 + req->zero = 1;
7588 +- req->context = skb2;
7589 ++ req->context = ctx;
7590 + if (usb_ep_queue(port->in_ep, req, GFP_ATOMIC))
7591 + DBG(cdev, "echo response queue fail\n");
7592 + break;
7593 +diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
7594 +index 3126f5b08bd4f..94ccf43368dfc 100644
7595 +--- a/drivers/usb/gadget/function/f_fs.c
7596 ++++ b/drivers/usb/gadget/function/f_fs.c
7597 +@@ -250,8 +250,8 @@ EXPORT_SYMBOL_GPL(ffs_lock);
7598 + static struct ffs_dev *_ffs_find_dev(const char *name);
7599 + static struct ffs_dev *_ffs_alloc_dev(void);
7600 + static void _ffs_free_dev(struct ffs_dev *dev);
7601 +-static void *ffs_acquire_dev(const char *dev_name);
7602 +-static void ffs_release_dev(struct ffs_data *ffs_data);
7603 ++static int ffs_acquire_dev(const char *dev_name, struct ffs_data *ffs_data);
7604 ++static void ffs_release_dev(struct ffs_dev *ffs_dev);
7605 + static int ffs_ready(struct ffs_data *ffs);
7606 + static void ffs_closed(struct ffs_data *ffs);
7607 +
7608 +@@ -1572,8 +1572,8 @@ unmapped_value:
7609 + static int ffs_fs_get_tree(struct fs_context *fc)
7610 + {
7611 + struct ffs_sb_fill_data *ctx = fc->fs_private;
7612 +- void *ffs_dev;
7613 + struct ffs_data *ffs;
7614 ++ int ret;
7615 +
7616 + ENTER();
7617 +
7618 +@@ -1592,13 +1592,12 @@ static int ffs_fs_get_tree(struct fs_context *fc)
7619 + return -ENOMEM;
7620 + }
7621 +
7622 +- ffs_dev = ffs_acquire_dev(ffs->dev_name);
7623 +- if (IS_ERR(ffs_dev)) {
7624 ++ ret = ffs_acquire_dev(ffs->dev_name, ffs);
7625 ++ if (ret) {
7626 + ffs_data_put(ffs);
7627 +- return PTR_ERR(ffs_dev);
7628 ++ return ret;
7629 + }
7630 +
7631 +- ffs->private_data = ffs_dev;
7632 + ctx->ffs_data = ffs;
7633 + return get_tree_nodev(fc, ffs_sb_fill);
7634 + }
7635 +@@ -1609,7 +1608,6 @@ static void ffs_fs_free_fc(struct fs_context *fc)
7636 +
7637 + if (ctx) {
7638 + if (ctx->ffs_data) {
7639 +- ffs_release_dev(ctx->ffs_data);
7640 + ffs_data_put(ctx->ffs_data);
7641 + }
7642 +
7643 +@@ -1648,10 +1646,8 @@ ffs_fs_kill_sb(struct super_block *sb)
7644 + ENTER();
7645 +
7646 + kill_litter_super(sb);
7647 +- if (sb->s_fs_info) {
7648 +- ffs_release_dev(sb->s_fs_info);
7649 ++ if (sb->s_fs_info)
7650 + ffs_data_closed(sb->s_fs_info);
7651 +- }
7652 + }
7653 +
7654 + static struct file_system_type ffs_fs_type = {
7655 +@@ -1721,6 +1717,7 @@ static void ffs_data_put(struct ffs_data *ffs)
7656 + if (unlikely(refcount_dec_and_test(&ffs->ref))) {
7657 + pr_info("%s(): freeing\n", __func__);
7658 + ffs_data_clear(ffs);
7659 ++ ffs_release_dev(ffs->private_data);
7660 + BUG_ON(waitqueue_active(&ffs->ev.waitq) ||
7661 + waitqueue_active(&ffs->ep0req_completion.wait) ||
7662 + waitqueue_active(&ffs->wait));
7663 +@@ -3050,6 +3047,7 @@ static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f,
7664 + struct ffs_function *func = ffs_func_from_usb(f);
7665 + struct f_fs_opts *ffs_opts =
7666 + container_of(f->fi, struct f_fs_opts, func_inst);
7667 ++ struct ffs_data *ffs_data;
7668 + int ret;
7669 +
7670 + ENTER();
7671 +@@ -3064,12 +3062,13 @@ static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f,
7672 + if (!ffs_opts->no_configfs)
7673 + ffs_dev_lock();
7674 + ret = ffs_opts->dev->desc_ready ? 0 : -ENODEV;
7675 +- func->ffs = ffs_opts->dev->ffs_data;
7676 ++ ffs_data = ffs_opts->dev->ffs_data;
7677 + if (!ffs_opts->no_configfs)
7678 + ffs_dev_unlock();
7679 + if (ret)
7680 + return ERR_PTR(ret);
7681 +
7682 ++ func->ffs = ffs_data;
7683 + func->conf = c;
7684 + func->gadget = c->cdev->gadget;
7685 +
7686 +@@ -3524,6 +3523,7 @@ static void ffs_free_inst(struct usb_function_instance *f)
7687 + struct f_fs_opts *opts;
7688 +
7689 + opts = to_f_fs_opts(f);
7690 ++ ffs_release_dev(opts->dev);
7691 + ffs_dev_lock();
7692 + _ffs_free_dev(opts->dev);
7693 + ffs_dev_unlock();
7694 +@@ -3711,47 +3711,48 @@ static void _ffs_free_dev(struct ffs_dev *dev)
7695 + {
7696 + list_del(&dev->entry);
7697 +
7698 +- /* Clear the private_data pointer to stop incorrect dev access */
7699 +- if (dev->ffs_data)
7700 +- dev->ffs_data->private_data = NULL;
7701 +-
7702 + kfree(dev);
7703 + if (list_empty(&ffs_devices))
7704 + functionfs_cleanup();
7705 + }
7706 +
7707 +-static void *ffs_acquire_dev(const char *dev_name)
7708 ++static int ffs_acquire_dev(const char *dev_name, struct ffs_data *ffs_data)
7709 + {
7710 ++ int ret = 0;
7711 + struct ffs_dev *ffs_dev;
7712 +
7713 + ENTER();
7714 + ffs_dev_lock();
7715 +
7716 + ffs_dev = _ffs_find_dev(dev_name);
7717 +- if (!ffs_dev)
7718 +- ffs_dev = ERR_PTR(-ENOENT);
7719 +- else if (ffs_dev->mounted)
7720 +- ffs_dev = ERR_PTR(-EBUSY);
7721 +- else if (ffs_dev->ffs_acquire_dev_callback &&
7722 +- ffs_dev->ffs_acquire_dev_callback(ffs_dev))
7723 +- ffs_dev = ERR_PTR(-ENOENT);
7724 +- else
7725 ++ if (!ffs_dev) {
7726 ++ ret = -ENOENT;
7727 ++ } else if (ffs_dev->mounted) {
7728 ++ ret = -EBUSY;
7729 ++ } else if (ffs_dev->ffs_acquire_dev_callback &&
7730 ++ ffs_dev->ffs_acquire_dev_callback(ffs_dev)) {
7731 ++ ret = -ENOENT;
7732 ++ } else {
7733 + ffs_dev->mounted = true;
7734 ++ ffs_dev->ffs_data = ffs_data;
7735 ++ ffs_data->private_data = ffs_dev;
7736 ++ }
7737 +
7738 + ffs_dev_unlock();
7739 +- return ffs_dev;
7740 ++ return ret;
7741 + }
7742 +
7743 +-static void ffs_release_dev(struct ffs_data *ffs_data)
7744 ++static void ffs_release_dev(struct ffs_dev *ffs_dev)
7745 + {
7746 +- struct ffs_dev *ffs_dev;
7747 +-
7748 + ENTER();
7749 + ffs_dev_lock();
7750 +
7751 +- ffs_dev = ffs_data->private_data;
7752 +- if (ffs_dev) {
7753 ++ if (ffs_dev && ffs_dev->mounted) {
7754 + ffs_dev->mounted = false;
7755 ++ if (ffs_dev->ffs_data) {
7756 ++ ffs_dev->ffs_data->private_data = NULL;
7757 ++ ffs_dev->ffs_data = NULL;
7758 ++ }
7759 +
7760 + if (ffs_dev->ffs_release_dev_callback)
7761 + ffs_dev->ffs_release_dev_callback(ffs_dev);
7762 +@@ -3779,7 +3780,6 @@ static int ffs_ready(struct ffs_data *ffs)
7763 + }
7764 +
7765 + ffs_obj->desc_ready = true;
7766 +- ffs_obj->ffs_data = ffs;
7767 +
7768 + if (ffs_obj->ffs_ready_callback) {
7769 + ret = ffs_obj->ffs_ready_callback(ffs);
7770 +@@ -3807,7 +3807,6 @@ static void ffs_closed(struct ffs_data *ffs)
7771 + goto done;
7772 +
7773 + ffs_obj->desc_ready = false;
7774 +- ffs_obj->ffs_data = NULL;
7775 +
7776 + if (test_and_clear_bit(FFS_FL_CALL_CLOSED_CALLBACK, &ffs->flags) &&
7777 + ffs_obj->ffs_closed_callback)
7778 +diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
7779 +index 7f9f302a73cdf..160caef09c5ea 100644
7780 +--- a/drivers/usb/host/xhci-mem.c
7781 ++++ b/drivers/usb/host/xhci-mem.c
7782 +@@ -1929,6 +1929,7 @@ no_bw:
7783 + xhci->hw_ports = NULL;
7784 + xhci->rh_bw = NULL;
7785 + xhci->ext_caps = NULL;
7786 ++ xhci->port_caps = NULL;
7787 +
7788 + xhci->page_size = 0;
7789 + xhci->page_shift = 0;
7790 +diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
7791 +index a400b65cf17bb..526509ed92e5c 100644
7792 +--- a/drivers/usb/typec/class.c
7793 ++++ b/drivers/usb/typec/class.c
7794 +@@ -487,8 +487,10 @@ typec_register_altmode(struct device *parent,
7795 + int ret;
7796 +
7797 + alt = kzalloc(sizeof(*alt), GFP_KERNEL);
7798 +- if (!alt)
7799 ++ if (!alt) {
7800 ++ altmode_id_remove(parent, id);
7801 + return ERR_PTR(-ENOMEM);
7802 ++ }
7803 +
7804 + alt->adev.svid = desc->svid;
7805 + alt->adev.mode = desc->mode;
7806 +diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
7807 +index a603f363835c4..b06d76216599e 100644
7808 +--- a/drivers/vfio/pci/vfio_pci.c
7809 ++++ b/drivers/vfio/pci/vfio_pci.c
7810 +@@ -1430,6 +1430,7 @@ static vm_fault_t vfio_pci_mmap_fault(struct vm_fault *vmf)
7811 + {
7812 + struct vm_area_struct *vma = vmf->vma;
7813 + struct vfio_pci_device *vdev = vma->vm_private_data;
7814 ++ struct vfio_pci_mmap_vma *mmap_vma;
7815 + vm_fault_t ret = VM_FAULT_NOPAGE;
7816 +
7817 + mutex_lock(&vdev->vma_lock);
7818 +@@ -1437,24 +1438,36 @@ static vm_fault_t vfio_pci_mmap_fault(struct vm_fault *vmf)
7819 +
7820 + if (!__vfio_pci_memory_enabled(vdev)) {
7821 + ret = VM_FAULT_SIGBUS;
7822 +- mutex_unlock(&vdev->vma_lock);
7823 + goto up_out;
7824 + }
7825 +
7826 +- if (__vfio_pci_add_vma(vdev, vma)) {
7827 +- ret = VM_FAULT_OOM;
7828 +- mutex_unlock(&vdev->vma_lock);
7829 +- goto up_out;
7830 ++ /*
7831 ++ * We populate the whole vma on fault, so we need to test whether
7832 ++ * the vma has already been mapped, such as for concurrent faults
7833 ++ * to the same vma. io_remap_pfn_range() will trigger a BUG_ON if
7834 ++ * we ask it to fill the same range again.
7835 ++ */
7836 ++ list_for_each_entry(mmap_vma, &vdev->vma_list, vma_next) {
7837 ++ if (mmap_vma->vma == vma)
7838 ++ goto up_out;
7839 + }
7840 +
7841 +- mutex_unlock(&vdev->vma_lock);
7842 +-
7843 + if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
7844 +- vma->vm_end - vma->vm_start, vma->vm_page_prot))
7845 ++ vma->vm_end - vma->vm_start,
7846 ++ vma->vm_page_prot)) {
7847 + ret = VM_FAULT_SIGBUS;
7848 ++ zap_vma_ptes(vma, vma->vm_start, vma->vm_end - vma->vm_start);
7849 ++ goto up_out;
7850 ++ }
7851 ++
7852 ++ if (__vfio_pci_add_vma(vdev, vma)) {
7853 ++ ret = VM_FAULT_OOM;
7854 ++ zap_vma_ptes(vma, vma->vm_start, vma->vm_end - vma->vm_start);
7855 ++ }
7856 +
7857 + up_out:
7858 + up_read(&vdev->memory_lock);
7859 ++ mutex_unlock(&vdev->vma_lock);
7860 + return ret;
7861 + }
7862 +
7863 +diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c
7864 +index 2d8e8192e4e29..f03ffe2bb2376 100644
7865 +--- a/drivers/video/backlight/lm3630a_bl.c
7866 ++++ b/drivers/video/backlight/lm3630a_bl.c
7867 +@@ -480,8 +480,10 @@ static int lm3630a_parse_node(struct lm3630a_chip *pchip,
7868 +
7869 + device_for_each_child_node(pchip->dev, node) {
7870 + ret = lm3630a_parse_bank(pdata, node, &seen_led_sources);
7871 +- if (ret)
7872 ++ if (ret) {
7873 ++ fwnode_handle_put(node);
7874 + return ret;
7875 ++ }
7876 + }
7877 +
7878 + return ret;
7879 +diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c
7880 +index b3286d1fa5439..ffde3107104bc 100644
7881 +--- a/drivers/video/fbdev/imxfb.c
7882 ++++ b/drivers/video/fbdev/imxfb.c
7883 +@@ -977,7 +977,7 @@ static int imxfb_probe(struct platform_device *pdev)
7884 + info->screen_buffer = dma_alloc_wc(&pdev->dev, fbi->map_size,
7885 + &fbi->map_dma, GFP_KERNEL);
7886 + if (!info->screen_buffer) {
7887 +- dev_err(&pdev->dev, "Failed to allocate video RAM: %d\n", ret);
7888 ++ dev_err(&pdev->dev, "Failed to allocate video RAM\n");
7889 + ret = -ENOMEM;
7890 + goto failed_map;
7891 + }
7892 +diff --git a/drivers/visorbus/visorchipset.c b/drivers/visorbus/visorchipset.c
7893 +index cb1eb7e05f871..5668cad86e374 100644
7894 +--- a/drivers/visorbus/visorchipset.c
7895 ++++ b/drivers/visorbus/visorchipset.c
7896 +@@ -1561,7 +1561,7 @@ schedule_out:
7897 +
7898 + static int visorchipset_init(struct acpi_device *acpi_device)
7899 + {
7900 +- int err = -ENODEV;
7901 ++ int err = -ENOMEM;
7902 + struct visorchannel *controlvm_channel;
7903 +
7904 + chipset_dev = kzalloc(sizeof(*chipset_dev), GFP_KERNEL);
7905 +@@ -1584,8 +1584,10 @@ static int visorchipset_init(struct acpi_device *acpi_device)
7906 + "controlvm",
7907 + sizeof(struct visor_controlvm_channel),
7908 + VISOR_CONTROLVM_CHANNEL_VERSIONID,
7909 +- VISOR_CHANNEL_SIGNATURE))
7910 ++ VISOR_CHANNEL_SIGNATURE)) {
7911 ++ err = -ENODEV;
7912 + goto error_delete_groups;
7913 ++ }
7914 + /* if booting in a crash kernel */
7915 + if (is_kdump_kernel())
7916 + INIT_DELAYED_WORK(&chipset_dev->periodic_controlvm_work,
7917 +diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig
7918 +index 38651fae7f21a..0aa1bee24d807 100644
7919 +--- a/fs/btrfs/Kconfig
7920 ++++ b/fs/btrfs/Kconfig
7921 +@@ -14,6 +14,8 @@ config BTRFS_FS
7922 + select RAID6_PQ
7923 + select XOR_BLOCKS
7924 + select SRCU
7925 ++ depends on !PPC_256K_PAGES # powerpc
7926 ++ depends on !PAGE_SIZE_256KB # hexagon
7927 +
7928 + help
7929 + Btrfs is a general purpose copy-on-write filesystem with extents,
7930 +diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
7931 +index 7dad8794ee388..3dccbbe4a6585 100644
7932 +--- a/fs/btrfs/delayed-inode.c
7933 ++++ b/fs/btrfs/delayed-inode.c
7934 +@@ -1033,12 +1033,10 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
7935 + nofs_flag = memalloc_nofs_save();
7936 + ret = btrfs_lookup_inode(trans, root, path, &key, mod);
7937 + memalloc_nofs_restore(nofs_flag);
7938 +- if (ret > 0) {
7939 +- btrfs_release_path(path);
7940 +- return -ENOENT;
7941 +- } else if (ret < 0) {
7942 +- return ret;
7943 +- }
7944 ++ if (ret > 0)
7945 ++ ret = -ENOENT;
7946 ++ if (ret < 0)
7947 ++ goto out;
7948 +
7949 + leaf = path->nodes[0];
7950 + inode_item = btrfs_item_ptr(leaf, path->slots[0],
7951 +@@ -1076,6 +1074,14 @@ err_out:
7952 + btrfs_delayed_inode_release_metadata(fs_info, node, (ret < 0));
7953 + btrfs_release_delayed_inode(node);
7954 +
7955 ++ /*
7956 ++ * If we fail to update the delayed inode we need to abort the
7957 ++ * transaction, because we could leave the inode with the improper
7958 ++ * counts behind.
7959 ++ */
7960 ++ if (ret && ret != -ENOENT)
7961 ++ btrfs_abort_transaction(trans, ret);
7962 ++
7963 + return ret;
7964 +
7965 + search:
7966 +diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
7967 +index ecdefa7262d2b..fc688af57c231 100644
7968 +--- a/fs/btrfs/send.c
7969 ++++ b/fs/btrfs/send.c
7970 +@@ -4087,6 +4087,17 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)
7971 + if (ret < 0)
7972 + goto out;
7973 + } else {
7974 ++ /*
7975 ++ * If we previously orphanized a directory that
7976 ++ * collided with a new reference that we already
7977 ++ * processed, recompute the current path because
7978 ++ * that directory may be part of the path.
7979 ++ */
7980 ++ if (orphanized_dir) {
7981 ++ ret = refresh_ref_path(sctx, cur);
7982 ++ if (ret < 0)
7983 ++ goto out;
7984 ++ }
7985 + ret = send_unlink(sctx, cur->full_path);
7986 + if (ret < 0)
7987 + goto out;
7988 +diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
7989 +index aca6c467d7761..d8e4e0bf3fc2d 100644
7990 +--- a/fs/btrfs/transaction.c
7991 ++++ b/fs/btrfs/transaction.c
7992 +@@ -1274,8 +1274,10 @@ int btrfs_defrag_root(struct btrfs_root *root)
7993 +
7994 + while (1) {
7995 + trans = btrfs_start_transaction(root, 0);
7996 +- if (IS_ERR(trans))
7997 +- return PTR_ERR(trans);
7998 ++ if (IS_ERR(trans)) {
7999 ++ ret = PTR_ERR(trans);
8000 ++ break;
8001 ++ }
8002 +
8003 + ret = btrfs_defrag_leaves(trans, root);
8004 +
8005 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
8006 +index 4ff381c23cefc..afc6731bb692c 100644
8007 +--- a/fs/btrfs/tree-log.c
8008 ++++ b/fs/btrfs/tree-log.c
8009 +@@ -6327,6 +6327,7 @@ next:
8010 + error:
8011 + if (wc.trans)
8012 + btrfs_end_transaction(wc.trans);
8013 ++ clear_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags);
8014 + btrfs_free_path(path);
8015 + return ret;
8016 + }
8017 +diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
8018 +index b16c994414ab0..9c0e348cb00f7 100644
8019 +--- a/fs/cifs/cifsglob.h
8020 ++++ b/fs/cifs/cifsglob.h
8021 +@@ -964,7 +964,7 @@ struct cifs_ses {
8022 + struct mutex session_mutex;
8023 + struct TCP_Server_Info *server; /* pointer to server info */
8024 + int ses_count; /* reference counter */
8025 +- enum statusEnum status;
8026 ++ enum statusEnum status; /* updates protected by GlobalMid_Lock */
8027 + unsigned overrideSecFlg; /* if non-zero override global sec flags */
8028 + char *serverOS; /* name of operating system underlying server */
8029 + char *serverNOS; /* name of network operating system of server */
8030 +@@ -1814,6 +1814,7 @@ require use of the stronger protocol */
8031 + * list operations on pending_mid_q and oplockQ
8032 + * updates to XID counters, multiplex id and SMB sequence numbers
8033 + * list operations on global DnotifyReqList
8034 ++ * updates to ses->status
8035 + * tcp_ses_lock protects:
8036 + * list operations on tcp and SMB session lists
8037 + * tcon->open_file_lock protects the list of open files hanging off the tcon
8038 +diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
8039 +index ab9eeb5ff8e57..da0720f41ebcb 100644
8040 +--- a/fs/cifs/connect.c
8041 ++++ b/fs/cifs/connect.c
8042 +@@ -3049,9 +3049,12 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
8043 + spin_unlock(&cifs_tcp_ses_lock);
8044 + return;
8045 + }
8046 ++ spin_unlock(&cifs_tcp_ses_lock);
8047 ++
8048 ++ spin_lock(&GlobalMid_Lock);
8049 + if (ses->status == CifsGood)
8050 + ses->status = CifsExiting;
8051 +- spin_unlock(&cifs_tcp_ses_lock);
8052 ++ spin_unlock(&GlobalMid_Lock);
8053 +
8054 + cifs_free_ipc(ses);
8055 +
8056 +diff --git a/fs/configfs/file.c b/fs/configfs/file.c
8057 +index 84b4d58fc65f7..66fae1853d998 100644
8058 +--- a/fs/configfs/file.c
8059 ++++ b/fs/configfs/file.c
8060 +@@ -482,13 +482,13 @@ static int configfs_release_bin_file(struct inode *inode, struct file *file)
8061 + buffer->bin_buffer_size);
8062 + }
8063 + up_read(&frag->frag_sem);
8064 +- /* vfree on NULL is safe */
8065 +- vfree(buffer->bin_buffer);
8066 +- buffer->bin_buffer = NULL;
8067 +- buffer->bin_buffer_size = 0;
8068 +- buffer->needs_read_fill = 1;
8069 + }
8070 +
8071 ++ vfree(buffer->bin_buffer);
8072 ++ buffer->bin_buffer = NULL;
8073 ++ buffer->bin_buffer_size = 0;
8074 ++ buffer->needs_read_fill = 1;
8075 ++
8076 + configfs_release(inode, file);
8077 + return 0;
8078 + }
8079 +diff --git a/fs/dax.c b/fs/dax.c
8080 +index 3b0e5da96d541..12953e892bb25 100644
8081 +--- a/fs/dax.c
8082 ++++ b/fs/dax.c
8083 +@@ -477,10 +477,11 @@ static void *grab_mapping_entry(struct xa_state *xas,
8084 + struct address_space *mapping, unsigned int order)
8085 + {
8086 + unsigned long index = xas->xa_index;
8087 +- bool pmd_downgrade = false; /* splitting PMD entry into PTE entries? */
8088 ++ bool pmd_downgrade; /* splitting PMD entry into PTE entries? */
8089 + void *entry;
8090 +
8091 + retry:
8092 ++ pmd_downgrade = false;
8093 + xas_lock_irq(xas);
8094 + entry = get_unlocked_entry(xas, order);
8095 +
8096 +diff --git a/fs/dlm/config.c b/fs/dlm/config.c
8097 +index 3b1012a3c4396..b7e288cf3f5f3 100644
8098 +--- a/fs/dlm/config.c
8099 ++++ b/fs/dlm/config.c
8100 +@@ -78,6 +78,9 @@ struct dlm_cluster {
8101 + unsigned int cl_new_rsb_count;
8102 + unsigned int cl_recover_callbacks;
8103 + char cl_cluster_name[DLM_LOCKSPACE_LEN];
8104 ++
8105 ++ struct dlm_spaces *sps;
8106 ++ struct dlm_comms *cms;
8107 + };
8108 +
8109 + static struct dlm_cluster *config_item_to_cluster(struct config_item *i)
8110 +@@ -354,6 +357,9 @@ static struct config_group *make_cluster(struct config_group *g,
8111 + if (!cl || !sps || !cms)
8112 + goto fail;
8113 +
8114 ++ cl->sps = sps;
8115 ++ cl->cms = cms;
8116 ++
8117 + config_group_init_type_name(&cl->group, name, &cluster_type);
8118 + config_group_init_type_name(&sps->ss_group, "spaces", &spaces_type);
8119 + config_group_init_type_name(&cms->cs_group, "comms", &comms_type);
8120 +@@ -403,6 +409,9 @@ static void drop_cluster(struct config_group *g, struct config_item *i)
8121 + static void release_cluster(struct config_item *i)
8122 + {
8123 + struct dlm_cluster *cl = config_item_to_cluster(i);
8124 ++
8125 ++ kfree(cl->sps);
8126 ++ kfree(cl->cms);
8127 + kfree(cl);
8128 + }
8129 +
8130 +diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
8131 +index 3951d39b9b759..d9202ba665cef 100644
8132 +--- a/fs/dlm/lowcomms.c
8133 ++++ b/fs/dlm/lowcomms.c
8134 +@@ -607,7 +607,7 @@ static void close_connection(struct connection *con, bool and_other,
8135 + }
8136 + if (con->othercon && and_other) {
8137 + /* Will only re-enter once. */
8138 +- close_connection(con->othercon, false, true, true);
8139 ++ close_connection(con->othercon, false, tx, rx);
8140 + }
8141 + if (con->rx_page) {
8142 + __free_page(con->rx_page);
8143 +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
8144 +index dbd0d7a101541..ae73e67936832 100644
8145 +--- a/fs/ext4/extents.c
8146 ++++ b/fs/ext4/extents.c
8147 +@@ -862,6 +862,7 @@ int ext4_ext_tree_init(handle_t *handle, struct inode *inode)
8148 + eh->eh_entries = 0;
8149 + eh->eh_magic = EXT4_EXT_MAGIC;
8150 + eh->eh_max = cpu_to_le16(ext4_ext_space_root(inode, 0));
8151 ++ eh->eh_generation = 0;
8152 + ext4_mark_inode_dirty(handle, inode);
8153 + return 0;
8154 + }
8155 +@@ -1118,6 +1119,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
8156 + neh->eh_max = cpu_to_le16(ext4_ext_space_block(inode, 0));
8157 + neh->eh_magic = EXT4_EXT_MAGIC;
8158 + neh->eh_depth = 0;
8159 ++ neh->eh_generation = 0;
8160 +
8161 + /* move remainder of path[depth] to the new leaf */
8162 + if (unlikely(path[depth].p_hdr->eh_entries !=
8163 +@@ -1195,6 +1197,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
8164 + neh->eh_magic = EXT4_EXT_MAGIC;
8165 + neh->eh_max = cpu_to_le16(ext4_ext_space_block_idx(inode, 0));
8166 + neh->eh_depth = cpu_to_le16(depth - i);
8167 ++ neh->eh_generation = 0;
8168 + fidx = EXT_FIRST_INDEX(neh);
8169 + fidx->ei_block = border;
8170 + ext4_idx_store_pblock(fidx, oldblock);
8171 +diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
8172 +index d996b44d2265b..43fba01da6c3d 100644
8173 +--- a/fs/ext4/extents_status.c
8174 ++++ b/fs/ext4/extents_status.c
8175 +@@ -1553,11 +1553,9 @@ static unsigned long ext4_es_scan(struct shrinker *shrink,
8176 + ret = percpu_counter_read_positive(&sbi->s_es_stats.es_stats_shk_cnt);
8177 + trace_ext4_es_shrink_scan_enter(sbi->s_sb, nr_to_scan, ret);
8178 +
8179 +- if (!nr_to_scan)
8180 +- return ret;
8181 +-
8182 + nr_shrunk = __es_shrink(sbi, nr_to_scan, NULL);
8183 +
8184 ++ ret = percpu_counter_read_positive(&sbi->s_es_stats.es_stats_shk_cnt);
8185 + trace_ext4_es_shrink_scan_exit(sbi->s_sb, nr_shrunk, ret);
8186 + return nr_shrunk;
8187 + }
8188 +diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
8189 +index dd2c23d1483cc..83846cc814850 100644
8190 +--- a/fs/ext4/ialloc.c
8191 ++++ b/fs/ext4/ialloc.c
8192 +@@ -394,7 +394,7 @@ static void get_orlov_stats(struct super_block *sb, ext4_group_t g,
8193 + *
8194 + * We always try to spread first-level directories.
8195 + *
8196 +- * If there are blockgroups with both free inodes and free blocks counts
8197 ++ * If there are blockgroups with both free inodes and free clusters counts
8198 + * not worse than average we return one with smallest directory count.
8199 + * Otherwise we simply return a random group.
8200 + *
8201 +@@ -403,7 +403,7 @@ static void get_orlov_stats(struct super_block *sb, ext4_group_t g,
8202 + * It's OK to put directory into a group unless
8203 + * it has too many directories already (max_dirs) or
8204 + * it has too few free inodes left (min_inodes) or
8205 +- * it has too few free blocks left (min_blocks) or
8206 ++ * it has too few free clusters left (min_clusters) or
8207 + * Parent's group is preferred, if it doesn't satisfy these
8208 + * conditions we search cyclically through the rest. If none
8209 + * of the groups look good we just look for a group with more
8210 +@@ -419,7 +419,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
8211 + ext4_group_t real_ngroups = ext4_get_groups_count(sb);
8212 + int inodes_per_group = EXT4_INODES_PER_GROUP(sb);
8213 + unsigned int freei, avefreei, grp_free;
8214 +- ext4_fsblk_t freeb, avefreec;
8215 ++ ext4_fsblk_t freec, avefreec;
8216 + unsigned int ndirs;
8217 + int max_dirs, min_inodes;
8218 + ext4_grpblk_t min_clusters;
8219 +@@ -438,9 +438,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
8220 +
8221 + freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter);
8222 + avefreei = freei / ngroups;
8223 +- freeb = EXT4_C2B(sbi,
8224 +- percpu_counter_read_positive(&sbi->s_freeclusters_counter));
8225 +- avefreec = freeb;
8226 ++ freec = percpu_counter_read_positive(&sbi->s_freeclusters_counter);
8227 ++ avefreec = freec;
8228 + do_div(avefreec, ngroups);
8229 + ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter);
8230 +
8231 +diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
8232 +index cd69510f29472..b67ea979f0cf7 100644
8233 +--- a/fs/ext4/mballoc.c
8234 ++++ b/fs/ext4/mballoc.c
8235 +@@ -1542,10 +1542,11 @@ static int mb_find_extent(struct ext4_buddy *e4b, int block,
8236 + if (ex->fe_start + ex->fe_len > EXT4_CLUSTERS_PER_GROUP(e4b->bd_sb)) {
8237 + /* Should never happen! (but apparently sometimes does?!?) */
8238 + WARN_ON(1);
8239 +- ext4_error(e4b->bd_sb, "corruption or bug in mb_find_extent "
8240 +- "block=%d, order=%d needed=%d ex=%u/%d/%d@%u",
8241 +- block, order, needed, ex->fe_group, ex->fe_start,
8242 +- ex->fe_len, ex->fe_logical);
8243 ++ ext4_grp_locked_error(e4b->bd_sb, e4b->bd_group, 0, 0,
8244 ++ "corruption or bug in mb_find_extent "
8245 ++ "block=%d, order=%d needed=%d ex=%u/%d/%d@%u",
8246 ++ block, order, needed, ex->fe_group, ex->fe_start,
8247 ++ ex->fe_len, ex->fe_logical);
8248 + ex->fe_len = 0;
8249 + ex->fe_start = 0;
8250 + ex->fe_group = 0;
8251 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
8252 +index 0b364f5e6fdf9..ce8372ceaa43e 100644
8253 +--- a/fs/ext4/super.c
8254 ++++ b/fs/ext4/super.c
8255 +@@ -2735,8 +2735,15 @@ static void ext4_orphan_cleanup(struct super_block *sb,
8256 + inode_lock(inode);
8257 + truncate_inode_pages(inode->i_mapping, inode->i_size);
8258 + ret = ext4_truncate(inode);
8259 +- if (ret)
8260 ++ if (ret) {
8261 ++ /*
8262 ++ * We need to clean up the in-core orphan list
8263 ++ * manually if ext4_truncate() failed to get a
8264 ++ * transaction handle.
8265 ++ */
8266 ++ ext4_orphan_del(NULL, inode);
8267 + ext4_std_error(inode->i_sb, ret);
8268 ++ }
8269 + inode_unlock(inode);
8270 + nr_truncates++;
8271 + } else {
8272 +@@ -4611,6 +4618,7 @@ no_journal:
8273 + ext4_msg(sb, KERN_ERR,
8274 + "unable to initialize "
8275 + "flex_bg meta info!");
8276 ++ ret = -ENOMEM;
8277 + goto failed_mount6;
8278 + }
8279 +
8280 +diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
8281 +index a2cf2db0d3def..22e9c88f3960a 100644
8282 +--- a/fs/fs-writeback.c
8283 ++++ b/fs/fs-writeback.c
8284 +@@ -505,12 +505,19 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
8285 + if (!isw)
8286 + return;
8287 +
8288 ++ atomic_inc(&isw_nr_in_flight);
8289 ++
8290 + /* find and pin the new wb */
8291 + rcu_read_lock();
8292 + memcg_css = css_from_id(new_wb_id, &memory_cgrp_subsys);
8293 +- if (memcg_css)
8294 +- isw->new_wb = wb_get_create(bdi, memcg_css, GFP_ATOMIC);
8295 ++ if (memcg_css && !css_tryget(memcg_css))
8296 ++ memcg_css = NULL;
8297 + rcu_read_unlock();
8298 ++ if (!memcg_css)
8299 ++ goto out_free;
8300 ++
8301 ++ isw->new_wb = wb_get_create(bdi, memcg_css, GFP_ATOMIC);
8302 ++ css_put(memcg_css);
8303 + if (!isw->new_wb)
8304 + goto out_free;
8305 +
8306 +@@ -535,11 +542,10 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
8307 + * Let's continue after I_WB_SWITCH is guaranteed to be visible.
8308 + */
8309 + call_rcu(&isw->rcu_head, inode_switch_wbs_rcu_fn);
8310 +-
8311 +- atomic_inc(&isw_nr_in_flight);
8312 + return;
8313 +
8314 + out_free:
8315 ++ atomic_dec(&isw_nr_in_flight);
8316 + if (isw->new_wb)
8317 + wb_put(isw->new_wb);
8318 + kfree(isw);
8319 +@@ -2196,28 +2202,6 @@ int dirtytime_interval_handler(struct ctl_table *table, int write,
8320 + return ret;
8321 + }
8322 +
8323 +-static noinline void block_dump___mark_inode_dirty(struct inode *inode)
8324 +-{
8325 +- if (inode->i_ino || strcmp(inode->i_sb->s_id, "bdev")) {
8326 +- struct dentry *dentry;
8327 +- const char *name = "?";
8328 +-
8329 +- dentry = d_find_alias(inode);
8330 +- if (dentry) {
8331 +- spin_lock(&dentry->d_lock);
8332 +- name = (const char *) dentry->d_name.name;
8333 +- }
8334 +- printk(KERN_DEBUG
8335 +- "%s(%d): dirtied inode %lu (%s) on %s\n",
8336 +- current->comm, task_pid_nr(current), inode->i_ino,
8337 +- name, inode->i_sb->s_id);
8338 +- if (dentry) {
8339 +- spin_unlock(&dentry->d_lock);
8340 +- dput(dentry);
8341 +- }
8342 +- }
8343 +-}
8344 +-
8345 + /**
8346 + * __mark_inode_dirty - internal function
8347 + *
8348 +@@ -2277,9 +2261,6 @@ void __mark_inode_dirty(struct inode *inode, int flags)
8349 + (dirtytime && (inode->i_state & I_DIRTY_INODE)))
8350 + return;
8351 +
8352 +- if (unlikely(block_dump))
8353 +- block_dump___mark_inode_dirty(inode);
8354 +-
8355 + spin_lock(&inode->i_lock);
8356 + if (dirtytime && (inode->i_state & I_DIRTY_INODE))
8357 + goto out_unlock_inode;
8358 +diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
8359 +index 40c262b3f9ff5..16aa55b73ccf5 100644
8360 +--- a/fs/fuse/dev.c
8361 ++++ b/fs/fuse/dev.c
8362 +@@ -770,6 +770,7 @@ static int fuse_check_page(struct page *page)
8363 + 1 << PG_uptodate |
8364 + 1 << PG_lru |
8365 + 1 << PG_active |
8366 ++ 1 << PG_workingset |
8367 + 1 << PG_reclaim |
8368 + 1 << PG_waiters))) {
8369 + pr_warn("trying to steal weird page\n");
8370 +@@ -1263,6 +1264,15 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
8371 + goto restart;
8372 + }
8373 + spin_lock(&fpq->lock);
8374 ++ /*
8375 ++ * Must not put request on fpq->io queue after having been shut down by
8376 ++ * fuse_abort_conn()
8377 ++ */
8378 ++ if (!fpq->connected) {
8379 ++ req->out.h.error = err = -ECONNABORTED;
8380 ++ goto out_end;
8381 ++
8382 ++ }
8383 + list_add(&req->list, &fpq->io);
8384 + spin_unlock(&fpq->lock);
8385 + cs->req = req;
8386 +@@ -1859,7 +1869,7 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud,
8387 + }
8388 +
8389 + err = -EINVAL;
8390 +- if (oh.error <= -1000 || oh.error > 0)
8391 ++ if (oh.error <= -512 || oh.error > 0)
8392 + goto copy_finish;
8393 +
8394 + spin_lock(&fpq->lock);
8395 +diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
8396 +index 672feb96e250e..46dc16e01fe20 100644
8397 +--- a/fs/ntfs/inode.c
8398 ++++ b/fs/ntfs/inode.c
8399 +@@ -476,7 +476,7 @@ err_corrupt_attr:
8400 + }
8401 + file_name_attr = (FILE_NAME_ATTR*)((u8*)attr +
8402 + le16_to_cpu(attr->data.resident.value_offset));
8403 +- p2 = (u8*)attr + le32_to_cpu(attr->data.resident.value_length);
8404 ++ p2 = (u8 *)file_name_attr + le32_to_cpu(attr->data.resident.value_length);
8405 + if (p2 < (u8*)attr || p2 > p)
8406 + goto err_corrupt_attr;
8407 + /* This attribute is ok, but is it in the $Extend directory? */
8408 +diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
8409 +index 50f11bfdc8c2d..82a3edc4aea4b 100644
8410 +--- a/fs/ocfs2/filecheck.c
8411 ++++ b/fs/ocfs2/filecheck.c
8412 +@@ -328,11 +328,7 @@ static ssize_t ocfs2_filecheck_attr_show(struct kobject *kobj,
8413 + ret = snprintf(buf + total, remain, "%lu\t\t%u\t%s\n",
8414 + p->fe_ino, p->fe_done,
8415 + ocfs2_filecheck_error(p->fe_status));
8416 +- if (ret < 0) {
8417 +- total = ret;
8418 +- break;
8419 +- }
8420 +- if (ret == remain) {
8421 ++ if (ret >= remain) {
8422 + /* snprintf() didn't fit */
8423 + total = -E2BIG;
8424 + break;
8425 +diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
8426 +index 8aa6a667860c9..1880387601361 100644
8427 +--- a/fs/ocfs2/stackglue.c
8428 ++++ b/fs/ocfs2/stackglue.c
8429 +@@ -502,11 +502,7 @@ static ssize_t ocfs2_loaded_cluster_plugins_show(struct kobject *kobj,
8430 + list_for_each_entry(p, &ocfs2_stack_list, sp_list) {
8431 + ret = snprintf(buf, remain, "%s\n",
8432 + p->sp_name);
8433 +- if (ret < 0) {
8434 +- total = ret;
8435 +- break;
8436 +- }
8437 +- if (ret == remain) {
8438 ++ if (ret >= remain) {
8439 + /* snprintf() didn't fit */
8440 + total = -E2BIG;
8441 + break;
8442 +@@ -533,7 +529,7 @@ static ssize_t ocfs2_active_cluster_plugin_show(struct kobject *kobj,
8443 + if (active_stack) {
8444 + ret = snprintf(buf, PAGE_SIZE, "%s\n",
8445 + active_stack->sp_name);
8446 +- if (ret == PAGE_SIZE)
8447 ++ if (ret >= PAGE_SIZE)
8448 + ret = -E2BIG;
8449 + }
8450 + spin_unlock(&ocfs2_stack_lock);
8451 +diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
8452 +index bfc9db7b100d6..9cc7f1c02d270 100644
8453 +--- a/include/crypto/internal/hash.h
8454 ++++ b/include/crypto/internal/hash.h
8455 +@@ -77,13 +77,7 @@ int ahash_register_instance(struct crypto_template *tmpl,
8456 + struct ahash_instance *inst);
8457 + void ahash_free_instance(struct crypto_instance *inst);
8458 +
8459 +-int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
8460 +- unsigned int keylen);
8461 +-
8462 +-static inline bool crypto_shash_alg_has_setkey(struct shash_alg *alg)
8463 +-{
8464 +- return alg->setkey != shash_no_setkey;
8465 +-}
8466 ++bool crypto_shash_alg_has_setkey(struct shash_alg *alg);
8467 +
8468 + bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg);
8469 +
8470 +diff --git a/include/linux/bio.h b/include/linux/bio.h
8471 +index 853d92ceee64e..b0927b27a8a88 100644
8472 +--- a/include/linux/bio.h
8473 ++++ b/include/linux/bio.h
8474 +@@ -40,9 +40,6 @@
8475 + #define bio_offset(bio) bio_iter_offset((bio), (bio)->bi_iter)
8476 + #define bio_iovec(bio) bio_iter_iovec((bio), (bio)->bi_iter)
8477 +
8478 +-#define bio_multiple_segments(bio) \
8479 +- ((bio)->bi_iter.bi_size != bio_iovec(bio).bv_len)
8480 +-
8481 + #define bvec_iter_sectors(iter) ((iter).bi_size >> 9)
8482 + #define bvec_iter_end_sector(iter) ((iter).bi_sector + bvec_iter_sectors((iter)))
8483 +
8484 +@@ -246,7 +243,7 @@ static inline void bio_clear_flag(struct bio *bio, unsigned int bit)
8485 +
8486 + static inline void bio_get_first_bvec(struct bio *bio, struct bio_vec *bv)
8487 + {
8488 +- *bv = bio_iovec(bio);
8489 ++ *bv = mp_bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
8490 + }
8491 +
8492 + static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv)
8493 +@@ -254,10 +251,9 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv)
8494 + struct bvec_iter iter = bio->bi_iter;
8495 + int idx;
8496 +
8497 +- if (unlikely(!bio_multiple_segments(bio))) {
8498 +- *bv = bio_iovec(bio);
8499 +- return;
8500 +- }
8501 ++ bio_get_first_bvec(bio, bv);
8502 ++ if (bv->bv_len == bio->bi_iter.bi_size)
8503 ++ return; /* this bio only has a single bvec */
8504 +
8505 + bio_advance_iter(bio, &iter, iter.bi_size);
8506 +
8507 +diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
8508 +index bb331e6356a9c..a321531539dd1 100644
8509 +--- a/include/linux/iio/common/cros_ec_sensors_core.h
8510 ++++ b/include/linux/iio/common/cros_ec_sensors_core.h
8511 +@@ -68,7 +68,7 @@ struct cros_ec_sensors_core_state {
8512 + u16 scale;
8513 + } calib[CROS_EC_SENSOR_MAX_AXIS];
8514 + s8 sign[CROS_EC_SENSOR_MAX_AXIS];
8515 +- u8 samples[CROS_EC_SAMPLE_SIZE];
8516 ++ u8 samples[CROS_EC_SAMPLE_SIZE] __aligned(8);
8517 +
8518 + int (*read_ec_sensors_data)(struct iio_dev *indio_dev,
8519 + unsigned long scan_mask, s16 *data);
8520 +diff --git a/include/linux/prandom.h b/include/linux/prandom.h
8521 +index cc1e71334e53c..e20339c78a84c 100644
8522 +--- a/include/linux/prandom.h
8523 ++++ b/include/linux/prandom.h
8524 +@@ -93,7 +93,7 @@ static inline u32 __seed(u32 x, u32 m)
8525 + */
8526 + static inline void prandom_seed_state(struct rnd_state *state, u64 seed)
8527 + {
8528 +- u32 i = (seed >> 32) ^ (seed << 10) ^ seed;
8529 ++ u32 i = ((seed >> 32) ^ (seed << 10) ^ seed) & 0xffffffffUL;
8530 +
8531 + state->s1 = __seed(i, 2U);
8532 + state->s2 = __seed(i, 8U);
8533 +diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
8534 +index 57ce5af258a3b..eede1a7c81955 100644
8535 +--- a/include/linux/tracepoint.h
8536 ++++ b/include/linux/tracepoint.h
8537 +@@ -40,7 +40,17 @@ extern int
8538 + tracepoint_probe_register_prio(struct tracepoint *tp, void *probe, void *data,
8539 + int prio);
8540 + extern int
8541 ++tracepoint_probe_register_prio_may_exist(struct tracepoint *tp, void *probe, void *data,
8542 ++ int prio);
8543 ++extern int
8544 + tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data);
8545 ++static inline int
8546 ++tracepoint_probe_register_may_exist(struct tracepoint *tp, void *probe,
8547 ++ void *data)
8548 ++{
8549 ++ return tracepoint_probe_register_prio_may_exist(tp, probe, data,
8550 ++ TRACEPOINT_DEFAULT_PRIO);
8551 ++}
8552 + extern void
8553 + for_each_kernel_tracepoint(void (*fct)(struct tracepoint *tp, void *priv),
8554 + void *priv);
8555 +diff --git a/include/media/media-dev-allocator.h b/include/media/media-dev-allocator.h
8556 +index b35ea6062596b..2ab54d426c644 100644
8557 +--- a/include/media/media-dev-allocator.h
8558 ++++ b/include/media/media-dev-allocator.h
8559 +@@ -19,7 +19,7 @@
8560 +
8561 + struct usb_device;
8562 +
8563 +-#if defined(CONFIG_MEDIA_CONTROLLER) && defined(CONFIG_USB)
8564 ++#if defined(CONFIG_MEDIA_CONTROLLER) && IS_ENABLED(CONFIG_USB)
8565 + /**
8566 + * media_device_usb_allocate() - Allocate and return struct &media device
8567 + *
8568 +diff --git a/include/net/ip.h b/include/net/ip.h
8569 +index 0278d63c15274..52abfc00b5e3d 100644
8570 +--- a/include/net/ip.h
8571 ++++ b/include/net/ip.h
8572 +@@ -30,6 +30,7 @@
8573 + #include <net/flow.h>
8574 + #include <net/flow_dissector.h>
8575 + #include <net/netns/hash.h>
8576 ++#include <net/lwtunnel.h>
8577 +
8578 + #define IPV4_MAX_PMTU 65535U /* RFC 2675, Section 5.1 */
8579 + #define IPV4_MIN_MTU 68 /* RFC 791 */
8580 +@@ -448,22 +449,25 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst,
8581 +
8582 + /* 'forwarding = true' case should always honour route mtu */
8583 + mtu = dst_metric_raw(dst, RTAX_MTU);
8584 +- if (mtu)
8585 +- return mtu;
8586 ++ if (!mtu)
8587 ++ mtu = min(READ_ONCE(dst->dev->mtu), IP_MAX_MTU);
8588 +
8589 +- return min(READ_ONCE(dst->dev->mtu), IP_MAX_MTU);
8590 ++ return mtu - lwtunnel_headroom(dst->lwtstate, mtu);
8591 + }
8592 +
8593 + static inline unsigned int ip_skb_dst_mtu(struct sock *sk,
8594 + const struct sk_buff *skb)
8595 + {
8596 ++ unsigned int mtu;
8597 ++
8598 + if (!sk || !sk_fullsock(sk) || ip_sk_use_pmtu(sk)) {
8599 + bool forwarding = IPCB(skb)->flags & IPSKB_FORWARDED;
8600 +
8601 + return ip_dst_mtu_maybe_forward(skb_dst(skb), forwarding);
8602 + }
8603 +
8604 +- return min(READ_ONCE(skb_dst(skb)->dev->mtu), IP_MAX_MTU);
8605 ++ mtu = min(READ_ONCE(skb_dst(skb)->dev->mtu), IP_MAX_MTU);
8606 ++ return mtu - lwtunnel_headroom(skb_dst(skb)->lwtstate, mtu);
8607 + }
8608 +
8609 + struct dst_metrics *ip_fib_metrics_init(struct net *net, struct nlattr *fc_mx,
8610 +diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
8611 +index 2d0d91070268c..40602def3fe76 100644
8612 +--- a/include/net/ip6_route.h
8613 ++++ b/include/net/ip6_route.h
8614 +@@ -263,11 +263,18 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
8615 +
8616 + static inline int ip6_skb_dst_mtu(struct sk_buff *skb)
8617 + {
8618 ++ int mtu;
8619 ++
8620 + struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ?
8621 + inet6_sk(skb->sk) : NULL;
8622 +
8623 +- return (np && np->pmtudisc >= IPV6_PMTUDISC_PROBE) ?
8624 +- skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb));
8625 ++ if (np && np->pmtudisc >= IPV6_PMTUDISC_PROBE) {
8626 ++ mtu = READ_ONCE(skb_dst(skb)->dev->mtu);
8627 ++ mtu -= lwtunnel_headroom(skb_dst(skb)->lwtstate, mtu);
8628 ++ } else
8629 ++ mtu = dst_mtu(skb_dst(skb));
8630 ++
8631 ++ return mtu;
8632 + }
8633 +
8634 + static inline bool ip6_sk_accept_pmtu(const struct sock *sk)
8635 +@@ -315,7 +322,7 @@ static inline unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
8636 + if (dst_metric_locked(dst, RTAX_MTU)) {
8637 + mtu = dst_metric_raw(dst, RTAX_MTU);
8638 + if (mtu)
8639 +- return mtu;
8640 ++ goto out;
8641 + }
8642 +
8643 + mtu = IPV6_MIN_MTU;
8644 +@@ -325,7 +332,8 @@ static inline unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
8645 + mtu = idev->cnf.mtu6;
8646 + rcu_read_unlock();
8647 +
8648 +- return mtu;
8649 ++out:
8650 ++ return mtu - lwtunnel_headroom(dst->lwtstate, mtu);
8651 + }
8652 +
8653 + u32 ip6_mtu_from_fib6(const struct fib6_result *res,
8654 +diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
8655 +index 0852f3e51360a..0cb0a4bcb5447 100644
8656 +--- a/include/net/sch_generic.h
8657 ++++ b/include/net/sch_generic.h
8658 +@@ -160,6 +160,12 @@ static inline bool qdisc_run_begin(struct Qdisc *qdisc)
8659 + if (spin_trylock(&qdisc->seqlock))
8660 + goto nolock_empty;
8661 +
8662 ++ /* Paired with smp_mb__after_atomic() to make sure
8663 ++ * STATE_MISSED checking is synchronized with clearing
8664 ++ * in pfifo_fast_dequeue().
8665 ++ */
8666 ++ smp_mb__before_atomic();
8667 ++
8668 + /* If the MISSED flag is set, it means other thread has
8669 + * set the MISSED flag before second spin_trylock(), so
8670 + * we can return false here to avoid multi cpus doing
8671 +@@ -177,6 +183,12 @@ static inline bool qdisc_run_begin(struct Qdisc *qdisc)
8672 + */
8673 + set_bit(__QDISC_STATE_MISSED, &qdisc->state);
8674 +
8675 ++ /* spin_trylock() only has load-acquire semantic, so use
8676 ++ * smp_mb__after_atomic() to ensure STATE_MISSED is set
8677 ++ * before doing the second spin_trylock().
8678 ++ */
8679 ++ smp_mb__after_atomic();
8680 ++
8681 + /* Retry again in case other CPU may not see the new flag
8682 + * after it releases the lock at the end of qdisc_run_end().
8683 + */
8684 +diff --git a/include/net/tc_act/tc_vlan.h b/include/net/tc_act/tc_vlan.h
8685 +index 4e2502408c316..add6fb50dd330 100644
8686 +--- a/include/net/tc_act/tc_vlan.h
8687 ++++ b/include/net/tc_act/tc_vlan.h
8688 +@@ -14,6 +14,7 @@ struct tcf_vlan_params {
8689 + u16 tcfv_push_vid;
8690 + __be16 tcfv_push_proto;
8691 + u8 tcfv_push_prio;
8692 ++ bool tcfv_push_prio_exists;
8693 + struct rcu_head rcu;
8694 + };
8695 +
8696 +diff --git a/include/net/xfrm.h b/include/net/xfrm.h
8697 +index 614f19bbad74f..8ce63850d6d01 100644
8698 +--- a/include/net/xfrm.h
8699 ++++ b/include/net/xfrm.h
8700 +@@ -1543,6 +1543,7 @@ void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si);
8701 + void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si);
8702 + u32 xfrm_replay_seqhi(struct xfrm_state *x, __be32 net_seq);
8703 + int xfrm_init_replay(struct xfrm_state *x);
8704 ++u32 __xfrm_state_mtu(struct xfrm_state *x, int mtu);
8705 + u32 xfrm_state_mtu(struct xfrm_state *x, int mtu);
8706 + int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload);
8707 + int xfrm_init_state(struct xfrm_state *x);
8708 +diff --git a/kernel/kthread.c b/kernel/kthread.c
8709 +index 2eb8d7550324b..b2bac5d929d2b 100644
8710 +--- a/kernel/kthread.c
8711 ++++ b/kernel/kthread.c
8712 +@@ -1083,14 +1083,14 @@ static bool __kthread_cancel_work(struct kthread_work *work)
8713 + * modify @dwork's timer so that it expires after @delay. If @delay is zero,
8714 + * @work is guaranteed to be queued immediately.
8715 + *
8716 +- * Return: %true if @dwork was pending and its timer was modified,
8717 +- * %false otherwise.
8718 ++ * Return: %false if @dwork was idle and queued, %true otherwise.
8719 + *
8720 + * A special case is when the work is being canceled in parallel.
8721 + * It might be caused either by the real kthread_cancel_delayed_work_sync()
8722 + * or yet another kthread_mod_delayed_work() call. We let the other command
8723 +- * win and return %false here. The caller is supposed to synchronize these
8724 +- * operations a reasonable way.
8725 ++ * win and return %true here. The return value can be used for reference
8726 ++ * counting and the number of queued works stays the same. Anyway, the caller
8727 ++ * is supposed to synchronize these operations a reasonable way.
8728 + *
8729 + * This function is safe to call from any context including IRQ handler.
8730 + * See __kthread_cancel_work() and kthread_delayed_work_timer_fn()
8731 +@@ -1102,13 +1102,15 @@ bool kthread_mod_delayed_work(struct kthread_worker *worker,
8732 + {
8733 + struct kthread_work *work = &dwork->work;
8734 + unsigned long flags;
8735 +- int ret = false;
8736 ++ int ret;
8737 +
8738 + raw_spin_lock_irqsave(&worker->lock, flags);
8739 +
8740 + /* Do not bother with canceling when never queued. */
8741 +- if (!work->worker)
8742 ++ if (!work->worker) {
8743 ++ ret = false;
8744 + goto fast_queue;
8745 ++ }
8746 +
8747 + /* Work must not be used with >1 worker, see kthread_queue_work() */
8748 + WARN_ON_ONCE(work->worker != worker);
8749 +@@ -1126,8 +1128,11 @@ bool kthread_mod_delayed_work(struct kthread_worker *worker,
8750 + * be used for reference counting.
8751 + */
8752 + kthread_cancel_delayed_work_timer(work, &flags);
8753 +- if (work->canceling)
8754 ++ if (work->canceling) {
8755 ++ /* The number of works in the queue does not change. */
8756 ++ ret = true;
8757 + goto out;
8758 ++ }
8759 + ret = __kthread_cancel_work(work);
8760 +
8761 + fast_queue:
8762 +diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
8763 +index 7429f15717559..3ec8fd2e80e53 100644
8764 +--- a/kernel/locking/lockdep.c
8765 ++++ b/kernel/locking/lockdep.c
8766 +@@ -1941,7 +1941,56 @@ static void print_lock_class_header(struct lock_class *class, int depth)
8767 + }
8768 +
8769 + /*
8770 +- * printk the shortest lock dependencies from @start to @end in reverse order:
8771 ++ * Dependency path printing:
8772 ++ *
8773 ++ * After BFS we get a lock dependency path (linked via ->parent of lock_list),
8774 ++ * printing out each lock in the dependency path will help on understanding how
8775 ++ * the deadlock could happen. Here are some details about dependency path
8776 ++ * printing:
8777 ++ *
8778 ++ * 1) A lock_list can be either forwards or backwards for a lock dependency,
8779 ++ * for a lock dependency A -> B, there are two lock_lists:
8780 ++ *
8781 ++ * a) lock_list in the ->locks_after list of A, whose ->class is B and
8782 ++ * ->links_to is A. In this case, we can say the lock_list is
8783 ++ * "A -> B" (forwards case).
8784 ++ *
8785 ++ * b) lock_list in the ->locks_before list of B, whose ->class is A
8786 ++ * and ->links_to is B. In this case, we can say the lock_list is
8787 ++ * "B <- A" (bacwards case).
8788 ++ *
8789 ++ * The ->trace of both a) and b) point to the call trace where B was
8790 ++ * acquired with A held.
8791 ++ *
8792 ++ * 2) A "helper" lock_list is introduced during BFS, this lock_list doesn't
8793 ++ * represent a certain lock dependency, it only provides an initial entry
8794 ++ * for BFS. For example, BFS may introduce a "helper" lock_list whose
8795 ++ * ->class is A, as a result BFS will search all dependencies starting with
8796 ++ * A, e.g. A -> B or A -> C.
8797 ++ *
8798 ++ * The notation of a forwards helper lock_list is like "-> A", which means
8799 ++ * we should search the forwards dependencies starting with "A", e.g A -> B
8800 ++ * or A -> C.
8801 ++ *
8802 ++ * The notation of a bacwards helper lock_list is like "<- B", which means
8803 ++ * we should search the backwards dependencies ending with "B", e.g.
8804 ++ * B <- A or B <- C.
8805 ++ */
8806 ++
8807 ++/*
8808 ++ * printk the shortest lock dependencies from @root to @leaf in reverse order.
8809 ++ *
8810 ++ * We have a lock dependency path as follow:
8811 ++ *
8812 ++ * @root @leaf
8813 ++ * | |
8814 ++ * V V
8815 ++ * ->parent ->parent
8816 ++ * | lock_list | <--------- | lock_list | ... | lock_list | <--------- | lock_list |
8817 ++ * | -> L1 | | L1 -> L2 | ... |Ln-2 -> Ln-1| | Ln-1 -> Ln|
8818 ++ *
8819 ++ * , so it's natural that we start from @leaf and print every ->class and
8820 ++ * ->trace until we reach the @root.
8821 + */
8822 + static void __used
8823 + print_shortest_lock_dependencies(struct lock_list *leaf,
8824 +@@ -1969,6 +2018,61 @@ print_shortest_lock_dependencies(struct lock_list *leaf,
8825 + } while (entry && (depth >= 0));
8826 + }
8827 +
8828 ++/*
8829 ++ * printk the shortest lock dependencies from @leaf to @root.
8830 ++ *
8831 ++ * We have a lock dependency path (from a backwards search) as follow:
8832 ++ *
8833 ++ * @leaf @root
8834 ++ * | |
8835 ++ * V V
8836 ++ * ->parent ->parent
8837 ++ * | lock_list | ---------> | lock_list | ... | lock_list | ---------> | lock_list |
8838 ++ * | L2 <- L1 | | L3 <- L2 | ... | Ln <- Ln-1 | | <- Ln |
8839 ++ *
8840 ++ * , so when we iterate from @leaf to @root, we actually print the lock
8841 ++ * dependency path L1 -> L2 -> .. -> Ln in the non-reverse order.
8842 ++ *
8843 ++ * Another thing to notice here is that ->class of L2 <- L1 is L1, while the
8844 ++ * ->trace of L2 <- L1 is the call trace of L2, in fact we don't have the call
8845 ++ * trace of L1 in the dependency path, which is alright, because most of the
8846 ++ * time we can figure out where L1 is held from the call trace of L2.
8847 ++ */
8848 ++static void __used
8849 ++print_shortest_lock_dependencies_backwards(struct lock_list *leaf,
8850 ++ struct lock_list *root)
8851 ++{
8852 ++ struct lock_list *entry = leaf;
8853 ++ const struct lock_trace *trace = NULL;
8854 ++ int depth;
8855 ++
8856 ++ /*compute depth from generated tree by BFS*/
8857 ++ depth = get_lock_depth(leaf);
8858 ++
8859 ++ do {
8860 ++ print_lock_class_header(entry->class, depth);
8861 ++ if (trace) {
8862 ++ printk("%*s ... acquired at:\n", depth, "");
8863 ++ print_lock_trace(trace, 2);
8864 ++ printk("\n");
8865 ++ }
8866 ++
8867 ++ /*
8868 ++ * Record the pointer to the trace for the next lock_list
8869 ++ * entry, see the comments for the function.
8870 ++ */
8871 ++ trace = entry->trace;
8872 ++
8873 ++ if (depth == 0 && (entry != root)) {
8874 ++ printk("lockdep:%s bad path found in chain graph\n", __func__);
8875 ++ break;
8876 ++ }
8877 ++
8878 ++ entry = get_lock_parent(entry);
8879 ++ depth--;
8880 ++ } while (entry && (depth >= 0));
8881 ++}
8882 ++
8883 + static void
8884 + print_irq_lock_scenario(struct lock_list *safe_entry,
8885 + struct lock_list *unsafe_entry,
8886 +@@ -2086,7 +2190,7 @@ print_bad_irq_dependency(struct task_struct *curr,
8887 + prev_root->trace = save_trace();
8888 + if (!prev_root->trace)
8889 + return;
8890 +- print_shortest_lock_dependencies(backwards_entry, prev_root);
8891 ++ print_shortest_lock_dependencies_backwards(backwards_entry, prev_root);
8892 +
8893 + pr_warn("\nthe dependencies between the lock to be acquired");
8894 + pr_warn(" and %s-irq-unsafe lock:\n", irqclass);
8895 +@@ -2273,8 +2377,18 @@ static int check_irq_usage(struct task_struct *curr, struct held_lock *prev,
8896 + * Step 3: we found a bad match! Now retrieve a lock from the backward
8897 + * list whose usage mask matches the exclusive usage mask from the
8898 + * lock found on the forward list.
8899 ++ *
8900 ++ * Note, we should only keep the LOCKF_ENABLED_IRQ_ALL bits, considering
8901 ++ * the follow case:
8902 ++ *
8903 ++ * When trying to add A -> B to the graph, we find that there is a
8904 ++ * hardirq-safe L, that L -> ... -> A, and another hardirq-unsafe M,
8905 ++ * that B -> ... -> M. However M is **softirq-safe**, if we use exact
8906 ++ * invert bits of M's usage_mask, we will find another lock N that is
8907 ++ * **softirq-unsafe** and N -> ... -> A, however N -> .. -> M will not
8908 ++ * cause a inversion deadlock.
8909 + */
8910 +- backward_mask = original_mask(target_entry1->class->usage_mask);
8911 ++ backward_mask = original_mask(target_entry1->class->usage_mask & LOCKF_ENABLED_IRQ_ALL);
8912 +
8913 + ret = find_usage_backwards(&this, backward_mask, &target_entry);
8914 + if (ret < 0) {
8915 +diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
8916 +index 4dfa9dd47223a..fd37827eca5b0 100644
8917 +--- a/kernel/rcu/tree.c
8918 ++++ b/kernel/rcu/tree.c
8919 +@@ -2498,7 +2498,6 @@ static int __init rcu_spawn_core_kthreads(void)
8920 + "%s: Could not start rcuc kthread, OOM is now expected behavior\n", __func__);
8921 + return 0;
8922 + }
8923 +-early_initcall(rcu_spawn_core_kthreads);
8924 +
8925 + /*
8926 + * Handle any core-RCU processing required by a call_rcu() invocation.
8927 +@@ -3315,6 +3314,7 @@ static int __init rcu_spawn_gp_kthread(void)
8928 + wake_up_process(t);
8929 + rcu_spawn_nocb_kthreads();
8930 + rcu_spawn_boost_kthreads();
8931 ++ rcu_spawn_core_kthreads();
8932 + return 0;
8933 + }
8934 + early_initcall(rcu_spawn_gp_kthread);
8935 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
8936 +index a3e95d7779e15..8294debf68c4d 100644
8937 +--- a/kernel/sched/core.c
8938 ++++ b/kernel/sched/core.c
8939 +@@ -894,9 +894,10 @@ unsigned int uclamp_rq_max_value(struct rq *rq, enum uclamp_id clamp_id,
8940 + static inline struct uclamp_se
8941 + uclamp_tg_restrict(struct task_struct *p, enum uclamp_id clamp_id)
8942 + {
8943 ++ /* Copy by value as we could modify it */
8944 + struct uclamp_se uc_req = p->uclamp_req[clamp_id];
8945 + #ifdef CONFIG_UCLAMP_TASK_GROUP
8946 +- struct uclamp_se uc_max;
8947 ++ unsigned int tg_min, tg_max, value;
8948 +
8949 + /*
8950 + * Tasks in autogroups or root task group will be
8951 +@@ -907,9 +908,11 @@ uclamp_tg_restrict(struct task_struct *p, enum uclamp_id clamp_id)
8952 + if (task_group(p) == &root_task_group)
8953 + return uc_req;
8954 +
8955 +- uc_max = task_group(p)->uclamp[clamp_id];
8956 +- if (uc_req.value > uc_max.value || !uc_req.user_defined)
8957 +- return uc_max;
8958 ++ tg_min = task_group(p)->uclamp[UCLAMP_MIN].value;
8959 ++ tg_max = task_group(p)->uclamp[UCLAMP_MAX].value;
8960 ++ value = uc_req.value;
8961 ++ value = clamp(value, tg_min, tg_max);
8962 ++ uclamp_se_set(&uc_req, value, false);
8963 + #endif
8964 +
8965 + return uc_req;
8966 +@@ -1108,8 +1111,9 @@ static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p)
8967 + }
8968 +
8969 + static inline void
8970 +-uclamp_update_active(struct task_struct *p, enum uclamp_id clamp_id)
8971 ++uclamp_update_active(struct task_struct *p)
8972 + {
8973 ++ enum uclamp_id clamp_id;
8974 + struct rq_flags rf;
8975 + struct rq *rq;
8976 +
8977 +@@ -1129,9 +1133,11 @@ uclamp_update_active(struct task_struct *p, enum uclamp_id clamp_id)
8978 + * affecting a valid clamp bucket, the next time it's enqueued,
8979 + * it will already see the updated clamp bucket value.
8980 + */
8981 +- if (p->uclamp[clamp_id].active) {
8982 +- uclamp_rq_dec_id(rq, p, clamp_id);
8983 +- uclamp_rq_inc_id(rq, p, clamp_id);
8984 ++ for_each_clamp_id(clamp_id) {
8985 ++ if (p->uclamp[clamp_id].active) {
8986 ++ uclamp_rq_dec_id(rq, p, clamp_id);
8987 ++ uclamp_rq_inc_id(rq, p, clamp_id);
8988 ++ }
8989 + }
8990 +
8991 + task_rq_unlock(rq, p, &rf);
8992 +@@ -1139,20 +1145,14 @@ uclamp_update_active(struct task_struct *p, enum uclamp_id clamp_id)
8993 +
8994 + #ifdef CONFIG_UCLAMP_TASK_GROUP
8995 + static inline void
8996 +-uclamp_update_active_tasks(struct cgroup_subsys_state *css,
8997 +- unsigned int clamps)
8998 ++uclamp_update_active_tasks(struct cgroup_subsys_state *css)
8999 + {
9000 +- enum uclamp_id clamp_id;
9001 + struct css_task_iter it;
9002 + struct task_struct *p;
9003 +
9004 + css_task_iter_start(css, 0, &it);
9005 +- while ((p = css_task_iter_next(&it))) {
9006 +- for_each_clamp_id(clamp_id) {
9007 +- if ((0x1 << clamp_id) & clamps)
9008 +- uclamp_update_active(p, clamp_id);
9009 +- }
9010 +- }
9011 ++ while ((p = css_task_iter_next(&it)))
9012 ++ uclamp_update_active(p);
9013 + css_task_iter_end(&it);
9014 + }
9015 +
9016 +@@ -7186,7 +7186,11 @@ static int cpu_cgroup_css_online(struct cgroup_subsys_state *css)
9017 +
9018 + #ifdef CONFIG_UCLAMP_TASK_GROUP
9019 + /* Propagate the effective uclamp value for the new group */
9020 ++ mutex_lock(&uclamp_mutex);
9021 ++ rcu_read_lock();
9022 + cpu_util_update_eff(css);
9023 ++ rcu_read_unlock();
9024 ++ mutex_unlock(&uclamp_mutex);
9025 + #endif
9026 +
9027 + return 0;
9028 +@@ -7276,6 +7280,9 @@ static void cpu_util_update_eff(struct cgroup_subsys_state *css)
9029 + enum uclamp_id clamp_id;
9030 + unsigned int clamps;
9031 +
9032 ++ lockdep_assert_held(&uclamp_mutex);
9033 ++ SCHED_WARN_ON(!rcu_read_lock_held());
9034 ++
9035 + css_for_each_descendant_pre(css, top_css) {
9036 + uc_parent = css_tg(css)->parent
9037 + ? css_tg(css)->parent->uclamp : NULL;
9038 +@@ -7308,7 +7315,7 @@ static void cpu_util_update_eff(struct cgroup_subsys_state *css)
9039 + }
9040 +
9041 + /* Immediately update descendants RUNNABLE tasks */
9042 +- uclamp_update_active_tasks(css, clamps);
9043 ++ uclamp_update_active_tasks(css);
9044 + }
9045 + }
9046 +
9047 +diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
9048 +index 4ce8c11e5e4ae..3cf776d5bce8f 100644
9049 +--- a/kernel/sched/deadline.c
9050 ++++ b/kernel/sched/deadline.c
9051 +@@ -2392,6 +2392,8 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
9052 + check_preempt_curr_dl(rq, p, 0);
9053 + else
9054 + resched_curr(rq);
9055 ++ } else {
9056 ++ update_dl_rq_load_avg(rq_clock_pelt(rq), rq, 0);
9057 + }
9058 + }
9059 +
9060 +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
9061 +index d3f4113e87ded..d2ba080ea7425 100644
9062 +--- a/kernel/sched/fair.c
9063 ++++ b/kernel/sched/fair.c
9064 +@@ -2927,7 +2927,7 @@ void reweight_task(struct task_struct *p, int prio)
9065 + *
9066 + * tg->weight * grq->load.weight
9067 + * ge->load.weight = ----------------------------- (1)
9068 +- * \Sum grq->load.weight
9069 ++ * \Sum grq->load.weight
9070 + *
9071 + * Now, because computing that sum is prohibitively expensive to compute (been
9072 + * there, done that) we approximate it with this average stuff. The average
9073 +@@ -2941,7 +2941,7 @@ void reweight_task(struct task_struct *p, int prio)
9074 + *
9075 + * tg->weight * grq->avg.load_avg
9076 + * ge->load.weight = ------------------------------ (3)
9077 +- * tg->load_avg
9078 ++ * tg->load_avg
9079 + *
9080 + * Where: tg->load_avg ~= \Sum grq->avg.load_avg
9081 + *
9082 +@@ -2957,7 +2957,7 @@ void reweight_task(struct task_struct *p, int prio)
9083 + *
9084 + * tg->weight * grq->load.weight
9085 + * ge->load.weight = ----------------------------- = tg->weight (4)
9086 +- * grp->load.weight
9087 ++ * grp->load.weight
9088 + *
9089 + * That is, the sum collapses because all other CPUs are idle; the UP scenario.
9090 + *
9091 +@@ -2976,7 +2976,7 @@ void reweight_task(struct task_struct *p, int prio)
9092 + *
9093 + * tg->weight * grq->load.weight
9094 + * ge->load.weight = ----------------------------- (6)
9095 +- * tg_load_avg'
9096 ++ * tg_load_avg'
9097 + *
9098 + * Where:
9099 + *
9100 +diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
9101 +index 5b04bba4500db..2dffb8762e16b 100644
9102 +--- a/kernel/sched/rt.c
9103 ++++ b/kernel/sched/rt.c
9104 +@@ -2221,13 +2221,20 @@ void __init init_sched_rt_class(void)
9105 + static void switched_to_rt(struct rq *rq, struct task_struct *p)
9106 + {
9107 + /*
9108 +- * If we are already running, then there's nothing
9109 +- * that needs to be done. But if we are not running
9110 +- * we may need to preempt the current running task.
9111 +- * If that current running task is also an RT task
9112 ++ * If we are running, update the avg_rt tracking, as the running time
9113 ++ * will now on be accounted into the latter.
9114 ++ */
9115 ++ if (task_current(rq, p)) {
9116 ++ update_rt_rq_load_avg(rq_clock_pelt(rq), rq, 0);
9117 ++ return;
9118 ++ }
9119 ++
9120 ++ /*
9121 ++ * If we are not running we may need to preempt the current
9122 ++ * running task. If that current running task is also an RT task
9123 + * then see if we can move to another run queue.
9124 + */
9125 +- if (task_on_rq_queued(p) && rq->curr != p) {
9126 ++ if (task_on_rq_queued(p)) {
9127 + #ifdef CONFIG_SMP
9128 + if (p->nr_cpus_allowed > 1 && rq->rt.overloaded)
9129 + rt_queue_push_tasks(rq);
9130 +diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
9131 +index 428beb69426a8..6863a054c9701 100644
9132 +--- a/kernel/time/clocksource.c
9133 ++++ b/kernel/time/clocksource.c
9134 +@@ -124,6 +124,13 @@ static void __clocksource_change_rating(struct clocksource *cs, int rating);
9135 + #define WATCHDOG_INTERVAL (HZ >> 1)
9136 + #define WATCHDOG_THRESHOLD (NSEC_PER_SEC >> 4)
9137 +
9138 ++/*
9139 ++ * Maximum permissible delay between two readouts of the watchdog
9140 ++ * clocksource surrounding a read of the clocksource being validated.
9141 ++ * This delay could be due to SMIs, NMIs, or to VCPU preemptions.
9142 ++ */
9143 ++#define WATCHDOG_MAX_SKEW (100 * NSEC_PER_USEC)
9144 ++
9145 + static void clocksource_watchdog_work(struct work_struct *work)
9146 + {
9147 + /*
9148 +@@ -184,12 +191,45 @@ void clocksource_mark_unstable(struct clocksource *cs)
9149 + spin_unlock_irqrestore(&watchdog_lock, flags);
9150 + }
9151 +
9152 ++static ulong max_cswd_read_retries = 3;
9153 ++module_param(max_cswd_read_retries, ulong, 0644);
9154 ++
9155 ++static bool cs_watchdog_read(struct clocksource *cs, u64 *csnow, u64 *wdnow)
9156 ++{
9157 ++ unsigned int nretries;
9158 ++ u64 wd_end, wd_delta;
9159 ++ int64_t wd_delay;
9160 ++
9161 ++ for (nretries = 0; nretries <= max_cswd_read_retries; nretries++) {
9162 ++ local_irq_disable();
9163 ++ *wdnow = watchdog->read(watchdog);
9164 ++ *csnow = cs->read(cs);
9165 ++ wd_end = watchdog->read(watchdog);
9166 ++ local_irq_enable();
9167 ++
9168 ++ wd_delta = clocksource_delta(wd_end, *wdnow, watchdog->mask);
9169 ++ wd_delay = clocksource_cyc2ns(wd_delta, watchdog->mult,
9170 ++ watchdog->shift);
9171 ++ if (wd_delay <= WATCHDOG_MAX_SKEW) {
9172 ++ if (nretries > 1 || nretries >= max_cswd_read_retries) {
9173 ++ pr_warn("timekeeping watchdog on CPU%d: %s retried %d times before success\n",
9174 ++ smp_processor_id(), watchdog->name, nretries);
9175 ++ }
9176 ++ return true;
9177 ++ }
9178 ++ }
9179 ++
9180 ++ pr_warn("timekeeping watchdog on CPU%d: %s read-back delay of %lldns, attempt %d, marking unstable\n",
9181 ++ smp_processor_id(), watchdog->name, wd_delay, nretries);
9182 ++ return false;
9183 ++}
9184 ++
9185 + static void clocksource_watchdog(struct timer_list *unused)
9186 + {
9187 +- struct clocksource *cs;
9188 + u64 csnow, wdnow, cslast, wdlast, delta;
9189 +- int64_t wd_nsec, cs_nsec;
9190 + int next_cpu, reset_pending;
9191 ++ int64_t wd_nsec, cs_nsec;
9192 ++ struct clocksource *cs;
9193 +
9194 + spin_lock(&watchdog_lock);
9195 + if (!watchdog_running)
9196 +@@ -206,10 +246,11 @@ static void clocksource_watchdog(struct timer_list *unused)
9197 + continue;
9198 + }
9199 +
9200 +- local_irq_disable();
9201 +- csnow = cs->read(cs);
9202 +- wdnow = watchdog->read(watchdog);
9203 +- local_irq_enable();
9204 ++ if (!cs_watchdog_read(cs, &csnow, &wdnow)) {
9205 ++ /* Clock readout unreliable, so give it up. */
9206 ++ __clocksource_unstable(cs);
9207 ++ continue;
9208 ++ }
9209 +
9210 + /* Clocksource initialized ? */
9211 + if (!(cs->flags & CLOCK_SOURCE_WATCHDOG) ||
9212 +diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
9213 +index 74c1db7178cff..4d9f818029112 100644
9214 +--- a/kernel/trace/bpf_trace.c
9215 ++++ b/kernel/trace/bpf_trace.c
9216 +@@ -1397,7 +1397,8 @@ static int __bpf_probe_register(struct bpf_raw_event_map *btp, struct bpf_prog *
9217 + if (prog->aux->max_tp_access > btp->writable_size)
9218 + return -EINVAL;
9219 +
9220 +- return tracepoint_probe_register(tp, (void *)btp->bpf_func, prog);
9221 ++ return tracepoint_probe_register_may_exist(tp, (void *)btp->bpf_func,
9222 ++ prog);
9223 + }
9224 +
9225 + int bpf_probe_register(struct bpf_raw_event_map *btp, struct bpf_prog *prog)
9226 +diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
9227 +index a616b314fb7ab..b05376a01091d 100644
9228 +--- a/kernel/trace/trace_events_hist.c
9229 ++++ b/kernel/trace/trace_events_hist.c
9230 +@@ -2437,6 +2437,13 @@ static int contains_operator(char *str)
9231 +
9232 + switch (*op) {
9233 + case '-':
9234 ++ /*
9235 ++ * Unfortunately, the modifier ".sym-offset"
9236 ++ * can confuse things.
9237 ++ */
9238 ++ if (op - str >= 4 && !strncmp(op - 4, ".sym-offset", 11))
9239 ++ return FIELD_OP_NONE;
9240 ++
9241 + if (*str == '-')
9242 + field_op = FIELD_OP_UNARY_MINUS;
9243 + else
9244 +diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
9245 +index be51df4508cbe..5d87b21ba1301 100644
9246 +--- a/kernel/tracepoint.c
9247 ++++ b/kernel/tracepoint.c
9248 +@@ -271,7 +271,8 @@ static void *func_remove(struct tracepoint_func **funcs,
9249 + * Add the probe function to a tracepoint.
9250 + */
9251 + static int tracepoint_add_func(struct tracepoint *tp,
9252 +- struct tracepoint_func *func, int prio)
9253 ++ struct tracepoint_func *func, int prio,
9254 ++ bool warn)
9255 + {
9256 + struct tracepoint_func *old, *tp_funcs;
9257 + int ret;
9258 +@@ -286,7 +287,7 @@ static int tracepoint_add_func(struct tracepoint *tp,
9259 + lockdep_is_held(&tracepoints_mutex));
9260 + old = func_add(&tp_funcs, func, prio);
9261 + if (IS_ERR(old)) {
9262 +- WARN_ON_ONCE(PTR_ERR(old) != -ENOMEM);
9263 ++ WARN_ON_ONCE(warn && PTR_ERR(old) != -ENOMEM);
9264 + return PTR_ERR(old);
9265 + }
9266 +
9267 +@@ -337,6 +338,32 @@ static int tracepoint_remove_func(struct tracepoint *tp,
9268 + return 0;
9269 + }
9270 +
9271 ++/**
9272 ++ * tracepoint_probe_register_prio_may_exist - Connect a probe to a tracepoint with priority
9273 ++ * @tp: tracepoint
9274 ++ * @probe: probe handler
9275 ++ * @data: tracepoint data
9276 ++ * @prio: priority of this function over other registered functions
9277 ++ *
9278 ++ * Same as tracepoint_probe_register_prio() except that it will not warn
9279 ++ * if the tracepoint is already registered.
9280 ++ */
9281 ++int tracepoint_probe_register_prio_may_exist(struct tracepoint *tp, void *probe,
9282 ++ void *data, int prio)
9283 ++{
9284 ++ struct tracepoint_func tp_func;
9285 ++ int ret;
9286 ++
9287 ++ mutex_lock(&tracepoints_mutex);
9288 ++ tp_func.func = probe;
9289 ++ tp_func.data = data;
9290 ++ tp_func.prio = prio;
9291 ++ ret = tracepoint_add_func(tp, &tp_func, prio, false);
9292 ++ mutex_unlock(&tracepoints_mutex);
9293 ++ return ret;
9294 ++}
9295 ++EXPORT_SYMBOL_GPL(tracepoint_probe_register_prio_may_exist);
9296 ++
9297 + /**
9298 + * tracepoint_probe_register_prio - Connect a probe to a tracepoint with priority
9299 + * @tp: tracepoint
9300 +@@ -360,7 +387,7 @@ int tracepoint_probe_register_prio(struct tracepoint *tp, void *probe,
9301 + tp_func.func = probe;
9302 + tp_func.data = data;
9303 + tp_func.prio = prio;
9304 +- ret = tracepoint_add_func(tp, &tp_func, prio);
9305 ++ ret = tracepoint_add_func(tp, &tp_func, prio, true);
9306 + mutex_unlock(&tracepoints_mutex);
9307 + return ret;
9308 + }
9309 +diff --git a/lib/iov_iter.c b/lib/iov_iter.c
9310 +index 9ea6f7bb83095..41b06af195368 100644
9311 +--- a/lib/iov_iter.c
9312 ++++ b/lib/iov_iter.c
9313 +@@ -422,7 +422,7 @@ int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes)
9314 + int err;
9315 + struct iovec v;
9316 +
9317 +- if (!(i->type & (ITER_BVEC|ITER_KVEC))) {
9318 ++ if (iter_is_iovec(i)) {
9319 + iterate_iovec(i, bytes, v, iov, skip, ({
9320 + err = fault_in_pages_readable(v.iov_base, v.iov_len);
9321 + if (unlikely(err))
9322 +@@ -896,9 +896,12 @@ size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes,
9323 + size_t wanted = copy_to_iter(kaddr + offset, bytes, i);
9324 + kunmap_atomic(kaddr);
9325 + return wanted;
9326 +- } else if (unlikely(iov_iter_is_discard(i)))
9327 ++ } else if (unlikely(iov_iter_is_discard(i))) {
9328 ++ if (unlikely(i->count < bytes))
9329 ++ bytes = i->count;
9330 ++ i->count -= bytes;
9331 + return bytes;
9332 +- else if (likely(!iov_iter_is_pipe(i)))
9333 ++ } else if (likely(!iov_iter_is_pipe(i)))
9334 + return copy_page_to_iter_iovec(page, offset, bytes, i);
9335 + else
9336 + return copy_page_to_iter_pipe(page, offset, bytes, i);
9337 +diff --git a/lib/kstrtox.c b/lib/kstrtox.c
9338 +index 1006bf70bf74c..95c7234ad4677 100644
9339 +--- a/lib/kstrtox.c
9340 ++++ b/lib/kstrtox.c
9341 +@@ -39,20 +39,22 @@ const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
9342 +
9343 + /*
9344 + * Convert non-negative integer string representation in explicitly given radix
9345 +- * to an integer.
9346 ++ * to an integer. A maximum of max_chars characters will be converted.
9347 ++ *
9348 + * Return number of characters consumed maybe or-ed with overflow bit.
9349 + * If overflow occurs, result integer (incorrect) is still returned.
9350 + *
9351 + * Don't you dare use this function.
9352 + */
9353 +-unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p)
9354 ++unsigned int _parse_integer_limit(const char *s, unsigned int base, unsigned long long *p,
9355 ++ size_t max_chars)
9356 + {
9357 + unsigned long long res;
9358 + unsigned int rv;
9359 +
9360 + res = 0;
9361 + rv = 0;
9362 +- while (1) {
9363 ++ while (max_chars--) {
9364 + unsigned int c = *s;
9365 + unsigned int lc = c | 0x20; /* don't tolower() this line */
9366 + unsigned int val;
9367 +@@ -82,6 +84,11 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long
9368 + return rv;
9369 + }
9370 +
9371 ++unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p)
9372 ++{
9373 ++ return _parse_integer_limit(s, base, p, INT_MAX);
9374 ++}
9375 ++
9376 + static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
9377 + {
9378 + unsigned long long _res;
9379 +diff --git a/lib/kstrtox.h b/lib/kstrtox.h
9380 +index 3b4637bcd2540..158c400ca8658 100644
9381 +--- a/lib/kstrtox.h
9382 ++++ b/lib/kstrtox.h
9383 +@@ -4,6 +4,8 @@
9384 +
9385 + #define KSTRTOX_OVERFLOW (1U << 31)
9386 + const char *_parse_integer_fixup_radix(const char *s, unsigned int *base);
9387 ++unsigned int _parse_integer_limit(const char *s, unsigned int base, unsigned long long *res,
9388 ++ size_t max_chars);
9389 + unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res);
9390 +
9391 + #endif
9392 +diff --git a/lib/seq_buf.c b/lib/seq_buf.c
9393 +index bd807f545a9d7..b15dbb6f061a5 100644
9394 +--- a/lib/seq_buf.c
9395 ++++ b/lib/seq_buf.c
9396 +@@ -242,12 +242,14 @@ int seq_buf_putmem_hex(struct seq_buf *s, const void *mem,
9397 + break;
9398 +
9399 + /* j increments twice per loop */
9400 +- len -= j / 2;
9401 + hex[j++] = ' ';
9402 +
9403 + seq_buf_putmem(s, hex, j);
9404 + if (seq_buf_has_overflowed(s))
9405 + return -1;
9406 ++
9407 ++ len -= start_len;
9408 ++ data += start_len;
9409 + }
9410 + return 0;
9411 + }
9412 +diff --git a/lib/vsprintf.c b/lib/vsprintf.c
9413 +index fb4af73142b42..2766d1b2c301d 100644
9414 +--- a/lib/vsprintf.c
9415 ++++ b/lib/vsprintf.c
9416 +@@ -50,6 +50,31 @@
9417 + #include <linux/string_helpers.h>
9418 + #include "kstrtox.h"
9419 +
9420 ++static unsigned long long simple_strntoull(const char *startp, size_t max_chars,
9421 ++ char **endp, unsigned int base)
9422 ++{
9423 ++ const char *cp;
9424 ++ unsigned long long result = 0ULL;
9425 ++ size_t prefix_chars;
9426 ++ unsigned int rv;
9427 ++
9428 ++ cp = _parse_integer_fixup_radix(startp, &base);
9429 ++ prefix_chars = cp - startp;
9430 ++ if (prefix_chars < max_chars) {
9431 ++ rv = _parse_integer_limit(cp, base, &result, max_chars - prefix_chars);
9432 ++ /* FIXME */
9433 ++ cp += (rv & ~KSTRTOX_OVERFLOW);
9434 ++ } else {
9435 ++ /* Field too short for prefix + digit, skip over without converting */
9436 ++ cp = startp + max_chars;
9437 ++ }
9438 ++
9439 ++ if (endp)
9440 ++ *endp = (char *)cp;
9441 ++
9442 ++ return result;
9443 ++}
9444 ++
9445 + /**
9446 + * simple_strtoull - convert a string to an unsigned long long
9447 + * @cp: The start of the string
9448 +@@ -60,18 +85,7 @@
9449 + */
9450 + unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
9451 + {
9452 +- unsigned long long result;
9453 +- unsigned int rv;
9454 +-
9455 +- cp = _parse_integer_fixup_radix(cp, &base);
9456 +- rv = _parse_integer(cp, base, &result);
9457 +- /* FIXME */
9458 +- cp += (rv & ~KSTRTOX_OVERFLOW);
9459 +-
9460 +- if (endp)
9461 +- *endp = (char *)cp;
9462 +-
9463 +- return result;
9464 ++ return simple_strntoull(cp, INT_MAX, endp, base);
9465 + }
9466 + EXPORT_SYMBOL(simple_strtoull);
9467 +
9468 +@@ -106,6 +120,21 @@ long simple_strtol(const char *cp, char **endp, unsigned int base)
9469 + }
9470 + EXPORT_SYMBOL(simple_strtol);
9471 +
9472 ++static long long simple_strntoll(const char *cp, size_t max_chars, char **endp,
9473 ++ unsigned int base)
9474 ++{
9475 ++ /*
9476 ++ * simple_strntoull() safely handles receiving max_chars==0 in the
9477 ++ * case cp[0] == '-' && max_chars == 1.
9478 ++ * If max_chars == 0 we can drop through and pass it to simple_strntoull()
9479 ++ * and the content of *cp is irrelevant.
9480 ++ */
9481 ++ if (*cp == '-' && max_chars > 0)
9482 ++ return -simple_strntoull(cp + 1, max_chars - 1, endp, base);
9483 ++
9484 ++ return simple_strntoull(cp, max_chars, endp, base);
9485 ++}
9486 ++
9487 + /**
9488 + * simple_strtoll - convert a string to a signed long long
9489 + * @cp: The start of the string
9490 +@@ -116,10 +145,7 @@ EXPORT_SYMBOL(simple_strtol);
9491 + */
9492 + long long simple_strtoll(const char *cp, char **endp, unsigned int base)
9493 + {
9494 +- if (*cp == '-')
9495 +- return -simple_strtoull(cp + 1, endp, base);
9496 +-
9497 +- return simple_strtoull(cp, endp, base);
9498 ++ return simple_strntoll(cp, INT_MAX, endp, base);
9499 + }
9500 + EXPORT_SYMBOL(simple_strtoll);
9501 +
9502 +@@ -3343,25 +3369,13 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
9503 + break;
9504 +
9505 + if (is_sign)
9506 +- val.s = qualifier != 'L' ?
9507 +- simple_strtol(str, &next, base) :
9508 +- simple_strtoll(str, &next, base);
9509 ++ val.s = simple_strntoll(str,
9510 ++ field_width >= 0 ? field_width : INT_MAX,
9511 ++ &next, base);
9512 + else
9513 +- val.u = qualifier != 'L' ?
9514 +- simple_strtoul(str, &next, base) :
9515 +- simple_strtoull(str, &next, base);
9516 +-
9517 +- if (field_width > 0 && next - str > field_width) {
9518 +- if (base == 0)
9519 +- _parse_integer_fixup_radix(str, &base);
9520 +- while (next - str > field_width) {
9521 +- if (is_sign)
9522 +- val.s = div_s64(val.s, base);
9523 +- else
9524 +- val.u = div_u64(val.u, base);
9525 +- --next;
9526 +- }
9527 +- }
9528 ++ val.u = simple_strntoull(str,
9529 ++ field_width >= 0 ? field_width : INT_MAX,
9530 ++ &next, base);
9531 +
9532 + switch (qualifier) {
9533 + case 'H': /* that's 'hh' in format */
9534 +diff --git a/mm/huge_memory.c b/mm/huge_memory.c
9535 +index 87a07aa61be0d..e50799d7002e5 100644
9536 +--- a/mm/huge_memory.c
9537 ++++ b/mm/huge_memory.c
9538 +@@ -1723,7 +1723,7 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
9539 + * If other processes are mapping this page, we couldn't discard
9540 + * the page unless they all do MADV_FREE so let's skip the page.
9541 + */
9542 +- if (page_mapcount(page) != 1)
9543 ++ if (total_mapcount(page) != 1)
9544 + goto out;
9545 +
9546 + if (!trylock_page(page))
9547 +diff --git a/mm/z3fold.c b/mm/z3fold.c
9548 +index 6d3d3f698ebb9..e97143713021e 100644
9549 +--- a/mm/z3fold.c
9550 ++++ b/mm/z3fold.c
9551 +@@ -839,6 +839,7 @@ static void z3fold_destroy_pool(struct z3fold_pool *pool)
9552 + destroy_workqueue(pool->compact_wq);
9553 + destroy_workqueue(pool->release_wq);
9554 + z3fold_unregister_migration(pool);
9555 ++ free_percpu(pool->unbuddied);
9556 + kfree(pool);
9557 + }
9558 +
9559 +diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
9560 +index bd678ffdaef73..e8e7f108b0161 100644
9561 +--- a/net/bluetooth/hci_event.c
9562 ++++ b/net/bluetooth/hci_event.c
9563 +@@ -5101,8 +5101,19 @@ static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb)
9564 +
9565 + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
9566 +
9567 +- if (ev->status)
9568 ++ if (ev->status) {
9569 ++ struct adv_info *adv;
9570 ++
9571 ++ adv = hci_find_adv_instance(hdev, ev->handle);
9572 ++ if (!adv)
9573 ++ return;
9574 ++
9575 ++ /* Remove advertising as it has been terminated */
9576 ++ hci_remove_adv_instance(hdev, ev->handle);
9577 ++ mgmt_advertising_removed(NULL, hdev, ev->handle);
9578 ++
9579 + return;
9580 ++ }
9581 +
9582 + conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle));
9583 + if (conn) {
9584 +diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
9585 +index 5fce559a61bf5..db525321da1f8 100644
9586 +--- a/net/bluetooth/mgmt.c
9587 ++++ b/net/bluetooth/mgmt.c
9588 +@@ -6461,6 +6461,9 @@ static bool tlv_data_is_valid(struct hci_dev *hdev, u32 adv_flags, u8 *data,
9589 + for (i = 0, cur_len = 0; i < len; i += (cur_len + 1)) {
9590 + cur_len = data[i];
9591 +
9592 ++ if (!cur_len)
9593 ++ continue;
9594 ++
9595 + if (data[i + 1] == EIR_FLAGS &&
9596 + (!is_adv_data || flags_managed(adv_flags)))
9597 + return false;
9598 +diff --git a/net/bpfilter/main.c b/net/bpfilter/main.c
9599 +index 05e1cfc1e5cd1..291a925462463 100644
9600 +--- a/net/bpfilter/main.c
9601 ++++ b/net/bpfilter/main.c
9602 +@@ -57,7 +57,7 @@ int main(void)
9603 + {
9604 + debug_f = fopen("/dev/kmsg", "w");
9605 + setvbuf(debug_f, 0, _IOLBF, 0);
9606 +- fprintf(debug_f, "Started bpfilter\n");
9607 ++ fprintf(debug_f, "<5>Started bpfilter\n");
9608 + loop();
9609 + fclose(debug_f);
9610 + return 0;
9611 +diff --git a/net/can/bcm.c b/net/can/bcm.c
9612 +index a7abced793765..1e17778d5ceeb 100644
9613 +--- a/net/can/bcm.c
9614 ++++ b/net/can/bcm.c
9615 +@@ -787,6 +787,7 @@ static int bcm_delete_rx_op(struct list_head *ops, struct bcm_msg_head *mh,
9616 + bcm_rx_handler, op);
9617 +
9618 + list_del(&op->list);
9619 ++ synchronize_rcu();
9620 + bcm_remove_op(op);
9621 + return 1; /* done */
9622 + }
9623 +@@ -1535,9 +1536,13 @@ static int bcm_release(struct socket *sock)
9624 + REGMASK(op->can_id),
9625 + bcm_rx_handler, op);
9626 +
9627 +- bcm_remove_op(op);
9628 + }
9629 +
9630 ++ synchronize_rcu();
9631 ++
9632 ++ list_for_each_entry_safe(op, next, &bo->rx_ops, list)
9633 ++ bcm_remove_op(op);
9634 ++
9635 + #if IS_ENABLED(CONFIG_PROC_FS)
9636 + /* remove procfs entry */
9637 + if (net->can.bcmproc_dir && bo->bcm_proc_read)
9638 +diff --git a/net/can/gw.c b/net/can/gw.c
9639 +index 65d60c93af294..ac2a5f11a7668 100644
9640 +--- a/net/can/gw.c
9641 ++++ b/net/can/gw.c
9642 +@@ -535,6 +535,7 @@ static int cgw_notifier(struct notifier_block *nb,
9643 + if (gwj->src.dev == dev || gwj->dst.dev == dev) {
9644 + hlist_del(&gwj->list);
9645 + cgw_unregister_filter(net, gwj);
9646 ++ synchronize_rcu();
9647 + kmem_cache_free(cgw_cache, gwj);
9648 + }
9649 + }
9650 +@@ -1093,6 +1094,7 @@ static void cgw_remove_all_jobs(struct net *net)
9651 + hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) {
9652 + hlist_del(&gwj->list);
9653 + cgw_unregister_filter(net, gwj);
9654 ++ synchronize_rcu();
9655 + kmem_cache_free(cgw_cache, gwj);
9656 + }
9657 + }
9658 +@@ -1161,6 +1163,7 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh,
9659 +
9660 + hlist_del(&gwj->list);
9661 + cgw_unregister_filter(net, gwj);
9662 ++ synchronize_rcu();
9663 + kmem_cache_free(cgw_cache, gwj);
9664 + err = 0;
9665 + break;
9666 +diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c
9667 +index e52330f628c9f..6884d18f919c7 100644
9668 +--- a/net/can/j1939/main.c
9669 ++++ b/net/can/j1939/main.c
9670 +@@ -193,6 +193,10 @@ static void j1939_can_rx_unregister(struct j1939_priv *priv)
9671 + can_rx_unregister(dev_net(ndev), ndev, J1939_CAN_ID, J1939_CAN_MASK,
9672 + j1939_can_recv, priv);
9673 +
9674 ++ /* The last reference of priv is dropped by the RCU deferred
9675 ++ * j1939_sk_sock_destruct() of the last socket, so we can
9676 ++ * safely drop this reference here.
9677 ++ */
9678 + j1939_priv_put(priv);
9679 + }
9680 +
9681 +diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
9682 +index d57475c8ba07f..51bfb220fad85 100644
9683 +--- a/net/can/j1939/socket.c
9684 ++++ b/net/can/j1939/socket.c
9685 +@@ -398,6 +398,9 @@ static int j1939_sk_init(struct sock *sk)
9686 + atomic_set(&jsk->skb_pending, 0);
9687 + spin_lock_init(&jsk->sk_session_queue_lock);
9688 + INIT_LIST_HEAD(&jsk->sk_session_queue);
9689 ++
9690 ++ /* j1939_sk_sock_destruct() depends on SOCK_RCU_FREE flag */
9691 ++ sock_set_flag(sk, SOCK_RCU_FREE);
9692 + sk->sk_destruct = j1939_sk_sock_destruct;
9693 + sk->sk_protocol = CAN_J1939;
9694 +
9695 +diff --git a/net/core/filter.c b/net/core/filter.c
9696 +index 108bcf6000529..0e161a6dff7e5 100644
9697 +--- a/net/core/filter.c
9698 ++++ b/net/core/filter.c
9699 +@@ -2861,8 +2861,6 @@ static int bpf_skb_proto_4_to_6(struct sk_buff *skb)
9700 + shinfo->gso_type |= SKB_GSO_TCPV6;
9701 + }
9702 +
9703 +- /* Due to IPv6 header, MSS needs to be downgraded. */
9704 +- skb_decrease_gso_size(shinfo, len_diff);
9705 + /* Header must be checked, and gso_segs recomputed. */
9706 + shinfo->gso_type |= SKB_GSO_DODGY;
9707 + shinfo->gso_segs = 0;
9708 +@@ -2902,8 +2900,6 @@ static int bpf_skb_proto_6_to_4(struct sk_buff *skb)
9709 + shinfo->gso_type |= SKB_GSO_TCPV4;
9710 + }
9711 +
9712 +- /* Due to IPv4 header, MSS can be upgraded. */
9713 +- skb_increase_gso_size(shinfo, len_diff);
9714 + /* Header must be checked, and gso_segs recomputed. */
9715 + shinfo->gso_type |= SKB_GSO_DODGY;
9716 + shinfo->gso_segs = 0;
9717 +diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
9718 +index 00210e55b4cd1..86c836fa21459 100644
9719 +--- a/net/ipv4/esp4.c
9720 ++++ b/net/ipv4/esp4.c
9721 +@@ -499,7 +499,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
9722 + struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb);
9723 + u32 padto;
9724 +
9725 +- padto = min(x->tfcpad, xfrm_state_mtu(x, dst->child_mtu_cached));
9726 ++ padto = min(x->tfcpad, __xfrm_state_mtu(x, dst->child_mtu_cached));
9727 + if (skb->len < padto)
9728 + esp.tfclen = padto - skb->len;
9729 + }
9730 +diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
9731 +index 2ce191019526e..b875b98820ede 100644
9732 +--- a/net/ipv4/fib_frontend.c
9733 ++++ b/net/ipv4/fib_frontend.c
9734 +@@ -381,6 +381,8 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
9735 + fl4.flowi4_proto = 0;
9736 + fl4.fl4_sport = 0;
9737 + fl4.fl4_dport = 0;
9738 ++ } else {
9739 ++ swap(fl4.fl4_sport, fl4.fl4_dport);
9740 + }
9741 +
9742 + if (fib_lookup(net, &fl4, &res, 0))
9743 +diff --git a/net/ipv4/route.c b/net/ipv4/route.c
9744 +index 3ff702380b629..0e976848d4bb9 100644
9745 +--- a/net/ipv4/route.c
9746 ++++ b/net/ipv4/route.c
9747 +@@ -1321,7 +1321,7 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst)
9748 + mtu = dst_metric_raw(dst, RTAX_MTU);
9749 +
9750 + if (mtu)
9751 +- return mtu;
9752 ++ goto out;
9753 +
9754 + mtu = READ_ONCE(dst->dev->mtu);
9755 +
9756 +@@ -1330,6 +1330,7 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst)
9757 + mtu = 576;
9758 + }
9759 +
9760 ++out:
9761 + mtu = min_t(unsigned int, mtu, IP_MAX_MTU);
9762 +
9763 + return mtu - lwtunnel_headroom(dst->lwtstate, mtu);
9764 +diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
9765 +index 7a739f16d82b2..12570a73def80 100644
9766 +--- a/net/ipv6/esp6.c
9767 ++++ b/net/ipv6/esp6.c
9768 +@@ -440,7 +440,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
9769 + struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb);
9770 + u32 padto;
9771 +
9772 +- padto = min(x->tfcpad, xfrm_state_mtu(x, dst->child_mtu_cached));
9773 ++ padto = min(x->tfcpad, __xfrm_state_mtu(x, dst->child_mtu_cached));
9774 + if (skb->len < padto)
9775 + esp.tfclen = padto - skb->len;
9776 + }
9777 +diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
9778 +index ab5add0fe6b49..69128000bc31b 100644
9779 +--- a/net/ipv6/exthdrs.c
9780 ++++ b/net/ipv6/exthdrs.c
9781 +@@ -134,18 +134,23 @@ static bool ip6_parse_tlv(const struct tlvtype_proc *procs,
9782 + len -= 2;
9783 +
9784 + while (len > 0) {
9785 +- int optlen = nh[off + 1] + 2;
9786 +- int i;
9787 ++ int optlen, i;
9788 +
9789 +- switch (nh[off]) {
9790 +- case IPV6_TLV_PAD1:
9791 +- optlen = 1;
9792 ++ if (nh[off] == IPV6_TLV_PAD1) {
9793 + padlen++;
9794 + if (padlen > 7)
9795 + goto bad;
9796 +- break;
9797 ++ off++;
9798 ++ len--;
9799 ++ continue;
9800 ++ }
9801 ++ if (len < 2)
9802 ++ goto bad;
9803 ++ optlen = nh[off + 1] + 2;
9804 ++ if (optlen > len)
9805 ++ goto bad;
9806 +
9807 +- case IPV6_TLV_PADN:
9808 ++ if (nh[off] == IPV6_TLV_PADN) {
9809 + /* RFC 2460 states that the purpose of PadN is
9810 + * to align the containing header to multiples
9811 + * of 8. 7 is therefore the highest valid value.
9812 +@@ -162,12 +167,7 @@ static bool ip6_parse_tlv(const struct tlvtype_proc *procs,
9813 + if (nh[off + i] != 0)
9814 + goto bad;
9815 + }
9816 +- break;
9817 +-
9818 +- default: /* Other TLV code so scan list */
9819 +- if (optlen > len)
9820 +- goto bad;
9821 +-
9822 ++ } else {
9823 + tlv_count++;
9824 + if (tlv_count > max_count)
9825 + goto bad;
9826 +@@ -187,7 +187,6 @@ static bool ip6_parse_tlv(const struct tlvtype_proc *procs,
9827 + return false;
9828 +
9829 + padlen = 0;
9830 +- break;
9831 + }
9832 + off += optlen;
9833 + len -= optlen;
9834 +@@ -305,7 +304,7 @@ fail_and_free:
9835 + #endif
9836 +
9837 + if (ip6_parse_tlv(tlvprocdestopt_lst, skb,
9838 +- init_net.ipv6.sysctl.max_dst_opts_cnt)) {
9839 ++ net->ipv6.sysctl.max_dst_opts_cnt)) {
9840 + skb->transport_header += extlen;
9841 + opt = IP6CB(skb);
9842 + #if IS_ENABLED(CONFIG_IPV6_MIP6)
9843 +@@ -844,7 +843,7 @@ fail_and_free:
9844 +
9845 + opt->flags |= IP6SKB_HOPBYHOP;
9846 + if (ip6_parse_tlv(tlvprochopopt_lst, skb,
9847 +- init_net.ipv6.sysctl.max_hbh_opts_cnt)) {
9848 ++ net->ipv6.sysctl.max_hbh_opts_cnt)) {
9849 + skb->transport_header += extlen;
9850 + opt = IP6CB(skb);
9851 + opt->nhoff = sizeof(struct ipv6hdr);
9852 +diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
9853 +index 44fd922cc32af..ccaf2389ccc1d 100644
9854 +--- a/net/mac80211/mlme.c
9855 ++++ b/net/mac80211/mlme.c
9856 +@@ -1014,11 +1014,6 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local,
9857 + struct ieee80211_hdr_3addr *nullfunc;
9858 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
9859 +
9860 +- /* Don't send NDPs when STA is connected HE */
9861 +- if (sdata->vif.type == NL80211_IFTYPE_STATION &&
9862 +- !(ifmgd->flags & IEEE80211_STA_DISABLE_HE))
9863 +- return;
9864 +-
9865 + skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif,
9866 + !ieee80211_hw_check(&local->hw, DOESNT_SUPPORT_QOS_NDP));
9867 + if (!skb)
9868 +@@ -1050,10 +1045,6 @@ static void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
9869 + if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
9870 + return;
9871 +
9872 +- /* Don't send NDPs when connected HE */
9873 +- if (!(sdata->u.mgd.flags & IEEE80211_STA_DISABLE_HE))
9874 +- return;
9875 +-
9876 + skb = dev_alloc_skb(local->hw.extra_tx_headroom + 30);
9877 + if (!skb)
9878 + return;
9879 +diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
9880 +index 82a1dd7b7d689..7b2e8c890381a 100644
9881 +--- a/net/mac80211/sta_info.c
9882 ++++ b/net/mac80211/sta_info.c
9883 +@@ -1395,11 +1395,6 @@ static void ieee80211_send_null_response(struct sta_info *sta, int tid,
9884 + struct ieee80211_tx_info *info;
9885 + struct ieee80211_chanctx_conf *chanctx_conf;
9886 +
9887 +- /* Don't send NDPs when STA is connected HE */
9888 +- if (sdata->vif.type == NL80211_IFTYPE_STATION &&
9889 +- !(sdata->u.mgd.flags & IEEE80211_STA_DISABLE_HE))
9890 +- return;
9891 +-
9892 + if (qos) {
9893 + fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
9894 + IEEE80211_STYPE_QOS_NULLFUNC |
9895 +diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
9896 +index 427d77b111b17..00f4323cfeb87 100644
9897 +--- a/net/netfilter/nft_exthdr.c
9898 ++++ b/net/netfilter/nft_exthdr.c
9899 +@@ -42,6 +42,9 @@ static void nft_exthdr_ipv6_eval(const struct nft_expr *expr,
9900 + unsigned int offset = 0;
9901 + int err;
9902 +
9903 ++ if (pkt->skb->protocol != htons(ETH_P_IPV6))
9904 ++ goto err;
9905 ++
9906 + err = ipv6_find_hdr(pkt->skb, &offset, priv->type, NULL, NULL);
9907 + if (priv->flags & NFT_EXTHDR_F_PRESENT) {
9908 + nft_reg_store8(dest, err >= 0);
9909 +diff --git a/net/netfilter/nft_osf.c b/net/netfilter/nft_osf.c
9910 +index b42247aa48a9e..4911f8eb394ff 100644
9911 +--- a/net/netfilter/nft_osf.c
9912 ++++ b/net/netfilter/nft_osf.c
9913 +@@ -28,6 +28,11 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs,
9914 + struct nf_osf_data data;
9915 + struct tcphdr _tcph;
9916 +
9917 ++ if (pkt->tprot != IPPROTO_TCP) {
9918 ++ regs->verdict.code = NFT_BREAK;
9919 ++ return;
9920 ++ }
9921 ++
9922 + tcp = skb_header_pointer(skb, ip_hdrlen(skb),
9923 + sizeof(struct tcphdr), &_tcph);
9924 + if (!tcp) {
9925 +diff --git a/net/netfilter/nft_tproxy.c b/net/netfilter/nft_tproxy.c
9926 +index 95980154ef02c..b97ab1198b03f 100644
9927 +--- a/net/netfilter/nft_tproxy.c
9928 ++++ b/net/netfilter/nft_tproxy.c
9929 +@@ -30,6 +30,12 @@ static void nft_tproxy_eval_v4(const struct nft_expr *expr,
9930 + __be16 tport = 0;
9931 + struct sock *sk;
9932 +
9933 ++ if (pkt->tprot != IPPROTO_TCP &&
9934 ++ pkt->tprot != IPPROTO_UDP) {
9935 ++ regs->verdict.code = NFT_BREAK;
9936 ++ return;
9937 ++ }
9938 ++
9939 + hp = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_hdr), &_hdr);
9940 + if (!hp) {
9941 + regs->verdict.code = NFT_BREAK;
9942 +@@ -91,7 +97,8 @@ static void nft_tproxy_eval_v6(const struct nft_expr *expr,
9943 +
9944 + memset(&taddr, 0, sizeof(taddr));
9945 +
9946 +- if (!pkt->tprot_set) {
9947 ++ if (pkt->tprot != IPPROTO_TCP &&
9948 ++ pkt->tprot != IPPROTO_UDP) {
9949 + regs->verdict.code = NFT_BREAK;
9950 + return;
9951 + }
9952 +diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
9953 +index e7a25fbfaf8b4..a92ed37d09226 100644
9954 +--- a/net/netlabel/netlabel_mgmt.c
9955 ++++ b/net/netlabel/netlabel_mgmt.c
9956 +@@ -76,6 +76,7 @@ static const struct nla_policy netlbl_mgmt_genl_policy[NLBL_MGMT_A_MAX + 1] = {
9957 + static int netlbl_mgmt_add_common(struct genl_info *info,
9958 + struct netlbl_audit *audit_info)
9959 + {
9960 ++ void *pmap = NULL;
9961 + int ret_val = -EINVAL;
9962 + struct netlbl_domaddr_map *addrmap = NULL;
9963 + struct cipso_v4_doi *cipsov4 = NULL;
9964 +@@ -175,6 +176,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
9965 + ret_val = -ENOMEM;
9966 + goto add_free_addrmap;
9967 + }
9968 ++ pmap = map;
9969 + map->list.addr = addr->s_addr & mask->s_addr;
9970 + map->list.mask = mask->s_addr;
9971 + map->list.valid = 1;
9972 +@@ -183,10 +185,8 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
9973 + map->def.cipso = cipsov4;
9974 +
9975 + ret_val = netlbl_af4list_add(&map->list, &addrmap->list4);
9976 +- if (ret_val != 0) {
9977 +- kfree(map);
9978 +- goto add_free_addrmap;
9979 +- }
9980 ++ if (ret_val != 0)
9981 ++ goto add_free_map;
9982 +
9983 + entry->family = AF_INET;
9984 + entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
9985 +@@ -223,6 +223,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
9986 + ret_val = -ENOMEM;
9987 + goto add_free_addrmap;
9988 + }
9989 ++ pmap = map;
9990 + map->list.addr = *addr;
9991 + map->list.addr.s6_addr32[0] &= mask->s6_addr32[0];
9992 + map->list.addr.s6_addr32[1] &= mask->s6_addr32[1];
9993 +@@ -235,10 +236,8 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
9994 + map->def.calipso = calipso;
9995 +
9996 + ret_val = netlbl_af6list_add(&map->list, &addrmap->list6);
9997 +- if (ret_val != 0) {
9998 +- kfree(map);
9999 +- goto add_free_addrmap;
10000 +- }
10001 ++ if (ret_val != 0)
10002 ++ goto add_free_map;
10003 +
10004 + entry->family = AF_INET6;
10005 + entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
10006 +@@ -248,10 +247,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
10007 +
10008 + ret_val = netlbl_domhsh_add(entry, audit_info);
10009 + if (ret_val != 0)
10010 +- goto add_free_addrmap;
10011 ++ goto add_free_map;
10012 +
10013 + return 0;
10014 +
10015 ++add_free_map:
10016 ++ kfree(pmap);
10017 + add_free_addrmap:
10018 + kfree(addrmap);
10019 + add_doi_put_def:
10020 +diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c
10021 +index 3c26042f4ea6d..7dc76c68ec52d 100644
10022 +--- a/net/sched/act_vlan.c
10023 ++++ b/net/sched/act_vlan.c
10024 +@@ -70,7 +70,7 @@ static int tcf_vlan_act(struct sk_buff *skb, const struct tc_action *a,
10025 + /* replace the vid */
10026 + tci = (tci & ~VLAN_VID_MASK) | p->tcfv_push_vid;
10027 + /* replace prio bits, if tcfv_push_prio specified */
10028 +- if (p->tcfv_push_prio) {
10029 ++ if (p->tcfv_push_prio_exists) {
10030 + tci &= ~VLAN_PRIO_MASK;
10031 + tci |= p->tcfv_push_prio << VLAN_PRIO_SHIFT;
10032 + }
10033 +@@ -107,6 +107,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
10034 + struct tc_action_net *tn = net_generic(net, vlan_net_id);
10035 + struct nlattr *tb[TCA_VLAN_MAX + 1];
10036 + struct tcf_chain *goto_ch = NULL;
10037 ++ bool push_prio_exists = false;
10038 + struct tcf_vlan_params *p;
10039 + struct tc_vlan *parm;
10040 + struct tcf_vlan *v;
10041 +@@ -175,7 +176,8 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
10042 + push_proto = htons(ETH_P_8021Q);
10043 + }
10044 +
10045 +- if (tb[TCA_VLAN_PUSH_VLAN_PRIORITY])
10046 ++ push_prio_exists = !!tb[TCA_VLAN_PUSH_VLAN_PRIORITY];
10047 ++ if (push_prio_exists)
10048 + push_prio = nla_get_u8(tb[TCA_VLAN_PUSH_VLAN_PRIORITY]);
10049 + break;
10050 + default:
10051 +@@ -216,6 +218,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
10052 + p->tcfv_action = action;
10053 + p->tcfv_push_vid = push_vid;
10054 + p->tcfv_push_prio = push_prio;
10055 ++ p->tcfv_push_prio_exists = push_prio_exists || action == TCA_VLAN_ACT_PUSH;
10056 + p->tcfv_push_proto = push_proto;
10057 +
10058 + spin_lock_bh(&v->tcf_lock);
10059 +diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
10060 +index c9399e81c5059..3e81f87d0c89f 100644
10061 +--- a/net/sched/cls_tcindex.c
10062 ++++ b/net/sched/cls_tcindex.c
10063 +@@ -304,7 +304,7 @@ static int tcindex_alloc_perfect_hash(struct net *net, struct tcindex_data *cp)
10064 + int i, err = 0;
10065 +
10066 + cp->perfect = kcalloc(cp->hash, sizeof(struct tcindex_filter_result),
10067 +- GFP_KERNEL);
10068 ++ GFP_KERNEL | __GFP_NOWARN);
10069 + if (!cp->perfect)
10070 + return -ENOMEM;
10071 +
10072 +diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
10073 +index 0b05ac7c848eb..b046fd3cac2cf 100644
10074 +--- a/net/sched/sch_qfq.c
10075 ++++ b/net/sched/sch_qfq.c
10076 +@@ -485,11 +485,6 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
10077 +
10078 + if (cl->qdisc != &noop_qdisc)
10079 + qdisc_hash_add(cl->qdisc, true);
10080 +- sch_tree_lock(sch);
10081 +- qdisc_class_hash_insert(&q->clhash, &cl->common);
10082 +- sch_tree_unlock(sch);
10083 +-
10084 +- qdisc_class_hash_grow(sch, &q->clhash);
10085 +
10086 + set_change_agg:
10087 + sch_tree_lock(sch);
10088 +@@ -507,8 +502,11 @@ set_change_agg:
10089 + }
10090 + if (existing)
10091 + qfq_deact_rm_from_agg(q, cl);
10092 ++ else
10093 ++ qdisc_class_hash_insert(&q->clhash, &cl->common);
10094 + qfq_add_to_agg(q, new_agg, cl);
10095 + sch_tree_unlock(sch);
10096 ++ qdisc_class_hash_grow(sch, &q->clhash);
10097 +
10098 + *arg = (unsigned long)cl;
10099 + return 0;
10100 +diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
10101 +index 4beb6d2957c33..8fc4a6b3422f4 100644
10102 +--- a/net/sunrpc/sched.c
10103 ++++ b/net/sunrpc/sched.c
10104 +@@ -613,11 +613,21 @@ static struct rpc_task *__rpc_find_next_queued_priority(struct rpc_wait_queue *q
10105 + struct list_head *q;
10106 + struct rpc_task *task;
10107 +
10108 ++ /*
10109 ++ * Service the privileged queue.
10110 ++ */
10111 ++ q = &queue->tasks[RPC_NR_PRIORITY - 1];
10112 ++ if (queue->maxpriority > RPC_PRIORITY_PRIVILEGED && !list_empty(q)) {
10113 ++ task = list_first_entry(q, struct rpc_task, u.tk_wait.list);
10114 ++ goto out;
10115 ++ }
10116 ++
10117 + /*
10118 + * Service a batch of tasks from a single owner.
10119 + */
10120 + q = &queue->tasks[queue->priority];
10121 +- if (!list_empty(q) && --queue->nr) {
10122 ++ if (!list_empty(q) && queue->nr) {
10123 ++ queue->nr--;
10124 + task = list_first_entry(q, struct rpc_task, u.tk_wait.list);
10125 + goto out;
10126 + }
10127 +diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
10128 +index cdb65aa54be70..7fb5c067f4293 100644
10129 +--- a/net/tls/tls_sw.c
10130 ++++ b/net/tls/tls_sw.c
10131 +@@ -1150,7 +1150,7 @@ static int tls_sw_do_sendpage(struct sock *sk, struct page *page,
10132 + int ret = 0;
10133 + bool eor;
10134 +
10135 +- eor = !(flags & (MSG_MORE | MSG_SENDPAGE_NOTLAST));
10136 ++ eor = !(flags & MSG_SENDPAGE_NOTLAST);
10137 + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
10138 +
10139 + /* Call the sk_stream functions to manage the sndbuf mem. */
10140 +diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
10141 +index 1423e2b7cb42a..c6b2c99b501b9 100644
10142 +--- a/net/xfrm/xfrm_state.c
10143 ++++ b/net/xfrm/xfrm_state.c
10144 +@@ -2440,7 +2440,7 @@ void xfrm_state_delete_tunnel(struct xfrm_state *x)
10145 + }
10146 + EXPORT_SYMBOL(xfrm_state_delete_tunnel);
10147 +
10148 +-u32 xfrm_state_mtu(struct xfrm_state *x, int mtu)
10149 ++u32 __xfrm_state_mtu(struct xfrm_state *x, int mtu)
10150 + {
10151 + const struct xfrm_type *type = READ_ONCE(x->type);
10152 + struct crypto_aead *aead;
10153 +@@ -2471,7 +2471,17 @@ u32 xfrm_state_mtu(struct xfrm_state *x, int mtu)
10154 + return ((mtu - x->props.header_len - crypto_aead_authsize(aead) -
10155 + net_adj) & ~(blksize - 1)) + net_adj - 2;
10156 + }
10157 +-EXPORT_SYMBOL_GPL(xfrm_state_mtu);
10158 ++EXPORT_SYMBOL_GPL(__xfrm_state_mtu);
10159 ++
10160 ++u32 xfrm_state_mtu(struct xfrm_state *x, int mtu)
10161 ++{
10162 ++ mtu = __xfrm_state_mtu(x, mtu);
10163 ++
10164 ++ if (x->props.family == AF_INET6 && mtu < IPV6_MIN_MTU)
10165 ++ return IPV6_MIN_MTU;
10166 ++
10167 ++ return mtu;
10168 ++}
10169 +
10170 + int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload)
10171 + {
10172 +diff --git a/samples/bpf/xdp_redirect_user.c b/samples/bpf/xdp_redirect_user.c
10173 +index 5440cd620607f..b7bc2a339d77c 100644
10174 +--- a/samples/bpf/xdp_redirect_user.c
10175 ++++ b/samples/bpf/xdp_redirect_user.c
10176 +@@ -216,5 +216,5 @@ int main(int argc, char **argv)
10177 + poll_stats(2, ifindex_out);
10178 +
10179 + out:
10180 +- return 0;
10181 ++ return ret;
10182 + }
10183 +diff --git a/scripts/Makefile.build b/scripts/Makefile.build
10184 +index 9c689d011bced..1261f75cb4e77 100644
10185 +--- a/scripts/Makefile.build
10186 ++++ b/scripts/Makefile.build
10187 +@@ -240,9 +240,9 @@ undefined_syms = $(NM) $< | $(AWK) '$$1 == "U" { printf("%s%s", x++ ? " " : "",
10188 + endif
10189 +
10190 + define rule_cc_o_c
10191 +- $(call cmd,checksrc)
10192 + $(call cmd_and_fixdep,cc_o_c)
10193 + $(call cmd,gen_ksymdeps)
10194 ++ $(call cmd,checksrc)
10195 + $(call cmd,checkdoc)
10196 + $(call cmd,objtool)
10197 + $(call cmd,modversions_c)
10198 +@@ -257,9 +257,10 @@ define rule_as_o_S
10199 + endef
10200 +
10201 + # Built-in and composite module parts
10202 +-$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE
10203 +- $(call cmd,force_checksrc)
10204 ++.SECONDEXPANSION:
10205 ++$(obj)/%.o: $(src)/%.c $(recordmcount_source) $$(objtool_dep) FORCE
10206 + $(call if_changed_rule,cc_o_c)
10207 ++ $(call cmd,force_checksrc)
10208 +
10209 + cmd_mod = { \
10210 + echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \
10211 +@@ -340,7 +341,7 @@ cmd_modversions_S = \
10212 + fi
10213 + endif
10214 +
10215 +-$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
10216 ++$(obj)/%.o: $(src)/%.S $$(objtool_dep) FORCE
10217 + $(call if_changed_rule,as_o_S)
10218 +
10219 + targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y)
10220 +diff --git a/scripts/tools-support-relr.sh b/scripts/tools-support-relr.sh
10221 +index 45e8aa360b457..cb55878bd5b81 100755
10222 +--- a/scripts/tools-support-relr.sh
10223 ++++ b/scripts/tools-support-relr.sh
10224 +@@ -7,7 +7,8 @@ trap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT
10225 + cat << "END" | $CC -c -x c - -o $tmp_file.o >/dev/null 2>&1
10226 + void *p = &p;
10227 + END
10228 +-$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr -o $tmp_file
10229 ++$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr \
10230 ++ --use-android-relr-tags -o $tmp_file
10231 +
10232 + # Despite printing an error message, GNU nm still exits with exit code 0 if it
10233 + # sees a relr section. So we need to check that nothing is printed to stderr.
10234 +diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
10235 +index 615094eda36d6..81e3245aec86c 100644
10236 +--- a/security/integrity/evm/evm_main.c
10237 ++++ b/security/integrity/evm/evm_main.c
10238 +@@ -520,7 +520,7 @@ void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)
10239 + }
10240 +
10241 + /*
10242 +- * evm_inode_init_security - initializes security.evm
10243 ++ * evm_inode_init_security - initializes security.evm HMAC value
10244 + */
10245 + int evm_inode_init_security(struct inode *inode,
10246 + const struct xattr *lsm_xattr,
10247 +@@ -529,7 +529,8 @@ int evm_inode_init_security(struct inode *inode,
10248 + struct evm_xattr *xattr_data;
10249 + int rc;
10250 +
10251 +- if (!evm_key_loaded() || !evm_protected_xattr(lsm_xattr->name))
10252 ++ if (!(evm_initialized & EVM_INIT_HMAC) ||
10253 ++ !evm_protected_xattr(lsm_xattr->name))
10254 + return 0;
10255 +
10256 + xattr_data = kzalloc(sizeof(*xattr_data), GFP_NOFS);
10257 +diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c
10258 +index 0f37ef27268de..d7f12ed191837 100644
10259 +--- a/security/integrity/evm/evm_secfs.c
10260 ++++ b/security/integrity/evm/evm_secfs.c
10261 +@@ -68,12 +68,13 @@ static ssize_t evm_read_key(struct file *filp, char __user *buf,
10262 + static ssize_t evm_write_key(struct file *file, const char __user *buf,
10263 + size_t count, loff_t *ppos)
10264 + {
10265 +- int i, ret;
10266 ++ unsigned int i;
10267 ++ int ret;
10268 +
10269 + if (!capable(CAP_SYS_ADMIN) || (evm_initialized & EVM_SETUP_COMPLETE))
10270 + return -EPERM;
10271 +
10272 +- ret = kstrtoint_from_user(buf, count, 0, &i);
10273 ++ ret = kstrtouint_from_user(buf, count, 0, &i);
10274 +
10275 + if (ret)
10276 + return ret;
10277 +@@ -82,12 +83,12 @@ static ssize_t evm_write_key(struct file *file, const char __user *buf,
10278 + if (!i || (i & ~EVM_INIT_MASK) != 0)
10279 + return -EINVAL;
10280 +
10281 +- /* Don't allow a request to freshly enable metadata writes if
10282 +- * keys are loaded.
10283 ++ /*
10284 ++ * Don't allow a request to enable metadata writes if
10285 ++ * an HMAC key is loaded.
10286 + */
10287 + if ((i & EVM_ALLOW_METADATA_WRITES) &&
10288 +- ((evm_initialized & EVM_KEY_MASK) != 0) &&
10289 +- !(evm_initialized & EVM_ALLOW_METADATA_WRITES))
10290 ++ (evm_initialized & EVM_INIT_HMAC) != 0)
10291 + return -EPERM;
10292 +
10293 + if (i & EVM_INIT_HMAC) {
10294 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
10295 +index de40bb99b6793..f5606036b6a29 100644
10296 +--- a/sound/pci/hda/patch_realtek.c
10297 ++++ b/sound/pci/hda/patch_realtek.c
10298 +@@ -375,6 +375,7 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
10299 + alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
10300 + /* fallthrough */
10301 + case 0x10ec0215:
10302 ++ case 0x10ec0230:
10303 + case 0x10ec0233:
10304 + case 0x10ec0235:
10305 + case 0x10ec0236:
10306 +@@ -3143,6 +3144,7 @@ static void alc_disable_headset_jack_key(struct hda_codec *codec)
10307 + alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
10308 + alc_update_coef_idx(codec, 0x44, 0x0045 << 8, 0x0);
10309 + break;
10310 ++ case 0x10ec0230:
10311 + case 0x10ec0236:
10312 + case 0x10ec0256:
10313 + alc_write_coef_idx(codec, 0x48, 0x0);
10314 +@@ -3170,6 +3172,7 @@ static void alc_enable_headset_jack_key(struct hda_codec *codec)
10315 + alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
10316 + alc_update_coef_idx(codec, 0x44, 0x007f << 8, 0x0045 << 8);
10317 + break;
10318 ++ case 0x10ec0230:
10319 + case 0x10ec0236:
10320 + case 0x10ec0256:
10321 + alc_write_coef_idx(codec, 0x48, 0xd011);
10322 +@@ -4630,6 +4633,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
10323 + case 0x10ec0255:
10324 + alc_process_coef_fw(codec, coef0255);
10325 + break;
10326 ++ case 0x10ec0230:
10327 + case 0x10ec0236:
10328 + case 0x10ec0256:
10329 + alc_process_coef_fw(codec, coef0256);
10330 +@@ -4744,6 +4748,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
10331 + alc_process_coef_fw(codec, coef0255);
10332 + snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
10333 + break;
10334 ++ case 0x10ec0230:
10335 + case 0x10ec0236:
10336 + case 0x10ec0256:
10337 + alc_write_coef_idx(codec, 0x45, 0xc489);
10338 +@@ -4893,6 +4898,7 @@ static void alc_headset_mode_default(struct hda_codec *codec)
10339 + case 0x10ec0255:
10340 + alc_process_coef_fw(codec, coef0255);
10341 + break;
10342 ++ case 0x10ec0230:
10343 + case 0x10ec0236:
10344 + case 0x10ec0256:
10345 + alc_write_coef_idx(codec, 0x1b, 0x0e4b);
10346 +@@ -4991,6 +4997,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
10347 + case 0x10ec0255:
10348 + alc_process_coef_fw(codec, coef0255);
10349 + break;
10350 ++ case 0x10ec0230:
10351 + case 0x10ec0236:
10352 + case 0x10ec0256:
10353 + alc_process_coef_fw(codec, coef0256);
10354 +@@ -5104,6 +5111,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
10355 + case 0x10ec0255:
10356 + alc_process_coef_fw(codec, coef0255);
10357 + break;
10358 ++ case 0x10ec0230:
10359 + case 0x10ec0236:
10360 + case 0x10ec0256:
10361 + alc_process_coef_fw(codec, coef0256);
10362 +@@ -5199,6 +5207,7 @@ static void alc_determine_headset_type(struct hda_codec *codec)
10363 + val = alc_read_coef_idx(codec, 0x46);
10364 + is_ctia = (val & 0x0070) == 0x0070;
10365 + break;
10366 ++ case 0x10ec0230:
10367 + case 0x10ec0236:
10368 + case 0x10ec0256:
10369 + alc_write_coef_idx(codec, 0x1b, 0x0e4b);
10370 +@@ -5492,6 +5501,7 @@ static void alc255_set_default_jack_type(struct hda_codec *codec)
10371 + case 0x10ec0255:
10372 + alc_process_coef_fw(codec, alc255fw);
10373 + break;
10374 ++ case 0x10ec0230:
10375 + case 0x10ec0236:
10376 + case 0x10ec0256:
10377 + alc_process_coef_fw(codec, alc256fw);
10378 +@@ -6092,6 +6102,7 @@ static void alc_combo_jack_hp_jd_restart(struct hda_codec *codec)
10379 + alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
10380 + alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
10381 + break;
10382 ++ case 0x10ec0230:
10383 + case 0x10ec0235:
10384 + case 0x10ec0236:
10385 + case 0x10ec0255:
10386 +@@ -6207,6 +6218,24 @@ static void alc274_fixup_hp_headset_mic(struct hda_codec *codec,
10387 + }
10388 + }
10389 +
10390 ++static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec,
10391 ++ const struct hda_fixup *fix, int action)
10392 ++{
10393 ++ static const hda_nid_t conn[] = { 0x02 };
10394 ++ static const struct hda_pintbl pincfgs[] = {
10395 ++ { 0x14, 0x90170110 }, /* rear speaker */
10396 ++ { }
10397 ++ };
10398 ++
10399 ++ switch (action) {
10400 ++ case HDA_FIXUP_ACT_PRE_PROBE:
10401 ++ snd_hda_apply_pincfgs(codec, pincfgs);
10402 ++ /* force front speaker to DAC1 */
10403 ++ snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
10404 ++ break;
10405 ++ }
10406 ++}
10407 ++
10408 + /* for hda_fixup_thinkpad_acpi() */
10409 + #include "thinkpad_helper.c"
10410 +
10411 +@@ -7652,6 +7681,8 @@ static const struct hda_fixup alc269_fixups[] = {
10412 + { 0x20, AC_VERB_SET_PROC_COEF, 0x4e4b },
10413 + { }
10414 + },
10415 ++ .chained = true,
10416 ++ .chain_id = ALC289_FIXUP_ASUS_GA401,
10417 + },
10418 + [ALC285_FIXUP_HP_GPIO_LED] = {
10419 + .type = HDA_FIXUP_FUNC,
10420 +@@ -7905,13 +7936,8 @@ static const struct hda_fixup alc269_fixups[] = {
10421 + .chain_id = ALC269_FIXUP_HP_LINE1_MIC1_LED,
10422 + },
10423 + [ALC285_FIXUP_HP_SPECTRE_X360] = {
10424 +- .type = HDA_FIXUP_PINS,
10425 +- .v.pins = (const struct hda_pintbl[]) {
10426 +- { 0x14, 0x90170110 }, /* enable top speaker */
10427 +- {}
10428 +- },
10429 +- .chained = true,
10430 +- .chain_id = ALC285_FIXUP_SPEAKER2_TO_DAC1,
10431 ++ .type = HDA_FIXUP_FUNC,
10432 ++ .v.func = alc285_fixup_hp_spectre_x360,
10433 + },
10434 + };
10435 +
10436 +@@ -8067,6 +8093,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
10437 + SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN),
10438 + SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
10439 + SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360),
10440 ++ SND_PCI_QUIRK(0x103c, 0x861f, "HP Elite Dragonfly G1", ALC285_FIXUP_HP_GPIO_AMP_INIT),
10441 + SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
10442 + SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED),
10443 + SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED),
10444 +@@ -9063,6 +9090,7 @@ static int patch_alc269(struct hda_codec *codec)
10445 + spec->shutup = alc256_shutup;
10446 + spec->init_hook = alc256_init;
10447 + break;
10448 ++ case 0x10ec0230:
10449 + case 0x10ec0236:
10450 + case 0x10ec0256:
10451 + spec->codec_variant = ALC269_TYPE_ALC256;
10452 +@@ -10354,6 +10382,7 @@ static const struct hda_device_id snd_hda_id_realtek[] = {
10453 + HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
10454 + HDA_CODEC_ENTRY(0x10ec0222, "ALC222", patch_alc269),
10455 + HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
10456 ++ HDA_CODEC_ENTRY(0x10ec0230, "ALC236", patch_alc269),
10457 + HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
10458 + HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
10459 + HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
10460 +diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
10461 +index 2a73fc4fd019f..5150e8d38975e 100644
10462 +--- a/sound/pci/intel8x0.c
10463 ++++ b/sound/pci/intel8x0.c
10464 +@@ -715,7 +715,7 @@ static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ich
10465 + int status, civ, i, step;
10466 + int ack = 0;
10467 +
10468 +- if (!ichdev->prepared || ichdev->suspended)
10469 ++ if (!(ichdev->prepared || chip->in_measurement) || ichdev->suspended)
10470 + return;
10471 +
10472 + spin_lock_irqsave(&chip->reg_lock, flags);
10473 +diff --git a/sound/soc/atmel/atmel-i2s.c b/sound/soc/atmel/atmel-i2s.c
10474 +index bbe2b638abb58..d870f56c44cfc 100644
10475 +--- a/sound/soc/atmel/atmel-i2s.c
10476 ++++ b/sound/soc/atmel/atmel-i2s.c
10477 +@@ -200,6 +200,7 @@ struct atmel_i2s_dev {
10478 + unsigned int fmt;
10479 + const struct atmel_i2s_gck_param *gck_param;
10480 + const struct atmel_i2s_caps *caps;
10481 ++ int clk_use_no;
10482 + };
10483 +
10484 + static irqreturn_t atmel_i2s_interrupt(int irq, void *dev_id)
10485 +@@ -321,9 +322,16 @@ static int atmel_i2s_hw_params(struct snd_pcm_substream *substream,
10486 + {
10487 + struct atmel_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
10488 + bool is_playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
10489 +- unsigned int mr = 0;
10490 ++ unsigned int mr = 0, mr_mask;
10491 + int ret;
10492 +
10493 ++ mr_mask = ATMEL_I2SC_MR_FORMAT_MASK | ATMEL_I2SC_MR_MODE_MASK |
10494 ++ ATMEL_I2SC_MR_DATALENGTH_MASK;
10495 ++ if (is_playback)
10496 ++ mr_mask |= ATMEL_I2SC_MR_TXMONO;
10497 ++ else
10498 ++ mr_mask |= ATMEL_I2SC_MR_RXMONO;
10499 ++
10500 + switch (dev->fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
10501 + case SND_SOC_DAIFMT_I2S:
10502 + mr |= ATMEL_I2SC_MR_FORMAT_I2S;
10503 +@@ -402,7 +410,7 @@ static int atmel_i2s_hw_params(struct snd_pcm_substream *substream,
10504 + return -EINVAL;
10505 + }
10506 +
10507 +- return regmap_write(dev->regmap, ATMEL_I2SC_MR, mr);
10508 ++ return regmap_update_bits(dev->regmap, ATMEL_I2SC_MR, mr_mask, mr);
10509 + }
10510 +
10511 + static int atmel_i2s_switch_mck_generator(struct atmel_i2s_dev *dev,
10512 +@@ -495,18 +503,28 @@ static int atmel_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
10513 + is_master = (mr & ATMEL_I2SC_MR_MODE_MASK) == ATMEL_I2SC_MR_MODE_MASTER;
10514 +
10515 + /* If master starts, enable the audio clock. */
10516 +- if (is_master && mck_enabled)
10517 +- err = atmel_i2s_switch_mck_generator(dev, true);
10518 +- if (err)
10519 +- return err;
10520 ++ if (is_master && mck_enabled) {
10521 ++ if (!dev->clk_use_no) {
10522 ++ err = atmel_i2s_switch_mck_generator(dev, true);
10523 ++ if (err)
10524 ++ return err;
10525 ++ }
10526 ++ dev->clk_use_no++;
10527 ++ }
10528 +
10529 + err = regmap_write(dev->regmap, ATMEL_I2SC_CR, cr);
10530 + if (err)
10531 + return err;
10532 +
10533 + /* If master stops, disable the audio clock. */
10534 +- if (is_master && !mck_enabled)
10535 +- err = atmel_i2s_switch_mck_generator(dev, false);
10536 ++ if (is_master && !mck_enabled) {
10537 ++ if (dev->clk_use_no == 1) {
10538 ++ err = atmel_i2s_switch_mck_generator(dev, false);
10539 ++ if (err)
10540 ++ return err;
10541 ++ }
10542 ++ dev->clk_use_no--;
10543 ++ }
10544 +
10545 + return err;
10546 + }
10547 +diff --git a/sound/soc/codecs/cs42l42.h b/sound/soc/codecs/cs42l42.h
10548 +index 866d7c873e3c9..ca2019732013e 100644
10549 +--- a/sound/soc/codecs/cs42l42.h
10550 ++++ b/sound/soc/codecs/cs42l42.h
10551 +@@ -77,7 +77,7 @@
10552 + #define CS42L42_HP_PDN_SHIFT 3
10553 + #define CS42L42_HP_PDN_MASK (1 << CS42L42_HP_PDN_SHIFT)
10554 + #define CS42L42_ADC_PDN_SHIFT 2
10555 +-#define CS42L42_ADC_PDN_MASK (1 << CS42L42_HP_PDN_SHIFT)
10556 ++#define CS42L42_ADC_PDN_MASK (1 << CS42L42_ADC_PDN_SHIFT)
10557 + #define CS42L42_PDN_ALL_SHIFT 0
10558 + #define CS42L42_PDN_ALL_MASK (1 << CS42L42_PDN_ALL_SHIFT)
10559 +
10560 +diff --git a/sound/soc/codecs/rk3328_codec.c b/sound/soc/codecs/rk3328_codec.c
10561 +index 287c962ba00d7..514ebe16bbfad 100644
10562 +--- a/sound/soc/codecs/rk3328_codec.c
10563 ++++ b/sound/soc/codecs/rk3328_codec.c
10564 +@@ -472,7 +472,8 @@ static int rk3328_platform_probe(struct platform_device *pdev)
10565 + rk3328->pclk = devm_clk_get(&pdev->dev, "pclk");
10566 + if (IS_ERR(rk3328->pclk)) {
10567 + dev_err(&pdev->dev, "can't get acodec pclk\n");
10568 +- return PTR_ERR(rk3328->pclk);
10569 ++ ret = PTR_ERR(rk3328->pclk);
10570 ++ goto err_unprepare_mclk;
10571 + }
10572 +
10573 + ret = clk_prepare_enable(rk3328->pclk);
10574 +@@ -482,19 +483,34 @@ static int rk3328_platform_probe(struct platform_device *pdev)
10575 + }
10576 +
10577 + base = devm_platform_ioremap_resource(pdev, 0);
10578 +- if (IS_ERR(base))
10579 +- return PTR_ERR(base);
10580 ++ if (IS_ERR(base)) {
10581 ++ ret = PTR_ERR(base);
10582 ++ goto err_unprepare_pclk;
10583 ++ }
10584 +
10585 + rk3328->regmap = devm_regmap_init_mmio(&pdev->dev, base,
10586 + &rk3328_codec_regmap_config);
10587 +- if (IS_ERR(rk3328->regmap))
10588 +- return PTR_ERR(rk3328->regmap);
10589 ++ if (IS_ERR(rk3328->regmap)) {
10590 ++ ret = PTR_ERR(rk3328->regmap);
10591 ++ goto err_unprepare_pclk;
10592 ++ }
10593 +
10594 + platform_set_drvdata(pdev, rk3328);
10595 +
10596 +- return devm_snd_soc_register_component(&pdev->dev, &soc_codec_rk3328,
10597 ++ ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_rk3328,
10598 + rk3328_dai,
10599 + ARRAY_SIZE(rk3328_dai));
10600 ++ if (ret)
10601 ++ goto err_unprepare_pclk;
10602 ++
10603 ++ return 0;
10604 ++
10605 ++err_unprepare_pclk:
10606 ++ clk_disable_unprepare(rk3328->pclk);
10607 ++
10608 ++err_unprepare_mclk:
10609 ++ clk_disable_unprepare(rk3328->mclk);
10610 ++ return ret;
10611 + }
10612 +
10613 + static const struct of_device_id rk3328_codec_of_match[] = {
10614 +diff --git a/sound/soc/hisilicon/hi6210-i2s.c b/sound/soc/hisilicon/hi6210-i2s.c
10615 +index ab3b76d298b34..03470e8f30083 100644
10616 +--- a/sound/soc/hisilicon/hi6210-i2s.c
10617 ++++ b/sound/soc/hisilicon/hi6210-i2s.c
10618 +@@ -102,18 +102,15 @@ static int hi6210_i2s_startup(struct snd_pcm_substream *substream,
10619 +
10620 + for (n = 0; n < i2s->clocks; n++) {
10621 + ret = clk_prepare_enable(i2s->clk[n]);
10622 +- if (ret) {
10623 +- while (n--)
10624 +- clk_disable_unprepare(i2s->clk[n]);
10625 +- return ret;
10626 +- }
10627 ++ if (ret)
10628 ++ goto err_unprepare_clk;
10629 + }
10630 +
10631 + ret = clk_set_rate(i2s->clk[CLK_I2S_BASE], 49152000);
10632 + if (ret) {
10633 + dev_err(i2s->dev, "%s: setting 49.152MHz base rate failed %d\n",
10634 + __func__, ret);
10635 +- return ret;
10636 ++ goto err_unprepare_clk;
10637 + }
10638 +
10639 + /* enable clock before frequency division */
10640 +@@ -165,6 +162,11 @@ static int hi6210_i2s_startup(struct snd_pcm_substream *substream,
10641 + hi6210_write_reg(i2s, HII2S_SW_RST_N, val);
10642 +
10643 + return 0;
10644 ++
10645 ++err_unprepare_clk:
10646 ++ while (n--)
10647 ++ clk_disable_unprepare(i2s->clk[n]);
10648 ++ return ret;
10649 + }
10650 +
10651 + static void hi6210_i2s_shutdown(struct snd_pcm_substream *substream,
10652 +diff --git a/sound/soc/mediatek/common/mtk-btcvsd.c b/sound/soc/mediatek/common/mtk-btcvsd.c
10653 +index d00608c73c6ec..b66f7dee1e149 100644
10654 +--- a/sound/soc/mediatek/common/mtk-btcvsd.c
10655 ++++ b/sound/soc/mediatek/common/mtk-btcvsd.c
10656 +@@ -1302,7 +1302,7 @@ static const struct snd_soc_component_driver mtk_btcvsd_snd_platform = {
10657 +
10658 + static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
10659 + {
10660 +- int ret = 0;
10661 ++ int ret;
10662 + int irq_id;
10663 + u32 offset[5] = {0, 0, 0, 0, 0};
10664 + struct mtk_btcvsd_snd *btcvsd;
10665 +@@ -1358,7 +1358,8 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
10666 + btcvsd->bt_sram_bank2_base = of_iomap(dev->of_node, 1);
10667 + if (!btcvsd->bt_sram_bank2_base) {
10668 + dev_err(dev, "iomap bt_sram_bank2_base fail\n");
10669 +- return -EIO;
10670 ++ ret = -EIO;
10671 ++ goto unmap_pkv_err;
10672 + }
10673 +
10674 + btcvsd->infra = syscon_regmap_lookup_by_phandle(dev->of_node,
10675 +@@ -1366,7 +1367,8 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
10676 + if (IS_ERR(btcvsd->infra)) {
10677 + dev_err(dev, "cannot find infra controller: %ld\n",
10678 + PTR_ERR(btcvsd->infra));
10679 +- return PTR_ERR(btcvsd->infra);
10680 ++ ret = PTR_ERR(btcvsd->infra);
10681 ++ goto unmap_bank2_err;
10682 + }
10683 +
10684 + /* get offset */
10685 +@@ -1375,7 +1377,7 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
10686 + ARRAY_SIZE(offset));
10687 + if (ret) {
10688 + dev_warn(dev, "%s(), get offset fail, ret %d\n", __func__, ret);
10689 +- return ret;
10690 ++ goto unmap_bank2_err;
10691 + }
10692 + btcvsd->infra_misc_offset = offset[0];
10693 + btcvsd->conn_bt_cvsd_mask = offset[1];
10694 +@@ -1394,8 +1396,18 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev)
10695 + mtk_btcvsd_snd_set_state(btcvsd, btcvsd->tx, BT_SCO_STATE_IDLE);
10696 + mtk_btcvsd_snd_set_state(btcvsd, btcvsd->rx, BT_SCO_STATE_IDLE);
10697 +
10698 +- return devm_snd_soc_register_component(dev, &mtk_btcvsd_snd_platform,
10699 +- NULL, 0);
10700 ++ ret = devm_snd_soc_register_component(dev, &mtk_btcvsd_snd_platform,
10701 ++ NULL, 0);
10702 ++ if (ret)
10703 ++ goto unmap_bank2_err;
10704 ++
10705 ++ return 0;
10706 ++
10707 ++unmap_bank2_err:
10708 ++ iounmap(btcvsd->bt_sram_bank2_base);
10709 ++unmap_pkv_err:
10710 ++ iounmap(btcvsd->bt_pkv_base);
10711 ++ return ret;
10712 + }
10713 +
10714 + static int mtk_btcvsd_snd_remove(struct platform_device *pdev)
10715 +diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c
10716 +index b9aacf3d3b29c..7532ab27a48df 100644
10717 +--- a/sound/soc/sh/rcar/adg.c
10718 ++++ b/sound/soc/sh/rcar/adg.c
10719 +@@ -289,7 +289,6 @@ static void rsnd_adg_set_ssi_clk(struct rsnd_mod *ssi_mod, u32 val)
10720 + int rsnd_adg_clk_query(struct rsnd_priv *priv, unsigned int rate)
10721 + {
10722 + struct rsnd_adg *adg = rsnd_priv_to_adg(priv);
10723 +- struct clk *clk;
10724 + int i;
10725 + int sel_table[] = {
10726 + [CLKA] = 0x1,
10727 +@@ -302,10 +301,9 @@ int rsnd_adg_clk_query(struct rsnd_priv *priv, unsigned int rate)
10728 + * find suitable clock from
10729 + * AUDIO_CLKA/AUDIO_CLKB/AUDIO_CLKC/AUDIO_CLKI.
10730 + */
10731 +- for_each_rsnd_clk(clk, adg, i) {
10732 ++ for (i = 0; i < CLKMAX; i++)
10733 + if (rate == adg->clk_rate[i])
10734 + return sel_table[i];
10735 +- }
10736 +
10737 + /*
10738 + * find divided clock from BRGA/BRGB
10739 +diff --git a/sound/usb/format.c b/sound/usb/format.c
10740 +index 9e9d4c10dfac6..84b66f7c627c4 100644
10741 +--- a/sound/usb/format.c
10742 ++++ b/sound/usb/format.c
10743 +@@ -195,9 +195,11 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
10744 + continue;
10745 + /* C-Media CM6501 mislabels its 96 kHz altsetting */
10746 + /* Terratec Aureon 7.1 USB C-Media 6206, too */
10747 ++ /* Ozone Z90 USB C-Media, too */
10748 + if (rate == 48000 && nr_rates == 1 &&
10749 + (chip->usb_id == USB_ID(0x0d8c, 0x0201) ||
10750 + chip->usb_id == USB_ID(0x0d8c, 0x0102) ||
10751 ++ chip->usb_id == USB_ID(0x0d8c, 0x0078) ||
10752 + chip->usb_id == USB_ID(0x0ccd, 0x00b1)) &&
10753 + fp->altsetting == 5 && fp->maxpacksize == 392)
10754 + rate = 96000;
10755 +diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
10756 +index f4f8778e907a9..22841ed2411e2 100644
10757 +--- a/sound/usb/mixer.c
10758 ++++ b/sound/usb/mixer.c
10759 +@@ -3241,8 +3241,9 @@ static void snd_usb_mixer_dump_cval(struct snd_info_buffer *buffer,
10760 + struct usb_mixer_elem_list *list)
10761 + {
10762 + struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list);
10763 +- static const char * const val_types[] = {"BOOLEAN", "INV_BOOLEAN",
10764 +- "S8", "U8", "S16", "U16"};
10765 ++ static const char * const val_types[] = {
10766 ++ "BOOLEAN", "INV_BOOLEAN", "S8", "U8", "S16", "U16", "S32", "U32",
10767 ++ };
10768 + snd_iprintf(buffer, " Info: id=%i, control=%i, cmask=0x%x, "
10769 + "channels=%i, type=\"%s\"\n", cval->head.id,
10770 + cval->control, cval->cmask, cval->channels,
10771 +@@ -3598,6 +3599,9 @@ static int restore_mixer_value(struct usb_mixer_elem_list *list)
10772 + struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list);
10773 + int c, err, idx;
10774 +
10775 ++ if (cval->val_type == USB_MIXER_BESPOKEN)
10776 ++ return 0;
10777 ++
10778 + if (cval->cmask) {
10779 + idx = 0;
10780 + for (c = 0; c < MAX_CHANNELS; c++) {
10781 +diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
10782 +index 01b5e5cc22210..0e813cd85bee7 100644
10783 +--- a/sound/usb/mixer.h
10784 ++++ b/sound/usb/mixer.h
10785 +@@ -55,6 +55,7 @@ enum {
10786 + USB_MIXER_U16,
10787 + USB_MIXER_S32,
10788 + USB_MIXER_U32,
10789 ++ USB_MIXER_BESPOKEN, /* non-standard type */
10790 + };
10791 +
10792 + typedef void (*usb_mixer_elem_dump_func_t)(struct snd_info_buffer *buffer,
10793 +diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c
10794 +index 7a10c9e22c46c..54bcf1c14bc24 100644
10795 +--- a/sound/usb/mixer_scarlett_gen2.c
10796 ++++ b/sound/usb/mixer_scarlett_gen2.c
10797 +@@ -949,10 +949,15 @@ static int scarlett2_add_new_ctl(struct usb_mixer_interface *mixer,
10798 + if (!elem)
10799 + return -ENOMEM;
10800 +
10801 ++ /* We set USB_MIXER_BESPOKEN type, so that the core USB mixer code
10802 ++ * ignores them for resume and other operations.
10803 ++ * Also, the head.id field is set to 0, as we don't use this field.
10804 ++ */
10805 + elem->head.mixer = mixer;
10806 + elem->control = index;
10807 +- elem->head.id = index;
10808 ++ elem->head.id = 0;
10809 + elem->channels = channels;
10810 ++ elem->val_type = USB_MIXER_BESPOKEN;
10811 +
10812 + kctl = snd_ctl_new1(ncontrol, elem);
10813 + if (!kctl) {
10814 +diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
10815 +index 93d008687020c..7d3cfb0ccbe61 100644
10816 +--- a/tools/bpf/bpftool/main.c
10817 ++++ b/tools/bpf/bpftool/main.c
10818 +@@ -303,8 +303,10 @@ static int do_batch(int argc, char **argv)
10819 + n_argc = make_args(buf, n_argv, BATCH_ARG_NB_MAX, lines);
10820 + if (!n_argc)
10821 + continue;
10822 +- if (n_argc < 0)
10823 ++ if (n_argc < 0) {
10824 ++ err = n_argc;
10825 + goto err_close;
10826 ++ }
10827 +
10828 + if (json_output) {
10829 + jsonw_start_object(json_wtr);
10830 +diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
10831 +index 8b14e4a7f1dc7..e7c7e3232fc5a 100644
10832 +--- a/tools/perf/util/llvm-utils.c
10833 ++++ b/tools/perf/util/llvm-utils.c
10834 +@@ -502,6 +502,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
10835 + goto errout;
10836 + }
10837 +
10838 ++ err = -ENOMEM;
10839 + if (asprintf(&pipe_template, "%s -emit-llvm | %s -march=bpf %s -filetype=obj -o -",
10840 + template, llc_path, opts) < 0) {
10841 + pr_err("ERROR:\tnot enough memory to setup command line\n");
10842 +@@ -522,6 +523,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
10843 +
10844 + pr_debug("llvm compiling command template: %s\n", template);
10845 +
10846 ++ err = -ENOMEM;
10847 + if (asprintf(&command_echo, "echo -n \"%s\"", template) < 0)
10848 + goto errout;
10849 +
10850 +diff --git a/tools/testing/selftests/tc-testing/plugin-lib/scapyPlugin.py b/tools/testing/selftests/tc-testing/plugin-lib/scapyPlugin.py
10851 +index 229ee185b27e1..a7b21658af9b4 100644
10852 +--- a/tools/testing/selftests/tc-testing/plugin-lib/scapyPlugin.py
10853 ++++ b/tools/testing/selftests/tc-testing/plugin-lib/scapyPlugin.py
10854 +@@ -36,7 +36,7 @@ class SubPlugin(TdcPlugin):
10855 + for k in scapy_keys:
10856 + if k not in scapyinfo:
10857 + keyfail = True
10858 +- missing_keys.add(k)
10859 ++ missing_keys.append(k)
10860 + if keyfail:
10861 + print('{}: Scapy block present in the test, but is missing info:'
10862 + .format(self.sub_class))
10863 +diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c
10864 +index 47191af466174..a3602148e2ea9 100644
10865 +--- a/tools/testing/selftests/x86/protection_keys.c
10866 ++++ b/tools/testing/selftests/x86/protection_keys.c
10867 +@@ -613,7 +613,6 @@ int alloc_random_pkey(void)
10868 + int nr_alloced = 0;
10869 + int random_index;
10870 + memset(alloced_pkeys, 0, sizeof(alloced_pkeys));
10871 +- srand((unsigned int)time(NULL));
10872 +
10873 + /* allocate every possible key and make a note of which ones we got */
10874 + max_nr_pkey_allocs = NR_PKEYS;
10875 +@@ -1479,6 +1478,8 @@ int main(void)
10876 + {
10877 + int nr_iterations = 22;
10878 +
10879 ++ srand((unsigned int)time(NULL));
10880 ++
10881 + setup_handlers();
10882 +
10883 + printf("has pku: %d\n", cpu_has_pku());