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: Wed, 21 Nov 2018 15:02:31
Message-Id: 1542812445.c1ea72dc1a0d9492f4268cfdd24323b907ee1487.mpagano@gentoo
1 commit: c1ea72dc1a0d9492f4268cfdd24323b907ee1487
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jul 4 14:25:42 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 21 15:00:45 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=c1ea72dc
7
8 Linux patch 4.4.139
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1138_linux-4.4.139.patch | 2867 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 2871 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 3ada367..cfb7ea3 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -595,6 +595,10 @@ Patch: 1137_linux-4.4.138.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.4.138
23
24 +Patch: 1138_linux-4.4.139.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.4.139
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/1138_linux-4.4.139.patch b/1138_linux-4.4.139.patch
33 new file mode 100644
34 index 0000000..a5150e7
35 --- /dev/null
36 +++ b/1138_linux-4.4.139.patch
37 @@ -0,0 +1,2867 @@
38 +diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
39 +index b784c270105f..ed6f6abaad57 100644
40 +--- a/Documentation/printk-formats.txt
41 ++++ b/Documentation/printk-formats.txt
42 +@@ -273,11 +273,10 @@ struct clk:
43 +
44 + %pC pll1
45 + %pCn pll1
46 +- %pCr 1560000000
47 +
48 + For printing struct clk structures. '%pC' and '%pCn' print the name
49 + (Common Clock Framework) or address (legacy clock framework) of the
50 +- structure; '%pCr' prints the current clock rate.
51 ++ structure.
52 +
53 + Passed by reference.
54 +
55 +diff --git a/Makefile b/Makefile
56 +index 1a8c0fc6b997..20a11fd36656 100644
57 +--- a/Makefile
58 ++++ b/Makefile
59 +@@ -1,6 +1,6 @@
60 + VERSION = 4
61 + PATCHLEVEL = 4
62 +-SUBLEVEL = 138
63 ++SUBLEVEL = 139
64 + EXTRAVERSION =
65 + NAME = Blurry Fish Butt
66 +
67 +diff --git a/arch/arm/include/asm/kgdb.h b/arch/arm/include/asm/kgdb.h
68 +index 0a9d5dd93294..6949c7d4481c 100644
69 +--- a/arch/arm/include/asm/kgdb.h
70 ++++ b/arch/arm/include/asm/kgdb.h
71 +@@ -76,7 +76,7 @@ extern int kgdb_fault_expected;
72 +
73 + #define KGDB_MAX_NO_CPUS 1
74 + #define BUFMAX 400
75 +-#define NUMREGBYTES (DBG_MAX_REG_NUM << 2)
76 ++#define NUMREGBYTES (GDB_MAX_REGS << 2)
77 + #define NUMCRITREGBYTES (32 << 2)
78 +
79 + #define _R0 0
80 +diff --git a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
81 +index 6e4955bc542b..fcd52cefee29 100644
82 +--- a/arch/m68k/mm/kmap.c
83 ++++ b/arch/m68k/mm/kmap.c
84 +@@ -88,7 +88,8 @@ static inline void free_io_area(void *addr)
85 + for (p = &iolist ; (tmp = *p) ; p = &tmp->next) {
86 + if (tmp->addr == addr) {
87 + *p = tmp->next;
88 +- __iounmap(tmp->addr, tmp->size);
89 ++ /* remove gap added in get_io_area() */
90 ++ __iounmap(tmp->addr, tmp->size - IO_SIZE);
91 + kfree(tmp);
92 + return;
93 + }
94 +diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
95 +index 6d38948f0f1e..4ca33175ec05 100644
96 +--- a/arch/mips/bcm47xx/setup.c
97 ++++ b/arch/mips/bcm47xx/setup.c
98 +@@ -249,6 +249,12 @@ static int __init bcm47xx_cpu_fixes(void)
99 + */
100 + if (bcm47xx_bus.bcma.bus.chipinfo.id == BCMA_CHIP_ID_BCM4706)
101 + cpu_wait = NULL;
102 ++
103 ++ /*
104 ++ * BCM47XX Erratum "R10: PCIe Transactions Periodically Fail"
105 ++ * Enable ExternalSync for sync instruction to take effect
106 ++ */
107 ++ set_c0_config7(MIPS_CONF7_ES);
108 + break;
109 + #endif
110 + }
111 +diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
112 +index d10fd80dbb7e..75fa296836fc 100644
113 +--- a/arch/mips/include/asm/io.h
114 ++++ b/arch/mips/include/asm/io.h
115 +@@ -411,6 +411,8 @@ static inline type pfx##in##bwlq##p(unsigned long port) \
116 + __val = *__addr; \
117 + slow; \
118 + \
119 ++ /* prevent prefetching of coherent DMA data prematurely */ \
120 ++ rmb(); \
121 + return pfx##ioswab##bwlq(__addr, __val); \
122 + }
123 +
124 +diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
125 +index e43aca183c99..15c183ce9d4f 100644
126 +--- a/arch/mips/include/asm/mipsregs.h
127 ++++ b/arch/mips/include/asm/mipsregs.h
128 +@@ -605,6 +605,8 @@
129 + #define MIPS_CONF7_WII (_ULCAST_(1) << 31)
130 +
131 + #define MIPS_CONF7_RPS (_ULCAST_(1) << 2)
132 ++/* ExternalSync */
133 ++#define MIPS_CONF7_ES (_ULCAST_(1) << 8)
134 +
135 + #define MIPS_CONF7_IAR (_ULCAST_(1) << 10)
136 + #define MIPS_CONF7_AR (_ULCAST_(1) << 16)
137 +@@ -2012,6 +2014,7 @@ __BUILD_SET_C0(status)
138 + __BUILD_SET_C0(cause)
139 + __BUILD_SET_C0(config)
140 + __BUILD_SET_C0(config5)
141 ++__BUILD_SET_C0(config7)
142 + __BUILD_SET_C0(intcontrol)
143 + __BUILD_SET_C0(intctl)
144 + __BUILD_SET_C0(srsmap)
145 +diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
146 +index 2f7c734771f4..0df911e772ae 100644
147 +--- a/arch/mips/kernel/mcount.S
148 ++++ b/arch/mips/kernel/mcount.S
149 +@@ -116,10 +116,20 @@ ftrace_stub:
150 + NESTED(_mcount, PT_SIZE, ra)
151 + PTR_LA t1, ftrace_stub
152 + PTR_L t2, ftrace_trace_function /* Prepare t2 for (1) */
153 +- bne t1, t2, static_trace
154 ++ beq t1, t2, fgraph_trace
155 + nop
156 +
157 ++ MCOUNT_SAVE_REGS
158 ++
159 ++ move a0, ra /* arg1: self return address */
160 ++ jalr t2 /* (1) call *ftrace_trace_function */
161 ++ move a1, AT /* arg2: parent's return address */
162 ++
163 ++ MCOUNT_RESTORE_REGS
164 ++
165 ++fgraph_trace:
166 + #ifdef CONFIG_FUNCTION_GRAPH_TRACER
167 ++ PTR_LA t1, ftrace_stub
168 + PTR_L t3, ftrace_graph_return
169 + bne t1, t3, ftrace_graph_caller
170 + nop
171 +@@ -128,24 +138,11 @@ NESTED(_mcount, PT_SIZE, ra)
172 + bne t1, t3, ftrace_graph_caller
173 + nop
174 + #endif
175 +- b ftrace_stub
176 +-#ifdef CONFIG_32BIT
177 +- addiu sp, sp, 8
178 +-#else
179 +- nop
180 +-#endif
181 +
182 +-static_trace:
183 +- MCOUNT_SAVE_REGS
184 +-
185 +- move a0, ra /* arg1: self return address */
186 +- jalr t2 /* (1) call *ftrace_trace_function */
187 +- move a1, AT /* arg2: parent's return address */
188 +-
189 +- MCOUNT_RESTORE_REGS
190 + #ifdef CONFIG_32BIT
191 + addiu sp, sp, 8
192 + #endif
193 ++
194 + .globl ftrace_stub
195 + ftrace_stub:
196 + RETURN_BACK
197 +diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
198 +index 2837232bbffb..59be96917369 100644
199 +--- a/arch/powerpc/kernel/entry_64.S
200 ++++ b/arch/powerpc/kernel/entry_64.S
201 +@@ -574,6 +574,7 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
202 + * actually hit this code path.
203 + */
204 +
205 ++ isync
206 + slbie r6
207 + slbie r6 /* Workaround POWER5 < DD2.1 issue */
208 + slbmte r7,r0
209 +diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
210 +index 26d091a1a54c..791d4c3329c3 100644
211 +--- a/arch/powerpc/kernel/fadump.c
212 ++++ b/arch/powerpc/kernel/fadump.c
213 +@@ -1025,6 +1025,9 @@ void fadump_cleanup(void)
214 + init_fadump_mem_struct(&fdm,
215 + be64_to_cpu(fdm_active->cpu_state_data.destination_address));
216 + fadump_invalidate_dump(&fdm);
217 ++ } else if (fw_dump.dump_registered) {
218 ++ /* Un-register Firmware-assisted dump if it was registered. */
219 ++ fadump_unregister_dump(&fdm);
220 + }
221 + }
222 +
223 +diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
224 +index fdf48785d3e9..56e4571e3a02 100644
225 +--- a/arch/powerpc/kernel/hw_breakpoint.c
226 ++++ b/arch/powerpc/kernel/hw_breakpoint.c
227 +@@ -174,8 +174,8 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
228 + if (cpu_has_feature(CPU_FTR_DAWR)) {
229 + length_max = 512 ; /* 64 doublewords */
230 + /* DAWR region can't cross 512 boundary */
231 +- if ((bp->attr.bp_addr >> 10) !=
232 +- ((bp->attr.bp_addr + bp->attr.bp_len - 1) >> 10))
233 ++ if ((bp->attr.bp_addr >> 9) !=
234 ++ ((bp->attr.bp_addr + bp->attr.bp_len - 1) >> 9))
235 + return -EINVAL;
236 + }
237 + if (info->len >
238 +diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
239 +index b38fd081b222..3b63655efa3c 100644
240 +--- a/arch/powerpc/kernel/ptrace.c
241 ++++ b/arch/powerpc/kernel/ptrace.c
242 +@@ -1004,6 +1004,7 @@ static int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
243 + /* Create a new breakpoint request if one doesn't exist already */
244 + hw_breakpoint_init(&attr);
245 + attr.bp_addr = hw_brk.address;
246 ++ attr.bp_len = 8;
247 + arch_bp_generic_fields(hw_brk.type,
248 + &attr.bp_type);
249 +
250 +diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
251 +index 814ef83c6720..e3a6f66d288c 100644
252 +--- a/arch/x86/include/asm/barrier.h
253 ++++ b/arch/x86/include/asm/barrier.h
254 +@@ -38,7 +38,7 @@ static inline unsigned long array_index_mask_nospec(unsigned long index,
255 + {
256 + unsigned long mask;
257 +
258 +- asm ("cmp %1,%2; sbb %0,%0;"
259 ++ asm volatile ("cmp %1,%2; sbb %0,%0;"
260 + :"=r" (mask)
261 + :"r"(size),"r" (index)
262 + :"cc");
263 +diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
264 +index 42d441f7898b..1edce040f470 100644
265 +--- a/arch/xtensa/kernel/traps.c
266 ++++ b/arch/xtensa/kernel/traps.c
267 +@@ -309,7 +309,7 @@ do_unaligned_user (struct pt_regs *regs)
268 + info.si_errno = 0;
269 + info.si_code = BUS_ADRALN;
270 + info.si_addr = (void *) regs->excvaddr;
271 +- force_sig_info(SIGSEGV, &info, current);
272 ++ force_sig_info(SIGBUS, &info, current);
273 +
274 + }
275 + #endif
276 +diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
277 +index f9b86a1d922d..9afd06ee5b30 100644
278 +--- a/drivers/ata/libata-core.c
279 ++++ b/drivers/ata/libata-core.c
280 +@@ -4247,9 +4247,6 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
281 + ATA_HORKAGE_ZERO_AFTER_TRIM |
282 + ATA_HORKAGE_NOLPM, },
283 +
284 +- /* Sandisk devices which are known to not handle LPM well */
285 +- { "SanDisk SD7UB3Q*G1001", NULL, ATA_HORKAGE_NOLPM, },
286 +-
287 + /* devices that don't properly handle queued TRIM commands */
288 + { "Micron_M500IT_*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM |
289 + ATA_HORKAGE_ZERO_AFTER_TRIM, },
290 +diff --git a/drivers/ata/libata-zpodd.c b/drivers/ata/libata-zpodd.c
291 +index f3a65a3140d3..0ad96c647541 100644
292 +--- a/drivers/ata/libata-zpodd.c
293 ++++ b/drivers/ata/libata-zpodd.c
294 +@@ -34,7 +34,7 @@ struct zpodd {
295 + static int eject_tray(struct ata_device *dev)
296 + {
297 + struct ata_taskfile tf;
298 +- const char cdb[] = { GPCMD_START_STOP_UNIT,
299 ++ static const char cdb[ATAPI_CDB_LEN] = { GPCMD_START_STOP_UNIT,
300 + 0, 0, 0,
301 + 0x02, /* LoEj */
302 + 0, 0, 0, 0, 0, 0, 0,
303 +@@ -55,7 +55,7 @@ static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev)
304 + unsigned int ret;
305 + struct rm_feature_desc *desc = (void *)(buf + 8);
306 + struct ata_taskfile tf;
307 +- char cdb[] = { GPCMD_GET_CONFIGURATION,
308 ++ static const char cdb[] = { GPCMD_GET_CONFIGURATION,
309 + 2, /* only 1 feature descriptor requested */
310 + 0, 3, /* 3, removable medium feature */
311 + 0, 0, 0,/* reserved */
312 +diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
313 +index 6eab52b92e01..c302f47f6323 100644
314 +--- a/drivers/atm/zatm.c
315 ++++ b/drivers/atm/zatm.c
316 +@@ -1149,8 +1149,8 @@ static void eprom_get_byte(struct zatm_dev *zatm_dev, unsigned char *byte,
317 + }
318 +
319 +
320 +-static unsigned char eprom_try_esi(struct atm_dev *dev, unsigned short cmd,
321 +- int offset, int swap)
322 ++static int eprom_try_esi(struct atm_dev *dev, unsigned short cmd, int offset,
323 ++ int swap)
324 + {
325 + unsigned char buf[ZEPROM_SIZE];
326 + struct zatm_dev *zatm_dev;
327 +diff --git a/drivers/base/core.c b/drivers/base/core.c
328 +index afe045792796..049ccc070ce5 100644
329 +--- a/drivers/base/core.c
330 ++++ b/drivers/base/core.c
331 +@@ -759,7 +759,7 @@ class_dir_create_and_add(struct class *class, struct kobject *parent_kobj)
332 +
333 + dir = kzalloc(sizeof(*dir), GFP_KERNEL);
334 + if (!dir)
335 +- return NULL;
336 ++ return ERR_PTR(-ENOMEM);
337 +
338 + dir->class = class;
339 + kobject_init(&dir->kobj, &class_dir_ktype);
340 +@@ -769,7 +769,7 @@ class_dir_create_and_add(struct class *class, struct kobject *parent_kobj)
341 + retval = kobject_add(&dir->kobj, parent_kobj, "%s", class->name);
342 + if (retval < 0) {
343 + kobject_put(&dir->kobj);
344 +- return NULL;
345 ++ return ERR_PTR(retval);
346 + }
347 + return &dir->kobj;
348 + }
349 +@@ -1076,6 +1076,10 @@ int device_add(struct device *dev)
350 +
351 + parent = get_device(dev->parent);
352 + kobj = get_device_parent(dev, parent);
353 ++ if (IS_ERR(kobj)) {
354 ++ error = PTR_ERR(kobj);
355 ++ goto parent_error;
356 ++ }
357 + if (kobj)
358 + dev->kobj.parent = kobj;
359 +
360 +@@ -1174,6 +1178,7 @@ done:
361 + kobject_del(&dev->kobj);
362 + Error:
363 + cleanup_glue_dir(dev, glue_dir);
364 ++parent_error:
365 + put_device(parent);
366 + name_error:
367 + kfree(dev->p);
368 +@@ -1990,6 +1995,11 @@ int device_move(struct device *dev, struct device *new_parent,
369 + device_pm_lock();
370 + new_parent = get_device(new_parent);
371 + new_parent_kobj = get_device_parent(dev, new_parent);
372 ++ if (IS_ERR(new_parent_kobj)) {
373 ++ error = PTR_ERR(new_parent_kobj);
374 ++ put_device(new_parent);
375 ++ goto out;
376 ++ }
377 +
378 + pr_debug("device: '%s': %s: moving to '%s'\n", dev_name(dev),
379 + __func__, new_parent ? dev_name(new_parent) : "<NULL>");
380 +diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
381 +index 8a3bf0a8c31d..476d39c7ba20 100644
382 +--- a/drivers/bluetooth/hci_qca.c
383 ++++ b/drivers/bluetooth/hci_qca.c
384 +@@ -939,6 +939,12 @@ static int qca_setup(struct hci_uart *hu)
385 + } else if (ret == -ENOENT) {
386 + /* No patch/nvm-config found, run with original fw/config */
387 + ret = 0;
388 ++ } else if (ret == -EAGAIN) {
389 ++ /*
390 ++ * Userspace firmware loader will return -EAGAIN in case no
391 ++ * patch/nvm-config is found, so run with original fw/config.
392 ++ */
393 ++ ret = 0;
394 + }
395 +
396 + /* Setup bdaddr */
397 +diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
398 +index feafdab734ae..4835b588b783 100644
399 +--- a/drivers/char/ipmi/ipmi_bt_sm.c
400 ++++ b/drivers/char/ipmi/ipmi_bt_sm.c
401 +@@ -522,11 +522,12 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
402 + if (status & BT_H_BUSY) /* clear a leftover H_BUSY */
403 + BT_CONTROL(BT_H_BUSY);
404 +
405 ++ bt->timeout = bt->BT_CAP_req2rsp;
406 ++
407 + /* Read BT capabilities if it hasn't been done yet */
408 + if (!bt->BT_CAP_outreqs)
409 + BT_STATE_CHANGE(BT_STATE_CAPABILITIES_BEGIN,
410 + SI_SM_CALL_WITHOUT_DELAY);
411 +- bt->timeout = bt->BT_CAP_req2rsp;
412 + BT_SI_SM_RETURN(SI_SM_IDLE);
413 +
414 + case BT_STATE_XACTION_START:
415 +diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
416 +index ebed319657e7..68b604ad8413 100644
417 +--- a/drivers/cpufreq/cpufreq.c
418 ++++ b/drivers/cpufreq/cpufreq.c
419 +@@ -603,6 +603,8 @@ static ssize_t store_##file_name \
420 + struct cpufreq_policy new_policy; \
421 + \
422 + memcpy(&new_policy, policy, sizeof(*policy)); \
423 ++ new_policy.min = policy->user_policy.min; \
424 ++ new_policy.max = policy->user_policy.max; \
425 + \
426 + ret = sscanf(buf, "%u", &new_policy.object); \
427 + if (ret != 1) \
428 +diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
429 +index c44a843cb405..44ebda8bbc84 100644
430 +--- a/drivers/cpuidle/cpuidle-powernv.c
431 ++++ b/drivers/cpuidle/cpuidle-powernv.c
432 +@@ -29,9 +29,31 @@ struct cpuidle_driver powernv_idle_driver = {
433 +
434 + static int max_idle_state;
435 + static struct cpuidle_state *cpuidle_state_table;
436 +-static u64 snooze_timeout;
437 ++static u64 default_snooze_timeout;
438 + static bool snooze_timeout_en;
439 +
440 ++static u64 get_snooze_timeout(struct cpuidle_device *dev,
441 ++ struct cpuidle_driver *drv,
442 ++ int index)
443 ++{
444 ++ int i;
445 ++
446 ++ if (unlikely(!snooze_timeout_en))
447 ++ return default_snooze_timeout;
448 ++
449 ++ for (i = index + 1; i < drv->state_count; i++) {
450 ++ struct cpuidle_state *s = &drv->states[i];
451 ++ struct cpuidle_state_usage *su = &dev->states_usage[i];
452 ++
453 ++ if (s->disabled || su->disable)
454 ++ continue;
455 ++
456 ++ return s->target_residency * tb_ticks_per_usec;
457 ++ }
458 ++
459 ++ return default_snooze_timeout;
460 ++}
461 ++
462 + static int snooze_loop(struct cpuidle_device *dev,
463 + struct cpuidle_driver *drv,
464 + int index)
465 +@@ -41,7 +63,7 @@ static int snooze_loop(struct cpuidle_device *dev,
466 + local_irq_enable();
467 + set_thread_flag(TIF_POLLING_NRFLAG);
468 +
469 +- snooze_exit_time = get_tb() + snooze_timeout;
470 ++ snooze_exit_time = get_tb() + get_snooze_timeout(dev, drv, index);
471 + ppc64_runlatch_off();
472 + while (!need_resched()) {
473 + HMT_low();
474 +@@ -286,11 +308,9 @@ static int powernv_idle_probe(void)
475 + cpuidle_state_table = powernv_states;
476 + /* Device tree can indicate more idle states */
477 + max_idle_state = powernv_add_idle_states();
478 +- if (max_idle_state > 1) {
479 ++ default_snooze_timeout = TICK_USEC * tb_ticks_per_usec;
480 ++ if (max_idle_state > 1)
481 + snooze_timeout_en = true;
482 +- snooze_timeout = powernv_states[1].target_residency *
483 +- tb_ticks_per_usec;
484 +- }
485 + } else
486 + return -ENODEV;
487 +
488 +diff --git a/drivers/iio/buffer/kfifo_buf.c b/drivers/iio/buffer/kfifo_buf.c
489 +index 7ef9b13262a8..e44181f9eb36 100644
490 +--- a/drivers/iio/buffer/kfifo_buf.c
491 ++++ b/drivers/iio/buffer/kfifo_buf.c
492 +@@ -19,7 +19,7 @@ struct iio_kfifo {
493 + #define iio_to_kfifo(r) container_of(r, struct iio_kfifo, buffer)
494 +
495 + static inline int __iio_allocate_kfifo(struct iio_kfifo *buf,
496 +- int bytes_per_datum, int length)
497 ++ size_t bytes_per_datum, unsigned int length)
498 + {
499 + if ((length == 0) || (bytes_per_datum == 0))
500 + return -EINVAL;
501 +@@ -71,7 +71,7 @@ static int iio_set_bytes_per_datum_kfifo(struct iio_buffer *r, size_t bpd)
502 + return 0;
503 + }
504 +
505 +-static int iio_set_length_kfifo(struct iio_buffer *r, int length)
506 ++static int iio_set_length_kfifo(struct iio_buffer *r, unsigned int length)
507 + {
508 + /* Avoid an invalid state */
509 + if (length < 2)
510 +diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
511 +index d862b9b7910e..199a9cdd0d12 100644
512 +--- a/drivers/infiniband/hw/mlx4/mad.c
513 ++++ b/drivers/infiniband/hw/mlx4/mad.c
514 +@@ -1780,7 +1780,6 @@ static void mlx4_ib_sqp_comp_worker(struct work_struct *work)
515 + "buf:%lld\n", wc.wr_id);
516 + break;
517 + default:
518 +- BUG_ON(1);
519 + break;
520 + }
521 + } else {
522 +diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
523 +index 7df16f74bb45..c6c75b99cf2c 100644
524 +--- a/drivers/infiniband/hw/qib/qib.h
525 ++++ b/drivers/infiniband/hw/qib/qib.h
526 +@@ -1451,8 +1451,7 @@ u64 qib_sps_ints(void);
527 + /*
528 + * dma_addr wrappers - all 0's invalid for hw
529 + */
530 +-dma_addr_t qib_map_page(struct pci_dev *, struct page *, unsigned long,
531 +- size_t, int);
532 ++int qib_map_page(struct pci_dev *d, struct page *p, dma_addr_t *daddr);
533 + const char *qib_get_unit_name(int unit);
534 +
535 + /*
536 +diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c
537 +index 24f4a782e0f4..5908fd3af00d 100644
538 +--- a/drivers/infiniband/hw/qib/qib_file_ops.c
539 ++++ b/drivers/infiniband/hw/qib/qib_file_ops.c
540 +@@ -364,6 +364,8 @@ static int qib_tid_update(struct qib_ctxtdata *rcd, struct file *fp,
541 + goto done;
542 + }
543 + for (i = 0; i < cnt; i++, vaddr += PAGE_SIZE) {
544 ++ dma_addr_t daddr;
545 ++
546 + for (; ntids--; tid++) {
547 + if (tid == tidcnt)
548 + tid = 0;
549 +@@ -380,12 +382,14 @@ static int qib_tid_update(struct qib_ctxtdata *rcd, struct file *fp,
550 + ret = -ENOMEM;
551 + break;
552 + }
553 ++ ret = qib_map_page(dd->pcidev, pagep[i], &daddr);
554 ++ if (ret)
555 ++ break;
556 ++
557 + tidlist[i] = tid + tidoff;
558 + /* we "know" system pages and TID pages are same size */
559 + dd->pageshadow[ctxttid + tid] = pagep[i];
560 +- dd->physshadow[ctxttid + tid] =
561 +- qib_map_page(dd->pcidev, pagep[i], 0, PAGE_SIZE,
562 +- PCI_DMA_FROMDEVICE);
563 ++ dd->physshadow[ctxttid + tid] = daddr;
564 + /*
565 + * don't need atomic or it's overhead
566 + */
567 +diff --git a/drivers/infiniband/hw/qib/qib_user_pages.c b/drivers/infiniband/hw/qib/qib_user_pages.c
568 +index 74f90b2619f6..ab1588ae1c85 100644
569 +--- a/drivers/infiniband/hw/qib/qib_user_pages.c
570 ++++ b/drivers/infiniband/hw/qib/qib_user_pages.c
571 +@@ -98,23 +98,27 @@ bail:
572 + *
573 + * I'm sure we won't be so lucky with other iommu's, so FIXME.
574 + */
575 +-dma_addr_t qib_map_page(struct pci_dev *hwdev, struct page *page,
576 +- unsigned long offset, size_t size, int direction)
577 ++int qib_map_page(struct pci_dev *hwdev, struct page *page, dma_addr_t *daddr)
578 + {
579 + dma_addr_t phys;
580 +
581 +- phys = pci_map_page(hwdev, page, offset, size, direction);
582 ++ phys = pci_map_page(hwdev, page, 0, PAGE_SIZE, PCI_DMA_FROMDEVICE);
583 ++ if (pci_dma_mapping_error(hwdev, phys))
584 ++ return -ENOMEM;
585 +
586 +- if (phys == 0) {
587 +- pci_unmap_page(hwdev, phys, size, direction);
588 +- phys = pci_map_page(hwdev, page, offset, size, direction);
589 ++ if (!phys) {
590 ++ pci_unmap_page(hwdev, phys, PAGE_SIZE, PCI_DMA_FROMDEVICE);
591 ++ phys = pci_map_page(hwdev, page, 0, PAGE_SIZE,
592 ++ PCI_DMA_FROMDEVICE);
593 ++ if (pci_dma_mapping_error(hwdev, phys))
594 ++ return -ENOMEM;
595 + /*
596 + * FIXME: If we get 0 again, we should keep this page,
597 + * map another, then free the 0 page.
598 + */
599 + }
600 +-
601 +- return phys;
602 ++ *daddr = phys;
603 ++ return 0;
604 + }
605 +
606 + /**
607 +diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
608 +index c0ec26118732..83dd0ce3ad2a 100644
609 +--- a/drivers/input/mouse/elan_i2c.h
610 ++++ b/drivers/input/mouse/elan_i2c.h
611 +@@ -27,6 +27,8 @@
612 + #define ETP_DISABLE_POWER 0x0001
613 + #define ETP_PRESSURE_OFFSET 25
614 +
615 ++#define ETP_CALIBRATE_MAX_LEN 3
616 ++
617 + /* IAP Firmware handling */
618 + #define ETP_PRODUCT_ID_FORMAT_STRING "%d.0"
619 + #define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin"
620 +diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
621 +index aeb8250ab079..97f6e05cffce 100644
622 +--- a/drivers/input/mouse/elan_i2c_core.c
623 ++++ b/drivers/input/mouse/elan_i2c_core.c
624 +@@ -595,7 +595,7 @@ static ssize_t calibrate_store(struct device *dev,
625 + int tries = 20;
626 + int retval;
627 + int error;
628 +- u8 val[3];
629 ++ u8 val[ETP_CALIBRATE_MAX_LEN];
630 +
631 + retval = mutex_lock_interruptible(&data->sysfs_mutex);
632 + if (retval)
633 +@@ -1250,6 +1250,7 @@ static const struct acpi_device_id elan_acpi_id[] = {
634 + { "ELAN060C", 0 },
635 + { "ELAN0611", 0 },
636 + { "ELAN0612", 0 },
637 ++ { "ELAN0618", 0 },
638 + { "ELAN1000", 0 },
639 + { }
640 + };
641 +diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
642 +index 25dba1d7aa57..2ac85f5cbf31 100644
643 +--- a/drivers/input/mouse/elan_i2c_smbus.c
644 ++++ b/drivers/input/mouse/elan_i2c_smbus.c
645 +@@ -56,7 +56,7 @@
646 + static int elan_smbus_initialize(struct i2c_client *client)
647 + {
648 + u8 check[ETP_SMBUS_HELLOPACKET_LEN] = { 0x55, 0x55, 0x55, 0x55, 0x55 };
649 +- u8 values[ETP_SMBUS_HELLOPACKET_LEN] = { 0, 0, 0, 0, 0 };
650 ++ u8 values[I2C_SMBUS_BLOCK_MAX] = {0};
651 + int len, error;
652 +
653 + /* Get hello packet */
654 +@@ -117,12 +117,16 @@ static int elan_smbus_calibrate(struct i2c_client *client)
655 + static int elan_smbus_calibrate_result(struct i2c_client *client, u8 *val)
656 + {
657 + int error;
658 ++ u8 buf[I2C_SMBUS_BLOCK_MAX] = {0};
659 ++
660 ++ BUILD_BUG_ON(ETP_CALIBRATE_MAX_LEN > sizeof(buf));
661 +
662 + error = i2c_smbus_read_block_data(client,
663 +- ETP_SMBUS_CALIBRATE_QUERY, val);
664 ++ ETP_SMBUS_CALIBRATE_QUERY, buf);
665 + if (error < 0)
666 + return error;
667 +
668 ++ memcpy(val, buf, ETP_CALIBRATE_MAX_LEN);
669 + return 0;
670 + }
671 +
672 +@@ -466,6 +470,8 @@ static int elan_smbus_get_report(struct i2c_client *client, u8 *report)
673 + {
674 + int len;
675 +
676 ++ BUILD_BUG_ON(I2C_SMBUS_BLOCK_MAX > ETP_SMBUS_REPORT_LEN);
677 ++
678 + len = i2c_smbus_read_block_data(client,
679 + ETP_SMBUS_PACKET_QUERY,
680 + &report[ETP_SMBUS_REPORT_OFFSET]);
681 +diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
682 +index 06ea28e5d7b4..174bb52c578b 100644
683 +--- a/drivers/input/mouse/elantech.c
684 ++++ b/drivers/input/mouse/elantech.c
685 +@@ -804,7 +804,7 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
686 + else if (ic_version == 7 && etd->samples[1] == 0x2A)
687 + sanity_check = ((packet[3] & 0x1c) == 0x10);
688 + else
689 +- sanity_check = ((packet[0] & 0x0c) == 0x04 &&
690 ++ sanity_check = ((packet[0] & 0x08) == 0x00 &&
691 + (packet[3] & 0x1c) == 0x10);
692 +
693 + if (!sanity_check)
694 +@@ -1177,6 +1177,12 @@ static const struct dmi_system_id elantech_dmi_has_middle_button[] = {
695 + { }
696 + };
697 +
698 ++static const char * const middle_button_pnp_ids[] = {
699 ++ "LEN2131", /* ThinkPad P52 w/ NFC */
700 ++ "LEN2132", /* ThinkPad P52 */
701 ++ NULL
702 ++};
703 ++
704 + /*
705 + * Set the appropriate event bits for the input subsystem
706 + */
707 +@@ -1196,7 +1202,8 @@ static int elantech_set_input_params(struct psmouse *psmouse)
708 + __clear_bit(EV_REL, dev->evbit);
709 +
710 + __set_bit(BTN_LEFT, dev->keybit);
711 +- if (dmi_check_system(elantech_dmi_has_middle_button))
712 ++ if (dmi_check_system(elantech_dmi_has_middle_button) ||
713 ++ psmouse_matches_pnp_id(psmouse, middle_button_pnp_ids))
714 + __set_bit(BTN_MIDDLE, dev->keybit);
715 + __set_bit(BTN_RIGHT, dev->keybit);
716 +
717 +diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
718 +index a1cc797fe88f..315767e8ae4d 100644
719 +--- a/drivers/md/dm-thin.c
720 ++++ b/drivers/md/dm-thin.c
721 +@@ -1299,6 +1299,8 @@ static void schedule_external_copy(struct thin_c *tc, dm_block_t virt_block,
722 +
723 + static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
724 +
725 ++static void requeue_bios(struct pool *pool);
726 ++
727 + static void check_for_space(struct pool *pool)
728 + {
729 + int r;
730 +@@ -1311,8 +1313,10 @@ static void check_for_space(struct pool *pool)
731 + if (r)
732 + return;
733 +
734 +- if (nr_free)
735 ++ if (nr_free) {
736 + set_pool_mode(pool, PM_WRITE);
737 ++ requeue_bios(pool);
738 ++ }
739 + }
740 +
741 + /*
742 +@@ -1389,7 +1393,10 @@ static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
743 +
744 + r = dm_pool_alloc_data_block(pool->pmd, result);
745 + if (r) {
746 +- metadata_operation_failed(pool, "dm_pool_alloc_data_block", r);
747 ++ if (r == -ENOSPC)
748 ++ set_pool_mode(pool, PM_OUT_OF_DATA_SPACE);
749 ++ else
750 ++ metadata_operation_failed(pool, "dm_pool_alloc_data_block", r);
751 + return r;
752 + }
753 +
754 +diff --git a/drivers/md/md.c b/drivers/md/md.c
755 +index 62c3328e2a1d..0663463df2f7 100644
756 +--- a/drivers/md/md.c
757 ++++ b/drivers/md/md.c
758 +@@ -2690,7 +2690,8 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
759 + err = 0;
760 + }
761 + } else if (cmd_match(buf, "re-add")) {
762 +- if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1)) {
763 ++ if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1) &&
764 ++ rdev->saved_raid_disk >= 0) {
765 + /* clear_bit is performed _after_ all the devices
766 + * have their local Faulty bit cleared. If any writes
767 + * happen in the meantime in the local node, they
768 +@@ -8153,6 +8154,7 @@ static int remove_and_add_spares(struct mddev *mddev,
769 + if (mddev->pers->hot_remove_disk(
770 + mddev, rdev) == 0) {
771 + sysfs_unlink_rdev(mddev, rdev);
772 ++ rdev->saved_raid_disk = rdev->raid_disk;
773 + rdev->raid_disk = -1;
774 + removed++;
775 + }
776 +diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
777 +index e2a3833170e3..2c835e69c4df 100644
778 +--- a/drivers/media/dvb-core/dvb_frontend.c
779 ++++ b/drivers/media/dvb-core/dvb_frontend.c
780 +@@ -230,8 +230,20 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe,
781 + wake_up_interruptible (&events->wait_queue);
782 + }
783 +
784 ++static int dvb_frontend_test_event(struct dvb_frontend_private *fepriv,
785 ++ struct dvb_fe_events *events)
786 ++{
787 ++ int ret;
788 ++
789 ++ up(&fepriv->sem);
790 ++ ret = events->eventw != events->eventr;
791 ++ down(&fepriv->sem);
792 ++
793 ++ return ret;
794 ++}
795 ++
796 + static int dvb_frontend_get_event(struct dvb_frontend *fe,
797 +- struct dvb_frontend_event *event, int flags)
798 ++ struct dvb_frontend_event *event, int flags)
799 + {
800 + struct dvb_frontend_private *fepriv = fe->frontend_priv;
801 + struct dvb_fe_events *events = &fepriv->events;
802 +@@ -249,13 +261,8 @@ static int dvb_frontend_get_event(struct dvb_frontend *fe,
803 + if (flags & O_NONBLOCK)
804 + return -EWOULDBLOCK;
805 +
806 +- up(&fepriv->sem);
807 +-
808 +- ret = wait_event_interruptible (events->wait_queue,
809 +- events->eventw != events->eventr);
810 +-
811 +- if (down_interruptible (&fepriv->sem))
812 +- return -ERESTARTSYS;
813 ++ ret = wait_event_interruptible(events->wait_queue,
814 ++ dvb_frontend_test_event(fepriv, events));
815 +
816 + if (ret < 0)
817 + return ret;
818 +diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
819 +index 04ae21278440..77f54e4198d3 100644
820 +--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
821 ++++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
822 +@@ -864,6 +864,9 @@ struct usb_device_id cx231xx_id_table[] = {
823 + .driver_info = CX231XX_BOARD_CNXT_RDE_250},
824 + {USB_DEVICE(0x0572, 0x58A0),
825 + .driver_info = CX231XX_BOARD_CNXT_RDU_250},
826 ++ /* AverMedia DVD EZMaker 7 */
827 ++ {USB_DEVICE(0x07ca, 0xc039),
828 ++ .driver_info = CX231XX_BOARD_CNXT_VIDEO_GRABBER},
829 + {USB_DEVICE(0x2040, 0xb110),
830 + .driver_info = CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL},
831 + {USB_DEVICE(0x2040, 0xb111),
832 +diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
833 +index e0ae2f34623a..9292e35aef06 100644
834 +--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
835 ++++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
836 +@@ -864,7 +864,7 @@ static int put_v4l2_ext_controls32(struct file *file,
837 + get_user(kcontrols, &kp->controls))
838 + return -EFAULT;
839 +
840 +- if (!count)
841 ++ if (!count || count > (U32_MAX/sizeof(*ucontrols)))
842 + return 0;
843 + if (get_user(p, &up->controls))
844 + return -EFAULT;
845 +diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
846 +index fe89e5e337d5..ac867489b5a9 100644
847 +--- a/drivers/mfd/intel-lpss.c
848 ++++ b/drivers/mfd/intel-lpss.c
849 +@@ -269,11 +269,11 @@ static void intel_lpss_init_dev(const struct intel_lpss *lpss)
850 +
851 + intel_lpss_deassert_reset(lpss);
852 +
853 ++ intel_lpss_set_remap_addr(lpss);
854 ++
855 + if (!intel_lpss_has_idma(lpss))
856 + return;
857 +
858 +- intel_lpss_set_remap_addr(lpss);
859 +-
860 + /* Make sure that SPI multiblock DMA transfers are re-enabled */
861 + if (lpss->type == LPSS_DEV_SPI)
862 + writel(value, lpss->priv + LPSS_PRIV_SSP_REG);
863 +diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
864 +index 31448a2b39ae..c484ca8c909c 100644
865 +--- a/drivers/mtd/chips/cfi_cmdset_0002.c
866 ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c
867 +@@ -1878,7 +1878,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
868 + if (time_after(jiffies, timeo) && !chip_ready(map, adr))
869 + break;
870 +
871 +- if (chip_ready(map, adr)) {
872 ++ if (chip_good(map, adr, datum)) {
873 + xip_enable(map, chip, adr);
874 + goto op_done;
875 + }
876 +@@ -2533,7 +2533,7 @@ static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
877 +
878 + struct ppb_lock {
879 + struct flchip *chip;
880 +- loff_t offset;
881 ++ unsigned long adr;
882 + int locked;
883 + };
884 +
885 +@@ -2551,8 +2551,9 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
886 + unsigned long timeo;
887 + int ret;
888 +
889 ++ adr += chip->start;
890 + mutex_lock(&chip->mutex);
891 +- ret = get_chip(map, chip, adr + chip->start, FL_LOCKING);
892 ++ ret = get_chip(map, chip, adr, FL_LOCKING);
893 + if (ret) {
894 + mutex_unlock(&chip->mutex);
895 + return ret;
896 +@@ -2570,8 +2571,8 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
897 +
898 + if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) {
899 + chip->state = FL_LOCKING;
900 +- map_write(map, CMD(0xA0), chip->start + adr);
901 +- map_write(map, CMD(0x00), chip->start + adr);
902 ++ map_write(map, CMD(0xA0), adr);
903 ++ map_write(map, CMD(0x00), adr);
904 + } else if (thunk == DO_XXLOCK_ONEBLOCK_UNLOCK) {
905 + /*
906 + * Unlocking of one specific sector is not supported, so we
907 +@@ -2609,7 +2610,7 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
908 + map_write(map, CMD(0x00), chip->start);
909 +
910 + chip->state = FL_READY;
911 +- put_chip(map, chip, adr + chip->start);
912 ++ put_chip(map, chip, adr);
913 + mutex_unlock(&chip->mutex);
914 +
915 + return ret;
916 +@@ -2666,9 +2667,9 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
917 + * sectors shall be unlocked, so lets keep their locking
918 + * status at "unlocked" (locked=0) for the final re-locking.
919 + */
920 +- if ((adr < ofs) || (adr >= (ofs + len))) {
921 ++ if ((offset < ofs) || (offset >= (ofs + len))) {
922 + sect[sectors].chip = &cfi->chips[chipnum];
923 +- sect[sectors].offset = offset;
924 ++ sect[sectors].adr = adr;
925 + sect[sectors].locked = do_ppb_xxlock(
926 + map, &cfi->chips[chipnum], adr, 0,
927 + DO_XXLOCK_ONEBLOCK_GETLOCK);
928 +@@ -2682,6 +2683,8 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
929 + i++;
930 +
931 + if (adr >> cfi->chipshift) {
932 ++ if (offset >= (ofs + len))
933 ++ break;
934 + adr = 0;
935 + chipnum++;
936 +
937 +@@ -2712,7 +2715,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
938 + */
939 + for (i = 0; i < sectors; i++) {
940 + if (sect[i].locked)
941 +- do_ppb_xxlock(map, sect[i].chip, sect[i].offset, 0,
942 ++ do_ppb_xxlock(map, sect[i].chip, sect[i].adr, 0,
943 + DO_XXLOCK_ONEBLOCK_LOCK);
944 + }
945 +
946 +diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
947 +index a2e6c7848b0a..c9f5ae424af7 100644
948 +--- a/drivers/mtd/ubi/build.c
949 ++++ b/drivers/mtd/ubi/build.c
950 +@@ -1132,6 +1132,9 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
951 + */
952 + get_device(&ubi->dev);
953 +
954 ++#ifdef CONFIG_MTD_UBI_FASTMAP
955 ++ cancel_work_sync(&ubi->fm_work);
956 ++#endif
957 + ubi_debugfs_exit_dev(ubi);
958 + uif_close(ubi);
959 +
960 +diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
961 +index 75286588b823..ca9746f41ff1 100644
962 +--- a/drivers/mtd/ubi/wl.c
963 ++++ b/drivers/mtd/ubi/wl.c
964 +@@ -1479,6 +1479,7 @@ int ubi_thread(void *u)
965 + }
966 +
967 + dbg_wl("background thread \"%s\" is killed", ubi->bgt_name);
968 ++ ubi->thread_enabled = 0;
969 + return 0;
970 + }
971 +
972 +@@ -1488,9 +1489,6 @@ int ubi_thread(void *u)
973 + */
974 + static void shutdown_work(struct ubi_device *ubi)
975 + {
976 +-#ifdef CONFIG_MTD_UBI_FASTMAP
977 +- flush_work(&ubi->fm_work);
978 +-#endif
979 + while (!list_empty(&ubi->works)) {
980 + struct ubi_work *wrk;
981 +
982 +diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
983 +index 55e93b6b6d21..66560a8fcfa2 100644
984 +--- a/drivers/net/bonding/bond_options.c
985 ++++ b/drivers/net/bonding/bond_options.c
986 +@@ -1115,6 +1115,7 @@ static int bond_option_primary_set(struct bonding *bond,
987 + slave->dev->name);
988 + rcu_assign_pointer(bond->primary_slave, slave);
989 + strcpy(bond->params.primary, slave->dev->name);
990 ++ bond->force_primary = true;
991 + bond_select_active_slave(bond);
992 + goto out;
993 + }
994 +diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c
995 +index 1bd419dbda6d..0798b4adb039 100644
996 +--- a/drivers/net/ethernet/natsemi/sonic.c
997 ++++ b/drivers/net/ethernet/natsemi/sonic.c
998 +@@ -71,7 +71,7 @@ static int sonic_open(struct net_device *dev)
999 + for (i = 0; i < SONIC_NUM_RRS; i++) {
1000 + dma_addr_t laddr = dma_map_single(lp->device, skb_put(lp->rx_skb[i], SONIC_RBSIZE),
1001 + SONIC_RBSIZE, DMA_FROM_DEVICE);
1002 +- if (!laddr) {
1003 ++ if (dma_mapping_error(lp->device, laddr)) {
1004 + while(i > 0) { /* free any that were mapped successfully */
1005 + i--;
1006 + dma_unmap_single(lp->device, lp->rx_laddr[i], SONIC_RBSIZE, DMA_FROM_DEVICE);
1007 +diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
1008 +index c8e98c8e29fa..36e1377fc954 100644
1009 +--- a/drivers/net/usb/cdc_ncm.c
1010 ++++ b/drivers/net/usb/cdc_ncm.c
1011 +@@ -1075,7 +1075,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
1012 + * accordingly. Otherwise, we should check here.
1013 + */
1014 + if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END)
1015 +- delayed_ndp_size = ctx->max_ndp_size;
1016 ++ delayed_ndp_size = ALIGN(ctx->max_ndp_size, ctx->tx_ndp_modulus);
1017 + else
1018 + delayed_ndp_size = 0;
1019 +
1020 +@@ -1208,7 +1208,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
1021 + /* If requested, put NDP at end of frame. */
1022 + if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) {
1023 + nth16 = (struct usb_cdc_ncm_nth16 *)skb_out->data;
1024 +- cdc_ncm_align_tail(skb_out, ctx->tx_ndp_modulus, 0, ctx->tx_max);
1025 ++ cdc_ncm_align_tail(skb_out, ctx->tx_ndp_modulus, 0, ctx->tx_max - ctx->max_ndp_size);
1026 + nth16->wNdpIndex = cpu_to_le16(skb_out->len);
1027 + memcpy(skb_put(skb_out, ctx->max_ndp_size), ctx->delayed_ndp16, ctx->max_ndp_size);
1028 +
1029 +diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
1030 +index d72205f06a1d..3b67140eed73 100644
1031 +--- a/drivers/net/usb/qmi_wwan.c
1032 ++++ b/drivers/net/usb/qmi_wwan.c
1033 +@@ -635,6 +635,7 @@ static const struct usb_device_id products[] = {
1034 + {QMI_FIXED_INTF(0x05c6, 0x920d, 0)},
1035 + {QMI_FIXED_INTF(0x05c6, 0x920d, 5)},
1036 + {QMI_FIXED_INTF(0x0846, 0x68a2, 8)},
1037 ++ {QMI_FIXED_INTF(0x0846, 0x68d3, 8)}, /* Netgear Aircard 779S */
1038 + {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */
1039 + {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)}, /* Huawei E1820 */
1040 + {QMI_FIXED_INTF(0x1435, 0xd181, 3)}, /* Wistron NeWeb D18Q1 */
1041 +diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
1042 +index 254b0ee37039..a71187c783b7 100644
1043 +--- a/drivers/nvdimm/bus.c
1044 ++++ b/drivers/nvdimm/bus.c
1045 +@@ -237,14 +237,18 @@ int nvdimm_revalidate_disk(struct gendisk *disk)
1046 + {
1047 + struct device *dev = disk->driverfs_dev;
1048 + struct nd_region *nd_region = to_nd_region(dev->parent);
1049 +- const char *pol = nd_region->ro ? "only" : "write";
1050 ++ int disk_ro = get_disk_ro(disk);
1051 +
1052 +- if (nd_region->ro == get_disk_ro(disk))
1053 ++ /*
1054 ++ * Upgrade to read-only if the region is read-only preserve as
1055 ++ * read-only if the disk is already read-only.
1056 ++ */
1057 ++ if (disk_ro || nd_region->ro == disk_ro)
1058 + return 0;
1059 +
1060 +- dev_info(dev, "%s read-%s, marking %s read-%s\n",
1061 +- dev_name(&nd_region->dev), pol, disk->disk_name, pol);
1062 +- set_disk_ro(disk, nd_region->ro);
1063 ++ dev_info(dev, "%s read-only, marking %s read-only\n",
1064 ++ dev_name(&nd_region->dev), disk->disk_name);
1065 ++ set_disk_ro(disk, 1);
1066 +
1067 + return 0;
1068 +
1069 +diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
1070 +index e16ea5717b7f..2a547ca3d443 100644
1071 +--- a/drivers/of/unittest.c
1072 ++++ b/drivers/of/unittest.c
1073 +@@ -156,20 +156,20 @@ static void __init of_unittest_dynamic(void)
1074 + /* Add a new property - should pass*/
1075 + prop->name = "new-property";
1076 + prop->value = "new-property-data";
1077 +- prop->length = strlen(prop->value);
1078 ++ prop->length = strlen(prop->value) + 1;
1079 + unittest(of_add_property(np, prop) == 0, "Adding a new property failed\n");
1080 +
1081 + /* Try to add an existing property - should fail */
1082 + prop++;
1083 + prop->name = "new-property";
1084 + prop->value = "new-property-data-should-fail";
1085 +- prop->length = strlen(prop->value);
1086 ++ prop->length = strlen(prop->value) + 1;
1087 + unittest(of_add_property(np, prop) != 0,
1088 + "Adding an existing property should have failed\n");
1089 +
1090 + /* Try to modify an existing property - should pass */
1091 + prop->value = "modify-property-data-should-pass";
1092 +- prop->length = strlen(prop->value);
1093 ++ prop->length = strlen(prop->value) + 1;
1094 + unittest(of_update_property(np, prop) == 0,
1095 + "Updating an existing property should have passed\n");
1096 +
1097 +@@ -177,7 +177,7 @@ static void __init of_unittest_dynamic(void)
1098 + prop++;
1099 + prop->name = "modify-property";
1100 + prop->value = "modify-missing-property-data-should-pass";
1101 +- prop->length = strlen(prop->value);
1102 ++ prop->length = strlen(prop->value) + 1;
1103 + unittest(of_update_property(np, prop) == 0,
1104 + "Updating a missing property should have passed\n");
1105 +
1106 +diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
1107 +index 62d6fe6c3714..cbe58480b474 100644
1108 +--- a/drivers/pci/hotplug/pciehp.h
1109 ++++ b/drivers/pci/hotplug/pciehp.h
1110 +@@ -134,7 +134,7 @@ struct controller *pcie_init(struct pcie_device *dev);
1111 + int pcie_init_notification(struct controller *ctrl);
1112 + int pciehp_enable_slot(struct slot *p_slot);
1113 + int pciehp_disable_slot(struct slot *p_slot);
1114 +-void pcie_enable_notification(struct controller *ctrl);
1115 ++void pcie_reenable_notification(struct controller *ctrl);
1116 + int pciehp_power_on_slot(struct slot *slot);
1117 + void pciehp_power_off_slot(struct slot *slot);
1118 + void pciehp_get_power_status(struct slot *slot, u8 *status);
1119 +diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
1120 +index 612b21a14df5..8f6ded43760a 100644
1121 +--- a/drivers/pci/hotplug/pciehp_core.c
1122 ++++ b/drivers/pci/hotplug/pciehp_core.c
1123 +@@ -295,7 +295,7 @@ static int pciehp_resume(struct pcie_device *dev)
1124 + ctrl = get_service_data(dev);
1125 +
1126 + /* reinitialize the chipset's event detection logic */
1127 +- pcie_enable_notification(ctrl);
1128 ++ pcie_reenable_notification(ctrl);
1129 +
1130 + slot = ctrl->slot;
1131 +
1132 +diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
1133 +index 5c24e938042f..63c6c7fce3eb 100644
1134 +--- a/drivers/pci/hotplug/pciehp_hpc.c
1135 ++++ b/drivers/pci/hotplug/pciehp_hpc.c
1136 +@@ -628,7 +628,7 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
1137 + return IRQ_HANDLED;
1138 + }
1139 +
1140 +-void pcie_enable_notification(struct controller *ctrl)
1141 ++static void pcie_enable_notification(struct controller *ctrl)
1142 + {
1143 + u16 cmd, mask;
1144 +
1145 +@@ -666,6 +666,17 @@ void pcie_enable_notification(struct controller *ctrl)
1146 + pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, cmd);
1147 + }
1148 +
1149 ++void pcie_reenable_notification(struct controller *ctrl)
1150 ++{
1151 ++ /*
1152 ++ * Clear both Presence and Data Link Layer Changed to make sure
1153 ++ * those events still fire after we have re-enabled them.
1154 ++ */
1155 ++ pcie_capability_write_word(ctrl->pcie->port, PCI_EXP_SLTSTA,
1156 ++ PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC);
1157 ++ pcie_enable_notification(ctrl);
1158 ++}
1159 ++
1160 + static void pcie_disable_notification(struct controller *ctrl)
1161 + {
1162 + u16 mask;
1163 +diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
1164 +index 4534a7ce77b8..b6caad0fee24 100644
1165 +--- a/drivers/s390/scsi/zfcp_dbf.c
1166 ++++ b/drivers/s390/scsi/zfcp_dbf.c
1167 +@@ -625,6 +625,46 @@ void zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *sc,
1168 + spin_unlock_irqrestore(&dbf->scsi_lock, flags);
1169 + }
1170 +
1171 ++/**
1172 ++ * zfcp_dbf_scsi_eh() - Trace event for special cases of scsi_eh callbacks.
1173 ++ * @tag: Identifier for event.
1174 ++ * @adapter: Pointer to zfcp adapter as context for this event.
1175 ++ * @scsi_id: SCSI ID/target to indicate scope of task management function (TMF).
1176 ++ * @ret: Return value of calling function.
1177 ++ *
1178 ++ * This SCSI trace variant does not depend on any of:
1179 ++ * scsi_cmnd, zfcp_fsf_req, scsi_device.
1180 ++ */
1181 ++void zfcp_dbf_scsi_eh(char *tag, struct zfcp_adapter *adapter,
1182 ++ unsigned int scsi_id, int ret)
1183 ++{
1184 ++ struct zfcp_dbf *dbf = adapter->dbf;
1185 ++ struct zfcp_dbf_scsi *rec = &dbf->scsi_buf;
1186 ++ unsigned long flags;
1187 ++ static int const level = 1;
1188 ++
1189 ++ if (unlikely(!debug_level_enabled(adapter->dbf->scsi, level)))
1190 ++ return;
1191 ++
1192 ++ spin_lock_irqsave(&dbf->scsi_lock, flags);
1193 ++ memset(rec, 0, sizeof(*rec));
1194 ++
1195 ++ memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
1196 ++ rec->id = ZFCP_DBF_SCSI_CMND;
1197 ++ rec->scsi_result = ret; /* re-use field, int is 4 bytes and fits */
1198 ++ rec->scsi_retries = ~0;
1199 ++ rec->scsi_allowed = ~0;
1200 ++ rec->fcp_rsp_info = ~0;
1201 ++ rec->scsi_id = scsi_id;
1202 ++ rec->scsi_lun = (u32)ZFCP_DBF_INVALID_LUN;
1203 ++ rec->scsi_lun_64_hi = (u32)(ZFCP_DBF_INVALID_LUN >> 32);
1204 ++ rec->host_scribble = ~0;
1205 ++ memset(rec->scsi_opcode, 0xff, ZFCP_DBF_SCSI_OPCODE);
1206 ++
1207 ++ debug_event(dbf->scsi, level, rec, sizeof(*rec));
1208 ++ spin_unlock_irqrestore(&dbf->scsi_lock, flags);
1209 ++}
1210 ++
1211 + static debug_info_t *zfcp_dbf_reg(const char *name, int size, int rec_size)
1212 + {
1213 + struct debug_info *d;
1214 +diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
1215 +index 3b23d6754598..2abcd331b05d 100644
1216 +--- a/drivers/s390/scsi/zfcp_erp.c
1217 ++++ b/drivers/s390/scsi/zfcp_erp.c
1218 +@@ -34,11 +34,28 @@ enum zfcp_erp_steps {
1219 + ZFCP_ERP_STEP_LUN_OPENING = 0x2000,
1220 + };
1221 +
1222 ++/**
1223 ++ * enum zfcp_erp_act_type - Type of ERP action object.
1224 ++ * @ZFCP_ERP_ACTION_REOPEN_LUN: LUN recovery.
1225 ++ * @ZFCP_ERP_ACTION_REOPEN_PORT: Port recovery.
1226 ++ * @ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: Forced port recovery.
1227 ++ * @ZFCP_ERP_ACTION_REOPEN_ADAPTER: Adapter recovery.
1228 ++ * @ZFCP_ERP_ACTION_NONE: Eyecatcher pseudo flag to bitwise or-combine with
1229 ++ * either of the first four enum values.
1230 ++ * Used to indicate that an ERP action could not be
1231 ++ * set up despite a detected need for some recovery.
1232 ++ * @ZFCP_ERP_ACTION_FAILED: Eyecatcher pseudo flag to bitwise or-combine with
1233 ++ * either of the first four enum values.
1234 ++ * Used to indicate that ERP not needed because
1235 ++ * the object has ZFCP_STATUS_COMMON_ERP_FAILED.
1236 ++ */
1237 + enum zfcp_erp_act_type {
1238 + ZFCP_ERP_ACTION_REOPEN_LUN = 1,
1239 + ZFCP_ERP_ACTION_REOPEN_PORT = 2,
1240 + ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3,
1241 + ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4,
1242 ++ ZFCP_ERP_ACTION_NONE = 0xc0,
1243 ++ ZFCP_ERP_ACTION_FAILED = 0xe0,
1244 + };
1245 +
1246 + enum zfcp_erp_act_state {
1247 +@@ -125,6 +142,49 @@ static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)
1248 + }
1249 + }
1250 +
1251 ++static int zfcp_erp_handle_failed(int want, struct zfcp_adapter *adapter,
1252 ++ struct zfcp_port *port,
1253 ++ struct scsi_device *sdev)
1254 ++{
1255 ++ int need = want;
1256 ++ struct zfcp_scsi_dev *zsdev;
1257 ++
1258 ++ switch (want) {
1259 ++ case ZFCP_ERP_ACTION_REOPEN_LUN:
1260 ++ zsdev = sdev_to_zfcp(sdev);
1261 ++ if (atomic_read(&zsdev->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
1262 ++ need = 0;
1263 ++ break;
1264 ++ case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1265 ++ if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
1266 ++ need = 0;
1267 ++ break;
1268 ++ case ZFCP_ERP_ACTION_REOPEN_PORT:
1269 ++ if (atomic_read(&port->status) &
1270 ++ ZFCP_STATUS_COMMON_ERP_FAILED) {
1271 ++ need = 0;
1272 ++ /* ensure propagation of failed status to new devices */
1273 ++ zfcp_erp_set_port_status(
1274 ++ port, ZFCP_STATUS_COMMON_ERP_FAILED);
1275 ++ }
1276 ++ break;
1277 ++ case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1278 ++ if (atomic_read(&adapter->status) &
1279 ++ ZFCP_STATUS_COMMON_ERP_FAILED) {
1280 ++ need = 0;
1281 ++ /* ensure propagation of failed status to new devices */
1282 ++ zfcp_erp_set_adapter_status(
1283 ++ adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
1284 ++ }
1285 ++ break;
1286 ++ default:
1287 ++ need = 0;
1288 ++ break;
1289 ++ }
1290 ++
1291 ++ return need;
1292 ++}
1293 ++
1294 + static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter,
1295 + struct zfcp_port *port,
1296 + struct scsi_device *sdev)
1297 +@@ -248,16 +308,27 @@ static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter,
1298 + int retval = 1, need;
1299 + struct zfcp_erp_action *act;
1300 +
1301 +- if (!adapter->erp_thread)
1302 +- return -EIO;
1303 ++ need = zfcp_erp_handle_failed(want, adapter, port, sdev);
1304 ++ if (!need) {
1305 ++ need = ZFCP_ERP_ACTION_FAILED; /* marker for trace */
1306 ++ goto out;
1307 ++ }
1308 ++
1309 ++ if (!adapter->erp_thread) {
1310 ++ need = ZFCP_ERP_ACTION_NONE; /* marker for trace */
1311 ++ retval = -EIO;
1312 ++ goto out;
1313 ++ }
1314 +
1315 + need = zfcp_erp_required_act(want, adapter, port, sdev);
1316 + if (!need)
1317 + goto out;
1318 +
1319 + act = zfcp_erp_setup_act(need, act_status, adapter, port, sdev);
1320 +- if (!act)
1321 ++ if (!act) {
1322 ++ need |= ZFCP_ERP_ACTION_NONE; /* marker for trace */
1323 + goto out;
1324 ++ }
1325 + atomic_or(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status);
1326 + ++adapter->erp_total_count;
1327 + list_add_tail(&act->list, &adapter->erp_ready_head);
1328 +@@ -268,18 +339,32 @@ static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter,
1329 + return retval;
1330 + }
1331 +
1332 ++void zfcp_erp_port_forced_no_port_dbf(char *id, struct zfcp_adapter *adapter,
1333 ++ u64 port_name, u32 port_id)
1334 ++{
1335 ++ unsigned long flags;
1336 ++ static /* don't waste stack */ struct zfcp_port tmpport;
1337 ++
1338 ++ write_lock_irqsave(&adapter->erp_lock, flags);
1339 ++ /* Stand-in zfcp port with fields just good enough for
1340 ++ * zfcp_dbf_rec_trig() and zfcp_dbf_set_common().
1341 ++ * Under lock because tmpport is static.
1342 ++ */
1343 ++ atomic_set(&tmpport.status, -1); /* unknown */
1344 ++ tmpport.wwpn = port_name;
1345 ++ tmpport.d_id = port_id;
1346 ++ zfcp_dbf_rec_trig(id, adapter, &tmpport, NULL,
1347 ++ ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
1348 ++ ZFCP_ERP_ACTION_NONE);
1349 ++ write_unlock_irqrestore(&adapter->erp_lock, flags);
1350 ++}
1351 ++
1352 + static int _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter,
1353 + int clear_mask, char *id)
1354 + {
1355 + zfcp_erp_adapter_block(adapter, clear_mask);
1356 + zfcp_scsi_schedule_rports_block(adapter);
1357 +
1358 +- /* ensure propagation of failed status to new devices */
1359 +- if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
1360 +- zfcp_erp_set_adapter_status(adapter,
1361 +- ZFCP_STATUS_COMMON_ERP_FAILED);
1362 +- return -EIO;
1363 +- }
1364 + return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER,
1365 + adapter, NULL, NULL, id, 0);
1366 + }
1367 +@@ -298,12 +383,8 @@ void zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear, char *id)
1368 + zfcp_scsi_schedule_rports_block(adapter);
1369 +
1370 + write_lock_irqsave(&adapter->erp_lock, flags);
1371 +- if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
1372 +- zfcp_erp_set_adapter_status(adapter,
1373 +- ZFCP_STATUS_COMMON_ERP_FAILED);
1374 +- else
1375 +- zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, adapter,
1376 +- NULL, NULL, id, 0);
1377 ++ zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, adapter,
1378 ++ NULL, NULL, id, 0);
1379 + write_unlock_irqrestore(&adapter->erp_lock, flags);
1380 + }
1381 +
1382 +@@ -344,9 +425,6 @@ static void _zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear,
1383 + zfcp_erp_port_block(port, clear);
1384 + zfcp_scsi_schedule_rport_block(port);
1385 +
1386 +- if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
1387 +- return;
1388 +-
1389 + zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
1390 + port->adapter, port, NULL, id, 0);
1391 + }
1392 +@@ -372,12 +450,6 @@ static int _zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *id)
1393 + zfcp_erp_port_block(port, clear);
1394 + zfcp_scsi_schedule_rport_block(port);
1395 +
1396 +- if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
1397 +- /* ensure propagation of failed status to new devices */
1398 +- zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_ERP_FAILED);
1399 +- return -EIO;
1400 +- }
1401 +-
1402 + return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT,
1403 + port->adapter, port, NULL, id, 0);
1404 + }
1405 +@@ -417,9 +489,6 @@ static void _zfcp_erp_lun_reopen(struct scsi_device *sdev, int clear, char *id,
1406 +
1407 + zfcp_erp_lun_block(sdev, clear);
1408 +
1409 +- if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
1410 +- return;
1411 +-
1412 + zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_LUN, adapter,
1413 + zfcp_sdev->port, sdev, id, act_status);
1414 + }
1415 +diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
1416 +index 7a7984a50683..b326f05c7f89 100644
1417 +--- a/drivers/s390/scsi/zfcp_ext.h
1418 ++++ b/drivers/s390/scsi/zfcp_ext.h
1419 +@@ -52,10 +52,15 @@ extern void zfcp_dbf_san_res(char *, struct zfcp_fsf_req *);
1420 + extern void zfcp_dbf_san_in_els(char *, struct zfcp_fsf_req *);
1421 + extern void zfcp_dbf_scsi(char *, int, struct scsi_cmnd *,
1422 + struct zfcp_fsf_req *);
1423 ++extern void zfcp_dbf_scsi_eh(char *tag, struct zfcp_adapter *adapter,
1424 ++ unsigned int scsi_id, int ret);
1425 +
1426 + /* zfcp_erp.c */
1427 + extern void zfcp_erp_set_adapter_status(struct zfcp_adapter *, u32);
1428 + extern void zfcp_erp_clear_adapter_status(struct zfcp_adapter *, u32);
1429 ++extern void zfcp_erp_port_forced_no_port_dbf(char *id,
1430 ++ struct zfcp_adapter *adapter,
1431 ++ u64 port_name, u32 port_id);
1432 + extern void zfcp_erp_adapter_reopen(struct zfcp_adapter *, int, char *);
1433 + extern void zfcp_erp_adapter_shutdown(struct zfcp_adapter *, int, char *);
1434 + extern void zfcp_erp_set_port_status(struct zfcp_port *, u32);
1435 +diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
1436 +index bb99db2948ab..3afb200b2829 100644
1437 +--- a/drivers/s390/scsi/zfcp_scsi.c
1438 ++++ b/drivers/s390/scsi/zfcp_scsi.c
1439 +@@ -180,6 +180,7 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
1440 + if (abrt_req)
1441 + break;
1442 +
1443 ++ zfcp_dbf_scsi_abort("abrt_wt", scpnt, NULL);
1444 + zfcp_erp_wait(adapter);
1445 + ret = fc_block_scsi_eh(scpnt);
1446 + if (ret) {
1447 +@@ -276,6 +277,7 @@ static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags)
1448 + if (fsf_req)
1449 + break;
1450 +
1451 ++ zfcp_dbf_scsi_devreset("wait", scpnt, tm_flags, NULL);
1452 + zfcp_erp_wait(adapter);
1453 + ret = fc_block_scsi_eh(scpnt);
1454 + if (ret) {
1455 +@@ -322,15 +324,16 @@ static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
1456 + {
1457 + struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device);
1458 + struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
1459 +- int ret;
1460 ++ int ret = SUCCESS, fc_ret;
1461 +
1462 + zfcp_erp_adapter_reopen(adapter, 0, "schrh_1");
1463 + zfcp_erp_wait(adapter);
1464 +- ret = fc_block_scsi_eh(scpnt);
1465 +- if (ret)
1466 +- return ret;
1467 ++ fc_ret = fc_block_scsi_eh(scpnt);
1468 ++ if (fc_ret)
1469 ++ ret = fc_ret;
1470 +
1471 +- return SUCCESS;
1472 ++ zfcp_dbf_scsi_eh("schrh_r", adapter, ~0, ret);
1473 ++ return ret;
1474 + }
1475 +
1476 + struct scsi_transport_template *zfcp_scsi_transport_template;
1477 +@@ -600,6 +603,11 @@ static void zfcp_scsi_terminate_rport_io(struct fc_rport *rport)
1478 + if (port) {
1479 + zfcp_erp_port_forced_reopen(port, 0, "sctrpi1");
1480 + put_device(&port->dev);
1481 ++ } else {
1482 ++ zfcp_erp_port_forced_no_port_dbf(
1483 ++ "sctrpin", adapter,
1484 ++ rport->port_name /* zfcp_scsi_rport_register */,
1485 ++ rport->port_id /* zfcp_scsi_rport_register */);
1486 + }
1487 + }
1488 +
1489 +diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
1490 +index aa18c729d23a..a9eb3cd453be 100644
1491 +--- a/drivers/scsi/qla2xxx/qla_init.c
1492 ++++ b/drivers/scsi/qla2xxx/qla_init.c
1493 +@@ -3261,7 +3261,8 @@ qla2x00_iidma_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
1494 + return;
1495 +
1496 + if (fcport->fp_speed == PORT_SPEED_UNKNOWN ||
1497 +- fcport->fp_speed > ha->link_data_rate)
1498 ++ fcport->fp_speed > ha->link_data_rate ||
1499 ++ !ha->flags.gpsc_supported)
1500 + return;
1501 +
1502 + rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed,
1503 +diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
1504 +index dee1cb87d24f..04fd651f9e3e 100644
1505 +--- a/drivers/spi/spi.c
1506 ++++ b/drivers/spi/spi.c
1507 +@@ -707,8 +707,14 @@ static int spi_map_buf(struct spi_master *master, struct device *dev,
1508 + for (i = 0; i < sgs; i++) {
1509 +
1510 + if (vmalloced_buf) {
1511 +- min = min_t(size_t,
1512 +- len, desc_len - offset_in_page(buf));
1513 ++ /*
1514 ++ * Next scatterlist entry size is the minimum between
1515 ++ * the desc_len and the remaining buffer length that
1516 ++ * fits in a page.
1517 ++ */
1518 ++ min = min_t(size_t, desc_len,
1519 ++ min_t(size_t, len,
1520 ++ PAGE_SIZE - offset_in_page(buf)));
1521 + vm_page = vmalloc_to_page(buf);
1522 + if (!vm_page) {
1523 + sg_free_table(sgt);
1524 +diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
1525 +index 8dd822feb972..b63920481b1d 100644
1526 +--- a/drivers/tty/serial/sh-sci.c
1527 ++++ b/drivers/tty/serial/sh-sci.c
1528 +@@ -2419,13 +2419,12 @@ static void serial_console_write(struct console *co, const char *s,
1529 + unsigned long flags;
1530 + int locked = 1;
1531 +
1532 +- local_irq_save(flags);
1533 + if (port->sysrq)
1534 + locked = 0;
1535 + else if (oops_in_progress)
1536 +- locked = spin_trylock(&port->lock);
1537 ++ locked = spin_trylock_irqsave(&port->lock, flags);
1538 + else
1539 +- spin_lock(&port->lock);
1540 ++ spin_lock_irqsave(&port->lock, flags);
1541 +
1542 + /* first save the SCSCR then disable the interrupts */
1543 + ctrl = serial_port_in(port, SCSCR);
1544 +@@ -2442,8 +2441,7 @@ static void serial_console_write(struct console *co, const char *s,
1545 + serial_port_out(port, SCSCR, ctrl);
1546 +
1547 + if (locked)
1548 +- spin_unlock(&port->lock);
1549 +- local_irq_restore(flags);
1550 ++ spin_unlock_irqrestore(&port->lock, flags);
1551 + }
1552 +
1553 + static int serial_console_setup(struct console *co, char *options)
1554 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
1555 +index 6d84f6c8fbe6..4d86da0df131 100644
1556 +--- a/drivers/usb/core/hub.c
1557 ++++ b/drivers/usb/core/hub.c
1558 +@@ -4442,7 +4442,9 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
1559 + * reset. But only on the first attempt,
1560 + * lest we get into a time out/reset loop
1561 + */
1562 +- if (r == 0 || (r == -ETIMEDOUT && retries == 0))
1563 ++ if (r == 0 || (r == -ETIMEDOUT &&
1564 ++ retries == 0 &&
1565 ++ udev->speed > USB_SPEED_FULL))
1566 + break;
1567 + }
1568 + udev->descriptor.bMaxPacketSize0 =
1569 +diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
1570 +index 494823f21c28..7ec66f1db418 100644
1571 +--- a/drivers/usb/musb/musb_host.c
1572 ++++ b/drivers/usb/musb/musb_host.c
1573 +@@ -2580,8 +2580,11 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
1574 + {
1575 + struct musb *musb = hcd_to_musb(hcd);
1576 + u8 devctl;
1577 ++ int ret;
1578 +
1579 +- musb_port_suspend(musb, true);
1580 ++ ret = musb_port_suspend(musb, true);
1581 ++ if (ret)
1582 ++ return ret;
1583 +
1584 + if (!is_host_active(musb))
1585 + return 0;
1586 +diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
1587 +index 7bbf01bf4bb0..54d02ed032df 100644
1588 +--- a/drivers/usb/musb/musb_host.h
1589 ++++ b/drivers/usb/musb/musb_host.h
1590 +@@ -92,7 +92,7 @@ extern void musb_host_rx(struct musb *, u8);
1591 + extern void musb_root_disconnect(struct musb *musb);
1592 + extern void musb_host_resume_root_hub(struct musb *musb);
1593 + extern void musb_host_poke_root_hub(struct musb *musb);
1594 +-extern void musb_port_suspend(struct musb *musb, bool do_suspend);
1595 ++extern int musb_port_suspend(struct musb *musb, bool do_suspend);
1596 + extern void musb_port_reset(struct musb *musb, bool do_reset);
1597 + extern void musb_host_finish_resume(struct work_struct *work);
1598 + #else
1599 +@@ -124,7 +124,10 @@ static inline void musb_root_disconnect(struct musb *musb) {}
1600 + static inline void musb_host_resume_root_hub(struct musb *musb) {}
1601 + static inline void musb_host_poll_rh_status(struct musb *musb) {}
1602 + static inline void musb_host_poke_root_hub(struct musb *musb) {}
1603 +-static inline void musb_port_suspend(struct musb *musb, bool do_suspend) {}
1604 ++static inline int musb_port_suspend(struct musb *musb, bool do_suspend)
1605 ++{
1606 ++ return 0;
1607 ++}
1608 + static inline void musb_port_reset(struct musb *musb, bool do_reset) {}
1609 + static inline void musb_host_finish_resume(struct work_struct *work) {}
1610 + #endif
1611 +diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
1612 +index 92d5f718659b..ac5458a69de5 100644
1613 +--- a/drivers/usb/musb/musb_virthub.c
1614 ++++ b/drivers/usb/musb/musb_virthub.c
1615 +@@ -74,14 +74,14 @@ void musb_host_finish_resume(struct work_struct *work)
1616 + spin_unlock_irqrestore(&musb->lock, flags);
1617 + }
1618 +
1619 +-void musb_port_suspend(struct musb *musb, bool do_suspend)
1620 ++int musb_port_suspend(struct musb *musb, bool do_suspend)
1621 + {
1622 + struct usb_otg *otg = musb->xceiv->otg;
1623 + u8 power;
1624 + void __iomem *mbase = musb->mregs;
1625 +
1626 + if (!is_host_active(musb))
1627 +- return;
1628 ++ return 0;
1629 +
1630 + /* NOTE: this doesn't necessarily put PHY into low power mode,
1631 + * turning off its clock; that's a function of PHY integration and
1632 +@@ -92,16 +92,20 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
1633 + if (do_suspend) {
1634 + int retries = 10000;
1635 +
1636 +- power &= ~MUSB_POWER_RESUME;
1637 +- power |= MUSB_POWER_SUSPENDM;
1638 +- musb_writeb(mbase, MUSB_POWER, power);
1639 ++ if (power & MUSB_POWER_RESUME)
1640 ++ return -EBUSY;
1641 +
1642 +- /* Needed for OPT A tests */
1643 +- power = musb_readb(mbase, MUSB_POWER);
1644 +- while (power & MUSB_POWER_SUSPENDM) {
1645 ++ if (!(power & MUSB_POWER_SUSPENDM)) {
1646 ++ power |= MUSB_POWER_SUSPENDM;
1647 ++ musb_writeb(mbase, MUSB_POWER, power);
1648 ++
1649 ++ /* Needed for OPT A tests */
1650 + power = musb_readb(mbase, MUSB_POWER);
1651 +- if (retries-- < 1)
1652 +- break;
1653 ++ while (power & MUSB_POWER_SUSPENDM) {
1654 ++ power = musb_readb(mbase, MUSB_POWER);
1655 ++ if (retries-- < 1)
1656 ++ break;
1657 ++ }
1658 + }
1659 +
1660 + dev_dbg(musb->controller, "Root port suspended, power %02x\n", power);
1661 +@@ -138,6 +142,7 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
1662 + schedule_delayed_work(&musb->finish_resume_work,
1663 + msecs_to_jiffies(USB_RESUME_TIMEOUT));
1664 + }
1665 ++ return 0;
1666 + }
1667 +
1668 + void musb_port_reset(struct musb *musb, bool do_reset)
1669 +diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c
1670 +index 734a9158946b..e55304d5cf07 100644
1671 +--- a/drivers/video/backlight/as3711_bl.c
1672 ++++ b/drivers/video/backlight/as3711_bl.c
1673 +@@ -262,10 +262,10 @@ static int as3711_bl_register(struct platform_device *pdev,
1674 + static int as3711_backlight_parse_dt(struct device *dev)
1675 + {
1676 + struct as3711_bl_pdata *pdata = dev_get_platdata(dev);
1677 +- struct device_node *bl =
1678 +- of_find_node_by_name(dev->parent->of_node, "backlight"), *fb;
1679 ++ struct device_node *bl, *fb;
1680 + int ret;
1681 +
1682 ++ bl = of_get_child_by_name(dev->parent->of_node, "backlight");
1683 + if (!bl) {
1684 + dev_dbg(dev, "backlight node not found\n");
1685 + return -ENODEV;
1686 +@@ -279,7 +279,7 @@ static int as3711_backlight_parse_dt(struct device *dev)
1687 + if (pdata->su1_max_uA <= 0)
1688 + ret = -EINVAL;
1689 + if (ret < 0)
1690 +- return ret;
1691 ++ goto err_put_bl;
1692 + }
1693 +
1694 + fb = of_parse_phandle(bl, "su2-dev", 0);
1695 +@@ -292,7 +292,7 @@ static int as3711_backlight_parse_dt(struct device *dev)
1696 + if (pdata->su2_max_uA <= 0)
1697 + ret = -EINVAL;
1698 + if (ret < 0)
1699 +- return ret;
1700 ++ goto err_put_bl;
1701 +
1702 + if (of_find_property(bl, "su2-feedback-voltage", NULL)) {
1703 + pdata->su2_feedback = AS3711_SU2_VOLTAGE;
1704 +@@ -314,8 +314,10 @@ static int as3711_backlight_parse_dt(struct device *dev)
1705 + pdata->su2_feedback = AS3711_SU2_CURR_AUTO;
1706 + count++;
1707 + }
1708 +- if (count != 1)
1709 +- return -EINVAL;
1710 ++ if (count != 1) {
1711 ++ ret = -EINVAL;
1712 ++ goto err_put_bl;
1713 ++ }
1714 +
1715 + count = 0;
1716 + if (of_find_property(bl, "su2-fbprot-lx-sd4", NULL)) {
1717 +@@ -334,8 +336,10 @@ static int as3711_backlight_parse_dt(struct device *dev)
1718 + pdata->su2_fbprot = AS3711_SU2_GPIO4;
1719 + count++;
1720 + }
1721 +- if (count != 1)
1722 +- return -EINVAL;
1723 ++ if (count != 1) {
1724 ++ ret = -EINVAL;
1725 ++ goto err_put_bl;
1726 ++ }
1727 +
1728 + count = 0;
1729 + if (of_find_property(bl, "su2-auto-curr1", NULL)) {
1730 +@@ -355,11 +359,20 @@ static int as3711_backlight_parse_dt(struct device *dev)
1731 + * At least one su2-auto-curr* must be specified iff
1732 + * AS3711_SU2_CURR_AUTO is used
1733 + */
1734 +- if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO))
1735 +- return -EINVAL;
1736 ++ if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) {
1737 ++ ret = -EINVAL;
1738 ++ goto err_put_bl;
1739 ++ }
1740 + }
1741 +
1742 ++ of_node_put(bl);
1743 ++
1744 + return 0;
1745 ++
1746 ++err_put_bl:
1747 ++ of_node_put(bl);
1748 ++
1749 ++ return ret;
1750 + }
1751 +
1752 + static int as3711_backlight_probe(struct platform_device *pdev)
1753 +diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
1754 +index 7b738d60ecc2..f3aa6088f1d9 100644
1755 +--- a/drivers/video/backlight/max8925_bl.c
1756 ++++ b/drivers/video/backlight/max8925_bl.c
1757 +@@ -116,7 +116,7 @@ static void max8925_backlight_dt_init(struct platform_device *pdev)
1758 + if (!pdata)
1759 + return;
1760 +
1761 +- np = of_find_node_by_name(nproot, "backlight");
1762 ++ np = of_get_child_by_name(nproot, "backlight");
1763 + if (!np) {
1764 + dev_err(&pdev->dev, "failed to find backlight node\n");
1765 + return;
1766 +@@ -125,6 +125,8 @@ static void max8925_backlight_dt_init(struct platform_device *pdev)
1767 + if (!of_property_read_u32(np, "maxim,max8925-dual-string", &val))
1768 + pdata->dual_string = val;
1769 +
1770 ++ of_node_put(np);
1771 ++
1772 + pdev->dev.platform_data = pdata;
1773 + }
1774 +
1775 +diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c
1776 +index 61d72bffd402..dc920e2aa094 100644
1777 +--- a/drivers/video/backlight/tps65217_bl.c
1778 ++++ b/drivers/video/backlight/tps65217_bl.c
1779 +@@ -184,11 +184,11 @@ static struct tps65217_bl_pdata *
1780 + tps65217_bl_parse_dt(struct platform_device *pdev)
1781 + {
1782 + struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
1783 +- struct device_node *node = of_node_get(tps->dev->of_node);
1784 ++ struct device_node *node;
1785 + struct tps65217_bl_pdata *pdata, *err;
1786 + u32 val;
1787 +
1788 +- node = of_find_node_by_name(node, "backlight");
1789 ++ node = of_get_child_by_name(tps->dev->of_node, "backlight");
1790 + if (!node)
1791 + return ERR_PTR(-ENODEV);
1792 +
1793 +diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
1794 +index 178ae93b7ebd..381236ff34d9 100644
1795 +--- a/drivers/video/fbdev/uvesafb.c
1796 ++++ b/drivers/video/fbdev/uvesafb.c
1797 +@@ -1059,7 +1059,8 @@ static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
1798 + info->cmap.len || cmap->start < info->cmap.start)
1799 + return -EINVAL;
1800 +
1801 +- entries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL);
1802 ++ entries = kmalloc_array(cmap->len, sizeof(*entries),
1803 ++ GFP_KERNEL);
1804 + if (!entries)
1805 + return -ENOMEM;
1806 +
1807 +diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c
1808 +index a4621757a47f..dacb5919970c 100644
1809 +--- a/drivers/w1/masters/mxc_w1.c
1810 ++++ b/drivers/w1/masters/mxc_w1.c
1811 +@@ -113,6 +113,10 @@ static int mxc_w1_probe(struct platform_device *pdev)
1812 + if (IS_ERR(mdev->clk))
1813 + return PTR_ERR(mdev->clk);
1814 +
1815 ++ err = clk_prepare_enable(mdev->clk);
1816 ++ if (err)
1817 ++ return err;
1818 ++
1819 + clkrate = clk_get_rate(mdev->clk);
1820 + if (clkrate < 10000000)
1821 + dev_warn(&pdev->dev,
1822 +@@ -126,12 +130,10 @@ static int mxc_w1_probe(struct platform_device *pdev)
1823 +
1824 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1825 + mdev->regs = devm_ioremap_resource(&pdev->dev, res);
1826 +- if (IS_ERR(mdev->regs))
1827 +- return PTR_ERR(mdev->regs);
1828 +-
1829 +- err = clk_prepare_enable(mdev->clk);
1830 +- if (err)
1831 +- return err;
1832 ++ if (IS_ERR(mdev->regs)) {
1833 ++ err = PTR_ERR(mdev->regs);
1834 ++ goto out_disable_clk;
1835 ++ }
1836 +
1837 + /* Software reset 1-Wire module */
1838 + writeb(MXC_W1_RESET_RST, mdev->regs + MXC_W1_RESET);
1839 +@@ -147,8 +149,12 @@ static int mxc_w1_probe(struct platform_device *pdev)
1840 +
1841 + err = w1_add_master_device(&mdev->bus_master);
1842 + if (err)
1843 +- clk_disable_unprepare(mdev->clk);
1844 ++ goto out_disable_clk;
1845 +
1846 ++ return 0;
1847 ++
1848 ++out_disable_clk:
1849 ++ clk_disable_unprepare(mdev->clk);
1850 + return err;
1851 + }
1852 +
1853 +diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
1854 +index 39886edfa222..88c1b8c01473 100644
1855 +--- a/drivers/w1/w1.c
1856 ++++ b/drivers/w1/w1.c
1857 +@@ -741,7 +741,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
1858 +
1859 + /* slave modules need to be loaded in a context with unlocked mutex */
1860 + mutex_unlock(&dev->mutex);
1861 +- request_module("w1-family-0x%02x", rn->family);
1862 ++ request_module("w1-family-0x%02X", rn->family);
1863 + mutex_lock(&dev->mutex);
1864 +
1865 + spin_lock(&w1_flock);
1866 +diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
1867 +index 468961c59fa5..21d679f88dfa 100644
1868 +--- a/drivers/xen/events/events_base.c
1869 ++++ b/drivers/xen/events/events_base.c
1870 +@@ -637,8 +637,6 @@ static void __unbind_from_irq(unsigned int irq)
1871 + xen_irq_info_cleanup(info);
1872 + }
1873 +
1874 +- BUG_ON(info_for_irq(irq)->type == IRQT_UNBOUND);
1875 +-
1876 + xen_free_irq(irq);
1877 + }
1878 +
1879 +diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
1880 +index 78f005f37847..dd784bcf7c96 100644
1881 +--- a/fs/binfmt_misc.c
1882 ++++ b/fs/binfmt_misc.c
1883 +@@ -369,8 +369,13 @@ static Node *create_entry(const char __user *buffer, size_t count)
1884 + s = strchr(p, del);
1885 + if (!s)
1886 + goto einval;
1887 +- *s++ = '\0';
1888 +- e->offset = simple_strtoul(p, &p, 10);
1889 ++ *s = '\0';
1890 ++ if (p != s) {
1891 ++ int r = kstrtoint(p, 10, &e->offset);
1892 ++ if (r != 0 || e->offset < 0)
1893 ++ goto einval;
1894 ++ }
1895 ++ p = s;
1896 + if (*p++)
1897 + goto einval;
1898 + pr_debug("register: offset: %#x\n", e->offset);
1899 +@@ -410,7 +415,8 @@ static Node *create_entry(const char __user *buffer, size_t count)
1900 + if (e->mask &&
1901 + string_unescape_inplace(e->mask, UNESCAPE_HEX) != e->size)
1902 + goto einval;
1903 +- if (e->size + e->offset > BINPRM_BUF_SIZE)
1904 ++ if (e->size > BINPRM_BUF_SIZE ||
1905 ++ BINPRM_BUF_SIZE - e->size < e->offset)
1906 + goto einval;
1907 + pr_debug("register: magic/mask length: %i\n", e->size);
1908 + if (USE_DEBUG) {
1909 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
1910 +index 1f01a8172308..b895be3d4311 100644
1911 +--- a/fs/btrfs/inode.c
1912 ++++ b/fs/btrfs/inode.c
1913 +@@ -1202,6 +1202,8 @@ static noinline int csum_exist_in_range(struct btrfs_root *root,
1914 + list_del(&sums->list);
1915 + kfree(sums);
1916 + }
1917 ++ if (ret < 0)
1918 ++ return ret;
1919 + return 1;
1920 + }
1921 +
1922 +@@ -1351,10 +1353,23 @@ next_slot:
1923 + goto out_check;
1924 + if (btrfs_extent_readonly(root, disk_bytenr))
1925 + goto out_check;
1926 +- if (btrfs_cross_ref_exist(trans, root, ino,
1927 ++ ret = btrfs_cross_ref_exist(trans, root, ino,
1928 + found_key.offset -
1929 +- extent_offset, disk_bytenr))
1930 ++ extent_offset, disk_bytenr);
1931 ++ if (ret) {
1932 ++ /*
1933 ++ * ret could be -EIO if the above fails to read
1934 ++ * metadata.
1935 ++ */
1936 ++ if (ret < 0) {
1937 ++ if (cow_start != (u64)-1)
1938 ++ cur_offset = cow_start;
1939 ++ goto error;
1940 ++ }
1941 ++
1942 ++ WARN_ON_ONCE(nolock);
1943 + goto out_check;
1944 ++ }
1945 + disk_bytenr += extent_offset;
1946 + disk_bytenr += cur_offset - found_key.offset;
1947 + num_bytes = min(end + 1, extent_end) - cur_offset;
1948 +@@ -1372,8 +1387,20 @@ next_slot:
1949 + * this ensure that csum for a given extent are
1950 + * either valid or do not exist.
1951 + */
1952 +- if (csum_exist_in_range(root, disk_bytenr, num_bytes))
1953 ++ ret = csum_exist_in_range(root, disk_bytenr, num_bytes);
1954 ++ if (ret) {
1955 ++ /*
1956 ++ * ret could be -EIO if the above fails to read
1957 ++ * metadata.
1958 ++ */
1959 ++ if (ret < 0) {
1960 ++ if (cow_start != (u64)-1)
1961 ++ cur_offset = cow_start;
1962 ++ goto error;
1963 ++ }
1964 ++ WARN_ON_ONCE(nolock);
1965 + goto out_check;
1966 ++ }
1967 + nocow = 1;
1968 + } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
1969 + extent_end = found_key.offset +
1970 +diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
1971 +index 4e3c889c1876..6caeb946fc1d 100644
1972 +--- a/fs/btrfs/ioctl.c
1973 ++++ b/fs/btrfs/ioctl.c
1974 +@@ -3923,11 +3923,6 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1975 + if (!(src_file.file->f_mode & FMODE_READ))
1976 + goto out_fput;
1977 +
1978 +- /* don't make the dst file partly checksummed */
1979 +- if ((BTRFS_I(src)->flags & BTRFS_INODE_NODATASUM) !=
1980 +- (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM))
1981 +- goto out_fput;
1982 +-
1983 + ret = -EISDIR;
1984 + if (S_ISDIR(src->i_mode) || S_ISDIR(inode->i_mode))
1985 + goto out_fput;
1986 +@@ -3942,6 +3937,13 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1987 + mutex_lock(&src->i_mutex);
1988 + }
1989 +
1990 ++ /* don't make the dst file partly checksummed */
1991 ++ if ((BTRFS_I(src)->flags & BTRFS_INODE_NODATASUM) !=
1992 ++ (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
1993 ++ ret = -EINVAL;
1994 ++ goto out_unlock;
1995 ++ }
1996 ++
1997 + /* determine range to clone */
1998 + ret = -EINVAL;
1999 + if (off + len > src->i_size || off + len < off)
2000 +diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
2001 +index b091d94ceef6..6dca9f937bf6 100644
2002 +--- a/fs/btrfs/scrub.c
2003 ++++ b/fs/btrfs/scrub.c
2004 +@@ -2513,7 +2513,7 @@ static int scrub_extent(struct scrub_ctx *sctx, u64 logical, u64 len,
2005 + have_csum = scrub_find_csum(sctx, logical, csum);
2006 + if (have_csum == 0)
2007 + ++sctx->stat.no_csum;
2008 +- if (sctx->is_dev_replace && !have_csum) {
2009 ++ if (0 && sctx->is_dev_replace && !have_csum) {
2010 + ret = copy_nocow_pages(sctx, logical, l,
2011 + mirror_num,
2012 + physical_for_dev_replace);
2013 +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
2014 +index 56ce7fd0f0d0..30efeb656c1e 100644
2015 +--- a/fs/ext4/inode.c
2016 ++++ b/fs/ext4/inode.c
2017 +@@ -3787,28 +3787,28 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
2018 + EXT4_BLOCK_SIZE_BITS(sb);
2019 + stop_block = (offset + length) >> EXT4_BLOCK_SIZE_BITS(sb);
2020 +
2021 +- /* If there are no blocks to remove, return now */
2022 +- if (first_block >= stop_block)
2023 +- goto out_stop;
2024 ++ /* If there are blocks to remove, do it */
2025 ++ if (stop_block > first_block) {
2026 +
2027 +- down_write(&EXT4_I(inode)->i_data_sem);
2028 +- ext4_discard_preallocations(inode);
2029 ++ down_write(&EXT4_I(inode)->i_data_sem);
2030 ++ ext4_discard_preallocations(inode);
2031 +
2032 +- ret = ext4_es_remove_extent(inode, first_block,
2033 +- stop_block - first_block);
2034 +- if (ret) {
2035 +- up_write(&EXT4_I(inode)->i_data_sem);
2036 +- goto out_stop;
2037 +- }
2038 ++ ret = ext4_es_remove_extent(inode, first_block,
2039 ++ stop_block - first_block);
2040 ++ if (ret) {
2041 ++ up_write(&EXT4_I(inode)->i_data_sem);
2042 ++ goto out_stop;
2043 ++ }
2044 +
2045 +- if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
2046 +- ret = ext4_ext_remove_space(inode, first_block,
2047 +- stop_block - 1);
2048 +- else
2049 +- ret = ext4_ind_remove_space(handle, inode, first_block,
2050 +- stop_block);
2051 ++ if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
2052 ++ ret = ext4_ext_remove_space(inode, first_block,
2053 ++ stop_block - 1);
2054 ++ else
2055 ++ ret = ext4_ind_remove_space(handle, inode, first_block,
2056 ++ stop_block);
2057 +
2058 +- up_write(&EXT4_I(inode)->i_data_sem);
2059 ++ up_write(&EXT4_I(inode)->i_data_sem);
2060 ++ }
2061 + if (IS_SYNC(inode))
2062 + ext4_handle_sync(handle);
2063 +
2064 +diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
2065 +index 74516efd874c..d2421fd38833 100644
2066 +--- a/fs/ext4/resize.c
2067 ++++ b/fs/ext4/resize.c
2068 +@@ -1903,7 +1903,7 @@ retry:
2069 + return 0;
2070 +
2071 + n_group = ext4_get_group_number(sb, n_blocks_count - 1);
2072 +- if (n_group > (0xFFFFFFFFUL / EXT4_INODES_PER_GROUP(sb))) {
2073 ++ if (n_group >= (0xFFFFFFFFUL / EXT4_INODES_PER_GROUP(sb))) {
2074 + ext4_warning(sb, "resize would cause inodes_count overflow");
2075 + return -EINVAL;
2076 + }
2077 +diff --git a/fs/fuse/control.c b/fs/fuse/control.c
2078 +index f863ac6647ac..89a4b231e79c 100644
2079 +--- a/fs/fuse/control.c
2080 ++++ b/fs/fuse/control.c
2081 +@@ -211,10 +211,11 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
2082 + if (!dentry)
2083 + return NULL;
2084 +
2085 +- fc->ctl_dentry[fc->ctl_ndents++] = dentry;
2086 + inode = new_inode(fuse_control_sb);
2087 +- if (!inode)
2088 ++ if (!inode) {
2089 ++ dput(dentry);
2090 + return NULL;
2091 ++ }
2092 +
2093 + inode->i_ino = get_next_ino();
2094 + inode->i_mode = mode;
2095 +@@ -228,6 +229,9 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
2096 + set_nlink(inode, nlink);
2097 + inode->i_private = fc;
2098 + d_add(dentry, inode);
2099 ++
2100 ++ fc->ctl_dentry[fc->ctl_ndents++] = dentry;
2101 ++
2102 + return dentry;
2103 + }
2104 +
2105 +@@ -284,7 +288,10 @@ void fuse_ctl_remove_conn(struct fuse_conn *fc)
2106 + for (i = fc->ctl_ndents - 1; i >= 0; i--) {
2107 + struct dentry *dentry = fc->ctl_dentry[i];
2108 + d_inode(dentry)->i_private = NULL;
2109 +- d_drop(dentry);
2110 ++ if (!i) {
2111 ++ /* Get rid of submounts: */
2112 ++ d_invalidate(dentry);
2113 ++ }
2114 + dput(dentry);
2115 + }
2116 + drop_nlink(d_inode(fuse_control_sb->s_root));
2117 +diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
2118 +index 5068dbf80ff8..49b7b40f7598 100644
2119 +--- a/fs/fuse/dir.c
2120 ++++ b/fs/fuse/dir.c
2121 +@@ -1609,8 +1609,19 @@ int fuse_do_setattr(struct inode *inode, struct iattr *attr,
2122 + return err;
2123 +
2124 + if (attr->ia_valid & ATTR_OPEN) {
2125 +- if (fc->atomic_o_trunc)
2126 ++ /* This is coming from open(..., ... | O_TRUNC); */
2127 ++ WARN_ON(!(attr->ia_valid & ATTR_SIZE));
2128 ++ WARN_ON(attr->ia_size != 0);
2129 ++ if (fc->atomic_o_trunc) {
2130 ++ /*
2131 ++ * No need to send request to userspace, since actual
2132 ++ * truncation has already been done by OPEN. But still
2133 ++ * need to truncate page cache.
2134 ++ */
2135 ++ i_size_write(inode, 0);
2136 ++ truncate_pagecache(inode, 0);
2137 + return 0;
2138 ++ }
2139 + file = NULL;
2140 + }
2141 +
2142 +diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
2143 +index 0d5e8e59b390..f0b73e0c6d48 100644
2144 +--- a/fs/fuse/inode.c
2145 ++++ b/fs/fuse/inode.c
2146 +@@ -1158,6 +1158,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
2147 + err_put_conn:
2148 + fuse_bdi_destroy(fc);
2149 + fuse_conn_put(fc);
2150 ++ sb->s_fs_info = NULL;
2151 + err_fput:
2152 + fput(file);
2153 + err:
2154 +diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c
2155 +index 1ee62e62ea76..c99a887100db 100644
2156 +--- a/fs/nfs/nfs4idmap.c
2157 ++++ b/fs/nfs/nfs4idmap.c
2158 +@@ -343,7 +343,7 @@ static ssize_t nfs_idmap_lookup_name(__u32 id, const char *type, char *buf,
2159 + int id_len;
2160 + ssize_t ret;
2161 +
2162 +- id_len = snprintf(id_str, sizeof(id_str), "%u", id);
2163 ++ id_len = nfs_map_numeric_to_string(id, id_str, sizeof(id_str));
2164 + ret = nfs_idmap_get_key(id_str, id_len, type, buf, buflen, idmap);
2165 + if (ret < 0)
2166 + return -EINVAL;
2167 +@@ -626,7 +626,8 @@ static int nfs_idmap_read_and_verify_message(struct idmap_msg *im,
2168 + if (strcmp(upcall->im_name, im->im_name) != 0)
2169 + break;
2170 + /* Note: here we store the NUL terminator too */
2171 +- len = sprintf(id_str, "%d", im->im_id) + 1;
2172 ++ len = 1 + nfs_map_numeric_to_string(im->im_id, id_str,
2173 ++ sizeof(id_str));
2174 + ret = nfs_idmap_instantiate(key, authkey, id_str, len);
2175 + break;
2176 + case IDMAP_CONV_IDTONAME:
2177 +diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
2178 +index 544672b440de..57e3262ec57a 100644
2179 +--- a/fs/nfsd/nfs4xdr.c
2180 ++++ b/fs/nfsd/nfs4xdr.c
2181 +@@ -3595,7 +3595,8 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
2182 + nfserr = nfserr_resource;
2183 + goto err_no_verf;
2184 + }
2185 +- maxcount = min_t(u32, readdir->rd_maxcount, INT_MAX);
2186 ++ maxcount = svc_max_payload(resp->rqstp);
2187 ++ maxcount = min_t(u32, readdir->rd_maxcount, maxcount);
2188 + /*
2189 + * Note the rfc defines rd_maxcount as the size of the
2190 + * READDIR4resok structure, which includes the verifier above
2191 +@@ -3609,7 +3610,7 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
2192 +
2193 + /* RFC 3530 14.2.24 allows us to ignore dircount when it's 0: */
2194 + if (!readdir->rd_dircount)
2195 +- readdir->rd_dircount = INT_MAX;
2196 ++ readdir->rd_dircount = svc_max_payload(resp->rqstp);
2197 +
2198 + readdir->xdr = xdr;
2199 + readdir->rd_maxcount = maxcount;
2200 +diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
2201 +index 0b9da5b6e0f9..22dba8837a86 100644
2202 +--- a/fs/ubifs/journal.c
2203 ++++ b/fs/ubifs/journal.c
2204 +@@ -1107,7 +1107,7 @@ static int recomp_data_node(const struct ubifs_info *c,
2205 + int err, len, compr_type, out_len;
2206 +
2207 + out_len = le32_to_cpu(dn->size);
2208 +- buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS);
2209 ++ buf = kmalloc_array(out_len, WORST_COMPR_FACTOR, GFP_NOFS);
2210 + if (!buf)
2211 + return -ENOMEM;
2212 +
2213 +diff --git a/fs/udf/directory.c b/fs/udf/directory.c
2214 +index c763fda257bf..637114e8c7fd 100644
2215 +--- a/fs/udf/directory.c
2216 ++++ b/fs/udf/directory.c
2217 +@@ -150,6 +150,9 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
2218 + sizeof(struct fileIdentDesc));
2219 + }
2220 + }
2221 ++ /* Got last entry outside of dir size - fs is corrupted! */
2222 ++ if (*nf_pos > dir->i_size)
2223 ++ return NULL;
2224 + return fi;
2225 + }
2226 +
2227 +diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
2228 +index fe14382f9664..1383e1c03ff2 100644
2229 +--- a/include/linux/blkdev.h
2230 ++++ b/include/linux/blkdev.h
2231 +@@ -882,8 +882,8 @@ static inline unsigned int blk_max_size_offset(struct request_queue *q,
2232 + if (!q->limits.chunk_sectors)
2233 + return q->limits.max_sectors;
2234 +
2235 +- return q->limits.chunk_sectors -
2236 +- (offset & (q->limits.chunk_sectors - 1));
2237 ++ return min(q->limits.max_sectors, (unsigned int)(q->limits.chunk_sectors -
2238 ++ (offset & (q->limits.chunk_sectors - 1))));
2239 + }
2240 +
2241 + static inline unsigned int blk_rq_get_max_sectors(struct request *rq)
2242 +diff --git a/include/linux/compiler.h b/include/linux/compiler.h
2243 +index 6fc9a6dd5ed2..0db1fa621d8a 100644
2244 +--- a/include/linux/compiler.h
2245 ++++ b/include/linux/compiler.h
2246 +@@ -111,7 +111,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
2247 + #define unlikely_notrace(x) __builtin_expect(!!(x), 0)
2248 +
2249 + #define __branch_check__(x, expect) ({ \
2250 +- int ______r; \
2251 ++ long ______r; \
2252 + static struct ftrace_branch_data \
2253 + __attribute__((__aligned__(4))) \
2254 + __attribute__((section("_ftrace_annotated_branch"))) \
2255 +diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
2256 +index 1600c55828e0..93a774ce4922 100644
2257 +--- a/include/linux/iio/buffer.h
2258 ++++ b/include/linux/iio/buffer.h
2259 +@@ -49,7 +49,7 @@ struct iio_buffer_access_funcs {
2260 + int (*request_update)(struct iio_buffer *buffer);
2261 +
2262 + int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
2263 +- int (*set_length)(struct iio_buffer *buffer, int length);
2264 ++ int (*set_length)(struct iio_buffer *buffer, unsigned int length);
2265 +
2266 + void (*release)(struct iio_buffer *buffer);
2267 +
2268 +@@ -78,8 +78,8 @@ struct iio_buffer_access_funcs {
2269 + * @watermark: [INTERN] number of datums to wait for poll/read.
2270 + */
2271 + struct iio_buffer {
2272 +- int length;
2273 +- int bytes_per_datum;
2274 ++ unsigned int length;
2275 ++ size_t bytes_per_datum;
2276 + struct attribute_group *scan_el_attrs;
2277 + long *scan_mask;
2278 + bool scan_timestamp;
2279 +diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
2280 +index 1878d0a96333..876688b5a356 100644
2281 +--- a/include/net/bluetooth/hci_core.h
2282 ++++ b/include/net/bluetooth/hci_core.h
2283 +@@ -878,7 +878,7 @@ struct hci_conn *hci_connect_le_scan(struct hci_dev *hdev, bdaddr_t *dst,
2284 + u16 conn_timeout, u8 role);
2285 + struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
2286 + u8 dst_type, u8 sec_level, u16 conn_timeout,
2287 +- u8 role);
2288 ++ u8 role, bdaddr_t *direct_rpa);
2289 + struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
2290 + u8 sec_level, u8 auth_type);
2291 + struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
2292 +diff --git a/kernel/time/time.c b/kernel/time/time.c
2293 +index 86751c68e08d..de70ac1f84d0 100644
2294 +--- a/kernel/time/time.c
2295 ++++ b/kernel/time/time.c
2296 +@@ -28,6 +28,7 @@
2297 + */
2298 +
2299 + #include <linux/export.h>
2300 ++#include <linux/kernel.h>
2301 + #include <linux/timex.h>
2302 + #include <linux/capability.h>
2303 + #include <linux/timekeeper_internal.h>
2304 +@@ -258,9 +259,10 @@ unsigned int jiffies_to_msecs(const unsigned long j)
2305 + return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);
2306 + #else
2307 + # if BITS_PER_LONG == 32
2308 +- return (HZ_TO_MSEC_MUL32 * j) >> HZ_TO_MSEC_SHR32;
2309 ++ return (HZ_TO_MSEC_MUL32 * j + (1ULL << HZ_TO_MSEC_SHR32) - 1) >>
2310 ++ HZ_TO_MSEC_SHR32;
2311 + # else
2312 +- return (j * HZ_TO_MSEC_NUM) / HZ_TO_MSEC_DEN;
2313 ++ return DIV_ROUND_UP(j * HZ_TO_MSEC_NUM, HZ_TO_MSEC_DEN);
2314 + # endif
2315 + #endif
2316 + }
2317 +diff --git a/lib/vsprintf.c b/lib/vsprintf.c
2318 +index f9cee8e1233c..646009db4198 100644
2319 +--- a/lib/vsprintf.c
2320 ++++ b/lib/vsprintf.c
2321 +@@ -1345,9 +1345,6 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
2322 + return string(buf, end, NULL, spec);
2323 +
2324 + switch (fmt[1]) {
2325 +- case 'r':
2326 +- return number(buf, end, clk_get_rate(clk), spec);
2327 +-
2328 + case 'n':
2329 + default:
2330 + #ifdef CONFIG_COMMON_CLK
2331 +diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
2332 +index 24e9410923d0..80be0ee17ff3 100644
2333 +--- a/net/bluetooth/hci_conn.c
2334 ++++ b/net/bluetooth/hci_conn.c
2335 +@@ -708,7 +708,8 @@ done:
2336 + }
2337 +
2338 + static void hci_req_add_le_create_conn(struct hci_request *req,
2339 +- struct hci_conn *conn)
2340 ++ struct hci_conn *conn,
2341 ++ bdaddr_t *direct_rpa)
2342 + {
2343 + struct hci_cp_le_create_conn cp;
2344 + struct hci_dev *hdev = conn->hdev;
2345 +@@ -716,11 +717,23 @@ static void hci_req_add_le_create_conn(struct hci_request *req,
2346 +
2347 + memset(&cp, 0, sizeof(cp));
2348 +
2349 +- /* Update random address, but set require_privacy to false so
2350 +- * that we never connect with an non-resolvable address.
2351 ++ /* If direct address was provided we use it instead of current
2352 ++ * address.
2353 + */
2354 +- if (hci_update_random_address(req, false, &own_addr_type))
2355 +- return;
2356 ++ if (direct_rpa) {
2357 ++ if (bacmp(&req->hdev->random_addr, direct_rpa))
2358 ++ hci_req_add(req, HCI_OP_LE_SET_RANDOM_ADDR, 6,
2359 ++ direct_rpa);
2360 ++
2361 ++ /* direct address is always RPA */
2362 ++ own_addr_type = ADDR_LE_DEV_RANDOM;
2363 ++ } else {
2364 ++ /* Update random address, but set require_privacy to false so
2365 ++ * that we never connect with an non-resolvable address.
2366 ++ */
2367 ++ if (hci_update_random_address(req, false, &own_addr_type))
2368 ++ return;
2369 ++ }
2370 +
2371 + /* Set window to be the same value as the interval to enable
2372 + * continuous scanning.
2373 +@@ -782,7 +795,7 @@ static void hci_req_directed_advertising(struct hci_request *req,
2374 +
2375 + struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
2376 + u8 dst_type, u8 sec_level, u16 conn_timeout,
2377 +- u8 role)
2378 ++ u8 role, bdaddr_t *direct_rpa)
2379 + {
2380 + struct hci_conn_params *params;
2381 + struct hci_conn *conn, *conn_unfinished;
2382 +@@ -913,7 +926,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
2383 + hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED);
2384 + }
2385 +
2386 +- hci_req_add_le_create_conn(&req, conn);
2387 ++ hci_req_add_le_create_conn(&req, conn, direct_rpa);
2388 +
2389 + create_conn:
2390 + err = hci_req_run(&req, create_le_conn_complete);
2391 +diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
2392 +index d57c11c1c6b5..d40d32a2c12d 100644
2393 +--- a/net/bluetooth/hci_event.c
2394 ++++ b/net/bluetooth/hci_event.c
2395 +@@ -4632,7 +4632,8 @@ static void hci_le_conn_update_complete_evt(struct hci_dev *hdev,
2396 + /* This function requires the caller holds hdev->lock */
2397 + static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
2398 + bdaddr_t *addr,
2399 +- u8 addr_type, u8 adv_type)
2400 ++ u8 addr_type, u8 adv_type,
2401 ++ bdaddr_t *direct_rpa)
2402 + {
2403 + struct hci_conn *conn;
2404 + struct hci_conn_params *params;
2405 +@@ -4683,7 +4684,8 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
2406 + }
2407 +
2408 + conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW,
2409 +- HCI_LE_AUTOCONN_TIMEOUT, HCI_ROLE_MASTER);
2410 ++ HCI_LE_AUTOCONN_TIMEOUT, HCI_ROLE_MASTER,
2411 ++ direct_rpa);
2412 + if (!IS_ERR(conn)) {
2413 + /* If HCI_AUTO_CONN_EXPLICIT is set, conn is already owned
2414 + * by higher layer that tried to connect, if no then
2415 +@@ -4780,8 +4782,13 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
2416 + bdaddr_type = irk->addr_type;
2417 + }
2418 +
2419 +- /* Check if we have been requested to connect to this device */
2420 +- conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type);
2421 ++ /* Check if we have been requested to connect to this device.
2422 ++ *
2423 ++ * direct_addr is set only for directed advertising reports (it is NULL
2424 ++ * for advertising reports) and is already verified to be RPA above.
2425 ++ */
2426 ++ conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type,
2427 ++ direct_addr);
2428 + if (conn && type == LE_ADV_IND) {
2429 + /* Store report for later inclusion by
2430 + * mgmt_device_connected
2431 +diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
2432 +index 51eab9b5baa1..9f70c267a7a5 100644
2433 +--- a/net/bridge/netfilter/ebtables.c
2434 ++++ b/net/bridge/netfilter/ebtables.c
2435 +@@ -1912,7 +1912,8 @@ static int compat_mtw_from_user(struct compat_ebt_entry_mwt *mwt,
2436 + int off, pad = 0;
2437 + unsigned int size_kern, match_size = mwt->match_size;
2438 +
2439 +- strlcpy(name, mwt->u.name, sizeof(name));
2440 ++ if (strscpy(name, mwt->u.name, sizeof(name)) < 0)
2441 ++ return -EINVAL;
2442 +
2443 + if (state->buf_kern_start)
2444 + dst = state->buf_kern_start + state->buf_kern_offset;
2445 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
2446 +index 23b95aead897..a9041915afc0 100644
2447 +--- a/net/ipv4/tcp_input.c
2448 ++++ b/net/ipv4/tcp_input.c
2449 +@@ -612,7 +612,7 @@ void tcp_rcv_space_adjust(struct sock *sk)
2450 + sk->sk_rcvbuf = rcvbuf;
2451 +
2452 + /* Make the window clamp follow along. */
2453 +- tp->window_clamp = rcvwin;
2454 ++ tp->window_clamp = tcp_win_from_space(rcvbuf);
2455 + }
2456 + }
2457 + tp->rcvq_space.space = copied;
2458 +diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
2459 +index 61c93a93f228..eeda67c3dd11 100644
2460 +--- a/net/ipv4/tcp_ipv4.c
2461 ++++ b/net/ipv4/tcp_ipv4.c
2462 +@@ -1627,6 +1627,10 @@ process:
2463 + reqsk_put(req);
2464 + goto discard_it;
2465 + }
2466 ++ if (tcp_checksum_complete(skb)) {
2467 ++ reqsk_put(req);
2468 ++ goto csum_error;
2469 ++ }
2470 + if (unlikely(sk->sk_state != TCP_LISTEN)) {
2471 + inet_csk_reqsk_queue_drop_and_put(sk, req);
2472 + goto lookup;
2473 +diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
2474 +index 74cbcc4b399c..90abe88e1b40 100644
2475 +--- a/net/ipv6/tcp_ipv6.c
2476 ++++ b/net/ipv6/tcp_ipv6.c
2477 +@@ -1415,6 +1415,10 @@ process:
2478 + reqsk_put(req);
2479 + goto discard_it;
2480 + }
2481 ++ if (tcp_checksum_complete(skb)) {
2482 ++ reqsk_put(req);
2483 ++ goto csum_error;
2484 ++ }
2485 + if (unlikely(sk->sk_state != TCP_LISTEN)) {
2486 + inet_csk_reqsk_queue_drop_and_put(sk, req);
2487 + goto lookup;
2488 +diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
2489 +index c074771a10f7..1ca0c2f3d92b 100644
2490 +--- a/net/ipv6/xfrm6_policy.c
2491 ++++ b/net/ipv6/xfrm6_policy.c
2492 +@@ -121,7 +121,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
2493 + struct flowi6 *fl6 = &fl->u.ip6;
2494 + int onlyproto = 0;
2495 + const struct ipv6hdr *hdr = ipv6_hdr(skb);
2496 +- u16 offset = sizeof(*hdr);
2497 ++ u32 offset = sizeof(*hdr);
2498 + struct ipv6_opt_hdr *exthdr;
2499 + const unsigned char *nh = skb_network_header(skb);
2500 + u16 nhoff = IP6CB(skb)->nhoff;
2501 +diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
2502 +index c0656510c4dc..3167ec76903a 100644
2503 +--- a/net/netfilter/ipvs/ip_vs_ctl.c
2504 ++++ b/net/netfilter/ipvs/ip_vs_ctl.c
2505 +@@ -2349,8 +2349,10 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
2506 + struct ipvs_sync_daemon_cfg cfg;
2507 +
2508 + memset(&cfg, 0, sizeof(cfg));
2509 +- strlcpy(cfg.mcast_ifn, dm->mcast_ifn,
2510 +- sizeof(cfg.mcast_ifn));
2511 ++ ret = -EINVAL;
2512 ++ if (strscpy(cfg.mcast_ifn, dm->mcast_ifn,
2513 ++ sizeof(cfg.mcast_ifn)) <= 0)
2514 ++ goto out_dec;
2515 + cfg.syncid = dm->syncid;
2516 + ret = start_sync_thread(ipvs, &cfg, dm->state);
2517 + } else {
2518 +@@ -2388,12 +2390,19 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
2519 + }
2520 + }
2521 +
2522 ++ if ((cmd == IP_VS_SO_SET_ADD || cmd == IP_VS_SO_SET_EDIT) &&
2523 ++ strnlen(usvc.sched_name, IP_VS_SCHEDNAME_MAXLEN) ==
2524 ++ IP_VS_SCHEDNAME_MAXLEN) {
2525 ++ ret = -EINVAL;
2526 ++ goto out_unlock;
2527 ++ }
2528 ++
2529 + /* Check for valid protocol: TCP or UDP or SCTP, even for fwmark!=0 */
2530 + if (usvc.protocol != IPPROTO_TCP && usvc.protocol != IPPROTO_UDP &&
2531 + usvc.protocol != IPPROTO_SCTP) {
2532 +- pr_err("set_ctl: invalid protocol: %d %pI4:%d %s\n",
2533 ++ pr_err("set_ctl: invalid protocol: %d %pI4:%d\n",
2534 + usvc.protocol, &usvc.addr.ip,
2535 +- ntohs(usvc.port), usvc.sched_name);
2536 ++ ntohs(usvc.port));
2537 + ret = -EFAULT;
2538 + goto out_unlock;
2539 + }
2540 +@@ -2822,7 +2831,7 @@ static const struct nla_policy ip_vs_cmd_policy[IPVS_CMD_ATTR_MAX + 1] = {
2541 + static const struct nla_policy ip_vs_daemon_policy[IPVS_DAEMON_ATTR_MAX + 1] = {
2542 + [IPVS_DAEMON_ATTR_STATE] = { .type = NLA_U32 },
2543 + [IPVS_DAEMON_ATTR_MCAST_IFN] = { .type = NLA_NUL_STRING,
2544 +- .len = IP_VS_IFNAME_MAXLEN },
2545 ++ .len = IP_VS_IFNAME_MAXLEN - 1 },
2546 + [IPVS_DAEMON_ATTR_SYNC_ID] = { .type = NLA_U32 },
2547 + [IPVS_DAEMON_ATTR_SYNC_MAXLEN] = { .type = NLA_U16 },
2548 + [IPVS_DAEMON_ATTR_MCAST_GROUP] = { .type = NLA_U32 },
2549 +@@ -2840,7 +2849,7 @@ static const struct nla_policy ip_vs_svc_policy[IPVS_SVC_ATTR_MAX + 1] = {
2550 + [IPVS_SVC_ATTR_PORT] = { .type = NLA_U16 },
2551 + [IPVS_SVC_ATTR_FWMARK] = { .type = NLA_U32 },
2552 + [IPVS_SVC_ATTR_SCHED_NAME] = { .type = NLA_NUL_STRING,
2553 +- .len = IP_VS_SCHEDNAME_MAXLEN },
2554 ++ .len = IP_VS_SCHEDNAME_MAXLEN - 1 },
2555 + [IPVS_SVC_ATTR_PE_NAME] = { .type = NLA_NUL_STRING,
2556 + .len = IP_VS_PENAME_MAXLEN },
2557 + [IPVS_SVC_ATTR_FLAGS] = { .type = NLA_BINARY,
2558 +diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
2559 +index d95cb69460f0..f9a13b67df5e 100644
2560 +--- a/net/xfrm/xfrm_policy.c
2561 ++++ b/net/xfrm/xfrm_policy.c
2562 +@@ -626,6 +626,11 @@ static void xfrm_hash_rebuild(struct work_struct *work)
2563 +
2564 + /* re-insert all policies by order of creation */
2565 + list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) {
2566 ++ if (policy->walk.dead ||
2567 ++ xfrm_policy_id2dir(policy->index) >= XFRM_POLICY_MAX) {
2568 ++ /* skip socket policies */
2569 ++ continue;
2570 ++ }
2571 + newpos = NULL;
2572 + chain = policy_hash_bysel(net, &policy->selector,
2573 + policy->family,
2574 +diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
2575 +index 9c6e10fb479f..273364c39171 100644
2576 +--- a/sound/pci/hda/hda_controller.c
2577 ++++ b/sound/pci/hda/hda_controller.c
2578 +@@ -547,8 +547,10 @@ int snd_hda_attach_pcm_stream(struct hda_bus *_bus, struct hda_codec *codec,
2579 + return err;
2580 + strlcpy(pcm->name, cpcm->name, sizeof(pcm->name));
2581 + apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
2582 +- if (apcm == NULL)
2583 ++ if (apcm == NULL) {
2584 ++ snd_device_free(chip->card, pcm);
2585 + return -ENOMEM;
2586 ++ }
2587 + apcm->chip = chip;
2588 + apcm->pcm = pcm;
2589 + apcm->codec = codec;
2590 +diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
2591 +index 9fae1d248318..cb19af145f46 100644
2592 +--- a/sound/pci/hda/patch_conexant.c
2593 ++++ b/sound/pci/hda/patch_conexant.c
2594 +@@ -851,6 +851,8 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
2595 + SND_PCI_QUIRK(0x103c, 0x8079, "HP EliteBook 840 G3", CXT_FIXUP_HP_DOCK),
2596 + SND_PCI_QUIRK(0x103c, 0x807C, "HP EliteBook 820 G3", CXT_FIXUP_HP_DOCK),
2597 + SND_PCI_QUIRK(0x103c, 0x80FD, "HP ProBook 640 G2", CXT_FIXUP_HP_DOCK),
2598 ++ SND_PCI_QUIRK(0x103c, 0x83b3, "HP EliteBook 830 G5", CXT_FIXUP_HP_DOCK),
2599 ++ SND_PCI_QUIRK(0x103c, 0x83d3, "HP ProBook 640 G4", CXT_FIXUP_HP_DOCK),
2600 + SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE),
2601 + SND_PCI_QUIRK(0x103c, 0x8115, "HP Z1 Gen3", CXT_FIXUP_HP_GATE_MIC),
2602 + SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN),
2603 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
2604 +index 580b8943b965..d706a416b587 100644
2605 +--- a/sound/pci/hda/patch_realtek.c
2606 ++++ b/sound/pci/hda/patch_realtek.c
2607 +@@ -2447,6 +2447,7 @@ static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2608 + SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2609 + SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2610 + SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2611 ++ SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
2612 + SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2613 + SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2614 + SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2615 +diff --git a/sound/soc/cirrus/edb93xx.c b/sound/soc/cirrus/edb93xx.c
2616 +index 85962657aabe..517963ef4847 100644
2617 +--- a/sound/soc/cirrus/edb93xx.c
2618 ++++ b/sound/soc/cirrus/edb93xx.c
2619 +@@ -67,7 +67,7 @@ static struct snd_soc_dai_link edb93xx_dai = {
2620 + .cpu_dai_name = "ep93xx-i2s",
2621 + .codec_name = "spi0.0",
2622 + .codec_dai_name = "cs4271-hifi",
2623 +- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF |
2624 ++ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
2625 + SND_SOC_DAIFMT_CBS_CFS,
2626 + .ops = &edb93xx_ops,
2627 + };
2628 +diff --git a/sound/soc/cirrus/ep93xx-i2s.c b/sound/soc/cirrus/ep93xx-i2s.c
2629 +index 934f8aefdd90..0dc3852c4621 100644
2630 +--- a/sound/soc/cirrus/ep93xx-i2s.c
2631 ++++ b/sound/soc/cirrus/ep93xx-i2s.c
2632 +@@ -51,7 +51,9 @@
2633 + #define EP93XX_I2S_WRDLEN_24 (1 << 0)
2634 + #define EP93XX_I2S_WRDLEN_32 (2 << 0)
2635 +
2636 +-#define EP93XX_I2S_LINCTRLDATA_R_JUST (1 << 2) /* Right justify */
2637 ++#define EP93XX_I2S_RXLINCTRLDATA_R_JUST BIT(1) /* Right justify */
2638 ++
2639 ++#define EP93XX_I2S_TXLINCTRLDATA_R_JUST BIT(2) /* Right justify */
2640 +
2641 + #define EP93XX_I2S_CLKCFG_LRS (1 << 0) /* lrclk polarity */
2642 + #define EP93XX_I2S_CLKCFG_CKP (1 << 1) /* Bit clock polarity */
2643 +@@ -170,25 +172,25 @@ static int ep93xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
2644 + unsigned int fmt)
2645 + {
2646 + struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(cpu_dai);
2647 +- unsigned int clk_cfg, lin_ctrl;
2648 ++ unsigned int clk_cfg;
2649 ++ unsigned int txlin_ctrl = 0;
2650 ++ unsigned int rxlin_ctrl = 0;
2651 +
2652 + clk_cfg = ep93xx_i2s_read_reg(info, EP93XX_I2S_RXCLKCFG);
2653 +- lin_ctrl = ep93xx_i2s_read_reg(info, EP93XX_I2S_RXLINCTRLDATA);
2654 +
2655 + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
2656 + case SND_SOC_DAIFMT_I2S:
2657 + clk_cfg |= EP93XX_I2S_CLKCFG_REL;
2658 +- lin_ctrl &= ~EP93XX_I2S_LINCTRLDATA_R_JUST;
2659 + break;
2660 +
2661 + case SND_SOC_DAIFMT_LEFT_J:
2662 + clk_cfg &= ~EP93XX_I2S_CLKCFG_REL;
2663 +- lin_ctrl &= ~EP93XX_I2S_LINCTRLDATA_R_JUST;
2664 + break;
2665 +
2666 + case SND_SOC_DAIFMT_RIGHT_J:
2667 + clk_cfg &= ~EP93XX_I2S_CLKCFG_REL;
2668 +- lin_ctrl |= EP93XX_I2S_LINCTRLDATA_R_JUST;
2669 ++ rxlin_ctrl |= EP93XX_I2S_RXLINCTRLDATA_R_JUST;
2670 ++ txlin_ctrl |= EP93XX_I2S_TXLINCTRLDATA_R_JUST;
2671 + break;
2672 +
2673 + default:
2674 +@@ -213,32 +215,32 @@ static int ep93xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
2675 + switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
2676 + case SND_SOC_DAIFMT_NB_NF:
2677 + /* Negative bit clock, lrclk low on left word */
2678 +- clk_cfg &= ~(EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_REL);
2679 ++ clk_cfg &= ~(EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_LRS);
2680 + break;
2681 +
2682 + case SND_SOC_DAIFMT_NB_IF:
2683 + /* Negative bit clock, lrclk low on right word */
2684 + clk_cfg &= ~EP93XX_I2S_CLKCFG_CKP;
2685 +- clk_cfg |= EP93XX_I2S_CLKCFG_REL;
2686 ++ clk_cfg |= EP93XX_I2S_CLKCFG_LRS;
2687 + break;
2688 +
2689 + case SND_SOC_DAIFMT_IB_NF:
2690 + /* Positive bit clock, lrclk low on left word */
2691 + clk_cfg |= EP93XX_I2S_CLKCFG_CKP;
2692 +- clk_cfg &= ~EP93XX_I2S_CLKCFG_REL;
2693 ++ clk_cfg &= ~EP93XX_I2S_CLKCFG_LRS;
2694 + break;
2695 +
2696 + case SND_SOC_DAIFMT_IB_IF:
2697 + /* Positive bit clock, lrclk low on right word */
2698 +- clk_cfg |= EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_REL;
2699 ++ clk_cfg |= EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_LRS;
2700 + break;
2701 + }
2702 +
2703 + /* Write new register values */
2704 + ep93xx_i2s_write_reg(info, EP93XX_I2S_RXCLKCFG, clk_cfg);
2705 + ep93xx_i2s_write_reg(info, EP93XX_I2S_TXCLKCFG, clk_cfg);
2706 +- ep93xx_i2s_write_reg(info, EP93XX_I2S_RXLINCTRLDATA, lin_ctrl);
2707 +- ep93xx_i2s_write_reg(info, EP93XX_I2S_TXLINCTRLDATA, lin_ctrl);
2708 ++ ep93xx_i2s_write_reg(info, EP93XX_I2S_RXLINCTRLDATA, rxlin_ctrl);
2709 ++ ep93xx_i2s_write_reg(info, EP93XX_I2S_TXLINCTRLDATA, txlin_ctrl);
2710 + return 0;
2711 + }
2712 +
2713 +diff --git a/sound/soc/cirrus/snappercl15.c b/sound/soc/cirrus/snappercl15.c
2714 +index 98089df08df6..c6737a573bc0 100644
2715 +--- a/sound/soc/cirrus/snappercl15.c
2716 ++++ b/sound/soc/cirrus/snappercl15.c
2717 +@@ -72,7 +72,7 @@ static struct snd_soc_dai_link snappercl15_dai = {
2718 + .codec_dai_name = "tlv320aic23-hifi",
2719 + .codec_name = "tlv320aic23-codec.0-001a",
2720 + .platform_name = "ep93xx-i2s",
2721 +- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF |
2722 ++ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
2723 + SND_SOC_DAIFMT_CBS_CFS,
2724 + .ops = &snappercl15_ops,
2725 + };
2726 +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
2727 +index 6a438a361592..9e784cc3e5d2 100644
2728 +--- a/sound/soc/soc-dapm.c
2729 ++++ b/sound/soc/soc-dapm.c
2730 +@@ -425,6 +425,8 @@ err_data:
2731 + static void dapm_kcontrol_free(struct snd_kcontrol *kctl)
2732 + {
2733 + struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl);
2734 ++
2735 ++ list_del(&data->paths);
2736 + kfree(data->wlist);
2737 + kfree(data);
2738 + }
2739 +diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
2740 +index 425df5c86c9c..425597186677 100644
2741 +--- a/tools/perf/util/dso.c
2742 ++++ b/tools/perf/util/dso.c
2743 +@@ -249,6 +249,8 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
2744 + if ((strncmp(name, "[kernel.kallsyms]", 17) == 0) ||
2745 + (strncmp(name, "[guest.kernel.kallsyms", 22) == 0) ||
2746 + (strncmp(name, "[vdso]", 6) == 0) ||
2747 ++ (strncmp(name, "[vdso32]", 8) == 0) ||
2748 ++ (strncmp(name, "[vdsox32]", 9) == 0) ||
2749 + (strncmp(name, "[vsyscall]", 10) == 0)) {
2750 + m->kmod = false;
2751 +
2752 +diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
2753 +index 0b540b84f8b7..dc17c881275d 100644
2754 +--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
2755 ++++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
2756 +@@ -111,6 +111,7 @@ struct intel_pt_decoder {
2757 + bool have_cyc;
2758 + bool fixup_last_mtc;
2759 + bool have_last_ip;
2760 ++ enum intel_pt_param_flags flags;
2761 + uint64_t pos;
2762 + uint64_t last_ip;
2763 + uint64_t ip;
2764 +@@ -213,6 +214,8 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params)
2765 + decoder->data = params->data;
2766 + decoder->return_compression = params->return_compression;
2767 +
2768 ++ decoder->flags = params->flags;
2769 ++
2770 + decoder->period = params->period;
2771 + decoder->period_type = params->period_type;
2772 +
2773 +@@ -1010,6 +1013,15 @@ out_no_progress:
2774 + return err;
2775 + }
2776 +
2777 ++static inline bool intel_pt_fup_with_nlip(struct intel_pt_decoder *decoder,
2778 ++ struct intel_pt_insn *intel_pt_insn,
2779 ++ uint64_t ip, int err)
2780 ++{
2781 ++ return decoder->flags & INTEL_PT_FUP_WITH_NLIP && !err &&
2782 ++ intel_pt_insn->branch == INTEL_PT_BR_INDIRECT &&
2783 ++ ip == decoder->ip + intel_pt_insn->length;
2784 ++}
2785 ++
2786 + static int intel_pt_walk_fup(struct intel_pt_decoder *decoder)
2787 + {
2788 + struct intel_pt_insn intel_pt_insn;
2789 +@@ -1022,7 +1034,8 @@ static int intel_pt_walk_fup(struct intel_pt_decoder *decoder)
2790 + err = intel_pt_walk_insn(decoder, &intel_pt_insn, ip);
2791 + if (err == INTEL_PT_RETURN)
2792 + return 0;
2793 +- if (err == -EAGAIN) {
2794 ++ if (err == -EAGAIN ||
2795 ++ intel_pt_fup_with_nlip(decoder, &intel_pt_insn, ip, err)) {
2796 + if (decoder->set_fup_tx_flags) {
2797 + decoder->set_fup_tx_flags = false;
2798 + decoder->tx_flags = decoder->fup_tx_flags;
2799 +@@ -1032,7 +1045,7 @@ static int intel_pt_walk_fup(struct intel_pt_decoder *decoder)
2800 + decoder->state.flags = decoder->fup_tx_flags;
2801 + return 0;
2802 + }
2803 +- return err;
2804 ++ return -EAGAIN;
2805 + }
2806 + decoder->set_fup_tx_flags = false;
2807 + if (err)
2808 +@@ -1268,7 +1281,6 @@ static int intel_pt_overflow(struct intel_pt_decoder *decoder)
2809 + {
2810 + intel_pt_log("ERROR: Buffer overflow\n");
2811 + intel_pt_clear_tx_flags(decoder);
2812 +- decoder->have_tma = false;
2813 + decoder->cbr = 0;
2814 + decoder->timestamp_insn_cnt = 0;
2815 + decoder->pkt_state = INTEL_PT_STATE_ERR_RESYNC;
2816 +@@ -1487,7 +1499,6 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)
2817 + case INTEL_PT_PSB:
2818 + case INTEL_PT_TSC:
2819 + case INTEL_PT_TMA:
2820 +- case INTEL_PT_CBR:
2821 + case INTEL_PT_MODE_TSX:
2822 + case INTEL_PT_BAD:
2823 + case INTEL_PT_PSBEND:
2824 +@@ -1496,6 +1507,10 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)
2825 + decoder->pkt_step = 0;
2826 + return -ENOENT;
2827 +
2828 ++ case INTEL_PT_CBR:
2829 ++ intel_pt_calc_cbr(decoder);
2830 ++ break;
2831 ++
2832 + case INTEL_PT_OVF:
2833 + return intel_pt_overflow(decoder);
2834 +
2835 +diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
2836 +index 89a3eda6a318..e420bd3be159 100644
2837 +--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
2838 ++++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
2839 +@@ -53,6 +53,14 @@ enum {
2840 + INTEL_PT_ERR_MAX,
2841 + };
2842 +
2843 ++enum intel_pt_param_flags {
2844 ++ /*
2845 ++ * FUP packet can contain next linear instruction pointer instead of
2846 ++ * current linear instruction pointer.
2847 ++ */
2848 ++ INTEL_PT_FUP_WITH_NLIP = 1 << 0,
2849 ++};
2850 ++
2851 + struct intel_pt_state {
2852 + enum intel_pt_sample_type type;
2853 + int err;
2854 +@@ -91,6 +99,7 @@ struct intel_pt_params {
2855 + unsigned int mtc_period;
2856 + uint32_t tsc_ctc_ratio_n;
2857 + uint32_t tsc_ctc_ratio_d;
2858 ++ enum intel_pt_param_flags flags;
2859 + };
2860 +
2861 + struct intel_pt_decoder;
2862 +diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
2863 +index 7528ae4f7e28..e5c6caf913f3 100644
2864 +--- a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
2865 ++++ b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
2866 +@@ -281,7 +281,7 @@ static int intel_pt_get_cyc(unsigned int byte, const unsigned char *buf,
2867 + if (len < offs)
2868 + return INTEL_PT_NEED_MORE_BYTES;
2869 + byte = buf[offs++];
2870 +- payload |= (byte >> 1) << shift;
2871 ++ payload |= ((uint64_t)byte >> 1) << shift;
2872 + }
2873 +
2874 + packet->type = INTEL_PT_CYC;
2875 +diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
2876 +index 3693cb26ec66..c8f2d084a8ce 100644
2877 +--- a/tools/perf/util/intel-pt.c
2878 ++++ b/tools/perf/util/intel-pt.c
2879 +@@ -676,6 +676,7 @@ static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt,
2880 + unsigned int queue_nr)
2881 + {
2882 + struct intel_pt_params params = { .get_trace = 0, };
2883 ++ struct perf_env *env = pt->machine->env;
2884 + struct intel_pt_queue *ptq;
2885 +
2886 + ptq = zalloc(sizeof(struct intel_pt_queue));
2887 +@@ -753,6 +754,9 @@ static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt,
2888 + }
2889 + }
2890 +
2891 ++ if (env->cpuid && !strncmp(env->cpuid, "GenuineIntel,6,92,", 18))
2892 ++ params.flags |= INTEL_PT_FUP_WITH_NLIP;
2893 ++
2894 + ptq->decoder = intel_pt_decoder_new(&params);
2895 + if (!ptq->decoder)
2896 + goto out_free;
2897 +@@ -1246,6 +1250,7 @@ static int intel_pt_sample(struct intel_pt_queue *ptq)
2898 +
2899 + if (intel_pt_is_switch_ip(ptq, state->to_ip)) {
2900 + switch (ptq->switch_state) {
2901 ++ case INTEL_PT_SS_NOT_TRACING:
2902 + case INTEL_PT_SS_UNKNOWN:
2903 + case INTEL_PT_SS_EXPECTING_SWITCH_IP:
2904 + err = intel_pt_next_tid(pt, ptq);