Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0103-5.4.4-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3484 - (show annotations) (download)
Mon May 11 14:35:59 2020 UTC (4 years ago) by niro
File size: 216607 byte(s)
-linux-5.4.4
1 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
2 index 9983ac73b66d..f5a551e4332d 100644
3 --- a/Documentation/admin-guide/kernel-parameters.txt
4 +++ b/Documentation/admin-guide/kernel-parameters.txt
5 @@ -5101,13 +5101,13 @@
6 Flags is a set of characters, each corresponding
7 to a common usb-storage quirk flag as follows:
8 a = SANE_SENSE (collect more than 18 bytes
9 - of sense data);
10 + of sense data, not on uas);
11 b = BAD_SENSE (don't collect more than 18
12 - bytes of sense data);
13 + bytes of sense data, not on uas);
14 c = FIX_CAPACITY (decrease the reported
15 device capacity by one sector);
16 d = NO_READ_DISC_INFO (don't use
17 - READ_DISC_INFO command);
18 + READ_DISC_INFO command, not on uas);
19 e = NO_READ_CAPACITY_16 (don't use
20 READ_CAPACITY_16 command);
21 f = NO_REPORT_OPCODES (don't use report opcodes
22 @@ -5122,17 +5122,18 @@
23 j = NO_REPORT_LUNS (don't use report luns
24 command, uas only);
25 l = NOT_LOCKABLE (don't try to lock and
26 - unlock ejectable media);
27 + unlock ejectable media, not on uas);
28 m = MAX_SECTORS_64 (don't transfer more
29 - than 64 sectors = 32 KB at a time);
30 + than 64 sectors = 32 KB at a time,
31 + not on uas);
32 n = INITIAL_READ10 (force a retry of the
33 - initial READ(10) command);
34 + initial READ(10) command, not on uas);
35 o = CAPACITY_OK (accept the capacity
36 - reported by the device);
37 + reported by the device, not on uas);
38 p = WRITE_CACHE (the device cache is ON
39 - by default);
40 + by default, not on uas);
41 r = IGNORE_RESIDUE (the device reports
42 - bogus residue values);
43 + bogus residue values, not on uas);
44 s = SINGLE_LUN (the device has only one
45 Logical Unit);
46 t = NO_ATA_1X (don't allow ATA(12) and ATA(16)
47 @@ -5141,7 +5142,8 @@
48 w = NO_WP_DETECT (don't test whether the
49 medium is write-protected).
50 y = ALWAYS_SYNC (issue a SYNCHRONIZE_CACHE
51 - even if the device claims no cache)
52 + even if the device claims no cache,
53 + not on uas)
54 Example: quirks=0419:aaf5:rl,0421:0433:rc
55
56 user_debug= [KNL,ARM]
57 diff --git a/Makefile b/Makefile
58 index 07998b60d56c..144daf02c78a 100644
59 --- a/Makefile
60 +++ b/Makefile
61 @@ -1,7 +1,7 @@
62 # SPDX-License-Identifier: GPL-2.0
63 VERSION = 5
64 PATCHLEVEL = 4
65 -SUBLEVEL = 3
66 +SUBLEVEL = 4
67 EXTRAVERSION =
68 NAME = Kleptomaniac Octopus
69
70 diff --git a/arch/arm/boot/dts/omap3-pandora-common.dtsi b/arch/arm/boot/dts/omap3-pandora-common.dtsi
71 index ec5891718ae6..150d5be42d27 100644
72 --- a/arch/arm/boot/dts/omap3-pandora-common.dtsi
73 +++ b/arch/arm/boot/dts/omap3-pandora-common.dtsi
74 @@ -226,6 +226,17 @@
75 gpio = <&gpio6 4 GPIO_ACTIVE_HIGH>; /* GPIO_164 */
76 };
77
78 + /* wl1251 wifi+bt module */
79 + wlan_en: fixed-regulator-wg7210_en {
80 + compatible = "regulator-fixed";
81 + regulator-name = "vwlan";
82 + regulator-min-microvolt = <1800000>;
83 + regulator-max-microvolt = <1800000>;
84 + startup-delay-us = <50000>;
85 + enable-active-high;
86 + gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>;
87 + };
88 +
89 /* wg7210 (wifi+bt module) 32k clock buffer */
90 wg7210_32k: fixed-regulator-wg7210_32k {
91 compatible = "regulator-fixed";
92 @@ -522,9 +533,30 @@
93 /*wp-gpios = <&gpio4 31 GPIO_ACTIVE_HIGH>;*/ /* GPIO_127 */
94 };
95
96 -/* mmc3 is probed using pdata-quirks to pass wl1251 card data */
97 &mmc3 {
98 - status = "disabled";
99 + vmmc-supply = <&wlan_en>;
100 +
101 + bus-width = <4>;
102 + non-removable;
103 + ti,non-removable;
104 + cap-power-off-card;
105 +
106 + pinctrl-names = "default";
107 + pinctrl-0 = <&mmc3_pins>;
108 +
109 + #address-cells = <1>;
110 + #size-cells = <0>;
111 +
112 + wlan: wifi@1 {
113 + compatible = "ti,wl1251";
114 +
115 + reg = <1>;
116 +
117 + interrupt-parent = <&gpio1>;
118 + interrupts = <21 IRQ_TYPE_LEVEL_HIGH>; /* GPIO_21 */
119 +
120 + ti,wl1251-has-eeprom;
121 + };
122 };
123
124 /* bluetooth*/
125 diff --git a/arch/arm/boot/dts/omap3-tao3530.dtsi b/arch/arm/boot/dts/omap3-tao3530.dtsi
126 index a7a04d78deeb..f24e2326cfa7 100644
127 --- a/arch/arm/boot/dts/omap3-tao3530.dtsi
128 +++ b/arch/arm/boot/dts/omap3-tao3530.dtsi
129 @@ -222,7 +222,7 @@
130 pinctrl-0 = <&mmc1_pins>;
131 vmmc-supply = <&vmmc1>;
132 vqmmc-supply = <&vsim>;
133 - cd-gpios = <&twl_gpio 0 GPIO_ACTIVE_HIGH>;
134 + cd-gpios = <&twl_gpio 0 GPIO_ACTIVE_LOW>;
135 bus-width = <8>;
136 };
137
138 diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
139 index 2efd18e8824c..1b7cf81ff035 100644
140 --- a/arch/arm/mach-omap2/pdata-quirks.c
141 +++ b/arch/arm/mach-omap2/pdata-quirks.c
142 @@ -7,7 +7,6 @@
143 #include <linux/clk.h>
144 #include <linux/davinci_emac.h>
145 #include <linux/gpio.h>
146 -#include <linux/gpio/machine.h>
147 #include <linux/init.h>
148 #include <linux/kernel.h>
149 #include <linux/of_platform.h>
150 @@ -311,118 +310,15 @@ static void __init omap3_logicpd_torpedo_init(void)
151 }
152
153 /* omap3pandora legacy devices */
154 -#define PANDORA_WIFI_IRQ_GPIO 21
155 -#define PANDORA_WIFI_NRESET_GPIO 23
156
157 static struct platform_device pandora_backlight = {
158 .name = "pandora-backlight",
159 .id = -1,
160 };
161
162 -static struct regulator_consumer_supply pandora_vmmc3_supply[] = {
163 - REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
164 -};
165 -
166 -static struct regulator_init_data pandora_vmmc3 = {
167 - .constraints = {
168 - .valid_ops_mask = REGULATOR_CHANGE_STATUS,
169 - },
170 - .num_consumer_supplies = ARRAY_SIZE(pandora_vmmc3_supply),
171 - .consumer_supplies = pandora_vmmc3_supply,
172 -};
173 -
174 -static struct fixed_voltage_config pandora_vwlan = {
175 - .supply_name = "vwlan",
176 - .microvolts = 1800000, /* 1.8V */
177 - .startup_delay = 50000, /* 50ms */
178 - .init_data = &pandora_vmmc3,
179 -};
180 -
181 -static struct platform_device pandora_vwlan_device = {
182 - .name = "reg-fixed-voltage",
183 - .id = 1,
184 - .dev = {
185 - .platform_data = &pandora_vwlan,
186 - },
187 -};
188 -
189 -static struct gpiod_lookup_table pandora_vwlan_gpiod_table = {
190 - .dev_id = "reg-fixed-voltage.1",
191 - .table = {
192 - /*
193 - * As this is a low GPIO number it should be at the first
194 - * GPIO bank.
195 - */
196 - GPIO_LOOKUP("gpio-0-31", PANDORA_WIFI_NRESET_GPIO,
197 - NULL, GPIO_ACTIVE_HIGH),
198 - { },
199 - },
200 -};
201 -
202 -static void pandora_wl1251_init_card(struct mmc_card *card)
203 -{
204 - /*
205 - * We have TI wl1251 attached to MMC3. Pass this information to
206 - * SDIO core because it can't be probed by normal methods.
207 - */
208 - if (card->type == MMC_TYPE_SDIO || card->type == MMC_TYPE_SD_COMBO) {
209 - card->quirks |= MMC_QUIRK_NONSTD_SDIO;
210 - card->cccr.wide_bus = 1;
211 - card->cis.vendor = 0x104c;
212 - card->cis.device = 0x9066;
213 - card->cis.blksize = 512;
214 - card->cis.max_dtr = 24000000;
215 - card->ocr = 0x80;
216 - }
217 -}
218 -
219 -static struct omap2_hsmmc_info pandora_mmc3[] = {
220 - {
221 - .mmc = 3,
222 - .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
223 - .init_card = pandora_wl1251_init_card,
224 - },
225 - {} /* Terminator */
226 -};
227 -
228 -static void __init pandora_wl1251_init(void)
229 -{
230 - struct wl1251_platform_data pandora_wl1251_pdata;
231 - int ret;
232 -
233 - memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
234 -
235 - pandora_wl1251_pdata.power_gpio = -1;
236 -
237 - ret = gpio_request_one(PANDORA_WIFI_IRQ_GPIO, GPIOF_IN, "wl1251 irq");
238 - if (ret < 0)
239 - goto fail;
240 -
241 - pandora_wl1251_pdata.irq = gpio_to_irq(PANDORA_WIFI_IRQ_GPIO);
242 - if (pandora_wl1251_pdata.irq < 0)
243 - goto fail_irq;
244 -
245 - pandora_wl1251_pdata.use_eeprom = true;
246 - ret = wl1251_set_platform_data(&pandora_wl1251_pdata);
247 - if (ret < 0)
248 - goto fail_irq;
249 -
250 - return;
251 -
252 -fail_irq:
253 - gpio_free(PANDORA_WIFI_IRQ_GPIO);
254 -fail:
255 - pr_err("wl1251 board initialisation failed\n");
256 -}
257 -
258 static void __init omap3_pandora_legacy_init(void)
259 {
260 platform_device_register(&pandora_backlight);
261 - gpiod_add_lookup_table(&pandora_vwlan_gpiod_table);
262 - platform_device_register(&pandora_vwlan_device);
263 - omap_hsmmc_init(pandora_mmc3);
264 - omap_hsmmc_late_init(pandora_mmc3);
265 - pandora_wl1251_init();
266 }
267 #endif /* CONFIG_ARCH_OMAP3 */
268
269 diff --git a/arch/powerpc/include/asm/sections.h b/arch/powerpc/include/asm/sections.h
270 index 5a9b6eb651b6..d19871763ed4 100644
271 --- a/arch/powerpc/include/asm/sections.h
272 +++ b/arch/powerpc/include/asm/sections.h
273 @@ -5,8 +5,22 @@
274
275 #include <linux/elf.h>
276 #include <linux/uaccess.h>
277 +
278 +#define arch_is_kernel_initmem_freed arch_is_kernel_initmem_freed
279 +
280 #include <asm-generic/sections.h>
281
282 +extern bool init_mem_is_free;
283 +
284 +static inline int arch_is_kernel_initmem_freed(unsigned long addr)
285 +{
286 + if (!init_mem_is_free)
287 + return 0;
288 +
289 + return addr >= (unsigned long)__init_begin &&
290 + addr < (unsigned long)__init_end;
291 +}
292 +
293 extern char __head_end[];
294
295 #ifdef __powerpc64__
296 diff --git a/arch/powerpc/include/asm/vdso_datapage.h b/arch/powerpc/include/asm/vdso_datapage.h
297 index c61d59ed3b45..2ccb938d8544 100644
298 --- a/arch/powerpc/include/asm/vdso_datapage.h
299 +++ b/arch/powerpc/include/asm/vdso_datapage.h
300 @@ -82,6 +82,7 @@ struct vdso_data {
301 __s32 wtom_clock_nsec; /* Wall to monotonic clock nsec */
302 __s64 wtom_clock_sec; /* Wall to monotonic clock sec */
303 struct timespec stamp_xtime; /* xtime as at tb_orig_stamp */
304 + __u32 hrtimer_res; /* hrtimer resolution */
305 __u32 syscall_map_64[SYSCALL_MAP_SIZE]; /* map of syscalls */
306 __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */
307 };
308 @@ -103,6 +104,7 @@ struct vdso_data {
309 __s32 wtom_clock_nsec;
310 struct timespec stamp_xtime; /* xtime as at tb_orig_stamp */
311 __u32 stamp_sec_fraction; /* fractional seconds of stamp_xtime */
312 + __u32 hrtimer_res; /* hrtimer resolution */
313 __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */
314 __u32 dcache_block_size; /* L1 d-cache block size */
315 __u32 icache_block_size; /* L1 i-cache block size */
316 diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
317 index a7ca8fe62368..3c02445cf086 100644
318 --- a/arch/powerpc/kernel/Makefile
319 +++ b/arch/powerpc/kernel/Makefile
320 @@ -5,8 +5,8 @@
321
322 CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
323
324 -# Disable clang warning for using setjmp without setjmp.h header
325 -CFLAGS_crash.o += $(call cc-disable-warning, builtin-requires-header)
326 +# Avoid clang warnings around longjmp/setjmp declarations
327 +CFLAGS_crash.o += -ffreestanding
328
329 ifdef CONFIG_PPC64
330 CFLAGS_prom_init.o += $(NO_MINIMAL_TOC)
331 diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
332 index 484f54dab247..5c0a1e17219b 100644
333 --- a/arch/powerpc/kernel/asm-offsets.c
334 +++ b/arch/powerpc/kernel/asm-offsets.c
335 @@ -387,6 +387,7 @@ int main(void)
336 OFFSET(WTOM_CLOCK_NSEC, vdso_data, wtom_clock_nsec);
337 OFFSET(STAMP_XTIME, vdso_data, stamp_xtime);
338 OFFSET(STAMP_SEC_FRAC, vdso_data, stamp_sec_fraction);
339 + OFFSET(CLOCK_HRTIMER_RES, vdso_data, hrtimer_res);
340 OFFSET(CFG_ICACHE_BLOCKSZ, vdso_data, icache_block_size);
341 OFFSET(CFG_DCACHE_BLOCKSZ, vdso_data, dcache_block_size);
342 OFFSET(CFG_ICACHE_LOGBLOCKSZ, vdso_data, icache_log_block_size);
343 @@ -417,7 +418,6 @@ int main(void)
344 DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
345 DEFINE(CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE);
346 DEFINE(NSEC_PER_SEC, NSEC_PER_SEC);
347 - DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
348
349 #ifdef CONFIG_BUG
350 DEFINE(BUG_ENTRY_SIZE, sizeof(struct bug_entry));
351 diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
352 index b55a7b4cb543..9bc0aa9aeb65 100644
353 --- a/arch/powerpc/kernel/misc_64.S
354 +++ b/arch/powerpc/kernel/misc_64.S
355 @@ -82,7 +82,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
356 subf r8,r6,r4 /* compute length */
357 add r8,r8,r5 /* ensure we get enough */
358 lwz r9,DCACHEL1LOGBLOCKSIZE(r10) /* Get log-2 of cache block size */
359 - srw. r8,r8,r9 /* compute line count */
360 + srd. r8,r8,r9 /* compute line count */
361 beqlr /* nothing to do? */
362 mtctr r8
363 1: dcbst 0,r6
364 @@ -98,7 +98,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
365 subf r8,r6,r4 /* compute length */
366 add r8,r8,r5
367 lwz r9,ICACHEL1LOGBLOCKSIZE(r10) /* Get log-2 of Icache block size */
368 - srw. r8,r8,r9 /* compute line count */
369 + srd. r8,r8,r9 /* compute line count */
370 beqlr /* nothing to do? */
371 mtctr r8
372 2: icbi 0,r6
373 diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
374 index 694522308cd5..619447b1b797 100644
375 --- a/arch/powerpc/kernel/time.c
376 +++ b/arch/powerpc/kernel/time.c
377 @@ -959,6 +959,7 @@ void update_vsyscall(struct timekeeper *tk)
378 vdso_data->wtom_clock_nsec = tk->wall_to_monotonic.tv_nsec;
379 vdso_data->stamp_xtime = xt;
380 vdso_data->stamp_sec_fraction = frac_sec;
381 + vdso_data->hrtimer_res = hrtimer_resolution;
382 smp_wmb();
383 ++(vdso_data->tb_update_count);
384 }
385 diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S
386 index becd9f8767ed..a967e795b96d 100644
387 --- a/arch/powerpc/kernel/vdso32/gettimeofday.S
388 +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S
389 @@ -156,12 +156,15 @@ V_FUNCTION_BEGIN(__kernel_clock_getres)
390 cror cr0*4+eq,cr0*4+eq,cr1*4+eq
391 bne cr0,99f
392
393 + mflr r12
394 + .cfi_register lr,r12
395 + bl __get_datapage@local /* get data page */
396 + lwz r5, CLOCK_HRTIMER_RES(r3)
397 + mtlr r12
398 li r3,0
399 cmpli cr0,r4,0
400 crclr cr0*4+so
401 beqlr
402 - lis r5,CLOCK_REALTIME_RES@h
403 - ori r5,r5,CLOCK_REALTIME_RES@l
404 stw r3,TSPC32_TV_SEC(r4)
405 stw r5,TSPC32_TV_NSEC(r4)
406 blr
407 diff --git a/arch/powerpc/kernel/vdso64/cacheflush.S b/arch/powerpc/kernel/vdso64/cacheflush.S
408 index 3f92561a64c4..526f5ba2593e 100644
409 --- a/arch/powerpc/kernel/vdso64/cacheflush.S
410 +++ b/arch/powerpc/kernel/vdso64/cacheflush.S
411 @@ -35,7 +35,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache)
412 subf r8,r6,r4 /* compute length */
413 add r8,r8,r5 /* ensure we get enough */
414 lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10)
415 - srw. r8,r8,r9 /* compute line count */
416 + srd. r8,r8,r9 /* compute line count */
417 crclr cr0*4+so
418 beqlr /* nothing to do? */
419 mtctr r8
420 @@ -52,7 +52,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache)
421 subf r8,r6,r4 /* compute length */
422 add r8,r8,r5
423 lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10)
424 - srw. r8,r8,r9 /* compute line count */
425 + srd. r8,r8,r9 /* compute line count */
426 crclr cr0*4+so
427 beqlr /* nothing to do? */
428 mtctr r8
429 diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
430 index 07bfe33fe874..81757f06bbd7 100644
431 --- a/arch/powerpc/kernel/vdso64/gettimeofday.S
432 +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
433 @@ -186,12 +186,15 @@ V_FUNCTION_BEGIN(__kernel_clock_getres)
434 cror cr0*4+eq,cr0*4+eq,cr1*4+eq
435 bne cr0,99f
436
437 + mflr r12
438 + .cfi_register lr,r12
439 + bl V_LOCAL_FUNC(__get_datapage)
440 + lwz r5, CLOCK_HRTIMER_RES(r3)
441 + mtlr r12
442 li r3,0
443 cmpldi cr0,r4,0
444 crclr cr0*4+so
445 beqlr
446 - lis r5,CLOCK_REALTIME_RES@h
447 - ori r5,r5,CLOCK_REALTIME_RES@l
448 std r3,TSPC64_TV_SEC(r4)
449 std r5,TSPC64_TV_NSEC(r4)
450 blr
451 diff --git a/arch/powerpc/platforms/powernv/opal-imc.c b/arch/powerpc/platforms/powernv/opal-imc.c
452 index e04b20625cb9..7ccc5c85c74e 100644
453 --- a/arch/powerpc/platforms/powernv/opal-imc.c
454 +++ b/arch/powerpc/platforms/powernv/opal-imc.c
455 @@ -285,7 +285,14 @@ static int opal_imc_counters_probe(struct platform_device *pdev)
456 domain = IMC_DOMAIN_THREAD;
457 break;
458 case IMC_TYPE_TRACE:
459 - domain = IMC_DOMAIN_TRACE;
460 + /*
461 + * FIXME. Using trace_imc events to monitor application
462 + * or KVM thread performance can cause a checkstop
463 + * (system crash).
464 + * Disable it for now.
465 + */
466 + pr_info_once("IMC: disabling trace_imc PMU\n");
467 + domain = -1;
468 break;
469 default:
470 pr_warn("IMC Unknown Device type \n");
471 diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
472 index df832b09e3e9..f5fadbd2533a 100644
473 --- a/arch/powerpc/sysdev/xive/common.c
474 +++ b/arch/powerpc/sysdev/xive/common.c
475 @@ -1035,6 +1035,15 @@ static int xive_irq_alloc_data(unsigned int virq, irq_hw_number_t hw)
476 xd->target = XIVE_INVALID_TARGET;
477 irq_set_handler_data(virq, xd);
478
479 + /*
480 + * Turn OFF by default the interrupt being mapped. A side
481 + * effect of this check is the mapping the ESB page of the
482 + * interrupt in the Linux address space. This prevents page
483 + * fault issues in the crash handler which masks all
484 + * interrupts.
485 + */
486 + xive_esb_read(xd, XIVE_ESB_SET_PQ_01);
487 +
488 return 0;
489 }
490
491 diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c
492 index 33c10749edec..55dc61cb4867 100644
493 --- a/arch/powerpc/sysdev/xive/spapr.c
494 +++ b/arch/powerpc/sysdev/xive/spapr.c
495 @@ -392,20 +392,28 @@ static int xive_spapr_populate_irq_data(u32 hw_irq, struct xive_irq_data *data)
496 data->esb_shift = esb_shift;
497 data->trig_page = trig_page;
498
499 + data->hw_irq = hw_irq;
500 +
501 /*
502 * No chip-id for the sPAPR backend. This has an impact how we
503 * pick a target. See xive_pick_irq_target().
504 */
505 data->src_chip = XIVE_INVALID_CHIP_ID;
506
507 + /*
508 + * When the H_INT_ESB flag is set, the H_INT_ESB hcall should
509 + * be used for interrupt management. Skip the remapping of the
510 + * ESB pages which are not available.
511 + */
512 + if (data->flags & XIVE_IRQ_FLAG_H_INT_ESB)
513 + return 0;
514 +
515 data->eoi_mmio = ioremap(data->eoi_page, 1u << data->esb_shift);
516 if (!data->eoi_mmio) {
517 pr_err("Failed to map EOI page for irq 0x%x\n", hw_irq);
518 return -ENOMEM;
519 }
520
521 - data->hw_irq = hw_irq;
522 -
523 /* Full function page supports trigger */
524 if (flags & XIVE_SRC_TRIGGER) {
525 data->trig_mmio = data->eoi_mmio;
526 diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile
527 index f142570ad860..c3842dbeb1b7 100644
528 --- a/arch/powerpc/xmon/Makefile
529 +++ b/arch/powerpc/xmon/Makefile
530 @@ -1,8 +1,8 @@
531 # SPDX-License-Identifier: GPL-2.0
532 # Makefile for xmon
533
534 -# Disable clang warning for using setjmp without setjmp.h header
535 -subdir-ccflags-y := $(call cc-disable-warning, builtin-requires-header)
536 +# Avoid clang warnings around longjmp/setjmp declarations
537 +subdir-ccflags-y := -ffreestanding
538
539 GCOV_PROFILE := n
540 KCOV_INSTRUMENT := n
541 diff --git a/arch/s390/boot/startup.c b/arch/s390/boot/startup.c
542 index 5367950510f6..fa0150285d38 100644
543 --- a/arch/s390/boot/startup.c
544 +++ b/arch/s390/boot/startup.c
545 @@ -170,6 +170,11 @@ void startup_kernel(void)
546 handle_relocs(__kaslr_offset);
547
548 if (__kaslr_offset) {
549 + /*
550 + * Save KASLR offset for early dumps, before vmcore_info is set.
551 + * Mark as uneven to distinguish from real vmcore_info pointer.
552 + */
553 + S390_lowcore.vmcore_info = __kaslr_offset | 0x1UL;
554 /* Clear non-relocated kernel */
555 if (IS_ENABLED(CONFIG_KERNEL_UNCOMPRESSED))
556 memset(img, 0, vmlinux.image_size);
557 diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
558 index 5ff98d76a66c..a9e46b83c536 100644
559 --- a/arch/s390/include/asm/pgtable.h
560 +++ b/arch/s390/include/asm/pgtable.h
561 @@ -1173,8 +1173,6 @@ void gmap_pmdp_idte_global(struct mm_struct *mm, unsigned long vmaddr);
562 static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
563 pte_t *ptep, pte_t entry)
564 {
565 - if (!MACHINE_HAS_NX)
566 - pte_val(entry) &= ~_PAGE_NOEXEC;
567 if (pte_present(entry))
568 pte_val(entry) &= ~_PAGE_UNUSED;
569 if (mm_has_pgste(mm))
570 @@ -1191,6 +1189,8 @@ static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)
571 {
572 pte_t __pte;
573 pte_val(__pte) = physpage + pgprot_val(pgprot);
574 + if (!MACHINE_HAS_NX)
575 + pte_val(__pte) &= ~_PAGE_NOEXEC;
576 return pte_mkyoung(__pte);
577 }
578
579 diff --git a/arch/s390/kernel/machine_kexec.c b/arch/s390/kernel/machine_kexec.c
580 index 444a19125a81..d402ced7f7c3 100644
581 --- a/arch/s390/kernel/machine_kexec.c
582 +++ b/arch/s390/kernel/machine_kexec.c
583 @@ -254,10 +254,10 @@ void arch_crash_save_vmcoreinfo(void)
584 VMCOREINFO_SYMBOL(lowcore_ptr);
585 VMCOREINFO_SYMBOL(high_memory);
586 VMCOREINFO_LENGTH(lowcore_ptr, NR_CPUS);
587 - mem_assign_absolute(S390_lowcore.vmcore_info, paddr_vmcoreinfo_note());
588 vmcoreinfo_append_str("SDMA=%lx\n", __sdma);
589 vmcoreinfo_append_str("EDMA=%lx\n", __edma);
590 vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset());
591 + mem_assign_absolute(S390_lowcore.vmcore_info, paddr_vmcoreinfo_note());
592 }
593
594 void machine_shutdown(void)
595 diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
596 index 44974654cbd0..d95c85780e07 100644
597 --- a/arch/s390/kernel/smp.c
598 +++ b/arch/s390/kernel/smp.c
599 @@ -262,10 +262,13 @@ static void pcpu_prepare_secondary(struct pcpu *pcpu, int cpu)
600 lc->spinlock_index = 0;
601 lc->percpu_offset = __per_cpu_offset[cpu];
602 lc->kernel_asce = S390_lowcore.kernel_asce;
603 + lc->user_asce = S390_lowcore.kernel_asce;
604 lc->machine_flags = S390_lowcore.machine_flags;
605 lc->user_timer = lc->system_timer =
606 lc->steal_timer = lc->avg_steal_timer = 0;
607 __ctl_store(lc->cregs_save_area, 0, 15);
608 + lc->cregs_save_area[1] = lc->kernel_asce;
609 + lc->cregs_save_area[7] = lc->vdso_asce;
610 save_access_regs((unsigned int *) lc->access_regs_save_area);
611 memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list,
612 sizeof(lc->stfle_fac_list));
613 @@ -816,6 +819,8 @@ static void smp_init_secondary(void)
614
615 S390_lowcore.last_update_clock = get_tod_clock();
616 restore_access_regs(S390_lowcore.access_regs_save_area);
617 + set_cpu_flag(CIF_ASCE_PRIMARY);
618 + set_cpu_flag(CIF_ASCE_SECONDARY);
619 cpu_init();
620 preempt_disable();
621 init_cpu_timer();
622 diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
623 index a0d3ce30fa08..a09ab0c3d074 100644
624 --- a/block/blk-mq-sysfs.c
625 +++ b/block/blk-mq-sysfs.c
626 @@ -166,20 +166,25 @@ static ssize_t blk_mq_hw_sysfs_nr_reserved_tags_show(struct blk_mq_hw_ctx *hctx,
627
628 static ssize_t blk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page)
629 {
630 + const size_t size = PAGE_SIZE - 1;
631 unsigned int i, first = 1;
632 - ssize_t ret = 0;
633 + int ret = 0, pos = 0;
634
635 for_each_cpu(i, hctx->cpumask) {
636 if (first)
637 - ret += sprintf(ret + page, "%u", i);
638 + ret = snprintf(pos + page, size - pos, "%u", i);
639 else
640 - ret += sprintf(ret + page, ", %u", i);
641 + ret = snprintf(pos + page, size - pos, ", %u", i);
642 +
643 + if (ret >= size - pos)
644 + break;
645
646 first = 0;
647 + pos += ret;
648 }
649
650 - ret += sprintf(ret + page, "\n");
651 - return ret;
652 + ret = snprintf(pos + page, size + 1 - pos, "\n");
653 + return pos + ret;
654 }
655
656 static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_tags = {
657 diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
658 index 60bbc5090abe..751ed38f2a10 100644
659 --- a/drivers/acpi/acpi_lpss.c
660 +++ b/drivers/acpi/acpi_lpss.c
661 @@ -10,6 +10,7 @@
662 #include <linux/acpi.h>
663 #include <linux/clkdev.h>
664 #include <linux/clk-provider.h>
665 +#include <linux/dmi.h>
666 #include <linux/err.h>
667 #include <linux/io.h>
668 #include <linux/mutex.h>
669 @@ -463,6 +464,18 @@ struct lpss_device_links {
670 const char *consumer_hid;
671 const char *consumer_uid;
672 u32 flags;
673 + const struct dmi_system_id *dep_missing_ids;
674 +};
675 +
676 +/* Please keep this list sorted alphabetically by vendor and model */
677 +static const struct dmi_system_id i2c1_dep_missing_dmi_ids[] = {
678 + {
679 + .matches = {
680 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
681 + DMI_MATCH(DMI_PRODUCT_NAME, "T200TA"),
682 + },
683 + },
684 + {}
685 };
686
687 /*
688 @@ -473,9 +486,17 @@ struct lpss_device_links {
689 * the supplier is not enumerated until after the consumer is probed.
690 */
691 static const struct lpss_device_links lpss_device_links[] = {
692 + /* CHT External sdcard slot controller depends on PMIC I2C ctrl */
693 {"808622C1", "7", "80860F14", "3", DL_FLAG_PM_RUNTIME},
694 + /* CHT iGPU depends on PMIC I2C controller */
695 {"808622C1", "7", "LNXVIDEO", NULL, DL_FLAG_PM_RUNTIME},
696 + /* BYT iGPU depends on the Embedded Controller I2C controller (UID 1) */
697 + {"80860F41", "1", "LNXVIDEO", NULL, DL_FLAG_PM_RUNTIME,
698 + i2c1_dep_missing_dmi_ids},
699 + /* BYT CR iGPU depends on PMIC I2C controller (UID 5 on CR) */
700 {"80860F41", "5", "LNXVIDEO", NULL, DL_FLAG_PM_RUNTIME},
701 + /* BYT iGPU depends on PMIC I2C controller (UID 7 on non CR) */
702 + {"80860F41", "7", "LNXVIDEO", NULL, DL_FLAG_PM_RUNTIME},
703 };
704
705 static bool hid_uid_match(struct acpi_device *adev,
706 @@ -570,7 +591,8 @@ static void acpi_lpss_link_consumer(struct device *dev1,
707 if (!dev2)
708 return;
709
710 - if (acpi_lpss_dep(ACPI_COMPANION(dev2), ACPI_HANDLE(dev1)))
711 + if ((link->dep_missing_ids && dmi_check_system(link->dep_missing_ids))
712 + || acpi_lpss_dep(ACPI_COMPANION(dev2), ACPI_HANDLE(dev1)))
713 device_link_add(dev2, dev1, link->flags);
714
715 put_device(dev2);
716 @@ -585,7 +607,8 @@ static void acpi_lpss_link_supplier(struct device *dev1,
717 if (!dev2)
718 return;
719
720 - if (acpi_lpss_dep(ACPI_COMPANION(dev1), ACPI_HANDLE(dev2)))
721 + if ((link->dep_missing_ids && dmi_check_system(link->dep_missing_ids))
722 + || acpi_lpss_dep(ACPI_COMPANION(dev1), ACPI_HANDLE(dev2)))
723 device_link_add(dev1, dev2, link->flags);
724
725 put_device(dev2);
726 diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
727 index 48bc96d45bab..54002670cb7a 100644
728 --- a/drivers/acpi/bus.c
729 +++ b/drivers/acpi/bus.c
730 @@ -153,7 +153,7 @@ int acpi_bus_get_private_data(acpi_handle handle, void **data)
731 {
732 acpi_status status;
733
734 - if (!*data)
735 + if (!data)
736 return -EINVAL;
737
738 status = acpi_get_data(handle, acpi_bus_private_data_handler, data);
739 diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
740 index 08bb9f2f2d23..5e4a8860a9c0 100644
741 --- a/drivers/acpi/device_pm.c
742 +++ b/drivers/acpi/device_pm.c
743 @@ -1314,9 +1314,19 @@ static void acpi_dev_pm_detach(struct device *dev, bool power_off)
744 */
745 int acpi_dev_pm_attach(struct device *dev, bool power_on)
746 {
747 + /*
748 + * Skip devices whose ACPI companions match the device IDs below,
749 + * because they require special power management handling incompatible
750 + * with the generic ACPI PM domain.
751 + */
752 + static const struct acpi_device_id special_pm_ids[] = {
753 + {"PNP0C0B", }, /* Generic ACPI fan */
754 + {"INT3404", }, /* Fan */
755 + {}
756 + };
757 struct acpi_device *adev = ACPI_COMPANION(dev);
758
759 - if (!adev)
760 + if (!adev || !acpi_match_device_ids(adev, special_pm_ids))
761 return 0;
762
763 /*
764 diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
765 index da1e5c5ce150..bd75caff8322 100644
766 --- a/drivers/acpi/ec.c
767 +++ b/drivers/acpi/ec.c
768 @@ -525,26 +525,10 @@ static void acpi_ec_enable_event(struct acpi_ec *ec)
769 }
770
771 #ifdef CONFIG_PM_SLEEP
772 -static bool acpi_ec_query_flushed(struct acpi_ec *ec)
773 +static void __acpi_ec_flush_work(void)
774 {
775 - bool flushed;
776 - unsigned long flags;
777 -
778 - spin_lock_irqsave(&ec->lock, flags);
779 - flushed = !ec->nr_pending_queries;
780 - spin_unlock_irqrestore(&ec->lock, flags);
781 - return flushed;
782 -}
783 -
784 -static void __acpi_ec_flush_event(struct acpi_ec *ec)
785 -{
786 - /*
787 - * When ec_freeze_events is true, we need to flush events in
788 - * the proper position before entering the noirq stage.
789 - */
790 - wait_event(ec->wait, acpi_ec_query_flushed(ec));
791 - if (ec_query_wq)
792 - flush_workqueue(ec_query_wq);
793 + flush_scheduled_work(); /* flush ec->work */
794 + flush_workqueue(ec_query_wq); /* flush queries */
795 }
796
797 static void acpi_ec_disable_event(struct acpi_ec *ec)
798 @@ -554,15 +538,21 @@ static void acpi_ec_disable_event(struct acpi_ec *ec)
799 spin_lock_irqsave(&ec->lock, flags);
800 __acpi_ec_disable_event(ec);
801 spin_unlock_irqrestore(&ec->lock, flags);
802 - __acpi_ec_flush_event(ec);
803 +
804 + /*
805 + * When ec_freeze_events is true, we need to flush events in
806 + * the proper position before entering the noirq stage.
807 + */
808 + __acpi_ec_flush_work();
809 }
810
811 void acpi_ec_flush_work(void)
812 {
813 - if (first_ec)
814 - __acpi_ec_flush_event(first_ec);
815 + /* Without ec_query_wq there is nothing to flush. */
816 + if (!ec_query_wq)
817 + return;
818
819 - flush_scheduled_work();
820 + __acpi_ec_flush_work();
821 }
822 #endif /* CONFIG_PM_SLEEP */
823
824 diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
825 index a2e844a8e9ed..41168c027a5a 100644
826 --- a/drivers/acpi/osl.c
827 +++ b/drivers/acpi/osl.c
828 @@ -374,19 +374,21 @@ void *__ref acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
829 }
830 EXPORT_SYMBOL_GPL(acpi_os_map_memory);
831
832 -static void acpi_os_drop_map_ref(struct acpi_ioremap *map)
833 +/* Must be called with mutex_lock(&acpi_ioremap_lock) */
834 +static unsigned long acpi_os_drop_map_ref(struct acpi_ioremap *map)
835 {
836 - if (!--map->refcount)
837 + unsigned long refcount = --map->refcount;
838 +
839 + if (!refcount)
840 list_del_rcu(&map->list);
841 + return refcount;
842 }
843
844 static void acpi_os_map_cleanup(struct acpi_ioremap *map)
845 {
846 - if (!map->refcount) {
847 - synchronize_rcu_expedited();
848 - acpi_unmap(map->phys, map->virt);
849 - kfree(map);
850 - }
851 + synchronize_rcu_expedited();
852 + acpi_unmap(map->phys, map->virt);
853 + kfree(map);
854 }
855
856 /**
857 @@ -406,6 +408,7 @@ static void acpi_os_map_cleanup(struct acpi_ioremap *map)
858 void __ref acpi_os_unmap_iomem(void __iomem *virt, acpi_size size)
859 {
860 struct acpi_ioremap *map;
861 + unsigned long refcount;
862
863 if (!acpi_permanent_mmap) {
864 __acpi_unmap_table(virt, size);
865 @@ -419,10 +422,11 @@ void __ref acpi_os_unmap_iomem(void __iomem *virt, acpi_size size)
866 WARN(true, PREFIX "%s: bad address %p\n", __func__, virt);
867 return;
868 }
869 - acpi_os_drop_map_ref(map);
870 + refcount = acpi_os_drop_map_ref(map);
871 mutex_unlock(&acpi_ioremap_lock);
872
873 - acpi_os_map_cleanup(map);
874 + if (!refcount)
875 + acpi_os_map_cleanup(map);
876 }
877 EXPORT_SYMBOL_GPL(acpi_os_unmap_iomem);
878
879 @@ -457,6 +461,7 @@ void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
880 {
881 u64 addr;
882 struct acpi_ioremap *map;
883 + unsigned long refcount;
884
885 if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
886 return;
887 @@ -472,10 +477,11 @@ void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
888 mutex_unlock(&acpi_ioremap_lock);
889 return;
890 }
891 - acpi_os_drop_map_ref(map);
892 + refcount = acpi_os_drop_map_ref(map);
893 mutex_unlock(&acpi_ioremap_lock);
894
895 - acpi_os_map_cleanup(map);
896 + if (!refcount)
897 + acpi_os_map_cleanup(map);
898 }
899 EXPORT_SYMBOL(acpi_os_unmap_generic_address);
900
901 diff --git a/drivers/android/binder.c b/drivers/android/binder.c
902 index 265d9dd46a5e..976a69420c16 100644
903 --- a/drivers/android/binder.c
904 +++ b/drivers/android/binder.c
905 @@ -3314,7 +3314,7 @@ static void binder_transaction(struct binder_proc *proc,
906 binder_size_t parent_offset;
907 struct binder_fd_array_object *fda =
908 to_binder_fd_array_object(hdr);
909 - size_t num_valid = (buffer_offset - off_start_offset) *
910 + size_t num_valid = (buffer_offset - off_start_offset) /
911 sizeof(binder_size_t);
912 struct binder_buffer_object *parent =
913 binder_validate_ptr(target_proc, t->buffer,
914 @@ -3388,7 +3388,7 @@ static void binder_transaction(struct binder_proc *proc,
915 t->buffer->user_data + sg_buf_offset;
916 sg_buf_offset += ALIGN(bp->length, sizeof(u64));
917
918 - num_valid = (buffer_offset - off_start_offset) *
919 + num_valid = (buffer_offset - off_start_offset) /
920 sizeof(binder_size_t);
921 ret = binder_fixup_parent(t, thread, bp,
922 off_start_offset,
923 diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
924 index b27f39688b5e..e329f82c0467 100644
925 --- a/drivers/char/hw_random/omap-rng.c
926 +++ b/drivers/char/hw_random/omap-rng.c
927 @@ -66,6 +66,13 @@
928 #define OMAP4_RNG_OUTPUT_SIZE 0x8
929 #define EIP76_RNG_OUTPUT_SIZE 0x10
930
931 +/*
932 + * EIP76 RNG takes approx. 700us to produce 16 bytes of output data
933 + * as per testing results. And to account for the lack of udelay()'s
934 + * reliability, we keep the timeout as 1000us.
935 + */
936 +#define RNG_DATA_FILL_TIMEOUT 100
937 +
938 enum {
939 RNG_OUTPUT_0_REG = 0,
940 RNG_OUTPUT_1_REG,
941 @@ -176,7 +183,7 @@ static int omap_rng_do_read(struct hwrng *rng, void *data, size_t max,
942 if (max < priv->pdata->data_size)
943 return 0;
944
945 - for (i = 0; i < 20; i++) {
946 + for (i = 0; i < RNG_DATA_FILL_TIMEOUT; i++) {
947 present = priv->pdata->data_present(priv);
948 if (present || !wait)
949 break;
950 diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
951 index c86f18aa8985..34bb88fe0b0a 100644
952 --- a/drivers/char/ppdev.c
953 +++ b/drivers/char/ppdev.c
954 @@ -619,20 +619,27 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
955 if (copy_from_user(time32, argp, sizeof(time32)))
956 return -EFAULT;
957
958 + if ((time32[0] < 0) || (time32[1] < 0))
959 + return -EINVAL;
960 +
961 return pp_set_timeout(pp->pdev, time32[0], time32[1]);
962
963 case PPSETTIME64:
964 if (copy_from_user(time64, argp, sizeof(time64)))
965 return -EFAULT;
966
967 + if ((time64[0] < 0) || (time64[1] < 0))
968 + return -EINVAL;
969 +
970 + if (IS_ENABLED(CONFIG_SPARC64) && !in_compat_syscall())
971 + time64[1] >>= 32;
972 +
973 return pp_set_timeout(pp->pdev, time64[0], time64[1]);
974
975 case PPGETTIME32:
976 jiffies_to_timespec64(pp->pdev->timeout, &ts);
977 time32[0] = ts.tv_sec;
978 time32[1] = ts.tv_nsec / NSEC_PER_USEC;
979 - if ((time32[0] < 0) || (time32[1] < 0))
980 - return -EINVAL;
981
982 if (copy_to_user(argp, time32, sizeof(time32)))
983 return -EFAULT;
984 @@ -643,8 +650,9 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
985 jiffies_to_timespec64(pp->pdev->timeout, &ts);
986 time64[0] = ts.tv_sec;
987 time64[1] = ts.tv_nsec / NSEC_PER_USEC;
988 - if ((time64[0] < 0) || (time64[1] < 0))
989 - return -EINVAL;
990 +
991 + if (IS_ENABLED(CONFIG_SPARC64) && !in_compat_syscall())
992 + time64[1] <<= 32;
993
994 if (copy_to_user(argp, time64, sizeof(time64)))
995 return -EFAULT;
996 diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
997 index ba9acae83bff..5817dfe5c5d2 100644
998 --- a/drivers/char/tpm/tpm2-cmd.c
999 +++ b/drivers/char/tpm/tpm2-cmd.c
1000 @@ -939,6 +939,10 @@ static int tpm2_get_cc_attrs_tbl(struct tpm_chip *chip)
1001
1002 chip->cc_attrs_tbl = devm_kcalloc(&chip->dev, 4, nr_commands,
1003 GFP_KERNEL);
1004 + if (!chip->cc_attrs_tbl) {
1005 + rc = -ENOMEM;
1006 + goto out;
1007 + }
1008
1009 rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_CAPABILITY);
1010 if (rc)
1011 diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
1012 index e4fdde93ed4c..e7df342a317d 100644
1013 --- a/drivers/char/tpm/tpm_tis.c
1014 +++ b/drivers/char/tpm/tpm_tis.c
1015 @@ -286,7 +286,7 @@ static int tpm_tis_plat_probe(struct platform_device *pdev)
1016 }
1017 tpm_info.res = *res;
1018
1019 - tpm_info.irq = platform_get_irq(pdev, 0);
1020 + tpm_info.irq = platform_get_irq_optional(pdev, 0);
1021 if (tpm_info.irq <= 0) {
1022 if (pdev != force_pdev)
1023 tpm_info.irq = -1;
1024 diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
1025 index 6061850e59c9..56f4bc0d209e 100644
1026 --- a/drivers/cpufreq/powernv-cpufreq.c
1027 +++ b/drivers/cpufreq/powernv-cpufreq.c
1028 @@ -1041,9 +1041,14 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
1029
1030 static int init_chip_info(void)
1031 {
1032 - unsigned int chip[256];
1033 + unsigned int *chip;
1034 unsigned int cpu, i;
1035 unsigned int prev_chip_id = UINT_MAX;
1036 + int ret = 0;
1037 +
1038 + chip = kcalloc(num_possible_cpus(), sizeof(*chip), GFP_KERNEL);
1039 + if (!chip)
1040 + return -ENOMEM;
1041
1042 for_each_possible_cpu(cpu) {
1043 unsigned int id = cpu_to_chip_id(cpu);
1044 @@ -1055,8 +1060,10 @@ static int init_chip_info(void)
1045 }
1046
1047 chips = kcalloc(nr_chips, sizeof(struct chip), GFP_KERNEL);
1048 - if (!chips)
1049 - return -ENOMEM;
1050 + if (!chips) {
1051 + ret = -ENOMEM;
1052 + goto free_and_return;
1053 + }
1054
1055 for (i = 0; i < nr_chips; i++) {
1056 chips[i].id = chip[i];
1057 @@ -1066,7 +1073,9 @@ static int init_chip_info(void)
1058 per_cpu(chip_info, cpu) = &chips[i];
1059 }
1060
1061 - return 0;
1062 +free_and_return:
1063 + kfree(chip);
1064 + return ret;
1065 }
1066
1067 static inline void clean_chip_info(void)
1068 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
1069 index 0895b988fa92..29d2d7a21bd7 100644
1070 --- a/drivers/cpuidle/cpuidle.c
1071 +++ b/drivers/cpuidle/cpuidle.c
1072 @@ -384,6 +384,7 @@ u64 cpuidle_poll_time(struct cpuidle_driver *drv,
1073 continue;
1074
1075 limit_ns = (u64)drv->states[i].target_residency * NSEC_PER_USEC;
1076 + break;
1077 }
1078
1079 dev->poll_limit_ns = limit_ns;
1080 diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
1081 index 80c1a830d991..9db154224999 100644
1082 --- a/drivers/cpuidle/driver.c
1083 +++ b/drivers/cpuidle/driver.c
1084 @@ -62,24 +62,23 @@ static inline void __cpuidle_unset_driver(struct cpuidle_driver *drv)
1085 * __cpuidle_set_driver - set per CPU driver variables for the given driver.
1086 * @drv: a valid pointer to a struct cpuidle_driver
1087 *
1088 - * For each CPU in the driver's cpumask, unset the registered driver per CPU
1089 - * to @drv.
1090 - *
1091 - * Returns 0 on success, -EBUSY if the CPUs have driver(s) already.
1092 + * Returns 0 on success, -EBUSY if any CPU in the cpumask have a driver
1093 + * different from drv already.
1094 */
1095 static inline int __cpuidle_set_driver(struct cpuidle_driver *drv)
1096 {
1097 int cpu;
1098
1099 for_each_cpu(cpu, drv->cpumask) {
1100 + struct cpuidle_driver *old_drv;
1101
1102 - if (__cpuidle_get_cpu_driver(cpu)) {
1103 - __cpuidle_unset_driver(drv);
1104 + old_drv = __cpuidle_get_cpu_driver(cpu);
1105 + if (old_drv && old_drv != drv)
1106 return -EBUSY;
1107 - }
1108 + }
1109
1110 + for_each_cpu(cpu, drv->cpumask)
1111 per_cpu(cpuidle_drivers, cpu) = drv;
1112 - }
1113
1114 return 0;
1115 }
1116 diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
1117 index b5a0e498f798..b9b9156618e6 100644
1118 --- a/drivers/cpuidle/governors/teo.c
1119 +++ b/drivers/cpuidle/governors/teo.c
1120 @@ -233,7 +233,7 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
1121 {
1122 struct teo_cpu *cpu_data = per_cpu_ptr(&teo_cpus, dev->cpu);
1123 int latency_req = cpuidle_governor_latency_req(dev->cpu);
1124 - unsigned int duration_us, count;
1125 + unsigned int duration_us, hits, misses, early_hits;
1126 int max_early_idx, constraint_idx, idx, i;
1127 ktime_t delta_tick;
1128
1129 @@ -247,7 +247,9 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
1130 cpu_data->sleep_length_ns = tick_nohz_get_sleep_length(&delta_tick);
1131 duration_us = ktime_to_us(cpu_data->sleep_length_ns);
1132
1133 - count = 0;
1134 + hits = 0;
1135 + misses = 0;
1136 + early_hits = 0;
1137 max_early_idx = -1;
1138 constraint_idx = drv->state_count;
1139 idx = -1;
1140 @@ -258,23 +260,61 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
1141
1142 if (s->disabled || su->disable) {
1143 /*
1144 - * If the "early hits" metric of a disabled state is
1145 - * greater than the current maximum, it should be taken
1146 - * into account, because it would be a mistake to select
1147 - * a deeper state with lower "early hits" metric. The
1148 - * index cannot be changed to point to it, however, so
1149 - * just increase the max count alone and let the index
1150 - * still point to a shallower idle state.
1151 + * Ignore disabled states with target residencies beyond
1152 + * the anticipated idle duration.
1153 */
1154 - if (max_early_idx >= 0 &&
1155 - count < cpu_data->states[i].early_hits)
1156 - count = cpu_data->states[i].early_hits;
1157 + if (s->target_residency > duration_us)
1158 + continue;
1159 +
1160 + /*
1161 + * This state is disabled, so the range of idle duration
1162 + * values corresponding to it is covered by the current
1163 + * candidate state, but still the "hits" and "misses"
1164 + * metrics of the disabled state need to be used to
1165 + * decide whether or not the state covering the range in
1166 + * question is good enough.
1167 + */
1168 + hits = cpu_data->states[i].hits;
1169 + misses = cpu_data->states[i].misses;
1170 +
1171 + if (early_hits >= cpu_data->states[i].early_hits ||
1172 + idx < 0)
1173 + continue;
1174 +
1175 + /*
1176 + * If the current candidate state has been the one with
1177 + * the maximum "early hits" metric so far, the "early
1178 + * hits" metric of the disabled state replaces the
1179 + * current "early hits" count to avoid selecting a
1180 + * deeper state with lower "early hits" metric.
1181 + */
1182 + if (max_early_idx == idx) {
1183 + early_hits = cpu_data->states[i].early_hits;
1184 + continue;
1185 + }
1186 +
1187 + /*
1188 + * The current candidate state is closer to the disabled
1189 + * one than the current maximum "early hits" state, so
1190 + * replace the latter with it, but in case the maximum
1191 + * "early hits" state index has not been set so far,
1192 + * check if the current candidate state is not too
1193 + * shallow for that role.
1194 + */
1195 + if (!(tick_nohz_tick_stopped() &&
1196 + drv->states[idx].target_residency < TICK_USEC)) {
1197 + early_hits = cpu_data->states[i].early_hits;
1198 + max_early_idx = idx;
1199 + }
1200
1201 continue;
1202 }
1203
1204 - if (idx < 0)
1205 + if (idx < 0) {
1206 idx = i; /* first enabled state */
1207 + hits = cpu_data->states[i].hits;
1208 + misses = cpu_data->states[i].misses;
1209 + }
1210
1211 if (s->target_residency > duration_us)
1212 break;
1213 @@ -283,11 +323,13 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
1214 constraint_idx = i;
1215
1216 idx = i;
1217 + hits = cpu_data->states[i].hits;
1218 + misses = cpu_data->states[i].misses;
1219
1220 - if (count < cpu_data->states[i].early_hits &&
1221 + if (early_hits < cpu_data->states[i].early_hits &&
1222 !(tick_nohz_tick_stopped() &&
1223 drv->states[i].target_residency < TICK_USEC)) {
1224 - count = cpu_data->states[i].early_hits;
1225 + early_hits = cpu_data->states[i].early_hits;
1226 max_early_idx = i;
1227 }
1228 }
1229 @@ -300,8 +342,7 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
1230 * "early hits" metric, but if that cannot be determined, just use the
1231 * state selected so far.
1232 */
1233 - if (cpu_data->states[idx].hits <= cpu_data->states[idx].misses &&
1234 - max_early_idx >= 0) {
1235 + if (hits <= misses && max_early_idx >= 0) {
1236 idx = max_early_idx;
1237 duration_us = drv->states[idx].target_residency;
1238 }
1239 @@ -316,10 +357,9 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
1240 if (idx < 0) {
1241 idx = 0; /* No states enabled. Must use 0. */
1242 } else if (idx > 0) {
1243 + unsigned int count = 0;
1244 u64 sum = 0;
1245
1246 - count = 0;
1247 -
1248 /*
1249 * Count and sum the most recent idle duration values less than
1250 * the current expected idle duration value.
1251 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
1252 index 446490c9d635..3a1484e7a3ae 100644
1253 --- a/drivers/devfreq/devfreq.c
1254 +++ b/drivers/devfreq/devfreq.c
1255 @@ -160,6 +160,7 @@ int devfreq_update_status(struct devfreq *devfreq, unsigned long freq)
1256 int lev, prev_lev, ret = 0;
1257 unsigned long cur_time;
1258
1259 + lockdep_assert_held(&devfreq->lock);
1260 cur_time = jiffies;
1261
1262 /* Immediately exit if previous_freq is not initialized yet. */
1263 @@ -1397,12 +1398,17 @@ static ssize_t trans_stat_show(struct device *dev,
1264 int i, j;
1265 unsigned int max_state = devfreq->profile->max_state;
1266
1267 - if (!devfreq->stop_polling &&
1268 - devfreq_update_status(devfreq, devfreq->previous_freq))
1269 - return 0;
1270 if (max_state == 0)
1271 return sprintf(buf, "Not Supported.\n");
1272
1273 + mutex_lock(&devfreq->lock);
1274 + if (!devfreq->stop_polling &&
1275 + devfreq_update_status(devfreq, devfreq->previous_freq)) {
1276 + mutex_unlock(&devfreq->lock);
1277 + return 0;
1278 + }
1279 + mutex_unlock(&devfreq->lock);
1280 +
1281 len = sprintf(buf, " From : To\n");
1282 len += sprintf(buf + len, " :");
1283 for (i = 0; i < max_state; i++)
1284 diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
1285 index fbda4b876afd..0be3d1b17f03 100644
1286 --- a/drivers/edac/altera_edac.c
1287 +++ b/drivers/edac/altera_edac.c
1288 @@ -560,6 +560,7 @@ static const struct regmap_config s10_sdram_regmap_cfg = {
1289 .reg_write = s10_protected_reg_write,
1290 .use_single_read = true,
1291 .use_single_write = true,
1292 + .fast_io = true,
1293 };
1294
1295 /************** </Stratix10 EDAC Memory Controller Functions> ***********/
1296 diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
1297 index f6f6a688c009..296e714bf553 100644
1298 --- a/drivers/edac/ghes_edac.c
1299 +++ b/drivers/edac/ghes_edac.c
1300 @@ -566,8 +566,8 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)
1301 ghes_pvt = pvt;
1302 spin_unlock_irqrestore(&ghes_lock, flags);
1303
1304 - /* only increment on success */
1305 - refcount_inc(&ghes_refcount);
1306 + /* only set on success */
1307 + refcount_set(&ghes_refcount, 1);
1308
1309 unlock:
1310 mutex_unlock(&ghes_reg_mutex);
1311 diff --git a/drivers/firmware/qcom_scm-64.c b/drivers/firmware/qcom_scm-64.c
1312 index 91d5ad7cf58b..25e0f60c759a 100644
1313 --- a/drivers/firmware/qcom_scm-64.c
1314 +++ b/drivers/firmware/qcom_scm-64.c
1315 @@ -150,7 +150,7 @@ static int qcom_scm_call(struct device *dev, u32 svc_id, u32 cmd_id,
1316 kfree(args_virt);
1317 }
1318
1319 - if (res->a0 < 0)
1320 + if ((long)res->a0 < 0)
1321 return qcom_scm_remap_error(res->a0);
1322
1323 return 0;
1324 diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
1325 index f21bc8a7ee3a..bdf91b75328e 100644
1326 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c
1327 +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
1328 @@ -443,7 +443,7 @@ panfrost_postclose(struct drm_device *dev, struct drm_file *file)
1329 {
1330 struct panfrost_file_priv *panfrost_priv = file->driver_priv;
1331
1332 - panfrost_perfcnt_close(panfrost_priv);
1333 + panfrost_perfcnt_close(file);
1334 panfrost_job_close(panfrost_priv);
1335
1336 panfrost_mmu_pgtable_free(panfrost_priv);
1337 diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
1338 index acb07fe06580..bc3ff22e5e85 100644
1339 --- a/drivers/gpu/drm/panfrost/panfrost_gem.c
1340 +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
1341 @@ -41,7 +41,7 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj)
1342 drm_gem_shmem_free_object(obj);
1343 }
1344
1345 -static int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_priv)
1346 +int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_priv)
1347 {
1348 int ret;
1349 size_t size = obj->size;
1350 @@ -80,7 +80,7 @@ static int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_p
1351 return ret;
1352 }
1353
1354 -static void panfrost_gem_close(struct drm_gem_object *obj, struct drm_file *file_priv)
1355 +void panfrost_gem_close(struct drm_gem_object *obj, struct drm_file *file_priv)
1356 {
1357 struct panfrost_gem_object *bo = to_panfrost_bo(obj);
1358 struct panfrost_file_priv *priv = file_priv->driver_priv;
1359 diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.h b/drivers/gpu/drm/panfrost/panfrost_gem.h
1360 index 50920819cc16..4b17e7308764 100644
1361 --- a/drivers/gpu/drm/panfrost/panfrost_gem.h
1362 +++ b/drivers/gpu/drm/panfrost/panfrost_gem.h
1363 @@ -45,6 +45,10 @@ panfrost_gem_create_with_handle(struct drm_file *file_priv,
1364 u32 flags,
1365 uint32_t *handle);
1366
1367 +int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_priv);
1368 +void panfrost_gem_close(struct drm_gem_object *obj,
1369 + struct drm_file *file_priv);
1370 +
1371 void panfrost_gem_shrinker_init(struct drm_device *dev);
1372 void panfrost_gem_shrinker_cleanup(struct drm_device *dev);
1373
1374 diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c
1375 index 2dba192bf198..2c04e858c50a 100644
1376 --- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c
1377 +++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c
1378 @@ -67,9 +67,10 @@ static int panfrost_perfcnt_dump_locked(struct panfrost_device *pfdev)
1379 }
1380
1381 static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev,
1382 - struct panfrost_file_priv *user,
1383 + struct drm_file *file_priv,
1384 unsigned int counterset)
1385 {
1386 + struct panfrost_file_priv *user = file_priv->driver_priv;
1387 struct panfrost_perfcnt *perfcnt = pfdev->perfcnt;
1388 struct drm_gem_shmem_object *bo;
1389 u32 cfg;
1390 @@ -91,14 +92,14 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev,
1391 perfcnt->bo = to_panfrost_bo(&bo->base);
1392
1393 /* Map the perfcnt buf in the address space attached to file_priv. */
1394 - ret = panfrost_mmu_map(perfcnt->bo);
1395 + ret = panfrost_gem_open(&perfcnt->bo->base.base, file_priv);
1396 if (ret)
1397 goto err_put_bo;
1398
1399 perfcnt->buf = drm_gem_shmem_vmap(&bo->base);
1400 if (IS_ERR(perfcnt->buf)) {
1401 ret = PTR_ERR(perfcnt->buf);
1402 - goto err_put_bo;
1403 + goto err_close_bo;
1404 }
1405
1406 /*
1407 @@ -157,14 +158,17 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev,
1408
1409 err_vunmap:
1410 drm_gem_shmem_vunmap(&perfcnt->bo->base.base, perfcnt->buf);
1411 +err_close_bo:
1412 + panfrost_gem_close(&perfcnt->bo->base.base, file_priv);
1413 err_put_bo:
1414 drm_gem_object_put_unlocked(&bo->base);
1415 return ret;
1416 }
1417
1418 static int panfrost_perfcnt_disable_locked(struct panfrost_device *pfdev,
1419 - struct panfrost_file_priv *user)
1420 + struct drm_file *file_priv)
1421 {
1422 + struct panfrost_file_priv *user = file_priv->driver_priv;
1423 struct panfrost_perfcnt *perfcnt = pfdev->perfcnt;
1424
1425 if (user != perfcnt->user)
1426 @@ -180,6 +184,7 @@ static int panfrost_perfcnt_disable_locked(struct panfrost_device *pfdev,
1427 perfcnt->user = NULL;
1428 drm_gem_shmem_vunmap(&perfcnt->bo->base.base, perfcnt->buf);
1429 perfcnt->buf = NULL;
1430 + panfrost_gem_close(&perfcnt->bo->base.base, file_priv);
1431 drm_gem_object_put_unlocked(&perfcnt->bo->base.base);
1432 perfcnt->bo = NULL;
1433 pm_runtime_mark_last_busy(pfdev->dev);
1434 @@ -191,7 +196,6 @@ static int panfrost_perfcnt_disable_locked(struct panfrost_device *pfdev,
1435 int panfrost_ioctl_perfcnt_enable(struct drm_device *dev, void *data,
1436 struct drm_file *file_priv)
1437 {
1438 - struct panfrost_file_priv *pfile = file_priv->driver_priv;
1439 struct panfrost_device *pfdev = dev->dev_private;
1440 struct panfrost_perfcnt *perfcnt = pfdev->perfcnt;
1441 struct drm_panfrost_perfcnt_enable *req = data;
1442 @@ -207,10 +211,10 @@ int panfrost_ioctl_perfcnt_enable(struct drm_device *dev, void *data,
1443
1444 mutex_lock(&perfcnt->lock);
1445 if (req->enable)
1446 - ret = panfrost_perfcnt_enable_locked(pfdev, pfile,
1447 + ret = panfrost_perfcnt_enable_locked(pfdev, file_priv,
1448 req->counterset);
1449 else
1450 - ret = panfrost_perfcnt_disable_locked(pfdev, pfile);
1451 + ret = panfrost_perfcnt_disable_locked(pfdev, file_priv);
1452 mutex_unlock(&perfcnt->lock);
1453
1454 return ret;
1455 @@ -248,15 +252,16 @@ out:
1456 return ret;
1457 }
1458
1459 -void panfrost_perfcnt_close(struct panfrost_file_priv *pfile)
1460 +void panfrost_perfcnt_close(struct drm_file *file_priv)
1461 {
1462 + struct panfrost_file_priv *pfile = file_priv->driver_priv;
1463 struct panfrost_device *pfdev = pfile->pfdev;
1464 struct panfrost_perfcnt *perfcnt = pfdev->perfcnt;
1465
1466 pm_runtime_get_sync(pfdev->dev);
1467 mutex_lock(&perfcnt->lock);
1468 if (perfcnt->user == pfile)
1469 - panfrost_perfcnt_disable_locked(pfdev, pfile);
1470 + panfrost_perfcnt_disable_locked(pfdev, file_priv);
1471 mutex_unlock(&perfcnt->lock);
1472 pm_runtime_mark_last_busy(pfdev->dev);
1473 pm_runtime_put_autosuspend(pfdev->dev);
1474 diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.h b/drivers/gpu/drm/panfrost/panfrost_perfcnt.h
1475 index 13b8fdaa1b43..8bbcf5f5fb33 100644
1476 --- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.h
1477 +++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.h
1478 @@ -9,7 +9,7 @@ void panfrost_perfcnt_sample_done(struct panfrost_device *pfdev);
1479 void panfrost_perfcnt_clean_cache_done(struct panfrost_device *pfdev);
1480 int panfrost_perfcnt_init(struct panfrost_device *pfdev);
1481 void panfrost_perfcnt_fini(struct panfrost_device *pfdev);
1482 -void panfrost_perfcnt_close(struct panfrost_file_priv *pfile);
1483 +void panfrost_perfcnt_close(struct drm_file *file_priv);
1484 int panfrost_ioctl_perfcnt_enable(struct drm_device *dev, void *data,
1485 struct drm_file *file_priv);
1486 int panfrost_ioctl_perfcnt_dump(struct drm_device *dev, void *data,
1487 diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
1488 index 05f7896c3a01..b605889b507a 100644
1489 --- a/drivers/hwtracing/coresight/coresight-funnel.c
1490 +++ b/drivers/hwtracing/coresight/coresight-funnel.c
1491 @@ -38,12 +38,14 @@ DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel");
1492 * @atclk: optional clock for the core parts of the funnel.
1493 * @csdev: component vitals needed by the framework.
1494 * @priority: port selection order.
1495 + * @spinlock: serialize enable/disable operations.
1496 */
1497 struct funnel_drvdata {
1498 void __iomem *base;
1499 struct clk *atclk;
1500 struct coresight_device *csdev;
1501 unsigned long priority;
1502 + spinlock_t spinlock;
1503 };
1504
1505 static int dynamic_funnel_enable_hw(struct funnel_drvdata *drvdata, int port)
1506 @@ -76,11 +78,21 @@ static int funnel_enable(struct coresight_device *csdev, int inport,
1507 {
1508 int rc = 0;
1509 struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
1510 -
1511 - if (drvdata->base)
1512 - rc = dynamic_funnel_enable_hw(drvdata, inport);
1513 -
1514 + unsigned long flags;
1515 + bool first_enable = false;
1516 +
1517 + spin_lock_irqsave(&drvdata->spinlock, flags);
1518 + if (atomic_read(&csdev->refcnt[inport]) == 0) {
1519 + if (drvdata->base)
1520 + rc = dynamic_funnel_enable_hw(drvdata, inport);
1521 + if (!rc)
1522 + first_enable = true;
1523 + }
1524 if (!rc)
1525 + atomic_inc(&csdev->refcnt[inport]);
1526 + spin_unlock_irqrestore(&drvdata->spinlock, flags);
1527 +
1528 + if (first_enable)
1529 dev_dbg(&csdev->dev, "FUNNEL inport %d enabled\n", inport);
1530 return rc;
1531 }
1532 @@ -107,11 +119,19 @@ static void funnel_disable(struct coresight_device *csdev, int inport,
1533 int outport)
1534 {
1535 struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
1536 + unsigned long flags;
1537 + bool last_disable = false;
1538 +
1539 + spin_lock_irqsave(&drvdata->spinlock, flags);
1540 + if (atomic_dec_return(&csdev->refcnt[inport]) == 0) {
1541 + if (drvdata->base)
1542 + dynamic_funnel_disable_hw(drvdata, inport);
1543 + last_disable = true;
1544 + }
1545 + spin_unlock_irqrestore(&drvdata->spinlock, flags);
1546
1547 - if (drvdata->base)
1548 - dynamic_funnel_disable_hw(drvdata, inport);
1549 -
1550 - dev_dbg(&csdev->dev, "FUNNEL inport %d disabled\n", inport);
1551 + if (last_disable)
1552 + dev_dbg(&csdev->dev, "FUNNEL inport %d disabled\n", inport);
1553 }
1554
1555 static const struct coresight_ops_link funnel_link_ops = {
1556 diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
1557 index b29ba640eb25..43304196a1a6 100644
1558 --- a/drivers/hwtracing/coresight/coresight-replicator.c
1559 +++ b/drivers/hwtracing/coresight/coresight-replicator.c
1560 @@ -31,11 +31,13 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
1561 * whether this one is programmable or not.
1562 * @atclk: optional clock for the core parts of the replicator.
1563 * @csdev: component vitals needed by the framework
1564 + * @spinlock: serialize enable/disable operations.
1565 */
1566 struct replicator_drvdata {
1567 void __iomem *base;
1568 struct clk *atclk;
1569 struct coresight_device *csdev;
1570 + spinlock_t spinlock;
1571 };
1572
1573 static void dynamic_replicator_reset(struct replicator_drvdata *drvdata)
1574 @@ -97,10 +99,22 @@ static int replicator_enable(struct coresight_device *csdev, int inport,
1575 {
1576 int rc = 0;
1577 struct replicator_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
1578 -
1579 - if (drvdata->base)
1580 - rc = dynamic_replicator_enable(drvdata, inport, outport);
1581 + unsigned long flags;
1582 + bool first_enable = false;
1583 +
1584 + spin_lock_irqsave(&drvdata->spinlock, flags);
1585 + if (atomic_read(&csdev->refcnt[outport]) == 0) {
1586 + if (drvdata->base)
1587 + rc = dynamic_replicator_enable(drvdata, inport,
1588 + outport);
1589 + if (!rc)
1590 + first_enable = true;
1591 + }
1592 if (!rc)
1593 + atomic_inc(&csdev->refcnt[outport]);
1594 + spin_unlock_irqrestore(&drvdata->spinlock, flags);
1595 +
1596 + if (first_enable)
1597 dev_dbg(&csdev->dev, "REPLICATOR enabled\n");
1598 return rc;
1599 }
1600 @@ -137,10 +151,19 @@ static void replicator_disable(struct coresight_device *csdev, int inport,
1601 int outport)
1602 {
1603 struct replicator_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
1604 + unsigned long flags;
1605 + bool last_disable = false;
1606 +
1607 + spin_lock_irqsave(&drvdata->spinlock, flags);
1608 + if (atomic_dec_return(&csdev->refcnt[outport]) == 0) {
1609 + if (drvdata->base)
1610 + dynamic_replicator_disable(drvdata, inport, outport);
1611 + last_disable = true;
1612 + }
1613 + spin_unlock_irqrestore(&drvdata->spinlock, flags);
1614
1615 - if (drvdata->base)
1616 - dynamic_replicator_disable(drvdata, inport, outport);
1617 - dev_dbg(&csdev->dev, "REPLICATOR disabled\n");
1618 + if (last_disable)
1619 + dev_dbg(&csdev->dev, "REPLICATOR disabled\n");
1620 }
1621
1622 static const struct coresight_ops_link replicator_link_ops = {
1623 diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
1624 index 807416b75ecc..d0cc3985b72a 100644
1625 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
1626 +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
1627 @@ -334,9 +334,10 @@ static int tmc_disable_etf_sink(struct coresight_device *csdev)
1628 static int tmc_enable_etf_link(struct coresight_device *csdev,
1629 int inport, int outport)
1630 {
1631 - int ret;
1632 + int ret = 0;
1633 unsigned long flags;
1634 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
1635 + bool first_enable = false;
1636
1637 spin_lock_irqsave(&drvdata->spinlock, flags);
1638 if (drvdata->reading) {
1639 @@ -344,12 +345,18 @@ static int tmc_enable_etf_link(struct coresight_device *csdev,
1640 return -EBUSY;
1641 }
1642
1643 - ret = tmc_etf_enable_hw(drvdata);
1644 + if (atomic_read(&csdev->refcnt[0]) == 0) {
1645 + ret = tmc_etf_enable_hw(drvdata);
1646 + if (!ret) {
1647 + drvdata->mode = CS_MODE_SYSFS;
1648 + first_enable = true;
1649 + }
1650 + }
1651 if (!ret)
1652 - drvdata->mode = CS_MODE_SYSFS;
1653 + atomic_inc(&csdev->refcnt[0]);
1654 spin_unlock_irqrestore(&drvdata->spinlock, flags);
1655
1656 - if (!ret)
1657 + if (first_enable)
1658 dev_dbg(&csdev->dev, "TMC-ETF enabled\n");
1659 return ret;
1660 }
1661 @@ -359,6 +366,7 @@ static void tmc_disable_etf_link(struct coresight_device *csdev,
1662 {
1663 unsigned long flags;
1664 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
1665 + bool last_disable = false;
1666
1667 spin_lock_irqsave(&drvdata->spinlock, flags);
1668 if (drvdata->reading) {
1669 @@ -366,11 +374,15 @@ static void tmc_disable_etf_link(struct coresight_device *csdev,
1670 return;
1671 }
1672
1673 - tmc_etf_disable_hw(drvdata);
1674 - drvdata->mode = CS_MODE_DISABLED;
1675 + if (atomic_dec_return(&csdev->refcnt[0]) == 0) {
1676 + tmc_etf_disable_hw(drvdata);
1677 + drvdata->mode = CS_MODE_DISABLED;
1678 + last_disable = true;
1679 + }
1680 spin_unlock_irqrestore(&drvdata->spinlock, flags);
1681
1682 - dev_dbg(&csdev->dev, "TMC-ETF disabled\n");
1683 + if (last_disable)
1684 + dev_dbg(&csdev->dev, "TMC-ETF disabled\n");
1685 }
1686
1687 static void *tmc_alloc_etf_buffer(struct coresight_device *csdev,
1688 diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
1689 index 6453c67a4d01..0bbce0d29158 100644
1690 --- a/drivers/hwtracing/coresight/coresight.c
1691 +++ b/drivers/hwtracing/coresight/coresight.c
1692 @@ -253,9 +253,9 @@ static int coresight_enable_link(struct coresight_device *csdev,
1693 struct coresight_device *parent,
1694 struct coresight_device *child)
1695 {
1696 - int ret;
1697 + int ret = 0;
1698 int link_subtype;
1699 - int refport, inport, outport;
1700 + int inport, outport;
1701
1702 if (!parent || !child)
1703 return -EINVAL;
1704 @@ -264,29 +264,17 @@ static int coresight_enable_link(struct coresight_device *csdev,
1705 outport = coresight_find_link_outport(csdev, child);
1706 link_subtype = csdev->subtype.link_subtype;
1707
1708 - if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG)
1709 - refport = inport;
1710 - else if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT)
1711 - refport = outport;
1712 - else
1713 - refport = 0;
1714 -
1715 - if (refport < 0)
1716 - return refport;
1717 + if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG && inport < 0)
1718 + return inport;
1719 + if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT && outport < 0)
1720 + return outport;
1721
1722 - if (atomic_inc_return(&csdev->refcnt[refport]) == 1) {
1723 - if (link_ops(csdev)->enable) {
1724 - ret = link_ops(csdev)->enable(csdev, inport, outport);
1725 - if (ret) {
1726 - atomic_dec(&csdev->refcnt[refport]);
1727 - return ret;
1728 - }
1729 - }
1730 - }
1731 -
1732 - csdev->enable = true;
1733 + if (link_ops(csdev)->enable)
1734 + ret = link_ops(csdev)->enable(csdev, inport, outport);
1735 + if (!ret)
1736 + csdev->enable = true;
1737
1738 - return 0;
1739 + return ret;
1740 }
1741
1742 static void coresight_disable_link(struct coresight_device *csdev,
1743 @@ -295,7 +283,7 @@ static void coresight_disable_link(struct coresight_device *csdev,
1744 {
1745 int i, nr_conns;
1746 int link_subtype;
1747 - int refport, inport, outport;
1748 + int inport, outport;
1749
1750 if (!parent || !child)
1751 return;
1752 @@ -305,20 +293,15 @@ static void coresight_disable_link(struct coresight_device *csdev,
1753 link_subtype = csdev->subtype.link_subtype;
1754
1755 if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG) {
1756 - refport = inport;
1757 nr_conns = csdev->pdata->nr_inport;
1758 } else if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT) {
1759 - refport = outport;
1760 nr_conns = csdev->pdata->nr_outport;
1761 } else {
1762 - refport = 0;
1763 nr_conns = 1;
1764 }
1765
1766 - if (atomic_dec_return(&csdev->refcnt[refport]) == 0) {
1767 - if (link_ops(csdev)->disable)
1768 - link_ops(csdev)->disable(csdev, inport, outport);
1769 - }
1770 + if (link_ops(csdev)->disable)
1771 + link_ops(csdev)->disable(csdev, inport, outport);
1772
1773 for (i = 0; i < nr_conns; i++)
1774 if (atomic_read(&csdev->refcnt[i]) != 0)
1775 diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
1776 index d5c1821b31c6..0dfd97bbde9e 100644
1777 --- a/drivers/hwtracing/intel_th/core.c
1778 +++ b/drivers/hwtracing/intel_th/core.c
1779 @@ -649,10 +649,8 @@ intel_th_subdevice_alloc(struct intel_th *th,
1780 }
1781
1782 err = intel_th_device_add_resources(thdev, res, subdev->nres);
1783 - if (err) {
1784 - put_device(&thdev->dev);
1785 + if (err)
1786 goto fail_put_device;
1787 - }
1788
1789 if (subdev->type == INTEL_TH_OUTPUT) {
1790 if (subdev->mknode)
1791 @@ -667,10 +665,8 @@ intel_th_subdevice_alloc(struct intel_th *th,
1792 }
1793
1794 err = device_add(&thdev->dev);
1795 - if (err) {
1796 - put_device(&thdev->dev);
1797 + if (err)
1798 goto fail_free_res;
1799 - }
1800
1801 /* need switch driver to be loaded to enumerate the rest */
1802 if (subdev->type == INTEL_TH_SWITCH && !req) {
1803 diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
1804 index 03ca5b1bef9f..ebf3e30e989a 100644
1805 --- a/drivers/hwtracing/intel_th/pci.c
1806 +++ b/drivers/hwtracing/intel_th/pci.c
1807 @@ -209,6 +209,16 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
1808 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x45c5),
1809 .driver_data = (kernel_ulong_t)&intel_th_2x,
1810 },
1811 + {
1812 + /* Ice Lake CPU */
1813 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x8a29),
1814 + .driver_data = (kernel_ulong_t)&intel_th_2x,
1815 + },
1816 + {
1817 + /* Tiger Lake CPU */
1818 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x9a33),
1819 + .driver_data = (kernel_ulong_t)&intel_th_2x,
1820 + },
1821 {
1822 /* Tiger Lake PCH */
1823 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa0a6),
1824 diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c
1825 index 4b9e44b227d8..4f932a419752 100644
1826 --- a/drivers/hwtracing/stm/policy.c
1827 +++ b/drivers/hwtracing/stm/policy.c
1828 @@ -345,7 +345,11 @@ void stp_policy_unbind(struct stp_policy *policy)
1829 stm->policy = NULL;
1830 policy->stm = NULL;
1831
1832 + /*
1833 + * Drop the reference on the protocol driver and lose the link.
1834 + */
1835 stm_put_protocol(stm->pdrv);
1836 + stm->pdrv = NULL;
1837 stm_put_device(stm);
1838 }
1839
1840 diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
1841 index edc6f1cc90b2..3f03abf100b5 100644
1842 --- a/drivers/iio/adc/ad7124.c
1843 +++ b/drivers/iio/adc/ad7124.c
1844 @@ -39,6 +39,8 @@
1845 #define AD7124_STATUS_POR_FLAG_MSK BIT(4)
1846
1847 /* AD7124_ADC_CONTROL */
1848 +#define AD7124_ADC_CTRL_REF_EN_MSK BIT(8)
1849 +#define AD7124_ADC_CTRL_REF_EN(x) FIELD_PREP(AD7124_ADC_CTRL_REF_EN_MSK, x)
1850 #define AD7124_ADC_CTRL_PWR_MSK GENMASK(7, 6)
1851 #define AD7124_ADC_CTRL_PWR(x) FIELD_PREP(AD7124_ADC_CTRL_PWR_MSK, x)
1852 #define AD7124_ADC_CTRL_MODE_MSK GENMASK(5, 2)
1853 @@ -424,7 +426,10 @@ static int ad7124_init_channel_vref(struct ad7124_state *st,
1854 break;
1855 case AD7124_INT_REF:
1856 st->channel_config[channel_number].vref_mv = 2500;
1857 - break;
1858 + st->adc_control &= ~AD7124_ADC_CTRL_REF_EN_MSK;
1859 + st->adc_control |= AD7124_ADC_CTRL_REF_EN(1);
1860 + return ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL,
1861 + 2, st->adc_control);
1862 default:
1863 dev_err(&st->sd.spi->dev, "Invalid reference %d\n", refsel);
1864 return -EINVAL;
1865 diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
1866 index f5ba94c03a8d..e4683a68522a 100644
1867 --- a/drivers/iio/adc/ad7606.c
1868 +++ b/drivers/iio/adc/ad7606.c
1869 @@ -85,7 +85,7 @@ err_unlock:
1870
1871 static int ad7606_read_samples(struct ad7606_state *st)
1872 {
1873 - unsigned int num = st->chip_info->num_channels;
1874 + unsigned int num = st->chip_info->num_channels - 1;
1875 u16 *data = st->data;
1876 int ret;
1877
1878 diff --git a/drivers/iio/adc/ad7949.c b/drivers/iio/adc/ad7949.c
1879 index ac0ffff6c5ae..6b51bfcad0d0 100644
1880 --- a/drivers/iio/adc/ad7949.c
1881 +++ b/drivers/iio/adc/ad7949.c
1882 @@ -57,29 +57,11 @@ struct ad7949_adc_chip {
1883 u32 buffer ____cacheline_aligned;
1884 };
1885
1886 -static bool ad7949_spi_cfg_is_read_back(struct ad7949_adc_chip *ad7949_adc)
1887 -{
1888 - if (!(ad7949_adc->cfg & AD7949_CFG_READ_BACK))
1889 - return true;
1890 -
1891 - return false;
1892 -}
1893 -
1894 -static int ad7949_spi_bits_per_word(struct ad7949_adc_chip *ad7949_adc)
1895 -{
1896 - int ret = ad7949_adc->resolution;
1897 -
1898 - if (ad7949_spi_cfg_is_read_back(ad7949_adc))
1899 - ret += AD7949_CFG_REG_SIZE_BITS;
1900 -
1901 - return ret;
1902 -}
1903 -
1904 static int ad7949_spi_write_cfg(struct ad7949_adc_chip *ad7949_adc, u16 val,
1905 u16 mask)
1906 {
1907 int ret;
1908 - int bits_per_word = ad7949_spi_bits_per_word(ad7949_adc);
1909 + int bits_per_word = ad7949_adc->resolution;
1910 int shift = bits_per_word - AD7949_CFG_REG_SIZE_BITS;
1911 struct spi_message msg;
1912 struct spi_transfer tx[] = {
1913 @@ -107,7 +89,8 @@ static int ad7949_spi_read_channel(struct ad7949_adc_chip *ad7949_adc, int *val,
1914 unsigned int channel)
1915 {
1916 int ret;
1917 - int bits_per_word = ad7949_spi_bits_per_word(ad7949_adc);
1918 + int i;
1919 + int bits_per_word = ad7949_adc->resolution;
1920 int mask = GENMASK(ad7949_adc->resolution, 0);
1921 struct spi_message msg;
1922 struct spi_transfer tx[] = {
1923 @@ -118,12 +101,23 @@ static int ad7949_spi_read_channel(struct ad7949_adc_chip *ad7949_adc, int *val,
1924 },
1925 };
1926
1927 - ret = ad7949_spi_write_cfg(ad7949_adc,
1928 - channel << AD7949_OFFSET_CHANNEL_SEL,
1929 - AD7949_MASK_CHANNEL_SEL);
1930 - if (ret)
1931 - return ret;
1932 + /*
1933 + * 1: write CFG for sample N and read old data (sample N-2)
1934 + * 2: if CFG was not changed since sample N-1 then we'll get good data
1935 + * at the next xfer, so we bail out now, otherwise we write something
1936 + * and we read garbage (sample N-1 configuration).
1937 + */
1938 + for (i = 0; i < 2; i++) {
1939 + ret = ad7949_spi_write_cfg(ad7949_adc,
1940 + channel << AD7949_OFFSET_CHANNEL_SEL,
1941 + AD7949_MASK_CHANNEL_SEL);
1942 + if (ret)
1943 + return ret;
1944 + if (channel == ad7949_adc->current_channel)
1945 + break;
1946 + }
1947
1948 + /* 3: write something and read actual data */
1949 ad7949_adc->buffer = 0;
1950 spi_message_init_with_transfers(&msg, tx, 1);
1951 ret = spi_sync(ad7949_adc->spi, &msg);
1952 @@ -138,10 +132,7 @@ static int ad7949_spi_read_channel(struct ad7949_adc_chip *ad7949_adc, int *val,
1953
1954 ad7949_adc->current_channel = channel;
1955
1956 - if (ad7949_spi_cfg_is_read_back(ad7949_adc))
1957 - *val = (ad7949_adc->buffer >> AD7949_CFG_REG_SIZE_BITS) & mask;
1958 - else
1959 - *val = ad7949_adc->buffer & mask;
1960 + *val = ad7949_adc->buffer & mask;
1961
1962 return 0;
1963 }
1964 diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
1965 index bfe1cdb16846..dcf5a5bdfaa8 100644
1966 --- a/drivers/iio/humidity/hdc100x.c
1967 +++ b/drivers/iio/humidity/hdc100x.c
1968 @@ -229,7 +229,7 @@ static int hdc100x_read_raw(struct iio_dev *indio_dev,
1969 *val2 = 65536;
1970 return IIO_VAL_FRACTIONAL;
1971 } else {
1972 - *val = 100;
1973 + *val = 100000;
1974 *val2 = 65536;
1975 return IIO_VAL_FRACTIONAL;
1976 }
1977 diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
1978 index 8743b2f376e2..7b966a41d623 100644
1979 --- a/drivers/iio/imu/adis16480.c
1980 +++ b/drivers/iio/imu/adis16480.c
1981 @@ -623,9 +623,13 @@ static int adis16480_read_raw(struct iio_dev *indio_dev,
1982 *val2 = (st->chip_info->temp_scale % 1000) * 1000;
1983 return IIO_VAL_INT_PLUS_MICRO;
1984 case IIO_PRESSURE:
1985 - *val = 0;
1986 - *val2 = 4000; /* 40ubar = 0.004 kPa */
1987 - return IIO_VAL_INT_PLUS_MICRO;
1988 + /*
1989 + * max scale is 1310 mbar
1990 + * max raw value is 32767 shifted for 32bits
1991 + */
1992 + *val = 131; /* 1310mbar = 131 kPa */
1993 + *val2 = 32767 << 16;
1994 + return IIO_VAL_FRACTIONAL;
1995 default:
1996 return -EINVAL;
1997 }
1998 @@ -786,13 +790,14 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
1999 .channels = adis16485_channels,
2000 .num_channels = ARRAY_SIZE(adis16485_channels),
2001 /*
2002 - * storing the value in rad/degree and the scale in degree
2003 - * gives us the result in rad and better precession than
2004 - * storing the scale directly in rad.
2005 + * Typically we do IIO_RAD_TO_DEGREE in the denominator, which
2006 + * is exactly the same as IIO_DEGREE_TO_RAD in numerator, since
2007 + * it gives better approximation. However, in this case we
2008 + * cannot do it since it would not fit in a 32bit variable.
2009 */
2010 - .gyro_max_val = IIO_RAD_TO_DEGREE(22887),
2011 - .gyro_max_scale = 300,
2012 - .accel_max_val = IIO_M_S_2_TO_G(21973),
2013 + .gyro_max_val = 22887 << 16,
2014 + .gyro_max_scale = IIO_DEGREE_TO_RAD(300),
2015 + .accel_max_val = IIO_M_S_2_TO_G(21973 << 16),
2016 .accel_max_scale = 18,
2017 .temp_scale = 5650, /* 5.65 milli degree Celsius */
2018 .int_clk = 2460000,
2019 @@ -802,9 +807,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
2020 [ADIS16480] = {
2021 .channels = adis16480_channels,
2022 .num_channels = ARRAY_SIZE(adis16480_channels),
2023 - .gyro_max_val = IIO_RAD_TO_DEGREE(22500),
2024 - .gyro_max_scale = 450,
2025 - .accel_max_val = IIO_M_S_2_TO_G(12500),
2026 + .gyro_max_val = 22500 << 16,
2027 + .gyro_max_scale = IIO_DEGREE_TO_RAD(450),
2028 + .accel_max_val = IIO_M_S_2_TO_G(12500 << 16),
2029 .accel_max_scale = 10,
2030 .temp_scale = 5650, /* 5.65 milli degree Celsius */
2031 .int_clk = 2460000,
2032 @@ -814,9 +819,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
2033 [ADIS16485] = {
2034 .channels = adis16485_channels,
2035 .num_channels = ARRAY_SIZE(adis16485_channels),
2036 - .gyro_max_val = IIO_RAD_TO_DEGREE(22500),
2037 - .gyro_max_scale = 450,
2038 - .accel_max_val = IIO_M_S_2_TO_G(20000),
2039 + .gyro_max_val = 22500 << 16,
2040 + .gyro_max_scale = IIO_DEGREE_TO_RAD(450),
2041 + .accel_max_val = IIO_M_S_2_TO_G(20000 << 16),
2042 .accel_max_scale = 5,
2043 .temp_scale = 5650, /* 5.65 milli degree Celsius */
2044 .int_clk = 2460000,
2045 @@ -826,9 +831,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
2046 [ADIS16488] = {
2047 .channels = adis16480_channels,
2048 .num_channels = ARRAY_SIZE(adis16480_channels),
2049 - .gyro_max_val = IIO_RAD_TO_DEGREE(22500),
2050 - .gyro_max_scale = 450,
2051 - .accel_max_val = IIO_M_S_2_TO_G(22500),
2052 + .gyro_max_val = 22500 << 16,
2053 + .gyro_max_scale = IIO_DEGREE_TO_RAD(450),
2054 + .accel_max_val = IIO_M_S_2_TO_G(22500 << 16),
2055 .accel_max_scale = 18,
2056 .temp_scale = 5650, /* 5.65 milli degree Celsius */
2057 .int_clk = 2460000,
2058 @@ -838,9 +843,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
2059 [ADIS16495_1] = {
2060 .channels = adis16485_channels,
2061 .num_channels = ARRAY_SIZE(adis16485_channels),
2062 - .gyro_max_val = IIO_RAD_TO_DEGREE(20000),
2063 - .gyro_max_scale = 125,
2064 - .accel_max_val = IIO_M_S_2_TO_G(32000),
2065 + .gyro_max_val = 20000 << 16,
2066 + .gyro_max_scale = IIO_DEGREE_TO_RAD(125),
2067 + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
2068 .accel_max_scale = 8,
2069 .temp_scale = 12500, /* 12.5 milli degree Celsius */
2070 .int_clk = 4250000,
2071 @@ -851,9 +856,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
2072 [ADIS16495_2] = {
2073 .channels = adis16485_channels,
2074 .num_channels = ARRAY_SIZE(adis16485_channels),
2075 - .gyro_max_val = IIO_RAD_TO_DEGREE(18000),
2076 - .gyro_max_scale = 450,
2077 - .accel_max_val = IIO_M_S_2_TO_G(32000),
2078 + .gyro_max_val = 18000 << 16,
2079 + .gyro_max_scale = IIO_DEGREE_TO_RAD(450),
2080 + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
2081 .accel_max_scale = 8,
2082 .temp_scale = 12500, /* 12.5 milli degree Celsius */
2083 .int_clk = 4250000,
2084 @@ -864,9 +869,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
2085 [ADIS16495_3] = {
2086 .channels = adis16485_channels,
2087 .num_channels = ARRAY_SIZE(adis16485_channels),
2088 - .gyro_max_val = IIO_RAD_TO_DEGREE(20000),
2089 - .gyro_max_scale = 2000,
2090 - .accel_max_val = IIO_M_S_2_TO_G(32000),
2091 + .gyro_max_val = 20000 << 16,
2092 + .gyro_max_scale = IIO_DEGREE_TO_RAD(2000),
2093 + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
2094 .accel_max_scale = 8,
2095 .temp_scale = 12500, /* 12.5 milli degree Celsius */
2096 .int_clk = 4250000,
2097 @@ -877,9 +882,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
2098 [ADIS16497_1] = {
2099 .channels = adis16485_channels,
2100 .num_channels = ARRAY_SIZE(adis16485_channels),
2101 - .gyro_max_val = IIO_RAD_TO_DEGREE(20000),
2102 - .gyro_max_scale = 125,
2103 - .accel_max_val = IIO_M_S_2_TO_G(32000),
2104 + .gyro_max_val = 20000 << 16,
2105 + .gyro_max_scale = IIO_DEGREE_TO_RAD(125),
2106 + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
2107 .accel_max_scale = 40,
2108 .temp_scale = 12500, /* 12.5 milli degree Celsius */
2109 .int_clk = 4250000,
2110 @@ -890,9 +895,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
2111 [ADIS16497_2] = {
2112 .channels = adis16485_channels,
2113 .num_channels = ARRAY_SIZE(adis16485_channels),
2114 - .gyro_max_val = IIO_RAD_TO_DEGREE(18000),
2115 - .gyro_max_scale = 450,
2116 - .accel_max_val = IIO_M_S_2_TO_G(32000),
2117 + .gyro_max_val = 18000 << 16,
2118 + .gyro_max_scale = IIO_DEGREE_TO_RAD(450),
2119 + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
2120 .accel_max_scale = 40,
2121 .temp_scale = 12500, /* 12.5 milli degree Celsius */
2122 .int_clk = 4250000,
2123 @@ -903,9 +908,9 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
2124 [ADIS16497_3] = {
2125 .channels = adis16485_channels,
2126 .num_channels = ARRAY_SIZE(adis16485_channels),
2127 - .gyro_max_val = IIO_RAD_TO_DEGREE(20000),
2128 - .gyro_max_scale = 2000,
2129 - .accel_max_val = IIO_M_S_2_TO_G(32000),
2130 + .gyro_max_val = 20000 << 16,
2131 + .gyro_max_scale = IIO_DEGREE_TO_RAD(2000),
2132 + .accel_max_val = IIO_M_S_2_TO_G(32000 << 16),
2133 .accel_max_scale = 40,
2134 .temp_scale = 12500, /* 12.5 milli degree Celsius */
2135 .int_clk = 4250000,
2136 @@ -919,6 +924,7 @@ static const struct iio_info adis16480_info = {
2137 .read_raw = &adis16480_read_raw,
2138 .write_raw = &adis16480_write_raw,
2139 .update_scan_mode = adis_update_scan_mode,
2140 + .debugfs_reg_access = adis_debugfs_reg_access,
2141 };
2142
2143 static int adis16480_stop_device(struct iio_dev *indio_dev)
2144 diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
2145 index 868281b8adb0..2261c6c4ac65 100644
2146 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
2147 +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
2148 @@ -115,6 +115,7 @@ static const struct inv_mpu6050_hw hw_info[] = {
2149 .reg = &reg_set_6050,
2150 .config = &chip_config_6050,
2151 .fifo_size = 1024,
2152 + .temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
2153 },
2154 {
2155 .whoami = INV_MPU6500_WHOAMI_VALUE,
2156 @@ -122,6 +123,7 @@ static const struct inv_mpu6050_hw hw_info[] = {
2157 .reg = &reg_set_6500,
2158 .config = &chip_config_6050,
2159 .fifo_size = 512,
2160 + .temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
2161 },
2162 {
2163 .whoami = INV_MPU6515_WHOAMI_VALUE,
2164 @@ -129,6 +131,7 @@ static const struct inv_mpu6050_hw hw_info[] = {
2165 .reg = &reg_set_6500,
2166 .config = &chip_config_6050,
2167 .fifo_size = 512,
2168 + .temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
2169 },
2170 {
2171 .whoami = INV_MPU6000_WHOAMI_VALUE,
2172 @@ -136,6 +139,7 @@ static const struct inv_mpu6050_hw hw_info[] = {
2173 .reg = &reg_set_6050,
2174 .config = &chip_config_6050,
2175 .fifo_size = 1024,
2176 + .temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
2177 },
2178 {
2179 .whoami = INV_MPU9150_WHOAMI_VALUE,
2180 @@ -143,6 +147,7 @@ static const struct inv_mpu6050_hw hw_info[] = {
2181 .reg = &reg_set_6050,
2182 .config = &chip_config_6050,
2183 .fifo_size = 1024,
2184 + .temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
2185 },
2186 {
2187 .whoami = INV_MPU9250_WHOAMI_VALUE,
2188 @@ -150,6 +155,7 @@ static const struct inv_mpu6050_hw hw_info[] = {
2189 .reg = &reg_set_6500,
2190 .config = &chip_config_6050,
2191 .fifo_size = 512,
2192 + .temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
2193 },
2194 {
2195 .whoami = INV_MPU9255_WHOAMI_VALUE,
2196 @@ -157,6 +163,7 @@ static const struct inv_mpu6050_hw hw_info[] = {
2197 .reg = &reg_set_6500,
2198 .config = &chip_config_6050,
2199 .fifo_size = 512,
2200 + .temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
2201 },
2202 {
2203 .whoami = INV_ICM20608_WHOAMI_VALUE,
2204 @@ -164,6 +171,7 @@ static const struct inv_mpu6050_hw hw_info[] = {
2205 .reg = &reg_set_6500,
2206 .config = &chip_config_6050,
2207 .fifo_size = 512,
2208 + .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
2209 },
2210 {
2211 .whoami = INV_ICM20602_WHOAMI_VALUE,
2212 @@ -171,6 +179,7 @@ static const struct inv_mpu6050_hw hw_info[] = {
2213 .reg = &reg_set_icm20602,
2214 .config = &chip_config_6050,
2215 .fifo_size = 1008,
2216 + .temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
2217 },
2218 };
2219
2220 @@ -471,12 +480,8 @@ inv_mpu6050_read_raw(struct iio_dev *indio_dev,
2221
2222 return IIO_VAL_INT_PLUS_MICRO;
2223 case IIO_TEMP:
2224 - *val = 0;
2225 - if (st->chip_type == INV_ICM20602)
2226 - *val2 = INV_ICM20602_TEMP_SCALE;
2227 - else
2228 - *val2 = INV_MPU6050_TEMP_SCALE;
2229 -
2230 + *val = st->hw->temp.scale / 1000000;
2231 + *val2 = st->hw->temp.scale % 1000000;
2232 return IIO_VAL_INT_PLUS_MICRO;
2233 default:
2234 return -EINVAL;
2235 @@ -484,11 +489,7 @@ inv_mpu6050_read_raw(struct iio_dev *indio_dev,
2236 case IIO_CHAN_INFO_OFFSET:
2237 switch (chan->type) {
2238 case IIO_TEMP:
2239 - if (st->chip_type == INV_ICM20602)
2240 - *val = INV_ICM20602_TEMP_OFFSET;
2241 - else
2242 - *val = INV_MPU6050_TEMP_OFFSET;
2243 -
2244 + *val = st->hw->temp.offset;
2245 return IIO_VAL_INT;
2246 default:
2247 return -EINVAL;
2248 diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
2249 index 51235677c534..c32bd0c012b5 100644
2250 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
2251 +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
2252 @@ -101,6 +101,7 @@ struct inv_mpu6050_chip_config {
2253 * @reg: register map of the chip.
2254 * @config: configuration of the chip.
2255 * @fifo_size: size of the FIFO in bytes.
2256 + * @temp: offset and scale to apply to raw temperature.
2257 */
2258 struct inv_mpu6050_hw {
2259 u8 whoami;
2260 @@ -108,6 +109,10 @@ struct inv_mpu6050_hw {
2261 const struct inv_mpu6050_reg_map *reg;
2262 const struct inv_mpu6050_chip_config *config;
2263 size_t fifo_size;
2264 + struct {
2265 + int offset;
2266 + int scale;
2267 + } temp;
2268 };
2269
2270 /*
2271 @@ -218,16 +223,19 @@ struct inv_mpu6050_state {
2272 #define INV_MPU6050_REG_UP_TIME_MIN 5000
2273 #define INV_MPU6050_REG_UP_TIME_MAX 10000
2274
2275 -#define INV_MPU6050_TEMP_OFFSET 12421
2276 -#define INV_MPU6050_TEMP_SCALE 2941
2277 +#define INV_MPU6050_TEMP_OFFSET 12420
2278 +#define INV_MPU6050_TEMP_SCALE 2941176
2279 #define INV_MPU6050_MAX_GYRO_FS_PARAM 3
2280 #define INV_MPU6050_MAX_ACCL_FS_PARAM 3
2281 #define INV_MPU6050_THREE_AXIS 3
2282 #define INV_MPU6050_GYRO_CONFIG_FSR_SHIFT 3
2283 #define INV_MPU6050_ACCL_CONFIG_FSR_SHIFT 3
2284
2285 -#define INV_ICM20602_TEMP_OFFSET 8170
2286 -#define INV_ICM20602_TEMP_SCALE 3060
2287 +#define INV_MPU6500_TEMP_OFFSET 7011
2288 +#define INV_MPU6500_TEMP_SCALE 2995178
2289 +
2290 +#define INV_ICM20608_TEMP_OFFSET 8170
2291 +#define INV_ICM20608_TEMP_SCALE 3059976
2292
2293 /* 6 + 6 round up and plus 8 */
2294 #define INV_MPU6050_OUTPUT_DATA_SIZE 24
2295 diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
2296 index fd5ebe1e1594..28e011b35f21 100644
2297 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
2298 +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
2299 @@ -985,8 +985,7 @@ int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u16 odr, u8 *val)
2300 return -EINVAL;
2301
2302 *val = odr_table->odr_avl[i].val;
2303 -
2304 - return 0;
2305 + return odr_table->odr_avl[i].hz;
2306 }
2307
2308 static u16 st_lsm6dsx_check_odr_dependency(struct st_lsm6dsx_hw *hw, u16 odr,
2309 @@ -1149,8 +1148,10 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev,
2310 case IIO_CHAN_INFO_SAMP_FREQ: {
2311 u8 data;
2312
2313 - err = st_lsm6dsx_check_odr(sensor, val, &data);
2314 - if (!err)
2315 + val = st_lsm6dsx_check_odr(sensor, val, &data);
2316 + if (val < 0)
2317 + err = val;
2318 + else
2319 sensor->odr = val;
2320 break;
2321 }
2322 diff --git a/drivers/interconnect/qcom/qcs404.c b/drivers/interconnect/qcom/qcs404.c
2323 index b4966d8f3348..8e0735a87040 100644
2324 --- a/drivers/interconnect/qcom/qcs404.c
2325 +++ b/drivers/interconnect/qcom/qcs404.c
2326 @@ -414,7 +414,7 @@ static int qnoc_probe(struct platform_device *pdev)
2327 struct icc_provider *provider;
2328 struct qcom_icc_node **qnodes;
2329 struct qcom_icc_provider *qp;
2330 - struct icc_node *node;
2331 + struct icc_node *node, *tmp;
2332 size_t num_nodes, i;
2333 int ret;
2334
2335 @@ -494,7 +494,7 @@ static int qnoc_probe(struct platform_device *pdev)
2336
2337 return 0;
2338 err:
2339 - list_for_each_entry(node, &provider->nodes, node_list) {
2340 + list_for_each_entry_safe(node, tmp, &provider->nodes, node_list) {
2341 icc_node_del(node);
2342 icc_node_destroy(node->id);
2343 }
2344 @@ -508,9 +508,9 @@ static int qnoc_remove(struct platform_device *pdev)
2345 {
2346 struct qcom_icc_provider *qp = platform_get_drvdata(pdev);
2347 struct icc_provider *provider = &qp->provider;
2348 - struct icc_node *n;
2349 + struct icc_node *n, *tmp;
2350
2351 - list_for_each_entry(n, &provider->nodes, node_list) {
2352 + list_for_each_entry_safe(n, tmp, &provider->nodes, node_list) {
2353 icc_node_del(n);
2354 icc_node_destroy(n->id);
2355 }
2356 diff --git a/drivers/interconnect/qcom/sdm845.c b/drivers/interconnect/qcom/sdm845.c
2357 index 502a6c22b41e..387267ee9648 100644
2358 --- a/drivers/interconnect/qcom/sdm845.c
2359 +++ b/drivers/interconnect/qcom/sdm845.c
2360 @@ -868,9 +868,9 @@ static int qnoc_remove(struct platform_device *pdev)
2361 {
2362 struct qcom_icc_provider *qp = platform_get_drvdata(pdev);
2363 struct icc_provider *provider = &qp->provider;
2364 - struct icc_node *n;
2365 + struct icc_node *n, *tmp;
2366
2367 - list_for_each_entry(n, &provider->nodes, node_list) {
2368 + list_for_each_entry_safe(n, tmp, &provider->nodes, node_list) {
2369 icc_node_del(n);
2370 icc_node_destroy(n->id);
2371 }
2372 diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
2373 index d06b8aa41e26..43d1af1d8173 100644
2374 --- a/drivers/md/dm-writecache.c
2375 +++ b/drivers/md/dm-writecache.c
2376 @@ -1218,7 +1218,8 @@ bio_copy:
2377 }
2378 } while (bio->bi_iter.bi_size);
2379
2380 - if (unlikely(wc->uncommitted_blocks >= wc->autocommit_blocks))
2381 + if (unlikely(bio->bi_opf & REQ_FUA ||
2382 + wc->uncommitted_blocks >= wc->autocommit_blocks))
2383 writecache_flush(wc);
2384 else
2385 writecache_schedule_autocommit(wc);
2386 diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
2387 index 595a73110e17..ac1179ca80d9 100644
2388 --- a/drivers/md/dm-zoned-metadata.c
2389 +++ b/drivers/md/dm-zoned-metadata.c
2390 @@ -554,6 +554,7 @@ static struct dmz_mblock *dmz_get_mblock(struct dmz_metadata *zmd,
2391 TASK_UNINTERRUPTIBLE);
2392 if (test_bit(DMZ_META_ERROR, &mblk->state)) {
2393 dmz_release_mblock(zmd, mblk);
2394 + dmz_check_bdev(zmd->dev);
2395 return ERR_PTR(-EIO);
2396 }
2397
2398 @@ -625,6 +626,8 @@ static int dmz_rdwr_block(struct dmz_metadata *zmd, int op, sector_t block,
2399 ret = submit_bio_wait(bio);
2400 bio_put(bio);
2401
2402 + if (ret)
2403 + dmz_check_bdev(zmd->dev);
2404 return ret;
2405 }
2406
2407 @@ -691,6 +694,7 @@ static int dmz_write_dirty_mblocks(struct dmz_metadata *zmd,
2408 TASK_UNINTERRUPTIBLE);
2409 if (test_bit(DMZ_META_ERROR, &mblk->state)) {
2410 clear_bit(DMZ_META_ERROR, &mblk->state);
2411 + dmz_check_bdev(zmd->dev);
2412 ret = -EIO;
2413 }
2414 nr_mblks_submitted--;
2415 @@ -768,7 +772,7 @@ int dmz_flush_metadata(struct dmz_metadata *zmd)
2416 /* If there are no dirty metadata blocks, just flush the device cache */
2417 if (list_empty(&write_list)) {
2418 ret = blkdev_issue_flush(zmd->dev->bdev, GFP_NOIO, NULL);
2419 - goto out;
2420 + goto err;
2421 }
2422
2423 /*
2424 @@ -778,7 +782,7 @@ int dmz_flush_metadata(struct dmz_metadata *zmd)
2425 */
2426 ret = dmz_log_dirty_mblocks(zmd, &write_list);
2427 if (ret)
2428 - goto out;
2429 + goto err;
2430
2431 /*
2432 * The log is on disk. It is now safe to update in place
2433 @@ -786,11 +790,11 @@ int dmz_flush_metadata(struct dmz_metadata *zmd)
2434 */
2435 ret = dmz_write_dirty_mblocks(zmd, &write_list, zmd->mblk_primary);
2436 if (ret)
2437 - goto out;
2438 + goto err;
2439
2440 ret = dmz_write_sb(zmd, zmd->mblk_primary);
2441 if (ret)
2442 - goto out;
2443 + goto err;
2444
2445 while (!list_empty(&write_list)) {
2446 mblk = list_first_entry(&write_list, struct dmz_mblock, link);
2447 @@ -805,16 +809,20 @@ int dmz_flush_metadata(struct dmz_metadata *zmd)
2448
2449 zmd->sb_gen++;
2450 out:
2451 - if (ret && !list_empty(&write_list)) {
2452 - spin_lock(&zmd->mblk_lock);
2453 - list_splice(&write_list, &zmd->mblk_dirty_list);
2454 - spin_unlock(&zmd->mblk_lock);
2455 - }
2456 -
2457 dmz_unlock_flush(zmd);
2458 up_write(&zmd->mblk_sem);
2459
2460 return ret;
2461 +
2462 +err:
2463 + if (!list_empty(&write_list)) {
2464 + spin_lock(&zmd->mblk_lock);
2465 + list_splice(&write_list, &zmd->mblk_dirty_list);
2466 + spin_unlock(&zmd->mblk_lock);
2467 + }
2468 + if (!dmz_check_bdev(zmd->dev))
2469 + ret = -EIO;
2470 + goto out;
2471 }
2472
2473 /*
2474 @@ -1244,6 +1252,7 @@ static int dmz_update_zone(struct dmz_metadata *zmd, struct dm_zone *zone)
2475 if (ret) {
2476 dmz_dev_err(zmd->dev, "Get zone %u report failed",
2477 dmz_id(zmd, zone));
2478 + dmz_check_bdev(zmd->dev);
2479 return ret;
2480 }
2481
2482 diff --git a/drivers/md/dm-zoned-reclaim.c b/drivers/md/dm-zoned-reclaim.c
2483 index d240d7ca8a8a..e7ace908a9b7 100644
2484 --- a/drivers/md/dm-zoned-reclaim.c
2485 +++ b/drivers/md/dm-zoned-reclaim.c
2486 @@ -82,6 +82,7 @@ static int dmz_reclaim_align_wp(struct dmz_reclaim *zrc, struct dm_zone *zone,
2487 "Align zone %u wp %llu to %llu (wp+%u) blocks failed %d",
2488 dmz_id(zmd, zone), (unsigned long long)wp_block,
2489 (unsigned long long)block, nr_blocks, ret);
2490 + dmz_check_bdev(zrc->dev);
2491 return ret;
2492 }
2493
2494 @@ -489,12 +490,7 @@ static void dmz_reclaim_work(struct work_struct *work)
2495 ret = dmz_do_reclaim(zrc);
2496 if (ret) {
2497 dmz_dev_debug(zrc->dev, "Reclaim error %d\n", ret);
2498 - if (ret == -EIO)
2499 - /*
2500 - * LLD might be performing some error handling sequence
2501 - * at the underlying device. To not interfere, do not
2502 - * attempt to schedule the next reclaim run immediately.
2503 - */
2504 + if (!dmz_check_bdev(zrc->dev))
2505 return;
2506 }
2507
2508 diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
2509 index d3bcc4197f5d..4574e0dedbd6 100644
2510 --- a/drivers/md/dm-zoned-target.c
2511 +++ b/drivers/md/dm-zoned-target.c
2512 @@ -80,6 +80,8 @@ static inline void dmz_bio_endio(struct bio *bio, blk_status_t status)
2513
2514 if (status != BLK_STS_OK && bio->bi_status == BLK_STS_OK)
2515 bio->bi_status = status;
2516 + if (bio->bi_status != BLK_STS_OK)
2517 + bioctx->target->dev->flags |= DMZ_CHECK_BDEV;
2518
2519 if (refcount_dec_and_test(&bioctx->ref)) {
2520 struct dm_zone *zone = bioctx->zone;
2521 @@ -565,31 +567,51 @@ out:
2522 }
2523
2524 /*
2525 - * Check the backing device availability. If it's on the way out,
2526 + * Check if the backing device is being removed. If it's on the way out,
2527 * start failing I/O. Reclaim and metadata components also call this
2528 * function to cleanly abort operation in the event of such failure.
2529 */
2530 bool dmz_bdev_is_dying(struct dmz_dev *dmz_dev)
2531 {
2532 - struct gendisk *disk;
2533 + if (dmz_dev->flags & DMZ_BDEV_DYING)
2534 + return true;
2535
2536 - if (!(dmz_dev->flags & DMZ_BDEV_DYING)) {
2537 - disk = dmz_dev->bdev->bd_disk;
2538 - if (blk_queue_dying(bdev_get_queue(dmz_dev->bdev))) {
2539 - dmz_dev_warn(dmz_dev, "Backing device queue dying");
2540 - dmz_dev->flags |= DMZ_BDEV_DYING;
2541 - } else if (disk->fops->check_events) {
2542 - if (disk->fops->check_events(disk, 0) &
2543 - DISK_EVENT_MEDIA_CHANGE) {
2544 - dmz_dev_warn(dmz_dev, "Backing device offline");
2545 - dmz_dev->flags |= DMZ_BDEV_DYING;
2546 - }
2547 - }
2548 + if (dmz_dev->flags & DMZ_CHECK_BDEV)
2549 + return !dmz_check_bdev(dmz_dev);
2550 +
2551 + if (blk_queue_dying(bdev_get_queue(dmz_dev->bdev))) {
2552 + dmz_dev_warn(dmz_dev, "Backing device queue dying");
2553 + dmz_dev->flags |= DMZ_BDEV_DYING;
2554 }
2555
2556 return dmz_dev->flags & DMZ_BDEV_DYING;
2557 }
2558
2559 +/*
2560 + * Check the backing device availability. This detects such events as
2561 + * backing device going offline due to errors, media removals, etc.
2562 + * This check is less efficient than dmz_bdev_is_dying() and should
2563 + * only be performed as a part of error handling.
2564 + */
2565 +bool dmz_check_bdev(struct dmz_dev *dmz_dev)
2566 +{
2567 + struct gendisk *disk;
2568 +
2569 + dmz_dev->flags &= ~DMZ_CHECK_BDEV;
2570 +
2571 + if (dmz_bdev_is_dying(dmz_dev))
2572 + return false;
2573 +
2574 + disk = dmz_dev->bdev->bd_disk;
2575 + if (disk->fops->check_events &&
2576 + disk->fops->check_events(disk, 0) & DISK_EVENT_MEDIA_CHANGE) {
2577 + dmz_dev_warn(dmz_dev, "Backing device offline");
2578 + dmz_dev->flags |= DMZ_BDEV_DYING;
2579 + }
2580 +
2581 + return !(dmz_dev->flags & DMZ_BDEV_DYING);
2582 +}
2583 +
2584 /*
2585 * Process a new BIO.
2586 */
2587 @@ -902,8 +924,8 @@ static int dmz_prepare_ioctl(struct dm_target *ti, struct block_device **bdev)
2588 {
2589 struct dmz_target *dmz = ti->private;
2590
2591 - if (dmz_bdev_is_dying(dmz->dev))
2592 - return -ENODEV;
2593 + if (!dmz_check_bdev(dmz->dev))
2594 + return -EIO;
2595
2596 *bdev = dmz->dev->bdev;
2597
2598 diff --git a/drivers/md/dm-zoned.h b/drivers/md/dm-zoned.h
2599 index d8e70b0ade35..5b5e493d479c 100644
2600 --- a/drivers/md/dm-zoned.h
2601 +++ b/drivers/md/dm-zoned.h
2602 @@ -72,6 +72,7 @@ struct dmz_dev {
2603
2604 /* Device flags. */
2605 #define DMZ_BDEV_DYING (1 << 0)
2606 +#define DMZ_CHECK_BDEV (2 << 0)
2607
2608 /*
2609 * Zone descriptor.
2610 @@ -255,5 +256,6 @@ void dmz_schedule_reclaim(struct dmz_reclaim *zrc);
2611 * Functions defined in dm-zoned-target.c
2612 */
2613 bool dmz_bdev_is_dying(struct dmz_dev *dmz_dev);
2614 +bool dmz_check_bdev(struct dmz_dev *dmz_dev);
2615
2616 #endif /* DM_ZONED_H */
2617 diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
2618 index c766c559d36d..26c75c0199fa 100644
2619 --- a/drivers/md/md-linear.c
2620 +++ b/drivers/md/md-linear.c
2621 @@ -244,10 +244,9 @@ static bool linear_make_request(struct mddev *mddev, struct bio *bio)
2622 sector_t start_sector, end_sector, data_offset;
2623 sector_t bio_sector = bio->bi_iter.bi_sector;
2624
2625 - if (unlikely(bio->bi_opf & REQ_PREFLUSH)) {
2626 - md_flush_request(mddev, bio);
2627 + if (unlikely(bio->bi_opf & REQ_PREFLUSH)
2628 + && md_flush_request(mddev, bio))
2629 return true;
2630 - }
2631
2632 tmp_dev = which_dev(mddev, bio_sector);
2633 start_sector = tmp_dev->end_sector - tmp_dev->rdev->sectors;
2634 diff --git a/drivers/md/md-multipath.c b/drivers/md/md-multipath.c
2635 index 6780938d2991..152f9e65a226 100644
2636 --- a/drivers/md/md-multipath.c
2637 +++ b/drivers/md/md-multipath.c
2638 @@ -104,10 +104,9 @@ static bool multipath_make_request(struct mddev *mddev, struct bio * bio)
2639 struct multipath_bh * mp_bh;
2640 struct multipath_info *multipath;
2641
2642 - if (unlikely(bio->bi_opf & REQ_PREFLUSH)) {
2643 - md_flush_request(mddev, bio);
2644 + if (unlikely(bio->bi_opf & REQ_PREFLUSH)
2645 + && md_flush_request(mddev, bio))
2646 return true;
2647 - }
2648
2649 mp_bh = mempool_alloc(&conf->pool, GFP_NOIO);
2650
2651 diff --git a/drivers/md/md.c b/drivers/md/md.c
2652 index 1be7abeb24fd..b8dd56b746da 100644
2653 --- a/drivers/md/md.c
2654 +++ b/drivers/md/md.c
2655 @@ -550,7 +550,13 @@ static void md_submit_flush_data(struct work_struct *ws)
2656 }
2657 }
2658
2659 -void md_flush_request(struct mddev *mddev, struct bio *bio)
2660 +/*
2661 + * Manages consolidation of flushes and submitting any flushes needed for
2662 + * a bio with REQ_PREFLUSH. Returns true if the bio is finished or is
2663 + * being finished in another context. Returns false if the flushing is
2664 + * complete but still needs the I/O portion of the bio to be processed.
2665 + */
2666 +bool md_flush_request(struct mddev *mddev, struct bio *bio)
2667 {
2668 ktime_t start = ktime_get_boottime();
2669 spin_lock_irq(&mddev->lock);
2670 @@ -575,9 +581,10 @@ void md_flush_request(struct mddev *mddev, struct bio *bio)
2671 bio_endio(bio);
2672 else {
2673 bio->bi_opf &= ~REQ_PREFLUSH;
2674 - mddev->pers->make_request(mddev, bio);
2675 + return false;
2676 }
2677 }
2678 + return true;
2679 }
2680 EXPORT_SYMBOL(md_flush_request);
2681
2682 diff --git a/drivers/md/md.h b/drivers/md/md.h
2683 index c5e3ff398b59..5f86f8adb0a4 100644
2684 --- a/drivers/md/md.h
2685 +++ b/drivers/md/md.h
2686 @@ -550,7 +550,7 @@ struct md_personality
2687 int level;
2688 struct list_head list;
2689 struct module *owner;
2690 - bool (*make_request)(struct mddev *mddev, struct bio *bio);
2691 + bool __must_check (*make_request)(struct mddev *mddev, struct bio *bio);
2692 /*
2693 * start up works that do NOT require md_thread. tasks that
2694 * requires md_thread should go into start()
2695 @@ -703,7 +703,7 @@ extern void md_error(struct mddev *mddev, struct md_rdev *rdev);
2696 extern void md_finish_reshape(struct mddev *mddev);
2697
2698 extern int mddev_congested(struct mddev *mddev, int bits);
2699 -extern void md_flush_request(struct mddev *mddev, struct bio *bio);
2700 +extern bool __must_check md_flush_request(struct mddev *mddev, struct bio *bio);
2701 extern void md_super_write(struct mddev *mddev, struct md_rdev *rdev,
2702 sector_t sector, int size, struct page *page);
2703 extern int md_super_wait(struct mddev *mddev);
2704 diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
2705 index aa88bdeb9978..b7c20979bd19 100644
2706 --- a/drivers/md/raid0.c
2707 +++ b/drivers/md/raid0.c
2708 @@ -575,10 +575,9 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio)
2709 unsigned chunk_sects;
2710 unsigned sectors;
2711
2712 - if (unlikely(bio->bi_opf & REQ_PREFLUSH)) {
2713 - md_flush_request(mddev, bio);
2714 + if (unlikely(bio->bi_opf & REQ_PREFLUSH)
2715 + && md_flush_request(mddev, bio))
2716 return true;
2717 - }
2718
2719 if (unlikely((bio_op(bio) == REQ_OP_DISCARD))) {
2720 raid0_handle_discard(mddev, bio);
2721 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
2722 index 0466ee2453b4..bb29aeefcbd0 100644
2723 --- a/drivers/md/raid1.c
2724 +++ b/drivers/md/raid1.c
2725 @@ -1567,10 +1567,9 @@ static bool raid1_make_request(struct mddev *mddev, struct bio *bio)
2726 {
2727 sector_t sectors;
2728
2729 - if (unlikely(bio->bi_opf & REQ_PREFLUSH)) {
2730 - md_flush_request(mddev, bio);
2731 + if (unlikely(bio->bi_opf & REQ_PREFLUSH)
2732 + && md_flush_request(mddev, bio))
2733 return true;
2734 - }
2735
2736 /*
2737 * There is a limit to the maximum size, but
2738 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
2739 index 8a62c920bb65..ec136e44aef7 100644
2740 --- a/drivers/md/raid10.c
2741 +++ b/drivers/md/raid10.c
2742 @@ -1525,10 +1525,9 @@ static bool raid10_make_request(struct mddev *mddev, struct bio *bio)
2743 int chunk_sects = chunk_mask + 1;
2744 int sectors = bio_sectors(bio);
2745
2746 - if (unlikely(bio->bi_opf & REQ_PREFLUSH)) {
2747 - md_flush_request(mddev, bio);
2748 + if (unlikely(bio->bi_opf & REQ_PREFLUSH)
2749 + && md_flush_request(mddev, bio))
2750 return true;
2751 - }
2752
2753 if (!md_write_start(mddev, bio))
2754 return false;
2755 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
2756 index 223e97ab27e6..12a8ce83786e 100644
2757 --- a/drivers/md/raid5.c
2758 +++ b/drivers/md/raid5.c
2759 @@ -5592,8 +5592,8 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
2760 if (ret == 0)
2761 return true;
2762 if (ret == -ENODEV) {
2763 - md_flush_request(mddev, bi);
2764 - return true;
2765 + if (md_flush_request(mddev, bi))
2766 + return true;
2767 }
2768 /* ret == -EAGAIN, fallback */
2769 /*
2770 diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
2771 index 7f4660555ddb..59ae7a1e63bc 100644
2772 --- a/drivers/media/platform/qcom/venus/vdec.c
2773 +++ b/drivers/media/platform/qcom/venus/vdec.c
2774 @@ -1412,9 +1412,6 @@ static const struct v4l2_file_operations vdec_fops = {
2775 .unlocked_ioctl = video_ioctl2,
2776 .poll = v4l2_m2m_fop_poll,
2777 .mmap = v4l2_m2m_fop_mmap,
2778 -#ifdef CONFIG_COMPAT
2779 - .compat_ioctl32 = v4l2_compat_ioctl32,
2780 -#endif
2781 };
2782
2783 static int vdec_probe(struct platform_device *pdev)
2784 diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
2785 index 1b7fb2d5887c..30028ceb548b 100644
2786 --- a/drivers/media/platform/qcom/venus/venc.c
2787 +++ b/drivers/media/platform/qcom/venus/venc.c
2788 @@ -1235,9 +1235,6 @@ static const struct v4l2_file_operations venc_fops = {
2789 .unlocked_ioctl = video_ioctl2,
2790 .poll = v4l2_m2m_fop_poll,
2791 .mmap = v4l2_m2m_fop_mmap,
2792 -#ifdef CONFIG_COMPAT
2793 - .compat_ioctl32 = v4l2_compat_ioctl32,
2794 -#endif
2795 };
2796
2797 static int venc_probe(struct platform_device *pdev)
2798 diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
2799 index e90f1ba30574..675b5f2b4c2e 100644
2800 --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
2801 +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
2802 @@ -651,8 +651,7 @@ static int bdisp_release(struct file *file)
2803
2804 dev_dbg(bdisp->dev, "%s\n", __func__);
2805
2806 - if (mutex_lock_interruptible(&bdisp->lock))
2807 - return -ERESTARTSYS;
2808 + mutex_lock(&bdisp->lock);
2809
2810 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
2811
2812 diff --git a/drivers/media/platform/vimc/vimc-sensor.c b/drivers/media/platform/vimc/vimc-sensor.c
2813 index 6c53b9fc1617..4a6a7e8e66c2 100644
2814 --- a/drivers/media/platform/vimc/vimc-sensor.c
2815 +++ b/drivers/media/platform/vimc/vimc-sensor.c
2816 @@ -25,7 +25,6 @@ struct vimc_sen_device {
2817 struct v4l2_subdev sd;
2818 struct device *dev;
2819 struct tpg_data tpg;
2820 - struct task_struct *kthread_sen;
2821 u8 *frame;
2822 /* The active format */
2823 struct v4l2_mbus_framefmt mbus_format;
2824 @@ -208,10 +207,6 @@ static int vimc_sen_s_stream(struct v4l2_subdev *sd, int enable)
2825 const struct vimc_pix_map *vpix;
2826 unsigned int frame_size;
2827
2828 - if (vsen->kthread_sen)
2829 - /* tpg is already executing */
2830 - return 0;
2831 -
2832 /* Calculate the frame size */
2833 vpix = vimc_pix_map_by_code(vsen->mbus_format.code);
2834 frame_size = vsen->mbus_format.width * vpix->bpp *
2835 diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c
2836 index 104ac41c6f96..112376873167 100644
2837 --- a/drivers/media/radio/radio-wl1273.c
2838 +++ b/drivers/media/radio/radio-wl1273.c
2839 @@ -1148,8 +1148,7 @@ static int wl1273_fm_fops_release(struct file *file)
2840 if (radio->rds_users > 0) {
2841 radio->rds_users--;
2842 if (radio->rds_users == 0) {
2843 - if (mutex_lock_interruptible(&core->lock))
2844 - return -EINTR;
2845 + mutex_lock(&core->lock);
2846
2847 radio->irq_flags &= ~WL1273_RDS_EVENT;
2848
2849 diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
2850 index 952fa4063ff8..d0df054b0b47 100644
2851 --- a/drivers/mmc/host/omap_hsmmc.c
2852 +++ b/drivers/mmc/host/omap_hsmmc.c
2853 @@ -1512,6 +1512,36 @@ static void omap_hsmmc_init_card(struct mmc_host *mmc, struct mmc_card *card)
2854
2855 if (mmc_pdata(host)->init_card)
2856 mmc_pdata(host)->init_card(card);
2857 + else if (card->type == MMC_TYPE_SDIO ||
2858 + card->type == MMC_TYPE_SD_COMBO) {
2859 + struct device_node *np = mmc_dev(mmc)->of_node;
2860 +
2861 + /*
2862 + * REVISIT: should be moved to sdio core and made more
2863 + * general e.g. by expanding the DT bindings of child nodes
2864 + * to provide a mechanism to provide this information:
2865 + * Documentation/devicetree/bindings/mmc/mmc-card.txt
2866 + */
2867 +
2868 + np = of_get_compatible_child(np, "ti,wl1251");
2869 + if (np) {
2870 + /*
2871 + * We have TI wl1251 attached to MMC3. Pass this
2872 + * information to the SDIO core because it can't be
2873 + * probed by normal methods.
2874 + */
2875 +
2876 + dev_info(host->dev, "found wl1251\n");
2877 + card->quirks |= MMC_QUIRK_NONSTD_SDIO;
2878 + card->cccr.wide_bus = 1;
2879 + card->cis.vendor = 0x104c;
2880 + card->cis.device = 0x9066;
2881 + card->cis.blksize = 512;
2882 + card->cis.max_dtr = 24000000;
2883 + card->ocr = 0x80;
2884 + of_node_put(np);
2885 + }
2886 + }
2887 }
2888
2889 static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
2890 diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
2891 index 986f81d2f93e..47ad0766affa 100644
2892 --- a/drivers/mtd/devices/spear_smi.c
2893 +++ b/drivers/mtd/devices/spear_smi.c
2894 @@ -592,6 +592,26 @@ static int spear_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
2895 return 0;
2896 }
2897
2898 +/*
2899 + * The purpose of this function is to ensure a memcpy_toio() with byte writes
2900 + * only. Its structure is inspired from the ARM implementation of _memcpy_toio()
2901 + * which also does single byte writes but cannot be used here as this is just an
2902 + * implementation detail and not part of the API. Not mentioning the comment
2903 + * stating that _memcpy_toio() should be optimized.
2904 + */
2905 +static void spear_smi_memcpy_toio_b(volatile void __iomem *dest,
2906 + const void *src, size_t len)
2907 +{
2908 + const unsigned char *from = src;
2909 +
2910 + while (len) {
2911 + len--;
2912 + writeb(*from, dest);
2913 + from++;
2914 + dest++;
2915 + }
2916 +}
2917 +
2918 static inline int spear_smi_cpy_toio(struct spear_smi *dev, u32 bank,
2919 void __iomem *dest, const void *src, size_t len)
2920 {
2921 @@ -614,7 +634,23 @@ static inline int spear_smi_cpy_toio(struct spear_smi *dev, u32 bank,
2922 ctrlreg1 = readl(dev->io_base + SMI_CR1);
2923 writel((ctrlreg1 | WB_MODE) & ~SW_MODE, dev->io_base + SMI_CR1);
2924
2925 - memcpy_toio(dest, src, len);
2926 + /*
2927 + * In Write Burst mode (WB_MODE), the specs states that writes must be:
2928 + * - incremental
2929 + * - of the same size
2930 + * The ARM implementation of memcpy_toio() will optimize the number of
2931 + * I/O by using as much 4-byte writes as possible, surrounded by
2932 + * 2-byte/1-byte access if:
2933 + * - the destination is not 4-byte aligned
2934 + * - the length is not a multiple of 4-byte.
2935 + * Avoid this alternance of write access size by using our own 'byte
2936 + * access' helper if at least one of the two conditions above is true.
2937 + */
2938 + if (IS_ALIGNED(len, sizeof(u32)) &&
2939 + IS_ALIGNED((uintptr_t)dest, sizeof(u32)))
2940 + memcpy_toio(dest, src, len);
2941 + else
2942 + spear_smi_memcpy_toio_b(dest, src, len);
2943
2944 writel(ctrlreg1, dev->io_base + SMI_CR1);
2945
2946 diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
2947 index 5c2c30a7dffa..f64e3b6605c6 100644
2948 --- a/drivers/mtd/nand/raw/nand_base.c
2949 +++ b/drivers/mtd/nand/raw/nand_base.c
2950 @@ -292,12 +292,16 @@ int nand_bbm_get_next_page(struct nand_chip *chip, int page)
2951 struct mtd_info *mtd = nand_to_mtd(chip);
2952 int last_page = ((mtd->erasesize - mtd->writesize) >>
2953 chip->page_shift) & chip->pagemask;
2954 + unsigned int bbm_flags = NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE
2955 + | NAND_BBM_LASTPAGE;
2956
2957 + if (page == 0 && !(chip->options & bbm_flags))
2958 + return 0;
2959 if (page == 0 && chip->options & NAND_BBM_FIRSTPAGE)
2960 return 0;
2961 - else if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
2962 + if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
2963 return 1;
2964 - else if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
2965 + if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
2966 return last_page;
2967
2968 return -EINVAL;
2969 diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c
2970 index 8ca9fad6e6ad..56654030ec7f 100644
2971 --- a/drivers/mtd/nand/raw/nand_micron.c
2972 +++ b/drivers/mtd/nand/raw/nand_micron.c
2973 @@ -446,8 +446,10 @@ static int micron_nand_init(struct nand_chip *chip)
2974 if (ret)
2975 goto err_free_manuf_data;
2976
2977 + chip->options |= NAND_BBM_FIRSTPAGE;
2978 +
2979 if (mtd->writesize == 2048)
2980 - chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;
2981 + chip->options |= NAND_BBM_SECONDPAGE;
2982
2983 ondie = micron_supports_on_die_ecc(chip);
2984
2985 diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
2986 index 1d67eeeab79d..235d51ea4d39 100644
2987 --- a/drivers/net/ethernet/realtek/r8169_main.c
2988 +++ b/drivers/net/ethernet/realtek/r8169_main.c
2989 @@ -4145,7 +4145,7 @@ static void rtl_hw_jumbo_disable(struct rtl8169_private *tp)
2990 case RTL_GIGA_MAC_VER_27 ... RTL_GIGA_MAC_VER_28:
2991 r8168dp_hw_jumbo_disable(tp);
2992 break;
2993 - case RTL_GIGA_MAC_VER_31 ... RTL_GIGA_MAC_VER_34:
2994 + case RTL_GIGA_MAC_VER_31 ... RTL_GIGA_MAC_VER_33:
2995 r8168e_hw_jumbo_disable(tp);
2996 break;
2997 default:
2998 diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c b/drivers/net/wireless/ath/ar5523/ar5523.c
2999 index b94759daeacc..da2d179430ca 100644
3000 --- a/drivers/net/wireless/ath/ar5523/ar5523.c
3001 +++ b/drivers/net/wireless/ath/ar5523/ar5523.c
3002 @@ -255,7 +255,8 @@ static int ar5523_cmd(struct ar5523 *ar, u32 code, const void *idata,
3003
3004 if (flags & AR5523_CMD_FLAG_MAGIC)
3005 hdr->magic = cpu_to_be32(1 << 24);
3006 - memcpy(hdr + 1, idata, ilen);
3007 + if (ilen)
3008 + memcpy(hdr + 1, idata, ilen);
3009
3010 cmd->odata = odata;
3011 cmd->olen = olen;
3012 diff --git a/drivers/net/wireless/ath/wil6210/wmi.c b/drivers/net/wireless/ath/wil6210/wmi.c
3013 index 153b84447e40..41389c1eb252 100644
3014 --- a/drivers/net/wireless/ath/wil6210/wmi.c
3015 +++ b/drivers/net/wireless/ath/wil6210/wmi.c
3016 @@ -2505,7 +2505,8 @@ int wmi_set_ie(struct wil6210_vif *vif, u8 type, u16 ie_len, const void *ie)
3017 cmd->mgmt_frm_type = type;
3018 /* BUG: FW API define ieLen as u8. Will fix FW */
3019 cmd->ie_len = cpu_to_le16(ie_len);
3020 - memcpy(cmd->ie_info, ie, ie_len);
3021 + if (ie_len)
3022 + memcpy(cmd->ie_info, ie, ie_len);
3023 rc = wmi_send(wil, WMI_SET_APPIE_CMDID, vif->mid, cmd, len);
3024 kfree(cmd);
3025 out:
3026 @@ -2541,7 +2542,8 @@ int wmi_update_ft_ies(struct wil6210_vif *vif, u16 ie_len, const void *ie)
3027 }
3028
3029 cmd->ie_len = cpu_to_le16(ie_len);
3030 - memcpy(cmd->ie_info, ie, ie_len);
3031 + if (ie_len)
3032 + memcpy(cmd->ie_info, ie, ie_len);
3033 rc = wmi_send(wil, WMI_UPDATE_FT_IES_CMDID, vif->mid, cmd, len);
3034 kfree(cmd);
3035
3036 diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
3037 index 6c463475e90b..3be60aef5465 100644
3038 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
3039 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
3040 @@ -1427,6 +1427,8 @@ static int brcmf_pcie_reset(struct device *dev)
3041 struct brcmf_fw_request *fwreq;
3042 int err;
3043
3044 + brcmf_pcie_intr_disable(devinfo);
3045 +
3046 brcmf_pcie_bus_console_read(devinfo, true);
3047
3048 brcmf_detach(dev);
3049 diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
3050 index d80f71f82a6d..97cb3a8d505c 100644
3051 --- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
3052 +++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
3053 @@ -468,6 +468,7 @@ iwl_tfh_tfd *iwl_pcie_gen2_build_tx(struct iwl_trans *trans,
3054 dma_addr_t tb_phys;
3055 int len, tb1_len, tb2_len;
3056 void *tb1_addr;
3057 + struct sk_buff *frag;
3058
3059 tb_phys = iwl_pcie_get_first_tb_dma(txq, idx);
3060
3061 @@ -516,6 +517,19 @@ iwl_tfh_tfd *iwl_pcie_gen2_build_tx(struct iwl_trans *trans,
3062 if (iwl_pcie_gen2_tx_add_frags(trans, skb, tfd, out_meta))
3063 goto out_err;
3064
3065 + skb_walk_frags(skb, frag) {
3066 + tb_phys = dma_map_single(trans->dev, frag->data,
3067 + skb_headlen(frag), DMA_TO_DEVICE);
3068 + if (unlikely(dma_mapping_error(trans->dev, tb_phys)))
3069 + goto out_err;
3070 + iwl_pcie_gen2_set_tb(trans, tfd, tb_phys, skb_headlen(frag));
3071 + trace_iwlwifi_dev_tx_tb(trans->dev, skb,
3072 + frag->data,
3073 + skb_headlen(frag));
3074 + if (iwl_pcie_gen2_tx_add_frags(trans, frag, tfd, out_meta))
3075 + goto out_err;
3076 + }
3077 +
3078 return tfd;
3079
3080 out_err:
3081 diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
3082 index c7f29a9be50d..146fe144f5f5 100644
3083 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
3084 +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
3085 @@ -1176,6 +1176,7 @@ void rtl92de_enable_interrupt(struct ieee80211_hw *hw)
3086
3087 rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] & 0xFFFFFFFF);
3088 rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] & 0xFFFFFFFF);
3089 + rtlpci->irq_enabled = true;
3090 }
3091
3092 void rtl92de_disable_interrupt(struct ieee80211_hw *hw)
3093 @@ -1185,7 +1186,7 @@ void rtl92de_disable_interrupt(struct ieee80211_hw *hw)
3094
3095 rtl_write_dword(rtlpriv, REG_HIMR, IMR8190_DISABLED);
3096 rtl_write_dword(rtlpriv, REG_HIMRE, IMR8190_DISABLED);
3097 - synchronize_irq(rtlpci->pdev->irq);
3098 + rtlpci->irq_enabled = false;
3099 }
3100
3101 static void _rtl92de_poweroff_adapter(struct ieee80211_hw *hw)
3102 @@ -1351,7 +1352,7 @@ void rtl92de_set_beacon_related_registers(struct ieee80211_hw *hw)
3103
3104 bcn_interval = mac->beacon_interval;
3105 atim_window = 2;
3106 - /*rtl92de_disable_interrupt(hw); */
3107 + rtl92de_disable_interrupt(hw);
3108 rtl_write_word(rtlpriv, REG_ATIMWND, atim_window);
3109 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval);
3110 rtl_write_word(rtlpriv, REG_BCNTCFG, 0x660f);
3111 @@ -1371,9 +1372,9 @@ void rtl92de_set_beacon_interval(struct ieee80211_hw *hw)
3112
3113 RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
3114 "beacon_interval:%d\n", bcn_interval);
3115 - /* rtl92de_disable_interrupt(hw); */
3116 + rtl92de_disable_interrupt(hw);
3117 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval);
3118 - /* rtl92de_enable_interrupt(hw); */
3119 + rtl92de_enable_interrupt(hw);
3120 }
3121
3122 void rtl92de_update_interrupt_mask(struct ieee80211_hw *hw,
3123 diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
3124 index 99e5cd9a5c86..1dbdddce0823 100644
3125 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
3126 +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
3127 @@ -216,6 +216,7 @@ static struct rtl_hal_ops rtl8192de_hal_ops = {
3128 .led_control = rtl92de_led_control,
3129 .set_desc = rtl92de_set_desc,
3130 .get_desc = rtl92de_get_desc,
3131 + .is_tx_desc_closed = rtl92de_is_tx_desc_closed,
3132 .tx_polling = rtl92de_tx_polling,
3133 .enable_hw_sec = rtl92de_enable_hw_security_config,
3134 .set_key = rtl92de_set_key,
3135 diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c
3136 index 2494e1f118f8..92c9fb45f800 100644
3137 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c
3138 +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c
3139 @@ -804,13 +804,15 @@ u64 rtl92de_get_desc(struct ieee80211_hw *hw,
3140 break;
3141 }
3142 } else {
3143 - struct rx_desc_92c *pdesc = (struct rx_desc_92c *)p_desc;
3144 switch (desc_name) {
3145 case HW_DESC_OWN:
3146 - ret = GET_RX_DESC_OWN(pdesc);
3147 + ret = GET_RX_DESC_OWN(p_desc);
3148 break;
3149 case HW_DESC_RXPKT_LEN:
3150 - ret = GET_RX_DESC_PKT_LEN(pdesc);
3151 + ret = GET_RX_DESC_PKT_LEN(p_desc);
3152 + break;
3153 + case HW_DESC_RXBUFF_ADDR:
3154 + ret = GET_RX_DESC_BUFF_ADDR(p_desc);
3155 break;
3156 default:
3157 WARN_ONCE(true, "rtl8192de: ERR rxdesc :%d not processed\n",
3158 @@ -821,6 +823,23 @@ u64 rtl92de_get_desc(struct ieee80211_hw *hw,
3159 return ret;
3160 }
3161
3162 +bool rtl92de_is_tx_desc_closed(struct ieee80211_hw *hw,
3163 + u8 hw_queue, u16 index)
3164 +{
3165 + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
3166 + struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
3167 + u8 *entry = (u8 *)(&ring->desc[ring->idx]);
3168 + u8 own = (u8)rtl92de_get_desc(hw, entry, true, HW_DESC_OWN);
3169 +
3170 + /* a beacon packet will only use the first
3171 + * descriptor by defaut, and the own bit may not
3172 + * be cleared by the hardware
3173 + */
3174 + if (own)
3175 + return false;
3176 + return true;
3177 +}
3178 +
3179 void rtl92de_tx_polling(struct ieee80211_hw *hw, u8 hw_queue)
3180 {
3181 struct rtl_priv *rtlpriv = rtl_priv(hw);
3182 diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.h b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.h
3183 index 36820070fd76..635989e15282 100644
3184 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.h
3185 +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.h
3186 @@ -715,6 +715,8 @@ void rtl92de_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
3187 u8 desc_name, u8 *val);
3188 u64 rtl92de_get_desc(struct ieee80211_hw *hw,
3189 u8 *p_desc, bool istx, u8 desc_name);
3190 +bool rtl92de_is_tx_desc_closed(struct ieee80211_hw *hw,
3191 + u8 hw_queue, u16 index);
3192 void rtl92de_tx_polling(struct ieee80211_hw *hw, u8 hw_queue);
3193 void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
3194 bool b_firstseg, bool b_lastseg,
3195 diff --git a/drivers/net/wireless/virt_wifi.c b/drivers/net/wireless/virt_wifi.c
3196 index 7997cc6de334..01305ba2d3aa 100644
3197 --- a/drivers/net/wireless/virt_wifi.c
3198 +++ b/drivers/net/wireless/virt_wifi.c
3199 @@ -450,7 +450,6 @@ static void virt_wifi_net_device_destructor(struct net_device *dev)
3200 */
3201 kfree(dev->ieee80211_ptr);
3202 dev->ieee80211_ptr = NULL;
3203 - free_netdev(dev);
3204 }
3205
3206 /* No lock interaction. */
3207 @@ -458,7 +457,7 @@ static void virt_wifi_setup(struct net_device *dev)
3208 {
3209 ether_setup(dev);
3210 dev->netdev_ops = &virt_wifi_ops;
3211 - dev->priv_destructor = virt_wifi_net_device_destructor;
3212 + dev->needs_free_netdev = true;
3213 }
3214
3215 /* Called in a RCU read critical section from netif_receive_skb */
3216 @@ -544,6 +543,7 @@ static int virt_wifi_newlink(struct net *src_net, struct net_device *dev,
3217 goto unregister_netdev;
3218 }
3219
3220 + dev->priv_destructor = virt_wifi_net_device_destructor;
3221 priv->being_deleted = false;
3222 priv->is_connected = false;
3223 priv->is_up = false;
3224 diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
3225 index fa7ba09dca77..af3212aec871 100644
3226 --- a/drivers/nvme/host/core.c
3227 +++ b/drivers/nvme/host/core.c
3228 @@ -1727,6 +1727,8 @@ static int nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid,
3229 if (ret)
3230 dev_warn(ctrl->device,
3231 "Identify Descriptors failed (%d)\n", ret);
3232 + if (ret > 0)
3233 + ret = 0;
3234 }
3235 return ret;
3236 }
3237 @@ -2404,16 +2406,6 @@ static const struct nvme_core_quirk_entry core_quirks[] = {
3238 .vid = 0x14a4,
3239 .fr = "22301111",
3240 .quirks = NVME_QUIRK_SIMPLE_SUSPEND,
3241 - },
3242 - {
3243 - /*
3244 - * This Kingston E8FK11.T firmware version has no interrupt
3245 - * after resume with actions related to suspend to idle
3246 - * https://bugzilla.kernel.org/show_bug.cgi?id=204887
3247 - */
3248 - .vid = 0x2646,
3249 - .fr = "E8FK11.T",
3250 - .quirks = NVME_QUIRK_SIMPLE_SUSPEND,
3251 }
3252 };
3253
3254 diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
3255 index e4c46637f32f..b3869951c0eb 100644
3256 --- a/drivers/pci/hotplug/acpiphp_glue.c
3257 +++ b/drivers/pci/hotplug/acpiphp_glue.c
3258 @@ -449,8 +449,15 @@ static void acpiphp_native_scan_bridge(struct pci_dev *bridge)
3259
3260 /* Scan non-hotplug bridges that need to be reconfigured */
3261 for_each_pci_bridge(dev, bus) {
3262 - if (!hotplug_is_native(dev))
3263 - max = pci_scan_bridge(bus, dev, max, 1);
3264 + if (hotplug_is_native(dev))
3265 + continue;
3266 +
3267 + max = pci_scan_bridge(bus, dev, max, 1);
3268 + if (dev->subordinate) {
3269 + pcibios_resource_survey_bus(dev->subordinate);
3270 + pci_bus_size_bridges(dev->subordinate);
3271 + pci_bus_assign_resources(dev->subordinate);
3272 + }
3273 }
3274 }
3275
3276 @@ -480,7 +487,6 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge)
3277 if (PCI_SLOT(dev->devfn) == slot->device)
3278 acpiphp_native_scan_bridge(dev);
3279 }
3280 - pci_assign_unassigned_bridge_resources(bus->self);
3281 } else {
3282 LIST_HEAD(add_list);
3283 int max, pass;
3284 diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
3285 index b7f6b1324395..6fd1390fd06e 100644
3286 --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
3287 +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
3288 @@ -21,6 +21,7 @@
3289 #include <linux/platform_device.h>
3290 #include <linux/pm_runtime.h>
3291 #include <linux/regulator/consumer.h>
3292 +#include <linux/string.h>
3293 #include <linux/usb/of.h>
3294 #include <linux/workqueue.h>
3295
3296 @@ -320,9 +321,9 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr,
3297 if (!ch->is_otg_channel || !rcar_gen3_is_any_rphy_initialized(ch))
3298 return -EIO;
3299
3300 - if (!strncmp(buf, "host", strlen("host")))
3301 + if (sysfs_streq(buf, "host"))
3302 new_mode = PHY_MODE_USB_HOST;
3303 - else if (!strncmp(buf, "peripheral", strlen("peripheral")))
3304 + else if (sysfs_streq(buf, "peripheral"))
3305 new_mode = PHY_MODE_USB_DEVICE;
3306 else
3307 return -EINVAL;
3308 diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
3309 index f2f5fcd9a237..83e585c5a613 100644
3310 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
3311 +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
3312 @@ -595,10 +595,10 @@ static int armada_37xx_irq_set_type(struct irq_data *d, unsigned int type)
3313 regmap_read(info->regmap, in_reg, &in_val);
3314
3315 /* Set initial polarity based on current input level. */
3316 - if (in_val & d->mask)
3317 - val |= d->mask; /* falling */
3318 + if (in_val & BIT(d->hwirq % GPIO_PER_REG))
3319 + val |= BIT(d->hwirq % GPIO_PER_REG); /* falling */
3320 else
3321 - val &= ~d->mask; /* rising */
3322 + val &= ~(BIT(d->hwirq % GPIO_PER_REG)); /* rising */
3323 break;
3324 }
3325 default:
3326 diff --git a/drivers/pinctrl/pinctrl-rza2.c b/drivers/pinctrl/pinctrl-rza2.c
3327 index 3be1d833bf25..eda88cdf870d 100644
3328 --- a/drivers/pinctrl/pinctrl-rza2.c
3329 +++ b/drivers/pinctrl/pinctrl-rza2.c
3330 @@ -213,8 +213,8 @@ static const char * const rza2_gpio_names[] = {
3331 "PC_0", "PC_1", "PC_2", "PC_3", "PC_4", "PC_5", "PC_6", "PC_7",
3332 "PD_0", "PD_1", "PD_2", "PD_3", "PD_4", "PD_5", "PD_6", "PD_7",
3333 "PE_0", "PE_1", "PE_2", "PE_3", "PE_4", "PE_5", "PE_6", "PE_7",
3334 - "PF_0", "PF_1", "PF_2", "PF_3", "P0_4", "PF_5", "PF_6", "PF_7",
3335 - "PG_0", "PG_1", "PG_2", "P0_3", "PG_4", "PG_5", "PG_6", "PG_7",
3336 + "PF_0", "PF_1", "PF_2", "PF_3", "PF_4", "PF_5", "PF_6", "PF_7",
3337 + "PG_0", "PG_1", "PG_2", "PG_3", "PG_4", "PG_5", "PG_6", "PG_7",
3338 "PH_0", "PH_1", "PH_2", "PH_3", "PH_4", "PH_5", "PH_6", "PH_7",
3339 /* port I does not exist */
3340 "PJ_0", "PJ_1", "PJ_2", "PJ_3", "PJ_4", "PJ_5", "PJ_6", "PJ_7",
3341 diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
3342 index ebc27b06718c..0599f5127b01 100644
3343 --- a/drivers/pinctrl/samsung/pinctrl-exynos.c
3344 +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
3345 @@ -486,8 +486,10 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
3346 if (match) {
3347 irq_chip = kmemdup(match->data,
3348 sizeof(*irq_chip), GFP_KERNEL);
3349 - if (!irq_chip)
3350 + if (!irq_chip) {
3351 + of_node_put(np);
3352 return -ENOMEM;
3353 + }
3354 wkup_np = np;
3355 break;
3356 }
3357 @@ -504,6 +506,7 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
3358 bank->nr_pins, &exynos_eint_irqd_ops, bank);
3359 if (!bank->irq_domain) {
3360 dev_err(dev, "wkup irq domain add failed\n");
3361 + of_node_put(wkup_np);
3362 return -ENXIO;
3363 }
3364
3365 @@ -518,8 +521,10 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
3366 weint_data = devm_kcalloc(dev,
3367 bank->nr_pins, sizeof(*weint_data),
3368 GFP_KERNEL);
3369 - if (!weint_data)
3370 + if (!weint_data) {
3371 + of_node_put(wkup_np);
3372 return -ENOMEM;
3373 + }
3374
3375 for (idx = 0; idx < bank->nr_pins; ++idx) {
3376 irq = irq_of_parse_and_map(bank->of_node, idx);
3377 @@ -536,10 +541,13 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
3378 }
3379 }
3380
3381 - if (!muxed_banks)
3382 + if (!muxed_banks) {
3383 + of_node_put(wkup_np);
3384 return 0;
3385 + }
3386
3387 irq = irq_of_parse_and_map(wkup_np, 0);
3388 + of_node_put(wkup_np);
3389 if (!irq) {
3390 dev_err(dev, "irq number for muxed EINTs not found\n");
3391 return 0;
3392 diff --git a/drivers/pinctrl/samsung/pinctrl-s3c24xx.c b/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
3393 index 7e824e4d20f4..9bd0a3de101d 100644
3394 --- a/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
3395 +++ b/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
3396 @@ -490,8 +490,10 @@ static int s3c24xx_eint_init(struct samsung_pinctrl_drv_data *d)
3397 return -ENODEV;
3398
3399 eint_data = devm_kzalloc(dev, sizeof(*eint_data), GFP_KERNEL);
3400 - if (!eint_data)
3401 + if (!eint_data) {
3402 + of_node_put(eint_np);
3403 return -ENOMEM;
3404 + }
3405
3406 eint_data->drvdata = d;
3407
3408 @@ -503,12 +505,14 @@ static int s3c24xx_eint_init(struct samsung_pinctrl_drv_data *d)
3409 irq = irq_of_parse_and_map(eint_np, i);
3410 if (!irq) {
3411 dev_err(dev, "failed to get wakeup EINT IRQ %d\n", i);
3412 + of_node_put(eint_np);
3413 return -ENXIO;
3414 }
3415
3416 eint_data->parents[i] = irq;
3417 irq_set_chained_handler_and_data(irq, handlers[i], eint_data);
3418 }
3419 + of_node_put(eint_np);
3420
3421 bank = d->pin_banks;
3422 for (i = 0; i < d->nr_banks; ++i, ++bank) {
3423 diff --git a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
3424 index c399f0932af5..f97f8179f2b1 100644
3425 --- a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
3426 +++ b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
3427 @@ -704,8 +704,10 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
3428 return -ENODEV;
3429
3430 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
3431 - if (!data)
3432 + if (!data) {
3433 + of_node_put(eint0_np);
3434 return -ENOMEM;
3435 + }
3436 data->drvdata = d;
3437
3438 for (i = 0; i < NUM_EINT0_IRQ; ++i) {
3439 @@ -714,6 +716,7 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
3440 irq = irq_of_parse_and_map(eint0_np, i);
3441 if (!irq) {
3442 dev_err(dev, "failed to get wakeup EINT IRQ %d\n", i);
3443 + of_node_put(eint0_np);
3444 return -ENXIO;
3445 }
3446
3447 @@ -721,6 +724,7 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
3448 s3c64xx_eint0_handlers[i],
3449 data);
3450 }
3451 + of_node_put(eint0_np);
3452
3453 bank = d->pin_banks;
3454 for (i = 0; i < d->nr_banks; ++i, ++bank) {
3455 diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
3456 index de0477bb469d..f26574ef234a 100644
3457 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c
3458 +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
3459 @@ -272,6 +272,7 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev,
3460 &reserved_maps, num_maps);
3461 if (ret < 0) {
3462 samsung_dt_free_map(pctldev, *map, *num_maps);
3463 + of_node_put(np);
3464 return ret;
3465 }
3466 }
3467 @@ -785,8 +786,10 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
3468 if (!of_get_child_count(cfg_np)) {
3469 ret = samsung_pinctrl_create_function(dev, drvdata,
3470 cfg_np, func);
3471 - if (ret < 0)
3472 + if (ret < 0) {
3473 + of_node_put(cfg_np);
3474 return ERR_PTR(ret);
3475 + }
3476 if (ret > 0) {
3477 ++func;
3478 ++func_cnt;
3479 @@ -797,8 +800,11 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
3480 for_each_child_of_node(cfg_np, func_np) {
3481 ret = samsung_pinctrl_create_function(dev, drvdata,
3482 func_np, func);
3483 - if (ret < 0)
3484 + if (ret < 0) {
3485 + of_node_put(func_np);
3486 + of_node_put(cfg_np);
3487 return ERR_PTR(ret);
3488 + }
3489 if (ret > 0) {
3490 ++func;
3491 ++func_cnt;
3492 diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
3493 index c93ef33b01d3..5c1378d2fab3 100644
3494 --- a/drivers/rtc/interface.c
3495 +++ b/drivers/rtc/interface.c
3496 @@ -125,7 +125,7 @@ EXPORT_SYMBOL_GPL(rtc_read_time);
3497
3498 int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
3499 {
3500 - int err;
3501 + int err, uie;
3502
3503 err = rtc_valid_tm(tm);
3504 if (err != 0)
3505 @@ -137,6 +137,17 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
3506
3507 rtc_subtract_offset(rtc, tm);
3508
3509 +#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
3510 + uie = rtc->uie_rtctimer.enabled || rtc->uie_irq_active;
3511 +#else
3512 + uie = rtc->uie_rtctimer.enabled;
3513 +#endif
3514 + if (uie) {
3515 + err = rtc_update_irq_enable(rtc, 0);
3516 + if (err)
3517 + return err;
3518 + }
3519 +
3520 err = mutex_lock_interruptible(&rtc->ops_lock);
3521 if (err)
3522 return err;
3523 @@ -153,6 +164,12 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
3524 /* A timer might have just expired */
3525 schedule_work(&rtc->irqwork);
3526
3527 + if (uie) {
3528 + err = rtc_update_irq_enable(rtc, 1);
3529 + if (err)
3530 + return err;
3531 + }
3532 +
3533 trace_rtc_set_time(rtc_tm_to_time64(tm), err);
3534 return err;
3535 }
3536 diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
3537 index dccdb41bed8c..1234294700c4 100644
3538 --- a/drivers/s390/scsi/zfcp_dbf.c
3539 +++ b/drivers/s390/scsi/zfcp_dbf.c
3540 @@ -95,11 +95,9 @@ void zfcp_dbf_hba_fsf_res(char *tag, int level, struct zfcp_fsf_req *req)
3541 memcpy(rec->u.res.fsf_status_qual, &q_head->fsf_status_qual,
3542 FSF_STATUS_QUALIFIER_SIZE);
3543
3544 - if (q_head->fsf_command != FSF_QTCB_FCP_CMND) {
3545 - rec->pl_len = q_head->log_length;
3546 - zfcp_dbf_pl_write(dbf, (char *)q_pref + q_head->log_start,
3547 - rec->pl_len, "fsf_res", req->req_id);
3548 - }
3549 + rec->pl_len = q_head->log_length;
3550 + zfcp_dbf_pl_write(dbf, (char *)q_pref + q_head->log_start,
3551 + rec->pl_len, "fsf_res", req->req_id);
3552
3553 debug_event(dbf->hba, level, rec, sizeof(*rec));
3554 spin_unlock_irqrestore(&dbf->hba_lock, flags);
3555 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
3556 index 6822cd9ff8f1..ad8ef67a1db3 100644
3557 --- a/drivers/scsi/lpfc/lpfc_scsi.c
3558 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
3559 @@ -526,7 +526,7 @@ lpfc_sli4_io_xri_aborted(struct lpfc_hba *phba,
3560 &qp->lpfc_abts_io_buf_list, list) {
3561 if (psb->cur_iocbq.sli4_xritag == xri) {
3562 list_del_init(&psb->list);
3563 - psb->exch_busy = 0;
3564 + psb->flags &= ~LPFC_SBUF_XBUSY;
3565 psb->status = IOSTAT_SUCCESS;
3566 if (psb->cur_iocbq.iocb_flag == LPFC_IO_NVME) {
3567 qp->abts_nvme_io_bufs--;
3568 @@ -566,7 +566,7 @@ lpfc_sli4_io_xri_aborted(struct lpfc_hba *phba,
3569 if (iocbq->sli4_xritag != xri)
3570 continue;
3571 psb = container_of(iocbq, struct lpfc_io_buf, cur_iocbq);
3572 - psb->exch_busy = 0;
3573 + psb->flags &= ~LPFC_SBUF_XBUSY;
3574 spin_unlock_irqrestore(&phba->hbalock, iflag);
3575 if (!list_empty(&pring->txq))
3576 lpfc_worker_wake_up(phba);
3577 @@ -786,7 +786,7 @@ lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *psb)
3578 psb->prot_seg_cnt = 0;
3579
3580 qp = psb->hdwq;
3581 - if (psb->exch_busy) {
3582 + if (psb->flags & LPFC_SBUF_XBUSY) {
3583 spin_lock_irqsave(&qp->abts_io_buf_list_lock, iflag);
3584 psb->pCmd = NULL;
3585 list_add_tail(&psb->list, &qp->lpfc_abts_io_buf_list);
3586 @@ -3835,7 +3835,10 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
3587 lpfc_cmd->result = (pIocbOut->iocb.un.ulpWord[4] & IOERR_PARAM_MASK);
3588 lpfc_cmd->status = pIocbOut->iocb.ulpStatus;
3589 /* pick up SLI4 exhange busy status from HBA */
3590 - lpfc_cmd->exch_busy = pIocbOut->iocb_flag & LPFC_EXCHANGE_BUSY;
3591 + if (pIocbOut->iocb_flag & LPFC_EXCHANGE_BUSY)
3592 + lpfc_cmd->flags |= LPFC_SBUF_XBUSY;
3593 + else
3594 + lpfc_cmd->flags &= ~LPFC_SBUF_XBUSY;
3595
3596 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
3597 if (lpfc_cmd->prot_data_type) {
3598 diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
3599 index 614f78dddafe..5ed4219675eb 100644
3600 --- a/drivers/scsi/lpfc/lpfc_sli.c
3601 +++ b/drivers/scsi/lpfc/lpfc_sli.c
3602 @@ -11736,7 +11736,10 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba,
3603 !(cmdiocbq->iocb_flag & LPFC_IO_LIBDFC)) {
3604 lpfc_cmd = container_of(cmdiocbq, struct lpfc_io_buf,
3605 cur_iocbq);
3606 - lpfc_cmd->exch_busy = rspiocbq->iocb_flag & LPFC_EXCHANGE_BUSY;
3607 + if (rspiocbq && (rspiocbq->iocb_flag & LPFC_EXCHANGE_BUSY))
3608 + lpfc_cmd->flags |= LPFC_SBUF_XBUSY;
3609 + else
3610 + lpfc_cmd->flags &= ~LPFC_SBUF_XBUSY;
3611 }
3612
3613 pdone_q = cmdiocbq->context_un.wait_queue;
3614 diff --git a/drivers/scsi/lpfc/lpfc_sli.h b/drivers/scsi/lpfc/lpfc_sli.h
3615 index 37fbcb46387e..7bcf922a8be2 100644
3616 --- a/drivers/scsi/lpfc/lpfc_sli.h
3617 +++ b/drivers/scsi/lpfc/lpfc_sli.h
3618 @@ -384,14 +384,13 @@ struct lpfc_io_buf {
3619
3620 struct lpfc_nodelist *ndlp;
3621 uint32_t timeout;
3622 - uint16_t flags; /* TBD convert exch_busy to flags */
3623 + uint16_t flags;
3624 #define LPFC_SBUF_XBUSY 0x1 /* SLI4 hba reported XB on WCQE cmpl */
3625 #define LPFC_SBUF_BUMP_QDEPTH 0x2 /* bumped queue depth counter */
3626 /* External DIF device IO conversions */
3627 #define LPFC_SBUF_NORMAL_DIF 0x4 /* normal mode to insert/strip */
3628 #define LPFC_SBUF_PASS_DIF 0x8 /* insert/strip mode to passthru */
3629 #define LPFC_SBUF_NOT_POSTED 0x10 /* SGL failed post to FW. */
3630 - uint16_t exch_busy; /* SLI4 hba reported XB on complete WCQE */
3631 uint16_t status; /* From IOCB Word 7- ulpStatus */
3632 uint32_t result; /* From IOCB Word 4. */
3633
3634 diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
3635 index 6ffa9877c28b..d5386edddaf6 100644
3636 --- a/drivers/scsi/qla2xxx/qla_def.h
3637 +++ b/drivers/scsi/qla2xxx/qla_def.h
3638 @@ -591,19 +591,23 @@ typedef struct srb {
3639 */
3640 uint8_t cmd_type;
3641 uint8_t pad[3];
3642 - atomic_t ref_count;
3643 struct kref cmd_kref; /* need to migrate ref_count over to this */
3644 void *priv;
3645 wait_queue_head_t nvme_ls_waitq;
3646 struct fc_port *fcport;
3647 struct scsi_qla_host *vha;
3648 unsigned int start_timer:1;
3649 + unsigned int abort:1;
3650 + unsigned int aborted:1;
3651 + unsigned int completed:1;
3652 +
3653 uint32_t handle;
3654 uint16_t flags;
3655 uint16_t type;
3656 const char *name;
3657 int iocbs;
3658 struct qla_qpair *qpair;
3659 + struct srb *cmd_sp;
3660 struct list_head elem;
3661 u32 gen1; /* scratch */
3662 u32 gen2; /* scratch */
3663 diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
3664 index 5298ed10059f..84bb4a048016 100644
3665 --- a/drivers/scsi/qla2xxx/qla_gs.c
3666 +++ b/drivers/scsi/qla2xxx/qla_gs.c
3667 @@ -3005,7 +3005,7 @@ static void qla24xx_async_gpsc_sp_done(srb_t *sp, int res)
3668 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
3669
3670 if (res == QLA_FUNCTION_TIMEOUT)
3671 - return;
3672 + goto done;
3673
3674 if (res == (DID_ERROR << 16)) {
3675 /* entry status error */
3676 diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
3677 index 1d041313ec52..d400b51929a6 100644
3678 --- a/drivers/scsi/qla2xxx/qla_init.c
3679 +++ b/drivers/scsi/qla2xxx/qla_init.c
3680 @@ -101,8 +101,22 @@ static void qla24xx_abort_iocb_timeout(void *data)
3681 u32 handle;
3682 unsigned long flags;
3683
3684 + if (sp->cmd_sp)
3685 + ql_dbg(ql_dbg_async, sp->vha, 0x507c,
3686 + "Abort timeout - cmd hdl=%x, cmd type=%x hdl=%x, type=%x\n",
3687 + sp->cmd_sp->handle, sp->cmd_sp->type,
3688 + sp->handle, sp->type);
3689 + else
3690 + ql_dbg(ql_dbg_async, sp->vha, 0x507c,
3691 + "Abort timeout 2 - hdl=%x, type=%x\n",
3692 + sp->handle, sp->type);
3693 +
3694 spin_lock_irqsave(qpair->qp_lock_ptr, flags);
3695 for (handle = 1; handle < qpair->req->num_outstanding_cmds; handle++) {
3696 + if (sp->cmd_sp && (qpair->req->outstanding_cmds[handle] ==
3697 + sp->cmd_sp))
3698 + qpair->req->outstanding_cmds[handle] = NULL;
3699 +
3700 /* removing the abort */
3701 if (qpair->req->outstanding_cmds[handle] == sp) {
3702 qpair->req->outstanding_cmds[handle] = NULL;
3703 @@ -111,6 +125,9 @@ static void qla24xx_abort_iocb_timeout(void *data)
3704 }
3705 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
3706
3707 + if (sp->cmd_sp)
3708 + sp->cmd_sp->done(sp->cmd_sp, QLA_OS_TIMER_EXPIRED);
3709 +
3710 abt->u.abt.comp_status = CS_TIMEOUT;
3711 sp->done(sp, QLA_OS_TIMER_EXPIRED);
3712 }
3713 @@ -142,6 +159,7 @@ static int qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait)
3714 sp->type = SRB_ABT_CMD;
3715 sp->name = "abort";
3716 sp->qpair = cmd_sp->qpair;
3717 + sp->cmd_sp = cmd_sp;
3718 if (wait)
3719 sp->flags = SRB_WAKEUP_ON_COMP;
3720
3721 @@ -1135,19 +1153,18 @@ static void qla24xx_async_gpdb_sp_done(srb_t *sp, int res)
3722 "Async done-%s res %x, WWPN %8phC mb[1]=%x mb[2]=%x \n",
3723 sp->name, res, fcport->port_name, mb[1], mb[2]);
3724
3725 - if (res == QLA_FUNCTION_TIMEOUT) {
3726 - dma_pool_free(sp->vha->hw->s_dma_pool, sp->u.iocb_cmd.u.mbx.in,
3727 - sp->u.iocb_cmd.u.mbx.in_dma);
3728 - return;
3729 - }
3730 -
3731 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
3732 +
3733 + if (res == QLA_FUNCTION_TIMEOUT)
3734 + goto done;
3735 +
3736 memset(&ea, 0, sizeof(ea));
3737 ea.fcport = fcport;
3738 ea.sp = sp;
3739
3740 qla24xx_handle_gpdb_event(vha, &ea);
3741
3742 +done:
3743 dma_pool_free(ha->s_dma_pool, sp->u.iocb_cmd.u.mbx.in,
3744 sp->u.iocb_cmd.u.mbx.in_dma);
3745
3746 @@ -9003,8 +9020,6 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair)
3747 struct qla_hw_data *ha = qpair->hw;
3748
3749 qpair->delete_in_progress = 1;
3750 - while (atomic_read(&qpair->ref_count))
3751 - msleep(500);
3752
3753 ret = qla25xx_delete_req_que(vha, qpair->req);
3754 if (ret != QLA_SUCCESS)
3755 diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
3756 index 009fd5a33fcd..9204e8467a4e 100644
3757 --- a/drivers/scsi/qla2xxx/qla_isr.c
3758 +++ b/drivers/scsi/qla2xxx/qla_isr.c
3759 @@ -2466,6 +2466,11 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
3760 return;
3761 }
3762
3763 + if (sp->abort)
3764 + sp->aborted = 1;
3765 + else
3766 + sp->completed = 1;
3767 +
3768 if (sp->cmd_type != TYPE_SRB) {
3769 req->outstanding_cmds[handle] = NULL;
3770 ql_dbg(ql_dbg_io, vha, 0x3015,
3771 diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
3772 index 4a1f21c11758..4d90cf101f5f 100644
3773 --- a/drivers/scsi/qla2xxx/qla_mbx.c
3774 +++ b/drivers/scsi/qla2xxx/qla_mbx.c
3775 @@ -6287,17 +6287,13 @@ int qla24xx_send_mb_cmd(struct scsi_qla_host *vha, mbx_cmd_t *mcp)
3776 case QLA_SUCCESS:
3777 ql_dbg(ql_dbg_mbx, vha, 0x119d, "%s: %s done.\n",
3778 __func__, sp->name);
3779 - sp->free(sp);
3780 break;
3781 default:
3782 ql_dbg(ql_dbg_mbx, vha, 0x119e, "%s: %s Failed. %x.\n",
3783 __func__, sp->name, rval);
3784 - sp->free(sp);
3785 break;
3786 }
3787
3788 - return rval;
3789 -
3790 done_free_sp:
3791 sp->free(sp);
3792 done:
3793 diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
3794 index 238240984bc1..eabc5127174e 100644
3795 --- a/drivers/scsi/qla2xxx/qla_mid.c
3796 +++ b/drivers/scsi/qla2xxx/qla_mid.c
3797 @@ -946,7 +946,7 @@ int qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
3798
3799 sp = qla2x00_get_sp(base_vha, NULL, GFP_KERNEL);
3800 if (!sp)
3801 - goto done;
3802 + return rval;
3803
3804 sp->type = SRB_CTRL_VP;
3805 sp->name = "ctrl_vp";
3806 @@ -962,7 +962,7 @@ int qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
3807 ql_dbg(ql_dbg_async, vha, 0xffff,
3808 "%s: %s Failed submission. %x.\n",
3809 __func__, sp->name, rval);
3810 - goto done_free_sp;
3811 + goto done;
3812 }
3813
3814 ql_dbg(ql_dbg_vport, vha, 0x113f, "%s hndl %x submitted\n",
3815 @@ -980,16 +980,13 @@ int qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
3816 case QLA_SUCCESS:
3817 ql_dbg(ql_dbg_vport, vha, 0xffff, "%s: %s done.\n",
3818 __func__, sp->name);
3819 - goto done_free_sp;
3820 + break;
3821 default:
3822 ql_dbg(ql_dbg_vport, vha, 0xffff, "%s: %s Failed. %x.\n",
3823 __func__, sp->name, rval);
3824 - goto done_free_sp;
3825 + break;
3826 }
3827 done:
3828 - return rval;
3829 -
3830 -done_free_sp:
3831 sp->free(sp);
3832 return rval;
3833 }
3834 diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
3835 index 6cc19e060afc..941aa53363f5 100644
3836 --- a/drivers/scsi/qla2xxx/qla_nvme.c
3837 +++ b/drivers/scsi/qla2xxx/qla_nvme.c
3838 @@ -224,8 +224,8 @@ static void qla_nvme_abort_work(struct work_struct *work)
3839
3840 if (ha->flags.host_shutting_down) {
3841 ql_log(ql_log_info, sp->fcport->vha, 0xffff,
3842 - "%s Calling done on sp: %p, type: 0x%x, sp->ref_count: 0x%x\n",
3843 - __func__, sp, sp->type, atomic_read(&sp->ref_count));
3844 + "%s Calling done on sp: %p, type: 0x%x\n",
3845 + __func__, sp, sp->type);
3846 sp->done(sp, 0);
3847 goto out;
3848 }
3849 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
3850 index 726ad4cbf4a6..06037e3c7854 100644
3851 --- a/drivers/scsi/qla2xxx/qla_os.c
3852 +++ b/drivers/scsi/qla2xxx/qla_os.c
3853 @@ -698,11 +698,6 @@ void qla2x00_sp_compl(srb_t *sp, int res)
3854 struct scsi_cmnd *cmd = GET_CMD_SP(sp);
3855 struct completion *comp = sp->comp;
3856
3857 - if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
3858 - return;
3859 -
3860 - atomic_dec(&sp->ref_count);
3861 -
3862 sp->free(sp);
3863 cmd->result = res;
3864 CMD_SP(cmd) = NULL;
3865 @@ -794,11 +789,6 @@ void qla2xxx_qpair_sp_compl(srb_t *sp, int res)
3866 struct scsi_cmnd *cmd = GET_CMD_SP(sp);
3867 struct completion *comp = sp->comp;
3868
3869 - if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0))
3870 - return;
3871 -
3872 - atomic_dec(&sp->ref_count);
3873 -
3874 sp->free(sp);
3875 cmd->result = res;
3876 CMD_SP(cmd) = NULL;
3877 @@ -903,7 +893,7 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
3878
3879 sp->u.scmd.cmd = cmd;
3880 sp->type = SRB_SCSI_CMD;
3881 - atomic_set(&sp->ref_count, 1);
3882 +
3883 CMD_SP(cmd) = (void *)sp;
3884 sp->free = qla2x00_sp_free_dma;
3885 sp->done = qla2x00_sp_compl;
3886 @@ -985,18 +975,16 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd,
3887
3888 sp->u.scmd.cmd = cmd;
3889 sp->type = SRB_SCSI_CMD;
3890 - atomic_set(&sp->ref_count, 1);
3891 CMD_SP(cmd) = (void *)sp;
3892 sp->free = qla2xxx_qpair_sp_free_dma;
3893 sp->done = qla2xxx_qpair_sp_compl;
3894 - sp->qpair = qpair;
3895
3896 rval = ha->isp_ops->start_scsi_mq(sp);
3897 if (rval != QLA_SUCCESS) {
3898 ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3078,
3899 "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd);
3900 if (rval == QLA_INTERFACE_ERROR)
3901 - goto qc24_fail_command;
3902 + goto qc24_free_sp_fail_command;
3903 goto qc24_host_busy_free_sp;
3904 }
3905
3906 @@ -1008,6 +996,11 @@ qc24_host_busy_free_sp:
3907 qc24_target_busy:
3908 return SCSI_MLQUEUE_TARGET_BUSY;
3909
3910 +qc24_free_sp_fail_command:
3911 + sp->free(sp);
3912 + CMD_SP(cmd) = NULL;
3913 + qla2xxx_rel_qpair_sp(sp->qpair, sp);
3914 +
3915 qc24_fail_command:
3916 cmd->scsi_done(cmd);
3917
3918 @@ -1184,16 +1177,6 @@ qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha)
3919 return return_status;
3920 }
3921
3922 -static int
3923 -sp_get(struct srb *sp)
3924 -{
3925 - if (!refcount_inc_not_zero((refcount_t *)&sp->ref_count))
3926 - /* kref get fail */
3927 - return ENXIO;
3928 - else
3929 - return 0;
3930 -}
3931 -
3932 #define ISP_REG_DISCONNECT 0xffffffffU
3933 /**************************************************************************
3934 * qla2x00_isp_reg_stat
3935 @@ -1249,6 +1232,9 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
3936 uint64_t lun;
3937 int rval;
3938 struct qla_hw_data *ha = vha->hw;
3939 + uint32_t ratov_j;
3940 + struct qla_qpair *qpair;
3941 + unsigned long flags;
3942
3943 if (qla2x00_isp_reg_stat(ha)) {
3944 ql_log(ql_log_info, vha, 0x8042,
3945 @@ -1261,13 +1247,26 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
3946 return ret;
3947
3948 sp = scsi_cmd_priv(cmd);
3949 + qpair = sp->qpair;
3950
3951 - if (sp->fcport && sp->fcport->deleted)
3952 + if ((sp->fcport && sp->fcport->deleted) || !qpair)
3953 return SUCCESS;
3954
3955 - /* Return if the command has already finished. */
3956 - if (sp_get(sp))
3957 + spin_lock_irqsave(qpair->qp_lock_ptr, flags);
3958 + if (sp->completed) {
3959 + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
3960 return SUCCESS;
3961 + }
3962 +
3963 + if (sp->abort || sp->aborted) {
3964 + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
3965 + return FAILED;
3966 + }
3967 +
3968 + sp->abort = 1;
3969 + sp->comp = &comp;
3970 + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
3971 +
3972
3973 id = cmd->device->id;
3974 lun = cmd->device->lun;
3975 @@ -1276,47 +1275,37 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
3976 "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n",
3977 vha->host_no, id, lun, sp, cmd, sp->handle);
3978
3979 + /*
3980 + * Abort will release the original Command/sp from FW. Let the
3981 + * original command call scsi_done. In return, he will wakeup
3982 + * this sleeping thread.
3983 + */
3984 rval = ha->isp_ops->abort_command(sp);
3985 +
3986 ql_dbg(ql_dbg_taskm, vha, 0x8003,
3987 "Abort command mbx cmd=%p, rval=%x.\n", cmd, rval);
3988
3989 + /* Wait for the command completion. */
3990 + ratov_j = ha->r_a_tov/10 * 4 * 1000;
3991 + ratov_j = msecs_to_jiffies(ratov_j);
3992 switch (rval) {
3993 case QLA_SUCCESS:
3994 - /*
3995 - * The command has been aborted. That means that the firmware
3996 - * won't report a completion.
3997 - */
3998 - sp->done(sp, DID_ABORT << 16);
3999 - ret = SUCCESS;
4000 - break;
4001 - case QLA_FUNCTION_PARAMETER_ERROR: {
4002 - /* Wait for the command completion. */
4003 - uint32_t ratov = ha->r_a_tov/10;
4004 - uint32_t ratov_j = msecs_to_jiffies(4 * ratov * 1000);
4005 -
4006 - WARN_ON_ONCE(sp->comp);
4007 - sp->comp = &comp;
4008 if (!wait_for_completion_timeout(&comp, ratov_j)) {
4009 ql_dbg(ql_dbg_taskm, vha, 0xffff,
4010 "%s: Abort wait timer (4 * R_A_TOV[%d]) expired\n",
4011 - __func__, ha->r_a_tov);
4012 + __func__, ha->r_a_tov/10);
4013 ret = FAILED;
4014 } else {
4015 ret = SUCCESS;
4016 }
4017 break;
4018 - }
4019 default:
4020 - /*
4021 - * Either abort failed or abort and completion raced. Let
4022 - * the SCSI core retry the abort in the former case.
4023 - */
4024 ret = FAILED;
4025 break;
4026 }
4027
4028 sp->comp = NULL;
4029 - atomic_dec(&sp->ref_count);
4030 +
4031 ql_log(ql_log_info, vha, 0x801c,
4032 "Abort command issued nexus=%ld:%d:%llu -- %x.\n",
4033 vha->host_no, id, lun, ret);
4034 @@ -1708,32 +1697,53 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res,
4035 scsi_qla_host_t *vha = qp->vha;
4036 struct qla_hw_data *ha = vha->hw;
4037 int rval;
4038 + bool ret_cmd;
4039 + uint32_t ratov_j;
4040
4041 - if (sp_get(sp))
4042 + if (qla2x00_chip_is_down(vha)) {
4043 + sp->done(sp, res);
4044 return;
4045 + }
4046
4047 if (sp->type == SRB_NVME_CMD || sp->type == SRB_NVME_LS ||
4048 (sp->type == SRB_SCSI_CMD && !ha->flags.eeh_busy &&
4049 !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) &&
4050 !qla2x00_isp_reg_stat(ha))) {
4051 + if (sp->comp) {
4052 + sp->done(sp, res);
4053 + return;
4054 + }
4055 +
4056 sp->comp = &comp;
4057 + sp->abort = 1;
4058 spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
4059 - rval = ha->isp_ops->abort_command(sp);
4060
4061 + rval = ha->isp_ops->abort_command(sp);
4062 + /* Wait for command completion. */
4063 + ret_cmd = false;
4064 + ratov_j = ha->r_a_tov/10 * 4 * 1000;
4065 + ratov_j = msecs_to_jiffies(ratov_j);
4066 switch (rval) {
4067 case QLA_SUCCESS:
4068 - sp->done(sp, res);
4069 + if (wait_for_completion_timeout(&comp, ratov_j)) {
4070 + ql_dbg(ql_dbg_taskm, vha, 0xffff,
4071 + "%s: Abort wait timer (4 * R_A_TOV[%d]) expired\n",
4072 + __func__, ha->r_a_tov/10);
4073 + ret_cmd = true;
4074 + }
4075 + /* else FW return SP to driver */
4076 break;
4077 - case QLA_FUNCTION_PARAMETER_ERROR:
4078 - wait_for_completion(&comp);
4079 + default:
4080 + ret_cmd = true;
4081 break;
4082 }
4083
4084 spin_lock_irqsave(qp->qp_lock_ptr, *flags);
4085 - sp->comp = NULL;
4086 + if (ret_cmd && (!sp->completed || !sp->aborted))
4087 + sp->done(sp, res);
4088 + } else {
4089 + sp->done(sp, res);
4090 }
4091 -
4092 - atomic_dec(&sp->ref_count);
4093 }
4094
4095 static void
4096 @@ -1755,7 +1765,6 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)
4097 for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) {
4098 sp = req->outstanding_cmds[cnt];
4099 if (sp) {
4100 - req->outstanding_cmds[cnt] = NULL;
4101 switch (sp->cmd_type) {
4102 case TYPE_SRB:
4103 qla2x00_abort_srb(qp, sp, res, &flags);
4104 @@ -1777,6 +1786,7 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)
4105 default:
4106 break;
4107 }
4108 + req->outstanding_cmds[cnt] = NULL;
4109 }
4110 }
4111 spin_unlock_irqrestore(qp->qp_lock_ptr, flags);
4112 @@ -4666,7 +4676,8 @@ qla2x00_mem_free(struct qla_hw_data *ha)
4113 ha->sfp_data = NULL;
4114
4115 if (ha->flt)
4116 - dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE,
4117 + dma_free_coherent(&ha->pdev->dev,
4118 + sizeof(struct qla_flt_header) + FLT_REGIONS_SIZE,
4119 ha->flt, ha->flt_dma);
4120 ha->flt = NULL;
4121 ha->flt_dma = 0;
4122 diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
4123 index 3abab33e932c..4973c9edc26e 100644
4124 --- a/drivers/staging/exfat/exfat.h
4125 +++ b/drivers/staging/exfat/exfat.h
4126 @@ -943,8 +943,8 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir,
4127 s32 create_file(struct inode *inode, struct chain_t *p_dir,
4128 struct uni_name_t *p_uniname, u8 mode, struct file_id_t *fid);
4129 void remove_file(struct inode *inode, struct chain_t *p_dir, s32 entry);
4130 -s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 old_entry,
4131 - struct uni_name_t *p_uniname, struct file_id_t *fid);
4132 +s32 exfat_rename_file(struct inode *inode, struct chain_t *p_dir, s32 old_entry,
4133 + struct uni_name_t *p_uniname, struct file_id_t *fid);
4134 s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
4135 struct chain_t *p_newdir, struct uni_name_t *p_uniname,
4136 struct file_id_t *fid);
4137 diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c
4138 index 79174e5c4145..f3774a1912d1 100644
4139 --- a/drivers/staging/exfat/exfat_core.c
4140 +++ b/drivers/staging/exfat/exfat_core.c
4141 @@ -3381,8 +3381,8 @@ void remove_file(struct inode *inode, struct chain_t *p_dir, s32 entry)
4142 fs_func->delete_dir_entry(sb, p_dir, entry, 0, num_entries);
4143 }
4144
4145 -s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry,
4146 - struct uni_name_t *p_uniname, struct file_id_t *fid)
4147 +s32 exfat_rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry,
4148 + struct uni_name_t *p_uniname, struct file_id_t *fid)
4149 {
4150 s32 ret, newentry = -1, num_old_entries, num_new_entries;
4151 sector_t sector_old, sector_new;
4152 diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
4153 index 3b2b0ceb7297..58c7d66060f7 100644
4154 --- a/drivers/staging/exfat/exfat_super.c
4155 +++ b/drivers/staging/exfat/exfat_super.c
4156 @@ -1308,8 +1308,8 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
4157 fs_set_vol_flags(sb, VOL_DIRTY);
4158
4159 if (olddir.dir == newdir.dir)
4160 - ret = rename_file(new_parent_inode, &olddir, dentry, &uni_name,
4161 - fid);
4162 + ret = exfat_rename_file(new_parent_inode, &olddir, dentry,
4163 + &uni_name, fid);
4164 else
4165 ret = move_file(new_parent_inode, &olddir, dentry, &newdir,
4166 &uni_name, fid);
4167 diff --git a/drivers/staging/isdn/gigaset/usb-gigaset.c b/drivers/staging/isdn/gigaset/usb-gigaset.c
4168 index 1b9b43659bdf..a20c0bfa68f3 100644
4169 --- a/drivers/staging/isdn/gigaset/usb-gigaset.c
4170 +++ b/drivers/staging/isdn/gigaset/usb-gigaset.c
4171 @@ -571,8 +571,7 @@ static int gigaset_initcshw(struct cardstate *cs)
4172 {
4173 struct usb_cardstate *ucs;
4174
4175 - cs->hw.usb = ucs =
4176 - kmalloc(sizeof(struct usb_cardstate), GFP_KERNEL);
4177 + cs->hw.usb = ucs = kzalloc(sizeof(struct usb_cardstate), GFP_KERNEL);
4178 if (!ucs) {
4179 pr_err("out of memory\n");
4180 return -ENOMEM;
4181 @@ -584,9 +583,6 @@ static int gigaset_initcshw(struct cardstate *cs)
4182 ucs->bchars[3] = 0;
4183 ucs->bchars[4] = 0x11;
4184 ucs->bchars[5] = 0x13;
4185 - ucs->bulk_out_buffer = NULL;
4186 - ucs->bulk_out_urb = NULL;
4187 - ucs->read_urb = NULL;
4188 tasklet_init(&cs->write_tasklet,
4189 gigaset_modem_fill, (unsigned long) cs);
4190
4191 @@ -685,6 +681,11 @@ static int gigaset_probe(struct usb_interface *interface,
4192 return -ENODEV;
4193 }
4194
4195 + if (hostif->desc.bNumEndpoints < 2) {
4196 + dev_err(&interface->dev, "missing endpoints\n");
4197 + return -ENODEV;
4198 + }
4199 +
4200 dev_info(&udev->dev, "%s: Device matched ... !\n", __func__);
4201
4202 /* allocate memory for our device state and initialize it */
4203 @@ -704,6 +705,12 @@ static int gigaset_probe(struct usb_interface *interface,
4204
4205 endpoint = &hostif->endpoint[0].desc;
4206
4207 + if (!usb_endpoint_is_bulk_out(endpoint)) {
4208 + dev_err(&interface->dev, "missing bulk-out endpoint\n");
4209 + retval = -ENODEV;
4210 + goto error;
4211 + }
4212 +
4213 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
4214 ucs->bulk_out_size = buffer_size;
4215 ucs->bulk_out_epnum = usb_endpoint_num(endpoint);
4216 @@ -723,6 +730,12 @@ static int gigaset_probe(struct usb_interface *interface,
4217
4218 endpoint = &hostif->endpoint[1].desc;
4219
4220 + if (!usb_endpoint_is_int_in(endpoint)) {
4221 + dev_err(&interface->dev, "missing int-in endpoint\n");
4222 + retval = -ENODEV;
4223 + goto error;
4224 + }
4225 +
4226 ucs->busy = 0;
4227
4228 ucs->read_urb = usb_alloc_urb(0, GFP_KERNEL);
4229 diff --git a/drivers/staging/media/hantro/hantro_g1_h264_dec.c b/drivers/staging/media/hantro/hantro_g1_h264_dec.c
4230 index 7ab534936843..636bf972adcf 100644
4231 --- a/drivers/staging/media/hantro/hantro_g1_h264_dec.c
4232 +++ b/drivers/staging/media/hantro/hantro_g1_h264_dec.c
4233 @@ -34,9 +34,11 @@ static void set_params(struct hantro_ctx *ctx)
4234 reg = G1_REG_DEC_CTRL0_DEC_AXI_WR_ID(0x0);
4235 if (sps->flags & V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD)
4236 reg |= G1_REG_DEC_CTRL0_SEQ_MBAFF_E;
4237 - reg |= G1_REG_DEC_CTRL0_PICORD_COUNT_E;
4238 - if (dec_param->nal_ref_idc)
4239 - reg |= G1_REG_DEC_CTRL0_WRITE_MVS_E;
4240 + if (sps->profile_idc > 66) {
4241 + reg |= G1_REG_DEC_CTRL0_PICORD_COUNT_E;
4242 + if (dec_param->nal_ref_idc)
4243 + reg |= G1_REG_DEC_CTRL0_WRITE_MVS_E;
4244 + }
4245
4246 if (!(sps->flags & V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY) &&
4247 (sps->flags & V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD ||
4248 @@ -246,7 +248,7 @@ static void set_buffers(struct hantro_ctx *ctx)
4249 vdpu_write_relaxed(vpu, dst_dma, G1_REG_ADDR_DST);
4250
4251 /* Higher profiles require DMV buffer appended to reference frames. */
4252 - if (ctrls->sps->profile_idc > 66) {
4253 + if (ctrls->sps->profile_idc > 66 && ctrls->decode->nal_ref_idc) {
4254 size_t pic_size = ctx->h264_dec.pic_size;
4255 size_t mv_offset = round_up(pic_size, 8);
4256
4257 diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c
4258 index 3dae52abb96c..fcf95c1d39ca 100644
4259 --- a/drivers/staging/media/hantro/hantro_v4l2.c
4260 +++ b/drivers/staging/media/hantro/hantro_v4l2.c
4261 @@ -367,19 +367,26 @@ vidioc_s_fmt_out_mplane(struct file *file, void *priv, struct v4l2_format *f)
4262 {
4263 struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
4264 struct hantro_ctx *ctx = fh_to_ctx(priv);
4265 + struct vb2_queue *vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
4266 const struct hantro_fmt *formats;
4267 unsigned int num_fmts;
4268 - struct vb2_queue *vq;
4269 int ret;
4270
4271 - /* Change not allowed if queue is busy. */
4272 - vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
4273 - if (vb2_is_busy(vq))
4274 - return -EBUSY;
4275 + ret = vidioc_try_fmt_out_mplane(file, priv, f);
4276 + if (ret)
4277 + return ret;
4278
4279 if (!hantro_is_encoder_ctx(ctx)) {
4280 struct vb2_queue *peer_vq;
4281
4282 + /*
4283 + * In order to support dynamic resolution change,
4284 + * the decoder admits a resolution change, as long
4285 + * as the pixelformat remains. Can't be done if streaming.
4286 + */
4287 + if (vb2_is_streaming(vq) || (vb2_is_busy(vq) &&
4288 + pix_mp->pixelformat != ctx->src_fmt.pixelformat))
4289 + return -EBUSY;
4290 /*
4291 * Since format change on the OUTPUT queue will reset
4292 * the CAPTURE queue, we can't allow doing so
4293 @@ -389,12 +396,15 @@ vidioc_s_fmt_out_mplane(struct file *file, void *priv, struct v4l2_format *f)
4294 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
4295 if (vb2_is_busy(peer_vq))
4296 return -EBUSY;
4297 + } else {
4298 + /*
4299 + * The encoder doesn't admit a format change if
4300 + * there are OUTPUT buffers allocated.
4301 + */
4302 + if (vb2_is_busy(vq))
4303 + return -EBUSY;
4304 }
4305
4306 - ret = vidioc_try_fmt_out_mplane(file, priv, f);
4307 - if (ret)
4308 - return ret;
4309 -
4310 formats = hantro_get_formats(ctx, &num_fmts);
4311 ctx->vpu_src_fmt = hantro_find_format(formats, num_fmts,
4312 pix_mp->pixelformat);
4313 diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
4314 index 4fac9dca798e..a7cac0719b8b 100644
4315 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
4316 +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
4317 @@ -70,7 +70,7 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
4318 phost_conf = pusbd->actconfig;
4319 pconf_desc = &phost_conf->desc;
4320
4321 - phost_iface = &usb_intf->altsetting[0];
4322 + phost_iface = usb_intf->cur_altsetting;
4323 piface_desc = &phost_iface->desc;
4324
4325 pdvobjpriv->NumInterfaces = pconf_desc->bNumInterfaces;
4326 diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
4327 index ba1288297ee4..a87562f632a7 100644
4328 --- a/drivers/staging/rtl8712/usb_intf.c
4329 +++ b/drivers/staging/rtl8712/usb_intf.c
4330 @@ -247,7 +247,7 @@ static uint r8712_usb_dvobj_init(struct _adapter *padapter)
4331
4332 pdvobjpriv->padapter = padapter;
4333 padapter->eeprom_address_size = 6;
4334 - phost_iface = &pintf->altsetting[0];
4335 + phost_iface = pintf->cur_altsetting;
4336 piface_desc = &phost_iface->desc;
4337 pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints;
4338 if (pusbd->speed == USB_SPEED_HIGH) {
4339 diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
4340 index b1595b13dea8..af6bf0736b52 100644
4341 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
4342 +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
4343 @@ -3299,7 +3299,7 @@ static int __init vchiq_driver_init(void)
4344 return 0;
4345
4346 region_unregister:
4347 - platform_driver_unregister(&vchiq_driver);
4348 + unregister_chrdev_region(vchiq_devid, 1);
4349
4350 class_destroy:
4351 class_destroy(vchiq_class);
4352 diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
4353 index 8b0ea8c70d73..635cf0466b59 100644
4354 --- a/drivers/usb/atm/ueagle-atm.c
4355 +++ b/drivers/usb/atm/ueagle-atm.c
4356 @@ -2124,10 +2124,11 @@ resubmit:
4357 /*
4358 * Start the modem : init the data and start kernel thread
4359 */
4360 -static int uea_boot(struct uea_softc *sc)
4361 +static int uea_boot(struct uea_softc *sc, struct usb_interface *intf)
4362 {
4363 - int ret, size;
4364 struct intr_pkt *intr;
4365 + int ret = -ENOMEM;
4366 + int size;
4367
4368 uea_enters(INS_TO_USBDEV(sc));
4369
4370 @@ -2152,6 +2153,11 @@ static int uea_boot(struct uea_softc *sc)
4371 if (UEA_CHIP_VERSION(sc) == ADI930)
4372 load_XILINX_firmware(sc);
4373
4374 + if (intf->cur_altsetting->desc.bNumEndpoints < 1) {
4375 + ret = -ENODEV;
4376 + goto err0;
4377 + }
4378 +
4379 intr = kmalloc(size, GFP_KERNEL);
4380 if (!intr)
4381 goto err0;
4382 @@ -2163,8 +2169,7 @@ static int uea_boot(struct uea_softc *sc)
4383 usb_fill_int_urb(sc->urb_int, sc->usb_dev,
4384 usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE),
4385 intr, size, uea_intr, sc,
4386 - sc->usb_dev->actconfig->interface[0]->altsetting[0].
4387 - endpoint[0].desc.bInterval);
4388 + intf->cur_altsetting->endpoint[0].desc.bInterval);
4389
4390 ret = usb_submit_urb(sc->urb_int, GFP_KERNEL);
4391 if (ret < 0) {
4392 @@ -2179,6 +2184,7 @@ static int uea_boot(struct uea_softc *sc)
4393 sc->kthread = kthread_create(uea_kthread, sc, "ueagle-atm");
4394 if (IS_ERR(sc->kthread)) {
4395 uea_err(INS_TO_USBDEV(sc), "failed to create thread\n");
4396 + ret = PTR_ERR(sc->kthread);
4397 goto err2;
4398 }
4399
4400 @@ -2193,7 +2199,7 @@ err1:
4401 kfree(intr);
4402 err0:
4403 uea_leaves(INS_TO_USBDEV(sc));
4404 - return -ENOMEM;
4405 + return ret;
4406 }
4407
4408 /*
4409 @@ -2548,7 +2554,7 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
4410 }
4411 }
4412
4413 - ret = uea_boot(sc);
4414 + ret = uea_boot(sc, intf);
4415 if (ret < 0)
4416 goto error;
4417
4418 diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c
4419 index 87338f9eb5be..ed204cbb63ea 100644
4420 --- a/drivers/usb/common/usb-conn-gpio.c
4421 +++ b/drivers/usb/common/usb-conn-gpio.c
4422 @@ -156,7 +156,8 @@ static int usb_conn_probe(struct platform_device *pdev)
4423
4424 info->vbus = devm_regulator_get(dev, "vbus");
4425 if (IS_ERR(info->vbus)) {
4426 - dev_err(dev, "failed to get vbus\n");
4427 + if (PTR_ERR(info->vbus) != -EPROBE_DEFER)
4428 + dev_err(dev, "failed to get vbus\n");
4429 return PTR_ERR(info->vbus);
4430 }
4431
4432 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
4433 index 236313f41f4a..dfe9ac8d2375 100644
4434 --- a/drivers/usb/core/hub.c
4435 +++ b/drivers/usb/core/hub.c
4436 @@ -5814,7 +5814,7 @@ re_enumerate_no_bos:
4437
4438 /**
4439 * usb_reset_device - warn interface drivers and perform a USB port reset
4440 - * @udev: device to reset (not in SUSPENDED or NOTATTACHED state)
4441 + * @udev: device to reset (not in NOTATTACHED state)
4442 *
4443 * Warns all drivers bound to registered interfaces (using their pre_reset
4444 * method), performs the port reset, and then lets the drivers know that
4445 @@ -5842,8 +5842,7 @@ int usb_reset_device(struct usb_device *udev)
4446 struct usb_host_config *config = udev->actconfig;
4447 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent);
4448
4449 - if (udev->state == USB_STATE_NOTATTACHED ||
4450 - udev->state == USB_STATE_SUSPENDED) {
4451 + if (udev->state == USB_STATE_NOTATTACHED) {
4452 dev_dbg(&udev->dev, "device reset not allowed in state %d\n",
4453 udev->state);
4454 return -EINVAL;
4455 diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
4456 index 0eab79f82ce4..da923ec17612 100644
4457 --- a/drivers/usb/core/urb.c
4458 +++ b/drivers/usb/core/urb.c
4459 @@ -45,6 +45,7 @@ void usb_init_urb(struct urb *urb)
4460 if (urb) {
4461 memset(urb, 0, sizeof(*urb));
4462 kref_init(&urb->kref);
4463 + INIT_LIST_HEAD(&urb->urb_list);
4464 INIT_LIST_HEAD(&urb->anchor_list);
4465 }
4466 }
4467 diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
4468 index 023f0357efd7..294276f7deb9 100644
4469 --- a/drivers/usb/dwc3/dwc3-pci.c
4470 +++ b/drivers/usb/dwc3/dwc3-pci.c
4471 @@ -29,7 +29,8 @@
4472 #define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa
4473 #define PCI_DEVICE_ID_INTEL_APL 0x5aaa
4474 #define PCI_DEVICE_ID_INTEL_KBP 0xa2b0
4475 -#define PCI_DEVICE_ID_INTEL_CMLH 0x02ee
4476 +#define PCI_DEVICE_ID_INTEL_CMLLP 0x02ee
4477 +#define PCI_DEVICE_ID_INTEL_CMLH 0x06ee
4478 #define PCI_DEVICE_ID_INTEL_GLK 0x31aa
4479 #define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee
4480 #define PCI_DEVICE_ID_INTEL_CNPH 0xa36e
4481 @@ -308,6 +309,9 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
4482 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
4483 (kernel_ulong_t) &dwc3_pci_mrfld_properties, },
4484
4485 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CMLLP),
4486 + (kernel_ulong_t) &dwc3_pci_intel_properties, },
4487 +
4488 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CMLH),
4489 (kernel_ulong_t) &dwc3_pci_intel_properties, },
4490
4491 diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
4492 index 3996b9c4ff8d..fd1b100d2927 100644
4493 --- a/drivers/usb/dwc3/ep0.c
4494 +++ b/drivers/usb/dwc3/ep0.c
4495 @@ -1117,6 +1117,9 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc,
4496 void dwc3_ep0_interrupt(struct dwc3 *dwc,
4497 const struct dwc3_event_depevt *event)
4498 {
4499 + struct dwc3_ep *dep = dwc->eps[event->endpoint_number];
4500 + u8 cmd;
4501 +
4502 switch (event->endpoint_event) {
4503 case DWC3_DEPEVT_XFERCOMPLETE:
4504 dwc3_ep0_xfer_complete(dwc, event);
4505 @@ -1129,7 +1132,12 @@ void dwc3_ep0_interrupt(struct dwc3 *dwc,
4506 case DWC3_DEPEVT_XFERINPROGRESS:
4507 case DWC3_DEPEVT_RXTXFIFOEVT:
4508 case DWC3_DEPEVT_STREAMEVT:
4509 + break;
4510 case DWC3_DEPEVT_EPCMDCMPLT:
4511 + cmd = DEPEVT_PARAMETER_CMD(event->parameters);
4512 +
4513 + if (cmd == DWC3_DEPCMD_ENDTRANSFER)
4514 + dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
4515 break;
4516 }
4517 }
4518 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
4519 index a9aba716bf80..0c960a97ea02 100644
4520 --- a/drivers/usb/dwc3/gadget.c
4521 +++ b/drivers/usb/dwc3/gadget.c
4522 @@ -2491,7 +2491,7 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
4523
4524 req->request.actual = req->request.length - req->remaining;
4525
4526 - if (!dwc3_gadget_ep_request_completed(req) &&
4527 + if (!dwc3_gadget_ep_request_completed(req) ||
4528 req->num_pending_sgs) {
4529 __dwc3_gadget_kick_transfer(dep);
4530 goto out;
4531 @@ -2719,6 +2719,9 @@ static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force,
4532 WARN_ON_ONCE(ret);
4533 dep->resource_index = 0;
4534
4535 + if (!interrupt)
4536 + dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
4537 +
4538 if (dwc3_is_usb31(dwc) || dwc->revision < DWC3_REVISION_310A)
4539 udelay(100);
4540 }
4541 diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
4542 index 33852c2b29d1..ab9ac48a751a 100644
4543 --- a/drivers/usb/gadget/configfs.c
4544 +++ b/drivers/usb/gadget/configfs.c
4545 @@ -1544,6 +1544,7 @@ static struct config_group *gadgets_make(
4546 gi->composite.resume = NULL;
4547 gi->composite.max_speed = USB_SPEED_SUPER;
4548
4549 + spin_lock_init(&gi->spinlock);
4550 mutex_init(&gi->lock);
4551 INIT_LIST_HEAD(&gi->string_list);
4552 INIT_LIST_HEAD(&gi->available_func);
4553 diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
4554 index 3d499d93c083..a8f1e5707c14 100644
4555 --- a/drivers/usb/gadget/udc/dummy_hcd.c
4556 +++ b/drivers/usb/gadget/udc/dummy_hcd.c
4557 @@ -2725,7 +2725,7 @@ static struct platform_driver dummy_hcd_driver = {
4558 };
4559
4560 /*-------------------------------------------------------------------------*/
4561 -#define MAX_NUM_UDC 2
4562 +#define MAX_NUM_UDC 32
4563 static struct platform_device *the_udc_pdev[MAX_NUM_UDC];
4564 static struct platform_device *the_hcd_pdev[MAX_NUM_UDC];
4565
4566 diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
4567 index 265dab2bbfac..3344fb8c4181 100644
4568 --- a/drivers/usb/gadget/udc/pch_udc.c
4569 +++ b/drivers/usb/gadget/udc/pch_udc.c
4570 @@ -1519,7 +1519,6 @@ static void pch_udc_free_dma_chain(struct pch_udc_dev *dev,
4571 td = phys_to_virt(addr);
4572 addr2 = (dma_addr_t)td->next;
4573 dma_pool_free(dev->data_requests, td, addr);
4574 - td->next = 0x00;
4575 addr = addr2;
4576 }
4577 req->chain_len = 1;
4578 diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
4579 index b7d23c438756..7a3a29e5e9d2 100644
4580 --- a/drivers/usb/host/xhci-hub.c
4581 +++ b/drivers/usb/host/xhci-hub.c
4582 @@ -806,7 +806,7 @@ static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status,
4583
4584 static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
4585 u32 *status, u32 portsc,
4586 - unsigned long flags)
4587 + unsigned long *flags)
4588 {
4589 struct xhci_bus_state *bus_state;
4590 struct xhci_hcd *xhci;
4591 @@ -860,11 +860,11 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
4592 xhci_test_and_clear_bit(xhci, port, PORT_PLC);
4593 xhci_set_link_state(xhci, port, XDEV_U0);
4594
4595 - spin_unlock_irqrestore(&xhci->lock, flags);
4596 + spin_unlock_irqrestore(&xhci->lock, *flags);
4597 time_left = wait_for_completion_timeout(
4598 &bus_state->rexit_done[wIndex],
4599 msecs_to_jiffies(XHCI_MAX_REXIT_TIMEOUT_MS));
4600 - spin_lock_irqsave(&xhci->lock, flags);
4601 + spin_lock_irqsave(&xhci->lock, *flags);
4602
4603 if (time_left) {
4604 slot_id = xhci_find_slot_id_by_port(hcd, xhci,
4605 @@ -920,11 +920,13 @@ static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status,
4606 {
4607 struct xhci_bus_state *bus_state;
4608 struct xhci_hcd *xhci;
4609 + struct usb_hcd *hcd;
4610 u32 link_state;
4611 u32 portnum;
4612
4613 bus_state = &port->rhub->bus_state;
4614 xhci = hcd_to_xhci(port->rhub->hcd);
4615 + hcd = port->rhub->hcd;
4616 link_state = portsc & PORT_PLS_MASK;
4617 portnum = port->hcd_portnum;
4618
4619 @@ -952,12 +954,20 @@ static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status,
4620 bus_state->suspended_ports &= ~(1 << portnum);
4621 }
4622
4623 + /* remote wake resume signaling complete */
4624 + if (bus_state->port_remote_wakeup & (1 << portnum) &&
4625 + link_state != XDEV_RESUME &&
4626 + link_state != XDEV_RECOVERY) {
4627 + bus_state->port_remote_wakeup &= ~(1 << portnum);
4628 + usb_hcd_end_port_resume(&hcd->self, portnum);
4629 + }
4630 +
4631 xhci_hub_report_usb3_link_state(xhci, status, portsc);
4632 xhci_del_comp_mod_timer(xhci, portsc, portnum);
4633 }
4634
4635 static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
4636 - u32 portsc, unsigned long flags)
4637 + u32 portsc, unsigned long *flags)
4638 {
4639 struct xhci_bus_state *bus_state;
4640 u32 link_state;
4641 @@ -1007,7 +1017,7 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
4642 static u32 xhci_get_port_status(struct usb_hcd *hcd,
4643 struct xhci_bus_state *bus_state,
4644 u16 wIndex, u32 raw_port_status,
4645 - unsigned long flags)
4646 + unsigned long *flags)
4647 __releases(&xhci->lock)
4648 __acquires(&xhci->lock)
4649 {
4650 @@ -1130,7 +1140,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
4651 }
4652 trace_xhci_get_port_status(wIndex, temp);
4653 status = xhci_get_port_status(hcd, bus_state, wIndex, temp,
4654 - flags);
4655 + &flags);
4656 if (status == 0xffffffff)
4657 goto error;
4658
4659 diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
4660 index e16eda6e2b8b..3b1388fa2f36 100644
4661 --- a/drivers/usb/host/xhci-mem.c
4662 +++ b/drivers/usb/host/xhci-mem.c
4663 @@ -1909,13 +1909,17 @@ no_bw:
4664 xhci->usb3_rhub.num_ports = 0;
4665 xhci->num_active_eps = 0;
4666 kfree(xhci->usb2_rhub.ports);
4667 + kfree(xhci->usb2_rhub.psi);
4668 kfree(xhci->usb3_rhub.ports);
4669 + kfree(xhci->usb3_rhub.psi);
4670 kfree(xhci->hw_ports);
4671 kfree(xhci->rh_bw);
4672 kfree(xhci->ext_caps);
4673
4674 xhci->usb2_rhub.ports = NULL;
4675 + xhci->usb2_rhub.psi = NULL;
4676 xhci->usb3_rhub.ports = NULL;
4677 + xhci->usb3_rhub.psi = NULL;
4678 xhci->hw_ports = NULL;
4679 xhci->rh_bw = NULL;
4680 xhci->ext_caps = NULL;
4681 diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
4682 index 1e0236e90687..1904ef56f61c 100644
4683 --- a/drivers/usb/host/xhci-pci.c
4684 +++ b/drivers/usb/host/xhci-pci.c
4685 @@ -519,6 +519,18 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
4686 }
4687 #endif /* CONFIG_PM */
4688
4689 +static void xhci_pci_shutdown(struct usb_hcd *hcd)
4690 +{
4691 + struct xhci_hcd *xhci = hcd_to_xhci(hcd);
4692 + struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
4693 +
4694 + xhci_shutdown(hcd);
4695 +
4696 + /* Yet another workaround for spurious wakeups at shutdown with HSW */
4697 + if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
4698 + pci_set_power_state(pdev, PCI_D3hot);
4699 +}
4700 +
4701 /*-------------------------------------------------------------------------*/
4702
4703 /* PCI driver selection metadata; PCI hotplugging uses this */
4704 @@ -554,6 +566,7 @@ static int __init xhci_pci_init(void)
4705 #ifdef CONFIG_PM
4706 xhci_pci_hc_driver.pci_suspend = xhci_pci_suspend;
4707 xhci_pci_hc_driver.pci_resume = xhci_pci_resume;
4708 + xhci_pci_hc_driver.shutdown = xhci_pci_shutdown;
4709 #endif
4710 return pci_register_driver(&xhci_pci_driver);
4711 }
4712 diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
4713 index e7aab31fd9a5..4a2fe56940bd 100644
4714 --- a/drivers/usb/host/xhci-ring.c
4715 +++ b/drivers/usb/host/xhci-ring.c
4716 @@ -1624,7 +1624,6 @@ static void handle_port_status(struct xhci_hcd *xhci,
4717 slot_id = xhci_find_slot_id_by_port(hcd, xhci, hcd_portnum + 1);
4718 if (slot_id && xhci->devs[slot_id])
4719 xhci->devs[slot_id]->flags |= VDEV_PORT_ERROR;
4720 - bus_state->port_remote_wakeup &= ~(1 << hcd_portnum);
4721 }
4722
4723 if ((portsc & PORT_PLC) && (portsc & PORT_PLS_MASK) == XDEV_RESUME) {
4724 @@ -1644,6 +1643,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
4725 */
4726 bus_state->port_remote_wakeup |= 1 << hcd_portnum;
4727 xhci_test_and_clear_bit(xhci, port, PORT_PLC);
4728 + usb_hcd_start_port_resume(&hcd->self, hcd_portnum);
4729 xhci_set_link_state(xhci, port, XDEV_U0);
4730 /* Need to wait until the next link state change
4731 * indicates the device is actually in U0.
4732 @@ -1684,7 +1684,6 @@ static void handle_port_status(struct xhci_hcd *xhci,
4733 if (slot_id && xhci->devs[slot_id])
4734 xhci_ring_device(xhci, slot_id);
4735 if (bus_state->port_remote_wakeup & (1 << hcd_portnum)) {
4736 - bus_state->port_remote_wakeup &= ~(1 << hcd_portnum);
4737 xhci_test_and_clear_bit(xhci, port, PORT_PLC);
4738 usb_wakeup_notification(hcd->self.root_hub,
4739 hcd_portnum + 1);
4740 @@ -2378,7 +2377,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
4741 case COMP_SUCCESS:
4742 if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) == 0)
4743 break;
4744 - if (xhci->quirks & XHCI_TRUST_TX_LENGTH)
4745 + if (xhci->quirks & XHCI_TRUST_TX_LENGTH ||
4746 + ep_ring->last_td_was_short)
4747 trb_comp_code = COMP_SHORT_PACKET;
4748 else
4749 xhci_warn_ratelimited(xhci,
4750 diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
4751 index 2ff7c911fbd0..dc172513a4aa 100644
4752 --- a/drivers/usb/host/xhci-tegra.c
4753 +++ b/drivers/usb/host/xhci-tegra.c
4754 @@ -755,7 +755,6 @@ static int tegra_xusb_runtime_suspend(struct device *dev)
4755 {
4756 struct tegra_xusb *tegra = dev_get_drvdata(dev);
4757
4758 - tegra_xusb_phy_disable(tegra);
4759 regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
4760 tegra_xusb_clk_disable(tegra);
4761
4762 @@ -779,16 +778,8 @@ static int tegra_xusb_runtime_resume(struct device *dev)
4763 goto disable_clk;
4764 }
4765
4766 - err = tegra_xusb_phy_enable(tegra);
4767 - if (err < 0) {
4768 - dev_err(dev, "failed to enable PHYs: %d\n", err);
4769 - goto disable_regulator;
4770 - }
4771 -
4772 return 0;
4773
4774 -disable_regulator:
4775 - regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
4776 disable_clk:
4777 tegra_xusb_clk_disable(tegra);
4778 return err;
4779 @@ -1181,6 +1172,12 @@ static int tegra_xusb_probe(struct platform_device *pdev)
4780 */
4781 platform_set_drvdata(pdev, tegra);
4782
4783 + err = tegra_xusb_phy_enable(tegra);
4784 + if (err < 0) {
4785 + dev_err(&pdev->dev, "failed to enable PHYs: %d\n", err);
4786 + goto put_hcd;
4787 + }
4788 +
4789 pm_runtime_enable(&pdev->dev);
4790 if (pm_runtime_enabled(&pdev->dev))
4791 err = pm_runtime_get_sync(&pdev->dev);
4792 @@ -1189,7 +1186,7 @@ static int tegra_xusb_probe(struct platform_device *pdev)
4793
4794 if (err < 0) {
4795 dev_err(&pdev->dev, "failed to enable device: %d\n", err);
4796 - goto disable_rpm;
4797 + goto disable_phy;
4798 }
4799
4800 tegra_xusb_config(tegra, regs);
4801 @@ -1275,9 +1272,11 @@ remove_usb2:
4802 put_rpm:
4803 if (!pm_runtime_status_suspended(&pdev->dev))
4804 tegra_xusb_runtime_suspend(&pdev->dev);
4805 -disable_rpm:
4806 - pm_runtime_disable(&pdev->dev);
4807 +put_hcd:
4808 usb_put_hcd(tegra->hcd);
4809 +disable_phy:
4810 + tegra_xusb_phy_disable(tegra);
4811 + pm_runtime_disable(&pdev->dev);
4812 put_powerdomains:
4813 if (!of_property_read_bool(pdev->dev.of_node, "power-domains")) {
4814 tegra_powergate_power_off(TEGRA_POWERGATE_XUSBC);
4815 @@ -1314,6 +1313,8 @@ static int tegra_xusb_remove(struct platform_device *pdev)
4816 tegra_xusb_powerdomain_remove(&pdev->dev, tegra);
4817 }
4818
4819 + tegra_xusb_phy_disable(tegra);
4820 +
4821 tegra_xusb_padctl_put(tegra->padctl);
4822
4823 return 0;
4824 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
4825 index 6c17e3fe181a..9b3b1b16eafb 100644
4826 --- a/drivers/usb/host/xhci.c
4827 +++ b/drivers/usb/host/xhci.c
4828 @@ -770,7 +770,7 @@ static void xhci_stop(struct usb_hcd *hcd)
4829 *
4830 * This will only ever be called with the main usb_hcd (the USB3 roothub).
4831 */
4832 -static void xhci_shutdown(struct usb_hcd *hcd)
4833 +void xhci_shutdown(struct usb_hcd *hcd)
4834 {
4835 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
4836
4837 @@ -789,11 +789,8 @@ static void xhci_shutdown(struct usb_hcd *hcd)
4838 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
4839 "xhci_shutdown completed - status = %x",
4840 readl(&xhci->op_regs->status));
4841 -
4842 - /* Yet another workaround for spurious wakeups at shutdown with HSW */
4843 - if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
4844 - pci_set_power_state(to_pci_dev(hcd->self.sysdev), PCI_D3hot);
4845 }
4846 +EXPORT_SYMBOL_GPL(xhci_shutdown);
4847
4848 #ifdef CONFIG_PM
4849 static void xhci_save_registers(struct xhci_hcd *xhci)
4850 @@ -973,7 +970,7 @@ static bool xhci_pending_portevent(struct xhci_hcd *xhci)
4851 int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
4852 {
4853 int rc = 0;
4854 - unsigned int delay = XHCI_MAX_HALT_USEC;
4855 + unsigned int delay = XHCI_MAX_HALT_USEC * 2;
4856 struct usb_hcd *hcd = xhci_to_hcd(xhci);
4857 u32 command;
4858 u32 res;
4859 diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
4860 index f9f88626a57a..973d665052a2 100644
4861 --- a/drivers/usb/host/xhci.h
4862 +++ b/drivers/usb/host/xhci.h
4863 @@ -2050,6 +2050,7 @@ int xhci_start(struct xhci_hcd *xhci);
4864 int xhci_reset(struct xhci_hcd *xhci);
4865 int xhci_run(struct usb_hcd *hcd);
4866 int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
4867 +void xhci_shutdown(struct usb_hcd *hcd);
4868 void xhci_init_driver(struct hc_driver *drv,
4869 const struct xhci_driver_overrides *over);
4870 int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id);
4871 diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
4872 index 6f5edb9fc61e..d8d157c4c271 100644
4873 --- a/drivers/usb/misc/adutux.c
4874 +++ b/drivers/usb/misc/adutux.c
4875 @@ -669,7 +669,7 @@ static int adu_probe(struct usb_interface *interface,
4876 init_waitqueue_head(&dev->read_wait);
4877 init_waitqueue_head(&dev->write_wait);
4878
4879 - res = usb_find_common_endpoints_reverse(&interface->altsetting[0],
4880 + res = usb_find_common_endpoints_reverse(interface->cur_altsetting,
4881 NULL, NULL,
4882 &dev->interrupt_in_endpoint,
4883 &dev->interrupt_out_endpoint);
4884 diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
4885 index 20b0f91a5d9b..bb24527f3c70 100644
4886 --- a/drivers/usb/misc/idmouse.c
4887 +++ b/drivers/usb/misc/idmouse.c
4888 @@ -337,7 +337,7 @@ static int idmouse_probe(struct usb_interface *interface,
4889 int result;
4890
4891 /* check if we have gotten the data or the hid interface */
4892 - iface_desc = &interface->altsetting[0];
4893 + iface_desc = interface->cur_altsetting;
4894 if (iface_desc->desc.bInterfaceClass != 0x0A)
4895 return -ENODEV;
4896
4897 diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
4898 index ac2b4fcc265f..f48a23adbc35 100644
4899 --- a/drivers/usb/mon/mon_bin.c
4900 +++ b/drivers/usb/mon/mon_bin.c
4901 @@ -1039,12 +1039,18 @@ static long mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg
4902
4903 mutex_lock(&rp->fetch_lock);
4904 spin_lock_irqsave(&rp->b_lock, flags);
4905 - mon_free_buff(rp->b_vec, rp->b_size/CHUNK_SIZE);
4906 - kfree(rp->b_vec);
4907 - rp->b_vec = vec;
4908 - rp->b_size = size;
4909 - rp->b_read = rp->b_in = rp->b_out = rp->b_cnt = 0;
4910 - rp->cnt_lost = 0;
4911 + if (rp->mmap_active) {
4912 + mon_free_buff(vec, size/CHUNK_SIZE);
4913 + kfree(vec);
4914 + ret = -EBUSY;
4915 + } else {
4916 + mon_free_buff(rp->b_vec, rp->b_size/CHUNK_SIZE);
4917 + kfree(rp->b_vec);
4918 + rp->b_vec = vec;
4919 + rp->b_size = size;
4920 + rp->b_read = rp->b_in = rp->b_out = rp->b_cnt = 0;
4921 + rp->cnt_lost = 0;
4922 + }
4923 spin_unlock_irqrestore(&rp->b_lock, flags);
4924 mutex_unlock(&rp->fetch_lock);
4925 }
4926 @@ -1216,13 +1222,21 @@ mon_bin_poll(struct file *file, struct poll_table_struct *wait)
4927 static void mon_bin_vma_open(struct vm_area_struct *vma)
4928 {
4929 struct mon_reader_bin *rp = vma->vm_private_data;
4930 + unsigned long flags;
4931 +
4932 + spin_lock_irqsave(&rp->b_lock, flags);
4933 rp->mmap_active++;
4934 + spin_unlock_irqrestore(&rp->b_lock, flags);
4935 }
4936
4937 static void mon_bin_vma_close(struct vm_area_struct *vma)
4938 {
4939 + unsigned long flags;
4940 +
4941 struct mon_reader_bin *rp = vma->vm_private_data;
4942 + spin_lock_irqsave(&rp->b_lock, flags);
4943 rp->mmap_active--;
4944 + spin_unlock_irqrestore(&rp->b_lock, flags);
4945 }
4946
4947 /*
4948 @@ -1234,16 +1248,12 @@ static vm_fault_t mon_bin_vma_fault(struct vm_fault *vmf)
4949 unsigned long offset, chunk_idx;
4950 struct page *pageptr;
4951
4952 - mutex_lock(&rp->fetch_lock);
4953 offset = vmf->pgoff << PAGE_SHIFT;
4954 - if (offset >= rp->b_size) {
4955 - mutex_unlock(&rp->fetch_lock);
4956 + if (offset >= rp->b_size)
4957 return VM_FAULT_SIGBUS;
4958 - }
4959 chunk_idx = offset / CHUNK_SIZE;
4960 pageptr = rp->b_vec[chunk_idx].pg;
4961 get_page(pageptr);
4962 - mutex_unlock(&rp->fetch_lock);
4963 vmf->page = pageptr;
4964 return 0;
4965 }
4966 diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
4967 index 94b4e7db2b94..97e3d75b19a3 100644
4968 --- a/drivers/usb/roles/class.c
4969 +++ b/drivers/usb/roles/class.c
4970 @@ -169,8 +169,8 @@ EXPORT_SYMBOL_GPL(fwnode_usb_role_switch_get);
4971 void usb_role_switch_put(struct usb_role_switch *sw)
4972 {
4973 if (!IS_ERR_OR_NULL(sw)) {
4974 - put_device(&sw->dev);
4975 module_put(sw->dev.parent->driver->owner);
4976 + put_device(&sw->dev);
4977 }
4978 }
4979 EXPORT_SYMBOL_GPL(usb_role_switch_put);
4980 diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
4981 index 48a439298a68..9690a5f4b9d6 100644
4982 --- a/drivers/usb/serial/io_edgeport.c
4983 +++ b/drivers/usb/serial/io_edgeport.c
4984 @@ -2901,16 +2901,18 @@ static int edge_startup(struct usb_serial *serial)
4985 response = 0;
4986
4987 if (edge_serial->is_epic) {
4988 + struct usb_host_interface *alt;
4989 +
4990 + alt = serial->interface->cur_altsetting;
4991 +
4992 /* EPIC thing, set up our interrupt polling now and our read
4993 * urb, so that the device knows it really is connected. */
4994 interrupt_in_found = bulk_in_found = bulk_out_found = false;
4995 - for (i = 0; i < serial->interface->altsetting[0]
4996 - .desc.bNumEndpoints; ++i) {
4997 + for (i = 0; i < alt->desc.bNumEndpoints; ++i) {
4998 struct usb_endpoint_descriptor *endpoint;
4999 int buffer_size;
5000
5001 - endpoint = &serial->interface->altsetting[0].
5002 - endpoint[i].desc;
5003 + endpoint = &alt->endpoint[i].desc;
5004 buffer_size = usb_endpoint_maxp(endpoint);
5005 if (!interrupt_in_found &&
5006 (usb_endpoint_is_int_in(endpoint))) {
5007 diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
5008 index 34538253f12c..475b9c692827 100644
5009 --- a/drivers/usb/storage/uas.c
5010 +++ b/drivers/usb/storage/uas.c
5011 @@ -825,6 +825,10 @@ static int uas_slave_configure(struct scsi_device *sdev)
5012 sdev->wce_default_on = 1;
5013 }
5014
5015 + /* Some disks cannot handle READ_CAPACITY_16 */
5016 + if (devinfo->flags & US_FL_NO_READ_CAPACITY_16)
5017 + sdev->no_read_capacity_16 = 1;
5018 +
5019 /*
5020 * Some disks return the total number of blocks in response
5021 * to READ CAPACITY rather than the highest block number.
5022 @@ -833,6 +837,12 @@ static int uas_slave_configure(struct scsi_device *sdev)
5023 if (devinfo->flags & US_FL_FIX_CAPACITY)
5024 sdev->fix_capacity = 1;
5025
5026 + /*
5027 + * in some cases we have to guess
5028 + */
5029 + if (devinfo->flags & US_FL_CAPACITY_HEURISTICS)
5030 + sdev->guess_capacity = 1;
5031 +
5032 /*
5033 * Some devices don't like MODE SENSE with page=0x3f,
5034 * which is the command used for checking if a device
5035 diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
5036 index 94a3eda62add..a400b65cf17b 100644
5037 --- a/drivers/usb/typec/class.c
5038 +++ b/drivers/usb/typec/class.c
5039 @@ -1592,14 +1592,16 @@ struct typec_port *typec_register_port(struct device *parent,
5040
5041 port->sw = typec_switch_get(&port->dev);
5042 if (IS_ERR(port->sw)) {
5043 + ret = PTR_ERR(port->sw);
5044 put_device(&port->dev);
5045 - return ERR_CAST(port->sw);
5046 + return ERR_PTR(ret);
5047 }
5048
5049 port->mux = typec_mux_get(&port->dev, NULL);
5050 if (IS_ERR(port->mux)) {
5051 + ret = PTR_ERR(port->mux);
5052 put_device(&port->dev);
5053 - return ERR_CAST(port->mux);
5054 + return ERR_PTR(ret);
5055 }
5056
5057 ret = device_add(&port->dev);
5058 diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
5059 index b939bc28d886..9c82e2a0a411 100644
5060 --- a/drivers/video/hdmi.c
5061 +++ b/drivers/video/hdmi.c
5062 @@ -1576,12 +1576,12 @@ static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
5063 if (ptr[0] & 0x10)
5064 frame->active_aspect = ptr[1] & 0xf;
5065 if (ptr[0] & 0x8) {
5066 - frame->top_bar = (ptr[5] << 8) + ptr[6];
5067 - frame->bottom_bar = (ptr[7] << 8) + ptr[8];
5068 + frame->top_bar = (ptr[6] << 8) | ptr[5];
5069 + frame->bottom_bar = (ptr[8] << 8) | ptr[7];
5070 }
5071 if (ptr[0] & 0x4) {
5072 - frame->left_bar = (ptr[9] << 8) + ptr[10];
5073 - frame->right_bar = (ptr[11] << 8) + ptr[12];
5074 + frame->left_bar = (ptr[10] << 8) | ptr[9];
5075 + frame->right_bar = (ptr[12] << 8) | ptr[11];
5076 }
5077 frame->scan_mode = ptr[0] & 0x3;
5078
5079 diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
5080 index e05679c478e2..9f4117766bb1 100644
5081 --- a/drivers/virtio/virtio_balloon.c
5082 +++ b/drivers/virtio/virtio_balloon.c
5083 @@ -721,6 +721,17 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
5084
5085 get_page(newpage); /* balloon reference */
5086
5087 + /*
5088 + * When we migrate a page to a different zone and adjusted the
5089 + * managed page count when inflating, we have to fixup the count of
5090 + * both involved zones.
5091 + */
5092 + if (!virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM) &&
5093 + page_zone(page) != page_zone(newpage)) {
5094 + adjust_managed_page_count(page, 1);
5095 + adjust_managed_page_count(newpage, -1);
5096 + }
5097 +
5098 /* balloon's page migration 1st step -- inflate "newpage" */
5099 spin_lock_irqsave(&vb_dev_info->pages_lock, flags);
5100 balloon_page_insert(vb_dev_info, newpage);
5101 diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
5102 index 670700cb1110..0d2da2366869 100644
5103 --- a/fs/btrfs/block-group.c
5104 +++ b/fs/btrfs/block-group.c
5105 @@ -2662,7 +2662,7 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
5106 * is because we need the unpinning stage to actually add the
5107 * space back to the block group, otherwise we will leak space.
5108 */
5109 - if (!alloc && cache->cached == BTRFS_CACHE_NO)
5110 + if (!alloc && !btrfs_block_group_cache_done(cache))
5111 btrfs_cache_block_group(cache, 1);
5112
5113 byte_in_group = bytenr - cache->key.objectid;
5114 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
5115 index 1f7f39b10bd0..57a9ad3e8c29 100644
5116 --- a/fs/btrfs/delayed-inode.c
5117 +++ b/fs/btrfs/delayed-inode.c
5118 @@ -1949,12 +1949,19 @@ void btrfs_kill_all_delayed_nodes(struct btrfs_root *root)
5119 }
5120
5121 inode_id = delayed_nodes[n - 1]->inode_id + 1;
5122 -
5123 - for (i = 0; i < n; i++)
5124 - refcount_inc(&delayed_nodes[i]->refs);
5125 + for (i = 0; i < n; i++) {
5126 + /*
5127 + * Don't increase refs in case the node is dead and
5128 + * about to be removed from the tree in the loop below
5129 + */
5130 + if (!refcount_inc_not_zero(&delayed_nodes[i]->refs))
5131 + delayed_nodes[i] = NULL;
5132 + }
5133 spin_unlock(&root->inode_lock);
5134
5135 for (i = 0; i < n; i++) {
5136 + if (!delayed_nodes[i])
5137 + continue;
5138 __btrfs_kill_delayed_node(delayed_nodes[i]);
5139 btrfs_release_delayed_node(delayed_nodes[i]);
5140 }
5141 diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
5142 index cceaf05aada2..4905f48587df 100644
5143 --- a/fs/btrfs/extent_io.c
5144 +++ b/fs/btrfs/extent_io.c
5145 @@ -4121,7 +4121,7 @@ retry:
5146 for (i = 0; i < nr_pages; i++) {
5147 struct page *page = pvec.pages[i];
5148
5149 - done_index = page->index;
5150 + done_index = page->index + 1;
5151 /*
5152 * At this point we hold neither the i_pages lock nor
5153 * the page lock: the page may be truncated or
5154 @@ -4156,16 +4156,6 @@ retry:
5155
5156 ret = __extent_writepage(page, wbc, epd);
5157 if (ret < 0) {
5158 - /*
5159 - * done_index is set past this page,
5160 - * so media errors will not choke
5161 - * background writeout for the entire
5162 - * file. This has consequences for
5163 - * range_cyclic semantics (ie. it may
5164 - * not be suitable for data integrity
5165 - * writeout).
5166 - */
5167 - done_index = page->index + 1;
5168 done = 1;
5169 break;
5170 }
5171 diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
5172 index 435a502a3226..c332968f9056 100644
5173 --- a/fs/btrfs/file.c
5174 +++ b/fs/btrfs/file.c
5175 @@ -1636,6 +1636,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
5176 break;
5177 }
5178
5179 + only_release_metadata = false;
5180 sector_offset = pos & (fs_info->sectorsize - 1);
5181 reserve_bytes = round_up(write_bytes + sector_offset,
5182 fs_info->sectorsize);
5183 @@ -1791,7 +1792,6 @@ again:
5184 set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
5185 lockend, EXTENT_NORESERVE, NULL,
5186 NULL, GFP_NOFS);
5187 - only_release_metadata = false;
5188 }
5189
5190 btrfs_drop_pages(pages, num_pages);
5191 diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
5192 index d54dcd0ab230..d86ada9c3c54 100644
5193 --- a/fs/btrfs/free-space-cache.c
5194 +++ b/fs/btrfs/free-space-cache.c
5195 @@ -385,6 +385,12 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, struct inode *inode
5196 if (uptodate && !PageUptodate(page)) {
5197 btrfs_readpage(NULL, page);
5198 lock_page(page);
5199 + if (page->mapping != inode->i_mapping) {
5200 + btrfs_err(BTRFS_I(inode)->root->fs_info,
5201 + "free space cache page truncated");
5202 + io_ctl_drop_pages(io_ctl);
5203 + return -EIO;
5204 + }
5205 if (!PageUptodate(page)) {
5206 btrfs_err(BTRFS_I(inode)->root->fs_info,
5207 "error reading free space cache");
5208 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
5209 index 015910079e73..10a01dd0c4e6 100644
5210 --- a/fs/btrfs/inode.c
5211 +++ b/fs/btrfs/inode.c
5212 @@ -2214,12 +2214,16 @@ again:
5213 mapping_set_error(page->mapping, ret);
5214 end_extent_writepage(page, ret, page_start, page_end);
5215 ClearPageChecked(page);
5216 - goto out;
5217 + goto out_reserved;
5218 }
5219
5220 ClearPageChecked(page);
5221 set_page_dirty(page);
5222 +out_reserved:
5223 btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE);
5224 + if (ret)
5225 + btrfs_delalloc_release_space(inode, data_reserved, page_start,
5226 + PAGE_SIZE, true);
5227 out:
5228 unlock_extent_cached(&BTRFS_I(inode)->io_tree, page_start, page_end,
5229 &cached_state);
5230 @@ -9550,6 +9554,9 @@ static int btrfs_rename_exchange(struct inode *old_dir,
5231 goto out_notrans;
5232 }
5233
5234 + if (dest != root)
5235 + btrfs_record_root_in_trans(trans, dest);
5236 +
5237 /*
5238 * We need to find a free sequence number both in the source and
5239 * in the destination directory for the exchange.
5240 diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
5241 index 123ac54af071..518ec1265a0c 100644
5242 --- a/fs/btrfs/send.c
5243 +++ b/fs/btrfs/send.c
5244 @@ -24,6 +24,14 @@
5245 #include "transaction.h"
5246 #include "compression.h"
5247
5248 +/*
5249 + * Maximum number of references an extent can have in order for us to attempt to
5250 + * issue clone operations instead of write operations. This currently exists to
5251 + * avoid hitting limitations of the backreference walking code (taking a lot of
5252 + * time and using too much memory for extents with large number of references).
5253 + */
5254 +#define SEND_MAX_EXTENT_REFS 64
5255 +
5256 /*
5257 * A fs_path is a helper to dynamically build path names with unknown size.
5258 * It reallocates the internal buffer on demand.
5259 @@ -1302,6 +1310,7 @@ static int find_extent_clone(struct send_ctx *sctx,
5260 struct clone_root *cur_clone_root;
5261 struct btrfs_key found_key;
5262 struct btrfs_path *tmp_path;
5263 + struct btrfs_extent_item *ei;
5264 int compressed;
5265 u32 i;
5266
5267 @@ -1349,7 +1358,6 @@ static int find_extent_clone(struct send_ctx *sctx,
5268 ret = extent_from_logical(fs_info, disk_byte, tmp_path,
5269 &found_key, &flags);
5270 up_read(&fs_info->commit_root_sem);
5271 - btrfs_release_path(tmp_path);
5272
5273 if (ret < 0)
5274 goto out;
5275 @@ -1358,6 +1366,21 @@ static int find_extent_clone(struct send_ctx *sctx,
5276 goto out;
5277 }
5278
5279 + ei = btrfs_item_ptr(tmp_path->nodes[0], tmp_path->slots[0],
5280 + struct btrfs_extent_item);
5281 + /*
5282 + * Backreference walking (iterate_extent_inodes() below) is currently
5283 + * too expensive when an extent has a large number of references, both
5284 + * in time spent and used memory. So for now just fallback to write
5285 + * operations instead of clone operations when an extent has more than
5286 + * a certain amount of references.
5287 + */
5288 + if (btrfs_extent_refs(tmp_path->nodes[0], ei) > SEND_MAX_EXTENT_REFS) {
5289 + ret = -ENOENT;
5290 + goto out;
5291 + }
5292 + btrfs_release_path(tmp_path);
5293 +
5294 /*
5295 * Setup the clone roots.
5296 */
5297 diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
5298 index a7da1f3e3627..5acf5c507ec2 100644
5299 --- a/fs/btrfs/volumes.h
5300 +++ b/fs/btrfs/volumes.h
5301 @@ -330,7 +330,6 @@ struct btrfs_bio {
5302 u64 map_type; /* get from map_lookup->type */
5303 bio_end_io_t *end_io;
5304 struct bio *orig_bio;
5305 - unsigned long flags;
5306 void *private;
5307 atomic_t error;
5308 int max_errors;
5309 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
5310 index d17a789fd856..2e4764fd1872 100644
5311 --- a/fs/ceph/dir.c
5312 +++ b/fs/ceph/dir.c
5313 @@ -1809,6 +1809,7 @@ const struct file_operations ceph_dir_fops = {
5314 .open = ceph_open,
5315 .release = ceph_release,
5316 .unlocked_ioctl = ceph_ioctl,
5317 + .compat_ioctl = compat_ptr_ioctl,
5318 .fsync = ceph_fsync,
5319 .lock = ceph_lock,
5320 .flock = ceph_flock,
5321 diff --git a/fs/ceph/file.c b/fs/ceph/file.c
5322 index 8de633964dc3..11929d2bb594 100644
5323 --- a/fs/ceph/file.c
5324 +++ b/fs/ceph/file.c
5325 @@ -2188,7 +2188,7 @@ const struct file_operations ceph_file_fops = {
5326 .splice_read = generic_file_splice_read,
5327 .splice_write = iter_file_splice_write,
5328 .unlocked_ioctl = ceph_ioctl,
5329 - .compat_ioctl = ceph_ioctl,
5330 + .compat_ioctl = compat_ptr_ioctl,
5331 .fallocate = ceph_fallocate,
5332 .copy_file_range = ceph_copy_file_range,
5333 };
5334 diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
5335 index a13a78725c57..b766c3ee5fa8 100644
5336 --- a/fs/erofs/xattr.c
5337 +++ b/fs/erofs/xattr.c
5338 @@ -649,6 +649,8 @@ ssize_t erofs_listxattr(struct dentry *dentry,
5339 struct listxattr_iter it;
5340
5341 ret = init_inode_xattrs(d_inode(dentry));
5342 + if (ret == -ENOATTR)
5343 + return 0;
5344 if (ret)
5345 return ret;
5346
5347 diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
5348 index 7004ce581a32..a16c53655e77 100644
5349 --- a/fs/ext2/inode.c
5350 +++ b/fs/ext2/inode.c
5351 @@ -701,10 +701,13 @@ static int ext2_get_blocks(struct inode *inode,
5352 if (!partial) {
5353 count++;
5354 mutex_unlock(&ei->truncate_mutex);
5355 - if (err)
5356 - goto cleanup;
5357 goto got_it;
5358 }
5359 +
5360 + if (err) {
5361 + mutex_unlock(&ei->truncate_mutex);
5362 + goto cleanup;
5363 + }
5364 }
5365
5366 /*
5367 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
5368 index 764ff4c56233..564e2ceb8417 100644
5369 --- a/fs/ext4/ialloc.c
5370 +++ b/fs/ext4/ialloc.c
5371 @@ -265,13 +265,8 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
5372 ext4_debug("freeing inode %lu\n", ino);
5373 trace_ext4_free_inode(inode);
5374
5375 - /*
5376 - * Note: we must free any quota before locking the superblock,
5377 - * as writing the quota to disk may need the lock as well.
5378 - */
5379 dquot_initialize(inode);
5380 dquot_free_inode(inode);
5381 - dquot_drop(inode);
5382
5383 is_directory = S_ISDIR(inode->i_mode);
5384
5385 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
5386 index d691d1783ed6..91da21890360 100644
5387 --- a/fs/ext4/inode.c
5388 +++ b/fs/ext4/inode.c
5389 @@ -196,7 +196,12 @@ void ext4_evict_inode(struct inode *inode)
5390 {
5391 handle_t *handle;
5392 int err;
5393 - int extra_credits = 3;
5394 + /*
5395 + * Credits for final inode cleanup and freeing:
5396 + * sb + inode (ext4_orphan_del()), block bitmap, group descriptor
5397 + * (xattr block freeing), bitmap, group descriptor (inode freeing)
5398 + */
5399 + int extra_credits = 6;
5400 struct ext4_xattr_inode_array *ea_inode_array = NULL;
5401
5402 trace_ext4_evict_inode(inode);
5403 @@ -252,8 +257,12 @@ void ext4_evict_inode(struct inode *inode)
5404 if (!IS_NOQUOTA(inode))
5405 extra_credits += EXT4_MAXQUOTAS_DEL_BLOCKS(inode->i_sb);
5406
5407 + /*
5408 + * Block bitmap, group descriptor, and inode are accounted in both
5409 + * ext4_blocks_for_truncate() and extra_credits. So subtract 3.
5410 + */
5411 handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE,
5412 - ext4_blocks_for_truncate(inode)+extra_credits);
5413 + ext4_blocks_for_truncate(inode) + extra_credits - 3);
5414 if (IS_ERR(handle)) {
5415 ext4_std_error(inode->i_sb, PTR_ERR(handle));
5416 /*
5417 @@ -5450,11 +5459,15 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
5418
5419 offset = inode->i_size & (PAGE_SIZE - 1);
5420 /*
5421 - * All buffers in the last page remain valid? Then there's nothing to
5422 - * do. We do the check mainly to optimize the common PAGE_SIZE ==
5423 - * blocksize case
5424 + * If the page is fully truncated, we don't need to wait for any commit
5425 + * (and we even should not as __ext4_journalled_invalidatepage() may
5426 + * strip all buffers from the page but keep the page dirty which can then
5427 + * confuse e.g. concurrent ext4_writepage() seeing dirty page without
5428 + * buffers). Also we don't need to wait for any commit if all buffers in
5429 + * the page remain valid. This is most beneficial for the common case of
5430 + * blocksize == PAGESIZE.
5431 */
5432 - if (offset > PAGE_SIZE - i_blocksize(inode))
5433 + if (!offset || offset > (PAGE_SIZE - i_blocksize(inode)))
5434 return;
5435 while (1) {
5436 page = find_lock_page(inode->i_mapping,
5437 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
5438 index a427d2031a8d..923476e3aefb 100644
5439 --- a/fs/ext4/namei.c
5440 +++ b/fs/ext4/namei.c
5441 @@ -3182,18 +3182,17 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
5442 if (IS_DIRSYNC(dir))
5443 ext4_handle_sync(handle);
5444
5445 - if (inode->i_nlink == 0) {
5446 - ext4_warning_inode(inode, "Deleting file '%.*s' with no links",
5447 - dentry->d_name.len, dentry->d_name.name);
5448 - set_nlink(inode, 1);
5449 - }
5450 retval = ext4_delete_entry(handle, dir, de, bh);
5451 if (retval)
5452 goto end_unlink;
5453 dir->i_ctime = dir->i_mtime = current_time(dir);
5454 ext4_update_dx_flag(dir);
5455 ext4_mark_inode_dirty(handle, dir);
5456 - drop_nlink(inode);
5457 + if (inode->i_nlink == 0)
5458 + ext4_warning_inode(inode, "Deleting file '%.*s' with no links",
5459 + dentry->d_name.len, dentry->d_name.name);
5460 + else
5461 + drop_nlink(inode);
5462 if (!inode->i_nlink)
5463 ext4_orphan_add(handle, inode);
5464 inode->i_ctime = current_time(inode);
5465 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
5466 index 73578359d451..98d37b8d0050 100644
5467 --- a/fs/ext4/super.c
5468 +++ b/fs/ext4/super.c
5469 @@ -1172,9 +1172,9 @@ void ext4_clear_inode(struct inode *inode)
5470 {
5471 invalidate_inode_buffers(inode);
5472 clear_inode(inode);
5473 - dquot_drop(inode);
5474 ext4_discard_preallocations(inode);
5475 ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS);
5476 + dquot_drop(inode);
5477 if (EXT4_I(inode)->jinode) {
5478 jbd2_journal_release_jbd_inode(EXT4_JOURNAL(inode),
5479 EXT4_I(inode)->jinode);
5480 diff --git a/fs/ioctl.c b/fs/ioctl.c
5481 index fef3a6bf7c78..3118da0de158 100644
5482 --- a/fs/ioctl.c
5483 +++ b/fs/ioctl.c
5484 @@ -8,6 +8,7 @@
5485 #include <linux/syscalls.h>
5486 #include <linux/mm.h>
5487 #include <linux/capability.h>
5488 +#include <linux/compat.h>
5489 #include <linux/file.h>
5490 #include <linux/fs.h>
5491 #include <linux/security.h>
5492 @@ -719,3 +720,37 @@ SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
5493 {
5494 return ksys_ioctl(fd, cmd, arg);
5495 }
5496 +
5497 +#ifdef CONFIG_COMPAT
5498 +/**
5499 + * compat_ptr_ioctl - generic implementation of .compat_ioctl file operation
5500 + *
5501 + * This is not normally called as a function, but instead set in struct
5502 + * file_operations as
5503 + *
5504 + * .compat_ioctl = compat_ptr_ioctl,
5505 + *
5506 + * On most architectures, the compat_ptr_ioctl() just passes all arguments
5507 + * to the corresponding ->ioctl handler. The exception is arch/s390, where
5508 + * compat_ptr() clears the top bit of a 32-bit pointer value, so user space
5509 + * pointers to the second 2GB alias the first 2GB, as is the case for
5510 + * native 32-bit s390 user space.
5511 + *
5512 + * The compat_ptr_ioctl() function must therefore be used only with ioctl
5513 + * functions that either ignore the argument or pass a pointer to a
5514 + * compatible data type.
5515 + *
5516 + * If any ioctl command handled by fops->unlocked_ioctl passes a plain
5517 + * integer instead of a pointer, or any of the passed data types
5518 + * is incompatible between 32-bit and 64-bit architectures, a proper
5519 + * handler is required instead of compat_ptr_ioctl.
5520 + */
5521 +long compat_ptr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
5522 +{
5523 + if (!file->f_op->unlocked_ioctl)
5524 + return -ENOIOCTLCMD;
5525 +
5526 + return file->f_op->unlocked_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
5527 +}
5528 +EXPORT_SYMBOL(compat_ptr_ioctl);
5529 +#endif
5530 diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
5531 index 7a922190a8c7..eda83487c9ec 100644
5532 --- a/fs/ocfs2/quota_global.c
5533 +++ b/fs/ocfs2/quota_global.c
5534 @@ -728,7 +728,7 @@ static int ocfs2_release_dquot(struct dquot *dquot)
5535
5536 mutex_lock(&dquot->dq_lock);
5537 /* Check whether we are not racing with some other dqget() */
5538 - if (atomic_read(&dquot->dq_count) > 1)
5539 + if (dquot_is_busy(dquot))
5540 goto out;
5541 /* Running from downconvert thread? Postpone quota processing to wq */
5542 if (current == osb->dc_task) {
5543 diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
5544 index 702aa63f6774..29abdb1d3b5c 100644
5545 --- a/fs/overlayfs/dir.c
5546 +++ b/fs/overlayfs/dir.c
5547 @@ -1170,7 +1170,7 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
5548 if (newdentry == trap)
5549 goto out_dput;
5550
5551 - if (WARN_ON(olddentry->d_inode == newdentry->d_inode))
5552 + if (olddentry->d_inode == newdentry->d_inode)
5553 goto out_dput;
5554
5555 err = 0;
5556 diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
5557 index bc14781886bf..b045cf1826fc 100644
5558 --- a/fs/overlayfs/inode.c
5559 +++ b/fs/overlayfs/inode.c
5560 @@ -200,8 +200,14 @@ int ovl_getattr(const struct path *path, struct kstat *stat,
5561 if (ovl_test_flag(OVL_INDEX, d_inode(dentry)) ||
5562 (!ovl_verify_lower(dentry->d_sb) &&
5563 (is_dir || lowerstat.nlink == 1))) {
5564 - stat->ino = lowerstat.ino;
5565 lower_layer = ovl_layer_lower(dentry);
5566 + /*
5567 + * Cannot use origin st_dev;st_ino because
5568 + * origin inode content may differ from overlay
5569 + * inode content.
5570 + */
5571 + if (samefs || lower_layer->fsid)
5572 + stat->ino = lowerstat.ino;
5573 }
5574
5575 /*
5576 diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
5577 index e9717c2f7d45..f47c591402d7 100644
5578 --- a/fs/overlayfs/namei.c
5579 +++ b/fs/overlayfs/namei.c
5580 @@ -325,6 +325,14 @@ int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected,
5581 int i;
5582
5583 for (i = 0; i < ofs->numlower; i++) {
5584 + /*
5585 + * If lower fs uuid is not unique among lower fs we cannot match
5586 + * fh->uuid to layer.
5587 + */
5588 + if (ofs->lower_layers[i].fsid &&
5589 + ofs->lower_layers[i].fs->bad_uuid)
5590 + continue;
5591 +
5592 origin = ovl_decode_real_fh(fh, ofs->lower_layers[i].mnt,
5593 connected);
5594 if (origin)
5595 diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
5596 index a8279280e88d..28348c44ea5b 100644
5597 --- a/fs/overlayfs/ovl_entry.h
5598 +++ b/fs/overlayfs/ovl_entry.h
5599 @@ -22,6 +22,8 @@ struct ovl_config {
5600 struct ovl_sb {
5601 struct super_block *sb;
5602 dev_t pseudo_dev;
5603 + /* Unusable (conflicting) uuid */
5604 + bool bad_uuid;
5605 };
5606
5607 struct ovl_layer {
5608 diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
5609 index afbcb116a7f1..7621ff176d15 100644
5610 --- a/fs/overlayfs/super.c
5611 +++ b/fs/overlayfs/super.c
5612 @@ -1255,7 +1255,7 @@ static bool ovl_lower_uuid_ok(struct ovl_fs *ofs, const uuid_t *uuid)
5613 {
5614 unsigned int i;
5615
5616 - if (!ofs->config.nfs_export && !(ofs->config.index && ofs->upper_mnt))
5617 + if (!ofs->config.nfs_export && !ofs->upper_mnt)
5618 return true;
5619
5620 for (i = 0; i < ofs->numlowerfs; i++) {
5621 @@ -1263,9 +1263,13 @@ static bool ovl_lower_uuid_ok(struct ovl_fs *ofs, const uuid_t *uuid)
5622 * We use uuid to associate an overlay lower file handle with a
5623 * lower layer, so we can accept lower fs with null uuid as long
5624 * as all lower layers with null uuid are on the same fs.
5625 + * if we detect multiple lower fs with the same uuid, we
5626 + * disable lower file handle decoding on all of them.
5627 */
5628 - if (uuid_equal(&ofs->lower_fs[i].sb->s_uuid, uuid))
5629 + if (uuid_equal(&ofs->lower_fs[i].sb->s_uuid, uuid)) {
5630 + ofs->lower_fs[i].bad_uuid = true;
5631 return false;
5632 + }
5633 }
5634 return true;
5635 }
5636 @@ -1277,6 +1281,7 @@ static int ovl_get_fsid(struct ovl_fs *ofs, const struct path *path)
5637 unsigned int i;
5638 dev_t dev;
5639 int err;
5640 + bool bad_uuid = false;
5641
5642 /* fsid 0 is reserved for upper fs even with non upper overlay */
5643 if (ofs->upper_mnt && ofs->upper_mnt->mnt_sb == sb)
5644 @@ -1288,11 +1293,15 @@ static int ovl_get_fsid(struct ovl_fs *ofs, const struct path *path)
5645 }
5646
5647 if (!ovl_lower_uuid_ok(ofs, &sb->s_uuid)) {
5648 - ofs->config.index = false;
5649 - ofs->config.nfs_export = false;
5650 - pr_warn("overlayfs: %s uuid detected in lower fs '%pd2', falling back to index=off,nfs_export=off.\n",
5651 - uuid_is_null(&sb->s_uuid) ? "null" : "conflicting",
5652 - path->dentry);
5653 + bad_uuid = true;
5654 + if (ofs->config.index || ofs->config.nfs_export) {
5655 + ofs->config.index = false;
5656 + ofs->config.nfs_export = false;
5657 + pr_warn("overlayfs: %s uuid detected in lower fs '%pd2', falling back to index=off,nfs_export=off.\n",
5658 + uuid_is_null(&sb->s_uuid) ? "null" :
5659 + "conflicting",
5660 + path->dentry);
5661 + }
5662 }
5663
5664 err = get_anon_bdev(&dev);
5665 @@ -1303,6 +1312,7 @@ static int ovl_get_fsid(struct ovl_fs *ofs, const struct path *path)
5666
5667 ofs->lower_fs[ofs->numlowerfs].sb = sb;
5668 ofs->lower_fs[ofs->numlowerfs].pseudo_dev = dev;
5669 + ofs->lower_fs[ofs->numlowerfs].bad_uuid = bad_uuid;
5670 ofs->numlowerfs++;
5671
5672 return ofs->numlowerfs;
5673 diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
5674 index 6e826b454082..7f0b39da5022 100644
5675 --- a/fs/quota/dquot.c
5676 +++ b/fs/quota/dquot.c
5677 @@ -497,7 +497,7 @@ int dquot_release(struct dquot *dquot)
5678
5679 mutex_lock(&dquot->dq_lock);
5680 /* Check whether we are not racing with some other dqget() */
5681 - if (atomic_read(&dquot->dq_count) > 1)
5682 + if (dquot_is_busy(dquot))
5683 goto out_dqlock;
5684 if (dqopt->ops[dquot->dq_id.type]->release_dqblk) {
5685 ret = dqopt->ops[dquot->dq_id.type]->release_dqblk(dquot);
5686 @@ -623,7 +623,7 @@ EXPORT_SYMBOL(dquot_scan_active);
5687 /* Write all dquot structures to quota files */
5688 int dquot_writeback_dquots(struct super_block *sb, int type)
5689 {
5690 - struct list_head *dirty;
5691 + struct list_head dirty;
5692 struct dquot *dquot;
5693 struct quota_info *dqopt = sb_dqopt(sb);
5694 int cnt;
5695 @@ -637,9 +637,10 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
5696 if (!sb_has_quota_active(sb, cnt))
5697 continue;
5698 spin_lock(&dq_list_lock);
5699 - dirty = &dqopt->info[cnt].dqi_dirty_list;
5700 - while (!list_empty(dirty)) {
5701 - dquot = list_first_entry(dirty, struct dquot,
5702 + /* Move list away to avoid livelock. */
5703 + list_replace_init(&dqopt->info[cnt].dqi_dirty_list, &dirty);
5704 + while (!list_empty(&dirty)) {
5705 + dquot = list_first_entry(&dirty, struct dquot,
5706 dq_dirty);
5707
5708 WARN_ON(!test_bit(DQ_ACTIVE_B, &dquot->dq_flags));
5709 diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
5710 index 132ec4406ed0..6419e6dacc39 100644
5711 --- a/fs/reiserfs/inode.c
5712 +++ b/fs/reiserfs/inode.c
5713 @@ -2097,6 +2097,15 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
5714 goto out_inserted_sd;
5715 }
5716
5717 + /*
5718 + * Mark it private if we're creating the privroot
5719 + * or something under it.
5720 + */
5721 + if (IS_PRIVATE(dir) || dentry == REISERFS_SB(sb)->priv_root) {
5722 + inode->i_flags |= S_PRIVATE;
5723 + inode->i_opflags &= ~IOP_XATTR;
5724 + }
5725 +
5726 if (reiserfs_posixacl(inode->i_sb)) {
5727 reiserfs_write_unlock(inode->i_sb);
5728 retval = reiserfs_inherit_default_acl(th, dir, dentry, inode);
5729 @@ -2111,8 +2120,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
5730 reiserfs_warning(inode->i_sb, "jdm-13090",
5731 "ACLs aren't enabled in the fs, "
5732 "but vfs thinks they are!");
5733 - } else if (IS_PRIVATE(dir))
5734 - inode->i_flags |= S_PRIVATE;
5735 + }
5736
5737 if (security->name) {
5738 reiserfs_write_unlock(inode->i_sb);
5739 diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
5740 index 97f3fc4fdd79..959a066b7bb0 100644
5741 --- a/fs/reiserfs/namei.c
5742 +++ b/fs/reiserfs/namei.c
5743 @@ -377,10 +377,13 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
5744
5745 /*
5746 * Propagate the private flag so we know we're
5747 - * in the priv tree
5748 + * in the priv tree. Also clear IOP_XATTR
5749 + * since we don't have xattrs on xattr files.
5750 */
5751 - if (IS_PRIVATE(dir))
5752 + if (IS_PRIVATE(dir)) {
5753 inode->i_flags |= S_PRIVATE;
5754 + inode->i_opflags &= ~IOP_XATTR;
5755 + }
5756 }
5757 reiserfs_write_unlock(dir->i_sb);
5758 if (retval == IO_ERROR) {
5759 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
5760 index e5ca9ed79e54..726580114d55 100644
5761 --- a/fs/reiserfs/reiserfs.h
5762 +++ b/fs/reiserfs/reiserfs.h
5763 @@ -1168,6 +1168,8 @@ static inline int bmap_would_wrap(unsigned bmap_nr)
5764 return bmap_nr > ((1LL << 16) - 1);
5765 }
5766
5767 +extern const struct xattr_handler *reiserfs_xattr_handlers[];
5768 +
5769 /*
5770 * this says about version of key of all items (but stat data) the
5771 * object consists of
5772 diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
5773 index d69b4ac0ae2f..3244037b1286 100644
5774 --- a/fs/reiserfs/super.c
5775 +++ b/fs/reiserfs/super.c
5776 @@ -2049,6 +2049,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
5777 if (replay_only(s))
5778 goto error_unlocked;
5779
5780 + s->s_xattr = reiserfs_xattr_handlers;
5781 +
5782 if (bdev_read_only(s->s_bdev) && !sb_rdonly(s)) {
5783 SWARN(silent, s, "clm-7000",
5784 "Detected readonly device, marking FS readonly");
5785 diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
5786 index b5b26d8a192c..62b40df36c98 100644
5787 --- a/fs/reiserfs/xattr.c
5788 +++ b/fs/reiserfs/xattr.c
5789 @@ -122,13 +122,13 @@ static struct dentry *open_xa_root(struct super_block *sb, int flags)
5790 struct dentry *xaroot;
5791
5792 if (d_really_is_negative(privroot))
5793 - return ERR_PTR(-ENODATA);
5794 + return ERR_PTR(-EOPNOTSUPP);
5795
5796 inode_lock_nested(d_inode(privroot), I_MUTEX_XATTR);
5797
5798 xaroot = dget(REISERFS_SB(sb)->xattr_root);
5799 if (!xaroot)
5800 - xaroot = ERR_PTR(-ENODATA);
5801 + xaroot = ERR_PTR(-EOPNOTSUPP);
5802 else if (d_really_is_negative(xaroot)) {
5803 int err = -ENODATA;
5804
5805 @@ -619,6 +619,10 @@ int reiserfs_xattr_set(struct inode *inode, const char *name,
5806 int error, error2;
5807 size_t jbegin_count = reiserfs_xattr_nblocks(inode, buffer_size);
5808
5809 + /* Check before we start a transaction and then do nothing. */
5810 + if (!d_really_is_positive(REISERFS_SB(inode->i_sb)->priv_root))
5811 + return -EOPNOTSUPP;
5812 +
5813 if (!(flags & XATTR_REPLACE))
5814 jbegin_count += reiserfs_xattr_jcreate_nblocks(inode);
5815
5816 @@ -841,8 +845,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
5817 if (d_really_is_negative(dentry))
5818 return -EINVAL;
5819
5820 - if (!dentry->d_sb->s_xattr ||
5821 - get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
5822 + if (get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
5823 return -EOPNOTSUPP;
5824
5825 dir = open_xa_dir(d_inode(dentry), XATTR_REPLACE);
5826 @@ -882,6 +885,7 @@ static int create_privroot(struct dentry *dentry)
5827 }
5828
5829 d_inode(dentry)->i_flags |= S_PRIVATE;
5830 + d_inode(dentry)->i_opflags &= ~IOP_XATTR;
5831 reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr "
5832 "storage.\n", PRIVROOT_NAME);
5833
5834 @@ -895,7 +899,7 @@ static int create_privroot(struct dentry *dentry) { return 0; }
5835 #endif
5836
5837 /* Actual operations that are exported to VFS-land */
5838 -static const struct xattr_handler *reiserfs_xattr_handlers[] = {
5839 +const struct xattr_handler *reiserfs_xattr_handlers[] = {
5840 #ifdef CONFIG_REISERFS_FS_XATTR
5841 &reiserfs_xattr_user_handler,
5842 &reiserfs_xattr_trusted_handler,
5843 @@ -966,8 +970,10 @@ int reiserfs_lookup_privroot(struct super_block *s)
5844 if (!IS_ERR(dentry)) {
5845 REISERFS_SB(s)->priv_root = dentry;
5846 d_set_d_op(dentry, &xattr_lookup_poison_ops);
5847 - if (d_really_is_positive(dentry))
5848 + if (d_really_is_positive(dentry)) {
5849 d_inode(dentry)->i_flags |= S_PRIVATE;
5850 + d_inode(dentry)->i_opflags &= ~IOP_XATTR;
5851 + }
5852 } else
5853 err = PTR_ERR(dentry);
5854 inode_unlock(d_inode(s->s_root));
5855 @@ -996,7 +1002,6 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags)
5856 }
5857
5858 if (d_really_is_positive(privroot)) {
5859 - s->s_xattr = reiserfs_xattr_handlers;
5860 inode_lock(d_inode(privroot));
5861 if (!REISERFS_SB(s)->xattr_root) {
5862 struct dentry *dentry;
5863 diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
5864 index aa9380bac196..05f666794561 100644
5865 --- a/fs/reiserfs/xattr_acl.c
5866 +++ b/fs/reiserfs/xattr_acl.c
5867 @@ -320,10 +320,8 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
5868 * would be useless since permissions are ignored, and a pain because
5869 * it introduces locking cycles
5870 */
5871 - if (IS_PRIVATE(dir)) {
5872 - inode->i_flags |= S_PRIVATE;
5873 + if (IS_PRIVATE(inode))
5874 goto apply_umask;
5875 - }
5876
5877 err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
5878 if (err)
5879 diff --git a/fs/splice.c b/fs/splice.c
5880 index 98412721f056..e509239d7e06 100644
5881 --- a/fs/splice.c
5882 +++ b/fs/splice.c
5883 @@ -945,12 +945,13 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
5884 WARN_ON_ONCE(pipe->nrbufs != 0);
5885
5886 while (len) {
5887 + unsigned int pipe_pages;
5888 size_t read_len;
5889 loff_t pos = sd->pos, prev_pos = pos;
5890
5891 /* Don't try to read more the pipe has space for. */
5892 - read_len = min_t(size_t, len,
5893 - (pipe->buffers - pipe->nrbufs) << PAGE_SHIFT);
5894 + pipe_pages = pipe->buffers - pipe->nrbufs;
5895 + read_len = min(len, (size_t)pipe_pages << PAGE_SHIFT);
5896 ret = do_splice_to(in, &pos, pipe, read_len, flags);
5897 if (unlikely(ret <= 0))
5898 goto out_release;
5899 @@ -1180,8 +1181,15 @@ static long do_splice(struct file *in, loff_t __user *off_in,
5900
5901 pipe_lock(opipe);
5902 ret = wait_for_space(opipe, flags);
5903 - if (!ret)
5904 + if (!ret) {
5905 + unsigned int pipe_pages;
5906 +
5907 + /* Don't try to read more the pipe has space for. */
5908 + pipe_pages = opipe->buffers - opipe->nrbufs;
5909 + len = min(len, (size_t)pipe_pages << PAGE_SHIFT);
5910 +
5911 ret = do_splice_to(in, &offset, opipe, len, flags);
5912 + }
5913 pipe_unlock(opipe);
5914 if (ret > 0)
5915 wakeup_pipe_readers(opipe);
5916 diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
5917 index 175f7b40c585..3f6fddeb7519 100644
5918 --- a/include/acpi/acpi_bus.h
5919 +++ b/include/acpi/acpi_bus.h
5920 @@ -78,9 +78,6 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
5921 bool acpi_dev_found(const char *hid);
5922 bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
5923
5924 -struct acpi_device *
5925 -acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
5926 -
5927 #ifdef CONFIG_ACPI
5928
5929 #include <linux/proc_fs.h>
5930 @@ -683,6 +680,9 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
5931 adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set);
5932 }
5933
5934 +struct acpi_device *
5935 +acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
5936 +
5937 static inline void acpi_dev_put(struct acpi_device *adev)
5938 {
5939 put_device(&adev->dev);
5940 diff --git a/include/linux/fs.h b/include/linux/fs.h
5941 index e0d909d35763..0b4d8fc79e0f 100644
5942 --- a/include/linux/fs.h
5943 +++ b/include/linux/fs.h
5944 @@ -1727,6 +1727,13 @@ int vfs_mkobj(struct dentry *, umode_t,
5945
5946 extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
5947
5948 +#ifdef CONFIG_COMPAT
5949 +extern long compat_ptr_ioctl(struct file *file, unsigned int cmd,
5950 + unsigned long arg);
5951 +#else
5952 +#define compat_ptr_ioctl NULL
5953 +#endif
5954 +
5955 /*
5956 * VFS file helper functions.
5957 */
5958 diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
5959 index 7cfd2b0504df..a59bf323f713 100644
5960 --- a/include/linux/mfd/rk808.h
5961 +++ b/include/linux/mfd/rk808.h
5962 @@ -610,7 +610,7 @@ enum {
5963 RK808_ID = 0x0000,
5964 RK809_ID = 0x8090,
5965 RK817_ID = 0x8170,
5966 - RK818_ID = 0x8181,
5967 + RK818_ID = 0x8180,
5968 };
5969
5970 struct rk808 {
5971 diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
5972 index 185d94829701..91e0b7624053 100644
5973 --- a/include/linux/quotaops.h
5974 +++ b/include/linux/quotaops.h
5975 @@ -54,6 +54,16 @@ static inline struct dquot *dqgrab(struct dquot *dquot)
5976 atomic_inc(&dquot->dq_count);
5977 return dquot;
5978 }
5979 +
5980 +static inline bool dquot_is_busy(struct dquot *dquot)
5981 +{
5982 + if (test_bit(DQ_MOD_B, &dquot->dq_flags))
5983 + return true;
5984 + if (atomic_read(&dquot->dq_count) > 1)
5985 + return true;
5986 + return false;
5987 +}
5988 +
5989 void dqput(struct dquot *dquot);
5990 int dquot_scan_active(struct super_block *sb,
5991 int (*fn)(struct dquot *dquot, unsigned long priv),
5992 diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
5993 index e7e733add99f..44c52639db55 100644
5994 --- a/include/rdma/ib_verbs.h
5995 +++ b/include/rdma/ib_verbs.h
5996 @@ -4043,9 +4043,7 @@ static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev,
5997 */
5998 static inline unsigned int ib_dma_max_seg_size(struct ib_device *dev)
5999 {
6000 - struct device_dma_parameters *p = dev->dma_device->dma_parms;
6001 -
6002 - return p ? p->max_segment_size : UINT_MAX;
6003 + return dma_get_max_seg_size(dev->dma_device);
6004 }
6005
6006 /**
6007 diff --git a/include/uapi/linux/cec.h b/include/uapi/linux/cec.h
6008 index 5704fa0292b5..423859e489c7 100644
6009 --- a/include/uapi/linux/cec.h
6010 +++ b/include/uapi/linux/cec.h
6011 @@ -768,8 +768,8 @@ struct cec_event {
6012 #define CEC_MSG_SELECT_DIGITAL_SERVICE 0x93
6013 #define CEC_MSG_TUNER_DEVICE_STATUS 0x07
6014 /* Recording Flag Operand (rec_flag) */
6015 -#define CEC_OP_REC_FLAG_USED 0
6016 -#define CEC_OP_REC_FLAG_NOT_USED 1
6017 +#define CEC_OP_REC_FLAG_NOT_USED 0
6018 +#define CEC_OP_REC_FLAG_USED 1
6019 /* Tuner Display Info Operand (tuner_display_info) */
6020 #define CEC_OP_TUNER_DISPLAY_INFO_DIGITAL 0
6021 #define CEC_OP_TUNER_DISPLAY_INFO_NONE 1
6022 diff --git a/kernel/cgroup/pids.c b/kernel/cgroup/pids.c
6023 index 8e513a573fe9..138059eb730d 100644
6024 --- a/kernel/cgroup/pids.c
6025 +++ b/kernel/cgroup/pids.c
6026 @@ -45,7 +45,7 @@ struct pids_cgroup {
6027 * %PIDS_MAX = (%PID_MAX_LIMIT + 1).
6028 */
6029 atomic64_t counter;
6030 - int64_t limit;
6031 + atomic64_t limit;
6032
6033 /* Handle for "pids.events" */
6034 struct cgroup_file events_file;
6035 @@ -73,8 +73,8 @@ pids_css_alloc(struct cgroup_subsys_state *parent)
6036 if (!pids)
6037 return ERR_PTR(-ENOMEM);
6038
6039 - pids->limit = PIDS_MAX;
6040 atomic64_set(&pids->counter, 0);
6041 + atomic64_set(&pids->limit, PIDS_MAX);
6042 atomic64_set(&pids->events_limit, 0);
6043 return &pids->css;
6044 }
6045 @@ -146,13 +146,14 @@ static int pids_try_charge(struct pids_cgroup *pids, int num)
6046
6047 for (p = pids; parent_pids(p); p = parent_pids(p)) {
6048 int64_t new = atomic64_add_return(num, &p->counter);
6049 + int64_t limit = atomic64_read(&p->limit);
6050
6051 /*
6052 * Since new is capped to the maximum number of pid_t, if
6053 * p->limit is %PIDS_MAX then we know that this test will never
6054 * fail.
6055 */
6056 - if (new > p->limit)
6057 + if (new > limit)
6058 goto revert;
6059 }
6060
6061 @@ -277,7 +278,7 @@ set_limit:
6062 * Limit updates don't need to be mutex'd, since it isn't
6063 * critical that any racing fork()s follow the new limit.
6064 */
6065 - pids->limit = limit;
6066 + atomic64_set(&pids->limit, limit);
6067 return nbytes;
6068 }
6069
6070 @@ -285,7 +286,7 @@ static int pids_max_show(struct seq_file *sf, void *v)
6071 {
6072 struct cgroup_subsys_state *css = seq_css(sf);
6073 struct pids_cgroup *pids = css_pids(css);
6074 - int64_t limit = pids->limit;
6075 + int64_t limit = atomic64_read(&pids->limit);
6076
6077 if (limit >= PIDS_MAX)
6078 seq_printf(sf, "%s\n", PIDS_MAX_STR);
6079 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
6080 index bc2e09a8ea61..649687622654 100644
6081 --- a/kernel/workqueue.c
6082 +++ b/kernel/workqueue.c
6083 @@ -2532,8 +2532,14 @@ repeat:
6084 */
6085 if (need_to_create_worker(pool)) {
6086 spin_lock(&wq_mayday_lock);
6087 - get_pwq(pwq);
6088 - list_move_tail(&pwq->mayday_node, &wq->maydays);
6089 + /*
6090 + * Queue iff we aren't racing destruction
6091 + * and somebody else hasn't queued it already.
6092 + */
6093 + if (wq->rescuer && list_empty(&pwq->mayday_node)) {
6094 + get_pwq(pwq);
6095 + list_add_tail(&pwq->mayday_node, &wq->maydays);
6096 + }
6097 spin_unlock(&wq_mayday_lock);
6098 }
6099 }
6100 @@ -4325,9 +4331,29 @@ void destroy_workqueue(struct workqueue_struct *wq)
6101 struct pool_workqueue *pwq;
6102 int node;
6103
6104 + /*
6105 + * Remove it from sysfs first so that sanity check failure doesn't
6106 + * lead to sysfs name conflicts.
6107 + */
6108 + workqueue_sysfs_unregister(wq);
6109 +
6110 /* drain it before proceeding with destruction */
6111 drain_workqueue(wq);
6112
6113 + /* kill rescuer, if sanity checks fail, leave it w/o rescuer */
6114 + if (wq->rescuer) {
6115 + struct worker *rescuer = wq->rescuer;
6116 +
6117 + /* this prevents new queueing */
6118 + spin_lock_irq(&wq_mayday_lock);
6119 + wq->rescuer = NULL;
6120 + spin_unlock_irq(&wq_mayday_lock);
6121 +
6122 + /* rescuer will empty maydays list before exiting */
6123 + kthread_stop(rescuer->task);
6124 + kfree(rescuer);
6125 + }
6126 +
6127 /* sanity checks */
6128 mutex_lock(&wq->mutex);
6129 for_each_pwq(pwq, wq) {
6130 @@ -4359,11 +4385,6 @@ void destroy_workqueue(struct workqueue_struct *wq)
6131 list_del_rcu(&wq->list);
6132 mutex_unlock(&wq_pool_mutex);
6133
6134 - workqueue_sysfs_unregister(wq);
6135 -
6136 - if (wq->rescuer)
6137 - kthread_stop(wq->rescuer->task);
6138 -
6139 if (!(wq->flags & WQ_UNBOUND)) {
6140 wq_unregister_lockdep(wq);
6141 /*
6142 @@ -4638,7 +4659,8 @@ static void show_pwq(struct pool_workqueue *pwq)
6143 pr_info(" pwq %d:", pool->id);
6144 pr_cont_pool_info(pool);
6145
6146 - pr_cont(" active=%d/%d%s\n", pwq->nr_active, pwq->max_active,
6147 + pr_cont(" active=%d/%d refcnt=%d%s\n",
6148 + pwq->nr_active, pwq->max_active, pwq->refcnt,
6149 !list_empty(&pwq->mayday_node) ? " MAYDAY" : "");
6150
6151 hash_for_each(pool->busy_hash, bkt, worker, hentry) {
6152 diff --git a/lib/raid6/unroll.awk b/lib/raid6/unroll.awk
6153 index c6aa03631df8..0809805a7e23 100644
6154 --- a/lib/raid6/unroll.awk
6155 +++ b/lib/raid6/unroll.awk
6156 @@ -13,7 +13,7 @@ BEGIN {
6157 for (i = 0; i < rep; ++i) {
6158 tmp = $0
6159 gsub(/\$\$/, i, tmp)
6160 - gsub(/\$\#/, n, tmp)
6161 + gsub(/\$#/, n, tmp)
6162 gsub(/\$\*/, "$", tmp)
6163 print tmp
6164 }
6165 diff --git a/mm/shmem.c b/mm/shmem.c
6166 index 220be9fa2c41..7a22e3e03d11 100644
6167 --- a/mm/shmem.c
6168 +++ b/mm/shmem.c
6169 @@ -2213,11 +2213,14 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
6170 return -EPERM;
6171
6172 /*
6173 - * Since the F_SEAL_FUTURE_WRITE seals allow for a MAP_SHARED
6174 - * read-only mapping, take care to not allow mprotect to revert
6175 - * protections.
6176 + * Since an F_SEAL_FUTURE_WRITE sealed memfd can be mapped as
6177 + * MAP_SHARED and read-only, take care to not allow mprotect to
6178 + * revert protections on such mappings. Do this only for shared
6179 + * mappings. For private mappings, don't need to mask
6180 + * VM_MAYWRITE as we still want them to be COW-writable.
6181 */
6182 - vma->vm_flags &= ~(VM_MAYWRITE);
6183 + if (vma->vm_flags & VM_SHARED)
6184 + vma->vm_flags &= ~(VM_MAYWRITE);
6185 }
6186
6187 file_accessed(file);
6188 @@ -2742,7 +2745,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
6189 }
6190
6191 shmem_falloc.waitq = &shmem_falloc_waitq;
6192 - shmem_falloc.start = unmap_start >> PAGE_SHIFT;
6193 + shmem_falloc.start = (u64)unmap_start >> PAGE_SHIFT;
6194 shmem_falloc.next = (unmap_end + 1) >> PAGE_SHIFT;
6195 spin_lock(&inode->i_lock);
6196 inode->i_private = &shmem_falloc;
6197 diff --git a/mm/slab_common.c b/mm/slab_common.c
6198 index f9fb27b4c843..78402b362df9 100644
6199 --- a/mm/slab_common.c
6200 +++ b/mm/slab_common.c
6201 @@ -904,6 +904,18 @@ static void flush_memcg_workqueue(struct kmem_cache *s)
6202 * previous workitems on workqueue are processed.
6203 */
6204 flush_workqueue(memcg_kmem_cache_wq);
6205 +
6206 + /*
6207 + * If we're racing with children kmem_cache deactivation, it might
6208 + * take another rcu grace period to complete their destruction.
6209 + * At this moment the corresponding percpu_ref_kill() call should be
6210 + * done, but it might take another rcu grace period to complete
6211 + * switching to the atomic mode.
6212 + * Please, note that we check without grabbing the slab_mutex. It's safe
6213 + * because at this moment the children list can't grow.
6214 + */
6215 + if (!list_empty(&s->memcg_params.children))
6216 + rcu_barrier();
6217 }
6218 #else
6219 static inline int shutdown_memcg_caches(struct kmem_cache *s)
6220 diff --git a/sound/firewire/fireface/ff-pcm.c b/sound/firewire/fireface/ff-pcm.c
6221 index 9eab3ad283ce..df6ff2df0124 100644
6222 --- a/sound/firewire/fireface/ff-pcm.c
6223 +++ b/sound/firewire/fireface/ff-pcm.c
6224 @@ -219,7 +219,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
6225 mutex_unlock(&ff->mutex);
6226 }
6227
6228 - return 0;
6229 + return err;
6230 }
6231
6232 static int pcm_hw_free(struct snd_pcm_substream *substream)
6233 diff --git a/sound/firewire/oxfw/oxfw-pcm.c b/sound/firewire/oxfw/oxfw-pcm.c
6234 index 7c6d1c277d4d..78d906af9c00 100644
6235 --- a/sound/firewire/oxfw/oxfw-pcm.c
6236 +++ b/sound/firewire/oxfw/oxfw-pcm.c
6237 @@ -255,7 +255,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream,
6238 mutex_unlock(&oxfw->mutex);
6239 }
6240
6241 - return 0;
6242 + return err;
6243 }
6244
6245 static int pcm_capture_hw_free(struct snd_pcm_substream *substream)
6246 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
6247 index ed3e314b5233..e1229dbad6b2 100644
6248 --- a/sound/pci/hda/patch_realtek.c
6249 +++ b/sound/pci/hda/patch_realtek.c
6250 @@ -7672,11 +7672,6 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
6251 {0x1a, 0x90a70130},
6252 {0x1b, 0x90170110},
6253 {0x21, 0x03211020}),
6254 - SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
6255 - {0x12, 0xb7a60130},
6256 - {0x13, 0xb8a61140},
6257 - {0x16, 0x90170110},
6258 - {0x21, 0x04211020}),
6259 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
6260 {0x12, 0x90a60130},
6261 {0x14, 0x90170110},
6262 @@ -7864,6 +7859,9 @@ static const struct snd_hda_pin_quirk alc269_fallback_pin_fixup_tbl[] = {
6263 SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
6264 {0x19, 0x40000000},
6265 {0x1b, 0x40000000}),
6266 + SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
6267 + {0x19, 0x40000000},
6268 + {0x1a, 0x40000000}),
6269 {}
6270 };
6271
6272 diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
6273 index 1c06b3b9218c..19662ee330d6 100644
6274 --- a/sound/soc/codecs/rt5645.c
6275 +++ b/sound/soc/codecs/rt5645.c
6276 @@ -3270,6 +3270,9 @@ static void rt5645_jack_detect_work(struct work_struct *work)
6277 snd_soc_jack_report(rt5645->mic_jack,
6278 report, SND_JACK_MICROPHONE);
6279 return;
6280 + case 4:
6281 + val = snd_soc_component_read32(rt5645->component, RT5645_A_JD_CTRL1) & 0x0020;
6282 + break;
6283 default: /* read rt5645 jd1_1 status */
6284 val = snd_soc_component_read32(rt5645->component, RT5645_INT_IRQ_ST) & 0x1000;
6285 break;
6286 @@ -3603,7 +3606,7 @@ static const struct rt5645_platform_data intel_braswell_platform_data = {
6287 static const struct rt5645_platform_data buddy_platform_data = {
6288 .dmic1_data_pin = RT5645_DMIC_DATA_GPIO5,
6289 .dmic2_data_pin = RT5645_DMIC_DATA_IN2P,
6290 - .jd_mode = 3,
6291 + .jd_mode = 4,
6292 .level_trigger_irq = true,
6293 };
6294
6295 @@ -3999,6 +4002,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
6296 RT5645_JD1_MODE_1);
6297 break;
6298 case 3:
6299 + case 4:
6300 regmap_update_bits(rt5645->regmap, RT5645_A_JD_CTRL1,
6301 RT5645_JD1_MODE_MASK,
6302 RT5645_JD1_MODE_2);
6303 diff --git a/sound/soc/fsl/fsl_audmix.c b/sound/soc/fsl/fsl_audmix.c
6304 index c7e4e9757dce..a1db1bce330f 100644
6305 --- a/sound/soc/fsl/fsl_audmix.c
6306 +++ b/sound/soc/fsl/fsl_audmix.c
6307 @@ -286,6 +286,7 @@ static int fsl_audmix_dai_trigger(struct snd_pcm_substream *substream, int cmd,
6308 struct snd_soc_dai *dai)
6309 {
6310 struct fsl_audmix *priv = snd_soc_dai_get_drvdata(dai);
6311 + unsigned long lock_flags;
6312
6313 /* Capture stream shall not be handled */
6314 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
6315 @@ -295,12 +296,16 @@ static int fsl_audmix_dai_trigger(struct snd_pcm_substream *substream, int cmd,
6316 case SNDRV_PCM_TRIGGER_START:
6317 case SNDRV_PCM_TRIGGER_RESUME:
6318 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
6319 + spin_lock_irqsave(&priv->lock, lock_flags);
6320 priv->tdms |= BIT(dai->driver->id);
6321 + spin_unlock_irqrestore(&priv->lock, lock_flags);
6322 break;
6323 case SNDRV_PCM_TRIGGER_STOP:
6324 case SNDRV_PCM_TRIGGER_SUSPEND:
6325 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
6326 + spin_lock_irqsave(&priv->lock, lock_flags);
6327 priv->tdms &= ~BIT(dai->driver->id);
6328 + spin_unlock_irqrestore(&priv->lock, lock_flags);
6329 break;
6330 default:
6331 return -EINVAL;
6332 @@ -491,6 +496,7 @@ static int fsl_audmix_probe(struct platform_device *pdev)
6333 return PTR_ERR(priv->ipg_clk);
6334 }
6335
6336 + spin_lock_init(&priv->lock);
6337 platform_set_drvdata(pdev, priv);
6338 pm_runtime_enable(dev);
6339
6340 diff --git a/sound/soc/fsl/fsl_audmix.h b/sound/soc/fsl/fsl_audmix.h
6341 index 7812ffec45c5..479f05695d53 100644
6342 --- a/sound/soc/fsl/fsl_audmix.h
6343 +++ b/sound/soc/fsl/fsl_audmix.h
6344 @@ -96,6 +96,7 @@ struct fsl_audmix {
6345 struct platform_device *pdev;
6346 struct regmap *regmap;
6347 struct clk *ipg_clk;
6348 + spinlock_t lock; /* Protect tdms */
6349 u8 tdms;
6350 };
6351
6352 diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
6353 index a71d2340eb05..b5748dcd490f 100644
6354 --- a/sound/soc/soc-jack.c
6355 +++ b/sound/soc/soc-jack.c
6356 @@ -82,10 +82,9 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
6357 unsigned int sync = 0;
6358 int enable;
6359
6360 - trace_snd_soc_jack_report(jack, mask, status);
6361 -
6362 if (!jack)
6363 return;
6364 + trace_snd_soc_jack_report(jack, mask, status);
6365
6366 dapm = &jack->card->dapm;
6367
6368 diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c
6369 index 338cd9faa835..5128f727c0ef 100644
6370 --- a/tools/perf/tests/backward-ring-buffer.c
6371 +++ b/tools/perf/tests/backward-ring-buffer.c
6372 @@ -147,6 +147,15 @@ int test__backward_ring_buffer(struct test *test __maybe_unused, int subtest __m
6373 goto out_delete_evlist;
6374 }
6375
6376 + evlist__close(evlist);
6377 +
6378 + err = evlist__open(evlist);
6379 + if (err < 0) {
6380 + pr_debug("perf_evlist__open: %s\n",
6381 + str_error_r(errno, sbuf, sizeof(sbuf)));
6382 + goto out_delete_evlist;
6383 + }
6384 +
6385 err = do_test(evlist, 1, &sample_count, &comm_count);
6386 if (err != TEST_OK)
6387 goto out_delete_evlist;
6388 diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
6389 index 7f8b5c8982e3..b505bb062d07 100644
6390 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
6391 +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
6392 @@ -35,6 +35,7 @@
6393 #include <stdbool.h>
6394 #include <string.h>
6395 #include <time.h>
6396 +#include <limits.h>
6397 #include <linux/elf.h>
6398 #include <sys/uio.h>
6399 #include <sys/utsname.h>
6400 @@ -3077,7 +3078,7 @@ static int user_trap_syscall(int nr, unsigned int flags)
6401 return seccomp(SECCOMP_SET_MODE_FILTER, flags, &prog);
6402 }
6403
6404 -#define USER_NOTIF_MAGIC 116983961184613L
6405 +#define USER_NOTIF_MAGIC INT_MAX
6406 TEST(user_notification_basic)
6407 {
6408 pid_t pid;