Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.4 commit in: /
Date: Mon, 07 Aug 2017 10:25:55
Message-Id: 1502101543.fd803648f495a130c6e667d35a20294307f534bb.mpagano@gentoo
1 commit: fd803648f495a130c6e667d35a20294307f534bb
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Mon Aug 7 10:25:43 2017 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Mon Aug 7 10:25:43 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=fd803648
7
8 Linux patch 4.4.80
9
10 0000_README | 4 +
11 1079_linux-4.4.80.patch | 3287 +++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 3291 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index 2986ab7..82594ae 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -359,6 +359,10 @@ Patch: 1078_linux-4.4.79.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.4.79
21
22 +Patch: 1079_linux-4.4.80.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.4.80
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/1079_linux-4.4.80.patch b/1079_linux-4.4.80.patch
31 new file mode 100644
32 index 0000000..3594fbc
33 --- /dev/null
34 +++ b/1079_linux-4.4.80.patch
35 @@ -0,0 +1,3287 @@
36 +diff --git a/Makefile b/Makefile
37 +index 1440a94b2474..dddd55adde24 100644
38 +--- a/Makefile
39 ++++ b/Makefile
40 +@@ -1,6 +1,6 @@
41 + VERSION = 4
42 + PATCHLEVEL = 4
43 +-SUBLEVEL = 79
44 ++SUBLEVEL = 80
45 + EXTRAVERSION =
46 + NAME = Blurry Fish Butt
47 +
48 +diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
49 +index 5f5e0f3d5b64..27cd4abfc74d 100644
50 +--- a/arch/arm/boot/dts/omap3-n900.dts
51 ++++ b/arch/arm/boot/dts/omap3-n900.dts
52 +@@ -697,6 +697,8 @@
53 + vmmc_aux-supply = <&vsim>;
54 + bus-width = <8>;
55 + non-removable;
56 ++ no-sdio;
57 ++ no-sd;
58 + };
59 +
60 + &mmc3 {
61 +diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
62 +index f3142369f594..01116ee1284b 100644
63 +--- a/arch/arm/configs/s3c2410_defconfig
64 ++++ b/arch/arm/configs/s3c2410_defconfig
65 +@@ -87,9 +87,9 @@ CONFIG_IPV6_TUNNEL=m
66 + CONFIG_NETFILTER=y
67 + CONFIG_NF_CONNTRACK=m
68 + CONFIG_NF_CONNTRACK_EVENTS=y
69 +-CONFIG_NF_CT_PROTO_DCCP=m
70 +-CONFIG_NF_CT_PROTO_SCTP=m
71 +-CONFIG_NF_CT_PROTO_UDPLITE=m
72 ++CONFIG_NF_CT_PROTO_DCCP=y
73 ++CONFIG_NF_CT_PROTO_SCTP=y
74 ++CONFIG_NF_CT_PROTO_UDPLITE=y
75 + CONFIG_NF_CONNTRACK_AMANDA=m
76 + CONFIG_NF_CONNTRACK_FTP=m
77 + CONFIG_NF_CONNTRACK_H323=m
78 +diff --git a/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts b/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts
79 +index ce5d848251fa..7b34822d61e9 100644
80 +--- a/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts
81 ++++ b/arch/arm64/boot/dts/xilinx/zynqmp-ep108.dts
82 +@@ -26,7 +26,7 @@
83 + stdout-path = "serial0:115200n8";
84 + };
85 +
86 +- memory {
87 ++ memory@0 {
88 + device_type = "memory";
89 + reg = <0x0 0x0 0x40000000>;
90 + };
91 +diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
92 +index 857eda5c7217..172402cc1a0f 100644
93 +--- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
94 ++++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi
95 +@@ -71,7 +71,7 @@
96 + <1 10 0xf01>;
97 + };
98 +
99 +- amba_apu {
100 ++ amba_apu: amba_apu@0 {
101 + compatible = "simple-bus";
102 + #address-cells = <2>;
103 + #size-cells = <1>;
104 +@@ -191,7 +191,7 @@
105 + };
106 +
107 + i2c0: i2c@ff020000 {
108 +- compatible = "cdns,i2c-r1p10";
109 ++ compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
110 + status = "disabled";
111 + interrupt-parent = <&gic>;
112 + interrupts = <0 17 4>;
113 +@@ -202,7 +202,7 @@
114 + };
115 +
116 + i2c1: i2c@ff030000 {
117 +- compatible = "cdns,i2c-r1p10";
118 ++ compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
119 + status = "disabled";
120 + interrupt-parent = <&gic>;
121 + interrupts = <0 18 4>;
122 +diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
123 +index 247bae758e1e..a4b466424a32 100644
124 +--- a/arch/arm64/mm/fault.c
125 ++++ b/arch/arm64/mm/fault.c
126 +@@ -66,21 +66,21 @@ void show_pte(struct mm_struct *mm, unsigned long addr)
127 + break;
128 +
129 + pud = pud_offset(pgd, addr);
130 +- printk(", *pud=%016llx", pud_val(*pud));
131 ++ pr_cont(", *pud=%016llx", pud_val(*pud));
132 + if (pud_none(*pud) || pud_bad(*pud))
133 + break;
134 +
135 + pmd = pmd_offset(pud, addr);
136 +- printk(", *pmd=%016llx", pmd_val(*pmd));
137 ++ pr_cont(", *pmd=%016llx", pmd_val(*pmd));
138 + if (pmd_none(*pmd) || pmd_bad(*pmd))
139 + break;
140 +
141 + pte = pte_offset_map(pmd, addr);
142 +- printk(", *pte=%016llx", pte_val(*pte));
143 ++ pr_cont(", *pte=%016llx", pte_val(*pte));
144 + pte_unmap(pte);
145 + } while(0);
146 +
147 +- printk("\n");
148 ++ pr_cont("\n");
149 + }
150 +
151 + #ifdef CONFIG_ARM64_HW_AFDBM
152 +diff --git a/arch/openrisc/kernel/vmlinux.lds.S b/arch/openrisc/kernel/vmlinux.lds.S
153 +index 2d69a853b742..3a08b55609b6 100644
154 +--- a/arch/openrisc/kernel/vmlinux.lds.S
155 ++++ b/arch/openrisc/kernel/vmlinux.lds.S
156 +@@ -38,6 +38,8 @@ SECTIONS
157 + /* Read-only sections, merged into text segment: */
158 + . = LOAD_BASE ;
159 +
160 ++ _text = .;
161 ++
162 + /* _s_kernel_ro must be page aligned */
163 + . = ALIGN(PAGE_SIZE);
164 + _s_kernel_ro = .;
165 +diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
166 +index 329771559cbb..8b3b46b7b0f2 100644
167 +--- a/arch/powerpc/include/asm/topology.h
168 ++++ b/arch/powerpc/include/asm/topology.h
169 +@@ -44,22 +44,8 @@ extern void __init dump_numa_cpu_topology(void);
170 + extern int sysfs_add_device_to_node(struct device *dev, int nid);
171 + extern void sysfs_remove_device_from_node(struct device *dev, int nid);
172 +
173 +-static inline int early_cpu_to_node(int cpu)
174 +-{
175 +- int nid;
176 +-
177 +- nid = numa_cpu_lookup_table[cpu];
178 +-
179 +- /*
180 +- * Fall back to node 0 if nid is unset (it should be, except bugs).
181 +- * This allows callers to safely do NODE_DATA(early_cpu_to_node(cpu)).
182 +- */
183 +- return (nid < 0) ? 0 : nid;
184 +-}
185 + #else
186 +
187 +-static inline int early_cpu_to_node(int cpu) { return 0; }
188 +-
189 + static inline void dump_numa_cpu_topology(void) {}
190 +
191 + static inline int sysfs_add_device_to_node(struct device *dev, int nid)
192 +diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
193 +index fe6e800c1357..a20823210ac0 100644
194 +--- a/arch/powerpc/kernel/setup_64.c
195 ++++ b/arch/powerpc/kernel/setup_64.c
196 +@@ -751,7 +751,7 @@ void __init setup_arch(char **cmdline_p)
197 +
198 + static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align)
199 + {
200 +- return __alloc_bootmem_node(NODE_DATA(early_cpu_to_node(cpu)), size, align,
201 ++ return __alloc_bootmem_node(NODE_DATA(cpu_to_node(cpu)), size, align,
202 + __pa(MAX_DMA_ADDRESS));
203 + }
204 +
205 +@@ -762,7 +762,7 @@ static void __init pcpu_fc_free(void *ptr, size_t size)
206 +
207 + static int pcpu_cpu_distance(unsigned int from, unsigned int to)
208 + {
209 +- if (early_cpu_to_node(from) == early_cpu_to_node(to))
210 ++ if (cpu_to_node(from) == cpu_to_node(to))
211 + return LOCAL_DISTANCE;
212 + else
213 + return REMOTE_DISTANCE;
214 +diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
215 +index 396dc44e783b..428563b195c3 100644
216 +--- a/arch/powerpc/kvm/book3s_hv.c
217 ++++ b/arch/powerpc/kvm/book3s_hv.c
218 +@@ -2687,6 +2687,10 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
219 + {
220 + int r;
221 + int srcu_idx;
222 ++ unsigned long ebb_regs[3] = {}; /* shut up GCC */
223 ++ unsigned long user_tar = 0;
224 ++ unsigned long proc_fscr = 0;
225 ++ unsigned int user_vrsave;
226 +
227 + if (!vcpu->arch.sane) {
228 + run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
229 +@@ -2707,10 +2711,11 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
230 + run->fail_entry.hardware_entry_failure_reason = 0;
231 + return -EINVAL;
232 + }
233 ++ /* Enable TM so we can read the TM SPRs */
234 ++ mtmsr(mfmsr() | MSR_TM);
235 + current->thread.tm_tfhar = mfspr(SPRN_TFHAR);
236 + current->thread.tm_tfiar = mfspr(SPRN_TFIAR);
237 + current->thread.tm_texasr = mfspr(SPRN_TEXASR);
238 +- current->thread.regs->msr &= ~MSR_TM;
239 + }
240 + #endif
241 +
242 +@@ -2736,6 +2741,17 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
243 + flush_fp_to_thread(current);
244 + flush_altivec_to_thread(current);
245 + flush_vsx_to_thread(current);
246 ++
247 ++ /* Save userspace EBB and other register values */
248 ++ if (cpu_has_feature(CPU_FTR_ARCH_207S)) {
249 ++ ebb_regs[0] = mfspr(SPRN_EBBHR);
250 ++ ebb_regs[1] = mfspr(SPRN_EBBRR);
251 ++ ebb_regs[2] = mfspr(SPRN_BESCR);
252 ++ user_tar = mfspr(SPRN_TAR);
253 ++ proc_fscr = mfspr(SPRN_FSCR);
254 ++ }
255 ++ user_vrsave = mfspr(SPRN_VRSAVE);
256 ++
257 + vcpu->arch.wqp = &vcpu->arch.vcore->wq;
258 + vcpu->arch.pgdir = current->mm->pgd;
259 + vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST;
260 +@@ -2757,6 +2773,29 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
261 + }
262 + } while (is_kvmppc_resume_guest(r));
263 +
264 ++ /* Restore userspace EBB and other register values */
265 ++ if (cpu_has_feature(CPU_FTR_ARCH_207S)) {
266 ++ mtspr(SPRN_EBBHR, ebb_regs[0]);
267 ++ mtspr(SPRN_EBBRR, ebb_regs[1]);
268 ++ mtspr(SPRN_BESCR, ebb_regs[2]);
269 ++ mtspr(SPRN_TAR, user_tar);
270 ++ mtspr(SPRN_FSCR, proc_fscr);
271 ++ }
272 ++ mtspr(SPRN_VRSAVE, user_vrsave);
273 ++
274 ++ /*
275 ++ * Since we don't do lazy TM reload, we need to reload
276 ++ * the TM registers here.
277 ++ */
278 ++#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
279 ++ if (cpu_has_feature(CPU_FTR_TM) && current->thread.regs &&
280 ++ (current->thread.regs->msr & MSR_TM)) {
281 ++ mtspr(SPRN_TFHAR, current->thread.tm_tfhar);
282 ++ mtspr(SPRN_TFIAR, current->thread.tm_tfiar);
283 ++ mtspr(SPRN_TEXASR, current->thread.tm_texasr);
284 ++ }
285 ++#endif
286 ++
287 + out:
288 + vcpu->arch.state = KVMPPC_VCPU_NOTREADY;
289 + atomic_dec(&vcpu->kvm->arch.vcpus_running);
290 +diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
291 +index 1a743f87b37d..ffab9269bfe4 100644
292 +--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
293 ++++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
294 +@@ -36,6 +36,13 @@
295 + #define NAPPING_CEDE 1
296 + #define NAPPING_NOVCPU 2
297 +
298 ++/* Stack frame offsets for kvmppc_hv_entry */
299 ++#define SFS 112
300 ++#define STACK_SLOT_TRAP (SFS-4)
301 ++#define STACK_SLOT_CIABR (SFS-16)
302 ++#define STACK_SLOT_DAWR (SFS-24)
303 ++#define STACK_SLOT_DAWRX (SFS-32)
304 ++
305 + /*
306 + * Call kvmppc_hv_entry in real mode.
307 + * Must be called with interrupts hard-disabled.
308 +@@ -274,10 +281,10 @@ kvm_novcpu_exit:
309 + bl kvmhv_accumulate_time
310 + #endif
311 + 13: mr r3, r12
312 +- stw r12, 112-4(r1)
313 ++ stw r12, STACK_SLOT_TRAP(r1)
314 + bl kvmhv_commence_exit
315 + nop
316 +- lwz r12, 112-4(r1)
317 ++ lwz r12, STACK_SLOT_TRAP(r1)
318 + b kvmhv_switch_to_host
319 +
320 + /*
321 +@@ -489,7 +496,7 @@ kvmppc_hv_entry:
322 + */
323 + mflr r0
324 + std r0, PPC_LR_STKOFF(r1)
325 +- stdu r1, -112(r1)
326 ++ stdu r1, -SFS(r1)
327 +
328 + /* Save R1 in the PACA */
329 + std r1, HSTATE_HOST_R1(r13)
330 +@@ -643,6 +650,16 @@ kvmppc_got_guest:
331 + mtspr SPRN_PURR,r7
332 + mtspr SPRN_SPURR,r8
333 +
334 ++ /* Save host values of some registers */
335 ++BEGIN_FTR_SECTION
336 ++ mfspr r5, SPRN_CIABR
337 ++ mfspr r6, SPRN_DAWR
338 ++ mfspr r7, SPRN_DAWRX
339 ++ std r5, STACK_SLOT_CIABR(r1)
340 ++ std r6, STACK_SLOT_DAWR(r1)
341 ++ std r7, STACK_SLOT_DAWRX(r1)
342 ++END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
343 ++
344 + BEGIN_FTR_SECTION
345 + /* Set partition DABR */
346 + /* Do this before re-enabling PMU to avoid P7 DABR corruption bug */
347 +@@ -1266,8 +1283,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
348 + */
349 + li r0, 0
350 + mtspr SPRN_IAMR, r0
351 +- mtspr SPRN_CIABR, r0
352 +- mtspr SPRN_DAWRX, r0
353 ++ mtspr SPRN_PSPB, r0
354 + mtspr SPRN_TCSCR, r0
355 + mtspr SPRN_WORT, r0
356 + /* Set MMCRS to 1<<31 to freeze and disable the SPMC counters */
357 +@@ -1283,6 +1299,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
358 + std r6,VCPU_UAMOR(r9)
359 + li r6,0
360 + mtspr SPRN_AMR,r6
361 ++ mtspr SPRN_UAMOR, r6
362 +
363 + /* Switch DSCR back to host value */
364 + mfspr r8, SPRN_DSCR
365 +@@ -1424,6 +1441,16 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
366 + slbia
367 + ptesync
368 +
369 ++ /* Restore host values of some registers */
370 ++BEGIN_FTR_SECTION
371 ++ ld r5, STACK_SLOT_CIABR(r1)
372 ++ ld r6, STACK_SLOT_DAWR(r1)
373 ++ ld r7, STACK_SLOT_DAWRX(r1)
374 ++ mtspr SPRN_CIABR, r5
375 ++ mtspr SPRN_DAWR, r6
376 ++ mtspr SPRN_DAWRX, r7
377 ++END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
378 ++
379 + /*
380 + * POWER7/POWER8 guest -> host partition switch code.
381 + * We don't have to lock against tlbies but we do
382 +@@ -1533,8 +1560,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
383 + li r0, KVM_GUEST_MODE_NONE
384 + stb r0, HSTATE_IN_GUEST(r13)
385 +
386 +- ld r0, 112+PPC_LR_STKOFF(r1)
387 +- addi r1, r1, 112
388 ++ ld r0, SFS+PPC_LR_STKOFF(r1)
389 ++ addi r1, r1, SFS
390 + mtlr r0
391 + blr
392 +
393 +diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
394 +index 7c7fcc042549..fb695f142563 100644
395 +--- a/arch/powerpc/platforms/pseries/reconfig.c
396 ++++ b/arch/powerpc/platforms/pseries/reconfig.c
397 +@@ -82,7 +82,6 @@ static int pSeries_reconfig_remove_node(struct device_node *np)
398 +
399 + of_detach_node(np);
400 + of_node_put(parent);
401 +- of_node_put(np); /* Must decrement the refcount */
402 + return 0;
403 + }
404 +
405 +diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
406 +index 62aca448726a..2116176c1721 100644
407 +--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
408 ++++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
409 +@@ -682,6 +682,9 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank)
410 + const char *name = th_names[bank];
411 + int err = 0;
412 +
413 ++ if (!dev)
414 ++ return -ENODEV;
415 ++
416 + if (is_shared_bank(bank)) {
417 + nb = node_to_amd_nb(amd_get_nb_id(cpu));
418 +
419 +diff --git a/crypto/authencesn.c b/crypto/authencesn.c
420 +index 0c0468869e25..52154ef21b5e 100644
421 +--- a/crypto/authencesn.c
422 ++++ b/crypto/authencesn.c
423 +@@ -245,6 +245,9 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req,
424 + u8 *ihash = ohash + crypto_ahash_digestsize(auth);
425 + u32 tmp[2];
426 +
427 ++ if (!authsize)
428 ++ goto decrypt;
429 ++
430 + /* Move high-order bits of sequence number back. */
431 + scatterwalk_map_and_copy(tmp, dst, 4, 4, 0);
432 + scatterwalk_map_and_copy(tmp + 1, dst, assoclen + cryptlen, 4, 0);
433 +@@ -253,6 +256,8 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req,
434 + if (crypto_memneq(ihash, ohash, authsize))
435 + return -EBADMSG;
436 +
437 ++decrypt:
438 ++
439 + sg_init_table(areq_ctx->dst, 2);
440 + dst = scatterwalk_ffwd(areq_ctx->dst, dst, assoclen);
441 +
442 +diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
443 +index 5ea5dc219f56..73c9c7fa9001 100644
444 +--- a/drivers/acpi/glue.c
445 ++++ b/drivers/acpi/glue.c
446 +@@ -98,7 +98,15 @@ static int find_child_checks(struct acpi_device *adev, bool check_children)
447 + if (check_children && list_empty(&adev->children))
448 + return -ENODEV;
449 +
450 +- return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE;
451 ++ /*
452 ++ * If the device has a _HID (or _CID) returning a valid ACPI/PNP
453 ++ * device ID, it is better to make it look less attractive here, so that
454 ++ * the other device with the same _ADR value (that may not have a valid
455 ++ * device ID) can be matched going forward. [This means a second spec
456 ++ * violation in a row, so whatever we do here is best effort anyway.]
457 ++ */
458 ++ return sta_present && list_empty(&adev->pnp.ids) ?
459 ++ FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE;
460 + }
461 +
462 + struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
463 +diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
464 +index 3f94e5fc110a..78b0ece0c867 100644
465 +--- a/drivers/base/power/domain.c
466 ++++ b/drivers/base/power/domain.c
467 +@@ -1188,7 +1188,6 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev,
468 + }
469 +
470 + dev->power.subsys_data->domain_data = &gpd_data->base;
471 +- dev->pm_domain = &genpd->domain;
472 +
473 + spin_unlock_irq(&dev->power.lock);
474 +
475 +@@ -1207,7 +1206,6 @@ static void genpd_free_dev_data(struct device *dev,
476 + {
477 + spin_lock_irq(&dev->power.lock);
478 +
479 +- dev->pm_domain = NULL;
480 + dev->power.subsys_data->domain_data = NULL;
481 +
482 + spin_unlock_irq(&dev->power.lock);
483 +@@ -1248,6 +1246,8 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
484 + if (ret)
485 + goto out;
486 +
487 ++ dev->pm_domain = &genpd->domain;
488 ++
489 + genpd->device_count++;
490 + genpd->max_off_time_changed = true;
491 +
492 +@@ -1299,6 +1299,8 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd,
493 + if (genpd->detach_dev)
494 + genpd->detach_dev(genpd, dev);
495 +
496 ++ dev->pm_domain = NULL;
497 ++
498 + list_del_init(&pdd->list_node);
499 +
500 + mutex_unlock(&genpd->lock);
501 +diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
502 +index 41fb1a917b17..33e23a7a691f 100644
503 +--- a/drivers/block/xen-blkback/blkback.c
504 ++++ b/drivers/block/xen-blkback/blkback.c
505 +@@ -595,8 +595,6 @@ int xen_blkif_schedule(void *arg)
506 + unsigned long timeout;
507 + int ret;
508 +
509 +- xen_blkif_get(blkif);
510 +-
511 + while (!kthread_should_stop()) {
512 + if (try_to_freeze())
513 + continue;
514 +@@ -650,7 +648,6 @@ purge_gnt_list:
515 + print_stats(blkif);
516 +
517 + blkif->xenblkd = NULL;
518 +- xen_blkif_put(blkif);
519 +
520 + return 0;
521 + }
522 +diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
523 +index f53cff42f8da..923308201375 100644
524 +--- a/drivers/block/xen-blkback/xenbus.c
525 ++++ b/drivers/block/xen-blkback/xenbus.c
526 +@@ -221,7 +221,6 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
527 + if (blkif->xenblkd) {
528 + kthread_stop(blkif->xenblkd);
529 + wake_up(&blkif->shutdown_wq);
530 +- blkif->xenblkd = NULL;
531 + }
532 +
533 + /* The above kthread_stop() guarantees that at this point we
534 +@@ -266,9 +265,10 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
535 +
536 + static void xen_blkif_free(struct xen_blkif *blkif)
537 + {
538 +-
539 +- xen_blkif_disconnect(blkif);
540 ++ WARN_ON(xen_blkif_disconnect(blkif));
541 + xen_vbd_free(&blkif->vbd);
542 ++ kfree(blkif->be->mode);
543 ++ kfree(blkif->be);
544 +
545 + /* Make sure everything is drained before shutting down */
546 + BUG_ON(blkif->persistent_gnt_c != 0);
547 +@@ -445,8 +445,6 @@ static int xen_blkbk_remove(struct xenbus_device *dev)
548 + xen_blkif_put(be->blkif);
549 + }
550 +
551 +- kfree(be->mode);
552 +- kfree(be);
553 + return 0;
554 + }
555 +
556 +diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
557 +index 096f0cef4da1..40d400fe5bb7 100644
558 +--- a/drivers/char/ipmi/ipmi_watchdog.c
559 ++++ b/drivers/char/ipmi/ipmi_watchdog.c
560 +@@ -1162,10 +1162,11 @@ static int wdog_reboot_handler(struct notifier_block *this,
561 + ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
562 + ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB);
563 + } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
564 +- /* Set a long timer to let the reboot happens, but
565 +- reboot if it hangs, but only if the watchdog
566 ++ /* Set a long timer to let the reboot happen or
567 ++ reset if it hangs, but only if the watchdog
568 + timer was already running. */
569 +- timeout = 120;
570 ++ if (timeout < 120)
571 ++ timeout = 120;
572 + pretimeout = 0;
573 + ipmi_watchdog_state = WDOG_TIMEOUT_RESET;
574 + ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB);
575 +diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
576 +index 6d56877b2e0a..a0d9ac6b6cc9 100644
577 +--- a/drivers/char/tpm/tpm-chip.c
578 ++++ b/drivers/char/tpm/tpm-chip.c
579 +@@ -29,9 +29,8 @@
580 + #include "tpm.h"
581 + #include "tpm_eventlog.h"
582 +
583 +-static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES);
584 +-static LIST_HEAD(tpm_chip_list);
585 +-static DEFINE_SPINLOCK(driver_lock);
586 ++DEFINE_IDR(dev_nums_idr);
587 ++static DEFINE_MUTEX(idr_lock);
588 +
589 + struct class *tpm_class;
590 + dev_t tpm_devt;
591 +@@ -92,20 +91,30 @@ EXPORT_SYMBOL_GPL(tpm_put_ops);
592 + */
593 + struct tpm_chip *tpm_chip_find_get(int chip_num)
594 + {
595 +- struct tpm_chip *pos, *chip = NULL;
596 ++ struct tpm_chip *chip, *res = NULL;
597 ++ int chip_prev;
598 ++
599 ++ mutex_lock(&idr_lock);
600 ++
601 ++ if (chip_num == TPM_ANY_NUM) {
602 ++ chip_num = 0;
603 ++ do {
604 ++ chip_prev = chip_num;
605 ++ chip = idr_get_next(&dev_nums_idr, &chip_num);
606 ++ if (chip && !tpm_try_get_ops(chip)) {
607 ++ res = chip;
608 ++ break;
609 ++ }
610 ++ } while (chip_prev != chip_num);
611 ++ } else {
612 ++ chip = idr_find_slowpath(&dev_nums_idr, chip_num);
613 ++ if (chip && !tpm_try_get_ops(chip))
614 ++ res = chip;
615 ++ }
616 +
617 +- rcu_read_lock();
618 +- list_for_each_entry_rcu(pos, &tpm_chip_list, list) {
619 +- if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
620 +- continue;
621 ++ mutex_unlock(&idr_lock);
622 +
623 +- /* rcu prevents chip from being free'd */
624 +- if (!tpm_try_get_ops(pos))
625 +- chip = pos;
626 +- break;
627 +- }
628 +- rcu_read_unlock();
629 +- return chip;
630 ++ return res;
631 + }
632 +
633 + /**
634 +@@ -118,9 +127,10 @@ static void tpm_dev_release(struct device *dev)
635 + {
636 + struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev);
637 +
638 +- spin_lock(&driver_lock);
639 +- clear_bit(chip->dev_num, dev_mask);
640 +- spin_unlock(&driver_lock);
641 ++ mutex_lock(&idr_lock);
642 ++ idr_remove(&dev_nums_idr, chip->dev_num);
643 ++ mutex_unlock(&idr_lock);
644 ++
645 + kfree(chip);
646 + }
647 +
648 +@@ -173,6 +183,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
649 + const struct tpm_class_ops *ops)
650 + {
651 + struct tpm_chip *chip;
652 ++ int rc;
653 +
654 + chip = kzalloc(sizeof(*chip), GFP_KERNEL);
655 + if (chip == NULL)
656 +@@ -180,21 +191,18 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
657 +
658 + mutex_init(&chip->tpm_mutex);
659 + init_rwsem(&chip->ops_sem);
660 +- INIT_LIST_HEAD(&chip->list);
661 +
662 + chip->ops = ops;
663 +
664 +- spin_lock(&driver_lock);
665 +- chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES);
666 +- spin_unlock(&driver_lock);
667 +-
668 +- if (chip->dev_num >= TPM_NUM_DEVICES) {
669 ++ mutex_lock(&idr_lock);
670 ++ rc = idr_alloc(&dev_nums_idr, NULL, 0, TPM_NUM_DEVICES, GFP_KERNEL);
671 ++ mutex_unlock(&idr_lock);
672 ++ if (rc < 0) {
673 + dev_err(dev, "No available tpm device numbers\n");
674 + kfree(chip);
675 +- return ERR_PTR(-ENOMEM);
676 ++ return ERR_PTR(rc);
677 + }
678 +-
679 +- set_bit(chip->dev_num, dev_mask);
680 ++ chip->dev_num = rc;
681 +
682 + scnprintf(chip->devname, sizeof(chip->devname), "tpm%d", chip->dev_num);
683 +
684 +@@ -252,19 +260,28 @@ static int tpm_add_char_device(struct tpm_chip *chip)
685 + return rc;
686 + }
687 +
688 ++ /* Make the chip available. */
689 ++ mutex_lock(&idr_lock);
690 ++ idr_replace(&dev_nums_idr, chip, chip->dev_num);
691 ++ mutex_unlock(&idr_lock);
692 ++
693 + return rc;
694 + }
695 +
696 + static void tpm_del_char_device(struct tpm_chip *chip)
697 + {
698 + cdev_del(&chip->cdev);
699 ++ device_del(&chip->dev);
700 ++
701 ++ /* Make the chip unavailable. */
702 ++ mutex_lock(&idr_lock);
703 ++ idr_replace(&dev_nums_idr, NULL, chip->dev_num);
704 ++ mutex_unlock(&idr_lock);
705 +
706 + /* Make the driver uncallable. */
707 + down_write(&chip->ops_sem);
708 + chip->ops = NULL;
709 + up_write(&chip->ops_sem);
710 +-
711 +- device_del(&chip->dev);
712 + }
713 +
714 + static int tpm1_chip_register(struct tpm_chip *chip)
715 +@@ -319,11 +336,6 @@ int tpm_chip_register(struct tpm_chip *chip)
716 + if (rc)
717 + goto out_err;
718 +
719 +- /* Make the chip available. */
720 +- spin_lock(&driver_lock);
721 +- list_add_tail_rcu(&chip->list, &tpm_chip_list);
722 +- spin_unlock(&driver_lock);
723 +-
724 + chip->flags |= TPM_CHIP_FLAG_REGISTERED;
725 +
726 + if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
727 +@@ -360,11 +372,6 @@ void tpm_chip_unregister(struct tpm_chip *chip)
728 + if (!(chip->flags & TPM_CHIP_FLAG_REGISTERED))
729 + return;
730 +
731 +- spin_lock(&driver_lock);
732 +- list_del_rcu(&chip->list);
733 +- spin_unlock(&driver_lock);
734 +- synchronize_rcu();
735 +-
736 + if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
737 + sysfs_remove_link(&chip->dev.parent->kobj, "ppi");
738 +
739 +diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
740 +index 8588f2e4b9af..aaa5fa95dede 100644
741 +--- a/drivers/char/tpm/tpm-interface.c
742 ++++ b/drivers/char/tpm/tpm-interface.c
743 +@@ -1127,6 +1127,7 @@ static int __init tpm_init(void)
744 +
745 + static void __exit tpm_exit(void)
746 + {
747 ++ idr_destroy(&dev_nums_idr);
748 + class_destroy(tpm_class);
749 + unregister_chrdev_region(tpm_devt, TPM_NUM_DEVICES);
750 + }
751 +diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
752 +index 6a4056a3f7ee..06ac6e9657d2 100644
753 +--- a/drivers/char/tpm/tpm-sysfs.c
754 ++++ b/drivers/char/tpm/tpm-sysfs.c
755 +@@ -38,6 +38,8 @@ static ssize_t pubek_show(struct device *dev, struct device_attribute *attr,
756 +
757 + struct tpm_chip *chip = dev_get_drvdata(dev);
758 +
759 ++ memset(&tpm_cmd, 0, sizeof(tpm_cmd));
760 ++
761 + tpm_cmd.header.in = tpm_readpubek_header;
762 + err = tpm_transmit_cmd(chip, &tpm_cmd, READ_PUBEK_RESULT_SIZE, 0,
763 + "attempting to read the PUBEK");
764 +diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
765 +index e21e2c599e66..772d99b3a8e4 100644
766 +--- a/drivers/char/tpm/tpm.h
767 ++++ b/drivers/char/tpm/tpm.h
768 +@@ -34,7 +34,7 @@
769 + enum tpm_const {
770 + TPM_MINOR = 224, /* officially assigned */
771 + TPM_BUFSIZE = 4096,
772 +- TPM_NUM_DEVICES = 256,
773 ++ TPM_NUM_DEVICES = 65536,
774 + TPM_RETRY = 50, /* 5 seconds */
775 + };
776 +
777 +@@ -200,8 +200,6 @@ struct tpm_chip {
778 + acpi_handle acpi_dev_handle;
779 + char ppi_version[TPM_PPI_VERSION_LEN + 1];
780 + #endif /* CONFIG_ACPI */
781 +-
782 +- struct list_head list;
783 + };
784 +
785 + #define to_tpm_chip(d) container_of(d, struct tpm_chip, dev)
786 +@@ -497,6 +495,7 @@ static inline void tpm_buf_append_u32(struct tpm_buf *buf, const u32 value)
787 + extern struct class *tpm_class;
788 + extern dev_t tpm_devt;
789 + extern const struct file_operations tpm_fops;
790 ++extern struct idr dev_nums_idr;
791 +
792 + enum tpm_transmit_flags {
793 + TPM_TRANSMIT_UNLOCKED = BIT(0),
794 +diff --git a/drivers/dma/ioat/hw.h b/drivers/dma/ioat/hw.h
795 +index 690e3b4f8202..b36da3c1073f 100644
796 +--- a/drivers/dma/ioat/hw.h
797 ++++ b/drivers/dma/ioat/hw.h
798 +@@ -64,6 +64,8 @@
799 + #define PCI_DEVICE_ID_INTEL_IOAT_BDX8 0x6f2e
800 + #define PCI_DEVICE_ID_INTEL_IOAT_BDX9 0x6f2f
801 +
802 ++#define PCI_DEVICE_ID_INTEL_IOAT_SKX 0x2021
803 ++
804 + #define IOAT_VER_1_2 0x12 /* Version 1.2 */
805 + #define IOAT_VER_2_0 0x20 /* Version 2.0 */
806 + #define IOAT_VER_3_0 0x30 /* Version 3.0 */
807 +diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
808 +index 4ef0c5e07912..abb75ebd65ea 100644
809 +--- a/drivers/dma/ioat/init.c
810 ++++ b/drivers/dma/ioat/init.c
811 +@@ -105,6 +105,8 @@ static struct pci_device_id ioat_pci_tbl[] = {
812 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BDX8) },
813 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BDX9) },
814 +
815 ++ { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SKX) },
816 ++
817 + /* I/OAT v3.3 platforms */
818 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BWD0) },
819 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_BWD1) },
820 +@@ -250,10 +252,15 @@ static bool is_bdx_ioat(struct pci_dev *pdev)
821 + }
822 + }
823 +
824 ++static inline bool is_skx_ioat(struct pci_dev *pdev)
825 ++{
826 ++ return (pdev->device == PCI_DEVICE_ID_INTEL_IOAT_SKX) ? true : false;
827 ++}
828 ++
829 + static bool is_xeon_cb32(struct pci_dev *pdev)
830 + {
831 + return is_jf_ioat(pdev) || is_snb_ioat(pdev) || is_ivb_ioat(pdev) ||
832 +- is_hsw_ioat(pdev) || is_bdx_ioat(pdev);
833 ++ is_hsw_ioat(pdev) || is_bdx_ioat(pdev) || is_skx_ioat(pdev);
834 + }
835 +
836 + bool is_bwd_ioat(struct pci_dev *pdev)
837 +@@ -1350,6 +1357,8 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
838 +
839 + device->version = readb(device->reg_base + IOAT_VER_OFFSET);
840 + if (device->version >= IOAT_VER_3_0) {
841 ++ if (is_skx_ioat(pdev))
842 ++ device->version = IOAT_VER_3_2;
843 + err = ioat3_dma_probe(device, ioat_dca_enabled);
844 +
845 + if (device->version >= IOAT_VER_3_3)
846 +diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
847 +index a415edbe61b1..149ec2bd9bc6 100644
848 +--- a/drivers/dma/ti-dma-crossbar.c
849 ++++ b/drivers/dma/ti-dma-crossbar.c
850 +@@ -146,6 +146,7 @@ static int ti_am335x_xbar_probe(struct platform_device *pdev)
851 + match = of_match_node(ti_am335x_master_match, dma_node);
852 + if (!match) {
853 + dev_err(&pdev->dev, "DMA master is not supported\n");
854 ++ of_node_put(dma_node);
855 + return -EINVAL;
856 + }
857 +
858 +@@ -310,6 +311,7 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev)
859 + match = of_match_node(ti_dra7_master_match, dma_node);
860 + if (!match) {
861 + dev_err(&pdev->dev, "DMA master is not supported\n");
862 ++ of_node_put(dma_node);
863 + return -EINVAL;
864 + }
865 +
866 +diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
867 +index a3b54cc76495..b66ffd44ff26 100644
868 +--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
869 ++++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
870 +@@ -204,7 +204,14 @@ int adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
871 + void adreno_flush(struct msm_gpu *gpu)
872 + {
873 + struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
874 +- uint32_t wptr = get_wptr(gpu->rb);
875 ++ uint32_t wptr;
876 ++
877 ++ /*
878 ++ * Mask wptr value that we calculate to fit in the HW range. This is
879 ++ * to account for the possibility that the last command fit exactly into
880 ++ * the ringbuffer and rb->next hasn't wrapped to zero yet
881 ++ */
882 ++ wptr = get_wptr(gpu->rb) & ((gpu->rb->size / 4) - 1);
883 +
884 + /* ensure writes to ringbuffer have hit system memory: */
885 + mb();
886 +diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
887 +index 1847f83b1e33..fed44d4e5b72 100644
888 +--- a/drivers/gpu/drm/msm/msm_gem_submit.c
889 ++++ b/drivers/gpu/drm/msm/msm_gem_submit.c
890 +@@ -90,7 +90,8 @@ static int submit_lookup_objects(struct msm_gem_submit *submit,
891 + pagefault_disable();
892 + }
893 +
894 +- if (submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) {
895 ++ if ((submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) ||
896 ++ !(submit_bo.flags & MSM_SUBMIT_BO_FLAGS)) {
897 + DRM_ERROR("invalid flags: %x\n", submit_bo.flags);
898 + ret = -EINVAL;
899 + goto out_unlock;
900 +diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c b/drivers/gpu/drm/msm/msm_ringbuffer.c
901 +index 1f14b908b221..ae317271cf81 100644
902 +--- a/drivers/gpu/drm/msm/msm_ringbuffer.c
903 ++++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
904 +@@ -23,7 +23,8 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int size)
905 + struct msm_ringbuffer *ring;
906 + int ret;
907 +
908 +- size = ALIGN(size, 4); /* size should be dword aligned */
909 ++ if (WARN_ON(!is_power_of_2(size)))
910 ++ return ERR_PTR(-EINVAL);
911 +
912 + ring = kzalloc(sizeof(*ring), GFP_KERNEL);
913 + if (!ring) {
914 +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
915 +index c794b2c2d21e..6d8f21290aa2 100644
916 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
917 ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
918 +@@ -129,7 +129,7 @@ gf100_bar_init(struct nvkm_bar *base)
919 +
920 + if (bar->bar[0].mem) {
921 + addr = nvkm_memory_addr(bar->bar[0].mem) >> 12;
922 +- nvkm_wr32(device, 0x001714, 0xc0000000 | addr);
923 ++ nvkm_wr32(device, 0x001714, 0x80000000 | addr);
924 + }
925 +
926 + return 0;
927 +diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
928 +index 48cb19949ca3..9255b9c096b6 100644
929 +--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
930 ++++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
931 +@@ -282,26 +282,6 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc)
932 + * Page Flip
933 + */
934 +
935 +-void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc,
936 +- struct drm_file *file)
937 +-{
938 +- struct drm_pending_vblank_event *event;
939 +- struct drm_device *dev = rcrtc->crtc.dev;
940 +- unsigned long flags;
941 +-
942 +- /* Destroy the pending vertical blanking event associated with the
943 +- * pending page flip, if any, and disable vertical blanking interrupts.
944 +- */
945 +- spin_lock_irqsave(&dev->event_lock, flags);
946 +- event = rcrtc->event;
947 +- if (event && event->base.file_priv == file) {
948 +- rcrtc->event = NULL;
949 +- event->base.destroy(&event->base);
950 +- drm_crtc_vblank_put(&rcrtc->crtc);
951 +- }
952 +- spin_unlock_irqrestore(&dev->event_lock, flags);
953 +-}
954 +-
955 + static void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc)
956 + {
957 + struct drm_pending_vblank_event *event;
958 +diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
959 +index 4b95d9d08c49..2bbe3f5aab65 100644
960 +--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
961 ++++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
962 +@@ -67,8 +67,6 @@ enum rcar_du_output {
963 +
964 + int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index);
965 + void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable);
966 +-void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc,
967 +- struct drm_file *file);
968 + void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc);
969 + void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc);
970 +
971 +diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
972 +index 40422f6b645e..bf4674aa6405 100644
973 +--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
974 ++++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
975 +@@ -144,91 +144,6 @@ MODULE_DEVICE_TABLE(of, rcar_du_of_table);
976 + * DRM operations
977 + */
978 +
979 +-static int rcar_du_unload(struct drm_device *dev)
980 +-{
981 +- struct rcar_du_device *rcdu = dev->dev_private;
982 +-
983 +- if (rcdu->fbdev)
984 +- drm_fbdev_cma_fini(rcdu->fbdev);
985 +-
986 +- drm_kms_helper_poll_fini(dev);
987 +- drm_mode_config_cleanup(dev);
988 +- drm_vblank_cleanup(dev);
989 +-
990 +- dev->irq_enabled = 0;
991 +- dev->dev_private = NULL;
992 +-
993 +- return 0;
994 +-}
995 +-
996 +-static int rcar_du_load(struct drm_device *dev, unsigned long flags)
997 +-{
998 +- struct platform_device *pdev = dev->platformdev;
999 +- struct device_node *np = pdev->dev.of_node;
1000 +- struct rcar_du_device *rcdu;
1001 +- struct resource *mem;
1002 +- int ret;
1003 +-
1004 +- if (np == NULL) {
1005 +- dev_err(dev->dev, "no platform data\n");
1006 +- return -ENODEV;
1007 +- }
1008 +-
1009 +- rcdu = devm_kzalloc(&pdev->dev, sizeof(*rcdu), GFP_KERNEL);
1010 +- if (rcdu == NULL) {
1011 +- dev_err(dev->dev, "failed to allocate private data\n");
1012 +- return -ENOMEM;
1013 +- }
1014 +-
1015 +- init_waitqueue_head(&rcdu->commit.wait);
1016 +-
1017 +- rcdu->dev = &pdev->dev;
1018 +- rcdu->info = of_match_device(rcar_du_of_table, rcdu->dev)->data;
1019 +- rcdu->ddev = dev;
1020 +- dev->dev_private = rcdu;
1021 +-
1022 +- /* I/O resources */
1023 +- mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1024 +- rcdu->mmio = devm_ioremap_resource(&pdev->dev, mem);
1025 +- if (IS_ERR(rcdu->mmio))
1026 +- return PTR_ERR(rcdu->mmio);
1027 +-
1028 +- /* Initialize vertical blanking interrupts handling. Start with vblank
1029 +- * disabled for all CRTCs.
1030 +- */
1031 +- ret = drm_vblank_init(dev, (1 << rcdu->info->num_crtcs) - 1);
1032 +- if (ret < 0) {
1033 +- dev_err(&pdev->dev, "failed to initialize vblank\n");
1034 +- goto done;
1035 +- }
1036 +-
1037 +- /* DRM/KMS objects */
1038 +- ret = rcar_du_modeset_init(rcdu);
1039 +- if (ret < 0) {
1040 +- dev_err(&pdev->dev, "failed to initialize DRM/KMS (%d)\n", ret);
1041 +- goto done;
1042 +- }
1043 +-
1044 +- dev->irq_enabled = 1;
1045 +-
1046 +- platform_set_drvdata(pdev, rcdu);
1047 +-
1048 +-done:
1049 +- if (ret)
1050 +- rcar_du_unload(dev);
1051 +-
1052 +- return ret;
1053 +-}
1054 +-
1055 +-static void rcar_du_preclose(struct drm_device *dev, struct drm_file *file)
1056 +-{
1057 +- struct rcar_du_device *rcdu = dev->dev_private;
1058 +- unsigned int i;
1059 +-
1060 +- for (i = 0; i < rcdu->num_crtcs; ++i)
1061 +- rcar_du_crtc_cancel_page_flip(&rcdu->crtcs[i], file);
1062 +-}
1063 +-
1064 + static void rcar_du_lastclose(struct drm_device *dev)
1065 + {
1066 + struct rcar_du_device *rcdu = dev->dev_private;
1067 +@@ -269,11 +184,7 @@ static const struct file_operations rcar_du_fops = {
1068 + static struct drm_driver rcar_du_driver = {
1069 + .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME
1070 + | DRIVER_ATOMIC,
1071 +- .load = rcar_du_load,
1072 +- .unload = rcar_du_unload,
1073 +- .preclose = rcar_du_preclose,
1074 + .lastclose = rcar_du_lastclose,
1075 +- .set_busid = drm_platform_set_busid,
1076 + .get_vblank_counter = drm_vblank_no_hw_counter,
1077 + .enable_vblank = rcar_du_enable_vblank,
1078 + .disable_vblank = rcar_du_disable_vblank,
1079 +@@ -333,18 +244,104 @@ static const struct dev_pm_ops rcar_du_pm_ops = {
1080 + * Platform driver
1081 + */
1082 +
1083 +-static int rcar_du_probe(struct platform_device *pdev)
1084 ++static int rcar_du_remove(struct platform_device *pdev)
1085 + {
1086 +- return drm_platform_init(&rcar_du_driver, pdev);
1087 ++ struct rcar_du_device *rcdu = platform_get_drvdata(pdev);
1088 ++ struct drm_device *ddev = rcdu->ddev;
1089 ++
1090 ++ mutex_lock(&ddev->mode_config.mutex);
1091 ++ drm_connector_unplug_all(ddev);
1092 ++ mutex_unlock(&ddev->mode_config.mutex);
1093 ++
1094 ++ drm_dev_unregister(ddev);
1095 ++
1096 ++ if (rcdu->fbdev)
1097 ++ drm_fbdev_cma_fini(rcdu->fbdev);
1098 ++
1099 ++ drm_kms_helper_poll_fini(ddev);
1100 ++ drm_mode_config_cleanup(ddev);
1101 ++
1102 ++ drm_dev_unref(ddev);
1103 ++
1104 ++ return 0;
1105 + }
1106 +
1107 +-static int rcar_du_remove(struct platform_device *pdev)
1108 ++static int rcar_du_probe(struct platform_device *pdev)
1109 + {
1110 +- struct rcar_du_device *rcdu = platform_get_drvdata(pdev);
1111 ++ struct device_node *np = pdev->dev.of_node;
1112 ++ struct rcar_du_device *rcdu;
1113 ++ struct drm_connector *connector;
1114 ++ struct drm_device *ddev;
1115 ++ struct resource *mem;
1116 ++ int ret;
1117 ++
1118 ++ if (np == NULL) {
1119 ++ dev_err(&pdev->dev, "no device tree node\n");
1120 ++ return -ENODEV;
1121 ++ }
1122 ++
1123 ++ /* Allocate and initialize the DRM and R-Car device structures. */
1124 ++ rcdu = devm_kzalloc(&pdev->dev, sizeof(*rcdu), GFP_KERNEL);
1125 ++ if (rcdu == NULL)
1126 ++ return -ENOMEM;
1127 ++
1128 ++ init_waitqueue_head(&rcdu->commit.wait);
1129 ++
1130 ++ rcdu->dev = &pdev->dev;
1131 ++ rcdu->info = of_match_device(rcar_du_of_table, rcdu->dev)->data;
1132 ++
1133 ++ platform_set_drvdata(pdev, rcdu);
1134 +
1135 +- drm_put_dev(rcdu->ddev);
1136 ++ /* I/O resources */
1137 ++ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1138 ++ rcdu->mmio = devm_ioremap_resource(&pdev->dev, mem);
1139 ++ if (IS_ERR(rcdu->mmio))
1140 ++ ret = PTR_ERR(rcdu->mmio);
1141 ++
1142 ++ /* DRM/KMS objects */
1143 ++ ddev = drm_dev_alloc(&rcar_du_driver, &pdev->dev);
1144 ++ if (!ddev)
1145 ++ return -ENOMEM;
1146 ++
1147 ++ drm_dev_set_unique(ddev, dev_name(&pdev->dev));
1148 ++
1149 ++ rcdu->ddev = ddev;
1150 ++ ddev->dev_private = rcdu;
1151 ++
1152 ++ ret = rcar_du_modeset_init(rcdu);
1153 ++ if (ret < 0) {
1154 ++ dev_err(&pdev->dev, "failed to initialize DRM/KMS (%d)\n", ret);
1155 ++ goto error;
1156 ++ }
1157 ++
1158 ++ ddev->irq_enabled = 1;
1159 ++
1160 ++ /* Register the DRM device with the core and the connectors with
1161 ++ * sysfs.
1162 ++ */
1163 ++ ret = drm_dev_register(ddev, 0);
1164 ++ if (ret)
1165 ++ goto error;
1166 ++
1167 ++ mutex_lock(&ddev->mode_config.mutex);
1168 ++ drm_for_each_connector(connector, ddev) {
1169 ++ ret = drm_connector_register(connector);
1170 ++ if (ret < 0)
1171 ++ break;
1172 ++ }
1173 ++ mutex_unlock(&ddev->mode_config.mutex);
1174 ++
1175 ++ if (ret < 0)
1176 ++ goto error;
1177 ++
1178 ++ DRM_INFO("Device %s probed\n", dev_name(&pdev->dev));
1179 +
1180 + return 0;
1181 ++
1182 ++error:
1183 ++ rcar_du_remove(pdev);
1184 ++
1185 ++ return ret;
1186 + }
1187 +
1188 + static struct platform_driver rcar_du_platform_driver = {
1189 +diff --git a/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c b/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
1190 +index 96f2eb43713c..6038be93c58d 100644
1191 +--- a/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
1192 ++++ b/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
1193 +@@ -55,12 +55,6 @@ static const struct drm_connector_helper_funcs connector_helper_funcs = {
1194 + .best_encoder = rcar_du_connector_best_encoder,
1195 + };
1196 +
1197 +-static void rcar_du_hdmi_connector_destroy(struct drm_connector *connector)
1198 +-{
1199 +- drm_connector_unregister(connector);
1200 +- drm_connector_cleanup(connector);
1201 +-}
1202 +-
1203 + static enum drm_connector_status
1204 + rcar_du_hdmi_connector_detect(struct drm_connector *connector, bool force)
1205 + {
1206 +@@ -79,7 +73,7 @@ static const struct drm_connector_funcs connector_funcs = {
1207 + .reset = drm_atomic_helper_connector_reset,
1208 + .detect = rcar_du_hdmi_connector_detect,
1209 + .fill_modes = drm_helper_probe_single_connector_modes,
1210 +- .destroy = rcar_du_hdmi_connector_destroy,
1211 ++ .destroy = drm_connector_cleanup,
1212 + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
1213 + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
1214 + };
1215 +@@ -108,9 +102,6 @@ int rcar_du_hdmi_connector_init(struct rcar_du_device *rcdu,
1216 + return ret;
1217 +
1218 + drm_connector_helper_add(connector, &connector_helper_funcs);
1219 +- ret = drm_connector_register(connector);
1220 +- if (ret < 0)
1221 +- return ret;
1222 +
1223 + connector->dpms = DRM_MODE_DPMS_OFF;
1224 + drm_object_property_set_value(&connector->base,
1225 +diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
1226 +index ca12e8ca5552..46429c4be8e5 100644
1227 +--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
1228 ++++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
1229 +@@ -761,6 +761,13 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
1230 + if (ret < 0)
1231 + return ret;
1232 +
1233 ++ /* Initialize vertical blanking interrupts handling. Start with vblank
1234 ++ * disabled for all CRTCs.
1235 ++ */
1236 ++ ret = drm_vblank_init(dev, (1 << rcdu->info->num_crtcs) - 1);
1237 ++ if (ret < 0)
1238 ++ return ret;
1239 ++
1240 + /* Initialize the groups. */
1241 + num_groups = DIV_ROUND_UP(rcdu->num_crtcs, 2);
1242 +
1243 +diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
1244 +index 0c43032fc693..e905f5da7aaa 100644
1245 +--- a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
1246 ++++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
1247 +@@ -62,12 +62,6 @@ static const struct drm_connector_helper_funcs connector_helper_funcs = {
1248 + .best_encoder = rcar_du_connector_best_encoder,
1249 + };
1250 +
1251 +-static void rcar_du_lvds_connector_destroy(struct drm_connector *connector)
1252 +-{
1253 +- drm_connector_unregister(connector);
1254 +- drm_connector_cleanup(connector);
1255 +-}
1256 +-
1257 + static enum drm_connector_status
1258 + rcar_du_lvds_connector_detect(struct drm_connector *connector, bool force)
1259 + {
1260 +@@ -79,7 +73,7 @@ static const struct drm_connector_funcs connector_funcs = {
1261 + .reset = drm_atomic_helper_connector_reset,
1262 + .detect = rcar_du_lvds_connector_detect,
1263 + .fill_modes = drm_helper_probe_single_connector_modes,
1264 +- .destroy = rcar_du_lvds_connector_destroy,
1265 ++ .destroy = drm_connector_cleanup,
1266 + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
1267 + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
1268 + };
1269 +@@ -117,9 +111,6 @@ int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu,
1270 + return ret;
1271 +
1272 + drm_connector_helper_add(connector, &connector_helper_funcs);
1273 +- ret = drm_connector_register(connector);
1274 +- if (ret < 0)
1275 +- return ret;
1276 +
1277 + connector->dpms = DRM_MODE_DPMS_OFF;
1278 + drm_object_property_set_value(&connector->base,
1279 +diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
1280 +index e0a5d8f93963..9d7e5c99caf6 100644
1281 +--- a/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
1282 ++++ b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
1283 +@@ -31,12 +31,6 @@ static const struct drm_connector_helper_funcs connector_helper_funcs = {
1284 + .best_encoder = rcar_du_connector_best_encoder,
1285 + };
1286 +
1287 +-static void rcar_du_vga_connector_destroy(struct drm_connector *connector)
1288 +-{
1289 +- drm_connector_unregister(connector);
1290 +- drm_connector_cleanup(connector);
1291 +-}
1292 +-
1293 + static enum drm_connector_status
1294 + rcar_du_vga_connector_detect(struct drm_connector *connector, bool force)
1295 + {
1296 +@@ -48,7 +42,7 @@ static const struct drm_connector_funcs connector_funcs = {
1297 + .reset = drm_atomic_helper_connector_reset,
1298 + .detect = rcar_du_vga_connector_detect,
1299 + .fill_modes = drm_helper_probe_single_connector_modes,
1300 +- .destroy = rcar_du_vga_connector_destroy,
1301 ++ .destroy = drm_connector_cleanup,
1302 + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
1303 + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
1304 + };
1305 +@@ -76,9 +70,6 @@ int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
1306 + return ret;
1307 +
1308 + drm_connector_helper_add(connector, &connector_helper_funcs);
1309 +- ret = drm_connector_register(connector);
1310 +- if (ret < 0)
1311 +- return ret;
1312 +
1313 + connector->dpms = DRM_MODE_DPMS_OFF;
1314 + drm_object_property_set_value(&connector->base,
1315 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
1316 +index ecf15cf0c3fd..04fd0f2b6af0 100644
1317 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
1318 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
1319 +@@ -471,7 +471,7 @@ static int vmw_cmd_invalid(struct vmw_private *dev_priv,
1320 + struct vmw_sw_context *sw_context,
1321 + SVGA3dCmdHeader *header)
1322 + {
1323 +- return capable(CAP_SYS_ADMIN) ? : -EINVAL;
1324 ++ return -EINVAL;
1325 + }
1326 +
1327 + static int vmw_cmd_ok(struct vmw_private *dev_priv,
1328 +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
1329 +index 936960202cf4..11a051bd8a8b 100644
1330 +--- a/drivers/hid/hid-core.c
1331 ++++ b/drivers/hid/hid-core.c
1332 +@@ -2427,6 +2427,7 @@ static const struct hid_device_id hid_ignore_list[] = {
1333 + { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) },
1334 + { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
1335 + { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
1336 ++ { HID_USB_DEVICE(USB_VENDOR_ID_PETZL, USB_DEVICE_ID_PETZL_HEADLAMP) },
1337 + { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) },
1338 + { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
1339 + #if defined(CONFIG_MOUSE_SYNAPTICS_USB) || defined(CONFIG_MOUSE_SYNAPTICS_USB_MODULE)
1340 +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
1341 +index c7f8b70d15ee..37cbc2ecfc5f 100644
1342 +--- a/drivers/hid/hid-ids.h
1343 ++++ b/drivers/hid/hid-ids.h
1344 +@@ -777,6 +777,9 @@
1345 + #define USB_VENDOR_ID_PETALYNX 0x18b1
1346 + #define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037
1347 +
1348 ++#define USB_VENDOR_ID_PETZL 0x2122
1349 ++#define USB_DEVICE_ID_PETZL_HEADLAMP 0x1234
1350 ++
1351 + #define USB_VENDOR_ID_PHILIPS 0x0471
1352 + #define USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE 0x0617
1353 +
1354 +diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
1355 +index 9eca4b41fa0a..b7a73f1a8beb 100644
1356 +--- a/drivers/infiniband/core/uverbs_cmd.c
1357 ++++ b/drivers/infiniband/core/uverbs_cmd.c
1358 +@@ -2287,8 +2287,9 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
1359 + if (copy_from_user(&cmd, buf, sizeof cmd))
1360 + return -EFAULT;
1361 +
1362 +- if (cmd.port_num < rdma_start_port(ib_dev) ||
1363 +- cmd.port_num > rdma_end_port(ib_dev))
1364 ++ if ((cmd.attr_mask & IB_QP_PORT) &&
1365 ++ (cmd.port_num < rdma_start_port(ib_dev) ||
1366 ++ cmd.port_num > rdma_end_port(ib_dev)))
1367 + return -EINVAL;
1368 +
1369 + INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
1370 +diff --git a/drivers/irqchip/irq-keystone.c b/drivers/irqchip/irq-keystone.c
1371 +index deb89d63a728..e684be1bb7c0 100644
1372 +--- a/drivers/irqchip/irq-keystone.c
1373 ++++ b/drivers/irqchip/irq-keystone.c
1374 +@@ -19,9 +19,9 @@
1375 + #include <linux/bitops.h>
1376 + #include <linux/module.h>
1377 + #include <linux/moduleparam.h>
1378 ++#include <linux/interrupt.h>
1379 + #include <linux/irqdomain.h>
1380 + #include <linux/irqchip.h>
1381 +-#include <linux/irqchip/chained_irq.h>
1382 + #include <linux/of.h>
1383 + #include <linux/of_platform.h>
1384 + #include <linux/mfd/syscon.h>
1385 +@@ -39,6 +39,7 @@ struct keystone_irq_device {
1386 + struct irq_domain *irqd;
1387 + struct regmap *devctrl_regs;
1388 + u32 devctrl_offset;
1389 ++ raw_spinlock_t wa_lock;
1390 + };
1391 +
1392 + static inline u32 keystone_irq_readl(struct keystone_irq_device *kirq)
1393 +@@ -83,17 +84,15 @@ static void keystone_irq_ack(struct irq_data *d)
1394 + /* nothing to do here */
1395 + }
1396 +
1397 +-static void keystone_irq_handler(struct irq_desc *desc)
1398 ++static irqreturn_t keystone_irq_handler(int irq, void *keystone_irq)
1399 + {
1400 +- unsigned int irq = irq_desc_get_irq(desc);
1401 +- struct keystone_irq_device *kirq = irq_desc_get_handler_data(desc);
1402 ++ struct keystone_irq_device *kirq = keystone_irq;
1403 ++ unsigned long wa_lock_flags;
1404 + unsigned long pending;
1405 + int src, virq;
1406 +
1407 + dev_dbg(kirq->dev, "start irq %d\n", irq);
1408 +
1409 +- chained_irq_enter(irq_desc_get_chip(desc), desc);
1410 +-
1411 + pending = keystone_irq_readl(kirq);
1412 + keystone_irq_writel(kirq, pending);
1413 +
1414 +@@ -111,13 +110,15 @@ static void keystone_irq_handler(struct irq_desc *desc)
1415 + if (!virq)
1416 + dev_warn(kirq->dev, "sporious irq detected hwirq %d, virq %d\n",
1417 + src, virq);
1418 ++ raw_spin_lock_irqsave(&kirq->wa_lock, wa_lock_flags);
1419 + generic_handle_irq(virq);
1420 ++ raw_spin_unlock_irqrestore(&kirq->wa_lock,
1421 ++ wa_lock_flags);
1422 + }
1423 + }
1424 +
1425 +- chained_irq_exit(irq_desc_get_chip(desc), desc);
1426 +-
1427 + dev_dbg(kirq->dev, "end irq %d\n", irq);
1428 ++ return IRQ_HANDLED;
1429 + }
1430 +
1431 + static int keystone_irq_map(struct irq_domain *h, unsigned int virq,
1432 +@@ -182,9 +183,16 @@ static int keystone_irq_probe(struct platform_device *pdev)
1433 + return -ENODEV;
1434 + }
1435 +
1436 ++ raw_spin_lock_init(&kirq->wa_lock);
1437 ++
1438 + platform_set_drvdata(pdev, kirq);
1439 +
1440 +- irq_set_chained_handler_and_data(kirq->irq, keystone_irq_handler, kirq);
1441 ++ ret = request_irq(kirq->irq, keystone_irq_handler,
1442 ++ 0, dev_name(dev), kirq);
1443 ++ if (ret) {
1444 ++ irq_domain_remove(kirq->irqd);
1445 ++ return ret;
1446 ++ }
1447 +
1448 + /* clear all source bits */
1449 + keystone_irq_writel(kirq, ~0x0);
1450 +@@ -199,6 +207,8 @@ static int keystone_irq_remove(struct platform_device *pdev)
1451 + struct keystone_irq_device *kirq = platform_get_drvdata(pdev);
1452 + int hwirq;
1453 +
1454 ++ free_irq(kirq->irq, kirq);
1455 ++
1456 + for (hwirq = 0; hwirq < KEYSTONE_N_IRQ; hwirq++)
1457 + irq_dispose_mapping(irq_find_mapping(kirq->irqd, hwirq));
1458 +
1459 +diff --git a/drivers/irqchip/irq-mxs.c b/drivers/irqchip/irq-mxs.c
1460 +index 17304705f2cf..05fa9f7af53c 100644
1461 +--- a/drivers/irqchip/irq-mxs.c
1462 ++++ b/drivers/irqchip/irq-mxs.c
1463 +@@ -131,12 +131,16 @@ static struct irq_chip mxs_icoll_chip = {
1464 + .irq_ack = icoll_ack_irq,
1465 + .irq_mask = icoll_mask_irq,
1466 + .irq_unmask = icoll_unmask_irq,
1467 ++ .flags = IRQCHIP_MASK_ON_SUSPEND |
1468 ++ IRQCHIP_SKIP_SET_WAKE,
1469 + };
1470 +
1471 + static struct irq_chip asm9260_icoll_chip = {
1472 + .irq_ack = icoll_ack_irq,
1473 + .irq_mask = asm9260_mask_irq,
1474 + .irq_unmask = asm9260_unmask_irq,
1475 ++ .flags = IRQCHIP_MASK_ON_SUSPEND |
1476 ++ IRQCHIP_SKIP_SET_WAKE,
1477 + };
1478 +
1479 + asmlinkage void __exception_irq_entry icoll_handle_irq(struct pt_regs *regs)
1480 +diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
1481 +index 9b856e1890d1..e4c43a17b333 100644
1482 +--- a/drivers/isdn/i4l/isdn_common.c
1483 ++++ b/drivers/isdn/i4l/isdn_common.c
1484 +@@ -1379,6 +1379,7 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
1485 + if (arg) {
1486 + if (copy_from_user(bname, argp, sizeof(bname) - 1))
1487 + return -EFAULT;
1488 ++ bname[sizeof(bname)-1] = 0;
1489 + } else
1490 + return -EINVAL;
1491 + ret = mutex_lock_interruptible(&dev->mtx);
1492 +diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
1493 +index aa5dd5668528..dbad5c431bcb 100644
1494 +--- a/drivers/isdn/i4l/isdn_net.c
1495 ++++ b/drivers/isdn/i4l/isdn_net.c
1496 +@@ -2611,10 +2611,9 @@ isdn_net_newslave(char *parm)
1497 + char newname[10];
1498 +
1499 + if (p) {
1500 +- /* Slave-Name MUST not be empty */
1501 +- if (!strlen(p + 1))
1502 ++ /* Slave-Name MUST not be empty or overflow 'newname' */
1503 ++ if (strscpy(newname, p + 1, sizeof(newname)) <= 0)
1504 + return NULL;
1505 +- strcpy(newname, p + 1);
1506 + *p = 0;
1507 + /* Master must already exist */
1508 + if (!(n = isdn_net_findif(parm)))
1509 +diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
1510 +index 9c1e8adaf4fc..bf3fbd00a091 100644
1511 +--- a/drivers/isdn/i4l/isdn_ppp.c
1512 ++++ b/drivers/isdn/i4l/isdn_ppp.c
1513 +@@ -2364,7 +2364,7 @@ static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_s
1514 + id);
1515 + return NULL;
1516 + } else {
1517 +- rs = kzalloc(sizeof(struct ippp_ccp_reset_state), GFP_KERNEL);
1518 ++ rs = kzalloc(sizeof(struct ippp_ccp_reset_state), GFP_ATOMIC);
1519 + if (!rs)
1520 + return NULL;
1521 + rs->state = CCPResetIdle;
1522 +diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
1523 +index 6a4811f85705..9cf826df89b1 100644
1524 +--- a/drivers/mailbox/mailbox.c
1525 ++++ b/drivers/mailbox/mailbox.c
1526 +@@ -104,11 +104,14 @@ static void tx_tick(struct mbox_chan *chan, int r)
1527 + /* Submit next message */
1528 + msg_submit(chan);
1529 +
1530 ++ if (!mssg)
1531 ++ return;
1532 ++
1533 + /* Notify the client */
1534 +- if (mssg && chan->cl->tx_done)
1535 ++ if (chan->cl->tx_done)
1536 + chan->cl->tx_done(chan->cl, mssg, r);
1537 +
1538 +- if (chan->cl->tx_block)
1539 ++ if (r != -ETIME && chan->cl->tx_block)
1540 + complete(&chan->tx_complete);
1541 + }
1542 +
1543 +@@ -261,7 +264,7 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)
1544 +
1545 + msg_submit(chan);
1546 +
1547 +- if (chan->cl->tx_block && chan->active_req) {
1548 ++ if (chan->cl->tx_block) {
1549 + unsigned long wait;
1550 + int ret;
1551 +
1552 +@@ -272,8 +275,8 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)
1553 +
1554 + ret = wait_for_completion_timeout(&chan->tx_complete, wait);
1555 + if (ret == 0) {
1556 +- t = -EIO;
1557 +- tx_tick(chan, -EIO);
1558 ++ t = -ETIME;
1559 ++ tx_tick(chan, t);
1560 + }
1561 + }
1562 +
1563 +diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
1564 +index fc182c4f2619..8f60520c8392 100644
1565 +--- a/drivers/md/raid5.c
1566 ++++ b/drivers/md/raid5.c
1567 +@@ -5821,6 +5821,8 @@ static void raid5_do_work(struct work_struct *work)
1568 + pr_debug("%d stripes handled\n", handled);
1569 +
1570 + spin_unlock_irq(&conf->device_lock);
1571 ++
1572 ++ async_tx_issue_pending_all();
1573 + blk_finish_plug(&plug);
1574 +
1575 + pr_debug("--- raid5worker inactive\n");
1576 +diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
1577 +index 8001cde1db1e..503135a4f47a 100644
1578 +--- a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
1579 ++++ b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c
1580 +@@ -211,7 +211,7 @@ static int s5c73m3_3a_lock(struct s5c73m3 *state, struct v4l2_ctrl *ctrl)
1581 + }
1582 +
1583 + if ((ctrl->val ^ ctrl->cur.val) & V4L2_LOCK_FOCUS)
1584 +- ret = s5c73m3_af_run(state, ~af_lock);
1585 ++ ret = s5c73m3_af_run(state, !af_lock);
1586 +
1587 + return ret;
1588 + }
1589 +diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c
1590 +index 2a9dd460a95f..e1f9e7cebf8f 100644
1591 +--- a/drivers/net/ethernet/mellanox/mlx4/icm.c
1592 ++++ b/drivers/net/ethernet/mellanox/mlx4/icm.c
1593 +@@ -118,8 +118,13 @@ static int mlx4_alloc_icm_coherent(struct device *dev, struct scatterlist *mem,
1594 + if (!buf)
1595 + return -ENOMEM;
1596 +
1597 ++ if (offset_in_page(buf)) {
1598 ++ dma_free_coherent(dev, PAGE_SIZE << order,
1599 ++ buf, sg_dma_address(mem));
1600 ++ return -ENOMEM;
1601 ++ }
1602 ++
1603 + sg_set_buf(mem, buf, PAGE_SIZE << order);
1604 +- BUG_ON(mem->offset);
1605 + sg_dma_len(mem) = PAGE_SIZE << order;
1606 + return 0;
1607 + }
1608 +diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
1609 +index 79ef799f88ab..c5ea1018cb47 100644
1610 +--- a/drivers/net/ethernet/realtek/r8169.c
1611 ++++ b/drivers/net/ethernet/realtek/r8169.c
1612 +@@ -326,6 +326,7 @@ enum cfg_version {
1613 + static const struct pci_device_id rtl8169_pci_tbl[] = {
1614 + { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 },
1615 + { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 },
1616 ++ { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8161), 0, 0, RTL_CFG_1 },
1617 + { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 },
1618 + { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_1 },
1619 + { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 },
1620 +diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
1621 +index 480f3dae0780..4296066a7ad3 100644
1622 +--- a/drivers/net/ethernet/renesas/sh_eth.c
1623 ++++ b/drivers/net/ethernet/renesas/sh_eth.c
1624 +@@ -750,6 +750,7 @@ static struct sh_eth_cpu_data sh7734_data = {
1625 + .tsu = 1,
1626 + .hw_crc = 1,
1627 + .select_mii = 1,
1628 ++ .shift_rd0 = 1,
1629 + };
1630 +
1631 + /* SH7763 */
1632 +diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
1633 +index 0bfbabad4431..1d1e5f7723ab 100644
1634 +--- a/drivers/net/phy/phy_device.c
1635 ++++ b/drivers/net/phy/phy_device.c
1636 +@@ -1442,7 +1442,7 @@ static struct phy_driver genphy_driver[] = {
1637 + .phy_id = 0xffffffff,
1638 + .phy_id_mask = 0xffffffff,
1639 + .name = "Generic PHY",
1640 +- .soft_reset = genphy_soft_reset,
1641 ++ .soft_reset = genphy_no_soft_reset,
1642 + .config_init = genphy_config_init,
1643 + .features = PHY_GBIT_FEATURES | SUPPORTED_MII |
1644 + SUPPORTED_AUI | SUPPORTED_FIBRE |
1645 +diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
1646 +index f64b25c221e8..cd93220c9b45 100644
1647 +--- a/drivers/net/usb/kaweth.c
1648 ++++ b/drivers/net/usb/kaweth.c
1649 +@@ -1009,6 +1009,7 @@ static int kaweth_probe(
1650 + struct net_device *netdev;
1651 + const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
1652 + int result = 0;
1653 ++ int rv = -EIO;
1654 +
1655 + dev_dbg(dev,
1656 + "Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n",
1657 +@@ -1029,6 +1030,7 @@ static int kaweth_probe(
1658 + kaweth = netdev_priv(netdev);
1659 + kaweth->dev = udev;
1660 + kaweth->net = netdev;
1661 ++ kaweth->intf = intf;
1662 +
1663 + spin_lock_init(&kaweth->device_lock);
1664 + init_waitqueue_head(&kaweth->term_wait);
1665 +@@ -1048,6 +1050,10 @@ static int kaweth_probe(
1666 + /* Download the firmware */
1667 + dev_info(dev, "Downloading firmware...\n");
1668 + kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL);
1669 ++ if (!kaweth->firmware_buf) {
1670 ++ rv = -ENOMEM;
1671 ++ goto err_free_netdev;
1672 ++ }
1673 + if ((result = kaweth_download_firmware(kaweth,
1674 + "kaweth/new_code.bin",
1675 + 100,
1676 +@@ -1139,8 +1145,6 @@ err_fw:
1677 +
1678 + dev_dbg(dev, "Initializing net device.\n");
1679 +
1680 +- kaweth->intf = intf;
1681 +-
1682 + kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
1683 + if (!kaweth->tx_urb)
1684 + goto err_free_netdev;
1685 +@@ -1204,7 +1208,7 @@ err_only_tx:
1686 + err_free_netdev:
1687 + free_netdev(netdev);
1688 +
1689 +- return -EIO;
1690 ++ return rv;
1691 + }
1692 +
1693 + /****************************************************************
1694 +diff --git a/drivers/net/wireless/ath/ath10k/wmi-ops.h b/drivers/net/wireless/ath/ath10k/wmi-ops.h
1695 +index 8f4f6a892581..cfed5808bc4e 100644
1696 +--- a/drivers/net/wireless/ath/ath10k/wmi-ops.h
1697 ++++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h
1698 +@@ -639,6 +639,9 @@ ath10k_wmi_vdev_spectral_conf(struct ath10k *ar,
1699 + struct sk_buff *skb;
1700 + u32 cmd_id;
1701 +
1702 ++ if (!ar->wmi.ops->gen_vdev_spectral_conf)
1703 ++ return -EOPNOTSUPP;
1704 ++
1705 + skb = ar->wmi.ops->gen_vdev_spectral_conf(ar, arg);
1706 + if (IS_ERR(skb))
1707 + return PTR_ERR(skb);
1708 +@@ -654,6 +657,9 @@ ath10k_wmi_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id, u32 trigger,
1709 + struct sk_buff *skb;
1710 + u32 cmd_id;
1711 +
1712 ++ if (!ar->wmi.ops->gen_vdev_spectral_enable)
1713 ++ return -EOPNOTSUPP;
1714 ++
1715 + skb = ar->wmi.ops->gen_vdev_spectral_enable(ar, vdev_id, trigger,
1716 + enable);
1717 + if (IS_ERR(skb))
1718 +diff --git a/drivers/net/wireless/ath/wil6210/main.c b/drivers/net/wireless/ath/wil6210/main.c
1719 +index bb69a5949aea..85bca557a339 100644
1720 +--- a/drivers/net/wireless/ath/wil6210/main.c
1721 ++++ b/drivers/net/wireless/ath/wil6210/main.c
1722 +@@ -330,18 +330,19 @@ static void wil_fw_error_worker(struct work_struct *work)
1723 +
1724 + wil->last_fw_recovery = jiffies;
1725 +
1726 ++ wil_info(wil, "fw error recovery requested (try %d)...\n",
1727 ++ wil->recovery_count);
1728 ++ if (!no_fw_recovery)
1729 ++ wil->recovery_state = fw_recovery_running;
1730 ++ if (wil_wait_for_recovery(wil) != 0)
1731 ++ return;
1732 ++
1733 + mutex_lock(&wil->mutex);
1734 + switch (wdev->iftype) {
1735 + case NL80211_IFTYPE_STATION:
1736 + case NL80211_IFTYPE_P2P_CLIENT:
1737 + case NL80211_IFTYPE_MONITOR:
1738 +- wil_info(wil, "fw error recovery requested (try %d)...\n",
1739 +- wil->recovery_count);
1740 +- if (!no_fw_recovery)
1741 +- wil->recovery_state = fw_recovery_running;
1742 +- if (0 != wil_wait_for_recovery(wil))
1743 +- break;
1744 +-
1745 ++ /* silent recovery, upper layers will see disconnect */
1746 + __wil_down(wil);
1747 + __wil_up(wil);
1748 + break;
1749 +diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
1750 +index 532db28145c7..a5d7332dfce5 100644
1751 +--- a/drivers/nfc/fdp/i2c.c
1752 ++++ b/drivers/nfc/fdp/i2c.c
1753 +@@ -210,14 +210,14 @@ static irqreturn_t fdp_nci_i2c_irq_thread_fn(int irq, void *phy_id)
1754 + struct sk_buff *skb;
1755 + int r;
1756 +
1757 +- client = phy->i2c_dev;
1758 +- dev_dbg(&client->dev, "%s\n", __func__);
1759 +-
1760 + if (!phy || irq != phy->i2c_dev->irq) {
1761 + WARN_ON_ONCE(1);
1762 + return IRQ_NONE;
1763 + }
1764 +
1765 ++ client = phy->i2c_dev;
1766 ++ dev_dbg(&client->dev, "%s\n", __func__);
1767 ++
1768 + r = fdp_nci_i2c_read(phy, &skb);
1769 +
1770 + if (r == -EREMOTEIO)
1771 +diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
1772 +index efb2c1ceef98..957234272ef7 100644
1773 +--- a/drivers/nvdimm/btt.c
1774 ++++ b/drivers/nvdimm/btt.c
1775 +@@ -1205,10 +1205,13 @@ static int btt_rw_page(struct block_device *bdev, sector_t sector,
1776 + struct page *page, int rw)
1777 + {
1778 + struct btt *btt = bdev->bd_disk->private_data;
1779 ++ int rc;
1780 +
1781 +- btt_do_bvec(btt, NULL, page, PAGE_CACHE_SIZE, 0, rw, sector);
1782 +- page_endio(page, rw & WRITE, 0);
1783 +- return 0;
1784 ++ rc = btt_do_bvec(btt, NULL, page, PAGE_CACHE_SIZE, 0, rw, sector);
1785 ++ if (rc == 0)
1786 ++ page_endio(page, rw & WRITE, 0);
1787 ++
1788 ++ return rc;
1789 + }
1790 +
1791 +
1792 +diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
1793 +index b7971d410b60..74e5360c53f0 100644
1794 +--- a/drivers/nvmem/imx-ocotp.c
1795 ++++ b/drivers/nvmem/imx-ocotp.c
1796 +@@ -88,7 +88,7 @@ static struct nvmem_config imx_ocotp_nvmem_config = {
1797 +
1798 + static const struct of_device_id imx_ocotp_dt_ids[] = {
1799 + { .compatible = "fsl,imx6q-ocotp", (void *)128 },
1800 +- { .compatible = "fsl,imx6sl-ocotp", (void *)32 },
1801 ++ { .compatible = "fsl,imx6sl-ocotp", (void *)64 },
1802 + { .compatible = "fsl,imx6sx-ocotp", (void *)128 },
1803 + { },
1804 + };
1805 +diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
1806 +index ce129e595b55..5c935847599c 100644
1807 +--- a/drivers/scsi/fnic/fnic.h
1808 ++++ b/drivers/scsi/fnic/fnic.h
1809 +@@ -248,6 +248,7 @@ struct fnic {
1810 + struct completion *remove_wait; /* device remove thread blocks */
1811 +
1812 + atomic_t in_flight; /* io counter */
1813 ++ bool internal_reset_inprogress;
1814 + u32 _reserved; /* fill hole */
1815 + unsigned long state_flags; /* protected by host lock */
1816 + enum fnic_state state;
1817 +diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
1818 +index 266b909fe854..82e4bc8c11c5 100644
1819 +--- a/drivers/scsi/fnic/fnic_scsi.c
1820 ++++ b/drivers/scsi/fnic/fnic_scsi.c
1821 +@@ -2533,6 +2533,19 @@ int fnic_host_reset(struct scsi_cmnd *sc)
1822 + unsigned long wait_host_tmo;
1823 + struct Scsi_Host *shost = sc->device->host;
1824 + struct fc_lport *lp = shost_priv(shost);
1825 ++ struct fnic *fnic = lport_priv(lp);
1826 ++ unsigned long flags;
1827 ++
1828 ++ spin_lock_irqsave(&fnic->fnic_lock, flags);
1829 ++ if (fnic->internal_reset_inprogress == 0) {
1830 ++ fnic->internal_reset_inprogress = 1;
1831 ++ } else {
1832 ++ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
1833 ++ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
1834 ++ "host reset in progress skipping another host reset\n");
1835 ++ return SUCCESS;
1836 ++ }
1837 ++ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
1838 +
1839 + /*
1840 + * If fnic_reset is successful, wait for fabric login to complete
1841 +@@ -2553,6 +2566,9 @@ int fnic_host_reset(struct scsi_cmnd *sc)
1842 + }
1843 + }
1844 +
1845 ++ spin_lock_irqsave(&fnic->fnic_lock, flags);
1846 ++ fnic->internal_reset_inprogress = 0;
1847 ++ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
1848 + return ret;
1849 + }
1850 +
1851 +diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
1852 +index 5b2c37f1e908..9b5367294116 100644
1853 +--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
1854 ++++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
1855 +@@ -4981,15 +4981,14 @@ _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, int sleep_flag,
1856 + static int
1857 + _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag)
1858 + {
1859 +- int r, i;
1860 ++ int r, i, index;
1861 + unsigned long flags;
1862 + u32 reply_address;
1863 + u16 smid;
1864 + struct _tr_list *delayed_tr, *delayed_tr_next;
1865 + u8 hide_flag;
1866 + struct adapter_reply_queue *reply_q;
1867 +- long reply_post_free;
1868 +- u32 reply_post_free_sz, index = 0;
1869 ++ Mpi2ReplyDescriptorsUnion_t *reply_post_free_contig;
1870 +
1871 + dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
1872 + __func__));
1873 +@@ -5061,27 +5060,27 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag)
1874 + _base_assign_reply_queues(ioc);
1875 +
1876 + /* initialize Reply Post Free Queue */
1877 +- reply_post_free_sz = ioc->reply_post_queue_depth *
1878 +- sizeof(Mpi2DefaultReplyDescriptor_t);
1879 +- reply_post_free = (long)ioc->reply_post[index].reply_post_free;
1880 ++ index = 0;
1881 ++ reply_post_free_contig = ioc->reply_post[0].reply_post_free;
1882 + list_for_each_entry(reply_q, &ioc->reply_queue_list, list) {
1883 ++ /*
1884 ++ * If RDPQ is enabled, switch to the next allocation.
1885 ++ * Otherwise advance within the contiguous region.
1886 ++ */
1887 ++ if (ioc->rdpq_array_enable) {
1888 ++ reply_q->reply_post_free =
1889 ++ ioc->reply_post[index++].reply_post_free;
1890 ++ } else {
1891 ++ reply_q->reply_post_free = reply_post_free_contig;
1892 ++ reply_post_free_contig += ioc->reply_post_queue_depth;
1893 ++ }
1894 ++
1895 + reply_q->reply_post_host_index = 0;
1896 +- reply_q->reply_post_free = (Mpi2ReplyDescriptorsUnion_t *)
1897 +- reply_post_free;
1898 + for (i = 0; i < ioc->reply_post_queue_depth; i++)
1899 + reply_q->reply_post_free[i].Words =
1900 + cpu_to_le64(ULLONG_MAX);
1901 + if (!_base_is_controller_msix_enabled(ioc))
1902 + goto skip_init_reply_post_free_queue;
1903 +- /*
1904 +- * If RDPQ is enabled, switch to the next allocation.
1905 +- * Otherwise advance within the contiguous region.
1906 +- */
1907 +- if (ioc->rdpq_array_enable)
1908 +- reply_post_free = (long)
1909 +- ioc->reply_post[++index].reply_post_free;
1910 +- else
1911 +- reply_post_free += reply_post_free_sz;
1912 + }
1913 + skip_init_reply_post_free_queue:
1914 +
1915 +diff --git a/drivers/scsi/snic/snic_main.c b/drivers/scsi/snic/snic_main.c
1916 +index 2b3c25371d76..8175f997e82c 100644
1917 +--- a/drivers/scsi/snic/snic_main.c
1918 ++++ b/drivers/scsi/snic/snic_main.c
1919 +@@ -584,6 +584,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1920 + if (!pool) {
1921 + SNIC_HOST_ERR(shost, "dflt sgl pool creation failed\n");
1922 +
1923 ++ ret = -ENOMEM;
1924 + goto err_free_res;
1925 + }
1926 +
1927 +@@ -594,6 +595,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1928 + if (!pool) {
1929 + SNIC_HOST_ERR(shost, "max sgl pool creation failed\n");
1930 +
1931 ++ ret = -ENOMEM;
1932 + goto err_free_dflt_sgl_pool;
1933 + }
1934 +
1935 +@@ -604,6 +606,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1936 + if (!pool) {
1937 + SNIC_HOST_ERR(shost, "snic tmreq info pool creation failed.\n");
1938 +
1939 ++ ret = -ENOMEM;
1940 + goto err_free_max_sgl_pool;
1941 + }
1942 +
1943 +diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
1944 +index 882cd6618cd5..87a0e47eeae6 100644
1945 +--- a/drivers/spi/spi-dw.c
1946 ++++ b/drivers/spi/spi-dw.c
1947 +@@ -107,7 +107,10 @@ static const struct file_operations dw_spi_regs_ops = {
1948 +
1949 + static int dw_spi_debugfs_init(struct dw_spi *dws)
1950 + {
1951 +- dws->debugfs = debugfs_create_dir("dw_spi", NULL);
1952 ++ char name[128];
1953 ++
1954 ++ snprintf(name, 128, "dw_spi-%s", dev_name(&dws->master->dev));
1955 ++ dws->debugfs = debugfs_create_dir(name, NULL);
1956 + if (!dws->debugfs)
1957 + return -ENOMEM;
1958 +
1959 +diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
1960 +index 8fed55342b0f..b831f08e2769 100644
1961 +--- a/drivers/staging/comedi/comedi_fops.c
1962 ++++ b/drivers/staging/comedi/comedi_fops.c
1963 +@@ -2901,9 +2901,6 @@ static int __init comedi_init(void)
1964 +
1965 + comedi_class->dev_groups = comedi_dev_groups;
1966 +
1967 +- /* XXX requires /proc interface */
1968 +- comedi_proc_init();
1969 +-
1970 + /* create devices files for legacy/manual use */
1971 + for (i = 0; i < comedi_num_legacy_minors; i++) {
1972 + struct comedi_device *dev;
1973 +@@ -2921,6 +2918,9 @@ static int __init comedi_init(void)
1974 + mutex_unlock(&dev->mutex);
1975 + }
1976 +
1977 ++ /* XXX requires /proc interface */
1978 ++ comedi_proc_init();
1979 ++
1980 + return 0;
1981 + }
1982 + module_init(comedi_init);
1983 +diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
1984 +index 99285b416308..ee579ba2b59e 100644
1985 +--- a/drivers/usb/gadget/function/f_hid.c
1986 ++++ b/drivers/usb/gadget/function/f_hid.c
1987 +@@ -539,7 +539,7 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
1988 + }
1989 + status = usb_ep_enable(hidg->out_ep);
1990 + if (status < 0) {
1991 +- ERROR(cdev, "Enable IN endpoint FAILED!\n");
1992 ++ ERROR(cdev, "Enable OUT endpoint FAILED!\n");
1993 + goto fail;
1994 + }
1995 + hidg->out_ep->driver_data = hidg;
1996 +diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
1997 +index 830e2fd47642..b31b84f56e8f 100644
1998 +--- a/drivers/vfio/pci/vfio_pci.c
1999 ++++ b/drivers/vfio/pci/vfio_pci.c
2000 +@@ -902,6 +902,10 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
2001 + return ret;
2002 +
2003 + vdev->barmap[index] = pci_iomap(pdev, index, 0);
2004 ++ if (!vdev->barmap[index]) {
2005 ++ pci_release_selected_regions(pdev, 1 << index);
2006 ++ return -ENOMEM;
2007 ++ }
2008 + }
2009 +
2010 + vma->vm_private_data = vdev;
2011 +diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c
2012 +index 210db24d2204..4d39f7959adf 100644
2013 +--- a/drivers/vfio/pci/vfio_pci_rdwr.c
2014 ++++ b/drivers/vfio/pci/vfio_pci_rdwr.c
2015 +@@ -190,7 +190,10 @@ ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf,
2016 + if (!vdev->has_vga)
2017 + return -EINVAL;
2018 +
2019 +- switch (pos) {
2020 ++ if (pos > 0xbfffful)
2021 ++ return -EINVAL;
2022 ++
2023 ++ switch ((u32)pos) {
2024 + case 0xa0000 ... 0xbffff:
2025 + count = min(count, (size_t)(0xc0000 - pos));
2026 + iomem = ioremap_nocache(0xa0000, 0xbffff - 0xa0000 + 1);
2027 +diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c
2028 +index 07675d6f323e..d4530b54479c 100644
2029 +--- a/drivers/video/fbdev/cobalt_lcdfb.c
2030 ++++ b/drivers/video/fbdev/cobalt_lcdfb.c
2031 +@@ -350,6 +350,11 @@ static int cobalt_lcdfb_probe(struct platform_device *dev)
2032 + info->screen_size = resource_size(res);
2033 + info->screen_base = devm_ioremap(&dev->dev, res->start,
2034 + info->screen_size);
2035 ++ if (!info->screen_base) {
2036 ++ framebuffer_release(info);
2037 ++ return -ENOMEM;
2038 ++ }
2039 ++
2040 + info->fbops = &cobalt_lcd_fbops;
2041 + info->fix = cobalt_lcdfb_fix;
2042 + info->fix.smem_start = res->start;
2043 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
2044 +index a61926cb01c0..bebd6517355d 100644
2045 +--- a/fs/btrfs/inode.c
2046 ++++ b/fs/btrfs/inode.c
2047 +@@ -7521,11 +7521,18 @@ static void adjust_dio_outstanding_extents(struct inode *inode,
2048 + * within our reservation, otherwise we need to adjust our inode
2049 + * counter appropriately.
2050 + */
2051 +- if (dio_data->outstanding_extents) {
2052 ++ if (dio_data->outstanding_extents >= num_extents) {
2053 + dio_data->outstanding_extents -= num_extents;
2054 + } else {
2055 ++ /*
2056 ++ * If dio write length has been split due to no large enough
2057 ++ * contiguous space, we need to compensate our inode counter
2058 ++ * appropriately.
2059 ++ */
2060 ++ u64 num_needed = num_extents - dio_data->outstanding_extents;
2061 ++
2062 + spin_lock(&BTRFS_I(inode)->lock);
2063 +- BTRFS_I(inode)->outstanding_extents += num_extents;
2064 ++ BTRFS_I(inode)->outstanding_extents += num_needed;
2065 + spin_unlock(&BTRFS_I(inode)->lock);
2066 + }
2067 + }
2068 +diff --git a/fs/dcache.c b/fs/dcache.c
2069 +index 3000cbb54949..3ed642e0a0c2 100644
2070 +--- a/fs/dcache.c
2071 ++++ b/fs/dcache.c
2072 +@@ -269,6 +269,33 @@ static inline int dname_external(const struct dentry *dentry)
2073 + return dentry->d_name.name != dentry->d_iname;
2074 + }
2075 +
2076 ++void take_dentry_name_snapshot(struct name_snapshot *name, struct dentry *dentry)
2077 ++{
2078 ++ spin_lock(&dentry->d_lock);
2079 ++ if (unlikely(dname_external(dentry))) {
2080 ++ struct external_name *p = external_name(dentry);
2081 ++ atomic_inc(&p->u.count);
2082 ++ spin_unlock(&dentry->d_lock);
2083 ++ name->name = p->name;
2084 ++ } else {
2085 ++ memcpy(name->inline_name, dentry->d_iname, DNAME_INLINE_LEN);
2086 ++ spin_unlock(&dentry->d_lock);
2087 ++ name->name = name->inline_name;
2088 ++ }
2089 ++}
2090 ++EXPORT_SYMBOL(take_dentry_name_snapshot);
2091 ++
2092 ++void release_dentry_name_snapshot(struct name_snapshot *name)
2093 ++{
2094 ++ if (unlikely(name->name != name->inline_name)) {
2095 ++ struct external_name *p;
2096 ++ p = container_of(name->name, struct external_name, name[0]);
2097 ++ if (unlikely(atomic_dec_and_test(&p->u.count)))
2098 ++ kfree_rcu(p, u.head);
2099 ++ }
2100 ++}
2101 ++EXPORT_SYMBOL(release_dentry_name_snapshot);
2102 ++
2103 + static inline void __d_set_inode_and_type(struct dentry *dentry,
2104 + struct inode *inode,
2105 + unsigned type_flags)
2106 +diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
2107 +index 0f5d05bf2131..e49ba072bd64 100644
2108 +--- a/fs/debugfs/inode.c
2109 ++++ b/fs/debugfs/inode.c
2110 +@@ -669,7 +669,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
2111 + {
2112 + int error;
2113 + struct dentry *dentry = NULL, *trap;
2114 +- const char *old_name;
2115 ++ struct name_snapshot old_name;
2116 +
2117 + trap = lock_rename(new_dir, old_dir);
2118 + /* Source or destination directories don't exist? */
2119 +@@ -684,19 +684,19 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
2120 + if (IS_ERR(dentry) || dentry == trap || d_really_is_positive(dentry))
2121 + goto exit;
2122 +
2123 +- old_name = fsnotify_oldname_init(old_dentry->d_name.name);
2124 ++ take_dentry_name_snapshot(&old_name, old_dentry);
2125 +
2126 + error = simple_rename(d_inode(old_dir), old_dentry, d_inode(new_dir),
2127 + dentry);
2128 + if (error) {
2129 +- fsnotify_oldname_free(old_name);
2130 ++ release_dentry_name_snapshot(&old_name);
2131 + goto exit;
2132 + }
2133 + d_move(old_dentry, dentry);
2134 +- fsnotify_move(d_inode(old_dir), d_inode(new_dir), old_name,
2135 ++ fsnotify_move(d_inode(old_dir), d_inode(new_dir), old_name.name,
2136 + d_is_dir(old_dentry),
2137 + NULL, old_dentry);
2138 +- fsnotify_oldname_free(old_name);
2139 ++ release_dentry_name_snapshot(&old_name);
2140 + unlock_rename(new_dir, old_dir);
2141 + dput(dentry);
2142 + return old_dentry;
2143 +diff --git a/fs/namei.c b/fs/namei.c
2144 +index 0b0acba72a71..3f96ae087488 100644
2145 +--- a/fs/namei.c
2146 ++++ b/fs/namei.c
2147 +@@ -4179,11 +4179,11 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2148 + {
2149 + int error;
2150 + bool is_dir = d_is_dir(old_dentry);
2151 +- const unsigned char *old_name;
2152 + struct inode *source = old_dentry->d_inode;
2153 + struct inode *target = new_dentry->d_inode;
2154 + bool new_is_dir = false;
2155 + unsigned max_links = new_dir->i_sb->s_max_links;
2156 ++ struct name_snapshot old_name;
2157 +
2158 + /*
2159 + * Check source == target.
2160 +@@ -4237,7 +4237,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2161 + if (error)
2162 + return error;
2163 +
2164 +- old_name = fsnotify_oldname_init(old_dentry->d_name.name);
2165 ++ take_dentry_name_snapshot(&old_name, old_dentry);
2166 + dget(new_dentry);
2167 + if (!is_dir || (flags & RENAME_EXCHANGE))
2168 + lock_two_nondirectories(source, target);
2169 +@@ -4298,14 +4298,14 @@ out:
2170 + mutex_unlock(&target->i_mutex);
2171 + dput(new_dentry);
2172 + if (!error) {
2173 +- fsnotify_move(old_dir, new_dir, old_name, is_dir,
2174 ++ fsnotify_move(old_dir, new_dir, old_name.name, is_dir,
2175 + !(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry);
2176 + if (flags & RENAME_EXCHANGE) {
2177 + fsnotify_move(new_dir, old_dir, old_dentry->d_name.name,
2178 + new_is_dir, NULL, new_dentry);
2179 + }
2180 + }
2181 +- fsnotify_oldname_free(old_name);
2182 ++ release_dentry_name_snapshot(&old_name);
2183 +
2184 + return error;
2185 + }
2186 +diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
2187 +index db39de2dd4cb..a64adc2fced9 100644
2188 +--- a/fs/notify/fsnotify.c
2189 ++++ b/fs/notify/fsnotify.c
2190 +@@ -104,16 +104,20 @@ int __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask)
2191 + if (unlikely(!fsnotify_inode_watches_children(p_inode)))
2192 + __fsnotify_update_child_dentry_flags(p_inode);
2193 + else if (p_inode->i_fsnotify_mask & mask) {
2194 ++ struct name_snapshot name;
2195 ++
2196 + /* we are notifying a parent so come up with the new mask which
2197 + * specifies these are events which came from a child. */
2198 + mask |= FS_EVENT_ON_CHILD;
2199 +
2200 ++ take_dentry_name_snapshot(&name, dentry);
2201 + if (path)
2202 + ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
2203 +- dentry->d_name.name, 0);
2204 ++ name.name, 0);
2205 + else
2206 + ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
2207 +- dentry->d_name.name, 0);
2208 ++ name.name, 0);
2209 ++ release_dentry_name_snapshot(&name);
2210 + }
2211 +
2212 + dput(parent);
2213 +diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
2214 +index 905caba36529..59d93acc29c7 100644
2215 +--- a/fs/pstore/ram.c
2216 ++++ b/fs/pstore/ram.c
2217 +@@ -413,7 +413,7 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt,
2218 + for (i = 0; i < cxt->max_dump_cnt; i++) {
2219 + cxt->przs[i] = persistent_ram_new(*paddr, cxt->record_size, 0,
2220 + &cxt->ecc_info,
2221 +- cxt->memtype);
2222 ++ cxt->memtype, 0);
2223 + if (IS_ERR(cxt->przs[i])) {
2224 + err = PTR_ERR(cxt->przs[i]);
2225 + dev_err(dev, "failed to request mem region (0x%zx@0x%llx): %d\n",
2226 +@@ -450,7 +450,8 @@ static int ramoops_init_prz(struct device *dev, struct ramoops_context *cxt,
2227 + return -ENOMEM;
2228 + }
2229 +
2230 +- *prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info, cxt->memtype);
2231 ++ *prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info,
2232 ++ cxt->memtype, 0);
2233 + if (IS_ERR(*prz)) {
2234 + int err = PTR_ERR(*prz);
2235 +
2236 +diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
2237 +index 364d2dffe5a6..27300533c2dd 100644
2238 +--- a/fs/pstore/ram_core.c
2239 ++++ b/fs/pstore/ram_core.c
2240 +@@ -47,16 +47,15 @@ static inline size_t buffer_start(struct persistent_ram_zone *prz)
2241 + return atomic_read(&prz->buffer->start);
2242 + }
2243 +
2244 +-static DEFINE_RAW_SPINLOCK(buffer_lock);
2245 +-
2246 + /* increase and wrap the start pointer, returning the old value */
2247 + static size_t buffer_start_add(struct persistent_ram_zone *prz, size_t a)
2248 + {
2249 + int old;
2250 + int new;
2251 +- unsigned long flags;
2252 ++ unsigned long flags = 0;
2253 +
2254 +- raw_spin_lock_irqsave(&buffer_lock, flags);
2255 ++ if (!(prz->flags & PRZ_FLAG_NO_LOCK))
2256 ++ raw_spin_lock_irqsave(&prz->buffer_lock, flags);
2257 +
2258 + old = atomic_read(&prz->buffer->start);
2259 + new = old + a;
2260 +@@ -64,7 +63,8 @@ static size_t buffer_start_add(struct persistent_ram_zone *prz, size_t a)
2261 + new -= prz->buffer_size;
2262 + atomic_set(&prz->buffer->start, new);
2263 +
2264 +- raw_spin_unlock_irqrestore(&buffer_lock, flags);
2265 ++ if (!(prz->flags & PRZ_FLAG_NO_LOCK))
2266 ++ raw_spin_unlock_irqrestore(&prz->buffer_lock, flags);
2267 +
2268 + return old;
2269 + }
2270 +@@ -74,9 +74,10 @@ static void buffer_size_add(struct persistent_ram_zone *prz, size_t a)
2271 + {
2272 + size_t old;
2273 + size_t new;
2274 +- unsigned long flags;
2275 ++ unsigned long flags = 0;
2276 +
2277 +- raw_spin_lock_irqsave(&buffer_lock, flags);
2278 ++ if (!(prz->flags & PRZ_FLAG_NO_LOCK))
2279 ++ raw_spin_lock_irqsave(&prz->buffer_lock, flags);
2280 +
2281 + old = atomic_read(&prz->buffer->size);
2282 + if (old == prz->buffer_size)
2283 +@@ -88,7 +89,8 @@ static void buffer_size_add(struct persistent_ram_zone *prz, size_t a)
2284 + atomic_set(&prz->buffer->size, new);
2285 +
2286 + exit:
2287 +- raw_spin_unlock_irqrestore(&buffer_lock, flags);
2288 ++ if (!(prz->flags & PRZ_FLAG_NO_LOCK))
2289 ++ raw_spin_unlock_irqrestore(&prz->buffer_lock, flags);
2290 + }
2291 +
2292 + static void notrace persistent_ram_encode_rs8(struct persistent_ram_zone *prz,
2293 +@@ -448,6 +450,7 @@ static int persistent_ram_post_init(struct persistent_ram_zone *prz, u32 sig,
2294 + prz->buffer->sig);
2295 + }
2296 +
2297 ++ /* Rewind missing or invalid memory area. */
2298 + prz->buffer->sig = sig;
2299 + persistent_ram_zap(prz);
2300 +
2301 +@@ -474,7 +477,7 @@ void persistent_ram_free(struct persistent_ram_zone *prz)
2302 +
2303 + struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
2304 + u32 sig, struct persistent_ram_ecc_info *ecc_info,
2305 +- unsigned int memtype)
2306 ++ unsigned int memtype, u32 flags)
2307 + {
2308 + struct persistent_ram_zone *prz;
2309 + int ret = -ENOMEM;
2310 +@@ -485,6 +488,10 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
2311 + goto err;
2312 + }
2313 +
2314 ++ /* Initialize general buffer state. */
2315 ++ raw_spin_lock_init(&prz->buffer_lock);
2316 ++ prz->flags = flags;
2317 ++
2318 + ret = persistent_ram_buffer_map(start, size, prz, memtype);
2319 + if (ret)
2320 + goto err;
2321 +diff --git a/fs/seq_file.c b/fs/seq_file.c
2322 +index d672e2fec459..6dc4296eed62 100644
2323 +--- a/fs/seq_file.c
2324 ++++ b/fs/seq_file.c
2325 +@@ -72,9 +72,10 @@ int seq_open(struct file *file, const struct seq_operations *op)
2326 +
2327 + mutex_init(&p->lock);
2328 + p->op = op;
2329 +-#ifdef CONFIG_USER_NS
2330 +- p->user_ns = file->f_cred->user_ns;
2331 +-#endif
2332 ++
2333 ++ // No refcounting: the lifetime of 'p' is constrained
2334 ++ // to the lifetime of the file.
2335 ++ p->file = file;
2336 +
2337 + /*
2338 + * Wrappers around seq_open(e.g. swaps_open) need to be
2339 +diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
2340 +index 187b80267ff9..a9063ac50c4e 100644
2341 +--- a/fs/xfs/xfs_aops.c
2342 ++++ b/fs/xfs/xfs_aops.c
2343 +@@ -1426,6 +1426,26 @@ __xfs_get_blocks(
2344 + if (error)
2345 + goto out_unlock;
2346 +
2347 ++ /*
2348 ++ * The only time we can ever safely find delalloc blocks on direct I/O
2349 ++ * is a dio write to post-eof speculative preallocation. All other
2350 ++ * scenarios are indicative of a problem or misuse (such as mixing
2351 ++ * direct and mapped I/O).
2352 ++ *
2353 ++ * The file may be unmapped by the time we get here so we cannot
2354 ++ * reliably fail the I/O based on mapping. Instead, fail the I/O if this
2355 ++ * is a read or a write within eof. Otherwise, carry on but warn as a
2356 ++ * precuation if the file happens to be mapped.
2357 ++ */
2358 ++ if (direct && imap.br_startblock == DELAYSTARTBLOCK) {
2359 ++ if (!create || offset < i_size_read(VFS_I(ip))) {
2360 ++ WARN_ON_ONCE(1);
2361 ++ error = -EIO;
2362 ++ goto out_unlock;
2363 ++ }
2364 ++ WARN_ON_ONCE(mapping_mapped(VFS_I(ip)->i_mapping));
2365 ++ }
2366 ++
2367 + /* for DAX, we convert unwritten extents directly */
2368 + if (create &&
2369 + (!nimaps ||
2370 +@@ -1525,7 +1545,6 @@ __xfs_get_blocks(
2371 + set_buffer_new(bh_result);
2372 +
2373 + if (imap.br_startblock == DELAYSTARTBLOCK) {
2374 +- BUG_ON(direct);
2375 + if (create) {
2376 + set_buffer_uptodate(bh_result);
2377 + set_buffer_mapped(bh_result);
2378 +diff --git a/include/linux/dcache.h b/include/linux/dcache.h
2379 +index 8d7151eb6ceb..d516847e0fae 100644
2380 +--- a/include/linux/dcache.h
2381 ++++ b/include/linux/dcache.h
2382 +@@ -615,5 +615,11 @@ static inline struct inode *d_real_inode(struct dentry *dentry)
2383 + return d_backing_inode(d_real(dentry));
2384 + }
2385 +
2386 ++struct name_snapshot {
2387 ++ const char *name;
2388 ++ char inline_name[DNAME_INLINE_LEN];
2389 ++};
2390 ++void take_dentry_name_snapshot(struct name_snapshot *, struct dentry *);
2391 ++void release_dentry_name_snapshot(struct name_snapshot *);
2392 +
2393 + #endif /* __LINUX_DCACHE_H */
2394 +diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
2395 +index 7ee1774edee5..a7789559078b 100644
2396 +--- a/include/linux/fsnotify.h
2397 ++++ b/include/linux/fsnotify.h
2398 +@@ -310,35 +310,4 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
2399 + }
2400 + }
2401 +
2402 +-#if defined(CONFIG_FSNOTIFY) /* notify helpers */
2403 +-
2404 +-/*
2405 +- * fsnotify_oldname_init - save off the old filename before we change it
2406 +- */
2407 +-static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
2408 +-{
2409 +- return kstrdup(name, GFP_KERNEL);
2410 +-}
2411 +-
2412 +-/*
2413 +- * fsnotify_oldname_free - free the name we got from fsnotify_oldname_init
2414 +- */
2415 +-static inline void fsnotify_oldname_free(const unsigned char *old_name)
2416 +-{
2417 +- kfree(old_name);
2418 +-}
2419 +-
2420 +-#else /* CONFIG_FSNOTIFY */
2421 +-
2422 +-static inline const char *fsnotify_oldname_init(const unsigned char *name)
2423 +-{
2424 +- return NULL;
2425 +-}
2426 +-
2427 +-static inline void fsnotify_oldname_free(const unsigned char *old_name)
2428 +-{
2429 +-}
2430 +-
2431 +-#endif /* CONFIG_FSNOTIFY */
2432 +-
2433 + #endif /* _LINUX_FS_NOTIFY_H */
2434 +diff --git a/include/linux/phy.h b/include/linux/phy.h
2435 +index 05fde31b6dc6..b64825d6ad26 100644
2436 +--- a/include/linux/phy.h
2437 ++++ b/include/linux/phy.h
2438 +@@ -785,6 +785,10 @@ int genphy_read_status(struct phy_device *phydev);
2439 + int genphy_suspend(struct phy_device *phydev);
2440 + int genphy_resume(struct phy_device *phydev);
2441 + int genphy_soft_reset(struct phy_device *phydev);
2442 ++static inline int genphy_no_soft_reset(struct phy_device *phydev)
2443 ++{
2444 ++ return 0;
2445 ++}
2446 + void phy_driver_unregister(struct phy_driver *drv);
2447 + void phy_drivers_unregister(struct phy_driver *drv, int n);
2448 + int phy_driver_register(struct phy_driver *new_driver);
2449 +diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h
2450 +index 9c9d6c154c8e..6f4520a82197 100644
2451 +--- a/include/linux/pstore_ram.h
2452 ++++ b/include/linux/pstore_ram.h
2453 +@@ -23,6 +23,13 @@
2454 + #include <linux/types.h>
2455 + #include <linux/init.h>
2456 +
2457 ++/*
2458 ++ * Choose whether access to the RAM zone requires locking or not. If a zone
2459 ++ * can be written to from different CPUs like with ftrace for example, then
2460 ++ * PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required.
2461 ++ */
2462 ++#define PRZ_FLAG_NO_LOCK BIT(0)
2463 ++
2464 + struct persistent_ram_buffer;
2465 + struct rs_control;
2466 +
2467 +@@ -39,6 +46,8 @@ struct persistent_ram_zone {
2468 + void *vaddr;
2469 + struct persistent_ram_buffer *buffer;
2470 + size_t buffer_size;
2471 ++ u32 flags;
2472 ++ raw_spinlock_t buffer_lock;
2473 +
2474 + /* ECC correction */
2475 + char *par_buffer;
2476 +@@ -54,7 +63,7 @@ struct persistent_ram_zone {
2477 +
2478 + struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
2479 + u32 sig, struct persistent_ram_ecc_info *ecc_info,
2480 +- unsigned int memtype);
2481 ++ unsigned int memtype, u32 flags);
2482 + void persistent_ram_free(struct persistent_ram_zone *prz);
2483 + void persistent_ram_zap(struct persistent_ram_zone *prz);
2484 +
2485 +diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
2486 +index dde00defbaa5..f3d45dd42695 100644
2487 +--- a/include/linux/seq_file.h
2488 ++++ b/include/linux/seq_file.h
2489 +@@ -7,13 +7,10 @@
2490 + #include <linux/mutex.h>
2491 + #include <linux/cpumask.h>
2492 + #include <linux/nodemask.h>
2493 ++#include <linux/fs.h>
2494 ++#include <linux/cred.h>
2495 +
2496 + struct seq_operations;
2497 +-struct file;
2498 +-struct path;
2499 +-struct inode;
2500 +-struct dentry;
2501 +-struct user_namespace;
2502 +
2503 + struct seq_file {
2504 + char *buf;
2505 +@@ -27,9 +24,7 @@ struct seq_file {
2506 + struct mutex lock;
2507 + const struct seq_operations *op;
2508 + int poll_event;
2509 +-#ifdef CONFIG_USER_NS
2510 +- struct user_namespace *user_ns;
2511 +-#endif
2512 ++ const struct file *file;
2513 + void *private;
2514 + };
2515 +
2516 +@@ -147,7 +142,7 @@ int seq_release_private(struct inode *, struct file *);
2517 + static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
2518 + {
2519 + #ifdef CONFIG_USER_NS
2520 +- return seq->user_ns;
2521 ++ return seq->file->f_cred->user_ns;
2522 + #else
2523 + extern struct user_namespace init_user_ns;
2524 + return &init_user_ns;
2525 +diff --git a/kernel/resource.c b/kernel/resource.c
2526 +index 249b1eb1e6e1..a4a94e700fb9 100644
2527 +--- a/kernel/resource.c
2528 ++++ b/kernel/resource.c
2529 +@@ -105,16 +105,25 @@ static int r_show(struct seq_file *m, void *v)
2530 + {
2531 + struct resource *root = m->private;
2532 + struct resource *r = v, *p;
2533 ++ unsigned long long start, end;
2534 + int width = root->end < 0x10000 ? 4 : 8;
2535 + int depth;
2536 +
2537 + for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent)
2538 + if (p->parent == root)
2539 + break;
2540 ++
2541 ++ if (file_ns_capable(m->file, &init_user_ns, CAP_SYS_ADMIN)) {
2542 ++ start = r->start;
2543 ++ end = r->end;
2544 ++ } else {
2545 ++ start = end = 0;
2546 ++ }
2547 ++
2548 + seq_printf(m, "%*s%0*llx-%0*llx : %s\n",
2549 + depth * 2, "",
2550 +- width, (unsigned long long) r->start,
2551 +- width, (unsigned long long) r->end,
2552 ++ width, start,
2553 ++ width, end,
2554 + r->name ? r->name : "<BAD>");
2555 + return 0;
2556 + }
2557 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
2558 +index c436426a80dd..dece705b7f8c 100644
2559 +--- a/kernel/sched/core.c
2560 ++++ b/kernel/sched/core.c
2561 +@@ -5553,7 +5553,6 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
2562 +
2563 + case CPU_UP_PREPARE:
2564 + rq->calc_load_update = calc_load_update;
2565 +- account_reset_rq(rq);
2566 + break;
2567 +
2568 + case CPU_ONLINE:
2569 +@@ -8253,11 +8252,20 @@ cpu_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
2570 + if (IS_ERR(tg))
2571 + return ERR_PTR(-ENOMEM);
2572 +
2573 +- sched_online_group(tg, parent);
2574 +-
2575 + return &tg->css;
2576 + }
2577 +
2578 ++/* Expose task group only after completing cgroup initialization */
2579 ++static int cpu_cgroup_css_online(struct cgroup_subsys_state *css)
2580 ++{
2581 ++ struct task_group *tg = css_tg(css);
2582 ++ struct task_group *parent = css_tg(css->parent);
2583 ++
2584 ++ if (parent)
2585 ++ sched_online_group(tg, parent);
2586 ++ return 0;
2587 ++}
2588 ++
2589 + static void cpu_cgroup_css_released(struct cgroup_subsys_state *css)
2590 + {
2591 + struct task_group *tg = css_tg(css);
2592 +@@ -8632,6 +8640,7 @@ static struct cftype cpu_files[] = {
2593 +
2594 + struct cgroup_subsys cpu_cgrp_subsys = {
2595 + .css_alloc = cpu_cgroup_css_alloc,
2596 ++ .css_online = cpu_cgroup_css_online,
2597 + .css_released = cpu_cgroup_css_released,
2598 + .css_free = cpu_cgroup_css_free,
2599 + .fork = cpu_cgroup_fork,
2600 +diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
2601 +index 4e5db65d1aab..55d92a1ca070 100644
2602 +--- a/kernel/sched/sched.h
2603 ++++ b/kernel/sched/sched.h
2604 +@@ -1770,16 +1770,3 @@ static inline u64 irq_time_read(int cpu)
2605 + }
2606 + #endif /* CONFIG_64BIT */
2607 + #endif /* CONFIG_IRQ_TIME_ACCOUNTING */
2608 +-
2609 +-static inline void account_reset_rq(struct rq *rq)
2610 +-{
2611 +-#ifdef CONFIG_IRQ_TIME_ACCOUNTING
2612 +- rq->prev_irq_time = 0;
2613 +-#endif
2614 +-#ifdef CONFIG_PARAVIRT
2615 +- rq->prev_steal_time = 0;
2616 +-#endif
2617 +-#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
2618 +- rq->prev_steal_time_rq = 0;
2619 +-#endif
2620 +-}
2621 +diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
2622 +index e20ae2d3c498..5e4199d5a388 100644
2623 +--- a/net/8021q/vlan.c
2624 ++++ b/net/8021q/vlan.c
2625 +@@ -292,6 +292,10 @@ static void vlan_sync_address(struct net_device *dev,
2626 + if (ether_addr_equal(vlan->real_dev_addr, dev->dev_addr))
2627 + return;
2628 +
2629 ++ /* vlan continues to inherit address of lower device */
2630 ++ if (vlan_dev_inherit_address(vlandev, dev))
2631 ++ goto out;
2632 ++
2633 + /* vlan address was different from the old address and is equal to
2634 + * the new address */
2635 + if (!ether_addr_equal(vlandev->dev_addr, vlan->real_dev_addr) &&
2636 +@@ -304,6 +308,7 @@ static void vlan_sync_address(struct net_device *dev,
2637 + !ether_addr_equal(vlandev->dev_addr, dev->dev_addr))
2638 + dev_uc_add(dev, vlandev->dev_addr);
2639 +
2640 ++out:
2641 + ether_addr_copy(vlan->real_dev_addr, dev->dev_addr);
2642 + }
2643 +
2644 +diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
2645 +index 9d010a09ab98..cc1557978066 100644
2646 +--- a/net/8021q/vlan.h
2647 ++++ b/net/8021q/vlan.h
2648 +@@ -109,6 +109,8 @@ int vlan_check_real_dev(struct net_device *real_dev,
2649 + void vlan_setup(struct net_device *dev);
2650 + int register_vlan_dev(struct net_device *dev);
2651 + void unregister_vlan_dev(struct net_device *dev, struct list_head *head);
2652 ++bool vlan_dev_inherit_address(struct net_device *dev,
2653 ++ struct net_device *real_dev);
2654 +
2655 + static inline u32 vlan_get_ingress_priority(struct net_device *dev,
2656 + u16 vlan_tci)
2657 +diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
2658 +index fded86508117..ca4dc9031073 100644
2659 +--- a/net/8021q/vlan_dev.c
2660 ++++ b/net/8021q/vlan_dev.c
2661 +@@ -244,6 +244,17 @@ void vlan_dev_get_realdev_name(const struct net_device *dev, char *result)
2662 + strncpy(result, vlan_dev_priv(dev)->real_dev->name, 23);
2663 + }
2664 +
2665 ++bool vlan_dev_inherit_address(struct net_device *dev,
2666 ++ struct net_device *real_dev)
2667 ++{
2668 ++ if (dev->addr_assign_type != NET_ADDR_STOLEN)
2669 ++ return false;
2670 ++
2671 ++ ether_addr_copy(dev->dev_addr, real_dev->dev_addr);
2672 ++ call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
2673 ++ return true;
2674 ++}
2675 ++
2676 + static int vlan_dev_open(struct net_device *dev)
2677 + {
2678 + struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
2679 +@@ -254,7 +265,8 @@ static int vlan_dev_open(struct net_device *dev)
2680 + !(vlan->flags & VLAN_FLAG_LOOSE_BINDING))
2681 + return -ENETDOWN;
2682 +
2683 +- if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr)) {
2684 ++ if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr) &&
2685 ++ !vlan_dev_inherit_address(dev, real_dev)) {
2686 + err = dev_uc_add(real_dev, dev->dev_addr);
2687 + if (err < 0)
2688 + goto out;
2689 +@@ -558,8 +570,10 @@ static int vlan_dev_init(struct net_device *dev)
2690 + /* ipv6 shared card related stuff */
2691 + dev->dev_id = real_dev->dev_id;
2692 +
2693 +- if (is_zero_ether_addr(dev->dev_addr))
2694 +- eth_hw_addr_inherit(dev, real_dev);
2695 ++ if (is_zero_ether_addr(dev->dev_addr)) {
2696 ++ ether_addr_copy(dev->dev_addr, real_dev->dev_addr);
2697 ++ dev->addr_assign_type = NET_ADDR_STOLEN;
2698 ++ }
2699 + if (is_zero_ether_addr(dev->broadcast))
2700 + memcpy(dev->broadcast, real_dev->broadcast, dev->addr_len);
2701 +
2702 +diff --git a/net/core/dev.c b/net/core/dev.c
2703 +index dc5d3d546150..4b0853194a03 100644
2704 +--- a/net/core/dev.c
2705 ++++ b/net/core/dev.c
2706 +@@ -2550,9 +2550,10 @@ EXPORT_SYMBOL(skb_mac_gso_segment);
2707 + static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path)
2708 + {
2709 + if (tx_path)
2710 +- return skb->ip_summed != CHECKSUM_PARTIAL;
2711 +- else
2712 +- return skb->ip_summed == CHECKSUM_NONE;
2713 ++ return skb->ip_summed != CHECKSUM_PARTIAL &&
2714 ++ skb->ip_summed != CHECKSUM_NONE;
2715 ++
2716 ++ return skb->ip_summed == CHECKSUM_NONE;
2717 + }
2718 +
2719 + /**
2720 +@@ -2571,11 +2572,12 @@ static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path)
2721 + struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
2722 + netdev_features_t features, bool tx_path)
2723 + {
2724 ++ struct sk_buff *segs;
2725 ++
2726 + if (unlikely(skb_needs_check(skb, tx_path))) {
2727 + int err;
2728 +
2729 +- skb_warn_bad_offload(skb);
2730 +-
2731 ++ /* We're going to init ->check field in TCP or UDP header */
2732 + err = skb_cow_head(skb, 0);
2733 + if (err < 0)
2734 + return ERR_PTR(err);
2735 +@@ -2590,7 +2592,12 @@ struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
2736 + skb_reset_mac_header(skb);
2737 + skb_reset_mac_len(skb);
2738 +
2739 +- return skb_mac_gso_segment(skb, features);
2740 ++ segs = skb_mac_gso_segment(skb, features);
2741 ++
2742 ++ if (unlikely(skb_needs_check(skb, tx_path)))
2743 ++ skb_warn_bad_offload(skb);
2744 ++
2745 ++ return segs;
2746 + }
2747 + EXPORT_SYMBOL(__skb_gso_segment);
2748 +
2749 +diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
2750 +index 7d339fc1057f..150b4923fb72 100644
2751 +--- a/net/ipv6/ip6_output.c
2752 ++++ b/net/ipv6/ip6_output.c
2753 +@@ -1361,7 +1361,7 @@ emsgsize:
2754 + */
2755 +
2756 + cork->length += length;
2757 +- if (((length > mtu) ||
2758 ++ if ((((length + fragheaderlen) > mtu) ||
2759 + (skb && skb_is_gso(skb))) &&
2760 + (sk->sk_protocol == IPPROTO_UDP) &&
2761 + (rt->dst.dev->features & NETIF_F_UFO) &&
2762 +diff --git a/net/key/af_key.c b/net/key/af_key.c
2763 +index d8d95b6415e4..2e1050ec2cf0 100644
2764 +--- a/net/key/af_key.c
2765 ++++ b/net/key/af_key.c
2766 +@@ -63,6 +63,7 @@ struct pfkey_sock {
2767 + } u;
2768 + struct sk_buff *skb;
2769 + } dump;
2770 ++ struct mutex dump_lock;
2771 + };
2772 +
2773 + static int parse_sockaddr_pair(struct sockaddr *sa, int ext_len,
2774 +@@ -143,6 +144,7 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol,
2775 + {
2776 + struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id);
2777 + struct sock *sk;
2778 ++ struct pfkey_sock *pfk;
2779 + int err;
2780 +
2781 + if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
2782 +@@ -157,6 +159,9 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol,
2783 + if (sk == NULL)
2784 + goto out;
2785 +
2786 ++ pfk = pfkey_sk(sk);
2787 ++ mutex_init(&pfk->dump_lock);
2788 ++
2789 + sock->ops = &pfkey_ops;
2790 + sock_init_data(sock, sk);
2791 +
2792 +@@ -285,13 +290,23 @@ static int pfkey_do_dump(struct pfkey_sock *pfk)
2793 + struct sadb_msg *hdr;
2794 + int rc;
2795 +
2796 ++ mutex_lock(&pfk->dump_lock);
2797 ++ if (!pfk->dump.dump) {
2798 ++ rc = 0;
2799 ++ goto out;
2800 ++ }
2801 ++
2802 + rc = pfk->dump.dump(pfk);
2803 +- if (rc == -ENOBUFS)
2804 +- return 0;
2805 ++ if (rc == -ENOBUFS) {
2806 ++ rc = 0;
2807 ++ goto out;
2808 ++ }
2809 +
2810 + if (pfk->dump.skb) {
2811 +- if (!pfkey_can_dump(&pfk->sk))
2812 +- return 0;
2813 ++ if (!pfkey_can_dump(&pfk->sk)) {
2814 ++ rc = 0;
2815 ++ goto out;
2816 ++ }
2817 +
2818 + hdr = (struct sadb_msg *) pfk->dump.skb->data;
2819 + hdr->sadb_msg_seq = 0;
2820 +@@ -302,6 +317,9 @@ static int pfkey_do_dump(struct pfkey_sock *pfk)
2821 + }
2822 +
2823 + pfkey_terminate_dump(pfk);
2824 ++
2825 ++out:
2826 ++ mutex_unlock(&pfk->dump_lock);
2827 + return rc;
2828 + }
2829 +
2830 +@@ -1806,19 +1824,26 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms
2831 + struct xfrm_address_filter *filter = NULL;
2832 + struct pfkey_sock *pfk = pfkey_sk(sk);
2833 +
2834 +- if (pfk->dump.dump != NULL)
2835 ++ mutex_lock(&pfk->dump_lock);
2836 ++ if (pfk->dump.dump != NULL) {
2837 ++ mutex_unlock(&pfk->dump_lock);
2838 + return -EBUSY;
2839 ++ }
2840 +
2841 + proto = pfkey_satype2proto(hdr->sadb_msg_satype);
2842 +- if (proto == 0)
2843 ++ if (proto == 0) {
2844 ++ mutex_unlock(&pfk->dump_lock);
2845 + return -EINVAL;
2846 ++ }
2847 +
2848 + if (ext_hdrs[SADB_X_EXT_FILTER - 1]) {
2849 + struct sadb_x_filter *xfilter = ext_hdrs[SADB_X_EXT_FILTER - 1];
2850 +
2851 + filter = kmalloc(sizeof(*filter), GFP_KERNEL);
2852 +- if (filter == NULL)
2853 ++ if (filter == NULL) {
2854 ++ mutex_unlock(&pfk->dump_lock);
2855 + return -ENOMEM;
2856 ++ }
2857 +
2858 + memcpy(&filter->saddr, &xfilter->sadb_x_filter_saddr,
2859 + sizeof(xfrm_address_t));
2860 +@@ -1834,6 +1859,7 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms
2861 + pfk->dump.dump = pfkey_dump_sa;
2862 + pfk->dump.done = pfkey_dump_sa_done;
2863 + xfrm_state_walk_init(&pfk->dump.u.state, proto, filter);
2864 ++ mutex_unlock(&pfk->dump_lock);
2865 +
2866 + return pfkey_do_dump(pfk);
2867 + }
2868 +@@ -2693,14 +2719,18 @@ static int pfkey_spddump(struct sock *sk, struct sk_buff *skb, const struct sadb
2869 + {
2870 + struct pfkey_sock *pfk = pfkey_sk(sk);
2871 +
2872 +- if (pfk->dump.dump != NULL)
2873 ++ mutex_lock(&pfk->dump_lock);
2874 ++ if (pfk->dump.dump != NULL) {
2875 ++ mutex_unlock(&pfk->dump_lock);
2876 + return -EBUSY;
2877 ++ }
2878 +
2879 + pfk->dump.msg_version = hdr->sadb_msg_version;
2880 + pfk->dump.msg_portid = hdr->sadb_msg_pid;
2881 + pfk->dump.dump = pfkey_dump_sp;
2882 + pfk->dump.done = pfkey_dump_sp_done;
2883 + xfrm_policy_walk_init(&pfk->dump.u.policy, XFRM_POLICY_TYPE_MAIN);
2884 ++ mutex_unlock(&pfk->dump_lock);
2885 +
2886 + return pfkey_do_dump(pfk);
2887 + }
2888 +diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
2889 +index 8a0fdd870395..77055a362041 100644
2890 +--- a/net/xfrm/xfrm_policy.c
2891 ++++ b/net/xfrm/xfrm_policy.c
2892 +@@ -1216,7 +1216,7 @@ static inline int policy_to_flow_dir(int dir)
2893 + }
2894 +
2895 + static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
2896 +- const struct flowi *fl)
2897 ++ const struct flowi *fl, u16 family)
2898 + {
2899 + struct xfrm_policy *pol;
2900 + struct net *net = sock_net(sk);
2901 +@@ -1225,8 +1225,7 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
2902 + read_lock_bh(&net->xfrm.xfrm_policy_lock);
2903 + pol = rcu_dereference(sk->sk_policy[dir]);
2904 + if (pol != NULL) {
2905 +- bool match = xfrm_selector_match(&pol->selector, fl,
2906 +- sk->sk_family);
2907 ++ bool match = xfrm_selector_match(&pol->selector, fl, family);
2908 + int err = 0;
2909 +
2910 + if (match) {
2911 +@@ -2174,7 +2173,7 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
2912 + sk = sk_const_to_full_sk(sk);
2913 + if (sk && sk->sk_policy[XFRM_POLICY_OUT]) {
2914 + num_pols = 1;
2915 +- pols[0] = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl);
2916 ++ pols[0] = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl, family);
2917 + err = xfrm_expand_policies(fl, family, pols,
2918 + &num_pols, &num_xfrms);
2919 + if (err < 0)
2920 +@@ -2453,7 +2452,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
2921 + pol = NULL;
2922 + sk = sk_to_full_sk(sk);
2923 + if (sk && sk->sk_policy[dir]) {
2924 +- pol = xfrm_sk_policy_lookup(sk, dir, &fl);
2925 ++ pol = xfrm_sk_policy_lookup(sk, dir, &fl, family);
2926 + if (IS_ERR(pol)) {
2927 + XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLERROR);
2928 + return 0;
2929 +diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
2930 +index c1b87c5800b1..b3fddba4c084 100644
2931 +--- a/sound/soc/codecs/nau8825.c
2932 ++++ b/sound/soc/codecs/nau8825.c
2933 +@@ -936,7 +936,8 @@ static void nau8825_fll_apply(struct nau8825 *nau8825,
2934 + NAU8825_FLL_INTEGER_MASK, fll_param->fll_int);
2935 + /* FLL pre-scaler */
2936 + regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL4,
2937 +- NAU8825_FLL_REF_DIV_MASK, fll_param->clk_ref_div);
2938 ++ NAU8825_FLL_REF_DIV_MASK,
2939 ++ fll_param->clk_ref_div << NAU8825_FLL_REF_DIV_SFT);
2940 + /* select divided VCO input */
2941 + regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL5,
2942 + NAU8825_FLL_FILTER_SW_MASK, 0x0000);
2943 +diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h
2944 +index dff8edb83bfd..a0b220726a63 100644
2945 +--- a/sound/soc/codecs/nau8825.h
2946 ++++ b/sound/soc/codecs/nau8825.h
2947 +@@ -114,7 +114,8 @@
2948 + #define NAU8825_FLL_INTEGER_MASK (0x3ff << 0)
2949 +
2950 + /* FLL4 (0x07) */
2951 +-#define NAU8825_FLL_REF_DIV_MASK (0x3 << 10)
2952 ++#define NAU8825_FLL_REF_DIV_SFT 10
2953 ++#define NAU8825_FLL_REF_DIV_MASK (0x3 << NAU8825_FLL_REF_DIV_SFT)
2954 +
2955 + /* FLL5 (0x08) */
2956 + #define NAU8825_FLL_FILTER_SW_MASK (0x1 << 14)
2957 +diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
2958 +index a564759845f9..5a3f544bb3a8 100644
2959 +--- a/sound/soc/codecs/tlv320aic3x.c
2960 ++++ b/sound/soc/codecs/tlv320aic3x.c
2961 +@@ -126,6 +126,16 @@ static const struct reg_default aic3x_reg[] = {
2962 + { 108, 0x00 }, { 109, 0x00 },
2963 + };
2964 +
2965 ++static bool aic3x_volatile_reg(struct device *dev, unsigned int reg)
2966 ++{
2967 ++ switch (reg) {
2968 ++ case AIC3X_RESET:
2969 ++ return true;
2970 ++ default:
2971 ++ return false;
2972 ++ }
2973 ++}
2974 ++
2975 + static const struct regmap_config aic3x_regmap = {
2976 + .reg_bits = 8,
2977 + .val_bits = 8,
2978 +@@ -133,6 +143,9 @@ static const struct regmap_config aic3x_regmap = {
2979 + .max_register = DAC_ICC_ADJ,
2980 + .reg_defaults = aic3x_reg,
2981 + .num_reg_defaults = ARRAY_SIZE(aic3x_reg),
2982 ++
2983 ++ .volatile_reg = aic3x_volatile_reg,
2984 ++
2985 + .cache_type = REGCACHE_RBTREE,
2986 + };
2987 +
2988 +diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
2989 +index 65b936e251ea..a1e605bbc465 100644
2990 +--- a/sound/soc/soc-pcm.c
2991 ++++ b/sound/soc/soc-pcm.c
2992 +@@ -2073,9 +2073,11 @@ static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd)
2993 + break;
2994 + case SNDRV_PCM_TRIGGER_STOP:
2995 + case SNDRV_PCM_TRIGGER_SUSPEND:
2996 +- case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
2997 + fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
2998 + break;
2999 ++ case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
3000 ++ fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED;
3001 ++ break;
3002 + }
3003 +
3004 + out:
3005 +diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
3006 +index be1f511e4f54..ae2981460cd8 100644
3007 +--- a/sound/usb/endpoint.c
3008 ++++ b/sound/usb/endpoint.c
3009 +@@ -384,6 +384,9 @@ static void snd_complete_urb(struct urb *urb)
3010 + if (unlikely(atomic_read(&ep->chip->shutdown)))
3011 + goto exit_clear;
3012 +
3013 ++ if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags)))
3014 ++ goto exit_clear;
3015 ++
3016 + if (usb_pipeout(ep->pipe)) {
3017 + retire_outbound_urb(ep, ctx);
3018 + /* can be stopped during retire callback */
3019 +diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c
3020 +index f1ce60065258..ec30c2fcbac0 100644
3021 +--- a/tools/lib/traceevent/plugin_sched_switch.c
3022 ++++ b/tools/lib/traceevent/plugin_sched_switch.c
3023 +@@ -111,7 +111,7 @@ static int sched_switch_handler(struct trace_seq *s,
3024 + trace_seq_printf(s, "%lld ", val);
3025 +
3026 + if (pevent_get_field_val(s, event, "prev_prio", record, &val, 0) == 0)
3027 +- trace_seq_printf(s, "[%lld] ", val);
3028 ++ trace_seq_printf(s, "[%d] ", (int) val);
3029 +
3030 + if (pevent_get_field_val(s, event, "prev_state", record, &val, 0) == 0)
3031 + write_state(s, val);
3032 +@@ -129,7 +129,7 @@ static int sched_switch_handler(struct trace_seq *s,
3033 + trace_seq_printf(s, "%lld", val);
3034 +
3035 + if (pevent_get_field_val(s, event, "next_prio", record, &val, 0) == 0)
3036 +- trace_seq_printf(s, " [%lld]", val);
3037 ++ trace_seq_printf(s, " [%d]", (int) val);
3038 +
3039 + return 0;
3040 + }
3041 +diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
3042 +index 929a32ba15f5..b67e006d56cc 100644
3043 +--- a/tools/perf/Makefile.perf
3044 ++++ b/tools/perf/Makefile.perf
3045 +@@ -563,9 +563,9 @@ install-tests: all install-gtk
3046 + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
3047 + $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
3048 +
3049 +-install-bin: install-tools install-tests
3050 ++install-bin: install-tools install-tests install-traceevent-plugins
3051 +
3052 +-install: install-bin try-install-man install-traceevent-plugins
3053 ++install: install-bin try-install-man
3054 +
3055 + install-python_ext:
3056 + $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
3057 +diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
3058 +index 67282a759496..eeeae0629ad3 100644
3059 +--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
3060 ++++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
3061 +@@ -110,6 +110,7 @@ struct intel_pt_decoder {
3062 + bool have_tma;
3063 + bool have_cyc;
3064 + bool fixup_last_mtc;
3065 ++ bool have_last_ip;
3066 + uint64_t pos;
3067 + uint64_t last_ip;
3068 + uint64_t ip;
3069 +@@ -145,8 +146,6 @@ struct intel_pt_decoder {
3070 + bool have_calc_cyc_to_tsc;
3071 + int exec_mode;
3072 + unsigned int insn_bytes;
3073 +- uint64_t sign_bit;
3074 +- uint64_t sign_bits;
3075 + uint64_t period;
3076 + enum intel_pt_period_type period_type;
3077 + uint64_t tot_insn_cnt;
3078 +@@ -214,9 +213,6 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params)
3079 + decoder->data = params->data;
3080 + decoder->return_compression = params->return_compression;
3081 +
3082 +- decoder->sign_bit = (uint64_t)1 << 47;
3083 +- decoder->sign_bits = ~(((uint64_t)1 << 48) - 1);
3084 +-
3085 + decoder->period = params->period;
3086 + decoder->period_type = params->period_type;
3087 +
3088 +@@ -385,21 +381,30 @@ int intel_pt__strerror(int code, char *buf, size_t buflen)
3089 + return 0;
3090 + }
3091 +
3092 +-static uint64_t intel_pt_calc_ip(struct intel_pt_decoder *decoder,
3093 +- const struct intel_pt_pkt *packet,
3094 ++static uint64_t intel_pt_calc_ip(const struct intel_pt_pkt *packet,
3095 + uint64_t last_ip)
3096 + {
3097 + uint64_t ip;
3098 +
3099 + switch (packet->count) {
3100 +- case 2:
3101 ++ case 1:
3102 + ip = (last_ip & (uint64_t)0xffffffffffff0000ULL) |
3103 + packet->payload;
3104 + break;
3105 +- case 4:
3106 ++ case 2:
3107 + ip = (last_ip & (uint64_t)0xffffffff00000000ULL) |
3108 + packet->payload;
3109 + break;
3110 ++ case 3:
3111 ++ ip = packet->payload;
3112 ++ /* Sign-extend 6-byte ip */
3113 ++ if (ip & (uint64_t)0x800000000000ULL)
3114 ++ ip |= (uint64_t)0xffff000000000000ULL;
3115 ++ break;
3116 ++ case 4:
3117 ++ ip = (last_ip & (uint64_t)0xffff000000000000ULL) |
3118 ++ packet->payload;
3119 ++ break;
3120 + case 6:
3121 + ip = packet->payload;
3122 + break;
3123 +@@ -407,16 +412,13 @@ static uint64_t intel_pt_calc_ip(struct intel_pt_decoder *decoder,
3124 + return 0;
3125 + }
3126 +
3127 +- if (ip & decoder->sign_bit)
3128 +- return ip | decoder->sign_bits;
3129 +-
3130 + return ip;
3131 + }
3132 +
3133 + static inline void intel_pt_set_last_ip(struct intel_pt_decoder *decoder)
3134 + {
3135 +- decoder->last_ip = intel_pt_calc_ip(decoder, &decoder->packet,
3136 +- decoder->last_ip);
3137 ++ decoder->last_ip = intel_pt_calc_ip(&decoder->packet, decoder->last_ip);
3138 ++ decoder->have_last_ip = true;
3139 + }
3140 +
3141 + static inline void intel_pt_set_ip(struct intel_pt_decoder *decoder)
3142 +@@ -1436,7 +1438,8 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
3143 +
3144 + case INTEL_PT_FUP:
3145 + decoder->pge = true;
3146 +- intel_pt_set_last_ip(decoder);
3147 ++ if (decoder->packet.count)
3148 ++ intel_pt_set_last_ip(decoder);
3149 + break;
3150 +
3151 + case INTEL_PT_MODE_TSX:
3152 +@@ -1640,6 +1643,8 @@ next:
3153 + break;
3154 +
3155 + case INTEL_PT_PSB:
3156 ++ decoder->last_ip = 0;
3157 ++ decoder->have_last_ip = true;
3158 + intel_pt_clear_stack(&decoder->stack);
3159 + err = intel_pt_walk_psbend(decoder);
3160 + if (err == -EAGAIN)
3161 +@@ -1718,6 +1723,13 @@ next:
3162 + }
3163 + }
3164 +
3165 ++static inline bool intel_pt_have_ip(struct intel_pt_decoder *decoder)
3166 ++{
3167 ++ return decoder->packet.count &&
3168 ++ (decoder->have_last_ip || decoder->packet.count == 3 ||
3169 ++ decoder->packet.count == 6);
3170 ++}
3171 ++
3172 + /* Walk PSB+ packets to get in sync. */
3173 + static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
3174 + {
3175 +@@ -1739,8 +1751,7 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
3176 +
3177 + case INTEL_PT_FUP:
3178 + decoder->pge = true;
3179 +- if (decoder->last_ip || decoder->packet.count == 6 ||
3180 +- decoder->packet.count == 0) {
3181 ++ if (intel_pt_have_ip(decoder)) {
3182 + uint64_t current_ip = decoder->ip;
3183 +
3184 + intel_pt_set_ip(decoder);
3185 +@@ -1832,24 +1843,17 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
3186 + case INTEL_PT_TIP_PGE:
3187 + case INTEL_PT_TIP:
3188 + decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD;
3189 +- if (decoder->last_ip || decoder->packet.count == 6 ||
3190 +- decoder->packet.count == 0)
3191 ++ if (intel_pt_have_ip(decoder))
3192 + intel_pt_set_ip(decoder);
3193 + if (decoder->ip)
3194 + return 0;
3195 + break;
3196 +
3197 + case INTEL_PT_FUP:
3198 +- if (decoder->overflow) {
3199 +- if (decoder->last_ip ||
3200 +- decoder->packet.count == 6 ||
3201 +- decoder->packet.count == 0)
3202 +- intel_pt_set_ip(decoder);
3203 +- if (decoder->ip)
3204 +- return 0;
3205 +- }
3206 +- if (decoder->packet.count)
3207 +- intel_pt_set_last_ip(decoder);
3208 ++ if (intel_pt_have_ip(decoder))
3209 ++ intel_pt_set_ip(decoder);
3210 ++ if (decoder->ip)
3211 ++ return 0;
3212 + break;
3213 +
3214 + case INTEL_PT_MTC:
3215 +@@ -1898,6 +1902,8 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
3216 + break;
3217 +
3218 + case INTEL_PT_PSB:
3219 ++ decoder->last_ip = 0;
3220 ++ decoder->have_last_ip = true;
3221 + intel_pt_clear_stack(&decoder->stack);
3222 + err = intel_pt_walk_psb(decoder);
3223 + if (err)
3224 +@@ -2034,6 +2040,7 @@ static int intel_pt_sync(struct intel_pt_decoder *decoder)
3225 +
3226 + decoder->pge = false;
3227 + decoder->continuous_period = false;
3228 ++ decoder->have_last_ip = false;
3229 + decoder->last_ip = 0;
3230 + decoder->ip = 0;
3231 + intel_pt_clear_stack(&decoder->stack);
3232 +@@ -2042,6 +2049,7 @@ static int intel_pt_sync(struct intel_pt_decoder *decoder)
3233 + if (err)
3234 + return err;
3235 +
3236 ++ decoder->have_last_ip = true;
3237 + decoder->pkt_state = INTEL_PT_STATE_NO_IP;
3238 +
3239 + err = intel_pt_walk_psb(decoder);
3240 +@@ -2084,6 +2092,7 @@ const struct intel_pt_state *intel_pt_decode(struct intel_pt_decoder *decoder)
3241 + err = intel_pt_sync(decoder);
3242 + break;
3243 + case INTEL_PT_STATE_NO_IP:
3244 ++ decoder->have_last_ip = false;
3245 + decoder->last_ip = 0;
3246 + decoder->ip = 0;
3247 + /* Fall through */
3248 +diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
3249 +index 9b2fce25162b..7528ae4f7e28 100644
3250 +--- a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
3251 ++++ b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
3252 +@@ -293,36 +293,46 @@ static int intel_pt_get_ip(enum intel_pt_pkt_type type, unsigned int byte,
3253 + const unsigned char *buf, size_t len,
3254 + struct intel_pt_pkt *packet)
3255 + {
3256 +- switch (byte >> 5) {
3257 ++ int ip_len;
3258 ++
3259 ++ packet->count = byte >> 5;
3260 ++
3261 ++ switch (packet->count) {
3262 + case 0:
3263 +- packet->count = 0;
3264 ++ ip_len = 0;
3265 + break;
3266 + case 1:
3267 + if (len < 3)
3268 + return INTEL_PT_NEED_MORE_BYTES;
3269 +- packet->count = 2;
3270 ++ ip_len = 2;
3271 + packet->payload = le16_to_cpu(*(uint16_t *)(buf + 1));
3272 + break;
3273 + case 2:
3274 + if (len < 5)
3275 + return INTEL_PT_NEED_MORE_BYTES;
3276 +- packet->count = 4;
3277 ++ ip_len = 4;
3278 + packet->payload = le32_to_cpu(*(uint32_t *)(buf + 1));
3279 + break;
3280 + case 3:
3281 +- case 6:
3282 ++ case 4:
3283 + if (len < 7)
3284 + return INTEL_PT_NEED_MORE_BYTES;
3285 +- packet->count = 6;
3286 ++ ip_len = 6;
3287 + memcpy_le64(&packet->payload, buf + 1, 6);
3288 + break;
3289 ++ case 6:
3290 ++ if (len < 9)
3291 ++ return INTEL_PT_NEED_MORE_BYTES;
3292 ++ ip_len = 8;
3293 ++ packet->payload = le64_to_cpu(*(uint64_t *)(buf + 1));
3294 ++ break;
3295 + default:
3296 + return INTEL_PT_BAD_PACKET;
3297 + }
3298 +
3299 + packet->type = type;
3300 +
3301 +- return packet->count + 1;
3302 ++ return ip_len + 1;
3303 + }
3304 +
3305 + static int intel_pt_get_mode(const unsigned char *buf, size_t len,
3306 +diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
3307 +index 27ae382feb2d..7c97ecaeae48 100644
3308 +--- a/tools/perf/util/symbol-elf.c
3309 ++++ b/tools/perf/util/symbol-elf.c
3310 +@@ -488,6 +488,12 @@ int sysfs__read_build_id(const char *filename, void *build_id, size_t size)
3311 + break;
3312 + } else {
3313 + int n = namesz + descsz;
3314 ++
3315 ++ if (n > (int)sizeof(bf)) {
3316 ++ n = sizeof(bf);
3317 ++ pr_debug("%s: truncating reading of build id in sysfs file %s: n_namesz=%u, n_descsz=%u.\n",
3318 ++ __func__, filename, nhdr.n_namesz, nhdr.n_descsz);
3319 ++ }
3320 + if (read(fd, bf, n) != n)
3321 + break;
3322 + }