Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0224-5.4.125-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: 96602 byte(s)
-sync kernel patches
1 diff --git a/Documentation/core-api/xarray.rst b/Documentation/core-api/xarray.rst
2 index fcedc5349ace4..2ad3c1fce5795 100644
3 --- a/Documentation/core-api/xarray.rst
4 +++ b/Documentation/core-api/xarray.rst
5 @@ -461,13 +461,15 @@ or iterations will move the index to the first index in the range.
6 Each entry will only be returned once, no matter how many indices it
7 occupies.
8
9 -Using xas_next() or xas_prev() with a multi-index xa_state
10 -is not supported. Using either of these functions on a multi-index entry
11 -will reveal sibling entries; these should be skipped over by the caller.
12 -
13 -Storing ``NULL`` into any index of a multi-index entry will set the entry
14 -at every index to ``NULL`` and dissolve the tie. Splitting a multi-index
15 -entry into entries occupying smaller ranges is not yet supported.
16 +Using xas_next() or xas_prev() with a multi-index xa_state is not
17 +supported. Using either of these functions on a multi-index entry will
18 +reveal sibling entries; these should be skipped over by the caller.
19 +
20 +Storing ``NULL`` into any index of a multi-index entry will set the
21 +entry at every index to ``NULL`` and dissolve the tie. A multi-index
22 +entry can be split into entries occupying smaller ranges by calling
23 +xas_split_alloc() without the xa_lock held, followed by taking the lock
24 +and calling xas_split().
25
26 Functions and structures
27 ========================
28 diff --git a/Makefile b/Makefile
29 index 22668742d3d04..43e7b07eea80e 100644
30 --- a/Makefile
31 +++ b/Makefile
32 @@ -1,7 +1,7 @@
33 # SPDX-License-Identifier: GPL-2.0
34 VERSION = 5
35 PATCHLEVEL = 4
36 -SUBLEVEL = 124
37 +SUBLEVEL = 125
38 EXTRAVERSION =
39 NAME = Kleptomaniac Octopus
40
41 diff --git a/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi b/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi
42 index e8d800fec6379..ce4a5a8074422 100644
43 --- a/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi
44 +++ b/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi
45 @@ -99,9 +99,13 @@
46 phy-reset-gpios = <&gpio1 25 GPIO_ACTIVE_LOW>;
47 phy-reset-duration = <20>;
48 phy-supply = <&sw2_reg>;
49 - phy-handle = <&ethphy0>;
50 status = "okay";
51
52 + fixed-link {
53 + speed = <1000>;
54 + full-duplex;
55 + };
56 +
57 mdio {
58 #address-cells = <1>;
59 #size-cells = <0>;
60 diff --git a/arch/arm/boot/dts/imx6q-dhcom-som.dtsi b/arch/arm/boot/dts/imx6q-dhcom-som.dtsi
61 index 08a2e17e0539b..621894d13dcbc 100644
62 --- a/arch/arm/boot/dts/imx6q-dhcom-som.dtsi
63 +++ b/arch/arm/boot/dts/imx6q-dhcom-som.dtsi
64 @@ -408,6 +408,18 @@
65 vin-supply = <&sw1_reg>;
66 };
67
68 +&reg_pu {
69 + vin-supply = <&sw1_reg>;
70 +};
71 +
72 +&reg_vdd1p1 {
73 + vin-supply = <&sw2_reg>;
74 +};
75 +
76 +&reg_vdd2p5 {
77 + vin-supply = <&sw2_reg>;
78 +};
79 +
80 &uart1 {
81 pinctrl-names = "default";
82 pinctrl-0 = <&pinctrl_uart1>;
83 diff --git a/arch/arm/boot/dts/imx6qdl-emcon-avari.dtsi b/arch/arm/boot/dts/imx6qdl-emcon-avari.dtsi
84 index 828cf3e39784a..c4e146f3341bb 100644
85 --- a/arch/arm/boot/dts/imx6qdl-emcon-avari.dtsi
86 +++ b/arch/arm/boot/dts/imx6qdl-emcon-avari.dtsi
87 @@ -126,7 +126,7 @@
88 compatible = "nxp,pca8574";
89 reg = <0x3a>;
90 gpio-controller;
91 - #gpio-cells = <1>;
92 + #gpio-cells = <2>;
93 };
94 };
95
96 diff --git a/arch/arm/boot/dts/imx7d-meerkat96.dts b/arch/arm/boot/dts/imx7d-meerkat96.dts
97 index 5339210b63d0f..dd8003bd1fc09 100644
98 --- a/arch/arm/boot/dts/imx7d-meerkat96.dts
99 +++ b/arch/arm/boot/dts/imx7d-meerkat96.dts
100 @@ -193,7 +193,7 @@
101 pinctrl-names = "default";
102 pinctrl-0 = <&pinctrl_usdhc1>;
103 keep-power-in-suspend;
104 - tuning-step = <2>;
105 + fsl,tuning-step = <2>;
106 vmmc-supply = <&reg_3p3v>;
107 no-1-8-v;
108 broken-cd;
109 diff --git a/arch/arm/boot/dts/imx7d-pico.dtsi b/arch/arm/boot/dts/imx7d-pico.dtsi
110 index 6f50ebf31a0ab..8a8df54ff5639 100644
111 --- a/arch/arm/boot/dts/imx7d-pico.dtsi
112 +++ b/arch/arm/boot/dts/imx7d-pico.dtsi
113 @@ -307,7 +307,7 @@
114 pinctrl-2 = <&pinctrl_usdhc1_200mhz>;
115 cd-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
116 bus-width = <4>;
117 - tuning-step = <2>;
118 + fsl,tuning-step = <2>;
119 vmmc-supply = <&reg_3p3v>;
120 wakeup-source;
121 no-1-8-v;
122 diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
123 index bd99fa68b7630..5a2a188debd1d 100644
124 --- a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
125 +++ b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
126 @@ -151,8 +151,8 @@
127 ddr: memory-controller@1080000 {
128 compatible = "fsl,qoriq-memory-controller";
129 reg = <0x0 0x1080000 0x0 0x1000>;
130 - interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>;
131 - big-endian;
132 + interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
133 + little-endian;
134 };
135
136 dcfg: syscon@1e00000 {
137 diff --git a/arch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi b/arch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi
138 index 32ce14936b013..f385b143b3086 100644
139 --- a/arch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi
140 +++ b/arch/arm64/boot/dts/freescale/imx8mq-zii-ultra.dtsi
141 @@ -45,8 +45,8 @@
142 reg_12p0_main: regulator-12p0-main {
143 compatible = "regulator-fixed";
144 regulator-name = "12V_MAIN";
145 - regulator-min-microvolt = <5000000>;
146 - regulator-max-microvolt = <5000000>;
147 + regulator-min-microvolt = <12000000>;
148 + regulator-max-microvolt = <12000000>;
149 regulator-always-on;
150 };
151
152 diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
153 index 98a177dd1f89f..da649e90240c8 100644
154 --- a/arch/arm64/kvm/sys_regs.c
155 +++ b/arch/arm64/kvm/sys_regs.c
156 @@ -432,14 +432,14 @@ static bool trap_bvr(struct kvm_vcpu *vcpu,
157 struct sys_reg_params *p,
158 const struct sys_reg_desc *rd)
159 {
160 - u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
161 + u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm];
162
163 if (p->is_write)
164 reg_to_dbg(vcpu, p, dbg_reg);
165 else
166 dbg_to_reg(vcpu, p, dbg_reg);
167
168 - trace_trap_reg(__func__, rd->reg, p->is_write, *dbg_reg);
169 + trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);
170
171 return true;
172 }
173 @@ -447,7 +447,7 @@ static bool trap_bvr(struct kvm_vcpu *vcpu,
174 static int set_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
175 const struct kvm_one_reg *reg, void __user *uaddr)
176 {
177 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
178 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm];
179
180 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
181 return -EFAULT;
182 @@ -457,7 +457,7 @@ static int set_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
183 static int get_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
184 const struct kvm_one_reg *reg, void __user *uaddr)
185 {
186 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
187 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm];
188
189 if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
190 return -EFAULT;
191 @@ -467,21 +467,21 @@ static int get_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
192 static void reset_bvr(struct kvm_vcpu *vcpu,
193 const struct sys_reg_desc *rd)
194 {
195 - vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg] = rd->val;
196 + vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm] = rd->val;
197 }
198
199 static bool trap_bcr(struct kvm_vcpu *vcpu,
200 struct sys_reg_params *p,
201 const struct sys_reg_desc *rd)
202 {
203 - u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg];
204 + u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm];
205
206 if (p->is_write)
207 reg_to_dbg(vcpu, p, dbg_reg);
208 else
209 dbg_to_reg(vcpu, p, dbg_reg);
210
211 - trace_trap_reg(__func__, rd->reg, p->is_write, *dbg_reg);
212 + trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);
213
214 return true;
215 }
216 @@ -489,7 +489,7 @@ static bool trap_bcr(struct kvm_vcpu *vcpu,
217 static int set_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
218 const struct kvm_one_reg *reg, void __user *uaddr)
219 {
220 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg];
221 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm];
222
223 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
224 return -EFAULT;
225 @@ -500,7 +500,7 @@ static int set_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
226 static int get_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
227 const struct kvm_one_reg *reg, void __user *uaddr)
228 {
229 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg];
230 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm];
231
232 if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
233 return -EFAULT;
234 @@ -510,22 +510,22 @@ static int get_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
235 static void reset_bcr(struct kvm_vcpu *vcpu,
236 const struct sys_reg_desc *rd)
237 {
238 - vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg] = rd->val;
239 + vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm] = rd->val;
240 }
241
242 static bool trap_wvr(struct kvm_vcpu *vcpu,
243 struct sys_reg_params *p,
244 const struct sys_reg_desc *rd)
245 {
246 - u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg];
247 + u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm];
248
249 if (p->is_write)
250 reg_to_dbg(vcpu, p, dbg_reg);
251 else
252 dbg_to_reg(vcpu, p, dbg_reg);
253
254 - trace_trap_reg(__func__, rd->reg, p->is_write,
255 - vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg]);
256 + trace_trap_reg(__func__, rd->CRm, p->is_write,
257 + vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm]);
258
259 return true;
260 }
261 @@ -533,7 +533,7 @@ static bool trap_wvr(struct kvm_vcpu *vcpu,
262 static int set_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
263 const struct kvm_one_reg *reg, void __user *uaddr)
264 {
265 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg];
266 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm];
267
268 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
269 return -EFAULT;
270 @@ -543,7 +543,7 @@ static int set_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
271 static int get_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
272 const struct kvm_one_reg *reg, void __user *uaddr)
273 {
274 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg];
275 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm];
276
277 if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
278 return -EFAULT;
279 @@ -553,21 +553,21 @@ static int get_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
280 static void reset_wvr(struct kvm_vcpu *vcpu,
281 const struct sys_reg_desc *rd)
282 {
283 - vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg] = rd->val;
284 + vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm] = rd->val;
285 }
286
287 static bool trap_wcr(struct kvm_vcpu *vcpu,
288 struct sys_reg_params *p,
289 const struct sys_reg_desc *rd)
290 {
291 - u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg];
292 + u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm];
293
294 if (p->is_write)
295 reg_to_dbg(vcpu, p, dbg_reg);
296 else
297 dbg_to_reg(vcpu, p, dbg_reg);
298
299 - trace_trap_reg(__func__, rd->reg, p->is_write, *dbg_reg);
300 + trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);
301
302 return true;
303 }
304 @@ -575,7 +575,7 @@ static bool trap_wcr(struct kvm_vcpu *vcpu,
305 static int set_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
306 const struct kvm_one_reg *reg, void __user *uaddr)
307 {
308 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg];
309 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm];
310
311 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
312 return -EFAULT;
313 @@ -585,7 +585,7 @@ static int set_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
314 static int get_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
315 const struct kvm_one_reg *reg, void __user *uaddr)
316 {
317 - __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg];
318 + __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm];
319
320 if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
321 return -EFAULT;
322 @@ -595,7 +595,7 @@ static int get_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
323 static void reset_wcr(struct kvm_vcpu *vcpu,
324 const struct sys_reg_desc *rd)
325 {
326 - vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg] = rd->val;
327 + vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm] = rd->val;
328 }
329
330 static void reset_amair_el1(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
331 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
332 index 5bef1575708dc..a49b1aeb2147b 100644
333 --- a/arch/x86/include/asm/apic.h
334 +++ b/arch/x86/include/asm/apic.h
335 @@ -174,6 +174,7 @@ static inline int apic_is_clustered_box(void)
336 extern int setup_APIC_eilvt(u8 lvt_off, u8 vector, u8 msg_type, u8 mask);
337 extern void lapic_assign_system_vectors(void);
338 extern void lapic_assign_legacy_vector(unsigned int isairq, bool replace);
339 +extern void lapic_update_legacy_vectors(void);
340 extern void lapic_online(void);
341 extern void lapic_offline(void);
342 extern bool apic_needs_pit(void);
343 diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
344 index 9b4df6eaa11a6..f913f62eb6c35 100644
345 --- a/arch/x86/include/asm/kvm_para.h
346 +++ b/arch/x86/include/asm/kvm_para.h
347 @@ -6,8 +6,6 @@
348 #include <asm/alternative.h>
349 #include <uapi/asm/kvm_para.h>
350
351 -extern void kvmclock_init(void);
352 -
353 #ifdef CONFIG_KVM_GUEST
354 bool kvm_check_and_clear_guest_paused(void);
355 #else
356 @@ -85,13 +83,14 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
357 }
358
359 #ifdef CONFIG_KVM_GUEST
360 +void kvmclock_init(void);
361 +void kvmclock_disable(void);
362 bool kvm_para_available(void);
363 unsigned int kvm_arch_para_features(void);
364 unsigned int kvm_arch_para_hints(void);
365 void kvm_async_pf_task_wait(u32 token, int interrupt_kernel);
366 void kvm_async_pf_task_wake(u32 token);
367 u32 kvm_read_and_reset_pf_reason(void);
368 -extern void kvm_disable_steal_time(void);
369 void do_async_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
370
371 #ifdef CONFIG_PARAVIRT_SPINLOCKS
372 @@ -125,11 +124,6 @@ static inline u32 kvm_read_and_reset_pf_reason(void)
373 {
374 return 0;
375 }
376 -
377 -static inline void kvm_disable_steal_time(void)
378 -{
379 - return;
380 -}
381 #endif
382
383 #endif /* _ASM_X86_KVM_PARA_H */
384 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
385 index 7fafa859e9f25..4e4476b832be2 100644
386 --- a/arch/x86/kernel/apic/apic.c
387 +++ b/arch/x86/kernel/apic/apic.c
388 @@ -2579,6 +2579,7 @@ static void __init apic_bsp_setup(bool upmode)
389 end_local_APIC_setup();
390 irq_remap_enable_fault_handling();
391 setup_IO_APIC();
392 + lapic_update_legacy_vectors();
393 }
394
395 #ifdef CONFIG_UP_LATE_INIT
396 diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
397 index bf6662d37a334..6b8b6bf6c5d1c 100644
398 --- a/arch/x86/kernel/apic/vector.c
399 +++ b/arch/x86/kernel/apic/vector.c
400 @@ -680,6 +680,26 @@ void lapic_assign_legacy_vector(unsigned int irq, bool replace)
401 irq_matrix_assign_system(vector_matrix, ISA_IRQ_VECTOR(irq), replace);
402 }
403
404 +void __init lapic_update_legacy_vectors(void)
405 +{
406 + unsigned int i;
407 +
408 + if (IS_ENABLED(CONFIG_X86_IO_APIC) && nr_ioapics > 0)
409 + return;
410 +
411 + /*
412 + * If the IO/APIC is disabled via config, kernel command line or
413 + * lack of enumeration then all legacy interrupts are routed
414 + * through the PIC. Make sure that they are marked as legacy
415 + * vectors. PIC_CASCADE_IRQ has already been marked in
416 + * lapic_assign_system_vectors().
417 + */
418 + for (i = 0; i < nr_legacy_irqs(); i++) {
419 + if (i != PIC_CASCADE_IR)
420 + lapic_assign_legacy_vector(i, true);
421 + }
422 +}
423 +
424 void __init lapic_assign_system_vectors(void)
425 {
426 unsigned int i, vector = 0;
427 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
428 index e820568ed4d5c..6ff2c7cac4c46 100644
429 --- a/arch/x86/kernel/kvm.c
430 +++ b/arch/x86/kernel/kvm.c
431 @@ -24,6 +24,7 @@
432 #include <linux/debugfs.h>
433 #include <linux/nmi.h>
434 #include <linux/swait.h>
435 +#include <linux/syscore_ops.h>
436 #include <asm/timer.h>
437 #include <asm/cpu.h>
438 #include <asm/traps.h>
439 @@ -33,6 +34,7 @@
440 #include <asm/apicdef.h>
441 #include <asm/hypervisor.h>
442 #include <asm/tlb.h>
443 +#include <asm/reboot.h>
444
445 static int kvmapf = 1;
446
447 @@ -351,6 +353,14 @@ static void kvm_pv_disable_apf(void)
448 smp_processor_id());
449 }
450
451 +static void kvm_disable_steal_time(void)
452 +{
453 + if (!has_steal_clock)
454 + return;
455 +
456 + wrmsr(MSR_KVM_STEAL_TIME, 0, 0);
457 +}
458 +
459 static void kvm_pv_guest_cpu_reboot(void *unused)
460 {
461 /*
462 @@ -393,14 +403,6 @@ static u64 kvm_steal_clock(int cpu)
463 return steal;
464 }
465
466 -void kvm_disable_steal_time(void)
467 -{
468 - if (!has_steal_clock)
469 - return;
470 -
471 - wrmsr(MSR_KVM_STEAL_TIME, 0, 0);
472 -}
473 -
474 static inline void __set_percpu_decrypted(void *ptr, unsigned long size)
475 {
476 early_set_memory_decrypted((unsigned long) ptr, size);
477 @@ -428,6 +430,27 @@ static void __init sev_map_percpu_data(void)
478 }
479 }
480
481 +static void kvm_guest_cpu_offline(bool shutdown)
482 +{
483 + kvm_disable_steal_time();
484 + if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
485 + wrmsrl(MSR_KVM_PV_EOI_EN, 0);
486 + kvm_pv_disable_apf();
487 + if (!shutdown)
488 + apf_task_wake_all();
489 + kvmclock_disable();
490 +}
491 +
492 +static int kvm_cpu_online(unsigned int cpu)
493 +{
494 + unsigned long flags;
495 +
496 + local_irq_save(flags);
497 + kvm_guest_cpu_init();
498 + local_irq_restore(flags);
499 + return 0;
500 +}
501 +
502 #ifdef CONFIG_SMP
503 #define KVM_IPI_CLUSTER_SIZE (2 * BITS_PER_LONG)
504
505 @@ -547,29 +570,46 @@ static void __init kvm_smp_prepare_boot_cpu(void)
506 kvm_spinlock_init();
507 }
508
509 -static void kvm_guest_cpu_offline(void)
510 +static int kvm_cpu_down_prepare(unsigned int cpu)
511 {
512 - kvm_disable_steal_time();
513 - if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
514 - wrmsrl(MSR_KVM_PV_EOI_EN, 0);
515 - kvm_pv_disable_apf();
516 - apf_task_wake_all();
517 + unsigned long flags;
518 +
519 + local_irq_save(flags);
520 + kvm_guest_cpu_offline(false);
521 + local_irq_restore(flags);
522 + return 0;
523 }
524
525 -static int kvm_cpu_online(unsigned int cpu)
526 +#endif
527 +
528 +static int kvm_suspend(void)
529 {
530 - local_irq_disable();
531 - kvm_guest_cpu_init();
532 - local_irq_enable();
533 + kvm_guest_cpu_offline(false);
534 +
535 return 0;
536 }
537
538 -static int kvm_cpu_down_prepare(unsigned int cpu)
539 +static void kvm_resume(void)
540 {
541 - local_irq_disable();
542 - kvm_guest_cpu_offline();
543 - local_irq_enable();
544 - return 0;
545 + kvm_cpu_online(raw_smp_processor_id());
546 +}
547 +
548 +static struct syscore_ops kvm_syscore_ops = {
549 + .suspend = kvm_suspend,
550 + .resume = kvm_resume,
551 +};
552 +
553 +/*
554 + * After a PV feature is registered, the host will keep writing to the
555 + * registered memory location. If the guest happens to shutdown, this memory
556 + * won't be valid. In cases like kexec, in which you install a new kernel, this
557 + * means a random memory location will be kept being written.
558 + */
559 +#ifdef CONFIG_KEXEC_CORE
560 +static void kvm_crash_shutdown(struct pt_regs *regs)
561 +{
562 + kvm_guest_cpu_offline(true);
563 + native_machine_crash_shutdown(regs);
564 }
565 #endif
566
567 @@ -649,6 +689,12 @@ static void __init kvm_guest_init(void)
568 kvm_guest_cpu_init();
569 #endif
570
571 +#ifdef CONFIG_KEXEC_CORE
572 + machine_ops.crash_shutdown = kvm_crash_shutdown;
573 +#endif
574 +
575 + register_syscore_ops(&kvm_syscore_ops);
576 +
577 /*
578 * Hard lockup detection is enabled by default. Disable it, as guests
579 * can get false positives too easily, for example if the host is
580 diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
581 index 904494b924c13..4a0802af2e3e0 100644
582 --- a/arch/x86/kernel/kvmclock.c
583 +++ b/arch/x86/kernel/kvmclock.c
584 @@ -20,7 +20,6 @@
585 #include <asm/hypervisor.h>
586 #include <asm/mem_encrypt.h>
587 #include <asm/x86_init.h>
588 -#include <asm/reboot.h>
589 #include <asm/kvmclock.h>
590
591 static int kvmclock __initdata = 1;
592 @@ -197,28 +196,9 @@ static void kvm_setup_secondary_clock(void)
593 }
594 #endif
595
596 -/*
597 - * After the clock is registered, the host will keep writing to the
598 - * registered memory location. If the guest happens to shutdown, this memory
599 - * won't be valid. In cases like kexec, in which you install a new kernel, this
600 - * means a random memory location will be kept being written. So before any
601 - * kind of shutdown from our side, we unregister the clock by writing anything
602 - * that does not have the 'enable' bit set in the msr
603 - */
604 -#ifdef CONFIG_KEXEC_CORE
605 -static void kvm_crash_shutdown(struct pt_regs *regs)
606 -{
607 - native_write_msr(msr_kvm_system_time, 0, 0);
608 - kvm_disable_steal_time();
609 - native_machine_crash_shutdown(regs);
610 -}
611 -#endif
612 -
613 -static void kvm_shutdown(void)
614 +void kvmclock_disable(void)
615 {
616 native_write_msr(msr_kvm_system_time, 0, 0);
617 - kvm_disable_steal_time();
618 - native_machine_shutdown();
619 }
620
621 static void __init kvmclock_init_mem(void)
622 @@ -346,10 +326,6 @@ void __init kvmclock_init(void)
623 #endif
624 x86_platform.save_sched_clock_state = kvm_save_sched_clock_state;
625 x86_platform.restore_sched_clock_state = kvm_restore_sched_clock_state;
626 - machine_ops.shutdown = kvm_shutdown;
627 -#ifdef CONFIG_KEXEC_CORE
628 - machine_ops.crash_shutdown = kvm_crash_shutdown;
629 -#endif
630 kvm_get_preset_lpj();
631
632 /*
633 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
634 index b9d14fdbd2d81..074cd170912aa 100644
635 --- a/arch/x86/kvm/svm.c
636 +++ b/arch/x86/kvm/svm.c
637 @@ -4057,7 +4057,7 @@ static int cr_interception(struct vcpu_svm *svm)
638 err = 0;
639 if (cr >= 16) { /* mov to cr */
640 cr -= 16;
641 - val = kvm_register_read(&svm->vcpu, reg);
642 + val = kvm_register_readl(&svm->vcpu, reg);
643 switch (cr) {
644 case 0:
645 if (!check_selective_cr0_intercepted(svm, val))
646 @@ -4102,7 +4102,7 @@ static int cr_interception(struct vcpu_svm *svm)
647 kvm_queue_exception(&svm->vcpu, UD_VECTOR);
648 return 1;
649 }
650 - kvm_register_write(&svm->vcpu, reg, val);
651 + kvm_register_writel(&svm->vcpu, reg, val);
652 }
653 return kvm_complete_insn_gp(&svm->vcpu, err);
654 }
655 @@ -4132,13 +4132,13 @@ static int dr_interception(struct vcpu_svm *svm)
656 if (dr >= 16) { /* mov to DRn */
657 if (!kvm_require_dr(&svm->vcpu, dr - 16))
658 return 1;
659 - val = kvm_register_read(&svm->vcpu, reg);
660 + val = kvm_register_readl(&svm->vcpu, reg);
661 kvm_set_dr(&svm->vcpu, dr - 16, val);
662 } else {
663 if (!kvm_require_dr(&svm->vcpu, dr))
664 return 1;
665 kvm_get_dr(&svm->vcpu, dr, &val);
666 - kvm_register_write(&svm->vcpu, reg, val);
667 + kvm_register_writel(&svm->vcpu, reg, val);
668 }
669
670 return kvm_skip_emulated_instruction(&svm->vcpu);
671 diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
672 index 4c0d4e4341961..72d2c0b656339 100644
673 --- a/drivers/acpi/acpica/utdelete.c
674 +++ b/drivers/acpi/acpica/utdelete.c
675 @@ -285,6 +285,14 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
676 }
677 break;
678
679 + case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:
680 +
681 + ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
682 + "***** Address handler %p\n", object));
683 +
684 + acpi_os_delete_mutex(object->address_space.context_mutex);
685 + break;
686 +
687 default:
688
689 break;
690 diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
691 index d59e1ca9990b6..90053c4a8290d 100644
692 --- a/drivers/bus/ti-sysc.c
693 +++ b/drivers/bus/ti-sysc.c
694 @@ -1376,9 +1376,9 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
695 SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE),
696 /* Uarts on omap4 and later */
697 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x50411e03, 0xffff00ff,
698 - SYSC_QUIRK_SWSUP_SIDLE_ACT | SYSC_QUIRK_LEGACY_IDLE),
699 + SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE),
700 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x47422e03, 0xffffffff,
701 - SYSC_QUIRK_SWSUP_SIDLE_ACT | SYSC_QUIRK_LEGACY_IDLE),
702 + SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE),
703
704 /* Quirks that need to be set based on the module address */
705 SYSC_QUIRK("mcpdm", 0x40132000, 0, 0x10, -ENODEV, 0x50000800, 0xffffffff,
706 diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
707 index b1af0de2e1008..e48298687b76d 100644
708 --- a/drivers/firmware/efi/cper.c
709 +++ b/drivers/firmware/efi/cper.c
710 @@ -263,8 +263,7 @@ static int cper_dimm_err_location(struct cper_mem_err_compact *mem, char *msg)
711 if (!msg || !(mem->validation_bits & CPER_MEM_VALID_MODULE_HANDLE))
712 return 0;
713
714 - n = 0;
715 - len = CPER_REC_LEN - 1;
716 + len = CPER_REC_LEN;
717 dmi_memdev_name(mem->mem_dev_handle, &bank, &device);
718 if (bank && device)
719 n = snprintf(msg, len, "DIMM location: %s %s ", bank, device);
720 @@ -273,7 +272,6 @@ static int cper_dimm_err_location(struct cper_mem_err_compact *mem, char *msg)
721 "DIMM location: not present. DMI handle: 0x%.4x ",
722 mem->mem_dev_handle);
723
724 - msg[n] = '\0';
725 return n;
726 }
727
728 diff --git a/drivers/firmware/efi/memattr.c b/drivers/firmware/efi/memattr.c
729 index 58452fde92cc0..5d343dc8e5354 100644
730 --- a/drivers/firmware/efi/memattr.c
731 +++ b/drivers/firmware/efi/memattr.c
732 @@ -66,11 +66,6 @@ static bool entry_is_valid(const efi_memory_desc_t *in, efi_memory_desc_t *out)
733 return false;
734 }
735
736 - if (!(in->attribute & (EFI_MEMORY_RO | EFI_MEMORY_XP))) {
737 - pr_warn("Entry attributes invalid: RO and XP bits both cleared\n");
738 - return false;
739 - }
740 -
741 if (PAGE_SIZE > EFI_PAGE_SIZE &&
742 (!PAGE_ALIGNED(in->phys_addr) ||
743 !PAGE_ALIGNED(in->num_pages << EFI_PAGE_SHIFT))) {
744 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
745 index 2cdaf3b2a7217..39ca0718ced0c 100644
746 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
747 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
748 @@ -351,7 +351,6 @@ static int amdgpu_ctx_query2(struct amdgpu_device *adev,
749 {
750 struct amdgpu_ctx *ctx;
751 struct amdgpu_ctx_mgr *mgr;
752 - unsigned long ras_counter;
753
754 if (!fpriv)
755 return -EINVAL;
756 @@ -376,21 +375,6 @@ static int amdgpu_ctx_query2(struct amdgpu_device *adev,
757 if (atomic_read(&ctx->guilty))
758 out->state.flags |= AMDGPU_CTX_QUERY2_FLAGS_GUILTY;
759
760 - /*query ue count*/
761 - ras_counter = amdgpu_ras_query_error_count(adev, false);
762 - /*ras counter is monotonic increasing*/
763 - if (ras_counter != ctx->ras_counter_ue) {
764 - out->state.flags |= AMDGPU_CTX_QUERY2_FLAGS_RAS_UE;
765 - ctx->ras_counter_ue = ras_counter;
766 - }
767 -
768 - /*query ce count*/
769 - ras_counter = amdgpu_ras_query_error_count(adev, true);
770 - if (ras_counter != ctx->ras_counter_ce) {
771 - out->state.flags |= AMDGPU_CTX_QUERY2_FLAGS_RAS_CE;
772 - ctx->ras_counter_ce = ras_counter;
773 - }
774 -
775 mutex_unlock(&mgr->lock);
776 return 0;
777 }
778 diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
779 index 217084d56ab8c..9deef20a02699 100644
780 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
781 +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
782 @@ -354,6 +354,7 @@ static int uvd_v6_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
783
784 error:
785 dma_fence_put(fence);
786 + amdgpu_bo_unpin(bo);
787 amdgpu_bo_unreserve(bo);
788 amdgpu_bo_unref(&bo);
789 return r;
790 diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
791 index abd86903875f0..fc4c074597539 100644
792 --- a/drivers/hid/hid-magicmouse.c
793 +++ b/drivers/hid/hid-magicmouse.c
794 @@ -597,7 +597,7 @@ static int magicmouse_probe(struct hid_device *hdev,
795 if (id->vendor == USB_VENDOR_ID_APPLE &&
796 id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
797 hdev->type != HID_TYPE_USBMOUSE)
798 - return 0;
799 + return -ENODEV;
800
801 msc = devm_kzalloc(&hdev->dev, sizeof(*msc), GFP_KERNEL);
802 if (msc == NULL) {
803 diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
804 index d91e6679afb18..f290ba856323a 100644
805 --- a/drivers/hid/hid-multitouch.c
806 +++ b/drivers/hid/hid-multitouch.c
807 @@ -611,9 +611,13 @@ static struct mt_report_data *mt_allocate_report_data(struct mt_device *td,
808 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
809 continue;
810
811 - for (n = 0; n < field->report_count; n++) {
812 - if (field->usage[n].hid == HID_DG_CONTACTID)
813 - rdata->is_mt_collection = true;
814 + if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) {
815 + for (n = 0; n < field->report_count; n++) {
816 + if (field->usage[n].hid == HID_DG_CONTACTID) {
817 + rdata->is_mt_collection = true;
818 + break;
819 + }
820 + }
821 }
822 }
823
824 diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
825 index 96898983db990..6f7a3702b5fba 100644
826 --- a/drivers/hid/i2c-hid/i2c-hid-core.c
827 +++ b/drivers/hid/i2c-hid/i2c-hid-core.c
828 @@ -50,6 +50,7 @@
829 #define I2C_HID_QUIRK_BOGUS_IRQ BIT(4)
830 #define I2C_HID_QUIRK_RESET_ON_RESUME BIT(5)
831 #define I2C_HID_QUIRK_BAD_INPUT_SIZE BIT(6)
832 +#define I2C_HID_QUIRK_NO_WAKEUP_AFTER_RESET BIT(7)
833
834
835 /* flags */
836 @@ -185,6 +186,11 @@ static const struct i2c_hid_quirks {
837 I2C_HID_QUIRK_RESET_ON_RESUME },
838 { USB_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720,
839 I2C_HID_QUIRK_BAD_INPUT_SIZE },
840 + /*
841 + * Sending the wakeup after reset actually break ELAN touchscreen controller
842 + */
843 + { USB_VENDOR_ID_ELAN, HID_ANY_ID,
844 + I2C_HID_QUIRK_NO_WAKEUP_AFTER_RESET },
845 { 0, 0 }
846 };
847
848 @@ -468,7 +474,8 @@ static int i2c_hid_hwreset(struct i2c_client *client)
849 }
850
851 /* At least some SIS devices need this after reset */
852 - ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
853 + if (!(ihid->quirks & I2C_HID_QUIRK_NO_WAKEUP_AFTER_RESET))
854 + ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
855
856 out_unlock:
857 mutex_unlock(&ihid->reset_lock);
858 @@ -1114,8 +1121,8 @@ static int i2c_hid_probe(struct i2c_client *client,
859 hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID);
860 hid->product = le16_to_cpu(ihid->hdesc.wProductID);
861
862 - snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX",
863 - client->name, hid->vendor, hid->product);
864 + snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X",
865 + client->name, (u16)hid->vendor, (u16)hid->product);
866 strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
867
868 ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product);
869 diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
870 index fddac7c72f645..07a9fe97d2e05 100644
871 --- a/drivers/hid/usbhid/hid-pidff.c
872 +++ b/drivers/hid/usbhid/hid-pidff.c
873 @@ -1292,6 +1292,7 @@ int hid_pidff_init(struct hid_device *hid)
874
875 if (pidff->pool[PID_DEVICE_MANAGED_POOL].value &&
876 pidff->pool[PID_DEVICE_MANAGED_POOL].value[0] == 0) {
877 + error = -EPERM;
878 hid_notice(hid,
879 "device does not support device managed pool\n");
880 goto fail;
881 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
882 index 4212d022d2534..35c00420d855b 100644
883 --- a/drivers/hwmon/dell-smm-hwmon.c
884 +++ b/drivers/hwmon/dell-smm-hwmon.c
885 @@ -792,10 +792,10 @@ static struct attribute *i8k_attrs[] = {
886 static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr,
887 int index)
888 {
889 - if (disallow_fan_support && index >= 8)
890 + if (disallow_fan_support && index >= 20)
891 return 0;
892 if (disallow_fan_type_call &&
893 - (index == 9 || index == 12 || index == 15))
894 + (index == 21 || index == 25 || index == 28))
895 return 0;
896 if (index >= 0 && index <= 1 &&
897 !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1))
898 diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
899 index b56a427fb928f..c73b997899af8 100644
900 --- a/drivers/i2c/busses/i2c-qcom-geni.c
901 +++ b/drivers/i2c/busses/i2c-qcom-geni.c
902 @@ -641,6 +641,14 @@ static int geni_i2c_remove(struct platform_device *pdev)
903 return 0;
904 }
905
906 +static void geni_i2c_shutdown(struct platform_device *pdev)
907 +{
908 + struct geni_i2c_dev *gi2c = platform_get_drvdata(pdev);
909 +
910 + /* Make client i2c transfers start failing */
911 + i2c_mark_adapter_suspended(&gi2c->adap);
912 +}
913 +
914 static int __maybe_unused geni_i2c_runtime_suspend(struct device *dev)
915 {
916 int ret;
917 @@ -677,6 +685,8 @@ static int __maybe_unused geni_i2c_suspend_noirq(struct device *dev)
918 {
919 struct geni_i2c_dev *gi2c = dev_get_drvdata(dev);
920
921 + i2c_mark_adapter_suspended(&gi2c->adap);
922 +
923 if (!gi2c->suspended) {
924 geni_i2c_runtime_suspend(dev);
925 pm_runtime_disable(dev);
926 @@ -686,8 +696,16 @@ static int __maybe_unused geni_i2c_suspend_noirq(struct device *dev)
927 return 0;
928 }
929
930 +static int __maybe_unused geni_i2c_resume_noirq(struct device *dev)
931 +{
932 + struct geni_i2c_dev *gi2c = dev_get_drvdata(dev);
933 +
934 + i2c_mark_adapter_resumed(&gi2c->adap);
935 + return 0;
936 +}
937 +
938 static const struct dev_pm_ops geni_i2c_pm_ops = {
939 - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(geni_i2c_suspend_noirq, NULL)
940 + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(geni_i2c_suspend_noirq, geni_i2c_resume_noirq)
941 SET_RUNTIME_PM_OPS(geni_i2c_runtime_suspend, geni_i2c_runtime_resume,
942 NULL)
943 };
944 @@ -701,6 +719,7 @@ MODULE_DEVICE_TABLE(of, geni_i2c_dt_match);
945 static struct platform_driver geni_i2c_driver = {
946 .probe = geni_i2c_probe,
947 .remove = geni_i2c_remove,
948 + .shutdown = geni_i2c_shutdown,
949 .driver = {
950 .name = "geni_i2c",
951 .pm = &geni_i2c_pm_ops,
952 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
953 index 0dba28bb309a2..00ae7a9a42bfe 100644
954 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
955 +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
956 @@ -7003,7 +7003,6 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
957
958 pf->fw_fid = le16_to_cpu(resp->fid);
959 pf->port_id = le16_to_cpu(resp->port_id);
960 - bp->dev->dev_port = pf->port_id;
961 memcpy(pf->mac_addr, resp->mac_address, ETH_ALEN);
962 pf->first_vf_id = le16_to_cpu(resp->first_vf_id);
963 pf->max_vfs = le16_to_cpu(resp->max_vfs);
964 diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
965 index 218aada8949d9..68a2fcf4c0bf5 100644
966 --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
967 +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
968 @@ -2233,15 +2233,20 @@ static struct sk_buff *i40e_run_xdp(struct i40e_ring *rx_ring,
969 case XDP_TX:
970 xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->queue_index];
971 result = i40e_xmit_xdp_tx_ring(xdp, xdp_ring);
972 + if (result == I40E_XDP_CONSUMED)
973 + goto out_failure;
974 break;
975 case XDP_REDIRECT:
976 err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog);
977 - result = !err ? I40E_XDP_REDIR : I40E_XDP_CONSUMED;
978 + if (err)
979 + goto out_failure;
980 + result = I40E_XDP_REDIR;
981 break;
982 default:
983 bpf_warn_invalid_xdp_action(act);
984 /* fall through */
985 case XDP_ABORTED:
986 +out_failure:
987 trace_xdp_exception(rx_ring->netdev, xdp_prog, act);
988 /* fall through -- handle aborts by dropping packet */
989 case XDP_DROP:
990 diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
991 index c9d4534fbdf02..a9ad788c4913d 100644
992 --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
993 +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
994 @@ -212,21 +212,28 @@ static int i40e_run_xdp_zc(struct i40e_ring *rx_ring, struct xdp_buff *xdp)
995
996 xdp->handle = xsk_umem_adjust_offset(umem, xdp->handle, offset);
997
998 + if (likely(act == XDP_REDIRECT)) {
999 + err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog);
1000 + if (err)
1001 + goto out_failure;
1002 + rcu_read_unlock();
1003 + return I40E_XDP_REDIR;
1004 + }
1005 +
1006 switch (act) {
1007 case XDP_PASS:
1008 break;
1009 case XDP_TX:
1010 xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->queue_index];
1011 result = i40e_xmit_xdp_tx_ring(xdp, xdp_ring);
1012 - break;
1013 - case XDP_REDIRECT:
1014 - err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog);
1015 - result = !err ? I40E_XDP_REDIR : I40E_XDP_CONSUMED;
1016 + if (result == I40E_XDP_CONSUMED)
1017 + goto out_failure;
1018 break;
1019 default:
1020 bpf_warn_invalid_xdp_action(act);
1021 /* fall through */
1022 case XDP_ABORTED:
1023 +out_failure:
1024 trace_xdp_exception(rx_ring->netdev, xdp_prog, act);
1025 /* fallthrough -- handle aborts by dropping packet */
1026 case XDP_DROP:
1027 diff --git a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
1028 index 9138b19de87e0..f2bb83af4d9e8 100644
1029 --- a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
1030 +++ b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
1031 @@ -34,6 +34,7 @@
1032 #define PF_FW_ATQLEN_ATQOVFL_M BIT(29)
1033 #define PF_FW_ATQLEN_ATQCRIT_M BIT(30)
1034 #define VF_MBX_ARQLEN(_VF) (0x0022BC00 + ((_VF) * 4))
1035 +#define VF_MBX_ATQLEN(_VF) (0x0022A800 + ((_VF) * 4))
1036 #define PF_FW_ATQLEN_ATQENABLE_M BIT(31)
1037 #define PF_FW_ATQT 0x00080400
1038 #define PF_MBX_ARQBAH 0x0022E400
1039 diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
1040 index 33dd103035dcd..2b55efe5ed963 100644
1041 --- a/drivers/net/ethernet/intel/ice/ice_txrx.c
1042 +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
1043 @@ -2109,6 +2109,7 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_ring *tx_ring)
1044 struct ice_tx_offload_params offload = { 0 };
1045 struct ice_vsi *vsi = tx_ring->vsi;
1046 struct ice_tx_buf *first;
1047 + struct ethhdr *eth;
1048 unsigned int count;
1049 int tso, csum;
1050
1051 @@ -2156,7 +2157,9 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_ring *tx_ring)
1052 goto out_drop;
1053
1054 /* allow CONTROL frames egress from main VSI if FW LLDP disabled */
1055 - if (unlikely(skb->priority == TC_PRIO_CONTROL &&
1056 + eth = (struct ethhdr *)skb_mac_header(skb);
1057 + if (unlikely((skb->priority == TC_PRIO_CONTROL ||
1058 + eth->h_proto == htons(ETH_P_LLDP)) &&
1059 vsi->type == ICE_VSI_PF &&
1060 vsi->port_info->is_sw_lldp))
1061 offload.cd_qw1 |= (u64)(ICE_TX_DESC_DTYPE_CTX |
1062 diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
1063 index e92a00a617556..5e97fdca5fab2 100644
1064 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
1065 +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
1066 @@ -384,13 +384,15 @@ static void ice_trigger_vf_reset(struct ice_vf *vf, bool is_vflr, bool is_pfr)
1067 */
1068 clear_bit(ICE_VF_STATE_INIT, vf->vf_states);
1069
1070 - /* VF_MBX_ARQLEN is cleared by PFR, so the driver needs to clear it
1071 - * in the case of VFR. If this is done for PFR, it can mess up VF
1072 - * resets because the VF driver may already have started cleanup
1073 - * by the time we get here.
1074 + /* VF_MBX_ARQLEN and VF_MBX_ATQLEN are cleared by PFR, so the driver
1075 + * needs to clear them in the case of VFR/VFLR. If this is done for
1076 + * PFR, it can mess up VF resets because the VF driver may already
1077 + * have started cleanup by the time we get here.
1078 */
1079 - if (!is_pfr)
1080 - wr32(hw, VF_MBX_ARQLEN(vf_abs_id), 0);
1081 + if (!is_pfr) {
1082 + wr32(hw, VF_MBX_ARQLEN(vf->vf_id), 0);
1083 + wr32(hw, VF_MBX_ATQLEN(vf->vf_id), 0);
1084 + }
1085
1086 /* In the case of a VFLR, the HW has already reset the VF and we
1087 * just need to clean up, so don't hit the VFRTRIG register.
1088 diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1089 index 64ec0e7c64b49..be8e6d4e376ec 100644
1090 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1091 +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1092 @@ -1079,11 +1079,14 @@ static struct sk_buff *ixgbevf_run_xdp(struct ixgbevf_adapter *adapter,
1093 case XDP_TX:
1094 xdp_ring = adapter->xdp_ring[rx_ring->queue_index];
1095 result = ixgbevf_xmit_xdp_ring(xdp_ring, xdp);
1096 + if (result == IXGBEVF_XDP_CONSUMED)
1097 + goto out_failure;
1098 break;
1099 default:
1100 bpf_warn_invalid_xdp_action(act);
1101 /* fallthrough */
1102 case XDP_ABORTED:
1103 +out_failure:
1104 trace_xdp_exception(rx_ring->netdev, xdp_prog, act);
1105 /* fallthrough -- handle aborts by dropping packet */
1106 case XDP_DROP:
1107 diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
1108 index cbe7f35eac982..0646bcd269682 100644
1109 --- a/drivers/net/usb/cdc_ncm.c
1110 +++ b/drivers/net/usb/cdc_ncm.c
1111 @@ -1589,6 +1589,15 @@ cdc_ncm_speed_change(struct usbnet *dev,
1112 uint32_t rx_speed = le32_to_cpu(data->DLBitRRate);
1113 uint32_t tx_speed = le32_to_cpu(data->ULBitRate);
1114
1115 + /* if the speed hasn't changed, don't report it.
1116 + * RTL8156 shipped before 2021 sends notification about every 32ms.
1117 + */
1118 + if (dev->rx_speed == rx_speed && dev->tx_speed == tx_speed)
1119 + return;
1120 +
1121 + dev->rx_speed = rx_speed;
1122 + dev->tx_speed = tx_speed;
1123 +
1124 /*
1125 * Currently the USB-NET API does not support reporting the actual
1126 * device speed. Do print it instead.
1127 @@ -1629,7 +1638,8 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
1128 * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be
1129 * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE.
1130 */
1131 - usbnet_link_change(dev, !!event->wValue, 0);
1132 + if (netif_carrier_ok(dev->net) != !!event->wValue)
1133 + usbnet_link_change(dev, !!event->wValue, 0);
1134 break;
1135
1136 case USB_CDC_NOTIFY_SPEED_CHANGE:
1137 diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
1138 index 9da27ec22d588..44d74584c7275 100644
1139 --- a/drivers/usb/dwc2/core_intr.c
1140 +++ b/drivers/usb/dwc2/core_intr.c
1141 @@ -712,7 +712,11 @@ static inline void dwc_handle_gpwrdn_disc_det(struct dwc2_hsotg *hsotg,
1142 dwc2_writel(hsotg, gpwrdn_tmp, GPWRDN);
1143
1144 hsotg->hibernated = 0;
1145 +
1146 +#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || \
1147 + IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
1148 hsotg->bus_suspended = 0;
1149 +#endif
1150
1151 if (gpwrdn & GPWRDN_IDSTS) {
1152 hsotg->op_state = OTG_STATE_B_PERIPHERAL;
1153 diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig
1154 index 4abddbebd4b23..c691127bc805a 100644
1155 --- a/drivers/vfio/pci/Kconfig
1156 +++ b/drivers/vfio/pci/Kconfig
1157 @@ -2,6 +2,7 @@
1158 config VFIO_PCI
1159 tristate "VFIO support for PCI devices"
1160 depends on VFIO && PCI && EVENTFD
1161 + depends on MMU
1162 select VFIO_VIRQFD
1163 select IRQ_BYPASS_MANAGER
1164 help
1165 diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
1166 index bf32997c557ff..50cd17fcf7541 100644
1167 --- a/drivers/vfio/pci/vfio_pci_config.c
1168 +++ b/drivers/vfio/pci/vfio_pci_config.c
1169 @@ -1576,7 +1576,7 @@ static int vfio_ecap_init(struct vfio_pci_device *vdev)
1170 if (len == 0xFF) {
1171 len = vfio_ext_cap_len(vdev, ecap, epos);
1172 if (len < 0)
1173 - return ret;
1174 + return len;
1175 }
1176 }
1177
1178 diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
1179 index 152e5188183ce..6f727034679f1 100644
1180 --- a/drivers/vfio/platform/vfio_platform_common.c
1181 +++ b/drivers/vfio/platform/vfio_platform_common.c
1182 @@ -289,7 +289,7 @@ err_irq:
1183 vfio_platform_regions_cleanup(vdev);
1184 err_reg:
1185 mutex_unlock(&driver_lock);
1186 - module_put(THIS_MODULE);
1187 + module_put(vdev->parent_module);
1188 return ret;
1189 }
1190
1191 diff --git a/drivers/xen/xen-pciback/vpci.c b/drivers/xen/xen-pciback/vpci.c
1192 index f6ba18191c0f9..30313084f06c1 100644
1193 --- a/drivers/xen/xen-pciback/vpci.c
1194 +++ b/drivers/xen/xen-pciback/vpci.c
1195 @@ -69,7 +69,7 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
1196 struct pci_dev *dev, int devid,
1197 publish_pci_dev_cb publish_cb)
1198 {
1199 - int err = 0, slot, func = -1;
1200 + int err = 0, slot, func = PCI_FUNC(dev->devfn);
1201 struct pci_dev_entry *t, *dev_entry;
1202 struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;
1203
1204 @@ -94,23 +94,26 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
1205
1206 /*
1207 * Keep multi-function devices together on the virtual PCI bus, except
1208 - * virtual functions.
1209 + * that we want to keep virtual functions at func 0 on their own. They
1210 + * aren't multi-function devices and hence their presence at func 0
1211 + * may cause guests to not scan the other functions.
1212 */
1213 - if (!dev->is_virtfn) {
1214 + if (!dev->is_virtfn || func) {
1215 for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
1216 if (list_empty(&vpci_dev->dev_list[slot]))
1217 continue;
1218
1219 t = list_entry(list_first(&vpci_dev->dev_list[slot]),
1220 struct pci_dev_entry, list);
1221 + if (t->dev->is_virtfn && !PCI_FUNC(t->dev->devfn))
1222 + continue;
1223
1224 if (match_slot(dev, t->dev)) {
1225 pr_info("vpci: %s: assign to virtual slot %d func %d\n",
1226 pci_name(dev), slot,
1227 - PCI_FUNC(dev->devfn));
1228 + func);
1229 list_add_tail(&dev_entry->list,
1230 &vpci_dev->dev_list[slot]);
1231 - func = PCI_FUNC(dev->devfn);
1232 goto unlock;
1233 }
1234 }
1235 @@ -123,7 +126,6 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
1236 pci_name(dev), slot);
1237 list_add_tail(&dev_entry->list,
1238 &vpci_dev->dev_list[slot]);
1239 - func = dev->is_virtfn ? 0 : PCI_FUNC(dev->devfn);
1240 goto unlock;
1241 }
1242 }
1243 diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
1244 index 6317394f02b86..832b40293907f 100644
1245 --- a/fs/btrfs/extent-tree.c
1246 +++ b/fs/btrfs/extent-tree.c
1247 @@ -1338,16 +1338,20 @@ int btrfs_discard_extent(struct btrfs_fs_info *fs_info, u64 bytenr,
1248 for (i = 0; i < bbio->num_stripes; i++, stripe++) {
1249 u64 bytes;
1250 struct request_queue *req_q;
1251 + struct btrfs_device *device = stripe->dev;
1252
1253 - if (!stripe->dev->bdev) {
1254 + if (!device->bdev) {
1255 ASSERT(btrfs_test_opt(fs_info, DEGRADED));
1256 continue;
1257 }
1258 - req_q = bdev_get_queue(stripe->dev->bdev);
1259 + req_q = bdev_get_queue(device->bdev);
1260 if (!blk_queue_discard(req_q))
1261 continue;
1262
1263 - ret = btrfs_issue_discard(stripe->dev->bdev,
1264 + if (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state))
1265 + continue;
1266 +
1267 + ret = btrfs_issue_discard(device->bdev,
1268 stripe->physical,
1269 stripe->length,
1270 &bytes);
1271 @@ -1879,7 +1883,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans,
1272 trace_run_delayed_ref_head(fs_info, head, 0);
1273 btrfs_delayed_ref_unlock(head);
1274 btrfs_put_delayed_ref_head(head);
1275 - return 0;
1276 + return ret;
1277 }
1278
1279 static struct btrfs_delayed_ref_head *btrfs_obtain_ref_head(
1280 diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
1281 index 2b8f29c07668b..61b82c69eed50 100644
1282 --- a/fs/btrfs/file-item.c
1283 +++ b/fs/btrfs/file-item.c
1284 @@ -599,7 +599,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
1285 u64 end_byte = bytenr + len;
1286 u64 csum_end;
1287 struct extent_buffer *leaf;
1288 - int ret;
1289 + int ret = 0;
1290 u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);
1291 int blocksize_bits = fs_info->sb->s_blocksize_bits;
1292
1293 @@ -618,6 +618,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
1294 path->leave_spinning = 1;
1295 ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
1296 if (ret > 0) {
1297 + ret = 0;
1298 if (path->slots[0] == 0)
1299 break;
1300 path->slots[0]--;
1301 @@ -674,7 +675,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
1302 ret = btrfs_del_items(trans, root, path,
1303 path->slots[0], del_nr);
1304 if (ret)
1305 - goto out;
1306 + break;
1307 if (key.offset == bytenr)
1308 break;
1309 } else if (key.offset < bytenr && csum_end > end_byte) {
1310 @@ -718,8 +719,9 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
1311 ret = btrfs_split_item(trans, root, path, &key, offset);
1312 if (ret && ret != -EAGAIN) {
1313 btrfs_abort_transaction(trans, ret);
1314 - goto out;
1315 + break;
1316 }
1317 + ret = 0;
1318
1319 key.offset = end_byte - 1;
1320 } else {
1321 @@ -729,8 +731,6 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
1322 }
1323 btrfs_release_path(path);
1324 }
1325 - ret = 0;
1326 -out:
1327 btrfs_free_path(path);
1328 return ret;
1329 }
1330 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
1331 index 8ea9559c1919a..64dd702a5448c 100644
1332 --- a/fs/btrfs/inode.c
1333 +++ b/fs/btrfs/inode.c
1334 @@ -3359,6 +3359,18 @@ out:
1335 if (ret || truncated) {
1336 u64 start, end;
1337
1338 + /*
1339 + * If we failed to finish this ordered extent for any reason we
1340 + * need to make sure BTRFS_ORDERED_IOERR is set on the ordered
1341 + * extent, and mark the inode with the error if it wasn't
1342 + * already set. Any error during writeback would have already
1343 + * set the mapping error, so we need to set it if we're the ones
1344 + * marking this ordered extent as failed.
1345 + */
1346 + if (ret && !test_and_set_bit(BTRFS_ORDERED_IOERR,
1347 + &ordered_extent->flags))
1348 + mapping_set_error(ordered_extent->inode->i_mapping, -EIO);
1349 +
1350 if (truncated)
1351 start = ordered_extent->file_offset + logical_len;
1352 else
1353 diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
1354 index 7d06842a3d747..368c43c6cbd08 100644
1355 --- a/fs/btrfs/tree-checker.c
1356 +++ b/fs/btrfs/tree-checker.c
1357 @@ -1285,22 +1285,14 @@ static int check_extent_data_ref(struct extent_buffer *leaf,
1358 return -EUCLEAN;
1359 }
1360 for (; ptr < end; ptr += sizeof(*dref)) {
1361 - u64 root_objectid;
1362 - u64 owner;
1363 u64 offset;
1364 - u64 hash;
1365
1366 + /*
1367 + * We cannot check the extent_data_ref hash due to possible
1368 + * overflow from the leaf due to hash collisions.
1369 + */
1370 dref = (struct btrfs_extent_data_ref *)ptr;
1371 - root_objectid = btrfs_extent_data_ref_root(leaf, dref);
1372 - owner = btrfs_extent_data_ref_objectid(leaf, dref);
1373 offset = btrfs_extent_data_ref_offset(leaf, dref);
1374 - hash = hash_extent_data_ref(root_objectid, owner, offset);
1375 - if (hash != key->offset) {
1376 - extent_err(leaf, slot,
1377 - "invalid extent data ref hash, item has 0x%016llx key has 0x%016llx",
1378 - hash, key->offset);
1379 - return -EUCLEAN;
1380 - }
1381 if (!IS_ALIGNED(offset, leaf->fs_info->sectorsize)) {
1382 extent_err(leaf, slot,
1383 "invalid extent data backref offset, have %llu expect aligned to %u",
1384 diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
1385 index 54647eb9c6ed2..4ff381c23cefc 100644
1386 --- a/fs/btrfs/tree-log.c
1387 +++ b/fs/btrfs/tree-log.c
1388 @@ -1775,6 +1775,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
1389 break;
1390
1391 if (ret == 1) {
1392 + ret = 0;
1393 if (path->slots[0] == 0)
1394 break;
1395 path->slots[0]--;
1396 @@ -1787,17 +1788,19 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
1397
1398 ret = btrfs_del_item(trans, root, path);
1399 if (ret)
1400 - goto out;
1401 + break;
1402
1403 btrfs_release_path(path);
1404 inode = read_one_inode(root, key.offset);
1405 - if (!inode)
1406 - return -EIO;
1407 + if (!inode) {
1408 + ret = -EIO;
1409 + break;
1410 + }
1411
1412 ret = fixup_inode_link_count(trans, root, inode);
1413 iput(inode);
1414 if (ret)
1415 - goto out;
1416 + break;
1417
1418 /*
1419 * fixup on a directory may create new entries,
1420 @@ -1806,8 +1809,6 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
1421 */
1422 key.offset = (u64)-1;
1423 }
1424 - ret = 0;
1425 -out:
1426 btrfs_release_path(path);
1427 return ret;
1428 }
1429 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
1430 index 3193f0b4a02d6..dbd0d7a101541 100644
1431 --- a/fs/ext4/extents.c
1432 +++ b/fs/ext4/extents.c
1433 @@ -3378,7 +3378,10 @@ static int ext4_split_extent_at(handle_t *handle,
1434 ext4_ext_mark_unwritten(ex2);
1435
1436 err = ext4_ext_insert_extent(handle, inode, ppath, &newex, flags);
1437 - if (err == -ENOSPC && (EXT4_EXT_MAY_ZEROOUT & split_flag)) {
1438 + if (err != -ENOSPC && err != -EDQUOT)
1439 + goto out;
1440 +
1441 + if (EXT4_EXT_MAY_ZEROOUT & split_flag) {
1442 if (split_flag & (EXT4_EXT_DATA_VALID1|EXT4_EXT_DATA_VALID2)) {
1443 if (split_flag & EXT4_EXT_DATA_VALID1) {
1444 err = ext4_ext_zeroout(inode, ex2);
1445 @@ -3404,30 +3407,30 @@ static int ext4_split_extent_at(handle_t *handle,
1446 ext4_ext_pblock(&orig_ex));
1447 }
1448
1449 - if (err)
1450 - goto fix_extent_len;
1451 - /* update the extent length and mark as initialized */
1452 - ex->ee_len = cpu_to_le16(ee_len);
1453 - ext4_ext_try_to_merge(handle, inode, path, ex);
1454 - err = ext4_ext_dirty(handle, inode, path + path->p_depth);
1455 - if (err)
1456 - goto fix_extent_len;
1457 -
1458 - /* update extent status tree */
1459 - err = ext4_zeroout_es(inode, &zero_ex);
1460 -
1461 - goto out;
1462 - } else if (err)
1463 - goto fix_extent_len;
1464 -
1465 -out:
1466 - ext4_ext_show_leaf(inode, path);
1467 - return err;
1468 + if (!err) {
1469 + /* update the extent length and mark as initialized */
1470 + ex->ee_len = cpu_to_le16(ee_len);
1471 + ext4_ext_try_to_merge(handle, inode, path, ex);
1472 + err = ext4_ext_dirty(handle, inode, path + path->p_depth);
1473 + if (!err)
1474 + /* update extent status tree */
1475 + err = ext4_zeroout_es(inode, &zero_ex);
1476 + /* If we failed at this point, we don't know in which
1477 + * state the extent tree exactly is so don't try to fix
1478 + * length of the original extent as it may do even more
1479 + * damage.
1480 + */
1481 + goto out;
1482 + }
1483 + }
1484
1485 fix_extent_len:
1486 ex->ee_len = orig_ex.ee_len;
1487 ext4_ext_dirty(handle, inode, path + path->p_depth);
1488 return err;
1489 +out:
1490 + ext4_ext_show_leaf(inode, path);
1491 + return err;
1492 }
1493
1494 /*
1495 diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
1496 index ab2b0d74ad03e..c2852d7cc14d4 100644
1497 --- a/fs/ocfs2/file.c
1498 +++ b/fs/ocfs2/file.c
1499 @@ -1855,6 +1855,45 @@ out:
1500 return ret;
1501 }
1502
1503 +/*
1504 + * zero out partial blocks of one cluster.
1505 + *
1506 + * start: file offset where zero starts, will be made upper block aligned.
1507 + * len: it will be trimmed to the end of current cluster if "start + len"
1508 + * is bigger than it.
1509 + */
1510 +static int ocfs2_zeroout_partial_cluster(struct inode *inode,
1511 + u64 start, u64 len)
1512 +{
1513 + int ret;
1514 + u64 start_block, end_block, nr_blocks;
1515 + u64 p_block, offset;
1516 + u32 cluster, p_cluster, nr_clusters;
1517 + struct super_block *sb = inode->i_sb;
1518 + u64 end = ocfs2_align_bytes_to_clusters(sb, start);
1519 +
1520 + if (start + len < end)
1521 + end = start + len;
1522 +
1523 + start_block = ocfs2_blocks_for_bytes(sb, start);
1524 + end_block = ocfs2_blocks_for_bytes(sb, end);
1525 + nr_blocks = end_block - start_block;
1526 + if (!nr_blocks)
1527 + return 0;
1528 +
1529 + cluster = ocfs2_bytes_to_clusters(sb, start);
1530 + ret = ocfs2_get_clusters(inode, cluster, &p_cluster,
1531 + &nr_clusters, NULL);
1532 + if (ret)
1533 + return ret;
1534 + if (!p_cluster)
1535 + return 0;
1536 +
1537 + offset = start_block - ocfs2_clusters_to_blocks(sb, cluster);
1538 + p_block = ocfs2_clusters_to_blocks(sb, p_cluster) + offset;
1539 + return sb_issue_zeroout(sb, p_block, nr_blocks, GFP_NOFS);
1540 +}
1541 +
1542 /*
1543 * Parts of this function taken from xfs_change_file_space()
1544 */
1545 @@ -1865,7 +1904,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
1546 {
1547 int ret;
1548 s64 llen;
1549 - loff_t size;
1550 + loff_t size, orig_isize;
1551 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1552 struct buffer_head *di_bh = NULL;
1553 handle_t *handle;
1554 @@ -1896,6 +1935,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
1555 goto out_inode_unlock;
1556 }
1557
1558 + orig_isize = i_size_read(inode);
1559 switch (sr->l_whence) {
1560 case 0: /*SEEK_SET*/
1561 break;
1562 @@ -1903,7 +1943,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
1563 sr->l_start += f_pos;
1564 break;
1565 case 2: /*SEEK_END*/
1566 - sr->l_start += i_size_read(inode);
1567 + sr->l_start += orig_isize;
1568 break;
1569 default:
1570 ret = -EINVAL;
1571 @@ -1957,6 +1997,14 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
1572 default:
1573 ret = -EINVAL;
1574 }
1575 +
1576 + /* zeroout eof blocks in the cluster. */
1577 + if (!ret && change_size && orig_isize < size) {
1578 + ret = ocfs2_zeroout_partial_cluster(inode, orig_isize,
1579 + size - orig_isize);
1580 + if (!ret)
1581 + i_size_write(inode, size);
1582 + }
1583 up_write(&OCFS2_I(inode)->ip_alloc_sem);
1584 if (ret) {
1585 mlog_errno(ret);
1586 @@ -1973,9 +2021,6 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
1587 goto out_inode_unlock;
1588 }
1589
1590 - if (change_size && i_size_read(inode) < size)
1591 - i_size_write(inode, size);
1592 -
1593 inode->i_ctime = inode->i_mtime = current_time(inode);
1594 ret = ocfs2_mark_inode_dirty(handle, inode, di_bh);
1595 if (ret < 0)
1596 diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
1597 index 93d5cf0bc7168..d8b86fd391134 100644
1598 --- a/include/linux/huge_mm.h
1599 +++ b/include/linux/huge_mm.h
1600 @@ -231,6 +231,19 @@ static inline spinlock_t *pud_trans_huge_lock(pud_t *pud,
1601 else
1602 return NULL;
1603 }
1604 +
1605 +/**
1606 + * thp_order - Order of a transparent huge page.
1607 + * @page: Head page of a transparent huge page.
1608 + */
1609 +static inline unsigned int thp_order(struct page *page)
1610 +{
1611 + VM_BUG_ON_PGFLAGS(PageTail(page), page);
1612 + if (PageHead(page))
1613 + return HPAGE_PMD_ORDER;
1614 + return 0;
1615 +}
1616 +
1617 static inline int hpage_nr_pages(struct page *page)
1618 {
1619 if (unlikely(PageTransHuge(page)))
1620 @@ -290,6 +303,12 @@ static inline struct list_head *page_deferred_list(struct page *page)
1621 #define HPAGE_PUD_MASK ({ BUILD_BUG(); 0; })
1622 #define HPAGE_PUD_SIZE ({ BUILD_BUG(); 0; })
1623
1624 +static inline unsigned int thp_order(struct page *page)
1625 +{
1626 + VM_BUG_ON_PGFLAGS(PageTail(page), page);
1627 + return 0;
1628 +}
1629 +
1630 #define hpage_nr_pages(x) 1
1631
1632 static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma)
1633 diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
1634 index d8860f2d0976d..fc6ed1311589c 100644
1635 --- a/include/linux/usb/usbnet.h
1636 +++ b/include/linux/usb/usbnet.h
1637 @@ -83,6 +83,8 @@ struct usbnet {
1638 # define EVENT_LINK_CHANGE 11
1639 # define EVENT_SET_RX_MODE 12
1640 # define EVENT_NO_IP_ALIGN 13
1641 + u32 rx_speed; /* in bps - NOT Mbps */
1642 + u32 tx_speed; /* in bps - NOT Mbps */
1643 };
1644
1645 static inline struct usb_driver *driver_of(struct usb_interface *intf)
1646 diff --git a/include/linux/xarray.h b/include/linux/xarray.h
1647 index 3b257c97837db..2903f25bff5e4 100644
1648 --- a/include/linux/xarray.h
1649 +++ b/include/linux/xarray.h
1650 @@ -1470,6 +1470,28 @@ void xas_pause(struct xa_state *);
1651
1652 void xas_create_range(struct xa_state *);
1653
1654 +#ifdef CONFIG_XARRAY_MULTI
1655 +int xa_get_order(struct xarray *, unsigned long index);
1656 +void xas_split(struct xa_state *, void *entry, unsigned int order);
1657 +void xas_split_alloc(struct xa_state *, void *entry, unsigned int order, gfp_t);
1658 +#else
1659 +static inline int xa_get_order(struct xarray *xa, unsigned long index)
1660 +{
1661 + return 0;
1662 +}
1663 +
1664 +static inline void xas_split(struct xa_state *xas, void *entry,
1665 + unsigned int order)
1666 +{
1667 + xas_store(xas, entry);
1668 +}
1669 +
1670 +static inline void xas_split_alloc(struct xa_state *xas, void *entry,
1671 + unsigned int order, gfp_t gfp)
1672 +{
1673 +}
1674 +#endif
1675 +
1676 /**
1677 * xas_reload() - Refetch an entry from the xarray.
1678 * @xas: XArray operation state.
1679 diff --git a/include/net/caif/caif_dev.h b/include/net/caif/caif_dev.h
1680 index 48ecca8530ffa..b655d8666f555 100644
1681 --- a/include/net/caif/caif_dev.h
1682 +++ b/include/net/caif/caif_dev.h
1683 @@ -119,7 +119,7 @@ void caif_free_client(struct cflayer *adap_layer);
1684 * The link_support layer is used to add any Link Layer specific
1685 * framing.
1686 */
1687 -void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
1688 +int caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
1689 struct cflayer *link_support, int head_room,
1690 struct cflayer **layer, int (**rcv_func)(
1691 struct sk_buff *, struct net_device *,
1692 diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h
1693 index 2aa5e91d84576..8819ff4db35a6 100644
1694 --- a/include/net/caif/cfcnfg.h
1695 +++ b/include/net/caif/cfcnfg.h
1696 @@ -62,7 +62,7 @@ void cfcnfg_remove(struct cfcnfg *cfg);
1697 * @fcs: Specify if checksum is used in CAIF Framing Layer.
1698 * @head_room: Head space needed by link specific protocol.
1699 */
1700 -void
1701 +int
1702 cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
1703 struct net_device *dev, struct cflayer *phy_layer,
1704 enum cfcnfg_phy_preference pref,
1705 diff --git a/include/net/caif/cfserl.h b/include/net/caif/cfserl.h
1706 index 14a55e03bb3ce..67cce8757175a 100644
1707 --- a/include/net/caif/cfserl.h
1708 +++ b/include/net/caif/cfserl.h
1709 @@ -9,4 +9,5 @@
1710 #include <net/caif/caif_layer.h>
1711
1712 struct cflayer *cfserl_create(int instance, bool use_stx);
1713 +void cfserl_release(struct cflayer *layer);
1714 #endif
1715 diff --git a/init/main.c b/init/main.c
1716 index fef9e610b74b7..e6a1fb14f3085 100644
1717 --- a/init/main.c
1718 +++ b/init/main.c
1719 @@ -1174,7 +1174,7 @@ static noinline void __init kernel_init_freeable(void)
1720 */
1721 set_mems_allowed(node_states[N_MEMORY]);
1722
1723 - cad_pid = task_pid(current);
1724 + cad_pid = get_pid(task_pid(current));
1725
1726 smp_prepare_cpus(setup_max_cpus);
1727
1728 diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c
1729 index 0c9d3ad17e0fc..4d0b59fa5550f 100644
1730 --- a/lib/lz4/lz4_decompress.c
1731 +++ b/lib/lz4/lz4_decompress.c
1732 @@ -260,7 +260,11 @@ static FORCE_INLINE int LZ4_decompress_generic(
1733 }
1734 }
1735
1736 - memcpy(op, ip, length);
1737 + /*
1738 + * supports overlapping memory regions; only matters
1739 + * for in-place decompression scenarios
1740 + */
1741 + LZ4_memmove(op, ip, length);
1742 ip += length;
1743 op += length;
1744
1745 diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
1746 index 1a7fa9d9170fb..369eb181d730c 100644
1747 --- a/lib/lz4/lz4defs.h
1748 +++ b/lib/lz4/lz4defs.h
1749 @@ -137,6 +137,8 @@ static FORCE_INLINE void LZ4_writeLE16(void *memPtr, U16 value)
1750 return put_unaligned_le16(value, memPtr);
1751 }
1752
1753 +#define LZ4_memmove(dst, src, size) __builtin_memmove(dst, src, size)
1754 +
1755 static FORCE_INLINE void LZ4_copy8(void *dst, const void *src)
1756 {
1757 #if LZ4_ARCH64
1758 diff --git a/lib/test_xarray.c b/lib/test_xarray.c
1759 index d4f97925dbd8d..8262c3f05a5d3 100644
1760 --- a/lib/test_xarray.c
1761 +++ b/lib/test_xarray.c
1762 @@ -1503,6 +1503,49 @@ static noinline void check_store_range(struct xarray *xa)
1763 }
1764 }
1765
1766 +#ifdef CONFIG_XARRAY_MULTI
1767 +static void check_split_1(struct xarray *xa, unsigned long index,
1768 + unsigned int order)
1769 +{
1770 + XA_STATE(xas, xa, index);
1771 + void *entry;
1772 + unsigned int i = 0;
1773 +
1774 + xa_store_order(xa, index, order, xa, GFP_KERNEL);
1775 +
1776 + xas_split_alloc(&xas, xa, order, GFP_KERNEL);
1777 + xas_lock(&xas);
1778 + xas_split(&xas, xa, order);
1779 + xas_unlock(&xas);
1780 +
1781 + xa_for_each(xa, index, entry) {
1782 + XA_BUG_ON(xa, entry != xa);
1783 + i++;
1784 + }
1785 + XA_BUG_ON(xa, i != 1 << order);
1786 +
1787 + xa_set_mark(xa, index, XA_MARK_0);
1788 + XA_BUG_ON(xa, !xa_get_mark(xa, index, XA_MARK_0));
1789 +
1790 + xa_destroy(xa);
1791 +}
1792 +
1793 +static noinline void check_split(struct xarray *xa)
1794 +{
1795 + unsigned int order;
1796 +
1797 + XA_BUG_ON(xa, !xa_empty(xa));
1798 +
1799 + for (order = 1; order < 2 * XA_CHUNK_SHIFT; order++) {
1800 + check_split_1(xa, 0, order);
1801 + check_split_1(xa, 1UL << order, order);
1802 + check_split_1(xa, 3UL << order, order);
1803 + }
1804 +}
1805 +#else
1806 +static void check_split(struct xarray *xa) { }
1807 +#endif
1808 +
1809 static void check_align_1(struct xarray *xa, char *name)
1810 {
1811 int i;
1812 @@ -1649,6 +1692,26 @@ static noinline void check_account(struct xarray *xa)
1813 #endif
1814 }
1815
1816 +static noinline void check_get_order(struct xarray *xa)
1817 +{
1818 + unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1;
1819 + unsigned int order;
1820 + unsigned long i, j;
1821 +
1822 + for (i = 0; i < 3; i++)
1823 + XA_BUG_ON(xa, xa_get_order(xa, i) != 0);
1824 +
1825 + for (order = 0; order < max_order; order++) {
1826 + for (i = 0; i < 10; i++) {
1827 + xa_store_order(xa, i << order, order,
1828 + xa_mk_index(i << order), GFP_KERNEL);
1829 + for (j = i << order; j < (i + 1) << order; j++)
1830 + XA_BUG_ON(xa, xa_get_order(xa, j) != order);
1831 + xa_erase(xa, i << order);
1832 + }
1833 + }
1834 +}
1835 +
1836 static noinline void check_destroy(struct xarray *xa)
1837 {
1838 unsigned long index;
1839 @@ -1697,6 +1760,7 @@ static int xarray_checks(void)
1840 check_reserve(&array);
1841 check_reserve(&xa0);
1842 check_multi_store(&array);
1843 + check_get_order(&array);
1844 check_xa_alloc();
1845 check_find(&array);
1846 check_find_entry(&array);
1847 @@ -1708,6 +1772,7 @@ static int xarray_checks(void)
1848 check_store_range(&array);
1849 check_store_iter(&array);
1850 check_align(&xa0);
1851 + check_split(&array);
1852
1853 check_workingset(&array, 0);
1854 check_workingset(&array, 64);
1855 diff --git a/lib/xarray.c b/lib/xarray.c
1856 index 08d71c7b75990..7d22b30591275 100644
1857 --- a/lib/xarray.c
1858 +++ b/lib/xarray.c
1859 @@ -266,13 +266,14 @@ static void xa_node_free(struct xa_node *node)
1860 */
1861 static void xas_destroy(struct xa_state *xas)
1862 {
1863 - struct xa_node *node = xas->xa_alloc;
1864 + struct xa_node *next, *node = xas->xa_alloc;
1865
1866 - if (!node)
1867 - return;
1868 - XA_NODE_BUG_ON(node, !list_empty(&node->private_list));
1869 - kmem_cache_free(radix_tree_node_cachep, node);
1870 - xas->xa_alloc = NULL;
1871 + while (node) {
1872 + XA_NODE_BUG_ON(node, !list_empty(&node->private_list));
1873 + next = rcu_dereference_raw(node->parent);
1874 + radix_tree_node_rcu_free(&node->rcu_head);
1875 + xas->xa_alloc = node = next;
1876 + }
1877 }
1878
1879 /**
1880 @@ -304,6 +305,7 @@ bool xas_nomem(struct xa_state *xas, gfp_t gfp)
1881 xas->xa_alloc = kmem_cache_alloc(radix_tree_node_cachep, gfp);
1882 if (!xas->xa_alloc)
1883 return false;
1884 + xas->xa_alloc->parent = NULL;
1885 XA_NODE_BUG_ON(xas->xa_alloc, !list_empty(&xas->xa_alloc->private_list));
1886 xas->xa_node = XAS_RESTART;
1887 return true;
1888 @@ -339,6 +341,7 @@ static bool __xas_nomem(struct xa_state *xas, gfp_t gfp)
1889 }
1890 if (!xas->xa_alloc)
1891 return false;
1892 + xas->xa_alloc->parent = NULL;
1893 XA_NODE_BUG_ON(xas->xa_alloc, !list_empty(&xas->xa_alloc->private_list));
1894 xas->xa_node = XAS_RESTART;
1895 return true;
1896 @@ -403,7 +406,7 @@ static unsigned long xas_size(const struct xa_state *xas)
1897 /*
1898 * Use this to calculate the maximum index that will need to be created
1899 * in order to add the entry described by @xas. Because we cannot store a
1900 - * multiple-index entry at index 0, the calculation is a little more complex
1901 + * multi-index entry at index 0, the calculation is a little more complex
1902 * than you might expect.
1903 */
1904 static unsigned long xas_max(struct xa_state *xas)
1905 @@ -946,6 +949,153 @@ void xas_init_marks(const struct xa_state *xas)
1906 }
1907 EXPORT_SYMBOL_GPL(xas_init_marks);
1908
1909 +#ifdef CONFIG_XARRAY_MULTI
1910 +static unsigned int node_get_marks(struct xa_node *node, unsigned int offset)
1911 +{
1912 + unsigned int marks = 0;
1913 + xa_mark_t mark = XA_MARK_0;
1914 +
1915 + for (;;) {
1916 + if (node_get_mark(node, offset, mark))
1917 + marks |= 1 << (__force unsigned int)mark;
1918 + if (mark == XA_MARK_MAX)
1919 + break;
1920 + mark_inc(mark);
1921 + }
1922 +
1923 + return marks;
1924 +}
1925 +
1926 +static void node_set_marks(struct xa_node *node, unsigned int offset,
1927 + struct xa_node *child, unsigned int marks)
1928 +{
1929 + xa_mark_t mark = XA_MARK_0;
1930 +
1931 + for (;;) {
1932 + if (marks & (1 << (__force unsigned int)mark)) {
1933 + node_set_mark(node, offset, mark);
1934 + if (child)
1935 + node_mark_all(child, mark);
1936 + }
1937 + if (mark == XA_MARK_MAX)
1938 + break;
1939 + mark_inc(mark);
1940 + }
1941 +}
1942 +
1943 +/**
1944 + * xas_split_alloc() - Allocate memory for splitting an entry.
1945 + * @xas: XArray operation state.
1946 + * @entry: New entry which will be stored in the array.
1947 + * @order: New entry order.
1948 + * @gfp: Memory allocation flags.
1949 + *
1950 + * This function should be called before calling xas_split().
1951 + * If necessary, it will allocate new nodes (and fill them with @entry)
1952 + * to prepare for the upcoming split of an entry of @order size into
1953 + * entries of the order stored in the @xas.
1954 + *
1955 + * Context: May sleep if @gfp flags permit.
1956 + */
1957 +void xas_split_alloc(struct xa_state *xas, void *entry, unsigned int order,
1958 + gfp_t gfp)
1959 +{
1960 + unsigned int sibs = (1 << (order % XA_CHUNK_SHIFT)) - 1;
1961 + unsigned int mask = xas->xa_sibs;
1962 +
1963 + /* XXX: no support for splitting really large entries yet */
1964 + if (WARN_ON(xas->xa_shift + 2 * XA_CHUNK_SHIFT < order))
1965 + goto nomem;
1966 + if (xas->xa_shift + XA_CHUNK_SHIFT > order)
1967 + return;
1968 +
1969 + do {
1970 + unsigned int i;
1971 + void *sibling;
1972 + struct xa_node *node;
1973 +
1974 + node = kmem_cache_alloc(radix_tree_node_cachep, gfp);
1975 + if (!node)
1976 + goto nomem;
1977 + node->array = xas->xa;
1978 + for (i = 0; i < XA_CHUNK_SIZE; i++) {
1979 + if ((i & mask) == 0) {
1980 + RCU_INIT_POINTER(node->slots[i], entry);
1981 + sibling = xa_mk_sibling(0);
1982 + } else {
1983 + RCU_INIT_POINTER(node->slots[i], sibling);
1984 + }
1985 + }
1986 + RCU_INIT_POINTER(node->parent, xas->xa_alloc);
1987 + xas->xa_alloc = node;
1988 + } while (sibs-- > 0);
1989 +
1990 + return;
1991 +nomem:
1992 + xas_destroy(xas);
1993 + xas_set_err(xas, -ENOMEM);
1994 +}
1995 +EXPORT_SYMBOL_GPL(xas_split_alloc);
1996 +
1997 +/**
1998 + * xas_split() - Split a multi-index entry into smaller entries.
1999 + * @xas: XArray operation state.
2000 + * @entry: New entry to store in the array.
2001 + * @order: New entry order.
2002 + *
2003 + * The value in the entry is copied to all the replacement entries.
2004 + *
2005 + * Context: Any context. The caller should hold the xa_lock.
2006 + */
2007 +void xas_split(struct xa_state *xas, void *entry, unsigned int order)
2008 +{
2009 + unsigned int sibs = (1 << (order % XA_CHUNK_SHIFT)) - 1;
2010 + unsigned int offset, marks;
2011 + struct xa_node *node;
2012 + void *curr = xas_load(xas);
2013 + int values = 0;
2014 +
2015 + node = xas->xa_node;
2016 + if (xas_top(node))
2017 + return;
2018 +
2019 + marks = node_get_marks(node, xas->xa_offset);
2020 +
2021 + offset = xas->xa_offset + sibs;
2022 + do {
2023 + if (xas->xa_shift < node->shift) {
2024 + struct xa_node *child = xas->xa_alloc;
2025 +
2026 + xas->xa_alloc = rcu_dereference_raw(child->parent);
2027 + child->shift = node->shift - XA_CHUNK_SHIFT;
2028 + child->offset = offset;
2029 + child->count = XA_CHUNK_SIZE;
2030 + child->nr_values = xa_is_value(entry) ?
2031 + XA_CHUNK_SIZE : 0;
2032 + RCU_INIT_POINTER(child->parent, node);
2033 + node_set_marks(node, offset, child, marks);
2034 + rcu_assign_pointer(node->slots[offset],
2035 + xa_mk_node(child));
2036 + if (xa_is_value(curr))
2037 + values--;
2038 + } else {
2039 + unsigned int canon = offset - xas->xa_sibs;
2040 +
2041 + node_set_marks(node, canon, NULL, marks);
2042 + rcu_assign_pointer(node->slots[canon], entry);
2043 + while (offset > canon)
2044 + rcu_assign_pointer(node->slots[offset--],
2045 + xa_mk_sibling(canon));
2046 + values += (xa_is_value(entry) - xa_is_value(curr)) *
2047 + (xas->xa_sibs + 1);
2048 + }
2049 + } while (offset-- > xas->xa_offset);
2050 +
2051 + node->nr_values += values;
2052 +}
2053 +EXPORT_SYMBOL_GPL(xas_split);
2054 +#endif
2055 +
2056 /**
2057 * xas_pause() - Pause a walk to drop a lock.
2058 * @xas: XArray operation state.
2059 @@ -1407,7 +1557,7 @@ EXPORT_SYMBOL(__xa_store);
2060 * @gfp: Memory allocation flags.
2061 *
2062 * After this function returns, loads from this index will return @entry.
2063 - * Storing into an existing multislot entry updates the entry of every index.
2064 + * Storing into an existing multi-index entry updates the entry of every index.
2065 * The marks associated with @index are unaffected unless @entry is %NULL.
2066 *
2067 * Context: Any context. Takes and releases the xa_lock.
2068 @@ -1549,7 +1699,7 @@ static void xas_set_range(struct xa_state *xas, unsigned long first,
2069 *
2070 * After this function returns, loads from any index between @first and @last,
2071 * inclusive will return @entry.
2072 - * Storing into an existing multislot entry updates the entry of every index.
2073 + * Storing into an existing multi-index entry updates the entry of every index.
2074 * The marks associated with @index are unaffected unless @entry is %NULL.
2075 *
2076 * Context: Process context. Takes and releases the xa_lock. May sleep
2077 @@ -1592,6 +1742,46 @@ unlock:
2078 return xas_result(&xas, NULL);
2079 }
2080 EXPORT_SYMBOL(xa_store_range);
2081 +
2082 +/**
2083 + * xa_get_order() - Get the order of an entry.
2084 + * @xa: XArray.
2085 + * @index: Index of the entry.
2086 + *
2087 + * Return: A number between 0 and 63 indicating the order of the entry.
2088 + */
2089 +int xa_get_order(struct xarray *xa, unsigned long index)
2090 +{
2091 + XA_STATE(xas, xa, index);
2092 + void *entry;
2093 + int order = 0;
2094 +
2095 + rcu_read_lock();
2096 + entry = xas_load(&xas);
2097 +
2098 + if (!entry)
2099 + goto unlock;
2100 +
2101 + if (!xas.xa_node)
2102 + goto unlock;
2103 +
2104 + for (;;) {
2105 + unsigned int slot = xas.xa_offset + (1 << order);
2106 +
2107 + if (slot >= XA_CHUNK_SIZE)
2108 + break;
2109 + if (!xa_is_sibling(xas.xa_node->slots[slot]))
2110 + break;
2111 + order++;
2112 + }
2113 +
2114 + order += xas.xa_node->shift;
2115 +unlock:
2116 + rcu_read_unlock();
2117 +
2118 + return order;
2119 +}
2120 +EXPORT_SYMBOL(xa_get_order);
2121 #endif /* CONFIG_XARRAY_MULTI */
2122
2123 /**
2124 diff --git a/mm/filemap.c b/mm/filemap.c
2125 index db542b4948838..c10e237cc2c6e 100644
2126 --- a/mm/filemap.c
2127 +++ b/mm/filemap.c
2128 @@ -856,7 +856,6 @@ noinline int __add_to_page_cache_locked(struct page *page,
2129 int huge = PageHuge(page);
2130 struct mem_cgroup *memcg;
2131 int error;
2132 - void *old;
2133
2134 VM_BUG_ON_PAGE(!PageLocked(page), page);
2135 VM_BUG_ON_PAGE(PageSwapBacked(page), page);
2136 @@ -872,21 +871,41 @@ noinline int __add_to_page_cache_locked(struct page *page,
2137 get_page(page);
2138 page->mapping = mapping;
2139 page->index = offset;
2140 + gfp_mask &= GFP_RECLAIM_MASK;
2141
2142 do {
2143 + unsigned int order = xa_get_order(xas.xa, xas.xa_index);
2144 + void *entry, *old = NULL;
2145 +
2146 + if (order > thp_order(page))
2147 + xas_split_alloc(&xas, xa_load(xas.xa, xas.xa_index),
2148 + order, gfp_mask);
2149 xas_lock_irq(&xas);
2150 - old = xas_load(&xas);
2151 - if (old && !xa_is_value(old))
2152 - xas_set_err(&xas, -EEXIST);
2153 + xas_for_each_conflict(&xas, entry) {
2154 + old = entry;
2155 + if (!xa_is_value(entry)) {
2156 + xas_set_err(&xas, -EEXIST);
2157 + goto unlock;
2158 + }
2159 + }
2160 +
2161 + if (old) {
2162 + if (shadowp)
2163 + *shadowp = old;
2164 + /* entry may have been split before we acquired lock */
2165 + order = xa_get_order(xas.xa, xas.xa_index);
2166 + if (order > thp_order(page)) {
2167 + xas_split(&xas, old, order);
2168 + xas_reset(&xas);
2169 + }
2170 + }
2171 +
2172 xas_store(&xas, page);
2173 if (xas_error(&xas))
2174 goto unlock;
2175
2176 - if (xa_is_value(old)) {
2177 + if (old)
2178 mapping->nrexceptional--;
2179 - if (shadowp)
2180 - *shadowp = old;
2181 - }
2182 mapping->nrpages++;
2183
2184 /* hugetlb pages do not participate in page cache accounting */
2185 @@ -894,7 +913,7 @@ noinline int __add_to_page_cache_locked(struct page *page,
2186 __inc_node_page_state(page, NR_FILE_PAGES);
2187 unlock:
2188 xas_unlock_irq(&xas);
2189 - } while (xas_nomem(&xas, gfp_mask & GFP_RECLAIM_MASK));
2190 + } while (xas_nomem(&xas, gfp_mask));
2191
2192 if (xas_error(&xas))
2193 goto error;
2194 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
2195 index 3b08e34a775df..fe15e7d8220ab 100644
2196 --- a/mm/hugetlb.c
2197 +++ b/mm/hugetlb.c
2198 @@ -4338,10 +4338,20 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
2199 struct page *page;
2200
2201 if (!*pagep) {
2202 - ret = -ENOMEM;
2203 + /* If a page already exists, then it's UFFDIO_COPY for
2204 + * a non-missing case. Return -EEXIST.
2205 + */
2206 + if (vm_shared &&
2207 + hugetlbfs_pagecache_present(h, dst_vma, dst_addr)) {
2208 + ret = -EEXIST;
2209 + goto out;
2210 + }
2211 +
2212 page = alloc_huge_page(dst_vma, dst_addr, 0);
2213 - if (IS_ERR(page))
2214 + if (IS_ERR(page)) {
2215 + ret = -ENOMEM;
2216 goto out;
2217 + }
2218
2219 ret = copy_huge_page_from_user(page,
2220 (const void __user *) src_addr,
2221 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
2222 index 83b324419ad3d..21a7ea9b70c8a 100644
2223 --- a/net/bluetooth/hci_core.c
2224 +++ b/net/bluetooth/hci_core.c
2225 @@ -1561,8 +1561,13 @@ setup_failed:
2226 } else {
2227 /* Init failed, cleanup */
2228 flush_work(&hdev->tx_work);
2229 - flush_work(&hdev->cmd_work);
2230 +
2231 + /* Since hci_rx_work() is possible to awake new cmd_work
2232 + * it should be flushed first to avoid unexpected call of
2233 + * hci_cmd_work()
2234 + */
2235 flush_work(&hdev->rx_work);
2236 + flush_work(&hdev->cmd_work);
2237
2238 skb_queue_purge(&hdev->cmd_q);
2239 skb_queue_purge(&hdev->rx_q);
2240 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
2241 index 8159b344deef5..8d2c26c4b6d3d 100644
2242 --- a/net/bluetooth/hci_sock.c
2243 +++ b/net/bluetooth/hci_sock.c
2244 @@ -755,7 +755,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event)
2245 /* Detach sockets from device */
2246 read_lock(&hci_sk_list.lock);
2247 sk_for_each(sk, &hci_sk_list.head) {
2248 - bh_lock_sock_nested(sk);
2249 + lock_sock(sk);
2250 if (hci_pi(sk)->hdev == hdev) {
2251 hci_pi(sk)->hdev = NULL;
2252 sk->sk_err = EPIPE;
2253 @@ -764,7 +764,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event)
2254
2255 hci_dev_put(hdev);
2256 }
2257 - bh_unlock_sock(sk);
2258 + release_sock(sk);
2259 }
2260 read_unlock(&hci_sk_list.lock);
2261 }
2262 diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
2263 index 03c7cdd8e4cbf..8a3c19b9a9958 100644
2264 --- a/net/caif/caif_dev.c
2265 +++ b/net/caif/caif_dev.c
2266 @@ -307,7 +307,7 @@ static void dev_flowctrl(struct net_device *dev, int on)
2267 caifd_put(caifd);
2268 }
2269
2270 -void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
2271 +int caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
2272 struct cflayer *link_support, int head_room,
2273 struct cflayer **layer,
2274 int (**rcv_func)(struct sk_buff *, struct net_device *,
2275 @@ -318,11 +318,12 @@ void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
2276 enum cfcnfg_phy_preference pref;
2277 struct cfcnfg *cfg = get_cfcnfg(dev_net(dev));
2278 struct caif_device_entry_list *caifdevs;
2279 + int res;
2280
2281 caifdevs = caif_device_list(dev_net(dev));
2282 caifd = caif_device_alloc(dev);
2283 if (!caifd)
2284 - return;
2285 + return -ENOMEM;
2286 *layer = &caifd->layer;
2287 spin_lock_init(&caifd->flow_lock);
2288
2289 @@ -343,7 +344,7 @@ void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
2290 strlcpy(caifd->layer.name, dev->name,
2291 sizeof(caifd->layer.name));
2292 caifd->layer.transmit = transmit;
2293 - cfcnfg_add_phy_layer(cfg,
2294 + res = cfcnfg_add_phy_layer(cfg,
2295 dev,
2296 &caifd->layer,
2297 pref,
2298 @@ -353,6 +354,7 @@ void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
2299 mutex_unlock(&caifdevs->lock);
2300 if (rcv_func)
2301 *rcv_func = receive;
2302 + return res;
2303 }
2304 EXPORT_SYMBOL(caif_enroll_dev);
2305
2306 @@ -367,6 +369,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
2307 struct cflayer *layer, *link_support;
2308 int head_room = 0;
2309 struct caif_device_entry_list *caifdevs;
2310 + int res;
2311
2312 cfg = get_cfcnfg(dev_net(dev));
2313 caifdevs = caif_device_list(dev_net(dev));
2314 @@ -392,8 +395,10 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
2315 break;
2316 }
2317 }
2318 - caif_enroll_dev(dev, caifdev, link_support, head_room,
2319 + res = caif_enroll_dev(dev, caifdev, link_support, head_room,
2320 &layer, NULL);
2321 + if (res)
2322 + cfserl_release(link_support);
2323 caifdev->flowctrl = dev_flowctrl;
2324 break;
2325
2326 diff --git a/net/caif/caif_usb.c b/net/caif/caif_usb.c
2327 index 76bd67891fb39..46c62dd1479b8 100644
2328 --- a/net/caif/caif_usb.c
2329 +++ b/net/caif/caif_usb.c
2330 @@ -115,6 +115,11 @@ static struct cflayer *cfusbl_create(int phyid, u8 ethaddr[ETH_ALEN],
2331 return (struct cflayer *) this;
2332 }
2333
2334 +static void cfusbl_release(struct cflayer *layer)
2335 +{
2336 + kfree(layer);
2337 +}
2338 +
2339 static struct packet_type caif_usb_type __read_mostly = {
2340 .type = cpu_to_be16(ETH_P_802_EX1),
2341 };
2342 @@ -127,6 +132,7 @@ static int cfusbl_device_notify(struct notifier_block *me, unsigned long what,
2343 struct cflayer *layer, *link_support;
2344 struct usbnet *usbnet;
2345 struct usb_device *usbdev;
2346 + int res;
2347
2348 /* Check whether we have a NCM device, and find its VID/PID. */
2349 if (!(dev->dev.parent && dev->dev.parent->driver &&
2350 @@ -169,8 +175,11 @@ static int cfusbl_device_notify(struct notifier_block *me, unsigned long what,
2351 if (dev->num_tx_queues > 1)
2352 pr_warn("USB device uses more than one tx queue\n");
2353
2354 - caif_enroll_dev(dev, &common, link_support, CFUSB_MAX_HEADLEN,
2355 + res = caif_enroll_dev(dev, &common, link_support, CFUSB_MAX_HEADLEN,
2356 &layer, &caif_usb_type.func);
2357 + if (res)
2358 + goto err;
2359 +
2360 if (!pack_added)
2361 dev_add_pack(&caif_usb_type);
2362 pack_added = true;
2363 @@ -178,6 +187,9 @@ static int cfusbl_device_notify(struct notifier_block *me, unsigned long what,
2364 strlcpy(layer->name, dev->name, sizeof(layer->name));
2365
2366 return 0;
2367 +err:
2368 + cfusbl_release(link_support);
2369 + return res;
2370 }
2371
2372 static struct notifier_block caif_device_notifier = {
2373 diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c
2374 index 399239a14420f..cac30e676ac94 100644
2375 --- a/net/caif/cfcnfg.c
2376 +++ b/net/caif/cfcnfg.c
2377 @@ -450,7 +450,7 @@ unlock:
2378 rcu_read_unlock();
2379 }
2380
2381 -void
2382 +int
2383 cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
2384 struct net_device *dev, struct cflayer *phy_layer,
2385 enum cfcnfg_phy_preference pref,
2386 @@ -459,7 +459,7 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
2387 {
2388 struct cflayer *frml;
2389 struct cfcnfg_phyinfo *phyinfo = NULL;
2390 - int i;
2391 + int i, res = 0;
2392 u8 phyid;
2393
2394 mutex_lock(&cnfg->lock);
2395 @@ -473,12 +473,15 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
2396 goto got_phyid;
2397 }
2398 pr_warn("Too many CAIF Link Layers (max 6)\n");
2399 + res = -EEXIST;
2400 goto out;
2401
2402 got_phyid:
2403 phyinfo = kzalloc(sizeof(struct cfcnfg_phyinfo), GFP_ATOMIC);
2404 - if (!phyinfo)
2405 + if (!phyinfo) {
2406 + res = -ENOMEM;
2407 goto out_err;
2408 + }
2409
2410 phy_layer->id = phyid;
2411 phyinfo->pref = pref;
2412 @@ -492,8 +495,10 @@ got_phyid:
2413
2414 frml = cffrml_create(phyid, fcs);
2415
2416 - if (!frml)
2417 + if (!frml) {
2418 + res = -ENOMEM;
2419 goto out_err;
2420 + }
2421 phyinfo->frm_layer = frml;
2422 layer_set_up(frml, cnfg->mux);
2423
2424 @@ -511,11 +516,12 @@ got_phyid:
2425 list_add_rcu(&phyinfo->node, &cnfg->phys);
2426 out:
2427 mutex_unlock(&cnfg->lock);
2428 - return;
2429 + return res;
2430
2431 out_err:
2432 kfree(phyinfo);
2433 mutex_unlock(&cnfg->lock);
2434 + return res;
2435 }
2436 EXPORT_SYMBOL(cfcnfg_add_phy_layer);
2437
2438 diff --git a/net/caif/cfserl.c b/net/caif/cfserl.c
2439 index e11725a4bb0ed..40cd57ad0a0f4 100644
2440 --- a/net/caif/cfserl.c
2441 +++ b/net/caif/cfserl.c
2442 @@ -31,6 +31,11 @@ static int cfserl_transmit(struct cflayer *layr, struct cfpkt *pkt);
2443 static void cfserl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
2444 int phyid);
2445
2446 +void cfserl_release(struct cflayer *layer)
2447 +{
2448 + kfree(layer);
2449 +}
2450 +
2451 struct cflayer *cfserl_create(int instance, bool use_stx)
2452 {
2453 struct cfserl *this = kzalloc(sizeof(struct cfserl), GFP_ATOMIC);
2454 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
2455 index 472a615775f32..f94d405358a21 100644
2456 --- a/net/core/neighbour.c
2457 +++ b/net/core/neighbour.c
2458 @@ -239,6 +239,7 @@ static int neigh_forced_gc(struct neigh_table *tbl)
2459
2460 write_lock(&n->lock);
2461 if ((n->nud_state == NUD_FAILED) ||
2462 + (n->nud_state == NUD_NOARP) ||
2463 (tbl->is_multicast &&
2464 tbl->is_multicast(n->primary_key)) ||
2465 time_after(tref, n->updated))
2466 diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
2467 index d19c40c684e80..71be751123210 100644
2468 --- a/net/ieee802154/nl-mac.c
2469 +++ b/net/ieee802154/nl-mac.c
2470 @@ -680,8 +680,10 @@ int ieee802154_llsec_getparams(struct sk_buff *skb, struct genl_info *info)
2471 nla_put_u8(msg, IEEE802154_ATTR_LLSEC_SECLEVEL, params.out_level) ||
2472 nla_put_u32(msg, IEEE802154_ATTR_LLSEC_FRAME_COUNTER,
2473 be32_to_cpu(params.frame_counter)) ||
2474 - ieee802154_llsec_fill_key_id(msg, &params.out_key))
2475 + ieee802154_llsec_fill_key_id(msg, &params.out_key)) {
2476 + rc = -ENOBUFS;
2477 goto out_free;
2478 + }
2479
2480 dev_put(dev);
2481
2482 diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
2483 index 2cdc7e63fe172..88215b5c93aa4 100644
2484 --- a/net/ieee802154/nl-phy.c
2485 +++ b/net/ieee802154/nl-phy.c
2486 @@ -241,8 +241,10 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
2487 }
2488
2489 if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) ||
2490 - nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name))
2491 + nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name)) {
2492 + rc = -EMSGSIZE;
2493 goto nla_put_failure;
2494 + }
2495 dev_put(dev);
2496
2497 wpan_phy_put(phy);
2498 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
2499 index 3a9bd9687e7d1..b903fe28ce507 100644
2500 --- a/net/ipv6/route.c
2501 +++ b/net/ipv6/route.c
2502 @@ -3688,11 +3688,11 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
2503 if (nh) {
2504 if (rt->fib6_src.plen) {
2505 NL_SET_ERR_MSG(extack, "Nexthops can not be used with source routing");
2506 - goto out;
2507 + goto out_free;
2508 }
2509 if (!nexthop_get(nh)) {
2510 NL_SET_ERR_MSG(extack, "Nexthop has been deleted");
2511 - goto out;
2512 + goto out_free;
2513 }
2514 rt->nh = nh;
2515 fib6_nh = nexthop_fib6_nh(rt->nh);
2516 @@ -3729,6 +3729,10 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
2517 out:
2518 fib6_info_release(rt);
2519 return ERR_PTR(err);
2520 +out_free:
2521 + ip_fib_metrics_put(rt->fib6_metrics);
2522 + kfree(rt);
2523 + return ERR_PTR(err);
2524 }
2525
2526 int ip6_route_add(struct fib6_config *cfg, gfp_t gfp_flags,
2527 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
2528 index 99168af0c28d9..f93fa0e210979 100644
2529 --- a/net/netfilter/ipvs/ip_vs_ctl.c
2530 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
2531 @@ -1340,7 +1340,7 @@ ip_vs_add_service(struct netns_ipvs *ipvs, struct ip_vs_service_user_kern *u,
2532 ip_vs_addr_copy(svc->af, &svc->addr, &u->addr);
2533 svc->port = u->port;
2534 svc->fwmark = u->fwmark;
2535 - svc->flags = u->flags;
2536 + svc->flags = u->flags & ~IP_VS_SVC_F_HASHED;
2537 svc->timeout = u->timeout * HZ;
2538 svc->netmask = u->netmask;
2539 svc->ipvs = ipvs;
2540 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
2541 index aaf4293ddd459..75e6b429635da 100644
2542 --- a/net/netfilter/nf_conntrack_proto.c
2543 +++ b/net/netfilter/nf_conntrack_proto.c
2544 @@ -660,7 +660,7 @@ int nf_conntrack_proto_init(void)
2545
2546 #if IS_ENABLED(CONFIG_IPV6)
2547 cleanup_sockopt:
2548 - nf_unregister_sockopt(&so_getorigdst6);
2549 + nf_unregister_sockopt(&so_getorigdst);
2550 #endif
2551 return ret;
2552 }
2553 diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
2554 index 81406b93f126d..3d5fc07b2530b 100644
2555 --- a/net/netfilter/nfnetlink_cthelper.c
2556 +++ b/net/netfilter/nfnetlink_cthelper.c
2557 @@ -380,10 +380,14 @@ static int
2558 nfnl_cthelper_update(const struct nlattr * const tb[],
2559 struct nf_conntrack_helper *helper)
2560 {
2561 + u32 size;
2562 int ret;
2563
2564 - if (tb[NFCTH_PRIV_DATA_LEN])
2565 - return -EBUSY;
2566 + if (tb[NFCTH_PRIV_DATA_LEN]) {
2567 + size = ntohl(nla_get_be32(tb[NFCTH_PRIV_DATA_LEN]));
2568 + if (size != helper->data_len)
2569 + return -EBUSY;
2570 + }
2571
2572 if (tb[NFCTH_POLICY]) {
2573 ret = nfnl_cthelper_update_policy(helper, tb[NFCTH_POLICY]);
2574 diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
2575 index 2042c6f4629cc..28991730728b9 100644
2576 --- a/net/netfilter/nft_ct.c
2577 +++ b/net/netfilter/nft_ct.c
2578 @@ -1218,7 +1218,7 @@ static void nft_ct_expect_obj_eval(struct nft_object *obj,
2579 struct nf_conn *ct;
2580
2581 ct = nf_ct_get(pkt->skb, &ctinfo);
2582 - if (!ct || ctinfo == IP_CT_UNTRACKED) {
2583 + if (!ct || nf_ct_is_confirmed(ct) || nf_ct_is_template(ct)) {
2584 regs->verdict.code = NFT_BREAK;
2585 return;
2586 }
2587 diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
2588 index 0d4246af6c02b..a7e861eede2d9 100644
2589 --- a/net/nfc/llcp_sock.c
2590 +++ b/net/nfc/llcp_sock.c
2591 @@ -110,6 +110,7 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
2592 if (!llcp_sock->service_name) {
2593 nfc_llcp_local_put(llcp_sock->local);
2594 llcp_sock->local = NULL;
2595 + llcp_sock->dev = NULL;
2596 ret = -ENOMEM;
2597 goto put_dev;
2598 }
2599 @@ -119,6 +120,7 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
2600 llcp_sock->local = NULL;
2601 kfree(llcp_sock->service_name);
2602 llcp_sock->service_name = NULL;
2603 + llcp_sock->dev = NULL;
2604 ret = -EADDRINUSE;
2605 goto put_dev;
2606 }
2607 diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
2608 index 6119c31dcd072..31eb8eefc8681 100644
2609 --- a/net/sched/act_ct.c
2610 +++ b/net/sched/act_ct.c
2611 @@ -648,9 +648,6 @@ static int tcf_ct_fill_params(struct net *net,
2612 sizeof(p->zone));
2613 }
2614
2615 - if (p->zone == NF_CT_DEFAULT_ZONE_ID)
2616 - return 0;
2617 -
2618 nf_ct_zone_init(&zone, p->zone, NF_CT_DEFAULT_ZONE_DIR, 0);
2619 tmpl = nf_ct_tmpl_alloc(net, &zone, GFP_KERNEL);
2620 if (!tmpl) {
2621 diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
2622 index 0214aa1c44278..8bd2454cc89dc 100644
2623 --- a/net/tipc/bearer.c
2624 +++ b/net/tipc/bearer.c
2625 @@ -233,7 +233,8 @@ void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest)
2626 */
2627 static int tipc_enable_bearer(struct net *net, const char *name,
2628 u32 disc_domain, u32 prio,
2629 - struct nlattr *attr[])
2630 + struct nlattr *attr[],
2631 + struct netlink_ext_ack *extack)
2632 {
2633 struct tipc_net *tn = tipc_net(net);
2634 struct tipc_bearer_names b_names;
2635 @@ -244,20 +245,24 @@ static int tipc_enable_bearer(struct net *net, const char *name,
2636 int bearer_id = 0;
2637 int res = -EINVAL;
2638 char *errstr = "";
2639 + u32 i;
2640
2641 if (!bearer_name_validate(name, &b_names)) {
2642 errstr = "illegal name";
2643 + NL_SET_ERR_MSG(extack, "Illegal name");
2644 goto rejected;
2645 }
2646
2647 if (prio > TIPC_MAX_LINK_PRI && prio != TIPC_MEDIA_LINK_PRI) {
2648 errstr = "illegal priority";
2649 + NL_SET_ERR_MSG(extack, "Illegal priority");
2650 goto rejected;
2651 }
2652
2653 m = tipc_media_find(b_names.media_name);
2654 if (!m) {
2655 errstr = "media not registered";
2656 + NL_SET_ERR_MSG(extack, "Media not registered");
2657 goto rejected;
2658 }
2659
2660 @@ -265,33 +270,43 @@ static int tipc_enable_bearer(struct net *net, const char *name,
2661 prio = m->priority;
2662
2663 /* Check new bearer vs existing ones and find free bearer id if any */
2664 - while (bearer_id < MAX_BEARERS) {
2665 - b = rtnl_dereference(tn->bearer_list[bearer_id]);
2666 - if (!b)
2667 - break;
2668 + bearer_id = MAX_BEARERS;
2669 + i = MAX_BEARERS;
2670 + while (i-- != 0) {
2671 + b = rtnl_dereference(tn->bearer_list[i]);
2672 + if (!b) {
2673 + bearer_id = i;
2674 + continue;
2675 + }
2676 if (!strcmp(name, b->name)) {
2677 errstr = "already enabled";
2678 + NL_SET_ERR_MSG(extack, "Already enabled");
2679 goto rejected;
2680 }
2681 - bearer_id++;
2682 - if (b->priority != prio)
2683 - continue;
2684 - if (++with_this_prio <= 2)
2685 - continue;
2686 - pr_warn("Bearer <%s>: already 2 bearers with priority %u\n",
2687 - name, prio);
2688 - if (prio == TIPC_MIN_LINK_PRI) {
2689 - errstr = "cannot adjust to lower";
2690 - goto rejected;
2691 +
2692 + if (b->priority == prio &&
2693 + (++with_this_prio > 2)) {
2694 + pr_warn("Bearer <%s>: already 2 bearers with priority %u\n",
2695 + name, prio);
2696 +
2697 + if (prio == TIPC_MIN_LINK_PRI) {
2698 + errstr = "cannot adjust to lower";
2699 + NL_SET_ERR_MSG(extack, "Cannot adjust to lower");
2700 + goto rejected;
2701 + }
2702 +
2703 + pr_warn("Bearer <%s>: trying with adjusted priority\n",
2704 + name);
2705 + prio--;
2706 + bearer_id = MAX_BEARERS;
2707 + i = MAX_BEARERS;
2708 + with_this_prio = 1;
2709 }
2710 - pr_warn("Bearer <%s>: trying with adjusted priority\n", name);
2711 - prio--;
2712 - bearer_id = 0;
2713 - with_this_prio = 1;
2714 }
2715
2716 if (bearer_id >= MAX_BEARERS) {
2717 errstr = "max 3 bearers permitted";
2718 + NL_SET_ERR_MSG(extack, "Max 3 bearers permitted");
2719 goto rejected;
2720 }
2721
2722 @@ -305,6 +320,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
2723 if (res) {
2724 kfree(b);
2725 errstr = "failed to enable media";
2726 + NL_SET_ERR_MSG(extack, "Failed to enable media");
2727 goto rejected;
2728 }
2729
2730 @@ -320,6 +336,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
2731 if (res) {
2732 bearer_disable(net, b);
2733 errstr = "failed to create discoverer";
2734 + NL_SET_ERR_MSG(extack, "Failed to create discoverer");
2735 goto rejected;
2736 }
2737
2738 @@ -862,6 +879,7 @@ int tipc_nl_bearer_get(struct sk_buff *skb, struct genl_info *info)
2739 bearer = tipc_bearer_find(net, name);
2740 if (!bearer) {
2741 err = -EINVAL;
2742 + NL_SET_ERR_MSG(info->extack, "Bearer not found");
2743 goto err_out;
2744 }
2745
2746 @@ -901,8 +919,10 @@ int __tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info)
2747 name = nla_data(attrs[TIPC_NLA_BEARER_NAME]);
2748
2749 bearer = tipc_bearer_find(net, name);
2750 - if (!bearer)
2751 + if (!bearer) {
2752 + NL_SET_ERR_MSG(info->extack, "Bearer not found");
2753 return -EINVAL;
2754 + }
2755
2756 bearer_disable(net, bearer);
2757
2758 @@ -960,7 +980,8 @@ int __tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info)
2759 prio = nla_get_u32(props[TIPC_NLA_PROP_PRIO]);
2760 }
2761
2762 - return tipc_enable_bearer(net, bearer, domain, prio, attrs);
2763 + return tipc_enable_bearer(net, bearer, domain, prio, attrs,
2764 + info->extack);
2765 }
2766
2767 int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info)
2768 @@ -999,6 +1020,7 @@ int tipc_nl_bearer_add(struct sk_buff *skb, struct genl_info *info)
2769 b = tipc_bearer_find(net, name);
2770 if (!b) {
2771 rtnl_unlock();
2772 + NL_SET_ERR_MSG(info->extack, "Bearer not found");
2773 return -EINVAL;
2774 }
2775
2776 @@ -1039,8 +1061,10 @@ int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)
2777 name = nla_data(attrs[TIPC_NLA_BEARER_NAME]);
2778
2779 b = tipc_bearer_find(net, name);
2780 - if (!b)
2781 + if (!b) {
2782 + NL_SET_ERR_MSG(info->extack, "Bearer not found");
2783 return -EINVAL;
2784 + }
2785
2786 if (attrs[TIPC_NLA_BEARER_PROP]) {
2787 struct nlattr *props[TIPC_NLA_PROP_MAX + 1];
2788 @@ -1059,12 +1083,18 @@ int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)
2789 if (props[TIPC_NLA_PROP_WIN])
2790 b->window = nla_get_u32(props[TIPC_NLA_PROP_WIN]);
2791 if (props[TIPC_NLA_PROP_MTU]) {
2792 - if (b->media->type_id != TIPC_MEDIA_TYPE_UDP)
2793 + if (b->media->type_id != TIPC_MEDIA_TYPE_UDP) {
2794 + NL_SET_ERR_MSG(info->extack,
2795 + "MTU property is unsupported");
2796 return -EINVAL;
2797 + }
2798 #ifdef CONFIG_TIPC_MEDIA_UDP
2799 if (tipc_udp_mtu_bad(nla_get_u32
2800 - (props[TIPC_NLA_PROP_MTU])))
2801 + (props[TIPC_NLA_PROP_MTU]))) {
2802 + NL_SET_ERR_MSG(info->extack,
2803 + "MTU value is out-of-range");
2804 return -EINVAL;
2805 + }
2806 b->mtu = nla_get_u32(props[TIPC_NLA_PROP_MTU]);
2807 tipc_node_apply_property(net, b, TIPC_NLA_PROP_MTU);
2808 #endif
2809 @@ -1192,6 +1222,7 @@ int tipc_nl_media_get(struct sk_buff *skb, struct genl_info *info)
2810 rtnl_lock();
2811 media = tipc_media_find(name);
2812 if (!media) {
2813 + NL_SET_ERR_MSG(info->extack, "Media not found");
2814 err = -EINVAL;
2815 goto err_out;
2816 }
2817 @@ -1228,9 +1259,10 @@ int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info)
2818 name = nla_data(attrs[TIPC_NLA_MEDIA_NAME]);
2819
2820 m = tipc_media_find(name);
2821 - if (!m)
2822 + if (!m) {
2823 + NL_SET_ERR_MSG(info->extack, "Media not found");
2824 return -EINVAL;
2825 -
2826 + }
2827 if (attrs[TIPC_NLA_MEDIA_PROP]) {
2828 struct nlattr *props[TIPC_NLA_PROP_MAX + 1];
2829
2830 @@ -1246,12 +1278,18 @@ int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info)
2831 if (props[TIPC_NLA_PROP_WIN])
2832 m->window = nla_get_u32(props[TIPC_NLA_PROP_WIN]);
2833 if (props[TIPC_NLA_PROP_MTU]) {
2834 - if (m->type_id != TIPC_MEDIA_TYPE_UDP)
2835 + if (m->type_id != TIPC_MEDIA_TYPE_UDP) {
2836 + NL_SET_ERR_MSG(info->extack,
2837 + "MTU property is unsupported");
2838 return -EINVAL;
2839 + }
2840 #ifdef CONFIG_TIPC_MEDIA_UDP
2841 if (tipc_udp_mtu_bad(nla_get_u32
2842 - (props[TIPC_NLA_PROP_MTU])))
2843 + (props[TIPC_NLA_PROP_MTU]))) {
2844 + NL_SET_ERR_MSG(info->extack,
2845 + "MTU value is out-of-range");
2846 return -EINVAL;
2847 + }
2848 m->mtu = nla_get_u32(props[TIPC_NLA_PROP_MTU]);
2849 #endif
2850 }
2851 diff --git a/net/wireless/core.h b/net/wireless/core.h
2852 index d83c8e009448a..17621d22fb175 100644
2853 --- a/net/wireless/core.h
2854 +++ b/net/wireless/core.h
2855 @@ -433,6 +433,8 @@ void cfg80211_sme_abandon_assoc(struct wireless_dev *wdev);
2856
2857 /* internal helpers */
2858 bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher);
2859 +bool cfg80211_valid_key_idx(struct cfg80211_registered_device *rdev,
2860 + int key_idx, bool pairwise);
2861 int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev,
2862 struct key_params *params, int key_idx,
2863 bool pairwise, const u8 *mac_addr);
2864 diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
2865 index 5bb2316befb98..7b170ed6923e7 100644
2866 --- a/net/wireless/nl80211.c
2867 +++ b/net/wireless/nl80211.c
2868 @@ -3979,9 +3979,6 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
2869 if (err)
2870 return err;
2871
2872 - if (key.idx < 0)
2873 - return -EINVAL;
2874 -
2875 if (info->attrs[NL80211_ATTR_MAC])
2876 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
2877
2878 @@ -3997,6 +3994,10 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
2879 key.type != NL80211_KEYTYPE_GROUP)
2880 return -EINVAL;
2881
2882 + if (!cfg80211_valid_key_idx(rdev, key.idx,
2883 + key.type == NL80211_KEYTYPE_PAIRWISE))
2884 + return -EINVAL;
2885 +
2886 if (!rdev->ops->del_key)
2887 return -EOPNOTSUPP;
2888
2889 diff --git a/net/wireless/util.c b/net/wireless/util.c
2890 index 82244e2fc1f54..4eae6ad328514 100644
2891 --- a/net/wireless/util.c
2892 +++ b/net/wireless/util.c
2893 @@ -229,11 +229,48 @@ bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher)
2894 return false;
2895 }
2896
2897 +static bool
2898 +cfg80211_igtk_cipher_supported(struct cfg80211_registered_device *rdev)
2899 +{
2900 + struct wiphy *wiphy = &rdev->wiphy;
2901 + int i;
2902 +
2903 + for (i = 0; i < wiphy->n_cipher_suites; i++) {
2904 + switch (wiphy->cipher_suites[i]) {
2905 + case WLAN_CIPHER_SUITE_AES_CMAC:
2906 + case WLAN_CIPHER_SUITE_BIP_CMAC_256:
2907 + case WLAN_CIPHER_SUITE_BIP_GMAC_128:
2908 + case WLAN_CIPHER_SUITE_BIP_GMAC_256:
2909 + return true;
2910 + }
2911 + }
2912 +
2913 + return false;
2914 +}
2915 +
2916 +bool cfg80211_valid_key_idx(struct cfg80211_registered_device *rdev,
2917 + int key_idx, bool pairwise)
2918 +{
2919 + int max_key_idx;
2920 +
2921 + if (pairwise)
2922 + max_key_idx = 3;
2923 + else if (cfg80211_igtk_cipher_supported(rdev))
2924 + max_key_idx = 5;
2925 + else
2926 + max_key_idx = 3;
2927 +
2928 + if (key_idx < 0 || key_idx > max_key_idx)
2929 + return false;
2930 +
2931 + return true;
2932 +}
2933 +
2934 int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev,
2935 struct key_params *params, int key_idx,
2936 bool pairwise, const u8 *mac_addr)
2937 {
2938 - if (key_idx < 0 || key_idx > 5)
2939 + if (!cfg80211_valid_key_idx(rdev, key_idx, pairwise))
2940 return -EINVAL;
2941
2942 if (!pairwise && mac_addr && !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN))
2943 diff --git a/samples/vfio-mdev/mdpy-fb.c b/samples/vfio-mdev/mdpy-fb.c
2944 index 2719bb2596530..a760e130bd0d6 100644
2945 --- a/samples/vfio-mdev/mdpy-fb.c
2946 +++ b/samples/vfio-mdev/mdpy-fb.c
2947 @@ -117,22 +117,27 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
2948 if (format != DRM_FORMAT_XRGB8888) {
2949 pci_err(pdev, "format mismatch (0x%x != 0x%x)\n",
2950 format, DRM_FORMAT_XRGB8888);
2951 - return -EINVAL;
2952 + ret = -EINVAL;
2953 + goto err_release_regions;
2954 }
2955 if (width < 100 || width > 10000) {
2956 pci_err(pdev, "width (%d) out of range\n", width);
2957 - return -EINVAL;
2958 + ret = -EINVAL;
2959 + goto err_release_regions;
2960 }
2961 if (height < 100 || height > 10000) {
2962 pci_err(pdev, "height (%d) out of range\n", height);
2963 - return -EINVAL;
2964 + ret = -EINVAL;
2965 + goto err_release_regions;
2966 }
2967 pci_info(pdev, "mdpy found: %dx%d framebuffer\n",
2968 width, height);
2969
2970 info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev);
2971 - if (!info)
2972 + if (!info) {
2973 + ret = -ENOMEM;
2974 goto err_release_regions;
2975 + }
2976 pci_set_drvdata(pdev, info);
2977 par = info->par;
2978
2979 diff --git a/sound/core/timer.c b/sound/core/timer.c
2980 index 013f0e69ff0f7..b5a0ba79bf746 100644
2981 --- a/sound/core/timer.c
2982 +++ b/sound/core/timer.c
2983 @@ -491,9 +491,10 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
2984 return;
2985 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
2986 return;
2987 + event += 10; /* convert to SNDRV_TIMER_EVENT_MXXX */
2988 list_for_each_entry(ts, &ti->slave_active_head, active_list)
2989 if (ts->ccallback)
2990 - ts->ccallback(ts, event + 100, &tstamp, resolution);
2991 + ts->ccallback(ts, event, &tstamp, resolution);
2992 }
2993
2994 /* start/continue a master timer */
2995 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
2996 index b9fa2ee0a40cb..de40bb99b6793 100644
2997 --- a/sound/pci/hda/patch_realtek.c
2998 +++ b/sound/pci/hda/patch_realtek.c
2999 @@ -8062,6 +8062,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
3000 SND_PCI_QUIRK(0x103c, 0x82bf, "HP G3 mini", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
3001 SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
3002 SND_PCI_QUIRK(0x103c, 0x83b9, "HP Spectre x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
3003 + SND_PCI_QUIRK(0x103c, 0x841c, "HP Pavilion 15-CK0xx", ALC269_FIXUP_HP_MUTE_LED_MIC3),
3004 SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
3005 SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN),
3006 SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
3007 diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
3008 index 5251818e10d33..d926869c031b1 100644
3009 --- a/sound/usb/mixer_quirks.c
3010 +++ b/sound/usb/mixer_quirks.c
3011 @@ -1697,7 +1697,7 @@ static struct snd_kcontrol_new snd_microii_mixer_spdif[] = {
3012 static int snd_microii_controls_create(struct usb_mixer_interface *mixer)
3013 {
3014 int err, i;
3015 - const static usb_mixer_elem_resume_func_t resume_funcs[] = {
3016 + static const usb_mixer_elem_resume_func_t resume_funcs[] = {
3017 snd_microii_spdif_default_update,
3018 NULL,
3019 snd_microii_spdif_switch_update