Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0217-5.4.118-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3637 - (show annotations) (download)
Mon Oct 24 12:40:44 2022 UTC (19 months ago) by niro
File size: 226598 byte(s)
-add missing
1 diff --git a/Makefile b/Makefile
2 index f4115702996c5..05a19383b3964 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,7 +1,7 @@
6 # SPDX-License-Identifier: GPL-2.0
7 VERSION = 5
8 PATCHLEVEL = 4
9 -SUBLEVEL = 117
10 +SUBLEVEL = 118
11 EXTRAVERSION =
12 NAME = Kleptomaniac Octopus
13
14 @@ -765,16 +765,16 @@ KBUILD_CFLAGS += -Wno-tautological-compare
15 KBUILD_CFLAGS += -mno-global-merge
16 else
17
18 -# These warnings generated too much noise in a regular build.
19 -# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
20 -KBUILD_CFLAGS += -Wno-unused-but-set-variable
21 -
22 # Warn about unmarked fall-throughs in switch statement.
23 # Disabled for clang while comment to attribute conversion happens and
24 # https://github.com/ClangBuiltLinux/linux/issues/636 is discussed.
25 KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
26 endif
27
28 +# These warnings generated too much noise in a regular build.
29 +# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
30 +KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
31 +
32 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
33 ifdef CONFIG_FRAME_POINTER
34 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
35 diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
36 index 6da67789ac221..f0b3a9281d69b 100644
37 --- a/arch/arm/boot/compressed/Makefile
38 +++ b/arch/arm/boot/compressed/Makefile
39 @@ -122,8 +122,8 @@ asflags-y := -DZIMAGE
40
41 # Supply kernel BSS size to the decompressor via a linker symbol.
42 KBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \
43 - sed -n -e 's/^\([^ ]*\) [AB] __bss_start$$/-0x\1/p' \
44 - -e 's/^\([^ ]*\) [AB] __bss_stop$$/+0x\1/p') )) )
45 + sed -n -e 's/^\([^ ]*\) [ABD] __bss_start$$/-0x\1/p' \
46 + -e 's/^\([^ ]*\) [ABD] __bss_stop$$/+0x\1/p') )) )
47 LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
48 # Supply ZRELADDR to the decompressor via a linker symbol.
49 ifneq ($(CONFIG_AUTO_ZRELADDR),y)
50 diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
51 index 000c135e39b73..28ad59ee6c34b 100644
52 --- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
53 +++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
54 @@ -156,7 +156,8 @@
55 };
56
57 nb_periph_clk: nb-periph-clk@13000 {
58 - compatible = "marvell,armada-3700-periph-clock-nb";
59 + compatible = "marvell,armada-3700-periph-clock-nb",
60 + "syscon";
61 reg = <0x13000 0x100>;
62 clocks = <&tbg 0>, <&tbg 1>, <&tbg 2>,
63 <&tbg 3>, <&xtalclk>;
64 diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
65 index dec5e4113ce4c..c4f742e6d1604 100644
66 --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
67 +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
68 @@ -1137,7 +1137,7 @@
69 <&mmsys CLK_MM_DSI1_DIGITAL>,
70 <&mipi_tx1>;
71 clock-names = "engine", "digital", "hs";
72 - phy = <&mipi_tx1>;
73 + phys = <&mipi_tx1>;
74 phy-names = "dphy";
75 status = "disabled";
76 };
77 diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
78 index 7ad2d3a0cd489..815df253f96e0 100644
79 --- a/arch/arm64/kernel/vdso/vdso.lds.S
80 +++ b/arch/arm64/kernel/vdso/vdso.lds.S
81 @@ -28,6 +28,13 @@ SECTIONS
82 .gnu.version_d : { *(.gnu.version_d) }
83 .gnu.version_r : { *(.gnu.version_r) }
84
85 + /*
86 + * Discard .note.gnu.property sections which are unused and have
87 + * different alignment requirement from vDSO note sections.
88 + */
89 + /DISCARD/ : {
90 + *(.note.GNU-stack .note.gnu.property)
91 + }
92 .note : { *(.note.*) } :text :note
93
94 . = ALIGN(16);
95 @@ -48,7 +55,6 @@ SECTIONS
96 PROVIDE(end = .);
97
98 /DISCARD/ : {
99 - *(.note.GNU-stack)
100 *(.data .data.* .gnu.linkonce.d.* .sdata*)
101 *(.bss .sbss .dynbss .dynsbss)
102 }
103 diff --git a/arch/powerpc/include/uapi/asm/errno.h b/arch/powerpc/include/uapi/asm/errno.h
104 index cc79856896a19..4ba87de32be00 100644
105 --- a/arch/powerpc/include/uapi/asm/errno.h
106 +++ b/arch/powerpc/include/uapi/asm/errno.h
107 @@ -2,6 +2,7 @@
108 #ifndef _ASM_POWERPC_ERRNO_H
109 #define _ASM_POWERPC_ERRNO_H
110
111 +#undef EDEADLOCK
112 #include <asm-generic/errno.h>
113
114 #undef EDEADLOCK
115 diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
116 index c35069294ecfb..8b0e523b2abbe 100644
117 --- a/arch/powerpc/kernel/eeh.c
118 +++ b/arch/powerpc/kernel/eeh.c
119 @@ -368,14 +368,11 @@ static inline unsigned long eeh_token_to_phys(unsigned long token)
120 pa = pte_pfn(*ptep);
121
122 /* On radix we can do hugepage mappings for io, so handle that */
123 - if (hugepage_shift) {
124 - pa <<= hugepage_shift;
125 - pa |= token & ((1ul << hugepage_shift) - 1);
126 - } else {
127 - pa <<= PAGE_SHIFT;
128 - pa |= token & (PAGE_SIZE - 1);
129 - }
130 + if (!hugepage_shift)
131 + hugepage_shift = PAGE_SHIFT;
132
133 + pa <<= PAGE_SHIFT;
134 + pa |= token & ((1ul << hugepage_shift) - 1);
135 return pa;
136 }
137
138 diff --git a/arch/s390/crypto/arch_random.c b/arch/s390/crypto/arch_random.c
139 index dd95cdbd22ce8..4cbb4b6d85a83 100644
140 --- a/arch/s390/crypto/arch_random.c
141 +++ b/arch/s390/crypto/arch_random.c
142 @@ -53,6 +53,10 @@ static DECLARE_DELAYED_WORK(arch_rng_work, arch_rng_refill_buffer);
143
144 bool s390_arch_random_generate(u8 *buf, unsigned int nbytes)
145 {
146 + /* max hunk is ARCH_RNG_BUF_SIZE */
147 + if (nbytes > ARCH_RNG_BUF_SIZE)
148 + return false;
149 +
150 /* lock rng buffer */
151 if (!spin_trylock(&arch_rng_lock))
152 return false;
153 diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
154 index f304802ecf7be..03e35b399c4ee 100644
155 --- a/arch/s390/kernel/dis.c
156 +++ b/arch/s390/kernel/dis.c
157 @@ -557,7 +557,7 @@ void show_code(struct pt_regs *regs)
158
159 void print_fn_code(unsigned char *code, unsigned long len)
160 {
161 - char buffer[64], *ptr;
162 + char buffer[128], *ptr;
163 int opsize, i;
164
165 while (len) {
166 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
167 index 59942e349e5f0..69f0cb01c6662 100644
168 --- a/arch/x86/Makefile
169 +++ b/arch/x86/Makefile
170 @@ -40,6 +40,7 @@ REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding
171 REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
172 REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member)
173 REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
174 +REALMODE_CFLAGS += $(CLANG_FLAGS)
175 export REALMODE_CFLAGS
176
177 # BITS is used as extension for files which are available in a 32 bit
178 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
179 index 8a85c2e144a6f..f961a56e9da3f 100644
180 --- a/arch/x86/kernel/cpu/common.c
181 +++ b/arch/x86/kernel/cpu/common.c
182 @@ -1826,7 +1826,7 @@ static void setup_getcpu(int cpu)
183 unsigned long cpudata = vdso_encode_cpunode(cpu, early_cpu_to_node(cpu));
184 struct desc_struct d = { };
185
186 - if (boot_cpu_has(X86_FEATURE_RDTSCP))
187 + if (boot_cpu_has(X86_FEATURE_RDTSCP) || boot_cpu_has(X86_FEATURE_RDPID))
188 write_rdtscp_aux(cpudata);
189
190 /* Store CPU and node number in limit. */
191 diff --git a/crypto/api.c b/crypto/api.c
192 index eda0c56b86154..c71d1485541c7 100644
193 --- a/crypto/api.c
194 +++ b/crypto/api.c
195 @@ -568,7 +568,7 @@ void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)
196 {
197 struct crypto_alg *alg;
198
199 - if (unlikely(!mem))
200 + if (IS_ERR_OR_NULL(mem))
201 return;
202
203 alg = tfm->__crt_alg;
204 diff --git a/crypto/rng.c b/crypto/rng.c
205 index 1490d210f1a19..608d6ce1440a6 100644
206 --- a/crypto/rng.c
207 +++ b/crypto/rng.c
208 @@ -34,22 +34,18 @@ int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen)
209 u8 *buf = NULL;
210 int err;
211
212 - crypto_stats_get(alg);
213 if (!seed && slen) {
214 buf = kmalloc(slen, GFP_KERNEL);
215 - if (!buf) {
216 - crypto_alg_put(alg);
217 + if (!buf)
218 return -ENOMEM;
219 - }
220
221 err = get_random_bytes_wait(buf, slen);
222 - if (err) {
223 - crypto_alg_put(alg);
224 + if (err)
225 goto out;
226 - }
227 seed = buf;
228 }
229
230 + crypto_stats_get(alg);
231 err = crypto_rng_alg(tfm)->seed(tfm, seed, slen);
232 crypto_stats_rng_seed(alg, err);
233 out:
234 diff --git a/drivers/acpi/arm64/gtdt.c b/drivers/acpi/arm64/gtdt.c
235 index 01962c63a7116..7d7497b856020 100644
236 --- a/drivers/acpi/arm64/gtdt.c
237 +++ b/drivers/acpi/arm64/gtdt.c
238 @@ -329,7 +329,7 @@ static int __init gtdt_import_sbsa_gwdt(struct acpi_gtdt_watchdog *wd,
239 int index)
240 {
241 struct platform_device *pdev;
242 - int irq = map_gt_gsi(wd->timer_interrupt, wd->timer_flags);
243 + int irq;
244
245 /*
246 * According to SBSA specification the size of refresh and control
247 @@ -338,7 +338,7 @@ static int __init gtdt_import_sbsa_gwdt(struct acpi_gtdt_watchdog *wd,
248 struct resource res[] = {
249 DEFINE_RES_MEM(wd->control_frame_address, SZ_4K),
250 DEFINE_RES_MEM(wd->refresh_frame_address, SZ_4K),
251 - DEFINE_RES_IRQ(irq),
252 + {},
253 };
254 int nr_res = ARRAY_SIZE(res);
255
256 @@ -348,10 +348,11 @@ static int __init gtdt_import_sbsa_gwdt(struct acpi_gtdt_watchdog *wd,
257
258 if (!(wd->refresh_frame_address && wd->control_frame_address)) {
259 pr_err(FW_BUG "failed to get the Watchdog base address.\n");
260 - acpi_unregister_gsi(wd->timer_interrupt);
261 return -EINVAL;
262 }
263
264 + irq = map_gt_gsi(wd->timer_interrupt, wd->timer_flags);
265 + res[2] = (struct resource)DEFINE_RES_IRQ(irq);
266 if (irq <= 0) {
267 pr_warn("failed to map the Watchdog interrupt.\n");
268 nr_res--;
269 @@ -364,7 +365,8 @@ static int __init gtdt_import_sbsa_gwdt(struct acpi_gtdt_watchdog *wd,
270 */
271 pdev = platform_device_register_simple("sbsa-gwdt", index, res, nr_res);
272 if (IS_ERR(pdev)) {
273 - acpi_unregister_gsi(wd->timer_interrupt);
274 + if (irq > 0)
275 + acpi_unregister_gsi(wd->timer_interrupt);
276 return PTR_ERR(pdev);
277 }
278
279 diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
280 index b097ef209313f..e7716c7b9be76 100644
281 --- a/drivers/acpi/custom_method.c
282 +++ b/drivers/acpi/custom_method.c
283 @@ -44,6 +44,8 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
284 sizeof(struct acpi_table_header)))
285 return -EFAULT;
286 uncopied_bytes = max_size = table.length;
287 + /* make sure the buf is not allocated */
288 + kfree(buf);
289 buf = kzalloc(max_size, GFP_KERNEL);
290 if (!buf)
291 return -ENOMEM;
292 @@ -57,6 +59,7 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
293 (*ppos + count < count) ||
294 (count > uncopied_bytes)) {
295 kfree(buf);
296 + buf = NULL;
297 return -EINVAL;
298 }
299
300 @@ -78,7 +81,6 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
301 add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE);
302 }
303
304 - kfree(buf);
305 return count;
306 }
307
308 diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
309 index d33528033042c..8beb418ce167b 100644
310 --- a/drivers/ata/ahci.c
311 +++ b/drivers/ata/ahci.c
312 @@ -1728,6 +1728,11 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
313 hpriv->flags |= AHCI_HFLAG_NO_DEVSLP;
314
315 #ifdef CONFIG_ARM64
316 + if (pdev->vendor == PCI_VENDOR_ID_HUAWEI &&
317 + pdev->device == 0xa235 &&
318 + pdev->revision < 0x30)
319 + hpriv->flags |= AHCI_HFLAG_NO_SXS;
320 +
321 if (pdev->vendor == 0x177d && pdev->device == 0xa01c)
322 hpriv->irq_handler = ahci_thunderx_irq_handler;
323 #endif
324 diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
325 index 9ef62e647cd20..732912cd4e083 100644
326 --- a/drivers/ata/ahci.h
327 +++ b/drivers/ata/ahci.h
328 @@ -242,6 +242,7 @@ enum {
329 suspend/resume */
330 AHCI_HFLAG_IGN_NOTSUPP_POWER_ON = (1 << 27), /* ignore -EOPNOTSUPP
331 from phy_power_on() */
332 + AHCI_HFLAG_NO_SXS = (1 << 28), /* SXS not supported */
333
334 /* ap->flags bits */
335
336 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
337 index ea5bf5f4cbed5..fec2e9754aed2 100644
338 --- a/drivers/ata/libahci.c
339 +++ b/drivers/ata/libahci.c
340 @@ -493,6 +493,11 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
341 cap |= HOST_CAP_ALPM;
342 }
343
344 + if ((cap & HOST_CAP_SXS) && (hpriv->flags & AHCI_HFLAG_NO_SXS)) {
345 + dev_info(dev, "controller does not support SXS, disabling CAP_SXS\n");
346 + cap &= ~HOST_CAP_SXS;
347 + }
348 +
349 if (hpriv->force_port_map && port_map != hpriv->force_port_map) {
350 dev_info(dev, "forcing port_map 0x%x -> 0x%x\n",
351 port_map, hpriv->force_port_map);
352 diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
353 index f9ff6d433dfe1..d59e1ca9990b6 100644
354 --- a/drivers/bus/ti-sysc.c
355 +++ b/drivers/bus/ti-sysc.c
356 @@ -602,6 +602,51 @@ static int sysc_parse_and_check_child_range(struct sysc *ddata)
357 return 0;
358 }
359
360 +/* Interconnect instances to probe before l4_per instances */
361 +static struct resource early_bus_ranges[] = {
362 + /* am3/4 l4_wkup */
363 + { .start = 0x44c00000, .end = 0x44c00000 + 0x300000, },
364 + /* omap4/5 and dra7 l4_cfg */
365 + { .start = 0x4a000000, .end = 0x4a000000 + 0x300000, },
366 + /* omap4 l4_wkup */
367 + { .start = 0x4a300000, .end = 0x4a300000 + 0x30000, },
368 + /* omap5 and dra7 l4_wkup without dra7 dcan segment */
369 + { .start = 0x4ae00000, .end = 0x4ae00000 + 0x30000, },
370 +};
371 +
372 +static atomic_t sysc_defer = ATOMIC_INIT(10);
373 +
374 +/**
375 + * sysc_defer_non_critical - defer non_critical interconnect probing
376 + * @ddata: device driver data
377 + *
378 + * We want to probe l4_cfg and l4_wkup interconnect instances before any
379 + * l4_per instances as l4_per instances depend on resources on l4_cfg and
380 + * l4_wkup interconnects.
381 + */
382 +static int sysc_defer_non_critical(struct sysc *ddata)
383 +{
384 + struct resource *res;
385 + int i;
386 +
387 + if (!atomic_read(&sysc_defer))
388 + return 0;
389 +
390 + for (i = 0; i < ARRAY_SIZE(early_bus_ranges); i++) {
391 + res = &early_bus_ranges[i];
392 + if (ddata->module_pa >= res->start &&
393 + ddata->module_pa <= res->end) {
394 + atomic_set(&sysc_defer, 0);
395 +
396 + return 0;
397 + }
398 + }
399 +
400 + atomic_dec_if_positive(&sysc_defer);
401 +
402 + return -EPROBE_DEFER;
403 +}
404 +
405 static struct device_node *stdout_path;
406
407 static void sysc_init_stdout_path(struct sysc *ddata)
408 @@ -826,6 +871,10 @@ static int sysc_map_and_check_registers(struct sysc *ddata)
409 if (error)
410 return error;
411
412 + error = sysc_defer_non_critical(ddata);
413 + if (error)
414 + return error;
415 +
416 sysc_check_children(ddata);
417
418 error = sysc_parse_registers(ddata);
419 diff --git a/drivers/char/tpm/eventlog/common.c b/drivers/char/tpm/eventlog/common.c
420 index 7460f230bae4c..8512ec76d5260 100644
421 --- a/drivers/char/tpm/eventlog/common.c
422 +++ b/drivers/char/tpm/eventlog/common.c
423 @@ -107,6 +107,9 @@ void tpm_bios_log_setup(struct tpm_chip *chip)
424 int log_version;
425 int rc = 0;
426
427 + if (chip->flags & TPM_CHIP_FLAG_VIRTUAL)
428 + return;
429 +
430 rc = tpm_read_log(chip);
431 if (rc < 0)
432 return;
433 diff --git a/drivers/char/tpm/eventlog/efi.c b/drivers/char/tpm/eventlog/efi.c
434 index 35229e5143cac..e6cb9d525e30c 100644
435 --- a/drivers/char/tpm/eventlog/efi.c
436 +++ b/drivers/char/tpm/eventlog/efi.c
437 @@ -17,6 +17,7 @@ int tpm_read_log_efi(struct tpm_chip *chip)
438 {
439
440 struct efi_tcg2_final_events_table *final_tbl = NULL;
441 + int final_events_log_size = efi_tpm_final_log_size;
442 struct linux_efi_tpm_eventlog *log_tbl;
443 struct tpm_bios_log *log;
444 u32 log_size;
445 @@ -66,12 +67,12 @@ int tpm_read_log_efi(struct tpm_chip *chip)
446 ret = tpm_log_version;
447
448 if (efi.tpm_final_log == EFI_INVALID_TABLE_ADDR ||
449 - efi_tpm_final_log_size == 0 ||
450 + final_events_log_size == 0 ||
451 tpm_log_version != EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)
452 goto out;
453
454 final_tbl = memremap(efi.tpm_final_log,
455 - sizeof(*final_tbl) + efi_tpm_final_log_size,
456 + sizeof(*final_tbl) + final_events_log_size,
457 MEMREMAP_WB);
458 if (!final_tbl) {
459 pr_err("Could not map UEFI TPM final log\n");
460 @@ -80,10 +81,18 @@ int tpm_read_log_efi(struct tpm_chip *chip)
461 goto out;
462 }
463
464 - efi_tpm_final_log_size -= log_tbl->final_events_preboot_size;
465 + /*
466 + * The 'final events log' size excludes the 'final events preboot log'
467 + * at its beginning.
468 + */
469 + final_events_log_size -= log_tbl->final_events_preboot_size;
470
471 + /*
472 + * Allocate memory for the 'combined log' where we will append the
473 + * 'final events log' to.
474 + */
475 tmp = krealloc(log->bios_event_log,
476 - log_size + efi_tpm_final_log_size,
477 + log_size + final_events_log_size,
478 GFP_KERNEL);
479 if (!tmp) {
480 kfree(log->bios_event_log);
481 @@ -94,15 +103,19 @@ int tpm_read_log_efi(struct tpm_chip *chip)
482 log->bios_event_log = tmp;
483
484 /*
485 - * Copy any of the final events log that didn't also end up in the
486 - * main log. Events can be logged in both if events are generated
487 + * Append any of the 'final events log' that didn't also end up in the
488 + * 'main log'. Events can be logged in both if events are generated
489 * between GetEventLog() and ExitBootServices().
490 */
491 memcpy((void *)log->bios_event_log + log_size,
492 final_tbl->events + log_tbl->final_events_preboot_size,
493 - efi_tpm_final_log_size);
494 + final_events_log_size);
495 + /*
496 + * The size of the 'combined log' is the size of the 'main log' plus
497 + * the size of the 'final events log'.
498 + */
499 log->bios_event_log_end = log->bios_event_log +
500 - log_size + efi_tpm_final_log_size;
501 + log_size + final_events_log_size;
502
503 out:
504 memunmap(final_tbl);
505 diff --git a/drivers/clk/socfpga/clk-gate-a10.c b/drivers/clk/socfpga/clk-gate-a10.c
506 index cd5df91036142..d62778884208c 100644
507 --- a/drivers/clk/socfpga/clk-gate-a10.c
508 +++ b/drivers/clk/socfpga/clk-gate-a10.c
509 @@ -146,6 +146,7 @@ static void __init __socfpga_gate_init(struct device_node *node,
510 if (IS_ERR(socfpga_clk->sys_mgr_base_addr)) {
511 pr_err("%s: failed to find altr,sys-mgr regmap!\n",
512 __func__);
513 + kfree(socfpga_clk);
514 return;
515 }
516 }
517 diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
518 index 103e704c14697..72edb10181b86 100644
519 --- a/drivers/crypto/omap-aes.c
520 +++ b/drivers/crypto/omap-aes.c
521 @@ -103,7 +103,7 @@ static int omap_aes_hw_init(struct omap_aes_dev *dd)
522 dd->err = 0;
523 }
524
525 - err = pm_runtime_get_sync(dd->dev);
526 + err = pm_runtime_resume_and_get(dd->dev);
527 if (err < 0) {
528 dev_err(dd->dev, "failed to get sync: %d\n", err);
529 return err;
530 @@ -1153,7 +1153,7 @@ static int omap_aes_probe(struct platform_device *pdev)
531 pm_runtime_set_autosuspend_delay(dev, DEFAULT_AUTOSUSPEND_DELAY);
532
533 pm_runtime_enable(dev);
534 - err = pm_runtime_get_sync(dev);
535 + err = pm_runtime_resume_and_get(dev);
536 if (err < 0) {
537 dev_err(dev, "%s: failed to get_sync(%d)\n",
538 __func__, err);
539 @@ -1318,7 +1318,7 @@ static int omap_aes_suspend(struct device *dev)
540
541 static int omap_aes_resume(struct device *dev)
542 {
543 - pm_runtime_get_sync(dev);
544 + pm_runtime_resume_and_get(dev);
545 return 0;
546 }
547 #endif
548 diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c
549 index 0d67cf5ede514..6b8ad3d67481a 100644
550 --- a/drivers/crypto/qat/qat_common/qat_algs.c
551 +++ b/drivers/crypto/qat/qat_common/qat_algs.c
552 @@ -715,7 +715,7 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst,
553 struct qat_alg_buf_list *bufl;
554 struct qat_alg_buf_list *buflout = NULL;
555 dma_addr_t blp;
556 - dma_addr_t bloutp = 0;
557 + dma_addr_t bloutp;
558 struct scatterlist *sg;
559 size_t sz_out, sz = struct_size(bufl, bufers, n + 1);
560
561 @@ -727,6 +727,9 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst,
562 if (unlikely(!bufl))
563 return -ENOMEM;
564
565 + for_each_sg(sgl, sg, n, i)
566 + bufl->bufers[i].addr = DMA_MAPPING_ERROR;
567 +
568 blp = dma_map_single(dev, bufl, sz, DMA_TO_DEVICE);
569 if (unlikely(dma_mapping_error(dev, blp)))
570 goto err_in;
571 @@ -760,10 +763,14 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst,
572 dev_to_node(&GET_DEV(inst->accel_dev)));
573 if (unlikely(!buflout))
574 goto err_in;
575 +
576 + bufers = buflout->bufers;
577 + for_each_sg(sglout, sg, n, i)
578 + bufers[i].addr = DMA_MAPPING_ERROR;
579 +
580 bloutp = dma_map_single(dev, buflout, sz_out, DMA_TO_DEVICE);
581 if (unlikely(dma_mapping_error(dev, bloutp)))
582 goto err_out;
583 - bufers = buflout->bufers;
584 for_each_sg(sglout, sg, n, i) {
585 int y = sg_nctr;
586
587 diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c
588 index ba5ea6434f9ca..9b3511236ba25 100644
589 --- a/drivers/crypto/stm32/stm32-cryp.c
590 +++ b/drivers/crypto/stm32/stm32-cryp.c
591 @@ -537,7 +537,7 @@ static int stm32_cryp_hw_init(struct stm32_cryp *cryp)
592 int ret;
593 u32 cfg, hw_mode;
594
595 - pm_runtime_get_sync(cryp->dev);
596 + pm_runtime_resume_and_get(cryp->dev);
597
598 /* Disable interrupt */
599 stm32_cryp_write(cryp, CRYP_IMSCR, 0);
600 @@ -2054,7 +2054,7 @@ static int stm32_cryp_remove(struct platform_device *pdev)
601 if (!cryp)
602 return -ENODEV;
603
604 - ret = pm_runtime_get_sync(cryp->dev);
605 + ret = pm_runtime_resume_and_get(cryp->dev);
606 if (ret < 0)
607 return ret;
608
609 diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
610 index cfc8e0e37beec..dcce15b558091 100644
611 --- a/drivers/crypto/stm32/stm32-hash.c
612 +++ b/drivers/crypto/stm32/stm32-hash.c
613 @@ -810,7 +810,7 @@ static void stm32_hash_finish_req(struct ahash_request *req, int err)
614 static int stm32_hash_hw_init(struct stm32_hash_dev *hdev,
615 struct stm32_hash_request_ctx *rctx)
616 {
617 - pm_runtime_get_sync(hdev->dev);
618 + pm_runtime_resume_and_get(hdev->dev);
619
620 if (!(HASH_FLAGS_INIT & hdev->flags)) {
621 stm32_hash_write(hdev, HASH_CR, HASH_CR_INIT);
622 @@ -959,7 +959,7 @@ static int stm32_hash_export(struct ahash_request *req, void *out)
623 u32 *preg;
624 unsigned int i;
625
626 - pm_runtime_get_sync(hdev->dev);
627 + pm_runtime_resume_and_get(hdev->dev);
628
629 while ((stm32_hash_read(hdev, HASH_SR) & HASH_SR_BUSY))
630 cpu_relax();
631 @@ -997,7 +997,7 @@ static int stm32_hash_import(struct ahash_request *req, const void *in)
632
633 preg = rctx->hw_context;
634
635 - pm_runtime_get_sync(hdev->dev);
636 + pm_runtime_resume_and_get(hdev->dev);
637
638 stm32_hash_write(hdev, HASH_IMR, *preg++);
639 stm32_hash_write(hdev, HASH_STR, *preg++);
640 @@ -1553,7 +1553,7 @@ static int stm32_hash_remove(struct platform_device *pdev)
641 if (!hdev)
642 return -ENODEV;
643
644 - ret = pm_runtime_get_sync(hdev->dev);
645 + ret = pm_runtime_resume_and_get(hdev->dev);
646 if (ret < 0)
647 return ret;
648
649 diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
650 index e970134c95fab..9a6103ac7118a 100644
651 --- a/drivers/extcon/extcon-arizona.c
652 +++ b/drivers/extcon/extcon-arizona.c
653 @@ -597,7 +597,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
654 struct arizona *arizona = info->arizona;
655 int id_gpio = arizona->pdata.hpdet_id_gpio;
656 unsigned int report = EXTCON_JACK_HEADPHONE;
657 - int ret, reading;
658 + int ret, reading, state;
659 bool mic = false;
660
661 mutex_lock(&info->lock);
662 @@ -610,12 +610,11 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
663 }
664
665 /* If the cable was removed while measuring ignore the result */
666 - ret = extcon_get_state(info->edev, EXTCON_MECHANICAL);
667 - if (ret < 0) {
668 - dev_err(arizona->dev, "Failed to check cable state: %d\n",
669 - ret);
670 + state = extcon_get_state(info->edev, EXTCON_MECHANICAL);
671 + if (state < 0) {
672 + dev_err(arizona->dev, "Failed to check cable state: %d\n", state);
673 goto out;
674 - } else if (!ret) {
675 + } else if (!state) {
676 dev_dbg(arizona->dev, "Ignoring HPDET for removed cable\n");
677 goto done;
678 }
679 @@ -668,7 +667,7 @@ done:
680 ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
681
682 /* If we have a mic then reenable MICDET */
683 - if (mic || info->mic)
684 + if (state && (mic || info->mic))
685 arizona_start_mic(info);
686
687 if (info->hpdet_active) {
688 @@ -676,7 +675,9 @@ done:
689 info->hpdet_active = false;
690 }
691
692 - info->hpdet_done = true;
693 + /* Do not set hp_det done when the cable has been unplugged */
694 + if (state)
695 + info->hpdet_done = true;
696
697 out:
698 mutex_unlock(&info->lock);
699 @@ -1724,25 +1725,6 @@ static int arizona_extcon_remove(struct platform_device *pdev)
700 bool change;
701 int ret;
702
703 - ret = regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
704 - ARIZONA_MICD_ENA, 0,
705 - &change);
706 - if (ret < 0) {
707 - dev_err(&pdev->dev, "Failed to disable micd on remove: %d\n",
708 - ret);
709 - } else if (change) {
710 - regulator_disable(info->micvdd);
711 - pm_runtime_put(info->dev);
712 - }
713 -
714 - gpiod_put(info->micd_pol_gpio);
715 -
716 - pm_runtime_disable(&pdev->dev);
717 -
718 - regmap_update_bits(arizona->regmap,
719 - ARIZONA_MICD_CLAMP_CONTROL,
720 - ARIZONA_MICD_CLAMP_MODE_MASK, 0);
721 -
722 if (info->micd_clamp) {
723 jack_irq_rise = ARIZONA_IRQ_MICD_CLAMP_RISE;
724 jack_irq_fall = ARIZONA_IRQ_MICD_CLAMP_FALL;
725 @@ -1758,10 +1740,31 @@ static int arizona_extcon_remove(struct platform_device *pdev)
726 arizona_free_irq(arizona, jack_irq_rise, info);
727 arizona_free_irq(arizona, jack_irq_fall, info);
728 cancel_delayed_work_sync(&info->hpdet_work);
729 + cancel_delayed_work_sync(&info->micd_detect_work);
730 + cancel_delayed_work_sync(&info->micd_timeout_work);
731 +
732 + ret = regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
733 + ARIZONA_MICD_ENA, 0,
734 + &change);
735 + if (ret < 0) {
736 + dev_err(&pdev->dev, "Failed to disable micd on remove: %d\n",
737 + ret);
738 + } else if (change) {
739 + regulator_disable(info->micvdd);
740 + pm_runtime_put(info->dev);
741 + }
742 +
743 + regmap_update_bits(arizona->regmap,
744 + ARIZONA_MICD_CLAMP_CONTROL,
745 + ARIZONA_MICD_CLAMP_MODE_MASK, 0);
746 regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
747 ARIZONA_JD1_ENA, 0);
748 arizona_clk32k_disable(arizona);
749
750 + gpiod_put(info->micd_pol_gpio);
751 +
752 + pm_runtime_disable(&pdev->dev);
753 +
754 return 0;
755 }
756
757 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
758 index 2a3f5ec298dbc..76429932035e1 100644
759 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
760 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
761 @@ -469,7 +469,7 @@ void amdgpu_irq_gpu_reset_resume_helper(struct amdgpu_device *adev)
762 for (j = 0; j < AMDGPU_MAX_IRQ_SRC_ID; ++j) {
763 struct amdgpu_irq_src *src = adev->irq.client[i].sources[j];
764
765 - if (!src)
766 + if (!src || !src->funcs || !src->funcs->set)
767 continue;
768 for (k = 0; k < src->num_types; k++)
769 amdgpu_irq_update(adev, src, k);
770 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
771 index c6a1dfe79e809..91e3a87b1de83 100644
772 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
773 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
774 @@ -984,7 +984,7 @@ static void amdgpu_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
775 DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
776
777 /* double check that we don't free the table twice */
778 - if (!ttm->sg->sgl)
779 + if (!ttm->sg || !ttm->sg->sgl)
780 return;
781
782 /* unmap the pages mapped to the device */
783 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
784 index b2c364b8695f9..cfa8324b9f51a 100644
785 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
786 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
787 @@ -231,7 +231,7 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
788 if ((adev->asic_type == CHIP_POLARIS10 ||
789 adev->asic_type == CHIP_POLARIS11) &&
790 (adev->uvd.fw_version < FW_1_66_16))
791 - DRM_ERROR("POLARIS10/11 UVD firmware version %hu.%hu is too old.\n",
792 + DRM_ERROR("POLARIS10/11 UVD firmware version %u.%u is too old.\n",
793 version_major, version_minor);
794 } else {
795 unsigned int enc_major, enc_minor, dec_minor;
796 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
797 index 65aae75f80fd5..ce1048bad1586 100644
798 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
799 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
800 @@ -311,15 +311,22 @@ int amdgpu_xgmi_update_topology(struct amdgpu_hive_info *hive, struct amdgpu_dev
801 }
802
803
804 +/*
805 + * NOTE psp_xgmi_node_info.num_hops layout is as follows:
806 + * num_hops[7:6] = link type (0 = xGMI2, 1 = xGMI3, 2/3 = reserved)
807 + * num_hops[5:3] = reserved
808 + * num_hops[2:0] = number of hops
809 + */
810 int amdgpu_xgmi_get_hops_count(struct amdgpu_device *adev,
811 struct amdgpu_device *peer_adev)
812 {
813 struct psp_xgmi_topology_info *top = &adev->psp.xgmi_context.top_info;
814 + uint8_t num_hops_mask = 0x7;
815 int i;
816
817 for (i = 0 ; i < top->num_nodes; ++i)
818 if (top->nodes[i].node_id == peer_adev->gmc.xgmi.node_id)
819 - return top->nodes[i].num_hops;
820 + return top->nodes[i].num_hops & num_hops_mask;
821 return -EINVAL;
822 }
823
824 diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
825 index 511712c2e382d..673d5e34f213c 100644
826 --- a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
827 +++ b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
828 @@ -33,6 +33,11 @@ static int kfd_debugfs_open(struct inode *inode, struct file *file)
829
830 return single_open(file, show, NULL);
831 }
832 +static int kfd_debugfs_hang_hws_read(struct seq_file *m, void *data)
833 +{
834 + seq_printf(m, "echo gpu_id > hang_hws\n");
835 + return 0;
836 +}
837
838 static ssize_t kfd_debugfs_hang_hws_write(struct file *file,
839 const char __user *user_buf, size_t size, loff_t *ppos)
840 @@ -94,7 +99,7 @@ void kfd_debugfs_init(void)
841 debugfs_create_file("rls", S_IFREG | 0444, debugfs_root,
842 kfd_debugfs_rls_by_device, &kfd_debugfs_fops);
843 debugfs_create_file("hang_hws", S_IFREG | 0200, debugfs_root,
844 - NULL, &kfd_debugfs_hang_hws_fops);
845 + kfd_debugfs_hang_hws_read, &kfd_debugfs_hang_hws_fops);
846 }
847
848 void kfd_debugfs_fini(void)
849 diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
850 index e9a2784400792..ab69898c9cb72 100644
851 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
852 +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
853 @@ -1011,6 +1011,9 @@ static int set_sched_resources(struct device_queue_manager *dqm)
854
855 static int initialize_cpsch(struct device_queue_manager *dqm)
856 {
857 + uint64_t num_sdma_queues;
858 + uint64_t num_xgmi_sdma_queues;
859 +
860 pr_debug("num of pipes: %d\n", get_pipes_per_mec(dqm));
861
862 mutex_init(&dqm->lock_hidden);
863 @@ -1019,8 +1022,18 @@ static int initialize_cpsch(struct device_queue_manager *dqm)
864 dqm->sdma_queue_count = 0;
865 dqm->xgmi_sdma_queue_count = 0;
866 dqm->active_runlist = false;
867 - dqm->sdma_bitmap = ~0ULL >> (64 - get_num_sdma_queues(dqm));
868 - dqm->xgmi_sdma_bitmap = ~0ULL >> (64 - get_num_xgmi_sdma_queues(dqm));
869 +
870 + num_sdma_queues = get_num_sdma_queues(dqm);
871 + if (num_sdma_queues >= BITS_PER_TYPE(dqm->sdma_bitmap))
872 + dqm->sdma_bitmap = ULLONG_MAX;
873 + else
874 + dqm->sdma_bitmap = (BIT_ULL(num_sdma_queues) - 1);
875 +
876 + num_xgmi_sdma_queues = get_num_xgmi_sdma_queues(dqm);
877 + if (num_xgmi_sdma_queues >= BITS_PER_TYPE(dqm->xgmi_sdma_bitmap))
878 + dqm->xgmi_sdma_bitmap = ULLONG_MAX;
879 + else
880 + dqm->xgmi_sdma_bitmap = (BIT_ULL(num_xgmi_sdma_queues) - 1);
881
882 INIT_WORK(&dqm->hw_exception_work, kfd_process_hw_exception);
883
884 diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
885 index fbbe611d4873f..1aec841fda359 100644
886 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
887 +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
888 @@ -5372,10 +5372,6 @@ static int get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc,
889 int x, y;
890 int xorigin = 0, yorigin = 0;
891
892 - position->enable = false;
893 - position->x = 0;
894 - position->y = 0;
895 -
896 if (!crtc || !plane->state->fb)
897 return 0;
898
899 @@ -5427,7 +5423,7 @@ static void handle_cursor_update(struct drm_plane *plane,
900 struct dm_crtc_state *crtc_state = crtc ? to_dm_crtc_state(crtc->state) : NULL;
901 struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
902 uint64_t address = afb ? afb->address : 0;
903 - struct dc_cursor_position position;
904 + struct dc_cursor_position position = {0};
905 struct dc_cursor_attributes attributes;
906 int ret;
907
908 @@ -7330,7 +7326,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
909 }
910
911 #if defined(CONFIG_DRM_AMD_DC_DCN)
912 - if (adev->asic_type >= CHIP_NAVI10) {
913 + if (dc_resource_is_dsc_encoding_supported(dc)) {
914 for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
915 if (drm_atomic_crtc_needs_modeset(new_crtc_state)) {
916 ret = add_affected_mst_dsc_crtcs(state, crtc);
917 diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
918 index 68d56a91d44b7..092db590087c9 100644
919 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c
920 +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
921 @@ -1961,7 +1961,8 @@ static void commit_planes_do_stream_update(struct dc *dc,
922 if (pipe_ctx->stream_res.audio && !dc->debug.az_endpoint_mute_only)
923 pipe_ctx->stream_res.audio->funcs->az_disable(pipe_ctx->stream_res.audio);
924
925 - dc->hwss.optimize_bandwidth(dc, dc->current_state);
926 + dc->optimized_required = true;
927 +
928 } else {
929 if (!dc->optimize_seamless_boot)
930 dc->hwss.prepare_bandwidth(dc, dc->current_state);
931 diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
932 index 6c6c486b774a4..945d23ca36777 100644
933 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
934 +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
935 @@ -3435,6 +3435,7 @@ void dml20_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l
936 mode_lib->vba.DCCEnabledInAnyPlane = true;
937 }
938 }
939 + mode_lib->vba.UrgentLatency = mode_lib->vba.UrgentLatencyPixelDataOnly;
940 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
941 locals->FabricAndDRAMBandwidthPerState[i] = dml_min(
942 mode_lib->vba.DRAMSpeedPerState[i] * mode_lib->vba.NumberOfChannels
943 diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
944 index 0fafd693ffb41..5b5ed1be19bad 100644
945 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
946 +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
947 @@ -3467,6 +3467,7 @@ void dml20v2_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode
948 mode_lib->vba.DCCEnabledInAnyPlane = true;
949 }
950 }
951 + mode_lib->vba.UrgentLatency = mode_lib->vba.UrgentLatencyPixelDataOnly;
952 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
953 locals->FabricAndDRAMBandwidthPerState[i] = dml_min(
954 mode_lib->vba.DRAMSpeedPerState[i] * mode_lib->vba.NumberOfChannels
955 diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c b/drivers/gpu/drm/drm_panel_orientation_quirks.c
956 index 58f5dc2f6dd52..f6bdec7fa9253 100644
957 --- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
958 +++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
959 @@ -84,6 +84,13 @@ static const struct drm_dmi_panel_orientation_data itworks_tw891 = {
960 .orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
961 };
962
963 +static const struct drm_dmi_panel_orientation_data onegx1_pro = {
964 + .width = 1200,
965 + .height = 1920,
966 + .bios_dates = (const char * const []){ "12/17/2020", NULL },
967 + .orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
968 +};
969 +
970 static const struct drm_dmi_panel_orientation_data lcd720x1280_rightside_up = {
971 .width = 720,
972 .height = 1280,
973 @@ -211,6 +218,13 @@ static const struct dmi_system_id orientation_data[] = {
974 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad D330-10IGM"),
975 },
976 .driver_data = (void *)&lcd1200x1920_rightside_up,
977 + }, { /* OneGX1 Pro */
978 + .matches = {
979 + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "SYSTEM_MANUFACTURER"),
980 + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "SYSTEM_PRODUCT_NAME"),
981 + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Default string"),
982 + },
983 + .driver_data = (void *)&onegx1_pro,
984 }, { /* VIOS LTH17 */
985 .matches = {
986 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "VIOS"),
987 diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
988 index ade607d93e45d..91afeca0c6f82 100644
989 --- a/drivers/gpu/drm/i915/intel_pm.c
990 +++ b/drivers/gpu/drm/i915/intel_pm.c
991 @@ -2966,7 +2966,7 @@ int ilk_wm_max_level(const struct drm_i915_private *dev_priv)
992
993 static void intel_print_wm_latency(struct drm_i915_private *dev_priv,
994 const char *name,
995 - const u16 wm[8])
996 + const u16 wm[])
997 {
998 int level, max_level = ilk_wm_max_level(dev_priv);
999
1000 diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_cmd_encoder.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_cmd_encoder.c
1001 index eeef41fcd4e1a..0425400f44db9 100644
1002 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_cmd_encoder.c
1003 +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_cmd_encoder.c
1004 @@ -41,7 +41,7 @@ static int pingpong_tearcheck_setup(struct drm_encoder *encoder,
1005 {
1006 struct mdp5_kms *mdp5_kms = get_kms(encoder);
1007 struct device *dev = encoder->dev->dev;
1008 - u32 total_lines_x100, vclks_line, cfg;
1009 + u32 total_lines, vclks_line, cfg;
1010 long vsync_clk_speed;
1011 struct mdp5_hw_mixer *mixer = mdp5_crtc_get_mixer(encoder->crtc);
1012 int pp_id = mixer->pp;
1013 @@ -51,8 +51,8 @@ static int pingpong_tearcheck_setup(struct drm_encoder *encoder,
1014 return -EINVAL;
1015 }
1016
1017 - total_lines_x100 = mode->vtotal * drm_mode_vrefresh(mode);
1018 - if (!total_lines_x100) {
1019 + total_lines = mode->vtotal * drm_mode_vrefresh(mode);
1020 + if (!total_lines) {
1021 DRM_DEV_ERROR(dev, "%s: vtotal(%d) or vrefresh(%d) is 0\n",
1022 __func__, mode->vtotal, drm_mode_vrefresh(mode));
1023 return -EINVAL;
1024 @@ -64,15 +64,23 @@ static int pingpong_tearcheck_setup(struct drm_encoder *encoder,
1025 vsync_clk_speed);
1026 return -EINVAL;
1027 }
1028 - vclks_line = vsync_clk_speed * 100 / total_lines_x100;
1029 + vclks_line = vsync_clk_speed / total_lines;
1030
1031 cfg = MDP5_PP_SYNC_CONFIG_VSYNC_COUNTER_EN
1032 | MDP5_PP_SYNC_CONFIG_VSYNC_IN_EN;
1033 cfg |= MDP5_PP_SYNC_CONFIG_VSYNC_COUNT(vclks_line);
1034
1035 + /*
1036 + * Tearcheck emits a blanking signal every vclks_line * vtotal * 2 ticks on
1037 + * the vsync_clk equating to roughly half the desired panel refresh rate.
1038 + * This is only necessary as stability fallback if interrupts from the
1039 + * panel arrive too late or not at all, but is currently used by default
1040 + * because these panel interrupts are not wired up yet.
1041 + */
1042 mdp5_write(mdp5_kms, REG_MDP5_PP_SYNC_CONFIG_VSYNC(pp_id), cfg);
1043 mdp5_write(mdp5_kms,
1044 - REG_MDP5_PP_SYNC_CONFIG_HEIGHT(pp_id), 0xfff0);
1045 + REG_MDP5_PP_SYNC_CONFIG_HEIGHT(pp_id), (2 * mode->vtotal));
1046 +
1047 mdp5_write(mdp5_kms,
1048 REG_MDP5_PP_VSYNC_INIT_VAL(pp_id), mode->vdisplay);
1049 mdp5_write(mdp5_kms, REG_MDP5_PP_RD_PTR_IRQ(pp_id), mode->vdisplay + 1);
1050 diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
1051 index 9abf3dc5ef990..a6ee10cbcfdd6 100644
1052 --- a/drivers/gpu/drm/qxl/qxl_display.c
1053 +++ b/drivers/gpu/drm/qxl/qxl_display.c
1054 @@ -1237,6 +1237,10 @@ int qxl_modeset_init(struct qxl_device *qdev)
1055
1056 void qxl_modeset_fini(struct qxl_device *qdev)
1057 {
1058 + if (qdev->dumb_shadow_bo) {
1059 + drm_gem_object_put(&qdev->dumb_shadow_bo->tbo.base);
1060 + qdev->dumb_shadow_bo = NULL;
1061 + }
1062 qxl_destroy_monitors_object(qdev);
1063 drm_mode_config_cleanup(&qdev->ddev);
1064 }
1065 diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
1066 index 927dafaebc766..8b01fae65f43b 100644
1067 --- a/drivers/gpu/drm/vkms/vkms_crtc.c
1068 +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
1069 @@ -20,7 +20,8 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer)
1070
1071 ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer,
1072 output->period_ns);
1073 - WARN_ON(ret_overrun != 1);
1074 + if (ret_overrun != 1)
1075 + pr_warn("%s: vblank timer overrun\n", __func__);
1076
1077 ret = drm_crtc_handle_vblank(crtc);
1078 if (!ret)
1079 diff --git a/drivers/hwtracing/intel_th/gth.c b/drivers/hwtracing/intel_th/gth.c
1080 index f72803a023910..28509b02a0b56 100644
1081 --- a/drivers/hwtracing/intel_th/gth.c
1082 +++ b/drivers/hwtracing/intel_th/gth.c
1083 @@ -543,7 +543,7 @@ static void intel_th_gth_disable(struct intel_th_device *thdev,
1084 output->active = false;
1085
1086 for_each_set_bit(master, gth->output[output->port].master,
1087 - TH_CONFIGURABLE_MASTERS) {
1088 + TH_CONFIGURABLE_MASTERS + 1) {
1089 gth_master_set(gth, master, -1);
1090 }
1091 spin_unlock(&gth->gth_lock);
1092 @@ -697,7 +697,7 @@ static void intel_th_gth_unassign(struct intel_th_device *thdev,
1093 othdev->output.port = -1;
1094 othdev->output.active = false;
1095 gth->output[port].output = NULL;
1096 - for (master = 0; master <= TH_CONFIGURABLE_MASTERS; master++)
1097 + for (master = 0; master < TH_CONFIGURABLE_MASTERS + 1; master++)
1098 if (gth->master[master] == port)
1099 gth->master[master] = -1;
1100 spin_unlock(&gth->gth_lock);
1101 diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
1102 index d7d99acac52f2..a723c8c330876 100644
1103 --- a/drivers/hwtracing/intel_th/pci.c
1104 +++ b/drivers/hwtracing/intel_th/pci.c
1105 @@ -268,6 +268,16 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
1106 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1bcc),
1107 .driver_data = (kernel_ulong_t)&intel_th_2x,
1108 },
1109 + {
1110 + /* Alder Lake-M */
1111 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x54a6),
1112 + .driver_data = (kernel_ulong_t)&intel_th_2x,
1113 + },
1114 + {
1115 + /* Rocket Lake CPU */
1116 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4c19),
1117 + .driver_data = (kernel_ulong_t)&intel_th_2x,
1118 + },
1119 { 0 },
1120 };
1121
1122 diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
1123 index f4ebdab062806..22839dde1d09f 100644
1124 --- a/drivers/input/touchscreen/ili210x.c
1125 +++ b/drivers/input/touchscreen/ili210x.c
1126 @@ -109,7 +109,7 @@ static bool ili210x_touchdata_to_coords(struct ili210x *priv, u8 *touchdata,
1127 if (finger >= ILI210X_TOUCHES)
1128 return false;
1129
1130 - if (touchdata[0] & BIT(finger))
1131 + if (!(touchdata[0] & BIT(finger)))
1132 return false;
1133
1134 *x = get_unaligned_be16(touchdata + 1 + (finger * 4) + 0);
1135 diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
1136 index 446603efbc90b..9d0b42cb9903e 100644
1137 --- a/drivers/irqchip/irq-gic-v3.c
1138 +++ b/drivers/irqchip/irq-gic-v3.c
1139 @@ -621,6 +621,10 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs
1140
1141 irqnr = gic_read_iar();
1142
1143 + /* Check for special IDs first */
1144 + if ((irqnr >= 1020 && irqnr <= 1023))
1145 + return;
1146 +
1147 if (gic_supports_nmi() &&
1148 unlikely(gic_read_rpr() == GICD_INT_NMI_PRI)) {
1149 gic_handle_nmi(irqnr, regs);
1150 @@ -632,10 +636,6 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs
1151 gic_arch_enable_irqs();
1152 }
1153
1154 - /* Check for special IDs first */
1155 - if ((irqnr >= 1020 && irqnr <= 1023))
1156 - return;
1157 -
1158 /* Treat anything but SGIs in a uniform way */
1159 if (likely(irqnr > 15)) {
1160 int err;
1161 diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
1162 index c967c2cdba870..9f4d657dd36c8 100644
1163 --- a/drivers/md/dm-integrity.c
1164 +++ b/drivers/md/dm-integrity.c
1165 @@ -3762,6 +3762,7 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
1166 if (val >= (uint64_t)UINT_MAX * 1000 / HZ) {
1167 r = -EINVAL;
1168 ti->error = "Invalid bitmap_flush_interval argument";
1169 + goto bad;
1170 }
1171 ic->bitmap_flush_interval = msecs_to_jiffies(val);
1172 } else if (!strncmp(opt_string, "internal_hash:", strlen("internal_hash:"))) {
1173 diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
1174 index 70210a7e4bc80..5e73cc6ad0ce4 100644
1175 --- a/drivers/md/dm-raid.c
1176 +++ b/drivers/md/dm-raid.c
1177 @@ -1892,6 +1892,14 @@ static bool rs_takeover_requested(struct raid_set *rs)
1178 return rs->md.new_level != rs->md.level;
1179 }
1180
1181 +/* True if layout is set to reshape. */
1182 +static bool rs_is_layout_change(struct raid_set *rs, bool use_mddev)
1183 +{
1184 + return (use_mddev ? rs->md.delta_disks : rs->delta_disks) ||
1185 + rs->md.new_layout != rs->md.layout ||
1186 + rs->md.new_chunk_sectors != rs->md.chunk_sectors;
1187 +}
1188 +
1189 /* True if @rs is requested to reshape by ctr */
1190 static bool rs_reshape_requested(struct raid_set *rs)
1191 {
1192 @@ -1904,9 +1912,7 @@ static bool rs_reshape_requested(struct raid_set *rs)
1193 if (rs_is_raid0(rs))
1194 return false;
1195
1196 - change = mddev->new_layout != mddev->layout ||
1197 - mddev->new_chunk_sectors != mddev->chunk_sectors ||
1198 - rs->delta_disks;
1199 + change = rs_is_layout_change(rs, false);
1200
1201 /* Historical case to support raid1 reshape without delta disks */
1202 if (rs_is_raid1(rs)) {
1203 @@ -2843,7 +2849,7 @@ static sector_t _get_reshape_sectors(struct raid_set *rs)
1204 }
1205
1206 /*
1207 - *
1208 + * Reshape:
1209 * - change raid layout
1210 * - change chunk size
1211 * - add disks
1212 @@ -2952,6 +2958,20 @@ static int rs_setup_reshape(struct raid_set *rs)
1213 return r;
1214 }
1215
1216 +/*
1217 + * If the md resync thread has updated superblock with max reshape position
1218 + * at the end of a reshape but not (yet) reset the layout configuration
1219 + * changes -> reset the latter.
1220 + */
1221 +static void rs_reset_inconclusive_reshape(struct raid_set *rs)
1222 +{
1223 + if (!rs_is_reshaping(rs) && rs_is_layout_change(rs, true)) {
1224 + rs_set_cur(rs);
1225 + rs->md.delta_disks = 0;
1226 + rs->md.reshape_backwards = 0;
1227 + }
1228 +}
1229 +
1230 /*
1231 * Enable/disable discard support on RAID set depending on
1232 * RAID level and discard properties of underlying RAID members.
1233 @@ -3216,11 +3236,14 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1234 if (r)
1235 goto bad;
1236
1237 + /* Catch any inconclusive reshape superblock content. */
1238 + rs_reset_inconclusive_reshape(rs);
1239 +
1240 /* Start raid set read-only and assumed clean to change in raid_resume() */
1241 rs->md.ro = 1;
1242 rs->md.in_sync = 1;
1243
1244 - /* Keep array frozen */
1245 + /* Keep array frozen until resume. */
1246 set_bit(MD_RECOVERY_FROZEN, &rs->md.recovery);
1247
1248 /* Has to be held on running the array */
1249 @@ -3234,7 +3257,6 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1250 }
1251
1252 r = md_start(&rs->md);
1253 -
1254 if (r) {
1255 ti->error = "Failed to start raid array";
1256 mddev_unlock(&rs->md);
1257 diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
1258 index 2bd2444ad99c6..6bc61927d3205 100644
1259 --- a/drivers/md/dm-rq.c
1260 +++ b/drivers/md/dm-rq.c
1261 @@ -572,6 +572,7 @@ out_tag_set:
1262 blk_mq_free_tag_set(md->tag_set);
1263 out_kfree_tag_set:
1264 kfree(md->tag_set);
1265 + md->tag_set = NULL;
1266
1267 return err;
1268 }
1269 @@ -581,6 +582,7 @@ void dm_mq_cleanup_mapped_device(struct mapped_device *md)
1270 if (md->tag_set) {
1271 blk_mq_free_tag_set(md->tag_set);
1272 kfree(md->tag_set);
1273 + md->tag_set = NULL;
1274 }
1275 }
1276
1277 diff --git a/drivers/md/persistent-data/dm-btree-internal.h b/drivers/md/persistent-data/dm-btree-internal.h
1278 index a240990a7f333..5673f8eb5f88f 100644
1279 --- a/drivers/md/persistent-data/dm-btree-internal.h
1280 +++ b/drivers/md/persistent-data/dm-btree-internal.h
1281 @@ -34,12 +34,12 @@ struct node_header {
1282 __le32 max_entries;
1283 __le32 value_size;
1284 __le32 padding;
1285 -} __packed;
1286 +} __attribute__((packed, aligned(8)));
1287
1288 struct btree_node {
1289 struct node_header header;
1290 __le64 keys[0];
1291 -} __packed;
1292 +} __attribute__((packed, aligned(8)));
1293
1294
1295 /*
1296 diff --git a/drivers/md/persistent-data/dm-space-map-common.c b/drivers/md/persistent-data/dm-space-map-common.c
1297 index d8b4125e338ca..a213bf11738fb 100644
1298 --- a/drivers/md/persistent-data/dm-space-map-common.c
1299 +++ b/drivers/md/persistent-data/dm-space-map-common.c
1300 @@ -339,6 +339,8 @@ int sm_ll_find_free_block(struct ll_disk *ll, dm_block_t begin,
1301 */
1302 begin = do_div(index_begin, ll->entries_per_block);
1303 end = do_div(end, ll->entries_per_block);
1304 + if (end == 0)
1305 + end = ll->entries_per_block;
1306
1307 for (i = index_begin; i < index_end; i++, begin = 0) {
1308 struct dm_block *blk;
1309 diff --git a/drivers/md/persistent-data/dm-space-map-common.h b/drivers/md/persistent-data/dm-space-map-common.h
1310 index 8de63ce39bdd5..87e17909ef521 100644
1311 --- a/drivers/md/persistent-data/dm-space-map-common.h
1312 +++ b/drivers/md/persistent-data/dm-space-map-common.h
1313 @@ -33,7 +33,7 @@ struct disk_index_entry {
1314 __le64 blocknr;
1315 __le32 nr_free;
1316 __le32 none_free_before;
1317 -} __packed;
1318 +} __attribute__ ((packed, aligned(8)));
1319
1320
1321 #define MAX_METADATA_BITMAPS 255
1322 @@ -43,7 +43,7 @@ struct disk_metadata_index {
1323 __le64 blocknr;
1324
1325 struct disk_index_entry index[MAX_METADATA_BITMAPS];
1326 -} __packed;
1327 +} __attribute__ ((packed, aligned(8)));
1328
1329 struct ll_disk;
1330
1331 @@ -86,7 +86,7 @@ struct disk_sm_root {
1332 __le64 nr_allocated;
1333 __le64 bitmap_root;
1334 __le64 ref_count_root;
1335 -} __packed;
1336 +} __attribute__ ((packed, aligned(8)));
1337
1338 #define ENTRIES_PER_BYTE 4
1339
1340 @@ -94,7 +94,7 @@ struct disk_bitmap_header {
1341 __le32 csum;
1342 __le32 not_used;
1343 __le64 blocknr;
1344 -} __packed;
1345 +} __attribute__ ((packed, aligned(8)));
1346
1347 enum allocation_event {
1348 SM_NONE,
1349 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
1350 index c7137f50bd1d3..a715cb88052c2 100644
1351 --- a/drivers/md/raid1.c
1352 +++ b/drivers/md/raid1.c
1353 @@ -458,6 +458,8 @@ static void raid1_end_write_request(struct bio *bio)
1354 if (!test_bit(Faulty, &rdev->flags))
1355 set_bit(R1BIO_WriteError, &r1_bio->state);
1356 else {
1357 + /* Fail the request */
1358 + set_bit(R1BIO_Degraded, &r1_bio->state);
1359 /* Finished with this branch */
1360 r1_bio->bios[mirror] = NULL;
1361 to_put = bio;
1362 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
1363 index 032b6d7dd5821..197cf17b246f7 100644
1364 --- a/drivers/media/dvb-core/dvbdev.c
1365 +++ b/drivers/media/dvb-core/dvbdev.c
1366 @@ -241,6 +241,7 @@ static void dvb_media_device_free(struct dvb_device *dvbdev)
1367
1368 if (dvbdev->adapter->conn) {
1369 media_device_unregister_entity(dvbdev->adapter->conn);
1370 + kfree(dvbdev->adapter->conn);
1371 dvbdev->adapter->conn = NULL;
1372 kfree(dvbdev->adapter->conn_pads);
1373 dvbdev->adapter->conn_pads = NULL;
1374 diff --git a/drivers/media/i2c/adv7511-v4l2.c b/drivers/media/i2c/adv7511-v4l2.c
1375 index 62763ec4cd073..809fa44ed9880 100644
1376 --- a/drivers/media/i2c/adv7511-v4l2.c
1377 +++ b/drivers/media/i2c/adv7511-v4l2.c
1378 @@ -1964,7 +1964,7 @@ static int adv7511_remove(struct i2c_client *client)
1379
1380 adv7511_set_isr(sd, false);
1381 adv7511_init_setup(sd);
1382 - cancel_delayed_work(&state->edid_handler);
1383 + cancel_delayed_work_sync(&state->edid_handler);
1384 i2c_unregister_device(state->i2c_edid);
1385 i2c_unregister_device(state->i2c_cec);
1386 i2c_unregister_device(state->i2c_pktmem);
1387 diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
1388 index 2dedd6ebb2361..b887299ac195f 100644
1389 --- a/drivers/media/i2c/adv7604.c
1390 +++ b/drivers/media/i2c/adv7604.c
1391 @@ -3606,7 +3606,7 @@ static int adv76xx_remove(struct i2c_client *client)
1392 io_write(sd, 0x6e, 0);
1393 io_write(sd, 0x73, 0);
1394
1395 - cancel_delayed_work(&state->delayed_work_enable_hotplug);
1396 + cancel_delayed_work_sync(&state->delayed_work_enable_hotplug);
1397 v4l2_async_unregister_subdev(sd);
1398 media_entity_cleanup(&sd->entity);
1399 adv76xx_unregister_clients(to_state(sd));
1400 diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
1401 index 885619841719b..02cbab826d0b6 100644
1402 --- a/drivers/media/i2c/adv7842.c
1403 +++ b/drivers/media/i2c/adv7842.c
1404 @@ -3586,7 +3586,7 @@ static int adv7842_remove(struct i2c_client *client)
1405 struct adv7842_state *state = to_state(sd);
1406
1407 adv7842_irq_enable(sd, false);
1408 - cancel_delayed_work(&state->delayed_work_enable_hotplug);
1409 + cancel_delayed_work_sync(&state->delayed_work_enable_hotplug);
1410 v4l2_device_unregister_subdev(sd);
1411 media_entity_cleanup(&sd->entity);
1412 adv7842_unregister_clients(sd);
1413 diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
1414 index cff99cf61ed4d..114c084c4aec1 100644
1415 --- a/drivers/media/i2c/tc358743.c
1416 +++ b/drivers/media/i2c/tc358743.c
1417 @@ -2192,7 +2192,7 @@ static int tc358743_remove(struct i2c_client *client)
1418 del_timer_sync(&state->timer);
1419 flush_work(&state->work_i2c_poll);
1420 }
1421 - cancel_delayed_work(&state->delayed_work_enable_hotplug);
1422 + cancel_delayed_work_sync(&state->delayed_work_enable_hotplug);
1423 cec_unregister_adapter(state->cec_adap);
1424 v4l2_async_unregister_subdev(sd);
1425 v4l2_device_unregister_subdev(sd);
1426 diff --git a/drivers/media/i2c/tda1997x.c b/drivers/media/i2c/tda1997x.c
1427 index 5e68182001ecc..e43d8327b8103 100644
1428 --- a/drivers/media/i2c/tda1997x.c
1429 +++ b/drivers/media/i2c/tda1997x.c
1430 @@ -2804,7 +2804,7 @@ static int tda1997x_remove(struct i2c_client *client)
1431 media_entity_cleanup(&sd->entity);
1432 v4l2_ctrl_handler_free(&state->hdl);
1433 regulator_bulk_disable(TDA1997X_NUM_SUPPLIES, state->supplies);
1434 - cancel_delayed_work(&state->delayed_work_enable_hpd);
1435 + cancel_delayed_work_sync(&state->delayed_work_enable_hpd);
1436 mutex_destroy(&state->page_lock);
1437 mutex_destroy(&state->lock);
1438
1439 diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c
1440 index 3fca7257a7201..df494644b5b64 100644
1441 --- a/drivers/media/pci/saa7164/saa7164-encoder.c
1442 +++ b/drivers/media/pci/saa7164/saa7164-encoder.c
1443 @@ -1008,7 +1008,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
1444 printk(KERN_ERR "%s() failed (errno = %d), NO PCI configuration\n",
1445 __func__, result);
1446 result = -ENOMEM;
1447 - goto failed;
1448 + goto fail_pci;
1449 }
1450
1451 /* Establish encoder defaults here */
1452 @@ -1062,7 +1062,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
1453 100000, ENCODER_DEF_BITRATE);
1454 if (hdl->error) {
1455 result = hdl->error;
1456 - goto failed;
1457 + goto fail_hdl;
1458 }
1459
1460 port->std = V4L2_STD_NTSC_M;
1461 @@ -1080,7 +1080,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
1462 printk(KERN_INFO "%s: can't allocate mpeg device\n",
1463 dev->name);
1464 result = -ENOMEM;
1465 - goto failed;
1466 + goto fail_hdl;
1467 }
1468
1469 port->v4l_device->ctrl_handler = hdl;
1470 @@ -1091,10 +1091,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
1471 if (result < 0) {
1472 printk(KERN_INFO "%s: can't register mpeg device\n",
1473 dev->name);
1474 - /* TODO: We're going to leak here if we don't dealloc
1475 - The buffers above. The unreg function can't deal wit it.
1476 - */
1477 - goto failed;
1478 + goto fail_reg;
1479 }
1480
1481 printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
1482 @@ -1116,9 +1113,14 @@ int saa7164_encoder_register(struct saa7164_port *port)
1483
1484 saa7164_api_set_encoder(port);
1485 saa7164_api_get_encoder(port);
1486 + return 0;
1487
1488 - result = 0;
1489 -failed:
1490 +fail_reg:
1491 + video_device_release(port->v4l_device);
1492 + port->v4l_device = NULL;
1493 +fail_hdl:
1494 + v4l2_ctrl_handler_free(hdl);
1495 +fail_pci:
1496 return result;
1497 }
1498
1499 diff --git a/drivers/media/pci/sta2x11/Kconfig b/drivers/media/pci/sta2x11/Kconfig
1500 index 011b766f0bffd..d613feee81767 100644
1501 --- a/drivers/media/pci/sta2x11/Kconfig
1502 +++ b/drivers/media/pci/sta2x11/Kconfig
1503 @@ -2,6 +2,7 @@
1504 config STA2X11_VIP
1505 tristate "STA2X11 VIP Video For Linux"
1506 depends on STA2X11 || COMPILE_TEST
1507 + select GPIOLIB if MEDIA_SUBDRV_AUTOSELECT
1508 select VIDEO_ADV7180 if MEDIA_SUBDRV_AUTOSELECT
1509 select VIDEOBUF2_DMA_CONTIG
1510 depends on PCI && VIDEO_V4L2 && VIRT_TO_BUS
1511 diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c b/drivers/media/platform/sti/bdisp/bdisp-debug.c
1512 index 77ca7517fa3e2..bae62af826434 100644
1513 --- a/drivers/media/platform/sti/bdisp/bdisp-debug.c
1514 +++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
1515 @@ -480,7 +480,7 @@ static int regs_show(struct seq_file *s, void *data)
1516 int ret;
1517 unsigned int i;
1518
1519 - ret = pm_runtime_get_sync(bdisp->dev);
1520 + ret = pm_runtime_resume_and_get(bdisp->dev);
1521 if (ret < 0) {
1522 seq_puts(s, "Cannot wake up IP\n");
1523 return 0;
1524 diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c
1525 index f6a5cdbd74e74..cc71aa4255972 100644
1526 --- a/drivers/media/platform/vivid/vivid-core.c
1527 +++ b/drivers/media/platform/vivid/vivid-core.c
1528 @@ -174,13 +174,13 @@ static const u8 vivid_hdmi_edid[256] = {
1529 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1530 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x7b,
1531
1532 - 0x02, 0x03, 0x3f, 0xf0, 0x51, 0x61, 0x60, 0x5f,
1533 + 0x02, 0x03, 0x3f, 0xf1, 0x51, 0x61, 0x60, 0x5f,
1534 0x5e, 0x5d, 0x10, 0x1f, 0x04, 0x13, 0x22, 0x21,
1535 0x20, 0x05, 0x14, 0x02, 0x11, 0x01, 0x23, 0x09,
1536 0x07, 0x07, 0x83, 0x01, 0x00, 0x00, 0x6d, 0x03,
1537 0x0c, 0x00, 0x10, 0x00, 0x00, 0x3c, 0x21, 0x00,
1538 0x60, 0x01, 0x02, 0x03, 0x67, 0xd8, 0x5d, 0xc4,
1539 - 0x01, 0x78, 0x00, 0x00, 0xe2, 0x00, 0xea, 0xe3,
1540 + 0x01, 0x78, 0x00, 0x00, 0xe2, 0x00, 0xca, 0xe3,
1541 0x05, 0x00, 0x00, 0xe3, 0x06, 0x01, 0x00, 0x4d,
1542 0xd0, 0x00, 0xa0, 0xf0, 0x70, 0x3e, 0x80, 0x30,
1543 0x20, 0x35, 0x00, 0xc0, 0x1c, 0x32, 0x00, 0x00,
1544 @@ -189,7 +189,7 @@ static const u8 vivid_hdmi_edid[256] = {
1545 0x00, 0x00, 0x1a, 0x1a, 0x1d, 0x00, 0x80, 0x51,
1546 0xd0, 0x1c, 0x20, 0x40, 0x80, 0x35, 0x00, 0xc0,
1547 0x1c, 0x32, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
1548 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63,
1549 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82,
1550 };
1551
1552 static int vidioc_querycap(struct file *file, void *priv,
1553 diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
1554 index 3ab6cec0dc3bc..4b8aee390518d 100644
1555 --- a/drivers/media/rc/ite-cir.c
1556 +++ b/drivers/media/rc/ite-cir.c
1557 @@ -276,8 +276,14 @@ static irqreturn_t ite_cir_isr(int irq, void *data)
1558 /* read the interrupt flags */
1559 iflags = dev->params.get_irq_causes(dev);
1560
1561 + /* Check for RX overflow */
1562 + if (iflags & ITE_IRQ_RX_FIFO_OVERRUN) {
1563 + dev_warn(&dev->rdev->dev, "receive overflow\n");
1564 + ir_raw_event_reset(dev->rdev);
1565 + }
1566 +
1567 /* check for the receive interrupt */
1568 - if (iflags & (ITE_IRQ_RX_FIFO | ITE_IRQ_RX_FIFO_OVERRUN)) {
1569 + if (iflags & ITE_IRQ_RX_FIFO) {
1570 /* read the FIFO bytes */
1571 rx_bytes =
1572 dev->params.get_rx_bytes(dev, rx_buf,
1573 diff --git a/drivers/media/usb/dvb-usb/dvb-usb-init.c b/drivers/media/usb/dvb-usb/dvb-usb-init.c
1574 index 16a0b4a359eac..f57c4627624f5 100644
1575 --- a/drivers/media/usb/dvb-usb/dvb-usb-init.c
1576 +++ b/drivers/media/usb/dvb-usb/dvb-usb-init.c
1577 @@ -79,11 +79,17 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d, short *adapter_nrs)
1578 }
1579 }
1580
1581 - if ((ret = dvb_usb_adapter_stream_init(adap)) ||
1582 - (ret = dvb_usb_adapter_dvb_init(adap, adapter_nrs)) ||
1583 - (ret = dvb_usb_adapter_frontend_init(adap))) {
1584 + ret = dvb_usb_adapter_stream_init(adap);
1585 + if (ret)
1586 return ret;
1587 - }
1588 +
1589 + ret = dvb_usb_adapter_dvb_init(adap, adapter_nrs);
1590 + if (ret)
1591 + goto dvb_init_err;
1592 +
1593 + ret = dvb_usb_adapter_frontend_init(adap);
1594 + if (ret)
1595 + goto frontend_init_err;
1596
1597 /* use exclusive FE lock if there is multiple shared FEs */
1598 if (adap->fe_adap[1].fe)
1599 @@ -103,6 +109,12 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d, short *adapter_nrs)
1600 }
1601
1602 return 0;
1603 +
1604 +frontend_init_err:
1605 + dvb_usb_adapter_dvb_exit(adap);
1606 +dvb_init_err:
1607 + dvb_usb_adapter_stream_exit(adap);
1608 + return ret;
1609 }
1610
1611 static int dvb_usb_adapter_exit(struct dvb_usb_device *d)
1612 @@ -158,22 +170,20 @@ static int dvb_usb_init(struct dvb_usb_device *d, short *adapter_nums)
1613
1614 if (d->props.priv_init != NULL) {
1615 ret = d->props.priv_init(d);
1616 - if (ret != 0) {
1617 - kfree(d->priv);
1618 - d->priv = NULL;
1619 - return ret;
1620 - }
1621 + if (ret != 0)
1622 + goto err_priv_init;
1623 }
1624 }
1625
1626 /* check the capabilities and set appropriate variables */
1627 dvb_usb_device_power_ctrl(d, 1);
1628
1629 - if ((ret = dvb_usb_i2c_init(d)) ||
1630 - (ret = dvb_usb_adapter_init(d, adapter_nums))) {
1631 - dvb_usb_exit(d);
1632 - return ret;
1633 - }
1634 + ret = dvb_usb_i2c_init(d);
1635 + if (ret)
1636 + goto err_i2c_init;
1637 + ret = dvb_usb_adapter_init(d, adapter_nums);
1638 + if (ret)
1639 + goto err_adapter_init;
1640
1641 if ((ret = dvb_usb_remote_init(d)))
1642 err("could not initialize remote control.");
1643 @@ -181,6 +191,17 @@ static int dvb_usb_init(struct dvb_usb_device *d, short *adapter_nums)
1644 dvb_usb_device_power_ctrl(d, 0);
1645
1646 return 0;
1647 +
1648 +err_adapter_init:
1649 + dvb_usb_adapter_exit(d);
1650 +err_i2c_init:
1651 + dvb_usb_i2c_exit(d);
1652 + if (d->priv && d->props.priv_destroy)
1653 + d->props.priv_destroy(d);
1654 +err_priv_init:
1655 + kfree(d->priv);
1656 + d->priv = NULL;
1657 + return ret;
1658 }
1659
1660 /* determine the name and the state of the just found USB device */
1661 @@ -255,41 +276,50 @@ int dvb_usb_device_init(struct usb_interface *intf,
1662 if (du != NULL)
1663 *du = NULL;
1664
1665 - if ((desc = dvb_usb_find_device(udev, props, &cold)) == NULL) {
1666 + d = kzalloc(sizeof(*d), GFP_KERNEL);
1667 + if (!d) {
1668 + err("no memory for 'struct dvb_usb_device'");
1669 + return -ENOMEM;
1670 + }
1671 +
1672 + memcpy(&d->props, props, sizeof(struct dvb_usb_device_properties));
1673 +
1674 + desc = dvb_usb_find_device(udev, &d->props, &cold);
1675 + if (!desc) {
1676 deb_err("something went very wrong, device was not found in current device list - let's see what comes next.\n");
1677 - return -ENODEV;
1678 + ret = -ENODEV;
1679 + goto error;
1680 }
1681
1682 if (cold) {
1683 info("found a '%s' in cold state, will try to load a firmware", desc->name);
1684 ret = dvb_usb_download_firmware(udev, props);
1685 if (!props->no_reconnect || ret != 0)
1686 - return ret;
1687 + goto error;
1688 }
1689
1690 info("found a '%s' in warm state.", desc->name);
1691 - d = kzalloc(sizeof(struct dvb_usb_device), GFP_KERNEL);
1692 - if (d == NULL) {
1693 - err("no memory for 'struct dvb_usb_device'");
1694 - return -ENOMEM;
1695 - }
1696 -
1697 d->udev = udev;
1698 - memcpy(&d->props, props, sizeof(struct dvb_usb_device_properties));
1699 d->desc = desc;
1700 d->owner = owner;
1701
1702 usb_set_intfdata(intf, d);
1703
1704 - if (du != NULL)
1705 + ret = dvb_usb_init(d, adapter_nums);
1706 + if (ret) {
1707 + info("%s error while loading driver (%d)", desc->name, ret);
1708 + goto error;
1709 + }
1710 +
1711 + if (du)
1712 *du = d;
1713
1714 - ret = dvb_usb_init(d, adapter_nums);
1715 + info("%s successfully initialized and connected.", desc->name);
1716 + return 0;
1717
1718 - if (ret == 0)
1719 - info("%s successfully initialized and connected.", desc->name);
1720 - else
1721 - info("%s error while loading driver (%d)", desc->name, ret);
1722 + error:
1723 + usb_set_intfdata(intf, NULL);
1724 + kfree(d);
1725 return ret;
1726 }
1727 EXPORT_SYMBOL(dvb_usb_device_init);
1728 diff --git a/drivers/media/usb/dvb-usb/dvb-usb.h b/drivers/media/usb/dvb-usb/dvb-usb.h
1729 index 2eb0e24e89434..20830b365f39e 100644
1730 --- a/drivers/media/usb/dvb-usb/dvb-usb.h
1731 +++ b/drivers/media/usb/dvb-usb/dvb-usb.h
1732 @@ -485,7 +485,7 @@ extern int __must_check
1733 dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16);
1734
1735 /* commonly used remote control parsing */
1736 -extern int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, int *);
1737 +extern int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *, u8[5], u32 *, int *);
1738
1739 /* commonly used firmware download types and function */
1740 struct hexline {
1741 diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
1742 index a73faf12f7e47..e1946237ac8cd 100644
1743 --- a/drivers/media/usb/em28xx/em28xx-dvb.c
1744 +++ b/drivers/media/usb/em28xx/em28xx-dvb.c
1745 @@ -1924,6 +1924,7 @@ ret:
1746 return result;
1747
1748 out_free:
1749 + em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE);
1750 kfree(dvb);
1751 dev->dvb = NULL;
1752 goto ret;
1753 diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
1754 index 4210826cc9106..e4d78e676e74a 100644
1755 --- a/drivers/media/usb/gspca/gspca.c
1756 +++ b/drivers/media/usb/gspca/gspca.c
1757 @@ -1576,6 +1576,8 @@ out:
1758 #endif
1759 v4l2_ctrl_handler_free(gspca_dev->vdev.ctrl_handler);
1760 v4l2_device_unregister(&gspca_dev->v4l2_dev);
1761 + if (sd_desc->probe_error)
1762 + sd_desc->probe_error(gspca_dev);
1763 kfree(gspca_dev->usb_buf);
1764 kfree(gspca_dev);
1765 return ret;
1766 diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h
1767 index b0ced2e140064..a6554d5e9e1a5 100644
1768 --- a/drivers/media/usb/gspca/gspca.h
1769 +++ b/drivers/media/usb/gspca/gspca.h
1770 @@ -105,6 +105,7 @@ struct sd_desc {
1771 cam_cf_op config; /* called on probe */
1772 cam_op init; /* called on probe and resume */
1773 cam_op init_controls; /* called on probe */
1774 + cam_v_op probe_error; /* called if probe failed, do cleanup here */
1775 cam_op start; /* called on stream on after URBs creation */
1776 cam_pkt_op pkt_scan;
1777 /* optional operations */
1778 diff --git a/drivers/media/usb/gspca/sq905.c b/drivers/media/usb/gspca/sq905.c
1779 index 863c485f42753..65a74060986a7 100644
1780 --- a/drivers/media/usb/gspca/sq905.c
1781 +++ b/drivers/media/usb/gspca/sq905.c
1782 @@ -158,7 +158,7 @@ static int
1783 sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, int size, int need_lock)
1784 {
1785 int ret;
1786 - int act_len;
1787 + int act_len = 0;
1788
1789 gspca_dev->usb_buf[0] = '\0';
1790 if (need_lock)
1791 diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx.c b/drivers/media/usb/gspca/stv06xx/stv06xx.c
1792 index 95673fc0a99c5..d9bc2aacc8851 100644
1793 --- a/drivers/media/usb/gspca/stv06xx/stv06xx.c
1794 +++ b/drivers/media/usb/gspca/stv06xx/stv06xx.c
1795 @@ -529,12 +529,21 @@ static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
1796 static int stv06xx_config(struct gspca_dev *gspca_dev,
1797 const struct usb_device_id *id);
1798
1799 +static void stv06xx_probe_error(struct gspca_dev *gspca_dev)
1800 +{
1801 + struct sd *sd = (struct sd *)gspca_dev;
1802 +
1803 + kfree(sd->sensor_priv);
1804 + sd->sensor_priv = NULL;
1805 +}
1806 +
1807 /* sub-driver description */
1808 static const struct sd_desc sd_desc = {
1809 .name = MODULE_NAME,
1810 .config = stv06xx_config,
1811 .init = stv06xx_init,
1812 .init_controls = stv06xx_init_controls,
1813 + .probe_error = stv06xx_probe_error,
1814 .start = stv06xx_start,
1815 .stopN = stv06xx_stopN,
1816 .pkt_scan = stv06xx_pkt_scan,
1817 diff --git a/drivers/mfd/arizona-irq.c b/drivers/mfd/arizona-irq.c
1818 index 077d9ab112b71..d919ae9691e23 100644
1819 --- a/drivers/mfd/arizona-irq.c
1820 +++ b/drivers/mfd/arizona-irq.c
1821 @@ -100,7 +100,7 @@ static irqreturn_t arizona_irq_thread(int irq, void *data)
1822 unsigned int val;
1823 int ret;
1824
1825 - ret = pm_runtime_get_sync(arizona->dev);
1826 + ret = pm_runtime_resume_and_get(arizona->dev);
1827 if (ret < 0) {
1828 dev_err(arizona->dev, "Failed to resume device: %d\n", ret);
1829 return IRQ_NONE;
1830 diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
1831 index 63e838ec8af84..39f2864455a60 100644
1832 --- a/drivers/mmc/core/block.c
1833 +++ b/drivers/mmc/core/block.c
1834 @@ -621,6 +621,18 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
1835 main_md->part_curr = value & EXT_CSD_PART_CONFIG_ACC_MASK;
1836 }
1837
1838 + /*
1839 + * Make sure to update CACHE_CTRL in case it was changed. The cache
1840 + * will get turned back on if the card is re-initialized, e.g.
1841 + * suspend/resume or hw reset in recovery.
1842 + */
1843 + if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_CACHE_CTRL) &&
1844 + (cmd.opcode == MMC_SWITCH)) {
1845 + u8 value = MMC_EXTRACT_VALUE_FROM_ARG(cmd.arg) & 1;
1846 +
1847 + card->ext_csd.cache_ctrl = value;
1848 + }
1849 +
1850 /*
1851 * According to the SD specs, some commands require a delay after
1852 * issuing the command.
1853 @@ -2215,6 +2227,10 @@ enum mmc_issued mmc_blk_mq_issue_rq(struct mmc_queue *mq, struct request *req)
1854 case MMC_ISSUE_ASYNC:
1855 switch (req_op(req)) {
1856 case REQ_OP_FLUSH:
1857 + if (!mmc_cache_enabled(host)) {
1858 + blk_mq_end_request(req, BLK_STS_OK);
1859 + return MMC_REQ_FINISHED;
1860 + }
1861 ret = mmc_blk_cqe_issue_flush(mq, req);
1862 break;
1863 case REQ_OP_READ:
1864 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
1865 index 26644b7ec13e3..460a456bcdd20 100644
1866 --- a/drivers/mmc/core/core.c
1867 +++ b/drivers/mmc/core/core.c
1868 @@ -1221,7 +1221,7 @@ int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr)
1869
1870 err = mmc_wait_for_cmd(host, &cmd, 0);
1871 if (err)
1872 - return err;
1873 + goto power_cycle;
1874
1875 if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR))
1876 return -EIO;
1877 @@ -2392,80 +2392,6 @@ void mmc_stop_host(struct mmc_host *host)
1878 mmc_release_host(host);
1879 }
1880
1881 -#ifdef CONFIG_PM_SLEEP
1882 -/* Do the card removal on suspend if card is assumed removeable
1883 - * Do that in pm notifier while userspace isn't yet frozen, so we will be able
1884 - to sync the card.
1885 -*/
1886 -static int mmc_pm_notify(struct notifier_block *notify_block,
1887 - unsigned long mode, void *unused)
1888 -{
1889 - struct mmc_host *host = container_of(
1890 - notify_block, struct mmc_host, pm_notify);
1891 - unsigned long flags;
1892 - int err = 0;
1893 -
1894 - switch (mode) {
1895 - case PM_HIBERNATION_PREPARE:
1896 - case PM_SUSPEND_PREPARE:
1897 - case PM_RESTORE_PREPARE:
1898 - spin_lock_irqsave(&host->lock, flags);
1899 - host->rescan_disable = 1;
1900 - spin_unlock_irqrestore(&host->lock, flags);
1901 - cancel_delayed_work_sync(&host->detect);
1902 -
1903 - if (!host->bus_ops)
1904 - break;
1905 -
1906 - /* Validate prerequisites for suspend */
1907 - if (host->bus_ops->pre_suspend)
1908 - err = host->bus_ops->pre_suspend(host);
1909 - if (!err)
1910 - break;
1911 -
1912 - if (!mmc_card_is_removable(host)) {
1913 - dev_warn(mmc_dev(host),
1914 - "pre_suspend failed for non-removable host: "
1915 - "%d\n", err);
1916 - /* Avoid removing non-removable hosts */
1917 - break;
1918 - }
1919 -
1920 - /* Calling bus_ops->remove() with a claimed host can deadlock */
1921 - host->bus_ops->remove(host);
1922 - mmc_claim_host(host);
1923 - mmc_detach_bus(host);
1924 - mmc_power_off(host);
1925 - mmc_release_host(host);
1926 - host->pm_flags = 0;
1927 - break;
1928 -
1929 - case PM_POST_SUSPEND:
1930 - case PM_POST_HIBERNATION:
1931 - case PM_POST_RESTORE:
1932 -
1933 - spin_lock_irqsave(&host->lock, flags);
1934 - host->rescan_disable = 0;
1935 - spin_unlock_irqrestore(&host->lock, flags);
1936 - _mmc_detect_change(host, 0, false);
1937 -
1938 - }
1939 -
1940 - return 0;
1941 -}
1942 -
1943 -void mmc_register_pm_notifier(struct mmc_host *host)
1944 -{
1945 - host->pm_notify.notifier_call = mmc_pm_notify;
1946 - register_pm_notifier(&host->pm_notify);
1947 -}
1948 -
1949 -void mmc_unregister_pm_notifier(struct mmc_host *host)
1950 -{
1951 - unregister_pm_notifier(&host->pm_notify);
1952 -}
1953 -#endif
1954 -
1955 static int __init mmc_init(void)
1956 {
1957 int ret;
1958 diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
1959 index 575ac0257af2f..db3c9c68875d8 100644
1960 --- a/drivers/mmc/core/core.h
1961 +++ b/drivers/mmc/core/core.h
1962 @@ -29,6 +29,7 @@ struct mmc_bus_ops {
1963 int (*shutdown)(struct mmc_host *);
1964 int (*hw_reset)(struct mmc_host *);
1965 int (*sw_reset)(struct mmc_host *);
1966 + bool (*cache_enabled)(struct mmc_host *);
1967 };
1968
1969 void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
1970 @@ -93,14 +94,6 @@ int mmc_execute_tuning(struct mmc_card *card);
1971 int mmc_hs200_to_hs400(struct mmc_card *card);
1972 int mmc_hs400_to_hs200(struct mmc_card *card);
1973
1974 -#ifdef CONFIG_PM_SLEEP
1975 -void mmc_register_pm_notifier(struct mmc_host *host);
1976 -void mmc_unregister_pm_notifier(struct mmc_host *host);
1977 -#else
1978 -static inline void mmc_register_pm_notifier(struct mmc_host *host) { }
1979 -static inline void mmc_unregister_pm_notifier(struct mmc_host *host) { }
1980 -#endif
1981 -
1982 void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq);
1983 bool mmc_is_req_done(struct mmc_host *host, struct mmc_request *mrq);
1984
1985 @@ -171,4 +164,12 @@ static inline void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq,
1986 host->ops->post_req(host, mrq, err);
1987 }
1988
1989 +static inline bool mmc_cache_enabled(struct mmc_host *host)
1990 +{
1991 + if (host->bus_ops->cache_enabled)
1992 + return host->bus_ops->cache_enabled(host);
1993 +
1994 + return false;
1995 +}
1996 +
1997 #endif
1998 diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
1999 index b3484def0a8b0..f7339590a84c8 100644
2000 --- a/drivers/mmc/core/host.c
2001 +++ b/drivers/mmc/core/host.c
2002 @@ -33,6 +33,42 @@
2003
2004 static DEFINE_IDA(mmc_host_ida);
2005
2006 +#ifdef CONFIG_PM_SLEEP
2007 +static int mmc_host_class_prepare(struct device *dev)
2008 +{
2009 + struct mmc_host *host = cls_dev_to_mmc_host(dev);
2010 +
2011 + /*
2012 + * It's safe to access the bus_ops pointer, as both userspace and the
2013 + * workqueue for detecting cards are frozen at this point.
2014 + */
2015 + if (!host->bus_ops)
2016 + return 0;
2017 +
2018 + /* Validate conditions for system suspend. */
2019 + if (host->bus_ops->pre_suspend)
2020 + return host->bus_ops->pre_suspend(host);
2021 +
2022 + return 0;
2023 +}
2024 +
2025 +static void mmc_host_class_complete(struct device *dev)
2026 +{
2027 + struct mmc_host *host = cls_dev_to_mmc_host(dev);
2028 +
2029 + _mmc_detect_change(host, 0, false);
2030 +}
2031 +
2032 +static const struct dev_pm_ops mmc_host_class_dev_pm_ops = {
2033 + .prepare = mmc_host_class_prepare,
2034 + .complete = mmc_host_class_complete,
2035 +};
2036 +
2037 +#define MMC_HOST_CLASS_DEV_PM_OPS (&mmc_host_class_dev_pm_ops)
2038 +#else
2039 +#define MMC_HOST_CLASS_DEV_PM_OPS NULL
2040 +#endif
2041 +
2042 static void mmc_host_classdev_release(struct device *dev)
2043 {
2044 struct mmc_host *host = cls_dev_to_mmc_host(dev);
2045 @@ -43,6 +79,7 @@ static void mmc_host_classdev_release(struct device *dev)
2046 static struct class mmc_host_class = {
2047 .name = "mmc_host",
2048 .dev_release = mmc_host_classdev_release,
2049 + .pm = MMC_HOST_CLASS_DEV_PM_OPS,
2050 };
2051
2052 int mmc_register_host_class(void)
2053 @@ -477,8 +514,6 @@ int mmc_add_host(struct mmc_host *host)
2054 #endif
2055
2056 mmc_start_host(host);
2057 - mmc_register_pm_notifier(host);
2058 -
2059 return 0;
2060 }
2061
2062 @@ -494,7 +529,6 @@ EXPORT_SYMBOL(mmc_add_host);
2063 */
2064 void mmc_remove_host(struct mmc_host *host)
2065 {
2066 - mmc_unregister_pm_notifier(host);
2067 mmc_stop_host(host);
2068
2069 #ifdef CONFIG_DEBUG_FS
2070 diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
2071 index 9f29288f2c9a9..ed939bb2f7006 100644
2072 --- a/drivers/mmc/core/mmc.c
2073 +++ b/drivers/mmc/core/mmc.c
2074 @@ -2019,6 +2019,12 @@ static void mmc_detect(struct mmc_host *host)
2075 }
2076 }
2077
2078 +static bool _mmc_cache_enabled(struct mmc_host *host)
2079 +{
2080 + return host->card->ext_csd.cache_size > 0 &&
2081 + host->card->ext_csd.cache_ctrl & 1;
2082 +}
2083 +
2084 static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
2085 {
2086 int err = 0;
2087 @@ -2197,6 +2203,7 @@ static const struct mmc_bus_ops mmc_ops = {
2088 .alive = mmc_alive,
2089 .shutdown = mmc_shutdown,
2090 .hw_reset = _mmc_hw_reset,
2091 + .cache_enabled = _mmc_cache_enabled,
2092 };
2093
2094 /*
2095 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
2096 index 18a7afb2a5b23..09311c2bd8588 100644
2097 --- a/drivers/mmc/core/mmc_ops.c
2098 +++ b/drivers/mmc/core/mmc_ops.c
2099 @@ -959,9 +959,7 @@ int mmc_flush_cache(struct mmc_card *card)
2100 {
2101 int err = 0;
2102
2103 - if (mmc_card_mmc(card) &&
2104 - (card->ext_csd.cache_size > 0) &&
2105 - (card->ext_csd.cache_ctrl & 1)) {
2106 + if (mmc_cache_enabled(card->host)) {
2107 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
2108 EXT_CSD_FLUSH_CACHE, 1, 0);
2109 if (err)
2110 diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
2111 index fe914ff5f5d66..4f7c08e68f8cb 100644
2112 --- a/drivers/mmc/core/sd.c
2113 +++ b/drivers/mmc/core/sd.c
2114 @@ -135,6 +135,9 @@ static int mmc_decode_csd(struct mmc_card *card)
2115 csd->erase_size = UNSTUFF_BITS(resp, 39, 7) + 1;
2116 csd->erase_size <<= csd->write_blkbits - 9;
2117 }
2118 +
2119 + if (UNSTUFF_BITS(resp, 13, 1))
2120 + mmc_card_set_readonly(card);
2121 break;
2122 case 1:
2123 /*
2124 @@ -169,6 +172,9 @@ static int mmc_decode_csd(struct mmc_card *card)
2125 csd->write_blkbits = 9;
2126 csd->write_partial = 0;
2127 csd->erase_size = 1;
2128 +
2129 + if (UNSTUFF_BITS(resp, 13, 1))
2130 + mmc_card_set_readonly(card);
2131 break;
2132 default:
2133 pr_err("%s: unrecognised CSD structure version %d\n",
2134 diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
2135 index 20eed28ea60da..0bf33786fc5c5 100644
2136 --- a/drivers/mmc/core/sdio.c
2137 +++ b/drivers/mmc/core/sdio.c
2138 @@ -924,21 +924,37 @@ out:
2139 */
2140 static int mmc_sdio_pre_suspend(struct mmc_host *host)
2141 {
2142 - int i, err = 0;
2143 + int i;
2144
2145 for (i = 0; i < host->card->sdio_funcs; i++) {
2146 struct sdio_func *func = host->card->sdio_func[i];
2147 if (func && sdio_func_present(func) && func->dev.driver) {
2148 const struct dev_pm_ops *pmops = func->dev.driver->pm;
2149 - if (!pmops || !pmops->suspend || !pmops->resume) {
2150 + if (!pmops || !pmops->suspend || !pmops->resume)
2151 /* force removal of entire card in that case */
2152 - err = -ENOSYS;
2153 - break;
2154 - }
2155 + goto remove;
2156 }
2157 }
2158
2159 - return err;
2160 + return 0;
2161 +
2162 +remove:
2163 + if (!mmc_card_is_removable(host)) {
2164 + dev_warn(mmc_dev(host),
2165 + "missing suspend/resume ops for non-removable SDIO card\n");
2166 + /* Don't remove a non-removable card - we can't re-detect it. */
2167 + return 0;
2168 + }
2169 +
2170 + /* Remove the SDIO card and let it be re-detected later on. */
2171 + mmc_sdio_remove(host);
2172 + mmc_claim_host(host);
2173 + mmc_detach_bus(host);
2174 + mmc_power_off(host);
2175 + mmc_release_host(host);
2176 + host->pm_flags = 0;
2177 +
2178 + return 0;
2179 }
2180
2181 /*
2182 diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
2183 index afbccfceaaf85..a9151bd27211a 100644
2184 --- a/drivers/mmc/host/sdhci-pci-core.c
2185 +++ b/drivers/mmc/host/sdhci-pci-core.c
2186 @@ -520,6 +520,7 @@ struct intel_host {
2187 int drv_strength;
2188 bool d3_retune;
2189 bool rpm_retune_ok;
2190 + bool needs_pwr_off;
2191 u32 glk_rx_ctrl1;
2192 u32 glk_tun_val;
2193 u32 active_ltr;
2194 @@ -647,9 +648,25 @@ out:
2195 static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
2196 unsigned short vdd)
2197 {
2198 + struct sdhci_pci_slot *slot = sdhci_priv(host);
2199 + struct intel_host *intel_host = sdhci_pci_priv(slot);
2200 int cntr;
2201 u8 reg;
2202
2203 + /*
2204 + * Bus power may control card power, but a full reset still may not
2205 + * reset the power, whereas a direct write to SDHCI_POWER_CONTROL can.
2206 + * That might be needed to initialize correctly, if the card was left
2207 + * powered on previously.
2208 + */
2209 + if (intel_host->needs_pwr_off) {
2210 + intel_host->needs_pwr_off = false;
2211 + if (mode != MMC_POWER_OFF) {
2212 + sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
2213 + usleep_range(10000, 12500);
2214 + }
2215 + }
2216 +
2217 sdhci_set_power(host, mode, vdd);
2218
2219 if (mode == MMC_POWER_OFF)
2220 @@ -1139,6 +1156,14 @@ static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
2221 return 0;
2222 }
2223
2224 +static void byt_needs_pwr_off(struct sdhci_pci_slot *slot)
2225 +{
2226 + struct intel_host *intel_host = sdhci_pci_priv(slot);
2227 + u8 reg = sdhci_readb(slot->host, SDHCI_POWER_CONTROL);
2228 +
2229 + intel_host->needs_pwr_off = reg & SDHCI_POWER_ON;
2230 +}
2231 +
2232 static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
2233 {
2234 byt_probe_slot(slot);
2235 @@ -1156,6 +1181,8 @@ static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
2236 slot->chip->pdev->subsystem_device == PCI_SUBDEVICE_ID_NI_78E3)
2237 slot->host->mmc->caps2 |= MMC_CAP2_AVOID_3_3V;
2238
2239 + byt_needs_pwr_off(slot);
2240 +
2241 return 0;
2242 }
2243
2244 @@ -1907,6 +1934,8 @@ static const struct pci_device_id pci_ids[] = {
2245 SDHCI_PCI_DEVICE(INTEL, CMLH_SD, intel_byt_sd),
2246 SDHCI_PCI_DEVICE(INTEL, JSL_EMMC, intel_glk_emmc),
2247 SDHCI_PCI_DEVICE(INTEL, JSL_SD, intel_byt_sd),
2248 + SDHCI_PCI_DEVICE(INTEL, LKF_EMMC, intel_glk_emmc),
2249 + SDHCI_PCI_DEVICE(INTEL, LKF_SD, intel_byt_sd),
2250 SDHCI_PCI_DEVICE(O2, 8120, o2),
2251 SDHCI_PCI_DEVICE(O2, 8220, o2),
2252 SDHCI_PCI_DEVICE(O2, 8221, o2),
2253 diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
2254 index 981bbbe63aff5..779156ce1ee17 100644
2255 --- a/drivers/mmc/host/sdhci-pci.h
2256 +++ b/drivers/mmc/host/sdhci-pci.h
2257 @@ -57,6 +57,8 @@
2258 #define PCI_DEVICE_ID_INTEL_CMLH_SD 0x06f5
2259 #define PCI_DEVICE_ID_INTEL_JSL_EMMC 0x4dc4
2260 #define PCI_DEVICE_ID_INTEL_JSL_SD 0x4df8
2261 +#define PCI_DEVICE_ID_INTEL_LKF_EMMC 0x98c4
2262 +#define PCI_DEVICE_ID_INTEL_LKF_SD 0x98f8
2263
2264 #define PCI_DEVICE_ID_SYSKONNECT_8000 0x8000
2265 #define PCI_DEVICE_ID_VIA_95D0 0x95d0
2266 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
2267 index a1aeb2e105641..92709232529a6 100644
2268 --- a/drivers/mmc/host/sdhci.c
2269 +++ b/drivers/mmc/host/sdhci.c
2270 @@ -2647,6 +2647,37 @@ static bool sdhci_request_done(struct sdhci_host *host)
2271 return true;
2272 }
2273
2274 + /*
2275 + * The controller needs a reset of internal state machines
2276 + * upon error conditions.
2277 + */
2278 + if (sdhci_needs_reset(host, mrq)) {
2279 + /*
2280 + * Do not finish until command and data lines are available for
2281 + * reset. Note there can only be one other mrq, so it cannot
2282 + * also be in mrqs_done, otherwise host->cmd and host->data_cmd
2283 + * would both be null.
2284 + */
2285 + if (host->cmd || host->data_cmd) {
2286 + spin_unlock_irqrestore(&host->lock, flags);
2287 + return true;
2288 + }
2289 +
2290 + /* Some controllers need this kick or reset won't work here */
2291 + if (host->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET)
2292 + /* This is to force an update */
2293 + host->ops->set_clock(host, host->clock);
2294 +
2295 + /*
2296 + * Spec says we should do both at the same time, but Ricoh
2297 + * controllers do not like that.
2298 + */
2299 + sdhci_do_reset(host, SDHCI_RESET_CMD);
2300 + sdhci_do_reset(host, SDHCI_RESET_DATA);
2301 +
2302 + host->pending_reset = false;
2303 + }
2304 +
2305 /*
2306 * Always unmap the data buffers if they were mapped by
2307 * sdhci_prepare_data() whenever we finish with a request.
2308 @@ -2699,35 +2730,6 @@ static bool sdhci_request_done(struct sdhci_host *host)
2309 }
2310 }
2311
2312 - /*
2313 - * The controller needs a reset of internal state machines
2314 - * upon error conditions.
2315 - */
2316 - if (sdhci_needs_reset(host, mrq)) {
2317 - /*
2318 - * Do not finish until command and data lines are available for
2319 - * reset. Note there can only be one other mrq, so it cannot
2320 - * also be in mrqs_done, otherwise host->cmd and host->data_cmd
2321 - * would both be null.
2322 - */
2323 - if (host->cmd || host->data_cmd) {
2324 - spin_unlock_irqrestore(&host->lock, flags);
2325 - return true;
2326 - }
2327 -
2328 - /* Some controllers need this kick or reset won't work here */
2329 - if (host->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET)
2330 - /* This is to force an update */
2331 - host->ops->set_clock(host, host->clock);
2332 -
2333 - /* Spec says we should do both at the same time, but Ricoh
2334 - controllers do not like that. */
2335 - sdhci_do_reset(host, SDHCI_RESET_CMD);
2336 - sdhci_do_reset(host, SDHCI_RESET_DATA);
2337 -
2338 - host->pending_reset = false;
2339 - }
2340 -
2341 host->mrqs_done[i] = NULL;
2342
2343 spin_unlock_irqrestore(&host->lock, flags);
2344 diff --git a/drivers/mmc/host/uniphier-sd.c b/drivers/mmc/host/uniphier-sd.c
2345 index aec9c8ae694c7..b2e28ecae4a54 100644
2346 --- a/drivers/mmc/host/uniphier-sd.c
2347 +++ b/drivers/mmc/host/uniphier-sd.c
2348 @@ -639,7 +639,7 @@ static int uniphier_sd_probe(struct platform_device *pdev)
2349
2350 ret = tmio_mmc_host_probe(host);
2351 if (ret)
2352 - goto free_host;
2353 + goto disable_clk;
2354
2355 ret = devm_request_irq(dev, irq, tmio_mmc_irq, IRQF_SHARED,
2356 dev_name(dev), host);
2357 @@ -650,6 +650,8 @@ static int uniphier_sd_probe(struct platform_device *pdev)
2358
2359 remove_host:
2360 tmio_mmc_host_remove(host);
2361 +disable_clk:
2362 + uniphier_sd_clk_disable(host);
2363 free_host:
2364 tmio_mmc_host_free(host);
2365
2366 @@ -662,6 +664,7 @@ static int uniphier_sd_remove(struct platform_device *pdev)
2367
2368 tmio_mmc_host_remove(host);
2369 uniphier_sd_clk_disable(host);
2370 + tmio_mmc_host_free(host);
2371
2372 return 0;
2373 }
2374 diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c
2375 index 8d6be90a6fe8a..23d11e8b56441 100644
2376 --- a/drivers/mtd/nand/raw/atmel/nand-controller.c
2377 +++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
2378 @@ -813,10 +813,12 @@ static int atmel_nand_pmecc_correct_data(struct nand_chip *chip, void *buf,
2379 NULL, 0,
2380 chip->ecc.strength);
2381
2382 - if (ret >= 0)
2383 + if (ret >= 0) {
2384 + mtd->ecc_stats.corrected += ret;
2385 max_bitflips = max(ret, max_bitflips);
2386 - else
2387 + } else {
2388 mtd->ecc_stats.failed++;
2389 + }
2390
2391 databuf += chip->ecc.size;
2392 eccbuf += chip->ecc.bytes;
2393 diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
2394 index 0d21c68bfe245..55e636efcc8b7 100644
2395 --- a/drivers/mtd/nand/spi/core.c
2396 +++ b/drivers/mtd/nand/spi/core.c
2397 @@ -1133,12 +1133,14 @@ static const struct spi_device_id spinand_ids[] = {
2398 { .name = "spi-nand" },
2399 { /* sentinel */ },
2400 };
2401 +MODULE_DEVICE_TABLE(spi, spinand_ids);
2402
2403 #ifdef CONFIG_OF
2404 static const struct of_device_id spinand_of_ids[] = {
2405 { .compatible = "spi-nand" },
2406 { /* sentinel */ },
2407 };
2408 +MODULE_DEVICE_TABLE(of, spinand_of_ids);
2409 #endif
2410
2411 static struct spi_mem_driver spinand_drv = {
2412 diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c
2413 index 336e5ecc68f86..f1874578aa141 100644
2414 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c
2415 +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c
2416 @@ -524,6 +524,16 @@ mlxsw_sp_mr_route_evif_resolve(struct mlxsw_sp_mr_table *mr_table,
2417 u16 erif_index = 0;
2418 int err;
2419
2420 + /* Add the eRIF */
2421 + if (mlxsw_sp_mr_vif_valid(rve->mr_vif)) {
2422 + erif_index = mlxsw_sp_rif_index(rve->mr_vif->rif);
2423 + err = mr->mr_ops->route_erif_add(mlxsw_sp,
2424 + rve->mr_route->route_priv,
2425 + erif_index);
2426 + if (err)
2427 + return err;
2428 + }
2429 +
2430 /* Update the route action, as the new eVIF can be a tunnel or a pimreg
2431 * device which will require updating the action.
2432 */
2433 @@ -533,17 +543,7 @@ mlxsw_sp_mr_route_evif_resolve(struct mlxsw_sp_mr_table *mr_table,
2434 rve->mr_route->route_priv,
2435 route_action);
2436 if (err)
2437 - return err;
2438 - }
2439 -
2440 - /* Add the eRIF */
2441 - if (mlxsw_sp_mr_vif_valid(rve->mr_vif)) {
2442 - erif_index = mlxsw_sp_rif_index(rve->mr_vif->rif);
2443 - err = mr->mr_ops->route_erif_add(mlxsw_sp,
2444 - rve->mr_route->route_priv,
2445 - erif_index);
2446 - if (err)
2447 - goto err_route_erif_add;
2448 + goto err_route_action_update;
2449 }
2450
2451 /* Update the minimum MTU */
2452 @@ -561,14 +561,14 @@ mlxsw_sp_mr_route_evif_resolve(struct mlxsw_sp_mr_table *mr_table,
2453 return 0;
2454
2455 err_route_min_mtu_update:
2456 - if (mlxsw_sp_mr_vif_valid(rve->mr_vif))
2457 - mr->mr_ops->route_erif_del(mlxsw_sp, rve->mr_route->route_priv,
2458 - erif_index);
2459 -err_route_erif_add:
2460 if (route_action != rve->mr_route->route_action)
2461 mr->mr_ops->route_action_update(mlxsw_sp,
2462 rve->mr_route->route_priv,
2463 rve->mr_route->route_action);
2464 +err_route_action_update:
2465 + if (mlxsw_sp_mr_vif_valid(rve->mr_vif))
2466 + mr->mr_ops->route_erif_del(mlxsw_sp, rve->mr_route->route_priv,
2467 + erif_index);
2468 return err;
2469 }
2470
2471 diff --git a/drivers/net/wimax/i2400m/op-rfkill.c b/drivers/net/wimax/i2400m/op-rfkill.c
2472 index 5c79f052cad20..34f81f16b5a0c 100644
2473 --- a/drivers/net/wimax/i2400m/op-rfkill.c
2474 +++ b/drivers/net/wimax/i2400m/op-rfkill.c
2475 @@ -86,7 +86,7 @@ int i2400m_op_rfkill_sw_toggle(struct wimax_dev *wimax_dev,
2476 if (cmd == NULL)
2477 goto error_alloc;
2478 cmd->hdr.type = cpu_to_le16(I2400M_MT_CMD_RF_CONTROL);
2479 - cmd->hdr.length = sizeof(cmd->sw_rf);
2480 + cmd->hdr.length = cpu_to_le16(sizeof(cmd->sw_rf));
2481 cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
2482 cmd->sw_rf.hdr.type = cpu_to_le16(I2400M_TLV_RF_OPERATION);
2483 cmd->sw_rf.hdr.length = cpu_to_le16(sizeof(cmd->sw_rf.status));
2484 diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c
2485 index d1e8c6593ef51..d51ec7104fb7c 100644
2486 --- a/drivers/net/wireless/rsi/rsi_91x_sdio.c
2487 +++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c
2488 @@ -1511,7 +1511,7 @@ static int rsi_restore(struct device *dev)
2489 }
2490 static const struct dev_pm_ops rsi_pm_ops = {
2491 .suspend = rsi_suspend,
2492 - .resume = rsi_resume,
2493 + .resume_noirq = rsi_resume,
2494 .freeze = rsi_freeze,
2495 .thaw = rsi_thaw,
2496 .restore = rsi_restore,
2497 diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
2498 index 3c3bc9f584983..34a06e89e176a 100644
2499 --- a/drivers/pci/pci.c
2500 +++ b/drivers/pci/pci.c
2501 @@ -1666,20 +1666,10 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
2502 int err;
2503 int i, bars = 0;
2504
2505 - /*
2506 - * Power state could be unknown at this point, either due to a fresh
2507 - * boot or a device removal call. So get the current power state
2508 - * so that things like MSI message writing will behave as expected
2509 - * (e.g. if the device really is in D0 at enable time).
2510 - */
2511 - if (dev->pm_cap) {
2512 - u16 pmcsr;
2513 - pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
2514 - dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
2515 - }
2516 -
2517 - if (atomic_inc_return(&dev->enable_cnt) > 1)
2518 + if (atomic_inc_return(&dev->enable_cnt) > 1) {
2519 + pci_update_current_state(dev, dev->current_state);
2520 return 0; /* already enabled */
2521 + }
2522
2523 bridge = pci_upstream_bridge(dev);
2524 if (bridge)
2525 diff --git a/drivers/perf/arm_pmu_platform.c b/drivers/perf/arm_pmu_platform.c
2526 index 933bd8410fc2a..e35cb76c8d104 100644
2527 --- a/drivers/perf/arm_pmu_platform.c
2528 +++ b/drivers/perf/arm_pmu_platform.c
2529 @@ -236,7 +236,7 @@ int arm_pmu_device_probe(struct platform_device *pdev,
2530
2531 ret = armpmu_register(pmu);
2532 if (ret)
2533 - goto out_free;
2534 + goto out_free_irqs;
2535
2536 return 0;
2537
2538 diff --git a/drivers/phy/ti/phy-twl4030-usb.c b/drivers/phy/ti/phy-twl4030-usb.c
2539 index 9887f908f5401..812e5409d3595 100644
2540 --- a/drivers/phy/ti/phy-twl4030-usb.c
2541 +++ b/drivers/phy/ti/phy-twl4030-usb.c
2542 @@ -779,7 +779,7 @@ static int twl4030_usb_remove(struct platform_device *pdev)
2543
2544 usb_remove_phy(&twl->phy);
2545 pm_runtime_get_sync(twl->dev);
2546 - cancel_delayed_work(&twl->id_workaround_work);
2547 + cancel_delayed_work_sync(&twl->id_workaround_work);
2548 device_remove_file(twl->dev, &dev_attr_vbus);
2549
2550 /* set transceiver mode to power on defaults */
2551 diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
2552 index 571b4754477c5..4c1312f1616c3 100644
2553 --- a/drivers/platform/x86/intel_pmc_core.c
2554 +++ b/drivers/platform/x86/intel_pmc_core.c
2555 @@ -831,9 +831,15 @@ static const struct pci_device_id pmc_pci_ids[] = {
2556 * the platform BIOS enforces 24Mhx Crystal to shutdown
2557 * before PMC can assert SLP_S0#.
2558 */
2559 +static bool xtal_ignore;
2560 static int quirk_xtal_ignore(const struct dmi_system_id *id)
2561 {
2562 - struct pmc_dev *pmcdev = &pmc;
2563 + xtal_ignore = true;
2564 + return 0;
2565 +}
2566 +
2567 +static void pmc_core_xtal_ignore(struct pmc_dev *pmcdev)
2568 +{
2569 u32 value;
2570
2571 value = pmc_core_reg_read(pmcdev, pmcdev->map->pm_vric1_offset);
2572 @@ -842,7 +848,6 @@ static int quirk_xtal_ignore(const struct dmi_system_id *id)
2573 /* Low Voltage Mode Enable */
2574 value &= ~SPT_PMC_VRIC1_SLPS0LVEN;
2575 pmc_core_reg_write(pmcdev, pmcdev->map->pm_vric1_offset, value);
2576 - return 0;
2577 }
2578
2579 static const struct dmi_system_id pmc_core_dmi_table[] = {
2580 @@ -857,6 +862,14 @@ static const struct dmi_system_id pmc_core_dmi_table[] = {
2581 {}
2582 };
2583
2584 +static void pmc_core_do_dmi_quirks(struct pmc_dev *pmcdev)
2585 +{
2586 + dmi_check_system(pmc_core_dmi_table);
2587 +
2588 + if (xtal_ignore)
2589 + pmc_core_xtal_ignore(pmcdev);
2590 +}
2591 +
2592 static int pmc_core_probe(struct platform_device *pdev)
2593 {
2594 static bool device_initialized;
2595 @@ -898,7 +911,7 @@ static int pmc_core_probe(struct platform_device *pdev)
2596 mutex_init(&pmcdev->lock);
2597 platform_set_drvdata(pdev, pmcdev);
2598 pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
2599 - dmi_check_system(pmc_core_dmi_table);
2600 + pmc_core_do_dmi_quirks(pmcdev);
2601
2602 pmc_core_dbgfs_register(pmcdev);
2603
2604 diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
2605 index aff0a0a5e7f8c..b1a37aa388800 100644
2606 --- a/drivers/power/supply/bq27xxx_battery.c
2607 +++ b/drivers/power/supply/bq27xxx_battery.c
2608 @@ -1499,27 +1499,6 @@ static int bq27xxx_battery_read_time(struct bq27xxx_device_info *di, u8 reg)
2609 return tval * 60;
2610 }
2611
2612 -/*
2613 - * Read an average power register.
2614 - * Return < 0 if something fails.
2615 - */
2616 -static int bq27xxx_battery_read_pwr_avg(struct bq27xxx_device_info *di)
2617 -{
2618 - int tval;
2619 -
2620 - tval = bq27xxx_read(di, BQ27XXX_REG_AP, false);
2621 - if (tval < 0) {
2622 - dev_err(di->dev, "error reading average power register %02x: %d\n",
2623 - BQ27XXX_REG_AP, tval);
2624 - return tval;
2625 - }
2626 -
2627 - if (di->opts & BQ27XXX_O_ZERO)
2628 - return (tval * BQ27XXX_POWER_CONSTANT) / BQ27XXX_RS;
2629 - else
2630 - return tval;
2631 -}
2632 -
2633 /*
2634 * Returns true if a battery over temperature condition is detected
2635 */
2636 @@ -1604,8 +1583,6 @@ void bq27xxx_battery_update(struct bq27xxx_device_info *di)
2637 }
2638 if (di->regs[BQ27XXX_REG_CYCT] != INVALID_REG_ADDR)
2639 cache.cycle_count = bq27xxx_battery_read_cyct(di);
2640 - if (di->regs[BQ27XXX_REG_AP] != INVALID_REG_ADDR)
2641 - cache.power_avg = bq27xxx_battery_read_pwr_avg(di);
2642
2643 /* We only have to read charge design full once */
2644 if (di->charge_design_full <= 0)
2645 @@ -1668,6 +1645,32 @@ static int bq27xxx_battery_current(struct bq27xxx_device_info *di,
2646 return 0;
2647 }
2648
2649 +/*
2650 + * Get the average power in µW
2651 + * Return < 0 if something fails.
2652 + */
2653 +static int bq27xxx_battery_pwr_avg(struct bq27xxx_device_info *di,
2654 + union power_supply_propval *val)
2655 +{
2656 + int power;
2657 +
2658 + power = bq27xxx_read(di, BQ27XXX_REG_AP, false);
2659 + if (power < 0) {
2660 + dev_err(di->dev,
2661 + "error reading average power register %02x: %d\n",
2662 + BQ27XXX_REG_AP, power);
2663 + return power;
2664 + }
2665 +
2666 + if (di->opts & BQ27XXX_O_ZERO)
2667 + val->intval = (power * BQ27XXX_POWER_CONSTANT) / BQ27XXX_RS;
2668 + else
2669 + /* Other gauges return a signed value in units of 10mW */
2670 + val->intval = (int)((s16)power) * 10000;
2671 +
2672 + return 0;
2673 +}
2674 +
2675 static int bq27xxx_battery_status(struct bq27xxx_device_info *di,
2676 union power_supply_propval *val)
2677 {
2678 @@ -1835,7 +1838,7 @@ static int bq27xxx_battery_get_property(struct power_supply *psy,
2679 ret = bq27xxx_simple_value(di->cache.energy, val);
2680 break;
2681 case POWER_SUPPLY_PROP_POWER_AVG:
2682 - ret = bq27xxx_simple_value(di->cache.power_avg, val);
2683 + ret = bq27xxx_battery_pwr_avg(di, val);
2684 break;
2685 case POWER_SUPPLY_PROP_HEALTH:
2686 ret = bq27xxx_simple_value(di->cache.health, val);
2687 diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c
2688 index bc462d1ec9630..97b0e873e87d2 100644
2689 --- a/drivers/power/supply/generic-adc-battery.c
2690 +++ b/drivers/power/supply/generic-adc-battery.c
2691 @@ -382,7 +382,7 @@ static int gab_remove(struct platform_device *pdev)
2692 }
2693
2694 kfree(adc_bat->psy_desc.properties);
2695 - cancel_delayed_work(&adc_bat->bat_work);
2696 + cancel_delayed_work_sync(&adc_bat->bat_work);
2697 return 0;
2698 }
2699
2700 diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
2701 index e7931ffb7151d..397e5a03b7d9a 100644
2702 --- a/drivers/power/supply/lp8788-charger.c
2703 +++ b/drivers/power/supply/lp8788-charger.c
2704 @@ -501,7 +501,7 @@ static int lp8788_set_irqs(struct platform_device *pdev,
2705
2706 ret = request_threaded_irq(virq, NULL,
2707 lp8788_charger_irq_thread,
2708 - 0, name, pchg);
2709 + IRQF_ONESHOT, name, pchg);
2710 if (ret)
2711 break;
2712 }
2713 diff --git a/drivers/power/supply/pm2301_charger.c b/drivers/power/supply/pm2301_charger.c
2714 index 17749fc90e165..d2aff1cf4f793 100644
2715 --- a/drivers/power/supply/pm2301_charger.c
2716 +++ b/drivers/power/supply/pm2301_charger.c
2717 @@ -1095,7 +1095,7 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
2718 ret = request_threaded_irq(gpio_to_irq(pm2->pdata->gpio_irq_number),
2719 NULL,
2720 pm2xxx_charger_irq[0].isr,
2721 - pm2->pdata->irq_type,
2722 + pm2->pdata->irq_type | IRQF_ONESHOT,
2723 pm2xxx_charger_irq[0].name, pm2);
2724
2725 if (ret != 0) {
2726 diff --git a/drivers/power/supply/s3c_adc_battery.c b/drivers/power/supply/s3c_adc_battery.c
2727 index 3d00b35cafc9e..8be31f80035c6 100644
2728 --- a/drivers/power/supply/s3c_adc_battery.c
2729 +++ b/drivers/power/supply/s3c_adc_battery.c
2730 @@ -394,7 +394,7 @@ static int s3c_adc_bat_remove(struct platform_device *pdev)
2731 gpio_free(pdata->gpio_charge_finished);
2732 }
2733
2734 - cancel_delayed_work(&bat_work);
2735 + cancel_delayed_work_sync(&bat_work);
2736
2737 if (pdata->exit)
2738 pdata->exit();
2739 diff --git a/drivers/power/supply/tps65090-charger.c b/drivers/power/supply/tps65090-charger.c
2740 index 6b0098e5a88b5..0990b2fa6cd8d 100644
2741 --- a/drivers/power/supply/tps65090-charger.c
2742 +++ b/drivers/power/supply/tps65090-charger.c
2743 @@ -301,7 +301,7 @@ static int tps65090_charger_probe(struct platform_device *pdev)
2744
2745 if (irq != -ENXIO) {
2746 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
2747 - tps65090_charger_isr, 0, "tps65090-charger", cdata);
2748 + tps65090_charger_isr, IRQF_ONESHOT, "tps65090-charger", cdata);
2749 if (ret) {
2750 dev_err(cdata->dev,
2751 "Unable to register irq %d err %d\n", irq,
2752 diff --git a/drivers/power/supply/tps65217_charger.c b/drivers/power/supply/tps65217_charger.c
2753 index 814c2b81fdfec..ba33d1617e0b6 100644
2754 --- a/drivers/power/supply/tps65217_charger.c
2755 +++ b/drivers/power/supply/tps65217_charger.c
2756 @@ -238,7 +238,7 @@ static int tps65217_charger_probe(struct platform_device *pdev)
2757 for (i = 0; i < NUM_CHARGER_IRQS; i++) {
2758 ret = devm_request_threaded_irq(&pdev->dev, irq[i], NULL,
2759 tps65217_charger_irq,
2760 - 0, "tps65217-charger",
2761 + IRQF_ONESHOT, "tps65217-charger",
2762 charger);
2763 if (ret) {
2764 dev_err(charger->dev,
2765 diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
2766 index 308bda2e9c000..df5a3bbeba5eb 100644
2767 --- a/drivers/scsi/device_handler/scsi_dh_alua.c
2768 +++ b/drivers/scsi/device_handler/scsi_dh_alua.c
2769 @@ -565,10 +565,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
2770 * even though it shouldn't according to T10.
2771 * The retry without rtpg_ext_hdr_req set
2772 * handles this.
2773 + * Note: some arrays return a sense key of ILLEGAL_REQUEST
2774 + * with ASC 00h if they don't support the extended header.
2775 */
2776 if (!(pg->flags & ALUA_RTPG_EXT_HDR_UNSUPP) &&
2777 - sense_hdr.sense_key == ILLEGAL_REQUEST &&
2778 - sense_hdr.asc == 0x24 && sense_hdr.ascq == 0) {
2779 + sense_hdr.sense_key == ILLEGAL_REQUEST) {
2780 pg->flags |= ALUA_RTPG_EXT_HDR_UNSUPP;
2781 goto retry;
2782 }
2783 diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
2784 index 684c5e361a286..9399e1455d597 100644
2785 --- a/drivers/scsi/libfc/fc_lport.c
2786 +++ b/drivers/scsi/libfc/fc_lport.c
2787 @@ -1729,7 +1729,7 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
2788
2789 if (mfs < FC_SP_MIN_MAX_PAYLOAD || mfs > FC_SP_MAX_MAX_PAYLOAD) {
2790 FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, "
2791 - "lport->mfs:%hu\n", mfs, lport->mfs);
2792 + "lport->mfs:%u\n", mfs, lport->mfs);
2793 fc_lport_error(lport, fp);
2794 goto out;
2795 }
2796 diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
2797 index bb973901b672d..45db19e31b348 100644
2798 --- a/drivers/scsi/lpfc/lpfc_attr.c
2799 +++ b/drivers/scsi/lpfc/lpfc_attr.c
2800 @@ -1691,8 +1691,7 @@ lpfc_set_trunking(struct lpfc_hba *phba, char *buff_out)
2801 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX,
2802 "0071 Set trunk mode failed with status: %d",
2803 rc);
2804 - if (rc != MBX_TIMEOUT)
2805 - mempool_free(mbox, phba->mbox_mem_pool);
2806 + mempool_free(mbox, phba->mbox_mem_pool);
2807
2808 return 0;
2809 }
2810 @@ -6608,15 +6607,19 @@ lpfc_get_stats(struct Scsi_Host *shost)
2811 pmboxq->ctx_buf = NULL;
2812 pmboxq->vport = vport;
2813
2814 - if (vport->fc_flag & FC_OFFLINE_MODE)
2815 + if (vport->fc_flag & FC_OFFLINE_MODE) {
2816 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
2817 - else
2818 - rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
2819 -
2820 - if (rc != MBX_SUCCESS) {
2821 - if (rc != MBX_TIMEOUT)
2822 + if (rc != MBX_SUCCESS) {
2823 mempool_free(pmboxq, phba->mbox_mem_pool);
2824 - return NULL;
2825 + return NULL;
2826 + }
2827 + } else {
2828 + rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
2829 + if (rc != MBX_SUCCESS) {
2830 + if (rc != MBX_TIMEOUT)
2831 + mempool_free(pmboxq, phba->mbox_mem_pool);
2832 + return NULL;
2833 + }
2834 }
2835
2836 memset(hs, 0, sizeof (struct fc_host_statistics));
2837 @@ -6640,15 +6643,19 @@ lpfc_get_stats(struct Scsi_Host *shost)
2838 pmboxq->ctx_buf = NULL;
2839 pmboxq->vport = vport;
2840
2841 - if (vport->fc_flag & FC_OFFLINE_MODE)
2842 + if (vport->fc_flag & FC_OFFLINE_MODE) {
2843 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
2844 - else
2845 - rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
2846 -
2847 - if (rc != MBX_SUCCESS) {
2848 - if (rc != MBX_TIMEOUT)
2849 + if (rc != MBX_SUCCESS) {
2850 mempool_free(pmboxq, phba->mbox_mem_pool);
2851 - return NULL;
2852 + return NULL;
2853 + }
2854 + } else {
2855 + rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
2856 + if (rc != MBX_SUCCESS) {
2857 + if (rc != MBX_TIMEOUT)
2858 + mempool_free(pmboxq, phba->mbox_mem_pool);
2859 + return NULL;
2860 + }
2861 }
2862
2863 hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
2864 @@ -6721,15 +6728,19 @@ lpfc_reset_stats(struct Scsi_Host *shost)
2865 pmboxq->vport = vport;
2866
2867 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
2868 - (!(psli->sli_flag & LPFC_SLI_ACTIVE)))
2869 + (!(psli->sli_flag & LPFC_SLI_ACTIVE))) {
2870 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
2871 - else
2872 - rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
2873 -
2874 - if (rc != MBX_SUCCESS) {
2875 - if (rc != MBX_TIMEOUT)
2876 + if (rc != MBX_SUCCESS) {
2877 mempool_free(pmboxq, phba->mbox_mem_pool);
2878 - return;
2879 + return;
2880 + }
2881 + } else {
2882 + rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
2883 + if (rc != MBX_SUCCESS) {
2884 + if (rc != MBX_TIMEOUT)
2885 + mempool_free(pmboxq, phba->mbox_mem_pool);
2886 + return;
2887 + }
2888 }
2889
2890 memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t));
2891 @@ -6739,15 +6750,19 @@ lpfc_reset_stats(struct Scsi_Host *shost)
2892 pmboxq->vport = vport;
2893
2894 if ((vport->fc_flag & FC_OFFLINE_MODE) ||
2895 - (!(psli->sli_flag & LPFC_SLI_ACTIVE)))
2896 + (!(psli->sli_flag & LPFC_SLI_ACTIVE))) {
2897 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
2898 - else
2899 + if (rc != MBX_SUCCESS) {
2900 + mempool_free(pmboxq, phba->mbox_mem_pool);
2901 + return;
2902 + }
2903 + } else {
2904 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
2905 -
2906 - if (rc != MBX_SUCCESS) {
2907 - if (rc != MBX_TIMEOUT)
2908 - mempool_free( pmboxq, phba->mbox_mem_pool);
2909 - return;
2910 + if (rc != MBX_SUCCESS) {
2911 + if (rc != MBX_TIMEOUT)
2912 + mempool_free(pmboxq, phba->mbox_mem_pool);
2913 + return;
2914 + }
2915 }
2916
2917 lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
2918 diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
2919 index 0f019e889ba6b..bdb1f380e7d8c 100644
2920 --- a/drivers/scsi/lpfc/lpfc_crtn.h
2921 +++ b/drivers/scsi/lpfc/lpfc_crtn.h
2922 @@ -56,9 +56,6 @@ void lpfc_register_new_vport(struct lpfc_hba *, struct lpfc_vport *,
2923 void lpfc_unreg_vpi(struct lpfc_hba *, uint16_t, LPFC_MBOXQ_t *);
2924 void lpfc_init_link(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t, uint32_t);
2925 void lpfc_request_features(struct lpfc_hba *, struct lpfcMboxq *);
2926 -void lpfc_supported_pages(struct lpfcMboxq *);
2927 -void lpfc_pc_sli4_params(struct lpfcMboxq *);
2928 -int lpfc_pc_sli4_params_get(struct lpfc_hba *, LPFC_MBOXQ_t *);
2929 int lpfc_sli4_mbox_rsrc_extent(struct lpfc_hba *, struct lpfcMboxq *,
2930 uint16_t, uint16_t, bool);
2931 int lpfc_get_sli4_parameters(struct lpfc_hba *, LPFC_MBOXQ_t *);
2932 diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
2933 index bd533475c86a4..b8a772f80d6c5 100644
2934 --- a/drivers/scsi/lpfc/lpfc_hw4.h
2935 +++ b/drivers/scsi/lpfc/lpfc_hw4.h
2936 @@ -122,6 +122,7 @@ struct lpfc_sli_intf {
2937 /* Define SLI4 Alignment requirements. */
2938 #define LPFC_ALIGN_16_BYTE 16
2939 #define LPFC_ALIGN_64_BYTE 64
2940 +#define SLI4_PAGE_SIZE 4096
2941
2942 /* Define SLI4 specific definitions. */
2943 #define LPFC_MQ_CQE_BYTE_OFFSET 256
2944 @@ -2962,62 +2963,6 @@ struct lpfc_mbx_request_features {
2945 #define lpfc_mbx_rq_ftr_rsp_mrqp_WORD word3
2946 };
2947
2948 -struct lpfc_mbx_supp_pages {
2949 - uint32_t word1;
2950 -#define qs_SHIFT 0
2951 -#define qs_MASK 0x00000001
2952 -#define qs_WORD word1
2953 -#define wr_SHIFT 1
2954 -#define wr_MASK 0x00000001
2955 -#define wr_WORD word1
2956 -#define pf_SHIFT 8
2957 -#define pf_MASK 0x000000ff
2958 -#define pf_WORD word1
2959 -#define cpn_SHIFT 16
2960 -#define cpn_MASK 0x000000ff
2961 -#define cpn_WORD word1
2962 - uint32_t word2;
2963 -#define list_offset_SHIFT 0
2964 -#define list_offset_MASK 0x000000ff
2965 -#define list_offset_WORD word2
2966 -#define next_offset_SHIFT 8
2967 -#define next_offset_MASK 0x000000ff
2968 -#define next_offset_WORD word2
2969 -#define elem_cnt_SHIFT 16
2970 -#define elem_cnt_MASK 0x000000ff
2971 -#define elem_cnt_WORD word2
2972 - uint32_t word3;
2973 -#define pn_0_SHIFT 24
2974 -#define pn_0_MASK 0x000000ff
2975 -#define pn_0_WORD word3
2976 -#define pn_1_SHIFT 16
2977 -#define pn_1_MASK 0x000000ff
2978 -#define pn_1_WORD word3
2979 -#define pn_2_SHIFT 8
2980 -#define pn_2_MASK 0x000000ff
2981 -#define pn_2_WORD word3
2982 -#define pn_3_SHIFT 0
2983 -#define pn_3_MASK 0x000000ff
2984 -#define pn_3_WORD word3
2985 - uint32_t word4;
2986 -#define pn_4_SHIFT 24
2987 -#define pn_4_MASK 0x000000ff
2988 -#define pn_4_WORD word4
2989 -#define pn_5_SHIFT 16
2990 -#define pn_5_MASK 0x000000ff
2991 -#define pn_5_WORD word4
2992 -#define pn_6_SHIFT 8
2993 -#define pn_6_MASK 0x000000ff
2994 -#define pn_6_WORD word4
2995 -#define pn_7_SHIFT 0
2996 -#define pn_7_MASK 0x000000ff
2997 -#define pn_7_WORD word4
2998 - uint32_t rsvd[27];
2999 -#define LPFC_SUPP_PAGES 0
3000 -#define LPFC_BLOCK_GUARD_PROFILES 1
3001 -#define LPFC_SLI4_PARAMETERS 2
3002 -};
3003 -
3004 struct lpfc_mbx_memory_dump_type3 {
3005 uint32_t word1;
3006 #define lpfc_mbx_memory_dump_type3_type_SHIFT 0
3007 @@ -3234,121 +3179,6 @@ struct user_eeprom {
3008 uint8_t reserved191[57];
3009 };
3010
3011 -struct lpfc_mbx_pc_sli4_params {
3012 - uint32_t word1;
3013 -#define qs_SHIFT 0
3014 -#define qs_MASK 0x00000001
3015 -#define qs_WORD word1
3016 -#define wr_SHIFT 1
3017 -#define wr_MASK 0x00000001
3018 -#define wr_WORD word1
3019 -#define pf_SHIFT 8
3020 -#define pf_MASK 0x000000ff
3021 -#define pf_WORD word1
3022 -#define cpn_SHIFT 16
3023 -#define cpn_MASK 0x000000ff
3024 -#define cpn_WORD word1
3025 - uint32_t word2;
3026 -#define if_type_SHIFT 0
3027 -#define if_type_MASK 0x00000007
3028 -#define if_type_WORD word2
3029 -#define sli_rev_SHIFT 4
3030 -#define sli_rev_MASK 0x0000000f
3031 -#define sli_rev_WORD word2
3032 -#define sli_family_SHIFT 8
3033 -#define sli_family_MASK 0x000000ff
3034 -#define sli_family_WORD word2
3035 -#define featurelevel_1_SHIFT 16
3036 -#define featurelevel_1_MASK 0x000000ff
3037 -#define featurelevel_1_WORD word2
3038 -#define featurelevel_2_SHIFT 24
3039 -#define featurelevel_2_MASK 0x0000001f
3040 -#define featurelevel_2_WORD word2
3041 - uint32_t word3;
3042 -#define fcoe_SHIFT 0
3043 -#define fcoe_MASK 0x00000001
3044 -#define fcoe_WORD word3
3045 -#define fc_SHIFT 1
3046 -#define fc_MASK 0x00000001
3047 -#define fc_WORD word3
3048 -#define nic_SHIFT 2
3049 -#define nic_MASK 0x00000001
3050 -#define nic_WORD word3
3051 -#define iscsi_SHIFT 3
3052 -#define iscsi_MASK 0x00000001
3053 -#define iscsi_WORD word3
3054 -#define rdma_SHIFT 4
3055 -#define rdma_MASK 0x00000001
3056 -#define rdma_WORD word3
3057 - uint32_t sge_supp_len;
3058 -#define SLI4_PAGE_SIZE 4096
3059 - uint32_t word5;
3060 -#define if_page_sz_SHIFT 0
3061 -#define if_page_sz_MASK 0x0000ffff
3062 -#define if_page_sz_WORD word5
3063 -#define loopbk_scope_SHIFT 24
3064 -#define loopbk_scope_MASK 0x0000000f
3065 -#define loopbk_scope_WORD word5
3066 -#define rq_db_window_SHIFT 28
3067 -#define rq_db_window_MASK 0x0000000f
3068 -#define rq_db_window_WORD word5
3069 - uint32_t word6;
3070 -#define eq_pages_SHIFT 0
3071 -#define eq_pages_MASK 0x0000000f
3072 -#define eq_pages_WORD word6
3073 -#define eqe_size_SHIFT 8
3074 -#define eqe_size_MASK 0x000000ff
3075 -#define eqe_size_WORD word6
3076 - uint32_t word7;
3077 -#define cq_pages_SHIFT 0
3078 -#define cq_pages_MASK 0x0000000f
3079 -#define cq_pages_WORD word7
3080 -#define cqe_size_SHIFT 8
3081 -#define cqe_size_MASK 0x000000ff
3082 -#define cqe_size_WORD word7
3083 - uint32_t word8;
3084 -#define mq_pages_SHIFT 0
3085 -#define mq_pages_MASK 0x0000000f
3086 -#define mq_pages_WORD word8
3087 -#define mqe_size_SHIFT 8
3088 -#define mqe_size_MASK 0x000000ff
3089 -#define mqe_size_WORD word8
3090 -#define mq_elem_cnt_SHIFT 16
3091 -#define mq_elem_cnt_MASK 0x000000ff
3092 -#define mq_elem_cnt_WORD word8
3093 - uint32_t word9;
3094 -#define wq_pages_SHIFT 0
3095 -#define wq_pages_MASK 0x0000ffff
3096 -#define wq_pages_WORD word9
3097 -#define wqe_size_SHIFT 8
3098 -#define wqe_size_MASK 0x000000ff
3099 -#define wqe_size_WORD word9
3100 - uint32_t word10;
3101 -#define rq_pages_SHIFT 0
3102 -#define rq_pages_MASK 0x0000ffff
3103 -#define rq_pages_WORD word10
3104 -#define rqe_size_SHIFT 8
3105 -#define rqe_size_MASK 0x000000ff
3106 -#define rqe_size_WORD word10
3107 - uint32_t word11;
3108 -#define hdr_pages_SHIFT 0
3109 -#define hdr_pages_MASK 0x0000000f
3110 -#define hdr_pages_WORD word11
3111 -#define hdr_size_SHIFT 8
3112 -#define hdr_size_MASK 0x0000000f
3113 -#define hdr_size_WORD word11
3114 -#define hdr_pp_align_SHIFT 16
3115 -#define hdr_pp_align_MASK 0x0000ffff
3116 -#define hdr_pp_align_WORD word11
3117 - uint32_t word12;
3118 -#define sgl_pages_SHIFT 0
3119 -#define sgl_pages_MASK 0x0000000f
3120 -#define sgl_pages_WORD word12
3121 -#define sgl_pp_align_SHIFT 16
3122 -#define sgl_pp_align_MASK 0x0000ffff
3123 -#define sgl_pp_align_WORD word12
3124 - uint32_t rsvd_13_63[51];
3125 -};
3126 #define SLI4_PAGE_ALIGN(addr) (((addr)+((SLI4_PAGE_SIZE)-1)) \
3127 &(~((SLI4_PAGE_SIZE)-1)))
3128
3129 @@ -3958,8 +3788,6 @@ struct lpfc_mqe {
3130 struct lpfc_mbx_post_hdr_tmpl hdr_tmpl;
3131 struct lpfc_mbx_query_fw_config query_fw_cfg;
3132 struct lpfc_mbx_set_beacon_config beacon_config;
3133 - struct lpfc_mbx_supp_pages supp_pages;
3134 - struct lpfc_mbx_pc_sli4_params sli4_params;
3135 struct lpfc_mbx_get_sli4_parameters get_sli4_parameters;
3136 struct lpfc_mbx_set_link_diag_state link_diag_state;
3137 struct lpfc_mbx_set_link_diag_loopback link_diag_loopback;
3138 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
3139 index d4c83eca0ad2c..b5cee2a2ac66c 100644
3140 --- a/drivers/scsi/lpfc/lpfc_init.c
3141 +++ b/drivers/scsi/lpfc/lpfc_init.c
3142 @@ -6415,8 +6415,6 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
3143 LPFC_MBOXQ_t *mboxq;
3144 MAILBOX_t *mb;
3145 int rc, i, max_buf_size;
3146 - uint8_t pn_page[LPFC_MAX_SUPPORTED_PAGES] = {0};
3147 - struct lpfc_mqe *mqe;
3148 int longs;
3149 int extra;
3150 uint64_t wwn;
3151 @@ -6640,32 +6638,6 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
3152
3153 lpfc_nvme_mod_param_dep(phba);
3154
3155 - /* Get the Supported Pages if PORT_CAPABILITIES is supported by port. */
3156 - lpfc_supported_pages(mboxq);
3157 - rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
3158 - if (!rc) {
3159 - mqe = &mboxq->u.mqe;
3160 - memcpy(&pn_page[0], ((uint8_t *)&mqe->un.supp_pages.word3),
3161 - LPFC_MAX_SUPPORTED_PAGES);
3162 - for (i = 0; i < LPFC_MAX_SUPPORTED_PAGES; i++) {
3163 - switch (pn_page[i]) {
3164 - case LPFC_SLI4_PARAMETERS:
3165 - phba->sli4_hba.pc_sli4_params.supported = 1;
3166 - break;
3167 - default:
3168 - break;
3169 - }
3170 - }
3171 - /* Read the port's SLI4 Parameters capabilities if supported. */
3172 - if (phba->sli4_hba.pc_sli4_params.supported)
3173 - rc = lpfc_pc_sli4_params_get(phba, mboxq);
3174 - if (rc) {
3175 - mempool_free(mboxq, phba->mbox_mem_pool);
3176 - rc = -EIO;
3177 - goto out_free_bsmbx;
3178 - }
3179 - }
3180 -
3181 /*
3182 * Get sli4 parameters that override parameters from Port capabilities.
3183 * If this call fails, it isn't critical unless the SLI4 parameters come
3184 @@ -9387,8 +9359,7 @@ lpfc_sli4_queue_setup(struct lpfc_hba *phba)
3185 "3250 QUERY_FW_CFG mailbox failed with status "
3186 "x%x add_status x%x, mbx status x%x\n",
3187 shdr_status, shdr_add_status, rc);
3188 - if (rc != MBX_TIMEOUT)
3189 - mempool_free(mboxq, phba->mbox_mem_pool);
3190 + mempool_free(mboxq, phba->mbox_mem_pool);
3191 rc = -ENXIO;
3192 goto out_error;
3193 }
3194 @@ -9404,8 +9375,7 @@ lpfc_sli4_queue_setup(struct lpfc_hba *phba)
3195 "ulp1_mode:x%x\n", phba->sli4_hba.fw_func_mode,
3196 phba->sli4_hba.ulp0_mode, phba->sli4_hba.ulp1_mode);
3197
3198 - if (rc != MBX_TIMEOUT)
3199 - mempool_free(mboxq, phba->mbox_mem_pool);
3200 + mempool_free(mboxq, phba->mbox_mem_pool);
3201
3202 /*
3203 * Set up HBA Event Queues (EQs)
3204 @@ -10001,8 +9971,7 @@ lpfc_pci_function_reset(struct lpfc_hba *phba)
3205 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response);
3206 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status,
3207 &shdr->response);
3208 - if (rc != MBX_TIMEOUT)
3209 - mempool_free(mboxq, phba->mbox_mem_pool);
3210 + mempool_free(mboxq, phba->mbox_mem_pool);
3211 if (shdr_status || shdr_add_status || rc) {
3212 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3213 "0495 SLI_FUNCTION_RESET mailbox "
3214 @@ -11577,78 +11546,6 @@ lpfc_sli4_hba_unset(struct lpfc_hba *phba)
3215 phba->pport->work_port_events = 0;
3216 }
3217
3218 - /**
3219 - * lpfc_pc_sli4_params_get - Get the SLI4_PARAMS port capabilities.
3220 - * @phba: Pointer to HBA context object.
3221 - * @mboxq: Pointer to the mailboxq memory for the mailbox command response.
3222 - *
3223 - * This function is called in the SLI4 code path to read the port's
3224 - * sli4 capabilities.
3225 - *
3226 - * This function may be be called from any context that can block-wait
3227 - * for the completion. The expectation is that this routine is called
3228 - * typically from probe_one or from the online routine.
3229 - **/
3230 -int
3231 -lpfc_pc_sli4_params_get(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
3232 -{
3233 - int rc;
3234 - struct lpfc_mqe *mqe;
3235 - struct lpfc_pc_sli4_params *sli4_params;
3236 - uint32_t mbox_tmo;
3237 -
3238 - rc = 0;
3239 - mqe = &mboxq->u.mqe;
3240 -
3241 - /* Read the port's SLI4 Parameters port capabilities */
3242 - lpfc_pc_sli4_params(mboxq);
3243 - if (!phba->sli4_hba.intr_enable)
3244 - rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
3245 - else {
3246 - mbox_tmo = lpfc_mbox_tmo_val(phba, mboxq);
3247 - rc = lpfc_sli_issue_mbox_wait(phba, mboxq, mbox_tmo);
3248 - }
3249 -
3250 - if (unlikely(rc))
3251 - return 1;
3252 -
3253 - sli4_params = &phba->sli4_hba.pc_sli4_params;
3254 - sli4_params->if_type = bf_get(if_type, &mqe->un.sli4_params);
3255 - sli4_params->sli_rev = bf_get(sli_rev, &mqe->un.sli4_params);
3256 - sli4_params->sli_family = bf_get(sli_family, &mqe->un.sli4_params);
3257 - sli4_params->featurelevel_1 = bf_get(featurelevel_1,
3258 - &mqe->un.sli4_params);
3259 - sli4_params->featurelevel_2 = bf_get(featurelevel_2,
3260 - &mqe->un.sli4_params);
3261 - sli4_params->proto_types = mqe->un.sli4_params.word3;
3262 - sli4_params->sge_supp_len = mqe->un.sli4_params.sge_supp_len;
3263 - sli4_params->if_page_sz = bf_get(if_page_sz, &mqe->un.sli4_params);
3264 - sli4_params->rq_db_window = bf_get(rq_db_window, &mqe->un.sli4_params);
3265 - sli4_params->loopbk_scope = bf_get(loopbk_scope, &mqe->un.sli4_params);
3266 - sli4_params->eq_pages_max = bf_get(eq_pages, &mqe->un.sli4_params);
3267 - sli4_params->eqe_size = bf_get(eqe_size, &mqe->un.sli4_params);
3268 - sli4_params->cq_pages_max = bf_get(cq_pages, &mqe->un.sli4_params);
3269 - sli4_params->cqe_size = bf_get(cqe_size, &mqe->un.sli4_params);
3270 - sli4_params->mq_pages_max = bf_get(mq_pages, &mqe->un.sli4_params);
3271 - sli4_params->mqe_size = bf_get(mqe_size, &mqe->un.sli4_params);
3272 - sli4_params->mq_elem_cnt = bf_get(mq_elem_cnt, &mqe->un.sli4_params);
3273 - sli4_params->wq_pages_max = bf_get(wq_pages, &mqe->un.sli4_params);
3274 - sli4_params->wqe_size = bf_get(wqe_size, &mqe->un.sli4_params);
3275 - sli4_params->rq_pages_max = bf_get(rq_pages, &mqe->un.sli4_params);
3276 - sli4_params->rqe_size = bf_get(rqe_size, &mqe->un.sli4_params);
3277 - sli4_params->hdr_pages_max = bf_get(hdr_pages, &mqe->un.sli4_params);
3278 - sli4_params->hdr_size = bf_get(hdr_size, &mqe->un.sli4_params);
3279 - sli4_params->hdr_pp_align = bf_get(hdr_pp_align, &mqe->un.sli4_params);
3280 - sli4_params->sgl_pages_max = bf_get(sgl_pages, &mqe->un.sli4_params);
3281 - sli4_params->sgl_pp_align = bf_get(sgl_pp_align, &mqe->un.sli4_params);
3282 -
3283 - /* Make sure that sge_supp_len can be handled by the driver */
3284 - if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE)
3285 - sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE;
3286 -
3287 - return rc;
3288 -}
3289 -
3290 /**
3291 * lpfc_get_sli4_parameters - Get the SLI4 Config PARAMETERS.
3292 * @phba: Pointer to HBA context object.
3293 @@ -11707,7 +11604,8 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
3294 else
3295 phba->sli3_options &= ~LPFC_SLI4_PHWQ_ENABLED;
3296 sli4_params->sge_supp_len = mbx_sli4_parameters->sge_supp_len;
3297 - sli4_params->loopbk_scope = bf_get(loopbk_scope, mbx_sli4_parameters);
3298 + sli4_params->loopbk_scope = bf_get(cfg_loopbk_scope,
3299 + mbx_sli4_parameters);
3300 sli4_params->oas_supported = bf_get(cfg_oas, mbx_sli4_parameters);
3301 sli4_params->cqv = bf_get(cfg_cqv, mbx_sli4_parameters);
3302 sli4_params->mqv = bf_get(cfg_mqv, mbx_sli4_parameters);
3303 diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c
3304 index 8abe933bad090..4a331164086e2 100644
3305 --- a/drivers/scsi/lpfc/lpfc_mbox.c
3306 +++ b/drivers/scsi/lpfc/lpfc_mbox.c
3307 @@ -2622,39 +2622,3 @@ lpfc_resume_rpi(struct lpfcMboxq *mbox, struct lpfc_nodelist *ndlp)
3308 resume_rpi->event_tag = ndlp->phba->fc_eventTag;
3309 }
3310
3311 -/**
3312 - * lpfc_supported_pages - Initialize the PORT_CAPABILITIES supported pages
3313 - * mailbox command.
3314 - * @mbox: pointer to lpfc mbox command to initialize.
3315 - *
3316 - * The PORT_CAPABILITIES supported pages mailbox command is issued to
3317 - * retrieve the particular feature pages supported by the port.
3318 - **/
3319 -void
3320 -lpfc_supported_pages(struct lpfcMboxq *mbox)
3321 -{
3322 - struct lpfc_mbx_supp_pages *supp_pages;
3323 -
3324 - memset(mbox, 0, sizeof(*mbox));
3325 - supp_pages = &mbox->u.mqe.un.supp_pages;
3326 - bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_PORT_CAPABILITIES);
3327 - bf_set(cpn, supp_pages, LPFC_SUPP_PAGES);
3328 -}
3329 -
3330 -/**
3331 - * lpfc_pc_sli4_params - Initialize the PORT_CAPABILITIES SLI4 Params mbox cmd.
3332 - * @mbox: pointer to lpfc mbox command to initialize.
3333 - *
3334 - * The PORT_CAPABILITIES SLI4 parameters mailbox command is issued to
3335 - * retrieve the particular SLI4 features supported by the port.
3336 - **/
3337 -void
3338 -lpfc_pc_sli4_params(struct lpfcMboxq *mbox)
3339 -{
3340 - struct lpfc_mbx_pc_sli4_params *sli4_params;
3341 -
3342 - memset(mbox, 0, sizeof(*mbox));
3343 - sli4_params = &mbox->u.mqe.un.sli4_params;
3344 - bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_PORT_CAPABILITIES);
3345 - bf_set(cpn, sli4_params, LPFC_SLI4_PARAMETERS);
3346 -}
3347 diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
3348 index 418d62e945544..fdd87508c804d 100644
3349 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c
3350 +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
3351 @@ -888,9 +888,14 @@ lpfc_rcv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
3352 }
3353 } else if ((!(ndlp->nlp_type & NLP_FABRIC) &&
3354 ((ndlp->nlp_type & NLP_FCP_TARGET) ||
3355 - !(ndlp->nlp_type & NLP_FCP_INITIATOR))) ||
3356 + (ndlp->nlp_type & NLP_NVME_TARGET) ||
3357 + (vport->fc_flag & FC_PT2PT))) ||
3358 (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) {
3359 - /* Only try to re-login if this is NOT a Fabric Node */
3360 + /* Only try to re-login if this is NOT a Fabric Node
3361 + * AND the remote NPORT is a FCP/NVME Target or we
3362 + * are in pt2pt mode. NLP_STE_ADISC_ISSUE is a special
3363 + * case for LOGO as a response to ADISC behavior.
3364 + */
3365 mod_timer(&ndlp->nlp_delayfunc,
3366 jiffies + msecs_to_jiffies(1000 * 1));
3367 spin_lock_irq(shost->host_lock);
3368 @@ -1956,8 +1961,6 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport,
3369 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
3370
3371 lpfc_issue_els_logo(vport, ndlp, 0);
3372 - ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
3373 - lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
3374 return ndlp->nlp_state;
3375 }
3376
3377 diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
3378 index f14394ab0e037..ce2e2b58fa7e6 100644
3379 --- a/drivers/scsi/lpfc/lpfc_nvmet.c
3380 +++ b/drivers/scsi/lpfc/lpfc_nvmet.c
3381 @@ -3204,7 +3204,6 @@ lpfc_nvmet_unsol_issue_abort(struct lpfc_hba *phba,
3382 bf_set(wqe_rcvoxid, &wqe_abts->xmit_sequence.wqe_com, xri);
3383
3384 /* Word 10 */
3385 - bf_set(wqe_dbde, &wqe_abts->xmit_sequence.wqe_com, 1);
3386 bf_set(wqe_iod, &wqe_abts->xmit_sequence.wqe_com, LPFC_WQE_IOD_WRITE);
3387 bf_set(wqe_lenloc, &wqe_abts->xmit_sequence.wqe_com,
3388 LPFC_WQE_LENLOC_WORD12);
3389 diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
3390 index b9857d7b224fb..ef7cef316d210 100644
3391 --- a/drivers/scsi/lpfc/lpfc_sli.c
3392 +++ b/drivers/scsi/lpfc/lpfc_sli.c
3393 @@ -5423,12 +5423,10 @@ lpfc_sli4_get_ctl_attr(struct lpfc_hba *phba)
3394 phba->sli4_hba.lnk_info.lnk_no,
3395 phba->BIOSVersion);
3396 out_free_mboxq:
3397 - if (rc != MBX_TIMEOUT) {
3398 - if (bf_get(lpfc_mqe_command, &mboxq->u.mqe) == MBX_SLI4_CONFIG)
3399 - lpfc_sli4_mbox_cmd_free(phba, mboxq);
3400 - else
3401 - mempool_free(mboxq, phba->mbox_mem_pool);
3402 - }
3403 + if (bf_get(lpfc_mqe_command, &mboxq->u.mqe) == MBX_SLI4_CONFIG)
3404 + lpfc_sli4_mbox_cmd_free(phba, mboxq);
3405 + else
3406 + mempool_free(mboxq, phba->mbox_mem_pool);
3407 return rc;
3408 }
3409
3410 @@ -5529,12 +5527,10 @@ retrieve_ppname:
3411 }
3412
3413 out_free_mboxq:
3414 - if (rc != MBX_TIMEOUT) {
3415 - if (bf_get(lpfc_mqe_command, &mboxq->u.mqe) == MBX_SLI4_CONFIG)
3416 - lpfc_sli4_mbox_cmd_free(phba, mboxq);
3417 - else
3418 - mempool_free(mboxq, phba->mbox_mem_pool);
3419 - }
3420 + if (bf_get(lpfc_mqe_command, &mboxq->u.mqe) == MBX_SLI4_CONFIG)
3421 + lpfc_sli4_mbox_cmd_free(phba, mboxq);
3422 + else
3423 + mempool_free(mboxq, phba->mbox_mem_pool);
3424 return rc;
3425 }
3426
3427 @@ -16485,8 +16481,7 @@ lpfc_rq_destroy(struct lpfc_hba *phba, struct lpfc_queue *hrq,
3428 "2509 RQ_DESTROY mailbox failed with "
3429 "status x%x add_status x%x, mbx status x%x\n",
3430 shdr_status, shdr_add_status, rc);
3431 - if (rc != MBX_TIMEOUT)
3432 - mempool_free(mbox, hrq->phba->mbox_mem_pool);
3433 + mempool_free(mbox, hrq->phba->mbox_mem_pool);
3434 return -ENXIO;
3435 }
3436 bf_set(lpfc_mbx_rq_destroy_q_id, &mbox->u.mqe.un.rq_destroy.u.request,
3437 @@ -16583,7 +16578,9 @@ lpfc_sli4_post_sgl(struct lpfc_hba *phba,
3438 shdr = (union lpfc_sli4_cfg_shdr *) &post_sgl_pages->header.cfg_shdr;
3439 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response);
3440 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response);
3441 - if (rc != MBX_TIMEOUT)
3442 + if (!phba->sli4_hba.intr_enable)
3443 + mempool_free(mbox, phba->mbox_mem_pool);
3444 + else if (rc != MBX_TIMEOUT)
3445 mempool_free(mbox, phba->mbox_mem_pool);
3446 if (shdr_status || shdr_add_status || rc) {
3447 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3448 @@ -16778,7 +16775,9 @@ lpfc_sli4_post_sgl_list(struct lpfc_hba *phba,
3449 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr;
3450 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response);
3451 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response);
3452 - if (rc != MBX_TIMEOUT)
3453 + if (!phba->sli4_hba.intr_enable)
3454 + lpfc_sli4_mbox_cmd_free(phba, mbox);
3455 + else if (rc != MBX_TIMEOUT)
3456 lpfc_sli4_mbox_cmd_free(phba, mbox);
3457 if (shdr_status || shdr_add_status || rc) {
3458 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
3459 @@ -16891,7 +16890,9 @@ lpfc_sli4_post_io_sgl_block(struct lpfc_hba *phba, struct list_head *nblist,
3460 shdr = (union lpfc_sli4_cfg_shdr *)&sgl->cfg_shdr;
3461 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response);
3462 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response);
3463 - if (rc != MBX_TIMEOUT)
3464 + if (!phba->sli4_hba.intr_enable)
3465 + lpfc_sli4_mbox_cmd_free(phba, mbox);
3466 + else if (rc != MBX_TIMEOUT)
3467 lpfc_sli4_mbox_cmd_free(phba, mbox);
3468 if (shdr_status || shdr_add_status || rc) {
3469 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
3470 @@ -17472,7 +17473,6 @@ lpfc_sli4_seq_abort_rsp_cmpl(struct lpfc_hba *phba,
3471 if (cmd_iocbq) {
3472 ndlp = (struct lpfc_nodelist *)cmd_iocbq->context1;
3473 lpfc_nlp_put(ndlp);
3474 - lpfc_nlp_not_used(ndlp);
3475 lpfc_sli_release_iocbq(phba, cmd_iocbq);
3476 }
3477
3478 @@ -18239,8 +18239,7 @@ lpfc_sli4_post_rpi_hdr(struct lpfc_hba *phba, struct lpfc_rpi_hdr *rpi_page)
3479 shdr = (union lpfc_sli4_cfg_shdr *) &hdr_tmpl->header.cfg_shdr;
3480 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response);
3481 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response);
3482 - if (rc != MBX_TIMEOUT)
3483 - mempool_free(mboxq, phba->mbox_mem_pool);
3484 + mempool_free(mboxq, phba->mbox_mem_pool);
3485 if (shdr_status || shdr_add_status || rc) {
3486 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3487 "2514 POST_RPI_HDR mailbox failed with "
3488 @@ -19465,7 +19464,9 @@ lpfc_wr_object(struct lpfc_hba *phba, struct list_head *dmabuf_list,
3489 break;
3490 }
3491 }
3492 - if (rc != MBX_TIMEOUT)
3493 + if (!phba->sli4_hba.intr_enable)
3494 + mempool_free(mbox, phba->mbox_mem_pool);
3495 + else if (rc != MBX_TIMEOUT)
3496 mempool_free(mbox, phba->mbox_mem_pool);
3497 if (shdr_status || shdr_add_status || rc) {
3498 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3499 diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
3500 index b6d42b2ce6fe4..e72f1dbc91f7f 100644
3501 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
3502 +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
3503 @@ -6572,6 +6572,8 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc)
3504
3505 ioc_info(ioc, "sending diag reset !!\n");
3506
3507 + pci_cfg_access_lock(ioc->pdev);
3508 +
3509 drsprintk(ioc, ioc_info(ioc, "clear interrupts\n"));
3510
3511 count = 0;
3512 @@ -6653,10 +6655,12 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc)
3513 goto out;
3514 }
3515
3516 + pci_cfg_access_unlock(ioc->pdev);
3517 ioc_info(ioc, "diag reset: SUCCESS\n");
3518 return 0;
3519
3520 out:
3521 + pci_cfg_access_unlock(ioc->pdev);
3522 ioc_err(ioc, "diag reset: FAILED\n");
3523 return -EFAULT;
3524 }
3525 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
3526 index bed7e86372174..580d30cd5c35c 100644
3527 --- a/drivers/scsi/qla2xxx/qla_attr.c
3528 +++ b/drivers/scsi/qla2xxx/qla_attr.c
3529 @@ -2691,6 +2691,8 @@ qla2x00_reset_host_stats(struct Scsi_Host *shost)
3530 vha->qla_stats.jiffies_at_last_reset = get_jiffies_64();
3531
3532 if (IS_FWI2_CAPABLE(ha)) {
3533 + int rval;
3534 +
3535 stats = dma_alloc_coherent(&ha->pdev->dev,
3536 sizeof(*stats), &stats_dma, GFP_KERNEL);
3537 if (!stats) {
3538 @@ -2700,7 +2702,11 @@ qla2x00_reset_host_stats(struct Scsi_Host *shost)
3539 }
3540
3541 /* reset firmware statistics */
3542 - qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
3543 + rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
3544 + if (rval != QLA_SUCCESS)
3545 + ql_log(ql_log_warn, vha, 0x70de,
3546 + "Resetting ISP statistics failed: rval = %d\n",
3547 + rval);
3548
3549 dma_free_coherent(&ha->pdev->dev, sizeof(*stats),
3550 stats, stats_dma);
3551 diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
3552 index cbaf178fc9796..ce55121910e89 100644
3553 --- a/drivers/scsi/qla2xxx/qla_bsg.c
3554 +++ b/drivers/scsi/qla2xxx/qla_bsg.c
3555 @@ -17,10 +17,11 @@ void qla2x00_bsg_job_done(srb_t *sp, int res)
3556 struct bsg_job *bsg_job = sp->u.bsg_job;
3557 struct fc_bsg_reply *bsg_reply = bsg_job->reply;
3558
3559 + sp->free(sp);
3560 +
3561 bsg_reply->result = res;
3562 bsg_job_done(bsg_job, bsg_reply->result,
3563 bsg_reply->reply_payload_rcv_len);
3564 - sp->free(sp);
3565 }
3566
3567 void qla2x00_bsg_sp_free(srb_t *sp)
3568 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
3569 index af8306a9777fc..052ce78814075 100644
3570 --- a/drivers/scsi/qla2xxx/qla_os.c
3571 +++ b/drivers/scsi/qla2xxx/qla_os.c
3572 @@ -983,8 +983,6 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd,
3573 if (rval != QLA_SUCCESS) {
3574 ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3078,
3575 "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd);
3576 - if (rval == QLA_INTERFACE_ERROR)
3577 - goto qc24_free_sp_fail_command;
3578 goto qc24_host_busy_free_sp;
3579 }
3580
3581 @@ -996,11 +994,6 @@ qc24_host_busy_free_sp:
3582 qc24_target_busy:
3583 return SCSI_MLQUEUE_TARGET_BUSY;
3584
3585 -qc24_free_sp_fail_command:
3586 - sp->free(sp);
3587 - CMD_SP(cmd) = NULL;
3588 - qla2xxx_rel_qpair_sp(sp->qpair, sp);
3589 -
3590 qc24_fail_command:
3591 cmd->scsi_done(cmd);
3592
3593 diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
3594 index 093ed5d1eef20..9bc451004184f 100644
3595 --- a/drivers/scsi/smartpqi/smartpqi_init.c
3596 +++ b/drivers/scsi/smartpqi/smartpqi_init.c
3597 @@ -5513,6 +5513,8 @@ static void pqi_fail_io_queued_for_device(struct pqi_ctrl_info *ctrl_info,
3598
3599 list_del(&io_request->request_list_entry);
3600 set_host_byte(scmd, DID_RESET);
3601 + pqi_free_io_request(io_request);
3602 + scsi_dma_unmap(scmd);
3603 pqi_scsi_done(scmd);
3604 }
3605
3606 @@ -5549,6 +5551,8 @@ static void pqi_fail_io_queued_for_all_devices(struct pqi_ctrl_info *ctrl_info)
3607
3608 list_del(&io_request->request_list_entry);
3609 set_host_byte(scmd, DID_RESET);
3610 + pqi_free_io_request(io_request);
3611 + scsi_dma_unmap(scmd);
3612 pqi_scsi_done(scmd);
3613 }
3614
3615 @@ -8142,6 +8146,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {
3616 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3617 0x152d, 0x8a37)
3618 },
3619 + {
3620 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3621 + 0x193d, 0x8460)
3622 + },
3623 {
3624 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3625 0x193d, 0x1104)
3626 @@ -8214,6 +8222,22 @@ static const struct pci_device_id pqi_pci_id_table[] = {
3627 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3628 0x1bd4, 0x004f)
3629 },
3630 + {
3631 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3632 + 0x1bd4, 0x0051)
3633 + },
3634 + {
3635 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3636 + 0x1bd4, 0x0052)
3637 + },
3638 + {
3639 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3640 + 0x1bd4, 0x0053)
3641 + },
3642 + {
3643 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3644 + 0x1bd4, 0x0054)
3645 + },
3646 {
3647 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3648 0x19e5, 0xd227)
3649 @@ -8370,6 +8394,122 @@ static const struct pci_device_id pqi_pci_id_table[] = {
3650 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3651 PCI_VENDOR_ID_ADAPTEC2, 0x1380)
3652 },
3653 + {
3654 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3655 + PCI_VENDOR_ID_ADAPTEC2, 0x1400)
3656 + },
3657 + {
3658 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3659 + PCI_VENDOR_ID_ADAPTEC2, 0x1402)
3660 + },
3661 + {
3662 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3663 + PCI_VENDOR_ID_ADAPTEC2, 0x1410)
3664 + },
3665 + {
3666 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3667 + PCI_VENDOR_ID_ADAPTEC2, 0x1411)
3668 + },
3669 + {
3670 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3671 + PCI_VENDOR_ID_ADAPTEC2, 0x1412)
3672 + },
3673 + {
3674 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3675 + PCI_VENDOR_ID_ADAPTEC2, 0x1420)
3676 + },
3677 + {
3678 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3679 + PCI_VENDOR_ID_ADAPTEC2, 0x1430)
3680 + },
3681 + {
3682 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3683 + PCI_VENDOR_ID_ADAPTEC2, 0x1440)
3684 + },
3685 + {
3686 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3687 + PCI_VENDOR_ID_ADAPTEC2, 0x1441)
3688 + },
3689 + {
3690 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3691 + PCI_VENDOR_ID_ADAPTEC2, 0x1450)
3692 + },
3693 + {
3694 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3695 + PCI_VENDOR_ID_ADAPTEC2, 0x1452)
3696 + },
3697 + {
3698 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3699 + PCI_VENDOR_ID_ADAPTEC2, 0x1460)
3700 + },
3701 + {
3702 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3703 + PCI_VENDOR_ID_ADAPTEC2, 0x1461)
3704 + },
3705 + {
3706 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3707 + PCI_VENDOR_ID_ADAPTEC2, 0x1462)
3708 + },
3709 + {
3710 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3711 + PCI_VENDOR_ID_ADAPTEC2, 0x1470)
3712 + },
3713 + {
3714 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3715 + PCI_VENDOR_ID_ADAPTEC2, 0x1471)
3716 + },
3717 + {
3718 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3719 + PCI_VENDOR_ID_ADAPTEC2, 0x1472)
3720 + },
3721 + {
3722 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3723 + PCI_VENDOR_ID_ADAPTEC2, 0x1480)
3724 + },
3725 + {
3726 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3727 + PCI_VENDOR_ID_ADAPTEC2, 0x1490)
3728 + },
3729 + {
3730 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3731 + PCI_VENDOR_ID_ADAPTEC2, 0x1491)
3732 + },
3733 + {
3734 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3735 + PCI_VENDOR_ID_ADAPTEC2, 0x14a0)
3736 + },
3737 + {
3738 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3739 + PCI_VENDOR_ID_ADAPTEC2, 0x14a1)
3740 + },
3741 + {
3742 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3743 + PCI_VENDOR_ID_ADAPTEC2, 0x14b0)
3744 + },
3745 + {
3746 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3747 + PCI_VENDOR_ID_ADAPTEC2, 0x14b1)
3748 + },
3749 + {
3750 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3751 + PCI_VENDOR_ID_ADAPTEC2, 0x14c0)
3752 + },
3753 + {
3754 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3755 + PCI_VENDOR_ID_ADAPTEC2, 0x14c1)
3756 + },
3757 + {
3758 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3759 + PCI_VENDOR_ID_ADAPTEC2, 0x14d0)
3760 + },
3761 + {
3762 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3763 + PCI_VENDOR_ID_ADAPTEC2, 0x14e0)
3764 + },
3765 + {
3766 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3767 + PCI_VENDOR_ID_ADAPTEC2, 0x14f0)
3768 + },
3769 {
3770 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3771 PCI_VENDOR_ID_ADVANTECH, 0x8312)
3772 @@ -8434,6 +8574,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {
3773 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3774 PCI_VENDOR_ID_HP, 0x1001)
3775 },
3776 + {
3777 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3778 + PCI_VENDOR_ID_HP, 0x1002)
3779 + },
3780 {
3781 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3782 PCI_VENDOR_ID_HP, 0x1100)
3783 @@ -8442,6 +8586,22 @@ static const struct pci_device_id pqi_pci_id_table[] = {
3784 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3785 PCI_VENDOR_ID_HP, 0x1101)
3786 },
3787 + {
3788 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3789 + 0x1590, 0x0294)
3790 + },
3791 + {
3792 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3793 + 0x1590, 0x02db)
3794 + },
3795 + {
3796 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3797 + 0x1590, 0x02dc)
3798 + },
3799 + {
3800 + PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3801 + 0x1590, 0x032e)
3802 + },
3803 {
3804 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
3805 0x1d8d, 0x0800)
3806 diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c
3807 index eb9a243e95265..98ace748cd986 100644
3808 --- a/drivers/spi/spi-ath79.c
3809 +++ b/drivers/spi/spi-ath79.c
3810 @@ -156,8 +156,7 @@ static int ath79_spi_probe(struct platform_device *pdev)
3811
3812 master->use_gpio_descriptors = true;
3813 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
3814 - master->setup = spi_bitbang_setup;
3815 - master->cleanup = spi_bitbang_cleanup;
3816 + master->flags = SPI_MASTER_GPIO_SS;
3817 if (pdata) {
3818 master->bus_num = pdata->bus_num;
3819 master->num_chipselect = pdata->num_chipselect;
3820 diff --git a/drivers/spi/spi-dln2.c b/drivers/spi/spi-dln2.c
3821 index 75b33d7d14b04..9a4d942fafcf5 100644
3822 --- a/drivers/spi/spi-dln2.c
3823 +++ b/drivers/spi/spi-dln2.c
3824 @@ -780,7 +780,7 @@ exit_free_master:
3825
3826 static int dln2_spi_remove(struct platform_device *pdev)
3827 {
3828 - struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
3829 + struct spi_master *master = platform_get_drvdata(pdev);
3830 struct dln2_spi *dln2 = spi_master_get_devdata(master);
3831
3832 pm_runtime_disable(&pdev->dev);
3833 diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c
3834 index b955ca8796d2d..b8e201c094843 100644
3835 --- a/drivers/spi/spi-omap-100k.c
3836 +++ b/drivers/spi/spi-omap-100k.c
3837 @@ -426,7 +426,7 @@ err:
3838
3839 static int omap1_spi100k_remove(struct platform_device *pdev)
3840 {
3841 - struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
3842 + struct spi_master *master = platform_get_drvdata(pdev);
3843 struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
3844
3845 pm_runtime_disable(&pdev->dev);
3846 @@ -440,7 +440,7 @@ static int omap1_spi100k_remove(struct platform_device *pdev)
3847 #ifdef CONFIG_PM
3848 static int omap1_spi100k_runtime_suspend(struct device *dev)
3849 {
3850 - struct spi_master *master = spi_master_get(dev_get_drvdata(dev));
3851 + struct spi_master *master = dev_get_drvdata(dev);
3852 struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
3853
3854 clk_disable_unprepare(spi100k->ick);
3855 @@ -451,7 +451,7 @@ static int omap1_spi100k_runtime_suspend(struct device *dev)
3856
3857 static int omap1_spi100k_runtime_resume(struct device *dev)
3858 {
3859 - struct spi_master *master = spi_master_get(dev_get_drvdata(dev));
3860 + struct spi_master *master = dev_get_drvdata(dev);
3861 struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
3862 int ret;
3863
3864 diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
3865 index fa8079fbea77a..d1dfb52008b4a 100644
3866 --- a/drivers/spi/spi-qup.c
3867 +++ b/drivers/spi/spi-qup.c
3868 @@ -1263,7 +1263,7 @@ static int spi_qup_remove(struct platform_device *pdev)
3869 struct spi_qup *controller = spi_master_get_devdata(master);
3870 int ret;
3871
3872 - ret = pm_runtime_get_sync(&pdev->dev);
3873 + ret = pm_runtime_resume_and_get(&pdev->dev);
3874 if (ret < 0)
3875 return ret;
3876
3877 diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
3878 index cad2abcbd9c78..6b6ef89442837 100644
3879 --- a/drivers/spi/spi-ti-qspi.c
3880 +++ b/drivers/spi/spi-ti-qspi.c
3881 @@ -656,6 +656,17 @@ static int ti_qspi_runtime_resume(struct device *dev)
3882 return 0;
3883 }
3884
3885 +static void ti_qspi_dma_cleanup(struct ti_qspi *qspi)
3886 +{
3887 + if (qspi->rx_bb_addr)
3888 + dma_free_coherent(qspi->dev, QSPI_DMA_BUFFER_SIZE,
3889 + qspi->rx_bb_addr,
3890 + qspi->rx_bb_dma_addr);
3891 +
3892 + if (qspi->rx_chan)
3893 + dma_release_channel(qspi->rx_chan);
3894 +}
3895 +
3896 static const struct of_device_id ti_qspi_match[] = {
3897 {.compatible = "ti,dra7xxx-qspi" },
3898 {.compatible = "ti,am4372-qspi" },
3899 @@ -809,6 +820,8 @@ no_dma:
3900 if (!ret)
3901 return 0;
3902
3903 + ti_qspi_dma_cleanup(qspi);
3904 +
3905 pm_runtime_disable(&pdev->dev);
3906 free_master:
3907 spi_master_put(master);
3908 @@ -827,12 +840,7 @@ static int ti_qspi_remove(struct platform_device *pdev)
3909 pm_runtime_put_sync(&pdev->dev);
3910 pm_runtime_disable(&pdev->dev);
3911
3912 - if (qspi->rx_bb_addr)
3913 - dma_free_coherent(qspi->dev, QSPI_DMA_BUFFER_SIZE,
3914 - qspi->rx_bb_addr,
3915 - qspi->rx_bb_dma_addr);
3916 - if (qspi->rx_chan)
3917 - dma_release_channel(qspi->rx_chan);
3918 + ti_qspi_dma_cleanup(qspi);
3919
3920 return 0;
3921 }
3922 diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
3923 index d151cd6d31884..fabbfceaa1077 100644
3924 --- a/drivers/staging/media/imx/imx-media-capture.c
3925 +++ b/drivers/staging/media/imx/imx-media-capture.c
3926 @@ -553,7 +553,7 @@ static int capture_validate_fmt(struct capture_priv *priv)
3927 priv->vdev.fmt.fmt.pix.height != f.fmt.pix.height ||
3928 priv->vdev.cc->cs != cc->cs ||
3929 priv->vdev.compose.width != compose.width ||
3930 - priv->vdev.compose.height != compose.height) ? -EINVAL : 0;
3931 + priv->vdev.compose.height != compose.height) ? -EPIPE : 0;
3932 }
3933
3934 static int capture_start_streaming(struct vb2_queue *vq, unsigned int count)
3935 diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
3936 index c764cb55dc8d9..908ae74aa970d 100644
3937 --- a/drivers/staging/media/ipu3/ipu3-v4l2.c
3938 +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
3939 @@ -685,6 +685,7 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
3940
3941 dev_dbg(dev, "IPU3 pipe %u pipe_id = %u", pipe, css_pipe->pipe_id);
3942
3943 + css_q = imgu_node_to_queue(node);
3944 for (i = 0; i < IPU3_CSS_QUEUES; i++) {
3945 unsigned int inode = imgu_map_node(imgu, i);
3946
3947 @@ -692,6 +693,18 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
3948 if (inode == IMGU_NODE_STAT_3A || inode == IMGU_NODE_PARAMS)
3949 continue;
3950
3951 + /* CSS expects some format on OUT queue */
3952 + if (i != IPU3_CSS_QUEUE_OUT &&
3953 + !imgu_pipe->nodes[inode].enabled) {
3954 + fmts[i] = NULL;
3955 + continue;
3956 + }
3957 +
3958 + if (i == css_q) {
3959 + fmts[i] = &f->fmt.pix_mp;
3960 + continue;
3961 + }
3962 +
3963 if (try) {
3964 fmts[i] = kmemdup(&imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp,
3965 sizeof(struct v4l2_pix_format_mplane),
3966 @@ -704,10 +717,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
3967 fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
3968 }
3969
3970 - /* CSS expects some format on OUT queue */
3971 - if (i != IPU3_CSS_QUEUE_OUT &&
3972 - !imgu_pipe->nodes[inode].enabled)
3973 - fmts[i] = NULL;
3974 }
3975
3976 if (!try) {
3977 @@ -724,16 +733,10 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
3978 rects[IPU3_CSS_RECT_GDC]->height = pad_fmt.height;
3979 }
3980
3981 - /*
3982 - * imgu doesn't set the node to the value given by user
3983 - * before we return success from this function, so set it here.
3984 - */
3985 - css_q = imgu_node_to_queue(node);
3986 if (!fmts[css_q]) {
3987 ret = -EINVAL;
3988 goto out;
3989 }
3990 - *fmts[css_q] = f->fmt.pix_mp;
3991
3992 if (try)
3993 ret = imgu_css_fmt_try(&imgu->css, fmts, rects, pipe);
3994 @@ -744,15 +747,18 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
3995 if (ret < 0)
3996 goto out;
3997
3998 - if (try)
3999 - f->fmt.pix_mp = *fmts[css_q];
4000 - else
4001 - f->fmt = imgu_pipe->nodes[node].vdev_fmt.fmt;
4002 + /*
4003 + * imgu doesn't set the node to the value given by user
4004 + * before we return success from this function, so set it here.
4005 + */
4006 + if (!try)
4007 + imgu_pipe->nodes[node].vdev_fmt.fmt.pix_mp = f->fmt.pix_mp;
4008
4009 out:
4010 if (try) {
4011 for (i = 0; i < IPU3_CSS_QUEUES; i++)
4012 - kfree(fmts[i]);
4013 + if (i != css_q)
4014 + kfree(fmts[i]);
4015 }
4016
4017 return ret;
4018 diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
4019 index 5a047ce77bc0b..55fe93296deb4 100644
4020 --- a/drivers/target/target_core_pscsi.c
4021 +++ b/drivers/target/target_core_pscsi.c
4022 @@ -620,8 +620,9 @@ static void pscsi_complete_cmd(struct se_cmd *cmd, u8 scsi_status,
4023 unsigned char *buf;
4024
4025 buf = transport_kmap_data_sg(cmd);
4026 - if (!buf)
4027 + if (!buf) {
4028 ; /* XXX: TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE */
4029 + }
4030
4031 if (cdb[0] == MODE_SENSE_10) {
4032 if (!(buf[3] & 0x80))
4033 diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
4034 index b830e0a87fbac..ba6cfba589a69 100644
4035 --- a/drivers/tee/optee/core.c
4036 +++ b/drivers/tee/optee/core.c
4037 @@ -78,16 +78,6 @@ int optee_from_msg_param(struct tee_param *params, size_t num_params,
4038 return rc;
4039 p->u.memref.shm_offs = mp->u.tmem.buf_ptr - pa;
4040 p->u.memref.shm = shm;
4041 -
4042 - /* Check that the memref is covered by the shm object */
4043 - if (p->u.memref.size) {
4044 - size_t o = p->u.memref.shm_offs +
4045 - p->u.memref.size - 1;
4046 -
4047 - rc = tee_shm_get_pa(shm, o, NULL);
4048 - if (rc)
4049 - return rc;
4050 - }
4051 break;
4052 case OPTEE_MSG_ATTR_TYPE_RMEM_INPUT:
4053 case OPTEE_MSG_ATTR_TYPE_RMEM_OUTPUT:
4054 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
4055 index 75408b9f232da..38eb49ba361f0 100644
4056 --- a/drivers/tty/n_gsm.c
4057 +++ b/drivers/tty/n_gsm.c
4058 @@ -2377,8 +2377,18 @@ static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
4059 /* Don't register device 0 - this is the control channel and not
4060 a usable tty interface */
4061 base = mux_num_to_base(gsm); /* Base for this MUX */
4062 - for (i = 1; i < NUM_DLCI; i++)
4063 - tty_register_device(gsm_tty_driver, base + i, NULL);
4064 + for (i = 1; i < NUM_DLCI; i++) {
4065 + struct device *dev;
4066 +
4067 + dev = tty_register_device(gsm_tty_driver,
4068 + base + i, NULL);
4069 + if (IS_ERR(dev)) {
4070 + for (i--; i >= 1; i--)
4071 + tty_unregister_device(gsm_tty_driver,
4072 + base + i);
4073 + return PTR_ERR(dev);
4074 + }
4075 + }
4076 }
4077 return ret;
4078 }
4079 diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
4080 index c55b6d7ccaf78..564e1fa2e4c94 100644
4081 --- a/drivers/tty/vt/vt.c
4082 +++ b/drivers/tty/vt/vt.c
4083 @@ -1377,6 +1377,7 @@ struct vc_data *vc_deallocate(unsigned int currcons)
4084 atomic_notifier_call_chain(&vt_notifier_list, VT_DEALLOCATE, &param);
4085 vcs_remove_sysfs(currcons);
4086 visual_deinit(vc);
4087 + con_free_unimap(vc);
4088 put_pid(vc->vt_pid);
4089 vc_uniscr_set(vc, NULL);
4090 kfree(vc->vc_screenbuf);
4091 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
4092 index 4d3de33885ffa..cd61860cada5e 100644
4093 --- a/drivers/usb/core/hub.c
4094 +++ b/drivers/usb/core/hub.c
4095 @@ -3537,7 +3537,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
4096 u16 portchange, portstatus;
4097
4098 if (!test_and_set_bit(port1, hub->child_usage_bits)) {
4099 - status = pm_runtime_get_sync(&port_dev->dev);
4100 + status = pm_runtime_resume_and_get(&port_dev->dev);
4101 if (status < 0) {
4102 dev_dbg(&udev->dev, "can't resume usb port, status %d\n",
4103 status);
4104 diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
4105 index 6272b4ae4740f..f73e78143ad14 100644
4106 --- a/drivers/usb/dwc2/core_intr.c
4107 +++ b/drivers/usb/dwc2/core_intr.c
4108 @@ -312,6 +312,7 @@ static void dwc2_handle_conn_id_status_change_intr(struct dwc2_hsotg *hsotg)
4109 static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg)
4110 {
4111 int ret;
4112 + u32 hprt0;
4113
4114 /* Clear interrupt */
4115 dwc2_writel(hsotg, GINTSTS_SESSREQINT, GINTSTS);
4116 @@ -332,6 +333,13 @@ static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg)
4117 * established
4118 */
4119 dwc2_hsotg_disconnect(hsotg);
4120 + } else {
4121 + /* Turn on the port power bit. */
4122 + hprt0 = dwc2_read_hprt0(hsotg);
4123 + hprt0 |= HPRT0_PWR;
4124 + dwc2_writel(hsotg, hprt0, HPRT0);
4125 + /* Connect hcd after port power is set. */
4126 + dwc2_hcd_connect(hsotg);
4127 }
4128 }
4129
4130 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
4131 index 904b0043011cf..af8efebfaf110 100644
4132 --- a/drivers/usb/dwc3/gadget.c
4133 +++ b/drivers/usb/dwc3/gadget.c
4134 @@ -304,13 +304,12 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
4135 }
4136
4137 if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
4138 - int needs_wakeup;
4139 + int link_state;
4140
4141 - needs_wakeup = (dwc->link_state == DWC3_LINK_STATE_U1 ||
4142 - dwc->link_state == DWC3_LINK_STATE_U2 ||
4143 - dwc->link_state == DWC3_LINK_STATE_U3);
4144 -
4145 - if (unlikely(needs_wakeup)) {
4146 + link_state = dwc3_gadget_get_link_state(dwc);
4147 + if (link_state == DWC3_LINK_STATE_U1 ||
4148 + link_state == DWC3_LINK_STATE_U2 ||
4149 + link_state == DWC3_LINK_STATE_U3) {
4150 ret = __dwc3_gadget_wakeup(dwc);
4151 dev_WARN_ONCE(dwc->dev, ret, "wakeup failed --> %d\n",
4152 ret);
4153 @@ -1862,6 +1861,8 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
4154 case DWC3_LINK_STATE_RESET:
4155 case DWC3_LINK_STATE_RX_DET: /* in HS, means Early Suspend */
4156 case DWC3_LINK_STATE_U3: /* in HS, means SUSPEND */
4157 + case DWC3_LINK_STATE_U2: /* in HS, means Sleep (L1) */
4158 + case DWC3_LINK_STATE_U1:
4159 case DWC3_LINK_STATE_RESUME:
4160 break;
4161 default:
4162 @@ -2986,6 +2987,15 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
4163
4164 dwc->connected = true;
4165
4166 + /*
4167 + * Ideally, dwc3_reset_gadget() would trigger the function
4168 + * drivers to stop any active transfers through ep disable.
4169 + * However, for functions which defer ep disable, such as mass
4170 + * storage, we will need to rely on the call to stop active
4171 + * transfers here, and avoid allowing of request queuing.
4172 + */
4173 + dwc->connected = false;
4174 +
4175 /*
4176 * WORKAROUND: DWC3 revisions <1.88a have an issue which
4177 * would cause a missing Disconnect Event if there's a
4178 diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
4179 index 2d115353424c2..8bb25773b61e9 100644
4180 --- a/drivers/usb/gadget/config.c
4181 +++ b/drivers/usb/gadget/config.c
4182 @@ -194,9 +194,13 @@ EXPORT_SYMBOL_GPL(usb_assign_descriptors);
4183 void usb_free_all_descriptors(struct usb_function *f)
4184 {
4185 usb_free_descriptors(f->fs_descriptors);
4186 + f->fs_descriptors = NULL;
4187 usb_free_descriptors(f->hs_descriptors);
4188 + f->hs_descriptors = NULL;
4189 usb_free_descriptors(f->ss_descriptors);
4190 + f->ss_descriptors = NULL;
4191 usb_free_descriptors(f->ssp_descriptors);
4192 + f->ssp_descriptors = NULL;
4193 }
4194 EXPORT_SYMBOL_GPL(usb_free_all_descriptors);
4195
4196 diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
4197 index df003bc67da07..aa56a080235c7 100644
4198 --- a/drivers/usb/gadget/function/f_fs.c
4199 +++ b/drivers/usb/gadget/function/f_fs.c
4200 @@ -2658,6 +2658,7 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
4201
4202 do { /* lang_count > 0 so we can use do-while */
4203 unsigned needed = needed_count;
4204 + u32 str_per_lang = str_count;
4205
4206 if (unlikely(len < 3))
4207 goto error_free;
4208 @@ -2693,7 +2694,7 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
4209
4210 data += length + 1;
4211 len -= length + 1;
4212 - } while (--str_count);
4213 + } while (--str_per_lang);
4214
4215 s->id = 0; /* terminator */
4216 s->s = NULL;
4217 diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c
4218 index 560382e0a8f38..e65f474ad7b3b 100644
4219 --- a/drivers/usb/gadget/function/f_uac1.c
4220 +++ b/drivers/usb/gadget/function/f_uac1.c
4221 @@ -19,6 +19,9 @@
4222 #include "u_audio.h"
4223 #include "u_uac1.h"
4224
4225 +/* UAC1 spec: 3.7.2.3 Audio Channel Cluster Format */
4226 +#define UAC1_CHANNEL_MASK 0x0FFF
4227 +
4228 struct f_uac1 {
4229 struct g_audio g_audio;
4230 u8 ac_intf, as_in_intf, as_out_intf;
4231 @@ -30,6 +33,11 @@ static inline struct f_uac1 *func_to_uac1(struct usb_function *f)
4232 return container_of(f, struct f_uac1, g_audio.func);
4233 }
4234
4235 +static inline struct f_uac1_opts *g_audio_to_uac1_opts(struct g_audio *audio)
4236 +{
4237 + return container_of(audio->func.fi, struct f_uac1_opts, func_inst);
4238 +}
4239 +
4240 /*
4241 * DESCRIPTORS ... most are static, but strings and full
4242 * configuration descriptors are built on demand.
4243 @@ -505,11 +513,42 @@ static void f_audio_disable(struct usb_function *f)
4244
4245 /*-------------------------------------------------------------------------*/
4246
4247 +static int f_audio_validate_opts(struct g_audio *audio, struct device *dev)
4248 +{
4249 + struct f_uac1_opts *opts = g_audio_to_uac1_opts(audio);
4250 +
4251 + if (!opts->p_chmask && !opts->c_chmask) {
4252 + dev_err(dev, "Error: no playback and capture channels\n");
4253 + return -EINVAL;
4254 + } else if (opts->p_chmask & ~UAC1_CHANNEL_MASK) {
4255 + dev_err(dev, "Error: unsupported playback channels mask\n");
4256 + return -EINVAL;
4257 + } else if (opts->c_chmask & ~UAC1_CHANNEL_MASK) {
4258 + dev_err(dev, "Error: unsupported capture channels mask\n");
4259 + return -EINVAL;
4260 + } else if ((opts->p_ssize < 1) || (opts->p_ssize > 4)) {
4261 + dev_err(dev, "Error: incorrect playback sample size\n");
4262 + return -EINVAL;
4263 + } else if ((opts->c_ssize < 1) || (opts->c_ssize > 4)) {
4264 + dev_err(dev, "Error: incorrect capture sample size\n");
4265 + return -EINVAL;
4266 + } else if (!opts->p_srate) {
4267 + dev_err(dev, "Error: incorrect playback sampling rate\n");
4268 + return -EINVAL;
4269 + } else if (!opts->c_srate) {
4270 + dev_err(dev, "Error: incorrect capture sampling rate\n");
4271 + return -EINVAL;
4272 + }
4273 +
4274 + return 0;
4275 +}
4276 +
4277 /* audio function driver setup/binding */
4278 static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
4279 {
4280 struct usb_composite_dev *cdev = c->cdev;
4281 struct usb_gadget *gadget = cdev->gadget;
4282 + struct device *dev = &gadget->dev;
4283 struct f_uac1 *uac1 = func_to_uac1(f);
4284 struct g_audio *audio = func_to_g_audio(f);
4285 struct f_uac1_opts *audio_opts;
4286 @@ -519,6 +558,10 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
4287 int rate;
4288 int status;
4289
4290 + status = f_audio_validate_opts(audio, dev);
4291 + if (status)
4292 + return status;
4293 +
4294 audio_opts = container_of(f->fi, struct f_uac1_opts, func_inst);
4295
4296 us = usb_gstrings_attach(cdev, uac1_strings, ARRAY_SIZE(strings_uac1));
4297 diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
4298 index 6f03e944e0e31..dd960cea642f3 100644
4299 --- a/drivers/usb/gadget/function/f_uac2.c
4300 +++ b/drivers/usb/gadget/function/f_uac2.c
4301 @@ -14,6 +14,9 @@
4302 #include "u_audio.h"
4303 #include "u_uac2.h"
4304
4305 +/* UAC2 spec: 4.1 Audio Channel Cluster Descriptor */
4306 +#define UAC2_CHANNEL_MASK 0x07FFFFFF
4307 +
4308 /*
4309 * The driver implements a simple UAC_2 topology.
4310 * USB-OUT -> IT_1 -> OT_3 -> ALSA_Capture
4311 @@ -604,6 +607,36 @@ static void setup_descriptor(struct f_uac2_opts *opts)
4312 hs_audio_desc[i] = NULL;
4313 }
4314
4315 +static int afunc_validate_opts(struct g_audio *agdev, struct device *dev)
4316 +{
4317 + struct f_uac2_opts *opts = g_audio_to_uac2_opts(agdev);
4318 +
4319 + if (!opts->p_chmask && !opts->c_chmask) {
4320 + dev_err(dev, "Error: no playback and capture channels\n");
4321 + return -EINVAL;
4322 + } else if (opts->p_chmask & ~UAC2_CHANNEL_MASK) {
4323 + dev_err(dev, "Error: unsupported playback channels mask\n");
4324 + return -EINVAL;
4325 + } else if (opts->c_chmask & ~UAC2_CHANNEL_MASK) {
4326 + dev_err(dev, "Error: unsupported capture channels mask\n");
4327 + return -EINVAL;
4328 + } else if ((opts->p_ssize < 1) || (opts->p_ssize > 4)) {
4329 + dev_err(dev, "Error: incorrect playback sample size\n");
4330 + return -EINVAL;
4331 + } else if ((opts->c_ssize < 1) || (opts->c_ssize > 4)) {
4332 + dev_err(dev, "Error: incorrect capture sample size\n");
4333 + return -EINVAL;
4334 + } else if (!opts->p_srate) {
4335 + dev_err(dev, "Error: incorrect playback sampling rate\n");
4336 + return -EINVAL;
4337 + } else if (!opts->c_srate) {
4338 + dev_err(dev, "Error: incorrect capture sampling rate\n");
4339 + return -EINVAL;
4340 + }
4341 +
4342 + return 0;
4343 +}
4344 +
4345 static int
4346 afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
4347 {
4348 @@ -612,11 +645,13 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
4349 struct usb_composite_dev *cdev = cfg->cdev;
4350 struct usb_gadget *gadget = cdev->gadget;
4351 struct device *dev = &gadget->dev;
4352 - struct f_uac2_opts *uac2_opts;
4353 + struct f_uac2_opts *uac2_opts = g_audio_to_uac2_opts(agdev);
4354 struct usb_string *us;
4355 int ret;
4356
4357 - uac2_opts = container_of(fn->fi, struct f_uac2_opts, func_inst);
4358 + ret = afunc_validate_opts(agdev, dev);
4359 + if (ret)
4360 + return ret;
4361
4362 us = usb_gstrings_attach(cdev, fn_strings, ARRAY_SIZE(strings_fn));
4363 if (IS_ERR(us))
4364 diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
4365 index fb0a892687c0c..c03b67aab1a85 100644
4366 --- a/drivers/usb/gadget/function/f_uvc.c
4367 +++ b/drivers/usb/gadget/function/f_uvc.c
4368 @@ -633,7 +633,12 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
4369
4370 uvc_hs_streaming_ep.wMaxPacketSize =
4371 cpu_to_le16(max_packet_size | ((max_packet_mult - 1) << 11));
4372 - uvc_hs_streaming_ep.bInterval = opts->streaming_interval;
4373 +
4374 + /* A high-bandwidth endpoint must specify a bInterval value of 1 */
4375 + if (max_packet_mult > 1)
4376 + uvc_hs_streaming_ep.bInterval = 1;
4377 + else
4378 + uvc_hs_streaming_ep.bInterval = opts->streaming_interval;
4379
4380 uvc_ss_streaming_ep.wMaxPacketSize = cpu_to_le16(max_packet_size);
4381 uvc_ss_streaming_ep.bInterval = opts->streaming_interval;
4382 @@ -817,6 +822,7 @@ static struct usb_function_instance *uvc_alloc_inst(void)
4383 pd->bmControls[0] = 1;
4384 pd->bmControls[1] = 0;
4385 pd->iProcessing = 0;
4386 + pd->bmVideoStandards = 0;
4387
4388 od = &opts->uvc_output_terminal;
4389 od->bLength = UVC_DT_OUTPUT_TERMINAL_SIZE;
4390 diff --git a/drivers/usb/gadget/legacy/webcam.c b/drivers/usb/gadget/legacy/webcam.c
4391 index a9f8eb8e1c767..2c9eab2b863d2 100644
4392 --- a/drivers/usb/gadget/legacy/webcam.c
4393 +++ b/drivers/usb/gadget/legacy/webcam.c
4394 @@ -125,6 +125,7 @@ static const struct uvc_processing_unit_descriptor uvc_processing = {
4395 .bmControls[0] = 1,
4396 .bmControls[1] = 0,
4397 .iProcessing = 0,
4398 + .bmVideoStandards = 0,
4399 };
4400
4401 static const struct uvc_output_terminal_descriptor uvc_output_terminal = {
4402 diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
4403 index a49c27b2ba16d..58261ec1300a8 100644
4404 --- a/drivers/usb/gadget/udc/dummy_hcd.c
4405 +++ b/drivers/usb/gadget/udc/dummy_hcd.c
4406 @@ -900,6 +900,21 @@ static int dummy_pullup(struct usb_gadget *_gadget, int value)
4407 spin_lock_irqsave(&dum->lock, flags);
4408 dum->pullup = (value != 0);
4409 set_link_state(dum_hcd);
4410 + if (value == 0) {
4411 + /*
4412 + * Emulate synchronize_irq(): wait for callbacks to finish.
4413 + * This seems to be the best place to emulate the call to
4414 + * synchronize_irq() that's in usb_gadget_remove_driver().
4415 + * Doing it in dummy_udc_stop() would be too late since it
4416 + * is called after the unbind callback and unbind shouldn't
4417 + * be invoked until all the other callbacks are finished.
4418 + */
4419 + while (dum->callback_usage > 0) {
4420 + spin_unlock_irqrestore(&dum->lock, flags);
4421 + usleep_range(1000, 2000);
4422 + spin_lock_irqsave(&dum->lock, flags);
4423 + }
4424 + }
4425 spin_unlock_irqrestore(&dum->lock, flags);
4426
4427 usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd));
4428 @@ -1001,14 +1016,6 @@ static int dummy_udc_stop(struct usb_gadget *g)
4429 spin_lock_irq(&dum->lock);
4430 dum->ints_enabled = 0;
4431 stop_activity(dum);
4432 -
4433 - /* emulate synchronize_irq(): wait for callbacks to finish */
4434 - while (dum->callback_usage > 0) {
4435 - spin_unlock_irq(&dum->lock);
4436 - usleep_range(1000, 2000);
4437 - spin_lock_irq(&dum->lock);
4438 - }
4439 -
4440 dum->driver = NULL;
4441 spin_unlock_irq(&dum->lock);
4442
4443 diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
4444 index 9764122c9cdf2..7f9f302a73cdf 100644
4445 --- a/drivers/usb/host/xhci-mem.c
4446 +++ b/drivers/usb/host/xhci-mem.c
4447 @@ -2134,6 +2134,15 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
4448
4449 if (major_revision == 0x03) {
4450 rhub = &xhci->usb3_rhub;
4451 + /*
4452 + * Some hosts incorrectly use sub-minor version for minor
4453 + * version (i.e. 0x02 instead of 0x20 for bcdUSB 0x320 and 0x01
4454 + * for bcdUSB 0x310). Since there is no USB release with sub
4455 + * minor version 0x301 to 0x309, we can assume that they are
4456 + * incorrect and fix it here.
4457 + */
4458 + if (minor_revision > 0x00 && minor_revision < 0x10)
4459 + minor_revision <<= 4;
4460 } else if (major_revision <= 0x02) {
4461 rhub = &xhci->usb2_rhub;
4462 } else {
4463 diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
4464 index 5fc3ea6d46c56..5c0eb35cd007a 100644
4465 --- a/drivers/usb/host/xhci-mtk.c
4466 +++ b/drivers/usb/host/xhci-mtk.c
4467 @@ -397,6 +397,8 @@ static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd *xhci)
4468 xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
4469 if (mtk->lpm_support)
4470 xhci->quirks |= XHCI_LPM_SUPPORT;
4471 + if (mtk->u2_lpm_disable)
4472 + xhci->quirks |= XHCI_HW_LPM_DISABLE;
4473
4474 /*
4475 * MTK xHCI 0.96: PSA is 1 by default even if doesn't support stream,
4476 @@ -469,6 +471,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
4477 return ret;
4478
4479 mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
4480 + mtk->u2_lpm_disable = of_property_read_bool(node, "usb2-lpm-disable");
4481 /* optional property, ignore the error if it does not exist */
4482 of_property_read_u32(node, "mediatek,u3p-dis-msk",
4483 &mtk->u3p_dis_msk);
4484 diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
4485 index 734c5513aa1bf..d9f438d078daf 100644
4486 --- a/drivers/usb/host/xhci-mtk.h
4487 +++ b/drivers/usb/host/xhci-mtk.h
4488 @@ -150,6 +150,7 @@ struct xhci_hcd_mtk {
4489 struct phy **phys;
4490 int num_phys;
4491 bool lpm_support;
4492 + bool u2_lpm_disable;
4493 /* usb remote wakeup */
4494 bool uwk_en;
4495 struct regmap *uwk;
4496 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
4497 index b5080bc1689e4..de05ac9d3ae15 100644
4498 --- a/drivers/usb/host/xhci.c
4499 +++ b/drivers/usb/host/xhci.c
4500 @@ -228,6 +228,7 @@ static void xhci_zero_64b_regs(struct xhci_hcd *xhci)
4501 struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
4502 int err, i;
4503 u64 val;
4504 + u32 intrs;
4505
4506 /*
4507 * Some Renesas controllers get into a weird state if they are
4508 @@ -266,7 +267,10 @@ static void xhci_zero_64b_regs(struct xhci_hcd *xhci)
4509 if (upper_32_bits(val))
4510 xhci_write_64(xhci, 0, &xhci->op_regs->cmd_ring);
4511
4512 - for (i = 0; i < HCS_MAX_INTRS(xhci->hcs_params1); i++) {
4513 + intrs = min_t(u32, HCS_MAX_INTRS(xhci->hcs_params1),
4514 + ARRAY_SIZE(xhci->run_regs->ir_set));
4515 +
4516 + for (i = 0; i < intrs; i++) {
4517 struct xhci_intr_reg __iomem *ir;
4518
4519 ir = &xhci->run_regs->ir_set[i];
4520 @@ -3227,6 +3231,14 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd,
4521
4522 /* config ep command clears toggle if add and drop ep flags are set */
4523 ctrl_ctx = xhci_get_input_control_ctx(cfg_cmd->in_ctx);
4524 + if (!ctrl_ctx) {
4525 + spin_unlock_irqrestore(&xhci->lock, flags);
4526 + xhci_free_command(xhci, cfg_cmd);
4527 + xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
4528 + __func__);
4529 + goto cleanup;
4530 + }
4531 +
4532 xhci_setup_input_ctx_for_config_ep(xhci, cfg_cmd->in_ctx, vdev->out_ctx,
4533 ctrl_ctx, ep_flag, ep_flag);
4534 xhci_endpoint_copy(xhci, cfg_cmd->in_ctx, vdev->out_ctx, ep_index);
4535 diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
4536 index 166f68f639c28..70ef603f7bb9b 100644
4537 --- a/drivers/usb/musb/musb_core.c
4538 +++ b/drivers/usb/musb/musb_core.c
4539 @@ -1932,7 +1932,7 @@ static void musb_irq_work(struct work_struct *data)
4540 struct musb *musb = container_of(data, struct musb, irq_work.work);
4541 int error;
4542
4543 - error = pm_runtime_get_sync(musb->controller);
4544 + error = pm_runtime_resume_and_get(musb->controller);
4545 if (error < 0) {
4546 dev_err(musb->controller, "Could not enable: %i\n", error);
4547
4548 diff --git a/drivers/video/fbdev/core/fbcmap.c b/drivers/video/fbdev/core/fbcmap.c
4549 index e5ae33c1a8e84..e8a17fb715ace 100644
4550 --- a/drivers/video/fbdev/core/fbcmap.c
4551 +++ b/drivers/video/fbdev/core/fbcmap.c
4552 @@ -101,17 +101,17 @@ int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags)
4553 if (!len)
4554 return 0;
4555
4556 - cmap->red = kmalloc(size, flags);
4557 + cmap->red = kzalloc(size, flags);
4558 if (!cmap->red)
4559 goto fail;
4560 - cmap->green = kmalloc(size, flags);
4561 + cmap->green = kzalloc(size, flags);
4562 if (!cmap->green)
4563 goto fail;
4564 - cmap->blue = kmalloc(size, flags);
4565 + cmap->blue = kzalloc(size, flags);
4566 if (!cmap->blue)
4567 goto fail;
4568 if (transp) {
4569 - cmap->transp = kmalloc(size, flags);
4570 + cmap->transp = kzalloc(size, flags);
4571 if (!cmap->transp)
4572 goto fail;
4573 } else {
4574 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
4575 index 35741901f4e0b..ab69e3563b125 100644
4576 --- a/fs/btrfs/ctree.c
4577 +++ b/fs/btrfs/ctree.c
4578 @@ -1406,10 +1406,30 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
4579 "failed to read tree block %llu from get_old_root",
4580 logical);
4581 } else {
4582 + struct tree_mod_elem *tm2;
4583 +
4584 btrfs_tree_read_lock(old);
4585 eb = btrfs_clone_extent_buffer(old);
4586 + /*
4587 + * After the lookup for the most recent tree mod operation
4588 + * above and before we locked and cloned the extent buffer
4589 + * 'old', a new tree mod log operation may have been added.
4590 + * So lookup for a more recent one to make sure the number
4591 + * of mod log operations we replay is consistent with the
4592 + * number of items we have in the cloned extent buffer,
4593 + * otherwise we can hit a BUG_ON when rewinding the extent
4594 + * buffer.
4595 + */
4596 + tm2 = tree_mod_log_search(fs_info, logical, time_seq);
4597 btrfs_tree_read_unlock(old);
4598 free_extent_buffer(old);
4599 + ASSERT(tm2);
4600 + ASSERT(tm2 == tm || tm2->seq > tm->seq);
4601 + if (!tm2 || tm2->seq < tm->seq) {
4602 + free_extent_buffer(eb);
4603 + return NULL;
4604 + }
4605 + tm = tm2;
4606 }
4607 } else if (old_root) {
4608 eb_root_owner = btrfs_header_owner(eb_root);
4609 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
4610 index 4bbd4b09fb96f..e9d3eb7f0e2b8 100644
4611 --- a/fs/btrfs/ioctl.c
4612 +++ b/fs/btrfs/ioctl.c
4613 @@ -667,8 +667,6 @@ static noinline int create_subvol(struct inode *dir,
4614 btrfs_set_root_otransid(root_item, trans->transid);
4615
4616 btrfs_tree_unlock(leaf);
4617 - free_extent_buffer(leaf);
4618 - leaf = NULL;
4619
4620 btrfs_set_root_dirid(root_item, new_dirid);
4621
4622 @@ -677,8 +675,22 @@ static noinline int create_subvol(struct inode *dir,
4623 key.type = BTRFS_ROOT_ITEM_KEY;
4624 ret = btrfs_insert_root(trans, fs_info->tree_root, &key,
4625 root_item);
4626 - if (ret)
4627 + if (ret) {
4628 + /*
4629 + * Since we don't abort the transaction in this case, free the
4630 + * tree block so that we don't leak space and leave the
4631 + * filesystem in an inconsistent state (an extent item in the
4632 + * extent tree without backreferences). Also no need to have
4633 + * the tree block locked since it is not in any tree at this
4634 + * point, so no other task can find it and use it.
4635 + */
4636 + btrfs_free_tree_block(trans, root, leaf, 0, 1);
4637 + free_extent_buffer(leaf);
4638 goto fail;
4639 + }
4640 +
4641 + free_extent_buffer(leaf);
4642 + leaf = NULL;
4643
4644 key.offset = (u64)-1;
4645 new_root = btrfs_read_fs_root_no_name(fs_info, &key);
4646 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
4647 index 68b5d7c4aa491..ba68b0b41dff3 100644
4648 --- a/fs/btrfs/relocation.c
4649 +++ b/fs/btrfs/relocation.c
4650 @@ -1836,8 +1836,8 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
4651 int ret;
4652 int slot;
4653
4654 - BUG_ON(src->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID);
4655 - BUG_ON(dest->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID);
4656 + ASSERT(src->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID);
4657 + ASSERT(dest->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID);
4658
4659 last_snapshot = btrfs_root_last_snapshot(&src->root_item);
4660 again:
4661 @@ -1871,7 +1871,7 @@ again:
4662 struct btrfs_key first_key;
4663
4664 level = btrfs_header_level(parent);
4665 - BUG_ON(level < lowest_level);
4666 + ASSERT(level >= lowest_level);
4667
4668 ret = btrfs_bin_search(parent, &key, level, &slot);
4669 if (ret < 0)
4670 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
4671 index 30025cc5d4ae7..997a106f28d37 100644
4672 --- a/fs/cifs/smb2ops.c
4673 +++ b/fs/cifs/smb2ops.c
4674 @@ -3693,7 +3693,7 @@ smb2_get_enc_key(struct TCP_Server_Info *server, __u64 ses_id, int enc, u8 *key)
4675 }
4676 spin_unlock(&cifs_tcp_ses_lock);
4677
4678 - return 1;
4679 + return -EAGAIN;
4680 }
4681 /*
4682 * Encrypt or decrypt @rqst message. @rqst[0] has the following format:
4683 diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
4684 index b8a7ce379ffe6..75fbdfb8aaef8 100644
4685 --- a/fs/ecryptfs/main.c
4686 +++ b/fs/ecryptfs/main.c
4687 @@ -492,6 +492,12 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
4688 goto out;
4689 }
4690
4691 + if (!dev_name) {
4692 + rc = -EINVAL;
4693 + err = "Device name cannot be null";
4694 + goto out;
4695 + }
4696 +
4697 rc = ecryptfs_parse_options(sbi, raw_data, &check_ruid);
4698 if (rc) {
4699 err = "Error parsing options";
4700 diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
4701 index b1ee5654750d8..52ab961544673 100644
4702 --- a/fs/erofs/erofs_fs.h
4703 +++ b/fs/erofs/erofs_fs.h
4704 @@ -74,6 +74,9 @@ static inline bool erofs_inode_is_data_compressed(unsigned int datamode)
4705 #define EROFS_I_VERSION_BIT 0
4706 #define EROFS_I_DATALAYOUT_BIT 1
4707
4708 +#define EROFS_I_ALL \
4709 + ((1 << (EROFS_I_DATALAYOUT_BIT + EROFS_I_DATALAYOUT_BITS)) - 1)
4710 +
4711 /* 32-byte reduced form of an ondisk inode */
4712 struct erofs_inode_compact {
4713 __le16 i_format; /* inode format hints */
4714 diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
4715 index 70fd3af7b8cb5..0dbeaf68e1d6e 100644
4716 --- a/fs/erofs/inode.c
4717 +++ b/fs/erofs/inode.c
4718 @@ -44,6 +44,13 @@ static struct page *erofs_read_inode(struct inode *inode,
4719 dic = page_address(page) + *ofs;
4720 ifmt = le16_to_cpu(dic->i_format);
4721
4722 + if (ifmt & ~EROFS_I_ALL) {
4723 + erofs_err(inode->i_sb, "unsupported i_format %u of nid %llu",
4724 + ifmt, vi->nid);
4725 + err = -EOPNOTSUPP;
4726 + goto err_out;
4727 + }
4728 +
4729 vi->datalayout = erofs_inode_datalayout(ifmt);
4730 if (vi->datalayout >= EROFS_INODE_DATALAYOUT_MAX) {
4731 erofs_err(inode->i_sb, "unsupported datalayout %u of nid %llu",
4732 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
4733 index 64b6549dd9016..dd2c23d1483cc 100644
4734 --- a/fs/ext4/ialloc.c
4735 +++ b/fs/ext4/ialloc.c
4736 @@ -1353,6 +1353,7 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group,
4737 handle_t *handle;
4738 ext4_fsblk_t blk;
4739 int num, ret = 0, used_blks = 0;
4740 + unsigned long used_inos = 0;
4741
4742 /* This should not happen, but just to be sure check this */
4743 if (sb_rdonly(sb)) {
4744 @@ -1383,22 +1384,37 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group,
4745 * used inodes so we need to skip blocks with used inodes in
4746 * inode table.
4747 */
4748 - if (!(gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)))
4749 - used_blks = DIV_ROUND_UP((EXT4_INODES_PER_GROUP(sb) -
4750 - ext4_itable_unused_count(sb, gdp)),
4751 - sbi->s_inodes_per_block);
4752 -
4753 - if ((used_blks < 0) || (used_blks > sbi->s_itb_per_group) ||
4754 - ((group == 0) && ((EXT4_INODES_PER_GROUP(sb) -
4755 - ext4_itable_unused_count(sb, gdp)) <
4756 - EXT4_FIRST_INO(sb)))) {
4757 - ext4_error(sb, "Something is wrong with group %u: "
4758 - "used itable blocks: %d; "
4759 - "itable unused count: %u",
4760 - group, used_blks,
4761 - ext4_itable_unused_count(sb, gdp));
4762 - ret = 1;
4763 - goto err_out;
4764 + if (!(gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT))) {
4765 + used_inos = EXT4_INODES_PER_GROUP(sb) -
4766 + ext4_itable_unused_count(sb, gdp);
4767 + used_blks = DIV_ROUND_UP(used_inos, sbi->s_inodes_per_block);
4768 +
4769 + /* Bogus inode unused count? */
4770 + if (used_blks < 0 || used_blks > sbi->s_itb_per_group) {
4771 + ext4_error(sb, "Something is wrong with group %u: "
4772 + "used itable blocks: %d; "
4773 + "itable unused count: %u",
4774 + group, used_blks,
4775 + ext4_itable_unused_count(sb, gdp));
4776 + ret = 1;
4777 + goto err_out;
4778 + }
4779 +
4780 + used_inos += group * EXT4_INODES_PER_GROUP(sb);
4781 + /*
4782 + * Are there some uninitialized inodes in the inode table
4783 + * before the first normal inode?
4784 + */
4785 + if ((used_blks != sbi->s_itb_per_group) &&
4786 + (used_inos < EXT4_FIRST_INO(sb))) {
4787 + ext4_error(sb, "Something is wrong with group %u: "
4788 + "itable unused count: %u; "
4789 + "itables initialized count: %ld",
4790 + group, ext4_itable_unused_count(sb, gdp),
4791 + used_inos);
4792 + ret = 1;
4793 + goto err_out;
4794 + }
4795 }
4796
4797 blk = ext4_inode_table(sb, gdp) + used_blks;
4798 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
4799 index 2ecf4594a20dd..0b364f5e6fdf9 100644
4800 --- a/fs/ext4/super.c
4801 +++ b/fs/ext4/super.c
4802 @@ -2675,9 +2675,6 @@ static void ext4_orphan_cleanup(struct super_block *sb,
4803 sb->s_flags &= ~SB_RDONLY;
4804 }
4805 #ifdef CONFIG_QUOTA
4806 - /* Needed for iput() to work correctly and not trash data */
4807 - sb->s_flags |= SB_ACTIVE;
4808 -
4809 /*
4810 * Turn on quotas which were not enabled for read-only mounts if
4811 * filesystem has quota feature, so that they are updated correctly.
4812 @@ -5060,8 +5057,10 @@ static int ext4_commit_super(struct super_block *sb, int sync)
4813 struct buffer_head *sbh = EXT4_SB(sb)->s_sbh;
4814 int error = 0;
4815
4816 - if (!sbh || block_device_ejected(sb))
4817 - return error;
4818 + if (!sbh)
4819 + return -EINVAL;
4820 + if (block_device_ejected(sb))
4821 + return -ENODEV;
4822
4823 /*
4824 * If the file system is mounted read-only, don't update the
4825 diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
4826 index 7ce33698ae381..48bb5d3c709db 100644
4827 --- a/fs/f2fs/node.c
4828 +++ b/fs/f2fs/node.c
4829 @@ -2718,6 +2718,9 @@ static void remove_nats_in_journal(struct f2fs_sb_info *sbi)
4830 struct f2fs_nat_entry raw_ne;
4831 nid_t nid = le32_to_cpu(nid_in_journal(journal, i));
4832
4833 + if (f2fs_check_nid_range(sbi, nid))
4834 + continue;
4835 +
4836 raw_ne = nat_in_journal(journal, i);
4837
4838 ne = __lookup_nat_cache(nm_i, nid);
4839 diff --git a/fs/fuse/file.c b/fs/fuse/file.c
4840 index 1e1aef1bc20b3..0883e5b24c901 100644
4841 --- a/fs/fuse/file.c
4842 +++ b/fs/fuse/file.c
4843 @@ -1108,6 +1108,7 @@ static ssize_t fuse_send_write_pages(struct fuse_io_args *ia,
4844 struct fuse_file *ff = file->private_data;
4845 struct fuse_conn *fc = ff->fc;
4846 unsigned int offset, i;
4847 + bool short_write;
4848 int err;
4849
4850 for (i = 0; i < ap->num_pages; i++)
4851 @@ -1120,32 +1121,38 @@ static ssize_t fuse_send_write_pages(struct fuse_io_args *ia,
4852 if (!err && ia->write.out.size > count)
4853 err = -EIO;
4854
4855 + short_write = ia->write.out.size < count;
4856 offset = ap->descs[0].offset;
4857 count = ia->write.out.size;
4858 for (i = 0; i < ap->num_pages; i++) {
4859 struct page *page = ap->pages[i];
4860
4861 - if (!err && !offset && count >= PAGE_SIZE)
4862 - SetPageUptodate(page);
4863 -
4864 - if (count > PAGE_SIZE - offset)
4865 - count -= PAGE_SIZE - offset;
4866 - else
4867 - count = 0;
4868 - offset = 0;
4869 -
4870 - unlock_page(page);
4871 + if (err) {
4872 + ClearPageUptodate(page);
4873 + } else {
4874 + if (count >= PAGE_SIZE - offset)
4875 + count -= PAGE_SIZE - offset;
4876 + else {
4877 + if (short_write)
4878 + ClearPageUptodate(page);
4879 + count = 0;
4880 + }
4881 + offset = 0;
4882 + }
4883 + if (ia->write.page_locked && (i == ap->num_pages - 1))
4884 + unlock_page(page);
4885 put_page(page);
4886 }
4887
4888 return err;
4889 }
4890
4891 -static ssize_t fuse_fill_write_pages(struct fuse_args_pages *ap,
4892 +static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
4893 struct address_space *mapping,
4894 struct iov_iter *ii, loff_t pos,
4895 unsigned int max_pages)
4896 {
4897 + struct fuse_args_pages *ap = &ia->ap;
4898 struct fuse_conn *fc = get_fuse_conn(mapping->host);
4899 unsigned offset = pos & (PAGE_SIZE - 1);
4900 size_t count = 0;
4901 @@ -1198,6 +1205,16 @@ static ssize_t fuse_fill_write_pages(struct fuse_args_pages *ap,
4902 if (offset == PAGE_SIZE)
4903 offset = 0;
4904
4905 + /* If we copied full page, mark it uptodate */
4906 + if (tmp == PAGE_SIZE)
4907 + SetPageUptodate(page);
4908 +
4909 + if (PageUptodate(page)) {
4910 + unlock_page(page);
4911 + } else {
4912 + ia->write.page_locked = true;
4913 + break;
4914 + }
4915 if (!fc->big_writes)
4916 break;
4917 } while (iov_iter_count(ii) && count < fc->max_write &&
4918 @@ -1241,7 +1258,7 @@ static ssize_t fuse_perform_write(struct kiocb *iocb,
4919 break;
4920 }
4921
4922 - count = fuse_fill_write_pages(ap, mapping, ii, pos, nr_pages);
4923 + count = fuse_fill_write_pages(&ia, mapping, ii, pos, nr_pages);
4924 if (count <= 0) {
4925 err = count;
4926 } else {
4927 diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
4928 index 43bacf0a6bd31..d878926485451 100644
4929 --- a/fs/fuse/fuse_i.h
4930 +++ b/fs/fuse/fuse_i.h
4931 @@ -845,6 +845,7 @@ struct fuse_io_args {
4932 struct {
4933 struct fuse_write_in in;
4934 struct fuse_write_out out;
4935 + bool page_locked;
4936 } write;
4937 };
4938 struct fuse_args_pages ap;
4939 diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
4940 index 7505f81027623..fadf6fb90fe22 100644
4941 --- a/fs/fuse/virtio_fs.c
4942 +++ b/fs/fuse/virtio_fs.c
4943 @@ -667,6 +667,7 @@ static int virtio_fs_probe(struct virtio_device *vdev)
4944 out_vqs:
4945 vdev->config->reset(vdev);
4946 virtio_fs_cleanup_vqs(vdev, fs);
4947 + kfree(fs->vqs);
4948
4949 out:
4950 vdev->priv = NULL;
4951 diff --git a/fs/jffs2/compr_rtime.c b/fs/jffs2/compr_rtime.c
4952 index 406d9cc84ba8d..79e771ab624f4 100644
4953 --- a/fs/jffs2/compr_rtime.c
4954 +++ b/fs/jffs2/compr_rtime.c
4955 @@ -37,6 +37,9 @@ static int jffs2_rtime_compress(unsigned char *data_in,
4956 int outpos = 0;
4957 int pos=0;
4958
4959 + if (*dstlen <= 3)
4960 + return -1;
4961 +
4962 memset(positions,0,sizeof(positions));
4963
4964 while (pos < (*sourcelen) && outpos <= (*dstlen)-2) {
4965 diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
4966 index 5f7e284e0df36..0b1a7f68b7122 100644
4967 --- a/fs/jffs2/scan.c
4968 +++ b/fs/jffs2/scan.c
4969 @@ -1078,7 +1078,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
4970 memcpy(&fd->name, rd->name, checkedlen);
4971 fd->name[checkedlen] = 0;
4972
4973 - crc = crc32(0, fd->name, rd->nsize);
4974 + crc = crc32(0, fd->name, checkedlen);
4975 if (crc != je32_to_cpu(rd->name_crc)) {
4976 pr_notice("%s(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
4977 __func__, ofs, je32_to_cpu(rd->name_crc), crc);
4978 diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
4979 index e3a79e6958124..7e8c18218e68f 100644
4980 --- a/fs/nfs/pnfs.c
4981 +++ b/fs/nfs/pnfs.c
4982 @@ -1311,7 +1311,7 @@ _pnfs_return_layout(struct inode *ino)
4983 }
4984 valid_layout = pnfs_layout_is_valid(lo);
4985 pnfs_clear_layoutcommit(ino, &tmp_list);
4986 - pnfs_mark_matching_lsegs_invalid(lo, &tmp_list, NULL, 0);
4987 + pnfs_mark_matching_lsegs_return(lo, &tmp_list, NULL, 0);
4988
4989 if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) {
4990 struct pnfs_layout_range range = {
4991 @@ -2427,6 +2427,9 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
4992
4993 assert_spin_locked(&lo->plh_inode->i_lock);
4994
4995 + if (test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags))
4996 + tmp_list = &lo->plh_return_segs;
4997 +
4998 list_for_each_entry_safe(lseg, next, &lo->plh_segs, pls_list)
4999 if (pnfs_match_lseg_recall(lseg, return_range, seq)) {
5000 dprintk("%s: marking lseg %p iomode %d "
5001 @@ -2434,6 +2437,8 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
5002 lseg, lseg->pls_range.iomode,
5003 lseg->pls_range.offset,
5004 lseg->pls_range.length);
5005 + if (test_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags))
5006 + tmp_list = &lo->plh_return_segs;
5007 if (mark_lseg_invalid(lseg, tmp_list))
5008 continue;
5009 remaining++;
5010 diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
5011 index 01fcf79750472..723a4b66a9b90 100644
5012 --- a/fs/ubifs/replay.c
5013 +++ b/fs/ubifs/replay.c
5014 @@ -223,7 +223,8 @@ static bool inode_still_linked(struct ubifs_info *c, struct replay_entry *rino)
5015 */
5016 list_for_each_entry_reverse(r, &c->replay_list, list) {
5017 ubifs_assert(c, r->sqnum >= rino->sqnum);
5018 - if (key_inum(c, &r->key) == key_inum(c, &rino->key))
5019 + if (key_inum(c, &r->key) == key_inum(c, &rino->key) &&
5020 + key_type(c, &r->key) == UBIFS_INO_KEY)
5021 return r->deletion == 0;
5022
5023 }
5024 diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h
5025 index d873f999b3347..3a801a7d3a0e9 100644
5026 --- a/include/crypto/acompress.h
5027 +++ b/include/crypto/acompress.h
5028 @@ -147,6 +147,8 @@ static inline struct crypto_acomp *crypto_acomp_reqtfm(struct acomp_req *req)
5029 * crypto_free_acomp() -- free ACOMPRESS tfm handle
5030 *
5031 * @tfm: ACOMPRESS tfm handle allocated with crypto_alloc_acomp()
5032 + *
5033 + * If @tfm is a NULL or error pointer, this function does nothing.
5034 */
5035 static inline void crypto_free_acomp(struct crypto_acomp *tfm)
5036 {
5037 diff --git a/include/crypto/aead.h b/include/crypto/aead.h
5038 index 3c245b1859e77..3b870b4e82751 100644
5039 --- a/include/crypto/aead.h
5040 +++ b/include/crypto/aead.h
5041 @@ -179,6 +179,8 @@ static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm)
5042 /**
5043 * crypto_free_aead() - zeroize and free aead handle
5044 * @tfm: cipher handle to be freed
5045 + *
5046 + * If @tfm is a NULL or error pointer, this function does nothing.
5047 */
5048 static inline void crypto_free_aead(struct crypto_aead *tfm)
5049 {
5050 diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
5051 index 6924b091adec1..8913b42fcb343 100644
5052 --- a/include/crypto/akcipher.h
5053 +++ b/include/crypto/akcipher.h
5054 @@ -174,6 +174,8 @@ static inline struct crypto_akcipher *crypto_akcipher_reqtfm(
5055 * crypto_free_akcipher() - free AKCIPHER tfm handle
5056 *
5057 * @tfm: AKCIPHER tfm handle allocated with crypto_alloc_akcipher()
5058 + *
5059 + * If @tfm is a NULL or error pointer, this function does nothing.
5060 */
5061 static inline void crypto_free_akcipher(struct crypto_akcipher *tfm)
5062 {
5063 diff --git a/include/crypto/hash.h b/include/crypto/hash.h
5064 index 84e9f2380edf2..e993c6beec073 100644
5065 --- a/include/crypto/hash.h
5066 +++ b/include/crypto/hash.h
5067 @@ -260,6 +260,8 @@ static inline struct crypto_tfm *crypto_ahash_tfm(struct crypto_ahash *tfm)
5068 /**
5069 * crypto_free_ahash() - zeroize and free the ahash handle
5070 * @tfm: cipher handle to be freed
5071 + *
5072 + * If @tfm is a NULL or error pointer, this function does nothing.
5073 */
5074 static inline void crypto_free_ahash(struct crypto_ahash *tfm)
5075 {
5076 @@ -703,6 +705,8 @@ static inline struct crypto_tfm *crypto_shash_tfm(struct crypto_shash *tfm)
5077 /**
5078 * crypto_free_shash() - zeroize and free the message digest handle
5079 * @tfm: cipher handle to be freed
5080 + *
5081 + * If @tfm is a NULL or error pointer, this function does nothing.
5082 */
5083 static inline void crypto_free_shash(struct crypto_shash *tfm)
5084 {
5085 diff --git a/include/crypto/kpp.h b/include/crypto/kpp.h
5086 index cd9a9b500624b..19a2eadbef613 100644
5087 --- a/include/crypto/kpp.h
5088 +++ b/include/crypto/kpp.h
5089 @@ -154,6 +154,8 @@ static inline void crypto_kpp_set_flags(struct crypto_kpp *tfm, u32 flags)
5090 * crypto_free_kpp() - free KPP tfm handle
5091 *
5092 * @tfm: KPP tfm handle allocated with crypto_alloc_kpp()
5093 + *
5094 + * If @tfm is a NULL or error pointer, this function does nothing.
5095 */
5096 static inline void crypto_free_kpp(struct crypto_kpp *tfm)
5097 {
5098 diff --git a/include/crypto/rng.h b/include/crypto/rng.h
5099 index 8b4b844b4eef8..17bb3673d3c17 100644
5100 --- a/include/crypto/rng.h
5101 +++ b/include/crypto/rng.h
5102 @@ -111,6 +111,8 @@ static inline struct rng_alg *crypto_rng_alg(struct crypto_rng *tfm)
5103 /**
5104 * crypto_free_rng() - zeroize and free RNG handle
5105 * @tfm: cipher handle to be freed
5106 + *
5107 + * If @tfm is a NULL or error pointer, this function does nothing.
5108 */
5109 static inline void crypto_free_rng(struct crypto_rng *tfm)
5110 {
5111 diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h
5112 index aada879169184..0bce6005d325d 100644
5113 --- a/include/crypto/skcipher.h
5114 +++ b/include/crypto/skcipher.h
5115 @@ -203,6 +203,8 @@ static inline struct crypto_tfm *crypto_skcipher_tfm(
5116 /**
5117 * crypto_free_skcipher() - zeroize and free cipher handle
5118 * @tfm: cipher handle to be freed
5119 + *
5120 + * If @tfm is a NULL or error pointer, this function does nothing.
5121 */
5122 static inline void crypto_free_skcipher(struct crypto_skcipher *tfm)
5123 {
5124 diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
5125 index 4c5eb3aa8e723..a0e1cf1bef4e5 100644
5126 --- a/include/linux/mmc/host.h
5127 +++ b/include/linux/mmc/host.h
5128 @@ -281,9 +281,6 @@ struct mmc_host {
5129 u32 ocr_avail_sdio; /* SDIO-specific OCR */
5130 u32 ocr_avail_sd; /* SD-specific OCR */
5131 u32 ocr_avail_mmc; /* MMC-specific OCR */
5132 -#ifdef CONFIG_PM_SLEEP
5133 - struct notifier_block pm_notify;
5134 -#endif
5135 u32 max_current_330;
5136 u32 max_current_300;
5137 u32 max_current_180;
5138 diff --git a/include/linux/module.h b/include/linux/module.h
5139 index 6d20895e77391..3e01e01f00ccb 100644
5140 --- a/include/linux/module.h
5141 +++ b/include/linux/module.h
5142 @@ -376,6 +376,7 @@ struct module {
5143 unsigned int num_gpl_syms;
5144 const struct kernel_symbol *gpl_syms;
5145 const s32 *gpl_crcs;
5146 + bool using_gplonly_symbols;
5147
5148 #ifdef CONFIG_UNUSED_SYMBOLS
5149 /* unused exported symbols. */
5150 @@ -561,34 +562,14 @@ struct module *find_module(const char *name);
5151 struct symsearch {
5152 const struct kernel_symbol *start, *stop;
5153 const s32 *crcs;
5154 - enum {
5155 + enum mod_license {
5156 NOT_GPL_ONLY,
5157 GPL_ONLY,
5158 WILL_BE_GPL_ONLY,
5159 - } licence;
5160 + } license;
5161 bool unused;
5162 };
5163
5164 -/*
5165 - * Search for an exported symbol by name.
5166 - *
5167 - * Must be called with module_mutex held or preemption disabled.
5168 - */
5169 -const struct kernel_symbol *find_symbol(const char *name,
5170 - struct module **owner,
5171 - const s32 **crc,
5172 - bool gplok,
5173 - bool warn);
5174 -
5175 -/*
5176 - * Walk the exported symbol table
5177 - *
5178 - * Must be called with module_mutex held or preemption disabled.
5179 - */
5180 -bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
5181 - struct module *owner,
5182 - void *data), void *data);
5183 -
5184 /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
5185 symnum out of range. */
5186 int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
5187 @@ -636,7 +617,6 @@ static inline void __module_get(struct module *module)
5188 #define symbol_put_addr(p) do { } while (0)
5189
5190 #endif /* CONFIG_MODULE_UNLOAD */
5191 -int ref_module(struct module *a, struct module *b);
5192
5193 /* This is a #define so the string doesn't get put in every .o file */
5194 #define module_name(mod) \
5195 diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
5196 index 507c5e214c424..7413779484d5a 100644
5197 --- a/include/linux/power/bq27xxx_battery.h
5198 +++ b/include/linux/power/bq27xxx_battery.h
5199 @@ -50,7 +50,6 @@ struct bq27xxx_reg_cache {
5200 int capacity;
5201 int energy;
5202 int flags;
5203 - int power_avg;
5204 int health;
5205 };
5206
5207 diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
5208 index 2568cb0627ec0..fac8e89aed81d 100644
5209 --- a/include/scsi/libfcoe.h
5210 +++ b/include/scsi/libfcoe.h
5211 @@ -249,7 +249,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_lport *,
5212 struct fc_frame *);
5213
5214 /* libfcoe funcs */
5215 -u64 fcoe_wwn_from_mac(unsigned char mac[], unsigned int, unsigned int);
5216 +u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN], unsigned int, unsigned int);
5217 int fcoe_libfc_config(struct fc_lport *, struct fcoe_ctlr *,
5218 const struct libfc_function_template *, int init_fcp);
5219 u32 fcoe_fc_crc(struct fc_frame *fp);
5220 diff --git a/include/uapi/linux/usb/video.h b/include/uapi/linux/usb/video.h
5221 index d854cb19c42c3..bfdae12cdacf8 100644
5222 --- a/include/uapi/linux/usb/video.h
5223 +++ b/include/uapi/linux/usb/video.h
5224 @@ -302,9 +302,10 @@ struct uvc_processing_unit_descriptor {
5225 __u8 bControlSize;
5226 __u8 bmControls[2];
5227 __u8 iProcessing;
5228 + __u8 bmVideoStandards;
5229 } __attribute__((__packed__));
5230
5231 -#define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n))
5232 +#define UVC_DT_PROCESSING_UNIT_SIZE(n) (10+(n))
5233
5234 /* 3.7.2.6. Extension Unit Descriptor */
5235 struct uvc_extension_unit_descriptor {
5236 diff --git a/kernel/.gitignore b/kernel/.gitignore
5237 index 34d1e77ee9df8..0f0dba6c1eedc 100644
5238 --- a/kernel/.gitignore
5239 +++ b/kernel/.gitignore
5240 @@ -1,4 +1,5 @@
5241 #
5242 +/config_data
5243 # Generated files
5244 #
5245 kheaders.md5
5246 diff --git a/kernel/Makefile b/kernel/Makefile
5247 index 6aef13053a5c4..d038b0de886e9 100644
5248 --- a/kernel/Makefile
5249 +++ b/kernel/Makefile
5250 @@ -122,10 +122,15 @@ KCOV_INSTRUMENT_stackleak.o := n
5251
5252 $(obj)/configs.o: $(obj)/config_data.gz
5253
5254 -targets += config_data.gz
5255 -$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
5256 +targets += config_data config_data.gz
5257 +$(obj)/config_data.gz: $(obj)/config_data FORCE
5258 $(call if_changed,gzip)
5259
5260 +filechk_cat = cat $<
5261 +
5262 +$(obj)/config_data: $(KCONFIG_CONFIG) FORCE
5263 + $(call filechk,cat)
5264 +
5265 $(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz
5266
5267 quiet_cmd_genikh = CHK $(obj)/kheaders_data.tar.xz
5268 diff --git a/kernel/futex.c b/kernel/futex.c
5269 index 36a2a923f7ccf..375e7e98e301f 100644
5270 --- a/kernel/futex.c
5271 +++ b/kernel/futex.c
5272 @@ -3862,8 +3862,7 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
5273
5274 if (op & FUTEX_CLOCK_REALTIME) {
5275 flags |= FLAGS_CLOCKRT;
5276 - if (cmd != FUTEX_WAIT && cmd != FUTEX_WAIT_BITSET && \
5277 - cmd != FUTEX_WAIT_REQUEUE_PI)
5278 + if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI)
5279 return -ENOSYS;
5280 }
5281
5282 diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c
5283 index 651a4ad6d711f..8e586858bcf41 100644
5284 --- a/kernel/irq/matrix.c
5285 +++ b/kernel/irq/matrix.c
5286 @@ -423,7 +423,9 @@ void irq_matrix_free(struct irq_matrix *m, unsigned int cpu,
5287 if (WARN_ON_ONCE(bit < m->alloc_start || bit >= m->alloc_end))
5288 return;
5289
5290 - clear_bit(bit, cm->alloc_map);
5291 + if (WARN_ON_ONCE(!test_and_clear_bit(bit, cm->alloc_map)))
5292 + return;
5293 +
5294 cm->allocated--;
5295 if(managed)
5296 cm->managed_allocated--;
5297 diff --git a/kernel/module.c b/kernel/module.c
5298 index c60559b5bf101..88a6a9e04f8dc 100644
5299 --- a/kernel/module.c
5300 +++ b/kernel/module.c
5301 @@ -420,7 +420,7 @@ static bool each_symbol_in_section(const struct symsearch *arr,
5302 }
5303
5304 /* Returns true as soon as fn returns true, otherwise false. */
5305 -bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
5306 +static bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
5307 struct module *owner,
5308 void *data),
5309 void *data)
5310 @@ -482,7 +482,6 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
5311 }
5312 return false;
5313 }
5314 -EXPORT_SYMBOL_GPL(each_symbol_section);
5315
5316 struct find_symbol_arg {
5317 /* Input */
5318 @@ -494,6 +493,7 @@ struct find_symbol_arg {
5319 struct module *owner;
5320 const s32 *crc;
5321 const struct kernel_symbol *sym;
5322 + enum mod_license license;
5323 };
5324
5325 static bool check_exported_symbol(const struct symsearch *syms,
5326 @@ -503,9 +503,9 @@ static bool check_exported_symbol(const struct symsearch *syms,
5327 struct find_symbol_arg *fsa = data;
5328
5329 if (!fsa->gplok) {
5330 - if (syms->licence == GPL_ONLY)
5331 + if (syms->license == GPL_ONLY)
5332 return false;
5333 - if (syms->licence == WILL_BE_GPL_ONLY && fsa->warn) {
5334 + if (syms->license == WILL_BE_GPL_ONLY && fsa->warn) {
5335 pr_warn("Symbol %s is being used by a non-GPL module, "
5336 "which will not be allowed in the future\n",
5337 fsa->name);
5338 @@ -527,6 +527,7 @@ static bool check_exported_symbol(const struct symsearch *syms,
5339 fsa->owner = owner;
5340 fsa->crc = symversion(syms->crcs, symnum);
5341 fsa->sym = &syms->start[symnum];
5342 + fsa->license = syms->license;
5343 return true;
5344 }
5345
5346 @@ -583,9 +584,10 @@ static bool find_exported_symbol_in_section(const struct symsearch *syms,
5347
5348 /* Find an exported symbol and return it, along with, (optional) crc and
5349 * (optional) module which owns it. Needs preempt disabled or module_mutex. */
5350 -const struct kernel_symbol *find_symbol(const char *name,
5351 +static const struct kernel_symbol *find_symbol(const char *name,
5352 struct module **owner,
5353 const s32 **crc,
5354 + enum mod_license *license,
5355 bool gplok,
5356 bool warn)
5357 {
5358 @@ -600,13 +602,14 @@ const struct kernel_symbol *find_symbol(const char *name,
5359 *owner = fsa.owner;
5360 if (crc)
5361 *crc = fsa.crc;
5362 + if (license)
5363 + *license = fsa.license;
5364 return fsa.sym;
5365 }
5366
5367 pr_debug("Failed to find symbol %s\n", name);
5368 return NULL;
5369 }
5370 -EXPORT_SYMBOL_GPL(find_symbol);
5371
5372 /*
5373 * Search for module by name: must hold module_mutex (or preempt disabled
5374 @@ -867,7 +870,7 @@ static int add_module_usage(struct module *a, struct module *b)
5375 }
5376
5377 /* Module a uses b: caller needs module_mutex() */
5378 -int ref_module(struct module *a, struct module *b)
5379 +static int ref_module(struct module *a, struct module *b)
5380 {
5381 int err;
5382
5383 @@ -886,7 +889,6 @@ int ref_module(struct module *a, struct module *b)
5384 }
5385 return 0;
5386 }
5387 -EXPORT_SYMBOL_GPL(ref_module);
5388
5389 /* Clear the unload stuff of the module. */
5390 static void module_unload_free(struct module *mod)
5391 @@ -1075,7 +1077,7 @@ void __symbol_put(const char *symbol)
5392 struct module *owner;
5393
5394 preempt_disable();
5395 - if (!find_symbol(symbol, &owner, NULL, true, false))
5396 + if (!find_symbol(symbol, &owner, NULL, NULL, true, false))
5397 BUG();
5398 module_put(owner);
5399 preempt_enable();
5400 @@ -1167,11 +1169,10 @@ static inline void module_unload_free(struct module *mod)
5401 {
5402 }
5403
5404 -int ref_module(struct module *a, struct module *b)
5405 +static int ref_module(struct module *a, struct module *b)
5406 {
5407 return strong_try_module_get(b);
5408 }
5409 -EXPORT_SYMBOL_GPL(ref_module);
5410
5411 static inline int module_unload_init(struct module *mod)
5412 {
5413 @@ -1354,7 +1355,7 @@ static inline int check_modstruct_version(const struct load_info *info,
5414 * locking is necessary -- use preempt_disable() to placate lockdep.
5415 */
5416 preempt_disable();
5417 - if (!find_symbol("module_layout", NULL, &crc, true, false)) {
5418 + if (!find_symbol("module_layout", NULL, &crc, NULL, true, false)) {
5419 preempt_enable();
5420 BUG();
5421 }
5422 @@ -1428,6 +1429,24 @@ static int verify_namespace_is_imported(const struct load_info *info,
5423 return 0;
5424 }
5425
5426 +static bool inherit_taint(struct module *mod, struct module *owner)
5427 +{
5428 + if (!owner || !test_bit(TAINT_PROPRIETARY_MODULE, &owner->taints))
5429 + return true;
5430 +
5431 + if (mod->using_gplonly_symbols) {
5432 + pr_err("%s: module using GPL-only symbols uses symbols from proprietary module %s.\n",
5433 + mod->name, owner->name);
5434 + return false;
5435 + }
5436 +
5437 + if (!test_bit(TAINT_PROPRIETARY_MODULE, &mod->taints)) {
5438 + pr_warn("%s: module uses symbols from proprietary module %s, inheriting taint.\n",
5439 + mod->name, owner->name);
5440 + set_bit(TAINT_PROPRIETARY_MODULE, &mod->taints);
5441 + }
5442 + return true;
5443 +}
5444
5445 /* Resolve a symbol for this module. I.e. if we find one, record usage. */
5446 static const struct kernel_symbol *resolve_symbol(struct module *mod,
5447 @@ -1438,6 +1457,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
5448 struct module *owner;
5449 const struct kernel_symbol *sym;
5450 const s32 *crc;
5451 + enum mod_license license;
5452 int err;
5453
5454 /*
5455 @@ -1447,11 +1467,19 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
5456 */
5457 sched_annotate_sleep();
5458 mutex_lock(&module_mutex);
5459 - sym = find_symbol(name, &owner, &crc,
5460 + sym = find_symbol(name, &owner, &crc, &license,
5461 !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true);
5462 if (!sym)
5463 goto unlock;
5464
5465 + if (license == GPL_ONLY)
5466 + mod->using_gplonly_symbols = true;
5467 +
5468 + if (!inherit_taint(mod, owner)) {
5469 + sym = NULL;
5470 + goto getname;
5471 + }
5472 +
5473 if (!check_version(info, name, mod, crc)) {
5474 sym = ERR_PTR(-EINVAL);
5475 goto getname;
5476 @@ -2262,7 +2290,7 @@ void *__symbol_get(const char *symbol)
5477 const struct kernel_symbol *sym;
5478
5479 preempt_disable();
5480 - sym = find_symbol(symbol, &owner, NULL, true, true);
5481 + sym = find_symbol(symbol, &owner, NULL, NULL, true, true);
5482 if (sym && strong_try_module_get(owner))
5483 sym = NULL;
5484 preempt_enable();
5485 @@ -2298,7 +2326,7 @@ static int verify_exported_symbols(struct module *mod)
5486 for (i = 0; i < ARRAY_SIZE(arr); i++) {
5487 for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
5488 if (find_symbol(kernel_symbol_name(s), &owner, NULL,
5489 - true, false)) {
5490 + NULL, true, false)) {
5491 pr_err("%s: exports duplicate symbol %s"
5492 " (owned by %s)\n",
5493 mod->name, kernel_symbol_name(s),
5494 @@ -4620,7 +4648,6 @@ struct module *__module_address(unsigned long addr)
5495 }
5496 return mod;
5497 }
5498 -EXPORT_SYMBOL_GPL(__module_address);
5499
5500 /*
5501 * is_module_text_address - is this address inside module code?
5502 @@ -4659,7 +4686,6 @@ struct module *__module_text_address(unsigned long addr)
5503 }
5504 return mod;
5505 }
5506 -EXPORT_SYMBOL_GPL(__module_text_address);
5507
5508 /* Don't grab lock, we're oopsing. */
5509 void print_modules(void)
5510 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
5511 index 611adca1e6d0c..93ab546b6e16c 100644
5512 --- a/kernel/sched/fair.c
5513 +++ b/kernel/sched/fair.c
5514 @@ -7300,6 +7300,10 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
5515 if (throttled_lb_pair(task_group(p), env->src_cpu, env->dst_cpu))
5516 return 0;
5517
5518 + /* Disregard pcpu kthreads; they are where they need to be. */
5519 + if ((p->flags & PF_KTHREAD) && kthread_is_per_cpu(p))
5520 + return 0;
5521 +
5522 if (!cpumask_test_cpu(env->dst_cpu, p->cpus_ptr)) {
5523 int cpu;
5524
5525 diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
5526 index 0ec5b7a1d769f..97d4a9dcf3399 100644
5527 --- a/kernel/time/posix-timers.c
5528 +++ b/kernel/time/posix-timers.c
5529 @@ -1169,8 +1169,8 @@ SYSCALL_DEFINE2(clock_adjtime32, clockid_t, which_clock,
5530
5531 err = do_clock_adjtime(which_clock, &ktx);
5532
5533 - if (err >= 0)
5534 - err = put_old_timex32(utp, &ktx);
5535 + if (err >= 0 && put_old_timex32(utp, &ktx))
5536 + return -EFAULT;
5537
5538 return err;
5539 }
5540 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
5541 index cbb76ffaf499f..74b5c36d7759a 100644
5542 --- a/kernel/trace/ftrace.c
5543 +++ b/kernel/trace/ftrace.c
5544 @@ -5053,7 +5053,10 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
5545
5546 parser = &iter->parser;
5547 if (trace_parser_loaded(parser)) {
5548 - ftrace_match_records(iter->hash, parser->buffer, parser->idx);
5549 + int enable = !(iter->flags & FTRACE_ITER_NOTRACE);
5550 +
5551 + ftrace_process_regex(iter, parser->buffer,
5552 + parser->idx, enable);
5553 }
5554
5555 trace_parser_put(parser);
5556 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
5557 index 1b5f54b309be5..5eaa46fe9ed63 100644
5558 --- a/kernel/trace/trace.c
5559 +++ b/kernel/trace/trace.c
5560 @@ -2140,14 +2140,13 @@ static void tracing_stop_tr(struct trace_array *tr)
5561
5562 static int trace_save_cmdline(struct task_struct *tsk)
5563 {
5564 - unsigned pid, idx;
5565 + unsigned tpid, idx;
5566
5567 /* treat recording of idle task as a success */
5568 if (!tsk->pid)
5569 return 1;
5570
5571 - if (unlikely(tsk->pid > PID_MAX_DEFAULT))
5572 - return 0;
5573 + tpid = tsk->pid & (PID_MAX_DEFAULT - 1);
5574
5575 /*
5576 * It's not the end of the world if we don't get
5577 @@ -2158,26 +2157,15 @@ static int trace_save_cmdline(struct task_struct *tsk)
5578 if (!arch_spin_trylock(&trace_cmdline_lock))
5579 return 0;
5580
5581 - idx = savedcmd->map_pid_to_cmdline[tsk->pid];
5582 + idx = savedcmd->map_pid_to_cmdline[tpid];
5583 if (idx == NO_CMDLINE_MAP) {
5584 idx = (savedcmd->cmdline_idx + 1) % savedcmd->cmdline_num;
5585
5586 - /*
5587 - * Check whether the cmdline buffer at idx has a pid
5588 - * mapped. We are going to overwrite that entry so we
5589 - * need to clear the map_pid_to_cmdline. Otherwise we
5590 - * would read the new comm for the old pid.
5591 - */
5592 - pid = savedcmd->map_cmdline_to_pid[idx];
5593 - if (pid != NO_CMDLINE_MAP)
5594 - savedcmd->map_pid_to_cmdline[pid] = NO_CMDLINE_MAP;
5595 -
5596 - savedcmd->map_cmdline_to_pid[idx] = tsk->pid;
5597 - savedcmd->map_pid_to_cmdline[tsk->pid] = idx;
5598 -
5599 + savedcmd->map_pid_to_cmdline[tpid] = idx;
5600 savedcmd->cmdline_idx = idx;
5601 }
5602
5603 + savedcmd->map_cmdline_to_pid[idx] = tsk->pid;
5604 set_cmdline(idx, tsk->comm);
5605
5606 arch_spin_unlock(&trace_cmdline_lock);
5607 @@ -2188,6 +2176,7 @@ static int trace_save_cmdline(struct task_struct *tsk)
5608 static void __trace_find_cmdline(int pid, char comm[])
5609 {
5610 unsigned map;
5611 + int tpid;
5612
5613 if (!pid) {
5614 strcpy(comm, "<idle>");
5615 @@ -2199,16 +2188,16 @@ static void __trace_find_cmdline(int pid, char comm[])
5616 return;
5617 }
5618
5619 - if (pid > PID_MAX_DEFAULT) {
5620 - strcpy(comm, "<...>");
5621 - return;
5622 + tpid = pid & (PID_MAX_DEFAULT - 1);
5623 + map = savedcmd->map_pid_to_cmdline[tpid];
5624 + if (map != NO_CMDLINE_MAP) {
5625 + tpid = savedcmd->map_cmdline_to_pid[map];
5626 + if (tpid == pid) {
5627 + strlcpy(comm, get_saved_cmdlines(map), TASK_COMM_LEN);
5628 + return;
5629 + }
5630 }
5631 -
5632 - map = savedcmd->map_pid_to_cmdline[pid];
5633 - if (map != NO_CMDLINE_MAP)
5634 - strlcpy(comm, get_saved_cmdlines(map), TASK_COMM_LEN);
5635 - else
5636 - strcpy(comm, "<...>");
5637 + strcpy(comm, "<...>");
5638 }
5639
5640 void trace_find_cmdline(int pid, char comm[])
5641 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
5642 index aaf6793ededaa..c1637f90c8a38 100644
5643 --- a/kernel/trace/trace_clock.c
5644 +++ b/kernel/trace/trace_clock.c
5645 @@ -95,33 +95,49 @@ u64 notrace trace_clock_global(void)
5646 {
5647 unsigned long flags;
5648 int this_cpu;
5649 - u64 now;
5650 + u64 now, prev_time;
5651
5652 raw_local_irq_save(flags);
5653
5654 this_cpu = raw_smp_processor_id();
5655 - now = sched_clock_cpu(this_cpu);
5656 +
5657 /*
5658 - * If in an NMI context then dont risk lockups and return the
5659 - * cpu_clock() time:
5660 + * The global clock "guarantees" that the events are ordered
5661 + * between CPUs. But if two events on two different CPUS call
5662 + * trace_clock_global at roughly the same time, it really does
5663 + * not matter which one gets the earlier time. Just make sure
5664 + * that the same CPU will always show a monotonic clock.
5665 + *
5666 + * Use a read memory barrier to get the latest written
5667 + * time that was recorded.
5668 */
5669 - if (unlikely(in_nmi()))
5670 - goto out;
5671 + smp_rmb();
5672 + prev_time = READ_ONCE(trace_clock_struct.prev_time);
5673 + now = sched_clock_cpu(this_cpu);
5674
5675 - arch_spin_lock(&trace_clock_struct.lock);
5676 + /* Make sure that now is always greater than prev_time */
5677 + if ((s64)(now - prev_time) < 0)
5678 + now = prev_time + 1;
5679
5680 /*
5681 - * TODO: if this happens often then maybe we should reset
5682 - * my_scd->clock to prev_time+1, to make sure
5683 - * we start ticking with the local clock from now on?
5684 + * If in an NMI context then dont risk lockups and simply return
5685 + * the current time.
5686 */
5687 - if ((s64)(now - trace_clock_struct.prev_time) < 0)
5688 - now = trace_clock_struct.prev_time + 1;
5689 + if (unlikely(in_nmi()))
5690 + goto out;
5691
5692 - trace_clock_struct.prev_time = now;
5693 + /* Tracing can cause strange recursion, always use a try lock */
5694 + if (arch_spin_trylock(&trace_clock_struct.lock)) {
5695 + /* Reread prev_time in case it was already updated */
5696 + prev_time = READ_ONCE(trace_clock_struct.prev_time);
5697 + if ((s64)(now - prev_time) < 0)
5698 + now = prev_time + 1;
5699
5700 - arch_spin_unlock(&trace_clock_struct.lock);
5701 + trace_clock_struct.prev_time = now;
5702
5703 + /* The unlock acts as the wmb for the above rmb */
5704 + arch_spin_unlock(&trace_clock_struct.lock);
5705 + }
5706 out:
5707 raw_local_irq_restore(flags);
5708
5709 diff --git a/net/bluetooth/ecdh_helper.h b/net/bluetooth/ecdh_helper.h
5710 index a6f8d03d4aaf6..830723971cf83 100644
5711 --- a/net/bluetooth/ecdh_helper.h
5712 +++ b/net/bluetooth/ecdh_helper.h
5713 @@ -25,6 +25,6 @@
5714
5715 int compute_ecdh_secret(struct crypto_kpp *tfm, const u8 pair_public_key[64],
5716 u8 secret[32]);
5717 -int set_ecdh_privkey(struct crypto_kpp *tfm, const u8 *private_key);
5718 +int set_ecdh_privkey(struct crypto_kpp *tfm, const u8 private_key[32]);
5719 int generate_ecdh_public_key(struct crypto_kpp *tfm, u8 public_key[64]);
5720 int generate_ecdh_keys(struct crypto_kpp *tfm, u8 public_key[64]);
5721 diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
5722 index 425e146523cc9..5c68f9ea98810 100644
5723 --- a/net/openvswitch/actions.c
5724 +++ b/net/openvswitch/actions.c
5725 @@ -831,17 +831,17 @@ static void ovs_fragment(struct net *net, struct vport *vport,
5726 }
5727
5728 if (key->eth.type == htons(ETH_P_IP)) {
5729 - struct dst_entry ovs_dst;
5730 + struct rtable ovs_rt = { 0 };
5731 unsigned long orig_dst;
5732
5733 prepare_frag(vport, skb, orig_network_offset,
5734 ovs_key_mac_proto(key));
5735 - dst_init(&ovs_dst, &ovs_dst_ops, NULL, 1,
5736 + dst_init(&ovs_rt.dst, &ovs_dst_ops, NULL, 1,
5737 DST_OBSOLETE_NONE, DST_NOCOUNT);
5738 - ovs_dst.dev = vport->dev;
5739 + ovs_rt.dst.dev = vport->dev;
5740
5741 orig_dst = skb->_skb_refdst;
5742 - skb_dst_set_noref(skb, &ovs_dst);
5743 + skb_dst_set_noref(skb, &ovs_rt.dst);
5744 IPCB(skb)->frag_max_size = mru;
5745
5746 ip_do_fragment(net, skb->sk, skb, ovs_vport_output);
5747 diff --git a/security/commoncap.c b/security/commoncap.c
5748 index 28a6939bcc4e5..1c70d11491863 100644
5749 --- a/security/commoncap.c
5750 +++ b/security/commoncap.c
5751 @@ -391,7 +391,7 @@ int cap_inode_getsecurity(struct inode *inode, const char *name, void **buffer,
5752 &tmpbuf, size, GFP_NOFS);
5753 dput(dentry);
5754
5755 - if (ret < 0)
5756 + if (ret < 0 || !tmpbuf)
5757 return ret;
5758
5759 fs_ns = inode->i_sb->s_user_ns;
5760 diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c
5761 index 433e32e254f90..91c96fad06185 100644
5762 --- a/sound/isa/sb/emu8000.c
5763 +++ b/sound/isa/sb/emu8000.c
5764 @@ -1029,8 +1029,10 @@ snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu)
5765
5766 memset(emu->controls, 0, sizeof(emu->controls));
5767 for (i = 0; i < EMU8000_NUM_CONTROLS; i++) {
5768 - if ((err = snd_ctl_add(card, emu->controls[i] = snd_ctl_new1(mixer_defs[i], emu))) < 0)
5769 + if ((err = snd_ctl_add(card, emu->controls[i] = snd_ctl_new1(mixer_defs[i], emu))) < 0) {
5770 + emu->controls[i] = NULL;
5771 goto __error;
5772 + }
5773 }
5774 return 0;
5775
5776 diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c
5777 index 4ad0ff0c4508c..69960cf1bb51d 100644
5778 --- a/sound/isa/sb/sb16_csp.c
5779 +++ b/sound/isa/sb/sb16_csp.c
5780 @@ -1045,10 +1045,14 @@ static int snd_sb_qsound_build(struct snd_sb_csp * p)
5781
5782 spin_lock_init(&p->q_lock);
5783
5784 - if ((err = snd_ctl_add(card, p->qsound_switch = snd_ctl_new1(&snd_sb_qsound_switch, p))) < 0)
5785 + if ((err = snd_ctl_add(card, p->qsound_switch = snd_ctl_new1(&snd_sb_qsound_switch, p))) < 0) {
5786 + p->qsound_switch = NULL;
5787 goto __error;
5788 - if ((err = snd_ctl_add(card, p->qsound_space = snd_ctl_new1(&snd_sb_qsound_space, p))) < 0)
5789 + }
5790 + if ((err = snd_ctl_add(card, p->qsound_space = snd_ctl_new1(&snd_sb_qsound_space, p))) < 0) {
5791 + p->qsound_space = NULL;
5792 goto __error;
5793 + }
5794
5795 return 0;
5796
5797 diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
5798 index c3a1ce129b3d9..5e2fadb264e4d 100644
5799 --- a/sound/pci/hda/patch_conexant.c
5800 +++ b/sound/pci/hda/patch_conexant.c
5801 @@ -898,18 +898,18 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
5802 SND_PCI_QUIRK(0x103c, 0x8079, "HP EliteBook 840 G3", CXT_FIXUP_HP_DOCK),
5803 SND_PCI_QUIRK(0x103c, 0x807C, "HP EliteBook 820 G3", CXT_FIXUP_HP_DOCK),
5804 SND_PCI_QUIRK(0x103c, 0x80FD, "HP ProBook 640 G2", CXT_FIXUP_HP_DOCK),
5805 - SND_PCI_QUIRK(0x103c, 0x828c, "HP EliteBook 840 G4", CXT_FIXUP_HP_DOCK),
5806 - SND_PCI_QUIRK(0x103c, 0x83b2, "HP EliteBook 840 G5", CXT_FIXUP_HP_DOCK),
5807 - SND_PCI_QUIRK(0x103c, 0x83b3, "HP EliteBook 830 G5", CXT_FIXUP_HP_DOCK),
5808 - SND_PCI_QUIRK(0x103c, 0x83d3, "HP ProBook 640 G4", CXT_FIXUP_HP_DOCK),
5809 - SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE),
5810 SND_PCI_QUIRK(0x103c, 0x8115, "HP Z1 Gen3", CXT_FIXUP_HP_GATE_MIC),
5811 SND_PCI_QUIRK(0x103c, 0x814f, "HP ZBook 15u G3", CXT_FIXUP_MUTE_LED_GPIO),
5812 + SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE),
5813 SND_PCI_QUIRK(0x103c, 0x822e, "HP ProBook 440 G4", CXT_FIXUP_MUTE_LED_GPIO),
5814 - SND_PCI_QUIRK(0x103c, 0x836e, "HP ProBook 455 G5", CXT_FIXUP_MUTE_LED_GPIO),
5815 - SND_PCI_QUIRK(0x103c, 0x837f, "HP ProBook 470 G5", CXT_FIXUP_MUTE_LED_GPIO),
5816 + SND_PCI_QUIRK(0x103c, 0x828c, "HP EliteBook 840 G4", CXT_FIXUP_HP_DOCK),
5817 SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
5818 SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE),
5819 + SND_PCI_QUIRK(0x103c, 0x836e, "HP ProBook 455 G5", CXT_FIXUP_MUTE_LED_GPIO),
5820 + SND_PCI_QUIRK(0x103c, 0x837f, "HP ProBook 470 G5", CXT_FIXUP_MUTE_LED_GPIO),
5821 + SND_PCI_QUIRK(0x103c, 0x83b2, "HP EliteBook 840 G5", CXT_FIXUP_HP_DOCK),
5822 + SND_PCI_QUIRK(0x103c, 0x83b3, "HP EliteBook 830 G5", CXT_FIXUP_HP_DOCK),
5823 + SND_PCI_QUIRK(0x103c, 0x83d3, "HP ProBook 640 G4", CXT_FIXUP_HP_DOCK),
5824 SND_PCI_QUIRK(0x103c, 0x8402, "HP ProBook 645 G4", CXT_FIXUP_MUTE_LED_GPIO),
5825 SND_PCI_QUIRK(0x103c, 0x8455, "HP Z2 G4", CXT_FIXUP_HP_MIC_NO_PRESENCE),
5826 SND_PCI_QUIRK(0x103c, 0x8456, "HP Z2 G4 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
5827 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
5828 index e3fab993b3395..3b47ca4f7cac7 100644
5829 --- a/sound/pci/hda/patch_realtek.c
5830 +++ b/sound/pci/hda/patch_realtek.c
5831 @@ -2542,8 +2542,10 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
5832 SND_PCI_QUIRK(0x1558, 0x65d1, "Clevo PB51[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
5833 SND_PCI_QUIRK(0x1558, 0x65d2, "Clevo PB51R[CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
5834 SND_PCI_QUIRK(0x1558, 0x65e1, "Clevo PB51[ED][DF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
5835 + SND_PCI_QUIRK(0x1558, 0x65e5, "Clevo PC50D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
5836 SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
5837 SND_PCI_QUIRK(0x1558, 0x67e1, "Clevo PB71[DE][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
5838 + SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
5839 SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
5840 SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
5841 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
5842 @@ -6332,6 +6334,8 @@ enum {
5843 ALC269_FIXUP_LEMOTE_A1802,
5844 ALC269_FIXUP_LEMOTE_A190X,
5845 ALC256_FIXUP_INTEL_NUC8_RUGGED,
5846 + ALC233_FIXUP_INTEL_NUC8_DMIC,
5847 + ALC233_FIXUP_INTEL_NUC8_BOOST,
5848 ALC256_FIXUP_INTEL_NUC10,
5849 ALC255_FIXUP_XIAOMI_HEADSET_MIC,
5850 ALC274_FIXUP_HP_MIC,
5851 @@ -7043,6 +7047,16 @@ static const struct hda_fixup alc269_fixups[] = {
5852 .type = HDA_FIXUP_FUNC,
5853 .v.func = alc233_fixup_lenovo_line2_mic_hotkey,
5854 },
5855 + [ALC233_FIXUP_INTEL_NUC8_DMIC] = {
5856 + .type = HDA_FIXUP_FUNC,
5857 + .v.func = alc_fixup_inv_dmic,
5858 + .chained = true,
5859 + .chain_id = ALC233_FIXUP_INTEL_NUC8_BOOST,
5860 + },
5861 + [ALC233_FIXUP_INTEL_NUC8_BOOST] = {
5862 + .type = HDA_FIXUP_FUNC,
5863 + .v.func = alc269_fixup_limit_int_mic_boost
5864 + },
5865 [ALC255_FIXUP_DELL_SPK_NOISE] = {
5866 .type = HDA_FIXUP_FUNC,
5867 .v.func = alc_fixup_disable_aamix,
5868 @@ -7958,6 +7972,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5869 SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
5870 SND_PCI_QUIRK(0x1043, 0x1d4e, "ASUS TM420", ALC256_FIXUP_ASUS_HPE),
5871 SND_PCI_QUIRK(0x1043, 0x1e11, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA502),
5872 + SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401),
5873 SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401),
5874 SND_PCI_QUIRK(0x1043, 0x1881, "ASUS Zephyrus S/M", ALC294_FIXUP_ASUS_GX502_PINS),
5875 SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
5876 @@ -8124,6 +8139,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5877 SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
5878 SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802),
5879 SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X),
5880 + SND_PCI_QUIRK(0x8086, 0x2074, "Intel NUC 8", ALC233_FIXUP_INTEL_NUC8_DMIC),
5881 SND_PCI_QUIRK(0x8086, 0x2080, "Intel NUC 8 Rugged", ALC256_FIXUP_INTEL_NUC8_RUGGED),
5882 SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", ALC256_FIXUP_INTEL_NUC10),
5883
5884 @@ -8583,12 +8599,7 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
5885 {0x12, 0x90a60130},
5886 {0x19, 0x03a11020},
5887 {0x21, 0x0321101f}),
5888 - SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
5889 - {0x14, 0x90170110},
5890 - {0x19, 0x04a11040},
5891 - {0x21, 0x04211020}),
5892 SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
5893 - {0x12, 0x90a60130},
5894 {0x14, 0x90170110},
5895 {0x19, 0x04a11040},
5896 {0x21, 0x04211020}),
5897 @@ -8756,6 +8767,10 @@ static const struct snd_hda_pin_quirk alc269_fallback_pin_fixup_tbl[] = {
5898 SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5899 {0x19, 0x40000000},
5900 {0x1a, 0x40000000}),
5901 + SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
5902 + {0x14, 0x90170110},
5903 + {0x19, 0x04a11040},
5904 + {0x21, 0x04211020}),
5905 {}
5906 };
5907
5908 diff --git a/sound/usb/clock.c b/sound/usb/clock.c
5909 index 385a488c25cb0..6a51b9d20eebf 100644
5910 --- a/sound/usb/clock.c
5911 +++ b/sound/usb/clock.c
5912 @@ -296,7 +296,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
5913
5914 selector = snd_usb_find_clock_selector(chip->ctrl_intf, entity_id);
5915 if (selector) {
5916 - int ret, i, cur;
5917 + int ret, i, cur, err;
5918
5919 /* the entity ID we are looking for is a selector.
5920 * find out what it currently selects */
5921 @@ -318,13 +318,17 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
5922 ret = __uac_clock_find_source(chip, fmt,
5923 selector->baCSourceID[ret - 1],
5924 visited, validate);
5925 + if (ret > 0) {
5926 + err = uac_clock_selector_set_val(chip, entity_id, cur);
5927 + if (err < 0)
5928 + return err;
5929 + }
5930 +
5931 if (!validate || ret > 0 || !chip->autoclock)
5932 return ret;
5933
5934 /* The current clock source is invalid, try others. */
5935 for (i = 1; i <= selector->bNrInPins; i++) {
5936 - int err;
5937 -
5938 if (i == cur)
5939 continue;
5940
5941 @@ -390,7 +394,7 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip,
5942
5943 selector = snd_usb_find_clock_selector_v3(chip->ctrl_intf, entity_id);
5944 if (selector) {
5945 - int ret, i, cur;
5946 + int ret, i, cur, err;
5947
5948 /* the entity ID we are looking for is a selector.
5949 * find out what it currently selects */
5950 @@ -412,6 +416,12 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip,
5951 ret = __uac3_clock_find_source(chip, fmt,
5952 selector->baCSourceID[ret - 1],
5953 visited, validate);
5954 + if (ret > 0) {
5955 + err = uac_clock_selector_set_val(chip, entity_id, cur);
5956 + if (err < 0)
5957 + return err;
5958 + }
5959 +
5960 if (!validate || ret > 0 || !chip->autoclock)
5961 return ret;
5962
5963 diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
5964 index 8aa96ed0b1b56..f4f8778e907a9 100644
5965 --- a/sound/usb/mixer.c
5966 +++ b/sound/usb/mixer.c
5967 @@ -1030,7 +1030,7 @@ struct usb_feature_control_info {
5968 int type_uac2; /* data type for uac2 if different from uac1, else -1 */
5969 };
5970
5971 -static struct usb_feature_control_info audio_feature_info[] = {
5972 +static const struct usb_feature_control_info audio_feature_info[] = {
5973 { UAC_FU_MUTE, "Mute", USB_MIXER_INV_BOOLEAN, -1 },
5974 { UAC_FU_VOLUME, "Volume", USB_MIXER_S16, -1 },
5975 { UAC_FU_BASS, "Tone Control - Bass", USB_MIXER_S8, -1 },
5976 @@ -1544,7 +1544,7 @@ static void check_no_speaker_on_headset(struct snd_kcontrol *kctl,
5977 strlcpy(kctl->id.name, "Headphone", sizeof(kctl->id.name));
5978 }
5979
5980 -static struct usb_feature_control_info *get_feature_control_info(int control)
5981 +static const struct usb_feature_control_info *get_feature_control_info(int control)
5982 {
5983 int i;
5984
5985 @@ -1562,7 +1562,7 @@ static void __build_feature_ctl(struct usb_mixer_interface *mixer,
5986 struct usb_audio_term *oterm,
5987 int unitid, int nameid, int readonly_mask)
5988 {
5989 - struct usb_feature_control_info *ctl_info;
5990 + const struct usb_feature_control_info *ctl_info;
5991 unsigned int len = 0;
5992 int mapped_name = 0;
5993 struct snd_kcontrol *kctl;
5994 @@ -2237,7 +2237,7 @@ static const struct snd_kcontrol_new mixer_procunit_ctl = {
5995 */
5996 struct procunit_value_info {
5997 int control;
5998 - char *suffix;
5999 + const char *suffix;
6000 int val_type;
6001 int min_value;
6002 };
6003 @@ -2245,44 +2245,44 @@ struct procunit_value_info {
6004 struct procunit_info {
6005 int type;
6006 char *name;
6007 - struct procunit_value_info *values;
6008 + const struct procunit_value_info *values;
6009 };
6010
6011 -static struct procunit_value_info undefined_proc_info[] = {
6012 +static const struct procunit_value_info undefined_proc_info[] = {
6013 { 0x00, "Control Undefined", 0 },
6014 { 0 }
6015 };
6016
6017 -static struct procunit_value_info updown_proc_info[] = {
6018 +static const struct procunit_value_info updown_proc_info[] = {
6019 { UAC_UD_ENABLE, "Switch", USB_MIXER_BOOLEAN },
6020 { UAC_UD_MODE_SELECT, "Mode Select", USB_MIXER_U8, 1 },
6021 { 0 }
6022 };
6023 -static struct procunit_value_info prologic_proc_info[] = {
6024 +static const struct procunit_value_info prologic_proc_info[] = {
6025 { UAC_DP_ENABLE, "Switch", USB_MIXER_BOOLEAN },
6026 { UAC_DP_MODE_SELECT, "Mode Select", USB_MIXER_U8, 1 },
6027 { 0 }
6028 };
6029 -static struct procunit_value_info threed_enh_proc_info[] = {
6030 +static const struct procunit_value_info threed_enh_proc_info[] = {
6031 { UAC_3D_ENABLE, "Switch", USB_MIXER_BOOLEAN },
6032 { UAC_3D_SPACE, "Spaciousness", USB_MIXER_U8 },
6033 { 0 }
6034 };
6035 -static struct procunit_value_info reverb_proc_info[] = {
6036 +static const struct procunit_value_info reverb_proc_info[] = {
6037 { UAC_REVERB_ENABLE, "Switch", USB_MIXER_BOOLEAN },
6038 { UAC_REVERB_LEVEL, "Level", USB_MIXER_U8 },
6039 { UAC_REVERB_TIME, "Time", USB_MIXER_U16 },
6040 { UAC_REVERB_FEEDBACK, "Feedback", USB_MIXER_U8 },
6041 { 0 }
6042 };
6043 -static struct procunit_value_info chorus_proc_info[] = {
6044 +static const struct procunit_value_info chorus_proc_info[] = {
6045 { UAC_CHORUS_ENABLE, "Switch", USB_MIXER_BOOLEAN },
6046 { UAC_CHORUS_LEVEL, "Level", USB_MIXER_U8 },
6047 { UAC_CHORUS_RATE, "Rate", USB_MIXER_U16 },
6048 { UAC_CHORUS_DEPTH, "Depth", USB_MIXER_U16 },
6049 { 0 }
6050 };
6051 -static struct procunit_value_info dcr_proc_info[] = {
6052 +static const struct procunit_value_info dcr_proc_info[] = {
6053 { UAC_DCR_ENABLE, "Switch", USB_MIXER_BOOLEAN },
6054 { UAC_DCR_RATE, "Ratio", USB_MIXER_U16 },
6055 { UAC_DCR_MAXAMPL, "Max Amp", USB_MIXER_S16 },
6056 @@ -2292,7 +2292,7 @@ static struct procunit_value_info dcr_proc_info[] = {
6057 { 0 }
6058 };
6059
6060 -static struct procunit_info procunits[] = {
6061 +static const struct procunit_info procunits[] = {
6062 { UAC_PROCESS_UP_DOWNMIX, "Up Down", updown_proc_info },
6063 { UAC_PROCESS_DOLBY_PROLOGIC, "Dolby Prologic", prologic_proc_info },
6064 { UAC_PROCESS_STEREO_EXTENDER, "3D Stereo Extender", threed_enh_proc_info },
6065 @@ -2302,16 +2302,16 @@ static struct procunit_info procunits[] = {
6066 { 0 },
6067 };
6068
6069 -static struct procunit_value_info uac3_updown_proc_info[] = {
6070 +static const struct procunit_value_info uac3_updown_proc_info[] = {
6071 { UAC3_UD_MODE_SELECT, "Mode Select", USB_MIXER_U8, 1 },
6072 { 0 }
6073 };
6074 -static struct procunit_value_info uac3_stereo_ext_proc_info[] = {
6075 +static const struct procunit_value_info uac3_stereo_ext_proc_info[] = {
6076 { UAC3_EXT_WIDTH_CONTROL, "Width Control", USB_MIXER_U8 },
6077 { 0 }
6078 };
6079
6080 -static struct procunit_info uac3_procunits[] = {
6081 +static const struct procunit_info uac3_procunits[] = {
6082 { UAC3_PROCESS_UP_DOWNMIX, "Up Down", uac3_updown_proc_info },
6083 { UAC3_PROCESS_STEREO_EXTENDER, "3D Stereo Extender", uac3_stereo_ext_proc_info },
6084 { UAC3_PROCESS_MULTI_FUNCTION, "Multi-Function", undefined_proc_info },
6085 @@ -2321,23 +2321,23 @@ static struct procunit_info uac3_procunits[] = {
6086 /*
6087 * predefined data for extension units
6088 */
6089 -static struct procunit_value_info clock_rate_xu_info[] = {
6090 +static const struct procunit_value_info clock_rate_xu_info[] = {
6091 { USB_XU_CLOCK_RATE_SELECTOR, "Selector", USB_MIXER_U8, 0 },
6092 { 0 }
6093 };
6094 -static struct procunit_value_info clock_source_xu_info[] = {
6095 +static const struct procunit_value_info clock_source_xu_info[] = {
6096 { USB_XU_CLOCK_SOURCE_SELECTOR, "External", USB_MIXER_BOOLEAN },
6097 { 0 }
6098 };
6099 -static struct procunit_value_info spdif_format_xu_info[] = {
6100 +static const struct procunit_value_info spdif_format_xu_info[] = {
6101 { USB_XU_DIGITAL_FORMAT_SELECTOR, "SPDIF/AC3", USB_MIXER_BOOLEAN },
6102 { 0 }
6103 };
6104 -static struct procunit_value_info soft_limit_xu_info[] = {
6105 +static const struct procunit_value_info soft_limit_xu_info[] = {
6106 { USB_XU_SOFT_LIMIT_SELECTOR, " ", USB_MIXER_BOOLEAN },
6107 { 0 }
6108 };
6109 -static struct procunit_info extunits[] = {
6110 +static const struct procunit_info extunits[] = {
6111 { USB_XU_CLOCK_RATE, "Clock rate", clock_rate_xu_info },
6112 { USB_XU_CLOCK_SOURCE, "DigitalIn CLK source", clock_source_xu_info },
6113 { USB_XU_DIGITAL_IO_STATUS, "DigitalOut format:", spdif_format_xu_info },
6114 @@ -2349,7 +2349,7 @@ static struct procunit_info extunits[] = {
6115 * build a processing/extension unit
6116 */
6117 static int build_audio_procunit(struct mixer_build *state, int unitid,
6118 - void *raw_desc, struct procunit_info *list,
6119 + void *raw_desc, const struct procunit_info *list,
6120 bool extension_unit)
6121 {
6122 struct uac_processing_unit_descriptor *desc = raw_desc;
6123 @@ -2357,14 +2357,14 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
6124 struct usb_mixer_elem_info *cval;
6125 struct snd_kcontrol *kctl;
6126 int i, err, nameid, type, len;
6127 - struct procunit_info *info;
6128 - struct procunit_value_info *valinfo;
6129 + const struct procunit_info *info;
6130 + const struct procunit_value_info *valinfo;
6131 const struct usbmix_name_map *map;
6132 - static struct procunit_value_info default_value_info[] = {
6133 + static const struct procunit_value_info default_value_info[] = {
6134 { 0x01, "Switch", USB_MIXER_BOOLEAN },
6135 { 0 }
6136 };
6137 - static struct procunit_info default_info = {
6138 + static const struct procunit_info default_info = {
6139 0, NULL, default_value_info
6140 };
6141 const char *name = extension_unit ?
6142 @@ -2842,7 +2842,7 @@ struct uac3_badd_profile {
6143 int st_chmask; /* side tone mixing channel mask */
6144 };
6145
6146 -static struct uac3_badd_profile uac3_badd_profiles[] = {
6147 +static const struct uac3_badd_profile uac3_badd_profiles[] = {
6148 {
6149 /*
6150 * BAIF, BAOF or combination of both
6151 @@ -2903,7 +2903,7 @@ static struct uac3_badd_profile uac3_badd_profiles[] = {
6152 };
6153
6154 static bool uac3_badd_func_has_valid_channels(struct usb_mixer_interface *mixer,
6155 - struct uac3_badd_profile *f,
6156 + const struct uac3_badd_profile *f,
6157 int c_chmask, int p_chmask)
6158 {
6159 /*
6160 @@ -2947,7 +2947,7 @@ static int snd_usb_mixer_controls_badd(struct usb_mixer_interface *mixer,
6161 struct usb_device *dev = mixer->chip->dev;
6162 struct usb_interface_assoc_descriptor *assoc;
6163 int badd_profile = mixer->chip->badd_profile;
6164 - struct uac3_badd_profile *f;
6165 + const struct uac3_badd_profile *f;
6166 const struct usbmix_ctl_map *map;
6167 int p_chmask = 0, c_chmask = 0, st_chmask = 0;
6168 int i;
6169 @@ -3241,7 +3241,7 @@ static void snd_usb_mixer_dump_cval(struct snd_info_buffer *buffer,
6170 struct usb_mixer_elem_list *list)
6171 {
6172 struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list);
6173 - static char *val_types[] = {"BOOLEAN", "INV_BOOLEAN",
6174 + static const char * const val_types[] = {"BOOLEAN", "INV_BOOLEAN",
6175 "S8", "U8", "S16", "U16"};
6176 snd_iprintf(buffer, " Info: id=%i, control=%i, cmask=0x%x, "
6177 "channels=%i, type=\"%s\"\n", cval->head.id,
6178 diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c
6179 index ac84f0b2b0bc7..dda13624a28cd 100644
6180 --- a/sound/usb/mixer_maps.c
6181 +++ b/sound/usb/mixer_maps.c
6182 @@ -14,7 +14,7 @@ struct usbmix_name_map {
6183 int id;
6184 const char *name;
6185 int control;
6186 - struct usbmix_dB_map *dB;
6187 + const struct usbmix_dB_map *dB;
6188 };
6189
6190 struct usbmix_selector_map {
6191 @@ -53,7 +53,7 @@ Mic-IN[9] --+->FU[10]----------------------------+ |
6192 ++--+->SU[11]-->FU[12] --------------------------------------------------------------------------------------> USB_OUT[13]
6193 */
6194
6195 -static struct usbmix_name_map extigy_map[] = {
6196 +static const struct usbmix_name_map extigy_map[] = {
6197 /* 1: IT pcm */
6198 { 2, "PCM Playback" }, /* FU */
6199 /* 3: IT pcm */
6200 @@ -94,12 +94,12 @@ static struct usbmix_name_map extigy_map[] = {
6201 * e.g. no Master and fake PCM volume
6202 * Pavel Mihaylov <bin@bash.info>
6203 */
6204 -static struct usbmix_dB_map mp3plus_dB_1 = {.min = -4781, .max = 0};
6205 +static const struct usbmix_dB_map mp3plus_dB_1 = {.min = -4781, .max = 0};
6206 /* just guess */
6207 -static struct usbmix_dB_map mp3plus_dB_2 = {.min = -1781, .max = 618};
6208 +static const struct usbmix_dB_map mp3plus_dB_2 = {.min = -1781, .max = 618};
6209 /* just guess */
6210
6211 -static struct usbmix_name_map mp3plus_map[] = {
6212 +static const struct usbmix_name_map mp3plus_map[] = {
6213 /* 1: IT pcm */
6214 /* 2: IT mic */
6215 /* 3: IT line */
6216 @@ -140,7 +140,7 @@ Lin_IN[7]-+--->FU[8]---+ +->EU[23]->FU[28]------------->Spk_OUT[19]
6217 | ^
6218 +->FU[13]--------------------------------------+
6219 */
6220 -static struct usbmix_name_map audigy2nx_map[] = {
6221 +static const struct usbmix_name_map audigy2nx_map[] = {
6222 /* 1: IT pcm playback */
6223 /* 4: IT digital in */
6224 { 6, "Digital In Playback" }, /* FU */
6225 @@ -168,12 +168,12 @@ static struct usbmix_name_map audigy2nx_map[] = {
6226 { 0 } /* terminator */
6227 };
6228
6229 -static struct usbmix_name_map mbox1_map[] = {
6230 +static const struct usbmix_name_map mbox1_map[] = {
6231 { 1, "Clock" },
6232 { 0 } /* terminator */
6233 };
6234
6235 -static struct usbmix_selector_map c400_selectors[] = {
6236 +static const struct usbmix_selector_map c400_selectors[] = {
6237 {
6238 .id = 0x80,
6239 .count = 2,
6240 @@ -182,7 +182,7 @@ static struct usbmix_selector_map c400_selectors[] = {
6241 { 0 } /* terminator */
6242 };
6243
6244 -static struct usbmix_selector_map audigy2nx_selectors[] = {
6245 +static const struct usbmix_selector_map audigy2nx_selectors[] = {
6246 {
6247 .id = 14, /* Capture Source */
6248 .count = 3,
6249 @@ -202,21 +202,21 @@ static struct usbmix_selector_map audigy2nx_selectors[] = {
6250 };
6251
6252 /* Creative SoundBlaster Live! 24-bit External */
6253 -static struct usbmix_name_map live24ext_map[] = {
6254 +static const struct usbmix_name_map live24ext_map[] = {
6255 /* 2: PCM Playback Volume */
6256 { 5, "Mic Capture" }, /* FU, default PCM Capture Volume */
6257 { 0 } /* terminator */
6258 };
6259
6260 /* LineX FM Transmitter entry - needed to bypass controls bug */
6261 -static struct usbmix_name_map linex_map[] = {
6262 +static const struct usbmix_name_map linex_map[] = {
6263 /* 1: IT pcm */
6264 /* 2: OT Speaker */
6265 { 3, "Master" }, /* FU: master volume - left / right / mute */
6266 { 0 } /* terminator */
6267 };
6268
6269 -static struct usbmix_name_map maya44_map[] = {
6270 +static const struct usbmix_name_map maya44_map[] = {
6271 /* 1: IT line */
6272 { 2, "Line Playback" }, /* FU */
6273 /* 3: IT line */
6274 @@ -239,7 +239,7 @@ static struct usbmix_name_map maya44_map[] = {
6275 * so this map removes all unwanted sliders from alsamixer
6276 */
6277
6278 -static struct usbmix_name_map justlink_map[] = {
6279 +static const struct usbmix_name_map justlink_map[] = {
6280 /* 1: IT pcm playback */
6281 /* 2: Not present */
6282 { 3, NULL}, /* IT mic (No mic input on device) */
6283 @@ -256,7 +256,7 @@ static struct usbmix_name_map justlink_map[] = {
6284 };
6285
6286 /* TerraTec Aureon 5.1 MkII USB */
6287 -static struct usbmix_name_map aureon_51_2_map[] = {
6288 +static const struct usbmix_name_map aureon_51_2_map[] = {
6289 /* 1: IT USB */
6290 /* 2: IT Mic */
6291 /* 3: IT Line */
6292 @@ -275,7 +275,7 @@ static struct usbmix_name_map aureon_51_2_map[] = {
6293 {} /* terminator */
6294 };
6295
6296 -static struct usbmix_name_map scratch_live_map[] = {
6297 +static const struct usbmix_name_map scratch_live_map[] = {
6298 /* 1: IT Line 1 (USB streaming) */
6299 /* 2: OT Line 1 (Speaker) */
6300 /* 3: IT Line 1 (Line connector) */
6301 @@ -291,7 +291,7 @@ static struct usbmix_name_map scratch_live_map[] = {
6302 { 0 } /* terminator */
6303 };
6304
6305 -static struct usbmix_name_map ebox44_map[] = {
6306 +static const struct usbmix_name_map ebox44_map[] = {
6307 { 4, NULL }, /* FU */
6308 { 6, NULL }, /* MU */
6309 { 7, NULL }, /* FU */
6310 @@ -306,7 +306,7 @@ static struct usbmix_name_map ebox44_map[] = {
6311 * FIXME: or mp3plus_map should use "Capture Source" too,
6312 * so this maps can be merget
6313 */
6314 -static struct usbmix_name_map hercules_usb51_map[] = {
6315 +static const struct usbmix_name_map hercules_usb51_map[] = {
6316 { 8, "Capture Source" }, /* SU, default "PCM Capture Source" */
6317 { 9, "Master Playback" }, /* FU, default "Speaker Playback" */
6318 { 10, "Mic Boost", 7 }, /* FU, default "Auto Gain Input" */
6319 @@ -317,7 +317,7 @@ static struct usbmix_name_map hercules_usb51_map[] = {
6320 };
6321
6322 /* Plantronics Gamecom 780 has a broken volume control, better to disable it */
6323 -static struct usbmix_name_map gamecom780_map[] = {
6324 +static const struct usbmix_name_map gamecom780_map[] = {
6325 { 9, NULL }, /* FU, speaker out */
6326 {}
6327 };
6328 @@ -331,12 +331,19 @@ static const struct usbmix_name_map scms_usb3318_map[] = {
6329 };
6330
6331 /* Bose companion 5, the dB conversion factor is 16 instead of 256 */
6332 -static struct usbmix_dB_map bose_companion5_dB = {-5006, -6};
6333 -static struct usbmix_name_map bose_companion5_map[] = {
6334 +static const struct usbmix_dB_map bose_companion5_dB = {-5006, -6};
6335 +static const struct usbmix_name_map bose_companion5_map[] = {
6336 { 3, NULL, .dB = &bose_companion5_dB },
6337 { 0 } /* terminator */
6338 };
6339
6340 +/* Sennheiser Communications Headset [PC 8], the dB value is reported as -6 negative maximum */
6341 +static const struct usbmix_dB_map sennheiser_pc8_dB = {-9500, 0};
6342 +static const struct usbmix_name_map sennheiser_pc8_map[] = {
6343 + { 9, NULL, .dB = &sennheiser_pc8_dB },
6344 + { 0 } /* terminator */
6345 +};
6346 +
6347 /*
6348 * Dell usb dock with ALC4020 codec had a firmware problem where it got
6349 * screwed up when zero volume is passed; just skip it as a workaround
6350 @@ -406,7 +413,7 @@ static const struct usbmix_name_map aorus_master_alc1220vb_map[] = {
6351 * Control map entries
6352 */
6353
6354 -static struct usbmix_ctl_map usbmix_ctl_maps[] = {
6355 +static const struct usbmix_ctl_map usbmix_ctl_maps[] = {
6356 {
6357 .id = USB_ID(0x041e, 0x3000),
6358 .map = extigy_map,
6359 @@ -560,37 +567,37 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
6360 * Control map entries for UAC3 BADD profiles
6361 */
6362
6363 -static struct usbmix_name_map uac3_badd_generic_io_map[] = {
6364 +static const struct usbmix_name_map uac3_badd_generic_io_map[] = {
6365 { UAC3_BADD_FU_ID2, "Generic Out Playback" },
6366 { UAC3_BADD_FU_ID5, "Generic In Capture" },
6367 { 0 } /* terminator */
6368 };
6369 -static struct usbmix_name_map uac3_badd_headphone_map[] = {
6370 +static const struct usbmix_name_map uac3_badd_headphone_map[] = {
6371 { UAC3_BADD_FU_ID2, "Headphone Playback" },
6372 { 0 } /* terminator */
6373 };
6374 -static struct usbmix_name_map uac3_badd_speaker_map[] = {
6375 +static const struct usbmix_name_map uac3_badd_speaker_map[] = {
6376 { UAC3_BADD_FU_ID2, "Speaker Playback" },
6377 { 0 } /* terminator */
6378 };
6379 -static struct usbmix_name_map uac3_badd_microphone_map[] = {
6380 +static const struct usbmix_name_map uac3_badd_microphone_map[] = {
6381 { UAC3_BADD_FU_ID5, "Mic Capture" },
6382 { 0 } /* terminator */
6383 };
6384 /* Covers also 'headset adapter' profile */
6385 -static struct usbmix_name_map uac3_badd_headset_map[] = {
6386 +static const struct usbmix_name_map uac3_badd_headset_map[] = {
6387 { UAC3_BADD_FU_ID2, "Headset Playback" },
6388 { UAC3_BADD_FU_ID5, "Headset Capture" },
6389 { UAC3_BADD_FU_ID7, "Sidetone Mixing" },
6390 { 0 } /* terminator */
6391 };
6392 -static struct usbmix_name_map uac3_badd_speakerphone_map[] = {
6393 +static const struct usbmix_name_map uac3_badd_speakerphone_map[] = {
6394 { UAC3_BADD_FU_ID2, "Speaker Playback" },
6395 { UAC3_BADD_FU_ID5, "Mic Capture" },
6396 { 0 } /* terminator */
6397 };
6398
6399 -static struct usbmix_ctl_map uac3_badd_usbmix_ctl_maps[] = {
6400 +static const struct usbmix_ctl_map uac3_badd_usbmix_ctl_maps[] = {
6401 {
6402 .id = UAC3_FUNCTION_SUBCLASS_GENERIC_IO,
6403 .map = uac3_badd_generic_io_map,
6404 @@ -619,5 +626,10 @@ static struct usbmix_ctl_map uac3_badd_usbmix_ctl_maps[] = {
6405 .id = UAC3_FUNCTION_SUBCLASS_SPEAKERPHONE,
6406 .map = uac3_badd_speakerphone_map,
6407 },
6408 + {
6409 + /* Sennheiser Communications Headset [PC 8] */
6410 + .id = USB_ID(0x1395, 0x0025),
6411 + .map = sennheiser_pc8_map,
6412 + },
6413 { 0 } /* terminator */
6414 };
6415 diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
6416 index 49f0dc0e3e4d6..2040fecea17b3 100644
6417 --- a/sound/usb/mixer_quirks.c
6418 +++ b/sound/usb/mixer_quirks.c
6419 @@ -119,7 +119,7 @@ static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
6420 * Create a set of standard UAC controls from a table
6421 */
6422 static int snd_create_std_mono_table(struct usb_mixer_interface *mixer,
6423 - struct std_mono_table *t)
6424 + const struct std_mono_table *t)
6425 {
6426 int err;
6427
6428 @@ -1388,7 +1388,7 @@ static int snd_c400_create_mixer(struct usb_mixer_interface *mixer)
6429 * are valid they presents mono controls as L and R channels of
6430 * stereo. So we provide a good mixer here.
6431 */
6432 -static struct std_mono_table ebox44_table[] = {
6433 +static const struct std_mono_table ebox44_table[] = {
6434 {
6435 .unitid = 4,
6436 .control = 1,
6437 @@ -1697,7 +1697,7 @@ static struct snd_kcontrol_new snd_microii_mixer_spdif[] = {
6438 static int snd_microii_controls_create(struct usb_mixer_interface *mixer)
6439 {
6440 int err, i;
6441 - static usb_mixer_elem_resume_func_t resume_funcs[] = {
6442 + const static usb_mixer_elem_resume_func_t resume_funcs[] = {
6443 snd_microii_spdif_default_update,
6444 NULL,
6445 snd_microii_spdif_switch_update
6446 diff --git a/sound/usb/mixer_scarlett.c b/sound/usb/mixer_scarlett.c
6447 index 83715fd8dfd64..6217424e973f5 100644
6448 --- a/sound/usb/mixer_scarlett.c
6449 +++ b/sound/usb/mixer_scarlett.c
6450 @@ -623,7 +623,7 @@ static int add_output_ctls(struct usb_mixer_interface *mixer,
6451 /********************** device-specific config *************************/
6452
6453 /* untested... */
6454 -static struct scarlett_device_info s6i6_info = {
6455 +static const struct scarlett_device_info s6i6_info = {
6456 .matrix_in = 18,
6457 .matrix_out = 8,
6458 .input_len = 6,
6459 @@ -665,7 +665,7 @@ static struct scarlett_device_info s6i6_info = {
6460 };
6461
6462 /* untested... */
6463 -static struct scarlett_device_info s8i6_info = {
6464 +static const struct scarlett_device_info s8i6_info = {
6465 .matrix_in = 18,
6466 .matrix_out = 6,
6467 .input_len = 8,
6468 @@ -704,7 +704,7 @@ static struct scarlett_device_info s8i6_info = {
6469 }
6470 };
6471
6472 -static struct scarlett_device_info s18i6_info = {
6473 +static const struct scarlett_device_info s18i6_info = {
6474 .matrix_in = 18,
6475 .matrix_out = 6,
6476 .input_len = 18,
6477 @@ -741,7 +741,7 @@ static struct scarlett_device_info s18i6_info = {
6478 }
6479 };
6480
6481 -static struct scarlett_device_info s18i8_info = {
6482 +static const struct scarlett_device_info s18i8_info = {
6483 .matrix_in = 18,
6484 .matrix_out = 8,
6485 .input_len = 18,
6486 @@ -783,7 +783,7 @@ static struct scarlett_device_info s18i8_info = {
6487 }
6488 };
6489
6490 -static struct scarlett_device_info s18i20_info = {
6491 +static const struct scarlett_device_info s18i20_info = {
6492 .matrix_in = 18,
6493 .matrix_out = 8,
6494 .input_len = 18,
6495 @@ -833,7 +833,7 @@ static struct scarlett_device_info s18i20_info = {
6496
6497
6498 static int scarlett_controls_create_generic(struct usb_mixer_interface *mixer,
6499 - struct scarlett_device_info *info)
6500 + const struct scarlett_device_info *info)
6501 {
6502 int i, err;
6503 char mx[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
6504 @@ -896,7 +896,7 @@ int snd_scarlett_controls_create(struct usb_mixer_interface *mixer)
6505 {
6506 int err, i, o;
6507 char mx[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
6508 - struct scarlett_device_info *info;
6509 + const struct scarlett_device_info *info;
6510 struct usb_mixer_elem_info *elem;
6511 static char sample_rate_buffer[4] = { '\x80', '\xbb', '\x00', '\x00' };
6512
6513 diff --git a/sound/usb/proc.c b/sound/usb/proc.c
6514 index 49e3f176aaf5a..ffbf4bd9208c4 100644
6515 --- a/sound/usb/proc.c
6516 +++ b/sound/usb/proc.c
6517 @@ -60,7 +60,7 @@ void snd_usb_audio_create_proc(struct snd_usb_audio *chip)
6518 static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct snd_info_buffer *buffer)
6519 {
6520 struct audioformat *fp;
6521 - static char *sync_types[4] = {
6522 + static const char * const sync_types[4] = {
6523 "NONE", "ASYNC", "ADAPTIVE", "SYNC"
6524 };
6525
6526 diff --git a/sound/usb/stream.c b/sound/usb/stream.c
6527 index c5cbba9fdf0da..eff1ac1dc9ba3 100644
6528 --- a/sound/usb/stream.c
6529 +++ b/sound/usb/stream.c
6530 @@ -240,7 +240,7 @@ static int add_chmap(struct snd_pcm *pcm, int stream,
6531 static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits,
6532 int protocol)
6533 {
6534 - static unsigned int uac1_maps[] = {
6535 + static const unsigned int uac1_maps[] = {
6536 SNDRV_CHMAP_FL, /* left front */
6537 SNDRV_CHMAP_FR, /* right front */
6538 SNDRV_CHMAP_FC, /* center front */
6539 @@ -255,7 +255,7 @@ static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits,
6540 SNDRV_CHMAP_TC, /* top */
6541 0 /* terminator */
6542 };
6543 - static unsigned int uac2_maps[] = {
6544 + static const unsigned int uac2_maps[] = {
6545 SNDRV_CHMAP_FL, /* front left */
6546 SNDRV_CHMAP_FR, /* front right */
6547 SNDRV_CHMAP_FC, /* front center */
6548 diff --git a/sound/usb/validate.c b/sound/usb/validate.c
6549 index 5a3c4f7882b00..89a48d7317199 100644
6550 --- a/sound/usb/validate.c
6551 +++ b/sound/usb/validate.c
6552 @@ -233,7 +233,7 @@ static bool validate_midi_out_jack(const void *p,
6553 #define FIXED(p, t, s) { .protocol = (p), .type = (t), .size = sizeof(s) }
6554 #define FUNC(p, t, f) { .protocol = (p), .type = (t), .func = (f) }
6555
6556 -static struct usb_desc_validator audio_validators[] = {
6557 +static const struct usb_desc_validator audio_validators[] = {
6558 /* UAC1 */
6559 FUNC(UAC_VERSION_1, UAC_HEADER, validate_uac1_header),
6560 FIXED(UAC_VERSION_1, UAC_INPUT_TERMINAL,
6561 @@ -288,7 +288,7 @@ static struct usb_desc_validator audio_validators[] = {
6562 { } /* terminator */
6563 };
6564
6565 -static struct usb_desc_validator midi_validators[] = {
6566 +static const struct usb_desc_validator midi_validators[] = {
6567 FIXED(UAC_VERSION_ALL, USB_MS_HEADER,
6568 struct usb_ms_header_descriptor),
6569 FIXED(UAC_VERSION_ALL, USB_MS_MIDI_IN_JACK,