Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.10 commit in: /
Date: Thu, 30 Mar 2017 18:18:01
Message-Id: 1490897867.81106172f4f12a8d54193305855bddefcb09ae71.mpagano@gentoo
1 commit: 81106172f4f12a8d54193305855bddefcb09ae71
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Thu Mar 30 18:17:47 2017 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Thu Mar 30 18:17:47 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=81106172
7
8 Linux patch 4.10.7
9
10 0000_README | 4 +
11 1006_linux-4.10.7.patch | 5177 +++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 5181 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index 014e9c4..02aad35 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -67,6 +67,10 @@ Patch: 1005_linux-4.10.6.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.10.6
21
22 +Patch: 1006_linux-4.10.7.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.10.7
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1006_linux-4.10.7.patch b/1006_linux-4.10.7.patch
31 new file mode 100644
32 index 0000000..beafe8f
33 --- /dev/null
34 +++ b/1006_linux-4.10.7.patch
35 @@ -0,0 +1,5177 @@
36 +diff --git a/Makefile b/Makefile
37 +index 23b6d29cb6da..976e8d1a468a 100644
38 +--- a/Makefile
39 ++++ b/Makefile
40 +@@ -1,6 +1,6 @@
41 + VERSION = 4
42 + PATCHLEVEL = 10
43 +-SUBLEVEL = 6
44 ++SUBLEVEL = 7
45 + EXTRAVERSION =
46 + NAME = Fearless Coyote
47 +
48 +diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
49 +index ceb9783ff7e1..ff7eae833a6d 100644
50 +--- a/arch/arm/boot/dts/sama5d2.dtsi
51 ++++ b/arch/arm/boot/dts/sama5d2.dtsi
52 +@@ -266,7 +266,7 @@
53 + };
54 +
55 + usb1: ohci@00400000 {
56 +- compatible = "atmel,sama5d2-ohci", "usb-ohci";
57 ++ compatible = "atmel,at91rm9200-ohci", "usb-ohci";
58 + reg = <0x00400000 0x100000>;
59 + interrupts = <41 IRQ_TYPE_LEVEL_HIGH 2>;
60 + clocks = <&uhphs_clk>, <&uhphs_clk>, <&uhpck>;
61 +diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
62 +index b4332b727e9c..31dde8b6f2ea 100644
63 +--- a/arch/arm/mach-at91/pm.c
64 ++++ b/arch/arm/mach-at91/pm.c
65 +@@ -289,6 +289,22 @@ static void at91_ddr_standby(void)
66 + at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);
67 + }
68 +
69 ++static void sama5d3_ddr_standby(void)
70 ++{
71 ++ u32 lpr0;
72 ++ u32 saved_lpr0;
73 ++
74 ++ saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
75 ++ lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
76 ++ lpr0 |= AT91_DDRSDRC_LPCB_POWER_DOWN;
77 ++
78 ++ at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
79 ++
80 ++ cpu_do_idle();
81 ++
82 ++ at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0);
83 ++}
84 ++
85 + /* We manage both DDRAM/SDRAM controllers, we need more than one value to
86 + * remember.
87 + */
88 +@@ -323,7 +339,7 @@ static const struct of_device_id const ramc_ids[] __initconst = {
89 + { .compatible = "atmel,at91rm9200-sdramc", .data = at91rm9200_standby },
90 + { .compatible = "atmel,at91sam9260-sdramc", .data = at91sam9_sdram_standby },
91 + { .compatible = "atmel,at91sam9g45-ddramc", .data = at91_ddr_standby },
92 +- { .compatible = "atmel,sama5d3-ddramc", .data = at91_ddr_standby },
93 ++ { .compatible = "atmel,sama5d3-ddramc", .data = sama5d3_ddr_standby },
94 + { /*sentinel*/ }
95 + };
96 +
97 +diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c
98 +index 769f24ef628c..d7e90d97f5c4 100644
99 +--- a/arch/arm64/kernel/kaslr.c
100 ++++ b/arch/arm64/kernel/kaslr.c
101 +@@ -131,11 +131,15 @@ u64 __init kaslr_early_init(u64 dt_phys, u64 modulo_offset)
102 + /*
103 + * The kernel Image should not extend across a 1GB/32MB/512MB alignment
104 + * boundary (for 4KB/16KB/64KB granule kernels, respectively). If this
105 +- * happens, increase the KASLR offset by the size of the kernel image.
106 ++ * happens, increase the KASLR offset by the size of the kernel image
107 ++ * rounded up by SWAPPER_BLOCK_SIZE.
108 + */
109 + if ((((u64)_text + offset + modulo_offset) >> SWAPPER_TABLE_SHIFT) !=
110 +- (((u64)_end + offset + modulo_offset) >> SWAPPER_TABLE_SHIFT))
111 +- offset = (offset + (u64)(_end - _text)) & mask;
112 ++ (((u64)_end + offset + modulo_offset) >> SWAPPER_TABLE_SHIFT)) {
113 ++ u64 kimg_sz = _end - _text;
114 ++ offset = (offset + round_up(kimg_sz, SWAPPER_BLOCK_SIZE))
115 ++ & mask;
116 ++ }
117 +
118 + if (IS_ENABLED(CONFIG_KASAN))
119 + /*
120 +diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
121 +index 72dac0b58061..b350ac5e3111 100644
122 +--- a/arch/powerpc/kernel/idle_book3s.S
123 ++++ b/arch/powerpc/kernel/idle_book3s.S
124 +@@ -439,9 +439,23 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
125 + _GLOBAL(pnv_wakeup_tb_loss)
126 + ld r1,PACAR1(r13)
127 + /*
128 +- * Before entering any idle state, the NVGPRs are saved in the stack
129 +- * and they are restored before switching to the process context. Hence
130 +- * until they are restored, they are free to be used.
131 ++ * Before entering any idle state, the NVGPRs are saved in the stack.
132 ++ * If there was a state loss, or PACA_NAPSTATELOST was set, then the
133 ++ * NVGPRs are restored. If we are here, it is likely that state is lost,
134 ++ * but not guaranteed -- neither ISA207 nor ISA300 tests to reach
135 ++ * here are the same as the test to restore NVGPRS:
136 ++ * PACA_THREAD_IDLE_STATE test for ISA207, PSSCR test for ISA300,
137 ++ * and SRR1 test for restoring NVGPRs.
138 ++ *
139 ++ * We are about to clobber NVGPRs now, so set NAPSTATELOST to
140 ++ * guarantee they will always be restored. This might be tightened
141 ++ * with careful reading of specs (particularly for ISA300) but this
142 ++ * is already a slow wakeup path and it's simpler to be safe.
143 ++ */
144 ++ li r0,1
145 ++ stb r0,PACA_NAPSTATELOST(r13)
146 ++
147 ++ /*
148 + *
149 + * Save SRR1 and LR in NVGPRs as they might be clobbered in
150 + * opal_call() (called in CHECK_HMI_INTERRUPT). SRR1 is required
151 +diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
152 +index e1fb269c87af..292ab0364a89 100644
153 +--- a/arch/x86/pci/xen.c
154 ++++ b/arch/x86/pci/xen.c
155 +@@ -234,23 +234,14 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
156 + return 1;
157 +
158 + for_each_pci_msi_entry(msidesc, dev) {
159 +- __pci_read_msi_msg(msidesc, &msg);
160 +- pirq = MSI_ADDR_EXT_DEST_ID(msg.address_hi) |
161 +- ((msg.address_lo >> MSI_ADDR_DEST_ID_SHIFT) & 0xff);
162 +- if (msg.data != XEN_PIRQ_MSI_DATA ||
163 +- xen_irq_from_pirq(pirq) < 0) {
164 +- pirq = xen_allocate_pirq_msi(dev, msidesc);
165 +- if (pirq < 0) {
166 +- irq = -ENODEV;
167 +- goto error;
168 +- }
169 +- xen_msi_compose_msg(dev, pirq, &msg);
170 +- __pci_write_msi_msg(msidesc, &msg);
171 +- dev_dbg(&dev->dev, "xen: msi bound to pirq=%d\n", pirq);
172 +- } else {
173 +- dev_dbg(&dev->dev,
174 +- "xen: msi already bound to pirq=%d\n", pirq);
175 ++ pirq = xen_allocate_pirq_msi(dev, msidesc);
176 ++ if (pirq < 0) {
177 ++ irq = -ENODEV;
178 ++ goto error;
179 + }
180 ++ xen_msi_compose_msg(dev, pirq, &msg);
181 ++ __pci_write_msi_msg(msidesc, &msg);
182 ++ dev_dbg(&dev->dev, "xen: msi bound to pirq=%d\n", pirq);
183 + irq = xen_bind_pirq_msi_to_irq(dev, msidesc, pirq,
184 + (type == PCI_CAP_ID_MSI) ? nvec : 1,
185 + (type == PCI_CAP_ID_MSIX) ?
186 +diff --git a/block/blk-mq.c b/block/blk-mq.c
187 +index c3400b5444a7..3b57e75098c3 100644
188 +--- a/block/blk-mq.c
189 ++++ b/block/blk-mq.c
190 +@@ -678,17 +678,8 @@ static void blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,
191 + {
192 + struct blk_mq_timeout_data *data = priv;
193 +
194 +- if (!test_bit(REQ_ATOM_STARTED, &rq->atomic_flags)) {
195 +- /*
196 +- * If a request wasn't started before the queue was
197 +- * marked dying, kill it here or it'll go unnoticed.
198 +- */
199 +- if (unlikely(blk_queue_dying(rq->q))) {
200 +- rq->errors = -EIO;
201 +- blk_mq_end_request(rq, rq->errors);
202 +- }
203 ++ if (!test_bit(REQ_ATOM_STARTED, &rq->atomic_flags))
204 + return;
205 +- }
206 +
207 + if (time_after_eq(jiffies, rq->deadline)) {
208 + if (!blk_mark_rq_complete(rq))
209 +diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
210 +index d19b09cdf284..54fc90e8339c 100644
211 +--- a/crypto/algif_hash.c
212 ++++ b/crypto/algif_hash.c
213 +@@ -245,7 +245,7 @@ static int hash_accept(struct socket *sock, struct socket *newsock, int flags)
214 + struct alg_sock *ask = alg_sk(sk);
215 + struct hash_ctx *ctx = ask->private;
216 + struct ahash_request *req = &ctx->req;
217 +- char state[crypto_ahash_statesize(crypto_ahash_reqtfm(req))];
218 ++ char state[crypto_ahash_statesize(crypto_ahash_reqtfm(req)) ? : 1];
219 + struct sock *sk2;
220 + struct alg_sock *ask2;
221 + struct hash_ctx *ctx2;
222 +diff --git a/drivers/auxdisplay/img-ascii-lcd.c b/drivers/auxdisplay/img-ascii-lcd.c
223 +index bf43b5d2aafc..83f1439e57fd 100644
224 +--- a/drivers/auxdisplay/img-ascii-lcd.c
225 ++++ b/drivers/auxdisplay/img-ascii-lcd.c
226 +@@ -218,6 +218,7 @@ static const struct of_device_id img_ascii_lcd_matches[] = {
227 + { .compatible = "img,boston-lcd", .data = &boston_config },
228 + { .compatible = "mti,malta-lcd", .data = &malta_config },
229 + { .compatible = "mti,sead3-lcd", .data = &sead3_config },
230 ++ { /* sentinel */ }
231 + };
232 +
233 + /**
234 +diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c
235 +index 4a99ac756f08..9959c762da2f 100644
236 +--- a/drivers/char/hw_random/amd-rng.c
237 ++++ b/drivers/char/hw_random/amd-rng.c
238 +@@ -55,6 +55,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
239 + struct amd768_priv {
240 + void __iomem *iobase;
241 + struct pci_dev *pcidev;
242 ++ u32 pmbase;
243 + };
244 +
245 + static int amd_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
246 +@@ -148,33 +149,58 @@ static int __init mod_init(void)
247 + if (pmbase == 0)
248 + return -EIO;
249 +
250 +- priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
251 ++ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
252 + if (!priv)
253 + return -ENOMEM;
254 +
255 +- if (!devm_request_region(&pdev->dev, pmbase + PMBASE_OFFSET,
256 +- PMBASE_SIZE, DRV_NAME)) {
257 ++ if (!request_region(pmbase + PMBASE_OFFSET, PMBASE_SIZE, DRV_NAME)) {
258 + dev_err(&pdev->dev, DRV_NAME " region 0x%x already in use!\n",
259 + pmbase + 0xF0);
260 +- return -EBUSY;
261 ++ err = -EBUSY;
262 ++ goto out;
263 + }
264 +
265 +- priv->iobase = devm_ioport_map(&pdev->dev, pmbase + PMBASE_OFFSET,
266 +- PMBASE_SIZE);
267 ++ priv->iobase = ioport_map(pmbase + PMBASE_OFFSET, PMBASE_SIZE);
268 + if (!priv->iobase) {
269 + pr_err(DRV_NAME "Cannot map ioport\n");
270 +- return -ENOMEM;
271 ++ err = -EINVAL;
272 ++ goto err_iomap;
273 + }
274 +
275 + amd_rng.priv = (unsigned long)priv;
276 ++ priv->pmbase = pmbase;
277 + priv->pcidev = pdev;
278 +
279 + pr_info(DRV_NAME " detected\n");
280 +- return devm_hwrng_register(&pdev->dev, &amd_rng);
281 ++ err = hwrng_register(&amd_rng);
282 ++ if (err) {
283 ++ pr_err(DRV_NAME " registering failed (%d)\n", err);
284 ++ goto err_hwrng;
285 ++ }
286 ++ return 0;
287 ++
288 ++err_hwrng:
289 ++ ioport_unmap(priv->iobase);
290 ++err_iomap:
291 ++ release_region(pmbase + PMBASE_OFFSET, PMBASE_SIZE);
292 ++out:
293 ++ kfree(priv);
294 ++ return err;
295 + }
296 +
297 + static void __exit mod_exit(void)
298 + {
299 ++ struct amd768_priv *priv;
300 ++
301 ++ priv = (struct amd768_priv *)amd_rng.priv;
302 ++
303 ++ hwrng_unregister(&amd_rng);
304 ++
305 ++ ioport_unmap(priv->iobase);
306 ++
307 ++ release_region(priv->pmbase + PMBASE_OFFSET, PMBASE_SIZE);
308 ++
309 ++ kfree(priv);
310 + }
311 +
312 + module_init(mod_init);
313 +diff --git a/drivers/char/hw_random/geode-rng.c b/drivers/char/hw_random/geode-rng.c
314 +index e7a245942029..e1d421a36a13 100644
315 +--- a/drivers/char/hw_random/geode-rng.c
316 ++++ b/drivers/char/hw_random/geode-rng.c
317 +@@ -31,6 +31,9 @@
318 + #include <linux/module.h>
319 + #include <linux/pci.h>
320 +
321 ++
322 ++#define PFX KBUILD_MODNAME ": "
323 ++
324 + #define GEODE_RNG_DATA_REG 0x50
325 + #define GEODE_RNG_STATUS_REG 0x54
326 +
327 +@@ -82,6 +85,7 @@ static struct hwrng geode_rng = {
328 +
329 + static int __init mod_init(void)
330 + {
331 ++ int err = -ENODEV;
332 + struct pci_dev *pdev = NULL;
333 + const struct pci_device_id *ent;
334 + void __iomem *mem;
335 +@@ -89,27 +93,43 @@ static int __init mod_init(void)
336 +
337 + for_each_pci_dev(pdev) {
338 + ent = pci_match_id(pci_tbl, pdev);
339 +- if (ent) {
340 +- rng_base = pci_resource_start(pdev, 0);
341 +- if (rng_base == 0)
342 +- return -ENODEV;
343 +-
344 +- mem = devm_ioremap(&pdev->dev, rng_base, 0x58);
345 +- if (!mem)
346 +- return -ENOMEM;
347 +- geode_rng.priv = (unsigned long)mem;
348 +-
349 +- pr_info("AMD Geode RNG detected\n");
350 +- return devm_hwrng_register(&pdev->dev, &geode_rng);
351 +- }
352 ++ if (ent)
353 ++ goto found;
354 + }
355 +-
356 + /* Device not found. */
357 +- return -ENODEV;
358 ++ goto out;
359 ++
360 ++found:
361 ++ rng_base = pci_resource_start(pdev, 0);
362 ++ if (rng_base == 0)
363 ++ goto out;
364 ++ err = -ENOMEM;
365 ++ mem = ioremap(rng_base, 0x58);
366 ++ if (!mem)
367 ++ goto out;
368 ++ geode_rng.priv = (unsigned long)mem;
369 ++
370 ++ pr_info("AMD Geode RNG detected\n");
371 ++ err = hwrng_register(&geode_rng);
372 ++ if (err) {
373 ++ pr_err(PFX "RNG registering failed (%d)\n",
374 ++ err);
375 ++ goto err_unmap;
376 ++ }
377 ++out:
378 ++ return err;
379 ++
380 ++err_unmap:
381 ++ iounmap(mem);
382 ++ goto out;
383 + }
384 +
385 + static void __exit mod_exit(void)
386 + {
387 ++ void __iomem *mem = (void __iomem *)geode_rng.priv;
388 ++
389 ++ hwrng_unregister(&geode_rng);
390 ++ iounmap(mem);
391 + }
392 +
393 + module_init(mod_init);
394 +diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
395 +index 87885d146dbb..a372fef7654b 100644
396 +--- a/drivers/char/ppdev.c
397 ++++ b/drivers/char/ppdev.c
398 +@@ -84,11 +84,14 @@ struct pp_struct {
399 + struct ieee1284_info state;
400 + struct ieee1284_info saved_state;
401 + long default_inactivity;
402 ++ int index;
403 + };
404 +
405 + /* should we use PARDEVICE_MAX here? */
406 + static struct device *devices[PARPORT_MAX];
407 +
408 ++static DEFINE_IDA(ida_index);
409 ++
410 + /* pp_struct.flags bitfields */
411 + #define PP_CLAIMED (1<<0)
412 + #define PP_EXCL (1<<1)
413 +@@ -290,7 +293,7 @@ static int register_device(int minor, struct pp_struct *pp)
414 + struct pardevice *pdev = NULL;
415 + char *name;
416 + struct pardev_cb ppdev_cb;
417 +- int rc = 0;
418 ++ int rc = 0, index;
419 +
420 + name = kasprintf(GFP_KERNEL, CHRDEV "%x", minor);
421 + if (name == NULL)
422 +@@ -303,20 +306,23 @@ static int register_device(int minor, struct pp_struct *pp)
423 + goto err;
424 + }
425 +
426 ++ index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
427 + memset(&ppdev_cb, 0, sizeof(ppdev_cb));
428 + ppdev_cb.irq_func = pp_irq;
429 + ppdev_cb.flags = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0;
430 + ppdev_cb.private = pp;
431 +- pdev = parport_register_dev_model(port, name, &ppdev_cb, minor);
432 ++ pdev = parport_register_dev_model(port, name, &ppdev_cb, index);
433 + parport_put_port(port);
434 +
435 + if (!pdev) {
436 + pr_warn("%s: failed to register device!\n", name);
437 + rc = -ENXIO;
438 ++ ida_simple_remove(&ida_index, index);
439 + goto err;
440 + }
441 +
442 + pp->pdev = pdev;
443 ++ pp->index = index;
444 + dev_dbg(&pdev->dev, "registered pardevice\n");
445 + err:
446 + kfree(name);
447 +@@ -755,6 +761,7 @@ static int pp_release(struct inode *inode, struct file *file)
448 +
449 + if (pp->pdev) {
450 + parport_unregister_device(pp->pdev);
451 ++ ida_simple_remove(&ida_index, pp->index);
452 + pp->pdev = NULL;
453 + pr_debug(CHRDEV "%x: unregistered pardevice\n", minor);
454 + }
455 +diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
456 +index fc75a335a7ce..8ca07fe8d3f3 100644
457 +--- a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
458 ++++ b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
459 +@@ -608,7 +608,7 @@ static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", lcd_ch1_parents,
460 + 0x150, 0, 4, 24, 2, BIT(31),
461 + CLK_SET_RATE_PARENT);
462 +
463 +-static SUNXI_CCU_GATE(hdmi_ddc_clk, "hdmi-ddc", "osc24M", 0x150, BIT(31), 0);
464 ++static SUNXI_CCU_GATE(hdmi_ddc_clk, "hdmi-ddc", "osc24M", 0x150, BIT(30), 0);
465 +
466 + static SUNXI_CCU_GATE(ps_clk, "ps", "lcd1-ch1", 0x140, BIT(31), 0);
467 +
468 +diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c
469 +index ebb1b31568a5..ee7810429c30 100644
470 +--- a/drivers/clk/sunxi-ng/ccu_mp.c
471 ++++ b/drivers/clk/sunxi-ng/ccu_mp.c
472 +@@ -85,6 +85,10 @@ static unsigned long ccu_mp_recalc_rate(struct clk_hw *hw,
473 + unsigned int m, p;
474 + u32 reg;
475 +
476 ++ /* Adjust parent_rate according to pre-dividers */
477 ++ ccu_mux_helper_adjust_parent_for_prediv(&cmp->common, &cmp->mux,
478 ++ -1, &parent_rate);
479 ++
480 + reg = readl(cmp->common.base + cmp->common.reg);
481 +
482 + m = reg >> cmp->m.shift;
483 +@@ -114,6 +118,10 @@ static int ccu_mp_set_rate(struct clk_hw *hw, unsigned long rate,
484 + unsigned int m, p;
485 + u32 reg;
486 +
487 ++ /* Adjust parent_rate according to pre-dividers */
488 ++ ccu_mux_helper_adjust_parent_for_prediv(&cmp->common, &cmp->mux,
489 ++ -1, &parent_rate);
490 ++
491 + max_m = cmp->m.max ?: 1 << cmp->m.width;
492 + max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
493 +
494 +diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
495 +index 061b165d632e..0af2229b09fb 100644
496 +--- a/drivers/cpufreq/cpufreq.c
497 ++++ b/drivers/cpufreq/cpufreq.c
498 +@@ -1190,6 +1190,9 @@ static int cpufreq_online(unsigned int cpu)
499 + for_each_cpu(j, policy->related_cpus)
500 + per_cpu(cpufreq_cpu_data, j) = policy;
501 + write_unlock_irqrestore(&cpufreq_driver_lock, flags);
502 ++ } else {
503 ++ policy->min = policy->user_policy.min;
504 ++ policy->max = policy->user_policy.max;
505 + }
506 +
507 + if (cpufreq_driver->get && !cpufreq_driver->setpolicy) {
508 +diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
509 +index c5adc8c9ac43..ae948b1da93a 100644
510 +--- a/drivers/cpuidle/sysfs.c
511 ++++ b/drivers/cpuidle/sysfs.c
512 +@@ -615,6 +615,18 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
513 + struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu);
514 + int error;
515 +
516 ++ /*
517 ++ * Return if cpu_device is not setup for this CPU.
518 ++ *
519 ++ * This could happen if the arch did not set up cpu_device
520 ++ * since this CPU is not in cpu_present mask and the
521 ++ * driver did not send a correct CPU mask during registration.
522 ++ * Without this check we would end up passing bogus
523 ++ * value for &cpu_dev->kobj in kobject_init_and_add()
524 ++ */
525 ++ if (!cpu_dev)
526 ++ return -ENODEV;
527 ++
528 + kdev = kzalloc(sizeof(*kdev), GFP_KERNEL);
529 + if (!kdev)
530 + return -ENOMEM;
531 +diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
532 +index 511ab042b5e7..92d1c6959f08 100644
533 +--- a/drivers/crypto/ccp/ccp-dev.c
534 ++++ b/drivers/crypto/ccp/ccp-dev.c
535 +@@ -283,11 +283,14 @@ EXPORT_SYMBOL_GPL(ccp_version);
536 + */
537 + int ccp_enqueue_cmd(struct ccp_cmd *cmd)
538 + {
539 +- struct ccp_device *ccp = ccp_get_device();
540 ++ struct ccp_device *ccp;
541 + unsigned long flags;
542 + unsigned int i;
543 + int ret;
544 +
545 ++ /* Some commands might need to be sent to a specific device */
546 ++ ccp = cmd->ccp ? cmd->ccp : ccp_get_device();
547 ++
548 + if (!ccp)
549 + return -ENODEV;
550 +
551 +diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
552 +index e5d9278f4019..8d0eeb46d4a2 100644
553 +--- a/drivers/crypto/ccp/ccp-dmaengine.c
554 ++++ b/drivers/crypto/ccp/ccp-dmaengine.c
555 +@@ -390,6 +390,7 @@ static struct ccp_dma_desc *ccp_create_desc(struct dma_chan *dma_chan,
556 + goto err;
557 +
558 + ccp_cmd = &cmd->ccp_cmd;
559 ++ ccp_cmd->ccp = chan->ccp;
560 + ccp_pt = &ccp_cmd->u.passthru_nomap;
561 + ccp_cmd->flags = CCP_CMD_MAY_BACKLOG;
562 + ccp_cmd->flags |= CCP_CMD_PASSTHRU_NO_DMA_MAP;
563 +diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
564 +index ed758b74ddf0..20ab6bf9d1c7 100644
565 +--- a/drivers/dax/dax.c
566 ++++ b/drivers/dax/dax.c
567 +@@ -427,6 +427,7 @@ static int __dax_dev_fault(struct dax_dev *dax_dev, struct vm_area_struct *vma,
568 + int rc = VM_FAULT_SIGBUS;
569 + phys_addr_t phys;
570 + pfn_t pfn;
571 ++ unsigned int fault_size = PAGE_SIZE;
572 +
573 + if (check_vma(dax_dev, vma, __func__))
574 + return VM_FAULT_SIGBUS;
575 +@@ -437,6 +438,9 @@ static int __dax_dev_fault(struct dax_dev *dax_dev, struct vm_area_struct *vma,
576 + return VM_FAULT_SIGBUS;
577 + }
578 +
579 ++ if (fault_size != dax_region->align)
580 ++ return VM_FAULT_SIGBUS;
581 ++
582 + phys = pgoff_to_phys(dax_dev, vmf->pgoff, PAGE_SIZE);
583 + if (phys == -1) {
584 + dev_dbg(dev, "%s: phys_to_pgoff(%#lx) failed\n", __func__,
585 +@@ -482,6 +486,7 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev,
586 + phys_addr_t phys;
587 + pgoff_t pgoff;
588 + pfn_t pfn;
589 ++ unsigned int fault_size = PMD_SIZE;
590 +
591 + if (check_vma(dax_dev, vma, __func__))
592 + return VM_FAULT_SIGBUS;
593 +@@ -498,6 +503,16 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev,
594 + return VM_FAULT_SIGBUS;
595 + }
596 +
597 ++ if (fault_size < dax_region->align)
598 ++ return VM_FAULT_SIGBUS;
599 ++ else if (fault_size > dax_region->align)
600 ++ return VM_FAULT_FALLBACK;
601 ++
602 ++ /* if we are outside of the VMA */
603 ++ if (pmd_addr < vma->vm_start ||
604 ++ (pmd_addr + PMD_SIZE) > vma->vm_end)
605 ++ return VM_FAULT_SIGBUS;
606 ++
607 + pgoff = linear_page_index(vma, pmd_addr);
608 + phys = pgoff_to_phys(dax_dev, pgoff, PMD_SIZE);
609 + if (phys == -1) {
610 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
611 +index 2534adaebe30..f48da3d6698d 100644
612 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
613 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
614 +@@ -424,6 +424,7 @@ static const struct pci_device_id pciidlist[] = {
615 + {0x1002, 0x6985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
616 + {0x1002, 0x6986, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
617 + {0x1002, 0x6987, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
618 ++ {0x1002, 0x6995, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
619 + {0x1002, 0x699F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
620 +
621 + {0, 0, 0}
622 +diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
623 +index 9a5ccae06b6c..054c9c29536d 100644
624 +--- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c
625 ++++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
626 +@@ -3498,9 +3498,13 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev,
627 + max_sclk = 75000;
628 + }
629 + } else if (adev->asic_type == CHIP_OLAND) {
630 +- if ((adev->pdev->device == 0x6604) &&
631 +- (adev->pdev->subsystem_vendor == 0x1028) &&
632 +- (adev->pdev->subsystem_device == 0x066F)) {
633 ++ if ((adev->pdev->revision == 0xC7) ||
634 ++ (adev->pdev->revision == 0x80) ||
635 ++ (adev->pdev->revision == 0x81) ||
636 ++ (adev->pdev->revision == 0x83) ||
637 ++ (adev->pdev->revision == 0x87) ||
638 ++ (adev->pdev->device == 0x6604) ||
639 ++ (adev->pdev->device == 0x6605)) {
640 + max_sclk = 75000;
641 + }
642 + }
643 +diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
644 +index 55e7372ea0a0..205251fae539 100644
645 +--- a/drivers/gpu/drm/drm_atomic_helper.c
646 ++++ b/drivers/gpu/drm/drm_atomic_helper.c
647 +@@ -1389,6 +1389,15 @@ static int stall_checks(struct drm_crtc *crtc, bool nonblock)
648 + return ret < 0 ? ret : 0;
649 + }
650 +
651 ++void release_crtc_commit(struct completion *completion)
652 ++{
653 ++ struct drm_crtc_commit *commit = container_of(completion,
654 ++ typeof(*commit),
655 ++ flip_done);
656 ++
657 ++ drm_crtc_commit_put(commit);
658 ++}
659 ++
660 + /**
661 + * drm_atomic_helper_setup_commit - setup possibly nonblocking commit
662 + * @state: new modeset state to be committed
663 +@@ -1481,6 +1490,8 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
664 + }
665 +
666 + crtc_state->event->base.completion = &commit->flip_done;
667 ++ crtc_state->event->base.completion_release = release_crtc_commit;
668 ++ drm_crtc_commit_get(commit);
669 + }
670 +
671 + return 0;
672 +diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
673 +index 5d96de40b63f..30c20f90520a 100644
674 +--- a/drivers/gpu/drm/drm_fops.c
675 ++++ b/drivers/gpu/drm/drm_fops.c
676 +@@ -689,8 +689,8 @@ void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e)
677 + assert_spin_locked(&dev->event_lock);
678 +
679 + if (e->completion) {
680 +- /* ->completion might disappear as soon as it signalled. */
681 + complete_all(e->completion);
682 ++ e->completion_release(e->completion);
683 + e->completion = NULL;
684 + }
685 +
686 +diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
687 +index f405b07d0381..740996f9bdd4 100644
688 +--- a/drivers/hid/hid-sony.c
689 ++++ b/drivers/hid/hid-sony.c
690 +@@ -2632,6 +2632,8 @@ static int sony_input_configured(struct hid_device *hdev,
691 + sony_leds_remove(sc);
692 + if (sc->quirks & SONY_BATTERY_SUPPORT)
693 + sony_battery_remove(sc);
694 ++ if (sc->touchpad)
695 ++ sony_unregister_touchpad(sc);
696 + sony_cancel_work_sync(sc);
697 + kfree(sc->output_report_dmabuf);
698 + sony_remove_dev_list(sc);
699 +diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
700 +index be34547cdb68..1606e7f08f4b 100644
701 +--- a/drivers/hv/channel.c
702 ++++ b/drivers/hv/channel.c
703 +@@ -506,12 +506,15 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
704 +
705 + wait_for_completion(&info->waitevent);
706 +
707 +- if (channel->rescind) {
708 +- ret = -ENODEV;
709 +- goto post_msg_err;
710 +- }
711 +-
712 + post_msg_err:
713 ++ /*
714 ++ * If the channel has been rescinded;
715 ++ * we will be awakened by the rescind
716 ++ * handler; set the error code to zero so we don't leak memory.
717 ++ */
718 ++ if (channel->rescind)
719 ++ ret = 0;
720 ++
721 + spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
722 + list_del(&info->msglistentry);
723 + spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
724 +diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
725 +index 0af7e39006c8..a58cd102af1b 100644
726 +--- a/drivers/hv/channel_mgmt.c
727 ++++ b/drivers/hv/channel_mgmt.c
728 +@@ -779,6 +779,7 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
729 + /* Allocate the channel object and save this offer. */
730 + newchannel = alloc_channel();
731 + if (!newchannel) {
732 ++ vmbus_release_relid(offer->child_relid);
733 + pr_err("Unable to allocate channel object\n");
734 + return;
735 + }
736 +diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
737 +index cdd9b3b26195..7563eceeaaea 100644
738 +--- a/drivers/hwtracing/intel_th/core.c
739 ++++ b/drivers/hwtracing/intel_th/core.c
740 +@@ -221,8 +221,10 @@ static int intel_th_output_activate(struct intel_th_device *thdev)
741 + else
742 + intel_th_trace_enable(thdev);
743 +
744 +- if (ret)
745 ++ if (ret) {
746 + pm_runtime_put(&thdev->dev);
747 ++ module_put(thdrv->driver.owner);
748 ++ }
749 +
750 + return ret;
751 + }
752 +diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
753 +index ad9dec30bb30..4282ceca3d8f 100644
754 +--- a/drivers/iio/adc/ti_am335x_adc.c
755 ++++ b/drivers/iio/adc/ti_am335x_adc.c
756 +@@ -169,7 +169,9 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
757 + {
758 + struct iio_dev *indio_dev = private;
759 + struct tiadc_device *adc_dev = iio_priv(indio_dev);
760 +- unsigned int status, config;
761 ++ unsigned int status, config, adc_fsm;
762 ++ unsigned short count = 0;
763 ++
764 + status = tiadc_readl(adc_dev, REG_IRQSTATUS);
765 +
766 + /*
767 +@@ -183,6 +185,15 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
768 + tiadc_writel(adc_dev, REG_CTRL, config);
769 + tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1OVRRUN
770 + | IRQENB_FIFO1UNDRFLW | IRQENB_FIFO1THRES);
771 ++
772 ++ /* wait for idle state.
773 ++ * ADC needs to finish the current conversion
774 ++ * before disabling the module
775 ++ */
776 ++ do {
777 ++ adc_fsm = tiadc_readl(adc_dev, REG_ADCFSM);
778 ++ } while (adc_fsm != 0x10 && count++ < 100);
779 ++
780 + tiadc_writel(adc_dev, REG_CTRL, (config | CNTRLREG_TSCSSENB));
781 + return IRQ_HANDLED;
782 + } else if (status & IRQENB_FIFO1THRES) {
783 +diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
784 +index a3cce3a38300..ecf592d69043 100644
785 +--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
786 ++++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
787 +@@ -51,8 +51,6 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
788 + st->report_state.report_id,
789 + st->report_state.index,
790 + HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM);
791 +-
792 +- poll_value = hid_sensor_read_poll_value(st);
793 + } else {
794 + int val;
795 +
796 +@@ -89,7 +87,9 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
797 + sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
798 + st->power_state.index,
799 + sizeof(state_val), &state_val);
800 +- if (state && poll_value)
801 ++ if (state)
802 ++ poll_value = hid_sensor_read_poll_value(st);
803 ++ if (poll_value > 0)
804 + msleep_interruptible(poll_value * 2);
805 +
806 + return 0;
807 +diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c
808 +index ce09d771c1fb..75f83424903b 100644
809 +--- a/drivers/iio/magnetometer/ak8974.c
810 ++++ b/drivers/iio/magnetometer/ak8974.c
811 +@@ -767,7 +767,7 @@ static int ak8974_probe(struct i2c_client *i2c,
812 + return ret;
813 + }
814 +
815 +-static int __exit ak8974_remove(struct i2c_client *i2c)
816 ++static int ak8974_remove(struct i2c_client *i2c)
817 + {
818 + struct iio_dev *indio_dev = i2c_get_clientdata(i2c);
819 + struct ak8974 *ak8974 = iio_priv(indio_dev);
820 +@@ -849,7 +849,7 @@ static struct i2c_driver ak8974_driver = {
821 + .of_match_table = of_match_ptr(ak8974_of_match),
822 + },
823 + .probe = ak8974_probe,
824 +- .remove = __exit_p(ak8974_remove),
825 ++ .remove = ak8974_remove,
826 + .id_table = ak8974_id,
827 + };
828 + module_i2c_driver(ak8974_driver);
829 +diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
830 +index d96aa27dfcdc..db64adfbe1af 100644
831 +--- a/drivers/input/joystick/iforce/iforce-usb.c
832 ++++ b/drivers/input/joystick/iforce/iforce-usb.c
833 +@@ -141,6 +141,9 @@ static int iforce_usb_probe(struct usb_interface *intf,
834 +
835 + interface = intf->cur_altsetting;
836 +
837 ++ if (interface->desc.bNumEndpoints < 2)
838 ++ return -ENODEV;
839 ++
840 + epirq = &interface->endpoint[0].desc;
841 + epout = &interface->endpoint[1].desc;
842 +
843 +diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
844 +index 9cc6d057c302..23c191a2a071 100644
845 +--- a/drivers/input/misc/cm109.c
846 ++++ b/drivers/input/misc/cm109.c
847 +@@ -700,6 +700,10 @@ static int cm109_usb_probe(struct usb_interface *intf,
848 + int error = -ENOMEM;
849 +
850 + interface = intf->cur_altsetting;
851 ++
852 ++ if (interface->desc.bNumEndpoints < 1)
853 ++ return -ENODEV;
854 ++
855 + endpoint = &interface->endpoint[0].desc;
856 +
857 + if (!usb_endpoint_is_int_in(endpoint))
858 +diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
859 +index 9c0ea36913b4..f4e8fbec6a94 100644
860 +--- a/drivers/input/misc/ims-pcu.c
861 ++++ b/drivers/input/misc/ims-pcu.c
862 +@@ -1667,6 +1667,10 @@ static int ims_pcu_parse_cdc_data(struct usb_interface *intf, struct ims_pcu *pc
863 + return -EINVAL;
864 +
865 + alt = pcu->ctrl_intf->cur_altsetting;
866 ++
867 ++ if (alt->desc.bNumEndpoints < 1)
868 ++ return -ENODEV;
869 ++
870 + pcu->ep_ctrl = &alt->endpoint[0].desc;
871 + pcu->max_ctrl_size = usb_endpoint_maxp(pcu->ep_ctrl);
872 +
873 +diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c
874 +index 79c964c075f1..6e7ff9561d92 100644
875 +--- a/drivers/input/misc/yealink.c
876 ++++ b/drivers/input/misc/yealink.c
877 +@@ -875,6 +875,10 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
878 + int ret, pipe, i;
879 +
880 + interface = intf->cur_altsetting;
881 ++
882 ++ if (interface->desc.bNumEndpoints < 1)
883 ++ return -ENODEV;
884 ++
885 + endpoint = &interface->endpoint[0].desc;
886 + if (!usb_endpoint_is_int_in(endpoint))
887 + return -ENODEV;
888 +diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
889 +index 328edc8c8786..2a0f9e79bf69 100644
890 +--- a/drivers/input/mouse/alps.c
891 ++++ b/drivers/input/mouse/alps.c
892 +@@ -1282,10 +1282,8 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
893 + /* handle buttons */
894 + if (pkt_id == SS4_PACKET_ID_STICK) {
895 + f->ts_left = !!(SS4_BTN_V2(p) & 0x01);
896 +- if (!(priv->flags & ALPS_BUTTONPAD)) {
897 +- f->ts_right = !!(SS4_BTN_V2(p) & 0x02);
898 +- f->ts_middle = !!(SS4_BTN_V2(p) & 0x04);
899 +- }
900 ++ f->ts_right = !!(SS4_BTN_V2(p) & 0x02);
901 ++ f->ts_middle = !!(SS4_BTN_V2(p) & 0x04);
902 + } else {
903 + f->left = !!(SS4_BTN_V2(p) & 0x01);
904 + if (!(priv->flags & ALPS_BUTTONPAD)) {
905 +@@ -2462,14 +2460,34 @@ static int alps_update_device_area_ss4_v2(unsigned char otp[][4],
906 + int num_y_electrode;
907 + int x_pitch, y_pitch, x_phys, y_phys;
908 +
909 +- num_x_electrode = SS4_NUMSENSOR_XOFFSET + (otp[1][0] & 0x0F);
910 +- num_y_electrode = SS4_NUMSENSOR_YOFFSET + ((otp[1][0] >> 4) & 0x0F);
911 ++ if (IS_SS4PLUS_DEV(priv->dev_id)) {
912 ++ num_x_electrode =
913 ++ SS4PLUS_NUMSENSOR_XOFFSET + (otp[0][2] & 0x0F);
914 ++ num_y_electrode =
915 ++ SS4PLUS_NUMSENSOR_YOFFSET + ((otp[0][2] >> 4) & 0x0F);
916 ++
917 ++ priv->x_max =
918 ++ (num_x_electrode - 1) * SS4PLUS_COUNT_PER_ELECTRODE;
919 ++ priv->y_max =
920 ++ (num_y_electrode - 1) * SS4PLUS_COUNT_PER_ELECTRODE;
921 +
922 +- priv->x_max = (num_x_electrode - 1) * SS4_COUNT_PER_ELECTRODE;
923 +- priv->y_max = (num_y_electrode - 1) * SS4_COUNT_PER_ELECTRODE;
924 ++ x_pitch = (otp[0][1] & 0x0F) + SS4PLUS_MIN_PITCH_MM;
925 ++ y_pitch = ((otp[0][1] >> 4) & 0x0F) + SS4PLUS_MIN_PITCH_MM;
926 +
927 +- x_pitch = ((otp[1][2] >> 2) & 0x07) + SS4_MIN_PITCH_MM;
928 +- y_pitch = ((otp[1][2] >> 5) & 0x07) + SS4_MIN_PITCH_MM;
929 ++ } else {
930 ++ num_x_electrode =
931 ++ SS4_NUMSENSOR_XOFFSET + (otp[1][0] & 0x0F);
932 ++ num_y_electrode =
933 ++ SS4_NUMSENSOR_YOFFSET + ((otp[1][0] >> 4) & 0x0F);
934 ++
935 ++ priv->x_max =
936 ++ (num_x_electrode - 1) * SS4_COUNT_PER_ELECTRODE;
937 ++ priv->y_max =
938 ++ (num_y_electrode - 1) * SS4_COUNT_PER_ELECTRODE;
939 ++
940 ++ x_pitch = ((otp[1][2] >> 2) & 0x07) + SS4_MIN_PITCH_MM;
941 ++ y_pitch = ((otp[1][2] >> 5) & 0x07) + SS4_MIN_PITCH_MM;
942 ++ }
943 +
944 + x_phys = x_pitch * (num_x_electrode - 1); /* In 0.1 mm units */
945 + y_phys = y_pitch * (num_y_electrode - 1); /* In 0.1 mm units */
946 +@@ -2485,7 +2503,10 @@ static int alps_update_btn_info_ss4_v2(unsigned char otp[][4],
947 + {
948 + unsigned char is_btnless;
949 +
950 +- is_btnless = (otp[1][1] >> 3) & 0x01;
951 ++ if (IS_SS4PLUS_DEV(priv->dev_id))
952 ++ is_btnless = (otp[1][0] >> 1) & 0x01;
953 ++ else
954 ++ is_btnless = (otp[1][1] >> 3) & 0x01;
955 +
956 + if (is_btnless)
957 + priv->flags |= ALPS_BUTTONPAD;
958 +@@ -2493,6 +2514,21 @@ static int alps_update_btn_info_ss4_v2(unsigned char otp[][4],
959 + return 0;
960 + }
961 +
962 ++static int alps_update_dual_info_ss4_v2(unsigned char otp[][4],
963 ++ struct alps_data *priv)
964 ++{
965 ++ bool is_dual = false;
966 ++
967 ++ if (IS_SS4PLUS_DEV(priv->dev_id))
968 ++ is_dual = (otp[0][0] >> 4) & 0x01;
969 ++
970 ++ if (is_dual)
971 ++ priv->flags |= ALPS_DUALPOINT |
972 ++ ALPS_DUALPOINT_WITH_PRESSURE;
973 ++
974 ++ return 0;
975 ++}
976 ++
977 + static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
978 + struct alps_data *priv)
979 + {
980 +@@ -2508,6 +2544,8 @@ static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
981 +
982 + alps_update_btn_info_ss4_v2(otp, priv);
983 +
984 ++ alps_update_dual_info_ss4_v2(otp, priv);
985 ++
986 + return 0;
987 + }
988 +
989 +@@ -2753,10 +2791,6 @@ static int alps_set_protocol(struct psmouse *psmouse,
990 + if (alps_set_defaults_ss4_v2(psmouse, priv))
991 + return -EIO;
992 +
993 +- if (priv->fw_ver[1] == 0x1)
994 +- priv->flags |= ALPS_DUALPOINT |
995 +- ALPS_DUALPOINT_WITH_PRESSURE;
996 +-
997 + break;
998 + }
999 +
1000 +@@ -2827,10 +2861,7 @@ static int alps_identify(struct psmouse *psmouse, struct alps_data *priv)
1001 + ec[2] >= 0x90 && ec[2] <= 0x9d) {
1002 + protocol = &alps_v3_protocol_data;
1003 + } else if (e7[0] == 0x73 && e7[1] == 0x03 &&
1004 +- e7[2] == 0x14 && ec[1] == 0x02) {
1005 +- protocol = &alps_v8_protocol_data;
1006 +- } else if (e7[0] == 0x73 && e7[1] == 0x03 &&
1007 +- e7[2] == 0x28 && ec[1] == 0x01) {
1008 ++ (e7[2] == 0x14 || e7[2] == 0x28)) {
1009 + protocol = &alps_v8_protocol_data;
1010 + } else {
1011 + psmouse_dbg(psmouse,
1012 +@@ -2840,7 +2871,8 @@ static int alps_identify(struct psmouse *psmouse, struct alps_data *priv)
1013 + }
1014 +
1015 + if (priv) {
1016 +- /* Save the Firmware version */
1017 ++ /* Save Device ID and Firmware version */
1018 ++ memcpy(priv->dev_id, e7, 3);
1019 + memcpy(priv->fw_ver, ec, 3);
1020 + error = alps_set_protocol(psmouse, priv, protocol);
1021 + if (error)
1022 +diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
1023 +index 6d279aa27cb9..4334f2805d93 100644
1024 +--- a/drivers/input/mouse/alps.h
1025 ++++ b/drivers/input/mouse/alps.h
1026 +@@ -54,6 +54,16 @@ enum SS4_PACKET_ID {
1027 +
1028 + #define SS4_MASK_NORMAL_BUTTONS 0x07
1029 +
1030 ++#define SS4PLUS_COUNT_PER_ELECTRODE 128
1031 ++#define SS4PLUS_NUMSENSOR_XOFFSET 16
1032 ++#define SS4PLUS_NUMSENSOR_YOFFSET 5
1033 ++#define SS4PLUS_MIN_PITCH_MM 37
1034 ++
1035 ++#define IS_SS4PLUS_DEV(_b) (((_b[0]) == 0x73) && \
1036 ++ ((_b[1]) == 0x03) && \
1037 ++ ((_b[2]) == 0x28) \
1038 ++ )
1039 ++
1040 + #define SS4_IS_IDLE_V2(_b) (((_b[0]) == 0x18) && \
1041 + ((_b[1]) == 0x10) && \
1042 + ((_b[2]) == 0x00) && \
1043 +@@ -283,6 +293,7 @@ struct alps_data {
1044 + int addr_command;
1045 + u16 proto_version;
1046 + u8 byte0, mask0;
1047 ++ u8 dev_id[3];
1048 + u8 fw_ver[3];
1049 + int flags;
1050 + int x_max;
1051 +diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
1052 +index 1e1d0ad406f2..a26f44c28d82 100644
1053 +--- a/drivers/input/mouse/elan_i2c_core.c
1054 ++++ b/drivers/input/mouse/elan_i2c_core.c
1055 +@@ -218,17 +218,19 @@ static int elan_query_product(struct elan_tp_data *data)
1056 +
1057 + static int elan_check_ASUS_special_fw(struct elan_tp_data *data)
1058 + {
1059 +- if (data->ic_type != 0x0E)
1060 +- return false;
1061 +-
1062 +- switch (data->product_id) {
1063 +- case 0x05 ... 0x07:
1064 +- case 0x09:
1065 +- case 0x13:
1066 ++ if (data->ic_type == 0x0E) {
1067 ++ switch (data->product_id) {
1068 ++ case 0x05 ... 0x07:
1069 ++ case 0x09:
1070 ++ case 0x13:
1071 ++ return true;
1072 ++ }
1073 ++ } else if (data->ic_type == 0x08 && data->product_id == 0x26) {
1074 ++ /* ASUS EeeBook X205TA */
1075 + return true;
1076 +- default:
1077 +- return false;
1078 + }
1079 ++
1080 ++ return false;
1081 + }
1082 +
1083 + static int __elan_initialize(struct elan_tp_data *data)
1084 +diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
1085 +index a7618776705a..27ae2a0ef1b9 100644
1086 +--- a/drivers/input/serio/i8042-x86ia64io.h
1087 ++++ b/drivers/input/serio/i8042-x86ia64io.h
1088 +@@ -120,6 +120,13 @@ static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = {
1089 + },
1090 + },
1091 + {
1092 ++ /* Dell Embedded Box PC 3000 */
1093 ++ .matches = {
1094 ++ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
1095 ++ DMI_MATCH(DMI_PRODUCT_NAME, "Embedded Box PC 3000"),
1096 ++ },
1097 ++ },
1098 ++ {
1099 + /* OQO Model 01 */
1100 + .matches = {
1101 + DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
1102 +diff --git a/drivers/input/tablet/hanwang.c b/drivers/input/tablet/hanwang.c
1103 +index cd852059b99e..df4bea96d7ed 100644
1104 +--- a/drivers/input/tablet/hanwang.c
1105 ++++ b/drivers/input/tablet/hanwang.c
1106 +@@ -340,6 +340,9 @@ static int hanwang_probe(struct usb_interface *intf, const struct usb_device_id
1107 + int error;
1108 + int i;
1109 +
1110 ++ if (intf->cur_altsetting->desc.bNumEndpoints < 1)
1111 ++ return -ENODEV;
1112 ++
1113 + hanwang = kzalloc(sizeof(struct hanwang), GFP_KERNEL);
1114 + input_dev = input_allocate_device();
1115 + if (!hanwang || !input_dev) {
1116 +diff --git a/drivers/input/tablet/kbtab.c b/drivers/input/tablet/kbtab.c
1117 +index e850d7e8afbc..4d9d64908b59 100644
1118 +--- a/drivers/input/tablet/kbtab.c
1119 ++++ b/drivers/input/tablet/kbtab.c
1120 +@@ -122,6 +122,9 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
1121 + struct input_dev *input_dev;
1122 + int error = -ENOMEM;
1123 +
1124 ++ if (intf->cur_altsetting->desc.bNumEndpoints < 1)
1125 ++ return -ENODEV;
1126 ++
1127 + kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL);
1128 + input_dev = input_allocate_device();
1129 + if (!kbtab || !input_dev)
1130 +diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
1131 +index aefb6e11f88a..4c0eecae065c 100644
1132 +--- a/drivers/input/touchscreen/sur40.c
1133 ++++ b/drivers/input/touchscreen/sur40.c
1134 +@@ -527,6 +527,9 @@ static int sur40_probe(struct usb_interface *interface,
1135 + if (iface_desc->desc.bInterfaceClass != 0xFF)
1136 + return -ENODEV;
1137 +
1138 ++ if (iface_desc->desc.bNumEndpoints < 5)
1139 ++ return -ENODEV;
1140 ++
1141 + /* Use endpoint #4 (0x86). */
1142 + endpoint = &iface_desc->endpoint[4].desc;
1143 + if (endpoint->bEndpointAddress != TOUCH_ENDPOINT)
1144 +diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
1145 +index 57ba0d3091ea..318cc878d0ca 100644
1146 +--- a/drivers/iommu/exynos-iommu.c
1147 ++++ b/drivers/iommu/exynos-iommu.c
1148 +@@ -509,7 +509,13 @@ static void sysmmu_tlb_invalidate_flpdcache(struct sysmmu_drvdata *data,
1149 + spin_lock_irqsave(&data->lock, flags);
1150 + if (data->active && data->version >= MAKE_MMU_VER(3, 3)) {
1151 + clk_enable(data->clk_master);
1152 +- __sysmmu_tlb_invalidate_entry(data, iova, 1);
1153 ++ if (sysmmu_block(data)) {
1154 ++ if (data->version >= MAKE_MMU_VER(5, 0))
1155 ++ __sysmmu_tlb_invalidate(data);
1156 ++ else
1157 ++ __sysmmu_tlb_invalidate_entry(data, iova, 1);
1158 ++ sysmmu_unblock(data);
1159 ++ }
1160 + clk_disable(data->clk_master);
1161 + }
1162 + spin_unlock_irqrestore(&data->lock, flags);
1163 +diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
1164 +index 23eead3cf77c..dfeb3808bc62 100644
1165 +--- a/drivers/iommu/intel-iommu.c
1166 ++++ b/drivers/iommu/intel-iommu.c
1167 +@@ -915,7 +915,7 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
1168 + * which we used for the IOMMU lookup. Strictly speaking
1169 + * we could do this for all PCI devices; we only need to
1170 + * get the BDF# from the scope table for ACPI matches. */
1171 +- if (pdev->is_virtfn)
1172 ++ if (pdev && pdev->is_virtfn)
1173 + goto got_pdev;
1174 +
1175 + *bus = drhd->devices[i].bus;
1176 +diff --git a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
1177 +index ab9866024ec7..04033efe7ad5 100644
1178 +--- a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
1179 ++++ b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
1180 +@@ -36,16 +36,18 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 le
1181 + int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
1182 + {
1183 + struct hexline *hx;
1184 +- u8 reset;
1185 +- int ret,pos=0;
1186 ++ u8 *buf;
1187 ++ int ret, pos = 0;
1188 ++ u16 cpu_cs_register = cypress[type].cpu_cs_register;
1189 +
1190 +- hx = kmalloc(sizeof(*hx), GFP_KERNEL);
1191 +- if (!hx)
1192 ++ buf = kmalloc(sizeof(*hx), GFP_KERNEL);
1193 ++ if (!buf)
1194 + return -ENOMEM;
1195 ++ hx = (struct hexline *)buf;
1196 +
1197 + /* stop the CPU */
1198 +- reset = 1;
1199 +- if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1)
1200 ++ buf[0] = 1;
1201 ++ if (usb_cypress_writemem(udev, cpu_cs_register, buf, 1) != 1)
1202 + err("could not stop the USB controller CPU.");
1203 +
1204 + while ((ret = dvb_usb_get_hexline(fw, hx, &pos)) > 0) {
1205 +@@ -61,21 +63,21 @@ int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw
1206 + }
1207 + if (ret < 0) {
1208 + err("firmware download failed at %d with %d",pos,ret);
1209 +- kfree(hx);
1210 ++ kfree(buf);
1211 + return ret;
1212 + }
1213 +
1214 + if (ret == 0) {
1215 + /* restart the CPU */
1216 +- reset = 0;
1217 +- if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) {
1218 ++ buf[0] = 0;
1219 ++ if (usb_cypress_writemem(udev, cpu_cs_register, buf, 1) != 1) {
1220 + err("could not restart the USB controller CPU.");
1221 + ret = -EINVAL;
1222 + }
1223 + } else
1224 + ret = -EIO;
1225 +
1226 +- kfree(hx);
1227 ++ kfree(buf);
1228 +
1229 + return ret;
1230 + }
1231 +diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c
1232 +index 3600c9993a98..29f2daed37e0 100644
1233 +--- a/drivers/misc/mei/bus-fixup.c
1234 ++++ b/drivers/misc/mei/bus-fixup.c
1235 +@@ -112,11 +112,9 @@ struct mkhi_msg {
1236 +
1237 + static int mei_osver(struct mei_cl_device *cldev)
1238 + {
1239 +- int ret;
1240 + const size_t size = sizeof(struct mkhi_msg_hdr) +
1241 + sizeof(struct mkhi_fwcaps) +
1242 + sizeof(struct mei_os_ver);
1243 +- size_t length = 8;
1244 + char buf[size];
1245 + struct mkhi_msg *req;
1246 + struct mkhi_fwcaps *fwcaps;
1247 +@@ -137,15 +135,7 @@ static int mei_osver(struct mei_cl_device *cldev)
1248 + os_ver = (struct mei_os_ver *)fwcaps->data;
1249 + os_ver->os_type = OSTYPE_LINUX;
1250 +
1251 +- ret = __mei_cl_send(cldev->cl, buf, size, mode);
1252 +- if (ret < 0)
1253 +- return ret;
1254 +-
1255 +- ret = __mei_cl_recv(cldev->cl, buf, length, 0);
1256 +- if (ret < 0)
1257 +- return ret;
1258 +-
1259 +- return 0;
1260 ++ return __mei_cl_send(cldev->cl, buf, size, mode);
1261 + }
1262 +
1263 + static void mei_mkhi_fix(struct mei_cl_device *cldev)
1264 +@@ -160,7 +150,7 @@ static void mei_mkhi_fix(struct mei_cl_device *cldev)
1265 + return;
1266 +
1267 + ret = mei_osver(cldev);
1268 +- if (ret)
1269 ++ if (ret < 0)
1270 + dev_err(&cldev->dev, "OS version command failed %d\n", ret);
1271 +
1272 + mei_cldev_disable(cldev);
1273 +diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
1274 +index 41e5760a6886..a13abc8fa1bc 100644
1275 +--- a/drivers/misc/mei/init.c
1276 ++++ b/drivers/misc/mei/init.c
1277 +@@ -124,8 +124,6 @@ int mei_reset(struct mei_device *dev)
1278 +
1279 + mei_clear_interrupts(dev);
1280 +
1281 +- mei_synchronize_irq(dev);
1282 +-
1283 + /* we're already in reset, cancel the init timer
1284 + * if the reset was called due the hbm protocol error
1285 + * we need to call it before hw start
1286 +@@ -304,6 +302,9 @@ static void mei_reset_work(struct work_struct *work)
1287 + container_of(work, struct mei_device, reset_work);
1288 + int ret;
1289 +
1290 ++ mei_clear_interrupts(dev);
1291 ++ mei_synchronize_irq(dev);
1292 ++
1293 + mutex_lock(&dev->device_lock);
1294 +
1295 + ret = mei_reset(dev);
1296 +@@ -328,6 +329,9 @@ void mei_stop(struct mei_device *dev)
1297 +
1298 + mei_cancel_work(dev);
1299 +
1300 ++ mei_clear_interrupts(dev);
1301 ++ mei_synchronize_irq(dev);
1302 ++
1303 + mutex_lock(&dev->device_lock);
1304 +
1305 + dev->dev_state = MEI_DEV_POWER_DOWN;
1306 +diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
1307 +index cb1698f268f1..7f4927a05be0 100644
1308 +--- a/drivers/mmc/core/block.c
1309 ++++ b/drivers/mmc/core/block.c
1310 +@@ -1791,6 +1791,7 @@ int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
1311 + ret = mmc_blk_issue_flush(mq, req);
1312 + } else {
1313 + ret = mmc_blk_issue_rw_rq(mq, req);
1314 ++ card->host->context_info.is_waiting_last_req = false;
1315 + }
1316 +
1317 + out:
1318 +diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
1319 +index 0fccca075e29..4ede0904602c 100644
1320 +--- a/drivers/mmc/core/mmc.c
1321 ++++ b/drivers/mmc/core/mmc.c
1322 +@@ -1706,7 +1706,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1323 + err = mmc_select_hs400(card);
1324 + if (err)
1325 + goto free_card;
1326 +- } else {
1327 ++ } else if (!mmc_card_hs400es(card)) {
1328 + /* Select the desired bus width optionally */
1329 + err = mmc_select_bus_width(card);
1330 + if (err > 0 && mmc_card_hs(card)) {
1331 +diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
1332 +index 410a55b1c25f..1cfd7f900339 100644
1333 +--- a/drivers/mmc/host/sdhci-of-arasan.c
1334 ++++ b/drivers/mmc/host/sdhci-of-arasan.c
1335 +@@ -28,13 +28,9 @@
1336 + #include "sdhci-pltfm.h"
1337 + #include <linux/of.h>
1338 +
1339 +-#define SDHCI_ARASAN_CLK_CTRL_OFFSET 0x2c
1340 + #define SDHCI_ARASAN_VENDOR_REGISTER 0x78
1341 +
1342 + #define VENDOR_ENHANCED_STROBE BIT(0)
1343 +-#define CLK_CTRL_TIMEOUT_SHIFT 16
1344 +-#define CLK_CTRL_TIMEOUT_MASK (0xf << CLK_CTRL_TIMEOUT_SHIFT)
1345 +-#define CLK_CTRL_TIMEOUT_MIN_EXP 13
1346 +
1347 + #define PHY_CLK_TOO_SLOW_HZ 400000
1348 +
1349 +@@ -163,15 +159,15 @@ static int sdhci_arasan_syscon_write(struct sdhci_host *host,
1350 +
1351 + static unsigned int sdhci_arasan_get_timeout_clock(struct sdhci_host *host)
1352 + {
1353 +- u32 div;
1354 + unsigned long freq;
1355 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
1356 +
1357 +- div = readl(host->ioaddr + SDHCI_ARASAN_CLK_CTRL_OFFSET);
1358 +- div = (div & CLK_CTRL_TIMEOUT_MASK) >> CLK_CTRL_TIMEOUT_SHIFT;
1359 ++ /* SDHCI timeout clock is in kHz */
1360 ++ freq = DIV_ROUND_UP(clk_get_rate(pltfm_host->clk), 1000);
1361 +
1362 +- freq = clk_get_rate(pltfm_host->clk);
1363 +- freq /= 1 << (CLK_CTRL_TIMEOUT_MIN_EXP + div);
1364 ++ /* or in MHz */
1365 ++ if (host->caps & SDHCI_TIMEOUT_CLK_UNIT)
1366 ++ freq = DIV_ROUND_UP(freq, 1000);
1367 +
1368 + return freq;
1369 + }
1370 +diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
1371 +index 2f9ad213377a..7fd964256faa 100644
1372 +--- a/drivers/mmc/host/sdhci-of-at91.c
1373 ++++ b/drivers/mmc/host/sdhci-of-at91.c
1374 +@@ -85,11 +85,30 @@ static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock)
1375 + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
1376 + }
1377 +
1378 ++/*
1379 ++ * In this specific implementation of the SDHCI controller, the power register
1380 ++ * needs to have a valid voltage set even when the power supply is managed by
1381 ++ * an external regulator.
1382 ++ */
1383 ++static void sdhci_at91_set_power(struct sdhci_host *host, unsigned char mode,
1384 ++ unsigned short vdd)
1385 ++{
1386 ++ if (!IS_ERR(host->mmc->supply.vmmc)) {
1387 ++ struct mmc_host *mmc = host->mmc;
1388 ++
1389 ++ spin_unlock_irq(&host->lock);
1390 ++ mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
1391 ++ spin_lock_irq(&host->lock);
1392 ++ }
1393 ++ sdhci_set_power_noreg(host, mode, vdd);
1394 ++}
1395 ++
1396 + static const struct sdhci_ops sdhci_at91_sama5d2_ops = {
1397 + .set_clock = sdhci_at91_set_clock,
1398 + .set_bus_width = sdhci_set_bus_width,
1399 + .reset = sdhci_reset,
1400 + .set_uhs_signaling = sdhci_set_uhs_signaling,
1401 ++ .set_power = sdhci_at91_set_power,
1402 + };
1403 +
1404 + static const struct sdhci_pltfm_data soc_data_sama5d2 = {
1405 +diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
1406 +index 1a72d32af07f..e977048a8428 100644
1407 +--- a/drivers/mmc/host/sdhci-pci-core.c
1408 ++++ b/drivers/mmc/host/sdhci-pci-core.c
1409 +@@ -452,6 +452,8 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
1410 + if (mode == MMC_POWER_OFF)
1411 + return;
1412 +
1413 ++ spin_unlock_irq(&host->lock);
1414 ++
1415 + /*
1416 + * Bus power might not enable after D3 -> D0 transition due to the
1417 + * present state not yet having propagated. Retry for up to 2ms.
1418 +@@ -464,6 +466,8 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
1419 + reg |= SDHCI_POWER_ON;
1420 + sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
1421 + }
1422 ++
1423 ++ spin_lock_irq(&host->lock);
1424 + }
1425 +
1426 + static const struct sdhci_ops sdhci_intel_byt_ops = {
1427 +diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
1428 +index 0def99590d16..d0819d18ad08 100644
1429 +--- a/drivers/mmc/host/sdhci.c
1430 ++++ b/drivers/mmc/host/sdhci.c
1431 +@@ -1362,7 +1362,9 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk)
1432 + return;
1433 + }
1434 + timeout--;
1435 +- mdelay(1);
1436 ++ spin_unlock_irq(&host->lock);
1437 ++ usleep_range(900, 1100);
1438 ++ spin_lock_irq(&host->lock);
1439 + }
1440 +
1441 + clk |= SDHCI_CLOCK_CARD_EN;
1442 +diff --git a/drivers/mmc/host/ushc.c b/drivers/mmc/host/ushc.c
1443 +index d2c386f09d69..1d843357422e 100644
1444 +--- a/drivers/mmc/host/ushc.c
1445 ++++ b/drivers/mmc/host/ushc.c
1446 +@@ -426,6 +426,9 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *id
1447 + struct ushc_data *ushc;
1448 + int ret;
1449 +
1450 ++ if (intf->cur_altsetting->desc.bNumEndpoints < 1)
1451 ++ return -ENODEV;
1452 ++
1453 + mmc = mmc_alloc_host(sizeof(struct ushc_data), &intf->dev);
1454 + if (mmc == NULL)
1455 + return -ENOMEM;
1456 +diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-common.h b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
1457 +index 8a280e7d66bd..127adbeefb10 100644
1458 +--- a/drivers/net/ethernet/amd/xgbe/xgbe-common.h
1459 ++++ b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
1460 +@@ -984,29 +984,29 @@
1461 + #define XP_ECC_CNT1_DESC_DED_WIDTH 8
1462 + #define XP_ECC_CNT1_DESC_SEC_INDEX 0
1463 + #define XP_ECC_CNT1_DESC_SEC_WIDTH 8
1464 +-#define XP_ECC_IER_DESC_DED_INDEX 0
1465 ++#define XP_ECC_IER_DESC_DED_INDEX 5
1466 + #define XP_ECC_IER_DESC_DED_WIDTH 1
1467 +-#define XP_ECC_IER_DESC_SEC_INDEX 1
1468 ++#define XP_ECC_IER_DESC_SEC_INDEX 4
1469 + #define XP_ECC_IER_DESC_SEC_WIDTH 1
1470 +-#define XP_ECC_IER_RX_DED_INDEX 2
1471 ++#define XP_ECC_IER_RX_DED_INDEX 3
1472 + #define XP_ECC_IER_RX_DED_WIDTH 1
1473 +-#define XP_ECC_IER_RX_SEC_INDEX 3
1474 ++#define XP_ECC_IER_RX_SEC_INDEX 2
1475 + #define XP_ECC_IER_RX_SEC_WIDTH 1
1476 +-#define XP_ECC_IER_TX_DED_INDEX 4
1477 ++#define XP_ECC_IER_TX_DED_INDEX 1
1478 + #define XP_ECC_IER_TX_DED_WIDTH 1
1479 +-#define XP_ECC_IER_TX_SEC_INDEX 5
1480 ++#define XP_ECC_IER_TX_SEC_INDEX 0
1481 + #define XP_ECC_IER_TX_SEC_WIDTH 1
1482 +-#define XP_ECC_ISR_DESC_DED_INDEX 0
1483 ++#define XP_ECC_ISR_DESC_DED_INDEX 5
1484 + #define XP_ECC_ISR_DESC_DED_WIDTH 1
1485 +-#define XP_ECC_ISR_DESC_SEC_INDEX 1
1486 ++#define XP_ECC_ISR_DESC_SEC_INDEX 4
1487 + #define XP_ECC_ISR_DESC_SEC_WIDTH 1
1488 +-#define XP_ECC_ISR_RX_DED_INDEX 2
1489 ++#define XP_ECC_ISR_RX_DED_INDEX 3
1490 + #define XP_ECC_ISR_RX_DED_WIDTH 1
1491 +-#define XP_ECC_ISR_RX_SEC_INDEX 3
1492 ++#define XP_ECC_ISR_RX_SEC_INDEX 2
1493 + #define XP_ECC_ISR_RX_SEC_WIDTH 1
1494 +-#define XP_ECC_ISR_TX_DED_INDEX 4
1495 ++#define XP_ECC_ISR_TX_DED_INDEX 1
1496 + #define XP_ECC_ISR_TX_DED_WIDTH 1
1497 +-#define XP_ECC_ISR_TX_SEC_INDEX 5
1498 ++#define XP_ECC_ISR_TX_SEC_INDEX 0
1499 + #define XP_ECC_ISR_TX_SEC_WIDTH 1
1500 + #define XP_I2C_MUTEX_BUSY_INDEX 31
1501 + #define XP_I2C_MUTEX_BUSY_WIDTH 1
1502 +@@ -1148,8 +1148,8 @@
1503 + #define RX_PACKET_ATTRIBUTES_CSUM_DONE_WIDTH 1
1504 + #define RX_PACKET_ATTRIBUTES_VLAN_CTAG_INDEX 1
1505 + #define RX_PACKET_ATTRIBUTES_VLAN_CTAG_WIDTH 1
1506 +-#define RX_PACKET_ATTRIBUTES_INCOMPLETE_INDEX 2
1507 +-#define RX_PACKET_ATTRIBUTES_INCOMPLETE_WIDTH 1
1508 ++#define RX_PACKET_ATTRIBUTES_LAST_INDEX 2
1509 ++#define RX_PACKET_ATTRIBUTES_LAST_WIDTH 1
1510 + #define RX_PACKET_ATTRIBUTES_CONTEXT_NEXT_INDEX 3
1511 + #define RX_PACKET_ATTRIBUTES_CONTEXT_NEXT_WIDTH 1
1512 + #define RX_PACKET_ATTRIBUTES_CONTEXT_INDEX 4
1513 +@@ -1158,6 +1158,8 @@
1514 + #define RX_PACKET_ATTRIBUTES_RX_TSTAMP_WIDTH 1
1515 + #define RX_PACKET_ATTRIBUTES_RSS_HASH_INDEX 6
1516 + #define RX_PACKET_ATTRIBUTES_RSS_HASH_WIDTH 1
1517 ++#define RX_PACKET_ATTRIBUTES_FIRST_INDEX 7
1518 ++#define RX_PACKET_ATTRIBUTES_FIRST_WIDTH 1
1519 +
1520 + #define RX_NORMAL_DESC0_OVT_INDEX 0
1521 + #define RX_NORMAL_DESC0_OVT_WIDTH 16
1522 +diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
1523 +index 937f37a5dcb2..24a687ce4388 100644
1524 +--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
1525 ++++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
1526 +@@ -1896,10 +1896,15 @@ static int xgbe_dev_read(struct xgbe_channel *channel)
1527 +
1528 + /* Get the header length */
1529 + if (XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, FD)) {
1530 ++ XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES,
1531 ++ FIRST, 1);
1532 + rdata->rx.hdr_len = XGMAC_GET_BITS_LE(rdesc->desc2,
1533 + RX_NORMAL_DESC2, HL);
1534 + if (rdata->rx.hdr_len)
1535 + pdata->ext_stats.rx_split_header_packets++;
1536 ++ } else {
1537 ++ XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES,
1538 ++ FIRST, 0);
1539 + }
1540 +
1541 + /* Get the RSS hash */
1542 +@@ -1922,19 +1927,16 @@ static int xgbe_dev_read(struct xgbe_channel *channel)
1543 + }
1544 + }
1545 +
1546 +- /* Get the packet length */
1547 +- rdata->rx.len = XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, PL);
1548 +-
1549 +- if (!XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, LD)) {
1550 +- /* Not all the data has been transferred for this packet */
1551 +- XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES,
1552 +- INCOMPLETE, 1);
1553 ++ /* Not all the data has been transferred for this packet */
1554 ++ if (!XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, LD))
1555 + return 0;
1556 +- }
1557 +
1558 + /* This is the last of the data for this packet */
1559 + XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES,
1560 +- INCOMPLETE, 0);
1561 ++ LAST, 1);
1562 ++
1563 ++ /* Get the packet length */
1564 ++ rdata->rx.len = XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, PL);
1565 +
1566 + /* Set checksum done indicator as appropriate */
1567 + if (netdev->features & NETIF_F_RXCSUM)
1568 +diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
1569 +index 742e5d1b5da4..36fd1a158251 100644
1570 +--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
1571 ++++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
1572 +@@ -1973,13 +1973,12 @@ static struct sk_buff *xgbe_create_skb(struct xgbe_prv_data *pdata,
1573 + {
1574 + struct sk_buff *skb;
1575 + u8 *packet;
1576 +- unsigned int copy_len;
1577 +
1578 + skb = napi_alloc_skb(napi, rdata->rx.hdr.dma_len);
1579 + if (!skb)
1580 + return NULL;
1581 +
1582 +- /* Start with the header buffer which may contain just the header
1583 ++ /* Pull in the header buffer which may contain just the header
1584 + * or the header plus data
1585 + */
1586 + dma_sync_single_range_for_cpu(pdata->dev, rdata->rx.hdr.dma_base,
1587 +@@ -1988,30 +1987,49 @@ static struct sk_buff *xgbe_create_skb(struct xgbe_prv_data *pdata,
1588 +
1589 + packet = page_address(rdata->rx.hdr.pa.pages) +
1590 + rdata->rx.hdr.pa.pages_offset;
1591 +- copy_len = (rdata->rx.hdr_len) ? rdata->rx.hdr_len : len;
1592 +- copy_len = min(rdata->rx.hdr.dma_len, copy_len);
1593 +- skb_copy_to_linear_data(skb, packet, copy_len);
1594 +- skb_put(skb, copy_len);
1595 +-
1596 +- len -= copy_len;
1597 +- if (len) {
1598 +- /* Add the remaining data as a frag */
1599 +- dma_sync_single_range_for_cpu(pdata->dev,
1600 +- rdata->rx.buf.dma_base,
1601 +- rdata->rx.buf.dma_off,
1602 +- rdata->rx.buf.dma_len,
1603 +- DMA_FROM_DEVICE);
1604 +-
1605 +- skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
1606 +- rdata->rx.buf.pa.pages,
1607 +- rdata->rx.buf.pa.pages_offset,
1608 +- len, rdata->rx.buf.dma_len);
1609 +- rdata->rx.buf.pa.pages = NULL;
1610 +- }
1611 ++ skb_copy_to_linear_data(skb, packet, len);
1612 ++ skb_put(skb, len);
1613 +
1614 + return skb;
1615 + }
1616 +
1617 ++static unsigned int xgbe_rx_buf1_len(struct xgbe_ring_data *rdata,
1618 ++ struct xgbe_packet_data *packet)
1619 ++{
1620 ++ /* Always zero if not the first descriptor */
1621 ++ if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, FIRST))
1622 ++ return 0;
1623 ++
1624 ++ /* First descriptor with split header, return header length */
1625 ++ if (rdata->rx.hdr_len)
1626 ++ return rdata->rx.hdr_len;
1627 ++
1628 ++ /* First descriptor but not the last descriptor and no split header,
1629 ++ * so the full buffer was used
1630 ++ */
1631 ++ if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, LAST))
1632 ++ return rdata->rx.hdr.dma_len;
1633 ++
1634 ++ /* First descriptor and last descriptor and no split header, so
1635 ++ * calculate how much of the buffer was used
1636 ++ */
1637 ++ return min_t(unsigned int, rdata->rx.hdr.dma_len, rdata->rx.len);
1638 ++}
1639 ++
1640 ++static unsigned int xgbe_rx_buf2_len(struct xgbe_ring_data *rdata,
1641 ++ struct xgbe_packet_data *packet,
1642 ++ unsigned int len)
1643 ++{
1644 ++ /* Always the full buffer if not the last descriptor */
1645 ++ if (!XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, LAST))
1646 ++ return rdata->rx.buf.dma_len;
1647 ++
1648 ++ /* Last descriptor so calculate how much of the buffer was used
1649 ++ * for the last bit of data
1650 ++ */
1651 ++ return rdata->rx.len - len;
1652 ++}
1653 ++
1654 + static int xgbe_tx_poll(struct xgbe_channel *channel)
1655 + {
1656 + struct xgbe_prv_data *pdata = channel->pdata;
1657 +@@ -2094,8 +2112,8 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
1658 + struct napi_struct *napi;
1659 + struct sk_buff *skb;
1660 + struct skb_shared_hwtstamps *hwtstamps;
1661 +- unsigned int incomplete, error, context_next, context;
1662 +- unsigned int len, rdesc_len, max_len;
1663 ++ unsigned int last, error, context_next, context;
1664 ++ unsigned int len, buf1_len, buf2_len, max_len;
1665 + unsigned int received = 0;
1666 + int packet_count = 0;
1667 +
1668 +@@ -2105,7 +2123,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
1669 + if (!ring)
1670 + return 0;
1671 +
1672 +- incomplete = 0;
1673 ++ last = 0;
1674 + context_next = 0;
1675 +
1676 + napi = (pdata->per_channel_irq) ? &channel->napi : &pdata->napi;
1677 +@@ -2139,9 +2157,8 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
1678 + received++;
1679 + ring->cur++;
1680 +
1681 +- incomplete = XGMAC_GET_BITS(packet->attributes,
1682 +- RX_PACKET_ATTRIBUTES,
1683 +- INCOMPLETE);
1684 ++ last = XGMAC_GET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES,
1685 ++ LAST);
1686 + context_next = XGMAC_GET_BITS(packet->attributes,
1687 + RX_PACKET_ATTRIBUTES,
1688 + CONTEXT_NEXT);
1689 +@@ -2150,7 +2167,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
1690 + CONTEXT);
1691 +
1692 + /* Earlier error, just drain the remaining data */
1693 +- if ((incomplete || context_next) && error)
1694 ++ if ((!last || context_next) && error)
1695 + goto read_again;
1696 +
1697 + if (error || packet->errors) {
1698 +@@ -2162,16 +2179,22 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
1699 + }
1700 +
1701 + if (!context) {
1702 +- /* Length is cumulative, get this descriptor's length */
1703 +- rdesc_len = rdata->rx.len - len;
1704 +- len += rdesc_len;
1705 ++ /* Get the data length in the descriptor buffers */
1706 ++ buf1_len = xgbe_rx_buf1_len(rdata, packet);
1707 ++ len += buf1_len;
1708 ++ buf2_len = xgbe_rx_buf2_len(rdata, packet, len);
1709 ++ len += buf2_len;
1710 +
1711 +- if (rdesc_len && !skb) {
1712 ++ if (!skb) {
1713 + skb = xgbe_create_skb(pdata, napi, rdata,
1714 +- rdesc_len);
1715 +- if (!skb)
1716 ++ buf1_len);
1717 ++ if (!skb) {
1718 + error = 1;
1719 +- } else if (rdesc_len) {
1720 ++ goto skip_data;
1721 ++ }
1722 ++ }
1723 ++
1724 ++ if (buf2_len) {
1725 + dma_sync_single_range_for_cpu(pdata->dev,
1726 + rdata->rx.buf.dma_base,
1727 + rdata->rx.buf.dma_off,
1728 +@@ -2181,13 +2204,14 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
1729 + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
1730 + rdata->rx.buf.pa.pages,
1731 + rdata->rx.buf.pa.pages_offset,
1732 +- rdesc_len,
1733 ++ buf2_len,
1734 + rdata->rx.buf.dma_len);
1735 + rdata->rx.buf.pa.pages = NULL;
1736 + }
1737 + }
1738 +
1739 +- if (incomplete || context_next)
1740 ++skip_data:
1741 ++ if (!last || context_next)
1742 + goto read_again;
1743 +
1744 + if (!skb)
1745 +@@ -2245,7 +2269,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
1746 + }
1747 +
1748 + /* Check if we need to save state before leaving */
1749 +- if (received && (incomplete || context_next)) {
1750 ++ if (received && (!last || context_next)) {
1751 + rdata = XGBE_GET_DESC_DATA(ring, ring->cur);
1752 + rdata->state_saved = 1;
1753 + rdata->state.skb = skb;
1754 +diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
1755 +index f92896835d2a..3789bed26716 100644
1756 +--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
1757 ++++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
1758 +@@ -3395,7 +3395,8 @@ static int bcmgenet_suspend(struct device *d)
1759 +
1760 + bcmgenet_netif_stop(dev);
1761 +
1762 +- phy_suspend(priv->phydev);
1763 ++ if (!device_may_wakeup(d))
1764 ++ phy_suspend(priv->phydev);
1765 +
1766 + netif_device_detach(dev);
1767 +
1768 +@@ -3492,7 +3493,8 @@ static int bcmgenet_resume(struct device *d)
1769 +
1770 + netif_device_attach(dev);
1771 +
1772 +- phy_resume(priv->phydev);
1773 ++ if (!device_may_wakeup(d))
1774 ++ phy_resume(priv->phydev);
1775 +
1776 + if (priv->eee.eee_enabled)
1777 + bcmgenet_eee_enable_set(dev, true);
1778 +diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
1779 +index e87607621e62..2f9281936f0e 100644
1780 +--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
1781 ++++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
1782 +@@ -220,20 +220,6 @@ void bcmgenet_phy_power_set(struct net_device *dev, bool enable)
1783 + udelay(60);
1784 + }
1785 +
1786 +-static void bcmgenet_internal_phy_setup(struct net_device *dev)
1787 +-{
1788 +- struct bcmgenet_priv *priv = netdev_priv(dev);
1789 +- u32 reg;
1790 +-
1791 +- /* Power up PHY */
1792 +- bcmgenet_phy_power_set(dev, true);
1793 +- /* enable APD */
1794 +- reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT);
1795 +- reg |= EXT_PWR_DN_EN_LD;
1796 +- bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
1797 +- bcmgenet_mii_reset(dev);
1798 +-}
1799 +-
1800 + static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv)
1801 + {
1802 + u32 reg;
1803 +@@ -281,7 +267,6 @@ int bcmgenet_mii_config(struct net_device *dev)
1804 +
1805 + if (priv->internal_phy) {
1806 + phy_name = "internal PHY";
1807 +- bcmgenet_internal_phy_setup(dev);
1808 + } else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
1809 + phy_name = "MoCA";
1810 + bcmgenet_moca_phy_setup(priv);
1811 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
1812 +index caa837e5e2b9..a380353a78c2 100644
1813 +--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
1814 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
1815 +@@ -361,6 +361,8 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,
1816 + case MLX5_CMD_OP_QUERY_VPORT_COUNTER:
1817 + case MLX5_CMD_OP_ALLOC_Q_COUNTER:
1818 + case MLX5_CMD_OP_QUERY_Q_COUNTER:
1819 ++ case MLX5_CMD_OP_SET_RATE_LIMIT:
1820 ++ case MLX5_CMD_OP_QUERY_RATE_LIMIT:
1821 + case MLX5_CMD_OP_ALLOC_PD:
1822 + case MLX5_CMD_OP_ALLOC_UAR:
1823 + case MLX5_CMD_OP_CONFIG_INT_MODERATION:
1824 +@@ -497,6 +499,8 @@ const char *mlx5_command_str(int command)
1825 + MLX5_COMMAND_STR_CASE(ALLOC_Q_COUNTER);
1826 + MLX5_COMMAND_STR_CASE(DEALLOC_Q_COUNTER);
1827 + MLX5_COMMAND_STR_CASE(QUERY_Q_COUNTER);
1828 ++ MLX5_COMMAND_STR_CASE(SET_RATE_LIMIT);
1829 ++ MLX5_COMMAND_STR_CASE(QUERY_RATE_LIMIT);
1830 + MLX5_COMMAND_STR_CASE(ALLOC_PD);
1831 + MLX5_COMMAND_STR_CASE(DEALLOC_PD);
1832 + MLX5_COMMAND_STR_CASE(ALLOC_UAR);
1833 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
1834 +index c69a1f827b65..41db47050991 100644
1835 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
1836 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
1837 +@@ -921,10 +921,6 @@ void mlx5e_destroy_netdev(struct mlx5_core_dev *mdev, struct mlx5e_priv *priv);
1838 + int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev);
1839 + void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev);
1840 + u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout);
1841 +-void mlx5e_add_vxlan_port(struct net_device *netdev,
1842 +- struct udp_tunnel_info *ti);
1843 +-void mlx5e_del_vxlan_port(struct net_device *netdev,
1844 +- struct udp_tunnel_info *ti);
1845 +
1846 + int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev,
1847 + void *sp);
1848 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
1849 +index 9d9c64927372..a501d823e87d 100644
1850 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
1851 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
1852 +@@ -3055,8 +3055,8 @@ static int mlx5e_get_vf_stats(struct net_device *dev,
1853 + vf_stats);
1854 + }
1855 +
1856 +-void mlx5e_add_vxlan_port(struct net_device *netdev,
1857 +- struct udp_tunnel_info *ti)
1858 ++static void mlx5e_add_vxlan_port(struct net_device *netdev,
1859 ++ struct udp_tunnel_info *ti)
1860 + {
1861 + struct mlx5e_priv *priv = netdev_priv(netdev);
1862 +
1863 +@@ -3069,8 +3069,8 @@ void mlx5e_add_vxlan_port(struct net_device *netdev,
1864 + mlx5e_vxlan_queue_work(priv, ti->sa_family, be16_to_cpu(ti->port), 1);
1865 + }
1866 +
1867 +-void mlx5e_del_vxlan_port(struct net_device *netdev,
1868 +- struct udp_tunnel_info *ti)
1869 ++static void mlx5e_del_vxlan_port(struct net_device *netdev,
1870 ++ struct udp_tunnel_info *ti)
1871 + {
1872 + struct mlx5e_priv *priv = netdev_priv(netdev);
1873 +
1874 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
1875 +index 850378893b25..871ff3b51293 100644
1876 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
1877 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
1878 +@@ -394,8 +394,6 @@ static const struct net_device_ops mlx5e_netdev_ops_rep = {
1879 + .ndo_get_phys_port_name = mlx5e_rep_get_phys_port_name,
1880 + .ndo_setup_tc = mlx5e_rep_ndo_setup_tc,
1881 + .ndo_get_stats64 = mlx5e_rep_get_stats,
1882 +- .ndo_udp_tunnel_add = mlx5e_add_vxlan_port,
1883 +- .ndo_udp_tunnel_del = mlx5e_del_vxlan_port,
1884 + .ndo_has_offload_stats = mlx5e_has_offload_stats,
1885 + .ndo_get_offload_stats = mlx5e_get_offload_stats,
1886 + };
1887 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
1888 +index e3b88bbb9dcf..b1939a1d4815 100644
1889 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
1890 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
1891 +@@ -603,6 +603,10 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe,
1892 + if (lro_num_seg > 1) {
1893 + mlx5e_lro_update_hdr(skb, cqe, cqe_bcnt);
1894 + skb_shinfo(skb)->gso_size = DIV_ROUND_UP(cqe_bcnt, lro_num_seg);
1895 ++ /* Subtract one since we already counted this as one
1896 ++ * "regular" packet in mlx5e_complete_rx_cqe()
1897 ++ */
1898 ++ rq->stats.packets += lro_num_seg - 1;
1899 + rq->stats.lro_packets++;
1900 + rq->stats.lro_bytes += cqe_bcnt;
1901 + }
1902 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
1903 +index 2ebbe80d8126..cc718814c378 100644
1904 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
1905 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
1906 +@@ -128,6 +128,23 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
1907 + return rule;
1908 + }
1909 +
1910 ++static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
1911 ++ struct mlx5e_tc_flow *flow)
1912 ++{
1913 ++ struct mlx5_fc *counter = NULL;
1914 ++
1915 ++ if (!IS_ERR(flow->rule)) {
1916 ++ counter = mlx5_flow_rule_counter(flow->rule);
1917 ++ mlx5_del_flow_rules(flow->rule);
1918 ++ mlx5_fc_destroy(priv->mdev, counter);
1919 ++ }
1920 ++
1921 ++ if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
1922 ++ mlx5_destroy_flow_table(priv->fs.tc.t);
1923 ++ priv->fs.tc.t = NULL;
1924 ++ }
1925 ++}
1926 ++
1927 + static struct mlx5_flow_handle *
1928 + mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
1929 + struct mlx5_flow_spec *spec,
1930 +@@ -144,7 +161,24 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
1931 + }
1932 +
1933 + static void mlx5e_detach_encap(struct mlx5e_priv *priv,
1934 +- struct mlx5e_tc_flow *flow) {
1935 ++ struct mlx5e_tc_flow *flow);
1936 ++
1937 ++static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
1938 ++ struct mlx5e_tc_flow *flow)
1939 ++{
1940 ++ struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
1941 ++
1942 ++ mlx5_eswitch_del_offloaded_rule(esw, flow->rule, flow->attr);
1943 ++
1944 ++ mlx5_eswitch_del_vlan_action(esw, flow->attr);
1945 ++
1946 ++ if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
1947 ++ mlx5e_detach_encap(priv, flow);
1948 ++}
1949 ++
1950 ++static void mlx5e_detach_encap(struct mlx5e_priv *priv,
1951 ++ struct mlx5e_tc_flow *flow)
1952 ++{
1953 + struct list_head *next = flow->encap.next;
1954 +
1955 + list_del(&flow->encap);
1956 +@@ -169,24 +203,11 @@ static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
1957 + struct mlx5e_tc_flow *flow)
1958 + {
1959 + struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
1960 +- struct mlx5_fc *counter = NULL;
1961 +-
1962 +- if (!IS_ERR(flow->rule)) {
1963 +- counter = mlx5_flow_rule_counter(flow->rule);
1964 +- mlx5_del_flow_rules(flow->rule);
1965 +- mlx5_fc_destroy(priv->mdev, counter);
1966 +- }
1967 +-
1968 +- if (esw && esw->mode == SRIOV_OFFLOADS) {
1969 +- mlx5_eswitch_del_vlan_action(esw, flow->attr);
1970 +- if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
1971 +- mlx5e_detach_encap(priv, flow);
1972 +- }
1973 +
1974 +- if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
1975 +- mlx5_destroy_flow_table(priv->fs.tc.t);
1976 +- priv->fs.tc.t = NULL;
1977 +- }
1978 ++ if (esw && esw->mode == SRIOV_OFFLOADS)
1979 ++ mlx5e_tc_del_fdb_flow(priv, flow);
1980 ++ else
1981 ++ mlx5e_tc_del_nic_flow(priv, flow);
1982 + }
1983 +
1984 + static void parse_vxlan_attr(struct mlx5_flow_spec *spec,
1985 +@@ -243,12 +264,15 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
1986 + skb_flow_dissector_target(f->dissector,
1987 + FLOW_DISSECTOR_KEY_ENC_PORTS,
1988 + f->mask);
1989 ++ struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
1990 ++ struct net_device *up_dev = mlx5_eswitch_get_uplink_netdev(esw);
1991 ++ struct mlx5e_priv *up_priv = netdev_priv(up_dev);
1992 +
1993 + /* Full udp dst port must be given */
1994 + if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst)))
1995 + goto vxlan_match_offload_err;
1996 +
1997 +- if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->dst)) &&
1998 ++ if (mlx5e_vxlan_lookup_port(up_priv, be16_to_cpu(key->dst)) &&
1999 + MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap))
2000 + parse_vxlan_attr(spec, f);
2001 + else {
2002 +@@ -806,6 +830,8 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
2003 + struct mlx5_esw_flow_attr *attr)
2004 + {
2005 + struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
2006 ++ struct net_device *up_dev = mlx5_eswitch_get_uplink_netdev(esw);
2007 ++ struct mlx5e_priv *up_priv = netdev_priv(up_dev);
2008 + unsigned short family = ip_tunnel_info_af(tun_info);
2009 + struct ip_tunnel_key *key = &tun_info->key;
2010 + struct mlx5_encap_info info;
2011 +@@ -828,7 +854,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
2012 + return -EOPNOTSUPP;
2013 + }
2014 +
2015 +- if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->tp_dst)) &&
2016 ++ if (mlx5e_vxlan_lookup_port(up_priv, be16_to_cpu(key->tp_dst)) &&
2017 + MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) {
2018 + info.tp_dst = key->tp_dst;
2019 + info.tun_id = tunnel_id_to_key32(key->tun_id);
2020 +@@ -953,14 +979,16 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
2021 + }
2022 +
2023 + if (is_tcf_vlan(a)) {
2024 +- if (tcf_vlan_action(a) == VLAN_F_POP) {
2025 ++ if (tcf_vlan_action(a) == TCA_VLAN_ACT_POP) {
2026 + attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_POP;
2027 +- } else if (tcf_vlan_action(a) == VLAN_F_PUSH) {
2028 ++ } else if (tcf_vlan_action(a) == TCA_VLAN_ACT_PUSH) {
2029 + if (tcf_vlan_push_proto(a) != htons(ETH_P_8021Q))
2030 + return -EOPNOTSUPP;
2031 +
2032 + attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH;
2033 + attr->vlan = tcf_vlan_push_vid(a);
2034 ++ } else { /* action is TCA_VLAN_ACT_MODIFY */
2035 ++ return -EOPNOTSUPP;
2036 + }
2037 + continue;
2038 + }
2039 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
2040 +index cfb68371c397..574311018e6f 100644
2041 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
2042 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
2043 +@@ -272,15 +272,18 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
2044 + sq->stats.tso_bytes += skb->len - ihs;
2045 + }
2046 +
2047 ++ sq->stats.packets += skb_shinfo(skb)->gso_segs;
2048 + num_bytes = skb->len + (skb_shinfo(skb)->gso_segs - 1) * ihs;
2049 + } else {
2050 + bf = sq->bf_budget &&
2051 + !skb->xmit_more &&
2052 + !skb_shinfo(skb)->nr_frags;
2053 + ihs = mlx5e_get_inline_hdr_size(sq, skb, bf);
2054 ++ sq->stats.packets++;
2055 + num_bytes = max_t(unsigned int, skb->len, ETH_ZLEN);
2056 + }
2057 +
2058 ++ sq->stats.bytes += num_bytes;
2059 + wi->num_bytes = num_bytes;
2060 +
2061 + if (skb_vlan_tag_present(skb)) {
2062 +@@ -377,8 +380,6 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
2063 + if (bf)
2064 + sq->bf_budget--;
2065 +
2066 +- sq->stats.packets++;
2067 +- sq->stats.bytes += num_bytes;
2068 + return NETDEV_TX_OK;
2069 +
2070 + dma_unmap_wqe_err:
2071 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
2072 +index 8661dd3f542c..b5967df1eeaa 100644
2073 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
2074 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
2075 +@@ -201,6 +201,7 @@ struct mlx5_esw_offload {
2076 + struct mlx5_eswitch_rep *vport_reps;
2077 + DECLARE_HASHTABLE(encap_tbl, 8);
2078 + u8 inline_mode;
2079 ++ u64 num_flows;
2080 + };
2081 +
2082 + struct mlx5_eswitch {
2083 +@@ -263,6 +264,11 @@ struct mlx5_flow_handle *
2084 + mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
2085 + struct mlx5_flow_spec *spec,
2086 + struct mlx5_esw_flow_attr *attr);
2087 ++void
2088 ++mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
2089 ++ struct mlx5_flow_handle *rule,
2090 ++ struct mlx5_esw_flow_attr *attr);
2091 ++
2092 + struct mlx5_flow_handle *
2093 + mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, u32 tirn);
2094 +
2095 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
2096 +index 595f7c7383b3..7bce2bdbb79b 100644
2097 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
2098 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
2099 +@@ -93,10 +93,27 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
2100 + spec, &flow_act, dest, i);
2101 + if (IS_ERR(rule))
2102 + mlx5_fc_destroy(esw->dev, counter);
2103 ++ else
2104 ++ esw->offloads.num_flows++;
2105 +
2106 + return rule;
2107 + }
2108 +
2109 ++void
2110 ++mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
2111 ++ struct mlx5_flow_handle *rule,
2112 ++ struct mlx5_esw_flow_attr *attr)
2113 ++{
2114 ++ struct mlx5_fc *counter = NULL;
2115 ++
2116 ++ if (!IS_ERR(rule)) {
2117 ++ counter = mlx5_flow_rule_counter(rule);
2118 ++ mlx5_del_flow_rules(rule);
2119 ++ mlx5_fc_destroy(esw->dev, counter);
2120 ++ esw->offloads.num_flows--;
2121 ++ }
2122 ++}
2123 ++
2124 + static int esw_set_global_vlan_pop(struct mlx5_eswitch *esw, u8 val)
2125 + {
2126 + struct mlx5_eswitch_rep *rep;
2127 +@@ -905,6 +922,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode)
2128 + MLX5_CAP_INLINE_MODE_VPORT_CONTEXT)
2129 + return -EOPNOTSUPP;
2130 +
2131 ++ if (esw->offloads.num_flows > 0) {
2132 ++ esw_warn(dev, "Can't set inline mode when flows are configured\n");
2133 ++ return -EOPNOTSUPP;
2134 ++ }
2135 ++
2136 + err = esw_inline_mode_from_devlink(mode, &mlx5_mode);
2137 + if (err)
2138 + goto out;
2139 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
2140 +index 3c315eb8d270..4aca265d9c14 100644
2141 +--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
2142 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
2143 +@@ -87,7 +87,7 @@ static struct mlx5_profile profile[] = {
2144 + [2] = {
2145 + .mask = MLX5_PROF_MASK_QP_SIZE |
2146 + MLX5_PROF_MASK_MR_CACHE,
2147 +- .log_max_qp = 17,
2148 ++ .log_max_qp = 18,
2149 + .mr_cache[0] = {
2150 + .size = 500,
2151 + .limit = 250
2152 +diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
2153 +index 296c8efd0038..bd0af5974a75 100644
2154 +--- a/drivers/net/ethernet/ti/Kconfig
2155 ++++ b/drivers/net/ethernet/ti/Kconfig
2156 +@@ -76,7 +76,7 @@ config TI_CPSW
2157 + config TI_CPTS
2158 + tristate "TI Common Platform Time Sync (CPTS) Support"
2159 + depends on TI_CPSW || TI_KEYSTONE_NETCP
2160 +- imply PTP_1588_CLOCK
2161 ++ depends on PTP_1588_CLOCK
2162 + ---help---
2163 + This driver supports the Common Platform Time Sync unit of
2164 + the CPSW Ethernet Switch and Keystone 2 1g/10g Switch Subsystem.
2165 +diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
2166 +index 24d5272cdce5..0d519a9582ca 100644
2167 +--- a/drivers/net/usb/qmi_wwan.c
2168 ++++ b/drivers/net/usb/qmi_wwan.c
2169 +@@ -924,6 +924,8 @@ static const struct usb_device_id products[] = {
2170 + {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
2171 + {QMI_FIXED_INTF(0x413c, 0x81b1, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */
2172 + {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */
2173 ++ {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */
2174 ++ {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */
2175 + {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */
2176 + {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */
2177 + {QMI_FIXED_INTF(0x1e0e, 0x9001, 5)}, /* SIMCom 7230E */
2178 +diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
2179 +index 682aac0a2267..921fef275ea4 100644
2180 +--- a/drivers/net/vrf.c
2181 ++++ b/drivers/net/vrf.c
2182 +@@ -462,8 +462,10 @@ static void vrf_rt6_release(struct net_device *dev, struct net_vrf *vrf)
2183 + }
2184 +
2185 + if (rt6_local) {
2186 +- if (rt6_local->rt6i_idev)
2187 ++ if (rt6_local->rt6i_idev) {
2188 + in6_dev_put(rt6_local->rt6i_idev);
2189 ++ rt6_local->rt6i_idev = NULL;
2190 ++ }
2191 +
2192 + dst = &rt6_local->dst;
2193 + dev_put(dst->dev);
2194 +diff --git a/drivers/net/wireless/ath/ath10k/hw.c b/drivers/net/wireless/ath/ath10k/hw.c
2195 +index 33fb26833cd0..d9f37ee4bfdd 100644
2196 +--- a/drivers/net/wireless/ath/ath10k/hw.c
2197 ++++ b/drivers/net/wireless/ath/ath10k/hw.c
2198 +@@ -51,7 +51,7 @@ const struct ath10k_hw_regs qca6174_regs = {
2199 + .rtc_soc_base_address = 0x00000800,
2200 + .rtc_wmac_base_address = 0x00001000,
2201 + .soc_core_base_address = 0x0003a000,
2202 +- .wlan_mac_base_address = 0x00020000,
2203 ++ .wlan_mac_base_address = 0x00010000,
2204 + .ce_wrapper_base_address = 0x00034000,
2205 + .ce0_base_address = 0x00034400,
2206 + .ce1_base_address = 0x00034800,
2207 +diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
2208 +index 4db07da81d8d..6d724c61cc7a 100644
2209 +--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
2210 ++++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
2211 +@@ -2742,6 +2742,21 @@ static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter)
2212 + schedule_work(&pcie_work);
2213 + }
2214 +
2215 ++static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter)
2216 ++{
2217 ++ struct pcie_service_card *card = adapter->card;
2218 ++ const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
2219 ++
2220 ++ if (reg->sleep_cookie)
2221 ++ mwifiex_pcie_delete_sleep_cookie_buf(adapter);
2222 ++
2223 ++ mwifiex_pcie_delete_cmdrsp_buf(adapter);
2224 ++ mwifiex_pcie_delete_evtbd_ring(adapter);
2225 ++ mwifiex_pcie_delete_rxbd_ring(adapter);
2226 ++ mwifiex_pcie_delete_txbd_ring(adapter);
2227 ++ card->cmdrsp_buf = NULL;
2228 ++}
2229 ++
2230 + /*
2231 + * This function initializes the PCI-E host memory space, WCB rings, etc.
2232 + *
2233 +@@ -2853,13 +2868,6 @@ static int mwifiex_pcie_init(struct mwifiex_adapter *adapter)
2234 +
2235 + /*
2236 + * This function cleans up the allocated card buffers.
2237 +- *
2238 +- * The following are freed by this function -
2239 +- * - TXBD ring buffers
2240 +- * - RXBD ring buffers
2241 +- * - Event BD ring buffers
2242 +- * - Command response ring buffer
2243 +- * - Sleep cookie buffer
2244 + */
2245 + static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter)
2246 + {
2247 +@@ -2875,6 +2883,8 @@ static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter)
2248 + "Failed to write driver not-ready signature\n");
2249 + }
2250 +
2251 ++ mwifiex_pcie_free_buffers(adapter);
2252 ++
2253 + if (pdev) {
2254 + pci_iounmap(pdev, card->pci_mmap);
2255 + pci_iounmap(pdev, card->pci_mmap1);
2256 +@@ -3115,10 +3125,7 @@ static void mwifiex_pcie_up_dev(struct mwifiex_adapter *adapter)
2257 + pci_iounmap(pdev, card->pci_mmap1);
2258 + }
2259 +
2260 +-/* This function cleans up the PCI-E host memory space.
2261 +- * Some code is extracted from mwifiex_unregister_dev()
2262 +- *
2263 +- */
2264 ++/* This function cleans up the PCI-E host memory space. */
2265 + static void mwifiex_pcie_down_dev(struct mwifiex_adapter *adapter)
2266 + {
2267 + struct pcie_service_card *card = adapter->card;
2268 +@@ -3130,14 +3137,7 @@ static void mwifiex_pcie_down_dev(struct mwifiex_adapter *adapter)
2269 + adapter->seq_num = 0;
2270 + adapter->tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K;
2271 +
2272 +- if (reg->sleep_cookie)
2273 +- mwifiex_pcie_delete_sleep_cookie_buf(adapter);
2274 +-
2275 +- mwifiex_pcie_delete_cmdrsp_buf(adapter);
2276 +- mwifiex_pcie_delete_evtbd_ring(adapter);
2277 +- mwifiex_pcie_delete_rxbd_ring(adapter);
2278 +- mwifiex_pcie_delete_txbd_ring(adapter);
2279 +- card->cmdrsp_buf = NULL;
2280 ++ mwifiex_pcie_free_buffers(adapter);
2281 + }
2282 +
2283 + static struct mwifiex_if_ops pcie_ops = {
2284 +diff --git a/drivers/parport/share.c b/drivers/parport/share.c
2285 +index 3308427ed9f7..4399de34054a 100644
2286 +--- a/drivers/parport/share.c
2287 ++++ b/drivers/parport/share.c
2288 +@@ -939,8 +939,10 @@ parport_register_dev_model(struct parport *port, const char *name,
2289 + * pardevice fields. -arca
2290 + */
2291 + port->ops->init_state(par_dev, par_dev->state);
2292 +- port->proc_device = par_dev;
2293 +- parport_device_proc_register(par_dev);
2294 ++ if (!test_and_set_bit(PARPORT_DEVPROC_REGISTERED, &port->devflags)) {
2295 ++ port->proc_device = par_dev;
2296 ++ parport_device_proc_register(par_dev);
2297 ++ }
2298 +
2299 + return par_dev;
2300 +
2301 +diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
2302 +index 245fbe2f1696..6e620242a600 100644
2303 +--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
2304 ++++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
2305 +@@ -4658,7 +4658,6 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
2306 + struct MPT3SAS_DEVICE *sas_device_priv_data;
2307 + u32 response_code = 0;
2308 + unsigned long flags;
2309 +- unsigned int sector_sz;
2310 +
2311 + mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
2312 + scmd = _scsih_scsi_lookup_get_clear(ioc, smid);
2313 +@@ -4717,20 +4716,6 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
2314 + }
2315 +
2316 + xfer_cnt = le32_to_cpu(mpi_reply->TransferCount);
2317 +-
2318 +- /* In case of bogus fw or device, we could end up having
2319 +- * unaligned partial completion. We can force alignment here,
2320 +- * then scsi-ml does not need to handle this misbehavior.
2321 +- */
2322 +- sector_sz = scmd->device->sector_size;
2323 +- if (unlikely(scmd->request->cmd_type == REQ_TYPE_FS && sector_sz &&
2324 +- xfer_cnt % sector_sz)) {
2325 +- sdev_printk(KERN_INFO, scmd->device,
2326 +- "unaligned partial completion avoided (xfer_cnt=%u, sector_sz=%u)\n",
2327 +- xfer_cnt, sector_sz);
2328 +- xfer_cnt = round_down(xfer_cnt, sector_sz);
2329 +- }
2330 +-
2331 + scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt);
2332 + if (ioc_status & MPI2_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE)
2333 + log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
2334 +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
2335 +index 1f5d92a25a49..1ee57619c95e 100644
2336 +--- a/drivers/scsi/sd.c
2337 ++++ b/drivers/scsi/sd.c
2338 +@@ -1790,6 +1790,8 @@ static int sd_done(struct scsi_cmnd *SCpnt)
2339 + {
2340 + int result = SCpnt->result;
2341 + unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt);
2342 ++ unsigned int sector_size = SCpnt->device->sector_size;
2343 ++ unsigned int resid;
2344 + struct scsi_sense_hdr sshdr;
2345 + struct scsi_disk *sdkp = scsi_disk(SCpnt->request->rq_disk);
2346 + struct request *req = SCpnt->request;
2347 +@@ -1820,6 +1822,21 @@ static int sd_done(struct scsi_cmnd *SCpnt)
2348 + scsi_set_resid(SCpnt, blk_rq_bytes(req));
2349 + }
2350 + break;
2351 ++ default:
2352 ++ /*
2353 ++ * In case of bogus fw or device, we could end up having
2354 ++ * an unaligned partial completion. Check this here and force
2355 ++ * alignment.
2356 ++ */
2357 ++ resid = scsi_get_resid(SCpnt);
2358 ++ if (resid & (sector_size - 1)) {
2359 ++ sd_printk(KERN_INFO, sdkp,
2360 ++ "Unaligned partial completion (resid=%u, sector_sz=%u)\n",
2361 ++ resid, sector_size);
2362 ++ resid = min(scsi_bufflen(SCpnt),
2363 ++ round_up(resid, sector_size));
2364 ++ scsi_set_resid(SCpnt, resid);
2365 ++ }
2366 + }
2367 +
2368 + if (result) {
2369 +diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
2370 +index f03692ec5520..8fb309a0ff6b 100644
2371 +--- a/drivers/usb/class/usbtmc.c
2372 ++++ b/drivers/usb/class/usbtmc.c
2373 +@@ -1381,7 +1381,7 @@ static int usbtmc_probe(struct usb_interface *intf,
2374 +
2375 + dev_dbg(&intf->dev, "%s called\n", __func__);
2376 +
2377 +- data = kmalloc(sizeof(*data), GFP_KERNEL);
2378 ++ data = kzalloc(sizeof(*data), GFP_KERNEL);
2379 + if (!data)
2380 + return -ENOMEM;
2381 +
2382 +@@ -1444,6 +1444,13 @@ static int usbtmc_probe(struct usb_interface *intf,
2383 + break;
2384 + }
2385 + }
2386 ++
2387 ++ if (!data->bulk_out || !data->bulk_in) {
2388 ++ dev_err(&intf->dev, "bulk endpoints not found\n");
2389 ++ retcode = -ENODEV;
2390 ++ goto err_put;
2391 ++ }
2392 ++
2393 + /* Find int endpoint */
2394 + for (n = 0; n < iface_desc->desc.bNumEndpoints; n++) {
2395 + endpoint = &iface_desc->endpoint[n].desc;
2396 +@@ -1469,8 +1476,10 @@ static int usbtmc_probe(struct usb_interface *intf,
2397 + if (data->iin_ep_present) {
2398 + /* allocate int urb */
2399 + data->iin_urb = usb_alloc_urb(0, GFP_KERNEL);
2400 +- if (!data->iin_urb)
2401 ++ if (!data->iin_urb) {
2402 ++ retcode = -ENOMEM;
2403 + goto error_register;
2404 ++ }
2405 +
2406 + /* Protect interrupt in endpoint data until iin_urb is freed */
2407 + kref_get(&data->kref);
2408 +@@ -1478,8 +1487,10 @@ static int usbtmc_probe(struct usb_interface *intf,
2409 + /* allocate buffer for interrupt in */
2410 + data->iin_buffer = kmalloc(data->iin_wMaxPacketSize,
2411 + GFP_KERNEL);
2412 +- if (!data->iin_buffer)
2413 ++ if (!data->iin_buffer) {
2414 ++ retcode = -ENOMEM;
2415 + goto error_register;
2416 ++ }
2417 +
2418 + /* fill interrupt urb */
2419 + usb_fill_int_urb(data->iin_urb, data->usb_dev,
2420 +@@ -1512,6 +1523,7 @@ static int usbtmc_probe(struct usb_interface *intf,
2421 + sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp);
2422 + sysfs_remove_group(&intf->dev.kobj, &data_attr_grp);
2423 + usbtmc_free_int(data);
2424 ++err_put:
2425 + kref_put(&data->kref, usbtmc_delete);
2426 + return retcode;
2427 + }
2428 +diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
2429 +index 25dbd8c7aec7..4be52c602e9b 100644
2430 +--- a/drivers/usb/core/config.c
2431 ++++ b/drivers/usb/core/config.c
2432 +@@ -280,6 +280,16 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
2433 +
2434 + /*
2435 + * Adjust bInterval for quirked devices.
2436 ++ */
2437 ++ /*
2438 ++ * This quirk fixes bIntervals reported in ms.
2439 ++ */
2440 ++ if (to_usb_device(ddev)->quirks &
2441 ++ USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL) {
2442 ++ n = clamp(fls(d->bInterval) + 3, i, j);
2443 ++ i = j = n;
2444 ++ }
2445 ++ /*
2446 + * This quirk fixes bIntervals reported in
2447 + * linear microframes.
2448 + */
2449 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
2450 +index a56c75e09786..48fbf523d186 100644
2451 +--- a/drivers/usb/core/hub.c
2452 ++++ b/drivers/usb/core/hub.c
2453 +@@ -4275,7 +4275,7 @@ static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev)
2454 + struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent);
2455 + int connect_type = USB_PORT_CONNECT_TYPE_UNKNOWN;
2456 +
2457 +- if (!udev->usb2_hw_lpm_capable)
2458 ++ if (!udev->usb2_hw_lpm_capable || !udev->bos)
2459 + return;
2460 +
2461 + if (hub)
2462 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
2463 +index 24f9f98968a5..96b21b0dac1e 100644
2464 +--- a/drivers/usb/core/quirks.c
2465 ++++ b/drivers/usb/core/quirks.c
2466 +@@ -170,6 +170,14 @@ static const struct usb_device_id usb_quirk_list[] = {
2467 + /* M-Systems Flash Disk Pioneers */
2468 + { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
2469 +
2470 ++ /* Baum Vario Ultra */
2471 ++ { USB_DEVICE(0x0904, 0x6101), .driver_info =
2472 ++ USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
2473 ++ { USB_DEVICE(0x0904, 0x6102), .driver_info =
2474 ++ USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
2475 ++ { USB_DEVICE(0x0904, 0x6103), .driver_info =
2476 ++ USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
2477 ++
2478 + /* Keytouch QWERTY Panel keyboard */
2479 + { USB_DEVICE(0x0926, 0x3333), .driver_info =
2480 + USB_QUIRK_CONFIG_INTF_STRINGS },
2481 +diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
2482 +index a30766ca4226..5e3828d9dac7 100644
2483 +--- a/drivers/usb/gadget/function/f_acm.c
2484 ++++ b/drivers/usb/gadget/function/f_acm.c
2485 +@@ -535,13 +535,15 @@ static int acm_notify_serial_state(struct f_acm *acm)
2486 + {
2487 + struct usb_composite_dev *cdev = acm->port.func.config->cdev;
2488 + int status;
2489 ++ __le16 serial_state;
2490 +
2491 + spin_lock(&acm->lock);
2492 + if (acm->notify_req) {
2493 + dev_dbg(&cdev->gadget->dev, "acm ttyGS%d serial state %04x\n",
2494 + acm->port_num, acm->serial_state);
2495 ++ serial_state = cpu_to_le16(acm->serial_state);
2496 + status = acm_cdc_notify(acm, USB_CDC_NOTIFY_SERIAL_STATE,
2497 +- 0, &acm->serial_state, sizeof(acm->serial_state));
2498 ++ 0, &serial_state, sizeof(acm->serial_state));
2499 + } else {
2500 + acm->pending = true;
2501 + status = 0;
2502 +diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
2503 +index 29b41b5dee04..c7689d05356c 100644
2504 +--- a/drivers/usb/gadget/function/f_uvc.c
2505 ++++ b/drivers/usb/gadget/function/f_uvc.c
2506 +@@ -625,7 +625,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
2507 + uvc_ss_streaming_comp.bMaxBurst = opts->streaming_maxburst;
2508 + uvc_ss_streaming_comp.wBytesPerInterval =
2509 + cpu_to_le16(max_packet_size * max_packet_mult *
2510 +- opts->streaming_maxburst);
2511 ++ (opts->streaming_maxburst + 1));
2512 +
2513 + /* Allocate endpoints. */
2514 + ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep);
2515 +diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
2516 +index debc1fd74b0d..dc9328fd8030 100644
2517 +--- a/drivers/usb/misc/idmouse.c
2518 ++++ b/drivers/usb/misc/idmouse.c
2519 +@@ -346,6 +346,9 @@ static int idmouse_probe(struct usb_interface *interface,
2520 + if (iface_desc->desc.bInterfaceClass != 0x0A)
2521 + return -ENODEV;
2522 +
2523 ++ if (iface_desc->desc.bNumEndpoints < 1)
2524 ++ return -ENODEV;
2525 ++
2526 + /* allocate memory for our device state and initialize it */
2527 + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
2528 + if (dev == NULL)
2529 +diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c
2530 +index 77176511658f..d3d124753266 100644
2531 +--- a/drivers/usb/misc/lvstest.c
2532 ++++ b/drivers/usb/misc/lvstest.c
2533 +@@ -366,6 +366,10 @@ static int lvs_rh_probe(struct usb_interface *intf,
2534 +
2535 + hdev = interface_to_usbdev(intf);
2536 + desc = intf->cur_altsetting;
2537 ++
2538 ++ if (desc->desc.bNumEndpoints < 1)
2539 ++ return -ENODEV;
2540 ++
2541 + endpoint = &desc->endpoint[0].desc;
2542 +
2543 + /* valid only for SS root hub */
2544 +diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
2545 +index 356d312add57..9ff66525924e 100644
2546 +--- a/drivers/usb/misc/uss720.c
2547 ++++ b/drivers/usb/misc/uss720.c
2548 +@@ -708,6 +708,11 @@ static int uss720_probe(struct usb_interface *intf,
2549 +
2550 + interface = intf->cur_altsetting;
2551 +
2552 ++ if (interface->desc.bNumEndpoints < 3) {
2553 ++ usb_put_dev(usbdev);
2554 ++ return -ENODEV;
2555 ++ }
2556 ++
2557 + /*
2558 + * Allocate parport interface
2559 + */
2560 +diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
2561 +index 16363852c034..cac3b21a720b 100644
2562 +--- a/drivers/usb/musb/musb_cppi41.c
2563 ++++ b/drivers/usb/musb/musb_cppi41.c
2564 +@@ -231,8 +231,27 @@ static void cppi41_dma_callback(void *private_data)
2565 + transferred < cppi41_channel->packet_sz)
2566 + cppi41_channel->prog_len = 0;
2567 +
2568 +- if (cppi41_channel->is_tx)
2569 +- empty = musb_is_tx_fifo_empty(hw_ep);
2570 ++ if (cppi41_channel->is_tx) {
2571 ++ u8 type;
2572 ++
2573 ++ if (is_host_active(musb))
2574 ++ type = hw_ep->out_qh->type;
2575 ++ else
2576 ++ type = hw_ep->ep_in.type;
2577 ++
2578 ++ if (type == USB_ENDPOINT_XFER_ISOC)
2579 ++ /*
2580 ++ * Don't use the early-TX-interrupt workaround below
2581 ++ * for Isoch transfter. Since Isoch are periodic
2582 ++ * transfer, by the time the next transfer is
2583 ++ * scheduled, the current one should be done already.
2584 ++ *
2585 ++ * This avoids audio playback underrun issue.
2586 ++ */
2587 ++ empty = true;
2588 ++ else
2589 ++ empty = musb_is_tx_fifo_empty(hw_ep);
2590 ++ }
2591 +
2592 + if (!cppi41_channel->is_tx || empty) {
2593 + cppi41_trans_done(cppi41_channel);
2594 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
2595 +index 42cc72e54c05..af67a0de6b5d 100644
2596 +--- a/drivers/usb/serial/option.c
2597 ++++ b/drivers/usb/serial/option.c
2598 +@@ -233,6 +233,14 @@ static void option_instat_callback(struct urb *urb);
2599 + #define BANDRICH_PRODUCT_1012 0x1012
2600 +
2601 + #define QUALCOMM_VENDOR_ID 0x05C6
2602 ++/* These Quectel products use Qualcomm's vendor ID */
2603 ++#define QUECTEL_PRODUCT_UC20 0x9003
2604 ++#define QUECTEL_PRODUCT_UC15 0x9090
2605 ++
2606 ++#define QUECTEL_VENDOR_ID 0x2c7c
2607 ++/* These Quectel products use Quectel's vendor ID */
2608 ++#define QUECTEL_PRODUCT_EC21 0x0121
2609 ++#define QUECTEL_PRODUCT_EC25 0x0125
2610 +
2611 + #define CMOTECH_VENDOR_ID 0x16d8
2612 + #define CMOTECH_PRODUCT_6001 0x6001
2613 +@@ -1161,7 +1169,14 @@ static const struct usb_device_id option_ids[] = {
2614 + { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
2615 + { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
2616 + { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
2617 +- { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9003), /* Quectel UC20 */
2618 ++ /* Quectel products using Qualcomm vendor ID */
2619 ++ { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC15)},
2620 ++ { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC20),
2621 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2622 ++ /* Quectel products using Quectel vendor ID */
2623 ++ { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21),
2624 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2625 ++ { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25),
2626 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2627 + { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
2628 + { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
2629 +diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
2630 +index 696458db7e3c..38b3f0d8cd58 100644
2631 +--- a/drivers/usb/serial/qcserial.c
2632 ++++ b/drivers/usb/serial/qcserial.c
2633 +@@ -169,6 +169,8 @@ static const struct usb_device_id id_table[] = {
2634 + {DEVICE_SWI(0x413c, 0x81a9)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
2635 + {DEVICE_SWI(0x413c, 0x81b1)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */
2636 + {DEVICE_SWI(0x413c, 0x81b3)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */
2637 ++ {DEVICE_SWI(0x413c, 0x81b5)}, /* Dell Wireless 5811e QDL */
2638 ++ {DEVICE_SWI(0x413c, 0x81b6)}, /* Dell Wireless 5811e QDL */
2639 +
2640 + /* Huawei devices */
2641 + {DEVICE_HWI(0x03f0, 0x581d)}, /* HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e) */
2642 +diff --git a/drivers/usb/wusbcore/wa-hc.c b/drivers/usb/wusbcore/wa-hc.c
2643 +index 252c7bd9218a..d01496fd27fe 100644
2644 +--- a/drivers/usb/wusbcore/wa-hc.c
2645 ++++ b/drivers/usb/wusbcore/wa-hc.c
2646 +@@ -39,6 +39,9 @@ int wa_create(struct wahc *wa, struct usb_interface *iface,
2647 + int result;
2648 + struct device *dev = &iface->dev;
2649 +
2650 ++ if (iface->cur_altsetting->desc.bNumEndpoints < 3)
2651 ++ return -ENODEV;
2652 ++
2653 + result = wa_rpipes_create(wa);
2654 + if (result < 0)
2655 + goto error_rpipes_create;
2656 +diff --git a/drivers/uwb/hwa-rc.c b/drivers/uwb/hwa-rc.c
2657 +index 0aa6c3c29d17..35a1e777b449 100644
2658 +--- a/drivers/uwb/hwa-rc.c
2659 ++++ b/drivers/uwb/hwa-rc.c
2660 +@@ -823,6 +823,9 @@ static int hwarc_probe(struct usb_interface *iface,
2661 + struct hwarc *hwarc;
2662 + struct device *dev = &iface->dev;
2663 +
2664 ++ if (iface->cur_altsetting->desc.bNumEndpoints < 1)
2665 ++ return -ENODEV;
2666 ++
2667 + result = -ENOMEM;
2668 + uwb_rc = uwb_rc_alloc();
2669 + if (uwb_rc == NULL) {
2670 +diff --git a/drivers/uwb/i1480/dfu/usb.c b/drivers/uwb/i1480/dfu/usb.c
2671 +index 2bfc846ac071..6345e85822a4 100644
2672 +--- a/drivers/uwb/i1480/dfu/usb.c
2673 ++++ b/drivers/uwb/i1480/dfu/usb.c
2674 +@@ -362,6 +362,9 @@ int i1480_usb_probe(struct usb_interface *iface, const struct usb_device_id *id)
2675 + result);
2676 + }
2677 +
2678 ++ if (iface->cur_altsetting->desc.bNumEndpoints < 1)
2679 ++ return -ENODEV;
2680 ++
2681 + result = -ENOMEM;
2682 + i1480_usb = kzalloc(sizeof(*i1480_usb), GFP_KERNEL);
2683 + if (i1480_usb == NULL) {
2684 +diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
2685 +index 9901c4671e2f..6e10325596b6 100644
2686 +--- a/drivers/vfio/vfio.c
2687 ++++ b/drivers/vfio/vfio.c
2688 +@@ -403,6 +403,7 @@ static void vfio_group_release(struct kref *kref)
2689 + struct iommu_group *iommu_group = group->iommu_group;
2690 +
2691 + WARN_ON(!list_empty(&group->device_list));
2692 ++ WARN_ON(group->notifier.head);
2693 +
2694 + list_for_each_entry_safe(unbound, tmp,
2695 + &group->unbound_list, unbound_next) {
2696 +@@ -1573,6 +1574,10 @@ static int vfio_group_fops_open(struct inode *inode, struct file *filep)
2697 + return -EBUSY;
2698 + }
2699 +
2700 ++ /* Warn if previous user didn't cleanup and re-init to drop them */
2701 ++ if (WARN_ON(group->notifier.head))
2702 ++ BLOCKING_INIT_NOTIFIER_HEAD(&group->notifier);
2703 ++
2704 + filep->private_data = group;
2705 +
2706 + return 0;
2707 +@@ -1584,9 +1589,6 @@ static int vfio_group_fops_release(struct inode *inode, struct file *filep)
2708 +
2709 + filep->private_data = NULL;
2710 +
2711 +- /* Any user didn't unregister? */
2712 +- WARN_ON(group->notifier.head);
2713 +-
2714 + vfio_group_try_dissolve_container(group);
2715 +
2716 + atomic_dec(&group->opened);
2717 +diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
2718 +index a44f5627b82a..f4daadff8a6c 100644
2719 +--- a/drivers/video/console/fbcon.c
2720 ++++ b/drivers/video/console/fbcon.c
2721 +@@ -1165,6 +1165,8 @@ static void fbcon_free_font(struct display *p, bool freefont)
2722 + p->userfont = 0;
2723 + }
2724 +
2725 ++static void set_vc_hi_font(struct vc_data *vc, bool set);
2726 ++
2727 + static void fbcon_deinit(struct vc_data *vc)
2728 + {
2729 + struct display *p = &fb_display[vc->vc_num];
2730 +@@ -1200,6 +1202,9 @@ static void fbcon_deinit(struct vc_data *vc)
2731 + if (free_font)
2732 + vc->vc_font.data = NULL;
2733 +
2734 ++ if (vc->vc_hi_font_mask)
2735 ++ set_vc_hi_font(vc, false);
2736 ++
2737 + if (!con_is_bound(&fb_con))
2738 + fbcon_exit();
2739 +
2740 +@@ -2436,32 +2441,10 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font)
2741 + return 0;
2742 + }
2743 +
2744 +-static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2745 +- const u8 * data, int userfont)
2746 ++/* set/clear vc_hi_font_mask and update vc attrs accordingly */
2747 ++static void set_vc_hi_font(struct vc_data *vc, bool set)
2748 + {
2749 +- struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2750 +- struct fbcon_ops *ops = info->fbcon_par;
2751 +- struct display *p = &fb_display[vc->vc_num];
2752 +- int resize;
2753 +- int cnt;
2754 +- char *old_data = NULL;
2755 +-
2756 +- if (con_is_visible(vc) && softback_lines)
2757 +- fbcon_set_origin(vc);
2758 +-
2759 +- resize = (w != vc->vc_font.width) || (h != vc->vc_font.height);
2760 +- if (p->userfont)
2761 +- old_data = vc->vc_font.data;
2762 +- if (userfont)
2763 +- cnt = FNTCHARCNT(data);
2764 +- else
2765 +- cnt = 256;
2766 +- vc->vc_font.data = (void *)(p->fontdata = data);
2767 +- if ((p->userfont = userfont))
2768 +- REFCOUNT(data)++;
2769 +- vc->vc_font.width = w;
2770 +- vc->vc_font.height = h;
2771 +- if (vc->vc_hi_font_mask && cnt == 256) {
2772 ++ if (!set) {
2773 + vc->vc_hi_font_mask = 0;
2774 + if (vc->vc_can_do_color) {
2775 + vc->vc_complement_mask >>= 1;
2776 +@@ -2484,7 +2467,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2777 + ((c & 0xfe00) >> 1) | (c & 0xff);
2778 + vc->vc_attr >>= 1;
2779 + }
2780 +- } else if (!vc->vc_hi_font_mask && cnt == 512) {
2781 ++ } else {
2782 + vc->vc_hi_font_mask = 0x100;
2783 + if (vc->vc_can_do_color) {
2784 + vc->vc_complement_mask <<= 1;
2785 +@@ -2516,8 +2499,38 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2786 + } else
2787 + vc->vc_video_erase_char = c & ~0x100;
2788 + }
2789 +-
2790 + }
2791 ++}
2792 ++
2793 ++static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2794 ++ const u8 * data, int userfont)
2795 ++{
2796 ++ struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2797 ++ struct fbcon_ops *ops = info->fbcon_par;
2798 ++ struct display *p = &fb_display[vc->vc_num];
2799 ++ int resize;
2800 ++ int cnt;
2801 ++ char *old_data = NULL;
2802 ++
2803 ++ if (con_is_visible(vc) && softback_lines)
2804 ++ fbcon_set_origin(vc);
2805 ++
2806 ++ resize = (w != vc->vc_font.width) || (h != vc->vc_font.height);
2807 ++ if (p->userfont)
2808 ++ old_data = vc->vc_font.data;
2809 ++ if (userfont)
2810 ++ cnt = FNTCHARCNT(data);
2811 ++ else
2812 ++ cnt = 256;
2813 ++ vc->vc_font.data = (void *)(p->fontdata = data);
2814 ++ if ((p->userfont = userfont))
2815 ++ REFCOUNT(data)++;
2816 ++ vc->vc_font.width = w;
2817 ++ vc->vc_font.height = h;
2818 ++ if (vc->vc_hi_font_mask && cnt == 256)
2819 ++ set_vc_hi_font(vc, false);
2820 ++ else if (!vc->vc_hi_font_mask && cnt == 512)
2821 ++ set_vc_hi_font(vc, true);
2822 +
2823 + if (resize) {
2824 + int cols, rows;
2825 +diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c
2826 +index 4ce10bcca18b..4b857463a2b4 100644
2827 +--- a/drivers/xen/xen-acpi-processor.c
2828 ++++ b/drivers/xen/xen-acpi-processor.c
2829 +@@ -27,10 +27,10 @@
2830 + #include <linux/init.h>
2831 + #include <linux/module.h>
2832 + #include <linux/types.h>
2833 ++#include <linux/syscore_ops.h>
2834 + #include <linux/acpi.h>
2835 + #include <acpi/processor.h>
2836 + #include <xen/xen.h>
2837 +-#include <xen/xen-ops.h>
2838 + #include <xen/interface/platform.h>
2839 + #include <asm/xen/hypercall.h>
2840 +
2841 +@@ -466,15 +466,33 @@ static int xen_upload_processor_pm_data(void)
2842 + return rc;
2843 + }
2844 +
2845 +-static int xen_acpi_processor_resume(struct notifier_block *nb,
2846 +- unsigned long action, void *data)
2847 ++static void xen_acpi_processor_resume_worker(struct work_struct *dummy)
2848 + {
2849 ++ int rc;
2850 ++
2851 + bitmap_zero(acpi_ids_done, nr_acpi_bits);
2852 +- return xen_upload_processor_pm_data();
2853 ++
2854 ++ rc = xen_upload_processor_pm_data();
2855 ++ if (rc != 0)
2856 ++ pr_info("ACPI data upload failed, error = %d\n", rc);
2857 ++}
2858 ++
2859 ++static void xen_acpi_processor_resume(void)
2860 ++{
2861 ++ static DECLARE_WORK(wq, xen_acpi_processor_resume_worker);
2862 ++
2863 ++ /*
2864 ++ * xen_upload_processor_pm_data() calls non-atomic code.
2865 ++ * However, the context for xen_acpi_processor_resume is syscore
2866 ++ * with only the boot CPU online and in an atomic context.
2867 ++ *
2868 ++ * So defer the upload for some point safer.
2869 ++ */
2870 ++ schedule_work(&wq);
2871 + }
2872 +
2873 +-struct notifier_block xen_acpi_processor_resume_nb = {
2874 +- .notifier_call = xen_acpi_processor_resume,
2875 ++static struct syscore_ops xap_syscore_ops = {
2876 ++ .resume = xen_acpi_processor_resume,
2877 + };
2878 +
2879 + static int __init xen_acpi_processor_init(void)
2880 +@@ -527,7 +545,7 @@ static int __init xen_acpi_processor_init(void)
2881 + if (rc)
2882 + goto err_unregister;
2883 +
2884 +- xen_resume_notifier_register(&xen_acpi_processor_resume_nb);
2885 ++ register_syscore_ops(&xap_syscore_ops);
2886 +
2887 + return 0;
2888 + err_unregister:
2889 +@@ -544,7 +562,7 @@ static void __exit xen_acpi_processor_exit(void)
2890 + {
2891 + int i;
2892 +
2893 +- xen_resume_notifier_unregister(&xen_acpi_processor_resume_nb);
2894 ++ unregister_syscore_ops(&xap_syscore_ops);
2895 + kfree(acpi_ids_done);
2896 + kfree(acpi_id_present);
2897 + kfree(acpi_id_cst_present);
2898 +diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
2899 +index ac8e4f6a3773..3c2ca312c251 100644
2900 +--- a/fs/crypto/crypto.c
2901 ++++ b/fs/crypto/crypto.c
2902 +@@ -394,7 +394,6 @@ EXPORT_SYMBOL(fscrypt_zeroout_range);
2903 + static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags)
2904 + {
2905 + struct dentry *dir;
2906 +- struct fscrypt_info *ci;
2907 + int dir_has_key, cached_with_key;
2908 +
2909 + if (flags & LOOKUP_RCU)
2910 +@@ -406,18 +405,11 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags)
2911 + return 0;
2912 + }
2913 +
2914 +- ci = d_inode(dir)->i_crypt_info;
2915 +- if (ci && ci->ci_keyring_key &&
2916 +- (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) |
2917 +- (1 << KEY_FLAG_REVOKED) |
2918 +- (1 << KEY_FLAG_DEAD))))
2919 +- ci = NULL;
2920 +-
2921 + /* this should eventually be an flag in d_flags */
2922 + spin_lock(&dentry->d_lock);
2923 + cached_with_key = dentry->d_flags & DCACHE_ENCRYPTED_WITH_KEY;
2924 + spin_unlock(&dentry->d_lock);
2925 +- dir_has_key = (ci != NULL);
2926 ++ dir_has_key = (d_inode(dir)->i_crypt_info != NULL);
2927 + dput(dir);
2928 +
2929 + /*
2930 +diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c
2931 +index 56ad9d195f18..8af4d5224bdd 100644
2932 +--- a/fs/crypto/fname.c
2933 ++++ b/fs/crypto/fname.c
2934 +@@ -350,7 +350,7 @@ int fscrypt_setup_filename(struct inode *dir, const struct qstr *iname,
2935 + fname->disk_name.len = iname->len;
2936 + return 0;
2937 + }
2938 +- ret = fscrypt_get_crypt_info(dir);
2939 ++ ret = fscrypt_get_encryption_info(dir);
2940 + if (ret && ret != -EOPNOTSUPP)
2941 + return ret;
2942 +
2943 +diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h
2944 +index aeab032d7d35..b7b9b566bd86 100644
2945 +--- a/fs/crypto/fscrypt_private.h
2946 ++++ b/fs/crypto/fscrypt_private.h
2947 +@@ -67,7 +67,6 @@ struct fscrypt_info {
2948 + u8 ci_filename_mode;
2949 + u8 ci_flags;
2950 + struct crypto_skcipher *ci_ctfm;
2951 +- struct key *ci_keyring_key;
2952 + u8 ci_master_key[FS_KEY_DESCRIPTOR_SIZE];
2953 + };
2954 +
2955 +@@ -87,7 +86,4 @@ struct fscrypt_completion_result {
2956 + /* crypto.c */
2957 + int fscrypt_initialize(unsigned int cop_flags);
2958 +
2959 +-/* keyinfo.c */
2960 +-extern int fscrypt_get_crypt_info(struct inode *);
2961 +-
2962 + #endif /* _FSCRYPT_PRIVATE_H */
2963 +diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
2964 +index 95cd4c3b06c3..6df6ad3af432 100644
2965 +--- a/fs/crypto/keyinfo.c
2966 ++++ b/fs/crypto/keyinfo.c
2967 +@@ -99,6 +99,7 @@ static int validate_user_key(struct fscrypt_info *crypt_info,
2968 + kfree(full_key_descriptor);
2969 + if (IS_ERR(keyring_key))
2970 + return PTR_ERR(keyring_key);
2971 ++ down_read(&keyring_key->sem);
2972 +
2973 + if (keyring_key->type != &key_type_logon) {
2974 + printk_once(KERN_WARNING
2975 +@@ -106,11 +107,9 @@ static int validate_user_key(struct fscrypt_info *crypt_info,
2976 + res = -ENOKEY;
2977 + goto out;
2978 + }
2979 +- down_read(&keyring_key->sem);
2980 + ukp = user_key_payload(keyring_key);
2981 + if (ukp->datalen != sizeof(struct fscrypt_key)) {
2982 + res = -EINVAL;
2983 +- up_read(&keyring_key->sem);
2984 + goto out;
2985 + }
2986 + master_key = (struct fscrypt_key *)ukp->data;
2987 +@@ -121,17 +120,11 @@ static int validate_user_key(struct fscrypt_info *crypt_info,
2988 + "%s: key size incorrect: %d\n",
2989 + __func__, master_key->size);
2990 + res = -ENOKEY;
2991 +- up_read(&keyring_key->sem);
2992 + goto out;
2993 + }
2994 + res = derive_key_aes(ctx->nonce, master_key->raw, raw_key);
2995 +- up_read(&keyring_key->sem);
2996 +- if (res)
2997 +- goto out;
2998 +-
2999 +- crypt_info->ci_keyring_key = keyring_key;
3000 +- return 0;
3001 + out:
3002 ++ up_read(&keyring_key->sem);
3003 + key_put(keyring_key);
3004 + return res;
3005 + }
3006 +@@ -173,12 +166,11 @@ static void put_crypt_info(struct fscrypt_info *ci)
3007 + if (!ci)
3008 + return;
3009 +
3010 +- key_put(ci->ci_keyring_key);
3011 + crypto_free_skcipher(ci->ci_ctfm);
3012 + kmem_cache_free(fscrypt_info_cachep, ci);
3013 + }
3014 +
3015 +-int fscrypt_get_crypt_info(struct inode *inode)
3016 ++int fscrypt_get_encryption_info(struct inode *inode)
3017 + {
3018 + struct fscrypt_info *crypt_info;
3019 + struct fscrypt_context ctx;
3020 +@@ -188,21 +180,15 @@ int fscrypt_get_crypt_info(struct inode *inode)
3021 + u8 *raw_key = NULL;
3022 + int res;
3023 +
3024 ++ if (inode->i_crypt_info)
3025 ++ return 0;
3026 ++
3027 + res = fscrypt_initialize(inode->i_sb->s_cop->flags);
3028 + if (res)
3029 + return res;
3030 +
3031 + if (!inode->i_sb->s_cop->get_context)
3032 + return -EOPNOTSUPP;
3033 +-retry:
3034 +- crypt_info = ACCESS_ONCE(inode->i_crypt_info);
3035 +- if (crypt_info) {
3036 +- if (!crypt_info->ci_keyring_key ||
3037 +- key_validate(crypt_info->ci_keyring_key) == 0)
3038 +- return 0;
3039 +- fscrypt_put_encryption_info(inode, crypt_info);
3040 +- goto retry;
3041 +- }
3042 +
3043 + res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
3044 + if (res < 0) {
3045 +@@ -230,7 +216,6 @@ int fscrypt_get_crypt_info(struct inode *inode)
3046 + crypt_info->ci_data_mode = ctx.contents_encryption_mode;
3047 + crypt_info->ci_filename_mode = ctx.filenames_encryption_mode;
3048 + crypt_info->ci_ctfm = NULL;
3049 +- crypt_info->ci_keyring_key = NULL;
3050 + memcpy(crypt_info->ci_master_key, ctx.master_key_descriptor,
3051 + sizeof(crypt_info->ci_master_key));
3052 +
3053 +@@ -286,14 +271,8 @@ int fscrypt_get_crypt_info(struct inode *inode)
3054 + if (res)
3055 + goto out;
3056 +
3057 +- kzfree(raw_key);
3058 +- raw_key = NULL;
3059 +- if (cmpxchg(&inode->i_crypt_info, NULL, crypt_info) != NULL) {
3060 +- put_crypt_info(crypt_info);
3061 +- goto retry;
3062 +- }
3063 +- return 0;
3064 +-
3065 ++ if (cmpxchg(&inode->i_crypt_info, NULL, crypt_info) == NULL)
3066 ++ crypt_info = NULL;
3067 + out:
3068 + if (res == -ENOKEY)
3069 + res = 0;
3070 +@@ -301,6 +280,7 @@ int fscrypt_get_crypt_info(struct inode *inode)
3071 + kzfree(raw_key);
3072 + return res;
3073 + }
3074 ++EXPORT_SYMBOL(fscrypt_get_encryption_info);
3075 +
3076 + void fscrypt_put_encryption_info(struct inode *inode, struct fscrypt_info *ci)
3077 + {
3078 +@@ -318,17 +298,3 @@ void fscrypt_put_encryption_info(struct inode *inode, struct fscrypt_info *ci)
3079 + put_crypt_info(ci);
3080 + }
3081 + EXPORT_SYMBOL(fscrypt_put_encryption_info);
3082 +-
3083 +-int fscrypt_get_encryption_info(struct inode *inode)
3084 +-{
3085 +- struct fscrypt_info *ci = inode->i_crypt_info;
3086 +-
3087 +- if (!ci ||
3088 +- (ci->ci_keyring_key &&
3089 +- (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) |
3090 +- (1 << KEY_FLAG_REVOKED) |
3091 +- (1 << KEY_FLAG_DEAD)))))
3092 +- return fscrypt_get_crypt_info(inode);
3093 +- return 0;
3094 +-}
3095 +-EXPORT_SYMBOL(fscrypt_get_encryption_info);
3096 +diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
3097 +index 627ace344739..b6a38ecbca00 100644
3098 +--- a/fs/ext4/inline.c
3099 ++++ b/fs/ext4/inline.c
3100 +@@ -1167,10 +1167,9 @@ static int ext4_finish_convert_inline_dir(handle_t *handle,
3101 + set_buffer_uptodate(dir_block);
3102 + err = ext4_handle_dirty_dirent_node(handle, inode, dir_block);
3103 + if (err)
3104 +- goto out;
3105 ++ return err;
3106 + set_buffer_verified(dir_block);
3107 +-out:
3108 +- return err;
3109 ++ return ext4_mark_inode_dirty(handle, inode);
3110 + }
3111 +
3112 + static int ext4_convert_inline_data_nolock(handle_t *handle,
3113 +diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
3114 +index c40bd55b6400..7b5a683defe6 100644
3115 +--- a/fs/ext4/xattr.c
3116 ++++ b/fs/ext4/xattr.c
3117 +@@ -131,31 +131,26 @@ static __le32 ext4_xattr_block_csum(struct inode *inode,
3118 + }
3119 +
3120 + static int ext4_xattr_block_csum_verify(struct inode *inode,
3121 +- sector_t block_nr,
3122 +- struct ext4_xattr_header *hdr)
3123 ++ struct buffer_head *bh)
3124 + {
3125 +- if (ext4_has_metadata_csum(inode->i_sb) &&
3126 +- (hdr->h_checksum != ext4_xattr_block_csum(inode, block_nr, hdr)))
3127 +- return 0;
3128 +- return 1;
3129 +-}
3130 +-
3131 +-static void ext4_xattr_block_csum_set(struct inode *inode,
3132 +- sector_t block_nr,
3133 +- struct ext4_xattr_header *hdr)
3134 +-{
3135 +- if (!ext4_has_metadata_csum(inode->i_sb))
3136 +- return;
3137 ++ struct ext4_xattr_header *hdr = BHDR(bh);
3138 ++ int ret = 1;
3139 +
3140 +- hdr->h_checksum = ext4_xattr_block_csum(inode, block_nr, hdr);
3141 ++ if (ext4_has_metadata_csum(inode->i_sb)) {
3142 ++ lock_buffer(bh);
3143 ++ ret = (hdr->h_checksum == ext4_xattr_block_csum(inode,
3144 ++ bh->b_blocknr, hdr));
3145 ++ unlock_buffer(bh);
3146 ++ }
3147 ++ return ret;
3148 + }
3149 +
3150 +-static inline int ext4_handle_dirty_xattr_block(handle_t *handle,
3151 +- struct inode *inode,
3152 +- struct buffer_head *bh)
3153 ++static void ext4_xattr_block_csum_set(struct inode *inode,
3154 ++ struct buffer_head *bh)
3155 + {
3156 +- ext4_xattr_block_csum_set(inode, bh->b_blocknr, BHDR(bh));
3157 +- return ext4_handle_dirty_metadata(handle, inode, bh);
3158 ++ if (ext4_has_metadata_csum(inode->i_sb))
3159 ++ BHDR(bh)->h_checksum = ext4_xattr_block_csum(inode,
3160 ++ bh->b_blocknr, BHDR(bh));
3161 + }
3162 +
3163 + static inline const struct xattr_handler *
3164 +@@ -233,7 +228,7 @@ ext4_xattr_check_block(struct inode *inode, struct buffer_head *bh)
3165 + if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
3166 + BHDR(bh)->h_blocks != cpu_to_le32(1))
3167 + return -EFSCORRUPTED;
3168 +- if (!ext4_xattr_block_csum_verify(inode, bh->b_blocknr, BHDR(bh)))
3169 ++ if (!ext4_xattr_block_csum_verify(inode, bh))
3170 + return -EFSBADCRC;
3171 + error = ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size,
3172 + bh->b_data);
3173 +@@ -615,23 +610,22 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
3174 + }
3175 + }
3176 +
3177 ++ ext4_xattr_block_csum_set(inode, bh);
3178 + /*
3179 + * Beware of this ugliness: Releasing of xattr block references
3180 + * from different inodes can race and so we have to protect
3181 + * from a race where someone else frees the block (and releases
3182 + * its journal_head) before we are done dirtying the buffer. In
3183 + * nojournal mode this race is harmless and we actually cannot
3184 +- * call ext4_handle_dirty_xattr_block() with locked buffer as
3185 ++ * call ext4_handle_dirty_metadata() with locked buffer as
3186 + * that function can call sync_dirty_buffer() so for that case
3187 + * we handle the dirtying after unlocking the buffer.
3188 + */
3189 + if (ext4_handle_valid(handle))
3190 +- error = ext4_handle_dirty_xattr_block(handle, inode,
3191 +- bh);
3192 ++ error = ext4_handle_dirty_metadata(handle, inode, bh);
3193 + unlock_buffer(bh);
3194 + if (!ext4_handle_valid(handle))
3195 +- error = ext4_handle_dirty_xattr_block(handle, inode,
3196 +- bh);
3197 ++ error = ext4_handle_dirty_metadata(handle, inode, bh);
3198 + if (IS_SYNC(inode))
3199 + ext4_handle_sync(handle);
3200 + dquot_free_block(inode, EXT4_C2B(EXT4_SB(inode->i_sb), 1));
3201 +@@ -860,13 +854,14 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
3202 + ext4_xattr_cache_insert(ext4_mb_cache,
3203 + bs->bh);
3204 + }
3205 ++ ext4_xattr_block_csum_set(inode, bs->bh);
3206 + unlock_buffer(bs->bh);
3207 + if (error == -EFSCORRUPTED)
3208 + goto bad_block;
3209 + if (!error)
3210 +- error = ext4_handle_dirty_xattr_block(handle,
3211 +- inode,
3212 +- bs->bh);
3213 ++ error = ext4_handle_dirty_metadata(handle,
3214 ++ inode,
3215 ++ bs->bh);
3216 + if (error)
3217 + goto cleanup;
3218 + goto inserted;
3219 +@@ -964,10 +959,11 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
3220 + ce->e_reusable = 0;
3221 + ea_bdebug(new_bh, "reusing; refcount now=%d",
3222 + ref);
3223 ++ ext4_xattr_block_csum_set(inode, new_bh);
3224 + unlock_buffer(new_bh);
3225 +- error = ext4_handle_dirty_xattr_block(handle,
3226 +- inode,
3227 +- new_bh);
3228 ++ error = ext4_handle_dirty_metadata(handle,
3229 ++ inode,
3230 ++ new_bh);
3231 + if (error)
3232 + goto cleanup_dquot;
3233 + }
3234 +@@ -1017,11 +1013,12 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
3235 + goto getblk_failed;
3236 + }
3237 + memcpy(new_bh->b_data, s->base, new_bh->b_size);
3238 ++ ext4_xattr_block_csum_set(inode, new_bh);
3239 + set_buffer_uptodate(new_bh);
3240 + unlock_buffer(new_bh);
3241 + ext4_xattr_cache_insert(ext4_mb_cache, new_bh);
3242 +- error = ext4_handle_dirty_xattr_block(handle,
3243 +- inode, new_bh);
3244 ++ error = ext4_handle_dirty_metadata(handle, inode,
3245 ++ new_bh);
3246 + if (error)
3247 + goto cleanup;
3248 + }
3249 +diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
3250 +index a097048ed1a3..bdc3afad4a8c 100644
3251 +--- a/fs/jbd2/journal.c
3252 ++++ b/fs/jbd2/journal.c
3253 +@@ -1125,10 +1125,8 @@ static journal_t *journal_init_common(struct block_device *bdev,
3254 +
3255 + /* Set up a default-sized revoke table for the new mount. */
3256 + err = jbd2_journal_init_revoke(journal, JOURNAL_REVOKE_DEFAULT_HASH);
3257 +- if (err) {
3258 +- kfree(journal);
3259 +- return NULL;
3260 +- }
3261 ++ if (err)
3262 ++ goto err_cleanup;
3263 +
3264 + spin_lock_init(&journal->j_history_lock);
3265 +
3266 +@@ -1145,23 +1143,25 @@ static journal_t *journal_init_common(struct block_device *bdev,
3267 + journal->j_wbufsize = n;
3268 + journal->j_wbuf = kmalloc_array(n, sizeof(struct buffer_head *),
3269 + GFP_KERNEL);
3270 +- if (!journal->j_wbuf) {
3271 +- kfree(journal);
3272 +- return NULL;
3273 +- }
3274 ++ if (!journal->j_wbuf)
3275 ++ goto err_cleanup;
3276 +
3277 + bh = getblk_unmovable(journal->j_dev, start, journal->j_blocksize);
3278 + if (!bh) {
3279 + pr_err("%s: Cannot get buffer for journal superblock\n",
3280 + __func__);
3281 +- kfree(journal->j_wbuf);
3282 +- kfree(journal);
3283 +- return NULL;
3284 ++ goto err_cleanup;
3285 + }
3286 + journal->j_sb_buffer = bh;
3287 + journal->j_superblock = (journal_superblock_t *)bh->b_data;
3288 +
3289 + return journal;
3290 ++
3291 ++err_cleanup:
3292 ++ kfree(journal->j_wbuf);
3293 ++ jbd2_journal_destroy_revoke(journal);
3294 ++ kfree(journal);
3295 ++ return NULL;
3296 + }
3297 +
3298 + /* jbd2_journal_init_dev and jbd2_journal_init_inode:
3299 +diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
3300 +index cfc38b552118..f9aefcda5854 100644
3301 +--- a/fs/jbd2/revoke.c
3302 ++++ b/fs/jbd2/revoke.c
3303 +@@ -280,6 +280,7 @@ int jbd2_journal_init_revoke(journal_t *journal, int hash_size)
3304 +
3305 + fail1:
3306 + jbd2_journal_destroy_revoke_table(journal->j_revoke_table[0]);
3307 ++ journal->j_revoke_table[0] = NULL;
3308 + fail0:
3309 + return -ENOMEM;
3310 + }
3311 +diff --git a/include/drm/drmP.h b/include/drm/drmP.h
3312 +index 9c4ee144b5f6..1871ca60e079 100644
3313 +--- a/include/drm/drmP.h
3314 ++++ b/include/drm/drmP.h
3315 +@@ -360,6 +360,7 @@ struct drm_ioctl_desc {
3316 + /* Event queued up for userspace to read */
3317 + struct drm_pending_event {
3318 + struct completion *completion;
3319 ++ void (*completion_release)(struct completion *completion);
3320 + struct drm_event *event;
3321 + struct dma_fence *fence;
3322 + struct list_head link;
3323 +diff --git a/include/linux/ccp.h b/include/linux/ccp.h
3324 +index c71dd8fa5764..c41b8d99dd0e 100644
3325 +--- a/include/linux/ccp.h
3326 ++++ b/include/linux/ccp.h
3327 +@@ -556,7 +556,7 @@ enum ccp_engine {
3328 + * struct ccp_cmd - CCP operation request
3329 + * @entry: list element (ccp driver use only)
3330 + * @work: work element used for callbacks (ccp driver use only)
3331 +- * @ccp: CCP device to be run on (ccp driver use only)
3332 ++ * @ccp: CCP device to be run on
3333 + * @ret: operation return code (ccp driver use only)
3334 + * @flags: cmd processing flags
3335 + * @engine: CCP operation to perform
3336 +diff --git a/include/linux/iio/sw_device.h b/include/linux/iio/sw_device.h
3337 +index 23ca41515527..fa7931933067 100644
3338 +--- a/include/linux/iio/sw_device.h
3339 ++++ b/include/linux/iio/sw_device.h
3340 +@@ -62,7 +62,7 @@ void iio_swd_group_init_type_name(struct iio_sw_device *d,
3341 + const char *name,
3342 + struct config_item_type *type)
3343 + {
3344 +-#ifdef CONFIG_CONFIGFS_FS
3345 ++#if IS_ENABLED(CONFIG_CONFIGFS_FS)
3346 + config_group_init_type_name(&d->group, name, type);
3347 + #endif
3348 + }
3349 +diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
3350 +index 27914672602d..bdef8b7d4305 100644
3351 +--- a/include/linux/netdevice.h
3352 ++++ b/include/linux/netdevice.h
3353 +@@ -330,6 +330,7 @@ struct napi_struct {
3354 +
3355 + enum {
3356 + NAPI_STATE_SCHED, /* Poll is scheduled */
3357 ++ NAPI_STATE_MISSED, /* reschedule a napi */
3358 + NAPI_STATE_DISABLE, /* Disable pending */
3359 + NAPI_STATE_NPSVC, /* Netpoll - don't dequeue from poll_list */
3360 + NAPI_STATE_HASHED, /* In NAPI hash (busy polling possible) */
3361 +@@ -338,12 +339,13 @@ enum {
3362 + };
3363 +
3364 + enum {
3365 +- NAPIF_STATE_SCHED = (1UL << NAPI_STATE_SCHED),
3366 +- NAPIF_STATE_DISABLE = (1UL << NAPI_STATE_DISABLE),
3367 +- NAPIF_STATE_NPSVC = (1UL << NAPI_STATE_NPSVC),
3368 +- NAPIF_STATE_HASHED = (1UL << NAPI_STATE_HASHED),
3369 +- NAPIF_STATE_NO_BUSY_POLL = (1UL << NAPI_STATE_NO_BUSY_POLL),
3370 +- NAPIF_STATE_IN_BUSY_POLL = (1UL << NAPI_STATE_IN_BUSY_POLL),
3371 ++ NAPIF_STATE_SCHED = BIT(NAPI_STATE_SCHED),
3372 ++ NAPIF_STATE_MISSED = BIT(NAPI_STATE_MISSED),
3373 ++ NAPIF_STATE_DISABLE = BIT(NAPI_STATE_DISABLE),
3374 ++ NAPIF_STATE_NPSVC = BIT(NAPI_STATE_NPSVC),
3375 ++ NAPIF_STATE_HASHED = BIT(NAPI_STATE_HASHED),
3376 ++ NAPIF_STATE_NO_BUSY_POLL = BIT(NAPI_STATE_NO_BUSY_POLL),
3377 ++ NAPIF_STATE_IN_BUSY_POLL = BIT(NAPI_STATE_IN_BUSY_POLL),
3378 + };
3379 +
3380 + enum gro_result {
3381 +@@ -413,20 +415,7 @@ static inline bool napi_disable_pending(struct napi_struct *n)
3382 + return test_bit(NAPI_STATE_DISABLE, &n->state);
3383 + }
3384 +
3385 +-/**
3386 +- * napi_schedule_prep - check if NAPI can be scheduled
3387 +- * @n: NAPI context
3388 +- *
3389 +- * Test if NAPI routine is already running, and if not mark
3390 +- * it as running. This is used as a condition variable to
3391 +- * insure only one NAPI poll instance runs. We also make
3392 +- * sure there is no pending NAPI disable.
3393 +- */
3394 +-static inline bool napi_schedule_prep(struct napi_struct *n)
3395 +-{
3396 +- return !napi_disable_pending(n) &&
3397 +- !test_and_set_bit(NAPI_STATE_SCHED, &n->state);
3398 +-}
3399 ++bool napi_schedule_prep(struct napi_struct *n);
3400 +
3401 + /**
3402 + * napi_schedule - schedule NAPI poll
3403 +diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
3404 +index 1d0043dc34e4..de2a722fe3cf 100644
3405 +--- a/include/linux/usb/quirks.h
3406 ++++ b/include/linux/usb/quirks.h
3407 +@@ -50,4 +50,10 @@
3408 + /* device can't handle Link Power Management */
3409 + #define USB_QUIRK_NO_LPM BIT(10)
3410 +
3411 ++/*
3412 ++ * Device reports its bInterval as linear frames instead of the
3413 ++ * USB 2.0 calculation.
3414 ++ */
3415 ++#define USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL BIT(11)
3416 ++
3417 + #endif /* __LINUX_USB_QUIRKS_H */
3418 +diff --git a/kernel/audit.c b/kernel/audit.c
3419 +index 6e399bb69d7c..ba4481d20fa1 100644
3420 +--- a/kernel/audit.c
3421 ++++ b/kernel/audit.c
3422 +@@ -54,6 +54,10 @@
3423 + #include <linux/kthread.h>
3424 + #include <linux/kernel.h>
3425 + #include <linux/syscalls.h>
3426 ++#include <linux/spinlock.h>
3427 ++#include <linux/rcupdate.h>
3428 ++#include <linux/mutex.h>
3429 ++#include <linux/gfp.h>
3430 +
3431 + #include <linux/audit.h>
3432 +
3433 +@@ -90,13 +94,34 @@ static u32 audit_default;
3434 + /* If auditing cannot proceed, audit_failure selects what happens. */
3435 + static u32 audit_failure = AUDIT_FAIL_PRINTK;
3436 +
3437 +-/*
3438 +- * If audit records are to be written to the netlink socket, audit_pid
3439 +- * contains the pid of the auditd process and audit_nlk_portid contains
3440 +- * the portid to use to send netlink messages to that process.
3441 ++/* private audit network namespace index */
3442 ++static unsigned int audit_net_id;
3443 ++
3444 ++/**
3445 ++ * struct audit_net - audit private network namespace data
3446 ++ * @sk: communication socket
3447 ++ */
3448 ++struct audit_net {
3449 ++ struct sock *sk;
3450 ++};
3451 ++
3452 ++/**
3453 ++ * struct auditd_connection - kernel/auditd connection state
3454 ++ * @pid: auditd PID
3455 ++ * @portid: netlink portid
3456 ++ * @net: the associated network namespace
3457 ++ * @lock: spinlock to protect write access
3458 ++ *
3459 ++ * Description:
3460 ++ * This struct is RCU protected; you must either hold the RCU lock for reading
3461 ++ * or the included spinlock for writing.
3462 + */
3463 +-int audit_pid;
3464 +-static __u32 audit_nlk_portid;
3465 ++static struct auditd_connection {
3466 ++ int pid;
3467 ++ u32 portid;
3468 ++ struct net *net;
3469 ++ spinlock_t lock;
3470 ++} auditd_conn;
3471 +
3472 + /* If audit_rate_limit is non-zero, limit the rate of sending audit records
3473 + * to that number per second. This prevents DoS attacks, but results in
3474 +@@ -123,10 +148,6 @@ u32 audit_sig_sid = 0;
3475 + */
3476 + static atomic_t audit_lost = ATOMIC_INIT(0);
3477 +
3478 +-/* The netlink socket. */
3479 +-static struct sock *audit_sock;
3480 +-static unsigned int audit_net_id;
3481 +-
3482 + /* Hash for inode-based rules */
3483 + struct list_head audit_inode_hash[AUDIT_INODE_BUCKETS];
3484 +
3485 +@@ -139,6 +160,7 @@ static LIST_HEAD(audit_freelist);
3486 +
3487 + /* queue msgs to send via kauditd_task */
3488 + static struct sk_buff_head audit_queue;
3489 ++static void kauditd_hold_skb(struct sk_buff *skb);
3490 + /* queue msgs due to temporary unicast send problems */
3491 + static struct sk_buff_head audit_retry_queue;
3492 + /* queue msgs waiting for new auditd connection */
3493 +@@ -192,6 +214,43 @@ struct audit_reply {
3494 + struct sk_buff *skb;
3495 + };
3496 +
3497 ++/**
3498 ++ * auditd_test_task - Check to see if a given task is an audit daemon
3499 ++ * @task: the task to check
3500 ++ *
3501 ++ * Description:
3502 ++ * Return 1 if the task is a registered audit daemon, 0 otherwise.
3503 ++ */
3504 ++int auditd_test_task(const struct task_struct *task)
3505 ++{
3506 ++ int rc;
3507 ++
3508 ++ rcu_read_lock();
3509 ++ rc = (auditd_conn.pid && task->tgid == auditd_conn.pid ? 1 : 0);
3510 ++ rcu_read_unlock();
3511 ++
3512 ++ return rc;
3513 ++}
3514 ++
3515 ++/**
3516 ++ * audit_get_sk - Return the audit socket for the given network namespace
3517 ++ * @net: the destination network namespace
3518 ++ *
3519 ++ * Description:
3520 ++ * Returns the sock pointer if valid, NULL otherwise. The caller must ensure
3521 ++ * that a reference is held for the network namespace while the sock is in use.
3522 ++ */
3523 ++static struct sock *audit_get_sk(const struct net *net)
3524 ++{
3525 ++ struct audit_net *aunet;
3526 ++
3527 ++ if (!net)
3528 ++ return NULL;
3529 ++
3530 ++ aunet = net_generic(net, audit_net_id);
3531 ++ return aunet->sk;
3532 ++}
3533 ++
3534 + static void audit_set_portid(struct audit_buffer *ab, __u32 portid)
3535 + {
3536 + if (ab) {
3537 +@@ -210,9 +269,7 @@ void audit_panic(const char *message)
3538 + pr_err("%s\n", message);
3539 + break;
3540 + case AUDIT_FAIL_PANIC:
3541 +- /* test audit_pid since printk is always losey, why bother? */
3542 +- if (audit_pid)
3543 +- panic("audit: %s\n", message);
3544 ++ panic("audit: %s\n", message);
3545 + break;
3546 + }
3547 + }
3548 +@@ -370,21 +427,87 @@ static int audit_set_failure(u32 state)
3549 + return audit_do_config_change("audit_failure", &audit_failure, state);
3550 + }
3551 +
3552 +-/*
3553 +- * For one reason or another this nlh isn't getting delivered to the userspace
3554 +- * audit daemon, just send it to printk.
3555 ++/**
3556 ++ * auditd_set - Set/Reset the auditd connection state
3557 ++ * @pid: auditd PID
3558 ++ * @portid: auditd netlink portid
3559 ++ * @net: auditd network namespace pointer
3560 ++ *
3561 ++ * Description:
3562 ++ * This function will obtain and drop network namespace references as
3563 ++ * necessary.
3564 ++ */
3565 ++static void auditd_set(int pid, u32 portid, struct net *net)
3566 ++{
3567 ++ unsigned long flags;
3568 ++
3569 ++ spin_lock_irqsave(&auditd_conn.lock, flags);
3570 ++ auditd_conn.pid = pid;
3571 ++ auditd_conn.portid = portid;
3572 ++ if (auditd_conn.net)
3573 ++ put_net(auditd_conn.net);
3574 ++ if (net)
3575 ++ auditd_conn.net = get_net(net);
3576 ++ else
3577 ++ auditd_conn.net = NULL;
3578 ++ spin_unlock_irqrestore(&auditd_conn.lock, flags);
3579 ++}
3580 ++
3581 ++/**
3582 ++ * auditd_reset - Disconnect the auditd connection
3583 ++ *
3584 ++ * Description:
3585 ++ * Break the auditd/kauditd connection and move all the queued records into the
3586 ++ * hold queue in case auditd reconnects.
3587 ++ */
3588 ++static void auditd_reset(void)
3589 ++{
3590 ++ struct sk_buff *skb;
3591 ++
3592 ++ /* if it isn't already broken, break the connection */
3593 ++ rcu_read_lock();
3594 ++ if (auditd_conn.pid)
3595 ++ auditd_set(0, 0, NULL);
3596 ++ rcu_read_unlock();
3597 ++
3598 ++ /* flush all of the main and retry queues to the hold queue */
3599 ++ while ((skb = skb_dequeue(&audit_retry_queue)))
3600 ++ kauditd_hold_skb(skb);
3601 ++ while ((skb = skb_dequeue(&audit_queue)))
3602 ++ kauditd_hold_skb(skb);
3603 ++}
3604 ++
3605 ++/**
3606 ++ * kauditd_print_skb - Print the audit record to the ring buffer
3607 ++ * @skb: audit record
3608 ++ *
3609 ++ * Whatever the reason, this packet may not make it to the auditd connection
3610 ++ * so write it via printk so the information isn't completely lost.
3611 + */
3612 + static void kauditd_printk_skb(struct sk_buff *skb)
3613 + {
3614 + struct nlmsghdr *nlh = nlmsg_hdr(skb);
3615 + char *data = nlmsg_data(nlh);
3616 +
3617 +- if (nlh->nlmsg_type != AUDIT_EOE) {
3618 +- if (printk_ratelimit())
3619 +- pr_notice("type=%d %s\n", nlh->nlmsg_type, data);
3620 +- else
3621 +- audit_log_lost("printk limit exceeded");
3622 +- }
3623 ++ if (nlh->nlmsg_type != AUDIT_EOE && printk_ratelimit())
3624 ++ pr_notice("type=%d %s\n", nlh->nlmsg_type, data);
3625 ++}
3626 ++
3627 ++/**
3628 ++ * kauditd_rehold_skb - Handle a audit record send failure in the hold queue
3629 ++ * @skb: audit record
3630 ++ *
3631 ++ * Description:
3632 ++ * This should only be used by the kauditd_thread when it fails to flush the
3633 ++ * hold queue.
3634 ++ */
3635 ++static void kauditd_rehold_skb(struct sk_buff *skb)
3636 ++{
3637 ++ /* put the record back in the queue at the same place */
3638 ++ skb_queue_head(&audit_hold_queue, skb);
3639 ++
3640 ++ /* fail the auditd connection */
3641 ++ auditd_reset();
3642 + }
3643 +
3644 + /**
3645 +@@ -421,6 +544,9 @@ static void kauditd_hold_skb(struct sk_buff *skb)
3646 + /* we have no other options - drop the message */
3647 + audit_log_lost("kauditd hold queue overflow");
3648 + kfree_skb(skb);
3649 ++
3650 ++ /* fail the auditd connection */
3651 ++ auditd_reset();
3652 + }
3653 +
3654 + /**
3655 +@@ -441,51 +567,122 @@ static void kauditd_retry_skb(struct sk_buff *skb)
3656 + }
3657 +
3658 + /**
3659 +- * auditd_reset - Disconnect the auditd connection
3660 ++ * auditd_send_unicast_skb - Send a record via unicast to auditd
3661 ++ * @skb: audit record
3662 + *
3663 + * Description:
3664 +- * Break the auditd/kauditd connection and move all the records in the retry
3665 +- * queue into the hold queue in case auditd reconnects. The audit_cmd_mutex
3666 +- * must be held when calling this function.
3667 ++ * Send a skb to the audit daemon, returns positive/zero values on success and
3668 ++ * negative values on failure; in all cases the skb will be consumed by this
3669 ++ * function. If the send results in -ECONNREFUSED the connection with auditd
3670 ++ * will be reset. This function may sleep so callers should not hold any locks
3671 ++ * where this would cause a problem.
3672 + */
3673 +-static void auditd_reset(void)
3674 ++static int auditd_send_unicast_skb(struct sk_buff *skb)
3675 + {
3676 +- struct sk_buff *skb;
3677 +-
3678 +- /* break the connection */
3679 +- if (audit_sock) {
3680 +- sock_put(audit_sock);
3681 +- audit_sock = NULL;
3682 ++ int rc;
3683 ++ u32 portid;
3684 ++ struct net *net;
3685 ++ struct sock *sk;
3686 ++
3687 ++ /* NOTE: we can't call netlink_unicast while in the RCU section so
3688 ++ * take a reference to the network namespace and grab local
3689 ++ * copies of the namespace, the sock, and the portid; the
3690 ++ * namespace and sock aren't going to go away while we hold a
3691 ++ * reference and if the portid does become invalid after the RCU
3692 ++ * section netlink_unicast() should safely return an error */
3693 ++
3694 ++ rcu_read_lock();
3695 ++ if (!auditd_conn.pid) {
3696 ++ rcu_read_unlock();
3697 ++ rc = -ECONNREFUSED;
3698 ++ goto err;
3699 + }
3700 +- audit_pid = 0;
3701 +- audit_nlk_portid = 0;
3702 ++ net = auditd_conn.net;
3703 ++ get_net(net);
3704 ++ sk = audit_get_sk(net);
3705 ++ portid = auditd_conn.portid;
3706 ++ rcu_read_unlock();
3707 +
3708 +- /* flush all of the retry queue to the hold queue */
3709 +- while ((skb = skb_dequeue(&audit_retry_queue)))
3710 +- kauditd_hold_skb(skb);
3711 ++ rc = netlink_unicast(sk, skb, portid, 0);
3712 ++ put_net(net);
3713 ++ if (rc < 0)
3714 ++ goto err;
3715 ++
3716 ++ return rc;
3717 ++
3718 ++err:
3719 ++ if (rc == -ECONNREFUSED)
3720 ++ auditd_reset();
3721 ++ return rc;
3722 + }
3723 +
3724 + /**
3725 +- * kauditd_send_unicast_skb - Send a record via unicast to auditd
3726 +- * @skb: audit record
3727 ++ * kauditd_send_queue - Helper for kauditd_thread to flush skb queues
3728 ++ * @sk: the sending sock
3729 ++ * @portid: the netlink destination
3730 ++ * @queue: the skb queue to process
3731 ++ * @retry_limit: limit on number of netlink unicast failures
3732 ++ * @skb_hook: per-skb hook for additional processing
3733 ++ * @err_hook: hook called if the skb fails the netlink unicast send
3734 ++ *
3735 ++ * Description:
3736 ++ * Run through the given queue and attempt to send the audit records to auditd,
3737 ++ * returns zero on success, negative values on failure. It is up to the caller
3738 ++ * to ensure that the @sk is valid for the duration of this function.
3739 ++ *
3740 + */
3741 +-static int kauditd_send_unicast_skb(struct sk_buff *skb)
3742 ++static int kauditd_send_queue(struct sock *sk, u32 portid,
3743 ++ struct sk_buff_head *queue,
3744 ++ unsigned int retry_limit,
3745 ++ void (*skb_hook)(struct sk_buff *skb),
3746 ++ void (*err_hook)(struct sk_buff *skb))
3747 + {
3748 +- int rc;
3749 ++ int rc = 0;
3750 ++ struct sk_buff *skb;
3751 ++ static unsigned int failed = 0;
3752 +
3753 +- /* if we know nothing is connected, don't even try the netlink call */
3754 +- if (!audit_pid)
3755 +- return -ECONNREFUSED;
3756 ++ /* NOTE: kauditd_thread takes care of all our locking, we just use
3757 ++ * the netlink info passed to us (e.g. sk and portid) */
3758 ++
3759 ++ while ((skb = skb_dequeue(queue))) {
3760 ++ /* call the skb_hook for each skb we touch */
3761 ++ if (skb_hook)
3762 ++ (*skb_hook)(skb);
3763 ++
3764 ++ /* can we send to anyone via unicast? */
3765 ++ if (!sk) {
3766 ++ if (err_hook)
3767 ++ (*err_hook)(skb);
3768 ++ continue;
3769 ++ }
3770 +
3771 +- /* get an extra skb reference in case we fail to send */
3772 +- skb_get(skb);
3773 +- rc = netlink_unicast(audit_sock, skb, audit_nlk_portid, 0);
3774 +- if (rc >= 0) {
3775 +- consume_skb(skb);
3776 +- rc = 0;
3777 ++ /* grab an extra skb reference in case of error */
3778 ++ skb_get(skb);
3779 ++ rc = netlink_unicast(sk, skb, portid, 0);
3780 ++ if (rc < 0) {
3781 ++ /* fatal failure for our queue flush attempt? */
3782 ++ if (++failed >= retry_limit ||
3783 ++ rc == -ECONNREFUSED || rc == -EPERM) {
3784 ++ /* yes - error processing for the queue */
3785 ++ sk = NULL;
3786 ++ if (err_hook)
3787 ++ (*err_hook)(skb);
3788 ++ if (!skb_hook)
3789 ++ goto out;
3790 ++ /* keep processing with the skb_hook */
3791 ++ continue;
3792 ++ } else
3793 ++ /* no - requeue to preserve ordering */
3794 ++ skb_queue_head(queue, skb);
3795 ++ } else {
3796 ++ /* it worked - drop the extra reference and continue */
3797 ++ consume_skb(skb);
3798 ++ failed = 0;
3799 ++ }
3800 + }
3801 +
3802 +- return rc;
3803 ++out:
3804 ++ return (rc >= 0 ? 0 : rc);
3805 + }
3806 +
3807 + /*
3808 +@@ -493,16 +690,19 @@ static int kauditd_send_unicast_skb(struct sk_buff *skb)
3809 + * @skb: audit record
3810 + *
3811 + * Description:
3812 +- * This function doesn't consume an skb as might be expected since it has to
3813 +- * copy it anyways.
3814 ++ * Write a multicast message to anyone listening in the initial network
3815 ++ * namespace. This function doesn't consume an skb as might be expected since
3816 ++ * it has to copy it anyways.
3817 + */
3818 + static void kauditd_send_multicast_skb(struct sk_buff *skb)
3819 + {
3820 + struct sk_buff *copy;
3821 +- struct audit_net *aunet = net_generic(&init_net, audit_net_id);
3822 +- struct sock *sock = aunet->nlsk;
3823 ++ struct sock *sock = audit_get_sk(&init_net);
3824 + struct nlmsghdr *nlh;
3825 +
3826 ++ /* NOTE: we are not taking an additional reference for init_net since
3827 ++ * we don't have to worry about it going away */
3828 ++
3829 + if (!netlink_has_listeners(sock, AUDIT_NLGRP_READLOG))
3830 + return;
3831 +
3832 +@@ -526,149 +726,75 @@ static void kauditd_send_multicast_skb(struct sk_buff *skb)
3833 + }
3834 +
3835 + /**
3836 +- * kauditd_wake_condition - Return true when it is time to wake kauditd_thread
3837 +- *
3838 +- * Description:
3839 +- * This function is for use by the wait_event_freezable() call in
3840 +- * kauditd_thread().
3841 ++ * kauditd_thread - Worker thread to send audit records to userspace
3842 ++ * @dummy: unused
3843 + */
3844 +-static int kauditd_wake_condition(void)
3845 +-{
3846 +- static int pid_last = 0;
3847 +- int rc;
3848 +- int pid = audit_pid;
3849 +-
3850 +- /* wake on new messages or a change in the connected auditd */
3851 +- rc = skb_queue_len(&audit_queue) || (pid && pid != pid_last);
3852 +- if (rc)
3853 +- pid_last = pid;
3854 +-
3855 +- return rc;
3856 +-}
3857 +-
3858 + static int kauditd_thread(void *dummy)
3859 + {
3860 + int rc;
3861 +- int auditd = 0;
3862 +- int reschedule = 0;
3863 +- struct sk_buff *skb;
3864 +- struct nlmsghdr *nlh;
3865 ++ u32 portid = 0;
3866 ++ struct net *net = NULL;
3867 ++ struct sock *sk = NULL;
3868 +
3869 + #define UNICAST_RETRIES 5
3870 +-#define AUDITD_BAD(x,y) \
3871 +- ((x) == -ECONNREFUSED || (x) == -EPERM || ++(y) >= UNICAST_RETRIES)
3872 +-
3873 +- /* NOTE: we do invalidate the auditd connection flag on any sending
3874 +- * errors, but we only "restore" the connection flag at specific places
3875 +- * in the loop in order to help ensure proper ordering of audit
3876 +- * records */
3877 +
3878 + set_freezable();
3879 + while (!kthread_should_stop()) {
3880 +- /* NOTE: possible area for future improvement is to look at
3881 +- * the hold and retry queues, since only this thread
3882 +- * has access to these queues we might be able to do
3883 +- * our own queuing and skip some/all of the locking */
3884 +-
3885 +- /* NOTE: it might be a fun experiment to split the hold and
3886 +- * retry queue handling to another thread, but the
3887 +- * synchronization issues and other overhead might kill
3888 +- * any performance gains */
3889 ++ /* NOTE: see the lock comments in auditd_send_unicast_skb() */
3890 ++ rcu_read_lock();
3891 ++ if (!auditd_conn.pid) {
3892 ++ rcu_read_unlock();
3893 ++ goto main_queue;
3894 ++ }
3895 ++ net = auditd_conn.net;
3896 ++ get_net(net);
3897 ++ sk = audit_get_sk(net);
3898 ++ portid = auditd_conn.portid;
3899 ++ rcu_read_unlock();
3900 +
3901 + /* attempt to flush the hold queue */
3902 +- while (auditd && (skb = skb_dequeue(&audit_hold_queue))) {
3903 +- rc = kauditd_send_unicast_skb(skb);
3904 +- if (rc) {
3905 +- /* requeue to the same spot */
3906 +- skb_queue_head(&audit_hold_queue, skb);
3907 +-
3908 +- auditd = 0;
3909 +- if (AUDITD_BAD(rc, reschedule)) {
3910 +- mutex_lock(&audit_cmd_mutex);
3911 +- auditd_reset();
3912 +- mutex_unlock(&audit_cmd_mutex);
3913 +- reschedule = 0;
3914 +- }
3915 +- } else
3916 +- /* we were able to send successfully */
3917 +- reschedule = 0;
3918 ++ rc = kauditd_send_queue(sk, portid,
3919 ++ &audit_hold_queue, UNICAST_RETRIES,
3920 ++ NULL, kauditd_rehold_skb);
3921 ++ if (rc < 0) {
3922 ++ sk = NULL;
3923 ++ goto main_queue;
3924 + }
3925 +
3926 + /* attempt to flush the retry queue */
3927 +- while (auditd && (skb = skb_dequeue(&audit_retry_queue))) {
3928 +- rc = kauditd_send_unicast_skb(skb);
3929 +- if (rc) {
3930 +- auditd = 0;
3931 +- if (AUDITD_BAD(rc, reschedule)) {
3932 +- kauditd_hold_skb(skb);
3933 +- mutex_lock(&audit_cmd_mutex);
3934 +- auditd_reset();
3935 +- mutex_unlock(&audit_cmd_mutex);
3936 +- reschedule = 0;
3937 +- } else
3938 +- /* temporary problem (we hope), queue
3939 +- * to the same spot and retry */
3940 +- skb_queue_head(&audit_retry_queue, skb);
3941 +- } else
3942 +- /* we were able to send successfully */
3943 +- reschedule = 0;
3944 ++ rc = kauditd_send_queue(sk, portid,
3945 ++ &audit_retry_queue, UNICAST_RETRIES,
3946 ++ NULL, kauditd_hold_skb);
3947 ++ if (rc < 0) {
3948 ++ sk = NULL;
3949 ++ goto main_queue;
3950 + }
3951 +
3952 +- /* standard queue processing, try to be as quick as possible */
3953 +-quick_loop:
3954 +- skb = skb_dequeue(&audit_queue);
3955 +- if (skb) {
3956 +- /* setup the netlink header, see the comments in
3957 +- * kauditd_send_multicast_skb() for length quirks */
3958 +- nlh = nlmsg_hdr(skb);
3959 +- nlh->nlmsg_len = skb->len - NLMSG_HDRLEN;
3960 +-
3961 +- /* attempt to send to any multicast listeners */
3962 +- kauditd_send_multicast_skb(skb);
3963 +-
3964 +- /* attempt to send to auditd, queue on failure */
3965 +- if (auditd) {
3966 +- rc = kauditd_send_unicast_skb(skb);
3967 +- if (rc) {
3968 +- auditd = 0;
3969 +- if (AUDITD_BAD(rc, reschedule)) {
3970 +- mutex_lock(&audit_cmd_mutex);
3971 +- auditd_reset();
3972 +- mutex_unlock(&audit_cmd_mutex);
3973 +- reschedule = 0;
3974 +- }
3975 +-
3976 +- /* move to the retry queue */
3977 +- kauditd_retry_skb(skb);
3978 +- } else
3979 +- /* everything is working so go fast! */
3980 +- goto quick_loop;
3981 +- } else if (reschedule)
3982 +- /* we are currently having problems, move to
3983 +- * the retry queue */
3984 +- kauditd_retry_skb(skb);
3985 +- else
3986 +- /* dump the message via printk and hold it */
3987 +- kauditd_hold_skb(skb);
3988 +- } else {
3989 +- /* we have flushed the backlog so wake everyone */
3990 +- wake_up(&audit_backlog_wait);
3991 +-
3992 +- /* if everything is okay with auditd (if present), go
3993 +- * to sleep until there is something new in the queue
3994 +- * or we have a change in the connected auditd;
3995 +- * otherwise simply reschedule to give things a chance
3996 +- * to recover */
3997 +- if (reschedule) {
3998 +- set_current_state(TASK_INTERRUPTIBLE);
3999 +- schedule();
4000 +- } else
4001 +- wait_event_freezable(kauditd_wait,
4002 +- kauditd_wake_condition());
4003 +-
4004 +- /* update the auditd connection status */
4005 +- auditd = (audit_pid ? 1 : 0);
4006 ++main_queue:
4007 ++ /* process the main queue - do the multicast send and attempt
4008 ++ * unicast, dump failed record sends to the retry queue; if
4009 ++ * sk == NULL due to previous failures we will just do the
4010 ++ * multicast send and move the record to the retry queue */
4011 ++ kauditd_send_queue(sk, portid, &audit_queue, 1,
4012 ++ kauditd_send_multicast_skb,
4013 ++ kauditd_retry_skb);
4014 ++
4015 ++ /* drop our netns reference, no auditd sends past this line */
4016 ++ if (net) {
4017 ++ put_net(net);
4018 ++ net = NULL;
4019 + }
4020 ++ sk = NULL;
4021 ++
4022 ++ /* we have processed all the queues so wake everyone */
4023 ++ wake_up(&audit_backlog_wait);
4024 ++
4025 ++ /* NOTE: we want to wake up if there is anything on the queue,
4026 ++ * regardless of if an auditd is connected, as we need to
4027 ++ * do the multicast send and rotate records from the
4028 ++ * main queue to the retry/hold queues */
4029 ++ wait_event_freezable(kauditd_wait,
4030 ++ (skb_queue_len(&audit_queue) ? 1 : 0));
4031 + }
4032 +
4033 + return 0;
4034 +@@ -678,17 +804,16 @@ int audit_send_list(void *_dest)
4035 + {
4036 + struct audit_netlink_list *dest = _dest;
4037 + struct sk_buff *skb;
4038 +- struct net *net = dest->net;
4039 +- struct audit_net *aunet = net_generic(net, audit_net_id);
4040 ++ struct sock *sk = audit_get_sk(dest->net);
4041 +
4042 + /* wait for parent to finish and send an ACK */
4043 + mutex_lock(&audit_cmd_mutex);
4044 + mutex_unlock(&audit_cmd_mutex);
4045 +
4046 + while ((skb = __skb_dequeue(&dest->q)) != NULL)
4047 +- netlink_unicast(aunet->nlsk, skb, dest->portid, 0);
4048 ++ netlink_unicast(sk, skb, dest->portid, 0);
4049 +
4050 +- put_net(net);
4051 ++ put_net(dest->net);
4052 + kfree(dest);
4053 +
4054 + return 0;
4055 +@@ -722,16 +847,15 @@ struct sk_buff *audit_make_reply(__u32 portid, int seq, int type, int done,
4056 + static int audit_send_reply_thread(void *arg)
4057 + {
4058 + struct audit_reply *reply = (struct audit_reply *)arg;
4059 +- struct net *net = reply->net;
4060 +- struct audit_net *aunet = net_generic(net, audit_net_id);
4061 ++ struct sock *sk = audit_get_sk(reply->net);
4062 +
4063 + mutex_lock(&audit_cmd_mutex);
4064 + mutex_unlock(&audit_cmd_mutex);
4065 +
4066 + /* Ignore failure. It'll only happen if the sender goes away,
4067 + because our timeout is set to infinite. */
4068 +- netlink_unicast(aunet->nlsk , reply->skb, reply->portid, 0);
4069 +- put_net(net);
4070 ++ netlink_unicast(sk, reply->skb, reply->portid, 0);
4071 ++ put_net(reply->net);
4072 + kfree(reply);
4073 + return 0;
4074 + }
4075 +@@ -949,12 +1073,12 @@ static int audit_set_feature(struct sk_buff *skb)
4076 +
4077 + static int audit_replace(pid_t pid)
4078 + {
4079 +- struct sk_buff *skb = audit_make_reply(0, 0, AUDIT_REPLACE, 0, 0,
4080 +- &pid, sizeof(pid));
4081 ++ struct sk_buff *skb;
4082 +
4083 ++ skb = audit_make_reply(0, 0, AUDIT_REPLACE, 0, 0, &pid, sizeof(pid));
4084 + if (!skb)
4085 + return -ENOMEM;
4086 +- return netlink_unicast(audit_sock, skb, audit_nlk_portid, 0);
4087 ++ return auditd_send_unicast_skb(skb);
4088 + }
4089 +
4090 + static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
4091 +@@ -981,7 +1105,9 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
4092 + memset(&s, 0, sizeof(s));
4093 + s.enabled = audit_enabled;
4094 + s.failure = audit_failure;
4095 +- s.pid = audit_pid;
4096 ++ rcu_read_lock();
4097 ++ s.pid = auditd_conn.pid;
4098 ++ rcu_read_unlock();
4099 + s.rate_limit = audit_rate_limit;
4100 + s.backlog_limit = audit_backlog_limit;
4101 + s.lost = atomic_read(&audit_lost);
4102 +@@ -1014,30 +1140,44 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
4103 + * from the initial pid namespace, but something
4104 + * to keep in mind if this changes */
4105 + int new_pid = s.pid;
4106 ++ pid_t auditd_pid;
4107 + pid_t requesting_pid = task_tgid_vnr(current);
4108 +
4109 +- if ((!new_pid) && (requesting_pid != audit_pid)) {
4110 +- audit_log_config_change("audit_pid", new_pid, audit_pid, 0);
4111 ++ /* test the auditd connection */
4112 ++ audit_replace(requesting_pid);
4113 ++
4114 ++ rcu_read_lock();
4115 ++ auditd_pid = auditd_conn.pid;
4116 ++ /* only the current auditd can unregister itself */
4117 ++ if ((!new_pid) && (requesting_pid != auditd_pid)) {
4118 ++ rcu_read_unlock();
4119 ++ audit_log_config_change("audit_pid", new_pid,
4120 ++ auditd_pid, 0);
4121 + return -EACCES;
4122 + }
4123 +- if (audit_pid && new_pid &&
4124 +- audit_replace(requesting_pid) != -ECONNREFUSED) {
4125 +- audit_log_config_change("audit_pid", new_pid, audit_pid, 0);
4126 ++ /* replacing a healthy auditd is not allowed */
4127 ++ if (auditd_pid && new_pid) {
4128 ++ rcu_read_unlock();
4129 ++ audit_log_config_change("audit_pid", new_pid,
4130 ++ auditd_pid, 0);
4131 + return -EEXIST;
4132 + }
4133 ++ rcu_read_unlock();
4134 ++
4135 + if (audit_enabled != AUDIT_OFF)
4136 +- audit_log_config_change("audit_pid", new_pid, audit_pid, 1);
4137 ++ audit_log_config_change("audit_pid", new_pid,
4138 ++ auditd_pid, 1);
4139 ++
4140 + if (new_pid) {
4141 +- if (audit_sock)
4142 +- sock_put(audit_sock);
4143 +- audit_pid = new_pid;
4144 +- audit_nlk_portid = NETLINK_CB(skb).portid;
4145 +- sock_hold(skb->sk);
4146 +- audit_sock = skb->sk;
4147 +- } else {
4148 ++ /* register a new auditd connection */
4149 ++ auditd_set(new_pid,
4150 ++ NETLINK_CB(skb).portid,
4151 ++ sock_net(NETLINK_CB(skb).sk));
4152 ++ /* try to process any backlog */
4153 ++ wake_up_interruptible(&kauditd_wait);
4154 ++ } else
4155 ++ /* unregister the auditd connection */
4156 + auditd_reset();
4157 +- }
4158 +- wake_up_interruptible(&kauditd_wait);
4159 + }
4160 + if (s.mask & AUDIT_STATUS_RATE_LIMIT) {
4161 + err = audit_set_rate_limit(s.rate_limit);
4162 +@@ -1084,7 +1224,6 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
4163 + if (err)
4164 + break;
4165 + }
4166 +- mutex_unlock(&audit_cmd_mutex);
4167 + audit_log_common_recv_msg(&ab, msg_type);
4168 + if (msg_type != AUDIT_USER_TTY)
4169 + audit_log_format(ab, " msg='%.*s'",
4170 +@@ -1102,7 +1241,6 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
4171 + }
4172 + audit_set_portid(ab, NETLINK_CB(skb).portid);
4173 + audit_log_end(ab);
4174 +- mutex_lock(&audit_cmd_mutex);
4175 + }
4176 + break;
4177 + case AUDIT_ADD_RULE:
4178 +@@ -1292,26 +1430,26 @@ static int __net_init audit_net_init(struct net *net)
4179 +
4180 + struct audit_net *aunet = net_generic(net, audit_net_id);
4181 +
4182 +- aunet->nlsk = netlink_kernel_create(net, NETLINK_AUDIT, &cfg);
4183 +- if (aunet->nlsk == NULL) {
4184 ++ aunet->sk = netlink_kernel_create(net, NETLINK_AUDIT, &cfg);
4185 ++ if (aunet->sk == NULL) {
4186 + audit_panic("cannot initialize netlink socket in namespace");
4187 + return -ENOMEM;
4188 + }
4189 +- aunet->nlsk->sk_sndtimeo = MAX_SCHEDULE_TIMEOUT;
4190 ++ aunet->sk->sk_sndtimeo = MAX_SCHEDULE_TIMEOUT;
4191 ++
4192 + return 0;
4193 + }
4194 +
4195 + static void __net_exit audit_net_exit(struct net *net)
4196 + {
4197 + struct audit_net *aunet = net_generic(net, audit_net_id);
4198 +- struct sock *sock = aunet->nlsk;
4199 +- mutex_lock(&audit_cmd_mutex);
4200 +- if (sock == audit_sock)
4201 ++
4202 ++ rcu_read_lock();
4203 ++ if (net == auditd_conn.net)
4204 + auditd_reset();
4205 +- mutex_unlock(&audit_cmd_mutex);
4206 ++ rcu_read_unlock();
4207 +
4208 +- netlink_kernel_release(sock);
4209 +- aunet->nlsk = NULL;
4210 ++ netlink_kernel_release(aunet->sk);
4211 + }
4212 +
4213 + static struct pernet_operations audit_net_ops __net_initdata = {
4214 +@@ -1329,20 +1467,24 @@ static int __init audit_init(void)
4215 + if (audit_initialized == AUDIT_DISABLED)
4216 + return 0;
4217 +
4218 +- pr_info("initializing netlink subsys (%s)\n",
4219 +- audit_default ? "enabled" : "disabled");
4220 +- register_pernet_subsys(&audit_net_ops);
4221 ++ memset(&auditd_conn, 0, sizeof(auditd_conn));
4222 ++ spin_lock_init(&auditd_conn.lock);
4223 +
4224 + skb_queue_head_init(&audit_queue);
4225 + skb_queue_head_init(&audit_retry_queue);
4226 + skb_queue_head_init(&audit_hold_queue);
4227 +- audit_initialized = AUDIT_INITIALIZED;
4228 +- audit_enabled = audit_default;
4229 +- audit_ever_enabled |= !!audit_default;
4230 +
4231 + for (i = 0; i < AUDIT_INODE_BUCKETS; i++)
4232 + INIT_LIST_HEAD(&audit_inode_hash[i]);
4233 +
4234 ++ pr_info("initializing netlink subsys (%s)\n",
4235 ++ audit_default ? "enabled" : "disabled");
4236 ++ register_pernet_subsys(&audit_net_ops);
4237 ++
4238 ++ audit_initialized = AUDIT_INITIALIZED;
4239 ++ audit_enabled = audit_default;
4240 ++ audit_ever_enabled |= !!audit_default;
4241 ++
4242 + kauditd_task = kthread_run(kauditd_thread, NULL, "kauditd");
4243 + if (IS_ERR(kauditd_task)) {
4244 + int err = PTR_ERR(kauditd_task);
4245 +@@ -1511,20 +1653,16 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
4246 + if (unlikely(!audit_filter(type, AUDIT_FILTER_TYPE)))
4247 + return NULL;
4248 +
4249 +- /* don't ever fail/sleep on these two conditions:
4250 ++ /* NOTE: don't ever fail/sleep on these two conditions:
4251 + * 1. auditd generated record - since we need auditd to drain the
4252 + * queue; also, when we are checking for auditd, compare PIDs using
4253 + * task_tgid_vnr() since auditd_pid is set in audit_receive_msg()
4254 + * using a PID anchored in the caller's namespace
4255 +- * 2. audit command message - record types 1000 through 1099 inclusive
4256 +- * are command messages/records used to manage the kernel subsystem
4257 +- * and the audit userspace, blocking on these messages could cause
4258 +- * problems under load so don't do it (note: not all of these
4259 +- * command types are valid as record types, but it is quicker to
4260 +- * just check two ints than a series of ints in a if/switch stmt) */
4261 +- if (!((audit_pid && audit_pid == task_tgid_vnr(current)) ||
4262 +- (type >= 1000 && type <= 1099))) {
4263 +- long sleep_time = audit_backlog_wait_time;
4264 ++ * 2. generator holding the audit_cmd_mutex - we don't want to block
4265 ++ * while holding the mutex */
4266 ++ if (!(auditd_test_task(current) ||
4267 ++ (current == __mutex_owner(&audit_cmd_mutex)))) {
4268 ++ long stime = audit_backlog_wait_time;
4269 +
4270 + while (audit_backlog_limit &&
4271 + (skb_queue_len(&audit_queue) > audit_backlog_limit)) {
4272 +@@ -1533,14 +1671,13 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
4273 +
4274 + /* sleep if we are allowed and we haven't exhausted our
4275 + * backlog wait limit */
4276 +- if ((gfp_mask & __GFP_DIRECT_RECLAIM) &&
4277 +- (sleep_time > 0)) {
4278 ++ if (gfpflags_allow_blocking(gfp_mask) && (stime > 0)) {
4279 + DECLARE_WAITQUEUE(wait, current);
4280 +
4281 + add_wait_queue_exclusive(&audit_backlog_wait,
4282 + &wait);
4283 + set_current_state(TASK_UNINTERRUPTIBLE);
4284 +- sleep_time = schedule_timeout(sleep_time);
4285 ++ stime = schedule_timeout(stime);
4286 + remove_wait_queue(&audit_backlog_wait, &wait);
4287 + } else {
4288 + if (audit_rate_check() && printk_ratelimit())
4289 +@@ -2119,15 +2256,27 @@ void audit_log_link_denied(const char *operation, const struct path *link)
4290 + */
4291 + void audit_log_end(struct audit_buffer *ab)
4292 + {
4293 ++ struct sk_buff *skb;
4294 ++ struct nlmsghdr *nlh;
4295 ++
4296 + if (!ab)
4297 + return;
4298 +- if (!audit_rate_check()) {
4299 +- audit_log_lost("rate limit exceeded");
4300 +- } else {
4301 +- skb_queue_tail(&audit_queue, ab->skb);
4302 +- wake_up_interruptible(&kauditd_wait);
4303 ++
4304 ++ if (audit_rate_check()) {
4305 ++ skb = ab->skb;
4306 + ab->skb = NULL;
4307 +- }
4308 ++
4309 ++ /* setup the netlink header, see the comments in
4310 ++ * kauditd_send_multicast_skb() for length quirks */
4311 ++ nlh = nlmsg_hdr(skb);
4312 ++ nlh->nlmsg_len = skb->len - NLMSG_HDRLEN;
4313 ++
4314 ++ /* queue the netlink packet and poke the kauditd thread */
4315 ++ skb_queue_tail(&audit_queue, skb);
4316 ++ wake_up_interruptible(&kauditd_wait);
4317 ++ } else
4318 ++ audit_log_lost("rate limit exceeded");
4319 ++
4320 + audit_buffer_free(ab);
4321 + }
4322 +
4323 +diff --git a/kernel/audit.h b/kernel/audit.h
4324 +index 960d49c9db5e..c6fba919b2e4 100644
4325 +--- a/kernel/audit.h
4326 ++++ b/kernel/audit.h
4327 +@@ -215,7 +215,7 @@ extern void audit_log_name(struct audit_context *context,
4328 + struct audit_names *n, const struct path *path,
4329 + int record_num, int *call_panic);
4330 +
4331 +-extern int audit_pid;
4332 ++extern int auditd_test_task(const struct task_struct *task);
4333 +
4334 + #define AUDIT_INODE_BUCKETS 32
4335 + extern struct list_head audit_inode_hash[AUDIT_INODE_BUCKETS];
4336 +@@ -247,10 +247,6 @@ struct audit_netlink_list {
4337 +
4338 + int audit_send_list(void *);
4339 +
4340 +-struct audit_net {
4341 +- struct sock *nlsk;
4342 +-};
4343 +-
4344 + extern int selinux_audit_rule_update(void);
4345 +
4346 + extern struct mutex audit_filter_mutex;
4347 +@@ -337,8 +333,7 @@ extern int audit_filter(int msgtype, unsigned int listtype);
4348 + extern int __audit_signal_info(int sig, struct task_struct *t);
4349 + static inline int audit_signal_info(int sig, struct task_struct *t)
4350 + {
4351 +- if (unlikely((audit_pid && t->tgid == audit_pid) ||
4352 +- (audit_signals && !audit_dummy_context())))
4353 ++ if (auditd_test_task(t) || (audit_signals && !audit_dummy_context()))
4354 + return __audit_signal_info(sig, t);
4355 + return 0;
4356 + }
4357 +diff --git a/kernel/auditsc.c b/kernel/auditsc.c
4358 +index cf1fa43512c1..9e69c3a6b732 100644
4359 +--- a/kernel/auditsc.c
4360 ++++ b/kernel/auditsc.c
4361 +@@ -762,7 +762,7 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk,
4362 + struct audit_entry *e;
4363 + enum audit_state state;
4364 +
4365 +- if (audit_pid && tsk->tgid == audit_pid)
4366 ++ if (auditd_test_task(tsk))
4367 + return AUDIT_DISABLED;
4368 +
4369 + rcu_read_lock();
4370 +@@ -816,7 +816,7 @@ void audit_filter_inodes(struct task_struct *tsk, struct audit_context *ctx)
4371 + {
4372 + struct audit_names *n;
4373 +
4374 +- if (audit_pid && tsk->tgid == audit_pid)
4375 ++ if (auditd_test_task(tsk))
4376 + return;
4377 +
4378 + rcu_read_lock();
4379 +@@ -2251,7 +2251,7 @@ int __audit_signal_info(int sig, struct task_struct *t)
4380 + struct audit_context *ctx = tsk->audit_context;
4381 + kuid_t uid = current_uid(), t_uid = task_uid(t);
4382 +
4383 +- if (audit_pid && t->tgid == audit_pid) {
4384 ++ if (auditd_test_task(t)) {
4385 + if (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1 || sig == SIGUSR2) {
4386 + audit_sig_pid = task_tgid_nr(tsk);
4387 + if (uid_valid(tsk->loginuid))
4388 +diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
4389 +index d2436880b305..d3f6c26425b3 100644
4390 +--- a/net/ceph/osdmap.c
4391 ++++ b/net/ceph/osdmap.c
4392 +@@ -1334,7 +1334,6 @@ static int decode_new_up_state_weight(void **p, void *end,
4393 + if ((map->osd_state[osd] & CEPH_OSD_EXISTS) &&
4394 + (xorstate & CEPH_OSD_EXISTS)) {
4395 + pr_info("osd%d does not exist\n", osd);
4396 +- map->osd_weight[osd] = CEPH_OSD_IN;
4397 + ret = set_primary_affinity(map, osd,
4398 + CEPH_OSD_DEFAULT_PRIMARY_AFFINITY);
4399 + if (ret)
4400 +diff --git a/net/core/dev.c b/net/core/dev.c
4401 +index fd6e2dfda45f..54f8c162ded8 100644
4402 +--- a/net/core/dev.c
4403 ++++ b/net/core/dev.c
4404 +@@ -4913,6 +4913,39 @@ void __napi_schedule(struct napi_struct *n)
4405 + EXPORT_SYMBOL(__napi_schedule);
4406 +
4407 + /**
4408 ++ * napi_schedule_prep - check if napi can be scheduled
4409 ++ * @n: napi context
4410 ++ *
4411 ++ * Test if NAPI routine is already running, and if not mark
4412 ++ * it as running. This is used as a condition variable
4413 ++ * insure only one NAPI poll instance runs. We also make
4414 ++ * sure there is no pending NAPI disable.
4415 ++ */
4416 ++bool napi_schedule_prep(struct napi_struct *n)
4417 ++{
4418 ++ unsigned long val, new;
4419 ++
4420 ++ do {
4421 ++ val = READ_ONCE(n->state);
4422 ++ if (unlikely(val & NAPIF_STATE_DISABLE))
4423 ++ return false;
4424 ++ new = val | NAPIF_STATE_SCHED;
4425 ++
4426 ++ /* Sets STATE_MISSED bit if STATE_SCHED was already set
4427 ++ * This was suggested by Alexander Duyck, as compiler
4428 ++ * emits better code than :
4429 ++ * if (val & NAPIF_STATE_SCHED)
4430 ++ * new |= NAPIF_STATE_MISSED;
4431 ++ */
4432 ++ new |= (val & NAPIF_STATE_SCHED) / NAPIF_STATE_SCHED *
4433 ++ NAPIF_STATE_MISSED;
4434 ++ } while (cmpxchg(&n->state, val, new) != val);
4435 ++
4436 ++ return !(val & NAPIF_STATE_SCHED);
4437 ++}
4438 ++EXPORT_SYMBOL(napi_schedule_prep);
4439 ++
4440 ++/**
4441 + * __napi_schedule_irqoff - schedule for receive
4442 + * @n: entry to schedule
4443 + *
4444 +@@ -4943,7 +4976,7 @@ EXPORT_SYMBOL(__napi_complete);
4445 +
4446 + bool napi_complete_done(struct napi_struct *n, int work_done)
4447 + {
4448 +- unsigned long flags;
4449 ++ unsigned long flags, val, new;
4450 +
4451 + /*
4452 + * 1) Don't let napi dequeue from the cpu poll list
4453 +@@ -4967,14 +5000,33 @@ bool napi_complete_done(struct napi_struct *n, int work_done)
4454 + else
4455 + napi_gro_flush(n, false);
4456 + }
4457 +- if (likely(list_empty(&n->poll_list))) {
4458 +- WARN_ON_ONCE(!test_and_clear_bit(NAPI_STATE_SCHED, &n->state));
4459 +- } else {
4460 ++ if (unlikely(!list_empty(&n->poll_list))) {
4461 + /* If n->poll_list is not empty, we need to mask irqs */
4462 + local_irq_save(flags);
4463 +- __napi_complete(n);
4464 ++ list_del_init(&n->poll_list);
4465 + local_irq_restore(flags);
4466 + }
4467 ++
4468 ++ do {
4469 ++ val = READ_ONCE(n->state);
4470 ++
4471 ++ WARN_ON_ONCE(!(val & NAPIF_STATE_SCHED));
4472 ++
4473 ++ new = val & ~(NAPIF_STATE_MISSED | NAPIF_STATE_SCHED);
4474 ++
4475 ++ /* If STATE_MISSED was set, leave STATE_SCHED set,
4476 ++ * because we will call napi->poll() one more time.
4477 ++ * This C code was suggested by Alexander Duyck to help gcc.
4478 ++ */
4479 ++ new |= (val & NAPIF_STATE_MISSED) / NAPIF_STATE_MISSED *
4480 ++ NAPIF_STATE_SCHED;
4481 ++ } while (cmpxchg(&n->state, val, new) != val);
4482 ++
4483 ++ if (unlikely(val & NAPIF_STATE_MISSED)) {
4484 ++ __napi_schedule(n);
4485 ++ return false;
4486 ++ }
4487 ++
4488 + return true;
4489 + }
4490 + EXPORT_SYMBOL(napi_complete_done);
4491 +@@ -5000,6 +5052,16 @@ static void busy_poll_stop(struct napi_struct *napi, void *have_poll_lock)
4492 + {
4493 + int rc;
4494 +
4495 ++ /* Busy polling means there is a high chance device driver hard irq
4496 ++ * could not grab NAPI_STATE_SCHED, and that NAPI_STATE_MISSED was
4497 ++ * set in napi_schedule_prep().
4498 ++ * Since we are about to call napi->poll() once more, we can safely
4499 ++ * clear NAPI_STATE_MISSED.
4500 ++ *
4501 ++ * Note: x86 could use a single "lock and ..." instruction
4502 ++ * to perform these two clear_bit()
4503 ++ */
4504 ++ clear_bit(NAPI_STATE_MISSED, &napi->state);
4505 + clear_bit(NAPI_STATE_IN_BUSY_POLL, &napi->state);
4506 +
4507 + local_bh_disable();
4508 +@@ -5146,8 +5208,13 @@ static enum hrtimer_restart napi_watchdog(struct hrtimer *timer)
4509 + struct napi_struct *napi;
4510 +
4511 + napi = container_of(timer, struct napi_struct, timer);
4512 +- if (napi->gro_list)
4513 +- napi_schedule(napi);
4514 ++
4515 ++ /* Note : we use a relaxed variant of napi_schedule_prep() not setting
4516 ++ * NAPI_STATE_MISSED, since we do not react to a device IRQ.
4517 ++ */
4518 ++ if (napi->gro_list && !napi_disable_pending(napi) &&
4519 ++ !test_and_set_bit(NAPI_STATE_SCHED, &napi->state))
4520 ++ __napi_schedule_irqoff(napi);
4521 +
4522 + return HRTIMER_NORESTART;
4523 + }
4524 +diff --git a/net/core/netclassid_cgroup.c b/net/core/netclassid_cgroup.c
4525 +index 11fce17274f6..46e8830c1979 100644
4526 +--- a/net/core/netclassid_cgroup.c
4527 ++++ b/net/core/netclassid_cgroup.c
4528 +@@ -69,27 +69,17 @@ static int update_classid_sock(const void *v, struct file *file, unsigned n)
4529 + return 0;
4530 + }
4531 +
4532 +-static void update_classid(struct cgroup_subsys_state *css, void *v)
4533 ++static void cgrp_attach(struct cgroup_taskset *tset)
4534 + {
4535 +- struct css_task_iter it;
4536 ++ struct cgroup_subsys_state *css;
4537 + struct task_struct *p;
4538 +
4539 +- css_task_iter_start(css, &it);
4540 +- while ((p = css_task_iter_next(&it))) {
4541 ++ cgroup_taskset_for_each(p, css, tset) {
4542 + task_lock(p);
4543 +- iterate_fd(p->files, 0, update_classid_sock, v);
4544 ++ iterate_fd(p->files, 0, update_classid_sock,
4545 ++ (void *)(unsigned long)css_cls_state(css)->classid);
4546 + task_unlock(p);
4547 + }
4548 +- css_task_iter_end(&it);
4549 +-}
4550 +-
4551 +-static void cgrp_attach(struct cgroup_taskset *tset)
4552 +-{
4553 +- struct cgroup_subsys_state *css;
4554 +-
4555 +- cgroup_taskset_first(tset, &css);
4556 +- update_classid(css,
4557 +- (void *)(unsigned long)css_cls_state(css)->classid);
4558 + }
4559 +
4560 + static u64 read_classid(struct cgroup_subsys_state *css, struct cftype *cft)
4561 +@@ -101,12 +91,22 @@ static int write_classid(struct cgroup_subsys_state *css, struct cftype *cft,
4562 + u64 value)
4563 + {
4564 + struct cgroup_cls_state *cs = css_cls_state(css);
4565 ++ struct css_task_iter it;
4566 ++ struct task_struct *p;
4567 +
4568 + cgroup_sk_alloc_disable();
4569 +
4570 + cs->classid = (u32)value;
4571 +
4572 +- update_classid(css, (void *)(unsigned long)cs->classid);
4573 ++ css_task_iter_start(css, &it);
4574 ++ while ((p = css_task_iter_next(&it))) {
4575 ++ task_lock(p);
4576 ++ iterate_fd(p->files, 0, update_classid_sock,
4577 ++ (void *)(unsigned long)cs->classid);
4578 ++ task_unlock(p);
4579 ++ }
4580 ++ css_task_iter_end(&it);
4581 ++
4582 + return 0;
4583 + }
4584 +
4585 +diff --git a/net/core/sock.c b/net/core/sock.c
4586 +index 4eca27dc5c94..4e7f10c92666 100644
4587 +--- a/net/core/sock.c
4588 ++++ b/net/core/sock.c
4589 +@@ -1444,6 +1444,11 @@ static void __sk_destruct(struct rcu_head *head)
4590 + pr_debug("%s: optmem leakage (%d bytes) detected\n",
4591 + __func__, atomic_read(&sk->sk_omem_alloc));
4592 +
4593 ++ if (sk->sk_frag.page) {
4594 ++ put_page(sk->sk_frag.page);
4595 ++ sk->sk_frag.page = NULL;
4596 ++ }
4597 ++
4598 + if (sk->sk_peer_cred)
4599 + put_cred(sk->sk_peer_cred);
4600 + put_pid(sk->sk_peer_pid);
4601 +@@ -1540,6 +1545,12 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
4602 + is_charged = sk_filter_charge(newsk, filter);
4603 +
4604 + if (unlikely(!is_charged || xfrm_sk_clone_policy(newsk, sk))) {
4605 ++ /* We need to make sure that we don't uncharge the new
4606 ++ * socket if we couldn't charge it in the first place
4607 ++ * as otherwise we uncharge the parent's filter.
4608 ++ */
4609 ++ if (!is_charged)
4610 ++ RCU_INIT_POINTER(newsk->sk_filter, NULL);
4611 + /* It is still raw copy of parent, so invalidate
4612 + * destructor and make plain sk_free() */
4613 + newsk->sk_destruct = NULL;
4614 +@@ -2774,11 +2785,6 @@ void sk_common_release(struct sock *sk)
4615 +
4616 + sk_refcnt_debug_release(sk);
4617 +
4618 +- if (sk->sk_frag.page) {
4619 +- put_page(sk->sk_frag.page);
4620 +- sk->sk_frag.page = NULL;
4621 +- }
4622 +-
4623 + sock_put(sk);
4624 + }
4625 + EXPORT_SYMBOL(sk_common_release);
4626 +diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
4627 +index b39a791f6756..091de0b93d5d 100644
4628 +--- a/net/ipv4/fib_frontend.c
4629 ++++ b/net/ipv4/fib_frontend.c
4630 +@@ -1082,7 +1082,8 @@ static void nl_fib_input(struct sk_buff *skb)
4631 +
4632 + net = sock_net(skb->sk);
4633 + nlh = nlmsg_hdr(skb);
4634 +- if (skb->len < NLMSG_HDRLEN || skb->len < nlh->nlmsg_len ||
4635 ++ if (skb->len < nlmsg_total_size(sizeof(*frn)) ||
4636 ++ skb->len < nlh->nlmsg_len ||
4637 + nlmsg_len(nlh) < sizeof(*frn))
4638 + return;
4639 +
4640 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
4641 +index 28777a0307c8..e7516efa99dc 100644
4642 +--- a/net/ipv4/tcp_input.c
4643 ++++ b/net/ipv4/tcp_input.c
4644 +@@ -5571,6 +5571,7 @@ void tcp_finish_connect(struct sock *sk, struct sk_buff *skb)
4645 + struct inet_connection_sock *icsk = inet_csk(sk);
4646 +
4647 + tcp_set_state(sk, TCP_ESTABLISHED);
4648 ++ icsk->icsk_ack.lrcvtime = tcp_time_stamp;
4649 +
4650 + if (skb) {
4651 + icsk->icsk_af_ops->sk_rx_dst_set(sk, skb);
4652 +@@ -5789,7 +5790,6 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
4653 + * to stand against the temptation 8) --ANK
4654 + */
4655 + inet_csk_schedule_ack(sk);
4656 +- icsk->icsk_ack.lrcvtime = tcp_time_stamp;
4657 + tcp_enter_quickack_mode(sk);
4658 + inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
4659 + TCP_DELACK_MAX, TCP_RTO_MAX);
4660 +diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
4661 +index 28ce5ee831f5..80ff517a7542 100644
4662 +--- a/net/ipv4/tcp_minisocks.c
4663 ++++ b/net/ipv4/tcp_minisocks.c
4664 +@@ -466,6 +466,7 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
4665 + newtp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT);
4666 + minmax_reset(&newtp->rtt_min, tcp_time_stamp, ~0U);
4667 + newicsk->icsk_rto = TCP_TIMEOUT_INIT;
4668 ++ newicsk->icsk_ack.lrcvtime = tcp_time_stamp;
4669 +
4670 + newtp->packets_out = 0;
4671 + newtp->retrans_out = 0;
4672 +diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
4673 +index 221825a9407a..0770f95f5e1c 100644
4674 +--- a/net/ipv6/udp.c
4675 ++++ b/net/ipv6/udp.c
4676 +@@ -1022,6 +1022,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
4677 + ipc6.hlimit = -1;
4678 + ipc6.tclass = -1;
4679 + ipc6.dontfrag = -1;
4680 ++ sockc.tsflags = sk->sk_tsflags;
4681 +
4682 + /* destination address check */
4683 + if (sin6) {
4684 +@@ -1146,7 +1147,6 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
4685 +
4686 + fl6.flowi6_mark = sk->sk_mark;
4687 + fl6.flowi6_uid = sk->sk_uid;
4688 +- sockc.tsflags = sk->sk_tsflags;
4689 +
4690 + if (msg->msg_controllen) {
4691 + opt = &opt_space;
4692 +diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
4693 +index fb6e10fdb217..92e0981f7404 100644
4694 +--- a/net/netlink/genetlink.c
4695 ++++ b/net/netlink/genetlink.c
4696 +@@ -783,8 +783,10 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
4697 +
4698 + if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).portid,
4699 + cb->nlh->nlmsg_seq, NLM_F_MULTI,
4700 +- skb, CTRL_CMD_NEWFAMILY) < 0)
4701 ++ skb, CTRL_CMD_NEWFAMILY) < 0) {
4702 ++ n--;
4703 + break;
4704 ++ }
4705 + }
4706 +
4707 + cb->args[0] = n;
4708 +diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
4709 +index c87d359b9b37..256e8f1450fd 100644
4710 +--- a/net/openvswitch/flow_netlink.c
4711 ++++ b/net/openvswitch/flow_netlink.c
4712 +@@ -588,7 +588,7 @@ static int ip_tun_from_nlattr(const struct nlattr *attr,
4713 + ipv4 = true;
4714 + break;
4715 + case OVS_TUNNEL_KEY_ATTR_IPV6_SRC:
4716 +- SW_FLOW_KEY_PUT(match, tun_key.u.ipv6.dst,
4717 ++ SW_FLOW_KEY_PUT(match, tun_key.u.ipv6.src,
4718 + nla_get_in6_addr(a), is_mask);
4719 + ipv6 = true;
4720 + break;
4721 +@@ -649,6 +649,8 @@ static int ip_tun_from_nlattr(const struct nlattr *attr,
4722 + tun_flags |= TUNNEL_VXLAN_OPT;
4723 + opts_type = type;
4724 + break;
4725 ++ case OVS_TUNNEL_KEY_ATTR_PAD:
4726 ++ break;
4727 + default:
4728 + OVS_NLERR(log, "Unknown IP tunnel attribute %d",
4729 + type);
4730 +diff --git a/net/unix/garbage.c b/net/unix/garbage.c
4731 +index 6a0d48525fcf..c36757e72844 100644
4732 +--- a/net/unix/garbage.c
4733 ++++ b/net/unix/garbage.c
4734 +@@ -146,6 +146,7 @@ void unix_notinflight(struct user_struct *user, struct file *fp)
4735 + if (s) {
4736 + struct unix_sock *u = unix_sk(s);
4737 +
4738 ++ BUG_ON(!atomic_long_read(&u->inflight));
4739 + BUG_ON(list_empty(&u->link));
4740 +
4741 + if (atomic_long_dec_and_test(&u->inflight))
4742 +@@ -341,6 +342,14 @@ void unix_gc(void)
4743 + }
4744 + list_del(&cursor);
4745 +
4746 ++ /* Now gc_candidates contains only garbage. Restore original
4747 ++ * inflight counters for these as well, and remove the skbuffs
4748 ++ * which are creating the cycle(s).
4749 ++ */
4750 ++ skb_queue_head_init(&hitlist);
4751 ++ list_for_each_entry(u, &gc_candidates, link)
4752 ++ scan_children(&u->sk, inc_inflight, &hitlist);
4753 ++
4754 + /* not_cycle_list contains those sockets which do not make up a
4755 + * cycle. Restore these to the inflight list.
4756 + */
4757 +@@ -350,14 +359,6 @@ void unix_gc(void)
4758 + list_move_tail(&u->link, &gc_inflight_list);
4759 + }
4760 +
4761 +- /* Now gc_candidates contains only garbage. Restore original
4762 +- * inflight counters for these as well, and remove the skbuffs
4763 +- * which are creating the cycle(s).
4764 +- */
4765 +- skb_queue_head_init(&hitlist);
4766 +- list_for_each_entry(u, &gc_candidates, link)
4767 +- scan_children(&u->sk, inc_inflight, &hitlist);
4768 +-
4769 + spin_unlock(&unix_gc_lock);
4770 +
4771 + /* Here we are. Hitlist is filled. Die. */
4772 +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
4773 +index aee396b9f190..c1081a6e31ef 100644
4774 +--- a/net/wireless/nl80211.c
4775 ++++ b/net/wireless/nl80211.c
4776 +@@ -540,22 +540,18 @@ static int nl80211_prepare_wdev_dump(struct sk_buff *skb,
4777 + {
4778 + int err;
4779 +
4780 +- rtnl_lock();
4781 +-
4782 + if (!cb->args[0]) {
4783 + err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
4784 + genl_family_attrbuf(&nl80211_fam),
4785 + nl80211_fam.maxattr, nl80211_policy);
4786 + if (err)
4787 +- goto out_unlock;
4788 ++ return err;
4789 +
4790 + *wdev = __cfg80211_wdev_from_attrs(
4791 + sock_net(skb->sk),
4792 + genl_family_attrbuf(&nl80211_fam));
4793 +- if (IS_ERR(*wdev)) {
4794 +- err = PTR_ERR(*wdev);
4795 +- goto out_unlock;
4796 +- }
4797 ++ if (IS_ERR(*wdev))
4798 ++ return PTR_ERR(*wdev);
4799 + *rdev = wiphy_to_rdev((*wdev)->wiphy);
4800 + /* 0 is the first index - add 1 to parse only once */
4801 + cb->args[0] = (*rdev)->wiphy_idx + 1;
4802 +@@ -565,10 +561,8 @@ static int nl80211_prepare_wdev_dump(struct sk_buff *skb,
4803 + struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1);
4804 + struct wireless_dev *tmp;
4805 +
4806 +- if (!wiphy) {
4807 +- err = -ENODEV;
4808 +- goto out_unlock;
4809 +- }
4810 ++ if (!wiphy)
4811 ++ return -ENODEV;
4812 + *rdev = wiphy_to_rdev(wiphy);
4813 + *wdev = NULL;
4814 +
4815 +@@ -579,21 +573,11 @@ static int nl80211_prepare_wdev_dump(struct sk_buff *skb,
4816 + }
4817 + }
4818 +
4819 +- if (!*wdev) {
4820 +- err = -ENODEV;
4821 +- goto out_unlock;
4822 +- }
4823 ++ if (!*wdev)
4824 ++ return -ENODEV;
4825 + }
4826 +
4827 + return 0;
4828 +- out_unlock:
4829 +- rtnl_unlock();
4830 +- return err;
4831 +-}
4832 +-
4833 +-static void nl80211_finish_wdev_dump(struct cfg80211_registered_device *rdev)
4834 +-{
4835 +- rtnl_unlock();
4836 + }
4837 +
4838 + /* IE validation */
4839 +@@ -2599,17 +2583,17 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback *
4840 + int filter_wiphy = -1;
4841 + struct cfg80211_registered_device *rdev;
4842 + struct wireless_dev *wdev;
4843 ++ int ret;
4844 +
4845 + rtnl_lock();
4846 + if (!cb->args[2]) {
4847 + struct nl80211_dump_wiphy_state state = {
4848 + .filter_wiphy = -1,
4849 + };
4850 +- int ret;
4851 +
4852 + ret = nl80211_dump_wiphy_parse(skb, cb, &state);
4853 + if (ret)
4854 +- return ret;
4855 ++ goto out_unlock;
4856 +
4857 + filter_wiphy = state.filter_wiphy;
4858 +
4859 +@@ -2654,12 +2638,14 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback *
4860 + wp_idx++;
4861 + }
4862 + out:
4863 +- rtnl_unlock();
4864 +-
4865 + cb->args[0] = wp_idx;
4866 + cb->args[1] = if_idx;
4867 +
4868 +- return skb->len;
4869 ++ ret = skb->len;
4870 ++ out_unlock:
4871 ++ rtnl_unlock();
4872 ++
4873 ++ return ret;
4874 + }
4875 +
4876 + static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info)
4877 +@@ -4398,9 +4384,10 @@ static int nl80211_dump_station(struct sk_buff *skb,
4878 + int sta_idx = cb->args[2];
4879 + int err;
4880 +
4881 ++ rtnl_lock();
4882 + err = nl80211_prepare_wdev_dump(skb, cb, &rdev, &wdev);
4883 + if (err)
4884 +- return err;
4885 ++ goto out_err;
4886 +
4887 + if (!wdev->netdev) {
4888 + err = -EINVAL;
4889 +@@ -4435,7 +4422,7 @@ static int nl80211_dump_station(struct sk_buff *skb,
4890 + cb->args[2] = sta_idx;
4891 + err = skb->len;
4892 + out_err:
4893 +- nl80211_finish_wdev_dump(rdev);
4894 ++ rtnl_unlock();
4895 +
4896 + return err;
4897 + }
4898 +@@ -5221,9 +5208,10 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
4899 + int path_idx = cb->args[2];
4900 + int err;
4901 +
4902 ++ rtnl_lock();
4903 + err = nl80211_prepare_wdev_dump(skb, cb, &rdev, &wdev);
4904 + if (err)
4905 +- return err;
4906 ++ goto out_err;
4907 +
4908 + if (!rdev->ops->dump_mpath) {
4909 + err = -EOPNOTSUPP;
4910 +@@ -5256,7 +5244,7 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
4911 + cb->args[2] = path_idx;
4912 + err = skb->len;
4913 + out_err:
4914 +- nl80211_finish_wdev_dump(rdev);
4915 ++ rtnl_unlock();
4916 + return err;
4917 + }
4918 +
4919 +@@ -5416,9 +5404,10 @@ static int nl80211_dump_mpp(struct sk_buff *skb,
4920 + int path_idx = cb->args[2];
4921 + int err;
4922 +
4923 ++ rtnl_lock();
4924 + err = nl80211_prepare_wdev_dump(skb, cb, &rdev, &wdev);
4925 + if (err)
4926 +- return err;
4927 ++ goto out_err;
4928 +
4929 + if (!rdev->ops->dump_mpp) {
4930 + err = -EOPNOTSUPP;
4931 +@@ -5451,7 +5440,7 @@ static int nl80211_dump_mpp(struct sk_buff *skb,
4932 + cb->args[2] = path_idx;
4933 + err = skb->len;
4934 + out_err:
4935 +- nl80211_finish_wdev_dump(rdev);
4936 ++ rtnl_unlock();
4937 + return err;
4938 + }
4939 +
4940 +@@ -7596,9 +7585,12 @@ static int nl80211_dump_scan(struct sk_buff *skb, struct netlink_callback *cb)
4941 + int start = cb->args[2], idx = 0;
4942 + int err;
4943 +
4944 ++ rtnl_lock();
4945 + err = nl80211_prepare_wdev_dump(skb, cb, &rdev, &wdev);
4946 +- if (err)
4947 ++ if (err) {
4948 ++ rtnl_unlock();
4949 + return err;
4950 ++ }
4951 +
4952 + wdev_lock(wdev);
4953 + spin_lock_bh(&rdev->bss_lock);
4954 +@@ -7621,7 +7613,7 @@ static int nl80211_dump_scan(struct sk_buff *skb, struct netlink_callback *cb)
4955 + wdev_unlock(wdev);
4956 +
4957 + cb->args[2] = idx;
4958 +- nl80211_finish_wdev_dump(rdev);
4959 ++ rtnl_unlock();
4960 +
4961 + return skb->len;
4962 + }
4963 +@@ -7706,9 +7698,10 @@ static int nl80211_dump_survey(struct sk_buff *skb, struct netlink_callback *cb)
4964 + int res;
4965 + bool radio_stats;
4966 +
4967 ++ rtnl_lock();
4968 + res = nl80211_prepare_wdev_dump(skb, cb, &rdev, &wdev);
4969 + if (res)
4970 +- return res;
4971 ++ goto out_err;
4972 +
4973 + /* prepare_wdev_dump parsed the attributes */
4974 + radio_stats = attrbuf[NL80211_ATTR_SURVEY_RADIO_STATS];
4975 +@@ -7749,7 +7742,7 @@ static int nl80211_dump_survey(struct sk_buff *skb, struct netlink_callback *cb)
4976 + cb->args[2] = survey_idx;
4977 + res = skb->len;
4978 + out_err:
4979 +- nl80211_finish_wdev_dump(rdev);
4980 ++ rtnl_unlock();
4981 + return res;
4982 + }
4983 +
4984 +@@ -11378,17 +11371,13 @@ static int nl80211_prepare_vendor_dump(struct sk_buff *skb,
4985 + void *data = NULL;
4986 + unsigned int data_len = 0;
4987 +
4988 +- rtnl_lock();
4989 +-
4990 + if (cb->args[0]) {
4991 + /* subtract the 1 again here */
4992 + struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1);
4993 + struct wireless_dev *tmp;
4994 +
4995 +- if (!wiphy) {
4996 +- err = -ENODEV;
4997 +- goto out_unlock;
4998 +- }
4999 ++ if (!wiphy)
5000 ++ return -ENODEV;
5001 + *rdev = wiphy_to_rdev(wiphy);
5002 + *wdev = NULL;
5003 +
5004 +@@ -11408,23 +11397,19 @@ static int nl80211_prepare_vendor_dump(struct sk_buff *skb,
5005 + err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
5006 + attrbuf, nl80211_fam.maxattr, nl80211_policy);
5007 + if (err)
5008 +- goto out_unlock;
5009 ++ return err;
5010 +
5011 + if (!attrbuf[NL80211_ATTR_VENDOR_ID] ||
5012 +- !attrbuf[NL80211_ATTR_VENDOR_SUBCMD]) {
5013 +- err = -EINVAL;
5014 +- goto out_unlock;
5015 +- }
5016 ++ !attrbuf[NL80211_ATTR_VENDOR_SUBCMD])
5017 ++ return -EINVAL;
5018 +
5019 + *wdev = __cfg80211_wdev_from_attrs(sock_net(skb->sk), attrbuf);
5020 + if (IS_ERR(*wdev))
5021 + *wdev = NULL;
5022 +
5023 + *rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk), attrbuf);
5024 +- if (IS_ERR(*rdev)) {
5025 +- err = PTR_ERR(*rdev);
5026 +- goto out_unlock;
5027 +- }
5028 ++ if (IS_ERR(*rdev))
5029 ++ return PTR_ERR(*rdev);
5030 +
5031 + vid = nla_get_u32(attrbuf[NL80211_ATTR_VENDOR_ID]);
5032 + subcmd = nla_get_u32(attrbuf[NL80211_ATTR_VENDOR_SUBCMD]);
5033 +@@ -11437,19 +11422,15 @@ static int nl80211_prepare_vendor_dump(struct sk_buff *skb,
5034 + if (vcmd->info.vendor_id != vid || vcmd->info.subcmd != subcmd)
5035 + continue;
5036 +
5037 +- if (!vcmd->dumpit) {
5038 +- err = -EOPNOTSUPP;
5039 +- goto out_unlock;
5040 +- }
5041 ++ if (!vcmd->dumpit)
5042 ++ return -EOPNOTSUPP;
5043 +
5044 + vcmd_idx = i;
5045 + break;
5046 + }
5047 +
5048 +- if (vcmd_idx < 0) {
5049 +- err = -EOPNOTSUPP;
5050 +- goto out_unlock;
5051 +- }
5052 ++ if (vcmd_idx < 0)
5053 ++ return -EOPNOTSUPP;
5054 +
5055 + if (attrbuf[NL80211_ATTR_VENDOR_DATA]) {
5056 + data = nla_data(attrbuf[NL80211_ATTR_VENDOR_DATA]);
5057 +@@ -11466,9 +11447,6 @@ static int nl80211_prepare_vendor_dump(struct sk_buff *skb,
5058 +
5059 + /* keep rtnl locked in successful case */
5060 + return 0;
5061 +- out_unlock:
5062 +- rtnl_unlock();
5063 +- return err;
5064 + }
5065 +
5066 + static int nl80211_vendor_cmd_dump(struct sk_buff *skb,
5067 +@@ -11483,9 +11461,10 @@ static int nl80211_vendor_cmd_dump(struct sk_buff *skb,
5068 + int err;
5069 + struct nlattr *vendor_data;
5070 +
5071 ++ rtnl_lock();
5072 + err = nl80211_prepare_vendor_dump(skb, cb, &rdev, &wdev);
5073 + if (err)
5074 +- return err;
5075 ++ goto out;
5076 +
5077 + vcmd_idx = cb->args[2];
5078 + data = (void *)cb->args[3];
5079 +@@ -11494,15 +11473,21 @@ static int nl80211_vendor_cmd_dump(struct sk_buff *skb,
5080 +
5081 + if (vcmd->flags & (WIPHY_VENDOR_CMD_NEED_WDEV |
5082 + WIPHY_VENDOR_CMD_NEED_NETDEV)) {
5083 +- if (!wdev)
5084 +- return -EINVAL;
5085 ++ if (!wdev) {
5086 ++ err = -EINVAL;
5087 ++ goto out;
5088 ++ }
5089 + if (vcmd->flags & WIPHY_VENDOR_CMD_NEED_NETDEV &&
5090 +- !wdev->netdev)
5091 +- return -EINVAL;
5092 ++ !wdev->netdev) {
5093 ++ err = -EINVAL;
5094 ++ goto out;
5095 ++ }
5096 +
5097 + if (vcmd->flags & WIPHY_VENDOR_CMD_NEED_RUNNING) {
5098 +- if (!wdev_running(wdev))
5099 +- return -ENETDOWN;
5100 ++ if (!wdev_running(wdev)) {
5101 ++ err = -ENETDOWN;
5102 ++ goto out;
5103 ++ }
5104 + }
5105 + }
5106 +
5107 +diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
5108 +index 4c935202ce23..f3b1d7f50b81 100644
5109 +--- a/sound/core/seq/seq_clientmgr.c
5110 ++++ b/sound/core/seq/seq_clientmgr.c
5111 +@@ -1832,6 +1832,7 @@ static int snd_seq_ioctl_set_client_pool(struct snd_seq_client *client,
5112 + info->output_pool != client->pool->size)) {
5113 + if (snd_seq_write_pool_allocated(client)) {
5114 + /* remove all existing cells */
5115 ++ snd_seq_pool_mark_closing(client->pool);
5116 + snd_seq_queue_client_leave_cells(client->number);
5117 + snd_seq_pool_done(client->pool);
5118 + }
5119 +diff --git a/sound/core/seq/seq_fifo.c b/sound/core/seq/seq_fifo.c
5120 +index 86240d02b530..3f4efcb85df5 100644
5121 +--- a/sound/core/seq/seq_fifo.c
5122 ++++ b/sound/core/seq/seq_fifo.c
5123 +@@ -70,6 +70,9 @@ void snd_seq_fifo_delete(struct snd_seq_fifo **fifo)
5124 + return;
5125 + *fifo = NULL;
5126 +
5127 ++ if (f->pool)
5128 ++ snd_seq_pool_mark_closing(f->pool);
5129 ++
5130 + snd_seq_fifo_clear(f);
5131 +
5132 + /* wake up clients if any */
5133 +diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c
5134 +index dfa5156f3585..5847c4475bf3 100644
5135 +--- a/sound/core/seq/seq_memory.c
5136 ++++ b/sound/core/seq/seq_memory.c
5137 +@@ -414,6 +414,18 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
5138 + return 0;
5139 + }
5140 +
5141 ++/* refuse the further insertion to the pool */
5142 ++void snd_seq_pool_mark_closing(struct snd_seq_pool *pool)
5143 ++{
5144 ++ unsigned long flags;
5145 ++
5146 ++ if (snd_BUG_ON(!pool))
5147 ++ return;
5148 ++ spin_lock_irqsave(&pool->lock, flags);
5149 ++ pool->closing = 1;
5150 ++ spin_unlock_irqrestore(&pool->lock, flags);
5151 ++}
5152 ++
5153 + /* remove events */
5154 + int snd_seq_pool_done(struct snd_seq_pool *pool)
5155 + {
5156 +@@ -424,10 +436,6 @@ int snd_seq_pool_done(struct snd_seq_pool *pool)
5157 + return -EINVAL;
5158 +
5159 + /* wait for closing all threads */
5160 +- spin_lock_irqsave(&pool->lock, flags);
5161 +- pool->closing = 1;
5162 +- spin_unlock_irqrestore(&pool->lock, flags);
5163 +-
5164 + if (waitqueue_active(&pool->output_sleep))
5165 + wake_up(&pool->output_sleep);
5166 +
5167 +@@ -484,6 +492,7 @@ int snd_seq_pool_delete(struct snd_seq_pool **ppool)
5168 + *ppool = NULL;
5169 + if (pool == NULL)
5170 + return 0;
5171 ++ snd_seq_pool_mark_closing(pool);
5172 + snd_seq_pool_done(pool);
5173 + kfree(pool);
5174 + return 0;
5175 +diff --git a/sound/core/seq/seq_memory.h b/sound/core/seq/seq_memory.h
5176 +index 4a2ec779b8a7..32f959c17786 100644
5177 +--- a/sound/core/seq/seq_memory.h
5178 ++++ b/sound/core/seq/seq_memory.h
5179 +@@ -84,6 +84,7 @@ static inline int snd_seq_total_cells(struct snd_seq_pool *pool)
5180 + int snd_seq_pool_init(struct snd_seq_pool *pool);
5181 +
5182 + /* done pool - free events */
5183 ++void snd_seq_pool_mark_closing(struct snd_seq_pool *pool);
5184 + int snd_seq_pool_done(struct snd_seq_pool *pool);
5185 +
5186 + /* create pool */
5187 +diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c
5188 +index ab4cdab5cfa5..79edd88d5cd0 100644
5189 +--- a/sound/pci/ctxfi/cthw20k1.c
5190 ++++ b/sound/pci/ctxfi/cthw20k1.c
5191 +@@ -1905,7 +1905,7 @@ static int hw_card_start(struct hw *hw)
5192 + return err;
5193 +
5194 + /* Set DMA transfer mask */
5195 +- if (dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
5196 ++ if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
5197 + dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
5198 + } else {
5199 + dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
5200 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
5201 +index 6b041f7268fb..c813ad857650 100644
5202 +--- a/sound/pci/hda/patch_realtek.c
5203 ++++ b/sound/pci/hda/patch_realtek.c
5204 +@@ -6058,6 +6058,8 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
5205 + ALC295_STANDARD_PINS,
5206 + {0x17, 0x21014040},
5207 + {0x18, 0x21a19050}),
5208 ++ SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5209 ++ ALC295_STANDARD_PINS),
5210 + SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
5211 + ALC298_STANDARD_PINS,
5212 + {0x17, 0x90170110}),