Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0108-5.4.9-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3489 - (show annotations) (download)
Mon May 11 14:36:03 2020 UTC (4 years ago) by niro
File size: 252729 byte(s)
-linux-5.4.9
1 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
2 index f5a551e4332d..5594c8bf1dcd 100644
3 --- a/Documentation/admin-guide/kernel-parameters.txt
4 +++ b/Documentation/admin-guide/kernel-parameters.txt
5 @@ -113,7 +113,7 @@
6 the GPE dispatcher.
7 This facility can be used to prevent such uncontrolled
8 GPE floodings.
9 - Format: <int>
10 + Format: <byte>
11
12 acpi_no_auto_serialize [HW,ACPI]
13 Disable auto-serialization of AML methods
14 diff --git a/Documentation/devicetree/bindings/clock/renesas,rcar-usb2-clock-sel.txt b/Documentation/devicetree/bindings/clock/renesas,rcar-usb2-clock-sel.txt
15 index e96e085271c1..83f6c6a7c41c 100644
16 --- a/Documentation/devicetree/bindings/clock/renesas,rcar-usb2-clock-sel.txt
17 +++ b/Documentation/devicetree/bindings/clock/renesas,rcar-usb2-clock-sel.txt
18 @@ -46,7 +46,7 @@ Required properties:
19 Example (R-Car H3):
20
21 usb2_clksel: clock-controller@e6590630 {
22 - compatible = "renesas,r8a77950-rcar-usb2-clock-sel",
23 + compatible = "renesas,r8a7795-rcar-usb2-clock-sel",
24 "renesas,rcar-gen3-usb2-clock-sel";
25 reg = <0 0xe6590630 0 0x02>;
26 clocks = <&cpg CPG_MOD 703>, <&usb_extal>, <&usb_xtal>;
27 diff --git a/Makefile b/Makefile
28 index 1adee1b06f3d..3ba15c3528c8 100644
29 --- a/Makefile
30 +++ b/Makefile
31 @@ -1,7 +1,7 @@
32 # SPDX-License-Identifier: GPL-2.0
33 VERSION = 5
34 PATCHLEVEL = 4
35 -SUBLEVEL = 8
36 +SUBLEVEL = 9
37 EXTRAVERSION =
38 NAME = Kleptomaniac Octopus
39
40 diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
41 index 6039adda12ee..b0b12e389835 100644
42 --- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
43 +++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
44 @@ -296,7 +296,7 @@
45 };
46
47 &usb0_phy {
48 - status = "okay";
49 + status = "disabled";
50 phy-supply = <&usb_otg_pwr>;
51 };
52
53 @@ -306,7 +306,7 @@
54 };
55
56 &usb0 {
57 - status = "okay";
58 + status = "disabled";
59 };
60
61 &usb1 {
62 diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
63 index 2a5cd303123d..8d6f316a5c7b 100644
64 --- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
65 +++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts
66 @@ -192,6 +192,9 @@
67 bluetooth {
68 compatible = "brcm,bcm43438-bt";
69 shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
70 + max-speed = <2000000>;
71 + clocks = <&wifi32k>;
72 + clock-names = "lpo";
73 };
74 };
75
76 diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
77 index f25ddd18a607..4d67eb715b91 100644
78 --- a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
79 +++ b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts
80 @@ -409,6 +409,9 @@
81 bluetooth {
82 compatible = "brcm,bcm43438-bt";
83 shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
84 + max-speed = <2000000>;
85 + clocks = <&wifi32k>;
86 + clock-names = "lpo";
87 };
88 };
89
90 diff --git a/arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi b/arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi
91 index 9682d4dd7496..1bae90705746 100644
92 --- a/arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi
93 +++ b/arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi
94 @@ -23,6 +23,43 @@
95 };
96 };
97
98 +/*
99 + * The laptop FW does not appear to support the retention state as it is
100 + * not advertised as enabled in ACPI, and enabling it in DT can cause boot
101 + * hangs.
102 + */
103 +&CPU0 {
104 + cpu-idle-states = <&LITTLE_CPU_SLEEP_1>;
105 +};
106 +
107 +&CPU1 {
108 + cpu-idle-states = <&LITTLE_CPU_SLEEP_1>;
109 +};
110 +
111 +&CPU2 {
112 + cpu-idle-states = <&LITTLE_CPU_SLEEP_1>;
113 +};
114 +
115 +&CPU3 {
116 + cpu-idle-states = <&LITTLE_CPU_SLEEP_1>;
117 +};
118 +
119 +&CPU4 {
120 + cpu-idle-states = <&BIG_CPU_SLEEP_1>;
121 +};
122 +
123 +&CPU5 {
124 + cpu-idle-states = <&BIG_CPU_SLEEP_1>;
125 +};
126 +
127 +&CPU6 {
128 + cpu-idle-states = <&BIG_CPU_SLEEP_1>;
129 +};
130 +
131 +&CPU7 {
132 + cpu-idle-states = <&BIG_CPU_SLEEP_1>;
133 +};
134 +
135 &qusb2phy {
136 status = "okay";
137
138 diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h
139 index 8dc6c5cdabe6..baf52baaa2a5 100644
140 --- a/arch/arm64/include/asm/pgtable-prot.h
141 +++ b/arch/arm64/include/asm/pgtable-prot.h
142 @@ -85,13 +85,12 @@
143 #define PAGE_SHARED_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_WRITE)
144 #define PAGE_READONLY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN)
145 #define PAGE_READONLY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN)
146 -#define PAGE_EXECONLY __pgprot(_PAGE_DEFAULT | PTE_RDONLY | PTE_NG | PTE_PXN)
147
148 #define __P000 PAGE_NONE
149 #define __P001 PAGE_READONLY
150 #define __P010 PAGE_READONLY
151 #define __P011 PAGE_READONLY
152 -#define __P100 PAGE_EXECONLY
153 +#define __P100 PAGE_READONLY_EXEC
154 #define __P101 PAGE_READONLY_EXEC
155 #define __P110 PAGE_READONLY_EXEC
156 #define __P111 PAGE_READONLY_EXEC
157 @@ -100,7 +99,7 @@
158 #define __S001 PAGE_READONLY
159 #define __S010 PAGE_SHARED
160 #define __S011 PAGE_SHARED
161 -#define __S100 PAGE_EXECONLY
162 +#define __S100 PAGE_READONLY_EXEC
163 #define __S101 PAGE_READONLY_EXEC
164 #define __S110 PAGE_SHARED_EXEC
165 #define __S111 PAGE_SHARED_EXEC
166 diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
167 index 565aa45ef134..13ebe2bad79f 100644
168 --- a/arch/arm64/include/asm/pgtable.h
169 +++ b/arch/arm64/include/asm/pgtable.h
170 @@ -96,12 +96,8 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
171 #define pte_dirty(pte) (pte_sw_dirty(pte) || pte_hw_dirty(pte))
172
173 #define pte_valid(pte) (!!(pte_val(pte) & PTE_VALID))
174 -/*
175 - * Execute-only user mappings do not have the PTE_USER bit set. All valid
176 - * kernel mappings have the PTE_UXN bit set.
177 - */
178 #define pte_valid_not_user(pte) \
179 - ((pte_val(pte) & (PTE_VALID | PTE_USER | PTE_UXN)) == (PTE_VALID | PTE_UXN))
180 + ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID)
181 #define pte_valid_young(pte) \
182 ((pte_val(pte) & (PTE_VALID | PTE_AF)) == (PTE_VALID | PTE_AF))
183 #define pte_valid_user(pte) \
184 @@ -117,8 +113,8 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
185
186 /*
187 * p??_access_permitted() is true for valid user mappings (subject to the
188 - * write permission check) other than user execute-only which do not have the
189 - * PTE_USER bit set. PROT_NONE mappings do not have the PTE_VALID bit set.
190 + * write permission check). PROT_NONE mappings do not have the PTE_VALID bit
191 + * set.
192 */
193 #define pte_access_permitted(pte, write) \
194 (pte_valid_user(pte) && (!(write) || pte_write(pte)))
195 diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
196 index 9fc6db0bcbad..d26e6cd28953 100644
197 --- a/arch/arm64/mm/fault.c
198 +++ b/arch/arm64/mm/fault.c
199 @@ -454,7 +454,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
200 const struct fault_info *inf;
201 struct mm_struct *mm = current->mm;
202 vm_fault_t fault, major = 0;
203 - unsigned long vm_flags = VM_READ | VM_WRITE;
204 + unsigned long vm_flags = VM_READ | VM_WRITE | VM_EXEC;
205 unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
206
207 if (kprobe_page_fault(regs, esr))
208 diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
209 index 60c929f3683b..d10247fab0fd 100644
210 --- a/arch/arm64/mm/mmu.c
211 +++ b/arch/arm64/mm/mmu.c
212 @@ -1069,7 +1069,6 @@ void arch_remove_memory(int nid, u64 start, u64 size,
213 {
214 unsigned long start_pfn = start >> PAGE_SHIFT;
215 unsigned long nr_pages = size >> PAGE_SHIFT;
216 - struct zone *zone;
217
218 /*
219 * FIXME: Cleanup page tables (also in arch_add_memory() in case
220 @@ -1078,7 +1077,6 @@ void arch_remove_memory(int nid, u64 start, u64 size,
221 * unplug. ARCH_ENABLE_MEMORY_HOTREMOVE must not be
222 * unlocked yet.
223 */
224 - zone = page_zone(pfn_to_page(start_pfn));
225 - __remove_pages(zone, start_pfn, nr_pages, altmap);
226 + __remove_pages(start_pfn, nr_pages, altmap);
227 }
228 #endif
229 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
230 index bf9df2625bc8..a6dd80a2c939 100644
231 --- a/arch/ia64/mm/init.c
232 +++ b/arch/ia64/mm/init.c
233 @@ -689,9 +689,7 @@ void arch_remove_memory(int nid, u64 start, u64 size,
234 {
235 unsigned long start_pfn = start >> PAGE_SHIFT;
236 unsigned long nr_pages = size >> PAGE_SHIFT;
237 - struct zone *zone;
238
239 - zone = page_zone(pfn_to_page(start_pfn));
240 - __remove_pages(zone, start_pfn, nr_pages, altmap);
241 + __remove_pages(start_pfn, nr_pages, altmap);
242 }
243 #endif
244 diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
245 index a0bd9bdb5f83..e5c2d47608fe 100644
246 --- a/arch/mips/Kconfig
247 +++ b/arch/mips/Kconfig
248 @@ -46,7 +46,7 @@ config MIPS
249 select HAVE_ARCH_TRACEHOOK
250 select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES
251 select HAVE_ASM_MODVERSIONS
252 - select HAVE_EBPF_JIT if (!CPU_MICROMIPS)
253 + select HAVE_EBPF_JIT if 64BIT && !CPU_MICROMIPS && TARGET_ISA_REV >= 2
254 select HAVE_CONTEXT_TRACKING
255 select HAVE_COPY_THREAD_TLS
256 select HAVE_C_RECORDMCOUNT
257 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
258 index 4993db40482c..ee26f9a4575d 100644
259 --- a/arch/mips/include/asm/thread_info.h
260 +++ b/arch/mips/include/asm/thread_info.h
261 @@ -49,8 +49,26 @@ struct thread_info {
262 .addr_limit = KERNEL_DS, \
263 }
264
265 -/* How to get the thread information struct from C. */
266 +/*
267 + * A pointer to the struct thread_info for the currently executing thread is
268 + * held in register $28/$gp.
269 + *
270 + * We declare __current_thread_info as a global register variable rather than a
271 + * local register variable within current_thread_info() because clang doesn't
272 + * support explicit local register variables.
273 + *
274 + * When building the VDSO we take care not to declare the global register
275 + * variable because this causes GCC to not preserve the value of $28/$gp in
276 + * functions that change its value (which is common in the PIC VDSO when
277 + * accessing the GOT). Since the VDSO shouldn't be accessing
278 + * __current_thread_info anyway we declare it extern in order to cause a link
279 + * failure if it's referenced.
280 + */
281 +#ifdef __VDSO__
282 +extern struct thread_info *__current_thread_info;
283 +#else
284 register struct thread_info *__current_thread_info __asm__("$28");
285 +#endif
286
287 static inline struct thread_info *current_thread_info(void)
288 {
289 diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c
290 index 46b76751f3a5..a2405d5f7d1e 100644
291 --- a/arch/mips/net/ebpf_jit.c
292 +++ b/arch/mips/net/ebpf_jit.c
293 @@ -1803,7 +1803,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
294 unsigned int image_size;
295 u8 *image_ptr;
296
297 - if (!prog->jit_requested || MIPS_ISA_REV < 2)
298 + if (!prog->jit_requested)
299 return prog;
300
301 tmp = bpf_jit_blind_constants(prog);
302 diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
303 index be941d382c8d..460afa415434 100644
304 --- a/arch/powerpc/mm/mem.c
305 +++ b/arch/powerpc/mm/mem.c
306 @@ -104,6 +104,27 @@ int __weak remove_section_mapping(unsigned long start, unsigned long end)
307 return -ENODEV;
308 }
309
310 +#define FLUSH_CHUNK_SIZE SZ_1G
311 +/**
312 + * flush_dcache_range_chunked(): Write any modified data cache blocks out to
313 + * memory and invalidate them, in chunks of up to FLUSH_CHUNK_SIZE
314 + * Does not invalidate the corresponding instruction cache blocks.
315 + *
316 + * @start: the start address
317 + * @stop: the stop address (exclusive)
318 + * @chunk: the max size of the chunks
319 + */
320 +static void flush_dcache_range_chunked(unsigned long start, unsigned long stop,
321 + unsigned long chunk)
322 +{
323 + unsigned long i;
324 +
325 + for (i = start; i < stop; i += chunk) {
326 + flush_dcache_range(i, min(stop, start + chunk));
327 + cond_resched();
328 + }
329 +}
330 +
331 int __ref arch_add_memory(int nid, u64 start, u64 size,
332 struct mhp_restrictions *restrictions)
333 {
334 @@ -120,7 +141,8 @@ int __ref arch_add_memory(int nid, u64 start, u64 size,
335 start, start + size, rc);
336 return -EFAULT;
337 }
338 - flush_dcache_range(start, start + size);
339 +
340 + flush_dcache_range_chunked(start, start + size, FLUSH_CHUNK_SIZE);
341
342 return __add_pages(nid, start_pfn, nr_pages, restrictions);
343 }
344 @@ -130,14 +152,14 @@ void __ref arch_remove_memory(int nid, u64 start, u64 size,
345 {
346 unsigned long start_pfn = start >> PAGE_SHIFT;
347 unsigned long nr_pages = size >> PAGE_SHIFT;
348 - struct page *page = pfn_to_page(start_pfn) + vmem_altmap_offset(altmap);
349 int ret;
350
351 - __remove_pages(page_zone(page), start_pfn, nr_pages, altmap);
352 + __remove_pages(start_pfn, nr_pages, altmap);
353
354 /* Remove htab bolted mappings for this section of memory */
355 start = (unsigned long)__va(start);
356 - flush_dcache_range(start, start + size);
357 + flush_dcache_range_chunked(start, start + size, FLUSH_CHUNK_SIZE);
358 +
359 ret = remove_section_mapping(start, start + size);
360 WARN_ON_ONCE(ret);
361
362 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
363 index 42bbcd47cc85..dffe1a45b6ed 100644
364 --- a/arch/powerpc/mm/slice.c
365 +++ b/arch/powerpc/mm/slice.c
366 @@ -50,7 +50,7 @@ static void slice_print_mask(const char *label, const struct slice_mask *mask) {
367
368 #endif
369
370 -static inline bool slice_addr_is_low(unsigned long addr)
371 +static inline notrace bool slice_addr_is_low(unsigned long addr)
372 {
373 u64 tmp = (u64)addr;
374
375 @@ -659,7 +659,7 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp,
376 mm_ctx_user_psize(&current->mm->context), 1);
377 }
378
379 -unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr)
380 +unsigned int notrace get_slice_psize(struct mm_struct *mm, unsigned long addr)
381 {
382 unsigned char *psizes;
383 int index, mask_index;
384 diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
385 index b94d8db5ddcc..c40fdcdeb950 100644
386 --- a/arch/riscv/kernel/ftrace.c
387 +++ b/arch/riscv/kernel/ftrace.c
388 @@ -142,7 +142,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
389 */
390 old = *parent;
391
392 - if (function_graph_enter(old, self_addr, frame_pointer, parent))
393 + if (!function_graph_enter(old, self_addr, frame_pointer, parent))
394 *parent = return_hooker;
395 }
396
397 diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
398 index 7511b71d2931..fdb8083e7870 100644
399 --- a/arch/s390/kernel/perf_cpum_sf.c
400 +++ b/arch/s390/kernel/perf_cpum_sf.c
401 @@ -1313,18 +1313,28 @@ static void hw_perf_event_update(struct perf_event *event, int flush_all)
402 */
403 if (flush_all && done)
404 break;
405 -
406 - /* If an event overflow happened, discard samples by
407 - * processing any remaining sample-data-blocks.
408 - */
409 - if (event_overflow)
410 - flush_all = 1;
411 }
412
413 /* Account sample overflows in the event hardware structure */
414 if (sampl_overflow)
415 OVERFLOW_REG(hwc) = DIV_ROUND_UP(OVERFLOW_REG(hwc) +
416 sampl_overflow, 1 + num_sdb);
417 +
418 + /* Perf_event_overflow() and perf_event_account_interrupt() limit
419 + * the interrupt rate to an upper limit. Roughly 1000 samples per
420 + * task tick.
421 + * Hitting this limit results in a large number
422 + * of throttled REF_REPORT_THROTTLE entries and the samples
423 + * are dropped.
424 + * Slightly increase the interval to avoid hitting this limit.
425 + */
426 + if (event_overflow) {
427 + SAMPL_RATE(hwc) += DIV_ROUND_UP(SAMPL_RATE(hwc), 10);
428 + debug_sprintf_event(sfdbg, 1, "%s: rate adjustment %ld\n",
429 + __func__,
430 + DIV_ROUND_UP(SAMPL_RATE(hwc), 10));
431 + }
432 +
433 if (sampl_overflow || event_overflow)
434 debug_sprintf_event(sfdbg, 4, "hw_perf_event_update: "
435 "overflow stats: sample=%llu event=%llu\n",
436 diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
437 index d95c85780e07..06dddd7c4290 100644
438 --- a/arch/s390/kernel/smp.c
439 +++ b/arch/s390/kernel/smp.c
440 @@ -727,39 +727,67 @@ static void __ref smp_get_core_info(struct sclp_core_info *info, int early)
441
442 static int smp_add_present_cpu(int cpu);
443
444 -static int __smp_rescan_cpus(struct sclp_core_info *info, int sysfs_add)
445 +static int smp_add_core(struct sclp_core_entry *core, cpumask_t *avail,
446 + bool configured, bool early)
447 {
448 struct pcpu *pcpu;
449 - cpumask_t avail;
450 - int cpu, nr, i, j;
451 + int cpu, nr, i;
452 u16 address;
453
454 nr = 0;
455 - cpumask_xor(&avail, cpu_possible_mask, cpu_present_mask);
456 - cpu = cpumask_first(&avail);
457 - for (i = 0; (i < info->combined) && (cpu < nr_cpu_ids); i++) {
458 - if (sclp.has_core_type && info->core[i].type != boot_core_type)
459 + if (sclp.has_core_type && core->type != boot_core_type)
460 + return nr;
461 + cpu = cpumask_first(avail);
462 + address = core->core_id << smp_cpu_mt_shift;
463 + for (i = 0; (i <= smp_cpu_mtid) && (cpu < nr_cpu_ids); i++) {
464 + if (pcpu_find_address(cpu_present_mask, address + i))
465 continue;
466 - address = info->core[i].core_id << smp_cpu_mt_shift;
467 - for (j = 0; j <= smp_cpu_mtid; j++) {
468 - if (pcpu_find_address(cpu_present_mask, address + j))
469 - continue;
470 - pcpu = pcpu_devices + cpu;
471 - pcpu->address = address + j;
472 - pcpu->state =
473 - (cpu >= info->configured*(smp_cpu_mtid + 1)) ?
474 - CPU_STATE_STANDBY : CPU_STATE_CONFIGURED;
475 - smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
476 - set_cpu_present(cpu, true);
477 - if (sysfs_add && smp_add_present_cpu(cpu) != 0)
478 - set_cpu_present(cpu, false);
479 - else
480 - nr++;
481 - cpu = cpumask_next(cpu, &avail);
482 - if (cpu >= nr_cpu_ids)
483 + pcpu = pcpu_devices + cpu;
484 + pcpu->address = address + i;
485 + if (configured)
486 + pcpu->state = CPU_STATE_CONFIGURED;
487 + else
488 + pcpu->state = CPU_STATE_STANDBY;
489 + smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
490 + set_cpu_present(cpu, true);
491 + if (!early && smp_add_present_cpu(cpu) != 0)
492 + set_cpu_present(cpu, false);
493 + else
494 + nr++;
495 + cpumask_clear_cpu(cpu, avail);
496 + cpu = cpumask_next(cpu, avail);
497 + }
498 + return nr;
499 +}
500 +
501 +static int __smp_rescan_cpus(struct sclp_core_info *info, bool early)
502 +{
503 + struct sclp_core_entry *core;
504 + cpumask_t avail;
505 + bool configured;
506 + u16 core_id;
507 + int nr, i;
508 +
509 + nr = 0;
510 + cpumask_xor(&avail, cpu_possible_mask, cpu_present_mask);
511 + /*
512 + * Add IPL core first (which got logical CPU number 0) to make sure
513 + * that all SMT threads get subsequent logical CPU numbers.
514 + */
515 + if (early) {
516 + core_id = pcpu_devices[0].address >> smp_cpu_mt_shift;
517 + for (i = 0; i < info->configured; i++) {
518 + core = &info->core[i];
519 + if (core->core_id == core_id) {
520 + nr += smp_add_core(core, &avail, true, early);
521 break;
522 + }
523 }
524 }
525 + for (i = 0; i < info->combined; i++) {
526 + configured = i < info->configured;
527 + nr += smp_add_core(&info->core[i], &avail, configured, early);
528 + }
529 return nr;
530 }
531
532 @@ -808,7 +836,7 @@ void __init smp_detect_cpus(void)
533
534 /* Add CPUs present at boot */
535 get_online_cpus();
536 - __smp_rescan_cpus(info, 0);
537 + __smp_rescan_cpus(info, true);
538 put_online_cpus();
539 memblock_free_early((unsigned long)info, sizeof(*info));
540 }
541 @@ -1153,7 +1181,7 @@ int __ref smp_rescan_cpus(void)
542 smp_get_core_info(info, 0);
543 get_online_cpus();
544 mutex_lock(&smp_cpu_state_mutex);
545 - nr = __smp_rescan_cpus(info, 1);
546 + nr = __smp_rescan_cpus(info, false);
547 mutex_unlock(&smp_cpu_state_mutex);
548 put_online_cpus();
549 kfree(info);
550 diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
551 index a124f19f7b3c..c1d96e588152 100644
552 --- a/arch/s390/mm/init.c
553 +++ b/arch/s390/mm/init.c
554 @@ -291,10 +291,8 @@ void arch_remove_memory(int nid, u64 start, u64 size,
555 {
556 unsigned long start_pfn = start >> PAGE_SHIFT;
557 unsigned long nr_pages = size >> PAGE_SHIFT;
558 - struct zone *zone;
559
560 - zone = page_zone(pfn_to_page(start_pfn));
561 - __remove_pages(zone, start_pfn, nr_pages, altmap);
562 + __remove_pages(start_pfn, nr_pages, altmap);
563 vmem_remove_mapping(start, size);
564 }
565 #endif /* CONFIG_MEMORY_HOTPLUG */
566 diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
567 index dfdbaa50946e..d1b1ff2be17a 100644
568 --- a/arch/sh/mm/init.c
569 +++ b/arch/sh/mm/init.c
570 @@ -434,9 +434,7 @@ void arch_remove_memory(int nid, u64 start, u64 size,
571 {
572 unsigned long start_pfn = PFN_DOWN(start);
573 unsigned long nr_pages = size >> PAGE_SHIFT;
574 - struct zone *zone;
575
576 - zone = page_zone(pfn_to_page(start_pfn));
577 - __remove_pages(zone, start_pfn, nr_pages, altmap);
578 + __remove_pages(start_pfn, nr_pages, altmap);
579 }
580 #endif /* CONFIG_MEMORY_HOTPLUG */
581 diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
582 index 5ee3fed881d3..741540d849f3 100644
583 --- a/arch/x86/events/intel/bts.c
584 +++ b/arch/x86/events/intel/bts.c
585 @@ -63,9 +63,17 @@ struct bts_buffer {
586
587 static struct pmu bts_pmu;
588
589 +static int buf_nr_pages(struct page *page)
590 +{
591 + if (!PagePrivate(page))
592 + return 1;
593 +
594 + return 1 << page_private(page);
595 +}
596 +
597 static size_t buf_size(struct page *page)
598 {
599 - return 1 << (PAGE_SHIFT + page_private(page));
600 + return buf_nr_pages(page) * PAGE_SIZE;
601 }
602
603 static void *
604 @@ -83,9 +91,7 @@ bts_buffer_setup_aux(struct perf_event *event, void **pages,
605 /* count all the high order buffers */
606 for (pg = 0, nbuf = 0; pg < nr_pages;) {
607 page = virt_to_page(pages[pg]);
608 - if (WARN_ON_ONCE(!PagePrivate(page) && nr_pages > 1))
609 - return NULL;
610 - pg += 1 << page_private(page);
611 + pg += buf_nr_pages(page);
612 nbuf++;
613 }
614
615 @@ -109,7 +115,7 @@ bts_buffer_setup_aux(struct perf_event *event, void **pages,
616 unsigned int __nr_pages;
617
618 page = virt_to_page(pages[pg]);
619 - __nr_pages = PagePrivate(page) ? 1 << page_private(page) : 1;
620 + __nr_pages = buf_nr_pages(page);
621 buf->buf[nbuf].page = page;
622 buf->buf[nbuf].offset = offset;
623 buf->buf[nbuf].displacement = (pad ? BTS_RECORD_SIZE - pad : 0);
624 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
625 index 930edeb41ec3..0a74407ef92e 100644
626 --- a/arch/x86/mm/init_32.c
627 +++ b/arch/x86/mm/init_32.c
628 @@ -865,10 +865,8 @@ void arch_remove_memory(int nid, u64 start, u64 size,
629 {
630 unsigned long start_pfn = start >> PAGE_SHIFT;
631 unsigned long nr_pages = size >> PAGE_SHIFT;
632 - struct zone *zone;
633
634 - zone = page_zone(pfn_to_page(start_pfn));
635 - __remove_pages(zone, start_pfn, nr_pages, altmap);
636 + __remove_pages(start_pfn, nr_pages, altmap);
637 }
638 #endif
639
640 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
641 index a6b5c653727b..b8541d77452c 100644
642 --- a/arch/x86/mm/init_64.c
643 +++ b/arch/x86/mm/init_64.c
644 @@ -1212,10 +1212,8 @@ void __ref arch_remove_memory(int nid, u64 start, u64 size,
645 {
646 unsigned long start_pfn = start >> PAGE_SHIFT;
647 unsigned long nr_pages = size >> PAGE_SHIFT;
648 - struct page *page = pfn_to_page(start_pfn) + vmem_altmap_offset(altmap);
649 - struct zone *zone = page_zone(page);
650
651 - __remove_pages(zone, start_pfn, nr_pages, altmap);
652 + __remove_pages(start_pfn, nr_pages, altmap);
653 kernel_physical_mapping_remove(start, start + size);
654 }
655 #endif /* CONFIG_MEMORY_HOTPLUG */
656 diff --git a/block/bio.c b/block/bio.c
657 index 43df756b68c4..c822ceb7c4de 100644
658 --- a/block/bio.c
659 +++ b/block/bio.c
660 @@ -535,6 +535,45 @@ void zero_fill_bio_iter(struct bio *bio, struct bvec_iter start)
661 }
662 EXPORT_SYMBOL(zero_fill_bio_iter);
663
664 +void bio_truncate(struct bio *bio, unsigned new_size)
665 +{
666 + struct bio_vec bv;
667 + struct bvec_iter iter;
668 + unsigned int done = 0;
669 + bool truncated = false;
670 +
671 + if (new_size >= bio->bi_iter.bi_size)
672 + return;
673 +
674 + if (bio_data_dir(bio) != READ)
675 + goto exit;
676 +
677 + bio_for_each_segment(bv, bio, iter) {
678 + if (done + bv.bv_len > new_size) {
679 + unsigned offset;
680 +
681 + if (!truncated)
682 + offset = new_size - done;
683 + else
684 + offset = 0;
685 + zero_user(bv.bv_page, offset, bv.bv_len - offset);
686 + truncated = true;
687 + }
688 + done += bv.bv_len;
689 + }
690 +
691 + exit:
692 + /*
693 + * Don't touch bvec table here and make it really immutable, since
694 + * fs bio user has to retrieve all pages via bio_for_each_segment_all
695 + * in its .end_bio() callback.
696 + *
697 + * It is enough to truncate bio by updating .bi_size since we can make
698 + * correct bvec with the updated .bi_size for drivers.
699 + */
700 + bio->bi_iter.bi_size = new_size;
701 +}
702 +
703 /**
704 * bio_put - release a reference to a bio
705 * @bio: bio to release reference to
706 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
707 index 6ca015f92766..7f053468b50d 100644
708 --- a/block/compat_ioctl.c
709 +++ b/block/compat_ioctl.c
710 @@ -6,6 +6,7 @@
711 #include <linux/compat.h>
712 #include <linux/elevator.h>
713 #include <linux/hdreg.h>
714 +#include <linux/pr.h>
715 #include <linux/slab.h>
716 #include <linux/syscalls.h>
717 #include <linux/types.h>
718 @@ -354,6 +355,10 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
719 * but we call blkdev_ioctl, which gets the lock for us
720 */
721 case BLKRRPART:
722 + case BLKREPORTZONE:
723 + case BLKRESETZONE:
724 + case BLKGETZONESZ:
725 + case BLKGETNRZONES:
726 return blkdev_ioctl(bdev, mode, cmd,
727 (unsigned long)compat_ptr(arg));
728 case BLKBSZSET_32:
729 @@ -401,6 +406,14 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
730 case BLKTRACETEARDOWN: /* compatible */
731 ret = blk_trace_ioctl(bdev, cmd, compat_ptr(arg));
732 return ret;
733 + case IOC_PR_REGISTER:
734 + case IOC_PR_RESERVE:
735 + case IOC_PR_RELEASE:
736 + case IOC_PR_PREEMPT:
737 + case IOC_PR_PREEMPT_ABORT:
738 + case IOC_PR_CLEAR:
739 + return blkdev_ioctl(bdev, mode, cmd,
740 + (unsigned long)compat_ptr(arg));
741 default:
742 if (disk->fops->compat_ioctl)
743 ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg);
744 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
745 index 75948a3f1a20..c60d2c6d31d6 100644
746 --- a/drivers/acpi/sysfs.c
747 +++ b/drivers/acpi/sysfs.c
748 @@ -819,14 +819,14 @@ end:
749 * interface:
750 * echo unmask > /sys/firmware/acpi/interrupts/gpe00
751 */
752 -#define ACPI_MASKABLE_GPE_MAX 0xFF
753 +#define ACPI_MASKABLE_GPE_MAX 0x100
754 static DECLARE_BITMAP(acpi_masked_gpes_map, ACPI_MASKABLE_GPE_MAX) __initdata;
755
756 static int __init acpi_gpe_set_masked_gpes(char *val)
757 {
758 u8 gpe;
759
760 - if (kstrtou8(val, 0, &gpe) || gpe > ACPI_MASKABLE_GPE_MAX)
761 + if (kstrtou8(val, 0, &gpe))
762 return -EINVAL;
763 set_bit(gpe, acpi_masked_gpes_map);
764
765 @@ -838,7 +838,7 @@ void __init acpi_gpe_apply_masked_gpes(void)
766 {
767 acpi_handle handle;
768 acpi_status status;
769 - u8 gpe;
770 + u16 gpe;
771
772 for_each_set_bit(gpe, acpi_masked_gpes_map, ACPI_MASKABLE_GPE_MAX) {
773 status = acpi_get_gpe_device(gpe, &handle);
774 diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c
775 index f41744b9b38a..66a570d0da83 100644
776 --- a/drivers/ata/ahci_brcm.c
777 +++ b/drivers/ata/ahci_brcm.c
778 @@ -76,8 +76,7 @@ enum brcm_ahci_version {
779 };
780
781 enum brcm_ahci_quirks {
782 - BRCM_AHCI_QUIRK_NO_NCQ = BIT(0),
783 - BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(1),
784 + BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(0),
785 };
786
787 struct brcm_ahci_priv {
788 @@ -213,19 +212,12 @@ static void brcm_sata_phys_disable(struct brcm_ahci_priv *priv)
789 brcm_sata_phy_disable(priv, i);
790 }
791
792 -static u32 brcm_ahci_get_portmask(struct platform_device *pdev,
793 +static u32 brcm_ahci_get_portmask(struct ahci_host_priv *hpriv,
794 struct brcm_ahci_priv *priv)
795 {
796 - void __iomem *ahci;
797 - struct resource *res;
798 u32 impl;
799
800 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ahci");
801 - ahci = devm_ioremap_resource(&pdev->dev, res);
802 - if (IS_ERR(ahci))
803 - return 0;
804 -
805 - impl = readl(ahci + HOST_PORTS_IMPL);
806 + impl = readl(hpriv->mmio + HOST_PORTS_IMPL);
807
808 if (fls(impl) > SATA_TOP_MAX_PHYS)
809 dev_warn(priv->dev, "warning: more ports than PHYs (%#x)\n",
810 @@ -233,9 +225,6 @@ static u32 brcm_ahci_get_portmask(struct platform_device *pdev,
811 else if (!impl)
812 dev_info(priv->dev, "no ports found\n");
813
814 - devm_iounmap(&pdev->dev, ahci);
815 - devm_release_mem_region(&pdev->dev, res->start, resource_size(res));
816 -
817 return impl;
818 }
819
820 @@ -285,6 +274,13 @@ static unsigned int brcm_ahci_read_id(struct ata_device *dev,
821 /* Perform the SATA PHY reset sequence */
822 brcm_sata_phy_disable(priv, ap->port_no);
823
824 + /* Reset the SATA clock */
825 + ahci_platform_disable_clks(hpriv);
826 + msleep(10);
827 +
828 + ahci_platform_enable_clks(hpriv);
829 + msleep(10);
830 +
831 /* Bring the PHY back on */
832 brcm_sata_phy_enable(priv, ap->port_no);
833
834 @@ -347,11 +343,10 @@ static int brcm_ahci_suspend(struct device *dev)
835 struct ata_host *host = dev_get_drvdata(dev);
836 struct ahci_host_priv *hpriv = host->private_data;
837 struct brcm_ahci_priv *priv = hpriv->plat_data;
838 - int ret;
839
840 - ret = ahci_platform_suspend(dev);
841 brcm_sata_phys_disable(priv);
842 - return ret;
843 +
844 + return ahci_platform_suspend(dev);
845 }
846
847 static int brcm_ahci_resume(struct device *dev)
848 @@ -359,11 +354,44 @@ static int brcm_ahci_resume(struct device *dev)
849 struct ata_host *host = dev_get_drvdata(dev);
850 struct ahci_host_priv *hpriv = host->private_data;
851 struct brcm_ahci_priv *priv = hpriv->plat_data;
852 + int ret;
853 +
854 + /* Make sure clocks are turned on before re-configuration */
855 + ret = ahci_platform_enable_clks(hpriv);
856 + if (ret)
857 + return ret;
858
859 brcm_sata_init(priv);
860 brcm_sata_phys_enable(priv);
861 brcm_sata_alpm_init(hpriv);
862 - return ahci_platform_resume(dev);
863 +
864 + /* Since we had to enable clocks earlier on, we cannot use
865 + * ahci_platform_resume() as-is since a second call to
866 + * ahci_platform_enable_resources() would bump up the resources
867 + * (regulators, clocks, PHYs) count artificially so we copy the part
868 + * after ahci_platform_enable_resources().
869 + */
870 + ret = ahci_platform_enable_phys(hpriv);
871 + if (ret)
872 + goto out_disable_phys;
873 +
874 + ret = ahci_platform_resume_host(dev);
875 + if (ret)
876 + goto out_disable_platform_phys;
877 +
878 + /* We resumed so update PM runtime state */
879 + pm_runtime_disable(dev);
880 + pm_runtime_set_active(dev);
881 + pm_runtime_enable(dev);
882 +
883 + return 0;
884 +
885 +out_disable_platform_phys:
886 + ahci_platform_disable_phys(hpriv);
887 +out_disable_phys:
888 + brcm_sata_phys_disable(priv);
889 + ahci_platform_disable_clks(hpriv);
890 + return ret;
891 }
892 #endif
893
894 @@ -410,44 +438,71 @@ static int brcm_ahci_probe(struct platform_device *pdev)
895 if (!IS_ERR_OR_NULL(priv->rcdev))
896 reset_control_deassert(priv->rcdev);
897
898 - if ((priv->version == BRCM_SATA_BCM7425) ||
899 - (priv->version == BRCM_SATA_NSP)) {
900 - priv->quirks |= BRCM_AHCI_QUIRK_NO_NCQ;
901 + hpriv = ahci_platform_get_resources(pdev, 0);
902 + if (IS_ERR(hpriv)) {
903 + ret = PTR_ERR(hpriv);
904 + goto out_reset;
905 + }
906 +
907 + hpriv->plat_data = priv;
908 + hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP | AHCI_HFLAG_NO_WRITE_TO_RO;
909 +
910 + switch (priv->version) {
911 + case BRCM_SATA_BCM7425:
912 + hpriv->flags |= AHCI_HFLAG_DELAY_ENGINE;
913 + /* fall through */
914 + case BRCM_SATA_NSP:
915 + hpriv->flags |= AHCI_HFLAG_NO_NCQ;
916 priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE;
917 + break;
918 + default:
919 + break;
920 }
921
922 + ret = ahci_platform_enable_clks(hpriv);
923 + if (ret)
924 + goto out_reset;
925 +
926 + /* Must be first so as to configure endianness including that
927 + * of the standard AHCI register space.
928 + */
929 brcm_sata_init(priv);
930
931 - priv->port_mask = brcm_ahci_get_portmask(pdev, priv);
932 - if (!priv->port_mask)
933 - return -ENODEV;
934 + /* Initializes priv->port_mask which is used below */
935 + priv->port_mask = brcm_ahci_get_portmask(hpriv, priv);
936 + if (!priv->port_mask) {
937 + ret = -ENODEV;
938 + goto out_disable_clks;
939 + }
940
941 + /* Must be done before ahci_platform_enable_phys() */
942 brcm_sata_phys_enable(priv);
943
944 - hpriv = ahci_platform_get_resources(pdev, 0);
945 - if (IS_ERR(hpriv))
946 - return PTR_ERR(hpriv);
947 - hpriv->plat_data = priv;
948 - hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP;
949 -
950 brcm_sata_alpm_init(hpriv);
951
952 - ret = ahci_platform_enable_resources(hpriv);
953 + ret = ahci_platform_enable_phys(hpriv);
954 if (ret)
955 - return ret;
956 -
957 - if (priv->quirks & BRCM_AHCI_QUIRK_NO_NCQ)
958 - hpriv->flags |= AHCI_HFLAG_NO_NCQ;
959 - hpriv->flags |= AHCI_HFLAG_NO_WRITE_TO_RO;
960 + goto out_disable_phys;
961
962 ret = ahci_platform_init_host(pdev, hpriv, &ahci_brcm_port_info,
963 &ahci_platform_sht);
964 if (ret)
965 - return ret;
966 + goto out_disable_platform_phys;
967
968 dev_info(dev, "Broadcom AHCI SATA3 registered\n");
969
970 return 0;
971 +
972 +out_disable_platform_phys:
973 + ahci_platform_disable_phys(hpriv);
974 +out_disable_phys:
975 + brcm_sata_phys_disable(priv);
976 +out_disable_clks:
977 + ahci_platform_disable_clks(hpriv);
978 +out_reset:
979 + if (!IS_ERR_OR_NULL(priv->rcdev))
980 + reset_control_assert(priv->rcdev);
981 + return ret;
982 }
983
984 static int brcm_ahci_remove(struct platform_device *pdev)
985 @@ -457,12 +512,12 @@ static int brcm_ahci_remove(struct platform_device *pdev)
986 struct brcm_ahci_priv *priv = hpriv->plat_data;
987 int ret;
988
989 + brcm_sata_phys_disable(priv);
990 +
991 ret = ata_platform_remove_one(pdev);
992 if (ret)
993 return ret;
994
995 - brcm_sata_phys_disable(priv);
996 -
997 return 0;
998 }
999
1000 diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
1001 index 8befce036af8..129556fcf6be 100644
1002 --- a/drivers/ata/libahci_platform.c
1003 +++ b/drivers/ata/libahci_platform.c
1004 @@ -43,7 +43,7 @@ EXPORT_SYMBOL_GPL(ahci_platform_ops);
1005 * RETURNS:
1006 * 0 on success otherwise a negative error code
1007 */
1008 -static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)
1009 +int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)
1010 {
1011 int rc, i;
1012
1013 @@ -74,6 +74,7 @@ disable_phys:
1014 }
1015 return rc;
1016 }
1017 +EXPORT_SYMBOL_GPL(ahci_platform_enable_phys);
1018
1019 /**
1020 * ahci_platform_disable_phys - Disable PHYs
1021 @@ -81,7 +82,7 @@ disable_phys:
1022 *
1023 * This function disables all PHYs found in hpriv->phys.
1024 */
1025 -static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)
1026 +void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)
1027 {
1028 int i;
1029
1030 @@ -90,6 +91,7 @@ static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)
1031 phy_exit(hpriv->phys[i]);
1032 }
1033 }
1034 +EXPORT_SYMBOL_GPL(ahci_platform_disable_phys);
1035
1036 /**
1037 * ahci_platform_enable_clks - Enable platform clocks
1038 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
1039 index 74c9b3032d46..84b183a6424e 100644
1040 --- a/drivers/ata/libata-core.c
1041 +++ b/drivers/ata/libata-core.c
1042 @@ -5325,6 +5325,30 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
1043 }
1044 }
1045
1046 +/**
1047 + * ata_qc_get_active - get bitmask of active qcs
1048 + * @ap: port in question
1049 + *
1050 + * LOCKING:
1051 + * spin_lock_irqsave(host lock)
1052 + *
1053 + * RETURNS:
1054 + * Bitmask of active qcs
1055 + */
1056 +u64 ata_qc_get_active(struct ata_port *ap)
1057 +{
1058 + u64 qc_active = ap->qc_active;
1059 +
1060 + /* ATA_TAG_INTERNAL is sent to hw as tag 0 */
1061 + if (qc_active & (1ULL << ATA_TAG_INTERNAL)) {
1062 + qc_active |= (1 << 0);
1063 + qc_active &= ~(1ULL << ATA_TAG_INTERNAL);
1064 + }
1065 +
1066 + return qc_active;
1067 +}
1068 +EXPORT_SYMBOL_GPL(ata_qc_get_active);
1069 +
1070 /**
1071 * ata_qc_complete_multiple - Complete multiple qcs successfully
1072 * @ap: port in question
1073 diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
1074 index 8e9cb198fcd1..ca6c706e9c25 100644
1075 --- a/drivers/ata/sata_fsl.c
1076 +++ b/drivers/ata/sata_fsl.c
1077 @@ -1278,7 +1278,7 @@ static void sata_fsl_host_intr(struct ata_port *ap)
1078 i, ioread32(hcr_base + CC),
1079 ioread32(hcr_base + CA));
1080 }
1081 - ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask);
1082 + ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask);
1083 return;
1084
1085 } else if ((ap->qc_active & (1ULL << ATA_TAG_INTERNAL))) {
1086 diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
1087 index ad385a113391..bde695a32097 100644
1088 --- a/drivers/ata/sata_mv.c
1089 +++ b/drivers/ata/sata_mv.c
1090 @@ -2827,7 +2827,7 @@ static void mv_process_crpb_entries(struct ata_port *ap, struct mv_port_priv *pp
1091 }
1092
1093 if (work_done) {
1094 - ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask);
1095 + ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask);
1096
1097 /* Update the software queue position index in hardware */
1098 writelfl((pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK) |
1099 diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
1100 index 56946012d113..7510303111fa 100644
1101 --- a/drivers/ata/sata_nv.c
1102 +++ b/drivers/ata/sata_nv.c
1103 @@ -984,7 +984,7 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance)
1104 check_commands = 0;
1105 check_commands &= ~(1 << pos);
1106 }
1107 - ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask);
1108 + ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask);
1109 }
1110 }
1111
1112 diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
1113 index fd1e19f1a49f..3666afa639d1 100644
1114 --- a/drivers/block/xen-blkback/blkback.c
1115 +++ b/drivers/block/xen-blkback/blkback.c
1116 @@ -936,6 +936,8 @@ next:
1117 out_of_memory:
1118 pr_alert("%s: out of memory\n", __func__);
1119 put_free_pages(ring, pages_to_gnt, segs_to_map);
1120 + for (i = last_map; i < num; i++)
1121 + pages[i]->handle = BLKBACK_INVALID_HANDLE;
1122 return -ENOMEM;
1123 }
1124
1125 diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
1126 index b90dbcd99c03..c4cd68116e7f 100644
1127 --- a/drivers/block/xen-blkback/xenbus.c
1128 +++ b/drivers/block/xen-blkback/xenbus.c
1129 @@ -171,6 +171,15 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
1130 blkif->domid = domid;
1131 atomic_set(&blkif->refcnt, 1);
1132 init_completion(&blkif->drain_complete);
1133 +
1134 + /*
1135 + * Because freeing back to the cache may be deferred, it is not
1136 + * safe to unload the module (and hence destroy the cache) until
1137 + * this has completed. To prevent premature unloading, take an
1138 + * extra module reference here and release only when the object
1139 + * has been freed back to the cache.
1140 + */
1141 + __module_get(THIS_MODULE);
1142 INIT_WORK(&blkif->free_work, xen_blkif_deferred_free);
1143
1144 return blkif;
1145 @@ -320,6 +329,7 @@ static void xen_blkif_free(struct xen_blkif *blkif)
1146
1147 /* Make sure everything is drained before shutting down */
1148 kmem_cache_free(xen_blkif_cachep, blkif);
1149 + module_put(THIS_MODULE);
1150 }
1151
1152 int __init xen_blkif_interface_init(void)
1153 diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
1154 index 23e606aaaea4..04cf767d0708 100644
1155 --- a/drivers/bluetooth/btusb.c
1156 +++ b/drivers/bluetooth/btusb.c
1157 @@ -1200,7 +1200,7 @@ static int btusb_open(struct hci_dev *hdev)
1158 if (data->setup_on_usb) {
1159 err = data->setup_on_usb(hdev);
1160 if (err < 0)
1161 - return err;
1162 + goto setup_fail;
1163 }
1164
1165 data->intf->needs_remote_wakeup = 1;
1166 @@ -1239,6 +1239,7 @@ done:
1167
1168 failed:
1169 clear_bit(BTUSB_INTR_RUNNING, &data->flags);
1170 +setup_fail:
1171 usb_autopm_put_interface(data->intf);
1172 return err;
1173 }
1174 diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
1175 index 470c7ef02ea4..4b04ffbe5e7e 100644
1176 --- a/drivers/clocksource/timer-riscv.c
1177 +++ b/drivers/clocksource/timer-riscv.c
1178 @@ -41,7 +41,7 @@ static unsigned long long riscv_clocksource_rdtime(struct clocksource *cs)
1179 return get_cycles64();
1180 }
1181
1182 -static u64 riscv_sched_clock(void)
1183 +static u64 notrace riscv_sched_clock(void)
1184 {
1185 return get_cycles64();
1186 }
1187 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
1188 index 3a1484e7a3ae..c64d20fdc187 100644
1189 --- a/drivers/devfreq/devfreq.c
1190 +++ b/drivers/devfreq/devfreq.c
1191 @@ -551,26 +551,30 @@ static int devfreq_notifier_call(struct notifier_block *nb, unsigned long type,
1192 void *devp)
1193 {
1194 struct devfreq *devfreq = container_of(nb, struct devfreq, nb);
1195 - int ret;
1196 + int err = -EINVAL;
1197
1198 mutex_lock(&devfreq->lock);
1199
1200 devfreq->scaling_min_freq = find_available_min_freq(devfreq);
1201 - if (!devfreq->scaling_min_freq) {
1202 - mutex_unlock(&devfreq->lock);
1203 - return -EINVAL;
1204 - }
1205 + if (!devfreq->scaling_min_freq)
1206 + goto out;
1207
1208 devfreq->scaling_max_freq = find_available_max_freq(devfreq);
1209 if (!devfreq->scaling_max_freq) {
1210 - mutex_unlock(&devfreq->lock);
1211 - return -EINVAL;
1212 + devfreq->scaling_max_freq = ULONG_MAX;
1213 + goto out;
1214 }
1215
1216 - ret = update_devfreq(devfreq);
1217 + err = update_devfreq(devfreq);
1218 +
1219 +out:
1220 mutex_unlock(&devfreq->lock);
1221 + if (err)
1222 + dev_err(devfreq->dev.parent,
1223 + "failed to update frequency from OPP notifier (%d)\n",
1224 + err);
1225
1226 - return ret;
1227 + return NOTIFY_OK;
1228 }
1229
1230 /**
1231 @@ -584,11 +588,6 @@ static void devfreq_dev_release(struct device *dev)
1232 struct devfreq *devfreq = to_devfreq(dev);
1233
1234 mutex_lock(&devfreq_list_lock);
1235 - if (IS_ERR(find_device_devfreq(devfreq->dev.parent))) {
1236 - mutex_unlock(&devfreq_list_lock);
1237 - dev_warn(&devfreq->dev, "releasing devfreq which doesn't exist\n");
1238 - return;
1239 - }
1240 list_del(&devfreq->node);
1241 mutex_unlock(&devfreq_list_lock);
1242
1243 @@ -643,6 +642,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
1244 devfreq->dev.parent = dev;
1245 devfreq->dev.class = devfreq_class;
1246 devfreq->dev.release = devfreq_dev_release;
1247 + INIT_LIST_HEAD(&devfreq->node);
1248 devfreq->profile = profile;
1249 strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
1250 devfreq->previous_freq = profile->initial_freq;
1251 @@ -1196,7 +1196,7 @@ static ssize_t available_governors_show(struct device *d,
1252 * The devfreq with immutable governor (e.g., passive) shows
1253 * only own governor.
1254 */
1255 - if (df->governor->immutable) {
1256 + if (df->governor && df->governor->immutable) {
1257 count = scnprintf(&buf[count], DEVFREQ_NAME_LEN,
1258 "%s ", df->governor_name);
1259 /*
1260 diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
1261 index cafb1cc065bb..bf95f1d551c5 100644
1262 --- a/drivers/dma/dma-jz4780.c
1263 +++ b/drivers/dma/dma-jz4780.c
1264 @@ -1004,7 +1004,8 @@ static const struct jz4780_dma_soc_data jz4740_dma_soc_data = {
1265 static const struct jz4780_dma_soc_data jz4725b_dma_soc_data = {
1266 .nb_channels = 6,
1267 .transfer_ord_max = 5,
1268 - .flags = JZ_SOC_DATA_PER_CHAN_PM | JZ_SOC_DATA_NO_DCKES_DCKEC,
1269 + .flags = JZ_SOC_DATA_PER_CHAN_PM | JZ_SOC_DATA_NO_DCKES_DCKEC |
1270 + JZ_SOC_DATA_BREAK_LINKS,
1271 };
1272
1273 static const struct jz4780_dma_soc_data jz4770_dma_soc_data = {
1274 diff --git a/drivers/dma/virt-dma.c b/drivers/dma/virt-dma.c
1275 index ec4adf4260a0..256fc662c500 100644
1276 --- a/drivers/dma/virt-dma.c
1277 +++ b/drivers/dma/virt-dma.c
1278 @@ -104,9 +104,8 @@ static void vchan_complete(unsigned long arg)
1279 dmaengine_desc_get_callback(&vd->tx, &cb);
1280
1281 list_del(&vd->node);
1282 - vchan_vdesc_fini(vd);
1283 -
1284 dmaengine_desc_callback_invoke(&cb, &vd->tx_result);
1285 + vchan_vdesc_fini(vd);
1286 }
1287 }
1288
1289 diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
1290 index b132ab9ad607..715e491dfbc3 100644
1291 --- a/drivers/firewire/net.c
1292 +++ b/drivers/firewire/net.c
1293 @@ -250,7 +250,11 @@ static int fwnet_header_cache(const struct neighbour *neigh,
1294 h = (struct fwnet_header *)((u8 *)hh->hh_data + HH_DATA_OFF(sizeof(*h)));
1295 h->h_proto = type;
1296 memcpy(h->h_dest, neigh->ha, net->addr_len);
1297 - hh->hh_len = FWNET_HLEN;
1298 +
1299 + /* Pairs with the READ_ONCE() in neigh_resolve_output(),
1300 + * neigh_hh_output() and neigh_update_hhs().
1301 + */
1302 + smp_store_release(&hh->hh_len, FWNET_HLEN);
1303
1304 return 0;
1305 }
1306 diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
1307 index 92f843eaf1e0..7a30952b463d 100644
1308 --- a/drivers/firmware/arm_scmi/bus.c
1309 +++ b/drivers/firmware/arm_scmi/bus.c
1310 @@ -135,8 +135,10 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol)
1311 return NULL;
1312
1313 id = ida_simple_get(&scmi_bus_id, 1, 0, GFP_KERNEL);
1314 - if (id < 0)
1315 - goto free_mem;
1316 + if (id < 0) {
1317 + kfree(scmi_dev);
1318 + return NULL;
1319 + }
1320
1321 scmi_dev->id = id;
1322 scmi_dev->protocol_id = protocol;
1323 @@ -154,8 +156,6 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol)
1324 put_dev:
1325 put_device(&scmi_dev->dev);
1326 ida_simple_remove(&scmi_bus_id, id);
1327 -free_mem:
1328 - kfree(scmi_dev);
1329 return NULL;
1330 }
1331
1332 diff --git a/drivers/firmware/efi/rci2-table.c b/drivers/firmware/efi/rci2-table.c
1333 index 76b0c354a027..de1a9a1f9f14 100644
1334 --- a/drivers/firmware/efi/rci2-table.c
1335 +++ b/drivers/firmware/efi/rci2-table.c
1336 @@ -81,6 +81,9 @@ static int __init efi_rci2_sysfs_init(void)
1337 struct kobject *tables_kobj;
1338 int ret = -ENOMEM;
1339
1340 + if (rci2_table_phys == EFI_INVALID_TABLE_ADDR)
1341 + return 0;
1342 +
1343 rci2_base = memremap(rci2_table_phys,
1344 sizeof(struct rci2_table_global_hdr),
1345 MEMREMAP_WB);
1346 diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c
1347 index 43d3fa5f511a..0fb2211f9573 100644
1348 --- a/drivers/gpio/gpio-xtensa.c
1349 +++ b/drivers/gpio/gpio-xtensa.c
1350 @@ -44,15 +44,14 @@ static inline unsigned long enable_cp(unsigned long *cpenable)
1351 unsigned long flags;
1352
1353 local_irq_save(flags);
1354 - RSR_CPENABLE(*cpenable);
1355 - WSR_CPENABLE(*cpenable | BIT(XCHAL_CP_ID_XTIOP));
1356 -
1357 + *cpenable = xtensa_get_sr(cpenable);
1358 + xtensa_set_sr(*cpenable | BIT(XCHAL_CP_ID_XTIOP), cpenable);
1359 return flags;
1360 }
1361
1362 static inline void disable_cp(unsigned long flags, unsigned long cpenable)
1363 {
1364 - WSR_CPENABLE(cpenable);
1365 + xtensa_set_sr(cpenable, cpenable);
1366 local_irq_restore(flags);
1367 }
1368
1369 diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
1370 index 104ed299d5ea..99d19f80440e 100644
1371 --- a/drivers/gpio/gpiolib.c
1372 +++ b/drivers/gpio/gpiolib.c
1373 @@ -220,6 +220,14 @@ int gpiod_get_direction(struct gpio_desc *desc)
1374 chip = gpiod_to_chip(desc);
1375 offset = gpio_chip_hwgpio(desc);
1376
1377 + /*
1378 + * Open drain emulation using input mode may incorrectly report
1379 + * input here, fix that up.
1380 + */
1381 + if (test_bit(FLAG_OPEN_DRAIN, &desc->flags) &&
1382 + test_bit(FLAG_IS_OUT, &desc->flags))
1383 + return 0;
1384 +
1385 if (!chip->get_direction)
1386 return -ENOTSUPP;
1387
1388 diff --git a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c
1389 index 5850c8e34caa..97d11d792351 100644
1390 --- a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c
1391 +++ b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c
1392 @@ -261,23 +261,29 @@ static void df_v3_6_update_medium_grain_clock_gating(struct amdgpu_device *adev,
1393 {
1394 u32 tmp;
1395
1396 - /* Put DF on broadcast mode */
1397 - adev->df_funcs->enable_broadcast_mode(adev, true);
1398 -
1399 - if (enable && (adev->cg_flags & AMD_CG_SUPPORT_DF_MGCG)) {
1400 - tmp = RREG32_SOC15(DF, 0, mmDF_PIE_AON0_DfGlobalClkGater);
1401 - tmp &= ~DF_PIE_AON0_DfGlobalClkGater__MGCGMode_MASK;
1402 - tmp |= DF_V3_6_MGCG_ENABLE_15_CYCLE_DELAY;
1403 - WREG32_SOC15(DF, 0, mmDF_PIE_AON0_DfGlobalClkGater, tmp);
1404 - } else {
1405 - tmp = RREG32_SOC15(DF, 0, mmDF_PIE_AON0_DfGlobalClkGater);
1406 - tmp &= ~DF_PIE_AON0_DfGlobalClkGater__MGCGMode_MASK;
1407 - tmp |= DF_V3_6_MGCG_DISABLE;
1408 - WREG32_SOC15(DF, 0, mmDF_PIE_AON0_DfGlobalClkGater, tmp);
1409 - }
1410 + if (adev->cg_flags & AMD_CG_SUPPORT_DF_MGCG) {
1411 + /* Put DF on broadcast mode */
1412 + adev->df_funcs->enable_broadcast_mode(adev, true);
1413 +
1414 + if (enable) {
1415 + tmp = RREG32_SOC15(DF, 0,
1416 + mmDF_PIE_AON0_DfGlobalClkGater);
1417 + tmp &= ~DF_PIE_AON0_DfGlobalClkGater__MGCGMode_MASK;
1418 + tmp |= DF_V3_6_MGCG_ENABLE_15_CYCLE_DELAY;
1419 + WREG32_SOC15(DF, 0,
1420 + mmDF_PIE_AON0_DfGlobalClkGater, tmp);
1421 + } else {
1422 + tmp = RREG32_SOC15(DF, 0,
1423 + mmDF_PIE_AON0_DfGlobalClkGater);
1424 + tmp &= ~DF_PIE_AON0_DfGlobalClkGater__MGCGMode_MASK;
1425 + tmp |= DF_V3_6_MGCG_DISABLE;
1426 + WREG32_SOC15(DF, 0,
1427 + mmDF_PIE_AON0_DfGlobalClkGater, tmp);
1428 + }
1429
1430 - /* Exit broadcast mode */
1431 - adev->df_funcs->enable_broadcast_mode(adev, false);
1432 + /* Exit broadcast mode */
1433 + adev->df_funcs->enable_broadcast_mode(adev, false);
1434 + }
1435 }
1436
1437 static void df_v3_6_get_clockgating_state(struct amdgpu_device *adev,
1438 diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
1439 index 87dd55e9d72b..cc88ba76a8d4 100644
1440 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
1441 +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
1442 @@ -6184,7 +6184,23 @@ static void gfx_v8_0_ring_emit_fence_gfx(struct amdgpu_ring *ring, u64 addr,
1443 bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT;
1444 bool int_sel = flags & AMDGPU_FENCE_FLAG_INT;
1445
1446 - /* EVENT_WRITE_EOP - flush caches, send int */
1447 + /* Workaround for cache flush problems. First send a dummy EOP
1448 + * event down the pipe with seq one below.
1449 + */
1450 + amdgpu_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4));
1451 + amdgpu_ring_write(ring, (EOP_TCL1_ACTION_EN |
1452 + EOP_TC_ACTION_EN |
1453 + EOP_TC_WB_ACTION_EN |
1454 + EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) |
1455 + EVENT_INDEX(5)));
1456 + amdgpu_ring_write(ring, addr & 0xfffffffc);
1457 + amdgpu_ring_write(ring, (upper_32_bits(addr) & 0xffff) |
1458 + DATA_SEL(1) | INT_SEL(0));
1459 + amdgpu_ring_write(ring, lower_32_bits(seq - 1));
1460 + amdgpu_ring_write(ring, upper_32_bits(seq - 1));
1461 +
1462 + /* Then send the real EOP event down the pipe:
1463 + * EVENT_WRITE_EOP - flush caches, send int */
1464 amdgpu_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4));
1465 amdgpu_ring_write(ring, (EOP_TCL1_ACTION_EN |
1466 EOP_TC_ACTION_EN |
1467 @@ -6926,7 +6942,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = {
1468 5 + /* COND_EXEC */
1469 7 + /* PIPELINE_SYNC */
1470 VI_FLUSH_GPU_TLB_NUM_WREG * 5 + 9 + /* VM_FLUSH */
1471 - 8 + /* FENCE for VM_FLUSH */
1472 + 12 + /* FENCE for VM_FLUSH */
1473 20 + /* GDS switch */
1474 4 + /* double SWITCH_BUFFER,
1475 the first COND_EXEC jump to the place just
1476 @@ -6938,7 +6954,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = {
1477 31 + /* DE_META */
1478 3 + /* CNTX_CTRL */
1479 5 + /* HDP_INVL */
1480 - 8 + 8 + /* FENCE x2 */
1481 + 12 + 12 + /* FENCE x2 */
1482 2, /* SWITCH_BUFFER */
1483 .emit_ib_size = 4, /* gfx_v8_0_ring_emit_ib_gfx */
1484 .emit_ib = gfx_v8_0_ring_emit_ib_gfx,
1485 diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
1486 index 067f5579f452..793aa8e8ec9a 100644
1487 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
1488 +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
1489 @@ -373,7 +373,7 @@ bool dc_link_is_dp_sink_present(struct dc_link *link)
1490
1491 if (GPIO_RESULT_OK != dal_ddc_open(
1492 ddc, GPIO_MODE_INPUT, GPIO_DDC_CONFIG_TYPE_MODE_I2C)) {
1493 - dal_gpio_destroy_ddc(&ddc);
1494 + dal_ddc_close(ddc);
1495
1496 return present;
1497 }
1498 diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
1499 index 5a583707d198..0ab890c927ec 100644
1500 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
1501 +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
1502 @@ -3492,7 +3492,14 @@ void dp_set_fec_enable(struct dc_link *link, bool enable)
1503 if (link_enc->funcs->fec_set_enable &&
1504 link->dpcd_caps.fec_cap.bits.FEC_CAPABLE) {
1505 if (link->fec_state == dc_link_fec_ready && enable) {
1506 - msleep(1);
1507 + /* Accord to DP spec, FEC enable sequence can first
1508 + * be transmitted anytime after 1000 LL codes have
1509 + * been transmitted on the link after link training
1510 + * completion. Using 1 lane RBR should have the maximum
1511 + * time for transmitting 1000 LL codes which is 6.173 us.
1512 + * So use 7 microseconds delay instead.
1513 + */
1514 + udelay(7);
1515 link_enc->funcs->fec_set_enable(link_enc, true);
1516 link->fec_state = dc_link_fec_enabled;
1517 } else if (link->fec_state == dc_link_fec_enabled && !enable) {
1518 diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
1519 index 78b2cc2e122f..3b7769a3e67e 100644
1520 --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
1521 +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
1522 @@ -1419,13 +1419,20 @@ enum dc_status dcn20_build_mapped_resource(const struct dc *dc, struct dc_state
1523
1524 static void acquire_dsc(struct resource_context *res_ctx,
1525 const struct resource_pool *pool,
1526 - struct display_stream_compressor **dsc)
1527 + struct display_stream_compressor **dsc,
1528 + int pipe_idx)
1529 {
1530 int i;
1531
1532 ASSERT(*dsc == NULL);
1533 *dsc = NULL;
1534
1535 + if (pool->res_cap->num_dsc == pool->res_cap->num_opp) {
1536 + *dsc = pool->dscs[pipe_idx];
1537 + res_ctx->is_dsc_acquired[pipe_idx] = true;
1538 + return;
1539 + }
1540 +
1541 /* Find first free DSC */
1542 for (i = 0; i < pool->res_cap->num_dsc; i++)
1543 if (!res_ctx->is_dsc_acquired[i]) {
1544 @@ -1468,7 +1475,7 @@ static enum dc_status add_dsc_to_stream_resource(struct dc *dc,
1545 if (pipe_ctx->stream != dc_stream)
1546 continue;
1547
1548 - acquire_dsc(&dc_ctx->res_ctx, pool, &pipe_ctx->stream_res.dsc);
1549 + acquire_dsc(&dc_ctx->res_ctx, pool, &pipe_ctx->stream_res.dsc, i);
1550
1551 /* The number of DSCs can be less than the number of pipes */
1552 if (!pipe_ctx->stream_res.dsc) {
1553 @@ -1669,7 +1676,7 @@ static bool dcn20_split_stream_for_odm(
1554 next_odm_pipe->stream_res.opp = pool->opps[next_odm_pipe->pipe_idx];
1555 #ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
1556 if (next_odm_pipe->stream->timing.flags.DSC == 1) {
1557 - acquire_dsc(res_ctx, pool, &next_odm_pipe->stream_res.dsc);
1558 + acquire_dsc(res_ctx, pool, &next_odm_pipe->stream_res.dsc, next_odm_pipe->pipe_idx);
1559 ASSERT(next_odm_pipe->stream_res.dsc);
1560 if (next_odm_pipe->stream_res.dsc == NULL)
1561 return false;
1562 diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c
1563 index 5ab9d6240498..e95025b1d14d 100644
1564 --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c
1565 +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c
1566 @@ -492,15 +492,23 @@ void enc2_stream_encoder_dp_unblank(
1567 DP_VID_N_MUL, n_multiply);
1568 }
1569
1570 - /* set DIG_START to 0x1 to reset FIFO */
1571 + /* make sure stream is disabled before resetting steer fifo */
1572 + REG_UPDATE(DP_VID_STREAM_CNTL, DP_VID_STREAM_ENABLE, false);
1573 + REG_WAIT(DP_VID_STREAM_CNTL, DP_VID_STREAM_STATUS, 0, 10, 5000);
1574
1575 + /* set DIG_START to 0x1 to reset FIFO */
1576 REG_UPDATE(DIG_FE_CNTL, DIG_START, 1);
1577 + udelay(1);
1578
1579 /* write 0 to take the FIFO out of reset */
1580
1581 REG_UPDATE(DIG_FE_CNTL, DIG_START, 0);
1582
1583 - /* switch DP encoder to CRTC data */
1584 + /* switch DP encoder to CRTC data, but reset it the fifo first. It may happen
1585 + * that it overflows during mode transition, and sometimes doesn't recover.
1586 + */
1587 + REG_UPDATE(DP_STEER_FIFO, DP_STEER_FIFO_RESET, 1);
1588 + udelay(10);
1589
1590 REG_UPDATE(DP_STEER_FIFO, DP_STEER_FIFO_RESET, 0);
1591
1592 diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
1593 index de182185fe1f..b0e5e64df212 100644
1594 --- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
1595 +++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
1596 @@ -258,7 +258,7 @@ struct _vcs_dpi_soc_bounding_box_st dcn2_1_soc = {
1597 .vmm_page_size_bytes = 4096,
1598 .dram_clock_change_latency_us = 23.84,
1599 .return_bus_width_bytes = 64,
1600 - .dispclk_dppclk_vco_speed_mhz = 3550,
1601 + .dispclk_dppclk_vco_speed_mhz = 3600,
1602 .xfc_bus_transport_time_us = 4,
1603 .xfc_xbuf_latency_tolerance_us = 4,
1604 .use_urgent_burst_bw = 1,
1605 diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
1606 index 58c091ab67b2..a066e9297777 100644
1607 --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
1608 +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
1609 @@ -844,6 +844,7 @@ static int smu_sw_init(void *handle)
1610 smu->smu_baco.platform_support = false;
1611
1612 mutex_init(&smu->sensor_lock);
1613 + mutex_init(&smu->metrics_lock);
1614
1615 smu->watermarks_bitmap = 0;
1616 smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
1617 diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
1618 index d493a3f8c07a..08a717a34bd6 100644
1619 --- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
1620 +++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
1621 @@ -910,18 +910,21 @@ static int arcturus_get_metrics_table(struct smu_context *smu,
1622 struct smu_table_context *smu_table= &smu->smu_table;
1623 int ret = 0;
1624
1625 + mutex_lock(&smu->metrics_lock);
1626 if (!smu_table->metrics_time ||
1627 time_after(jiffies, smu_table->metrics_time + HZ / 1000)) {
1628 ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, 0,
1629 (void *)smu_table->metrics_table, false);
1630 if (ret) {
1631 pr_info("Failed to export SMU metrics table!\n");
1632 + mutex_unlock(&smu->metrics_lock);
1633 return ret;
1634 }
1635 smu_table->metrics_time = jiffies;
1636 }
1637
1638 memcpy(metrics_table, smu_table->metrics_table, sizeof(SmuMetrics_t));
1639 + mutex_unlock(&smu->metrics_lock);
1640
1641 return ret;
1642 }
1643 @@ -1388,12 +1391,17 @@ static int arcturus_get_power_profile_mode(struct smu_context *smu,
1644 "VR",
1645 "COMPUTE",
1646 "CUSTOM"};
1647 + static const char *title[] = {
1648 + "PROFILE_INDEX(NAME)"};
1649 uint32_t i, size = 0;
1650 int16_t workload_type = 0;
1651
1652 if (!smu->pm_enabled || !buf)
1653 return -EINVAL;
1654
1655 + size += sprintf(buf + size, "%16s\n",
1656 + title[0]);
1657 +
1658 for (i = 0; i <= PP_SMC_POWER_PROFILE_CUSTOM; i++) {
1659 /*
1660 * Conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT
1661 diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
1662 index 23171a4d9a31..5ad9a7878f6b 100644
1663 --- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
1664 +++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
1665 @@ -345,6 +345,7 @@ struct smu_context
1666 const struct pptable_funcs *ppt_funcs;
1667 struct mutex mutex;
1668 struct mutex sensor_lock;
1669 + struct mutex metrics_lock;
1670 uint64_t pool_size;
1671
1672 struct smu_table_context smu_table;
1673 diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
1674 index 328e258a6895..7d913a06ebac 100644
1675 --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
1676 +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
1677 @@ -547,17 +547,20 @@ static int navi10_get_metrics_table(struct smu_context *smu,
1678 struct smu_table_context *smu_table= &smu->smu_table;
1679 int ret = 0;
1680
1681 + mutex_lock(&smu->metrics_lock);
1682 if (!smu_table->metrics_time || time_after(jiffies, smu_table->metrics_time + msecs_to_jiffies(100))) {
1683 ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, 0,
1684 (void *)smu_table->metrics_table, false);
1685 if (ret) {
1686 pr_info("Failed to export SMU metrics table!\n");
1687 + mutex_unlock(&smu->metrics_lock);
1688 return ret;
1689 }
1690 smu_table->metrics_time = jiffies;
1691 }
1692
1693 memcpy(metrics_table, smu_table->metrics_table, sizeof(SmuMetrics_t));
1694 + mutex_unlock(&smu->metrics_lock);
1695
1696 return ret;
1697 }
1698 diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
1699 index 92c393f613d3..3c3f719971f7 100644
1700 --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
1701 +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
1702 @@ -1691,17 +1691,20 @@ static int vega20_get_metrics_table(struct smu_context *smu,
1703 struct smu_table_context *smu_table= &smu->smu_table;
1704 int ret = 0;
1705
1706 + mutex_lock(&smu->metrics_lock);
1707 if (!smu_table->metrics_time || time_after(jiffies, smu_table->metrics_time + HZ / 1000)) {
1708 ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, 0,
1709 (void *)smu_table->metrics_table, false);
1710 if (ret) {
1711 pr_info("Failed to export SMU metrics table!\n");
1712 + mutex_unlock(&smu->metrics_lock);
1713 return ret;
1714 }
1715 smu_table->metrics_time = jiffies;
1716 }
1717
1718 memcpy(metrics_table, smu_table->metrics_table, sizeof(SmuMetrics_t));
1719 + mutex_unlock(&smu->metrics_lock);
1720
1721 return ret;
1722 }
1723 diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
1724 index 06a506c29463..d564bfcab6a3 100644
1725 --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
1726 +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
1727 @@ -525,7 +525,8 @@ __unwind_incomplete_requests(struct intel_engine_cs *engine)
1728 */
1729 if (test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
1730 &rq->fence.flags)) {
1731 - spin_lock(&rq->lock);
1732 + spin_lock_nested(&rq->lock,
1733 + SINGLE_DEPTH_NESTING);
1734 i915_request_cancel_breadcrumb(rq);
1735 spin_unlock(&rq->lock);
1736 }
1737 diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
1738 index f9c9e32b299c..35bb825d1918 100644
1739 --- a/drivers/gpu/drm/mcde/mcde_dsi.c
1740 +++ b/drivers/gpu/drm/mcde/mcde_dsi.c
1741 @@ -935,11 +935,13 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
1742 for_each_available_child_of_node(dev->of_node, child) {
1743 panel = of_drm_find_panel(child);
1744 if (IS_ERR(panel)) {
1745 - dev_err(dev, "failed to find panel try bridge (%lu)\n",
1746 + dev_err(dev, "failed to find panel try bridge (%ld)\n",
1747 PTR_ERR(panel));
1748 + panel = NULL;
1749 +
1750 bridge = of_drm_find_bridge(child);
1751 if (IS_ERR(bridge)) {
1752 - dev_err(dev, "failed to find bridge (%lu)\n",
1753 + dev_err(dev, "failed to find bridge (%ld)\n",
1754 PTR_ERR(bridge));
1755 return PTR_ERR(bridge);
1756 }
1757 diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
1758 index a052364a5d74..edd45f434ccd 100644
1759 --- a/drivers/gpu/drm/msm/msm_gpu.c
1760 +++ b/drivers/gpu/drm/msm/msm_gpu.c
1761 @@ -16,6 +16,7 @@
1762 #include <linux/pm_opp.h>
1763 #include <linux/devfreq.h>
1764 #include <linux/devcoredump.h>
1765 +#include <linux/sched/task.h>
1766
1767 /*
1768 * Power Management:
1769 diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
1770 index b5b1a34f896f..d735ea7e2d88 100644
1771 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
1772 +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
1773 @@ -326,9 +326,9 @@ nv50_outp_atomic_check_view(struct drm_encoder *encoder,
1774 * same size as the native one (e.g. different
1775 * refresh rate)
1776 */
1777 - if (adjusted_mode->hdisplay == native_mode->hdisplay &&
1778 - adjusted_mode->vdisplay == native_mode->vdisplay &&
1779 - adjusted_mode->type & DRM_MODE_TYPE_DRIVER)
1780 + if (mode->hdisplay == native_mode->hdisplay &&
1781 + mode->vdisplay == native_mode->vdisplay &&
1782 + mode->type & DRM_MODE_TYPE_DRIVER)
1783 break;
1784 mode = native_mode;
1785 asyc->scaler.full = true;
1786 diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
1787 index a442a955f98c..eb31c5b6c8e9 100644
1788 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c
1789 +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
1790 @@ -245,14 +245,22 @@ nouveau_conn_atomic_duplicate_state(struct drm_connector *connector)
1791 void
1792 nouveau_conn_reset(struct drm_connector *connector)
1793 {
1794 + struct nouveau_connector *nv_connector = nouveau_connector(connector);
1795 struct nouveau_conn_atom *asyc;
1796
1797 - if (WARN_ON(!(asyc = kzalloc(sizeof(*asyc), GFP_KERNEL))))
1798 - return;
1799 + if (drm_drv_uses_atomic_modeset(connector->dev)) {
1800 + if (WARN_ON(!(asyc = kzalloc(sizeof(*asyc), GFP_KERNEL))))
1801 + return;
1802 +
1803 + if (connector->state)
1804 + nouveau_conn_atomic_destroy_state(connector,
1805 + connector->state);
1806 +
1807 + __drm_atomic_helper_connector_reset(connector, &asyc->state);
1808 + } else {
1809 + asyc = &nv_connector->properties_state;
1810 + }
1811
1812 - if (connector->state)
1813 - nouveau_conn_atomic_destroy_state(connector, connector->state);
1814 - __drm_atomic_helper_connector_reset(connector, &asyc->state);
1815 asyc->dither.mode = DITHERING_MODE_AUTO;
1816 asyc->dither.depth = DITHERING_DEPTH_AUTO;
1817 asyc->scaler.mode = DRM_MODE_SCALE_NONE;
1818 @@ -276,8 +284,14 @@ void
1819 nouveau_conn_attach_properties(struct drm_connector *connector)
1820 {
1821 struct drm_device *dev = connector->dev;
1822 - struct nouveau_conn_atom *armc = nouveau_conn_atom(connector->state);
1823 struct nouveau_display *disp = nouveau_display(dev);
1824 + struct nouveau_connector *nv_connector = nouveau_connector(connector);
1825 + struct nouveau_conn_atom *armc;
1826 +
1827 + if (drm_drv_uses_atomic_modeset(connector->dev))
1828 + armc = nouveau_conn_atom(connector->state);
1829 + else
1830 + armc = &nv_connector->properties_state;
1831
1832 /* Init DVI-I specific properties. */
1833 if (connector->connector_type == DRM_MODE_CONNECTOR_DVII)
1834 @@ -749,9 +763,9 @@ static int
1835 nouveau_connector_set_property(struct drm_connector *connector,
1836 struct drm_property *property, uint64_t value)
1837 {
1838 - struct nouveau_conn_atom *asyc = nouveau_conn_atom(connector->state);
1839 struct nouveau_connector *nv_connector = nouveau_connector(connector);
1840 struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
1841 + struct nouveau_conn_atom *asyc = &nv_connector->properties_state;
1842 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
1843 int ret;
1844
1845 diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.h b/drivers/gpu/drm/nouveau/nouveau_connector.h
1846 index f43a8d63aef8..de84fb4708c7 100644
1847 --- a/drivers/gpu/drm/nouveau/nouveau_connector.h
1848 +++ b/drivers/gpu/drm/nouveau/nouveau_connector.h
1849 @@ -29,6 +29,7 @@
1850
1851 #include <nvif/notify.h>
1852
1853 +#include <drm/drm_crtc.h>
1854 #include <drm/drm_edid.h>
1855 #include <drm/drm_encoder.h>
1856 #include <drm/drm_dp_helper.h>
1857 @@ -44,6 +45,60 @@ struct dcb_output;
1858 struct nouveau_backlight;
1859 #endif
1860
1861 +#define nouveau_conn_atom(p) \
1862 + container_of((p), struct nouveau_conn_atom, state)
1863 +
1864 +struct nouveau_conn_atom {
1865 + struct drm_connector_state state;
1866 +
1867 + struct {
1868 + /* The enum values specifically defined here match nv50/gf119
1869 + * hw values, and the code relies on this.
1870 + */
1871 + enum {
1872 + DITHERING_MODE_OFF = 0x00,
1873 + DITHERING_MODE_ON = 0x01,
1874 + DITHERING_MODE_DYNAMIC2X2 = 0x10 | DITHERING_MODE_ON,
1875 + DITHERING_MODE_STATIC2X2 = 0x18 | DITHERING_MODE_ON,
1876 + DITHERING_MODE_TEMPORAL = 0x20 | DITHERING_MODE_ON,
1877 + DITHERING_MODE_AUTO
1878 + } mode;
1879 + enum {
1880 + DITHERING_DEPTH_6BPC = 0x00,
1881 + DITHERING_DEPTH_8BPC = 0x02,
1882 + DITHERING_DEPTH_AUTO
1883 + } depth;
1884 + } dither;
1885 +
1886 + struct {
1887 + int mode; /* DRM_MODE_SCALE_* */
1888 + struct {
1889 + enum {
1890 + UNDERSCAN_OFF,
1891 + UNDERSCAN_ON,
1892 + UNDERSCAN_AUTO,
1893 + } mode;
1894 + u32 hborder;
1895 + u32 vborder;
1896 + } underscan;
1897 + bool full;
1898 + } scaler;
1899 +
1900 + struct {
1901 + int color_vibrance;
1902 + int vibrant_hue;
1903 + } procamp;
1904 +
1905 + union {
1906 + struct {
1907 + bool dither:1;
1908 + bool scaler:1;
1909 + bool procamp:1;
1910 + };
1911 + u8 mask;
1912 + } set;
1913 +};
1914 +
1915 struct nouveau_connector {
1916 struct drm_connector base;
1917 enum dcb_connector_type type;
1918 @@ -63,6 +118,12 @@ struct nouveau_connector {
1919 #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
1920 struct nouveau_backlight *backlight;
1921 #endif
1922 + /*
1923 + * Our connector property code expects a nouveau_conn_atom struct
1924 + * even on pre-nv50 where we do not support atomic. This embedded
1925 + * version gets used in the non atomic modeset case.
1926 + */
1927 + struct nouveau_conn_atom properties_state;
1928 };
1929
1930 static inline struct nouveau_connector *nouveau_connector(
1931 @@ -121,61 +182,6 @@ extern int nouveau_ignorelid;
1932 extern int nouveau_duallink;
1933 extern int nouveau_hdmimhz;
1934
1935 -#include <drm/drm_crtc.h>
1936 -#define nouveau_conn_atom(p) \
1937 - container_of((p), struct nouveau_conn_atom, state)
1938 -
1939 -struct nouveau_conn_atom {
1940 - struct drm_connector_state state;
1941 -
1942 - struct {
1943 - /* The enum values specifically defined here match nv50/gf119
1944 - * hw values, and the code relies on this.
1945 - */
1946 - enum {
1947 - DITHERING_MODE_OFF = 0x00,
1948 - DITHERING_MODE_ON = 0x01,
1949 - DITHERING_MODE_DYNAMIC2X2 = 0x10 | DITHERING_MODE_ON,
1950 - DITHERING_MODE_STATIC2X2 = 0x18 | DITHERING_MODE_ON,
1951 - DITHERING_MODE_TEMPORAL = 0x20 | DITHERING_MODE_ON,
1952 - DITHERING_MODE_AUTO
1953 - } mode;
1954 - enum {
1955 - DITHERING_DEPTH_6BPC = 0x00,
1956 - DITHERING_DEPTH_8BPC = 0x02,
1957 - DITHERING_DEPTH_AUTO
1958 - } depth;
1959 - } dither;
1960 -
1961 - struct {
1962 - int mode; /* DRM_MODE_SCALE_* */
1963 - struct {
1964 - enum {
1965 - UNDERSCAN_OFF,
1966 - UNDERSCAN_ON,
1967 - UNDERSCAN_AUTO,
1968 - } mode;
1969 - u32 hborder;
1970 - u32 vborder;
1971 - } underscan;
1972 - bool full;
1973 - } scaler;
1974 -
1975 - struct {
1976 - int color_vibrance;
1977 - int vibrant_hue;
1978 - } procamp;
1979 -
1980 - union {
1981 - struct {
1982 - bool dither:1;
1983 - bool scaler:1;
1984 - bool procamp:1;
1985 - };
1986 - u8 mask;
1987 - } set;
1988 -};
1989 -
1990 void nouveau_conn_attach_properties(struct drm_connector *);
1991 void nouveau_conn_reset(struct drm_connector *);
1992 struct drm_connector_state *
1993 diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
1994 index eb8071a4d6d0..9c3bdfd20337 100644
1995 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
1996 +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
1997 @@ -683,8 +683,6 @@ static void sun4i_hdmi_unbind(struct device *dev, struct device *master,
1998 struct sun4i_hdmi *hdmi = dev_get_drvdata(dev);
1999
2000 cec_unregister_adapter(hdmi->cec_adap);
2001 - drm_connector_cleanup(&hdmi->connector);
2002 - drm_encoder_cleanup(&hdmi->encoder);
2003 i2c_del_adapter(hdmi->i2c);
2004 i2c_put_adapter(hdmi->ddc_i2c);
2005 clk_disable_unprepare(hdmi->mod_clk);
2006 diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
2007 index 7608ee053114..ac44bf752ff1 100644
2008 --- a/drivers/hid/i2c-hid/i2c-hid-core.c
2009 +++ b/drivers/hid/i2c-hid/i2c-hid-core.c
2010 @@ -48,6 +48,7 @@
2011 #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0)
2012 #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1)
2013 #define I2C_HID_QUIRK_BOGUS_IRQ BIT(4)
2014 +#define I2C_HID_QUIRK_RESET_ON_RESUME BIT(5)
2015
2016 /* flags */
2017 #define I2C_HID_STARTED 0
2018 @@ -174,6 +175,8 @@ static const struct i2c_hid_quirks {
2019 I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
2020 { USB_VENDOR_ID_ELAN, HID_ANY_ID,
2021 I2C_HID_QUIRK_BOGUS_IRQ },
2022 + { USB_VENDOR_ID_ALPS_JP, HID_ANY_ID,
2023 + I2C_HID_QUIRK_RESET_ON_RESUME },
2024 { 0, 0 }
2025 };
2026
2027 @@ -1214,8 +1217,15 @@ static int i2c_hid_resume(struct device *dev)
2028 * solves "incomplete reports" on Raydium devices 2386:3118 and
2029 * 2386:4B33 and fixes various SIS touchscreens no longer sending
2030 * data after a suspend/resume.
2031 + *
2032 + * However some ALPS touchpads generate IRQ storm without reset, so
2033 + * let's still reset them here.
2034 */
2035 - ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
2036 + if (ihid->quirks & I2C_HID_QUIRK_RESET_ON_RESUME)
2037 + ret = i2c_hid_hwreset(client);
2038 + else
2039 + ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
2040 +
2041 if (ret)
2042 return ret;
2043
2044 diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
2045 index 2e37f8a6d8cf..be661396095c 100644
2046 --- a/drivers/iio/accel/st_accel_core.c
2047 +++ b/drivers/iio/accel/st_accel_core.c
2048 @@ -993,6 +993,7 @@ static const struct iio_trigger_ops st_accel_trigger_ops = {
2049 #define ST_ACCEL_TRIGGER_OPS NULL
2050 #endif
2051
2052 +#ifdef CONFIG_ACPI
2053 static const struct iio_mount_matrix *
2054 get_mount_matrix(const struct iio_dev *indio_dev,
2055 const struct iio_chan_spec *chan)
2056 @@ -1013,7 +1014,6 @@ static const struct iio_chan_spec_ext_info mount_matrix_ext_info[] = {
2057 static int apply_acpi_orientation(struct iio_dev *indio_dev,
2058 struct iio_chan_spec *channels)
2059 {
2060 -#ifdef CONFIG_ACPI
2061 struct st_sensor_data *adata = iio_priv(indio_dev);
2062 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
2063 struct acpi_device *adev;
2064 @@ -1141,10 +1141,14 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev,
2065 out:
2066 kfree(buffer.pointer);
2067 return ret;
2068 +}
2069 #else /* !CONFIG_ACPI */
2070 +static int apply_acpi_orientation(struct iio_dev *indio_dev,
2071 + struct iio_chan_spec *channels)
2072 +{
2073 return 0;
2074 -#endif
2075 }
2076 +#endif
2077
2078 /*
2079 * st_accel_get_settings() - get sensor settings from device name
2080 diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
2081 index da073d72f649..e480529b3f04 100644
2082 --- a/drivers/iio/adc/max9611.c
2083 +++ b/drivers/iio/adc/max9611.c
2084 @@ -89,6 +89,12 @@
2085 #define MAX9611_TEMP_SCALE_NUM 1000000
2086 #define MAX9611_TEMP_SCALE_DIV 2083
2087
2088 +/*
2089 + * Conversion time is 2 ms (typically) at Ta=25 degreeC
2090 + * No maximum value is known, so play it safe.
2091 + */
2092 +#define MAX9611_CONV_TIME_US_RANGE 3000, 3300
2093 +
2094 struct max9611_dev {
2095 struct device *dev;
2096 struct i2c_client *i2c_client;
2097 @@ -236,11 +242,9 @@ static int max9611_read_single(struct max9611_dev *max9611,
2098 return ret;
2099 }
2100
2101 - /*
2102 - * need a delay here to make register configuration
2103 - * stabilize. 1 msec at least, from empirical testing.
2104 - */
2105 - usleep_range(1000, 2000);
2106 + /* need a delay here to make register configuration stabilize. */
2107 +
2108 + usleep_range(MAX9611_CONV_TIME_US_RANGE);
2109
2110 ret = i2c_smbus_read_word_swapped(max9611->i2c_client, reg_addr);
2111 if (ret < 0) {
2112 @@ -507,7 +511,7 @@ static int max9611_init(struct max9611_dev *max9611)
2113 MAX9611_REG_CTRL2, 0);
2114 return ret;
2115 }
2116 - usleep_range(1000, 2000);
2117 + usleep_range(MAX9611_CONV_TIME_US_RANGE);
2118
2119 return 0;
2120 }
2121 diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
2122 index d78f67623f24..50052e9a1731 100644
2123 --- a/drivers/infiniband/core/cma.c
2124 +++ b/drivers/infiniband/core/cma.c
2125 @@ -4736,6 +4736,7 @@ err_ib:
2126 err:
2127 unregister_netdevice_notifier(&cma_nb);
2128 ib_sa_unregister_client(&sa_client);
2129 + unregister_pernet_subsys(&cma_pernet_operations);
2130 err_wq:
2131 destroy_workqueue(cma_wq);
2132 return ret;
2133 diff --git a/drivers/infiniband/core/counters.c b/drivers/infiniband/core/counters.c
2134 index 680ad27f497d..023478107f0e 100644
2135 --- a/drivers/infiniband/core/counters.c
2136 +++ b/drivers/infiniband/core/counters.c
2137 @@ -282,6 +282,9 @@ int rdma_counter_bind_qp_auto(struct ib_qp *qp, u8 port)
2138 struct rdma_counter *counter;
2139 int ret;
2140
2141 + if (!qp->res.valid)
2142 + return 0;
2143 +
2144 if (!rdma_is_port_valid(dev, port))
2145 return -EINVAL;
2146
2147 diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
2148 index 8d2f1e38b891..907d99822bf0 100644
2149 --- a/drivers/infiniband/hw/mlx4/main.c
2150 +++ b/drivers/infiniband/hw/mlx4/main.c
2151 @@ -3008,16 +3008,17 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr)
2152 ibdev->ib_active = false;
2153 flush_workqueue(wq);
2154
2155 - mlx4_ib_close_sriov(ibdev);
2156 - mlx4_ib_mad_cleanup(ibdev);
2157 - ib_unregister_device(&ibdev->ib_dev);
2158 - mlx4_ib_diag_cleanup(ibdev);
2159 if (ibdev->iboe.nb.notifier_call) {
2160 if (unregister_netdevice_notifier(&ibdev->iboe.nb))
2161 pr_warn("failure unregistering notifier\n");
2162 ibdev->iboe.nb.notifier_call = NULL;
2163 }
2164
2165 + mlx4_ib_close_sriov(ibdev);
2166 + mlx4_ib_mad_cleanup(ibdev);
2167 + ib_unregister_device(&ibdev->ib_dev);
2168 + mlx4_ib_diag_cleanup(ibdev);
2169 +
2170 mlx4_qp_release_range(dev, ibdev->steer_qpn_base,
2171 ibdev->steer_qpn_count);
2172 kfree(ibdev->ib_uc_qpns_bitmap);
2173 diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
2174 index 831539419c30..e1cfbedefcbc 100644
2175 --- a/drivers/infiniband/hw/mlx5/main.c
2176 +++ b/drivers/infiniband/hw/mlx5/main.c
2177 @@ -3548,10 +3548,6 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
2178 }
2179
2180 INIT_LIST_HEAD(&handler->list);
2181 - if (dst) {
2182 - memcpy(&dest_arr[0], dst, sizeof(*dst));
2183 - dest_num++;
2184 - }
2185
2186 for (spec_index = 0; spec_index < flow_attr->num_of_specs; spec_index++) {
2187 err = parse_flow_attr(dev->mdev, spec,
2188 @@ -3564,6 +3560,11 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
2189 ib_flow += ((union ib_flow_spec *)ib_flow)->size;
2190 }
2191
2192 + if (dst && !(flow_act.action & MLX5_FLOW_CONTEXT_ACTION_DROP)) {
2193 + memcpy(&dest_arr[0], dst, sizeof(*dst));
2194 + dest_num++;
2195 + }
2196 +
2197 if (!flow_is_multicast_only(flow_attr))
2198 set_underlay_qp(dev, spec, underlay_qpn);
2199
2200 @@ -3604,10 +3605,8 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
2201 }
2202
2203 if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_DROP) {
2204 - if (!(flow_act.action & MLX5_FLOW_CONTEXT_ACTION_COUNT)) {
2205 + if (!dest_num)
2206 rule_dst = NULL;
2207 - dest_num = 0;
2208 - }
2209 } else {
2210 if (is_egress)
2211 flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_ALLOW;
2212 diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c
2213 index f9a492ed900b..831ad578a7b2 100644
2214 --- a/drivers/infiniband/sw/rxe/rxe_recv.c
2215 +++ b/drivers/infiniband/sw/rxe/rxe_recv.c
2216 @@ -389,7 +389,7 @@ void rxe_rcv(struct sk_buff *skb)
2217
2218 calc_icrc = rxe_icrc_hdr(pkt, skb);
2219 calc_icrc = rxe_crc32(rxe, calc_icrc, (u8 *)payload_addr(pkt),
2220 - payload_size(pkt));
2221 + payload_size(pkt) + bth_pad(pkt));
2222 calc_icrc = (__force u32)cpu_to_be32(~calc_icrc);
2223 if (unlikely(calc_icrc != pack_icrc)) {
2224 if (skb->protocol == htons(ETH_P_IPV6))
2225 diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c
2226 index c5d9b558fa90..e5031172c019 100644
2227 --- a/drivers/infiniband/sw/rxe/rxe_req.c
2228 +++ b/drivers/infiniband/sw/rxe/rxe_req.c
2229 @@ -500,6 +500,12 @@ static int fill_packet(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
2230 if (err)
2231 return err;
2232 }
2233 + if (bth_pad(pkt)) {
2234 + u8 *pad = payload_addr(pkt) + paylen;
2235 +
2236 + memset(pad, 0, bth_pad(pkt));
2237 + crc = rxe_crc32(rxe, crc, pad, bth_pad(pkt));
2238 + }
2239 }
2240 p = payload_addr(pkt) + paylen + bth_pad(pkt);
2241
2242 diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
2243 index 1cbfbd98eb22..c4a8195bf670 100644
2244 --- a/drivers/infiniband/sw/rxe/rxe_resp.c
2245 +++ b/drivers/infiniband/sw/rxe/rxe_resp.c
2246 @@ -732,6 +732,13 @@ static enum resp_states read_reply(struct rxe_qp *qp,
2247 if (err)
2248 pr_err("Failed copying memory\n");
2249
2250 + if (bth_pad(&ack_pkt)) {
2251 + struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
2252 + u8 *pad = payload_addr(&ack_pkt) + payload;
2253 +
2254 + memset(pad, 0, bth_pad(&ack_pkt));
2255 + icrc = rxe_crc32(rxe, icrc, pad, bth_pad(&ack_pkt));
2256 + }
2257 p = payload_addr(&ack_pkt) + payload + bth_pad(&ack_pkt);
2258 *p = ~icrc;
2259
2260 diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
2261 index 9b159132405d..dca88f9fdf29 100644
2262 --- a/drivers/iommu/intel-svm.c
2263 +++ b/drivers/iommu/intel-svm.c
2264 @@ -104,11 +104,7 @@ static void intel_flush_svm_range_dev (struct intel_svm *svm, struct intel_svm_d
2265 {
2266 struct qi_desc desc;
2267
2268 - /*
2269 - * Do PASID granu IOTLB invalidation if page selective capability is
2270 - * not available.
2271 - */
2272 - if (pages == -1 || !cap_pgsel_inv(svm->iommu->cap)) {
2273 + if (pages == -1) {
2274 desc.qw0 = QI_EIOTLB_PASID(svm->pasid) |
2275 QI_EIOTLB_DID(sdev->did) |
2276 QI_EIOTLB_GRAN(QI_GRAN_NONG_PASID) |
2277 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
2278 index bb29aeefcbd0..c7137f50bd1d 100644
2279 --- a/drivers/md/raid1.c
2280 +++ b/drivers/md/raid1.c
2281 @@ -2781,7 +2781,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
2282 write_targets++;
2283 }
2284 }
2285 - if (bio->bi_end_io) {
2286 + if (rdev && bio->bi_end_io) {
2287 atomic_inc(&rdev->nr_pending);
2288 bio->bi_iter.bi_sector = sector_nr + rdev->data_offset;
2289 bio_set_dev(bio, rdev->bdev);
2290 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
2291 index 12a8ce83786e..36cd7c2fbf40 100644
2292 --- a/drivers/md/raid5.c
2293 +++ b/drivers/md/raid5.c
2294 @@ -5726,7 +5726,7 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
2295 do_flush = false;
2296 }
2297
2298 - if (!sh->batch_head)
2299 + if (!sh->batch_head || sh == sh->batch_head)
2300 set_bit(STRIPE_HANDLE, &sh->state);
2301 clear_bit(STRIPE_DELAYED, &sh->state);
2302 if ((!sh->batch_head || sh == sh->batch_head) &&
2303 diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c
2304 index 5ef7daeb8cbd..b14c09cd9593 100644
2305 --- a/drivers/media/cec/cec-adap.c
2306 +++ b/drivers/media/cec/cec-adap.c
2307 @@ -378,7 +378,8 @@ static void cec_data_cancel(struct cec_data *data, u8 tx_status)
2308 } else {
2309 list_del_init(&data->list);
2310 if (!(data->msg.tx_status & CEC_TX_STATUS_OK))
2311 - data->adap->transmit_queue_sz--;
2312 + if (!WARN_ON(!data->adap->transmit_queue_sz))
2313 + data->adap->transmit_queue_sz--;
2314 }
2315
2316 if (data->msg.tx_status & CEC_TX_STATUS_OK) {
2317 @@ -430,6 +431,14 @@ static void cec_flush(struct cec_adapter *adap)
2318 * need to do anything special in that case.
2319 */
2320 }
2321 + /*
2322 + * If something went wrong and this counter isn't what it should
2323 + * be, then this will reset it back to 0. Warn if it is not 0,
2324 + * since it indicates a bug, either in this framework or in a
2325 + * CEC driver.
2326 + */
2327 + if (WARN_ON(adap->transmit_queue_sz))
2328 + adap->transmit_queue_sz = 0;
2329 }
2330
2331 /*
2332 @@ -454,7 +463,7 @@ int cec_thread_func(void *_adap)
2333 bool timeout = false;
2334 u8 attempts;
2335
2336 - if (adap->transmitting) {
2337 + if (adap->transmit_in_progress) {
2338 int err;
2339
2340 /*
2341 @@ -489,7 +498,7 @@ int cec_thread_func(void *_adap)
2342 goto unlock;
2343 }
2344
2345 - if (adap->transmitting && timeout) {
2346 + if (adap->transmit_in_progress && timeout) {
2347 /*
2348 * If we timeout, then log that. Normally this does
2349 * not happen and it is an indication of a faulty CEC
2350 @@ -498,14 +507,18 @@ int cec_thread_func(void *_adap)
2351 * so much traffic on the bus that the adapter was
2352 * unable to transmit for CEC_XFER_TIMEOUT_MS (2.1s).
2353 */
2354 - pr_warn("cec-%s: message %*ph timed out\n", adap->name,
2355 - adap->transmitting->msg.len,
2356 - adap->transmitting->msg.msg);
2357 + if (adap->transmitting) {
2358 + pr_warn("cec-%s: message %*ph timed out\n", adap->name,
2359 + adap->transmitting->msg.len,
2360 + adap->transmitting->msg.msg);
2361 + /* Just give up on this. */
2362 + cec_data_cancel(adap->transmitting,
2363 + CEC_TX_STATUS_TIMEOUT);
2364 + } else {
2365 + pr_warn("cec-%s: transmit timed out\n", adap->name);
2366 + }
2367 adap->transmit_in_progress = false;
2368 adap->tx_timeouts++;
2369 - /* Just give up on this. */
2370 - cec_data_cancel(adap->transmitting,
2371 - CEC_TX_STATUS_TIMEOUT);
2372 goto unlock;
2373 }
2374
2375 @@ -520,7 +533,8 @@ int cec_thread_func(void *_adap)
2376 data = list_first_entry(&adap->transmit_queue,
2377 struct cec_data, list);
2378 list_del_init(&data->list);
2379 - adap->transmit_queue_sz--;
2380 + if (!WARN_ON(!data->adap->transmit_queue_sz))
2381 + adap->transmit_queue_sz--;
2382
2383 /* Make this the current transmitting message */
2384 adap->transmitting = data;
2385 @@ -1083,11 +1097,11 @@ void cec_received_msg_ts(struct cec_adapter *adap,
2386 valid_la = false;
2387 else if (!cec_msg_is_broadcast(msg) && !(dir_fl & DIRECTED))
2388 valid_la = false;
2389 - else if (cec_msg_is_broadcast(msg) && !(dir_fl & BCAST1_4))
2390 + else if (cec_msg_is_broadcast(msg) && !(dir_fl & BCAST))
2391 valid_la = false;
2392 else if (cec_msg_is_broadcast(msg) &&
2393 - adap->log_addrs.cec_version >= CEC_OP_CEC_VERSION_2_0 &&
2394 - !(dir_fl & BCAST2_0))
2395 + adap->log_addrs.cec_version < CEC_OP_CEC_VERSION_2_0 &&
2396 + !(dir_fl & BCAST1_4))
2397 valid_la = false;
2398 }
2399 if (valid_la && min_len) {
2400 diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c
2401 index d1331f828108..039963a7765b 100644
2402 --- a/drivers/media/usb/b2c2/flexcop-usb.c
2403 +++ b/drivers/media/usb/b2c2/flexcop-usb.c
2404 @@ -295,7 +295,7 @@ static int flexcop_usb_i2c_req(struct flexcop_i2c_adapter *i2c,
2405
2406 mutex_unlock(&fc_usb->data_mutex);
2407
2408 - return 0;
2409 + return ret;
2410 }
2411
2412 /* actual bus specific access functions,
2413 diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c
2414 index 02697d86e8c1..ac93e88d7038 100644
2415 --- a/drivers/media/usb/dvb-usb/af9005.c
2416 +++ b/drivers/media/usb/dvb-usb/af9005.c
2417 @@ -976,8 +976,9 @@ static int af9005_identify_state(struct usb_device *udev,
2418 else if (reply == 0x02)
2419 *cold = 0;
2420 else
2421 - return -EIO;
2422 - deb_info("Identify state cold = %d\n", *cold);
2423 + ret = -EIO;
2424 + if (!ret)
2425 + deb_info("Identify state cold = %d\n", *cold);
2426
2427 err:
2428 kfree(buf);
2429 diff --git a/drivers/media/usb/pulse8-cec/pulse8-cec.c b/drivers/media/usb/pulse8-cec/pulse8-cec.c
2430 index ac88ade94cda..59609556d969 100644
2431 --- a/drivers/media/usb/pulse8-cec/pulse8-cec.c
2432 +++ b/drivers/media/usb/pulse8-cec/pulse8-cec.c
2433 @@ -116,6 +116,7 @@ struct pulse8 {
2434 unsigned int vers;
2435 struct completion cmd_done;
2436 struct work_struct work;
2437 + u8 work_result;
2438 struct delayed_work ping_eeprom_work;
2439 struct cec_msg rx_msg;
2440 u8 data[DATA_SIZE];
2441 @@ -137,8 +138,10 @@ static void pulse8_irq_work_handler(struct work_struct *work)
2442 {
2443 struct pulse8 *pulse8 =
2444 container_of(work, struct pulse8, work);
2445 + u8 result = pulse8->work_result;
2446
2447 - switch (pulse8->data[0] & 0x3f) {
2448 + pulse8->work_result = 0;
2449 + switch (result & 0x3f) {
2450 case MSGCODE_FRAME_DATA:
2451 cec_received_msg(pulse8->adap, &pulse8->rx_msg);
2452 break;
2453 @@ -172,12 +175,12 @@ static irqreturn_t pulse8_interrupt(struct serio *serio, unsigned char data,
2454 pulse8->escape = false;
2455 } else if (data == MSGEND) {
2456 struct cec_msg *msg = &pulse8->rx_msg;
2457 + u8 msgcode = pulse8->buf[0];
2458
2459 if (debug)
2460 dev_info(pulse8->dev, "received: %*ph\n",
2461 pulse8->idx, pulse8->buf);
2462 - pulse8->data[0] = pulse8->buf[0];
2463 - switch (pulse8->buf[0] & 0x3f) {
2464 + switch (msgcode & 0x3f) {
2465 case MSGCODE_FRAME_START:
2466 msg->len = 1;
2467 msg->msg[0] = pulse8->buf[1];
2468 @@ -186,14 +189,20 @@ static irqreturn_t pulse8_interrupt(struct serio *serio, unsigned char data,
2469 if (msg->len == CEC_MAX_MSG_SIZE)
2470 break;
2471 msg->msg[msg->len++] = pulse8->buf[1];
2472 - if (pulse8->buf[0] & MSGCODE_FRAME_EOM)
2473 + if (msgcode & MSGCODE_FRAME_EOM) {
2474 + WARN_ON(pulse8->work_result);
2475 + pulse8->work_result = msgcode;
2476 schedule_work(&pulse8->work);
2477 + break;
2478 + }
2479 break;
2480 case MSGCODE_TRANSMIT_SUCCEEDED:
2481 case MSGCODE_TRANSMIT_FAILED_LINE:
2482 case MSGCODE_TRANSMIT_FAILED_ACK:
2483 case MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA:
2484 case MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE:
2485 + WARN_ON(pulse8->work_result);
2486 + pulse8->work_result = msgcode;
2487 schedule_work(&pulse8->work);
2488 break;
2489 case MSGCODE_HIGH_ERROR:
2490 diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
2491 index 4e8e80ac8341..9cec5c216e1f 100644
2492 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
2493 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
2494 @@ -973,6 +973,8 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
2495 struct ath_htc_rx_status *rxstatus;
2496 struct ath_rx_status rx_stats;
2497 bool decrypt_error = false;
2498 + __be16 rs_datalen;
2499 + bool is_phyerr;
2500
2501 if (skb->len < HTC_RX_FRAME_HEADER_SIZE) {
2502 ath_err(common, "Corrupted RX frame, dropping (len: %d)\n",
2503 @@ -982,11 +984,24 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
2504
2505 rxstatus = (struct ath_htc_rx_status *)skb->data;
2506
2507 - if (be16_to_cpu(rxstatus->rs_datalen) -
2508 - (skb->len - HTC_RX_FRAME_HEADER_SIZE) != 0) {
2509 + rs_datalen = be16_to_cpu(rxstatus->rs_datalen);
2510 + if (unlikely(rs_datalen -
2511 + (skb->len - HTC_RX_FRAME_HEADER_SIZE) != 0)) {
2512 ath_err(common,
2513 "Corrupted RX data len, dropping (dlen: %d, skblen: %d)\n",
2514 - rxstatus->rs_datalen, skb->len);
2515 + rs_datalen, skb->len);
2516 + goto rx_next;
2517 + }
2518 +
2519 + is_phyerr = rxstatus->rs_status & ATH9K_RXERR_PHY;
2520 + /*
2521 + * Discard zero-length packets and packets smaller than an ACK
2522 + * which are not PHY_ERROR (short radar pulses have a length of 3)
2523 + */
2524 + if (unlikely(!rs_datalen || (rs_datalen < 10 && !is_phyerr))) {
2525 + ath_warn(common,
2526 + "Short RX data len, dropping (dlen: %d)\n",
2527 + rs_datalen);
2528 goto rx_next;
2529 }
2530
2531 @@ -1011,7 +1026,7 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
2532 * Process PHY errors and return so that the packet
2533 * can be dropped.
2534 */
2535 - if (rx_stats.rs_status & ATH9K_RXERR_PHY) {
2536 + if (unlikely(is_phyerr)) {
2537 /* TODO: Not using DFS processing now. */
2538 if (ath_cmn_process_fft(&priv->spec_priv, hdr,
2539 &rx_stats, rx_status->mactime)) {
2540 diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
2541 index 265f89e11d8b..59474bd0c728 100644
2542 --- a/drivers/nvme/host/fc.c
2543 +++ b/drivers/nvme/host/fc.c
2544 @@ -342,7 +342,8 @@ nvme_fc_register_localport(struct nvme_fc_port_info *pinfo,
2545 !template->ls_req || !template->fcp_io ||
2546 !template->ls_abort || !template->fcp_abort ||
2547 !template->max_hw_queues || !template->max_sgl_segments ||
2548 - !template->max_dif_sgl_segments || !template->dma_boundary) {
2549 + !template->max_dif_sgl_segments || !template->dma_boundary ||
2550 + !template->module) {
2551 ret = -EINVAL;
2552 goto out_reghost_failed;
2553 }
2554 @@ -2015,6 +2016,7 @@ nvme_fc_ctrl_free(struct kref *ref)
2555 {
2556 struct nvme_fc_ctrl *ctrl =
2557 container_of(ref, struct nvme_fc_ctrl, ref);
2558 + struct nvme_fc_lport *lport = ctrl->lport;
2559 unsigned long flags;
2560
2561 if (ctrl->ctrl.tagset) {
2562 @@ -2041,6 +2043,7 @@ nvme_fc_ctrl_free(struct kref *ref)
2563 if (ctrl->ctrl.opts)
2564 nvmf_free_options(ctrl->ctrl.opts);
2565 kfree(ctrl);
2566 + module_put(lport->ops->module);
2567 }
2568
2569 static void
2570 @@ -2907,10 +2910,22 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)
2571 static void
2572 __nvme_fc_terminate_io(struct nvme_fc_ctrl *ctrl)
2573 {
2574 - nvme_stop_keep_alive(&ctrl->ctrl);
2575 + /*
2576 + * if state is connecting - the error occurred as part of a
2577 + * reconnect attempt. The create_association error paths will
2578 + * clean up any outstanding io.
2579 + *
2580 + * if it's a different state - ensure all pending io is
2581 + * terminated. Given this can delay while waiting for the
2582 + * aborted io to return, we recheck adapter state below
2583 + * before changing state.
2584 + */
2585 + if (ctrl->ctrl.state != NVME_CTRL_CONNECTING) {
2586 + nvme_stop_keep_alive(&ctrl->ctrl);
2587
2588 - /* will block will waiting for io to terminate */
2589 - nvme_fc_delete_association(ctrl);
2590 + /* will block will waiting for io to terminate */
2591 + nvme_fc_delete_association(ctrl);
2592 + }
2593
2594 if (ctrl->ctrl.state != NVME_CTRL_CONNECTING &&
2595 !nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING))
2596 @@ -3056,10 +3071,15 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
2597 goto out_fail;
2598 }
2599
2600 + if (!try_module_get(lport->ops->module)) {
2601 + ret = -EUNATCH;
2602 + goto out_free_ctrl;
2603 + }
2604 +
2605 idx = ida_simple_get(&nvme_fc_ctrl_cnt, 0, 0, GFP_KERNEL);
2606 if (idx < 0) {
2607 ret = -ENOSPC;
2608 - goto out_free_ctrl;
2609 + goto out_mod_put;
2610 }
2611
2612 ctrl->ctrl.opts = opts;
2613 @@ -3212,6 +3232,8 @@ out_free_queues:
2614 out_free_ida:
2615 put_device(ctrl->dev);
2616 ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum);
2617 +out_mod_put:
2618 + module_put(lport->ops->module);
2619 out_free_ctrl:
2620 kfree(ctrl);
2621 out_fail:
2622 diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
2623 index 869f462e6b6e..14d513087a14 100644
2624 --- a/drivers/nvme/host/pci.c
2625 +++ b/drivers/nvme/host/pci.c
2626 @@ -68,14 +68,14 @@ static int io_queue_depth = 1024;
2627 module_param_cb(io_queue_depth, &io_queue_depth_ops, &io_queue_depth, 0644);
2628 MODULE_PARM_DESC(io_queue_depth, "set io queue depth, should >= 2");
2629
2630 -static int write_queues;
2631 -module_param(write_queues, int, 0644);
2632 +static unsigned int write_queues;
2633 +module_param(write_queues, uint, 0644);
2634 MODULE_PARM_DESC(write_queues,
2635 "Number of queues to use for writes. If not set, reads and writes "
2636 "will share a queue set.");
2637
2638 -static int poll_queues;
2639 -module_param(poll_queues, int, 0644);
2640 +static unsigned int poll_queues;
2641 +module_param(poll_queues, uint, 0644);
2642 MODULE_PARM_DESC(poll_queues, "Number of queues to use for polled IO.");
2643
2644 struct nvme_dev;
2645 @@ -2060,7 +2060,6 @@ static int nvme_setup_irqs(struct nvme_dev *dev, unsigned int nr_io_queues)
2646 .priv = dev,
2647 };
2648 unsigned int irq_queues, this_p_queues;
2649 - unsigned int nr_cpus = num_possible_cpus();
2650
2651 /*
2652 * Poll queues don't need interrupts, but we need at least one IO
2653 @@ -2071,10 +2070,7 @@ static int nvme_setup_irqs(struct nvme_dev *dev, unsigned int nr_io_queues)
2654 this_p_queues = nr_io_queues - 1;
2655 irq_queues = 1;
2656 } else {
2657 - if (nr_cpus < nr_io_queues - this_p_queues)
2658 - irq_queues = nr_cpus + 1;
2659 - else
2660 - irq_queues = nr_io_queues - this_p_queues + 1;
2661 + irq_queues = nr_io_queues - this_p_queues + 1;
2662 }
2663 dev->io_queues[HCTX_TYPE_POLL] = this_p_queues;
2664
2665 diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
2666 index b50b53db3746..1c50af6219f3 100644
2667 --- a/drivers/nvme/target/fcloop.c
2668 +++ b/drivers/nvme/target/fcloop.c
2669 @@ -850,6 +850,7 @@ fcloop_targetport_delete(struct nvmet_fc_target_port *targetport)
2670 #define FCLOOP_DMABOUND_4G 0xFFFFFFFF
2671
2672 static struct nvme_fc_port_template fctemplate = {
2673 + .module = THIS_MODULE,
2674 .localport_delete = fcloop_localport_delete,
2675 .remoteport_delete = fcloop_remoteport_delete,
2676 .create_queue = fcloop_create_queue,
2677 diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
2678 index c423e94baf0f..9617b7df7c4d 100644
2679 --- a/drivers/of/overlay.c
2680 +++ b/drivers/of/overlay.c
2681 @@ -305,7 +305,6 @@ static int add_changeset_property(struct overlay_changeset *ovcs,
2682 {
2683 struct property *new_prop = NULL, *prop;
2684 int ret = 0;
2685 - bool check_for_non_overlay_node = false;
2686
2687 if (target->in_livetree)
2688 if (!of_prop_cmp(overlay_prop->name, "name") ||
2689 @@ -318,6 +317,25 @@ static int add_changeset_property(struct overlay_changeset *ovcs,
2690 else
2691 prop = NULL;
2692
2693 + if (prop) {
2694 + if (!of_prop_cmp(prop->name, "#address-cells")) {
2695 + if (!of_prop_val_eq(prop, overlay_prop)) {
2696 + pr_err("ERROR: changing value of #address-cells is not allowed in %pOF\n",
2697 + target->np);
2698 + ret = -EINVAL;
2699 + }
2700 + return ret;
2701 +
2702 + } else if (!of_prop_cmp(prop->name, "#size-cells")) {
2703 + if (!of_prop_val_eq(prop, overlay_prop)) {
2704 + pr_err("ERROR: changing value of #size-cells is not allowed in %pOF\n",
2705 + target->np);
2706 + ret = -EINVAL;
2707 + }
2708 + return ret;
2709 + }
2710 + }
2711 +
2712 if (is_symbols_prop) {
2713 if (prop)
2714 return -EINVAL;
2715 @@ -330,33 +348,18 @@ static int add_changeset_property(struct overlay_changeset *ovcs,
2716 return -ENOMEM;
2717
2718 if (!prop) {
2719 - check_for_non_overlay_node = true;
2720 if (!target->in_livetree) {
2721 new_prop->next = target->np->deadprops;
2722 target->np->deadprops = new_prop;
2723 }
2724 ret = of_changeset_add_property(&ovcs->cset, target->np,
2725 new_prop);
2726 - } else if (!of_prop_cmp(prop->name, "#address-cells")) {
2727 - if (!of_prop_val_eq(prop, new_prop)) {
2728 - pr_err("ERROR: changing value of #address-cells is not allowed in %pOF\n",
2729 - target->np);
2730 - ret = -EINVAL;
2731 - }
2732 - } else if (!of_prop_cmp(prop->name, "#size-cells")) {
2733 - if (!of_prop_val_eq(prop, new_prop)) {
2734 - pr_err("ERROR: changing value of #size-cells is not allowed in %pOF\n",
2735 - target->np);
2736 - ret = -EINVAL;
2737 - }
2738 } else {
2739 - check_for_non_overlay_node = true;
2740 ret = of_changeset_update_property(&ovcs->cset, target->np,
2741 new_prop);
2742 }
2743
2744 - if (check_for_non_overlay_node &&
2745 - !of_node_check_flag(target->np, OF_OVERLAY))
2746 + if (!of_node_check_flag(target->np, OF_OVERLAY))
2747 pr_err("WARNING: memory leak will occur if overlay removed, property: %pOF/%s\n",
2748 target->np, new_prop->name);
2749
2750 diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
2751 index a97e2571a527..fcfaadc774ee 100644
2752 --- a/drivers/pci/pci.c
2753 +++ b/drivers/pci/pci.c
2754 @@ -5854,6 +5854,24 @@ int pci_set_vga_state(struct pci_dev *dev, bool decode,
2755 return 0;
2756 }
2757
2758 +#ifdef CONFIG_ACPI
2759 +bool pci_pr3_present(struct pci_dev *pdev)
2760 +{
2761 + struct acpi_device *adev;
2762 +
2763 + if (acpi_disabled)
2764 + return false;
2765 +
2766 + adev = ACPI_COMPANION(&pdev->dev);
2767 + if (!adev)
2768 + return false;
2769 +
2770 + return adev->power.flags.power_resources &&
2771 + acpi_has_method(adev->handle, "_PR3");
2772 +}
2773 +EXPORT_SYMBOL_GPL(pci_pr3_present);
2774 +#endif
2775 +
2776 /**
2777 * pci_add_dma_alias - Add a DMA devfn alias for a device
2778 * @dev: the PCI device for which alias is added
2779 diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
2780 index 6fd1390fd06e..bfb22f868857 100644
2781 --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
2782 +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
2783 @@ -615,7 +615,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
2784 return PTR_ERR(channel->base);
2785
2786 /* call request_irq for OTG */
2787 - irq = platform_get_irq(pdev, 0);
2788 + irq = platform_get_irq_optional(pdev, 0);
2789 if (irq >= 0) {
2790 INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work);
2791 irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq,
2792 diff --git a/drivers/platform/x86/pmc_atom.c b/drivers/platform/x86/pmc_atom.c
2793 index 07d1b911e72f..52ef1419b671 100644
2794 --- a/drivers/platform/x86/pmc_atom.c
2795 +++ b/drivers/platform/x86/pmc_atom.c
2796 @@ -429,6 +429,14 @@ static const struct dmi_system_id critclk_systems[] = {
2797 DMI_MATCH(DMI_PRODUCT_VERSION, "6AV7882-0"),
2798 },
2799 },
2800 + {
2801 + .ident = "CONNECT X300",
2802 + .matches = {
2803 + DMI_MATCH(DMI_SYS_VENDOR, "SIEMENS AG"),
2804 + DMI_MATCH(DMI_PRODUCT_VERSION, "A5E45074588"),
2805 + },
2806 + },
2807 +
2808 { /*sentinel*/ }
2809 };
2810
2811 diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
2812 index efb2f01a9101..f60e1b26c2d2 100644
2813 --- a/drivers/regulator/ab8500.c
2814 +++ b/drivers/regulator/ab8500.c
2815 @@ -953,23 +953,6 @@ static struct ab8500_regulator_info
2816 .update_val_idle = 0x82,
2817 .update_val_normal = 0x02,
2818 },
2819 - [AB8505_LDO_USB] = {
2820 - .desc = {
2821 - .name = "LDO-USB",
2822 - .ops = &ab8500_regulator_mode_ops,
2823 - .type = REGULATOR_VOLTAGE,
2824 - .id = AB8505_LDO_USB,
2825 - .owner = THIS_MODULE,
2826 - .n_voltages = 1,
2827 - .volt_table = fixed_3300000_voltage,
2828 - },
2829 - .update_bank = 0x03,
2830 - .update_reg = 0x82,
2831 - .update_mask = 0x03,
2832 - .update_val = 0x01,
2833 - .update_val_idle = 0x03,
2834 - .update_val_normal = 0x01,
2835 - },
2836 [AB8505_LDO_AUDIO] = {
2837 .desc = {
2838 .name = "LDO-AUDIO",
2839 diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
2840 index 989506bd90b1..16f0c8570036 100644
2841 --- a/drivers/regulator/axp20x-regulator.c
2842 +++ b/drivers/regulator/axp20x-regulator.c
2843 @@ -413,10 +413,13 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
2844 int i;
2845
2846 for (i = 0; i < rate_count; i++) {
2847 - if (ramp <= slew_rates[i])
2848 - cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i);
2849 - else
2850 + if (ramp > slew_rates[i])
2851 break;
2852 +
2853 + if (id == AXP20X_DCDC2)
2854 + cfg = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE(i);
2855 + else
2856 + cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i);
2857 }
2858
2859 if (cfg == 0xff) {
2860 @@ -605,7 +608,7 @@ static const struct regulator_desc axp22x_regulators[] = {
2861 AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK),
2862 AXP_DESC(AXP22X, ELDO2, "eldo2", "eldoin", 700, 3300, 100,
2863 AXP22X_ELDO2_V_OUT, AXP22X_ELDO2_V_OUT_MASK,
2864 - AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK),
2865 + AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO2_MASK),
2866 AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100,
2867 AXP22X_ELDO3_V_OUT, AXP22X_ELDO3_V_OUT_MASK,
2868 AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO3_MASK),
2869 diff --git a/drivers/regulator/bd70528-regulator.c b/drivers/regulator/bd70528-regulator.c
2870 index 0248a61f1006..6041839ec38c 100644
2871 --- a/drivers/regulator/bd70528-regulator.c
2872 +++ b/drivers/regulator/bd70528-regulator.c
2873 @@ -101,7 +101,6 @@ static const struct regulator_ops bd70528_ldo_ops = {
2874 .set_voltage_sel = regulator_set_voltage_sel_regmap,
2875 .get_voltage_sel = regulator_get_voltage_sel_regmap,
2876 .set_voltage_time_sel = regulator_set_voltage_time_sel,
2877 - .set_ramp_delay = bd70528_set_ramp_delay,
2878 };
2879
2880 static const struct regulator_ops bd70528_led_ops = {
2881 diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
2882 index f47b4b281b14..d7302c2052f9 100644
2883 --- a/drivers/scsi/libsas/sas_discover.c
2884 +++ b/drivers/scsi/libsas/sas_discover.c
2885 @@ -81,12 +81,21 @@ static int sas_get_port_device(struct asd_sas_port *port)
2886 else
2887 dev->dev_type = SAS_SATA_DEV;
2888 dev->tproto = SAS_PROTOCOL_SATA;
2889 - } else {
2890 + } else if (port->oob_mode == SAS_OOB_MODE) {
2891 struct sas_identify_frame *id =
2892 (struct sas_identify_frame *) dev->frame_rcvd;
2893 dev->dev_type = id->dev_type;
2894 dev->iproto = id->initiator_bits;
2895 dev->tproto = id->target_bits;
2896 + } else {
2897 + /* If the oob mode is OOB_NOT_CONNECTED, the port is
2898 + * disconnected due to race with PHY down. We cannot
2899 + * continue to discover this port
2900 + */
2901 + sas_put_device(dev);
2902 + pr_warn("Port %016llx is disconnected when discovering\n",
2903 + SAS_ADDR(port->attached_sas_addr));
2904 + return -ENODEV;
2905 }
2906
2907 sas_init_dev(dev);
2908 diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
2909 index 39a736b887b1..6c2b03415a2c 100644
2910 --- a/drivers/scsi/lpfc/lpfc_bsg.c
2911 +++ b/drivers/scsi/lpfc/lpfc_bsg.c
2912 @@ -4489,12 +4489,6 @@ lpfc_bsg_write_ebuf_set(struct lpfc_hba *phba, struct bsg_job *job,
2913 phba->mbox_ext_buf_ctx.seqNum++;
2914 nemb_tp = phba->mbox_ext_buf_ctx.nembType;
2915
2916 - dd_data = kmalloc(sizeof(struct bsg_job_data), GFP_KERNEL);
2917 - if (!dd_data) {
2918 - rc = -ENOMEM;
2919 - goto job_error;
2920 - }
2921 -
2922 pbuf = (uint8_t *)dmabuf->virt;
2923 size = job->request_payload.payload_len;
2924 sg_copy_to_buffer(job->request_payload.sg_list,
2925 @@ -4531,6 +4525,13 @@ lpfc_bsg_write_ebuf_set(struct lpfc_hba *phba, struct bsg_job *job,
2926 "2968 SLI_CONFIG ext-buffer wr all %d "
2927 "ebuffers received\n",
2928 phba->mbox_ext_buf_ctx.numBuf);
2929 +
2930 + dd_data = kmalloc(sizeof(struct bsg_job_data), GFP_KERNEL);
2931 + if (!dd_data) {
2932 + rc = -ENOMEM;
2933 + goto job_error;
2934 + }
2935 +
2936 /* mailbox command structure for base driver */
2937 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
2938 if (!pmboxq) {
2939 @@ -4579,6 +4580,8 @@ lpfc_bsg_write_ebuf_set(struct lpfc_hba *phba, struct bsg_job *job,
2940 return SLI_CONFIG_HANDLED;
2941
2942 job_error:
2943 + if (pmboxq)
2944 + mempool_free(pmboxq, phba->mbox_mem_pool);
2945 lpfc_bsg_dma_page_free(phba, dmabuf);
2946 kfree(dd_data);
2947
2948 diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
2949 index 1286c658ba34..ee70d14e7a9d 100644
2950 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c
2951 +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
2952 @@ -4843,6 +4843,44 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
2953 }
2954 }
2955
2956 +/*
2957 + * Sets the mailbox completion handler to be used for the
2958 + * unreg_rpi command. The handler varies based on the state of
2959 + * the port and what will be happening to the rpi next.
2960 + */
2961 +static void
2962 +lpfc_set_unreg_login_mbx_cmpl(struct lpfc_hba *phba, struct lpfc_vport *vport,
2963 + struct lpfc_nodelist *ndlp, LPFC_MBOXQ_t *mbox)
2964 +{
2965 + unsigned long iflags;
2966 +
2967 + if (ndlp->nlp_flag & NLP_ISSUE_LOGO) {
2968 + mbox->ctx_ndlp = ndlp;
2969 + mbox->mbox_cmpl = lpfc_nlp_logo_unreg;
2970 +
2971 + } else if (phba->sli_rev == LPFC_SLI_REV4 &&
2972 + (!(vport->load_flag & FC_UNLOADING)) &&
2973 + (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >=
2974 + LPFC_SLI_INTF_IF_TYPE_2) &&
2975 + (kref_read(&ndlp->kref) > 0)) {
2976 + mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
2977 + mbox->mbox_cmpl = lpfc_sli4_unreg_rpi_cmpl_clr;
2978 + } else {
2979 + if (vport->load_flag & FC_UNLOADING) {
2980 + if (phba->sli_rev == LPFC_SLI_REV4) {
2981 + spin_lock_irqsave(&vport->phba->ndlp_lock,
2982 + iflags);
2983 + ndlp->nlp_flag |= NLP_RELEASE_RPI;
2984 + spin_unlock_irqrestore(&vport->phba->ndlp_lock,
2985 + iflags);
2986 + }
2987 + lpfc_nlp_get(ndlp);
2988 + }
2989 + mbox->ctx_ndlp = ndlp;
2990 + mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
2991 + }
2992 +}
2993 +
2994 /*
2995 * Free rpi associated with LPFC_NODELIST entry.
2996 * This routine is called from lpfc_freenode(), when we are removing
2997 @@ -4893,33 +4931,12 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
2998
2999 lpfc_unreg_login(phba, vport->vpi, rpi, mbox);
3000 mbox->vport = vport;
3001 - if (ndlp->nlp_flag & NLP_ISSUE_LOGO) {
3002 - mbox->ctx_ndlp = ndlp;
3003 - mbox->mbox_cmpl = lpfc_nlp_logo_unreg;
3004 - } else {
3005 - if (phba->sli_rev == LPFC_SLI_REV4 &&
3006 - (!(vport->load_flag & FC_UNLOADING)) &&
3007 - (bf_get(lpfc_sli_intf_if_type,
3008 - &phba->sli4_hba.sli_intf) >=
3009 - LPFC_SLI_INTF_IF_TYPE_2) &&
3010 - (kref_read(&ndlp->kref) > 0)) {
3011 - mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
3012 - mbox->mbox_cmpl =
3013 - lpfc_sli4_unreg_rpi_cmpl_clr;
3014 - /*
3015 - * accept PLOGIs after unreg_rpi_cmpl
3016 - */
3017 - acc_plogi = 0;
3018 - } else if (vport->load_flag & FC_UNLOADING) {
3019 - mbox->ctx_ndlp = NULL;
3020 - mbox->mbox_cmpl =
3021 - lpfc_sli_def_mbox_cmpl;
3022 - } else {
3023 - mbox->ctx_ndlp = ndlp;
3024 - mbox->mbox_cmpl =
3025 - lpfc_sli_def_mbox_cmpl;
3026 - }
3027 - }
3028 + lpfc_set_unreg_login_mbx_cmpl(phba, vport, ndlp, mbox);
3029 + if (mbox->mbox_cmpl == lpfc_sli4_unreg_rpi_cmpl_clr)
3030 + /*
3031 + * accept PLOGIs after unreg_rpi_cmpl
3032 + */
3033 + acc_plogi = 0;
3034 if (((ndlp->nlp_DID & Fabric_DID_MASK) !=
3035 Fabric_DID_MASK) &&
3036 (!(vport->fc_flag & FC_OFFLINE_MODE)))
3037 @@ -5060,6 +5077,7 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
3038 struct lpfc_hba *phba = vport->phba;
3039 LPFC_MBOXQ_t *mb, *nextmb;
3040 struct lpfc_dmabuf *mp;
3041 + unsigned long iflags;
3042
3043 /* Cleanup node for NPort <nlp_DID> */
3044 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
3045 @@ -5141,8 +5159,20 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
3046 lpfc_cleanup_vports_rrqs(vport, ndlp);
3047 if (phba->sli_rev == LPFC_SLI_REV4)
3048 ndlp->nlp_flag |= NLP_RELEASE_RPI;
3049 - lpfc_unreg_rpi(vport, ndlp);
3050 -
3051 + if (!lpfc_unreg_rpi(vport, ndlp)) {
3052 + /* Clean up unregistered and non freed rpis */
3053 + if ((ndlp->nlp_flag & NLP_RELEASE_RPI) &&
3054 + !(ndlp->nlp_rpi == LPFC_RPI_ALLOC_ERROR)) {
3055 + lpfc_sli4_free_rpi(vport->phba,
3056 + ndlp->nlp_rpi);
3057 + spin_lock_irqsave(&vport->phba->ndlp_lock,
3058 + iflags);
3059 + ndlp->nlp_flag &= ~NLP_RELEASE_RPI;
3060 + ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR;
3061 + spin_unlock_irqrestore(&vport->phba->ndlp_lock,
3062 + iflags);
3063 + }
3064 + }
3065 return 0;
3066 }
3067
3068 diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
3069 index a227e36cbdc2..8e0f03ef346b 100644
3070 --- a/drivers/scsi/lpfc/lpfc_nvme.c
3071 +++ b/drivers/scsi/lpfc/lpfc_nvme.c
3072 @@ -1976,6 +1976,8 @@ out_unlock:
3073
3074 /* Declare and initialization an instance of the FC NVME template. */
3075 static struct nvme_fc_port_template lpfc_nvme_template = {
3076 + .module = THIS_MODULE,
3077 +
3078 /* initiator-based functions */
3079 .localport_delete = lpfc_nvme_localport_delete,
3080 .remoteport_delete = lpfc_nvme_remoteport_delete,
3081 diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
3082 index 2b0e7b32c2df..8860f41af3ff 100644
3083 --- a/drivers/scsi/lpfc/lpfc_sli.c
3084 +++ b/drivers/scsi/lpfc/lpfc_sli.c
3085 @@ -2526,6 +2526,8 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3086 } else {
3087 __lpfc_sli_rpi_release(vport, ndlp);
3088 }
3089 + if (vport->load_flag & FC_UNLOADING)
3090 + lpfc_nlp_put(ndlp);
3091 pmb->ctx_ndlp = NULL;
3092 }
3093 }
3094 diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
3095 index d5386edddaf6..1eb3fe281cc3 100644
3096 --- a/drivers/scsi/qla2xxx/qla_def.h
3097 +++ b/drivers/scsi/qla2xxx/qla_def.h
3098 @@ -2401,6 +2401,7 @@ typedef struct fc_port {
3099 unsigned int id_changed:1;
3100 unsigned int scan_needed:1;
3101 unsigned int n2n_flag:1;
3102 + unsigned int explicit_logout:1;
3103
3104 struct completion nvme_del_done;
3105 uint32_t nvme_prli_service_param;
3106 diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
3107 index 5d31e3d52b6b..80f276d67c14 100644
3108 --- a/drivers/scsi/qla2xxx/qla_init.c
3109 +++ b/drivers/scsi/qla2xxx/qla_init.c
3110 @@ -4927,14 +4927,8 @@ qla2x00_configure_loop(scsi_qla_host_t *vha)
3111 set_bit(RSCN_UPDATE, &flags);
3112 clear_bit(LOCAL_LOOP_UPDATE, &flags);
3113
3114 - } else if (ha->current_topology == ISP_CFG_N) {
3115 - clear_bit(RSCN_UPDATE, &flags);
3116 - if (qla_tgt_mode_enabled(vha)) {
3117 - /* allow the other side to start the login */
3118 - clear_bit(LOCAL_LOOP_UPDATE, &flags);
3119 - set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
3120 - }
3121 - } else if (ha->current_topology == ISP_CFG_NL) {
3122 + } else if (ha->current_topology == ISP_CFG_NL ||
3123 + ha->current_topology == ISP_CFG_N) {
3124 clear_bit(RSCN_UPDATE, &flags);
3125 set_bit(LOCAL_LOOP_UPDATE, &flags);
3126 } else if (!vha->flags.online ||
3127 @@ -5051,7 +5045,6 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
3128 memcpy(&ha->plogi_els_payld.data,
3129 (void *)ha->init_cb,
3130 sizeof(ha->plogi_els_payld.data));
3131 - set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
3132 } else {
3133 ql_dbg(ql_dbg_init, vha, 0x00d1,
3134 "PLOGI ELS param read fail.\n");
3135 diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
3136 index 518eb954cf42..bdf1994251b9 100644
3137 --- a/drivers/scsi/qla2xxx/qla_iocb.c
3138 +++ b/drivers/scsi/qla2xxx/qla_iocb.c
3139 @@ -2405,11 +2405,19 @@ qla2x00_login_iocb(srb_t *sp, struct mbx_entry *mbx)
3140 static void
3141 qla24xx_logout_iocb(srb_t *sp, struct logio_entry_24xx *logio)
3142 {
3143 + u16 control_flags = LCF_COMMAND_LOGO;
3144 logio->entry_type = LOGINOUT_PORT_IOCB_TYPE;
3145 - logio->control_flags =
3146 - cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO);
3147 - if (!sp->fcport->keep_nport_handle)
3148 - logio->control_flags |= cpu_to_le16(LCF_FREE_NPORT);
3149 +
3150 + if (sp->fcport->explicit_logout) {
3151 + control_flags |= LCF_EXPL_LOGO|LCF_FREE_NPORT;
3152 + } else {
3153 + control_flags |= LCF_IMPL_LOGO;
3154 +
3155 + if (!sp->fcport->keep_nport_handle)
3156 + control_flags |= LCF_FREE_NPORT;
3157 + }
3158 +
3159 + logio->control_flags = cpu_to_le16(control_flags);
3160 logio->nport_handle = cpu_to_le16(sp->fcport->loop_id);
3161 logio->port_id[0] = sp->fcport->d_id.b.al_pa;
3162 logio->port_id[1] = sp->fcport->d_id.b.area;
3163 @@ -2676,7 +2684,8 @@ qla24xx_els_logo_iocb(srb_t *sp, struct els_entry_24xx *els_iocb)
3164 ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x3073,
3165 "PLOGI ELS IOCB:\n");
3166 ql_dump_buffer(ql_log_info, vha, 0x0109,
3167 - (uint8_t *)els_iocb, 0x70);
3168 + (uint8_t *)els_iocb,
3169 + sizeof(*els_iocb));
3170 } else {
3171 els_iocb->control_flags = 1 << 13;
3172 els_iocb->tx_byte_count =
3173 @@ -2842,7 +2851,8 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
3174
3175 ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x3073, "PLOGI buffer:\n");
3176 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x0109,
3177 - (uint8_t *)elsio->u.els_plogi.els_plogi_pyld, 0x70);
3178 + (uint8_t *)elsio->u.els_plogi.els_plogi_pyld,
3179 + sizeof(*elsio->u.els_plogi.els_plogi_pyld));
3180
3181 rval = qla2x00_start_sp(sp);
3182 if (rval != QLA_SUCCESS) {
3183 diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
3184 index 9204e8467a4e..b3766b1879e3 100644
3185 --- a/drivers/scsi/qla2xxx/qla_isr.c
3186 +++ b/drivers/scsi/qla2xxx/qla_isr.c
3187 @@ -1061,8 +1061,6 @@ global_port_update:
3188 ql_dbg(ql_dbg_async, vha, 0x5011,
3189 "Asynchronous PORT UPDATE ignored %04x/%04x/%04x.\n",
3190 mb[1], mb[2], mb[3]);
3191 -
3192 - qlt_async_event(mb[0], vha, mb);
3193 break;
3194 }
3195
3196 @@ -1079,8 +1077,6 @@ global_port_update:
3197 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
3198 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
3199 set_bit(VP_CONFIG_OK, &vha->vp_flags);
3200 -
3201 - qlt_async_event(mb[0], vha, mb);
3202 break;
3203
3204 case MBA_RSCN_UPDATE: /* State Change Registration */
3205 diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
3206 index 4d90cf101f5f..eac76e934cbe 100644
3207 --- a/drivers/scsi/qla2xxx/qla_mbx.c
3208 +++ b/drivers/scsi/qla2xxx/qla_mbx.c
3209 @@ -3920,6 +3920,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
3210 vha->d_id.b24 = 0;
3211 vha->d_id.b.al_pa = 1;
3212 ha->flags.n2n_bigger = 1;
3213 + ha->flags.n2n_ae = 0;
3214
3215 id.b.al_pa = 2;
3216 ql_dbg(ql_dbg_async, vha, 0x5075,
3217 @@ -3930,6 +3931,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
3218 "Format 1: Remote login - Waiting for WWPN %8phC.\n",
3219 rptid_entry->u.f1.port_name);
3220 ha->flags.n2n_bigger = 0;
3221 + ha->flags.n2n_ae = 1;
3222 }
3223 qla24xx_post_newsess_work(vha, &id,
3224 rptid_entry->u.f1.port_name,
3225 @@ -3941,7 +3943,6 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
3226 /* if our portname is higher then initiate N2N login */
3227
3228 set_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags);
3229 - ha->flags.n2n_ae = 1;
3230 return;
3231 break;
3232 case TOPO_FL:
3233 diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
3234 index 941aa53363f5..bfcd02fdf2b8 100644
3235 --- a/drivers/scsi/qla2xxx/qla_nvme.c
3236 +++ b/drivers/scsi/qla2xxx/qla_nvme.c
3237 @@ -610,6 +610,7 @@ static void qla_nvme_remoteport_delete(struct nvme_fc_remote_port *rport)
3238 }
3239
3240 static struct nvme_fc_port_template qla_nvme_fc_transport = {
3241 + .module = THIS_MODULE,
3242 .localport_delete = qla_nvme_localport_delete,
3243 .remoteport_delete = qla_nvme_remoteport_delete,
3244 .create_queue = qla_nvme_alloc_queue,
3245 diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
3246 index a9bd0f513316..74a378a91b71 100644
3247 --- a/drivers/scsi/qla2xxx/qla_target.c
3248 +++ b/drivers/scsi/qla2xxx/qla_target.c
3249 @@ -1104,6 +1104,7 @@ void qlt_free_session_done(struct work_struct *work)
3250 }
3251 }
3252
3253 + sess->explicit_logout = 0;
3254 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
3255 sess->free_pending = 0;
3256
3257 @@ -1264,7 +1265,6 @@ void qlt_schedule_sess_for_deletion(struct fc_port *sess)
3258 "Scheduling sess %p for deletion %8phC\n",
3259 sess, sess->port_name);
3260
3261 - INIT_WORK(&sess->del_work, qla24xx_delete_sess_fn);
3262 WARN_ON(!queue_work(sess->vha->hw->wq, &sess->del_work));
3263 }
3264
3265 @@ -4803,6 +4803,7 @@ static int qlt_handle_login(struct scsi_qla_host *vha,
3266
3267 switch (sess->disc_state) {
3268 case DSC_DELETED:
3269 + case DSC_LOGIN_PEND:
3270 qlt_plogi_ack_unref(vha, pla);
3271 break;
3272
3273 diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
3274 index bab2073c1f72..abe7f79bb789 100644
3275 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
3276 +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
3277 @@ -350,6 +350,7 @@ static void tcm_qla2xxx_close_session(struct se_session *se_sess)
3278 target_sess_cmd_list_set_waiting(se_sess);
3279 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
3280
3281 + sess->explicit_logout = 1;
3282 tcm_qla2xxx_put_sess(sess);
3283 }
3284
3285 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
3286 index 8c674eca09f1..2323432a0edb 100644
3287 --- a/drivers/scsi/qla4xxx/ql4_os.c
3288 +++ b/drivers/scsi/qla4xxx/ql4_os.c
3289 @@ -4275,7 +4275,6 @@ static int qla4xxx_mem_alloc(struct scsi_qla_host *ha)
3290 return QLA_SUCCESS;
3291
3292 mem_alloc_error_exit:
3293 - qla4xxx_mem_free(ha);
3294 return QLA_ERROR;
3295 }
3296
3297 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
3298 index 417b868d8735..ed8d9709b9b9 100644
3299 --- a/drivers/scsi/scsi_transport_iscsi.c
3300 +++ b/drivers/scsi/scsi_transport_iscsi.c
3301 @@ -24,6 +24,8 @@
3302
3303 #define ISCSI_TRANSPORT_VERSION "2.0-870"
3304
3305 +#define ISCSI_SEND_MAX_ALLOWED 10
3306 +
3307 #define CREATE_TRACE_POINTS
3308 #include <trace/events/iscsi.h>
3309
3310 @@ -3682,6 +3684,7 @@ iscsi_if_rx(struct sk_buff *skb)
3311 struct nlmsghdr *nlh;
3312 struct iscsi_uevent *ev;
3313 uint32_t group;
3314 + int retries = ISCSI_SEND_MAX_ALLOWED;
3315
3316 nlh = nlmsg_hdr(skb);
3317 if (nlh->nlmsg_len < sizeof(*nlh) + sizeof(*ev) ||
3318 @@ -3712,6 +3715,10 @@ iscsi_if_rx(struct sk_buff *skb)
3319 break;
3320 err = iscsi_if_send_reply(portid, nlh->nlmsg_type,
3321 ev, sizeof(*ev));
3322 + if (err == -EAGAIN && --retries < 0) {
3323 + printk(KERN_WARNING "Send reply failed, error %d\n", err);
3324 + break;
3325 + }
3326 } while (err < 0 && err != -ECONNREFUSED && err != -ESRCH);
3327 skb_pull(skb, rlen);
3328 }
3329 diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
3330 index bec758e978fb..d47bd26577b3 100644
3331 --- a/drivers/spi/spi-fsl-dspi.c
3332 +++ b/drivers/spi/spi-fsl-dspi.c
3333 @@ -583,21 +583,14 @@ static void dspi_tcfq_write(struct fsl_dspi *dspi)
3334 dspi->tx_cmd |= SPI_PUSHR_CMD_CTCNT;
3335
3336 if (dspi->devtype_data->xspi_mode && dspi->bits_per_word > 16) {
3337 - /* Write two TX FIFO entries first, and then the corresponding
3338 - * CMD FIFO entry.
3339 + /* Write the CMD FIFO entry first, and then the two
3340 + * corresponding TX FIFO entries.
3341 */
3342 u32 data = dspi_pop_tx(dspi);
3343
3344 - if (dspi->cur_chip->ctar_val & SPI_CTAR_LSBFE) {
3345 - /* LSB */
3346 - tx_fifo_write(dspi, data & 0xFFFF);
3347 - tx_fifo_write(dspi, data >> 16);
3348 - } else {
3349 - /* MSB */
3350 - tx_fifo_write(dspi, data >> 16);
3351 - tx_fifo_write(dspi, data & 0xFFFF);
3352 - }
3353 cmd_fifo_write(dspi);
3354 + tx_fifo_write(dspi, data & 0xFFFF);
3355 + tx_fifo_write(dspi, data >> 16);
3356 } else {
3357 /* Write one entry to both TX FIFO and CMD FIFO
3358 * simultaneously.
3359 diff --git a/drivers/spi/spi-uniphier.c b/drivers/spi/spi-uniphier.c
3360 index 47cde1864630..ce9b30112e26 100644
3361 --- a/drivers/spi/spi-uniphier.c
3362 +++ b/drivers/spi/spi-uniphier.c
3363 @@ -290,25 +290,32 @@ static void uniphier_spi_recv(struct uniphier_spi_priv *priv)
3364 }
3365 }
3366
3367 -static void uniphier_spi_fill_tx_fifo(struct uniphier_spi_priv *priv)
3368 +static void uniphier_spi_set_fifo_threshold(struct uniphier_spi_priv *priv,
3369 + unsigned int threshold)
3370 {
3371 - unsigned int fifo_threshold, fill_bytes;
3372 u32 val;
3373
3374 - fifo_threshold = DIV_ROUND_UP(priv->rx_bytes,
3375 - bytes_per_word(priv->bits_per_word));
3376 - fifo_threshold = min(fifo_threshold, SSI_FIFO_DEPTH);
3377 -
3378 - fill_bytes = fifo_threshold - (priv->rx_bytes - priv->tx_bytes);
3379 -
3380 - /* set fifo threshold */
3381 val = readl(priv->base + SSI_FC);
3382 val &= ~(SSI_FC_TXFTH_MASK | SSI_FC_RXFTH_MASK);
3383 - val |= FIELD_PREP(SSI_FC_TXFTH_MASK, fifo_threshold);
3384 - val |= FIELD_PREP(SSI_FC_RXFTH_MASK, fifo_threshold);
3385 + val |= FIELD_PREP(SSI_FC_TXFTH_MASK, SSI_FIFO_DEPTH - threshold);
3386 + val |= FIELD_PREP(SSI_FC_RXFTH_MASK, threshold);
3387 writel(val, priv->base + SSI_FC);
3388 +}
3389 +
3390 +static void uniphier_spi_fill_tx_fifo(struct uniphier_spi_priv *priv)
3391 +{
3392 + unsigned int fifo_threshold, fill_words;
3393 + unsigned int bpw = bytes_per_word(priv->bits_per_word);
3394 +
3395 + fifo_threshold = DIV_ROUND_UP(priv->rx_bytes, bpw);
3396 + fifo_threshold = min(fifo_threshold, SSI_FIFO_DEPTH);
3397 +
3398 + uniphier_spi_set_fifo_threshold(priv, fifo_threshold);
3399 +
3400 + fill_words = fifo_threshold -
3401 + DIV_ROUND_UP(priv->rx_bytes - priv->tx_bytes, bpw);
3402
3403 - while (fill_bytes--)
3404 + while (fill_words--)
3405 uniphier_spi_send(priv);
3406 }
3407
3408 diff --git a/drivers/staging/wlan-ng/Kconfig b/drivers/staging/wlan-ng/Kconfig
3409 index ac136663fa8e..082c16a31616 100644
3410 --- a/drivers/staging/wlan-ng/Kconfig
3411 +++ b/drivers/staging/wlan-ng/Kconfig
3412 @@ -4,6 +4,7 @@ config PRISM2_USB
3413 depends on WLAN && USB && CFG80211
3414 select WIRELESS_EXT
3415 select WEXT_PRIV
3416 + select CRC32
3417 help
3418 This is the wlan-ng prism 2.5/3 USB driver for a wide range of
3419 old USB wireless devices.
3420 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
3421 index 00964b6e4ac1..e0718ee5d42a 100644
3422 --- a/drivers/tty/serial/msm_serial.c
3423 +++ b/drivers/tty/serial/msm_serial.c
3424 @@ -1580,6 +1580,7 @@ static void __msm_console_write(struct uart_port *port, const char *s,
3425 int num_newlines = 0;
3426 bool replaced = false;
3427 void __iomem *tf;
3428 + int locked = 1;
3429
3430 if (is_uartdm)
3431 tf = port->membase + UARTDM_TF;
3432 @@ -1592,7 +1593,13 @@ static void __msm_console_write(struct uart_port *port, const char *s,
3433 num_newlines++;
3434 count += num_newlines;
3435
3436 - spin_lock(&port->lock);
3437 + if (port->sysrq)
3438 + locked = 0;
3439 + else if (oops_in_progress)
3440 + locked = spin_trylock(&port->lock);
3441 + else
3442 + spin_lock(&port->lock);
3443 +
3444 if (is_uartdm)
3445 msm_reset_dm_count(port, count);
3446
3447 @@ -1628,7 +1635,9 @@ static void __msm_console_write(struct uart_port *port, const char *s,
3448 iowrite32_rep(tf, buf, 1);
3449 i += num_chars;
3450 }
3451 - spin_unlock(&port->lock);
3452 +
3453 + if (locked)
3454 + spin_unlock(&port->lock);
3455 }
3456
3457 static void msm_console_write(struct console *co, const char *s,
3458 diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
3459 index 6ce044008cf6..460d5d7c984f 100644
3460 --- a/drivers/usb/gadget/function/f_ecm.c
3461 +++ b/drivers/usb/gadget/function/f_ecm.c
3462 @@ -621,8 +621,12 @@ static void ecm_disable(struct usb_function *f)
3463
3464 DBG(cdev, "ecm deactivated\n");
3465
3466 - if (ecm->port.in_ep->enabled)
3467 + if (ecm->port.in_ep->enabled) {
3468 gether_disconnect(&ecm->port);
3469 + } else {
3470 + ecm->port.in_ep->desc = NULL;
3471 + ecm->port.out_ep->desc = NULL;
3472 + }
3473
3474 usb_ep_disable(ecm->notify);
3475 ecm->notify->desc = NULL;
3476 diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
3477 index d48df36622b7..0d8e4a364ca6 100644
3478 --- a/drivers/usb/gadget/function/f_rndis.c
3479 +++ b/drivers/usb/gadget/function/f_rndis.c
3480 @@ -618,6 +618,7 @@ static void rndis_disable(struct usb_function *f)
3481 gether_disconnect(&rndis->port);
3482
3483 usb_ep_disable(rndis->notify);
3484 + rndis->notify->desc = NULL;
3485 }
3486
3487 /*-------------------------------------------------------------------------*/
3488 diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
3489 index 58e7c100b6ad..4c761abc5688 100644
3490 --- a/drivers/watchdog/Kconfig
3491 +++ b/drivers/watchdog/Kconfig
3492 @@ -1444,6 +1444,7 @@ config SMSC37B787_WDT
3493 config TQMX86_WDT
3494 tristate "TQ-Systems TQMX86 Watchdog Timer"
3495 depends on X86
3496 + select WATCHDOG_CORE
3497 help
3498 This is the driver for the hardware watchdog timer in the TQMX86 IO
3499 controller found on some of their ComExpress Modules.
3500 diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
3501 index 5bae515c8e25..bed90d612e48 100644
3502 --- a/drivers/xen/balloon.c
3503 +++ b/drivers/xen/balloon.c
3504 @@ -395,7 +395,8 @@ static struct notifier_block xen_memory_nb = {
3505 #else
3506 static enum bp_state reserve_additional_memory(void)
3507 {
3508 - balloon_stats.target_pages = balloon_stats.current_pages;
3509 + balloon_stats.target_pages = balloon_stats.current_pages +
3510 + balloon_stats.target_unpopulated;
3511 return BP_ECANCELED;
3512 }
3513 #endif /* CONFIG_XEN_BALLOON_MEMORY_HOTPLUG */
3514 diff --git a/fs/afs/dynroot.c b/fs/afs/dynroot.c
3515 index 4150280509ff..7503899c0a1b 100644
3516 --- a/fs/afs/dynroot.c
3517 +++ b/fs/afs/dynroot.c
3518 @@ -136,6 +136,9 @@ static struct dentry *afs_dynroot_lookup(struct inode *dir, struct dentry *dentr
3519
3520 ASSERTCMP(d_inode(dentry), ==, NULL);
3521
3522 + if (flags & LOOKUP_CREATE)
3523 + return ERR_PTR(-EOPNOTSUPP);
3524 +
3525 if (dentry->d_name.len >= AFSNAMEMAX) {
3526 _leave(" = -ENAMETOOLONG");
3527 return ERR_PTR(-ENAMETOOLONG);
3528 diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
3529 index f532d6d3bd28..79bc5f1338ed 100644
3530 --- a/fs/afs/mntpt.c
3531 +++ b/fs/afs/mntpt.c
3532 @@ -126,7 +126,7 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt)
3533 if (src_as->cell)
3534 ctx->cell = afs_get_cell(src_as->cell);
3535
3536 - if (size > PAGE_SIZE - 1)
3537 + if (size < 2 || size > PAGE_SIZE - 1)
3538 return -EINVAL;
3539
3540 page = read_mapping_page(d_inode(mntpt)->i_mapping, 0, NULL);
3541 @@ -140,7 +140,9 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt)
3542 }
3543
3544 buf = kmap(page);
3545 - ret = vfs_parse_fs_string(fc, "source", buf, size);
3546 + ret = -EINVAL;
3547 + if (buf[size - 1] == '.')
3548 + ret = vfs_parse_fs_string(fc, "source", buf, size - 1);
3549 kunmap(page);
3550 put_page(page);
3551 if (ret < 0)
3552 diff --git a/fs/afs/server.c b/fs/afs/server.c
3553 index 64d440aaabc0..ca8115ba1724 100644
3554 --- a/fs/afs/server.c
3555 +++ b/fs/afs/server.c
3556 @@ -32,18 +32,11 @@ static void afs_dec_servers_outstanding(struct afs_net *net)
3557 struct afs_server *afs_find_server(struct afs_net *net,
3558 const struct sockaddr_rxrpc *srx)
3559 {
3560 - const struct sockaddr_in6 *a = &srx->transport.sin6, *b;
3561 const struct afs_addr_list *alist;
3562 struct afs_server *server = NULL;
3563 unsigned int i;
3564 - bool ipv6 = true;
3565 int seq = 0, diff;
3566
3567 - if (srx->transport.sin6.sin6_addr.s6_addr32[0] == 0 ||
3568 - srx->transport.sin6.sin6_addr.s6_addr32[1] == 0 ||
3569 - srx->transport.sin6.sin6_addr.s6_addr32[2] == htonl(0xffff))
3570 - ipv6 = false;
3571 -
3572 rcu_read_lock();
3573
3574 do {
3575 @@ -52,7 +45,8 @@ struct afs_server *afs_find_server(struct afs_net *net,
3576 server = NULL;
3577 read_seqbegin_or_lock(&net->fs_addr_lock, &seq);
3578
3579 - if (ipv6) {
3580 + if (srx->transport.family == AF_INET6) {
3581 + const struct sockaddr_in6 *a = &srx->transport.sin6, *b;
3582 hlist_for_each_entry_rcu(server, &net->fs_addresses6, addr6_link) {
3583 alist = rcu_dereference(server->addresses);
3584 for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) {
3585 @@ -68,15 +62,16 @@ struct afs_server *afs_find_server(struct afs_net *net,
3586 }
3587 }
3588 } else {
3589 + const struct sockaddr_in *a = &srx->transport.sin, *b;
3590 hlist_for_each_entry_rcu(server, &net->fs_addresses4, addr4_link) {
3591 alist = rcu_dereference(server->addresses);
3592 for (i = 0; i < alist->nr_ipv4; i++) {
3593 - b = &alist->addrs[i].transport.sin6;
3594 - diff = ((u16 __force)a->sin6_port -
3595 - (u16 __force)b->sin6_port);
3596 + b = &alist->addrs[i].transport.sin;
3597 + diff = ((u16 __force)a->sin_port -
3598 + (u16 __force)b->sin_port);
3599 if (diff == 0)
3600 - diff = ((u32 __force)a->sin6_addr.s6_addr32[3] -
3601 - (u32 __force)b->sin6_addr.s6_addr32[3]);
3602 + diff = ((u32 __force)a->sin_addr.s_addr -
3603 + (u32 __force)b->sin_addr.s_addr);
3604 if (diff == 0)
3605 goto found;
3606 }
3607 diff --git a/fs/afs/super.c b/fs/afs/super.c
3608 index 488641b1a418..d9a6036b70b9 100644
3609 --- a/fs/afs/super.c
3610 +++ b/fs/afs/super.c
3611 @@ -448,7 +448,6 @@ static int afs_fill_super(struct super_block *sb, struct afs_fs_context *ctx)
3612 /* allocate the root inode and dentry */
3613 if (as->dyn_root) {
3614 inode = afs_iget_pseudo_dir(sb, true);
3615 - sb->s_flags |= SB_RDONLY;
3616 } else {
3617 sprintf(sb->s_id, "%llu", as->volume->vid);
3618 afs_activate_volume(as->volume);
3619 diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
3620 index 10a04b99798a..3f3110975f88 100644
3621 --- a/fs/btrfs/async-thread.c
3622 +++ b/fs/btrfs/async-thread.c
3623 @@ -53,16 +53,6 @@ struct btrfs_workqueue {
3624 struct __btrfs_workqueue *high;
3625 };
3626
3627 -static void normal_work_helper(struct btrfs_work *work);
3628 -
3629 -#define BTRFS_WORK_HELPER(name) \
3630 -noinline_for_stack void btrfs_##name(struct work_struct *arg) \
3631 -{ \
3632 - struct btrfs_work *work = container_of(arg, struct btrfs_work, \
3633 - normal_work); \
3634 - normal_work_helper(work); \
3635 -}
3636 -
3637 struct btrfs_fs_info *
3638 btrfs_workqueue_owner(const struct __btrfs_workqueue *wq)
3639 {
3640 @@ -89,29 +79,6 @@ bool btrfs_workqueue_normal_congested(const struct btrfs_workqueue *wq)
3641 return atomic_read(&wq->normal->pending) > wq->normal->thresh * 2;
3642 }
3643
3644 -BTRFS_WORK_HELPER(worker_helper);
3645 -BTRFS_WORK_HELPER(delalloc_helper);
3646 -BTRFS_WORK_HELPER(flush_delalloc_helper);
3647 -BTRFS_WORK_HELPER(cache_helper);
3648 -BTRFS_WORK_HELPER(submit_helper);
3649 -BTRFS_WORK_HELPER(fixup_helper);
3650 -BTRFS_WORK_HELPER(endio_helper);
3651 -BTRFS_WORK_HELPER(endio_meta_helper);
3652 -BTRFS_WORK_HELPER(endio_meta_write_helper);
3653 -BTRFS_WORK_HELPER(endio_raid56_helper);
3654 -BTRFS_WORK_HELPER(endio_repair_helper);
3655 -BTRFS_WORK_HELPER(rmw_helper);
3656 -BTRFS_WORK_HELPER(endio_write_helper);
3657 -BTRFS_WORK_HELPER(freespace_write_helper);
3658 -BTRFS_WORK_HELPER(delayed_meta_helper);
3659 -BTRFS_WORK_HELPER(readahead_helper);
3660 -BTRFS_WORK_HELPER(qgroup_rescan_helper);
3661 -BTRFS_WORK_HELPER(extent_refs_helper);
3662 -BTRFS_WORK_HELPER(scrub_helper);
3663 -BTRFS_WORK_HELPER(scrubwrc_helper);
3664 -BTRFS_WORK_HELPER(scrubnc_helper);
3665 -BTRFS_WORK_HELPER(scrubparity_helper);
3666 -
3667 static struct __btrfs_workqueue *
3668 __btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info, const char *name,
3669 unsigned int flags, int limit_active, int thresh)
3670 @@ -302,12 +269,13 @@ static void run_ordered_work(struct __btrfs_workqueue *wq,
3671 * original work item cannot depend on the recycled work
3672 * item in that case (see find_worker_executing_work()).
3673 *
3674 - * Note that the work of one Btrfs filesystem may depend
3675 - * on the work of another Btrfs filesystem via, e.g., a
3676 - * loop device. Therefore, we must not allow the current
3677 - * work item to be recycled until we are really done,
3678 - * otherwise we break the above assumption and can
3679 - * deadlock.
3680 + * Note that different types of Btrfs work can depend on
3681 + * each other, and one type of work on one Btrfs
3682 + * filesystem may even depend on the same type of work
3683 + * on another Btrfs filesystem via, e.g., a loop device.
3684 + * Therefore, we must not allow the current work item to
3685 + * be recycled until we are really done, otherwise we
3686 + * break the above assumption and can deadlock.
3687 */
3688 free_self = true;
3689 } else {
3690 @@ -331,8 +299,10 @@ static void run_ordered_work(struct __btrfs_workqueue *wq,
3691 }
3692 }
3693
3694 -static void normal_work_helper(struct btrfs_work *work)
3695 +static void btrfs_work_helper(struct work_struct *normal_work)
3696 {
3697 + struct btrfs_work *work = container_of(normal_work, struct btrfs_work,
3698 + normal_work);
3699 struct __btrfs_workqueue *wq;
3700 void *wtag;
3701 int need_order = 0;
3702 @@ -362,15 +332,13 @@ static void normal_work_helper(struct btrfs_work *work)
3703 trace_btrfs_all_work_done(wq->fs_info, wtag);
3704 }
3705
3706 -void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t uniq_func,
3707 - btrfs_func_t func,
3708 - btrfs_func_t ordered_func,
3709 - btrfs_func_t ordered_free)
3710 +void btrfs_init_work(struct btrfs_work *work, btrfs_func_t func,
3711 + btrfs_func_t ordered_func, btrfs_func_t ordered_free)
3712 {
3713 work->func = func;
3714 work->ordered_func = ordered_func;
3715 work->ordered_free = ordered_free;
3716 - INIT_WORK(&work->normal_work, uniq_func);
3717 + INIT_WORK(&work->normal_work, btrfs_work_helper);
3718 INIT_LIST_HEAD(&work->ordered_list);
3719 work->flags = 0;
3720 }
3721 diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h
3722 index 7861c9feba5f..c5bf2b117c05 100644
3723 --- a/fs/btrfs/async-thread.h
3724 +++ b/fs/btrfs/async-thread.h
3725 @@ -29,42 +29,13 @@ struct btrfs_work {
3726 unsigned long flags;
3727 };
3728
3729 -#define BTRFS_WORK_HELPER_PROTO(name) \
3730 -void btrfs_##name(struct work_struct *arg)
3731 -
3732 -BTRFS_WORK_HELPER_PROTO(worker_helper);
3733 -BTRFS_WORK_HELPER_PROTO(delalloc_helper);
3734 -BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper);
3735 -BTRFS_WORK_HELPER_PROTO(cache_helper);
3736 -BTRFS_WORK_HELPER_PROTO(submit_helper);
3737 -BTRFS_WORK_HELPER_PROTO(fixup_helper);
3738 -BTRFS_WORK_HELPER_PROTO(endio_helper);
3739 -BTRFS_WORK_HELPER_PROTO(endio_meta_helper);
3740 -BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper);
3741 -BTRFS_WORK_HELPER_PROTO(endio_raid56_helper);
3742 -BTRFS_WORK_HELPER_PROTO(endio_repair_helper);
3743 -BTRFS_WORK_HELPER_PROTO(rmw_helper);
3744 -BTRFS_WORK_HELPER_PROTO(endio_write_helper);
3745 -BTRFS_WORK_HELPER_PROTO(freespace_write_helper);
3746 -BTRFS_WORK_HELPER_PROTO(delayed_meta_helper);
3747 -BTRFS_WORK_HELPER_PROTO(readahead_helper);
3748 -BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper);
3749 -BTRFS_WORK_HELPER_PROTO(extent_refs_helper);
3750 -BTRFS_WORK_HELPER_PROTO(scrub_helper);
3751 -BTRFS_WORK_HELPER_PROTO(scrubwrc_helper);
3752 -BTRFS_WORK_HELPER_PROTO(scrubnc_helper);
3753 -BTRFS_WORK_HELPER_PROTO(scrubparity_helper);
3754 -
3755 -
3756 struct btrfs_workqueue *btrfs_alloc_workqueue(struct btrfs_fs_info *fs_info,
3757 const char *name,
3758 unsigned int flags,
3759 int limit_active,
3760 int thresh);
3761 -void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper,
3762 - btrfs_func_t func,
3763 - btrfs_func_t ordered_func,
3764 - btrfs_func_t ordered_free);
3765 +void btrfs_init_work(struct btrfs_work *work, btrfs_func_t func,
3766 + btrfs_func_t ordered_func, btrfs_func_t ordered_free);
3767 void btrfs_queue_work(struct btrfs_workqueue *wq,
3768 struct btrfs_work *work);
3769 void btrfs_destroy_workqueue(struct btrfs_workqueue *wq);
3770 diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
3771 index 0d2da2366869..7dcfa7d7632a 100644
3772 --- a/fs/btrfs/block-group.c
3773 +++ b/fs/btrfs/block-group.c
3774 @@ -695,8 +695,7 @@ int btrfs_cache_block_group(struct btrfs_block_group_cache *cache,
3775 caching_ctl->block_group = cache;
3776 caching_ctl->progress = cache->key.objectid;
3777 refcount_set(&caching_ctl->count, 1);
3778 - btrfs_init_work(&caching_ctl->work, btrfs_cache_helper,
3779 - caching_thread, NULL, NULL);
3780 + btrfs_init_work(&caching_ctl->work, caching_thread, NULL, NULL);
3781
3782 spin_lock(&cache->lock);
3783 /*
3784 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
3785 index 57a9ad3e8c29..c7a53e79c66d 100644
3786 --- a/fs/btrfs/delayed-inode.c
3787 +++ b/fs/btrfs/delayed-inode.c
3788 @@ -1367,8 +1367,8 @@ static int btrfs_wq_run_delayed_node(struct btrfs_delayed_root *delayed_root,
3789 return -ENOMEM;
3790
3791 async_work->delayed_root = delayed_root;
3792 - btrfs_init_work(&async_work->work, btrfs_delayed_meta_helper,
3793 - btrfs_async_run_delayed_root, NULL, NULL);
3794 + btrfs_init_work(&async_work->work, btrfs_async_run_delayed_root, NULL,
3795 + NULL);
3796 async_work->nr = nr;
3797
3798 btrfs_queue_work(fs_info->delayed_workers, &async_work->work);
3799 diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
3800 index 3895c21853cc..bae334212ee2 100644
3801 --- a/fs/btrfs/disk-io.c
3802 +++ b/fs/btrfs/disk-io.c
3803 @@ -706,43 +706,31 @@ static void end_workqueue_bio(struct bio *bio)
3804 struct btrfs_end_io_wq *end_io_wq = bio->bi_private;
3805 struct btrfs_fs_info *fs_info;
3806 struct btrfs_workqueue *wq;
3807 - btrfs_work_func_t func;
3808
3809 fs_info = end_io_wq->info;
3810 end_io_wq->status = bio->bi_status;
3811
3812 if (bio_op(bio) == REQ_OP_WRITE) {
3813 - if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA) {
3814 + if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA)
3815 wq = fs_info->endio_meta_write_workers;
3816 - func = btrfs_endio_meta_write_helper;
3817 - } else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_FREE_SPACE) {
3818 + else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_FREE_SPACE)
3819 wq = fs_info->endio_freespace_worker;
3820 - func = btrfs_freespace_write_helper;
3821 - } else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56) {
3822 + else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56)
3823 wq = fs_info->endio_raid56_workers;
3824 - func = btrfs_endio_raid56_helper;
3825 - } else {
3826 + else
3827 wq = fs_info->endio_write_workers;
3828 - func = btrfs_endio_write_helper;
3829 - }
3830 } else {
3831 - if (unlikely(end_io_wq->metadata ==
3832 - BTRFS_WQ_ENDIO_DIO_REPAIR)) {
3833 + if (unlikely(end_io_wq->metadata == BTRFS_WQ_ENDIO_DIO_REPAIR))
3834 wq = fs_info->endio_repair_workers;
3835 - func = btrfs_endio_repair_helper;
3836 - } else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56) {
3837 + else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56)
3838 wq = fs_info->endio_raid56_workers;
3839 - func = btrfs_endio_raid56_helper;
3840 - } else if (end_io_wq->metadata) {
3841 + else if (end_io_wq->metadata)
3842 wq = fs_info->endio_meta_workers;
3843 - func = btrfs_endio_meta_helper;
3844 - } else {
3845 + else
3846 wq = fs_info->endio_workers;
3847 - func = btrfs_endio_helper;
3848 - }
3849 }
3850
3851 - btrfs_init_work(&end_io_wq->work, func, end_workqueue_fn, NULL, NULL);
3852 + btrfs_init_work(&end_io_wq->work, end_workqueue_fn, NULL, NULL);
3853 btrfs_queue_work(wq, &end_io_wq->work);
3854 }
3855
3856 @@ -835,8 +823,8 @@ blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
3857 async->mirror_num = mirror_num;
3858 async->submit_bio_start = submit_bio_start;
3859
3860 - btrfs_init_work(&async->work, btrfs_worker_helper, run_one_async_start,
3861 - run_one_async_done, run_one_async_free);
3862 + btrfs_init_work(&async->work, run_one_async_start, run_one_async_done,
3863 + run_one_async_free);
3864
3865 async->bio_offset = bio_offset;
3866
3867 diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
3868 index be9dc78aa727..33c6b191ca59 100644
3869 --- a/fs/btrfs/extent_io.c
3870 +++ b/fs/btrfs/extent_io.c
3871 @@ -1899,7 +1899,7 @@ static int __process_pages_contig(struct address_space *mapping,
3872 if (page_ops & PAGE_SET_PRIVATE2)
3873 SetPagePrivate2(pages[i]);
3874
3875 - if (pages[i] == locked_page) {
3876 + if (locked_page && pages[i] == locked_page) {
3877 put_page(pages[i]);
3878 pages_locked++;
3879 continue;
3880 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
3881 index e5758f62e8d8..0b2758961b1c 100644
3882 --- a/fs/btrfs/inode.c
3883 +++ b/fs/btrfs/inode.c
3884 @@ -712,10 +712,12 @@ cleanup_and_bail_uncompressed:
3885 * to our extent and set things up for the async work queue to run
3886 * cow_file_range to do the normal delalloc dance.
3887 */
3888 - if (page_offset(async_chunk->locked_page) >= start &&
3889 - page_offset(async_chunk->locked_page) <= end)
3890 + if (async_chunk->locked_page &&
3891 + (page_offset(async_chunk->locked_page) >= start &&
3892 + page_offset(async_chunk->locked_page)) <= end) {
3893 __set_page_dirty_nobuffers(async_chunk->locked_page);
3894 /* unlocked later on in the async handlers */
3895 + }
3896
3897 if (redirty)
3898 extent_range_redirty_for_io(inode, start, end);
3899 @@ -795,7 +797,7 @@ retry:
3900 async_extent->start +
3901 async_extent->ram_size - 1,
3902 WB_SYNC_ALL);
3903 - else if (ret)
3904 + else if (ret && async_chunk->locked_page)
3905 unlock_page(async_chunk->locked_page);
3906 kfree(async_extent);
3907 cond_resched();
3908 @@ -1264,14 +1266,27 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
3909 async_chunk[i].inode = inode;
3910 async_chunk[i].start = start;
3911 async_chunk[i].end = cur_end;
3912 - async_chunk[i].locked_page = locked_page;
3913 async_chunk[i].write_flags = write_flags;
3914 INIT_LIST_HEAD(&async_chunk[i].extents);
3915
3916 - btrfs_init_work(&async_chunk[i].work,
3917 - btrfs_delalloc_helper,
3918 - async_cow_start, async_cow_submit,
3919 - async_cow_free);
3920 + /*
3921 + * The locked_page comes all the way from writepage and its
3922 + * the original page we were actually given. As we spread
3923 + * this large delalloc region across multiple async_chunk
3924 + * structs, only the first struct needs a pointer to locked_page
3925 + *
3926 + * This way we don't need racey decisions about who is supposed
3927 + * to unlock it.
3928 + */
3929 + if (locked_page) {
3930 + async_chunk[i].locked_page = locked_page;
3931 + locked_page = NULL;
3932 + } else {
3933 + async_chunk[i].locked_page = NULL;
3934 + }
3935 +
3936 + btrfs_init_work(&async_chunk[i].work, async_cow_start,
3937 + async_cow_submit, async_cow_free);
3938
3939 nr_pages = DIV_ROUND_UP(cur_end - start, PAGE_SIZE);
3940 atomic_add(nr_pages, &fs_info->async_delalloc_pages);
3941 @@ -1439,10 +1454,10 @@ next_slot:
3942 disk_num_bytes =
3943 btrfs_file_extent_disk_num_bytes(leaf, fi);
3944 /*
3945 - * If extent we got ends before our range starts, skip
3946 - * to next extent
3947 + * If the extent we got ends before our current offset,
3948 + * skip to the next extent.
3949 */
3950 - if (extent_end <= start) {
3951 + if (extent_end <= cur_offset) {
3952 path->slots[0]++;
3953 goto next_slot;
3954 }
3955 @@ -2264,8 +2279,7 @@ int btrfs_writepage_cow_fixup(struct page *page, u64 start, u64 end)
3956
3957 SetPageChecked(page);
3958 get_page(page);
3959 - btrfs_init_work(&fixup->work, btrfs_fixup_helper,
3960 - btrfs_writepage_fixup_worker, NULL, NULL);
3961 + btrfs_init_work(&fixup->work, btrfs_writepage_fixup_worker, NULL, NULL);
3962 fixup->page = page;
3963 btrfs_queue_work(fs_info->fixup_workers, &fixup->work);
3964 return -EBUSY;
3965 @@ -3258,7 +3272,6 @@ void btrfs_writepage_endio_finish_ordered(struct page *page, u64 start,
3966 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
3967 struct btrfs_ordered_extent *ordered_extent = NULL;
3968 struct btrfs_workqueue *wq;
3969 - btrfs_work_func_t func;
3970
3971 trace_btrfs_writepage_end_io_hook(page, start, end, uptodate);
3972
3973 @@ -3267,16 +3280,12 @@ void btrfs_writepage_endio_finish_ordered(struct page *page, u64 start,
3974 end - start + 1, uptodate))
3975 return;
3976
3977 - if (btrfs_is_free_space_inode(BTRFS_I(inode))) {
3978 + if (btrfs_is_free_space_inode(BTRFS_I(inode)))
3979 wq = fs_info->endio_freespace_worker;
3980 - func = btrfs_freespace_write_helper;
3981 - } else {
3982 + else
3983 wq = fs_info->endio_write_workers;
3984 - func = btrfs_endio_write_helper;
3985 - }
3986
3987 - btrfs_init_work(&ordered_extent->work, func, finish_ordered_fn, NULL,
3988 - NULL);
3989 + btrfs_init_work(&ordered_extent->work, finish_ordered_fn, NULL, NULL);
3990 btrfs_queue_work(wq, &ordered_extent->work);
3991 }
3992
3993 @@ -8213,18 +8222,14 @@ static void __endio_write_update_ordered(struct inode *inode,
3994 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
3995 struct btrfs_ordered_extent *ordered = NULL;
3996 struct btrfs_workqueue *wq;
3997 - btrfs_work_func_t func;
3998 u64 ordered_offset = offset;
3999 u64 ordered_bytes = bytes;
4000 u64 last_offset;
4001
4002 - if (btrfs_is_free_space_inode(BTRFS_I(inode))) {
4003 + if (btrfs_is_free_space_inode(BTRFS_I(inode)))
4004 wq = fs_info->endio_freespace_worker;
4005 - func = btrfs_freespace_write_helper;
4006 - } else {
4007 + else
4008 wq = fs_info->endio_write_workers;
4009 - func = btrfs_endio_write_helper;
4010 - }
4011
4012 while (ordered_offset < offset + bytes) {
4013 last_offset = ordered_offset;
4014 @@ -8232,9 +8237,8 @@ static void __endio_write_update_ordered(struct inode *inode,
4015 &ordered_offset,
4016 ordered_bytes,
4017 uptodate)) {
4018 - btrfs_init_work(&ordered->work, func,
4019 - finish_ordered_fn,
4020 - NULL, NULL);
4021 + btrfs_init_work(&ordered->work, finish_ordered_fn, NULL,
4022 + NULL);
4023 btrfs_queue_work(wq, &ordered->work);
4024 }
4025 /*
4026 @@ -10119,8 +10123,7 @@ static struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode
4027 init_completion(&work->completion);
4028 INIT_LIST_HEAD(&work->list);
4029 work->inode = inode;
4030 - btrfs_init_work(&work->work, btrfs_flush_delalloc_helper,
4031 - btrfs_run_delalloc_work, NULL, NULL);
4032 + btrfs_init_work(&work->work, btrfs_run_delalloc_work, NULL, NULL);
4033
4034 return work;
4035 }
4036 diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
4037 index 24b6c72b9a59..6240a5a1f2c0 100644
4038 --- a/fs/btrfs/ordered-data.c
4039 +++ b/fs/btrfs/ordered-data.c
4040 @@ -547,7 +547,6 @@ u64 btrfs_wait_ordered_extents(struct btrfs_root *root, u64 nr,
4041 spin_unlock(&root->ordered_extent_lock);
4042
4043 btrfs_init_work(&ordered->flush_work,
4044 - btrfs_flush_delalloc_helper,
4045 btrfs_run_ordered_extent_work, NULL, NULL);
4046 list_add_tail(&ordered->work_list, &works);
4047 btrfs_queue_work(fs_info->flush_workers, &ordered->flush_work);
4048 diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
4049 index 3ad151655eb8..27a903aaf43b 100644
4050 --- a/fs/btrfs/qgroup.c
4051 +++ b/fs/btrfs/qgroup.c
4052 @@ -3280,7 +3280,6 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
4053 memset(&fs_info->qgroup_rescan_work, 0,
4054 sizeof(fs_info->qgroup_rescan_work));
4055 btrfs_init_work(&fs_info->qgroup_rescan_work,
4056 - btrfs_qgroup_rescan_helper,
4057 btrfs_qgroup_rescan_worker, NULL, NULL);
4058 return 0;
4059 }
4060 diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
4061 index 57a2ac721985..8f47a85944eb 100644
4062 --- a/fs/btrfs/raid56.c
4063 +++ b/fs/btrfs/raid56.c
4064 @@ -190,7 +190,7 @@ static void scrub_parity_work(struct btrfs_work *work);
4065
4066 static void start_async_work(struct btrfs_raid_bio *rbio, btrfs_func_t work_func)
4067 {
4068 - btrfs_init_work(&rbio->work, btrfs_rmw_helper, work_func, NULL, NULL);
4069 + btrfs_init_work(&rbio->work, work_func, NULL, NULL);
4070 btrfs_queue_work(rbio->fs_info->rmw_workers, &rbio->work);
4071 }
4072
4073 @@ -1743,8 +1743,7 @@ static void btrfs_raid_unplug(struct blk_plug_cb *cb, bool from_schedule)
4074 plug = container_of(cb, struct btrfs_plug_cb, cb);
4075
4076 if (from_schedule) {
4077 - btrfs_init_work(&plug->work, btrfs_rmw_helper,
4078 - unplug_work, NULL, NULL);
4079 + btrfs_init_work(&plug->work, unplug_work, NULL, NULL);
4080 btrfs_queue_work(plug->info->rmw_workers,
4081 &plug->work);
4082 return;
4083 diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
4084 index dd4f9c2b7107..1feaeadc8cf5 100644
4085 --- a/fs/btrfs/reada.c
4086 +++ b/fs/btrfs/reada.c
4087 @@ -819,8 +819,7 @@ static void reada_start_machine(struct btrfs_fs_info *fs_info)
4088 /* FIXME we cannot handle this properly right now */
4089 BUG();
4090 }
4091 - btrfs_init_work(&rmw->work, btrfs_readahead_helper,
4092 - reada_start_machine_worker, NULL, NULL);
4093 + btrfs_init_work(&rmw->work, reada_start_machine_worker, NULL, NULL);
4094 rmw->fs_info = fs_info;
4095
4096 btrfs_queue_work(fs_info->readahead_workers, &rmw->work);
4097 diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
4098 index a0770a6aee00..a7b043fd7a57 100644
4099 --- a/fs/btrfs/scrub.c
4100 +++ b/fs/btrfs/scrub.c
4101 @@ -598,8 +598,8 @@ static noinline_for_stack struct scrub_ctx *scrub_setup_ctx(
4102 sbio->index = i;
4103 sbio->sctx = sctx;
4104 sbio->page_count = 0;
4105 - btrfs_init_work(&sbio->work, btrfs_scrub_helper,
4106 - scrub_bio_end_io_worker, NULL, NULL);
4107 + btrfs_init_work(&sbio->work, scrub_bio_end_io_worker, NULL,
4108 + NULL);
4109
4110 if (i != SCRUB_BIOS_PER_SCTX - 1)
4111 sctx->bios[i]->next_free = i + 1;
4112 @@ -1720,8 +1720,7 @@ static void scrub_wr_bio_end_io(struct bio *bio)
4113 sbio->status = bio->bi_status;
4114 sbio->bio = bio;
4115
4116 - btrfs_init_work(&sbio->work, btrfs_scrubwrc_helper,
4117 - scrub_wr_bio_end_io_worker, NULL, NULL);
4118 + btrfs_init_work(&sbio->work, scrub_wr_bio_end_io_worker, NULL, NULL);
4119 btrfs_queue_work(fs_info->scrub_wr_completion_workers, &sbio->work);
4120 }
4121
4122 @@ -2203,8 +2202,7 @@ static void scrub_missing_raid56_pages(struct scrub_block *sblock)
4123 raid56_add_scrub_pages(rbio, spage->page, spage->logical);
4124 }
4125
4126 - btrfs_init_work(&sblock->work, btrfs_scrub_helper,
4127 - scrub_missing_raid56_worker, NULL, NULL);
4128 + btrfs_init_work(&sblock->work, scrub_missing_raid56_worker, NULL, NULL);
4129 scrub_block_get(sblock);
4130 scrub_pending_bio_inc(sctx);
4131 raid56_submit_missing_rbio(rbio);
4132 @@ -2742,8 +2740,8 @@ static void scrub_parity_bio_endio(struct bio *bio)
4133
4134 bio_put(bio);
4135
4136 - btrfs_init_work(&sparity->work, btrfs_scrubparity_helper,
4137 - scrub_parity_bio_endio_worker, NULL, NULL);
4138 + btrfs_init_work(&sparity->work, scrub_parity_bio_endio_worker, NULL,
4139 + NULL);
4140 btrfs_queue_work(fs_info->scrub_parity_workers, &sparity->work);
4141 }
4142
4143 diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
4144 index e04409f85063..d8d7b1ee83ca 100644
4145 --- a/fs/btrfs/volumes.c
4146 +++ b/fs/btrfs/volumes.c
4147 @@ -6676,8 +6676,7 @@ struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info,
4148 else
4149 generate_random_uuid(dev->uuid);
4150
4151 - btrfs_init_work(&dev->work, btrfs_submit_helper,
4152 - pending_bios_fn, NULL, NULL);
4153 + btrfs_init_work(&dev->work, pending_bios_fn, NULL, NULL);
4154
4155 return dev;
4156 }
4157 diff --git a/fs/buffer.c b/fs/buffer.c
4158 index 86a38b979323..7744488f7bde 100644
4159 --- a/fs/buffer.c
4160 +++ b/fs/buffer.c
4161 @@ -2994,8 +2994,6 @@ static void end_bio_bh_io_sync(struct bio *bio)
4162 void guard_bio_eod(int op, struct bio *bio)
4163 {
4164 sector_t maxsector;
4165 - struct bio_vec *bvec = bio_last_bvec_all(bio);
4166 - unsigned truncated_bytes;
4167 struct hd_struct *part;
4168
4169 rcu_read_lock();
4170 @@ -3021,28 +3019,7 @@ void guard_bio_eod(int op, struct bio *bio)
4171 if (likely((bio->bi_iter.bi_size >> 9) <= maxsector))
4172 return;
4173
4174 - /* Uhhuh. We've got a bio that straddles the device size! */
4175 - truncated_bytes = bio->bi_iter.bi_size - (maxsector << 9);
4176 -
4177 - /*
4178 - * The bio contains more than one segment which spans EOD, just return
4179 - * and let IO layer turn it into an EIO
4180 - */
4181 - if (truncated_bytes > bvec->bv_len)
4182 - return;
4183 -
4184 - /* Truncate the bio.. */
4185 - bio->bi_iter.bi_size -= truncated_bytes;
4186 - bvec->bv_len -= truncated_bytes;
4187 -
4188 - /* ..and clear the end of the buffer for reads */
4189 - if (op == REQ_OP_READ) {
4190 - struct bio_vec bv;
4191 -
4192 - mp_bvec_last_segment(bvec, &bv);
4193 - zero_user(bv.bv_page, bv.bv_offset + bv.bv_len,
4194 - truncated_bytes);
4195 - }
4196 + bio_truncate(bio, maxsector << 9);
4197 }
4198
4199 static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
4200 diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c
4201 index 1692c0c6c23a..2faa05860a48 100644
4202 --- a/fs/cifs/dfs_cache.c
4203 +++ b/fs/cifs/dfs_cache.c
4204 @@ -1317,7 +1317,6 @@ static struct cifs_ses *find_root_ses(struct dfs_cache_vol_info *vi,
4205 int rc;
4206 struct dfs_info3_param ref = {0};
4207 char *mdata = NULL, *devname = NULL;
4208 - bool is_smb3 = tcon->ses->server->vals->header_preamble_size == 0;
4209 struct TCP_Server_Info *server;
4210 struct cifs_ses *ses;
4211 struct smb_vol vol;
4212 @@ -1344,7 +1343,7 @@ static struct cifs_ses *find_root_ses(struct dfs_cache_vol_info *vi,
4213 goto out;
4214 }
4215
4216 - rc = cifs_setup_volume_info(&vol, mdata, devname, is_smb3);
4217 + rc = cifs_setup_volume_info(&vol, mdata, devname, false);
4218 kfree(devname);
4219
4220 if (rc) {
4221 diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
4222 index df9377828e2f..ed59e4a8db59 100644
4223 --- a/fs/cifs/inode.c
4224 +++ b/fs/cifs/inode.c
4225 @@ -163,7 +163,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
4226
4227 spin_lock(&inode->i_lock);
4228 /* we do not want atime to be less than mtime, it broke some apps */
4229 - if (timespec64_compare(&fattr->cf_atime, &fattr->cf_mtime))
4230 + if (timespec64_compare(&fattr->cf_atime, &fattr->cf_mtime) < 0)
4231 inode->i_atime = fattr->cf_mtime;
4232 else
4233 inode->i_atime = fattr->cf_atime;
4234 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
4235 index c985caa2d955..e1d8cec6ba2e 100644
4236 --- a/fs/cifs/smb2pdu.c
4237 +++ b/fs/cifs/smb2pdu.c
4238 @@ -252,7 +252,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon)
4239 if (tcon == NULL)
4240 return 0;
4241
4242 - if (smb2_command == SMB2_TREE_CONNECT || smb2_command == SMB2_IOCTL)
4243 + if (smb2_command == SMB2_TREE_CONNECT)
4244 return 0;
4245
4246 if (tcon->tidStatus == CifsExiting) {
4247 @@ -426,16 +426,9 @@ fill_small_buf(__le16 smb2_command, struct cifs_tcon *tcon, void *buf,
4248 * SMB information in the SMB header. If the return code is zero, this
4249 * function must have filled in request_buf pointer.
4250 */
4251 -static int
4252 -smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
4253 - void **request_buf, unsigned int *total_len)
4254 +static int __smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
4255 + void **request_buf, unsigned int *total_len)
4256 {
4257 - int rc;
4258 -
4259 - rc = smb2_reconnect(smb2_command, tcon);
4260 - if (rc)
4261 - return rc;
4262 -
4263 /* BB eventually switch this to SMB2 specific small buf size */
4264 if (smb2_command == SMB2_SET_INFO)
4265 *request_buf = cifs_buf_get();
4266 @@ -456,7 +449,31 @@ smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
4267 cifs_stats_inc(&tcon->num_smbs_sent);
4268 }
4269
4270 - return rc;
4271 + return 0;
4272 +}
4273 +
4274 +static int smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
4275 + void **request_buf, unsigned int *total_len)
4276 +{
4277 + int rc;
4278 +
4279 + rc = smb2_reconnect(smb2_command, tcon);
4280 + if (rc)
4281 + return rc;
4282 +
4283 + return __smb2_plain_req_init(smb2_command, tcon, request_buf,
4284 + total_len);
4285 +}
4286 +
4287 +static int smb2_ioctl_req_init(u32 opcode, struct cifs_tcon *tcon,
4288 + void **request_buf, unsigned int *total_len)
4289 +{
4290 + /* Skip reconnect only for FSCTL_VALIDATE_NEGOTIATE_INFO IOCTLs */
4291 + if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO) {
4292 + return __smb2_plain_req_init(SMB2_IOCTL, tcon, request_buf,
4293 + total_len);
4294 + }
4295 + return smb2_plain_req_init(SMB2_IOCTL, tcon, request_buf, total_len);
4296 }
4297
4298 /* For explanation of negotiate contexts see MS-SMB2 section 2.2.3.1 */
4299 @@ -2661,7 +2678,7 @@ SMB2_ioctl_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,
4300 int rc;
4301 char *in_data_buf;
4302
4303 - rc = smb2_plain_req_init(SMB2_IOCTL, tcon, (void **) &req, &total_len);
4304 + rc = smb2_ioctl_req_init(opcode, tcon, (void **) &req, &total_len);
4305 if (rc)
4306 return rc;
4307
4308 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
4309 index a7ec2d3dff92..e0226b2138d6 100644
4310 --- a/fs/compat_ioctl.c
4311 +++ b/fs/compat_ioctl.c
4312 @@ -1032,10 +1032,11 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
4313 #endif
4314
4315 case FICLONE:
4316 + goto do_ioctl;
4317 case FICLONERANGE:
4318 case FIDEDUPERANGE:
4319 case FS_IOC_FIEMAP:
4320 - goto do_ioctl;
4321 + goto found_handler;
4322
4323 case FIBMAP:
4324 case FIGETBSZ:
4325 diff --git a/fs/io_uring.c b/fs/io_uring.c
4326 index 74e786578c77..a60c6315a348 100644
4327 --- a/fs/io_uring.c
4328 +++ b/fs/io_uring.c
4329 @@ -239,7 +239,7 @@ struct io_ring_ctx {
4330
4331 struct user_struct *user;
4332
4333 - struct cred *creds;
4334 + const struct cred *creds;
4335
4336 struct completion ctx_done;
4337
4338 @@ -3876,7 +3876,7 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p)
4339 ctx->account_mem = account_mem;
4340 ctx->user = user;
4341
4342 - ctx->creds = prepare_creds();
4343 + ctx->creds = get_current_cred();
4344 if (!ctx->creds) {
4345 ret = -ENOMEM;
4346 goto err;
4347 diff --git a/fs/locks.c b/fs/locks.c
4348 index 6970f55daf54..44b6da032842 100644
4349 --- a/fs/locks.c
4350 +++ b/fs/locks.c
4351 @@ -2853,7 +2853,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
4352 }
4353 if (inode) {
4354 /* userspace relies on this representation of dev_t */
4355 - seq_printf(f, "%d %02x:%02x:%ld ", fl_pid,
4356 + seq_printf(f, "%d %02x:%02x:%lu ", fl_pid,
4357 MAJOR(inode->i_sb->s_dev),
4358 MINOR(inode->i_sb->s_dev), inode->i_ino);
4359 } else {
4360 diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
4361 index c65aeaa812d4..08f6eb2b73f8 100644
4362 --- a/fs/nfsd/nfs4state.c
4363 +++ b/fs/nfsd/nfs4state.c
4364 @@ -3548,12 +3548,17 @@ static bool replay_matches_cache(struct svc_rqst *rqstp,
4365 (bool)seq->cachethis)
4366 return false;
4367 /*
4368 - * If there's an error than the reply can have fewer ops than
4369 - * the call. But if we cached a reply with *more* ops than the
4370 - * call you're sending us now, then this new call is clearly not
4371 - * really a replay of the old one:
4372 + * If there's an error then the reply can have fewer ops than
4373 + * the call.
4374 */
4375 - if (slot->sl_opcnt < argp->opcnt)
4376 + if (slot->sl_opcnt < argp->opcnt && !slot->sl_status)
4377 + return false;
4378 + /*
4379 + * But if we cached a reply with *more* ops than the call you're
4380 + * sending us now, then this new call is clearly not really a
4381 + * replay of the old one:
4382 + */
4383 + if (slot->sl_opcnt > argp->opcnt)
4384 return false;
4385 /* This is the only check explicitly called by spec: */
4386 if (!same_creds(&rqstp->rq_cred, &slot->sl_cred))
4387 diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
4388 index 6e774c5ea13b..8a2e284ccfcd 100644
4389 --- a/fs/ocfs2/dlmglue.c
4390 +++ b/fs/ocfs2/dlmglue.c
4391 @@ -3282,6 +3282,7 @@ static void ocfs2_dlm_init_debug(struct ocfs2_super *osb)
4392
4393 debugfs_create_u32("locking_filter", 0600, osb->osb_debug_root,
4394 &dlm_debug->d_filter_secs);
4395 + ocfs2_get_dlm_debug(dlm_debug);
4396 }
4397
4398 static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb)
4399 diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
4400 index 8caff834f002..487ee39b438a 100644
4401 --- a/fs/pstore/ram.c
4402 +++ b/fs/pstore/ram.c
4403 @@ -407,6 +407,17 @@ static int notrace ramoops_pstore_write(struct pstore_record *record)
4404
4405 prz = cxt->dprzs[cxt->dump_write_cnt];
4406
4407 + /*
4408 + * Since this is a new crash dump, we need to reset the buffer in
4409 + * case it still has an old dump present. Without this, the new dump
4410 + * will get appended, which would seriously confuse anything trying
4411 + * to check dump file contents. Specifically, ramoops_read_kmsg_hdr()
4412 + * expects to find a dump header in the beginning of buffer data, so
4413 + * we must to reset the buffer values, in order to ensure that the
4414 + * header will be written to the beginning of the buffer.
4415 + */
4416 + persistent_ram_zap(prz);
4417 +
4418 /* Build header and append record contents. */
4419 hlen = ramoops_write_kmsg_hdr(prz, record);
4420 if (!hlen)
4421 @@ -577,6 +588,7 @@ static int ramoops_init_przs(const char *name,
4422 dev_err(dev, "failed to request %s mem region (0x%zx@0x%llx): %d\n",
4423 name, record_size,
4424 (unsigned long long)*paddr, err);
4425 + kfree(label);
4426
4427 while (i > 0) {
4428 i--;
4429 @@ -622,6 +634,7 @@ static int ramoops_init_prz(const char *name,
4430
4431 dev_err(dev, "failed to request %s mem region (0x%zx@0x%llx): %d\n",
4432 name, sz, (unsigned long long)*paddr, err);
4433 + kfree(label);
4434 return err;
4435 }
4436
4437 diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
4438 index a384a0f9ff32..234be1c4dc87 100644
4439 --- a/fs/ubifs/tnc_commit.c
4440 +++ b/fs/ubifs/tnc_commit.c
4441 @@ -212,7 +212,7 @@ static int is_idx_node_in_use(struct ubifs_info *c, union ubifs_key *key,
4442 /**
4443 * layout_leb_in_gaps - layout index nodes using in-the-gaps method.
4444 * @c: UBIFS file-system description object
4445 - * @p: return LEB number here
4446 + * @p: return LEB number in @c->gap_lebs[p]
4447 *
4448 * This function lays out new index nodes for dirty znodes using in-the-gaps
4449 * method of TNC commit.
4450 @@ -221,7 +221,7 @@ static int is_idx_node_in_use(struct ubifs_info *c, union ubifs_key *key,
4451 * This function returns the number of index nodes written into the gaps, or a
4452 * negative error code on failure.
4453 */
4454 -static int layout_leb_in_gaps(struct ubifs_info *c, int *p)
4455 +static int layout_leb_in_gaps(struct ubifs_info *c, int p)
4456 {
4457 struct ubifs_scan_leb *sleb;
4458 struct ubifs_scan_node *snod;
4459 @@ -236,7 +236,7 @@ static int layout_leb_in_gaps(struct ubifs_info *c, int *p)
4460 * filled, however we do not check there at present.
4461 */
4462 return lnum; /* Error code */
4463 - *p = lnum;
4464 + c->gap_lebs[p] = lnum;
4465 dbg_gc("LEB %d", lnum);
4466 /*
4467 * Scan the index LEB. We use the generic scan for this even though
4468 @@ -355,7 +355,7 @@ static int get_leb_cnt(struct ubifs_info *c, int cnt)
4469 */
4470 static int layout_in_gaps(struct ubifs_info *c, int cnt)
4471 {
4472 - int err, leb_needed_cnt, written, *p;
4473 + int err, leb_needed_cnt, written, p = 0, old_idx_lebs, *gap_lebs;
4474
4475 dbg_gc("%d znodes to write", cnt);
4476
4477 @@ -364,9 +364,9 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt)
4478 if (!c->gap_lebs)
4479 return -ENOMEM;
4480
4481 - p = c->gap_lebs;
4482 + old_idx_lebs = c->lst.idx_lebs;
4483 do {
4484 - ubifs_assert(c, p < c->gap_lebs + c->lst.idx_lebs);
4485 + ubifs_assert(c, p < c->lst.idx_lebs);
4486 written = layout_leb_in_gaps(c, p);
4487 if (written < 0) {
4488 err = written;
4489 @@ -392,9 +392,29 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt)
4490 leb_needed_cnt = get_leb_cnt(c, cnt);
4491 dbg_gc("%d znodes remaining, need %d LEBs, have %d", cnt,
4492 leb_needed_cnt, c->ileb_cnt);
4493 + /*
4494 + * Dynamically change the size of @c->gap_lebs to prevent
4495 + * oob, because @c->lst.idx_lebs could be increased by
4496 + * function @get_idx_gc_leb (called by layout_leb_in_gaps->
4497 + * ubifs_find_dirty_idx_leb) during loop. Only enlarge
4498 + * @c->gap_lebs when needed.
4499 + *
4500 + */
4501 + if (leb_needed_cnt > c->ileb_cnt && p >= old_idx_lebs &&
4502 + old_idx_lebs < c->lst.idx_lebs) {
4503 + old_idx_lebs = c->lst.idx_lebs;
4504 + gap_lebs = krealloc(c->gap_lebs, sizeof(int) *
4505 + (old_idx_lebs + 1), GFP_NOFS);
4506 + if (!gap_lebs) {
4507 + kfree(c->gap_lebs);
4508 + c->gap_lebs = NULL;
4509 + return -ENOMEM;
4510 + }
4511 + c->gap_lebs = gap_lebs;
4512 + }
4513 } while (leb_needed_cnt > c->ileb_cnt);
4514
4515 - *p = -1;
4516 + c->gap_lebs[p] = -1;
4517 return 0;
4518 }
4519
4520 diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
4521 index 02469d59c787..3f76da11197c 100644
4522 --- a/fs/xfs/libxfs/xfs_bmap.c
4523 +++ b/fs/xfs/libxfs/xfs_bmap.c
4524 @@ -5300,7 +5300,7 @@ __xfs_bunmapi(
4525 * Make sure we don't touch multiple AGF headers out of order
4526 * in a single transaction, as that could cause AB-BA deadlocks.
4527 */
4528 - if (!wasdel) {
4529 + if (!wasdel && !isrt) {
4530 agno = XFS_FSB_TO_AGNO(mp, del.br_startblock);
4531 if (prev_agno != NULLAGNUMBER && prev_agno > agno)
4532 break;
4533 diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h
4534 index 003a772cd26c..2e50d146105d 100644
4535 --- a/fs/xfs/scrub/common.h
4536 +++ b/fs/xfs/scrub/common.h
4537 @@ -14,8 +14,15 @@
4538 static inline bool
4539 xchk_should_terminate(
4540 struct xfs_scrub *sc,
4541 - int *error)
4542 + int *error)
4543 {
4544 + /*
4545 + * If preemption is disabled, we need to yield to the scheduler every
4546 + * few seconds so that we don't run afoul of the soft lockup watchdog
4547 + * or RCU stall detector.
4548 + */
4549 + cond_resched();
4550 +
4551 if (fatal_signal_pending(current)) {
4552 if (*error == 0)
4553 *error = -EAGAIN;
4554 diff --git a/include/linux/ahci_platform.h b/include/linux/ahci_platform.h
4555 index 6782f0d45ebe..49e5383d4222 100644
4556 --- a/include/linux/ahci_platform.h
4557 +++ b/include/linux/ahci_platform.h
4558 @@ -19,6 +19,8 @@ struct ahci_host_priv;
4559 struct platform_device;
4560 struct scsi_host_template;
4561
4562 +int ahci_platform_enable_phys(struct ahci_host_priv *hpriv);
4563 +void ahci_platform_disable_phys(struct ahci_host_priv *hpriv);
4564 int ahci_platform_enable_clks(struct ahci_host_priv *hpriv);
4565 void ahci_platform_disable_clks(struct ahci_host_priv *hpriv);
4566 int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv);
4567 diff --git a/include/linux/bio.h b/include/linux/bio.h
4568 index 3cdb84cdc488..853d92ceee64 100644
4569 --- a/include/linux/bio.h
4570 +++ b/include/linux/bio.h
4571 @@ -470,6 +470,7 @@ extern struct bio *bio_copy_user_iov(struct request_queue *,
4572 gfp_t);
4573 extern int bio_uncopy_user(struct bio *);
4574 void zero_fill_bio_iter(struct bio *bio, struct bvec_iter iter);
4575 +void bio_truncate(struct bio *bio, unsigned new_size);
4576
4577 static inline void zero_fill_bio(struct bio *bio)
4578 {
4579 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
4580 index 8fcdee1c0cf9..dad4a68fa009 100644
4581 --- a/include/linux/dmaengine.h
4582 +++ b/include/linux/dmaengine.h
4583 @@ -1364,8 +1364,11 @@ static inline int dma_get_slave_caps(struct dma_chan *chan,
4584 static inline int dmaengine_desc_set_reuse(struct dma_async_tx_descriptor *tx)
4585 {
4586 struct dma_slave_caps caps;
4587 + int ret;
4588
4589 - dma_get_slave_caps(tx->chan, &caps);
4590 + ret = dma_get_slave_caps(tx->chan, &caps);
4591 + if (ret)
4592 + return ret;
4593
4594 if (caps.descriptor_reuse) {
4595 tx->flags |= DMA_CTRL_REUSE;
4596 diff --git a/include/linux/libata.h b/include/linux/libata.h
4597 index 207e7ee764ce..fa0c3dae2094 100644
4598 --- a/include/linux/libata.h
4599 +++ b/include/linux/libata.h
4600 @@ -1174,6 +1174,7 @@ extern unsigned int ata_do_dev_read_id(struct ata_device *dev,
4601 struct ata_taskfile *tf, u16 *id);
4602 extern void ata_qc_complete(struct ata_queued_cmd *qc);
4603 extern int ata_qc_complete_multiple(struct ata_port *ap, u64 qc_active);
4604 +extern u64 ata_qc_get_active(struct ata_port *ap);
4605 extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd);
4606 extern int ata_std_bios_param(struct scsi_device *sdev,
4607 struct block_device *bdev,
4608 diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
4609 index f46ea71b4ffd..451efd4499cc 100644
4610 --- a/include/linux/memory_hotplug.h
4611 +++ b/include/linux/memory_hotplug.h
4612 @@ -125,8 +125,8 @@ static inline bool movable_node_is_enabled(void)
4613
4614 extern void arch_remove_memory(int nid, u64 start, u64 size,
4615 struct vmem_altmap *altmap);
4616 -extern void __remove_pages(struct zone *zone, unsigned long start_pfn,
4617 - unsigned long nr_pages, struct vmem_altmap *altmap);
4618 +extern void __remove_pages(unsigned long start_pfn, unsigned long nr_pages,
4619 + struct vmem_altmap *altmap);
4620
4621 /* reasonably generic interface to expand the physical pages */
4622 extern int __add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
4623 @@ -345,6 +345,9 @@ extern int add_memory(int nid, u64 start, u64 size);
4624 extern int add_memory_resource(int nid, struct resource *resource);
4625 extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
4626 unsigned long nr_pages, struct vmem_altmap *altmap);
4627 +extern void remove_pfn_range_from_zone(struct zone *zone,
4628 + unsigned long start_pfn,
4629 + unsigned long nr_pages);
4630 extern bool is_memblock_offlined(struct memory_block *mem);
4631 extern int sparse_add_section(int nid, unsigned long pfn,
4632 unsigned long nr_pages, struct vmem_altmap *altmap);
4633 diff --git a/include/linux/nvme-fc-driver.h b/include/linux/nvme-fc-driver.h
4634 index 10f81629b9ce..6d0d70f3219c 100644
4635 --- a/include/linux/nvme-fc-driver.h
4636 +++ b/include/linux/nvme-fc-driver.h
4637 @@ -270,6 +270,8 @@ struct nvme_fc_remote_port {
4638 *
4639 * Host/Initiator Transport Entrypoints/Parameters:
4640 *
4641 + * @module: The LLDD module using the interface
4642 + *
4643 * @localport_delete: The LLDD initiates deletion of a localport via
4644 * nvme_fc_deregister_localport(). However, the teardown is
4645 * asynchronous. This routine is called upon the completion of the
4646 @@ -383,6 +385,8 @@ struct nvme_fc_remote_port {
4647 * Value is Mandatory. Allowed to be zero.
4648 */
4649 struct nvme_fc_port_template {
4650 + struct module *module;
4651 +
4652 /* initiator-based functions */
4653 void (*localport_delete)(struct nvme_fc_local_port *);
4654 void (*remoteport_delete)(struct nvme_fc_remote_port *);
4655 diff --git a/include/linux/pci.h b/include/linux/pci.h
4656 index f9088c89a534..be529d311122 100644
4657 --- a/include/linux/pci.h
4658 +++ b/include/linux/pci.h
4659 @@ -2310,9 +2310,11 @@ struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus);
4660
4661 void
4662 pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *));
4663 +bool pci_pr3_present(struct pci_dev *pdev);
4664 #else
4665 static inline struct irq_domain *
4666 pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
4667 +static inline bool pci_pr3_present(struct pci_dev *pdev) { return false; }
4668 #endif
4669
4670 #ifdef CONFIG_EEH
4671 diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h
4672 index 7cf8f797e13a..505e94a6e3e8 100644
4673 --- a/include/linux/regulator/ab8500.h
4674 +++ b/include/linux/regulator/ab8500.h
4675 @@ -37,7 +37,6 @@ enum ab8505_regulator_id {
4676 AB8505_LDO_AUX6,
4677 AB8505_LDO_INTCORE,
4678 AB8505_LDO_ADC,
4679 - AB8505_LDO_USB,
4680 AB8505_LDO_AUDIO,
4681 AB8505_LDO_ANAMIC1,
4682 AB8505_LDO_ANAMIC2,
4683 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
4684 index 5e679c8dae0b..8ec77bfdc1a4 100644
4685 --- a/include/net/neighbour.h
4686 +++ b/include/net/neighbour.h
4687 @@ -467,7 +467,7 @@ static inline int neigh_hh_output(const struct hh_cache *hh, struct sk_buff *skb
4688
4689 do {
4690 seq = read_seqbegin(&hh->hh_lock);
4691 - hh_len = hh->hh_len;
4692 + hh_len = READ_ONCE(hh->hh_len);
4693 if (likely(hh_len <= HH_DATA_MOD)) {
4694 hh_alen = HH_DATA_MOD;
4695
4696 diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
4697 index 47e61956168d..32e418dba133 100644
4698 --- a/include/net/sch_generic.h
4699 +++ b/include/net/sch_generic.h
4700 @@ -149,8 +149,8 @@ static inline bool qdisc_is_percpu_stats(const struct Qdisc *q)
4701 static inline bool qdisc_is_empty(const struct Qdisc *qdisc)
4702 {
4703 if (qdisc_is_percpu_stats(qdisc))
4704 - return qdisc->empty;
4705 - return !qdisc->q.qlen;
4706 + return READ_ONCE(qdisc->empty);
4707 + return !READ_ONCE(qdisc->q.qlen);
4708 }
4709
4710 static inline bool qdisc_run_begin(struct Qdisc *qdisc)
4711 @@ -158,7 +158,7 @@ static inline bool qdisc_run_begin(struct Qdisc *qdisc)
4712 if (qdisc->flags & TCQ_F_NOLOCK) {
4713 if (!spin_trylock(&qdisc->seqlock))
4714 return false;
4715 - qdisc->empty = false;
4716 + WRITE_ONCE(qdisc->empty, false);
4717 } else if (qdisc_is_running(qdisc)) {
4718 return false;
4719 }
4720 diff --git a/include/net/sock.h b/include/net/sock.h
4721 index e09e2886a836..6c5a3809483e 100644
4722 --- a/include/net/sock.h
4723 +++ b/include/net/sock.h
4724 @@ -2589,9 +2589,9 @@ static inline int sk_get_rmem0(const struct sock *sk, const struct proto *proto)
4725 */
4726 static inline void sk_pacing_shift_update(struct sock *sk, int val)
4727 {
4728 - if (!sk || !sk_fullsock(sk) || sk->sk_pacing_shift == val)
4729 + if (!sk || !sk_fullsock(sk) || READ_ONCE(sk->sk_pacing_shift) == val)
4730 return;
4731 - sk->sk_pacing_shift = val;
4732 + WRITE_ONCE(sk->sk_pacing_shift, val);
4733 }
4734
4735 /* if a socket is bound to a device, check that the given device
4736 diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
4737 index 9e7cee5307e0..5c51021775af 100644
4738 --- a/kernel/bpf/verifier.c
4739 +++ b/kernel/bpf/verifier.c
4740 @@ -852,7 +852,8 @@ static const int caller_saved[CALLER_SAVED_REGS] = {
4741 BPF_REG_0, BPF_REG_1, BPF_REG_2, BPF_REG_3, BPF_REG_4, BPF_REG_5
4742 };
4743
4744 -static void __mark_reg_not_init(struct bpf_reg_state *reg);
4745 +static void __mark_reg_not_init(const struct bpf_verifier_env *env,
4746 + struct bpf_reg_state *reg);
4747
4748 /* Mark the unknown part of a register (variable offset or scalar value) as
4749 * known to have the value @imm.
4750 @@ -890,7 +891,7 @@ static void mark_reg_known_zero(struct bpf_verifier_env *env,
4751 verbose(env, "mark_reg_known_zero(regs, %u)\n", regno);
4752 /* Something bad happened, let's kill all regs */
4753 for (regno = 0; regno < MAX_BPF_REG; regno++)
4754 - __mark_reg_not_init(regs + regno);
4755 + __mark_reg_not_init(env, regs + regno);
4756 return;
4757 }
4758 __mark_reg_known_zero(regs + regno);
4759 @@ -999,7 +1000,8 @@ static void __mark_reg_unbounded(struct bpf_reg_state *reg)
4760 }
4761
4762 /* Mark a register as having a completely unknown (scalar) value. */
4763 -static void __mark_reg_unknown(struct bpf_reg_state *reg)
4764 +static void __mark_reg_unknown(const struct bpf_verifier_env *env,
4765 + struct bpf_reg_state *reg)
4766 {
4767 /*
4768 * Clear type, id, off, and union(map_ptr, range) and
4769 @@ -1009,6 +1011,8 @@ static void __mark_reg_unknown(struct bpf_reg_state *reg)
4770 reg->type = SCALAR_VALUE;
4771 reg->var_off = tnum_unknown;
4772 reg->frameno = 0;
4773 + reg->precise = env->subprog_cnt > 1 || !env->allow_ptr_leaks ?
4774 + true : false;
4775 __mark_reg_unbounded(reg);
4776 }
4777
4778 @@ -1019,19 +1023,16 @@ static void mark_reg_unknown(struct bpf_verifier_env *env,
4779 verbose(env, "mark_reg_unknown(regs, %u)\n", regno);
4780 /* Something bad happened, let's kill all regs except FP */
4781 for (regno = 0; regno < BPF_REG_FP; regno++)
4782 - __mark_reg_not_init(regs + regno);
4783 + __mark_reg_not_init(env, regs + regno);
4784 return;
4785 }
4786 - regs += regno;
4787 - __mark_reg_unknown(regs);
4788 - /* constant backtracking is enabled for root without bpf2bpf calls */
4789 - regs->precise = env->subprog_cnt > 1 || !env->allow_ptr_leaks ?
4790 - true : false;
4791 + __mark_reg_unknown(env, regs + regno);
4792 }
4793
4794 -static void __mark_reg_not_init(struct bpf_reg_state *reg)
4795 +static void __mark_reg_not_init(const struct bpf_verifier_env *env,
4796 + struct bpf_reg_state *reg)
4797 {
4798 - __mark_reg_unknown(reg);
4799 + __mark_reg_unknown(env, reg);
4800 reg->type = NOT_INIT;
4801 }
4802
4803 @@ -1042,10 +1043,10 @@ static void mark_reg_not_init(struct bpf_verifier_env *env,
4804 verbose(env, "mark_reg_not_init(regs, %u)\n", regno);
4805 /* Something bad happened, let's kill all regs except FP */
4806 for (regno = 0; regno < BPF_REG_FP; regno++)
4807 - __mark_reg_not_init(regs + regno);
4808 + __mark_reg_not_init(env, regs + regno);
4809 return;
4810 }
4811 - __mark_reg_not_init(regs + regno);
4812 + __mark_reg_not_init(env, regs + regno);
4813 }
4814
4815 #define DEF_NOT_SUBREG (0)
4816 @@ -3066,7 +3067,7 @@ static int check_stack_boundary(struct bpf_verifier_env *env, int regno,
4817 }
4818 if (state->stack[spi].slot_type[0] == STACK_SPILL &&
4819 state->stack[spi].spilled_ptr.type == SCALAR_VALUE) {
4820 - __mark_reg_unknown(&state->stack[spi].spilled_ptr);
4821 + __mark_reg_unknown(env, &state->stack[spi].spilled_ptr);
4822 for (j = 0; j < BPF_REG_SIZE; j++)
4823 state->stack[spi].slot_type[j] = STACK_MISC;
4824 goto mark;
4825 @@ -3706,7 +3707,7 @@ static void __clear_all_pkt_pointers(struct bpf_verifier_env *env,
4826 if (!reg)
4827 continue;
4828 if (reg_is_pkt_pointer_any(reg))
4829 - __mark_reg_unknown(reg);
4830 + __mark_reg_unknown(env, reg);
4831 }
4832 }
4833
4834 @@ -3734,7 +3735,7 @@ static void release_reg_references(struct bpf_verifier_env *env,
4835 if (!reg)
4836 continue;
4837 if (reg->ref_obj_id == ref_obj_id)
4838 - __mark_reg_unknown(reg);
4839 + __mark_reg_unknown(env, reg);
4840 }
4841 }
4842
4843 @@ -4357,7 +4358,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env,
4844 /* Taint dst register if offset had invalid bounds derived from
4845 * e.g. dead branches.
4846 */
4847 - __mark_reg_unknown(dst_reg);
4848 + __mark_reg_unknown(env, dst_reg);
4849 return 0;
4850 }
4851
4852 @@ -4609,13 +4610,13 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env,
4853 /* Taint dst register if offset had invalid bounds derived from
4854 * e.g. dead branches.
4855 */
4856 - __mark_reg_unknown(dst_reg);
4857 + __mark_reg_unknown(env, dst_reg);
4858 return 0;
4859 }
4860
4861 if (!src_known &&
4862 opcode != BPF_ADD && opcode != BPF_SUB && opcode != BPF_AND) {
4863 - __mark_reg_unknown(dst_reg);
4864 + __mark_reg_unknown(env, dst_reg);
4865 return 0;
4866 }
4867
4868 @@ -6746,7 +6747,7 @@ static void clean_func_state(struct bpf_verifier_env *env,
4869 /* since the register is unused, clear its state
4870 * to make further comparison simpler
4871 */
4872 - __mark_reg_not_init(&st->regs[i]);
4873 + __mark_reg_not_init(env, &st->regs[i]);
4874 }
4875
4876 for (i = 0; i < st->allocated_stack / BPF_REG_SIZE; i++) {
4877 @@ -6754,7 +6755,7 @@ static void clean_func_state(struct bpf_verifier_env *env,
4878 /* liveness must not touch this stack slot anymore */
4879 st->stack[i].spilled_ptr.live |= REG_LIVE_DONE;
4880 if (!(live & REG_LIVE_READ)) {
4881 - __mark_reg_not_init(&st->stack[i].spilled_ptr);
4882 + __mark_reg_not_init(env, &st->stack[i].spilled_ptr);
4883 for (j = 0; j < BPF_REG_SIZE; j++)
4884 st->stack[i].slot_type[j] = STACK_INVALID;
4885 }
4886 diff --git a/kernel/cred.c b/kernel/cred.c
4887 index c0a4c12d38b2..9ed51b70ed80 100644
4888 --- a/kernel/cred.c
4889 +++ b/kernel/cred.c
4890 @@ -223,7 +223,7 @@ struct cred *cred_alloc_blank(void)
4891 new->magic = CRED_MAGIC;
4892 #endif
4893
4894 - if (security_cred_alloc_blank(new, GFP_KERNEL) < 0)
4895 + if (security_cred_alloc_blank(new, GFP_KERNEL_ACCOUNT) < 0)
4896 goto error;
4897
4898 return new;
4899 @@ -282,7 +282,7 @@ struct cred *prepare_creds(void)
4900 new->security = NULL;
4901 #endif
4902
4903 - if (security_prepare_creds(new, old, GFP_KERNEL) < 0)
4904 + if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0)
4905 goto error;
4906 validate_creds(new);
4907 return new;
4908 @@ -715,7 +715,7 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon)
4909 #ifdef CONFIG_SECURITY
4910 new->security = NULL;
4911 #endif
4912 - if (security_prepare_creds(new, old, GFP_KERNEL) < 0)
4913 + if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0)
4914 goto error;
4915
4916 put_cred(old);
4917 diff --git a/kernel/exit.c b/kernel/exit.c
4918 index d351fd09e739..22dfaac9e48c 100644
4919 --- a/kernel/exit.c
4920 +++ b/kernel/exit.c
4921 @@ -517,10 +517,6 @@ static struct task_struct *find_child_reaper(struct task_struct *father,
4922 }
4923
4924 write_unlock_irq(&tasklist_lock);
4925 - if (unlikely(pid_ns == &init_pid_ns)) {
4926 - panic("Attempted to kill init! exitcode=0x%08x\n",
4927 - father->signal->group_exit_code ?: father->exit_code);
4928 - }
4929
4930 list_for_each_entry_safe(p, n, dead, ptrace_entry) {
4931 list_del_init(&p->ptrace_entry);
4932 @@ -766,6 +762,14 @@ void __noreturn do_exit(long code)
4933 acct_update_integrals(tsk);
4934 group_dead = atomic_dec_and_test(&tsk->signal->live);
4935 if (group_dead) {
4936 + /*
4937 + * If the last thread of global init has exited, panic
4938 + * immediately to get a useable coredump.
4939 + */
4940 + if (unlikely(is_global_init(tsk)))
4941 + panic("Attempted to kill init! exitcode=0x%08x\n",
4942 + tsk->signal->group_exit_code ?: (int)code);
4943 +
4944 #ifdef CONFIG_POSIX_TIMERS
4945 hrtimer_cancel(&tsk->signal->real_timer);
4946 exit_itimers(tsk->signal);
4947 diff --git a/kernel/module.c b/kernel/module.c
4948 index ff2d7359a418..cb09a5f37a5f 100644
4949 --- a/kernel/module.c
4950 +++ b/kernel/module.c
4951 @@ -1033,6 +1033,8 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
4952 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module));
4953
4954 free_module(mod);
4955 + /* someone could wait for the module in add_unformed_module() */
4956 + wake_up_all(&module_wq);
4957 return 0;
4958 out:
4959 mutex_unlock(&module_mutex);
4960 diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
4961 index 83105874f255..26b9168321e7 100644
4962 --- a/kernel/power/snapshot.c
4963 +++ b/kernel/power/snapshot.c
4964 @@ -734,8 +734,15 @@ zone_found:
4965 * We have found the zone. Now walk the radix tree to find the leaf node
4966 * for our PFN.
4967 */
4968 +
4969 + /*
4970 + * If the zone we wish to scan is the the current zone and the
4971 + * pfn falls into the current node then we do not need to walk
4972 + * the tree.
4973 + */
4974 node = bm->cur.node;
4975 - if (((pfn - zone->start_pfn) & ~BM_BLOCK_MASK) == bm->cur.node_pfn)
4976 + if (zone == bm->cur.zone &&
4977 + ((pfn - zone->start_pfn) & ~BM_BLOCK_MASK) == bm->cur.node_pfn)
4978 goto node_found;
4979
4980 node = zone->rtree;
4981 diff --git a/kernel/seccomp.c b/kernel/seccomp.c
4982 index dba52a7db5e8..614a557a0814 100644
4983 --- a/kernel/seccomp.c
4984 +++ b/kernel/seccomp.c
4985 @@ -1015,6 +1015,13 @@ static long seccomp_notify_recv(struct seccomp_filter *filter,
4986 struct seccomp_notif unotif;
4987 ssize_t ret;
4988
4989 + /* Verify that we're not given garbage to keep struct extensible. */
4990 + ret = check_zeroed_user(buf, sizeof(unotif));
4991 + if (ret < 0)
4992 + return ret;
4993 + if (!ret)
4994 + return -EINVAL;
4995 +
4996 memset(&unotif, 0, sizeof(unotif));
4997
4998 ret = down_interruptible(&filter->notif->request);
4999 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
5000 index 13a0f2e6ebc2..e2ac0e37c4ae 100644
5001 --- a/kernel/taskstats.c
5002 +++ b/kernel/taskstats.c
5003 @@ -554,25 +554,33 @@ static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
5004 static struct taskstats *taskstats_tgid_alloc(struct task_struct *tsk)
5005 {
5006 struct signal_struct *sig = tsk->signal;
5007 - struct taskstats *stats;
5008 + struct taskstats *stats_new, *stats;
5009
5010 - if (sig->stats || thread_group_empty(tsk))
5011 - goto ret;
5012 + /* Pairs with smp_store_release() below. */
5013 + stats = smp_load_acquire(&sig->stats);
5014 + if (stats || thread_group_empty(tsk))
5015 + return stats;
5016
5017 /* No problem if kmem_cache_zalloc() fails */
5018 - stats = kmem_cache_zalloc(taskstats_cache, GFP_KERNEL);
5019 + stats_new = kmem_cache_zalloc(taskstats_cache, GFP_KERNEL);
5020
5021 spin_lock_irq(&tsk->sighand->siglock);
5022 - if (!sig->stats) {
5023 - sig->stats = stats;
5024 - stats = NULL;
5025 + stats = sig->stats;
5026 + if (!stats) {
5027 + /*
5028 + * Pairs with smp_store_release() above and order the
5029 + * kmem_cache_zalloc().
5030 + */
5031 + smp_store_release(&sig->stats, stats_new);
5032 + stats = stats_new;
5033 + stats_new = NULL;
5034 }
5035 spin_unlock_irq(&tsk->sighand->siglock);
5036
5037 - if (stats)
5038 - kmem_cache_free(taskstats_cache, stats);
5039 -ret:
5040 - return sig->stats;
5041 + if (stats_new)
5042 + kmem_cache_free(taskstats_cache, stats_new);
5043 +
5044 + return stats;
5045 }
5046
5047 /* Send pid data out on exit */
5048 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
5049 index f296d89be757..0708a41cfe2d 100644
5050 --- a/kernel/trace/ftrace.c
5051 +++ b/kernel/trace/ftrace.c
5052 @@ -524,8 +524,7 @@ static int function_stat_show(struct seq_file *m, void *v)
5053 }
5054
5055 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
5056 - avg = rec->time;
5057 - do_div(avg, rec->counter);
5058 + avg = div64_ul(rec->time, rec->counter);
5059 if (tracing_thresh && (avg < tracing_thresh))
5060 goto out;
5061 #endif
5062 @@ -551,7 +550,8 @@ static int function_stat_show(struct seq_file *m, void *v)
5063 * Divide only 1000 for ns^2 -> us^2 conversion.
5064 * trace_print_graph_duration will divide 1000 again.
5065 */
5066 - do_div(stddev, rec->counter * (rec->counter - 1) * 1000);
5067 + stddev = div64_ul(stddev,
5068 + rec->counter * (rec->counter - 1) * 1000);
5069 }
5070
5071 trace_seq_init(&s);
5072 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
5073 index 2fa72419bbd7..d8bd9b1d8bce 100644
5074 --- a/kernel/trace/trace.c
5075 +++ b/kernel/trace/trace.c
5076 @@ -4590,6 +4590,10 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
5077
5078 int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
5079 {
5080 + if ((mask == TRACE_ITER_RECORD_TGID) ||
5081 + (mask == TRACE_ITER_RECORD_CMD))
5082 + lockdep_assert_held(&event_mutex);
5083 +
5084 /* do nothing if flag is already set */
5085 if (!!(tr->trace_flags & mask) == !!enabled)
5086 return 0;
5087 @@ -4657,6 +4661,7 @@ static int trace_set_options(struct trace_array *tr, char *option)
5088
5089 cmp += len;
5090
5091 + mutex_lock(&event_mutex);
5092 mutex_lock(&trace_types_lock);
5093
5094 ret = match_string(trace_options, -1, cmp);
5095 @@ -4667,6 +4672,7 @@ static int trace_set_options(struct trace_array *tr, char *option)
5096 ret = set_tracer_flag(tr, 1 << ret, !neg);
5097
5098 mutex_unlock(&trace_types_lock);
5099 + mutex_unlock(&event_mutex);
5100
5101 /*
5102 * If the first trailing whitespace is replaced with '\0' by strstrip,
5103 @@ -7972,9 +7978,11 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
5104 if (val != 0 && val != 1)
5105 return -EINVAL;
5106
5107 + mutex_lock(&event_mutex);
5108 mutex_lock(&trace_types_lock);
5109 ret = set_tracer_flag(tr, 1 << index, val);
5110 mutex_unlock(&trace_types_lock);
5111 + mutex_unlock(&event_mutex);
5112
5113 if (ret < 0)
5114 return ret;
5115 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
5116 index fba87d10f0c1..995061bb2dec 100644
5117 --- a/kernel/trace/trace_events.c
5118 +++ b/kernel/trace/trace_events.c
5119 @@ -320,7 +320,8 @@ void trace_event_enable_cmd_record(bool enable)
5120 struct trace_event_file *file;
5121 struct trace_array *tr;
5122
5123 - mutex_lock(&event_mutex);
5124 + lockdep_assert_held(&event_mutex);
5125 +
5126 do_for_each_event_file(tr, file) {
5127
5128 if (!(file->flags & EVENT_FILE_FL_ENABLED))
5129 @@ -334,7 +335,6 @@ void trace_event_enable_cmd_record(bool enable)
5130 clear_bit(EVENT_FILE_FL_RECORDED_CMD_BIT, &file->flags);
5131 }
5132 } while_for_each_event_file();
5133 - mutex_unlock(&event_mutex);
5134 }
5135
5136 void trace_event_enable_tgid_record(bool enable)
5137 @@ -342,7 +342,8 @@ void trace_event_enable_tgid_record(bool enable)
5138 struct trace_event_file *file;
5139 struct trace_array *tr;
5140
5141 - mutex_lock(&event_mutex);
5142 + lockdep_assert_held(&event_mutex);
5143 +
5144 do_for_each_event_file(tr, file) {
5145 if (!(file->flags & EVENT_FILE_FL_ENABLED))
5146 continue;
5147 @@ -356,7 +357,6 @@ void trace_event_enable_tgid_record(bool enable)
5148 &file->flags);
5149 }
5150 } while_for_each_event_file();
5151 - mutex_unlock(&event_mutex);
5152 }
5153
5154 static int __ftrace_event_enable_disable(struct trace_event_file *file,
5155 diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
5156 index c9a74f82b14a..bf44f6bbd0c3 100644
5157 --- a/kernel/trace/trace_events_filter.c
5158 +++ b/kernel/trace/trace_events_filter.c
5159 @@ -1662,7 +1662,7 @@ static int process_system_preds(struct trace_subsystem_dir *dir,
5160 parse_error(pe, FILT_ERR_BAD_SUBSYS_FILTER, 0);
5161 return -EINVAL;
5162 fail_mem:
5163 - kfree(filter);
5164 + __free_filter(filter);
5165 /* If any call succeeded, we still need to sync */
5166 if (!fail)
5167 tracepoint_synchronize_unregister();
5168 diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
5169 index 7482a1466ebf..c2783915600c 100644
5170 --- a/kernel/trace/trace_events_hist.c
5171 +++ b/kernel/trace/trace_events_hist.c
5172 @@ -911,7 +911,26 @@ static notrace void trace_event_raw_event_synth(void *__data,
5173 strscpy(str_field, str_val, STR_VAR_LEN_MAX);
5174 n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
5175 } else {
5176 - entry->fields[n_u64] = var_ref_vals[var_ref_idx + i];
5177 + struct synth_field *field = event->fields[i];
5178 + u64 val = var_ref_vals[var_ref_idx + i];
5179 +
5180 + switch (field->size) {
5181 + case 1:
5182 + *(u8 *)&entry->fields[n_u64] = (u8)val;
5183 + break;
5184 +
5185 + case 2:
5186 + *(u16 *)&entry->fields[n_u64] = (u16)val;
5187 + break;
5188 +
5189 + case 4:
5190 + *(u32 *)&entry->fields[n_u64] = (u32)val;
5191 + break;
5192 +
5193 + default:
5194 + entry->fields[n_u64] = val;
5195 + break;
5196 + }
5197 n_u64++;
5198 }
5199 }
5200 diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c
5201 index 9a1c22310323..9e31bfc818ff 100644
5202 --- a/kernel/trace/tracing_map.c
5203 +++ b/kernel/trace/tracing_map.c
5204 @@ -148,8 +148,8 @@ static int tracing_map_cmp_atomic64(void *val_a, void *val_b)
5205 #define DEFINE_TRACING_MAP_CMP_FN(type) \
5206 static int tracing_map_cmp_##type(void *val_a, void *val_b) \
5207 { \
5208 - type a = *(type *)val_a; \
5209 - type b = *(type *)val_b; \
5210 + type a = (type)(*(u64 *)val_a); \
5211 + type b = (type)(*(u64 *)val_b); \
5212 \
5213 return (a > b) ? 1 : ((a < b) ? -1 : 0); \
5214 }
5215 diff --git a/lib/ubsan.c b/lib/ubsan.c
5216 index 0c4681118fcd..f007a406f89c 100644
5217 --- a/lib/ubsan.c
5218 +++ b/lib/ubsan.c
5219 @@ -140,25 +140,21 @@ static void val_to_string(char *str, size_t size, struct type_descriptor *type,
5220 }
5221 }
5222
5223 -static DEFINE_SPINLOCK(report_lock);
5224 -
5225 -static void ubsan_prologue(struct source_location *location,
5226 - unsigned long *flags)
5227 +static void ubsan_prologue(struct source_location *location)
5228 {
5229 current->in_ubsan++;
5230 - spin_lock_irqsave(&report_lock, *flags);
5231
5232 pr_err("========================================"
5233 "========================================\n");
5234 print_source_location("UBSAN: Undefined behaviour in", location);
5235 }
5236
5237 -static void ubsan_epilogue(unsigned long *flags)
5238 +static void ubsan_epilogue(void)
5239 {
5240 dump_stack();
5241 pr_err("========================================"
5242 "========================================\n");
5243 - spin_unlock_irqrestore(&report_lock, *flags);
5244 +
5245 current->in_ubsan--;
5246 }
5247
5248 @@ -167,14 +163,13 @@ static void handle_overflow(struct overflow_data *data, void *lhs,
5249 {
5250
5251 struct type_descriptor *type = data->type;
5252 - unsigned long flags;
5253 char lhs_val_str[VALUE_LENGTH];
5254 char rhs_val_str[VALUE_LENGTH];
5255
5256 if (suppress_report(&data->location))
5257 return;
5258
5259 - ubsan_prologue(&data->location, &flags);
5260 + ubsan_prologue(&data->location);
5261
5262 val_to_string(lhs_val_str, sizeof(lhs_val_str), type, lhs);
5263 val_to_string(rhs_val_str, sizeof(rhs_val_str), type, rhs);
5264 @@ -186,7 +181,7 @@ static void handle_overflow(struct overflow_data *data, void *lhs,
5265 rhs_val_str,
5266 type->type_name);
5267
5268 - ubsan_epilogue(&flags);
5269 + ubsan_epilogue();
5270 }
5271
5272 void __ubsan_handle_add_overflow(struct overflow_data *data,
5273 @@ -214,20 +209,19 @@ EXPORT_SYMBOL(__ubsan_handle_mul_overflow);
5274 void __ubsan_handle_negate_overflow(struct overflow_data *data,
5275 void *old_val)
5276 {
5277 - unsigned long flags;
5278 char old_val_str[VALUE_LENGTH];
5279
5280 if (suppress_report(&data->location))
5281 return;
5282
5283 - ubsan_prologue(&data->location, &flags);
5284 + ubsan_prologue(&data->location);
5285
5286 val_to_string(old_val_str, sizeof(old_val_str), data->type, old_val);
5287
5288 pr_err("negation of %s cannot be represented in type %s:\n",
5289 old_val_str, data->type->type_name);
5290
5291 - ubsan_epilogue(&flags);
5292 + ubsan_epilogue();
5293 }
5294 EXPORT_SYMBOL(__ubsan_handle_negate_overflow);
5295
5296 @@ -235,13 +229,12 @@ EXPORT_SYMBOL(__ubsan_handle_negate_overflow);
5297 void __ubsan_handle_divrem_overflow(struct overflow_data *data,
5298 void *lhs, void *rhs)
5299 {
5300 - unsigned long flags;
5301 char rhs_val_str[VALUE_LENGTH];
5302
5303 if (suppress_report(&data->location))
5304 return;
5305
5306 - ubsan_prologue(&data->location, &flags);
5307 + ubsan_prologue(&data->location);
5308
5309 val_to_string(rhs_val_str, sizeof(rhs_val_str), data->type, rhs);
5310
5311 @@ -251,58 +244,52 @@ void __ubsan_handle_divrem_overflow(struct overflow_data *data,
5312 else
5313 pr_err("division by zero\n");
5314
5315 - ubsan_epilogue(&flags);
5316 + ubsan_epilogue();
5317 }
5318 EXPORT_SYMBOL(__ubsan_handle_divrem_overflow);
5319
5320 static void handle_null_ptr_deref(struct type_mismatch_data_common *data)
5321 {
5322 - unsigned long flags;
5323 -
5324 if (suppress_report(data->location))
5325 return;
5326
5327 - ubsan_prologue(data->location, &flags);
5328 + ubsan_prologue(data->location);
5329
5330 pr_err("%s null pointer of type %s\n",
5331 type_check_kinds[data->type_check_kind],
5332 data->type->type_name);
5333
5334 - ubsan_epilogue(&flags);
5335 + ubsan_epilogue();
5336 }
5337
5338 static void handle_misaligned_access(struct type_mismatch_data_common *data,
5339 unsigned long ptr)
5340 {
5341 - unsigned long flags;
5342 -
5343 if (suppress_report(data->location))
5344 return;
5345
5346 - ubsan_prologue(data->location, &flags);
5347 + ubsan_prologue(data->location);
5348
5349 pr_err("%s misaligned address %p for type %s\n",
5350 type_check_kinds[data->type_check_kind],
5351 (void *)ptr, data->type->type_name);
5352 pr_err("which requires %ld byte alignment\n", data->alignment);
5353
5354 - ubsan_epilogue(&flags);
5355 + ubsan_epilogue();
5356 }
5357
5358 static void handle_object_size_mismatch(struct type_mismatch_data_common *data,
5359 unsigned long ptr)
5360 {
5361 - unsigned long flags;
5362 -
5363 if (suppress_report(data->location))
5364 return;
5365
5366 - ubsan_prologue(data->location, &flags);
5367 + ubsan_prologue(data->location);
5368 pr_err("%s address %p with insufficient space\n",
5369 type_check_kinds[data->type_check_kind],
5370 (void *) ptr);
5371 pr_err("for an object of type %s\n", data->type->type_name);
5372 - ubsan_epilogue(&flags);
5373 + ubsan_epilogue();
5374 }
5375
5376 static void ubsan_type_mismatch_common(struct type_mismatch_data_common *data,
5377 @@ -351,25 +338,23 @@ EXPORT_SYMBOL(__ubsan_handle_type_mismatch_v1);
5378
5379 void __ubsan_handle_out_of_bounds(struct out_of_bounds_data *data, void *index)
5380 {
5381 - unsigned long flags;
5382 char index_str[VALUE_LENGTH];
5383
5384 if (suppress_report(&data->location))
5385 return;
5386
5387 - ubsan_prologue(&data->location, &flags);
5388 + ubsan_prologue(&data->location);
5389
5390 val_to_string(index_str, sizeof(index_str), data->index_type, index);
5391 pr_err("index %s is out of range for type %s\n", index_str,
5392 data->array_type->type_name);
5393 - ubsan_epilogue(&flags);
5394 + ubsan_epilogue();
5395 }
5396 EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
5397
5398 void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
5399 void *lhs, void *rhs)
5400 {
5401 - unsigned long flags;
5402 struct type_descriptor *rhs_type = data->rhs_type;
5403 struct type_descriptor *lhs_type = data->lhs_type;
5404 char rhs_str[VALUE_LENGTH];
5405 @@ -379,7 +364,7 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
5406 if (suppress_report(&data->location))
5407 goto out;
5408
5409 - ubsan_prologue(&data->location, &flags);
5410 + ubsan_prologue(&data->location);
5411
5412 val_to_string(rhs_str, sizeof(rhs_str), rhs_type, rhs);
5413 val_to_string(lhs_str, sizeof(lhs_str), lhs_type, lhs);
5414 @@ -402,7 +387,7 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
5415 lhs_str, rhs_str,
5416 lhs_type->type_name);
5417
5418 - ubsan_epilogue(&flags);
5419 + ubsan_epilogue();
5420 out:
5421 user_access_restore(ua_flags);
5422 }
5423 @@ -411,11 +396,9 @@ EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
5424
5425 void __ubsan_handle_builtin_unreachable(struct unreachable_data *data)
5426 {
5427 - unsigned long flags;
5428 -
5429 - ubsan_prologue(&data->location, &flags);
5430 + ubsan_prologue(&data->location);
5431 pr_err("calling __builtin_unreachable()\n");
5432 - ubsan_epilogue(&flags);
5433 + ubsan_epilogue();
5434 panic("can't return from __builtin_unreachable()");
5435 }
5436 EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
5437 @@ -423,19 +406,18 @@ EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
5438 void __ubsan_handle_load_invalid_value(struct invalid_value_data *data,
5439 void *val)
5440 {
5441 - unsigned long flags;
5442 char val_str[VALUE_LENGTH];
5443
5444 if (suppress_report(&data->location))
5445 return;
5446
5447 - ubsan_prologue(&data->location, &flags);
5448 + ubsan_prologue(&data->location);
5449
5450 val_to_string(val_str, sizeof(val_str), data->type, val);
5451
5452 pr_err("load of value %s is not a valid value for type %s\n",
5453 val_str, data->type->type_name);
5454
5455 - ubsan_epilogue(&flags);
5456 + ubsan_epilogue();
5457 }
5458 EXPORT_SYMBOL(__ubsan_handle_load_invalid_value);
5459 diff --git a/mm/filemap.c b/mm/filemap.c
5460 index 85b7d087eb45..1f5731768222 100644
5461 --- a/mm/filemap.c
5462 +++ b/mm/filemap.c
5463 @@ -2329,27 +2329,6 @@ EXPORT_SYMBOL(generic_file_read_iter);
5464
5465 #ifdef CONFIG_MMU
5466 #define MMAP_LOTSAMISS (100)
5467 -static struct file *maybe_unlock_mmap_for_io(struct vm_fault *vmf,
5468 - struct file *fpin)
5469 -{
5470 - int flags = vmf->flags;
5471 -
5472 - if (fpin)
5473 - return fpin;
5474 -
5475 - /*
5476 - * FAULT_FLAG_RETRY_NOWAIT means we don't want to wait on page locks or
5477 - * anything, so we only pin the file and drop the mmap_sem if only
5478 - * FAULT_FLAG_ALLOW_RETRY is set.
5479 - */
5480 - if ((flags & (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT)) ==
5481 - FAULT_FLAG_ALLOW_RETRY) {
5482 - fpin = get_file(vmf->vma->vm_file);
5483 - up_read(&vmf->vma->vm_mm->mmap_sem);
5484 - }
5485 - return fpin;
5486 -}
5487 -
5488 /*
5489 * lock_page_maybe_drop_mmap - lock the page, possibly dropping the mmap_sem
5490 * @vmf - the vm_fault for this fault.
5491 diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c
5492 index 7dd602d7f8db..ad9d5b1c4473 100644
5493 --- a/mm/gup_benchmark.c
5494 +++ b/mm/gup_benchmark.c
5495 @@ -26,6 +26,7 @@ static int __gup_benchmark_ioctl(unsigned int cmd,
5496 unsigned long i, nr_pages, addr, next;
5497 int nr;
5498 struct page **pages;
5499 + int ret = 0;
5500
5501 if (gup->size > ULONG_MAX)
5502 return -EINVAL;
5503 @@ -63,7 +64,9 @@ static int __gup_benchmark_ioctl(unsigned int cmd,
5504 NULL);
5505 break;
5506 default:
5507 - return -1;
5508 + kvfree(pages);
5509 + ret = -EINVAL;
5510 + goto out;
5511 }
5512
5513 if (nr <= 0)
5514 @@ -85,7 +88,8 @@ static int __gup_benchmark_ioctl(unsigned int cmd,
5515 gup->put_delta_usec = ktime_us_delta(end_time, start_time);
5516
5517 kvfree(pages);
5518 - return 0;
5519 +out:
5520 + return ret;
5521 }
5522
5523 static long gup_benchmark_ioctl(struct file *filep, unsigned int cmd,
5524 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
5525 index b45a95363a84..e0afd582ca01 100644
5526 --- a/mm/hugetlb.c
5527 +++ b/mm/hugetlb.c
5528 @@ -27,6 +27,7 @@
5529 #include <linux/swapops.h>
5530 #include <linux/jhash.h>
5531 #include <linux/numa.h>
5532 +#include <linux/llist.h>
5533
5534 #include <asm/page.h>
5535 #include <asm/pgtable.h>
5536 @@ -1255,7 +1256,7 @@ static inline void ClearPageHugeTemporary(struct page *page)
5537 page[2].mapping = NULL;
5538 }
5539
5540 -void free_huge_page(struct page *page)
5541 +static void __free_huge_page(struct page *page)
5542 {
5543 /*
5544 * Can't pass hstate in here because it is called from the
5545 @@ -1318,6 +1319,54 @@ void free_huge_page(struct page *page)
5546 spin_unlock(&hugetlb_lock);
5547 }
5548
5549 +/*
5550 + * As free_huge_page() can be called from a non-task context, we have
5551 + * to defer the actual freeing in a workqueue to prevent potential
5552 + * hugetlb_lock deadlock.
5553 + *
5554 + * free_hpage_workfn() locklessly retrieves the linked list of pages to
5555 + * be freed and frees them one-by-one. As the page->mapping pointer is
5556 + * going to be cleared in __free_huge_page() anyway, it is reused as the
5557 + * llist_node structure of a lockless linked list of huge pages to be freed.
5558 + */
5559 +static LLIST_HEAD(hpage_freelist);
5560 +
5561 +static void free_hpage_workfn(struct work_struct *work)
5562 +{
5563 + struct llist_node *node;
5564 + struct page *page;
5565 +
5566 + node = llist_del_all(&hpage_freelist);
5567 +
5568 + while (node) {
5569 + page = container_of((struct address_space **)node,
5570 + struct page, mapping);
5571 + node = node->next;
5572 + __free_huge_page(page);
5573 + }
5574 +}
5575 +static DECLARE_WORK(free_hpage_work, free_hpage_workfn);
5576 +
5577 +void free_huge_page(struct page *page)
5578 +{
5579 + /*
5580 + * Defer freeing if in non-task context to avoid hugetlb_lock deadlock.
5581 + */
5582 + if (!in_task()) {
5583 + /*
5584 + * Only call schedule_work() if hpage_freelist is previously
5585 + * empty. Otherwise, schedule_work() had been called but the
5586 + * workfn hasn't retrieved the list yet.
5587 + */
5588 + if (llist_add((struct llist_node *)&page->mapping,
5589 + &hpage_freelist))
5590 + schedule_work(&free_hpage_work);
5591 + return;
5592 + }
5593 +
5594 + __free_huge_page(page);
5595 +}
5596 +
5597 static void prep_new_huge_page(struct hstate *h, struct page *page, int nid)
5598 {
5599 INIT_LIST_HEAD(&page->lru);
5600 diff --git a/mm/internal.h b/mm/internal.h
5601 index 0d5f720c75ab..7dd7fbb577a9 100644
5602 --- a/mm/internal.h
5603 +++ b/mm/internal.h
5604 @@ -362,6 +362,27 @@ vma_address(struct page *page, struct vm_area_struct *vma)
5605 return max(start, vma->vm_start);
5606 }
5607
5608 +static inline struct file *maybe_unlock_mmap_for_io(struct vm_fault *vmf,
5609 + struct file *fpin)
5610 +{
5611 + int flags = vmf->flags;
5612 +
5613 + if (fpin)
5614 + return fpin;
5615 +
5616 + /*
5617 + * FAULT_FLAG_RETRY_NOWAIT means we don't want to wait on page locks or
5618 + * anything, so we only pin the file and drop the mmap_sem if only
5619 + * FAULT_FLAG_ALLOW_RETRY is set.
5620 + */
5621 + if ((flags & (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT)) ==
5622 + FAULT_FLAG_ALLOW_RETRY) {
5623 + fpin = get_file(vmf->vma->vm_file);
5624 + up_read(&vmf->vma->vm_mm->mmap_sem);
5625 + }
5626 + return fpin;
5627 +}
5628 +
5629 #else /* !CONFIG_MMU */
5630 static inline void clear_page_mlock(struct page *page) { }
5631 static inline void mlock_vma_page(struct page *page) { }
5632 diff --git a/mm/memory.c b/mm/memory.c
5633 index b1ca51a079f2..cb7c940cf800 100644
5634 --- a/mm/memory.c
5635 +++ b/mm/memory.c
5636 @@ -2227,10 +2227,11 @@ static vm_fault_t do_page_mkwrite(struct vm_fault *vmf)
5637 *
5638 * The function expects the page to be locked and unlocks it.
5639 */
5640 -static void fault_dirty_shared_page(struct vm_area_struct *vma,
5641 - struct page *page)
5642 +static vm_fault_t fault_dirty_shared_page(struct vm_fault *vmf)
5643 {
5644 + struct vm_area_struct *vma = vmf->vma;
5645 struct address_space *mapping;
5646 + struct page *page = vmf->page;
5647 bool dirtied;
5648 bool page_mkwrite = vma->vm_ops && vma->vm_ops->page_mkwrite;
5649
5650 @@ -2245,16 +2246,30 @@ static void fault_dirty_shared_page(struct vm_area_struct *vma,
5651 mapping = page_rmapping(page);
5652 unlock_page(page);
5653
5654 + if (!page_mkwrite)
5655 + file_update_time(vma->vm_file);
5656 +
5657 + /*
5658 + * Throttle page dirtying rate down to writeback speed.
5659 + *
5660 + * mapping may be NULL here because some device drivers do not
5661 + * set page.mapping but still dirty their pages
5662 + *
5663 + * Drop the mmap_sem before waiting on IO, if we can. The file
5664 + * is pinning the mapping, as per above.
5665 + */
5666 if ((dirtied || page_mkwrite) && mapping) {
5667 - /*
5668 - * Some device drivers do not set page.mapping
5669 - * but still dirty their pages
5670 - */
5671 + struct file *fpin;
5672 +
5673 + fpin = maybe_unlock_mmap_for_io(vmf, NULL);
5674 balance_dirty_pages_ratelimited(mapping);
5675 + if (fpin) {
5676 + fput(fpin);
5677 + return VM_FAULT_RETRY;
5678 + }
5679 }
5680
5681 - if (!page_mkwrite)
5682 - file_update_time(vma->vm_file);
5683 + return 0;
5684 }
5685
5686 /*
5687 @@ -2497,6 +2512,7 @@ static vm_fault_t wp_page_shared(struct vm_fault *vmf)
5688 __releases(vmf->ptl)
5689 {
5690 struct vm_area_struct *vma = vmf->vma;
5691 + vm_fault_t ret = VM_FAULT_WRITE;
5692
5693 get_page(vmf->page);
5694
5695 @@ -2520,10 +2536,10 @@ static vm_fault_t wp_page_shared(struct vm_fault *vmf)
5696 wp_page_reuse(vmf);
5697 lock_page(vmf->page);
5698 }
5699 - fault_dirty_shared_page(vma, vmf->page);
5700 + ret |= fault_dirty_shared_page(vmf);
5701 put_page(vmf->page);
5702
5703 - return VM_FAULT_WRITE;
5704 + return ret;
5705 }
5706
5707 /*
5708 @@ -3567,7 +3583,7 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf)
5709 return ret;
5710 }
5711
5712 - fault_dirty_shared_page(vma, vmf->page);
5713 + ret |= fault_dirty_shared_page(vmf);
5714 return ret;
5715 }
5716
5717 diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
5718 index f307bd82d750..fab540685279 100644
5719 --- a/mm/memory_hotplug.c
5720 +++ b/mm/memory_hotplug.c
5721 @@ -465,8 +465,9 @@ static void update_pgdat_span(struct pglist_data *pgdat)
5722 pgdat->node_spanned_pages = node_end_pfn - node_start_pfn;
5723 }
5724
5725 -static void __remove_zone(struct zone *zone, unsigned long start_pfn,
5726 - unsigned long nr_pages)
5727 +void __ref remove_pfn_range_from_zone(struct zone *zone,
5728 + unsigned long start_pfn,
5729 + unsigned long nr_pages)
5730 {
5731 struct pglist_data *pgdat = zone->zone_pgdat;
5732 unsigned long flags;
5733 @@ -481,28 +482,30 @@ static void __remove_zone(struct zone *zone, unsigned long start_pfn,
5734 return;
5735 #endif
5736
5737 + clear_zone_contiguous(zone);
5738 +
5739 pgdat_resize_lock(zone->zone_pgdat, &flags);
5740 shrink_zone_span(zone, start_pfn, start_pfn + nr_pages);
5741 update_pgdat_span(pgdat);
5742 pgdat_resize_unlock(zone->zone_pgdat, &flags);
5743 +
5744 + set_zone_contiguous(zone);
5745 }
5746
5747 -static void __remove_section(struct zone *zone, unsigned long pfn,
5748 - unsigned long nr_pages, unsigned long map_offset,
5749 - struct vmem_altmap *altmap)
5750 +static void __remove_section(unsigned long pfn, unsigned long nr_pages,
5751 + unsigned long map_offset,
5752 + struct vmem_altmap *altmap)
5753 {
5754 struct mem_section *ms = __nr_to_section(pfn_to_section_nr(pfn));
5755
5756 if (WARN_ON_ONCE(!valid_section(ms)))
5757 return;
5758
5759 - __remove_zone(zone, pfn, nr_pages);
5760 sparse_remove_section(ms, pfn, nr_pages, map_offset, altmap);
5761 }
5762
5763 /**
5764 - * __remove_pages() - remove sections of pages from a zone
5765 - * @zone: zone from which pages need to be removed
5766 + * __remove_pages() - remove sections of pages
5767 * @pfn: starting pageframe (must be aligned to start of a section)
5768 * @nr_pages: number of pages to remove (must be multiple of section size)
5769 * @altmap: alternative device page map or %NULL if default memmap is used
5770 @@ -512,16 +515,14 @@ static void __remove_section(struct zone *zone, unsigned long pfn,
5771 * sure that pages are marked reserved and zones are adjust properly by
5772 * calling offline_pages().
5773 */
5774 -void __remove_pages(struct zone *zone, unsigned long pfn,
5775 - unsigned long nr_pages, struct vmem_altmap *altmap)
5776 +void __remove_pages(unsigned long pfn, unsigned long nr_pages,
5777 + struct vmem_altmap *altmap)
5778 {
5779 unsigned long map_offset = 0;
5780 unsigned long nr, start_sec, end_sec;
5781
5782 map_offset = vmem_altmap_offset(altmap);
5783
5784 - clear_zone_contiguous(zone);
5785 -
5786 if (check_pfn_span(pfn, nr_pages, "remove"))
5787 return;
5788
5789 @@ -533,13 +534,11 @@ void __remove_pages(struct zone *zone, unsigned long pfn,
5790 cond_resched();
5791 pfns = min(nr_pages, PAGES_PER_SECTION
5792 - (pfn & ~PAGE_SECTION_MASK));
5793 - __remove_section(zone, pfn, pfns, map_offset, altmap);
5794 + __remove_section(pfn, pfns, map_offset, altmap);
5795 pfn += pfns;
5796 nr_pages -= pfns;
5797 map_offset = 0;
5798 }
5799 -
5800 - set_zone_contiguous(zone);
5801 }
5802
5803 int set_online_page_callback(online_page_callback_t callback)
5804 @@ -867,6 +866,7 @@ failed_addition:
5805 (unsigned long long) pfn << PAGE_SHIFT,
5806 (((unsigned long long) pfn + nr_pages) << PAGE_SHIFT) - 1);
5807 memory_notify(MEM_CANCEL_ONLINE, &arg);
5808 + remove_pfn_range_from_zone(zone, pfn, nr_pages);
5809 mem_hotplug_done();
5810 return ret;
5811 }
5812 @@ -1602,6 +1602,7 @@ static int __ref __offline_pages(unsigned long start_pfn,
5813 writeback_set_ratelimit();
5814
5815 memory_notify(MEM_OFFLINE, &arg);
5816 + remove_pfn_range_from_zone(zone, start_pfn, nr_pages);
5817 mem_hotplug_done();
5818 return 0;
5819
5820 diff --git a/mm/memremap.c b/mm/memremap.c
5821 index 03ccbdfeb697..c51c6bd2fe34 100644
5822 --- a/mm/memremap.c
5823 +++ b/mm/memremap.c
5824 @@ -120,7 +120,7 @@ void memunmap_pages(struct dev_pagemap *pgmap)
5825
5826 mem_hotplug_begin();
5827 if (pgmap->type == MEMORY_DEVICE_PRIVATE) {
5828 - __remove_pages(page_zone(first_page), PHYS_PFN(res->start),
5829 + __remove_pages(PHYS_PFN(res->start),
5830 PHYS_PFN(resource_size(res)), NULL);
5831 } else {
5832 arch_remove_memory(nid, res->start, resource_size(res),
5833 diff --git a/mm/migrate.c b/mm/migrate.c
5834 index 4fe45d1428c8..45d3303e0022 100644
5835 --- a/mm/migrate.c
5836 +++ b/mm/migrate.c
5837 @@ -1516,9 +1516,11 @@ static int do_move_pages_to_node(struct mm_struct *mm,
5838 /*
5839 * Resolves the given address to a struct page, isolates it from the LRU and
5840 * puts it to the given pagelist.
5841 - * Returns -errno if the page cannot be found/isolated or 0 when it has been
5842 - * queued or the page doesn't need to be migrated because it is already on
5843 - * the target node
5844 + * Returns:
5845 + * errno - if the page cannot be found/isolated
5846 + * 0 - when it doesn't have to be migrated because it is already on the
5847 + * target node
5848 + * 1 - when it has been queued
5849 */
5850 static int add_page_for_migration(struct mm_struct *mm, unsigned long addr,
5851 int node, struct list_head *pagelist, bool migrate_all)
5852 @@ -1557,7 +1559,7 @@ static int add_page_for_migration(struct mm_struct *mm, unsigned long addr,
5853 if (PageHuge(page)) {
5854 if (PageHead(page)) {
5855 isolate_huge_page(page, pagelist);
5856 - err = 0;
5857 + err = 1;
5858 }
5859 } else {
5860 struct page *head;
5861 @@ -1567,7 +1569,7 @@ static int add_page_for_migration(struct mm_struct *mm, unsigned long addr,
5862 if (err)
5863 goto out_putpage;
5864
5865 - err = 0;
5866 + err = 1;
5867 list_add_tail(&head->lru, pagelist);
5868 mod_node_page_state(page_pgdat(head),
5869 NR_ISOLATED_ANON + page_is_file_cache(head),
5870 @@ -1644,8 +1646,17 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes,
5871 */
5872 err = add_page_for_migration(mm, addr, current_node,
5873 &pagelist, flags & MPOL_MF_MOVE_ALL);
5874 - if (!err)
5875 +
5876 + if (!err) {
5877 + /* The page is already on the target node */
5878 + err = store_status(status, i, current_node, 1);
5879 + if (err)
5880 + goto out_flush;
5881 continue;
5882 + } else if (err > 0) {
5883 + /* The page is successfully queued for migration */
5884 + continue;
5885 + }
5886
5887 err = store_status(status, i, err, 1);
5888 if (err)
5889 diff --git a/mm/mmap.c b/mm/mmap.c
5890 index a7d8c84d19b7..4390dbea4aa5 100644
5891 --- a/mm/mmap.c
5892 +++ b/mm/mmap.c
5893 @@ -90,12 +90,6 @@ static void unmap_region(struct mm_struct *mm,
5894 * MAP_PRIVATE r: (no) no r: (yes) yes r: (no) yes r: (no) yes
5895 * w: (no) no w: (no) no w: (copy) copy w: (no) no
5896 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
5897 - *
5898 - * On arm64, PROT_EXEC has the following behaviour for both MAP_SHARED and
5899 - * MAP_PRIVATE:
5900 - * r: (no) no
5901 - * w: (no) no
5902 - * x: (yes) yes
5903 */
5904 pgprot_t protection_map[16] __ro_after_init = {
5905 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
5906 diff --git a/mm/oom_kill.c b/mm/oom_kill.c
5907 index 71e3acea7817..d58c481b3df8 100644
5908 --- a/mm/oom_kill.c
5909 +++ b/mm/oom_kill.c
5910 @@ -890,7 +890,7 @@ static void __oom_kill_process(struct task_struct *victim, const char *message)
5911 K(get_mm_counter(mm, MM_FILEPAGES)),
5912 K(get_mm_counter(mm, MM_SHMEMPAGES)),
5913 from_kuid(&init_user_ns, task_uid(victim)),
5914 - mm_pgtables_bytes(mm), victim->signal->oom_score_adj);
5915 + mm_pgtables_bytes(mm) >> 10, victim->signal->oom_score_adj);
5916 task_unlock(victim);
5917
5918 /*
5919 diff --git a/mm/shmem.c b/mm/shmem.c
5920 index 7a22e3e03d11..6074714fdbd4 100644
5921 --- a/mm/shmem.c
5922 +++ b/mm/shmem.c
5923 @@ -2022,16 +2022,14 @@ static vm_fault_t shmem_fault(struct vm_fault *vmf)
5924 shmem_falloc->waitq &&
5925 vmf->pgoff >= shmem_falloc->start &&
5926 vmf->pgoff < shmem_falloc->next) {
5927 + struct file *fpin;
5928 wait_queue_head_t *shmem_falloc_waitq;
5929 DEFINE_WAIT_FUNC(shmem_fault_wait, synchronous_wake_function);
5930
5931 ret = VM_FAULT_NOPAGE;
5932 - if ((vmf->flags & FAULT_FLAG_ALLOW_RETRY) &&
5933 - !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) {
5934 - /* It's polite to up mmap_sem if we can */
5935 - up_read(&vma->vm_mm->mmap_sem);
5936 + fpin = maybe_unlock_mmap_for_io(vmf, NULL);
5937 + if (fpin)
5938 ret = VM_FAULT_RETRY;
5939 - }
5940
5941 shmem_falloc_waitq = shmem_falloc->waitq;
5942 prepare_to_wait(shmem_falloc_waitq, &shmem_fault_wait,
5943 @@ -2049,6 +2047,9 @@ static vm_fault_t shmem_fault(struct vm_fault *vmf)
5944 spin_lock(&inode->i_lock);
5945 finish_wait(shmem_falloc_waitq, &shmem_fault_wait);
5946 spin_unlock(&inode->i_lock);
5947 +
5948 + if (fpin)
5949 + fput(fpin);
5950 return ret;
5951 }
5952 spin_unlock(&inode->i_lock);
5953 diff --git a/mm/sparse.c b/mm/sparse.c
5954 index f6891c1992b1..c2c01b6330af 100644
5955 --- a/mm/sparse.c
5956 +++ b/mm/sparse.c
5957 @@ -647,7 +647,7 @@ void offline_mem_sections(unsigned long start_pfn, unsigned long end_pfn)
5958 #endif
5959
5960 #ifdef CONFIG_SPARSEMEM_VMEMMAP
5961 -static struct page *populate_section_memmap(unsigned long pfn,
5962 +static struct page * __meminit populate_section_memmap(unsigned long pfn,
5963 unsigned long nr_pages, int nid, struct vmem_altmap *altmap)
5964 {
5965 return __populate_section_memmap(pfn, nr_pages, nid, altmap);
5966 @@ -669,7 +669,7 @@ static void free_map_bootmem(struct page *memmap)
5967 vmemmap_free(start, end, NULL);
5968 }
5969 #else
5970 -struct page *populate_section_memmap(unsigned long pfn,
5971 +struct page * __meminit populate_section_memmap(unsigned long pfn,
5972 unsigned long nr_pages, int nid, struct vmem_altmap *altmap)
5973 {
5974 struct page *page, *ret;
5975 diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
5976 index 2b2b9aae8a3c..22d17ecfe7df 100644
5977 --- a/mm/zsmalloc.c
5978 +++ b/mm/zsmalloc.c
5979 @@ -2069,6 +2069,11 @@ static int zs_page_migrate(struct address_space *mapping, struct page *newpage,
5980 zs_pool_dec_isolated(pool);
5981 }
5982
5983 + if (page_zone(newpage) != page_zone(page)) {
5984 + dec_zone_page_state(page, NR_ZSPAGES);
5985 + inc_zone_page_state(newpage, NR_ZSPAGES);
5986 + }
5987 +
5988 reset_page(page);
5989 put_page(page);
5990 page = newpage;
5991 diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
5992 index 7ff92dd4c53c..87691404d0c6 100644
5993 --- a/net/bluetooth/hci_conn.c
5994 +++ b/net/bluetooth/hci_conn.c
5995 @@ -1176,8 +1176,10 @@ struct hci_conn *hci_connect_le_scan(struct hci_dev *hdev, bdaddr_t *dst,
5996 if (!conn)
5997 return ERR_PTR(-ENOMEM);
5998
5999 - if (hci_explicit_conn_params_set(hdev, dst, dst_type) < 0)
6000 + if (hci_explicit_conn_params_set(hdev, dst, dst_type) < 0) {
6001 + hci_conn_del(conn);
6002 return ERR_PTR(-EBUSY);
6003 + }
6004
6005 conn->state = BT_CONNECT;
6006 set_bit(HCI_CONN_SCANNING, &conn->flags);
6007 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
6008 index da7fdbdf9c41..a845786258a0 100644
6009 --- a/net/bluetooth/l2cap_core.c
6010 +++ b/net/bluetooth/l2cap_core.c
6011 @@ -4936,10 +4936,8 @@ void __l2cap_physical_cfm(struct l2cap_chan *chan, int result)
6012 BT_DBG("chan %p, result %d, local_amp_id %d, remote_amp_id %d",
6013 chan, result, local_amp_id, remote_amp_id);
6014
6015 - if (chan->state == BT_DISCONN || chan->state == BT_CLOSED) {
6016 - l2cap_chan_unlock(chan);
6017 + if (chan->state == BT_DISCONN || chan->state == BT_CLOSED)
6018 return;
6019 - }
6020
6021 if (chan->state != BT_CONNECTED) {
6022 l2cap_do_create(chan, result, local_amp_id, remote_amp_id);
6023 diff --git a/net/core/dev.c b/net/core/dev.c
6024 index 046307445ece..3e11c6bb4dd6 100644
6025 --- a/net/core/dev.c
6026 +++ b/net/core/dev.c
6027 @@ -3386,7 +3386,7 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
6028 qdisc_calculate_pkt_len(skb, q);
6029
6030 if (q->flags & TCQ_F_NOLOCK) {
6031 - if ((q->flags & TCQ_F_CAN_BYPASS) && q->empty &&
6032 + if ((q->flags & TCQ_F_CAN_BYPASS) && READ_ONCE(q->empty) &&
6033 qdisc_run_begin(q)) {
6034 if (unlikely(test_bit(__QDISC_STATE_DEACTIVATED,
6035 &q->state))) {
6036 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
6037 index 08ebc3ac5343..f2452496ad9f 100644
6038 --- a/net/core/neighbour.c
6039 +++ b/net/core/neighbour.c
6040 @@ -1194,7 +1194,7 @@ static void neigh_update_hhs(struct neighbour *neigh)
6041
6042 if (update) {
6043 hh = &neigh->hh;
6044 - if (hh->hh_len) {
6045 + if (READ_ONCE(hh->hh_len)) {
6046 write_seqlock_bh(&hh->hh_lock);
6047 update(hh, neigh->dev, neigh->ha);
6048 write_sequnlock_bh(&hh->hh_lock);
6049 @@ -1473,7 +1473,7 @@ int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb)
6050 struct net_device *dev = neigh->dev;
6051 unsigned int seq;
6052
6053 - if (dev->header_ops->cache && !neigh->hh.hh_len)
6054 + if (dev->header_ops->cache && !READ_ONCE(neigh->hh.hh_len))
6055 neigh_hh_init(neigh);
6056
6057 do {
6058 diff --git a/net/core/sock.c b/net/core/sock.c
6059 index ac78a570e43a..b4d1112174c1 100644
6060 --- a/net/core/sock.c
6061 +++ b/net/core/sock.c
6062 @@ -2918,7 +2918,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
6063
6064 sk->sk_max_pacing_rate = ~0UL;
6065 sk->sk_pacing_rate = ~0UL;
6066 - sk->sk_pacing_shift = 10;
6067 + WRITE_ONCE(sk->sk_pacing_shift, 10);
6068 sk->sk_incoming_cpu = -1;
6069
6070 sk_rx_queue_clear(sk);
6071 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
6072 index eb29e5adc84d..9f9e00ba3ad7 100644
6073 --- a/net/core/sysctl_net_core.c
6074 +++ b/net/core/sysctl_net_core.c
6075 @@ -288,6 +288,7 @@ static int proc_dointvec_minmax_bpf_enable(struct ctl_table *table, int write,
6076 return ret;
6077 }
6078
6079 +# ifdef CONFIG_HAVE_EBPF_JIT
6080 static int
6081 proc_dointvec_minmax_bpf_restricted(struct ctl_table *table, int write,
6082 void __user *buffer, size_t *lenp,
6083 @@ -298,6 +299,7 @@ proc_dointvec_minmax_bpf_restricted(struct ctl_table *table, int write,
6084
6085 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
6086 }
6087 +# endif /* CONFIG_HAVE_EBPF_JIT */
6088
6089 static int
6090 proc_dolongvec_minmax_bpf_restricted(struct ctl_table *table, int write,
6091 diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
6092 index 17374afee28f..9040fe55e0f5 100644
6093 --- a/net/ethernet/eth.c
6094 +++ b/net/ethernet/eth.c
6095 @@ -244,7 +244,12 @@ int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh, __be16
6096 eth->h_proto = type;
6097 memcpy(eth->h_source, dev->dev_addr, ETH_ALEN);
6098 memcpy(eth->h_dest, neigh->ha, ETH_ALEN);
6099 - hh->hh_len = ETH_HLEN;
6100 +
6101 + /* Pairs with READ_ONCE() in neigh_resolve_output(),
6102 + * neigh_hh_output() and neigh_update_hhs().
6103 + */
6104 + smp_store_release(&hh->hh_len, ETH_HLEN);
6105 +
6106 return 0;
6107 }
6108 EXPORT_SYMBOL(eth_header_cache);
6109 diff --git a/net/hsr/hsr_debugfs.c b/net/hsr/hsr_debugfs.c
6110 index 94447974a3c0..6618a9d8e58e 100644
6111 --- a/net/hsr/hsr_debugfs.c
6112 +++ b/net/hsr/hsr_debugfs.c
6113 @@ -64,7 +64,6 @@ hsr_node_table_open(struct inode *inode, struct file *filp)
6114 }
6115
6116 static const struct file_operations hsr_fops = {
6117 - .owner = THIS_MODULE,
6118 .open = hsr_node_table_open,
6119 .read = seq_read,
6120 .llseek = seq_lseek,
6121 @@ -78,15 +77,14 @@ static const struct file_operations hsr_fops = {
6122 * When debugfs is configured this routine sets up the node_table file per
6123 * hsr device for dumping the node_table entries
6124 */
6125 -int hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev)
6126 +void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev)
6127 {
6128 - int rc = -1;
6129 struct dentry *de = NULL;
6130
6131 de = debugfs_create_dir(hsr_dev->name, NULL);
6132 - if (!de) {
6133 + if (IS_ERR(de)) {
6134 pr_err("Cannot create hsr debugfs root\n");
6135 - return rc;
6136 + return;
6137 }
6138
6139 priv->node_tbl_root = de;
6140 @@ -94,13 +92,13 @@ int hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev)
6141 de = debugfs_create_file("node_table", S_IFREG | 0444,
6142 priv->node_tbl_root, priv,
6143 &hsr_fops);
6144 - if (!de) {
6145 + if (IS_ERR(de)) {
6146 pr_err("Cannot create hsr node_table directory\n");
6147 - return rc;
6148 + debugfs_remove(priv->node_tbl_root);
6149 + priv->node_tbl_root = NULL;
6150 + return;
6151 }
6152 priv->node_tbl_file = de;
6153 -
6154 - return 0;
6155 }
6156
6157 /* hsr_debugfs_term - Tear down debugfs intrastructure
6158 diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
6159 index b01e1bae4ddc..62c03f0d0079 100644
6160 --- a/net/hsr/hsr_device.c
6161 +++ b/net/hsr/hsr_device.c
6162 @@ -368,7 +368,7 @@ static void hsr_dev_destroy(struct net_device *hsr_dev)
6163 del_timer_sync(&hsr->prune_timer);
6164 del_timer_sync(&hsr->announce_timer);
6165
6166 - hsr_del_self_node(&hsr->self_node_db);
6167 + hsr_del_self_node(hsr);
6168 hsr_del_nodes(&hsr->node_db);
6169 }
6170
6171 @@ -440,11 +440,12 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
6172 INIT_LIST_HEAD(&hsr->ports);
6173 INIT_LIST_HEAD(&hsr->node_db);
6174 INIT_LIST_HEAD(&hsr->self_node_db);
6175 + spin_lock_init(&hsr->list_lock);
6176
6177 ether_addr_copy(hsr_dev->dev_addr, slave[0]->dev_addr);
6178
6179 /* Make sure we recognize frames from ourselves in hsr_rcv() */
6180 - res = hsr_create_self_node(&hsr->self_node_db, hsr_dev->dev_addr,
6181 + res = hsr_create_self_node(hsr, hsr_dev->dev_addr,
6182 slave[1]->dev_addr);
6183 if (res < 0)
6184 return res;
6185 @@ -477,31 +478,32 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
6186
6187 res = hsr_add_port(hsr, hsr_dev, HSR_PT_MASTER);
6188 if (res)
6189 - goto err_add_port;
6190 + goto err_add_master;
6191
6192 res = register_netdevice(hsr_dev);
6193 if (res)
6194 - goto fail;
6195 + goto err_unregister;
6196
6197 res = hsr_add_port(hsr, slave[0], HSR_PT_SLAVE_A);
6198 if (res)
6199 - goto fail;
6200 + goto err_add_slaves;
6201 +
6202 res = hsr_add_port(hsr, slave[1], HSR_PT_SLAVE_B);
6203 if (res)
6204 - goto fail;
6205 + goto err_add_slaves;
6206
6207 + hsr_debugfs_init(hsr, hsr_dev);
6208 mod_timer(&hsr->prune_timer, jiffies + msecs_to_jiffies(PRUNE_PERIOD));
6209 - res = hsr_debugfs_init(hsr, hsr_dev);
6210 - if (res)
6211 - goto fail;
6212
6213 return 0;
6214
6215 -fail:
6216 +err_add_slaves:
6217 + unregister_netdevice(hsr_dev);
6218 +err_unregister:
6219 list_for_each_entry_safe(port, tmp, &hsr->ports, port_list)
6220 hsr_del_port(port);
6221 -err_add_port:
6222 - hsr_del_self_node(&hsr->self_node_db);
6223 +err_add_master:
6224 + hsr_del_self_node(hsr);
6225
6226 return res;
6227 }
6228 diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
6229 index 292be446007b..27dc65d7de67 100644
6230 --- a/net/hsr/hsr_framereg.c
6231 +++ b/net/hsr/hsr_framereg.c
6232 @@ -75,10 +75,11 @@ static struct hsr_node *find_node_by_addr_A(struct list_head *node_db,
6233 /* Helper for device init; the self_node_db is used in hsr_rcv() to recognize
6234 * frames from self that's been looped over the HSR ring.
6235 */
6236 -int hsr_create_self_node(struct list_head *self_node_db,
6237 +int hsr_create_self_node(struct hsr_priv *hsr,
6238 unsigned char addr_a[ETH_ALEN],
6239 unsigned char addr_b[ETH_ALEN])
6240 {
6241 + struct list_head *self_node_db = &hsr->self_node_db;
6242 struct hsr_node *node, *oldnode;
6243
6244 node = kmalloc(sizeof(*node), GFP_KERNEL);
6245 @@ -88,33 +89,33 @@ int hsr_create_self_node(struct list_head *self_node_db,
6246 ether_addr_copy(node->macaddress_A, addr_a);
6247 ether_addr_copy(node->macaddress_B, addr_b);
6248
6249 - rcu_read_lock();
6250 + spin_lock_bh(&hsr->list_lock);
6251 oldnode = list_first_or_null_rcu(self_node_db,
6252 struct hsr_node, mac_list);
6253 if (oldnode) {
6254 list_replace_rcu(&oldnode->mac_list, &node->mac_list);
6255 - rcu_read_unlock();
6256 - synchronize_rcu();
6257 - kfree(oldnode);
6258 + spin_unlock_bh(&hsr->list_lock);
6259 + kfree_rcu(oldnode, rcu_head);
6260 } else {
6261 - rcu_read_unlock();
6262 list_add_tail_rcu(&node->mac_list, self_node_db);
6263 + spin_unlock_bh(&hsr->list_lock);
6264 }
6265
6266 return 0;
6267 }
6268
6269 -void hsr_del_self_node(struct list_head *self_node_db)
6270 +void hsr_del_self_node(struct hsr_priv *hsr)
6271 {
6272 + struct list_head *self_node_db = &hsr->self_node_db;
6273 struct hsr_node *node;
6274
6275 - rcu_read_lock();
6276 + spin_lock_bh(&hsr->list_lock);
6277 node = list_first_or_null_rcu(self_node_db, struct hsr_node, mac_list);
6278 - rcu_read_unlock();
6279 if (node) {
6280 list_del_rcu(&node->mac_list);
6281 - kfree(node);
6282 + kfree_rcu(node, rcu_head);
6283 }
6284 + spin_unlock_bh(&hsr->list_lock);
6285 }
6286
6287 void hsr_del_nodes(struct list_head *node_db)
6288 @@ -130,30 +131,43 @@ void hsr_del_nodes(struct list_head *node_db)
6289 * seq_out is used to initialize filtering of outgoing duplicate frames
6290 * originating from the newly added node.
6291 */
6292 -struct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[],
6293 - u16 seq_out)
6294 +static struct hsr_node *hsr_add_node(struct hsr_priv *hsr,
6295 + struct list_head *node_db,
6296 + unsigned char addr[],
6297 + u16 seq_out)
6298 {
6299 - struct hsr_node *node;
6300 + struct hsr_node *new_node, *node;
6301 unsigned long now;
6302 int i;
6303
6304 - node = kzalloc(sizeof(*node), GFP_ATOMIC);
6305 - if (!node)
6306 + new_node = kzalloc(sizeof(*new_node), GFP_ATOMIC);
6307 + if (!new_node)
6308 return NULL;
6309
6310 - ether_addr_copy(node->macaddress_A, addr);
6311 + ether_addr_copy(new_node->macaddress_A, addr);
6312
6313 /* We are only interested in time diffs here, so use current jiffies
6314 * as initialization. (0 could trigger an spurious ring error warning).
6315 */
6316 now = jiffies;
6317 for (i = 0; i < HSR_PT_PORTS; i++)
6318 - node->time_in[i] = now;
6319 + new_node->time_in[i] = now;
6320 for (i = 0; i < HSR_PT_PORTS; i++)
6321 - node->seq_out[i] = seq_out;
6322 -
6323 - list_add_tail_rcu(&node->mac_list, node_db);
6324 + new_node->seq_out[i] = seq_out;
6325
6326 + spin_lock_bh(&hsr->list_lock);
6327 + list_for_each_entry_rcu(node, node_db, mac_list) {
6328 + if (ether_addr_equal(node->macaddress_A, addr))
6329 + goto out;
6330 + if (ether_addr_equal(node->macaddress_B, addr))
6331 + goto out;
6332 + }
6333 + list_add_tail_rcu(&new_node->mac_list, node_db);
6334 + spin_unlock_bh(&hsr->list_lock);
6335 + return new_node;
6336 +out:
6337 + spin_unlock_bh(&hsr->list_lock);
6338 + kfree(new_node);
6339 return node;
6340 }
6341
6342 @@ -163,6 +177,7 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
6343 bool is_sup)
6344 {
6345 struct list_head *node_db = &port->hsr->node_db;
6346 + struct hsr_priv *hsr = port->hsr;
6347 struct hsr_node *node;
6348 struct ethhdr *ethhdr;
6349 u16 seq_out;
6350 @@ -196,7 +211,7 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
6351 seq_out = HSR_SEQNR_START;
6352 }
6353
6354 - return hsr_add_node(node_db, ethhdr->h_source, seq_out);
6355 + return hsr_add_node(hsr, node_db, ethhdr->h_source, seq_out);
6356 }
6357
6358 /* Use the Supervision frame's info about an eventual macaddress_B for merging
6359 @@ -206,10 +221,11 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
6360 void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr,
6361 struct hsr_port *port_rcv)
6362 {
6363 - struct ethhdr *ethhdr;
6364 - struct hsr_node *node_real;
6365 + struct hsr_priv *hsr = port_rcv->hsr;
6366 struct hsr_sup_payload *hsr_sp;
6367 + struct hsr_node *node_real;
6368 struct list_head *node_db;
6369 + struct ethhdr *ethhdr;
6370 int i;
6371
6372 ethhdr = (struct ethhdr *)skb_mac_header(skb);
6373 @@ -231,7 +247,7 @@ void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr,
6374 node_real = find_node_by_addr_A(node_db, hsr_sp->macaddress_A);
6375 if (!node_real)
6376 /* No frame received from AddrA of this node yet */
6377 - node_real = hsr_add_node(node_db, hsr_sp->macaddress_A,
6378 + node_real = hsr_add_node(hsr, node_db, hsr_sp->macaddress_A,
6379 HSR_SEQNR_START - 1);
6380 if (!node_real)
6381 goto done; /* No mem */
6382 @@ -252,7 +268,9 @@ void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr,
6383 }
6384 node_real->addr_B_port = port_rcv->type;
6385
6386 + spin_lock_bh(&hsr->list_lock);
6387 list_del_rcu(&node_curr->mac_list);
6388 + spin_unlock_bh(&hsr->list_lock);
6389 kfree_rcu(node_curr, rcu_head);
6390
6391 done:
6392 @@ -368,12 +386,13 @@ void hsr_prune_nodes(struct timer_list *t)
6393 {
6394 struct hsr_priv *hsr = from_timer(hsr, t, prune_timer);
6395 struct hsr_node *node;
6396 + struct hsr_node *tmp;
6397 struct hsr_port *port;
6398 unsigned long timestamp;
6399 unsigned long time_a, time_b;
6400
6401 - rcu_read_lock();
6402 - list_for_each_entry_rcu(node, &hsr->node_db, mac_list) {
6403 + spin_lock_bh(&hsr->list_lock);
6404 + list_for_each_entry_safe(node, tmp, &hsr->node_db, mac_list) {
6405 /* Don't prune own node. Neither time_in[HSR_PT_SLAVE_A]
6406 * nor time_in[HSR_PT_SLAVE_B], will ever be updated for
6407 * the master port. Thus the master node will be repeatedly
6408 @@ -421,7 +440,7 @@ void hsr_prune_nodes(struct timer_list *t)
6409 kfree_rcu(node, rcu_head);
6410 }
6411 }
6412 - rcu_read_unlock();
6413 + spin_unlock_bh(&hsr->list_lock);
6414
6415 /* Restart timer */
6416 mod_timer(&hsr->prune_timer,
6417 diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h
6418 index 89a3ce38151d..0f0fa12b4329 100644
6419 --- a/net/hsr/hsr_framereg.h
6420 +++ b/net/hsr/hsr_framereg.h
6421 @@ -12,10 +12,8 @@
6422
6423 struct hsr_node;
6424
6425 -void hsr_del_self_node(struct list_head *self_node_db);
6426 +void hsr_del_self_node(struct hsr_priv *hsr);
6427 void hsr_del_nodes(struct list_head *node_db);
6428 -struct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[],
6429 - u16 seq_out);
6430 struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
6431 bool is_sup);
6432 void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr,
6433 @@ -33,7 +31,7 @@ int hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node,
6434
6435 void hsr_prune_nodes(struct timer_list *t);
6436
6437 -int hsr_create_self_node(struct list_head *self_node_db,
6438 +int hsr_create_self_node(struct hsr_priv *hsr,
6439 unsigned char addr_a[ETH_ALEN],
6440 unsigned char addr_b[ETH_ALEN]);
6441
6442 diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c
6443 index b9988a662ee1..6deb8fa8d5c8 100644
6444 --- a/net/hsr/hsr_main.c
6445 +++ b/net/hsr/hsr_main.c
6446 @@ -64,7 +64,7 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
6447
6448 /* Make sure we recognize frames from ourselves in hsr_rcv() */
6449 port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
6450 - res = hsr_create_self_node(&hsr->self_node_db,
6451 + res = hsr_create_self_node(hsr,
6452 master->dev->dev_addr,
6453 port ?
6454 port->dev->dev_addr :
6455 diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h
6456 index 96fac696a1e1..9ec38e33b8b1 100644
6457 --- a/net/hsr/hsr_main.h
6458 +++ b/net/hsr/hsr_main.h
6459 @@ -160,8 +160,9 @@ struct hsr_priv {
6460 int announce_count;
6461 u16 sequence_nr;
6462 u16 sup_sequence_nr; /* For HSRv1 separate seq_nr for supervision */
6463 - u8 prot_version; /* Indicate if HSRv0 or HSRv1. */
6464 - spinlock_t seqnr_lock; /* locking for sequence_nr */
6465 + u8 prot_version; /* Indicate if HSRv0 or HSRv1. */
6466 + spinlock_t seqnr_lock; /* locking for sequence_nr */
6467 + spinlock_t list_lock; /* locking for node list */
6468 unsigned char sup_multicast_addr[ETH_ALEN];
6469 #ifdef CONFIG_DEBUG_FS
6470 struct dentry *node_tbl_root;
6471 @@ -184,15 +185,12 @@ static inline u16 hsr_get_skb_sequence_nr(struct sk_buff *skb)
6472 }
6473
6474 #if IS_ENABLED(CONFIG_DEBUG_FS)
6475 -int hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev);
6476 +void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev);
6477 void hsr_debugfs_term(struct hsr_priv *priv);
6478 #else
6479 -static inline int hsr_debugfs_init(struct hsr_priv *priv,
6480 - struct net_device *hsr_dev)
6481 -{
6482 - return 0;
6483 -}
6484 -
6485 +static inline void hsr_debugfs_init(struct hsr_priv *priv,
6486 + struct net_device *hsr_dev)
6487 +{}
6488 static inline void hsr_debugfs_term(struct hsr_priv *priv)
6489 {}
6490 #endif
6491 diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
6492 index d8876f0e9672..e537a4b6531b 100644
6493 --- a/net/ipv4/tcp.c
6494 +++ b/net/ipv4/tcp.c
6495 @@ -1958,8 +1958,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
6496 struct sk_buff *skb, *last;
6497 u32 urg_hole = 0;
6498 struct scm_timestamping_internal tss;
6499 - bool has_tss = false;
6500 - bool has_cmsg;
6501 + int cmsg_flags;
6502
6503 if (unlikely(flags & MSG_ERRQUEUE))
6504 return inet_recv_error(sk, msg, len, addr_len);
6505 @@ -1974,7 +1973,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
6506 if (sk->sk_state == TCP_LISTEN)
6507 goto out;
6508
6509 - has_cmsg = tp->recvmsg_inq;
6510 + cmsg_flags = tp->recvmsg_inq ? 1 : 0;
6511 timeo = sock_rcvtimeo(sk, nonblock);
6512
6513 /* Urgent data needs to be handled specially. */
6514 @@ -2157,8 +2156,7 @@ skip_copy:
6515
6516 if (TCP_SKB_CB(skb)->has_rxtstamp) {
6517 tcp_update_recv_tstamps(skb, &tss);
6518 - has_tss = true;
6519 - has_cmsg = true;
6520 + cmsg_flags |= 2;
6521 }
6522 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
6523 goto found_fin_ok;
6524 @@ -2183,10 +2181,10 @@ found_fin_ok:
6525
6526 release_sock(sk);
6527
6528 - if (has_cmsg) {
6529 - if (has_tss)
6530 + if (cmsg_flags) {
6531 + if (cmsg_flags & 2)
6532 tcp_recv_timestamp(msg, sk, &tss);
6533 - if (tp->recvmsg_inq) {
6534 + if (cmsg_flags & 1) {
6535 inq = tcp_inq_hint(sk);
6536 put_cmsg(msg, SOL_TCP, TCP_CM_INQ, sizeof(inq), &inq);
6537 }
6538 diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c
6539 index 32772d6ded4e..a6545ef0d27b 100644
6540 --- a/net/ipv4/tcp_bbr.c
6541 +++ b/net/ipv4/tcp_bbr.c
6542 @@ -306,7 +306,8 @@ static u32 bbr_tso_segs_goal(struct sock *sk)
6543 /* Sort of tcp_tso_autosize() but ignoring
6544 * driver provided sk_gso_max_size.
6545 */
6546 - bytes = min_t(unsigned long, sk->sk_pacing_rate >> sk->sk_pacing_shift,
6547 + bytes = min_t(unsigned long,
6548 + sk->sk_pacing_rate >> READ_ONCE(sk->sk_pacing_shift),
6549 GSO_MAX_SIZE - 1 - MAX_TCP_HEADER);
6550 segs = max_t(u32, bytes / tp->mss_cache, bbr_min_tso_segs(sk));
6551
6552 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
6553 index 0269584e9cf7..e4ba915c4bb5 100644
6554 --- a/net/ipv4/tcp_output.c
6555 +++ b/net/ipv4/tcp_output.c
6556 @@ -1728,7 +1728,7 @@ static u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now,
6557 u32 bytes, segs;
6558
6559 bytes = min_t(unsigned long,
6560 - sk->sk_pacing_rate >> sk->sk_pacing_shift,
6561 + sk->sk_pacing_rate >> READ_ONCE(sk->sk_pacing_shift),
6562 sk->sk_gso_max_size - 1 - MAX_TCP_HEADER);
6563
6564 /* Goal is to send at least one packet per ms,
6565 @@ -2263,7 +2263,7 @@ static bool tcp_small_queue_check(struct sock *sk, const struct sk_buff *skb,
6566
6567 limit = max_t(unsigned long,
6568 2 * skb->truesize,
6569 - sk->sk_pacing_rate >> sk->sk_pacing_shift);
6570 + sk->sk_pacing_rate >> READ_ONCE(sk->sk_pacing_shift));
6571 if (sk->sk_pacing_status == SK_PACING_NONE)
6572 limit = min_t(unsigned long, limit,
6573 sock_net(sk)->ipv4.sysctl_tcp_limit_output_bytes);
6574 diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
6575 index a2b58de82600..f8f52ff99cfb 100644
6576 --- a/net/netfilter/nf_queue.c
6577 +++ b/net/netfilter/nf_queue.c
6578 @@ -189,7 +189,7 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
6579 goto err;
6580 }
6581
6582 - if (!skb_dst_force(skb) && state->hook != NF_INET_PRE_ROUTING) {
6583 + if (skb_dst(skb) && !skb_dst_force(skb)) {
6584 status = -ENETDOWN;
6585 goto err;
6586 }
6587 diff --git a/net/netfilter/nft_tproxy.c b/net/netfilter/nft_tproxy.c
6588 index f92a82c73880..95980154ef02 100644
6589 --- a/net/netfilter/nft_tproxy.c
6590 +++ b/net/netfilter/nft_tproxy.c
6591 @@ -50,7 +50,7 @@ static void nft_tproxy_eval_v4(const struct nft_expr *expr,
6592 taddr = nf_tproxy_laddr4(skb, taddr, iph->daddr);
6593
6594 if (priv->sreg_port)
6595 - tport = regs->data[priv->sreg_port];
6596 + tport = nft_reg_load16(&regs->data[priv->sreg_port]);
6597 if (!tport)
6598 tport = hp->dest;
6599
6600 @@ -117,7 +117,7 @@ static void nft_tproxy_eval_v6(const struct nft_expr *expr,
6601 taddr = *nf_tproxy_laddr6(skb, &taddr, &iph->daddr);
6602
6603 if (priv->sreg_port)
6604 - tport = regs->data[priv->sreg_port];
6605 + tport = nft_reg_load16(&regs->data[priv->sreg_port]);
6606 if (!tport)
6607 tport = hp->dest;
6608
6609 diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
6610 index 8769b4b8807d..7c3c5fdb82a9 100644
6611 --- a/net/sched/sch_generic.c
6612 +++ b/net/sched/sch_generic.c
6613 @@ -657,7 +657,7 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
6614 if (likely(skb)) {
6615 qdisc_update_stats_at_dequeue(qdisc, skb);
6616 } else {
6617 - qdisc->empty = true;
6618 + WRITE_ONCE(qdisc->empty, true);
6619 }
6620
6621 return skb;
6622 diff --git a/net/socket.c b/net/socket.c
6623 index d7a106028f0e..ca8de9e1582d 100644
6624 --- a/net/socket.c
6625 +++ b/net/socket.c
6626 @@ -955,7 +955,7 @@ static ssize_t sock_read_iter(struct kiocb *iocb, struct iov_iter *to)
6627 .msg_iocb = iocb};
6628 ssize_t res;
6629
6630 - if (file->f_flags & O_NONBLOCK)
6631 + if (file->f_flags & O_NONBLOCK || (iocb->ki_flags & IOCB_NOWAIT))
6632 msg.msg_flags = MSG_DONTWAIT;
6633
6634 if (iocb->ki_pos != 0)
6635 @@ -980,7 +980,7 @@ static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from)
6636 if (iocb->ki_pos != 0)
6637 return -ESPIPE;
6638
6639 - if (file->f_flags & O_NONBLOCK)
6640 + if (file->f_flags & O_NONBLOCK || (iocb->ki_flags & IOCB_NOWAIT))
6641 msg.msg_flags = MSG_DONTWAIT;
6642
6643 if (sock->type == SOCK_SEQPACKET)
6644 diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
6645 index a349094f6fb7..f740cb51802a 100644
6646 --- a/net/sunrpc/cache.c
6647 +++ b/net/sunrpc/cache.c
6648 @@ -53,9 +53,6 @@ static void cache_init(struct cache_head *h, struct cache_detail *detail)
6649 h->last_refresh = now;
6650 }
6651
6652 -static inline int cache_is_valid(struct cache_head *h);
6653 -static void cache_fresh_locked(struct cache_head *head, time_t expiry,
6654 - struct cache_detail *detail);
6655 static void cache_fresh_unlocked(struct cache_head *head,
6656 struct cache_detail *detail);
6657
6658 @@ -105,9 +102,6 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
6659 if (cache_is_expired(detail, tmp)) {
6660 hlist_del_init_rcu(&tmp->cache_list);
6661 detail->entries --;
6662 - if (cache_is_valid(tmp) == -EAGAIN)
6663 - set_bit(CACHE_NEGATIVE, &tmp->flags);
6664 - cache_fresh_locked(tmp, 0, detail);
6665 freeme = tmp;
6666 break;
6667 }
6668 diff --git a/samples/seccomp/user-trap.c b/samples/seccomp/user-trap.c
6669 index 6d0125ca8af7..20291ec6489f 100644
6670 --- a/samples/seccomp/user-trap.c
6671 +++ b/samples/seccomp/user-trap.c
6672 @@ -298,14 +298,14 @@ int main(void)
6673 req = malloc(sizes.seccomp_notif);
6674 if (!req)
6675 goto out_close;
6676 - memset(req, 0, sizeof(*req));
6677
6678 resp = malloc(sizes.seccomp_notif_resp);
6679 if (!resp)
6680 goto out_req;
6681 - memset(resp, 0, sizeof(*resp));
6682 + memset(resp, 0, sizes.seccomp_notif_resp);
6683
6684 while (1) {
6685 + memset(req, 0, sizes.seccomp_notif);
6686 if (ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, req)) {
6687 perror("ioctl recv");
6688 goto out_resp;
6689 diff --git a/samples/trace_printk/trace-printk.c b/samples/trace_printk/trace-printk.c
6690 index 7affc3b50b61..cfc159580263 100644
6691 --- a/samples/trace_printk/trace-printk.c
6692 +++ b/samples/trace_printk/trace-printk.c
6693 @@ -36,6 +36,7 @@ static int __init trace_printk_init(void)
6694
6695 /* Kick off printing in irq context */
6696 irq_work_queue(&irqwork);
6697 + irq_work_sync(&irqwork);
6698
6699 trace_printk("This is a %s that will use trace_bprintk()\n",
6700 "static string");
6701 diff --git a/scripts/gcc-plugins/Kconfig b/scripts/gcc-plugins/Kconfig
6702 index d33de0b9f4f5..e3569543bdac 100644
6703 --- a/scripts/gcc-plugins/Kconfig
6704 +++ b/scripts/gcc-plugins/Kconfig
6705 @@ -14,8 +14,8 @@ config HAVE_GCC_PLUGINS
6706 An arch should select this symbol if it supports building with
6707 GCC plugins.
6708
6709 -config GCC_PLUGINS
6710 - bool
6711 +menuconfig GCC_PLUGINS
6712 + bool "GCC plugins"
6713 depends on HAVE_GCC_PLUGINS
6714 depends on PLUGIN_HOSTCC != ""
6715 default y
6716 @@ -25,8 +25,7 @@ config GCC_PLUGINS
6717
6718 See Documentation/core-api/gcc-plugins.rst for details.
6719
6720 -menu "GCC plugins"
6721 - depends on GCC_PLUGINS
6722 +if GCC_PLUGINS
6723
6724 config GCC_PLUGIN_CYC_COMPLEXITY
6725 bool "Compute the cyclomatic complexity of a function" if EXPERT
6726 @@ -113,4 +112,4 @@ config GCC_PLUGIN_ARM_SSP_PER_TASK
6727 bool
6728 depends on GCC_PLUGINS && ARM
6729
6730 -endmenu
6731 +endif
6732 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
6733 index 45d13b6462aa..90d21675c3ad 100644
6734 --- a/security/apparmor/apparmorfs.c
6735 +++ b/security/apparmor/apparmorfs.c
6736 @@ -593,7 +593,7 @@ static __poll_t ns_revision_poll(struct file *file, poll_table *pt)
6737
6738 void __aa_bump_ns_revision(struct aa_ns *ns)
6739 {
6740 - ns->revision++;
6741 + WRITE_ONCE(ns->revision, ns->revision + 1);
6742 wake_up_interruptible(&ns->wait);
6743 }
6744
6745 diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
6746 index 9e0492795267..039ca71872ce 100644
6747 --- a/security/apparmor/domain.c
6748 +++ b/security/apparmor/domain.c
6749 @@ -317,6 +317,7 @@ static int aa_xattrs_match(const struct linux_binprm *bprm,
6750
6751 if (!bprm || !profile->xattr_count)
6752 return 0;
6753 + might_sleep();
6754
6755 /* transition from exec match to xattr set */
6756 state = aa_dfa_null_transition(profile->xmatch, state);
6757 @@ -361,10 +362,11 @@ out:
6758 }
6759
6760 /**
6761 - * __attach_match_ - find an attachment match
6762 + * find_attach - do attachment search for unconfined processes
6763 * @bprm - binprm structure of transitioning task
6764 - * @name - to match against (NOT NULL)
6765 + * @ns: the current namespace (NOT NULL)
6766 * @head - profile list to walk (NOT NULL)
6767 + * @name - to match against (NOT NULL)
6768 * @info - info message if there was an error (NOT NULL)
6769 *
6770 * Do a linear search on the profiles in the list. There is a matching
6771 @@ -374,12 +376,11 @@ out:
6772 *
6773 * Requires: @head not be shared or have appropriate locks held
6774 *
6775 - * Returns: profile or NULL if no match found
6776 + * Returns: label or NULL if no match found
6777 */
6778 -static struct aa_profile *__attach_match(const struct linux_binprm *bprm,
6779 - const char *name,
6780 - struct list_head *head,
6781 - const char **info)
6782 +static struct aa_label *find_attach(const struct linux_binprm *bprm,
6783 + struct aa_ns *ns, struct list_head *head,
6784 + const char *name, const char **info)
6785 {
6786 int candidate_len = 0, candidate_xattrs = 0;
6787 bool conflict = false;
6788 @@ -388,6 +389,8 @@ static struct aa_profile *__attach_match(const struct linux_binprm *bprm,
6789 AA_BUG(!name);
6790 AA_BUG(!head);
6791
6792 + rcu_read_lock();
6793 +restart:
6794 list_for_each_entry_rcu(profile, head, base.list) {
6795 if (profile->label.flags & FLAG_NULL &&
6796 &profile->label == ns_unconfined(profile->ns))
6797 @@ -413,16 +416,32 @@ static struct aa_profile *__attach_match(const struct linux_binprm *bprm,
6798 perm = dfa_user_allow(profile->xmatch, state);
6799 /* any accepting state means a valid match. */
6800 if (perm & MAY_EXEC) {
6801 - int ret;
6802 + int ret = 0;
6803
6804 if (count < candidate_len)
6805 continue;
6806
6807 - ret = aa_xattrs_match(bprm, profile, state);
6808 - /* Fail matching if the xattrs don't match */
6809 - if (ret < 0)
6810 - continue;
6811 -
6812 + if (bprm && profile->xattr_count) {
6813 + long rev = READ_ONCE(ns->revision);
6814 +
6815 + if (!aa_get_profile_not0(profile))
6816 + goto restart;
6817 + rcu_read_unlock();
6818 + ret = aa_xattrs_match(bprm, profile,
6819 + state);
6820 + rcu_read_lock();
6821 + aa_put_profile(profile);
6822 + if (rev !=
6823 + READ_ONCE(ns->revision))
6824 + /* policy changed */
6825 + goto restart;
6826 + /*
6827 + * Fail matching if the xattrs don't
6828 + * match
6829 + */
6830 + if (ret < 0)
6831 + continue;
6832 + }
6833 /*
6834 * TODO: allow for more flexible best match
6835 *
6836 @@ -445,43 +464,28 @@ static struct aa_profile *__attach_match(const struct linux_binprm *bprm,
6837 candidate_xattrs = ret;
6838 conflict = false;
6839 }
6840 - } else if (!strcmp(profile->base.name, name))
6841 + } else if (!strcmp(profile->base.name, name)) {
6842 /*
6843 * old exact non-re match, without conditionals such
6844 * as xattrs. no more searching required
6845 */
6846 - return profile;
6847 + candidate = profile;
6848 + goto out;
6849 + }
6850 }
6851
6852 - if (conflict) {
6853 - *info = "conflicting profile attachments";
6854 + if (!candidate || conflict) {
6855 + if (conflict)
6856 + *info = "conflicting profile attachments";
6857 + rcu_read_unlock();
6858 return NULL;
6859 }
6860
6861 - return candidate;
6862 -}
6863 -
6864 -/**
6865 - * find_attach - do attachment search for unconfined processes
6866 - * @bprm - binprm structure of transitioning task
6867 - * @ns: the current namespace (NOT NULL)
6868 - * @list: list to search (NOT NULL)
6869 - * @name: the executable name to match against (NOT NULL)
6870 - * @info: info message if there was an error
6871 - *
6872 - * Returns: label or NULL if no match found
6873 - */
6874 -static struct aa_label *find_attach(const struct linux_binprm *bprm,
6875 - struct aa_ns *ns, struct list_head *list,
6876 - const char *name, const char **info)
6877 -{
6878 - struct aa_profile *profile;
6879 -
6880 - rcu_read_lock();
6881 - profile = aa_get_profile(__attach_match(bprm, name, list, info));
6882 +out:
6883 + candidate = aa_get_newest_profile(candidate);
6884 rcu_read_unlock();
6885
6886 - return profile ? &profile->label : NULL;
6887 + return &candidate->label;
6888 }
6889
6890 static const char *next_name(int xtype, const char *name)
6891 diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
6892 index ade333074c8e..06355717ee84 100644
6893 --- a/security/apparmor/policy.c
6894 +++ b/security/apparmor/policy.c
6895 @@ -1124,8 +1124,8 @@ ssize_t aa_remove_profiles(struct aa_ns *policy_ns, struct aa_label *subj,
6896 if (!name) {
6897 /* remove namespace - can only happen if fqname[0] == ':' */
6898 mutex_lock_nested(&ns->parent->lock, ns->level);
6899 - __aa_remove_ns(ns);
6900 __aa_bump_ns_revision(ns);
6901 + __aa_remove_ns(ns);
6902 mutex_unlock(&ns->parent->lock);
6903 } else {
6904 /* remove profile */
6905 @@ -1137,9 +1137,9 @@ ssize_t aa_remove_profiles(struct aa_ns *policy_ns, struct aa_label *subj,
6906 goto fail_ns_lock;
6907 }
6908 name = profile->base.hname;
6909 + __aa_bump_ns_revision(ns);
6910 __remove_profile(profile);
6911 __aa_labelset_update_subtree(ns);
6912 - __aa_bump_ns_revision(ns);
6913 mutex_unlock(&ns->lock);
6914 }
6915
6916 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
6917 index d4280568a41e..5c74ea2bb44b 100644
6918 --- a/sound/core/pcm_native.c
6919 +++ b/sound/core/pcm_native.c
6920 @@ -3408,7 +3408,8 @@ int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream,
6921 #endif /* CONFIG_GENERIC_ALLOCATOR */
6922 #ifndef CONFIG_X86 /* for avoiding warnings arch/x86/mm/pat.c */
6923 if (IS_ENABLED(CONFIG_HAS_DMA) && !substream->ops->page &&
6924 - substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV)
6925 + (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV ||
6926 + substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_UC))
6927 return dma_mmap_coherent(substream->dma_buffer.dev.dev,
6928 area,
6929 substream->runtime->dma_area,
6930 diff --git a/sound/firewire/motu/motu-proc.c b/sound/firewire/motu/motu-proc.c
6931 index ea46fb4c1b5a..126a7bd187bb 100644
6932 --- a/sound/firewire/motu/motu-proc.c
6933 +++ b/sound/firewire/motu/motu-proc.c
6934 @@ -16,7 +16,7 @@ static const char *const clock_names[] = {
6935 [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT] = "S/PDIF on optical interface",
6936 [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_A] = "S/PDIF on optical interface A",
6937 [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_B] = "S/PDIF on optical interface B",
6938 - [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX] = "S/PCIF on coaxial interface",
6939 + [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX] = "S/PDIF on coaxial interface",
6940 [SND_MOTU_CLOCK_SOURCE_AESEBU_ON_XLR] = "AESEBU on XLR interface",
6941 [SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC] = "Word clock on BNC interface",
6942 };
6943 diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
6944 index 78dd213589b4..fa3c39cff5f8 100644
6945 --- a/sound/isa/cs423x/cs4236.c
6946 +++ b/sound/isa/cs423x/cs4236.c
6947 @@ -278,7 +278,8 @@ static int snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev)
6948 } else {
6949 mpu_port[dev] = pnp_port_start(pdev, 0);
6950 if (mpu_irq[dev] >= 0 &&
6951 - pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) {
6952 + pnp_irq_valid(pdev, 0) &&
6953 + pnp_irq(pdev, 0) != (resource_size_t)-1) {
6954 mpu_irq[dev] = pnp_irq(pdev, 0);
6955 } else {
6956 mpu_irq[dev] = -1; /* disable interrupt */
6957 diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
6958 index 6387c7e90918..76b507058cb4 100644
6959 --- a/sound/pci/hda/hda_controller.c
6960 +++ b/sound/pci/hda/hda_controller.c
6961 @@ -884,7 +884,7 @@ static int azx_rirb_get_response(struct hdac_bus *bus, unsigned int addr,
6962 return -EAGAIN; /* give a chance to retry */
6963 }
6964
6965 - dev_WARN(chip->card->dev,
6966 + dev_err(chip->card->dev,
6967 "azx_get_response timeout, switching to single_cmd mode: last cmd=0x%08x\n",
6968 bus->last_cmd[addr]);
6969 chip->single_cmd = 1;
6970 diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
6971 index 86a416cdeb29..f6cbb831b86a 100644
6972 --- a/sound/pci/hda/hda_intel.c
6973 +++ b/sound/pci/hda/hda_intel.c
6974 @@ -280,12 +280,13 @@ enum {
6975
6976 /* quirks for old Intel chipsets */
6977 #define AZX_DCAPS_INTEL_ICH \
6978 - (AZX_DCAPS_OLD_SSYNC | AZX_DCAPS_NO_ALIGN_BUFSIZE)
6979 + (AZX_DCAPS_OLD_SSYNC | AZX_DCAPS_NO_ALIGN_BUFSIZE |\
6980 + AZX_DCAPS_SYNC_WRITE)
6981
6982 /* quirks for Intel PCH */
6983 #define AZX_DCAPS_INTEL_PCH_BASE \
6984 (AZX_DCAPS_NO_ALIGN_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY |\
6985 - AZX_DCAPS_SNOOP_TYPE(SCH))
6986 + AZX_DCAPS_SNOOP_TYPE(SCH) | AZX_DCAPS_SYNC_WRITE)
6987
6988 /* PCH up to IVB; no runtime PM; bind with i915 gfx */
6989 #define AZX_DCAPS_INTEL_PCH_NOPM \
6990 @@ -300,13 +301,13 @@ enum {
6991 #define AZX_DCAPS_INTEL_HASWELL \
6992 (/*AZX_DCAPS_ALIGN_BUFSIZE |*/ AZX_DCAPS_COUNT_LPIB_DELAY |\
6993 AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_COMPONENT |\
6994 - AZX_DCAPS_SNOOP_TYPE(SCH))
6995 + AZX_DCAPS_SNOOP_TYPE(SCH) | AZX_DCAPS_SYNC_WRITE)
6996
6997 /* Broadwell HDMI can't use position buffer reliably, force to use LPIB */
6998 #define AZX_DCAPS_INTEL_BROADWELL \
6999 (/*AZX_DCAPS_ALIGN_BUFSIZE |*/ AZX_DCAPS_POSFIX_LPIB |\
7000 AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_COMPONENT |\
7001 - AZX_DCAPS_SNOOP_TYPE(SCH))
7002 + AZX_DCAPS_SNOOP_TYPE(SCH) | AZX_DCAPS_SYNC_WRITE)
7003
7004 #define AZX_DCAPS_INTEL_BAYTRAIL \
7005 (AZX_DCAPS_INTEL_PCH_BASE | AZX_DCAPS_I915_COMPONENT)
7006 @@ -1280,11 +1281,17 @@ static void init_vga_switcheroo(struct azx *chip)
7007 {
7008 struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
7009 struct pci_dev *p = get_bound_vga(chip->pci);
7010 + struct pci_dev *parent;
7011 if (p) {
7012 dev_info(chip->card->dev,
7013 "Handle vga_switcheroo audio client\n");
7014 hda->use_vga_switcheroo = 1;
7015 - chip->bus.keep_power = 1; /* cleared in either gpu_bound op or codec probe */
7016 +
7017 + /* cleared in either gpu_bound op or codec probe, or when its
7018 + * upstream port has _PR3 (i.e. dGPU).
7019 + */
7020 + parent = pci_upstream_bridge(p);
7021 + chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1;
7022 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME;
7023 pci_dev_put(p);
7024 }
7025 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
7026 index e1229dbad6b2..252888f426de 100644
7027 --- a/sound/pci/hda/patch_realtek.c
7028 +++ b/sound/pci/hda/patch_realtek.c
7029 @@ -501,6 +501,7 @@ static void alc_shutup_pins(struct hda_codec *codec)
7030 struct alc_spec *spec = codec->spec;
7031
7032 switch (codec->core.vendor_id) {
7033 + case 0x10ec0283:
7034 case 0x10ec0286:
7035 case 0x10ec0288:
7036 case 0x10ec0298:
7037 @@ -5547,6 +5548,16 @@ static void alc295_fixup_disable_dac3(struct hda_codec *codec,
7038 }
7039 }
7040
7041 +/* force NID 0x17 (Bass Speaker) to DAC1 to share it with the main speaker */
7042 +static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec,
7043 + const struct hda_fixup *fix, int action)
7044 +{
7045 + if (action == HDA_FIXUP_ACT_PRE_PROBE) {
7046 + hda_nid_t conn[1] = { 0x02 };
7047 + snd_hda_override_conn_list(codec, 0x17, 1, conn);
7048 + }
7049 +}
7050 +
7051 /* Hook to update amp GPIO4 for automute */
7052 static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
7053 struct hda_jack_callback *jack)
7054 @@ -5849,6 +5860,7 @@ enum {
7055 ALC225_FIXUP_DISABLE_MIC_VREF,
7056 ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7057 ALC295_FIXUP_DISABLE_DAC3,
7058 + ALC285_FIXUP_SPEAKER2_TO_DAC1,
7059 ALC280_FIXUP_HP_HEADSET_MIC,
7060 ALC221_FIXUP_HP_FRONT_MIC,
7061 ALC292_FIXUP_TPT460,
7062 @@ -5893,9 +5905,12 @@ enum {
7063 ALC256_FIXUP_ASUS_HEADSET_MIC,
7064 ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
7065 ALC299_FIXUP_PREDATOR_SPK,
7066 - ALC294_FIXUP_ASUS_INTSPK_HEADSET_MIC,
7067 ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE,
7068 - ALC294_FIXUP_ASUS_INTSPK_GPIO,
7069 + ALC289_FIXUP_DELL_SPK2,
7070 + ALC289_FIXUP_DUAL_SPK,
7071 + ALC294_FIXUP_SPK2_TO_DAC1,
7072 + ALC294_FIXUP_ASUS_DUAL_SPK,
7073 +
7074 };
7075
7076 static const struct hda_fixup alc269_fixups[] = {
7077 @@ -6649,6 +6664,10 @@ static const struct hda_fixup alc269_fixups[] = {
7078 .type = HDA_FIXUP_FUNC,
7079 .v.func = alc295_fixup_disable_dac3,
7080 },
7081 + [ALC285_FIXUP_SPEAKER2_TO_DAC1] = {
7082 + .type = HDA_FIXUP_FUNC,
7083 + .v.func = alc285_fixup_speaker2_to_dac1,
7084 + },
7085 [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
7086 .type = HDA_FIXUP_PINS,
7087 .v.pins = (const struct hda_pintbl[]) {
7088 @@ -6966,33 +6985,45 @@ static const struct hda_fixup alc269_fixups[] = {
7089 { }
7090 }
7091 },
7092 - [ALC294_FIXUP_ASUS_INTSPK_HEADSET_MIC] = {
7093 + [ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE] = {
7094 .type = HDA_FIXUP_PINS,
7095 .v.pins = (const struct hda_pintbl[]) {
7096 - { 0x14, 0x411111f0 }, /* disable confusing internal speaker */
7097 - { 0x19, 0x04a11150 }, /* use as headset mic, without its own jack detect */
7098 + { 0x19, 0x04a11040 },
7099 + { 0x21, 0x04211020 },
7100 { }
7101 },
7102 .chained = true,
7103 - .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7104 + .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7105 },
7106 - [ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE] = {
7107 + [ALC289_FIXUP_DELL_SPK2] = {
7108 .type = HDA_FIXUP_PINS,
7109 .v.pins = (const struct hda_pintbl[]) {
7110 - { 0x19, 0x04a11040 },
7111 - { 0x21, 0x04211020 },
7112 + { 0x17, 0x90170130 }, /* bass spk */
7113 { }
7114 },
7115 .chained = true,
7116 - .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7117 + .chain_id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE
7118 },
7119 - [ALC294_FIXUP_ASUS_INTSPK_GPIO] = {
7120 + [ALC289_FIXUP_DUAL_SPK] = {
7121 + .type = HDA_FIXUP_FUNC,
7122 + .v.func = alc285_fixup_speaker2_to_dac1,
7123 + .chained = true,
7124 + .chain_id = ALC289_FIXUP_DELL_SPK2
7125 + },
7126 + [ALC294_FIXUP_SPK2_TO_DAC1] = {
7127 + .type = HDA_FIXUP_FUNC,
7128 + .v.func = alc285_fixup_speaker2_to_dac1,
7129 + .chained = true,
7130 + .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
7131 + },
7132 + [ALC294_FIXUP_ASUS_DUAL_SPK] = {
7133 .type = HDA_FIXUP_FUNC,
7134 /* The GPIO must be pulled to initialize the AMP */
7135 .v.func = alc_fixup_gpio4,
7136 .chained = true,
7137 - .chain_id = ALC294_FIXUP_ASUS_INTSPK_HEADSET_MIC
7138 + .chain_id = ALC294_FIXUP_SPK2_TO_DAC1
7139 },
7140 +
7141 };
7142
7143 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
7144 @@ -7065,6 +7096,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
7145 SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE),
7146 SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE),
7147 SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
7148 + SND_PCI_QUIRK(0x1028, 0x097e, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
7149 + SND_PCI_QUIRK(0x1028, 0x097d, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
7150 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
7151 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
7152 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
7153 @@ -7152,7 +7185,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
7154 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
7155 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
7156 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
7157 - SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_INTSPK_GPIO),
7158 + SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_DUAL_SPK),
7159 SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
7160 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
7161 SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
7162 @@ -7224,6 +7257,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
7163 SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7164 SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
7165 SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
7166 + SND_PCI_QUIRK(0x17aa, 0x2293, "Thinkpad X1 Carbon 7th", ALC285_FIXUP_SPEAKER2_TO_DAC1),
7167 SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
7168 SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
7169 SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
7170 @@ -7408,6 +7442,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
7171 {.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"},
7172 {.id = ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc225-dell1"},
7173 {.id = ALC295_FIXUP_DISABLE_DAC3, .name = "alc295-disable-dac3"},
7174 + {.id = ALC285_FIXUP_SPEAKER2_TO_DAC1, .name = "alc285-speaker2-to-dac1"},
7175 {.id = ALC280_FIXUP_HP_HEADSET_MIC, .name = "alc280-hp-headset"},
7176 {.id = ALC221_FIXUP_HP_FRONT_MIC, .name = "alc221-hp-mic"},
7177 {.id = ALC298_FIXUP_SPK_VOLUME, .name = "alc298-spk-volume"},
7178 diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
7179 index e62c11816683..f360b33a1042 100644
7180 --- a/sound/pci/ice1712/ice1724.c
7181 +++ b/sound/pci/ice1712/ice1724.c
7182 @@ -647,6 +647,7 @@ static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
7183 unsigned long flags;
7184 unsigned char mclk_change;
7185 unsigned int i, old_rate;
7186 + bool call_set_rate = false;
7187
7188 if (rate > ice->hw_rates->list[ice->hw_rates->count - 1])
7189 return -EINVAL;
7190 @@ -670,7 +671,7 @@ static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
7191 * setting clock rate for internal clock mode */
7192 old_rate = ice->get_rate(ice);
7193 if (force || (old_rate != rate))
7194 - ice->set_rate(ice, rate);
7195 + call_set_rate = true;
7196 else if (rate == ice->cur_rate) {
7197 spin_unlock_irqrestore(&ice->reg_lock, flags);
7198 return 0;
7199 @@ -678,12 +679,14 @@ static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
7200 }
7201
7202 ice->cur_rate = rate;
7203 + spin_unlock_irqrestore(&ice->reg_lock, flags);
7204 +
7205 + if (call_set_rate)
7206 + ice->set_rate(ice, rate);
7207
7208 /* setting master clock */
7209 mclk_change = ice->set_mclk(ice, rate);
7210
7211 - spin_unlock_irqrestore(&ice->reg_lock, flags);
7212 -
7213 if (mclk_change && ice->gpio.i2s_mclk_changed)
7214 ice->gpio.i2s_mclk_changed(ice);
7215 if (ice->gpio.set_pro_rate)
7216 diff --git a/sound/usb/card.h b/sound/usb/card.h
7217 index 2991b9986f66..395403a2d33f 100644
7218 --- a/sound/usb/card.h
7219 +++ b/sound/usb/card.h
7220 @@ -145,6 +145,7 @@ struct snd_usb_substream {
7221 struct snd_usb_endpoint *sync_endpoint;
7222 unsigned long flags;
7223 bool need_setup_ep; /* (re)configure EP at prepare? */
7224 + bool need_setup_fmt; /* (re)configure fmt after resume? */
7225 unsigned int speed; /* USB_SPEED_XXX */
7226
7227 u64 formats; /* format bitmasks (all or'ed) */
7228 diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
7229 index ff5ab24f3bd1..a04c727dcd19 100644
7230 --- a/sound/usb/pcm.c
7231 +++ b/sound/usb/pcm.c
7232 @@ -506,15 +506,15 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
7233 if (WARN_ON(!iface))
7234 return -EINVAL;
7235 alts = usb_altnum_to_altsetting(iface, fmt->altsetting);
7236 - altsd = get_iface_desc(alts);
7237 - if (WARN_ON(altsd->bAlternateSetting != fmt->altsetting))
7238 + if (WARN_ON(!alts))
7239 return -EINVAL;
7240 + altsd = get_iface_desc(alts);
7241
7242 - if (fmt == subs->cur_audiofmt)
7243 + if (fmt == subs->cur_audiofmt && !subs->need_setup_fmt)
7244 return 0;
7245
7246 /* close the old interface */
7247 - if (subs->interface >= 0 && subs->interface != fmt->iface) {
7248 + if (subs->interface >= 0 && (subs->interface != fmt->iface || subs->need_setup_fmt)) {
7249 if (!subs->stream->chip->keep_iface) {
7250 err = usb_set_interface(subs->dev, subs->interface, 0);
7251 if (err < 0) {
7252 @@ -528,6 +528,9 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
7253 subs->altset_idx = 0;
7254 }
7255
7256 + if (subs->need_setup_fmt)
7257 + subs->need_setup_fmt = false;
7258 +
7259 /* set interface */
7260 if (iface->cur_altsetting != alts) {
7261 err = snd_usb_select_mode_quirk(subs, fmt);
7262 @@ -1735,6 +1738,13 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea
7263 subs->data_endpoint->retire_data_urb = retire_playback_urb;
7264 subs->running = 0;
7265 return 0;
7266 + case SNDRV_PCM_TRIGGER_SUSPEND:
7267 + if (subs->stream->chip->setup_fmt_after_resume_quirk) {
7268 + stop_endpoints(subs, true);
7269 + subs->need_setup_fmt = true;
7270 + return 0;
7271 + }
7272 + break;
7273 }
7274
7275 return -EINVAL;
7276 @@ -1767,6 +1777,13 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream
7277 subs->data_endpoint->retire_data_urb = retire_capture_urb;
7278 subs->running = 1;
7279 return 0;
7280 + case SNDRV_PCM_TRIGGER_SUSPEND:
7281 + if (subs->stream->chip->setup_fmt_after_resume_quirk) {
7282 + stop_endpoints(subs, true);
7283 + subs->need_setup_fmt = true;
7284 + return 0;
7285 + }
7286 + break;
7287 }
7288
7289 return -EINVAL;
7290 diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
7291 index 70c338f3ae24..d187aa6d50db 100644
7292 --- a/sound/usb/quirks-table.h
7293 +++ b/sound/usb/quirks-table.h
7294 @@ -3466,7 +3466,8 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
7295 .vendor_name = "Dell",
7296 .product_name = "WD19 Dock",
7297 .profile_name = "Dell-WD15-Dock",
7298 - .ifnum = QUIRK_NO_INTERFACE
7299 + .ifnum = QUIRK_ANY_INTERFACE,
7300 + .type = QUIRK_SETUP_FMT_AFTER_RESUME
7301 }
7302 },
7303 /* MOTU Microbook II */
7304 diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
7305 index 349e1e52996d..a81c2066499f 100644
7306 --- a/sound/usb/quirks.c
7307 +++ b/sound/usb/quirks.c
7308 @@ -508,6 +508,16 @@ static int create_standard_mixer_quirk(struct snd_usb_audio *chip,
7309 return snd_usb_create_mixer(chip, quirk->ifnum, 0);
7310 }
7311
7312 +
7313 +static int setup_fmt_after_resume_quirk(struct snd_usb_audio *chip,
7314 + struct usb_interface *iface,
7315 + struct usb_driver *driver,
7316 + const struct snd_usb_audio_quirk *quirk)
7317 +{
7318 + chip->setup_fmt_after_resume_quirk = 1;
7319 + return 1; /* Continue with creating streams and mixer */
7320 +}
7321 +
7322 /*
7323 * audio-interface quirks
7324 *
7325 @@ -546,6 +556,7 @@ int snd_usb_create_quirk(struct snd_usb_audio *chip,
7326 [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk,
7327 [QUIRK_AUDIO_ALIGN_TRANSFER] = create_align_transfer_quirk,
7328 [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk,
7329 + [QUIRK_SETUP_FMT_AFTER_RESUME] = setup_fmt_after_resume_quirk,
7330 };
7331
7332 if (quirk->type < QUIRK_TYPE_COUNT) {
7333 diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
7334 index feb30f9c1716..e360680f45f3 100644
7335 --- a/sound/usb/usbaudio.h
7336 +++ b/sound/usb/usbaudio.h
7337 @@ -33,7 +33,7 @@ struct snd_usb_audio {
7338 wait_queue_head_t shutdown_wait;
7339 unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */
7340 unsigned int tx_length_quirk:1; /* Put length specifier in transfers */
7341 -
7342 + unsigned int setup_fmt_after_resume_quirk:1; /* setup the format to interface after resume */
7343 int num_interfaces;
7344 int num_suspended_intf;
7345 int sample_rate_read_error;
7346 @@ -98,6 +98,7 @@ enum quirk_type {
7347 QUIRK_AUDIO_EDIROL_UAXX,
7348 QUIRK_AUDIO_ALIGN_TRANSFER,
7349 QUIRK_AUDIO_STANDARD_MIXER,
7350 + QUIRK_SETUP_FMT_AFTER_RESUME,
7351
7352 QUIRK_TYPE_COUNT
7353 };
7354 diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
7355 index 70a9f8716a4b..888814df758d 100644
7356 --- a/tools/perf/util/machine.c
7357 +++ b/tools/perf/util/machine.c
7358 @@ -2403,7 +2403,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
7359 }
7360
7361 check_calls:
7362 - if (callchain_param.order != ORDER_CALLEE) {
7363 + if (chain && callchain_param.order != ORDER_CALLEE) {
7364 err = find_prev_cpumode(chain, thread, cursor, parent, root_al,
7365 &cpumode, chain->nr - first_call);
7366 if (err)
7367 diff --git a/tools/testing/selftests/rseq/param_test.c b/tools/testing/selftests/rseq/param_test.c
7368 index eec2663261f2..e8a657a5f48a 100644
7369 --- a/tools/testing/selftests/rseq/param_test.c
7370 +++ b/tools/testing/selftests/rseq/param_test.c
7371 @@ -15,7 +15,7 @@
7372 #include <errno.h>
7373 #include <stddef.h>
7374
7375 -static inline pid_t gettid(void)
7376 +static inline pid_t rseq_gettid(void)
7377 {
7378 return syscall(__NR_gettid);
7379 }
7380 @@ -373,11 +373,12 @@ void *test_percpu_spinlock_thread(void *arg)
7381 rseq_percpu_unlock(&data->lock, cpu);
7382 #ifndef BENCHMARK
7383 if (i != 0 && !(i % (reps / 10)))
7384 - printf_verbose("tid %d: count %lld\n", (int) gettid(), i);
7385 + printf_verbose("tid %d: count %lld\n",
7386 + (int) rseq_gettid(), i);
7387 #endif
7388 }
7389 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n",
7390 - (int) gettid(), nr_abort, signals_delivered);
7391 + (int) rseq_gettid(), nr_abort, signals_delivered);
7392 if (!opt_disable_rseq && thread_data->reg &&
7393 rseq_unregister_current_thread())
7394 abort();
7395 @@ -454,11 +455,12 @@ void *test_percpu_inc_thread(void *arg)
7396 } while (rseq_unlikely(ret));
7397 #ifndef BENCHMARK
7398 if (i != 0 && !(i % (reps / 10)))
7399 - printf_verbose("tid %d: count %lld\n", (int) gettid(), i);
7400 + printf_verbose("tid %d: count %lld\n",
7401 + (int) rseq_gettid(), i);
7402 #endif
7403 }
7404 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n",
7405 - (int) gettid(), nr_abort, signals_delivered);
7406 + (int) rseq_gettid(), nr_abort, signals_delivered);
7407 if (!opt_disable_rseq && thread_data->reg &&
7408 rseq_unregister_current_thread())
7409 abort();
7410 @@ -605,7 +607,7 @@ void *test_percpu_list_thread(void *arg)
7411 }
7412
7413 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n",
7414 - (int) gettid(), nr_abort, signals_delivered);
7415 + (int) rseq_gettid(), nr_abort, signals_delivered);
7416 if (!opt_disable_rseq && rseq_unregister_current_thread())
7417 abort();
7418
7419 @@ -796,7 +798,7 @@ void *test_percpu_buffer_thread(void *arg)
7420 }
7421
7422 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n",
7423 - (int) gettid(), nr_abort, signals_delivered);
7424 + (int) rseq_gettid(), nr_abort, signals_delivered);
7425 if (!opt_disable_rseq && rseq_unregister_current_thread())
7426 abort();
7427
7428 @@ -1011,7 +1013,7 @@ void *test_percpu_memcpy_buffer_thread(void *arg)
7429 }
7430
7431 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n",
7432 - (int) gettid(), nr_abort, signals_delivered);
7433 + (int) rseq_gettid(), nr_abort, signals_delivered);
7434 if (!opt_disable_rseq && rseq_unregister_current_thread())
7435 abort();
7436
7437 diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
7438 index b505bb062d07..96bbda4f10fc 100644
7439 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
7440 +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
7441 @@ -3147,7 +3147,18 @@ TEST(user_notification_basic)
7442 EXPECT_GT(poll(&pollfd, 1, -1), 0);
7443 EXPECT_EQ(pollfd.revents, POLLIN);
7444
7445 - EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req), 0);
7446 + /* Test that we can't pass garbage to the kernel. */
7447 + memset(&req, 0, sizeof(req));
7448 + req.pid = -1;
7449 + errno = 0;
7450 + ret = ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req);
7451 + EXPECT_EQ(-1, ret);
7452 + EXPECT_EQ(EINVAL, errno);
7453 +
7454 + if (ret) {
7455 + req.pid = 0;
7456 + EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req), 0);
7457 + }
7458
7459 pollfd.fd = listener;
7460 pollfd.events = POLLIN | POLLOUT;
7461 @@ -3267,6 +3278,7 @@ TEST(user_notification_signal)
7462
7463 close(sk_pair[1]);
7464
7465 + memset(&req, 0, sizeof(req));
7466 EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req), 0);
7467
7468 EXPECT_EQ(kill(pid, SIGUSR1), 0);
7469 @@ -3285,6 +3297,7 @@ TEST(user_notification_signal)
7470 EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_SEND, &resp), -1);
7471 EXPECT_EQ(errno, ENOENT);
7472
7473 + memset(&req, 0, sizeof(req));
7474 EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req), 0);
7475
7476 resp.id = req.id;
7477 diff --git a/usr/gen_initramfs_list.sh b/usr/gen_initramfs_list.sh
7478 index 0aad760fcd8c..2bbac73e6477 100755
7479 --- a/usr/gen_initramfs_list.sh
7480 +++ b/usr/gen_initramfs_list.sh
7481 @@ -128,7 +128,7 @@ parse() {
7482 str="${ftype} ${name} ${location} ${str}"
7483 ;;
7484 "nod")
7485 - local dev=`LC_ALL=C ls -l "${location}"`
7486 + local dev="`LC_ALL=C ls -l "${location}"`"
7487 local maj=`field 5 ${dev}`
7488 local min=`field 6 ${dev}`
7489 maj=${maj%,}