Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Thu, 03 Sep 2020 11:36:39
Message-Id: 1599132979.59b337eb3c3d025e0438ff4e37dfb6b3c02dc7f5.mpagano@gentoo
1 commit: 59b337eb3c3d025e0438ff4e37dfb6b3c02dc7f5
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Thu Sep 3 11:36:19 2020 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Thu Sep 3 11:36:19 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=59b337eb
7
8 Linux patch 4.14.196
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1195_linux-4.14.196.patch | 3387 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 3391 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 7d4b532..923cca1 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -823,6 +823,10 @@ Patch: 1194_linux-4.14.195.patch
21 From: https://www.kernel.org
22 Desc: Linux 4.14.195
23
24 +Patch: 1195_linux-4.14.196.patch
25 +From: https://www.kernel.org
26 +Desc: Linux 4.14.196
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/1195_linux-4.14.196.patch b/1195_linux-4.14.196.patch
33 new file mode 100644
34 index 0000000..508cd1a
35 --- /dev/null
36 +++ b/1195_linux-4.14.196.patch
37 @@ -0,0 +1,3387 @@
38 +diff --git a/Makefile b/Makefile
39 +index a5946969f4fcb..5c8b785f72919 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 4
45 + PATCHLEVEL = 14
46 +-SUBLEVEL = 195
47 ++SUBLEVEL = 196
48 + EXTRAVERSION =
49 + NAME = Petit Gorille
50 +
51 +diff --git a/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi b/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
52 +index 69ba1d79bcd5d..b24493ad44b0f 100644
53 +--- a/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
54 ++++ b/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
55 +@@ -555,7 +555,7 @@
56 + pins = "gpio63", "gpio64", "gpio65", "gpio66",
57 + "gpio67", "gpio68";
58 + drive-strength = <2>;
59 +- bias-disable;
60 ++ bias-pull-down;
61 + };
62 + };
63 + };
64 +diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
65 +index 4a8fdbb292863..0ad952e074457 100644
66 +--- a/arch/arm64/kvm/hyp/switch.c
67 ++++ b/arch/arm64/kvm/hyp/switch.c
68 +@@ -444,7 +444,7 @@ static void __hyp_text __hyp_call_panic_nvhe(u64 spsr, u64 elr, u64 par,
69 + * making sure it is a kernel address and not a PC-relative
70 + * reference.
71 + */
72 +- asm volatile("ldr %0, =__hyp_panic_string" : "=r" (str_va));
73 ++ asm volatile("ldr %0, =%1" : "=r" (str_va) : "S" (__hyp_panic_string));
74 +
75 + __hyp_do_panic(str_va,
76 + spsr, elr,
77 +diff --git a/arch/mips/vdso/genvdso.c b/arch/mips/vdso/genvdso.c
78 +index 530a36f465ced..afcc86726448e 100644
79 +--- a/arch/mips/vdso/genvdso.c
80 ++++ b/arch/mips/vdso/genvdso.c
81 +@@ -126,6 +126,7 @@ static void *map_vdso(const char *path, size_t *_size)
82 + if (fstat(fd, &stat) != 0) {
83 + fprintf(stderr, "%s: Failed to stat '%s': %s\n", program_name,
84 + path, strerror(errno));
85 ++ close(fd);
86 + return NULL;
87 + }
88 +
89 +@@ -134,6 +135,7 @@ static void *map_vdso(const char *path, size_t *_size)
90 + if (addr == MAP_FAILED) {
91 + fprintf(stderr, "%s: Failed to map '%s': %s\n", program_name,
92 + path, strerror(errno));
93 ++ close(fd);
94 + return NULL;
95 + }
96 +
97 +@@ -143,6 +145,7 @@ static void *map_vdso(const char *path, size_t *_size)
98 + if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0) {
99 + fprintf(stderr, "%s: '%s' is not an ELF file\n", program_name,
100 + path);
101 ++ close(fd);
102 + return NULL;
103 + }
104 +
105 +@@ -154,6 +157,7 @@ static void *map_vdso(const char *path, size_t *_size)
106 + default:
107 + fprintf(stderr, "%s: '%s' has invalid ELF class\n",
108 + program_name, path);
109 ++ close(fd);
110 + return NULL;
111 + }
112 +
113 +@@ -165,6 +169,7 @@ static void *map_vdso(const char *path, size_t *_size)
114 + default:
115 + fprintf(stderr, "%s: '%s' has invalid ELF data order\n",
116 + program_name, path);
117 ++ close(fd);
118 + return NULL;
119 + }
120 +
121 +@@ -172,15 +177,18 @@ static void *map_vdso(const char *path, size_t *_size)
122 + fprintf(stderr,
123 + "%s: '%s' has invalid ELF machine (expected EM_MIPS)\n",
124 + program_name, path);
125 ++ close(fd);
126 + return NULL;
127 + } else if (swap_uint16(ehdr->e_type) != ET_DYN) {
128 + fprintf(stderr,
129 + "%s: '%s' has invalid ELF type (expected ET_DYN)\n",
130 + program_name, path);
131 ++ close(fd);
132 + return NULL;
133 + }
134 +
135 + *_size = stat.st_size;
136 ++ close(fd);
137 + return addr;
138 + }
139 +
140 +@@ -284,10 +292,12 @@ int main(int argc, char **argv)
141 + /* Calculate and write symbol offsets to <output file> */
142 + if (!get_symbols(dbg_vdso_path, dbg_vdso)) {
143 + unlink(out_path);
144 ++ fclose(out_file);
145 + return EXIT_FAILURE;
146 + }
147 +
148 + fprintf(out_file, "};\n");
149 ++ fclose(out_file);
150 +
151 + return EXIT_SUCCESS;
152 + }
153 +diff --git a/arch/powerpc/kernel/cpu_setup_power.S b/arch/powerpc/kernel/cpu_setup_power.S
154 +index 9daede99c1316..f52e2c55a12b2 100644
155 +--- a/arch/powerpc/kernel/cpu_setup_power.S
156 ++++ b/arch/powerpc/kernel/cpu_setup_power.S
157 +@@ -189,7 +189,7 @@ __init_LPCR_ISA300:
158 +
159 + __init_FSCR:
160 + mfspr r3,SPRN_FSCR
161 +- ori r3,r3,FSCR_TAR|FSCR_DSCR|FSCR_EBB
162 ++ ori r3,r3,FSCR_TAR|FSCR_EBB
163 + mtspr SPRN_FSCR,r3
164 + blr
165 +
166 +diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
167 +index 3188040022c4f..78f75e48dfe7f 100644
168 +--- a/arch/powerpc/perf/core-book3s.c
169 ++++ b/arch/powerpc/perf/core-book3s.c
170 +@@ -2096,6 +2096,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
171 +
172 + if (perf_event_overflow(event, &data, regs))
173 + power_pmu_stop(event, 0);
174 ++ } else if (period) {
175 ++ /* Account for interrupt in case of invalid SIAR */
176 ++ if (perf_event_account_interrupt(event))
177 ++ power_pmu_stop(event, 0);
178 + }
179 + }
180 +
181 +diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig
182 +index 9f5958f169234..741a8fa8a3e6b 100644
183 +--- a/arch/powerpc/platforms/cell/Kconfig
184 ++++ b/arch/powerpc/platforms/cell/Kconfig
185 +@@ -46,6 +46,7 @@ config SPU_FS
186 + tristate "SPU file system"
187 + default m
188 + depends on PPC_CELL
189 ++ depends on COREDUMP
190 + select SPU_BASE
191 + help
192 + The SPU file system is used to access Synergistic Processing
193 +diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c
194 +index 30cdcbfa1c04e..b0e96f4b728c1 100644
195 +--- a/arch/powerpc/sysdev/xive/native.c
196 ++++ b/arch/powerpc/sysdev/xive/native.c
197 +@@ -22,6 +22,7 @@
198 + #include <linux/delay.h>
199 + #include <linux/cpumask.h>
200 + #include <linux/mm.h>
201 ++#include <linux/kmemleak.h>
202 +
203 + #include <asm/prom.h>
204 + #include <asm/io.h>
205 +@@ -630,6 +631,7 @@ static bool xive_native_provision_pages(void)
206 + pr_err("Failed to allocate provisioning page\n");
207 + return false;
208 + }
209 ++ kmemleak_ignore(p);
210 + opal_xive_donate_page(chip, __pa(p));
211 + }
212 + return true;
213 +diff --git a/drivers/base/core.c b/drivers/base/core.c
214 +index 93c2fc58013ed..3c14f0c4ef87f 100644
215 +--- a/drivers/base/core.c
216 ++++ b/drivers/base/core.c
217 +@@ -3074,9 +3074,9 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
218 + */
219 + void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
220 + {
221 +- if (fwnode) {
222 +- struct fwnode_handle *fn = dev->fwnode;
223 ++ struct fwnode_handle *fn = dev->fwnode;
224 +
225 ++ if (fwnode) {
226 + if (fwnode_is_primary(fn))
227 + fn = fn->secondary;
228 +
229 +@@ -3086,8 +3086,12 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
230 + }
231 + dev->fwnode = fwnode;
232 + } else {
233 +- dev->fwnode = fwnode_is_primary(dev->fwnode) ?
234 +- dev->fwnode->secondary : NULL;
235 ++ if (fwnode_is_primary(fn)) {
236 ++ dev->fwnode = fn->secondary;
237 ++ fn->secondary = NULL;
238 ++ } else {
239 ++ dev->fwnode = NULL;
240 ++ }
241 + }
242 + }
243 + EXPORT_SYMBOL_GPL(set_primary_fwnode);
244 +diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
245 +index 0e7fa1f27ad46..4fd49d55bc3e2 100644
246 +--- a/drivers/base/power/main.c
247 ++++ b/drivers/base/power/main.c
248 +@@ -1500,13 +1500,17 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
249 + }
250 +
251 + /*
252 +- * If a device configured to wake up the system from sleep states
253 +- * has been suspended at run time and there's a resume request pending
254 +- * for it, this is equivalent to the device signaling wakeup, so the
255 +- * system suspend operation should be aborted.
256 ++ * Wait for possible runtime PM transitions of the device in progress
257 ++ * to complete and if there's a runtime resume request pending for it,
258 ++ * resume it before proceeding with invoking the system-wide suspend
259 ++ * callbacks for it.
260 ++ *
261 ++ * If the system-wide suspend callbacks below change the configuration
262 ++ * of the device, they must disable runtime PM for it or otherwise
263 ++ * ensure that its runtime-resume callbacks will not be confused by that
264 ++ * change in case they are invoked going forward.
265 + */
266 +- if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
267 +- pm_wakeup_event(dev, 0);
268 ++ pm_runtime_barrier(dev);
269 +
270 + if (pm_wakeup_pending()) {
271 + dev->power.direct_complete = false;
272 +diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
273 +index b12e373aa956a..ec670a1b7e02f 100644
274 +--- a/drivers/block/null_blk.c
275 ++++ b/drivers/block/null_blk.c
276 +@@ -1135,7 +1135,7 @@ static int null_handle_rq(struct nullb_cmd *cmd)
277 + len = bvec.bv_len;
278 + err = null_transfer(nullb, bvec.bv_page, len, bvec.bv_offset,
279 + op_is_write(req_op(rq)), sector,
280 +- req_op(rq) & REQ_FUA);
281 ++ rq->cmd_flags & REQ_FUA);
282 + if (err) {
283 + spin_unlock_irq(&nullb->lock);
284 + return err;
285 +diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
286 +index dcf5bb1534955..11ec5c2715a9e 100644
287 +--- a/drivers/char/tpm/tpm-chip.c
288 ++++ b/drivers/char/tpm/tpm-chip.c
289 +@@ -247,13 +247,8 @@ struct tpm_chip *tpm_chip_alloc(struct device *pdev,
290 + chip->cdev.owner = THIS_MODULE;
291 + chip->cdevs.owner = THIS_MODULE;
292 +
293 +- chip->work_space.context_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
294 +- if (!chip->work_space.context_buf) {
295 +- rc = -ENOMEM;
296 +- goto out;
297 +- }
298 +- chip->work_space.session_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
299 +- if (!chip->work_space.session_buf) {
300 ++ rc = tpm2_init_space(&chip->work_space, TPM2_SPACE_BUFFER_SIZE);
301 ++ if (rc) {
302 + rc = -ENOMEM;
303 + goto out;
304 + }
305 +diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
306 +index d53d12f3df6d6..019fe80fedd83 100644
307 +--- a/drivers/char/tpm/tpm.h
308 ++++ b/drivers/char/tpm/tpm.h
309 +@@ -174,6 +174,7 @@ struct tpm_space {
310 + u8 *context_buf;
311 + u32 session_tbl[3];
312 + u8 *session_buf;
313 ++ u32 buf_size;
314 + };
315 +
316 + enum tpm_chip_flags {
317 +@@ -261,6 +262,9 @@ struct tpm_output_header {
318 +
319 + #define TPM_TAG_RQU_COMMAND 193
320 +
321 ++/* TPM2 specific constants. */
322 ++#define TPM2_SPACE_BUFFER_SIZE 16384 /* 16 kB */
323 ++
324 + struct stclear_flags_t {
325 + __be16 tag;
326 + u8 deactivated;
327 +@@ -583,7 +587,7 @@ void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
328 + unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
329 + int tpm2_probe(struct tpm_chip *chip);
330 + int tpm2_find_cc(struct tpm_chip *chip, u32 cc);
331 +-int tpm2_init_space(struct tpm_space *space);
332 ++int tpm2_init_space(struct tpm_space *space, unsigned int buf_size);
333 + void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space);
334 + int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u32 cc,
335 + u8 *cmd);
336 +diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
337 +index dabb2ae4e779a..115f0fb32179f 100644
338 +--- a/drivers/char/tpm/tpm2-space.c
339 ++++ b/drivers/char/tpm/tpm2-space.c
340 +@@ -44,18 +44,21 @@ static void tpm2_flush_sessions(struct tpm_chip *chip, struct tpm_space *space)
341 + }
342 + }
343 +
344 +-int tpm2_init_space(struct tpm_space *space)
345 ++int tpm2_init_space(struct tpm_space *space, unsigned int buf_size)
346 + {
347 +- space->context_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
348 ++ space->context_buf = kzalloc(buf_size, GFP_KERNEL);
349 + if (!space->context_buf)
350 + return -ENOMEM;
351 +
352 +- space->session_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
353 ++ space->session_buf = kzalloc(buf_size, GFP_KERNEL);
354 + if (space->session_buf == NULL) {
355 + kfree(space->context_buf);
356 ++ /* Prevent caller getting a dangling pointer. */
357 ++ space->context_buf = NULL;
358 + return -ENOMEM;
359 + }
360 +
361 ++ space->buf_size = buf_size;
362 + return 0;
363 + }
364 +
365 +@@ -278,8 +281,10 @@ int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u32 cc,
366 + sizeof(space->context_tbl));
367 + memcpy(&chip->work_space.session_tbl, &space->session_tbl,
368 + sizeof(space->session_tbl));
369 +- memcpy(chip->work_space.context_buf, space->context_buf, PAGE_SIZE);
370 +- memcpy(chip->work_space.session_buf, space->session_buf, PAGE_SIZE);
371 ++ memcpy(chip->work_space.context_buf, space->context_buf,
372 ++ space->buf_size);
373 ++ memcpy(chip->work_space.session_buf, space->session_buf,
374 ++ space->buf_size);
375 +
376 + rc = tpm2_load_space(chip);
377 + if (rc) {
378 +@@ -459,7 +464,7 @@ static int tpm2_save_space(struct tpm_chip *chip)
379 + continue;
380 +
381 + rc = tpm2_save_context(chip, space->context_tbl[i],
382 +- space->context_buf, PAGE_SIZE,
383 ++ space->context_buf, space->buf_size,
384 + &offset);
385 + if (rc == -ENOENT) {
386 + space->context_tbl[i] = 0;
387 +@@ -478,9 +483,8 @@ static int tpm2_save_space(struct tpm_chip *chip)
388 + continue;
389 +
390 + rc = tpm2_save_context(chip, space->session_tbl[i],
391 +- space->session_buf, PAGE_SIZE,
392 ++ space->session_buf, space->buf_size,
393 + &offset);
394 +-
395 + if (rc == -ENOENT) {
396 + /* handle error saving session, just forget it */
397 + space->session_tbl[i] = 0;
398 +@@ -526,8 +530,10 @@ int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space,
399 + sizeof(space->context_tbl));
400 + memcpy(&space->session_tbl, &chip->work_space.session_tbl,
401 + sizeof(space->session_tbl));
402 +- memcpy(space->context_buf, chip->work_space.context_buf, PAGE_SIZE);
403 +- memcpy(space->session_buf, chip->work_space.session_buf, PAGE_SIZE);
404 ++ memcpy(space->context_buf, chip->work_space.context_buf,
405 ++ space->buf_size);
406 ++ memcpy(space->session_buf, chip->work_space.session_buf,
407 ++ space->buf_size);
408 +
409 + return 0;
410 + }
411 +diff --git a/drivers/char/tpm/tpmrm-dev.c b/drivers/char/tpm/tpmrm-dev.c
412 +index 1a0e97a5da5a4..162fb16243d03 100644
413 +--- a/drivers/char/tpm/tpmrm-dev.c
414 ++++ b/drivers/char/tpm/tpmrm-dev.c
415 +@@ -22,7 +22,7 @@ static int tpmrm_open(struct inode *inode, struct file *file)
416 + if (priv == NULL)
417 + return -ENOMEM;
418 +
419 +- rc = tpm2_init_space(&priv->space);
420 ++ rc = tpm2_init_space(&priv->space, TPM2_SPACE_BUFFER_SIZE);
421 + if (rc) {
422 + kfree(priv);
423 + return -ENOMEM;
424 +diff --git a/drivers/edac/ie31200_edac.c b/drivers/edac/ie31200_edac.c
425 +index aac9b9b360b80..9e4781a807cfa 100644
426 +--- a/drivers/edac/ie31200_edac.c
427 ++++ b/drivers/edac/ie31200_edac.c
428 +@@ -147,6 +147,8 @@
429 + (n << (28 + (2 * skl) - PAGE_SHIFT))
430 +
431 + static int nr_channels;
432 ++static struct pci_dev *mci_pdev;
433 ++static int ie31200_registered = 1;
434 +
435 + struct ie31200_priv {
436 + void __iomem *window;
437 +@@ -518,12 +520,16 @@ fail_free:
438 + static int ie31200_init_one(struct pci_dev *pdev,
439 + const struct pci_device_id *ent)
440 + {
441 +- edac_dbg(0, "MC:\n");
442 ++ int rc;
443 +
444 ++ edac_dbg(0, "MC:\n");
445 + if (pci_enable_device(pdev) < 0)
446 + return -EIO;
447 ++ rc = ie31200_probe1(pdev, ent->driver_data);
448 ++ if (rc == 0 && !mci_pdev)
449 ++ mci_pdev = pci_dev_get(pdev);
450 +
451 +- return ie31200_probe1(pdev, ent->driver_data);
452 ++ return rc;
453 + }
454 +
455 + static void ie31200_remove_one(struct pci_dev *pdev)
456 +@@ -532,6 +538,8 @@ static void ie31200_remove_one(struct pci_dev *pdev)
457 + struct ie31200_priv *priv;
458 +
459 + edac_dbg(0, "\n");
460 ++ pci_dev_put(mci_pdev);
461 ++ mci_pdev = NULL;
462 + mci = edac_mc_del_mc(&pdev->dev);
463 + if (!mci)
464 + return;
465 +@@ -583,17 +591,53 @@ static struct pci_driver ie31200_driver = {
466 +
467 + static int __init ie31200_init(void)
468 + {
469 ++ int pci_rc, i;
470 ++
471 + edac_dbg(3, "MC:\n");
472 + /* Ensure that the OPSTATE is set correctly for POLL or NMI */
473 + opstate_init();
474 +
475 +- return pci_register_driver(&ie31200_driver);
476 ++ pci_rc = pci_register_driver(&ie31200_driver);
477 ++ if (pci_rc < 0)
478 ++ goto fail0;
479 ++
480 ++ if (!mci_pdev) {
481 ++ ie31200_registered = 0;
482 ++ for (i = 0; ie31200_pci_tbl[i].vendor != 0; i++) {
483 ++ mci_pdev = pci_get_device(ie31200_pci_tbl[i].vendor,
484 ++ ie31200_pci_tbl[i].device,
485 ++ NULL);
486 ++ if (mci_pdev)
487 ++ break;
488 ++ }
489 ++ if (!mci_pdev) {
490 ++ edac_dbg(0, "ie31200 pci_get_device fail\n");
491 ++ pci_rc = -ENODEV;
492 ++ goto fail1;
493 ++ }
494 ++ pci_rc = ie31200_init_one(mci_pdev, &ie31200_pci_tbl[i]);
495 ++ if (pci_rc < 0) {
496 ++ edac_dbg(0, "ie31200 init fail\n");
497 ++ pci_rc = -ENODEV;
498 ++ goto fail1;
499 ++ }
500 ++ }
501 ++ return 0;
502 ++
503 ++fail1:
504 ++ pci_unregister_driver(&ie31200_driver);
505 ++fail0:
506 ++ pci_dev_put(mci_pdev);
507 ++
508 ++ return pci_rc;
509 + }
510 +
511 + static void __exit ie31200_exit(void)
512 + {
513 + edac_dbg(3, "MC:\n");
514 + pci_unregister_driver(&ie31200_driver);
515 ++ if (!ie31200_registered)
516 ++ ie31200_remove_one(mci_pdev);
517 + }
518 +
519 + module_init(ie31200_init);
520 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
521 +index 1eff36a875958..3992e1cbb61ca 100644
522 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
523 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
524 +@@ -734,8 +734,10 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force)
525 +
526 + if (!drm_kms_helper_is_poll_worker()) {
527 + r = pm_runtime_get_sync(connector->dev->dev);
528 +- if (r < 0)
529 ++ if (r < 0) {
530 ++ pm_runtime_put_autosuspend(connector->dev->dev);
531 + return connector_status_disconnected;
532 ++ }
533 + }
534 +
535 + if (encoder) {
536 +@@ -872,8 +874,10 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force)
537 +
538 + if (!drm_kms_helper_is_poll_worker()) {
539 + r = pm_runtime_get_sync(connector->dev->dev);
540 +- if (r < 0)
541 ++ if (r < 0) {
542 ++ pm_runtime_put_autosuspend(connector->dev->dev);
543 + return connector_status_disconnected;
544 ++ }
545 + }
546 +
547 + encoder = amdgpu_connector_best_single_encoder(connector);
548 +@@ -996,8 +1000,10 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force)
549 +
550 + if (!drm_kms_helper_is_poll_worker()) {
551 + r = pm_runtime_get_sync(connector->dev->dev);
552 +- if (r < 0)
553 ++ if (r < 0) {
554 ++ pm_runtime_put_autosuspend(connector->dev->dev);
555 + return connector_status_disconnected;
556 ++ }
557 + }
558 +
559 + if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {
560 +@@ -1371,8 +1377,10 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force)
561 +
562 + if (!drm_kms_helper_is_poll_worker()) {
563 + r = pm_runtime_get_sync(connector->dev->dev);
564 +- if (r < 0)
565 ++ if (r < 0) {
566 ++ pm_runtime_put_autosuspend(connector->dev->dev);
567 + return connector_status_disconnected;
568 ++ }
569 + }
570 +
571 + if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {
572 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
573 +index 6ad243293a78b..df24494299791 100644
574 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
575 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
576 +@@ -269,7 +269,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set,
577 +
578 + ret = pm_runtime_get_sync(dev->dev);
579 + if (ret < 0)
580 +- return ret;
581 ++ goto out;
582 +
583 + ret = drm_crtc_helper_set_config(set, ctx);
584 +
585 +@@ -284,7 +284,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set,
586 + take the current one */
587 + if (active && !adev->have_disp_power_ref) {
588 + adev->have_disp_power_ref = true;
589 +- return ret;
590 ++ goto out;
591 + }
592 + /* if we have no active crtcs, then drop the power ref
593 + we got before */
594 +@@ -293,6 +293,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set,
595 + adev->have_disp_power_ref = false;
596 + }
597 +
598 ++out:
599 + /* drop the power reference we got coming in here */
600 + pm_runtime_put_autosuspend(dev->dev);
601 + return ret;
602 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
603 +index ae23f7e0290c3..465ece90e63ab 100644
604 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
605 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
606 +@@ -801,11 +801,12 @@ long amdgpu_drm_ioctl(struct file *filp,
607 + dev = file_priv->minor->dev;
608 + ret = pm_runtime_get_sync(dev->dev);
609 + if (ret < 0)
610 +- return ret;
611 ++ goto out;
612 +
613 + ret = drm_ioctl(filp, cmd, arg);
614 +
615 + pm_runtime_mark_last_busy(dev->dev);
616 ++out:
617 + pm_runtime_put_autosuspend(dev->dev);
618 + return ret;
619 + }
620 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
621 +index 22d9ec80a2ffd..df5ed16f7fb7c 100644
622 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
623 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
624 +@@ -502,8 +502,12 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
625 + * in the bitfields */
626 + if (se_num == AMDGPU_INFO_MMR_SE_INDEX_MASK)
627 + se_num = 0xffffffff;
628 ++ else if (se_num >= AMDGPU_GFX_MAX_SE)
629 ++ return -EINVAL;
630 + if (sh_num == AMDGPU_INFO_MMR_SH_INDEX_MASK)
631 + sh_num = 0xffffffff;
632 ++ else if (sh_num >= AMDGPU_GFX_MAX_SH_PER_SE)
633 ++ return -EINVAL;
634 +
635 + if (info->read_mmr_reg.count > 128)
636 + return -EINVAL;
637 +@@ -785,7 +789,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
638 +
639 + r = pm_runtime_get_sync(dev->dev);
640 + if (r < 0)
641 +- return r;
642 ++ goto pm_put;
643 +
644 + fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
645 + if (unlikely(!fpriv)) {
646 +@@ -824,6 +828,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
647 +
648 + out_suspend:
649 + pm_runtime_mark_last_busy(dev->dev);
650 ++pm_put:
651 + pm_runtime_put_autosuspend(dev->dev);
652 +
653 + return r;
654 +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
655 +index e0b78fd9804de..ab79c1030f005 100644
656 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
657 ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
658 +@@ -821,8 +821,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
659 +
660 + ret = kobject_init_and_add(dev->kobj_node, &node_type,
661 + sys_props.kobj_nodes, "%d", id);
662 +- if (ret < 0)
663 ++ if (ret < 0) {
664 ++ kobject_put(dev->kobj_node);
665 + return ret;
666 ++ }
667 +
668 + dev->kobj_mem = kobject_create_and_add("mem_banks", dev->kobj_node);
669 + if (!dev->kobj_mem)
670 +@@ -865,8 +867,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
671 + return -ENOMEM;
672 + ret = kobject_init_and_add(mem->kobj, &mem_type,
673 + dev->kobj_mem, "%d", i);
674 +- if (ret < 0)
675 ++ if (ret < 0) {
676 ++ kobject_put(mem->kobj);
677 + return ret;
678 ++ }
679 +
680 + mem->attr.name = "properties";
681 + mem->attr.mode = KFD_SYSFS_FILE_MODE;
682 +@@ -884,8 +888,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
683 + return -ENOMEM;
684 + ret = kobject_init_and_add(cache->kobj, &cache_type,
685 + dev->kobj_cache, "%d", i);
686 +- if (ret < 0)
687 ++ if (ret < 0) {
688 ++ kobject_put(cache->kobj);
689 + return ret;
690 ++ }
691 +
692 + cache->attr.name = "properties";
693 + cache->attr.mode = KFD_SYSFS_FILE_MODE;
694 +@@ -903,8 +909,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
695 + return -ENOMEM;
696 + ret = kobject_init_and_add(iolink->kobj, &iolink_type,
697 + dev->kobj_iolink, "%d", i);
698 +- if (ret < 0)
699 ++ if (ret < 0) {
700 ++ kobject_put(iolink->kobj);
701 + return ret;
702 ++ }
703 +
704 + iolink->attr.name = "properties";
705 + iolink->attr.mode = KFD_SYSFS_FILE_MODE;
706 +@@ -956,8 +964,10 @@ static int kfd_topology_update_sysfs(void)
707 + ret = kobject_init_and_add(sys_props.kobj_topology,
708 + &sysprops_type, &kfd_device->kobj,
709 + "topology");
710 +- if (ret < 0)
711 ++ if (ret < 0) {
712 ++ kobject_put(sys_props.kobj_topology);
713 + return ret;
714 ++ }
715 +
716 + sys_props.kobj_nodes = kobject_create_and_add("nodes",
717 + sys_props.kobj_topology);
718 +diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
719 +index 4a7d50a96d36f..b5c8219c54557 100644
720 +--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
721 ++++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
722 +@@ -580,8 +580,10 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
723 + pm_runtime_get_noresume(dev->dev);
724 + } else {
725 + ret = pm_runtime_get_sync(dev->dev);
726 +- if (ret < 0 && ret != -EACCES)
727 ++ if (ret < 0 && ret != -EACCES) {
728 ++ pm_runtime_put_autosuspend(dev->dev);
729 + return conn_status;
730 ++ }
731 + }
732 +
733 + nv_encoder = nouveau_connector_ddc_detect(connector);
734 +diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
735 +index 9ffb09679cc4a..cae1beabcd05d 100644
736 +--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
737 ++++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
738 +@@ -184,8 +184,10 @@ nouveau_fbcon_open(struct fb_info *info, int user)
739 + struct nouveau_fbdev *fbcon = info->par;
740 + struct nouveau_drm *drm = nouveau_drm(fbcon->helper.dev);
741 + int ret = pm_runtime_get_sync(drm->dev->dev);
742 +- if (ret < 0 && ret != -EACCES)
743 ++ if (ret < 0 && ret != -EACCES) {
744 ++ pm_runtime_put(drm->dev->dev);
745 + return ret;
746 ++ }
747 + return 0;
748 + }
749 +
750 +diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
751 +index 48f752cf7a920..fc021b8e4077d 100644
752 +--- a/drivers/gpu/drm/radeon/radeon_connectors.c
753 ++++ b/drivers/gpu/drm/radeon/radeon_connectors.c
754 +@@ -895,8 +895,10 @@ radeon_lvds_detect(struct drm_connector *connector, bool force)
755 +
756 + if (!drm_kms_helper_is_poll_worker()) {
757 + r = pm_runtime_get_sync(connector->dev->dev);
758 +- if (r < 0)
759 ++ if (r < 0) {
760 ++ pm_runtime_put_autosuspend(connector->dev->dev);
761 + return connector_status_disconnected;
762 ++ }
763 + }
764 +
765 + if (encoder) {
766 +@@ -1041,8 +1043,10 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
767 +
768 + if (!drm_kms_helper_is_poll_worker()) {
769 + r = pm_runtime_get_sync(connector->dev->dev);
770 +- if (r < 0)
771 ++ if (r < 0) {
772 ++ pm_runtime_put_autosuspend(connector->dev->dev);
773 + return connector_status_disconnected;
774 ++ }
775 + }
776 +
777 + encoder = radeon_best_single_encoder(connector);
778 +@@ -1179,8 +1183,10 @@ radeon_tv_detect(struct drm_connector *connector, bool force)
779 +
780 + if (!drm_kms_helper_is_poll_worker()) {
781 + r = pm_runtime_get_sync(connector->dev->dev);
782 +- if (r < 0)
783 ++ if (r < 0) {
784 ++ pm_runtime_put_autosuspend(connector->dev->dev);
785 + return connector_status_disconnected;
786 ++ }
787 + }
788 +
789 + encoder = radeon_best_single_encoder(connector);
790 +@@ -1263,8 +1269,10 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
791 +
792 + if (!drm_kms_helper_is_poll_worker()) {
793 + r = pm_runtime_get_sync(connector->dev->dev);
794 +- if (r < 0)
795 ++ if (r < 0) {
796 ++ pm_runtime_put_autosuspend(connector->dev->dev);
797 + return connector_status_disconnected;
798 ++ }
799 + }
800 +
801 + if (radeon_connector->detected_hpd_without_ddc) {
802 +@@ -1704,8 +1712,10 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
803 +
804 + if (!drm_kms_helper_is_poll_worker()) {
805 + r = pm_runtime_get_sync(connector->dev->dev);
806 +- if (r < 0)
807 ++ if (r < 0) {
808 ++ pm_runtime_put_autosuspend(connector->dev->dev);
809 + return connector_status_disconnected;
810 ++ }
811 + }
812 +
813 + if (!force && radeon_check_hpd_status_unchanged(connector)) {
814 +diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
815 +index 7842d76aa813b..0294cac4c856d 100644
816 +--- a/drivers/hid/i2c-hid/i2c-hid-core.c
817 ++++ b/drivers/hid/i2c-hid/i2c-hid-core.c
818 +@@ -406,6 +406,19 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state)
819 + dev_err(&client->dev, "failed to change power setting.\n");
820 +
821 + set_pwr_exit:
822 ++
823 ++ /*
824 ++ * The HID over I2C specification states that if a DEVICE needs time
825 ++ * after the PWR_ON request, it should utilise CLOCK stretching.
826 ++ * However, it has been observered that the Windows driver provides a
827 ++ * 1ms sleep between the PWR_ON and RESET requests.
828 ++ * According to Goodix Windows even waits 60 ms after (other?)
829 ++ * PWR_ON requests. Testing has confirmed that several devices
830 ++ * will not work properly without a delay after a PWR_ON request.
831 ++ */
832 ++ if (!ret && power_state == I2C_HID_PWR_ON)
833 ++ msleep(60);
834 ++
835 + return ret;
836 + }
837 +
838 +@@ -427,15 +440,6 @@ static int i2c_hid_hwreset(struct i2c_client *client)
839 + if (ret)
840 + goto out_unlock;
841 +
842 +- /*
843 +- * The HID over I2C specification states that if a DEVICE needs time
844 +- * after the PWR_ON request, it should utilise CLOCK stretching.
845 +- * However, it has been observered that the Windows driver provides a
846 +- * 1ms sleep between the PWR_ON and RESET requests and that some devices
847 +- * rely on this.
848 +- */
849 +- usleep_range(1000, 5000);
850 +-
851 + i2c_hid_dbg(ihid, "resetting...\n");
852 +
853 + ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0);
854 +diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
855 +index d9602f3a359e1..5f56feb468c15 100644
856 +--- a/drivers/hid/usbhid/hiddev.c
857 ++++ b/drivers/hid/usbhid/hiddev.c
858 +@@ -532,12 +532,16 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
859 +
860 + switch (cmd) {
861 + case HIDIOCGUSAGE:
862 ++ if (uref->usage_index >= field->report_count)
863 ++ goto inval;
864 + uref->value = field->value[uref->usage_index];
865 + if (copy_to_user(user_arg, uref, sizeof(*uref)))
866 + goto fault;
867 + goto goodreturn;
868 +
869 + case HIDIOCSUSAGE:
870 ++ if (uref->usage_index >= field->report_count)
871 ++ goto inval;
872 + field->value[uref->usage_index] = uref->value;
873 + goto goodreturn;
874 +
875 +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
876 +index ed0f068109785..d5d0809a6283c 100644
877 +--- a/drivers/i2c/busses/i2c-rcar.c
878 ++++ b/drivers/i2c/busses/i2c-rcar.c
879 +@@ -545,6 +545,7 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv)
880 + /* master sent stop */
881 + if (ssr_filtered & SSR) {
882 + i2c_slave_event(priv->slave, I2C_SLAVE_STOP, &value);
883 ++ rcar_i2c_write(priv, ICSCR, SIE | SDBS); /* clear our NACK */
884 + rcar_i2c_write(priv, ICSIER, SAR);
885 + rcar_i2c_write(priv, ICSSR, ~SSR & 0xff);
886 + }
887 +diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
888 +index 4edf65dbbcab5..2c97d2552c5bd 100644
889 +--- a/drivers/iommu/iova.c
890 ++++ b/drivers/iommu/iova.c
891 +@@ -845,7 +845,9 @@ iova_magazine_free_pfns(struct iova_magazine *mag, struct iova_domain *iovad)
892 + for (i = 0 ; i < mag->size; ++i) {
893 + struct iova *iova = private_find_iova(iovad, mag->pfns[i]);
894 +
895 +- BUG_ON(!iova);
896 ++ if (WARN_ON(!iova))
897 ++ continue;
898 ++
899 + private_free_iova(iovad, iova);
900 + }
901 +
902 +diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
903 +index 8f070debe4982..777343cff5f1e 100644
904 +--- a/drivers/md/dm-table.c
905 ++++ b/drivers/md/dm-table.c
906 +@@ -547,14 +547,14 @@ static int adjoin(struct dm_table *table, struct dm_target *ti)
907 + * On the other hand, dm-switch needs to process bulk data using messages and
908 + * excessive use of GFP_NOIO could cause trouble.
909 + */
910 +-static char **realloc_argv(unsigned *array_size, char **old_argv)
911 ++static char **realloc_argv(unsigned *size, char **old_argv)
912 + {
913 + char **argv;
914 + unsigned new_size;
915 + gfp_t gfp;
916 +
917 +- if (*array_size) {
918 +- new_size = *array_size * 2;
919 ++ if (*size) {
920 ++ new_size = *size * 2;
921 + gfp = GFP_KERNEL;
922 + } else {
923 + new_size = 8;
924 +@@ -562,8 +562,8 @@ static char **realloc_argv(unsigned *array_size, char **old_argv)
925 + }
926 + argv = kmalloc(new_size * sizeof(*argv), gfp);
927 + if (argv) {
928 +- memcpy(argv, old_argv, *array_size * sizeof(*argv));
929 +- *array_size = new_size;
930 ++ memcpy(argv, old_argv, *size * sizeof(*argv));
931 ++ *size = new_size;
932 + }
933 +
934 + kfree(old_argv);
935 +diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c
936 +index 21a5f45e0259e..66ef06f4670c8 100644
937 +--- a/drivers/media/cec/cec-api.c
938 ++++ b/drivers/media/cec/cec-api.c
939 +@@ -159,7 +159,13 @@ static long cec_adap_g_log_addrs(struct cec_adapter *adap,
940 + struct cec_log_addrs log_addrs;
941 +
942 + mutex_lock(&adap->lock);
943 +- log_addrs = adap->log_addrs;
944 ++ /*
945 ++ * We use memcpy here instead of assignment since there is a
946 ++ * hole at the end of struct cec_log_addrs that an assignment
947 ++ * might ignore. So when we do copy_to_user() we could leak
948 ++ * one byte of memory.
949 ++ */
950 ++ memcpy(&log_addrs, &adap->log_addrs, sizeof(log_addrs));
951 + if (!adap->is_configured)
952 + memset(log_addrs.log_addr, CEC_LOG_ADDR_INVALID,
953 + sizeof(log_addrs.log_addr));
954 +diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
955 +index f46947d8adf8f..fcc053d95ae49 100644
956 +--- a/drivers/media/pci/ttpci/av7110.c
957 ++++ b/drivers/media/pci/ttpci/av7110.c
958 +@@ -423,14 +423,15 @@ static void debiirq(unsigned long cookie)
959 + case DATA_CI_GET:
960 + {
961 + u8 *data = av7110->debi_virt;
962 ++ u8 data_0 = data[0];
963 +
964 +- if ((data[0] < 2) && data[2] == 0xff) {
965 ++ if (data_0 < 2 && data[2] == 0xff) {
966 + int flags = 0;
967 + if (data[5] > 0)
968 + flags |= CA_CI_MODULE_PRESENT;
969 + if (data[5] > 5)
970 + flags |= CA_CI_MODULE_READY;
971 +- av7110->ci_slot[data[0]].flags = flags;
972 ++ av7110->ci_slot[data_0].flags = flags;
973 + } else
974 + ci_get_data(&av7110->ci_rbuffer,
975 + av7110->debi_virt,
976 +diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
977 +index dc8fc2120b63f..acc52d28c5c45 100644
978 +--- a/drivers/media/platform/davinci/vpif_capture.c
979 ++++ b/drivers/media/platform/davinci/vpif_capture.c
980 +@@ -1489,8 +1489,6 @@ probe_out:
981 + /* Unregister video device */
982 + video_unregister_device(&ch->video_dev);
983 + }
984 +- kfree(vpif_obj.sd);
985 +- v4l2_device_unregister(&vpif_obj.v4l2_dev);
986 +
987 + return err;
988 + }
989 +diff --git a/drivers/media/rc/gpio-ir-tx.c b/drivers/media/rc/gpio-ir-tx.c
990 +index cd476cab97820..4e70b67ccd181 100644
991 +--- a/drivers/media/rc/gpio-ir-tx.c
992 ++++ b/drivers/media/rc/gpio-ir-tx.c
993 +@@ -87,13 +87,8 @@ static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
994 + // space
995 + edge = ktime_add_us(edge, txbuf[i]);
996 + delta = ktime_us_delta(edge, ktime_get());
997 +- if (delta > 10) {
998 +- spin_unlock_irqrestore(&gpio_ir->lock, flags);
999 +- usleep_range(delta, delta + 10);
1000 +- spin_lock_irqsave(&gpio_ir->lock, flags);
1001 +- } else if (delta > 0) {
1002 ++ if (delta > 0)
1003 + udelay(delta);
1004 +- }
1005 + } else {
1006 + // pulse
1007 + ktime_t last = ktime_add_us(edge, txbuf[i]);
1008 +diff --git a/drivers/mfd/intel-lpss-pci.c b/drivers/mfd/intel-lpss-pci.c
1009 +index 0504761516f7b..a12bb8ed20405 100644
1010 +--- a/drivers/mfd/intel-lpss-pci.c
1011 ++++ b/drivers/mfd/intel-lpss-pci.c
1012 +@@ -176,6 +176,9 @@ static const struct pci_device_id intel_lpss_pci_ids[] = {
1013 + { PCI_VDEVICE(INTEL, 0x1ac4), (kernel_ulong_t)&bxt_info },
1014 + { PCI_VDEVICE(INTEL, 0x1ac6), (kernel_ulong_t)&bxt_info },
1015 + { PCI_VDEVICE(INTEL, 0x1aee), (kernel_ulong_t)&bxt_uart_info },
1016 ++ /* EBG */
1017 ++ { PCI_VDEVICE(INTEL, 0x1bad), (kernel_ulong_t)&bxt_uart_info },
1018 ++ { PCI_VDEVICE(INTEL, 0x1bae), (kernel_ulong_t)&bxt_uart_info },
1019 + /* GLK */
1020 + { PCI_VDEVICE(INTEL, 0x31ac), (kernel_ulong_t)&glk_i2c_info },
1021 + { PCI_VDEVICE(INTEL, 0x31ae), (kernel_ulong_t)&glk_i2c_info },
1022 +diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
1023 +index e4a2c74a9b47e..6b95334e172d1 100644
1024 +--- a/drivers/net/ethernet/freescale/gianfar.c
1025 ++++ b/drivers/net/ethernet/freescale/gianfar.c
1026 +@@ -844,8 +844,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
1027 + continue;
1028 +
1029 + err = gfar_parse_group(child, priv, model);
1030 +- if (err)
1031 ++ if (err) {
1032 ++ of_node_put(child);
1033 + goto err_grp_init;
1034 ++ }
1035 + }
1036 + } else { /* SQ_SG_MODE */
1037 + err = gfar_parse_group(np, priv, model);
1038 +diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
1039 +index cd32d6623f6a3..11b7006142cec 100644
1040 +--- a/drivers/net/ipvlan/ipvlan_main.c
1041 ++++ b/drivers/net/ipvlan/ipvlan_main.c
1042 +@@ -187,12 +187,21 @@ static void ipvlan_port_destroy(struct net_device *dev)
1043 + kfree(port);
1044 + }
1045 +
1046 ++#define IPVLAN_ALWAYS_ON_OFLOADS \
1047 ++ (NETIF_F_SG | NETIF_F_HW_CSUM | \
1048 ++ NETIF_F_GSO_ROBUST | NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ENCAP_ALL)
1049 ++
1050 ++#define IPVLAN_ALWAYS_ON \
1051 ++ (IPVLAN_ALWAYS_ON_OFLOADS | NETIF_F_LLTX | NETIF_F_VLAN_CHALLENGED)
1052 ++
1053 + #define IPVLAN_FEATURES \
1054 +- (NETIF_F_SG | NETIF_F_CSUM_MASK | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
1055 ++ (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
1056 + NETIF_F_GSO | NETIF_F_TSO | NETIF_F_GSO_ROBUST | \
1057 + NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_GRO | NETIF_F_RXCSUM | \
1058 + NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_STAG_FILTER)
1059 +
1060 ++ /* NETIF_F_GSO_ENCAP_ALL NETIF_F_GSO_SOFTWARE Newly added */
1061 ++
1062 + #define IPVLAN_STATE_MASK \
1063 + ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT))
1064 +
1065 +@@ -205,7 +214,9 @@ static int ipvlan_init(struct net_device *dev)
1066 + dev->state = (dev->state & ~IPVLAN_STATE_MASK) |
1067 + (phy_dev->state & IPVLAN_STATE_MASK);
1068 + dev->features = phy_dev->features & IPVLAN_FEATURES;
1069 +- dev->features |= NETIF_F_LLTX;
1070 ++ dev->features |= IPVLAN_ALWAYS_ON;
1071 ++ dev->vlan_features = phy_dev->vlan_features & IPVLAN_FEATURES;
1072 ++ dev->vlan_features |= IPVLAN_ALWAYS_ON_OFLOADS;
1073 + dev->gso_max_size = phy_dev->gso_max_size;
1074 + dev->gso_max_segs = phy_dev->gso_max_segs;
1075 + dev->hard_header_len = phy_dev->hard_header_len;
1076 +@@ -293,7 +304,14 @@ static netdev_features_t ipvlan_fix_features(struct net_device *dev,
1077 + {
1078 + struct ipvl_dev *ipvlan = netdev_priv(dev);
1079 +
1080 +- return features & (ipvlan->sfeatures | ~IPVLAN_FEATURES);
1081 ++ features |= NETIF_F_ALL_FOR_ALL;
1082 ++ features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES);
1083 ++ features = netdev_increment_features(ipvlan->phy_dev->features,
1084 ++ features, features);
1085 ++ features |= IPVLAN_ALWAYS_ON;
1086 ++ features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON);
1087 ++
1088 ++ return features;
1089 + }
1090 +
1091 + static void ipvlan_change_rx_flags(struct net_device *dev, int change)
1092 +@@ -743,10 +761,9 @@ static int ipvlan_device_event(struct notifier_block *unused,
1093 +
1094 + case NETDEV_FEAT_CHANGE:
1095 + list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
1096 +- ipvlan->dev->features = dev->features & IPVLAN_FEATURES;
1097 + ipvlan->dev->gso_max_size = dev->gso_max_size;
1098 + ipvlan->dev->gso_max_segs = dev->gso_max_segs;
1099 +- netdev_features_change(ipvlan->dev);
1100 ++ netdev_update_features(ipvlan->dev);
1101 + }
1102 + break;
1103 +
1104 +diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h
1105 +index 0c089f6dd3d92..6a8c5f71787ad 100644
1106 +--- a/drivers/net/wireless/ath/ath10k/hw.h
1107 ++++ b/drivers/net/wireless/ath/ath10k/hw.h
1108 +@@ -702,7 +702,7 @@ ath10k_rx_desc_get_l3_pad_bytes(struct ath10k_hw_params *hw,
1109 +
1110 + #define TARGET_10_4_TX_DBG_LOG_SIZE 1024
1111 + #define TARGET_10_4_NUM_WDS_ENTRIES 32
1112 +-#define TARGET_10_4_DMA_BURST_SIZE 0
1113 ++#define TARGET_10_4_DMA_BURST_SIZE 1
1114 + #define TARGET_10_4_MAC_AGGR_DELIM 0
1115 + #define TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1
1116 + #define TARGET_10_4_VOW_CONFIG 0
1117 +diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
1118 +index 7a050a75bdcbb..4fa4d877f913b 100644
1119 +--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
1120 ++++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
1121 +@@ -739,8 +739,11 @@ static int _rtl_usb_receive(struct ieee80211_hw *hw)
1122 +
1123 + usb_anchor_urb(urb, &rtlusb->rx_submitted);
1124 + err = usb_submit_urb(urb, GFP_KERNEL);
1125 +- if (err)
1126 ++ if (err) {
1127 ++ usb_unanchor_urb(urb);
1128 ++ usb_free_urb(urb);
1129 + goto err_out;
1130 ++ }
1131 + usb_free_urb(urb);
1132 + }
1133 + return 0;
1134 +diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
1135 +index 058d542647dd5..13c89cc9d10cf 100644
1136 +--- a/drivers/nvme/host/fc.c
1137 ++++ b/drivers/nvme/host/fc.c
1138 +@@ -1492,7 +1492,7 @@ __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl,
1139 + if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.cmddma)) {
1140 + dev_err(ctrl->dev,
1141 + "FCP Op failed - cmdiu dma mapping failed.\n");
1142 +- ret = EFAULT;
1143 ++ ret = -EFAULT;
1144 + goto out_on_error;
1145 + }
1146 +
1147 +@@ -1502,7 +1502,7 @@ __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl,
1148 + if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.rspdma)) {
1149 + dev_err(ctrl->dev,
1150 + "FCP Op failed - rspiu dma mapping failed.\n");
1151 +- ret = EFAULT;
1152 ++ ret = -EFAULT;
1153 + }
1154 +
1155 + atomic_set(&op->state, FCPOP_STATE_IDLE);
1156 +diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
1157 +index e42909524deed..379925fc49d4e 100644
1158 +--- a/drivers/pci/slot.c
1159 ++++ b/drivers/pci/slot.c
1160 +@@ -303,13 +303,16 @@ placeholder:
1161 + slot_name = make_slot_name(name);
1162 + if (!slot_name) {
1163 + err = -ENOMEM;
1164 ++ kfree(slot);
1165 + goto err;
1166 + }
1167 +
1168 + err = kobject_init_and_add(&slot->kobj, &pci_slot_ktype, NULL,
1169 + "%s", slot_name);
1170 +- if (err)
1171 ++ if (err) {
1172 ++ kobject_put(&slot->kobj);
1173 + goto err;
1174 ++ }
1175 +
1176 + INIT_LIST_HEAD(&slot->list);
1177 + list_add(&slot->list, &parent->slots);
1178 +@@ -328,7 +331,6 @@ out:
1179 + mutex_unlock(&pci_slot_mutex);
1180 + return slot;
1181 + err:
1182 +- kfree(slot);
1183 + slot = ERR_PTR(err);
1184 + goto out;
1185 + }
1186 +diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
1187 +index dadff1838fec1..e2026d54dd375 100644
1188 +--- a/drivers/s390/cio/css.c
1189 ++++ b/drivers/s390/cio/css.c
1190 +@@ -581,6 +581,11 @@ static int slow_eval_known_fn(struct subchannel *sch, void *data)
1191 + rc = css_evaluate_known_subchannel(sch, 1);
1192 + if (rc == -EAGAIN)
1193 + css_schedule_eval(sch->schid);
1194 ++ /*
1195 ++ * The loop might take long time for platforms with lots of
1196 ++ * known devices. Allow scheduling here.
1197 ++ */
1198 ++ cond_resched();
1199 + }
1200 + return 0;
1201 + }
1202 +diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
1203 +index d95ba1a07ba3b..eaab59afd90c7 100644
1204 +--- a/drivers/scsi/fcoe/fcoe_ctlr.c
1205 ++++ b/drivers/scsi/fcoe/fcoe_ctlr.c
1206 +@@ -267,9 +267,9 @@ static void fcoe_sysfs_fcf_del(struct fcoe_fcf *new)
1207 + WARN_ON(!fcf_dev);
1208 + new->fcf_dev = NULL;
1209 + fcoe_fcf_device_delete(fcf_dev);
1210 +- kfree(new);
1211 + mutex_unlock(&cdev->lock);
1212 + }
1213 ++ kfree(new);
1214 + }
1215 +
1216 + /**
1217 +diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c
1218 +index c714482bf4c55..9c738e201f462 100644
1219 +--- a/drivers/scsi/lpfc/lpfc_vport.c
1220 ++++ b/drivers/scsi/lpfc/lpfc_vport.c
1221 +@@ -644,27 +644,16 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
1222 + vport->port_state < LPFC_VPORT_READY)
1223 + return -EAGAIN;
1224 + }
1225 ++
1226 + /*
1227 +- * This is a bit of a mess. We want to ensure the shost doesn't get
1228 +- * torn down until we're done with the embedded lpfc_vport structure.
1229 +- *
1230 +- * Beyond holding a reference for this function, we also need a
1231 +- * reference for outstanding I/O requests we schedule during delete
1232 +- * processing. But once we scsi_remove_host() we can no longer obtain
1233 +- * a reference through scsi_host_get().
1234 +- *
1235 +- * So we take two references here. We release one reference at the
1236 +- * bottom of the function -- after delinking the vport. And we
1237 +- * release the other at the completion of the unreg_vpi that get's
1238 +- * initiated after we've disposed of all other resources associated
1239 +- * with the port.
1240 ++ * Take early refcount for outstanding I/O requests we schedule during
1241 ++ * delete processing for unreg_vpi. Always keep this before
1242 ++ * scsi_remove_host() as we can no longer obtain a reference through
1243 ++ * scsi_host_get() after scsi_host_remove as shost is set to SHOST_DEL.
1244 + */
1245 + if (!scsi_host_get(shost))
1246 + return VPORT_INVAL;
1247 +- if (!scsi_host_get(shost)) {
1248 +- scsi_host_put(shost);
1249 +- return VPORT_INVAL;
1250 +- }
1251 ++
1252 + lpfc_free_sysfs_attr(vport);
1253 +
1254 + lpfc_debugfs_terminate(vport);
1255 +@@ -811,8 +800,9 @@ skip_logo:
1256 + if (!(vport->vpi_state & LPFC_VPI_REGISTERED) ||
1257 + lpfc_mbx_unreg_vpi(vport))
1258 + scsi_host_put(shost);
1259 +- } else
1260 ++ } else {
1261 + scsi_host_put(shost);
1262 ++ }
1263 +
1264 + lpfc_free_vpi(phba, vport->vpi);
1265 + vport->work_port_events = 0;
1266 +diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
1267 +index 9589015234693..c3170500a1a1d 100644
1268 +--- a/drivers/scsi/scsi_transport_iscsi.c
1269 ++++ b/drivers/scsi/scsi_transport_iscsi.c
1270 +@@ -3172,7 +3172,7 @@ static int iscsi_set_flashnode_param(struct iscsi_transport *transport,
1271 + pr_err("%s could not find host no %u\n",
1272 + __func__, ev->u.set_flashnode.host_no);
1273 + err = -ENODEV;
1274 +- goto put_host;
1275 ++ goto exit_set_fnode;
1276 + }
1277 +
1278 + idx = ev->u.set_flashnode.flashnode_idx;
1279 +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
1280 +index 11e917b44a0f1..c1792f271ac5d 100644
1281 +--- a/drivers/scsi/ufs/ufshcd.c
1282 ++++ b/drivers/scsi/ufs/ufshcd.c
1283 +@@ -1425,6 +1425,7 @@ unblock_reqs:
1284 + int ufshcd_hold(struct ufs_hba *hba, bool async)
1285 + {
1286 + int rc = 0;
1287 ++ bool flush_result;
1288 + unsigned long flags;
1289 +
1290 + if (!ufshcd_is_clkgating_allowed(hba))
1291 +@@ -1456,7 +1457,9 @@ start:
1292 + break;
1293 + }
1294 + spin_unlock_irqrestore(hba->host->host_lock, flags);
1295 +- flush_work(&hba->clk_gating.ungate_work);
1296 ++ flush_result = flush_work(&hba->clk_gating.ungate_work);
1297 ++ if (hba->clk_gating.is_suspended && !flush_result)
1298 ++ goto out;
1299 + spin_lock_irqsave(hba->host->host_lock, flags);
1300 + goto start;
1301 + }
1302 +@@ -5370,7 +5373,7 @@ static void ufshcd_sl_intr(struct ufs_hba *hba, u32 intr_status)
1303 + */
1304 + static irqreturn_t ufshcd_intr(int irq, void *__hba)
1305 + {
1306 +- u32 intr_status, enabled_intr_status;
1307 ++ u32 intr_status, enabled_intr_status = 0;
1308 + irqreturn_t retval = IRQ_NONE;
1309 + struct ufs_hba *hba = __hba;
1310 + int retries = hba->nutrs;
1311 +@@ -5384,7 +5387,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
1312 + * read, make sure we handle them by checking the interrupt status
1313 + * again in a loop until we process all of the reqs before returning.
1314 + */
1315 +- do {
1316 ++ while (intr_status && retries--) {
1317 + enabled_intr_status =
1318 + intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
1319 + if (intr_status)
1320 +@@ -5395,7 +5398,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
1321 + }
1322 +
1323 + intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
1324 +- } while (intr_status && --retries);
1325 ++ }
1326 +
1327 + spin_unlock(hba->host->host_lock);
1328 + return retval;
1329 +@@ -5691,7 +5694,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
1330 + /* command completed already */
1331 + dev_err(hba->dev, "%s: cmd at tag %d successfully cleared from DB.\n",
1332 + __func__, tag);
1333 +- goto out;
1334 ++ goto cleanup;
1335 + } else {
1336 + dev_err(hba->dev,
1337 + "%s: no response from device. tag = %d, err %d\n",
1338 +@@ -5725,6 +5728,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
1339 + goto out;
1340 + }
1341 +
1342 ++cleanup:
1343 + scsi_dma_unmap(cmd);
1344 +
1345 + spin_lock_irqsave(host->host_lock, flags);
1346 +diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
1347 +index ba9743fa2326d..179749f354c33 100644
1348 +--- a/drivers/spi/spi-stm32.c
1349 ++++ b/drivers/spi/spi-stm32.c
1350 +@@ -254,7 +254,8 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz)
1351 + {
1352 + u32 div, mbrdiv;
1353 +
1354 +- div = DIV_ROUND_UP(spi->clk_rate, speed_hz);
1355 ++ /* Ensure spi->clk_rate is even */
1356 ++ div = DIV_ROUND_UP(spi->clk_rate & ~0x1, speed_hz);
1357 +
1358 + /*
1359 + * SPI framework set xfer->speed_hz to master->max_speed_hz if
1360 +diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
1361 +index c4a5fb6f038fc..96601fda47b18 100644
1362 +--- a/drivers/target/target_core_user.c
1363 ++++ b/drivers/target/target_core_user.c
1364 +@@ -997,7 +997,14 @@ static unsigned int tcmu_handle_completions(struct tcmu_dev *udev)
1365 + struct tcmu_cmd_entry *entry = (void *) mb + CMDR_OFF + udev->cmdr_last_cleaned;
1366 + struct tcmu_cmd *cmd;
1367 +
1368 +- tcmu_flush_dcache_range(entry, sizeof(*entry));
1369 ++ /*
1370 ++ * Flush max. up to end of cmd ring since current entry might
1371 ++ * be a padding that is shorter than sizeof(*entry)
1372 ++ */
1373 ++ size_t ring_left = head_to_end(udev->cmdr_last_cleaned,
1374 ++ udev->cmdr_size);
1375 ++ tcmu_flush_dcache_range(entry, ring_left < sizeof(*entry) ?
1376 ++ ring_left : sizeof(*entry));
1377 +
1378 + if (tcmu_hdr_get_op(entry->hdr.len_op) == TCMU_OP_PAD) {
1379 + UPDATE_HEAD(udev->cmdr_last_cleaned,
1380 +diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
1381 +index ed81128bb42e0..fd7d9aa1de9a7 100644
1382 +--- a/drivers/tty/serial/8250/8250_exar.c
1383 ++++ b/drivers/tty/serial/8250/8250_exar.c
1384 +@@ -629,6 +629,24 @@ static const struct exar8250_board pbn_exar_XR17V35x = {
1385 + .exit = pci_xr17v35x_exit,
1386 + };
1387 +
1388 ++static const struct exar8250_board pbn_fastcom35x_2 = {
1389 ++ .num_ports = 2,
1390 ++ .setup = pci_xr17v35x_setup,
1391 ++ .exit = pci_xr17v35x_exit,
1392 ++};
1393 ++
1394 ++static const struct exar8250_board pbn_fastcom35x_4 = {
1395 ++ .num_ports = 4,
1396 ++ .setup = pci_xr17v35x_setup,
1397 ++ .exit = pci_xr17v35x_exit,
1398 ++};
1399 ++
1400 ++static const struct exar8250_board pbn_fastcom35x_8 = {
1401 ++ .num_ports = 8,
1402 ++ .setup = pci_xr17v35x_setup,
1403 ++ .exit = pci_xr17v35x_exit,
1404 ++};
1405 ++
1406 + static const struct exar8250_board pbn_exar_XR17V4358 = {
1407 + .num_ports = 12,
1408 + .has_slave = true,
1409 +@@ -701,9 +719,9 @@ static const struct pci_device_id exar_pci_tbl[] = {
1410 + EXAR_DEVICE(EXAR, EXAR_XR17V358, pbn_exar_XR17V35x),
1411 + EXAR_DEVICE(EXAR, EXAR_XR17V4358, pbn_exar_XR17V4358),
1412 + EXAR_DEVICE(EXAR, EXAR_XR17V8358, pbn_exar_XR17V8358),
1413 +- EXAR_DEVICE(COMMTECH, COMMTECH_4222PCIE, pbn_exar_XR17V35x),
1414 +- EXAR_DEVICE(COMMTECH, COMMTECH_4224PCIE, pbn_exar_XR17V35x),
1415 +- EXAR_DEVICE(COMMTECH, COMMTECH_4228PCIE, pbn_exar_XR17V35x),
1416 ++ EXAR_DEVICE(COMMTECH, COMMTECH_4222PCIE, pbn_fastcom35x_2),
1417 ++ EXAR_DEVICE(COMMTECH, COMMTECH_4224PCIE, pbn_fastcom35x_4),
1418 ++ EXAR_DEVICE(COMMTECH, COMMTECH_4228PCIE, pbn_fastcom35x_8),
1419 +
1420 + EXAR_DEVICE(COMMTECH, COMMTECH_4222PCI335, pbn_fastcom335_2),
1421 + EXAR_DEVICE(COMMTECH, COMMTECH_4224PCI335, pbn_fastcom335_4),
1422 +diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
1423 +index 90a93c001e169..07d5925791e1c 100644
1424 +--- a/drivers/tty/serial/8250/8250_port.c
1425 ++++ b/drivers/tty/serial/8250/8250_port.c
1426 +@@ -2264,6 +2264,10 @@ int serial8250_do_startup(struct uart_port *port)
1427 +
1428 + if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) {
1429 + unsigned char iir1;
1430 ++
1431 ++ if (port->irqflags & IRQF_SHARED)
1432 ++ disable_irq_nosync(port->irq);
1433 ++
1434 + /*
1435 + * Test for UARTs that do not reassert THRE when the
1436 + * transmitter is idle and the interrupt has already
1437 +@@ -2273,8 +2277,6 @@ int serial8250_do_startup(struct uart_port *port)
1438 + * allow register changes to become visible.
1439 + */
1440 + spin_lock_irqsave(&port->lock, flags);
1441 +- if (up->port.irqflags & IRQF_SHARED)
1442 +- disable_irq_nosync(port->irq);
1443 +
1444 + wait_for_xmitr(up, UART_LSR_THRE);
1445 + serial_port_out_sync(port, UART_IER, UART_IER_THRI);
1446 +@@ -2286,9 +2288,10 @@ int serial8250_do_startup(struct uart_port *port)
1447 + iir = serial_port_in(port, UART_IIR);
1448 + serial_port_out(port, UART_IER, 0);
1449 +
1450 ++ spin_unlock_irqrestore(&port->lock, flags);
1451 ++
1452 + if (port->irqflags & IRQF_SHARED)
1453 + enable_irq(port->irq);
1454 +- spin_unlock_irqrestore(&port->lock, flags);
1455 +
1456 + /*
1457 + * If the interrupt is not reasserted, or we otherwise
1458 +diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
1459 +index e55b556337214..49bdd0f8d06a0 100644
1460 +--- a/drivers/tty/serial/amba-pl011.c
1461 ++++ b/drivers/tty/serial/amba-pl011.c
1462 +@@ -2272,9 +2272,8 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
1463 + clk_disable(uap->clk);
1464 + }
1465 +
1466 +-static void __init
1467 +-pl011_console_get_options(struct uart_amba_port *uap, int *baud,
1468 +- int *parity, int *bits)
1469 ++static void pl011_console_get_options(struct uart_amba_port *uap, int *baud,
1470 ++ int *parity, int *bits)
1471 + {
1472 + if (pl011_read(uap, REG_CR) & UART01x_CR_UARTEN) {
1473 + unsigned int lcr_h, ibrd, fbrd;
1474 +@@ -2307,7 +2306,7 @@ pl011_console_get_options(struct uart_amba_port *uap, int *baud,
1475 + }
1476 + }
1477 +
1478 +-static int __init pl011_console_setup(struct console *co, char *options)
1479 ++static int pl011_console_setup(struct console *co, char *options)
1480 + {
1481 + struct uart_amba_port *uap;
1482 + int baud = 38400;
1483 +@@ -2375,8 +2374,8 @@ static int __init pl011_console_setup(struct console *co, char *options)
1484 + *
1485 + * Returns 0 if console matches; otherwise non-zero to use default matching
1486 + */
1487 +-static int __init pl011_console_match(struct console *co, char *name, int idx,
1488 +- char *options)
1489 ++static int pl011_console_match(struct console *co, char *name, int idx,
1490 ++ char *options)
1491 + {
1492 + unsigned char iotype;
1493 + resource_size_t addr;
1494 +@@ -2614,7 +2613,7 @@ static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap,
1495 +
1496 + static int pl011_register_port(struct uart_amba_port *uap)
1497 + {
1498 +- int ret;
1499 ++ int ret, i;
1500 +
1501 + /* Ensure interrupts from this UART are masked and cleared */
1502 + pl011_write(0, uap, REG_IMSC);
1503 +@@ -2625,6 +2624,9 @@ static int pl011_register_port(struct uart_amba_port *uap)
1504 + if (ret < 0) {
1505 + dev_err(uap->port.dev,
1506 + "Failed to register AMBA-PL011 driver\n");
1507 ++ for (i = 0; i < ARRAY_SIZE(amba_ports); i++)
1508 ++ if (amba_ports[i] == uap)
1509 ++ amba_ports[i] = NULL;
1510 + return ret;
1511 + }
1512 + }
1513 +diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
1514 +index 808373d4e37a6..c67d39fea74ca 100644
1515 +--- a/drivers/tty/serial/samsung.c
1516 ++++ b/drivers/tty/serial/samsung.c
1517 +@@ -1733,9 +1733,11 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1518 + ourport->tx_irq = ret + 1;
1519 + }
1520 +
1521 +- ret = platform_get_irq(platdev, 1);
1522 +- if (ret > 0)
1523 +- ourport->tx_irq = ret;
1524 ++ if (!s3c24xx_serial_has_interrupt_mask(port)) {
1525 ++ ret = platform_get_irq(platdev, 1);
1526 ++ if (ret > 0)
1527 ++ ourport->tx_irq = ret;
1528 ++ }
1529 + /*
1530 + * DMA is currently supported only on DT platforms, if DMA properties
1531 + * are specified.
1532 +diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
1533 +index 92267396ff407..781d95113742f 100644
1534 +--- a/drivers/tty/vt/vt.c
1535 ++++ b/drivers/tty/vt/vt.c
1536 +@@ -865,7 +865,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
1537 + unsigned int old_rows, old_row_size;
1538 + unsigned int new_cols, new_rows, new_row_size, new_screen_size;
1539 + unsigned int user;
1540 +- unsigned short *newscreen;
1541 ++ unsigned short *oldscreen, *newscreen;
1542 +
1543 + WARN_CONSOLE_UNLOCKED();
1544 +
1545 +@@ -947,10 +947,11 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
1546 + if (new_scr_end > new_origin)
1547 + scr_memsetw((void *)new_origin, vc->vc_video_erase_char,
1548 + new_scr_end - new_origin);
1549 +- kfree(vc->vc_screenbuf);
1550 ++ oldscreen = vc->vc_screenbuf;
1551 + vc->vc_screenbuf = newscreen;
1552 + vc->vc_screenbuf_size = new_screen_size;
1553 + set_origin(vc);
1554 ++ kfree(oldscreen);
1555 +
1556 + /* do part of a reset_terminal() */
1557 + vc->vc_top = 0;
1558 +diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
1559 +index 699ad55e3ec60..1184105b2a17b 100644
1560 +--- a/drivers/tty/vt/vt_ioctl.c
1561 ++++ b/drivers/tty/vt/vt_ioctl.c
1562 +@@ -893,12 +893,22 @@ int vt_ioctl(struct tty_struct *tty,
1563 + console_lock();
1564 + vcp = vc_cons[i].d;
1565 + if (vcp) {
1566 ++ int ret;
1567 ++ int save_scan_lines = vcp->vc_scan_lines;
1568 ++ int save_font_height = vcp->vc_font.height;
1569 ++
1570 + if (v.v_vlin)
1571 + vcp->vc_scan_lines = v.v_vlin;
1572 + if (v.v_clin)
1573 + vcp->vc_font.height = v.v_clin;
1574 + vcp->vc_resize_user = 1;
1575 +- vc_resize(vcp, v.v_cols, v.v_rows);
1576 ++ ret = vc_resize(vcp, v.v_cols, v.v_rows);
1577 ++ if (ret) {
1578 ++ vcp->vc_scan_lines = save_scan_lines;
1579 ++ vcp->vc_font.height = save_font_height;
1580 ++ console_unlock();
1581 ++ return ret;
1582 ++ }
1583 + }
1584 + console_unlock();
1585 + }
1586 +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
1587 +index 0de467c8593db..b3e4b014a1cc0 100644
1588 +--- a/drivers/usb/class/cdc-acm.c
1589 ++++ b/drivers/usb/class/cdc-acm.c
1590 +@@ -390,21 +390,19 @@ static void acm_ctrl_irq(struct urb *urb)
1591 + if (current_size < expected_size) {
1592 + /* notification is transmitted fragmented, reassemble */
1593 + if (acm->nb_size < expected_size) {
1594 +- if (acm->nb_size) {
1595 +- kfree(acm->notification_buffer);
1596 +- acm->nb_size = 0;
1597 +- }
1598 ++ u8 *new_buffer;
1599 + alloc_size = roundup_pow_of_two(expected_size);
1600 +- /*
1601 +- * kmalloc ensures a valid notification_buffer after a
1602 +- * use of kfree in case the previous allocation was too
1603 +- * small. Final freeing is done on disconnect.
1604 +- */
1605 +- acm->notification_buffer =
1606 +- kmalloc(alloc_size, GFP_ATOMIC);
1607 +- if (!acm->notification_buffer)
1608 ++ /* Final freeing is done on disconnect. */
1609 ++ new_buffer = krealloc(acm->notification_buffer,
1610 ++ alloc_size, GFP_ATOMIC);
1611 ++ if (!new_buffer) {
1612 ++ acm->nb_index = 0;
1613 + goto exit;
1614 ++ }
1615 ++
1616 ++ acm->notification_buffer = new_buffer;
1617 + acm->nb_size = alloc_size;
1618 ++ dr = (struct usb_cdc_notification *)acm->notification_buffer;
1619 + }
1620 +
1621 + copy_size = min(current_size,
1622 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
1623 +index e6e0f786547bf..eed7c8d8e3d4f 100644
1624 +--- a/drivers/usb/core/quirks.c
1625 ++++ b/drivers/usb/core/quirks.c
1626 +@@ -299,6 +299,8 @@ static const struct usb_device_id usb_quirk_list[] = {
1627 +
1628 + { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM },
1629 +
1630 ++ { USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM },
1631 ++
1632 + /* DJI CineSSD */
1633 + { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
1634 +
1635 +diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
1636 +index 5c2d39232bb0e..03fb995d359ee 100644
1637 +--- a/drivers/usb/gadget/function/f_ncm.c
1638 ++++ b/drivers/usb/gadget/function/f_ncm.c
1639 +@@ -1202,12 +1202,15 @@ static int ncm_unwrap_ntb(struct gether *port,
1640 + int ndp_index;
1641 + unsigned dg_len, dg_len2;
1642 + unsigned ndp_len;
1643 ++ unsigned block_len;
1644 + struct sk_buff *skb2;
1645 + int ret = -EINVAL;
1646 +- unsigned max_size = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize);
1647 ++ unsigned ntb_max = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize);
1648 ++ unsigned frame_max = le16_to_cpu(ecm_desc.wMaxSegmentSize);
1649 + const struct ndp_parser_opts *opts = ncm->parser_opts;
1650 + unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
1651 + int dgram_counter;
1652 ++ bool ndp_after_header;
1653 +
1654 + /* dwSignature */
1655 + if (get_unaligned_le32(tmp) != opts->nth_sign) {
1656 +@@ -1226,25 +1229,37 @@ static int ncm_unwrap_ntb(struct gether *port,
1657 + }
1658 + tmp++; /* skip wSequence */
1659 +
1660 ++ block_len = get_ncm(&tmp, opts->block_length);
1661 + /* (d)wBlockLength */
1662 +- if (get_ncm(&tmp, opts->block_length) > max_size) {
1663 ++ if (block_len > ntb_max) {
1664 + INFO(port->func.config->cdev, "OUT size exceeded\n");
1665 + goto err;
1666 + }
1667 +
1668 + ndp_index = get_ncm(&tmp, opts->ndp_index);
1669 ++ ndp_after_header = false;
1670 +
1671 + /* Run through all the NDP's in the NTB */
1672 + do {
1673 +- /* NCM 3.2 */
1674 +- if (((ndp_index % 4) != 0) &&
1675 +- (ndp_index < opts->nth_size)) {
1676 ++ /*
1677 ++ * NCM 3.2
1678 ++ * dwNdpIndex
1679 ++ */
1680 ++ if (((ndp_index % 4) != 0) ||
1681 ++ (ndp_index < opts->nth_size) ||
1682 ++ (ndp_index > (block_len -
1683 ++ opts->ndp_size))) {
1684 + INFO(port->func.config->cdev, "Bad index: %#X\n",
1685 + ndp_index);
1686 + goto err;
1687 + }
1688 ++ if (ndp_index == opts->nth_size)
1689 ++ ndp_after_header = true;
1690 +
1691 +- /* walk through NDP */
1692 ++ /*
1693 ++ * walk through NDP
1694 ++ * dwSignature
1695 ++ */
1696 + tmp = (void *)(skb->data + ndp_index);
1697 + if (get_unaligned_le32(tmp) != ncm->ndp_sign) {
1698 + INFO(port->func.config->cdev, "Wrong NDP SIGN\n");
1699 +@@ -1255,14 +1270,15 @@ static int ncm_unwrap_ntb(struct gether *port,
1700 + ndp_len = get_unaligned_le16(tmp++);
1701 + /*
1702 + * NCM 3.3.1
1703 ++ * wLength
1704 + * entry is 2 items
1705 + * item size is 16/32 bits, opts->dgram_item_len * 2 bytes
1706 + * minimal: struct usb_cdc_ncm_ndpX + normal entry + zero entry
1707 + * Each entry is a dgram index and a dgram length.
1708 + */
1709 + if ((ndp_len < opts->ndp_size
1710 +- + 2 * 2 * (opts->dgram_item_len * 2))
1711 +- || (ndp_len % opts->ndplen_align != 0)) {
1712 ++ + 2 * 2 * (opts->dgram_item_len * 2)) ||
1713 ++ (ndp_len % opts->ndplen_align != 0)) {
1714 + INFO(port->func.config->cdev, "Bad NDP length: %#X\n",
1715 + ndp_len);
1716 + goto err;
1717 +@@ -1279,8 +1295,21 @@ static int ncm_unwrap_ntb(struct gether *port,
1718 +
1719 + do {
1720 + index = index2;
1721 ++ /* wDatagramIndex[0] */
1722 ++ if ((index < opts->nth_size) ||
1723 ++ (index > block_len - opts->dpe_size)) {
1724 ++ INFO(port->func.config->cdev,
1725 ++ "Bad index: %#X\n", index);
1726 ++ goto err;
1727 ++ }
1728 ++
1729 + dg_len = dg_len2;
1730 +- if (dg_len < 14 + crc_len) { /* ethernet hdr + crc */
1731 ++ /*
1732 ++ * wDatagramLength[0]
1733 ++ * ethernet hdr + crc or larger than max frame size
1734 ++ */
1735 ++ if ((dg_len < 14 + crc_len) ||
1736 ++ (dg_len > frame_max)) {
1737 + INFO(port->func.config->cdev,
1738 + "Bad dgram length: %#X\n", dg_len);
1739 + goto err;
1740 +@@ -1304,6 +1333,37 @@ static int ncm_unwrap_ntb(struct gether *port,
1741 + index2 = get_ncm(&tmp, opts->dgram_item_len);
1742 + dg_len2 = get_ncm(&tmp, opts->dgram_item_len);
1743 +
1744 ++ if (index2 == 0 || dg_len2 == 0)
1745 ++ break;
1746 ++
1747 ++ /* wDatagramIndex[1] */
1748 ++ if (ndp_after_header) {
1749 ++ if (index2 < opts->nth_size + opts->ndp_size) {
1750 ++ INFO(port->func.config->cdev,
1751 ++ "Bad index: %#X\n", index2);
1752 ++ goto err;
1753 ++ }
1754 ++ } else {
1755 ++ if (index2 < opts->nth_size + opts->dpe_size) {
1756 ++ INFO(port->func.config->cdev,
1757 ++ "Bad index: %#X\n", index2);
1758 ++ goto err;
1759 ++ }
1760 ++ }
1761 ++ if (index2 > block_len - opts->dpe_size) {
1762 ++ INFO(port->func.config->cdev,
1763 ++ "Bad index: %#X\n", index2);
1764 ++ goto err;
1765 ++ }
1766 ++
1767 ++ /* wDatagramLength[1] */
1768 ++ if ((dg_len2 < 14 + crc_len) ||
1769 ++ (dg_len2 > frame_max)) {
1770 ++ INFO(port->func.config->cdev,
1771 ++ "Bad dgram length: %#X\n", dg_len);
1772 ++ goto err;
1773 ++ }
1774 ++
1775 + /*
1776 + * Copy the data into a new skb.
1777 + * This ensures the truesize is correct
1778 +@@ -1320,9 +1380,6 @@ static int ncm_unwrap_ntb(struct gether *port,
1779 + ndp_len -= 2 * (opts->dgram_item_len * 2);
1780 +
1781 + dgram_counter++;
1782 +-
1783 +- if (index2 == 0 || dg_len2 == 0)
1784 +- break;
1785 + } while (ndp_len > 2 * (opts->dgram_item_len * 2));
1786 + } while (ndp_index);
1787 +
1788 +diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
1789 +index a82e2bd5ea34d..c41d09166a1d6 100644
1790 +--- a/drivers/usb/gadget/function/f_tcm.c
1791 ++++ b/drivers/usb/gadget/function/f_tcm.c
1792 +@@ -751,12 +751,13 @@ static int uasp_alloc_stream_res(struct f_uas *fu, struct uas_stream *stream)
1793 + goto err_sts;
1794 +
1795 + return 0;
1796 ++
1797 + err_sts:
1798 +- usb_ep_free_request(fu->ep_status, stream->req_status);
1799 +- stream->req_status = NULL;
1800 +-err_out:
1801 + usb_ep_free_request(fu->ep_out, stream->req_out);
1802 + stream->req_out = NULL;
1803 ++err_out:
1804 ++ usb_ep_free_request(fu->ep_in, stream->req_in);
1805 ++ stream->req_in = NULL;
1806 + out:
1807 + return -ENOMEM;
1808 + }
1809 +diff --git a/drivers/usb/gadget/u_f.h b/drivers/usb/gadget/u_f.h
1810 +index 2f03334c68741..d150a6795f481 100644
1811 +--- a/drivers/usb/gadget/u_f.h
1812 ++++ b/drivers/usb/gadget/u_f.h
1813 +@@ -17,6 +17,7 @@
1814 + #define __U_F_H__
1815 +
1816 + #include <linux/usb/gadget.h>
1817 ++#include <linux/overflow.h>
1818 +
1819 + /* Variable Length Array Macros **********************************************/
1820 + #define vla_group(groupname) size_t groupname##__next = 0
1821 +@@ -24,21 +25,36 @@
1822 +
1823 + #define vla_item(groupname, type, name, n) \
1824 + size_t groupname##_##name##__offset = ({ \
1825 +- size_t align_mask = __alignof__(type) - 1; \
1826 +- size_t offset = (groupname##__next + align_mask) & ~align_mask;\
1827 +- size_t size = (n) * sizeof(type); \
1828 +- groupname##__next = offset + size; \
1829 ++ size_t offset = 0; \
1830 ++ if (groupname##__next != SIZE_MAX) { \
1831 ++ size_t align_mask = __alignof__(type) - 1; \
1832 ++ size_t size = array_size(n, sizeof(type)); \
1833 ++ offset = (groupname##__next + align_mask) & \
1834 ++ ~align_mask; \
1835 ++ if (check_add_overflow(offset, size, \
1836 ++ &groupname##__next)) { \
1837 ++ groupname##__next = SIZE_MAX; \
1838 ++ offset = 0; \
1839 ++ } \
1840 ++ } \
1841 + offset; \
1842 + })
1843 +
1844 + #define vla_item_with_sz(groupname, type, name, n) \
1845 +- size_t groupname##_##name##__sz = (n) * sizeof(type); \
1846 +- size_t groupname##_##name##__offset = ({ \
1847 +- size_t align_mask = __alignof__(type) - 1; \
1848 +- size_t offset = (groupname##__next + align_mask) & ~align_mask;\
1849 +- size_t size = groupname##_##name##__sz; \
1850 +- groupname##__next = offset + size; \
1851 +- offset; \
1852 ++ size_t groupname##_##name##__sz = array_size(n, sizeof(type)); \
1853 ++ size_t groupname##_##name##__offset = ({ \
1854 ++ size_t offset = 0; \
1855 ++ if (groupname##__next != SIZE_MAX) { \
1856 ++ size_t align_mask = __alignof__(type) - 1; \
1857 ++ offset = (groupname##__next + align_mask) & \
1858 ++ ~align_mask; \
1859 ++ if (check_add_overflow(offset, groupname##_##name##__sz,\
1860 ++ &groupname##__next)) { \
1861 ++ groupname##__next = SIZE_MAX; \
1862 ++ offset = 0; \
1863 ++ } \
1864 ++ } \
1865 ++ offset; \
1866 + })
1867 +
1868 + #define vla_ptr(ptr, groupname, name) \
1869 +diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
1870 +index 6865b919403f7..2ed062a2e93b4 100644
1871 +--- a/drivers/usb/host/ohci-exynos.c
1872 ++++ b/drivers/usb/host/ohci-exynos.c
1873 +@@ -166,9 +166,8 @@ skip_phy:
1874 + hcd->rsrc_len = resource_size(res);
1875 +
1876 + irq = platform_get_irq(pdev, 0);
1877 +- if (!irq) {
1878 +- dev_err(&pdev->dev, "Failed to get IRQ\n");
1879 +- err = -ENODEV;
1880 ++ if (irq < 0) {
1881 ++ err = irq;
1882 + goto fail_io;
1883 + }
1884 +
1885 +diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
1886 +index 3bb38d9dc45bf..592f8183af280 100644
1887 +--- a/drivers/usb/host/xhci-hub.c
1888 ++++ b/drivers/usb/host/xhci-hub.c
1889 +@@ -750,15 +750,6 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci,
1890 + {
1891 + u32 pls = status_reg & PORT_PLS_MASK;
1892 +
1893 +- /* resume state is a xHCI internal state.
1894 +- * Do not report it to usb core, instead, pretend to be U3,
1895 +- * thus usb core knows it's not ready for transfer
1896 +- */
1897 +- if (pls == XDEV_RESUME) {
1898 +- *status |= USB_SS_PORT_LS_U3;
1899 +- return;
1900 +- }
1901 +-
1902 + /* When the CAS bit is set then warm reset
1903 + * should be performed on port
1904 + */
1905 +@@ -780,6 +771,16 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci,
1906 + */
1907 + pls |= USB_PORT_STAT_CONNECTION;
1908 + } else {
1909 ++ /*
1910 ++ * Resume state is an xHCI internal state. Do not report it to
1911 ++ * usb core, instead, pretend to be U3, thus usb core knows
1912 ++ * it's not ready for transfer.
1913 ++ */
1914 ++ if (pls == XDEV_RESUME) {
1915 ++ *status |= USB_SS_PORT_LS_U3;
1916 ++ return;
1917 ++ }
1918 ++
1919 + /*
1920 + * If CAS bit isn't set but the Port is already at
1921 + * Compliance Mode, fake a connection so the USB core
1922 +diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c
1923 +index ddddd6387f664..e4a7510f9b0e1 100644
1924 +--- a/drivers/usb/misc/lvstest.c
1925 ++++ b/drivers/usb/misc/lvstest.c
1926 +@@ -432,7 +432,7 @@ static int lvs_rh_probe(struct usb_interface *intf,
1927 + USB_DT_SS_HUB_SIZE, USB_CTRL_GET_TIMEOUT);
1928 + if (ret < (USB_DT_HUB_NONVAR_SIZE + 2)) {
1929 + dev_err(&hdev->dev, "wrong root hub descriptor read %d\n", ret);
1930 +- return ret;
1931 ++ return ret < 0 ? ret : -EINVAL;
1932 + }
1933 +
1934 + /* submit urb to poll interrupt endpoint */
1935 +diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
1936 +index a6f88442a53a9..a020d5eafb4a5 100644
1937 +--- a/drivers/usb/misc/sisusbvga/sisusb.c
1938 ++++ b/drivers/usb/misc/sisusbvga/sisusb.c
1939 +@@ -760,7 +760,7 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
1940 + u8 swap8, fromkern = kernbuffer ? 1 : 0;
1941 + u16 swap16;
1942 + u32 swap32, flag = (length >> 28) & 1;
1943 +- char buf[4];
1944 ++ u8 buf[4];
1945 +
1946 + /* if neither kernbuffer not userbuffer are given, assume
1947 + * data in obuf
1948 +diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
1949 +index ec42f6b75564e..cf4a7ef4e663d 100644
1950 +--- a/drivers/usb/misc/yurex.c
1951 ++++ b/drivers/usb/misc/yurex.c
1952 +@@ -496,7 +496,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
1953 + prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE);
1954 + dev_dbg(&dev->interface->dev, "%s - submit %c\n", __func__,
1955 + dev->cntl_buffer[0]);
1956 +- retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL);
1957 ++ retval = usb_submit_urb(dev->cntl_urb, GFP_ATOMIC);
1958 + if (retval >= 0)
1959 + timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);
1960 + finish_wait(&dev->waitq, &wait);
1961 +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
1962 +index 5c3f2eaf59e8c..e77140a5b6729 100644
1963 +--- a/drivers/usb/storage/unusual_devs.h
1964 ++++ b/drivers/usb/storage/unusual_devs.h
1965 +@@ -2347,7 +2347,7 @@ UNUSUAL_DEV( 0x357d, 0x7788, 0x0114, 0x0114,
1966 + "JMicron",
1967 + "USB to ATA/ATAPI Bridge",
1968 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1969 +- US_FL_BROKEN_FUA ),
1970 ++ US_FL_BROKEN_FUA | US_FL_IGNORE_UAS ),
1971 +
1972 + /* Reported by Andrey Rahmatullin <wrar@××××××××.org> */
1973 + UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100,
1974 +diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
1975 +index 4df15faa66d71..018b0663d6109 100644
1976 +--- a/drivers/usb/storage/unusual_uas.h
1977 ++++ b/drivers/usb/storage/unusual_uas.h
1978 +@@ -41,6 +41,13 @@
1979 + * and don't forget to CC: the USB development list <linux-usb@×××××××××××.org>
1980 + */
1981 +
1982 ++/* Reported-by: Till Dörges <doerges@×××××××××.de> */
1983 ++UNUSUAL_DEV(0x054c, 0x087d, 0x0000, 0x9999,
1984 ++ "Sony",
1985 ++ "PSZ-HA*",
1986 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1987 ++ US_FL_NO_REPORT_OPCODES),
1988 ++
1989 + /* Reported-by: Julian Groß <julian.g@××××××.de> */
1990 + UNUSUAL_DEV(0x059f, 0x105f, 0x0000, 0x9999,
1991 + "LaCie",
1992 +@@ -156,6 +163,13 @@ UNUSUAL_DEV(0x152d, 0x0578, 0x0000, 0x9999,
1993 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1994 + US_FL_BROKEN_FUA),
1995 +
1996 ++/* Reported-by: Thinh Nguyen <thinhn@××××××××.com> */
1997 ++UNUSUAL_DEV(0x154b, 0xf00d, 0x0000, 0x9999,
1998 ++ "PNY",
1999 ++ "Pro Elite SSD",
2000 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2001 ++ US_FL_NO_ATA_1X),
2002 ++
2003 + /* Reported-by: Hans de Goede <hdegoede@××××××.com> */
2004 + UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999,
2005 + "VIA",
2006 +diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
2007 +index 41360caff17f8..be31be84af67d 100644
2008 +--- a/drivers/video/fbdev/core/fbcon.c
2009 ++++ b/drivers/video/fbdev/core/fbcon.c
2010 +@@ -2130,6 +2130,9 @@ static void updatescrollmode(struct display *p,
2011 + }
2012 + }
2013 +
2014 ++#define PITCH(w) (((w) + 7) >> 3)
2015 ++#define CALC_FONTSZ(h, p, c) ((h) * (p) * (c)) /* size = height * pitch * charcount */
2016 ++
2017 + static int fbcon_resize(struct vc_data *vc, unsigned int width,
2018 + unsigned int height, unsigned int user)
2019 + {
2020 +@@ -2139,6 +2142,24 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
2021 + struct fb_var_screeninfo var = info->var;
2022 + int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh;
2023 +
2024 ++ if (ops->p && ops->p->userfont && FNTSIZE(vc->vc_font.data)) {
2025 ++ int size;
2026 ++ int pitch = PITCH(vc->vc_font.width);
2027 ++
2028 ++ /*
2029 ++ * If user font, ensure that a possible change to user font
2030 ++ * height or width will not allow a font data out-of-bounds access.
2031 ++ * NOTE: must use original charcount in calculation as font
2032 ++ * charcount can change and cannot be used to determine the
2033 ++ * font data allocated size.
2034 ++ */
2035 ++ if (pitch <= 0)
2036 ++ return -EINVAL;
2037 ++ size = CALC_FONTSZ(vc->vc_font.height, pitch, FNTCHARCNT(vc->vc_font.data));
2038 ++ if (size > FNTSIZE(vc->vc_font.data))
2039 ++ return -EINVAL;
2040 ++ }
2041 ++
2042 + virt_w = FBCON_SWAP(ops->rotate, width, height);
2043 + virt_h = FBCON_SWAP(ops->rotate, height, width);
2044 + virt_fw = FBCON_SWAP(ops->rotate, vc->vc_font.width,
2045 +@@ -2600,7 +2621,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigne
2046 + int size;
2047 + int i, csum;
2048 + u8 *new_data, *data = font->data;
2049 +- int pitch = (font->width+7) >> 3;
2050 ++ int pitch = PITCH(font->width);
2051 +
2052 + /* Is there a reason why fbconsole couldn't handle any charcount >256?
2053 + * If not this check should be changed to charcount < 256 */
2054 +@@ -2616,7 +2637,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigne
2055 + if (fbcon_invalid_charcount(info, charcount))
2056 + return -EINVAL;
2057 +
2058 +- size = h * pitch * charcount;
2059 ++ size = CALC_FONTSZ(h, pitch, charcount);
2060 +
2061 + new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER);
2062 +
2063 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dispc.c b/drivers/video/fbdev/omap2/omapfb/dss/dispc.c
2064 +index 7a75dfda98457..00f5a54aaf9b7 100644
2065 +--- a/drivers/video/fbdev/omap2/omapfb/dss/dispc.c
2066 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/dispc.c
2067 +@@ -531,8 +531,11 @@ int dispc_runtime_get(void)
2068 + DSSDBG("dispc_runtime_get\n");
2069 +
2070 + r = pm_runtime_get_sync(&dispc.pdev->dev);
2071 +- WARN_ON(r < 0);
2072 +- return r < 0 ? r : 0;
2073 ++ if (WARN_ON(r < 0)) {
2074 ++ pm_runtime_put_sync(&dispc.pdev->dev);
2075 ++ return r;
2076 ++ }
2077 ++ return 0;
2078 + }
2079 + EXPORT_SYMBOL(dispc_runtime_get);
2080 +
2081 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
2082 +index 30d49f3800b33..2bfd9063cdfc3 100644
2083 +--- a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
2084 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
2085 +@@ -1148,8 +1148,11 @@ static int dsi_runtime_get(struct platform_device *dsidev)
2086 + DSSDBG("dsi_runtime_get\n");
2087 +
2088 + r = pm_runtime_get_sync(&dsi->pdev->dev);
2089 +- WARN_ON(r < 0);
2090 +- return r < 0 ? r : 0;
2091 ++ if (WARN_ON(r < 0)) {
2092 ++ pm_runtime_put_sync(&dsi->pdev->dev);
2093 ++ return r;
2094 ++ }
2095 ++ return 0;
2096 + }
2097 +
2098 + static void dsi_runtime_put(struct platform_device *dsidev)
2099 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss.c b/drivers/video/fbdev/omap2/omapfb/dss/dss.c
2100 +index 4429ad37b64cd..acecee5b1c102 100644
2101 +--- a/drivers/video/fbdev/omap2/omapfb/dss/dss.c
2102 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/dss.c
2103 +@@ -778,8 +778,11 @@ int dss_runtime_get(void)
2104 + DSSDBG("dss_runtime_get\n");
2105 +
2106 + r = pm_runtime_get_sync(&dss.pdev->dev);
2107 +- WARN_ON(r < 0);
2108 +- return r < 0 ? r : 0;
2109 ++ if (WARN_ON(r < 0)) {
2110 ++ pm_runtime_put_sync(&dss.pdev->dev);
2111 ++ return r;
2112 ++ }
2113 ++ return 0;
2114 + }
2115 +
2116 + void dss_runtime_put(void)
2117 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
2118 +index ec78d61bc5512..e2d571ca8590a 100644
2119 +--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
2120 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
2121 +@@ -50,9 +50,10 @@ static int hdmi_runtime_get(void)
2122 + DSSDBG("hdmi_runtime_get\n");
2123 +
2124 + r = pm_runtime_get_sync(&hdmi.pdev->dev);
2125 +- WARN_ON(r < 0);
2126 +- if (r < 0)
2127 ++ if (WARN_ON(r < 0)) {
2128 ++ pm_runtime_put_sync(&hdmi.pdev->dev);
2129 + return r;
2130 ++ }
2131 +
2132 + return 0;
2133 + }
2134 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
2135 +index 2e2fcc3d6d4f7..13f3a5ce55294 100644
2136 +--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
2137 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
2138 +@@ -54,9 +54,10 @@ static int hdmi_runtime_get(void)
2139 + DSSDBG("hdmi_runtime_get\n");
2140 +
2141 + r = pm_runtime_get_sync(&hdmi.pdev->dev);
2142 +- WARN_ON(r < 0);
2143 +- if (r < 0)
2144 ++ if (WARN_ON(r < 0)) {
2145 ++ pm_runtime_put_sync(&hdmi.pdev->dev);
2146 + return r;
2147 ++ }
2148 +
2149 + return 0;
2150 + }
2151 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/venc.c b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
2152 +index 392464da12e41..96714b4596d2d 100644
2153 +--- a/drivers/video/fbdev/omap2/omapfb/dss/venc.c
2154 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
2155 +@@ -402,8 +402,11 @@ static int venc_runtime_get(void)
2156 + DSSDBG("venc_runtime_get\n");
2157 +
2158 + r = pm_runtime_get_sync(&venc.pdev->dev);
2159 +- WARN_ON(r < 0);
2160 +- return r < 0 ? r : 0;
2161 ++ if (WARN_ON(r < 0)) {
2162 ++ pm_runtime_put_sync(&venc.pdev->dev);
2163 ++ return r;
2164 ++ }
2165 ++ return 0;
2166 + }
2167 +
2168 + static void venc_runtime_put(void)
2169 +diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
2170 +index 8d49b91d92cd3..95e5a9300ff04 100644
2171 +--- a/drivers/xen/events/events_base.c
2172 ++++ b/drivers/xen/events/events_base.c
2173 +@@ -154,7 +154,7 @@ int get_evtchn_to_irq(unsigned evtchn)
2174 + /* Get info for IRQ */
2175 + struct irq_info *info_for_irq(unsigned irq)
2176 + {
2177 +- return irq_get_handler_data(irq);
2178 ++ return irq_get_chip_data(irq);
2179 + }
2180 +
2181 + /* Constructors for packed IRQ information. */
2182 +@@ -375,7 +375,7 @@ static void xen_irq_init(unsigned irq)
2183 + info->type = IRQT_UNBOUND;
2184 + info->refcnt = -1;
2185 +
2186 +- irq_set_handler_data(irq, info);
2187 ++ irq_set_chip_data(irq, info);
2188 +
2189 + list_add_tail(&info->list, &xen_irq_list_head);
2190 + }
2191 +@@ -424,14 +424,14 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi)
2192 +
2193 + static void xen_free_irq(unsigned irq)
2194 + {
2195 +- struct irq_info *info = irq_get_handler_data(irq);
2196 ++ struct irq_info *info = irq_get_chip_data(irq);
2197 +
2198 + if (WARN_ON(!info))
2199 + return;
2200 +
2201 + list_del(&info->list);
2202 +
2203 +- irq_set_handler_data(irq, NULL);
2204 ++ irq_set_chip_data(irq, NULL);
2205 +
2206 + WARN_ON(info->refcnt > 0);
2207 +
2208 +@@ -601,7 +601,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi);
2209 + static void __unbind_from_irq(unsigned int irq)
2210 + {
2211 + int evtchn = evtchn_from_irq(irq);
2212 +- struct irq_info *info = irq_get_handler_data(irq);
2213 ++ struct irq_info *info = irq_get_chip_data(irq);
2214 +
2215 + if (info->refcnt > 0) {
2216 + info->refcnt--;
2217 +@@ -1105,7 +1105,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
2218 +
2219 + void unbind_from_irqhandler(unsigned int irq, void *dev_id)
2220 + {
2221 +- struct irq_info *info = irq_get_handler_data(irq);
2222 ++ struct irq_info *info = irq_get_chip_data(irq);
2223 +
2224 + if (WARN_ON(!info))
2225 + return;
2226 +@@ -1139,7 +1139,7 @@ int evtchn_make_refcounted(unsigned int evtchn)
2227 + if (irq == -1)
2228 + return -ENOENT;
2229 +
2230 +- info = irq_get_handler_data(irq);
2231 ++ info = irq_get_chip_data(irq);
2232 +
2233 + if (!info)
2234 + return -ENOENT;
2235 +@@ -1167,7 +1167,7 @@ int evtchn_get(unsigned int evtchn)
2236 + if (irq == -1)
2237 + goto done;
2238 +
2239 +- info = irq_get_handler_data(irq);
2240 ++ info = irq_get_chip_data(irq);
2241 +
2242 + if (!info)
2243 + goto done;
2244 +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
2245 +index 893066970c689..495430e4f84be 100644
2246 +--- a/fs/btrfs/disk-io.c
2247 ++++ b/fs/btrfs/disk-io.c
2248 +@@ -4344,6 +4344,7 @@ static void btrfs_cleanup_bg_io(struct btrfs_block_group_cache *cache)
2249 + cache->io_ctl.inode = NULL;
2250 + iput(inode);
2251 + }
2252 ++ ASSERT(cache->io_ctl.pages == NULL);
2253 + btrfs_put_block_group(cache);
2254 + }
2255 +
2256 +diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
2257 +index 57f89708fab1c..9bf72a9088aca 100644
2258 +--- a/fs/btrfs/free-space-cache.c
2259 ++++ b/fs/btrfs/free-space-cache.c
2260 +@@ -1169,7 +1169,6 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
2261 + ret = update_cache_item(trans, root, inode, path, offset,
2262 + io_ctl->entries, io_ctl->bitmaps);
2263 + out:
2264 +- io_ctl_free(io_ctl);
2265 + if (ret) {
2266 + invalidate_inode_pages2(inode->i_mapping);
2267 + BTRFS_I(inode)->generation = 0;
2268 +@@ -1334,6 +1333,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
2269 + * them out later
2270 + */
2271 + io_ctl_drop_pages(io_ctl);
2272 ++ io_ctl_free(io_ctl);
2273 +
2274 + unlock_extent_cached(&BTRFS_I(inode)->io_tree, 0,
2275 + i_size_read(inode) - 1, &cached_state, GFP_NOFS);
2276 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
2277 +index 3d30bf90d59ec..ec8706a6e9c66 100644
2278 +--- a/fs/btrfs/tree-log.c
2279 ++++ b/fs/btrfs/tree-log.c
2280 +@@ -3311,11 +3311,13 @@ fail:
2281 + btrfs_free_path(path);
2282 + out_unlock:
2283 + mutex_unlock(&dir->log_mutex);
2284 +- if (ret == -ENOSPC) {
2285 ++ if (err == -ENOSPC) {
2286 + btrfs_set_log_full_commit(root->fs_info, trans);
2287 +- ret = 0;
2288 +- } else if (ret < 0)
2289 +- btrfs_abort_transaction(trans, ret);
2290 ++ err = 0;
2291 ++ } else if (err < 0 && err != -ENOENT) {
2292 ++ /* ENOENT can be returned if the entry hasn't been fsynced yet */
2293 ++ btrfs_abort_transaction(trans, err);
2294 ++ }
2295 +
2296 + btrfs_end_log_trans(root);
2297 +
2298 +diff --git a/fs/buffer.c b/fs/buffer.c
2299 +index cae7f24a0410e..9fbeddb6834a4 100644
2300 +--- a/fs/buffer.c
2301 ++++ b/fs/buffer.c
2302 +@@ -3250,6 +3250,15 @@ int __sync_dirty_buffer(struct buffer_head *bh, int op_flags)
2303 + WARN_ON(atomic_read(&bh->b_count) < 1);
2304 + lock_buffer(bh);
2305 + if (test_clear_buffer_dirty(bh)) {
2306 ++ /*
2307 ++ * The bh should be mapped, but it might not be if the
2308 ++ * device was hot-removed. Not much we can do but fail the I/O.
2309 ++ */
2310 ++ if (!buffer_mapped(bh)) {
2311 ++ unlock_buffer(bh);
2312 ++ return -EIO;
2313 ++ }
2314 ++
2315 + get_bh(bh);
2316 + bh->b_end_io = end_buffer_write_sync;
2317 + ret = submit_bh(REQ_OP_WRITE, op_flags, bh);
2318 +diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
2319 +index f36ddfea4997e..06109314d93c8 100644
2320 +--- a/fs/ceph/mds_client.c
2321 ++++ b/fs/ceph/mds_client.c
2322 +@@ -3518,6 +3518,9 @@ static void delayed_work(struct work_struct *work)
2323 + dout("mdsc delayed_work\n");
2324 + ceph_check_delayed_caps(mdsc);
2325 +
2326 ++ if (mdsc->stopping)
2327 ++ return;
2328 ++
2329 + mutex_lock(&mdsc->mutex);
2330 + renew_interval = mdsc->mdsmap->m_session_timeout >> 2;
2331 + renew_caps = time_after_eq(jiffies, HZ*renew_interval +
2332 +@@ -3851,7 +3854,16 @@ void ceph_mdsc_force_umount(struct ceph_mds_client *mdsc)
2333 + static void ceph_mdsc_stop(struct ceph_mds_client *mdsc)
2334 + {
2335 + dout("stop\n");
2336 +- cancel_delayed_work_sync(&mdsc->delayed_work); /* cancel timer */
2337 ++ /*
2338 ++ * Make sure the delayed work stopped before releasing
2339 ++ * the resources.
2340 ++ *
2341 ++ * Because the cancel_delayed_work_sync() will only
2342 ++ * guarantee that the work finishes executing. But the
2343 ++ * delayed work will re-arm itself again after that.
2344 ++ */
2345 ++ flush_delayed_work(&mdsc->delayed_work);
2346 ++
2347 + if (mdsc->mdsmap)
2348 + ceph_mdsmap_destroy(mdsc->mdsmap);
2349 + kfree(mdsc->sessions);
2350 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
2351 +index ffc985d781373..634c822d1dc98 100644
2352 +--- a/fs/ext4/super.c
2353 ++++ b/fs/ext4/super.c
2354 +@@ -63,10 +63,10 @@ static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
2355 + unsigned long journal_devnum);
2356 + static int ext4_show_options(struct seq_file *seq, struct dentry *root);
2357 + static int ext4_commit_super(struct super_block *sb, int sync);
2358 +-static void ext4_mark_recovery_complete(struct super_block *sb,
2359 ++static int ext4_mark_recovery_complete(struct super_block *sb,
2360 + struct ext4_super_block *es);
2361 +-static void ext4_clear_journal_err(struct super_block *sb,
2362 +- struct ext4_super_block *es);
2363 ++static int ext4_clear_journal_err(struct super_block *sb,
2364 ++ struct ext4_super_block *es);
2365 + static int ext4_sync_fs(struct super_block *sb, int wait);
2366 + static int ext4_remount(struct super_block *sb, int *flags, char *data);
2367 + static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf);
2368 +@@ -4458,7 +4458,9 @@ no_journal:
2369 + EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS;
2370 + if (needs_recovery) {
2371 + ext4_msg(sb, KERN_INFO, "recovery complete");
2372 +- ext4_mark_recovery_complete(sb, es);
2373 ++ err = ext4_mark_recovery_complete(sb, es);
2374 ++ if (err)
2375 ++ goto failed_mount8;
2376 + }
2377 + if (EXT4_SB(sb)->s_journal) {
2378 + if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
2379 +@@ -4501,10 +4503,8 @@ cantfind_ext4:
2380 + ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem");
2381 + goto failed_mount;
2382 +
2383 +-#ifdef CONFIG_QUOTA
2384 + failed_mount8:
2385 + ext4_unregister_sysfs(sb);
2386 +-#endif
2387 + failed_mount7:
2388 + ext4_unregister_li_request(sb);
2389 + failed_mount6:
2390 +@@ -4640,7 +4640,8 @@ static journal_t *ext4_get_journal(struct super_block *sb,
2391 + struct inode *journal_inode;
2392 + journal_t *journal;
2393 +
2394 +- BUG_ON(!ext4_has_feature_journal(sb));
2395 ++ if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
2396 ++ return NULL;
2397 +
2398 + journal_inode = ext4_get_journal_inode(sb, journal_inum);
2399 + if (!journal_inode)
2400 +@@ -4670,7 +4671,8 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
2401 + struct ext4_super_block *es;
2402 + struct block_device *bdev;
2403 +
2404 +- BUG_ON(!ext4_has_feature_journal(sb));
2405 ++ if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
2406 ++ return NULL;
2407 +
2408 + bdev = ext4_blkdev_get(j_dev, sb);
2409 + if (bdev == NULL)
2410 +@@ -4762,7 +4764,8 @@ static int ext4_load_journal(struct super_block *sb,
2411 + int err = 0;
2412 + int really_read_only;
2413 +
2414 +- BUG_ON(!ext4_has_feature_journal(sb));
2415 ++ if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
2416 ++ return -EFSCORRUPTED;
2417 +
2418 + if (journal_devnum &&
2419 + journal_devnum != le32_to_cpu(es->s_journal_dev)) {
2420 +@@ -4831,7 +4834,12 @@ static int ext4_load_journal(struct super_block *sb,
2421 + }
2422 +
2423 + EXT4_SB(sb)->s_journal = journal;
2424 +- ext4_clear_journal_err(sb, es);
2425 ++ err = ext4_clear_journal_err(sb, es);
2426 ++ if (err) {
2427 ++ EXT4_SB(sb)->s_journal = NULL;
2428 ++ jbd2_journal_destroy(journal);
2429 ++ return err;
2430 ++ }
2431 +
2432 + if (!really_read_only && journal_devnum &&
2433 + journal_devnum != le32_to_cpu(es->s_journal_dev)) {
2434 +@@ -4853,13 +4861,6 @@ static int ext4_commit_super(struct super_block *sb, int sync)
2435 + if (!sbh || block_device_ejected(sb))
2436 + return error;
2437 +
2438 +- /*
2439 +- * The superblock bh should be mapped, but it might not be if the
2440 +- * device was hot-removed. Not much we can do but fail the I/O.
2441 +- */
2442 +- if (!buffer_mapped(sbh))
2443 +- return error;
2444 +-
2445 + /*
2446 + * If the file system is mounted read-only, don't update the
2447 + * superblock write time. This avoids updating the superblock
2448 +@@ -4930,26 +4931,32 @@ static int ext4_commit_super(struct super_block *sb, int sync)
2449 + * remounting) the filesystem readonly, then we will end up with a
2450 + * consistent fs on disk. Record that fact.
2451 + */
2452 +-static void ext4_mark_recovery_complete(struct super_block *sb,
2453 +- struct ext4_super_block *es)
2454 ++static int ext4_mark_recovery_complete(struct super_block *sb,
2455 ++ struct ext4_super_block *es)
2456 + {
2457 ++ int err;
2458 + journal_t *journal = EXT4_SB(sb)->s_journal;
2459 +
2460 + if (!ext4_has_feature_journal(sb)) {
2461 +- BUG_ON(journal != NULL);
2462 +- return;
2463 ++ if (journal != NULL) {
2464 ++ ext4_error(sb, "Journal got removed while the fs was "
2465 ++ "mounted!");
2466 ++ return -EFSCORRUPTED;
2467 ++ }
2468 ++ return 0;
2469 + }
2470 + jbd2_journal_lock_updates(journal);
2471 +- if (jbd2_journal_flush(journal) < 0)
2472 ++ err = jbd2_journal_flush(journal);
2473 ++ if (err < 0)
2474 + goto out;
2475 +
2476 + if (ext4_has_feature_journal_needs_recovery(sb) && sb_rdonly(sb)) {
2477 + ext4_clear_feature_journal_needs_recovery(sb);
2478 + ext4_commit_super(sb, 1);
2479 + }
2480 +-
2481 + out:
2482 + jbd2_journal_unlock_updates(journal);
2483 ++ return err;
2484 + }
2485 +
2486 + /*
2487 +@@ -4957,14 +4964,17 @@ out:
2488 + * has recorded an error from a previous lifetime, move that error to the
2489 + * main filesystem now.
2490 + */
2491 +-static void ext4_clear_journal_err(struct super_block *sb,
2492 ++static int ext4_clear_journal_err(struct super_block *sb,
2493 + struct ext4_super_block *es)
2494 + {
2495 + journal_t *journal;
2496 + int j_errno;
2497 + const char *errstr;
2498 +
2499 +- BUG_ON(!ext4_has_feature_journal(sb));
2500 ++ if (!ext4_has_feature_journal(sb)) {
2501 ++ ext4_error(sb, "Journal got removed while the fs was mounted!");
2502 ++ return -EFSCORRUPTED;
2503 ++ }
2504 +
2505 + journal = EXT4_SB(sb)->s_journal;
2506 +
2507 +@@ -4989,6 +4999,7 @@ static void ext4_clear_journal_err(struct super_block *sb,
2508 + jbd2_journal_clear_err(journal);
2509 + jbd2_journal_update_sb_errno(journal);
2510 + }
2511 ++ return 0;
2512 + }
2513 +
2514 + /*
2515 +@@ -5268,8 +5279,13 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
2516 + (sbi->s_mount_state & EXT4_VALID_FS))
2517 + es->s_state = cpu_to_le16(sbi->s_mount_state);
2518 +
2519 +- if (sbi->s_journal)
2520 ++ if (sbi->s_journal) {
2521 ++ /*
2522 ++ * We let remount-ro finish even if marking fs
2523 ++ * as clean failed...
2524 ++ */
2525 + ext4_mark_recovery_complete(sb, es);
2526 ++ }
2527 + if (sbi->s_mmp_tsk)
2528 + kthread_stop(sbi->s_mmp_tsk);
2529 + } else {
2530 +@@ -5317,8 +5333,11 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
2531 + * been changed by e2fsck since we originally mounted
2532 + * the partition.)
2533 + */
2534 +- if (sbi->s_journal)
2535 +- ext4_clear_journal_err(sb, es);
2536 ++ if (sbi->s_journal) {
2537 ++ err = ext4_clear_journal_err(sb, es);
2538 ++ if (err)
2539 ++ goto restore_opts;
2540 ++ }
2541 + sbi->s_mount_state = le16_to_cpu(es->s_state);
2542 + if (!ext4_setup_super(sb, es, 0))
2543 + sb->s_flags &= ~MS_RDONLY;
2544 +diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
2545 +index 89319c3524061..990339c538b0a 100644
2546 +--- a/fs/f2fs/super.c
2547 ++++ b/fs/f2fs/super.c
2548 +@@ -782,6 +782,9 @@ static void f2fs_put_super(struct super_block *sb)
2549 + struct f2fs_sb_info *sbi = F2FS_SB(sb);
2550 + int i;
2551 +
2552 ++ /* unregister procfs/sysfs entries in advance to avoid race case */
2553 ++ f2fs_unregister_sysfs(sbi);
2554 ++
2555 + f2fs_quota_off_umount(sb);
2556 +
2557 + /* prevent remaining shrinker jobs */
2558 +@@ -834,8 +837,6 @@ static void f2fs_put_super(struct super_block *sb)
2559 +
2560 + kfree(sbi->ckpt);
2561 +
2562 +- f2fs_unregister_sysfs(sbi);
2563 +-
2564 + sb->s_fs_info = NULL;
2565 + if (sbi->s_chksum_driver)
2566 + crypto_free_shash(sbi->s_chksum_driver);
2567 +diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
2568 +index fe907ff91eeb5..3dbb875ed7903 100644
2569 +--- a/fs/fs-writeback.c
2570 ++++ b/fs/fs-writeback.c
2571 +@@ -45,7 +45,6 @@ struct wb_completion {
2572 + struct wb_writeback_work {
2573 + long nr_pages;
2574 + struct super_block *sb;
2575 +- unsigned long *older_than_this;
2576 + enum writeback_sync_modes sync_mode;
2577 + unsigned int tagged_writepages:1;
2578 + unsigned int for_kupdate:1;
2579 +@@ -160,7 +159,9 @@ static void inode_io_list_del_locked(struct inode *inode,
2580 + struct bdi_writeback *wb)
2581 + {
2582 + assert_spin_locked(&wb->list_lock);
2583 ++ assert_spin_locked(&inode->i_lock);
2584 +
2585 ++ inode->i_state &= ~I_SYNC_QUEUED;
2586 + list_del_init(&inode->i_io_list);
2587 + wb_io_lists_depopulated(wb);
2588 + }
2589 +@@ -1039,7 +1040,9 @@ void inode_io_list_del(struct inode *inode)
2590 + struct bdi_writeback *wb;
2591 +
2592 + wb = inode_to_wb_and_lock_list(inode);
2593 ++ spin_lock(&inode->i_lock);
2594 + inode_io_list_del_locked(inode, wb);
2595 ++ spin_unlock(&inode->i_lock);
2596 + spin_unlock(&wb->list_lock);
2597 + }
2598 +
2599 +@@ -1088,8 +1091,10 @@ void sb_clear_inode_writeback(struct inode *inode)
2600 + * the case then the inode must have been redirtied while it was being written
2601 + * out and we don't reset its dirtied_when.
2602 + */
2603 +-static void redirty_tail(struct inode *inode, struct bdi_writeback *wb)
2604 ++static void redirty_tail_locked(struct inode *inode, struct bdi_writeback *wb)
2605 + {
2606 ++ assert_spin_locked(&inode->i_lock);
2607 ++
2608 + if (!list_empty(&wb->b_dirty)) {
2609 + struct inode *tail;
2610 +
2611 +@@ -1098,6 +1103,14 @@ static void redirty_tail(struct inode *inode, struct bdi_writeback *wb)
2612 + inode->dirtied_when = jiffies;
2613 + }
2614 + inode_io_list_move_locked(inode, wb, &wb->b_dirty);
2615 ++ inode->i_state &= ~I_SYNC_QUEUED;
2616 ++}
2617 ++
2618 ++static void redirty_tail(struct inode *inode, struct bdi_writeback *wb)
2619 ++{
2620 ++ spin_lock(&inode->i_lock);
2621 ++ redirty_tail_locked(inode, wb);
2622 ++ spin_unlock(&inode->i_lock);
2623 + }
2624 +
2625 + /*
2626 +@@ -1136,16 +1149,13 @@ static bool inode_dirtied_after(struct inode *inode, unsigned long t)
2627 + #define EXPIRE_DIRTY_ATIME 0x0001
2628 +
2629 + /*
2630 +- * Move expired (dirtied before work->older_than_this) dirty inodes from
2631 ++ * Move expired (dirtied before dirtied_before) dirty inodes from
2632 + * @delaying_queue to @dispatch_queue.
2633 + */
2634 + static int move_expired_inodes(struct list_head *delaying_queue,
2635 + struct list_head *dispatch_queue,
2636 +- int flags,
2637 +- struct wb_writeback_work *work)
2638 ++ int flags, unsigned long dirtied_before)
2639 + {
2640 +- unsigned long *older_than_this = NULL;
2641 +- unsigned long expire_time;
2642 + LIST_HEAD(tmp);
2643 + struct list_head *pos, *node;
2644 + struct super_block *sb = NULL;
2645 +@@ -1153,21 +1163,17 @@ static int move_expired_inodes(struct list_head *delaying_queue,
2646 + int do_sb_sort = 0;
2647 + int moved = 0;
2648 +
2649 +- if ((flags & EXPIRE_DIRTY_ATIME) == 0)
2650 +- older_than_this = work->older_than_this;
2651 +- else if (!work->for_sync) {
2652 +- expire_time = jiffies - (dirtytime_expire_interval * HZ);
2653 +- older_than_this = &expire_time;
2654 +- }
2655 + while (!list_empty(delaying_queue)) {
2656 + inode = wb_inode(delaying_queue->prev);
2657 +- if (older_than_this &&
2658 +- inode_dirtied_after(inode, *older_than_this))
2659 ++ if (inode_dirtied_after(inode, dirtied_before))
2660 + break;
2661 + list_move(&inode->i_io_list, &tmp);
2662 + moved++;
2663 ++ spin_lock(&inode->i_lock);
2664 + if (flags & EXPIRE_DIRTY_ATIME)
2665 +- set_bit(__I_DIRTY_TIME_EXPIRED, &inode->i_state);
2666 ++ inode->i_state |= I_DIRTY_TIME_EXPIRED;
2667 ++ inode->i_state |= I_SYNC_QUEUED;
2668 ++ spin_unlock(&inode->i_lock);
2669 + if (sb_is_blkdev_sb(inode->i_sb))
2670 + continue;
2671 + if (sb && sb != inode->i_sb)
2672 +@@ -1205,18 +1211,22 @@ out:
2673 + * |
2674 + * +--> dequeue for IO
2675 + */
2676 +-static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work)
2677 ++static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work,
2678 ++ unsigned long dirtied_before)
2679 + {
2680 + int moved;
2681 ++ unsigned long time_expire_jif = dirtied_before;
2682 +
2683 + assert_spin_locked(&wb->list_lock);
2684 + list_splice_init(&wb->b_more_io, &wb->b_io);
2685 +- moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, 0, work);
2686 ++ moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, 0, dirtied_before);
2687 ++ if (!work->for_sync)
2688 ++ time_expire_jif = jiffies - dirtytime_expire_interval * HZ;
2689 + moved += move_expired_inodes(&wb->b_dirty_time, &wb->b_io,
2690 +- EXPIRE_DIRTY_ATIME, work);
2691 ++ EXPIRE_DIRTY_ATIME, time_expire_jif);
2692 + if (moved)
2693 + wb_io_lists_populated(wb);
2694 +- trace_writeback_queue_io(wb, work, moved);
2695 ++ trace_writeback_queue_io(wb, work, dirtied_before, moved);
2696 + }
2697 +
2698 + static int write_inode(struct inode *inode, struct writeback_control *wbc)
2699 +@@ -1310,7 +1320,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
2700 + * writeback is not making progress due to locked
2701 + * buffers. Skip this inode for now.
2702 + */
2703 +- redirty_tail(inode, wb);
2704 ++ redirty_tail_locked(inode, wb);
2705 + return;
2706 + }
2707 +
2708 +@@ -1330,7 +1340,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
2709 + * retrying writeback of the dirty page/inode
2710 + * that cannot be performed immediately.
2711 + */
2712 +- redirty_tail(inode, wb);
2713 ++ redirty_tail_locked(inode, wb);
2714 + }
2715 + } else if (inode->i_state & I_DIRTY) {
2716 + /*
2717 +@@ -1338,10 +1348,11 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
2718 + * such as delayed allocation during submission or metadata
2719 + * updates after data IO completion.
2720 + */
2721 +- redirty_tail(inode, wb);
2722 ++ redirty_tail_locked(inode, wb);
2723 + } else if (inode->i_state & I_DIRTY_TIME) {
2724 + inode->dirtied_when = jiffies;
2725 + inode_io_list_move_locked(inode, wb, &wb->b_dirty_time);
2726 ++ inode->i_state &= ~I_SYNC_QUEUED;
2727 + } else {
2728 + /* The inode is clean. Remove from writeback lists. */
2729 + inode_io_list_del_locked(inode, wb);
2730 +@@ -1585,8 +1596,8 @@ static long writeback_sb_inodes(struct super_block *sb,
2731 + */
2732 + spin_lock(&inode->i_lock);
2733 + if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) {
2734 ++ redirty_tail_locked(inode, wb);
2735 + spin_unlock(&inode->i_lock);
2736 +- redirty_tail(inode, wb);
2737 + continue;
2738 + }
2739 + if ((inode->i_state & I_SYNC) && wbc.sync_mode != WB_SYNC_ALL) {
2740 +@@ -1727,7 +1738,7 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
2741 + blk_start_plug(&plug);
2742 + spin_lock(&wb->list_lock);
2743 + if (list_empty(&wb->b_io))
2744 +- queue_io(wb, &work);
2745 ++ queue_io(wb, &work, jiffies);
2746 + __writeback_inodes_wb(wb, &work);
2747 + spin_unlock(&wb->list_lock);
2748 + blk_finish_plug(&plug);
2749 +@@ -1747,7 +1758,7 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
2750 + * takes longer than a dirty_writeback_interval interval, then leave a
2751 + * one-second gap.
2752 + *
2753 +- * older_than_this takes precedence over nr_to_write. So we'll only write back
2754 ++ * dirtied_before takes precedence over nr_to_write. So we'll only write back
2755 + * all dirty pages if they are all attached to "old" mappings.
2756 + */
2757 + static long wb_writeback(struct bdi_writeback *wb,
2758 +@@ -1755,14 +1766,11 @@ static long wb_writeback(struct bdi_writeback *wb,
2759 + {
2760 + unsigned long wb_start = jiffies;
2761 + long nr_pages = work->nr_pages;
2762 +- unsigned long oldest_jif;
2763 ++ unsigned long dirtied_before = jiffies;
2764 + struct inode *inode;
2765 + long progress;
2766 + struct blk_plug plug;
2767 +
2768 +- oldest_jif = jiffies;
2769 +- work->older_than_this = &oldest_jif;
2770 +-
2771 + blk_start_plug(&plug);
2772 + spin_lock(&wb->list_lock);
2773 + for (;;) {
2774 +@@ -1796,14 +1804,14 @@ static long wb_writeback(struct bdi_writeback *wb,
2775 + * safe.
2776 + */
2777 + if (work->for_kupdate) {
2778 +- oldest_jif = jiffies -
2779 ++ dirtied_before = jiffies -
2780 + msecs_to_jiffies(dirty_expire_interval * 10);
2781 + } else if (work->for_background)
2782 +- oldest_jif = jiffies;
2783 ++ dirtied_before = jiffies;
2784 +
2785 + trace_writeback_start(wb, work);
2786 + if (list_empty(&wb->b_io))
2787 +- queue_io(wb, work);
2788 ++ queue_io(wb, work, dirtied_before);
2789 + if (work->sb)
2790 + progress = writeback_sb_inodes(work->sb, wb, work);
2791 + else
2792 +@@ -2176,11 +2184,12 @@ void __mark_inode_dirty(struct inode *inode, int flags)
2793 + inode->i_state |= flags;
2794 +
2795 + /*
2796 +- * If the inode is being synced, just update its dirty state.
2797 +- * The unlocker will place the inode on the appropriate
2798 +- * superblock list, based upon its state.
2799 ++ * If the inode is queued for writeback by flush worker, just
2800 ++ * update its dirty state. Once the flush worker is done with
2801 ++ * the inode it will place it on the appropriate superblock
2802 ++ * list, based upon its state.
2803 + */
2804 +- if (inode->i_state & I_SYNC)
2805 ++ if (inode->i_state & I_SYNC_QUEUED)
2806 + goto out_unlock_inode;
2807 +
2808 + /*
2809 +diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
2810 +index a355ca418e788..3311b1e684def 100644
2811 +--- a/fs/jbd2/transaction.c
2812 ++++ b/fs/jbd2/transaction.c
2813 +@@ -1914,6 +1914,9 @@ static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh)
2814 + */
2815 + static void __jbd2_journal_unfile_buffer(struct journal_head *jh)
2816 + {
2817 ++ J_ASSERT_JH(jh, jh->b_transaction != NULL);
2818 ++ J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
2819 ++
2820 + __jbd2_journal_temp_unlink_buffer(jh);
2821 + jh->b_transaction = NULL;
2822 + jbd2_journal_put_journal_head(jh);
2823 +@@ -2005,6 +2008,7 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
2824 + {
2825 + struct buffer_head *head;
2826 + struct buffer_head *bh;
2827 ++ bool has_write_io_error = false;
2828 + int ret = 0;
2829 +
2830 + J_ASSERT(PageLocked(page));
2831 +@@ -2029,11 +2033,26 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
2832 + jbd_unlock_bh_state(bh);
2833 + if (buffer_jbd(bh))
2834 + goto busy;
2835 ++
2836 ++ /*
2837 ++ * If we free a metadata buffer which has been failed to
2838 ++ * write out, the jbd2 checkpoint procedure will not detect
2839 ++ * this failure and may lead to filesystem inconsistency
2840 ++ * after cleanup journal tail.
2841 ++ */
2842 ++ if (buffer_write_io_error(bh)) {
2843 ++ pr_err("JBD2: Error while async write back metadata bh %llu.",
2844 ++ (unsigned long long)bh->b_blocknr);
2845 ++ has_write_io_error = true;
2846 ++ }
2847 + } while ((bh = bh->b_this_page) != head);
2848 +
2849 + ret = try_to_free_buffers(page);
2850 +
2851 + busy:
2852 ++ if (has_write_io_error)
2853 ++ jbd2_journal_abort(journal, -EIO);
2854 ++
2855 + return ret;
2856 + }
2857 +
2858 +@@ -2461,6 +2480,13 @@ void __jbd2_journal_refile_buffer(struct journal_head *jh)
2859 +
2860 + was_dirty = test_clear_buffer_jbddirty(bh);
2861 + __jbd2_journal_temp_unlink_buffer(jh);
2862 ++
2863 ++ /*
2864 ++ * b_transaction must be set, otherwise the new b_transaction won't
2865 ++ * be holding jh reference
2866 ++ */
2867 ++ J_ASSERT_JH(jh, jh->b_transaction != NULL);
2868 ++
2869 + /*
2870 + * We set b_transaction here because b_next_transaction will inherit
2871 + * our jh reference and thus __jbd2_journal_file_buffer() must not
2872 +diff --git a/include/linux/efi.h b/include/linux/efi.h
2873 +index 2dab158b74c45..598ee6ba5b18f 100644
2874 +--- a/include/linux/efi.h
2875 ++++ b/include/linux/efi.h
2876 +@@ -948,7 +948,11 @@ extern void *efi_get_pal_addr (void);
2877 + extern void efi_map_pal_code (void);
2878 + extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
2879 + extern void efi_gettimeofday (struct timespec64 *ts);
2880 ++#ifdef CONFIG_EFI
2881 + extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */
2882 ++#else
2883 ++static inline void efi_enter_virtual_mode (void) {}
2884 ++#endif
2885 + #ifdef CONFIG_X86
2886 + extern void efi_late_init(void);
2887 + extern void efi_free_boot_services(void);
2888 +diff --git a/include/linux/fs.h b/include/linux/fs.h
2889 +index 92b9cf88a95e6..30172ad84b25f 100644
2890 +--- a/include/linux/fs.h
2891 ++++ b/include/linux/fs.h
2892 +@@ -1989,6 +1989,10 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
2893 + * I_OVL_INUSE Used by overlayfs to get exclusive ownership on upper
2894 + * and work dirs among overlayfs mounts.
2895 + *
2896 ++ * I_SYNC_QUEUED Inode is queued in b_io or b_more_io writeback lists.
2897 ++ * Used to detect that mark_inode_dirty() should not move
2898 ++ * inode between dirty lists.
2899 ++ *
2900 + * Q: What is the difference between I_WILL_FREE and I_FREEING?
2901 + */
2902 + #define I_DIRTY_SYNC (1 << 0)
2903 +@@ -2006,10 +2010,10 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
2904 + #define I_DIO_WAKEUP (1 << __I_DIO_WAKEUP)
2905 + #define I_LINKABLE (1 << 10)
2906 + #define I_DIRTY_TIME (1 << 11)
2907 +-#define __I_DIRTY_TIME_EXPIRED 12
2908 +-#define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED)
2909 ++#define I_DIRTY_TIME_EXPIRED (1 << 12)
2910 + #define I_WB_SWITCH (1 << 13)
2911 + #define I_OVL_INUSE (1 << 14)
2912 ++#define I_SYNC_QUEUED (1 << 17)
2913 +
2914 + #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
2915 + #define I_DIRTY_ALL (I_DIRTY | I_DIRTY_TIME)
2916 +diff --git a/include/linux/overflow.h b/include/linux/overflow.h
2917 +index d309788f4cd24..40b48e2133cb8 100644
2918 +--- a/include/linux/overflow.h
2919 ++++ b/include/linux/overflow.h
2920 +@@ -233,4 +233,77 @@
2921 + (*_d >> _to_shift) != _a); \
2922 + })
2923 +
2924 ++/**
2925 ++ * array_size() - Calculate size of 2-dimensional array.
2926 ++ *
2927 ++ * @a: dimension one
2928 ++ * @b: dimension two
2929 ++ *
2930 ++ * Calculates size of 2-dimensional array: @a * @b.
2931 ++ *
2932 ++ * Returns: number of bytes needed to represent the array or SIZE_MAX on
2933 ++ * overflow.
2934 ++ */
2935 ++static inline __must_check size_t array_size(size_t a, size_t b)
2936 ++{
2937 ++ size_t bytes;
2938 ++
2939 ++ if (check_mul_overflow(a, b, &bytes))
2940 ++ return SIZE_MAX;
2941 ++
2942 ++ return bytes;
2943 ++}
2944 ++
2945 ++/**
2946 ++ * array3_size() - Calculate size of 3-dimensional array.
2947 ++ *
2948 ++ * @a: dimension one
2949 ++ * @b: dimension two
2950 ++ * @c: dimension three
2951 ++ *
2952 ++ * Calculates size of 3-dimensional array: @a * @b * @c.
2953 ++ *
2954 ++ * Returns: number of bytes needed to represent the array or SIZE_MAX on
2955 ++ * overflow.
2956 ++ */
2957 ++static inline __must_check size_t array3_size(size_t a, size_t b, size_t c)
2958 ++{
2959 ++ size_t bytes;
2960 ++
2961 ++ if (check_mul_overflow(a, b, &bytes))
2962 ++ return SIZE_MAX;
2963 ++ if (check_mul_overflow(bytes, c, &bytes))
2964 ++ return SIZE_MAX;
2965 ++
2966 ++ return bytes;
2967 ++}
2968 ++
2969 ++static inline __must_check size_t __ab_c_size(size_t n, size_t size, size_t c)
2970 ++{
2971 ++ size_t bytes;
2972 ++
2973 ++ if (check_mul_overflow(n, size, &bytes))
2974 ++ return SIZE_MAX;
2975 ++ if (check_add_overflow(bytes, c, &bytes))
2976 ++ return SIZE_MAX;
2977 ++
2978 ++ return bytes;
2979 ++}
2980 ++
2981 ++/**
2982 ++ * struct_size() - Calculate size of structure with trailing array.
2983 ++ * @p: Pointer to the structure.
2984 ++ * @member: Name of the array member.
2985 ++ * @n: Number of elements in the array.
2986 ++ *
2987 ++ * Calculates size of memory needed for structure @p followed by an
2988 ++ * array of @n @member elements.
2989 ++ *
2990 ++ * Return: number of bytes needed or SIZE_MAX on overflow.
2991 ++ */
2992 ++#define struct_size(p, member, n) \
2993 ++ __ab_c_size(n, \
2994 ++ sizeof(*(p)->member) + __must_be_array((p)->member),\
2995 ++ sizeof(*(p)))
2996 ++
2997 + #endif /* __LINUX_OVERFLOW_H */
2998 +diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
2999 +index 2e1fa7910306d..3a76ca2eecd06 100644
3000 +--- a/include/trace/events/writeback.h
3001 ++++ b/include/trace/events/writeback.h
3002 +@@ -361,8 +361,9 @@ DEFINE_WBC_EVENT(wbc_writepage);
3003 + TRACE_EVENT(writeback_queue_io,
3004 + TP_PROTO(struct bdi_writeback *wb,
3005 + struct wb_writeback_work *work,
3006 ++ unsigned long dirtied_before,
3007 + int moved),
3008 +- TP_ARGS(wb, work, moved),
3009 ++ TP_ARGS(wb, work, dirtied_before, moved),
3010 + TP_STRUCT__entry(
3011 + __array(char, name, 32)
3012 + __field(unsigned long, older)
3013 +@@ -372,19 +373,17 @@ TRACE_EVENT(writeback_queue_io,
3014 + __field(unsigned int, cgroup_ino)
3015 + ),
3016 + TP_fast_assign(
3017 +- unsigned long *older_than_this = work->older_than_this;
3018 + strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
3019 +- __entry->older = older_than_this ? *older_than_this : 0;
3020 +- __entry->age = older_than_this ?
3021 +- (jiffies - *older_than_this) * 1000 / HZ : -1;
3022 ++ __entry->older = dirtied_before;
3023 ++ __entry->age = (jiffies - dirtied_before) * 1000 / HZ;
3024 + __entry->moved = moved;
3025 + __entry->reason = work->reason;
3026 + __entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
3027 + ),
3028 + TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup_ino=%u",
3029 + __entry->name,
3030 +- __entry->older, /* older_than_this in jiffies */
3031 +- __entry->age, /* older_than_this in relative milliseconds */
3032 ++ __entry->older, /* dirtied_before in jiffies */
3033 ++ __entry->age, /* dirtied_before in relative milliseconds */
3034 + __entry->moved,
3035 + __print_symbolic(__entry->reason, WB_WORK_REASON),
3036 + __entry->cgroup_ino
3037 +diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
3038 +index 8b2ef15e35524..06c02cd0ff577 100644
3039 +--- a/kernel/locking/lockdep_proc.c
3040 ++++ b/kernel/locking/lockdep_proc.c
3041 +@@ -430,7 +430,7 @@ static void seq_lock_time(struct seq_file *m, struct lock_time *lt)
3042 + seq_time(m, lt->min);
3043 + seq_time(m, lt->max);
3044 + seq_time(m, lt->total);
3045 +- seq_time(m, lt->nr ? div_s64(lt->total, lt->nr) : 0);
3046 ++ seq_time(m, lt->nr ? div64_u64(lt->total, lt->nr) : 0);
3047 + }
3048 +
3049 + static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
3050 +diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
3051 +index 9a55c5bc52434..987daf9cc6e54 100644
3052 +--- a/kernel/trace/blktrace.c
3053 ++++ b/kernel/trace/blktrace.c
3054 +@@ -541,6 +541,18 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
3055 + if (!dir)
3056 + goto err;
3057 +
3058 ++ /*
3059 ++ * As blktrace relies on debugfs for its interface the debugfs directory
3060 ++ * is required, contrary to the usual mantra of not checking for debugfs
3061 ++ * files or directories.
3062 ++ */
3063 ++ if (IS_ERR_OR_NULL(dir)) {
3064 ++ pr_warn("debugfs_dir not present for %s so skipping\n",
3065 ++ buts->name);
3066 ++ ret = -ENOENT;
3067 ++ goto err;
3068 ++ }
3069 ++
3070 + bt->dev = dev;
3071 + atomic_set(&bt->dropped, 0);
3072 + INIT_LIST_HEAD(&bt->running_list);
3073 +diff --git a/net/core/skbuff.c b/net/core/skbuff.c
3074 +index b1933e1f3aef9..4c0f637bbf8b8 100644
3075 +--- a/net/core/skbuff.c
3076 ++++ b/net/core/skbuff.c
3077 +@@ -5053,8 +5053,8 @@ struct sk_buff *skb_vlan_untag(struct sk_buff *skb)
3078 + skb = skb_share_check(skb, GFP_ATOMIC);
3079 + if (unlikely(!skb))
3080 + goto err_free;
3081 +-
3082 +- if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
3083 ++ /* We may access the two bytes after vlan_hdr in vlan_set_encap_proto(). */
3084 ++ if (unlikely(!pskb_may_pull(skb, VLAN_HLEN + sizeof(unsigned short))))
3085 + goto err_free;
3086 +
3087 + vhdr = (struct vlan_hdr *)skb->data;
3088 +diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
3089 +index c2644405bab19..2ffb4b8eca04c 100644
3090 +--- a/net/ipv6/ip6_tunnel.c
3091 ++++ b/net/ipv6/ip6_tunnel.c
3092 +@@ -872,7 +872,15 @@ int ip6_tnl_rcv(struct ip6_tnl *t, struct sk_buff *skb,
3093 + struct metadata_dst *tun_dst,
3094 + bool log_ecn_err)
3095 + {
3096 +- return __ip6_tnl_rcv(t, skb, tpi, NULL, ip6ip6_dscp_ecn_decapsulate,
3097 ++ int (*dscp_ecn_decapsulate)(const struct ip6_tnl *t,
3098 ++ const struct ipv6hdr *ipv6h,
3099 ++ struct sk_buff *skb);
3100 ++
3101 ++ dscp_ecn_decapsulate = ip6ip6_dscp_ecn_decapsulate;
3102 ++ if (tpi->proto == htons(ETH_P_IP))
3103 ++ dscp_ecn_decapsulate = ip4ip6_dscp_ecn_decapsulate;
3104 ++
3105 ++ return __ip6_tnl_rcv(t, skb, tpi, NULL, dscp_ecn_decapsulate,
3106 + log_ecn_err);
3107 + }
3108 + EXPORT_SYMBOL(ip6_tnl_rcv);
3109 +diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
3110 +index fa0522cd683ee..99c69489bb442 100644
3111 +--- a/net/tipc/netlink_compat.c
3112 ++++ b/net/tipc/netlink_compat.c
3113 +@@ -250,8 +250,9 @@ err_out:
3114 + static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
3115 + struct tipc_nl_compat_msg *msg)
3116 + {
3117 +- int err;
3118 ++ struct nlmsghdr *nlh;
3119 + struct sk_buff *arg;
3120 ++ int err;
3121 +
3122 + if (msg->req_type && (!msg->req_size ||
3123 + !TLV_CHECK_TYPE(msg->req, msg->req_type)))
3124 +@@ -280,6 +281,15 @@ static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
3125 + return -ENOMEM;
3126 + }
3127 +
3128 ++ nlh = nlmsg_put(arg, 0, 0, tipc_genl_family.id, 0, NLM_F_MULTI);
3129 ++ if (!nlh) {
3130 ++ kfree_skb(arg);
3131 ++ kfree_skb(msg->rep);
3132 ++ msg->rep = NULL;
3133 ++ return -EMSGSIZE;
3134 ++ }
3135 ++ nlmsg_end(arg, nlh);
3136 ++
3137 + err = __tipc_nl_compat_dumpit(cmd, msg, arg);
3138 + if (err) {
3139 + kfree_skb(msg->rep);
3140 +diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
3141 +index 0020fd0efc466..09c547f4cc186 100644
3142 +--- a/sound/pci/cs46xx/cs46xx_lib.c
3143 ++++ b/sound/pci/cs46xx/cs46xx_lib.c
3144 +@@ -780,7 +780,7 @@ static void snd_cs46xx_set_capture_sample_rate(struct snd_cs46xx *chip, unsigned
3145 + rate = 48000 / 9;
3146 +
3147 + /*
3148 +- * We can not capture at at rate greater than the Input Rate (48000).
3149 ++ * We can not capture at a rate greater than the Input Rate (48000).
3150 + * Return an error if an attempt is made to stray outside that limit.
3151 + */
3152 + if (rate > 48000)
3153 +diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
3154 +index 7488e1b7a7707..4e726d39b05d1 100644
3155 +--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
3156 ++++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
3157 +@@ -1742,7 +1742,7 @@ int cs46xx_iec958_pre_open (struct snd_cs46xx *chip)
3158 + struct dsp_spos_instance * ins = chip->dsp_spos_instance;
3159 +
3160 + if ( ins->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED ) {
3161 +- /* remove AsynchFGTxSCB and and PCMSerialInput_II */
3162 ++ /* remove AsynchFGTxSCB and PCMSerialInput_II */
3163 + cs46xx_dsp_disable_spdif_out (chip);
3164 +
3165 + /* save state */
3166 +diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
3167 +index 7d65fe31c8257..a56f018d586f5 100644
3168 +--- a/sound/pci/hda/hda_codec.c
3169 ++++ b/sound/pci/hda/hda_codec.c
3170 +@@ -3394,7 +3394,7 @@ EXPORT_SYMBOL_GPL(snd_hda_set_power_save);
3171 + * @nid: NID to check / update
3172 + *
3173 + * Check whether the given NID is in the amp list. If it's in the list,
3174 +- * check the current AMP status, and update the the power-status according
3175 ++ * check the current AMP status, and update the power-status according
3176 + * to the mute status.
3177 + *
3178 + * This function is supposed to be set or called from the check_power_status
3179 +diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
3180 +index 28ef409a9e6ae..9dee657ce9e27 100644
3181 +--- a/sound/pci/hda/hda_generic.c
3182 ++++ b/sound/pci/hda/hda_generic.c
3183 +@@ -823,7 +823,7 @@ static void activate_amp_in(struct hda_codec *codec, struct nid_path *path,
3184 + }
3185 + }
3186 +
3187 +-/* sync power of each widget in the the given path */
3188 ++/* sync power of each widget in the given path */
3189 + static hda_nid_t path_power_update(struct hda_codec *codec,
3190 + struct nid_path *path,
3191 + bool allow_powerdown)
3192 +diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
3193 +index 7cd147411b22d..f7896a9ae3d65 100644
3194 +--- a/sound/pci/hda/patch_sigmatel.c
3195 ++++ b/sound/pci/hda/patch_sigmatel.c
3196 +@@ -863,7 +863,7 @@ static int stac_auto_create_beep_ctls(struct hda_codec *codec,
3197 + static struct snd_kcontrol_new beep_vol_ctl =
3198 + HDA_CODEC_VOLUME(NULL, 0, 0, 0);
3199 +
3200 +- /* check for mute support for the the amp */
3201 ++ /* check for mute support for the amp */
3202 + if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3203 + const struct snd_kcontrol_new *temp;
3204 + if (spec->anabeep_nid == nid)
3205 +diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
3206 +index 3919aed39ca03..5e52086d7b986 100644
3207 +--- a/sound/pci/ice1712/prodigy192.c
3208 ++++ b/sound/pci/ice1712/prodigy192.c
3209 +@@ -31,7 +31,7 @@
3210 + * Experimentally I found out that only a combination of
3211 + * OCKS0=1, OCKS1=1 (128fs, 64fs output) and ice1724 -
3212 + * VT1724_MT_I2S_MCLK_128X=0 (256fs input) yields correct
3213 +- * sampling rate. That means the the FPGA doubles the
3214 ++ * sampling rate. That means that the FPGA doubles the
3215 + * MCK01 rate.
3216 + *
3217 + * Copyright (c) 2003 Takashi Iwai <tiwai@××××.de>
3218 +diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c
3219 +index 4cf3200e988b0..df44135e1b0c9 100644
3220 +--- a/sound/pci/oxygen/xonar_dg.c
3221 ++++ b/sound/pci/oxygen/xonar_dg.c
3222 +@@ -39,7 +39,7 @@
3223 + * GPIO 4 <- headphone detect
3224 + * GPIO 5 -> enable ADC analog circuit for the left channel
3225 + * GPIO 6 -> enable ADC analog circuit for the right channel
3226 +- * GPIO 7 -> switch green rear output jack between CS4245 and and the first
3227 ++ * GPIO 7 -> switch green rear output jack between CS4245 and the first
3228 + * channel of CS4361 (mechanical relay)
3229 + * GPIO 8 -> enable output to speakers
3230 + *
3231 +diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c
3232 +index 43679aeeb12be..88e838ac937dc 100644
3233 +--- a/sound/soc/tegra/tegra30_ahub.c
3234 ++++ b/sound/soc/tegra/tegra30_ahub.c
3235 +@@ -655,8 +655,10 @@ static int tegra30_ahub_resume(struct device *dev)
3236 + int ret;
3237 +
3238 + ret = pm_runtime_get_sync(dev);
3239 +- if (ret < 0)
3240 ++ if (ret < 0) {
3241 ++ pm_runtime_put(dev);
3242 + return ret;
3243 ++ }
3244 + ret = regcache_sync(ahub->regmap_ahub);
3245 + ret |= regcache_sync(ahub->regmap_apbif);
3246 + pm_runtime_put(dev);
3247 +diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c
3248 +index 0b176ea24914b..bf155c5092f06 100644
3249 +--- a/sound/soc/tegra/tegra30_i2s.c
3250 ++++ b/sound/soc/tegra/tegra30_i2s.c
3251 +@@ -551,8 +551,10 @@ static int tegra30_i2s_resume(struct device *dev)
3252 + int ret;
3253 +
3254 + ret = pm_runtime_get_sync(dev);
3255 +- if (ret < 0)
3256 ++ if (ret < 0) {
3257 ++ pm_runtime_put(dev);
3258 + return ret;
3259 ++ }
3260 + ret = regcache_sync(i2s->regmap);
3261 + pm_runtime_put(dev);
3262 +
3263 +diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
3264 +index 689fd3103e5b6..a917b7e02d312 100644
3265 +--- a/sound/usb/quirks-table.h
3266 ++++ b/sound/usb/quirks-table.h
3267 +@@ -3331,8 +3331,8 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
3268 + * they pretend to be 96kHz mono as a workaround for stereo being broken
3269 + * by that...
3270 + *
3271 +- * They also have swapped L-R channels, but that's for userspace to deal
3272 +- * with.
3273 ++ * They also have an issue with initial stream alignment that causes the
3274 ++ * channels to be swapped and out of phase, which is dealt with in quirks.c.
3275 + */
3276 + {
3277 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
3278 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
3279 +index 94110b1dcd3d8..031baa43646fb 100644
3280 +--- a/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
3281 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
3282 +@@ -91,8 +91,6 @@ int back_to_back_ebbs(void)
3283 + ebb_global_disable();
3284 + ebb_freeze_pmcs();
3285 +
3286 +- count_pmc(1, sample_period);
3287 +-
3288 + dump_ebb_state();
3289 +
3290 + event_close(&event);
3291 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
3292 +index 7c57a8d79535d..361e0be9df9ae 100644
3293 +--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
3294 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
3295 +@@ -42,8 +42,6 @@ int cycles(void)
3296 + ebb_global_disable();
3297 + ebb_freeze_pmcs();
3298 +
3299 +- count_pmc(1, sample_period);
3300 +-
3301 + dump_ebb_state();
3302 +
3303 + event_close(&event);
3304 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
3305 +index ecf5ee3283a3e..fe7d0dc2a1a26 100644
3306 +--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
3307 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
3308 +@@ -99,8 +99,6 @@ int cycles_with_freeze(void)
3309 + ebb_global_disable();
3310 + ebb_freeze_pmcs();
3311 +
3312 +- count_pmc(1, sample_period);
3313 +-
3314 + dump_ebb_state();
3315 +
3316 + printf("EBBs while frozen %d\n", ebbs_while_frozen);
3317 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
3318 +index c0faba520b35c..b9b30f974b5ea 100644
3319 +--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
3320 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
3321 +@@ -71,8 +71,6 @@ int cycles_with_mmcr2(void)
3322 + ebb_global_disable();
3323 + ebb_freeze_pmcs();
3324 +
3325 +- count_pmc(1, sample_period);
3326 +-
3327 + dump_ebb_state();
3328 +
3329 + event_close(&event);
3330 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
3331 +index 46681fec549b8..2694ae161a84a 100644
3332 +--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
3333 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
3334 +@@ -396,8 +396,6 @@ int ebb_child(union pipe read_pipe, union pipe write_pipe)
3335 + ebb_global_disable();
3336 + ebb_freeze_pmcs();
3337 +
3338 +- count_pmc(1, sample_period);
3339 +-
3340 + dump_ebb_state();
3341 +
3342 + event_close(&event);
3343 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c b/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
3344 +index a991d2ea8d0a1..174e4f4dae6c0 100644
3345 +--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
3346 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
3347 +@@ -38,8 +38,6 @@ static int victim_child(union pipe read_pipe, union pipe write_pipe)
3348 + ebb_global_disable();
3349 + ebb_freeze_pmcs();
3350 +
3351 +- count_pmc(1, sample_period);
3352 +-
3353 + dump_ebb_state();
3354 +
3355 + FAIL_IF(ebb_state.stats.ebb_count == 0);
3356 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c b/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
3357 +index eb8acb78bc6c1..531083accfcad 100644
3358 +--- a/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
3359 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
3360 +@@ -75,7 +75,6 @@ static int test_body(void)
3361 + ebb_freeze_pmcs();
3362 + ebb_global_disable();
3363 +
3364 +- count_pmc(4, sample_period);
3365 + mtspr(SPRN_PMC4, 0xdead);
3366 +
3367 + dump_summary_ebb_state();
3368 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c b/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
3369 +index 6ff8c8ff27d66..035c02273cd49 100644
3370 +--- a/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
3371 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
3372 +@@ -70,13 +70,6 @@ int multi_counter(void)
3373 + ebb_global_disable();
3374 + ebb_freeze_pmcs();
3375 +
3376 +- count_pmc(1, sample_period);
3377 +- count_pmc(2, sample_period);
3378 +- count_pmc(3, sample_period);
3379 +- count_pmc(4, sample_period);
3380 +- count_pmc(5, sample_period);
3381 +- count_pmc(6, sample_period);
3382 +-
3383 + dump_ebb_state();
3384 +
3385 + for (i = 0; i < 6; i++)
3386 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c b/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
3387 +index 037cb6154f360..3e9d4ac965c85 100644
3388 +--- a/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
3389 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
3390 +@@ -61,8 +61,6 @@ static int cycles_child(void)
3391 + ebb_global_disable();
3392 + ebb_freeze_pmcs();
3393 +
3394 +- count_pmc(1, sample_period);
3395 +-
3396 + dump_summary_ebb_state();
3397 +
3398 + event_close(&event);
3399 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c b/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
3400 +index c5fa64790c22e..d90891fe96a32 100644
3401 +--- a/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
3402 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
3403 +@@ -82,8 +82,6 @@ static int test_body(void)
3404 + ebb_global_disable();
3405 + ebb_freeze_pmcs();
3406 +
3407 +- count_pmc(1, sample_period);
3408 +-
3409 + dump_ebb_state();
3410 +
3411 + if (mmcr0_mismatch)
3412 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
3413 +index 30e1ac62e8cb4..8ca92b9ee5b01 100644
3414 +--- a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
3415 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
3416 +@@ -76,8 +76,6 @@ int pmc56_overflow(void)
3417 + ebb_global_disable();
3418 + ebb_freeze_pmcs();
3419 +
3420 +- count_pmc(2, sample_period);
3421 +-
3422 + dump_ebb_state();
3423 +
3424 + printf("PMC5/6 overflow %d\n", pmc56_overflowed);