Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Tue, 31 Dec 2019 13:56:33
Message-Id: 1577800570.38a3596cbc44155e080a890297511b9b663caf94.mpagano@gentoo
1 commit: 38a3596cbc44155e080a890297511b9b663caf94
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 31 13:56:10 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 31 13:56:10 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=38a3596c
7
8 Linux patch 4.14.161
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1160_linux-4.14.161.patch | 4240 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 4244 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 1266cf6..a19bacd 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -683,6 +683,10 @@ Patch: 1159_linux-4.14.160.patch
21 From: https://www.kernel.org
22 Desc: Linux 4.14.160
23
24 +Patch: 1160_linux-4.14.161.patch
25 +From: https://www.kernel.org
26 +Desc: Linux 4.14.161
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1160_linux-4.14.161.patch b/1160_linux-4.14.161.patch
33 new file mode 100644
34 index 0000000..a74a8d4
35 --- /dev/null
36 +++ b/1160_linux-4.14.161.patch
37 @@ -0,0 +1,4240 @@
38 +diff --git a/Makefile b/Makefile
39 +index f011cb69545f..6b4528888a75 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 4
45 + PATCHLEVEL = 14
46 +-SUBLEVEL = 160
47 ++SUBLEVEL = 161
48 + EXTRAVERSION =
49 + NAME = Petit Gorille
50 +
51 +diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c
52 +index e8edbf13302a..3856d51c645b 100644
53 +--- a/arch/arm64/kernel/psci.c
54 ++++ b/arch/arm64/kernel/psci.c
55 +@@ -84,7 +84,8 @@ static void cpu_psci_cpu_die(unsigned int cpu)
56 +
57 + static int cpu_psci_cpu_kill(unsigned int cpu)
58 + {
59 +- int err, i;
60 ++ int err;
61 ++ unsigned long start, end;
62 +
63 + if (!psci_ops.affinity_info)
64 + return 0;
65 +@@ -94,16 +95,18 @@ static int cpu_psci_cpu_kill(unsigned int cpu)
66 + * while it is dying. So, try again a few times.
67 + */
68 +
69 +- for (i = 0; i < 10; i++) {
70 ++ start = jiffies;
71 ++ end = start + msecs_to_jiffies(100);
72 ++ do {
73 + err = psci_ops.affinity_info(cpu_logical_map(cpu), 0);
74 + if (err == PSCI_0_2_AFFINITY_LEVEL_OFF) {
75 +- pr_info("CPU%d killed.\n", cpu);
76 ++ pr_info("CPU%d killed (polled %d ms)\n", cpu,
77 ++ jiffies_to_msecs(jiffies - start));
78 + return 0;
79 + }
80 +
81 +- msleep(10);
82 +- pr_info("Retrying again to check for CPU kill\n");
83 +- }
84 ++ usleep_range(100, 1000);
85 ++ } while (time_before(jiffies, end));
86 +
87 + pr_warn("CPU%d may not have shut down cleanly (AFFINITY_INFO reports %d)\n",
88 + cpu, err);
89 +diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
90 +index cfbf7bd0dfba..32ae5c9daac4 100644
91 +--- a/arch/arm64/kvm/sys_regs.c
92 ++++ b/arch/arm64/kvm/sys_regs.c
93 +@@ -1785,8 +1785,11 @@ static const struct sys_reg_desc *index_to_sys_reg_desc(struct kvm_vcpu *vcpu,
94 + if ((id & KVM_REG_ARM_COPROC_MASK) != KVM_REG_ARM64_SYSREG)
95 + return NULL;
96 +
97 ++ if (!index_to_params(id, &params))
98 ++ return NULL;
99 ++
100 + table = get_target_table(vcpu->arch.target, true, &num);
101 +- r = find_reg_by_id(id, &params, table, num);
102 ++ r = find_reg(&params, table, num);
103 + if (!r)
104 + r = find_reg(&params, sys_reg_descs, ARRAY_SIZE(sys_reg_descs));
105 +
106 +diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
107 +index a2252c2a9ded..d0b9912fb63f 100644
108 +--- a/arch/mips/include/asm/pgtable-64.h
109 ++++ b/arch/mips/include/asm/pgtable-64.h
110 +@@ -18,10 +18,12 @@
111 + #include <asm/fixmap.h>
112 +
113 + #define __ARCH_USE_5LEVEL_HACK
114 +-#if defined(CONFIG_PAGE_SIZE_64KB) && !defined(CONFIG_MIPS_VA_BITS_48)
115 ++#if CONFIG_PGTABLE_LEVELS == 2
116 + #include <asm-generic/pgtable-nopmd.h>
117 +-#elif !(defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_MIPS_VA_BITS_48))
118 ++#elif CONFIG_PGTABLE_LEVELS == 3
119 + #include <asm-generic/pgtable-nopud.h>
120 ++#else
121 ++#include <asm-generic/5level-fixup.h>
122 + #endif
123 +
124 + /*
125 +@@ -222,6 +224,9 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
126 + return pgd_val(pgd);
127 + }
128 +
129 ++#define pgd_phys(pgd) virt_to_phys((void *)pgd_val(pgd))
130 ++#define pgd_page(pgd) (pfn_to_page(pgd_phys(pgd) >> PAGE_SHIFT))
131 ++
132 + static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
133 + {
134 + return (pud_t *)pgd_page_vaddr(*pgd) + pud_index(address);
135 +diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
136 +index 0ce8b0e5d7ba..207ba53a500b 100644
137 +--- a/arch/powerpc/kernel/irq.c
138 ++++ b/arch/powerpc/kernel/irq.c
139 +@@ -561,8 +561,6 @@ void __do_irq(struct pt_regs *regs)
140 +
141 + trace_irq_entry(regs);
142 +
143 +- check_stack_overflow();
144 +-
145 + /*
146 + * Query the platform PIC for the interrupt & ack it.
147 + *
148 +@@ -594,6 +592,8 @@ void do_IRQ(struct pt_regs *regs)
149 + irqtp = hardirq_ctx[raw_smp_processor_id()];
150 + sirqtp = softirq_ctx[raw_smp_processor_id()];
151 +
152 ++ check_stack_overflow();
153 ++
154 + /* Already there ? */
155 + if (unlikely(curtp == irqtp || curtp == sirqtp)) {
156 + __do_irq(regs);
157 +diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h
158 +index bbe99cb8219d..11857fea993c 100644
159 +--- a/arch/s390/include/asm/pgalloc.h
160 ++++ b/arch/s390/include/asm/pgalloc.h
161 +@@ -70,7 +70,12 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long address)
162 + crst_table_init(table, _REGION2_ENTRY_EMPTY);
163 + return (p4d_t *) table;
164 + }
165 +-#define p4d_free(mm, p4d) crst_table_free(mm, (unsigned long *) p4d)
166 ++
167 ++static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d)
168 ++{
169 ++ if (!mm_p4d_folded(mm))
170 ++ crst_table_free(mm, (unsigned long *) p4d);
171 ++}
172 +
173 + static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address)
174 + {
175 +@@ -79,7 +84,12 @@ static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address)
176 + crst_table_init(table, _REGION3_ENTRY_EMPTY);
177 + return (pud_t *) table;
178 + }
179 +-#define pud_free(mm, pud) crst_table_free(mm, (unsigned long *) pud)
180 ++
181 ++static inline void pud_free(struct mm_struct *mm, pud_t *pud)
182 ++{
183 ++ if (!mm_pud_folded(mm))
184 ++ crst_table_free(mm, (unsigned long *) pud);
185 ++}
186 +
187 + static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr)
188 + {
189 +@@ -97,6 +107,8 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr)
190 +
191 + static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
192 + {
193 ++ if (mm_pmd_folded(mm))
194 ++ return;
195 + pgtable_pmd_page_dtor(virt_to_page(pmd));
196 + crst_table_free(mm, (unsigned long *) pmd);
197 + }
198 +diff --git a/arch/s390/include/asm/timex.h b/arch/s390/include/asm/timex.h
199 +index 64539c221672..2dc9eb4e1acc 100644
200 +--- a/arch/s390/include/asm/timex.h
201 ++++ b/arch/s390/include/asm/timex.h
202 +@@ -10,8 +10,9 @@
203 + #ifndef _ASM_S390_TIMEX_H
204 + #define _ASM_S390_TIMEX_H
205 +
206 +-#include <asm/lowcore.h>
207 ++#include <linux/preempt.h>
208 + #include <linux/time64.h>
209 ++#include <asm/lowcore.h>
210 +
211 + /* The value of the TOD clock for 1.1.1970. */
212 + #define TOD_UNIX_EPOCH 0x7d91048bca000000ULL
213 +@@ -186,15 +187,18 @@ extern unsigned char tod_clock_base[16] __aligned(8);
214 + /**
215 + * get_clock_monotonic - returns current time in clock rate units
216 + *
217 +- * The caller must ensure that preemption is disabled.
218 + * The clock and tod_clock_base get changed via stop_machine.
219 +- * Therefore preemption must be disabled when calling this
220 +- * function, otherwise the returned value is not guaranteed to
221 +- * be monotonic.
222 ++ * Therefore preemption must be disabled, otherwise the returned
223 ++ * value is not guaranteed to be monotonic.
224 + */
225 + static inline unsigned long long get_tod_clock_monotonic(void)
226 + {
227 +- return get_tod_clock() - *(unsigned long long *) &tod_clock_base[1];
228 ++ unsigned long long tod;
229 ++
230 ++ preempt_disable_notrace();
231 ++ tod = get_tod_clock() - *(unsigned long long *) &tod_clock_base[1];
232 ++ preempt_enable_notrace();
233 ++ return tod;
234 + }
235 +
236 + /**
237 +diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
238 +index 2394557653d5..6d154069c962 100644
239 +--- a/arch/s390/kernel/dis.c
240 ++++ b/arch/s390/kernel/dis.c
241 +@@ -1930,10 +1930,11 @@ static int print_insn(char *buffer, unsigned char *code, unsigned long addr)
242 + ptr += sprintf(ptr, "%%c%i", value);
243 + else if (operand->flags & OPERAND_VR)
244 + ptr += sprintf(ptr, "%%v%i", value);
245 +- else if (operand->flags & OPERAND_PCREL)
246 +- ptr += sprintf(ptr, "%lx", (signed int) value
247 +- + addr);
248 +- else if (operand->flags & OPERAND_SIGNED)
249 ++ else if (operand->flags & OPERAND_PCREL) {
250 ++ void *pcrel = (void *)((int)value + addr);
251 ++
252 ++ ptr += sprintf(ptr, "%px", pcrel);
253 ++ } else if (operand->flags & OPERAND_SIGNED)
254 + ptr += sprintf(ptr, "%i", value);
255 + else
256 + ptr += sprintf(ptr, "%u", value);
257 +@@ -2005,7 +2006,7 @@ void show_code(struct pt_regs *regs)
258 + else
259 + *ptr++ = ' ';
260 + addr = regs->psw.addr + start - 32;
261 +- ptr += sprintf(ptr, "%016lx: ", addr);
262 ++ ptr += sprintf(ptr, "%px: ", (void *)addr);
263 + if (start + opsize >= end)
264 + break;
265 + for (i = 0; i < opsize; i++)
266 +@@ -2033,7 +2034,7 @@ void print_fn_code(unsigned char *code, unsigned long len)
267 + opsize = insn_length(*code);
268 + if (opsize > len)
269 + break;
270 +- ptr += sprintf(ptr, "%p: ", code);
271 ++ ptr += sprintf(ptr, "%px: ", code);
272 + for (i = 0; i < opsize; i++)
273 + ptr += sprintf(ptr, "%02x", code[i]);
274 + *ptr++ = '\t';
275 +diff --git a/arch/sh/include/cpu-sh4/cpu/sh7734.h b/arch/sh/include/cpu-sh4/cpu/sh7734.h
276 +index 96f0246ad2f2..82b63208135a 100644
277 +--- a/arch/sh/include/cpu-sh4/cpu/sh7734.h
278 ++++ b/arch/sh/include/cpu-sh4/cpu/sh7734.h
279 +@@ -134,7 +134,7 @@ enum {
280 + GPIO_FN_EX_WAIT1, GPIO_FN_SD1_DAT0_A, GPIO_FN_DREQ2, GPIO_FN_CAN1_TX_C,
281 + GPIO_FN_ET0_LINK_C, GPIO_FN_ET0_ETXD5_A,
282 + GPIO_FN_EX_WAIT0, GPIO_FN_TCLK1_B,
283 +- GPIO_FN_RD_WR, GPIO_FN_TCLK0,
284 ++ GPIO_FN_RD_WR, GPIO_FN_TCLK0, GPIO_FN_CAN_CLK_B, GPIO_FN_ET0_ETXD4,
285 + GPIO_FN_EX_CS5, GPIO_FN_SD1_CMD_A, GPIO_FN_ATADIR, GPIO_FN_QSSL_B,
286 + GPIO_FN_ET0_ETXD3_A,
287 + GPIO_FN_EX_CS4, GPIO_FN_SD1_WP_A, GPIO_FN_ATAWR, GPIO_FN_QMI_QIO1_B,
288 +diff --git a/arch/x86/include/asm/crash.h b/arch/x86/include/asm/crash.h
289 +index a7adb2bfbf0b..6b8ad6fa3979 100644
290 +--- a/arch/x86/include/asm/crash.h
291 ++++ b/arch/x86/include/asm/crash.h
292 +@@ -2,6 +2,8 @@
293 + #ifndef _ASM_X86_CRASH_H
294 + #define _ASM_X86_CRASH_H
295 +
296 ++struct kimage;
297 ++
298 + int crash_load_segments(struct kimage *image);
299 + int crash_copy_backup_region(struct kimage *image);
300 + int crash_setup_memmap_entries(struct kimage *image,
301 +diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
302 +index 6390bd8c141b..5e12b2319d7a 100644
303 +--- a/arch/x86/include/asm/fixmap.h
304 ++++ b/arch/x86/include/asm/fixmap.h
305 +@@ -159,7 +159,7 @@ extern pte_t *kmap_pte;
306 + extern pte_t *pkmap_page_table;
307 +
308 + void __native_set_fixmap(enum fixed_addresses idx, pte_t pte);
309 +-void native_set_fixmap(enum fixed_addresses idx,
310 ++void native_set_fixmap(unsigned /* enum fixed_addresses */ idx,
311 + phys_addr_t phys, pgprot_t flags);
312 +
313 + #ifndef CONFIG_PARAVIRT
314 +diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
315 +index 566b7bc5deaa..2271adbc3c42 100644
316 +--- a/arch/x86/kernel/apic/io_apic.c
317 ++++ b/arch/x86/kernel/apic/io_apic.c
318 +@@ -1690,9 +1690,10 @@ static bool io_apic_level_ack_pending(struct mp_chip_data *data)
319 +
320 + static inline bool ioapic_irqd_mask(struct irq_data *data)
321 + {
322 +- /* If we are moving the irq we need to mask it */
323 ++ /* If we are moving the IRQ we need to mask it */
324 + if (unlikely(irqd_is_setaffinity_pending(data))) {
325 +- mask_ioapic_irq(data);
326 ++ if (!irqd_irq_masked(data))
327 ++ mask_ioapic_irq(data);
328 + return true;
329 + }
330 + return false;
331 +@@ -1729,7 +1730,9 @@ static inline void ioapic_irqd_unmask(struct irq_data *data, bool masked)
332 + */
333 + if (!io_apic_level_ack_pending(data->chip_data))
334 + irq_move_masked_irq(data);
335 +- unmask_ioapic_irq(data);
336 ++ /* If the IRQ is masked in the core, leave it: */
337 ++ if (!irqd_irq_masked(data))
338 ++ unmask_ioapic_irq(data);
339 + }
340 + }
341 + #else
342 +diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
343 +index b434780ae680..a8f47697276b 100644
344 +--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
345 ++++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
346 +@@ -228,10 +228,10 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
347 + }
348 +
349 + /* Return early if this bank was already initialized. */
350 +- if (smca_banks[bank].hwid)
351 ++ if (smca_banks[bank].hwid && smca_banks[bank].hwid->hwid_mcatype != 0)
352 + return;
353 +
354 +- if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
355 ++ if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) {
356 + pr_warn("Failed to read MCA_IPID for bank %d\n", bank);
357 + return;
358 + }
359 +diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
360 +index ee229ceee745..ec6a07b04fdb 100644
361 +--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
362 ++++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
363 +@@ -185,7 +185,7 @@ static void therm_throt_process(bool new_event, int event, int level)
364 + /* if we just entered the thermal event */
365 + if (new_event) {
366 + if (event == THERMAL_THROTTLING_EVENT)
367 +- pr_crit("CPU%d: %s temperature above threshold, cpu clock throttled (total events = %lu)\n",
368 ++ pr_warn("CPU%d: %s temperature above threshold, cpu clock throttled (total events = %lu)\n",
369 + this_cpu,
370 + level == CORE_LEVEL ? "Core" : "Package",
371 + state->count);
372 +diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt
373 +index e0b85930dd77..0a0e9112f284 100644
374 +--- a/arch/x86/lib/x86-opcode-map.txt
375 ++++ b/arch/x86/lib/x86-opcode-map.txt
376 +@@ -333,7 +333,7 @@ AVXcode: 1
377 + 06: CLTS
378 + 07: SYSRET (o64)
379 + 08: INVD
380 +-09: WBINVD
381 ++09: WBINVD | WBNOINVD (F3)
382 + 0a:
383 + 0b: UD2 (1B)
384 + 0c:
385 +@@ -364,7 +364,7 @@ AVXcode: 1
386 + # a ModR/M byte.
387 + 1a: BNDCL Gv,Ev (F3) | BNDCU Gv,Ev (F2) | BNDMOV Gv,Ev (66) | BNDLDX Gv,Ev
388 + 1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv
389 +-1c:
390 ++1c: Grp20 (1A),(1C)
391 + 1d:
392 + 1e:
393 + 1f: NOP Ev
394 +@@ -792,6 +792,8 @@ f3: Grp17 (1A)
395 + f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v)
396 + f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v)
397 + f7: BEXTR Gy,Ey,By (v) | SHLX Gy,Ey,By (66),(v) | SARX Gy,Ey,By (F3),(v) | SHRX Gy,Ey,By (F2),(v)
398 ++f8: MOVDIR64B Gv,Mdqq (66) | ENQCMD Gv,Mdqq (F2) | ENQCMDS Gv,Mdqq (F3)
399 ++f9: MOVDIRI My,Gy
400 + EndTable
401 +
402 + Table: 3-byte opcode 2 (0x0f 0x3a)
403 +@@ -943,9 +945,9 @@ GrpTable: Grp6
404 + EndTable
405 +
406 + GrpTable: Grp7
407 +-0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B)
408 +-1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B)
409 +-2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B)
410 ++0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B) | PCONFIG (101),(11B) | ENCLV (000),(11B)
411 ++1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B) | ENCLS (111),(11B)
412 ++2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B) | ENCLU (111),(11B)
413 + 3: LIDT Ms
414 + 4: SMSW Mw/Rv
415 + 5: rdpkru (110),(11B) | wrpkru (111),(11B)
416 +@@ -1020,7 +1022,7 @@ GrpTable: Grp15
417 + 3: vstmxcsr Md (v1) | WRGSBASE Ry (F3),(11B)
418 + 4: XSAVE | ptwrite Ey (F3),(11B)
419 + 5: XRSTOR | lfence (11B)
420 +-6: XSAVEOPT | clwb (66) | mfence (11B)
421 ++6: XSAVEOPT | clwb (66) | mfence (11B) | TPAUSE Rd (66),(11B) | UMONITOR Rv (F3),(11B) | UMWAIT Rd (F2),(11B)
422 + 7: clflush | clflushopt (66) | sfence (11B)
423 + EndTable
424 +
425 +@@ -1051,6 +1053,10 @@ GrpTable: Grp19
426 + 6: vscatterpf1qps/d Wx (66),(ev)
427 + EndTable
428 +
429 ++GrpTable: Grp20
430 ++0: cldemote Mb
431 ++EndTable
432 ++
433 + # AMD's Prefetch Group
434 + GrpTable: GrpP
435 + 0: PREFETCH
436 +diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
437 +index b4fd36271f90..55338b392221 100644
438 +--- a/arch/x86/mm/pgtable.c
439 ++++ b/arch/x86/mm/pgtable.c
440 +@@ -590,8 +590,8 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
441 + fixmaps_set++;
442 + }
443 +
444 +-void native_set_fixmap(enum fixed_addresses idx, phys_addr_t phys,
445 +- pgprot_t flags)
446 ++void native_set_fixmap(unsigned /* enum fixed_addresses */ idx,
447 ++ phys_addr_t phys, pgprot_t flags)
448 + {
449 + __native_set_fixmap(idx, pfn_pte(phys >> PAGE_SHIFT, flags));
450 + }
451 +diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
452 +index cbb162b683b6..08f67c109429 100644
453 +--- a/drivers/ata/libata-core.c
454 ++++ b/drivers/ata/libata-core.c
455 +@@ -6676,6 +6676,9 @@ void ata_host_detach(struct ata_host *host)
456 + {
457 + int i;
458 +
459 ++ /* Ensure ata_port probe has completed */
460 ++ async_synchronize_full();
461 ++
462 + for (i = 0; i < host->n_ports; i++)
463 + ata_port_detach(host->ports[i]);
464 +
465 +diff --git a/drivers/block/loop.c b/drivers/block/loop.c
466 +index ec61dd873c93..453e3728e657 100644
467 +--- a/drivers/block/loop.c
468 ++++ b/drivers/block/loop.c
469 +@@ -414,18 +414,20 @@ out_free_page:
470 + return ret;
471 + }
472 +
473 +-static int lo_discard(struct loop_device *lo, struct request *rq, loff_t pos)
474 ++static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos,
475 ++ int mode)
476 + {
477 + /*
478 +- * We use punch hole to reclaim the free space used by the
479 +- * image a.k.a. discard. However we do not support discard if
480 +- * encryption is enabled, because it may give an attacker
481 +- * useful information.
482 ++ * We use fallocate to manipulate the space mappings used by the image
483 ++ * a.k.a. discard/zerorange. However we do not support this if
484 ++ * encryption is enabled, because it may give an attacker useful
485 ++ * information.
486 + */
487 + struct file *file = lo->lo_backing_file;
488 +- int mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
489 + int ret;
490 +
491 ++ mode |= FALLOC_FL_KEEP_SIZE;
492 ++
493 + if ((!file->f_op->fallocate) || lo->lo_encrypt_key_size) {
494 + ret = -EOPNOTSUPP;
495 + goto out;
496 +@@ -565,9 +567,17 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
497 + switch (req_op(rq)) {
498 + case REQ_OP_FLUSH:
499 + return lo_req_flush(lo, rq);
500 +- case REQ_OP_DISCARD:
501 + case REQ_OP_WRITE_ZEROES:
502 +- return lo_discard(lo, rq, pos);
503 ++ /*
504 ++ * If the caller doesn't want deallocation, call zeroout to
505 ++ * write zeroes the range. Otherwise, punch them out.
506 ++ */
507 ++ return lo_fallocate(lo, rq, pos,
508 ++ (rq->cmd_flags & REQ_NOUNMAP) ?
509 ++ FALLOC_FL_ZERO_RANGE :
510 ++ FALLOC_FL_PUNCH_HOLE);
511 ++ case REQ_OP_DISCARD:
512 ++ return lo_fallocate(lo, rq, pos, FALLOC_FL_PUNCH_HOLE);
513 + case REQ_OP_WRITE:
514 + if (lo->transfer)
515 + return lo_write_transfer(lo, rq, pos);
516 +diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
517 +index 929bd255a290..4c661ad91e7d 100644
518 +--- a/drivers/block/nbd.c
519 ++++ b/drivers/block/nbd.c
520 +@@ -1234,10 +1234,10 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
521 + mutex_unlock(&nbd->config_lock);
522 + ret = wait_event_interruptible(config->recv_wq,
523 + atomic_read(&config->recv_threads) == 0);
524 +- if (ret) {
525 ++ if (ret)
526 + sock_shutdown(nbd);
527 +- flush_workqueue(nbd->recv_workq);
528 +- }
529 ++ flush_workqueue(nbd->recv_workq);
530 ++
531 + mutex_lock(&nbd->config_lock);
532 + bd_set_size(bdev, 0);
533 + /* user requested, ignore socket errors */
534 +diff --git a/drivers/char/hw_random/omap3-rom-rng.c b/drivers/char/hw_random/omap3-rom-rng.c
535 +index 38b719017186..648e39ce6bd9 100644
536 +--- a/drivers/char/hw_random/omap3-rom-rng.c
537 ++++ b/drivers/char/hw_random/omap3-rom-rng.c
538 +@@ -121,7 +121,8 @@ static int omap3_rom_rng_remove(struct platform_device *pdev)
539 + {
540 + cancel_delayed_work_sync(&idle_work);
541 + hwrng_unregister(&omap3_rom_rng_ops);
542 +- clk_disable_unprepare(rng_clk);
543 ++ if (!rng_idle)
544 ++ clk_disable_unprepare(rng_clk);
545 + return 0;
546 + }
547 +
548 +diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
549 +index 480e8c13567c..c798a1233e6a 100644
550 +--- a/drivers/cpufreq/cpufreq.c
551 ++++ b/drivers/cpufreq/cpufreq.c
552 +@@ -2475,6 +2475,13 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
553 + if (cpufreq_disabled())
554 + return -ENODEV;
555 +
556 ++ /*
557 ++ * The cpufreq core depends heavily on the availability of device
558 ++ * structure, make sure they are available before proceeding further.
559 ++ */
560 ++ if (!get_cpu_device(0))
561 ++ return -EPROBE_DEFER;
562 ++
563 + if (!driver_data || !driver_data->verify || !driver_data->init ||
564 + !(driver_data->setpolicy || driver_data->target_index ||
565 + driver_data->target) ||
566 +diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
567 +index 5cf64746731a..22e491857925 100644
568 +--- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
569 ++++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
570 +@@ -81,7 +81,8 @@ static int sun4i_ss_opti_poll(struct skcipher_request *areq)
571 + oi = 0;
572 + oo = 0;
573 + do {
574 +- todo = min3(rx_cnt, ileft, (mi.length - oi) / 4);
575 ++ todo = min(rx_cnt, ileft);
576 ++ todo = min_t(size_t, todo, (mi.length - oi) / 4);
577 + if (todo) {
578 + ileft -= todo;
579 + writesl(ss->base + SS_RXFIFO, mi.addr + oi, todo);
580 +@@ -96,7 +97,8 @@ static int sun4i_ss_opti_poll(struct skcipher_request *areq)
581 + rx_cnt = SS_RXFIFO_SPACES(spaces);
582 + tx_cnt = SS_TXFIFO_SPACES(spaces);
583 +
584 +- todo = min3(tx_cnt, oleft, (mo.length - oo) / 4);
585 ++ todo = min(tx_cnt, oleft);
586 ++ todo = min_t(size_t, todo, (mo.length - oo) / 4);
587 + if (todo) {
588 + oleft -= todo;
589 + readsl(ss->base + SS_TXFIFO, mo.addr + oo, todo);
590 +@@ -220,7 +222,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
591 + * todo is the number of consecutive 4byte word that we
592 + * can read from current SG
593 + */
594 +- todo = min3(rx_cnt, ileft / 4, (mi.length - oi) / 4);
595 ++ todo = min(rx_cnt, ileft / 4);
596 ++ todo = min_t(size_t, todo, (mi.length - oi) / 4);
597 + if (todo && !ob) {
598 + writesl(ss->base + SS_RXFIFO, mi.addr + oi,
599 + todo);
600 +@@ -234,8 +237,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
601 + * we need to be able to write all buf in one
602 + * pass, so it is why we min() with rx_cnt
603 + */
604 +- todo = min3(rx_cnt * 4 - ob, ileft,
605 +- mi.length - oi);
606 ++ todo = min(rx_cnt * 4 - ob, ileft);
607 ++ todo = min_t(size_t, todo, mi.length - oi);
608 + memcpy(buf + ob, mi.addr + oi, todo);
609 + ileft -= todo;
610 + oi += todo;
611 +@@ -255,7 +258,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
612 + spaces = readl(ss->base + SS_FCSR);
613 + rx_cnt = SS_RXFIFO_SPACES(spaces);
614 + tx_cnt = SS_TXFIFO_SPACES(spaces);
615 +- dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
616 ++ dev_dbg(ss->dev,
617 ++ "%x %u/%zu %u/%u cnt=%u %u/%zu %u/%u cnt=%u %u\n",
618 + mode,
619 + oi, mi.length, ileft, areq->cryptlen, rx_cnt,
620 + oo, mo.length, oleft, areq->cryptlen, tx_cnt, ob);
621 +@@ -263,7 +267,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
622 + if (!tx_cnt)
623 + continue;
624 + /* todo in 4bytes word */
625 +- todo = min3(tx_cnt, oleft / 4, (mo.length - oo) / 4);
626 ++ todo = min(tx_cnt, oleft / 4);
627 ++ todo = min_t(size_t, todo, (mo.length - oo) / 4);
628 + if (todo) {
629 + readsl(ss->base + SS_TXFIFO, mo.addr + oo, todo);
630 + oleft -= todo * 4;
631 +@@ -287,7 +292,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
632 + * no more than remaining buffer
633 + * no need to test against oleft
634 + */
635 +- todo = min(mo.length - oo, obl - obo);
636 ++ todo = min_t(size_t,
637 ++ mo.length - oo, obl - obo);
638 + memcpy(mo.addr + oo, bufo + obo, todo);
639 + oleft -= todo;
640 + obo += todo;
641 +diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
642 +index f6936bb3b7be..1a724263761b 100644
643 +--- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
644 ++++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
645 +@@ -276,8 +276,8 @@ static int sun4i_hash(struct ahash_request *areq)
646 + */
647 + while (op->len < 64 && i < end) {
648 + /* how many bytes we can read from current SG */
649 +- in_r = min3(mi.length - in_i, end - i,
650 +- 64 - op->len);
651 ++ in_r = min(end - i, 64 - op->len);
652 ++ in_r = min_t(size_t, mi.length - in_i, in_r);
653 + memcpy(op->buf + op->len, mi.addr + in_i, in_r);
654 + op->len += in_r;
655 + i += in_r;
656 +@@ -297,8 +297,8 @@ static int sun4i_hash(struct ahash_request *areq)
657 + }
658 + if (mi.length - in_i > 3 && i < end) {
659 + /* how many bytes we can read from current SG */
660 +- in_r = min3(mi.length - in_i, areq->nbytes - i,
661 +- ((mi.length - in_i) / 4) * 4);
662 ++ in_r = min_t(size_t, mi.length - in_i, areq->nbytes - i);
663 ++ in_r = min_t(size_t, ((mi.length - in_i) / 4) * 4, in_r);
664 + /* how many bytes we can write in the device*/
665 + todo = min3((u32)(end - i) / 4, rx_cnt, (u32)in_r / 4);
666 + writesl(ss->base + SS_RXFIFO, mi.addr + in_i, todo);
667 +@@ -324,8 +324,8 @@ static int sun4i_hash(struct ahash_request *areq)
668 + if ((areq->nbytes - i) < 64) {
669 + while (i < areq->nbytes && in_i < mi.length && op->len < 64) {
670 + /* how many bytes we can read from current SG */
671 +- in_r = min3(mi.length - in_i, areq->nbytes - i,
672 +- 64 - op->len);
673 ++ in_r = min(areq->nbytes - i, 64 - op->len);
674 ++ in_r = min_t(size_t, mi.length - in_i, in_r);
675 + memcpy(op->buf + op->len, mi.addr + in_i, in_r);
676 + op->len += in_r;
677 + i += in_r;
678 +diff --git a/drivers/crypto/virtio/virtio_crypto_algs.c b/drivers/crypto/virtio/virtio_crypto_algs.c
679 +index 5035b0dc1e40..e2231a1a05a1 100644
680 +--- a/drivers/crypto/virtio/virtio_crypto_algs.c
681 ++++ b/drivers/crypto/virtio/virtio_crypto_algs.c
682 +@@ -110,8 +110,6 @@ virtio_crypto_alg_validate_key(int key_len, uint32_t *alg)
683 + *alg = VIRTIO_CRYPTO_CIPHER_AES_CBC;
684 + break;
685 + default:
686 +- pr_err("virtio_crypto: Unsupported key length: %d\n",
687 +- key_len);
688 + return -EINVAL;
689 + }
690 + return 0;
691 +@@ -485,6 +483,11 @@ static int virtio_crypto_ablkcipher_encrypt(struct ablkcipher_request *req)
692 + /* Use the first data virtqueue as default */
693 + struct data_queue *data_vq = &vcrypto->data_vq[0];
694 +
695 ++ if (!req->nbytes)
696 ++ return 0;
697 ++ if (req->nbytes % AES_BLOCK_SIZE)
698 ++ return -EINVAL;
699 ++
700 + vc_req->dataq = data_vq;
701 + vc_req->alg_cb = virtio_crypto_dataq_sym_callback;
702 + vc_sym_req->ablkcipher_ctx = ctx;
703 +@@ -505,6 +508,11 @@ static int virtio_crypto_ablkcipher_decrypt(struct ablkcipher_request *req)
704 + /* Use the first data virtqueue as default */
705 + struct data_queue *data_vq = &vcrypto->data_vq[0];
706 +
707 ++ if (!req->nbytes)
708 ++ return 0;
709 ++ if (req->nbytes % AES_BLOCK_SIZE)
710 ++ return -EINVAL;
711 ++
712 + vc_req->dataq = data_vq;
713 + vc_req->alg_cb = virtio_crypto_dataq_sym_callback;
714 + vc_sym_req->ablkcipher_ctx = ctx;
715 +diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
716 +index cab32cfec9c4..709670d2b553 100644
717 +--- a/drivers/crypto/vmx/Makefile
718 ++++ b/drivers/crypto/vmx/Makefile
719 +@@ -3,13 +3,13 @@ obj-$(CONFIG_CRYPTO_DEV_VMX_ENCRYPT) += vmx-crypto.o
720 + vmx-crypto-objs := vmx.o aesp8-ppc.o ghashp8-ppc.o aes.o aes_cbc.o aes_ctr.o aes_xts.o ghash.o
721 +
722 + ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
723 +-TARGET := linux-ppc64le
724 ++override flavour := linux-ppc64le
725 + else
726 +-TARGET := linux-ppc64
727 ++override flavour := linux-ppc64
728 + endif
729 +
730 + quiet_cmd_perl = PERL $@
731 +- cmd_perl = $(PERL) $(<) $(TARGET) > $(@)
732 ++ cmd_perl = $(PERL) $(<) $(flavour) > $(@)
733 +
734 + targets += aesp8-ppc.S ghashp8-ppc.S
735 +
736 +diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
737 +index 6f80eb65c26c..acae39278669 100644
738 +--- a/drivers/edac/ghes_edac.c
739 ++++ b/drivers/edac/ghes_edac.c
740 +@@ -187,6 +187,7 @@ void ghes_edac_report_mem_error(struct ghes *ghes, int sev,
741 + /* Cleans the error report buffer */
742 + memset(e, 0, sizeof (*e));
743 + e->error_count = 1;
744 ++ e->grain = 1;
745 + strcpy(e->label, "unknown label");
746 + e->msg = pvt->msg;
747 + e->other_detail = pvt->other_detail;
748 +@@ -282,7 +283,7 @@ void ghes_edac_report_mem_error(struct ghes *ghes, int sev,
749 +
750 + /* Error grain */
751 + if (mem_err->validation_bits & CPER_MEM_VALID_PA_MASK)
752 +- e->grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK);
753 ++ e->grain = ~mem_err->physical_addr_mask + 1;
754 +
755 + /* Memory error location, mapped on e->location */
756 + p = e->location;
757 +@@ -389,8 +390,13 @@ void ghes_edac_report_mem_error(struct ghes *ghes, int sev,
758 + if (p > pvt->other_detail)
759 + *(p - 1) = '\0';
760 +
761 ++ /* Sanity-check driver-supplied grain value. */
762 ++ if (WARN_ON_ONCE(!e->grain))
763 ++ e->grain = 1;
764 ++
765 ++ grain_bits = fls_long(e->grain - 1);
766 ++
767 + /* Generate the trace event */
768 +- grain_bits = fls_long(e->grain);
769 + snprintf(pvt->detail_location, sizeof(pvt->detail_location),
770 + "APEI location: %s %s", e->location, e->other_detail);
771 + trace_mc_event(type, e->msg, e->label, e->error_count,
772 +diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c
773 +index 106ef0297b53..1a1ee3db3455 100644
774 +--- a/drivers/extcon/extcon-sm5502.c
775 ++++ b/drivers/extcon/extcon-sm5502.c
776 +@@ -69,6 +69,10 @@ struct sm5502_muic_info {
777 + /* Default value of SM5502 register to bring up MUIC device. */
778 + static struct reg_data sm5502_reg_data[] = {
779 + {
780 ++ .reg = SM5502_REG_RESET,
781 ++ .val = SM5502_REG_RESET_MASK,
782 ++ .invert = true,
783 ++ }, {
784 + .reg = SM5502_REG_CONTROL,
785 + .val = SM5502_REG_CONTROL_MASK_INT_MASK,
786 + .invert = false,
787 +diff --git a/drivers/extcon/extcon-sm5502.h b/drivers/extcon/extcon-sm5502.h
788 +index 974b53222f56..12f8b01e5753 100644
789 +--- a/drivers/extcon/extcon-sm5502.h
790 ++++ b/drivers/extcon/extcon-sm5502.h
791 +@@ -241,6 +241,8 @@ enum sm5502_reg {
792 + #define DM_DP_SWITCH_UART ((DM_DP_CON_SWITCH_UART <<SM5502_REG_MANUAL_SW1_DP_SHIFT) \
793 + | (DM_DP_CON_SWITCH_UART <<SM5502_REG_MANUAL_SW1_DM_SHIFT))
794 +
795 ++#define SM5502_REG_RESET_MASK (0x1)
796 ++
797 + /* SM5502 Interrupts */
798 + enum sm5502_irq {
799 + /* INT1 */
800 +diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
801 +index 4ea63d9bd131..8feca59c1f6b 100644
802 +--- a/drivers/fsi/fsi-core.c
803 ++++ b/drivers/fsi/fsi-core.c
804 +@@ -419,6 +419,31 @@ static int fsi_slave_scan(struct fsi_slave *slave)
805 + return 0;
806 + }
807 +
808 ++static unsigned long aligned_access_size(size_t offset, size_t count)
809 ++{
810 ++ unsigned long offset_unit, count_unit;
811 ++
812 ++ /* Criteria:
813 ++ *
814 ++ * 1. Access size must be less than or equal to the maximum access
815 ++ * width or the highest power-of-two factor of offset
816 ++ * 2. Access size must be less than or equal to the amount specified by
817 ++ * count
818 ++ *
819 ++ * The access width is optimal if we can calculate 1 to be strictly
820 ++ * equal while still satisfying 2.
821 ++ */
822 ++
823 ++ /* Find 1 by the bottom bit of offset (with a 4 byte access cap) */
824 ++ offset_unit = BIT(__builtin_ctzl(offset | 4));
825 ++
826 ++ /* Find 2 by the top bit of count */
827 ++ count_unit = BIT(8 * sizeof(unsigned long) - 1 - __builtin_clzl(count));
828 ++
829 ++ /* Constrain the maximum access width to the minimum of both criteria */
830 ++ return BIT(__builtin_ctzl(offset_unit | count_unit));
831 ++}
832 ++
833 + static ssize_t fsi_slave_sysfs_raw_read(struct file *file,
834 + struct kobject *kobj, struct bin_attribute *attr, char *buf,
835 + loff_t off, size_t count)
836 +@@ -434,8 +459,7 @@ static ssize_t fsi_slave_sysfs_raw_read(struct file *file,
837 + return -EINVAL;
838 +
839 + for (total_len = 0; total_len < count; total_len += read_len) {
840 +- read_len = min_t(size_t, count, 4);
841 +- read_len -= off & 0x3;
842 ++ read_len = aligned_access_size(off, count - total_len);
843 +
844 + rc = fsi_slave_read(slave, off, buf + total_len, read_len);
845 + if (rc)
846 +@@ -462,8 +486,7 @@ static ssize_t fsi_slave_sysfs_raw_write(struct file *file,
847 + return -EINVAL;
848 +
849 + for (total_len = 0; total_len < count; total_len += write_len) {
850 +- write_len = min_t(size_t, count, 4);
851 +- write_len -= off & 0x3;
852 ++ write_len = aligned_access_size(off, count - total_len);
853 +
854 + rc = fsi_slave_write(slave, off, buf + total_len, write_len);
855 + if (rc)
856 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
857 +index ed8c3739015b..b35b0741fd97 100644
858 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
859 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
860 +@@ -125,6 +125,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
861 + }
862 +
863 + dma_fence_put(fence);
864 ++ fence = NULL;
865 +
866 + r = amdgpu_bo_kmap(vram_obj, &vram_map);
867 + if (r) {
868 +@@ -170,6 +171,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
869 + }
870 +
871 + dma_fence_put(fence);
872 ++ fence = NULL;
873 +
874 + r = amdgpu_bo_kmap(gtt_obj[i], &gtt_map);
875 + if (r) {
876 +diff --git a/drivers/gpu/drm/bridge/analogix-anx78xx.c b/drivers/gpu/drm/bridge/analogix-anx78xx.c
877 +index 9385eb0b1ee4..cd2bfd7bf048 100644
878 +--- a/drivers/gpu/drm/bridge/analogix-anx78xx.c
879 ++++ b/drivers/gpu/drm/bridge/analogix-anx78xx.c
880 +@@ -725,7 +725,9 @@ static int anx78xx_init_pdata(struct anx78xx *anx78xx)
881 + /* 1.0V digital core power regulator */
882 + pdata->dvdd10 = devm_regulator_get(dev, "dvdd10");
883 + if (IS_ERR(pdata->dvdd10)) {
884 +- DRM_ERROR("DVDD10 regulator not found\n");
885 ++ if (PTR_ERR(pdata->dvdd10) != -EPROBE_DEFER)
886 ++ DRM_ERROR("DVDD10 regulator not found\n");
887 ++
888 + return PTR_ERR(pdata->dvdd10);
889 + }
890 +
891 +@@ -1344,7 +1346,9 @@ static int anx78xx_i2c_probe(struct i2c_client *client,
892 +
893 + err = anx78xx_init_pdata(anx78xx);
894 + if (err) {
895 +- DRM_ERROR("Failed to initialize pdata: %d\n", err);
896 ++ if (err != -EPROBE_DEFER)
897 ++ DRM_ERROR("Failed to initialize pdata: %d\n", err);
898 ++
899 + return err;
900 + }
901 +
902 +diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
903 +index 4db31b89507c..cc1094f90125 100644
904 +--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
905 ++++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
906 +@@ -39,6 +39,7 @@
907 +
908 + #include <media/cec-notifier.h>
909 +
910 ++#define DDC_CI_ADDR 0x37
911 + #define DDC_SEGMENT_ADDR 0x30
912 +
913 + #define HDMI_EDID_LEN 512
914 +@@ -320,6 +321,15 @@ static int dw_hdmi_i2c_xfer(struct i2c_adapter *adap,
915 + u8 addr = msgs[0].addr;
916 + int i, ret = 0;
917 +
918 ++ if (addr == DDC_CI_ADDR)
919 ++ /*
920 ++ * The internal I2C controller does not support the multi-byte
921 ++ * read and write operations needed for DDC/CI.
922 ++ * TOFIX: Blacklist the DDC/CI address until we filter out
923 ++ * unsupported I2C operations.
924 ++ */
925 ++ return -EOPNOTSUPP;
926 ++
927 + dev_dbg(hdmi->dev, "xfer: num: %d, addr: %#x\n", num, addr);
928 +
929 + for (i = 0; i < num; i++) {
930 +@@ -1733,7 +1743,7 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode)
931 +
932 + /* HDMI Initialization Step E - Configure audio */
933 + hdmi_clk_regenerator_update_pixel_clock(hdmi);
934 +- hdmi_enable_audio_clk(hdmi, true);
935 ++ hdmi_enable_audio_clk(hdmi, hdmi->audio_enable);
936 + }
937 +
938 + /* not for DVI mode */
939 +diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
940 +index 0fff269d3fe6..42785f3df60f 100644
941 +--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
942 ++++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
943 +@@ -139,6 +139,7 @@ static bool mrst_sdvo_find_best_pll(const struct gma_limit_t *limit,
944 + s32 freq_error, min_error = 100000;
945 +
946 + memset(best_clock, 0, sizeof(*best_clock));
947 ++ memset(&clock, 0, sizeof(clock));
948 +
949 + for (clock.m = limit->m.min; clock.m <= limit->m.max; clock.m++) {
950 + for (clock.n = limit->n.min; clock.n <= limit->n.max;
951 +@@ -195,6 +196,7 @@ static bool mrst_lvds_find_best_pll(const struct gma_limit_t *limit,
952 + int err = target;
953 +
954 + memset(best_clock, 0, sizeof(*best_clock));
955 ++ memset(&clock, 0, sizeof(clock));
956 +
957 + for (clock.m = limit->m.min; clock.m <= limit->m.max; clock.m++) {
958 + for (clock.p1 = limit->p1.min; clock.p1 <= limit->p1.max;
959 +diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c
960 +index acd99783bbca..67f3c050c4cf 100644
961 +--- a/drivers/gpu/host1x/job.c
962 ++++ b/drivers/gpu/host1x/job.c
963 +@@ -545,7 +545,8 @@ out:
964 + return err;
965 + }
966 +
967 +-static inline int copy_gathers(struct host1x_job *job, struct device *dev)
968 ++static inline int copy_gathers(struct device *host, struct host1x_job *job,
969 ++ struct device *dev)
970 + {
971 + struct host1x_firewall fw;
972 + size_t size = 0;
973 +@@ -570,12 +571,12 @@ static inline int copy_gathers(struct host1x_job *job, struct device *dev)
974 + * Try a non-blocking allocation from a higher priority pools first,
975 + * as awaiting for the allocation here is a major performance hit.
976 + */
977 +- job->gather_copy_mapped = dma_alloc_wc(dev, size, &job->gather_copy,
978 ++ job->gather_copy_mapped = dma_alloc_wc(host, size, &job->gather_copy,
979 + GFP_NOWAIT);
980 +
981 + /* the higher priority allocation failed, try the generic-blocking */
982 + if (!job->gather_copy_mapped)
983 +- job->gather_copy_mapped = dma_alloc_wc(dev, size,
984 ++ job->gather_copy_mapped = dma_alloc_wc(host, size,
985 + &job->gather_copy,
986 + GFP_KERNEL);
987 + if (!job->gather_copy_mapped)
988 +@@ -636,7 +637,7 @@ int host1x_job_pin(struct host1x_job *job, struct device *dev)
989 + goto out;
990 +
991 + if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) {
992 +- err = copy_gathers(job, dev);
993 ++ err = copy_gathers(host->dev, job, dev);
994 + if (err)
995 + goto out;
996 + }
997 +@@ -701,7 +702,7 @@ void host1x_job_unpin(struct host1x_job *job)
998 + job->num_unpins = 0;
999 +
1000 + if (job->gather_copy_size)
1001 +- dma_free_wc(job->channel->dev, job->gather_copy_size,
1002 ++ dma_free_wc(host->dev, job->gather_copy_size,
1003 + job->gather_copy_mapped, job->gather_copy);
1004 + }
1005 + EXPORT_SYMBOL(host1x_job_unpin);
1006 +diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
1007 +index c224b92a80f1..fc371444407d 100644
1008 +--- a/drivers/hwtracing/intel_th/pci.c
1009 ++++ b/drivers/hwtracing/intel_th/pci.c
1010 +@@ -188,6 +188,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
1011 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x06a6),
1012 + .driver_data = (kernel_ulong_t)&intel_th_2x,
1013 + },
1014 ++ {
1015 ++ /* Comet Lake PCH-V */
1016 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa3a6),
1017 ++ .driver_data = (kernel_ulong_t)&intel_th_2x,
1018 ++ },
1019 + {
1020 + /* Ice Lake NNPI */
1021 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x45c5),
1022 +@@ -213,6 +218,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
1023 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4da6),
1024 + .driver_data = (kernel_ulong_t)&intel_th_2x,
1025 + },
1026 ++ {
1027 ++ /* Elkhart Lake */
1028 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4b26),
1029 ++ .driver_data = (kernel_ulong_t)&intel_th_2x,
1030 ++ },
1031 + { 0 },
1032 + };
1033 +
1034 +diff --git a/drivers/iio/adc/dln2-adc.c b/drivers/iio/adc/dln2-adc.c
1035 +index ab8d6aed5085..2a299bbd6acf 100644
1036 +--- a/drivers/iio/adc/dln2-adc.c
1037 ++++ b/drivers/iio/adc/dln2-adc.c
1038 +@@ -528,6 +528,10 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
1039 + u16 conflict;
1040 + unsigned int trigger_chan;
1041 +
1042 ++ ret = iio_triggered_buffer_postenable(indio_dev);
1043 ++ if (ret)
1044 ++ return ret;
1045 ++
1046 + mutex_lock(&dln2->mutex);
1047 +
1048 + /* Enable ADC */
1049 +@@ -541,6 +545,7 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
1050 + (int)conflict);
1051 + ret = -EBUSY;
1052 + }
1053 ++ iio_triggered_buffer_predisable(indio_dev);
1054 + return ret;
1055 + }
1056 +
1057 +@@ -554,6 +559,7 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
1058 + mutex_unlock(&dln2->mutex);
1059 + if (ret < 0) {
1060 + dev_dbg(&dln2->pdev->dev, "Problem in %s\n", __func__);
1061 ++ iio_triggered_buffer_predisable(indio_dev);
1062 + return ret;
1063 + }
1064 + } else {
1065 +@@ -561,12 +567,12 @@ static int dln2_adc_triggered_buffer_postenable(struct iio_dev *indio_dev)
1066 + mutex_unlock(&dln2->mutex);
1067 + }
1068 +
1069 +- return iio_triggered_buffer_postenable(indio_dev);
1070 ++ return 0;
1071 + }
1072 +
1073 + static int dln2_adc_triggered_buffer_predisable(struct iio_dev *indio_dev)
1074 + {
1075 +- int ret;
1076 ++ int ret, ret2;
1077 + struct dln2_adc *dln2 = iio_priv(indio_dev);
1078 +
1079 + mutex_lock(&dln2->mutex);
1080 +@@ -581,12 +587,14 @@ static int dln2_adc_triggered_buffer_predisable(struct iio_dev *indio_dev)
1081 + ret = dln2_adc_set_port_enabled(dln2, false, NULL);
1082 +
1083 + mutex_unlock(&dln2->mutex);
1084 +- if (ret < 0) {
1085 ++ if (ret < 0)
1086 + dev_dbg(&dln2->pdev->dev, "Problem in %s\n", __func__);
1087 +- return ret;
1088 +- }
1089 +
1090 +- return iio_triggered_buffer_predisable(indio_dev);
1091 ++ ret2 = iio_triggered_buffer_predisable(indio_dev);
1092 ++ if (ret == 0)
1093 ++ ret = ret2;
1094 ++
1095 ++ return ret;
1096 + }
1097 +
1098 + static const struct iio_buffer_setup_ops dln2_adc_buffer_setup_ops = {
1099 +diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
1100 +index ebc715927e63..03af02769370 100644
1101 +--- a/drivers/iio/adc/max1027.c
1102 ++++ b/drivers/iio/adc/max1027.c
1103 +@@ -462,6 +462,14 @@ static int max1027_probe(struct spi_device *spi)
1104 + goto fail_dev_register;
1105 + }
1106 +
1107 ++ /* Internal reset */
1108 ++ st->reg = MAX1027_RST_REG;
1109 ++ ret = spi_write(st->spi, &st->reg, 1);
1110 ++ if (ret < 0) {
1111 ++ dev_err(&indio_dev->dev, "Failed to reset the ADC\n");
1112 ++ return ret;
1113 ++ }
1114 ++
1115 + /* Disable averaging */
1116 + st->reg = MAX1027_AVG_REG;
1117 + ret = spi_write(st->spi, &st->reg, 1);
1118 +diff --git a/drivers/iio/light/bh1750.c b/drivers/iio/light/bh1750.c
1119 +index 6c61187e630f..0b7ba02c8d16 100644
1120 +--- a/drivers/iio/light/bh1750.c
1121 ++++ b/drivers/iio/light/bh1750.c
1122 +@@ -62,9 +62,9 @@ struct bh1750_chip_info {
1123 +
1124 + u16 int_time_low_mask;
1125 + u16 int_time_high_mask;
1126 +-}
1127 ++};
1128 +
1129 +-static const bh1750_chip_info_tbl[] = {
1130 ++static const struct bh1750_chip_info bh1750_chip_info_tbl[] = {
1131 + [BH1710] = { 140, 1022, 300, 400, 250000000, 2, 0x001F, 0x03E0 },
1132 + [BH1721] = { 140, 1020, 300, 400, 250000000, 2, 0x0010, 0x03E0 },
1133 + [BH1750] = { 31, 254, 69, 1740, 57500000, 1, 0x001F, 0x00E0 },
1134 +diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
1135 +index 7f4cc9336442..656e7c1a4449 100644
1136 +--- a/drivers/infiniband/hw/qedr/verbs.c
1137 ++++ b/drivers/infiniband/hw/qedr/verbs.c
1138 +@@ -1343,6 +1343,14 @@ static void qedr_cleanup_user(struct qedr_dev *dev, struct qedr_qp *qp)
1139 + if (qp->urq.umem)
1140 + ib_umem_release(qp->urq.umem);
1141 + qp->urq.umem = NULL;
1142 ++
1143 ++ if (rdma_protocol_roce(&dev->ibdev, 1)) {
1144 ++ qedr_free_pbl(dev, &qp->usq.pbl_info, qp->usq.pbl_tbl);
1145 ++ qedr_free_pbl(dev, &qp->urq.pbl_info, qp->urq.pbl_tbl);
1146 ++ } else {
1147 ++ kfree(qp->usq.pbl_tbl);
1148 ++ kfree(qp->urq.pbl_tbl);
1149 ++ }
1150 + }
1151 +
1152 + static int qedr_create_user_qp(struct qedr_dev *dev,
1153 +@@ -2331,8 +2339,8 @@ int qedr_dereg_mr(struct ib_mr *ib_mr)
1154 +
1155 + dev->ops->rdma_free_tid(dev->rdma_ctx, mr->hw_mr.itid);
1156 +
1157 +- if ((mr->type != QEDR_MR_DMA) && (mr->type != QEDR_MR_FRMR))
1158 +- qedr_free_pbl(dev, &mr->info.pbl_info, mr->info.pbl_table);
1159 ++ if (mr->type != QEDR_MR_DMA)
1160 ++ free_mr_info(dev, &mr->info);
1161 +
1162 + /* it could be user registered memory. */
1163 + if (mr->umem)
1164 +diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
1165 +index 19624e023ebd..b5a789567b4e 100644
1166 +--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
1167 ++++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
1168 +@@ -648,6 +648,7 @@ iscsi_iser_session_create(struct iscsi_endpoint *ep,
1169 + if (ib_conn->pi_support) {
1170 + u32 sig_caps = ib_conn->device->ib_device->attrs.sig_prot_cap;
1171 +
1172 ++ shost->sg_prot_tablesize = shost->sg_tablesize;
1173 + scsi_host_set_prot(shost, iser_dif_prot_caps(sig_caps));
1174 + scsi_host_set_guard(shost, SHOST_DIX_GUARD_IP |
1175 + SHOST_DIX_GUARD_CRC);
1176 +diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
1177 +index ce23f436e130..44b0584eb8a6 100644
1178 +--- a/drivers/media/i2c/ov2659.c
1179 ++++ b/drivers/media/i2c/ov2659.c
1180 +@@ -419,10 +419,14 @@ static struct sensor_register ov2659_720p[] = {
1181 + { REG_TIMING_YINC, 0x11 },
1182 + { REG_TIMING_VERT_FORMAT, 0x80 },
1183 + { REG_TIMING_HORIZ_FORMAT, 0x00 },
1184 ++ { 0x370a, 0x12 },
1185 + { 0x3a03, 0xe8 },
1186 + { 0x3a09, 0x6f },
1187 + { 0x3a0b, 0x5d },
1188 + { 0x3a15, 0x9a },
1189 ++ { REG_VFIFO_READ_START_H, 0x00 },
1190 ++ { REG_VFIFO_READ_START_L, 0x80 },
1191 ++ { REG_ISP_CTRL02, 0x00 },
1192 + { REG_NULL, 0x00 },
1193 + };
1194 +
1195 +@@ -1203,11 +1207,15 @@ static int ov2659_s_stream(struct v4l2_subdev *sd, int on)
1196 + goto unlock;
1197 + }
1198 +
1199 +- ov2659_set_pixel_clock(ov2659);
1200 +- ov2659_set_frame_size(ov2659);
1201 +- ov2659_set_format(ov2659);
1202 +- ov2659_set_streaming(ov2659, 1);
1203 +- ov2659->streaming = on;
1204 ++ ret = ov2659_set_pixel_clock(ov2659);
1205 ++ if (!ret)
1206 ++ ret = ov2659_set_frame_size(ov2659);
1207 ++ if (!ret)
1208 ++ ret = ov2659_set_format(ov2659);
1209 ++ if (!ret) {
1210 ++ ov2659_set_streaming(ov2659, 1);
1211 ++ ov2659->streaming = on;
1212 ++ }
1213 +
1214 + unlock:
1215 + mutex_unlock(&ov2659->lock);
1216 +diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
1217 +index 025869eec2ac..348296be4925 100644
1218 +--- a/drivers/media/i2c/ov6650.c
1219 ++++ b/drivers/media/i2c/ov6650.c
1220 +@@ -469,38 +469,39 @@ static int ov6650_set_selection(struct v4l2_subdev *sd,
1221 + {
1222 + struct i2c_client *client = v4l2_get_subdevdata(sd);
1223 + struct ov6650 *priv = to_ov6650(client);
1224 +- struct v4l2_rect rect = sel->r;
1225 + int ret;
1226 +
1227 + if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE ||
1228 + sel->target != V4L2_SEL_TGT_CROP)
1229 + return -EINVAL;
1230 +
1231 +- v4l_bound_align_image(&rect.width, 2, W_CIF, 1,
1232 +- &rect.height, 2, H_CIF, 1, 0);
1233 +- v4l_bound_align_image(&rect.left, DEF_HSTRT << 1,
1234 +- (DEF_HSTRT << 1) + W_CIF - (__s32)rect.width, 1,
1235 +- &rect.top, DEF_VSTRT << 1,
1236 +- (DEF_VSTRT << 1) + H_CIF - (__s32)rect.height, 1,
1237 +- 0);
1238 ++ v4l_bound_align_image(&sel->r.width, 2, W_CIF, 1,
1239 ++ &sel->r.height, 2, H_CIF, 1, 0);
1240 ++ v4l_bound_align_image(&sel->r.left, DEF_HSTRT << 1,
1241 ++ (DEF_HSTRT << 1) + W_CIF - (__s32)sel->r.width, 1,
1242 ++ &sel->r.top, DEF_VSTRT << 1,
1243 ++ (DEF_VSTRT << 1) + H_CIF - (__s32)sel->r.height,
1244 ++ 1, 0);
1245 +
1246 +- ret = ov6650_reg_write(client, REG_HSTRT, rect.left >> 1);
1247 ++ ret = ov6650_reg_write(client, REG_HSTRT, sel->r.left >> 1);
1248 + if (!ret) {
1249 +- priv->rect.left = rect.left;
1250 ++ priv->rect.width += priv->rect.left - sel->r.left;
1251 ++ priv->rect.left = sel->r.left;
1252 + ret = ov6650_reg_write(client, REG_HSTOP,
1253 +- (rect.left + rect.width) >> 1);
1254 ++ (sel->r.left + sel->r.width) >> 1);
1255 + }
1256 + if (!ret) {
1257 +- priv->rect.width = rect.width;
1258 +- ret = ov6650_reg_write(client, REG_VSTRT, rect.top >> 1);
1259 ++ priv->rect.width = sel->r.width;
1260 ++ ret = ov6650_reg_write(client, REG_VSTRT, sel->r.top >> 1);
1261 + }
1262 + if (!ret) {
1263 +- priv->rect.top = rect.top;
1264 ++ priv->rect.height += priv->rect.top - sel->r.top;
1265 ++ priv->rect.top = sel->r.top;
1266 + ret = ov6650_reg_write(client, REG_VSTOP,
1267 +- (rect.top + rect.height) >> 1);
1268 ++ (sel->r.top + sel->r.height) >> 1);
1269 + }
1270 + if (!ret)
1271 +- priv->rect.height = rect.height;
1272 ++ priv->rect.height = sel->r.height;
1273 +
1274 + return ret;
1275 + }
1276 +@@ -614,7 +615,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1277 + dev_err(&client->dev, "Pixel format not handled: 0x%x\n", code);
1278 + return -EINVAL;
1279 + }
1280 +- priv->code = code;
1281 +
1282 + if (code == MEDIA_BUS_FMT_Y8_1X8 ||
1283 + code == MEDIA_BUS_FMT_SBGGR8_1X8) {
1284 +@@ -640,7 +640,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1285 + dev_dbg(&client->dev, "max resolution: CIF\n");
1286 + coma_mask |= COMA_QCIF;
1287 + }
1288 +- priv->half_scale = half_scale;
1289 +
1290 + clkrc = CLKRC_12MHz;
1291 + mclk = 12000000;
1292 +@@ -658,8 +657,13 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
1293 + ret = ov6650_reg_rmw(client, REG_COMA, coma_set, coma_mask);
1294 + if (!ret)
1295 + ret = ov6650_reg_write(client, REG_CLKRC, clkrc);
1296 +- if (!ret)
1297 ++ if (!ret) {
1298 ++ priv->half_scale = half_scale;
1299 ++
1300 + ret = ov6650_reg_rmw(client, REG_COML, coml_set, coml_mask);
1301 ++ }
1302 ++ if (!ret)
1303 ++ priv->code = code;
1304 +
1305 + if (!ret) {
1306 + mf->colorspace = priv->colorspace;
1307 +diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
1308 +index 7d25ecd4404b..1748812bd7e5 100644
1309 +--- a/drivers/media/pci/cx88/cx88-video.c
1310 ++++ b/drivers/media/pci/cx88/cx88-video.c
1311 +@@ -1310,7 +1310,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1312 + core = cx88_core_get(dev->pci);
1313 + if (!core) {
1314 + err = -EINVAL;
1315 +- goto fail_free;
1316 ++ goto fail_disable;
1317 + }
1318 + dev->core = core;
1319 +
1320 +@@ -1356,7 +1356,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1321 + cc->step, cc->default_value);
1322 + if (!vc) {
1323 + err = core->audio_hdl.error;
1324 +- goto fail_core;
1325 ++ goto fail_irq;
1326 + }
1327 + vc->priv = (void *)cc;
1328 + }
1329 +@@ -1370,7 +1370,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1330 + cc->step, cc->default_value);
1331 + if (!vc) {
1332 + err = core->video_hdl.error;
1333 +- goto fail_core;
1334 ++ goto fail_irq;
1335 + }
1336 + vc->priv = (void *)cc;
1337 + if (vc->id == V4L2_CID_CHROMA_AGC)
1338 +@@ -1533,11 +1533,14 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1339 +
1340 + fail_unreg:
1341 + cx8800_unregister_video(dev);
1342 +- free_irq(pci_dev->irq, dev);
1343 + mutex_unlock(&core->lock);
1344 ++fail_irq:
1345 ++ free_irq(pci_dev->irq, dev);
1346 + fail_core:
1347 + core->v4ldev = NULL;
1348 + cx88_core_put(core, dev->pci);
1349 ++fail_disable:
1350 ++ pci_disable_device(pci_dev);
1351 + fail_free:
1352 + kfree(dev);
1353 + return err;
1354 +diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
1355 +index dfcc484cab89..e92c5b56be42 100644
1356 +--- a/drivers/media/platform/am437x/am437x-vpfe.c
1357 ++++ b/drivers/media/platform/am437x/am437x-vpfe.c
1358 +@@ -1848,6 +1848,10 @@ static int vpfe_s_std(struct file *file, void *priv, v4l2_std_id std_id)
1359 + if (!(sdinfo->inputs[0].capabilities & V4L2_IN_CAP_STD))
1360 + return -ENODATA;
1361 +
1362 ++ /* if trying to set the same std then nothing to do */
1363 ++ if (vpfe_standards[vpfe->std_index].std_id == std_id)
1364 ++ return 0;
1365 ++
1366 + /* If streaming is started, return error */
1367 + if (vb2_is_busy(&vpfe->buffer_queue)) {
1368 + vpfe_err(vpfe, "%s device busy\n", __func__);
1369 +diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
1370 +index 769e9e68562d..9360b36b82cd 100644
1371 +--- a/drivers/media/platform/qcom/venus/core.c
1372 ++++ b/drivers/media/platform/qcom/venus/core.c
1373 +@@ -345,10 +345,11 @@ static const struct venus_resources msm8916_res = {
1374 + };
1375 +
1376 + static const struct freq_tbl msm8996_freq_table[] = {
1377 +- { 1944000, 490000000 }, /* 4k UHD @ 60 */
1378 +- { 972000, 320000000 }, /* 4k UHD @ 30 */
1379 +- { 489600, 150000000 }, /* 1080p @ 60 */
1380 +- { 244800, 75000000 }, /* 1080p @ 30 */
1381 ++ { 1944000, 520000000 }, /* 4k UHD @ 60 (decode only) */
1382 ++ { 972000, 520000000 }, /* 4k UHD @ 30 */
1383 ++ { 489600, 346666667 }, /* 1080p @ 60 */
1384 ++ { 244800, 150000000 }, /* 1080p @ 30 */
1385 ++ { 108000, 75000000 }, /* 720p @ 30 */
1386 + };
1387 +
1388 + static const struct reg_val msm8996_reg_preset[] = {
1389 +diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
1390 +index 522364ff0d5d..3871ed6a1fcb 100644
1391 +--- a/drivers/media/platform/rcar_drif.c
1392 ++++ b/drivers/media/platform/rcar_drif.c
1393 +@@ -915,6 +915,7 @@ static int rcar_drif_g_fmt_sdr_cap(struct file *file, void *priv,
1394 + {
1395 + struct rcar_drif_sdr *sdr = video_drvdata(file);
1396 +
1397 ++ memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
1398 + f->fmt.sdr.pixelformat = sdr->fmt->pixelformat;
1399 + f->fmt.sdr.buffersize = sdr->fmt->buffersize;
1400 +
1401 +diff --git a/drivers/media/platform/ti-vpe/vpdma.h b/drivers/media/platform/ti-vpe/vpdma.h
1402 +index 7e611501c291..f29074c84915 100644
1403 +--- a/drivers/media/platform/ti-vpe/vpdma.h
1404 ++++ b/drivers/media/platform/ti-vpe/vpdma.h
1405 +@@ -60,6 +60,7 @@ struct vpdma_data_format {
1406 + * line stride of source and dest
1407 + * buffers should be 16 byte aligned
1408 + */
1409 ++#define VPDMA_MAX_STRIDE 65520 /* Max line stride 16 byte aligned */
1410 + #define VPDMA_DTD_DESC_SIZE 32 /* 8 words */
1411 + #define VPDMA_CFD_CTD_DESC_SIZE 16 /* 4 words */
1412 +
1413 +diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
1414 +index 45bd10544189..2e8970c7e22d 100644
1415 +--- a/drivers/media/platform/ti-vpe/vpe.c
1416 ++++ b/drivers/media/platform/ti-vpe/vpe.c
1417 +@@ -352,20 +352,25 @@ enum {
1418 + };
1419 +
1420 + /* find our format description corresponding to the passed v4l2_format */
1421 +-static struct vpe_fmt *find_format(struct v4l2_format *f)
1422 ++static struct vpe_fmt *__find_format(u32 fourcc)
1423 + {
1424 + struct vpe_fmt *fmt;
1425 + unsigned int k;
1426 +
1427 + for (k = 0; k < ARRAY_SIZE(vpe_formats); k++) {
1428 + fmt = &vpe_formats[k];
1429 +- if (fmt->fourcc == f->fmt.pix.pixelformat)
1430 ++ if (fmt->fourcc == fourcc)
1431 + return fmt;
1432 + }
1433 +
1434 + return NULL;
1435 + }
1436 +
1437 ++static struct vpe_fmt *find_format(struct v4l2_format *f)
1438 ++{
1439 ++ return __find_format(f->fmt.pix.pixelformat);
1440 ++}
1441 ++
1442 + /*
1443 + * there is one vpe_dev structure in the driver, it is shared by
1444 + * all instances.
1445 +@@ -1044,11 +1049,14 @@ static void add_out_dtd(struct vpe_ctx *ctx, int port)
1446 + dma_addr_t dma_addr;
1447 + u32 flags = 0;
1448 + u32 offset = 0;
1449 ++ u32 stride;
1450 +
1451 + if (port == VPE_PORT_MV_OUT) {
1452 + vpdma_fmt = &vpdma_misc_fmts[VPDMA_DATA_FMT_MV];
1453 + dma_addr = ctx->mv_buf_dma[mv_buf_selector];
1454 + q_data = &ctx->q_data[Q_DATA_SRC];
1455 ++ stride = ALIGN((q_data->width * vpdma_fmt->depth) >> 3,
1456 ++ VPDMA_STRIDE_ALIGN);
1457 + } else {
1458 + /* to incorporate interleaved formats */
1459 + int plane = fmt->coplanar ? p_data->vb_part : 0;
1460 +@@ -1075,6 +1083,7 @@ static void add_out_dtd(struct vpe_ctx *ctx, int port)
1461 + }
1462 + /* Apply the offset */
1463 + dma_addr += offset;
1464 ++ stride = q_data->bytesperline[VPE_LUMA];
1465 + }
1466 +
1467 + if (q_data->flags & Q_DATA_FRAME_1D)
1468 +@@ -1086,7 +1095,7 @@ static void add_out_dtd(struct vpe_ctx *ctx, int port)
1469 + MAX_W, MAX_H);
1470 +
1471 + vpdma_add_out_dtd(&ctx->desc_list, q_data->width,
1472 +- q_data->bytesperline[VPE_LUMA], &q_data->c_rect,
1473 ++ stride, &q_data->c_rect,
1474 + vpdma_fmt, dma_addr, MAX_OUT_WIDTH_REG1,
1475 + MAX_OUT_HEIGHT_REG1, p_data->channel, flags);
1476 + }
1477 +@@ -1105,10 +1114,13 @@ static void add_in_dtd(struct vpe_ctx *ctx, int port)
1478 + dma_addr_t dma_addr;
1479 + u32 flags = 0;
1480 + u32 offset = 0;
1481 ++ u32 stride;
1482 +
1483 + if (port == VPE_PORT_MV_IN) {
1484 + vpdma_fmt = &vpdma_misc_fmts[VPDMA_DATA_FMT_MV];
1485 + dma_addr = ctx->mv_buf_dma[mv_buf_selector];
1486 ++ stride = ALIGN((q_data->width * vpdma_fmt->depth) >> 3,
1487 ++ VPDMA_STRIDE_ALIGN);
1488 + } else {
1489 + /* to incorporate interleaved formats */
1490 + int plane = fmt->coplanar ? p_data->vb_part : 0;
1491 +@@ -1135,6 +1147,7 @@ static void add_in_dtd(struct vpe_ctx *ctx, int port)
1492 + }
1493 + /* Apply the offset */
1494 + dma_addr += offset;
1495 ++ stride = q_data->bytesperline[VPE_LUMA];
1496 +
1497 + if (q_data->flags & Q_DATA_INTERLACED_SEQ_TB) {
1498 + /*
1499 +@@ -1170,10 +1183,10 @@ static void add_in_dtd(struct vpe_ctx *ctx, int port)
1500 + if (p_data->vb_part && fmt->fourcc == V4L2_PIX_FMT_NV12)
1501 + frame_height /= 2;
1502 +
1503 +- vpdma_add_in_dtd(&ctx->desc_list, q_data->width,
1504 +- q_data->bytesperline[VPE_LUMA], &q_data->c_rect,
1505 +- vpdma_fmt, dma_addr, p_data->channel, field, flags, frame_width,
1506 +- frame_height, 0, 0);
1507 ++ vpdma_add_in_dtd(&ctx->desc_list, q_data->width, stride,
1508 ++ &q_data->c_rect, vpdma_fmt, dma_addr,
1509 ++ p_data->channel, field, flags, frame_width,
1510 ++ frame_height, 0, 0);
1511 + }
1512 +
1513 + /*
1514 +@@ -1422,9 +1435,6 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1515 + /* the previous dst mv buffer becomes the next src mv buffer */
1516 + ctx->src_mv_buf_selector = !ctx->src_mv_buf_selector;
1517 +
1518 +- if (ctx->aborting)
1519 +- goto finished;
1520 +-
1521 + s_vb = ctx->src_vbs[0];
1522 + d_vb = ctx->dst_vb;
1523 +
1524 +@@ -1435,6 +1445,7 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1525 + d_vb->timecode = s_vb->timecode;
1526 +
1527 + d_vb->sequence = ctx->sequence;
1528 ++ s_vb->sequence = ctx->sequence;
1529 +
1530 + d_q_data = &ctx->q_data[Q_DATA_DST];
1531 + if (d_q_data->flags & Q_IS_INTERLACED) {
1532 +@@ -1488,6 +1499,9 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1533 + ctx->src_vbs[0] = NULL;
1534 + ctx->dst_vb = NULL;
1535 +
1536 ++ if (ctx->aborting)
1537 ++ goto finished;
1538 ++
1539 + ctx->bufs_completed++;
1540 + if (ctx->bufs_completed < ctx->bufs_per_job && job_ready(ctx)) {
1541 + device_run(ctx);
1542 +@@ -1600,9 +1614,9 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
1543 + unsigned int stride = 0;
1544 +
1545 + if (!fmt || !(fmt->types & type)) {
1546 +- vpe_err(ctx->dev, "Fourcc format (0x%08x) invalid.\n",
1547 ++ vpe_dbg(ctx->dev, "Fourcc format (0x%08x) invalid.\n",
1548 + pix->pixelformat);
1549 +- return -EINVAL;
1550 ++ fmt = __find_format(V4L2_PIX_FMT_YUYV);
1551 + }
1552 +
1553 + if (pix->field != V4L2_FIELD_NONE && pix->field != V4L2_FIELD_ALTERNATE
1554 +@@ -1649,7 +1663,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
1555 + &pix->height, MIN_H, MAX_H, H_ALIGN,
1556 + S_ALIGN);
1557 +
1558 +- if (!pix->num_planes)
1559 ++ if (!pix->num_planes || pix->num_planes > 2)
1560 + pix->num_planes = fmt->coplanar ? 2 : 1;
1561 + else if (pix->num_planes > 1 && !fmt->coplanar)
1562 + pix->num_planes = 1;
1563 +@@ -1688,6 +1702,10 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
1564 + if (stride > plane_fmt->bytesperline)
1565 + plane_fmt->bytesperline = stride;
1566 +
1567 ++ plane_fmt->bytesperline = clamp_t(u32, plane_fmt->bytesperline,
1568 ++ stride,
1569 ++ VPDMA_MAX_STRIDE);
1570 ++
1571 + plane_fmt->bytesperline = ALIGN(plane_fmt->bytesperline,
1572 + VPDMA_STRIDE_ALIGN);
1573 +
1574 +@@ -2308,7 +2326,7 @@ static int vpe_open(struct file *file)
1575 + v4l2_ctrl_handler_setup(hdl);
1576 +
1577 + s_q_data = &ctx->q_data[Q_DATA_SRC];
1578 +- s_q_data->fmt = &vpe_formats[2];
1579 ++ s_q_data->fmt = __find_format(V4L2_PIX_FMT_YUYV);
1580 + s_q_data->width = 1920;
1581 + s_q_data->height = 1080;
1582 + s_q_data->nplanes = 1;
1583 +@@ -2386,6 +2404,12 @@ static int vpe_release(struct file *file)
1584 +
1585 + mutex_lock(&dev->dev_mutex);
1586 + free_mv_buffers(ctx);
1587 ++
1588 ++ vpdma_unmap_desc_buf(dev->vpdma, &ctx->desc_list.buf);
1589 ++ vpdma_unmap_desc_buf(dev->vpdma, &ctx->mmr_adb);
1590 ++ vpdma_unmap_desc_buf(dev->vpdma, &ctx->sc_coeff_h);
1591 ++ vpdma_unmap_desc_buf(dev->vpdma, &ctx->sc_coeff_v);
1592 ++
1593 + vpdma_free_desc_list(&ctx->desc_list);
1594 + vpdma_free_desc_buf(&ctx->mmr_adb);
1595 +
1596 +diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
1597 +index 8ce6f9cff746..b60fb6ed5aeb 100644
1598 +--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
1599 ++++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
1600 +@@ -455,6 +455,8 @@ static int si470x_i2c_remove(struct i2c_client *client)
1601 + video_unregister_device(&radio->videodev);
1602 + kfree(radio);
1603 +
1604 ++ v4l2_ctrl_handler_free(&radio->hdl);
1605 ++ v4l2_device_unregister(&radio->v4l2_dev);
1606 + return 0;
1607 + }
1608 +
1609 +diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c
1610 +index ac4fddfd0a43..f1807c16438d 100644
1611 +--- a/drivers/media/usb/b2c2/flexcop-usb.c
1612 ++++ b/drivers/media/usb/b2c2/flexcop-usb.c
1613 +@@ -503,7 +503,13 @@ urb_error:
1614 + static int flexcop_usb_init(struct flexcop_usb *fc_usb)
1615 + {
1616 + /* use the alternate setting with the larges buffer */
1617 +- usb_set_interface(fc_usb->udev,0,1);
1618 ++ int ret = usb_set_interface(fc_usb->udev, 0, 1);
1619 ++
1620 ++ if (ret) {
1621 ++ err("set interface failed.");
1622 ++ return ret;
1623 ++ }
1624 ++
1625 + switch (fc_usb->udev->speed) {
1626 + case USB_SPEED_LOW:
1627 + err("cannot handle USB speed because it is too slow.");
1628 +diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
1629 +index 4320bda9352d..e0413db26781 100644
1630 +--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
1631 ++++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
1632 +@@ -915,8 +915,12 @@ static void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
1633 + pvr2_v4l2_dev_disassociate_parent(vp->dev_video);
1634 + pvr2_v4l2_dev_disassociate_parent(vp->dev_radio);
1635 + if (!list_empty(&vp->dev_video->devbase.fh_list) ||
1636 +- !list_empty(&vp->dev_radio->devbase.fh_list))
1637 ++ (vp->dev_radio &&
1638 ++ !list_empty(&vp->dev_radio->devbase.fh_list))) {
1639 ++ pvr2_trace(PVR2_TRACE_STRUCT,
1640 ++ "pvr2_v4l2 internal_check exit-empty id=%p", vp);
1641 + return;
1642 ++ }
1643 + pvr2_v4l2_destroy_no_lock(vp);
1644 + }
1645 +
1646 +@@ -990,7 +994,8 @@ static int pvr2_v4l2_release(struct file *file)
1647 + kfree(fhp);
1648 + if (vp->channel.mc_head->disconnect_flag &&
1649 + list_empty(&vp->dev_video->devbase.fh_list) &&
1650 +- list_empty(&vp->dev_radio->devbase.fh_list)) {
1651 ++ (!vp->dev_radio ||
1652 ++ list_empty(&vp->dev_radio->devbase.fh_list))) {
1653 + pvr2_v4l2_destroy_no_lock(vp);
1654 + }
1655 + return 0;
1656 +diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
1657 +index 681eef972e63..7cafc8a57950 100644
1658 +--- a/drivers/media/v4l2-core/v4l2-ioctl.c
1659 ++++ b/drivers/media/v4l2-core/v4l2-ioctl.c
1660 +@@ -1363,10 +1363,26 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
1661 + return ret;
1662 + }
1663 +
1664 ++static void v4l_pix_format_touch(struct v4l2_pix_format *p)
1665 ++{
1666 ++ /*
1667 ++ * The v4l2_pix_format structure contains fields that make no sense for
1668 ++ * touch. Set them to default values in this case.
1669 ++ */
1670 ++
1671 ++ p->field = V4L2_FIELD_NONE;
1672 ++ p->colorspace = V4L2_COLORSPACE_RAW;
1673 ++ p->flags = 0;
1674 ++ p->ycbcr_enc = 0;
1675 ++ p->quantization = 0;
1676 ++ p->xfer_func = 0;
1677 ++}
1678 ++
1679 + static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
1680 + struct file *file, void *fh, void *arg)
1681 + {
1682 + struct v4l2_format *p = arg;
1683 ++ struct video_device *vfd = video_devdata(file);
1684 + int ret = check_fmt(file, p->type);
1685 +
1686 + if (ret)
1687 +@@ -1404,6 +1420,8 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
1688 + ret = ops->vidioc_g_fmt_vid_cap(file, fh, arg);
1689 + /* just in case the driver zeroed it again */
1690 + p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
1691 ++ if (vfd->vfl_type == VFL_TYPE_TOUCH)
1692 ++ v4l_pix_format_touch(&p->fmt.pix);
1693 + return ret;
1694 + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
1695 + return ops->vidioc_g_fmt_vid_cap_mplane(file, fh, arg);
1696 +@@ -1439,21 +1457,6 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
1697 + return -EINVAL;
1698 + }
1699 +
1700 +-static void v4l_pix_format_touch(struct v4l2_pix_format *p)
1701 +-{
1702 +- /*
1703 +- * The v4l2_pix_format structure contains fields that make no sense for
1704 +- * touch. Set them to default values in this case.
1705 +- */
1706 +-
1707 +- p->field = V4L2_FIELD_NONE;
1708 +- p->colorspace = V4L2_COLORSPACE_RAW;
1709 +- p->flags = 0;
1710 +- p->ycbcr_enc = 0;
1711 +- p->quantization = 0;
1712 +- p->xfer_func = 0;
1713 +-}
1714 +-
1715 + static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
1716 + struct file *file, void *fh, void *arg)
1717 + {
1718 +diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
1719 +index a2ac9938d945..1a5d5c40324b 100644
1720 +--- a/drivers/mmc/host/mtk-sd.c
1721 ++++ b/drivers/mmc/host/mtk-sd.c
1722 +@@ -212,6 +212,8 @@
1723 + #define MSDC_PATCH_BIT_SPCPUSH (0x1 << 29) /* RW */
1724 + #define MSDC_PATCH_BIT_DECRCTMO (0x1 << 30) /* RW */
1725 +
1726 ++#define MSDC_PATCH_BIT1_CMDTA (0x7 << 3) /* RW */
1727 ++
1728 + #define MSDC_PAD_TUNE_DATWRDLY (0x1f << 0) /* RW */
1729 + #define MSDC_PAD_TUNE_DATRRDLY (0x1f << 8) /* RW */
1730 + #define MSDC_PAD_TUNE_CMDRDLY (0x1f << 16) /* RW */
1731 +@@ -1442,6 +1444,7 @@ static int hs400_tune_response(struct mmc_host *mmc, u32 opcode)
1732 +
1733 + /* select EMMC50 PAD CMD tune */
1734 + sdr_set_bits(host->base + PAD_CMD_TUNE, BIT(0));
1735 ++ sdr_set_field(host->base + MSDC_PATCH_BIT1, MSDC_PATCH_BIT1_CMDTA, 2);
1736 +
1737 + if (mmc->ios.timing == MMC_TIMING_MMC_HS200 ||
1738 + mmc->ios.timing == MMC_TIMING_UHS_SDR104)
1739 +diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
1740 +index 176cbc67d08a..9a1ab39ee35e 100644
1741 +--- a/drivers/mmc/host/sdhci-of-esdhc.c
1742 ++++ b/drivers/mmc/host/sdhci-of-esdhc.c
1743 +@@ -615,9 +615,6 @@ static void esdhc_reset(struct sdhci_host *host, u8 mask)
1744 + sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
1745 + sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
1746 +
1747 +- if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc"))
1748 +- mdelay(5);
1749 +-
1750 + if (mask & SDHCI_RESET_ALL) {
1751 + val = sdhci_readl(host, ESDHC_TBCTL);
1752 + val &= ~ESDHC_TB_EN;
1753 +@@ -889,8 +886,8 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)
1754 + host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ;
1755 +
1756 + if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc")) {
1757 +- host->quirks2 |= SDHCI_QUIRK_RESET_AFTER_REQUEST;
1758 +- host->quirks2 |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
1759 ++ host->quirks |= SDHCI_QUIRK_RESET_AFTER_REQUEST;
1760 ++ host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
1761 + }
1762 +
1763 + if (of_device_is_compatible(np, "fsl,p5040-esdhc") ||
1764 +diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
1765 +index 5807028c8309..645775dd4edb 100644
1766 +--- a/drivers/mmc/host/sdhci.c
1767 ++++ b/drivers/mmc/host/sdhci.c
1768 +@@ -1635,9 +1635,7 @@ void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
1769 + ctrl_2 |= SDHCI_CTRL_UHS_SDR104;
1770 + else if (timing == MMC_TIMING_UHS_SDR12)
1771 + ctrl_2 |= SDHCI_CTRL_UHS_SDR12;
1772 +- else if (timing == MMC_TIMING_SD_HS ||
1773 +- timing == MMC_TIMING_MMC_HS ||
1774 +- timing == MMC_TIMING_UHS_SDR25)
1775 ++ else if (timing == MMC_TIMING_UHS_SDR25)
1776 + ctrl_2 |= SDHCI_CTRL_UHS_SDR25;
1777 + else if (timing == MMC_TIMING_UHS_SDR50)
1778 + ctrl_2 |= SDHCI_CTRL_UHS_SDR50;
1779 +@@ -2164,8 +2162,8 @@ static void __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
1780 + sdhci_send_tuning(host, opcode);
1781 +
1782 + if (!host->tuning_done) {
1783 +- pr_info("%s: Tuning timeout, falling back to fixed sampling clock\n",
1784 +- mmc_hostname(host->mmc));
1785 ++ pr_debug("%s: Tuning timeout, falling back to fixed sampling clock\n",
1786 ++ mmc_hostname(host->mmc));
1787 + sdhci_abort_tuning(host, opcode);
1788 + return;
1789 + }
1790 +diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
1791 +index 2fd862dc9770..a09aad9155a5 100644
1792 +--- a/drivers/mmc/host/tmio_mmc_core.c
1793 ++++ b/drivers/mmc/host/tmio_mmc_core.c
1794 +@@ -1220,7 +1220,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
1795 + _host->start_signal_voltage_switch;
1796 + mmc->ops = &tmio_mmc_ops;
1797 +
1798 +- mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities;
1799 ++ mmc->caps |= MMC_CAP_ERASE | MMC_CAP_4_BIT_DATA | pdata->capabilities;
1800 + mmc->caps2 |= pdata->capabilities2;
1801 + mmc->max_segs = pdata->max_segs ? : 32;
1802 + mmc->max_blk_size = 512;
1803 +diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig
1804 +index 83a9bc892a3b..6ae13f2419e3 100644
1805 +--- a/drivers/net/dsa/Kconfig
1806 ++++ b/drivers/net/dsa/Kconfig
1807 +@@ -55,6 +55,7 @@ config NET_DSA_QCA8K
1808 + config NET_DSA_SMSC_LAN9303
1809 + tristate
1810 + select NET_DSA_TAG_LAN9303
1811 ++ select REGMAP
1812 + ---help---
1813 + This enables support for the SMSC/Microchip LAN9303 3 port ethernet
1814 + switch chips.
1815 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
1816 +index 9ca994d0bab6..1977e0c552df 100644
1817 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
1818 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
1819 +@@ -2389,15 +2389,21 @@ static int bnx2x_set_pf_tx_switching(struct bnx2x *bp, bool enable)
1820 + /* send the ramrod on all the queues of the PF */
1821 + for_each_eth_queue(bp, i) {
1822 + struct bnx2x_fastpath *fp = &bp->fp[i];
1823 ++ int tx_idx;
1824 +
1825 + /* Set the appropriate Queue object */
1826 + q_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
1827 +
1828 +- /* Update the Queue state */
1829 +- rc = bnx2x_queue_state_change(bp, &q_params);
1830 +- if (rc) {
1831 +- BNX2X_ERR("Failed to configure Tx switching\n");
1832 +- return rc;
1833 ++ for (tx_idx = FIRST_TX_COS_INDEX;
1834 ++ tx_idx < fp->max_cos; tx_idx++) {
1835 ++ q_params.params.update.cid_index = tx_idx;
1836 ++
1837 ++ /* Update the Queue state */
1838 ++ rc = bnx2x_queue_state_change(bp, &q_params);
1839 ++ if (rc) {
1840 ++ BNX2X_ERR("Failed to configure Tx switching\n");
1841 ++ return rc;
1842 ++ }
1843 + }
1844 + }
1845 +
1846 +diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c
1847 +index 84c0f22ac2db..d5489cb0afff 100644
1848 +--- a/drivers/net/ethernet/hisilicon/hip04_eth.c
1849 ++++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
1850 +@@ -456,9 +456,9 @@ hip04_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1851 + skb_tx_timestamp(skb);
1852 +
1853 + hip04_set_xmit_desc(priv, phys);
1854 +- priv->tx_head = TX_NEXT(tx_head);
1855 + count++;
1856 + netdev_sent_queue(ndev, skb->len);
1857 ++ priv->tx_head = TX_NEXT(tx_head);
1858 +
1859 + stats->tx_bytes += skb->len;
1860 + stats->tx_packets++;
1861 +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1862 +index 4801d96c4fa9..0edfd199937d 100644
1863 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1864 ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1865 +@@ -8379,7 +8379,8 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
1866 +
1867 + if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
1868 + adapter->ptp_clock) {
1869 +- if (!test_and_set_bit_lock(__IXGBE_PTP_TX_IN_PROGRESS,
1870 ++ if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON &&
1871 ++ !test_and_set_bit_lock(__IXGBE_PTP_TX_IN_PROGRESS,
1872 + &adapter->state)) {
1873 + skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
1874 + tx_flags |= IXGBE_TX_FLAGS_TSTAMP;
1875 +diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
1876 +index f79e36e4060a..e7ad95de3da8 100644
1877 +--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
1878 ++++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
1879 +@@ -1181,7 +1181,7 @@ qede_configure_mcast_filtering(struct net_device *ndev,
1880 + netif_addr_lock_bh(ndev);
1881 +
1882 + mc_count = netdev_mc_count(ndev);
1883 +- if (mc_count < 64) {
1884 ++ if (mc_count <= 64) {
1885 + netdev_for_each_mc_addr(ha, ndev) {
1886 + ether_addr_copy(temp, ha->addr);
1887 + temp += ETH_ALEN;
1888 +diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c
1889 +index 5fca9a75780c..cc53ee26bd3e 100644
1890 +--- a/drivers/net/ethernet/qlogic/qla3xxx.c
1891 ++++ b/drivers/net/ethernet/qlogic/qla3xxx.c
1892 +@@ -2756,6 +2756,9 @@ static int ql_alloc_large_buffers(struct ql3_adapter *qdev)
1893 + int err;
1894 +
1895 + for (i = 0; i < qdev->num_large_buffers; i++) {
1896 ++ lrg_buf_cb = &qdev->lrg_buf[i];
1897 ++ memset(lrg_buf_cb, 0, sizeof(struct ql_rcv_buf_cb));
1898 ++
1899 + skb = netdev_alloc_skb(qdev->ndev,
1900 + qdev->lrg_buffer_len);
1901 + if (unlikely(!skb)) {
1902 +@@ -2766,11 +2769,7 @@ static int ql_alloc_large_buffers(struct ql3_adapter *qdev)
1903 + ql_free_large_buffers(qdev);
1904 + return -ENOMEM;
1905 + } else {
1906 +-
1907 +- lrg_buf_cb = &qdev->lrg_buf[i];
1908 +- memset(lrg_buf_cb, 0, sizeof(struct ql_rcv_buf_cb));
1909 + lrg_buf_cb->index = i;
1910 +- lrg_buf_cb->skb = skb;
1911 + /*
1912 + * We save some space to copy the ethhdr from first
1913 + * buffer
1914 +@@ -2792,6 +2791,7 @@ static int ql_alloc_large_buffers(struct ql3_adapter *qdev)
1915 + return -ENOMEM;
1916 + }
1917 +
1918 ++ lrg_buf_cb->skb = skb;
1919 + dma_unmap_addr_set(lrg_buf_cb, mapaddr, map);
1920 + dma_unmap_len_set(lrg_buf_cb, maplen,
1921 + qdev->lrg_buffer_len -
1922 +diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
1923 +index 14d6579b292a..314e3eac09b9 100644
1924 +--- a/drivers/net/fjes/fjes_main.c
1925 ++++ b/drivers/net/fjes/fjes_main.c
1926 +@@ -181,6 +181,9 @@ static int fjes_acpi_add(struct acpi_device *device)
1927 + /* create platform_device */
1928 + plat_dev = platform_device_register_simple(DRV_NAME, 0, fjes_resource,
1929 + ARRAY_SIZE(fjes_resource));
1930 ++ if (IS_ERR(plat_dev))
1931 ++ return PTR_ERR(plat_dev);
1932 ++
1933 + device->driver_data = plat_dev;
1934 +
1935 + return 0;
1936 +diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
1937 +index e03e91d5f1b1..0cbcced0870e 100644
1938 +--- a/drivers/net/phy/dp83867.c
1939 ++++ b/drivers/net/phy/dp83867.c
1940 +@@ -84,6 +84,10 @@
1941 + #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX 0x0
1942 + #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN 0x1f
1943 +
1944 ++/* CFG3 bits */
1945 ++#define DP83867_CFG3_INT_OE BIT(7)
1946 ++#define DP83867_CFG3_ROBUST_AUTO_MDIX BIT(9)
1947 ++
1948 + /* CFG4 bits */
1949 + #define DP83867_CFG4_PORT_MIRROR_EN BIT(0)
1950 +
1951 +@@ -320,12 +324,13 @@ static int dp83867_config_init(struct phy_device *phydev)
1952 + return ret;
1953 + }
1954 +
1955 ++ val = phy_read(phydev, DP83867_CFG3);
1956 + /* Enable Interrupt output INT_OE in CFG3 register */
1957 +- if (phy_interrupt_is_valid(phydev)) {
1958 +- val = phy_read(phydev, DP83867_CFG3);
1959 +- val |= BIT(7);
1960 +- phy_write(phydev, DP83867_CFG3, val);
1961 +- }
1962 ++ if (phy_interrupt_is_valid(phydev))
1963 ++ val |= DP83867_CFG3_INT_OE;
1964 ++
1965 ++ val |= DP83867_CFG3_ROBUST_AUTO_MDIX;
1966 ++ phy_write(phydev, DP83867_CFG3, val);
1967 +
1968 + if (dp83867->port_mirroring != DP83867_PORT_MIRROING_KEEP)
1969 + dp83867_config_port_mirroring(phydev);
1970 +diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
1971 +index ed7e3c70b511..a98c227a4c2e 100644
1972 +--- a/drivers/net/phy/phy_device.c
1973 ++++ b/drivers/net/phy/phy_device.c
1974 +@@ -367,8 +367,8 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
1975 + mdiodev->device_free = phy_mdio_device_free;
1976 + mdiodev->device_remove = phy_mdio_device_remove;
1977 +
1978 +- dev->speed = 0;
1979 +- dev->duplex = -1;
1980 ++ dev->speed = SPEED_UNKNOWN;
1981 ++ dev->duplex = DUPLEX_UNKNOWN;
1982 + dev->pause = 0;
1983 + dev->asym_pause = 0;
1984 + dev->link = 1;
1985 +diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
1986 +index 2229284d16f5..7d1d5b30ecc3 100644
1987 +--- a/drivers/net/usb/lan78xx.c
1988 ++++ b/drivers/net/usb/lan78xx.c
1989 +@@ -1765,6 +1765,7 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev)
1990 + dev->mdiobus->read = lan78xx_mdiobus_read;
1991 + dev->mdiobus->write = lan78xx_mdiobus_write;
1992 + dev->mdiobus->name = "lan78xx-mdiobus";
1993 ++ dev->mdiobus->parent = &dev->udev->dev;
1994 +
1995 + snprintf(dev->mdiobus->id, MII_BUS_ID_SIZE, "usb-%03d:%03d",
1996 + dev->udev->bus->busnum, dev->udev->devnum);
1997 +diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
1998 +index dff34448588f..ea47ad4b2343 100644
1999 +--- a/drivers/net/wireless/ath/ath10k/mac.c
2000 ++++ b/drivers/net/wireless/ath/ath10k/mac.c
2001 +@@ -3627,7 +3627,7 @@ static int ath10k_mac_tx(struct ath10k *ar,
2002 + struct ieee80211_vif *vif,
2003 + enum ath10k_hw_txrx_mode txmode,
2004 + enum ath10k_mac_tx_path txpath,
2005 +- struct sk_buff *skb)
2006 ++ struct sk_buff *skb, bool noque_offchan)
2007 + {
2008 + struct ieee80211_hw *hw = ar->hw;
2009 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2010 +@@ -3655,10 +3655,10 @@ static int ath10k_mac_tx(struct ath10k *ar,
2011 + }
2012 + }
2013 +
2014 +- if (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) {
2015 ++ if (!noque_offchan && info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) {
2016 + if (!ath10k_mac_tx_frm_has_freq(ar)) {
2017 +- ath10k_dbg(ar, ATH10K_DBG_MAC, "queued offchannel skb %pK\n",
2018 +- skb);
2019 ++ ath10k_dbg(ar, ATH10K_DBG_MAC, "mac queued offchannel skb %pK len %d\n",
2020 ++ skb, skb->len);
2021 +
2022 + skb_queue_tail(&ar->offchan_tx_queue, skb);
2023 + ieee80211_queue_work(hw, &ar->offchan_tx_work);
2024 +@@ -3720,8 +3720,8 @@ void ath10k_offchan_tx_work(struct work_struct *work)
2025 +
2026 + mutex_lock(&ar->conf_mutex);
2027 +
2028 +- ath10k_dbg(ar, ATH10K_DBG_MAC, "mac offchannel skb %pK\n",
2029 +- skb);
2030 ++ ath10k_dbg(ar, ATH10K_DBG_MAC, "mac offchannel skb %pK len %d\n",
2031 ++ skb, skb->len);
2032 +
2033 + hdr = (struct ieee80211_hdr *)skb->data;
2034 + peer_addr = ieee80211_get_DA(hdr);
2035 +@@ -3767,7 +3767,7 @@ void ath10k_offchan_tx_work(struct work_struct *work)
2036 + txmode = ath10k_mac_tx_h_get_txmode(ar, vif, sta, skb);
2037 + txpath = ath10k_mac_tx_h_get_txpath(ar, skb, txmode);
2038 +
2039 +- ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb);
2040 ++ ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb, true);
2041 + if (ret) {
2042 + ath10k_warn(ar, "failed to transmit offchannel frame: %d\n",
2043 + ret);
2044 +@@ -3777,8 +3777,8 @@ void ath10k_offchan_tx_work(struct work_struct *work)
2045 + time_left =
2046 + wait_for_completion_timeout(&ar->offchan_tx_completed, 3 * HZ);
2047 + if (time_left == 0)
2048 +- ath10k_warn(ar, "timed out waiting for offchannel skb %pK\n",
2049 +- skb);
2050 ++ ath10k_warn(ar, "timed out waiting for offchannel skb %pK, len: %d\n",
2051 ++ skb, skb->len);
2052 +
2053 + if (!peer && tmp_peer_created) {
2054 + ret = ath10k_peer_delete(ar, vdev_id, peer_addr);
2055 +@@ -3957,7 +3957,7 @@ int ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,
2056 + spin_unlock_bh(&ar->htt.tx_lock);
2057 + }
2058 +
2059 +- ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb);
2060 ++ ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb, false);
2061 + if (unlikely(ret)) {
2062 + ath10k_warn(ar, "failed to push frame: %d\n", ret);
2063 +
2064 +@@ -4239,7 +4239,7 @@ static void ath10k_mac_op_tx(struct ieee80211_hw *hw,
2065 + spin_unlock_bh(&ar->htt.tx_lock);
2066 + }
2067 +
2068 +- ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb);
2069 ++ ret = ath10k_mac_tx(ar, vif, txmode, txpath, skb, false);
2070 + if (ret) {
2071 + ath10k_warn(ar, "failed to transmit frame: %d\n", ret);
2072 + if (is_htt) {
2073 +diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
2074 +index d4986f626c35..9999c8c40269 100644
2075 +--- a/drivers/net/wireless/ath/ath10k/txrx.c
2076 ++++ b/drivers/net/wireless/ath/ath10k/txrx.c
2077 +@@ -100,6 +100,8 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt,
2078 +
2079 + info = IEEE80211_SKB_CB(msdu);
2080 + memset(&info->status, 0, sizeof(info->status));
2081 ++ info->status.rates[0].idx = -1;
2082 ++
2083 + trace_ath10k_txrx_tx_unref(ar, tx_done->msdu_id);
2084 +
2085 + if (tx_done->status == HTT_TX_COMPL_STATE_DISCARD) {
2086 +diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/led.c b/drivers/net/wireless/intel/iwlwifi/dvm/led.c
2087 +index 1bbd17ada974..20e16c423990 100644
2088 +--- a/drivers/net/wireless/intel/iwlwifi/dvm/led.c
2089 ++++ b/drivers/net/wireless/intel/iwlwifi/dvm/led.c
2090 +@@ -185,6 +185,9 @@ void iwl_leds_init(struct iwl_priv *priv)
2091 +
2092 + priv->led.name = kasprintf(GFP_KERNEL, "%s-led",
2093 + wiphy_name(priv->hw->wiphy));
2094 ++ if (!priv->led.name)
2095 ++ return;
2096 ++
2097 + priv->led.brightness_set = iwl_led_brightness_set;
2098 + priv->led.blink_set = iwl_led_blink_set;
2099 + priv->led.max_brightness = 1;
2100 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/led.c b/drivers/net/wireless/intel/iwlwifi/mvm/led.c
2101 +index b27269504a62..072f80c90ce4 100644
2102 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/led.c
2103 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/led.c
2104 +@@ -131,6 +131,9 @@ int iwl_mvm_leds_init(struct iwl_mvm *mvm)
2105 +
2106 + mvm->led.name = kasprintf(GFP_KERNEL, "%s-led",
2107 + wiphy_name(mvm->hw->wiphy));
2108 ++ if (!mvm->led.name)
2109 ++ return -ENOMEM;
2110 ++
2111 + mvm->led.brightness_set = iwl_led_brightness_set;
2112 + mvm->led.max_brightness = 1;
2113 +
2114 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
2115 +index c73e4be9bde3..c31303d13069 100644
2116 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
2117 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
2118 +@@ -62,6 +62,7 @@
2119 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2120 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2121 + *****************************************************************************/
2122 ++#include <asm/unaligned.h>
2123 + #include <linux/etherdevice.h>
2124 + #include <linux/skbuff.h>
2125 + #include "iwl-trans.h"
2126 +@@ -290,7 +291,7 @@ void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,
2127 + rx_res = (struct iwl_rx_mpdu_res_start *)pkt->data;
2128 + hdr = (struct ieee80211_hdr *)(pkt->data + sizeof(*rx_res));
2129 + len = le16_to_cpu(rx_res->byte_count);
2130 +- rx_pkt_status = le32_to_cpup((__le32 *)
2131 ++ rx_pkt_status = get_unaligned_le32((__le32 *)
2132 + (pkt->data + sizeof(*rx_res) + len));
2133 +
2134 + /* Dont use dev_alloc_skb(), we'll have enough headroom once
2135 +diff --git a/drivers/net/wireless/marvell/libertas/if_sdio.c b/drivers/net/wireless/marvell/libertas/if_sdio.c
2136 +index 39bf85d0ade0..c7f8a29d2606 100644
2137 +--- a/drivers/net/wireless/marvell/libertas/if_sdio.c
2138 ++++ b/drivers/net/wireless/marvell/libertas/if_sdio.c
2139 +@@ -1183,6 +1183,10 @@ static int if_sdio_probe(struct sdio_func *func,
2140 +
2141 + spin_lock_init(&card->lock);
2142 + card->workqueue = alloc_workqueue("libertas_sdio", WQ_MEM_RECLAIM, 0);
2143 ++ if (unlikely(!card->workqueue)) {
2144 ++ ret = -ENOMEM;
2145 ++ goto err_queue;
2146 ++ }
2147 + INIT_WORK(&card->packet_worker, if_sdio_host_to_card_worker);
2148 + init_waitqueue_head(&card->pwron_waitq);
2149 +
2150 +@@ -1234,6 +1238,7 @@ err_activate_card:
2151 + lbs_remove_card(priv);
2152 + free:
2153 + destroy_workqueue(card->workqueue);
2154 ++err_queue:
2155 + while (card->packets) {
2156 + packet = card->packets;
2157 + card->packets = card->packets->next;
2158 +diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
2159 +index 9511f5fe62f4..9d0d790a1319 100644
2160 +--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
2161 ++++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
2162 +@@ -677,8 +677,11 @@ static int mwifiex_pcie_init_evt_ring(struct mwifiex_adapter *adapter)
2163 + skb_put(skb, MAX_EVENT_SIZE);
2164 +
2165 + if (mwifiex_map_pci_memory(adapter, skb, MAX_EVENT_SIZE,
2166 +- PCI_DMA_FROMDEVICE))
2167 ++ PCI_DMA_FROMDEVICE)) {
2168 ++ kfree_skb(skb);
2169 ++ kfree(card->evtbd_ring_vbase);
2170 + return -1;
2171 ++ }
2172 +
2173 + buf_pa = MWIFIEX_SKB_DMA_ADDR(skb);
2174 +
2175 +diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
2176 +index 95e3993d8a33..a895b6fd6f85 100644
2177 +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
2178 ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
2179 +@@ -1349,6 +1349,7 @@ struct rtl8xxxu_fileops {
2180 + u8 has_s0s1:1;
2181 + u8 has_tx_report:1;
2182 + u8 gen2_thermal_meter:1;
2183 ++ u8 needs_full_init:1;
2184 + u32 adda_1t_init;
2185 + u32 adda_1t_path_on;
2186 + u32 adda_2t_path_on_a;
2187 +diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
2188 +index c4b86a84a721..27e97df996c7 100644
2189 +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
2190 ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
2191 +@@ -1673,6 +1673,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = {
2192 + .has_s0s1 = 1,
2193 + .has_tx_report = 1,
2194 + .gen2_thermal_meter = 1,
2195 ++ .needs_full_init = 1,
2196 + .adda_1t_init = 0x01c00014,
2197 + .adda_1t_path_on = 0x01c00014,
2198 + .adda_2t_path_on_a = 0x01c00014,
2199 +diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
2200 +index 91b01ca32e75..b58bf8e2cad2 100644
2201 +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
2202 ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
2203 +@@ -3905,6 +3905,9 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
2204 + else
2205 + macpower = true;
2206 +
2207 ++ if (fops->needs_full_init)
2208 ++ macpower = false;
2209 ++
2210 + ret = fops->power_on(priv);
2211 + if (ret < 0) {
2212 + dev_warn(dev, "%s: Failed power on\n", __func__);
2213 +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
2214 +index 530e80f0ef0b..1ee7f796113b 100644
2215 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
2216 ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
2217 +@@ -1556,6 +1556,8 @@ static bool usb_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
2218 + * This is maybe necessary:
2219 + * rtlpriv->cfg->ops->fill_tx_cmddesc(hw, buffer, 1, 1, skb);
2220 + */
2221 ++ dev_kfree_skb(skb);
2222 ++
2223 + return true;
2224 + }
2225 +
2226 +diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
2227 +index 2401c8bdb211..93eda23f0123 100644
2228 +--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
2229 ++++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
2230 +@@ -1068,8 +1068,10 @@ int rtl_usb_probe(struct usb_interface *intf,
2231 + rtlpriv->hw = hw;
2232 + rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32),
2233 + GFP_KERNEL);
2234 +- if (!rtlpriv->usb_data)
2235 ++ if (!rtlpriv->usb_data) {
2236 ++ ieee80211_free_hw(hw);
2237 + return -ENOMEM;
2238 ++ }
2239 +
2240 + /* this spin lock must be initialized early */
2241 + spin_lock_init(&rtlpriv->locks.usb_lock);
2242 +@@ -1130,6 +1132,7 @@ error_out2:
2243 + _rtl_usb_io_handler_release(hw);
2244 + usb_put_dev(udev);
2245 + complete(&rtlpriv->firmware_loading_complete);
2246 ++ kfree(rtlpriv->usb_data);
2247 + return -ENODEV;
2248 + }
2249 + EXPORT_SYMBOL(rtl_usb_probe);
2250 +diff --git a/drivers/parport/share.c b/drivers/parport/share.c
2251 +index 7b4ee33c1935..15c81cffd2de 100644
2252 +--- a/drivers/parport/share.c
2253 ++++ b/drivers/parport/share.c
2254 +@@ -230,6 +230,18 @@ static int port_check(struct device *dev, void *dev_drv)
2255 + return 0;
2256 + }
2257 +
2258 ++/*
2259 ++ * Iterates through all the devices connected to the bus and return 1
2260 ++ * if the device is a parallel port.
2261 ++ */
2262 ++
2263 ++static int port_detect(struct device *dev, void *dev_drv)
2264 ++{
2265 ++ if (is_parport(dev))
2266 ++ return 1;
2267 ++ return 0;
2268 ++}
2269 ++
2270 + /**
2271 + * parport_register_driver - register a parallel port device driver
2272 + * @drv: structure describing the driver
2273 +@@ -282,6 +294,15 @@ int __parport_register_driver(struct parport_driver *drv, struct module *owner,
2274 + if (ret)
2275 + return ret;
2276 +
2277 ++ /*
2278 ++ * check if bus has any parallel port registered, if
2279 ++ * none is found then load the lowlevel driver.
2280 ++ */
2281 ++ ret = bus_for_each_dev(&parport_bus_type, NULL, NULL,
2282 ++ port_detect);
2283 ++ if (!ret)
2284 ++ get_lowlevel_driver();
2285 ++
2286 + mutex_lock(&registration_lock);
2287 + if (drv->match_port)
2288 + bus_for_each_dev(&parport_bus_type, NULL, drv,
2289 +diff --git a/drivers/phy/qualcomm/phy-qcom-usb-hs.c b/drivers/phy/qualcomm/phy-qcom-usb-hs.c
2290 +index 2d0c70b5589f..643934a2a70c 100644
2291 +--- a/drivers/phy/qualcomm/phy-qcom-usb-hs.c
2292 ++++ b/drivers/phy/qualcomm/phy-qcom-usb-hs.c
2293 +@@ -159,8 +159,8 @@ static int qcom_usb_hs_phy_power_on(struct phy *phy)
2294 + /* setup initial state */
2295 + qcom_usb_hs_phy_vbus_notifier(&uphy->vbus_notify, state,
2296 + uphy->vbus_edev);
2297 +- ret = devm_extcon_register_notifier(&ulpi->dev, uphy->vbus_edev,
2298 +- EXTCON_USB, &uphy->vbus_notify);
2299 ++ ret = extcon_register_notifier(uphy->vbus_edev, EXTCON_USB,
2300 ++ &uphy->vbus_notify);
2301 + if (ret)
2302 + goto err_ulpi;
2303 + }
2304 +@@ -181,6 +181,9 @@ static int qcom_usb_hs_phy_power_off(struct phy *phy)
2305 + {
2306 + struct qcom_usb_hs_phy *uphy = phy_get_drvdata(phy);
2307 +
2308 ++ if (uphy->vbus_edev)
2309 ++ extcon_unregister_notifier(uphy->vbus_edev, EXTCON_USB,
2310 ++ &uphy->vbus_notify);
2311 + regulator_disable(uphy->v3p3);
2312 + regulator_disable(uphy->v1p8);
2313 + clk_disable_unprepare(uphy->sleep_clk);
2314 +diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
2315 +index c4aa411f5935..3a7c2d6e4d5f 100644
2316 +--- a/drivers/pinctrl/devicetree.c
2317 ++++ b/drivers/pinctrl/devicetree.c
2318 +@@ -40,6 +40,13 @@ struct pinctrl_dt_map {
2319 + static void dt_free_map(struct pinctrl_dev *pctldev,
2320 + struct pinctrl_map *map, unsigned num_maps)
2321 + {
2322 ++ int i;
2323 ++
2324 ++ for (i = 0; i < num_maps; ++i) {
2325 ++ kfree_const(map[i].dev_name);
2326 ++ map[i].dev_name = NULL;
2327 ++ }
2328 ++
2329 + if (pctldev) {
2330 + const struct pinctrl_ops *ops = pctldev->desc->pctlops;
2331 + if (ops->dt_free_map)
2332 +@@ -74,7 +81,13 @@ static int dt_remember_or_free_map(struct pinctrl *p, const char *statename,
2333 +
2334 + /* Initialize common mapping table entry fields */
2335 + for (i = 0; i < num_maps; i++) {
2336 +- map[i].dev_name = dev_name(p->dev);
2337 ++ const char *devname;
2338 ++
2339 ++ devname = kstrdup_const(dev_name(p->dev), GFP_KERNEL);
2340 ++ if (!devname)
2341 ++ goto err_free_map;
2342 ++
2343 ++ map[i].dev_name = devname;
2344 + map[i].name = statename;
2345 + if (pctldev)
2346 + map[i].ctrl_dev_name = dev_name(pctldev->dev);
2347 +@@ -82,10 +95,8 @@ static int dt_remember_or_free_map(struct pinctrl *p, const char *statename,
2348 +
2349 + /* Remember the converted mapping table entries */
2350 + dt_map = kzalloc(sizeof(*dt_map), GFP_KERNEL);
2351 +- if (!dt_map) {
2352 +- dt_free_map(pctldev, map, num_maps);
2353 +- return -ENOMEM;
2354 +- }
2355 ++ if (!dt_map)
2356 ++ goto err_free_map;
2357 +
2358 + dt_map->pctldev = pctldev;
2359 + dt_map->map = map;
2360 +@@ -93,6 +104,10 @@ static int dt_remember_or_free_map(struct pinctrl *p, const char *statename,
2361 + list_add_tail(&dt_map->node, &p->dt_maps);
2362 +
2363 + return pinctrl_register_map(map, num_maps, false);
2364 ++
2365 ++err_free_map:
2366 ++ dt_free_map(pctldev, map, num_maps);
2367 ++ return -ENOMEM;
2368 + }
2369 +
2370 + struct pinctrl_dev *of_pinctrl_get(struct device_node *np)
2371 +diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
2372 +index b78f42abff2f..7385cd81498c 100644
2373 +--- a/drivers/pinctrl/pinctrl-amd.c
2374 ++++ b/drivers/pinctrl/pinctrl-amd.c
2375 +@@ -509,7 +509,8 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
2376 + irqreturn_t ret = IRQ_NONE;
2377 + unsigned int i, irqnr;
2378 + unsigned long flags;
2379 +- u32 *regs, regval;
2380 ++ u32 __iomem *regs;
2381 ++ u32 regval;
2382 + u64 status, mask;
2383 +
2384 + /* Read the wake status */
2385 +diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7734.c b/drivers/pinctrl/sh-pfc/pfc-sh7734.c
2386 +index 33232041ee86..3eccc9b3ca84 100644
2387 +--- a/drivers/pinctrl/sh-pfc/pfc-sh7734.c
2388 ++++ b/drivers/pinctrl/sh-pfc/pfc-sh7734.c
2389 +@@ -1453,7 +1453,7 @@ static const struct pinmux_func pinmux_func_gpios[] = {
2390 + GPIO_FN(ET0_ETXD2_A),
2391 + GPIO_FN(EX_CS5), GPIO_FN(SD1_CMD_A), GPIO_FN(ATADIR), GPIO_FN(QSSL_B),
2392 + GPIO_FN(ET0_ETXD3_A),
2393 +- GPIO_FN(RD_WR), GPIO_FN(TCLK1_B),
2394 ++ GPIO_FN(RD_WR), GPIO_FN(TCLK0), GPIO_FN(CAN_CLK_B), GPIO_FN(ET0_ETXD4),
2395 + GPIO_FN(EX_WAIT0), GPIO_FN(TCLK1_B),
2396 + GPIO_FN(EX_WAIT1), GPIO_FN(SD1_DAT0_A), GPIO_FN(DREQ2),
2397 + GPIO_FN(CAN1_TX_C), GPIO_FN(ET0_LINK_C), GPIO_FN(ET0_ETXD5_A),
2398 +@@ -1949,7 +1949,7 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
2399 + /* IP3_20 [1] */
2400 + FN_EX_WAIT0, FN_TCLK1_B,
2401 + /* IP3_19_18 [2] */
2402 +- FN_RD_WR, FN_TCLK1_B, 0, 0,
2403 ++ FN_RD_WR, FN_TCLK0, FN_CAN_CLK_B, FN_ET0_ETXD4,
2404 + /* IP3_17_15 [3] */
2405 + FN_EX_CS5, FN_SD1_CMD_A, FN_ATADIR, FN_QSSL_B,
2406 + FN_ET0_ETXD3_A, 0, 0, 0,
2407 +diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
2408 +index d0ffdd5d9199..06a3c1ef8eee 100644
2409 +--- a/drivers/platform/x86/hp-wmi.c
2410 ++++ b/drivers/platform/x86/hp-wmi.c
2411 +@@ -313,7 +313,7 @@ static int __init hp_wmi_bios_2008_later(void)
2412 +
2413 + static int __init hp_wmi_bios_2009_later(void)
2414 + {
2415 +- int state = 0;
2416 ++ u8 state[128];
2417 + int ret = hp_wmi_perform_query(HPWMI_FEATURE2_QUERY, HPWMI_READ, &state,
2418 + sizeof(state), sizeof(state));
2419 + if (!ret)
2420 +diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c
2421 +index 860400d2cd85..a8f2f07239fb 100644
2422 +--- a/drivers/regulator/max8907-regulator.c
2423 ++++ b/drivers/regulator/max8907-regulator.c
2424 +@@ -299,7 +299,10 @@ static int max8907_regulator_probe(struct platform_device *pdev)
2425 + memcpy(pmic->desc, max8907_regulators, sizeof(pmic->desc));
2426 +
2427 + /* Backwards compatibility with MAX8907B; SD1 uses different voltages */
2428 +- regmap_read(max8907->regmap_gen, MAX8907_REG_II2RR, &val);
2429 ++ ret = regmap_read(max8907->regmap_gen, MAX8907_REG_II2RR, &val);
2430 ++ if (ret)
2431 ++ return ret;
2432 ++
2433 + if ((val & MAX8907_II2RR_VERSION_MASK) ==
2434 + MAX8907_II2RR_VERSION_REV_B) {
2435 + pmic->desc[MAX8907_SD1].min_uV = 637500;
2436 +@@ -336,14 +339,20 @@ static int max8907_regulator_probe(struct platform_device *pdev)
2437 + }
2438 +
2439 + if (pmic->desc[i].ops == &max8907_ldo_ops) {
2440 +- regmap_read(config.regmap, pmic->desc[i].enable_reg,
2441 ++ ret = regmap_read(config.regmap, pmic->desc[i].enable_reg,
2442 + &val);
2443 ++ if (ret)
2444 ++ return ret;
2445 ++
2446 + if ((val & MAX8907_MASK_LDO_SEQ) !=
2447 + MAX8907_MASK_LDO_SEQ)
2448 + pmic->desc[i].ops = &max8907_ldo_hwctl_ops;
2449 + } else if (pmic->desc[i].ops == &max8907_out5v_ops) {
2450 +- regmap_read(config.regmap, pmic->desc[i].enable_reg,
2451 ++ ret = regmap_read(config.regmap, pmic->desc[i].enable_reg,
2452 + &val);
2453 ++ if (ret)
2454 ++ return ret;
2455 ++
2456 + if ((val & (MAX8907_MASK_OUT5V_VINEN |
2457 + MAX8907_MASK_OUT5V_ENSRC)) !=
2458 + MAX8907_MASK_OUT5V_ENSRC)
2459 +diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c
2460 +index 7a37090dabbe..2e65b70c7879 100644
2461 +--- a/drivers/spi/spi-img-spfi.c
2462 ++++ b/drivers/spi/spi-img-spfi.c
2463 +@@ -673,6 +673,8 @@ static int img_spfi_probe(struct platform_device *pdev)
2464 + dma_release_channel(spfi->tx_ch);
2465 + if (spfi->rx_ch)
2466 + dma_release_channel(spfi->rx_ch);
2467 ++ spfi->tx_ch = NULL;
2468 ++ spfi->rx_ch = NULL;
2469 + dev_warn(spfi->dev, "Failed to get DMA channels, falling back to PIO mode\n");
2470 + } else {
2471 + master->dma_tx = spfi->tx_ch;
2472 +diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
2473 +index 9bf3e5f945c7..b2245cdce230 100644
2474 +--- a/drivers/spi/spi-pxa2xx.c
2475 ++++ b/drivers/spi/spi-pxa2xx.c
2476 +@@ -1559,7 +1559,13 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
2477 + }
2478 +
2479 + ssp->clk = devm_clk_get(&pdev->dev, NULL);
2480 ++ if (IS_ERR(ssp->clk))
2481 ++ return NULL;
2482 ++
2483 + ssp->irq = platform_get_irq(pdev, 0);
2484 ++ if (ssp->irq < 0)
2485 ++ return NULL;
2486 ++
2487 + ssp->type = type;
2488 + ssp->pdev = pdev;
2489 + ssp->port_id = pxa2xx_spi_get_port_id(adev);
2490 +diff --git a/drivers/spi/spi-st-ssc4.c b/drivers/spi/spi-st-ssc4.c
2491 +index a4e43fc19ece..5df01ffdef46 100644
2492 +--- a/drivers/spi/spi-st-ssc4.c
2493 ++++ b/drivers/spi/spi-st-ssc4.c
2494 +@@ -385,6 +385,7 @@ static int spi_st_probe(struct platform_device *pdev)
2495 + return 0;
2496 +
2497 + clk_disable:
2498 ++ pm_runtime_disable(&pdev->dev);
2499 + clk_disable_unprepare(spi_st->clk);
2500 + put_master:
2501 + spi_master_put(master);
2502 +@@ -396,6 +397,8 @@ static int spi_st_remove(struct platform_device *pdev)
2503 + struct spi_master *master = platform_get_drvdata(pdev);
2504 + struct spi_st *spi_st = spi_master_get_devdata(master);
2505 +
2506 ++ pm_runtime_disable(&pdev->dev);
2507 ++
2508 + clk_disable_unprepare(spi_st->clk);
2509 +
2510 + pinctrl_pm_select_sleep_state(&pdev->dev);
2511 +diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
2512 +index 9831c1106945..62b074b167a9 100644
2513 +--- a/drivers/spi/spi-tegra20-slink.c
2514 ++++ b/drivers/spi/spi-tegra20-slink.c
2515 +@@ -1078,7 +1078,7 @@ static int tegra_slink_probe(struct platform_device *pdev)
2516 + ret = clk_enable(tspi->clk);
2517 + if (ret < 0) {
2518 + dev_err(&pdev->dev, "Clock enable failed %d\n", ret);
2519 +- goto exit_free_master;
2520 ++ goto exit_clk_unprepare;
2521 + }
2522 +
2523 + spi_irq = platform_get_irq(pdev, 0);
2524 +@@ -1151,6 +1151,8 @@ exit_free_irq:
2525 + free_irq(spi_irq, tspi);
2526 + exit_clk_disable:
2527 + clk_disable(tspi->clk);
2528 ++exit_clk_unprepare:
2529 ++ clk_unprepare(tspi->clk);
2530 + exit_free_master:
2531 + spi_master_put(master);
2532 + return ret;
2533 +@@ -1164,6 +1166,7 @@ static int tegra_slink_remove(struct platform_device *pdev)
2534 + free_irq(tspi->irq, tspi);
2535 +
2536 + clk_disable(tspi->clk);
2537 ++ clk_unprepare(tspi->clk);
2538 +
2539 + if (tspi->tx_dma_chan)
2540 + tegra_slink_deinit_dma_param(tspi, false);
2541 +diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
2542 +index c5fe08bc34a0..028725573e63 100644
2543 +--- a/drivers/spi/spidev.c
2544 ++++ b/drivers/spi/spidev.c
2545 +@@ -634,6 +634,9 @@ static int spidev_release(struct inode *inode, struct file *filp)
2546 + if (dofree)
2547 + kfree(spidev);
2548 + }
2549 ++#ifdef CONFIG_SPI_SLAVE
2550 ++ spi_slave_abort(spidev->spi);
2551 ++#endif
2552 + mutex_unlock(&device_list_lock);
2553 +
2554 + return 0;
2555 +diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c
2556 +index e5b948405fd9..a09631f9d813 100644
2557 +--- a/drivers/staging/comedi/drivers/gsc_hpdi.c
2558 ++++ b/drivers/staging/comedi/drivers/gsc_hpdi.c
2559 +@@ -632,6 +632,11 @@ static int gsc_hpdi_auto_attach(struct comedi_device *dev,
2560 + dma_alloc_coherent(&pcidev->dev, DMA_BUFFER_SIZE,
2561 + &devpriv->dio_buffer_phys_addr[i],
2562 + GFP_KERNEL);
2563 ++ if (!devpriv->dio_buffer[i]) {
2564 ++ dev_warn(dev->class_dev,
2565 ++ "failed to allocate DMA buffer\n");
2566 ++ return -ENOMEM;
2567 ++ }
2568 + }
2569 + /* allocate dma descriptors */
2570 + devpriv->dma_desc = dma_alloc_coherent(&pcidev->dev,
2571 +@@ -639,6 +644,11 @@ static int gsc_hpdi_auto_attach(struct comedi_device *dev,
2572 + NUM_DMA_DESCRIPTORS,
2573 + &devpriv->dma_desc_phys_addr,
2574 + GFP_KERNEL);
2575 ++ if (!devpriv->dma_desc) {
2576 ++ dev_warn(dev->class_dev,
2577 ++ "failed to allocate DMA descriptors\n");
2578 ++ return -ENOMEM;
2579 ++ }
2580 + if (devpriv->dma_desc_phys_addr & 0xf) {
2581 + dev_warn(dev->class_dev,
2582 + " dma descriptors not quad-word aligned (bug)\n");
2583 +diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
2584 +index 0cbcbad8f074..b81c6dfa5b24 100644
2585 +--- a/drivers/staging/fbtft/fbtft-core.c
2586 ++++ b/drivers/staging/fbtft/fbtft-core.c
2587 +@@ -780,7 +780,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
2588 + fbdefio->deferred_io = fbtft_deferred_io;
2589 + fb_deferred_io_init(info);
2590 +
2591 +- strncpy(info->fix.id, dev->driver->name, 16);
2592 ++ snprintf(info->fix.id, sizeof(info->fix.id), "%s", dev->driver->name);
2593 + info->fix.type = FB_TYPE_PACKED_PIXELS;
2594 + info->fix.visual = FB_VISUAL_TRUECOLOR;
2595 + info->fix.xpanstep = 0;
2596 +diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
2597 +index 904b988ecc4e..7c895af1ba31 100644
2598 +--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
2599 ++++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
2600 +@@ -805,7 +805,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
2601 + memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN);
2602 + memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN);
2603 +
2604 +- if (psta->qos_option)
2605 ++ if (psta && psta->qos_option)
2606 + qos_option = true;
2607 + } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
2608 + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
2609 +@@ -813,7 +813,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
2610 + memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
2611 + memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN);
2612 +
2613 +- if (psta->qos_option)
2614 ++ if (psta && psta->qos_option)
2615 + qos_option = true;
2616 + } else {
2617 + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv)));
2618 +diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
2619 +index db3eb7ec5809..fbbd1b59dc11 100644
2620 +--- a/drivers/staging/rtl8192u/r8192U_core.c
2621 ++++ b/drivers/staging/rtl8192u/r8192U_core.c
2622 +@@ -1506,7 +1506,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
2623 + (tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
2624 + struct usb_device *udev = priv->udev;
2625 + int pend;
2626 +- int status;
2627 ++ int status, rt = -1;
2628 + struct urb *tx_urb = NULL, *tx_urb_zero = NULL;
2629 + unsigned int idx_pipe;
2630 +
2631 +@@ -1650,8 +1650,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
2632 + }
2633 + if (bSend0Byte) {
2634 + tx_urb_zero = usb_alloc_urb(0, GFP_ATOMIC);
2635 +- if (!tx_urb_zero)
2636 +- return -ENOMEM;
2637 ++ if (!tx_urb_zero) {
2638 ++ rt = -ENOMEM;
2639 ++ goto error;
2640 ++ }
2641 + usb_fill_bulk_urb(tx_urb_zero, udev,
2642 + usb_sndbulkpipe(udev, idx_pipe),
2643 + &zero, 0, tx_zero_isr, dev);
2644 +@@ -1661,7 +1663,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
2645 + "Error TX URB for zero byte %d, error %d",
2646 + atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
2647 + status);
2648 +- return -1;
2649 ++ goto error;
2650 + }
2651 + }
2652 + netif_trans_update(dev);
2653 +@@ -1672,7 +1674,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
2654 + RT_TRACE(COMP_ERR, "Error TX URB %d, error %d",
2655 + atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
2656 + status);
2657 +- return -1;
2658 ++
2659 ++error:
2660 ++ dev_kfree_skb_any(skb);
2661 ++ usb_free_urb(tx_urb);
2662 ++ usb_free_urb(tx_urb_zero);
2663 ++ return rt;
2664 + }
2665 +
2666 + static short rtl8192_usb_initendpoints(struct net_device *dev)
2667 +diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
2668 +index 62b2a7105f02..4fb4cf8c2f14 100644
2669 +--- a/drivers/usb/core/devio.c
2670 ++++ b/drivers/usb/core/devio.c
2671 +@@ -755,8 +755,15 @@ static int claimintf(struct usb_dev_state *ps, unsigned int ifnum)
2672 + intf = usb_ifnum_to_if(dev, ifnum);
2673 + if (!intf)
2674 + err = -ENOENT;
2675 +- else
2676 ++ else {
2677 ++ unsigned int old_suppress;
2678 ++
2679 ++ /* suppress uevents while claiming interface */
2680 ++ old_suppress = dev_get_uevent_suppress(&intf->dev);
2681 ++ dev_set_uevent_suppress(&intf->dev, 1);
2682 + err = usb_driver_claim_interface(&usbfs_driver, intf, ps);
2683 ++ dev_set_uevent_suppress(&intf->dev, old_suppress);
2684 ++ }
2685 + if (err == 0)
2686 + set_bit(ifnum, &ps->ifclaimed);
2687 + return err;
2688 +@@ -776,7 +783,13 @@ static int releaseintf(struct usb_dev_state *ps, unsigned int ifnum)
2689 + if (!intf)
2690 + err = -ENOENT;
2691 + else if (test_and_clear_bit(ifnum, &ps->ifclaimed)) {
2692 ++ unsigned int old_suppress;
2693 ++
2694 ++ /* suppress uevents while releasing interface */
2695 ++ old_suppress = dev_get_uevent_suppress(&intf->dev);
2696 ++ dev_set_uevent_suppress(&intf->dev, 1);
2697 + usb_driver_release_interface(&usbfs_driver, intf);
2698 ++ dev_set_uevent_suppress(&intf->dev, old_suppress);
2699 + err = 0;
2700 + }
2701 + return err;
2702 +diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
2703 +index 8f3f055c05fa..477ba3842cc4 100644
2704 +--- a/drivers/usb/host/ehci-q.c
2705 ++++ b/drivers/usb/host/ehci-q.c
2706 +@@ -40,6 +40,10 @@
2707 +
2708 + /*-------------------------------------------------------------------------*/
2709 +
2710 ++/* PID Codes that are used here, from EHCI specification, Table 3-16. */
2711 ++#define PID_CODE_IN 1
2712 ++#define PID_CODE_SETUP 2
2713 ++
2714 + /* fill a qtd, returning how much of the buffer we were able to queue up */
2715 +
2716 + static int
2717 +@@ -203,7 +207,7 @@ static int qtd_copy_status (
2718 + int status = -EINPROGRESS;
2719 +
2720 + /* count IN/OUT bytes, not SETUP (even short packets) */
2721 +- if (likely (QTD_PID (token) != 2))
2722 ++ if (likely(QTD_PID(token) != PID_CODE_SETUP))
2723 + urb->actual_length += length - QTD_LENGTH (token);
2724 +
2725 + /* don't modify error codes */
2726 +@@ -219,6 +223,13 @@ static int qtd_copy_status (
2727 + if (token & QTD_STS_BABBLE) {
2728 + /* FIXME "must" disable babbling device's port too */
2729 + status = -EOVERFLOW;
2730 ++ /*
2731 ++ * When MMF is active and PID Code is IN, queue is halted.
2732 ++ * EHCI Specification, Table 4-13.
2733 ++ */
2734 ++ } else if ((token & QTD_STS_MMF) &&
2735 ++ (QTD_PID(token) == PID_CODE_IN)) {
2736 ++ status = -EPROTO;
2737 + /* CERR nonzero + halt --> stall */
2738 + } else if (QTD_CERR(token)) {
2739 + status = -EPIPE;
2740 +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
2741 +index 021a2d320acc..09f228279c01 100644
2742 +--- a/drivers/usb/host/xhci-pci.c
2743 ++++ b/drivers/usb/host/xhci-pci.c
2744 +@@ -497,7 +497,6 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
2745 + retval = xhci_resume(xhci, hibernated);
2746 + return retval;
2747 + }
2748 +-#endif /* CONFIG_PM */
2749 +
2750 + static void xhci_pci_shutdown(struct usb_hcd *hcd)
2751 + {
2752 +@@ -510,6 +509,7 @@ static void xhci_pci_shutdown(struct usb_hcd *hcd)
2753 + if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
2754 + pci_set_power_state(pdev, PCI_D3hot);
2755 + }
2756 ++#endif /* CONFIG_PM */
2757 +
2758 + /*-------------------------------------------------------------------------*/
2759 +
2760 +diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
2761 +index b8620aa6b72e..8424c165f732 100644
2762 +--- a/drivers/usb/renesas_usbhs/common.h
2763 ++++ b/drivers/usb/renesas_usbhs/common.h
2764 +@@ -163,11 +163,12 @@ struct usbhs_priv;
2765 + #define VBSTS (1 << 7) /* VBUS_0 and VBUSIN_0 Input Status */
2766 + #define VALID (1 << 3) /* USB Request Receive */
2767 +
2768 +-#define DVSQ_MASK (0x3 << 4) /* Device State */
2769 ++#define DVSQ_MASK (0x7 << 4) /* Device State */
2770 + #define POWER_STATE (0 << 4)
2771 + #define DEFAULT_STATE (1 << 4)
2772 + #define ADDRESS_STATE (2 << 4)
2773 + #define CONFIGURATION_STATE (3 << 4)
2774 ++#define SUSPENDED_STATE (4 << 4)
2775 +
2776 + #define CTSQ_MASK (0x7) /* Control Transfer Stage */
2777 + #define IDLE_SETUP_STAGE 0 /* Idle stage or setup stage */
2778 +diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
2779 +index 0dedb0d91dcc..b27f2135b66d 100644
2780 +--- a/drivers/usb/renesas_usbhs/mod_gadget.c
2781 ++++ b/drivers/usb/renesas_usbhs/mod_gadget.c
2782 +@@ -465,12 +465,18 @@ static int usbhsg_irq_dev_state(struct usbhs_priv *priv,
2783 + {
2784 + struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
2785 + struct device *dev = usbhsg_gpriv_to_dev(gpriv);
2786 ++ int state = usbhs_status_get_device_state(irq_state);
2787 +
2788 + gpriv->gadget.speed = usbhs_bus_get_speed(priv);
2789 +
2790 +- dev_dbg(dev, "state = %x : speed : %d\n",
2791 +- usbhs_status_get_device_state(irq_state),
2792 +- gpriv->gadget.speed);
2793 ++ dev_dbg(dev, "state = %x : speed : %d\n", state, gpriv->gadget.speed);
2794 ++
2795 ++ if (gpriv->gadget.speed != USB_SPEED_UNKNOWN &&
2796 ++ (state & SUSPENDED_STATE)) {
2797 ++ if (gpriv->driver && gpriv->driver->suspend)
2798 ++ gpriv->driver->suspend(&gpriv->gadget);
2799 ++ usb_gadget_set_state(&gpriv->gadget, USB_STATE_SUSPENDED);
2800 ++ }
2801 +
2802 + return 0;
2803 + }
2804 +diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
2805 +index da03451328cd..cd01f1e278ee 100644
2806 +--- a/drivers/usb/usbip/usbip_common.c
2807 ++++ b/drivers/usb/usbip/usbip_common.c
2808 +@@ -742,6 +742,9 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb)
2809 +
2810 + copy -= recv;
2811 + ret += recv;
2812 ++
2813 ++ if (!copy)
2814 ++ break;
2815 + }
2816 +
2817 + if (ret != size)
2818 +diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
2819 +index 3f998b605f03..c13dd526b996 100644
2820 +--- a/drivers/usb/usbip/vhci_rx.c
2821 ++++ b/drivers/usb/usbip/vhci_rx.c
2822 +@@ -91,16 +91,21 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
2823 + usbip_pack_pdu(pdu, urb, USBIP_RET_SUBMIT, 0);
2824 +
2825 + /* recv transfer buffer */
2826 +- if (usbip_recv_xbuff(ud, urb) < 0)
2827 +- return;
2828 ++ if (usbip_recv_xbuff(ud, urb) < 0) {
2829 ++ urb->status = -EPROTO;
2830 ++ goto error;
2831 ++ }
2832 +
2833 + /* recv iso_packet_descriptor */
2834 +- if (usbip_recv_iso(ud, urb) < 0)
2835 +- return;
2836 ++ if (usbip_recv_iso(ud, urb) < 0) {
2837 ++ urb->status = -EPROTO;
2838 ++ goto error;
2839 ++ }
2840 +
2841 + /* restore the padding in iso packets */
2842 + usbip_pad_iso(ud, urb);
2843 +
2844 ++error:
2845 + if (usbip_dbg_flag_vhci_rx)
2846 + usbip_dump_urb(urb);
2847 +
2848 +diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
2849 +index e00c8a9fd5bb..72d7589072f5 100644
2850 +--- a/fs/btrfs/async-thread.c
2851 ++++ b/fs/btrfs/async-thread.c
2852 +@@ -265,16 +265,17 @@ out:
2853 + }
2854 + }
2855 +
2856 +-static void run_ordered_work(struct __btrfs_workqueue *wq)
2857 ++static void run_ordered_work(struct __btrfs_workqueue *wq,
2858 ++ struct btrfs_work *self)
2859 + {
2860 + struct list_head *list = &wq->ordered_list;
2861 + struct btrfs_work *work;
2862 + spinlock_t *lock = &wq->list_lock;
2863 + unsigned long flags;
2864 ++ void *wtag;
2865 ++ bool free_self = false;
2866 +
2867 + while (1) {
2868 +- void *wtag;
2869 +-
2870 + spin_lock_irqsave(lock, flags);
2871 + if (list_empty(list))
2872 + break;
2873 +@@ -300,16 +301,47 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
2874 + list_del(&work->ordered_list);
2875 + spin_unlock_irqrestore(lock, flags);
2876 +
2877 +- /*
2878 +- * We don't want to call the ordered free functions with the
2879 +- * lock held though. Save the work as tag for the trace event,
2880 +- * because the callback could free the structure.
2881 +- */
2882 +- wtag = work;
2883 +- work->ordered_free(work);
2884 +- trace_btrfs_all_work_done(wq->fs_info, wtag);
2885 ++ if (work == self) {
2886 ++ /*
2887 ++ * This is the work item that the worker is currently
2888 ++ * executing.
2889 ++ *
2890 ++ * The kernel workqueue code guarantees non-reentrancy
2891 ++ * of work items. I.e., if a work item with the same
2892 ++ * address and work function is queued twice, the second
2893 ++ * execution is blocked until the first one finishes. A
2894 ++ * work item may be freed and recycled with the same
2895 ++ * work function; the workqueue code assumes that the
2896 ++ * original work item cannot depend on the recycled work
2897 ++ * item in that case (see find_worker_executing_work()).
2898 ++ *
2899 ++ * Note that the work of one Btrfs filesystem may depend
2900 ++ * on the work of another Btrfs filesystem via, e.g., a
2901 ++ * loop device. Therefore, we must not allow the current
2902 ++ * work item to be recycled until we are really done,
2903 ++ * otherwise we break the above assumption and can
2904 ++ * deadlock.
2905 ++ */
2906 ++ free_self = true;
2907 ++ } else {
2908 ++ /*
2909 ++ * We don't want to call the ordered free functions with
2910 ++ * the lock held though. Save the work as tag for the
2911 ++ * trace event, because the callback could free the
2912 ++ * structure.
2913 ++ */
2914 ++ wtag = work;
2915 ++ work->ordered_free(work);
2916 ++ trace_btrfs_all_work_done(wq->fs_info, wtag);
2917 ++ }
2918 + }
2919 + spin_unlock_irqrestore(lock, flags);
2920 ++
2921 ++ if (free_self) {
2922 ++ wtag = self;
2923 ++ self->ordered_free(self);
2924 ++ trace_btrfs_all_work_done(wq->fs_info, wtag);
2925 ++ }
2926 + }
2927 +
2928 + static void normal_work_helper(struct btrfs_work *work)
2929 +@@ -337,7 +369,7 @@ static void normal_work_helper(struct btrfs_work *work)
2930 + work->func(work);
2931 + if (need_order) {
2932 + set_bit(WORK_DONE_BIT, &work->flags);
2933 +- run_ordered_work(wq);
2934 ++ run_ordered_work(wq, work);
2935 + }
2936 + if (!need_order)
2937 + trace_btrfs_all_work_done(wq->fs_info, wtag);
2938 +diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
2939 +index d2263caff307..740ef428acdd 100644
2940 +--- a/fs/btrfs/ctree.c
2941 ++++ b/fs/btrfs/ctree.c
2942 +@@ -427,7 +427,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
2943 + for (node = rb_first(tm_root); node; node = next) {
2944 + next = rb_next(node);
2945 + tm = rb_entry(node, struct tree_mod_elem, node);
2946 +- if (tm->seq > min_seq)
2947 ++ if (tm->seq >= min_seq)
2948 + continue;
2949 + rb_erase(node, tm_root);
2950 + kfree(tm);
2951 +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
2952 +index 813834552aa1..a8ea56218d6b 100644
2953 +--- a/fs/btrfs/disk-io.c
2954 ++++ b/fs/btrfs/disk-io.c
2955 +@@ -1679,8 +1679,8 @@ static void end_workqueue_fn(struct btrfs_work *work)
2956 + bio->bi_status = end_io_wq->status;
2957 + bio->bi_private = end_io_wq->private;
2958 + bio->bi_end_io = end_io_wq->end_io;
2959 +- kmem_cache_free(btrfs_end_io_wq_cache, end_io_wq);
2960 + bio_endio(bio);
2961 ++ kmem_cache_free(btrfs_end_io_wq_cache, end_io_wq);
2962 + }
2963 +
2964 + static int cleaner_kthread(void *arg)
2965 +diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
2966 +index 4cc534584665..fced434bbddc 100644
2967 +--- a/fs/btrfs/extent_io.c
2968 ++++ b/fs/btrfs/extent_io.c
2969 +@@ -4949,12 +4949,14 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
2970 + return eb;
2971 + eb = alloc_dummy_extent_buffer(fs_info, start);
2972 + if (!eb)
2973 +- return NULL;
2974 ++ return ERR_PTR(-ENOMEM);
2975 + eb->fs_info = fs_info;
2976 + again:
2977 + ret = radix_tree_preload(GFP_NOFS);
2978 +- if (ret)
2979 ++ if (ret) {
2980 ++ exists = ERR_PTR(ret);
2981 + goto free_eb;
2982 ++ }
2983 + spin_lock(&fs_info->buffer_lock);
2984 + ret = radix_tree_insert(&fs_info->buffer_radix,
2985 + start >> PAGE_SHIFT, eb);
2986 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
2987 +index 739f45b04b52..f2dc517768f0 100644
2988 +--- a/fs/btrfs/inode.c
2989 ++++ b/fs/btrfs/inode.c
2990 +@@ -5729,7 +5729,6 @@ static void inode_tree_add(struct inode *inode)
2991 +
2992 + static void inode_tree_del(struct inode *inode)
2993 + {
2994 +- struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
2995 + struct btrfs_root *root = BTRFS_I(inode)->root;
2996 + int empty = 0;
2997 +
2998 +@@ -5742,7 +5741,6 @@ static void inode_tree_del(struct inode *inode)
2999 + spin_unlock(&root->inode_lock);
3000 +
3001 + if (empty && btrfs_root_refs(&root->root_item) == 0) {
3002 +- synchronize_srcu(&fs_info->subvol_srcu);
3003 + spin_lock(&root->inode_lock);
3004 + empty = RB_EMPTY_ROOT(&root->inode_tree);
3005 + spin_unlock(&root->inode_lock);
3006 +@@ -9820,9 +9818,8 @@ static int btrfs_rename_exchange(struct inode *old_dir,
3007 + return -EXDEV;
3008 +
3009 + /* close the race window with snapshot create/destroy ioctl */
3010 +- if (old_ino == BTRFS_FIRST_FREE_OBJECTID)
3011 +- down_read(&fs_info->subvol_sem);
3012 +- if (new_ino == BTRFS_FIRST_FREE_OBJECTID)
3013 ++ if (old_ino == BTRFS_FIRST_FREE_OBJECTID ||
3014 ++ new_ino == BTRFS_FIRST_FREE_OBJECTID)
3015 + down_read(&fs_info->subvol_sem);
3016 +
3017 + /*
3018 +@@ -10014,9 +10011,8 @@ out_fail:
3019 + ret2 = btrfs_end_transaction(trans);
3020 + ret = ret ? ret : ret2;
3021 + out_notrans:
3022 +- if (new_ino == BTRFS_FIRST_FREE_OBJECTID)
3023 +- up_read(&fs_info->subvol_sem);
3024 +- if (old_ino == BTRFS_FIRST_FREE_OBJECTID)
3025 ++ if (new_ino == BTRFS_FIRST_FREE_OBJECTID ||
3026 ++ old_ino == BTRFS_FIRST_FREE_OBJECTID)
3027 + up_read(&fs_info->subvol_sem);
3028 +
3029 + return ret;
3030 +diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
3031 +index dd3b4820ac30..e82b4f3f490c 100644
3032 +--- a/fs/btrfs/ioctl.c
3033 ++++ b/fs/btrfs/ioctl.c
3034 +@@ -580,12 +580,18 @@ static noinline int create_subvol(struct inode *dir,
3035 +
3036 + btrfs_i_size_write(BTRFS_I(dir), dir->i_size + namelen * 2);
3037 + ret = btrfs_update_inode(trans, root, dir);
3038 +- BUG_ON(ret);
3039 ++ if (ret) {
3040 ++ btrfs_abort_transaction(trans, ret);
3041 ++ goto fail;
3042 ++ }
3043 +
3044 + ret = btrfs_add_root_ref(trans, fs_info,
3045 + objectid, root->root_key.objectid,
3046 + btrfs_ino(BTRFS_I(dir)), index, name, namelen);
3047 +- BUG_ON(ret);
3048 ++ if (ret) {
3049 ++ btrfs_abort_transaction(trans, ret);
3050 ++ goto fail;
3051 ++ }
3052 +
3053 + ret = btrfs_uuid_tree_add(trans, fs_info, root_item->uuid,
3054 + BTRFS_UUID_KEY_SUBVOL, objectid);
3055 +diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
3056 +index 3a4e15b39cc1..440c0d5d2050 100644
3057 +--- a/fs/btrfs/reada.c
3058 ++++ b/fs/btrfs/reada.c
3059 +@@ -734,21 +734,19 @@ static int reada_start_machine_dev(struct btrfs_device *dev)
3060 + static void reada_start_machine_worker(struct btrfs_work *work)
3061 + {
3062 + struct reada_machine_work *rmw;
3063 +- struct btrfs_fs_info *fs_info;
3064 + int old_ioprio;
3065 +
3066 + rmw = container_of(work, struct reada_machine_work, work);
3067 +- fs_info = rmw->fs_info;
3068 +-
3069 +- kfree(rmw);
3070 +
3071 + old_ioprio = IOPRIO_PRIO_VALUE(task_nice_ioclass(current),
3072 + task_nice_ioprio(current));
3073 + set_task_ioprio(current, BTRFS_IOPRIO_READA);
3074 +- __reada_start_machine(fs_info);
3075 ++ __reada_start_machine(rmw->fs_info);
3076 + set_task_ioprio(current, old_ioprio);
3077 +
3078 +- atomic_dec(&fs_info->reada_works_cnt);
3079 ++ atomic_dec(&rmw->fs_info->reada_works_cnt);
3080 ++
3081 ++ kfree(rmw);
3082 + }
3083 +
3084 + static void __reada_start_machine(struct btrfs_fs_info *fs_info)
3085 +diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
3086 +index 9fa6db6a6f7d..d4c00edd16d2 100644
3087 +--- a/fs/btrfs/relocation.c
3088 ++++ b/fs/btrfs/relocation.c
3089 +@@ -4587,6 +4587,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
3090 + fs_root = read_fs_root(fs_info, reloc_root->root_key.offset);
3091 + if (IS_ERR(fs_root)) {
3092 + err = PTR_ERR(fs_root);
3093 ++ list_add_tail(&reloc_root->root_list, &reloc_roots);
3094 + goto out_free;
3095 + }
3096 +
3097 +diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
3098 +index 61192c536e6c..2ebae9773978 100644
3099 +--- a/fs/btrfs/scrub.c
3100 ++++ b/fs/btrfs/scrub.c
3101 +@@ -2421,14 +2421,13 @@ static void scrub_missing_raid56_worker(struct btrfs_work *work)
3102 + scrub_write_block_to_dev_replace(sblock);
3103 + }
3104 +
3105 +- scrub_block_put(sblock);
3106 +-
3107 + if (sctx->is_dev_replace && sctx->flush_all_writes) {
3108 + mutex_lock(&sctx->wr_lock);
3109 + scrub_wr_submit(sctx);
3110 + mutex_unlock(&sctx->wr_lock);
3111 + }
3112 +
3113 ++ scrub_block_put(sblock);
3114 + scrub_pending_bio_dec(sctx);
3115 + }
3116 +
3117 +diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
3118 +index 8444a018cca2..f6c783e959b7 100644
3119 +--- a/fs/btrfs/tests/free-space-tree-tests.c
3120 ++++ b/fs/btrfs/tests/free-space-tree-tests.c
3121 +@@ -475,9 +475,9 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
3122 + root->fs_info->tree_root = root;
3123 +
3124 + root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
3125 +- if (!root->node) {
3126 +- test_msg("Couldn't allocate dummy buffer\n");
3127 +- ret = -ENOMEM;
3128 ++ if (IS_ERR(root->node)) {
3129 ++ test_msg("couldn't allocate dummy buffer\n");
3130 ++ ret = PTR_ERR(root->node);
3131 + goto out;
3132 + }
3133 + btrfs_set_header_level(root->node, 0);
3134 +diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c
3135 +index 578fd045e859..eb72cf280546 100644
3136 +--- a/fs/btrfs/tests/qgroup-tests.c
3137 ++++ b/fs/btrfs/tests/qgroup-tests.c
3138 +@@ -487,9 +487,9 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
3139 + * *cough*backref walking code*cough*
3140 + */
3141 + root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
3142 +- if (!root->node) {
3143 ++ if (IS_ERR(root->node)) {
3144 + test_msg("Couldn't allocate dummy buffer\n");
3145 +- ret = -ENOMEM;
3146 ++ ret = PTR_ERR(root->node);
3147 + goto out;
3148 + }
3149 + btrfs_set_header_level(root->node, 0);
3150 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
3151 +index e35301e5fe8e..98c397eb054c 100644
3152 +--- a/fs/btrfs/tree-log.c
3153 ++++ b/fs/btrfs/tree-log.c
3154 +@@ -6018,9 +6018,28 @@ again:
3155 + wc.replay_dest = btrfs_read_fs_root_no_name(fs_info, &tmp_key);
3156 + if (IS_ERR(wc.replay_dest)) {
3157 + ret = PTR_ERR(wc.replay_dest);
3158 ++
3159 ++ /*
3160 ++ * We didn't find the subvol, likely because it was
3161 ++ * deleted. This is ok, simply skip this log and go to
3162 ++ * the next one.
3163 ++ *
3164 ++ * We need to exclude the root because we can't have
3165 ++ * other log replays overwriting this log as we'll read
3166 ++ * it back in a few more times. This will keep our
3167 ++ * block from being modified, and we'll just bail for
3168 ++ * each subsequent pass.
3169 ++ */
3170 ++ if (ret == -ENOENT)
3171 ++ ret = btrfs_pin_extent_for_log_replay(fs_info,
3172 ++ log->node->start,
3173 ++ log->node->len);
3174 + free_extent_buffer(log->node);
3175 + free_extent_buffer(log->commit_root);
3176 + kfree(log);
3177 ++
3178 ++ if (!ret)
3179 ++ goto next;
3180 + btrfs_handle_fs_error(fs_info, ret,
3181 + "Couldn't read target root for tree log recovery.");
3182 + goto error;
3183 +@@ -6052,7 +6071,6 @@ again:
3184 + &root->highest_objectid);
3185 + }
3186 +
3187 +- key.offset = found_key.offset - 1;
3188 + wc.replay_dest->log_root = NULL;
3189 + free_extent_buffer(log->node);
3190 + free_extent_buffer(log->commit_root);
3191 +@@ -6060,9 +6078,10 @@ again:
3192 +
3193 + if (ret)
3194 + goto error;
3195 +-
3196 ++next:
3197 + if (found_key.offset == 0)
3198 + break;
3199 ++ key.offset = found_key.offset - 1;
3200 + }
3201 + btrfs_release_path(path);
3202 +
3203 +diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
3204 +index 726f928238d0..331f3a1ad23b 100644
3205 +--- a/fs/btrfs/uuid-tree.c
3206 ++++ b/fs/btrfs/uuid-tree.c
3207 +@@ -336,6 +336,8 @@ again_search_slot:
3208 + }
3209 + if (ret < 0 && ret != -ENOENT)
3210 + goto out;
3211 ++ key.offset++;
3212 ++ goto again_search_slot;
3213 + }
3214 + item_size -= sizeof(subid_le);
3215 + offset += sizeof(subid_le);
3216 +diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
3217 +index 446b6c375b6f..c17855fead7b 100644
3218 +--- a/fs/ext4/dir.c
3219 ++++ b/fs/ext4/dir.c
3220 +@@ -76,6 +76,11 @@ int __ext4_check_dir_entry(const char *function, unsigned int line,
3221 + error_msg = "rec_len is too small for name_len";
3222 + else if (unlikely(((char *) de - buf) + rlen > size))
3223 + error_msg = "directory entry overrun";
3224 ++ else if (unlikely(((char *) de - buf) + rlen >
3225 ++ size - EXT4_DIR_REC_LEN(1) &&
3226 ++ ((char *) de - buf) + rlen != size)) {
3227 ++ error_msg = "directory entry too close to block end";
3228 ++ }
3229 + else if (unlikely(le32_to_cpu(de->inode) >
3230 + le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count)))
3231 + error_msg = "inode out of bounds";
3232 +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
3233 +index 11bc4c69bf16..c2920cbfa3bf 100644
3234 +--- a/fs/ext4/inode.c
3235 ++++ b/fs/ext4/inode.c
3236 +@@ -5874,7 +5874,7 @@ int ext4_expand_extra_isize(struct inode *inode,
3237 + error = ext4_journal_get_write_access(handle, iloc->bh);
3238 + if (error) {
3239 + brelse(iloc->bh);
3240 +- goto out_stop;
3241 ++ goto out_unlock;
3242 + }
3243 +
3244 + error = __ext4_expand_extra_isize(inode, new_extra_isize, iloc,
3245 +@@ -5884,8 +5884,8 @@ int ext4_expand_extra_isize(struct inode *inode,
3246 + if (!error)
3247 + error = rc;
3248 +
3249 ++out_unlock:
3250 + ext4_write_unlock_xattr(inode, &no_expand);
3251 +-out_stop:
3252 + ext4_journal_stop(handle);
3253 + return error;
3254 + }
3255 +diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
3256 +index b4e0c270def4..0b5c36bd5418 100644
3257 +--- a/fs/ext4/namei.c
3258 ++++ b/fs/ext4/namei.c
3259 +@@ -2702,7 +2702,7 @@ bool ext4_empty_dir(struct inode *inode)
3260 + {
3261 + unsigned int offset;
3262 + struct buffer_head *bh;
3263 +- struct ext4_dir_entry_2 *de, *de1;
3264 ++ struct ext4_dir_entry_2 *de;
3265 + struct super_block *sb;
3266 +
3267 + if (ext4_has_inline_data(inode)) {
3268 +@@ -2727,19 +2727,25 @@ bool ext4_empty_dir(struct inode *inode)
3269 + return true;
3270 +
3271 + de = (struct ext4_dir_entry_2 *) bh->b_data;
3272 +- de1 = ext4_next_entry(de, sb->s_blocksize);
3273 +- if (le32_to_cpu(de->inode) != inode->i_ino ||
3274 +- le32_to_cpu(de1->inode) == 0 ||
3275 +- strcmp(".", de->name) || strcmp("..", de1->name)) {
3276 +- ext4_warning_inode(inode, "directory missing '.' and/or '..'");
3277 ++ if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data, bh->b_size,
3278 ++ 0) ||
3279 ++ le32_to_cpu(de->inode) != inode->i_ino || strcmp(".", de->name)) {
3280 ++ ext4_warning_inode(inode, "directory missing '.'");
3281 ++ brelse(bh);
3282 ++ return true;
3283 ++ }
3284 ++ offset = ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize);
3285 ++ de = ext4_next_entry(de, sb->s_blocksize);
3286 ++ if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data, bh->b_size,
3287 ++ offset) ||
3288 ++ le32_to_cpu(de->inode) == 0 || strcmp("..", de->name)) {
3289 ++ ext4_warning_inode(inode, "directory missing '..'");
3290 + brelse(bh);
3291 + return true;
3292 + }
3293 +- offset = ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize) +
3294 +- ext4_rec_len_from_disk(de1->rec_len, sb->s_blocksize);
3295 +- de = ext4_next_entry(de1, sb->s_blocksize);
3296 ++ offset += ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize);
3297 + while (offset < inode->i_size) {
3298 +- if ((void *) de >= (void *) (bh->b_data+sb->s_blocksize)) {
3299 ++ if (!(offset & (sb->s_blocksize - 1))) {
3300 + unsigned int lblock;
3301 + brelse(bh);
3302 + lblock = offset >> EXT4_BLOCK_SIZE_BITS(sb);
3303 +@@ -2750,12 +2756,11 @@ bool ext4_empty_dir(struct inode *inode)
3304 + }
3305 + if (IS_ERR(bh))
3306 + return true;
3307 +- de = (struct ext4_dir_entry_2 *) bh->b_data;
3308 + }
3309 ++ de = (struct ext4_dir_entry_2 *) (bh->b_data +
3310 ++ (offset & (sb->s_blocksize - 1)));
3311 + if (ext4_check_dir_entry(inode, NULL, de, bh,
3312 + bh->b_data, bh->b_size, offset)) {
3313 +- de = (struct ext4_dir_entry_2 *)(bh->b_data +
3314 +- sb->s_blocksize);
3315 + offset = (offset | (sb->s_blocksize - 1)) + 1;
3316 + continue;
3317 + }
3318 +@@ -2764,7 +2769,6 @@ bool ext4_empty_dir(struct inode *inode)
3319 + return false;
3320 + }
3321 + offset += ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize);
3322 +- de = ext4_next_entry(de, sb->s_blocksize);
3323 + }
3324 + brelse(bh);
3325 + return true;
3326 +diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
3327 +index d55abb75f29a..eec6cba204ea 100644
3328 +--- a/include/drm/drm_dp_mst_helper.h
3329 ++++ b/include/drm/drm_dp_mst_helper.h
3330 +@@ -313,7 +313,7 @@ struct drm_dp_resource_status_notify {
3331 +
3332 + struct drm_dp_query_payload_ack_reply {
3333 + u8 port_number;
3334 +- u8 allocated_pbn;
3335 ++ u16 allocated_pbn;
3336 + };
3337 +
3338 + struct drm_dp_sideband_msg_req_body {
3339 +diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
3340 +index 4de703d9e21f..5e1e50b8f8c4 100644
3341 +--- a/include/linux/miscdevice.h
3342 ++++ b/include/linux/miscdevice.h
3343 +@@ -56,6 +56,7 @@
3344 + #define UHID_MINOR 239
3345 + #define USERIO_MINOR 240
3346 + #define VHOST_VSOCK_MINOR 241
3347 ++#define RFKILL_MINOR 242
3348 + #define MISC_DYNAMIC_MINOR 255
3349 +
3350 + struct device;
3351 +diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
3352 +index 1c2e8d6b7274..6db347b58644 100644
3353 +--- a/include/linux/mod_devicetable.h
3354 ++++ b/include/linux/mod_devicetable.h
3355 +@@ -519,9 +519,9 @@ struct platform_device_id {
3356 + #define MDIO_NAME_SIZE 32
3357 + #define MDIO_MODULE_PREFIX "mdio:"
3358 +
3359 +-#define MDIO_ID_FMT "%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d"
3360 ++#define MDIO_ID_FMT "%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u%u"
3361 + #define MDIO_ID_ARGS(_id) \
3362 +- (_id)>>31, ((_id)>>30) & 1, ((_id)>>29) & 1, ((_id)>>28) & 1, \
3363 ++ ((_id)>>31) & 1, ((_id)>>30) & 1, ((_id)>>29) & 1, ((_id)>>28) & 1, \
3364 + ((_id)>>27) & 1, ((_id)>>26) & 1, ((_id)>>25) & 1, ((_id)>>24) & 1, \
3365 + ((_id)>>23) & 1, ((_id)>>22) & 1, ((_id)>>21) & 1, ((_id)>>20) & 1, \
3366 + ((_id)>>19) & 1, ((_id)>>18) & 1, ((_id)>>17) & 1, ((_id)>>16) & 1, \
3367 +diff --git a/include/net/dst.h b/include/net/dst.h
3368 +index 2acd670fc86b..fe230dd62c28 100644
3369 +--- a/include/net/dst.h
3370 ++++ b/include/net/dst.h
3371 +@@ -110,7 +110,7 @@ struct dst_entry {
3372 + struct dst_metrics {
3373 + u32 metrics[RTAX_MAX];
3374 + refcount_t refcnt;
3375 +-};
3376 ++} __aligned(4); /* Low pointer bits contain DST_METRICS_FLAGS */
3377 + extern const struct dst_metrics dst_default_metrics;
3378 +
3379 + u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old);
3380 +diff --git a/include/trace/events/wbt.h b/include/trace/events/wbt.h
3381 +index b048694070e2..37342a13c9cb 100644
3382 +--- a/include/trace/events/wbt.h
3383 ++++ b/include/trace/events/wbt.h
3384 +@@ -33,7 +33,8 @@ TRACE_EVENT(wbt_stat,
3385 + ),
3386 +
3387 + TP_fast_assign(
3388 +- strncpy(__entry->name, dev_name(bdi->dev), 32);
3389 ++ strlcpy(__entry->name, dev_name(bdi->dev),
3390 ++ ARRAY_SIZE(__entry->name));
3391 + __entry->rmean = stat[0].mean;
3392 + __entry->rmin = stat[0].min;
3393 + __entry->rmax = stat[0].max;
3394 +@@ -67,7 +68,8 @@ TRACE_EVENT(wbt_lat,
3395 + ),
3396 +
3397 + TP_fast_assign(
3398 +- strncpy(__entry->name, dev_name(bdi->dev), 32);
3399 ++ strlcpy(__entry->name, dev_name(bdi->dev),
3400 ++ ARRAY_SIZE(__entry->name));
3401 + __entry->lat = div_u64(lat, 1000);
3402 + ),
3403 +
3404 +@@ -103,7 +105,8 @@ TRACE_EVENT(wbt_step,
3405 + ),
3406 +
3407 + TP_fast_assign(
3408 +- strncpy(__entry->name, dev_name(bdi->dev), 32);
3409 ++ strlcpy(__entry->name, dev_name(bdi->dev),
3410 ++ ARRAY_SIZE(__entry->name));
3411 + __entry->msg = msg;
3412 + __entry->step = step;
3413 + __entry->window = div_u64(window, 1000);
3414 +@@ -138,7 +141,8 @@ TRACE_EVENT(wbt_timer,
3415 + ),
3416 +
3417 + TP_fast_assign(
3418 +- strncpy(__entry->name, dev_name(bdi->dev), 32);
3419 ++ strlcpy(__entry->name, dev_name(bdi->dev),
3420 ++ ARRAY_SIZE(__entry->name));
3421 + __entry->status = status;
3422 + __entry->step = step;
3423 + __entry->inflight = inflight;
3424 +diff --git a/include/uapi/linux/cec-funcs.h b/include/uapi/linux/cec-funcs.h
3425 +index 28e8a2a86e16..2a114f7a24d4 100644
3426 +--- a/include/uapi/linux/cec-funcs.h
3427 ++++ b/include/uapi/linux/cec-funcs.h
3428 +@@ -952,7 +952,8 @@ static inline void cec_msg_give_deck_status(struct cec_msg *msg,
3429 + msg->len = 3;
3430 + msg->msg[1] = CEC_MSG_GIVE_DECK_STATUS;
3431 + msg->msg[2] = status_req;
3432 +- msg->reply = reply ? CEC_MSG_DECK_STATUS : 0;
3433 ++ msg->reply = (reply && status_req != CEC_OP_STATUS_REQ_OFF) ?
3434 ++ CEC_MSG_DECK_STATUS : 0;
3435 + }
3436 +
3437 + static inline void cec_ops_give_deck_status(const struct cec_msg *msg,
3438 +@@ -1056,7 +1057,8 @@ static inline void cec_msg_give_tuner_device_status(struct cec_msg *msg,
3439 + msg->len = 3;
3440 + msg->msg[1] = CEC_MSG_GIVE_TUNER_DEVICE_STATUS;
3441 + msg->msg[2] = status_req;
3442 +- msg->reply = reply ? CEC_MSG_TUNER_DEVICE_STATUS : 0;
3443 ++ msg->reply = (reply && status_req != CEC_OP_STATUS_REQ_OFF) ?
3444 ++ CEC_MSG_TUNER_DEVICE_STATUS : 0;
3445 + }
3446 +
3447 + static inline void cec_ops_give_tuner_device_status(const struct cec_msg *msg,
3448 +diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
3449 +index 6bc679cd3481..ff80a9d41ce1 100644
3450 +--- a/net/bluetooth/hci_core.c
3451 ++++ b/net/bluetooth/hci_core.c
3452 +@@ -802,8 +802,8 @@ static int hci_init4_req(struct hci_request *req, unsigned long opt)
3453 + if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) {
3454 + struct hci_cp_le_write_def_data_len cp;
3455 +
3456 +- cp.tx_len = hdev->le_max_tx_len;
3457 +- cp.tx_time = hdev->le_max_tx_time;
3458 ++ cp.tx_len = cpu_to_le16(hdev->le_max_tx_len);
3459 ++ cp.tx_time = cpu_to_le16(hdev->le_max_tx_time);
3460 + hci_req_add(req, HCI_OP_LE_WRITE_DEF_DATA_LEN, sizeof(cp), &cp);
3461 + }
3462 +
3463 +@@ -4215,7 +4215,14 @@ static void hci_rx_work(struct work_struct *work)
3464 + hci_send_to_sock(hdev, skb);
3465 + }
3466 +
3467 +- if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) {
3468 ++ /* If the device has been opened in HCI_USER_CHANNEL,
3469 ++ * the userspace has exclusive access to device.
3470 ++ * When device is HCI_INIT, we still need to process
3471 ++ * the data packets to the driver in order
3472 ++ * to complete its setup().
3473 ++ */
3474 ++ if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
3475 ++ !test_bit(HCI_INIT, &hdev->flags)) {
3476 + kfree_skb(skb);
3477 + continue;
3478 + }
3479 +diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
3480 +index b73ac149de34..759329bec399 100644
3481 +--- a/net/bluetooth/hci_request.c
3482 ++++ b/net/bluetooth/hci_request.c
3483 +@@ -1095,6 +1095,14 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr)
3484 +
3485 + instance_flags = get_adv_instance_flags(hdev, instance);
3486 +
3487 ++ /* If instance already has the flags set skip adding it once
3488 ++ * again.
3489 ++ */
3490 ++ if (adv_instance && eir_get_data(adv_instance->adv_data,
3491 ++ adv_instance->adv_data_len, EIR_FLAGS,
3492 ++ NULL))
3493 ++ goto skip_flags;
3494 ++
3495 + /* The Add Advertising command allows userspace to set both the general
3496 + * and limited discoverable flags.
3497 + */
3498 +@@ -1127,6 +1135,7 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr)
3499 + }
3500 + }
3501 +
3502 ++skip_flags:
3503 + if (adv_instance) {
3504 + memcpy(ptr, adv_instance->adv_data,
3505 + adv_instance->adv_data_len);
3506 +diff --git a/net/mac80211/status.c b/net/mac80211/status.c
3507 +index b18466cf466c..fbe7354aeac7 100644
3508 +--- a/net/mac80211/status.c
3509 ++++ b/net/mac80211/status.c
3510 +@@ -856,7 +856,8 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
3511 + I802_DEBUG_INC(local->dot11FailedCount);
3512 + }
3513 +
3514 +- if (ieee80211_is_nullfunc(fc) && ieee80211_has_pm(fc) &&
3515 ++ if ((ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc)) &&
3516 ++ ieee80211_has_pm(fc) &&
3517 + ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS) &&
3518 + !(info->flags & IEEE80211_TX_CTL_INJECTED) &&
3519 + local->ps_sdata && !(local->scanning)) {
3520 +diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c
3521 +index 8d104c1db628..6f5addb5225c 100644
3522 +--- a/net/nfc/nci/uart.c
3523 ++++ b/net/nfc/nci/uart.c
3524 +@@ -348,7 +348,7 @@ static int nci_uart_default_recv_buf(struct nci_uart *nu, const u8 *data,
3525 + nu->rx_packet_len = -1;
3526 + nu->rx_skb = nci_skb_alloc(nu->ndev,
3527 + NCI_MAX_PACKET_SIZE,
3528 +- GFP_KERNEL);
3529 ++ GFP_ATOMIC);
3530 + if (!nu->rx_skb)
3531 + return -ENOMEM;
3532 + }
3533 +diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
3534 +index 1f86bf0d1649..4e1058159b08 100644
3535 +--- a/net/packet/af_packet.c
3536 ++++ b/net/packet/af_packet.c
3537 +@@ -593,7 +593,8 @@ static int prb_calc_retire_blk_tmo(struct packet_sock *po,
3538 + msec = 1;
3539 + div = ecmd.base.speed / 1000;
3540 + }
3541 +- }
3542 ++ } else
3543 ++ return DEFAULT_PRB_RETIRE_TOV;
3544 +
3545 + mbits = (blk_size_in_bytes * 8) / (1024 * 1024);
3546 +
3547 +diff --git a/net/rfkill/core.c b/net/rfkill/core.c
3548 +index 2064c3a35ef8..99a2e55b01cf 100644
3549 +--- a/net/rfkill/core.c
3550 ++++ b/net/rfkill/core.c
3551 +@@ -1312,10 +1312,12 @@ static const struct file_operations rfkill_fops = {
3552 + .llseek = no_llseek,
3553 + };
3554 +
3555 ++#define RFKILL_NAME "rfkill"
3556 ++
3557 + static struct miscdevice rfkill_miscdev = {
3558 +- .name = "rfkill",
3559 + .fops = &rfkill_fops,
3560 +- .minor = MISC_DYNAMIC_MINOR,
3561 ++ .name = RFKILL_NAME,
3562 ++ .minor = RFKILL_MINOR,
3563 + };
3564 +
3565 + static int __init rfkill_init(void)
3566 +@@ -1367,3 +1369,6 @@ static void __exit rfkill_exit(void)
3567 + class_unregister(&rfkill_class);
3568 + }
3569 + module_exit(rfkill_exit);
3570 ++
3571 ++MODULE_ALIAS_MISCDEV(RFKILL_MINOR);
3572 ++MODULE_ALIAS("devname:" RFKILL_NAME);
3573 +diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
3574 +index 01f88e9abbc6..bf39f317953a 100644
3575 +--- a/net/sctp/protocol.c
3576 ++++ b/net/sctp/protocol.c
3577 +@@ -253,6 +253,7 @@ static void sctp_v4_from_skb(union sctp_addr *addr, struct sk_buff *skb,
3578 + sa->sin_port = sh->dest;
3579 + sa->sin_addr.s_addr = ip_hdr(skb)->daddr;
3580 + }
3581 ++ memset(sa->sin_zero, 0, sizeof(sa->sin_zero));
3582 + }
3583 +
3584 + /* Initialize an sctp_addr from a socket. */
3585 +@@ -261,6 +262,7 @@ static void sctp_v4_from_sk(union sctp_addr *addr, struct sock *sk)
3586 + addr->v4.sin_family = AF_INET;
3587 + addr->v4.sin_port = 0;
3588 + addr->v4.sin_addr.s_addr = inet_sk(sk)->inet_rcv_saddr;
3589 ++ memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero));
3590 + }
3591 +
3592 + /* Initialize sk->sk_rcv_saddr from sctp_addr. */
3593 +@@ -283,6 +285,7 @@ static void sctp_v4_from_addr_param(union sctp_addr *addr,
3594 + addr->v4.sin_family = AF_INET;
3595 + addr->v4.sin_port = port;
3596 + addr->v4.sin_addr.s_addr = param->v4.addr.s_addr;
3597 ++ memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero));
3598 + }
3599 +
3600 + /* Initialize an address parameter from a sctp_addr and return the length
3601 +@@ -307,6 +310,7 @@ static void sctp_v4_dst_saddr(union sctp_addr *saddr, struct flowi4 *fl4,
3602 + saddr->v4.sin_family = AF_INET;
3603 + saddr->v4.sin_port = port;
3604 + saddr->v4.sin_addr.s_addr = fl4->saddr;
3605 ++ memset(saddr->v4.sin_zero, 0, sizeof(saddr->v4.sin_zero));
3606 + }
3607 +
3608 + /* Compare two addresses exactly. */
3609 +@@ -329,6 +333,7 @@ static void sctp_v4_inaddr_any(union sctp_addr *addr, __be16 port)
3610 + addr->v4.sin_family = AF_INET;
3611 + addr->v4.sin_addr.s_addr = htonl(INADDR_ANY);
3612 + addr->v4.sin_port = port;
3613 ++ memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero));
3614 + }
3615 +
3616 + /* Is this a wildcard address? */
3617 +diff --git a/samples/bpf/cgroup_helpers.c b/samples/bpf/cgroup_helpers.c
3618 +index 09afaddfc9ba..b5c09cd6c7bd 100644
3619 +--- a/samples/bpf/cgroup_helpers.c
3620 ++++ b/samples/bpf/cgroup_helpers.c
3621 +@@ -43,7 +43,7 @@
3622 + */
3623 + int setup_cgroup_environment(void)
3624 + {
3625 +- char cgroup_workdir[PATH_MAX + 1];
3626 ++ char cgroup_workdir[PATH_MAX - 24];
3627 +
3628 + format_cgroup_path(cgroup_workdir, "");
3629 +
3630 +diff --git a/samples/pktgen/functions.sh b/samples/pktgen/functions.sh
3631 +index 205e4cde4601..065a7e296ee3 100644
3632 +--- a/samples/pktgen/functions.sh
3633 ++++ b/samples/pktgen/functions.sh
3634 +@@ -5,6 +5,8 @@
3635 + # Author: Jesper Dangaaard Brouer
3636 + # License: GPL
3637 +
3638 ++set -o errexit
3639 ++
3640 + ## -- General shell logging cmds --
3641 + function err() {
3642 + local exitcode=$1
3643 +@@ -58,6 +60,7 @@ function pg_set() {
3644 + function proc_cmd() {
3645 + local result
3646 + local proc_file=$1
3647 ++ local status=0
3648 + # after shift, the remaining args are contained in $@
3649 + shift
3650 + local proc_ctrl=${PROC_DIR}/$proc_file
3651 +@@ -73,13 +76,13 @@ function proc_cmd() {
3652 + echo "cmd: $@ > $proc_ctrl"
3653 + fi
3654 + # Quoting of "$@" is important for space expansion
3655 +- echo "$@" > "$proc_ctrl"
3656 +- local status=$?
3657 ++ echo "$@" > "$proc_ctrl" || status=$?
3658 +
3659 +- result=$(grep "Result: OK:" $proc_ctrl)
3660 +- # Due to pgctrl, cannot use exit code $? from grep
3661 +- if [[ "$result" == "" ]]; then
3662 +- grep "Result:" $proc_ctrl >&2
3663 ++ if [[ "$proc_file" != "pgctrl" ]]; then
3664 ++ result=$(grep "Result: OK:" $proc_ctrl) || true
3665 ++ if [[ "$result" == "" ]]; then
3666 ++ grep "Result:" $proc_ctrl >&2
3667 ++ fi
3668 + fi
3669 + if (( $status != 0 )); then
3670 + err 5 "Write error($status) occurred cmd: \"$@ > $proc_ctrl\""
3671 +@@ -105,6 +108,8 @@ function pgset() {
3672 + fi
3673 + }
3674 +
3675 ++[[ $EUID -eq 0 ]] && trap 'pg_ctrl "reset"' EXIT
3676 ++
3677 + ## -- General shell tricks --
3678 +
3679 + function root_check_run_with_sudo() {
3680 +diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
3681 +index 182e4afd21eb..14b1ee29509d 100644
3682 +--- a/sound/core/pcm_native.c
3683 ++++ b/sound/core/pcm_native.c
3684 +@@ -720,6 +720,10 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
3685 + while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size)
3686 + runtime->boundary *= 2;
3687 +
3688 ++ /* clear the buffer for avoiding possible kernel info leaks */
3689 ++ if (runtime->dma_area && !substream->ops->copy_user)
3690 ++ memset(runtime->dma_area, 0, runtime->dma_bytes);
3691 ++
3692 + snd_pcm_timer_resolution_change(substream);
3693 + snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP);
3694 +
3695 +diff --git a/sound/core/timer.c b/sound/core/timer.c
3696 +index c60dfd52e8a6..22589a073423 100644
3697 +--- a/sound/core/timer.c
3698 ++++ b/sound/core/timer.c
3699 +@@ -88,6 +88,9 @@ static LIST_HEAD(snd_timer_slave_list);
3700 + /* lock for slave active lists */
3701 + static DEFINE_SPINLOCK(slave_active_lock);
3702 +
3703 ++#define MAX_SLAVE_INSTANCES 1000
3704 ++static int num_slaves;
3705 ++
3706 + static DEFINE_MUTEX(register_mutex);
3707 +
3708 + static int snd_timer_free(struct snd_timer *timer);
3709 +@@ -266,6 +269,10 @@ int snd_timer_open(struct snd_timer_instance **ti,
3710 + err = -EINVAL;
3711 + goto unlock;
3712 + }
3713 ++ if (num_slaves >= MAX_SLAVE_INSTANCES) {
3714 ++ err = -EBUSY;
3715 ++ goto unlock;
3716 ++ }
3717 + timeri = snd_timer_instance_new(owner, NULL);
3718 + if (!timeri) {
3719 + err = -ENOMEM;
3720 +@@ -275,6 +282,7 @@ int snd_timer_open(struct snd_timer_instance **ti,
3721 + timeri->slave_id = tid->device;
3722 + timeri->flags |= SNDRV_TIMER_IFLG_SLAVE;
3723 + list_add_tail(&timeri->open_list, &snd_timer_slave_list);
3724 ++ num_slaves++;
3725 + err = snd_timer_check_slave(timeri);
3726 + if (err < 0) {
3727 + snd_timer_close_locked(timeri, &card_dev_to_put);
3728 +@@ -364,6 +372,8 @@ static int snd_timer_close_locked(struct snd_timer_instance *timeri,
3729 + struct snd_timer_instance *slave, *tmp;
3730 +
3731 + list_del(&timeri->open_list);
3732 ++ if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE)
3733 ++ num_slaves--;
3734 +
3735 + /* force to stop the timer */
3736 + snd_timer_stop(timeri);
3737 +diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
3738 +index 9876d8dc2ede..92f5f452bee2 100644
3739 +--- a/sound/pci/hda/patch_ca0132.c
3740 ++++ b/sound/pci/hda/patch_ca0132.c
3741 +@@ -1300,13 +1300,14 @@ struct scp_msg {
3742 +
3743 + static void dspio_clear_response_queue(struct hda_codec *codec)
3744 + {
3745 ++ unsigned long timeout = jiffies + msecs_to_jiffies(1000);
3746 + unsigned int dummy = 0;
3747 +- int status = -1;
3748 ++ int status;
3749 +
3750 + /* clear all from the response queue */
3751 + do {
3752 + status = dspio_read(codec, &dummy);
3753 +- } while (status == 0);
3754 ++ } while (status == 0 && time_before(jiffies, timeout));
3755 + }
3756 +
3757 + static int dspio_get_response_data(struct hda_codec *codec)
3758 +@@ -4424,12 +4425,14 @@ static void ca0132_process_dsp_response(struct hda_codec *codec,
3759 + struct ca0132_spec *spec = codec->spec;
3760 +
3761 + codec_dbg(codec, "ca0132_process_dsp_response\n");
3762 ++ snd_hda_power_up_pm(codec);
3763 + if (spec->wait_scp) {
3764 + if (dspio_get_response_data(codec) >= 0)
3765 + spec->wait_scp = 0;
3766 + }
3767 +
3768 + dspio_clear_response_queue(codec);
3769 ++ snd_hda_power_down_pm(codec);
3770 + }
3771 +
3772 + static void hp_callback(struct hda_codec *codec, struct hda_jack_callback *cb)
3773 +diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
3774 +index 1cd20b88a3a9..82ee8f4b965b 100644
3775 +--- a/sound/soc/codecs/rt5677.c
3776 ++++ b/sound/soc/codecs/rt5677.c
3777 +@@ -297,6 +297,7 @@ static bool rt5677_volatile_register(struct device *dev, unsigned int reg)
3778 + case RT5677_I2C_MASTER_CTRL7:
3779 + case RT5677_I2C_MASTER_CTRL8:
3780 + case RT5677_HAP_GENE_CTRL2:
3781 ++ case RT5677_PWR_ANLG2: /* Modified by DSP firmware */
3782 + case RT5677_PWR_DSP_ST:
3783 + case RT5677_PRIV_DATA:
3784 + case RT5677_ASRC_22:
3785 +diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
3786 +index 41cb1fefbd42..405196283688 100644
3787 +--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
3788 ++++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
3789 +@@ -422,6 +422,9 @@ static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
3790 + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
3791 + dmic_constraints);
3792 +
3793 ++ runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
3794 ++ snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
3795 ++
3796 + return snd_pcm_hw_constraint_list(substream->runtime, 0,
3797 + SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
3798 + }
3799 +diff --git a/tools/lib/subcmd/Makefile b/tools/lib/subcmd/Makefile
3800 +index 5b2cd5e58df0..5dbb0dde208c 100644
3801 +--- a/tools/lib/subcmd/Makefile
3802 ++++ b/tools/lib/subcmd/Makefile
3803 +@@ -28,7 +28,9 @@ ifeq ($(DEBUG),0)
3804 + endif
3805 + endif
3806 +
3807 +-ifeq ($(CC_NO_CLANG), 0)
3808 ++ifeq ($(DEBUG),1)
3809 ++ CFLAGS += -O0
3810 ++else ifeq ($(CC_NO_CLANG), 0)
3811 + CFLAGS += -O3
3812 + else
3813 + CFLAGS += -O6
3814 +diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
3815 +index 5e10ba796a6f..569bceff5f51 100644
3816 +--- a/tools/lib/traceevent/parse-filter.c
3817 ++++ b/tools/lib/traceevent/parse-filter.c
3818 +@@ -1492,8 +1492,10 @@ static int copy_filter_type(struct event_filter *filter,
3819 + if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
3820 + /* Add trivial event */
3821 + arg = allocate_arg();
3822 +- if (arg == NULL)
3823 ++ if (arg == NULL) {
3824 ++ free(str);
3825 + return -1;
3826 ++ }
3827 +
3828 + arg->type = FILTER_ARG_BOOLEAN;
3829 + if (strcmp(str, "TRUE") == 0)
3830 +@@ -1502,8 +1504,11 @@ static int copy_filter_type(struct event_filter *filter,
3831 + arg->boolean.value = 0;
3832 +
3833 + filter_type = add_filter_type(filter, event->id);
3834 +- if (filter_type == NULL)
3835 ++ if (filter_type == NULL) {
3836 ++ free(str);
3837 ++ free_arg(arg);
3838 + return -1;
3839 ++ }
3840 +
3841 + filter_type->filter = arg;
3842 +
3843 +diff --git a/tools/objtool/arch/x86/lib/x86-opcode-map.txt b/tools/objtool/arch/x86/lib/x86-opcode-map.txt
3844 +index e0b85930dd77..0a0e9112f284 100644
3845 +--- a/tools/objtool/arch/x86/lib/x86-opcode-map.txt
3846 ++++ b/tools/objtool/arch/x86/lib/x86-opcode-map.txt
3847 +@@ -333,7 +333,7 @@ AVXcode: 1
3848 + 06: CLTS
3849 + 07: SYSRET (o64)
3850 + 08: INVD
3851 +-09: WBINVD
3852 ++09: WBINVD | WBNOINVD (F3)
3853 + 0a:
3854 + 0b: UD2 (1B)
3855 + 0c:
3856 +@@ -364,7 +364,7 @@ AVXcode: 1
3857 + # a ModR/M byte.
3858 + 1a: BNDCL Gv,Ev (F3) | BNDCU Gv,Ev (F2) | BNDMOV Gv,Ev (66) | BNDLDX Gv,Ev
3859 + 1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv
3860 +-1c:
3861 ++1c: Grp20 (1A),(1C)
3862 + 1d:
3863 + 1e:
3864 + 1f: NOP Ev
3865 +@@ -792,6 +792,8 @@ f3: Grp17 (1A)
3866 + f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v)
3867 + f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v)
3868 + f7: BEXTR Gy,Ey,By (v) | SHLX Gy,Ey,By (66),(v) | SARX Gy,Ey,By (F3),(v) | SHRX Gy,Ey,By (F2),(v)
3869 ++f8: MOVDIR64B Gv,Mdqq (66) | ENQCMD Gv,Mdqq (F2) | ENQCMDS Gv,Mdqq (F3)
3870 ++f9: MOVDIRI My,Gy
3871 + EndTable
3872 +
3873 + Table: 3-byte opcode 2 (0x0f 0x3a)
3874 +@@ -943,9 +945,9 @@ GrpTable: Grp6
3875 + EndTable
3876 +
3877 + GrpTable: Grp7
3878 +-0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B)
3879 +-1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B)
3880 +-2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B)
3881 ++0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B) | PCONFIG (101),(11B) | ENCLV (000),(11B)
3882 ++1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B) | ENCLS (111),(11B)
3883 ++2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B) | ENCLU (111),(11B)
3884 + 3: LIDT Ms
3885 + 4: SMSW Mw/Rv
3886 + 5: rdpkru (110),(11B) | wrpkru (111),(11B)
3887 +@@ -1020,7 +1022,7 @@ GrpTable: Grp15
3888 + 3: vstmxcsr Md (v1) | WRGSBASE Ry (F3),(11B)
3889 + 4: XSAVE | ptwrite Ey (F3),(11B)
3890 + 5: XRSTOR | lfence (11B)
3891 +-6: XSAVEOPT | clwb (66) | mfence (11B)
3892 ++6: XSAVEOPT | clwb (66) | mfence (11B) | TPAUSE Rd (66),(11B) | UMONITOR Rv (F3),(11B) | UMWAIT Rd (F2),(11B)
3893 + 7: clflush | clflushopt (66) | sfence (11B)
3894 + EndTable
3895 +
3896 +@@ -1051,6 +1053,10 @@ GrpTable: Grp19
3897 + 6: vscatterpf1qps/d Wx (66),(ev)
3898 + EndTable
3899 +
3900 ++GrpTable: Grp20
3901 ++0: cldemote Mb
3902 ++EndTable
3903 ++
3904 + # AMD's Prefetch Group
3905 + GrpTable: GrpP
3906 + 0: PREFETCH
3907 +diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
3908 +index 4ddb0726eebc..fd4dd12b8f9d 100644
3909 +--- a/tools/perf/builtin-report.c
3910 ++++ b/tools/perf/builtin-report.c
3911 +@@ -342,6 +342,13 @@ static int report__setup_sample_type(struct report *rep)
3912 + PERF_SAMPLE_BRANCH_ANY))
3913 + rep->nonany_branch_mode = true;
3914 +
3915 ++#ifndef HAVE_LIBUNWIND_SUPPORT
3916 ++ if (dwarf_callchain_users) {
3917 ++ ui__warning("Please install libunwind development packages "
3918 ++ "during the perf build.\n");
3919 ++ }
3920 ++#endif
3921 ++
3922 + return 0;
3923 + }
3924 +
3925 +diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
3926 +index 89c8e1604ca7..94fe5464bc6f 100644
3927 +--- a/tools/perf/tests/task-exit.c
3928 ++++ b/tools/perf/tests/task-exit.c
3929 +@@ -104,6 +104,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
3930 + if (perf_evlist__mmap(evlist, 128, true) < 0) {
3931 + pr_debug("failed to mmap events: %d (%s)\n", errno,
3932 + str_error_r(errno, sbuf, sizeof(sbuf)));
3933 ++ err = -1;
3934 + goto out_delete_evlist;
3935 + }
3936 +
3937 +diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
3938 +index f5acda13dcfa..289ef63208fb 100644
3939 +--- a/tools/perf/util/dwarf-aux.c
3940 ++++ b/tools/perf/util/dwarf-aux.c
3941 +@@ -320,21 +320,51 @@ bool die_is_func_def(Dwarf_Die *dw_die)
3942 + dwarf_attr(dw_die, DW_AT_declaration, &attr) == NULL);
3943 + }
3944 +
3945 ++/**
3946 ++ * die_entrypc - Returns entry PC (the lowest address) of a DIE
3947 ++ * @dw_die: a DIE
3948 ++ * @addr: where to store entry PC
3949 ++ *
3950 ++ * Since dwarf_entrypc() does not return entry PC if the DIE has only address
3951 ++ * range, we have to use this to retrieve the lowest address from the address
3952 ++ * range attribute.
3953 ++ */
3954 ++int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr)
3955 ++{
3956 ++ Dwarf_Addr base, end;
3957 ++
3958 ++ if (!addr)
3959 ++ return -EINVAL;
3960 ++
3961 ++ if (dwarf_entrypc(dw_die, addr) == 0)
3962 ++ return 0;
3963 ++
3964 ++ return dwarf_ranges(dw_die, 0, &base, addr, &end) < 0 ? -ENOENT : 0;
3965 ++}
3966 ++
3967 + /**
3968 + * die_is_func_instance - Ensure that this DIE is an instance of a subprogram
3969 + * @dw_die: a DIE
3970 + *
3971 + * Ensure that this DIE is an instance (which has an entry address).
3972 +- * This returns true if @dw_die is a function instance. If not, you need to
3973 +- * call die_walk_instances() to find actual instances.
3974 ++ * This returns true if @dw_die is a function instance. If not, the @dw_die
3975 ++ * must be a prototype. You can use die_walk_instances() to find actual
3976 ++ * instances.
3977 + **/
3978 + bool die_is_func_instance(Dwarf_Die *dw_die)
3979 + {
3980 + Dwarf_Addr tmp;
3981 ++ Dwarf_Attribute attr_mem;
3982 ++ int tag = dwarf_tag(dw_die);
3983 +
3984 +- /* Actually gcc optimizes non-inline as like as inlined */
3985 +- return !dwarf_func_inline(dw_die) && dwarf_entrypc(dw_die, &tmp) == 0;
3986 ++ if (tag != DW_TAG_subprogram &&
3987 ++ tag != DW_TAG_inlined_subroutine)
3988 ++ return false;
3989 ++
3990 ++ return dwarf_entrypc(dw_die, &tmp) == 0 ||
3991 ++ dwarf_attr(dw_die, DW_AT_ranges, &attr_mem) != NULL;
3992 + }
3993 ++
3994 + /**
3995 + * die_get_data_member_location - Get the data-member offset
3996 + * @mb_die: a DIE of a member of a data structure
3997 +@@ -611,6 +641,9 @@ static int __die_walk_instances_cb(Dwarf_Die *inst, void *data)
3998 + Dwarf_Die *origin;
3999 + int tmp;
4000 +
4001 ++ if (!die_is_func_instance(inst))
4002 ++ return DIE_FIND_CB_CONTINUE;
4003 ++
4004 + attr = dwarf_attr(inst, DW_AT_abstract_origin, &attr_mem);
4005 + if (attr == NULL)
4006 + return DIE_FIND_CB_CONTINUE;
4007 +@@ -682,15 +715,14 @@ static int __die_walk_funclines_cb(Dwarf_Die *in_die, void *data)
4008 + if (dwarf_tag(in_die) == DW_TAG_inlined_subroutine) {
4009 + fname = die_get_call_file(in_die);
4010 + lineno = die_get_call_lineno(in_die);
4011 +- if (fname && lineno > 0 && dwarf_entrypc(in_die, &addr) == 0) {
4012 ++ if (fname && lineno > 0 && die_entrypc(in_die, &addr) == 0) {
4013 + lw->retval = lw->callback(fname, lineno, addr, lw->data);
4014 + if (lw->retval != 0)
4015 + return DIE_FIND_CB_END;
4016 + }
4017 ++ if (!lw->recursive)
4018 ++ return DIE_FIND_CB_SIBLING;
4019 + }
4020 +- if (!lw->recursive)
4021 +- /* Don't need to search recursively */
4022 +- return DIE_FIND_CB_SIBLING;
4023 +
4024 + if (addr) {
4025 + fname = dwarf_decl_file(in_die);
4026 +@@ -723,7 +755,7 @@ static int __die_walk_funclines(Dwarf_Die *sp_die, bool recursive,
4027 + /* Handle function declaration line */
4028 + fname = dwarf_decl_file(sp_die);
4029 + if (fname && dwarf_decl_line(sp_die, &lineno) == 0 &&
4030 +- dwarf_entrypc(sp_die, &addr) == 0) {
4031 ++ die_entrypc(sp_die, &addr) == 0) {
4032 + lw.retval = callback(fname, lineno, addr, data);
4033 + if (lw.retval != 0)
4034 + goto done;
4035 +@@ -737,6 +769,10 @@ static int __die_walk_culines_cb(Dwarf_Die *sp_die, void *data)
4036 + {
4037 + struct __line_walk_param *lw = data;
4038 +
4039 ++ /*
4040 ++ * Since inlined function can include another inlined function in
4041 ++ * the same file, we need to walk in it recursively.
4042 ++ */
4043 + lw->retval = __die_walk_funclines(sp_die, true, lw->callback, lw->data);
4044 + if (lw->retval != 0)
4045 + return DWARF_CB_ABORT;
4046 +@@ -761,11 +797,12 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
4047 + Dwarf_Lines *lines;
4048 + Dwarf_Line *line;
4049 + Dwarf_Addr addr;
4050 +- const char *fname, *decf = NULL;
4051 ++ const char *fname, *decf = NULL, *inf = NULL;
4052 + int lineno, ret = 0;
4053 + int decl = 0, inl;
4054 + Dwarf_Die die_mem, *cu_die;
4055 + size_t nlines, i;
4056 ++ bool flag;
4057 +
4058 + /* Get the CU die */
4059 + if (dwarf_tag(rt_die) != DW_TAG_compile_unit) {
4060 +@@ -796,6 +833,12 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
4061 + "Possible error in debuginfo.\n");
4062 + continue;
4063 + }
4064 ++ /* Skip end-of-sequence */
4065 ++ if (dwarf_lineendsequence(line, &flag) != 0 || flag)
4066 ++ continue;
4067 ++ /* Skip Non statement line-info */
4068 ++ if (dwarf_linebeginstatement(line, &flag) != 0 || !flag)
4069 ++ continue;
4070 + /* Filter lines based on address */
4071 + if (rt_die != cu_die) {
4072 + /*
4073 +@@ -805,13 +848,21 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
4074 + */
4075 + if (!dwarf_haspc(rt_die, addr))
4076 + continue;
4077 ++
4078 + if (die_find_inlinefunc(rt_die, addr, &die_mem)) {
4079 ++ /* Call-site check */
4080 ++ inf = die_get_call_file(&die_mem);
4081 ++ if ((inf && !strcmp(inf, decf)) &&
4082 ++ die_get_call_lineno(&die_mem) == lineno)
4083 ++ goto found;
4084 ++
4085 + dwarf_decl_line(&die_mem, &inl);
4086 + if (inl != decl ||
4087 + decf != dwarf_decl_file(&die_mem))
4088 + continue;
4089 + }
4090 + }
4091 ++found:
4092 + /* Get source line */
4093 + fname = dwarf_linesrc(line, NULL, NULL);
4094 +
4095 +@@ -826,8 +877,9 @@ int die_walk_lines(Dwarf_Die *rt_die, line_walk_callback_t callback, void *data)
4096 + */
4097 + if (rt_die != cu_die)
4098 + /*
4099 +- * Don't need walk functions recursively, because nested
4100 +- * inlined functions don't have lines of the specified DIE.
4101 ++ * Don't need walk inlined functions recursively, because
4102 ++ * inner inlined functions don't have the lines of the
4103 ++ * specified function.
4104 + */
4105 + ret = __die_walk_funclines(rt_die, false, callback, data);
4106 + else {
4107 +@@ -1002,7 +1054,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die,
4108 + bool first = true;
4109 + const char *name;
4110 +
4111 +- ret = dwarf_entrypc(sp_die, &entry);
4112 ++ ret = die_entrypc(sp_die, &entry);
4113 + if (ret)
4114 + return ret;
4115 +
4116 +@@ -1065,7 +1117,7 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)
4117 + bool first = true;
4118 + const char *name;
4119 +
4120 +- ret = dwarf_entrypc(sp_die, &entry);
4121 ++ ret = die_entrypc(sp_die, &entry);
4122 + if (ret)
4123 + return ret;
4124 +
4125 +diff --git a/tools/perf/util/dwarf-aux.h b/tools/perf/util/dwarf-aux.h
4126 +index 8ac53bf1ec4e..ee15fac4e1d0 100644
4127 +--- a/tools/perf/util/dwarf-aux.h
4128 ++++ b/tools/perf/util/dwarf-aux.h
4129 +@@ -41,6 +41,9 @@ int cu_walk_functions_at(Dwarf_Die *cu_die, Dwarf_Addr addr,
4130 + /* Get DW_AT_linkage_name (should be NULL for C binary) */
4131 + const char *die_get_linkage_name(Dwarf_Die *dw_die);
4132 +
4133 ++/* Get the lowest PC in DIE (including range list) */
4134 ++int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr);
4135 ++
4136 + /* Ensure that this DIE is a subprogram and definition (not declaration) */
4137 + bool die_is_func_def(Dwarf_Die *dw_die);
4138 +
4139 +diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
4140 +index 29e2bb304168..096c52f296d7 100644
4141 +--- a/tools/perf/util/parse-events.c
4142 ++++ b/tools/perf/util/parse-events.c
4143 +@@ -1253,8 +1253,15 @@ static int __parse_events_add_pmu(struct parse_events_state *parse_state,
4144 + if (get_config_terms(head_config, &config_terms))
4145 + return -ENOMEM;
4146 +
4147 +- if (perf_pmu__config(pmu, &attr, head_config, parse_state->error))
4148 ++ if (perf_pmu__config(pmu, &attr, head_config, parse_state->error)) {
4149 ++ struct perf_evsel_config_term *pos, *tmp;
4150 ++
4151 ++ list_for_each_entry_safe(pos, tmp, &config_terms, list) {
4152 ++ list_del_init(&pos->list);
4153 ++ free(pos);
4154 ++ }
4155 + return -EINVAL;
4156 ++ }
4157 +
4158 + evsel = __add_event(list, &parse_state->idx, &attr,
4159 + get_config_name(head_config), pmu,
4160 +diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
4161 +index a5731de0e5eb..30a5e92b67bd 100644
4162 +--- a/tools/perf/util/probe-finder.c
4163 ++++ b/tools/perf/util/probe-finder.c
4164 +@@ -767,6 +767,16 @@ static int find_best_scope_cb(Dwarf_Die *fn_die, void *data)
4165 + return 0;
4166 + }
4167 +
4168 ++/* Return innermost DIE */
4169 ++static int find_inner_scope_cb(Dwarf_Die *fn_die, void *data)
4170 ++{
4171 ++ struct find_scope_param *fsp = data;
4172 ++
4173 ++ memcpy(fsp->die_mem, fn_die, sizeof(Dwarf_Die));
4174 ++ fsp->found = true;
4175 ++ return 1;
4176 ++}
4177 ++
4178 + /* Find an appropriate scope fits to given conditions */
4179 + static Dwarf_Die *find_best_scope(struct probe_finder *pf, Dwarf_Die *die_mem)
4180 + {
4181 +@@ -778,8 +788,13 @@ static Dwarf_Die *find_best_scope(struct probe_finder *pf, Dwarf_Die *die_mem)
4182 + .die_mem = die_mem,
4183 + .found = false,
4184 + };
4185 ++ int ret;
4186 +
4187 +- cu_walk_functions_at(&pf->cu_die, pf->addr, find_best_scope_cb, &fsp);
4188 ++ ret = cu_walk_functions_at(&pf->cu_die, pf->addr, find_best_scope_cb,
4189 ++ &fsp);
4190 ++ if (!ret && !fsp.found)
4191 ++ cu_walk_functions_at(&pf->cu_die, pf->addr,
4192 ++ find_inner_scope_cb, &fsp);
4193 +
4194 + return fsp.found ? die_mem : NULL;
4195 + }
4196 +@@ -953,7 +968,7 @@ static int probe_point_inline_cb(Dwarf_Die *in_die, void *data)
4197 + ret = find_probe_point_lazy(in_die, pf);
4198 + else {
4199 + /* Get probe address */
4200 +- if (dwarf_entrypc(in_die, &addr) != 0) {
4201 ++ if (die_entrypc(in_die, &addr) != 0) {
4202 + pr_warning("Failed to get entry address of %s.\n",
4203 + dwarf_diename(in_die));
4204 + return -ENOENT;
4205 +@@ -1005,7 +1020,7 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data)
4206 + param->retval = find_probe_point_by_line(pf);
4207 + } else if (die_is_func_instance(sp_die)) {
4208 + /* Instances always have the entry address */
4209 +- dwarf_entrypc(sp_die, &pf->addr);
4210 ++ die_entrypc(sp_die, &pf->addr);
4211 + /* But in some case the entry address is 0 */
4212 + if (pf->addr == 0) {
4213 + pr_debug("%s has no entry PC. Skipped\n",
4214 +@@ -1417,6 +1432,18 @@ error:
4215 + return DIE_FIND_CB_END;
4216 + }
4217 +
4218 ++static bool available_var_finder_overlap(struct available_var_finder *af)
4219 ++{
4220 ++ int i;
4221 ++
4222 ++ for (i = 0; i < af->nvls; i++) {
4223 ++ if (af->pf.addr == af->vls[i].point.address)
4224 ++ return true;
4225 ++ }
4226 ++ return false;
4227 ++
4228 ++}
4229 ++
4230 + /* Add a found vars into available variables list */
4231 + static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
4232 + {
4233 +@@ -1427,6 +1454,14 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
4234 + Dwarf_Die die_mem;
4235 + int ret;
4236 +
4237 ++ /*
4238 ++ * For some reason (e.g. different column assigned to same address),
4239 ++ * this callback can be called with the address which already passed.
4240 ++ * Ignore it first.
4241 ++ */
4242 ++ if (available_var_finder_overlap(af))
4243 ++ return 0;
4244 ++
4245 + /* Check number of tevs */
4246 + if (af->nvls == af->max_vls) {
4247 + pr_warning("Too many( > %d) probe point found.\n", af->max_vls);
4248 +@@ -1570,7 +1605,7 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
4249 + /* Get function entry information */
4250 + func = basefunc = dwarf_diename(&spdie);
4251 + if (!func ||
4252 +- dwarf_entrypc(&spdie, &baseaddr) != 0 ||
4253 ++ die_entrypc(&spdie, &baseaddr) != 0 ||
4254 + dwarf_decl_line(&spdie, &baseline) != 0) {
4255 + lineno = 0;
4256 + goto post;
4257 +@@ -1587,7 +1622,7 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
4258 + while (die_find_top_inlinefunc(&spdie, (Dwarf_Addr)addr,
4259 + &indie)) {
4260 + /* There is an inline function */
4261 +- if (dwarf_entrypc(&indie, &_addr) == 0 &&
4262 ++ if (die_entrypc(&indie, &_addr) == 0 &&
4263 + _addr == addr) {
4264 + /*
4265 + * addr is at an inline function entry.
4266 +diff --git a/tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c b/tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c
4267 +index f794d6bbb7e9..3e4ff4a1cdf4 100644
4268 +--- a/tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c
4269 ++++ b/tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c
4270 +@@ -40,7 +40,6 @@ static cstate_t hsw_ext_cstates[HSW_EXT_CSTATE_COUNT] = {
4271 + {
4272 + .name = "PC9",
4273 + .desc = N_("Processor Package C9"),
4274 +- .desc = N_("Processor Package C2"),
4275 + .id = PC9,
4276 + .range = RANGE_PACKAGE,
4277 + .get_count_percent = hsw_ext_get_count_percent,