Contents of /trunk/kernel-alx/patches-4.19/0117-4.19.18-all-fixes.patch
Parent Directory | Revision Log
Revision 3396 -
(show annotations)
(download)
Fri Aug 2 11:47:30 2019 UTC (5 years, 1 month ago) by niro
File size: 156651 byte(s)
Fri Aug 2 11:47:30 2019 UTC (5 years, 1 month ago) by niro
File size: 156651 byte(s)
-linux-4.19.18
1 | diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt |
2 | index 22b4b00dee31..06ac6dda9b34 100644 |
3 | --- a/Documentation/filesystems/proc.txt |
4 | +++ b/Documentation/filesystems/proc.txt |
5 | @@ -496,7 +496,9 @@ manner. The codes are the following: |
6 | |
7 | Note that there is no guarantee that every flag and associated mnemonic will |
8 | be present in all further kernel releases. Things get changed, the flags may |
9 | -be vanished or the reverse -- new added. |
10 | +be vanished or the reverse -- new added. Interpretation of their meaning |
11 | +might change in future as well. So each consumer of these flags has to |
12 | +follow each specific kernel version for the exact semantic. |
13 | |
14 | This file is only present if the CONFIG_MMU kernel configuration option is |
15 | enabled. |
16 | diff --git a/Makefile b/Makefile |
17 | index 4b0bce87a36b..9f37a8a9feb9 100644 |
18 | --- a/Makefile |
19 | +++ b/Makefile |
20 | @@ -1,7 +1,7 @@ |
21 | # SPDX-License-Identifier: GPL-2.0 |
22 | VERSION = 4 |
23 | PATCHLEVEL = 19 |
24 | -SUBLEVEL = 17 |
25 | +SUBLEVEL = 18 |
26 | EXTRAVERSION = |
27 | NAME = "People's Front" |
28 | |
29 | diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h |
30 | index 0bcc98dbba56..f90f5d83b228 100644 |
31 | --- a/arch/arm64/include/asm/assembler.h |
32 | +++ b/arch/arm64/include/asm/assembler.h |
33 | @@ -378,27 +378,33 @@ alternative_endif |
34 | * size: size of the region |
35 | * Corrupts: kaddr, size, tmp1, tmp2 |
36 | */ |
37 | + .macro __dcache_op_workaround_clean_cache, op, kaddr |
38 | +alternative_if_not ARM64_WORKAROUND_CLEAN_CACHE |
39 | + dc \op, \kaddr |
40 | +alternative_else |
41 | + dc civac, \kaddr |
42 | +alternative_endif |
43 | + .endm |
44 | + |
45 | .macro dcache_by_line_op op, domain, kaddr, size, tmp1, tmp2 |
46 | dcache_line_size \tmp1, \tmp2 |
47 | add \size, \kaddr, \size |
48 | sub \tmp2, \tmp1, #1 |
49 | bic \kaddr, \kaddr, \tmp2 |
50 | 9998: |
51 | - .if (\op == cvau || \op == cvac) |
52 | -alternative_if_not ARM64_WORKAROUND_CLEAN_CACHE |
53 | - dc \op, \kaddr |
54 | -alternative_else |
55 | - dc civac, \kaddr |
56 | -alternative_endif |
57 | - .elseif (\op == cvap) |
58 | -alternative_if ARM64_HAS_DCPOP |
59 | - sys 3, c7, c12, 1, \kaddr // dc cvap |
60 | -alternative_else |
61 | - dc cvac, \kaddr |
62 | -alternative_endif |
63 | + .ifc \op, cvau |
64 | + __dcache_op_workaround_clean_cache \op, \kaddr |
65 | + .else |
66 | + .ifc \op, cvac |
67 | + __dcache_op_workaround_clean_cache \op, \kaddr |
68 | + .else |
69 | + .ifc \op, cvap |
70 | + sys 3, c7, c12, 1, \kaddr // dc cvap |
71 | .else |
72 | dc \op, \kaddr |
73 | .endif |
74 | + .endif |
75 | + .endif |
76 | add \kaddr, \kaddr, \tmp1 |
77 | cmp \kaddr, \size |
78 | b.lo 9998b |
79 | diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h |
80 | index b96442960aea..56562ff01076 100644 |
81 | --- a/arch/arm64/include/asm/memory.h |
82 | +++ b/arch/arm64/include/asm/memory.h |
83 | @@ -76,12 +76,17 @@ |
84 | /* |
85 | * KASAN requires 1/8th of the kernel virtual address space for the shadow |
86 | * region. KASAN can bloat the stack significantly, so double the (minimum) |
87 | - * stack size when KASAN is in use. |
88 | + * stack size when KASAN is in use, and then double it again if KASAN_EXTRA is |
89 | + * on. |
90 | */ |
91 | #ifdef CONFIG_KASAN |
92 | #define KASAN_SHADOW_SCALE_SHIFT 3 |
93 | #define KASAN_SHADOW_SIZE (UL(1) << (VA_BITS - KASAN_SHADOW_SCALE_SHIFT)) |
94 | +#ifdef CONFIG_KASAN_EXTRA |
95 | +#define KASAN_THREAD_SHIFT 2 |
96 | +#else |
97 | #define KASAN_THREAD_SHIFT 1 |
98 | +#endif /* CONFIG_KASAN_EXTRA */ |
99 | #else |
100 | #define KASAN_SHADOW_SIZE (0) |
101 | #define KASAN_THREAD_SHIFT 0 |
102 | diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c |
103 | index e213f8e867f6..8a91ac067d44 100644 |
104 | --- a/arch/arm64/kernel/perf_event.c |
105 | +++ b/arch/arm64/kernel/perf_event.c |
106 | @@ -1274,6 +1274,7 @@ static struct platform_driver armv8_pmu_driver = { |
107 | .driver = { |
108 | .name = ARMV8_PMU_PDEV_NAME, |
109 | .of_match_table = armv8_pmu_of_device_ids, |
110 | + .suppress_bind_attrs = true, |
111 | }, |
112 | .probe = armv8_pmu_device_probe, |
113 | }; |
114 | diff --git a/arch/arm64/mm/cache.S b/arch/arm64/mm/cache.S |
115 | index 0c22ede52f90..a194fd0e837f 100644 |
116 | --- a/arch/arm64/mm/cache.S |
117 | +++ b/arch/arm64/mm/cache.S |
118 | @@ -212,6 +212,9 @@ ENDPROC(__dma_clean_area) |
119 | * - size - size in question |
120 | */ |
121 | ENTRY(__clean_dcache_area_pop) |
122 | + alternative_if_not ARM64_HAS_DCPOP |
123 | + b __clean_dcache_area_poc |
124 | + alternative_else_nop_endif |
125 | dcache_by_line_op cvap, sy, x0, x1, x2, x3 |
126 | ret |
127 | ENDPIPROC(__clean_dcache_area_pop) |
128 | diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig |
129 | index 154b811d5894..201caf226b47 100644 |
130 | --- a/arch/mips/Kconfig |
131 | +++ b/arch/mips/Kconfig |
132 | @@ -794,6 +794,7 @@ config SIBYTE_SWARM |
133 | select SYS_SUPPORTS_HIGHMEM |
134 | select SYS_SUPPORTS_LITTLE_ENDIAN |
135 | select ZONE_DMA32 if 64BIT |
136 | + select SWIOTLB if ARCH_DMA_ADDR_T_64BIT && PCI |
137 | |
138 | config SIBYTE_LITTLESUR |
139 | bool "Sibyte BCM91250C2-LittleSur" |
140 | @@ -814,6 +815,7 @@ config SIBYTE_SENTOSA |
141 | select SYS_HAS_CPU_SB1 |
142 | select SYS_SUPPORTS_BIG_ENDIAN |
143 | select SYS_SUPPORTS_LITTLE_ENDIAN |
144 | + select SWIOTLB if ARCH_DMA_ADDR_T_64BIT && PCI |
145 | |
146 | config SIBYTE_BIGSUR |
147 | bool "Sibyte BCM91480B-BigSur" |
148 | @@ -826,6 +828,7 @@ config SIBYTE_BIGSUR |
149 | select SYS_SUPPORTS_HIGHMEM |
150 | select SYS_SUPPORTS_LITTLE_ENDIAN |
151 | select ZONE_DMA32 if 64BIT |
152 | + select SWIOTLB if ARCH_DMA_ADDR_T_64BIT && PCI |
153 | |
154 | config SNI_RM |
155 | bool "SNI RM200/300/400" |
156 | diff --git a/arch/mips/sibyte/common/Makefile b/arch/mips/sibyte/common/Makefile |
157 | index b3d6bf23a662..3ef3fb658136 100644 |
158 | --- a/arch/mips/sibyte/common/Makefile |
159 | +++ b/arch/mips/sibyte/common/Makefile |
160 | @@ -1,4 +1,5 @@ |
161 | obj-y := cfe.o |
162 | +obj-$(CONFIG_SWIOTLB) += dma.o |
163 | obj-$(CONFIG_SIBYTE_BUS_WATCHER) += bus_watcher.o |
164 | obj-$(CONFIG_SIBYTE_CFE_CONSOLE) += cfe_console.o |
165 | obj-$(CONFIG_SIBYTE_TBPROF) += sb_tbprof.o |
166 | diff --git a/arch/mips/sibyte/common/dma.c b/arch/mips/sibyte/common/dma.c |
167 | new file mode 100644 |
168 | index 000000000000..eb47a94f3583 |
169 | --- /dev/null |
170 | +++ b/arch/mips/sibyte/common/dma.c |
171 | @@ -0,0 +1,14 @@ |
172 | +// SPDX-License-Identifier: GPL-2.0+ |
173 | +/* |
174 | + * DMA support for Broadcom SiByte platforms. |
175 | + * |
176 | + * Copyright (c) 2018 Maciej W. Rozycki |
177 | + */ |
178 | + |
179 | +#include <linux/swiotlb.h> |
180 | +#include <asm/bootinfo.h> |
181 | + |
182 | +void __init plat_swiotlb_setup(void) |
183 | +{ |
184 | + swiotlb_init(1); |
185 | +} |
186 | diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c |
187 | index 4264aedc7775..dd6badc31f45 100644 |
188 | --- a/arch/powerpc/xmon/xmon.c |
189 | +++ b/arch/powerpc/xmon/xmon.c |
190 | @@ -75,6 +75,9 @@ static int xmon_gate; |
191 | #define xmon_owner 0 |
192 | #endif /* CONFIG_SMP */ |
193 | |
194 | +#ifdef CONFIG_PPC_PSERIES |
195 | +static int set_indicator_token = RTAS_UNKNOWN_SERVICE; |
196 | +#endif |
197 | static unsigned long in_xmon __read_mostly = 0; |
198 | static int xmon_on = IS_ENABLED(CONFIG_XMON_DEFAULT); |
199 | |
200 | @@ -358,7 +361,6 @@ static inline void disable_surveillance(void) |
201 | #ifdef CONFIG_PPC_PSERIES |
202 | /* Since this can't be a module, args should end up below 4GB. */ |
203 | static struct rtas_args args; |
204 | - int token; |
205 | |
206 | /* |
207 | * At this point we have got all the cpus we can into |
208 | @@ -367,11 +369,11 @@ static inline void disable_surveillance(void) |
209 | * If we did try to take rtas.lock there would be a |
210 | * real possibility of deadlock. |
211 | */ |
212 | - token = rtas_token("set-indicator"); |
213 | - if (token == RTAS_UNKNOWN_SERVICE) |
214 | + if (set_indicator_token == RTAS_UNKNOWN_SERVICE) |
215 | return; |
216 | |
217 | - rtas_call_unlocked(&args, token, 3, 1, NULL, SURVEILLANCE_TOKEN, 0, 0); |
218 | + rtas_call_unlocked(&args, set_indicator_token, 3, 1, NULL, |
219 | + SURVEILLANCE_TOKEN, 0, 0); |
220 | |
221 | #endif /* CONFIG_PPC_PSERIES */ |
222 | } |
223 | @@ -3672,6 +3674,14 @@ static void xmon_init(int enable) |
224 | __debugger_iabr_match = xmon_iabr_match; |
225 | __debugger_break_match = xmon_break_match; |
226 | __debugger_fault_handler = xmon_fault_handler; |
227 | + |
228 | +#ifdef CONFIG_PPC_PSERIES |
229 | + /* |
230 | + * Get the token here to avoid trying to get a lock |
231 | + * during the crash, causing a deadlock. |
232 | + */ |
233 | + set_indicator_token = rtas_token("set-indicator"); |
234 | +#endif |
235 | } else { |
236 | __debugger = NULL; |
237 | __debugger_ipi = NULL; |
238 | diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h |
239 | index 3de69330e6c5..afbc87206886 100644 |
240 | --- a/arch/x86/include/asm/traps.h |
241 | +++ b/arch/x86/include/asm/traps.h |
242 | @@ -104,9 +104,9 @@ extern int panic_on_unrecovered_nmi; |
243 | |
244 | void math_emulate(struct math_emu_info *); |
245 | #ifndef CONFIG_X86_32 |
246 | -asmlinkage void smp_thermal_interrupt(void); |
247 | -asmlinkage void smp_threshold_interrupt(void); |
248 | -asmlinkage void smp_deferred_error_interrupt(void); |
249 | +asmlinkage void smp_thermal_interrupt(struct pt_regs *regs); |
250 | +asmlinkage void smp_threshold_interrupt(struct pt_regs *regs); |
251 | +asmlinkage void smp_deferred_error_interrupt(struct pt_regs *regs); |
252 | #endif |
253 | |
254 | extern void ist_enter(struct pt_regs *regs); |
255 | diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c |
256 | index e12454e21b8a..9f915a8791cc 100644 |
257 | --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c |
258 | +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c |
259 | @@ -23,6 +23,7 @@ |
260 | #include <linux/string.h> |
261 | |
262 | #include <asm/amd_nb.h> |
263 | +#include <asm/traps.h> |
264 | #include <asm/apic.h> |
265 | #include <asm/mce.h> |
266 | #include <asm/msr.h> |
267 | @@ -99,7 +100,7 @@ static u32 smca_bank_addrs[MAX_NR_BANKS][NR_BLOCKS] __ro_after_init = |
268 | [0 ... MAX_NR_BANKS - 1] = { [0 ... NR_BLOCKS - 1] = -1 } |
269 | }; |
270 | |
271 | -const char *smca_get_name(enum smca_bank_types t) |
272 | +static const char *smca_get_name(enum smca_bank_types t) |
273 | { |
274 | if (t >= N_SMCA_BANK_TYPES) |
275 | return NULL; |
276 | @@ -824,7 +825,7 @@ static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc) |
277 | mce_log(&m); |
278 | } |
279 | |
280 | -asmlinkage __visible void __irq_entry smp_deferred_error_interrupt(void) |
281 | +asmlinkage __visible void __irq_entry smp_deferred_error_interrupt(struct pt_regs *regs) |
282 | { |
283 | entering_irq(); |
284 | trace_deferred_error_apic_entry(DEFERRED_ERROR_VECTOR); |
285 | diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c |
286 | index 2da67b70ba98..ee229ceee745 100644 |
287 | --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c |
288 | +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c |
289 | @@ -25,6 +25,7 @@ |
290 | #include <linux/cpu.h> |
291 | |
292 | #include <asm/processor.h> |
293 | +#include <asm/traps.h> |
294 | #include <asm/apic.h> |
295 | #include <asm/mce.h> |
296 | #include <asm/msr.h> |
297 | @@ -390,7 +391,7 @@ static void unexpected_thermal_interrupt(void) |
298 | |
299 | static void (*smp_thermal_vector)(void) = unexpected_thermal_interrupt; |
300 | |
301 | -asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *r) |
302 | +asmlinkage __visible void __irq_entry smp_thermal_interrupt(struct pt_regs *regs) |
303 | { |
304 | entering_irq(); |
305 | trace_thermal_apic_entry(THERMAL_APIC_VECTOR); |
306 | diff --git a/arch/x86/kernel/cpu/mcheck/threshold.c b/arch/x86/kernel/cpu/mcheck/threshold.c |
307 | index 2b584b319eff..c21e0a1efd0f 100644 |
308 | --- a/arch/x86/kernel/cpu/mcheck/threshold.c |
309 | +++ b/arch/x86/kernel/cpu/mcheck/threshold.c |
310 | @@ -6,6 +6,7 @@ |
311 | #include <linux/kernel.h> |
312 | |
313 | #include <asm/irq_vectors.h> |
314 | +#include <asm/traps.h> |
315 | #include <asm/apic.h> |
316 | #include <asm/mce.h> |
317 | #include <asm/trace/irq_vectors.h> |
318 | @@ -18,7 +19,7 @@ static void default_threshold_interrupt(void) |
319 | |
320 | void (*mce_threshold_vector)(void) = default_threshold_interrupt; |
321 | |
322 | -asmlinkage __visible void __irq_entry smp_threshold_interrupt(void) |
323 | +asmlinkage __visible void __irq_entry smp_threshold_interrupt(struct pt_regs *regs) |
324 | { |
325 | entering_irq(); |
326 | trace_threshold_apic_entry(THRESHOLD_APIC_VECTOR); |
327 | diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c |
328 | index f02ecaf97904..6489067b78a4 100644 |
329 | --- a/arch/x86/kernel/smpboot.c |
330 | +++ b/arch/x86/kernel/smpboot.c |
331 | @@ -1346,7 +1346,7 @@ void __init calculate_max_logical_packages(void) |
332 | * extrapolate the boot cpu's data to all packages. |
333 | */ |
334 | ncpus = cpu_data(0).booted_cores * topology_max_smt_threads(); |
335 | - __max_logical_packages = DIV_ROUND_UP(nr_cpu_ids, ncpus); |
336 | + __max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus); |
337 | pr_info("Max logical packages: %u\n", __max_logical_packages); |
338 | } |
339 | |
340 | diff --git a/crypto/ecc.c b/crypto/ecc.c |
341 | index 8facafd67802..adcce310f646 100644 |
342 | --- a/crypto/ecc.c |
343 | +++ b/crypto/ecc.c |
344 | @@ -842,15 +842,23 @@ static void xycz_add_c(u64 *x1, u64 *y1, u64 *x2, u64 *y2, u64 *curve_prime, |
345 | |
346 | static void ecc_point_mult(struct ecc_point *result, |
347 | const struct ecc_point *point, const u64 *scalar, |
348 | - u64 *initial_z, u64 *curve_prime, |
349 | + u64 *initial_z, const struct ecc_curve *curve, |
350 | unsigned int ndigits) |
351 | { |
352 | /* R0 and R1 */ |
353 | u64 rx[2][ECC_MAX_DIGITS]; |
354 | u64 ry[2][ECC_MAX_DIGITS]; |
355 | u64 z[ECC_MAX_DIGITS]; |
356 | + u64 sk[2][ECC_MAX_DIGITS]; |
357 | + u64 *curve_prime = curve->p; |
358 | int i, nb; |
359 | - int num_bits = vli_num_bits(scalar, ndigits); |
360 | + int num_bits; |
361 | + int carry; |
362 | + |
363 | + carry = vli_add(sk[0], scalar, curve->n, ndigits); |
364 | + vli_add(sk[1], sk[0], curve->n, ndigits); |
365 | + scalar = sk[!carry]; |
366 | + num_bits = sizeof(u64) * ndigits * 8 + 1; |
367 | |
368 | vli_set(rx[1], point->x, ndigits); |
369 | vli_set(ry[1], point->y, ndigits); |
370 | @@ -1004,7 +1012,7 @@ int ecc_make_pub_key(unsigned int curve_id, unsigned int ndigits, |
371 | goto out; |
372 | } |
373 | |
374 | - ecc_point_mult(pk, &curve->g, priv, NULL, curve->p, ndigits); |
375 | + ecc_point_mult(pk, &curve->g, priv, NULL, curve, ndigits); |
376 | if (ecc_point_is_zero(pk)) { |
377 | ret = -EAGAIN; |
378 | goto err_free_point; |
379 | @@ -1090,7 +1098,7 @@ int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits, |
380 | goto err_alloc_product; |
381 | } |
382 | |
383 | - ecc_point_mult(product, pk, priv, rand_z, curve->p, ndigits); |
384 | + ecc_point_mult(product, pk, priv, rand_z, curve, ndigits); |
385 | |
386 | ecc_swap_digits(product->x, secret, ndigits); |
387 | |
388 | diff --git a/drivers/base/bus.c b/drivers/base/bus.c |
389 | index 8bfd27ec73d6..585e2e1c9c8f 100644 |
390 | --- a/drivers/base/bus.c |
391 | +++ b/drivers/base/bus.c |
392 | @@ -31,6 +31,9 @@ static struct kset *system_kset; |
393 | |
394 | #define to_drv_attr(_attr) container_of(_attr, struct driver_attribute, attr) |
395 | |
396 | +#define DRIVER_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \ |
397 | + struct driver_attribute driver_attr_##_name = \ |
398 | + __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) |
399 | |
400 | static int __must_check bus_rescan_devices_helper(struct device *dev, |
401 | void *data); |
402 | @@ -195,7 +198,7 @@ static ssize_t unbind_store(struct device_driver *drv, const char *buf, |
403 | bus_put(bus); |
404 | return err; |
405 | } |
406 | -static DRIVER_ATTR_WO(unbind); |
407 | +static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, S_IWUSR, NULL, unbind_store); |
408 | |
409 | /* |
410 | * Manually attach a device to a driver. |
411 | @@ -231,7 +234,7 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf, |
412 | bus_put(bus); |
413 | return err; |
414 | } |
415 | -static DRIVER_ATTR_WO(bind); |
416 | +static DRIVER_ATTR_IGNORE_LOCKDEP(bind, S_IWUSR, NULL, bind_store); |
417 | |
418 | static ssize_t show_drivers_autoprobe(struct bus_type *bus, char *buf) |
419 | { |
420 | diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c |
421 | index cd2e5cf14ea5..77b67a5f21ee 100644 |
422 | --- a/drivers/bluetooth/btusb.c |
423 | +++ b/drivers/bluetooth/btusb.c |
424 | @@ -343,6 +343,7 @@ static const struct usb_device_id blacklist_table[] = { |
425 | /* Intel Bluetooth devices */ |
426 | { USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_NEW }, |
427 | { USB_DEVICE(0x8087, 0x0026), .driver_info = BTUSB_INTEL_NEW }, |
428 | + { USB_DEVICE(0x8087, 0x0029), .driver_info = BTUSB_INTEL_NEW }, |
429 | { USB_DEVICE(0x8087, 0x07da), .driver_info = BTUSB_CSR }, |
430 | { USB_DEVICE(0x8087, 0x07dc), .driver_info = BTUSB_INTEL }, |
431 | { USB_DEVICE(0x8087, 0x0a2a), .driver_info = BTUSB_INTEL }, |
432 | @@ -2054,6 +2055,35 @@ static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb) |
433 | return -EILSEQ; |
434 | } |
435 | |
436 | +static bool btusb_setup_intel_new_get_fw_name(struct intel_version *ver, |
437 | + struct intel_boot_params *params, |
438 | + char *fw_name, size_t len, |
439 | + const char *suffix) |
440 | +{ |
441 | + switch (ver->hw_variant) { |
442 | + case 0x0b: /* SfP */ |
443 | + case 0x0c: /* WsP */ |
444 | + snprintf(fw_name, len, "intel/ibt-%u-%u.%s", |
445 | + le16_to_cpu(ver->hw_variant), |
446 | + le16_to_cpu(params->dev_revid), |
447 | + suffix); |
448 | + break; |
449 | + case 0x11: /* JfP */ |
450 | + case 0x12: /* ThP */ |
451 | + case 0x13: /* HrP */ |
452 | + case 0x14: /* CcP */ |
453 | + snprintf(fw_name, len, "intel/ibt-%u-%u-%u.%s", |
454 | + le16_to_cpu(ver->hw_variant), |
455 | + le16_to_cpu(ver->hw_revision), |
456 | + le16_to_cpu(ver->fw_revision), |
457 | + suffix); |
458 | + break; |
459 | + default: |
460 | + return false; |
461 | + } |
462 | + return true; |
463 | +} |
464 | + |
465 | static int btusb_setup_intel_new(struct hci_dev *hdev) |
466 | { |
467 | struct btusb_data *data = hci_get_drvdata(hdev); |
468 | @@ -2105,7 +2135,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) |
469 | case 0x11: /* JfP */ |
470 | case 0x12: /* ThP */ |
471 | case 0x13: /* HrP */ |
472 | - case 0x14: /* QnJ, IcP */ |
473 | + case 0x14: /* CcP */ |
474 | break; |
475 | default: |
476 | bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)", |
477 | @@ -2189,23 +2219,9 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) |
478 | * ibt-<hw_variant>-<hw_revision>-<fw_revision>.sfi. |
479 | * |
480 | */ |
481 | - switch (ver.hw_variant) { |
482 | - case 0x0b: /* SfP */ |
483 | - case 0x0c: /* WsP */ |
484 | - snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.sfi", |
485 | - le16_to_cpu(ver.hw_variant), |
486 | - le16_to_cpu(params.dev_revid)); |
487 | - break; |
488 | - case 0x11: /* JfP */ |
489 | - case 0x12: /* ThP */ |
490 | - case 0x13: /* HrP */ |
491 | - case 0x14: /* QnJ, IcP */ |
492 | - snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u-%u.sfi", |
493 | - le16_to_cpu(ver.hw_variant), |
494 | - le16_to_cpu(ver.hw_revision), |
495 | - le16_to_cpu(ver.fw_revision)); |
496 | - break; |
497 | - default: |
498 | + err = btusb_setup_intel_new_get_fw_name(&ver, ¶ms, fwname, |
499 | + sizeof(fwname), "sfi"); |
500 | + if (!err) { |
501 | bt_dev_err(hdev, "Unsupported Intel firmware naming"); |
502 | return -EINVAL; |
503 | } |
504 | @@ -2221,23 +2237,9 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) |
505 | /* Save the DDC file name for later use to apply once the firmware |
506 | * downloading is done. |
507 | */ |
508 | - switch (ver.hw_variant) { |
509 | - case 0x0b: /* SfP */ |
510 | - case 0x0c: /* WsP */ |
511 | - snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.ddc", |
512 | - le16_to_cpu(ver.hw_variant), |
513 | - le16_to_cpu(params.dev_revid)); |
514 | - break; |
515 | - case 0x11: /* JfP */ |
516 | - case 0x12: /* ThP */ |
517 | - case 0x13: /* HrP */ |
518 | - case 0x14: /* QnJ, IcP */ |
519 | - snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u-%u.ddc", |
520 | - le16_to_cpu(ver.hw_variant), |
521 | - le16_to_cpu(ver.hw_revision), |
522 | - le16_to_cpu(ver.fw_revision)); |
523 | - break; |
524 | - default: |
525 | + err = btusb_setup_intel_new_get_fw_name(&ver, ¶ms, fwname, |
526 | + sizeof(fwname), "ddc"); |
527 | + if (!err) { |
528 | bt_dev_err(hdev, "Unsupported Intel firmware naming"); |
529 | return -EINVAL; |
530 | } |
531 | diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c |
532 | index 7fc9612070a1..d5f7a12e350e 100644 |
533 | --- a/drivers/char/ipmi/ipmi_msghandler.c |
534 | +++ b/drivers/char/ipmi/ipmi_msghandler.c |
535 | @@ -29,6 +29,7 @@ |
536 | #include <linux/moduleparam.h> |
537 | #include <linux/workqueue.h> |
538 | #include <linux/uuid.h> |
539 | +#include <linux/nospec.h> |
540 | |
541 | #define PFX "IPMI message handler: " |
542 | |
543 | @@ -61,7 +62,8 @@ static void ipmi_debug_msg(const char *title, unsigned char *data, |
544 | { } |
545 | #endif |
546 | |
547 | -static int initialized; |
548 | +static bool initialized; |
549 | +static bool drvregistered; |
550 | |
551 | enum ipmi_panic_event_op { |
552 | IPMI_SEND_PANIC_EVENT_NONE, |
553 | @@ -611,7 +613,7 @@ static DEFINE_MUTEX(ipmidriver_mutex); |
554 | |
555 | static LIST_HEAD(ipmi_interfaces); |
556 | static DEFINE_MUTEX(ipmi_interfaces_mutex); |
557 | -DEFINE_STATIC_SRCU(ipmi_interfaces_srcu); |
558 | +struct srcu_struct ipmi_interfaces_srcu; |
559 | |
560 | /* |
561 | * List of watchers that want to know when smi's are added and deleted. |
562 | @@ -719,7 +721,15 @@ struct watcher_entry { |
563 | int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher) |
564 | { |
565 | struct ipmi_smi *intf; |
566 | - int index; |
567 | + int index, rv; |
568 | + |
569 | + /* |
570 | + * Make sure the driver is actually initialized, this handles |
571 | + * problems with initialization order. |
572 | + */ |
573 | + rv = ipmi_init_msghandler(); |
574 | + if (rv) |
575 | + return rv; |
576 | |
577 | mutex_lock(&smi_watchers_mutex); |
578 | |
579 | @@ -883,7 +893,7 @@ static int deliver_response(struct ipmi_smi *intf, struct ipmi_recv_msg *msg) |
580 | |
581 | if (user) { |
582 | user->handler->ipmi_recv_hndl(msg, user->handler_data); |
583 | - release_ipmi_user(msg->user, index); |
584 | + release_ipmi_user(user, index); |
585 | } else { |
586 | /* User went away, give up. */ |
587 | ipmi_free_recv_msg(msg); |
588 | @@ -1075,7 +1085,7 @@ int ipmi_create_user(unsigned int if_num, |
589 | { |
590 | unsigned long flags; |
591 | struct ipmi_user *new_user; |
592 | - int rv = 0, index; |
593 | + int rv, index; |
594 | struct ipmi_smi *intf; |
595 | |
596 | /* |
597 | @@ -1093,18 +1103,9 @@ int ipmi_create_user(unsigned int if_num, |
598 | * Make sure the driver is actually initialized, this handles |
599 | * problems with initialization order. |
600 | */ |
601 | - if (!initialized) { |
602 | - rv = ipmi_init_msghandler(); |
603 | - if (rv) |
604 | - return rv; |
605 | - |
606 | - /* |
607 | - * The init code doesn't return an error if it was turned |
608 | - * off, but it won't initialize. Check that. |
609 | - */ |
610 | - if (!initialized) |
611 | - return -ENODEV; |
612 | - } |
613 | + rv = ipmi_init_msghandler(); |
614 | + if (rv) |
615 | + return rv; |
616 | |
617 | new_user = kmalloc(sizeof(*new_user), GFP_KERNEL); |
618 | if (!new_user) |
619 | @@ -1182,6 +1183,7 @@ EXPORT_SYMBOL(ipmi_get_smi_info); |
620 | static void free_user(struct kref *ref) |
621 | { |
622 | struct ipmi_user *user = container_of(ref, struct ipmi_user, refcount); |
623 | + cleanup_srcu_struct(&user->release_barrier); |
624 | kfree(user); |
625 | } |
626 | |
627 | @@ -1258,7 +1260,6 @@ int ipmi_destroy_user(struct ipmi_user *user) |
628 | { |
629 | _ipmi_destroy_user(user); |
630 | |
631 | - cleanup_srcu_struct(&user->release_barrier); |
632 | kref_put(&user->refcount, free_user); |
633 | |
634 | return 0; |
635 | @@ -1297,10 +1298,12 @@ int ipmi_set_my_address(struct ipmi_user *user, |
636 | if (!user) |
637 | return -ENODEV; |
638 | |
639 | - if (channel >= IPMI_MAX_CHANNELS) |
640 | + if (channel >= IPMI_MAX_CHANNELS) { |
641 | rv = -EINVAL; |
642 | - else |
643 | + } else { |
644 | + channel = array_index_nospec(channel, IPMI_MAX_CHANNELS); |
645 | user->intf->addrinfo[channel].address = address; |
646 | + } |
647 | release_ipmi_user(user, index); |
648 | |
649 | return rv; |
650 | @@ -1317,10 +1320,12 @@ int ipmi_get_my_address(struct ipmi_user *user, |
651 | if (!user) |
652 | return -ENODEV; |
653 | |
654 | - if (channel >= IPMI_MAX_CHANNELS) |
655 | + if (channel >= IPMI_MAX_CHANNELS) { |
656 | rv = -EINVAL; |
657 | - else |
658 | + } else { |
659 | + channel = array_index_nospec(channel, IPMI_MAX_CHANNELS); |
660 | *address = user->intf->addrinfo[channel].address; |
661 | + } |
662 | release_ipmi_user(user, index); |
663 | |
664 | return rv; |
665 | @@ -1337,10 +1342,12 @@ int ipmi_set_my_LUN(struct ipmi_user *user, |
666 | if (!user) |
667 | return -ENODEV; |
668 | |
669 | - if (channel >= IPMI_MAX_CHANNELS) |
670 | + if (channel >= IPMI_MAX_CHANNELS) { |
671 | rv = -EINVAL; |
672 | - else |
673 | + } else { |
674 | + channel = array_index_nospec(channel, IPMI_MAX_CHANNELS); |
675 | user->intf->addrinfo[channel].lun = LUN & 0x3; |
676 | + } |
677 | release_ipmi_user(user, index); |
678 | |
679 | return 0; |
680 | @@ -1357,10 +1364,12 @@ int ipmi_get_my_LUN(struct ipmi_user *user, |
681 | if (!user) |
682 | return -ENODEV; |
683 | |
684 | - if (channel >= IPMI_MAX_CHANNELS) |
685 | + if (channel >= IPMI_MAX_CHANNELS) { |
686 | rv = -EINVAL; |
687 | - else |
688 | + } else { |
689 | + channel = array_index_nospec(channel, IPMI_MAX_CHANNELS); |
690 | *address = user->intf->addrinfo[channel].lun; |
691 | + } |
692 | release_ipmi_user(user, index); |
693 | |
694 | return rv; |
695 | @@ -2184,6 +2193,7 @@ static int check_addr(struct ipmi_smi *intf, |
696 | { |
697 | if (addr->channel >= IPMI_MAX_CHANNELS) |
698 | return -EINVAL; |
699 | + addr->channel = array_index_nospec(addr->channel, IPMI_MAX_CHANNELS); |
700 | *lun = intf->addrinfo[addr->channel].lun; |
701 | *saddr = intf->addrinfo[addr->channel].address; |
702 | return 0; |
703 | @@ -3294,17 +3304,9 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers, |
704 | * Make sure the driver is actually initialized, this handles |
705 | * problems with initialization order. |
706 | */ |
707 | - if (!initialized) { |
708 | - rv = ipmi_init_msghandler(); |
709 | - if (rv) |
710 | - return rv; |
711 | - /* |
712 | - * The init code doesn't return an error if it was turned |
713 | - * off, but it won't initialize. Check that. |
714 | - */ |
715 | - if (!initialized) |
716 | - return -ENODEV; |
717 | - } |
718 | + rv = ipmi_init_msghandler(); |
719 | + if (rv) |
720 | + return rv; |
721 | |
722 | intf = kzalloc(sizeof(*intf), GFP_KERNEL); |
723 | if (!intf) |
724 | @@ -5020,6 +5022,22 @@ static int panic_event(struct notifier_block *this, |
725 | return NOTIFY_DONE; |
726 | } |
727 | |
728 | +/* Must be called with ipmi_interfaces_mutex held. */ |
729 | +static int ipmi_register_driver(void) |
730 | +{ |
731 | + int rv; |
732 | + |
733 | + if (drvregistered) |
734 | + return 0; |
735 | + |
736 | + rv = driver_register(&ipmidriver.driver); |
737 | + if (rv) |
738 | + pr_err("Could not register IPMI driver\n"); |
739 | + else |
740 | + drvregistered = true; |
741 | + return rv; |
742 | +} |
743 | + |
744 | static struct notifier_block panic_block = { |
745 | .notifier_call = panic_event, |
746 | .next = NULL, |
747 | @@ -5030,66 +5048,74 @@ static int ipmi_init_msghandler(void) |
748 | { |
749 | int rv; |
750 | |
751 | + mutex_lock(&ipmi_interfaces_mutex); |
752 | + rv = ipmi_register_driver(); |
753 | + if (rv) |
754 | + goto out; |
755 | if (initialized) |
756 | - return 0; |
757 | - |
758 | - rv = driver_register(&ipmidriver.driver); |
759 | - if (rv) { |
760 | - pr_err(PFX "Could not register IPMI driver\n"); |
761 | - return rv; |
762 | - } |
763 | + goto out; |
764 | |
765 | - pr_info("ipmi message handler version " IPMI_DRIVER_VERSION "\n"); |
766 | + init_srcu_struct(&ipmi_interfaces_srcu); |
767 | |
768 | timer_setup(&ipmi_timer, ipmi_timeout, 0); |
769 | mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES); |
770 | |
771 | atomic_notifier_chain_register(&panic_notifier_list, &panic_block); |
772 | |
773 | - initialized = 1; |
774 | + initialized = true; |
775 | |
776 | - return 0; |
777 | +out: |
778 | + mutex_unlock(&ipmi_interfaces_mutex); |
779 | + return rv; |
780 | } |
781 | |
782 | static int __init ipmi_init_msghandler_mod(void) |
783 | { |
784 | - ipmi_init_msghandler(); |
785 | - return 0; |
786 | + int rv; |
787 | + |
788 | + pr_info("version " IPMI_DRIVER_VERSION "\n"); |
789 | + |
790 | + mutex_lock(&ipmi_interfaces_mutex); |
791 | + rv = ipmi_register_driver(); |
792 | + mutex_unlock(&ipmi_interfaces_mutex); |
793 | + |
794 | + return rv; |
795 | } |
796 | |
797 | static void __exit cleanup_ipmi(void) |
798 | { |
799 | int count; |
800 | |
801 | - if (!initialized) |
802 | - return; |
803 | - |
804 | - atomic_notifier_chain_unregister(&panic_notifier_list, &panic_block); |
805 | - |
806 | - /* |
807 | - * This can't be called if any interfaces exist, so no worry |
808 | - * about shutting down the interfaces. |
809 | - */ |
810 | - |
811 | - /* |
812 | - * Tell the timer to stop, then wait for it to stop. This |
813 | - * avoids problems with race conditions removing the timer |
814 | - * here. |
815 | - */ |
816 | - atomic_inc(&stop_operation); |
817 | - del_timer_sync(&ipmi_timer); |
818 | + if (initialized) { |
819 | + atomic_notifier_chain_unregister(&panic_notifier_list, |
820 | + &panic_block); |
821 | |
822 | - driver_unregister(&ipmidriver.driver); |
823 | - |
824 | - initialized = 0; |
825 | + /* |
826 | + * This can't be called if any interfaces exist, so no worry |
827 | + * about shutting down the interfaces. |
828 | + */ |
829 | |
830 | - /* Check for buffer leaks. */ |
831 | - count = atomic_read(&smi_msg_inuse_count); |
832 | - if (count != 0) |
833 | - pr_warn(PFX "SMI message count %d at exit\n", count); |
834 | - count = atomic_read(&recv_msg_inuse_count); |
835 | - if (count != 0) |
836 | - pr_warn(PFX "recv message count %d at exit\n", count); |
837 | + /* |
838 | + * Tell the timer to stop, then wait for it to stop. This |
839 | + * avoids problems with race conditions removing the timer |
840 | + * here. |
841 | + */ |
842 | + atomic_inc(&stop_operation); |
843 | + del_timer_sync(&ipmi_timer); |
844 | + |
845 | + initialized = false; |
846 | + |
847 | + /* Check for buffer leaks. */ |
848 | + count = atomic_read(&smi_msg_inuse_count); |
849 | + if (count != 0) |
850 | + pr_warn(PFX "SMI message count %d at exit\n", count); |
851 | + count = atomic_read(&recv_msg_inuse_count); |
852 | + if (count != 0) |
853 | + pr_warn(PFX "recv message count %d at exit\n", count); |
854 | + cleanup_srcu_struct(&ipmi_interfaces_srcu); |
855 | + } |
856 | + if (drvregistered) |
857 | + driver_unregister(&ipmidriver.driver); |
858 | } |
859 | module_exit(cleanup_ipmi); |
860 | |
861 | diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c |
862 | index 9b786726e426..76c2010ba672 100644 |
863 | --- a/drivers/char/ipmi/ipmi_ssif.c |
864 | +++ b/drivers/char/ipmi/ipmi_ssif.c |
865 | @@ -630,8 +630,9 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, |
866 | |
867 | /* Remove the multi-part read marker. */ |
868 | len -= 2; |
869 | + data += 2; |
870 | for (i = 0; i < len; i++) |
871 | - ssif_info->data[i] = data[i+2]; |
872 | + ssif_info->data[i] = data[i]; |
873 | ssif_info->multi_len = len; |
874 | ssif_info->multi_pos = 1; |
875 | |
876 | @@ -659,8 +660,19 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, |
877 | } |
878 | |
879 | blocknum = data[0]; |
880 | + len--; |
881 | + data++; |
882 | + |
883 | + if (blocknum != 0xff && len != 31) { |
884 | + /* All blocks but the last must have 31 data bytes. */ |
885 | + result = -EIO; |
886 | + if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) |
887 | + pr_info("Received middle message <31\n"); |
888 | |
889 | - if (ssif_info->multi_len + len - 1 > IPMI_MAX_MSG_LENGTH) { |
890 | + goto continue_op; |
891 | + } |
892 | + |
893 | + if (ssif_info->multi_len + len > IPMI_MAX_MSG_LENGTH) { |
894 | /* Received message too big, abort the operation. */ |
895 | result = -E2BIG; |
896 | if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) |
897 | @@ -669,16 +681,14 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, |
898 | goto continue_op; |
899 | } |
900 | |
901 | - /* Remove the blocknum from the data. */ |
902 | - len--; |
903 | for (i = 0; i < len; i++) |
904 | - ssif_info->data[i + ssif_info->multi_len] = data[i + 1]; |
905 | + ssif_info->data[i + ssif_info->multi_len] = data[i]; |
906 | ssif_info->multi_len += len; |
907 | if (blocknum == 0xff) { |
908 | /* End of read */ |
909 | len = ssif_info->multi_len; |
910 | data = ssif_info->data; |
911 | - } else if (blocknum + 1 != ssif_info->multi_pos) { |
912 | + } else if (blocknum != ssif_info->multi_pos) { |
913 | /* |
914 | * Out of sequence block, just abort. Block |
915 | * numbers start at zero for the second block, |
916 | @@ -706,6 +716,7 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, |
917 | } |
918 | } |
919 | |
920 | + continue_op: |
921 | if (result < 0) { |
922 | ssif_inc_stat(ssif_info, receive_errors); |
923 | } else { |
924 | @@ -713,8 +724,6 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result, |
925 | ssif_inc_stat(ssif_info, received_message_parts); |
926 | } |
927 | |
928 | - |
929 | - continue_op: |
930 | if (ssif_info->ssif_debug & SSIF_DEBUG_STATE) |
931 | pr_info(PFX "DONE 1: state = %d, result=%d.\n", |
932 | ssif_info->ssif_state, result); |
933 | diff --git a/drivers/clk/imx/clk-busy.c b/drivers/clk/imx/clk-busy.c |
934 | index 99036527eb0d..e695622c5aa5 100644 |
935 | --- a/drivers/clk/imx/clk-busy.c |
936 | +++ b/drivers/clk/imx/clk-busy.c |
937 | @@ -154,7 +154,7 @@ static const struct clk_ops clk_busy_mux_ops = { |
938 | |
939 | struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift, |
940 | u8 width, void __iomem *busy_reg, u8 busy_shift, |
941 | - const char **parent_names, int num_parents) |
942 | + const char * const *parent_names, int num_parents) |
943 | { |
944 | struct clk_busy_mux *busy; |
945 | struct clk *clk; |
946 | diff --git a/drivers/clk/imx/clk-fixup-mux.c b/drivers/clk/imx/clk-fixup-mux.c |
947 | index c9b327e0a8dd..44817c1b0b88 100644 |
948 | --- a/drivers/clk/imx/clk-fixup-mux.c |
949 | +++ b/drivers/clk/imx/clk-fixup-mux.c |
950 | @@ -70,7 +70,7 @@ static const struct clk_ops clk_fixup_mux_ops = { |
951 | }; |
952 | |
953 | struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg, |
954 | - u8 shift, u8 width, const char **parents, |
955 | + u8 shift, u8 width, const char * const *parents, |
956 | int num_parents, void (*fixup)(u32 *val)) |
957 | { |
958 | struct clk_fixup_mux *fixup_mux; |
959 | diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c |
960 | index 8c7c2fcb8d94..c509324f6338 100644 |
961 | --- a/drivers/clk/imx/clk-imx6q.c |
962 | +++ b/drivers/clk/imx/clk-imx6q.c |
963 | @@ -508,8 +508,12 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node) |
964 | * lvds1_gate and lvds2_gate are pseudo-gates. Both can be |
965 | * independently configured as clock inputs or outputs. We treat |
966 | * the "output_enable" bit as a gate, even though it's really just |
967 | - * enabling clock output. |
968 | + * enabling clock output. Initially the gate bits are cleared, as |
969 | + * otherwise the exclusive configuration gets locked in the setup done |
970 | + * by software running before the clock driver, with no way to change |
971 | + * it. |
972 | */ |
973 | + writel(readl(base + 0x160) & ~0x3c00, base + 0x160); |
974 | clk[IMX6QDL_CLK_LVDS1_GATE] = imx_clk_gate_exclusive("lvds1_gate", "lvds1_sel", base + 0x160, 10, BIT(12)); |
975 | clk[IMX6QDL_CLK_LVDS2_GATE] = imx_clk_gate_exclusive("lvds2_gate", "lvds2_sel", base + 0x160, 11, BIT(13)); |
976 | |
977 | diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h |
978 | index 8076ec040f37..e65c1115d978 100644 |
979 | --- a/drivers/clk/imx/clk.h |
980 | +++ b/drivers/clk/imx/clk.h |
981 | @@ -63,14 +63,14 @@ struct clk *imx_clk_busy_divider(const char *name, const char *parent_name, |
982 | |
983 | struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift, |
984 | u8 width, void __iomem *busy_reg, u8 busy_shift, |
985 | - const char **parent_names, int num_parents); |
986 | + const char * const *parent_names, int num_parents); |
987 | |
988 | struct clk *imx_clk_fixup_divider(const char *name, const char *parent, |
989 | void __iomem *reg, u8 shift, u8 width, |
990 | void (*fixup)(u32 *val)); |
991 | |
992 | struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg, |
993 | - u8 shift, u8 width, const char **parents, |
994 | + u8 shift, u8 width, const char * const *parents, |
995 | int num_parents, void (*fixup)(u32 *val)); |
996 | |
997 | static inline struct clk *imx_clk_fixed(const char *name, int rate) |
998 | @@ -79,7 +79,8 @@ static inline struct clk *imx_clk_fixed(const char *name, int rate) |
999 | } |
1000 | |
1001 | static inline struct clk *imx_clk_mux_ldb(const char *name, void __iomem *reg, |
1002 | - u8 shift, u8 width, const char **parents, int num_parents) |
1003 | + u8 shift, u8 width, const char * const *parents, |
1004 | + int num_parents) |
1005 | { |
1006 | return clk_register_mux(NULL, name, parents, num_parents, |
1007 | CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, reg, |
1008 | @@ -192,7 +193,8 @@ static inline struct clk *imx_clk_gate4(const char *name, const char *parent, |
1009 | } |
1010 | |
1011 | static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg, |
1012 | - u8 shift, u8 width, const char **parents, int num_parents) |
1013 | + u8 shift, u8 width, const char * const *parents, |
1014 | + int num_parents) |
1015 | { |
1016 | return clk_register_mux(NULL, name, parents, num_parents, |
1017 | CLK_SET_RATE_NO_REPARENT, reg, shift, |
1018 | @@ -200,7 +202,8 @@ static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg, |
1019 | } |
1020 | |
1021 | static inline struct clk *imx_clk_mux2(const char *name, void __iomem *reg, |
1022 | - u8 shift, u8 width, const char **parents, int num_parents) |
1023 | + u8 shift, u8 width, const char * const *parents, |
1024 | + int num_parents) |
1025 | { |
1026 | return clk_register_mux(NULL, name, parents, num_parents, |
1027 | CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, |
1028 | @@ -208,8 +211,9 @@ static inline struct clk *imx_clk_mux2(const char *name, void __iomem *reg, |
1029 | } |
1030 | |
1031 | static inline struct clk *imx_clk_mux_flags(const char *name, |
1032 | - void __iomem *reg, u8 shift, u8 width, const char **parents, |
1033 | - int num_parents, unsigned long flags) |
1034 | + void __iomem *reg, u8 shift, u8 width, |
1035 | + const char * const *parents, int num_parents, |
1036 | + unsigned long flags) |
1037 | { |
1038 | return clk_register_mux(NULL, name, parents, num_parents, |
1039 | flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0, |
1040 | diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c |
1041 | index 74697e145dde..50060e895e7a 100644 |
1042 | --- a/drivers/clk/meson/meson8b.c |
1043 | +++ b/drivers/clk/meson/meson8b.c |
1044 | @@ -568,13 +568,14 @@ static struct clk_fixed_factor meson8b_cpu_div3 = { |
1045 | }; |
1046 | |
1047 | static const struct clk_div_table cpu_scale_table[] = { |
1048 | - { .val = 2, .div = 4 }, |
1049 | - { .val = 3, .div = 6 }, |
1050 | - { .val = 4, .div = 8 }, |
1051 | - { .val = 5, .div = 10 }, |
1052 | - { .val = 6, .div = 12 }, |
1053 | - { .val = 7, .div = 14 }, |
1054 | - { .val = 8, .div = 16 }, |
1055 | + { .val = 1, .div = 4 }, |
1056 | + { .val = 2, .div = 6 }, |
1057 | + { .val = 3, .div = 8 }, |
1058 | + { .val = 4, .div = 10 }, |
1059 | + { .val = 5, .div = 12 }, |
1060 | + { .val = 6, .div = 14 }, |
1061 | + { .val = 7, .div = 16 }, |
1062 | + { .val = 8, .div = 18 }, |
1063 | { /* sentinel */ }, |
1064 | }; |
1065 | |
1066 | diff --git a/drivers/clocksource/timer-integrator-ap.c b/drivers/clocksource/timer-integrator-ap.c |
1067 | index 62d24690ba02..9701107806a7 100644 |
1068 | --- a/drivers/clocksource/timer-integrator-ap.c |
1069 | +++ b/drivers/clocksource/timer-integrator-ap.c |
1070 | @@ -181,8 +181,7 @@ static int __init integrator_ap_timer_init_of(struct device_node *node) |
1071 | int irq; |
1072 | struct clk *clk; |
1073 | unsigned long rate; |
1074 | - struct device_node *pri_node; |
1075 | - struct device_node *sec_node; |
1076 | + struct device_node *alias_node; |
1077 | |
1078 | base = of_io_request_and_map(node, 0, "integrator-timer"); |
1079 | if (IS_ERR(base)) |
1080 | @@ -204,7 +203,18 @@ static int __init integrator_ap_timer_init_of(struct device_node *node) |
1081 | return err; |
1082 | } |
1083 | |
1084 | - pri_node = of_find_node_by_path(path); |
1085 | + alias_node = of_find_node_by_path(path); |
1086 | + |
1087 | + /* |
1088 | + * The pointer is used as an identifier not as a pointer, we |
1089 | + * can drop the refcount on the of__node immediately after |
1090 | + * getting it. |
1091 | + */ |
1092 | + of_node_put(alias_node); |
1093 | + |
1094 | + if (node == alias_node) |
1095 | + /* The primary timer lacks IRQ, use as clocksource */ |
1096 | + return integrator_clocksource_init(rate, base); |
1097 | |
1098 | err = of_property_read_string(of_aliases, |
1099 | "arm,timer-secondary", &path); |
1100 | @@ -213,14 +223,11 @@ static int __init integrator_ap_timer_init_of(struct device_node *node) |
1101 | return err; |
1102 | } |
1103 | |
1104 | + alias_node = of_find_node_by_path(path); |
1105 | |
1106 | - sec_node = of_find_node_by_path(path); |
1107 | - |
1108 | - if (node == pri_node) |
1109 | - /* The primary timer lacks IRQ, use as clocksource */ |
1110 | - return integrator_clocksource_init(rate, base); |
1111 | + of_node_put(alias_node); |
1112 | |
1113 | - if (node == sec_node) { |
1114 | + if (node == alias_node) { |
1115 | /* The secondary timer will drive the clock event */ |
1116 | irq = irq_of_parse_and_map(node, 0); |
1117 | return integrator_clockevent_init(rate, base, irq); |
1118 | diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c |
1119 | index 9e56bc411061..74c247972bb3 100644 |
1120 | --- a/drivers/cpuidle/cpuidle-pseries.c |
1121 | +++ b/drivers/cpuidle/cpuidle-pseries.c |
1122 | @@ -247,7 +247,13 @@ static int pseries_idle_probe(void) |
1123 | return -ENODEV; |
1124 | |
1125 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) { |
1126 | - if (lppaca_shared_proc(get_lppaca())) { |
1127 | + /* |
1128 | + * Use local_paca instead of get_lppaca() since |
1129 | + * preemption is not disabled, and it is not required in |
1130 | + * fact, since lppaca_ptr does not need to be the value |
1131 | + * associated to the current CPU, it can be from any CPU. |
1132 | + */ |
1133 | + if (lppaca_shared_proc(local_paca->lppaca_ptr)) { |
1134 | cpuidle_state_table = shared_states; |
1135 | max_idle_state = ARRAY_SIZE(shared_states); |
1136 | } else { |
1137 | diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile |
1138 | index c51627660dbb..d9845099635e 100644 |
1139 | --- a/drivers/firmware/efi/libstub/Makefile |
1140 | +++ b/drivers/firmware/efi/libstub/Makefile |
1141 | @@ -9,7 +9,10 @@ cflags-$(CONFIG_X86_32) := -march=i386 |
1142 | cflags-$(CONFIG_X86_64) := -mcmodel=small |
1143 | cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -O2 \ |
1144 | -fPIC -fno-strict-aliasing -mno-red-zone \ |
1145 | - -mno-mmx -mno-sse -fshort-wchar |
1146 | + -mno-mmx -mno-sse -fshort-wchar \ |
1147 | + -Wno-pointer-sign \ |
1148 | + $(call cc-disable-warning, address-of-packed-member) \ |
1149 | + $(call cc-disable-warning, gnu) |
1150 | |
1151 | # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly |
1152 | # disable the stackleak plugin |
1153 | diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c |
1154 | index 7fa793672a7a..68e4b2b98c8f 100644 |
1155 | --- a/drivers/fpga/altera-cvp.c |
1156 | +++ b/drivers/fpga/altera-cvp.c |
1157 | @@ -468,14 +468,6 @@ static int altera_cvp_probe(struct pci_dev *pdev, |
1158 | goto err_unmap; |
1159 | } |
1160 | |
1161 | - ret = driver_create_file(&altera_cvp_driver.driver, |
1162 | - &driver_attr_chkcfg); |
1163 | - if (ret) { |
1164 | - dev_err(&pdev->dev, "Can't create sysfs chkcfg file\n"); |
1165 | - fpga_mgr_unregister(mgr); |
1166 | - goto err_unmap; |
1167 | - } |
1168 | - |
1169 | return 0; |
1170 | |
1171 | err_unmap: |
1172 | @@ -493,7 +485,6 @@ static void altera_cvp_remove(struct pci_dev *pdev) |
1173 | struct altera_cvp_conf *conf = mgr->priv; |
1174 | u16 cmd; |
1175 | |
1176 | - driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg); |
1177 | fpga_mgr_unregister(mgr); |
1178 | pci_iounmap(pdev, conf->map); |
1179 | pci_release_region(pdev, CVP_BAR); |
1180 | @@ -502,7 +493,30 @@ static void altera_cvp_remove(struct pci_dev *pdev) |
1181 | pci_write_config_word(pdev, PCI_COMMAND, cmd); |
1182 | } |
1183 | |
1184 | -module_pci_driver(altera_cvp_driver); |
1185 | +static int __init altera_cvp_init(void) |
1186 | +{ |
1187 | + int ret; |
1188 | + |
1189 | + ret = pci_register_driver(&altera_cvp_driver); |
1190 | + if (ret) |
1191 | + return ret; |
1192 | + |
1193 | + ret = driver_create_file(&altera_cvp_driver.driver, |
1194 | + &driver_attr_chkcfg); |
1195 | + if (ret) |
1196 | + pr_warn("Can't create sysfs chkcfg file\n"); |
1197 | + |
1198 | + return 0; |
1199 | +} |
1200 | + |
1201 | +static void __exit altera_cvp_exit(void) |
1202 | +{ |
1203 | + driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg); |
1204 | + pci_unregister_driver(&altera_cvp_driver); |
1205 | +} |
1206 | + |
1207 | +module_init(altera_cvp_init); |
1208 | +module_exit(altera_cvp_exit); |
1209 | |
1210 | MODULE_LICENSE("GPL v2"); |
1211 | MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>"); |
1212 | diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c |
1213 | index 2afd9de84a0d..dc42571e6fdc 100644 |
1214 | --- a/drivers/gpio/gpio-pl061.c |
1215 | +++ b/drivers/gpio/gpio-pl061.c |
1216 | @@ -54,6 +54,7 @@ struct pl061 { |
1217 | |
1218 | void __iomem *base; |
1219 | struct gpio_chip gc; |
1220 | + struct irq_chip irq_chip; |
1221 | int parent_irq; |
1222 | |
1223 | #ifdef CONFIG_PM |
1224 | @@ -281,15 +282,6 @@ static int pl061_irq_set_wake(struct irq_data *d, unsigned int state) |
1225 | return irq_set_irq_wake(pl061->parent_irq, state); |
1226 | } |
1227 | |
1228 | -static struct irq_chip pl061_irqchip = { |
1229 | - .name = "pl061", |
1230 | - .irq_ack = pl061_irq_ack, |
1231 | - .irq_mask = pl061_irq_mask, |
1232 | - .irq_unmask = pl061_irq_unmask, |
1233 | - .irq_set_type = pl061_irq_type, |
1234 | - .irq_set_wake = pl061_irq_set_wake, |
1235 | -}; |
1236 | - |
1237 | static int pl061_probe(struct amba_device *adev, const struct amba_id *id) |
1238 | { |
1239 | struct device *dev = &adev->dev; |
1240 | @@ -328,6 +320,13 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) |
1241 | /* |
1242 | * irq_chip support |
1243 | */ |
1244 | + pl061->irq_chip.name = dev_name(dev); |
1245 | + pl061->irq_chip.irq_ack = pl061_irq_ack; |
1246 | + pl061->irq_chip.irq_mask = pl061_irq_mask; |
1247 | + pl061->irq_chip.irq_unmask = pl061_irq_unmask; |
1248 | + pl061->irq_chip.irq_set_type = pl061_irq_type; |
1249 | + pl061->irq_chip.irq_set_wake = pl061_irq_set_wake; |
1250 | + |
1251 | writeb(0, pl061->base + GPIOIE); /* disable irqs */ |
1252 | irq = adev->irq[0]; |
1253 | if (irq < 0) { |
1254 | @@ -336,14 +335,14 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) |
1255 | } |
1256 | pl061->parent_irq = irq; |
1257 | |
1258 | - ret = gpiochip_irqchip_add(&pl061->gc, &pl061_irqchip, |
1259 | + ret = gpiochip_irqchip_add(&pl061->gc, &pl061->irq_chip, |
1260 | 0, handle_bad_irq, |
1261 | IRQ_TYPE_NONE); |
1262 | if (ret) { |
1263 | dev_info(&adev->dev, "could not add irqchip\n"); |
1264 | return ret; |
1265 | } |
1266 | - gpiochip_set_chained_irqchip(&pl061->gc, &pl061_irqchip, |
1267 | + gpiochip_set_chained_irqchip(&pl061->gc, &pl061->irq_chip, |
1268 | irq, pl061_irq_handler); |
1269 | |
1270 | amba_set_drvdata(adev, pl061); |
1271 | diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c |
1272 | index 8a926d1df939..2b4199adcd94 100644 |
1273 | --- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c |
1274 | +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c |
1275 | @@ -116,16 +116,16 @@ static int uvd_v4_2_sw_init(void *handle) |
1276 | if (r) |
1277 | return r; |
1278 | |
1279 | - r = amdgpu_uvd_resume(adev); |
1280 | - if (r) |
1281 | - return r; |
1282 | - |
1283 | ring = &adev->uvd.inst->ring; |
1284 | sprintf(ring->name, "uvd"); |
1285 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst->irq, 0); |
1286 | if (r) |
1287 | return r; |
1288 | |
1289 | + r = amdgpu_uvd_resume(adev); |
1290 | + if (r) |
1291 | + return r; |
1292 | + |
1293 | r = amdgpu_uvd_entity_init(adev); |
1294 | |
1295 | return r; |
1296 | diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c |
1297 | index 50248059412e..88c006c5ee2c 100644 |
1298 | --- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c |
1299 | +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c |
1300 | @@ -113,16 +113,16 @@ static int uvd_v5_0_sw_init(void *handle) |
1301 | if (r) |
1302 | return r; |
1303 | |
1304 | - r = amdgpu_uvd_resume(adev); |
1305 | - if (r) |
1306 | - return r; |
1307 | - |
1308 | ring = &adev->uvd.inst->ring; |
1309 | sprintf(ring->name, "uvd"); |
1310 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst->irq, 0); |
1311 | if (r) |
1312 | return r; |
1313 | |
1314 | + r = amdgpu_uvd_resume(adev); |
1315 | + if (r) |
1316 | + return r; |
1317 | + |
1318 | r = amdgpu_uvd_entity_init(adev); |
1319 | |
1320 | return r; |
1321 | diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c |
1322 | index 6ae82cc2e55e..d4070839ac80 100644 |
1323 | --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c |
1324 | +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c |
1325 | @@ -420,16 +420,16 @@ static int uvd_v6_0_sw_init(void *handle) |
1326 | DRM_INFO("UVD ENC is disabled\n"); |
1327 | } |
1328 | |
1329 | - r = amdgpu_uvd_resume(adev); |
1330 | - if (r) |
1331 | - return r; |
1332 | - |
1333 | ring = &adev->uvd.inst->ring; |
1334 | sprintf(ring->name, "uvd"); |
1335 | r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst->irq, 0); |
1336 | if (r) |
1337 | return r; |
1338 | |
1339 | + r = amdgpu_uvd_resume(adev); |
1340 | + if (r) |
1341 | + return r; |
1342 | + |
1343 | if (uvd_v6_0_enc_support(adev)) { |
1344 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) { |
1345 | ring = &adev->uvd.inst->ring_enc[i]; |
1346 | diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c |
1347 | index 9b7f8469bc5c..057151b17b45 100644 |
1348 | --- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c |
1349 | +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c |
1350 | @@ -444,10 +444,6 @@ static int uvd_v7_0_sw_init(void *handle) |
1351 | DRM_INFO("PSP loading UVD firmware\n"); |
1352 | } |
1353 | |
1354 | - r = amdgpu_uvd_resume(adev); |
1355 | - if (r) |
1356 | - return r; |
1357 | - |
1358 | for (j = 0; j < adev->uvd.num_uvd_inst; j++) { |
1359 | if (adev->uvd.harvest_config & (1 << j)) |
1360 | continue; |
1361 | @@ -479,6 +475,10 @@ static int uvd_v7_0_sw_init(void *handle) |
1362 | } |
1363 | } |
1364 | |
1365 | + r = amdgpu_uvd_resume(adev); |
1366 | + if (r) |
1367 | + return r; |
1368 | + |
1369 | r = amdgpu_uvd_entity_init(adev); |
1370 | if (r) |
1371 | return r; |
1372 | diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c |
1373 | index 1427675d0e5a..5aba50f63ac6 100644 |
1374 | --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c |
1375 | +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c |
1376 | @@ -661,6 +661,7 @@ void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry) |
1377 | { |
1378 | uint32_t patched_ihre[KFD_MAX_RING_ENTRY_SIZE]; |
1379 | bool is_patched = false; |
1380 | + unsigned long flags; |
1381 | |
1382 | if (!kfd->init_complete) |
1383 | return; |
1384 | @@ -670,7 +671,7 @@ void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry) |
1385 | return; |
1386 | } |
1387 | |
1388 | - spin_lock(&kfd->interrupt_lock); |
1389 | + spin_lock_irqsave(&kfd->interrupt_lock, flags); |
1390 | |
1391 | if (kfd->interrupts_active |
1392 | && interrupt_is_wanted(kfd, ih_ring_entry, |
1393 | @@ -679,7 +680,7 @@ void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry) |
1394 | is_patched ? patched_ihre : ih_ring_entry)) |
1395 | queue_work(kfd->ih_wq, &kfd->interrupt_work); |
1396 | |
1397 | - spin_unlock(&kfd->interrupt_lock); |
1398 | + spin_unlock_irqrestore(&kfd->interrupt_lock, flags); |
1399 | } |
1400 | |
1401 | int kgd2kfd_quiesce_mm(struct mm_struct *mm) |
1402 | diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c |
1403 | index 9bfb040352e9..6a6d977ddd7a 100644 |
1404 | --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c |
1405 | +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c |
1406 | @@ -60,6 +60,11 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name, |
1407 | return -EINVAL; |
1408 | } |
1409 | |
1410 | + if (!stream_state) { |
1411 | + DRM_ERROR("No stream state for CRTC%d\n", crtc->index); |
1412 | + return -EINVAL; |
1413 | + } |
1414 | + |
1415 | /* When enabling CRC, we should also disable dithering. */ |
1416 | if (source == AMDGPU_DM_PIPE_CRC_SOURCE_AUTO) { |
1417 | if (dc_stream_configure_crc(stream_state->ctx->dc, |
1418 | diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c |
1419 | index 1bb4c318bdd4..f77bff5aa307 100644 |
1420 | --- a/drivers/gpu/drm/drm_atomic_helper.c |
1421 | +++ b/drivers/gpu/drm/drm_atomic_helper.c |
1422 | @@ -1425,6 +1425,9 @@ void drm_atomic_helper_wait_for_flip_done(struct drm_device *dev, |
1423 | DRM_ERROR("[CRTC:%d:%s] flip_done timed out\n", |
1424 | crtc->base.id, crtc->name); |
1425 | } |
1426 | + |
1427 | + if (old_state->fake_commit) |
1428 | + complete_all(&old_state->fake_commit->flip_done); |
1429 | } |
1430 | EXPORT_SYMBOL(drm_atomic_helper_wait_for_flip_done); |
1431 | |
1432 | diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c |
1433 | index 9973ac893635..3db232429630 100644 |
1434 | --- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c |
1435 | +++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c |
1436 | @@ -334,13 +334,16 @@ int usnic_ib_query_port(struct ib_device *ibdev, u8 port, |
1437 | |
1438 | usnic_dbg("\n"); |
1439 | |
1440 | - mutex_lock(&us_ibdev->usdev_lock); |
1441 | if (ib_get_eth_speed(ibdev, port, &props->active_speed, |
1442 | - &props->active_width)) { |
1443 | - mutex_unlock(&us_ibdev->usdev_lock); |
1444 | + &props->active_width)) |
1445 | return -EINVAL; |
1446 | - } |
1447 | |
1448 | + /* |
1449 | + * usdev_lock is acquired after (and not before) ib_get_eth_speed call |
1450 | + * because acquiring rtnl_lock in ib_get_eth_speed, while holding |
1451 | + * usdev_lock could lead to a deadlock. |
1452 | + */ |
1453 | + mutex_lock(&us_ibdev->usdev_lock); |
1454 | /* props being zeroed by the caller, avoid zeroing it here */ |
1455 | |
1456 | props->lid = 0; |
1457 | diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c |
1458 | index 8be27238a86e..fa98a5279647 100644 |
1459 | --- a/drivers/infiniband/sw/rxe/rxe_req.c |
1460 | +++ b/drivers/infiniband/sw/rxe/rxe_req.c |
1461 | @@ -640,6 +640,7 @@ next_wqe: |
1462 | rmr->access = wqe->wr.wr.reg.access; |
1463 | rmr->lkey = wqe->wr.wr.reg.key; |
1464 | rmr->rkey = wqe->wr.wr.reg.key; |
1465 | + rmr->iova = wqe->wr.wr.reg.mr->iova; |
1466 | wqe->state = wqe_state_done; |
1467 | wqe->status = IB_WC_SUCCESS; |
1468 | } else { |
1469 | diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c |
1470 | index 0481223b1deb..f2ec882f96be 100644 |
1471 | --- a/drivers/md/dm-crypt.c |
1472 | +++ b/drivers/md/dm-crypt.c |
1473 | @@ -49,7 +49,7 @@ struct convert_context { |
1474 | struct bio *bio_out; |
1475 | struct bvec_iter iter_in; |
1476 | struct bvec_iter iter_out; |
1477 | - sector_t cc_sector; |
1478 | + u64 cc_sector; |
1479 | atomic_t cc_pending; |
1480 | union { |
1481 | struct skcipher_request *req; |
1482 | @@ -81,7 +81,7 @@ struct dm_crypt_request { |
1483 | struct convert_context *ctx; |
1484 | struct scatterlist sg_in[4]; |
1485 | struct scatterlist sg_out[4]; |
1486 | - sector_t iv_sector; |
1487 | + u64 iv_sector; |
1488 | }; |
1489 | |
1490 | struct crypt_config; |
1491 | @@ -160,7 +160,7 @@ struct crypt_config { |
1492 | struct iv_lmk_private lmk; |
1493 | struct iv_tcw_private tcw; |
1494 | } iv_gen_private; |
1495 | - sector_t iv_offset; |
1496 | + u64 iv_offset; |
1497 | unsigned int iv_size; |
1498 | unsigned short int sector_size; |
1499 | unsigned char sector_shift; |
1500 | @@ -2780,7 +2780,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) |
1501 | } |
1502 | |
1503 | ret = -EINVAL; |
1504 | - if (sscanf(argv[4], "%llu%c", &tmpll, &dummy) != 1) { |
1505 | + if (sscanf(argv[4], "%llu%c", &tmpll, &dummy) != 1 || tmpll != (sector_t)tmpll) { |
1506 | ti->error = "Invalid device sector"; |
1507 | goto bad; |
1508 | } |
1509 | diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c |
1510 | index 2fb7bb4304ad..fddffe251bf6 100644 |
1511 | --- a/drivers/md/dm-delay.c |
1512 | +++ b/drivers/md/dm-delay.c |
1513 | @@ -141,7 +141,7 @@ static int delay_class_ctr(struct dm_target *ti, struct delay_class *c, char **a |
1514 | unsigned long long tmpll; |
1515 | char dummy; |
1516 | |
1517 | - if (sscanf(argv[1], "%llu%c", &tmpll, &dummy) != 1) { |
1518 | + if (sscanf(argv[1], "%llu%c", &tmpll, &dummy) != 1 || tmpll != (sector_t)tmpll) { |
1519 | ti->error = "Invalid device sector"; |
1520 | return -EINVAL; |
1521 | } |
1522 | diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c |
1523 | index 32aabe27b37c..b86d2439ffc7 100644 |
1524 | --- a/drivers/md/dm-flakey.c |
1525 | +++ b/drivers/md/dm-flakey.c |
1526 | @@ -213,7 +213,7 @@ static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv) |
1527 | devname = dm_shift_arg(&as); |
1528 | |
1529 | r = -EINVAL; |
1530 | - if (sscanf(dm_shift_arg(&as), "%llu%c", &tmpll, &dummy) != 1) { |
1531 | + if (sscanf(dm_shift_arg(&as), "%llu%c", &tmpll, &dummy) != 1 || tmpll != (sector_t)tmpll) { |
1532 | ti->error = "Invalid device sector"; |
1533 | goto bad; |
1534 | } |
1535 | diff --git a/drivers/md/dm-kcopyd.c b/drivers/md/dm-kcopyd.c |
1536 | index 2fc4213e02b5..671c24332802 100644 |
1537 | --- a/drivers/md/dm-kcopyd.c |
1538 | +++ b/drivers/md/dm-kcopyd.c |
1539 | @@ -56,15 +56,17 @@ struct dm_kcopyd_client { |
1540 | atomic_t nr_jobs; |
1541 | |
1542 | /* |
1543 | - * We maintain three lists of jobs: |
1544 | + * We maintain four lists of jobs: |
1545 | * |
1546 | * i) jobs waiting for pages |
1547 | * ii) jobs that have pages, and are waiting for the io to be issued. |
1548 | - * iii) jobs that have completed. |
1549 | + * iii) jobs that don't need to do any IO and just run a callback |
1550 | + * iv) jobs that have completed. |
1551 | * |
1552 | - * All three of these are protected by job_lock. |
1553 | + * All four of these are protected by job_lock. |
1554 | */ |
1555 | spinlock_t job_lock; |
1556 | + struct list_head callback_jobs; |
1557 | struct list_head complete_jobs; |
1558 | struct list_head io_jobs; |
1559 | struct list_head pages_jobs; |
1560 | @@ -625,6 +627,7 @@ static void do_work(struct work_struct *work) |
1561 | struct dm_kcopyd_client *kc = container_of(work, |
1562 | struct dm_kcopyd_client, kcopyd_work); |
1563 | struct blk_plug plug; |
1564 | + unsigned long flags; |
1565 | |
1566 | /* |
1567 | * The order that these are called is *very* important. |
1568 | @@ -633,6 +636,10 @@ static void do_work(struct work_struct *work) |
1569 | * list. io jobs call wake when they complete and it all |
1570 | * starts again. |
1571 | */ |
1572 | + spin_lock_irqsave(&kc->job_lock, flags); |
1573 | + list_splice_tail_init(&kc->callback_jobs, &kc->complete_jobs); |
1574 | + spin_unlock_irqrestore(&kc->job_lock, flags); |
1575 | + |
1576 | blk_start_plug(&plug); |
1577 | process_jobs(&kc->complete_jobs, kc, run_complete_job); |
1578 | process_jobs(&kc->pages_jobs, kc, run_pages_job); |
1579 | @@ -650,7 +657,7 @@ static void dispatch_job(struct kcopyd_job *job) |
1580 | struct dm_kcopyd_client *kc = job->kc; |
1581 | atomic_inc(&kc->nr_jobs); |
1582 | if (unlikely(!job->source.count)) |
1583 | - push(&kc->complete_jobs, job); |
1584 | + push(&kc->callback_jobs, job); |
1585 | else if (job->pages == &zero_page_list) |
1586 | push(&kc->io_jobs, job); |
1587 | else |
1588 | @@ -858,7 +865,7 @@ void dm_kcopyd_do_callback(void *j, int read_err, unsigned long write_err) |
1589 | job->read_err = read_err; |
1590 | job->write_err = write_err; |
1591 | |
1592 | - push(&kc->complete_jobs, job); |
1593 | + push(&kc->callback_jobs, job); |
1594 | wake(kc); |
1595 | } |
1596 | EXPORT_SYMBOL(dm_kcopyd_do_callback); |
1597 | @@ -888,6 +895,7 @@ struct dm_kcopyd_client *dm_kcopyd_client_create(struct dm_kcopyd_throttle *thro |
1598 | return ERR_PTR(-ENOMEM); |
1599 | |
1600 | spin_lock_init(&kc->job_lock); |
1601 | + INIT_LIST_HEAD(&kc->callback_jobs); |
1602 | INIT_LIST_HEAD(&kc->complete_jobs); |
1603 | INIT_LIST_HEAD(&kc->io_jobs); |
1604 | INIT_LIST_HEAD(&kc->pages_jobs); |
1605 | @@ -939,6 +947,7 @@ void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc) |
1606 | /* Wait for completion of all jobs submitted by this client. */ |
1607 | wait_event(kc->destroyq, !atomic_read(&kc->nr_jobs)); |
1608 | |
1609 | + BUG_ON(!list_empty(&kc->callback_jobs)); |
1610 | BUG_ON(!list_empty(&kc->complete_jobs)); |
1611 | BUG_ON(!list_empty(&kc->io_jobs)); |
1612 | BUG_ON(!list_empty(&kc->pages_jobs)); |
1613 | diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c |
1614 | index 2f7c44a006c4..caa08c4b84cd 100644 |
1615 | --- a/drivers/md/dm-linear.c |
1616 | +++ b/drivers/md/dm-linear.c |
1617 | @@ -45,7 +45,7 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv) |
1618 | } |
1619 | |
1620 | ret = -EINVAL; |
1621 | - if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1) { |
1622 | + if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1 || tmp != (sector_t)tmp) { |
1623 | ti->error = "Invalid device sector"; |
1624 | goto bad; |
1625 | } |
1626 | diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c |
1627 | index 79eab1071ec2..5a51151f680d 100644 |
1628 | --- a/drivers/md/dm-raid1.c |
1629 | +++ b/drivers/md/dm-raid1.c |
1630 | @@ -943,7 +943,8 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti, |
1631 | char dummy; |
1632 | int ret; |
1633 | |
1634 | - if (sscanf(argv[1], "%llu%c", &offset, &dummy) != 1) { |
1635 | + if (sscanf(argv[1], "%llu%c", &offset, &dummy) != 1 || |
1636 | + offset != (sector_t)offset) { |
1637 | ti->error = "Invalid offset"; |
1638 | return -EINVAL; |
1639 | } |
1640 | diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c |
1641 | index ae4b33d10924..36805b12661e 100644 |
1642 | --- a/drivers/md/dm-snap.c |
1643 | +++ b/drivers/md/dm-snap.c |
1644 | @@ -19,6 +19,7 @@ |
1645 | #include <linux/vmalloc.h> |
1646 | #include <linux/log2.h> |
1647 | #include <linux/dm-kcopyd.h> |
1648 | +#include <linux/semaphore.h> |
1649 | |
1650 | #include "dm.h" |
1651 | |
1652 | @@ -105,6 +106,9 @@ struct dm_snapshot { |
1653 | /* The on disk metadata handler */ |
1654 | struct dm_exception_store *store; |
1655 | |
1656 | + /* Maximum number of in-flight COW jobs. */ |
1657 | + struct semaphore cow_count; |
1658 | + |
1659 | struct dm_kcopyd_client *kcopyd_client; |
1660 | |
1661 | /* Wait for events based on state_bits */ |
1662 | @@ -145,6 +149,19 @@ struct dm_snapshot { |
1663 | #define RUNNING_MERGE 0 |
1664 | #define SHUTDOWN_MERGE 1 |
1665 | |
1666 | +/* |
1667 | + * Maximum number of chunks being copied on write. |
1668 | + * |
1669 | + * The value was decided experimentally as a trade-off between memory |
1670 | + * consumption, stalling the kernel's workqueues and maintaining a high enough |
1671 | + * throughput. |
1672 | + */ |
1673 | +#define DEFAULT_COW_THRESHOLD 2048 |
1674 | + |
1675 | +static int cow_threshold = DEFAULT_COW_THRESHOLD; |
1676 | +module_param_named(snapshot_cow_threshold, cow_threshold, int, 0644); |
1677 | +MODULE_PARM_DESC(snapshot_cow_threshold, "Maximum number of chunks being copied on write"); |
1678 | + |
1679 | DECLARE_DM_KCOPYD_THROTTLE_WITH_MODULE_PARM(snapshot_copy_throttle, |
1680 | "A percentage of time allocated for copy on write"); |
1681 | |
1682 | @@ -1190,6 +1207,8 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) |
1683 | goto bad_hash_tables; |
1684 | } |
1685 | |
1686 | + sema_init(&s->cow_count, (cow_threshold > 0) ? cow_threshold : INT_MAX); |
1687 | + |
1688 | s->kcopyd_client = dm_kcopyd_client_create(&dm_kcopyd_throttle); |
1689 | if (IS_ERR(s->kcopyd_client)) { |
1690 | r = PTR_ERR(s->kcopyd_client); |
1691 | @@ -1575,6 +1594,7 @@ static void copy_callback(int read_err, unsigned long write_err, void *context) |
1692 | rb_link_node(&pe->out_of_order_node, parent, p); |
1693 | rb_insert_color(&pe->out_of_order_node, &s->out_of_order_tree); |
1694 | } |
1695 | + up(&s->cow_count); |
1696 | } |
1697 | |
1698 | /* |
1699 | @@ -1598,6 +1618,7 @@ static void start_copy(struct dm_snap_pending_exception *pe) |
1700 | dest.count = src.count; |
1701 | |
1702 | /* Hand over to kcopyd */ |
1703 | + down(&s->cow_count); |
1704 | dm_kcopyd_copy(s->kcopyd_client, &src, 1, &dest, 0, copy_callback, pe); |
1705 | } |
1706 | |
1707 | @@ -1617,6 +1638,7 @@ static void start_full_bio(struct dm_snap_pending_exception *pe, |
1708 | pe->full_bio = bio; |
1709 | pe->full_bio_end_io = bio->bi_end_io; |
1710 | |
1711 | + down(&s->cow_count); |
1712 | callback_data = dm_kcopyd_prepare_callback(s->kcopyd_client, |
1713 | copy_callback, pe); |
1714 | |
1715 | diff --git a/drivers/md/dm-unstripe.c b/drivers/md/dm-unstripe.c |
1716 | index 954b7ab4e684..e673dacf6418 100644 |
1717 | --- a/drivers/md/dm-unstripe.c |
1718 | +++ b/drivers/md/dm-unstripe.c |
1719 | @@ -78,7 +78,7 @@ static int unstripe_ctr(struct dm_target *ti, unsigned int argc, char **argv) |
1720 | goto err; |
1721 | } |
1722 | |
1723 | - if (sscanf(argv[4], "%llu%c", &start, &dummy) != 1) { |
1724 | + if (sscanf(argv[4], "%llu%c", &start, &dummy) != 1 || start != (sector_t)start) { |
1725 | ti->error = "Invalid striped device offset"; |
1726 | goto err; |
1727 | } |
1728 | diff --git a/drivers/media/firewire/firedtv-avc.c b/drivers/media/firewire/firedtv-avc.c |
1729 | index 1c933b2cf760..3ef5df1648d7 100644 |
1730 | --- a/drivers/media/firewire/firedtv-avc.c |
1731 | +++ b/drivers/media/firewire/firedtv-avc.c |
1732 | @@ -968,7 +968,8 @@ static int get_ca_object_length(struct avc_response_frame *r) |
1733 | return r->operand[7]; |
1734 | } |
1735 | |
1736 | -int avc_ca_app_info(struct firedtv *fdtv, char *app_info, unsigned int *len) |
1737 | +int avc_ca_app_info(struct firedtv *fdtv, unsigned char *app_info, |
1738 | + unsigned int *len) |
1739 | { |
1740 | struct avc_command_frame *c = (void *)fdtv->avc_data; |
1741 | struct avc_response_frame *r = (void *)fdtv->avc_data; |
1742 | @@ -1009,7 +1010,8 @@ out: |
1743 | return ret; |
1744 | } |
1745 | |
1746 | -int avc_ca_info(struct firedtv *fdtv, char *app_info, unsigned int *len) |
1747 | +int avc_ca_info(struct firedtv *fdtv, unsigned char *app_info, |
1748 | + unsigned int *len) |
1749 | { |
1750 | struct avc_command_frame *c = (void *)fdtv->avc_data; |
1751 | struct avc_response_frame *r = (void *)fdtv->avc_data; |
1752 | diff --git a/drivers/media/firewire/firedtv.h b/drivers/media/firewire/firedtv.h |
1753 | index 876cdec8329b..009905a19947 100644 |
1754 | --- a/drivers/media/firewire/firedtv.h |
1755 | +++ b/drivers/media/firewire/firedtv.h |
1756 | @@ -124,8 +124,10 @@ int avc_lnb_control(struct firedtv *fdtv, char voltage, char burst, |
1757 | struct dvb_diseqc_master_cmd *diseqcmd); |
1758 | void avc_remote_ctrl_work(struct work_struct *work); |
1759 | int avc_register_remote_control(struct firedtv *fdtv); |
1760 | -int avc_ca_app_info(struct firedtv *fdtv, char *app_info, unsigned int *len); |
1761 | -int avc_ca_info(struct firedtv *fdtv, char *app_info, unsigned int *len); |
1762 | +int avc_ca_app_info(struct firedtv *fdtv, unsigned char *app_info, |
1763 | + unsigned int *len); |
1764 | +int avc_ca_info(struct firedtv *fdtv, unsigned char *app_info, |
1765 | + unsigned int *len); |
1766 | int avc_ca_reset(struct firedtv *fdtv); |
1767 | int avc_ca_pmt(struct firedtv *fdtv, char *app_info, int length); |
1768 | int avc_ca_get_time_date(struct firedtv *fdtv, int *interval); |
1769 | diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c |
1770 | index bb6add9d340e..5b8350e87e75 100644 |
1771 | --- a/drivers/media/platform/qcom/venus/core.c |
1772 | +++ b/drivers/media/platform/qcom/venus/core.c |
1773 | @@ -264,6 +264,14 @@ static int venus_probe(struct platform_device *pdev) |
1774 | if (ret) |
1775 | return ret; |
1776 | |
1777 | + if (!dev->dma_parms) { |
1778 | + dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), |
1779 | + GFP_KERNEL); |
1780 | + if (!dev->dma_parms) |
1781 | + return -ENOMEM; |
1782 | + } |
1783 | + dma_set_max_seg_size(dev, DMA_BIT_MASK(32)); |
1784 | + |
1785 | INIT_LIST_HEAD(&core->instances); |
1786 | mutex_init(&core->lock); |
1787 | INIT_DELAYED_WORK(&core->work, venus_sys_error_handler); |
1788 | diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c |
1789 | index d46dc432456c..361abbc00486 100644 |
1790 | --- a/drivers/media/usb/uvc/uvc_driver.c |
1791 | +++ b/drivers/media/usb/uvc/uvc_driver.c |
1792 | @@ -1824,11 +1824,7 @@ static void uvc_delete(struct kref *kref) |
1793 | usb_put_intf(dev->intf); |
1794 | usb_put_dev(dev->udev); |
1795 | |
1796 | - if (dev->vdev.dev) |
1797 | - v4l2_device_unregister(&dev->vdev); |
1798 | #ifdef CONFIG_MEDIA_CONTROLLER |
1799 | - if (media_devnode_is_registered(dev->mdev.devnode)) |
1800 | - media_device_unregister(&dev->mdev); |
1801 | media_device_cleanup(&dev->mdev); |
1802 | #endif |
1803 | |
1804 | @@ -1885,6 +1881,15 @@ static void uvc_unregister_video(struct uvc_device *dev) |
1805 | |
1806 | uvc_debugfs_cleanup_stream(stream); |
1807 | } |
1808 | + |
1809 | + uvc_status_unregister(dev); |
1810 | + |
1811 | + if (dev->vdev.dev) |
1812 | + v4l2_device_unregister(&dev->vdev); |
1813 | +#ifdef CONFIG_MEDIA_CONTROLLER |
1814 | + if (media_devnode_is_registered(dev->mdev.devnode)) |
1815 | + media_device_unregister(&dev->mdev); |
1816 | +#endif |
1817 | } |
1818 | |
1819 | int uvc_register_video_device(struct uvc_device *dev, |
1820 | diff --git a/drivers/media/usb/uvc/uvc_status.c b/drivers/media/usb/uvc/uvc_status.c |
1821 | index 0722dc684378..883e4cab45e7 100644 |
1822 | --- a/drivers/media/usb/uvc/uvc_status.c |
1823 | +++ b/drivers/media/usb/uvc/uvc_status.c |
1824 | @@ -54,7 +54,7 @@ error: |
1825 | return ret; |
1826 | } |
1827 | |
1828 | -static void uvc_input_cleanup(struct uvc_device *dev) |
1829 | +static void uvc_input_unregister(struct uvc_device *dev) |
1830 | { |
1831 | if (dev->input) |
1832 | input_unregister_device(dev->input); |
1833 | @@ -71,7 +71,7 @@ static void uvc_input_report_key(struct uvc_device *dev, unsigned int code, |
1834 | |
1835 | #else |
1836 | #define uvc_input_init(dev) |
1837 | -#define uvc_input_cleanup(dev) |
1838 | +#define uvc_input_unregister(dev) |
1839 | #define uvc_input_report_key(dev, code, value) |
1840 | #endif /* CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV */ |
1841 | |
1842 | @@ -292,12 +292,16 @@ int uvc_status_init(struct uvc_device *dev) |
1843 | return 0; |
1844 | } |
1845 | |
1846 | -void uvc_status_cleanup(struct uvc_device *dev) |
1847 | +void uvc_status_unregister(struct uvc_device *dev) |
1848 | { |
1849 | usb_kill_urb(dev->int_urb); |
1850 | + uvc_input_unregister(dev); |
1851 | +} |
1852 | + |
1853 | +void uvc_status_cleanup(struct uvc_device *dev) |
1854 | +{ |
1855 | usb_free_urb(dev->int_urb); |
1856 | kfree(dev->status); |
1857 | - uvc_input_cleanup(dev); |
1858 | } |
1859 | |
1860 | int uvc_status_start(struct uvc_device *dev, gfp_t flags) |
1861 | diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h |
1862 | index e5f5d84f1d1d..a738486fd9d6 100644 |
1863 | --- a/drivers/media/usb/uvc/uvcvideo.h |
1864 | +++ b/drivers/media/usb/uvc/uvcvideo.h |
1865 | @@ -750,6 +750,7 @@ int uvc_register_video_device(struct uvc_device *dev, |
1866 | |
1867 | /* Status */ |
1868 | int uvc_status_init(struct uvc_device *dev); |
1869 | +void uvc_status_unregister(struct uvc_device *dev); |
1870 | void uvc_status_cleanup(struct uvc_device *dev); |
1871 | int uvc_status_start(struct uvc_device *dev, gfp_t flags); |
1872 | void uvc_status_stop(struct uvc_device *dev); |
1873 | diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c |
1874 | index be53044086c7..fbc56ee99682 100644 |
1875 | --- a/drivers/mmc/host/atmel-mci.c |
1876 | +++ b/drivers/mmc/host/atmel-mci.c |
1877 | @@ -1954,13 +1954,14 @@ static void atmci_tasklet_func(unsigned long priv) |
1878 | } |
1879 | |
1880 | atmci_request_end(host, host->mrq); |
1881 | - state = STATE_IDLE; |
1882 | + goto unlock; /* atmci_request_end() sets host->state */ |
1883 | break; |
1884 | } |
1885 | } while (state != prev_state); |
1886 | |
1887 | host->state = state; |
1888 | |
1889 | +unlock: |
1890 | spin_unlock(&host->lock); |
1891 | } |
1892 | |
1893 | diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c |
1894 | index 8da3d39e3218..258918d8a416 100644 |
1895 | --- a/drivers/net/dsa/mv88e6xxx/chip.c |
1896 | +++ b/drivers/net/dsa/mv88e6xxx/chip.c |
1897 | @@ -2391,6 +2391,107 @@ static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip) |
1898 | return mv88e6xxx_g1_stats_clear(chip); |
1899 | } |
1900 | |
1901 | +/* The mv88e6390 has some hidden registers used for debug and |
1902 | + * development. The errata also makes use of them. |
1903 | + */ |
1904 | +static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port, |
1905 | + int reg, u16 val) |
1906 | +{ |
1907 | + u16 ctrl; |
1908 | + int err; |
1909 | + |
1910 | + err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT, |
1911 | + PORT_RESERVED_1A, val); |
1912 | + if (err) |
1913 | + return err; |
1914 | + |
1915 | + ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE | |
1916 | + PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT | |
1917 | + reg; |
1918 | + |
1919 | + return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT, |
1920 | + PORT_RESERVED_1A, ctrl); |
1921 | +} |
1922 | + |
1923 | +static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip) |
1924 | +{ |
1925 | + return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT, |
1926 | + PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY); |
1927 | +} |
1928 | + |
1929 | + |
1930 | +static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port, |
1931 | + int reg, u16 *val) |
1932 | +{ |
1933 | + u16 ctrl; |
1934 | + int err; |
1935 | + |
1936 | + ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ | |
1937 | + PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT | |
1938 | + reg; |
1939 | + |
1940 | + err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT, |
1941 | + PORT_RESERVED_1A, ctrl); |
1942 | + if (err) |
1943 | + return err; |
1944 | + |
1945 | + err = mv88e6390_hidden_wait(chip); |
1946 | + if (err) |
1947 | + return err; |
1948 | + |
1949 | + return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT, |
1950 | + PORT_RESERVED_1A, val); |
1951 | +} |
1952 | + |
1953 | +/* Check if the errata has already been applied. */ |
1954 | +static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip) |
1955 | +{ |
1956 | + int port; |
1957 | + int err; |
1958 | + u16 val; |
1959 | + |
1960 | + for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
1961 | + err = mv88e6390_hidden_read(chip, port, 0, &val); |
1962 | + if (err) { |
1963 | + dev_err(chip->dev, |
1964 | + "Error reading hidden register: %d\n", err); |
1965 | + return false; |
1966 | + } |
1967 | + if (val != 0x01c0) |
1968 | + return false; |
1969 | + } |
1970 | + |
1971 | + return true; |
1972 | +} |
1973 | + |
1974 | +/* The 6390 copper ports have an errata which require poking magic |
1975 | + * values into undocumented hidden registers and then performing a |
1976 | + * software reset. |
1977 | + */ |
1978 | +static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip) |
1979 | +{ |
1980 | + int port; |
1981 | + int err; |
1982 | + |
1983 | + if (mv88e6390_setup_errata_applied(chip)) |
1984 | + return 0; |
1985 | + |
1986 | + /* Set the ports into blocking mode */ |
1987 | + for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
1988 | + err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED); |
1989 | + if (err) |
1990 | + return err; |
1991 | + } |
1992 | + |
1993 | + for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
1994 | + err = mv88e6390_hidden_write(chip, port, 0, 0x01c0); |
1995 | + if (err) |
1996 | + return err; |
1997 | + } |
1998 | + |
1999 | + return mv88e6xxx_software_reset(chip); |
2000 | +} |
2001 | + |
2002 | static int mv88e6xxx_setup(struct dsa_switch *ds) |
2003 | { |
2004 | struct mv88e6xxx_chip *chip = ds->priv; |
2005 | @@ -2403,6 +2504,12 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) |
2006 | |
2007 | mutex_lock(&chip->reg_lock); |
2008 | |
2009 | + if (chip->info->ops->setup_errata) { |
2010 | + err = chip->info->ops->setup_errata(chip); |
2011 | + if (err) |
2012 | + goto unlock; |
2013 | + } |
2014 | + |
2015 | /* Cache the cmode of each port. */ |
2016 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
2017 | if (chip->info->ops->port_get_cmode) { |
2018 | @@ -3201,6 +3308,7 @@ static const struct mv88e6xxx_ops mv88e6185_ops = { |
2019 | |
2020 | static const struct mv88e6xxx_ops mv88e6190_ops = { |
2021 | /* MV88E6XXX_FAMILY_6390 */ |
2022 | + .setup_errata = mv88e6390_setup_errata, |
2023 | .irl_init_all = mv88e6390_g2_irl_init_all, |
2024 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
2025 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
2026 | @@ -3243,6 +3351,7 @@ static const struct mv88e6xxx_ops mv88e6190_ops = { |
2027 | |
2028 | static const struct mv88e6xxx_ops mv88e6190x_ops = { |
2029 | /* MV88E6XXX_FAMILY_6390 */ |
2030 | + .setup_errata = mv88e6390_setup_errata, |
2031 | .irl_init_all = mv88e6390_g2_irl_init_all, |
2032 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
2033 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
2034 | @@ -3285,6 +3394,7 @@ static const struct mv88e6xxx_ops mv88e6190x_ops = { |
2035 | |
2036 | static const struct mv88e6xxx_ops mv88e6191_ops = { |
2037 | /* MV88E6XXX_FAMILY_6390 */ |
2038 | + .setup_errata = mv88e6390_setup_errata, |
2039 | .irl_init_all = mv88e6390_g2_irl_init_all, |
2040 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
2041 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
2042 | @@ -3374,6 +3484,7 @@ static const struct mv88e6xxx_ops mv88e6240_ops = { |
2043 | |
2044 | static const struct mv88e6xxx_ops mv88e6290_ops = { |
2045 | /* MV88E6XXX_FAMILY_6390 */ |
2046 | + .setup_errata = mv88e6390_setup_errata, |
2047 | .irl_init_all = mv88e6390_g2_irl_init_all, |
2048 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
2049 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
2050 | @@ -3675,6 +3786,7 @@ static const struct mv88e6xxx_ops mv88e6352_ops = { |
2051 | |
2052 | static const struct mv88e6xxx_ops mv88e6390_ops = { |
2053 | /* MV88E6XXX_FAMILY_6390 */ |
2054 | + .setup_errata = mv88e6390_setup_errata, |
2055 | .irl_init_all = mv88e6390_g2_irl_init_all, |
2056 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
2057 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
2058 | @@ -3722,6 +3834,7 @@ static const struct mv88e6xxx_ops mv88e6390_ops = { |
2059 | |
2060 | static const struct mv88e6xxx_ops mv88e6390x_ops = { |
2061 | /* MV88E6XXX_FAMILY_6390 */ |
2062 | + .setup_errata = mv88e6390_setup_errata, |
2063 | .irl_init_all = mv88e6390_g2_irl_init_all, |
2064 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
2065 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
2066 | diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h |
2067 | index f9ecb7872d32..546651d8c3e1 100644 |
2068 | --- a/drivers/net/dsa/mv88e6xxx/chip.h |
2069 | +++ b/drivers/net/dsa/mv88e6xxx/chip.h |
2070 | @@ -300,6 +300,11 @@ struct mv88e6xxx_mdio_bus { |
2071 | }; |
2072 | |
2073 | struct mv88e6xxx_ops { |
2074 | + /* Switch Setup Errata, called early in the switch setup to |
2075 | + * allow any errata actions to be performed |
2076 | + */ |
2077 | + int (*setup_errata)(struct mv88e6xxx_chip *chip); |
2078 | + |
2079 | int (*ieee_pri_map)(struct mv88e6xxx_chip *chip); |
2080 | int (*ip_pri_map)(struct mv88e6xxx_chip *chip); |
2081 | |
2082 | diff --git a/drivers/net/dsa/mv88e6xxx/port.h b/drivers/net/dsa/mv88e6xxx/port.h |
2083 | index f32f56af8e35..b31910023bb6 100644 |
2084 | --- a/drivers/net/dsa/mv88e6xxx/port.h |
2085 | +++ b/drivers/net/dsa/mv88e6xxx/port.h |
2086 | @@ -251,6 +251,16 @@ |
2087 | /* Offset 0x19: Port IEEE Priority Remapping Registers (4-7) */ |
2088 | #define MV88E6095_PORT_IEEE_PRIO_REMAP_4567 0x19 |
2089 | |
2090 | +/* Offset 0x1a: Magic undocumented errata register */ |
2091 | +#define PORT_RESERVED_1A 0x1a |
2092 | +#define PORT_RESERVED_1A_BUSY BIT(15) |
2093 | +#define PORT_RESERVED_1A_WRITE BIT(14) |
2094 | +#define PORT_RESERVED_1A_READ 0 |
2095 | +#define PORT_RESERVED_1A_PORT_SHIFT 5 |
2096 | +#define PORT_RESERVED_1A_BLOCK (0xf << 10) |
2097 | +#define PORT_RESERVED_1A_CTRL_PORT 4 |
2098 | +#define PORT_RESERVED_1A_DATA_PORT 5 |
2099 | + |
2100 | int mv88e6xxx_port_read(struct mv88e6xxx_chip *chip, int port, int reg, |
2101 | u16 *val); |
2102 | int mv88e6xxx_port_write(struct mv88e6xxx_chip *chip, int port, int reg, |
2103 | diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c |
2104 | index 37c76945ad9b..e1f821edbc21 100644 |
2105 | --- a/drivers/net/ethernet/intel/e1000e/ptp.c |
2106 | +++ b/drivers/net/ethernet/intel/e1000e/ptp.c |
2107 | @@ -173,10 +173,14 @@ static int e1000e_phc_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts) |
2108 | struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, |
2109 | ptp_clock_info); |
2110 | unsigned long flags; |
2111 | - u64 ns; |
2112 | + u64 cycles, ns; |
2113 | |
2114 | spin_lock_irqsave(&adapter->systim_lock, flags); |
2115 | - ns = timecounter_read(&adapter->tc); |
2116 | + |
2117 | + /* Use timecounter_cyc2time() to allow non-monotonic SYSTIM readings */ |
2118 | + cycles = adapter->cc.read(&adapter->cc); |
2119 | + ns = timecounter_cyc2time(&adapter->tc, cycles); |
2120 | + |
2121 | spin_unlock_irqrestore(&adapter->systim_lock, flags); |
2122 | |
2123 | *ts = ns_to_timespec64(ns); |
2124 | @@ -232,9 +236,12 @@ static void e1000e_systim_overflow_work(struct work_struct *work) |
2125 | systim_overflow_work.work); |
2126 | struct e1000_hw *hw = &adapter->hw; |
2127 | struct timespec64 ts; |
2128 | + u64 ns; |
2129 | |
2130 | - adapter->ptp_clock_info.gettime64(&adapter->ptp_clock_info, &ts); |
2131 | + /* Update the timecounter */ |
2132 | + ns = timecounter_read(&adapter->tc); |
2133 | |
2134 | + ts = ns_to_timespec64(ns); |
2135 | e_dbg("SYSTIM overflow check at %lld.%09lu\n", |
2136 | (long long) ts.tv_sec, ts.tv_nsec); |
2137 | |
2138 | diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c |
2139 | index add124e0381d..b27f7a968820 100644 |
2140 | --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c |
2141 | +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c |
2142 | @@ -4,6 +4,7 @@ |
2143 | #include "ixgbe.h" |
2144 | #include <net/xfrm.h> |
2145 | #include <crypto/aead.h> |
2146 | +#include <linux/if_bridge.h> |
2147 | |
2148 | /** |
2149 | * ixgbe_ipsec_set_tx_sa - set the Tx SA registers |
2150 | @@ -676,7 +677,8 @@ static int ixgbe_ipsec_add_sa(struct xfrm_state *xs) |
2151 | } else { |
2152 | struct tx_sa tsa; |
2153 | |
2154 | - if (adapter->num_vfs) |
2155 | + if (adapter->num_vfs && |
2156 | + adapter->bridge_mode != BRIDGE_MODE_VEPA) |
2157 | return -EOPNOTSUPP; |
2158 | |
2159 | /* find the first unused index */ |
2160 | diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c |
2161 | index 3d1159f8a53f..de821a9fdfaf 100644 |
2162 | --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c |
2163 | +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c |
2164 | @@ -4635,12 +4635,15 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev, |
2165 | lower_dev, |
2166 | upper_dev); |
2167 | } else if (netif_is_lag_master(upper_dev)) { |
2168 | - if (info->linking) |
2169 | + if (info->linking) { |
2170 | err = mlxsw_sp_port_lag_join(mlxsw_sp_port, |
2171 | upper_dev); |
2172 | - else |
2173 | + } else { |
2174 | + mlxsw_sp_port_lag_tx_en_set(mlxsw_sp_port, |
2175 | + false); |
2176 | mlxsw_sp_port_lag_leave(mlxsw_sp_port, |
2177 | upper_dev); |
2178 | + } |
2179 | } else if (netif_is_ovs_master(upper_dev)) { |
2180 | if (info->linking) |
2181 | err = mlxsw_sp_port_ovs_join(mlxsw_sp_port); |
2182 | diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c |
2183 | index 4eb64cb0d9a1..0d9ea37c5d21 100644 |
2184 | --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c |
2185 | +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c |
2186 | @@ -1761,7 +1761,7 @@ static void |
2187 | mlxsw_sp_bridge_port_vlan_del(struct mlxsw_sp_port *mlxsw_sp_port, |
2188 | struct mlxsw_sp_bridge_port *bridge_port, u16 vid) |
2189 | { |
2190 | - u16 pvid = mlxsw_sp_port->pvid == vid ? 0 : vid; |
2191 | + u16 pvid = mlxsw_sp_port->pvid == vid ? 0 : mlxsw_sp_port->pvid; |
2192 | struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; |
2193 | |
2194 | mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid(mlxsw_sp_port, vid); |
2195 | diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c |
2196 | index 07f3080eca18..5f45ffeeecb4 100644 |
2197 | --- a/drivers/net/ethernet/realtek/r8169.c |
2198 | +++ b/drivers/net/ethernet/realtek/r8169.c |
2199 | @@ -214,6 +214,8 @@ enum cfg_version { |
2200 | }; |
2201 | |
2202 | static const struct pci_device_id rtl8169_pci_tbl[] = { |
2203 | + { PCI_VDEVICE(REALTEK, 0x2502), RTL_CFG_1 }, |
2204 | + { PCI_VDEVICE(REALTEK, 0x2600), RTL_CFG_1 }, |
2205 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 }, |
2206 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 }, |
2207 | { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8161), 0, 0, RTL_CFG_1 }, |
2208 | diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c |
2209 | index 774e1ff01c9a..735ad838e2ba 100644 |
2210 | --- a/drivers/net/usb/qmi_wwan.c |
2211 | +++ b/drivers/net/usb/qmi_wwan.c |
2212 | @@ -123,6 +123,7 @@ static void qmimux_setup(struct net_device *dev) |
2213 | dev->addr_len = 0; |
2214 | dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; |
2215 | dev->netdev_ops = &qmimux_netdev_ops; |
2216 | + dev->mtu = 1500; |
2217 | dev->needs_free_netdev = true; |
2218 | } |
2219 | |
2220 | diff --git a/drivers/net/wireless/ath/ath10k/debugfs_sta.c b/drivers/net/wireless/ath/ath10k/debugfs_sta.c |
2221 | index a63c97e2c50c..6f10331e986b 100644 |
2222 | --- a/drivers/net/wireless/ath/ath10k/debugfs_sta.c |
2223 | +++ b/drivers/net/wireless/ath/ath10k/debugfs_sta.c |
2224 | @@ -71,7 +71,7 @@ void ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k *ar, u16 peer_id, u8 tid |
2225 | spin_lock_bh(&ar->data_lock); |
2226 | |
2227 | peer = ath10k_peer_find_by_id(ar, peer_id); |
2228 | - if (!peer) |
2229 | + if (!peer || !peer->sta) |
2230 | goto out; |
2231 | |
2232 | arsta = (struct ath10k_sta *)peer->sta->drv_priv; |
2233 | diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c |
2234 | index 4d1cd90d6d27..03d4cc6f35bc 100644 |
2235 | --- a/drivers/net/wireless/ath/ath10k/htt_rx.c |
2236 | +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c |
2237 | @@ -2589,7 +2589,7 @@ static void ath10k_htt_fetch_peer_stats(struct ath10k *ar, |
2238 | rcu_read_lock(); |
2239 | spin_lock_bh(&ar->data_lock); |
2240 | peer = ath10k_peer_find_by_id(ar, peer_id); |
2241 | - if (!peer) { |
2242 | + if (!peer || !peer->sta) { |
2243 | ath10k_warn(ar, "Invalid peer id %d peer stats buffer\n", |
2244 | peer_id); |
2245 | goto out; |
2246 | @@ -2642,7 +2642,7 @@ static void ath10k_fetch_10_2_tx_stats(struct ath10k *ar, u8 *data) |
2247 | rcu_read_lock(); |
2248 | spin_lock_bh(&ar->data_lock); |
2249 | peer = ath10k_peer_find_by_id(ar, peer_id); |
2250 | - if (!peer) { |
2251 | + if (!peer || !peer->sta) { |
2252 | ath10k_warn(ar, "Invalid peer id %d in peer stats buffer\n", |
2253 | peer_id); |
2254 | goto out; |
2255 | diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c |
2256 | index afed549f5645..9a764af30f36 100644 |
2257 | --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c |
2258 | +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c |
2259 | @@ -2938,7 +2938,8 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, |
2260 | iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); |
2261 | } |
2262 | |
2263 | - iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band); |
2264 | + iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band, |
2265 | + false); |
2266 | ret = iwl_mvm_update_sta(mvm, vif, sta); |
2267 | } else if (old_state == IEEE80211_STA_ASSOC && |
2268 | new_state == IEEE80211_STA_AUTHORIZED) { |
2269 | @@ -2954,7 +2955,8 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, |
2270 | /* enable beacon filtering */ |
2271 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0)); |
2272 | |
2273 | - iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band); |
2274 | + iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band, |
2275 | + true); |
2276 | |
2277 | ret = 0; |
2278 | } else if (old_state == IEEE80211_STA_AUTHORIZED && |
2279 | diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h |
2280 | index b3987a0a7018..6b65ad6c9b56 100644 |
2281 | --- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h |
2282 | +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h |
2283 | @@ -1685,7 +1685,7 @@ iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif) |
2284 | #endif /* CONFIG_IWLWIFI_DEBUGFS */ |
2285 | |
2286 | /* rate scaling */ |
2287 | -int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, bool init); |
2288 | +int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, bool sync); |
2289 | void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm, u32 rate, bool agg); |
2290 | int rs_pretty_print_rate(char *buf, int bufsz, const u32 rate); |
2291 | void rs_update_last_rssi(struct iwl_mvm *mvm, |
2292 | diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c |
2293 | index f2830b5693d2..6b9c670fcef8 100644 |
2294 | --- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c |
2295 | +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c |
2296 | @@ -1280,7 +1280,7 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta, |
2297 | (unsigned long)(lq_sta->last_tx + |
2298 | (IWL_MVM_RS_IDLE_TIMEOUT * HZ)))) { |
2299 | IWL_DEBUG_RATE(mvm, "Tx idle for too long. reinit rs\n"); |
2300 | - iwl_mvm_rs_rate_init(mvm, sta, info->band); |
2301 | + iwl_mvm_rs_rate_init(mvm, sta, info->band, true); |
2302 | return; |
2303 | } |
2304 | lq_sta->last_tx = jiffies; |
2305 | @@ -2870,9 +2870,8 @@ void rs_update_last_rssi(struct iwl_mvm *mvm, |
2306 | static void rs_initialize_lq(struct iwl_mvm *mvm, |
2307 | struct ieee80211_sta *sta, |
2308 | struct iwl_lq_sta *lq_sta, |
2309 | - enum nl80211_band band) |
2310 | + enum nl80211_band band, bool update) |
2311 | { |
2312 | - struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
2313 | struct iwl_scale_tbl_info *tbl; |
2314 | struct rs_rate *rate; |
2315 | u8 active_tbl = 0; |
2316 | @@ -2901,8 +2900,7 @@ static void rs_initialize_lq(struct iwl_mvm *mvm, |
2317 | rs_set_expected_tpt_table(lq_sta, tbl); |
2318 | rs_fill_lq_cmd(mvm, sta, lq_sta, rate); |
2319 | /* TODO restore station should remember the lq cmd */ |
2320 | - iwl_mvm_send_lq_cmd(mvm, &lq_sta->lq, |
2321 | - mvmsta->sta_state < IEEE80211_STA_AUTHORIZED); |
2322 | + iwl_mvm_send_lq_cmd(mvm, &lq_sta->lq, !update); |
2323 | } |
2324 | |
2325 | static void rs_drv_get_rate(void *mvm_r, struct ieee80211_sta *sta, |
2326 | @@ -3155,7 +3153,7 @@ void iwl_mvm_update_frame_stats(struct iwl_mvm *mvm, u32 rate, bool agg) |
2327 | * Called after adding a new station to initialize rate scaling |
2328 | */ |
2329 | static void rs_drv_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta, |
2330 | - enum nl80211_band band) |
2331 | + enum nl80211_band band, bool update) |
2332 | { |
2333 | int i, j; |
2334 | struct ieee80211_hw *hw = mvm->hw; |
2335 | @@ -3235,7 +3233,7 @@ static void rs_drv_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta, |
2336 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
2337 | iwl_mvm_reset_frame_stats(mvm); |
2338 | #endif |
2339 | - rs_initialize_lq(mvm, sta, lq_sta, band); |
2340 | + rs_initialize_lq(mvm, sta, lq_sta, band, update); |
2341 | } |
2342 | |
2343 | static void rs_drv_rate_update(void *mvm_r, |
2344 | @@ -3255,7 +3253,7 @@ static void rs_drv_rate_update(void *mvm_r, |
2345 | for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) |
2346 | ieee80211_stop_tx_ba_session(sta, tid); |
2347 | |
2348 | - iwl_mvm_rs_rate_init(mvm, sta, sband->band); |
2349 | + iwl_mvm_rs_rate_init(mvm, sta, sband->band, true); |
2350 | } |
2351 | |
2352 | #ifdef CONFIG_MAC80211_DEBUGFS |
2353 | @@ -4112,12 +4110,12 @@ static const struct rate_control_ops rs_mvm_ops_drv = { |
2354 | }; |
2355 | |
2356 | void iwl_mvm_rs_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta, |
2357 | - enum nl80211_band band) |
2358 | + enum nl80211_band band, bool update) |
2359 | { |
2360 | if (iwl_mvm_has_tlc_offload(mvm)) |
2361 | rs_fw_rate_init(mvm, sta, band); |
2362 | else |
2363 | - rs_drv_rate_init(mvm, sta, band); |
2364 | + rs_drv_rate_init(mvm, sta, band, update); |
2365 | } |
2366 | |
2367 | int iwl_mvm_rate_control_register(void) |
2368 | diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.h b/drivers/net/wireless/intel/iwlwifi/mvm/rs.h |
2369 | index d2cf484e2b73..8e7f993e2911 100644 |
2370 | --- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.h |
2371 | +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.h |
2372 | @@ -420,7 +420,7 @@ struct iwl_lq_sta { |
2373 | |
2374 | /* Initialize station's rate scaling information after adding station */ |
2375 | void iwl_mvm_rs_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta, |
2376 | - enum nl80211_band band); |
2377 | + enum nl80211_band band, bool init); |
2378 | |
2379 | /* Notify RS about Tx status */ |
2380 | void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta, |
2381 | diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c |
2382 | index b002a7afb5f5..6a5349401aa9 100644 |
2383 | --- a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c |
2384 | +++ b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c |
2385 | @@ -900,20 +900,19 @@ int iwl_mvm_disable_txq(struct iwl_mvm *mvm, int queue, int mac80211_queue, |
2386 | |
2387 | /** |
2388 | * iwl_mvm_send_lq_cmd() - Send link quality command |
2389 | - * @init: This command is sent as part of station initialization right |
2390 | - * after station has been added. |
2391 | + * @sync: This command can be sent synchronously. |
2392 | * |
2393 | * The link quality command is sent as the last step of station creation. |
2394 | * This is the special case in which init is set and we call a callback in |
2395 | * this case to clear the state indicating that station creation is in |
2396 | * progress. |
2397 | */ |
2398 | -int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, bool init) |
2399 | +int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq, bool sync) |
2400 | { |
2401 | struct iwl_host_cmd cmd = { |
2402 | .id = LQ_CMD, |
2403 | .len = { sizeof(struct iwl_lq_cmd), }, |
2404 | - .flags = init ? 0 : CMD_ASYNC, |
2405 | + .flags = sync ? 0 : CMD_ASYNC, |
2406 | .data = { lq, }, |
2407 | }; |
2408 | |
2409 | diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c |
2410 | index eda57ef12fd0..baa9cee6fa2c 100644 |
2411 | --- a/drivers/of/overlay.c |
2412 | +++ b/drivers/of/overlay.c |
2413 | @@ -378,7 +378,9 @@ static int add_changeset_node(struct overlay_changeset *ovcs, |
2414 | if (ret) |
2415 | return ret; |
2416 | |
2417 | - return build_changeset_next_level(ovcs, tchild, node); |
2418 | + ret = build_changeset_next_level(ovcs, tchild, node); |
2419 | + of_node_put(tchild); |
2420 | + return ret; |
2421 | } |
2422 | |
2423 | if (node->phandle && tchild->phandle) |
2424 | diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c |
2425 | index 2d6e272315a8..db3556dc90d1 100644 |
2426 | --- a/drivers/platform/x86/asus-wmi.c |
2427 | +++ b/drivers/platform/x86/asus-wmi.c |
2428 | @@ -2231,7 +2231,8 @@ static int asus_wmi_add(struct platform_device *pdev) |
2429 | err = asus_wmi_backlight_init(asus); |
2430 | if (err && err != -ENODEV) |
2431 | goto fail_backlight; |
2432 | - } |
2433 | + } else |
2434 | + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT, 2, NULL); |
2435 | |
2436 | status = wmi_install_notify_handler(asus->driver->event_guid, |
2437 | asus_wmi_notify, asus); |
2438 | diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c |
2439 | index 59ecbb3b53b5..a33628550425 100644 |
2440 | --- a/drivers/scsi/megaraid/megaraid_sas_fp.c |
2441 | +++ b/drivers/scsi/megaraid/megaraid_sas_fp.c |
2442 | @@ -1266,7 +1266,7 @@ void mr_update_load_balance_params(struct MR_DRV_RAID_MAP_ALL *drv_map, |
2443 | |
2444 | for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES_EXT; ldCount++) { |
2445 | ld = MR_TargetIdToLdGet(ldCount, drv_map); |
2446 | - if (ld >= MAX_LOGICAL_DRIVES_EXT) { |
2447 | + if (ld >= MAX_LOGICAL_DRIVES_EXT - 1) { |
2448 | lbInfo[ldCount].loadBalanceFlag = 0; |
2449 | continue; |
2450 | } |
2451 | diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c |
2452 | index c7f95bace353..f45c54f02bfa 100644 |
2453 | --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c |
2454 | +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c |
2455 | @@ -2832,7 +2832,7 @@ static void megasas_build_ld_nonrw_fusion(struct megasas_instance *instance, |
2456 | device_id < instance->fw_supported_vd_count)) { |
2457 | |
2458 | ld = MR_TargetIdToLdGet(device_id, local_map_ptr); |
2459 | - if (ld >= instance->fw_supported_vd_count) |
2460 | + if (ld >= instance->fw_supported_vd_count - 1) |
2461 | fp_possible = 0; |
2462 | else { |
2463 | raid = MR_LdRaidGet(ld, local_map_ptr); |
2464 | diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c |
2465 | index 59d7844ee022..b59bba3e6516 100644 |
2466 | --- a/drivers/scsi/mpt3sas/mpt3sas_base.c |
2467 | +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c |
2468 | @@ -3344,8 +3344,9 @@ _base_mpi_ep_writeq(__u64 b, volatile void __iomem *addr, |
2469 | static inline void |
2470 | _base_writeq(__u64 b, volatile void __iomem *addr, spinlock_t *writeq_lock) |
2471 | { |
2472 | + wmb(); |
2473 | __raw_writeq(b, addr); |
2474 | - mmiowb(); |
2475 | + barrier(); |
2476 | } |
2477 | #else |
2478 | static inline void |
2479 | diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c |
2480 | index e5bd035ebad0..4de740da547b 100644 |
2481 | --- a/drivers/scsi/qedi/qedi_main.c |
2482 | +++ b/drivers/scsi/qedi/qedi_main.c |
2483 | @@ -952,6 +952,9 @@ static int qedi_find_boot_info(struct qedi_ctx *qedi, |
2484 | cls_sess = iscsi_conn_to_session(cls_conn); |
2485 | sess = cls_sess->dd_data; |
2486 | |
2487 | + if (!iscsi_is_session_online(cls_sess)) |
2488 | + continue; |
2489 | + |
2490 | if (pri_ctrl_flags) { |
2491 | if (!strcmp(pri_tgt->iscsi_name, sess->targetname) && |
2492 | !strcmp(pri_tgt->ip_addr, ep_ip_addr)) { |
2493 | diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c |
2494 | index 2112ea6723c6..8c1a232ac6bf 100644 |
2495 | --- a/drivers/scsi/smartpqi/smartpqi_init.c |
2496 | +++ b/drivers/scsi/smartpqi/smartpqi_init.c |
2497 | @@ -2720,6 +2720,9 @@ static unsigned int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info, |
2498 | switch (response->header.iu_type) { |
2499 | case PQI_RESPONSE_IU_RAID_PATH_IO_SUCCESS: |
2500 | case PQI_RESPONSE_IU_AIO_PATH_IO_SUCCESS: |
2501 | + if (io_request->scmd) |
2502 | + io_request->scmd->result = 0; |
2503 | + /* fall through */ |
2504 | case PQI_RESPONSE_IU_GENERAL_MANAGEMENT: |
2505 | break; |
2506 | case PQI_RESPONSE_IU_TASK_MANAGEMENT: |
2507 | @@ -6686,6 +6689,7 @@ static void pqi_shutdown(struct pci_dev *pci_dev) |
2508 | * storage. |
2509 | */ |
2510 | rc = pqi_flush_cache(ctrl_info, SHUTDOWN); |
2511 | + pqi_free_interrupts(ctrl_info); |
2512 | pqi_reset(ctrl_info); |
2513 | if (rc == 0) |
2514 | return; |
2515 | diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c |
2516 | index 14da8cc2246a..0346630b67c8 100644 |
2517 | --- a/drivers/staging/erofs/unzip_vle.c |
2518 | +++ b/drivers/staging/erofs/unzip_vle.c |
2519 | @@ -724,13 +724,18 @@ static void z_erofs_vle_unzip_kickoff(void *ptr, int bios) |
2520 | struct z_erofs_vle_unzip_io *io = tagptr_unfold_ptr(t); |
2521 | bool background = tagptr_unfold_tags(t); |
2522 | |
2523 | - if (atomic_add_return(bios, &io->pending_bios)) |
2524 | + if (!background) { |
2525 | + unsigned long flags; |
2526 | + |
2527 | + spin_lock_irqsave(&io->u.wait.lock, flags); |
2528 | + if (!atomic_add_return(bios, &io->pending_bios)) |
2529 | + wake_up_locked(&io->u.wait); |
2530 | + spin_unlock_irqrestore(&io->u.wait.lock, flags); |
2531 | return; |
2532 | + } |
2533 | |
2534 | - if (background) |
2535 | + if (!atomic_add_return(bios, &io->pending_bios)) |
2536 | queue_work(z_erofs_workqueue, &io->u.work); |
2537 | - else |
2538 | - wake_up(&io->u.wait); |
2539 | } |
2540 | |
2541 | static inline void z_erofs_vle_read_endio(struct bio *bio) |
2542 | diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c |
2543 | index cb0461a10808..93424db5f002 100644 |
2544 | --- a/drivers/target/target_core_spc.c |
2545 | +++ b/drivers/target/target_core_spc.c |
2546 | @@ -108,12 +108,17 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf) |
2547 | |
2548 | buf[7] = 0x2; /* CmdQue=1 */ |
2549 | |
2550 | - memcpy(&buf[8], "LIO-ORG ", 8); |
2551 | - memset(&buf[16], 0x20, 16); |
2552 | + /* |
2553 | + * ASCII data fields described as being left-aligned shall have any |
2554 | + * unused bytes at the end of the field (i.e., highest offset) and the |
2555 | + * unused bytes shall be filled with ASCII space characters (20h). |
2556 | + */ |
2557 | + memset(&buf[8], 0x20, 8 + 16 + 4); |
2558 | + memcpy(&buf[8], "LIO-ORG", sizeof("LIO-ORG") - 1); |
2559 | memcpy(&buf[16], dev->t10_wwn.model, |
2560 | - min_t(size_t, strlen(dev->t10_wwn.model), 16)); |
2561 | + strnlen(dev->t10_wwn.model, 16)); |
2562 | memcpy(&buf[32], dev->t10_wwn.revision, |
2563 | - min_t(size_t, strlen(dev->t10_wwn.revision), 4)); |
2564 | + strnlen(dev->t10_wwn.revision, 4)); |
2565 | buf[4] = 31; /* Set additional length to 31 */ |
2566 | |
2567 | return 0; |
2568 | @@ -251,7 +256,9 @@ check_t10_vend_desc: |
2569 | buf[off] = 0x2; /* ASCII */ |
2570 | buf[off+1] = 0x1; /* T10 Vendor ID */ |
2571 | buf[off+2] = 0x0; |
2572 | - memcpy(&buf[off+4], "LIO-ORG", 8); |
2573 | + /* left align Vendor ID and pad with spaces */ |
2574 | + memset(&buf[off+4], 0x20, 8); |
2575 | + memcpy(&buf[off+4], "LIO-ORG", sizeof("LIO-ORG") - 1); |
2576 | /* Extra Byte for NULL Terminator */ |
2577 | id_len++; |
2578 | /* Identifier Length */ |
2579 | diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c |
2580 | index fc3093d21b96..3f7aad45d215 100644 |
2581 | --- a/drivers/target/target_core_transport.c |
2582 | +++ b/drivers/target/target_core_transport.c |
2583 | @@ -224,19 +224,28 @@ void transport_subsystem_check_init(void) |
2584 | sub_api_initialized = 1; |
2585 | } |
2586 | |
2587 | +static void target_release_sess_cmd_refcnt(struct percpu_ref *ref) |
2588 | +{ |
2589 | + struct se_session *sess = container_of(ref, typeof(*sess), cmd_count); |
2590 | + |
2591 | + wake_up(&sess->cmd_list_wq); |
2592 | +} |
2593 | + |
2594 | /** |
2595 | * transport_init_session - initialize a session object |
2596 | * @se_sess: Session object pointer. |
2597 | * |
2598 | * The caller must have zero-initialized @se_sess before calling this function. |
2599 | */ |
2600 | -void transport_init_session(struct se_session *se_sess) |
2601 | +int transport_init_session(struct se_session *se_sess) |
2602 | { |
2603 | INIT_LIST_HEAD(&se_sess->sess_list); |
2604 | INIT_LIST_HEAD(&se_sess->sess_acl_list); |
2605 | INIT_LIST_HEAD(&se_sess->sess_cmd_list); |
2606 | spin_lock_init(&se_sess->sess_cmd_lock); |
2607 | init_waitqueue_head(&se_sess->cmd_list_wq); |
2608 | + return percpu_ref_init(&se_sess->cmd_count, |
2609 | + target_release_sess_cmd_refcnt, 0, GFP_KERNEL); |
2610 | } |
2611 | EXPORT_SYMBOL(transport_init_session); |
2612 | |
2613 | @@ -247,6 +256,7 @@ EXPORT_SYMBOL(transport_init_session); |
2614 | struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops) |
2615 | { |
2616 | struct se_session *se_sess; |
2617 | + int ret; |
2618 | |
2619 | se_sess = kmem_cache_zalloc(se_sess_cache, GFP_KERNEL); |
2620 | if (!se_sess) { |
2621 | @@ -254,7 +264,11 @@ struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops) |
2622 | " se_sess_cache\n"); |
2623 | return ERR_PTR(-ENOMEM); |
2624 | } |
2625 | - transport_init_session(se_sess); |
2626 | + ret = transport_init_session(se_sess); |
2627 | + if (ret < 0) { |
2628 | + kfree(se_sess); |
2629 | + return ERR_PTR(ret); |
2630 | + } |
2631 | se_sess->sup_prot_ops = sup_prot_ops; |
2632 | |
2633 | return se_sess; |
2634 | @@ -581,6 +595,7 @@ void transport_free_session(struct se_session *se_sess) |
2635 | sbitmap_queue_free(&se_sess->sess_tag_pool); |
2636 | kvfree(se_sess->sess_cmd_map); |
2637 | } |
2638 | + percpu_ref_exit(&se_sess->cmd_count); |
2639 | kmem_cache_free(se_sess_cache, se_sess); |
2640 | } |
2641 | EXPORT_SYMBOL(transport_free_session); |
2642 | @@ -2724,6 +2739,7 @@ int target_get_sess_cmd(struct se_cmd *se_cmd, bool ack_kref) |
2643 | } |
2644 | se_cmd->transport_state |= CMD_T_PRE_EXECUTE; |
2645 | list_add_tail(&se_cmd->se_cmd_list, &se_sess->sess_cmd_list); |
2646 | + percpu_ref_get(&se_sess->cmd_count); |
2647 | out: |
2648 | spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); |
2649 | |
2650 | @@ -2754,8 +2770,6 @@ static void target_release_cmd_kref(struct kref *kref) |
2651 | if (se_sess) { |
2652 | spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); |
2653 | list_del_init(&se_cmd->se_cmd_list); |
2654 | - if (se_sess->sess_tearing_down && list_empty(&se_sess->sess_cmd_list)) |
2655 | - wake_up(&se_sess->cmd_list_wq); |
2656 | spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); |
2657 | } |
2658 | |
2659 | @@ -2763,6 +2777,8 @@ static void target_release_cmd_kref(struct kref *kref) |
2660 | se_cmd->se_tfo->release_cmd(se_cmd); |
2661 | if (compl) |
2662 | complete(compl); |
2663 | + |
2664 | + percpu_ref_put(&se_sess->cmd_count); |
2665 | } |
2666 | |
2667 | /** |
2668 | @@ -2891,6 +2907,8 @@ void target_sess_cmd_list_set_waiting(struct se_session *se_sess) |
2669 | spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); |
2670 | se_sess->sess_tearing_down = 1; |
2671 | spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); |
2672 | + |
2673 | + percpu_ref_kill(&se_sess->cmd_count); |
2674 | } |
2675 | EXPORT_SYMBOL(target_sess_cmd_list_set_waiting); |
2676 | |
2677 | @@ -2905,17 +2923,14 @@ void target_wait_for_sess_cmds(struct se_session *se_sess) |
2678 | |
2679 | WARN_ON_ONCE(!se_sess->sess_tearing_down); |
2680 | |
2681 | - spin_lock_irq(&se_sess->sess_cmd_lock); |
2682 | do { |
2683 | - ret = wait_event_lock_irq_timeout( |
2684 | - se_sess->cmd_list_wq, |
2685 | - list_empty(&se_sess->sess_cmd_list), |
2686 | - se_sess->sess_cmd_lock, 180 * HZ); |
2687 | + ret = wait_event_timeout(se_sess->cmd_list_wq, |
2688 | + percpu_ref_is_zero(&se_sess->cmd_count), |
2689 | + 180 * HZ); |
2690 | list_for_each_entry(cmd, &se_sess->sess_cmd_list, se_cmd_list) |
2691 | target_show_cmd("session shutdown: still waiting for ", |
2692 | cmd); |
2693 | } while (ret <= 0); |
2694 | - spin_unlock_irq(&se_sess->sess_cmd_lock); |
2695 | } |
2696 | EXPORT_SYMBOL(target_wait_for_sess_cmds); |
2697 | |
2698 | diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c |
2699 | index 2718a933c0c6..7cdb5d7f6538 100644 |
2700 | --- a/drivers/target/target_core_xcopy.c |
2701 | +++ b/drivers/target/target_core_xcopy.c |
2702 | @@ -480,6 +480,8 @@ static const struct target_core_fabric_ops xcopy_pt_tfo = { |
2703 | |
2704 | int target_xcopy_setup_pt(void) |
2705 | { |
2706 | + int ret; |
2707 | + |
2708 | xcopy_wq = alloc_workqueue("xcopy_wq", WQ_MEM_RECLAIM, 0); |
2709 | if (!xcopy_wq) { |
2710 | pr_err("Unable to allocate xcopy_wq\n"); |
2711 | @@ -497,7 +499,9 @@ int target_xcopy_setup_pt(void) |
2712 | INIT_LIST_HEAD(&xcopy_pt_nacl.acl_list); |
2713 | INIT_LIST_HEAD(&xcopy_pt_nacl.acl_sess_list); |
2714 | memset(&xcopy_pt_sess, 0, sizeof(struct se_session)); |
2715 | - transport_init_session(&xcopy_pt_sess); |
2716 | + ret = transport_init_session(&xcopy_pt_sess); |
2717 | + if (ret < 0) |
2718 | + return ret; |
2719 | |
2720 | xcopy_pt_nacl.se_tpg = &xcopy_pt_tpg; |
2721 | xcopy_pt_nacl.nacl_sess = &xcopy_pt_sess; |
2722 | diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c |
2723 | index ebd33c0232e6..89ade213a1a9 100644 |
2724 | --- a/drivers/tty/serial/amba-pl011.c |
2725 | +++ b/drivers/tty/serial/amba-pl011.c |
2726 | @@ -2780,6 +2780,7 @@ static struct platform_driver arm_sbsa_uart_platform_driver = { |
2727 | .name = "sbsa-uart", |
2728 | .of_match_table = of_match_ptr(sbsa_uart_of_match), |
2729 | .acpi_match_table = ACPI_PTR(sbsa_uart_acpi_match), |
2730 | + .suppress_bind_attrs = IS_BUILTIN(CONFIG_SERIAL_AMBA_PL011), |
2731 | }, |
2732 | }; |
2733 | |
2734 | @@ -2808,6 +2809,7 @@ static struct amba_driver pl011_driver = { |
2735 | .drv = { |
2736 | .name = "uart-pl011", |
2737 | .pm = &pl011_dev_pm_ops, |
2738 | + .suppress_bind_attrs = IS_BUILTIN(CONFIG_SERIAL_AMBA_PL011), |
2739 | }, |
2740 | .id_table = pl011_ids, |
2741 | .probe = pl011_probe, |
2742 | diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c |
2743 | index fd80d999308d..0bdf1687983f 100644 |
2744 | --- a/drivers/tty/serial/pic32_uart.c |
2745 | +++ b/drivers/tty/serial/pic32_uart.c |
2746 | @@ -919,6 +919,7 @@ static struct platform_driver pic32_uart_platform_driver = { |
2747 | .driver = { |
2748 | .name = PIC32_DEV_NAME, |
2749 | .of_match_table = of_match_ptr(pic32_serial_dt_ids), |
2750 | + .suppress_bind_attrs = IS_BUILTIN(CONFIG_SERIAL_PIC32), |
2751 | }, |
2752 | }; |
2753 | |
2754 | diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c |
2755 | index 80bb56facfb6..ad126f51d549 100644 |
2756 | --- a/drivers/tty/serial/serial_core.c |
2757 | +++ b/drivers/tty/serial/serial_core.c |
2758 | @@ -205,10 +205,15 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state, |
2759 | if (!state->xmit.buf) { |
2760 | state->xmit.buf = (unsigned char *) page; |
2761 | uart_circ_clear(&state->xmit); |
2762 | + uart_port_unlock(uport, flags); |
2763 | } else { |
2764 | + uart_port_unlock(uport, flags); |
2765 | + /* |
2766 | + * Do not free() the page under the port lock, see |
2767 | + * uart_shutdown(). |
2768 | + */ |
2769 | free_page(page); |
2770 | } |
2771 | - uart_port_unlock(uport, flags); |
2772 | |
2773 | retval = uport->ops->startup(uport); |
2774 | if (retval == 0) { |
2775 | @@ -268,6 +273,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state) |
2776 | struct uart_port *uport = uart_port_check(state); |
2777 | struct tty_port *port = &state->port; |
2778 | unsigned long flags = 0; |
2779 | + char *xmit_buf = NULL; |
2780 | |
2781 | /* |
2782 | * Set the TTY IO error marker |
2783 | @@ -298,14 +304,18 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state) |
2784 | tty_port_set_suspended(port, 0); |
2785 | |
2786 | /* |
2787 | - * Free the transmit buffer page. |
2788 | + * Do not free() the transmit buffer page under the port lock since |
2789 | + * this can create various circular locking scenarios. For instance, |
2790 | + * console driver may need to allocate/free a debug object, which |
2791 | + * can endup in printk() recursion. |
2792 | */ |
2793 | uart_port_lock(state, flags); |
2794 | - if (state->xmit.buf) { |
2795 | - free_page((unsigned long)state->xmit.buf); |
2796 | - state->xmit.buf = NULL; |
2797 | - } |
2798 | + xmit_buf = state->xmit.buf; |
2799 | + state->xmit.buf = NULL; |
2800 | uart_port_unlock(uport, flags); |
2801 | + |
2802 | + if (xmit_buf) |
2803 | + free_page((unsigned long)xmit_buf); |
2804 | } |
2805 | |
2806 | /** |
2807 | diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c |
2808 | index 6ed74735b58c..87d8dd90d605 100644 |
2809 | --- a/drivers/tty/serial/xilinx_uartps.c |
2810 | +++ b/drivers/tty/serial/xilinx_uartps.c |
2811 | @@ -1608,6 +1608,7 @@ static struct platform_driver cdns_uart_platform_driver = { |
2812 | .name = CDNS_UART_NAME, |
2813 | .of_match_table = cdns_uart_of_match, |
2814 | .pm = &cdns_uart_dev_pm_ops, |
2815 | + .suppress_bind_attrs = IS_BUILTIN(CONFIG_SERIAL_XILINX_PS_UART), |
2816 | }, |
2817 | }; |
2818 | |
2819 | diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c |
2820 | index 67d8a501d994..fea02c7ad4f4 100644 |
2821 | --- a/drivers/usb/gadget/udc/renesas_usb3.c |
2822 | +++ b/drivers/usb/gadget/udc/renesas_usb3.c |
2823 | @@ -358,6 +358,7 @@ struct renesas_usb3 { |
2824 | bool extcon_host; /* check id and set EXTCON_USB_HOST */ |
2825 | bool extcon_usb; /* check vbus and set EXTCON_USB */ |
2826 | bool forced_b_device; |
2827 | + bool start_to_connect; |
2828 | }; |
2829 | |
2830 | #define gadget_to_renesas_usb3(_gadget) \ |
2831 | @@ -476,7 +477,8 @@ static void usb3_init_axi_bridge(struct renesas_usb3 *usb3) |
2832 | static void usb3_init_epc_registers(struct renesas_usb3 *usb3) |
2833 | { |
2834 | usb3_write(usb3, ~0, USB3_USB_INT_STA_1); |
2835 | - usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG); |
2836 | + if (!usb3->workaround_for_vbus) |
2837 | + usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG); |
2838 | } |
2839 | |
2840 | static bool usb3_wakeup_usb2_phy(struct renesas_usb3 *usb3) |
2841 | @@ -700,8 +702,7 @@ static void usb3_mode_config(struct renesas_usb3 *usb3, bool host, bool a_dev) |
2842 | usb3_set_mode_by_role_sw(usb3, host); |
2843 | usb3_vbus_out(usb3, a_dev); |
2844 | /* for A-Peripheral or forced B-device mode */ |
2845 | - if ((!host && a_dev) || |
2846 | - (usb3->workaround_for_vbus && usb3->forced_b_device)) |
2847 | + if ((!host && a_dev) || usb3->start_to_connect) |
2848 | usb3_connect(usb3); |
2849 | spin_unlock_irqrestore(&usb3->lock, flags); |
2850 | } |
2851 | @@ -2432,7 +2433,11 @@ static ssize_t renesas_usb3_b_device_write(struct file *file, |
2852 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
2853 | return -EFAULT; |
2854 | |
2855 | - if (!strncmp(buf, "1", 1)) |
2856 | + usb3->start_to_connect = false; |
2857 | + if (usb3->workaround_for_vbus && usb3->forced_b_device && |
2858 | + !strncmp(buf, "2", 1)) |
2859 | + usb3->start_to_connect = true; |
2860 | + else if (!strncmp(buf, "1", 1)) |
2861 | usb3->forced_b_device = true; |
2862 | else |
2863 | usb3->forced_b_device = false; |
2864 | @@ -2440,7 +2445,7 @@ static ssize_t renesas_usb3_b_device_write(struct file *file, |
2865 | if (usb3->workaround_for_vbus) |
2866 | usb3_disconnect(usb3); |
2867 | |
2868 | - /* Let this driver call usb3_connect() anyway */ |
2869 | + /* Let this driver call usb3_connect() if needed */ |
2870 | usb3_check_id(usb3); |
2871 | |
2872 | return count; |
2873 | diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c |
2874 | index c74cc9c309b1..3457c1fdebd1 100644 |
2875 | --- a/drivers/usb/typec/tcpm.c |
2876 | +++ b/drivers/usb/typec/tcpm.c |
2877 | @@ -317,6 +317,9 @@ struct tcpm_port { |
2878 | /* Deadline in jiffies to exit src_try_wait state */ |
2879 | unsigned long max_wait; |
2880 | |
2881 | + /* port belongs to a self powered device */ |
2882 | + bool self_powered; |
2883 | + |
2884 | #ifdef CONFIG_DEBUG_FS |
2885 | struct dentry *dentry; |
2886 | struct mutex logbuffer_lock; /* log buffer access lock */ |
2887 | @@ -3257,7 +3260,8 @@ static void run_state_machine(struct tcpm_port *port) |
2888 | case SRC_HARD_RESET_VBUS_OFF: |
2889 | tcpm_set_vconn(port, true); |
2890 | tcpm_set_vbus(port, false); |
2891 | - tcpm_set_roles(port, false, TYPEC_SOURCE, TYPEC_HOST); |
2892 | + tcpm_set_roles(port, port->self_powered, TYPEC_SOURCE, |
2893 | + TYPEC_HOST); |
2894 | tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER); |
2895 | break; |
2896 | case SRC_HARD_RESET_VBUS_ON: |
2897 | @@ -3270,7 +3274,8 @@ static void run_state_machine(struct tcpm_port *port) |
2898 | memset(&port->pps_data, 0, sizeof(port->pps_data)); |
2899 | tcpm_set_vconn(port, false); |
2900 | tcpm_set_charge(port, false); |
2901 | - tcpm_set_roles(port, false, TYPEC_SINK, TYPEC_DEVICE); |
2902 | + tcpm_set_roles(port, port->self_powered, TYPEC_SINK, |
2903 | + TYPEC_DEVICE); |
2904 | /* |
2905 | * VBUS may or may not toggle, depending on the adapter. |
2906 | * If it doesn't toggle, transition to SNK_HARD_RESET_SINK_ON |
2907 | @@ -4415,6 +4420,8 @@ sink: |
2908 | return -EINVAL; |
2909 | port->operating_snk_mw = mw / 1000; |
2910 | |
2911 | + port->self_powered = fwnode_property_read_bool(fwnode, "self-powered"); |
2912 | + |
2913 | return 0; |
2914 | } |
2915 | |
2916 | @@ -4723,6 +4730,7 @@ static int tcpm_copy_caps(struct tcpm_port *port, |
2917 | port->typec_caps.prefer_role = tcfg->default_role; |
2918 | port->typec_caps.type = tcfg->type; |
2919 | port->typec_caps.data = tcfg->data; |
2920 | + port->self_powered = port->tcpc->config->self_powered; |
2921 | |
2922 | return 0; |
2923 | } |
2924 | diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c |
2925 | index b2b283e48439..8fed470bb7e1 100644 |
2926 | --- a/fs/btrfs/dev-replace.c |
2927 | +++ b/fs/btrfs/dev-replace.c |
2928 | @@ -800,39 +800,58 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info) |
2929 | case BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED: |
2930 | result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED; |
2931 | btrfs_dev_replace_write_unlock(dev_replace); |
2932 | - goto leave; |
2933 | + break; |
2934 | case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED: |
2935 | + result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR; |
2936 | + tgt_device = dev_replace->tgtdev; |
2937 | + src_device = dev_replace->srcdev; |
2938 | + btrfs_dev_replace_write_unlock(dev_replace); |
2939 | + btrfs_scrub_cancel(fs_info); |
2940 | + /* btrfs_dev_replace_finishing() will handle the cleanup part */ |
2941 | + btrfs_info_in_rcu(fs_info, |
2942 | + "dev_replace from %s (devid %llu) to %s canceled", |
2943 | + btrfs_dev_name(src_device), src_device->devid, |
2944 | + btrfs_dev_name(tgt_device)); |
2945 | + break; |
2946 | case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED: |
2947 | + /* |
2948 | + * Scrub doing the replace isn't running so we need to do the |
2949 | + * cleanup step of btrfs_dev_replace_finishing() here |
2950 | + */ |
2951 | result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR; |
2952 | tgt_device = dev_replace->tgtdev; |
2953 | src_device = dev_replace->srcdev; |
2954 | dev_replace->tgtdev = NULL; |
2955 | dev_replace->srcdev = NULL; |
2956 | - break; |
2957 | - } |
2958 | - dev_replace->replace_state = BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED; |
2959 | - dev_replace->time_stopped = ktime_get_real_seconds(); |
2960 | - dev_replace->item_needs_writeback = 1; |
2961 | - btrfs_dev_replace_write_unlock(dev_replace); |
2962 | - btrfs_scrub_cancel(fs_info); |
2963 | + dev_replace->replace_state = |
2964 | + BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED; |
2965 | + dev_replace->time_stopped = ktime_get_real_seconds(); |
2966 | + dev_replace->item_needs_writeback = 1; |
2967 | |
2968 | - trans = btrfs_start_transaction(root, 0); |
2969 | - if (IS_ERR(trans)) { |
2970 | - mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); |
2971 | - return PTR_ERR(trans); |
2972 | - } |
2973 | - ret = btrfs_commit_transaction(trans); |
2974 | - WARN_ON(ret); |
2975 | + btrfs_dev_replace_write_unlock(dev_replace); |
2976 | |
2977 | - btrfs_info_in_rcu(fs_info, |
2978 | - "dev_replace from %s (devid %llu) to %s canceled", |
2979 | - btrfs_dev_name(src_device), src_device->devid, |
2980 | - btrfs_dev_name(tgt_device)); |
2981 | + btrfs_scrub_cancel(fs_info); |
2982 | + |
2983 | + trans = btrfs_start_transaction(root, 0); |
2984 | + if (IS_ERR(trans)) { |
2985 | + mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); |
2986 | + return PTR_ERR(trans); |
2987 | + } |
2988 | + ret = btrfs_commit_transaction(trans); |
2989 | + WARN_ON(ret); |
2990 | |
2991 | - if (tgt_device) |
2992 | - btrfs_destroy_dev_replace_tgtdev(tgt_device); |
2993 | + btrfs_info_in_rcu(fs_info, |
2994 | + "suspended dev_replace from %s (devid %llu) to %s canceled", |
2995 | + btrfs_dev_name(src_device), src_device->devid, |
2996 | + btrfs_dev_name(tgt_device)); |
2997 | + |
2998 | + if (tgt_device) |
2999 | + btrfs_destroy_dev_replace_tgtdev(tgt_device); |
3000 | + break; |
3001 | + default: |
3002 | + result = -EINVAL; |
3003 | + } |
3004 | |
3005 | -leave: |
3006 | mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); |
3007 | return result; |
3008 | } |
3009 | diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c |
3010 | index 4f6dc56b4f4d..83b3a626c796 100644 |
3011 | --- a/fs/btrfs/inode.c |
3012 | +++ b/fs/btrfs/inode.c |
3013 | @@ -6440,14 +6440,19 @@ fail_dir_item: |
3014 | err = btrfs_del_root_ref(trans, key.objectid, |
3015 | root->root_key.objectid, parent_ino, |
3016 | &local_index, name, name_len); |
3017 | - |
3018 | + if (err) |
3019 | + btrfs_abort_transaction(trans, err); |
3020 | } else if (add_backref) { |
3021 | u64 local_index; |
3022 | int err; |
3023 | |
3024 | err = btrfs_del_inode_ref(trans, root, name, name_len, |
3025 | ino, parent_ino, &local_index); |
3026 | + if (err) |
3027 | + btrfs_abort_transaction(trans, err); |
3028 | } |
3029 | + |
3030 | + /* Return the original error code */ |
3031 | return ret; |
3032 | } |
3033 | |
3034 | diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c |
3035 | index 223334f08530..0ee1cd4b56fb 100644 |
3036 | --- a/fs/btrfs/volumes.c |
3037 | +++ b/fs/btrfs/volumes.c |
3038 | @@ -4768,19 +4768,17 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, |
3039 | /* |
3040 | * Use the number of data stripes to figure out how big this chunk |
3041 | * is really going to be in terms of logical address space, |
3042 | - * and compare that answer with the max chunk size |
3043 | + * and compare that answer with the max chunk size. If it's higher, |
3044 | + * we try to reduce stripe_size. |
3045 | */ |
3046 | if (stripe_size * data_stripes > max_chunk_size) { |
3047 | - stripe_size = div_u64(max_chunk_size, data_stripes); |
3048 | - |
3049 | - /* bump the answer up to a 16MB boundary */ |
3050 | - stripe_size = round_up(stripe_size, SZ_16M); |
3051 | - |
3052 | /* |
3053 | - * But don't go higher than the limits we found while searching |
3054 | - * for free extents |
3055 | + * Reduce stripe_size, round it up to a 16MB boundary again and |
3056 | + * then use it, unless it ends up being even bigger than the |
3057 | + * previous value we had already. |
3058 | */ |
3059 | - stripe_size = min(devices_info[ndevs - 1].max_avail, |
3060 | + stripe_size = min(round_up(div_u64(max_chunk_size, |
3061 | + data_stripes), SZ_16M), |
3062 | stripe_size); |
3063 | } |
3064 | |
3065 | @@ -7474,6 +7472,8 @@ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info) |
3066 | struct btrfs_path *path; |
3067 | struct btrfs_root *root = fs_info->dev_root; |
3068 | struct btrfs_key key; |
3069 | + u64 prev_devid = 0; |
3070 | + u64 prev_dev_ext_end = 0; |
3071 | int ret = 0; |
3072 | |
3073 | key.objectid = 1; |
3074 | @@ -7518,10 +7518,22 @@ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info) |
3075 | chunk_offset = btrfs_dev_extent_chunk_offset(leaf, dext); |
3076 | physical_len = btrfs_dev_extent_length(leaf, dext); |
3077 | |
3078 | + /* Check if this dev extent overlaps with the previous one */ |
3079 | + if (devid == prev_devid && physical_offset < prev_dev_ext_end) { |
3080 | + btrfs_err(fs_info, |
3081 | +"dev extent devid %llu physical offset %llu overlap with previous dev extent end %llu", |
3082 | + devid, physical_offset, prev_dev_ext_end); |
3083 | + ret = -EUCLEAN; |
3084 | + goto out; |
3085 | + } |
3086 | + |
3087 | ret = verify_one_dev_extent(fs_info, chunk_offset, devid, |
3088 | physical_offset, physical_len); |
3089 | if (ret < 0) |
3090 | goto out; |
3091 | + prev_devid = devid; |
3092 | + prev_dev_ext_end = physical_offset + physical_len; |
3093 | + |
3094 | ret = btrfs_next_item(root, path); |
3095 | if (ret < 0) |
3096 | goto out; |
3097 | diff --git a/fs/iomap.c b/fs/iomap.c |
3098 | index ec15cf2ec696..e57fb1e534c5 100644 |
3099 | --- a/fs/iomap.c |
3100 | +++ b/fs/iomap.c |
3101 | @@ -488,16 +488,29 @@ done: |
3102 | } |
3103 | EXPORT_SYMBOL_GPL(iomap_readpages); |
3104 | |
3105 | +/* |
3106 | + * iomap_is_partially_uptodate checks whether blocks within a page are |
3107 | + * uptodate or not. |
3108 | + * |
3109 | + * Returns true if all blocks which correspond to a file portion |
3110 | + * we want to read within the page are uptodate. |
3111 | + */ |
3112 | int |
3113 | iomap_is_partially_uptodate(struct page *page, unsigned long from, |
3114 | unsigned long count) |
3115 | { |
3116 | struct iomap_page *iop = to_iomap_page(page); |
3117 | struct inode *inode = page->mapping->host; |
3118 | - unsigned first = from >> inode->i_blkbits; |
3119 | - unsigned last = (from + count - 1) >> inode->i_blkbits; |
3120 | + unsigned len, first, last; |
3121 | unsigned i; |
3122 | |
3123 | + /* Limit range to one page */ |
3124 | + len = min_t(unsigned, PAGE_SIZE - from, count); |
3125 | + |
3126 | + /* First and last blocks in range within page */ |
3127 | + first = from >> inode->i_blkbits; |
3128 | + last = (from + len - 1) >> inode->i_blkbits; |
3129 | + |
3130 | if (iop) { |
3131 | for (i = first; i <= last; i++) |
3132 | if (!test_bit(i, iop->uptodate)) |
3133 | diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c |
3134 | index 902a7dd10e5c..bb6ae387469f 100644 |
3135 | --- a/fs/jffs2/super.c |
3136 | +++ b/fs/jffs2/super.c |
3137 | @@ -101,7 +101,8 @@ static int jffs2_sync_fs(struct super_block *sb, int wait) |
3138 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); |
3139 | |
3140 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER |
3141 | - cancel_delayed_work_sync(&c->wbuf_dwork); |
3142 | + if (jffs2_is_writebuffered(c)) |
3143 | + cancel_delayed_work_sync(&c->wbuf_dwork); |
3144 | #endif |
3145 | |
3146 | mutex_lock(&c->alloc_sem); |
3147 | diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c |
3148 | index 7642b6712c39..30208233f65b 100644 |
3149 | --- a/fs/ocfs2/localalloc.c |
3150 | +++ b/fs/ocfs2/localalloc.c |
3151 | @@ -345,13 +345,18 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb) |
3152 | if (num_used |
3153 | || alloc->id1.bitmap1.i_used |
3154 | || alloc->id1.bitmap1.i_total |
3155 | - || la->la_bm_off) |
3156 | - mlog(ML_ERROR, "Local alloc hasn't been recovered!\n" |
3157 | + || la->la_bm_off) { |
3158 | + mlog(ML_ERROR, "inconsistent detected, clean journal with" |
3159 | + " unrecovered local alloc, please run fsck.ocfs2!\n" |
3160 | "found = %u, set = %u, taken = %u, off = %u\n", |
3161 | num_used, le32_to_cpu(alloc->id1.bitmap1.i_used), |
3162 | le32_to_cpu(alloc->id1.bitmap1.i_total), |
3163 | OCFS2_LOCAL_ALLOC(alloc)->la_bm_off); |
3164 | |
3165 | + status = -EINVAL; |
3166 | + goto bail; |
3167 | + } |
3168 | + |
3169 | osb->local_alloc_bh = alloc_bh; |
3170 | osb->local_alloc_state = OCFS2_LA_ENABLED; |
3171 | |
3172 | diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c |
3173 | index 0792595ebcfb..3c777ec80d47 100644 |
3174 | --- a/fs/pstore/ram_core.c |
3175 | +++ b/fs/pstore/ram_core.c |
3176 | @@ -496,6 +496,11 @@ static int persistent_ram_post_init(struct persistent_ram_zone *prz, u32 sig, |
3177 | sig ^= PERSISTENT_RAM_SIG; |
3178 | |
3179 | if (prz->buffer->sig == sig) { |
3180 | + if (buffer_size(prz) == 0) { |
3181 | + pr_debug("found existing empty buffer\n"); |
3182 | + return 0; |
3183 | + } |
3184 | + |
3185 | if (buffer_size(prz) > prz->buffer_size || |
3186 | buffer_start(prz) > buffer_size(prz)) |
3187 | pr_info("found existing invalid buffer, size %zu, start %zu\n", |
3188 | diff --git a/fs/quota/quota.c b/fs/quota/quota.c |
3189 | index f0cbf58ad4da..fd5dd806f1b9 100644 |
3190 | --- a/fs/quota/quota.c |
3191 | +++ b/fs/quota/quota.c |
3192 | @@ -791,7 +791,8 @@ static int quotactl_cmd_write(int cmd) |
3193 | /* Return true if quotactl command is manipulating quota on/off state */ |
3194 | static bool quotactl_cmd_onoff(int cmd) |
3195 | { |
3196 | - return (cmd == Q_QUOTAON) || (cmd == Q_QUOTAOFF); |
3197 | + return (cmd == Q_QUOTAON) || (cmd == Q_QUOTAOFF) || |
3198 | + (cmd == Q_XQUOTAON) || (cmd == Q_XQUOTAOFF); |
3199 | } |
3200 | |
3201 | /* |
3202 | diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c |
3203 | index 7a85e609fc27..d8b8323e80f4 100644 |
3204 | --- a/fs/userfaultfd.c |
3205 | +++ b/fs/userfaultfd.c |
3206 | @@ -736,10 +736,18 @@ void mremap_userfaultfd_prep(struct vm_area_struct *vma, |
3207 | struct userfaultfd_ctx *ctx; |
3208 | |
3209 | ctx = vma->vm_userfaultfd_ctx.ctx; |
3210 | - if (ctx && (ctx->features & UFFD_FEATURE_EVENT_REMAP)) { |
3211 | + |
3212 | + if (!ctx) |
3213 | + return; |
3214 | + |
3215 | + if (ctx->features & UFFD_FEATURE_EVENT_REMAP) { |
3216 | vm_ctx->ctx = ctx; |
3217 | userfaultfd_ctx_get(ctx); |
3218 | WRITE_ONCE(ctx->mmap_changing, true); |
3219 | + } else { |
3220 | + /* Drop uffd context if remap feature not enabled */ |
3221 | + vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX; |
3222 | + vma->vm_flags &= ~(VM_UFFD_WP | VM_UFFD_MISSING); |
3223 | } |
3224 | } |
3225 | |
3226 | diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h |
3227 | index 9a6bc0951cfa..c31157135598 100644 |
3228 | --- a/include/linux/backing-dev-defs.h |
3229 | +++ b/include/linux/backing-dev-defs.h |
3230 | @@ -258,6 +258,14 @@ static inline void wb_get(struct bdi_writeback *wb) |
3231 | */ |
3232 | static inline void wb_put(struct bdi_writeback *wb) |
3233 | { |
3234 | + if (WARN_ON_ONCE(!wb->bdi)) { |
3235 | + /* |
3236 | + * A driver bug might cause a file to be removed before bdi was |
3237 | + * initialized. |
3238 | + */ |
3239 | + return; |
3240 | + } |
3241 | + |
3242 | if (wb != &wb->bdi->wb) |
3243 | percpu_ref_put(&wb->refcnt); |
3244 | } |
3245 | diff --git a/include/linux/filter.h b/include/linux/filter.h |
3246 | index 6791a0ac0139..ec90d5255cf7 100644 |
3247 | --- a/include/linux/filter.h |
3248 | +++ b/include/linux/filter.h |
3249 | @@ -665,24 +665,10 @@ static inline u32 bpf_ctx_off_adjust_machine(u32 size) |
3250 | return size; |
3251 | } |
3252 | |
3253 | -static inline bool bpf_ctx_narrow_align_ok(u32 off, u32 size_access, |
3254 | - u32 size_default) |
3255 | -{ |
3256 | - size_default = bpf_ctx_off_adjust_machine(size_default); |
3257 | - size_access = bpf_ctx_off_adjust_machine(size_access); |
3258 | - |
3259 | -#ifdef __LITTLE_ENDIAN |
3260 | - return (off & (size_default - 1)) == 0; |
3261 | -#else |
3262 | - return (off & (size_default - 1)) + size_access == size_default; |
3263 | -#endif |
3264 | -} |
3265 | - |
3266 | static inline bool |
3267 | bpf_ctx_narrow_access_ok(u32 off, u32 size, u32 size_default) |
3268 | { |
3269 | - return bpf_ctx_narrow_align_ok(off, size, size_default) && |
3270 | - size <= size_default && (size & (size - 1)) == 0; |
3271 | + return size <= size_default && (size & (size - 1)) == 0; |
3272 | } |
3273 | |
3274 | #define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0])) |
3275 | diff --git a/include/linux/swap.h b/include/linux/swap.h |
3276 | index 8e2c11e692ba..77221c16733a 100644 |
3277 | --- a/include/linux/swap.h |
3278 | +++ b/include/linux/swap.h |
3279 | @@ -232,7 +232,6 @@ struct swap_info_struct { |
3280 | unsigned long flags; /* SWP_USED etc: see above */ |
3281 | signed short prio; /* swap priority of this type */ |
3282 | struct plist_node list; /* entry in swap_active_head */ |
3283 | - struct plist_node avail_lists[MAX_NUMNODES];/* entry in swap_avail_heads */ |
3284 | signed char type; /* strange name for an index */ |
3285 | unsigned int max; /* extent of the swap_map */ |
3286 | unsigned char *swap_map; /* vmalloc'ed array of usage counts */ |
3287 | @@ -273,6 +272,16 @@ struct swap_info_struct { |
3288 | */ |
3289 | struct work_struct discard_work; /* discard worker */ |
3290 | struct swap_cluster_list discard_clusters; /* discard clusters list */ |
3291 | + struct plist_node avail_lists[0]; /* |
3292 | + * entries in swap_avail_heads, one |
3293 | + * entry per node. |
3294 | + * Must be last as the number of the |
3295 | + * array is nr_node_ids, which is not |
3296 | + * a fixed value so have to allocate |
3297 | + * dynamically. |
3298 | + * And it has to be an array so that |
3299 | + * plist_for_each_* can work. |
3300 | + */ |
3301 | }; |
3302 | |
3303 | #ifdef CONFIG_64BIT |
3304 | diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h |
3305 | index 7e7fbfb84e8e..50c74a77db55 100644 |
3306 | --- a/include/linux/usb/tcpm.h |
3307 | +++ b/include/linux/usb/tcpm.h |
3308 | @@ -89,6 +89,7 @@ struct tcpc_config { |
3309 | enum typec_port_data data; |
3310 | enum typec_role default_role; |
3311 | bool try_role_hw; /* try.{src,snk} implemented in hardware */ |
3312 | + bool self_powered; /* port belongs to a self powered device */ |
3313 | |
3314 | const struct typec_altmode_desc *alt_modes; |
3315 | }; |
3316 | diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h |
3317 | index 7a4ee7852ca4..2cfd3b4573b0 100644 |
3318 | --- a/include/target/target_core_base.h |
3319 | +++ b/include/target/target_core_base.h |
3320 | @@ -602,6 +602,7 @@ struct se_session { |
3321 | struct se_node_acl *se_node_acl; |
3322 | struct se_portal_group *se_tpg; |
3323 | void *fabric_sess_ptr; |
3324 | + struct percpu_ref cmd_count; |
3325 | struct list_head sess_list; |
3326 | struct list_head sess_acl_list; |
3327 | struct list_head sess_cmd_list; |
3328 | diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h |
3329 | index f4147b398431..eb9d0923c55c 100644 |
3330 | --- a/include/target/target_core_fabric.h |
3331 | +++ b/include/target/target_core_fabric.h |
3332 | @@ -116,7 +116,7 @@ struct se_session *target_setup_session(struct se_portal_group *, |
3333 | struct se_session *, void *)); |
3334 | void target_remove_session(struct se_session *); |
3335 | |
3336 | -void transport_init_session(struct se_session *); |
3337 | +int transport_init_session(struct se_session *se_sess); |
3338 | struct se_session *transport_alloc_session(enum target_prot_op); |
3339 | int transport_alloc_session_tags(struct se_session *, unsigned int, |
3340 | unsigned int); |
3341 | diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c |
3342 | index 2954e4b3abd5..341806668f03 100644 |
3343 | --- a/kernel/bpf/verifier.c |
3344 | +++ b/kernel/bpf/verifier.c |
3345 | @@ -3285,12 +3285,15 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn) |
3346 | return err; |
3347 | |
3348 | if (BPF_SRC(insn->code) == BPF_X) { |
3349 | + struct bpf_reg_state *src_reg = regs + insn->src_reg; |
3350 | + struct bpf_reg_state *dst_reg = regs + insn->dst_reg; |
3351 | + |
3352 | if (BPF_CLASS(insn->code) == BPF_ALU64) { |
3353 | /* case: R1 = R2 |
3354 | * copy register state to dest reg |
3355 | */ |
3356 | - regs[insn->dst_reg] = regs[insn->src_reg]; |
3357 | - regs[insn->dst_reg].live |= REG_LIVE_WRITTEN; |
3358 | + *dst_reg = *src_reg; |
3359 | + dst_reg->live |= REG_LIVE_WRITTEN; |
3360 | } else { |
3361 | /* R1 = (u32) R2 */ |
3362 | if (is_pointer_value(env, insn->src_reg)) { |
3363 | @@ -3298,9 +3301,14 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn) |
3364 | "R%d partial copy of pointer\n", |
3365 | insn->src_reg); |
3366 | return -EACCES; |
3367 | + } else if (src_reg->type == SCALAR_VALUE) { |
3368 | + *dst_reg = *src_reg; |
3369 | + dst_reg->live |= REG_LIVE_WRITTEN; |
3370 | + } else { |
3371 | + mark_reg_unknown(env, regs, |
3372 | + insn->dst_reg); |
3373 | } |
3374 | - mark_reg_unknown(env, regs, insn->dst_reg); |
3375 | - coerce_reg_to_size(®s[insn->dst_reg], 4); |
3376 | + coerce_reg_to_size(dst_reg, 4); |
3377 | } |
3378 | } else { |
3379 | /* case: R = imm |
3380 | @@ -5341,10 +5349,10 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env) |
3381 | int i, cnt, size, ctx_field_size, delta = 0; |
3382 | const int insn_cnt = env->prog->len; |
3383 | struct bpf_insn insn_buf[16], *insn; |
3384 | + u32 target_size, size_default, off; |
3385 | struct bpf_prog *new_prog; |
3386 | enum bpf_access_type type; |
3387 | bool is_narrower_load; |
3388 | - u32 target_size; |
3389 | |
3390 | if (ops->gen_prologue) { |
3391 | cnt = ops->gen_prologue(insn_buf, env->seen_direct_write, |
3392 | @@ -5421,9 +5429,9 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env) |
3393 | * we will apply proper mask to the result. |
3394 | */ |
3395 | is_narrower_load = size < ctx_field_size; |
3396 | + size_default = bpf_ctx_off_adjust_machine(ctx_field_size); |
3397 | + off = insn->off; |
3398 | if (is_narrower_load) { |
3399 | - u32 size_default = bpf_ctx_off_adjust_machine(ctx_field_size); |
3400 | - u32 off = insn->off; |
3401 | u8 size_code; |
3402 | |
3403 | if (type == BPF_WRITE) { |
3404 | @@ -5451,12 +5459,23 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env) |
3405 | } |
3406 | |
3407 | if (is_narrower_load && size < target_size) { |
3408 | - if (ctx_field_size <= 4) |
3409 | + u8 shift = (off & (size_default - 1)) * 8; |
3410 | + |
3411 | + if (ctx_field_size <= 4) { |
3412 | + if (shift) |
3413 | + insn_buf[cnt++] = BPF_ALU32_IMM(BPF_RSH, |
3414 | + insn->dst_reg, |
3415 | + shift); |
3416 | insn_buf[cnt++] = BPF_ALU32_IMM(BPF_AND, insn->dst_reg, |
3417 | (1 << size * 8) - 1); |
3418 | - else |
3419 | + } else { |
3420 | + if (shift) |
3421 | + insn_buf[cnt++] = BPF_ALU64_IMM(BPF_RSH, |
3422 | + insn->dst_reg, |
3423 | + shift); |
3424 | insn_buf[cnt++] = BPF_ALU64_IMM(BPF_AND, insn->dst_reg, |
3425 | (1 << size * 8) - 1); |
3426 | + } |
3427 | } |
3428 | |
3429 | new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt); |
3430 | diff --git a/mm/page-writeback.c b/mm/page-writeback.c |
3431 | index 84ae9bf5858a..ea4fd3af3b4b 100644 |
3432 | --- a/mm/page-writeback.c |
3433 | +++ b/mm/page-writeback.c |
3434 | @@ -2156,6 +2156,7 @@ int write_cache_pages(struct address_space *mapping, |
3435 | { |
3436 | int ret = 0; |
3437 | int done = 0; |
3438 | + int error; |
3439 | struct pagevec pvec; |
3440 | int nr_pages; |
3441 | pgoff_t uninitialized_var(writeback_index); |
3442 | @@ -2236,25 +2237,31 @@ continue_unlock: |
3443 | goto continue_unlock; |
3444 | |
3445 | trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); |
3446 | - ret = (*writepage)(page, wbc, data); |
3447 | - if (unlikely(ret)) { |
3448 | - if (ret == AOP_WRITEPAGE_ACTIVATE) { |
3449 | + error = (*writepage)(page, wbc, data); |
3450 | + if (unlikely(error)) { |
3451 | + /* |
3452 | + * Handle errors according to the type of |
3453 | + * writeback. There's no need to continue for |
3454 | + * background writeback. Just push done_index |
3455 | + * past this page so media errors won't choke |
3456 | + * writeout for the entire file. For integrity |
3457 | + * writeback, we must process the entire dirty |
3458 | + * set regardless of errors because the fs may |
3459 | + * still have state to clear for each page. In |
3460 | + * that case we continue processing and return |
3461 | + * the first error. |
3462 | + */ |
3463 | + if (error == AOP_WRITEPAGE_ACTIVATE) { |
3464 | unlock_page(page); |
3465 | - ret = 0; |
3466 | - } else { |
3467 | - /* |
3468 | - * done_index is set past this page, |
3469 | - * so media errors will not choke |
3470 | - * background writeout for the entire |
3471 | - * file. This has consequences for |
3472 | - * range_cyclic semantics (ie. it may |
3473 | - * not be suitable for data integrity |
3474 | - * writeout). |
3475 | - */ |
3476 | + error = 0; |
3477 | + } else if (wbc->sync_mode != WB_SYNC_ALL) { |
3478 | + ret = error; |
3479 | done_index = page->index + 1; |
3480 | done = 1; |
3481 | break; |
3482 | } |
3483 | + if (!ret) |
3484 | + ret = error; |
3485 | } |
3486 | |
3487 | /* |
3488 | diff --git a/mm/swapfile.c b/mm/swapfile.c |
3489 | index 67aaf7ae22ff..340ef3177686 100644 |
3490 | --- a/mm/swapfile.c |
3491 | +++ b/mm/swapfile.c |
3492 | @@ -2820,8 +2820,9 @@ static struct swap_info_struct *alloc_swap_info(void) |
3493 | struct swap_info_struct *p; |
3494 | unsigned int type; |
3495 | int i; |
3496 | + int size = sizeof(*p) + nr_node_ids * sizeof(struct plist_node); |
3497 | |
3498 | - p = kvzalloc(sizeof(*p), GFP_KERNEL); |
3499 | + p = kvzalloc(size, GFP_KERNEL); |
3500 | if (!p) |
3501 | return ERR_PTR(-ENOMEM); |
3502 | |
3503 | diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c |
3504 | index f12555f23a49..7f800c3480f7 100644 |
3505 | --- a/net/bluetooth/hci_event.c |
3506 | +++ b/net/bluetooth/hci_event.c |
3507 | @@ -5668,6 +5668,12 @@ static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, |
3508 | return true; |
3509 | } |
3510 | |
3511 | + /* Check if request ended in Command Status - no way to retreive |
3512 | + * any extra parameters in this case. |
3513 | + */ |
3514 | + if (hdr->evt == HCI_EV_CMD_STATUS) |
3515 | + return false; |
3516 | + |
3517 | if (hdr->evt != HCI_EV_CMD_COMPLETE) { |
3518 | bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)", |
3519 | hdr->evt); |
3520 | diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c |
3521 | index 5372e2042adf..2cb8da465b98 100644 |
3522 | --- a/net/bridge/br_forward.c |
3523 | +++ b/net/bridge/br_forward.c |
3524 | @@ -65,6 +65,7 @@ EXPORT_SYMBOL_GPL(br_dev_queue_push_xmit); |
3525 | |
3526 | int br_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb) |
3527 | { |
3528 | + skb->tstamp = 0; |
3529 | return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, |
3530 | net, sk, skb, NULL, skb->dev, |
3531 | br_dev_queue_push_xmit); |
3532 | diff --git a/net/core/skbuff.c b/net/core/skbuff.c |
3533 | index abbbd7fd17fe..589ec5b9ec5f 100644 |
3534 | --- a/net/core/skbuff.c |
3535 | +++ b/net/core/skbuff.c |
3536 | @@ -5258,7 +5258,6 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len, |
3537 | unsigned long chunk; |
3538 | struct sk_buff *skb; |
3539 | struct page *page; |
3540 | - gfp_t gfp_head; |
3541 | int i; |
3542 | |
3543 | *errcode = -EMSGSIZE; |
3544 | @@ -5268,12 +5267,8 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len, |
3545 | if (npages > MAX_SKB_FRAGS) |
3546 | return NULL; |
3547 | |
3548 | - gfp_head = gfp_mask; |
3549 | - if (gfp_head & __GFP_DIRECT_RECLAIM) |
3550 | - gfp_head |= __GFP_RETRY_MAYFAIL; |
3551 | - |
3552 | *errcode = -ENOBUFS; |
3553 | - skb = alloc_skb(header_len, gfp_head); |
3554 | + skb = alloc_skb(header_len, gfp_mask); |
3555 | if (!skb) |
3556 | return NULL; |
3557 | |
3558 | diff --git a/net/core/sock.c b/net/core/sock.c |
3559 | index 5a8a3b76832f..c9668dcb5eb9 100644 |
3560 | --- a/net/core/sock.c |
3561 | +++ b/net/core/sock.c |
3562 | @@ -698,6 +698,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, |
3563 | break; |
3564 | case SO_DONTROUTE: |
3565 | sock_valbool_flag(sk, SOCK_LOCALROUTE, valbool); |
3566 | + sk_dst_reset(sk); |
3567 | break; |
3568 | case SO_BROADCAST: |
3569 | sock_valbool_flag(sk, SOCK_BROADCAST, valbool); |
3570 | diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c |
3571 | index 2c8d313ae216..fb1e7f237f53 100644 |
3572 | --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c |
3573 | +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c |
3574 | @@ -57,17 +57,14 @@ struct clusterip_config { |
3575 | enum clusterip_hashmode hash_mode; /* which hashing mode */ |
3576 | u_int32_t hash_initval; /* hash initialization */ |
3577 | struct rcu_head rcu; |
3578 | - |
3579 | + struct net *net; /* netns for pernet list */ |
3580 | char ifname[IFNAMSIZ]; /* device ifname */ |
3581 | - struct notifier_block notifier; /* refresh c->ifindex in it */ |
3582 | }; |
3583 | |
3584 | #ifdef CONFIG_PROC_FS |
3585 | static const struct file_operations clusterip_proc_fops; |
3586 | #endif |
3587 | |
3588 | -static unsigned int clusterip_net_id __read_mostly; |
3589 | - |
3590 | struct clusterip_net { |
3591 | struct list_head configs; |
3592 | /* lock protects the configs list */ |
3593 | @@ -78,16 +75,30 @@ struct clusterip_net { |
3594 | #endif |
3595 | }; |
3596 | |
3597 | +static unsigned int clusterip_net_id __read_mostly; |
3598 | +static inline struct clusterip_net *clusterip_pernet(struct net *net) |
3599 | +{ |
3600 | + return net_generic(net, clusterip_net_id); |
3601 | +} |
3602 | + |
3603 | static inline void |
3604 | clusterip_config_get(struct clusterip_config *c) |
3605 | { |
3606 | refcount_inc(&c->refcount); |
3607 | } |
3608 | |
3609 | - |
3610 | static void clusterip_config_rcu_free(struct rcu_head *head) |
3611 | { |
3612 | - kfree(container_of(head, struct clusterip_config, rcu)); |
3613 | + struct clusterip_config *config; |
3614 | + struct net_device *dev; |
3615 | + |
3616 | + config = container_of(head, struct clusterip_config, rcu); |
3617 | + dev = dev_get_by_name(config->net, config->ifname); |
3618 | + if (dev) { |
3619 | + dev_mc_del(dev, config->clustermac); |
3620 | + dev_put(dev); |
3621 | + } |
3622 | + kfree(config); |
3623 | } |
3624 | |
3625 | static inline void |
3626 | @@ -101,9 +112,9 @@ clusterip_config_put(struct clusterip_config *c) |
3627 | * entry(rule) is removed, remove the config from lists, but don't free it |
3628 | * yet, since proc-files could still be holding references */ |
3629 | static inline void |
3630 | -clusterip_config_entry_put(struct net *net, struct clusterip_config *c) |
3631 | +clusterip_config_entry_put(struct clusterip_config *c) |
3632 | { |
3633 | - struct clusterip_net *cn = net_generic(net, clusterip_net_id); |
3634 | + struct clusterip_net *cn = clusterip_pernet(c->net); |
3635 | |
3636 | local_bh_disable(); |
3637 | if (refcount_dec_and_lock(&c->entries, &cn->lock)) { |
3638 | @@ -118,8 +129,6 @@ clusterip_config_entry_put(struct net *net, struct clusterip_config *c) |
3639 | spin_unlock(&cn->lock); |
3640 | local_bh_enable(); |
3641 | |
3642 | - unregister_netdevice_notifier(&c->notifier); |
3643 | - |
3644 | return; |
3645 | } |
3646 | local_bh_enable(); |
3647 | @@ -129,7 +138,7 @@ static struct clusterip_config * |
3648 | __clusterip_config_find(struct net *net, __be32 clusterip) |
3649 | { |
3650 | struct clusterip_config *c; |
3651 | - struct clusterip_net *cn = net_generic(net, clusterip_net_id); |
3652 | + struct clusterip_net *cn = clusterip_pernet(net); |
3653 | |
3654 | list_for_each_entry_rcu(c, &cn->configs, list) { |
3655 | if (c->clusterip == clusterip) |
3656 | @@ -181,32 +190,37 @@ clusterip_netdev_event(struct notifier_block *this, unsigned long event, |
3657 | void *ptr) |
3658 | { |
3659 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); |
3660 | + struct net *net = dev_net(dev); |
3661 | + struct clusterip_net *cn = clusterip_pernet(net); |
3662 | struct clusterip_config *c; |
3663 | |
3664 | - c = container_of(this, struct clusterip_config, notifier); |
3665 | - switch (event) { |
3666 | - case NETDEV_REGISTER: |
3667 | - if (!strcmp(dev->name, c->ifname)) { |
3668 | - c->ifindex = dev->ifindex; |
3669 | - dev_mc_add(dev, c->clustermac); |
3670 | - } |
3671 | - break; |
3672 | - case NETDEV_UNREGISTER: |
3673 | - if (dev->ifindex == c->ifindex) { |
3674 | - dev_mc_del(dev, c->clustermac); |
3675 | - c->ifindex = -1; |
3676 | - } |
3677 | - break; |
3678 | - case NETDEV_CHANGENAME: |
3679 | - if (!strcmp(dev->name, c->ifname)) { |
3680 | - c->ifindex = dev->ifindex; |
3681 | - dev_mc_add(dev, c->clustermac); |
3682 | - } else if (dev->ifindex == c->ifindex) { |
3683 | - dev_mc_del(dev, c->clustermac); |
3684 | - c->ifindex = -1; |
3685 | + spin_lock_bh(&cn->lock); |
3686 | + list_for_each_entry_rcu(c, &cn->configs, list) { |
3687 | + switch (event) { |
3688 | + case NETDEV_REGISTER: |
3689 | + if (!strcmp(dev->name, c->ifname)) { |
3690 | + c->ifindex = dev->ifindex; |
3691 | + dev_mc_add(dev, c->clustermac); |
3692 | + } |
3693 | + break; |
3694 | + case NETDEV_UNREGISTER: |
3695 | + if (dev->ifindex == c->ifindex) { |
3696 | + dev_mc_del(dev, c->clustermac); |
3697 | + c->ifindex = -1; |
3698 | + } |
3699 | + break; |
3700 | + case NETDEV_CHANGENAME: |
3701 | + if (!strcmp(dev->name, c->ifname)) { |
3702 | + c->ifindex = dev->ifindex; |
3703 | + dev_mc_add(dev, c->clustermac); |
3704 | + } else if (dev->ifindex == c->ifindex) { |
3705 | + dev_mc_del(dev, c->clustermac); |
3706 | + c->ifindex = -1; |
3707 | + } |
3708 | + break; |
3709 | } |
3710 | - break; |
3711 | } |
3712 | + spin_unlock_bh(&cn->lock); |
3713 | |
3714 | return NOTIFY_DONE; |
3715 | } |
3716 | @@ -215,30 +229,44 @@ static struct clusterip_config * |
3717 | clusterip_config_init(struct net *net, const struct ipt_clusterip_tgt_info *i, |
3718 | __be32 ip, const char *iniface) |
3719 | { |
3720 | - struct clusterip_net *cn = net_generic(net, clusterip_net_id); |
3721 | + struct clusterip_net *cn = clusterip_pernet(net); |
3722 | struct clusterip_config *c; |
3723 | + struct net_device *dev; |
3724 | int err; |
3725 | |
3726 | + if (iniface[0] == '\0') { |
3727 | + pr_info("Please specify an interface name\n"); |
3728 | + return ERR_PTR(-EINVAL); |
3729 | + } |
3730 | + |
3731 | c = kzalloc(sizeof(*c), GFP_ATOMIC); |
3732 | if (!c) |
3733 | return ERR_PTR(-ENOMEM); |
3734 | |
3735 | - strcpy(c->ifname, iniface); |
3736 | - c->ifindex = -1; |
3737 | - c->clusterip = ip; |
3738 | + dev = dev_get_by_name(net, iniface); |
3739 | + if (!dev) { |
3740 | + pr_info("no such interface %s\n", iniface); |
3741 | + kfree(c); |
3742 | + return ERR_PTR(-ENOENT); |
3743 | + } |
3744 | + c->ifindex = dev->ifindex; |
3745 | + strcpy(c->ifname, dev->name); |
3746 | memcpy(&c->clustermac, &i->clustermac, ETH_ALEN); |
3747 | + dev_mc_add(dev, c->clustermac); |
3748 | + dev_put(dev); |
3749 | + |
3750 | + c->clusterip = ip; |
3751 | c->num_total_nodes = i->num_total_nodes; |
3752 | clusterip_config_init_nodelist(c, i); |
3753 | c->hash_mode = i->hash_mode; |
3754 | c->hash_initval = i->hash_initval; |
3755 | + c->net = net; |
3756 | refcount_set(&c->refcount, 1); |
3757 | |
3758 | spin_lock_bh(&cn->lock); |
3759 | if (__clusterip_config_find(net, ip)) { |
3760 | - spin_unlock_bh(&cn->lock); |
3761 | - kfree(c); |
3762 | - |
3763 | - return ERR_PTR(-EBUSY); |
3764 | + err = -EBUSY; |
3765 | + goto out_config_put; |
3766 | } |
3767 | |
3768 | list_add_rcu(&c->list, &cn->configs); |
3769 | @@ -260,22 +288,17 @@ clusterip_config_init(struct net *net, const struct ipt_clusterip_tgt_info *i, |
3770 | } |
3771 | #endif |
3772 | |
3773 | - c->notifier.notifier_call = clusterip_netdev_event; |
3774 | - err = register_netdevice_notifier(&c->notifier); |
3775 | - if (!err) { |
3776 | - refcount_set(&c->entries, 1); |
3777 | - return c; |
3778 | - } |
3779 | + refcount_set(&c->entries, 1); |
3780 | + return c; |
3781 | |
3782 | #ifdef CONFIG_PROC_FS |
3783 | - proc_remove(c->pde); |
3784 | err: |
3785 | #endif |
3786 | spin_lock_bh(&cn->lock); |
3787 | list_del_rcu(&c->list); |
3788 | +out_config_put: |
3789 | spin_unlock_bh(&cn->lock); |
3790 | clusterip_config_put(c); |
3791 | - |
3792 | return ERR_PTR(err); |
3793 | } |
3794 | |
3795 | @@ -475,34 +498,20 @@ static int clusterip_tg_check(const struct xt_tgchk_param *par) |
3796 | &e->ip.dst.s_addr); |
3797 | return -EINVAL; |
3798 | } else { |
3799 | - struct net_device *dev; |
3800 | - |
3801 | - if (e->ip.iniface[0] == '\0') { |
3802 | - pr_info("Please specify an interface name\n"); |
3803 | - return -EINVAL; |
3804 | - } |
3805 | - |
3806 | - dev = dev_get_by_name(par->net, e->ip.iniface); |
3807 | - if (!dev) { |
3808 | - pr_info("no such interface %s\n", |
3809 | - e->ip.iniface); |
3810 | - return -ENOENT; |
3811 | - } |
3812 | - dev_put(dev); |
3813 | - |
3814 | config = clusterip_config_init(par->net, cipinfo, |
3815 | e->ip.dst.s_addr, |
3816 | e->ip.iniface); |
3817 | if (IS_ERR(config)) |
3818 | return PTR_ERR(config); |
3819 | } |
3820 | - } |
3821 | + } else if (memcmp(&config->clustermac, &cipinfo->clustermac, ETH_ALEN)) |
3822 | + return -EINVAL; |
3823 | |
3824 | ret = nf_ct_netns_get(par->net, par->family); |
3825 | if (ret < 0) { |
3826 | pr_info("cannot load conntrack support for proto=%u\n", |
3827 | par->family); |
3828 | - clusterip_config_entry_put(par->net, config); |
3829 | + clusterip_config_entry_put(config); |
3830 | clusterip_config_put(config); |
3831 | return ret; |
3832 | } |
3833 | @@ -524,7 +533,7 @@ static void clusterip_tg_destroy(const struct xt_tgdtor_param *par) |
3834 | |
3835 | /* if no more entries are referencing the config, remove it |
3836 | * from the list and destroy the proc entry */ |
3837 | - clusterip_config_entry_put(par->net, cipinfo->config); |
3838 | + clusterip_config_entry_put(cipinfo->config); |
3839 | |
3840 | clusterip_config_put(cipinfo->config); |
3841 | |
3842 | @@ -806,7 +815,7 @@ static const struct file_operations clusterip_proc_fops = { |
3843 | |
3844 | static int clusterip_net_init(struct net *net) |
3845 | { |
3846 | - struct clusterip_net *cn = net_generic(net, clusterip_net_id); |
3847 | + struct clusterip_net *cn = clusterip_pernet(net); |
3848 | int ret; |
3849 | |
3850 | INIT_LIST_HEAD(&cn->configs); |
3851 | @@ -831,13 +840,12 @@ static int clusterip_net_init(struct net *net) |
3852 | |
3853 | static void clusterip_net_exit(struct net *net) |
3854 | { |
3855 | - struct clusterip_net *cn = net_generic(net, clusterip_net_id); |
3856 | + struct clusterip_net *cn = clusterip_pernet(net); |
3857 | #ifdef CONFIG_PROC_FS |
3858 | proc_remove(cn->procdir); |
3859 | cn->procdir = NULL; |
3860 | #endif |
3861 | nf_unregister_net_hook(net, &cip_arp_ops); |
3862 | - WARN_ON_ONCE(!list_empty(&cn->configs)); |
3863 | } |
3864 | |
3865 | static struct pernet_operations clusterip_net_ops = { |
3866 | @@ -847,6 +855,10 @@ static struct pernet_operations clusterip_net_ops = { |
3867 | .size = sizeof(struct clusterip_net), |
3868 | }; |
3869 | |
3870 | +struct notifier_block cip_netdev_notifier = { |
3871 | + .notifier_call = clusterip_netdev_event |
3872 | +}; |
3873 | + |
3874 | static int __init clusterip_tg_init(void) |
3875 | { |
3876 | int ret; |
3877 | @@ -859,11 +871,17 @@ static int __init clusterip_tg_init(void) |
3878 | if (ret < 0) |
3879 | goto cleanup_subsys; |
3880 | |
3881 | + ret = register_netdevice_notifier(&cip_netdev_notifier); |
3882 | + if (ret < 0) |
3883 | + goto unregister_target; |
3884 | + |
3885 | pr_info("ClusterIP Version %s loaded successfully\n", |
3886 | CLUSTERIP_VERSION); |
3887 | |
3888 | return 0; |
3889 | |
3890 | +unregister_target: |
3891 | + xt_unregister_target(&clusterip_tg_reg); |
3892 | cleanup_subsys: |
3893 | unregister_pernet_subsys(&clusterip_net_ops); |
3894 | return ret; |
3895 | @@ -873,6 +891,7 @@ static void __exit clusterip_tg_exit(void) |
3896 | { |
3897 | pr_info("ClusterIP Version %s unloading\n", CLUSTERIP_VERSION); |
3898 | |
3899 | + unregister_netdevice_notifier(&cip_netdev_notifier); |
3900 | xt_unregister_target(&clusterip_tg_reg); |
3901 | unregister_pernet_subsys(&clusterip_net_ops); |
3902 | |
3903 | diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c |
3904 | index 9a4261e50272..506b2ae07bb3 100644 |
3905 | --- a/net/ipv6/af_inet6.c |
3906 | +++ b/net/ipv6/af_inet6.c |
3907 | @@ -309,6 +309,7 @@ static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len, |
3908 | |
3909 | /* Check if the address belongs to the host. */ |
3910 | if (addr_type == IPV6_ADDR_MAPPED) { |
3911 | + struct net_device *dev = NULL; |
3912 | int chk_addr_ret; |
3913 | |
3914 | /* Binding to v4-mapped address on a v6-only socket |
3915 | @@ -319,9 +320,20 @@ static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len, |
3916 | goto out; |
3917 | } |
3918 | |
3919 | + rcu_read_lock(); |
3920 | + if (sk->sk_bound_dev_if) { |
3921 | + dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if); |
3922 | + if (!dev) { |
3923 | + err = -ENODEV; |
3924 | + goto out_unlock; |
3925 | + } |
3926 | + } |
3927 | + |
3928 | /* Reproduce AF_INET checks to make the bindings consistent */ |
3929 | v4addr = addr->sin6_addr.s6_addr32[3]; |
3930 | - chk_addr_ret = inet_addr_type(net, v4addr); |
3931 | + chk_addr_ret = inet_addr_type_dev_table(net, dev, v4addr); |
3932 | + rcu_read_unlock(); |
3933 | + |
3934 | if (!inet_can_nonlocal_bind(net, inet) && |
3935 | v4addr != htonl(INADDR_ANY) && |
3936 | chk_addr_ret != RTN_LOCAL && |
3937 | diff --git a/net/netfilter/ipset/ip_set_bitmap_ipmac.c b/net/netfilter/ipset/ip_set_bitmap_ipmac.c |
3938 | index c00b6a2e8e3c..13ade5782847 100644 |
3939 | --- a/net/netfilter/ipset/ip_set_bitmap_ipmac.c |
3940 | +++ b/net/netfilter/ipset/ip_set_bitmap_ipmac.c |
3941 | @@ -219,10 +219,6 @@ bitmap_ipmac_kadt(struct ip_set *set, const struct sk_buff *skb, |
3942 | struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); |
3943 | u32 ip; |
3944 | |
3945 | - /* MAC can be src only */ |
3946 | - if (!(opt->flags & IPSET_DIM_TWO_SRC)) |
3947 | - return 0; |
3948 | - |
3949 | ip = ntohl(ip4addr(skb, opt->flags & IPSET_DIM_ONE_SRC)); |
3950 | if (ip < map->first_ip || ip > map->last_ip) |
3951 | return -IPSET_ERR_BITMAP_RANGE; |
3952 | @@ -233,7 +229,11 @@ bitmap_ipmac_kadt(struct ip_set *set, const struct sk_buff *skb, |
3953 | return -EINVAL; |
3954 | |
3955 | e.id = ip_to_id(map, ip); |
3956 | - memcpy(e.ether, eth_hdr(skb)->h_source, ETH_ALEN); |
3957 | + |
3958 | + if (opt->flags & IPSET_DIM_ONE_SRC) |
3959 | + ether_addr_copy(e.ether, eth_hdr(skb)->h_source); |
3960 | + else |
3961 | + ether_addr_copy(e.ether, eth_hdr(skb)->h_dest); |
3962 | |
3963 | return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags); |
3964 | } |
3965 | diff --git a/net/netfilter/ipset/ip_set_hash_ipmac.c b/net/netfilter/ipset/ip_set_hash_ipmac.c |
3966 | index 1ab5ed2f6839..fd87de3ed55b 100644 |
3967 | --- a/net/netfilter/ipset/ip_set_hash_ipmac.c |
3968 | +++ b/net/netfilter/ipset/ip_set_hash_ipmac.c |
3969 | @@ -103,7 +103,11 @@ hash_ipmac4_kadt(struct ip_set *set, const struct sk_buff *skb, |
3970 | (skb_mac_header(skb) + ETH_HLEN) > skb->data) |
3971 | return -EINVAL; |
3972 | |
3973 | - memcpy(e.ether, eth_hdr(skb)->h_source, ETH_ALEN); |
3974 | + if (opt->flags & IPSET_DIM_ONE_SRC) |
3975 | + ether_addr_copy(e.ether, eth_hdr(skb)->h_source); |
3976 | + else |
3977 | + ether_addr_copy(e.ether, eth_hdr(skb)->h_dest); |
3978 | + |
3979 | if (ether_addr_equal(e.ether, invalid_ether)) |
3980 | return -EINVAL; |
3981 | |
3982 | @@ -211,15 +215,15 @@ hash_ipmac6_kadt(struct ip_set *set, const struct sk_buff *skb, |
3983 | }; |
3984 | struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); |
3985 | |
3986 | - /* MAC can be src only */ |
3987 | - if (!(opt->flags & IPSET_DIM_TWO_SRC)) |
3988 | - return 0; |
3989 | - |
3990 | if (skb_mac_header(skb) < skb->head || |
3991 | (skb_mac_header(skb) + ETH_HLEN) > skb->data) |
3992 | return -EINVAL; |
3993 | |
3994 | - memcpy(e.ether, eth_hdr(skb)->h_source, ETH_ALEN); |
3995 | + if (opt->flags & IPSET_DIM_ONE_SRC) |
3996 | + ether_addr_copy(e.ether, eth_hdr(skb)->h_source); |
3997 | + else |
3998 | + ether_addr_copy(e.ether, eth_hdr(skb)->h_dest); |
3999 | + |
4000 | if (ether_addr_equal(e.ether, invalid_ether)) |
4001 | return -EINVAL; |
4002 | |
4003 | diff --git a/net/netfilter/ipset/ip_set_hash_mac.c b/net/netfilter/ipset/ip_set_hash_mac.c |
4004 | index f9d5a2a1e3d0..4fe5f243d0a3 100644 |
4005 | --- a/net/netfilter/ipset/ip_set_hash_mac.c |
4006 | +++ b/net/netfilter/ipset/ip_set_hash_mac.c |
4007 | @@ -81,15 +81,15 @@ hash_mac4_kadt(struct ip_set *set, const struct sk_buff *skb, |
4008 | struct hash_mac4_elem e = { { .foo[0] = 0, .foo[1] = 0 } }; |
4009 | struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); |
4010 | |
4011 | - /* MAC can be src only */ |
4012 | - if (!(opt->flags & IPSET_DIM_ONE_SRC)) |
4013 | - return 0; |
4014 | - |
4015 | if (skb_mac_header(skb) < skb->head || |
4016 | (skb_mac_header(skb) + ETH_HLEN) > skb->data) |
4017 | return -EINVAL; |
4018 | |
4019 | - ether_addr_copy(e.ether, eth_hdr(skb)->h_source); |
4020 | + if (opt->flags & IPSET_DIM_ONE_SRC) |
4021 | + ether_addr_copy(e.ether, eth_hdr(skb)->h_source); |
4022 | + else |
4023 | + ether_addr_copy(e.ether, eth_hdr(skb)->h_dest); |
4024 | + |
4025 | if (is_zero_ether_addr(e.ether)) |
4026 | return -EINVAL; |
4027 | return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags); |
4028 | diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c |
4029 | index 904e775d1a44..cf40a8284a38 100644 |
4030 | --- a/samples/bpf/bpf_load.c |
4031 | +++ b/samples/bpf/bpf_load.c |
4032 | @@ -55,6 +55,23 @@ static int populate_prog_array(const char *event, int prog_fd) |
4033 | return 0; |
4034 | } |
4035 | |
4036 | +static int write_kprobe_events(const char *val) |
4037 | +{ |
4038 | + int fd, ret, flags; |
4039 | + |
4040 | + if ((val != NULL) && (val[0] == '\0')) |
4041 | + flags = O_WRONLY | O_TRUNC; |
4042 | + else |
4043 | + flags = O_WRONLY | O_APPEND; |
4044 | + |
4045 | + fd = open("/sys/kernel/debug/tracing/kprobe_events", flags); |
4046 | + |
4047 | + ret = write(fd, val, strlen(val)); |
4048 | + close(fd); |
4049 | + |
4050 | + return ret; |
4051 | +} |
4052 | + |
4053 | static int load_and_attach(const char *event, struct bpf_insn *prog, int size) |
4054 | { |
4055 | bool is_socket = strncmp(event, "socket", 6) == 0; |
4056 | @@ -166,10 +183,9 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size) |
4057 | |
4058 | #ifdef __x86_64__ |
4059 | if (strncmp(event, "sys_", 4) == 0) { |
4060 | - snprintf(buf, sizeof(buf), |
4061 | - "echo '%c:__x64_%s __x64_%s' >> /sys/kernel/debug/tracing/kprobe_events", |
4062 | - is_kprobe ? 'p' : 'r', event, event); |
4063 | - err = system(buf); |
4064 | + snprintf(buf, sizeof(buf), "%c:__x64_%s __x64_%s", |
4065 | + is_kprobe ? 'p' : 'r', event, event); |
4066 | + err = write_kprobe_events(buf); |
4067 | if (err >= 0) { |
4068 | need_normal_check = false; |
4069 | event_prefix = "__x64_"; |
4070 | @@ -177,10 +193,9 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size) |
4071 | } |
4072 | #endif |
4073 | if (need_normal_check) { |
4074 | - snprintf(buf, sizeof(buf), |
4075 | - "echo '%c:%s %s' >> /sys/kernel/debug/tracing/kprobe_events", |
4076 | - is_kprobe ? 'p' : 'r', event, event); |
4077 | - err = system(buf); |
4078 | + snprintf(buf, sizeof(buf), "%c:%s %s", |
4079 | + is_kprobe ? 'p' : 'r', event, event); |
4080 | + err = write_kprobe_events(buf); |
4081 | if (err < 0) { |
4082 | printf("failed to create kprobe '%s' error '%s'\n", |
4083 | event, strerror(errno)); |
4084 | @@ -520,7 +535,7 @@ static int do_load_bpf_file(const char *path, fixup_map_cb fixup_map) |
4085 | return 1; |
4086 | |
4087 | /* clear all kprobes */ |
4088 | - i = system("echo \"\" > /sys/kernel/debug/tracing/kprobe_events"); |
4089 | + i = write_kprobe_events(""); |
4090 | |
4091 | /* scan over all elf sections to get license and map info */ |
4092 | for (i = 1; i < ehdr.e_shnum; i++) { |
4093 | diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l |
4094 | index 25bd2b89fe3f..c2f577d71964 100644 |
4095 | --- a/scripts/kconfig/zconf.l |
4096 | +++ b/scripts/kconfig/zconf.l |
4097 | @@ -73,7 +73,7 @@ static void warn_ignored_character(char chr) |
4098 | { |
4099 | fprintf(stderr, |
4100 | "%s:%d:warning: ignoring unsupported character '%c'\n", |
4101 | - zconf_curname(), zconf_lineno(), chr); |
4102 | + current_file->name, yylineno, chr); |
4103 | } |
4104 | %} |
4105 | |
4106 | @@ -221,6 +221,8 @@ n [A-Za-z0-9_-] |
4107 | } |
4108 | <<EOF>> { |
4109 | BEGIN(INITIAL); |
4110 | + yylval.string = text; |
4111 | + return T_WORD_QUOTE; |
4112 | } |
4113 | } |
4114 | |
4115 | diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c |
4116 | index fe251c6f09f1..3c3878f0d2fa 100644 |
4117 | --- a/security/selinux/hooks.c |
4118 | +++ b/security/selinux/hooks.c |
4119 | @@ -2934,7 +2934,7 @@ static int selinux_sb_kern_mount(struct super_block *sb, int flags, void *data) |
4120 | return rc; |
4121 | |
4122 | /* Allow all mounts performed by the kernel */ |
4123 | - if (flags & MS_KERNMOUNT) |
4124 | + if (flags & (MS_KERNMOUNT | MS_SUBMOUNT)) |
4125 | return 0; |
4126 | |
4127 | ad.type = LSM_AUDIT_DATA_DENTRY; |
4128 | diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig |
4129 | index 529d9f405fa9..0cb65d0864cc 100644 |
4130 | --- a/sound/firewire/Kconfig |
4131 | +++ b/sound/firewire/Kconfig |
4132 | @@ -41,6 +41,7 @@ config SND_OXFW |
4133 | * Mackie(Loud) U.420/U.420d |
4134 | * TASCAM FireOne |
4135 | * Stanton Controllers & Systems 1 Deck/Mixer |
4136 | + * APOGEE duet FireWire |
4137 | |
4138 | To compile this driver as a module, choose M here: the module |
4139 | will be called snd-oxfw. |
4140 | diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c |
4141 | index 93676354f87f..de4af8a41ff0 100644 |
4142 | --- a/sound/firewire/bebob/bebob.c |
4143 | +++ b/sound/firewire/bebob/bebob.c |
4144 | @@ -434,7 +434,7 @@ static const struct ieee1394_device_id bebob_id_table[] = { |
4145 | /* Apogee Electronics, DA/AD/DD-16X (X-FireWire card) */ |
4146 | SND_BEBOB_DEV_ENTRY(VEN_APOGEE, 0x00010048, &spec_normal), |
4147 | /* Apogee Electronics, Ensemble */ |
4148 | - SND_BEBOB_DEV_ENTRY(VEN_APOGEE, 0x00001eee, &spec_normal), |
4149 | + SND_BEBOB_DEV_ENTRY(VEN_APOGEE, 0x01eeee, &spec_normal), |
4150 | /* ESI, Quatafire610 */ |
4151 | SND_BEBOB_DEV_ENTRY(VEN_ESI, 0x00010064, &spec_normal), |
4152 | /* AcousticReality, eARMasterOne */ |
4153 | diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c |
4154 | index 2ea8be6c8584..5f82a375725a 100644 |
4155 | --- a/sound/firewire/oxfw/oxfw.c |
4156 | +++ b/sound/firewire/oxfw/oxfw.c |
4157 | @@ -20,6 +20,7 @@ |
4158 | #define VENDOR_LACIE 0x00d04b |
4159 | #define VENDOR_TASCAM 0x00022e |
4160 | #define OUI_STANTON 0x001260 |
4161 | +#define OUI_APOGEE 0x0003db |
4162 | |
4163 | #define MODEL_SATELLITE 0x00200f |
4164 | |
4165 | @@ -436,6 +437,13 @@ static const struct ieee1394_device_id oxfw_id_table[] = { |
4166 | .vendor_id = OUI_STANTON, |
4167 | .model_id = 0x002000, |
4168 | }, |
4169 | + // APOGEE, duet FireWire |
4170 | + { |
4171 | + .match_flags = IEEE1394_MATCH_VENDOR_ID | |
4172 | + IEEE1394_MATCH_MODEL_ID, |
4173 | + .vendor_id = OUI_APOGEE, |
4174 | + .model_id = 0x01dddd, |
4175 | + }, |
4176 | { } |
4177 | }; |
4178 | MODULE_DEVICE_TABLE(ieee1394, oxfw_id_table); |
4179 | diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c |
4180 | index 3135e9eafd18..7f376b63a166 100644 |
4181 | --- a/sound/soc/amd/acp-pcm-dma.c |
4182 | +++ b/sound/soc/amd/acp-pcm-dma.c |
4183 | @@ -1147,18 +1147,21 @@ static int acp_dma_new(struct snd_soc_pcm_runtime *rtd) |
4184 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, |
4185 | DRV_NAME); |
4186 | struct audio_drv_data *adata = dev_get_drvdata(component->dev); |
4187 | + struct device *parent = component->dev->parent; |
4188 | |
4189 | switch (adata->asic_type) { |
4190 | case CHIP_STONEY: |
4191 | ret = snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, |
4192 | SNDRV_DMA_TYPE_DEV, |
4193 | - NULL, ST_MIN_BUFFER, |
4194 | + parent, |
4195 | + ST_MIN_BUFFER, |
4196 | ST_MAX_BUFFER); |
4197 | break; |
4198 | default: |
4199 | ret = snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, |
4200 | SNDRV_DMA_TYPE_DEV, |
4201 | - NULL, MIN_BUFFER, |
4202 | + parent, |
4203 | + MIN_BUFFER, |
4204 | MAX_BUFFER); |
4205 | break; |
4206 | } |
4207 | diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c |
4208 | index 3356c91f55b0..e3de1ff3b6c2 100644 |
4209 | --- a/sound/soc/codecs/pcm3168a.c |
4210 | +++ b/sound/soc/codecs/pcm3168a.c |
4211 | @@ -688,15 +688,22 @@ err_clk: |
4212 | } |
4213 | EXPORT_SYMBOL_GPL(pcm3168a_probe); |
4214 | |
4215 | -void pcm3168a_remove(struct device *dev) |
4216 | +static void pcm3168a_disable(struct device *dev) |
4217 | { |
4218 | struct pcm3168a_priv *pcm3168a = dev_get_drvdata(dev); |
4219 | |
4220 | - pm_runtime_disable(dev); |
4221 | regulator_bulk_disable(ARRAY_SIZE(pcm3168a->supplies), |
4222 | - pcm3168a->supplies); |
4223 | + pcm3168a->supplies); |
4224 | clk_disable_unprepare(pcm3168a->scki); |
4225 | } |
4226 | + |
4227 | +void pcm3168a_remove(struct device *dev) |
4228 | +{ |
4229 | + pm_runtime_disable(dev); |
4230 | +#ifndef CONFIG_PM |
4231 | + pcm3168a_disable(dev); |
4232 | +#endif |
4233 | +} |
4234 | EXPORT_SYMBOL_GPL(pcm3168a_remove); |
4235 | |
4236 | #ifdef CONFIG_PM |
4237 | @@ -751,10 +758,7 @@ static int pcm3168a_rt_suspend(struct device *dev) |
4238 | |
4239 | regcache_cache_only(pcm3168a->regmap, true); |
4240 | |
4241 | - regulator_bulk_disable(ARRAY_SIZE(pcm3168a->supplies), |
4242 | - pcm3168a->supplies); |
4243 | - |
4244 | - clk_disable_unprepare(pcm3168a->scki); |
4245 | + pcm3168a_disable(dev); |
4246 | |
4247 | return 0; |
4248 | } |
4249 | diff --git a/tools/lib/subcmd/Makefile b/tools/lib/subcmd/Makefile |
4250 | index 95563b8e1ad7..ed61fb3a46c0 100644 |
4251 | --- a/tools/lib/subcmd/Makefile |
4252 | +++ b/tools/lib/subcmd/Makefile |
4253 | @@ -36,8 +36,6 @@ endif |
4254 | CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE |
4255 | |
4256 | CFLAGS += -I$(srctree)/tools/include/ |
4257 | -CFLAGS += -I$(srctree)/include/uapi |
4258 | -CFLAGS += -I$(srctree)/include |
4259 | |
4260 | SUBCMD_IN := $(OUTPUT)libsubcmd-in.o |
4261 | |
4262 | diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config |
4263 | index e30d20fb482d..f00ea77f5f08 100644 |
4264 | --- a/tools/perf/Makefile.config |
4265 | +++ b/tools/perf/Makefile.config |
4266 | @@ -294,6 +294,8 @@ ifndef NO_BIONIC |
4267 | $(call feature_check,bionic) |
4268 | ifeq ($(feature-bionic), 1) |
4269 | BIONIC := 1 |
4270 | + CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE |
4271 | + CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE |
4272 | EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) |
4273 | EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) |
4274 | endif |
4275 | diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c |
4276 | index db0ba8caf5a2..ba8ecaf52200 100644 |
4277 | --- a/tools/perf/arch/x86/util/intel-pt.c |
4278 | +++ b/tools/perf/arch/x86/util/intel-pt.c |
4279 | @@ -524,10 +524,21 @@ static int intel_pt_validate_config(struct perf_pmu *intel_pt_pmu, |
4280 | struct perf_evsel *evsel) |
4281 | { |
4282 | int err; |
4283 | + char c; |
4284 | |
4285 | if (!evsel) |
4286 | return 0; |
4287 | |
4288 | + /* |
4289 | + * If supported, force pass-through config term (pt=1) even if user |
4290 | + * sets pt=0, which avoids senseless kernel errors. |
4291 | + */ |
4292 | + if (perf_pmu__scan_file(intel_pt_pmu, "format/pt", "%c", &c) == 1 && |
4293 | + !(evsel->attr.config & 1)) { |
4294 | + pr_warning("pt=0 doesn't make sense, forcing pt=1\n"); |
4295 | + evsel->attr.config |= 1; |
4296 | + } |
4297 | + |
4298 | err = intel_pt_val_config_term(intel_pt_pmu, "caps/cycle_thresholds", |
4299 | "cyc_thresh", "caps/psb_cyc", |
4300 | evsel->attr.config); |
4301 | diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c |
4302 | index d097b5b47eb8..40720150ccd8 100644 |
4303 | --- a/tools/perf/builtin-stat.c |
4304 | +++ b/tools/perf/builtin-stat.c |
4305 | @@ -1961,7 +1961,7 @@ static int parse_metric_groups(const struct option *opt, |
4306 | return metricgroup__parse_groups(opt, str, &metric_events); |
4307 | } |
4308 | |
4309 | -static const struct option stat_options[] = { |
4310 | +static struct option stat_options[] = { |
4311 | OPT_BOOLEAN('T', "transaction", &transaction_run, |
4312 | "hardware transaction statistics"), |
4313 | OPT_CALLBACK('e', "event", &evsel_list, "event", |
4314 | @@ -2847,6 +2847,12 @@ int cmd_stat(int argc, const char **argv) |
4315 | return -ENOMEM; |
4316 | |
4317 | parse_events__shrink_config_terms(); |
4318 | + |
4319 | + /* String-parsing callback-based options would segfault when negated */ |
4320 | + set_option_flag(stat_options, 'e', "event", PARSE_OPT_NONEG); |
4321 | + set_option_flag(stat_options, 'M', "metrics", PARSE_OPT_NONEG); |
4322 | + set_option_flag(stat_options, 'G', "cgroup", PARSE_OPT_NONEG); |
4323 | + |
4324 | argc = parse_options_subcommand(argc, argv, stat_options, stat_subcommands, |
4325 | (const char **) stat_usage, |
4326 | PARSE_OPT_STOP_AT_NON_OPTION); |
4327 | diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c |
4328 | index a827919c6263..775b99833e51 100644 |
4329 | --- a/tools/perf/builtin-timechart.c |
4330 | +++ b/tools/perf/builtin-timechart.c |
4331 | @@ -43,6 +43,10 @@ |
4332 | #include "util/data.h" |
4333 | #include "util/debug.h" |
4334 | |
4335 | +#ifdef LACKS_OPEN_MEMSTREAM_PROTOTYPE |
4336 | +FILE *open_memstream(char **ptr, size_t *sizeloc); |
4337 | +#endif |
4338 | + |
4339 | #define SUPPORT_OLD_POWER_EVENTS 1 |
4340 | #define PWR_EVENT_EXIT -1 |
4341 | |
4342 | diff --git a/tools/perf/pmu-events/arch/x86/skylake/skl-metrics.json b/tools/perf/pmu-events/arch/x86/skylake/skl-metrics.json |
4343 | index 36c903faed0b..71e9737f4614 100644 |
4344 | --- a/tools/perf/pmu-events/arch/x86/skylake/skl-metrics.json |
4345 | +++ b/tools/perf/pmu-events/arch/x86/skylake/skl-metrics.json |
4346 | @@ -73,7 +73,7 @@ |
4347 | }, |
4348 | { |
4349 | "BriefDescription": "Actual Average Latency for L1 data-cache miss demand loads", |
4350 | - "MetricExpr": "L1D_PEND_MISS.PENDING / ( MEM_LOAD_RETIRED.L1_MISS_PS + MEM_LOAD_RETIRED.FB_HIT_PS )", |
4351 | + "MetricExpr": "L1D_PEND_MISS.PENDING / ( MEM_LOAD_RETIRED.L1_MISS + MEM_LOAD_RETIRED.FB_HIT )", |
4352 | "MetricGroup": "Memory_Bound;Memory_Lat", |
4353 | "MetricName": "Load_Miss_Real_Latency" |
4354 | }, |
4355 | diff --git a/tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json b/tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json |
4356 | index 36c903faed0b..71e9737f4614 100644 |
4357 | --- a/tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json |
4358 | +++ b/tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json |
4359 | @@ -73,7 +73,7 @@ |
4360 | }, |
4361 | { |
4362 | "BriefDescription": "Actual Average Latency for L1 data-cache miss demand loads", |
4363 | - "MetricExpr": "L1D_PEND_MISS.PENDING / ( MEM_LOAD_RETIRED.L1_MISS_PS + MEM_LOAD_RETIRED.FB_HIT_PS )", |
4364 | + "MetricExpr": "L1D_PEND_MISS.PENDING / ( MEM_LOAD_RETIRED.L1_MISS + MEM_LOAD_RETIRED.FB_HIT )", |
4365 | "MetricGroup": "Memory_Bound;Memory_Lat", |
4366 | "MetricName": "Load_Miss_Real_Latency" |
4367 | }, |
4368 | diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c |
4369 | index a467615c5a0e..910e25e64188 100644 |
4370 | --- a/tools/perf/tests/bp_signal.c |
4371 | +++ b/tools/perf/tests/bp_signal.c |
4372 | @@ -291,12 +291,20 @@ int test__bp_signal(struct test *test __maybe_unused, int subtest __maybe_unused |
4373 | |
4374 | bool test__bp_signal_is_supported(void) |
4375 | { |
4376 | -/* |
4377 | - * The powerpc so far does not have support to even create |
4378 | - * instruction breakpoint using the perf event interface. |
4379 | - * Once it's there we can release this. |
4380 | - */ |
4381 | -#if defined(__powerpc__) || defined(__s390x__) |
4382 | + /* |
4383 | + * PowerPC and S390 do not support creation of instruction |
4384 | + * breakpoints using the perf_event interface. |
4385 | + * |
4386 | + * ARM requires explicit rounding down of the instruction |
4387 | + * pointer in Thumb mode, and then requires the single-step |
4388 | + * to be handled explicitly in the overflow handler to avoid |
4389 | + * stepping into the SIGIO handler and getting stuck on the |
4390 | + * breakpointed instruction. |
4391 | + * |
4392 | + * Just disable the test for these architectures until these |
4393 | + * issues are resolved. |
4394 | + */ |
4395 | +#if defined(__powerpc__) || defined(__s390x__) || defined(__arm__) |
4396 | return false; |
4397 | #else |
4398 | return true; |
4399 | diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c |
4400 | index ca577658e890..7b5e15cc6b71 100644 |
4401 | --- a/tools/perf/util/cs-etm.c |
4402 | +++ b/tools/perf/util/cs-etm.c |
4403 | @@ -1005,7 +1005,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) |
4404 | } |
4405 | |
4406 | swap_packet: |
4407 | - if (etmq->etm->synth_opts.last_branch) { |
4408 | + if (etm->sample_branches || etm->synth_opts.last_branch) { |
4409 | /* |
4410 | * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for |
4411 | * the next incoming packet. |
4412 | diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c |
4413 | index be440df29615..819aa4491b53 100644 |
4414 | --- a/tools/perf/util/evlist.c |
4415 | +++ b/tools/perf/util/evlist.c |
4416 | @@ -34,6 +34,10 @@ |
4417 | #include <linux/log2.h> |
4418 | #include <linux/err.h> |
4419 | |
4420 | +#ifdef LACKS_SIGQUEUE_PROTOTYPE |
4421 | +int sigqueue(pid_t pid, int sig, const union sigval value); |
4422 | +#endif |
4423 | + |
4424 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) |
4425 | #define SID(e, x, y) xyarray__entry(e->sample_id, x, y) |
4426 | |
4427 | diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c |
4428 | index f8cd3e7c9186..ebb18a9bc460 100644 |
4429 | --- a/tools/perf/util/parse-events.c |
4430 | +++ b/tools/perf/util/parse-events.c |
4431 | @@ -2454,7 +2454,7 @@ restart: |
4432 | if (!name_only && strlen(syms->alias)) |
4433 | snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); |
4434 | else |
4435 | - strncpy(name, syms->symbol, MAX_NAME_LEN); |
4436 | + strlcpy(name, syms->symbol, MAX_NAME_LEN); |
4437 | |
4438 | evt_list[evt_i] = strdup(name); |
4439 | if (evt_list[evt_i] == NULL) |
4440 | diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c |
4441 | index 1cbada2dc6be..f735ee038713 100644 |
4442 | --- a/tools/perf/util/svghelper.c |
4443 | +++ b/tools/perf/util/svghelper.c |
4444 | @@ -334,7 +334,7 @@ static char *cpu_model(void) |
4445 | if (file) { |
4446 | while (fgets(buf, 255, file)) { |
4447 | if (strstr(buf, "model name")) { |
4448 | - strncpy(cpu_m, &buf[13], 255); |
4449 | + strlcpy(cpu_m, &buf[13], 255); |
4450 | break; |
4451 | } |
4452 | } |
4453 | diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile |
4454 | index fff7fb1285fc..f3f874ba186b 100644 |
4455 | --- a/tools/testing/selftests/bpf/Makefile |
4456 | +++ b/tools/testing/selftests/bpf/Makefile |
4457 | @@ -124,6 +124,16 @@ endif |
4458 | endif |
4459 | endif |
4460 | |
4461 | +# Have one program compiled without "-target bpf" to test whether libbpf loads |
4462 | +# it successfully |
4463 | +$(OUTPUT)/test_xdp.o: test_xdp.c |
4464 | + $(CLANG) $(CLANG_FLAGS) \ |
4465 | + -O2 -emit-llvm -c $< -o - | \ |
4466 | + $(LLC) -march=bpf -mcpu=$(CPU) $(LLC_FLAGS) -filetype=obj -o $@ |
4467 | +ifeq ($(DWARF2BTF),y) |
4468 | + $(BTF_PAHOLE) -J $@ |
4469 | +endif |
4470 | + |
4471 | $(OUTPUT)/%.o: %.c |
4472 | $(CLANG) $(CLANG_FLAGS) \ |
4473 | -O2 -target bpf -emit-llvm -c $< -o - | \ |
4474 | diff --git a/tools/testing/selftests/bpf/test_libbpf.sh b/tools/testing/selftests/bpf/test_libbpf.sh |
4475 | index d97dc914cd49..8b1bc96d8e0c 100755 |
4476 | --- a/tools/testing/selftests/bpf/test_libbpf.sh |
4477 | +++ b/tools/testing/selftests/bpf/test_libbpf.sh |
4478 | @@ -33,17 +33,11 @@ trap exit_handler 0 2 3 6 9 |
4479 | |
4480 | libbpf_open_file test_l4lb.o |
4481 | |
4482 | -# TODO: fix libbpf to load noinline functions |
4483 | -# [warning] libbpf: incorrect bpf_call opcode |
4484 | -#libbpf_open_file test_l4lb_noinline.o |
4485 | +# Load a program with BPF-to-BPF calls |
4486 | +libbpf_open_file test_l4lb_noinline.o |
4487 | |
4488 | -# TODO: fix test_xdp_meta.c to load with libbpf |
4489 | -# [warning] libbpf: test_xdp_meta.o doesn't provide kernel version |
4490 | -#libbpf_open_file test_xdp_meta.o |
4491 | - |
4492 | -# TODO: fix libbpf to handle .eh_frame |
4493 | -# [warning] libbpf: relocation failed: no section(10) |
4494 | -#libbpf_open_file ../../../../samples/bpf/tracex3_kern.o |
4495 | +# Load a program compiled without the "-target bpf" flag |
4496 | +libbpf_open_file test_xdp.o |
4497 | |
4498 | # Success |
4499 | exit 0 |
4500 | diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c |
4501 | index e436b67f2426..9db5a7378f40 100644 |
4502 | --- a/tools/testing/selftests/bpf/test_verifier.c |
4503 | +++ b/tools/testing/selftests/bpf/test_verifier.c |
4504 | @@ -2748,6 +2748,19 @@ static struct bpf_test tests[] = { |
4505 | .result_unpriv = REJECT, |
4506 | .result = ACCEPT, |
4507 | }, |
4508 | + { |
4509 | + "alu32: mov u32 const", |
4510 | + .insns = { |
4511 | + BPF_MOV32_IMM(BPF_REG_7, 0), |
4512 | + BPF_ALU32_IMM(BPF_AND, BPF_REG_7, 1), |
4513 | + BPF_MOV32_REG(BPF_REG_0, BPF_REG_7), |
4514 | + BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 1), |
4515 | + BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_7, 0), |
4516 | + BPF_EXIT_INSN(), |
4517 | + }, |
4518 | + .result = ACCEPT, |
4519 | + .retval = 0, |
4520 | + }, |
4521 | { |
4522 | "unpriv: partial copy of pointer", |
4523 | .insns = { |
4524 | diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h |
4525 | index 6ae3730c4ee3..76d654ef3234 100644 |
4526 | --- a/tools/testing/selftests/kselftest_harness.h |
4527 | +++ b/tools/testing/selftests/kselftest_harness.h |
4528 | @@ -354,7 +354,7 @@ |
4529 | * ASSERT_EQ(expected, measured): expected == measured |
4530 | */ |
4531 | #define ASSERT_EQ(expected, seen) \ |
4532 | - __EXPECT(expected, seen, ==, 1) |
4533 | + __EXPECT(expected, #expected, seen, #seen, ==, 1) |
4534 | |
4535 | /** |
4536 | * ASSERT_NE(expected, seen) |
4537 | @@ -365,7 +365,7 @@ |
4538 | * ASSERT_NE(expected, measured): expected != measured |
4539 | */ |
4540 | #define ASSERT_NE(expected, seen) \ |
4541 | - __EXPECT(expected, seen, !=, 1) |
4542 | + __EXPECT(expected, #expected, seen, #seen, !=, 1) |
4543 | |
4544 | /** |
4545 | * ASSERT_LT(expected, seen) |
4546 | @@ -376,7 +376,7 @@ |
4547 | * ASSERT_LT(expected, measured): expected < measured |
4548 | */ |
4549 | #define ASSERT_LT(expected, seen) \ |
4550 | - __EXPECT(expected, seen, <, 1) |
4551 | + __EXPECT(expected, #expected, seen, #seen, <, 1) |
4552 | |
4553 | /** |
4554 | * ASSERT_LE(expected, seen) |
4555 | @@ -387,7 +387,7 @@ |
4556 | * ASSERT_LE(expected, measured): expected <= measured |
4557 | */ |
4558 | #define ASSERT_LE(expected, seen) \ |
4559 | - __EXPECT(expected, seen, <=, 1) |
4560 | + __EXPECT(expected, #expected, seen, #seen, <=, 1) |
4561 | |
4562 | /** |
4563 | * ASSERT_GT(expected, seen) |
4564 | @@ -398,7 +398,7 @@ |
4565 | * ASSERT_GT(expected, measured): expected > measured |
4566 | */ |
4567 | #define ASSERT_GT(expected, seen) \ |
4568 | - __EXPECT(expected, seen, >, 1) |
4569 | + __EXPECT(expected, #expected, seen, #seen, >, 1) |
4570 | |
4571 | /** |
4572 | * ASSERT_GE(expected, seen) |
4573 | @@ -409,7 +409,7 @@ |
4574 | * ASSERT_GE(expected, measured): expected >= measured |
4575 | */ |
4576 | #define ASSERT_GE(expected, seen) \ |
4577 | - __EXPECT(expected, seen, >=, 1) |
4578 | + __EXPECT(expected, #expected, seen, #seen, >=, 1) |
4579 | |
4580 | /** |
4581 | * ASSERT_NULL(seen) |
4582 | @@ -419,7 +419,7 @@ |
4583 | * ASSERT_NULL(measured): NULL == measured |
4584 | */ |
4585 | #define ASSERT_NULL(seen) \ |
4586 | - __EXPECT(NULL, seen, ==, 1) |
4587 | + __EXPECT(NULL, "NULL", seen, #seen, ==, 1) |
4588 | |
4589 | /** |
4590 | * ASSERT_TRUE(seen) |
4591 | @@ -429,7 +429,7 @@ |
4592 | * ASSERT_TRUE(measured): measured != 0 |
4593 | */ |
4594 | #define ASSERT_TRUE(seen) \ |
4595 | - ASSERT_NE(0, seen) |
4596 | + __EXPECT(0, "0", seen, #seen, !=, 1) |
4597 | |
4598 | /** |
4599 | * ASSERT_FALSE(seen) |
4600 | @@ -439,7 +439,7 @@ |
4601 | * ASSERT_FALSE(measured): measured == 0 |
4602 | */ |
4603 | #define ASSERT_FALSE(seen) \ |
4604 | - ASSERT_EQ(0, seen) |
4605 | + __EXPECT(0, "0", seen, #seen, ==, 1) |
4606 | |
4607 | /** |
4608 | * ASSERT_STREQ(expected, seen) |
4609 | @@ -472,7 +472,7 @@ |
4610 | * EXPECT_EQ(expected, measured): expected == measured |
4611 | */ |
4612 | #define EXPECT_EQ(expected, seen) \ |
4613 | - __EXPECT(expected, seen, ==, 0) |
4614 | + __EXPECT(expected, #expected, seen, #seen, ==, 0) |
4615 | |
4616 | /** |
4617 | * EXPECT_NE(expected, seen) |
4618 | @@ -483,7 +483,7 @@ |
4619 | * EXPECT_NE(expected, measured): expected != measured |
4620 | */ |
4621 | #define EXPECT_NE(expected, seen) \ |
4622 | - __EXPECT(expected, seen, !=, 0) |
4623 | + __EXPECT(expected, #expected, seen, #seen, !=, 0) |
4624 | |
4625 | /** |
4626 | * EXPECT_LT(expected, seen) |
4627 | @@ -494,7 +494,7 @@ |
4628 | * EXPECT_LT(expected, measured): expected < measured |
4629 | */ |
4630 | #define EXPECT_LT(expected, seen) \ |
4631 | - __EXPECT(expected, seen, <, 0) |
4632 | + __EXPECT(expected, #expected, seen, #seen, <, 0) |
4633 | |
4634 | /** |
4635 | * EXPECT_LE(expected, seen) |
4636 | @@ -505,7 +505,7 @@ |
4637 | * EXPECT_LE(expected, measured): expected <= measured |
4638 | */ |
4639 | #define EXPECT_LE(expected, seen) \ |
4640 | - __EXPECT(expected, seen, <=, 0) |
4641 | + __EXPECT(expected, #expected, seen, #seen, <=, 0) |
4642 | |
4643 | /** |
4644 | * EXPECT_GT(expected, seen) |
4645 | @@ -516,7 +516,7 @@ |
4646 | * EXPECT_GT(expected, measured): expected > measured |
4647 | */ |
4648 | #define EXPECT_GT(expected, seen) \ |
4649 | - __EXPECT(expected, seen, >, 0) |
4650 | + __EXPECT(expected, #expected, seen, #seen, >, 0) |
4651 | |
4652 | /** |
4653 | * EXPECT_GE(expected, seen) |
4654 | @@ -527,7 +527,7 @@ |
4655 | * EXPECT_GE(expected, measured): expected >= measured |
4656 | */ |
4657 | #define EXPECT_GE(expected, seen) \ |
4658 | - __EXPECT(expected, seen, >=, 0) |
4659 | + __EXPECT(expected, #expected, seen, #seen, >=, 0) |
4660 | |
4661 | /** |
4662 | * EXPECT_NULL(seen) |
4663 | @@ -537,7 +537,7 @@ |
4664 | * EXPECT_NULL(measured): NULL == measured |
4665 | */ |
4666 | #define EXPECT_NULL(seen) \ |
4667 | - __EXPECT(NULL, seen, ==, 0) |
4668 | + __EXPECT(NULL, "NULL", seen, #seen, ==, 0) |
4669 | |
4670 | /** |
4671 | * EXPECT_TRUE(seen) |
4672 | @@ -547,7 +547,7 @@ |
4673 | * EXPECT_TRUE(measured): 0 != measured |
4674 | */ |
4675 | #define EXPECT_TRUE(seen) \ |
4676 | - EXPECT_NE(0, seen) |
4677 | + __EXPECT(0, "0", seen, #seen, !=, 0) |
4678 | |
4679 | /** |
4680 | * EXPECT_FALSE(seen) |
4681 | @@ -557,7 +557,7 @@ |
4682 | * EXPECT_FALSE(measured): 0 == measured |
4683 | */ |
4684 | #define EXPECT_FALSE(seen) \ |
4685 | - EXPECT_EQ(0, seen) |
4686 | + __EXPECT(0, "0", seen, #seen, ==, 0) |
4687 | |
4688 | /** |
4689 | * EXPECT_STREQ(expected, seen) |
4690 | @@ -597,7 +597,7 @@ |
4691 | if (_metadata->passed && _metadata->step < 255) \ |
4692 | _metadata->step++; |
4693 | |
4694 | -#define __EXPECT(_expected, _seen, _t, _assert) do { \ |
4695 | +#define __EXPECT(_expected, _expected_str, _seen, _seen_str, _t, _assert) do { \ |
4696 | /* Avoid multiple evaluation of the cases */ \ |
4697 | __typeof__(_expected) __exp = (_expected); \ |
4698 | __typeof__(_seen) __seen = (_seen); \ |
4699 | @@ -606,8 +606,8 @@ |
4700 | unsigned long long __exp_print = (uintptr_t)__exp; \ |
4701 | unsigned long long __seen_print = (uintptr_t)__seen; \ |
4702 | __TH_LOG("Expected %s (%llu) %s %s (%llu)", \ |
4703 | - #_expected, __exp_print, #_t, \ |
4704 | - #_seen, __seen_print); \ |
4705 | + _expected_str, __exp_print, #_t, \ |
4706 | + _seen_str, __seen_print); \ |
4707 | _metadata->passed = 0; \ |
4708 | /* Ensure the optional handler is triggered */ \ |
4709 | _metadata->trigger = 1; \ |