Gentoo Archives: gentoo-commits

From: Alice Ferrazzi <alicef@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.15 commit in: /
Date: Wed, 28 Feb 2018 14:57:30
Message-Id: 1519829841.006fd7a2fd975934fe667e0ab4c9a35d03ab9ce4.alicef@gentoo
1 commit: 006fd7a2fd975934fe667e0ab4c9a35d03ab9ce4
2 Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
3 AuthorDate: Wed Feb 28 14:57:21 2018 +0000
4 Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
5 CommitDate: Wed Feb 28 14:57:21 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=006fd7a2
7
8 linux kernel 4.15.7
9
10 0000_README | 4 +
11 1006_linux-4.15.7.patch | 1984 +++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 1988 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index 8e1b91f..2454462 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -67,6 +67,10 @@ Patch: 1005_linux-4.15.6.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.15.6
21
22 +Patch: 1006_linux-4.15.7.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.15.7
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1006_linux-4.15.7.patch b/1006_linux-4.15.7.patch
31 new file mode 100644
32 index 0000000..b68c91a
33 --- /dev/null
34 +++ b/1006_linux-4.15.7.patch
35 @@ -0,0 +1,1984 @@
36 +diff --git a/Makefile b/Makefile
37 +index 51563c76bdf6..49f524444050 100644
38 +--- a/Makefile
39 ++++ b/Makefile
40 +@@ -1,7 +1,7 @@
41 + # SPDX-License-Identifier: GPL-2.0
42 + VERSION = 4
43 + PATCHLEVEL = 15
44 +-SUBLEVEL = 6
45 ++SUBLEVEL = 7
46 + EXTRAVERSION =
47 + NAME = Fearless Coyote
48 +
49 +diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
50 +index 46dee071bab1..1bcf03b5cd04 100644
51 +--- a/arch/arm64/kernel/cpufeature.c
52 ++++ b/arch/arm64/kernel/cpufeature.c
53 +@@ -197,9 +197,11 @@ static const struct arm64_ftr_bits ftr_id_aa64mmfr2[] = {
54 + };
55 +
56 + static const struct arm64_ftr_bits ftr_ctr[] = {
57 +- ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, 31, 1, 1), /* RAO */
58 ++ ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, 31, 1, 1), /* RES1 */
59 ++ ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 29, 1, 1), /* DIC */
60 ++ ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 28, 1, 1), /* IDC */
61 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_HIGHER_SAFE, 24, 4, 0), /* CWG */
62 +- ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 20, 4, 0), /* ERG */
63 ++ ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_HIGHER_SAFE, 20, 4, 0), /* ERG */
64 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 1), /* DminLine */
65 + /*
66 + * Linux can handle differing I-cache policies. Userspace JITs will
67 +diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
68 +index 583fd8154695..d6ca5fccb229 100644
69 +--- a/arch/arm64/kernel/process.c
70 ++++ b/arch/arm64/kernel/process.c
71 +@@ -221,8 +221,15 @@ void __show_regs(struct pt_regs *regs)
72 +
73 + show_regs_print_info(KERN_DEFAULT);
74 + print_pstate(regs);
75 +- print_symbol("pc : %s\n", regs->pc);
76 +- print_symbol("lr : %s\n", lr);
77 ++
78 ++ if (!user_mode(regs)) {
79 ++ print_symbol("pc : %s\n", regs->pc);
80 ++ print_symbol("lr : %s\n", lr);
81 ++ } else {
82 ++ printk("pc : %016llx\n", regs->pc);
83 ++ printk("lr : %016llx\n", lr);
84 ++ }
85 ++
86 + printk("sp : %016llx\n", sp);
87 +
88 + i = top_reg;
89 +diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
90 +index 3d3588fcd1c7..c759d9ca0e5a 100644
91 +--- a/arch/arm64/kernel/traps.c
92 ++++ b/arch/arm64/kernel/traps.c
93 +@@ -57,7 +57,7 @@ static const char *handler[]= {
94 + "Error"
95 + };
96 +
97 +-int show_unhandled_signals = 1;
98 ++int show_unhandled_signals = 0;
99 +
100 + static void dump_backtrace_entry(unsigned long where)
101 + {
102 +@@ -526,14 +526,6 @@ asmlinkage long do_ni_syscall(struct pt_regs *regs)
103 + }
104 + #endif
105 +
106 +- if (show_unhandled_signals_ratelimited()) {
107 +- pr_info("%s[%d]: syscall %d\n", current->comm,
108 +- task_pid_nr(current), regs->syscallno);
109 +- dump_instr("", regs);
110 +- if (user_mode(regs))
111 +- __show_regs(regs);
112 +- }
113 +-
114 + return sys_ni_syscall();
115 + }
116 +
117 +diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
118 +index 248f2e7b24ab..a233975848cc 100644
119 +--- a/arch/arm64/mm/proc.S
120 ++++ b/arch/arm64/mm/proc.S
121 +@@ -155,7 +155,7 @@ ENDPROC(cpu_do_switch_mm)
122 +
123 + .macro __idmap_cpu_set_reserved_ttbr1, tmp1, tmp2
124 + adrp \tmp1, empty_zero_page
125 +- msr ttbr1_el1, \tmp2
126 ++ msr ttbr1_el1, \tmp1
127 + isb
128 + tlbi vmalle1
129 + dsb nsh
130 +diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
131 +index 830ee7d42fa0..d269dd4b8279 100644
132 +--- a/arch/microblaze/Makefile
133 ++++ b/arch/microblaze/Makefile
134 +@@ -36,16 +36,21 @@ endif
135 + CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div
136 + CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift
137 + CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare
138 +-CPUFLAGS-$(CONFIG_BIG_ENDIAN) += -mbig-endian
139 +-CPUFLAGS-$(CONFIG_LITTLE_ENDIAN) += -mlittle-endian
140 ++
141 ++ifdef CONFIG_CPU_BIG_ENDIAN
142 ++KBUILD_CFLAGS += -mbig-endian
143 ++KBUILD_AFLAGS += -mbig-endian
144 ++LD += -EB
145 ++else
146 ++KBUILD_CFLAGS += -mlittle-endian
147 ++KBUILD_AFLAGS += -mlittle-endian
148 ++LD += -EL
149 ++endif
150 +
151 + CPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER))
152 +
153 + # r31 holds current when in kernel mode
154 +-KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-1) $(CPUFLAGS-2)
155 +-
156 +-LDFLAGS :=
157 +-LDFLAGS_vmlinux :=
158 ++KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2)
159 +
160 + head-y := arch/microblaze/kernel/head.o
161 + libs-y += arch/microblaze/lib/
162 +diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
163 +index 1bd5c4f00d19..c22da16d67b8 100644
164 +--- a/arch/mips/boot/Makefile
165 ++++ b/arch/mips/boot/Makefile
166 +@@ -126,6 +126,7 @@ $(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS
167 +
168 + quiet_cmd_cpp_its_S = ITS $@
169 + cmd_cpp_its_S = $(CPP) $(cpp_flags) -P -C -o $@ $< \
170 ++ -D__ASSEMBLY__ \
171 + -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \
172 + -DVMLINUX_BINARY="\"$(3)\"" \
173 + -DVMLINUX_COMPRESSION="\"$(2)\"" \
174 +diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h
175 +index 49691331ada4..08ec0762ca50 100644
176 +--- a/arch/mips/include/asm/compat.h
177 ++++ b/arch/mips/include/asm/compat.h
178 +@@ -86,7 +86,6 @@ struct compat_flock {
179 + compat_off_t l_len;
180 + s32 l_sysid;
181 + compat_pid_t l_pid;
182 +- short __unused;
183 + s32 pad[4];
184 + };
185 +
186 +diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
187 +index 3cc471beb50b..bb6f7a2148d7 100644
188 +--- a/arch/x86/kernel/apic/vector.c
189 ++++ b/arch/x86/kernel/apic/vector.c
190 +@@ -134,21 +134,40 @@ static void apic_update_vector(struct irq_data *irqd, unsigned int newvec,
191 + {
192 + struct apic_chip_data *apicd = apic_chip_data(irqd);
193 + struct irq_desc *desc = irq_data_to_desc(irqd);
194 ++ bool managed = irqd_affinity_is_managed(irqd);
195 +
196 + lockdep_assert_held(&vector_lock);
197 +
198 + trace_vector_update(irqd->irq, newvec, newcpu, apicd->vector,
199 + apicd->cpu);
200 +
201 +- /* Setup the vector move, if required */
202 +- if (apicd->vector && cpu_online(apicd->cpu)) {
203 ++ /*
204 ++ * If there is no vector associated or if the associated vector is
205 ++ * the shutdown vector, which is associated to make PCI/MSI
206 ++ * shutdown mode work, then there is nothing to release. Clear out
207 ++ * prev_vector for this and the offlined target case.
208 ++ */
209 ++ apicd->prev_vector = 0;
210 ++ if (!apicd->vector || apicd->vector == MANAGED_IRQ_SHUTDOWN_VECTOR)
211 ++ goto setnew;
212 ++ /*
213 ++ * If the target CPU of the previous vector is online, then mark
214 ++ * the vector as move in progress and store it for cleanup when the
215 ++ * first interrupt on the new vector arrives. If the target CPU is
216 ++ * offline then the regular release mechanism via the cleanup
217 ++ * vector is not possible and the vector can be immediately freed
218 ++ * in the underlying matrix allocator.
219 ++ */
220 ++ if (cpu_online(apicd->cpu)) {
221 + apicd->move_in_progress = true;
222 + apicd->prev_vector = apicd->vector;
223 + apicd->prev_cpu = apicd->cpu;
224 + } else {
225 +- apicd->prev_vector = 0;
226 ++ irq_matrix_free(vector_matrix, apicd->cpu, apicd->vector,
227 ++ managed);
228 + }
229 +
230 ++setnew:
231 + apicd->vector = newvec;
232 + apicd->cpu = newcpu;
233 + BUG_ON(!IS_ERR_OR_NULL(per_cpu(vector_irq, newcpu)[newvec]));
234 +diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
235 +index 174c59774cc9..a7a7677265b6 100644
236 +--- a/arch/x86/oprofile/nmi_int.c
237 ++++ b/arch/x86/oprofile/nmi_int.c
238 +@@ -460,7 +460,7 @@ static int nmi_setup(void)
239 + goto fail;
240 +
241 + for_each_possible_cpu(cpu) {
242 +- if (!cpu)
243 ++ if (!IS_ENABLED(CONFIG_SMP) || !cpu)
244 + continue;
245 +
246 + memcpy(per_cpu(cpu_msrs, cpu).counters,
247 +diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
248 +index 720fe4e8b497..8dad076661fc 100644
249 +--- a/arch/xtensa/mm/init.c
250 ++++ b/arch/xtensa/mm/init.c
251 +@@ -79,19 +79,75 @@ void __init zones_init(void)
252 + free_area_init_node(0, zones_size, ARCH_PFN_OFFSET, NULL);
253 + }
254 +
255 ++#ifdef CONFIG_HIGHMEM
256 ++static void __init free_area_high(unsigned long pfn, unsigned long end)
257 ++{
258 ++ for (; pfn < end; pfn++)
259 ++ free_highmem_page(pfn_to_page(pfn));
260 ++}
261 ++
262 ++static void __init free_highpages(void)
263 ++{
264 ++ unsigned long max_low = max_low_pfn;
265 ++ struct memblock_region *mem, *res;
266 ++
267 ++ reset_all_zones_managed_pages();
268 ++ /* set highmem page free */
269 ++ for_each_memblock(memory, mem) {
270 ++ unsigned long start = memblock_region_memory_base_pfn(mem);
271 ++ unsigned long end = memblock_region_memory_end_pfn(mem);
272 ++
273 ++ /* Ignore complete lowmem entries */
274 ++ if (end <= max_low)
275 ++ continue;
276 ++
277 ++ if (memblock_is_nomap(mem))
278 ++ continue;
279 ++
280 ++ /* Truncate partial highmem entries */
281 ++ if (start < max_low)
282 ++ start = max_low;
283 ++
284 ++ /* Find and exclude any reserved regions */
285 ++ for_each_memblock(reserved, res) {
286 ++ unsigned long res_start, res_end;
287 ++
288 ++ res_start = memblock_region_reserved_base_pfn(res);
289 ++ res_end = memblock_region_reserved_end_pfn(res);
290 ++
291 ++ if (res_end < start)
292 ++ continue;
293 ++ if (res_start < start)
294 ++ res_start = start;
295 ++ if (res_start > end)
296 ++ res_start = end;
297 ++ if (res_end > end)
298 ++ res_end = end;
299 ++ if (res_start != start)
300 ++ free_area_high(start, res_start);
301 ++ start = res_end;
302 ++ if (start == end)
303 ++ break;
304 ++ }
305 ++
306 ++ /* And now free anything which remains */
307 ++ if (start < end)
308 ++ free_area_high(start, end);
309 ++ }
310 ++}
311 ++#else
312 ++static void __init free_highpages(void)
313 ++{
314 ++}
315 ++#endif
316 ++
317 + /*
318 + * Initialize memory pages.
319 + */
320 +
321 + void __init mem_init(void)
322 + {
323 +-#ifdef CONFIG_HIGHMEM
324 +- unsigned long tmp;
325 +-
326 +- reset_all_zones_managed_pages();
327 +- for (tmp = max_low_pfn; tmp < max_pfn; tmp++)
328 +- free_highmem_page(pfn_to_page(tmp));
329 +-#endif
330 ++ free_highpages();
331 +
332 + max_mapnr = max_pfn - ARCH_PFN_OFFSET;
333 + high_memory = (void *)__va(max_low_pfn << PAGE_SHIFT);
334 +diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c
335 +index 39e6de0c2761..97c77f66b20d 100644
336 +--- a/crypto/asymmetric_keys/pkcs7_verify.c
337 ++++ b/crypto/asymmetric_keys/pkcs7_verify.c
338 +@@ -270,7 +270,7 @@ static int pkcs7_verify_sig_chain(struct pkcs7_message *pkcs7,
339 + sinfo->index);
340 + return 0;
341 + }
342 +- ret = public_key_verify_signature(p->pub, p->sig);
343 ++ ret = public_key_verify_signature(p->pub, x509->sig);
344 + if (ret < 0)
345 + return ret;
346 + x509->signer = p;
347 +@@ -366,8 +366,7 @@ static int pkcs7_verify_one(struct pkcs7_message *pkcs7,
348 + *
349 + * (*) -EBADMSG if some part of the message was invalid, or:
350 + *
351 +- * (*) 0 if no signature chains were found to be blacklisted or to contain
352 +- * unsupported crypto, or:
353 ++ * (*) 0 if a signature chain passed verification, or:
354 + *
355 + * (*) -EKEYREJECTED if a blacklisted key was encountered, or:
356 + *
357 +@@ -423,8 +422,11 @@ int pkcs7_verify(struct pkcs7_message *pkcs7,
358 +
359 + for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) {
360 + ret = pkcs7_verify_one(pkcs7, sinfo);
361 +- if (sinfo->blacklisted && actual_ret == -ENOPKG)
362 +- actual_ret = -EKEYREJECTED;
363 ++ if (sinfo->blacklisted) {
364 ++ if (actual_ret == -ENOPKG)
365 ++ actual_ret = -EKEYREJECTED;
366 ++ continue;
367 ++ }
368 + if (ret < 0) {
369 + if (ret == -ENOPKG) {
370 + sinfo->unsupported_crypto = true;
371 +diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
372 +index de996586762a..e929fe1e4106 100644
373 +--- a/crypto/asymmetric_keys/public_key.c
374 ++++ b/crypto/asymmetric_keys/public_key.c
375 +@@ -79,9 +79,11 @@ int public_key_verify_signature(const struct public_key *pkey,
376 +
377 + BUG_ON(!pkey);
378 + BUG_ON(!sig);
379 +- BUG_ON(!sig->digest);
380 + BUG_ON(!sig->s);
381 +
382 ++ if (!sig->digest)
383 ++ return -ENOPKG;
384 ++
385 + alg_name = sig->pkey_algo;
386 + if (strcmp(sig->pkey_algo, "rsa") == 0) {
387 + /* The data wangled by the RSA algorithm is typically padded
388 +diff --git a/crypto/asymmetric_keys/restrict.c b/crypto/asymmetric_keys/restrict.c
389 +index 86fb68508952..7c93c7728454 100644
390 +--- a/crypto/asymmetric_keys/restrict.c
391 ++++ b/crypto/asymmetric_keys/restrict.c
392 +@@ -67,8 +67,9 @@ __setup("ca_keys=", ca_keys_setup);
393 + *
394 + * Returns 0 if the new certificate was accepted, -ENOKEY if we couldn't find a
395 + * matching parent certificate in the trusted list, -EKEYREJECTED if the
396 +- * signature check fails or the key is blacklisted and some other error if
397 +- * there is a matching certificate but the signature check cannot be performed.
398 ++ * signature check fails or the key is blacklisted, -ENOPKG if the signature
399 ++ * uses unsupported crypto, or some other error if there is a matching
400 ++ * certificate but the signature check cannot be performed.
401 + */
402 + int restrict_link_by_signature(struct key *dest_keyring,
403 + const struct key_type *type,
404 +@@ -88,6 +89,8 @@ int restrict_link_by_signature(struct key *dest_keyring,
405 + return -EOPNOTSUPP;
406 +
407 + sig = payload->data[asym_auth];
408 ++ if (!sig)
409 ++ return -ENOPKG;
410 + if (!sig->auth_ids[0] && !sig->auth_ids[1])
411 + return -ENOKEY;
412 +
413 +@@ -139,6 +142,8 @@ static int key_or_keyring_common(struct key *dest_keyring,
414 + return -EOPNOTSUPP;
415 +
416 + sig = payload->data[asym_auth];
417 ++ if (!sig)
418 ++ return -ENOPKG;
419 + if (!sig->auth_ids[0] && !sig->auth_ids[1])
420 + return -ENOKEY;
421 +
422 +@@ -222,9 +227,9 @@ static int key_or_keyring_common(struct key *dest_keyring,
423 + *
424 + * Returns 0 if the new certificate was accepted, -ENOKEY if we
425 + * couldn't find a matching parent certificate in the trusted list,
426 +- * -EKEYREJECTED if the signature check fails, and some other error if
427 +- * there is a matching certificate but the signature check cannot be
428 +- * performed.
429 ++ * -EKEYREJECTED if the signature check fails, -ENOPKG if the signature uses
430 ++ * unsupported crypto, or some other error if there is a matching certificate
431 ++ * but the signature check cannot be performed.
432 + */
433 + int restrict_link_by_key_or_keyring(struct key *dest_keyring,
434 + const struct key_type *type,
435 +@@ -249,9 +254,9 @@ int restrict_link_by_key_or_keyring(struct key *dest_keyring,
436 + *
437 + * Returns 0 if the new certificate was accepted, -ENOKEY if we
438 + * couldn't find a matching parent certificate in the trusted list,
439 +- * -EKEYREJECTED if the signature check fails, and some other error if
440 +- * there is a matching certificate but the signature check cannot be
441 +- * performed.
442 ++ * -EKEYREJECTED if the signature check fails, -ENOPKG if the signature uses
443 ++ * unsupported crypto, or some other error if there is a matching certificate
444 ++ * but the signature check cannot be performed.
445 + */
446 + int restrict_link_by_key_or_keyring_chain(struct key *dest_keyring,
447 + const struct key_type *type,
448 +diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
449 +index c8691b5a9cb0..191e99f06a9a 100644
450 +--- a/drivers/extcon/extcon-intel-int3496.c
451 ++++ b/drivers/extcon/extcon-intel-int3496.c
452 +@@ -153,8 +153,9 @@ static int int3496_probe(struct platform_device *pdev)
453 + return ret;
454 + }
455 +
456 +- /* queue initial processing of id-pin */
457 ++ /* process id-pin so that we start with the right status */
458 + queue_delayed_work(system_wq, &data->work, 0);
459 ++ flush_delayed_work(&data->work);
460 +
461 + platform_set_drvdata(pdev, data);
462 +
463 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
464 +index c13c51af0b68..c53095b3b0fb 100644
465 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
466 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
467 +@@ -14,6 +14,16 @@
468 +
469 + #include "amd_acpi.h"
470 +
471 ++#define AMDGPU_PX_QUIRK_FORCE_ATPX (1 << 0)
472 ++
473 ++struct amdgpu_px_quirk {
474 ++ u32 chip_vendor;
475 ++ u32 chip_device;
476 ++ u32 subsys_vendor;
477 ++ u32 subsys_device;
478 ++ u32 px_quirk_flags;
479 ++};
480 ++
481 + struct amdgpu_atpx_functions {
482 + bool px_params;
483 + bool power_cntl;
484 +@@ -35,6 +45,7 @@ struct amdgpu_atpx {
485 + static struct amdgpu_atpx_priv {
486 + bool atpx_detected;
487 + bool bridge_pm_usable;
488 ++ unsigned int quirks;
489 + /* handle for device - and atpx */
490 + acpi_handle dhandle;
491 + acpi_handle other_handle;
492 +@@ -205,13 +216,19 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
493 +
494 + atpx->is_hybrid = false;
495 + if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
496 +- printk("ATPX Hybrid Graphics\n");
497 +- /*
498 +- * Disable legacy PM methods only when pcie port PM is usable,
499 +- * otherwise the device might fail to power off or power on.
500 +- */
501 +- atpx->functions.power_cntl = !amdgpu_atpx_priv.bridge_pm_usable;
502 +- atpx->is_hybrid = true;
503 ++ if (amdgpu_atpx_priv.quirks & AMDGPU_PX_QUIRK_FORCE_ATPX) {
504 ++ printk("ATPX Hybrid Graphics, forcing to ATPX\n");
505 ++ atpx->functions.power_cntl = true;
506 ++ atpx->is_hybrid = false;
507 ++ } else {
508 ++ printk("ATPX Hybrid Graphics\n");
509 ++ /*
510 ++ * Disable legacy PM methods only when pcie port PM is usable,
511 ++ * otherwise the device might fail to power off or power on.
512 ++ */
513 ++ atpx->functions.power_cntl = !amdgpu_atpx_priv.bridge_pm_usable;
514 ++ atpx->is_hybrid = true;
515 ++ }
516 + }
517 +
518 + atpx->dgpu_req_power_for_displays = false;
519 +@@ -547,6 +564,31 @@ static const struct vga_switcheroo_handler amdgpu_atpx_handler = {
520 + .get_client_id = amdgpu_atpx_get_client_id,
521 + };
522 +
523 ++static const struct amdgpu_px_quirk amdgpu_px_quirk_list[] = {
524 ++ /* HG _PR3 doesn't seem to work on this A+A weston board */
525 ++ { 0x1002, 0x6900, 0x1002, 0x0124, AMDGPU_PX_QUIRK_FORCE_ATPX },
526 ++ { 0x1002, 0x6900, 0x1028, 0x0812, AMDGPU_PX_QUIRK_FORCE_ATPX },
527 ++ { 0x1002, 0x6900, 0x1028, 0x0813, AMDGPU_PX_QUIRK_FORCE_ATPX },
528 ++ { 0, 0, 0, 0, 0 },
529 ++};
530 ++
531 ++static void amdgpu_atpx_get_quirks(struct pci_dev *pdev)
532 ++{
533 ++ const struct amdgpu_px_quirk *p = amdgpu_px_quirk_list;
534 ++
535 ++ /* Apply PX quirks */
536 ++ while (p && p->chip_device != 0) {
537 ++ if (pdev->vendor == p->chip_vendor &&
538 ++ pdev->device == p->chip_device &&
539 ++ pdev->subsystem_vendor == p->subsys_vendor &&
540 ++ pdev->subsystem_device == p->subsys_device) {
541 ++ amdgpu_atpx_priv.quirks |= p->px_quirk_flags;
542 ++ break;
543 ++ }
544 ++ ++p;
545 ++ }
546 ++}
547 ++
548 + /**
549 + * amdgpu_atpx_detect - detect whether we have PX
550 + *
551 +@@ -570,6 +612,7 @@ static bool amdgpu_atpx_detect(void)
552 +
553 + parent_pdev = pci_upstream_bridge(pdev);
554 + d3_supported |= parent_pdev && parent_pdev->bridge_d3;
555 ++ amdgpu_atpx_get_quirks(pdev);
556 + }
557 +
558 + while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
559 +@@ -579,6 +622,7 @@ static bool amdgpu_atpx_detect(void)
560 +
561 + parent_pdev = pci_upstream_bridge(pdev);
562 + d3_supported |= parent_pdev && parent_pdev->bridge_d3;
563 ++ amdgpu_atpx_get_quirks(pdev);
564 + }
565 +
566 + if (has_atpx && vga_count == 2) {
567 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
568 +index 57abf7abd7a9..b9cfcffbf80f 100644
569 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
570 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
571 +@@ -865,8 +865,8 @@ static int amdgpu_cs_ib_vm_chunk(struct amdgpu_device *adev,
572 + struct amdgpu_bo_va_mapping *m;
573 + struct amdgpu_bo *aobj = NULL;
574 + struct amdgpu_cs_chunk *chunk;
575 ++ uint64_t offset, va_start;
576 + struct amdgpu_ib *ib;
577 +- uint64_t offset;
578 + uint8_t *kptr;
579 +
580 + chunk = &p->chunks[i];
581 +@@ -876,14 +876,14 @@ static int amdgpu_cs_ib_vm_chunk(struct amdgpu_device *adev,
582 + if (chunk->chunk_id != AMDGPU_CHUNK_ID_IB)
583 + continue;
584 +
585 +- r = amdgpu_cs_find_mapping(p, chunk_ib->va_start,
586 +- &aobj, &m);
587 ++ va_start = chunk_ib->va_start & AMDGPU_VA_HOLE_MASK;
588 ++ r = amdgpu_cs_find_mapping(p, va_start, &aobj, &m);
589 + if (r) {
590 + DRM_ERROR("IB va_start is invalid\n");
591 + return r;
592 + }
593 +
594 +- if ((chunk_ib->va_start + chunk_ib->ib_bytes) >
595 ++ if ((va_start + chunk_ib->ib_bytes) >
596 + (m->last + 1) * AMDGPU_GPU_PAGE_SIZE) {
597 + DRM_ERROR("IB va_start+ib_bytes is invalid\n");
598 + return -EINVAL;
599 +@@ -896,7 +896,7 @@ static int amdgpu_cs_ib_vm_chunk(struct amdgpu_device *adev,
600 + }
601 +
602 + offset = m->start * AMDGPU_GPU_PAGE_SIZE;
603 +- kptr += chunk_ib->va_start - offset;
604 ++ kptr += va_start - offset;
605 +
606 + memcpy(ib->ptr, kptr, chunk_ib->ib_bytes);
607 + amdgpu_bo_kunmap(aobj);
608 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
609 +index 3573ecdb06ee..3288cbdd2df0 100644
610 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
611 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
612 +@@ -2228,8 +2228,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
613 + * ignore it */
614 + vga_client_register(adev->pdev, adev, NULL, amdgpu_vga_set_decode);
615 +
616 +- if (amdgpu_runtime_pm == 1)
617 +- runtime = true;
618 + if (amdgpu_device_is_px(ddev))
619 + runtime = true;
620 + if (!pci_is_thunderbolt_attached(adev->pdev))
621 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
622 +index e87eedcc0da9..1eac7c3c687b 100644
623 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
624 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
625 +@@ -563,6 +563,17 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
626 + return -EINVAL;
627 + }
628 +
629 ++ if (args->va_address >= AMDGPU_VA_HOLE_START &&
630 ++ args->va_address < AMDGPU_VA_HOLE_END) {
631 ++ dev_dbg(&dev->pdev->dev,
632 ++ "va_address 0x%LX is in VA hole 0x%LX-0x%LX\n",
633 ++ args->va_address, AMDGPU_VA_HOLE_START,
634 ++ AMDGPU_VA_HOLE_END);
635 ++ return -EINVAL;
636 ++ }
637 ++
638 ++ args->va_address &= AMDGPU_VA_HOLE_MASK;
639 ++
640 + if ((args->flags & ~valid_flags) && (args->flags & ~prt_flags)) {
641 + dev_err(&dev->pdev->dev, "invalid flags combination 0x%08X\n",
642 + args->flags);
643 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
644 +index 720139e182a3..c8b7abf887ed 100644
645 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
646 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
647 +@@ -586,7 +586,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
648 + if (amdgpu_sriov_vf(adev))
649 + dev_info.ids_flags |= AMDGPU_IDS_FLAGS_PREEMPTION;
650 + dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE;
651 +- dev_info.virtual_address_max = (uint64_t)adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE;
652 ++ dev_info.virtual_address_max =
653 ++ min(adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE,
654 ++ AMDGPU_VA_HOLE_START);
655 + dev_info.virtual_address_alignment = max((int)PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE);
656 + dev_info.pte_fragment_size = (1 << adev->vm_manager.fragment_size) * AMDGPU_GPU_PAGE_SIZE;
657 + dev_info.gart_page_size = AMDGPU_GPU_PAGE_SIZE;
658 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
659 +index bae77353447b..aef9ae5cec51 100644
660 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
661 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
662 +@@ -96,6 +96,19 @@ struct amdgpu_bo_list_entry;
663 + /* hardcode that limit for now */
664 + #define AMDGPU_VA_RESERVED_SIZE (8ULL << 20)
665 +
666 ++/* VA hole for 48bit addresses on Vega10 */
667 ++#define AMDGPU_VA_HOLE_START 0x0000800000000000ULL
668 ++#define AMDGPU_VA_HOLE_END 0xffff800000000000ULL
669 ++
670 ++/*
671 ++ * Hardware is programmed as if the hole doesn't exists with start and end
672 ++ * address values.
673 ++ *
674 ++ * This mask is used to remove the upper 16bits of the VA and so come up with
675 ++ * the linear addr value.
676 ++ */
677 ++#define AMDGPU_VA_HOLE_MASK 0x0000ffffffffffffULL
678 ++
679 + /* max vmids dedicated for process */
680 + #define AMDGPU_VM_MAX_RESERVED_VMID 1
681 +
682 +diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
683 +index 51fd0c9a20a5..3af322adae76 100644
684 +--- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c
685 ++++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
686 +@@ -3464,6 +3464,11 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev,
687 + (adev->pdev->device == 0x6667)) {
688 + max_sclk = 75000;
689 + }
690 ++ if ((adev->pdev->revision == 0xC3) ||
691 ++ (adev->pdev->device == 0x6665)) {
692 ++ max_sclk = 60000;
693 ++ max_mclk = 80000;
694 ++ }
695 + } else if (adev->asic_type == CHIP_OLAND) {
696 + if ((adev->pdev->revision == 0xC7) ||
697 + (adev->pdev->revision == 0x80) ||
698 +diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
699 +index 4e67fe1e7955..40767fdb6cd3 100644
700 +--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
701 ++++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
702 +@@ -659,8 +659,8 @@ static int soc15_common_early_init(void *handle)
703 + AMD_CG_SUPPORT_MC_LS |
704 + AMD_CG_SUPPORT_SDMA_MGCG |
705 + AMD_CG_SUPPORT_SDMA_LS;
706 +- adev->pg_flags = AMD_PG_SUPPORT_SDMA |
707 +- AMD_PG_SUPPORT_MMHUB;
708 ++ adev->pg_flags = AMD_PG_SUPPORT_SDMA;
709 ++
710 + adev->external_rev_id = 0x1;
711 + break;
712 + default:
713 +diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
714 +index 3a4c2fa7e36d..d582964702ad 100644
715 +--- a/drivers/gpu/drm/amd/amdgpu/vi.c
716 ++++ b/drivers/gpu/drm/amd/amdgpu/vi.c
717 +@@ -449,14 +449,19 @@ static bool vi_read_bios_from_rom(struct amdgpu_device *adev,
718 +
719 + static void vi_detect_hw_virtualization(struct amdgpu_device *adev)
720 + {
721 +- uint32_t reg = RREG32(mmBIF_IOV_FUNC_IDENTIFIER);
722 +- /* bit0: 0 means pf and 1 means vf */
723 +- /* bit31: 0 means disable IOV and 1 means enable */
724 +- if (reg & 1)
725 +- adev->virt.caps |= AMDGPU_SRIOV_CAPS_IS_VF;
726 +-
727 +- if (reg & 0x80000000)
728 +- adev->virt.caps |= AMDGPU_SRIOV_CAPS_ENABLE_IOV;
729 ++ uint32_t reg = 0;
730 ++
731 ++ if (adev->asic_type == CHIP_TONGA ||
732 ++ adev->asic_type == CHIP_FIJI) {
733 ++ reg = RREG32(mmBIF_IOV_FUNC_IDENTIFIER);
734 ++ /* bit0: 0 means pf and 1 means vf */
735 ++ /* bit31: 0 means disable IOV and 1 means enable */
736 ++ if (reg & 1)
737 ++ adev->virt.caps |= AMDGPU_SRIOV_CAPS_IS_VF;
738 ++
739 ++ if (reg & 0x80000000)
740 ++ adev->virt.caps |= AMDGPU_SRIOV_CAPS_ENABLE_IOV;
741 ++ }
742 +
743 + if (reg == 0) {
744 + if (is_virtual_machine()) /* passthrough mode exclus sr-iov mode */
745 +diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c
746 +index cd23b1b28259..c91b9b054e3f 100644
747 +--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
748 ++++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
749 +@@ -294,22 +294,7 @@ static void cirrus_crtc_prepare(struct drm_crtc *crtc)
750 + {
751 + }
752 +
753 +-/*
754 +- * This is called after a mode is programmed. It should reverse anything done
755 +- * by the prepare function
756 +- */
757 +-static void cirrus_crtc_commit(struct drm_crtc *crtc)
758 +-{
759 +-}
760 +-
761 +-/*
762 +- * The core can pass us a set of gamma values to program. We actually only
763 +- * use this for 8-bit mode so can't perform smooth fades on deeper modes,
764 +- * but it's a requirement that we provide the function
765 +- */
766 +-static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
767 +- u16 *blue, uint32_t size,
768 +- struct drm_modeset_acquire_ctx *ctx)
769 ++static void cirrus_crtc_load_lut(struct drm_crtc *crtc)
770 + {
771 + struct drm_device *dev = crtc->dev;
772 + struct cirrus_device *cdev = dev->dev_private;
773 +@@ -317,7 +302,7 @@ static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
774 + int i;
775 +
776 + if (!crtc->enabled)
777 +- return 0;
778 ++ return;
779 +
780 + r = crtc->gamma_store;
781 + g = r + crtc->gamma_size;
782 +@@ -330,6 +315,27 @@ static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
783 + WREG8(PALETTE_DATA, *g++ >> 8);
784 + WREG8(PALETTE_DATA, *b++ >> 8);
785 + }
786 ++}
787 ++
788 ++/*
789 ++ * This is called after a mode is programmed. It should reverse anything done
790 ++ * by the prepare function
791 ++ */
792 ++static void cirrus_crtc_commit(struct drm_crtc *crtc)
793 ++{
794 ++ cirrus_crtc_load_lut(crtc);
795 ++}
796 ++
797 ++/*
798 ++ * The core can pass us a set of gamma values to program. We actually only
799 ++ * use this for 8-bit mode so can't perform smooth fades on deeper modes,
800 ++ * but it's a requirement that we provide the function
801 ++ */
802 ++static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
803 ++ u16 *blue, uint32_t size,
804 ++ struct drm_modeset_acquire_ctx *ctx)
805 ++{
806 ++ cirrus_crtc_load_lut(crtc);
807 +
808 + return 0;
809 + }
810 +diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
811 +index b16f1d69a0bb..e8c249361d7e 100644
812 +--- a/drivers/gpu/drm/drm_atomic_helper.c
813 ++++ b/drivers/gpu/drm/drm_atomic_helper.c
814 +@@ -1778,6 +1778,8 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
815 + new_crtc_state->event->base.completion = &commit->flip_done;
816 + new_crtc_state->event->base.completion_release = release_crtc_commit;
817 + drm_crtc_commit_get(commit);
818 ++
819 ++ commit->abort_completion = true;
820 + }
821 +
822 + for_each_oldnew_connector_in_state(state, conn, old_conn_state, new_conn_state, i) {
823 +@@ -3327,8 +3329,21 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state);
824 + void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state)
825 + {
826 + if (state->commit) {
827 ++ /*
828 ++ * In the event that a non-blocking commit returns
829 ++ * -ERESTARTSYS before the commit_tail work is queued, we will
830 ++ * have an extra reference to the commit object. Release it, if
831 ++ * the event has not been consumed by the worker.
832 ++ *
833 ++ * state->event may be freed, so we can't directly look at
834 ++ * state->event->base.completion.
835 ++ */
836 ++ if (state->event && state->commit->abort_completion)
837 ++ drm_crtc_commit_put(state->commit);
838 ++
839 + kfree(state->commit->event);
840 + state->commit->event = NULL;
841 ++
842 + drm_crtc_commit_put(state->commit);
843 + }
844 +
845 +diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
846 +index cb487148359a..16fb76ba6509 100644
847 +--- a/drivers/gpu/drm/drm_edid.c
848 ++++ b/drivers/gpu/drm/drm_edid.c
849 +@@ -113,6 +113,9 @@ static const struct edid_quirk {
850 + /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */
851 + { "AEO", 0, EDID_QUIRK_FORCE_6BPC },
852 +
853 ++ /* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */
854 ++ { "CPT", 0x17df, EDID_QUIRK_FORCE_6BPC },
855 ++
856 + /* Belinea 10 15 55 */
857 + { "MAX", 1516, EDID_QUIRK_PREFER_LARGE_60 },
858 + { "MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60 },
859 +diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
860 +index c3c79ee6119e..edab571dbc90 100644
861 +--- a/drivers/gpu/drm/drm_mm.c
862 ++++ b/drivers/gpu/drm/drm_mm.c
863 +@@ -836,9 +836,24 @@ struct drm_mm_node *drm_mm_scan_color_evict(struct drm_mm_scan *scan)
864 + if (!mm->color_adjust)
865 + return NULL;
866 +
867 +- hole = list_first_entry(&mm->hole_stack, typeof(*hole), hole_stack);
868 +- hole_start = __drm_mm_hole_node_start(hole);
869 +- hole_end = hole_start + hole->hole_size;
870 ++ /*
871 ++ * The hole found during scanning should ideally be the first element
872 ++ * in the hole_stack list, but due to side-effects in the driver it
873 ++ * may not be.
874 ++ */
875 ++ list_for_each_entry(hole, &mm->hole_stack, hole_stack) {
876 ++ hole_start = __drm_mm_hole_node_start(hole);
877 ++ hole_end = hole_start + hole->hole_size;
878 ++
879 ++ if (hole_start <= scan->hit_start &&
880 ++ hole_end >= scan->hit_end)
881 ++ break;
882 ++ }
883 ++
884 ++ /* We should only be called after we found the hole previously */
885 ++ DRM_MM_BUG_ON(&hole->hole_stack == &mm->hole_stack);
886 ++ if (unlikely(&hole->hole_stack == &mm->hole_stack))
887 ++ return NULL;
888 +
889 + DRM_MM_BUG_ON(hole_start > scan->hit_start);
890 + DRM_MM_BUG_ON(hole_end < scan->hit_end);
891 +diff --git a/drivers/gpu/drm/i915/intel_breadcrumbs.c b/drivers/gpu/drm/i915/intel_breadcrumbs.c
892 +index bcbc7abe6693..5d0c6504efe8 100644
893 +--- a/drivers/gpu/drm/i915/intel_breadcrumbs.c
894 ++++ b/drivers/gpu/drm/i915/intel_breadcrumbs.c
895 +@@ -552,29 +552,16 @@ void intel_engine_remove_wait(struct intel_engine_cs *engine,
896 + spin_unlock_irq(&b->rb_lock);
897 + }
898 +
899 +-static bool signal_valid(const struct drm_i915_gem_request *request)
900 +-{
901 +- return intel_wait_check_request(&request->signaling.wait, request);
902 +-}
903 +-
904 + static bool signal_complete(const struct drm_i915_gem_request *request)
905 + {
906 + if (!request)
907 + return false;
908 +
909 +- /* If another process served as the bottom-half it may have already
910 +- * signalled that this wait is already completed.
911 +- */
912 +- if (intel_wait_complete(&request->signaling.wait))
913 +- return signal_valid(request);
914 +-
915 +- /* Carefully check if the request is complete, giving time for the
916 ++ /*
917 ++ * Carefully check if the request is complete, giving time for the
918 + * seqno to be visible or if the GPU hung.
919 + */
920 +- if (__i915_request_irq_complete(request))
921 +- return true;
922 +-
923 +- return false;
924 ++ return __i915_request_irq_complete(request);
925 + }
926 +
927 + static struct drm_i915_gem_request *to_signaler(struct rb_node *rb)
928 +@@ -617,9 +604,13 @@ static int intel_breadcrumbs_signaler(void *arg)
929 + request = i915_gem_request_get_rcu(request);
930 + rcu_read_unlock();
931 + if (signal_complete(request)) {
932 +- local_bh_disable();
933 +- dma_fence_signal(&request->fence);
934 +- local_bh_enable(); /* kick start the tasklets */
935 ++ if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
936 ++ &request->fence.flags)) {
937 ++ local_bh_disable();
938 ++ dma_fence_signal(&request->fence);
939 ++ GEM_BUG_ON(!i915_gem_request_completed(request));
940 ++ local_bh_enable(); /* kick start the tasklets */
941 ++ }
942 +
943 + spin_lock_irq(&b->rb_lock);
944 +
945 +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
946 +index b5f85d6f6bef..721633658544 100644
947 +--- a/drivers/hid/hid-core.c
948 ++++ b/drivers/hid/hid-core.c
949 +@@ -2721,6 +2721,9 @@ static const struct hid_device_id hid_ignore_list[] = {
950 + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) },
951 + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) },
952 + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) },
953 ++ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERANALYSERCASSY) },
954 ++ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY) },
955 ++ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETESTCASSY) },
956 + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) },
957 + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) },
958 + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
959 +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
960 +index 5da3d6256d25..a0baa5ba5b84 100644
961 +--- a/drivers/hid/hid-ids.h
962 ++++ b/drivers/hid/hid-ids.h
963 +@@ -641,6 +641,9 @@
964 + #define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033
965 + #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035
966 + #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038
967 ++#define USB_DEVICE_ID_LD_POWERANALYSERCASSY 0x1040
968 ++#define USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY 0x1042
969 ++#define USB_DEVICE_ID_LD_MACHINETESTCASSY 0x1043
970 + #define USB_DEVICE_ID_LD_JWM 0x1080
971 + #define USB_DEVICE_ID_LD_DMMP 0x1081
972 + #define USB_DEVICE_ID_LD_UMIP 0x1090
973 +diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
974 +index cd07a69e2e93..44deae78913e 100644
975 +--- a/drivers/i2c/busses/i2c-bcm2835.c
976 ++++ b/drivers/i2c/busses/i2c-bcm2835.c
977 +@@ -50,6 +50,9 @@
978 + #define BCM2835_I2C_S_CLKT BIT(9)
979 + #define BCM2835_I2C_S_LEN BIT(10) /* Fake bit for SW error reporting */
980 +
981 ++#define BCM2835_I2C_FEDL_SHIFT 16
982 ++#define BCM2835_I2C_REDL_SHIFT 0
983 ++
984 + #define BCM2835_I2C_CDIV_MIN 0x0002
985 + #define BCM2835_I2C_CDIV_MAX 0xFFFE
986 +
987 +@@ -81,7 +84,7 @@ static inline u32 bcm2835_i2c_readl(struct bcm2835_i2c_dev *i2c_dev, u32 reg)
988 +
989 + static int bcm2835_i2c_set_divider(struct bcm2835_i2c_dev *i2c_dev)
990 + {
991 +- u32 divider;
992 ++ u32 divider, redl, fedl;
993 +
994 + divider = DIV_ROUND_UP(clk_get_rate(i2c_dev->clk),
995 + i2c_dev->bus_clk_rate);
996 +@@ -100,6 +103,22 @@ static int bcm2835_i2c_set_divider(struct bcm2835_i2c_dev *i2c_dev)
997 +
998 + bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DIV, divider);
999 +
1000 ++ /*
1001 ++ * Number of core clocks to wait after falling edge before
1002 ++ * outputting the next data bit. Note that both FEDL and REDL
1003 ++ * can't be greater than CDIV/2.
1004 ++ */
1005 ++ fedl = max(divider / 16, 1u);
1006 ++
1007 ++ /*
1008 ++ * Number of core clocks to wait after rising edge before
1009 ++ * sampling the next incoming data bit.
1010 ++ */
1011 ++ redl = max(divider / 4, 1u);
1012 ++
1013 ++ bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DEL,
1014 ++ (fedl << BCM2835_I2C_FEDL_SHIFT) |
1015 ++ (redl << BCM2835_I2C_REDL_SHIFT));
1016 + return 0;
1017 + }
1018 +
1019 +diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
1020 +index 418c233075d3..13e849bf9aa0 100644
1021 +--- a/drivers/i2c/busses/i2c-designware-master.c
1022 ++++ b/drivers/i2c/busses/i2c-designware-master.c
1023 +@@ -207,7 +207,7 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
1024 + i2c_dw_disable_int(dev);
1025 +
1026 + /* Enable the adapter */
1027 +- __i2c_dw_enable(dev, true);
1028 ++ __i2c_dw_enable_and_wait(dev, true);
1029 +
1030 + /* Clear and enable interrupts */
1031 + dw_readl(dev, DW_IC_CLR_INTR);
1032 +diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
1033 +index cecf1e5b244c..b61b52f43179 100644
1034 +--- a/drivers/iio/adc/stm32-adc.c
1035 ++++ b/drivers/iio/adc/stm32-adc.c
1036 +@@ -765,8 +765,6 @@ static int stm32h7_adc_enable(struct stm32_adc *adc)
1037 + int ret;
1038 + u32 val;
1039 +
1040 +- /* Clear ADRDY by writing one, then enable ADC */
1041 +- stm32_adc_set_bits(adc, STM32H7_ADC_ISR, STM32H7_ADRDY);
1042 + stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADEN);
1043 +
1044 + /* Poll for ADRDY to be set (after adc startup time) */
1045 +@@ -774,8 +772,11 @@ static int stm32h7_adc_enable(struct stm32_adc *adc)
1046 + val & STM32H7_ADRDY,
1047 + 100, STM32_ADC_TIMEOUT_US);
1048 + if (ret) {
1049 +- stm32_adc_clr_bits(adc, STM32H7_ADC_CR, STM32H7_ADEN);
1050 ++ stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADDIS);
1051 + dev_err(&indio_dev->dev, "Failed to enable ADC\n");
1052 ++ } else {
1053 ++ /* Clear ADRDY by writing one */
1054 ++ stm32_adc_set_bits(adc, STM32H7_ADC_ISR, STM32H7_ADRDY);
1055 + }
1056 +
1057 + return ret;
1058 +diff --git a/drivers/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c
1059 +index 0dd5a381be64..457372f36791 100644
1060 +--- a/drivers/iio/imu/adis_trigger.c
1061 ++++ b/drivers/iio/imu/adis_trigger.c
1062 +@@ -46,6 +46,10 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)
1063 + if (adis->trig == NULL)
1064 + return -ENOMEM;
1065 +
1066 ++ adis->trig->dev.parent = &adis->spi->dev;
1067 ++ adis->trig->ops = &adis_trigger_ops;
1068 ++ iio_trigger_set_drvdata(adis->trig, adis);
1069 ++
1070 + ret = request_irq(adis->spi->irq,
1071 + &iio_trigger_generic_data_rdy_poll,
1072 + IRQF_TRIGGER_RISING,
1073 +@@ -54,9 +58,6 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)
1074 + if (ret)
1075 + goto error_free_trig;
1076 +
1077 +- adis->trig->dev.parent = &adis->spi->dev;
1078 +- adis->trig->ops = &adis_trigger_ops;
1079 +- iio_trigger_set_drvdata(adis->trig, adis);
1080 + ret = iio_trigger_register(adis->trig);
1081 +
1082 + indio_dev->trig = iio_trigger_get(adis->trig);
1083 +diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
1084 +index d2b465140a6b..78482d456c3b 100644
1085 +--- a/drivers/iio/industrialio-buffer.c
1086 ++++ b/drivers/iio/industrialio-buffer.c
1087 +@@ -175,7 +175,7 @@ unsigned int iio_buffer_poll(struct file *filp,
1088 + struct iio_dev *indio_dev = filp->private_data;
1089 + struct iio_buffer *rb = indio_dev->buffer;
1090 +
1091 +- if (!indio_dev->info)
1092 ++ if (!indio_dev->info || rb == NULL)
1093 + return 0;
1094 +
1095 + poll_wait(filp, &rb->pollq, wait);
1096 +diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig
1097 +index fcb1c4ba5e41..f726f9427602 100644
1098 +--- a/drivers/iio/proximity/Kconfig
1099 ++++ b/drivers/iio/proximity/Kconfig
1100 +@@ -68,6 +68,8 @@ config SX9500
1101 +
1102 + config SRF08
1103 + tristate "Devantech SRF02/SRF08/SRF10 ultrasonic ranger sensor"
1104 ++ select IIO_BUFFER
1105 ++ select IIO_TRIGGERED_BUFFER
1106 + depends on I2C
1107 + help
1108 + Say Y here to build a driver for Devantech SRF02/SRF08/SRF10
1109 +diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
1110 +index 85b5ee4defa4..4e1f76730855 100644
1111 +--- a/drivers/infiniband/core/rdma_core.c
1112 ++++ b/drivers/infiniband/core/rdma_core.c
1113 +@@ -196,7 +196,15 @@ static struct ib_uobject *lookup_get_idr_uobject(const struct uverbs_obj_type *t
1114 + goto free;
1115 + }
1116 +
1117 +- uverbs_uobject_get(uobj);
1118 ++ /*
1119 ++ * The idr_find is guaranteed to return a pointer to something that
1120 ++ * isn't freed yet, or NULL, as the free after idr_remove goes through
1121 ++ * kfree_rcu(). However the object may still have been released and
1122 ++ * kfree() could be called at any time.
1123 ++ */
1124 ++ if (!kref_get_unless_zero(&uobj->ref))
1125 ++ uobj = ERR_PTR(-ENOENT);
1126 ++
1127 + free:
1128 + rcu_read_unlock();
1129 + return uobj;
1130 +diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
1131 +index 840b24096690..df127c8b9a9f 100644
1132 +--- a/drivers/infiniband/core/uverbs_cmd.c
1133 ++++ b/drivers/infiniband/core/uverbs_cmd.c
1134 +@@ -560,9 +560,10 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
1135 + if (f.file)
1136 + fdput(f);
1137 +
1138 ++ mutex_unlock(&file->device->xrcd_tree_mutex);
1139 ++
1140 + uobj_alloc_commit(&obj->uobject);
1141 +
1142 +- mutex_unlock(&file->device->xrcd_tree_mutex);
1143 + return in_len;
1144 +
1145 + err_copy:
1146 +@@ -601,10 +602,8 @@ ssize_t ib_uverbs_close_xrcd(struct ib_uverbs_file *file,
1147 +
1148 + uobj = uobj_get_write(uobj_get_type(xrcd), cmd.xrcd_handle,
1149 + file->ucontext);
1150 +- if (IS_ERR(uobj)) {
1151 +- mutex_unlock(&file->device->xrcd_tree_mutex);
1152 ++ if (IS_ERR(uobj))
1153 + return PTR_ERR(uobj);
1154 +- }
1155 +
1156 + ret = uobj_remove_commit(uobj);
1157 + return ret ?: in_len;
1158 +@@ -1971,8 +1970,15 @@ static int modify_qp(struct ib_uverbs_file *file,
1159 + goto release_qp;
1160 + }
1161 +
1162 ++ if ((cmd->base.attr_mask & IB_QP_AV) &&
1163 ++ !rdma_is_port_valid(qp->device, cmd->base.dest.port_num)) {
1164 ++ ret = -EINVAL;
1165 ++ goto release_qp;
1166 ++ }
1167 ++
1168 + if ((cmd->base.attr_mask & IB_QP_ALT_PATH) &&
1169 +- !rdma_is_port_valid(qp->device, cmd->base.alt_port_num)) {
1170 ++ (!rdma_is_port_valid(qp->device, cmd->base.alt_port_num) ||
1171 ++ !rdma_is_port_valid(qp->device, cmd->base.alt_dest.port_num))) {
1172 + ret = -EINVAL;
1173 + goto release_qp;
1174 + }
1175 +diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
1176 +index 381fd9c096ae..0804239e43f0 100644
1177 +--- a/drivers/infiniband/core/uverbs_main.c
1178 ++++ b/drivers/infiniband/core/uverbs_main.c
1179 +@@ -648,12 +648,21 @@ static int verify_command_mask(struct ib_device *ib_dev, __u32 command)
1180 + return -1;
1181 + }
1182 +
1183 ++static bool verify_command_idx(u32 command, bool extended)
1184 ++{
1185 ++ if (extended)
1186 ++ return command < ARRAY_SIZE(uverbs_ex_cmd_table);
1187 ++
1188 ++ return command < ARRAY_SIZE(uverbs_cmd_table);
1189 ++}
1190 ++
1191 + static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
1192 + size_t count, loff_t *pos)
1193 + {
1194 + struct ib_uverbs_file *file = filp->private_data;
1195 + struct ib_device *ib_dev;
1196 + struct ib_uverbs_cmd_hdr hdr;
1197 ++ bool extended_command;
1198 + __u32 command;
1199 + __u32 flags;
1200 + int srcu_key;
1201 +@@ -686,6 +695,15 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
1202 + }
1203 +
1204 + command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK;
1205 ++ flags = (hdr.command &
1206 ++ IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT;
1207 ++
1208 ++ extended_command = flags & IB_USER_VERBS_CMD_FLAG_EXTENDED;
1209 ++ if (!verify_command_idx(command, extended_command)) {
1210 ++ ret = -EINVAL;
1211 ++ goto out;
1212 ++ }
1213 ++
1214 + if (verify_command_mask(ib_dev, command)) {
1215 + ret = -EOPNOTSUPP;
1216 + goto out;
1217 +@@ -697,12 +715,8 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
1218 + goto out;
1219 + }
1220 +
1221 +- flags = (hdr.command &
1222 +- IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT;
1223 +-
1224 + if (!flags) {
1225 +- if (command >= ARRAY_SIZE(uverbs_cmd_table) ||
1226 +- !uverbs_cmd_table[command]) {
1227 ++ if (!uverbs_cmd_table[command]) {
1228 + ret = -EINVAL;
1229 + goto out;
1230 + }
1231 +@@ -723,8 +737,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
1232 + struct ib_udata uhw;
1233 + size_t written_count = count;
1234 +
1235 +- if (command >= ARRAY_SIZE(uverbs_ex_cmd_table) ||
1236 +- !uverbs_ex_cmd_table[command]) {
1237 ++ if (!uverbs_ex_cmd_table[command]) {
1238 + ret = -ENOSYS;
1239 + goto out;
1240 + }
1241 +diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
1242 +index b56c3e23f0af..980ae8e7df30 100644
1243 +--- a/drivers/irqchip/irq-gic-v3.c
1244 ++++ b/drivers/irqchip/irq-gic-v3.c
1245 +@@ -688,7 +688,7 @@ static void gic_raise_softirq(const struct cpumask *mask, unsigned int irq)
1246 + * Ensure that stores to Normal memory are visible to the
1247 + * other CPUs before issuing the IPI.
1248 + */
1249 +- smp_wmb();
1250 ++ wmb();
1251 +
1252 + for_each_cpu(cpu, mask) {
1253 + u64 cluster_id = MPIDR_TO_SGI_CLUSTER_ID(cpu_logical_map(cpu));
1254 +diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
1255 +index ef92a4d2038e..d32268cc1174 100644
1256 +--- a/drivers/irqchip/irq-mips-gic.c
1257 ++++ b/drivers/irqchip/irq-mips-gic.c
1258 +@@ -424,8 +424,6 @@ static int gic_shared_irq_domain_map(struct irq_domain *d, unsigned int virq,
1259 + spin_lock_irqsave(&gic_lock, flags);
1260 + write_gic_map_pin(intr, GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin);
1261 + write_gic_map_vp(intr, BIT(mips_cm_vp_id(cpu)));
1262 +- gic_clear_pcpu_masks(intr);
1263 +- set_bit(intr, per_cpu_ptr(pcpu_masks, cpu));
1264 + irq_data_update_effective_affinity(data, cpumask_of(cpu));
1265 + spin_unlock_irqrestore(&gic_lock, flags);
1266 +
1267 +diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
1268 +index 375ef86a84da..322671076c9c 100644
1269 +--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
1270 ++++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
1271 +@@ -2632,7 +2632,6 @@ void t4_get_regs(struct adapter *adap, void *buf, size_t buf_size)
1272 + }
1273 +
1274 + #define EEPROM_STAT_ADDR 0x7bfc
1275 +-#define VPD_SIZE 0x800
1276 + #define VPD_BASE 0x400
1277 + #define VPD_BASE_OLD 0
1278 + #define VPD_LEN 1024
1279 +@@ -2699,15 +2698,6 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p)
1280 + if (!vpd)
1281 + return -ENOMEM;
1282 +
1283 +- /* We have two VPD data structures stored in the adapter VPD area.
1284 +- * By default, Linux calculates the size of the VPD area by traversing
1285 +- * the first VPD area at offset 0x0, so we need to tell the OS what
1286 +- * our real VPD size is.
1287 +- */
1288 +- ret = pci_set_vpd_size(adapter->pdev, VPD_SIZE);
1289 +- if (ret < 0)
1290 +- goto out;
1291 +-
1292 + /* Card information normally starts at VPD_BASE but early cards had
1293 + * it at 0.
1294 + */
1295 +diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c
1296 +index ca5e375de27c..e0d6760f3219 100644
1297 +--- a/drivers/net/thunderbolt.c
1298 ++++ b/drivers/net/thunderbolt.c
1299 +@@ -166,6 +166,8 @@ struct tbnet_ring {
1300 + * @connected_work: Worker that finalizes the ThunderboltIP connection
1301 + * setup and enables DMA paths for high speed data
1302 + * transfers
1303 ++ * @disconnect_work: Worker that handles tearing down the ThunderboltIP
1304 ++ * connection
1305 + * @rx_hdr: Copy of the currently processed Rx frame. Used when a
1306 + * network packet consists of multiple Thunderbolt frames.
1307 + * In host byte order.
1308 +@@ -190,6 +192,7 @@ struct tbnet {
1309 + int login_retries;
1310 + struct delayed_work login_work;
1311 + struct work_struct connected_work;
1312 ++ struct work_struct disconnect_work;
1313 + struct thunderbolt_ip_frame_header rx_hdr;
1314 + struct tbnet_ring rx_ring;
1315 + atomic_t frame_id;
1316 +@@ -445,7 +448,7 @@ static int tbnet_handle_packet(const void *buf, size_t size, void *data)
1317 + case TBIP_LOGOUT:
1318 + ret = tbnet_logout_response(net, route, sequence, command_id);
1319 + if (!ret)
1320 +- tbnet_tear_down(net, false);
1321 ++ queue_work(system_long_wq, &net->disconnect_work);
1322 + break;
1323 +
1324 + default:
1325 +@@ -659,6 +662,13 @@ static void tbnet_login_work(struct work_struct *work)
1326 + }
1327 + }
1328 +
1329 ++static void tbnet_disconnect_work(struct work_struct *work)
1330 ++{
1331 ++ struct tbnet *net = container_of(work, typeof(*net), disconnect_work);
1332 ++
1333 ++ tbnet_tear_down(net, false);
1334 ++}
1335 ++
1336 + static bool tbnet_check_frame(struct tbnet *net, const struct tbnet_frame *tf,
1337 + const struct thunderbolt_ip_frame_header *hdr)
1338 + {
1339 +@@ -881,6 +891,7 @@ static int tbnet_stop(struct net_device *dev)
1340 +
1341 + napi_disable(&net->napi);
1342 +
1343 ++ cancel_work_sync(&net->disconnect_work);
1344 + tbnet_tear_down(net, true);
1345 +
1346 + tb_ring_free(net->rx_ring.ring);
1347 +@@ -1195,6 +1206,7 @@ static int tbnet_probe(struct tb_service *svc, const struct tb_service_id *id)
1348 + net = netdev_priv(dev);
1349 + INIT_DELAYED_WORK(&net->login_work, tbnet_login_work);
1350 + INIT_WORK(&net->connected_work, tbnet_connected_work);
1351 ++ INIT_WORK(&net->disconnect_work, tbnet_disconnect_work);
1352 + mutex_init(&net->connection_lock);
1353 + atomic_set(&net->command_id, 0);
1354 + atomic_set(&net->frame_id, 0);
1355 +@@ -1270,10 +1282,7 @@ static int __maybe_unused tbnet_suspend(struct device *dev)
1356 + stop_login(net);
1357 + if (netif_running(net->dev)) {
1358 + netif_device_detach(net->dev);
1359 +- tb_ring_stop(net->rx_ring.ring);
1360 +- tb_ring_stop(net->tx_ring.ring);
1361 +- tbnet_free_buffers(&net->rx_ring);
1362 +- tbnet_free_buffers(&net->tx_ring);
1363 ++ tbnet_tear_down(net, true);
1364 + }
1365 +
1366 + return 0;
1367 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
1368 +index d22750ea7444..d7135140bf40 100644
1369 +--- a/drivers/pci/quirks.c
1370 ++++ b/drivers/pci/quirks.c
1371 +@@ -3419,22 +3419,29 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PORT_RIDGE,
1372 +
1373 + static void quirk_chelsio_extend_vpd(struct pci_dev *dev)
1374 + {
1375 +- pci_set_vpd_size(dev, 8192);
1376 +-}
1377 +-
1378 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x20, quirk_chelsio_extend_vpd);
1379 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x21, quirk_chelsio_extend_vpd);
1380 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x22, quirk_chelsio_extend_vpd);
1381 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x23, quirk_chelsio_extend_vpd);
1382 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x24, quirk_chelsio_extend_vpd);
1383 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x25, quirk_chelsio_extend_vpd);
1384 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x26, quirk_chelsio_extend_vpd);
1385 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x30, quirk_chelsio_extend_vpd);
1386 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x31, quirk_chelsio_extend_vpd);
1387 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x32, quirk_chelsio_extend_vpd);
1388 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x35, quirk_chelsio_extend_vpd);
1389 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x36, quirk_chelsio_extend_vpd);
1390 +-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x37, quirk_chelsio_extend_vpd);
1391 ++ int chip = (dev->device & 0xf000) >> 12;
1392 ++ int func = (dev->device & 0x0f00) >> 8;
1393 ++ int prod = (dev->device & 0x00ff) >> 0;
1394 ++
1395 ++ /*
1396 ++ * If this is a T3-based adapter, there's a 1KB VPD area at offset
1397 ++ * 0xc00 which contains the preferred VPD values. If this is a T4 or
1398 ++ * later based adapter, the special VPD is at offset 0x400 for the
1399 ++ * Physical Functions (the SR-IOV Virtual Functions have no VPD
1400 ++ * Capabilities). The PCI VPD Access core routines will normally
1401 ++ * compute the size of the VPD by parsing the VPD Data Structure at
1402 ++ * offset 0x000. This will result in silent failures when attempting
1403 ++ * to accesses these other VPD areas which are beyond those computed
1404 ++ * limits.
1405 ++ */
1406 ++ if (chip == 0x0 && prod >= 0x20)
1407 ++ pci_set_vpd_size(dev, 8192);
1408 ++ else if (chip >= 0x4 && func < 0x8)
1409 ++ pci_set_vpd_size(dev, 2048);
1410 ++}
1411 ++
1412 ++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID,
1413 ++ quirk_chelsio_extend_vpd);
1414 +
1415 + #ifdef CONFIG_ACPI
1416 + /*
1417 +diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h
1418 +index 9a0696f68f37..b81a53c4a9a8 100644
1419 +--- a/drivers/scsi/ibmvscsi/ibmvfc.h
1420 ++++ b/drivers/scsi/ibmvscsi/ibmvfc.h
1421 +@@ -367,7 +367,7 @@ enum ibmvfc_fcp_rsp_info_codes {
1422 + };
1423 +
1424 + struct ibmvfc_fcp_rsp_info {
1425 +- __be16 reserved;
1426 ++ u8 reserved[3];
1427 + u8 rsp_code;
1428 + u8 reserved2[4];
1429 + }__attribute__((packed, aligned (2)));
1430 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
1431 +index 4024926c1d68..f4a548471f0f 100644
1432 +--- a/drivers/usb/core/quirks.c
1433 ++++ b/drivers/usb/core/quirks.c
1434 +@@ -226,6 +226,9 @@ static const struct usb_device_id usb_quirk_list[] = {
1435 + { USB_DEVICE(0x1a0a, 0x0200), .driver_info =
1436 + USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
1437 +
1438 ++ /* Corsair K70 RGB */
1439 ++ { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT },
1440 ++
1441 + /* Corsair Strafe RGB */
1442 + { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT },
1443 +
1444 +diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
1445 +index fd3e7ad2eb0e..618b4260f0d9 100644
1446 +--- a/drivers/usb/dwc3/ep0.c
1447 ++++ b/drivers/usb/dwc3/ep0.c
1448 +@@ -858,7 +858,12 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
1449 + trb++;
1450 + trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
1451 + trace_dwc3_complete_trb(ep0, trb);
1452 +- ep0->trb_enqueue = 0;
1453 ++
1454 ++ if (r->direction)
1455 ++ dwc->eps[1]->trb_enqueue = 0;
1456 ++ else
1457 ++ dwc->eps[0]->trb_enqueue = 0;
1458 ++
1459 + dwc->ep0_bounced = false;
1460 + }
1461 +
1462 +diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
1463 +index 639dd1b163a0..21abea0ac622 100644
1464 +--- a/drivers/usb/dwc3/gadget.c
1465 ++++ b/drivers/usb/dwc3/gadget.c
1466 +@@ -2744,6 +2744,8 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
1467 + break;
1468 + }
1469 +
1470 ++ dwc->eps[1]->endpoint.maxpacket = dwc->gadget.ep0->maxpacket;
1471 ++
1472 + /* Enable USB2 LPM Capability */
1473 +
1474 + if ((dwc->revision > DWC3_REVISION_194A) &&
1475 +diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
1476 +index f9bd351637cd..0ef08a909ba6 100644
1477 +--- a/drivers/usb/gadget/function/f_fs.c
1478 ++++ b/drivers/usb/gadget/function/f_fs.c
1479 +@@ -1852,44 +1852,20 @@ static int ffs_func_eps_enable(struct ffs_function *func)
1480 +
1481 + spin_lock_irqsave(&func->ffs->eps_lock, flags);
1482 + while(count--) {
1483 +- struct usb_endpoint_descriptor *ds;
1484 +- struct usb_ss_ep_comp_descriptor *comp_desc = NULL;
1485 +- int needs_comp_desc = false;
1486 +- int desc_idx;
1487 +-
1488 +- if (ffs->gadget->speed == USB_SPEED_SUPER) {
1489 +- desc_idx = 2;
1490 +- needs_comp_desc = true;
1491 +- } else if (ffs->gadget->speed == USB_SPEED_HIGH)
1492 +- desc_idx = 1;
1493 +- else
1494 +- desc_idx = 0;
1495 +-
1496 +- /* fall-back to lower speed if desc missing for current speed */
1497 +- do {
1498 +- ds = ep->descs[desc_idx];
1499 +- } while (!ds && --desc_idx >= 0);
1500 +-
1501 +- if (!ds) {
1502 +- ret = -EINVAL;
1503 +- break;
1504 +- }
1505 +-
1506 + ep->ep->driver_data = ep;
1507 +- ep->ep->desc = ds;
1508 +
1509 +- if (needs_comp_desc) {
1510 +- comp_desc = (struct usb_ss_ep_comp_descriptor *)(ds +
1511 +- USB_DT_ENDPOINT_SIZE);
1512 +- ep->ep->maxburst = comp_desc->bMaxBurst + 1;
1513 +- ep->ep->comp_desc = comp_desc;
1514 ++ ret = config_ep_by_speed(func->gadget, &func->function, ep->ep);
1515 ++ if (ret) {
1516 ++ pr_err("%s: config_ep_by_speed(%s) returned %d\n",
1517 ++ __func__, ep->ep->name, ret);
1518 ++ break;
1519 + }
1520 +
1521 + ret = usb_ep_enable(ep->ep);
1522 + if (likely(!ret)) {
1523 + epfile->ep = ep;
1524 +- epfile->in = usb_endpoint_dir_in(ds);
1525 +- epfile->isoc = usb_endpoint_xfer_isoc(ds);
1526 ++ epfile->in = usb_endpoint_dir_in(ep->ep->desc);
1527 ++ epfile->isoc = usb_endpoint_xfer_isoc(ep->ep->desc);
1528 + } else {
1529 + break;
1530 + }
1531 +@@ -2976,10 +2952,8 @@ static int _ffs_func_bind(struct usb_configuration *c,
1532 + struct ffs_data *ffs = func->ffs;
1533 +
1534 + const int full = !!func->ffs->fs_descs_count;
1535 +- const int high = gadget_is_dualspeed(func->gadget) &&
1536 +- func->ffs->hs_descs_count;
1537 +- const int super = gadget_is_superspeed(func->gadget) &&
1538 +- func->ffs->ss_descs_count;
1539 ++ const int high = !!func->ffs->hs_descs_count;
1540 ++ const int super = !!func->ffs->ss_descs_count;
1541 +
1542 + int fs_len, hs_len, ss_len, ret, i;
1543 + struct ffs_ep *eps_ptr;
1544 +diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
1545 +index facafdf8fb95..d7641cbdee43 100644
1546 +--- a/drivers/usb/host/ehci-hub.c
1547 ++++ b/drivers/usb/host/ehci-hub.c
1548 +@@ -774,12 +774,12 @@ static struct urb *request_single_step_set_feature_urb(
1549 + atomic_inc(&urb->use_count);
1550 + atomic_inc(&urb->dev->urbnum);
1551 + urb->setup_dma = dma_map_single(
1552 +- hcd->self.controller,
1553 ++ hcd->self.sysdev,
1554 + urb->setup_packet,
1555 + sizeof(struct usb_ctrlrequest),
1556 + DMA_TO_DEVICE);
1557 + urb->transfer_dma = dma_map_single(
1558 +- hcd->self.controller,
1559 ++ hcd->self.sysdev,
1560 + urb->transfer_buffer,
1561 + urb->transfer_buffer_length,
1562 + DMA_FROM_DEVICE);
1563 +diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
1564 +index ee9676349333..84f88fa411cd 100644
1565 +--- a/drivers/usb/host/ohci-hcd.c
1566 ++++ b/drivers/usb/host/ohci-hcd.c
1567 +@@ -74,6 +74,7 @@ static const char hcd_name [] = "ohci_hcd";
1568 +
1569 + #define STATECHANGE_DELAY msecs_to_jiffies(300)
1570 + #define IO_WATCHDOG_DELAY msecs_to_jiffies(275)
1571 ++#define IO_WATCHDOG_OFF 0xffffff00
1572 +
1573 + #include "ohci.h"
1574 + #include "pci-quirks.h"
1575 +@@ -231,7 +232,7 @@ static int ohci_urb_enqueue (
1576 + }
1577 +
1578 + /* Start up the I/O watchdog timer, if it's not running */
1579 +- if (!timer_pending(&ohci->io_watchdog) &&
1580 ++ if (ohci->prev_frame_no == IO_WATCHDOG_OFF &&
1581 + list_empty(&ohci->eds_in_use) &&
1582 + !(ohci->flags & OHCI_QUIRK_QEMU)) {
1583 + ohci->prev_frame_no = ohci_frame_no(ohci);
1584 +@@ -501,6 +502,7 @@ static int ohci_init (struct ohci_hcd *ohci)
1585 + return 0;
1586 +
1587 + timer_setup(&ohci->io_watchdog, io_watchdog_func, 0);
1588 ++ ohci->prev_frame_no = IO_WATCHDOG_OFF;
1589 +
1590 + ohci->hcca = dma_alloc_coherent (hcd->self.controller,
1591 + sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_KERNEL);
1592 +@@ -730,7 +732,7 @@ static void io_watchdog_func(struct timer_list *t)
1593 + u32 head;
1594 + struct ed *ed;
1595 + struct td *td, *td_start, *td_next;
1596 +- unsigned frame_no;
1597 ++ unsigned frame_no, prev_frame_no = IO_WATCHDOG_OFF;
1598 + unsigned long flags;
1599 +
1600 + spin_lock_irqsave(&ohci->lock, flags);
1601 +@@ -835,7 +837,7 @@ static void io_watchdog_func(struct timer_list *t)
1602 + }
1603 + }
1604 + if (!list_empty(&ohci->eds_in_use)) {
1605 +- ohci->prev_frame_no = frame_no;
1606 ++ prev_frame_no = frame_no;
1607 + ohci->prev_wdh_cnt = ohci->wdh_cnt;
1608 + ohci->prev_donehead = ohci_readl(ohci,
1609 + &ohci->regs->donehead);
1610 +@@ -845,6 +847,7 @@ static void io_watchdog_func(struct timer_list *t)
1611 + }
1612 +
1613 + done:
1614 ++ ohci->prev_frame_no = prev_frame_no;
1615 + spin_unlock_irqrestore(&ohci->lock, flags);
1616 + }
1617 +
1618 +@@ -973,6 +976,7 @@ static void ohci_stop (struct usb_hcd *hcd)
1619 + if (quirk_nec(ohci))
1620 + flush_work(&ohci->nec_work);
1621 + del_timer_sync(&ohci->io_watchdog);
1622 ++ ohci->prev_frame_no = IO_WATCHDOG_OFF;
1623 +
1624 + ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
1625 + ohci_usb_reset(ohci);
1626 +diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
1627 +index fb7aaa3b9d06..634f3c7bf774 100644
1628 +--- a/drivers/usb/host/ohci-hub.c
1629 ++++ b/drivers/usb/host/ohci-hub.c
1630 +@@ -311,8 +311,10 @@ static int ohci_bus_suspend (struct usb_hcd *hcd)
1631 + rc = ohci_rh_suspend (ohci, 0);
1632 + spin_unlock_irq (&ohci->lock);
1633 +
1634 +- if (rc == 0)
1635 ++ if (rc == 0) {
1636 + del_timer_sync(&ohci->io_watchdog);
1637 ++ ohci->prev_frame_no = IO_WATCHDOG_OFF;
1638 ++ }
1639 + return rc;
1640 + }
1641 +
1642 +diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
1643 +index b2ec8c399363..4ccb85a67bb3 100644
1644 +--- a/drivers/usb/host/ohci-q.c
1645 ++++ b/drivers/usb/host/ohci-q.c
1646 +@@ -1019,6 +1019,8 @@ static void finish_unlinks(struct ohci_hcd *ohci)
1647 + * have modified this list. normally it's just prepending
1648 + * entries (which we'd ignore), but paranoia won't hurt.
1649 + */
1650 ++ *last = ed->ed_next;
1651 ++ ed->ed_next = NULL;
1652 + modified = 0;
1653 +
1654 + /* unlink urbs as requested, but rescan the list after
1655 +@@ -1077,21 +1079,22 @@ static void finish_unlinks(struct ohci_hcd *ohci)
1656 + goto rescan_this;
1657 +
1658 + /*
1659 +- * If no TDs are queued, take ED off the ed_rm_list.
1660 ++ * If no TDs are queued, ED is now idle.
1661 + * Otherwise, if the HC is running, reschedule.
1662 +- * If not, leave it on the list for further dequeues.
1663 ++ * If the HC isn't running, add ED back to the
1664 ++ * start of the list for later processing.
1665 + */
1666 + if (list_empty(&ed->td_list)) {
1667 +- *last = ed->ed_next;
1668 +- ed->ed_next = NULL;
1669 + ed->state = ED_IDLE;
1670 + list_del(&ed->in_use_list);
1671 + } else if (ohci->rh_state == OHCI_RH_RUNNING) {
1672 +- *last = ed->ed_next;
1673 +- ed->ed_next = NULL;
1674 + ed_schedule(ohci, ed);
1675 + } else {
1676 +- last = &ed->ed_next;
1677 ++ ed->ed_next = ohci->ed_rm_list;
1678 ++ ohci->ed_rm_list = ed;
1679 ++ /* Don't loop on the same ED */
1680 ++ if (last == &ohci->ed_rm_list)
1681 ++ last = &ed->ed_next;
1682 + }
1683 +
1684 + if (modified)
1685 +diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
1686 +index 5c1a3b852453..98ef7fcbda58 100644
1687 +--- a/drivers/usb/misc/ldusb.c
1688 ++++ b/drivers/usb/misc/ldusb.c
1689 +@@ -42,6 +42,9 @@
1690 + #define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033 /* USB Product ID of Micro-CASSY Time (reserved) */
1691 + #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035 /* USB Product ID of Micro-CASSY Temperature */
1692 + #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 /* USB Product ID of Micro-CASSY pH */
1693 ++#define USB_DEVICE_ID_LD_POWERANALYSERCASSY 0x1040 /* USB Product ID of Power Analyser CASSY */
1694 ++#define USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY 0x1042 /* USB Product ID of Converter Controller CASSY */
1695 ++#define USB_DEVICE_ID_LD_MACHINETESTCASSY 0x1043 /* USB Product ID of Machine Test CASSY */
1696 + #define USB_DEVICE_ID_LD_JWM 0x1080 /* USB Product ID of Joule and Wattmeter */
1697 + #define USB_DEVICE_ID_LD_DMMP 0x1081 /* USB Product ID of Digital Multimeter P (reserved) */
1698 + #define USB_DEVICE_ID_LD_UMIP 0x1090 /* USB Product ID of UMI P */
1699 +@@ -84,6 +87,9 @@ static const struct usb_device_id ld_usb_table[] = {
1700 + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) },
1701 + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) },
1702 + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) },
1703 ++ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERANALYSERCASSY) },
1704 ++ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY) },
1705 ++ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETESTCASSY) },
1706 + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) },
1707 + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) },
1708 + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
1709 +diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
1710 +index 2627363fb4fe..6f311212f3c5 100644
1711 +--- a/drivers/usb/musb/musb_host.c
1712 ++++ b/drivers/usb/musb/musb_host.c
1713 +@@ -393,13 +393,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb,
1714 + }
1715 + }
1716 +
1717 +- /*
1718 +- * The pipe must be broken if current urb->status is set, so don't
1719 +- * start next urb.
1720 +- * TODO: to minimize the risk of regression, only check urb->status
1721 +- * for RX, until we have a test case to understand the behavior of TX.
1722 +- */
1723 +- if ((!status || !is_in) && qh && qh->is_ready) {
1724 ++ if (qh != NULL && qh->is_ready) {
1725 + musb_dbg(musb, "... next ep%d %cX urb %p",
1726 + hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh));
1727 + musb_start_urb(musb, is_in, qh);
1728 +diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
1729 +index da031c45395a..fbec863350f6 100644
1730 +--- a/drivers/usb/phy/phy-mxs-usb.c
1731 ++++ b/drivers/usb/phy/phy-mxs-usb.c
1732 +@@ -602,6 +602,9 @@ static enum usb_charger_type mxs_phy_charger_detect(struct usb_phy *phy)
1733 + void __iomem *base = phy->io_priv;
1734 + enum usb_charger_type chgr_type = UNKNOWN_TYPE;
1735 +
1736 ++ if (!regmap)
1737 ++ return UNKNOWN_TYPE;
1738 ++
1739 + if (mxs_charger_data_contact_detect(mxs_phy))
1740 + return chgr_type;
1741 +
1742 +diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
1743 +index 2d24ef3076ef..b295e204a575 100644
1744 +--- a/drivers/usb/renesas_usbhs/fifo.c
1745 ++++ b/drivers/usb/renesas_usbhs/fifo.c
1746 +@@ -989,6 +989,10 @@ static int usbhsf_dma_prepare_pop_with_usb_dmac(struct usbhs_pkt *pkt,
1747 + if ((uintptr_t)pkt->buf & (USBHS_USB_DMAC_XFER_SIZE - 1))
1748 + goto usbhsf_pio_prepare_pop;
1749 +
1750 ++ /* return at this time if the pipe is running */
1751 ++ if (usbhs_pipe_is_running(pipe))
1752 ++ return 0;
1753 ++
1754 + usbhs_pipe_config_change_bfre(pipe, 1);
1755 +
1756 + ret = usbhsf_fifo_select(pipe, fifo, 0);
1757 +@@ -1179,6 +1183,7 @@ static int usbhsf_dma_pop_done_with_usb_dmac(struct usbhs_pkt *pkt,
1758 + usbhsf_fifo_clear(pipe, fifo);
1759 + pkt->actual = usbhs_dma_calc_received_size(pkt, chan, rcv_len);
1760 +
1761 ++ usbhs_pipe_running(pipe, 0);
1762 + usbhsf_dma_stop(pipe, fifo);
1763 + usbhsf_dma_unmap(pkt);
1764 + usbhsf_fifo_unselect(pipe, pipe->fifo);
1765 +diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c
1766 +index bf13d1ec51f3..04e7b3b29bac 100644
1767 +--- a/drivers/xen/tmem.c
1768 ++++ b/drivers/xen/tmem.c
1769 +@@ -284,6 +284,10 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset,
1770 + int pool = tmem_frontswap_poolid;
1771 + int ret;
1772 +
1773 ++ /* THP isn't supported */
1774 ++ if (PageTransHuge(page))
1775 ++ return -1;
1776 ++
1777 + if (pool < 0)
1778 + return -1;
1779 + if (ind64 != ind)
1780 +diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
1781 +index 5afd6e364fb6..c63b0b48e884 100644
1782 +--- a/include/drm/drm_atomic.h
1783 ++++ b/include/drm/drm_atomic.h
1784 +@@ -134,6 +134,15 @@ struct drm_crtc_commit {
1785 + * &drm_pending_vblank_event pointer to clean up private events.
1786 + */
1787 + struct drm_pending_vblank_event *event;
1788 ++
1789 ++ /**
1790 ++ * @abort_completion:
1791 ++ *
1792 ++ * A flag that's set after drm_atomic_helper_setup_commit takes a second
1793 ++ * reference for the completion of $drm_crtc_state.event. It's used by
1794 ++ * the free code to remove the second reference if commit fails.
1795 ++ */
1796 ++ bool abort_completion;
1797 + };
1798 +
1799 + struct __drm_planes_state {
1800 +diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
1801 +index fec5076eda91..dcde9471897d 100644
1802 +--- a/include/linux/kconfig.h
1803 ++++ b/include/linux/kconfig.h
1804 +@@ -4,6 +4,12 @@
1805 +
1806 + #include <generated/autoconf.h>
1807 +
1808 ++#ifdef CONFIG_CPU_BIG_ENDIAN
1809 ++#define __BIG_ENDIAN 4321
1810 ++#else
1811 ++#define __LITTLE_ENDIAN 1234
1812 ++#endif
1813 ++
1814 + #define __ARG_PLACEHOLDER_1 0,
1815 + #define __take_second_arg(__ignored, val, ...) val
1816 +
1817 +@@ -64,4 +70,7 @@
1818 + */
1819 + #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option))
1820 +
1821 ++/* Make sure we always have all types and struct attributes defined. */
1822 ++#include <linux/compiler_types.h>
1823 ++
1824 + #endif /* __LINUX_KCONFIG_H */
1825 +diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h
1826 +index 144de4d2f385..153c9c2eaaa7 100644
1827 +--- a/include/uapi/linux/if_ether.h
1828 ++++ b/include/uapi/linux/if_ether.h
1829 +@@ -23,7 +23,6 @@
1830 + #define _UAPI_LINUX_IF_ETHER_H
1831 +
1832 + #include <linux/types.h>
1833 +-#include <linux/libc-compat.h>
1834 +
1835 + /*
1836 + * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
1837 +@@ -150,6 +149,11 @@
1838 + * This is an Ethernet frame header.
1839 + */
1840 +
1841 ++/* allow libcs like musl to deactivate this, glibc does not implement this. */
1842 ++#ifndef __UAPI_DEF_ETHHDR
1843 ++#define __UAPI_DEF_ETHHDR 1
1844 ++#endif
1845 ++
1846 + #if __UAPI_DEF_ETHHDR
1847 + struct ethhdr {
1848 + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
1849 +diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
1850 +index fc29efaa918c..8254c937c9f4 100644
1851 +--- a/include/uapi/linux/libc-compat.h
1852 ++++ b/include/uapi/linux/libc-compat.h
1853 +@@ -264,10 +264,4 @@
1854 +
1855 + #endif /* __GLIBC__ */
1856 +
1857 +-/* Definitions for if_ether.h */
1858 +-/* allow libcs like musl to deactivate this, glibc does not implement this. */
1859 +-#ifndef __UAPI_DEF_ETHHDR
1860 +-#define __UAPI_DEF_ETHHDR 1
1861 +-#endif
1862 +-
1863 + #endif /* _UAPI_LIBC_COMPAT_H */
1864 +diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c
1865 +index 5187dfe809ac..4c5770407031 100644
1866 +--- a/kernel/irq/matrix.c
1867 ++++ b/kernel/irq/matrix.c
1868 +@@ -16,6 +16,7 @@ struct cpumap {
1869 + unsigned int available;
1870 + unsigned int allocated;
1871 + unsigned int managed;
1872 ++ bool initialized;
1873 + bool online;
1874 + unsigned long alloc_map[IRQ_MATRIX_SIZE];
1875 + unsigned long managed_map[IRQ_MATRIX_SIZE];
1876 +@@ -81,9 +82,11 @@ void irq_matrix_online(struct irq_matrix *m)
1877 +
1878 + BUG_ON(cm->online);
1879 +
1880 +- bitmap_zero(cm->alloc_map, m->matrix_bits);
1881 +- cm->available = m->alloc_size - (cm->managed + m->systembits_inalloc);
1882 +- cm->allocated = 0;
1883 ++ if (!cm->initialized) {
1884 ++ cm->available = m->alloc_size;
1885 ++ cm->available -= cm->managed + m->systembits_inalloc;
1886 ++ cm->initialized = true;
1887 ++ }
1888 + m->global_available += cm->available;
1889 + cm->online = true;
1890 + m->online_maps++;
1891 +@@ -370,14 +373,16 @@ void irq_matrix_free(struct irq_matrix *m, unsigned int cpu,
1892 + if (WARN_ON_ONCE(bit < m->alloc_start || bit >= m->alloc_end))
1893 + return;
1894 +
1895 +- if (cm->online) {
1896 +- clear_bit(bit, cm->alloc_map);
1897 +- cm->allocated--;
1898 ++ clear_bit(bit, cm->alloc_map);
1899 ++ cm->allocated--;
1900 ++
1901 ++ if (cm->online)
1902 + m->total_allocated--;
1903 +- if (!managed) {
1904 +- cm->available++;
1905 ++
1906 ++ if (!managed) {
1907 ++ cm->available++;
1908 ++ if (cm->online)
1909 + m->global_available++;
1910 +- }
1911 + }
1912 + trace_irq_matrix_free(bit, cpu, m, cm);
1913 + }
1914 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
1915 +index d23818c5465a..9f927497f2f5 100644
1916 +--- a/mm/page_alloc.c
1917 ++++ b/mm/page_alloc.c
1918 +@@ -46,6 +46,7 @@
1919 + #include <linux/stop_machine.h>
1920 + #include <linux/sort.h>
1921 + #include <linux/pfn.h>
1922 ++#include <xen/xen.h>
1923 + #include <linux/backing-dev.h>
1924 + #include <linux/fault-inject.h>
1925 + #include <linux/page-isolation.h>
1926 +@@ -347,6 +348,9 @@ static inline bool update_defer_init(pg_data_t *pgdat,
1927 + /* Always populate low zones for address-contrained allocations */
1928 + if (zone_end < pgdat_end_pfn(pgdat))
1929 + return true;
1930 ++ /* Xen PV domains need page structures early */
1931 ++ if (xen_pv_domain())
1932 ++ return true;
1933 + (*nr_initialised)++;
1934 + if ((*nr_initialised > pgdat->static_init_pgcnt) &&
1935 + (pfn & (PAGES_PER_SECTION - 1)) == 0) {
1936 +diff --git a/mm/zswap.c b/mm/zswap.c
1937 +index d39581a076c3..597008a44f70 100644
1938 +--- a/mm/zswap.c
1939 ++++ b/mm/zswap.c
1940 +@@ -970,6 +970,12 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
1941 + u8 *src, *dst;
1942 + struct zswap_header *zhdr;
1943 +
1944 ++ /* THP isn't supported */
1945 ++ if (PageTransHuge(page)) {
1946 ++ ret = -EINVAL;
1947 ++ goto reject;
1948 ++ }
1949 ++
1950 + if (!zswap_enabled || !tree) {
1951 + ret = -ENODEV;
1952 + goto reject;
1953 +diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
1954 +index c7df4969f80a..f56aab54e0c8 100644
1955 +--- a/net/ipv4/ip_sockglue.c
1956 ++++ b/net/ipv4/ip_sockglue.c
1957 +@@ -1563,10 +1563,7 @@ int ip_getsockopt(struct sock *sk, int level,
1958 + if (get_user(len, optlen))
1959 + return -EFAULT;
1960 +
1961 +- lock_sock(sk);
1962 +- err = nf_getsockopt(sk, PF_INET, optname, optval,
1963 +- &len);
1964 +- release_sock(sk);
1965 ++ err = nf_getsockopt(sk, PF_INET, optname, optval, &len);
1966 + if (err >= 0)
1967 + err = put_user(len, optlen);
1968 + return err;
1969 +@@ -1598,9 +1595,7 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname,
1970 + if (get_user(len, optlen))
1971 + return -EFAULT;
1972 +
1973 +- lock_sock(sk);
1974 + err = compat_nf_getsockopt(sk, PF_INET, optname, optval, &len);
1975 +- release_sock(sk);
1976 + if (err >= 0)
1977 + err = put_user(len, optlen);
1978 + return err;
1979 +diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
1980 +index d78d41fc4b1a..24535169663d 100644
1981 +--- a/net/ipv6/ipv6_sockglue.c
1982 ++++ b/net/ipv6/ipv6_sockglue.c
1983 +@@ -1367,10 +1367,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname,
1984 + if (get_user(len, optlen))
1985 + return -EFAULT;
1986 +
1987 +- lock_sock(sk);
1988 +- err = nf_getsockopt(sk, PF_INET6, optname, optval,
1989 +- &len);
1990 +- release_sock(sk);
1991 ++ err = nf_getsockopt(sk, PF_INET6, optname, optval, &len);
1992 + if (err >= 0)
1993 + err = put_user(len, optlen);
1994 + }
1995 +@@ -1409,10 +1406,7 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,
1996 + if (get_user(len, optlen))
1997 + return -EFAULT;
1998 +
1999 +- lock_sock(sk);
2000 +- err = compat_nf_getsockopt(sk, PF_INET6,
2001 +- optname, optval, &len);
2002 +- release_sock(sk);
2003 ++ err = compat_nf_getsockopt(sk, PF_INET6, optname, optval, &len);
2004 + if (err >= 0)
2005 + err = put_user(len, optlen);
2006 + }
2007 +diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
2008 +index fb15d3b97cb2..84f757c5d91a 100644
2009 +--- a/net/mac80211/cfg.c
2010 ++++ b/net/mac80211/cfg.c
2011 +@@ -2863,7 +2863,7 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
2012 + }
2013 + if (beacon->probe_resp_len) {
2014 + new_beacon->probe_resp_len = beacon->probe_resp_len;
2015 +- beacon->probe_resp = pos;
2016 ++ new_beacon->probe_resp = pos;
2017 + memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
2018 + pos += beacon->probe_resp_len;
2019 + }