Magellan Linux

Contents of /trunk/kernel-alx/patches-4.19/0162-4.19.63-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3441 - (show annotations) (download)
Fri Aug 2 11:48:08 2019 UTC (4 years, 9 months ago) by niro
File size: 106030 byte(s)
-linux-4.19.63
1 diff --git a/Makefile b/Makefile
2 index a4463d880ae2..8ad77a93de30 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,7 +1,7 @@
6 # SPDX-License-Identifier: GPL-2.0
7 VERSION = 4
8 PATCHLEVEL = 19
9 -SUBLEVEL = 62
10 +SUBLEVEL = 63
11 EXTRAVERSION =
12 NAME = "People's Front"
13
14 @@ -491,6 +491,7 @@ ifneq ($(GCC_TOOLCHAIN),)
15 CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
16 endif
17 CLANG_FLAGS += -no-integrated-as
18 +CLANG_FLAGS += -Werror=unknown-warning-option
19 KBUILD_CFLAGS += $(CLANG_FLAGS)
20 KBUILD_AFLAGS += $(CLANG_FLAGS)
21 export CLANG_FLAGS
22 diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
23 index f90f5d83b228..5a97ac853168 100644
24 --- a/arch/arm64/include/asm/assembler.h
25 +++ b/arch/arm64/include/asm/assembler.h
26 @@ -112,7 +112,11 @@
27 * RAS Error Synchronization barrier
28 */
29 .macro esb
30 +#ifdef CONFIG_ARM64_RAS_EXTN
31 hint #16
32 +#else
33 + nop
34 +#endif
35 .endm
36
37 /*
38 diff --git a/arch/powerpc/boot/xz_config.h b/arch/powerpc/boot/xz_config.h
39 index e22e5b3770dd..ebfadd39e192 100644
40 --- a/arch/powerpc/boot/xz_config.h
41 +++ b/arch/powerpc/boot/xz_config.h
42 @@ -20,10 +20,30 @@ static inline uint32_t swab32p(void *p)
43
44 #ifdef __LITTLE_ENDIAN__
45 #define get_le32(p) (*((uint32_t *) (p)))
46 +#define cpu_to_be32(x) swab32(x)
47 +static inline u32 be32_to_cpup(const u32 *p)
48 +{
49 + return swab32p((u32 *)p);
50 +}
51 #else
52 #define get_le32(p) swab32p(p)
53 +#define cpu_to_be32(x) (x)
54 +static inline u32 be32_to_cpup(const u32 *p)
55 +{
56 + return *p;
57 +}
58 #endif
59
60 +static inline uint32_t get_unaligned_be32(const void *p)
61 +{
62 + return be32_to_cpup(p);
63 +}
64 +
65 +static inline void put_unaligned_be32(u32 val, void *p)
66 +{
67 + *((u32 *)p) = cpu_to_be32(val);
68 +}
69 +
70 #define memeq(a, b, size) (memcmp(a, b, size) == 0)
71 #define memzero(buf, size) memset(buf, 0, size)
72
73 diff --git a/arch/powerpc/include/asm/cacheflush.h b/arch/powerpc/include/asm/cacheflush.h
74 index d5a8d7bf0759..b189f7aee222 100644
75 --- a/arch/powerpc/include/asm/cacheflush.h
76 +++ b/arch/powerpc/include/asm/cacheflush.h
77 @@ -32,9 +32,12 @@
78 * not expect this type of fault. flush_cache_vmap is not exactly the right
79 * place to put this, but it seems to work well enough.
80 */
81 -#define flush_cache_vmap(start, end) do { asm volatile("ptesync" ::: "memory"); } while (0)
82 +static inline void flush_cache_vmap(unsigned long start, unsigned long end)
83 +{
84 + asm volatile("ptesync" ::: "memory");
85 +}
86 #else
87 -#define flush_cache_vmap(start, end) do { } while (0)
88 +static inline void flush_cache_vmap(unsigned long start, unsigned long end) { }
89 #endif
90
91 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
92 diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
93 index c72767a5327a..fe3c6f3bd3b6 100644
94 --- a/arch/powerpc/kernel/eeh.c
95 +++ b/arch/powerpc/kernel/eeh.c
96 @@ -360,10 +360,19 @@ static inline unsigned long eeh_token_to_phys(unsigned long token)
97 ptep = find_init_mm_pte(token, &hugepage_shift);
98 if (!ptep)
99 return token;
100 - WARN_ON(hugepage_shift);
101 - pa = pte_pfn(*ptep) << PAGE_SHIFT;
102
103 - return pa | (token & (PAGE_SIZE-1));
104 + pa = pte_pfn(*ptep);
105 +
106 + /* On radix we can do hugepage mappings for io, so handle that */
107 + if (hugepage_shift) {
108 + pa <<= hugepage_shift;
109 + pa |= token & ((1ul << hugepage_shift) - 1);
110 + } else {
111 + pa <<= PAGE_SHIFT;
112 + pa |= token & (PAGE_SIZE - 1);
113 + }
114 +
115 + return pa;
116 }
117
118 /*
119 diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
120 index 98f04725def7..c101b321dece 100644
121 --- a/arch/powerpc/kernel/pci_of_scan.c
122 +++ b/arch/powerpc/kernel/pci_of_scan.c
123 @@ -45,6 +45,8 @@ unsigned int pci_parse_of_flags(u32 addr0, int bridge)
124 if (addr0 & 0x02000000) {
125 flags = IORESOURCE_MEM | PCI_BASE_ADDRESS_SPACE_MEMORY;
126 flags |= (addr0 >> 22) & PCI_BASE_ADDRESS_MEM_TYPE_64;
127 + if (flags & PCI_BASE_ADDRESS_MEM_TYPE_64)
128 + flags |= IORESOURCE_MEM_64;
129 flags |= (addr0 >> 28) & PCI_BASE_ADDRESS_MEM_TYPE_1M;
130 if (addr0 & 0x40000000)
131 flags |= IORESOURCE_PREFETCH
132 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
133 index fd59fef9931b..906b05c2adae 100644
134 --- a/arch/powerpc/kernel/signal_32.c
135 +++ b/arch/powerpc/kernel/signal_32.c
136 @@ -1202,6 +1202,9 @@ SYSCALL_DEFINE0(rt_sigreturn)
137 goto bad;
138
139 if (MSR_TM_ACTIVE(msr_hi<<32)) {
140 + /* Trying to start TM on non TM system */
141 + if (!cpu_has_feature(CPU_FTR_TM))
142 + goto bad;
143 /* We only recheckpoint on return if we're
144 * transaction.
145 */
146 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
147 index 14b0f5b6a373..b5933d7219db 100644
148 --- a/arch/powerpc/kernel/signal_64.c
149 +++ b/arch/powerpc/kernel/signal_64.c
150 @@ -750,6 +750,11 @@ SYSCALL_DEFINE0(rt_sigreturn)
151 if (MSR_TM_ACTIVE(msr)) {
152 /* We recheckpoint on return. */
153 struct ucontext __user *uc_transact;
154 +
155 + /* Trying to start TM on non TM system */
156 + if (!cpu_has_feature(CPU_FTR_TM))
157 + goto badframe;
158 +
159 if (__get_user(uc_transact, &uc->uc_link))
160 goto badframe;
161 if (restore_tm_sigcontexts(current, &uc->uc_mcontext,
162 diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
163 index 7296a42eb62e..cef0b7ee1024 100644
164 --- a/arch/powerpc/mm/hugetlbpage.c
165 +++ b/arch/powerpc/mm/hugetlbpage.c
166 @@ -150,6 +150,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
167 } else {
168 pdshift = PUD_SHIFT;
169 pu = pud_alloc(mm, pg, addr);
170 + if (!pu)
171 + return NULL;
172 if (pshift == PUD_SHIFT)
173 return (pte_t *)pu;
174 else if (pshift > PMD_SHIFT) {
175 @@ -158,6 +160,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
176 } else {
177 pdshift = PMD_SHIFT;
178 pm = pmd_alloc(mm, pu, addr);
179 + if (!pm)
180 + return NULL;
181 if (pshift == PMD_SHIFT)
182 /* 16MB hugepage */
183 return (pte_t *)pm;
184 @@ -174,12 +178,16 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
185 } else {
186 pdshift = PUD_SHIFT;
187 pu = pud_alloc(mm, pg, addr);
188 + if (!pu)
189 + return NULL;
190 if (pshift >= PUD_SHIFT) {
191 ptl = pud_lockptr(mm, pu);
192 hpdp = (hugepd_t *)pu;
193 } else {
194 pdshift = PMD_SHIFT;
195 pm = pmd_alloc(mm, pu, addr);
196 + if (!pm)
197 + return NULL;
198 ptl = pmd_lockptr(mm, pm);
199 hpdp = (hugepd_t *)pm;
200 }
201 diff --git a/arch/powerpc/platforms/4xx/uic.c b/arch/powerpc/platforms/4xx/uic.c
202 index 8b4dd0da0839..9e27cfe27026 100644
203 --- a/arch/powerpc/platforms/4xx/uic.c
204 +++ b/arch/powerpc/platforms/4xx/uic.c
205 @@ -158,6 +158,7 @@ static int uic_set_irq_type(struct irq_data *d, unsigned int flow_type)
206
207 mtdcr(uic->dcrbase + UIC_PR, pr);
208 mtdcr(uic->dcrbase + UIC_TR, tr);
209 + mtdcr(uic->dcrbase + UIC_SR, ~mask);
210
211 raw_spin_unlock_irqrestore(&uic->lock, flags);
212
213 diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c
214 index f0e30dc94988..7b60fcf04dc4 100644
215 --- a/arch/powerpc/platforms/pseries/mobility.c
216 +++ b/arch/powerpc/platforms/pseries/mobility.c
217 @@ -9,6 +9,7 @@
218 * 2 as published by the Free Software Foundation.
219 */
220
221 +#include <linux/cpu.h>
222 #include <linux/kernel.h>
223 #include <linux/kobject.h>
224 #include <linux/smp.h>
225 @@ -344,11 +345,19 @@ void post_mobility_fixup(void)
226 if (rc)
227 printk(KERN_ERR "Post-mobility activate-fw failed: %d\n", rc);
228
229 + /*
230 + * We don't want CPUs to go online/offline while the device
231 + * tree is being updated.
232 + */
233 + cpus_read_lock();
234 +
235 rc = pseries_devicetree_update(MIGRATION_SCOPE);
236 if (rc)
237 printk(KERN_ERR "Post-mobility device tree update "
238 "failed: %d\n", rc);
239
240 + cpus_read_unlock();
241 +
242 /* Possibly switch to a new RFI flush type */
243 pseries_setup_rfi_flush();
244
245 diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
246 index 959a2a62f233..0b24b1031221 100644
247 --- a/arch/powerpc/sysdev/xive/common.c
248 +++ b/arch/powerpc/sysdev/xive/common.c
249 @@ -483,7 +483,7 @@ static int xive_find_target_in_mask(const struct cpumask *mask,
250 * Now go through the entire mask until we find a valid
251 * target.
252 */
253 - for (;;) {
254 + do {
255 /*
256 * We re-check online as the fallback case passes us
257 * an untested affinity mask
258 @@ -491,12 +491,11 @@ static int xive_find_target_in_mask(const struct cpumask *mask,
259 if (cpu_online(cpu) && xive_try_pick_target(cpu))
260 return cpu;
261 cpu = cpumask_next(cpu, mask);
262 - if (cpu == first)
263 - break;
264 /* Wrap around */
265 if (cpu >= nr_cpu_ids)
266 cpu = cpumask_first(mask);
267 - }
268 + } while (cpu != first);
269 +
270 return -1;
271 }
272
273 diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
274 index dd6badc31f45..74cfc1be04d6 100644
275 --- a/arch/powerpc/xmon/xmon.c
276 +++ b/arch/powerpc/xmon/xmon.c
277 @@ -466,8 +466,10 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
278 local_irq_save(flags);
279 hard_irq_disable();
280
281 - tracing_enabled = tracing_is_on();
282 - tracing_off();
283 + if (!fromipi) {
284 + tracing_enabled = tracing_is_on();
285 + tracing_off();
286 + }
287
288 bp = in_breakpoint_table(regs->nip, &offset);
289 if (bp != NULL) {
290 diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
291 index 98cb8c802b1a..0ae60d680000 100644
292 --- a/arch/sh/include/asm/io.h
293 +++ b/arch/sh/include/asm/io.h
294 @@ -371,7 +371,11 @@ static inline int iounmap_fixed(void __iomem *addr) { return -EINVAL; }
295
296 #define ioremap_nocache ioremap
297 #define ioremap_uc ioremap
298 -#define iounmap __iounmap
299 +
300 +static inline void iounmap(void __iomem *addr)
301 +{
302 + __iounmap(addr);
303 +}
304
305 /*
306 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
307 diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h
308 index fca34b2177e2..129fb1d1f1c5 100644
309 --- a/arch/um/include/asm/mmu_context.h
310 +++ b/arch/um/include/asm/mmu_context.h
311 @@ -53,7 +53,7 @@ static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
312 * when the new ->mm is used for the first time.
313 */
314 __switch_mm(&new->context.id);
315 - down_write(&new->mmap_sem);
316 + down_write_nested(&new->mmap_sem, 1);
317 uml_setup_stubs(new);
318 up_write(&new->mmap_sem);
319 }
320 diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
321 index a5cde748cf76..c5690440fbd4 100644
322 --- a/arch/x86/kernel/cpu/bugs.c
323 +++ b/arch/x86/kernel/cpu/bugs.c
324 @@ -1196,7 +1196,7 @@ static ssize_t l1tf_show_state(char *buf)
325
326 static ssize_t mds_show_state(char *buf)
327 {
328 - if (!hypervisor_is_type(X86_HYPER_NATIVE)) {
329 + if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) {
330 return sprintf(buf, "%s; SMT Host state unknown\n",
331 mds_strings[mds_mitigation]);
332 }
333 diff --git a/arch/x86/kernel/sysfb_efi.c b/arch/x86/kernel/sysfb_efi.c
334 index 623965e86b65..897da526e40e 100644
335 --- a/arch/x86/kernel/sysfb_efi.c
336 +++ b/arch/x86/kernel/sysfb_efi.c
337 @@ -231,9 +231,55 @@ static const struct dmi_system_id efifb_dmi_system_table[] __initconst = {
338 {},
339 };
340
341 +/*
342 + * Some devices have a portrait LCD but advertise a landscape resolution (and
343 + * pitch). We simply swap width and height for these devices so that we can
344 + * correctly deal with some of them coming with multiple resolutions.
345 + */
346 +static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
347 + {
348 + /*
349 + * Lenovo MIIX310-10ICR, only some batches have the troublesome
350 + * 800x1280 portrait screen. Luckily the portrait version has
351 + * its own BIOS version, so we match on that.
352 + */
353 + .matches = {
354 + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
355 + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "MIIX 310-10ICR"),
356 + DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1HCN44WW"),
357 + },
358 + },
359 + {
360 + /* Lenovo MIIX 320-10ICR with 800x1280 portrait screen */
361 + .matches = {
362 + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
363 + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION,
364 + "Lenovo MIIX 320-10ICR"),
365 + },
366 + },
367 + {
368 + /* Lenovo D330 with 800x1280 or 1200x1920 portrait screen */
369 + .matches = {
370 + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
371 + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION,
372 + "Lenovo ideapad D330-10IGM"),
373 + },
374 + },
375 + {},
376 +};
377 +
378 __init void sysfb_apply_efi_quirks(void)
379 {
380 if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI ||
381 !(screen_info.capabilities & VIDEO_CAPABILITY_SKIP_QUIRKS))
382 dmi_check_system(efifb_dmi_system_table);
383 +
384 + if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI &&
385 + dmi_check_system(efifb_dmi_swap_width_height)) {
386 + u16 temp = screen_info.lfb_width;
387 +
388 + screen_info.lfb_width = screen_info.lfb_height;
389 + screen_info.lfb_height = temp;
390 + screen_info.lfb_linelength = 4 * screen_info.lfb_width;
391 + }
392 }
393 diff --git a/block/bio-integrity.c b/block/bio-integrity.c
394 index 67b5fb861a51..5bd90cd4b51e 100644
395 --- a/block/bio-integrity.c
396 +++ b/block/bio-integrity.c
397 @@ -291,8 +291,12 @@ bool bio_integrity_prep(struct bio *bio)
398 ret = bio_integrity_add_page(bio, virt_to_page(buf),
399 bytes, offset);
400
401 - if (ret == 0)
402 - return false;
403 + if (ret == 0) {
404 + printk(KERN_ERR "could not attach integrity payload\n");
405 + kfree(buf);
406 + status = BLK_STS_RESOURCE;
407 + goto err_end_io;
408 + }
409
410 if (ret < bytes)
411 break;
412 diff --git a/block/blk-core.c b/block/blk-core.c
413 index 682bc561b77b..9ca703bcfe3b 100644
414 --- a/block/blk-core.c
415 +++ b/block/blk-core.c
416 @@ -198,6 +198,7 @@ void blk_rq_init(struct request_queue *q, struct request *rq)
417 rq->internal_tag = -1;
418 rq->start_time_ns = ktime_get_ns();
419 rq->part = NULL;
420 + refcount_set(&rq->ref, 1);
421 }
422 EXPORT_SYMBOL(blk_rq_init);
423
424 diff --git a/drivers/android/binder.c b/drivers/android/binder.c
425 index 5d67f5fec6c1..1e0e438f079f 100644
426 --- a/drivers/android/binder.c
427 +++ b/drivers/android/binder.c
428 @@ -2838,7 +2838,7 @@ static void binder_transaction(struct binder_proc *proc,
429 else
430 return_error = BR_DEAD_REPLY;
431 mutex_unlock(&context->context_mgr_node_lock);
432 - if (target_node && target_proc == proc) {
433 + if (target_node && target_proc->pid == proc->pid) {
434 binder_user_error("%d:%d got transaction to context manager from process owning it\n",
435 proc->pid, thread->pid);
436 return_error = BR_FAILED_REPLY;
437 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
438 index 9bffcd37cc7b..c0732f032248 100644
439 --- a/drivers/char/hpet.c
440 +++ b/drivers/char/hpet.c
441 @@ -570,8 +570,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
442 unsigned long long m;
443
444 m = hpets->hp_tick_freq + (dis >> 1);
445 - do_div(m, dis);
446 - return (unsigned long)m;
447 + return div64_ul(m, dis);
448 }
449
450 static int
451 diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig
452 index 1ebcef4bab5b..87337fcfbc0d 100644
453 --- a/drivers/fpga/Kconfig
454 +++ b/drivers/fpga/Kconfig
455 @@ -39,6 +39,7 @@ config ALTERA_PR_IP_CORE_PLAT
456 config FPGA_MGR_ALTERA_PS_SPI
457 tristate "Altera FPGA Passive Serial over SPI"
458 depends on SPI
459 + select BITREVERSE
460 help
461 FPGA manager driver support for Altera Arria/Cyclone/Stratix
462 using the passive serial interface over SPI.
463 diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
464 index 72f8018fa2a8..ede27dab675f 100644
465 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
466 +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
467 @@ -1037,6 +1037,9 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
468 tmp = RREG32_SOC15(HDP, 0, mmHDP_HOST_PATH_CNTL);
469 WREG32_SOC15(HDP, 0, mmHDP_HOST_PATH_CNTL, tmp);
470
471 + WREG32_SOC15(HDP, 0, mmHDP_NONSURFACE_BASE, (adev->gmc.vram_start >> 8));
472 + WREG32_SOC15(HDP, 0, mmHDP_NONSURFACE_BASE_HI, (adev->gmc.vram_start >> 40));
473 +
474 /* After HDP is initialized, flush HDP.*/
475 adev->nbio_funcs->hdp_flush(adev, NULL);
476
477 diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
478 index 4f22e745df51..189212cb3547 100644
479 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
480 +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
481 @@ -1268,12 +1268,17 @@ int amdkfd_fence_wait_timeout(unsigned int *fence_addr,
482 return 0;
483 }
484
485 -static int unmap_sdma_queues(struct device_queue_manager *dqm,
486 - unsigned int sdma_engine)
487 +static int unmap_sdma_queues(struct device_queue_manager *dqm)
488 {
489 - return pm_send_unmap_queue(&dqm->packets, KFD_QUEUE_TYPE_SDMA,
490 - KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0, false,
491 - sdma_engine);
492 + int i, retval = 0;
493 +
494 + for (i = 0; i < dqm->dev->device_info->num_sdma_engines; i++) {
495 + retval = pm_send_unmap_queue(&dqm->packets, KFD_QUEUE_TYPE_SDMA,
496 + KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES, 0, false, i);
497 + if (retval)
498 + return retval;
499 + }
500 + return retval;
501 }
502
503 /* dqm->lock mutex has to be locked before calling this function */
504 @@ -1312,10 +1317,8 @@ static int unmap_queues_cpsch(struct device_queue_manager *dqm,
505 pr_debug("Before destroying queues, sdma queue count is : %u\n",
506 dqm->sdma_queue_count);
507
508 - if (dqm->sdma_queue_count > 0) {
509 - unmap_sdma_queues(dqm, 0);
510 - unmap_sdma_queues(dqm, 1);
511 - }
512 + if (dqm->sdma_queue_count > 0)
513 + unmap_sdma_queues(dqm);
514
515 retval = pm_send_unmap_queue(&dqm->packets, KFD_QUEUE_TYPE_COMPUTE,
516 filter, filter_param, false, 0);
517 diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
518 index 0cedb37cf513..985bebde5a34 100644
519 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
520 +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
521 @@ -75,6 +75,7 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
522 struct v9_mqd *m;
523 struct kfd_dev *kfd = mm->dev;
524
525 + *mqd_mem_obj = NULL;
526 /* From V9, for CWSR, the control stack is located on the next page
527 * boundary after the mqd, we will use the gtt allocation function
528 * instead of sub-allocation function.
529 @@ -92,8 +93,10 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
530 } else
531 retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct v9_mqd),
532 mqd_mem_obj);
533 - if (retval != 0)
534 + if (retval) {
535 + kfree(*mqd_mem_obj);
536 return -ENOMEM;
537 + }
538
539 m = (struct v9_mqd *) (*mqd_mem_obj)->cpu_ptr;
540 addr = (*mqd_mem_obj)->gpu_addr;
541 diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
542 index dac7978f5ee1..221de241535a 100644
543 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
544 +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
545 @@ -3644,6 +3644,13 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
546 {
547 struct amdgpu_device *adev = dm->ddev->dev_private;
548
549 + /*
550 + * Some of the properties below require access to state, like bpc.
551 + * Allocate some default initial connector state with our reset helper.
552 + */
553 + if (aconnector->base.funcs->reset)
554 + aconnector->base.funcs->reset(&aconnector->base);
555 +
556 aconnector->connector_id = link_index;
557 aconnector->dc_link = link;
558 aconnector->base.interlace_allowed = false;
559 @@ -3811,9 +3818,6 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
560 &aconnector->base,
561 &amdgpu_dm_connector_helper_funcs);
562
563 - if (aconnector->base.funcs->reset)
564 - aconnector->base.funcs->reset(&aconnector->base);
565 -
566 amdgpu_dm_connector_init_helper(
567 dm,
568 aconnector,
569 diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c b/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c
570 index 29294db1a96b..070ab56a8aca 100644
571 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c
572 +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c
573 @@ -474,6 +474,8 @@ void dce_abm_destroy(struct abm **abm)
574 {
575 struct dce_abm *abm_dce = TO_DCE_ABM(*abm);
576
577 + abm_dce->base.funcs->set_abm_immediate_disable(*abm);
578 +
579 kfree(abm_dce);
580 *abm = NULL;
581 }
582 diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
583 index 53ccacf99eca..c3ad2bbec1a5 100644
584 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
585 +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
586 @@ -242,6 +242,9 @@ static void build_prescale_params(struct ipp_prescale_params *prescale_params,
587 prescale_params->mode = IPP_PRESCALE_MODE_FIXED_UNSIGNED;
588
589 switch (plane_state->format) {
590 + case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
591 + prescale_params->scale = 0x2082;
592 + break;
593 case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
594 case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
595 prescale_params->scale = 0x2020;
596 diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
597 index 7736ef123e9b..ead221ccb93e 100644
598 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
599 +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
600 @@ -23,6 +23,7 @@
601 *
602 */
603
604 +#include <linux/delay.h>
605 #include "dm_services.h"
606 #include "core_types.h"
607 #include "resource.h"
608 diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
609 index e59a13542333..0cc6dbbcddcf 100644
610 --- a/drivers/gpu/drm/bridge/sii902x.c
611 +++ b/drivers/gpu/drm/bridge/sii902x.c
612 @@ -261,10 +261,11 @@ static void sii902x_bridge_mode_set(struct drm_bridge *bridge,
613 struct regmap *regmap = sii902x->regmap;
614 u8 buf[HDMI_INFOFRAME_SIZE(AVI)];
615 struct hdmi_avi_infoframe frame;
616 + u16 pixel_clock_10kHz = adj->clock / 10;
617 int ret;
618
619 - buf[0] = adj->clock;
620 - buf[1] = adj->clock >> 8;
621 + buf[0] = pixel_clock_10kHz & 0xff;
622 + buf[1] = pixel_clock_10kHz >> 8;
623 buf[2] = adj->vrefresh;
624 buf[3] = 0x00;
625 buf[4] = adj->hdisplay;
626 diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
627 index 391547358756..aaca5248da07 100644
628 --- a/drivers/gpu/drm/bridge/tc358767.c
629 +++ b/drivers/gpu/drm/bridge/tc358767.c
630 @@ -1149,6 +1149,13 @@ static int tc_connector_get_modes(struct drm_connector *connector)
631 struct tc_data *tc = connector_to_tc(connector);
632 struct edid *edid;
633 unsigned int count;
634 + int ret;
635 +
636 + ret = tc_get_display_props(tc);
637 + if (ret < 0) {
638 + dev_err(tc->dev, "failed to read display props: %d\n", ret);
639 + return 0;
640 + }
641
642 if (tc->panel && tc->panel->funcs && tc->panel->funcs->get_modes) {
643 count = tc->panel->funcs->get_modes(tc->panel);
644 diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c
645 index 99961192bf03..c88e5ff41add 100644
646 --- a/drivers/gpu/drm/drm_debugfs_crc.c
647 +++ b/drivers/gpu/drm/drm_debugfs_crc.c
648 @@ -379,12 +379,13 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame,
649 struct drm_crtc_crc *crc = &crtc->crc;
650 struct drm_crtc_crc_entry *entry;
651 int head, tail;
652 + unsigned long flags;
653
654 - spin_lock(&crc->lock);
655 + spin_lock_irqsave(&crc->lock, flags);
656
657 /* Caller may not have noticed yet that userspace has stopped reading */
658 if (!crc->entries) {
659 - spin_unlock(&crc->lock);
660 + spin_unlock_irqrestore(&crc->lock, flags);
661 return -EINVAL;
662 }
663
664 @@ -395,7 +396,7 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame,
665 bool was_overflow = crc->overflow;
666
667 crc->overflow = true;
668 - spin_unlock(&crc->lock);
669 + spin_unlock_irqrestore(&crc->lock, flags);
670
671 if (!was_overflow)
672 DRM_ERROR("Overflow of CRC buffer, userspace reads too slow.\n");
673 @@ -411,7 +412,7 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame,
674 head = (head + 1) & (DRM_CRC_ENTRIES_NR - 1);
675 crc->head = head;
676
677 - spin_unlock(&crc->lock);
678 + spin_unlock_irqrestore(&crc->lock, flags);
679
680 wake_up_interruptible(&crc->wq);
681
682 diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
683 index a4915099aaa9..a0e107abc40d 100644
684 --- a/drivers/gpu/drm/drm_edid_load.c
685 +++ b/drivers/gpu/drm/drm_edid_load.c
686 @@ -290,6 +290,8 @@ struct edid *drm_load_edid_firmware(struct drm_connector *connector)
687 * the last one found one as a fallback.
688 */
689 fwstr = kstrdup(edid_firmware, GFP_KERNEL);
690 + if (!fwstr)
691 + return ERR_PTR(-ENOMEM);
692 edidstr = fwstr;
693
694 while ((edidname = strsep(&edidstr, ","))) {
695 diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
696 index c1abad8a8612..ed9a3a1e50ef 100644
697 --- a/drivers/gpu/drm/msm/msm_drv.c
698 +++ b/drivers/gpu/drm/msm/msm_drv.c
699 @@ -1321,16 +1321,24 @@ static int msm_pdev_probe(struct platform_device *pdev)
700
701 ret = add_gpu_components(&pdev->dev, &match);
702 if (ret)
703 - return ret;
704 + goto fail;
705
706 /* on all devices that I am aware of, iommu's which can map
707 * any address the cpu can see are used:
708 */
709 ret = dma_set_mask_and_coherent(&pdev->dev, ~0);
710 if (ret)
711 - return ret;
712 + goto fail;
713 +
714 + ret = component_master_add_with_match(&pdev->dev, &msm_drm_ops, match);
715 + if (ret)
716 + goto fail;
717
718 - return component_master_add_with_match(&pdev->dev, &msm_drm_ops, match);
719 + return 0;
720 +
721 +fail:
722 + of_platform_depopulate(&pdev->dev);
723 + return ret;
724 }
725
726 static int msm_pdev_remove(struct platform_device *pdev)
727 diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
728 index 97964f7f2ace..b1d41c4921dd 100644
729 --- a/drivers/gpu/drm/panel/panel-simple.c
730 +++ b/drivers/gpu/drm/panel/panel-simple.c
731 @@ -2803,7 +2803,14 @@ static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
732 dsi->format = desc->format;
733 dsi->lanes = desc->lanes;
734
735 - return mipi_dsi_attach(dsi);
736 + err = mipi_dsi_attach(dsi);
737 + if (err) {
738 + struct panel_simple *panel = dev_get_drvdata(&dsi->dev);
739 +
740 + drm_panel_remove(&panel->base);
741 + }
742 +
743 + return err;
744 }
745
746 static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi)
747 diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
748 index f8f9ae6622eb..873624a11ce8 100644
749 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
750 +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
751 @@ -880,7 +880,8 @@ static bool vop_crtc_mode_fixup(struct drm_crtc *crtc,
752 struct vop *vop = to_vop(crtc);
753
754 adjusted_mode->clock =
755 - clk_round_rate(vop->dclk, mode->clock * 1000) / 1000;
756 + DIV_ROUND_UP(clk_round_rate(vop->dclk, mode->clock * 1000),
757 + 1000);
758
759 return true;
760 }
761 diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
762 index 7bdf6f0e58a5..8d2f5ded86d6 100644
763 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
764 +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
765 @@ -528,6 +528,9 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev,
766 if (!ret)
767 return -EBUSY;
768
769 + /* is_valid check must proceed before copy of the cache entry. */
770 + smp_rmb();
771 +
772 ptr = cache_ent->caps_cache;
773
774 copy_exit:
775 diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
776 index 020070d483d3..c8a581b1f4c4 100644
777 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
778 +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
779 @@ -588,6 +588,8 @@ static void virtio_gpu_cmd_capset_cb(struct virtio_gpu_device *vgdev,
780 cache_ent->id == le32_to_cpu(cmd->capset_id)) {
781 memcpy(cache_ent->caps_cache, resp->capset_data,
782 cache_ent->size);
783 + /* Copy must occur before is_valid is signalled. */
784 + smp_wmb();
785 atomic_set(&cache_ent->is_valid, 1);
786 break;
787 }
788 diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
789 index 815bdb42e3f0..0121fe7a4548 100644
790 --- a/drivers/gpu/host1x/bus.c
791 +++ b/drivers/gpu/host1x/bus.c
792 @@ -423,6 +423,9 @@ static int host1x_device_add(struct host1x *host1x,
793
794 of_dma_configure(&device->dev, host1x->dev->of_node, true);
795
796 + device->dev.dma_parms = &device->dma_parms;
797 + dma_set_max_seg_size(&device->dev, SZ_4M);
798 +
799 err = host1x_device_parse_dt(device, driver);
800 if (err < 0) {
801 kfree(device);
802 diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
803 index a492da9fd0d3..ac9c9486b834 100644
804 --- a/drivers/i2c/busses/i2c-stm32f7.c
805 +++ b/drivers/i2c/busses/i2c-stm32f7.c
806 @@ -24,7 +24,6 @@
807 #include <linux/module.h>
808 #include <linux/of.h>
809 #include <linux/of_address.h>
810 -#include <linux/of_irq.h>
811 #include <linux/of_platform.h>
812 #include <linux/platform_device.h>
813 #include <linux/reset.h>
814 @@ -1782,15 +1781,14 @@ static struct i2c_algorithm stm32f7_i2c_algo = {
815
816 static int stm32f7_i2c_probe(struct platform_device *pdev)
817 {
818 - struct device_node *np = pdev->dev.of_node;
819 struct stm32f7_i2c_dev *i2c_dev;
820 const struct stm32f7_i2c_setup *setup;
821 struct resource *res;
822 - u32 irq_error, irq_event, clk_rate, rise_time, fall_time;
823 + u32 clk_rate, rise_time, fall_time;
824 struct i2c_adapter *adap;
825 struct reset_control *rst;
826 dma_addr_t phy_addr;
827 - int ret;
828 + int irq_error, irq_event, ret;
829
830 i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL);
831 if (!i2c_dev)
832 @@ -1802,16 +1800,20 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
833 return PTR_ERR(i2c_dev->base);
834 phy_addr = (dma_addr_t)res->start;
835
836 - irq_event = irq_of_parse_and_map(np, 0);
837 - if (!irq_event) {
838 - dev_err(&pdev->dev, "IRQ event missing or invalid\n");
839 - return -EINVAL;
840 + irq_event = platform_get_irq(pdev, 0);
841 + if (irq_event <= 0) {
842 + if (irq_event != -EPROBE_DEFER)
843 + dev_err(&pdev->dev, "Failed to get IRQ event: %d\n",
844 + irq_event);
845 + return irq_event ? : -ENOENT;
846 }
847
848 - irq_error = irq_of_parse_and_map(np, 1);
849 - if (!irq_error) {
850 - dev_err(&pdev->dev, "IRQ error missing or invalid\n");
851 - return -EINVAL;
852 + irq_error = platform_get_irq(pdev, 1);
853 + if (irq_error <= 0) {
854 + if (irq_error != -EPROBE_DEFER)
855 + dev_err(&pdev->dev, "Failed to get IRQ error: %d\n",
856 + irq_error);
857 + return irq_error ? : -ENOENT;
858 }
859
860 i2c_dev->clk = devm_clk_get(&pdev->dev, NULL);
861 diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
862 index fcd4a1c00ca0..15a115210108 100644
863 --- a/drivers/iio/adc/stm32-dfsdm-adc.c
864 +++ b/drivers/iio/adc/stm32-dfsdm-adc.c
865 @@ -1144,6 +1144,12 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
866 * So IRQ associated to filter instance 0 is dedicated to the Filter 0.
867 */
868 irq = platform_get_irq(pdev, 0);
869 + if (irq < 0) {
870 + if (irq != -EPROBE_DEFER)
871 + dev_err(dev, "Failed to get IRQ: %d\n", irq);
872 + return irq;
873 + }
874 +
875 ret = devm_request_irq(dev, irq, stm32_dfsdm_irq,
876 0, pdev->name, adc);
877 if (ret < 0) {
878 diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c
879 index bf089f5d6225..941630615e88 100644
880 --- a/drivers/iio/adc/stm32-dfsdm-core.c
881 +++ b/drivers/iio/adc/stm32-dfsdm-core.c
882 @@ -213,6 +213,8 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev,
883 }
884 priv->dfsdm.phys_base = res->start;
885 priv->dfsdm.base = devm_ioremap_resource(&pdev->dev, res);
886 + if (IS_ERR(priv->dfsdm.base))
887 + return PTR_ERR(priv->dfsdm.base);
888
889 /*
890 * "dfsdm" clock is mandatory for DFSDM peripheral clocking.
891 @@ -222,8 +224,10 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev,
892 */
893 priv->clk = devm_clk_get(&pdev->dev, "dfsdm");
894 if (IS_ERR(priv->clk)) {
895 - dev_err(&pdev->dev, "No stm32_dfsdm_clk clock found\n");
896 - return -EINVAL;
897 + ret = PTR_ERR(priv->clk);
898 + if (ret != -EPROBE_DEFER)
899 + dev_err(&pdev->dev, "Failed to get clock (%d)\n", ret);
900 + return ret;
901 }
902
903 priv->aclk = devm_clk_get(&pdev->dev, "audio");
904 diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
905 index e2e6c74a7452..a5e3349b8a7c 100644
906 --- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c
907 +++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
908 @@ -806,6 +806,8 @@ static int i40iw_query_qp(struct ib_qp *ibqp,
909 struct i40iw_qp *iwqp = to_iwqp(ibqp);
910 struct i40iw_sc_qp *qp = &iwqp->sc_qp;
911
912 + attr->qp_state = iwqp->ibqp_state;
913 + attr->cur_qp_state = attr->qp_state;
914 attr->qp_access_flags = 0;
915 attr->cap.max_send_wr = qp->qp_uk.sq_size;
916 attr->cap.max_recv_wr = qp->qp_uk.rq_size;
917 diff --git a/drivers/infiniband/hw/mlx5/mad.c b/drivers/infiniband/hw/mlx5/mad.c
918 index 32a9e9228b13..cdf6e26ebc87 100644
919 --- a/drivers/infiniband/hw/mlx5/mad.c
920 +++ b/drivers/infiniband/hw/mlx5/mad.c
921 @@ -197,19 +197,33 @@ static void pma_cnt_assign(struct ib_pma_portcounters *pma_cnt,
922 vl_15_dropped);
923 }
924
925 -static int process_pma_cmd(struct mlx5_core_dev *mdev, u8 port_num,
926 +static int process_pma_cmd(struct mlx5_ib_dev *dev, u8 port_num,
927 const struct ib_mad *in_mad, struct ib_mad *out_mad)
928 {
929 - int err;
930 + struct mlx5_core_dev *mdev;
931 + bool native_port = true;
932 + u8 mdev_port_num;
933 void *out_cnt;
934 + int err;
935
936 + mdev = mlx5_ib_get_native_port_mdev(dev, port_num, &mdev_port_num);
937 + if (!mdev) {
938 + /* Fail to get the native port, likely due to 2nd port is still
939 + * unaffiliated. In such case default to 1st port and attached
940 + * PF device.
941 + */
942 + native_port = false;
943 + mdev = dev->mdev;
944 + mdev_port_num = 1;
945 + }
946 /* Declaring support of extended counters */
947 if (in_mad->mad_hdr.attr_id == IB_PMA_CLASS_PORT_INFO) {
948 struct ib_class_port_info cpi = {};
949
950 cpi.capability_mask = IB_PMA_CLASS_CAP_EXT_WIDTH;
951 memcpy((out_mad->data + 40), &cpi, sizeof(cpi));
952 - return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
953 + err = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
954 + goto done;
955 }
956
957 if (in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS_EXT) {
958 @@ -218,11 +232,13 @@ static int process_pma_cmd(struct mlx5_core_dev *mdev, u8 port_num,
959 int sz = MLX5_ST_SZ_BYTES(query_vport_counter_out);
960
961 out_cnt = kvzalloc(sz, GFP_KERNEL);
962 - if (!out_cnt)
963 - return IB_MAD_RESULT_FAILURE;
964 + if (!out_cnt) {
965 + err = IB_MAD_RESULT_FAILURE;
966 + goto done;
967 + }
968
969 err = mlx5_core_query_vport_counter(mdev, 0, 0,
970 - port_num, out_cnt, sz);
971 + mdev_port_num, out_cnt, sz);
972 if (!err)
973 pma_cnt_ext_assign(pma_cnt_ext, out_cnt);
974 } else {
975 @@ -231,20 +247,23 @@ static int process_pma_cmd(struct mlx5_core_dev *mdev, u8 port_num,
976 int sz = MLX5_ST_SZ_BYTES(ppcnt_reg);
977
978 out_cnt = kvzalloc(sz, GFP_KERNEL);
979 - if (!out_cnt)
980 - return IB_MAD_RESULT_FAILURE;
981 + if (!out_cnt) {
982 + err = IB_MAD_RESULT_FAILURE;
983 + goto done;
984 + }
985
986 - err = mlx5_core_query_ib_ppcnt(mdev, port_num,
987 + err = mlx5_core_query_ib_ppcnt(mdev, mdev_port_num,
988 out_cnt, sz);
989 if (!err)
990 pma_cnt_assign(pma_cnt, out_cnt);
991 - }
992 -
993 + }
994 kvfree(out_cnt);
995 - if (err)
996 - return IB_MAD_RESULT_FAILURE;
997 -
998 - return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
999 + err = err ? IB_MAD_RESULT_FAILURE :
1000 + IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
1001 +done:
1002 + if (native_port)
1003 + mlx5_ib_put_native_port_mdev(dev, port_num);
1004 + return err;
1005 }
1006
1007 int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
1008 @@ -256,8 +275,6 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
1009 struct mlx5_ib_dev *dev = to_mdev(ibdev);
1010 const struct ib_mad *in_mad = (const struct ib_mad *)in;
1011 struct ib_mad *out_mad = (struct ib_mad *)out;
1012 - struct mlx5_core_dev *mdev;
1013 - u8 mdev_port_num;
1014 int ret;
1015
1016 if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) ||
1017 @@ -266,19 +283,14 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
1018
1019 memset(out_mad->data, 0, sizeof(out_mad->data));
1020
1021 - mdev = mlx5_ib_get_native_port_mdev(dev, port_num, &mdev_port_num);
1022 - if (!mdev)
1023 - return IB_MAD_RESULT_FAILURE;
1024 -
1025 - if (MLX5_CAP_GEN(mdev, vport_counters) &&
1026 + if (MLX5_CAP_GEN(dev->mdev, vport_counters) &&
1027 in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
1028 in_mad->mad_hdr.method == IB_MGMT_METHOD_GET) {
1029 - ret = process_pma_cmd(mdev, mdev_port_num, in_mad, out_mad);
1030 + ret = process_pma_cmd(dev, port_num, in_mad, out_mad);
1031 } else {
1032 ret = process_mad(ibdev, mad_flags, port_num, in_wc, in_grh,
1033 in_mad, out_mad);
1034 }
1035 - mlx5_ib_put_native_port_mdev(dev, port_num);
1036 return ret;
1037 }
1038
1039 diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
1040 index 4111b798fd3c..681d8e0913d0 100644
1041 --- a/drivers/infiniband/sw/rxe/rxe_resp.c
1042 +++ b/drivers/infiniband/sw/rxe/rxe_resp.c
1043 @@ -435,6 +435,7 @@ static enum resp_states check_rkey(struct rxe_qp *qp,
1044 qp->resp.va = reth_va(pkt);
1045 qp->resp.rkey = reth_rkey(pkt);
1046 qp->resp.resid = reth_len(pkt);
1047 + qp->resp.length = reth_len(pkt);
1048 }
1049 access = (pkt->mask & RXE_READ_MASK) ? IB_ACCESS_REMOTE_READ
1050 : IB_ACCESS_REMOTE_WRITE;
1051 @@ -859,7 +860,9 @@ static enum resp_states do_complete(struct rxe_qp *qp,
1052 pkt->mask & RXE_WRITE_MASK) ?
1053 IB_WC_RECV_RDMA_WITH_IMM : IB_WC_RECV;
1054 wc->vendor_err = 0;
1055 - wc->byte_len = wqe->dma.length - wqe->dma.resid;
1056 + wc->byte_len = (pkt->mask & RXE_IMMDT_MASK &&
1057 + pkt->mask & RXE_WRITE_MASK) ?
1058 + qp->resp.length : wqe->dma.length - wqe->dma.resid;
1059
1060 /* fields after byte_len are different between kernel and user
1061 * space
1062 diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h
1063 index 332a16dad2a7..3b731c7682e5 100644
1064 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h
1065 +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h
1066 @@ -212,6 +212,7 @@ struct rxe_resp_info {
1067 struct rxe_mem *mr;
1068 u32 resid;
1069 u32 rkey;
1070 + u32 length;
1071 u64 atomic_orig;
1072
1073 /* SRQ only */
1074 diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
1075 index 009615499b37..78dd36daac00 100644
1076 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
1077 +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
1078 @@ -1892,12 +1892,6 @@ static void ipoib_child_init(struct net_device *ndev)
1079 struct ipoib_dev_priv *priv = ipoib_priv(ndev);
1080 struct ipoib_dev_priv *ppriv = ipoib_priv(priv->parent);
1081
1082 - dev_hold(priv->parent);
1083 -
1084 - down_write(&ppriv->vlan_rwsem);
1085 - list_add_tail(&priv->list, &ppriv->child_intfs);
1086 - up_write(&ppriv->vlan_rwsem);
1087 -
1088 priv->max_ib_mtu = ppriv->max_ib_mtu;
1089 set_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags);
1090 memcpy(priv->dev->dev_addr, ppriv->dev->dev_addr, INFINIBAND_ALEN);
1091 @@ -1940,6 +1934,17 @@ static int ipoib_ndo_init(struct net_device *ndev)
1092 if (rc) {
1093 pr_warn("%s: failed to initialize device: %s port %d (ret = %d)\n",
1094 priv->ca->name, priv->dev->name, priv->port, rc);
1095 + return rc;
1096 + }
1097 +
1098 + if (priv->parent) {
1099 + struct ipoib_dev_priv *ppriv = ipoib_priv(priv->parent);
1100 +
1101 + dev_hold(priv->parent);
1102 +
1103 + down_write(&ppriv->vlan_rwsem);
1104 + list_add_tail(&priv->list, &ppriv->child_intfs);
1105 + up_write(&ppriv->vlan_rwsem);
1106 }
1107
1108 return 0;
1109 @@ -1957,6 +1962,14 @@ static void ipoib_ndo_uninit(struct net_device *dev)
1110 */
1111 WARN_ON(!list_empty(&priv->child_intfs));
1112
1113 + if (priv->parent) {
1114 + struct ipoib_dev_priv *ppriv = ipoib_priv(priv->parent);
1115 +
1116 + down_write(&ppriv->vlan_rwsem);
1117 + list_del(&priv->list);
1118 + up_write(&ppriv->vlan_rwsem);
1119 + }
1120 +
1121 ipoib_neigh_hash_uninit(dev);
1122
1123 ipoib_ib_dev_cleanup(dev);
1124 @@ -1968,15 +1981,8 @@ static void ipoib_ndo_uninit(struct net_device *dev)
1125 priv->wq = NULL;
1126 }
1127
1128 - if (priv->parent) {
1129 - struct ipoib_dev_priv *ppriv = ipoib_priv(priv->parent);
1130 -
1131 - down_write(&ppriv->vlan_rwsem);
1132 - list_del(&priv->list);
1133 - up_write(&ppriv->vlan_rwsem);
1134 -
1135 + if (priv->parent)
1136 dev_put(priv->parent);
1137 - }
1138 }
1139
1140 static int ipoib_set_vf_link_state(struct net_device *dev, int vf, int link_state)
1141 diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
1142 index 674b35f402f5..055c90b8253c 100644
1143 --- a/drivers/mailbox/mailbox.c
1144 +++ b/drivers/mailbox/mailbox.c
1145 @@ -391,11 +391,13 @@ struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl,
1146
1147 of_property_for_each_string(np, "mbox-names", prop, mbox_name) {
1148 if (!strncmp(name, mbox_name, strlen(name)))
1149 - break;
1150 + return mbox_request_channel(cl, index);
1151 index++;
1152 }
1153
1154 - return mbox_request_channel(cl, index);
1155 + dev_err(cl->dev, "%s() could not locate channel named \"%s\"\n",
1156 + __func__, name);
1157 + return ERR_PTR(-EINVAL);
1158 }
1159 EXPORT_SYMBOL_GPL(mbox_request_channel_byname);
1160
1161 diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
1162 index 1246d69ba187..b1564cacd19e 100644
1163 --- a/drivers/memstick/core/memstick.c
1164 +++ b/drivers/memstick/core/memstick.c
1165 @@ -629,13 +629,18 @@ static int __init memstick_init(void)
1166 return -ENOMEM;
1167
1168 rc = bus_register(&memstick_bus_type);
1169 - if (!rc)
1170 - rc = class_register(&memstick_host_class);
1171 + if (rc)
1172 + goto error_destroy_workqueue;
1173
1174 - if (!rc)
1175 - return 0;
1176 + rc = class_register(&memstick_host_class);
1177 + if (rc)
1178 + goto error_bus_unregister;
1179 +
1180 + return 0;
1181
1182 +error_bus_unregister:
1183 bus_unregister(&memstick_bus_type);
1184 +error_destroy_workqueue:
1185 destroy_workqueue(workqueue);
1186
1187 return rc;
1188 diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
1189 index 5f1e37d23943..47d6d40f41cd 100644
1190 --- a/drivers/mfd/arizona-core.c
1191 +++ b/drivers/mfd/arizona-core.c
1192 @@ -996,7 +996,7 @@ int arizona_dev_init(struct arizona *arizona)
1193 unsigned int reg, val;
1194 int (*apply_patch)(struct arizona *) = NULL;
1195 const struct mfd_cell *subdevs = NULL;
1196 - int n_subdevs, ret, i;
1197 + int n_subdevs = 0, ret, i;
1198
1199 dev_set_drvdata(arizona->dev, arizona);
1200 mutex_init(&arizona->clk_lock);
1201 diff --git a/drivers/mfd/hi655x-pmic.c b/drivers/mfd/hi655x-pmic.c
1202 index 96c07fa1802a..6693f74aa6ab 100644
1203 --- a/drivers/mfd/hi655x-pmic.c
1204 +++ b/drivers/mfd/hi655x-pmic.c
1205 @@ -112,6 +112,8 @@ static int hi655x_pmic_probe(struct platform_device *pdev)
1206
1207 pmic->regmap = devm_regmap_init_mmio_clk(dev, NULL, base,
1208 &hi655x_regmap_config);
1209 + if (IS_ERR(pmic->regmap))
1210 + return PTR_ERR(pmic->regmap);
1211
1212 regmap_read(pmic->regmap, HI655X_BUS_ADDR(HI655X_VER_REG), &pmic->ver);
1213 if ((pmic->ver < PMU_VER_START) || (pmic->ver > PMU_VER_END)) {
1214 diff --git a/drivers/mfd/madera-core.c b/drivers/mfd/madera-core.c
1215 index 8cfea969b060..45c7d8b97349 100644
1216 --- a/drivers/mfd/madera-core.c
1217 +++ b/drivers/mfd/madera-core.c
1218 @@ -278,6 +278,7 @@ const struct of_device_id madera_of_match[] = {
1219 { .compatible = "cirrus,wm1840", .data = (void *)WM1840 },
1220 {}
1221 };
1222 +MODULE_DEVICE_TABLE(of, madera_of_match);
1223 EXPORT_SYMBOL_GPL(madera_of_match);
1224
1225 static int madera_get_reset_gpio(struct madera *madera)
1226 diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
1227 index 94e3f32ce935..182973df1aed 100644
1228 --- a/drivers/mfd/mfd-core.c
1229 +++ b/drivers/mfd/mfd-core.c
1230 @@ -179,6 +179,7 @@ static int mfd_add_device(struct device *parent, int id,
1231 for_each_child_of_node(parent->of_node, np) {
1232 if (of_device_is_compatible(np, cell->of_compatible)) {
1233 pdev->dev.of_node = np;
1234 + pdev->dev.fwnode = &np->fwnode;
1235 break;
1236 }
1237 }
1238 diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h
1239 index bb1ee9834a02..225373e4a9ef 100644
1240 --- a/drivers/misc/mei/hw-me-regs.h
1241 +++ b/drivers/misc/mei/hw-me-regs.h
1242 @@ -141,6 +141,9 @@
1243
1244 #define MEI_DEV_ID_ICP_LP 0x34E0 /* Ice Lake Point LP */
1245
1246 +#define MEI_DEV_ID_MCC 0x4B70 /* Mule Creek Canyon (EHL) */
1247 +#define MEI_DEV_ID_MCC_4 0x4B75 /* Mule Creek Canyon 4 (EHL) */
1248 +
1249 /*
1250 * MEI HW Section
1251 */
1252 diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
1253 index 4299658d48d6..a66ebceea408 100644
1254 --- a/drivers/misc/mei/pci-me.c
1255 +++ b/drivers/misc/mei/pci-me.c
1256 @@ -107,6 +107,9 @@ static const struct pci_device_id mei_me_pci_tbl[] = {
1257
1258 {MEI_PCI_DEVICE(MEI_DEV_ID_ICP_LP, MEI_ME_PCH12_CFG)},
1259
1260 + {MEI_PCI_DEVICE(MEI_DEV_ID_MCC, MEI_ME_PCH12_CFG)},
1261 + {MEI_PCI_DEVICE(MEI_DEV_ID_MCC_4, MEI_ME_PCH8_CFG)},
1262 +
1263 /* required last entry */
1264 {0, }
1265 };
1266 diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
1267 index fa8d9da2ab7f..e248d7945c06 100644
1268 --- a/drivers/mmc/host/sdhci-pci-o2micro.c
1269 +++ b/drivers/mmc/host/sdhci-pci-o2micro.c
1270 @@ -290,11 +290,21 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
1271 {
1272 struct sdhci_pci_chip *chip;
1273 struct sdhci_host *host;
1274 - u32 reg;
1275 + u32 reg, caps;
1276 int ret;
1277
1278 chip = slot->chip;
1279 host = slot->host;
1280 +
1281 + caps = sdhci_readl(host, SDHCI_CAPABILITIES);
1282 +
1283 + /*
1284 + * mmc_select_bus_width() will test the bus to determine the actual bus
1285 + * width.
1286 + */
1287 + if (caps & SDHCI_CAN_DO_8BIT)
1288 + host->mmc->caps |= MMC_CAP_8_BIT_DATA;
1289 +
1290 switch (chip->pdev->device) {
1291 case PCI_DEVICE_ID_O2_SDS0:
1292 case PCI_DEVICE_ID_O2_SEABIRD0:
1293 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
1294 index d97e0d7e541a..b766362031c3 100644
1295 --- a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
1296 +++ b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
1297 @@ -1065,14 +1065,12 @@ static void cudbg_t4_fwcache(struct cudbg_init *pdbg_init,
1298 }
1299 }
1300
1301 -static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init,
1302 - struct cudbg_buffer *dbg_buff,
1303 - struct cudbg_error *cudbg_err,
1304 - u8 mem_type)
1305 +static unsigned long cudbg_mem_region_size(struct cudbg_init *pdbg_init,
1306 + struct cudbg_error *cudbg_err,
1307 + u8 mem_type)
1308 {
1309 struct adapter *padap = pdbg_init->adap;
1310 struct cudbg_meminfo mem_info;
1311 - unsigned long size;
1312 u8 mc_idx;
1313 int rc;
1314
1315 @@ -1086,7 +1084,16 @@ static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init,
1316 if (rc)
1317 return rc;
1318
1319 - size = mem_info.avail[mc_idx].limit - mem_info.avail[mc_idx].base;
1320 + return mem_info.avail[mc_idx].limit - mem_info.avail[mc_idx].base;
1321 +}
1322 +
1323 +static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init,
1324 + struct cudbg_buffer *dbg_buff,
1325 + struct cudbg_error *cudbg_err,
1326 + u8 mem_type)
1327 +{
1328 + unsigned long size = cudbg_mem_region_size(pdbg_init, cudbg_err, mem_type);
1329 +
1330 return cudbg_read_fw_mem(pdbg_init, dbg_buff, mem_type, size,
1331 cudbg_err);
1332 }
1333 diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
1334 index a3132a9eb91c..ee39e2c1644a 100644
1335 --- a/drivers/nvdimm/bus.c
1336 +++ b/drivers/nvdimm/bus.c
1337 @@ -86,7 +86,7 @@ static void nvdimm_bus_probe_end(struct nvdimm_bus *nvdimm_bus)
1338 {
1339 nvdimm_bus_lock(&nvdimm_bus->dev);
1340 if (--nvdimm_bus->probe_active == 0)
1341 - wake_up(&nvdimm_bus->probe_wait);
1342 + wake_up(&nvdimm_bus->wait);
1343 nvdimm_bus_unlock(&nvdimm_bus->dev);
1344 }
1345
1346 @@ -348,7 +348,7 @@ struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
1347 return NULL;
1348 INIT_LIST_HEAD(&nvdimm_bus->list);
1349 INIT_LIST_HEAD(&nvdimm_bus->mapping_list);
1350 - init_waitqueue_head(&nvdimm_bus->probe_wait);
1351 + init_waitqueue_head(&nvdimm_bus->wait);
1352 nvdimm_bus->id = ida_simple_get(&nd_ida, 0, 0, GFP_KERNEL);
1353 mutex_init(&nvdimm_bus->reconfig_mutex);
1354 badrange_init(&nvdimm_bus->badrange);
1355 @@ -418,6 +418,9 @@ static int nd_bus_remove(struct device *dev)
1356 list_del_init(&nvdimm_bus->list);
1357 mutex_unlock(&nvdimm_bus_list_mutex);
1358
1359 + wait_event(nvdimm_bus->wait,
1360 + atomic_read(&nvdimm_bus->ioctl_active) == 0);
1361 +
1362 nd_synchronize();
1363 device_for_each_child(&nvdimm_bus->dev, NULL, child_unregister);
1364
1365 @@ -838,7 +841,7 @@ void wait_nvdimm_bus_probe_idle(struct device *dev)
1366 if (nvdimm_bus->probe_active == 0)
1367 break;
1368 nvdimm_bus_unlock(&nvdimm_bus->dev);
1369 - wait_event(nvdimm_bus->probe_wait,
1370 + wait_event(nvdimm_bus->wait,
1371 nvdimm_bus->probe_active == 0);
1372 nvdimm_bus_lock(&nvdimm_bus->dev);
1373 } while (true);
1374 @@ -1068,24 +1071,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
1375 return rc;
1376 }
1377
1378 -static long nd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1379 -{
1380 - long id = (long) file->private_data;
1381 - int rc = -ENXIO, ro;
1382 - struct nvdimm_bus *nvdimm_bus;
1383 -
1384 - ro = ((file->f_flags & O_ACCMODE) == O_RDONLY);
1385 - mutex_lock(&nvdimm_bus_list_mutex);
1386 - list_for_each_entry(nvdimm_bus, &nvdimm_bus_list, list) {
1387 - if (nvdimm_bus->id == id) {
1388 - rc = __nd_ioctl(nvdimm_bus, NULL, ro, cmd, arg);
1389 - break;
1390 - }
1391 - }
1392 - mutex_unlock(&nvdimm_bus_list_mutex);
1393 -
1394 - return rc;
1395 -}
1396 +enum nd_ioctl_mode {
1397 + BUS_IOCTL,
1398 + DIMM_IOCTL,
1399 +};
1400
1401 static int match_dimm(struct device *dev, void *data)
1402 {
1403 @@ -1100,31 +1089,62 @@ static int match_dimm(struct device *dev, void *data)
1404 return 0;
1405 }
1406
1407 -static long nvdimm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1408 +static long nd_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
1409 + enum nd_ioctl_mode mode)
1410 +
1411 {
1412 - int rc = -ENXIO, ro;
1413 - struct nvdimm_bus *nvdimm_bus;
1414 + struct nvdimm_bus *nvdimm_bus, *found = NULL;
1415 + long id = (long) file->private_data;
1416 + struct nvdimm *nvdimm = NULL;
1417 + int rc, ro;
1418
1419 ro = ((file->f_flags & O_ACCMODE) == O_RDONLY);
1420 mutex_lock(&nvdimm_bus_list_mutex);
1421 list_for_each_entry(nvdimm_bus, &nvdimm_bus_list, list) {
1422 - struct device *dev = device_find_child(&nvdimm_bus->dev,
1423 - file->private_data, match_dimm);
1424 - struct nvdimm *nvdimm;
1425 -
1426 - if (!dev)
1427 - continue;
1428 + if (mode == DIMM_IOCTL) {
1429 + struct device *dev;
1430 +
1431 + dev = device_find_child(&nvdimm_bus->dev,
1432 + file->private_data, match_dimm);
1433 + if (!dev)
1434 + continue;
1435 + nvdimm = to_nvdimm(dev);
1436 + found = nvdimm_bus;
1437 + } else if (nvdimm_bus->id == id) {
1438 + found = nvdimm_bus;
1439 + }
1440
1441 - nvdimm = to_nvdimm(dev);
1442 - rc = __nd_ioctl(nvdimm_bus, nvdimm, ro, cmd, arg);
1443 - put_device(dev);
1444 - break;
1445 + if (found) {
1446 + atomic_inc(&nvdimm_bus->ioctl_active);
1447 + break;
1448 + }
1449 }
1450 mutex_unlock(&nvdimm_bus_list_mutex);
1451
1452 + if (!found)
1453 + return -ENXIO;
1454 +
1455 + nvdimm_bus = found;
1456 + rc = __nd_ioctl(nvdimm_bus, nvdimm, ro, cmd, arg);
1457 +
1458 + if (nvdimm)
1459 + put_device(&nvdimm->dev);
1460 + if (atomic_dec_and_test(&nvdimm_bus->ioctl_active))
1461 + wake_up(&nvdimm_bus->wait);
1462 +
1463 return rc;
1464 }
1465
1466 +static long bus_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1467 +{
1468 + return nd_ioctl(file, cmd, arg, BUS_IOCTL);
1469 +}
1470 +
1471 +static long dimm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1472 +{
1473 + return nd_ioctl(file, cmd, arg, DIMM_IOCTL);
1474 +}
1475 +
1476 static int nd_open(struct inode *inode, struct file *file)
1477 {
1478 long minor = iminor(inode);
1479 @@ -1136,16 +1156,16 @@ static int nd_open(struct inode *inode, struct file *file)
1480 static const struct file_operations nvdimm_bus_fops = {
1481 .owner = THIS_MODULE,
1482 .open = nd_open,
1483 - .unlocked_ioctl = nd_ioctl,
1484 - .compat_ioctl = nd_ioctl,
1485 + .unlocked_ioctl = bus_ioctl,
1486 + .compat_ioctl = bus_ioctl,
1487 .llseek = noop_llseek,
1488 };
1489
1490 static const struct file_operations nvdimm_fops = {
1491 .owner = THIS_MODULE,
1492 .open = nd_open,
1493 - .unlocked_ioctl = nvdimm_ioctl,
1494 - .compat_ioctl = nvdimm_ioctl,
1495 + .unlocked_ioctl = dimm_ioctl,
1496 + .compat_ioctl = dimm_ioctl,
1497 .llseek = noop_llseek,
1498 };
1499
1500 diff --git a/drivers/nvdimm/nd-core.h b/drivers/nvdimm/nd-core.h
1501 index 5ff254dc9b14..adf62a6c0fe2 100644
1502 --- a/drivers/nvdimm/nd-core.h
1503 +++ b/drivers/nvdimm/nd-core.h
1504 @@ -25,10 +25,11 @@ extern int nvdimm_major;
1505
1506 struct nvdimm_bus {
1507 struct nvdimm_bus_descriptor *nd_desc;
1508 - wait_queue_head_t probe_wait;
1509 + wait_queue_head_t wait;
1510 struct list_head list;
1511 struct device dev;
1512 int id, probe_active;
1513 + atomic_t ioctl_active;
1514 struct list_head mapping_list;
1515 struct mutex reconfig_mutex;
1516 struct badrange badrange;
1517 diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
1518 index a32d6dde7a57..412524aa1fde 100644
1519 --- a/drivers/pci/controller/dwc/pci-dra7xx.c
1520 +++ b/drivers/pci/controller/dwc/pci-dra7xx.c
1521 @@ -26,6 +26,7 @@
1522 #include <linux/types.h>
1523 #include <linux/mfd/syscon.h>
1524 #include <linux/regmap.h>
1525 +#include <linux/gpio/consumer.h>
1526
1527 #include "../../pci.h"
1528 #include "pcie-designware.h"
1529 diff --git a/drivers/pci/controller/pcie-mobiveil.c b/drivers/pci/controller/pcie-mobiveil.c
1530 index a939e8d31735..a2d1e89d4867 100644
1531 --- a/drivers/pci/controller/pcie-mobiveil.c
1532 +++ b/drivers/pci/controller/pcie-mobiveil.c
1533 @@ -508,6 +508,12 @@ static int mobiveil_host_init(struct mobiveil_pcie *pcie)
1534 return err;
1535 }
1536
1537 + /* setup bus numbers */
1538 + value = csr_readl(pcie, PCI_PRIMARY_BUS);
1539 + value &= 0xff000000;
1540 + value |= 0x00ff0100;
1541 + csr_writel(pcie, value, PCI_PRIMARY_BUS);
1542 +
1543 /*
1544 * program Bus Master Enable Bit in Command Register in PAB Config
1545 * Space
1546 @@ -547,7 +553,7 @@ static int mobiveil_host_init(struct mobiveil_pcie *pcie)
1547 resource_size(pcie->ob_io_res));
1548
1549 /* memory inbound translation window */
1550 - program_ib_windows(pcie, WIN_NUM_1, 0, MEM_WINDOW_TYPE, IB_WIN_SIZE);
1551 + program_ib_windows(pcie, WIN_NUM_0, 0, MEM_WINDOW_TYPE, IB_WIN_SIZE);
1552
1553 /* Get the I/O and memory ranges from DT */
1554 resource_list_for_each_entry_safe(win, tmp, &pcie->resources) {
1555 @@ -559,11 +565,18 @@ static int mobiveil_host_init(struct mobiveil_pcie *pcie)
1556 if (type) {
1557 /* configure outbound translation window */
1558 program_ob_windows(pcie, pcie->ob_wins_configured,
1559 - win->res->start, 0, type,
1560 - resource_size(win->res));
1561 + win->res->start,
1562 + win->res->start - win->offset,
1563 + type, resource_size(win->res));
1564 }
1565 }
1566
1567 + /* fixup for PCIe class register */
1568 + value = csr_readl(pcie, PAB_INTP_AXI_PIO_CLASS);
1569 + value &= 0xff;
1570 + value |= (PCI_CLASS_BRIDGE_PCI << 16);
1571 + csr_writel(pcie, value, PAB_INTP_AXI_PIO_CLASS);
1572 +
1573 /* setup MSI hardware registers */
1574 mobiveil_pcie_enable_msi(pcie);
1575
1576 @@ -804,9 +817,6 @@ static int mobiveil_pcie_probe(struct platform_device *pdev)
1577 goto error;
1578 }
1579
1580 - /* fixup for PCIe class register */
1581 - csr_writel(pcie, 0x060402ab, PAB_INTP_AXI_PIO_CLASS);
1582 -
1583 /* initialize the IRQ domains */
1584 ret = mobiveil_pcie_init_irq_domain(pcie);
1585 if (ret) {
1586 diff --git a/drivers/pci/controller/pcie-xilinx-nwl.c b/drivers/pci/controller/pcie-xilinx-nwl.c
1587 index fb32840ce8e6..4850a1b8eec1 100644
1588 --- a/drivers/pci/controller/pcie-xilinx-nwl.c
1589 +++ b/drivers/pci/controller/pcie-xilinx-nwl.c
1590 @@ -483,15 +483,13 @@ static int nwl_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
1591 int i;
1592
1593 mutex_lock(&msi->lock);
1594 - bit = bitmap_find_next_zero_area(msi->bitmap, INT_PCI_MSI_NR, 0,
1595 - nr_irqs, 0);
1596 - if (bit >= INT_PCI_MSI_NR) {
1597 + bit = bitmap_find_free_region(msi->bitmap, INT_PCI_MSI_NR,
1598 + get_count_order(nr_irqs));
1599 + if (bit < 0) {
1600 mutex_unlock(&msi->lock);
1601 return -ENOSPC;
1602 }
1603
1604 - bitmap_set(msi->bitmap, bit, nr_irqs);
1605 -
1606 for (i = 0; i < nr_irqs; i++) {
1607 irq_domain_set_info(domain, virq + i, bit + i, &nwl_irq_chip,
1608 domain->host_data, handle_simple_irq,
1609 @@ -509,7 +507,8 @@ static void nwl_irq_domain_free(struct irq_domain *domain, unsigned int virq,
1610 struct nwl_msi *msi = &pcie->msi;
1611
1612 mutex_lock(&msi->lock);
1613 - bitmap_clear(msi->bitmap, data->hwirq, nr_irqs);
1614 + bitmap_release_region(msi->bitmap, data->hwirq,
1615 + get_count_order(nr_irqs));
1616 mutex_unlock(&msi->lock);
1617 }
1618
1619 diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
1620 index 33f3f475e5c6..956ee7527d2c 100644
1621 --- a/drivers/pci/pci-driver.c
1622 +++ b/drivers/pci/pci-driver.c
1623 @@ -414,6 +414,9 @@ static int pci_device_probe(struct device *dev)
1624 struct pci_dev *pci_dev = to_pci_dev(dev);
1625 struct pci_driver *drv = to_pci_driver(dev->driver);
1626
1627 + if (!pci_device_can_probe(pci_dev))
1628 + return -ENODEV;
1629 +
1630 pci_assign_irq(pci_dev);
1631
1632 error = pcibios_alloc_irq(pci_dev);
1633 @@ -421,12 +424,10 @@ static int pci_device_probe(struct device *dev)
1634 return error;
1635
1636 pci_dev_get(pci_dev);
1637 - if (pci_device_can_probe(pci_dev)) {
1638 - error = __pci_device_probe(drv, pci_dev);
1639 - if (error) {
1640 - pcibios_free_irq(pci_dev);
1641 - pci_dev_put(pci_dev);
1642 - }
1643 + error = __pci_device_probe(drv, pci_dev);
1644 + if (error) {
1645 + pcibios_free_irq(pci_dev);
1646 + pci_dev_put(pci_dev);
1647 }
1648
1649 return error;
1650 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
1651 index 9ecfe13157c0..1edf5a1836ea 100644
1652 --- a/drivers/pci/pci-sysfs.c
1653 +++ b/drivers/pci/pci-sysfs.c
1654 @@ -478,7 +478,7 @@ static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
1655 pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
1656 return count;
1657 }
1658 -static struct device_attribute dev_remove_attr = __ATTR(remove,
1659 +static struct device_attribute dev_remove_attr = __ATTR_IGNORE_LOCKDEP(remove,
1660 (S_IWUSR|S_IWGRP),
1661 NULL, remove_store);
1662
1663 diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c
1664 index 97d4dd6ea924..aa02b19b7e0e 100644
1665 --- a/drivers/phy/renesas/phy-rcar-gen2.c
1666 +++ b/drivers/phy/renesas/phy-rcar-gen2.c
1667 @@ -288,6 +288,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
1668 error = of_property_read_u32(np, "reg", &channel_num);
1669 if (error || channel_num > 2) {
1670 dev_err(dev, "Invalid \"reg\" property\n");
1671 + of_node_put(np);
1672 return error;
1673 }
1674 channel->select_mask = select_mask[channel_num];
1675 @@ -303,6 +304,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
1676 &rcar_gen2_phy_ops);
1677 if (IS_ERR(phy->phy)) {
1678 dev_err(dev, "Failed to create PHY\n");
1679 + of_node_put(np);
1680 return PTR_ERR(phy->phy);
1681 }
1682 phy_set_drvdata(phy->phy, phy);
1683 diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
1684 index f4a61429e06e..8d83817935da 100644
1685 --- a/drivers/pinctrl/pinctrl-rockchip.c
1686 +++ b/drivers/pinctrl/pinctrl-rockchip.c
1687 @@ -3172,6 +3172,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
1688 base,
1689 &rockchip_regmap_config);
1690 }
1691 + of_node_put(node);
1692 }
1693
1694 bank->irq = irq_of_parse_and_map(bank->of_node, 0);
1695 diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
1696 index ccafcc2c87ac..70433f756d8e 100644
1697 --- a/drivers/staging/vt6656/main_usb.c
1698 +++ b/drivers/staging/vt6656/main_usb.c
1699 @@ -402,16 +402,19 @@ static void vnt_free_int_bufs(struct vnt_private *priv)
1700 kfree(priv->int_buf.data_buf);
1701 }
1702
1703 -static bool vnt_alloc_bufs(struct vnt_private *priv)
1704 +static int vnt_alloc_bufs(struct vnt_private *priv)
1705 {
1706 + int ret = 0;
1707 struct vnt_usb_send_context *tx_context;
1708 struct vnt_rcb *rcb;
1709 int ii;
1710
1711 for (ii = 0; ii < priv->num_tx_context; ii++) {
1712 tx_context = kmalloc(sizeof(*tx_context), GFP_KERNEL);
1713 - if (!tx_context)
1714 + if (!tx_context) {
1715 + ret = -ENOMEM;
1716 goto free_tx;
1717 + }
1718
1719 priv->tx_context[ii] = tx_context;
1720 tx_context->priv = priv;
1721 @@ -419,16 +422,20 @@ static bool vnt_alloc_bufs(struct vnt_private *priv)
1722
1723 /* allocate URBs */
1724 tx_context->urb = usb_alloc_urb(0, GFP_KERNEL);
1725 - if (!tx_context->urb)
1726 + if (!tx_context->urb) {
1727 + ret = -ENOMEM;
1728 goto free_tx;
1729 + }
1730
1731 tx_context->in_use = false;
1732 }
1733
1734 for (ii = 0; ii < priv->num_rcb; ii++) {
1735 priv->rcb[ii] = kzalloc(sizeof(*priv->rcb[ii]), GFP_KERNEL);
1736 - if (!priv->rcb[ii])
1737 + if (!priv->rcb[ii]) {
1738 + ret = -ENOMEM;
1739 goto free_rx_tx;
1740 + }
1741
1742 rcb = priv->rcb[ii];
1743
1744 @@ -436,39 +443,46 @@ static bool vnt_alloc_bufs(struct vnt_private *priv)
1745
1746 /* allocate URBs */
1747 rcb->urb = usb_alloc_urb(0, GFP_KERNEL);
1748 - if (!rcb->urb)
1749 + if (!rcb->urb) {
1750 + ret = -ENOMEM;
1751 goto free_rx_tx;
1752 + }
1753
1754 rcb->skb = dev_alloc_skb(priv->rx_buf_sz);
1755 - if (!rcb->skb)
1756 + if (!rcb->skb) {
1757 + ret = -ENOMEM;
1758 goto free_rx_tx;
1759 + }
1760
1761 rcb->in_use = false;
1762
1763 /* submit rx urb */
1764 - if (vnt_submit_rx_urb(priv, rcb))
1765 + ret = vnt_submit_rx_urb(priv, rcb);
1766 + if (ret)
1767 goto free_rx_tx;
1768 }
1769
1770 priv->interrupt_urb = usb_alloc_urb(0, GFP_KERNEL);
1771 - if (!priv->interrupt_urb)
1772 + if (!priv->interrupt_urb) {
1773 + ret = -ENOMEM;
1774 goto free_rx_tx;
1775 + }
1776
1777 priv->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL);
1778 if (!priv->int_buf.data_buf) {
1779 - usb_free_urb(priv->interrupt_urb);
1780 - goto free_rx_tx;
1781 + ret = -ENOMEM;
1782 + goto free_rx_tx_urb;
1783 }
1784
1785 - return true;
1786 + return 0;
1787
1788 +free_rx_tx_urb:
1789 + usb_free_urb(priv->interrupt_urb);
1790 free_rx_tx:
1791 vnt_free_rx_bufs(priv);
1792 -
1793 free_tx:
1794 vnt_free_tx_bufs(priv);
1795 -
1796 - return false;
1797 + return ret;
1798 }
1799
1800 static void vnt_tx_80211(struct ieee80211_hw *hw,
1801 diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
1802 index e26d87b6ffc5..aa4de6907f77 100644
1803 --- a/drivers/tty/serial/8250/8250_port.c
1804 +++ b/drivers/tty/serial/8250/8250_port.c
1805 @@ -1874,7 +1874,8 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
1806 status = serial8250_rx_chars(up, status);
1807 }
1808 serial8250_modem_status(up);
1809 - if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE))
1810 + if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE) &&
1811 + (up->ier & UART_IER_THRI))
1812 serial8250_tx_chars(up);
1813
1814 spin_unlock_irqrestore(&port->lock, flags);
1815 diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
1816 index e5389591bb4f..ad40c75bb58f 100644
1817 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
1818 +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
1819 @@ -407,7 +407,16 @@ static int cpm_uart_startup(struct uart_port *port)
1820 clrbits16(&pinfo->sccp->scc_sccm, UART_SCCM_RX);
1821 }
1822 cpm_uart_initbd(pinfo);
1823 - cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX);
1824 + if (IS_SMC(pinfo)) {
1825 + out_be32(&pinfo->smcup->smc_rstate, 0);
1826 + out_be32(&pinfo->smcup->smc_tstate, 0);
1827 + out_be16(&pinfo->smcup->smc_rbptr,
1828 + in_be16(&pinfo->smcup->smc_rbase));
1829 + out_be16(&pinfo->smcup->smc_tbptr,
1830 + in_be16(&pinfo->smcup->smc_tbase));
1831 + } else {
1832 + cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX);
1833 + }
1834 }
1835 /* Install interrupt handler. */
1836 retval = request_irq(port->irq, cpm_uart_int, 0, "cpm_uart", port);
1837 @@ -861,16 +870,14 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo)
1838 (u8 __iomem *)pinfo->tx_bd_base - DPRAM_BASE);
1839
1840 /*
1841 - * In case SMC1 is being relocated...
1842 + * In case SMC is being relocated...
1843 */
1844 -#if defined (CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
1845 out_be16(&up->smc_rbptr, in_be16(&pinfo->smcup->smc_rbase));
1846 out_be16(&up->smc_tbptr, in_be16(&pinfo->smcup->smc_tbase));
1847 out_be32(&up->smc_rstate, 0);
1848 out_be32(&up->smc_tstate, 0);
1849 out_be16(&up->smc_brkcr, 1); /* number of break chars */
1850 out_be16(&up->smc_brkec, 0);
1851 -#endif
1852
1853 /* Set up the uart parameters in the
1854 * parameter ram.
1855 @@ -884,8 +891,6 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo)
1856 out_be16(&up->smc_brkec, 0);
1857 out_be16(&up->smc_brkcr, 1);
1858
1859 - cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX);
1860 -
1861 /* Set UART mode, 8 bit, no parity, one stop.
1862 * Enable receive and transmit.
1863 */
1864 diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
1865 index f460cca139e2..13ac36e2da4f 100644
1866 --- a/drivers/tty/serial/digicolor-usart.c
1867 +++ b/drivers/tty/serial/digicolor-usart.c
1868 @@ -541,7 +541,11 @@ static int __init digicolor_uart_init(void)
1869 if (ret)
1870 return ret;
1871
1872 - return platform_driver_register(&digicolor_uart_platform);
1873 + ret = platform_driver_register(&digicolor_uart_platform);
1874 + if (ret)
1875 + uart_unregister_driver(&digicolor_uart);
1876 +
1877 + return ret;
1878 }
1879 module_init(digicolor_uart_init);
1880
1881 diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
1882 index 0f67197a3783..105de92b0b3b 100644
1883 --- a/drivers/tty/serial/imx.c
1884 +++ b/drivers/tty/serial/imx.c
1885 @@ -382,6 +382,7 @@ static void imx_uart_ucrs_restore(struct imx_port *sport,
1886 }
1887 #endif
1888
1889 +/* called with port.lock taken and irqs caller dependent */
1890 static void imx_uart_rts_active(struct imx_port *sport, u32 *ucr2)
1891 {
1892 *ucr2 &= ~(UCR2_CTSC | UCR2_CTS);
1893 @@ -390,6 +391,7 @@ static void imx_uart_rts_active(struct imx_port *sport, u32 *ucr2)
1894 mctrl_gpio_set(sport->gpios, sport->port.mctrl);
1895 }
1896
1897 +/* called with port.lock taken and irqs caller dependent */
1898 static void imx_uart_rts_inactive(struct imx_port *sport, u32 *ucr2)
1899 {
1900 *ucr2 &= ~UCR2_CTSC;
1901 @@ -399,6 +401,7 @@ static void imx_uart_rts_inactive(struct imx_port *sport, u32 *ucr2)
1902 mctrl_gpio_set(sport->gpios, sport->port.mctrl);
1903 }
1904
1905 +/* called with port.lock taken and irqs caller dependent */
1906 static void imx_uart_rts_auto(struct imx_port *sport, u32 *ucr2)
1907 {
1908 *ucr2 |= UCR2_CTSC;
1909 @@ -1554,6 +1557,16 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios,
1910 old_csize = CS8;
1911 }
1912
1913 + del_timer_sync(&sport->timer);
1914 +
1915 + /*
1916 + * Ask the core to calculate the divisor for us.
1917 + */
1918 + baud = uart_get_baud_rate(port, termios, old, 50, port->uartclk / 16);
1919 + quot = uart_get_divisor(port, baud);
1920 +
1921 + spin_lock_irqsave(&sport->port.lock, flags);
1922 +
1923 if ((termios->c_cflag & CSIZE) == CS8)
1924 ucr2 = UCR2_WS | UCR2_SRST | UCR2_IRTS;
1925 else
1926 @@ -1597,16 +1610,6 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios,
1927 ucr2 |= UCR2_PROE;
1928 }
1929
1930 - del_timer_sync(&sport->timer);
1931 -
1932 - /*
1933 - * Ask the core to calculate the divisor for us.
1934 - */
1935 - baud = uart_get_baud_rate(port, termios, old, 50, port->uartclk / 16);
1936 - quot = uart_get_divisor(port, baud);
1937 -
1938 - spin_lock_irqsave(&sport->port.lock, flags);
1939 -
1940 sport->port.read_status_mask = 0;
1941 if (termios->c_iflag & INPCK)
1942 sport->port.read_status_mask |= (URXD_FRMERR | URXD_PRERR);
1943 diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
1944 index 38c48a02b920..bd3e6cf81af5 100644
1945 --- a/drivers/tty/serial/max310x.c
1946 +++ b/drivers/tty/serial/max310x.c
1947 @@ -491,37 +491,48 @@ static bool max310x_reg_precious(struct device *dev, unsigned int reg)
1948
1949 static int max310x_set_baud(struct uart_port *port, int baud)
1950 {
1951 - unsigned int mode = 0, clk = port->uartclk, div = clk / baud;
1952 + unsigned int mode = 0, div = 0, frac = 0, c = 0, F = 0;
1953
1954 - /* Check for minimal value for divider */
1955 - if (div < 16)
1956 - div = 16;
1957 -
1958 - if (clk % baud && (div / 16) < 0x8000) {
1959 + /*
1960 + * Calculate the integer divisor first. Select a proper mode
1961 + * in case if the requested baud is too high for the pre-defined
1962 + * clocks frequency.
1963 + */
1964 + div = port->uartclk / baud;
1965 + if (div < 8) {
1966 + /* Mode x4 */
1967 + c = 4;
1968 + mode = MAX310X_BRGCFG_4XMODE_BIT;
1969 + } else if (div < 16) {
1970 /* Mode x2 */
1971 + c = 8;
1972 mode = MAX310X_BRGCFG_2XMODE_BIT;
1973 - clk = port->uartclk * 2;
1974 - div = clk / baud;
1975 -
1976 - if (clk % baud && (div / 16) < 0x8000) {
1977 - /* Mode x4 */
1978 - mode = MAX310X_BRGCFG_4XMODE_BIT;
1979 - clk = port->uartclk * 4;
1980 - div = clk / baud;
1981 - }
1982 + } else {
1983 + c = 16;
1984 }
1985
1986 - max310x_port_write(port, MAX310X_BRGDIVMSB_REG, (div / 16) >> 8);
1987 - max310x_port_write(port, MAX310X_BRGDIVLSB_REG, div / 16);
1988 - max310x_port_write(port, MAX310X_BRGCFG_REG, (div % 16) | mode);
1989 + /* Calculate the divisor in accordance with the fraction coefficient */
1990 + div /= c;
1991 + F = c*baud;
1992 +
1993 + /* Calculate the baud rate fraction */
1994 + if (div > 0)
1995 + frac = (16*(port->uartclk % F)) / F;
1996 + else
1997 + div = 1;
1998 +
1999 + max310x_port_write(port, MAX310X_BRGDIVMSB_REG, div >> 8);
2000 + max310x_port_write(port, MAX310X_BRGDIVLSB_REG, div);
2001 + max310x_port_write(port, MAX310X_BRGCFG_REG, frac | mode);
2002
2003 - return DIV_ROUND_CLOSEST(clk, div);
2004 + /* Return the actual baud rate we just programmed */
2005 + return (16*port->uartclk) / (c*(16*div + frac));
2006 }
2007
2008 static int max310x_update_best_err(unsigned long f, long *besterr)
2009 {
2010 /* Use baudrate 115200 for calculate error */
2011 - long err = f % (115200 * 16);
2012 + long err = f % (460800 * 16);
2013
2014 if ((*besterr < 0) || (*besterr > err)) {
2015 *besterr = err;
2016 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
2017 index 0f41b936da03..310bbae515b0 100644
2018 --- a/drivers/tty/serial/msm_serial.c
2019 +++ b/drivers/tty/serial/msm_serial.c
2020 @@ -383,10 +383,14 @@ no_rx:
2021
2022 static inline void msm_wait_for_xmitr(struct uart_port *port)
2023 {
2024 + unsigned int timeout = 500000;
2025 +
2026 while (!(msm_read(port, UART_SR) & UART_SR_TX_EMPTY)) {
2027 if (msm_read(port, UART_ISR) & UART_ISR_TX_READY)
2028 break;
2029 udelay(1);
2030 + if (!timeout--)
2031 + break;
2032 }
2033 msm_write(port, UART_CR_CMD_RESET_TX_READY, UART_CR);
2034 }
2035 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
2036 index 8dbeb14a1e3a..fe9261ffe3db 100644
2037 --- a/drivers/tty/serial/serial_core.c
2038 +++ b/drivers/tty/serial/serial_core.c
2039 @@ -1738,6 +1738,7 @@ static int uart_port_activate(struct tty_port *port, struct tty_struct *tty)
2040 {
2041 struct uart_state *state = container_of(port, struct uart_state, port);
2042 struct uart_port *uport;
2043 + int ret;
2044
2045 uport = uart_port_check(state);
2046 if (!uport || uport->flags & UPF_DEAD)
2047 @@ -1748,7 +1749,11 @@ static int uart_port_activate(struct tty_port *port, struct tty_struct *tty)
2048 /*
2049 * Start up the serial port.
2050 */
2051 - return uart_startup(tty, state, 0);
2052 + ret = uart_startup(tty, state, 0);
2053 + if (ret > 0)
2054 + tty_port_set_active(port, 1);
2055 +
2056 + return ret;
2057 }
2058
2059 static const char *uart_type(struct uart_port *port)
2060 diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c
2061 index 1c06325beaca..07f318603e74 100644
2062 --- a/drivers/tty/serial/serial_mctrl_gpio.c
2063 +++ b/drivers/tty/serial/serial_mctrl_gpio.c
2064 @@ -12,6 +12,7 @@
2065 #include <linux/termios.h>
2066 #include <linux/serial_core.h>
2067 #include <linux/module.h>
2068 +#include <linux/property.h>
2069
2070 #include "serial_mctrl_gpio.h"
2071
2072 @@ -115,6 +116,19 @@ struct mctrl_gpios *mctrl_gpio_init_noauto(struct device *dev, unsigned int idx)
2073
2074 for (i = 0; i < UART_GPIO_MAX; i++) {
2075 enum gpiod_flags flags;
2076 + char *gpio_str;
2077 + bool present;
2078 +
2079 + /* Check if GPIO property exists and continue if not */
2080 + gpio_str = kasprintf(GFP_KERNEL, "%s-gpios",
2081 + mctrl_gpios_desc[i].name);
2082 + if (!gpio_str)
2083 + continue;
2084 +
2085 + present = device_property_present(dev, gpio_str);
2086 + kfree(gpio_str);
2087 + if (!present)
2088 + continue;
2089
2090 if (mctrl_gpios_desc[i].dir_out)
2091 flags = GPIOD_OUT_LOW;
2092 diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
2093 index 040832635a64..5550289e6678 100644
2094 --- a/drivers/tty/serial/sh-sci.c
2095 +++ b/drivers/tty/serial/sh-sci.c
2096 @@ -1376,6 +1376,7 @@ static void work_fn_tx(struct work_struct *work)
2097 struct circ_buf *xmit = &port->state->xmit;
2098 unsigned long flags;
2099 dma_addr_t buf;
2100 + int head, tail;
2101
2102 /*
2103 * DMA is idle now.
2104 @@ -1385,16 +1386,23 @@ static void work_fn_tx(struct work_struct *work)
2105 * consistent xmit buffer state.
2106 */
2107 spin_lock_irq(&port->lock);
2108 - buf = s->tx_dma_addr + (xmit->tail & (UART_XMIT_SIZE - 1));
2109 + head = xmit->head;
2110 + tail = xmit->tail;
2111 + buf = s->tx_dma_addr + (tail & (UART_XMIT_SIZE - 1));
2112 s->tx_dma_len = min_t(unsigned int,
2113 - CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE),
2114 - CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE));
2115 - spin_unlock_irq(&port->lock);
2116 + CIRC_CNT(head, tail, UART_XMIT_SIZE),
2117 + CIRC_CNT_TO_END(head, tail, UART_XMIT_SIZE));
2118 + if (!s->tx_dma_len) {
2119 + /* Transmit buffer has been flushed */
2120 + spin_unlock_irq(&port->lock);
2121 + return;
2122 + }
2123
2124 desc = dmaengine_prep_slave_single(chan, buf, s->tx_dma_len,
2125 DMA_MEM_TO_DEV,
2126 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
2127 if (!desc) {
2128 + spin_unlock_irq(&port->lock);
2129 dev_warn(port->dev, "Failed preparing Tx DMA descriptor\n");
2130 goto switch_to_pio;
2131 }
2132 @@ -1402,18 +1410,18 @@ static void work_fn_tx(struct work_struct *work)
2133 dma_sync_single_for_device(chan->device->dev, buf, s->tx_dma_len,
2134 DMA_TO_DEVICE);
2135
2136 - spin_lock_irq(&port->lock);
2137 desc->callback = sci_dma_tx_complete;
2138 desc->callback_param = s;
2139 - spin_unlock_irq(&port->lock);
2140 s->cookie_tx = dmaengine_submit(desc);
2141 if (dma_submit_error(s->cookie_tx)) {
2142 + spin_unlock_irq(&port->lock);
2143 dev_warn(port->dev, "Failed submitting Tx DMA descriptor\n");
2144 goto switch_to_pio;
2145 }
2146
2147 + spin_unlock_irq(&port->lock);
2148 dev_dbg(port->dev, "%s: %p: %d...%d, cookie %d\n",
2149 - __func__, xmit->buf, xmit->tail, xmit->head, s->cookie_tx);
2150 + __func__, xmit->buf, tail, head, s->cookie_tx);
2151
2152 dma_async_issue_pending(chan);
2153 return;
2154 @@ -1633,11 +1641,18 @@ static void sci_free_dma(struct uart_port *port)
2155
2156 static void sci_flush_buffer(struct uart_port *port)
2157 {
2158 + struct sci_port *s = to_sci_port(port);
2159 +
2160 /*
2161 * In uart_flush_buffer(), the xmit circular buffer has just been
2162 - * cleared, so we have to reset tx_dma_len accordingly.
2163 + * cleared, so we have to reset tx_dma_len accordingly, and stop any
2164 + * pending transfers
2165 */
2166 - to_sci_port(port)->tx_dma_len = 0;
2167 + s->tx_dma_len = 0;
2168 + if (s->chan_tx) {
2169 + dmaengine_terminate_async(s->chan_tx);
2170 + s->cookie_tx = -EINVAL;
2171 + }
2172 }
2173 #else /* !CONFIG_SERIAL_SH_SCI_DMA */
2174 static inline void sci_request_dma(struct uart_port *port)
2175 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
2176 index f4e8e869649a..8018f813972e 100644
2177 --- a/drivers/usb/core/hub.c
2178 +++ b/drivers/usb/core/hub.c
2179 @@ -3961,6 +3961,9 @@ static int usb_set_lpm_timeout(struct usb_device *udev,
2180 * control transfers to set the hub timeout or enable device-initiated U1/U2
2181 * will be successful.
2182 *
2183 + * If the control transfer to enable device-initiated U1/U2 entry fails, then
2184 + * hub-initiated U1/U2 will be disabled.
2185 + *
2186 * If we cannot set the parent hub U1/U2 timeout, we attempt to let the xHCI
2187 * driver know about it. If that call fails, it should be harmless, and just
2188 * take up more slightly more bus bandwidth for unnecessary U1/U2 exit latency.
2189 @@ -4015,23 +4018,24 @@ static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev,
2190 * host know that this link state won't be enabled.
2191 */
2192 hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state);
2193 - } else {
2194 - /* Only a configured device will accept the Set Feature
2195 - * U1/U2_ENABLE
2196 - */
2197 - if (udev->actconfig)
2198 - usb_set_device_initiated_lpm(udev, state, true);
2199 + return;
2200 + }
2201
2202 - /* As soon as usb_set_lpm_timeout(timeout) returns 0, the
2203 - * hub-initiated LPM is enabled. Thus, LPM is enabled no
2204 - * matter the result of usb_set_device_initiated_lpm().
2205 - * The only difference is whether device is able to initiate
2206 - * LPM.
2207 - */
2208 + /* Only a configured device will accept the Set Feature
2209 + * U1/U2_ENABLE
2210 + */
2211 + if (udev->actconfig &&
2212 + usb_set_device_initiated_lpm(udev, state, true) == 0) {
2213 if (state == USB3_LPM_U1)
2214 udev->usb3_lpm_u1_enabled = 1;
2215 else if (state == USB3_LPM_U2)
2216 udev->usb3_lpm_u2_enabled = 1;
2217 + } else {
2218 + /* Don't request U1/U2 entry if the device
2219 + * cannot transition to U1/U2.
2220 + */
2221 + usb_set_lpm_timeout(udev, state, 0);
2222 + hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state);
2223 }
2224 }
2225
2226 diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
2227 index aa15593a3ac4..2050993fb58b 100644
2228 --- a/drivers/usb/gadget/function/f_fs.c
2229 +++ b/drivers/usb/gadget/function/f_fs.c
2230 @@ -1101,11 +1101,12 @@ static ssize_t ffs_epfile_write_iter(struct kiocb *kiocb, struct iov_iter *from)
2231 ENTER();
2232
2233 if (!is_sync_kiocb(kiocb)) {
2234 - p = kmalloc(sizeof(io_data), GFP_KERNEL);
2235 + p = kzalloc(sizeof(io_data), GFP_KERNEL);
2236 if (unlikely(!p))
2237 return -ENOMEM;
2238 p->aio = true;
2239 } else {
2240 + memset(p, 0, sizeof(*p));
2241 p->aio = false;
2242 }
2243
2244 @@ -1137,11 +1138,12 @@ static ssize_t ffs_epfile_read_iter(struct kiocb *kiocb, struct iov_iter *to)
2245 ENTER();
2246
2247 if (!is_sync_kiocb(kiocb)) {
2248 - p = kmalloc(sizeof(io_data), GFP_KERNEL);
2249 + p = kzalloc(sizeof(io_data), GFP_KERNEL);
2250 if (unlikely(!p))
2251 return -ENOMEM;
2252 p->aio = true;
2253 } else {
2254 + memset(p, 0, sizeof(*p));
2255 p->aio = false;
2256 }
2257
2258 diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
2259 index 09a8ebd95588..6968b9f2b76b 100644
2260 --- a/drivers/usb/host/hwa-hc.c
2261 +++ b/drivers/usb/host/hwa-hc.c
2262 @@ -159,7 +159,7 @@ out:
2263 return result;
2264
2265 error_set_cluster_id:
2266 - wusb_cluster_id_put(wusbhc->cluster_id);
2267 + wusb_cluster_id_put(addr);
2268 error_cluster_id_get:
2269 goto out;
2270
2271 diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
2272 index 3625a5c1a41b..070c66f86e67 100644
2273 --- a/drivers/usb/host/pci-quirks.c
2274 +++ b/drivers/usb/host/pci-quirks.c
2275 @@ -205,7 +205,7 @@ int usb_amd_find_chipset_info(void)
2276 {
2277 unsigned long flags;
2278 struct amd_chipset_info info;
2279 - int ret;
2280 + int need_pll_quirk = 0;
2281
2282 spin_lock_irqsave(&amd_lock, flags);
2283
2284 @@ -219,21 +219,28 @@ int usb_amd_find_chipset_info(void)
2285 spin_unlock_irqrestore(&amd_lock, flags);
2286
2287 if (!amd_chipset_sb_type_init(&info)) {
2288 - ret = 0;
2289 goto commit;
2290 }
2291
2292 - /* Below chipset generations needn't enable AMD PLL quirk */
2293 - if (info.sb_type.gen == AMD_CHIPSET_UNKNOWN ||
2294 - info.sb_type.gen == AMD_CHIPSET_SB600 ||
2295 - info.sb_type.gen == AMD_CHIPSET_YANGTZE ||
2296 - (info.sb_type.gen == AMD_CHIPSET_SB700 &&
2297 - info.sb_type.rev > 0x3b)) {
2298 + switch (info.sb_type.gen) {
2299 + case AMD_CHIPSET_SB700:
2300 + need_pll_quirk = info.sb_type.rev <= 0x3B;
2301 + break;
2302 + case AMD_CHIPSET_SB800:
2303 + case AMD_CHIPSET_HUDSON2:
2304 + case AMD_CHIPSET_BOLTON:
2305 + need_pll_quirk = 1;
2306 + break;
2307 + default:
2308 + need_pll_quirk = 0;
2309 + break;
2310 + }
2311 +
2312 + if (!need_pll_quirk) {
2313 if (info.smbus_dev) {
2314 pci_dev_put(info.smbus_dev);
2315 info.smbus_dev = NULL;
2316 }
2317 - ret = 0;
2318 goto commit;
2319 }
2320
2321 @@ -252,7 +259,7 @@ int usb_amd_find_chipset_info(void)
2322 }
2323 }
2324
2325 - ret = info.probe_result = 1;
2326 + need_pll_quirk = info.probe_result = 1;
2327 printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n");
2328
2329 commit:
2330 @@ -263,7 +270,7 @@ commit:
2331
2332 /* Mark that we where here */
2333 amd_chipset.probe_count++;
2334 - ret = amd_chipset.probe_result;
2335 + need_pll_quirk = amd_chipset.probe_result;
2336
2337 spin_unlock_irqrestore(&amd_lock, flags);
2338
2339 @@ -277,7 +284,7 @@ commit:
2340 spin_unlock_irqrestore(&amd_lock, flags);
2341 }
2342
2343 - return ret;
2344 + return need_pll_quirk;
2345 }
2346 EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info);
2347
2348 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
2349 index e1cbdfdb7c68..197069303510 100644
2350 --- a/fs/9p/vfs_addr.c
2351 +++ b/fs/9p/vfs_addr.c
2352 @@ -50,8 +50,9 @@
2353 * @page: structure to page
2354 *
2355 */
2356 -static int v9fs_fid_readpage(struct p9_fid *fid, struct page *page)
2357 +static int v9fs_fid_readpage(void *data, struct page *page)
2358 {
2359 + struct p9_fid *fid = data;
2360 struct inode *inode = page->mapping->host;
2361 struct bio_vec bvec = {.bv_page = page, .bv_len = PAGE_SIZE};
2362 struct iov_iter to;
2363 @@ -122,7 +123,8 @@ static int v9fs_vfs_readpages(struct file *filp, struct address_space *mapping,
2364 if (ret == 0)
2365 return ret;
2366
2367 - ret = read_cache_pages(mapping, pages, (void *)v9fs_vfs_readpage, filp);
2368 + ret = read_cache_pages(mapping, pages, v9fs_fid_readpage,
2369 + filp->private_data);
2370 p9_debug(P9_DEBUG_VFS, " = %d\n", ret);
2371 return ret;
2372 }
2373 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
2374 index c1cd3fe2b295..355ff08e9d44 100644
2375 --- a/fs/btrfs/inode.c
2376 +++ b/fs/btrfs/inode.c
2377 @@ -388,10 +388,31 @@ static noinline int add_async_extent(struct async_cow *cow,
2378 return 0;
2379 }
2380
2381 +/*
2382 + * Check if the inode has flags compatible with compression
2383 + */
2384 +static inline bool inode_can_compress(struct inode *inode)
2385 +{
2386 + if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATACOW ||
2387 + BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)
2388 + return false;
2389 + return true;
2390 +}
2391 +
2392 +/*
2393 + * Check if the inode needs to be submitted to compression, based on mount
2394 + * options, defragmentation, properties or heuristics.
2395 + */
2396 static inline int inode_need_compress(struct inode *inode, u64 start, u64 end)
2397 {
2398 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
2399
2400 + if (!inode_can_compress(inode)) {
2401 + WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG),
2402 + KERN_ERR "BTRFS: unexpected compression for ino %llu\n",
2403 + btrfs_ino(BTRFS_I(inode)));
2404 + return 0;
2405 + }
2406 /* force compress */
2407 if (btrfs_test_opt(fs_info, FORCE_COMPRESS))
2408 return 1;
2409 @@ -1596,7 +1617,8 @@ static int run_delalloc_range(void *private_data, struct page *locked_page,
2410 } else if (BTRFS_I(inode)->flags & BTRFS_INODE_PREALLOC && !force_cow) {
2411 ret = run_delalloc_nocow(inode, locked_page, start, end,
2412 page_started, 0, nr_written);
2413 - } else if (!inode_need_compress(inode, start, end)) {
2414 + } else if (!inode_can_compress(inode) ||
2415 + !inode_need_compress(inode, start, end)) {
2416 ret = cow_file_range(inode, locked_page, start, end, end,
2417 page_started, nr_written, 1, NULL);
2418 } else {
2419 diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
2420 index a5e4a221435c..a93ebffe84b3 100644
2421 --- a/fs/dlm/lowcomms.c
2422 +++ b/fs/dlm/lowcomms.c
2423 @@ -1630,8 +1630,10 @@ static void clean_writequeues(void)
2424
2425 static void work_stop(void)
2426 {
2427 - destroy_workqueue(recv_workqueue);
2428 - destroy_workqueue(send_workqueue);
2429 + if (recv_workqueue)
2430 + destroy_workqueue(recv_workqueue);
2431 + if (send_workqueue)
2432 + destroy_workqueue(send_workqueue);
2433 }
2434
2435 static int work_start(void)
2436 @@ -1691,13 +1693,17 @@ static void work_flush(void)
2437 struct hlist_node *n;
2438 struct connection *con;
2439
2440 - flush_workqueue(recv_workqueue);
2441 - flush_workqueue(send_workqueue);
2442 + if (recv_workqueue)
2443 + flush_workqueue(recv_workqueue);
2444 + if (send_workqueue)
2445 + flush_workqueue(send_workqueue);
2446 do {
2447 ok = 1;
2448 foreach_conn(stop_conn);
2449 - flush_workqueue(recv_workqueue);
2450 - flush_workqueue(send_workqueue);
2451 + if (recv_workqueue)
2452 + flush_workqueue(recv_workqueue);
2453 + if (send_workqueue)
2454 + flush_workqueue(send_workqueue);
2455 for (i = 0; i < CONN_HASH_SIZE && ok; i++) {
2456 hlist_for_each_entry_safe(con, n,
2457 &connection_hash[i], list) {
2458 diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
2459 index 8fc3edb6760c..92f72bb5aff4 100644
2460 --- a/fs/f2fs/segment.c
2461 +++ b/fs/f2fs/segment.c
2462 @@ -3261,6 +3261,11 @@ static int read_compacted_summaries(struct f2fs_sb_info *sbi)
2463 seg_i = CURSEG_I(sbi, i);
2464 segno = le32_to_cpu(ckpt->cur_data_segno[i]);
2465 blk_off = le16_to_cpu(ckpt->cur_data_blkoff[i]);
2466 + if (blk_off > ENTRIES_IN_SUM) {
2467 + f2fs_bug_on(sbi, 1);
2468 + f2fs_put_page(page, 1);
2469 + return -EFAULT;
2470 + }
2471 seg_i->next_segno = segno;
2472 reset_curseg(sbi, i, 0);
2473 seg_i->alloc_type = ckpt->alloc_type[i];
2474 diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
2475 index 29dee9630eec..a18b8d7a3075 100644
2476 --- a/fs/notify/fanotify/fanotify.c
2477 +++ b/fs/notify/fanotify/fanotify.c
2478 @@ -148,10 +148,13 @@ struct fanotify_event_info *fanotify_alloc_event(struct fsnotify_group *group,
2479 /*
2480 * For queues with unlimited length lost events are not expected and
2481 * can possibly have security implications. Avoid losing events when
2482 - * memory is short.
2483 + * memory is short. For the limited size queues, avoid OOM killer in the
2484 + * target monitoring memcg as it may have security repercussion.
2485 */
2486 if (group->max_events == UINT_MAX)
2487 gfp |= __GFP_NOFAIL;
2488 + else
2489 + gfp |= __GFP_RETRY_MAYFAIL;
2490
2491 /* Whoever is interested in the event, pays for the allocation. */
2492 memalloc_use_memcg(group->memcg);
2493 diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c
2494 index f4184b4f3815..16b8702af0e7 100644
2495 --- a/fs/notify/inotify/inotify_fsnotify.c
2496 +++ b/fs/notify/inotify/inotify_fsnotify.c
2497 @@ -99,9 +99,13 @@ int inotify_handle_event(struct fsnotify_group *group,
2498 i_mark = container_of(inode_mark, struct inotify_inode_mark,
2499 fsn_mark);
2500
2501 - /* Whoever is interested in the event, pays for the allocation. */
2502 + /*
2503 + * Whoever is interested in the event, pays for the allocation. Do not
2504 + * trigger OOM killer in the target monitoring memcg as it may have
2505 + * security repercussion.
2506 + */
2507 memalloc_use_memcg(group->memcg);
2508 - event = kmalloc(alloc_len, GFP_KERNEL_ACCOUNT);
2509 + event = kmalloc(alloc_len, GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL);
2510 memalloc_unuse_memcg();
2511
2512 if (unlikely(!event)) {
2513 diff --git a/fs/open.c b/fs/open.c
2514 index a00350018a47..878478745924 100644
2515 --- a/fs/open.c
2516 +++ b/fs/open.c
2517 @@ -373,6 +373,25 @@ long do_faccessat(int dfd, const char __user *filename, int mode)
2518 override_cred->cap_permitted;
2519 }
2520
2521 + /*
2522 + * The new set of credentials can *only* be used in
2523 + * task-synchronous circumstances, and does not need
2524 + * RCU freeing, unless somebody then takes a separate
2525 + * reference to it.
2526 + *
2527 + * NOTE! This is _only_ true because this credential
2528 + * is used purely for override_creds() that installs
2529 + * it as the subjective cred. Other threads will be
2530 + * accessing ->real_cred, not the subjective cred.
2531 + *
2532 + * If somebody _does_ make a copy of this (using the
2533 + * 'get_current_cred()' function), that will clear the
2534 + * non_rcu field, because now that other user may be
2535 + * expecting RCU freeing. But normal thread-synchronous
2536 + * cred accesses will keep things non-RCY.
2537 + */
2538 + override_cred->non_rcu = 1;
2539 +
2540 old_cred = override_creds(override_cred);
2541 retry:
2542 res = user_path_at(dfd, filename, lookup_flags, &path);
2543 diff --git a/fs/proc/base.c b/fs/proc/base.c
2544 index f999e8bd3771..a7fbda72afeb 100644
2545 --- a/fs/proc/base.c
2546 +++ b/fs/proc/base.c
2547 @@ -1960,9 +1960,12 @@ static int map_files_d_revalidate(struct dentry *dentry, unsigned int flags)
2548 goto out;
2549
2550 if (!dname_to_vma_addr(dentry, &vm_start, &vm_end)) {
2551 - down_read(&mm->mmap_sem);
2552 - exact_vma_exists = !!find_exact_vma(mm, vm_start, vm_end);
2553 - up_read(&mm->mmap_sem);
2554 + status = down_read_killable(&mm->mmap_sem);
2555 + if (!status) {
2556 + exact_vma_exists = !!find_exact_vma(mm, vm_start,
2557 + vm_end);
2558 + up_read(&mm->mmap_sem);
2559 + }
2560 }
2561
2562 mmput(mm);
2563 @@ -2008,8 +2011,11 @@ static int map_files_get_link(struct dentry *dentry, struct path *path)
2564 if (rc)
2565 goto out_mmput;
2566
2567 + rc = down_read_killable(&mm->mmap_sem);
2568 + if (rc)
2569 + goto out_mmput;
2570 +
2571 rc = -ENOENT;
2572 - down_read(&mm->mmap_sem);
2573 vma = find_exact_vma(mm, vm_start, vm_end);
2574 if (vma && vma->vm_file) {
2575 *path = vma->vm_file->f_path;
2576 @@ -2105,7 +2111,11 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
2577 if (!mm)
2578 goto out_put_task;
2579
2580 - down_read(&mm->mmap_sem);
2581 + result = ERR_PTR(-EINTR);
2582 + if (down_read_killable(&mm->mmap_sem))
2583 + goto out_put_mm;
2584 +
2585 + result = ERR_PTR(-ENOENT);
2586 vma = find_exact_vma(mm, vm_start, vm_end);
2587 if (!vma)
2588 goto out_no_vma;
2589 @@ -2116,6 +2126,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
2590
2591 out_no_vma:
2592 up_read(&mm->mmap_sem);
2593 +out_put_mm:
2594 mmput(mm);
2595 out_put_task:
2596 put_task_struct(task);
2597 @@ -2157,7 +2168,12 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
2598 mm = get_task_mm(task);
2599 if (!mm)
2600 goto out_put_task;
2601 - down_read(&mm->mmap_sem);
2602 +
2603 + ret = down_read_killable(&mm->mmap_sem);
2604 + if (ret) {
2605 + mmput(mm);
2606 + goto out_put_task;
2607 + }
2608
2609 nr_files = 0;
2610
2611 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
2612 index c5819baee35c..71aba44c4fa6 100644
2613 --- a/fs/proc/task_mmu.c
2614 +++ b/fs/proc/task_mmu.c
2615 @@ -166,7 +166,11 @@ static void *m_start(struct seq_file *m, loff_t *ppos)
2616 if (!mm || !mmget_not_zero(mm))
2617 return NULL;
2618
2619 - down_read(&mm->mmap_sem);
2620 + if (down_read_killable(&mm->mmap_sem)) {
2621 + mmput(mm);
2622 + return ERR_PTR(-EINTR);
2623 + }
2624 +
2625 hold_task_mempolicy(priv);
2626 priv->tail_vma = get_gate_vma(mm);
2627
2628 @@ -826,7 +830,10 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
2629
2630 memset(&mss, 0, sizeof(mss));
2631
2632 - down_read(&mm->mmap_sem);
2633 + ret = down_read_killable(&mm->mmap_sem);
2634 + if (ret)
2635 + goto out_put_mm;
2636 +
2637 hold_task_mempolicy(priv);
2638
2639 for (vma = priv->mm->mmap; vma; vma = vma->vm_next) {
2640 @@ -843,8 +850,9 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
2641
2642 release_task_mempolicy(priv);
2643 up_read(&mm->mmap_sem);
2644 - mmput(mm);
2645
2646 +out_put_mm:
2647 + mmput(mm);
2648 out_put_task:
2649 put_task_struct(priv->task);
2650 priv->task = NULL;
2651 @@ -1127,7 +1135,10 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
2652 goto out_mm;
2653 }
2654
2655 - down_read(&mm->mmap_sem);
2656 + if (down_read_killable(&mm->mmap_sem)) {
2657 + count = -EINTR;
2658 + goto out_mm;
2659 + }
2660 tlb_gather_mmu(&tlb, mm, 0, -1);
2661 if (type == CLEAR_REFS_SOFT_DIRTY) {
2662 for (vma = mm->mmap; vma; vma = vma->vm_next) {
2663 @@ -1531,7 +1542,9 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
2664 /* overflow ? */
2665 if (end < start_vaddr || end > end_vaddr)
2666 end = end_vaddr;
2667 - down_read(&mm->mmap_sem);
2668 + ret = down_read_killable(&mm->mmap_sem);
2669 + if (ret)
2670 + goto out_free;
2671 ret = walk_page_range(start_vaddr, end, &pagemap_walk);
2672 up_read(&mm->mmap_sem);
2673 start_vaddr = end;
2674 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
2675 index 0b63d68dedb2..5161894a6d62 100644
2676 --- a/fs/proc/task_nommu.c
2677 +++ b/fs/proc/task_nommu.c
2678 @@ -211,7 +211,11 @@ static void *m_start(struct seq_file *m, loff_t *pos)
2679 if (!mm || !mmget_not_zero(mm))
2680 return NULL;
2681
2682 - down_read(&mm->mmap_sem);
2683 + if (down_read_killable(&mm->mmap_sem)) {
2684 + mmput(mm);
2685 + return ERR_PTR(-EINTR);
2686 + }
2687 +
2688 /* start from the Nth VMA */
2689 for (p = rb_first(&mm->mm_rb); p; p = rb_next(p))
2690 if (n-- == 0)
2691 diff --git a/include/linux/cred.h b/include/linux/cred.h
2692 index 7eed6101c791..1dc351d8548b 100644
2693 --- a/include/linux/cred.h
2694 +++ b/include/linux/cred.h
2695 @@ -150,7 +150,11 @@ struct cred {
2696 struct user_struct *user; /* real user ID subscription */
2697 struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */
2698 struct group_info *group_info; /* supplementary groups for euid/fsgid */
2699 - struct rcu_head rcu; /* RCU deletion hook */
2700 + /* RCU deletion */
2701 + union {
2702 + int non_rcu; /* Can we skip RCU deletion? */
2703 + struct rcu_head rcu; /* RCU deletion hook */
2704 + };
2705 } __randomize_layout;
2706
2707 extern void __put_cred(struct cred *);
2708 @@ -248,6 +252,7 @@ static inline const struct cred *get_cred(const struct cred *cred)
2709 {
2710 struct cred *nonconst_cred = (struct cred *) cred;
2711 validate_creds(cred);
2712 + nonconst_cred->non_rcu = 0;
2713 return get_new_cred(nonconst_cred);
2714 }
2715
2716 diff --git a/include/linux/host1x.h b/include/linux/host1x.h
2717 index 89110d896d72..aef6e2f73802 100644
2718 --- a/include/linux/host1x.h
2719 +++ b/include/linux/host1x.h
2720 @@ -310,6 +310,8 @@ struct host1x_device {
2721 struct list_head clients;
2722
2723 bool registered;
2724 +
2725 + struct device_dma_parameters dma_parms;
2726 };
2727
2728 static inline struct host1x_device *to_host1x_device(struct device *dev)
2729 diff --git a/kernel/cred.c b/kernel/cred.c
2730 index efd04b2ec84c..5ab1f7ec946e 100644
2731 --- a/kernel/cred.c
2732 +++ b/kernel/cred.c
2733 @@ -147,7 +147,10 @@ void __put_cred(struct cred *cred)
2734 BUG_ON(cred == current->cred);
2735 BUG_ON(cred == current->real_cred);
2736
2737 - call_rcu(&cred->rcu, put_cred_rcu);
2738 + if (cred->non_rcu)
2739 + put_cred_rcu(&cred->rcu);
2740 + else
2741 + call_rcu(&cred->rcu, put_cred_rcu);
2742 }
2743 EXPORT_SYMBOL(__put_cred);
2744
2745 @@ -258,6 +261,7 @@ struct cred *prepare_creds(void)
2746 old = task->cred;
2747 memcpy(new, old, sizeof(struct cred));
2748
2749 + new->non_rcu = 0;
2750 atomic_set(&new->usage, 1);
2751 set_cred_subscribers(new, 0);
2752 get_group_info(new->group_info);
2753 @@ -537,7 +541,19 @@ const struct cred *override_creds(const struct cred *new)
2754
2755 validate_creds(old);
2756 validate_creds(new);
2757 - get_cred(new);
2758 +
2759 + /*
2760 + * NOTE! This uses 'get_new_cred()' rather than 'get_cred()'.
2761 + *
2762 + * That means that we do not clear the 'non_rcu' flag, since
2763 + * we are only installing the cred into the thread-synchronous
2764 + * '->cred' pointer, not the '->real_cred' pointer that is
2765 + * visible to other threads under RCU.
2766 + *
2767 + * Also note that we did validate_creds() manually, not depending
2768 + * on the validation in 'get_cred()'.
2769 + */
2770 + get_new_cred((struct cred *)new);
2771 alter_cred_subscribers(new, 1);
2772 rcu_assign_pointer(current->cred, new);
2773 alter_cred_subscribers(old, -1);
2774 @@ -620,6 +636,7 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon)
2775 validate_creds(old);
2776
2777 *new = *old;
2778 + new->non_rcu = 0;
2779 atomic_set(&new->usage, 1);
2780 set_cred_subscribers(new, 0);
2781 get_uid(new->user);
2782 diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
2783 index 3dd980dfba2d..6fcc4650f0c4 100644
2784 --- a/kernel/locking/lockdep_proc.c
2785 +++ b/kernel/locking/lockdep_proc.c
2786 @@ -200,7 +200,6 @@ static void lockdep_stats_debug_show(struct seq_file *m)
2787
2788 static int lockdep_stats_show(struct seq_file *m, void *v)
2789 {
2790 - struct lock_class *class;
2791 unsigned long nr_unused = 0, nr_uncategorized = 0,
2792 nr_irq_safe = 0, nr_irq_unsafe = 0,
2793 nr_softirq_safe = 0, nr_softirq_unsafe = 0,
2794 @@ -210,6 +209,9 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
2795 nr_hardirq_read_safe = 0, nr_hardirq_read_unsafe = 0,
2796 sum_forward_deps = 0;
2797
2798 +#ifdef CONFIG_PROVE_LOCKING
2799 + struct lock_class *class;
2800 +
2801 list_for_each_entry(class, &all_lock_classes, lock_entry) {
2802
2803 if (class->usage_mask == 0)
2804 @@ -241,12 +243,12 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
2805 if (class->usage_mask & LOCKF_ENABLED_HARDIRQ_READ)
2806 nr_hardirq_read_unsafe++;
2807
2808 -#ifdef CONFIG_PROVE_LOCKING
2809 sum_forward_deps += lockdep_count_forward_deps(class);
2810 -#endif
2811 }
2812 #ifdef CONFIG_DEBUG_LOCKDEP
2813 DEBUG_LOCKS_WARN_ON(debug_atomic_read(nr_unused_locks) != nr_unused);
2814 +#endif
2815 +
2816 #endif
2817 seq_printf(m, " lock-classes: %11lu [max: %lu]\n",
2818 nr_lock_classes, MAX_LOCKDEP_KEYS);
2819 diff --git a/mm/gup.c b/mm/gup.c
2820 index caadd31714a5..f3088d25bd92 100644
2821 --- a/mm/gup.c
2822 +++ b/mm/gup.c
2823 @@ -458,11 +458,14 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
2824 pgd = pgd_offset_k(address);
2825 else
2826 pgd = pgd_offset_gate(mm, address);
2827 - BUG_ON(pgd_none(*pgd));
2828 + if (pgd_none(*pgd))
2829 + return -EFAULT;
2830 p4d = p4d_offset(pgd, address);
2831 - BUG_ON(p4d_none(*p4d));
2832 + if (p4d_none(*p4d))
2833 + return -EFAULT;
2834 pud = pud_offset(p4d, address);
2835 - BUG_ON(pud_none(*pud));
2836 + if (pud_none(*pud))
2837 + return -EFAULT;
2838 pmd = pmd_offset(pud, address);
2839 if (!pmd_present(*pmd))
2840 return -EFAULT;
2841 @@ -1367,7 +1370,8 @@ static inline pte_t gup_get_pte(pte_t *ptep)
2842 }
2843 #endif
2844
2845 -static void undo_dev_pagemap(int *nr, int nr_start, struct page **pages)
2846 +static void __maybe_unused undo_dev_pagemap(int *nr, int nr_start,
2847 + struct page **pages)
2848 {
2849 while ((*nr) - nr_start) {
2850 struct page *page = pages[--(*nr)];
2851 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
2852 index 72e3fb3bb037..6c94b6865ac2 100644
2853 --- a/mm/kmemleak.c
2854 +++ b/mm/kmemleak.c
2855 @@ -576,7 +576,7 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size,
2856 if (in_irq()) {
2857 object->pid = 0;
2858 strncpy(object->comm, "hardirq", sizeof(object->comm));
2859 - } else if (in_softirq()) {
2860 + } else if (in_serving_softirq()) {
2861 object->pid = 0;
2862 strncpy(object->comm, "softirq", sizeof(object->comm));
2863 } else {
2864 diff --git a/mm/memory.c b/mm/memory.c
2865 index e0010cb870e0..fb5655b518c9 100644
2866 --- a/mm/memory.c
2867 +++ b/mm/memory.c
2868 @@ -4491,7 +4491,9 @@ int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
2869 void *old_buf = buf;
2870 int write = gup_flags & FOLL_WRITE;
2871
2872 - down_read(&mm->mmap_sem);
2873 + if (down_read_killable(&mm->mmap_sem))
2874 + return 0;
2875 +
2876 /* ignore errors, just check how much was successfully transferred */
2877 while (len) {
2878 int bytes, ret, offset;
2879 diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
2880 index 82bb1a939c0e..06dedb175572 100644
2881 --- a/mm/mmu_notifier.c
2882 +++ b/mm/mmu_notifier.c
2883 @@ -316,7 +316,7 @@ static int do_mmu_notifier_register(struct mmu_notifier *mn,
2884 * thanks to mm_take_all_locks().
2885 */
2886 spin_lock(&mm->mmu_notifier_mm->lock);
2887 - hlist_add_head(&mn->hlist, &mm->mmu_notifier_mm->list);
2888 + hlist_add_head_rcu(&mn->hlist, &mm->mmu_notifier_mm->list);
2889 spin_unlock(&mm->mmu_notifier_mm->lock);
2890
2891 mm_drop_all_locks(mm);
2892 diff --git a/mm/nommu.c b/mm/nommu.c
2893 index e4aac33216ae..1d63ecfc98c5 100644
2894 --- a/mm/nommu.c
2895 +++ b/mm/nommu.c
2896 @@ -1779,7 +1779,8 @@ int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
2897 struct vm_area_struct *vma;
2898 int write = gup_flags & FOLL_WRITE;
2899
2900 - down_read(&mm->mmap_sem);
2901 + if (down_read_killable(&mm->mmap_sem))
2902 + return 0;
2903
2904 /* the access must start within one of the target process's mappings */
2905 vma = find_vma(mm, addr);
2906 diff --git a/mm/swap.c b/mm/swap.c
2907 index a3fc028e338e..45fdbfb6b2a6 100644
2908 --- a/mm/swap.c
2909 +++ b/mm/swap.c
2910 @@ -740,15 +740,20 @@ void release_pages(struct page **pages, int nr)
2911 if (is_huge_zero_page(page))
2912 continue;
2913
2914 - /* Device public page can not be huge page */
2915 - if (is_device_public_page(page)) {
2916 + if (is_zone_device_page(page)) {
2917 if (locked_pgdat) {
2918 spin_unlock_irqrestore(&locked_pgdat->lru_lock,
2919 flags);
2920 locked_pgdat = NULL;
2921 }
2922 - put_devmap_managed_page(page);
2923 - continue;
2924 + /*
2925 + * ZONE_DEVICE pages that return 'false' from
2926 + * put_devmap_managed_page() do not require special
2927 + * processing, and instead, expect a call to
2928 + * put_page_testzero().
2929 + */
2930 + if (put_devmap_managed_page(page))
2931 + continue;
2932 }
2933
2934 page = compound_head(page);
2935 diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
2936 index a827547aa102..b131561a9469 100644
2937 --- a/net/vmw_vsock/hyperv_transport.c
2938 +++ b/net/vmw_vsock/hyperv_transport.c
2939 @@ -217,18 +217,6 @@ static void hvs_set_channel_pending_send_size(struct vmbus_channel *chan)
2940 set_channel_pending_send_size(chan,
2941 HVS_PKT_LEN(HVS_SEND_BUF_SIZE));
2942
2943 - /* See hvs_stream_has_space(): we must make sure the host has seen
2944 - * the new pending send size, before we can re-check the writable
2945 - * bytes.
2946 - */
2947 - virt_mb();
2948 -}
2949 -
2950 -static void hvs_clear_channel_pending_send_size(struct vmbus_channel *chan)
2951 -{
2952 - set_channel_pending_send_size(chan, 0);
2953 -
2954 - /* Ditto */
2955 virt_mb();
2956 }
2957
2958 @@ -298,9 +286,6 @@ static void hvs_channel_cb(void *ctx)
2959 if (hvs_channel_readable(chan))
2960 sk->sk_data_ready(sk);
2961
2962 - /* See hvs_stream_has_space(): when we reach here, the writable bytes
2963 - * may be already less than HVS_PKT_LEN(HVS_SEND_BUF_SIZE).
2964 - */
2965 if (hv_get_bytes_to_write(&chan->outbound) > 0)
2966 sk->sk_write_space(sk);
2967 }
2968 @@ -328,8 +313,9 @@ static void hvs_open_connection(struct vmbus_channel *chan)
2969
2970 struct sockaddr_vm addr;
2971 struct sock *sk, *new = NULL;
2972 - struct vsock_sock *vnew;
2973 - struct hvsock *hvs, *hvs_new;
2974 + struct vsock_sock *vnew = NULL;
2975 + struct hvsock *hvs = NULL;
2976 + struct hvsock *hvs_new = NULL;
2977 int ret;
2978
2979 if_type = &chan->offermsg.offer.if_type;
2980 @@ -388,6 +374,13 @@ static void hvs_open_connection(struct vmbus_channel *chan)
2981 set_per_channel_state(chan, conn_from_host ? new : sk);
2982 vmbus_set_chn_rescind_callback(chan, hvs_close_connection);
2983
2984 + /* Set the pending send size to max packet size to always get
2985 + * notifications from the host when there is enough writable space.
2986 + * The host is optimized to send notifications only when the pending
2987 + * size boundary is crossed, and not always.
2988 + */
2989 + hvs_set_channel_pending_send_size(chan);
2990 +
2991 if (conn_from_host) {
2992 new->sk_state = TCP_ESTABLISHED;
2993 sk->sk_ack_backlog++;
2994 @@ -651,23 +644,8 @@ static s64 hvs_stream_has_data(struct vsock_sock *vsk)
2995 static s64 hvs_stream_has_space(struct vsock_sock *vsk)
2996 {
2997 struct hvsock *hvs = vsk->trans;
2998 - struct vmbus_channel *chan = hvs->chan;
2999 - s64 ret;
3000 -
3001 - ret = hvs_channel_writable_bytes(chan);
3002 - if (ret > 0) {
3003 - hvs_clear_channel_pending_send_size(chan);
3004 - } else {
3005 - /* See hvs_channel_cb() */
3006 - hvs_set_channel_pending_send_size(chan);
3007 -
3008 - /* Re-check the writable bytes to avoid race */
3009 - ret = hvs_channel_writable_bytes(chan);
3010 - if (ret > 0)
3011 - hvs_clear_channel_pending_send_size(chan);
3012 - }
3013
3014 - return ret;
3015 + return hvs_channel_writable_bytes(hvs->chan);
3016 }
3017
3018 static u64 hvs_stream_rcvhiwat(struct vsock_sock *vsk)
3019 diff --git a/scripts/genksyms/keywords.c b/scripts/genksyms/keywords.c
3020 index 9f40bcd17d07..f6956aa41366 100644
3021 --- a/scripts/genksyms/keywords.c
3022 +++ b/scripts/genksyms/keywords.c
3023 @@ -24,6 +24,10 @@ static struct resword {
3024 { "__volatile__", VOLATILE_KEYW },
3025 { "__builtin_va_list", VA_LIST_KEYW },
3026
3027 + { "__int128", BUILTIN_INT_KEYW },
3028 + { "__int128_t", BUILTIN_INT_KEYW },
3029 + { "__uint128_t", BUILTIN_INT_KEYW },
3030 +
3031 // According to rth, c99 defines "_Bool", __restrict", __restrict__", "restrict". KAO
3032 { "_Bool", BOOL_KEYW },
3033 { "_restrict", RESTRICT_KEYW },
3034 diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y
3035 index 00a6d7e54971..1ebcf52cd0f9 100644
3036 --- a/scripts/genksyms/parse.y
3037 +++ b/scripts/genksyms/parse.y
3038 @@ -76,6 +76,7 @@ static void record_compound(struct string_list **keyw,
3039 %token ATTRIBUTE_KEYW
3040 %token AUTO_KEYW
3041 %token BOOL_KEYW
3042 +%token BUILTIN_INT_KEYW
3043 %token CHAR_KEYW
3044 %token CONST_KEYW
3045 %token DOUBLE_KEYW
3046 @@ -263,6 +264,7 @@ simple_type_specifier:
3047 | VOID_KEYW
3048 | BOOL_KEYW
3049 | VA_LIST_KEYW
3050 + | BUILTIN_INT_KEYW
3051 | TYPE { (*$1)->tag = SYM_TYPEDEF; $$ = $1; }
3052 ;
3053
3054 diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
3055 index 0c9c54b57515..31ed7f3f0e15 100644
3056 --- a/scripts/kallsyms.c
3057 +++ b/scripts/kallsyms.c
3058 @@ -152,6 +152,9 @@ static int read_symbol(FILE *in, struct sym_entry *s)
3059 /* exclude debugging symbols */
3060 else if (stype == 'N' || stype == 'n')
3061 return -1;
3062 + /* exclude s390 kasan local symbols */
3063 + else if (!strncmp(sym, ".LASANPC", 8))
3064 + return -1;
3065
3066 /* include the type field in the symbol name, so that it gets
3067 * compressed together */
3068 diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
3069 index 2e7793735e14..ccfbfde61556 100644
3070 --- a/scripts/recordmcount.h
3071 +++ b/scripts/recordmcount.h
3072 @@ -326,7 +326,8 @@ static uint_t *sift_rel_mcount(uint_t *mlocp,
3073 if (!mcountsym)
3074 mcountsym = get_mcountsym(sym0, relp, str0);
3075
3076 - if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) {
3077 + if (mcountsym && mcountsym == Elf_r_sym(relp) &&
3078 + !is_fake_mcount(relp)) {
3079 uint_t const addend =
3080 _w(_w(relp->r_offset) - recval + mcount_adjust);
3081 mrelp->r_offset = _w(offbase
3082 diff --git a/sound/ac97/bus.c b/sound/ac97/bus.c
3083 index 9cbf6927abe9..ca50ff444796 100644
3084 --- a/sound/ac97/bus.c
3085 +++ b/sound/ac97/bus.c
3086 @@ -125,17 +125,12 @@ static int ac97_codec_add(struct ac97_controller *ac97_ctrl, int idx,
3087 vendor_id);
3088
3089 ret = device_add(&codec->dev);
3090 - if (ret)
3091 - goto err_free_codec;
3092 + if (ret) {
3093 + put_device(&codec->dev);
3094 + return ret;
3095 + }
3096
3097 return 0;
3098 -err_free_codec:
3099 - of_node_put(codec->dev.of_node);
3100 - put_device(&codec->dev);
3101 - kfree(codec);
3102 - ac97_ctrl->codecs[idx] = NULL;
3103 -
3104 - return ret;
3105 }
3106
3107 unsigned int snd_ac97_bus_scan_one(struct ac97_controller *adrv,
3108 diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
3109 index 3cbd2119e148..b70fbfa80546 100644
3110 --- a/sound/pci/hda/patch_conexant.c
3111 +++ b/sound/pci/hda/patch_conexant.c
3112 @@ -1096,6 +1096,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
3113 */
3114
3115 static const struct hda_device_id snd_hda_id_conexant[] = {
3116 + HDA_CODEC_ENTRY(0x14f11f86, "CX8070", patch_conexant_auto),
3117 HDA_CODEC_ENTRY(0x14f12008, "CX8200", patch_conexant_auto),
3118 HDA_CODEC_ENTRY(0x14f15045, "CX20549 (Venice)", patch_conexant_auto),
3119 HDA_CODEC_ENTRY(0x14f15047, "CX20551 (Waikiki)", patch_conexant_auto),
3120 diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c
3121 index 5f3c87264e66..da627b015b32 100644
3122 --- a/sound/usb/line6/podhd.c
3123 +++ b/sound/usb/line6/podhd.c
3124 @@ -417,7 +417,7 @@ static const struct line6_properties podhd_properties_table[] = {
3125 .name = "POD HD500",
3126 .capabilities = LINE6_CAP_PCM
3127 | LINE6_CAP_HWMON,
3128 - .altsetting = 1,
3129 + .altsetting = 0,
3130 .ep_ctrl_r = 0x81,
3131 .ep_ctrl_w = 0x01,
3132 .ep_audio_r = 0x86,
3133 diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
3134 index 7a6d61c6c012..55272fef3b50 100644
3135 --- a/tools/iio/iio_utils.c
3136 +++ b/tools/iio/iio_utils.c
3137 @@ -159,9 +159,9 @@ int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
3138 *be = (endianchar == 'b');
3139 *bytes = padint / 8;
3140 if (*bits_used == 64)
3141 - *mask = ~0;
3142 + *mask = ~(0ULL);
3143 else
3144 - *mask = (1ULL << *bits_used) - 1;
3145 + *mask = (1ULL << *bits_used) - 1ULL;
3146
3147 *is_signed = (signchar == 's');
3148 if (fclose(sysfsfp)) {
3149 diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
3150 index 40720150ccd8..789962565c9c 100644
3151 --- a/tools/perf/builtin-stat.c
3152 +++ b/tools/perf/builtin-stat.c
3153 @@ -2497,8 +2497,8 @@ static int add_default_attributes(void)
3154 fprintf(stderr,
3155 "Cannot set up top down events %s: %d\n",
3156 str, err);
3157 - free(str);
3158 parse_events_print_error(&errinfo, str);
3159 + free(str);
3160 return -1;
3161 }
3162 } else {
3163 diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
3164 index 33eefc33e0ea..d0733251a386 100644
3165 --- a/tools/perf/builtin-top.c
3166 +++ b/tools/perf/builtin-top.c
3167 @@ -99,7 +99,7 @@ static void perf_top__resize(struct perf_top *top)
3168
3169 static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
3170 {
3171 - struct perf_evsel *evsel = hists_to_evsel(he->hists);
3172 + struct perf_evsel *evsel;
3173 struct symbol *sym;
3174 struct annotation *notes;
3175 struct map *map;
3176 @@ -108,6 +108,8 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
3177 if (!he || !he->ms.sym)
3178 return -1;
3179
3180 + evsel = hists_to_evsel(he->hists);
3181 +
3182 sym = he->ms.sym;
3183 map = he->ms.map;
3184
3185 @@ -224,7 +226,7 @@ static void perf_top__record_precise_ip(struct perf_top *top,
3186 static void perf_top__show_details(struct perf_top *top)
3187 {
3188 struct hist_entry *he = top->sym_filter_entry;
3189 - struct perf_evsel *evsel = hists_to_evsel(he->hists);
3190 + struct perf_evsel *evsel;
3191 struct annotation *notes;
3192 struct symbol *symbol;
3193 int more;
3194 @@ -232,6 +234,8 @@ static void perf_top__show_details(struct perf_top *top)
3195 if (!he)
3196 return;
3197
3198 + evsel = hists_to_evsel(he->hists);
3199 +
3200 symbol = he->ms.sym;
3201 notes = symbol__annotation(symbol);
3202
3203 diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c
3204 index b1af2499a3c9..7a9b123c7bfc 100644
3205 --- a/tools/perf/tests/mmap-thread-lookup.c
3206 +++ b/tools/perf/tests/mmap-thread-lookup.c
3207 @@ -52,7 +52,7 @@ static void *thread_fn(void *arg)
3208 {
3209 struct thread_data *td = arg;
3210 ssize_t ret;
3211 - int go;
3212 + int go = 0;
3213
3214 if (thread_init(td))
3215 return NULL;
3216 diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
3217 index a96f62ca984a..692d2fa31c35 100644
3218 --- a/tools/perf/ui/browsers/hists.c
3219 +++ b/tools/perf/ui/browsers/hists.c
3220 @@ -633,7 +633,11 @@ int hist_browser__run(struct hist_browser *browser, const char *help,
3221 switch (key) {
3222 case K_TIMER: {
3223 u64 nr_entries;
3224 - hbt->timer(hbt->arg);
3225 +
3226 + WARN_ON_ONCE(!hbt);
3227 +
3228 + if (hbt)
3229 + hbt->timer(hbt->arg);
3230
3231 if (hist_browser__has_filter(browser) ||
3232 symbol_conf.report_hierarchy)
3233 @@ -2707,7 +2711,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
3234 {
3235 struct hists *hists = evsel__hists(evsel);
3236 struct hist_browser *browser = perf_evsel_browser__new(evsel, hbt, env, annotation_opts);
3237 - struct branch_info *bi;
3238 + struct branch_info *bi = NULL;
3239 #define MAX_OPTIONS 16
3240 char *options[MAX_OPTIONS];
3241 struct popup_action actions[MAX_OPTIONS];
3242 @@ -2973,7 +2977,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
3243 goto skip_annotation;
3244
3245 if (sort__mode == SORT_MODE__BRANCH) {
3246 - bi = browser->he_selection->branch_info;
3247 +
3248 + if (browser->he_selection)
3249 + bi = browser->he_selection->branch_info;
3250
3251 if (bi == NULL)
3252 goto skip_annotation;
3253 @@ -3144,7 +3150,8 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu,
3254
3255 switch (key) {
3256 case K_TIMER:
3257 - hbt->timer(hbt->arg);
3258 + if (hbt)
3259 + hbt->timer(hbt->arg);
3260
3261 if (!menu->lost_events_warned &&
3262 menu->lost_events &&
3263 diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
3264 index c357051dd2b6..daea1fdf7385 100644
3265 --- a/tools/perf/util/annotate.c
3266 +++ b/tools/perf/util/annotate.c
3267 @@ -1079,16 +1079,14 @@ static int disasm_line__parse(char *line, const char **namep, char **rawp)
3268 *namep = strdup(name);
3269
3270 if (*namep == NULL)
3271 - goto out_free_name;
3272 + goto out;
3273
3274 (*rawp)[0] = tmp;
3275 *rawp = ltrim(*rawp);
3276
3277 return 0;
3278
3279 -out_free_name:
3280 - free((void *)namep);
3281 - *namep = NULL;
3282 +out:
3283 return -1;
3284 }
3285
3286 diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
3287 index 11086097fc9f..f016d1b330e5 100644
3288 --- a/tools/perf/util/session.c
3289 +++ b/tools/perf/util/session.c
3290 @@ -1141,6 +1141,9 @@ static void dump_read(struct perf_evsel *evsel, union perf_event *event)
3291 evsel ? perf_evsel__name(evsel) : "FAIL",
3292 event->read.value);
3293
3294 + if (!evsel)
3295 + return;
3296 +
3297 read_format = evsel->attr.read_format;
3298
3299 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)