Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Tue, 29 Oct 2019 14:00:25
Message-Id: 1572357542.7131d9f67a5bd21a4347c246523936063807b3c1.mpagano@gentoo
1 commit: 7131d9f67a5bd21a4347c246523936063807b3c1
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Sep 6 17:19:23 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Tue Oct 29 13:59:02 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=7131d9f6
7
8 Linux patch 4.14.142
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1141_linux-4.14.142.patch | 1816 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 1820 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 9d8b846..1bb6a46 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -607,6 +607,10 @@ Patch: 1140_linux-4.14.141.patch
21 From: https://www.kernel.org
22 Desc: Linux 4.14.141
23
24 +Patch: 1141_linux-4.14.142.patch
25 +From: https://www.kernel.org
26 +Desc: Linux 4.14.142
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1141_linux-4.14.142.patch b/1141_linux-4.14.142.patch
33 new file mode 100644
34 index 0000000..6525c6f
35 --- /dev/null
36 +++ b/1141_linux-4.14.142.patch
37 @@ -0,0 +1,1816 @@
38 +diff --git a/Makefile b/Makefile
39 +index eefd21f3d1ec..ccced427d9de 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 4
45 + PATCHLEVEL = 14
46 +-SUBLEVEL = 141
47 ++SUBLEVEL = 142
48 + EXTRAVERSION =
49 + NAME = Petit Gorille
50 +
51 +diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
52 +index e14cec6bc339..2c6cce8e7cfd 100644
53 +--- a/arch/powerpc/kvm/book3s_64_vio.c
54 ++++ b/arch/powerpc/kvm/book3s_64_vio.c
55 +@@ -566,8 +566,10 @@ long kvmppc_h_put_tce_indirect(struct kvm_vcpu *vcpu,
56 +
57 + if (kvmppc_gpa_to_ua(vcpu->kvm,
58 + tce & ~(TCE_PCI_READ | TCE_PCI_WRITE),
59 +- &ua, NULL))
60 +- return H_PARAMETER;
61 ++ &ua, NULL)) {
62 ++ ret = H_PARAMETER;
63 ++ goto unlock_exit;
64 ++ }
65 +
66 + list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
67 + ret = kvmppc_tce_iommu_map(vcpu->kvm,
68 +diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c
69 +index 648cf6c01348..23d6d1592f11 100644
70 +--- a/arch/powerpc/kvm/book3s_64_vio_hv.c
71 ++++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
72 +@@ -475,8 +475,10 @@ long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu,
73 + ua = 0;
74 + if (kvmppc_gpa_to_ua(vcpu->kvm,
75 + tce & ~(TCE_PCI_READ | TCE_PCI_WRITE),
76 +- &ua, NULL))
77 +- return H_PARAMETER;
78 ++ &ua, NULL)) {
79 ++ ret = H_PARAMETER;
80 ++ goto unlock_exit;
81 ++ }
82 +
83 + list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
84 + ret = kvmppc_rm_tce_iommu_map(vcpu->kvm,
85 +diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
86 +index f8f9cfded97d..8199b7e4aff9 100644
87 +--- a/arch/x86/kernel/apic/apic.c
88 ++++ b/arch/x86/kernel/apic/apic.c
89 +@@ -1148,6 +1148,10 @@ void clear_local_APIC(void)
90 + apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
91 + v = apic_read(APIC_LVT1);
92 + apic_write(APIC_LVT1, v | APIC_LVT_MASKED);
93 ++ if (!x2apic_enabled()) {
94 ++ v = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
95 ++ apic_write(APIC_LDR, v);
96 ++ }
97 + if (maxlvt >= 4) {
98 + v = apic_read(APIC_LVTPC);
99 + apic_write(APIC_LVTPC, v | APIC_LVT_MASKED);
100 +diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
101 +index e12fbcfc9571..a527f2a712b4 100644
102 +--- a/arch/x86/kernel/apic/bigsmp_32.c
103 ++++ b/arch/x86/kernel/apic/bigsmp_32.c
104 +@@ -38,32 +38,12 @@ static int bigsmp_early_logical_apicid(int cpu)
105 + return early_per_cpu(x86_cpu_to_apicid, cpu);
106 + }
107 +
108 +-static inline unsigned long calculate_ldr(int cpu)
109 +-{
110 +- unsigned long val, id;
111 +-
112 +- val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
113 +- id = per_cpu(x86_bios_cpu_apicid, cpu);
114 +- val |= SET_APIC_LOGICAL_ID(id);
115 +-
116 +- return val;
117 +-}
118 +-
119 + /*
120 +- * Set up the logical destination ID.
121 +- *
122 +- * Intel recommends to set DFR, LDR and TPR before enabling
123 +- * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
124 +- * document number 292116). So here it goes...
125 ++ * bigsmp enables physical destination mode
126 ++ * and doesn't use LDR and DFR
127 + */
128 + static void bigsmp_init_apic_ldr(void)
129 + {
130 +- unsigned long val;
131 +- int cpu = smp_processor_id();
132 +-
133 +- apic_write(APIC_DFR, APIC_DFR_FLAT);
134 +- val = calculate_ldr(cpu);
135 +- apic_write(APIC_LDR, val);
136 + }
137 +
138 + static void bigsmp_setup_apic_routing(void)
139 +diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
140 +index 2a65ab291312..584cdd475bb3 100644
141 +--- a/arch/x86/kernel/ptrace.c
142 ++++ b/arch/x86/kernel/ptrace.c
143 +@@ -652,11 +652,10 @@ static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n)
144 + {
145 + struct thread_struct *thread = &tsk->thread;
146 + unsigned long val = 0;
147 +- int index = n;
148 +
149 + if (n < HBP_NUM) {
150 ++ int index = array_index_nospec(n, HBP_NUM);
151 + struct perf_event *bp = thread->ptrace_bps[index];
152 +- index = array_index_nospec(index, HBP_NUM);
153 +
154 + if (bp)
155 + val = bp->hw.info.address;
156 +diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
157 +index b9a8f34b5e5a..7a87ef1f5b5e 100644
158 +--- a/arch/x86/kernel/uprobes.c
159 ++++ b/arch/x86/kernel/uprobes.c
160 +@@ -518,9 +518,12 @@ struct uprobe_xol_ops {
161 + void (*abort)(struct arch_uprobe *, struct pt_regs *);
162 + };
163 +
164 +-static inline int sizeof_long(void)
165 ++static inline int sizeof_long(struct pt_regs *regs)
166 + {
167 +- return in_ia32_syscall() ? 4 : 8;
168 ++ /*
169 ++ * Check registers for mode as in_xxx_syscall() does not apply here.
170 ++ */
171 ++ return user_64bit_mode(regs) ? 8 : 4;
172 + }
173 +
174 + static int default_pre_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs)
175 +@@ -531,9 +534,9 @@ static int default_pre_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs)
176 +
177 + static int push_ret_address(struct pt_regs *regs, unsigned long ip)
178 + {
179 +- unsigned long new_sp = regs->sp - sizeof_long();
180 ++ unsigned long new_sp = regs->sp - sizeof_long(regs);
181 +
182 +- if (copy_to_user((void __user *)new_sp, &ip, sizeof_long()))
183 ++ if (copy_to_user((void __user *)new_sp, &ip, sizeof_long(regs)))
184 + return -EFAULT;
185 +
186 + regs->sp = new_sp;
187 +@@ -566,7 +569,7 @@ static int default_post_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs
188 + long correction = utask->vaddr - utask->xol_vaddr;
189 + regs->ip += correction;
190 + } else if (auprobe->defparam.fixups & UPROBE_FIX_CALL) {
191 +- regs->sp += sizeof_long(); /* Pop incorrect return address */
192 ++ regs->sp += sizeof_long(regs); /* Pop incorrect return address */
193 + if (push_ret_address(regs, utask->vaddr + auprobe->defparam.ilen))
194 + return -ERESTART;
195 + }
196 +@@ -675,7 +678,7 @@ static int branch_post_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs)
197 + * "call" insn was executed out-of-line. Just restore ->sp and restart.
198 + * We could also restore ->ip and try to call branch_emulate_op() again.
199 + */
200 +- regs->sp += sizeof_long();
201 ++ regs->sp += sizeof_long(regs);
202 + return -ERESTART;
203 + }
204 +
205 +@@ -966,7 +969,7 @@ bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
206 + unsigned long
207 + arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs *regs)
208 + {
209 +- int rasize = sizeof_long(), nleft;
210 ++ int rasize = sizeof_long(regs), nleft;
211 + unsigned long orig_ret_vaddr = 0; /* clear high bits for 32-bit apps */
212 +
213 + if (copy_from_user(&orig_ret_vaddr, (void __user *)regs->sp, rasize))
214 +diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
215 +index 3aa0b8123c91..7b9ad9de4f37 100644
216 +--- a/arch/x86/kvm/lapic.c
217 ++++ b/arch/x86/kvm/lapic.c
218 +@@ -209,6 +209,9 @@ static void recalculate_apic_map(struct kvm *kvm)
219 + if (!apic_x2apic_mode(apic) && !new->phys_map[xapic_id])
220 + new->phys_map[xapic_id] = apic;
221 +
222 ++ if (!kvm_apic_sw_enabled(apic))
223 ++ continue;
224 ++
225 + ldr = kvm_lapic_get_reg(apic, APIC_LDR);
226 +
227 + if (apic_x2apic_mode(apic)) {
228 +@@ -252,6 +255,8 @@ static inline void apic_set_spiv(struct kvm_lapic *apic, u32 val)
229 + recalculate_apic_map(apic->vcpu->kvm);
230 + } else
231 + static_key_slow_inc(&apic_sw_disabled.key);
232 ++
233 ++ recalculate_apic_map(apic->vcpu->kvm);
234 + }
235 + }
236 +
237 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
238 +index a620936d97cf..c502f2e106db 100644
239 +--- a/arch/x86/kvm/x86.c
240 ++++ b/arch/x86/kvm/x86.c
241 +@@ -5954,12 +5954,13 @@ restart:
242 + unsigned long rflags = kvm_x86_ops->get_rflags(vcpu);
243 + toggle_interruptibility(vcpu, ctxt->interruptibility);
244 + vcpu->arch.emulate_regs_need_sync_to_vcpu = false;
245 +- kvm_rip_write(vcpu, ctxt->eip);
246 +- if (r == EMULATE_DONE && ctxt->tf)
247 +- kvm_vcpu_do_singlestep(vcpu, &r);
248 + if (!ctxt->have_exception ||
249 +- exception_type(ctxt->exception.vector) == EXCPT_TRAP)
250 ++ exception_type(ctxt->exception.vector) == EXCPT_TRAP) {
251 ++ kvm_rip_write(vcpu, ctxt->eip);
252 ++ if (r == EMULATE_DONE && ctxt->tf)
253 ++ kvm_vcpu_do_singlestep(vcpu, &r);
254 + __kvm_set_rflags(vcpu, ctxt->eflags);
255 ++ }
256 +
257 + /*
258 + * For STI, interrupts are shadowed; so KVM_REQ_EVENT will
259 +diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c
260 +index 6911acd896d9..e30953ceb7df 100644
261 +--- a/drivers/auxdisplay/panel.c
262 ++++ b/drivers/auxdisplay/panel.c
263 +@@ -1622,6 +1622,8 @@ static void panel_attach(struct parport *port)
264 + return;
265 +
266 + err_lcd_unreg:
267 ++ if (scan_timer.function)
268 ++ del_timer_sync(&scan_timer);
269 + if (lcd.enabled)
270 + charlcd_unregister(lcd.charlcd);
271 + err_unreg_device:
272 +diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
273 +index 21c1be1eb226..ed4e80779124 100644
274 +--- a/drivers/block/xen-blkback/xenbus.c
275 ++++ b/drivers/block/xen-blkback/xenbus.c
276 +@@ -973,6 +973,7 @@ static int read_per_ring_refs(struct xen_blkif_ring *ring, const char *dir)
277 + }
278 + blkif->nr_ring_pages = nr_grefs;
279 +
280 ++ err = -ENOMEM;
281 + for (i = 0; i < nr_grefs * XEN_BLKIF_REQS_PER_PAGE; i++) {
282 + req = kzalloc(sizeof(*req), GFP_KERNEL);
283 + if (!req)
284 +@@ -995,7 +996,7 @@ static int read_per_ring_refs(struct xen_blkif_ring *ring, const char *dir)
285 + err = xen_blkif_map(ring, ring_ref, nr_grefs, evtchn);
286 + if (err) {
287 + xenbus_dev_fatal(dev, err, "mapping ring-ref port %u", evtchn);
288 +- return err;
289 ++ goto fail;
290 + }
291 +
292 + return 0;
293 +@@ -1015,8 +1016,7 @@ fail:
294 + }
295 + kfree(req);
296 + }
297 +- return -ENOMEM;
298 +-
299 ++ return err;
300 + }
301 +
302 + static int connect_ring(struct backend_info *be)
303 +diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
304 +index 18d10694dd2a..b119df4c0043 100644
305 +--- a/drivers/crypto/ccp/ccp-dev.c
306 ++++ b/drivers/crypto/ccp/ccp-dev.c
307 +@@ -540,6 +540,10 @@ int ccp_dev_suspend(struct sp_device *sp, pm_message_t state)
308 + unsigned long flags;
309 + unsigned int i;
310 +
311 ++ /* If there's no device there's nothing to do */
312 ++ if (!ccp)
313 ++ return 0;
314 ++
315 + spin_lock_irqsave(&ccp->cmd_lock, flags);
316 +
317 + ccp->suspending = 1;
318 +@@ -564,6 +568,10 @@ int ccp_dev_resume(struct sp_device *sp)
319 + unsigned long flags;
320 + unsigned int i;
321 +
322 ++ /* If there's no device there's nothing to do */
323 ++ if (!ccp)
324 ++ return 0;
325 ++
326 + spin_lock_irqsave(&ccp->cmd_lock, flags);
327 +
328 + ccp->suspending = 0;
329 +diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
330 +index c2b089af0420..90feb6a05e59 100644
331 +--- a/drivers/dma/ste_dma40.c
332 ++++ b/drivers/dma/ste_dma40.c
333 +@@ -142,7 +142,7 @@ enum d40_events {
334 + * when the DMA hw is powered off.
335 + * TODO: Add save/restore of D40_DREG_GCC on dma40 v3 or later, if that works.
336 + */
337 +-static u32 d40_backup_regs[] = {
338 ++static __maybe_unused u32 d40_backup_regs[] = {
339 + D40_DREG_LCPA,
340 + D40_DREG_LCLA,
341 + D40_DREG_PRMSE,
342 +@@ -211,7 +211,7 @@ static u32 d40_backup_regs_v4b[] = {
343 +
344 + #define BACKUP_REGS_SZ_V4B ARRAY_SIZE(d40_backup_regs_v4b)
345 +
346 +-static u32 d40_backup_regs_chan[] = {
347 ++static __maybe_unused u32 d40_backup_regs_chan[] = {
348 + D40_CHAN_REG_SSCFG,
349 + D40_CHAN_REG_SSELT,
350 + D40_CHAN_REG_SSPTR,
351 +diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
352 +index 373700c05a00..224fa1ef87ff 100644
353 +--- a/drivers/gpu/drm/ast/ast_main.c
354 ++++ b/drivers/gpu/drm/ast/ast_main.c
355 +@@ -131,8 +131,8 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
356 +
357 +
358 + /* Enable extended register access */
359 +- ast_enable_mmio(dev);
360 + ast_open_key(ast);
361 ++ ast_enable_mmio(dev);
362 +
363 + /* Find out whether P2A works or whether to use device-tree */
364 + ast_detect_config_mode(dev, &scu_rev);
365 +@@ -576,6 +576,9 @@ void ast_driver_unload(struct drm_device *dev)
366 + {
367 + struct ast_private *ast = dev->dev_private;
368 +
369 ++ /* enable standard VGA decode */
370 ++ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04);
371 ++
372 + ast_release_firmware(dev);
373 + kfree(ast->dp501_fw_addr);
374 + ast_mode_fini(dev);
375 +diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
376 +index 343867b182dd..a09fafa27082 100644
377 +--- a/drivers/gpu/drm/ast/ast_mode.c
378 ++++ b/drivers/gpu/drm/ast/ast_mode.c
379 +@@ -600,7 +600,7 @@ static int ast_crtc_mode_set(struct drm_crtc *crtc,
380 + return -EINVAL;
381 + ast_open_key(ast);
382 +
383 +- ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa1, 0xff, 0x04);
384 ++ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x06);
385 +
386 + ast_set_std_reg(crtc, adjusted_mode, &vbios_mode);
387 + ast_set_crtc_reg(crtc, adjusted_mode, &vbios_mode);
388 +diff --git a/drivers/gpu/drm/ast/ast_post.c b/drivers/gpu/drm/ast/ast_post.c
389 +index f7d421359d56..c1d1ac51d1c2 100644
390 +--- a/drivers/gpu/drm/ast/ast_post.c
391 ++++ b/drivers/gpu/drm/ast/ast_post.c
392 +@@ -46,7 +46,7 @@ void ast_enable_mmio(struct drm_device *dev)
393 + {
394 + struct ast_private *ast = dev->dev_private;
395 +
396 +- ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa1, 0xff, 0x04);
397 ++ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x06);
398 + }
399 +
400 +
401 +diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c
402 +index acb857030951..1bb01905be8e 100644
403 +--- a/drivers/gpu/drm/bridge/ti-tfp410.c
404 ++++ b/drivers/gpu/drm/bridge/ti-tfp410.c
405 +@@ -64,7 +64,12 @@ static int tfp410_get_modes(struct drm_connector *connector)
406 +
407 + drm_mode_connector_update_edid_property(connector, edid);
408 +
409 +- return drm_add_edid_modes(connector, edid);
410 ++ ret = drm_add_edid_modes(connector, edid);
411 ++
412 ++ kfree(edid);
413 ++
414 ++ return ret;
415 ++
416 + fallback:
417 + /* No EDID, fallback on the XGA standard modes */
418 + ret = drm_add_modes_noedid(connector, 1920, 1200);
419 +diff --git a/drivers/gpu/drm/i915/i915_vgpu.c b/drivers/gpu/drm/i915/i915_vgpu.c
420 +index 5fe9f3f39467..e13ddd559f79 100644
421 +--- a/drivers/gpu/drm/i915/i915_vgpu.c
422 ++++ b/drivers/gpu/drm/i915/i915_vgpu.c
423 +@@ -100,6 +100,9 @@ static struct _balloon_info_ bl_info;
424 + static void vgt_deballoon_space(struct i915_ggtt *ggtt,
425 + struct drm_mm_node *node)
426 + {
427 ++ if (!drm_mm_node_allocated(node))
428 ++ return;
429 ++
430 + DRM_DEBUG_DRIVER("deballoon space: range [0x%llx - 0x%llx] %llu KiB.\n",
431 + node->start,
432 + node->start + node->size,
433 +diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
434 +index b0d70f943cec..56039897607c 100644
435 +--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
436 ++++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
437 +@@ -189,6 +189,12 @@ static void tilcdc_fini(struct drm_device *dev)
438 + {
439 + struct tilcdc_drm_private *priv = dev->dev_private;
440 +
441 ++#ifdef CONFIG_CPU_FREQ
442 ++ if (priv->freq_transition.notifier_call)
443 ++ cpufreq_unregister_notifier(&priv->freq_transition,
444 ++ CPUFREQ_TRANSITION_NOTIFIER);
445 ++#endif
446 ++
447 + if (priv->crtc)
448 + tilcdc_crtc_shutdown(priv->crtc);
449 +
450 +@@ -204,12 +210,6 @@ static void tilcdc_fini(struct drm_device *dev)
451 + drm_mode_config_cleanup(dev);
452 + tilcdc_remove_external_device(dev);
453 +
454 +-#ifdef CONFIG_CPU_FREQ
455 +- if (priv->freq_transition.notifier_call)
456 +- cpufreq_unregister_notifier(&priv->freq_transition,
457 +- CPUFREQ_TRANSITION_NOTIFIER);
458 +-#endif
459 +-
460 + if (priv->clk)
461 + clk_put(priv->clk);
462 +
463 +@@ -282,17 +282,6 @@ static int tilcdc_init(struct drm_driver *ddrv, struct device *dev)
464 + goto init_failed;
465 + }
466 +
467 +-#ifdef CONFIG_CPU_FREQ
468 +- priv->freq_transition.notifier_call = cpufreq_transition;
469 +- ret = cpufreq_register_notifier(&priv->freq_transition,
470 +- CPUFREQ_TRANSITION_NOTIFIER);
471 +- if (ret) {
472 +- dev_err(dev, "failed to register cpufreq notifier\n");
473 +- priv->freq_transition.notifier_call = NULL;
474 +- goto init_failed;
475 +- }
476 +-#endif
477 +-
478 + if (of_property_read_u32(node, "max-bandwidth", &priv->max_bandwidth))
479 + priv->max_bandwidth = TILCDC_DEFAULT_MAX_BANDWIDTH;
480 +
481 +@@ -369,6 +358,17 @@ static int tilcdc_init(struct drm_driver *ddrv, struct device *dev)
482 + }
483 + modeset_init(ddev);
484 +
485 ++#ifdef CONFIG_CPU_FREQ
486 ++ priv->freq_transition.notifier_call = cpufreq_transition;
487 ++ ret = cpufreq_register_notifier(&priv->freq_transition,
488 ++ CPUFREQ_TRANSITION_NOTIFIER);
489 ++ if (ret) {
490 ++ dev_err(dev, "failed to register cpufreq notifier\n");
491 ++ priv->freq_transition.notifier_call = NULL;
492 ++ goto init_failed;
493 ++ }
494 ++#endif
495 ++
496 + if (priv->is_componentized) {
497 + ret = component_bind_all(dev, ddev);
498 + if (ret < 0)
499 +diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
500 +index c001a37b7055..140b18d858e8 100644
501 +--- a/drivers/hwtracing/intel_th/pci.c
502 ++++ b/drivers/hwtracing/intel_th/pci.c
503 +@@ -148,6 +148,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
504 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa1a6),
505 + .driver_data = (kernel_ulong_t)0,
506 + },
507 ++ {
508 ++ /* Lewisburg PCH */
509 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa226),
510 ++ .driver_data = (kernel_ulong_t)0,
511 ++ },
512 + {
513 + /* Gemini Lake */
514 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x318e),
515 +@@ -183,6 +188,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
516 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x45c5),
517 + .driver_data = (kernel_ulong_t)&intel_th_2x,
518 + },
519 ++ {
520 ++ /* Tiger Lake PCH */
521 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa0a6),
522 ++ .driver_data = (kernel_ulong_t)&intel_th_2x,
523 ++ },
524 + { 0 },
525 + };
526 +
527 +diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
528 +index f4530b08b1e5..c592cef4e82c 100644
529 +--- a/drivers/hwtracing/stm/core.c
530 ++++ b/drivers/hwtracing/stm/core.c
531 +@@ -1107,7 +1107,6 @@ int stm_source_register_device(struct device *parent,
532 +
533 + err:
534 + put_device(&src->dev);
535 +- kfree(src);
536 +
537 + return err;
538 + }
539 +diff --git a/drivers/i2c/busses/i2c-emev2.c b/drivers/i2c/busses/i2c-emev2.c
540 +index d2e84480fbe9..dd97e5d9f49a 100644
541 +--- a/drivers/i2c/busses/i2c-emev2.c
542 ++++ b/drivers/i2c/busses/i2c-emev2.c
543 +@@ -72,6 +72,7 @@ struct em_i2c_device {
544 + struct completion msg_done;
545 + struct clk *sclk;
546 + struct i2c_client *slave;
547 ++ int irq;
548 + };
549 +
550 + static inline void em_clear_set_bit(struct em_i2c_device *priv, u8 clear, u8 set, u8 reg)
551 +@@ -342,6 +343,12 @@ static int em_i2c_unreg_slave(struct i2c_client *slave)
552 +
553 + writeb(0, priv->base + I2C_OFS_SVA0);
554 +
555 ++ /*
556 ++ * Wait for interrupt to finish. New slave irqs cannot happen because we
557 ++ * cleared the slave address and, thus, only extension codes will be
558 ++ * detected which do not use the slave ptr.
559 ++ */
560 ++ synchronize_irq(priv->irq);
561 + priv->slave = NULL;
562 +
563 + return 0;
564 +@@ -358,7 +365,7 @@ static int em_i2c_probe(struct platform_device *pdev)
565 + {
566 + struct em_i2c_device *priv;
567 + struct resource *r;
568 +- int irq, ret;
569 ++ int ret;
570 +
571 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
572 + if (!priv)
573 +@@ -393,8 +400,8 @@ static int em_i2c_probe(struct platform_device *pdev)
574 +
575 + em_i2c_reset(&priv->adap);
576 +
577 +- irq = platform_get_irq(pdev, 0);
578 +- ret = devm_request_irq(&pdev->dev, irq, em_i2c_irq_handler, 0,
579 ++ priv->irq = platform_get_irq(pdev, 0);
580 ++ ret = devm_request_irq(&pdev->dev, priv->irq, em_i2c_irq_handler, 0,
581 + "em_i2c", priv);
582 + if (ret)
583 + goto err_clk;
584 +@@ -404,7 +411,8 @@ static int em_i2c_probe(struct platform_device *pdev)
585 + if (ret)
586 + goto err_clk;
587 +
588 +- dev_info(&pdev->dev, "Added i2c controller %d, irq %d\n", priv->adap.nr, irq);
589 ++ dev_info(&pdev->dev, "Added i2c controller %d, irq %d\n", priv->adap.nr,
590 ++ priv->irq);
591 +
592 + return 0;
593 +
594 +diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
595 +index 174579d32e5f..4b81dc231b18 100644
596 +--- a/drivers/i2c/busses/i2c-piix4.c
597 ++++ b/drivers/i2c/busses/i2c-piix4.c
598 +@@ -99,7 +99,7 @@
599 + #define SB800_PIIX4_PORT_IDX_MASK 0x06
600 + #define SB800_PIIX4_PORT_IDX_SHIFT 1
601 +
602 +-/* On kerncz, SmBus0Sel is at bit 20:19 of PMx00 DecodeEn */
603 ++/* On kerncz and Hudson2, SmBus0Sel is at bit 20:19 of PMx00 DecodeEn */
604 + #define SB800_PIIX4_PORT_IDX_KERNCZ 0x02
605 + #define SB800_PIIX4_PORT_IDX_MASK_KERNCZ 0x18
606 + #define SB800_PIIX4_PORT_IDX_SHIFT_KERNCZ 3
607 +@@ -359,18 +359,16 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev,
608 +
609 + /* Find which register is used for port selection */
610 + if (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD) {
611 +- switch (PIIX4_dev->device) {
612 +- case PCI_DEVICE_ID_AMD_KERNCZ_SMBUS:
613 ++ if (PIIX4_dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS ||
614 ++ (PIIX4_dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS &&
615 ++ PIIX4_dev->revision >= 0x1F)) {
616 + piix4_port_sel_sb800 = SB800_PIIX4_PORT_IDX_KERNCZ;
617 + piix4_port_mask_sb800 = SB800_PIIX4_PORT_IDX_MASK_KERNCZ;
618 + piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT_KERNCZ;
619 +- break;
620 +- case PCI_DEVICE_ID_AMD_HUDSON2_SMBUS:
621 +- default:
622 ++ } else {
623 + piix4_port_sel_sb800 = SB800_PIIX4_PORT_IDX_ALT;
624 + piix4_port_mask_sb800 = SB800_PIIX4_PORT_IDX_MASK;
625 + piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT;
626 +- break;
627 + }
628 + } else {
629 + mutex_lock(&piix4_mutex_sb800);
630 +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
631 +index 3415733a9364..132c4a405bf8 100644
632 +--- a/drivers/i2c/busses/i2c-rcar.c
633 ++++ b/drivers/i2c/busses/i2c-rcar.c
634 +@@ -144,6 +144,7 @@ struct rcar_i2c_priv {
635 + enum dma_data_direction dma_direction;
636 +
637 + struct reset_control *rstc;
638 ++ int irq;
639 + };
640 +
641 + #define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent)
642 +@@ -813,9 +814,11 @@ static int rcar_unreg_slave(struct i2c_client *slave)
643 +
644 + WARN_ON(!priv->slave);
645 +
646 ++ /* disable irqs and ensure none is running before clearing ptr */
647 + rcar_i2c_write(priv, ICSIER, 0);
648 + rcar_i2c_write(priv, ICSCR, 0);
649 +
650 ++ synchronize_irq(priv->irq);
651 + priv->slave = NULL;
652 +
653 + pm_runtime_put(rcar_i2c_priv_to_dev(priv));
654 +@@ -866,7 +869,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
655 + struct i2c_adapter *adap;
656 + struct device *dev = &pdev->dev;
657 + struct i2c_timings i2c_t;
658 +- int irq, ret;
659 ++ int ret;
660 +
661 + priv = devm_kzalloc(dev, sizeof(struct rcar_i2c_priv), GFP_KERNEL);
662 + if (!priv)
663 +@@ -927,10 +930,10 @@ static int rcar_i2c_probe(struct platform_device *pdev)
664 + pm_runtime_put(dev);
665 +
666 +
667 +- irq = platform_get_irq(pdev, 0);
668 +- ret = devm_request_irq(dev, irq, rcar_i2c_irq, 0, dev_name(dev), priv);
669 ++ priv->irq = platform_get_irq(pdev, 0);
670 ++ ret = devm_request_irq(dev, priv->irq, rcar_i2c_irq, 0, dev_name(dev), priv);
671 + if (ret < 0) {
672 +- dev_err(dev, "cannot get irq %d\n", irq);
673 ++ dev_err(dev, "cannot get irq %d\n", priv->irq);
674 + goto out_pm_disable;
675 + }
676 +
677 +diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
678 +index 9d1cebe7f6cb..c87764a4e212 100644
679 +--- a/drivers/iommu/dma-iommu.c
680 ++++ b/drivers/iommu/dma-iommu.c
681 +@@ -684,7 +684,7 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents,
682 + * - and wouldn't make the resulting output segment too long
683 + */
684 + if (cur_len && !s_iova_off && (dma_addr & seg_mask) &&
685 +- (cur_len + s_length <= max_len)) {
686 ++ (max_len - cur_len >= s_length)) {
687 + /* ...then concatenate it with the previous one */
688 + cur_len += s_length;
689 + } else {
690 +diff --git a/drivers/misc/vmw_vmci/vmci_doorbell.c b/drivers/misc/vmw_vmci/vmci_doorbell.c
691 +index b3fa738ae005..f005206d9033 100644
692 +--- a/drivers/misc/vmw_vmci/vmci_doorbell.c
693 ++++ b/drivers/misc/vmw_vmci/vmci_doorbell.c
694 +@@ -318,7 +318,8 @@ int vmci_dbell_host_context_notify(u32 src_cid, struct vmci_handle handle)
695 +
696 + entry = container_of(resource, struct dbell_entry, resource);
697 + if (entry->run_delayed) {
698 +- schedule_work(&entry->work);
699 ++ if (!schedule_work(&entry->work))
700 ++ vmci_resource_put(resource);
701 + } else {
702 + entry->notify_cb(entry->client_data);
703 + vmci_resource_put(resource);
704 +@@ -366,7 +367,8 @@ static void dbell_fire_entries(u32 notify_idx)
705 + atomic_read(&dbell->active) == 1) {
706 + if (dbell->run_delayed) {
707 + vmci_resource_get(&dbell->resource);
708 +- schedule_work(&dbell->work);
709 ++ if (!schedule_work(&dbell->work))
710 ++ vmci_resource_put(&dbell->resource);
711 + } else {
712 + dbell->notify_cb(dbell->client_data);
713 + }
714 +diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
715 +index fe2ef52135b6..33975ec14b7e 100644
716 +--- a/drivers/mmc/core/sd.c
717 ++++ b/drivers/mmc/core/sd.c
718 +@@ -1232,6 +1232,12 @@ int mmc_attach_sd(struct mmc_host *host)
719 + goto err;
720 + }
721 +
722 ++ /*
723 ++ * Some SD cards claims an out of spec VDD voltage range. Let's treat
724 ++ * these bits as being in-valid and especially also bit7.
725 ++ */
726 ++ ocr &= ~0x7FFF;
727 ++
728 + rocr = mmc_select_voltage(host, ocr);
729 +
730 + /*
731 +diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
732 +index 4e47ed6bc716..74af8cc4ef36 100644
733 +--- a/drivers/mmc/host/sdhci-of-at91.c
734 ++++ b/drivers/mmc/host/sdhci-of-at91.c
735 +@@ -364,6 +364,9 @@ static int sdhci_at91_probe(struct platform_device *pdev)
736 + pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
737 + pm_runtime_use_autosuspend(&pdev->dev);
738 +
739 ++ /* HS200 is broken at this moment */
740 ++ host->quirks2 = SDHCI_QUIRK2_BROKEN_HS200;
741 ++
742 + ret = sdhci_add_host(host);
743 + if (ret)
744 + goto pm_runtime_disable;
745 +diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h
746 +index 23129d7b2678..c77e36526447 100644
747 +--- a/drivers/scsi/ufs/unipro.h
748 ++++ b/drivers/scsi/ufs/unipro.h
749 +@@ -52,7 +52,7 @@
750 + #define RX_HS_UNTERMINATED_ENABLE 0x00A6
751 + #define RX_ENTER_HIBERN8 0x00A7
752 + #define RX_BYPASS_8B10B_ENABLE 0x00A8
753 +-#define RX_TERMINATION_FORCE_ENABLE 0x0089
754 ++#define RX_TERMINATION_FORCE_ENABLE 0x00A9
755 + #define RX_MIN_ACTIVATETIME_CAPABILITY 0x008F
756 + #define RX_HIBERN8TIME_CAPABILITY 0x0092
757 + #define RX_REFCLKFREQ 0x00EB
758 +diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
759 +index 340f97404034..e3a44bea7bb7 100644
760 +--- a/drivers/usb/chipidea/udc.c
761 ++++ b/drivers/usb/chipidea/udc.c
762 +@@ -711,12 +711,6 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
763 + struct ci_hdrc *ci = container_of(gadget, struct ci_hdrc, gadget);
764 + unsigned long flags;
765 +
766 +- spin_lock_irqsave(&ci->lock, flags);
767 +- ci->gadget.speed = USB_SPEED_UNKNOWN;
768 +- ci->remote_wakeup = 0;
769 +- ci->suspended = 0;
770 +- spin_unlock_irqrestore(&ci->lock, flags);
771 +-
772 + /* flush all endpoints */
773 + gadget_for_each_ep(ep, gadget) {
774 + usb_ep_fifo_flush(ep);
775 +@@ -734,6 +728,12 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
776 + ci->status = NULL;
777 + }
778 +
779 ++ spin_lock_irqsave(&ci->lock, flags);
780 ++ ci->gadget.speed = USB_SPEED_UNKNOWN;
781 ++ ci->remote_wakeup = 0;
782 ++ ci->suspended = 0;
783 ++ spin_unlock_irqrestore(&ci->lock, flags);
784 ++
785 + return 0;
786 + }
787 +
788 +@@ -1305,6 +1305,10 @@ static int ep_disable(struct usb_ep *ep)
789 + return -EBUSY;
790 +
791 + spin_lock_irqsave(hwep->lock, flags);
792 ++ if (hwep->ci->gadget.speed == USB_SPEED_UNKNOWN) {
793 ++ spin_unlock_irqrestore(hwep->lock, flags);
794 ++ return 0;
795 ++ }
796 +
797 + /* only internal SW should disable ctrl endpts */
798 +
799 +@@ -1394,6 +1398,10 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req,
800 + return -EINVAL;
801 +
802 + spin_lock_irqsave(hwep->lock, flags);
803 ++ if (hwep->ci->gadget.speed == USB_SPEED_UNKNOWN) {
804 ++ spin_unlock_irqrestore(hwep->lock, flags);
805 ++ return 0;
806 ++ }
807 + retval = _ep_queue(ep, req, gfp_flags);
808 + spin_unlock_irqrestore(hwep->lock, flags);
809 + return retval;
810 +@@ -1417,8 +1425,8 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
811 + return -EINVAL;
812 +
813 + spin_lock_irqsave(hwep->lock, flags);
814 +-
815 +- hw_ep_flush(hwep->ci, hwep->num, hwep->dir);
816 ++ if (hwep->ci->gadget.speed != USB_SPEED_UNKNOWN)
817 ++ hw_ep_flush(hwep->ci, hwep->num, hwep->dir);
818 +
819 + list_for_each_entry_safe(node, tmpnode, &hwreq->tds, td) {
820 + dma_pool_free(hwep->td_pool, node->ptr, node->dma);
821 +@@ -1489,6 +1497,10 @@ static void ep_fifo_flush(struct usb_ep *ep)
822 + }
823 +
824 + spin_lock_irqsave(hwep->lock, flags);
825 ++ if (hwep->ci->gadget.speed == USB_SPEED_UNKNOWN) {
826 ++ spin_unlock_irqrestore(hwep->lock, flags);
827 ++ return;
828 ++ }
829 +
830 + hw_ep_flush(hwep->ci, hwep->num, hwep->dir);
831 +
832 +@@ -1557,6 +1569,10 @@ static int ci_udc_wakeup(struct usb_gadget *_gadget)
833 + int ret = 0;
834 +
835 + spin_lock_irqsave(&ci->lock, flags);
836 ++ if (ci->gadget.speed == USB_SPEED_UNKNOWN) {
837 ++ spin_unlock_irqrestore(&ci->lock, flags);
838 ++ return 0;
839 ++ }
840 + if (!ci->remote_wakeup) {
841 + ret = -EOPNOTSUPP;
842 + goto out;
843 +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
844 +index 3e865dbf878c..a593cdfc897f 100644
845 +--- a/drivers/usb/class/cdc-wdm.c
846 ++++ b/drivers/usb/class/cdc-wdm.c
847 +@@ -584,10 +584,20 @@ static int wdm_flush(struct file *file, fl_owner_t id)
848 + {
849 + struct wdm_device *desc = file->private_data;
850 +
851 +- wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags));
852 ++ wait_event(desc->wait,
853 ++ /*
854 ++ * needs both flags. We cannot do with one
855 ++ * because resetting it would cause a race
856 ++ * with write() yet we need to signal
857 ++ * a disconnect
858 ++ */
859 ++ !test_bit(WDM_IN_USE, &desc->flags) ||
860 ++ test_bit(WDM_DISCONNECTING, &desc->flags));
861 +
862 + /* cannot dereference desc->intf if WDM_DISCONNECTING */
863 +- if (desc->werr < 0 && !test_bit(WDM_DISCONNECTING, &desc->flags))
864 ++ if (test_bit(WDM_DISCONNECTING, &desc->flags))
865 ++ return -ENODEV;
866 ++ if (desc->werr < 0)
867 + dev_err(&desc->intf->dev, "Error in flush path: %d\n",
868 + desc->werr);
869 +
870 +@@ -955,8 +965,6 @@ static void wdm_disconnect(struct usb_interface *intf)
871 + spin_lock_irqsave(&desc->iuspin, flags);
872 + set_bit(WDM_DISCONNECTING, &desc->flags);
873 + set_bit(WDM_READ, &desc->flags);
874 +- /* to terminate pending flushes */
875 +- clear_bit(WDM_IN_USE, &desc->flags);
876 + spin_unlock_irqrestore(&desc->iuspin, flags);
877 + wake_up_all(&desc->wait);
878 + mutex_lock(&desc->rlock);
879 +diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
880 +index b805962f5154..75c42393b64b 100644
881 +--- a/drivers/usb/gadget/composite.c
882 ++++ b/drivers/usb/gadget/composite.c
883 +@@ -2008,6 +2008,7 @@ void composite_disconnect(struct usb_gadget *gadget)
884 + * disconnect callbacks?
885 + */
886 + spin_lock_irqsave(&cdev->lock, flags);
887 ++ cdev->suspended = 0;
888 + if (cdev->config)
889 + reset_config(cdev);
890 + if (cdev->driver->disconnect)
891 +diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
892 +index 25ba30329533..41b5baa1f43b 100644
893 +--- a/drivers/usb/gadget/function/f_mass_storage.c
894 ++++ b/drivers/usb/gadget/function/f_mass_storage.c
895 +@@ -261,7 +261,7 @@ struct fsg_common;
896 + struct fsg_common {
897 + struct usb_gadget *gadget;
898 + struct usb_composite_dev *cdev;
899 +- struct fsg_dev *fsg, *new_fsg;
900 ++ struct fsg_dev *fsg;
901 + wait_queue_head_t io_wait;
902 + wait_queue_head_t fsg_wait;
903 +
904 +@@ -290,6 +290,7 @@ struct fsg_common {
905 + unsigned int bulk_out_maxpacket;
906 + enum fsg_state state; /* For exception handling */
907 + unsigned int exception_req_tag;
908 ++ void *exception_arg;
909 +
910 + enum data_direction data_dir;
911 + u32 data_size;
912 +@@ -393,7 +394,8 @@ static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)
913 +
914 + /* These routines may be called in process context or in_irq */
915 +
916 +-static void raise_exception(struct fsg_common *common, enum fsg_state new_state)
917 ++static void __raise_exception(struct fsg_common *common, enum fsg_state new_state,
918 ++ void *arg)
919 + {
920 + unsigned long flags;
921 +
922 +@@ -406,6 +408,7 @@ static void raise_exception(struct fsg_common *common, enum fsg_state new_state)
923 + if (common->state <= new_state) {
924 + common->exception_req_tag = common->ep0_req_tag;
925 + common->state = new_state;
926 ++ common->exception_arg = arg;
927 + if (common->thread_task)
928 + send_sig_info(SIGUSR1, SEND_SIG_FORCED,
929 + common->thread_task);
930 +@@ -413,6 +416,10 @@ static void raise_exception(struct fsg_common *common, enum fsg_state new_state)
931 + spin_unlock_irqrestore(&common->lock, flags);
932 + }
933 +
934 ++static void raise_exception(struct fsg_common *common, enum fsg_state new_state)
935 ++{
936 ++ __raise_exception(common, new_state, NULL);
937 ++}
938 +
939 + /*-------------------------------------------------------------------------*/
940 +
941 +@@ -2287,16 +2294,16 @@ reset:
942 + static int fsg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
943 + {
944 + struct fsg_dev *fsg = fsg_from_func(f);
945 +- fsg->common->new_fsg = fsg;
946 +- raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE);
947 ++
948 ++ __raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE, fsg);
949 + return USB_GADGET_DELAYED_STATUS;
950 + }
951 +
952 + static void fsg_disable(struct usb_function *f)
953 + {
954 + struct fsg_dev *fsg = fsg_from_func(f);
955 +- fsg->common->new_fsg = NULL;
956 +- raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE);
957 ++
958 ++ __raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE, NULL);
959 + }
960 +
961 +
962 +@@ -2309,6 +2316,7 @@ static void handle_exception(struct fsg_common *common)
963 + enum fsg_state old_state;
964 + struct fsg_lun *curlun;
965 + unsigned int exception_req_tag;
966 ++ struct fsg_dev *new_fsg;
967 +
968 + /*
969 + * Clear the existing signals. Anything but SIGUSR1 is converted
970 +@@ -2362,6 +2370,7 @@ static void handle_exception(struct fsg_common *common)
971 + common->next_buffhd_to_fill = &common->buffhds[0];
972 + common->next_buffhd_to_drain = &common->buffhds[0];
973 + exception_req_tag = common->exception_req_tag;
974 ++ new_fsg = common->exception_arg;
975 + old_state = common->state;
976 + common->state = FSG_STATE_NORMAL;
977 +
978 +@@ -2415,8 +2424,8 @@ static void handle_exception(struct fsg_common *common)
979 + break;
980 +
981 + case FSG_STATE_CONFIG_CHANGE:
982 +- do_set_interface(common, common->new_fsg);
983 +- if (common->new_fsg)
984 ++ do_set_interface(common, new_fsg);
985 ++ if (new_fsg)
986 + usb_composite_setup_continue(common->cdev);
987 + break;
988 +
989 +@@ -3007,8 +3016,7 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f)
990 +
991 + DBG(fsg, "unbind\n");
992 + if (fsg->common->fsg == fsg) {
993 +- fsg->common->new_fsg = NULL;
994 +- raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE);
995 ++ __raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE, NULL);
996 + /* FIXME: make interruptible or killable somehow? */
997 + wait_event(common->fsg_wait, common->fsg != fsg);
998 + }
999 +diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
1000 +index 457cc6525abd..aa2103682808 100644
1001 +--- a/drivers/usb/host/fotg210-hcd.c
1002 ++++ b/drivers/usb/host/fotg210-hcd.c
1003 +@@ -1652,6 +1652,10 @@ static int fotg210_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
1004 + /* see what we found out */
1005 + temp = check_reset_complete(fotg210, wIndex, status_reg,
1006 + fotg210_readl(fotg210, status_reg));
1007 ++
1008 ++ /* restart schedule */
1009 ++ fotg210->command |= CMD_RUN;
1010 ++ fotg210_writel(fotg210, fotg210->command, &fotg210->regs->command);
1011 + }
1012 +
1013 + if (!(temp & (PORT_RESUME|PORT_RESET))) {
1014 +diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
1015 +index b4599aa428f3..4ea1530257e2 100644
1016 +--- a/drivers/usb/host/ohci-hcd.c
1017 ++++ b/drivers/usb/host/ohci-hcd.c
1018 +@@ -417,8 +417,7 @@ static void ohci_usb_reset (struct ohci_hcd *ohci)
1019 + * other cases where the next software may expect clean state from the
1020 + * "firmware". this is bus-neutral, unlike shutdown() methods.
1021 + */
1022 +-static void
1023 +-ohci_shutdown (struct usb_hcd *hcd)
1024 ++static void _ohci_shutdown(struct usb_hcd *hcd)
1025 + {
1026 + struct ohci_hcd *ohci;
1027 +
1028 +@@ -434,6 +433,16 @@ ohci_shutdown (struct usb_hcd *hcd)
1029 + ohci->rh_state = OHCI_RH_HALTED;
1030 + }
1031 +
1032 ++static void ohci_shutdown(struct usb_hcd *hcd)
1033 ++{
1034 ++ struct ohci_hcd *ohci = hcd_to_ohci(hcd);
1035 ++ unsigned long flags;
1036 ++
1037 ++ spin_lock_irqsave(&ohci->lock, flags);
1038 ++ _ohci_shutdown(hcd);
1039 ++ spin_unlock_irqrestore(&ohci->lock, flags);
1040 ++}
1041 ++
1042 + /*-------------------------------------------------------------------------*
1043 + * HC functions
1044 + *-------------------------------------------------------------------------*/
1045 +@@ -752,7 +761,7 @@ static void io_watchdog_func(unsigned long _ohci)
1046 + died:
1047 + usb_hc_died(ohci_to_hcd(ohci));
1048 + ohci_dump(ohci);
1049 +- ohci_shutdown(ohci_to_hcd(ohci));
1050 ++ _ohci_shutdown(ohci_to_hcd(ohci));
1051 + goto done;
1052 + } else {
1053 + /* No write back because the done queue was empty */
1054 +diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
1055 +index 544e03452877..08eea4c402ee 100644
1056 +--- a/drivers/usb/host/xhci-rcar.c
1057 ++++ b/drivers/usb/host/xhci-rcar.c
1058 +@@ -113,7 +113,7 @@ static int xhci_rcar_is_gen2(struct device *dev)
1059 + return of_device_is_compatible(node, "renesas,xhci-r8a7790") ||
1060 + of_device_is_compatible(node, "renesas,xhci-r8a7791") ||
1061 + of_device_is_compatible(node, "renesas,xhci-r8a7793") ||
1062 +- of_device_is_compatible(node, "renensas,rcar-gen2-xhci");
1063 ++ of_device_is_compatible(node, "renesas,rcar-gen2-xhci");
1064 + }
1065 +
1066 + static int xhci_rcar_is_gen3(struct device *dev)
1067 +diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
1068 +index 1a6df40f8b53..8e0b12cc084a 100644
1069 +--- a/drivers/usb/storage/realtek_cr.c
1070 ++++ b/drivers/usb/storage/realtek_cr.c
1071 +@@ -50,7 +50,7 @@ MODULE_LICENSE("GPL");
1072 +
1073 + static int auto_delink_en = 1;
1074 + module_param(auto_delink_en, int, S_IRUGO | S_IWUSR);
1075 +-MODULE_PARM_DESC(auto_delink_en, "enable auto delink");
1076 ++MODULE_PARM_DESC(auto_delink_en, "auto delink mode (0=firmware, 1=software [default])");
1077 +
1078 + #ifdef CONFIG_REALTEK_AUTOPM
1079 + static int ss_en = 1;
1080 +@@ -1009,12 +1009,15 @@ static int init_realtek_cr(struct us_data *us)
1081 + goto INIT_FAIL;
1082 + }
1083 +
1084 +- if (CHECK_FW_VER(chip, 0x5888) || CHECK_FW_VER(chip, 0x5889) ||
1085 +- CHECK_FW_VER(chip, 0x5901))
1086 +- SET_AUTO_DELINK(chip);
1087 +- if (STATUS_LEN(chip) == 16) {
1088 +- if (SUPPORT_AUTO_DELINK(chip))
1089 ++ if (CHECK_PID(chip, 0x0138) || CHECK_PID(chip, 0x0158) ||
1090 ++ CHECK_PID(chip, 0x0159)) {
1091 ++ if (CHECK_FW_VER(chip, 0x5888) || CHECK_FW_VER(chip, 0x5889) ||
1092 ++ CHECK_FW_VER(chip, 0x5901))
1093 + SET_AUTO_DELINK(chip);
1094 ++ if (STATUS_LEN(chip) == 16) {
1095 ++ if (SUPPORT_AUTO_DELINK(chip))
1096 ++ SET_AUTO_DELINK(chip);
1097 ++ }
1098 + }
1099 + #ifdef CONFIG_REALTEK_AUTOPM
1100 + if (ss_en)
1101 +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
1102 +index 0fa88daed149..fb69cb64f7d4 100644
1103 +--- a/drivers/usb/storage/unusual_devs.h
1104 ++++ b/drivers/usb/storage/unusual_devs.h
1105 +@@ -2119,7 +2119,7 @@ UNUSUAL_DEV( 0x14cd, 0x6600, 0x0201, 0x0201,
1106 + US_FL_IGNORE_RESIDUE ),
1107 +
1108 + /* Reported by Michael Büsch <m@××××.ch> */
1109 +-UNUSUAL_DEV( 0x152d, 0x0567, 0x0114, 0x0116,
1110 ++UNUSUAL_DEV( 0x152d, 0x0567, 0x0114, 0x0117,
1111 + "JMicron",
1112 + "USB to ATA/ATAPI Bridge",
1113 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1114 +diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c
1115 +index b339e0e67b4c..adb699145a07 100644
1116 +--- a/drivers/watchdog/bcm2835_wdt.c
1117 ++++ b/drivers/watchdog/bcm2835_wdt.c
1118 +@@ -252,6 +252,7 @@ module_param(nowayout, bool, 0);
1119 + MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
1120 + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
1121 +
1122 ++MODULE_ALIAS("platform:bcm2835-wdt");
1123 + MODULE_AUTHOR("Lubomir Rintel <lkundrak@××.sk>");
1124 + MODULE_DESCRIPTION("Driver for Broadcom BCM2835 watchdog timer");
1125 + MODULE_LICENSE("GPL");
1126 +diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
1127 +index 89c03a507dd9..614ce1f8b4ac 100644
1128 +--- a/fs/nfs/direct.c
1129 ++++ b/fs/nfs/direct.c
1130 +@@ -400,15 +400,21 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr)
1131 + unsigned long bytes = 0;
1132 + struct nfs_direct_req *dreq = hdr->dreq;
1133 +
1134 +- if (test_bit(NFS_IOHDR_REDO, &hdr->flags))
1135 +- goto out_put;
1136 +-
1137 + spin_lock(&dreq->lock);
1138 +- if (test_bit(NFS_IOHDR_ERROR, &hdr->flags) && (hdr->good_bytes == 0))
1139 ++ if (test_bit(NFS_IOHDR_ERROR, &hdr->flags))
1140 + dreq->error = hdr->error;
1141 +- else
1142 ++
1143 ++ if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) {
1144 ++ spin_unlock(&dreq->lock);
1145 ++ goto out_put;
1146 ++ }
1147 ++
1148 ++ if (hdr->good_bytes != 0)
1149 + nfs_direct_good_bytes(dreq, hdr);
1150 +
1151 ++ if (test_bit(NFS_IOHDR_EOF, &hdr->flags))
1152 ++ dreq->error = 0;
1153 ++
1154 + spin_unlock(&dreq->lock);
1155 +
1156 + while (!list_empty(&hdr->pages)) {
1157 +@@ -428,7 +434,7 @@ out_put:
1158 + hdr->release(hdr);
1159 + }
1160 +
1161 +-static void nfs_read_sync_pgio_error(struct list_head *head)
1162 ++static void nfs_read_sync_pgio_error(struct list_head *head, int error)
1163 + {
1164 + struct nfs_page *req;
1165 +
1166 +@@ -664,8 +670,7 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
1167 +
1168 + list_for_each_entry_safe(req, tmp, &reqs, wb_list) {
1169 + if (!nfs_pageio_add_request(&desc, req)) {
1170 +- nfs_list_remove_request(req);
1171 +- nfs_list_add_request(req, &failed);
1172 ++ nfs_list_move_request(req, &failed);
1173 + spin_lock(&cinfo.inode->i_lock);
1174 + dreq->flags = 0;
1175 + if (desc.pg_error < 0)
1176 +@@ -775,16 +780,19 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr)
1177 + bool request_commit = false;
1178 + struct nfs_page *req = nfs_list_entry(hdr->pages.next);
1179 +
1180 +- if (test_bit(NFS_IOHDR_REDO, &hdr->flags))
1181 +- goto out_put;
1182 +-
1183 + nfs_init_cinfo_from_dreq(&cinfo, dreq);
1184 +
1185 + spin_lock(&dreq->lock);
1186 +
1187 + if (test_bit(NFS_IOHDR_ERROR, &hdr->flags))
1188 + dreq->error = hdr->error;
1189 +- if (dreq->error == 0) {
1190 ++
1191 ++ if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) {
1192 ++ spin_unlock(&dreq->lock);
1193 ++ goto out_put;
1194 ++ }
1195 ++
1196 ++ if (hdr->good_bytes != 0) {
1197 + nfs_direct_good_bytes(dreq, hdr);
1198 + if (nfs_write_need_commit(hdr)) {
1199 + if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES)
1200 +@@ -821,7 +829,7 @@ out_put:
1201 + hdr->release(hdr);
1202 + }
1203 +
1204 +-static void nfs_write_sync_pgio_error(struct list_head *head)
1205 ++static void nfs_write_sync_pgio_error(struct list_head *head, int error)
1206 + {
1207 + struct nfs_page *req;
1208 +
1209 +diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
1210 +index 28b013d1d44a..132e568524df 100644
1211 +--- a/fs/nfs/pagelist.c
1212 ++++ b/fs/nfs/pagelist.c
1213 +@@ -768,8 +768,7 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc,
1214 + pageused = 0;
1215 + while (!list_empty(head)) {
1216 + req = nfs_list_entry(head->next);
1217 +- nfs_list_remove_request(req);
1218 +- nfs_list_add_request(req, &hdr->pages);
1219 ++ nfs_list_move_request(req, &hdr->pages);
1220 +
1221 + if (!last_page || last_page != req->wb_page) {
1222 + pageused++;
1223 +@@ -961,8 +960,7 @@ static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc,
1224 + }
1225 + if (!nfs_can_coalesce_requests(prev, req, desc))
1226 + return 0;
1227 +- nfs_list_remove_request(req);
1228 +- nfs_list_add_request(req, &mirror->pg_list);
1229 ++ nfs_list_move_request(req, &mirror->pg_list);
1230 + mirror->pg_count += req->wb_bytes;
1231 + return 1;
1232 + }
1233 +@@ -994,9 +992,8 @@ nfs_pageio_cleanup_request(struct nfs_pageio_descriptor *desc,
1234 + {
1235 + LIST_HEAD(head);
1236 +
1237 +- nfs_list_remove_request(req);
1238 +- nfs_list_add_request(req, &head);
1239 +- desc->pg_completion_ops->error_cleanup(&head);
1240 ++ nfs_list_move_request(req, &head);
1241 ++ desc->pg_completion_ops->error_cleanup(&head, desc->pg_error);
1242 + }
1243 +
1244 + /**
1245 +@@ -1132,7 +1129,8 @@ static void nfs_pageio_error_cleanup(struct nfs_pageio_descriptor *desc)
1246 +
1247 + for (midx = 0; midx < desc->pg_mirror_count; midx++) {
1248 + mirror = &desc->pg_mirrors[midx];
1249 +- desc->pg_completion_ops->error_cleanup(&mirror->pg_list);
1250 ++ desc->pg_completion_ops->error_cleanup(&mirror->pg_list,
1251 ++ desc->pg_error);
1252 + }
1253 + }
1254 +
1255 +@@ -1234,21 +1232,23 @@ static void nfs_pageio_complete_mirror(struct nfs_pageio_descriptor *desc,
1256 + int nfs_pageio_resend(struct nfs_pageio_descriptor *desc,
1257 + struct nfs_pgio_header *hdr)
1258 + {
1259 +- LIST_HEAD(failed);
1260 ++ LIST_HEAD(pages);
1261 +
1262 + desc->pg_io_completion = hdr->io_completion;
1263 + desc->pg_dreq = hdr->dreq;
1264 +- while (!list_empty(&hdr->pages)) {
1265 +- struct nfs_page *req = nfs_list_entry(hdr->pages.next);
1266 ++ list_splice_init(&hdr->pages, &pages);
1267 ++ while (!list_empty(&pages)) {
1268 ++ struct nfs_page *req = nfs_list_entry(pages.next);
1269 +
1270 +- nfs_list_remove_request(req);
1271 + if (!nfs_pageio_add_request(desc, req))
1272 +- nfs_list_add_request(req, &failed);
1273 ++ break;
1274 + }
1275 + nfs_pageio_complete(desc);
1276 +- if (!list_empty(&failed)) {
1277 +- list_move(&failed, &hdr->pages);
1278 +- return desc->pg_error < 0 ? desc->pg_error : -EIO;
1279 ++ if (!list_empty(&pages)) {
1280 ++ int err = desc->pg_error < 0 ? desc->pg_error : -EIO;
1281 ++ hdr->completion_ops->error_cleanup(&pages, err);
1282 ++ nfs_set_pgio_error(hdr, err, hdr->io_start);
1283 ++ return err;
1284 + }
1285 + return 0;
1286 + }
1287 +diff --git a/fs/nfs/read.c b/fs/nfs/read.c
1288 +index 48d7277c60a9..09d5c282f50e 100644
1289 +--- a/fs/nfs/read.c
1290 ++++ b/fs/nfs/read.c
1291 +@@ -205,7 +205,7 @@ static void nfs_initiate_read(struct nfs_pgio_header *hdr,
1292 + }
1293 +
1294 + static void
1295 +-nfs_async_read_error(struct list_head *head)
1296 ++nfs_async_read_error(struct list_head *head, int error)
1297 + {
1298 + struct nfs_page *req;
1299 +
1300 +diff --git a/fs/nfs/write.c b/fs/nfs/write.c
1301 +index 50ed3944d183..3c1e46f4bce3 100644
1302 +--- a/fs/nfs/write.c
1303 ++++ b/fs/nfs/write.c
1304 +@@ -1397,20 +1397,27 @@ static void nfs_redirty_request(struct nfs_page *req)
1305 + nfs_release_request(req);
1306 + }
1307 +
1308 +-static void nfs_async_write_error(struct list_head *head)
1309 ++static void nfs_async_write_error(struct list_head *head, int error)
1310 + {
1311 + struct nfs_page *req;
1312 +
1313 + while (!list_empty(head)) {
1314 + req = nfs_list_entry(head->next);
1315 + nfs_list_remove_request(req);
1316 ++ if (nfs_error_is_fatal(error)) {
1317 ++ nfs_context_set_write_error(req->wb_context, error);
1318 ++ if (nfs_error_is_fatal_on_server(error)) {
1319 ++ nfs_write_error_remove_page(req);
1320 ++ continue;
1321 ++ }
1322 ++ }
1323 + nfs_redirty_request(req);
1324 + }
1325 + }
1326 +
1327 + static void nfs_async_write_reschedule_io(struct nfs_pgio_header *hdr)
1328 + {
1329 +- nfs_async_write_error(&hdr->pages);
1330 ++ nfs_async_write_error(&hdr->pages, 0);
1331 + }
1332 +
1333 + static const struct nfs_pgio_completion_ops nfs_async_write_completion_ops = {
1334 +diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
1335 +index e27572d30d97..ad69430fd0eb 100644
1336 +--- a/include/linux/nfs_page.h
1337 ++++ b/include/linux/nfs_page.h
1338 +@@ -164,6 +164,16 @@ nfs_list_add_request(struct nfs_page *req, struct list_head *head)
1339 + list_add_tail(&req->wb_list, head);
1340 + }
1341 +
1342 ++/**
1343 ++ * nfs_list_move_request - Move a request to a new list
1344 ++ * @req: request
1345 ++ * @head: head of list into which to insert the request.
1346 ++ */
1347 ++static inline void
1348 ++nfs_list_move_request(struct nfs_page *req, struct list_head *head)
1349 ++{
1350 ++ list_move_tail(&req->wb_list, head);
1351 ++}
1352 +
1353 + /**
1354 + * nfs_list_remove_request - Remove a request from its wb_list
1355 +diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
1356 +index 6959968dc36a..373fb26b5fed 100644
1357 +--- a/include/linux/nfs_xdr.h
1358 ++++ b/include/linux/nfs_xdr.h
1359 +@@ -1520,7 +1520,7 @@ struct nfs_commit_data {
1360 + };
1361 +
1362 + struct nfs_pgio_completion_ops {
1363 +- void (*error_cleanup)(struct list_head *head);
1364 ++ void (*error_cleanup)(struct list_head *head, int);
1365 + void (*init_hdr)(struct nfs_pgio_header *hdr);
1366 + void (*completion)(struct nfs_pgio_header *hdr);
1367 + void (*reschedule_io)(struct nfs_pgio_header *hdr);
1368 +diff --git a/include/net/tcp.h b/include/net/tcp.h
1369 +index 7994e569644e..785c4ef4e1bf 100644
1370 +--- a/include/net/tcp.h
1371 ++++ b/include/net/tcp.h
1372 +@@ -1702,6 +1702,10 @@ static inline struct sk_buff *tcp_rtx_queue_tail(const struct sock *sk)
1373 + {
1374 + struct sk_buff *skb = tcp_send_head(sk);
1375 +
1376 ++ /* empty retransmit queue, for example due to zero window */
1377 ++ if (skb == tcp_write_queue_head(sk))
1378 ++ return NULL;
1379 ++
1380 + return skb ? tcp_write_queue_prev(sk, skb) : tcp_write_queue_tail(sk);
1381 + }
1382 +
1383 +diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
1384 +index 7420f5f36094..10b3e3b22af6 100644
1385 +--- a/kernel/trace/ftrace.c
1386 ++++ b/kernel/trace/ftrace.c
1387 +@@ -3184,6 +3184,14 @@ t_probe_next(struct seq_file *m, loff_t *pos)
1388 + hnd = &iter->probe_entry->hlist;
1389 +
1390 + hash = iter->probe->ops.func_hash->filter_hash;
1391 ++
1392 ++ /*
1393 ++ * A probe being registered may temporarily have an empty hash
1394 ++ * and it's at the end of the func_probes list.
1395 ++ */
1396 ++ if (!hash || hash == EMPTY_HASH)
1397 ++ return NULL;
1398 ++
1399 + size = 1 << hash->size_bits;
1400 +
1401 + retry:
1402 +@@ -4380,12 +4388,21 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr,
1403 +
1404 + mutex_unlock(&ftrace_lock);
1405 +
1406 ++ /*
1407 ++ * Note, there's a small window here that the func_hash->filter_hash
1408 ++ * may be NULL or empty. Need to be carefule when reading the loop.
1409 ++ */
1410 + mutex_lock(&probe->ops.func_hash->regex_lock);
1411 +
1412 + orig_hash = &probe->ops.func_hash->filter_hash;
1413 + old_hash = *orig_hash;
1414 + hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, old_hash);
1415 +
1416 ++ if (!hash) {
1417 ++ ret = -ENOMEM;
1418 ++ goto out;
1419 ++ }
1420 ++
1421 + ret = ftrace_match_records(hash, glob, strlen(glob));
1422 +
1423 + /* Nothing found? */
1424 +diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
1425 +index c5317a7f05e9..3197de2a3896 100644
1426 +--- a/mm/zsmalloc.c
1427 ++++ b/mm/zsmalloc.c
1428 +@@ -2431,7 +2431,9 @@ struct zs_pool *zs_create_pool(const char *name)
1429 + if (!pool->name)
1430 + goto err;
1431 +
1432 ++#ifdef CONFIG_COMPACTION
1433 + init_waitqueue_head(&pool->migration_wait);
1434 ++#endif
1435 +
1436 + if (create_cache(pool))
1437 + goto err;
1438 +diff --git a/net/core/stream.c b/net/core/stream.c
1439 +index 1cff9c6270c6..31839fb06d88 100644
1440 +--- a/net/core/stream.c
1441 ++++ b/net/core/stream.c
1442 +@@ -120,7 +120,6 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
1443 + int err = 0;
1444 + long vm_wait = 0;
1445 + long current_timeo = *timeo_p;
1446 +- bool noblock = (*timeo_p ? false : true);
1447 + DEFINE_WAIT_FUNC(wait, woken_wake_function);
1448 +
1449 + if (sk_stream_memory_free(sk))
1450 +@@ -133,11 +132,8 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
1451 +
1452 + if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
1453 + goto do_error;
1454 +- if (!*timeo_p) {
1455 +- if (noblock)
1456 +- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
1457 +- goto do_nonblock;
1458 +- }
1459 ++ if (!*timeo_p)
1460 ++ goto do_eagain;
1461 + if (signal_pending(current))
1462 + goto do_interrupted;
1463 + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
1464 +@@ -169,7 +165,13 @@ out:
1465 + do_error:
1466 + err = -EPIPE;
1467 + goto out;
1468 +-do_nonblock:
1469 ++do_eagain:
1470 ++ /* Make sure that whenever EAGAIN is returned, EPOLLOUT event can
1471 ++ * be generated later.
1472 ++ * When TCP receives ACK packets that make room, tcp_check_space()
1473 ++ * only calls tcp_new_space() if SOCK_NOSPACE is set.
1474 ++ */
1475 ++ set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
1476 + err = -EAGAIN;
1477 + goto out;
1478 + do_interrupted:
1479 +diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
1480 +index 150dd2160cef..8168c667d91d 100644
1481 +--- a/net/mac80211/cfg.c
1482 ++++ b/net/mac80211/cfg.c
1483 +@@ -1459,6 +1459,11 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1484 + if (is_multicast_ether_addr(mac))
1485 + return -EINVAL;
1486 +
1487 ++ if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) &&
1488 ++ sdata->vif.type == NL80211_IFTYPE_STATION &&
1489 ++ !sdata->u.mgd.associated)
1490 ++ return -EINVAL;
1491 ++
1492 + sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
1493 + if (!sta)
1494 + return -ENOMEM;
1495 +@@ -1466,10 +1471,6 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1496 + if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1497 + sta->sta.tdls = true;
1498 +
1499 +- if (sta->sta.tdls && sdata->vif.type == NL80211_IFTYPE_STATION &&
1500 +- !sdata->u.mgd.associated)
1501 +- return -EINVAL;
1502 +-
1503 + err = sta_apply_parameters(local, sta, params);
1504 + if (err) {
1505 + sta_info_free(local, sta);
1506 +diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
1507 +index 710ab3fbf607..ec9397ec2def 100644
1508 +--- a/net/smc/smc_tx.c
1509 ++++ b/net/smc/smc_tx.c
1510 +@@ -70,13 +70,11 @@ static int smc_tx_wait_memory(struct smc_sock *smc, int flags)
1511 + DEFINE_WAIT_FUNC(wait, woken_wake_function);
1512 + struct smc_connection *conn = &smc->conn;
1513 + struct sock *sk = &smc->sk;
1514 +- bool noblock;
1515 + long timeo;
1516 + int rc = 0;
1517 +
1518 + /* similar to sk_stream_wait_memory */
1519 + timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
1520 +- noblock = timeo ? false : true;
1521 + add_wait_queue(sk_sleep(sk), &wait);
1522 + while (1) {
1523 + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
1524 +@@ -91,8 +89,8 @@ static int smc_tx_wait_memory(struct smc_sock *smc, int flags)
1525 + break;
1526 + }
1527 + if (!timeo) {
1528 +- if (noblock)
1529 +- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
1530 ++ /* ensure EPOLLOUT is subsequently generated */
1531 ++ set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
1532 + rc = -EAGAIN;
1533 + break;
1534 + }
1535 +diff --git a/net/wireless/reg.c b/net/wireless/reg.c
1536 +index ebfbc3f1be42..376f08798169 100644
1537 +--- a/net/wireless/reg.c
1538 ++++ b/net/wireless/reg.c
1539 +@@ -2252,7 +2252,7 @@ static void reg_process_pending_hints(void)
1540 +
1541 + /* When last_request->processed becomes true this will be rescheduled */
1542 + if (lr && !lr->processed) {
1543 +- reg_process_hint(lr);
1544 ++ pr_debug("Pending regulatory request, waiting for it to be processed...\n");
1545 + return;
1546 + }
1547 +
1548 +diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
1549 +index cc5b4c25d6f1..92b0d4523a07 100644
1550 +--- a/sound/core/seq/seq_clientmgr.c
1551 ++++ b/sound/core/seq/seq_clientmgr.c
1552 +@@ -1821,8 +1821,7 @@ static int snd_seq_ioctl_get_client_pool(struct snd_seq_client *client,
1553 + if (cptr->type == USER_CLIENT) {
1554 + info->input_pool = cptr->data.user.fifo_pool_size;
1555 + info->input_free = info->input_pool;
1556 +- if (cptr->data.user.fifo)
1557 +- info->input_free = snd_seq_unused_cells(cptr->data.user.fifo->pool);
1558 ++ info->input_free = snd_seq_fifo_unused_cells(cptr->data.user.fifo);
1559 + } else {
1560 + info->input_pool = 0;
1561 + info->input_free = 0;
1562 +diff --git a/sound/core/seq/seq_fifo.c b/sound/core/seq/seq_fifo.c
1563 +index 72c0302a55d2..6a24732704fc 100644
1564 +--- a/sound/core/seq/seq_fifo.c
1565 ++++ b/sound/core/seq/seq_fifo.c
1566 +@@ -280,3 +280,20 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
1567 +
1568 + return 0;
1569 + }
1570 ++
1571 ++/* get the number of unused cells safely */
1572 ++int snd_seq_fifo_unused_cells(struct snd_seq_fifo *f)
1573 ++{
1574 ++ unsigned long flags;
1575 ++ int cells;
1576 ++
1577 ++ if (!f)
1578 ++ return 0;
1579 ++
1580 ++ snd_use_lock_use(&f->use_lock);
1581 ++ spin_lock_irqsave(&f->lock, flags);
1582 ++ cells = snd_seq_unused_cells(f->pool);
1583 ++ spin_unlock_irqrestore(&f->lock, flags);
1584 ++ snd_use_lock_free(&f->use_lock);
1585 ++ return cells;
1586 ++}
1587 +diff --git a/sound/core/seq/seq_fifo.h b/sound/core/seq/seq_fifo.h
1588 +index 062c446e7867..5d38a0d7f0cd 100644
1589 +--- a/sound/core/seq/seq_fifo.h
1590 ++++ b/sound/core/seq/seq_fifo.h
1591 +@@ -68,5 +68,7 @@ int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file, poll_table
1592 + /* resize pool in fifo */
1593 + int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize);
1594 +
1595 ++/* get the number of unused cells safely */
1596 ++int snd_seq_fifo_unused_cells(struct snd_seq_fifo *f);
1597 +
1598 + #endif
1599 +diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
1600 +index ff5206f5455d..42c2a3065b77 100644
1601 +--- a/sound/soc/soc-core.c
1602 ++++ b/sound/soc/soc-core.c
1603 +@@ -1757,11 +1757,8 @@ static int soc_probe_link_dais(struct snd_soc_card *card,
1604 + }
1605 + }
1606 +
1607 +- if (dai_link->dai_fmt) {
1608 +- ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
1609 +- if (ret)
1610 +- return ret;
1611 +- }
1612 ++ if (dai_link->dai_fmt)
1613 ++ snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
1614 +
1615 + ret = soc_post_component_init(rtd, dai_link->name);
1616 + if (ret)
1617 +diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c
1618 +index f5614507a81c..896add5ffee3 100644
1619 +--- a/sound/usb/line6/pcm.c
1620 ++++ b/sound/usb/line6/pcm.c
1621 +@@ -552,6 +552,15 @@ int line6_init_pcm(struct usb_line6 *line6,
1622 + line6pcm->volume_monitor = 255;
1623 + line6pcm->line6 = line6;
1624 +
1625 ++ spin_lock_init(&line6pcm->out.lock);
1626 ++ spin_lock_init(&line6pcm->in.lock);
1627 ++ line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD;
1628 ++
1629 ++ line6->line6pcm = line6pcm;
1630 ++
1631 ++ pcm->private_data = line6pcm;
1632 ++ pcm->private_free = line6_cleanup_pcm;
1633 ++
1634 + line6pcm->max_packet_size_in =
1635 + usb_maxpacket(line6->usbdev,
1636 + usb_rcvisocpipe(line6->usbdev, ep_read), 0);
1637 +@@ -564,15 +573,6 @@ int line6_init_pcm(struct usb_line6 *line6,
1638 + return -EINVAL;
1639 + }
1640 +
1641 +- spin_lock_init(&line6pcm->out.lock);
1642 +- spin_lock_init(&line6pcm->in.lock);
1643 +- line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD;
1644 +-
1645 +- line6->line6pcm = line6pcm;
1646 +-
1647 +- pcm->private_data = line6pcm;
1648 +- pcm->private_free = line6_cleanup_pcm;
1649 +-
1650 + err = line6_create_audio_out_urbs(line6pcm);
1651 + if (err < 0)
1652 + return err;
1653 +diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
1654 +index 3d93e33b3485..5d48f8e74c56 100644
1655 +--- a/sound/usb/mixer.c
1656 ++++ b/sound/usb/mixer.c
1657 +@@ -82,6 +82,7 @@ struct mixer_build {
1658 + unsigned char *buffer;
1659 + unsigned int buflen;
1660 + DECLARE_BITMAP(unitbitmap, MAX_ID_ELEMS);
1661 ++ DECLARE_BITMAP(termbitmap, MAX_ID_ELEMS);
1662 + struct usb_audio_term oterm;
1663 + const struct usbmix_name_map *map;
1664 + const struct usbmix_selector_map *selector_map;
1665 +@@ -716,15 +717,24 @@ static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm
1666 + * parse the source unit recursively until it reaches to a terminal
1667 + * or a branched unit.
1668 + */
1669 +-static int check_input_term(struct mixer_build *state, int id,
1670 ++static int __check_input_term(struct mixer_build *state, int id,
1671 + struct usb_audio_term *term)
1672 + {
1673 + int err;
1674 + void *p1;
1675 ++ unsigned char *hdr;
1676 +
1677 + memset(term, 0, sizeof(*term));
1678 +- while ((p1 = find_audio_control_unit(state, id)) != NULL) {
1679 +- unsigned char *hdr = p1;
1680 ++ for (;;) {
1681 ++ /* a loop in the terminal chain? */
1682 ++ if (test_and_set_bit(id, state->termbitmap))
1683 ++ return -EINVAL;
1684 ++
1685 ++ p1 = find_audio_control_unit(state, id);
1686 ++ if (!p1)
1687 ++ break;
1688 ++
1689 ++ hdr = p1;
1690 + term->id = id;
1691 + switch (hdr[2]) {
1692 + case UAC_INPUT_TERMINAL:
1693 +@@ -739,7 +749,7 @@ static int check_input_term(struct mixer_build *state, int id,
1694 +
1695 + /* call recursively to verify that the
1696 + * referenced clock entity is valid */
1697 +- err = check_input_term(state, d->bCSourceID, term);
1698 ++ err = __check_input_term(state, d->bCSourceID, term);
1699 + if (err < 0)
1700 + return err;
1701 +
1702 +@@ -771,7 +781,7 @@ static int check_input_term(struct mixer_build *state, int id,
1703 + case UAC2_CLOCK_SELECTOR: {
1704 + struct uac_selector_unit_descriptor *d = p1;
1705 + /* call recursively to retrieve the channel info */
1706 +- err = check_input_term(state, d->baSourceID[0], term);
1707 ++ err = __check_input_term(state, d->baSourceID[0], term);
1708 + if (err < 0)
1709 + return err;
1710 + term->type = d->bDescriptorSubtype << 16; /* virtual type */
1711 +@@ -818,6 +828,15 @@ static int check_input_term(struct mixer_build *state, int id,
1712 + return -ENODEV;
1713 + }
1714 +
1715 ++
1716 ++static int check_input_term(struct mixer_build *state, int id,
1717 ++ struct usb_audio_term *term)
1718 ++{
1719 ++ memset(term, 0, sizeof(*term));
1720 ++ memset(state->termbitmap, 0, sizeof(state->termbitmap));
1721 ++ return __check_input_term(state, id, term);
1722 ++}
1723 ++
1724 + /*
1725 + * Feature Unit
1726 + */
1727 +@@ -1700,6 +1719,7 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid,
1728 + int pin, ich, err;
1729 +
1730 + if (desc->bLength < 11 || !(input_pins = desc->bNrInPins) ||
1731 ++ desc->bLength < sizeof(*desc) + desc->bNrInPins ||
1732 + !(num_outs = uac_mixer_unit_bNrChannels(desc))) {
1733 + usb_audio_err(state->chip,
1734 + "invalid MIXER UNIT descriptor %d\n",
1735 +diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
1736 +index 62c9a503ae05..0ef215061fb5 100644
1737 +--- a/tools/hv/hv_kvp_daemon.c
1738 ++++ b/tools/hv/hv_kvp_daemon.c
1739 +@@ -1380,6 +1380,8 @@ int main(int argc, char *argv[])
1740 + daemonize = 0;
1741 + break;
1742 + case 'h':
1743 ++ print_usage(argv);
1744 ++ exit(0);
1745 + default:
1746 + print_usage(argv);
1747 + exit(EXIT_FAILURE);
1748 +diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
1749 +index 34031a297f02..514d29966ac6 100644
1750 +--- a/tools/hv/hv_vss_daemon.c
1751 ++++ b/tools/hv/hv_vss_daemon.c
1752 +@@ -172,6 +172,8 @@ int main(int argc, char *argv[])
1753 + daemonize = 0;
1754 + break;
1755 + case 'h':
1756 ++ print_usage(argv);
1757 ++ exit(0);
1758 + default:
1759 + print_usage(argv);
1760 + exit(EXIT_FAILURE);
1761 +diff --git a/virt/kvm/arm/vgic/vgic-mmio.c b/virt/kvm/arm/vgic/vgic-mmio.c
1762 +index 36194c666814..63c6b630174f 100644
1763 +--- a/virt/kvm/arm/vgic/vgic-mmio.c
1764 ++++ b/virt/kvm/arm/vgic/vgic-mmio.c
1765 +@@ -123,6 +123,12 @@ unsigned long vgic_mmio_read_pending(struct kvm_vcpu *vcpu,
1766 + return value;
1767 + }
1768 +
1769 ++static bool is_vgic_v2_sgi(struct kvm_vcpu *vcpu, struct vgic_irq *irq)
1770 ++{
1771 ++ return (vgic_irq_is_sgi(irq->intid) &&
1772 ++ vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V2);
1773 ++}
1774 ++
1775 + void vgic_mmio_write_spending(struct kvm_vcpu *vcpu,
1776 + gpa_t addr, unsigned int len,
1777 + unsigned long val)
1778 +@@ -133,6 +139,12 @@ void vgic_mmio_write_spending(struct kvm_vcpu *vcpu,
1779 + for_each_set_bit(i, &val, len * 8) {
1780 + struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
1781 +
1782 ++ /* GICD_ISPENDR0 SGI bits are WI */
1783 ++ if (is_vgic_v2_sgi(vcpu, irq)) {
1784 ++ vgic_put_irq(vcpu->kvm, irq);
1785 ++ continue;
1786 ++ }
1787 ++
1788 + spin_lock(&irq->irq_lock);
1789 + irq->pending_latch = true;
1790 +
1791 +@@ -151,6 +163,12 @@ void vgic_mmio_write_cpending(struct kvm_vcpu *vcpu,
1792 + for_each_set_bit(i, &val, len * 8) {
1793 + struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
1794 +
1795 ++ /* GICD_ICPENDR0 SGI bits are WI */
1796 ++ if (is_vgic_v2_sgi(vcpu, irq)) {
1797 ++ vgic_put_irq(vcpu->kvm, irq);
1798 ++ continue;
1799 ++ }
1800 ++
1801 + spin_lock(&irq->irq_lock);
1802 +
1803 + irq->pending_latch = false;
1804 +diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c
1805 +index a2273a5aaece..7fe39de1ee33 100644
1806 +--- a/virt/kvm/arm/vgic/vgic-v2.c
1807 ++++ b/virt/kvm/arm/vgic/vgic-v2.c
1808 +@@ -142,7 +142,10 @@ void vgic_v2_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr)
1809 + if (vgic_irq_is_sgi(irq->intid)) {
1810 + u32 src = ffs(irq->source);
1811 +
1812 +- BUG_ON(!src);
1813 ++ if (WARN_RATELIMIT(!src, "No SGI source for INTID %d\n",
1814 ++ irq->intid))
1815 ++ return;
1816 ++
1817 + val |= (src - 1) << GICH_LR_PHYSID_CPUID_SHIFT;
1818 + irq->source &= ~(1 << (src - 1));
1819 + if (irq->source)
1820 +diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
1821 +index 094f8ff8f7ba..084edc9dc553 100644
1822 +--- a/virt/kvm/arm/vgic/vgic-v3.c
1823 ++++ b/virt/kvm/arm/vgic/vgic-v3.c
1824 +@@ -124,7 +124,10 @@ void vgic_v3_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr)
1825 + model == KVM_DEV_TYPE_ARM_VGIC_V2) {
1826 + u32 src = ffs(irq->source);
1827 +
1828 +- BUG_ON(!src);
1829 ++ if (WARN_RATELIMIT(!src, "No SGI source for INTID %d\n",
1830 ++ irq->intid))
1831 ++ return;
1832 ++
1833 + val |= (src - 1) << GICH_LR_PHYSID_CPUID_SHIFT;
1834 + irq->source &= ~(1 << (src - 1));
1835 + if (irq->source)
1836 +diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c
1837 +index 9d4e01f10949..07ee8e4e00a2 100644
1838 +--- a/virt/kvm/arm/vgic/vgic.c
1839 ++++ b/virt/kvm/arm/vgic/vgic.c
1840 +@@ -199,6 +199,13 @@ static int vgic_irq_cmp(void *priv, struct list_head *a, struct list_head *b)
1841 + bool penda, pendb;
1842 + int ret;
1843 +
1844 ++ /*
1845 ++ * list_sort may call this function with the same element when
1846 ++ * the list is fairly long.
1847 ++ */
1848 ++ if (unlikely(irqa == irqb))
1849 ++ return 0;
1850 ++
1851 + spin_lock(&irqa->irq_lock);
1852 + spin_lock_nested(&irqb->irq_lock, SINGLE_DEPTH_NESTING);
1853 +