Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.4 commit in: /
Date: Thu, 28 Nov 2019 23:49:27
Message-Id: 1574984937.682b6b91928dd140f710b849c6088c907a05ab65.mpagano@gentoo
1 commit: 682b6b91928dd140f710b849c6088c907a05ab65
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Thu Nov 28 23:48:57 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Thu Nov 28 23:48:57 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=682b6b91
7
8 Linux patch 4.4.204
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1203_linux-4.4.204.patch | 4378 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 4382 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index e8a6184..72fc76b 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -855,6 +855,10 @@ Patch: 1202_linux-4.4.203.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.4.203
23
24 +Patch: 1203_linux-4.4.204.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.4.204
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/1203_linux-4.4.204.patch b/1203_linux-4.4.204.patch
33 new file mode 100644
34 index 0000000..dbe4f95
35 --- /dev/null
36 +++ b/1203_linux-4.4.204.patch
37 @@ -0,0 +1,4378 @@
38 +diff --git a/Documentation/hw-vuln/mds.rst b/Documentation/hw-vuln/mds.rst
39 +index 3f92728be021..7b8a1e9c5240 100644
40 +--- a/Documentation/hw-vuln/mds.rst
41 ++++ b/Documentation/hw-vuln/mds.rst
42 +@@ -262,8 +262,11 @@ time with the option "mds=". The valid arguments for this option are:
43 +
44 + ============ =============================================================
45 +
46 +-Not specifying this option is equivalent to "mds=full".
47 +-
48 ++Not specifying this option is equivalent to "mds=full". For processors
49 ++that are affected by both TAA (TSX Asynchronous Abort) and MDS,
50 ++specifying just "mds=off" without an accompanying "tsx_async_abort=off"
51 ++will have no effect as the same mitigation is used for both
52 ++vulnerabilities.
53 +
54 + Mitigation selection guide
55 + --------------------------
56 +diff --git a/Documentation/hw-vuln/tsx_async_abort.rst b/Documentation/hw-vuln/tsx_async_abort.rst
57 +index 38beda735f39..0adfe63612ce 100644
58 +--- a/Documentation/hw-vuln/tsx_async_abort.rst
59 ++++ b/Documentation/hw-vuln/tsx_async_abort.rst
60 +@@ -169,7 +169,10 @@ the option "tsx_async_abort=". The valid arguments for this option are:
61 + systems will have no effect.
62 + ============ =============================================================
63 +
64 +-Not specifying this option is equivalent to "tsx_async_abort=full".
65 ++Not specifying this option is equivalent to "tsx_async_abort=full". For
66 ++processors that are affected by both TAA and MDS, specifying just
67 ++"tsx_async_abort=off" without an accompanying "mds=off" will have no
68 ++effect as the same mitigation is used for both vulnerabilities.
69 +
70 + The kernel command line also allows to control the TSX feature using the
71 + parameter "tsx=" on CPUs which support TSX control. MSR_IA32_TSX_CTRL is used
72 +diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
73 +index 70f05fc3873c..da9acfb23383 100644
74 +--- a/Documentation/kernel-parameters.txt
75 ++++ b/Documentation/kernel-parameters.txt
76 +@@ -2054,6 +2054,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
77 + full - Enable MDS mitigation on vulnerable CPUs
78 + off - Unconditionally disable MDS mitigation
79 +
80 ++ On TAA-affected machines, mds=off can be prevented by
81 ++ an active TAA mitigation as both vulnerabilities are
82 ++ mitigated with the same mechanism so in order to disable
83 ++ this mitigation, you need to specify tsx_async_abort=off
84 ++ too.
85 ++
86 + Not specifying this option is equivalent to
87 + mds=full.
88 +
89 +@@ -4105,6 +4111,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
90 +
91 + off - Unconditionally disable TAA mitigation
92 +
93 ++ On MDS-affected machines, tsx_async_abort=off can be
94 ++ prevented by an active MDS mitigation as both vulnerabilities
95 ++ are mitigated with the same mechanism so in order to disable
96 ++ this mitigation, you need to specify mds=off too.
97 ++
98 + Not specifying this option is equivalent to
99 + tsx_async_abort=full. On CPUs which are MDS affected
100 + and deploy MDS mitigation, TAA mitigation is not
101 +diff --git a/Makefile b/Makefile
102 +index 3163f289cb52..c2a57420c570 100644
103 +--- a/Makefile
104 ++++ b/Makefile
105 +@@ -1,6 +1,6 @@
106 + VERSION = 4
107 + PATCHLEVEL = 4
108 +-SUBLEVEL = 203
109 ++SUBLEVEL = 204
110 + EXTRAVERSION =
111 + NAME = Blurry Fish Butt
112 +
113 +diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c
114 +index 8b134cfe5e1f..71fcbccc8f98 100644
115 +--- a/arch/arc/kernel/perf_event.c
116 ++++ b/arch/arc/kernel/perf_event.c
117 +@@ -486,8 +486,8 @@ static int arc_pmu_device_probe(struct platform_device *pdev)
118 + /* loop thru all available h/w condition indexes */
119 + for (j = 0; j < cc_bcr.c; j++) {
120 + write_aux_reg(ARC_REG_CC_INDEX, j);
121 +- cc_name.indiv.word0 = read_aux_reg(ARC_REG_CC_NAME0);
122 +- cc_name.indiv.word1 = read_aux_reg(ARC_REG_CC_NAME1);
123 ++ cc_name.indiv.word0 = le32_to_cpu(read_aux_reg(ARC_REG_CC_NAME0));
124 ++ cc_name.indiv.word1 = le32_to_cpu(read_aux_reg(ARC_REG_CC_NAME1));
125 +
126 + /* See if it has been mapped to a perf event_id */
127 + for (i = 0; i < ARRAY_SIZE(arc_pmu_ev_hw_map); i++) {
128 +diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
129 +index 6b4579e07aa2..02710f99c137 100644
130 +--- a/arch/arm64/kernel/traps.c
131 ++++ b/arch/arm64/kernel/traps.c
132 +@@ -448,7 +448,6 @@ asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr)
133 + pr_crit("Bad mode in %s handler detected, code 0x%08x -- %s\n",
134 + handler[reason], esr, esr_get_class_string(esr));
135 +
136 +- die("Oops - bad mode", regs, 0);
137 + local_irq_disable();
138 + panic("bad mode");
139 + }
140 +diff --git a/arch/powerpc/include/asm/asm-prototypes.h b/arch/powerpc/include/asm/asm-prototypes.h
141 +index 8944c55591cf..77c6bfe60137 100644
142 +--- a/arch/powerpc/include/asm/asm-prototypes.h
143 ++++ b/arch/powerpc/include/asm/asm-prototypes.h
144 +@@ -15,7 +15,10 @@
145 + /* Patch sites */
146 + extern s32 patch__call_flush_count_cache;
147 + extern s32 patch__flush_count_cache_return;
148 ++extern s32 patch__flush_link_stack_return;
149 ++extern s32 patch__call_kvm_flush_link_stack;
150 +
151 + extern long flush_count_cache;
152 ++extern long kvm_flush_link_stack;
153 +
154 + #endif /* _ASM_POWERPC_ASM_PROTOTYPES_H */
155 +diff --git a/arch/powerpc/include/asm/security_features.h b/arch/powerpc/include/asm/security_features.h
156 +index 759597bf0fd8..ccf44c135389 100644
157 +--- a/arch/powerpc/include/asm/security_features.h
158 ++++ b/arch/powerpc/include/asm/security_features.h
159 +@@ -81,6 +81,9 @@ static inline bool security_ftr_enabled(unsigned long feature)
160 + // Software required to flush count cache on context switch
161 + #define SEC_FTR_FLUSH_COUNT_CACHE 0x0000000000000400ull
162 +
163 ++// Software required to flush link stack on context switch
164 ++#define SEC_FTR_FLUSH_LINK_STACK 0x0000000000001000ull
165 ++
166 +
167 + // Features enabled by default
168 + #define SEC_FTR_DEFAULT \
169 +diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
170 +index 304f07cfa262..4d4c32d0e6ce 100644
171 +--- a/arch/powerpc/kernel/eeh_pe.c
172 ++++ b/arch/powerpc/kernel/eeh_pe.c
173 +@@ -367,7 +367,7 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
174 + while (parent) {
175 + if (!(parent->type & EEH_PE_INVALID))
176 + break;
177 +- parent->type &= ~(EEH_PE_INVALID | EEH_PE_KEEP);
178 ++ parent->type &= ~EEH_PE_INVALID;
179 + parent = parent->parent;
180 + }
181 +
182 +diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
183 +index 6d36a4fb4acf..e523d16c8b6e 100644
184 +--- a/arch/powerpc/kernel/entry_64.S
185 ++++ b/arch/powerpc/kernel/entry_64.S
186 +@@ -477,6 +477,7 @@ flush_count_cache:
187 + /* Save LR into r9 */
188 + mflr r9
189 +
190 ++ // Flush the link stack
191 + .rept 64
192 + bl .+4
193 + .endr
194 +@@ -486,6 +487,11 @@ flush_count_cache:
195 + .balign 32
196 + /* Restore LR */
197 + 1: mtlr r9
198 ++
199 ++ // If we're just flushing the link stack, return here
200 ++3: nop
201 ++ patch_site 3b patch__flush_link_stack_return
202 ++
203 + li r9,0x7fff
204 + mtctr r9
205 +
206 +diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
207 +index fe30ddfd51ee..156cfe6d23b0 100644
208 +--- a/arch/powerpc/kernel/security.c
209 ++++ b/arch/powerpc/kernel/security.c
210 +@@ -25,11 +25,12 @@ enum count_cache_flush_type {
211 + COUNT_CACHE_FLUSH_HW = 0x4,
212 + };
213 + static enum count_cache_flush_type count_cache_flush_type = COUNT_CACHE_FLUSH_NONE;
214 ++static bool link_stack_flush_enabled;
215 +
216 + bool barrier_nospec_enabled;
217 + static bool no_nospec;
218 + static bool btb_flush_enabled;
219 +-#ifdef CONFIG_PPC_FSL_BOOK3E
220 ++#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64)
221 + static bool no_spectrev2;
222 + #endif
223 +
224 +@@ -107,7 +108,7 @@ static __init int barrier_nospec_debugfs_init(void)
225 + device_initcall(barrier_nospec_debugfs_init);
226 + #endif /* CONFIG_DEBUG_FS */
227 +
228 +-#ifdef CONFIG_PPC_FSL_BOOK3E
229 ++#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64)
230 + static int __init handle_nospectre_v2(char *p)
231 + {
232 + no_spectrev2 = true;
233 +@@ -115,6 +116,9 @@ static int __init handle_nospectre_v2(char *p)
234 + return 0;
235 + }
236 + early_param("nospectre_v2", handle_nospectre_v2);
237 ++#endif /* CONFIG_PPC_FSL_BOOK3E || CONFIG_PPC_BOOK3S_64 */
238 ++
239 ++#ifdef CONFIG_PPC_FSL_BOOK3E
240 + void setup_spectre_v2(void)
241 + {
242 + if (no_spectrev2)
243 +@@ -202,11 +206,19 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c
244 +
245 + if (ccd)
246 + seq_buf_printf(&s, "Indirect branch cache disabled");
247 ++
248 ++ if (link_stack_flush_enabled)
249 ++ seq_buf_printf(&s, ", Software link stack flush");
250 ++
251 + } else if (count_cache_flush_type != COUNT_CACHE_FLUSH_NONE) {
252 + seq_buf_printf(&s, "Mitigation: Software count cache flush");
253 +
254 + if (count_cache_flush_type == COUNT_CACHE_FLUSH_HW)
255 + seq_buf_printf(&s, " (hardware accelerated)");
256 ++
257 ++ if (link_stack_flush_enabled)
258 ++ seq_buf_printf(&s, ", Software link stack flush");
259 ++
260 + } else if (btb_flush_enabled) {
261 + seq_buf_printf(&s, "Mitigation: Branch predictor state flush");
262 + } else {
263 +@@ -365,18 +377,49 @@ static __init int stf_barrier_debugfs_init(void)
264 + device_initcall(stf_barrier_debugfs_init);
265 + #endif /* CONFIG_DEBUG_FS */
266 +
267 ++static void no_count_cache_flush(void)
268 ++{
269 ++ count_cache_flush_type = COUNT_CACHE_FLUSH_NONE;
270 ++ pr_info("count-cache-flush: software flush disabled.\n");
271 ++}
272 ++
273 + static void toggle_count_cache_flush(bool enable)
274 + {
275 +- if (!enable || !security_ftr_enabled(SEC_FTR_FLUSH_COUNT_CACHE)) {
276 ++ if (!security_ftr_enabled(SEC_FTR_FLUSH_COUNT_CACHE) &&
277 ++ !security_ftr_enabled(SEC_FTR_FLUSH_LINK_STACK))
278 ++ enable = false;
279 ++
280 ++ if (!enable) {
281 + patch_instruction_site(&patch__call_flush_count_cache, PPC_INST_NOP);
282 +- count_cache_flush_type = COUNT_CACHE_FLUSH_NONE;
283 +- pr_info("count-cache-flush: software flush disabled.\n");
284 ++#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
285 ++ patch_instruction_site(&patch__call_kvm_flush_link_stack, PPC_INST_NOP);
286 ++#endif
287 ++ pr_info("link-stack-flush: software flush disabled.\n");
288 ++ link_stack_flush_enabled = false;
289 ++ no_count_cache_flush();
290 + return;
291 + }
292 +
293 ++ // This enables the branch from _switch to flush_count_cache
294 + patch_branch_site(&patch__call_flush_count_cache,
295 + (u64)&flush_count_cache, BRANCH_SET_LINK);
296 +
297 ++#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
298 ++ // This enables the branch from guest_exit_cont to kvm_flush_link_stack
299 ++ patch_branch_site(&patch__call_kvm_flush_link_stack,
300 ++ (u64)&kvm_flush_link_stack, BRANCH_SET_LINK);
301 ++#endif
302 ++
303 ++ pr_info("link-stack-flush: software flush enabled.\n");
304 ++ link_stack_flush_enabled = true;
305 ++
306 ++ // If we just need to flush the link stack, patch an early return
307 ++ if (!security_ftr_enabled(SEC_FTR_FLUSH_COUNT_CACHE)) {
308 ++ patch_instruction_site(&patch__flush_link_stack_return, PPC_INST_BLR);
309 ++ no_count_cache_flush();
310 ++ return;
311 ++ }
312 ++
313 + if (!security_ftr_enabled(SEC_FTR_BCCTR_FLUSH_ASSIST)) {
314 + count_cache_flush_type = COUNT_CACHE_FLUSH_SW;
315 + pr_info("count-cache-flush: full software flush sequence enabled.\n");
316 +@@ -390,7 +433,26 @@ static void toggle_count_cache_flush(bool enable)
317 +
318 + void setup_count_cache_flush(void)
319 + {
320 +- toggle_count_cache_flush(true);
321 ++ bool enable = true;
322 ++
323 ++ if (no_spectrev2 || cpu_mitigations_off()) {
324 ++ if (security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED) ||
325 ++ security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED))
326 ++ pr_warn("Spectre v2 mitigations not fully under software control, can't disable\n");
327 ++
328 ++ enable = false;
329 ++ }
330 ++
331 ++ /*
332 ++ * There's no firmware feature flag/hypervisor bit to tell us we need to
333 ++ * flush the link stack on context switch. So we set it here if we see
334 ++ * either of the Spectre v2 mitigations that aim to protect userspace.
335 ++ */
336 ++ if (security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED) ||
337 ++ security_ftr_enabled(SEC_FTR_FLUSH_COUNT_CACHE))
338 ++ security_ftr_set(SEC_FTR_FLUSH_LINK_STACK);
339 ++
340 ++ toggle_count_cache_flush(enable);
341 + }
342 +
343 + #ifdef CONFIG_DEBUG_FS
344 +diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
345 +index 4463718ae614..c8b9194567d6 100644
346 +--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
347 ++++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
348 +@@ -18,6 +18,7 @@
349 + */
350 +
351 + #include <asm/ppc_asm.h>
352 ++#include <asm/code-patching-asm.h>
353 + #include <asm/kvm_asm.h>
354 + #include <asm/reg.h>
355 + #include <asm/mmu.h>
356 +@@ -1169,6 +1170,10 @@ mc_cont:
357 + bl kvmhv_accumulate_time
358 + #endif
359 +
360 ++ /* Possibly flush the link stack here. */
361 ++1: nop
362 ++ patch_site 1b patch__call_kvm_flush_link_stack
363 ++
364 + mr r3, r12
365 + /* Increment exit count, poke other threads to exit */
366 + bl kvmhv_commence_exit
367 +@@ -1564,6 +1569,21 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
368 + mtlr r0
369 + blr
370 +
371 ++.balign 32
372 ++.global kvm_flush_link_stack
373 ++kvm_flush_link_stack:
374 ++ /* Save LR into r0 */
375 ++ mflr r0
376 ++
377 ++ /* Flush the link stack. On Power8 it's up to 32 entries in size. */
378 ++ .rept 32
379 ++ bl .+4
380 ++ .endr
381 ++
382 ++ /* Restore LR */
383 ++ mtlr r0
384 ++ blr
385 ++
386 + /*
387 + * Check whether an HDSI is an HPTE not found fault or something else.
388 + * If it is an HPTE not found fault that is due to the guest accessing
389 +diff --git a/arch/powerpc/platforms/ps3/os-area.c b/arch/powerpc/platforms/ps3/os-area.c
390 +index 3db53e8aff92..9b2ef76578f0 100644
391 +--- a/arch/powerpc/platforms/ps3/os-area.c
392 ++++ b/arch/powerpc/platforms/ps3/os-area.c
393 +@@ -664,7 +664,7 @@ static int update_flash_db(void)
394 + db_set_64(db, &os_area_db_id_rtc_diff, saved_params.rtc_diff);
395 +
396 + count = os_area_flash_write(db, sizeof(struct os_area_db), pos);
397 +- if (count < sizeof(struct os_area_db)) {
398 ++ if (count < 0 || count < sizeof(struct os_area_db)) {
399 + pr_debug("%s: os_area_flash_write failed %zd\n", __func__,
400 + count);
401 + error = count < 0 ? count : -EIO;
402 +diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
403 +index b79d51459cf2..874762a51c54 100644
404 +--- a/arch/s390/kernel/perf_cpum_sf.c
405 ++++ b/arch/s390/kernel/perf_cpum_sf.c
406 +@@ -1616,14 +1616,17 @@ static int __init init_cpum_sampling_pmu(void)
407 + }
408 +
409 + sfdbg = debug_register(KMSG_COMPONENT, 2, 1, 80);
410 +- if (!sfdbg)
411 ++ if (!sfdbg) {
412 + pr_err("Registering for s390dbf failed\n");
413 ++ return -ENOMEM;
414 ++ }
415 + debug_register_view(sfdbg, &debug_sprintf_view);
416 +
417 + err = register_external_irq(EXT_IRQ_MEASURE_ALERT,
418 + cpumf_measurement_alert);
419 + if (err) {
420 + pr_cpumsf_err(RS_INIT_FAILURE_ALRT);
421 ++ debug_unregister(sfdbg);
422 + goto out;
423 + }
424 +
425 +@@ -1632,6 +1635,7 @@ static int __init init_cpum_sampling_pmu(void)
426 + pr_cpumsf_err(RS_INIT_FAILURE_PERF);
427 + unregister_external_irq(EXT_IRQ_MEASURE_ALERT,
428 + cpumf_measurement_alert);
429 ++ debug_unregister(sfdbg);
430 + goto out;
431 + }
432 + perf_cpu_notifier(cpumf_pmu_notifier);
433 +diff --git a/arch/sparc/include/asm/cmpxchg_64.h b/arch/sparc/include/asm/cmpxchg_64.h
434 +index faa2f61058c2..92f0a46ace78 100644
435 +--- a/arch/sparc/include/asm/cmpxchg_64.h
436 ++++ b/arch/sparc/include/asm/cmpxchg_64.h
437 +@@ -40,7 +40,12 @@ static inline unsigned long xchg64(__volatile__ unsigned long *m, unsigned long
438 + return val;
439 + }
440 +
441 +-#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
442 ++#define xchg(ptr,x) \
443 ++({ __typeof__(*(ptr)) __ret; \
444 ++ __ret = (__typeof__(*(ptr))) \
445 ++ __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))); \
446 ++ __ret; \
447 ++})
448 +
449 + void __xchg_called_with_bad_pointer(void);
450 +
451 +diff --git a/arch/sparc/include/asm/parport.h b/arch/sparc/include/asm/parport.h
452 +index f005ccac91cc..e87c0f81b700 100644
453 +--- a/arch/sparc/include/asm/parport.h
454 ++++ b/arch/sparc/include/asm/parport.h
455 +@@ -20,6 +20,7 @@
456 + */
457 + #define HAS_DMA
458 +
459 ++#ifdef CONFIG_PARPORT_PC_FIFO
460 + static DEFINE_SPINLOCK(dma_spin_lock);
461 +
462 + #define claim_dma_lock() \
463 +@@ -30,6 +31,7 @@ static DEFINE_SPINLOCK(dma_spin_lock);
464 +
465 + #define release_dma_lock(__flags) \
466 + spin_unlock_irqrestore(&dma_spin_lock, __flags);
467 ++#endif
468 +
469 + static struct sparc_ebus_info {
470 + struct ebus_dma_info info;
471 +diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
472 +index 62087028a9ce..d2ad45c10113 100644
473 +--- a/arch/um/drivers/line.c
474 ++++ b/arch/um/drivers/line.c
475 +@@ -260,7 +260,7 @@ static irqreturn_t line_write_interrupt(int irq, void *data)
476 + if (err == 0) {
477 + spin_unlock(&line->lock);
478 + return IRQ_NONE;
479 +- } else if (err < 0) {
480 ++ } else if ((err < 0) && (err != -EAGAIN)) {
481 + line->head = line->buffer;
482 + line->tail = line->buffer;
483 + }
484 +diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
485 +index 0d8e0831b1a0..3daec418c822 100644
486 +--- a/arch/x86/include/asm/ptrace.h
487 ++++ b/arch/x86/include/asm/ptrace.h
488 +@@ -205,24 +205,52 @@ static inline int regs_within_kernel_stack(struct pt_regs *regs,
489 + (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
490 + }
491 +
492 ++/**
493 ++ * regs_get_kernel_stack_nth_addr() - get the address of the Nth entry on stack
494 ++ * @regs: pt_regs which contains kernel stack pointer.
495 ++ * @n: stack entry number.
496 ++ *
497 ++ * regs_get_kernel_stack_nth() returns the address of the @n th entry of the
498 ++ * kernel stack which is specified by @regs. If the @n th entry is NOT in
499 ++ * the kernel stack, this returns NULL.
500 ++ */
501 ++static inline unsigned long *regs_get_kernel_stack_nth_addr(struct pt_regs *regs, unsigned int n)
502 ++{
503 ++ unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs);
504 ++
505 ++ addr += n;
506 ++ if (regs_within_kernel_stack(regs, (unsigned long)addr))
507 ++ return addr;
508 ++ else
509 ++ return NULL;
510 ++}
511 ++
512 ++/* To avoid include hell, we can't include uaccess.h */
513 ++extern long probe_kernel_read(void *dst, const void *src, size_t size);
514 ++
515 + /**
516 + * regs_get_kernel_stack_nth() - get Nth entry of the stack
517 + * @regs: pt_regs which contains kernel stack pointer.
518 + * @n: stack entry number.
519 + *
520 + * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
521 +- * is specified by @regs. If the @n th entry is NOT in the kernel stack,
522 ++ * is specified by @regs. If the @n th entry is NOT in the kernel stack
523 + * this returns 0.
524 + */
525 + static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
526 + unsigned int n)
527 + {
528 +- unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs);
529 +- addr += n;
530 +- if (regs_within_kernel_stack(regs, (unsigned long)addr))
531 +- return *addr;
532 +- else
533 +- return 0;
534 ++ unsigned long *addr;
535 ++ unsigned long val;
536 ++ long ret;
537 ++
538 ++ addr = regs_get_kernel_stack_nth_addr(regs, n);
539 ++ if (addr) {
540 ++ ret = probe_kernel_read(&val, addr, sizeof(val));
541 ++ if (!ret)
542 ++ return val;
543 ++ }
544 ++ return 0;
545 + }
546 +
547 + #define arch_has_single_step() (1)
548 +diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
549 +index 7fd0a13ae0ba..e9aa50ba4f97 100644
550 +--- a/arch/x86/kernel/cpu/bugs.c
551 ++++ b/arch/x86/kernel/cpu/bugs.c
552 +@@ -37,6 +37,7 @@ static void __init spectre_v2_select_mitigation(void);
553 + static void __init ssb_select_mitigation(void);
554 + static void __init l1tf_select_mitigation(void);
555 + static void __init mds_select_mitigation(void);
556 ++static void __init mds_print_mitigation(void);
557 + static void __init taa_select_mitigation(void);
558 +
559 + /* The base value of the SPEC_CTRL MSR that always has to be preserved. */
560 +@@ -99,6 +100,12 @@ void __init check_bugs(void)
561 + mds_select_mitigation();
562 + taa_select_mitigation();
563 +
564 ++ /*
565 ++ * As MDS and TAA mitigations are inter-related, print MDS
566 ++ * mitigation until after TAA mitigation selection is done.
567 ++ */
568 ++ mds_print_mitigation();
569 ++
570 + arch_smt_update();
571 +
572 + #ifdef CONFIG_X86_32
573 +@@ -224,6 +231,12 @@ static void __init mds_select_mitigation(void)
574 + mds_mitigation = MDS_MITIGATION_OFF;
575 + return;
576 + }
577 ++}
578 ++
579 ++static void __init mds_print_mitigation(void)
580 ++{
581 ++ if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off())
582 ++ return;
583 +
584 + if (mds_mitigation == MDS_MITIGATION_FULL) {
585 + if (!boot_cpu_has(X86_FEATURE_MD_CLEAR))
586 +@@ -283,8 +296,12 @@ static void __init taa_select_mitigation(void)
587 + return;
588 + }
589 +
590 +- /* TAA mitigation is turned off on the cmdline (tsx_async_abort=off) */
591 +- if (taa_mitigation == TAA_MITIGATION_OFF)
592 ++ /*
593 ++ * TAA mitigation via VERW is turned off if both
594 ++ * tsx_async_abort=off and mds=off are specified.
595 ++ */
596 ++ if (taa_mitigation == TAA_MITIGATION_OFF &&
597 ++ mds_mitigation == MDS_MITIGATION_OFF)
598 + goto out;
599 +
600 + if (boot_cpu_has(X86_FEATURE_MD_CLEAR))
601 +@@ -315,6 +332,15 @@ static void __init taa_select_mitigation(void)
602 + */
603 + static_branch_enable(&mds_user_clear);
604 +
605 ++ /*
606 ++ * Update MDS mitigation, if necessary, as the mds_user_clear is
607 ++ * now enabled for TAA mitigation.
608 ++ */
609 ++ if (mds_mitigation == MDS_MITIGATION_OFF &&
610 ++ boot_cpu_has_bug(X86_BUG_MDS)) {
611 ++ mds_mitigation = MDS_MITIGATION_FULL;
612 ++ mds_select_mitigation();
613 ++ }
614 + out:
615 + pr_info("%s\n", taa_strings[taa_mitigation]);
616 + }
617 +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
618 +index 1b3a432f6fd5..9344ac6b4f99 100644
619 +--- a/arch/x86/kvm/vmx.c
620 ++++ b/arch/x86/kvm/vmx.c
621 +@@ -1298,7 +1298,7 @@ static int __find_msr_index(struct vcpu_vmx *vmx, u32 msr)
622 + return -1;
623 + }
624 +
625 +-static inline void __invvpid(int ext, u16 vpid, gva_t gva)
626 ++static inline void __invvpid(unsigned long ext, u16 vpid, gva_t gva)
627 + {
628 + struct {
629 + u64 vpid : 16;
630 +@@ -1312,7 +1312,7 @@ static inline void __invvpid(int ext, u16 vpid, gva_t gva)
631 + : : "a"(&operand), "c"(ext) : "cc", "memory");
632 + }
633 +
634 +-static inline void __invept(int ext, u64 eptp, gpa_t gpa)
635 ++static inline void __invept(unsigned long ext, u64 eptp, gpa_t gpa)
636 + {
637 + struct {
638 + u64 eptp, gpa;
639 +diff --git a/arch/x86/tools/gen-insn-attr-x86.awk b/arch/x86/tools/gen-insn-attr-x86.awk
640 +index 093a892026f9..e832db558194 100644
641 +--- a/arch/x86/tools/gen-insn-attr-x86.awk
642 ++++ b/arch/x86/tools/gen-insn-attr-x86.awk
643 +@@ -68,7 +68,7 @@ BEGIN {
644 +
645 + lprefix1_expr = "\\((66|!F3)\\)"
646 + lprefix2_expr = "\\(F3\\)"
647 +- lprefix3_expr = "\\((F2|!F3|66\\&F2)\\)"
648 ++ lprefix3_expr = "\\((F2|!F3|66&F2)\\)"
649 + lprefix_expr = "\\((66|F2|F3)\\)"
650 + max_lprefix = 4
651 +
652 +@@ -253,7 +253,7 @@ function convert_operands(count,opnd, i,j,imm,mod)
653 + return add_flags(imm, mod)
654 + }
655 +
656 +-/^[0-9a-f]+\:/ {
657 ++/^[0-9a-f]+:/ {
658 + if (NR == 1)
659 + next
660 + # get index
661 +diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
662 +index 94712e1c5cf9..bcdde3e36052 100644
663 +--- a/drivers/atm/zatm.c
664 ++++ b/drivers/atm/zatm.c
665 +@@ -126,7 +126,7 @@ static unsigned long dummy[2] = {0,0};
666 + #define zin_n(r) inl(zatm_dev->base+r*4)
667 + #define zin(r) inl(zatm_dev->base+uPD98401_##r*4)
668 + #define zout(v,r) outl(v,zatm_dev->base+uPD98401_##r*4)
669 +-#define zwait while (zin(CMR) & uPD98401_BUSY)
670 ++#define zwait() do {} while (zin(CMR) & uPD98401_BUSY)
671 +
672 + /* RX0, RX1, TX0, TX1 */
673 + static const int mbx_entries[NR_MBX] = { 1024,1024,1024,1024 };
674 +@@ -140,7 +140,7 @@ static const int mbx_esize[NR_MBX] = { 16,16,4,4 }; /* entry size in bytes */
675 +
676 + static void zpokel(struct zatm_dev *zatm_dev,u32 value,u32 addr)
677 + {
678 +- zwait;
679 ++ zwait();
680 + zout(value,CER);
681 + zout(uPD98401_IND_ACC | uPD98401_IA_BALL |
682 + (uPD98401_IA_TGT_CM << uPD98401_IA_TGT_SHIFT) | addr,CMR);
683 +@@ -149,10 +149,10 @@ static void zpokel(struct zatm_dev *zatm_dev,u32 value,u32 addr)
684 +
685 + static u32 zpeekl(struct zatm_dev *zatm_dev,u32 addr)
686 + {
687 +- zwait;
688 ++ zwait();
689 + zout(uPD98401_IND_ACC | uPD98401_IA_BALL | uPD98401_IA_RW |
690 + (uPD98401_IA_TGT_CM << uPD98401_IA_TGT_SHIFT) | addr,CMR);
691 +- zwait;
692 ++ zwait();
693 + return zin(CER);
694 + }
695 +
696 +@@ -241,7 +241,7 @@ static void refill_pool(struct atm_dev *dev,int pool)
697 + }
698 + if (first) {
699 + spin_lock_irqsave(&zatm_dev->lock, flags);
700 +- zwait;
701 ++ zwait();
702 + zout(virt_to_bus(first),CER);
703 + zout(uPD98401_ADD_BAT | (pool << uPD98401_POOL_SHIFT) | count,
704 + CMR);
705 +@@ -508,9 +508,9 @@ static int open_rx_first(struct atm_vcc *vcc)
706 + }
707 + if (zatm_vcc->pool < 0) return -EMSGSIZE;
708 + spin_lock_irqsave(&zatm_dev->lock, flags);
709 +- zwait;
710 ++ zwait();
711 + zout(uPD98401_OPEN_CHAN,CMR);
712 +- zwait;
713 ++ zwait();
714 + DPRINTK("0x%x 0x%x\n",zin(CMR),zin(CER));
715 + chan = (zin(CMR) & uPD98401_CHAN_ADDR) >> uPD98401_CHAN_ADDR_SHIFT;
716 + spin_unlock_irqrestore(&zatm_dev->lock, flags);
717 +@@ -571,21 +571,21 @@ static void close_rx(struct atm_vcc *vcc)
718 + pos = vcc->vci >> 1;
719 + shift = (1-(vcc->vci & 1)) << 4;
720 + zpokel(zatm_dev,zpeekl(zatm_dev,pos) & ~(0xffff << shift),pos);
721 +- zwait;
722 ++ zwait();
723 + zout(uPD98401_NOP,CMR);
724 +- zwait;
725 ++ zwait();
726 + zout(uPD98401_NOP,CMR);
727 + spin_unlock_irqrestore(&zatm_dev->lock, flags);
728 + }
729 + spin_lock_irqsave(&zatm_dev->lock, flags);
730 +- zwait;
731 ++ zwait();
732 + zout(uPD98401_DEACT_CHAN | uPD98401_CHAN_RT | (zatm_vcc->rx_chan <<
733 + uPD98401_CHAN_ADDR_SHIFT),CMR);
734 +- zwait;
735 ++ zwait();
736 + udelay(10); /* why oh why ... ? */
737 + zout(uPD98401_CLOSE_CHAN | uPD98401_CHAN_RT | (zatm_vcc->rx_chan <<
738 + uPD98401_CHAN_ADDR_SHIFT),CMR);
739 +- zwait;
740 ++ zwait();
741 + if (!(zin(CMR) & uPD98401_CHAN_ADDR))
742 + printk(KERN_CRIT DEV_LABEL "(itf %d): can't close RX channel "
743 + "%d\n",vcc->dev->number,zatm_vcc->rx_chan);
744 +@@ -698,7 +698,7 @@ printk("NONONONOO!!!!\n");
745 + skb_queue_tail(&zatm_vcc->tx_queue,skb);
746 + DPRINTK("QRP=0x%08lx\n",zpeekl(zatm_dev,zatm_vcc->tx_chan*VC_SIZE/4+
747 + uPD98401_TXVC_QRP));
748 +- zwait;
749 ++ zwait();
750 + zout(uPD98401_TX_READY | (zatm_vcc->tx_chan <<
751 + uPD98401_CHAN_ADDR_SHIFT),CMR);
752 + spin_unlock_irqrestore(&zatm_dev->lock, flags);
753 +@@ -890,12 +890,12 @@ static void close_tx(struct atm_vcc *vcc)
754 + }
755 + spin_lock_irqsave(&zatm_dev->lock, flags);
756 + #if 0
757 +- zwait;
758 ++ zwait();
759 + zout(uPD98401_DEACT_CHAN | (chan << uPD98401_CHAN_ADDR_SHIFT),CMR);
760 + #endif
761 +- zwait;
762 ++ zwait();
763 + zout(uPD98401_CLOSE_CHAN | (chan << uPD98401_CHAN_ADDR_SHIFT),CMR);
764 +- zwait;
765 ++ zwait();
766 + if (!(zin(CMR) & uPD98401_CHAN_ADDR))
767 + printk(KERN_CRIT DEV_LABEL "(itf %d): can't close TX channel "
768 + "%d\n",vcc->dev->number,chan);
769 +@@ -925,9 +925,9 @@ static int open_tx_first(struct atm_vcc *vcc)
770 + zatm_vcc->tx_chan = 0;
771 + if (vcc->qos.txtp.traffic_class == ATM_NONE) return 0;
772 + spin_lock_irqsave(&zatm_dev->lock, flags);
773 +- zwait;
774 ++ zwait();
775 + zout(uPD98401_OPEN_CHAN,CMR);
776 +- zwait;
777 ++ zwait();
778 + DPRINTK("0x%x 0x%x\n",zin(CMR),zin(CER));
779 + chan = (zin(CMR) & uPD98401_CHAN_ADDR) >> uPD98401_CHAN_ADDR_SHIFT;
780 + spin_unlock_irqrestore(&zatm_dev->lock, flags);
781 +@@ -1557,7 +1557,7 @@ static void zatm_phy_put(struct atm_dev *dev,unsigned char value,
782 + struct zatm_dev *zatm_dev;
783 +
784 + zatm_dev = ZATM_DEV(dev);
785 +- zwait;
786 ++ zwait();
787 + zout(value,CER);
788 + zout(uPD98401_IND_ACC | uPD98401_IA_B0 |
789 + (uPD98401_IA_TGT_PHY << uPD98401_IA_TGT_SHIFT) | addr,CMR);
790 +@@ -1569,10 +1569,10 @@ static unsigned char zatm_phy_get(struct atm_dev *dev,unsigned long addr)
791 + struct zatm_dev *zatm_dev;
792 +
793 + zatm_dev = ZATM_DEV(dev);
794 +- zwait;
795 ++ zwait();
796 + zout(uPD98401_IND_ACC | uPD98401_IA_B0 | uPD98401_IA_RW |
797 + (uPD98401_IA_TGT_PHY << uPD98401_IA_TGT_SHIFT) | addr,CMR);
798 +- zwait;
799 ++ zwait();
800 + return zin(CER) & 0xff;
801 + }
802 +
803 +diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
804 +index 5fd50a284168..db4354fb2a0d 100644
805 +--- a/drivers/block/amiflop.c
806 ++++ b/drivers/block/amiflop.c
807 +@@ -1699,11 +1699,41 @@ static const struct block_device_operations floppy_fops = {
808 + .check_events = amiga_check_events,
809 + };
810 +
811 ++static struct gendisk *fd_alloc_disk(int drive)
812 ++{
813 ++ struct gendisk *disk;
814 ++
815 ++ disk = alloc_disk(1);
816 ++ if (!disk)
817 ++ goto out;
818 ++
819 ++ disk->queue = blk_init_queue(do_fd_request, &amiflop_lock);
820 ++ if (IS_ERR(disk->queue)) {
821 ++ disk->queue = NULL;
822 ++ goto out_put_disk;
823 ++ }
824 ++
825 ++ unit[drive].trackbuf = kmalloc(FLOPPY_MAX_SECTORS * 512, GFP_KERNEL);
826 ++ if (!unit[drive].trackbuf)
827 ++ goto out_cleanup_queue;
828 ++
829 ++ return disk;
830 ++
831 ++out_cleanup_queue:
832 ++ blk_cleanup_queue(disk->queue);
833 ++ disk->queue = NULL;
834 ++out_put_disk:
835 ++ put_disk(disk);
836 ++out:
837 ++ unit[drive].type->code = FD_NODRIVE;
838 ++ return NULL;
839 ++}
840 ++
841 + static int __init fd_probe_drives(void)
842 + {
843 + int drive,drives,nomem;
844 +
845 +- printk(KERN_INFO "FD: probing units\nfound ");
846 ++ pr_info("FD: probing units\nfound");
847 + drives=0;
848 + nomem=0;
849 + for(drive=0;drive<FD_MAX_UNITS;drive++) {
850 +@@ -1711,27 +1741,17 @@ static int __init fd_probe_drives(void)
851 + fd_probe(drive);
852 + if (unit[drive].type->code == FD_NODRIVE)
853 + continue;
854 +- disk = alloc_disk(1);
855 ++
856 ++ disk = fd_alloc_disk(drive);
857 + if (!disk) {
858 +- unit[drive].type->code = FD_NODRIVE;
859 ++ pr_cont(" no mem for fd%d", drive);
860 ++ nomem = 1;
861 + continue;
862 + }
863 + unit[drive].gendisk = disk;
864 +-
865 +- disk->queue = blk_init_queue(do_fd_request, &amiflop_lock);
866 +- if (!disk->queue) {
867 +- unit[drive].type->code = FD_NODRIVE;
868 +- continue;
869 +- }
870 +-
871 + drives++;
872 +- if ((unit[drive].trackbuf = kmalloc(FLOPPY_MAX_SECTORS * 512, GFP_KERNEL)) == NULL) {
873 +- printk("no mem for ");
874 +- unit[drive].type = &drive_types[num_dr_types - 1]; /* FD_NODRIVE */
875 +- drives--;
876 +- nomem = 1;
877 +- }
878 +- printk("fd%d ",drive);
879 ++
880 ++ pr_cont(" fd%d",drive);
881 + disk->major = FLOPPY_MAJOR;
882 + disk->first_minor = drive;
883 + disk->fops = &floppy_fops;
884 +@@ -1742,11 +1762,11 @@ static int __init fd_probe_drives(void)
885 + }
886 + if ((drives > 0) || (nomem == 0)) {
887 + if (drives == 0)
888 +- printk("no drives");
889 +- printk("\n");
890 ++ pr_cont(" no drives");
891 ++ pr_cont("\n");
892 + return drives;
893 + }
894 +- printk("\n");
895 ++ pr_cont("\n");
896 + return -ENOMEM;
897 + }
898 +
899 +@@ -1837,30 +1857,6 @@ out_blkdev:
900 + return ret;
901 + }
902 +
903 +-#if 0 /* not safe to unload */
904 +-static int __exit amiga_floppy_remove(struct platform_device *pdev)
905 +-{
906 +- int i;
907 +-
908 +- for( i = 0; i < FD_MAX_UNITS; i++) {
909 +- if (unit[i].type->code != FD_NODRIVE) {
910 +- struct request_queue *q = unit[i].gendisk->queue;
911 +- del_gendisk(unit[i].gendisk);
912 +- put_disk(unit[i].gendisk);
913 +- kfree(unit[i].trackbuf);
914 +- if (q)
915 +- blk_cleanup_queue(q);
916 +- }
917 +- }
918 +- blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
919 +- free_irq(IRQ_AMIGA_CIAA_TB, NULL);
920 +- free_irq(IRQ_AMIGA_DSKBLK, NULL);
921 +- custom.dmacon = DMAF_DISK; /* disable DMA */
922 +- amiga_chip_free(raw_buf);
923 +- unregister_blkdev(FLOPPY_MAJOR, "fd");
924 +-}
925 +-#endif
926 +-
927 + static struct platform_driver amiga_floppy_driver = {
928 + .driver = {
929 + .name = "amiga-floppy",
930 +diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
931 +index 9833b53a8b50..37e46c6b5315 100644
932 +--- a/drivers/bluetooth/hci_bcsp.c
933 ++++ b/drivers/bluetooth/hci_bcsp.c
934 +@@ -566,6 +566,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
935 + if (*ptr == 0xc0) {
936 + BT_ERR("Short BCSP packet");
937 + kfree_skb(bcsp->rx_skb);
938 ++ bcsp->rx_skb = NULL;
939 + bcsp->rx_state = BCSP_W4_PKT_START;
940 + bcsp->rx_count = 0;
941 + } else
942 +@@ -581,6 +582,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
943 + bcsp->rx_skb->data[2])) != bcsp->rx_skb->data[3]) {
944 + BT_ERR("Error in BCSP hdr checksum");
945 + kfree_skb(bcsp->rx_skb);
946 ++ bcsp->rx_skb = NULL;
947 + bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
948 + bcsp->rx_count = 0;
949 + continue;
950 +@@ -615,6 +617,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
951 + bscp_get_crc(bcsp));
952 +
953 + kfree_skb(bcsp->rx_skb);
954 ++ bcsp->rx_skb = NULL;
955 + bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
956 + bcsp->rx_count = 0;
957 + continue;
958 +diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
959 +index df9eab91c2d2..5e0e29ee31d1 100644
960 +--- a/drivers/char/virtio_console.c
961 ++++ b/drivers/char/virtio_console.c
962 +@@ -417,7 +417,7 @@ static void reclaim_dma_bufs(void)
963 + }
964 + }
965 +
966 +-static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size,
967 ++static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size,
968 + int pages)
969 + {
970 + struct port_buffer *buf;
971 +@@ -440,7 +440,7 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size,
972 + return buf;
973 + }
974 +
975 +- if (is_rproc_serial(vq->vdev)) {
976 ++ if (is_rproc_serial(vdev)) {
977 + /*
978 + * Allocate DMA memory from ancestor. When a virtio
979 + * device is created by remoteproc, the DMA memory is
980 +@@ -450,9 +450,9 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size,
981 + * DMA_MEMORY_INCLUDES_CHILDREN had been supported
982 + * in dma-coherent.c
983 + */
984 +- if (!vq->vdev->dev.parent || !vq->vdev->dev.parent->parent)
985 ++ if (!vdev->dev.parent || !vdev->dev.parent->parent)
986 + goto free_buf;
987 +- buf->dev = vq->vdev->dev.parent->parent;
988 ++ buf->dev = vdev->dev.parent->parent;
989 +
990 + /* Increase device refcnt to avoid freeing it */
991 + get_device(buf->dev);
992 +@@ -835,7 +835,7 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,
993 +
994 + count = min((size_t)(32 * 1024), count);
995 +
996 +- buf = alloc_buf(port->out_vq, count, 0);
997 ++ buf = alloc_buf(port->portdev->vdev, count, 0);
998 + if (!buf)
999 + return -ENOMEM;
1000 +
1001 +@@ -954,7 +954,7 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
1002 + if (ret < 0)
1003 + goto error_out;
1004 +
1005 +- buf = alloc_buf(port->out_vq, 0, pipe->nrbufs);
1006 ++ buf = alloc_buf(port->portdev->vdev, 0, pipe->nrbufs);
1007 + if (!buf) {
1008 + ret = -ENOMEM;
1009 + goto error_out;
1010 +@@ -1363,24 +1363,24 @@ static void set_console_size(struct port *port, u16 rows, u16 cols)
1011 + port->cons.ws.ws_col = cols;
1012 + }
1013 +
1014 +-static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
1015 ++static int fill_queue(struct virtqueue *vq, spinlock_t *lock)
1016 + {
1017 + struct port_buffer *buf;
1018 +- unsigned int nr_added_bufs;
1019 ++ int nr_added_bufs;
1020 + int ret;
1021 +
1022 + nr_added_bufs = 0;
1023 + do {
1024 +- buf = alloc_buf(vq, PAGE_SIZE, 0);
1025 ++ buf = alloc_buf(vq->vdev, PAGE_SIZE, 0);
1026 + if (!buf)
1027 +- break;
1028 ++ return -ENOMEM;
1029 +
1030 + spin_lock_irq(lock);
1031 + ret = add_inbuf(vq, buf);
1032 + if (ret < 0) {
1033 + spin_unlock_irq(lock);
1034 + free_buf(buf, true);
1035 +- break;
1036 ++ return ret;
1037 + }
1038 + nr_added_bufs++;
1039 + spin_unlock_irq(lock);
1040 +@@ -1400,7 +1400,6 @@ static int add_port(struct ports_device *portdev, u32 id)
1041 + char debugfs_name[16];
1042 + struct port *port;
1043 + dev_t devt;
1044 +- unsigned int nr_added_bufs;
1045 + int err;
1046 +
1047 + port = kmalloc(sizeof(*port), GFP_KERNEL);
1048 +@@ -1459,11 +1458,13 @@ static int add_port(struct ports_device *portdev, u32 id)
1049 + spin_lock_init(&port->outvq_lock);
1050 + init_waitqueue_head(&port->waitqueue);
1051 +
1052 +- /* Fill the in_vq with buffers so the host can send us data. */
1053 +- nr_added_bufs = fill_queue(port->in_vq, &port->inbuf_lock);
1054 +- if (!nr_added_bufs) {
1055 ++ /* We can safely ignore ENOSPC because it means
1056 ++ * the queue already has buffers. Buffers are removed
1057 ++ * only by virtcons_remove(), not by unplug_port()
1058 ++ */
1059 ++ err = fill_queue(port->in_vq, &port->inbuf_lock);
1060 ++ if (err < 0 && err != -ENOSPC) {
1061 + dev_err(port->dev, "Error allocating inbufs\n");
1062 +- err = -ENOMEM;
1063 + goto free_device;
1064 + }
1065 +
1066 +@@ -1986,19 +1987,40 @@ static void remove_vqs(struct ports_device *portdev)
1067 + kfree(portdev->out_vqs);
1068 + }
1069 +
1070 +-static void remove_controlq_data(struct ports_device *portdev)
1071 ++static void virtcons_remove(struct virtio_device *vdev)
1072 + {
1073 +- struct port_buffer *buf;
1074 +- unsigned int len;
1075 ++ struct ports_device *portdev;
1076 ++ struct port *port, *port2;
1077 +
1078 +- if (!use_multiport(portdev))
1079 +- return;
1080 ++ portdev = vdev->priv;
1081 +
1082 +- while ((buf = virtqueue_get_buf(portdev->c_ivq, &len)))
1083 +- free_buf(buf, true);
1084 ++ spin_lock_irq(&pdrvdata_lock);
1085 ++ list_del(&portdev->list);
1086 ++ spin_unlock_irq(&pdrvdata_lock);
1087 +
1088 +- while ((buf = virtqueue_detach_unused_buf(portdev->c_ivq)))
1089 +- free_buf(buf, true);
1090 ++ /* Disable interrupts for vqs */
1091 ++ vdev->config->reset(vdev);
1092 ++ /* Finish up work that's lined up */
1093 ++ if (use_multiport(portdev))
1094 ++ cancel_work_sync(&portdev->control_work);
1095 ++ else
1096 ++ cancel_work_sync(&portdev->config_work);
1097 ++
1098 ++ list_for_each_entry_safe(port, port2, &portdev->ports, list)
1099 ++ unplug_port(port);
1100 ++
1101 ++ unregister_chrdev(portdev->chr_major, "virtio-portsdev");
1102 ++
1103 ++ /*
1104 ++ * When yanking out a device, we immediately lose the
1105 ++ * (device-side) queues. So there's no point in keeping the
1106 ++ * guest side around till we drop our final reference. This
1107 ++ * also means that any ports which are in an open state will
1108 ++ * have to just stop using the port, as the vqs are going
1109 ++ * away.
1110 ++ */
1111 ++ remove_vqs(portdev);
1112 ++ kfree(portdev);
1113 + }
1114 +
1115 + /*
1116 +@@ -2067,6 +2089,7 @@ static int virtcons_probe(struct virtio_device *vdev)
1117 +
1118 + spin_lock_init(&portdev->ports_lock);
1119 + INIT_LIST_HEAD(&portdev->ports);
1120 ++ INIT_LIST_HEAD(&portdev->list);
1121 +
1122 + virtio_device_ready(portdev->vdev);
1123 +
1124 +@@ -2074,18 +2097,22 @@ static int virtcons_probe(struct virtio_device *vdev)
1125 + INIT_WORK(&portdev->control_work, &control_work_handler);
1126 +
1127 + if (multiport) {
1128 +- unsigned int nr_added_bufs;
1129 +-
1130 + spin_lock_init(&portdev->c_ivq_lock);
1131 + spin_lock_init(&portdev->c_ovq_lock);
1132 +
1133 +- nr_added_bufs = fill_queue(portdev->c_ivq,
1134 +- &portdev->c_ivq_lock);
1135 +- if (!nr_added_bufs) {
1136 ++ err = fill_queue(portdev->c_ivq, &portdev->c_ivq_lock);
1137 ++ if (err < 0) {
1138 + dev_err(&vdev->dev,
1139 + "Error allocating buffers for control queue\n");
1140 +- err = -ENOMEM;
1141 +- goto free_vqs;
1142 ++ /*
1143 ++ * The host might want to notify mgmt sw about device
1144 ++ * add failure.
1145 ++ */
1146 ++ __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID,
1147 ++ VIRTIO_CONSOLE_DEVICE_READY, 0);
1148 ++ /* Device was functional: we need full cleanup. */
1149 ++ virtcons_remove(vdev);
1150 ++ return err;
1151 + }
1152 + } else {
1153 + /*
1154 +@@ -2116,11 +2143,6 @@ static int virtcons_probe(struct virtio_device *vdev)
1155 +
1156 + return 0;
1157 +
1158 +-free_vqs:
1159 +- /* The host might want to notify mgmt sw about device add failure */
1160 +- __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID,
1161 +- VIRTIO_CONSOLE_DEVICE_READY, 0);
1162 +- remove_vqs(portdev);
1163 + free_chrdev:
1164 + unregister_chrdev(portdev->chr_major, "virtio-portsdev");
1165 + free:
1166 +@@ -2129,43 +2151,6 @@ fail:
1167 + return err;
1168 + }
1169 +
1170 +-static void virtcons_remove(struct virtio_device *vdev)
1171 +-{
1172 +- struct ports_device *portdev;
1173 +- struct port *port, *port2;
1174 +-
1175 +- portdev = vdev->priv;
1176 +-
1177 +- spin_lock_irq(&pdrvdata_lock);
1178 +- list_del(&portdev->list);
1179 +- spin_unlock_irq(&pdrvdata_lock);
1180 +-
1181 +- /* Disable interrupts for vqs */
1182 +- vdev->config->reset(vdev);
1183 +- /* Finish up work that's lined up */
1184 +- if (use_multiport(portdev))
1185 +- cancel_work_sync(&portdev->control_work);
1186 +- else
1187 +- cancel_work_sync(&portdev->config_work);
1188 +-
1189 +- list_for_each_entry_safe(port, port2, &portdev->ports, list)
1190 +- unplug_port(port);
1191 +-
1192 +- unregister_chrdev(portdev->chr_major, "virtio-portsdev");
1193 +-
1194 +- /*
1195 +- * When yanking out a device, we immediately lose the
1196 +- * (device-side) queues. So there's no point in keeping the
1197 +- * guest side around till we drop our final reference. This
1198 +- * also means that any ports which are in an open state will
1199 +- * have to just stop using the port, as the vqs are going
1200 +- * away.
1201 +- */
1202 +- remove_controlq_data(portdev);
1203 +- remove_vqs(portdev);
1204 +- kfree(portdev);
1205 +-}
1206 +-
1207 + static struct virtio_device_id id_table[] = {
1208 + { VIRTIO_ID_CONSOLE, VIRTIO_DEV_ANY_ID },
1209 + { 0 },
1210 +@@ -2196,15 +2181,16 @@ static int virtcons_freeze(struct virtio_device *vdev)
1211 +
1212 + vdev->config->reset(vdev);
1213 +
1214 +- virtqueue_disable_cb(portdev->c_ivq);
1215 ++ if (use_multiport(portdev))
1216 ++ virtqueue_disable_cb(portdev->c_ivq);
1217 + cancel_work_sync(&portdev->control_work);
1218 + cancel_work_sync(&portdev->config_work);
1219 + /*
1220 + * Once more: if control_work_handler() was running, it would
1221 + * enable the cb as the last step.
1222 + */
1223 +- virtqueue_disable_cb(portdev->c_ivq);
1224 +- remove_controlq_data(portdev);
1225 ++ if (use_multiport(portdev))
1226 ++ virtqueue_disable_cb(portdev->c_ivq);
1227 +
1228 + list_for_each_entry(port, &portdev->ports, list) {
1229 + virtqueue_disable_cb(port->in_vq);
1230 +diff --git a/drivers/clk/mmp/clk-of-mmp2.c b/drivers/clk/mmp/clk-of-mmp2.c
1231 +index f261b1d292c7..8b45cb2caed1 100644
1232 +--- a/drivers/clk/mmp/clk-of-mmp2.c
1233 ++++ b/drivers/clk/mmp/clk-of-mmp2.c
1234 +@@ -227,8 +227,8 @@ static struct mmp_param_gate_clk apmu_gate_clks[] = {
1235 + /* The gate clocks has mux parent. */
1236 + {MMP2_CLK_SDH0, "sdh0_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH0, 0x1b, 0x1b, 0x0, 0, &sdh_lock},
1237 + {MMP2_CLK_SDH1, "sdh1_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH1, 0x1b, 0x1b, 0x0, 0, &sdh_lock},
1238 +- {MMP2_CLK_SDH1, "sdh2_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH2, 0x1b, 0x1b, 0x0, 0, &sdh_lock},
1239 +- {MMP2_CLK_SDH1, "sdh3_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH3, 0x1b, 0x1b, 0x0, 0, &sdh_lock},
1240 ++ {MMP2_CLK_SDH2, "sdh2_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH2, 0x1b, 0x1b, 0x0, 0, &sdh_lock},
1241 ++ {MMP2_CLK_SDH3, "sdh3_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH3, 0x1b, 0x1b, 0x0, 0, &sdh_lock},
1242 + {MMP2_CLK_DISP0, "disp0_clk", "disp0_div", CLK_SET_RATE_PARENT, APMU_DISP0, 0x1b, 0x1b, 0x0, 0, &disp0_lock},
1243 + {MMP2_CLK_DISP0_SPHY, "disp0_sphy_clk", "disp0_sphy_div", CLK_SET_RATE_PARENT, APMU_DISP0, 0x1024, 0x1024, 0x0, 0, &disp0_lock},
1244 + {MMP2_CLK_DISP1, "disp1_clk", "disp1_div", CLK_SET_RATE_PARENT, APMU_DISP1, 0x1b, 0x1b, 0x0, 0, &disp1_lock},
1245 +diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
1246 +index 0836d2939c7a..2239d42bdadd 100644
1247 +--- a/drivers/cpufreq/cpufreq.c
1248 ++++ b/drivers/cpufreq/cpufreq.c
1249 +@@ -821,6 +821,9 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)
1250 + struct freq_attr *fattr = to_attr(attr);
1251 + ssize_t ret;
1252 +
1253 ++ if (!fattr->show)
1254 ++ return -EIO;
1255 ++
1256 + down_read(&policy->rwsem);
1257 +
1258 + if (fattr->show)
1259 +@@ -840,6 +843,9 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
1260 + struct freq_attr *fattr = to_attr(attr);
1261 + ssize_t ret = -EINVAL;
1262 +
1263 ++ if (!fattr->store)
1264 ++ return -EIO;
1265 ++
1266 + get_online_cpus();
1267 +
1268 + if (!cpu_online(policy->cpu))
1269 +@@ -1627,6 +1633,9 @@ void cpufreq_resume(void)
1270 + if (!cpufreq_driver)
1271 + return;
1272 +
1273 ++ if (unlikely(!cpufreq_suspended))
1274 ++ return;
1275 ++
1276 + cpufreq_suspended = false;
1277 +
1278 + if (!has_target())
1279 +diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
1280 +index f1ab05ea56bb..3c117559f102 100644
1281 +--- a/drivers/firmware/google/gsmi.c
1282 ++++ b/drivers/firmware/google/gsmi.c
1283 +@@ -480,11 +480,10 @@ static ssize_t eventlog_write(struct file *filp, struct kobject *kobj,
1284 + if (count < sizeof(u32))
1285 + return -EINVAL;
1286 + param.type = *(u32 *)buf;
1287 +- count -= sizeof(u32);
1288 + buf += sizeof(u32);
1289 +
1290 + /* The remaining buffer is the data payload */
1291 +- if (count > gsmi_dev.data_buf->length)
1292 ++ if ((count - sizeof(u32)) > gsmi_dev.data_buf->length)
1293 + return -EINVAL;
1294 + param.data_len = count - sizeof(u32);
1295 +
1296 +@@ -504,7 +503,7 @@ static ssize_t eventlog_write(struct file *filp, struct kobject *kobj,
1297 +
1298 + spin_unlock_irqrestore(&gsmi_dev.lock, flags);
1299 +
1300 +- return rc;
1301 ++ return (rc == 0) ? count : rc;
1302 +
1303 + }
1304 +
1305 +diff --git a/drivers/isdn/mISDN/tei.c b/drivers/isdn/mISDN/tei.c
1306 +index 592f597d8951..8261afbbafb0 100644
1307 +--- a/drivers/isdn/mISDN/tei.c
1308 ++++ b/drivers/isdn/mISDN/tei.c
1309 +@@ -1180,8 +1180,7 @@ static int
1310 + ctrl_teimanager(struct manager *mgr, void *arg)
1311 + {
1312 + /* currently we only have one option */
1313 +- int *val = (int *)arg;
1314 +- int ret = 0;
1315 ++ unsigned int *val = (unsigned int *)arg;
1316 +
1317 + switch (val[0]) {
1318 + case IMCLEAR_L2:
1319 +@@ -1197,9 +1196,9 @@ ctrl_teimanager(struct manager *mgr, void *arg)
1320 + test_and_clear_bit(OPTION_L1_HOLD, &mgr->options);
1321 + break;
1322 + default:
1323 +- ret = -EINVAL;
1324 ++ return -EINVAL;
1325 + }
1326 +- return ret;
1327 ++ return 0;
1328 + }
1329 +
1330 + /* This function does create a L2 for fixed TEI in NT Mode */
1331 +diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
1332 +index ad6223e88340..3d310dd60a0b 100644
1333 +--- a/drivers/macintosh/windfarm_smu_sat.c
1334 ++++ b/drivers/macintosh/windfarm_smu_sat.c
1335 +@@ -22,14 +22,6 @@
1336 +
1337 + #define VERSION "1.0"
1338 +
1339 +-#define DEBUG
1340 +-
1341 +-#ifdef DEBUG
1342 +-#define DBG(args...) printk(args)
1343 +-#else
1344 +-#define DBG(args...) do { } while(0)
1345 +-#endif
1346 +-
1347 + /* If the cache is older than 800ms we'll refetch it */
1348 + #define MAX_AGE msecs_to_jiffies(800)
1349 +
1350 +@@ -106,13 +98,10 @@ struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id, int id,
1351 + buf[i+2] = data[3];
1352 + buf[i+3] = data[2];
1353 + }
1354 +-#ifdef DEBUG
1355 +- DBG(KERN_DEBUG "sat %d partition %x:", sat_id, id);
1356 +- for (i = 0; i < len; ++i)
1357 +- DBG(" %x", buf[i]);
1358 +- DBG("\n");
1359 +-#endif
1360 +
1361 ++ printk(KERN_DEBUG "sat %d partition %x:", sat_id, id);
1362 ++ print_hex_dump(KERN_DEBUG, " ", DUMP_PREFIX_OFFSET,
1363 ++ 16, 1, buf, len, false);
1364 + if (size)
1365 + *size = len;
1366 + return (struct smu_sdbp_header *) buf;
1367 +@@ -132,13 +121,13 @@ static int wf_sat_read_cache(struct wf_sat *sat)
1368 + if (err < 0)
1369 + return err;
1370 + sat->last_read = jiffies;
1371 ++
1372 + #ifdef LOTSA_DEBUG
1373 + {
1374 + int i;
1375 +- DBG(KERN_DEBUG "wf_sat_get: data is");
1376 +- for (i = 0; i < 16; ++i)
1377 +- DBG(" %.2x", sat->cache[i]);
1378 +- DBG("\n");
1379 ++ printk(KERN_DEBUG "wf_sat_get: data is");
1380 ++ print_hex_dump(KERN_DEBUG, " ", DUMP_PREFIX_OFFSET,
1381 ++ 16, 1, sat->cache, 16, false);
1382 + }
1383 + #endif
1384 + return 0;
1385 +diff --git a/drivers/md/dm.c b/drivers/md/dm.c
1386 +index 3d9a80759d95..c752c55f0bb2 100644
1387 +--- a/drivers/md/dm.c
1388 ++++ b/drivers/md/dm.c
1389 +@@ -2939,9 +2939,7 @@ static void __dm_destroy(struct mapped_device *md, bool wait)
1390 + set_bit(DMF_FREEING, &md->flags);
1391 + spin_unlock(&_minor_lock);
1392 +
1393 +- spin_lock_irq(q->queue_lock);
1394 +- queue_flag_set(QUEUE_FLAG_DYING, q);
1395 +- spin_unlock_irq(q->queue_lock);
1396 ++ blk_set_queue_dying(q);
1397 +
1398 + if (dm_request_based(md) && md->kworker_task)
1399 + flush_kthread_worker(&md->kworker);
1400 +diff --git a/drivers/media/platform/vivid/vivid-kthread-cap.c b/drivers/media/platform/vivid/vivid-kthread-cap.c
1401 +index 81ba454a6d95..1e34ee16b792 100644
1402 +--- a/drivers/media/platform/vivid/vivid-kthread-cap.c
1403 ++++ b/drivers/media/platform/vivid/vivid-kthread-cap.c
1404 +@@ -763,7 +763,11 @@ static int vivid_thread_vid_cap(void *data)
1405 + if (kthread_should_stop())
1406 + break;
1407 +
1408 +- mutex_lock(&dev->mutex);
1409 ++ if (!mutex_trylock(&dev->mutex)) {
1410 ++ schedule_timeout_uninterruptible(1);
1411 ++ continue;
1412 ++ }
1413 ++
1414 + cur_jiffies = jiffies;
1415 + if (dev->cap_seq_resync) {
1416 + dev->jiffies_vid_cap = cur_jiffies;
1417 +@@ -916,8 +920,6 @@ void vivid_stop_generating_vid_cap(struct vivid_dev *dev, bool *pstreaming)
1418 +
1419 + /* shutdown control thread */
1420 + vivid_grab_controls(dev, false);
1421 +- mutex_unlock(&dev->mutex);
1422 + kthread_stop(dev->kthread_vid_cap);
1423 + dev->kthread_vid_cap = NULL;
1424 +- mutex_lock(&dev->mutex);
1425 + }
1426 +diff --git a/drivers/media/platform/vivid/vivid-kthread-out.c b/drivers/media/platform/vivid/vivid-kthread-out.c
1427 +index 2c5dbdcb576a..ba38602680d6 100644
1428 +--- a/drivers/media/platform/vivid/vivid-kthread-out.c
1429 ++++ b/drivers/media/platform/vivid/vivid-kthread-out.c
1430 +@@ -147,7 +147,11 @@ static int vivid_thread_vid_out(void *data)
1431 + if (kthread_should_stop())
1432 + break;
1433 +
1434 +- mutex_lock(&dev->mutex);
1435 ++ if (!mutex_trylock(&dev->mutex)) {
1436 ++ schedule_timeout_uninterruptible(1);
1437 ++ continue;
1438 ++ }
1439 ++
1440 + cur_jiffies = jiffies;
1441 + if (dev->out_seq_resync) {
1442 + dev->jiffies_vid_out = cur_jiffies;
1443 +@@ -301,8 +305,6 @@ void vivid_stop_generating_vid_out(struct vivid_dev *dev, bool *pstreaming)
1444 +
1445 + /* shutdown control thread */
1446 + vivid_grab_controls(dev, false);
1447 +- mutex_unlock(&dev->mutex);
1448 + kthread_stop(dev->kthread_vid_out);
1449 + dev->kthread_vid_out = NULL;
1450 +- mutex_lock(&dev->mutex);
1451 + }
1452 +diff --git a/drivers/media/platform/vivid/vivid-sdr-cap.c b/drivers/media/platform/vivid/vivid-sdr-cap.c
1453 +index 082c401764ce..4866f42c8027 100644
1454 +--- a/drivers/media/platform/vivid/vivid-sdr-cap.c
1455 ++++ b/drivers/media/platform/vivid/vivid-sdr-cap.c
1456 +@@ -151,7 +151,11 @@ static int vivid_thread_sdr_cap(void *data)
1457 + if (kthread_should_stop())
1458 + break;
1459 +
1460 +- mutex_lock(&dev->mutex);
1461 ++ if (!mutex_trylock(&dev->mutex)) {
1462 ++ schedule_timeout_uninterruptible(1);
1463 ++ continue;
1464 ++ }
1465 ++
1466 + cur_jiffies = jiffies;
1467 + if (dev->sdr_cap_seq_resync) {
1468 + dev->jiffies_sdr_cap = cur_jiffies;
1469 +@@ -311,10 +315,8 @@ static void sdr_cap_stop_streaming(struct vb2_queue *vq)
1470 + }
1471 +
1472 + /* shutdown control thread */
1473 +- mutex_unlock(&dev->mutex);
1474 + kthread_stop(dev->kthread_sdr_cap);
1475 + dev->kthread_sdr_cap = NULL;
1476 +- mutex_lock(&dev->mutex);
1477 + }
1478 +
1479 + const struct vb2_ops vivid_sdr_cap_qops = {
1480 +diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
1481 +index 9eb0bc4a8d97..9240c375d540 100644
1482 +--- a/drivers/media/platform/vivid/vivid-vid-cap.c
1483 ++++ b/drivers/media/platform/vivid/vivid-vid-cap.c
1484 +@@ -253,9 +253,6 @@ static int vid_cap_start_streaming(struct vb2_queue *vq, unsigned count)
1485 + if (vb2_is_streaming(&dev->vb_vid_out_q))
1486 + dev->can_loop_video = vivid_vid_can_loop(dev);
1487 +
1488 +- if (dev->kthread_vid_cap)
1489 +- return 0;
1490 +-
1491 + dev->vid_cap_seq_count = 0;
1492 + dprintk(dev, 1, "%s\n", __func__);
1493 + for (i = 0; i < VIDEO_MAX_FRAME; i++)
1494 +diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c
1495 +index b77acb6a7013..ffe5531dfc81 100644
1496 +--- a/drivers/media/platform/vivid/vivid-vid-out.c
1497 ++++ b/drivers/media/platform/vivid/vivid-vid-out.c
1498 +@@ -173,9 +173,6 @@ static int vid_out_start_streaming(struct vb2_queue *vq, unsigned count)
1499 + if (vb2_is_streaming(&dev->vb_vid_cap_q))
1500 + dev->can_loop_video = vivid_vid_can_loop(dev);
1501 +
1502 +- if (dev->kthread_vid_out)
1503 +- return 0;
1504 +-
1505 + dev->vid_out_seq_count = 0;
1506 + dprintk(dev, 1, "%s\n", __func__);
1507 + if (dev->start_streaming_error) {
1508 +diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
1509 +index 7a16e9ea041c..0a8d529e12cc 100644
1510 +--- a/drivers/media/rc/imon.c
1511 ++++ b/drivers/media/rc/imon.c
1512 +@@ -1644,8 +1644,7 @@ static void imon_incoming_packet(struct imon_context *ictx,
1513 + spin_unlock_irqrestore(&ictx->kc_lock, flags);
1514 +
1515 + /* send touchscreen events through input subsystem if touchpad data */
1516 +- if (ictx->display_type == IMON_DISPLAY_TYPE_VGA && len == 8 &&
1517 +- buf[7] == 0x86) {
1518 ++ if (ictx->touch && len == 8 && buf[7] == 0x86) {
1519 + imon_touch_event(ictx, buf);
1520 + return;
1521 +
1522 +diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c
1523 +index 0bd969063392..83d3a5cf272f 100644
1524 +--- a/drivers/media/usb/b2c2/flexcop-usb.c
1525 ++++ b/drivers/media/usb/b2c2/flexcop-usb.c
1526 +@@ -508,6 +508,9 @@ static int flexcop_usb_probe(struct usb_interface *intf,
1527 + struct flexcop_device *fc = NULL;
1528 + int ret;
1529 +
1530 ++ if (intf->cur_altsetting->desc.bNumEndpoints < 1)
1531 ++ return -ENODEV;
1532 ++
1533 + if ((fc = flexcop_device_kmalloc(sizeof(struct flexcop_usb))) == NULL) {
1534 + err("out of memory\n");
1535 + return -ENOMEM;
1536 +diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
1537 +index d00b27ed73a6..72bde33211b2 100644
1538 +--- a/drivers/media/usb/dvb-usb/cxusb.c
1539 ++++ b/drivers/media/usb/dvb-usb/cxusb.c
1540 +@@ -435,7 +435,8 @@ static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1541 + u8 ircode[4];
1542 + int i;
1543 +
1544 +- cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
1545 ++ if (cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4) < 0)
1546 ++ return 0;
1547 +
1548 + *event = 0;
1549 + *state = REMOTE_NO_KEY_PRESSED;
1550 +diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
1551 +index 156ed6f92aa3..2d9ae7cf948f 100644
1552 +--- a/drivers/mfd/max8997.c
1553 ++++ b/drivers/mfd/max8997.c
1554 +@@ -156,12 +156,6 @@ static struct max8997_platform_data *max8997_i2c_parse_dt_pdata(
1555 +
1556 + pd->ono = irq_of_parse_and_map(dev->of_node, 1);
1557 +
1558 +- /*
1559 +- * ToDo: the 'wakeup' member in the platform data is more of a linux
1560 +- * specfic information. Hence, there is no binding for that yet and
1561 +- * not parsed here.
1562 +- */
1563 +-
1564 + return pd;
1565 + }
1566 +
1567 +@@ -249,7 +243,7 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
1568 + */
1569 +
1570 + /* MAX8997 has a power button input. */
1571 +- device_init_wakeup(max8997->dev, pdata->wakeup);
1572 ++ device_init_wakeup(max8997->dev, true);
1573 +
1574 + return ret;
1575 +
1576 +diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
1577 +index 8d74806b83c1..1494e7cbd593 100644
1578 +--- a/drivers/mfd/mc13xxx-core.c
1579 ++++ b/drivers/mfd/mc13xxx-core.c
1580 +@@ -278,7 +278,8 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
1581 + if (ret)
1582 + goto out;
1583 +
1584 +- adc0 = MC13XXX_ADC0_ADINC1 | MC13XXX_ADC0_ADINC2;
1585 ++ adc0 = MC13XXX_ADC0_ADINC1 | MC13XXX_ADC0_ADINC2 |
1586 ++ MC13XXX_ADC0_CHRGRAWDIV;
1587 + adc1 = MC13XXX_ADC1_ADEN | MC13XXX_ADC1_ADTRIGIGN | MC13XXX_ADC1_ASC;
1588 +
1589 + if (channel > 7)
1590 +diff --git a/drivers/misc/mic/scif/scif_fence.c b/drivers/misc/mic/scif/scif_fence.c
1591 +index 7f2c96f57066..6821d9d41585 100644
1592 +--- a/drivers/misc/mic/scif/scif_fence.c
1593 ++++ b/drivers/misc/mic/scif/scif_fence.c
1594 +@@ -271,7 +271,7 @@ static int _scif_prog_signal(scif_epd_t epd, dma_addr_t dst, u64 val)
1595 + dma_fail:
1596 + if (!x100)
1597 + dma_pool_free(ep->remote_dev->signal_pool, status,
1598 +- status->src_dma_addr);
1599 ++ src - offsetof(struct scif_status, val));
1600 + alloc_fail:
1601 + return err;
1602 + }
1603 +diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
1604 +index f600bdcaf5b4..07592e428755 100644
1605 +--- a/drivers/mmc/card/block.c
1606 ++++ b/drivers/mmc/card/block.c
1607 +@@ -1772,8 +1772,7 @@ static void mmc_blk_packed_hdr_wrq_prep(struct mmc_queue_req *mqrq,
1608 + do_data_tag = (card->ext_csd.data_tag_unit_size) &&
1609 + (prq->cmd_flags & REQ_META) &&
1610 + (rq_data_dir(prq) == WRITE) &&
1611 +- ((brq->data.blocks * brq->data.blksz) >=
1612 +- card->ext_csd.data_tag_unit_size);
1613 ++ blk_rq_bytes(prq) >= card->ext_csd.data_tag_unit_size;
1614 + /* Argument of CMD23 */
1615 + packed_cmd_hdr[(i * 2)] = cpu_to_le32(
1616 + (do_rel_wr ? MMC_CMD23_ARG_REL_WR : 0) |
1617 +diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
1618 +index 0bf0d0e9dbdb..5ef25463494f 100644
1619 +--- a/drivers/mmc/host/mtk-sd.c
1620 ++++ b/drivers/mmc/host/mtk-sd.c
1621 +@@ -846,6 +846,7 @@ static void msdc_start_command(struct msdc_host *host,
1622 + WARN_ON(host->cmd);
1623 + host->cmd = cmd;
1624 +
1625 ++ mod_delayed_work(system_wq, &host->req_timeout, DAT_TIMEOUT);
1626 + if (!msdc_cmd_is_ready(host, mrq, cmd))
1627 + return;
1628 +
1629 +@@ -857,7 +858,6 @@ static void msdc_start_command(struct msdc_host *host,
1630 +
1631 + cmd->error = 0;
1632 + rawcmd = msdc_cmd_prepare_raw_cmd(host, mrq, cmd);
1633 +- mod_delayed_work(system_wq, &host->req_timeout, DAT_TIMEOUT);
1634 +
1635 + sdr_set_bits(host->base + MSDC_INTEN, cmd_ints_mask);
1636 + writel(cmd->arg, host->base + SDC_ARG);
1637 +diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
1638 +index 04fe570275cd..34fae5576b60 100644
1639 +--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
1640 ++++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
1641 +@@ -1074,7 +1074,7 @@ static int bcmgenet_power_down(struct bcmgenet_priv *priv,
1642 + break;
1643 + }
1644 +
1645 +- return 0;
1646 ++ return ret;
1647 + }
1648 +
1649 + static void bcmgenet_power_up(struct bcmgenet_priv *priv,
1650 +diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
1651 +index c44df87c38de..5e65d8a78c3e 100644
1652 +--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
1653 ++++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
1654 +@@ -65,9 +65,15 @@
1655 + *
1656 + * The 40 bit 82580 SYSTIM overflows every
1657 + * 2^40 * 10^-9 / 60 = 18.3 minutes.
1658 ++ *
1659 ++ * SYSTIM is converted to real time using a timecounter. As
1660 ++ * timecounter_cyc2time() allows old timestamps, the timecounter
1661 ++ * needs to be updated at least once per half of the SYSTIM interval.
1662 ++ * Scheduling of delayed work is not very accurate, so we aim for 8
1663 ++ * minutes to be sure the actual interval is shorter than 9.16 minutes.
1664 + */
1665 +
1666 +-#define IGB_SYSTIM_OVERFLOW_PERIOD (HZ * 60 * 9)
1667 ++#define IGB_SYSTIM_OVERFLOW_PERIOD (HZ * 60 * 8)
1668 + #define IGB_PTP_TX_TIMEOUT (HZ * 15)
1669 + #define INCPERIOD_82576 (1 << E1000_TIMINCA_16NS_SHIFT)
1670 + #define INCVALUE_82576_MASK ((1 << E1000_TIMINCA_16NS_SHIFT) - 1)
1671 +diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1672 +index fcd1e6b3950d..b52491f09a4d 100644
1673 +--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1674 ++++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1675 +@@ -1667,6 +1667,7 @@ static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
1676 + err = mlx4_en_get_flow(dev, cmd, cmd->fs.location);
1677 + break;
1678 + case ETHTOOL_GRXCLSRLALL:
1679 ++ cmd->data = MAX_NUM_OF_FS_RULES;
1680 + while ((!err || err == -ENOENT) && priority < cmd->rule_cnt) {
1681 + err = mlx4_en_get_flow(dev, cmd, i);
1682 + if (!err)
1683 +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c
1684 +index a72bcddf160a..178e7236eeb5 100644
1685 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c
1686 ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c
1687 +@@ -883,7 +883,7 @@ static u8 qlcnic_dcb_get_capability(struct net_device *netdev, int capid,
1688 + struct qlcnic_adapter *adapter = netdev_priv(netdev);
1689 +
1690 + if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state))
1691 +- return 0;
1692 ++ return 1;
1693 +
1694 + switch (capid) {
1695 + case DCB_CAP_ATTR_PG:
1696 +diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
1697 +index c771e0af4e06..ffb2544f8574 100644
1698 +--- a/drivers/net/ethernet/sfc/ptp.c
1699 ++++ b/drivers/net/ethernet/sfc/ptp.c
1700 +@@ -1320,7 +1320,8 @@ void efx_ptp_remove(struct efx_nic *efx)
1701 + (void)efx_ptp_disable(efx);
1702 +
1703 + cancel_work_sync(&efx->ptp_data->work);
1704 +- cancel_work_sync(&efx->ptp_data->pps_work);
1705 ++ if (efx->ptp_data->pps_workwq)
1706 ++ cancel_work_sync(&efx->ptp_data->pps_work);
1707 +
1708 + skb_queue_purge(&efx->ptp_data->rxq);
1709 + skb_queue_purge(&efx->ptp_data->txq);
1710 +diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c
1711 +index a9acf7156855..03009f1becdd 100644
1712 +--- a/drivers/net/ntb_netdev.c
1713 ++++ b/drivers/net/ntb_netdev.c
1714 +@@ -236,7 +236,7 @@ static void ntb_netdev_tx_timer(unsigned long data)
1715 + struct ntb_netdev *dev = netdev_priv(ndev);
1716 +
1717 + if (ntb_transport_tx_free_entry(dev->qp) < tx_stop) {
1718 +- mod_timer(&dev->tx_timer, jiffies + msecs_to_jiffies(tx_time));
1719 ++ mod_timer(&dev->tx_timer, jiffies + usecs_to_jiffies(tx_time));
1720 + } else {
1721 + /* Make sure anybody stopping the queue after this sees the new
1722 + * value of ntb_transport_tx_free_entry()
1723 +diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
1724 +index 17c40f06f13e..82d24f2b9c19 100644
1725 +--- a/drivers/net/wireless/airo.c
1726 ++++ b/drivers/net/wireless/airo.c
1727 +@@ -5484,7 +5484,7 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
1728 + we have to add a spin lock... */
1729 + rc = readBSSListRid(ai, doLoseSync, &BSSList_rid);
1730 + while(rc == 0 && BSSList_rid.index != cpu_to_le16(0xffff)) {
1731 +- ptr += sprintf(ptr, "%pM %*s rssi = %d",
1732 ++ ptr += sprintf(ptr, "%pM %.*s rssi = %d",
1733 + BSSList_rid.bssid,
1734 + (int)BSSList_rid.ssidLen,
1735 + BSSList_rid.ssid,
1736 +diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1737 +index ef493271c712..c876dc2437b0 100644
1738 +--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1739 ++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1740 +@@ -4114,7 +4114,7 @@ static void ar9003_hw_thermometer_apply(struct ath_hw *ah)
1741 +
1742 + static void ar9003_hw_thermo_cal_apply(struct ath_hw *ah)
1743 + {
1744 +- u32 data, ko, kg;
1745 ++ u32 data = 0, ko, kg;
1746 +
1747 + if (!AR_SREV_9462_20_OR_LATER(ah))
1748 + return;
1749 +diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
1750 +index 61ae2768132a..a4e1eec96c60 100644
1751 +--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
1752 ++++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
1753 +@@ -502,6 +502,7 @@ brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1754 + }
1755 +
1756 + spin_lock_bh(&wl->lock);
1757 ++ wl->wlc->vif = vif;
1758 + wl->mute_tx = false;
1759 + brcms_c_mute(wl->wlc, false);
1760 + if (vif->type == NL80211_IFTYPE_STATION)
1761 +@@ -519,6 +520,11 @@ brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1762 + static void
1763 + brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1764 + {
1765 ++ struct brcms_info *wl = hw->priv;
1766 ++
1767 ++ spin_lock_bh(&wl->lock);
1768 ++ wl->wlc->vif = NULL;
1769 ++ spin_unlock_bh(&wl->lock);
1770 + }
1771 +
1772 + static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed)
1773 +@@ -840,8 +846,8 @@ brcms_ops_ampdu_action(struct ieee80211_hw *hw,
1774 + status = brcms_c_aggregatable(wl->wlc, tid);
1775 + spin_unlock_bh(&wl->lock);
1776 + if (!status) {
1777 +- brcms_err(wl->wlc->hw->d11core,
1778 +- "START: tid %d is not agg\'able\n", tid);
1779 ++ brcms_dbg_ht(wl->wlc->hw->d11core,
1780 ++ "START: tid %d is not agg\'able\n", tid);
1781 + return -EINVAL;
1782 + }
1783 + ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
1784 +@@ -937,6 +943,25 @@ static void brcms_ops_set_tsf(struct ieee80211_hw *hw,
1785 + spin_unlock_bh(&wl->lock);
1786 + }
1787 +
1788 ++static int brcms_ops_beacon_set_tim(struct ieee80211_hw *hw,
1789 ++ struct ieee80211_sta *sta, bool set)
1790 ++{
1791 ++ struct brcms_info *wl = hw->priv;
1792 ++ struct sk_buff *beacon = NULL;
1793 ++ u16 tim_offset = 0;
1794 ++
1795 ++ spin_lock_bh(&wl->lock);
1796 ++ if (wl->wlc->vif)
1797 ++ beacon = ieee80211_beacon_get_tim(hw, wl->wlc->vif,
1798 ++ &tim_offset, NULL);
1799 ++ if (beacon)
1800 ++ brcms_c_set_new_beacon(wl->wlc, beacon, tim_offset,
1801 ++ wl->wlc->vif->bss_conf.dtim_period);
1802 ++ spin_unlock_bh(&wl->lock);
1803 ++
1804 ++ return 0;
1805 ++}
1806 ++
1807 + static const struct ieee80211_ops brcms_ops = {
1808 + .tx = brcms_ops_tx,
1809 + .start = brcms_ops_start,
1810 +@@ -955,6 +980,7 @@ static const struct ieee80211_ops brcms_ops = {
1811 + .flush = brcms_ops_flush,
1812 + .get_tsf = brcms_ops_get_tsf,
1813 + .set_tsf = brcms_ops_set_tsf,
1814 ++ .set_tim = brcms_ops_beacon_set_tim,
1815 + };
1816 +
1817 + void brcms_dpc(unsigned long data)
1818 +diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h
1819 +index c4d135cff04a..9f76b880814e 100644
1820 +--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
1821 ++++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
1822 +@@ -563,6 +563,7 @@ struct brcms_c_info {
1823 +
1824 + struct wiphy *wiphy;
1825 + struct scb pri_scb;
1826 ++ struct ieee80211_vif *vif;
1827 +
1828 + struct sk_buff *beacon;
1829 + u16 beacon_tim_offset;
1830 +diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
1831 +index 1e074eaf613d..c6c2d3304dba 100644
1832 +--- a/drivers/net/wireless/mwifiex/cfg80211.c
1833 ++++ b/drivers/net/wireless/mwifiex/cfg80211.c
1834 +@@ -365,11 +365,20 @@ mwifiex_cfg80211_set_tx_power(struct wiphy *wiphy,
1835 + struct mwifiex_power_cfg power_cfg;
1836 + int dbm = MBM_TO_DBM(mbm);
1837 +
1838 +- if (type == NL80211_TX_POWER_FIXED) {
1839 ++ switch (type) {
1840 ++ case NL80211_TX_POWER_FIXED:
1841 + power_cfg.is_power_auto = 0;
1842 ++ power_cfg.is_power_fixed = 1;
1843 + power_cfg.power_level = dbm;
1844 +- } else {
1845 ++ break;
1846 ++ case NL80211_TX_POWER_LIMITED:
1847 ++ power_cfg.is_power_auto = 0;
1848 ++ power_cfg.is_power_fixed = 0;
1849 ++ power_cfg.power_level = dbm;
1850 ++ break;
1851 ++ case NL80211_TX_POWER_AUTOMATIC:
1852 + power_cfg.is_power_auto = 1;
1853 ++ break;
1854 + }
1855 +
1856 + priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
1857 +diff --git a/drivers/net/wireless/mwifiex/ioctl.h b/drivers/net/wireless/mwifiex/ioctl.h
1858 +index 4f0174c64946..4cb700160396 100644
1859 +--- a/drivers/net/wireless/mwifiex/ioctl.h
1860 ++++ b/drivers/net/wireless/mwifiex/ioctl.h
1861 +@@ -256,6 +256,7 @@ struct mwifiex_ds_encrypt_key {
1862 +
1863 + struct mwifiex_power_cfg {
1864 + u32 is_power_auto;
1865 ++ u32 is_power_fixed;
1866 + u32 power_level;
1867 + };
1868 +
1869 +diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
1870 +index 12eedb33db7b..992f9feaea92 100644
1871 +--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
1872 ++++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
1873 +@@ -666,6 +666,9 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
1874 + txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf;
1875 + txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET);
1876 + if (!power_cfg->is_power_auto) {
1877 ++ u16 dbm_min = power_cfg->is_power_fixed ?
1878 ++ dbm : priv->min_tx_power_level;
1879 ++
1880 + txp_cfg->mode = cpu_to_le32(1);
1881 + pg_tlv = (struct mwifiex_types_power_group *)
1882 + (buf + sizeof(struct host_cmd_ds_txpwr_cfg));
1883 +@@ -680,7 +683,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
1884 + pg->last_rate_code = 0x03;
1885 + pg->modulation_class = MOD_CLASS_HR_DSSS;
1886 + pg->power_step = 0;
1887 +- pg->power_min = (s8) dbm;
1888 ++ pg->power_min = (s8) dbm_min;
1889 + pg->power_max = (s8) dbm;
1890 + pg++;
1891 + /* Power group for modulation class OFDM */
1892 +@@ -688,7 +691,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
1893 + pg->last_rate_code = 0x07;
1894 + pg->modulation_class = MOD_CLASS_OFDM;
1895 + pg->power_step = 0;
1896 +- pg->power_min = (s8) dbm;
1897 ++ pg->power_min = (s8) dbm_min;
1898 + pg->power_max = (s8) dbm;
1899 + pg++;
1900 + /* Power group for modulation class HTBW20 */
1901 +@@ -696,7 +699,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
1902 + pg->last_rate_code = 0x20;
1903 + pg->modulation_class = MOD_CLASS_HT;
1904 + pg->power_step = 0;
1905 +- pg->power_min = (s8) dbm;
1906 ++ pg->power_min = (s8) dbm_min;
1907 + pg->power_max = (s8) dbm;
1908 + pg->ht_bandwidth = HT_BW_20;
1909 + pg++;
1910 +@@ -705,7 +708,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
1911 + pg->last_rate_code = 0x20;
1912 + pg->modulation_class = MOD_CLASS_HT;
1913 + pg->power_step = 0;
1914 +- pg->power_min = (s8) dbm;
1915 ++ pg->power_min = (s8) dbm_min;
1916 + pg->power_max = (s8) dbm;
1917 + pg->ht_bandwidth = HT_BW_40;
1918 + }
1919 +diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
1920 +index 7d820c395375..52def14d55d3 100644
1921 +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
1922 ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c
1923 +@@ -5331,6 +5331,7 @@ static int rtl8xxxu_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1924 + break;
1925 + case WLAN_CIPHER_SUITE_TKIP:
1926 + key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1927 ++ break;
1928 + default:
1929 + return -EOPNOTSUPP;
1930 + }
1931 +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c
1932 +index 62ef8209718f..5bf3712a4d49 100644
1933 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c
1934 ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c
1935 +@@ -234,7 +234,7 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw)
1936 + rtl_read_byte(rtlpriv, FW_MAC1_READY));
1937 + }
1938 + RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
1939 +- "Polling FW ready fail!! REG_MCUFWDL:0x%08ul\n",
1940 ++ "Polling FW ready fail!! REG_MCUFWDL:0x%08x\n",
1941 + rtl_read_dword(rtlpriv, REG_MCUFWDL));
1942 + return -1;
1943 + }
1944 +diff --git a/drivers/net/wireless/ti/wlcore/vendor_cmd.c b/drivers/net/wireless/ti/wlcore/vendor_cmd.c
1945 +index fd4e9ba176c9..332a3a5c1c90 100644
1946 +--- a/drivers/net/wireless/ti/wlcore/vendor_cmd.c
1947 ++++ b/drivers/net/wireless/ti/wlcore/vendor_cmd.c
1948 +@@ -66,7 +66,7 @@ wlcore_vendor_cmd_smart_config_start(struct wiphy *wiphy,
1949 + out:
1950 + mutex_unlock(&wl->mutex);
1951 +
1952 +- return 0;
1953 ++ return ret;
1954 + }
1955 +
1956 + static int
1957 +diff --git a/drivers/ntb/hw/intel/ntb_hw_intel.c b/drivers/ntb/hw/intel/ntb_hw_intel.c
1958 +index a198f8298258..2898b39c065e 100644
1959 +--- a/drivers/ntb/hw/intel/ntb_hw_intel.c
1960 ++++ b/drivers/ntb/hw/intel/ntb_hw_intel.c
1961 +@@ -330,7 +330,7 @@ static inline int ndev_db_clear_mask(struct intel_ntb_dev *ndev, u64 db_bits,
1962 + return 0;
1963 + }
1964 +
1965 +-static inline int ndev_vec_mask(struct intel_ntb_dev *ndev, int db_vector)
1966 ++static inline u64 ndev_vec_mask(struct intel_ntb_dev *ndev, int db_vector)
1967 + {
1968 + u64 shift, mask;
1969 +
1970 +diff --git a/drivers/pci/host/pci-keystone.c b/drivers/pci/host/pci-keystone.c
1971 +index fb682e8af74d..bdb808ba90d2 100644
1972 +--- a/drivers/pci/host/pci-keystone.c
1973 ++++ b/drivers/pci/host/pci-keystone.c
1974 +@@ -42,6 +42,7 @@
1975 + #define PCIE_RC_K2HK 0xb008
1976 + #define PCIE_RC_K2E 0xb009
1977 + #define PCIE_RC_K2L 0xb00a
1978 ++#define PCIE_RC_K2G 0xb00b
1979 +
1980 + #define to_keystone_pcie(x) container_of(x, struct keystone_pcie, pp)
1981 +
1982 +@@ -56,6 +57,8 @@ static void quirk_limit_mrrs(struct pci_dev *dev)
1983 + .class = PCI_CLASS_BRIDGE_PCI << 8, .class_mask = ~0, },
1984 + { PCI_DEVICE(PCI_VENDOR_ID_TI, PCIE_RC_K2L),
1985 + .class = PCI_CLASS_BRIDGE_PCI << 8, .class_mask = ~0, },
1986 ++ { PCI_DEVICE(PCI_VENDOR_ID_TI, PCIE_RC_K2G),
1987 ++ .class = PCI_CLASS_BRIDGE_PCI << 8, .class_mask = ~0, },
1988 + { 0, },
1989 + };
1990 +
1991 +diff --git a/drivers/pinctrl/pinctrl-zynq.c b/drivers/pinctrl/pinctrl-zynq.c
1992 +index d57b5eca7b98..ad12205dd796 100644
1993 +--- a/drivers/pinctrl/pinctrl-zynq.c
1994 ++++ b/drivers/pinctrl/pinctrl-zynq.c
1995 +@@ -967,15 +967,12 @@ enum zynq_io_standards {
1996 + zynq_iostd_max
1997 + };
1998 +
1999 +-/**
2000 +- * enum zynq_pin_config_param - possible pin configuration parameters
2001 +- * @PIN_CONFIG_IOSTANDARD: if the pin can select an IO standard, the argument to
2002 ++/*
2003 ++ * PIN_CONFIG_IOSTANDARD: if the pin can select an IO standard, the argument to
2004 + * this parameter (on a custom format) tells the driver which alternative
2005 + * IO standard to use.
2006 + */
2007 +-enum zynq_pin_config_param {
2008 +- PIN_CONFIG_IOSTANDARD = PIN_CONFIG_END + 1,
2009 +-};
2010 ++#define PIN_CONFIG_IOSTANDARD (PIN_CONFIG_END + 1)
2011 +
2012 + static const struct pinconf_generic_params zynq_dt_params[] = {
2013 + {"io-standard", PIN_CONFIG_IOSTANDARD, zynq_iostd_lvcmos18},
2014 +diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
2015 +index 4ea810cafaac..913b2604d345 100644
2016 +--- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
2017 ++++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
2018 +@@ -793,10 +793,23 @@ static int pmic_gpio_probe(struct platform_device *pdev)
2019 + goto err_chip;
2020 + }
2021 +
2022 +- ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins);
2023 +- if (ret) {
2024 +- dev_err(dev, "failed to add pin range\n");
2025 +- goto err_range;
2026 ++ /*
2027 ++ * For DeviceTree-supported systems, the gpio core checks the
2028 ++ * pinctrl's device node for the "gpio-ranges" property.
2029 ++ * If it is present, it takes care of adding the pin ranges
2030 ++ * for the driver. In this case the driver can skip ahead.
2031 ++ *
2032 ++ * In order to remain compatible with older, existing DeviceTree
2033 ++ * files which don't set the "gpio-ranges" property or systems that
2034 ++ * utilize ACPI the driver has to call gpiochip_add_pin_range().
2035 ++ */
2036 ++ if (!of_property_read_bool(dev->of_node, "gpio-ranges")) {
2037 ++ ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0,
2038 ++ npins);
2039 ++ if (ret) {
2040 ++ dev_err(dev, "failed to add pin range\n");
2041 ++ goto err_range;
2042 ++ }
2043 + }
2044 +
2045 + return 0;
2046 +diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
2047 +index 953974b5a9a9..6487453c68b5 100644
2048 +--- a/drivers/platform/x86/Kconfig
2049 ++++ b/drivers/platform/x86/Kconfig
2050 +@@ -566,6 +566,7 @@ config ASUS_WMI
2051 + config ASUS_NB_WMI
2052 + tristate "Asus Notebook WMI Driver"
2053 + depends on ASUS_WMI
2054 ++ depends on SERIO_I8042 || SERIO_I8042 = n
2055 + ---help---
2056 + This is a driver for newer Asus notebooks. It adds extra features
2057 + like wireless radio and bluetooth control, leds, hotkeys, backlight...
2058 +diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
2059 +index a284a2b42bcd..cccf250cd1e3 100644
2060 +--- a/drivers/platform/x86/asus-nb-wmi.c
2061 ++++ b/drivers/platform/x86/asus-nb-wmi.c
2062 +@@ -27,6 +27,7 @@
2063 + #include <linux/input/sparse-keymap.h>
2064 + #include <linux/fb.h>
2065 + #include <linux/dmi.h>
2066 ++#include <linux/i8042.h>
2067 +
2068 + #include "asus-wmi.h"
2069 +
2070 +@@ -55,8 +56,34 @@ MODULE_PARM_DESC(wapf, "WAPF value");
2071 +
2072 + static struct quirk_entry *quirks;
2073 +
2074 ++static bool asus_q500a_i8042_filter(unsigned char data, unsigned char str,
2075 ++ struct serio *port)
2076 ++{
2077 ++ static bool extended;
2078 ++ bool ret = false;
2079 ++
2080 ++ if (str & I8042_STR_AUXDATA)
2081 ++ return false;
2082 ++
2083 ++ if (unlikely(data == 0xe1)) {
2084 ++ extended = true;
2085 ++ ret = true;
2086 ++ } else if (unlikely(extended)) {
2087 ++ extended = false;
2088 ++ ret = true;
2089 ++ }
2090 ++
2091 ++ return ret;
2092 ++}
2093 ++
2094 + static struct quirk_entry quirk_asus_unknown = {
2095 + .wapf = 0,
2096 ++ .wmi_backlight_set_devstate = true,
2097 ++};
2098 ++
2099 ++static struct quirk_entry quirk_asus_q500a = {
2100 ++ .i8042_filter = asus_q500a_i8042_filter,
2101 ++ .wmi_backlight_set_devstate = true,
2102 + };
2103 +
2104 + /*
2105 +@@ -67,15 +94,42 @@ static struct quirk_entry quirk_asus_unknown = {
2106 + static struct quirk_entry quirk_asus_x55u = {
2107 + .wapf = 4,
2108 + .wmi_backlight_power = true,
2109 ++ .wmi_backlight_set_devstate = true,
2110 + .no_display_toggle = true,
2111 + };
2112 +
2113 + static struct quirk_entry quirk_asus_wapf4 = {
2114 + .wapf = 4,
2115 ++ .wmi_backlight_set_devstate = true,
2116 + };
2117 +
2118 + static struct quirk_entry quirk_asus_x200ca = {
2119 + .wapf = 2,
2120 ++ .wmi_backlight_set_devstate = true,
2121 ++};
2122 ++
2123 ++static struct quirk_entry quirk_no_rfkill = {
2124 ++ .no_rfkill = true,
2125 ++};
2126 ++
2127 ++static struct quirk_entry quirk_no_rfkill_wapf4 = {
2128 ++ .wapf = 4,
2129 ++ .no_rfkill = true,
2130 ++};
2131 ++
2132 ++static struct quirk_entry quirk_asus_ux303ub = {
2133 ++ .wmi_backlight_native = true,
2134 ++ .wmi_backlight_set_devstate = true,
2135 ++};
2136 ++
2137 ++static struct quirk_entry quirk_asus_x550lb = {
2138 ++ .wmi_backlight_set_devstate = true,
2139 ++ .xusb2pr = 0x01D9,
2140 ++};
2141 ++
2142 ++static struct quirk_entry quirk_asus_forceals = {
2143 ++ .wmi_backlight_set_devstate = true,
2144 ++ .wmi_force_als_set = true,
2145 + };
2146 +
2147 + static int dmi_matched(const struct dmi_system_id *dmi)
2148 +@@ -85,6 +139,15 @@ static int dmi_matched(const struct dmi_system_id *dmi)
2149 + }
2150 +
2151 + static const struct dmi_system_id asus_quirks[] = {
2152 ++ {
2153 ++ .callback = dmi_matched,
2154 ++ .ident = "ASUSTeK COMPUTER INC. Q500A",
2155 ++ .matches = {
2156 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
2157 ++ DMI_MATCH(DMI_PRODUCT_NAME, "Q500A"),
2158 ++ },
2159 ++ .driver_data = &quirk_asus_q500a,
2160 ++ },
2161 + {
2162 + .callback = dmi_matched,
2163 + .ident = "ASUSTeK COMPUTER INC. U32U",
2164 +@@ -160,7 +223,7 @@ static const struct dmi_system_id asus_quirks[] = {
2165 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
2166 + DMI_MATCH(DMI_PRODUCT_NAME, "X456UF"),
2167 + },
2168 +- .driver_data = &quirk_asus_wapf4,
2169 ++ .driver_data = &quirk_no_rfkill_wapf4,
2170 + },
2171 + {
2172 + .callback = dmi_matched,
2173 +@@ -315,11 +378,85 @@ static const struct dmi_system_id asus_quirks[] = {
2174 + },
2175 + .driver_data = &quirk_asus_x200ca,
2176 + },
2177 ++ {
2178 ++ .callback = dmi_matched,
2179 ++ .ident = "ASUSTeK COMPUTER INC. X555UB",
2180 ++ .matches = {
2181 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
2182 ++ DMI_MATCH(DMI_PRODUCT_NAME, "X555UB"),
2183 ++ },
2184 ++ .driver_data = &quirk_no_rfkill,
2185 ++ },
2186 ++ {
2187 ++ .callback = dmi_matched,
2188 ++ .ident = "ASUSTeK COMPUTER INC. N552VW",
2189 ++ .matches = {
2190 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
2191 ++ DMI_MATCH(DMI_PRODUCT_NAME, "N552VW"),
2192 ++ },
2193 ++ .driver_data = &quirk_no_rfkill,
2194 ++ },
2195 ++ {
2196 ++ .callback = dmi_matched,
2197 ++ .ident = "ASUSTeK COMPUTER INC. U303LB",
2198 ++ .matches = {
2199 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
2200 ++ DMI_MATCH(DMI_PRODUCT_NAME, "U303LB"),
2201 ++ },
2202 ++ .driver_data = &quirk_no_rfkill,
2203 ++ },
2204 ++ {
2205 ++ .callback = dmi_matched,
2206 ++ .ident = "ASUSTeK COMPUTER INC. Z550MA",
2207 ++ .matches = {
2208 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
2209 ++ DMI_MATCH(DMI_PRODUCT_NAME, "Z550MA"),
2210 ++ },
2211 ++ .driver_data = &quirk_no_rfkill,
2212 ++ },
2213 ++ {
2214 ++ .callback = dmi_matched,
2215 ++ .ident = "ASUSTeK COMPUTER INC. UX303UB",
2216 ++ .matches = {
2217 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
2218 ++ DMI_MATCH(DMI_PRODUCT_NAME, "UX303UB"),
2219 ++ },
2220 ++ .driver_data = &quirk_asus_ux303ub,
2221 ++ },
2222 ++ {
2223 ++ .callback = dmi_matched,
2224 ++ .ident = "ASUSTeK COMPUTER INC. UX330UAK",
2225 ++ .matches = {
2226 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
2227 ++ DMI_MATCH(DMI_PRODUCT_NAME, "UX330UAK"),
2228 ++ },
2229 ++ .driver_data = &quirk_asus_forceals,
2230 ++ },
2231 ++ {
2232 ++ .callback = dmi_matched,
2233 ++ .ident = "ASUSTeK COMPUTER INC. X550LB",
2234 ++ .matches = {
2235 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
2236 ++ DMI_MATCH(DMI_PRODUCT_NAME, "X550LB"),
2237 ++ },
2238 ++ .driver_data = &quirk_asus_x550lb,
2239 ++ },
2240 ++ {
2241 ++ .callback = dmi_matched,
2242 ++ .ident = "ASUSTeK COMPUTER INC. UX430UQ",
2243 ++ .matches = {
2244 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
2245 ++ DMI_MATCH(DMI_PRODUCT_NAME, "UX430UQ"),
2246 ++ },
2247 ++ .driver_data = &quirk_asus_forceals,
2248 ++ },
2249 + {},
2250 + };
2251 +
2252 + static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
2253 + {
2254 ++ int ret;
2255 ++
2256 + quirks = &quirk_asus_unknown;
2257 + dmi_check_system(asus_quirks);
2258 +
2259 +@@ -331,6 +468,15 @@ static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
2260 + quirks->wapf = wapf;
2261 + else
2262 + wapf = quirks->wapf;
2263 ++
2264 ++ if (quirks->i8042_filter) {
2265 ++ ret = i8042_install_filter(quirks->i8042_filter);
2266 ++ if (ret) {
2267 ++ pr_warn("Unable to install key filter\n");
2268 ++ return;
2269 ++ }
2270 ++ pr_info("Using i8042 filter function for receiving events\n");
2271 ++ }
2272 + }
2273 +
2274 + static const struct key_entry asus_nb_wmi_keymap[] = {
2275 +diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
2276 +index 7c1defaef3f5..63b5b6838e8b 100644
2277 +--- a/drivers/platform/x86/asus-wmi.c
2278 ++++ b/drivers/platform/x86/asus-wmi.c
2279 +@@ -117,6 +117,7 @@ MODULE_LICENSE("GPL");
2280 + #define ASUS_WMI_DEVID_LED6 0x00020016
2281 +
2282 + /* Backlight and Brightness */
2283 ++#define ASUS_WMI_DEVID_ALS_ENABLE 0x00050001 /* Ambient Light Sensor */
2284 + #define ASUS_WMI_DEVID_BACKLIGHT 0x00050011
2285 + #define ASUS_WMI_DEVID_BRIGHTNESS 0x00050012
2286 + #define ASUS_WMI_DEVID_KBD_BACKLIGHT 0x00050021
2287 +@@ -158,6 +159,9 @@ MODULE_LICENSE("GPL");
2288 + #define ASUS_FAN_CTRL_MANUAL 1
2289 + #define ASUS_FAN_CTRL_AUTO 2
2290 +
2291 ++#define USB_INTEL_XUSB2PR 0xD0
2292 ++#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
2293 ++
2294 + struct bios_args {
2295 + u32 arg0;
2296 + u32 arg1;
2297 +@@ -1082,6 +1086,38 @@ exit:
2298 + return result;
2299 + }
2300 +
2301 ++static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
2302 ++{
2303 ++ struct pci_dev *xhci_pdev;
2304 ++ u32 orig_ports_available;
2305 ++ u32 ports_available = asus->driver->quirks->xusb2pr;
2306 ++
2307 ++ xhci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
2308 ++ PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI,
2309 ++ NULL);
2310 ++
2311 ++ if (!xhci_pdev)
2312 ++ return;
2313 ++
2314 ++ pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
2315 ++ &orig_ports_available);
2316 ++
2317 ++ pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
2318 ++ cpu_to_le32(ports_available));
2319 ++
2320 ++ pr_info("set USB_INTEL_XUSB2PR old: 0x%04x, new: 0x%04x\n",
2321 ++ orig_ports_available, ports_available);
2322 ++}
2323 ++
2324 ++/*
2325 ++ * Some devices dont support or have borcken get_als method
2326 ++ * but still support set method.
2327 ++ */
2328 ++static void asus_wmi_set_als(void)
2329 ++{
2330 ++ asus_wmi_set_devstate(ASUS_WMI_DEVID_ALS_ENABLE, 1, NULL);
2331 ++}
2332 ++
2333 + /*
2334 + * Hwmon device
2335 + */
2336 +@@ -1733,6 +1769,7 @@ ASUS_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, ASUS_WMI_DEVID_TOUCHPAD);
2337 + ASUS_WMI_CREATE_DEVICE_ATTR(camera, 0644, ASUS_WMI_DEVID_CAMERA);
2338 + ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER);
2339 + ASUS_WMI_CREATE_DEVICE_ATTR(lid_resume, 0644, ASUS_WMI_DEVID_LID_RESUME);
2340 ++ASUS_WMI_CREATE_DEVICE_ATTR(als_enable, 0644, ASUS_WMI_DEVID_ALS_ENABLE);
2341 +
2342 + static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr,
2343 + const char *buf, size_t count)
2344 +@@ -1759,6 +1796,7 @@ static struct attribute *platform_attributes[] = {
2345 + &dev_attr_cardr.attr,
2346 + &dev_attr_touchpad.attr,
2347 + &dev_attr_lid_resume.attr,
2348 ++ &dev_attr_als_enable.attr,
2349 + NULL
2350 + };
2351 +
2352 +@@ -1779,6 +1817,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
2353 + devid = ASUS_WMI_DEVID_TOUCHPAD;
2354 + else if (attr == &dev_attr_lid_resume.attr)
2355 + devid = ASUS_WMI_DEVID_LID_RESUME;
2356 ++ else if (attr == &dev_attr_als_enable.attr)
2357 ++ devid = ASUS_WMI_DEVID_ALS_ENABLE;
2358 +
2359 + if (devid != -1)
2360 + ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
2361 +@@ -2067,9 +2107,14 @@ static int asus_wmi_add(struct platform_device *pdev)
2362 + if (err)
2363 + goto fail_leds;
2364 +
2365 +- err = asus_wmi_rfkill_init(asus);
2366 +- if (err)
2367 +- goto fail_rfkill;
2368 ++ if (!asus->driver->quirks->no_rfkill) {
2369 ++ err = asus_wmi_rfkill_init(asus);
2370 ++ if (err)
2371 ++ goto fail_rfkill;
2372 ++ }
2373 ++
2374 ++ if (asus->driver->quirks->wmi_force_als_set)
2375 ++ asus_wmi_set_als();
2376 +
2377 + /* Some Asus desktop boards export an acpi-video backlight interface,
2378 + stop this from showing up */
2379 +@@ -2080,11 +2125,17 @@ static int asus_wmi_add(struct platform_device *pdev)
2380 + if (asus->driver->quirks->wmi_backlight_power)
2381 + acpi_video_set_dmi_backlight_type(acpi_backlight_vendor);
2382 +
2383 ++ if (asus->driver->quirks->wmi_backlight_native)
2384 ++ acpi_video_set_dmi_backlight_type(acpi_backlight_native);
2385 ++
2386 ++ if (asus->driver->quirks->xusb2pr)
2387 ++ asus_wmi_set_xusb2pr(asus);
2388 ++
2389 + if (acpi_video_get_backlight_type() == acpi_backlight_vendor) {
2390 + err = asus_wmi_backlight_init(asus);
2391 + if (err && err != -ENODEV)
2392 + goto fail_backlight;
2393 +- } else
2394 ++ } else if (asus->driver->quirks->wmi_backlight_set_devstate)
2395 + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT, 2, NULL);
2396 +
2397 + status = wmi_install_notify_handler(asus->driver->event_guid,
2398 +diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
2399 +index 4da4c8bafe70..53bab79780e2 100644
2400 +--- a/drivers/platform/x86/asus-wmi.h
2401 ++++ b/drivers/platform/x86/asus-wmi.h
2402 +@@ -28,6 +28,7 @@
2403 + #define _ASUS_WMI_H_
2404 +
2405 + #include <linux/platform_device.h>
2406 ++#include <linux/i8042.h>
2407 +
2408 + #define ASUS_WMI_KEY_IGNORE (-1)
2409 + #define ASUS_WMI_BRN_DOWN 0x20
2410 +@@ -38,10 +39,14 @@ struct key_entry;
2411 + struct asus_wmi;
2412 +
2413 + struct quirk_entry {
2414 ++ bool no_rfkill;
2415 + bool hotplug_wireless;
2416 + bool scalar_panel_brightness;
2417 + bool store_backlight_power;
2418 + bool wmi_backlight_power;
2419 ++ bool wmi_backlight_native;
2420 ++ bool wmi_backlight_set_devstate;
2421 ++ bool wmi_force_als_set;
2422 + int wapf;
2423 + /*
2424 + * For machines with AMD graphic chips, it will send out WMI event
2425 +@@ -50,6 +55,10 @@ struct quirk_entry {
2426 + * and let the ACPI interrupt to send out the key event.
2427 + */
2428 + int no_display_toggle;
2429 ++ u32 xusb2pr;
2430 ++
2431 ++ bool (*i8042_filter)(unsigned char data, unsigned char str,
2432 ++ struct serio *serio);
2433 + };
2434 +
2435 + struct asus_wmi_driver {
2436 +diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
2437 +index 00662dd28d66..9a931efd50d3 100644
2438 +--- a/drivers/rtc/rtc-s35390a.c
2439 ++++ b/drivers/rtc/rtc-s35390a.c
2440 +@@ -106,7 +106,7 @@ static int s35390a_get_reg(struct s35390a *s35390a, int reg, char *buf, int len)
2441 + */
2442 + static int s35390a_reset(struct s35390a *s35390a, char *status1)
2443 + {
2444 +- char buf;
2445 ++ u8 buf;
2446 + int ret;
2447 + unsigned initcount = 0;
2448 +
2449 +diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
2450 +index 5ee7f44cf869..830b2d2dcf20 100644
2451 +--- a/drivers/scsi/dc395x.c
2452 ++++ b/drivers/scsi/dc395x.c
2453 +@@ -1972,6 +1972,11 @@ static void sg_update_list(struct ScsiReqBlk *srb, u32 left)
2454 + xferred -= psge->length;
2455 + } else {
2456 + /* Partial SG entry done */
2457 ++ pci_dma_sync_single_for_cpu(srb->dcb->
2458 ++ acb->dev,
2459 ++ srb->sg_bus_addr,
2460 ++ SEGMENTX_LEN,
2461 ++ PCI_DMA_TODEVICE);
2462 + psge->length -= xferred;
2463 + psge->address += xferred;
2464 + srb->sg_index = idx;
2465 +@@ -3450,14 +3455,12 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
2466 + }
2467 + }
2468 +
2469 +- if (dir != PCI_DMA_NONE && scsi_sg_count(cmd))
2470 +- pci_dma_sync_sg_for_cpu(acb->dev, scsi_sglist(cmd),
2471 +- scsi_sg_count(cmd), dir);
2472 +-
2473 + ckc_only = 0;
2474 + /* Check Error Conditions */
2475 + ckc_e:
2476 +
2477 ++ pci_unmap_srb(acb, srb);
2478 ++
2479 + if (cmd->cmnd[0] == INQUIRY) {
2480 + unsigned char *base = NULL;
2481 + struct ScsiInqData *ptr;
2482 +@@ -3511,7 +3514,6 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
2483 + cmd, cmd->result);
2484 + srb_free_insert(acb, srb);
2485 + }
2486 +- pci_unmap_srb(acb, srb);
2487 +
2488 + cmd->scsi_done(cmd);
2489 + waiting_process_next(acb);
2490 +diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
2491 +index 02cb76fd4420..6bbf2945a3e0 100644
2492 +--- a/drivers/scsi/ips.c
2493 ++++ b/drivers/scsi/ips.c
2494 +@@ -3500,6 +3500,7 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb)
2495 +
2496 + case START_STOP:
2497 + scb->scsi_cmd->result = DID_OK << 16;
2498 ++ break;
2499 +
2500 + case TEST_UNIT_READY:
2501 + case INQUIRY:
2502 +diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
2503 +index 609dafd661d1..da4583a2fa23 100644
2504 +--- a/drivers/scsi/isci/host.c
2505 ++++ b/drivers/scsi/isci/host.c
2506 +@@ -2717,9 +2717,9 @@ enum sci_status sci_controller_continue_io(struct isci_request *ireq)
2507 + * the task management request.
2508 + * @task_request: the handle to the task request object to start.
2509 + */
2510 +-enum sci_task_status sci_controller_start_task(struct isci_host *ihost,
2511 +- struct isci_remote_device *idev,
2512 +- struct isci_request *ireq)
2513 ++enum sci_status sci_controller_start_task(struct isci_host *ihost,
2514 ++ struct isci_remote_device *idev,
2515 ++ struct isci_request *ireq)
2516 + {
2517 + enum sci_status status;
2518 +
2519 +@@ -2728,7 +2728,7 @@ enum sci_task_status sci_controller_start_task(struct isci_host *ihost,
2520 + "%s: SCIC Controller starting task from invalid "
2521 + "state\n",
2522 + __func__);
2523 +- return SCI_TASK_FAILURE_INVALID_STATE;
2524 ++ return SCI_FAILURE_INVALID_STATE;
2525 + }
2526 +
2527 + status = sci_remote_device_start_task(ihost, idev, ireq);
2528 +diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h
2529 +index 22a9bb1abae1..15dc6e0d8deb 100644
2530 +--- a/drivers/scsi/isci/host.h
2531 ++++ b/drivers/scsi/isci/host.h
2532 +@@ -490,7 +490,7 @@ enum sci_status sci_controller_start_io(
2533 + struct isci_remote_device *idev,
2534 + struct isci_request *ireq);
2535 +
2536 +-enum sci_task_status sci_controller_start_task(
2537 ++enum sci_status sci_controller_start_task(
2538 + struct isci_host *ihost,
2539 + struct isci_remote_device *idev,
2540 + struct isci_request *ireq);
2541 +diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
2542 +index cfd0084f1cd2..224c9c60834c 100644
2543 +--- a/drivers/scsi/isci/request.c
2544 ++++ b/drivers/scsi/isci/request.c
2545 +@@ -1626,9 +1626,9 @@ static enum sci_status atapi_d2h_reg_frame_handler(struct isci_request *ireq,
2546 +
2547 + if (status == SCI_SUCCESS) {
2548 + if (ireq->stp.rsp.status & ATA_ERR)
2549 +- status = SCI_IO_FAILURE_RESPONSE_VALID;
2550 ++ status = SCI_FAILURE_IO_RESPONSE_VALID;
2551 + } else {
2552 +- status = SCI_IO_FAILURE_RESPONSE_VALID;
2553 ++ status = SCI_FAILURE_IO_RESPONSE_VALID;
2554 + }
2555 +
2556 + if (status != SCI_SUCCESS) {
2557 +diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
2558 +index 6dcaed0c1fc8..fb6eba331ac6 100644
2559 +--- a/drivers/scsi/isci/task.c
2560 ++++ b/drivers/scsi/isci/task.c
2561 +@@ -258,7 +258,7 @@ static int isci_task_execute_tmf(struct isci_host *ihost,
2562 + struct isci_tmf *tmf, unsigned long timeout_ms)
2563 + {
2564 + DECLARE_COMPLETION_ONSTACK(completion);
2565 +- enum sci_task_status status = SCI_TASK_FAILURE;
2566 ++ enum sci_status status = SCI_FAILURE;
2567 + struct isci_request *ireq;
2568 + int ret = TMF_RESP_FUNC_FAILED;
2569 + unsigned long flags;
2570 +@@ -301,7 +301,7 @@ static int isci_task_execute_tmf(struct isci_host *ihost,
2571 + /* start the TMF io. */
2572 + status = sci_controller_start_task(ihost, idev, ireq);
2573 +
2574 +- if (status != SCI_TASK_SUCCESS) {
2575 ++ if (status != SCI_SUCCESS) {
2576 + dev_dbg(&ihost->pdev->dev,
2577 + "%s: start_io failed - status = 0x%x, request = %p\n",
2578 + __func__,
2579 +diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
2580 +index 0b8af186e707..fccb8991bd5b 100644
2581 +--- a/drivers/scsi/iscsi_tcp.c
2582 ++++ b/drivers/scsi/iscsi_tcp.c
2583 +@@ -788,7 +788,8 @@ static int iscsi_sw_tcp_host_get_param(struct Scsi_Host *shost,
2584 + return rc;
2585 +
2586 + return iscsi_conn_get_addr_param((struct sockaddr_storage *)
2587 +- &addr, param, buf);
2588 ++ &addr,
2589 ++ (enum iscsi_param)param, buf);
2590 + default:
2591 + return iscsi_host_get_param(shost, param, buf);
2592 + }
2593 +diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
2594 +index 82a690924f5e..7ca8c2522c92 100644
2595 +--- a/drivers/scsi/lpfc/lpfc_els.c
2596 ++++ b/drivers/scsi/lpfc/lpfc_els.c
2597 +@@ -1124,6 +1124,7 @@ stop_rr_fcf_flogi:
2598 + phba->fcf.fcf_flag &= ~FCF_DISCOVERY;
2599 + phba->hba_flag &= ~(FCF_RR_INPROG | HBA_DEVLOSS_TMO);
2600 + spin_unlock_irq(&phba->hbalock);
2601 ++ phba->fcf.fcf_redisc_attempted = 0; /* reset */
2602 + goto out;
2603 + }
2604 + if (!rc) {
2605 +@@ -1138,6 +1139,7 @@ stop_rr_fcf_flogi:
2606 + phba->fcf.fcf_flag &= ~FCF_DISCOVERY;
2607 + phba->hba_flag &= ~(FCF_RR_INPROG | HBA_DEVLOSS_TMO);
2608 + spin_unlock_irq(&phba->hbalock);
2609 ++ phba->fcf.fcf_redisc_attempted = 0; /* reset */
2610 + goto out;
2611 + }
2612 + }
2613 +diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
2614 +index a67950908db1..d50db2004d21 100644
2615 +--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
2616 ++++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
2617 +@@ -1966,6 +1966,26 @@ int lpfc_sli4_fcf_rr_next_proc(struct lpfc_vport *vport, uint16_t fcf_index)
2618 + "failover and change port state:x%x/x%x\n",
2619 + phba->pport->port_state, LPFC_VPORT_UNKNOWN);
2620 + phba->pport->port_state = LPFC_VPORT_UNKNOWN;
2621 ++
2622 ++ if (!phba->fcf.fcf_redisc_attempted) {
2623 ++ lpfc_unregister_fcf(phba);
2624 ++
2625 ++ rc = lpfc_sli4_redisc_fcf_table(phba);
2626 ++ if (!rc) {
2627 ++ lpfc_printf_log(phba, KERN_INFO, LOG_FIP,
2628 ++ "3195 Rediscover FCF table\n");
2629 ++ phba->fcf.fcf_redisc_attempted = 1;
2630 ++ lpfc_sli4_clear_fcf_rr_bmask(phba);
2631 ++ } else {
2632 ++ lpfc_printf_log(phba, KERN_WARNING, LOG_FIP,
2633 ++ "3196 Rediscover FCF table "
2634 ++ "failed. Status:x%x\n", rc);
2635 ++ }
2636 ++ } else {
2637 ++ lpfc_printf_log(phba, KERN_WARNING, LOG_FIP,
2638 ++ "3197 Already rediscover FCF table "
2639 ++ "attempted. No more retry\n");
2640 ++ }
2641 + goto stop_flogi_current_fcf;
2642 + } else {
2643 + lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_ELS,
2644 +diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
2645 +index 60c21093f865..7e06fd6127cc 100644
2646 +--- a/drivers/scsi/lpfc/lpfc_init.c
2647 ++++ b/drivers/scsi/lpfc/lpfc_init.c
2648 +@@ -4376,7 +4376,7 @@ lpfc_sli4_async_fip_evt(struct lpfc_hba *phba,
2649 + break;
2650 + }
2651 + /* If fast FCF failover rescan event is pending, do nothing */
2652 +- if (phba->fcf.fcf_flag & FCF_REDISC_EVT) {
2653 ++ if (phba->fcf.fcf_flag & (FCF_REDISC_EVT | FCF_REDISC_PEND)) {
2654 + spin_unlock_irq(&phba->hbalock);
2655 + break;
2656 + }
2657 +diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
2658 +index ad4f16ab7f7a..523a1058078a 100644
2659 +--- a/drivers/scsi/lpfc/lpfc_sli.c
2660 ++++ b/drivers/scsi/lpfc/lpfc_sli.c
2661 +@@ -16350,15 +16350,8 @@ next_priority:
2662 + goto initial_priority;
2663 + lpfc_printf_log(phba, KERN_WARNING, LOG_FIP,
2664 + "2844 No roundrobin failover FCF available\n");
2665 +- if (next_fcf_index >= LPFC_SLI4_FCF_TBL_INDX_MAX)
2666 +- return LPFC_FCOE_FCF_NEXT_NONE;
2667 +- else {
2668 +- lpfc_printf_log(phba, KERN_WARNING, LOG_FIP,
2669 +- "3063 Only FCF available idx %d, flag %x\n",
2670 +- next_fcf_index,
2671 +- phba->fcf.fcf_pri[next_fcf_index].fcf_rec.flag);
2672 +- return next_fcf_index;
2673 +- }
2674 ++
2675 ++ return LPFC_FCOE_FCF_NEXT_NONE;
2676 + }
2677 +
2678 + if (next_fcf_index < LPFC_SLI4_FCF_TBL_INDX_MAX &&
2679 +diff --git a/drivers/scsi/lpfc/lpfc_sli4.h b/drivers/scsi/lpfc/lpfc_sli4.h
2680 +index 1e916e16ce98..0ecf92c8a288 100644
2681 +--- a/drivers/scsi/lpfc/lpfc_sli4.h
2682 ++++ b/drivers/scsi/lpfc/lpfc_sli4.h
2683 +@@ -237,6 +237,7 @@ struct lpfc_fcf {
2684 + #define FCF_REDISC_EVT 0x100 /* FCF rediscovery event to worker thread */
2685 + #define FCF_REDISC_FOV 0x200 /* Post FCF rediscovery fast failover */
2686 + #define FCF_REDISC_PROG (FCF_REDISC_PEND | FCF_REDISC_EVT)
2687 ++ uint16_t fcf_redisc_attempted;
2688 + uint32_t addr_mode;
2689 + uint32_t eligible_fcf_cnt;
2690 + struct lpfc_fcf_rec current_rec;
2691 +diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
2692 +index 5e0bac8de638..7be968f60b59 100644
2693 +--- a/drivers/scsi/megaraid/megaraid_sas_base.c
2694 ++++ b/drivers/scsi/megaraid/megaraid_sas_base.c
2695 +@@ -3585,12 +3585,12 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
2696 + /*
2697 + * The cur_state should not last for more than max_wait secs
2698 + */
2699 +- for (i = 0; i < (max_wait * 1000); i++) {
2700 ++ for (i = 0; i < max_wait; i++) {
2701 + curr_abs_state = instance->instancet->
2702 + read_fw_status_reg(instance->reg_set);
2703 +
2704 + if (abs_state == curr_abs_state) {
2705 +- msleep(1);
2706 ++ msleep(1000);
2707 + } else
2708 + break;
2709 + }
2710 +diff --git a/drivers/scsi/mpt3sas/mpt3sas_config.c b/drivers/scsi/mpt3sas/mpt3sas_config.c
2711 +index a6914ec99cc0..56dc0e3be2ba 100644
2712 +--- a/drivers/scsi/mpt3sas/mpt3sas_config.c
2713 ++++ b/drivers/scsi/mpt3sas/mpt3sas_config.c
2714 +@@ -677,10 +677,6 @@ mpt3sas_config_set_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc,
2715 + r = _config_request(ioc, &mpi_request, mpi_reply,
2716 + MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
2717 + sizeof(*config_page));
2718 +- mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM;
2719 +- r = _config_request(ioc, &mpi_request, mpi_reply,
2720 +- MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page,
2721 +- sizeof(*config_page));
2722 + out:
2723 + return r;
2724 + }
2725 +diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
2726 +index 7d67a68bcc62..8735e4257028 100644
2727 +--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
2728 ++++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
2729 +@@ -3254,6 +3254,40 @@ _scsih_tm_tr_complete(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
2730 + return _scsih_check_for_pending_tm(ioc, smid);
2731 + }
2732 +
2733 ++/** _scsih_allow_scmd_to_device - check whether scmd needs to
2734 ++ * issue to IOC or not.
2735 ++ * @ioc: per adapter object
2736 ++ * @scmd: pointer to scsi command object
2737 ++ *
2738 ++ * Returns true if scmd can be issued to IOC otherwise returns false.
2739 ++ */
2740 ++inline bool _scsih_allow_scmd_to_device(struct MPT3SAS_ADAPTER *ioc,
2741 ++ struct scsi_cmnd *scmd)
2742 ++{
2743 ++
2744 ++ if (ioc->pci_error_recovery)
2745 ++ return false;
2746 ++
2747 ++ if (ioc->hba_mpi_version_belonged == MPI2_VERSION) {
2748 ++ if (ioc->remove_host)
2749 ++ return false;
2750 ++
2751 ++ return true;
2752 ++ }
2753 ++
2754 ++ if (ioc->remove_host) {
2755 ++
2756 ++ switch (scmd->cmnd[0]) {
2757 ++ case SYNCHRONIZE_CACHE:
2758 ++ case START_STOP:
2759 ++ return true;
2760 ++ default:
2761 ++ return false;
2762 ++ }
2763 ++ }
2764 ++
2765 ++ return true;
2766 ++}
2767 +
2768 + /**
2769 + * _scsih_sas_control_complete - completion routine
2770 +@@ -3880,7 +3914,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
2771 + return 0;
2772 + }
2773 +
2774 +- if (ioc->pci_error_recovery || ioc->remove_host) {
2775 ++ if (!(_scsih_allow_scmd_to_device(ioc, scmd))) {
2776 + scmd->result = DID_NO_CONNECT << 16;
2777 + scmd->scsi_done(scmd);
2778 + return 0;
2779 +diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
2780 +index 83b53cd956aa..79fa237f76c4 100644
2781 +--- a/drivers/spi/spi-omap2-mcspi.c
2782 ++++ b/drivers/spi/spi-omap2-mcspi.c
2783 +@@ -301,7 +301,7 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
2784 + struct omap2_mcspi_cs *cs = spi->controller_state;
2785 + struct omap2_mcspi *mcspi;
2786 + unsigned int wcnt;
2787 +- int max_fifo_depth, fifo_depth, bytes_per_word;
2788 ++ int max_fifo_depth, bytes_per_word;
2789 + u32 chconf, xferlevel;
2790 +
2791 + mcspi = spi_master_get_devdata(master);
2792 +@@ -317,10 +317,6 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
2793 + else
2794 + max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH;
2795 +
2796 +- fifo_depth = gcd(t->len, max_fifo_depth);
2797 +- if (fifo_depth < 2 || fifo_depth % bytes_per_word != 0)
2798 +- goto disable_fifo;
2799 +-
2800 + wcnt = t->len / bytes_per_word;
2801 + if (wcnt > OMAP2_MCSPI_MAX_FIFOWCNT)
2802 + goto disable_fifo;
2803 +@@ -328,16 +324,17 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
2804 + xferlevel = wcnt << 16;
2805 + if (t->rx_buf != NULL) {
2806 + chconf |= OMAP2_MCSPI_CHCONF_FFER;
2807 +- xferlevel |= (fifo_depth - 1) << 8;
2808 ++ xferlevel |= (bytes_per_word - 1) << 8;
2809 + }
2810 ++
2811 + if (t->tx_buf != NULL) {
2812 + chconf |= OMAP2_MCSPI_CHCONF_FFET;
2813 +- xferlevel |= fifo_depth - 1;
2814 ++ xferlevel |= bytes_per_word - 1;
2815 + }
2816 +
2817 + mcspi_write_reg(master, OMAP2_MCSPI_XFERLEVEL, xferlevel);
2818 + mcspi_write_chconf0(spi, chconf);
2819 +- mcspi->fifo_depth = fifo_depth;
2820 ++ mcspi->fifo_depth = max_fifo_depth;
2821 +
2822 + return;
2823 + }
2824 +@@ -569,7 +566,6 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
2825 + struct dma_slave_config cfg;
2826 + enum dma_slave_buswidth width;
2827 + unsigned es;
2828 +- u32 burst;
2829 + void __iomem *chstat_reg;
2830 + void __iomem *irqstat_reg;
2831 + int wait_res;
2832 +@@ -591,22 +587,14 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
2833 + }
2834 +
2835 + count = xfer->len;
2836 +- burst = 1;
2837 +-
2838 +- if (mcspi->fifo_depth > 0) {
2839 +- if (count > mcspi->fifo_depth)
2840 +- burst = mcspi->fifo_depth / es;
2841 +- else
2842 +- burst = count / es;
2843 +- }
2844 +
2845 + memset(&cfg, 0, sizeof(cfg));
2846 + cfg.src_addr = cs->phys + OMAP2_MCSPI_RX0;
2847 + cfg.dst_addr = cs->phys + OMAP2_MCSPI_TX0;
2848 + cfg.src_addr_width = width;
2849 + cfg.dst_addr_width = width;
2850 +- cfg.src_maxburst = burst;
2851 +- cfg.dst_maxburst = burst;
2852 ++ cfg.src_maxburst = 1;
2853 ++ cfg.dst_maxburst = 1;
2854 +
2855 + rx = xfer->rx_buf;
2856 + tx = xfer->tx_buf;
2857 +diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
2858 +index 03b566848da6..b4f136d04a2b 100644
2859 +--- a/drivers/spi/spi-sh-msiof.c
2860 ++++ b/drivers/spi/spi-sh-msiof.c
2861 +@@ -1198,8 +1198,8 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
2862 +
2863 + i = platform_get_irq(pdev, 0);
2864 + if (i < 0) {
2865 +- dev_err(&pdev->dev, "cannot get platform IRQ\n");
2866 +- ret = -ENOENT;
2867 ++ dev_err(&pdev->dev, "cannot get IRQ\n");
2868 ++ ret = i;
2869 + goto err1;
2870 + }
2871 +
2872 +diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c
2873 +index 10f94ec34536..cab8a4027aeb 100644
2874 +--- a/drivers/staging/comedi/drivers/usbduxfast.c
2875 ++++ b/drivers/staging/comedi/drivers/usbduxfast.c
2876 +@@ -1,5 +1,5 @@
2877 + /*
2878 +- * Copyright (C) 2004-2014 Bernd Porr, mail@××××××××××××.uk
2879 ++ * Copyright (C) 2004-2019 Bernd Porr, mail@××××××××××××.uk
2880 + *
2881 + * This program is free software; you can redistribute it and/or modify
2882 + * it under the terms of the GNU General Public License as published by
2883 +@@ -17,7 +17,7 @@
2884 + * Description: University of Stirling USB DAQ & INCITE Technology Limited
2885 + * Devices: [ITL] USB-DUX-FAST (usbduxfast)
2886 + * Author: Bernd Porr <mail@××××××××××××.uk>
2887 +- * Updated: 10 Oct 2014
2888 ++ * Updated: 16 Nov 2019
2889 + * Status: stable
2890 + */
2891 +
2892 +@@ -31,6 +31,7 @@
2893 + *
2894 + *
2895 + * Revision history:
2896 ++ * 1.0: Fixed a rounding error in usbduxfast_ai_cmdtest
2897 + * 0.9: Dropping the first data packet which seems to be from the last transfer.
2898 + * Buffer overflows in the FX2 are handed over to comedi.
2899 + * 0.92: Dropping now 4 packets. The quad buffer has to be emptied.
2900 +@@ -359,6 +360,7 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
2901 + struct comedi_cmd *cmd)
2902 + {
2903 + int err = 0;
2904 ++ int err2 = 0;
2905 + unsigned int steps;
2906 + unsigned int arg;
2907 +
2908 +@@ -408,11 +410,16 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
2909 + */
2910 + steps = (cmd->convert_arg * 30) / 1000;
2911 + if (cmd->chanlist_len != 1)
2912 +- err |= comedi_check_trigger_arg_min(&steps,
2913 +- MIN_SAMPLING_PERIOD);
2914 +- err |= comedi_check_trigger_arg_max(&steps, MAX_SAMPLING_PERIOD);
2915 +- arg = (steps * 1000) / 30;
2916 +- err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
2917 ++ err2 |= comedi_check_trigger_arg_min(&steps,
2918 ++ MIN_SAMPLING_PERIOD);
2919 ++ else
2920 ++ err2 |= comedi_check_trigger_arg_min(&steps, 1);
2921 ++ err2 |= comedi_check_trigger_arg_max(&steps, MAX_SAMPLING_PERIOD);
2922 ++ if (err2) {
2923 ++ err |= err2;
2924 ++ arg = (steps * 1000) / 30;
2925 ++ err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
2926 ++ }
2927 +
2928 + if (cmd->stop_src == TRIG_COUNT)
2929 + err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
2930 +diff --git a/drivers/staging/rdma/hfi1/pcie.c b/drivers/staging/rdma/hfi1/pcie.c
2931 +index a956044459a2..ea4df848d840 100644
2932 +--- a/drivers/staging/rdma/hfi1/pcie.c
2933 ++++ b/drivers/staging/rdma/hfi1/pcie.c
2934 +@@ -389,7 +389,8 @@ int pcie_speeds(struct hfi1_devdata *dd)
2935 + /*
2936 + * bus->max_bus_speed is set from the bridge's linkcap Max Link Speed
2937 + */
2938 +- if (dd->pcidev->bus->max_bus_speed != PCIE_SPEED_8_0GT) {
2939 ++ if (dd->pcidev->bus->max_bus_speed == PCIE_SPEED_2_5GT ||
2940 ++ dd->pcidev->bus->max_bus_speed == PCIE_SPEED_5_0GT) {
2941 + dd_dev_info(dd, "Parent PCIe bridge does not support Gen3\n");
2942 + dd->link_gen3_capable = 0;
2943 + }
2944 +diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
2945 +index 13d01edc7a04..487c5cd7516c 100644
2946 +--- a/drivers/thermal/rcar_thermal.c
2947 ++++ b/drivers/thermal/rcar_thermal.c
2948 +@@ -350,8 +350,8 @@ static irqreturn_t rcar_thermal_irq(int irq, void *data)
2949 + rcar_thermal_for_each_priv(priv, common) {
2950 + if (rcar_thermal_had_changed(priv, status)) {
2951 + rcar_thermal_irq_disable(priv);
2952 +- schedule_delayed_work(&priv->work,
2953 +- msecs_to_jiffies(300));
2954 ++ queue_delayed_work(system_freezable_wq, &priv->work,
2955 ++ msecs_to_jiffies(300));
2956 + }
2957 + }
2958 +
2959 +diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
2960 +index 6fc39fbfc275..b5145e8bdf0a 100644
2961 +--- a/drivers/tty/synclink_gt.c
2962 ++++ b/drivers/tty/synclink_gt.c
2963 +@@ -1192,14 +1192,13 @@ static long slgt_compat_ioctl(struct tty_struct *tty,
2964 + unsigned int cmd, unsigned long arg)
2965 + {
2966 + struct slgt_info *info = tty->driver_data;
2967 +- int rc = -ENOIOCTLCMD;
2968 ++ int rc;
2969 +
2970 + if (sanity_check(info, tty->name, "compat_ioctl"))
2971 + return -ENODEV;
2972 + DBGINFO(("%s compat_ioctl() cmd=%08X\n", info->device_name, cmd));
2973 +
2974 + switch (cmd) {
2975 +-
2976 + case MGSL_IOCSPARAMS32:
2977 + rc = set_params32(info, compat_ptr(arg));
2978 + break;
2979 +@@ -1219,18 +1218,11 @@ static long slgt_compat_ioctl(struct tty_struct *tty,
2980 + case MGSL_IOCWAITGPIO:
2981 + case MGSL_IOCGXSYNC:
2982 + case MGSL_IOCGXCTRL:
2983 +- case MGSL_IOCSTXIDLE:
2984 +- case MGSL_IOCTXENABLE:
2985 +- case MGSL_IOCRXENABLE:
2986 +- case MGSL_IOCTXABORT:
2987 +- case TIOCMIWAIT:
2988 +- case MGSL_IOCSIF:
2989 +- case MGSL_IOCSXSYNC:
2990 +- case MGSL_IOCSXCTRL:
2991 +- rc = ioctl(tty, cmd, arg);
2992 ++ rc = ioctl(tty, cmd, (unsigned long)compat_ptr(arg));
2993 + break;
2994 ++ default:
2995 ++ rc = ioctl(tty, cmd, arg);
2996 + }
2997 +-
2998 + DBGINFO(("%s compat_ioctl() cmd=%08X rc=%d\n", info->device_name, cmd, rc));
2999 + return rc;
3000 + }
3001 +diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
3002 +index 993f4da065c3..8b7d43c282f8 100644
3003 +--- a/drivers/usb/misc/appledisplay.c
3004 ++++ b/drivers/usb/misc/appledisplay.c
3005 +@@ -161,8 +161,11 @@ static int appledisplay_bl_update_status(struct backlight_device *bd)
3006 + pdata->msgdata, 2,
3007 + ACD_USB_TIMEOUT);
3008 + mutex_unlock(&pdata->sysfslock);
3009 +-
3010 +- return retval;
3011 ++
3012 ++ if (retval < 0)
3013 ++ return retval;
3014 ++ else
3015 ++ return 0;
3016 + }
3017 +
3018 + static int appledisplay_bl_get_brightness(struct backlight_device *bd)
3019 +@@ -180,7 +183,12 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd)
3020 + 0,
3021 + pdata->msgdata, 2,
3022 + ACD_USB_TIMEOUT);
3023 +- brightness = pdata->msgdata[1];
3024 ++ if (retval < 2) {
3025 ++ if (retval >= 0)
3026 ++ retval = -EMSGSIZE;
3027 ++ } else {
3028 ++ brightness = pdata->msgdata[1];
3029 ++ }
3030 + mutex_unlock(&pdata->sysfslock);
3031 +
3032 + if (retval < 0)
3033 +@@ -326,6 +334,7 @@ error:
3034 + if (pdata) {
3035 + if (pdata->urb) {
3036 + usb_kill_urb(pdata->urb);
3037 ++ cancel_delayed_work_sync(&pdata->work);
3038 + if (pdata->urbdata)
3039 + usb_free_coherent(pdata->udev, ACD_URB_BUFFER_LEN,
3040 + pdata->urbdata, pdata->urb->transfer_dma);
3041 +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
3042 +index e3ea0fdd3913..205f31200264 100644
3043 +--- a/drivers/usb/serial/cp210x.c
3044 ++++ b/drivers/usb/serial/cp210x.c
3045 +@@ -121,6 +121,7 @@ static const struct usb_device_id id_table[] = {
3046 + { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
3047 + { USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */
3048 + { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */
3049 ++ { USB_DEVICE(0x10C4, 0x83AA) }, /* Mark-10 Digital Force Gauge */
3050 + { USB_DEVICE(0x10C4, 0x83D8) }, /* DekTec DTA Plus VHF/UHF Booster/Attenuator */
3051 + { USB_DEVICE(0x10C4, 0x8411) }, /* Kyocera GPS Module */
3052 + { USB_DEVICE(0x10C4, 0x8418) }, /* IRZ Automation Teleport SG-10 GSM/GPRS Modem */
3053 +diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
3054 +index 286b43c79d38..1927f41ccafc 100644
3055 +--- a/drivers/usb/serial/mos7720.c
3056 ++++ b/drivers/usb/serial/mos7720.c
3057 +@@ -1941,10 +1941,6 @@ static int mos7720_startup(struct usb_serial *serial)
3058 + }
3059 + }
3060 +
3061 +- /* setting configuration feature to one */
3062 +- usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
3063 +- (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000);
3064 +-
3065 + #ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
3066 + if (product == MOSCHIP_DEVICE_ID_7715) {
3067 + ret_val = mos7715_parport_init(serial);
3068 +diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
3069 +index 58ba6904a087..4add6bc38d64 100644
3070 +--- a/drivers/usb/serial/mos7840.c
3071 ++++ b/drivers/usb/serial/mos7840.c
3072 +@@ -131,11 +131,15 @@
3073 + /* This driver also supports
3074 + * ATEN UC2324 device using Moschip MCS7840
3075 + * ATEN UC2322 device using Moschip MCS7820
3076 ++ * MOXA UPort 2210 device using Moschip MCS7820
3077 + */
3078 + #define USB_VENDOR_ID_ATENINTL 0x0557
3079 + #define ATENINTL_DEVICE_ID_UC2324 0x2011
3080 + #define ATENINTL_DEVICE_ID_UC2322 0x7820
3081 +
3082 ++#define USB_VENDOR_ID_MOXA 0x110a
3083 ++#define MOXA_DEVICE_ID_2210 0x2210
3084 ++
3085 + /* Interrupt Routine Defines */
3086 +
3087 + #define SERIAL_IIR_RLS 0x06
3088 +@@ -206,6 +210,7 @@ static const struct usb_device_id id_table[] = {
3089 + {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL2_4)},
3090 + {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)},
3091 + {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)},
3092 ++ {USB_DEVICE(USB_VENDOR_ID_MOXA, MOXA_DEVICE_ID_2210)},
3093 + {} /* terminating entry */
3094 + };
3095 + MODULE_DEVICE_TABLE(usb, id_table);
3096 +@@ -2089,6 +2094,7 @@ static int mos7840_probe(struct usb_serial *serial,
3097 + const struct usb_device_id *id)
3098 + {
3099 + u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
3100 ++ u16 vid = le16_to_cpu(serial->dev->descriptor.idVendor);
3101 + u8 *buf;
3102 + int device_type;
3103 +
3104 +@@ -2098,6 +2104,11 @@ static int mos7840_probe(struct usb_serial *serial,
3105 + goto out;
3106 + }
3107 +
3108 ++ if (vid == USB_VENDOR_ID_MOXA && product == MOXA_DEVICE_ID_2210) {
3109 ++ device_type = MOSCHIP_DEVICE_ID_7820;
3110 ++ goto out;
3111 ++ }
3112 ++
3113 + buf = kzalloc(VENDOR_READ_LENGTH, GFP_KERNEL);
3114 + if (!buf)
3115 + return -ENOMEM;
3116 +@@ -2350,11 +2361,6 @@ out:
3117 + goto error;
3118 + } else
3119 + dev_dbg(&port->dev, "ZLP_REG5 Writing success status%d\n", status);
3120 +-
3121 +- /* setting configuration feature to one */
3122 +- usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
3123 +- 0x03, 0x00, 0x01, 0x00, NULL, 0x00,
3124 +- MOS_WDR_TIMEOUT);
3125 + }
3126 + return 0;
3127 + error:
3128 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
3129 +index 00a6e62a68a8..084332a5855e 100644
3130 +--- a/drivers/usb/serial/option.c
3131 ++++ b/drivers/usb/serial/option.c
3132 +@@ -200,6 +200,7 @@ static void option_instat_callback(struct urb *urb);
3133 + #define DELL_PRODUCT_5804_MINICARD_ATT 0x819b /* Novatel E371 */
3134 +
3135 + #define DELL_PRODUCT_5821E 0x81d7
3136 ++#define DELL_PRODUCT_5821E_ESIM 0x81e0
3137 +
3138 + #define KYOCERA_VENDOR_ID 0x0c88
3139 + #define KYOCERA_PRODUCT_KPC650 0x17da
3140 +@@ -1043,6 +1044,8 @@ static const struct usb_device_id option_ids[] = {
3141 + { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5804_MINICARD_ATT, 0xff, 0xff, 0xff) },
3142 + { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5821E),
3143 + .driver_info = RSVD(0) | RSVD(1) | RSVD(6) },
3144 ++ { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5821E_ESIM),
3145 ++ .driver_info = RSVD(0) | RSVD(1) | RSVD(6) },
3146 + { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */
3147 + { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) },
3148 + { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) },
3149 +@@ -1987,6 +1990,10 @@ static const struct usb_device_id option_ids[] = {
3150 + { USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0xa31d, 0xff, 0x06, 0x13) },
3151 + { USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0xa31d, 0xff, 0x06, 0x14) },
3152 + { USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0xa31d, 0xff, 0x06, 0x1b) },
3153 ++ { USB_DEVICE(0x0489, 0xe0b4), /* Foxconn T77W968 */
3154 ++ .driver_info = RSVD(0) | RSVD(1) | RSVD(6) },
3155 ++ { USB_DEVICE(0x0489, 0xe0b5), /* Foxconn T77W968 ESIM */
3156 ++ .driver_info = RSVD(0) | RSVD(1) | RSVD(6) },
3157 + { USB_DEVICE(0x1508, 0x1001), /* Fibocom NL668 */
3158 + .driver_info = RSVD(4) | RSVD(5) | RSVD(6) },
3159 + { USB_DEVICE(0x2cb7, 0x0104), /* Fibocom NL678 series */
3160 +diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
3161 +index 51a0409e1b84..a980b3309770 100644
3162 +--- a/fs/btrfs/ctree.c
3163 ++++ b/fs/btrfs/ctree.c
3164 +@@ -2966,6 +2966,10 @@ int btrfs_search_old_slot(struct btrfs_root *root, struct btrfs_key *key,
3165 +
3166 + again:
3167 + b = get_old_root(root, time_seq);
3168 ++ if (!b) {
3169 ++ ret = -EIO;
3170 ++ goto done;
3171 ++ }
3172 + level = btrfs_header_level(b);
3173 + p->locks[level] = BTRFS_READ_LOCK;
3174 +
3175 +diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
3176 +index 2ad3f4ab4dcf..0be931cf3c44 100644
3177 +--- a/fs/ceph/inode.c
3178 ++++ b/fs/ceph/inode.c
3179 +@@ -1515,7 +1515,6 @@ retry_lookup:
3180 + if (IS_ERR(realdn)) {
3181 + err = PTR_ERR(realdn);
3182 + d_drop(dn);
3183 +- dn = NULL;
3184 + goto next_item;
3185 + }
3186 + dn = realdn;
3187 +diff --git a/fs/dlm/member.c b/fs/dlm/member.c
3188 +index 9c47f1c14a8b..a47ae99f7bcb 100644
3189 +--- a/fs/dlm/member.c
3190 ++++ b/fs/dlm/member.c
3191 +@@ -683,7 +683,7 @@ int dlm_ls_start(struct dlm_ls *ls)
3192 +
3193 + error = dlm_config_nodes(ls->ls_name, &nodes, &count);
3194 + if (error < 0)
3195 +- goto fail;
3196 ++ goto fail_rv;
3197 +
3198 + spin_lock(&ls->ls_recover_lock);
3199 +
3200 +@@ -715,8 +715,9 @@ int dlm_ls_start(struct dlm_ls *ls)
3201 + return 0;
3202 +
3203 + fail:
3204 +- kfree(rv);
3205 + kfree(nodes);
3206 ++ fail_rv:
3207 ++ kfree(rv);
3208 + return error;
3209 + }
3210 +
3211 +diff --git a/fs/dlm/user.c b/fs/dlm/user.c
3212 +index e40c440a4555..dd2b7416e40a 100644
3213 +--- a/fs/dlm/user.c
3214 ++++ b/fs/dlm/user.c
3215 +@@ -705,7 +705,7 @@ static int copy_result_to_user(struct dlm_user_args *ua, int compat,
3216 + result.version[0] = DLM_DEVICE_VERSION_MAJOR;
3217 + result.version[1] = DLM_DEVICE_VERSION_MINOR;
3218 + result.version[2] = DLM_DEVICE_VERSION_PATCH;
3219 +- memcpy(&result.lksb, &ua->lksb, sizeof(struct dlm_lksb));
3220 ++ memcpy(&result.lksb, &ua->lksb, offsetof(struct dlm_lksb, sb_lvbptr));
3221 + result.user_lksb = ua->user_lksb;
3222 +
3223 + /* FIXME: dlm1 provides for the user's bastparam/addr to not be updated
3224 +diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
3225 +index e632006a52df..2736e9cfc2ee 100644
3226 +--- a/fs/gfs2/rgrp.c
3227 ++++ b/fs/gfs2/rgrp.c
3228 +@@ -645,7 +645,10 @@ static void __rs_deltree(struct gfs2_blkreserv *rs)
3229 + RB_CLEAR_NODE(&rs->rs_node);
3230 +
3231 + if (rs->rs_free) {
3232 +- struct gfs2_bitmap *bi = rbm_bi(&rs->rs_rbm);
3233 ++ u64 last_block = gfs2_rbm_to_block(&rs->rs_rbm) +
3234 ++ rs->rs_free - 1;
3235 ++ struct gfs2_rbm last_rbm = { .rgd = rs->rs_rbm.rgd, };
3236 ++ struct gfs2_bitmap *start, *last;
3237 +
3238 + /* return reserved blocks to the rgrp */
3239 + BUG_ON(rs->rs_rbm.rgd->rd_reserved < rs->rs_free);
3240 +@@ -656,7 +659,13 @@ static void __rs_deltree(struct gfs2_blkreserv *rs)
3241 + it will force the number to be recalculated later. */
3242 + rgd->rd_extfail_pt += rs->rs_free;
3243 + rs->rs_free = 0;
3244 +- clear_bit(GBF_FULL, &bi->bi_flags);
3245 ++ if (gfs2_rbm_from_block(&last_rbm, last_block))
3246 ++ return;
3247 ++ start = rbm_bi(&rs->rs_rbm);
3248 ++ last = rbm_bi(&last_rbm);
3249 ++ do
3250 ++ clear_bit(GBF_FULL, &start->bi_flags);
3251 ++ while (start++ != last);
3252 + }
3253 + }
3254 +
3255 +diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
3256 +index 2e713673df42..85dab71bee74 100644
3257 +--- a/fs/hfs/brec.c
3258 ++++ b/fs/hfs/brec.c
3259 +@@ -444,6 +444,7 @@ skip:
3260 + /* restore search_key */
3261 + hfs_bnode_read_key(node, fd->search_key, 14);
3262 + }
3263 ++ new_node = NULL;
3264 + }
3265 +
3266 + if (!rec && node->parent)
3267 +diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c
3268 +index 1ff5774a5382..9e9b02f5134b 100644
3269 +--- a/fs/hfs/btree.c
3270 ++++ b/fs/hfs/btree.c
3271 +@@ -219,25 +219,17 @@ static struct hfs_bnode *hfs_bmap_new_bmap(struct hfs_bnode *prev, u32 idx)
3272 + return node;
3273 + }
3274 +
3275 +-struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
3276 ++/* Make sure @tree has enough space for the @rsvd_nodes */
3277 ++int hfs_bmap_reserve(struct hfs_btree *tree, int rsvd_nodes)
3278 + {
3279 +- struct hfs_bnode *node, *next_node;
3280 +- struct page **pagep;
3281 +- u32 nidx, idx;
3282 +- unsigned off;
3283 +- u16 off16;
3284 +- u16 len;
3285 +- u8 *data, byte, m;
3286 +- int i;
3287 +-
3288 +- while (!tree->free_nodes) {
3289 +- struct inode *inode = tree->inode;
3290 +- u32 count;
3291 +- int res;
3292 ++ struct inode *inode = tree->inode;
3293 ++ u32 count;
3294 ++ int res;
3295 +
3296 ++ while (tree->free_nodes < rsvd_nodes) {
3297 + res = hfs_extend_file(inode);
3298 + if (res)
3299 +- return ERR_PTR(res);
3300 ++ return res;
3301 + HFS_I(inode)->phys_size = inode->i_size =
3302 + (loff_t)HFS_I(inode)->alloc_blocks *
3303 + HFS_SB(tree->sb)->alloc_blksz;
3304 +@@ -245,9 +237,26 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
3305 + tree->sb->s_blocksize_bits;
3306 + inode_set_bytes(inode, inode->i_size);
3307 + count = inode->i_size >> tree->node_size_shift;
3308 +- tree->free_nodes = count - tree->node_count;
3309 ++ tree->free_nodes += count - tree->node_count;
3310 + tree->node_count = count;
3311 + }
3312 ++ return 0;
3313 ++}
3314 ++
3315 ++struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
3316 ++{
3317 ++ struct hfs_bnode *node, *next_node;
3318 ++ struct page **pagep;
3319 ++ u32 nidx, idx;
3320 ++ unsigned off;
3321 ++ u16 off16;
3322 ++ u16 len;
3323 ++ u8 *data, byte, m;
3324 ++ int i, res;
3325 ++
3326 ++ res = hfs_bmap_reserve(tree, 1);
3327 ++ if (res)
3328 ++ return ERR_PTR(res);
3329 +
3330 + nidx = 0;
3331 + node = hfs_bnode_find(tree, nidx);
3332 +diff --git a/fs/hfs/btree.h b/fs/hfs/btree.h
3333 +index f6bd266d70b5..2715f416b5a8 100644
3334 +--- a/fs/hfs/btree.h
3335 ++++ b/fs/hfs/btree.h
3336 +@@ -81,6 +81,7 @@ struct hfs_find_data {
3337 + extern struct hfs_btree *hfs_btree_open(struct super_block *, u32, btree_keycmp);
3338 + extern void hfs_btree_close(struct hfs_btree *);
3339 + extern void hfs_btree_write(struct hfs_btree *);
3340 ++extern int hfs_bmap_reserve(struct hfs_btree *, int);
3341 + extern struct hfs_bnode * hfs_bmap_alloc(struct hfs_btree *);
3342 + extern void hfs_bmap_free(struct hfs_bnode *node);
3343 +
3344 +diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
3345 +index db458ee3a546..34158c276200 100644
3346 +--- a/fs/hfs/catalog.c
3347 ++++ b/fs/hfs/catalog.c
3348 +@@ -97,6 +97,14 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
3349 + if (err)
3350 + return err;
3351 +
3352 ++ /*
3353 ++ * Fail early and avoid ENOSPC during the btree operations. We may
3354 ++ * have to split the root node at most once.
3355 ++ */
3356 ++ err = hfs_bmap_reserve(fd.tree, 2 * fd.tree->depth);
3357 ++ if (err)
3358 ++ goto err2;
3359 ++
3360 + hfs_cat_build_key(sb, fd.search_key, cnid, NULL);
3361 + entry_size = hfs_cat_build_thread(sb, &entry, S_ISDIR(inode->i_mode) ?
3362 + HFS_CDR_THD : HFS_CDR_FTH,
3363 +@@ -294,6 +302,14 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name,
3364 + return err;
3365 + dst_fd = src_fd;
3366 +
3367 ++ /*
3368 ++ * Fail early and avoid ENOSPC during the btree operations. We may
3369 ++ * have to split the root node at most once.
3370 ++ */
3371 ++ err = hfs_bmap_reserve(src_fd.tree, 2 * src_fd.tree->depth);
3372 ++ if (err)
3373 ++ goto out;
3374 ++
3375 + /* find the old dir entry and read the data */
3376 + hfs_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name);
3377 + err = hfs_brec_find(&src_fd);
3378 +diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
3379 +index e33a0d36a93e..cbe4fca96378 100644
3380 +--- a/fs/hfs/extent.c
3381 ++++ b/fs/hfs/extent.c
3382 +@@ -117,6 +117,10 @@ static int __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
3383 + if (HFS_I(inode)->flags & HFS_FLG_EXT_NEW) {
3384 + if (res != -ENOENT)
3385 + return res;
3386 ++ /* Fail early and avoid ENOSPC during the btree operation */
3387 ++ res = hfs_bmap_reserve(fd->tree, fd->tree->depth + 1);
3388 ++ if (res)
3389 ++ return res;
3390 + hfs_brec_insert(fd, HFS_I(inode)->cached_extents, sizeof(hfs_extent_rec));
3391 + HFS_I(inode)->flags &= ~(HFS_FLG_EXT_DIRTY|HFS_FLG_EXT_NEW);
3392 + } else {
3393 +@@ -300,7 +304,7 @@ int hfs_free_fork(struct super_block *sb, struct hfs_cat_file *file, int type)
3394 + return 0;
3395 +
3396 + blocks = 0;
3397 +- for (i = 0; i < 3; extent++, i++)
3398 ++ for (i = 0; i < 3; i++)
3399 + blocks += be16_to_cpu(extent[i].count);
3400 +
3401 + res = hfs_free_extents(sb, extent, blocks, blocks);
3402 +@@ -341,7 +345,9 @@ int hfs_get_block(struct inode *inode, sector_t block,
3403 + ablock = (u32)block / HFS_SB(sb)->fs_div;
3404 +
3405 + if (block >= HFS_I(inode)->fs_blocks) {
3406 +- if (block > HFS_I(inode)->fs_blocks || !create)
3407 ++ if (!create)
3408 ++ return 0;
3409 ++ if (block > HFS_I(inode)->fs_blocks)
3410 + return -EIO;
3411 + if (ablock >= HFS_I(inode)->alloc_blocks) {
3412 + res = hfs_extend_file(inode);
3413 +diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c
3414 +index e5b221de7de6..d7455ea70287 100644
3415 +--- a/fs/hfsplus/attributes.c
3416 ++++ b/fs/hfsplus/attributes.c
3417 +@@ -216,6 +216,11 @@ int hfsplus_create_attr(struct inode *inode,
3418 + if (err)
3419 + goto failed_init_create_attr;
3420 +
3421 ++ /* Fail early and avoid ENOSPC during the btree operation */
3422 ++ err = hfs_bmap_reserve(fd.tree, fd.tree->depth + 1);
3423 ++ if (err)
3424 ++ goto failed_create_attr;
3425 ++
3426 + if (name) {
3427 + err = hfsplus_attr_build_key(sb, fd.search_key,
3428 + inode->i_ino, name);
3429 +@@ -312,6 +317,11 @@ int hfsplus_delete_attr(struct inode *inode, const char *name)
3430 + if (err)
3431 + return err;
3432 +
3433 ++ /* Fail early and avoid ENOSPC during the btree operation */
3434 ++ err = hfs_bmap_reserve(fd.tree, fd.tree->depth);
3435 ++ if (err)
3436 ++ goto out;
3437 ++
3438 + if (name) {
3439 + err = hfsplus_attr_build_key(sb, fd.search_key,
3440 + inode->i_ino, name);
3441 +diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
3442 +index 1002a0c08319..20ce698251ad 100644
3443 +--- a/fs/hfsplus/brec.c
3444 ++++ b/fs/hfsplus/brec.c
3445 +@@ -447,6 +447,7 @@ skip:
3446 + /* restore search_key */
3447 + hfs_bnode_read_key(node, fd->search_key, 14);
3448 + }
3449 ++ new_node = NULL;
3450 + }
3451 +
3452 + if (!rec && node->parent)
3453 +diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
3454 +index 7adc8a327e03..1ae3e187bc9d 100644
3455 +--- a/fs/hfsplus/btree.c
3456 ++++ b/fs/hfsplus/btree.c
3457 +@@ -341,26 +341,21 @@ static struct hfs_bnode *hfs_bmap_new_bmap(struct hfs_bnode *prev, u32 idx)
3458 + return node;
3459 + }
3460 +
3461 +-struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
3462 ++/* Make sure @tree has enough space for the @rsvd_nodes */
3463 ++int hfs_bmap_reserve(struct hfs_btree *tree, int rsvd_nodes)
3464 + {
3465 +- struct hfs_bnode *node, *next_node;
3466 +- struct page **pagep;
3467 +- u32 nidx, idx;
3468 +- unsigned off;
3469 +- u16 off16;
3470 +- u16 len;
3471 +- u8 *data, byte, m;
3472 +- int i;
3473 ++ struct inode *inode = tree->inode;
3474 ++ struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
3475 ++ u32 count;
3476 ++ int res;
3477 +
3478 +- while (!tree->free_nodes) {
3479 +- struct inode *inode = tree->inode;
3480 +- struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
3481 +- u32 count;
3482 +- int res;
3483 ++ if (rsvd_nodes <= 0)
3484 ++ return 0;
3485 +
3486 ++ while (tree->free_nodes < rsvd_nodes) {
3487 + res = hfsplus_file_extend(inode, hfs_bnode_need_zeroout(tree));
3488 + if (res)
3489 +- return ERR_PTR(res);
3490 ++ return res;
3491 + hip->phys_size = inode->i_size =
3492 + (loff_t)hip->alloc_blocks <<
3493 + HFSPLUS_SB(tree->sb)->alloc_blksz_shift;
3494 +@@ -368,9 +363,26 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
3495 + hip->alloc_blocks << HFSPLUS_SB(tree->sb)->fs_shift;
3496 + inode_set_bytes(inode, inode->i_size);
3497 + count = inode->i_size >> tree->node_size_shift;
3498 +- tree->free_nodes = count - tree->node_count;
3499 ++ tree->free_nodes += count - tree->node_count;
3500 + tree->node_count = count;
3501 + }
3502 ++ return 0;
3503 ++}
3504 ++
3505 ++struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
3506 ++{
3507 ++ struct hfs_bnode *node, *next_node;
3508 ++ struct page **pagep;
3509 ++ u32 nidx, idx;
3510 ++ unsigned off;
3511 ++ u16 off16;
3512 ++ u16 len;
3513 ++ u8 *data, byte, m;
3514 ++ int i, res;
3515 ++
3516 ++ res = hfs_bmap_reserve(tree, 1);
3517 ++ if (res)
3518 ++ return ERR_PTR(res);
3519 +
3520 + nidx = 0;
3521 + node = hfs_bnode_find(tree, nidx);
3522 +diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
3523 +index 022974ab6e3c..e35df33583c4 100644
3524 +--- a/fs/hfsplus/catalog.c
3525 ++++ b/fs/hfsplus/catalog.c
3526 +@@ -264,6 +264,14 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
3527 + if (err)
3528 + return err;
3529 +
3530 ++ /*
3531 ++ * Fail early and avoid ENOSPC during the btree operations. We may
3532 ++ * have to split the root node at most once.
3533 ++ */
3534 ++ err = hfs_bmap_reserve(fd.tree, 2 * fd.tree->depth);
3535 ++ if (err)
3536 ++ goto err2;
3537 ++
3538 + hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid);
3539 + entry_size = hfsplus_fill_cat_thread(sb, &entry,
3540 + S_ISDIR(inode->i_mode) ?
3541 +@@ -332,6 +340,14 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
3542 + if (err)
3543 + return err;
3544 +
3545 ++ /*
3546 ++ * Fail early and avoid ENOSPC during the btree operations. We may
3547 ++ * have to split the root node at most once.
3548 ++ */
3549 ++ err = hfs_bmap_reserve(fd.tree, 2 * (int)fd.tree->depth - 2);
3550 ++ if (err)
3551 ++ goto out;
3552 ++
3553 + if (!str) {
3554 + int len;
3555 +
3556 +@@ -429,6 +445,14 @@ int hfsplus_rename_cat(u32 cnid,
3557 + return err;
3558 + dst_fd = src_fd;
3559 +
3560 ++ /*
3561 ++ * Fail early and avoid ENOSPC during the btree operations. We may
3562 ++ * have to split the root node at most twice.
3563 ++ */
3564 ++ err = hfs_bmap_reserve(src_fd.tree, 4 * (int)src_fd.tree->depth - 1);
3565 ++ if (err)
3566 ++ goto out;
3567 ++
3568 + /* find the old dir entry and read the data */
3569 + err = hfsplus_cat_build_key(sb, src_fd.search_key,
3570 + src_dir->i_ino, src_name);
3571 +diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
3572 +index feca524ce2a5..d93c051559cb 100644
3573 +--- a/fs/hfsplus/extents.c
3574 ++++ b/fs/hfsplus/extents.c
3575 +@@ -99,6 +99,10 @@ static int __hfsplus_ext_write_extent(struct inode *inode,
3576 + if (hip->extent_state & HFSPLUS_EXT_NEW) {
3577 + if (res != -ENOENT)
3578 + return res;
3579 ++ /* Fail early and avoid ENOSPC during the btree operation */
3580 ++ res = hfs_bmap_reserve(fd->tree, fd->tree->depth + 1);
3581 ++ if (res)
3582 ++ return res;
3583 + hfs_brec_insert(fd, hip->cached_extents,
3584 + sizeof(hfsplus_extent_rec));
3585 + hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW);
3586 +@@ -232,7 +236,9 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock,
3587 + ablock = iblock >> sbi->fs_shift;
3588 +
3589 + if (iblock >= hip->fs_blocks) {
3590 +- if (iblock > hip->fs_blocks || !create)
3591 ++ if (!create)
3592 ++ return 0;
3593 ++ if (iblock > hip->fs_blocks)
3594 + return -EIO;
3595 + if (ablock >= hip->alloc_blocks) {
3596 + res = hfsplus_file_extend(inode, false);
3597 +diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
3598 +index f91a1faf819e..0ab654149340 100644
3599 +--- a/fs/hfsplus/hfsplus_fs.h
3600 ++++ b/fs/hfsplus/hfsplus_fs.h
3601 +@@ -310,6 +310,7 @@ static inline unsigned short hfsplus_min_io_size(struct super_block *sb)
3602 + #define hfs_btree_open hfsplus_btree_open
3603 + #define hfs_btree_close hfsplus_btree_close
3604 + #define hfs_btree_write hfsplus_btree_write
3605 ++#define hfs_bmap_reserve hfsplus_bmap_reserve
3606 + #define hfs_bmap_alloc hfsplus_bmap_alloc
3607 + #define hfs_bmap_free hfsplus_bmap_free
3608 + #define hfs_bnode_read hfsplus_bnode_read
3609 +@@ -394,6 +395,7 @@ u32 hfsplus_calc_btree_clump_size(u32 block_size, u32 node_size, u64 sectors,
3610 + struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id);
3611 + void hfs_btree_close(struct hfs_btree *tree);
3612 + int hfs_btree_write(struct hfs_btree *tree);
3613 ++int hfs_bmap_reserve(struct hfs_btree *tree, int rsvd_nodes);
3614 + struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree);
3615 + void hfs_bmap_free(struct hfs_bnode *node);
3616 +
3617 +diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
3618 +index 9ee8bcfbf00f..92593179f7e2 100644
3619 +--- a/fs/ocfs2/buffer_head_io.c
3620 ++++ b/fs/ocfs2/buffer_head_io.c
3621 +@@ -98,25 +98,34 @@ out:
3622 + return ret;
3623 + }
3624 +
3625 ++/* Caller must provide a bhs[] with all NULL or non-NULL entries, so it
3626 ++ * will be easier to handle read failure.
3627 ++ */
3628 + int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
3629 + unsigned int nr, struct buffer_head *bhs[])
3630 + {
3631 + int status = 0;
3632 + unsigned int i;
3633 + struct buffer_head *bh;
3634 ++ int new_bh = 0;
3635 +
3636 + trace_ocfs2_read_blocks_sync((unsigned long long)block, nr);
3637 +
3638 + if (!nr)
3639 + goto bail;
3640 +
3641 ++ /* Don't put buffer head and re-assign it to NULL if it is allocated
3642 ++ * outside since the caller can't be aware of this alternation!
3643 ++ */
3644 ++ new_bh = (bhs[0] == NULL);
3645 ++
3646 + for (i = 0 ; i < nr ; i++) {
3647 + if (bhs[i] == NULL) {
3648 + bhs[i] = sb_getblk(osb->sb, block++);
3649 + if (bhs[i] == NULL) {
3650 + status = -ENOMEM;
3651 + mlog_errno(status);
3652 +- goto bail;
3653 ++ break;
3654 + }
3655 + }
3656 + bh = bhs[i];
3657 +@@ -151,9 +160,26 @@ int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
3658 + submit_bh(READ, bh);
3659 + }
3660 +
3661 ++read_failure:
3662 + for (i = nr; i > 0; i--) {
3663 + bh = bhs[i - 1];
3664 +
3665 ++ if (unlikely(status)) {
3666 ++ if (new_bh && bh) {
3667 ++ /* If middle bh fails, let previous bh
3668 ++ * finish its read and then put it to
3669 ++ * aovoid bh leak
3670 ++ */
3671 ++ if (!buffer_jbd(bh))
3672 ++ wait_on_buffer(bh);
3673 ++ put_bh(bh);
3674 ++ bhs[i - 1] = NULL;
3675 ++ } else if (bh && buffer_uptodate(bh)) {
3676 ++ clear_buffer_uptodate(bh);
3677 ++ }
3678 ++ continue;
3679 ++ }
3680 ++
3681 + /* No need to wait on the buffer if it's managed by JBD. */
3682 + if (!buffer_jbd(bh))
3683 + wait_on_buffer(bh);
3684 +@@ -163,8 +189,7 @@ int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
3685 + * so we can safely record this and loop back
3686 + * to cleanup the other buffers. */
3687 + status = -EIO;
3688 +- put_bh(bh);
3689 +- bhs[i - 1] = NULL;
3690 ++ goto read_failure;
3691 + }
3692 + }
3693 +
3694 +@@ -172,6 +197,9 @@ bail:
3695 + return status;
3696 + }
3697 +
3698 ++/* Caller must provide a bhs[] with all NULL or non-NULL entries, so it
3699 ++ * will be easier to handle read failure.
3700 ++ */
3701 + int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
3702 + struct buffer_head *bhs[], int flags,
3703 + int (*validate)(struct super_block *sb,
3704 +@@ -181,6 +209,7 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
3705 + int i, ignore_cache = 0;
3706 + struct buffer_head *bh;
3707 + struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
3708 ++ int new_bh = 0;
3709 +
3710 + trace_ocfs2_read_blocks_begin(ci, (unsigned long long)block, nr, flags);
3711 +
3712 +@@ -206,6 +235,11 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
3713 + goto bail;
3714 + }
3715 +
3716 ++ /* Don't put buffer head and re-assign it to NULL if it is allocated
3717 ++ * outside since the caller can't be aware of this alternation!
3718 ++ */
3719 ++ new_bh = (bhs[0] == NULL);
3720 ++
3721 + ocfs2_metadata_cache_io_lock(ci);
3722 + for (i = 0 ; i < nr ; i++) {
3723 + if (bhs[i] == NULL) {
3724 +@@ -214,7 +248,8 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
3725 + ocfs2_metadata_cache_io_unlock(ci);
3726 + status = -ENOMEM;
3727 + mlog_errno(status);
3728 +- goto bail;
3729 ++ /* Don't forget to put previous bh! */
3730 ++ break;
3731 + }
3732 + }
3733 + bh = bhs[i];
3734 +@@ -308,16 +343,27 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
3735 + }
3736 + }
3737 +
3738 +- status = 0;
3739 +-
3740 ++read_failure:
3741 + for (i = (nr - 1); i >= 0; i--) {
3742 + bh = bhs[i];
3743 +
3744 + if (!(flags & OCFS2_BH_READAHEAD)) {
3745 +- if (status) {
3746 +- /* Clear the rest of the buffers on error */
3747 +- put_bh(bh);
3748 +- bhs[i] = NULL;
3749 ++ if (unlikely(status)) {
3750 ++ /* Clear the buffers on error including those
3751 ++ * ever succeeded in reading
3752 ++ */
3753 ++ if (new_bh && bh) {
3754 ++ /* If middle bh fails, let previous bh
3755 ++ * finish its read and then put it to
3756 ++ * aovoid bh leak
3757 ++ */
3758 ++ if (!buffer_jbd(bh))
3759 ++ wait_on_buffer(bh);
3760 ++ put_bh(bh);
3761 ++ bhs[i] = NULL;
3762 ++ } else if (bh && buffer_uptodate(bh)) {
3763 ++ clear_buffer_uptodate(bh);
3764 ++ }
3765 + continue;
3766 + }
3767 + /* We know this can't have changed as we hold the
3768 +@@ -335,9 +381,7 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
3769 + * uptodate. */
3770 + status = -EIO;
3771 + clear_buffer_needs_validate(bh);
3772 +- put_bh(bh);
3773 +- bhs[i] = NULL;
3774 +- continue;
3775 ++ goto read_failure;
3776 + }
3777 +
3778 + if (buffer_needs_validate(bh)) {
3779 +@@ -347,11 +391,8 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
3780 + BUG_ON(buffer_jbd(bh));
3781 + clear_buffer_needs_validate(bh);
3782 + status = validate(sb, bh);
3783 +- if (status) {
3784 +- put_bh(bh);
3785 +- bhs[i] = NULL;
3786 +- continue;
3787 +- }
3788 ++ if (status)
3789 ++ goto read_failure;
3790 + }
3791 + }
3792 +
3793 +diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
3794 +index 825136070d2c..73eaccea09b9 100644
3795 +--- a/fs/ocfs2/dlm/dlmdebug.c
3796 ++++ b/fs/ocfs2/dlm/dlmdebug.c
3797 +@@ -329,7 +329,7 @@ void dlm_print_one_mle(struct dlm_master_list_entry *mle)
3798 + {
3799 + char *buf;
3800 +
3801 +- buf = (char *) get_zeroed_page(GFP_NOFS);
3802 ++ buf = (char *) get_zeroed_page(GFP_ATOMIC);
3803 + if (buf) {
3804 + dump_mle(mle, buf, PAGE_SIZE - 1);
3805 + free_page((unsigned long)buf);
3806 +diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
3807 +index 555b57a16499..faaf8bfd2f52 100644
3808 +--- a/fs/ocfs2/dlmglue.c
3809 ++++ b/fs/ocfs2/dlmglue.c
3810 +@@ -3426,7 +3426,7 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
3811 + * we can recover correctly from node failure. Otherwise, we may get
3812 + * invalid LVB in LKB, but without DLM_SBF_VALNOTVALID being set.
3813 + */
3814 +- if (!ocfs2_is_o2cb_active() &&
3815 ++ if (ocfs2_userspace_stack(osb) &&
3816 + lockres->l_ops->flags & LOCK_TYPE_USES_LVB)
3817 + lvb = 1;
3818 +
3819 +diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
3820 +index c1a83c58456e..725a870fd14f 100644
3821 +--- a/fs/ocfs2/move_extents.c
3822 ++++ b/fs/ocfs2/move_extents.c
3823 +@@ -25,6 +25,7 @@
3824 + #include "ocfs2_ioctl.h"
3825 +
3826 + #include "alloc.h"
3827 ++#include "localalloc.h"
3828 + #include "aops.h"
3829 + #include "dlmglue.h"
3830 + #include "extent_map.h"
3831 +@@ -222,6 +223,7 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context,
3832 + struct ocfs2_refcount_tree *ref_tree = NULL;
3833 + u32 new_phys_cpos, new_len;
3834 + u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
3835 ++ int need_free = 0;
3836 +
3837 + if ((ext_flags & OCFS2_EXT_REFCOUNTED) && *len) {
3838 +
3839 +@@ -315,6 +317,7 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context,
3840 + if (!partial) {
3841 + context->range->me_flags &= ~OCFS2_MOVE_EXT_FL_COMPLETE;
3842 + ret = -ENOSPC;
3843 ++ need_free = 1;
3844 + goto out_commit;
3845 + }
3846 + }
3847 +@@ -339,6 +342,20 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context,
3848 + mlog_errno(ret);
3849 +
3850 + out_commit:
3851 ++ if (need_free && context->data_ac) {
3852 ++ struct ocfs2_alloc_context *data_ac = context->data_ac;
3853 ++
3854 ++ if (context->data_ac->ac_which == OCFS2_AC_USE_LOCAL)
3855 ++ ocfs2_free_local_alloc_bits(osb, handle, data_ac,
3856 ++ new_phys_cpos, new_len);
3857 ++ else
3858 ++ ocfs2_free_clusters(handle,
3859 ++ data_ac->ac_inode,
3860 ++ data_ac->ac_bh,
3861 ++ ocfs2_clusters_to_blocks(osb->sb, new_phys_cpos),
3862 ++ new_len);
3863 ++ }
3864 ++
3865 + ocfs2_commit_trans(osb, handle);
3866 +
3867 + out_unlock_mutex:
3868 +diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
3869 +index 783bcdce5666..5d965e83bd43 100644
3870 +--- a/fs/ocfs2/stackglue.c
3871 ++++ b/fs/ocfs2/stackglue.c
3872 +@@ -48,12 +48,6 @@ static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
3873 + */
3874 + static struct ocfs2_stack_plugin *active_stack;
3875 +
3876 +-inline int ocfs2_is_o2cb_active(void)
3877 +-{
3878 +- return !strcmp(active_stack->sp_name, OCFS2_STACK_PLUGIN_O2CB);
3879 +-}
3880 +-EXPORT_SYMBOL_GPL(ocfs2_is_o2cb_active);
3881 +-
3882 + static struct ocfs2_stack_plugin *ocfs2_stack_lookup(const char *name)
3883 + {
3884 + struct ocfs2_stack_plugin *p;
3885 +diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h
3886 +index e1b30931974d..66334a30cea8 100644
3887 +--- a/fs/ocfs2/stackglue.h
3888 ++++ b/fs/ocfs2/stackglue.h
3889 +@@ -298,7 +298,4 @@ void ocfs2_stack_glue_set_max_proto_version(struct ocfs2_protocol_version *max_p
3890 + int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin);
3891 + void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin);
3892 +
3893 +-/* In ocfs2_downconvert_lock(), we need to know which stack we are using */
3894 +-int ocfs2_is_o2cb_active(void);
3895 +-
3896 + #endif /* STACKGLUE_H */
3897 +diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
3898 +index dfa6d45dc4dc..06faa608e562 100644
3899 +--- a/fs/ocfs2/xattr.c
3900 ++++ b/fs/ocfs2/xattr.c
3901 +@@ -1475,6 +1475,18 @@ static int ocfs2_xa_check_space(struct ocfs2_xa_loc *loc,
3902 + return loc->xl_ops->xlo_check_space(loc, xi);
3903 + }
3904 +
3905 ++static void ocfs2_xa_add_entry(struct ocfs2_xa_loc *loc, u32 name_hash)
3906 ++{
3907 ++ loc->xl_ops->xlo_add_entry(loc, name_hash);
3908 ++ loc->xl_entry->xe_name_hash = cpu_to_le32(name_hash);
3909 ++ /*
3910 ++ * We can't leave the new entry's xe_name_offset at zero or
3911 ++ * add_namevalue() will go nuts. We set it to the size of our
3912 ++ * storage so that it can never be less than any other entry.
3913 ++ */
3914 ++ loc->xl_entry->xe_name_offset = cpu_to_le16(loc->xl_size);
3915 ++}
3916 ++
3917 + static void ocfs2_xa_add_namevalue(struct ocfs2_xa_loc *loc,
3918 + struct ocfs2_xattr_info *xi)
3919 + {
3920 +@@ -2106,31 +2118,29 @@ static int ocfs2_xa_prepare_entry(struct ocfs2_xa_loc *loc,
3921 + if (rc)
3922 + goto out;
3923 +
3924 +- if (!loc->xl_entry) {
3925 +- rc = -EINVAL;
3926 +- goto out;
3927 +- }
3928 +-
3929 +- if (ocfs2_xa_can_reuse_entry(loc, xi)) {
3930 +- orig_value_size = loc->xl_entry->xe_value_size;
3931 +- rc = ocfs2_xa_reuse_entry(loc, xi, ctxt);
3932 +- if (rc)
3933 +- goto out;
3934 +- goto alloc_value;
3935 +- }
3936 ++ if (loc->xl_entry) {
3937 ++ if (ocfs2_xa_can_reuse_entry(loc, xi)) {
3938 ++ orig_value_size = loc->xl_entry->xe_value_size;
3939 ++ rc = ocfs2_xa_reuse_entry(loc, xi, ctxt);
3940 ++ if (rc)
3941 ++ goto out;
3942 ++ goto alloc_value;
3943 ++ }
3944 +
3945 +- if (!ocfs2_xattr_is_local(loc->xl_entry)) {
3946 +- orig_clusters = ocfs2_xa_value_clusters(loc);
3947 +- rc = ocfs2_xa_value_truncate(loc, 0, ctxt);
3948 +- if (rc) {
3949 +- mlog_errno(rc);
3950 +- ocfs2_xa_cleanup_value_truncate(loc,
3951 +- "overwriting",
3952 +- orig_clusters);
3953 +- goto out;
3954 ++ if (!ocfs2_xattr_is_local(loc->xl_entry)) {
3955 ++ orig_clusters = ocfs2_xa_value_clusters(loc);
3956 ++ rc = ocfs2_xa_value_truncate(loc, 0, ctxt);
3957 ++ if (rc) {
3958 ++ mlog_errno(rc);
3959 ++ ocfs2_xa_cleanup_value_truncate(loc,
3960 ++ "overwriting",
3961 ++ orig_clusters);
3962 ++ goto out;
3963 ++ }
3964 + }
3965 +- }
3966 +- ocfs2_xa_wipe_namevalue(loc);
3967 ++ ocfs2_xa_wipe_namevalue(loc);
3968 ++ } else
3969 ++ ocfs2_xa_add_entry(loc, name_hash);
3970 +
3971 + /*
3972 + * If we get here, we have a blank entry. Fill it. We grow our
3973 +diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
3974 +index 9653fdb76a42..714ce4a5e31f 100644
3975 +--- a/include/linux/bitmap.h
3976 ++++ b/include/linux/bitmap.h
3977 +@@ -175,8 +175,13 @@ extern int bitmap_print_to_pagebuf(bool list, char *buf,
3978 + #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
3979 + #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
3980 +
3981 ++/*
3982 ++ * The static inlines below do not handle constant nbits==0 correctly,
3983 ++ * so make such users (should any ever turn up) call the out-of-line
3984 ++ * versions.
3985 ++ */
3986 + #define small_const_nbits(nbits) \
3987 +- (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
3988 ++ (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG && (nbits) > 0)
3989 +
3990 + static inline void bitmap_zero(unsigned long *dst, unsigned int nbits)
3991 + {
3992 +@@ -303,7 +308,7 @@ static __always_inline int bitmap_weight(const unsigned long *src, unsigned int
3993 + }
3994 +
3995 + static inline void bitmap_shift_right(unsigned long *dst, const unsigned long *src,
3996 +- unsigned int shift, int nbits)
3997 ++ unsigned int shift, unsigned int nbits)
3998 + {
3999 + if (small_const_nbits(nbits))
4000 + *dst = (*src & BITMAP_LAST_WORD_MASK(nbits)) >> shift;
4001 +diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
4002 +index cf815577bd68..3ae1fe743bc3 100644
4003 +--- a/include/linux/mfd/max8997.h
4004 ++++ b/include/linux/mfd/max8997.h
4005 +@@ -178,7 +178,6 @@ struct max8997_led_platform_data {
4006 + struct max8997_platform_data {
4007 + /* IRQ */
4008 + int ono;
4009 +- int wakeup;
4010 +
4011 + /* ---- PMIC ---- */
4012 + struct max8997_regulator_data *regulators;
4013 +diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h
4014 +index 638222e43e48..93011c61aafd 100644
4015 +--- a/include/linux/mfd/mc13xxx.h
4016 ++++ b/include/linux/mfd/mc13xxx.h
4017 +@@ -247,6 +247,7 @@ struct mc13xxx_platform_data {
4018 + #define MC13XXX_ADC0_TSMOD0 (1 << 12)
4019 + #define MC13XXX_ADC0_TSMOD1 (1 << 13)
4020 + #define MC13XXX_ADC0_TSMOD2 (1 << 14)
4021 ++#define MC13XXX_ADC0_CHRGRAWDIV (1 << 15)
4022 + #define MC13XXX_ADC0_ADINC1 (1 << 16)
4023 + #define MC13XXX_ADC0_ADINC2 (1 << 17)
4024 +
4025 +diff --git a/kernel/auditsc.c b/kernel/auditsc.c
4026 +index 0fe8b337291a..87c43c92fb7d 100644
4027 +--- a/kernel/auditsc.c
4028 ++++ b/kernel/auditsc.c
4029 +@@ -1093,7 +1093,7 @@ static void audit_log_execve_info(struct audit_context *context,
4030 + }
4031 +
4032 + /* write as much as we can to the audit log */
4033 +- if (len_buf > 0) {
4034 ++ if (len_buf >= 0) {
4035 + /* NOTE: some magic numbers here - basically if we
4036 + * can't fit a reasonable amount of data into the
4037 + * existing audit buffer, flush it and start with
4038 +diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
4039 +index 699c18c9d763..e53a976ca28e 100644
4040 +--- a/kernel/printk/printk.c
4041 ++++ b/kernel/printk/printk.c
4042 +@@ -937,7 +937,7 @@ void __init setup_log_buf(int early)
4043 + {
4044 + unsigned long flags;
4045 + char *new_log_buf;
4046 +- int free;
4047 ++ unsigned int free;
4048 +
4049 + if (log_buf != __log_buf)
4050 + return;
4051 +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
4052 +index cd2fb8384fbe..d012681fb1ab 100644
4053 +--- a/kernel/sched/fair.c
4054 ++++ b/kernel/sched/fair.c
4055 +@@ -7334,13 +7334,22 @@ out_all_pinned:
4056 + sd->nr_balance_failed = 0;
4057 +
4058 + out_one_pinned:
4059 ++ ld_moved = 0;
4060 ++
4061 ++ /*
4062 ++ * idle_balance() disregards balance intervals, so we could repeatedly
4063 ++ * reach this code, which would lead to balance_interval skyrocketting
4064 ++ * in a short amount of time. Skip the balance_interval increase logic
4065 ++ * to avoid that.
4066 ++ */
4067 ++ if (env.idle == CPU_NEWLY_IDLE)
4068 ++ goto out;
4069 ++
4070 + /* tune up the balancing interval */
4071 + if (((env.flags & LBF_ALL_PINNED) &&
4072 + sd->balance_interval < MAX_PINNED_INTERVAL) ||
4073 + (sd->balance_interval < sd->max_interval))
4074 + sd->balance_interval *= 2;
4075 +-
4076 +- ld_moved = 0;
4077 + out:
4078 + return ld_moved;
4079 + }
4080 +diff --git a/mm/ksm.c b/mm/ksm.c
4081 +index 0b496edc704b..f51613052aee 100644
4082 +--- a/mm/ksm.c
4083 ++++ b/mm/ksm.c
4084 +@@ -714,13 +714,13 @@ static int remove_stable_node(struct stable_node *stable_node)
4085 + return 0;
4086 + }
4087 +
4088 +- if (WARN_ON_ONCE(page_mapped(page))) {
4089 +- /*
4090 +- * This should not happen: but if it does, just refuse to let
4091 +- * merge_across_nodes be switched - there is no need to panic.
4092 +- */
4093 +- err = -EBUSY;
4094 +- } else {
4095 ++ /*
4096 ++ * Page could be still mapped if this races with __mmput() running in
4097 ++ * between ksm_exit() and exit_mmap(). Just refuse to let
4098 ++ * merge_across_nodes/max_page_sharing be switched.
4099 ++ */
4100 ++ err = -EBUSY;
4101 ++ if (!page_mapped(page)) {
4102 + /*
4103 + * The stable node did not yet appear stale to get_ksm_page(),
4104 + * since that allows for an unmapped ksm page to be recognized
4105 +diff --git a/mm/page-writeback.c b/mm/page-writeback.c
4106 +index 0bc7fa21db85..d2211e42b779 100644
4107 +--- a/mm/page-writeback.c
4108 ++++ b/mm/page-writeback.c
4109 +@@ -2144,6 +2144,13 @@ EXPORT_SYMBOL(tag_pages_for_writeback);
4110 + * not miss some pages (e.g., because some other process has cleared TOWRITE
4111 + * tag we set). The rule we follow is that TOWRITE tag can be cleared only
4112 + * by the process clearing the DIRTY tag (and submitting the page for IO).
4113 ++ *
4114 ++ * To avoid deadlocks between range_cyclic writeback and callers that hold
4115 ++ * pages in PageWriteback to aggregate IO until write_cache_pages() returns,
4116 ++ * we do not loop back to the start of the file. Doing so causes a page
4117 ++ * lock/page writeback access order inversion - we should only ever lock
4118 ++ * multiple pages in ascending page->index order, and looping back to the start
4119 ++ * of the file violates that rule and causes deadlocks.
4120 + */
4121 + int write_cache_pages(struct address_space *mapping,
4122 + struct writeback_control *wbc, writepage_t writepage,
4123 +@@ -2158,7 +2165,6 @@ int write_cache_pages(struct address_space *mapping,
4124 + pgoff_t index;
4125 + pgoff_t end; /* Inclusive */
4126 + pgoff_t done_index;
4127 +- int cycled;
4128 + int range_whole = 0;
4129 + int tag;
4130 +
4131 +@@ -2166,23 +2172,17 @@ int write_cache_pages(struct address_space *mapping,
4132 + if (wbc->range_cyclic) {
4133 + writeback_index = mapping->writeback_index; /* prev offset */
4134 + index = writeback_index;
4135 +- if (index == 0)
4136 +- cycled = 1;
4137 +- else
4138 +- cycled = 0;
4139 + end = -1;
4140 + } else {
4141 + index = wbc->range_start >> PAGE_CACHE_SHIFT;
4142 + end = wbc->range_end >> PAGE_CACHE_SHIFT;
4143 + if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
4144 + range_whole = 1;
4145 +- cycled = 1; /* ignore range_cyclic tests */
4146 + }
4147 + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
4148 + tag = PAGECACHE_TAG_TOWRITE;
4149 + else
4150 + tag = PAGECACHE_TAG_DIRTY;
4151 +-retry:
4152 + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
4153 + tag_pages_for_writeback(mapping, index, end);
4154 + done_index = index;
4155 +@@ -2290,17 +2290,14 @@ continue_unlock:
4156 + pagevec_release(&pvec);
4157 + cond_resched();
4158 + }
4159 +- if (!cycled && !done) {
4160 +- /*
4161 +- * range_cyclic:
4162 +- * We hit the last page and there is more work to be done: wrap
4163 +- * back to the start of the file
4164 +- */
4165 +- cycled = 1;
4166 +- index = 0;
4167 +- end = writeback_index - 1;
4168 +- goto retry;
4169 +- }
4170 ++
4171 ++ /*
4172 ++ * If we hit the last page and there is more work to be done: wrap
4173 ++ * back the index back to the start of the file for the next
4174 ++ * time we are called.
4175 ++ */
4176 ++ if (wbc->range_cyclic && !done)
4177 ++ done_index = 0;
4178 + if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
4179 + mapping->writeback_index = done_index;
4180 +
4181 +diff --git a/net/core/dev.c b/net/core/dev.c
4182 +index 18a5154e2f25..903c6242b449 100644
4183 +--- a/net/core/dev.c
4184 ++++ b/net/core/dev.c
4185 +@@ -2801,7 +2801,7 @@ struct sk_buff *dev_hard_start_xmit(struct sk_buff *first, struct net_device *de
4186 + }
4187 +
4188 + skb = next;
4189 +- if (netif_xmit_stopped(txq) && skb) {
4190 ++ if (netif_tx_queue_stopped(txq) && skb) {
4191 + rc = NETDEV_TX_BUSY;
4192 + break;
4193 + }
4194 +diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
4195 +index d52b633164c9..a9da58204afa 100644
4196 +--- a/net/core/rtnetlink.c
4197 ++++ b/net/core/rtnetlink.c
4198 +@@ -1549,6 +1549,8 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
4199 + if (tb[IFLA_VF_MAC]) {
4200 + struct ifla_vf_mac *ivm = nla_data(tb[IFLA_VF_MAC]);
4201 +
4202 ++ if (ivm->vf >= INT_MAX)
4203 ++ return -EINVAL;
4204 + err = -EOPNOTSUPP;
4205 + if (ops->ndo_set_vf_mac)
4206 + err = ops->ndo_set_vf_mac(dev, ivm->vf,
4207 +@@ -1560,6 +1562,8 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
4208 + if (tb[IFLA_VF_VLAN]) {
4209 + struct ifla_vf_vlan *ivv = nla_data(tb[IFLA_VF_VLAN]);
4210 +
4211 ++ if (ivv->vf >= INT_MAX)
4212 ++ return -EINVAL;
4213 + err = -EOPNOTSUPP;
4214 + if (ops->ndo_set_vf_vlan)
4215 + err = ops->ndo_set_vf_vlan(dev, ivv->vf, ivv->vlan,
4216 +@@ -1572,6 +1576,8 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
4217 + struct ifla_vf_tx_rate *ivt = nla_data(tb[IFLA_VF_TX_RATE]);
4218 + struct ifla_vf_info ivf;
4219 +
4220 ++ if (ivt->vf >= INT_MAX)
4221 ++ return -EINVAL;
4222 + err = -EOPNOTSUPP;
4223 + if (ops->ndo_get_vf_config)
4224 + err = ops->ndo_get_vf_config(dev, ivt->vf, &ivf);
4225 +@@ -1590,6 +1596,8 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
4226 + if (tb[IFLA_VF_RATE]) {
4227 + struct ifla_vf_rate *ivt = nla_data(tb[IFLA_VF_RATE]);
4228 +
4229 ++ if (ivt->vf >= INT_MAX)
4230 ++ return -EINVAL;
4231 + err = -EOPNOTSUPP;
4232 + if (ops->ndo_set_vf_rate)
4233 + err = ops->ndo_set_vf_rate(dev, ivt->vf,
4234 +@@ -1602,6 +1610,8 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
4235 + if (tb[IFLA_VF_SPOOFCHK]) {
4236 + struct ifla_vf_spoofchk *ivs = nla_data(tb[IFLA_VF_SPOOFCHK]);
4237 +
4238 ++ if (ivs->vf >= INT_MAX)
4239 ++ return -EINVAL;
4240 + err = -EOPNOTSUPP;
4241 + if (ops->ndo_set_vf_spoofchk)
4242 + err = ops->ndo_set_vf_spoofchk(dev, ivs->vf,
4243 +@@ -1613,6 +1623,8 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
4244 + if (tb[IFLA_VF_LINK_STATE]) {
4245 + struct ifla_vf_link_state *ivl = nla_data(tb[IFLA_VF_LINK_STATE]);
4246 +
4247 ++ if (ivl->vf >= INT_MAX)
4248 ++ return -EINVAL;
4249 + err = -EOPNOTSUPP;
4250 + if (ops->ndo_set_vf_link_state)
4251 + err = ops->ndo_set_vf_link_state(dev, ivl->vf,
4252 +@@ -1626,6 +1638,8 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
4253 +
4254 + err = -EOPNOTSUPP;
4255 + ivrssq_en = nla_data(tb[IFLA_VF_RSS_QUERY_EN]);
4256 ++ if (ivrssq_en->vf >= INT_MAX)
4257 ++ return -EINVAL;
4258 + if (ops->ndo_set_vf_rss_query_en)
4259 + err = ops->ndo_set_vf_rss_query_en(dev, ivrssq_en->vf,
4260 + ivrssq_en->setting);
4261 +@@ -1636,6 +1650,8 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
4262 + if (tb[IFLA_VF_TRUST]) {
4263 + struct ifla_vf_trust *ivt = nla_data(tb[IFLA_VF_TRUST]);
4264 +
4265 ++ if (ivt->vf >= INT_MAX)
4266 ++ return -EINVAL;
4267 + err = -EOPNOTSUPP;
4268 + if (ops->ndo_set_vf_trust)
4269 + err = ops->ndo_set_vf_trust(dev, ivt->vf, ivt->setting);
4270 +diff --git a/net/core/sock.c b/net/core/sock.c
4271 +index 8aa4a5f89572..92d5f6232ec7 100644
4272 +--- a/net/core/sock.c
4273 ++++ b/net/core/sock.c
4274 +@@ -951,10 +951,12 @@ set_rcvbuf:
4275 + clear_bit(SOCK_PASSSEC, &sock->flags);
4276 + break;
4277 + case SO_MARK:
4278 +- if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN))
4279 ++ if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) {
4280 + ret = -EPERM;
4281 +- else
4282 ++ } else if (val != sk->sk_mark) {
4283 + sk->sk_mark = val;
4284 ++ sk_dst_reset(sk);
4285 ++ }
4286 + break;
4287 +
4288 + case SO_RXQ_OVFL:
4289 +diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
4290 +index c3434e902445..63d3b0ac43fb 100644
4291 +--- a/net/sched/act_pedit.c
4292 ++++ b/net/sched/act_pedit.c
4293 +@@ -50,13 +50,14 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
4294 + if (tb[TCA_PEDIT_PARMS] == NULL)
4295 + return -EINVAL;
4296 + parm = nla_data(tb[TCA_PEDIT_PARMS]);
4297 ++ if (!parm->nkeys)
4298 ++ return -EINVAL;
4299 ++
4300 + ksize = parm->nkeys * sizeof(struct tc_pedit_key);
4301 + if (nla_len(tb[TCA_PEDIT_PARMS]) < sizeof(*parm) + ksize)
4302 + return -EINVAL;
4303 +
4304 + if (!tcf_hash_check(parm->index, a, bind)) {
4305 +- if (!parm->nkeys)
4306 +- return -EINVAL;
4307 + ret = tcf_hash_create(parm->index, est, a, sizeof(*p),
4308 + bind, false);
4309 + if (ret)
4310 +diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c
4311 +index 1d74d653e6c0..ad0dcb69395d 100644
4312 +--- a/net/sunrpc/auth_gss/gss_krb5_seal.c
4313 ++++ b/net/sunrpc/auth_gss/gss_krb5_seal.c
4314 +@@ -63,6 +63,7 @@
4315 + #include <linux/sunrpc/gss_krb5.h>
4316 + #include <linux/random.h>
4317 + #include <linux/crypto.h>
4318 ++#include <linux/atomic.h>
4319 +
4320 + #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
4321 + # define RPCDBG_FACILITY RPCDBG_AUTH
4322 +diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
4323 +index b1a72615fdc3..b5e2ef242efe 100644
4324 +--- a/net/unix/af_unix.c
4325 ++++ b/net/unix/af_unix.c
4326 +@@ -224,6 +224,8 @@ static inline void unix_release_addr(struct unix_address *addr)
4327 +
4328 + static int unix_mkname(struct sockaddr_un *sunaddr, int len, unsigned int *hashp)
4329 + {
4330 ++ *hashp = 0;
4331 ++
4332 + if (len <= sizeof(short) || len > sizeof(*sunaddr))
4333 + return -EINVAL;
4334 + if (!sunaddr || sunaddr->sun_family != AF_UNIX)
4335 +diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
4336 +index 48d6dca471c6..6c8daf5b391f 100644
4337 +--- a/sound/firewire/isight.c
4338 ++++ b/sound/firewire/isight.c
4339 +@@ -639,7 +639,7 @@ static int isight_probe(struct fw_unit *unit,
4340 + if (!isight->audio_base) {
4341 + dev_err(&unit->device, "audio unit base not found\n");
4342 + err = -ENXIO;
4343 +- goto err_unit;
4344 ++ goto error;
4345 + }
4346 + fw_iso_resources_init(&isight->resources, unit);
4347 +
4348 +@@ -668,12 +668,12 @@ static int isight_probe(struct fw_unit *unit,
4349 + dev_set_drvdata(&unit->device, isight);
4350 +
4351 + return 0;
4352 +-
4353 +-err_unit:
4354 +- fw_unit_put(isight->unit);
4355 +- mutex_destroy(&isight->mutex);
4356 + error:
4357 + snd_card_free(card);
4358 ++
4359 ++ mutex_destroy(&isight->mutex);
4360 ++ fw_unit_put(isight->unit);
4361 ++
4362 + return err;
4363 + }
4364 +
4365 +diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c
4366 +index 7e21621e492a..7fd1b4000883 100644
4367 +--- a/sound/i2c/cs8427.c
4368 ++++ b/sound/i2c/cs8427.c
4369 +@@ -118,7 +118,7 @@ static int snd_cs8427_send_corudata(struct snd_i2c_device *device,
4370 + struct cs8427 *chip = device->private_data;
4371 + char *hw_data = udata ?
4372 + chip->playback.hw_udata : chip->playback.hw_status;
4373 +- char data[32];
4374 ++ unsigned char data[32];
4375 + int err, idx;
4376 +
4377 + if (!memcmp(hw_data, ndata, count))
4378 +diff --git a/tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk b/tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk
4379 +index 517567347aac..cd2faf0ca2e3 100644
4380 +--- a/tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk
4381 ++++ b/tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk
4382 +@@ -68,7 +68,7 @@ BEGIN {
4383 +
4384 + lprefix1_expr = "\\((66|!F3)\\)"
4385 + lprefix2_expr = "\\(F3\\)"
4386 +- lprefix3_expr = "\\((F2|!F3|66\\&F2)\\)"
4387 ++ lprefix3_expr = "\\((F2|!F3|66&F2)\\)"
4388 + lprefix_expr = "\\((66|F2|F3)\\)"
4389 + max_lprefix = 4
4390 +
4391 +@@ -253,7 +253,7 @@ function convert_operands(count,opnd, i,j,imm,mod)
4392 + return add_flags(imm, mod)
4393 + }
4394 +
4395 +-/^[0-9a-f]+\:/ {
4396 ++/^[0-9a-f]+:/ {
4397 + if (NR == 1)
4398 + next
4399 + # get index
4400 +diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc
4401 +index 231bcd2c4eb5..1e7ac6f3362f 100644
4402 +--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc
4403 ++++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc
4404 +@@ -71,8 +71,11 @@ test_badarg "\$stackp" "\$stack0+10" "\$stack1-10"
4405 + echo "r ${PROBEFUNC} \$retval" > kprobe_events
4406 + ! echo "p ${PROBEFUNC} \$retval" > kprobe_events
4407 +
4408 ++# $comm was introduced in 4.8, older kernels reject it.
4409 ++if grep -A1 "fetcharg:" README | grep -q '\$comm' ; then
4410 + : "Comm access"
4411 + test_goodarg "\$comm"
4412 ++fi
4413 +
4414 + : "Indirect memory access"
4415 + test_goodarg "+0(${GOODREG})" "-0(${GOODREG})" "+10(\$stack)" \