Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0198-5.4.99-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3635 - (show annotations) (download)
Mon Oct 24 12:34:12 2022 UTC (19 months ago) by niro
File size: 83279 byte(s)
-sync kernel patches
1 diff --git a/Makefile b/Makefile
2 index 4f6bfcf434e80..a0491ba1d7593 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,7 +1,7 @@
6 # SPDX-License-Identifier: GPL-2.0
7 VERSION = 5
8 PATCHLEVEL = 4
9 -SUBLEVEL = 98
10 +SUBLEVEL = 99
11 EXTRAVERSION =
12 NAME = Kleptomaniac Octopus
13
14 diff --git a/arch/arm/boot/dts/lpc32xx.dtsi b/arch/arm/boot/dts/lpc32xx.dtsi
15 index 7b7ec7b1217b8..824393e1bcfb7 100644
16 --- a/arch/arm/boot/dts/lpc32xx.dtsi
17 +++ b/arch/arm/boot/dts/lpc32xx.dtsi
18 @@ -329,9 +329,6 @@
19
20 clocks = <&xtal_32k>, <&xtal>;
21 clock-names = "xtal_32k", "xtal";
22 -
23 - assigned-clocks = <&clk LPC32XX_CLK_HCLK_PLL>;
24 - assigned-clock-rates = <208000000>;
25 };
26 };
27
28 diff --git a/arch/arm/include/asm/kexec-internal.h b/arch/arm/include/asm/kexec-internal.h
29 new file mode 100644
30 index 0000000000000..ecc2322db7aa1
31 --- /dev/null
32 +++ b/arch/arm/include/asm/kexec-internal.h
33 @@ -0,0 +1,12 @@
34 +/* SPDX-License-Identifier: GPL-2.0 */
35 +#ifndef _ARM_KEXEC_INTERNAL_H
36 +#define _ARM_KEXEC_INTERNAL_H
37 +
38 +struct kexec_relocate_data {
39 + unsigned long kexec_start_address;
40 + unsigned long kexec_indirection_page;
41 + unsigned long kexec_mach_type;
42 + unsigned long kexec_r2;
43 +};
44 +
45 +#endif
46 diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
47 index c773b829ee8ee..bfb05c93494db 100644
48 --- a/arch/arm/kernel/asm-offsets.c
49 +++ b/arch/arm/kernel/asm-offsets.c
50 @@ -15,6 +15,7 @@
51 #include <linux/kvm_host.h>
52 #endif
53 #include <asm/cacheflush.h>
54 +#include <asm/kexec-internal.h>
55 #include <asm/glue-df.h>
56 #include <asm/glue-pf.h>
57 #include <asm/mach/arch.h>
58 @@ -190,5 +191,9 @@ int main(void)
59 DEFINE(MPU_RGN_PRBAR, offsetof(struct mpu_rgn, prbar));
60 DEFINE(MPU_RGN_PRLAR, offsetof(struct mpu_rgn, prlar));
61 #endif
62 + DEFINE(KEXEC_START_ADDR, offsetof(struct kexec_relocate_data, kexec_start_address));
63 + DEFINE(KEXEC_INDIR_PAGE, offsetof(struct kexec_relocate_data, kexec_indirection_page));
64 + DEFINE(KEXEC_MACH_TYPE, offsetof(struct kexec_relocate_data, kexec_mach_type));
65 + DEFINE(KEXEC_R2, offsetof(struct kexec_relocate_data, kexec_r2));
66 return 0;
67 }
68 diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
69 index 76300f3813e89..734adeb42df87 100644
70 --- a/arch/arm/kernel/machine_kexec.c
71 +++ b/arch/arm/kernel/machine_kexec.c
72 @@ -15,6 +15,7 @@
73 #include <asm/pgalloc.h>
74 #include <asm/mmu_context.h>
75 #include <asm/cacheflush.h>
76 +#include <asm/kexec-internal.h>
77 #include <asm/fncpy.h>
78 #include <asm/mach-types.h>
79 #include <asm/smp_plat.h>
80 @@ -24,11 +25,6 @@
81 extern void relocate_new_kernel(void);
82 extern const unsigned int relocate_new_kernel_size;
83
84 -extern unsigned long kexec_start_address;
85 -extern unsigned long kexec_indirection_page;
86 -extern unsigned long kexec_mach_type;
87 -extern unsigned long kexec_boot_atags;
88 -
89 static atomic_t waiting_for_crash_ipi;
90
91 /*
92 @@ -161,6 +157,7 @@ void (*kexec_reinit)(void);
93 void machine_kexec(struct kimage *image)
94 {
95 unsigned long page_list, reboot_entry_phys;
96 + struct kexec_relocate_data *data;
97 void (*reboot_entry)(void);
98 void *reboot_code_buffer;
99
100 @@ -176,18 +173,17 @@ void machine_kexec(struct kimage *image)
101
102 reboot_code_buffer = page_address(image->control_code_page);
103
104 - /* Prepare parameters for reboot_code_buffer*/
105 - set_kernel_text_rw();
106 - kexec_start_address = image->start;
107 - kexec_indirection_page = page_list;
108 - kexec_mach_type = machine_arch_type;
109 - kexec_boot_atags = image->arch.kernel_r2;
110 -
111 /* copy our kernel relocation code to the control code page */
112 reboot_entry = fncpy(reboot_code_buffer,
113 &relocate_new_kernel,
114 relocate_new_kernel_size);
115
116 + data = reboot_code_buffer + relocate_new_kernel_size;
117 + data->kexec_start_address = image->start;
118 + data->kexec_indirection_page = page_list;
119 + data->kexec_mach_type = machine_arch_type;
120 + data->kexec_r2 = image->arch.kernel_r2;
121 +
122 /* get the identity mapping physical address for the reboot code */
123 reboot_entry_phys = virt_to_idmap(reboot_entry);
124
125 diff --git a/arch/arm/kernel/relocate_kernel.S b/arch/arm/kernel/relocate_kernel.S
126 index 7eaa2ae7aff58..5e15b5912cb05 100644
127 --- a/arch/arm/kernel/relocate_kernel.S
128 +++ b/arch/arm/kernel/relocate_kernel.S
129 @@ -5,14 +5,16 @@
130
131 #include <linux/linkage.h>
132 #include <asm/assembler.h>
133 +#include <asm/asm-offsets.h>
134 #include <asm/kexec.h>
135
136 .align 3 /* not needed for this code, but keeps fncpy() happy */
137
138 ENTRY(relocate_new_kernel)
139
140 - ldr r0,kexec_indirection_page
141 - ldr r1,kexec_start_address
142 + adr r7, relocate_new_kernel_end
143 + ldr r0, [r7, #KEXEC_INDIR_PAGE]
144 + ldr r1, [r7, #KEXEC_START_ADDR]
145
146 /*
147 * If there is no indirection page (we are doing crashdumps)
148 @@ -57,34 +59,16 @@ ENTRY(relocate_new_kernel)
149
150 2:
151 /* Jump to relocated kernel */
152 - mov lr,r1
153 - mov r0,#0
154 - ldr r1,kexec_mach_type
155 - ldr r2,kexec_boot_atags
156 - ARM( ret lr )
157 - THUMB( bx lr )
158 -
159 - .align
160 -
161 - .globl kexec_start_address
162 -kexec_start_address:
163 - .long 0x0
164 -
165 - .globl kexec_indirection_page
166 -kexec_indirection_page:
167 - .long 0x0
168 -
169 - .globl kexec_mach_type
170 -kexec_mach_type:
171 - .long 0x0
172 -
173 - /* phy addr of the atags for the new kernel */
174 - .globl kexec_boot_atags
175 -kexec_boot_atags:
176 - .long 0x0
177 + mov lr, r1
178 + mov r0, #0
179 + ldr r1, [r7, #KEXEC_MACH_TYPE]
180 + ldr r2, [r7, #KEXEC_R2]
181 + ARM( ret lr )
182 + THUMB( bx lr )
183
184 ENDPROC(relocate_new_kernel)
185
186 + .align 3
187 relocate_new_kernel_end:
188
189 .globl relocate_new_kernel_size
190 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
191 index ab2568996ddb0..c01f76cd02422 100644
192 --- a/arch/arm/kernel/signal.c
193 +++ b/arch/arm/kernel/signal.c
194 @@ -694,18 +694,20 @@ struct page *get_signal_page(void)
195
196 addr = page_address(page);
197
198 + /* Poison the entire page */
199 + memset32(addr, __opcode_to_mem_arm(0xe7fddef1),
200 + PAGE_SIZE / sizeof(u32));
201 +
202 /* Give the signal return code some randomness */
203 offset = 0x200 + (get_random_int() & 0x7fc);
204 signal_return_offset = offset;
205
206 - /*
207 - * Copy signal return handlers into the vector page, and
208 - * set sigreturn to be a pointer to these.
209 - */
210 + /* Copy signal return handlers into the page */
211 memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
212
213 - ptr = (unsigned long)addr + offset;
214 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
215 + /* Flush out all instructions in this page */
216 + ptr = (unsigned long)addr;
217 + flush_icache_range(ptr, ptr + PAGE_SIZE);
218
219 return page;
220 }
221 diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c
222 index c8d317fafe2ea..de37027ad7587 100644
223 --- a/arch/arm/mach-omap2/cpuidle44xx.c
224 +++ b/arch/arm/mach-omap2/cpuidle44xx.c
225 @@ -151,10 +151,10 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
226 (cx->mpu_logic_state == PWRDM_POWER_OFF);
227
228 /* Enter broadcast mode for periodic timers */
229 - tick_broadcast_enable();
230 + RCU_NONIDLE(tick_broadcast_enable());
231
232 /* Enter broadcast mode for one-shot timers */
233 - tick_broadcast_enter();
234 + RCU_NONIDLE(tick_broadcast_enter());
235
236 /*
237 * Call idle CPU PM enter notifier chain so that
238 @@ -166,7 +166,7 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
239
240 if (dev->cpu == 0) {
241 pwrdm_set_logic_retst(mpu_pd, cx->mpu_logic_state);
242 - omap_set_pwrdm_state(mpu_pd, cx->mpu_state);
243 + RCU_NONIDLE(omap_set_pwrdm_state(mpu_pd, cx->mpu_state));
244
245 /*
246 * Call idle CPU cluster PM enter notifier chain
247 @@ -178,7 +178,7 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
248 index = 0;
249 cx = state_ptr + index;
250 pwrdm_set_logic_retst(mpu_pd, cx->mpu_logic_state);
251 - omap_set_pwrdm_state(mpu_pd, cx->mpu_state);
252 + RCU_NONIDLE(omap_set_pwrdm_state(mpu_pd, cx->mpu_state));
253 mpuss_can_lose_context = 0;
254 }
255 }
256 @@ -194,9 +194,9 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
257 mpuss_can_lose_context)
258 gic_dist_disable();
259
260 - clkdm_deny_idle(cpu_clkdm[1]);
261 - omap_set_pwrdm_state(cpu_pd[1], PWRDM_POWER_ON);
262 - clkdm_allow_idle(cpu_clkdm[1]);
263 + RCU_NONIDLE(clkdm_deny_idle(cpu_clkdm[1]));
264 + RCU_NONIDLE(omap_set_pwrdm_state(cpu_pd[1], PWRDM_POWER_ON));
265 + RCU_NONIDLE(clkdm_allow_idle(cpu_clkdm[1]));
266
267 if (IS_PM44XX_ERRATUM(PM_OMAP4_ROM_SMP_BOOT_ERRATUM_GICD) &&
268 mpuss_can_lose_context) {
269 @@ -222,7 +222,7 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
270 cpu_pm_exit();
271
272 cpu_pm_out:
273 - tick_broadcast_exit();
274 + RCU_NONIDLE(tick_broadcast_exit());
275
276 fail:
277 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
278 diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
279 index f45bff158fc20..57dfc13b27529 100644
280 --- a/arch/arm/xen/enlighten.c
281 +++ b/arch/arm/xen/enlighten.c
282 @@ -370,8 +370,6 @@ static int __init xen_guest_init(void)
283 return -ENOMEM;
284 }
285 gnttab_init();
286 - if (!xen_initial_domain())
287 - xenbus_probe();
288
289 /*
290 * Making sure board specific code will not set up ops for
291 diff --git a/arch/arm64/boot/dts/qcom/sdm845-db845c.dts b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
292 index 751651a6cd819..bf4fde88011c8 100644
293 --- a/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
294 +++ b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
295 @@ -337,7 +337,9 @@
296 &gcc {
297 protected-clocks = <GCC_QSPI_CORE_CLK>,
298 <GCC_QSPI_CORE_CLK_SRC>,
299 - <GCC_QSPI_CNOC_PERIPH_AHB_CLK>;
300 + <GCC_QSPI_CNOC_PERIPH_AHB_CLK>,
301 + <GCC_LPASS_Q6_AXI_CLK>,
302 + <GCC_LPASS_SWAY_CLK>;
303 };
304
305 &pm8998_gpio {
306 diff --git a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
307 index e638f216dbfb3..840d6b9bbb598 100644
308 --- a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
309 +++ b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
310 @@ -232,7 +232,9 @@
311 &gcc {
312 protected-clocks = <GCC_QSPI_CORE_CLK>,
313 <GCC_QSPI_CORE_CLK_SRC>,
314 - <GCC_QSPI_CNOC_PERIPH_AHB_CLK>;
315 + <GCC_QSPI_CNOC_PERIPH_AHB_CLK>,
316 + <GCC_LPASS_Q6_AXI_CLK>,
317 + <GCC_LPASS_SWAY_CLK>;
318 };
319
320 &i2c1 {
321 diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
322 index bb7d0aac6b9db..9d6ed8cda2c86 100644
323 --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
324 +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
325 @@ -232,6 +232,7 @@
326 reg = <0x0 0xf8000000 0x0 0x2000000>,
327 <0x0 0xfd000000 0x0 0x1000000>;
328 reg-names = "axi-base", "apb-base";
329 + device_type = "pci";
330 #address-cells = <3>;
331 #size-cells = <2>;
332 #interrupt-cells = <1>;
333 @@ -250,7 +251,6 @@
334 <0 0 0 2 &pcie0_intc 1>,
335 <0 0 0 3 &pcie0_intc 2>,
336 <0 0 0 4 &pcie0_intc 3>;
337 - linux,pci-domain = <0>;
338 max-link-speed = <1>;
339 msi-map = <0x0 &its 0x0 0x1000>;
340 phys = <&pcie_phy 0>, <&pcie_phy 1>,
341 diff --git a/arch/h8300/kernel/asm-offsets.c b/arch/h8300/kernel/asm-offsets.c
342 index 85e60509f0a83..d4b53af657c84 100644
343 --- a/arch/h8300/kernel/asm-offsets.c
344 +++ b/arch/h8300/kernel/asm-offsets.c
345 @@ -63,6 +63,9 @@ int main(void)
346 OFFSET(TI_FLAGS, thread_info, flags);
347 OFFSET(TI_CPU, thread_info, cpu);
348 OFFSET(TI_PRE, thread_info, preempt_count);
349 +#ifdef CONFIG_PREEMPTION
350 + DEFINE(TI_PRE_COUNT, offsetof(struct thread_info, preempt_count));
351 +#endif
352
353 return 0;
354 }
355 diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
356 index a4e576019d79c..3ea360cad337b 100644
357 --- a/arch/powerpc/kernel/vmlinux.lds.S
358 +++ b/arch/powerpc/kernel/vmlinux.lds.S
359 @@ -102,6 +102,7 @@ SECTIONS
360 #ifdef CONFIG_PPC64
361 *(.tramp.ftrace.text);
362 #endif
363 + NOINSTR_TEXT
364 SCHED_TEXT
365 CPUIDLE_TEXT
366 LOCK_TEXT
367 diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
368 index 3db261c4810fc..6a30794aa1eea 100644
369 --- a/arch/riscv/include/asm/page.h
370 +++ b/arch/riscv/include/asm/page.h
371 @@ -119,7 +119,10 @@ extern unsigned long min_low_pfn;
372
373 #endif /* __ASSEMBLY__ */
374
375 -#define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr)))
376 +#define virt_addr_valid(vaddr) ({ \
377 + unsigned long _addr = (unsigned long)vaddr; \
378 + (unsigned long)(_addr) >= PAGE_OFFSET && pfn_valid(virt_to_pfn(_addr)); \
379 +})
380
381 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
382 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
383 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
384 index b5e3bfd4facea..8ca3cf7c5ec97 100644
385 --- a/arch/x86/Makefile
386 +++ b/arch/x86/Makefile
387 @@ -61,6 +61,9 @@ endif
388 KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
389 KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
390
391 +# Intel CET isn't enabled in the kernel
392 +KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
393 +
394 ifeq ($(CONFIG_X86_32),y)
395 BITS := 32
396 UTS_MACHINE := i386
397 @@ -131,9 +134,6 @@ else
398
399 KBUILD_CFLAGS += -mno-red-zone
400 KBUILD_CFLAGS += -mcmodel=kernel
401 -
402 - # Intel CET isn't enabled in the kernel
403 - KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
404 endif
405
406 ifdef CONFIG_X86_X32
407 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
408 index 7d19aae015aeb..ba32adaeefdd0 100644
409 --- a/block/bfq-iosched.c
410 +++ b/block/bfq-iosched.c
411 @@ -6320,13 +6320,13 @@ static unsigned int bfq_update_depths(struct bfq_data *bfqd,
412 * limit 'something'.
413 */
414 /* no more than 50% of tags for async I/O */
415 - bfqd->word_depths[0][0] = max(bt->sb.depth >> 1, 1U);
416 + bfqd->word_depths[0][0] = max((1U << bt->sb.shift) >> 1, 1U);
417 /*
418 * no more than 75% of tags for sync writes (25% extra tags
419 * w.r.t. async I/O, to prevent async I/O from starving sync
420 * writes)
421 */
422 - bfqd->word_depths[0][1] = max((bt->sb.depth * 3) >> 2, 1U);
423 + bfqd->word_depths[0][1] = max(((1U << bt->sb.shift) * 3) >> 2, 1U);
424
425 /*
426 * In-word depths in case some bfq_queue is being weight-
427 @@ -6336,9 +6336,9 @@ static unsigned int bfq_update_depths(struct bfq_data *bfqd,
428 * shortage.
429 */
430 /* no more than ~18% of tags for async I/O */
431 - bfqd->word_depths[1][0] = max((bt->sb.depth * 3) >> 4, 1U);
432 + bfqd->word_depths[1][0] = max(((1U << bt->sb.shift) * 3) >> 4, 1U);
433 /* no more than ~37% of tags for sync writes (~20% extra tags) */
434 - bfqd->word_depths[1][1] = max((bt->sb.depth * 6) >> 4, 1U);
435 + bfqd->word_depths[1][1] = max(((1U << bt->sb.shift) * 6) >> 4, 1U);
436
437 for (i = 0; i < 2; i++)
438 for (j = 0; j < 2; j++)
439 diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c
440 index fa4ecb9155909..9d3a76604d94c 100644
441 --- a/drivers/clk/sunxi-ng/ccu_mp.c
442 +++ b/drivers/clk/sunxi-ng/ccu_mp.c
443 @@ -108,7 +108,7 @@ static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux,
444 max_m = cmp->m.max ?: 1 << cmp->m.width;
445 max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
446
447 - if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) {
448 + if (!clk_hw_can_set_rate_parent(&cmp->common.hw)) {
449 ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, &p);
450 rate = *parent_rate / p / m;
451 } else {
452 diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c
453 index 226da8df6f100..94d9fa0d6aa70 100644
454 --- a/drivers/gpio/gpio-ep93xx.c
455 +++ b/drivers/gpio/gpio-ep93xx.c
456 @@ -25,6 +25,9 @@
457 /* Maximum value for gpio line identifiers */
458 #define EP93XX_GPIO_LINE_MAX 63
459
460 +/* Number of GPIO chips in EP93XX */
461 +#define EP93XX_GPIO_CHIP_NUM 8
462 +
463 /* Maximum value for irq capable line identifiers */
464 #define EP93XX_GPIO_LINE_MAX_IRQ 23
465
466 @@ -34,74 +37,75 @@
467 */
468 #define EP93XX_GPIO_F_IRQ_BASE 80
469
470 -struct ep93xx_gpio {
471 - void __iomem *base;
472 - struct gpio_chip gc[8];
473 +struct ep93xx_gpio_irq_chip {
474 + struct irq_chip ic;
475 + u8 irq_offset;
476 + u8 int_unmasked;
477 + u8 int_enabled;
478 + u8 int_type1;
479 + u8 int_type2;
480 + u8 int_debounce;
481 };
482
483 -/*************************************************************************
484 - * Interrupt handling for EP93xx on-chip GPIOs
485 - *************************************************************************/
486 -static unsigned char gpio_int_unmasked[3];
487 -static unsigned char gpio_int_enabled[3];
488 -static unsigned char gpio_int_type1[3];
489 -static unsigned char gpio_int_type2[3];
490 -static unsigned char gpio_int_debounce[3];
491 -
492 -/* Port ordering is: A B F */
493 -static const u8 int_type1_register_offset[3] = { 0x90, 0xac, 0x4c };
494 -static const u8 int_type2_register_offset[3] = { 0x94, 0xb0, 0x50 };
495 -static const u8 eoi_register_offset[3] = { 0x98, 0xb4, 0x54 };
496 -static const u8 int_en_register_offset[3] = { 0x9c, 0xb8, 0x58 };
497 -static const u8 int_debounce_register_offset[3] = { 0xa8, 0xc4, 0x64 };
498 -
499 -static void ep93xx_gpio_update_int_params(struct ep93xx_gpio *epg, unsigned port)
500 -{
501 - BUG_ON(port > 2);
502 +struct ep93xx_gpio_chip {
503 + struct gpio_chip gc;
504 + struct ep93xx_gpio_irq_chip *eic;
505 +};
506
507 - writeb_relaxed(0, epg->base + int_en_register_offset[port]);
508 +struct ep93xx_gpio {
509 + void __iomem *base;
510 + struct ep93xx_gpio_chip gc[EP93XX_GPIO_CHIP_NUM];
511 +};
512
513 - writeb_relaxed(gpio_int_type2[port],
514 - epg->base + int_type2_register_offset[port]);
515 +#define to_ep93xx_gpio_chip(x) container_of(x, struct ep93xx_gpio_chip, gc)
516
517 - writeb_relaxed(gpio_int_type1[port],
518 - epg->base + int_type1_register_offset[port]);
519 +static struct ep93xx_gpio_irq_chip *to_ep93xx_gpio_irq_chip(struct gpio_chip *gc)
520 +{
521 + struct ep93xx_gpio_chip *egc = to_ep93xx_gpio_chip(gc);
522
523 - writeb(gpio_int_unmasked[port] & gpio_int_enabled[port],
524 - epg->base + int_en_register_offset[port]);
525 + return egc->eic;
526 }
527
528 -static int ep93xx_gpio_port(struct gpio_chip *gc)
529 +/*************************************************************************
530 + * Interrupt handling for EP93xx on-chip GPIOs
531 + *************************************************************************/
532 +#define EP93XX_INT_TYPE1_OFFSET 0x00
533 +#define EP93XX_INT_TYPE2_OFFSET 0x04
534 +#define EP93XX_INT_EOI_OFFSET 0x08
535 +#define EP93XX_INT_EN_OFFSET 0x0c
536 +#define EP93XX_INT_STATUS_OFFSET 0x10
537 +#define EP93XX_INT_RAW_STATUS_OFFSET 0x14
538 +#define EP93XX_INT_DEBOUNCE_OFFSET 0x18
539 +
540 +static void ep93xx_gpio_update_int_params(struct ep93xx_gpio *epg,
541 + struct ep93xx_gpio_irq_chip *eic)
542 {
543 - struct ep93xx_gpio *epg = gpiochip_get_data(gc);
544 - int port = 0;
545 + writeb_relaxed(0, epg->base + eic->irq_offset + EP93XX_INT_EN_OFFSET);
546
547 - while (port < ARRAY_SIZE(epg->gc) && gc != &epg->gc[port])
548 - port++;
549 + writeb_relaxed(eic->int_type2,
550 + epg->base + eic->irq_offset + EP93XX_INT_TYPE2_OFFSET);
551
552 - /* This should not happen but is there as a last safeguard */
553 - if (port == ARRAY_SIZE(epg->gc)) {
554 - pr_crit("can't find the GPIO port\n");
555 - return 0;
556 - }
557 + writeb_relaxed(eic->int_type1,
558 + epg->base + eic->irq_offset + EP93XX_INT_TYPE1_OFFSET);
559
560 - return port;
561 + writeb_relaxed(eic->int_unmasked & eic->int_enabled,
562 + epg->base + eic->irq_offset + EP93XX_INT_EN_OFFSET);
563 }
564
565 static void ep93xx_gpio_int_debounce(struct gpio_chip *gc,
566 unsigned int offset, bool enable)
567 {
568 struct ep93xx_gpio *epg = gpiochip_get_data(gc);
569 - int port = ep93xx_gpio_port(gc);
570 + struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
571 int port_mask = BIT(offset);
572
573 if (enable)
574 - gpio_int_debounce[port] |= port_mask;
575 + eic->int_debounce |= port_mask;
576 else
577 - gpio_int_debounce[port] &= ~port_mask;
578 + eic->int_debounce &= ~port_mask;
579
580 - writeb(gpio_int_debounce[port],
581 - epg->base + int_debounce_register_offset[port]);
582 + writeb(eic->int_debounce,
583 + epg->base + eic->irq_offset + EP93XX_INT_DEBOUNCE_OFFSET);
584 }
585
586 static void ep93xx_gpio_ab_irq_handler(struct irq_desc *desc)
587 @@ -122,12 +126,12 @@ static void ep93xx_gpio_ab_irq_handler(struct irq_desc *desc)
588 */
589 stat = readb(epg->base + EP93XX_GPIO_A_INT_STATUS);
590 for_each_set_bit(offset, &stat, 8)
591 - generic_handle_irq(irq_find_mapping(epg->gc[0].irq.domain,
592 + generic_handle_irq(irq_find_mapping(epg->gc[0].gc.irq.domain,
593 offset));
594
595 stat = readb(epg->base + EP93XX_GPIO_B_INT_STATUS);
596 for_each_set_bit(offset, &stat, 8)
597 - generic_handle_irq(irq_find_mapping(epg->gc[1].irq.domain,
598 + generic_handle_irq(irq_find_mapping(epg->gc[1].gc.irq.domain,
599 offset));
600
601 chained_irq_exit(irqchip, desc);
602 @@ -153,52 +157,52 @@ static void ep93xx_gpio_f_irq_handler(struct irq_desc *desc)
603 static void ep93xx_gpio_irq_ack(struct irq_data *d)
604 {
605 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
606 + struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
607 struct ep93xx_gpio *epg = gpiochip_get_data(gc);
608 - int port = ep93xx_gpio_port(gc);
609 int port_mask = BIT(d->irq & 7);
610
611 if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) {
612 - gpio_int_type2[port] ^= port_mask; /* switch edge direction */
613 - ep93xx_gpio_update_int_params(epg, port);
614 + eic->int_type2 ^= port_mask; /* switch edge direction */
615 + ep93xx_gpio_update_int_params(epg, eic);
616 }
617
618 - writeb(port_mask, epg->base + eoi_register_offset[port]);
619 + writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET);
620 }
621
622 static void ep93xx_gpio_irq_mask_ack(struct irq_data *d)
623 {
624 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
625 + struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
626 struct ep93xx_gpio *epg = gpiochip_get_data(gc);
627 - int port = ep93xx_gpio_port(gc);
628 int port_mask = BIT(d->irq & 7);
629
630 if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH)
631 - gpio_int_type2[port] ^= port_mask; /* switch edge direction */
632 + eic->int_type2 ^= port_mask; /* switch edge direction */
633
634 - gpio_int_unmasked[port] &= ~port_mask;
635 - ep93xx_gpio_update_int_params(epg, port);
636 + eic->int_unmasked &= ~port_mask;
637 + ep93xx_gpio_update_int_params(epg, eic);
638
639 - writeb(port_mask, epg->base + eoi_register_offset[port]);
640 + writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET);
641 }
642
643 static void ep93xx_gpio_irq_mask(struct irq_data *d)
644 {
645 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
646 + struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
647 struct ep93xx_gpio *epg = gpiochip_get_data(gc);
648 - int port = ep93xx_gpio_port(gc);
649
650 - gpio_int_unmasked[port] &= ~BIT(d->irq & 7);
651 - ep93xx_gpio_update_int_params(epg, port);
652 + eic->int_unmasked &= ~BIT(d->irq & 7);
653 + ep93xx_gpio_update_int_params(epg, eic);
654 }
655
656 static void ep93xx_gpio_irq_unmask(struct irq_data *d)
657 {
658 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
659 + struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
660 struct ep93xx_gpio *epg = gpiochip_get_data(gc);
661 - int port = ep93xx_gpio_port(gc);
662
663 - gpio_int_unmasked[port] |= BIT(d->irq & 7);
664 - ep93xx_gpio_update_int_params(epg, port);
665 + eic->int_unmasked |= BIT(d->irq & 7);
666 + ep93xx_gpio_update_int_params(epg, eic);
667 }
668
669 /*
670 @@ -209,8 +213,8 @@ static void ep93xx_gpio_irq_unmask(struct irq_data *d)
671 static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
672 {
673 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
674 + struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
675 struct ep93xx_gpio *epg = gpiochip_get_data(gc);
676 - int port = ep93xx_gpio_port(gc);
677 int offset = d->irq & 7;
678 int port_mask = BIT(offset);
679 irq_flow_handler_t handler;
680 @@ -219,32 +223,32 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
681
682 switch (type) {
683 case IRQ_TYPE_EDGE_RISING:
684 - gpio_int_type1[port] |= port_mask;
685 - gpio_int_type2[port] |= port_mask;
686 + eic->int_type1 |= port_mask;
687 + eic->int_type2 |= port_mask;
688 handler = handle_edge_irq;
689 break;
690 case IRQ_TYPE_EDGE_FALLING:
691 - gpio_int_type1[port] |= port_mask;
692 - gpio_int_type2[port] &= ~port_mask;
693 + eic->int_type1 |= port_mask;
694 + eic->int_type2 &= ~port_mask;
695 handler = handle_edge_irq;
696 break;
697 case IRQ_TYPE_LEVEL_HIGH:
698 - gpio_int_type1[port] &= ~port_mask;
699 - gpio_int_type2[port] |= port_mask;
700 + eic->int_type1 &= ~port_mask;
701 + eic->int_type2 |= port_mask;
702 handler = handle_level_irq;
703 break;
704 case IRQ_TYPE_LEVEL_LOW:
705 - gpio_int_type1[port] &= ~port_mask;
706 - gpio_int_type2[port] &= ~port_mask;
707 + eic->int_type1 &= ~port_mask;
708 + eic->int_type2 &= ~port_mask;
709 handler = handle_level_irq;
710 break;
711 case IRQ_TYPE_EDGE_BOTH:
712 - gpio_int_type1[port] |= port_mask;
713 + eic->int_type1 |= port_mask;
714 /* set initial polarity based on current input level */
715 if (gc->get(gc, offset))
716 - gpio_int_type2[port] &= ~port_mask; /* falling */
717 + eic->int_type2 &= ~port_mask; /* falling */
718 else
719 - gpio_int_type2[port] |= port_mask; /* rising */
720 + eic->int_type2 |= port_mask; /* rising */
721 handler = handle_edge_irq;
722 break;
723 default:
724 @@ -253,22 +257,13 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
725
726 irq_set_handler_locked(d, handler);
727
728 - gpio_int_enabled[port] |= port_mask;
729 + eic->int_enabled |= port_mask;
730
731 - ep93xx_gpio_update_int_params(epg, port);
732 + ep93xx_gpio_update_int_params(epg, eic);
733
734 return 0;
735 }
736
737 -static struct irq_chip ep93xx_gpio_irq_chip = {
738 - .name = "GPIO",
739 - .irq_ack = ep93xx_gpio_irq_ack,
740 - .irq_mask_ack = ep93xx_gpio_irq_mask_ack,
741 - .irq_mask = ep93xx_gpio_irq_mask,
742 - .irq_unmask = ep93xx_gpio_irq_unmask,
743 - .irq_set_type = ep93xx_gpio_irq_type,
744 -};
745 -
746 /*************************************************************************
747 * gpiolib interface for EP93xx on-chip GPIOs
748 *************************************************************************/
749 @@ -276,17 +271,19 @@ struct ep93xx_gpio_bank {
750 const char *label;
751 int data;
752 int dir;
753 + int irq;
754 int base;
755 bool has_irq;
756 bool has_hierarchical_irq;
757 unsigned int irq_base;
758 };
759
760 -#define EP93XX_GPIO_BANK(_label, _data, _dir, _base, _has_irq, _has_hier, _irq_base) \
761 +#define EP93XX_GPIO_BANK(_label, _data, _dir, _irq, _base, _has_irq, _has_hier, _irq_base) \
762 { \
763 .label = _label, \
764 .data = _data, \
765 .dir = _dir, \
766 + .irq = _irq, \
767 .base = _base, \
768 .has_irq = _has_irq, \
769 .has_hierarchical_irq = _has_hier, \
770 @@ -295,16 +292,16 @@ struct ep93xx_gpio_bank {
771
772 static struct ep93xx_gpio_bank ep93xx_gpio_banks[] = {
773 /* Bank A has 8 IRQs */
774 - EP93XX_GPIO_BANK("A", 0x00, 0x10, 0, true, false, 64),
775 + EP93XX_GPIO_BANK("A", 0x00, 0x10, 0x90, 0, true, false, 64),
776 /* Bank B has 8 IRQs */
777 - EP93XX_GPIO_BANK("B", 0x04, 0x14, 8, true, false, 72),
778 - EP93XX_GPIO_BANK("C", 0x08, 0x18, 40, false, false, 0),
779 - EP93XX_GPIO_BANK("D", 0x0c, 0x1c, 24, false, false, 0),
780 - EP93XX_GPIO_BANK("E", 0x20, 0x24, 32, false, false, 0),
781 + EP93XX_GPIO_BANK("B", 0x04, 0x14, 0xac, 8, true, false, 72),
782 + EP93XX_GPIO_BANK("C", 0x08, 0x18, 0x00, 40, false, false, 0),
783 + EP93XX_GPIO_BANK("D", 0x0c, 0x1c, 0x00, 24, false, false, 0),
784 + EP93XX_GPIO_BANK("E", 0x20, 0x24, 0x00, 32, false, false, 0),
785 /* Bank F has 8 IRQs */
786 - EP93XX_GPIO_BANK("F", 0x30, 0x34, 16, false, true, 0),
787 - EP93XX_GPIO_BANK("G", 0x38, 0x3c, 48, false, false, 0),
788 - EP93XX_GPIO_BANK("H", 0x40, 0x44, 56, false, false, 0),
789 + EP93XX_GPIO_BANK("F", 0x30, 0x34, 0x4c, 16, false, true, 0),
790 + EP93XX_GPIO_BANK("G", 0x38, 0x3c, 0x00, 48, false, false, 0),
791 + EP93XX_GPIO_BANK("H", 0x40, 0x44, 0x00, 56, false, false, 0),
792 };
793
794 static int ep93xx_gpio_set_config(struct gpio_chip *gc, unsigned offset,
795 @@ -326,13 +323,23 @@ static int ep93xx_gpio_f_to_irq(struct gpio_chip *gc, unsigned offset)
796 return EP93XX_GPIO_F_IRQ_BASE + offset;
797 }
798
799 -static int ep93xx_gpio_add_bank(struct gpio_chip *gc,
800 +static void ep93xx_init_irq_chip(struct device *dev, struct irq_chip *ic)
801 +{
802 + ic->irq_ack = ep93xx_gpio_irq_ack;
803 + ic->irq_mask_ack = ep93xx_gpio_irq_mask_ack;
804 + ic->irq_mask = ep93xx_gpio_irq_mask;
805 + ic->irq_unmask = ep93xx_gpio_irq_unmask;
806 + ic->irq_set_type = ep93xx_gpio_irq_type;
807 +}
808 +
809 +static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc,
810 struct platform_device *pdev,
811 struct ep93xx_gpio *epg,
812 struct ep93xx_gpio_bank *bank)
813 {
814 void __iomem *data = epg->base + bank->data;
815 void __iomem *dir = epg->base + bank->dir;
816 + struct gpio_chip *gc = &egc->gc;
817 struct device *dev = &pdev->dev;
818 struct gpio_irq_chip *girq;
819 int err;
820 @@ -346,8 +353,21 @@ static int ep93xx_gpio_add_bank(struct gpio_chip *gc,
821
822 girq = &gc->irq;
823 if (bank->has_irq || bank->has_hierarchical_irq) {
824 + struct irq_chip *ic;
825 +
826 gc->set_config = ep93xx_gpio_set_config;
827 - girq->chip = &ep93xx_gpio_irq_chip;
828 + egc->eic = devm_kcalloc(dev, 1,
829 + sizeof(*egc->eic),
830 + GFP_KERNEL);
831 + if (!egc->eic)
832 + return -ENOMEM;
833 + egc->eic->irq_offset = bank->irq;
834 + ic = &egc->eic->ic;
835 + ic->name = devm_kasprintf(dev, GFP_KERNEL, "gpio-irq-%s", bank->label);
836 + if (!ic->name)
837 + return -ENOMEM;
838 + ep93xx_init_irq_chip(dev, ic);
839 + girq->chip = ic;
840 }
841
842 if (bank->has_irq) {
843 @@ -389,7 +409,7 @@ static int ep93xx_gpio_add_bank(struct gpio_chip *gc,
844 gpio_irq = EP93XX_GPIO_F_IRQ_BASE + i;
845 irq_set_chip_data(gpio_irq, &epg->gc[5]);
846 irq_set_chip_and_handler(gpio_irq,
847 - &ep93xx_gpio_irq_chip,
848 + girq->chip,
849 handle_level_irq);
850 irq_clear_status_flags(gpio_irq, IRQ_NOREQUEST);
851 }
852 @@ -415,7 +435,7 @@ static int ep93xx_gpio_probe(struct platform_device *pdev)
853 return PTR_ERR(epg->base);
854
855 for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_banks); i++) {
856 - struct gpio_chip *gc = &epg->gc[i];
857 + struct ep93xx_gpio_chip *gc = &epg->gc[i];
858 struct ep93xx_gpio_bank *bank = &ep93xx_gpio_banks[i];
859
860 if (ep93xx_gpio_add_bank(gc, pdev, epg, bank))
861 diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
862 index de06ee7d2ad46..fbbe611d4873f 100644
863 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
864 +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
865 @@ -1093,8 +1093,8 @@ static void emulated_link_detect(struct dc_link *link)
866 link->type = dc_connection_none;
867 prev_sink = link->local_sink;
868
869 - if (prev_sink != NULL)
870 - dc_sink_retain(prev_sink);
871 + if (prev_sink)
872 + dc_sink_release(prev_sink);
873
874 switch (link->connector_signal) {
875 case SIGNAL_TYPE_HDMI_TYPE_A: {
876 @@ -1417,8 +1417,10 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
877 * TODO: check if we still need the S3 mode update workaround.
878 * If yes, put it here.
879 */
880 - if (aconnector->dc_sink)
881 + if (aconnector->dc_sink) {
882 amdgpu_dm_update_freesync_caps(connector, NULL);
883 + dc_sink_release(aconnector->dc_sink);
884 + }
885
886 aconnector->dc_sink = sink;
887 dc_sink_retain(aconnector->dc_sink);
888 @@ -6463,14 +6465,14 @@ static int dm_force_atomic_commit(struct drm_connector *connector)
889
890 ret = PTR_ERR_OR_ZERO(conn_state);
891 if (ret)
892 - goto err;
893 + goto out;
894
895 /* Attach crtc to drm_atomic_state*/
896 crtc_state = drm_atomic_get_crtc_state(state, &disconnected_acrtc->base);
897
898 ret = PTR_ERR_OR_ZERO(crtc_state);
899 if (ret)
900 - goto err;
901 + goto out;
902
903 /* force a restore */
904 crtc_state->mode_changed = true;
905 @@ -6480,17 +6482,15 @@ static int dm_force_atomic_commit(struct drm_connector *connector)
906
907 ret = PTR_ERR_OR_ZERO(plane_state);
908 if (ret)
909 - goto err;
910 -
911 + goto out;
912
913 /* Call commit internally with the state we just constructed */
914 ret = drm_atomic_commit(state);
915 - if (!ret)
916 - return 0;
917
918 -err:
919 - DRM_ERROR("Restoring old state failed with %i\n", ret);
920 +out:
921 drm_atomic_state_put(state);
922 + if (ret)
923 + DRM_ERROR("Restoring old state failed with %i\n", ret);
924
925 return ret;
926 }
927 diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
928 index a6d5beada6634..f63cbbee7b337 100644
929 --- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
930 +++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
931 @@ -826,6 +826,8 @@ enum dcn20_clk_src_array_id {
932 DCN20_CLK_SRC_PLL0,
933 DCN20_CLK_SRC_PLL1,
934 DCN20_CLK_SRC_PLL2,
935 + DCN20_CLK_SRC_PLL3,
936 + DCN20_CLK_SRC_PLL4,
937 DCN20_CLK_SRC_TOTAL_DCN21
938 };
939
940 @@ -1498,6 +1500,14 @@ static bool construct(
941 dcn21_clock_source_create(ctx, ctx->dc_bios,
942 CLOCK_SOURCE_COMBO_PHY_PLL2,
943 &clk_src_regs[2], false);
944 + pool->base.clock_sources[DCN20_CLK_SRC_PLL3] =
945 + dcn21_clock_source_create(ctx, ctx->dc_bios,
946 + CLOCK_SOURCE_COMBO_PHY_PLL3,
947 + &clk_src_regs[3], false);
948 + pool->base.clock_sources[DCN20_CLK_SRC_PLL4] =
949 + dcn21_clock_source_create(ctx, ctx->dc_bios,
950 + CLOCK_SOURCE_COMBO_PHY_PLL4,
951 + &clk_src_regs[4], false);
952
953 pool->base.clk_src_count = DCN20_CLK_SRC_TOTAL_DCN21;
954
955 diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
956 index ae7ae432aa4ab..6bf1425e8b0ca 100644
957 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
958 +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
959 @@ -665,6 +665,30 @@ static void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon,
960 SUN4I_TCON1_BASIC5_V_SYNC(vsync) |
961 SUN4I_TCON1_BASIC5_H_SYNC(hsync));
962
963 + /* Setup the polarity of multiple signals */
964 + if (tcon->quirks->polarity_in_ch0) {
965 + val = 0;
966 +
967 + if (mode->flags & DRM_MODE_FLAG_PHSYNC)
968 + val |= SUN4I_TCON0_IO_POL_HSYNC_POSITIVE;
969 +
970 + if (mode->flags & DRM_MODE_FLAG_PVSYNC)
971 + val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE;
972 +
973 + regmap_write(tcon->regs, SUN4I_TCON0_IO_POL_REG, val);
974 + } else {
975 + /* according to vendor driver, this bit must be always set */
976 + val = SUN4I_TCON1_IO_POL_UNKNOWN;
977 +
978 + if (mode->flags & DRM_MODE_FLAG_PHSYNC)
979 + val |= SUN4I_TCON1_IO_POL_HSYNC_POSITIVE;
980 +
981 + if (mode->flags & DRM_MODE_FLAG_PVSYNC)
982 + val |= SUN4I_TCON1_IO_POL_VSYNC_POSITIVE;
983 +
984 + regmap_write(tcon->regs, SUN4I_TCON1_IO_POL_REG, val);
985 + }
986 +
987 /* Map output pins to channel 1 */
988 regmap_update_bits(tcon->regs, SUN4I_TCON_GCTL_REG,
989 SUN4I_TCON_GCTL_IOMAP_MASK,
990 @@ -1482,6 +1506,7 @@ static const struct sun4i_tcon_quirks sun8i_a83t_tv_quirks = {
991
992 static const struct sun4i_tcon_quirks sun8i_r40_tv_quirks = {
993 .has_channel_1 = true,
994 + .polarity_in_ch0 = true,
995 .set_mux = sun8i_r40_tcon_tv_set_mux,
996 };
997
998 diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h
999 index a62ec826ae71e..5bdbaf0847824 100644
1000 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h
1001 +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h
1002 @@ -153,6 +153,11 @@
1003 #define SUN4I_TCON1_BASIC5_V_SYNC(height) (((height) - 1) & 0x3ff)
1004
1005 #define SUN4I_TCON1_IO_POL_REG 0xf0
1006 +/* there is no documentation about this bit */
1007 +#define SUN4I_TCON1_IO_POL_UNKNOWN BIT(26)
1008 +#define SUN4I_TCON1_IO_POL_HSYNC_POSITIVE BIT(25)
1009 +#define SUN4I_TCON1_IO_POL_VSYNC_POSITIVE BIT(24)
1010 +
1011 #define SUN4I_TCON1_IO_TRI_REG 0xf4
1012
1013 #define SUN4I_TCON_ECC_FIFO_REG 0xf8
1014 @@ -224,6 +229,7 @@ struct sun4i_tcon_quirks {
1015 bool needs_de_be_mux; /* sun6i needs mux to select backend */
1016 bool needs_edp_reset; /* a80 edp reset needed for tcon0 access */
1017 bool supports_lvds; /* Does the TCON support an LVDS output? */
1018 + bool polarity_in_ch0; /* some tcon1 channels have polarity bits in tcon0 pol register */
1019 u8 dclk_min_div; /* minimum divider for TCON0 DCLK */
1020
1021 /* callback to handle tcon muxing options */
1022 diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
1023 index 12fe241956213..8f721be26477b 100644
1024 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
1025 +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
1026 @@ -49,11 +49,9 @@ sun8i_dw_hdmi_mode_valid_h6(struct drm_connector *connector,
1027 {
1028 /*
1029 * Controller support maximum of 594 MHz, which correlates to
1030 - * 4K@60Hz 4:4:4 or RGB. However, for frequencies greater than
1031 - * 340 MHz scrambling has to be enabled. Because scrambling is
1032 - * not yet implemented, just limit to 340 MHz for now.
1033 + * 4K@60Hz 4:4:4 or RGB.
1034 */
1035 - if (mode->clock > 340000)
1036 + if (mode->clock > 594000)
1037 return MODE_CLOCK_HIGH;
1038
1039 return MODE_OK;
1040 diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c
1041 index 43643ad317306..a4012ec13d4b3 100644
1042 --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c
1043 +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c
1044 @@ -104,29 +104,21 @@ static const struct dw_hdmi_mpll_config sun50i_h6_mpll_cfg[] = {
1045
1046 static const struct dw_hdmi_curr_ctrl sun50i_h6_cur_ctr[] = {
1047 /* pixelclk bpp8 bpp10 bpp12 */
1048 - { 25175000, { 0x0000, 0x0000, 0x0000 }, },
1049 { 27000000, { 0x0012, 0x0000, 0x0000 }, },
1050 - { 59400000, { 0x0008, 0x0008, 0x0008 }, },
1051 - { 72000000, { 0x0008, 0x0008, 0x001b }, },
1052 - { 74250000, { 0x0013, 0x0013, 0x0013 }, },
1053 - { 90000000, { 0x0008, 0x001a, 0x001b }, },
1054 - { 118800000, { 0x001b, 0x001a, 0x001b }, },
1055 - { 144000000, { 0x001b, 0x001a, 0x0034 }, },
1056 - { 180000000, { 0x001b, 0x0033, 0x0034 }, },
1057 - { 216000000, { 0x0036, 0x0033, 0x0034 }, },
1058 - { 237600000, { 0x0036, 0x0033, 0x001b }, },
1059 - { 288000000, { 0x0036, 0x001b, 0x001b }, },
1060 - { 297000000, { 0x0019, 0x001b, 0x0019 }, },
1061 - { 330000000, { 0x0036, 0x001b, 0x001b }, },
1062 - { 594000000, { 0x003f, 0x001b, 0x001b }, },
1063 + { 74250000, { 0x0013, 0x001a, 0x001b }, },
1064 + { 148500000, { 0x0019, 0x0033, 0x0034 }, },
1065 + { 297000000, { 0x0019, 0x001b, 0x001b }, },
1066 + { 594000000, { 0x0010, 0x001b, 0x001b }, },
1067 { ~0UL, { 0x0000, 0x0000, 0x0000 }, }
1068 };
1069
1070 static const struct dw_hdmi_phy_config sun50i_h6_phy_config[] = {
1071 /*pixelclk symbol term vlev*/
1072 - { 74250000, 0x8009, 0x0004, 0x0232},
1073 - { 148500000, 0x8029, 0x0004, 0x0273},
1074 - { 594000000, 0x8039, 0x0004, 0x014a},
1075 + { 27000000, 0x8009, 0x0007, 0x02b0 },
1076 + { 74250000, 0x8009, 0x0006, 0x022d },
1077 + { 148500000, 0x8029, 0x0006, 0x0270 },
1078 + { 297000000, 0x8039, 0x0005, 0x01ab },
1079 + { 594000000, 0x8029, 0x0000, 0x008a },
1080 { ~0UL, 0x0000, 0x0000, 0x0000}
1081 };
1082
1083 diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
1084 index 5e5f90810acaf..363f456ea7134 100644
1085 --- a/drivers/gpu/drm/vc4/vc4_plane.c
1086 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
1087 @@ -205,7 +205,7 @@ static void vc4_plane_reset(struct drm_plane *plane)
1088 __drm_atomic_helper_plane_reset(plane, &vc4_state->base);
1089 }
1090
1091 -static void vc4_dlist_write(struct vc4_plane_state *vc4_state, u32 val)
1092 +static void vc4_dlist_counter_increment(struct vc4_plane_state *vc4_state)
1093 {
1094 if (vc4_state->dlist_count == vc4_state->dlist_size) {
1095 u32 new_size = max(4u, vc4_state->dlist_count * 2);
1096 @@ -220,7 +220,15 @@ static void vc4_dlist_write(struct vc4_plane_state *vc4_state, u32 val)
1097 vc4_state->dlist_size = new_size;
1098 }
1099
1100 - vc4_state->dlist[vc4_state->dlist_count++] = val;
1101 + vc4_state->dlist_count++;
1102 +}
1103 +
1104 +static void vc4_dlist_write(struct vc4_plane_state *vc4_state, u32 val)
1105 +{
1106 + unsigned int idx = vc4_state->dlist_count;
1107 +
1108 + vc4_dlist_counter_increment(vc4_state);
1109 + vc4_state->dlist[idx] = val;
1110 }
1111
1112 /* Returns the scl0/scl1 field based on whether the dimensions need to
1113 @@ -871,8 +879,10 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
1114 * be set when calling vc4_plane_allocate_lbm().
1115 */
1116 if (vc4_state->y_scaling[0] != VC4_SCALING_NONE ||
1117 - vc4_state->y_scaling[1] != VC4_SCALING_NONE)
1118 - vc4_state->lbm_offset = vc4_state->dlist_count++;
1119 + vc4_state->y_scaling[1] != VC4_SCALING_NONE) {
1120 + vc4_state->lbm_offset = vc4_state->dlist_count;
1121 + vc4_dlist_counter_increment(vc4_state);
1122 + }
1123
1124 if (num_planes > 1) {
1125 /* Emit Cb/Cr as channel 0 and Y as channel
1126 diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
1127 index b2634afe066d3..a7977eef2ead5 100644
1128 --- a/drivers/i2c/busses/i2c-stm32f7.c
1129 +++ b/drivers/i2c/busses/i2c-stm32f7.c
1130 @@ -53,6 +53,8 @@
1131 #define STM32F7_I2C_CR1_RXDMAEN BIT(15)
1132 #define STM32F7_I2C_CR1_TXDMAEN BIT(14)
1133 #define STM32F7_I2C_CR1_ANFOFF BIT(12)
1134 +#define STM32F7_I2C_CR1_DNF_MASK GENMASK(11, 8)
1135 +#define STM32F7_I2C_CR1_DNF(n) (((n) & 0xf) << 8)
1136 #define STM32F7_I2C_CR1_ERRIE BIT(7)
1137 #define STM32F7_I2C_CR1_TCIE BIT(6)
1138 #define STM32F7_I2C_CR1_STOPIE BIT(5)
1139 @@ -151,7 +153,7 @@
1140 #define STM32F7_I2C_MAX_SLAVE 0x2
1141
1142 #define STM32F7_I2C_DNF_DEFAULT 0
1143 -#define STM32F7_I2C_DNF_MAX 16
1144 +#define STM32F7_I2C_DNF_MAX 15
1145
1146 #define STM32F7_I2C_ANALOG_FILTER_ENABLE 1
1147 #define STM32F7_I2C_ANALOG_FILTER_DELAY_MIN 50 /* ns */
1148 @@ -657,6 +659,13 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
1149 else
1150 stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
1151 STM32F7_I2C_CR1_ANFOFF);
1152 +
1153 + /* Program the Digital Filter */
1154 + stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
1155 + STM32F7_I2C_CR1_DNF_MASK);
1156 + stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
1157 + STM32F7_I2C_CR1_DNF(i2c_dev->setup.dnf));
1158 +
1159 stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
1160 STM32F7_I2C_CR1_PE);
1161 }
1162 diff --git a/drivers/misc/lkdtm/Makefile b/drivers/misc/lkdtm/Makefile
1163 index c70b3822013f4..30c8ac24635d4 100644
1164 --- a/drivers/misc/lkdtm/Makefile
1165 +++ b/drivers/misc/lkdtm/Makefile
1166 @@ -16,7 +16,7 @@ KCOV_INSTRUMENT_rodata.o := n
1167
1168 OBJCOPYFLAGS :=
1169 OBJCOPYFLAGS_rodata_objcopy.o := \
1170 - --rename-section .text=.rodata,alloc,readonly,load
1171 + --rename-section .noinstr.text=.rodata,alloc,readonly,load
1172 targets += rodata.o rodata_objcopy.o
1173 $(obj)/rodata_objcopy.o: $(obj)/rodata.o FORCE
1174 $(call if_changed,objcopy)
1175 diff --git a/drivers/misc/lkdtm/rodata.c b/drivers/misc/lkdtm/rodata.c
1176 index 58d180af72cf0..baacb876d1d94 100644
1177 --- a/drivers/misc/lkdtm/rodata.c
1178 +++ b/drivers/misc/lkdtm/rodata.c
1179 @@ -5,7 +5,7 @@
1180 */
1181 #include "lkdtm.h"
1182
1183 -void notrace lkdtm_rodata_do_nothing(void)
1184 +void noinstr lkdtm_rodata_do_nothing(void)
1185 {
1186 /* Does nothing. We just want an architecture agnostic "return". */
1187 }
1188 diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
1189 index 7428f62408a20..fac80831d5327 100644
1190 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h
1191 +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
1192 @@ -181,6 +181,8 @@ enum enetc_bdr_type {TX, RX};
1193 #define ENETC_PTCCBSR0(n) (0x1110 + (n) * 8) /* n = 0 to 7*/
1194 #define ENETC_PTCCBSR1(n) (0x1114 + (n) * 8) /* n = 0 to 7*/
1195 #define ENETC_RSSHASH_KEY_SIZE 40
1196 +#define ENETC_PRSSCAPR 0x1404
1197 +#define ENETC_PRSSCAPR_GET_NUM_RSS(val) (BIT((val) & 0xf) * 32)
1198 #define ENETC_PRSSK(n) (0x1410 + (n) * 4) /* n = [0..9] */
1199 #define ENETC_PSIVLANFMR 0x1700
1200 #define ENETC_PSIVLANFMR_VS BIT(0)
1201 diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
1202 index 74847aa644f12..22f70638a4055 100644
1203 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
1204 +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
1205 @@ -809,6 +809,51 @@ static void enetc_of_put_phy(struct enetc_ndev_priv *priv)
1206 of_node_put(priv->phy_node);
1207 }
1208
1209 +/* Initialize the entire shared memory for the flow steering entries
1210 + * of this port (PF + VFs)
1211 + */
1212 +static int enetc_init_port_rfs_memory(struct enetc_si *si)
1213 +{
1214 + struct enetc_cmd_rfse rfse = {0};
1215 + struct enetc_hw *hw = &si->hw;
1216 + int num_rfs, i, err = 0;
1217 + u32 val;
1218 +
1219 + val = enetc_port_rd(hw, ENETC_PRFSCAPR);
1220 + num_rfs = ENETC_PRFSCAPR_GET_NUM_RFS(val);
1221 +
1222 + for (i = 0; i < num_rfs; i++) {
1223 + err = enetc_set_fs_entry(si, &rfse, i);
1224 + if (err)
1225 + break;
1226 + }
1227 +
1228 + return err;
1229 +}
1230 +
1231 +static int enetc_init_port_rss_memory(struct enetc_si *si)
1232 +{
1233 + struct enetc_hw *hw = &si->hw;
1234 + int num_rss, err;
1235 + int *rss_table;
1236 + u32 val;
1237 +
1238 + val = enetc_port_rd(hw, ENETC_PRSSCAPR);
1239 + num_rss = ENETC_PRSSCAPR_GET_NUM_RSS(val);
1240 + if (!num_rss)
1241 + return 0;
1242 +
1243 + rss_table = kcalloc(num_rss, sizeof(*rss_table), GFP_KERNEL);
1244 + if (!rss_table)
1245 + return -ENOMEM;
1246 +
1247 + err = enetc_set_rss_table(si, rss_table, num_rss);
1248 +
1249 + kfree(rss_table);
1250 +
1251 + return err;
1252 +}
1253 +
1254 static int enetc_pf_probe(struct pci_dev *pdev,
1255 const struct pci_device_id *ent)
1256 {
1257 @@ -863,6 +908,18 @@ static int enetc_pf_probe(struct pci_dev *pdev,
1258 goto err_alloc_si_res;
1259 }
1260
1261 + err = enetc_init_port_rfs_memory(si);
1262 + if (err) {
1263 + dev_err(&pdev->dev, "Failed to initialize RFS memory\n");
1264 + goto err_init_port_rfs;
1265 + }
1266 +
1267 + err = enetc_init_port_rss_memory(si);
1268 + if (err) {
1269 + dev_err(&pdev->dev, "Failed to initialize RSS memory\n");
1270 + goto err_init_port_rss;
1271 + }
1272 +
1273 err = enetc_alloc_msix(priv);
1274 if (err) {
1275 dev_err(&pdev->dev, "MSIX alloc failed\n");
1276 @@ -888,6 +945,8 @@ err_reg_netdev:
1277 enetc_mdio_remove(pf);
1278 enetc_of_put_phy(priv);
1279 enetc_free_msix(priv);
1280 +err_init_port_rss:
1281 +err_init_port_rfs:
1282 err_alloc_msix:
1283 enetc_free_si_resources(priv);
1284 err_alloc_si_res:
1285 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
1286 index 6887b7fda6e07..08040cafc06bc 100644
1287 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
1288 +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
1289 @@ -8563,12 +8563,19 @@ int hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
1290
1291 void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id)
1292 {
1293 + struct hnae3_handle *handle = &vport->nic;
1294 struct hclge_dev *hdev = vport->back;
1295 int reset_try_times = 0;
1296 int reset_status;
1297 u16 queue_gid;
1298 int ret;
1299
1300 + if (queue_id >= handle->kinfo.num_tqps) {
1301 + dev_warn(&hdev->pdev->dev, "Invalid vf queue id(%u)\n",
1302 + queue_id);
1303 + return;
1304 + }
1305 +
1306 queue_gid = hclge_covert_handle_qid_global(&vport->nic, queue_id);
1307
1308 ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, true);
1309 diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
1310 index c3079f436f6d7..0f35eec967ae8 100644
1311 --- a/drivers/net/ethernet/ibm/ibmvnic.c
1312 +++ b/drivers/net/ethernet/ibm/ibmvnic.c
1313 @@ -4595,7 +4595,22 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
1314 complete(&adapter->init_done);
1315 adapter->init_done_rc = -EIO;
1316 }
1317 - ibmvnic_reset(adapter, VNIC_RESET_FAILOVER);
1318 + rc = ibmvnic_reset(adapter, VNIC_RESET_FAILOVER);
1319 + if (rc && rc != -EBUSY) {
1320 + /* We were unable to schedule the failover
1321 + * reset either because the adapter was still
1322 + * probing (eg: during kexec) or we could not
1323 + * allocate memory. Clear the failover_pending
1324 + * flag since no one else will. We ignore
1325 + * EBUSY because it means either FAILOVER reset
1326 + * is already scheduled or the adapter is
1327 + * being removed.
1328 + */
1329 + netdev_err(netdev,
1330 + "Error %ld scheduling failover reset\n",
1331 + rc);
1332 + adapter->failover_pending = false;
1333 + }
1334 break;
1335 case IBMVNIC_CRQ_INIT_COMPLETE:
1336 dev_info(dev, "Partner initialization complete\n");
1337 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
1338 index 1d135b02ea021..52b453b605979 100644
1339 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
1340 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
1341 @@ -332,7 +332,12 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
1342
1343 priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_AVB;
1344 } else if (!qopt->enable) {
1345 - return stmmac_dma_qmode(priv, priv->ioaddr, queue, MTL_QUEUE_DCB);
1346 + ret = stmmac_dma_qmode(priv, priv->ioaddr, queue,
1347 + MTL_QUEUE_DCB);
1348 + if (ret)
1349 + return ret;
1350 +
1351 + priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
1352 }
1353
1354 /* Port Transmit Rate and Speed Divider */
1355 diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
1356 index 026d996612fbe..781952b686ed2 100644
1357 --- a/drivers/net/wireless/mediatek/mt76/dma.c
1358 +++ b/drivers/net/wireless/mediatek/mt76/dma.c
1359 @@ -452,15 +452,17 @@ static void
1360 mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,
1361 int len, bool more)
1362 {
1363 - struct page *page = virt_to_head_page(data);
1364 - int offset = data - page_address(page);
1365 struct sk_buff *skb = q->rx_head;
1366 struct skb_shared_info *shinfo = skb_shinfo(skb);
1367
1368 if (shinfo->nr_frags < ARRAY_SIZE(shinfo->frags)) {
1369 - offset += q->buf_offset;
1370 + struct page *page = virt_to_head_page(data);
1371 + int offset = data - page_address(page) + q->buf_offset;
1372 +
1373 skb_add_rx_frag(skb, shinfo->nr_frags, page, offset, len,
1374 q->buf_size);
1375 + } else {
1376 + skb_free_frag(data);
1377 }
1378
1379 if (more)
1380 diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c
1381 index 9b62f65b630e4..48e2006f96ce6 100644
1382 --- a/drivers/net/xen-netback/rx.c
1383 +++ b/drivers/net/xen-netback/rx.c
1384 @@ -38,10 +38,15 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue)
1385 RING_IDX prod, cons;
1386 struct sk_buff *skb;
1387 int needed;
1388 + unsigned long flags;
1389 +
1390 + spin_lock_irqsave(&queue->rx_queue.lock, flags);
1391
1392 skb = skb_peek(&queue->rx_queue);
1393 - if (!skb)
1394 + if (!skb) {
1395 + spin_unlock_irqrestore(&queue->rx_queue.lock, flags);
1396 return false;
1397 + }
1398
1399 needed = DIV_ROUND_UP(skb->len, XEN_PAGE_SIZE);
1400 if (skb_is_gso(skb))
1401 @@ -49,6 +54,8 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue)
1402 if (skb->sw_hash)
1403 needed++;
1404
1405 + spin_unlock_irqrestore(&queue->rx_queue.lock, flags);
1406 +
1407 do {
1408 prod = queue->rx.sring->req_prod;
1409 cons = queue->rx.req_cons;
1410 diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
1411 index 434d3f21f0e13..19e375b59f407 100644
1412 --- a/drivers/nvme/host/pci.c
1413 +++ b/drivers/nvme/host/pci.c
1414 @@ -3147,6 +3147,8 @@ static const struct pci_device_id nvme_id_table[] = {
1415 { PCI_DEVICE(0x144d, 0xa822), /* Samsung PM1725a */
1416 .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY |
1417 NVME_QUIRK_IGNORE_DEV_SUBNQN, },
1418 + { PCI_DEVICE(0x1987, 0x5016), /* Phison E16 */
1419 + .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, },
1420 { PCI_DEVICE(0x1d1d, 0x1f1f), /* LighNVM qemu device */
1421 .driver_data = NVME_QUIRK_LIGHTNVM, },
1422 { PCI_DEVICE(0x1d1d, 0x2807), /* CNEX WL */
1423 diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
1424 index a44a2ec332872..63a530a3d9feb 100644
1425 --- a/drivers/platform/x86/hp-wmi.c
1426 +++ b/drivers/platform/x86/hp-wmi.c
1427 @@ -32,6 +32,10 @@ MODULE_LICENSE("GPL");
1428 MODULE_ALIAS("wmi:95F24279-4D7B-4334-9387-ACCDC67EF61C");
1429 MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
1430
1431 +static int enable_tablet_mode_sw = -1;
1432 +module_param(enable_tablet_mode_sw, int, 0444);
1433 +MODULE_PARM_DESC(enable_tablet_mode_sw, "Enable SW_TABLET_MODE reporting (-1=auto, 0=no, 1=yes)");
1434 +
1435 #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C"
1436 #define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4"
1437
1438 @@ -654,10 +658,12 @@ static int __init hp_wmi_input_setup(void)
1439 }
1440
1441 /* Tablet mode */
1442 - val = hp_wmi_hw_state(HPWMI_TABLET_MASK);
1443 - if (!(val < 0)) {
1444 - __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit);
1445 - input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val);
1446 + if (enable_tablet_mode_sw > 0) {
1447 + val = hp_wmi_hw_state(HPWMI_TABLET_MASK);
1448 + if (val >= 0) {
1449 + __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit);
1450 + input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val);
1451 + }
1452 }
1453
1454 err = sparse_keymap_setup(hp_wmi_input_dev, hp_wmi_keymap, NULL);
1455 diff --git a/drivers/usb/dwc3/ulpi.c b/drivers/usb/dwc3/ulpi.c
1456 index bb8271531da70..ffe3440abb74c 100644
1457 --- a/drivers/usb/dwc3/ulpi.c
1458 +++ b/drivers/usb/dwc3/ulpi.c
1459 @@ -7,6 +7,8 @@
1460 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
1461 */
1462
1463 +#include <linux/delay.h>
1464 +#include <linux/time64.h>
1465 #include <linux/ulpi/regs.h>
1466
1467 #include "core.h"
1468 @@ -17,12 +19,22 @@
1469 DWC3_GUSB2PHYACC_ADDR(ULPI_ACCESS_EXTENDED) | \
1470 DWC3_GUSB2PHYACC_EXTEND_ADDR(a) : DWC3_GUSB2PHYACC_ADDR(a))
1471
1472 -static int dwc3_ulpi_busyloop(struct dwc3 *dwc)
1473 +#define DWC3_ULPI_BASE_DELAY DIV_ROUND_UP(NSEC_PER_SEC, 60000000L)
1474 +
1475 +static int dwc3_ulpi_busyloop(struct dwc3 *dwc, u8 addr, bool read)
1476 {
1477 - unsigned count = 1000;
1478 + unsigned long ns = 5L * DWC3_ULPI_BASE_DELAY;
1479 + unsigned int count = 1000;
1480 u32 reg;
1481
1482 + if (addr >= ULPI_EXT_VENDOR_SPECIFIC)
1483 + ns += DWC3_ULPI_BASE_DELAY;
1484 +
1485 + if (read)
1486 + ns += DWC3_ULPI_BASE_DELAY;
1487 +
1488 while (count--) {
1489 + ndelay(ns);
1490 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYACC(0));
1491 if (reg & DWC3_GUSB2PHYACC_DONE)
1492 return 0;
1493 @@ -47,7 +59,7 @@ static int dwc3_ulpi_read(struct device *dev, u8 addr)
1494 reg = DWC3_GUSB2PHYACC_NEWREGREQ | DWC3_ULPI_ADDR(addr);
1495 dwc3_writel(dwc->regs, DWC3_GUSB2PHYACC(0), reg);
1496
1497 - ret = dwc3_ulpi_busyloop(dwc);
1498 + ret = dwc3_ulpi_busyloop(dwc, addr, true);
1499 if (ret)
1500 return ret;
1501
1502 @@ -71,7 +83,7 @@ static int dwc3_ulpi_write(struct device *dev, u8 addr, u8 val)
1503 reg |= DWC3_GUSB2PHYACC_WRITE | val;
1504 dwc3_writel(dwc->regs, DWC3_GUSB2PHYACC(0), reg);
1505
1506 - return dwc3_ulpi_busyloop(dwc);
1507 + return dwc3_ulpi_busyloop(dwc, addr, false);
1508 }
1509
1510 static const struct ulpi_ops dwc3_ulpi_ops = {
1511 diff --git a/drivers/xen/xenbus/xenbus.h b/drivers/xen/xenbus/xenbus.h
1512 index a9bb5f91082d3..88516a8a9f932 100644
1513 --- a/drivers/xen/xenbus/xenbus.h
1514 +++ b/drivers/xen/xenbus/xenbus.h
1515 @@ -115,7 +115,6 @@ int xenbus_probe_node(struct xen_bus_type *bus,
1516 const char *type,
1517 const char *nodename);
1518 int xenbus_probe_devices(struct xen_bus_type *bus);
1519 -void xenbus_probe(void);
1520
1521 void xenbus_dev_changed(const char *node, struct xen_bus_type *bus);
1522
1523 diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
1524 index 786494bb7f20b..652894d619677 100644
1525 --- a/drivers/xen/xenbus/xenbus_probe.c
1526 +++ b/drivers/xen/xenbus/xenbus_probe.c
1527 @@ -683,7 +683,7 @@ void unregister_xenstore_notifier(struct notifier_block *nb)
1528 }
1529 EXPORT_SYMBOL_GPL(unregister_xenstore_notifier);
1530
1531 -void xenbus_probe(void)
1532 +static void xenbus_probe(void)
1533 {
1534 xenstored_ready = 1;
1535
1536 diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
1537 index ec5eca5a96f41..7b758d623b5bd 100644
1538 --- a/fs/overlayfs/copy_up.c
1539 +++ b/fs/overlayfs/copy_up.c
1540 @@ -76,6 +76,14 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new)
1541
1542 if (ovl_is_private_xattr(name))
1543 continue;
1544 +
1545 + error = security_inode_copy_up_xattr(name);
1546 + if (error < 0 && error != -EOPNOTSUPP)
1547 + break;
1548 + if (error == 1) {
1549 + error = 0;
1550 + continue; /* Discard */
1551 + }
1552 retry:
1553 size = vfs_getxattr(old, name, value, value_size);
1554 if (size == -ERANGE)
1555 @@ -99,13 +107,6 @@ retry:
1556 goto retry;
1557 }
1558
1559 - error = security_inode_copy_up_xattr(name);
1560 - if (error < 0 && error != -EOPNOTSUPP)
1561 - break;
1562 - if (error == 1) {
1563 - error = 0;
1564 - continue; /* Discard */
1565 - }
1566 error = vfs_setxattr(new, name, value, size, 0);
1567 if (error)
1568 break;
1569 diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
1570 index bb980721502dd..56b55397a7a00 100644
1571 --- a/fs/overlayfs/inode.c
1572 +++ b/fs/overlayfs/inode.c
1573 @@ -337,7 +337,9 @@ int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char *name,
1574 goto out;
1575
1576 if (!value && !upperdentry) {
1577 + old_cred = ovl_override_creds(dentry->d_sb);
1578 err = vfs_getxattr(realdentry, name, NULL, 0);
1579 + revert_creds(old_cred);
1580 if (err < 0)
1581 goto out_drop_write;
1582 }
1583 diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
1584 index d6b724beb304c..87cf9b1d2eca3 100644
1585 --- a/fs/overlayfs/super.c
1586 +++ b/fs/overlayfs/super.c
1587 @@ -79,7 +79,7 @@ static void ovl_dentry_release(struct dentry *dentry)
1588 static struct dentry *ovl_d_real(struct dentry *dentry,
1589 const struct inode *inode)
1590 {
1591 - struct dentry *real;
1592 + struct dentry *real = NULL, *lower;
1593
1594 /* It's an overlay file */
1595 if (inode && d_inode(dentry) == inode)
1596 @@ -98,9 +98,10 @@ static struct dentry *ovl_d_real(struct dentry *dentry,
1597 if (real && !inode && ovl_has_upperdata(d_inode(dentry)))
1598 return real;
1599
1600 - real = ovl_dentry_lowerdata(dentry);
1601 - if (!real)
1602 + lower = ovl_dentry_lowerdata(dentry);
1603 + if (!lower)
1604 goto bug;
1605 + real = lower;
1606
1607 /* Handle recursion */
1608 real = d_real(real, inode);
1609 @@ -108,8 +109,10 @@ static struct dentry *ovl_d_real(struct dentry *dentry,
1610 if (!inode || inode == d_inode(real))
1611 return real;
1612 bug:
1613 - WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry,
1614 - inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0);
1615 + WARN(1, "%s(%pd4, %s:%lu): real dentry (%p/%lu) not found\n",
1616 + __func__, dentry, inode ? inode->i_sb->s_id : "NULL",
1617 + inode ? inode->i_ino : 0, real,
1618 + real && d_inode(real) ? d_inode(real)->i_ino : 0);
1619 return dentry;
1620 }
1621
1622 diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
1623 index d1779d442aa51..66397ed10acb7 100644
1624 --- a/include/asm-generic/sections.h
1625 +++ b/include/asm-generic/sections.h
1626 @@ -53,6 +53,9 @@ extern char __ctors_start[], __ctors_end[];
1627 /* Start and end of .opd section - used for function descriptors. */
1628 extern char __start_opd[], __end_opd[];
1629
1630 +/* Start and end of instrumentation protected text section */
1631 +extern char __noinstr_text_start[], __noinstr_text_end[];
1632 +
1633 extern __visible const void __nosave_begin, __nosave_end;
1634
1635 /* Function descriptor handling (if any). Override in asm/sections.h */
1636 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
1637 index 130f16cc0b86d..2267b7c763c64 100644
1638 --- a/include/asm-generic/vmlinux.lds.h
1639 +++ b/include/asm-generic/vmlinux.lds.h
1640 @@ -396,7 +396,7 @@
1641 } \
1642 \
1643 /* Built-in firmware blobs */ \
1644 - .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \
1645 + .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) ALIGN(8) { \
1646 __start_builtin_fw = .; \
1647 KEEP(*(.builtin_fw)) \
1648 __end_builtin_fw = .; \
1649 @@ -510,6 +510,15 @@
1650 #define RODATA RO_DATA_SECTION(4096)
1651 #define RO_DATA(align) RO_DATA_SECTION(align)
1652
1653 +/*
1654 + * Non-instrumentable text section
1655 + */
1656 +#define NOINSTR_TEXT \
1657 + ALIGN_FUNCTION(); \
1658 + __noinstr_text_start = .; \
1659 + *(.noinstr.text) \
1660 + __noinstr_text_end = .;
1661 +
1662 /*
1663 * .text section. Map to function alignment to avoid address changes
1664 * during second ld run in second ld pass when generating System.map
1665 @@ -524,6 +533,7 @@
1666 *(TEXT_MAIN .text.fixup) \
1667 *(.text.unlikely .text.unlikely.*) \
1668 *(.text.unknown .text.unknown.*) \
1669 + NOINSTR_TEXT \
1670 *(.text..refcount) \
1671 *(.ref.text) \
1672 MEM_KEEP(init.text*) \
1673 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
1674 index f164a9b12813f..9446e8fbe55c5 100644
1675 --- a/include/linux/compiler.h
1676 +++ b/include/linux/compiler.h
1677 @@ -134,12 +134,65 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
1678 /* Annotate a C jump table to allow objtool to follow the code flow */
1679 #define __annotate_jump_table __section(.rodata..c_jump_table)
1680
1681 +#ifdef CONFIG_DEBUG_ENTRY
1682 +/* Begin/end of an instrumentation safe region */
1683 +#define instrumentation_begin() ({ \
1684 + asm volatile("%c0:\n\t" \
1685 + ".pushsection .discard.instr_begin\n\t" \
1686 + ".long %c0b - .\n\t" \
1687 + ".popsection\n\t" : : "i" (__COUNTER__)); \
1688 +})
1689 +
1690 +/*
1691 + * Because instrumentation_{begin,end}() can nest, objtool validation considers
1692 + * _begin() a +1 and _end() a -1 and computes a sum over the instructions.
1693 + * When the value is greater than 0, we consider instrumentation allowed.
1694 + *
1695 + * There is a problem with code like:
1696 + *
1697 + * noinstr void foo()
1698 + * {
1699 + * instrumentation_begin();
1700 + * ...
1701 + * if (cond) {
1702 + * instrumentation_begin();
1703 + * ...
1704 + * instrumentation_end();
1705 + * }
1706 + * bar();
1707 + * instrumentation_end();
1708 + * }
1709 + *
1710 + * If instrumentation_end() would be an empty label, like all the other
1711 + * annotations, the inner _end(), which is at the end of a conditional block,
1712 + * would land on the instruction after the block.
1713 + *
1714 + * If we then consider the sum of the !cond path, we'll see that the call to
1715 + * bar() is with a 0-value, even though, we meant it to happen with a positive
1716 + * value.
1717 + *
1718 + * To avoid this, have _end() be a NOP instruction, this ensures it will be
1719 + * part of the condition block and does not escape.
1720 + */
1721 +#define instrumentation_end() ({ \
1722 + asm volatile("%c0: nop\n\t" \
1723 + ".pushsection .discard.instr_end\n\t" \
1724 + ".long %c0b - .\n\t" \
1725 + ".popsection\n\t" : : "i" (__COUNTER__)); \
1726 +})
1727 +#endif /* CONFIG_DEBUG_ENTRY */
1728 +
1729 #else
1730 #define annotate_reachable()
1731 #define annotate_unreachable()
1732 #define __annotate_jump_table
1733 #endif
1734
1735 +#ifndef instrumentation_begin
1736 +#define instrumentation_begin() do { } while(0)
1737 +#define instrumentation_end() do { } while(0)
1738 +#endif
1739 +
1740 #ifndef ASM_UNREACHABLE
1741 # define ASM_UNREACHABLE
1742 #endif
1743 diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
1744 index 77433633572e4..b94d08d055ff5 100644
1745 --- a/include/linux/compiler_types.h
1746 +++ b/include/linux/compiler_types.h
1747 @@ -118,6 +118,10 @@ struct ftrace_likely_data {
1748 #define notrace __attribute__((__no_instrument_function__))
1749 #endif
1750
1751 +/* Section for code which can't be instrumented at all */
1752 +#define noinstr \
1753 + noinline notrace __attribute((__section__(".noinstr.text")))
1754 +
1755 /*
1756 * it doesn't make sense on ARM (currently the only user of __naked)
1757 * to trace naked functions because then mcount is called without
1758 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
1759 index ec3081ab04c01..3e0692fd6282c 100644
1760 --- a/include/linux/netdevice.h
1761 +++ b/include/linux/netdevice.h
1762 @@ -4044,6 +4044,7 @@ static inline void netif_tx_disable(struct net_device *dev)
1763
1764 local_bh_disable();
1765 cpu = smp_processor_id();
1766 + spin_lock(&dev->tx_global_lock);
1767 for (i = 0; i < dev->num_tx_queues; i++) {
1768 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1769
1770 @@ -4051,6 +4052,7 @@ static inline void netif_tx_disable(struct net_device *dev)
1771 netif_tx_stop_queue(txq);
1772 __netif_tx_unlock(txq);
1773 }
1774 + spin_unlock(&dev->tx_global_lock);
1775 local_bh_enable();
1776 }
1777
1778 diff --git a/include/linux/uio.h b/include/linux/uio.h
1779 index ab5f523bc0df9..b74d292b9960e 100644
1780 --- a/include/linux/uio.h
1781 +++ b/include/linux/uio.h
1782 @@ -261,7 +261,13 @@ static inline void iov_iter_reexpand(struct iov_iter *i, size_t count)
1783 {
1784 i->count = count;
1785 }
1786 -size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump, struct iov_iter *i);
1787 +
1788 +struct csum_state {
1789 + __wsum csum;
1790 + size_t off;
1791 +};
1792 +
1793 +size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csstate, struct iov_iter *i);
1794 size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i);
1795 bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i);
1796 size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,
1797 diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
1798 index fe9a9fa2ebc45..14d47ed4114fd 100644
1799 --- a/include/xen/xenbus.h
1800 +++ b/include/xen/xenbus.h
1801 @@ -187,8 +187,6 @@ void xs_suspend_cancel(void);
1802
1803 struct work_struct;
1804
1805 -void xenbus_probe(void);
1806 -
1807 #define XENBUS_IS_ERR_READ(str) ({ \
1808 if (!IS_ERR(str) && strlen(str) == 0) { \
1809 kfree(str); \
1810 diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
1811 index 173e983619d77..fba2ade28fb3a 100644
1812 --- a/kernel/bpf/stackmap.c
1813 +++ b/kernel/bpf/stackmap.c
1814 @@ -112,6 +112,8 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
1815
1816 /* hash table size must be power of 2 */
1817 n_buckets = roundup_pow_of_two(attr->max_entries);
1818 + if (!n_buckets)
1819 + return ERR_PTR(-E2BIG);
1820
1821 cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap);
1822 cost += n_buckets * (value_size + sizeof(struct stack_map_bucket));
1823 diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
1824 index 35faf082a709c..37db8eba149ac 100644
1825 --- a/kernel/cgroup/cgroup.c
1826 +++ b/kernel/cgroup/cgroup.c
1827 @@ -3627,6 +3627,7 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf,
1828 {
1829 struct psi_trigger *new;
1830 struct cgroup *cgrp;
1831 + struct psi_group *psi;
1832
1833 cgrp = cgroup_kn_lock_live(of->kn, false);
1834 if (!cgrp)
1835 @@ -3635,7 +3636,8 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf,
1836 cgroup_get(cgrp);
1837 cgroup_kn_unlock(of->kn);
1838
1839 - new = psi_trigger_create(&cgrp->psi, buf, nbytes, res);
1840 + psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi;
1841 + new = psi_trigger_create(psi, buf, nbytes, res);
1842 if (IS_ERR(new)) {
1843 cgroup_put(cgrp);
1844 return PTR_ERR(new);
1845 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
1846 index 67af28f03cf41..1a75610f5f57b 100644
1847 --- a/kernel/trace/trace.c
1848 +++ b/kernel/trace/trace.c
1849 @@ -2498,7 +2498,7 @@ trace_event_buffer_lock_reserve(struct ring_buffer **current_rb,
1850 (entry = this_cpu_read(trace_buffered_event))) {
1851 /* Try to use the per cpu buffer first */
1852 val = this_cpu_inc_return(trace_buffered_event_cnt);
1853 - if (val == 1) {
1854 + if ((len < (PAGE_SIZE - sizeof(*entry))) && val == 1) {
1855 trace_event_setup(entry, type, flags, pc);
1856 entry->array[0] = len;
1857 return entry;
1858 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
1859 index 309b2b3c5349e..e31ee325dad16 100644
1860 --- a/kernel/trace/trace_events.c
1861 +++ b/kernel/trace/trace_events.c
1862 @@ -1107,7 +1107,8 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
1863 mutex_lock(&event_mutex);
1864 list_for_each_entry(file, &tr->events, list) {
1865 call = file->event_call;
1866 - if (!trace_event_name(call) || !call->class || !call->class->reg)
1867 + if ((call->flags & TRACE_EVENT_FL_IGNORE_ENABLE) ||
1868 + !trace_event_name(call) || !call->class || !call->class->reg)
1869 continue;
1870
1871 if (system && strcmp(call->class->system, system->name) != 0)
1872 diff --git a/lib/iov_iter.c b/lib/iov_iter.c
1873 index 639d5e7014c1e..9ea6f7bb83095 100644
1874 --- a/lib/iov_iter.c
1875 +++ b/lib/iov_iter.c
1876 @@ -570,12 +570,13 @@ static __wsum csum_and_memcpy(void *to, const void *from, size_t len,
1877 }
1878
1879 static size_t csum_and_copy_to_pipe_iter(const void *addr, size_t bytes,
1880 - __wsum *csum, struct iov_iter *i)
1881 + struct csum_state *csstate,
1882 + struct iov_iter *i)
1883 {
1884 struct pipe_inode_info *pipe = i->pipe;
1885 + __wsum sum = csstate->csum;
1886 + size_t off = csstate->off;
1887 size_t n, r;
1888 - size_t off = 0;
1889 - __wsum sum = *csum;
1890 int idx;
1891
1892 if (!sanity(i))
1893 @@ -596,7 +597,8 @@ static size_t csum_and_copy_to_pipe_iter(const void *addr, size_t bytes,
1894 addr += chunk;
1895 }
1896 i->count -= bytes;
1897 - *csum = sum;
1898 + csstate->csum = sum;
1899 + csstate->off = off;
1900 return bytes;
1901 }
1902
1903 @@ -1484,18 +1486,19 @@ bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum,
1904 }
1905 EXPORT_SYMBOL(csum_and_copy_from_iter_full);
1906
1907 -size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump,
1908 +size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *_csstate,
1909 struct iov_iter *i)
1910 {
1911 + struct csum_state *csstate = _csstate;
1912 const char *from = addr;
1913 - __wsum *csum = csump;
1914 __wsum sum, next;
1915 - size_t off = 0;
1916 + size_t off;
1917
1918 if (unlikely(iov_iter_is_pipe(i)))
1919 - return csum_and_copy_to_pipe_iter(addr, bytes, csum, i);
1920 + return csum_and_copy_to_pipe_iter(addr, bytes, _csstate, i);
1921
1922 - sum = *csum;
1923 + sum = csstate->csum;
1924 + off = csstate->off;
1925 if (unlikely(iov_iter_is_discard(i))) {
1926 WARN_ON(1); /* for now */
1927 return 0;
1928 @@ -1524,7 +1527,8 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump,
1929 off += v.iov_len;
1930 })
1931 )
1932 - *csum = sum;
1933 + csstate->csum = sum;
1934 + csstate->off = off;
1935 return bytes;
1936 }
1937 EXPORT_SYMBOL(csum_and_copy_to_iter);
1938 diff --git a/net/core/datagram.c b/net/core/datagram.c
1939 index 189ad4c73a3fe..b0488f30f2c4e 100644
1940 --- a/net/core/datagram.c
1941 +++ b/net/core/datagram.c
1942 @@ -700,8 +700,16 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset,
1943 struct iov_iter *to, int len,
1944 __wsum *csump)
1945 {
1946 - return __skb_datagram_iter(skb, offset, to, len, true,
1947 - csum_and_copy_to_iter, csump);
1948 + struct csum_state csdata = { .csum = *csump };
1949 + int ret;
1950 +
1951 + ret = __skb_datagram_iter(skb, offset, to, len, true,
1952 + csum_and_copy_to_iter, &csdata);
1953 + if (ret)
1954 + return ret;
1955 +
1956 + *csump = csdata.csum;
1957 + return 0;
1958 }
1959
1960 /**
1961 diff --git a/net/core/dev.c b/net/core/dev.c
1962 index ec66d13d2bdad..d90e8bd87df83 100644
1963 --- a/net/core/dev.c
1964 +++ b/net/core/dev.c
1965 @@ -5275,10 +5275,11 @@ static void gro_normal_list(struct napi_struct *napi)
1966 /* Queue one GRO_NORMAL SKB up for list processing. If batch size exceeded,
1967 * pass the whole batch up to the stack.
1968 */
1969 -static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb)
1970 +static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb, int segs)
1971 {
1972 list_add_tail(&skb->list, &napi->rx_list);
1973 - if (++napi->rx_count >= gro_normal_batch)
1974 + napi->rx_count += segs;
1975 + if (napi->rx_count >= gro_normal_batch)
1976 gro_normal_list(napi);
1977 }
1978
1979 @@ -5317,7 +5318,7 @@ static int napi_gro_complete(struct napi_struct *napi, struct sk_buff *skb)
1980 }
1981
1982 out:
1983 - gro_normal_one(napi, skb);
1984 + gro_normal_one(napi, skb, NAPI_GRO_CB(skb)->count);
1985 return NET_RX_SUCCESS;
1986 }
1987
1988 @@ -5608,7 +5609,7 @@ static gro_result_t napi_skb_finish(struct napi_struct *napi,
1989 {
1990 switch (ret) {
1991 case GRO_NORMAL:
1992 - gro_normal_one(napi, skb);
1993 + gro_normal_one(napi, skb, 1);
1994 break;
1995
1996 case GRO_DROP:
1997 @@ -5696,7 +5697,7 @@ static gro_result_t napi_frags_finish(struct napi_struct *napi,
1998 __skb_push(skb, ETH_HLEN);
1999 skb->protocol = eth_type_trans(skb, skb->dev);
2000 if (ret == GRO_NORMAL)
2001 - gro_normal_one(napi, skb);
2002 + gro_normal_one(napi, skb, 1);
2003 break;
2004
2005 case GRO_DROP:
2006 diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
2007 index 0f7f38c295799..70e6fc2edd304 100644
2008 --- a/net/dsa/dsa2.c
2009 +++ b/net/dsa/dsa2.c
2010 @@ -399,18 +399,21 @@ static int dsa_switch_setup(struct dsa_switch *ds)
2011 ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
2012 if (!ds->slave_mii_bus) {
2013 err = -ENOMEM;
2014 - goto unregister_notifier;
2015 + goto teardown;
2016 }
2017
2018 dsa_slave_mii_bus_init(ds);
2019
2020 err = mdiobus_register(ds->slave_mii_bus);
2021 if (err < 0)
2022 - goto unregister_notifier;
2023 + goto teardown;
2024 }
2025
2026 return 0;
2027
2028 +teardown:
2029 + if (ds->ops->teardown)
2030 + ds->ops->teardown(ds);
2031 unregister_notifier:
2032 dsa_switch_unregister_notifier(ds);
2033 unregister_devlink:
2034 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
2035 index 200cdad3ff3ab..9a40312b1f161 100644
2036 --- a/net/netfilter/nf_conntrack_core.c
2037 +++ b/net/netfilter/nf_conntrack_core.c
2038 @@ -1091,7 +1091,8 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
2039 * Let nf_ct_resolve_clash() deal with this later.
2040 */
2041 if (nf_ct_tuple_equal(&ignored_conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
2042 - &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple))
2043 + &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple) &&
2044 + nf_ct_zone_equal(ct, zone, IP_CT_DIR_ORIGINAL))
2045 continue;
2046
2047 NF_CT_STAT_INC_ATOMIC(net, found);
2048 diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
2049 index 128245efe84ab..e05e5df803d68 100644
2050 --- a/net/netfilter/nf_flow_table_core.c
2051 +++ b/net/netfilter/nf_flow_table_core.c
2052 @@ -354,7 +354,7 @@ static int nf_flow_nat_port_tcp(struct sk_buff *skb, unsigned int thoff,
2053 return -1;
2054
2055 tcph = (void *)(skb_network_header(skb) + thoff);
2056 - inet_proto_csum_replace2(&tcph->check, skb, port, new_port, true);
2057 + inet_proto_csum_replace2(&tcph->check, skb, port, new_port, false);
2058
2059 return 0;
2060 }
2061 @@ -371,7 +371,7 @@ static int nf_flow_nat_port_udp(struct sk_buff *skb, unsigned int thoff,
2062 udph = (void *)(skb_network_header(skb) + thoff);
2063 if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) {
2064 inet_proto_csum_replace2(&udph->check, skb, port,
2065 - new_port, true);
2066 + new_port, false);
2067 if (!udph->check)
2068 udph->check = CSUM_MANGLED_0;
2069 }
2070 diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
2071 index 40216c2a7dd72..373ea0e49f12d 100644
2072 --- a/net/netfilter/nf_tables_api.c
2073 +++ b/net/netfilter/nf_tables_api.c
2074 @@ -7696,6 +7696,17 @@ int __nft_release_basechain(struct nft_ctx *ctx)
2075 }
2076 EXPORT_SYMBOL_GPL(__nft_release_basechain);
2077
2078 +static void __nft_release_hooks(struct net *net)
2079 +{
2080 + struct nft_table *table;
2081 + struct nft_chain *chain;
2082 +
2083 + list_for_each_entry(table, &net->nft.tables, list) {
2084 + list_for_each_entry(chain, &table->chains, list)
2085 + nf_tables_unregister_hook(net, table, chain);
2086 + }
2087 +}
2088 +
2089 static void __nft_release_tables(struct net *net)
2090 {
2091 struct nft_flowtable *flowtable, *nf;
2092 @@ -7711,10 +7722,6 @@ static void __nft_release_tables(struct net *net)
2093
2094 list_for_each_entry_safe(table, nt, &net->nft.tables, list) {
2095 ctx.family = table->family;
2096 -
2097 - list_for_each_entry(chain, &table->chains, list)
2098 - nf_tables_unregister_hook(net, table, chain);
2099 - /* No packets are walking on these chains anymore. */
2100 ctx.table = table;
2101 list_for_each_entry(chain, &table->chains, list) {
2102 ctx.chain = chain;
2103 @@ -7762,6 +7769,11 @@ static int __net_init nf_tables_init_net(struct net *net)
2104 return 0;
2105 }
2106
2107 +static void __net_exit nf_tables_pre_exit_net(struct net *net)
2108 +{
2109 + __nft_release_hooks(net);
2110 +}
2111 +
2112 static void __net_exit nf_tables_exit_net(struct net *net)
2113 {
2114 mutex_lock(&net->nft.commit_mutex);
2115 @@ -7774,8 +7786,9 @@ static void __net_exit nf_tables_exit_net(struct net *net)
2116 }
2117
2118 static struct pernet_operations nf_tables_net_ops = {
2119 - .init = nf_tables_init_net,
2120 - .exit = nf_tables_exit_net,
2121 + .init = nf_tables_init_net,
2122 + .pre_exit = nf_tables_pre_exit_net,
2123 + .exit = nf_tables_exit_net,
2124 };
2125
2126 static int __init nf_tables_module_init(void)
2127 diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
2128 index 6c2582a197667..3469b60736103 100644
2129 --- a/net/netfilter/xt_recent.c
2130 +++ b/net/netfilter/xt_recent.c
2131 @@ -152,7 +152,8 @@ static void recent_entry_remove(struct recent_table *t, struct recent_entry *e)
2132 /*
2133 * Drop entries with timestamps older then 'time'.
2134 */
2135 -static void recent_entry_reap(struct recent_table *t, unsigned long time)
2136 +static void recent_entry_reap(struct recent_table *t, unsigned long time,
2137 + struct recent_entry *working, bool update)
2138 {
2139 struct recent_entry *e;
2140
2141 @@ -161,6 +162,12 @@ static void recent_entry_reap(struct recent_table *t, unsigned long time)
2142 */
2143 e = list_entry(t->lru_list.next, struct recent_entry, lru_list);
2144
2145 + /*
2146 + * Do not reap the entry which are going to be updated.
2147 + */
2148 + if (e == working && update)
2149 + return;
2150 +
2151 /*
2152 * The last time stamp is the most recent.
2153 */
2154 @@ -303,7 +310,8 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par)
2155
2156 /* info->seconds must be non-zero */
2157 if (info->check_set & XT_RECENT_REAP)
2158 - recent_entry_reap(t, time);
2159 + recent_entry_reap(t, time, e,
2160 + info->check_set & XT_RECENT_UPDATE && ret);
2161 }
2162
2163 if (info->check_set & XT_RECENT_SET ||
2164 diff --git a/net/qrtr/tun.c b/net/qrtr/tun.c
2165 index e35869e81766e..997af345ce374 100644
2166 --- a/net/qrtr/tun.c
2167 +++ b/net/qrtr/tun.c
2168 @@ -80,6 +80,12 @@ static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from)
2169 ssize_t ret;
2170 void *kbuf;
2171
2172 + if (!len)
2173 + return -EINVAL;
2174 +
2175 + if (len > KMALLOC_MAX_SIZE)
2176 + return -ENOMEM;
2177 +
2178 kbuf = kzalloc(len, GFP_KERNEL);
2179 if (!kbuf)
2180 return -ENOMEM;
2181 diff --git a/net/rds/rdma.c b/net/rds/rdma.c
2182 index 8e10f954a22fe..1c42a600fe7fa 100644
2183 --- a/net/rds/rdma.c
2184 +++ b/net/rds/rdma.c
2185 @@ -532,6 +532,9 @@ int rds_rdma_extra_size(struct rds_rdma_args *args,
2186 if (args->nr_local == 0)
2187 return -EINVAL;
2188
2189 + if (args->nr_local > UIO_MAXIOV)
2190 + return -EMSGSIZE;
2191 +
2192 iov->iov = kcalloc(args->nr_local,
2193 sizeof(struct rds_iovec),
2194 GFP_KERNEL);
2195 diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c
2196 index 38a46167523fa..f8233bc76c0ea 100644
2197 --- a/net/rxrpc/call_object.c
2198 +++ b/net/rxrpc/call_object.c
2199 @@ -507,8 +507,6 @@ void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call)
2200 rxrpc_disconnect_call(call);
2201 if (call->security)
2202 call->security->free_call_crypto(call);
2203 -
2204 - rxrpc_cleanup_ring(call);
2205 _leave("");
2206 }
2207
2208 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
2209 index f7da88ae20a57..982a87b3e11f8 100644
2210 --- a/net/sctp/proc.c
2211 +++ b/net/sctp/proc.c
2212 @@ -215,6 +215,12 @@ static void sctp_transport_seq_stop(struct seq_file *seq, void *v)
2213 {
2214 struct sctp_ht_iter *iter = seq->private;
2215
2216 + if (v && v != SEQ_START_TOKEN) {
2217 + struct sctp_transport *transport = v;
2218 +
2219 + sctp_transport_put(transport);
2220 + }
2221 +
2222 sctp_transport_walk_stop(&iter->hti);
2223 }
2224
2225 @@ -222,6 +228,12 @@ static void *sctp_transport_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2226 {
2227 struct sctp_ht_iter *iter = seq->private;
2228
2229 + if (v && v != SEQ_START_TOKEN) {
2230 + struct sctp_transport *transport = v;
2231 +
2232 + sctp_transport_put(transport);
2233 + }
2234 +
2235 ++*pos;
2236
2237 return sctp_transport_get_next(seq_file_net(seq), &iter->hti);
2238 @@ -277,8 +289,6 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
2239 sk->sk_rcvbuf);
2240 seq_printf(seq, "\n");
2241
2242 - sctp_transport_put(transport);
2243 -
2244 return 0;
2245 }
2246
2247 @@ -354,8 +364,6 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
2248 seq_printf(seq, "\n");
2249 }
2250
2251 - sctp_transport_put(transport);
2252 -
2253 return 0;
2254 }
2255
2256 diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
2257 index 3a074a03d3820..5d323574d04fe 100644
2258 --- a/net/vmw_vsock/af_vsock.c
2259 +++ b/net/vmw_vsock/af_vsock.c
2260 @@ -808,10 +808,12 @@ static int vsock_shutdown(struct socket *sock, int mode)
2261 */
2262
2263 sk = sock->sk;
2264 +
2265 + lock_sock(sk);
2266 if (sock->state == SS_UNCONNECTED) {
2267 err = -ENOTCONN;
2268 if (sk->sk_type == SOCK_STREAM)
2269 - return err;
2270 + goto out;
2271 } else {
2272 sock->state = SS_DISCONNECTING;
2273 err = 0;
2274 @@ -820,10 +822,8 @@ static int vsock_shutdown(struct socket *sock, int mode)
2275 /* Receive and send shutdowns are treated alike. */
2276 mode = mode & (RCV_SHUTDOWN | SEND_SHUTDOWN);
2277 if (mode) {
2278 - lock_sock(sk);
2279 sk->sk_shutdown |= mode;
2280 sk->sk_state_change(sk);
2281 - release_sock(sk);
2282
2283 if (sk->sk_type == SOCK_STREAM) {
2284 sock_reset_flag(sk, SOCK_DONE);
2285 @@ -831,6 +831,8 @@ static int vsock_shutdown(struct socket *sock, int mode)
2286 }
2287 }
2288
2289 +out:
2290 + release_sock(sk);
2291 return err;
2292 }
2293
2294 @@ -1099,7 +1101,6 @@ static void vsock_connect_timeout(struct work_struct *work)
2295 {
2296 struct sock *sk;
2297 struct vsock_sock *vsk;
2298 - int cancel = 0;
2299
2300 vsk = container_of(work, struct vsock_sock, connect_work.work);
2301 sk = sk_vsock(vsk);
2302 @@ -1110,11 +1111,9 @@ static void vsock_connect_timeout(struct work_struct *work)
2303 sk->sk_state = TCP_CLOSE;
2304 sk->sk_err = ETIMEDOUT;
2305 sk->sk_error_report(sk);
2306 - cancel = 1;
2307 + vsock_transport_cancel_pkt(vsk);
2308 }
2309 release_sock(sk);
2310 - if (cancel)
2311 - vsock_transport_cancel_pkt(vsk);
2312
2313 sock_put(sk);
2314 }
2315 diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
2316 index 463cefc1e5ae2..a3c57c048cbd8 100644
2317 --- a/net/vmw_vsock/hyperv_transport.c
2318 +++ b/net/vmw_vsock/hyperv_transport.c
2319 @@ -464,14 +464,10 @@ static void hvs_shutdown_lock_held(struct hvsock *hvs, int mode)
2320
2321 static int hvs_shutdown(struct vsock_sock *vsk, int mode)
2322 {
2323 - struct sock *sk = sk_vsock(vsk);
2324 -
2325 if (!(mode & SEND_SHUTDOWN))
2326 return 0;
2327
2328 - lock_sock(sk);
2329 hvs_shutdown_lock_held(vsk->trans, mode);
2330 - release_sock(sk);
2331 return 0;
2332 }
2333
2334 diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
2335 index efbb521bff135..dde16a033a09d 100644
2336 --- a/net/vmw_vsock/virtio_transport_common.c
2337 +++ b/net/vmw_vsock/virtio_transport_common.c
2338 @@ -1100,10 +1100,10 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
2339
2340 vsk = vsock_sk(sk);
2341
2342 - space_available = virtio_transport_space_update(sk, pkt);
2343 -
2344 lock_sock(sk);
2345
2346 + space_available = virtio_transport_space_update(sk, pkt);
2347 +
2348 /* Update CID in case it has changed after a transport reset event */
2349 vsk->local_addr.svm_cid = dst.svm_cid;
2350
2351 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
2352 index 52f1152c98389..13cda6aa26880 100644
2353 --- a/scripts/mod/modpost.c
2354 +++ b/scripts/mod/modpost.c
2355 @@ -960,7 +960,7 @@ static void check_section(const char *modname, struct elf_info *elf,
2356
2357 #define DATA_SECTIONS ".data", ".data.rel"
2358 #define TEXT_SECTIONS ".text", ".text.unlikely", ".sched.text", \
2359 - ".kprobes.text", ".cpuidle.text"
2360 + ".kprobes.text", ".cpuidle.text", ".noinstr.text"
2361 #define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \
2362 ".fixup", ".entry.text", ".exception.text", ".text.*", \
2363 ".coldtext"
2364 diff --git a/security/commoncap.c b/security/commoncap.c
2365 index 0ca31c8bc0b13..28a6939bcc4e5 100644
2366 --- a/security/commoncap.c
2367 +++ b/security/commoncap.c
2368 @@ -371,10 +371,11 @@ int cap_inode_getsecurity(struct inode *inode, const char *name, void **buffer,
2369 {
2370 int size, ret;
2371 kuid_t kroot;
2372 + u32 nsmagic, magic;
2373 uid_t root, mappedroot;
2374 char *tmpbuf = NULL;
2375 struct vfs_cap_data *cap;
2376 - struct vfs_ns_cap_data *nscap;
2377 + struct vfs_ns_cap_data *nscap = NULL;
2378 struct dentry *dentry;
2379 struct user_namespace *fs_ns;
2380
2381 @@ -396,46 +397,61 @@ int cap_inode_getsecurity(struct inode *inode, const char *name, void **buffer,
2382 fs_ns = inode->i_sb->s_user_ns;
2383 cap = (struct vfs_cap_data *) tmpbuf;
2384 if (is_v2header((size_t) ret, cap)) {
2385 - /* If this is sizeof(vfs_cap_data) then we're ok with the
2386 - * on-disk value, so return that. */
2387 - if (alloc)
2388 - *buffer = tmpbuf;
2389 - else
2390 - kfree(tmpbuf);
2391 - return ret;
2392 - } else if (!is_v3header((size_t) ret, cap)) {
2393 - kfree(tmpbuf);
2394 - return -EINVAL;
2395 + root = 0;
2396 + } else if (is_v3header((size_t) ret, cap)) {
2397 + nscap = (struct vfs_ns_cap_data *) tmpbuf;
2398 + root = le32_to_cpu(nscap->rootid);
2399 + } else {
2400 + size = -EINVAL;
2401 + goto out_free;
2402 }
2403
2404 - nscap = (struct vfs_ns_cap_data *) tmpbuf;
2405 - root = le32_to_cpu(nscap->rootid);
2406 kroot = make_kuid(fs_ns, root);
2407
2408 /* If the root kuid maps to a valid uid in current ns, then return
2409 * this as a nscap. */
2410 mappedroot = from_kuid(current_user_ns(), kroot);
2411 if (mappedroot != (uid_t)-1 && mappedroot != (uid_t)0) {
2412 + size = sizeof(struct vfs_ns_cap_data);
2413 if (alloc) {
2414 - *buffer = tmpbuf;
2415 + if (!nscap) {
2416 + /* v2 -> v3 conversion */
2417 + nscap = kzalloc(size, GFP_ATOMIC);
2418 + if (!nscap) {
2419 + size = -ENOMEM;
2420 + goto out_free;
2421 + }
2422 + nsmagic = VFS_CAP_REVISION_3;
2423 + magic = le32_to_cpu(cap->magic_etc);
2424 + if (magic & VFS_CAP_FLAGS_EFFECTIVE)
2425 + nsmagic |= VFS_CAP_FLAGS_EFFECTIVE;
2426 + memcpy(&nscap->data, &cap->data, sizeof(__le32) * 2 * VFS_CAP_U32);
2427 + nscap->magic_etc = cpu_to_le32(nsmagic);
2428 + } else {
2429 + /* use allocated v3 buffer */
2430 + tmpbuf = NULL;
2431 + }
2432 nscap->rootid = cpu_to_le32(mappedroot);
2433 - } else
2434 - kfree(tmpbuf);
2435 - return size;
2436 + *buffer = nscap;
2437 + }
2438 + goto out_free;
2439 }
2440
2441 if (!rootid_owns_currentns(kroot)) {
2442 - kfree(tmpbuf);
2443 - return -EOPNOTSUPP;
2444 + size = -EOVERFLOW;
2445 + goto out_free;
2446 }
2447
2448 /* This comes from a parent namespace. Return as a v2 capability */
2449 size = sizeof(struct vfs_cap_data);
2450 if (alloc) {
2451 - *buffer = kmalloc(size, GFP_ATOMIC);
2452 - if (*buffer) {
2453 - struct vfs_cap_data *cap = *buffer;
2454 - __le32 nsmagic, magic;
2455 + if (nscap) {
2456 + /* v3 -> v2 conversion */
2457 + cap = kzalloc(size, GFP_ATOMIC);
2458 + if (!cap) {
2459 + size = -ENOMEM;
2460 + goto out_free;
2461 + }
2462 magic = VFS_CAP_REVISION_2;
2463 nsmagic = le32_to_cpu(nscap->magic_etc);
2464 if (nsmagic & VFS_CAP_FLAGS_EFFECTIVE)
2465 @@ -443,9 +459,12 @@ int cap_inode_getsecurity(struct inode *inode, const char *name, void **buffer,
2466 memcpy(&cap->data, &nscap->data, sizeof(__le32) * 2 * VFS_CAP_U32);
2467 cap->magic_etc = cpu_to_le32(magic);
2468 } else {
2469 - size = -ENOMEM;
2470 + /* use unconverted v2 */
2471 + tmpbuf = NULL;
2472 }
2473 + *buffer = cap;
2474 }
2475 +out_free:
2476 kfree(tmpbuf);
2477 return size;
2478 }
2479 diff --git a/tools/testing/selftests/networking/timestamping/txtimestamp.c b/tools/testing/selftests/networking/timestamping/txtimestamp.c
2480 index 7e386be471201..2fce2e8f47f55 100644
2481 --- a/tools/testing/selftests/networking/timestamping/txtimestamp.c
2482 +++ b/tools/testing/selftests/networking/timestamping/txtimestamp.c
2483 @@ -26,6 +26,7 @@
2484 #include <inttypes.h>
2485 #include <linux/errqueue.h>
2486 #include <linux/if_ether.h>
2487 +#include <linux/if_packet.h>
2488 #include <linux/ipv6.h>
2489 #include <linux/net_tstamp.h>
2490 #include <netdb.h>
2491 @@ -34,7 +35,6 @@
2492 #include <netinet/ip.h>
2493 #include <netinet/udp.h>
2494 #include <netinet/tcp.h>
2495 -#include <netpacket/packet.h>
2496 #include <poll.h>
2497 #include <stdarg.h>
2498 #include <stdbool.h>
2499 @@ -396,12 +396,12 @@ static void do_test(int family, unsigned int report_opt)
2500 total_len = cfg_payload_len;
2501 if (cfg_use_pf_packet || cfg_proto == SOCK_RAW) {
2502 total_len += sizeof(struct udphdr);
2503 - if (cfg_use_pf_packet || cfg_ipproto == IPPROTO_RAW)
2504 + if (cfg_use_pf_packet || cfg_ipproto == IPPROTO_RAW) {
2505 if (family == PF_INET)
2506 total_len += sizeof(struct iphdr);
2507 else
2508 total_len += sizeof(struct ipv6hdr);
2509 -
2510 + }
2511 /* special case, only rawv6_sendmsg:
2512 * pass proto in sin6_port if not connected
2513 * also see ANK comment in net/ipv4/raw.c