Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.16 commit in: /
Date: Wed, 02 May 2018 16:15:44
Message-Id: 1525277730.7cde86eb95c44a9bfb0eab9ae50e3ac566563f2c.mpagano@gentoo
1 commit: 7cde86eb95c44a9bfb0eab9ae50e3ac566563f2c
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 2 16:15:30 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed May 2 16:15:30 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=7cde86eb
7
8 Linux patch 4.16.7
9
10 0000_README | 4 +
11 1006_linux-4.16.7.patch | 4737 +++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 4741 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index d4182dc..1139362 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -67,6 +67,10 @@ Patch: 1005_linux-4.16.6.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.16.6
21
22 +Patch: 1006_linux-4.16.7.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.16.7
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1006_linux-4.16.7.patch b/1006_linux-4.16.7.patch
31 new file mode 100644
32 index 0000000..4dec6c8
33 --- /dev/null
34 +++ b/1006_linux-4.16.7.patch
35 @@ -0,0 +1,4737 @@
36 +diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
37 +index d6b3ff51a14f..36187fc32ab2 100644
38 +--- a/Documentation/virtual/kvm/api.txt
39 ++++ b/Documentation/virtual/kvm/api.txt
40 +@@ -1960,6 +1960,9 @@ ARM 32-bit VFP control registers have the following id bit patterns:
41 + ARM 64-bit FP registers have the following id bit patterns:
42 + 0x4030 0000 0012 0 <regno:12>
43 +
44 ++ARM firmware pseudo-registers have the following bit pattern:
45 ++ 0x4030 0000 0014 <regno:16>
46 ++
47 +
48 + arm64 registers are mapped using the lower 32 bits. The upper 16 of
49 + that is the register group type, or coprocessor number:
50 +@@ -1976,6 +1979,9 @@ arm64 CCSIDR registers are demultiplexed by CSSELR value:
51 + arm64 system registers have the following id bit patterns:
52 + 0x6030 0000 0013 <op0:2> <op1:3> <crn:4> <crm:4> <op2:3>
53 +
54 ++arm64 firmware pseudo-registers have the following bit pattern:
55 ++ 0x6030 0000 0014 <regno:16>
56 ++
57 +
58 + MIPS registers are mapped using the lower 32 bits. The upper 16 of that is
59 + the register group type:
60 +@@ -2510,7 +2516,8 @@ Possible features:
61 + and execute guest code when KVM_RUN is called.
62 + - KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode.
63 + Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only).
64 +- - KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 for the CPU.
65 ++ - KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 (or a future revision
66 ++ backward compatible with v0.2) for the CPU.
67 + Depends on KVM_CAP_ARM_PSCI_0_2.
68 + - KVM_ARM_VCPU_PMU_V3: Emulate PMUv3 for the CPU.
69 + Depends on KVM_CAP_ARM_PMU_V3.
70 +diff --git a/Documentation/virtual/kvm/arm/psci.txt b/Documentation/virtual/kvm/arm/psci.txt
71 +new file mode 100644
72 +index 000000000000..aafdab887b04
73 +--- /dev/null
74 ++++ b/Documentation/virtual/kvm/arm/psci.txt
75 +@@ -0,0 +1,30 @@
76 ++KVM implements the PSCI (Power State Coordination Interface)
77 ++specification in order to provide services such as CPU on/off, reset
78 ++and power-off to the guest.
79 ++
80 ++The PSCI specification is regularly updated to provide new features,
81 ++and KVM implements these updates if they make sense from a virtualization
82 ++point of view.
83 ++
84 ++This means that a guest booted on two different versions of KVM can
85 ++observe two different "firmware" revisions. This could cause issues if
86 ++a given guest is tied to a particular PSCI revision (unlikely), or if
87 ++a migration causes a different PSCI version to be exposed out of the
88 ++blue to an unsuspecting guest.
89 ++
90 ++In order to remedy this situation, KVM exposes a set of "firmware
91 ++pseudo-registers" that can be manipulated using the GET/SET_ONE_REG
92 ++interface. These registers can be saved/restored by userspace, and set
93 ++to a convenient value if required.
94 ++
95 ++The following register is defined:
96 ++
97 ++* KVM_REG_ARM_PSCI_VERSION:
98 ++
99 ++ - Only valid if the vcpu has the KVM_ARM_VCPU_PSCI_0_2 feature set
100 ++ (and thus has already been initialized)
101 ++ - Returns the current PSCI version on GET_ONE_REG (defaulting to the
102 ++ highest PSCI version implemented by KVM and compatible with v0.2)
103 ++ - Allows any PSCI version implemented by KVM and compatible with
104 ++ v0.2 to be set with SET_ONE_REG
105 ++ - Affects the whole VM (even if the register view is per-vcpu)
106 +diff --git a/Makefile b/Makefile
107 +index 41f07b2b7905..1c5d5d8c45e2 100644
108 +--- a/Makefile
109 ++++ b/Makefile
110 +@@ -1,7 +1,7 @@
111 + # SPDX-License-Identifier: GPL-2.0
112 + VERSION = 4
113 + PATCHLEVEL = 16
114 +-SUBLEVEL = 6
115 ++SUBLEVEL = 7
116 + EXTRAVERSION =
117 + NAME = Fearless Coyote
118 +
119 +diff --git a/arch/arm/boot/dts/gemini-nas4220b.dts b/arch/arm/boot/dts/gemini-nas4220b.dts
120 +index 8bbb6f85d161..4785fbcc41ed 100644
121 +--- a/arch/arm/boot/dts/gemini-nas4220b.dts
122 ++++ b/arch/arm/boot/dts/gemini-nas4220b.dts
123 +@@ -134,37 +134,37 @@
124 + function = "gmii";
125 + groups = "gmii_gmac0_grp";
126 + };
127 +- /* Settings come from OpenWRT */
128 ++ /* Settings come from OpenWRT, pins on SL3516 */
129 + conf0 {
130 +- pins = "R8 GMAC0 RXDV", "U11 GMAC1 RXDV";
131 ++ pins = "V8 GMAC0 RXDV", "T10 GMAC1 RXDV";
132 + skew-delay = <0>;
133 + };
134 + conf1 {
135 +- pins = "T8 GMAC0 RXC", "T11 GMAC1 RXC";
136 ++ pins = "Y7 GMAC0 RXC", "Y11 GMAC1 RXC";
137 + skew-delay = <15>;
138 + };
139 + conf2 {
140 +- pins = "P8 GMAC0 TXEN", "V11 GMAC1 TXEN";
141 ++ pins = "T8 GMAC0 TXEN", "W11 GMAC1 TXEN";
142 + skew-delay = <7>;
143 + };
144 + conf3 {
145 +- pins = "V7 GMAC0 TXC";
146 ++ pins = "U8 GMAC0 TXC";
147 + skew-delay = <11>;
148 + };
149 + conf4 {
150 +- pins = "P10 GMAC1 TXC";
151 ++ pins = "V11 GMAC1 TXC";
152 + skew-delay = <10>;
153 + };
154 + conf5 {
155 + /* The data lines all have default skew */
156 +- pins = "U8 GMAC0 RXD0", "V8 GMAC0 RXD1",
157 +- "P9 GMAC0 RXD2", "R9 GMAC0 RXD3",
158 +- "U7 GMAC0 TXD0", "T7 GMAC0 TXD1",
159 +- "R7 GMAC0 TXD2", "P7 GMAC0 TXD3",
160 +- "R11 GMAC1 RXD0", "P11 GMAC1 RXD1",
161 +- "V12 GMAC1 RXD2", "U12 GMAC1 RXD3",
162 +- "R10 GMAC1 TXD0", "T10 GMAC1 TXD1",
163 +- "U10 GMAC1 TXD2", "V10 GMAC1 TXD3";
164 ++ pins = "W8 GMAC0 RXD0", "V9 GMAC0 RXD1",
165 ++ "Y8 GMAC0 RXD2", "U9 GMAC0 RXD3",
166 ++ "T7 GMAC0 TXD0", "U6 GMAC0 TXD1",
167 ++ "V7 GMAC0 TXD2", "U7 GMAC0 TXD3",
168 ++ "Y12 GMAC1 RXD0", "V12 GMAC1 RXD1",
169 ++ "T11 GMAC1 RXD2", "W12 GMAC1 RXD3",
170 ++ "U10 GMAC1 TXD0", "Y10 GMAC1 TXD1",
171 ++ "W10 GMAC1 TXD2", "T9 GMAC1 TXD3";
172 + skew-delay = <7>;
173 + };
174 + /* Set up drive strength on GMAC0 to 16 mA */
175 +diff --git a/arch/arm/configs/socfpga_defconfig b/arch/arm/configs/socfpga_defconfig
176 +index 2620ce790db0..371fca4e1ab7 100644
177 +--- a/arch/arm/configs/socfpga_defconfig
178 ++++ b/arch/arm/configs/socfpga_defconfig
179 +@@ -57,6 +57,7 @@ CONFIG_MTD_M25P80=y
180 + CONFIG_MTD_NAND=y
181 + CONFIG_MTD_NAND_DENALI_DT=y
182 + CONFIG_MTD_SPI_NOR=y
183 ++# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
184 + CONFIG_SPI_CADENCE_QUADSPI=y
185 + CONFIG_OF_OVERLAY=y
186 + CONFIG_OF_CONFIGFS=y
187 +diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
188 +index 248b930563e5..8b908d23c58a 100644
189 +--- a/arch/arm/include/asm/kvm_host.h
190 ++++ b/arch/arm/include/asm/kvm_host.h
191 +@@ -77,6 +77,9 @@ struct kvm_arch {
192 + /* Interrupt controller */
193 + struct vgic_dist vgic;
194 + int max_vcpus;
195 ++
196 ++ /* Mandated version of PSCI */
197 ++ u32 psci_version;
198 + };
199 +
200 + #define KVM_NR_MEM_OBJS 40
201 +diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
202 +index 6edd177bb1c7..47dfc99f5cd0 100644
203 +--- a/arch/arm/include/uapi/asm/kvm.h
204 ++++ b/arch/arm/include/uapi/asm/kvm.h
205 +@@ -186,6 +186,12 @@ struct kvm_arch_memory_slot {
206 + #define KVM_REG_ARM_VFP_FPINST 0x1009
207 + #define KVM_REG_ARM_VFP_FPINST2 0x100A
208 +
209 ++/* KVM-as-firmware specific pseudo-registers */
210 ++#define KVM_REG_ARM_FW (0x0014 << KVM_REG_ARM_COPROC_SHIFT)
211 ++#define KVM_REG_ARM_FW_REG(r) (KVM_REG_ARM | KVM_REG_SIZE_U64 | \
212 ++ KVM_REG_ARM_FW | ((r) & 0xffff))
213 ++#define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0)
214 ++
215 + /* Device Control API: ARM VGIC */
216 + #define KVM_DEV_ARM_VGIC_GRP_ADDR 0
217 + #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1
218 +diff --git a/arch/arm/kvm/guest.c b/arch/arm/kvm/guest.c
219 +index 1e0784ebbfd6..a18f33edc471 100644
220 +--- a/arch/arm/kvm/guest.c
221 ++++ b/arch/arm/kvm/guest.c
222 +@@ -22,6 +22,7 @@
223 + #include <linux/module.h>
224 + #include <linux/vmalloc.h>
225 + #include <linux/fs.h>
226 ++#include <kvm/arm_psci.h>
227 + #include <asm/cputype.h>
228 + #include <linux/uaccess.h>
229 + #include <asm/kvm.h>
230 +@@ -176,6 +177,7 @@ static unsigned long num_core_regs(void)
231 + unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu)
232 + {
233 + return num_core_regs() + kvm_arm_num_coproc_regs(vcpu)
234 ++ + kvm_arm_get_fw_num_regs(vcpu)
235 + + NUM_TIMER_REGS;
236 + }
237 +
238 +@@ -196,6 +198,11 @@ int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices)
239 + uindices++;
240 + }
241 +
242 ++ ret = kvm_arm_copy_fw_reg_indices(vcpu, uindices);
243 ++ if (ret)
244 ++ return ret;
245 ++ uindices += kvm_arm_get_fw_num_regs(vcpu);
246 ++
247 + ret = copy_timer_indices(vcpu, uindices);
248 + if (ret)
249 + return ret;
250 +@@ -214,6 +221,9 @@ int kvm_arm_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
251 + if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_CORE)
252 + return get_core_reg(vcpu, reg);
253 +
254 ++ if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_FW)
255 ++ return kvm_arm_get_fw_reg(vcpu, reg);
256 ++
257 + if (is_timer_reg(reg->id))
258 + return get_timer_reg(vcpu, reg);
259 +
260 +@@ -230,6 +240,9 @@ int kvm_arm_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
261 + if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_CORE)
262 + return set_core_reg(vcpu, reg);
263 +
264 ++ if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_FW)
265 ++ return kvm_arm_set_fw_reg(vcpu, reg);
266 ++
267 + if (is_timer_reg(reg->id))
268 + return set_timer_reg(vcpu, reg);
269 +
270 +diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
271 +index 596f8e414a4c..b9e355bd3b78 100644
272 +--- a/arch/arm64/include/asm/kvm_host.h
273 ++++ b/arch/arm64/include/asm/kvm_host.h
274 +@@ -75,6 +75,9 @@ struct kvm_arch {
275 +
276 + /* Interrupt controller */
277 + struct vgic_dist vgic;
278 ++
279 ++ /* Mandated version of PSCI */
280 ++ u32 psci_version;
281 + };
282 +
283 + #define KVM_NR_MEM_OBJS 40
284 +diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
285 +index 9abbf3044654..04b3256f8e6d 100644
286 +--- a/arch/arm64/include/uapi/asm/kvm.h
287 ++++ b/arch/arm64/include/uapi/asm/kvm.h
288 +@@ -206,6 +206,12 @@ struct kvm_arch_memory_slot {
289 + #define KVM_REG_ARM_TIMER_CNT ARM64_SYS_REG(3, 3, 14, 3, 2)
290 + #define KVM_REG_ARM_TIMER_CVAL ARM64_SYS_REG(3, 3, 14, 0, 2)
291 +
292 ++/* KVM-as-firmware specific pseudo-registers */
293 ++#define KVM_REG_ARM_FW (0x0014 << KVM_REG_ARM_COPROC_SHIFT)
294 ++#define KVM_REG_ARM_FW_REG(r) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \
295 ++ KVM_REG_ARM_FW | ((r) & 0xffff))
296 ++#define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0)
297 ++
298 + /* Device Control API: ARM VGIC */
299 + #define KVM_DEV_ARM_VGIC_GRP_ADDR 0
300 + #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1
301 +diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
302 +index 959e50d2588c..56a0260ceb11 100644
303 +--- a/arch/arm64/kvm/guest.c
304 ++++ b/arch/arm64/kvm/guest.c
305 +@@ -25,6 +25,7 @@
306 + #include <linux/module.h>
307 + #include <linux/vmalloc.h>
308 + #include <linux/fs.h>
309 ++#include <kvm/arm_psci.h>
310 + #include <asm/cputype.h>
311 + #include <linux/uaccess.h>
312 + #include <asm/kvm.h>
313 +@@ -205,7 +206,7 @@ static int get_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
314 + unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu)
315 + {
316 + return num_core_regs() + kvm_arm_num_sys_reg_descs(vcpu)
317 +- + NUM_TIMER_REGS;
318 ++ + kvm_arm_get_fw_num_regs(vcpu) + NUM_TIMER_REGS;
319 + }
320 +
321 + /**
322 +@@ -225,6 +226,11 @@ int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices)
323 + uindices++;
324 + }
325 +
326 ++ ret = kvm_arm_copy_fw_reg_indices(vcpu, uindices);
327 ++ if (ret)
328 ++ return ret;
329 ++ uindices += kvm_arm_get_fw_num_regs(vcpu);
330 ++
331 + ret = copy_timer_indices(vcpu, uindices);
332 + if (ret)
333 + return ret;
334 +@@ -243,6 +249,9 @@ int kvm_arm_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
335 + if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_CORE)
336 + return get_core_reg(vcpu, reg);
337 +
338 ++ if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_FW)
339 ++ return kvm_arm_get_fw_reg(vcpu, reg);
340 ++
341 + if (is_timer_reg(reg->id))
342 + return get_timer_reg(vcpu, reg);
343 +
344 +@@ -259,6 +268,9 @@ int kvm_arm_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
345 + if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_CORE)
346 + return set_core_reg(vcpu, reg);
347 +
348 ++ if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_FW)
349 ++ return kvm_arm_set_fw_reg(vcpu, reg);
350 ++
351 + if (is_timer_reg(reg->id))
352 + return set_timer_reg(vcpu, reg);
353 +
354 +diff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c
355 +index fe6fc63251fe..38c5b4764bfe 100644
356 +--- a/arch/powerpc/kernel/mce_power.c
357 ++++ b/arch/powerpc/kernel/mce_power.c
358 +@@ -441,7 +441,6 @@ static int mce_handle_ierror(struct pt_regs *regs,
359 + if (pfn != ULONG_MAX) {
360 + *phys_addr =
361 + (pfn << PAGE_SHIFT);
362 +- handled = 1;
363 + }
364 + }
365 + }
366 +@@ -532,9 +531,7 @@ static int mce_handle_derror(struct pt_regs *regs,
367 + * kernel/exception-64s.h
368 + */
369 + if (get_paca()->in_mce < MAX_MCE_DEPTH)
370 +- if (!mce_find_instr_ea_and_pfn(regs, addr,
371 +- phys_addr))
372 +- handled = 1;
373 ++ mce_find_instr_ea_and_pfn(regs, addr, phys_addr);
374 + }
375 + found = 1;
376 + }
377 +@@ -572,7 +569,7 @@ static long mce_handle_error(struct pt_regs *regs,
378 + const struct mce_ierror_table itable[])
379 + {
380 + struct mce_error_info mce_err = { 0 };
381 +- uint64_t addr, phys_addr;
382 ++ uint64_t addr, phys_addr = ULONG_MAX;
383 + uint64_t srr1 = regs->msr;
384 + long handled;
385 +
386 +diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
387 +index fe8c61149fb8..0cd9031b6b54 100644
388 +--- a/arch/powerpc/mm/mem.c
389 ++++ b/arch/powerpc/mm/mem.c
390 +@@ -143,6 +143,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
391 + start, start + size, rc);
392 + return -EFAULT;
393 + }
394 ++ flush_inval_dcache_range(start, start + size);
395 +
396 + return __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock);
397 + }
398 +@@ -169,6 +170,7 @@ int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
399 +
400 + /* Remove htab bolted mappings for this section of memory */
401 + start = (unsigned long)__va(start);
402 ++ flush_inval_dcache_range(start, start + size);
403 + ret = remove_section_mapping(start, start + size);
404 +
405 + /* Ensure all vmalloc mappings are flushed in case they also
406 +diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
407 +index 0a253b64ac5f..e7b621f619b2 100644
408 +--- a/arch/powerpc/platforms/powernv/npu-dma.c
409 ++++ b/arch/powerpc/platforms/powernv/npu-dma.c
410 +@@ -33,6 +33,13 @@
411 +
412 + #define npu_to_phb(x) container_of(x, struct pnv_phb, npu)
413 +
414 ++/*
415 ++ * When an address shootdown range exceeds this threshold we invalidate the
416 ++ * entire TLB on the GPU for the given PID rather than each specific address in
417 ++ * the range.
418 ++ */
419 ++#define ATSD_THRESHOLD (2*1024*1024)
420 ++
421 + /*
422 + * Other types of TCE cache invalidation are not functional in the
423 + * hardware.
424 +@@ -627,11 +634,19 @@ static void pnv_npu2_mn_invalidate_range(struct mmu_notifier *mn,
425 + struct npu_context *npu_context = mn_to_npu_context(mn);
426 + unsigned long address;
427 +
428 +- for (address = start; address < end; address += PAGE_SIZE)
429 +- mmio_invalidate(npu_context, 1, address, false);
430 ++ if (end - start > ATSD_THRESHOLD) {
431 ++ /*
432 ++ * Just invalidate the entire PID if the address range is too
433 ++ * large.
434 ++ */
435 ++ mmio_invalidate(npu_context, 0, 0, true);
436 ++ } else {
437 ++ for (address = start; address < end; address += PAGE_SIZE)
438 ++ mmio_invalidate(npu_context, 1, address, false);
439 +
440 +- /* Do the flush only on the final addess == end */
441 +- mmio_invalidate(npu_context, 1, address, true);
442 ++ /* Do the flush only on the final addess == end */
443 ++ mmio_invalidate(npu_context, 1, address, true);
444 ++ }
445 + }
446 +
447 + static const struct mmu_notifier_ops nv_nmmu_notifier_ops = {
448 +diff --git a/arch/powerpc/platforms/powernv/opal-rtc.c b/arch/powerpc/platforms/powernv/opal-rtc.c
449 +index f8868864f373..aa2a5139462e 100644
450 +--- a/arch/powerpc/platforms/powernv/opal-rtc.c
451 ++++ b/arch/powerpc/platforms/powernv/opal-rtc.c
452 +@@ -48,10 +48,12 @@ unsigned long __init opal_get_boot_time(void)
453 +
454 + while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
455 + rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms);
456 +- if (rc == OPAL_BUSY_EVENT)
457 ++ if (rc == OPAL_BUSY_EVENT) {
458 ++ mdelay(OPAL_BUSY_DELAY_MS);
459 + opal_poll_events(NULL);
460 +- else if (rc == OPAL_BUSY)
461 +- mdelay(10);
462 ++ } else if (rc == OPAL_BUSY) {
463 ++ mdelay(OPAL_BUSY_DELAY_MS);
464 ++ }
465 + }
466 + if (rc != OPAL_SUCCESS)
467 + return 0;
468 +diff --git a/arch/sparc/include/uapi/asm/oradax.h b/arch/sparc/include/uapi/asm/oradax.h
469 +index 722951908b0a..4f6676fe4bcc 100644
470 +--- a/arch/sparc/include/uapi/asm/oradax.h
471 ++++ b/arch/sparc/include/uapi/asm/oradax.h
472 +@@ -3,7 +3,7 @@
473 + *
474 + * This program is free software: you can redistribute it and/or modify
475 + * it under the terms of the GNU General Public License as published by
476 +- * the Free Software Foundation, either version 3 of the License, or
477 ++ * the Free Software Foundation, either version 2 of the License, or
478 + * (at your option) any later version.
479 + *
480 + * This program is distributed in the hope that it will be useful,
481 +diff --git a/arch/x86/include/uapi/asm/msgbuf.h b/arch/x86/include/uapi/asm/msgbuf.h
482 +index 809134c644a6..90ab9a795b49 100644
483 +--- a/arch/x86/include/uapi/asm/msgbuf.h
484 ++++ b/arch/x86/include/uapi/asm/msgbuf.h
485 +@@ -1 +1,32 @@
486 ++/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
487 ++#ifndef __ASM_X64_MSGBUF_H
488 ++#define __ASM_X64_MSGBUF_H
489 ++
490 ++#if !defined(__x86_64__) || !defined(__ILP32__)
491 + #include <asm-generic/msgbuf.h>
492 ++#else
493 ++/*
494 ++ * The msqid64_ds structure for x86 architecture with x32 ABI.
495 ++ *
496 ++ * On x86-32 and x86-64 we can just use the generic definition, but
497 ++ * x32 uses the same binary layout as x86_64, which is differnet
498 ++ * from other 32-bit architectures.
499 ++ */
500 ++
501 ++struct msqid64_ds {
502 ++ struct ipc64_perm msg_perm;
503 ++ __kernel_time_t msg_stime; /* last msgsnd time */
504 ++ __kernel_time_t msg_rtime; /* last msgrcv time */
505 ++ __kernel_time_t msg_ctime; /* last change time */
506 ++ __kernel_ulong_t msg_cbytes; /* current number of bytes on queue */
507 ++ __kernel_ulong_t msg_qnum; /* number of messages in queue */
508 ++ __kernel_ulong_t msg_qbytes; /* max number of bytes on queue */
509 ++ __kernel_pid_t msg_lspid; /* pid of last msgsnd */
510 ++ __kernel_pid_t msg_lrpid; /* last receive pid */
511 ++ __kernel_ulong_t __unused4;
512 ++ __kernel_ulong_t __unused5;
513 ++};
514 ++
515 ++#endif
516 ++
517 ++#endif /* __ASM_GENERIC_MSGBUF_H */
518 +diff --git a/arch/x86/include/uapi/asm/shmbuf.h b/arch/x86/include/uapi/asm/shmbuf.h
519 +index 83c05fc2de38..644421f3823b 100644
520 +--- a/arch/x86/include/uapi/asm/shmbuf.h
521 ++++ b/arch/x86/include/uapi/asm/shmbuf.h
522 +@@ -1 +1,43 @@
523 ++/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
524 ++#ifndef __ASM_X86_SHMBUF_H
525 ++#define __ASM_X86_SHMBUF_H
526 ++
527 ++#if !defined(__x86_64__) || !defined(__ILP32__)
528 + #include <asm-generic/shmbuf.h>
529 ++#else
530 ++/*
531 ++ * The shmid64_ds structure for x86 architecture with x32 ABI.
532 ++ *
533 ++ * On x86-32 and x86-64 we can just use the generic definition, but
534 ++ * x32 uses the same binary layout as x86_64, which is differnet
535 ++ * from other 32-bit architectures.
536 ++ */
537 ++
538 ++struct shmid64_ds {
539 ++ struct ipc64_perm shm_perm; /* operation perms */
540 ++ size_t shm_segsz; /* size of segment (bytes) */
541 ++ __kernel_time_t shm_atime; /* last attach time */
542 ++ __kernel_time_t shm_dtime; /* last detach time */
543 ++ __kernel_time_t shm_ctime; /* last change time */
544 ++ __kernel_pid_t shm_cpid; /* pid of creator */
545 ++ __kernel_pid_t shm_lpid; /* pid of last operator */
546 ++ __kernel_ulong_t shm_nattch; /* no. of current attaches */
547 ++ __kernel_ulong_t __unused4;
548 ++ __kernel_ulong_t __unused5;
549 ++};
550 ++
551 ++struct shminfo64 {
552 ++ __kernel_ulong_t shmmax;
553 ++ __kernel_ulong_t shmmin;
554 ++ __kernel_ulong_t shmmni;
555 ++ __kernel_ulong_t shmseg;
556 ++ __kernel_ulong_t shmall;
557 ++ __kernel_ulong_t __unused1;
558 ++ __kernel_ulong_t __unused2;
559 ++ __kernel_ulong_t __unused3;
560 ++ __kernel_ulong_t __unused4;
561 ++};
562 ++
563 ++#endif
564 ++
565 ++#endif /* __ASM_X86_SHMBUF_H */
566 +diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
567 +index 10c4fc2c91f8..77e201301528 100644
568 +--- a/arch/x86/kernel/cpu/microcode/core.c
569 ++++ b/arch/x86/kernel/cpu/microcode/core.c
570 +@@ -564,14 +564,12 @@ static int __reload_late(void *info)
571 + apply_microcode_local(&err);
572 + spin_unlock(&update_lock);
573 +
574 ++ /* siblings return UCODE_OK because their engine got updated already */
575 + if (err > UCODE_NFOUND) {
576 + pr_warn("Error reloading microcode on CPU %d\n", cpu);
577 +- return -1;
578 +- /* siblings return UCODE_OK because their engine got updated already */
579 ++ ret = -1;
580 + } else if (err == UCODE_UPDATED || err == UCODE_OK) {
581 + ret = 1;
582 +- } else {
583 +- return ret;
584 + }
585 +
586 + /*
587 +diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
588 +index 32b8e5724f96..1c2cfa0644aa 100644
589 +--- a/arch/x86/kernel/cpu/microcode/intel.c
590 ++++ b/arch/x86/kernel/cpu/microcode/intel.c
591 +@@ -485,7 +485,6 @@ static void show_saved_mc(void)
592 + */
593 + static void save_mc_for_early(u8 *mc, unsigned int size)
594 + {
595 +-#ifdef CONFIG_HOTPLUG_CPU
596 + /* Synchronization during CPU hotplug. */
597 + static DEFINE_MUTEX(x86_cpu_microcode_mutex);
598 +
599 +@@ -495,7 +494,6 @@ static void save_mc_for_early(u8 *mc, unsigned int size)
600 + show_saved_mc();
601 +
602 + mutex_unlock(&x86_cpu_microcode_mutex);
603 +-#endif
604 + }
605 +
606 + static bool load_builtin_intel_microcode(struct cpio_data *cp)
607 +diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
608 +index ff99e2b6fc54..12599e55e040 100644
609 +--- a/arch/x86/kernel/smpboot.c
610 ++++ b/arch/x86/kernel/smpboot.c
611 +@@ -1536,6 +1536,8 @@ static inline void mwait_play_dead(void)
612 + void *mwait_ptr;
613 + int i;
614 +
615 ++ if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
616 ++ return;
617 + if (!this_cpu_has(X86_FEATURE_MWAIT))
618 + return;
619 + if (!this_cpu_has(X86_FEATURE_CLFLUSH))
620 +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
621 +index aeca22d91101..3193b2663bed 100644
622 +--- a/block/bfq-iosched.c
623 ++++ b/block/bfq-iosched.c
624 +@@ -4911,8 +4911,16 @@ static void bfq_prepare_request(struct request *rq, struct bio *bio)
625 + bool new_queue = false;
626 + bool bfqq_already_existing = false, split = false;
627 +
628 +- if (!rq->elv.icq)
629 ++ /*
630 ++ * Even if we don't have an icq attached, we should still clear
631 ++ * the scheduler pointers, as they might point to previously
632 ++ * allocated bic/bfqq structs.
633 ++ */
634 ++ if (!rq->elv.icq) {
635 ++ rq->elv.priv[0] = rq->elv.priv[1] = NULL;
636 + return;
637 ++ }
638 ++
639 + bic = icq_to_bic(rq->elv.icq);
640 +
641 + spin_lock_irq(&bfqd->lock);
642 +diff --git a/block/blk-core.c b/block/blk-core.c
643 +index 3b489527c8f2..b459d277d170 100644
644 +--- a/block/blk-core.c
645 ++++ b/block/blk-core.c
646 +@@ -129,6 +129,10 @@ void blk_rq_init(struct request_queue *q, struct request *rq)
647 + rq->part = NULL;
648 + seqcount_init(&rq->gstate_seq);
649 + u64_stats_init(&rq->aborted_gstate_sync);
650 ++ /*
651 ++ * See comment of blk_mq_init_request
652 ++ */
653 ++ WRITE_ONCE(rq->gstate, MQ_RQ_GEN_INC);
654 + }
655 + EXPORT_SYMBOL(blk_rq_init);
656 +
657 +@@ -825,7 +829,6 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags)
658 +
659 + while (true) {
660 + bool success = false;
661 +- int ret;
662 +
663 + rcu_read_lock();
664 + if (percpu_ref_tryget_live(&q->q_usage_counter)) {
665 +@@ -857,14 +860,12 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags)
666 + */
667 + smp_rmb();
668 +
669 +- ret = wait_event_interruptible(q->mq_freeze_wq,
670 +- (atomic_read(&q->mq_freeze_depth) == 0 &&
671 +- (preempt || !blk_queue_preempt_only(q))) ||
672 +- blk_queue_dying(q));
673 ++ wait_event(q->mq_freeze_wq,
674 ++ (atomic_read(&q->mq_freeze_depth) == 0 &&
675 ++ (preempt || !blk_queue_preempt_only(q))) ||
676 ++ blk_queue_dying(q));
677 + if (blk_queue_dying(q))
678 + return -ENODEV;
679 +- if (ret)
680 +- return ret;
681 + }
682 + }
683 +
684 +diff --git a/block/blk-mq.c b/block/blk-mq.c
685 +index 56e0c3699f9e..96de7aa4f62a 100644
686 +--- a/block/blk-mq.c
687 ++++ b/block/blk-mq.c
688 +@@ -2076,6 +2076,13 @@ static int blk_mq_init_request(struct blk_mq_tag_set *set, struct request *rq,
689 +
690 + seqcount_init(&rq->gstate_seq);
691 + u64_stats_init(&rq->aborted_gstate_sync);
692 ++ /*
693 ++ * start gstate with gen 1 instead of 0, otherwise it will be equal
694 ++ * to aborted_gstate, and be identified timed out by
695 ++ * blk_mq_terminate_expired.
696 ++ */
697 ++ WRITE_ONCE(rq->gstate, MQ_RQ_GEN_INC);
698 ++
699 + return 0;
700 + }
701 +
702 +diff --git a/crypto/drbg.c b/crypto/drbg.c
703 +index 4faa2781c964..466a112a4446 100644
704 +--- a/crypto/drbg.c
705 ++++ b/crypto/drbg.c
706 +@@ -1134,8 +1134,10 @@ static inline void drbg_dealloc_state(struct drbg_state *drbg)
707 + if (!drbg)
708 + return;
709 + kzfree(drbg->Vbuf);
710 ++ drbg->Vbuf = NULL;
711 + drbg->V = NULL;
712 + kzfree(drbg->Cbuf);
713 ++ drbg->Cbuf = NULL;
714 + drbg->C = NULL;
715 + kzfree(drbg->scratchpadbuf);
716 + drbg->scratchpadbuf = NULL;
717 +diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
718 +index 594c228d2f02..4a3ac31c07d0 100644
719 +--- a/drivers/amba/bus.c
720 ++++ b/drivers/amba/bus.c
721 +@@ -69,11 +69,12 @@ static ssize_t driver_override_show(struct device *_dev,
722 + struct device_attribute *attr, char *buf)
723 + {
724 + struct amba_device *dev = to_amba_device(_dev);
725 ++ ssize_t len;
726 +
727 +- if (!dev->driver_override)
728 +- return 0;
729 +-
730 +- return sprintf(buf, "%s\n", dev->driver_override);
731 ++ device_lock(_dev);
732 ++ len = sprintf(buf, "%s\n", dev->driver_override);
733 ++ device_unlock(_dev);
734 ++ return len;
735 + }
736 +
737 + static ssize_t driver_override_store(struct device *_dev,
738 +@@ -81,9 +82,10 @@ static ssize_t driver_override_store(struct device *_dev,
739 + const char *buf, size_t count)
740 + {
741 + struct amba_device *dev = to_amba_device(_dev);
742 +- char *driver_override, *old = dev->driver_override, *cp;
743 ++ char *driver_override, *old, *cp;
744 +
745 +- if (count > PATH_MAX)
746 ++ /* We need to keep extra room for a newline */
747 ++ if (count >= (PAGE_SIZE - 1))
748 + return -EINVAL;
749 +
750 + driver_override = kstrndup(buf, count, GFP_KERNEL);
751 +@@ -94,12 +96,15 @@ static ssize_t driver_override_store(struct device *_dev,
752 + if (cp)
753 + *cp = '\0';
754 +
755 ++ device_lock(_dev);
756 ++ old = dev->driver_override;
757 + if (strlen(driver_override)) {
758 + dev->driver_override = driver_override;
759 + } else {
760 + kfree(driver_override);
761 + dev->driver_override = NULL;
762 + }
763 ++ device_unlock(_dev);
764 +
765 + kfree(old);
766 +
767 +diff --git a/drivers/android/binder.c b/drivers/android/binder.c
768 +index 764b63a5aade..e578eee31589 100644
769 +--- a/drivers/android/binder.c
770 ++++ b/drivers/android/binder.c
771 +@@ -2839,6 +2839,14 @@ static void binder_transaction(struct binder_proc *proc,
772 + else
773 + return_error = BR_DEAD_REPLY;
774 + mutex_unlock(&context->context_mgr_node_lock);
775 ++ if (target_node && target_proc == proc) {
776 ++ binder_user_error("%d:%d got transaction to context manager from process owning it\n",
777 ++ proc->pid, thread->pid);
778 ++ return_error = BR_FAILED_REPLY;
779 ++ return_error_param = -EINVAL;
780 ++ return_error_line = __LINE__;
781 ++ goto err_invalid_target_handle;
782 ++ }
783 + }
784 + if (!target_node) {
785 + /*
786 +diff --git a/drivers/char/random.c b/drivers/char/random.c
787 +index 38729baed6ee..8f4e11842c60 100644
788 +--- a/drivers/char/random.c
789 ++++ b/drivers/char/random.c
790 +@@ -261,6 +261,7 @@
791 + #include <linux/ptrace.h>
792 + #include <linux/workqueue.h>
793 + #include <linux/irq.h>
794 ++#include <linux/ratelimit.h>
795 + #include <linux/syscalls.h>
796 + #include <linux/completion.h>
797 + #include <linux/uuid.h>
798 +@@ -438,6 +439,16 @@ static void _crng_backtrack_protect(struct crng_state *crng,
799 + static void process_random_ready_list(void);
800 + static void _get_random_bytes(void *buf, int nbytes);
801 +
802 ++static struct ratelimit_state unseeded_warning =
803 ++ RATELIMIT_STATE_INIT("warn_unseeded_randomness", HZ, 3);
804 ++static struct ratelimit_state urandom_warning =
805 ++ RATELIMIT_STATE_INIT("warn_urandom_randomness", HZ, 3);
806 ++
807 ++static int ratelimit_disable __read_mostly;
808 ++
809 ++module_param_named(ratelimit_disable, ratelimit_disable, int, 0644);
810 ++MODULE_PARM_DESC(ratelimit_disable, "Disable random ratelimit suppression");
811 ++
812 + /**********************************************************************
813 + *
814 + * OS independent entropy store. Here are the functions which handle
815 +@@ -787,6 +798,39 @@ static void crng_initialize(struct crng_state *crng)
816 + crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
817 + }
818 +
819 ++#ifdef CONFIG_NUMA
820 ++static void do_numa_crng_init(struct work_struct *work)
821 ++{
822 ++ int i;
823 ++ struct crng_state *crng;
824 ++ struct crng_state **pool;
825 ++
826 ++ pool = kcalloc(nr_node_ids, sizeof(*pool), GFP_KERNEL|__GFP_NOFAIL);
827 ++ for_each_online_node(i) {
828 ++ crng = kmalloc_node(sizeof(struct crng_state),
829 ++ GFP_KERNEL | __GFP_NOFAIL, i);
830 ++ spin_lock_init(&crng->lock);
831 ++ crng_initialize(crng);
832 ++ pool[i] = crng;
833 ++ }
834 ++ mb();
835 ++ if (cmpxchg(&crng_node_pool, NULL, pool)) {
836 ++ for_each_node(i)
837 ++ kfree(pool[i]);
838 ++ kfree(pool);
839 ++ }
840 ++}
841 ++
842 ++static DECLARE_WORK(numa_crng_init_work, do_numa_crng_init);
843 ++
844 ++static void numa_crng_init(void)
845 ++{
846 ++ schedule_work(&numa_crng_init_work);
847 ++}
848 ++#else
849 ++static void numa_crng_init(void) {}
850 ++#endif
851 ++
852 + /*
853 + * crng_fast_load() can be called by code in the interrupt service
854 + * path. So we can't afford to dilly-dally.
855 +@@ -893,10 +937,23 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
856 + spin_unlock_irqrestore(&crng->lock, flags);
857 + if (crng == &primary_crng && crng_init < 2) {
858 + invalidate_batched_entropy();
859 ++ numa_crng_init();
860 + crng_init = 2;
861 + process_random_ready_list();
862 + wake_up_interruptible(&crng_init_wait);
863 + pr_notice("random: crng init done\n");
864 ++ if (unseeded_warning.missed) {
865 ++ pr_notice("random: %d get_random_xx warning(s) missed "
866 ++ "due to ratelimiting\n",
867 ++ unseeded_warning.missed);
868 ++ unseeded_warning.missed = 0;
869 ++ }
870 ++ if (urandom_warning.missed) {
871 ++ pr_notice("random: %d urandom warning(s) missed "
872 ++ "due to ratelimiting\n",
873 ++ urandom_warning.missed);
874 ++ urandom_warning.missed = 0;
875 ++ }
876 + }
877 + }
878 +
879 +@@ -1540,8 +1597,9 @@ static void _warn_unseeded_randomness(const char *func_name, void *caller,
880 + #ifndef CONFIG_WARN_ALL_UNSEEDED_RANDOM
881 + print_once = true;
882 + #endif
883 +- pr_notice("random: %s called from %pS with crng_init=%d\n",
884 +- func_name, caller, crng_init);
885 ++ if (__ratelimit(&unseeded_warning))
886 ++ pr_notice("random: %s called from %pS with crng_init=%d\n",
887 ++ func_name, caller, crng_init);
888 + }
889 +
890 + /*
891 +@@ -1731,29 +1789,14 @@ static void init_std_data(struct entropy_store *r)
892 + */
893 + static int rand_initialize(void)
894 + {
895 +-#ifdef CONFIG_NUMA
896 +- int i;
897 +- struct crng_state *crng;
898 +- struct crng_state **pool;
899 +-#endif
900 +-
901 + init_std_data(&input_pool);
902 + init_std_data(&blocking_pool);
903 + crng_initialize(&primary_crng);
904 + crng_global_init_time = jiffies;
905 +-
906 +-#ifdef CONFIG_NUMA
907 +- pool = kcalloc(nr_node_ids, sizeof(*pool), GFP_KERNEL|__GFP_NOFAIL);
908 +- for_each_online_node(i) {
909 +- crng = kmalloc_node(sizeof(struct crng_state),
910 +- GFP_KERNEL | __GFP_NOFAIL, i);
911 +- spin_lock_init(&crng->lock);
912 +- crng_initialize(crng);
913 +- pool[i] = crng;
914 ++ if (ratelimit_disable) {
915 ++ urandom_warning.interval = 0;
916 ++ unseeded_warning.interval = 0;
917 + }
918 +- mb();
919 +- crng_node_pool = pool;
920 +-#endif
921 + return 0;
922 + }
923 + early_initcall(rand_initialize);
924 +@@ -1821,9 +1864,10 @@ urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
925 +
926 + if (!crng_ready() && maxwarn > 0) {
927 + maxwarn--;
928 +- printk(KERN_NOTICE "random: %s: uninitialized urandom read "
929 +- "(%zd bytes read)\n",
930 +- current->comm, nbytes);
931 ++ if (__ratelimit(&urandom_warning))
932 ++ printk(KERN_NOTICE "random: %s: uninitialized "
933 ++ "urandom read (%zd bytes read)\n",
934 ++ current->comm, nbytes);
935 + spin_lock_irqsave(&primary_crng.lock, flags);
936 + crng_init_cnt = 0;
937 + spin_unlock_irqrestore(&primary_crng.lock, flags);
938 +diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
939 +index 468f06134012..21085515814f 100644
940 +--- a/drivers/char/virtio_console.c
941 ++++ b/drivers/char/virtio_console.c
942 +@@ -422,7 +422,7 @@ static void reclaim_dma_bufs(void)
943 + }
944 + }
945 +
946 +-static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size,
947 ++static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size,
948 + int pages)
949 + {
950 + struct port_buffer *buf;
951 +@@ -445,16 +445,16 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size,
952 + return buf;
953 + }
954 +
955 +- if (is_rproc_serial(vq->vdev)) {
956 ++ if (is_rproc_serial(vdev)) {
957 + /*
958 + * Allocate DMA memory from ancestor. When a virtio
959 + * device is created by remoteproc, the DMA memory is
960 + * associated with the grandparent device:
961 + * vdev => rproc => platform-dev.
962 + */
963 +- if (!vq->vdev->dev.parent || !vq->vdev->dev.parent->parent)
964 ++ if (!vdev->dev.parent || !vdev->dev.parent->parent)
965 + goto free_buf;
966 +- buf->dev = vq->vdev->dev.parent->parent;
967 ++ buf->dev = vdev->dev.parent->parent;
968 +
969 + /* Increase device refcnt to avoid freeing it */
970 + get_device(buf->dev);
971 +@@ -838,7 +838,7 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,
972 +
973 + count = min((size_t)(32 * 1024), count);
974 +
975 +- buf = alloc_buf(port->out_vq, count, 0);
976 ++ buf = alloc_buf(port->portdev->vdev, count, 0);
977 + if (!buf)
978 + return -ENOMEM;
979 +
980 +@@ -957,7 +957,7 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
981 + if (ret < 0)
982 + goto error_out;
983 +
984 +- buf = alloc_buf(port->out_vq, 0, pipe->nrbufs);
985 ++ buf = alloc_buf(port->portdev->vdev, 0, pipe->nrbufs);
986 + if (!buf) {
987 + ret = -ENOMEM;
988 + goto error_out;
989 +@@ -1374,7 +1374,7 @@ static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
990 +
991 + nr_added_bufs = 0;
992 + do {
993 +- buf = alloc_buf(vq, PAGE_SIZE, 0);
994 ++ buf = alloc_buf(vq->vdev, PAGE_SIZE, 0);
995 + if (!buf)
996 + break;
997 +
998 +@@ -1402,7 +1402,6 @@ static int add_port(struct ports_device *portdev, u32 id)
999 + {
1000 + char debugfs_name[16];
1001 + struct port *port;
1002 +- struct port_buffer *buf;
1003 + dev_t devt;
1004 + unsigned int nr_added_bufs;
1005 + int err;
1006 +@@ -1513,8 +1512,6 @@ static int add_port(struct ports_device *portdev, u32 id)
1007 + return 0;
1008 +
1009 + free_inbufs:
1010 +- while ((buf = virtqueue_detach_unused_buf(port->in_vq)))
1011 +- free_buf(buf, true);
1012 + free_device:
1013 + device_destroy(pdrvdata.class, port->dev->devt);
1014 + free_cdev:
1015 +@@ -1539,34 +1536,14 @@ static void remove_port(struct kref *kref)
1016 +
1017 + static void remove_port_data(struct port *port)
1018 + {
1019 +- struct port_buffer *buf;
1020 +-
1021 + spin_lock_irq(&port->inbuf_lock);
1022 + /* Remove unused data this port might have received. */
1023 + discard_port_data(port);
1024 + spin_unlock_irq(&port->inbuf_lock);
1025 +
1026 +- /* Remove buffers we queued up for the Host to send us data in. */
1027 +- do {
1028 +- spin_lock_irq(&port->inbuf_lock);
1029 +- buf = virtqueue_detach_unused_buf(port->in_vq);
1030 +- spin_unlock_irq(&port->inbuf_lock);
1031 +- if (buf)
1032 +- free_buf(buf, true);
1033 +- } while (buf);
1034 +-
1035 + spin_lock_irq(&port->outvq_lock);
1036 + reclaim_consumed_buffers(port);
1037 + spin_unlock_irq(&port->outvq_lock);
1038 +-
1039 +- /* Free pending buffers from the out-queue. */
1040 +- do {
1041 +- spin_lock_irq(&port->outvq_lock);
1042 +- buf = virtqueue_detach_unused_buf(port->out_vq);
1043 +- spin_unlock_irq(&port->outvq_lock);
1044 +- if (buf)
1045 +- free_buf(buf, true);
1046 +- } while (buf);
1047 + }
1048 +
1049 + /*
1050 +@@ -1791,13 +1768,24 @@ static void control_work_handler(struct work_struct *work)
1051 + spin_unlock(&portdev->c_ivq_lock);
1052 + }
1053 +
1054 ++static void flush_bufs(struct virtqueue *vq, bool can_sleep)
1055 ++{
1056 ++ struct port_buffer *buf;
1057 ++ unsigned int len;
1058 ++
1059 ++ while ((buf = virtqueue_get_buf(vq, &len)))
1060 ++ free_buf(buf, can_sleep);
1061 ++}
1062 ++
1063 + static void out_intr(struct virtqueue *vq)
1064 + {
1065 + struct port *port;
1066 +
1067 + port = find_port_by_vq(vq->vdev->priv, vq);
1068 +- if (!port)
1069 ++ if (!port) {
1070 ++ flush_bufs(vq, false);
1071 + return;
1072 ++ }
1073 +
1074 + wake_up_interruptible(&port->waitqueue);
1075 + }
1076 +@@ -1808,8 +1796,10 @@ static void in_intr(struct virtqueue *vq)
1077 + unsigned long flags;
1078 +
1079 + port = find_port_by_vq(vq->vdev->priv, vq);
1080 +- if (!port)
1081 ++ if (!port) {
1082 ++ flush_bufs(vq, false);
1083 + return;
1084 ++ }
1085 +
1086 + spin_lock_irqsave(&port->inbuf_lock, flags);
1087 + port->inbuf = get_inbuf(port);
1088 +@@ -1984,24 +1974,54 @@ static const struct file_operations portdev_fops = {
1089 +
1090 + static void remove_vqs(struct ports_device *portdev)
1091 + {
1092 ++ struct virtqueue *vq;
1093 ++
1094 ++ virtio_device_for_each_vq(portdev->vdev, vq) {
1095 ++ struct port_buffer *buf;
1096 ++
1097 ++ flush_bufs(vq, true);
1098 ++ while ((buf = virtqueue_detach_unused_buf(vq)))
1099 ++ free_buf(buf, true);
1100 ++ }
1101 + portdev->vdev->config->del_vqs(portdev->vdev);
1102 + kfree(portdev->in_vqs);
1103 + kfree(portdev->out_vqs);
1104 + }
1105 +
1106 +-static void remove_controlq_data(struct ports_device *portdev)
1107 ++static void virtcons_remove(struct virtio_device *vdev)
1108 + {
1109 +- struct port_buffer *buf;
1110 +- unsigned int len;
1111 ++ struct ports_device *portdev;
1112 ++ struct port *port, *port2;
1113 +
1114 +- if (!use_multiport(portdev))
1115 +- return;
1116 ++ portdev = vdev->priv;
1117 +
1118 +- while ((buf = virtqueue_get_buf(portdev->c_ivq, &len)))
1119 +- free_buf(buf, true);
1120 ++ spin_lock_irq(&pdrvdata_lock);
1121 ++ list_del(&portdev->list);
1122 ++ spin_unlock_irq(&pdrvdata_lock);
1123 +
1124 +- while ((buf = virtqueue_detach_unused_buf(portdev->c_ivq)))
1125 +- free_buf(buf, true);
1126 ++ /* Disable interrupts for vqs */
1127 ++ vdev->config->reset(vdev);
1128 ++ /* Finish up work that's lined up */
1129 ++ if (use_multiport(portdev))
1130 ++ cancel_work_sync(&portdev->control_work);
1131 ++ else
1132 ++ cancel_work_sync(&portdev->config_work);
1133 ++
1134 ++ list_for_each_entry_safe(port, port2, &portdev->ports, list)
1135 ++ unplug_port(port);
1136 ++
1137 ++ unregister_chrdev(portdev->chr_major, "virtio-portsdev");
1138 ++
1139 ++ /*
1140 ++ * When yanking out a device, we immediately lose the
1141 ++ * (device-side) queues. So there's no point in keeping the
1142 ++ * guest side around till we drop our final reference. This
1143 ++ * also means that any ports which are in an open state will
1144 ++ * have to just stop using the port, as the vqs are going
1145 ++ * away.
1146 ++ */
1147 ++ remove_vqs(portdev);
1148 ++ kfree(portdev);
1149 + }
1150 +
1151 + /*
1152 +@@ -2070,6 +2090,7 @@ static int virtcons_probe(struct virtio_device *vdev)
1153 +
1154 + spin_lock_init(&portdev->ports_lock);
1155 + INIT_LIST_HEAD(&portdev->ports);
1156 ++ INIT_LIST_HEAD(&portdev->list);
1157 +
1158 + virtio_device_ready(portdev->vdev);
1159 +
1160 +@@ -2087,8 +2108,15 @@ static int virtcons_probe(struct virtio_device *vdev)
1161 + if (!nr_added_bufs) {
1162 + dev_err(&vdev->dev,
1163 + "Error allocating buffers for control queue\n");
1164 +- err = -ENOMEM;
1165 +- goto free_vqs;
1166 ++ /*
1167 ++ * The host might want to notify mgmt sw about device
1168 ++ * add failure.
1169 ++ */
1170 ++ __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID,
1171 ++ VIRTIO_CONSOLE_DEVICE_READY, 0);
1172 ++ /* Device was functional: we need full cleanup. */
1173 ++ virtcons_remove(vdev);
1174 ++ return -ENOMEM;
1175 + }
1176 + } else {
1177 + /*
1178 +@@ -2119,11 +2147,6 @@ static int virtcons_probe(struct virtio_device *vdev)
1179 +
1180 + return 0;
1181 +
1182 +-free_vqs:
1183 +- /* The host might want to notify mgmt sw about device add failure */
1184 +- __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID,
1185 +- VIRTIO_CONSOLE_DEVICE_READY, 0);
1186 +- remove_vqs(portdev);
1187 + free_chrdev:
1188 + unregister_chrdev(portdev->chr_major, "virtio-portsdev");
1189 + free:
1190 +@@ -2132,43 +2155,6 @@ static int virtcons_probe(struct virtio_device *vdev)
1191 + return err;
1192 + }
1193 +
1194 +-static void virtcons_remove(struct virtio_device *vdev)
1195 +-{
1196 +- struct ports_device *portdev;
1197 +- struct port *port, *port2;
1198 +-
1199 +- portdev = vdev->priv;
1200 +-
1201 +- spin_lock_irq(&pdrvdata_lock);
1202 +- list_del(&portdev->list);
1203 +- spin_unlock_irq(&pdrvdata_lock);
1204 +-
1205 +- /* Disable interrupts for vqs */
1206 +- vdev->config->reset(vdev);
1207 +- /* Finish up work that's lined up */
1208 +- if (use_multiport(portdev))
1209 +- cancel_work_sync(&portdev->control_work);
1210 +- else
1211 +- cancel_work_sync(&portdev->config_work);
1212 +-
1213 +- list_for_each_entry_safe(port, port2, &portdev->ports, list)
1214 +- unplug_port(port);
1215 +-
1216 +- unregister_chrdev(portdev->chr_major, "virtio-portsdev");
1217 +-
1218 +- /*
1219 +- * When yanking out a device, we immediately lose the
1220 +- * (device-side) queues. So there's no point in keeping the
1221 +- * guest side around till we drop our final reference. This
1222 +- * also means that any ports which are in an open state will
1223 +- * have to just stop using the port, as the vqs are going
1224 +- * away.
1225 +- */
1226 +- remove_controlq_data(portdev);
1227 +- remove_vqs(portdev);
1228 +- kfree(portdev);
1229 +-}
1230 +-
1231 + static struct virtio_device_id id_table[] = {
1232 + { VIRTIO_ID_CONSOLE, VIRTIO_DEV_ANY_ID },
1233 + { 0 },
1234 +@@ -2209,7 +2195,6 @@ static int virtcons_freeze(struct virtio_device *vdev)
1235 + */
1236 + if (use_multiport(portdev))
1237 + virtqueue_disable_cb(portdev->c_ivq);
1238 +- remove_controlq_data(portdev);
1239 +
1240 + list_for_each_entry(port, &portdev->ports, list) {
1241 + virtqueue_disable_cb(port->in_vq);
1242 +diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
1243 +index 29cdec198657..422e1fc38b43 100644
1244 +--- a/drivers/cpufreq/powernv-cpufreq.c
1245 ++++ b/drivers/cpufreq/powernv-cpufreq.c
1246 +@@ -679,6 +679,16 @@ void gpstate_timer_handler(struct timer_list *t)
1247 +
1248 + if (!spin_trylock(&gpstates->gpstate_lock))
1249 + return;
1250 ++ /*
1251 ++ * If the timer has migrated to the different cpu then bring
1252 ++ * it back to one of the policy->cpus
1253 ++ */
1254 ++ if (!cpumask_test_cpu(raw_smp_processor_id(), policy->cpus)) {
1255 ++ gpstates->timer.expires = jiffies + msecs_to_jiffies(1);
1256 ++ add_timer_on(&gpstates->timer, cpumask_first(policy->cpus));
1257 ++ spin_unlock(&gpstates->gpstate_lock);
1258 ++ return;
1259 ++ }
1260 +
1261 + /*
1262 + * If PMCR was last updated was using fast_swtich then
1263 +@@ -718,10 +728,8 @@ void gpstate_timer_handler(struct timer_list *t)
1264 + if (gpstate_idx != gpstates->last_lpstate_idx)
1265 + queue_gpstate_timer(gpstates);
1266 +
1267 ++ set_pstate(&freq_data);
1268 + spin_unlock(&gpstates->gpstate_lock);
1269 +-
1270 +- /* Timer may get migrated to a different cpu on cpu hot unplug */
1271 +- smp_call_function_any(policy->cpus, set_pstate, &freq_data, 1);
1272 + }
1273 +
1274 + /*
1275 +diff --git a/drivers/crypto/ccp/sp-dev.c b/drivers/crypto/ccp/sp-dev.c
1276 +index eb0da6572720..e0459002eb71 100644
1277 +--- a/drivers/crypto/ccp/sp-dev.c
1278 ++++ b/drivers/crypto/ccp/sp-dev.c
1279 +@@ -252,12 +252,12 @@ struct sp_device *sp_get_psp_master_device(void)
1280 + goto unlock;
1281 +
1282 + list_for_each_entry(i, &sp_units, entry) {
1283 +- if (i->psp_data)
1284 ++ if (i->psp_data && i->get_psp_master_device) {
1285 ++ ret = i->get_psp_master_device();
1286 + break;
1287 ++ }
1288 + }
1289 +
1290 +- if (i->get_psp_master_device)
1291 +- ret = i->get_psp_master_device();
1292 + unlock:
1293 + write_unlock_irqrestore(&sp_unit_lock, flags);
1294 + return ret;
1295 +diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c
1296 +index 14f14efdf0d5..06d212a3d49d 100644
1297 +--- a/drivers/fpga/altera-ps-spi.c
1298 ++++ b/drivers/fpga/altera-ps-spi.c
1299 +@@ -249,7 +249,7 @@ static int altera_ps_probe(struct spi_device *spi)
1300 +
1301 + conf->data = of_id->data;
1302 + conf->spi = spi;
1303 +- conf->config = devm_gpiod_get(&spi->dev, "nconfig", GPIOD_OUT_HIGH);
1304 ++ conf->config = devm_gpiod_get(&spi->dev, "nconfig", GPIOD_OUT_LOW);
1305 + if (IS_ERR(conf->config)) {
1306 + dev_err(&spi->dev, "Failed to get config gpio: %ld\n",
1307 + PTR_ERR(conf->config));
1308 +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
1309 +index 4e694ae9f308..45cc4d572897 100644
1310 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
1311 ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
1312 +@@ -1459,10 +1459,11 @@ static const u32 sgpr_init_compute_shader[] =
1313 + static const u32 vgpr_init_regs[] =
1314 + {
1315 + mmCOMPUTE_STATIC_THREAD_MGMT_SE0, 0xffffffff,
1316 +- mmCOMPUTE_RESOURCE_LIMITS, 0,
1317 ++ mmCOMPUTE_RESOURCE_LIMITS, 0x1000000, /* CU_GROUP_COUNT=1 */
1318 + mmCOMPUTE_NUM_THREAD_X, 256*4,
1319 + mmCOMPUTE_NUM_THREAD_Y, 1,
1320 + mmCOMPUTE_NUM_THREAD_Z, 1,
1321 ++ mmCOMPUTE_PGM_RSRC1, 0x100004f, /* VGPRS=15 (64 logical VGPRs), SGPRS=1 (16 SGPRs), BULKY=1 */
1322 + mmCOMPUTE_PGM_RSRC2, 20,
1323 + mmCOMPUTE_USER_DATA_0, 0xedcedc00,
1324 + mmCOMPUTE_USER_DATA_1, 0xedcedc01,
1325 +@@ -1479,10 +1480,11 @@ static const u32 vgpr_init_regs[] =
1326 + static const u32 sgpr1_init_regs[] =
1327 + {
1328 + mmCOMPUTE_STATIC_THREAD_MGMT_SE0, 0x0f,
1329 +- mmCOMPUTE_RESOURCE_LIMITS, 0x1000000,
1330 ++ mmCOMPUTE_RESOURCE_LIMITS, 0x1000000, /* CU_GROUP_COUNT=1 */
1331 + mmCOMPUTE_NUM_THREAD_X, 256*5,
1332 + mmCOMPUTE_NUM_THREAD_Y, 1,
1333 + mmCOMPUTE_NUM_THREAD_Z, 1,
1334 ++ mmCOMPUTE_PGM_RSRC1, 0x240, /* SGPRS=9 (80 GPRS) */
1335 + mmCOMPUTE_PGM_RSRC2, 20,
1336 + mmCOMPUTE_USER_DATA_0, 0xedcedc00,
1337 + mmCOMPUTE_USER_DATA_1, 0xedcedc01,
1338 +@@ -1503,6 +1505,7 @@ static const u32 sgpr2_init_regs[] =
1339 + mmCOMPUTE_NUM_THREAD_X, 256*5,
1340 + mmCOMPUTE_NUM_THREAD_Y, 1,
1341 + mmCOMPUTE_NUM_THREAD_Z, 1,
1342 ++ mmCOMPUTE_PGM_RSRC1, 0x240, /* SGPRS=9 (80 GPRS) */
1343 + mmCOMPUTE_PGM_RSRC2, 20,
1344 + mmCOMPUTE_USER_DATA_0, 0xedcedc00,
1345 + mmCOMPUTE_USER_DATA_1, 0xedcedc01,
1346 +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
1347 +index 8a6e6fbc78cd..2e94881d4f7f 100644
1348 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
1349 ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
1350 +@@ -4506,6 +4506,7 @@ static int dm_update_crtcs_state(struct dc *dc,
1351 + struct amdgpu_dm_connector *aconnector = NULL;
1352 + struct drm_connector_state *new_con_state = NULL;
1353 + struct dm_connector_state *dm_conn_state = NULL;
1354 ++ struct drm_plane_state *new_plane_state = NULL;
1355 +
1356 + new_stream = NULL;
1357 +
1358 +@@ -4513,6 +4514,13 @@ static int dm_update_crtcs_state(struct dc *dc,
1359 + dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
1360 + acrtc = to_amdgpu_crtc(crtc);
1361 +
1362 ++ new_plane_state = drm_atomic_get_new_plane_state(state, new_crtc_state->crtc->primary);
1363 ++
1364 ++ if (new_crtc_state->enable && new_plane_state && !new_plane_state->fb) {
1365 ++ ret = -EINVAL;
1366 ++ goto fail;
1367 ++ }
1368 ++
1369 + aconnector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc);
1370 +
1371 + /* TODO This hack should go away */
1372 +@@ -4685,7 +4693,7 @@ static int dm_update_planes_state(struct dc *dc,
1373 + if (!dm_old_crtc_state->stream)
1374 + continue;
1375 +
1376 +- DRM_DEBUG_DRIVER("Disabling DRM plane: %d on DRM crtc %d\n",
1377 ++ DRM_DEBUG_ATOMIC("Disabling DRM plane: %d on DRM crtc %d\n",
1378 + plane->base.id, old_plane_crtc->base.id);
1379 +
1380 + if (!dc_remove_plane_from_context(
1381 +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
1382 +index 422055080df4..54a25fb048fb 100644
1383 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
1384 ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
1385 +@@ -400,14 +400,15 @@ void amdgpu_dm_irq_fini(struct amdgpu_device *adev)
1386 + {
1387 + int src;
1388 + struct irq_list_head *lh;
1389 ++ unsigned long irq_table_flags;
1390 + DRM_DEBUG_KMS("DM_IRQ: releasing resources.\n");
1391 +-
1392 + for (src = 0; src < DAL_IRQ_SOURCES_NUMBER; src++) {
1393 +-
1394 ++ DM_IRQ_TABLE_LOCK(adev, irq_table_flags);
1395 + /* The handler was removed from the table,
1396 + * it means it is safe to flush all the 'work'
1397 + * (because no code can schedule a new one). */
1398 + lh = &adev->dm.irq_handler_list_low_tab[src];
1399 ++ DM_IRQ_TABLE_UNLOCK(adev, irq_table_flags);
1400 + flush_work(&lh->work);
1401 + }
1402 +
1403 +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
1404 +index 93421dad21bd..160933c16461 100644
1405 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
1406 ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
1407 +@@ -157,6 +157,11 @@ dm_dp_mst_connector_destroy(struct drm_connector *connector)
1408 + struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector);
1409 + struct amdgpu_encoder *amdgpu_encoder = amdgpu_dm_connector->mst_encoder;
1410 +
1411 ++ if (amdgpu_dm_connector->edid) {
1412 ++ kfree(amdgpu_dm_connector->edid);
1413 ++ amdgpu_dm_connector->edid = NULL;
1414 ++ }
1415 ++
1416 + drm_encoder_cleanup(&amdgpu_encoder->base);
1417 + kfree(amdgpu_encoder);
1418 + drm_connector_cleanup(connector);
1419 +@@ -183,28 +188,22 @@ static int dm_connector_update_modes(struct drm_connector *connector,
1420 + void dm_dp_mst_dc_sink_create(struct drm_connector *connector)
1421 + {
1422 + struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
1423 +- struct edid *edid;
1424 + struct dc_sink *dc_sink;
1425 + struct dc_sink_init_data init_params = {
1426 + .link = aconnector->dc_link,
1427 + .sink_signal = SIGNAL_TYPE_DISPLAY_PORT_MST };
1428 +
1429 ++ /* FIXME none of this is safe. we shouldn't touch aconnector here in
1430 ++ * atomic_check
1431 ++ */
1432 ++
1433 + /*
1434 + * TODO: Need to further figure out why ddc.algo is NULL while MST port exists
1435 + */
1436 + if (!aconnector->port || !aconnector->port->aux.ddc.algo)
1437 + return;
1438 +
1439 +- edid = drm_dp_mst_get_edid(connector, &aconnector->mst_port->mst_mgr, aconnector->port);
1440 +-
1441 +- if (!edid) {
1442 +- drm_mode_connector_update_edid_property(
1443 +- &aconnector->base,
1444 +- NULL);
1445 +- return;
1446 +- }
1447 +-
1448 +- aconnector->edid = edid;
1449 ++ ASSERT(aconnector->edid);
1450 +
1451 + dc_sink = dc_link_add_remote_sink(
1452 + aconnector->dc_link,
1453 +@@ -217,9 +216,6 @@ void dm_dp_mst_dc_sink_create(struct drm_connector *connector)
1454 +
1455 + amdgpu_dm_add_sink_to_freesync_module(
1456 + connector, aconnector->edid);
1457 +-
1458 +- drm_mode_connector_update_edid_property(
1459 +- &aconnector->base, aconnector->edid);
1460 + }
1461 +
1462 + static int dm_dp_mst_get_modes(struct drm_connector *connector)
1463 +@@ -426,14 +422,6 @@ static void dm_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
1464 + dc_sink_release(aconnector->dc_sink);
1465 + aconnector->dc_sink = NULL;
1466 + }
1467 +- if (aconnector->edid) {
1468 +- kfree(aconnector->edid);
1469 +- aconnector->edid = NULL;
1470 +- }
1471 +-
1472 +- drm_mode_connector_update_edid_property(
1473 +- &aconnector->base,
1474 +- NULL);
1475 +
1476 + aconnector->mst_connected = false;
1477 + }
1478 +diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
1479 +index 4f751a9d71a3..2368ad0b3f4d 100644
1480 +--- a/drivers/gpu/drm/drm_edid.c
1481 ++++ b/drivers/gpu/drm/drm_edid.c
1482 +@@ -4450,6 +4450,7 @@ drm_reset_display_info(struct drm_connector *connector)
1483 + info->max_tmds_clock = 0;
1484 + info->dvi_dual = false;
1485 + info->has_hdmi_infoframe = false;
1486 ++ memset(&info->hdmi, 0, sizeof(info->hdmi));
1487 +
1488 + info->non_desktop = 0;
1489 + }
1490 +@@ -4461,17 +4462,11 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
1491 +
1492 + u32 quirks = edid_get_quirks(edid);
1493 +
1494 ++ drm_reset_display_info(connector);
1495 ++
1496 + info->width_mm = edid->width_cm * 10;
1497 + info->height_mm = edid->height_cm * 10;
1498 +
1499 +- /* driver figures it out in this case */
1500 +- info->bpc = 0;
1501 +- info->color_formats = 0;
1502 +- info->cea_rev = 0;
1503 +- info->max_tmds_clock = 0;
1504 +- info->dvi_dual = false;
1505 +- info->has_hdmi_infoframe = false;
1506 +-
1507 + info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
1508 +
1509 + DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
1510 +diff --git a/drivers/gpu/drm/i915/intel_cdclk.c b/drivers/gpu/drm/i915/intel_cdclk.c
1511 +index 1704c8897afd..fd58647fbff3 100644
1512 +--- a/drivers/gpu/drm/i915/intel_cdclk.c
1513 ++++ b/drivers/gpu/drm/i915/intel_cdclk.c
1514 +@@ -1946,10 +1946,22 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state)
1515 + }
1516 + }
1517 +
1518 +- /* According to BSpec, "The CD clock frequency must be at least twice
1519 ++ /*
1520 ++ * According to BSpec, "The CD clock frequency must be at least twice
1521 + * the frequency of the Azalia BCLK." and BCLK is 96 MHz by default.
1522 ++ *
1523 ++ * FIXME: Check the actual, not default, BCLK being used.
1524 ++ *
1525 ++ * FIXME: This does not depend on ->has_audio because the higher CDCLK
1526 ++ * is required for audio probe, also when there are no audio capable
1527 ++ * displays connected at probe time. This leads to unnecessarily high
1528 ++ * CDCLK when audio is not required.
1529 ++ *
1530 ++ * FIXME: This limit is only applied when there are displays connected
1531 ++ * at probe time. If we probe without displays, we'll still end up using
1532 ++ * the platform minimum CDCLK, failing audio probe.
1533 + */
1534 +- if (crtc_state->has_audio && INTEL_GEN(dev_priv) >= 9)
1535 ++ if (INTEL_GEN(dev_priv) >= 9)
1536 + min_cdclk = max(2 * 96000, min_cdclk);
1537 +
1538 + /*
1539 +diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
1540 +index da48af11eb6b..0cf33034a8ba 100644
1541 +--- a/drivers/gpu/drm/i915/intel_fbdev.c
1542 ++++ b/drivers/gpu/drm/i915/intel_fbdev.c
1543 +@@ -801,7 +801,7 @@ void intel_fbdev_output_poll_changed(struct drm_device *dev)
1544 + return;
1545 +
1546 + intel_fbdev_sync(ifbdev);
1547 +- if (ifbdev->vma)
1548 ++ if (ifbdev->vma || ifbdev->helper.deferred_setup)
1549 + drm_fb_helper_hotplug_event(&ifbdev->helper);
1550 + }
1551 +
1552 +diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c
1553 +index d758da6156a8..9faee4875ddf 100644
1554 +--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
1555 ++++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
1556 +@@ -624,19 +624,18 @@ void skl_enable_dc6(struct drm_i915_private *dev_priv)
1557 +
1558 + DRM_DEBUG_KMS("Enabling DC6\n");
1559 +
1560 +- gen9_set_dc_state(dev_priv, DC_STATE_EN_UPTO_DC6);
1561 ++ /* Wa Display #1183: skl,kbl,cfl */
1562 ++ if (IS_GEN9_BC(dev_priv))
1563 ++ I915_WRITE(GEN8_CHICKEN_DCPR_1, I915_READ(GEN8_CHICKEN_DCPR_1) |
1564 ++ SKL_SELECT_ALTERNATE_DC_EXIT);
1565 +
1566 ++ gen9_set_dc_state(dev_priv, DC_STATE_EN_UPTO_DC6);
1567 + }
1568 +
1569 + void skl_disable_dc6(struct drm_i915_private *dev_priv)
1570 + {
1571 + DRM_DEBUG_KMS("Disabling DC6\n");
1572 +
1573 +- /* Wa Display #1183: skl,kbl,cfl */
1574 +- if (IS_GEN9_BC(dev_priv))
1575 +- I915_WRITE(GEN8_CHICKEN_DCPR_1, I915_READ(GEN8_CHICKEN_DCPR_1) |
1576 +- SKL_SELECT_ALTERNATE_DC_EXIT);
1577 +-
1578 + gen9_set_dc_state(dev_priv, DC_STATE_DISABLE);
1579 + }
1580 +
1581 +diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
1582 +index 9eb96fb2c147..26a2da1f712d 100644
1583 +--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
1584 ++++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
1585 +@@ -291,7 +291,7 @@ static int virtio_gpu_queue_ctrl_buffer_locked(struct virtio_gpu_device *vgdev,
1586 + ret = virtqueue_add_sgs(vq, sgs, outcnt, incnt, vbuf, GFP_ATOMIC);
1587 + if (ret == -ENOSPC) {
1588 + spin_unlock(&vgdev->ctrlq.qlock);
1589 +- wait_event(vgdev->ctrlq.ack_queue, vq->num_free);
1590 ++ wait_event(vgdev->ctrlq.ack_queue, vq->num_free >= outcnt + incnt);
1591 + spin_lock(&vgdev->ctrlq.qlock);
1592 + goto retry;
1593 + } else {
1594 +@@ -366,7 +366,7 @@ static int virtio_gpu_queue_cursor(struct virtio_gpu_device *vgdev,
1595 + ret = virtqueue_add_sgs(vq, sgs, outcnt, 0, vbuf, GFP_ATOMIC);
1596 + if (ret == -ENOSPC) {
1597 + spin_unlock(&vgdev->cursorq.qlock);
1598 +- wait_event(vgdev->cursorq.ack_queue, vq->num_free);
1599 ++ wait_event(vgdev->cursorq.ack_queue, vq->num_free >= outcnt);
1600 + spin_lock(&vgdev->cursorq.qlock);
1601 + goto retry;
1602 + } else {
1603 +diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
1604 +index 5e1b68cbcd0a..e1b603ca0170 100644
1605 +--- a/drivers/mtd/chips/cfi_cmdset_0001.c
1606 ++++ b/drivers/mtd/chips/cfi_cmdset_0001.c
1607 +@@ -45,6 +45,7 @@
1608 + #define I82802AB 0x00ad
1609 + #define I82802AC 0x00ac
1610 + #define PF38F4476 0x881c
1611 ++#define M28F00AP30 0x8963
1612 + /* STMicroelectronics chips */
1613 + #define M50LPW080 0x002F
1614 + #define M50FLW080A 0x0080
1615 +@@ -375,6 +376,17 @@ static void cfi_fixup_major_minor(struct cfi_private *cfi,
1616 + extp->MinorVersion = '1';
1617 + }
1618 +
1619 ++static int cfi_is_micron_28F00AP30(struct cfi_private *cfi, struct flchip *chip)
1620 ++{
1621 ++ /*
1622 ++ * Micron(was Numonyx) 1Gbit bottom boot are buggy w.r.t
1623 ++ * Erase Supend for their small Erase Blocks(0x8000)
1624 ++ */
1625 ++ if (cfi->mfr == CFI_MFR_INTEL && cfi->id == M28F00AP30)
1626 ++ return 1;
1627 ++ return 0;
1628 ++}
1629 ++
1630 + static inline struct cfi_pri_intelext *
1631 + read_pri_intelext(struct map_info *map, __u16 adr)
1632 + {
1633 +@@ -831,21 +843,30 @@ static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long
1634 + (mode == FL_WRITING && (cfip->SuspendCmdSupport & 1))))
1635 + goto sleep;
1636 +
1637 ++ /* Do not allow suspend iff read/write to EB address */
1638 ++ if ((adr & chip->in_progress_block_mask) ==
1639 ++ chip->in_progress_block_addr)
1640 ++ goto sleep;
1641 ++
1642 ++ /* do not suspend small EBs, buggy Micron Chips */
1643 ++ if (cfi_is_micron_28F00AP30(cfi, chip) &&
1644 ++ (chip->in_progress_block_mask == ~(0x8000-1)))
1645 ++ goto sleep;
1646 +
1647 + /* Erase suspend */
1648 +- map_write(map, CMD(0xB0), adr);
1649 ++ map_write(map, CMD(0xB0), chip->in_progress_block_addr);
1650 +
1651 + /* If the flash has finished erasing, then 'erase suspend'
1652 + * appears to make some (28F320) flash devices switch to
1653 + * 'read' mode. Make sure that we switch to 'read status'
1654 + * mode so we get the right data. --rmk
1655 + */
1656 +- map_write(map, CMD(0x70), adr);
1657 ++ map_write(map, CMD(0x70), chip->in_progress_block_addr);
1658 + chip->oldstate = FL_ERASING;
1659 + chip->state = FL_ERASE_SUSPENDING;
1660 + chip->erase_suspended = 1;
1661 + for (;;) {
1662 +- status = map_read(map, adr);
1663 ++ status = map_read(map, chip->in_progress_block_addr);
1664 + if (map_word_andequal(map, status, status_OK, status_OK))
1665 + break;
1666 +
1667 +@@ -1041,8 +1062,8 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
1668 + sending the 0x70 (Read Status) command to an erasing
1669 + chip and expecting it to be ignored, that's what we
1670 + do. */
1671 +- map_write(map, CMD(0xd0), adr);
1672 +- map_write(map, CMD(0x70), adr);
1673 ++ map_write(map, CMD(0xd0), chip->in_progress_block_addr);
1674 ++ map_write(map, CMD(0x70), chip->in_progress_block_addr);
1675 + chip->oldstate = FL_READY;
1676 + chip->state = FL_ERASING;
1677 + break;
1678 +@@ -1933,6 +1954,8 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1679 + map_write(map, CMD(0xD0), adr);
1680 + chip->state = FL_ERASING;
1681 + chip->erase_suspended = 0;
1682 ++ chip->in_progress_block_addr = adr;
1683 ++ chip->in_progress_block_mask = ~(len - 1);
1684 +
1685 + ret = INVAL_CACHE_AND_WAIT(map, chip, adr,
1686 + adr, len,
1687 +diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
1688 +index 56aa6b75213d..d524a64ed754 100644
1689 +--- a/drivers/mtd/chips/cfi_cmdset_0002.c
1690 ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c
1691 +@@ -816,9 +816,10 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
1692 + (mode == FL_WRITING && (cfip->EraseSuspend & 0x2))))
1693 + goto sleep;
1694 +
1695 +- /* We could check to see if we're trying to access the sector
1696 +- * that is currently being erased. However, no user will try
1697 +- * anything like that so we just wait for the timeout. */
1698 ++ /* Do not allow suspend iff read/write to EB address */
1699 ++ if ((adr & chip->in_progress_block_mask) ==
1700 ++ chip->in_progress_block_addr)
1701 ++ goto sleep;
1702 +
1703 + /* Erase suspend */
1704 + /* It's harmless to issue the Erase-Suspend and Erase-Resume
1705 +@@ -2267,6 +2268,7 @@ static int __xipram do_erase_chip(struct map_info *map, struct flchip *chip)
1706 + chip->state = FL_ERASING;
1707 + chip->erase_suspended = 0;
1708 + chip->in_progress_block_addr = adr;
1709 ++ chip->in_progress_block_mask = ~(map->size - 1);
1710 +
1711 + INVALIDATE_CACHE_UDELAY(map, chip,
1712 + adr, map->size,
1713 +@@ -2356,6 +2358,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1714 + chip->state = FL_ERASING;
1715 + chip->erase_suspended = 0;
1716 + chip->in_progress_block_addr = adr;
1717 ++ chip->in_progress_block_mask = ~(len - 1);
1718 +
1719 + INVALIDATE_CACHE_UDELAY(map, chip,
1720 + adr, len,
1721 +diff --git a/drivers/mtd/nand/marvell_nand.c b/drivers/mtd/nand/marvell_nand.c
1722 +index 2196f2a233d6..795f868fe1f7 100644
1723 +--- a/drivers/mtd/nand/marvell_nand.c
1724 ++++ b/drivers/mtd/nand/marvell_nand.c
1725 +@@ -2277,29 +2277,20 @@ static int marvell_nand_chip_init(struct device *dev, struct marvell_nfc *nfc,
1726 + /*
1727 + * The legacy "num-cs" property indicates the number of CS on the only
1728 + * chip connected to the controller (legacy bindings does not support
1729 +- * more than one chip). CS are only incremented one by one while the RB
1730 +- * pin is always the #0.
1731 ++ * more than one chip). The CS and RB pins are always the #0.
1732 + *
1733 + * When not using legacy bindings, a couple of "reg" and "nand-rb"
1734 + * properties must be filled. For each chip, expressed as a subnode,
1735 + * "reg" points to the CS lines and "nand-rb" to the RB line.
1736 + */
1737 +- if (pdata) {
1738 ++ if (pdata || nfc->caps->legacy_of_bindings) {
1739 + nsels = 1;
1740 +- } else if (nfc->caps->legacy_of_bindings &&
1741 +- !of_get_property(np, "num-cs", &nsels)) {
1742 +- dev_err(dev, "missing num-cs property\n");
1743 +- return -EINVAL;
1744 +- } else if (!of_get_property(np, "reg", &nsels)) {
1745 +- dev_err(dev, "missing reg property\n");
1746 +- return -EINVAL;
1747 +- }
1748 +-
1749 +- if (!pdata)
1750 +- nsels /= sizeof(u32);
1751 +- if (!nsels) {
1752 +- dev_err(dev, "invalid reg property size\n");
1753 +- return -EINVAL;
1754 ++ } else {
1755 ++ nsels = of_property_count_elems_of_size(np, "reg", sizeof(u32));
1756 ++ if (nsels <= 0) {
1757 ++ dev_err(dev, "missing/invalid reg property\n");
1758 ++ return -EINVAL;
1759 ++ }
1760 + }
1761 +
1762 + /* Alloc the nand chip structure */
1763 +diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c
1764 +index c5bee00b7f5e..76761b841f1f 100644
1765 +--- a/drivers/mtd/nand/tango_nand.c
1766 ++++ b/drivers/mtd/nand/tango_nand.c
1767 +@@ -643,7 +643,7 @@ static int tango_nand_probe(struct platform_device *pdev)
1768 +
1769 + writel_relaxed(MODE_RAW, nfc->pbus_base + PBUS_PAD_MODE);
1770 +
1771 +- clk = clk_get(&pdev->dev, NULL);
1772 ++ clk = devm_clk_get(&pdev->dev, NULL);
1773 + if (IS_ERR(clk))
1774 + return PTR_ERR(clk);
1775 +
1776 +diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c
1777 +index 4b8e9183489a..5872f31eaa60 100644
1778 +--- a/drivers/mtd/spi-nor/cadence-quadspi.c
1779 ++++ b/drivers/mtd/spi-nor/cadence-quadspi.c
1780 +@@ -501,7 +501,9 @@ static int cqspi_indirect_read_execute(struct spi_nor *nor, u8 *rxbuf,
1781 + void __iomem *reg_base = cqspi->iobase;
1782 + void __iomem *ahb_base = cqspi->ahb_base;
1783 + unsigned int remaining = n_rx;
1784 ++ unsigned int mod_bytes = n_rx % 4;
1785 + unsigned int bytes_to_read = 0;
1786 ++ u8 *rxbuf_end = rxbuf + n_rx;
1787 + int ret = 0;
1788 +
1789 + writel(from_addr, reg_base + CQSPI_REG_INDIRECTRDSTARTADDR);
1790 +@@ -530,11 +532,24 @@ static int cqspi_indirect_read_execute(struct spi_nor *nor, u8 *rxbuf,
1791 + }
1792 +
1793 + while (bytes_to_read != 0) {
1794 ++ unsigned int word_remain = round_down(remaining, 4);
1795 ++
1796 + bytes_to_read *= cqspi->fifo_width;
1797 + bytes_to_read = bytes_to_read > remaining ?
1798 + remaining : bytes_to_read;
1799 +- ioread32_rep(ahb_base, rxbuf,
1800 +- DIV_ROUND_UP(bytes_to_read, 4));
1801 ++ bytes_to_read = round_down(bytes_to_read, 4);
1802 ++ /* Read 4 byte word chunks then single bytes */
1803 ++ if (bytes_to_read) {
1804 ++ ioread32_rep(ahb_base, rxbuf,
1805 ++ (bytes_to_read / 4));
1806 ++ } else if (!word_remain && mod_bytes) {
1807 ++ unsigned int temp = ioread32(ahb_base);
1808 ++
1809 ++ bytes_to_read = mod_bytes;
1810 ++ memcpy(rxbuf, &temp, min((unsigned int)
1811 ++ (rxbuf_end - rxbuf),
1812 ++ bytes_to_read));
1813 ++ }
1814 + rxbuf += bytes_to_read;
1815 + remaining -= bytes_to_read;
1816 + bytes_to_read = cqspi_get_rd_sram_level(cqspi);
1817 +diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
1818 +index 84aa9d676375..6da20b9688f7 100644
1819 +--- a/drivers/of/fdt.c
1820 ++++ b/drivers/of/fdt.c
1821 +@@ -942,7 +942,7 @@ int __init early_init_dt_scan_chosen_stdout(void)
1822 + int offset;
1823 + const char *p, *q, *options = NULL;
1824 + int l;
1825 +- const struct earlycon_id *match;
1826 ++ const struct earlycon_id **p_match;
1827 + const void *fdt = initial_boot_params;
1828 +
1829 + offset = fdt_path_offset(fdt, "/chosen");
1830 +@@ -969,7 +969,10 @@ int __init early_init_dt_scan_chosen_stdout(void)
1831 + return 0;
1832 + }
1833 +
1834 +- for (match = __earlycon_table; match < __earlycon_table_end; match++) {
1835 ++ for (p_match = __earlycon_table; p_match < __earlycon_table_end;
1836 ++ p_match++) {
1837 ++ const struct earlycon_id *match = *p_match;
1838 ++
1839 + if (!match->compatible[0])
1840 + continue;
1841 +
1842 +diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
1843 +index b04d37b3c5de..9abf549631b4 100644
1844 +--- a/drivers/pci/host/pci-aardvark.c
1845 ++++ b/drivers/pci/host/pci-aardvark.c
1846 +@@ -29,6 +29,7 @@
1847 + #define PCIE_CORE_DEV_CTRL_STATS_MAX_PAYLOAD_SZ_SHIFT 5
1848 + #define PCIE_CORE_DEV_CTRL_STATS_SNOOP_DISABLE (0 << 11)
1849 + #define PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SIZE_SHIFT 12
1850 ++#define PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SZ 0x2
1851 + #define PCIE_CORE_LINK_CTRL_STAT_REG 0xd0
1852 + #define PCIE_CORE_LINK_L0S_ENTRY BIT(0)
1853 + #define PCIE_CORE_LINK_TRAINING BIT(5)
1854 +@@ -100,7 +101,8 @@
1855 + #define PCIE_ISR1_MASK_REG (CONTROL_BASE_ADDR + 0x4C)
1856 + #define PCIE_ISR1_POWER_STATE_CHANGE BIT(4)
1857 + #define PCIE_ISR1_FLUSH BIT(5)
1858 +-#define PCIE_ISR1_ALL_MASK GENMASK(5, 4)
1859 ++#define PCIE_ISR1_INTX_ASSERT(val) BIT(8 + (val))
1860 ++#define PCIE_ISR1_ALL_MASK GENMASK(11, 4)
1861 + #define PCIE_MSI_ADDR_LOW_REG (CONTROL_BASE_ADDR + 0x50)
1862 + #define PCIE_MSI_ADDR_HIGH_REG (CONTROL_BASE_ADDR + 0x54)
1863 + #define PCIE_MSI_STATUS_REG (CONTROL_BASE_ADDR + 0x58)
1864 +@@ -172,8 +174,6 @@
1865 + #define PCIE_CONFIG_WR_TYPE0 0xa
1866 + #define PCIE_CONFIG_WR_TYPE1 0xb
1867 +
1868 +-/* PCI_BDF shifts 8bit, so we need extra 4bit shift */
1869 +-#define PCIE_BDF(dev) (dev << 4)
1870 + #define PCIE_CONF_BUS(bus) (((bus) & 0xff) << 20)
1871 + #define PCIE_CONF_DEV(dev) (((dev) & 0x1f) << 15)
1872 + #define PCIE_CONF_FUNC(fun) (((fun) & 0x7) << 12)
1873 +@@ -296,7 +296,8 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)
1874 + reg = PCIE_CORE_DEV_CTRL_STATS_RELAX_ORDER_DISABLE |
1875 + (7 << PCIE_CORE_DEV_CTRL_STATS_MAX_PAYLOAD_SZ_SHIFT) |
1876 + PCIE_CORE_DEV_CTRL_STATS_SNOOP_DISABLE |
1877 +- PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SIZE_SHIFT;
1878 ++ (PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SZ <<
1879 ++ PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SIZE_SHIFT);
1880 + advk_writel(pcie, reg, PCIE_CORE_DEV_CTRL_STATS_REG);
1881 +
1882 + /* Program PCIe Control 2 to disable strict ordering */
1883 +@@ -437,7 +438,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
1884 + u32 reg;
1885 + int ret;
1886 +
1887 +- if (PCI_SLOT(devfn) != 0) {
1888 ++ if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) {
1889 + *val = 0xffffffff;
1890 + return PCIBIOS_DEVICE_NOT_FOUND;
1891 + }
1892 +@@ -456,7 +457,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
1893 + advk_writel(pcie, reg, PIO_CTRL);
1894 +
1895 + /* Program the address registers */
1896 +- reg = PCIE_BDF(devfn) | PCIE_CONF_REG(where);
1897 ++ reg = PCIE_CONF_ADDR(bus->number, devfn, where);
1898 + advk_writel(pcie, reg, PIO_ADDR_LS);
1899 + advk_writel(pcie, 0, PIO_ADDR_MS);
1900 +
1901 +@@ -491,7 +492,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
1902 + int offset;
1903 + int ret;
1904 +
1905 +- if (PCI_SLOT(devfn) != 0)
1906 ++ if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
1907 + return PCIBIOS_DEVICE_NOT_FOUND;
1908 +
1909 + if (where % size)
1910 +@@ -609,9 +610,9 @@ static void advk_pcie_irq_mask(struct irq_data *d)
1911 + irq_hw_number_t hwirq = irqd_to_hwirq(d);
1912 + u32 mask;
1913 +
1914 +- mask = advk_readl(pcie, PCIE_ISR0_MASK_REG);
1915 +- mask |= PCIE_ISR0_INTX_ASSERT(hwirq);
1916 +- advk_writel(pcie, mask, PCIE_ISR0_MASK_REG);
1917 ++ mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
1918 ++ mask |= PCIE_ISR1_INTX_ASSERT(hwirq);
1919 ++ advk_writel(pcie, mask, PCIE_ISR1_MASK_REG);
1920 + }
1921 +
1922 + static void advk_pcie_irq_unmask(struct irq_data *d)
1923 +@@ -620,9 +621,9 @@ static void advk_pcie_irq_unmask(struct irq_data *d)
1924 + irq_hw_number_t hwirq = irqd_to_hwirq(d);
1925 + u32 mask;
1926 +
1927 +- mask = advk_readl(pcie, PCIE_ISR0_MASK_REG);
1928 +- mask &= ~PCIE_ISR0_INTX_ASSERT(hwirq);
1929 +- advk_writel(pcie, mask, PCIE_ISR0_MASK_REG);
1930 ++ mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
1931 ++ mask &= ~PCIE_ISR1_INTX_ASSERT(hwirq);
1932 ++ advk_writel(pcie, mask, PCIE_ISR1_MASK_REG);
1933 + }
1934 +
1935 + static int advk_pcie_irq_map(struct irq_domain *h,
1936 +@@ -765,29 +766,35 @@ static void advk_pcie_handle_msi(struct advk_pcie *pcie)
1937 +
1938 + static void advk_pcie_handle_int(struct advk_pcie *pcie)
1939 + {
1940 +- u32 val, mask, status;
1941 ++ u32 isr0_val, isr0_mask, isr0_status;
1942 ++ u32 isr1_val, isr1_mask, isr1_status;
1943 + int i, virq;
1944 +
1945 +- val = advk_readl(pcie, PCIE_ISR0_REG);
1946 +- mask = advk_readl(pcie, PCIE_ISR0_MASK_REG);
1947 +- status = val & ((~mask) & PCIE_ISR0_ALL_MASK);
1948 ++ isr0_val = advk_readl(pcie, PCIE_ISR0_REG);
1949 ++ isr0_mask = advk_readl(pcie, PCIE_ISR0_MASK_REG);
1950 ++ isr0_status = isr0_val & ((~isr0_mask) & PCIE_ISR0_ALL_MASK);
1951 ++
1952 ++ isr1_val = advk_readl(pcie, PCIE_ISR1_REG);
1953 ++ isr1_mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
1954 ++ isr1_status = isr1_val & ((~isr1_mask) & PCIE_ISR1_ALL_MASK);
1955 +
1956 +- if (!status) {
1957 +- advk_writel(pcie, val, PCIE_ISR0_REG);
1958 ++ if (!isr0_status && !isr1_status) {
1959 ++ advk_writel(pcie, isr0_val, PCIE_ISR0_REG);
1960 ++ advk_writel(pcie, isr1_val, PCIE_ISR1_REG);
1961 + return;
1962 + }
1963 +
1964 + /* Process MSI interrupts */
1965 +- if (status & PCIE_ISR0_MSI_INT_PENDING)
1966 ++ if (isr0_status & PCIE_ISR0_MSI_INT_PENDING)
1967 + advk_pcie_handle_msi(pcie);
1968 +
1969 + /* Process legacy interrupts */
1970 + for (i = 0; i < PCI_NUM_INTX; i++) {
1971 +- if (!(status & PCIE_ISR0_INTX_ASSERT(i)))
1972 ++ if (!(isr1_status & PCIE_ISR1_INTX_ASSERT(i)))
1973 + continue;
1974 +
1975 +- advk_writel(pcie, PCIE_ISR0_INTX_ASSERT(i),
1976 +- PCIE_ISR0_REG);
1977 ++ advk_writel(pcie, PCIE_ISR1_INTX_ASSERT(i),
1978 ++ PCIE_ISR1_REG);
1979 +
1980 + virq = irq_find_mapping(pcie->irq_domain, i);
1981 + generic_handle_irq(virq);
1982 +diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
1983 +index 3bed6beda051..eede34e5ada2 100644
1984 +--- a/drivers/pci/pci-driver.c
1985 ++++ b/drivers/pci/pci-driver.c
1986 +@@ -945,10 +945,11 @@ static int pci_pm_freeze(struct device *dev)
1987 + * devices should not be touched during freeze/thaw transitions,
1988 + * however.
1989 + */
1990 +- if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND))
1991 ++ if (!dev_pm_smart_suspend_and_suspended(dev)) {
1992 + pm_runtime_resume(dev);
1993 ++ pci_dev->state_saved = false;
1994 ++ }
1995 +
1996 +- pci_dev->state_saved = false;
1997 + if (pm->freeze) {
1998 + int error;
1999 +
2000 +diff --git a/drivers/rtc/rtc-opal.c b/drivers/rtc/rtc-opal.c
2001 +index 304e891e35fc..60f2250fd96b 100644
2002 +--- a/drivers/rtc/rtc-opal.c
2003 ++++ b/drivers/rtc/rtc-opal.c
2004 +@@ -57,7 +57,7 @@ static void tm_to_opal(struct rtc_time *tm, u32 *y_m_d, u64 *h_m_s_ms)
2005 +
2006 + static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm)
2007 + {
2008 +- long rc = OPAL_BUSY;
2009 ++ s64 rc = OPAL_BUSY;
2010 + int retries = 10;
2011 + u32 y_m_d;
2012 + u64 h_m_s_ms;
2013 +@@ -66,13 +66,17 @@ static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm)
2014 +
2015 + while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
2016 + rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms);
2017 +- if (rc == OPAL_BUSY_EVENT)
2018 ++ if (rc == OPAL_BUSY_EVENT) {
2019 ++ msleep(OPAL_BUSY_DELAY_MS);
2020 + opal_poll_events(NULL);
2021 +- else if (retries-- && (rc == OPAL_HARDWARE
2022 +- || rc == OPAL_INTERNAL_ERROR))
2023 +- msleep(10);
2024 +- else if (rc != OPAL_BUSY && rc != OPAL_BUSY_EVENT)
2025 +- break;
2026 ++ } else if (rc == OPAL_BUSY) {
2027 ++ msleep(OPAL_BUSY_DELAY_MS);
2028 ++ } else if (rc == OPAL_HARDWARE || rc == OPAL_INTERNAL_ERROR) {
2029 ++ if (retries--) {
2030 ++ msleep(10); /* Wait 10ms before retry */
2031 ++ rc = OPAL_BUSY; /* go around again */
2032 ++ }
2033 ++ }
2034 + }
2035 +
2036 + if (rc != OPAL_SUCCESS)
2037 +@@ -87,21 +91,26 @@ static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm)
2038 +
2039 + static int opal_set_rtc_time(struct device *dev, struct rtc_time *tm)
2040 + {
2041 +- long rc = OPAL_BUSY;
2042 ++ s64 rc = OPAL_BUSY;
2043 + int retries = 10;
2044 + u32 y_m_d = 0;
2045 + u64 h_m_s_ms = 0;
2046 +
2047 + tm_to_opal(tm, &y_m_d, &h_m_s_ms);
2048 ++
2049 + while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
2050 + rc = opal_rtc_write(y_m_d, h_m_s_ms);
2051 +- if (rc == OPAL_BUSY_EVENT)
2052 ++ if (rc == OPAL_BUSY_EVENT) {
2053 ++ msleep(OPAL_BUSY_DELAY_MS);
2054 + opal_poll_events(NULL);
2055 +- else if (retries-- && (rc == OPAL_HARDWARE
2056 +- || rc == OPAL_INTERNAL_ERROR))
2057 +- msleep(10);
2058 +- else if (rc != OPAL_BUSY && rc != OPAL_BUSY_EVENT)
2059 +- break;
2060 ++ } else if (rc == OPAL_BUSY) {
2061 ++ msleep(OPAL_BUSY_DELAY_MS);
2062 ++ } else if (rc == OPAL_HARDWARE || rc == OPAL_INTERNAL_ERROR) {
2063 ++ if (retries--) {
2064 ++ msleep(10); /* Wait 10ms before retry */
2065 ++ rc = OPAL_BUSY; /* go around again */
2066 ++ }
2067 ++ }
2068 + }
2069 +
2070 + return rc == OPAL_SUCCESS ? 0 : -EIO;
2071 +diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fsm.c
2072 +index c30420c517b1..e96b85579f21 100644
2073 +--- a/drivers/s390/cio/vfio_ccw_fsm.c
2074 ++++ b/drivers/s390/cio/vfio_ccw_fsm.c
2075 +@@ -20,12 +20,12 @@ static int fsm_io_helper(struct vfio_ccw_private *private)
2076 + int ccode;
2077 + __u8 lpm;
2078 + unsigned long flags;
2079 ++ int ret;
2080 +
2081 + sch = private->sch;
2082 +
2083 + spin_lock_irqsave(sch->lock, flags);
2084 + private->state = VFIO_CCW_STATE_BUSY;
2085 +- spin_unlock_irqrestore(sch->lock, flags);
2086 +
2087 + orb = cp_get_orb(&private->cp, (u32)(addr_t)sch, sch->lpm);
2088 +
2089 +@@ -38,10 +38,12 @@ static int fsm_io_helper(struct vfio_ccw_private *private)
2090 + * Initialize device status information
2091 + */
2092 + sch->schib.scsw.cmd.actl |= SCSW_ACTL_START_PEND;
2093 +- return 0;
2094 ++ ret = 0;
2095 ++ break;
2096 + case 1: /* Status pending */
2097 + case 2: /* Busy */
2098 +- return -EBUSY;
2099 ++ ret = -EBUSY;
2100 ++ break;
2101 + case 3: /* Device/path not operational */
2102 + {
2103 + lpm = orb->cmd.lpm;
2104 +@@ -51,13 +53,16 @@ static int fsm_io_helper(struct vfio_ccw_private *private)
2105 + sch->lpm = 0;
2106 +
2107 + if (cio_update_schib(sch))
2108 +- return -ENODEV;
2109 +-
2110 +- return sch->lpm ? -EACCES : -ENODEV;
2111 ++ ret = -ENODEV;
2112 ++ else
2113 ++ ret = sch->lpm ? -EACCES : -ENODEV;
2114 ++ break;
2115 + }
2116 + default:
2117 +- return ccode;
2118 ++ ret = ccode;
2119 + }
2120 ++ spin_unlock_irqrestore(sch->lock, flags);
2121 ++ return ret;
2122 + }
2123 +
2124 + static void fsm_notoper(struct vfio_ccw_private *private,
2125 +diff --git a/drivers/sbus/char/oradax.c b/drivers/sbus/char/oradax.c
2126 +index c44d7c7ffc92..1754f55e2fac 100644
2127 +--- a/drivers/sbus/char/oradax.c
2128 ++++ b/drivers/sbus/char/oradax.c
2129 +@@ -3,7 +3,7 @@
2130 + *
2131 + * This program is free software: you can redistribute it and/or modify
2132 + * it under the terms of the GNU General Public License as published by
2133 +- * the Free Software Foundation, either version 3 of the License, or
2134 ++ * the Free Software Foundation, either version 2 of the License, or
2135 + * (at your option) any later version.
2136 + *
2137 + * This program is distributed in the hope that it will be useful,
2138 +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
2139 +index 1fa84d6a0f8b..d19b41bcebea 100644
2140 +--- a/drivers/scsi/sd.c
2141 ++++ b/drivers/scsi/sd.c
2142 +@@ -2121,6 +2121,8 @@ sd_spinup_disk(struct scsi_disk *sdkp)
2143 + break; /* standby */
2144 + if (sshdr.asc == 4 && sshdr.ascq == 0xc)
2145 + break; /* unavailable */
2146 ++ if (sshdr.asc == 4 && sshdr.ascq == 0x1b)
2147 ++ break; /* sanitize in progress */
2148 + /*
2149 + * Issue command to spin up drive when not ready
2150 + */
2151 +diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
2152 +index 89cf4498f535..973a497739f0 100644
2153 +--- a/drivers/scsi/sd_zbc.c
2154 ++++ b/drivers/scsi/sd_zbc.c
2155 +@@ -400,8 +400,10 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf)
2156 + *
2157 + * Check that all zones of the device are equal. The last zone can however
2158 + * be smaller. The zone size must also be a power of two number of LBAs.
2159 ++ *
2160 ++ * Returns the zone size in bytes upon success or an error code upon failure.
2161 + */
2162 +-static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
2163 ++static s64 sd_zbc_check_zone_size(struct scsi_disk *sdkp)
2164 + {
2165 + u64 zone_blocks = 0;
2166 + sector_t block = 0;
2167 +@@ -412,8 +414,6 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
2168 + int ret;
2169 + u8 same;
2170 +
2171 +- sdkp->zone_blocks = 0;
2172 +-
2173 + /* Get a buffer */
2174 + buf = kmalloc(SD_ZBC_BUF_SIZE, GFP_KERNEL);
2175 + if (!buf)
2176 +@@ -445,16 +445,17 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
2177 +
2178 + /* Parse zone descriptors */
2179 + while (rec < buf + buf_len) {
2180 +- zone_blocks = get_unaligned_be64(&rec[8]);
2181 +- if (sdkp->zone_blocks == 0) {
2182 +- sdkp->zone_blocks = zone_blocks;
2183 +- } else if (zone_blocks != sdkp->zone_blocks &&
2184 +- (block + zone_blocks < sdkp->capacity
2185 +- || zone_blocks > sdkp->zone_blocks)) {
2186 +- zone_blocks = 0;
2187 ++ u64 this_zone_blocks = get_unaligned_be64(&rec[8]);
2188 ++
2189 ++ if (zone_blocks == 0) {
2190 ++ zone_blocks = this_zone_blocks;
2191 ++ } else if (this_zone_blocks != zone_blocks &&
2192 ++ (block + this_zone_blocks < sdkp->capacity
2193 ++ || this_zone_blocks > zone_blocks)) {
2194 ++ this_zone_blocks = 0;
2195 + goto out;
2196 + }
2197 +- block += zone_blocks;
2198 ++ block += this_zone_blocks;
2199 + rec += 64;
2200 + }
2201 +
2202 +@@ -467,8 +468,6 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
2203 +
2204 + } while (block < sdkp->capacity);
2205 +
2206 +- zone_blocks = sdkp->zone_blocks;
2207 +-
2208 + out:
2209 + if (!zone_blocks) {
2210 + if (sdkp->first_scan)
2211 +@@ -488,8 +487,7 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
2212 + "Zone size too large\n");
2213 + ret = -ENODEV;
2214 + } else {
2215 +- sdkp->zone_blocks = zone_blocks;
2216 +- sdkp->zone_shift = ilog2(zone_blocks);
2217 ++ ret = zone_blocks;
2218 + }
2219 +
2220 + out_free:
2221 +@@ -500,21 +498,21 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
2222 +
2223 + /**
2224 + * sd_zbc_alloc_zone_bitmap - Allocate a zone bitmap (one bit per zone).
2225 +- * @sdkp: The disk of the bitmap
2226 ++ * @nr_zones: Number of zones to allocate space for.
2227 ++ * @numa_node: NUMA node to allocate the memory from.
2228 + */
2229 +-static inline unsigned long *sd_zbc_alloc_zone_bitmap(struct scsi_disk *sdkp)
2230 ++static inline unsigned long *
2231 ++sd_zbc_alloc_zone_bitmap(u32 nr_zones, int numa_node)
2232 + {
2233 +- struct request_queue *q = sdkp->disk->queue;
2234 +-
2235 +- return kzalloc_node(BITS_TO_LONGS(sdkp->nr_zones)
2236 +- * sizeof(unsigned long),
2237 +- GFP_KERNEL, q->node);
2238 ++ return kzalloc_node(BITS_TO_LONGS(nr_zones) * sizeof(unsigned long),
2239 ++ GFP_KERNEL, numa_node);
2240 + }
2241 +
2242 + /**
2243 + * sd_zbc_get_seq_zones - Parse report zones reply to identify sequential zones
2244 + * @sdkp: disk used
2245 + * @buf: report reply buffer
2246 ++ * @zone_shift: logarithm base 2 of the number of blocks in a zone
2247 + * @seq_zone_bitamp: bitmap of sequential zones to set
2248 + *
2249 + * Parse reported zone descriptors in @buf to identify sequential zones and
2250 +@@ -524,7 +522,7 @@ static inline unsigned long *sd_zbc_alloc_zone_bitmap(struct scsi_disk *sdkp)
2251 + * Return the LBA after the last zone reported.
2252 + */
2253 + static sector_t sd_zbc_get_seq_zones(struct scsi_disk *sdkp, unsigned char *buf,
2254 +- unsigned int buflen,
2255 ++ unsigned int buflen, u32 zone_shift,
2256 + unsigned long *seq_zones_bitmap)
2257 + {
2258 + sector_t lba, next_lba = sdkp->capacity;
2259 +@@ -543,7 +541,7 @@ static sector_t sd_zbc_get_seq_zones(struct scsi_disk *sdkp, unsigned char *buf,
2260 + if (type != ZBC_ZONE_TYPE_CONV &&
2261 + cond != ZBC_ZONE_COND_READONLY &&
2262 + cond != ZBC_ZONE_COND_OFFLINE)
2263 +- set_bit(lba >> sdkp->zone_shift, seq_zones_bitmap);
2264 ++ set_bit(lba >> zone_shift, seq_zones_bitmap);
2265 + next_lba = lba + get_unaligned_be64(&rec[8]);
2266 + rec += 64;
2267 + }
2268 +@@ -552,12 +550,16 @@ static sector_t sd_zbc_get_seq_zones(struct scsi_disk *sdkp, unsigned char *buf,
2269 + }
2270 +
2271 + /**
2272 +- * sd_zbc_setup_seq_zones_bitmap - Initialize the disk seq zone bitmap.
2273 ++ * sd_zbc_setup_seq_zones_bitmap - Initialize a seq zone bitmap.
2274 + * @sdkp: target disk
2275 ++ * @zone_shift: logarithm base 2 of the number of blocks in a zone
2276 ++ * @nr_zones: number of zones to set up a seq zone bitmap for
2277 + *
2278 + * Allocate a zone bitmap and initialize it by identifying sequential zones.
2279 + */
2280 +-static int sd_zbc_setup_seq_zones_bitmap(struct scsi_disk *sdkp)
2281 ++static unsigned long *
2282 ++sd_zbc_setup_seq_zones_bitmap(struct scsi_disk *sdkp, u32 zone_shift,
2283 ++ u32 nr_zones)
2284 + {
2285 + struct request_queue *q = sdkp->disk->queue;
2286 + unsigned long *seq_zones_bitmap;
2287 +@@ -565,9 +567,9 @@ static int sd_zbc_setup_seq_zones_bitmap(struct scsi_disk *sdkp)
2288 + unsigned char *buf;
2289 + int ret = -ENOMEM;
2290 +
2291 +- seq_zones_bitmap = sd_zbc_alloc_zone_bitmap(sdkp);
2292 ++ seq_zones_bitmap = sd_zbc_alloc_zone_bitmap(nr_zones, q->node);
2293 + if (!seq_zones_bitmap)
2294 +- return -ENOMEM;
2295 ++ return ERR_PTR(-ENOMEM);
2296 +
2297 + buf = kmalloc(SD_ZBC_BUF_SIZE, GFP_KERNEL);
2298 + if (!buf)
2299 +@@ -578,7 +580,7 @@ static int sd_zbc_setup_seq_zones_bitmap(struct scsi_disk *sdkp)
2300 + if (ret)
2301 + goto out;
2302 + lba = sd_zbc_get_seq_zones(sdkp, buf, SD_ZBC_BUF_SIZE,
2303 +- seq_zones_bitmap);
2304 ++ zone_shift, seq_zones_bitmap);
2305 + }
2306 +
2307 + if (lba != sdkp->capacity) {
2308 +@@ -590,12 +592,9 @@ static int sd_zbc_setup_seq_zones_bitmap(struct scsi_disk *sdkp)
2309 + kfree(buf);
2310 + if (ret) {
2311 + kfree(seq_zones_bitmap);
2312 +- return ret;
2313 ++ return ERR_PTR(ret);
2314 + }
2315 +-
2316 +- q->seq_zones_bitmap = seq_zones_bitmap;
2317 +-
2318 +- return 0;
2319 ++ return seq_zones_bitmap;
2320 + }
2321 +
2322 + static void sd_zbc_cleanup(struct scsi_disk *sdkp)
2323 +@@ -611,44 +610,64 @@ static void sd_zbc_cleanup(struct scsi_disk *sdkp)
2324 + q->nr_zones = 0;
2325 + }
2326 +
2327 +-static int sd_zbc_setup(struct scsi_disk *sdkp)
2328 ++static int sd_zbc_setup(struct scsi_disk *sdkp, u32 zone_blocks)
2329 + {
2330 + struct request_queue *q = sdkp->disk->queue;
2331 ++ u32 zone_shift = ilog2(zone_blocks);
2332 ++ u32 nr_zones;
2333 + int ret;
2334 +
2335 +- /* READ16/WRITE16 is mandatory for ZBC disks */
2336 +- sdkp->device->use_16_for_rw = 1;
2337 +- sdkp->device->use_10_for_rw = 0;
2338 +-
2339 + /* chunk_sectors indicates the zone size */
2340 +- blk_queue_chunk_sectors(sdkp->disk->queue,
2341 +- logical_to_sectors(sdkp->device, sdkp->zone_blocks));
2342 +- sdkp->nr_zones =
2343 +- round_up(sdkp->capacity, sdkp->zone_blocks) >> sdkp->zone_shift;
2344 ++ blk_queue_chunk_sectors(q,
2345 ++ logical_to_sectors(sdkp->device, zone_blocks));
2346 ++ nr_zones = round_up(sdkp->capacity, zone_blocks) >> zone_shift;
2347 +
2348 + /*
2349 + * Initialize the device request queue information if the number
2350 + * of zones changed.
2351 + */
2352 +- if (sdkp->nr_zones != q->nr_zones) {
2353 +-
2354 +- sd_zbc_cleanup(sdkp);
2355 +-
2356 +- q->nr_zones = sdkp->nr_zones;
2357 +- if (sdkp->nr_zones) {
2358 +- q->seq_zones_wlock = sd_zbc_alloc_zone_bitmap(sdkp);
2359 +- if (!q->seq_zones_wlock) {
2360 ++ if (nr_zones != sdkp->nr_zones || nr_zones != q->nr_zones) {
2361 ++ unsigned long *seq_zones_wlock = NULL, *seq_zones_bitmap = NULL;
2362 ++ size_t zone_bitmap_size;
2363 ++
2364 ++ if (nr_zones) {
2365 ++ seq_zones_wlock = sd_zbc_alloc_zone_bitmap(nr_zones,
2366 ++ q->node);
2367 ++ if (!seq_zones_wlock) {
2368 + ret = -ENOMEM;
2369 + goto err;
2370 + }
2371 +
2372 +- ret = sd_zbc_setup_seq_zones_bitmap(sdkp);
2373 +- if (ret) {
2374 +- sd_zbc_cleanup(sdkp);
2375 ++ seq_zones_bitmap = sd_zbc_setup_seq_zones_bitmap(sdkp,
2376 ++ zone_shift, nr_zones);
2377 ++ if (IS_ERR(seq_zones_bitmap)) {
2378 ++ ret = PTR_ERR(seq_zones_bitmap);
2379 ++ kfree(seq_zones_wlock);
2380 + goto err;
2381 + }
2382 + }
2383 +-
2384 ++ zone_bitmap_size = BITS_TO_LONGS(nr_zones) *
2385 ++ sizeof(unsigned long);
2386 ++ blk_mq_freeze_queue(q);
2387 ++ if (q->nr_zones != nr_zones) {
2388 ++ /* READ16/WRITE16 is mandatory for ZBC disks */
2389 ++ sdkp->device->use_16_for_rw = 1;
2390 ++ sdkp->device->use_10_for_rw = 0;
2391 ++
2392 ++ sdkp->zone_blocks = zone_blocks;
2393 ++ sdkp->zone_shift = zone_shift;
2394 ++ sdkp->nr_zones = nr_zones;
2395 ++ q->nr_zones = nr_zones;
2396 ++ swap(q->seq_zones_wlock, seq_zones_wlock);
2397 ++ swap(q->seq_zones_bitmap, seq_zones_bitmap);
2398 ++ } else if (memcmp(q->seq_zones_bitmap, seq_zones_bitmap,
2399 ++ zone_bitmap_size) != 0) {
2400 ++ memcpy(q->seq_zones_bitmap, seq_zones_bitmap,
2401 ++ zone_bitmap_size);
2402 ++ }
2403 ++ blk_mq_unfreeze_queue(q);
2404 ++ kfree(seq_zones_wlock);
2405 ++ kfree(seq_zones_bitmap);
2406 + }
2407 +
2408 + return 0;
2409 +@@ -660,6 +679,7 @@ static int sd_zbc_setup(struct scsi_disk *sdkp)
2410 +
2411 + int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
2412 + {
2413 ++ int64_t zone_blocks;
2414 + int ret;
2415 +
2416 + if (!sd_is_zoned(sdkp))
2417 +@@ -696,12 +716,16 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
2418 + * Check zone size: only devices with a constant zone size (except
2419 + * an eventual last runt zone) that is a power of 2 are supported.
2420 + */
2421 +- ret = sd_zbc_check_zone_size(sdkp);
2422 +- if (ret)
2423 ++ zone_blocks = sd_zbc_check_zone_size(sdkp);
2424 ++ ret = -EFBIG;
2425 ++ if (zone_blocks != (u32)zone_blocks)
2426 ++ goto err;
2427 ++ ret = zone_blocks;
2428 ++ if (ret < 0)
2429 + goto err;
2430 +
2431 + /* The drive satisfies the kernel restrictions: set it up */
2432 +- ret = sd_zbc_setup(sdkp);
2433 ++ ret = sd_zbc_setup(sdkp, zone_blocks);
2434 + if (ret)
2435 + goto err;
2436 +
2437 +diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c
2438 +index 884419c37e84..457ea1f8db30 100644
2439 +--- a/drivers/slimbus/messaging.c
2440 ++++ b/drivers/slimbus/messaging.c
2441 +@@ -183,7 +183,7 @@ static u16 slim_slicesize(int code)
2442 + 0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7
2443 + };
2444 +
2445 +- clamp(code, 1, (int)ARRAY_SIZE(sizetocode));
2446 ++ code = clamp(code, 1, (int)ARRAY_SIZE(sizetocode));
2447 +
2448 + return sizetocode[code - 1];
2449 + }
2450 +diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
2451 +index 3b3e1f6632d7..1dbe27c9946c 100644
2452 +--- a/drivers/tty/n_gsm.c
2453 ++++ b/drivers/tty/n_gsm.c
2454 +@@ -121,6 +121,9 @@ struct gsm_dlci {
2455 + struct mutex mutex;
2456 +
2457 + /* Link layer */
2458 ++ int mode;
2459 ++#define DLCI_MODE_ABM 0 /* Normal Asynchronous Balanced Mode */
2460 ++#define DLCI_MODE_ADM 1 /* Asynchronous Disconnected Mode */
2461 + spinlock_t lock; /* Protects the internal state */
2462 + struct timer_list t1; /* Retransmit timer for SABM and UA */
2463 + int retries;
2464 +@@ -1364,7 +1367,13 @@ static struct gsm_control *gsm_control_send(struct gsm_mux *gsm,
2465 + ctrl->data = data;
2466 + ctrl->len = clen;
2467 + gsm->pending_cmd = ctrl;
2468 +- gsm->cretries = gsm->n2;
2469 ++
2470 ++ /* If DLCI0 is in ADM mode skip retries, it won't respond */
2471 ++ if (gsm->dlci[0]->mode == DLCI_MODE_ADM)
2472 ++ gsm->cretries = 1;
2473 ++ else
2474 ++ gsm->cretries = gsm->n2;
2475 ++
2476 + mod_timer(&gsm->t2_timer, jiffies + gsm->t2 * HZ / 100);
2477 + gsm_control_transmit(gsm, ctrl);
2478 + spin_unlock_irqrestore(&gsm->control_lock, flags);
2479 +@@ -1472,6 +1481,7 @@ static void gsm_dlci_t1(struct timer_list *t)
2480 + if (debug & 8)
2481 + pr_info("DLCI %d opening in ADM mode.\n",
2482 + dlci->addr);
2483 ++ dlci->mode = DLCI_MODE_ADM;
2484 + gsm_dlci_open(dlci);
2485 + } else {
2486 + gsm_dlci_close(dlci);
2487 +@@ -2861,11 +2871,22 @@ static int gsmtty_modem_update(struct gsm_dlci *dlci, u8 brk)
2488 + static int gsm_carrier_raised(struct tty_port *port)
2489 + {
2490 + struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port);
2491 ++ struct gsm_mux *gsm = dlci->gsm;
2492 ++
2493 + /* Not yet open so no carrier info */
2494 + if (dlci->state != DLCI_OPEN)
2495 + return 0;
2496 + if (debug & 2)
2497 + return 1;
2498 ++
2499 ++ /*
2500 ++ * Basic mode with control channel in ADM mode may not respond
2501 ++ * to CMD_MSC at all and modem_rx is empty.
2502 ++ */
2503 ++ if (gsm->encoding == 0 && gsm->dlci[0]->mode == DLCI_MODE_ADM &&
2504 ++ !dlci->modem_rx)
2505 ++ return 1;
2506 ++
2507 + return dlci->modem_rx & TIOCM_CD;
2508 + }
2509 +
2510 +diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
2511 +index a24278380fec..22683393a0f2 100644
2512 +--- a/drivers/tty/serial/earlycon.c
2513 ++++ b/drivers/tty/serial/earlycon.c
2514 +@@ -169,7 +169,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
2515 + */
2516 + int __init setup_earlycon(char *buf)
2517 + {
2518 +- const struct earlycon_id *match;
2519 ++ const struct earlycon_id **p_match;
2520 +
2521 + if (!buf || !buf[0])
2522 + return -EINVAL;
2523 +@@ -177,7 +177,9 @@ int __init setup_earlycon(char *buf)
2524 + if (early_con.flags & CON_ENABLED)
2525 + return -EALREADY;
2526 +
2527 +- for (match = __earlycon_table; match < __earlycon_table_end; match++) {
2528 ++ for (p_match = __earlycon_table; p_match < __earlycon_table_end;
2529 ++ p_match++) {
2530 ++ const struct earlycon_id *match = *p_match;
2531 + size_t len = strlen(match->name);
2532 +
2533 + if (strncmp(buf, match->name, len))
2534 +diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
2535 +index a100e98259d7..03d26aabb0c4 100644
2536 +--- a/drivers/tty/serial/mvebu-uart.c
2537 ++++ b/drivers/tty/serial/mvebu-uart.c
2538 +@@ -495,7 +495,6 @@ static void mvebu_uart_set_termios(struct uart_port *port,
2539 + termios->c_iflag |= old->c_iflag & ~(INPCK | IGNPAR);
2540 + termios->c_cflag &= CREAD | CBAUD;
2541 + termios->c_cflag |= old->c_cflag & ~(CREAD | CBAUD);
2542 +- termios->c_lflag = old->c_lflag;
2543 + }
2544 +
2545 + spin_unlock_irqrestore(&port->lock, flags);
2546 +diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
2547 +index 63114ea35ec1..7c838b90a31d 100644
2548 +--- a/drivers/tty/tty_io.c
2549 ++++ b/drivers/tty/tty_io.c
2550 +@@ -2816,7 +2816,10 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)
2551 +
2552 + kref_init(&tty->kref);
2553 + tty->magic = TTY_MAGIC;
2554 +- tty_ldisc_init(tty);
2555 ++ if (tty_ldisc_init(tty)) {
2556 ++ kfree(tty);
2557 ++ return NULL;
2558 ++ }
2559 + tty->session = NULL;
2560 + tty->pgrp = NULL;
2561 + mutex_init(&tty->legacy_mutex);
2562 +diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
2563 +index 050f4d650891..fb7329ab2b37 100644
2564 +--- a/drivers/tty/tty_ldisc.c
2565 ++++ b/drivers/tty/tty_ldisc.c
2566 +@@ -176,12 +176,11 @@ static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc)
2567 + return ERR_CAST(ldops);
2568 + }
2569 +
2570 +- ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL);
2571 +- if (ld == NULL) {
2572 +- put_ldops(ldops);
2573 +- return ERR_PTR(-ENOMEM);
2574 +- }
2575 +-
2576 ++ /*
2577 ++ * There is no way to handle allocation failure of only 16 bytes.
2578 ++ * Let's simplify error handling and save more memory.
2579 ++ */
2580 ++ ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL | __GFP_NOFAIL);
2581 + ld->ops = ldops;
2582 + ld->tty = tty;
2583 +
2584 +@@ -527,19 +526,16 @@ static int tty_ldisc_failto(struct tty_struct *tty, int ld)
2585 + static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old)
2586 + {
2587 + /* There is an outstanding reference here so this is safe */
2588 +- old = tty_ldisc_get(tty, old->ops->num);
2589 +- WARN_ON(IS_ERR(old));
2590 +- tty->ldisc = old;
2591 +- tty_set_termios_ldisc(tty, old->ops->num);
2592 +- if (tty_ldisc_open(tty, old) < 0) {
2593 +- tty_ldisc_put(old);
2594 ++ if (tty_ldisc_failto(tty, old->ops->num) < 0) {
2595 ++ const char *name = tty_name(tty);
2596 ++
2597 ++ pr_warn("Falling back ldisc for %s.\n", name);
2598 + /* The traditional behaviour is to fall back to N_TTY, we
2599 + want to avoid falling back to N_NULL unless we have no
2600 + choice to avoid the risk of breaking anything */
2601 + if (tty_ldisc_failto(tty, N_TTY) < 0 &&
2602 + tty_ldisc_failto(tty, N_NULL) < 0)
2603 +- panic("Couldn't open N_NULL ldisc for %s.",
2604 +- tty_name(tty));
2605 ++ panic("Couldn't open N_NULL ldisc for %s.", name);
2606 + }
2607 + }
2608 +
2609 +@@ -824,12 +820,13 @@ EXPORT_SYMBOL_GPL(tty_ldisc_release);
2610 + * the tty structure is not completely set up when this call is made.
2611 + */
2612 +
2613 +-void tty_ldisc_init(struct tty_struct *tty)
2614 ++int tty_ldisc_init(struct tty_struct *tty)
2615 + {
2616 + struct tty_ldisc *ld = tty_ldisc_get(tty, N_TTY);
2617 + if (IS_ERR(ld))
2618 +- panic("n_tty: init_tty");
2619 ++ return PTR_ERR(ld);
2620 + tty->ldisc = ld;
2621 ++ return 0;
2622 + }
2623 +
2624 + /**
2625 +diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
2626 +index fc32391a34d5..15736b462c55 100644
2627 +--- a/drivers/usb/core/hcd.c
2628 ++++ b/drivers/usb/core/hcd.c
2629 +@@ -2365,6 +2365,7 @@ void usb_hcd_resume_root_hub (struct usb_hcd *hcd)
2630 +
2631 + spin_lock_irqsave (&hcd_root_hub_lock, flags);
2632 + if (hcd->rh_registered) {
2633 ++ pm_wakeup_event(&hcd->self.root_hub->dev, 0);
2634 + set_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags);
2635 + queue_work(pm_wq, &hcd->wakeup_work);
2636 + }
2637 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
2638 +index c5c1f6cf3228..83c58a20d16f 100644
2639 +--- a/drivers/usb/core/hub.c
2640 ++++ b/drivers/usb/core/hub.c
2641 +@@ -653,12 +653,17 @@ void usb_wakeup_notification(struct usb_device *hdev,
2642 + unsigned int portnum)
2643 + {
2644 + struct usb_hub *hub;
2645 ++ struct usb_port *port_dev;
2646 +
2647 + if (!hdev)
2648 + return;
2649 +
2650 + hub = usb_hub_to_struct_hub(hdev);
2651 + if (hub) {
2652 ++ port_dev = hub->ports[portnum - 1];
2653 ++ if (port_dev && port_dev->child)
2654 ++ pm_wakeup_event(&port_dev->child->dev, 0);
2655 ++
2656 + set_bit(portnum, hub->wakeup_bits);
2657 + kick_hub_wq(hub);
2658 + }
2659 +@@ -3430,8 +3435,11 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
2660 +
2661 + /* Skip the initial Clear-Suspend step for a remote wakeup */
2662 + status = hub_port_status(hub, port1, &portstatus, &portchange);
2663 +- if (status == 0 && !port_is_suspended(hub, portstatus))
2664 ++ if (status == 0 && !port_is_suspended(hub, portstatus)) {
2665 ++ if (portchange & USB_PORT_STAT_C_SUSPEND)
2666 ++ pm_wakeup_event(&udev->dev, 0);
2667 + goto SuspendCleared;
2668 ++ }
2669 +
2670 + /* see 7.1.7.7; affects power usage, but not budgeting */
2671 + if (hub_is_superspeed(hub->hdev))
2672 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
2673 +index 54b019e267c5..9f5f78b7bb55 100644
2674 +--- a/drivers/usb/core/quirks.c
2675 ++++ b/drivers/usb/core/quirks.c
2676 +@@ -40,6 +40,9 @@ static const struct usb_device_id usb_quirk_list[] = {
2677 + { USB_DEVICE(0x03f0, 0x0701), .driver_info =
2678 + USB_QUIRK_STRING_FETCH_255 },
2679 +
2680 ++ /* HP v222w 16GB Mini USB Drive */
2681 ++ { USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT },
2682 ++
2683 + /* Creative SB Audigy 2 NX */
2684 + { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
2685 +
2686 +diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
2687 +index 75f0b92694ba..50203e77c925 100644
2688 +--- a/drivers/usb/host/xhci-dbgtty.c
2689 ++++ b/drivers/usb/host/xhci-dbgtty.c
2690 +@@ -320,9 +320,11 @@ int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci)
2691 +
2692 + void xhci_dbc_tty_unregister_driver(void)
2693 + {
2694 +- tty_unregister_driver(dbc_tty_driver);
2695 +- put_tty_driver(dbc_tty_driver);
2696 +- dbc_tty_driver = NULL;
2697 ++ if (dbc_tty_driver) {
2698 ++ tty_unregister_driver(dbc_tty_driver);
2699 ++ put_tty_driver(dbc_tty_driver);
2700 ++ dbc_tty_driver = NULL;
2701 ++ }
2702 + }
2703 +
2704 + static void dbc_rx_push(unsigned long _port)
2705 +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
2706 +index d9f831b67e57..93ce34bce7b5 100644
2707 +--- a/drivers/usb/host/xhci-pci.c
2708 ++++ b/drivers/usb/host/xhci-pci.c
2709 +@@ -126,7 +126,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
2710 + if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
2711 + xhci->quirks |= XHCI_AMD_PLL_FIX;
2712 +
2713 +- if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x43bb)
2714 ++ if (pdev->vendor == PCI_VENDOR_ID_AMD &&
2715 ++ (pdev->device == 0x15e0 ||
2716 ++ pdev->device == 0x15e1 ||
2717 ++ pdev->device == 0x43bb))
2718 + xhci->quirks |= XHCI_SUSPEND_DELAY;
2719 +
2720 + if (pdev->vendor == PCI_VENDOR_ID_AMD)
2721 +diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
2722 +index 6652e2d5bd2e..c435df29cdb8 100644
2723 +--- a/drivers/usb/host/xhci-plat.c
2724 ++++ b/drivers/usb/host/xhci-plat.c
2725 +@@ -419,7 +419,6 @@ MODULE_DEVICE_TABLE(acpi, usb_xhci_acpi_match);
2726 + static struct platform_driver usb_xhci_driver = {
2727 + .probe = xhci_plat_probe,
2728 + .remove = xhci_plat_remove,
2729 +- .shutdown = usb_hcd_platform_shutdown,
2730 + .driver = {
2731 + .name = "xhci-hcd",
2732 + .pm = &xhci_plat_pm_ops,
2733 +diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
2734 +index a646820f5a78..533f127c30ad 100644
2735 +--- a/drivers/usb/serial/Kconfig
2736 ++++ b/drivers/usb/serial/Kconfig
2737 +@@ -62,6 +62,7 @@ config USB_SERIAL_SIMPLE
2738 + - Fundamental Software dongle.
2739 + - Google USB serial devices
2740 + - HP4x calculators
2741 ++ - Libtransistor USB console
2742 + - a number of Motorola phones
2743 + - Motorola Tetra devices
2744 + - Novatel Wireless GPS receivers
2745 +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
2746 +index de1e759dd512..eb6c26cbe579 100644
2747 +--- a/drivers/usb/serial/cp210x.c
2748 ++++ b/drivers/usb/serial/cp210x.c
2749 +@@ -214,6 +214,7 @@ static const struct usb_device_id id_table[] = {
2750 + { USB_DEVICE(0x3195, 0xF190) }, /* Link Instruments MSO-19 */
2751 + { USB_DEVICE(0x3195, 0xF280) }, /* Link Instruments MSO-28 */
2752 + { USB_DEVICE(0x3195, 0xF281) }, /* Link Instruments MSO-28 */
2753 ++ { USB_DEVICE(0x3923, 0x7A0B) }, /* National Instruments USB Serial Console */
2754 + { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */
2755 + { } /* Terminating Entry */
2756 + };
2757 +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
2758 +index 87202ad5a50d..7ea221d42dba 100644
2759 +--- a/drivers/usb/serial/ftdi_sio.c
2760 ++++ b/drivers/usb/serial/ftdi_sio.c
2761 +@@ -1898,7 +1898,8 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial)
2762 + return ftdi_jtag_probe(serial);
2763 +
2764 + if (udev->product &&
2765 +- (!strcmp(udev->product, "BeagleBone/XDS100V2") ||
2766 ++ (!strcmp(udev->product, "Arrow USB Blaster") ||
2767 ++ !strcmp(udev->product, "BeagleBone/XDS100V2") ||
2768 + !strcmp(udev->product, "SNAP Connect E10")))
2769 + return ftdi_jtag_probe(serial);
2770 +
2771 +diff --git a/drivers/usb/serial/usb-serial-simple.c b/drivers/usb/serial/usb-serial-simple.c
2772 +index 4ef79e29cb26..40864c2bd9dc 100644
2773 +--- a/drivers/usb/serial/usb-serial-simple.c
2774 ++++ b/drivers/usb/serial/usb-serial-simple.c
2775 +@@ -63,6 +63,11 @@ DEVICE(flashloader, FLASHLOADER_IDS);
2776 + 0x01) }
2777 + DEVICE(google, GOOGLE_IDS);
2778 +
2779 ++/* Libtransistor USB console */
2780 ++#define LIBTRANSISTOR_IDS() \
2781 ++ { USB_DEVICE(0x1209, 0x8b00) }
2782 ++DEVICE(libtransistor, LIBTRANSISTOR_IDS);
2783 ++
2784 + /* ViVOpay USB Serial Driver */
2785 + #define VIVOPAY_IDS() \
2786 + { USB_DEVICE(0x1d5f, 0x1004) } /* ViVOpay 8800 */
2787 +@@ -110,6 +115,7 @@ static struct usb_serial_driver * const serial_drivers[] = {
2788 + &funsoft_device,
2789 + &flashloader_device,
2790 + &google_device,
2791 ++ &libtransistor_device,
2792 + &vivopay_device,
2793 + &moto_modem_device,
2794 + &motorola_tetra_device,
2795 +@@ -126,6 +132,7 @@ static const struct usb_device_id id_table[] = {
2796 + FUNSOFT_IDS(),
2797 + FLASHLOADER_IDS(),
2798 + GOOGLE_IDS(),
2799 ++ LIBTRANSISTOR_IDS(),
2800 + VIVOPAY_IDS(),
2801 + MOTO_IDS(),
2802 + MOTOROLA_TETRA_IDS(),
2803 +diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
2804 +index 79046fe66426..8d95b3a168d2 100644
2805 +--- a/drivers/usb/typec/ucsi/ucsi.c
2806 ++++ b/drivers/usb/typec/ucsi/ucsi.c
2807 +@@ -28,7 +28,7 @@
2808 + * difficult to estimate the time it takes for the system to process the command
2809 + * before it is actually passed to the PPM.
2810 + */
2811 +-#define UCSI_TIMEOUT_MS 1000
2812 ++#define UCSI_TIMEOUT_MS 5000
2813 +
2814 + /*
2815 + * UCSI_SWAP_TIMEOUT_MS - Timeout for role swap requests
2816 +diff --git a/drivers/usb/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c
2817 +index c31c8402a0c5..d41d0cdeec0f 100644
2818 +--- a/drivers/usb/usbip/stub_main.c
2819 ++++ b/drivers/usb/usbip/stub_main.c
2820 +@@ -186,7 +186,12 @@ static ssize_t rebind_store(struct device_driver *dev, const char *buf,
2821 + if (!bid)
2822 + return -ENODEV;
2823 +
2824 ++ /* device_attach() callers should hold parent lock for USB */
2825 ++ if (bid->udev->dev.parent)
2826 ++ device_lock(bid->udev->dev.parent);
2827 + ret = device_attach(&bid->udev->dev);
2828 ++ if (bid->udev->dev.parent)
2829 ++ device_unlock(bid->udev->dev.parent);
2830 + if (ret < 0) {
2831 + dev_err(&bid->udev->dev, "rebind failed\n");
2832 + return ret;
2833 +diff --git a/drivers/usb/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h
2834 +index 473fb8a87289..bf8afe9b5883 100644
2835 +--- a/drivers/usb/usbip/usbip_common.h
2836 ++++ b/drivers/usb/usbip/usbip_common.h
2837 +@@ -243,7 +243,7 @@ enum usbip_side {
2838 + #define VUDC_EVENT_ERROR_USB (USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE)
2839 + #define VUDC_EVENT_ERROR_MALLOC (USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE)
2840 +
2841 +-#define VDEV_EVENT_REMOVED (USBIP_EH_SHUTDOWN | USBIP_EH_BYE)
2842 ++#define VDEV_EVENT_REMOVED (USBIP_EH_SHUTDOWN | USBIP_EH_RESET | USBIP_EH_BYE)
2843 + #define VDEV_EVENT_DOWN (USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
2844 + #define VDEV_EVENT_ERROR_TCP (USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
2845 + #define VDEV_EVENT_ERROR_MALLOC (USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE)
2846 +diff --git a/drivers/usb/usbip/usbip_event.c b/drivers/usb/usbip/usbip_event.c
2847 +index 5b4c0864ad92..5d88917c9631 100644
2848 +--- a/drivers/usb/usbip/usbip_event.c
2849 ++++ b/drivers/usb/usbip/usbip_event.c
2850 +@@ -91,10 +91,6 @@ static void event_handler(struct work_struct *work)
2851 + unset_event(ud, USBIP_EH_UNUSABLE);
2852 + }
2853 +
2854 +- /* Stop the error handler. */
2855 +- if (ud->event & USBIP_EH_BYE)
2856 +- usbip_dbg_eh("removed %p\n", ud);
2857 +-
2858 + wake_up(&ud->eh_waitq);
2859 + }
2860 + }
2861 +diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
2862 +index 20e3d4609583..d11f3f8dad40 100644
2863 +--- a/drivers/usb/usbip/vhci_hcd.c
2864 ++++ b/drivers/usb/usbip/vhci_hcd.c
2865 +@@ -354,6 +354,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
2866 + usbip_dbg_vhci_rh(" ClearHubFeature\n");
2867 + break;
2868 + case ClearPortFeature:
2869 ++ if (rhport < 0)
2870 ++ goto error;
2871 + switch (wValue) {
2872 + case USB_PORT_FEAT_SUSPEND:
2873 + if (hcd->speed == HCD_USB3) {
2874 +@@ -511,11 +513,16 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
2875 + goto error;
2876 + }
2877 +
2878 ++ if (rhport < 0)
2879 ++ goto error;
2880 ++
2881 + vhci_hcd->port_status[rhport] |= USB_PORT_STAT_SUSPEND;
2882 + break;
2883 + case USB_PORT_FEAT_POWER:
2884 + usbip_dbg_vhci_rh(
2885 + " SetPortFeature: USB_PORT_FEAT_POWER\n");
2886 ++ if (rhport < 0)
2887 ++ goto error;
2888 + if (hcd->speed == HCD_USB3)
2889 + vhci_hcd->port_status[rhport] |= USB_SS_PORT_STAT_POWER;
2890 + else
2891 +@@ -524,6 +531,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
2892 + case USB_PORT_FEAT_BH_PORT_RESET:
2893 + usbip_dbg_vhci_rh(
2894 + " SetPortFeature: USB_PORT_FEAT_BH_PORT_RESET\n");
2895 ++ if (rhport < 0)
2896 ++ goto error;
2897 + /* Applicable only for USB3.0 hub */
2898 + if (hcd->speed != HCD_USB3) {
2899 + pr_err("USB_PORT_FEAT_BH_PORT_RESET req not "
2900 +@@ -534,6 +543,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
2901 + case USB_PORT_FEAT_RESET:
2902 + usbip_dbg_vhci_rh(
2903 + " SetPortFeature: USB_PORT_FEAT_RESET\n");
2904 ++ if (rhport < 0)
2905 ++ goto error;
2906 + /* if it's already enabled, disable */
2907 + if (hcd->speed == HCD_USB3) {
2908 + vhci_hcd->port_status[rhport] = 0;
2909 +@@ -554,6 +565,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
2910 + default:
2911 + usbip_dbg_vhci_rh(" SetPortFeature: default %d\n",
2912 + wValue);
2913 ++ if (rhport < 0)
2914 ++ goto error;
2915 + if (hcd->speed == HCD_USB3) {
2916 + if ((vhci_hcd->port_status[rhport] &
2917 + USB_SS_PORT_STAT_POWER) != 0) {
2918 +diff --git a/drivers/virt/vboxguest/vboxguest_core.c b/drivers/virt/vboxguest/vboxguest_core.c
2919 +index 190dbf8cfcb5..7411a535fda2 100644
2920 +--- a/drivers/virt/vboxguest/vboxguest_core.c
2921 ++++ b/drivers/virt/vboxguest/vboxguest_core.c
2922 +@@ -114,7 +114,7 @@ static void vbg_guest_mappings_init(struct vbg_dev *gdev)
2923 + }
2924 +
2925 + out:
2926 +- kfree(req);
2927 ++ vbg_req_free(req, sizeof(*req));
2928 + kfree(pages);
2929 + }
2930 +
2931 +@@ -144,7 +144,7 @@ static void vbg_guest_mappings_exit(struct vbg_dev *gdev)
2932 +
2933 + rc = vbg_req_perform(gdev, req);
2934 +
2935 +- kfree(req);
2936 ++ vbg_req_free(req, sizeof(*req));
2937 +
2938 + if (rc < 0) {
2939 + vbg_err("%s error: %d\n", __func__, rc);
2940 +@@ -214,8 +214,8 @@ static int vbg_report_guest_info(struct vbg_dev *gdev)
2941 + ret = vbg_status_code_to_errno(rc);
2942 +
2943 + out_free:
2944 +- kfree(req2);
2945 +- kfree(req1);
2946 ++ vbg_req_free(req2, sizeof(*req2));
2947 ++ vbg_req_free(req1, sizeof(*req1));
2948 + return ret;
2949 + }
2950 +
2951 +@@ -245,7 +245,7 @@ static int vbg_report_driver_status(struct vbg_dev *gdev, bool active)
2952 + if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
2953 + rc = VINF_SUCCESS;
2954 +
2955 +- kfree(req);
2956 ++ vbg_req_free(req, sizeof(*req));
2957 +
2958 + return vbg_status_code_to_errno(rc);
2959 + }
2960 +@@ -431,7 +431,7 @@ static int vbg_heartbeat_host_config(struct vbg_dev *gdev, bool enabled)
2961 + rc = vbg_req_perform(gdev, req);
2962 + do_div(req->interval_ns, 1000000); /* ns -> ms */
2963 + gdev->heartbeat_interval_ms = req->interval_ns;
2964 +- kfree(req);
2965 ++ vbg_req_free(req, sizeof(*req));
2966 +
2967 + return vbg_status_code_to_errno(rc);
2968 + }
2969 +@@ -454,12 +454,6 @@ static int vbg_heartbeat_init(struct vbg_dev *gdev)
2970 + if (ret < 0)
2971 + return ret;
2972 +
2973 +- /*
2974 +- * Preallocate the request to use it from the timer callback because:
2975 +- * 1) on Windows vbg_req_alloc must be called at IRQL <= APC_LEVEL
2976 +- * and the timer callback runs at DISPATCH_LEVEL;
2977 +- * 2) avoid repeated allocations.
2978 +- */
2979 + gdev->guest_heartbeat_req = vbg_req_alloc(
2980 + sizeof(*gdev->guest_heartbeat_req),
2981 + VMMDEVREQ_GUEST_HEARTBEAT);
2982 +@@ -481,8 +475,8 @@ static void vbg_heartbeat_exit(struct vbg_dev *gdev)
2983 + {
2984 + del_timer_sync(&gdev->heartbeat_timer);
2985 + vbg_heartbeat_host_config(gdev, false);
2986 +- kfree(gdev->guest_heartbeat_req);
2987 +-
2988 ++ vbg_req_free(gdev->guest_heartbeat_req,
2989 ++ sizeof(*gdev->guest_heartbeat_req));
2990 + }
2991 +
2992 + /**
2993 +@@ -543,7 +537,7 @@ static int vbg_reset_host_event_filter(struct vbg_dev *gdev,
2994 + if (rc < 0)
2995 + vbg_err("%s error, rc: %d\n", __func__, rc);
2996 +
2997 +- kfree(req);
2998 ++ vbg_req_free(req, sizeof(*req));
2999 + return vbg_status_code_to_errno(rc);
3000 + }
3001 +
3002 +@@ -617,7 +611,7 @@ static int vbg_set_session_event_filter(struct vbg_dev *gdev,
3003 +
3004 + out:
3005 + mutex_unlock(&gdev->session_mutex);
3006 +- kfree(req);
3007 ++ vbg_req_free(req, sizeof(*req));
3008 +
3009 + return ret;
3010 + }
3011 +@@ -642,7 +636,7 @@ static int vbg_reset_host_capabilities(struct vbg_dev *gdev)
3012 + if (rc < 0)
3013 + vbg_err("%s error, rc: %d\n", __func__, rc);
3014 +
3015 +- kfree(req);
3016 ++ vbg_req_free(req, sizeof(*req));
3017 + return vbg_status_code_to_errno(rc);
3018 + }
3019 +
3020 +@@ -712,7 +706,7 @@ static int vbg_set_session_capabilities(struct vbg_dev *gdev,
3021 +
3022 + out:
3023 + mutex_unlock(&gdev->session_mutex);
3024 +- kfree(req);
3025 ++ vbg_req_free(req, sizeof(*req));
3026 +
3027 + return ret;
3028 + }
3029 +@@ -749,7 +743,7 @@ static int vbg_query_host_version(struct vbg_dev *gdev)
3030 + }
3031 +
3032 + out:
3033 +- kfree(req);
3034 ++ vbg_req_free(req, sizeof(*req));
3035 + return ret;
3036 + }
3037 +
3038 +@@ -847,11 +841,16 @@ int vbg_core_init(struct vbg_dev *gdev, u32 fixed_events)
3039 + return 0;
3040 +
3041 + err_free_reqs:
3042 +- kfree(gdev->mouse_status_req);
3043 +- kfree(gdev->ack_events_req);
3044 +- kfree(gdev->cancel_req);
3045 +- kfree(gdev->mem_balloon.change_req);
3046 +- kfree(gdev->mem_balloon.get_req);
3047 ++ vbg_req_free(gdev->mouse_status_req,
3048 ++ sizeof(*gdev->mouse_status_req));
3049 ++ vbg_req_free(gdev->ack_events_req,
3050 ++ sizeof(*gdev->ack_events_req));
3051 ++ vbg_req_free(gdev->cancel_req,
3052 ++ sizeof(*gdev->cancel_req));
3053 ++ vbg_req_free(gdev->mem_balloon.change_req,
3054 ++ sizeof(*gdev->mem_balloon.change_req));
3055 ++ vbg_req_free(gdev->mem_balloon.get_req,
3056 ++ sizeof(*gdev->mem_balloon.get_req));
3057 + return ret;
3058 + }
3059 +
3060 +@@ -872,11 +871,16 @@ void vbg_core_exit(struct vbg_dev *gdev)
3061 + vbg_reset_host_capabilities(gdev);
3062 + vbg_core_set_mouse_status(gdev, 0);
3063 +
3064 +- kfree(gdev->mouse_status_req);
3065 +- kfree(gdev->ack_events_req);
3066 +- kfree(gdev->cancel_req);
3067 +- kfree(gdev->mem_balloon.change_req);
3068 +- kfree(gdev->mem_balloon.get_req);
3069 ++ vbg_req_free(gdev->mouse_status_req,
3070 ++ sizeof(*gdev->mouse_status_req));
3071 ++ vbg_req_free(gdev->ack_events_req,
3072 ++ sizeof(*gdev->ack_events_req));
3073 ++ vbg_req_free(gdev->cancel_req,
3074 ++ sizeof(*gdev->cancel_req));
3075 ++ vbg_req_free(gdev->mem_balloon.change_req,
3076 ++ sizeof(*gdev->mem_balloon.change_req));
3077 ++ vbg_req_free(gdev->mem_balloon.get_req,
3078 ++ sizeof(*gdev->mem_balloon.get_req));
3079 + }
3080 +
3081 + /**
3082 +@@ -1415,7 +1419,7 @@ static int vbg_ioctl_write_core_dump(struct vbg_dev *gdev,
3083 + req->flags = dump->u.in.flags;
3084 + dump->hdr.rc = vbg_req_perform(gdev, req);
3085 +
3086 +- kfree(req);
3087 ++ vbg_req_free(req, sizeof(*req));
3088 + return 0;
3089 + }
3090 +
3091 +@@ -1513,7 +1517,7 @@ int vbg_core_set_mouse_status(struct vbg_dev *gdev, u32 features)
3092 + if (rc < 0)
3093 + vbg_err("%s error, rc: %d\n", __func__, rc);
3094 +
3095 +- kfree(req);
3096 ++ vbg_req_free(req, sizeof(*req));
3097 + return vbg_status_code_to_errno(rc);
3098 + }
3099 +
3100 +diff --git a/drivers/virt/vboxguest/vboxguest_core.h b/drivers/virt/vboxguest/vboxguest_core.h
3101 +index 6c784bf4fa6d..7ad9ec45bfa9 100644
3102 +--- a/drivers/virt/vboxguest/vboxguest_core.h
3103 ++++ b/drivers/virt/vboxguest/vboxguest_core.h
3104 +@@ -171,4 +171,13 @@ irqreturn_t vbg_core_isr(int irq, void *dev_id);
3105 +
3106 + void vbg_linux_mouse_event(struct vbg_dev *gdev);
3107 +
3108 ++/* Private (non exported) functions form vboxguest_utils.c */
3109 ++void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type);
3110 ++void vbg_req_free(void *req, size_t len);
3111 ++int vbg_req_perform(struct vbg_dev *gdev, void *req);
3112 ++int vbg_hgcm_call32(
3113 ++ struct vbg_dev *gdev, u32 client_id, u32 function, u32 timeout_ms,
3114 ++ struct vmmdev_hgcm_function_parameter32 *parm32, u32 parm_count,
3115 ++ int *vbox_status);
3116 ++
3117 + #endif
3118 +diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
3119 +index 82e280d38cc2..398d22693234 100644
3120 +--- a/drivers/virt/vboxguest/vboxguest_linux.c
3121 ++++ b/drivers/virt/vboxguest/vboxguest_linux.c
3122 +@@ -87,6 +87,7 @@ static long vbg_misc_device_ioctl(struct file *filp, unsigned int req,
3123 + struct vbg_session *session = filp->private_data;
3124 + size_t returned_size, size;
3125 + struct vbg_ioctl_hdr hdr;
3126 ++ bool is_vmmdev_req;
3127 + int ret = 0;
3128 + void *buf;
3129 +
3130 +@@ -106,8 +107,17 @@ static long vbg_misc_device_ioctl(struct file *filp, unsigned int req,
3131 + if (size > SZ_16M)
3132 + return -E2BIG;
3133 +
3134 +- /* __GFP_DMA32 because IOCTL_VMMDEV_REQUEST passes this to the host */
3135 +- buf = kmalloc(size, GFP_KERNEL | __GFP_DMA32);
3136 ++ /*
3137 ++ * IOCTL_VMMDEV_REQUEST needs the buffer to be below 4G to avoid
3138 ++ * the need for a bounce-buffer and another copy later on.
3139 ++ */
3140 ++ is_vmmdev_req = (req & ~IOCSIZE_MASK) == VBG_IOCTL_VMMDEV_REQUEST(0) ||
3141 ++ req == VBG_IOCTL_VMMDEV_REQUEST_BIG;
3142 ++
3143 ++ if (is_vmmdev_req)
3144 ++ buf = vbg_req_alloc(size, VBG_IOCTL_HDR_TYPE_DEFAULT);
3145 ++ else
3146 ++ buf = kmalloc(size, GFP_KERNEL);
3147 + if (!buf)
3148 + return -ENOMEM;
3149 +
3150 +@@ -132,7 +142,10 @@ static long vbg_misc_device_ioctl(struct file *filp, unsigned int req,
3151 + ret = -EFAULT;
3152 +
3153 + out:
3154 +- kfree(buf);
3155 ++ if (is_vmmdev_req)
3156 ++ vbg_req_free(buf, size);
3157 ++ else
3158 ++ kfree(buf);
3159 +
3160 + return ret;
3161 + }
3162 +diff --git a/drivers/virt/vboxguest/vboxguest_utils.c b/drivers/virt/vboxguest/vboxguest_utils.c
3163 +index 0f0dab8023cf..bf4474214b4d 100644
3164 +--- a/drivers/virt/vboxguest/vboxguest_utils.c
3165 ++++ b/drivers/virt/vboxguest/vboxguest_utils.c
3166 +@@ -65,8 +65,9 @@ VBG_LOG(vbg_debug, pr_debug);
3167 + void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type)
3168 + {
3169 + struct vmmdev_request_header *req;
3170 ++ int order = get_order(PAGE_ALIGN(len));
3171 +
3172 +- req = kmalloc(len, GFP_KERNEL | __GFP_DMA32);
3173 ++ req = (void *)__get_free_pages(GFP_KERNEL | GFP_DMA32, order);
3174 + if (!req)
3175 + return NULL;
3176 +
3177 +@@ -82,6 +83,14 @@ void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type)
3178 + return req;
3179 + }
3180 +
3181 ++void vbg_req_free(void *req, size_t len)
3182 ++{
3183 ++ if (!req)
3184 ++ return;
3185 ++
3186 ++ free_pages((unsigned long)req, get_order(PAGE_ALIGN(len)));
3187 ++}
3188 ++
3189 + /* Note this function returns a VBox status code, not a negative errno!! */
3190 + int vbg_req_perform(struct vbg_dev *gdev, void *req)
3191 + {
3192 +@@ -137,7 +146,7 @@ int vbg_hgcm_connect(struct vbg_dev *gdev,
3193 + rc = hgcm_connect->header.result;
3194 + }
3195 +
3196 +- kfree(hgcm_connect);
3197 ++ vbg_req_free(hgcm_connect, sizeof(*hgcm_connect));
3198 +
3199 + *vbox_status = rc;
3200 + return 0;
3201 +@@ -166,7 +175,7 @@ int vbg_hgcm_disconnect(struct vbg_dev *gdev, u32 client_id, int *vbox_status)
3202 + if (rc >= 0)
3203 + rc = hgcm_disconnect->header.result;
3204 +
3205 +- kfree(hgcm_disconnect);
3206 ++ vbg_req_free(hgcm_disconnect, sizeof(*hgcm_disconnect));
3207 +
3208 + *vbox_status = rc;
3209 + return 0;
3210 +@@ -623,7 +632,7 @@ int vbg_hgcm_call(struct vbg_dev *gdev, u32 client_id, u32 function,
3211 + }
3212 +
3213 + if (!leak_it)
3214 +- kfree(call);
3215 ++ vbg_req_free(call, size);
3216 +
3217 + free_bounce_bufs:
3218 + if (bounce_bufs) {
3219 +diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
3220 +index 9ceebf30eb22..a82f91d75f29 100644
3221 +--- a/fs/cifs/cifssmb.c
3222 ++++ b/fs/cifs/cifssmb.c
3223 +@@ -453,6 +453,9 @@ cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required)
3224 + server->sign = true;
3225 + }
3226 +
3227 ++ if (cifs_rdma_enabled(server) && server->sign)
3228 ++ cifs_dbg(VFS, "Signing is enabled, and RDMA read/write will be disabled");
3229 ++
3230 + return 0;
3231 + }
3232 +
3233 +diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
3234 +index dfd6fb02b7a3..1c1940d90c96 100644
3235 +--- a/fs/cifs/smb2ops.c
3236 ++++ b/fs/cifs/smb2ops.c
3237 +@@ -252,9 +252,14 @@ smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
3238 + wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE;
3239 + wsize = min_t(unsigned int, wsize, server->max_write);
3240 + #ifdef CONFIG_CIFS_SMB_DIRECT
3241 +- if (server->rdma)
3242 +- wsize = min_t(unsigned int,
3243 ++ if (server->rdma) {
3244 ++ if (server->sign)
3245 ++ wsize = min_t(unsigned int,
3246 ++ wsize, server->smbd_conn->max_fragmented_send_size);
3247 ++ else
3248 ++ wsize = min_t(unsigned int,
3249 + wsize, server->smbd_conn->max_readwrite_size);
3250 ++ }
3251 + #endif
3252 + if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
3253 + wsize = min_t(unsigned int, wsize, SMB2_MAX_BUFFER_SIZE);
3254 +@@ -272,9 +277,14 @@ smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
3255 + rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE;
3256 + rsize = min_t(unsigned int, rsize, server->max_read);
3257 + #ifdef CONFIG_CIFS_SMB_DIRECT
3258 +- if (server->rdma)
3259 +- rsize = min_t(unsigned int,
3260 ++ if (server->rdma) {
3261 ++ if (server->sign)
3262 ++ rsize = min_t(unsigned int,
3263 ++ rsize, server->smbd_conn->max_fragmented_recv_size);
3264 ++ else
3265 ++ rsize = min_t(unsigned int,
3266 + rsize, server->smbd_conn->max_readwrite_size);
3267 ++ }
3268 + #endif
3269 +
3270 + if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
3271 +diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
3272 +index af62c75b17c4..8ae6a089489c 100644
3273 +--- a/fs/cifs/smb2pdu.c
3274 ++++ b/fs/cifs/smb2pdu.c
3275 +@@ -2479,7 +2479,7 @@ smb2_new_read_req(void **buf, unsigned int *total_len,
3276 + * If we want to do a RDMA write, fill in and append
3277 + * smbd_buffer_descriptor_v1 to the end of read request
3278 + */
3279 +- if (server->rdma && rdata &&
3280 ++ if (server->rdma && rdata && !server->sign &&
3281 + rdata->bytes >= server->smbd_conn->rdma_readwrite_threshold) {
3282 +
3283 + struct smbd_buffer_descriptor_v1 *v1;
3284 +@@ -2857,7 +2857,7 @@ smb2_async_writev(struct cifs_writedata *wdata,
3285 + * If we want to do a server RDMA read, fill in and append
3286 + * smbd_buffer_descriptor_v1 to the end of write request
3287 + */
3288 +- if (server->rdma && wdata->bytes >=
3289 ++ if (server->rdma && !server->sign && wdata->bytes >=
3290 + server->smbd_conn->rdma_readwrite_threshold) {
3291 +
3292 + struct smbd_buffer_descriptor_v1 *v1;
3293 +diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c
3294 +index 34be5c5d027f..608ce9abd240 100644
3295 +--- a/fs/cifs/smbdirect.c
3296 ++++ b/fs/cifs/smbdirect.c
3297 +@@ -2086,7 +2086,7 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
3298 + int start, i, j;
3299 + int max_iov_size =
3300 + info->max_send_size - sizeof(struct smbd_data_transfer);
3301 +- struct kvec iov[SMBDIRECT_MAX_SGE];
3302 ++ struct kvec *iov;
3303 + int rc;
3304 +
3305 + info->smbd_send_pending++;
3306 +@@ -2096,32 +2096,20 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
3307 + }
3308 +
3309 + /*
3310 +- * This usually means a configuration error
3311 +- * We use RDMA read/write for packet size > rdma_readwrite_threshold
3312 +- * as long as it's properly configured we should never get into this
3313 +- * situation
3314 +- */
3315 +- if (rqst->rq_nvec + rqst->rq_npages > SMBDIRECT_MAX_SGE) {
3316 +- log_write(ERR, "maximum send segment %x exceeding %x\n",
3317 +- rqst->rq_nvec + rqst->rq_npages, SMBDIRECT_MAX_SGE);
3318 +- rc = -EINVAL;
3319 +- goto done;
3320 +- }
3321 +-
3322 +- /*
3323 +- * Remove the RFC1002 length defined in MS-SMB2 section 2.1
3324 +- * It is used only for TCP transport
3325 ++ * Skip the RFC1002 length defined in MS-SMB2 section 2.1
3326 ++ * It is used only for TCP transport in the iov[0]
3327 + * In future we may want to add a transport layer under protocol
3328 + * layer so this will only be issued to TCP transport
3329 + */
3330 +- iov[0].iov_base = (char *)rqst->rq_iov[0].iov_base + 4;
3331 +- iov[0].iov_len = rqst->rq_iov[0].iov_len - 4;
3332 +- buflen += iov[0].iov_len;
3333 ++
3334 ++ if (rqst->rq_iov[0].iov_len != 4) {
3335 ++ log_write(ERR, "expected the pdu length in 1st iov, but got %zu\n", rqst->rq_iov[0].iov_len);
3336 ++ return -EINVAL;
3337 ++ }
3338 ++ iov = &rqst->rq_iov[1];
3339 +
3340 + /* total up iov array first */
3341 +- for (i = 1; i < rqst->rq_nvec; i++) {
3342 +- iov[i].iov_base = rqst->rq_iov[i].iov_base;
3343 +- iov[i].iov_len = rqst->rq_iov[i].iov_len;
3344 ++ for (i = 0; i < rqst->rq_nvec-1; i++) {
3345 + buflen += iov[i].iov_len;
3346 + }
3347 +
3348 +@@ -2194,14 +2182,14 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
3349 + goto done;
3350 + }
3351 + i++;
3352 +- if (i == rqst->rq_nvec)
3353 ++ if (i == rqst->rq_nvec-1)
3354 + break;
3355 + }
3356 + start = i;
3357 + buflen = 0;
3358 + } else {
3359 + i++;
3360 +- if (i == rqst->rq_nvec) {
3361 ++ if (i == rqst->rq_nvec-1) {
3362 + /* send out all remaining vecs */
3363 + remaining_data_length -= buflen;
3364 + log_write(INFO,
3365 +diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
3366 +index 665661464067..1b5cd3b8617c 100644
3367 +--- a/fs/cifs/transport.c
3368 ++++ b/fs/cifs/transport.c
3369 +@@ -753,7 +753,7 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
3370 + goto out;
3371 +
3372 + #ifdef CONFIG_CIFS_SMB311
3373 +- if (ses->status == CifsNew)
3374 ++ if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP))
3375 + smb311_update_preauth_hash(ses, rqst->rq_iov+1,
3376 + rqst->rq_nvec-1);
3377 + #endif
3378 +@@ -797,7 +797,7 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
3379 + *resp_buf_type = CIFS_SMALL_BUFFER;
3380 +
3381 + #ifdef CONFIG_CIFS_SMB311
3382 +- if (ses->status == CifsNew) {
3383 ++ if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP)) {
3384 + struct kvec iov = {
3385 + .iov_base = buf + 4,
3386 + .iov_len = get_rfc1002_length(buf)
3387 +diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
3388 +index f82c4966f4ce..508b905d744d 100644
3389 +--- a/fs/ext4/balloc.c
3390 ++++ b/fs/ext4/balloc.c
3391 +@@ -321,6 +321,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
3392 + struct ext4_sb_info *sbi = EXT4_SB(sb);
3393 + ext4_grpblk_t offset;
3394 + ext4_grpblk_t next_zero_bit;
3395 ++ ext4_grpblk_t max_bit = EXT4_CLUSTERS_PER_GROUP(sb);
3396 + ext4_fsblk_t blk;
3397 + ext4_fsblk_t group_first_block;
3398 +
3399 +@@ -338,20 +339,25 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
3400 + /* check whether block bitmap block number is set */
3401 + blk = ext4_block_bitmap(sb, desc);
3402 + offset = blk - group_first_block;
3403 +- if (!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
3404 ++ if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
3405 ++ !ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
3406 + /* bad block bitmap */
3407 + return blk;
3408 +
3409 + /* check whether the inode bitmap block number is set */
3410 + blk = ext4_inode_bitmap(sb, desc);
3411 + offset = blk - group_first_block;
3412 +- if (!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
3413 ++ if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
3414 ++ !ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
3415 + /* bad block bitmap */
3416 + return blk;
3417 +
3418 + /* check whether the inode table block number is set */
3419 + blk = ext4_inode_table(sb, desc);
3420 + offset = blk - group_first_block;
3421 ++ if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
3422 ++ EXT4_B2C(sbi, offset + sbi->s_itb_per_group) >= max_bit)
3423 ++ return blk;
3424 + next_zero_bit = ext4_find_next_zero_bit(bh->b_data,
3425 + EXT4_B2C(sbi, offset + sbi->s_itb_per_group),
3426 + EXT4_B2C(sbi, offset));
3427 +@@ -417,6 +423,7 @@ struct buffer_head *
3428 + ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
3429 + {
3430 + struct ext4_group_desc *desc;
3431 ++ struct ext4_sb_info *sbi = EXT4_SB(sb);
3432 + struct buffer_head *bh;
3433 + ext4_fsblk_t bitmap_blk;
3434 + int err;
3435 +@@ -425,6 +432,12 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
3436 + if (!desc)
3437 + return ERR_PTR(-EFSCORRUPTED);
3438 + bitmap_blk = ext4_block_bitmap(sb, desc);
3439 ++ if ((bitmap_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) ||
3440 ++ (bitmap_blk >= ext4_blocks_count(sbi->s_es))) {
3441 ++ ext4_error(sb, "Invalid block bitmap block %llu in "
3442 ++ "block_group %u", bitmap_blk, block_group);
3443 ++ return ERR_PTR(-EFSCORRUPTED);
3444 ++ }
3445 + bh = sb_getblk(sb, bitmap_blk);
3446 + if (unlikely(!bh)) {
3447 + ext4_error(sb, "Cannot get buffer for block bitmap - "
3448 +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
3449 +index 054416e9d827..a7ca193a7480 100644
3450 +--- a/fs/ext4/extents.c
3451 ++++ b/fs/ext4/extents.c
3452 +@@ -5334,8 +5334,9 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
3453 + stop = le32_to_cpu(extent->ee_block);
3454 +
3455 + /*
3456 +- * In case of left shift, Don't start shifting extents until we make
3457 +- * sure the hole is big enough to accommodate the shift.
3458 ++ * For left shifts, make sure the hole on the left is big enough to
3459 ++ * accommodate the shift. For right shifts, make sure the last extent
3460 ++ * won't be shifted beyond EXT_MAX_BLOCKS.
3461 + */
3462 + if (SHIFT == SHIFT_LEFT) {
3463 + path = ext4_find_extent(inode, start - 1, &path,
3464 +@@ -5355,9 +5356,14 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
3465 +
3466 + if ((start == ex_start && shift > ex_start) ||
3467 + (shift > start - ex_end)) {
3468 +- ext4_ext_drop_refs(path);
3469 +- kfree(path);
3470 +- return -EINVAL;
3471 ++ ret = -EINVAL;
3472 ++ goto out;
3473 ++ }
3474 ++ } else {
3475 ++ if (shift > EXT_MAX_BLOCKS -
3476 ++ (stop + ext4_ext_get_actual_len(extent))) {
3477 ++ ret = -EINVAL;
3478 ++ goto out;
3479 + }
3480 + }
3481 +
3482 +diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
3483 +index 3fa93665b4a3..df92e3ec9913 100644
3484 +--- a/fs/ext4/ialloc.c
3485 ++++ b/fs/ext4/ialloc.c
3486 +@@ -122,6 +122,7 @@ static struct buffer_head *
3487 + ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
3488 + {
3489 + struct ext4_group_desc *desc;
3490 ++ struct ext4_sb_info *sbi = EXT4_SB(sb);
3491 + struct buffer_head *bh = NULL;
3492 + ext4_fsblk_t bitmap_blk;
3493 + int err;
3494 +@@ -131,6 +132,12 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
3495 + return ERR_PTR(-EFSCORRUPTED);
3496 +
3497 + bitmap_blk = ext4_inode_bitmap(sb, desc);
3498 ++ if ((bitmap_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) ||
3499 ++ (bitmap_blk >= ext4_blocks_count(sbi->s_es))) {
3500 ++ ext4_error(sb, "Invalid inode bitmap blk %llu in "
3501 ++ "block_group %u", bitmap_blk, block_group);
3502 ++ return ERR_PTR(-EFSCORRUPTED);
3503 ++ }
3504 + bh = sb_getblk(sb, bitmap_blk);
3505 + if (unlikely(!bh)) {
3506 + ext4_error(sb, "Cannot read inode bitmap - "
3507 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
3508 +index 192c5ad09d71..b8dace7abe09 100644
3509 +--- a/fs/ext4/super.c
3510 ++++ b/fs/ext4/super.c
3511 +@@ -5868,5 +5868,6 @@ static void __exit ext4_exit_fs(void)
3512 + MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
3513 + MODULE_DESCRIPTION("Fourth Extended Filesystem");
3514 + MODULE_LICENSE("GPL");
3515 ++MODULE_SOFTDEP("pre: crc32c");
3516 + module_init(ext4_init_fs)
3517 + module_exit(ext4_exit_fs)
3518 +diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
3519 +index ac311037d7a5..8aa453784402 100644
3520 +--- a/fs/jbd2/transaction.c
3521 ++++ b/fs/jbd2/transaction.c
3522 +@@ -532,6 +532,7 @@ int jbd2_journal_start_reserved(handle_t *handle, unsigned int type,
3523 + */
3524 + ret = start_this_handle(journal, handle, GFP_NOFS);
3525 + if (ret < 0) {
3526 ++ handle->h_journal = journal;
3527 + jbd2_journal_free_reserved(handle);
3528 + return ret;
3529 + }
3530 +diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
3531 +index 1ab0e520d6fc..e17de55c2542 100644
3532 +--- a/include/asm-generic/vmlinux.lds.h
3533 ++++ b/include/asm-generic/vmlinux.lds.h
3534 +@@ -179,7 +179,7 @@
3535 + #endif
3536 +
3537 + #ifdef CONFIG_SERIAL_EARLYCON
3538 +-#define EARLYCON_TABLE() STRUCT_ALIGN(); \
3539 ++#define EARLYCON_TABLE() . = ALIGN(8); \
3540 + VMLINUX_SYMBOL(__earlycon_table) = .; \
3541 + KEEP(*(__earlycon_table)) \
3542 + VMLINUX_SYMBOL(__earlycon_table_end) = .;
3543 +diff --git a/include/kvm/arm_psci.h b/include/kvm/arm_psci.h
3544 +index e518e4e3dfb5..4b1548129fa2 100644
3545 +--- a/include/kvm/arm_psci.h
3546 ++++ b/include/kvm/arm_psci.h
3547 +@@ -37,10 +37,15 @@ static inline int kvm_psci_version(struct kvm_vcpu *vcpu, struct kvm *kvm)
3548 + * Our PSCI implementation stays the same across versions from
3549 + * v0.2 onward, only adding the few mandatory functions (such
3550 + * as FEATURES with 1.0) that are required by newer
3551 +- * revisions. It is thus safe to return the latest.
3552 ++ * revisions. It is thus safe to return the latest, unless
3553 ++ * userspace has instructed us otherwise.
3554 + */
3555 +- if (test_bit(KVM_ARM_VCPU_PSCI_0_2, vcpu->arch.features))
3556 ++ if (test_bit(KVM_ARM_VCPU_PSCI_0_2, vcpu->arch.features)) {
3557 ++ if (vcpu->kvm->arch.psci_version)
3558 ++ return vcpu->kvm->arch.psci_version;
3559 ++
3560 + return KVM_ARM_PSCI_LATEST;
3561 ++ }
3562 +
3563 + return KVM_ARM_PSCI_0_1;
3564 + }
3565 +@@ -48,4 +53,11 @@ static inline int kvm_psci_version(struct kvm_vcpu *vcpu, struct kvm *kvm)
3566 +
3567 + int kvm_hvc_call_handler(struct kvm_vcpu *vcpu);
3568 +
3569 ++struct kvm_one_reg;
3570 ++
3571 ++int kvm_arm_get_fw_num_regs(struct kvm_vcpu *vcpu);
3572 ++int kvm_arm_copy_fw_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices);
3573 ++int kvm_arm_get_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg);
3574 ++int kvm_arm_set_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg);
3575 ++
3576 + #endif /* __KVM_ARM_PSCI_H__ */
3577 +diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
3578 +index ed63f3b69c12..c9e601dce06f 100644
3579 +--- a/include/linux/blkdev.h
3580 ++++ b/include/linux/blkdev.h
3581 +@@ -605,6 +605,11 @@ struct request_queue {
3582 + * initialized by the low level device driver (e.g. scsi/sd.c).
3583 + * Stacking drivers (device mappers) may or may not initialize
3584 + * these fields.
3585 ++ *
3586 ++ * Reads of this information must be protected with blk_queue_enter() /
3587 ++ * blk_queue_exit(). Modifying this information is only allowed while
3588 ++ * no requests are being processed. See also blk_mq_freeze_queue() and
3589 ++ * blk_mq_unfreeze_queue().
3590 + */
3591 + unsigned int nr_zones;
3592 + unsigned long *seq_zones_bitmap;
3593 +diff --git a/include/linux/mtd/flashchip.h b/include/linux/mtd/flashchip.h
3594 +index b63fa457febd..3529683f691e 100644
3595 +--- a/include/linux/mtd/flashchip.h
3596 ++++ b/include/linux/mtd/flashchip.h
3597 +@@ -85,6 +85,7 @@ struct flchip {
3598 + unsigned int write_suspended:1;
3599 + unsigned int erase_suspended:1;
3600 + unsigned long in_progress_block_addr;
3601 ++ unsigned long in_progress_block_mask;
3602 +
3603 + struct mutex mutex;
3604 + wait_queue_head_t wq; /* Wait on here when we're waiting for the chip
3605 +diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
3606 +index b32df49a3bd5..c4219b9cbb70 100644
3607 +--- a/include/linux/serial_core.h
3608 ++++ b/include/linux/serial_core.h
3609 +@@ -351,10 +351,10 @@ struct earlycon_id {
3610 + char name[16];
3611 + char compatible[128];
3612 + int (*setup)(struct earlycon_device *, const char *options);
3613 +-} __aligned(32);
3614 ++};
3615 +
3616 +-extern const struct earlycon_id __earlycon_table[];
3617 +-extern const struct earlycon_id __earlycon_table_end[];
3618 ++extern const struct earlycon_id *__earlycon_table[];
3619 ++extern const struct earlycon_id *__earlycon_table_end[];
3620 +
3621 + #if defined(CONFIG_SERIAL_EARLYCON) && !defined(MODULE)
3622 + #define EARLYCON_USED_OR_UNUSED __used
3623 +@@ -362,12 +362,19 @@ extern const struct earlycon_id __earlycon_table_end[];
3624 + #define EARLYCON_USED_OR_UNUSED __maybe_unused
3625 + #endif
3626 +
3627 +-#define OF_EARLYCON_DECLARE(_name, compat, fn) \
3628 +- static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name) \
3629 +- EARLYCON_USED_OR_UNUSED __section(__earlycon_table) \
3630 ++#define _OF_EARLYCON_DECLARE(_name, compat, fn, unique_id) \
3631 ++ static const struct earlycon_id unique_id \
3632 ++ EARLYCON_USED_OR_UNUSED __initconst \
3633 + = { .name = __stringify(_name), \
3634 + .compatible = compat, \
3635 +- .setup = fn }
3636 ++ .setup = fn }; \
3637 ++ static const struct earlycon_id EARLYCON_USED_OR_UNUSED \
3638 ++ __section(__earlycon_table) \
3639 ++ * const __PASTE(__p, unique_id) = &unique_id
3640 ++
3641 ++#define OF_EARLYCON_DECLARE(_name, compat, fn) \
3642 ++ _OF_EARLYCON_DECLARE(_name, compat, fn, \
3643 ++ __UNIQUE_ID(__earlycon_##_name))
3644 +
3645 + #define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)
3646 +
3647 +diff --git a/include/linux/tty.h b/include/linux/tty.h
3648 +index 47f8af22f216..1dd587ba6d88 100644
3649 +--- a/include/linux/tty.h
3650 ++++ b/include/linux/tty.h
3651 +@@ -701,7 +701,7 @@ extern int tty_unregister_ldisc(int disc);
3652 + extern int tty_set_ldisc(struct tty_struct *tty, int disc);
3653 + extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty);
3654 + extern void tty_ldisc_release(struct tty_struct *tty);
3655 +-extern void tty_ldisc_init(struct tty_struct *tty);
3656 ++extern int __must_check tty_ldisc_init(struct tty_struct *tty);
3657 + extern void tty_ldisc_deinit(struct tty_struct *tty);
3658 + extern int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p,
3659 + char *f, int count);
3660 +diff --git a/include/linux/vbox_utils.h b/include/linux/vbox_utils.h
3661 +index c71def6b310f..a240ed2a0372 100644
3662 +--- a/include/linux/vbox_utils.h
3663 ++++ b/include/linux/vbox_utils.h
3664 +@@ -24,24 +24,6 @@ __printf(1, 2) void vbg_debug(const char *fmt, ...);
3665 + #define vbg_debug pr_debug
3666 + #endif
3667 +
3668 +-/**
3669 +- * Allocate memory for generic request and initialize the request header.
3670 +- *
3671 +- * Return: the allocated memory
3672 +- * @len: Size of memory block required for the request.
3673 +- * @req_type: The generic request type.
3674 +- */
3675 +-void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type);
3676 +-
3677 +-/**
3678 +- * Perform a generic request.
3679 +- *
3680 +- * Return: VBox status code
3681 +- * @gdev: The Guest extension device.
3682 +- * @req: Pointer to the request structure.
3683 +- */
3684 +-int vbg_req_perform(struct vbg_dev *gdev, void *req);
3685 +-
3686 + int vbg_hgcm_connect(struct vbg_dev *gdev,
3687 + struct vmmdev_hgcm_service_location *loc,
3688 + u32 *client_id, int *vbox_status);
3689 +@@ -52,11 +34,6 @@ int vbg_hgcm_call(struct vbg_dev *gdev, u32 client_id, u32 function,
3690 + u32 timeout_ms, struct vmmdev_hgcm_function_parameter *parms,
3691 + u32 parm_count, int *vbox_status);
3692 +
3693 +-int vbg_hgcm_call32(
3694 +- struct vbg_dev *gdev, u32 client_id, u32 function, u32 timeout_ms,
3695 +- struct vmmdev_hgcm_function_parameter32 *parm32, u32 parm_count,
3696 +- int *vbox_status);
3697 +-
3698 + /**
3699 + * Convert a VirtualBox status code to a standard Linux kernel return value.
3700 + * Return: 0 or negative errno value.
3701 +diff --git a/include/linux/virtio.h b/include/linux/virtio.h
3702 +index 988c7355bc22..fa1b5da2804e 100644
3703 +--- a/include/linux/virtio.h
3704 ++++ b/include/linux/virtio.h
3705 +@@ -157,6 +157,9 @@ int virtio_device_freeze(struct virtio_device *dev);
3706 + int virtio_device_restore(struct virtio_device *dev);
3707 + #endif
3708 +
3709 ++#define virtio_device_for_each_vq(vdev, vq) \
3710 ++ list_for_each_entry(vq, &vdev->vqs, list)
3711 ++
3712 + /**
3713 + * virtio_driver - operations for a virtio I/O driver
3714 + * @driver: underlying device driver (populate name and owner).
3715 +diff --git a/include/sound/control.h b/include/sound/control.h
3716 +index ca13a44ae9d4..6011a58d3e20 100644
3717 +--- a/include/sound/control.h
3718 ++++ b/include/sound/control.h
3719 +@@ -23,6 +23,7 @@
3720 + */
3721 +
3722 + #include <linux/wait.h>
3723 ++#include <linux/nospec.h>
3724 + #include <sound/asound.h>
3725 +
3726 + #define snd_kcontrol_chip(kcontrol) ((kcontrol)->private_data)
3727 +@@ -148,12 +149,14 @@ int snd_ctl_get_preferred_subdevice(struct snd_card *card, int type);
3728 +
3729 + static inline unsigned int snd_ctl_get_ioffnum(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
3730 + {
3731 +- return id->numid - kctl->id.numid;
3732 ++ unsigned int ioff = id->numid - kctl->id.numid;
3733 ++ return array_index_nospec(ioff, kctl->count);
3734 + }
3735 +
3736 + static inline unsigned int snd_ctl_get_ioffidx(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
3737 + {
3738 +- return id->index - kctl->id.index;
3739 ++ unsigned int ioff = id->index - kctl->id.index;
3740 ++ return array_index_nospec(ioff, kctl->count);
3741 + }
3742 +
3743 + static inline unsigned int snd_ctl_get_ioff(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
3744 +diff --git a/kernel/module.c b/kernel/module.c
3745 +index e42764acedb4..bbb45c038321 100644
3746 +--- a/kernel/module.c
3747 ++++ b/kernel/module.c
3748 +@@ -1472,7 +1472,8 @@ static ssize_t module_sect_show(struct module_attribute *mattr,
3749 + {
3750 + struct module_sect_attr *sattr =
3751 + container_of(mattr, struct module_sect_attr, mattr);
3752 +- return sprintf(buf, "0x%pK\n", (void *)sattr->address);
3753 ++ return sprintf(buf, "0x%px\n", kptr_restrict < 2 ?
3754 ++ (void *)sattr->address : NULL);
3755 + }
3756 +
3757 + static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
3758 +diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
3759 +index 29a5733eff83..741eadbeba58 100644
3760 +--- a/kernel/time/tick-sched.c
3761 ++++ b/kernel/time/tick-sched.c
3762 +@@ -797,12 +797,13 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
3763 + goto out;
3764 + }
3765 +
3766 +- hrtimer_set_expires(&ts->sched_timer, tick);
3767 +-
3768 +- if (ts->nohz_mode == NOHZ_MODE_HIGHRES)
3769 +- hrtimer_start_expires(&ts->sched_timer, HRTIMER_MODE_ABS_PINNED);
3770 +- else
3771 ++ if (ts->nohz_mode == NOHZ_MODE_HIGHRES) {
3772 ++ hrtimer_start(&ts->sched_timer, tick, HRTIMER_MODE_ABS_PINNED);
3773 ++ } else {
3774 ++ hrtimer_set_expires(&ts->sched_timer, tick);
3775 + tick_program_event(tick, 1);
3776 ++ }
3777 ++
3778 + out:
3779 + /*
3780 + * Update the estimated sleep length until the next timer
3781 +diff --git a/lib/kobject.c b/lib/kobject.c
3782 +index afd5a3fc6123..d20a97a7e168 100644
3783 +--- a/lib/kobject.c
3784 ++++ b/lib/kobject.c
3785 +@@ -232,14 +232,12 @@ static int kobject_add_internal(struct kobject *kobj)
3786 +
3787 + /* be noisy on error issues */
3788 + if (error == -EEXIST)
3789 +- WARN(1, "%s failed for %s with "
3790 +- "-EEXIST, don't try to register things with "
3791 +- "the same name in the same directory.\n",
3792 +- __func__, kobject_name(kobj));
3793 ++ pr_err("%s failed for %s with -EEXIST, don't try to register things with the same name in the same directory.\n",
3794 ++ __func__, kobject_name(kobj));
3795 + else
3796 +- WARN(1, "%s failed for %s (error: %d parent: %s)\n",
3797 +- __func__, kobject_name(kobj), error,
3798 +- parent ? kobject_name(parent) : "'none'");
3799 ++ pr_err("%s failed for %s (error: %d parent: %s)\n",
3800 ++ __func__, kobject_name(kobj), error,
3801 ++ parent ? kobject_name(parent) : "'none'");
3802 + } else
3803 + kobj->state_in_sysfs = 1;
3804 +
3805 +diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
3806 +index 8a4d3758030b..02572130a77a 100644
3807 +--- a/net/ceph/messenger.c
3808 ++++ b/net/ceph/messenger.c
3809 +@@ -2531,6 +2531,11 @@ static int try_write(struct ceph_connection *con)
3810 + int ret = 1;
3811 +
3812 + dout("try_write start %p state %lu\n", con, con->state);
3813 ++ if (con->state != CON_STATE_PREOPEN &&
3814 ++ con->state != CON_STATE_CONNECTING &&
3815 ++ con->state != CON_STATE_NEGOTIATING &&
3816 ++ con->state != CON_STATE_OPEN)
3817 ++ return 0;
3818 +
3819 + more:
3820 + dout("try_write out_kvec_bytes %d\n", con->out_kvec_bytes);
3821 +@@ -2556,6 +2561,8 @@ static int try_write(struct ceph_connection *con)
3822 + }
3823 +
3824 + more_kvec:
3825 ++ BUG_ON(!con->sock);
3826 ++
3827 + /* kvec data queued? */
3828 + if (con->out_kvec_left) {
3829 + ret = write_partial_kvec(con);
3830 +diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
3831 +index 1547107f4854..4887443f52dd 100644
3832 +--- a/net/ceph/mon_client.c
3833 ++++ b/net/ceph/mon_client.c
3834 +@@ -209,6 +209,14 @@ static void reopen_session(struct ceph_mon_client *monc)
3835 + __open_session(monc);
3836 + }
3837 +
3838 ++static void un_backoff(struct ceph_mon_client *monc)
3839 ++{
3840 ++ monc->hunt_mult /= 2; /* reduce by 50% */
3841 ++ if (monc->hunt_mult < 1)
3842 ++ monc->hunt_mult = 1;
3843 ++ dout("%s hunt_mult now %d\n", __func__, monc->hunt_mult);
3844 ++}
3845 ++
3846 + /*
3847 + * Reschedule delayed work timer.
3848 + */
3849 +@@ -963,6 +971,7 @@ static void delayed_work(struct work_struct *work)
3850 + if (!monc->hunting) {
3851 + ceph_con_keepalive(&monc->con);
3852 + __validate_auth(monc);
3853 ++ un_backoff(monc);
3854 + }
3855 +
3856 + if (is_auth &&
3857 +@@ -1123,9 +1132,8 @@ static void finish_hunting(struct ceph_mon_client *monc)
3858 + dout("%s found mon%d\n", __func__, monc->cur_mon);
3859 + monc->hunting = false;
3860 + monc->had_a_connection = true;
3861 +- monc->hunt_mult /= 2; /* reduce by 50% */
3862 +- if (monc->hunt_mult < 1)
3863 +- monc->hunt_mult = 1;
3864 ++ un_backoff(monc);
3865 ++ __schedule_delayed(monc);
3866 + }
3867 + }
3868 +
3869 +diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
3870 +index b719d0bd833e..06d7c40af570 100644
3871 +--- a/sound/core/pcm_compat.c
3872 ++++ b/sound/core/pcm_compat.c
3873 +@@ -27,10 +27,11 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
3874 + s32 __user *src)
3875 + {
3876 + snd_pcm_sframes_t delay;
3877 ++ int err;
3878 +
3879 +- delay = snd_pcm_delay(substream);
3880 +- if (delay < 0)
3881 +- return delay;
3882 ++ err = snd_pcm_delay(substream, &delay);
3883 ++ if (err)
3884 ++ return err;
3885 + if (put_user(delay, src))
3886 + return -EFAULT;
3887 + return 0;
3888 +diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
3889 +index d18b3982548b..5ea0c1a3bbe6 100644
3890 +--- a/sound/core/pcm_native.c
3891 ++++ b/sound/core/pcm_native.c
3892 +@@ -2687,7 +2687,8 @@ static int snd_pcm_hwsync(struct snd_pcm_substream *substream)
3893 + return err;
3894 + }
3895 +
3896 +-static snd_pcm_sframes_t snd_pcm_delay(struct snd_pcm_substream *substream)
3897 ++static int snd_pcm_delay(struct snd_pcm_substream *substream,
3898 ++ snd_pcm_sframes_t *delay)
3899 + {
3900 + struct snd_pcm_runtime *runtime = substream->runtime;
3901 + int err;
3902 +@@ -2703,7 +2704,9 @@ static snd_pcm_sframes_t snd_pcm_delay(struct snd_pcm_substream *substream)
3903 + n += runtime->delay;
3904 + }
3905 + snd_pcm_stream_unlock_irq(substream);
3906 +- return err < 0 ? err : n;
3907 ++ if (!err)
3908 ++ *delay = n;
3909 ++ return err;
3910 + }
3911 +
3912 + static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream,
3913 +@@ -2746,6 +2749,7 @@ static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream,
3914 + sync_ptr.s.status.hw_ptr = status->hw_ptr;
3915 + sync_ptr.s.status.tstamp = status->tstamp;
3916 + sync_ptr.s.status.suspended_state = status->suspended_state;
3917 ++ sync_ptr.s.status.audio_tstamp = status->audio_tstamp;
3918 + snd_pcm_stream_unlock_irq(substream);
3919 + if (copy_to_user(_sync_ptr, &sync_ptr, sizeof(sync_ptr)))
3920 + return -EFAULT;
3921 +@@ -2911,11 +2915,13 @@ static int snd_pcm_common_ioctl(struct file *file,
3922 + return snd_pcm_hwsync(substream);
3923 + case SNDRV_PCM_IOCTL_DELAY:
3924 + {
3925 +- snd_pcm_sframes_t delay = snd_pcm_delay(substream);
3926 ++ snd_pcm_sframes_t delay;
3927 + snd_pcm_sframes_t __user *res = arg;
3928 ++ int err;
3929 +
3930 +- if (delay < 0)
3931 +- return delay;
3932 ++ err = snd_pcm_delay(substream, &delay);
3933 ++ if (err)
3934 ++ return err;
3935 + if (put_user(delay, res))
3936 + return -EFAULT;
3937 + return 0;
3938 +@@ -3003,13 +3009,7 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
3939 + case SNDRV_PCM_IOCTL_DROP:
3940 + return snd_pcm_drop(substream);
3941 + case SNDRV_PCM_IOCTL_DELAY:
3942 +- {
3943 +- result = snd_pcm_delay(substream);
3944 +- if (result < 0)
3945 +- return result;
3946 +- *frames = result;
3947 +- return 0;
3948 +- }
3949 ++ return snd_pcm_delay(substream, frames);
3950 + default:
3951 + return -EINVAL;
3952 + }
3953 +diff --git a/sound/core/seq/oss/seq_oss_event.c b/sound/core/seq/oss/seq_oss_event.c
3954 +index c3908862bc8b..86ca584c27b2 100644
3955 +--- a/sound/core/seq/oss/seq_oss_event.c
3956 ++++ b/sound/core/seq/oss/seq_oss_event.c
3957 +@@ -26,6 +26,7 @@
3958 + #include <sound/seq_oss_legacy.h>
3959 + #include "seq_oss_readq.h"
3960 + #include "seq_oss_writeq.h"
3961 ++#include <linux/nospec.h>
3962 +
3963 +
3964 + /*
3965 +@@ -287,10 +288,10 @@ note_on_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, st
3966 + {
3967 + struct seq_oss_synthinfo *info;
3968 +
3969 +- if (!snd_seq_oss_synth_is_valid(dp, dev))
3970 ++ info = snd_seq_oss_synth_info(dp, dev);
3971 ++ if (!info)
3972 + return -ENXIO;
3973 +
3974 +- info = &dp->synths[dev];
3975 + switch (info->arg.event_passing) {
3976 + case SNDRV_SEQ_OSS_PROCESS_EVENTS:
3977 + if (! info->ch || ch < 0 || ch >= info->nr_voices) {
3978 +@@ -298,6 +299,7 @@ note_on_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, st
3979 + return set_note_event(dp, dev, SNDRV_SEQ_EVENT_NOTEON, ch, note, vel, ev);
3980 + }
3981 +
3982 ++ ch = array_index_nospec(ch, info->nr_voices);
3983 + if (note == 255 && info->ch[ch].note >= 0) {
3984 + /* volume control */
3985 + int type;
3986 +@@ -347,10 +349,10 @@ note_off_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, s
3987 + {
3988 + struct seq_oss_synthinfo *info;
3989 +
3990 +- if (!snd_seq_oss_synth_is_valid(dp, dev))
3991 ++ info = snd_seq_oss_synth_info(dp, dev);
3992 ++ if (!info)
3993 + return -ENXIO;
3994 +
3995 +- info = &dp->synths[dev];
3996 + switch (info->arg.event_passing) {
3997 + case SNDRV_SEQ_OSS_PROCESS_EVENTS:
3998 + if (! info->ch || ch < 0 || ch >= info->nr_voices) {
3999 +@@ -358,6 +360,7 @@ note_off_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, s
4000 + return set_note_event(dp, dev, SNDRV_SEQ_EVENT_NOTEON, ch, note, vel, ev);
4001 + }
4002 +
4003 ++ ch = array_index_nospec(ch, info->nr_voices);
4004 + if (info->ch[ch].note >= 0) {
4005 + note = info->ch[ch].note;
4006 + info->ch[ch].vel = 0;
4007 +@@ -381,7 +384,7 @@ note_off_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, s
4008 + static int
4009 + set_note_event(struct seq_oss_devinfo *dp, int dev, int type, int ch, int note, int vel, struct snd_seq_event *ev)
4010 + {
4011 +- if (! snd_seq_oss_synth_is_valid(dp, dev))
4012 ++ if (!snd_seq_oss_synth_info(dp, dev))
4013 + return -ENXIO;
4014 +
4015 + ev->type = type;
4016 +@@ -399,7 +402,7 @@ set_note_event(struct seq_oss_devinfo *dp, int dev, int type, int ch, int note,
4017 + static int
4018 + set_control_event(struct seq_oss_devinfo *dp, int dev, int type, int ch, int param, int val, struct snd_seq_event *ev)
4019 + {
4020 +- if (! snd_seq_oss_synth_is_valid(dp, dev))
4021 ++ if (!snd_seq_oss_synth_info(dp, dev))
4022 + return -ENXIO;
4023 +
4024 + ev->type = type;
4025 +diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c
4026 +index b30b2139e3f0..9debd1b8fd28 100644
4027 +--- a/sound/core/seq/oss/seq_oss_midi.c
4028 ++++ b/sound/core/seq/oss/seq_oss_midi.c
4029 +@@ -29,6 +29,7 @@
4030 + #include "../seq_lock.h"
4031 + #include <linux/init.h>
4032 + #include <linux/slab.h>
4033 ++#include <linux/nospec.h>
4034 +
4035 +
4036 + /*
4037 +@@ -315,6 +316,7 @@ get_mididev(struct seq_oss_devinfo *dp, int dev)
4038 + {
4039 + if (dev < 0 || dev >= dp->max_mididev)
4040 + return NULL;
4041 ++ dev = array_index_nospec(dev, dp->max_mididev);
4042 + return get_mdev(dev);
4043 + }
4044 +
4045 +diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c
4046 +index cd0e0ebbfdb1..278ebb993122 100644
4047 +--- a/sound/core/seq/oss/seq_oss_synth.c
4048 ++++ b/sound/core/seq/oss/seq_oss_synth.c
4049 +@@ -26,6 +26,7 @@
4050 + #include <linux/init.h>
4051 + #include <linux/module.h>
4052 + #include <linux/slab.h>
4053 ++#include <linux/nospec.h>
4054 +
4055 + /*
4056 + * constants
4057 +@@ -339,17 +340,13 @@ snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp)
4058 + dp->max_synthdev = 0;
4059 + }
4060 +
4061 +-/*
4062 +- * check if the specified device is MIDI mapped device
4063 +- */
4064 +-static int
4065 +-is_midi_dev(struct seq_oss_devinfo *dp, int dev)
4066 ++static struct seq_oss_synthinfo *
4067 ++get_synthinfo_nospec(struct seq_oss_devinfo *dp, int dev)
4068 + {
4069 + if (dev < 0 || dev >= dp->max_synthdev)
4070 +- return 0;
4071 +- if (dp->synths[dev].is_midi)
4072 +- return 1;
4073 +- return 0;
4074 ++ return NULL;
4075 ++ dev = array_index_nospec(dev, SNDRV_SEQ_OSS_MAX_SYNTH_DEVS);
4076 ++ return &dp->synths[dev];
4077 + }
4078 +
4079 + /*
4080 +@@ -359,14 +356,20 @@ static struct seq_oss_synth *
4081 + get_synthdev(struct seq_oss_devinfo *dp, int dev)
4082 + {
4083 + struct seq_oss_synth *rec;
4084 +- if (dev < 0 || dev >= dp->max_synthdev)
4085 +- return NULL;
4086 +- if (! dp->synths[dev].opened)
4087 ++ struct seq_oss_synthinfo *info = get_synthinfo_nospec(dp, dev);
4088 ++
4089 ++ if (!info)
4090 + return NULL;
4091 +- if (dp->synths[dev].is_midi)
4092 +- return &midi_synth_dev;
4093 +- if ((rec = get_sdev(dev)) == NULL)
4094 ++ if (!info->opened)
4095 + return NULL;
4096 ++ if (info->is_midi) {
4097 ++ rec = &midi_synth_dev;
4098 ++ snd_use_lock_use(&rec->use_lock);
4099 ++ } else {
4100 ++ rec = get_sdev(dev);
4101 ++ if (!rec)
4102 ++ return NULL;
4103 ++ }
4104 + if (! rec->opened) {
4105 + snd_use_lock_free(&rec->use_lock);
4106 + return NULL;
4107 +@@ -402,10 +405,8 @@ snd_seq_oss_synth_reset(struct seq_oss_devinfo *dp, int dev)
4108 + struct seq_oss_synth *rec;
4109 + struct seq_oss_synthinfo *info;
4110 +
4111 +- if (snd_BUG_ON(dev < 0 || dev >= dp->max_synthdev))
4112 +- return;
4113 +- info = &dp->synths[dev];
4114 +- if (! info->opened)
4115 ++ info = get_synthinfo_nospec(dp, dev);
4116 ++ if (!info || !info->opened)
4117 + return;
4118 + if (info->sysex)
4119 + info->sysex->len = 0; /* reset sysex */
4120 +@@ -454,12 +455,14 @@ snd_seq_oss_synth_load_patch(struct seq_oss_devinfo *dp, int dev, int fmt,
4121 + const char __user *buf, int p, int c)
4122 + {
4123 + struct seq_oss_synth *rec;
4124 ++ struct seq_oss_synthinfo *info;
4125 + int rc;
4126 +
4127 +- if (dev < 0 || dev >= dp->max_synthdev)
4128 ++ info = get_synthinfo_nospec(dp, dev);
4129 ++ if (!info)
4130 + return -ENXIO;
4131 +
4132 +- if (is_midi_dev(dp, dev))
4133 ++ if (info->is_midi)
4134 + return 0;
4135 + if ((rec = get_synthdev(dp, dev)) == NULL)
4136 + return -ENXIO;
4137 +@@ -467,24 +470,25 @@ snd_seq_oss_synth_load_patch(struct seq_oss_devinfo *dp, int dev, int fmt,
4138 + if (rec->oper.load_patch == NULL)
4139 + rc = -ENXIO;
4140 + else
4141 +- rc = rec->oper.load_patch(&dp->synths[dev].arg, fmt, buf, p, c);
4142 ++ rc = rec->oper.load_patch(&info->arg, fmt, buf, p, c);
4143 + snd_use_lock_free(&rec->use_lock);
4144 + return rc;
4145 + }
4146 +
4147 + /*
4148 +- * check if the device is valid synth device
4149 ++ * check if the device is valid synth device and return the synth info
4150 + */
4151 +-int
4152 +-snd_seq_oss_synth_is_valid(struct seq_oss_devinfo *dp, int dev)
4153 ++struct seq_oss_synthinfo *
4154 ++snd_seq_oss_synth_info(struct seq_oss_devinfo *dp, int dev)
4155 + {
4156 + struct seq_oss_synth *rec;
4157 ++
4158 + rec = get_synthdev(dp, dev);
4159 + if (rec) {
4160 + snd_use_lock_free(&rec->use_lock);
4161 +- return 1;
4162 ++ return get_synthinfo_nospec(dp, dev);
4163 + }
4164 +- return 0;
4165 ++ return NULL;
4166 + }
4167 +
4168 +
4169 +@@ -499,16 +503,18 @@ snd_seq_oss_synth_sysex(struct seq_oss_devinfo *dp, int dev, unsigned char *buf,
4170 + int i, send;
4171 + unsigned char *dest;
4172 + struct seq_oss_synth_sysex *sysex;
4173 ++ struct seq_oss_synthinfo *info;
4174 +
4175 +- if (! snd_seq_oss_synth_is_valid(dp, dev))
4176 ++ info = snd_seq_oss_synth_info(dp, dev);
4177 ++ if (!info)
4178 + return -ENXIO;
4179 +
4180 +- sysex = dp->synths[dev].sysex;
4181 ++ sysex = info->sysex;
4182 + if (sysex == NULL) {
4183 + sysex = kzalloc(sizeof(*sysex), GFP_KERNEL);
4184 + if (sysex == NULL)
4185 + return -ENOMEM;
4186 +- dp->synths[dev].sysex = sysex;
4187 ++ info->sysex = sysex;
4188 + }
4189 +
4190 + send = 0;
4191 +@@ -553,10 +559,12 @@ snd_seq_oss_synth_sysex(struct seq_oss_devinfo *dp, int dev, unsigned char *buf,
4192 + int
4193 + snd_seq_oss_synth_addr(struct seq_oss_devinfo *dp, int dev, struct snd_seq_event *ev)
4194 + {
4195 +- if (! snd_seq_oss_synth_is_valid(dp, dev))
4196 ++ struct seq_oss_synthinfo *info = snd_seq_oss_synth_info(dp, dev);
4197 ++
4198 ++ if (!info)
4199 + return -EINVAL;
4200 +- snd_seq_oss_fill_addr(dp, ev, dp->synths[dev].arg.addr.client,
4201 +- dp->synths[dev].arg.addr.port);
4202 ++ snd_seq_oss_fill_addr(dp, ev, info->arg.addr.client,
4203 ++ info->arg.addr.port);
4204 + return 0;
4205 + }
4206 +
4207 +@@ -568,16 +576,18 @@ int
4208 + snd_seq_oss_synth_ioctl(struct seq_oss_devinfo *dp, int dev, unsigned int cmd, unsigned long addr)
4209 + {
4210 + struct seq_oss_synth *rec;
4211 ++ struct seq_oss_synthinfo *info;
4212 + int rc;
4213 +
4214 +- if (is_midi_dev(dp, dev))
4215 ++ info = get_synthinfo_nospec(dp, dev);
4216 ++ if (!info || info->is_midi)
4217 + return -ENXIO;
4218 + if ((rec = get_synthdev(dp, dev)) == NULL)
4219 + return -ENXIO;
4220 + if (rec->oper.ioctl == NULL)
4221 + rc = -ENXIO;
4222 + else
4223 +- rc = rec->oper.ioctl(&dp->synths[dev].arg, cmd, addr);
4224 ++ rc = rec->oper.ioctl(&info->arg, cmd, addr);
4225 + snd_use_lock_free(&rec->use_lock);
4226 + return rc;
4227 + }
4228 +@@ -589,7 +599,10 @@ snd_seq_oss_synth_ioctl(struct seq_oss_devinfo *dp, int dev, unsigned int cmd, u
4229 + int
4230 + snd_seq_oss_synth_raw_event(struct seq_oss_devinfo *dp, int dev, unsigned char *data, struct snd_seq_event *ev)
4231 + {
4232 +- if (! snd_seq_oss_synth_is_valid(dp, dev) || is_midi_dev(dp, dev))
4233 ++ struct seq_oss_synthinfo *info;
4234 ++
4235 ++ info = snd_seq_oss_synth_info(dp, dev);
4236 ++ if (!info || info->is_midi)
4237 + return -ENXIO;
4238 + ev->type = SNDRV_SEQ_EVENT_OSS;
4239 + memcpy(ev->data.raw8.d, data, 8);
4240 +diff --git a/sound/core/seq/oss/seq_oss_synth.h b/sound/core/seq/oss/seq_oss_synth.h
4241 +index 74ac55f166b6..a63f9e22974d 100644
4242 +--- a/sound/core/seq/oss/seq_oss_synth.h
4243 ++++ b/sound/core/seq/oss/seq_oss_synth.h
4244 +@@ -37,7 +37,8 @@ void snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp);
4245 + void snd_seq_oss_synth_reset(struct seq_oss_devinfo *dp, int dev);
4246 + int snd_seq_oss_synth_load_patch(struct seq_oss_devinfo *dp, int dev, int fmt,
4247 + const char __user *buf, int p, int c);
4248 +-int snd_seq_oss_synth_is_valid(struct seq_oss_devinfo *dp, int dev);
4249 ++struct seq_oss_synthinfo *snd_seq_oss_synth_info(struct seq_oss_devinfo *dp,
4250 ++ int dev);
4251 + int snd_seq_oss_synth_sysex(struct seq_oss_devinfo *dp, int dev, unsigned char *buf,
4252 + struct snd_seq_event *ev);
4253 + int snd_seq_oss_synth_addr(struct seq_oss_devinfo *dp, int dev, struct snd_seq_event *ev);
4254 +diff --git a/sound/drivers/opl3/opl3_synth.c b/sound/drivers/opl3/opl3_synth.c
4255 +index ddcc1a325a61..42920a243328 100644
4256 +--- a/sound/drivers/opl3/opl3_synth.c
4257 ++++ b/sound/drivers/opl3/opl3_synth.c
4258 +@@ -21,6 +21,7 @@
4259 +
4260 + #include <linux/slab.h>
4261 + #include <linux/export.h>
4262 ++#include <linux/nospec.h>
4263 + #include <sound/opl3.h>
4264 + #include <sound/asound_fm.h>
4265 +
4266 +@@ -448,7 +449,7 @@ static int snd_opl3_set_voice(struct snd_opl3 * opl3, struct snd_dm_fm_voice * v
4267 + {
4268 + unsigned short reg_side;
4269 + unsigned char op_offset;
4270 +- unsigned char voice_offset;
4271 ++ unsigned char voice_offset, voice_op;
4272 +
4273 + unsigned short opl3_reg;
4274 + unsigned char reg_val;
4275 +@@ -473,7 +474,9 @@ static int snd_opl3_set_voice(struct snd_opl3 * opl3, struct snd_dm_fm_voice * v
4276 + voice_offset = voice->voice - MAX_OPL2_VOICES;
4277 + }
4278 + /* Get register offset of operator */
4279 +- op_offset = snd_opl3_regmap[voice_offset][voice->op];
4280 ++ voice_offset = array_index_nospec(voice_offset, MAX_OPL2_VOICES);
4281 ++ voice_op = array_index_nospec(voice->op, 4);
4282 ++ op_offset = snd_opl3_regmap[voice_offset][voice_op];
4283 +
4284 + reg_val = 0x00;
4285 + /* Set amplitude modulation (tremolo) effect */
4286 +diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c
4287 +index 8573289c381e..928a255bfc35 100644
4288 +--- a/sound/firewire/dice/dice-stream.c
4289 ++++ b/sound/firewire/dice/dice-stream.c
4290 +@@ -435,7 +435,7 @@ int snd_dice_stream_init_duplex(struct snd_dice *dice)
4291 + err = init_stream(dice, AMDTP_IN_STREAM, i);
4292 + if (err < 0) {
4293 + for (; i >= 0; i--)
4294 +- destroy_stream(dice, AMDTP_OUT_STREAM, i);
4295 ++ destroy_stream(dice, AMDTP_IN_STREAM, i);
4296 + goto end;
4297 + }
4298 + }
4299 +diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c
4300 +index 4ddb4cdd054b..96bb01b6b751 100644
4301 +--- a/sound/firewire/dice/dice.c
4302 ++++ b/sound/firewire/dice/dice.c
4303 +@@ -14,7 +14,7 @@ MODULE_LICENSE("GPL v2");
4304 + #define OUI_WEISS 0x001c6a
4305 + #define OUI_LOUD 0x000ff2
4306 + #define OUI_FOCUSRITE 0x00130e
4307 +-#define OUI_TCELECTRONIC 0x001486
4308 ++#define OUI_TCELECTRONIC 0x000166
4309 +
4310 + #define DICE_CATEGORY_ID 0x04
4311 + #define WEISS_CATEGORY_ID 0x00
4312 +diff --git a/sound/pci/asihpi/hpimsginit.c b/sound/pci/asihpi/hpimsginit.c
4313 +index 7eb617175fde..a31a70dccecf 100644
4314 +--- a/sound/pci/asihpi/hpimsginit.c
4315 ++++ b/sound/pci/asihpi/hpimsginit.c
4316 +@@ -23,6 +23,7 @@
4317 +
4318 + #include "hpi_internal.h"
4319 + #include "hpimsginit.h"
4320 ++#include <linux/nospec.h>
4321 +
4322 + /* The actual message size for each object type */
4323 + static u16 msg_size[HPI_OBJ_MAXINDEX + 1] = HPI_MESSAGE_SIZE_BY_OBJECT;
4324 +@@ -39,10 +40,12 @@ static void hpi_init_message(struct hpi_message *phm, u16 object,
4325 + {
4326 + u16 size;
4327 +
4328 +- if ((object > 0) && (object <= HPI_OBJ_MAXINDEX))
4329 ++ if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) {
4330 ++ object = array_index_nospec(object, HPI_OBJ_MAXINDEX + 1);
4331 + size = msg_size[object];
4332 +- else
4333 ++ } else {
4334 + size = sizeof(*phm);
4335 ++ }
4336 +
4337 + memset(phm, 0, size);
4338 + phm->size = size;
4339 +@@ -66,10 +69,12 @@ void hpi_init_response(struct hpi_response *phr, u16 object, u16 function,
4340 + {
4341 + u16 size;
4342 +
4343 +- if ((object > 0) && (object <= HPI_OBJ_MAXINDEX))
4344 ++ if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) {
4345 ++ object = array_index_nospec(object, HPI_OBJ_MAXINDEX + 1);
4346 + size = res_size[object];
4347 +- else
4348 ++ } else {
4349 + size = sizeof(*phr);
4350 ++ }
4351 +
4352 + memset(phr, 0, sizeof(*phr));
4353 + phr->size = size;
4354 +diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
4355 +index 5badd08e1d69..b1a2a7ea4172 100644
4356 +--- a/sound/pci/asihpi/hpioctl.c
4357 ++++ b/sound/pci/asihpi/hpioctl.c
4358 +@@ -33,6 +33,7 @@
4359 + #include <linux/stringify.h>
4360 + #include <linux/module.h>
4361 + #include <linux/vmalloc.h>
4362 ++#include <linux/nospec.h>
4363 +
4364 + #ifdef MODULE_FIRMWARE
4365 + MODULE_FIRMWARE("asihpi/dsp5000.bin");
4366 +@@ -186,7 +187,8 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
4367 + struct hpi_adapter *pa = NULL;
4368 +
4369 + if (hm->h.adapter_index < ARRAY_SIZE(adapters))
4370 +- pa = &adapters[hm->h.adapter_index];
4371 ++ pa = &adapters[array_index_nospec(hm->h.adapter_index,
4372 ++ ARRAY_SIZE(adapters))];
4373 +
4374 + if (!pa || !pa->adapter || !pa->adapter->type) {
4375 + hpi_init_response(&hr->r0, hm->h.object,
4376 +diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
4377 +index 57df06e76968..cc009a4a3d1d 100644
4378 +--- a/sound/pci/hda/hda_hwdep.c
4379 ++++ b/sound/pci/hda/hda_hwdep.c
4380 +@@ -21,6 +21,7 @@
4381 + #include <linux/init.h>
4382 + #include <linux/slab.h>
4383 + #include <linux/compat.h>
4384 ++#include <linux/nospec.h>
4385 + #include <sound/core.h>
4386 + #include "hda_codec.h"
4387 + #include "hda_local.h"
4388 +@@ -51,7 +52,16 @@ static int get_wcap_ioctl(struct hda_codec *codec,
4389 +
4390 + if (get_user(verb, &arg->verb))
4391 + return -EFAULT;
4392 +- res = get_wcaps(codec, verb >> 24);
4393 ++ /* open-code get_wcaps(verb>>24) with nospec */
4394 ++ verb >>= 24;
4395 ++ if (verb < codec->core.start_nid ||
4396 ++ verb >= codec->core.start_nid + codec->core.num_nodes) {
4397 ++ res = 0;
4398 ++ } else {
4399 ++ verb -= codec->core.start_nid;
4400 ++ verb = array_index_nospec(verb, codec->core.num_nodes);
4401 ++ res = codec->wcaps[verb];
4402 ++ }
4403 + if (put_user(res, &arg->res))
4404 + return -EFAULT;
4405 + return 0;
4406 +diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
4407 +index b4f1b6e88305..7d7eb1354eee 100644
4408 +--- a/sound/pci/hda/patch_hdmi.c
4409 ++++ b/sound/pci/hda/patch_hdmi.c
4410 +@@ -1383,6 +1383,8 @@ static void hdmi_pcm_setup_pin(struct hdmi_spec *spec,
4411 + pcm = get_pcm_rec(spec, per_pin->pcm_idx);
4412 + else
4413 + return;
4414 ++ if (!pcm->pcm)
4415 ++ return;
4416 + if (!test_bit(per_pin->pcm_idx, &spec->pcm_in_use))
4417 + return;
4418 +
4419 +@@ -2151,8 +2153,13 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
4420 + int dev, err;
4421 + int pin_idx, pcm_idx;
4422 +
4423 +-
4424 + for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) {
4425 ++ if (!get_pcm_rec(spec, pcm_idx)->pcm) {
4426 ++ /* no PCM: mark this for skipping permanently */
4427 ++ set_bit(pcm_idx, &spec->pcm_bitmap);
4428 ++ continue;
4429 ++ }
4430 ++
4431 + err = generic_hdmi_build_jack(codec, pcm_idx);
4432 + if (err < 0)
4433 + return err;
4434 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
4435 +index fc77bf7a1544..8c238e51bb5a 100644
4436 +--- a/sound/pci/hda/patch_realtek.c
4437 ++++ b/sound/pci/hda/patch_realtek.c
4438 +@@ -331,6 +331,7 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
4439 + /* fallthrough */
4440 + case 0x10ec0215:
4441 + case 0x10ec0233:
4442 ++ case 0x10ec0235:
4443 + case 0x10ec0236:
4444 + case 0x10ec0255:
4445 + case 0x10ec0256:
4446 +@@ -6575,6 +6576,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4447 + SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
4448 + SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
4449 + SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
4450 ++ SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
4451 + SND_PCI_QUIRK(0x17aa, 0x3138, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
4452 + SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
4453 + SND_PCI_QUIRK(0x17aa, 0x3112, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
4454 +@@ -7160,8 +7162,11 @@ static int patch_alc269(struct hda_codec *codec)
4455 + case 0x10ec0298:
4456 + spec->codec_variant = ALC269_TYPE_ALC298;
4457 + break;
4458 ++ case 0x10ec0235:
4459 + case 0x10ec0255:
4460 + spec->codec_variant = ALC269_TYPE_ALC255;
4461 ++ spec->shutup = alc256_shutup;
4462 ++ spec->init_hook = alc256_init;
4463 + break;
4464 + case 0x10ec0236:
4465 + case 0x10ec0256:
4466 +diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
4467 +index 4c59983158e0..11b5b5e0e058 100644
4468 +--- a/sound/pci/rme9652/hdspm.c
4469 ++++ b/sound/pci/rme9652/hdspm.c
4470 +@@ -137,6 +137,7 @@
4471 + #include <linux/pci.h>
4472 + #include <linux/math64.h>
4473 + #include <linux/io.h>
4474 ++#include <linux/nospec.h>
4475 +
4476 + #include <sound/core.h>
4477 + #include <sound/control.h>
4478 +@@ -5698,40 +5699,43 @@ static int snd_hdspm_channel_info(struct snd_pcm_substream *substream,
4479 + struct snd_pcm_channel_info *info)
4480 + {
4481 + struct hdspm *hdspm = snd_pcm_substream_chip(substream);
4482 ++ unsigned int channel = info->channel;
4483 +
4484 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
4485 +- if (snd_BUG_ON(info->channel >= hdspm->max_channels_out)) {
4486 ++ if (snd_BUG_ON(channel >= hdspm->max_channels_out)) {
4487 + dev_info(hdspm->card->dev,
4488 + "snd_hdspm_channel_info: output channel out of range (%d)\n",
4489 +- info->channel);
4490 ++ channel);
4491 + return -EINVAL;
4492 + }
4493 +
4494 +- if (hdspm->channel_map_out[info->channel] < 0) {
4495 ++ channel = array_index_nospec(channel, hdspm->max_channels_out);
4496 ++ if (hdspm->channel_map_out[channel] < 0) {
4497 + dev_info(hdspm->card->dev,
4498 + "snd_hdspm_channel_info: output channel %d mapped out\n",
4499 +- info->channel);
4500 ++ channel);
4501 + return -EINVAL;
4502 + }
4503 +
4504 +- info->offset = hdspm->channel_map_out[info->channel] *
4505 ++ info->offset = hdspm->channel_map_out[channel] *
4506 + HDSPM_CHANNEL_BUFFER_BYTES;
4507 + } else {
4508 +- if (snd_BUG_ON(info->channel >= hdspm->max_channels_in)) {
4509 ++ if (snd_BUG_ON(channel >= hdspm->max_channels_in)) {
4510 + dev_info(hdspm->card->dev,
4511 + "snd_hdspm_channel_info: input channel out of range (%d)\n",
4512 +- info->channel);
4513 ++ channel);
4514 + return -EINVAL;
4515 + }
4516 +
4517 +- if (hdspm->channel_map_in[info->channel] < 0) {
4518 ++ channel = array_index_nospec(channel, hdspm->max_channels_in);
4519 ++ if (hdspm->channel_map_in[channel] < 0) {
4520 + dev_info(hdspm->card->dev,
4521 + "snd_hdspm_channel_info: input channel %d mapped out\n",
4522 +- info->channel);
4523 ++ channel);
4524 + return -EINVAL;
4525 + }
4526 +
4527 +- info->offset = hdspm->channel_map_in[info->channel] *
4528 ++ info->offset = hdspm->channel_map_in[channel] *
4529 + HDSPM_CHANNEL_BUFFER_BYTES;
4530 + }
4531 +
4532 +diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
4533 +index df648b1d9217..edd765e22377 100644
4534 +--- a/sound/pci/rme9652/rme9652.c
4535 ++++ b/sound/pci/rme9652/rme9652.c
4536 +@@ -26,6 +26,7 @@
4537 + #include <linux/pci.h>
4538 + #include <linux/module.h>
4539 + #include <linux/io.h>
4540 ++#include <linux/nospec.h>
4541 +
4542 + #include <sound/core.h>
4543 + #include <sound/control.h>
4544 +@@ -2071,9 +2072,10 @@ static int snd_rme9652_channel_info(struct snd_pcm_substream *substream,
4545 + if (snd_BUG_ON(info->channel >= RME9652_NCHANNELS))
4546 + return -EINVAL;
4547 +
4548 +- if ((chn = rme9652->channel_map[info->channel]) < 0) {
4549 ++ chn = rme9652->channel_map[array_index_nospec(info->channel,
4550 ++ RME9652_NCHANNELS)];
4551 ++ if (chn < 0)
4552 + return -EINVAL;
4553 +- }
4554 +
4555 + info->offset = chn * RME9652_CHANNEL_BUFFER_BYTES;
4556 + info->first = 0;
4557 +diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
4558 +index cef79a1a620b..81268760b7a9 100644
4559 +--- a/sound/soc/fsl/fsl_esai.c
4560 ++++ b/sound/soc/fsl/fsl_esai.c
4561 +@@ -144,6 +144,13 @@ static int fsl_esai_divisor_cal(struct snd_soc_dai *dai, bool tx, u32 ratio,
4562 +
4563 + psr = ratio <= 256 * maxfp ? ESAI_xCCR_xPSR_BYPASS : ESAI_xCCR_xPSR_DIV8;
4564 +
4565 ++ /* Do not loop-search if PM (1 ~ 256) alone can serve the ratio */
4566 ++ if (ratio <= 256) {
4567 ++ pm = ratio;
4568 ++ fp = 1;
4569 ++ goto out;
4570 ++ }
4571 ++
4572 + /* Set the max fluctuation -- 0.1% of the max devisor */
4573 + savesub = (psr ? 1 : 8) * 256 * maxfp / 1000;
4574 +
4575 +diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
4576 +index 09db2aec12a3..b2f5d2fa354d 100644
4577 +--- a/sound/soc/omap/omap-dmic.c
4578 ++++ b/sound/soc/omap/omap-dmic.c
4579 +@@ -281,7 +281,7 @@ static int omap_dmic_dai_trigger(struct snd_pcm_substream *substream,
4580 + static int omap_dmic_select_fclk(struct omap_dmic *dmic, int clk_id,
4581 + unsigned int freq)
4582 + {
4583 +- struct clk *parent_clk;
4584 ++ struct clk *parent_clk, *mux;
4585 + char *parent_clk_name;
4586 + int ret = 0;
4587 +
4588 +@@ -329,14 +329,21 @@ static int omap_dmic_select_fclk(struct omap_dmic *dmic, int clk_id,
4589 + return -ENODEV;
4590 + }
4591 +
4592 ++ mux = clk_get_parent(dmic->fclk);
4593 ++ if (IS_ERR(mux)) {
4594 ++ dev_err(dmic->dev, "can't get fck mux parent\n");
4595 ++ clk_put(parent_clk);
4596 ++ return -ENODEV;
4597 ++ }
4598 ++
4599 + mutex_lock(&dmic->mutex);
4600 + if (dmic->active) {
4601 + /* disable clock while reparenting */
4602 + pm_runtime_put_sync(dmic->dev);
4603 +- ret = clk_set_parent(dmic->fclk, parent_clk);
4604 ++ ret = clk_set_parent(mux, parent_clk);
4605 + pm_runtime_get_sync(dmic->dev);
4606 + } else {
4607 +- ret = clk_set_parent(dmic->fclk, parent_clk);
4608 ++ ret = clk_set_parent(mux, parent_clk);
4609 + }
4610 + mutex_unlock(&dmic->mutex);
4611 +
4612 +@@ -349,6 +356,7 @@ static int omap_dmic_select_fclk(struct omap_dmic *dmic, int clk_id,
4613 + dmic->fclk_freq = freq;
4614 +
4615 + err_busy:
4616 ++ clk_put(mux);
4617 + clk_put(parent_clk);
4618 +
4619 + return ret;
4620 +diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c
4621 +index 9038b2e7df73..eaa03acd4686 100644
4622 +--- a/sound/usb/mixer_maps.c
4623 ++++ b/sound/usb/mixer_maps.c
4624 +@@ -353,8 +353,11 @@ static struct usbmix_name_map bose_companion5_map[] = {
4625 + /*
4626 + * Dell usb dock with ALC4020 codec had a firmware problem where it got
4627 + * screwed up when zero volume is passed; just skip it as a workaround
4628 ++ *
4629 ++ * Also the extension unit gives an access error, so skip it as well.
4630 + */
4631 + static const struct usbmix_name_map dell_alc4020_map[] = {
4632 ++ { 4, NULL }, /* extension unit */
4633 + { 16, NULL },
4634 + { 19, NULL },
4635 + { 0 }
4636 +diff --git a/tools/lib/str_error_r.c b/tools/lib/str_error_r.c
4637 +index d6d65537b0d9..6aad8308a0ac 100644
4638 +--- a/tools/lib/str_error_r.c
4639 ++++ b/tools/lib/str_error_r.c
4640 +@@ -22,6 +22,6 @@ char *str_error_r(int errnum, char *buf, size_t buflen)
4641 + {
4642 + int err = strerror_r(errnum, buf, buflen);
4643 + if (err)
4644 +- snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d", errnum, buf, buflen, err);
4645 ++ snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, [buf], %zd)=%d", errnum, buflen, err);
4646 + return buf;
4647 + }
4648 +diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
4649 +index 53572304843b..a6483b5576fd 100644
4650 +--- a/virt/kvm/arm/arm.c
4651 ++++ b/virt/kvm/arm/arm.c
4652 +@@ -63,7 +63,7 @@ static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
4653 + static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
4654 + static u32 kvm_next_vmid;
4655 + static unsigned int kvm_vmid_bits __read_mostly;
4656 +-static DEFINE_SPINLOCK(kvm_vmid_lock);
4657 ++static DEFINE_RWLOCK(kvm_vmid_lock);
4658 +
4659 + static bool vgic_present;
4660 +
4661 +@@ -470,11 +470,16 @@ static void update_vttbr(struct kvm *kvm)
4662 + {
4663 + phys_addr_t pgd_phys;
4664 + u64 vmid;
4665 ++ bool new_gen;
4666 +
4667 +- if (!need_new_vmid_gen(kvm))
4668 ++ read_lock(&kvm_vmid_lock);
4669 ++ new_gen = need_new_vmid_gen(kvm);
4670 ++ read_unlock(&kvm_vmid_lock);
4671 ++
4672 ++ if (!new_gen)
4673 + return;
4674 +
4675 +- spin_lock(&kvm_vmid_lock);
4676 ++ write_lock(&kvm_vmid_lock);
4677 +
4678 + /*
4679 + * We need to re-check the vmid_gen here to ensure that if another vcpu
4680 +@@ -482,7 +487,7 @@ static void update_vttbr(struct kvm *kvm)
4681 + * use the same vmid.
4682 + */
4683 + if (!need_new_vmid_gen(kvm)) {
4684 +- spin_unlock(&kvm_vmid_lock);
4685 ++ write_unlock(&kvm_vmid_lock);
4686 + return;
4687 + }
4688 +
4689 +@@ -516,7 +521,7 @@ static void update_vttbr(struct kvm *kvm)
4690 + vmid = ((u64)(kvm->arch.vmid) << VTTBR_VMID_SHIFT) & VTTBR_VMID_MASK(kvm_vmid_bits);
4691 + kvm->arch.vttbr = kvm_phys_to_vttbr(pgd_phys) | vmid;
4692 +
4693 +- spin_unlock(&kvm_vmid_lock);
4694 ++ write_unlock(&kvm_vmid_lock);
4695 + }
4696 +
4697 + static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)
4698 +diff --git a/virt/kvm/arm/psci.c b/virt/kvm/arm/psci.c
4699 +index 6919352cbf15..c4762bef13c6 100644
4700 +--- a/virt/kvm/arm/psci.c
4701 ++++ b/virt/kvm/arm/psci.c
4702 +@@ -18,6 +18,7 @@
4703 + #include <linux/arm-smccc.h>
4704 + #include <linux/preempt.h>
4705 + #include <linux/kvm_host.h>
4706 ++#include <linux/uaccess.h>
4707 + #include <linux/wait.h>
4708 +
4709 + #include <asm/cputype.h>
4710 +@@ -427,3 +428,62 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
4711 + smccc_set_retval(vcpu, val, 0, 0, 0);
4712 + return 1;
4713 + }
4714 ++
4715 ++int kvm_arm_get_fw_num_regs(struct kvm_vcpu *vcpu)
4716 ++{
4717 ++ return 1; /* PSCI version */
4718 ++}
4719 ++
4720 ++int kvm_arm_copy_fw_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices)
4721 ++{
4722 ++ if (put_user(KVM_REG_ARM_PSCI_VERSION, uindices))
4723 ++ return -EFAULT;
4724 ++
4725 ++ return 0;
4726 ++}
4727 ++
4728 ++int kvm_arm_get_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
4729 ++{
4730 ++ if (reg->id == KVM_REG_ARM_PSCI_VERSION) {
4731 ++ void __user *uaddr = (void __user *)(long)reg->addr;
4732 ++ u64 val;
4733 ++
4734 ++ val = kvm_psci_version(vcpu, vcpu->kvm);
4735 ++ if (copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id)))
4736 ++ return -EFAULT;
4737 ++
4738 ++ return 0;
4739 ++ }
4740 ++
4741 ++ return -EINVAL;
4742 ++}
4743 ++
4744 ++int kvm_arm_set_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
4745 ++{
4746 ++ if (reg->id == KVM_REG_ARM_PSCI_VERSION) {
4747 ++ void __user *uaddr = (void __user *)(long)reg->addr;
4748 ++ bool wants_02;
4749 ++ u64 val;
4750 ++
4751 ++ if (copy_from_user(&val, uaddr, KVM_REG_SIZE(reg->id)))
4752 ++ return -EFAULT;
4753 ++
4754 ++ wants_02 = test_bit(KVM_ARM_VCPU_PSCI_0_2, vcpu->arch.features);
4755 ++
4756 ++ switch (val) {
4757 ++ case KVM_ARM_PSCI_0_1:
4758 ++ if (wants_02)
4759 ++ return -EINVAL;
4760 ++ vcpu->kvm->arch.psci_version = val;
4761 ++ return 0;
4762 ++ case KVM_ARM_PSCI_0_2:
4763 ++ case KVM_ARM_PSCI_1_0:
4764 ++ if (!wants_02)
4765 ++ return -EINVAL;
4766 ++ vcpu->kvm->arch.psci_version = val;
4767 ++ return 0;
4768 ++ }
4769 ++ }
4770 ++
4771 ++ return -EINVAL;
4772 ++}