Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.4 commit in: /
Date: Thu, 22 Mar 2018 12:54:13
Message-Id: 1521723236.3df32cd6e72e69dac4427b5af02ebc4d6e799c8b.mpagano@gentoo
1 commit: 3df32cd6e72e69dac4427b5af02ebc4d6e799c8b
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Thu Mar 22 12:53:56 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Thu Mar 22 12:53:56 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=3df32cd6
7
8 Linux patch 4.4.122 and 4.4.123
9
10 0000_README | 8 +
11 1121_linux-4.4.122.patch | 2177 ++++++++++++++++++++++++++++
12 1122_linux-4.4.123.patch | 3500 ++++++++++++++++++++++++++++++++++++++++++++++
13 3 files changed, 5685 insertions(+)
14
15 diff --git a/0000_README b/0000_README
16 index 617be60..992f353 100644
17 --- a/0000_README
18 +++ b/0000_README
19 @@ -527,6 +527,14 @@ Patch: 1120_linux-4.4.121.patch
20 From: http://www.kernel.org
21 Desc: Linux 4.4.121
22
23 +Patch: 1121_linux-4.4.122.patch
24 +From: http://www.kernel.org
25 +Desc: Linux 4.4.122
26 +
27 +Patch: 1122_linux-4.4.123.patch
28 +From: http://www.kernel.org
29 +Desc: Linux 4.4.123
30 +
31 Patch: 1500_XATTR_USER_PREFIX.patch
32 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
33 Desc: Support for namespace user.pax.* on tmpfs.
34
35 diff --git a/1121_linux-4.4.122.patch b/1121_linux-4.4.122.patch
36 new file mode 100644
37 index 0000000..1488cb1
38 --- /dev/null
39 +++ b/1121_linux-4.4.122.patch
40 @@ -0,0 +1,2177 @@
41 +diff --git a/Makefile b/Makefile
42 +index 0e22e4eb85cc..3eb21d269b42 100644
43 +--- a/Makefile
44 ++++ b/Makefile
45 +@@ -1,6 +1,6 @@
46 + VERSION = 4
47 + PATCHLEVEL = 4
48 +-SUBLEVEL = 121
49 ++SUBLEVEL = 122
50 + EXTRAVERSION =
51 + NAME = Blurry Fish Butt
52 +
53 +diff --git a/arch/arm/boot/dts/logicpd-torpedo-som.dtsi b/arch/arm/boot/dts/logicpd-torpedo-som.dtsi
54 +index 5562c5feb0be..80f6c786a37e 100644
55 +--- a/arch/arm/boot/dts/logicpd-torpedo-som.dtsi
56 ++++ b/arch/arm/boot/dts/logicpd-torpedo-som.dtsi
57 +@@ -90,8 +90,6 @@
58 + };
59 +
60 + &i2c1 {
61 +- pinctrl-names = "default";
62 +- pinctrl-0 = <&i2c1_pins>;
63 + clock-frequency = <2600000>;
64 +
65 + twl: twl@48 {
66 +@@ -148,12 +146,6 @@
67 + OMAP3630_CORE2_IOPAD(0x25da, PIN_INPUT_PULLUP | MUX_MODE2) /* etk_ctl.sdmmc3_cmd */
68 + >;
69 + };
70 +- i2c1_pins: pinmux_i2c1_pins {
71 +- pinctrl-single,pins = <
72 +- OMAP3_CORE1_IOPAD(0x21ba, PIN_INPUT | MUX_MODE0) /* i2c1_scl.i2c1_scl */
73 +- OMAP3_CORE1_IOPAD(0x21bc, PIN_INPUT | MUX_MODE0) /* i2c1_sda.i2c1_sda */
74 +- >;
75 +- };
76 + };
77 +
78 + #include "twl4030.dtsi"
79 +diff --git a/arch/arm/mach-omap2/omap-secure.c b/arch/arm/mach-omap2/omap-secure.c
80 +index 9ff92050053c..fa7f308c9027 100644
81 +--- a/arch/arm/mach-omap2/omap-secure.c
82 ++++ b/arch/arm/mach-omap2/omap-secure.c
83 +@@ -73,6 +73,7 @@ phys_addr_t omap_secure_ram_mempool_base(void)
84 + return omap_secure_memblock_base;
85 + }
86 +
87 ++#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
88 + u32 omap3_save_secure_ram(void __iomem *addr, int size)
89 + {
90 + u32 ret;
91 +@@ -91,6 +92,7 @@ u32 omap3_save_secure_ram(void __iomem *addr, int size)
92 +
93 + return ret;
94 + }
95 ++#endif
96 +
97 + /**
98 + * rx51_secure_dispatcher: Routine to dispatch secure PPA API calls
99 +diff --git a/arch/mips/ath25/board.c b/arch/mips/ath25/board.c
100 +index 9ab48ff80c1c..6d11ae581ea7 100644
101 +--- a/arch/mips/ath25/board.c
102 ++++ b/arch/mips/ath25/board.c
103 +@@ -135,6 +135,8 @@ int __init ath25_find_config(phys_addr_t base, unsigned long size)
104 + }
105 +
106 + board_data = kzalloc(BOARD_CONFIG_BUFSZ, GFP_KERNEL);
107 ++ if (!board_data)
108 ++ goto error;
109 + ath25_board.config = (struct ath25_boarddata *)board_data;
110 + memcpy_fromio(board_data, bcfg, 0x100);
111 + if (broken_boarddata) {
112 +diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
113 +index 4f9eb0576884..10d0b2140375 100644
114 +--- a/arch/mips/cavium-octeon/octeon-irq.c
115 ++++ b/arch/mips/cavium-octeon/octeon-irq.c
116 +@@ -2246,6 +2246,8 @@ static int __init octeon_irq_init_cib(struct device_node *ciu_node,
117 + }
118 +
119 + host_data = kzalloc(sizeof(*host_data), GFP_KERNEL);
120 ++ if (!host_data)
121 ++ return -ENOMEM;
122 + raw_spin_lock_init(&host_data->lock);
123 +
124 + addr = of_get_address(ciu_node, 0, NULL, NULL);
125 +diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c
126 +index 78cf8c2f1de0..4874712b475e 100644
127 +--- a/arch/mips/kernel/smp-bmips.c
128 ++++ b/arch/mips/kernel/smp-bmips.c
129 +@@ -166,11 +166,11 @@ static void bmips_prepare_cpus(unsigned int max_cpus)
130 + return;
131 + }
132 +
133 +- if (request_irq(IPI0_IRQ, bmips_ipi_interrupt, IRQF_PERCPU,
134 +- "smp_ipi0", NULL))
135 ++ if (request_irq(IPI0_IRQ, bmips_ipi_interrupt,
136 ++ IRQF_PERCPU | IRQF_NO_SUSPEND, "smp_ipi0", NULL))
137 + panic("Can't request IPI0 interrupt");
138 +- if (request_irq(IPI1_IRQ, bmips_ipi_interrupt, IRQF_PERCPU,
139 +- "smp_ipi1", NULL))
140 ++ if (request_irq(IPI1_IRQ, bmips_ipi_interrupt,
141 ++ IRQF_PERCPU | IRQF_NO_SUSPEND, "smp_ipi1", NULL))
142 + panic("Can't request IPI1 interrupt");
143 + }
144 +
145 +diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
146 +index 364fbad72e60..6edb9530d7e9 100644
147 +--- a/arch/x86/kernel/cpu/mcheck/mce.c
148 ++++ b/arch/x86/kernel/cpu/mcheck/mce.c
149 +@@ -60,6 +60,9 @@ static DEFINE_MUTEX(mce_chrdev_read_mutex);
150 + smp_load_acquire(&(p)); \
151 + })
152 +
153 ++/* sysfs synchronization */
154 ++static DEFINE_MUTEX(mce_sysfs_mutex);
155 ++
156 + #define CREATE_TRACE_POINTS
157 + #include <trace/events/mce.h>
158 +
159 +@@ -2220,6 +2223,7 @@ static ssize_t set_ignore_ce(struct device *s,
160 + if (kstrtou64(buf, 0, &new) < 0)
161 + return -EINVAL;
162 +
163 ++ mutex_lock(&mce_sysfs_mutex);
164 + if (mca_cfg.ignore_ce ^ !!new) {
165 + if (new) {
166 + /* disable ce features */
167 +@@ -2232,6 +2236,8 @@ static ssize_t set_ignore_ce(struct device *s,
168 + on_each_cpu(mce_enable_ce, (void *)1, 1);
169 + }
170 + }
171 ++ mutex_unlock(&mce_sysfs_mutex);
172 ++
173 + return size;
174 + }
175 +
176 +@@ -2244,6 +2250,7 @@ static ssize_t set_cmci_disabled(struct device *s,
177 + if (kstrtou64(buf, 0, &new) < 0)
178 + return -EINVAL;
179 +
180 ++ mutex_lock(&mce_sysfs_mutex);
181 + if (mca_cfg.cmci_disabled ^ !!new) {
182 + if (new) {
183 + /* disable cmci */
184 +@@ -2255,6 +2262,8 @@ static ssize_t set_cmci_disabled(struct device *s,
185 + on_each_cpu(mce_enable_ce, NULL, 1);
186 + }
187 + }
188 ++ mutex_unlock(&mce_sysfs_mutex);
189 ++
190 + return size;
191 + }
192 +
193 +@@ -2262,8 +2271,19 @@ static ssize_t store_int_with_restart(struct device *s,
194 + struct device_attribute *attr,
195 + const char *buf, size_t size)
196 + {
197 +- ssize_t ret = device_store_int(s, attr, buf, size);
198 ++ unsigned long old_check_interval = check_interval;
199 ++ ssize_t ret = device_store_ulong(s, attr, buf, size);
200 ++
201 ++ if (check_interval == old_check_interval)
202 ++ return ret;
203 ++
204 ++ if (check_interval < 1)
205 ++ check_interval = 1;
206 ++
207 ++ mutex_lock(&mce_sysfs_mutex);
208 + mce_restart();
209 ++ mutex_unlock(&mce_sysfs_mutex);
210 ++
211 + return ret;
212 + }
213 +
214 +diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
215 +index 819ab3f9c9c7..ca6e65250b1a 100644
216 +--- a/arch/x86/kernel/machine_kexec_64.c
217 ++++ b/arch/x86/kernel/machine_kexec_64.c
218 +@@ -519,6 +519,7 @@ int arch_kexec_apply_relocations_add(const Elf64_Ehdr *ehdr,
219 + goto overflow;
220 + break;
221 + case R_X86_64_PC32:
222 ++ case R_X86_64_PLT32:
223 + value -= (u64)address;
224 + *(u32 *)location = value;
225 + break;
226 +diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
227 +index 005c03e93fc5..94779f66bf49 100644
228 +--- a/arch/x86/kernel/module.c
229 ++++ b/arch/x86/kernel/module.c
230 +@@ -170,19 +170,28 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
231 + case R_X86_64_NONE:
232 + break;
233 + case R_X86_64_64:
234 ++ if (*(u64 *)loc != 0)
235 ++ goto invalid_relocation;
236 + *(u64 *)loc = val;
237 + break;
238 + case R_X86_64_32:
239 ++ if (*(u32 *)loc != 0)
240 ++ goto invalid_relocation;
241 + *(u32 *)loc = val;
242 + if (val != *(u32 *)loc)
243 + goto overflow;
244 + break;
245 + case R_X86_64_32S:
246 ++ if (*(s32 *)loc != 0)
247 ++ goto invalid_relocation;
248 + *(s32 *)loc = val;
249 + if ((s64)val != *(s32 *)loc)
250 + goto overflow;
251 + break;
252 + case R_X86_64_PC32:
253 ++ case R_X86_64_PLT32:
254 ++ if (*(u32 *)loc != 0)
255 ++ goto invalid_relocation;
256 + val -= (u64)loc;
257 + *(u32 *)loc = val;
258 + #if 0
259 +@@ -198,6 +207,11 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
260 + }
261 + return 0;
262 +
263 ++invalid_relocation:
264 ++ pr_err("x86/modules: Skipping invalid relocation target, existing value is nonzero for type %d, loc %p, val %Lx\n",
265 ++ (int)ELF64_R_TYPE(rel[i].r_info), loc, val);
266 ++ return -ENOEXEC;
267 ++
268 + overflow:
269 + pr_err("overflow in relocation type %d val %Lx\n",
270 + (int)ELF64_R_TYPE(rel[i].r_info), val);
271 +diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
272 +index 73eb7fd4aec4..5b6c8486a0be 100644
273 +--- a/arch/x86/tools/relocs.c
274 ++++ b/arch/x86/tools/relocs.c
275 +@@ -769,9 +769,12 @@ static int do_reloc64(struct section *sec, Elf_Rel *rel, ElfW(Sym) *sym,
276 + break;
277 +
278 + case R_X86_64_PC32:
279 ++ case R_X86_64_PLT32:
280 + /*
281 + * PC relative relocations don't need to be adjusted unless
282 + * referencing a percpu symbol.
283 ++ *
284 ++ * NB: R_X86_64_PLT32 can be treated as R_X86_64_PC32.
285 + */
286 + if (is_percpu_sym(sym, symname))
287 + add_reloc(&relocs32neg, offset);
288 +diff --git a/drivers/block/loop.c b/drivers/block/loop.c
289 +index 1c36de9719e5..3e65ae144fde 100644
290 +--- a/drivers/block/loop.c
291 ++++ b/drivers/block/loop.c
292 +@@ -263,7 +263,7 @@ static int lo_write_bvec(struct file *file, struct bio_vec *bvec, loff_t *ppos)
293 + struct iov_iter i;
294 + ssize_t bw;
295 +
296 +- iov_iter_bvec(&i, ITER_BVEC, bvec, 1, bvec->bv_len);
297 ++ iov_iter_bvec(&i, ITER_BVEC | WRITE, bvec, 1, bvec->bv_len);
298 +
299 + file_start_write(file);
300 + bw = vfs_iter_write(file, &i, ppos);
301 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
302 +index a142d5ae148d..5c40d6d710af 100644
303 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
304 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
305 +@@ -585,6 +585,9 @@ int amdgpu_acpi_pcie_performance_request(struct amdgpu_device *adev,
306 + size_t size;
307 + u32 retry = 3;
308 +
309 ++ if (amdgpu_acpi_pcie_notify_device_ready(adev))
310 ++ return -EINVAL;
311 ++
312 + /* Get the device handle */
313 + handle = ACPI_HANDLE(&adev->pdev->dev);
314 + if (!handle)
315 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
316 +index 930083336968..6470c9aa1351 100644
317 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
318 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
319 +@@ -739,9 +739,11 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force)
320 + enum drm_connector_status ret = connector_status_disconnected;
321 + int r;
322 +
323 +- r = pm_runtime_get_sync(connector->dev->dev);
324 +- if (r < 0)
325 +- return connector_status_disconnected;
326 ++ if (!drm_kms_helper_is_poll_worker()) {
327 ++ r = pm_runtime_get_sync(connector->dev->dev);
328 ++ if (r < 0)
329 ++ return connector_status_disconnected;
330 ++ }
331 +
332 + if (encoder) {
333 + struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
334 +@@ -760,8 +762,12 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force)
335 + /* check acpi lid status ??? */
336 +
337 + amdgpu_connector_update_scratch_regs(connector, ret);
338 +- pm_runtime_mark_last_busy(connector->dev->dev);
339 +- pm_runtime_put_autosuspend(connector->dev->dev);
340 ++
341 ++ if (!drm_kms_helper_is_poll_worker()) {
342 ++ pm_runtime_mark_last_busy(connector->dev->dev);
343 ++ pm_runtime_put_autosuspend(connector->dev->dev);
344 ++ }
345 ++
346 + return ret;
347 + }
348 +
349 +@@ -862,9 +868,11 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force)
350 + enum drm_connector_status ret = connector_status_disconnected;
351 + int r;
352 +
353 +- r = pm_runtime_get_sync(connector->dev->dev);
354 +- if (r < 0)
355 +- return connector_status_disconnected;
356 ++ if (!drm_kms_helper_is_poll_worker()) {
357 ++ r = pm_runtime_get_sync(connector->dev->dev);
358 ++ if (r < 0)
359 ++ return connector_status_disconnected;
360 ++ }
361 +
362 + encoder = amdgpu_connector_best_single_encoder(connector);
363 + if (!encoder)
364 +@@ -918,8 +926,10 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force)
365 + amdgpu_connector_update_scratch_regs(connector, ret);
366 +
367 + out:
368 +- pm_runtime_mark_last_busy(connector->dev->dev);
369 +- pm_runtime_put_autosuspend(connector->dev->dev);
370 ++ if (!drm_kms_helper_is_poll_worker()) {
371 ++ pm_runtime_mark_last_busy(connector->dev->dev);
372 ++ pm_runtime_put_autosuspend(connector->dev->dev);
373 ++ }
374 +
375 + return ret;
376 + }
377 +@@ -981,9 +991,11 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force)
378 + enum drm_connector_status ret = connector_status_disconnected;
379 + bool dret = false, broken_edid = false;
380 +
381 +- r = pm_runtime_get_sync(connector->dev->dev);
382 +- if (r < 0)
383 +- return connector_status_disconnected;
384 ++ if (!drm_kms_helper_is_poll_worker()) {
385 ++ r = pm_runtime_get_sync(connector->dev->dev);
386 ++ if (r < 0)
387 ++ return connector_status_disconnected;
388 ++ }
389 +
390 + if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {
391 + ret = connector->status;
392 +@@ -1108,8 +1120,10 @@ out:
393 + amdgpu_connector_update_scratch_regs(connector, ret);
394 +
395 + exit:
396 +- pm_runtime_mark_last_busy(connector->dev->dev);
397 +- pm_runtime_put_autosuspend(connector->dev->dev);
398 ++ if (!drm_kms_helper_is_poll_worker()) {
399 ++ pm_runtime_mark_last_busy(connector->dev->dev);
400 ++ pm_runtime_put_autosuspend(connector->dev->dev);
401 ++ }
402 +
403 + return ret;
404 + }
405 +@@ -1351,9 +1365,11 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force)
406 + struct drm_encoder *encoder = amdgpu_connector_best_single_encoder(connector);
407 + int r;
408 +
409 +- r = pm_runtime_get_sync(connector->dev->dev);
410 +- if (r < 0)
411 +- return connector_status_disconnected;
412 ++ if (!drm_kms_helper_is_poll_worker()) {
413 ++ r = pm_runtime_get_sync(connector->dev->dev);
414 ++ if (r < 0)
415 ++ return connector_status_disconnected;
416 ++ }
417 +
418 + if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {
419 + ret = connector->status;
420 +@@ -1421,8 +1437,10 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force)
421 +
422 + amdgpu_connector_update_scratch_regs(connector, ret);
423 + out:
424 +- pm_runtime_mark_last_busy(connector->dev->dev);
425 +- pm_runtime_put_autosuspend(connector->dev->dev);
426 ++ if (!drm_kms_helper_is_poll_worker()) {
427 ++ pm_runtime_mark_last_busy(connector->dev->dev);
428 ++ pm_runtime_put_autosuspend(connector->dev->dev);
429 ++ }
430 +
431 + return ret;
432 + }
433 +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
434 +index b57fffc2d4af..0a91261b6f5b 100644
435 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
436 ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
437 +@@ -2104,34 +2104,8 @@ static void gfx_v7_0_gpu_init(struct amdgpu_device *adev)
438 + case CHIP_KAVERI:
439 + adev->gfx.config.max_shader_engines = 1;
440 + adev->gfx.config.max_tile_pipes = 4;
441 +- if ((adev->pdev->device == 0x1304) ||
442 +- (adev->pdev->device == 0x1305) ||
443 +- (adev->pdev->device == 0x130C) ||
444 +- (adev->pdev->device == 0x130F) ||
445 +- (adev->pdev->device == 0x1310) ||
446 +- (adev->pdev->device == 0x1311) ||
447 +- (adev->pdev->device == 0x131C)) {
448 +- adev->gfx.config.max_cu_per_sh = 8;
449 +- adev->gfx.config.max_backends_per_se = 2;
450 +- } else if ((adev->pdev->device == 0x1309) ||
451 +- (adev->pdev->device == 0x130A) ||
452 +- (adev->pdev->device == 0x130D) ||
453 +- (adev->pdev->device == 0x1313) ||
454 +- (adev->pdev->device == 0x131D)) {
455 +- adev->gfx.config.max_cu_per_sh = 6;
456 +- adev->gfx.config.max_backends_per_se = 2;
457 +- } else if ((adev->pdev->device == 0x1306) ||
458 +- (adev->pdev->device == 0x1307) ||
459 +- (adev->pdev->device == 0x130B) ||
460 +- (adev->pdev->device == 0x130E) ||
461 +- (adev->pdev->device == 0x1315) ||
462 +- (adev->pdev->device == 0x131B)) {
463 +- adev->gfx.config.max_cu_per_sh = 4;
464 +- adev->gfx.config.max_backends_per_se = 1;
465 +- } else {
466 +- adev->gfx.config.max_cu_per_sh = 3;
467 +- adev->gfx.config.max_backends_per_se = 1;
468 +- }
469 ++ adev->gfx.config.max_cu_per_sh = 8;
470 ++ adev->gfx.config.max_backends_per_se = 2;
471 + adev->gfx.config.max_sh_per_se = 1;
472 + adev->gfx.config.max_texture_channel_caches = 4;
473 + adev->gfx.config.max_gprs = 256;
474 +diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
475 +index f8b5fcfa91a2..1fe4b8e6596b 100644
476 +--- a/drivers/gpu/drm/drm_probe_helper.c
477 ++++ b/drivers/gpu/drm/drm_probe_helper.c
478 +@@ -411,6 +411,26 @@ out:
479 + schedule_delayed_work(delayed_work, DRM_OUTPUT_POLL_PERIOD);
480 + }
481 +
482 ++/**
483 ++ * drm_kms_helper_is_poll_worker - is %current task an output poll worker?
484 ++ *
485 ++ * Determine if %current task is an output poll worker. This can be used
486 ++ * to select distinct code paths for output polling versus other contexts.
487 ++ *
488 ++ * One use case is to avoid a deadlock between the output poll worker and
489 ++ * the autosuspend worker wherein the latter waits for polling to finish
490 ++ * upon calling drm_kms_helper_poll_disable(), while the former waits for
491 ++ * runtime suspend to finish upon calling pm_runtime_get_sync() in a
492 ++ * connector ->detect hook.
493 ++ */
494 ++bool drm_kms_helper_is_poll_worker(void)
495 ++{
496 ++ struct work_struct *work = current_work();
497 ++
498 ++ return work && work->func == output_poll_execute;
499 ++}
500 ++EXPORT_SYMBOL(drm_kms_helper_is_poll_worker);
501 ++
502 + /**
503 + * drm_kms_helper_poll_disable - disable output polling
504 + * @dev: drm_device
505 +diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
506 +index 2a5ed7460354..ababdaabe870 100644
507 +--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
508 ++++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
509 +@@ -253,9 +253,15 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
510 + nv_connector->edid = NULL;
511 + }
512 +
513 +- ret = pm_runtime_get_sync(connector->dev->dev);
514 +- if (ret < 0 && ret != -EACCES)
515 +- return conn_status;
516 ++ /* Outputs are only polled while runtime active, so acquiring a
517 ++ * runtime PM ref here is unnecessary (and would deadlock upon
518 ++ * runtime suspend because it waits for polling to finish).
519 ++ */
520 ++ if (!drm_kms_helper_is_poll_worker()) {
521 ++ ret = pm_runtime_get_sync(connector->dev->dev);
522 ++ if (ret < 0 && ret != -EACCES)
523 ++ return conn_status;
524 ++ }
525 +
526 + nv_encoder = nouveau_connector_ddc_detect(connector);
527 + if (nv_encoder && (i2c = nv_encoder->i2c) != NULL) {
528 +@@ -323,8 +329,10 @@ detect_analog:
529 +
530 + out:
531 +
532 +- pm_runtime_mark_last_busy(connector->dev->dev);
533 +- pm_runtime_put_autosuspend(connector->dev->dev);
534 ++ if (!drm_kms_helper_is_poll_worker()) {
535 ++ pm_runtime_mark_last_busy(connector->dev->dev);
536 ++ pm_runtime_put_autosuspend(connector->dev->dev);
537 ++ }
538 +
539 + return conn_status;
540 + }
541 +diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
542 +index 134874cab4c7..80b6d6e4721a 100644
543 +--- a/drivers/gpu/drm/radeon/cik.c
544 ++++ b/drivers/gpu/drm/radeon/cik.c
545 +@@ -3599,35 +3599,8 @@ static void cik_gpu_init(struct radeon_device *rdev)
546 + case CHIP_KAVERI:
547 + rdev->config.cik.max_shader_engines = 1;
548 + rdev->config.cik.max_tile_pipes = 4;
549 +- if ((rdev->pdev->device == 0x1304) ||
550 +- (rdev->pdev->device == 0x1305) ||
551 +- (rdev->pdev->device == 0x130C) ||
552 +- (rdev->pdev->device == 0x130F) ||
553 +- (rdev->pdev->device == 0x1310) ||
554 +- (rdev->pdev->device == 0x1311) ||
555 +- (rdev->pdev->device == 0x131C)) {
556 +- rdev->config.cik.max_cu_per_sh = 8;
557 +- rdev->config.cik.max_backends_per_se = 2;
558 +- } else if ((rdev->pdev->device == 0x1309) ||
559 +- (rdev->pdev->device == 0x130A) ||
560 +- (rdev->pdev->device == 0x130D) ||
561 +- (rdev->pdev->device == 0x1313) ||
562 +- (rdev->pdev->device == 0x131D)) {
563 +- rdev->config.cik.max_cu_per_sh = 6;
564 +- rdev->config.cik.max_backends_per_se = 2;
565 +- } else if ((rdev->pdev->device == 0x1306) ||
566 +- (rdev->pdev->device == 0x1307) ||
567 +- (rdev->pdev->device == 0x130B) ||
568 +- (rdev->pdev->device == 0x130E) ||
569 +- (rdev->pdev->device == 0x1315) ||
570 +- (rdev->pdev->device == 0x1318) ||
571 +- (rdev->pdev->device == 0x131B)) {
572 +- rdev->config.cik.max_cu_per_sh = 4;
573 +- rdev->config.cik.max_backends_per_se = 1;
574 +- } else {
575 +- rdev->config.cik.max_cu_per_sh = 3;
576 +- rdev->config.cik.max_backends_per_se = 1;
577 +- }
578 ++ rdev->config.cik.max_cu_per_sh = 8;
579 ++ rdev->config.cik.max_backends_per_se = 2;
580 + rdev->config.cik.max_sh_per_se = 1;
581 + rdev->config.cik.max_texture_channel_caches = 4;
582 + rdev->config.cik.max_gprs = 256;
583 +diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
584 +index 30f00748ed37..3feaab94f358 100644
585 +--- a/drivers/gpu/drm/radeon/radeon_connectors.c
586 ++++ b/drivers/gpu/drm/radeon/radeon_connectors.c
587 +@@ -891,9 +891,11 @@ radeon_lvds_detect(struct drm_connector *connector, bool force)
588 + enum drm_connector_status ret = connector_status_disconnected;
589 + int r;
590 +
591 +- r = pm_runtime_get_sync(connector->dev->dev);
592 +- if (r < 0)
593 +- return connector_status_disconnected;
594 ++ if (!drm_kms_helper_is_poll_worker()) {
595 ++ r = pm_runtime_get_sync(connector->dev->dev);
596 ++ if (r < 0)
597 ++ return connector_status_disconnected;
598 ++ }
599 +
600 + if (encoder) {
601 + struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
602 +@@ -916,8 +918,12 @@ radeon_lvds_detect(struct drm_connector *connector, bool force)
603 + /* check acpi lid status ??? */
604 +
605 + radeon_connector_update_scratch_regs(connector, ret);
606 +- pm_runtime_mark_last_busy(connector->dev->dev);
607 +- pm_runtime_put_autosuspend(connector->dev->dev);
608 ++
609 ++ if (!drm_kms_helper_is_poll_worker()) {
610 ++ pm_runtime_mark_last_busy(connector->dev->dev);
611 ++ pm_runtime_put_autosuspend(connector->dev->dev);
612 ++ }
613 ++
614 + return ret;
615 + }
616 +
617 +@@ -1020,9 +1026,11 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
618 + enum drm_connector_status ret = connector_status_disconnected;
619 + int r;
620 +
621 +- r = pm_runtime_get_sync(connector->dev->dev);
622 +- if (r < 0)
623 +- return connector_status_disconnected;
624 ++ if (!drm_kms_helper_is_poll_worker()) {
625 ++ r = pm_runtime_get_sync(connector->dev->dev);
626 ++ if (r < 0)
627 ++ return connector_status_disconnected;
628 ++ }
629 +
630 + encoder = radeon_best_single_encoder(connector);
631 + if (!encoder)
632 +@@ -1089,8 +1097,10 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
633 + radeon_connector_update_scratch_regs(connector, ret);
634 +
635 + out:
636 +- pm_runtime_mark_last_busy(connector->dev->dev);
637 +- pm_runtime_put_autosuspend(connector->dev->dev);
638 ++ if (!drm_kms_helper_is_poll_worker()) {
639 ++ pm_runtime_mark_last_busy(connector->dev->dev);
640 ++ pm_runtime_put_autosuspend(connector->dev->dev);
641 ++ }
642 +
643 + return ret;
644 + }
645 +@@ -1153,9 +1163,11 @@ radeon_tv_detect(struct drm_connector *connector, bool force)
646 + if (!radeon_connector->dac_load_detect)
647 + return ret;
648 +
649 +- r = pm_runtime_get_sync(connector->dev->dev);
650 +- if (r < 0)
651 +- return connector_status_disconnected;
652 ++ if (!drm_kms_helper_is_poll_worker()) {
653 ++ r = pm_runtime_get_sync(connector->dev->dev);
654 ++ if (r < 0)
655 ++ return connector_status_disconnected;
656 ++ }
657 +
658 + encoder = radeon_best_single_encoder(connector);
659 + if (!encoder)
660 +@@ -1167,8 +1179,12 @@ radeon_tv_detect(struct drm_connector *connector, bool force)
661 + if (ret == connector_status_connected)
662 + ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false);
663 + radeon_connector_update_scratch_regs(connector, ret);
664 +- pm_runtime_mark_last_busy(connector->dev->dev);
665 +- pm_runtime_put_autosuspend(connector->dev->dev);
666 ++
667 ++ if (!drm_kms_helper_is_poll_worker()) {
668 ++ pm_runtime_mark_last_busy(connector->dev->dev);
669 ++ pm_runtime_put_autosuspend(connector->dev->dev);
670 ++ }
671 ++
672 + return ret;
673 + }
674 +
675 +@@ -1230,9 +1246,11 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
676 + enum drm_connector_status ret = connector_status_disconnected;
677 + bool dret = false, broken_edid = false;
678 +
679 +- r = pm_runtime_get_sync(connector->dev->dev);
680 +- if (r < 0)
681 +- return connector_status_disconnected;
682 ++ if (!drm_kms_helper_is_poll_worker()) {
683 ++ r = pm_runtime_get_sync(connector->dev->dev);
684 ++ if (r < 0)
685 ++ return connector_status_disconnected;
686 ++ }
687 +
688 + if (radeon_connector->detected_hpd_without_ddc) {
689 + force = true;
690 +@@ -1415,8 +1433,10 @@ out:
691 + }
692 +
693 + exit:
694 +- pm_runtime_mark_last_busy(connector->dev->dev);
695 +- pm_runtime_put_autosuspend(connector->dev->dev);
696 ++ if (!drm_kms_helper_is_poll_worker()) {
697 ++ pm_runtime_mark_last_busy(connector->dev->dev);
698 ++ pm_runtime_put_autosuspend(connector->dev->dev);
699 ++ }
700 +
701 + return ret;
702 + }
703 +@@ -1666,9 +1686,11 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
704 + if (radeon_dig_connector->is_mst)
705 + return connector_status_disconnected;
706 +
707 +- r = pm_runtime_get_sync(connector->dev->dev);
708 +- if (r < 0)
709 +- return connector_status_disconnected;
710 ++ if (!drm_kms_helper_is_poll_worker()) {
711 ++ r = pm_runtime_get_sync(connector->dev->dev);
712 ++ if (r < 0)
713 ++ return connector_status_disconnected;
714 ++ }
715 +
716 + if (!force && radeon_check_hpd_status_unchanged(connector)) {
717 + ret = connector->status;
718 +@@ -1755,8 +1777,10 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
719 + }
720 +
721 + out:
722 +- pm_runtime_mark_last_busy(connector->dev->dev);
723 +- pm_runtime_put_autosuspend(connector->dev->dev);
724 ++ if (!drm_kms_helper_is_poll_worker()) {
725 ++ pm_runtime_mark_last_busy(connector->dev->dev);
726 ++ pm_runtime_put_autosuspend(connector->dev->dev);
727 ++ }
728 +
729 + return ret;
730 + }
731 +diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
732 +index 886f61ea6cc7..cdac2c9421ab 100644
733 +--- a/drivers/infiniband/core/ucma.c
734 ++++ b/drivers/infiniband/core/ucma.c
735 +@@ -1138,6 +1138,9 @@ static ssize_t ucma_init_qp_attr(struct ucma_file *file,
736 + if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
737 + return -EFAULT;
738 +
739 ++ if (cmd.qp_state > IB_QPS_ERR)
740 ++ return -EINVAL;
741 ++
742 + ctx = ucma_get_ctx(file, cmd.id);
743 + if (IS_ERR(ctx))
744 + return PTR_ERR(ctx);
745 +@@ -1274,6 +1277,9 @@ static ssize_t ucma_set_option(struct ucma_file *file, const char __user *inbuf,
746 + if (IS_ERR(ctx))
747 + return PTR_ERR(ctx);
748 +
749 ++ if (unlikely(cmd.optval > KMALLOC_MAX_SIZE))
750 ++ return -EINVAL;
751 ++
752 + optval = memdup_user((void __user *) (unsigned long) cmd.optval,
753 + cmd.optlen);
754 + if (IS_ERR(optval)) {
755 +diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c
756 +index 02c8deab1fff..4a4ab433062f 100644
757 +--- a/drivers/infiniband/hw/mlx5/cq.c
758 ++++ b/drivers/infiniband/hw/mlx5/cq.c
759 +@@ -972,7 +972,12 @@ static int resize_user(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
760 + if (ucmd.reserved0 || ucmd.reserved1)
761 + return -EINVAL;
762 +
763 +- umem = ib_umem_get(context, ucmd.buf_addr, entries * ucmd.cqe_size,
764 ++ /* check multiplication overflow */
765 ++ if (ucmd.cqe_size && SIZE_MAX / ucmd.cqe_size <= entries - 1)
766 ++ return -EINVAL;
767 ++
768 ++ umem = ib_umem_get(context, ucmd.buf_addr,
769 ++ (size_t)ucmd.cqe_size * entries,
770 + IB_ACCESS_LOCAL_WRITE, 1);
771 + if (IS_ERR(umem)) {
772 + err = PTR_ERR(umem);
773 +diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
774 +index 7f12b6579f82..795fa353de7c 100644
775 +--- a/drivers/input/keyboard/matrix_keypad.c
776 ++++ b/drivers/input/keyboard/matrix_keypad.c
777 +@@ -216,8 +216,10 @@ static void matrix_keypad_stop(struct input_dev *dev)
778 + {
779 + struct matrix_keypad *keypad = input_get_drvdata(dev);
780 +
781 ++ spin_lock_irq(&keypad->lock);
782 + keypad->stopped = true;
783 +- mb();
784 ++ spin_unlock_irq(&keypad->lock);
785 ++
786 + flush_work(&keypad->work.work);
787 + /*
788 + * matrix_keypad_scan() will leave IRQs enabled;
789 +diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c
790 +index 3048ef3e3e16..a5e8998047fe 100644
791 +--- a/drivers/input/keyboard/tca8418_keypad.c
792 ++++ b/drivers/input/keyboard/tca8418_keypad.c
793 +@@ -189,8 +189,6 @@ static void tca8418_read_keypad(struct tca8418_keypad *keypad_data)
794 + input_event(input, EV_MSC, MSC_SCAN, code);
795 + input_report_key(input, keymap[code], state);
796 +
797 +- /* Read for next loop */
798 +- error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, &reg);
799 + } while (1);
800 +
801 + input_sync(input);
802 +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
803 +index 8eaadd9869bc..be8307550bd7 100644
804 +--- a/drivers/md/bcache/super.c
805 ++++ b/drivers/md/bcache/super.c
806 +@@ -935,6 +935,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
807 + uint32_t rtime = cpu_to_le32(get_seconds());
808 + struct uuid_entry *u;
809 + char buf[BDEVNAME_SIZE];
810 ++ struct cached_dev *exist_dc, *t;
811 +
812 + bdevname(dc->bdev, buf);
813 +
814 +@@ -958,6 +959,16 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
815 + return -EINVAL;
816 + }
817 +
818 ++ /* Check whether already attached */
819 ++ list_for_each_entry_safe(exist_dc, t, &c->cached_devs, list) {
820 ++ if (!memcmp(dc->sb.uuid, exist_dc->sb.uuid, 16)) {
821 ++ pr_err("Tried to attach %s but duplicate UUID already attached",
822 ++ buf);
823 ++
824 ++ return -EINVAL;
825 ++ }
826 ++ }
827 ++
828 + u = uuid_find(c, dc->sb.uuid);
829 +
830 + if (u &&
831 +diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
832 +index ea2777e1ee10..bc630a719776 100644
833 +--- a/drivers/media/i2c/tc358743.c
834 ++++ b/drivers/media/i2c/tc358743.c
835 +@@ -226,7 +226,7 @@ static void i2c_wr8(struct v4l2_subdev *sd, u16 reg, u8 val)
836 + static void i2c_wr8_and_or(struct v4l2_subdev *sd, u16 reg,
837 + u8 mask, u8 val)
838 + {
839 +- i2c_wrreg(sd, reg, (i2c_rdreg(sd, reg, 2) & mask) | val, 2);
840 ++ i2c_wrreg(sd, reg, (i2c_rdreg(sd, reg, 1) & mask) | val, 1);
841 + }
842 +
843 + static u16 i2c_rd16(struct v4l2_subdev *sd, u16 reg)
844 +diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
845 +index 3ea4c022cbb9..ccdb3dd74421 100644
846 +--- a/drivers/mtd/ubi/vmt.c
847 ++++ b/drivers/mtd/ubi/vmt.c
848 +@@ -265,6 +265,12 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
849 + vol->last_eb_bytes = vol->usable_leb_size;
850 + }
851 +
852 ++ /* Make volume "available" before it becomes accessible via sysfs */
853 ++ spin_lock(&ubi->volumes_lock);
854 ++ ubi->volumes[vol_id] = vol;
855 ++ ubi->vol_count += 1;
856 ++ spin_unlock(&ubi->volumes_lock);
857 ++
858 + /* Register character device for the volume */
859 + cdev_init(&vol->cdev, &ubi_vol_cdev_operations);
860 + vol->cdev.owner = THIS_MODULE;
861 +@@ -304,11 +310,6 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
862 + if (err)
863 + goto out_sysfs;
864 +
865 +- spin_lock(&ubi->volumes_lock);
866 +- ubi->volumes[vol_id] = vol;
867 +- ubi->vol_count += 1;
868 +- spin_unlock(&ubi->volumes_lock);
869 +-
870 + ubi_volume_notify(ubi, vol, UBI_VOLUME_ADDED);
871 + self_check_volumes(ubi);
872 + return err;
873 +@@ -328,6 +329,10 @@ out_sysfs:
874 + out_cdev:
875 + cdev_del(&vol->cdev);
876 + out_mapping:
877 ++ spin_lock(&ubi->volumes_lock);
878 ++ ubi->volumes[vol_id] = NULL;
879 ++ ubi->vol_count -= 1;
880 ++ spin_unlock(&ubi->volumes_lock);
881 + if (do_free)
882 + kfree(vol->eba_tbl);
883 + out_acc:
884 +diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
885 +index e197c6f39de2..aa18c729d23a 100644
886 +--- a/drivers/scsi/qla2xxx/qla_init.c
887 ++++ b/drivers/scsi/qla2xxx/qla_init.c
888 +@@ -365,6 +365,7 @@ qla24xx_abort_sp_done(void *data, void *ptr, int res)
889 + srb_t *sp = (srb_t *)ptr;
890 + struct srb_iocb *abt = &sp->u.iocb_cmd;
891 +
892 ++ del_timer(&sp->u.iocb_cmd.timer);
893 + complete(&abt->u.abt.comp);
894 + }
895 +
896 +diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
897 +index e6faa0b050d1..824e27eec7a1 100644
898 +--- a/drivers/scsi/qla2xxx/qla_target.c
899 ++++ b/drivers/scsi/qla2xxx/qla_target.c
900 +@@ -5502,7 +5502,7 @@ static fc_port_t *qlt_get_port_database(struct scsi_qla_host *vha,
901 + fc_port_t *fcport;
902 + int rc;
903 +
904 +- fcport = kzalloc(sizeof(*fcport), GFP_KERNEL);
905 ++ fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL);
906 + if (!fcport) {
907 + ql_dbg(ql_dbg_tgt_mgt, vha, 0xf06f,
908 + "qla_target(%d): Allocation of tmp FC port failed",
909 +diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
910 +index ec31b53ae3a5..f5b5bec6f3c1 100644
911 +--- a/drivers/staging/android/ashmem.c
912 ++++ b/drivers/staging/android/ashmem.c
913 +@@ -330,24 +330,23 @@ static loff_t ashmem_llseek(struct file *file, loff_t offset, int origin)
914 + mutex_lock(&ashmem_mutex);
915 +
916 + if (asma->size == 0) {
917 +- ret = -EINVAL;
918 +- goto out;
919 ++ mutex_unlock(&ashmem_mutex);
920 ++ return -EINVAL;
921 + }
922 +
923 + if (!asma->file) {
924 +- ret = -EBADF;
925 +- goto out;
926 ++ mutex_unlock(&ashmem_mutex);
927 ++ return -EBADF;
928 + }
929 +
930 ++ mutex_unlock(&ashmem_mutex);
931 ++
932 + ret = vfs_llseek(asma->file, offset, origin);
933 + if (ret < 0)
934 +- goto out;
935 ++ return ret;
936 +
937 + /** Copy f_pos from backing file, since f_ops->llseek() sets it */
938 + file->f_pos = asma->file->f_pos;
939 +-
940 +-out:
941 +- mutex_unlock(&ashmem_mutex);
942 + return ret;
943 + }
944 +
945 +diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
946 +index b63dd2ef78b5..1f398d06f4ee 100644
947 +--- a/drivers/staging/comedi/drivers.c
948 ++++ b/drivers/staging/comedi/drivers.c
949 +@@ -484,8 +484,7 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s,
950 + struct comedi_cmd *cmd = &async->cmd;
951 +
952 + if (cmd->stop_src == TRIG_COUNT) {
953 +- unsigned int nscans = nsamples / cmd->scan_end_arg;
954 +- unsigned int scans_left = __comedi_nscans_left(s, nscans);
955 ++ unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg);
956 + unsigned int scan_pos =
957 + comedi_bytes_to_samples(s, async->scan_progress);
958 + unsigned long long samples_left = 0;
959 +diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
960 +index 7025f47fa284..746c76b358a0 100644
961 +--- a/drivers/tty/serial/8250/8250_pci.c
962 ++++ b/drivers/tty/serial/8250/8250_pci.c
963 +@@ -5299,6 +5299,17 @@ static struct pci_device_id serial_pci_tbl[] = {
964 + { PCI_VENDOR_ID_INTASHIELD, PCI_DEVICE_ID_INTASHIELD_IS400,
965 + PCI_ANY_ID, PCI_ANY_ID, 0, 0, /* 135a.0dc0 */
966 + pbn_b2_4_115200 },
967 ++ /*
968 ++ * BrainBoxes UC-260
969 ++ */
970 ++ { PCI_VENDOR_ID_INTASHIELD, 0x0D21,
971 ++ PCI_ANY_ID, PCI_ANY_ID,
972 ++ PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00,
973 ++ pbn_b2_4_115200 },
974 ++ { PCI_VENDOR_ID_INTASHIELD, 0x0E34,
975 ++ PCI_ANY_ID, PCI_ANY_ID,
976 ++ PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00,
977 ++ pbn_b2_4_115200 },
978 + /*
979 + * Perle PCI-RAS cards
980 + */
981 +diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
982 +index 53e4d5056db7..e0277cf0bf58 100644
983 +--- a/drivers/tty/serial/atmel_serial.c
984 ++++ b/drivers/tty/serial/atmel_serial.c
985 +@@ -1783,6 +1783,7 @@ static void atmel_get_ip_name(struct uart_port *port)
986 + switch (version) {
987 + case 0x302:
988 + case 0x10213:
989 ++ case 0x10302:
990 + dev_dbg(port->dev, "This version is usart\n");
991 + atmel_port->is_usart = true;
992 + break;
993 +diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
994 +index 80d0ffe7abc1..fc7711c75b01 100644
995 +--- a/drivers/tty/serial/sh-sci.c
996 ++++ b/drivers/tty/serial/sh-sci.c
997 +@@ -847,6 +847,8 @@ static void sci_receive_chars(struct uart_port *port)
998 + /* Tell the rest of the system the news. New characters! */
999 + tty_flip_buffer_push(tport);
1000 + } else {
1001 ++ /* TTY buffers full; read from RX reg to prevent lockup */
1002 ++ serial_port_in(port, SCxRDR);
1003 + serial_port_in(port, SCxSR); /* dummy read */
1004 + sci_clear_SCxSR(port, SCxSR_RDxF_CLEAR(port));
1005 + }
1006 +diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
1007 +index 8e641b5893ed..29adabdb305f 100644
1008 +--- a/drivers/usb/core/message.c
1009 ++++ b/drivers/usb/core/message.c
1010 +@@ -147,6 +147,10 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
1011 +
1012 + ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout);
1013 +
1014 ++ /* Linger a bit, prior to the next control message. */
1015 ++ if (dev->quirks & USB_QUIRK_DELAY_CTRL_MSG)
1016 ++ msleep(200);
1017 ++
1018 + kfree(dr);
1019 +
1020 + return ret;
1021 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
1022 +index 774c97bb1c08..4f1c6f8d4352 100644
1023 +--- a/drivers/usb/core/quirks.c
1024 ++++ b/drivers/usb/core/quirks.c
1025 +@@ -229,7 +229,8 @@ static const struct usb_device_id usb_quirk_list[] = {
1026 + { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT },
1027 +
1028 + /* Corsair Strafe RGB */
1029 +- { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT },
1030 ++ { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT |
1031 ++ USB_QUIRK_DELAY_CTRL_MSG },
1032 +
1033 + /* Corsair K70 LUX */
1034 + { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
1035 +diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
1036 +index 51c2b05b5dd9..7deebd0b21ae 100644
1037 +--- a/drivers/usb/gadget/function/f_fs.c
1038 ++++ b/drivers/usb/gadget/function/f_fs.c
1039 +@@ -1333,7 +1333,6 @@ ffs_fs_kill_sb(struct super_block *sb)
1040 + if (sb->s_fs_info) {
1041 + ffs_release_dev(sb->s_fs_info);
1042 + ffs_data_closed(sb->s_fs_info);
1043 +- ffs_data_put(sb->s_fs_info);
1044 + }
1045 + }
1046 +
1047 +diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
1048 +index ad408251d955..108dcc5f5350 100644
1049 +--- a/drivers/usb/mon/mon_text.c
1050 ++++ b/drivers/usb/mon/mon_text.c
1051 +@@ -82,6 +82,8 @@ struct mon_reader_text {
1052 +
1053 + wait_queue_head_t wait;
1054 + int printf_size;
1055 ++ size_t printf_offset;
1056 ++ size_t printf_togo;
1057 + char *printf_buf;
1058 + struct mutex printf_lock;
1059 +
1060 +@@ -373,73 +375,103 @@ err_alloc:
1061 + return rc;
1062 + }
1063 +
1064 +-/*
1065 +- * For simplicity, we read one record in one system call and throw out
1066 +- * what does not fit. This means that the following does not work:
1067 +- * dd if=/dbg/usbmon/0t bs=10
1068 +- * Also, we do not allow seeks and do not bother advancing the offset.
1069 +- */
1070 ++static ssize_t mon_text_copy_to_user(struct mon_reader_text *rp,
1071 ++ char __user * const buf, const size_t nbytes)
1072 ++{
1073 ++ const size_t togo = min(nbytes, rp->printf_togo);
1074 ++
1075 ++ if (copy_to_user(buf, &rp->printf_buf[rp->printf_offset], togo))
1076 ++ return -EFAULT;
1077 ++ rp->printf_togo -= togo;
1078 ++ rp->printf_offset += togo;
1079 ++ return togo;
1080 ++}
1081 ++
1082 ++/* ppos is not advanced since the llseek operation is not permitted. */
1083 + static ssize_t mon_text_read_t(struct file *file, char __user *buf,
1084 +- size_t nbytes, loff_t *ppos)
1085 ++ size_t nbytes, loff_t *ppos)
1086 + {
1087 + struct mon_reader_text *rp = file->private_data;
1088 + struct mon_event_text *ep;
1089 + struct mon_text_ptr ptr;
1090 ++ ssize_t ret;
1091 +
1092 +- if (IS_ERR(ep = mon_text_read_wait(rp, file)))
1093 +- return PTR_ERR(ep);
1094 + mutex_lock(&rp->printf_lock);
1095 +- ptr.cnt = 0;
1096 +- ptr.pbuf = rp->printf_buf;
1097 +- ptr.limit = rp->printf_size;
1098 +-
1099 +- mon_text_read_head_t(rp, &ptr, ep);
1100 +- mon_text_read_statset(rp, &ptr, ep);
1101 +- ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt,
1102 +- " %d", ep->length);
1103 +- mon_text_read_data(rp, &ptr, ep);
1104 +-
1105 +- if (copy_to_user(buf, rp->printf_buf, ptr.cnt))
1106 +- ptr.cnt = -EFAULT;
1107 ++
1108 ++ if (rp->printf_togo == 0) {
1109 ++
1110 ++ ep = mon_text_read_wait(rp, file);
1111 ++ if (IS_ERR(ep)) {
1112 ++ mutex_unlock(&rp->printf_lock);
1113 ++ return PTR_ERR(ep);
1114 ++ }
1115 ++ ptr.cnt = 0;
1116 ++ ptr.pbuf = rp->printf_buf;
1117 ++ ptr.limit = rp->printf_size;
1118 ++
1119 ++ mon_text_read_head_t(rp, &ptr, ep);
1120 ++ mon_text_read_statset(rp, &ptr, ep);
1121 ++ ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt,
1122 ++ " %d", ep->length);
1123 ++ mon_text_read_data(rp, &ptr, ep);
1124 ++
1125 ++ rp->printf_togo = ptr.cnt;
1126 ++ rp->printf_offset = 0;
1127 ++
1128 ++ kmem_cache_free(rp->e_slab, ep);
1129 ++ }
1130 ++
1131 ++ ret = mon_text_copy_to_user(rp, buf, nbytes);
1132 + mutex_unlock(&rp->printf_lock);
1133 +- kmem_cache_free(rp->e_slab, ep);
1134 +- return ptr.cnt;
1135 ++ return ret;
1136 + }
1137 +
1138 ++/* ppos is not advanced since the llseek operation is not permitted. */
1139 + static ssize_t mon_text_read_u(struct file *file, char __user *buf,
1140 +- size_t nbytes, loff_t *ppos)
1141 ++ size_t nbytes, loff_t *ppos)
1142 + {
1143 + struct mon_reader_text *rp = file->private_data;
1144 + struct mon_event_text *ep;
1145 + struct mon_text_ptr ptr;
1146 ++ ssize_t ret;
1147 +
1148 +- if (IS_ERR(ep = mon_text_read_wait(rp, file)))
1149 +- return PTR_ERR(ep);
1150 + mutex_lock(&rp->printf_lock);
1151 +- ptr.cnt = 0;
1152 +- ptr.pbuf = rp->printf_buf;
1153 +- ptr.limit = rp->printf_size;
1154 +
1155 +- mon_text_read_head_u(rp, &ptr, ep);
1156 +- if (ep->type == 'E') {
1157 +- mon_text_read_statset(rp, &ptr, ep);
1158 +- } else if (ep->xfertype == USB_ENDPOINT_XFER_ISOC) {
1159 +- mon_text_read_isostat(rp, &ptr, ep);
1160 +- mon_text_read_isodesc(rp, &ptr, ep);
1161 +- } else if (ep->xfertype == USB_ENDPOINT_XFER_INT) {
1162 +- mon_text_read_intstat(rp, &ptr, ep);
1163 +- } else {
1164 +- mon_text_read_statset(rp, &ptr, ep);
1165 ++ if (rp->printf_togo == 0) {
1166 ++
1167 ++ ep = mon_text_read_wait(rp, file);
1168 ++ if (IS_ERR(ep)) {
1169 ++ mutex_unlock(&rp->printf_lock);
1170 ++ return PTR_ERR(ep);
1171 ++ }
1172 ++ ptr.cnt = 0;
1173 ++ ptr.pbuf = rp->printf_buf;
1174 ++ ptr.limit = rp->printf_size;
1175 ++
1176 ++ mon_text_read_head_u(rp, &ptr, ep);
1177 ++ if (ep->type == 'E') {
1178 ++ mon_text_read_statset(rp, &ptr, ep);
1179 ++ } else if (ep->xfertype == USB_ENDPOINT_XFER_ISOC) {
1180 ++ mon_text_read_isostat(rp, &ptr, ep);
1181 ++ mon_text_read_isodesc(rp, &ptr, ep);
1182 ++ } else if (ep->xfertype == USB_ENDPOINT_XFER_INT) {
1183 ++ mon_text_read_intstat(rp, &ptr, ep);
1184 ++ } else {
1185 ++ mon_text_read_statset(rp, &ptr, ep);
1186 ++ }
1187 ++ ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt,
1188 ++ " %d", ep->length);
1189 ++ mon_text_read_data(rp, &ptr, ep);
1190 ++
1191 ++ rp->printf_togo = ptr.cnt;
1192 ++ rp->printf_offset = 0;
1193 ++
1194 ++ kmem_cache_free(rp->e_slab, ep);
1195 + }
1196 +- ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt,
1197 +- " %d", ep->length);
1198 +- mon_text_read_data(rp, &ptr, ep);
1199 +
1200 +- if (copy_to_user(buf, rp->printf_buf, ptr.cnt))
1201 +- ptr.cnt = -EFAULT;
1202 ++ ret = mon_text_copy_to_user(rp, buf, nbytes);
1203 + mutex_unlock(&rp->printf_lock);
1204 +- kmem_cache_free(rp->e_slab, ep);
1205 +- return ptr.cnt;
1206 ++ return ret;
1207 + }
1208 +
1209 + static struct mon_event_text *mon_text_read_wait(struct mon_reader_text *rp,
1210 +diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
1211 +index de7214ae4fed..6cac8f26b97a 100644
1212 +--- a/drivers/usb/storage/uas.c
1213 ++++ b/drivers/usb/storage/uas.c
1214 +@@ -1052,7 +1052,7 @@ static int uas_post_reset(struct usb_interface *intf)
1215 + return 0;
1216 +
1217 + err = uas_configure_endpoints(devinfo);
1218 +- if (err && err != ENODEV)
1219 ++ if (err && err != -ENODEV)
1220 + shost_printk(KERN_ERR, shost,
1221 + "%s: alloc streams error %d after reset",
1222 + __func__, err);
1223 +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
1224 +index c10eceb76c39..1a34d2a89de6 100644
1225 +--- a/drivers/usb/storage/unusual_devs.h
1226 ++++ b/drivers/usb/storage/unusual_devs.h
1227 +@@ -2142,6 +2142,13 @@ UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001,
1228 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1229 + US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ),
1230 +
1231 ++/* Reported by Teijo Kinnunen <teijo.kinnunen@××××××.fi> */
1232 ++UNUSUAL_DEV( 0x152d, 0x2567, 0x0117, 0x0117,
1233 ++ "JMicron",
1234 ++ "USB to ATA/ATAPI Bridge",
1235 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1236 ++ US_FL_BROKEN_FUA ),
1237 ++
1238 + /* Reported-by George Cherian <george.cherian@××××××.com> */
1239 + UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999,
1240 + "JMicron",
1241 +diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
1242 +index 286369d4f0f5..be99112fad00 100644
1243 +--- a/drivers/watchdog/hpwdt.c
1244 ++++ b/drivers/watchdog/hpwdt.c
1245 +@@ -51,6 +51,7 @@ static char expect_release;
1246 + static unsigned long hpwdt_is_open;
1247 +
1248 + static void __iomem *pci_mem_addr; /* the PCI-memory address */
1249 ++static unsigned long __iomem *hpwdt_nmistat;
1250 + static unsigned long __iomem *hpwdt_timer_reg;
1251 + static unsigned long __iomem *hpwdt_timer_con;
1252 +
1253 +@@ -474,6 +475,11 @@ static int hpwdt_time_left(void)
1254 + }
1255 +
1256 + #ifdef CONFIG_HPWDT_NMI_DECODING
1257 ++static int hpwdt_my_nmi(void)
1258 ++{
1259 ++ return ioread8(hpwdt_nmistat) & 0x6;
1260 ++}
1261 ++
1262 + /*
1263 + * NMI Handler
1264 + */
1265 +@@ -485,6 +491,9 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)
1266 + if (!hpwdt_nmi_decoding)
1267 + goto out;
1268 +
1269 ++ if ((ulReason == NMI_UNKNOWN) && !hpwdt_my_nmi())
1270 ++ return NMI_DONE;
1271 ++
1272 + spin_lock_irqsave(&rom_lock, rom_pl);
1273 + if (!die_nmi_called && !is_icru && !is_uefi)
1274 + asminline_call(&cmn_regs, cru_rom_addr);
1275 +@@ -700,7 +709,7 @@ static void dmi_find_icru(const struct dmi_header *dm, void *dummy)
1276 + smbios_proliant_ptr = (struct smbios_proliant_info *) dm;
1277 + if (smbios_proliant_ptr->misc_features & 0x01)
1278 + is_icru = 1;
1279 +- if (smbios_proliant_ptr->misc_features & 0x408)
1280 ++ if (smbios_proliant_ptr->misc_features & 0x1400)
1281 + is_uefi = 1;
1282 + }
1283 + }
1284 +@@ -840,6 +849,7 @@ static int hpwdt_init_one(struct pci_dev *dev,
1285 + retval = -ENOMEM;
1286 + goto error_pci_iomap;
1287 + }
1288 ++ hpwdt_nmistat = pci_mem_addr + 0x6e;
1289 + hpwdt_timer_reg = pci_mem_addr + 0x70;
1290 + hpwdt_timer_con = pci_mem_addr + 0x72;
1291 +
1292 +diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
1293 +index 7c23363ecf19..8d661b3c47b6 100644
1294 +--- a/fs/ext4/xattr.c
1295 ++++ b/fs/ext4/xattr.c
1296 +@@ -828,8 +828,6 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
1297 + if (!IS_LAST_ENTRY(s->first))
1298 + ext4_xattr_rehash(header(s->base),
1299 + s->here);
1300 +- ext4_xattr_cache_insert(ext4_mb_cache,
1301 +- bs->bh);
1302 + }
1303 + unlock_buffer(bs->bh);
1304 + if (error == -EFSCORRUPTED)
1305 +@@ -918,6 +916,7 @@ inserted:
1306 + } else if (bs->bh && s->base == bs->bh->b_data) {
1307 + /* We were modifying this block in-place. */
1308 + ea_bdebug(bs->bh, "keeping this block");
1309 ++ ext4_xattr_cache_insert(ext4_mb_cache, bs->bh);
1310 + new_bh = bs->bh;
1311 + get_bh(new_bh);
1312 + } else {
1313 +diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
1314 +index 5fd3cf54b2b3..211440722e24 100644
1315 +--- a/fs/nfs/direct.c
1316 ++++ b/fs/nfs/direct.c
1317 +@@ -86,9 +86,9 @@ struct nfs_direct_req {
1318 + struct nfs_direct_mirror mirrors[NFS_PAGEIO_DESCRIPTOR_MIRROR_MAX];
1319 + int mirror_count;
1320 +
1321 ++ loff_t io_start; /* Start offset for I/O */
1322 + ssize_t count, /* bytes actually processed */
1323 + bytes_left, /* bytes left to be sent */
1324 +- io_start, /* start of IO */
1325 + error; /* any reported error */
1326 + struct completion completion; /* wait for i/o completion */
1327 +
1328 +diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
1329 +index 3febb4b9fce9..d842bec3d271 100644
1330 +--- a/include/drm/drm_crtc_helper.h
1331 ++++ b/include/drm/drm_crtc_helper.h
1332 +@@ -241,5 +241,6 @@ extern void drm_kms_helper_hotplug_event(struct drm_device *dev);
1333 + extern void drm_kms_helper_poll_disable(struct drm_device *dev);
1334 + extern void drm_kms_helper_poll_enable(struct drm_device *dev);
1335 + extern void drm_kms_helper_poll_enable_locked(struct drm_device *dev);
1336 ++extern bool drm_kms_helper_is_poll_worker(void);
1337 +
1338 + #endif
1339 +diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
1340 +index d6c53fce006b..53e361a9af79 100644
1341 +--- a/include/linux/netfilter/x_tables.h
1342 ++++ b/include/linux/netfilter/x_tables.h
1343 +@@ -368,38 +368,14 @@ static inline unsigned long ifname_compare_aligned(const char *_a,
1344 + return ret;
1345 + }
1346 +
1347 ++struct xt_percpu_counter_alloc_state {
1348 ++ unsigned int off;
1349 ++ const char __percpu *mem;
1350 ++};
1351 +
1352 +-/* On SMP, ip(6)t_entry->counters.pcnt holds address of the
1353 +- * real (percpu) counter. On !SMP, its just the packet count,
1354 +- * so nothing needs to be done there.
1355 +- *
1356 +- * xt_percpu_counter_alloc returns the address of the percpu
1357 +- * counter, or 0 on !SMP. We force an alignment of 16 bytes
1358 +- * so that bytes/packets share a common cache line.
1359 +- *
1360 +- * Hence caller must use IS_ERR_VALUE to check for error, this
1361 +- * allows us to return 0 for single core systems without forcing
1362 +- * callers to deal with SMP vs. NONSMP issues.
1363 +- */
1364 +-static inline unsigned long xt_percpu_counter_alloc(void)
1365 +-{
1366 +- if (nr_cpu_ids > 1) {
1367 +- void __percpu *res = __alloc_percpu(sizeof(struct xt_counters),
1368 +- sizeof(struct xt_counters));
1369 +-
1370 +- if (res == NULL)
1371 +- return -ENOMEM;
1372 +-
1373 +- return (__force unsigned long) res;
1374 +- }
1375 +-
1376 +- return 0;
1377 +-}
1378 +-static inline void xt_percpu_counter_free(u64 pcnt)
1379 +-{
1380 +- if (nr_cpu_ids > 1)
1381 +- free_percpu((void __percpu *) (unsigned long) pcnt);
1382 +-}
1383 ++bool xt_percpu_counter_alloc(struct xt_percpu_counter_alloc_state *state,
1384 ++ struct xt_counters *counter);
1385 ++void xt_percpu_counter_free(struct xt_counters *cnt);
1386 +
1387 + static inline struct xt_counters *
1388 + xt_get_this_cpu_counter(struct xt_counters *cnt)
1389 +diff --git a/include/linux/nospec.h b/include/linux/nospec.h
1390 +index 4a040862f4bf..115381228203 100644
1391 +--- a/include/linux/nospec.h
1392 ++++ b/include/linux/nospec.h
1393 +@@ -5,6 +5,7 @@
1394 +
1395 + #ifndef _LINUX_NOSPEC_H
1396 + #define _LINUX_NOSPEC_H
1397 ++#include <asm/barrier.h>
1398 +
1399 + /**
1400 + * array_index_mask_nospec() - generate a ~0 mask when index < size, 0 otherwise
1401 +diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
1402 +index de2a722fe3cf..ea4f81c2a6d5 100644
1403 +--- a/include/linux/usb/quirks.h
1404 ++++ b/include/linux/usb/quirks.h
1405 +@@ -56,4 +56,7 @@
1406 + */
1407 + #define USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL BIT(11)
1408 +
1409 ++/* Device needs a pause after every control message. */
1410 ++#define USB_QUIRK_DELAY_CTRL_MSG BIT(13)
1411 ++
1412 + #endif /* __LINUX_USB_QUIRKS_H */
1413 +diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
1414 +index 217abe56e711..f63ce973b27b 100644
1415 +--- a/include/linux/workqueue.h
1416 ++++ b/include/linux/workqueue.h
1417 +@@ -451,6 +451,7 @@ extern bool cancel_delayed_work_sync(struct delayed_work *dwork);
1418 +
1419 + extern void workqueue_set_max_active(struct workqueue_struct *wq,
1420 + int max_active);
1421 ++extern struct work_struct *current_work(void);
1422 + extern bool current_is_workqueue_rescuer(void);
1423 + extern bool workqueue_congested(int cpu, struct workqueue_struct *wq);
1424 + extern unsigned int work_busy(struct work_struct *work);
1425 +diff --git a/kernel/workqueue.c b/kernel/workqueue.c
1426 +index 85555eb4d3cb..8df77ed6aa99 100644
1427 +--- a/kernel/workqueue.c
1428 ++++ b/kernel/workqueue.c
1429 +@@ -4047,6 +4047,22 @@ void workqueue_set_max_active(struct workqueue_struct *wq, int max_active)
1430 + }
1431 + EXPORT_SYMBOL_GPL(workqueue_set_max_active);
1432 +
1433 ++/**
1434 ++ * current_work - retrieve %current task's work struct
1435 ++ *
1436 ++ * Determine if %current task is a workqueue worker and what it's working on.
1437 ++ * Useful to find out the context that the %current task is running in.
1438 ++ *
1439 ++ * Return: work struct if %current task is a workqueue worker, %NULL otherwise.
1440 ++ */
1441 ++struct work_struct *current_work(void)
1442 ++{
1443 ++ struct worker *worker = current_wq_worker();
1444 ++
1445 ++ return worker ? worker->current_work : NULL;
1446 ++}
1447 ++EXPORT_SYMBOL(current_work);
1448 ++
1449 + /**
1450 + * current_is_workqueue_rescuer - is %current workqueue rescuer?
1451 + *
1452 +diff --git a/net/bridge/netfilter/ebt_among.c b/net/bridge/netfilter/ebt_among.c
1453 +index 9024283d2bca..9637a681bdda 100644
1454 +--- a/net/bridge/netfilter/ebt_among.c
1455 ++++ b/net/bridge/netfilter/ebt_among.c
1456 +@@ -172,18 +172,35 @@ ebt_among_mt(const struct sk_buff *skb, struct xt_action_param *par)
1457 + return true;
1458 + }
1459 +
1460 ++static bool poolsize_invalid(const struct ebt_mac_wormhash *w)
1461 ++{
1462 ++ return w && w->poolsize >= (INT_MAX / sizeof(struct ebt_mac_wormhash_tuple));
1463 ++}
1464 ++
1465 + static int ebt_among_mt_check(const struct xt_mtchk_param *par)
1466 + {
1467 + const struct ebt_among_info *info = par->matchinfo;
1468 + const struct ebt_entry_match *em =
1469 + container_of(par->matchinfo, const struct ebt_entry_match, data);
1470 +- int expected_length = sizeof(struct ebt_among_info);
1471 ++ unsigned int expected_length = sizeof(struct ebt_among_info);
1472 + const struct ebt_mac_wormhash *wh_dst, *wh_src;
1473 + int err;
1474 +
1475 ++ if (expected_length > em->match_size)
1476 ++ return -EINVAL;
1477 ++
1478 + wh_dst = ebt_among_wh_dst(info);
1479 +- wh_src = ebt_among_wh_src(info);
1480 ++ if (poolsize_invalid(wh_dst))
1481 ++ return -EINVAL;
1482 ++
1483 + expected_length += ebt_mac_wormhash_size(wh_dst);
1484 ++ if (expected_length > em->match_size)
1485 ++ return -EINVAL;
1486 ++
1487 ++ wh_src = ebt_among_wh_src(info);
1488 ++ if (poolsize_invalid(wh_src))
1489 ++ return -EINVAL;
1490 ++
1491 + expected_length += ebt_mac_wormhash_size(wh_src);
1492 +
1493 + if (em->match_size != EBT_ALIGN(expected_length)) {
1494 +diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
1495 +index f46ca417bf2d..50b76011f470 100644
1496 +--- a/net/bridge/netfilter/ebtables.c
1497 ++++ b/net/bridge/netfilter/ebtables.c
1498 +@@ -2021,7 +2021,9 @@ static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32,
1499 + if (match_kern)
1500 + match_kern->match_size = ret;
1501 +
1502 +- WARN_ON(type == EBT_COMPAT_TARGET && size_left);
1503 ++ if (WARN_ON(type == EBT_COMPAT_TARGET && size_left))
1504 ++ return -EINVAL;
1505 ++
1506 + match32 = (struct compat_ebt_entry_mwt *) buf;
1507 + }
1508 +
1509 +@@ -2078,6 +2080,15 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
1510 + *
1511 + * offsets are relative to beginning of struct ebt_entry (i.e., 0).
1512 + */
1513 ++ for (i = 0; i < 4 ; ++i) {
1514 ++ if (offsets[i] >= *total)
1515 ++ return -EINVAL;
1516 ++ if (i == 0)
1517 ++ continue;
1518 ++ if (offsets[i-1] > offsets[i])
1519 ++ return -EINVAL;
1520 ++ }
1521 ++
1522 + for (i = 0, j = 1 ; j < 4 ; j++, i++) {
1523 + struct compat_ebt_entry_mwt *match32;
1524 + unsigned int size;
1525 +diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c
1526 +index c3776ff6749f..699f8a5457a3 100644
1527 +--- a/net/ipv4/netfilter.c
1528 ++++ b/net/ipv4/netfilter.c
1529 +@@ -23,7 +23,8 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t
1530 + struct rtable *rt;
1531 + struct flowi4 fl4 = {};
1532 + __be32 saddr = iph->saddr;
1533 +- __u8 flags = skb->sk ? inet_sk_flowi_flags(skb->sk) : 0;
1534 ++ const struct sock *sk = skb_to_full_sk(skb);
1535 ++ __u8 flags = sk ? inet_sk_flowi_flags(sk) : 0;
1536 + unsigned int hh_len;
1537 +
1538 + if (addr_type == RTN_UNSPEC)
1539 +@@ -39,7 +40,7 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t
1540 + fl4.daddr = iph->daddr;
1541 + fl4.saddr = saddr;
1542 + fl4.flowi4_tos = RT_TOS(iph->tos);
1543 +- fl4.flowi4_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0;
1544 ++ fl4.flowi4_oif = sk ? sk->sk_bound_dev_if : 0;
1545 + fl4.flowi4_mark = skb->mark;
1546 + fl4.flowi4_flags = flags;
1547 + rt = ip_route_output_key(net, &fl4);
1548 +@@ -58,7 +59,7 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t
1549 + xfrm_decode_session(skb, flowi4_to_flowi(&fl4), AF_INET) == 0) {
1550 + struct dst_entry *dst = skb_dst(skb);
1551 + skb_dst_set(skb, NULL);
1552 +- dst = xfrm_lookup(net, dst, flowi4_to_flowi(&fl4), skb->sk, 0);
1553 ++ dst = xfrm_lookup(net, dst, flowi4_to_flowi(&fl4), sk, 0);
1554 + if (IS_ERR(dst))
1555 + return PTR_ERR(dst);
1556 + skb_dst_set(skb, dst);
1557 +diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
1558 +index 4cfcc22f7430..f51b32ed353c 100644
1559 +--- a/net/ipv4/netfilter/arp_tables.c
1560 ++++ b/net/ipv4/netfilter/arp_tables.c
1561 +@@ -329,6 +329,10 @@ unsigned int arpt_do_table(struct sk_buff *skb,
1562 + }
1563 + if (table_base + v
1564 + != arpt_next_entry(e)) {
1565 ++ if (unlikely(stackidx >= private->stacksize)) {
1566 ++ verdict = NF_DROP;
1567 ++ break;
1568 ++ }
1569 + jumpstack[stackidx++] = e;
1570 + }
1571 +
1572 +@@ -507,17 +511,15 @@ static inline int check_target(struct arpt_entry *e, const char *name)
1573 + }
1574 +
1575 + static inline int
1576 +-find_check_entry(struct arpt_entry *e, const char *name, unsigned int size)
1577 ++find_check_entry(struct arpt_entry *e, const char *name, unsigned int size,
1578 ++ struct xt_percpu_counter_alloc_state *alloc_state)
1579 + {
1580 + struct xt_entry_target *t;
1581 + struct xt_target *target;
1582 +- unsigned long pcnt;
1583 + int ret;
1584 +
1585 +- pcnt = xt_percpu_counter_alloc();
1586 +- if (IS_ERR_VALUE(pcnt))
1587 ++ if (!xt_percpu_counter_alloc(alloc_state, &e->counters))
1588 + return -ENOMEM;
1589 +- e->counters.pcnt = pcnt;
1590 +
1591 + t = arpt_get_target(e);
1592 + target = xt_request_find_target(NFPROTO_ARP, t->u.user.name,
1593 +@@ -536,7 +538,7 @@ find_check_entry(struct arpt_entry *e, const char *name, unsigned int size)
1594 + err:
1595 + module_put(t->u.kernel.target->me);
1596 + out:
1597 +- xt_percpu_counter_free(e->counters.pcnt);
1598 ++ xt_percpu_counter_free(&e->counters);
1599 +
1600 + return ret;
1601 + }
1602 +@@ -624,7 +626,7 @@ static inline void cleanup_entry(struct arpt_entry *e)
1603 + if (par.target->destroy != NULL)
1604 + par.target->destroy(&par);
1605 + module_put(par.target->me);
1606 +- xt_percpu_counter_free(e->counters.pcnt);
1607 ++ xt_percpu_counter_free(&e->counters);
1608 + }
1609 +
1610 + /* Checks and translates the user-supplied table segment (held in
1611 +@@ -633,6 +635,7 @@ static inline void cleanup_entry(struct arpt_entry *e)
1612 + static int translate_table(struct xt_table_info *newinfo, void *entry0,
1613 + const struct arpt_replace *repl)
1614 + {
1615 ++ struct xt_percpu_counter_alloc_state alloc_state = { 0 };
1616 + struct arpt_entry *iter;
1617 + unsigned int *offsets;
1618 + unsigned int i;
1619 +@@ -706,7 +709,8 @@ static int translate_table(struct xt_table_info *newinfo, void *entry0,
1620 + /* Finally, each sanity check must pass */
1621 + i = 0;
1622 + xt_entry_foreach(iter, entry0, newinfo->size) {
1623 +- ret = find_check_entry(iter, repl->name, repl->size);
1624 ++ ret = find_check_entry(iter, repl->name, repl->size,
1625 ++ &alloc_state);
1626 + if (ret != 0)
1627 + break;
1628 + ++i;
1629 +diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
1630 +index a98173d1ea97..dac62b5e7fe3 100644
1631 +--- a/net/ipv4/netfilter/ip_tables.c
1632 ++++ b/net/ipv4/netfilter/ip_tables.c
1633 +@@ -408,6 +408,10 @@ ipt_do_table(struct sk_buff *skb,
1634 + }
1635 + if (table_base + v != ipt_next_entry(e) &&
1636 + !(e->ip.flags & IPT_F_GOTO)) {
1637 ++ if (unlikely(stackidx >= private->stacksize)) {
1638 ++ verdict = NF_DROP;
1639 ++ break;
1640 ++ }
1641 + jumpstack[stackidx++] = e;
1642 + pr_debug("Pushed %p into pos %u\n",
1643 + e, stackidx - 1);
1644 +@@ -645,7 +649,8 @@ static int check_target(struct ipt_entry *e, struct net *net, const char *name)
1645 +
1646 + static int
1647 + find_check_entry(struct ipt_entry *e, struct net *net, const char *name,
1648 +- unsigned int size)
1649 ++ unsigned int size,
1650 ++ struct xt_percpu_counter_alloc_state *alloc_state)
1651 + {
1652 + struct xt_entry_target *t;
1653 + struct xt_target *target;
1654 +@@ -653,12 +658,9 @@ find_check_entry(struct ipt_entry *e, struct net *net, const char *name,
1655 + unsigned int j;
1656 + struct xt_mtchk_param mtpar;
1657 + struct xt_entry_match *ematch;
1658 +- unsigned long pcnt;
1659 +
1660 +- pcnt = xt_percpu_counter_alloc();
1661 +- if (IS_ERR_VALUE(pcnt))
1662 ++ if (!xt_percpu_counter_alloc(alloc_state, &e->counters))
1663 + return -ENOMEM;
1664 +- e->counters.pcnt = pcnt;
1665 +
1666 + j = 0;
1667 + mtpar.net = net;
1668 +@@ -697,7 +699,7 @@ find_check_entry(struct ipt_entry *e, struct net *net, const char *name,
1669 + cleanup_match(ematch, net);
1670 + }
1671 +
1672 +- xt_percpu_counter_free(e->counters.pcnt);
1673 ++ xt_percpu_counter_free(&e->counters);
1674 +
1675 + return ret;
1676 + }
1677 +@@ -793,7 +795,7 @@ cleanup_entry(struct ipt_entry *e, struct net *net)
1678 + if (par.target->destroy != NULL)
1679 + par.target->destroy(&par);
1680 + module_put(par.target->me);
1681 +- xt_percpu_counter_free(e->counters.pcnt);
1682 ++ xt_percpu_counter_free(&e->counters);
1683 + }
1684 +
1685 + /* Checks and translates the user-supplied table segment (held in
1686 +@@ -802,6 +804,7 @@ static int
1687 + translate_table(struct net *net, struct xt_table_info *newinfo, void *entry0,
1688 + const struct ipt_replace *repl)
1689 + {
1690 ++ struct xt_percpu_counter_alloc_state alloc_state = { 0 };
1691 + struct ipt_entry *iter;
1692 + unsigned int *offsets;
1693 + unsigned int i;
1694 +@@ -871,7 +874,8 @@ translate_table(struct net *net, struct xt_table_info *newinfo, void *entry0,
1695 + /* Finally, each sanity check must pass */
1696 + i = 0;
1697 + xt_entry_foreach(iter, entry0, newinfo->size) {
1698 +- ret = find_check_entry(iter, net, repl->name, repl->size);
1699 ++ ret = find_check_entry(iter, net, repl->name, repl->size,
1700 ++ &alloc_state);
1701 + if (ret != 0)
1702 + break;
1703 + ++i;
1704 +diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
1705 +index bb1b5453a7a1..795c343347ec 100644
1706 +--- a/net/ipv6/netfilter/ip6_tables.c
1707 ++++ b/net/ipv6/netfilter/ip6_tables.c
1708 +@@ -425,6 +425,10 @@ ip6t_do_table(struct sk_buff *skb,
1709 + }
1710 + if (table_base + v != ip6t_next_entry(e) &&
1711 + !(e->ipv6.flags & IP6T_F_GOTO)) {
1712 ++ if (unlikely(stackidx >= private->stacksize)) {
1713 ++ verdict = NF_DROP;
1714 ++ break;
1715 ++ }
1716 + jumpstack[stackidx++] = e;
1717 + }
1718 +
1719 +@@ -658,7 +662,8 @@ static int check_target(struct ip6t_entry *e, struct net *net, const char *name)
1720 +
1721 + static int
1722 + find_check_entry(struct ip6t_entry *e, struct net *net, const char *name,
1723 +- unsigned int size)
1724 ++ unsigned int size,
1725 ++ struct xt_percpu_counter_alloc_state *alloc_state)
1726 + {
1727 + struct xt_entry_target *t;
1728 + struct xt_target *target;
1729 +@@ -666,12 +671,9 @@ find_check_entry(struct ip6t_entry *e, struct net *net, const char *name,
1730 + unsigned int j;
1731 + struct xt_mtchk_param mtpar;
1732 + struct xt_entry_match *ematch;
1733 +- unsigned long pcnt;
1734 +
1735 +- pcnt = xt_percpu_counter_alloc();
1736 +- if (IS_ERR_VALUE(pcnt))
1737 ++ if (!xt_percpu_counter_alloc(alloc_state, &e->counters))
1738 + return -ENOMEM;
1739 +- e->counters.pcnt = pcnt;
1740 +
1741 + j = 0;
1742 + mtpar.net = net;
1743 +@@ -709,7 +711,7 @@ find_check_entry(struct ip6t_entry *e, struct net *net, const char *name,
1744 + cleanup_match(ematch, net);
1745 + }
1746 +
1747 +- xt_percpu_counter_free(e->counters.pcnt);
1748 ++ xt_percpu_counter_free(&e->counters);
1749 +
1750 + return ret;
1751 + }
1752 +@@ -804,8 +806,7 @@ static void cleanup_entry(struct ip6t_entry *e, struct net *net)
1753 + if (par.target->destroy != NULL)
1754 + par.target->destroy(&par);
1755 + module_put(par.target->me);
1756 +-
1757 +- xt_percpu_counter_free(e->counters.pcnt);
1758 ++ xt_percpu_counter_free(&e->counters);
1759 + }
1760 +
1761 + /* Checks and translates the user-supplied table segment (held in
1762 +@@ -814,6 +815,7 @@ static int
1763 + translate_table(struct net *net, struct xt_table_info *newinfo, void *entry0,
1764 + const struct ip6t_replace *repl)
1765 + {
1766 ++ struct xt_percpu_counter_alloc_state alloc_state = { 0 };
1767 + struct ip6t_entry *iter;
1768 + unsigned int *offsets;
1769 + unsigned int i;
1770 +@@ -883,7 +885,8 @@ translate_table(struct net *net, struct xt_table_info *newinfo, void *entry0,
1771 + /* Finally, each sanity check must pass */
1772 + i = 0;
1773 + xt_entry_foreach(iter, entry0, newinfo->size) {
1774 +- ret = find_check_entry(iter, net, repl->name, repl->size);
1775 ++ ret = find_check_entry(iter, net, repl->name, repl->size,
1776 ++ &alloc_state);
1777 + if (ret != 0)
1778 + break;
1779 + ++i;
1780 +diff --git a/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c b/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
1781 +index 238e70c3f7b7..7b9c2cabd495 100644
1782 +--- a/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
1783 ++++ b/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
1784 +@@ -99,6 +99,10 @@ static bool nf_nat_ipv6_manip_pkt(struct sk_buff *skb,
1785 + !l4proto->manip_pkt(skb, &nf_nat_l3proto_ipv6, iphdroff, hdroff,
1786 + target, maniptype))
1787 + return false;
1788 ++
1789 ++ /* must reload, offset might have changed */
1790 ++ ipv6h = (void *)skb->data + iphdroff;
1791 ++
1792 + manip_addr:
1793 + if (maniptype == NF_NAT_MANIP_SRC)
1794 + ipv6h->saddr = target->src.u3.in6;
1795 +diff --git a/net/netfilter/nf_nat_proto_common.c b/net/netfilter/nf_nat_proto_common.c
1796 +index fbce552a796e..7d7466dbf663 100644
1797 +--- a/net/netfilter/nf_nat_proto_common.c
1798 ++++ b/net/netfilter/nf_nat_proto_common.c
1799 +@@ -41,7 +41,7 @@ void nf_nat_l4proto_unique_tuple(const struct nf_nat_l3proto *l3proto,
1800 + const struct nf_conn *ct,
1801 + u16 *rover)
1802 + {
1803 +- unsigned int range_size, min, i;
1804 ++ unsigned int range_size, min, max, i;
1805 + __be16 *portptr;
1806 + u_int16_t off;
1807 +
1808 +@@ -71,7 +71,10 @@ void nf_nat_l4proto_unique_tuple(const struct nf_nat_l3proto *l3proto,
1809 + }
1810 + } else {
1811 + min = ntohs(range->min_proto.all);
1812 +- range_size = ntohs(range->max_proto.all) - min + 1;
1813 ++ max = ntohs(range->max_proto.all);
1814 ++ if (unlikely(max < min))
1815 ++ swap(max, min);
1816 ++ range_size = max - min + 1;
1817 + }
1818 +
1819 + if (range->flags & NF_NAT_RANGE_PROTO_RANDOM) {
1820 +diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
1821 +index f853b55bf877..7edcfda288c4 100644
1822 +--- a/net/netfilter/nfnetlink_queue.c
1823 ++++ b/net/netfilter/nfnetlink_queue.c
1824 +@@ -501,7 +501,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
1825 +
1826 + if (entskb->tstamp.tv64) {
1827 + struct nfqnl_msg_packet_timestamp ts;
1828 +- struct timespec64 kts = ktime_to_timespec64(skb->tstamp);
1829 ++ struct timespec64 kts = ktime_to_timespec64(entskb->tstamp);
1830 +
1831 + ts.sec = cpu_to_be64(kts.tv_sec);
1832 + ts.usec = cpu_to_be64(kts.tv_nsec / NSEC_PER_USEC);
1833 +diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
1834 +index 5b52dd3feb7d..34ae20490c94 100644
1835 +--- a/net/netfilter/x_tables.c
1836 ++++ b/net/netfilter/x_tables.c
1837 +@@ -38,6 +38,8 @@ MODULE_LICENSE("GPL");
1838 + MODULE_AUTHOR("Harald Welte <laforge@×××××××××.org>");
1839 + MODULE_DESCRIPTION("{ip,ip6,arp,eb}_tables backend module");
1840 +
1841 ++#define XT_PCPU_BLOCK_SIZE 4096
1842 ++
1843 + struct compat_delta {
1844 + unsigned int offset; /* offset in kernel */
1845 + int delta; /* delta in 32bit user land */
1846 +@@ -1592,6 +1594,59 @@ void xt_proto_fini(struct net *net, u_int8_t af)
1847 + }
1848 + EXPORT_SYMBOL_GPL(xt_proto_fini);
1849 +
1850 ++/**
1851 ++ * xt_percpu_counter_alloc - allocate x_tables rule counter
1852 ++ *
1853 ++ * @state: pointer to xt_percpu allocation state
1854 ++ * @counter: pointer to counter struct inside the ip(6)/arpt_entry struct
1855 ++ *
1856 ++ * On SMP, the packet counter [ ip(6)t_entry->counters.pcnt ] will then
1857 ++ * contain the address of the real (percpu) counter.
1858 ++ *
1859 ++ * Rule evaluation needs to use xt_get_this_cpu_counter() helper
1860 ++ * to fetch the real percpu counter.
1861 ++ *
1862 ++ * To speed up allocation and improve data locality, a 4kb block is
1863 ++ * allocated.
1864 ++ *
1865 ++ * xt_percpu_counter_alloc_state contains the base address of the
1866 ++ * allocated page and the current sub-offset.
1867 ++ *
1868 ++ * returns false on error.
1869 ++ */
1870 ++bool xt_percpu_counter_alloc(struct xt_percpu_counter_alloc_state *state,
1871 ++ struct xt_counters *counter)
1872 ++{
1873 ++ BUILD_BUG_ON(XT_PCPU_BLOCK_SIZE < (sizeof(*counter) * 2));
1874 ++
1875 ++ if (nr_cpu_ids <= 1)
1876 ++ return true;
1877 ++
1878 ++ if (!state->mem) {
1879 ++ state->mem = __alloc_percpu(XT_PCPU_BLOCK_SIZE,
1880 ++ XT_PCPU_BLOCK_SIZE);
1881 ++ if (!state->mem)
1882 ++ return false;
1883 ++ }
1884 ++ counter->pcnt = (__force unsigned long)(state->mem + state->off);
1885 ++ state->off += sizeof(*counter);
1886 ++ if (state->off > (XT_PCPU_BLOCK_SIZE - sizeof(*counter))) {
1887 ++ state->mem = NULL;
1888 ++ state->off = 0;
1889 ++ }
1890 ++ return true;
1891 ++}
1892 ++EXPORT_SYMBOL_GPL(xt_percpu_counter_alloc);
1893 ++
1894 ++void xt_percpu_counter_free(struct xt_counters *counters)
1895 ++{
1896 ++ unsigned long pcnt = counters->pcnt;
1897 ++
1898 ++ if (nr_cpu_ids > 1 && (pcnt & (XT_PCPU_BLOCK_SIZE - 1)) == 0)
1899 ++ free_percpu((void __percpu *)pcnt);
1900 ++}
1901 ++EXPORT_SYMBOL_GPL(xt_percpu_counter_free);
1902 ++
1903 + static int __net_init xt_net_init(struct net *net)
1904 + {
1905 + int i;
1906 +diff --git a/net/netfilter/xt_IDLETIMER.c b/net/netfilter/xt_IDLETIMER.c
1907 +index 29d2c31f406c..1718f536689f 100644
1908 +--- a/net/netfilter/xt_IDLETIMER.c
1909 ++++ b/net/netfilter/xt_IDLETIMER.c
1910 +@@ -147,11 +147,11 @@ static int idletimer_tg_create(struct idletimer_tg_info *info)
1911 + (unsigned long) info->timer);
1912 + info->timer->refcnt = 1;
1913 +
1914 ++ INIT_WORK(&info->timer->work, idletimer_tg_work);
1915 ++
1916 + mod_timer(&info->timer->timer,
1917 + msecs_to_jiffies(info->timeout * 1000) + jiffies);
1918 +
1919 +- INIT_WORK(&info->timer->work, idletimer_tg_work);
1920 +-
1921 + return 0;
1922 +
1923 + out_free_attr:
1924 +@@ -192,7 +192,10 @@ static int idletimer_tg_checkentry(const struct xt_tgchk_param *par)
1925 + pr_debug("timeout value is zero\n");
1926 + return -EINVAL;
1927 + }
1928 +-
1929 ++ if (info->timeout >= INT_MAX / 1000) {
1930 ++ pr_debug("timeout value is too big\n");
1931 ++ return -EINVAL;
1932 ++ }
1933 + if (info->label[0] == '\0' ||
1934 + strnlen(info->label,
1935 + MAX_IDLETIMER_LABEL_SIZE) == MAX_IDLETIMER_LABEL_SIZE) {
1936 +diff --git a/net/netfilter/xt_LED.c b/net/netfilter/xt_LED.c
1937 +index 3ba31c194cce..0858fe17e14a 100644
1938 +--- a/net/netfilter/xt_LED.c
1939 ++++ b/net/netfilter/xt_LED.c
1940 +@@ -141,10 +141,11 @@ static int led_tg_check(const struct xt_tgchk_param *par)
1941 + goto exit_alloc;
1942 + }
1943 +
1944 +- /* See if we need to set up a timer */
1945 +- if (ledinfo->delay > 0)
1946 +- setup_timer(&ledinternal->timer, led_timeout_callback,
1947 +- (unsigned long)ledinternal);
1948 ++ /* Since the letinternal timer can be shared between multiple targets,
1949 ++ * always set it up, even if the current target does not need it
1950 ++ */
1951 ++ setup_timer(&ledinternal->timer, led_timeout_callback,
1952 ++ (unsigned long)ledinternal);
1953 +
1954 + list_add_tail(&ledinternal->list, &xt_led_triggers);
1955 +
1956 +@@ -181,8 +182,7 @@ static void led_tg_destroy(const struct xt_tgdtor_param *par)
1957 +
1958 + list_del(&ledinternal->list);
1959 +
1960 +- if (ledinfo->delay > 0)
1961 +- del_timer_sync(&ledinternal->timer);
1962 ++ del_timer_sync(&ledinternal->timer);
1963 +
1964 + led_trigger_unregister(&ledinternal->netfilter_led_trigger);
1965 +
1966 +diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
1967 +index 4ca31e052dd8..509e9426a056 100644
1968 +--- a/net/sctp/sm_make_chunk.c
1969 ++++ b/net/sctp/sm_make_chunk.c
1970 +@@ -1369,7 +1369,7 @@ static struct sctp_chunk *_sctp_make_chunk(const struct sctp_association *asoc,
1971 + struct sock *sk;
1972 + int chunklen;
1973 +
1974 +- chunklen = sizeof(*chunk_hdr) + paylen;
1975 ++ chunklen = WORD_ROUND(sizeof(*chunk_hdr) + paylen);
1976 + if (chunklen > SCTP_MAX_CHUNK_LEN)
1977 + goto nodata;
1978 +
1979 +diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
1980 +index 79e86613712f..24914e7de944 100644
1981 +--- a/scripts/Makefile.lib
1982 ++++ b/scripts/Makefile.lib
1983 +@@ -270,11 +270,11 @@ cmd_dt_S_dtb= \
1984 + echo '\#include <asm-generic/vmlinux.lds.h>'; \
1985 + echo '.section .dtb.init.rodata,"a"'; \
1986 + echo '.balign STRUCT_ALIGNMENT'; \
1987 +- echo '.global __dtb_$(*F)_begin'; \
1988 +- echo '__dtb_$(*F)_begin:'; \
1989 ++ echo '.global __dtb_$(subst -,_,$(*F))_begin'; \
1990 ++ echo '__dtb_$(subst -,_,$(*F))_begin:'; \
1991 + echo '.incbin "$<" '; \
1992 +- echo '__dtb_$(*F)_end:'; \
1993 +- echo '.global __dtb_$(*F)_end'; \
1994 ++ echo '__dtb_$(subst -,_,$(*F))_end:'; \
1995 ++ echo '.global __dtb_$(subst -,_,$(*F))_end'; \
1996 + echo '.balign STRUCT_ALIGNMENT'; \
1997 + ) > $@
1998 +
1999 +diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
2000 +index 167b943469ab..94fd3df2cf21 100644
2001 +--- a/sound/core/seq/seq_clientmgr.c
2002 ++++ b/sound/core/seq/seq_clientmgr.c
2003 +@@ -919,7 +919,8 @@ int snd_seq_dispatch_event(struct snd_seq_event_cell *cell, int atomic, int hop)
2004 + static int snd_seq_client_enqueue_event(struct snd_seq_client *client,
2005 + struct snd_seq_event *event,
2006 + struct file *file, int blocking,
2007 +- int atomic, int hop)
2008 ++ int atomic, int hop,
2009 ++ struct mutex *mutexp)
2010 + {
2011 + struct snd_seq_event_cell *cell;
2012 + int err;
2013 +@@ -957,7 +958,8 @@ static int snd_seq_client_enqueue_event(struct snd_seq_client *client,
2014 + return -ENXIO; /* queue is not allocated */
2015 +
2016 + /* allocate an event cell */
2017 +- err = snd_seq_event_dup(client->pool, event, &cell, !blocking || atomic, file);
2018 ++ err = snd_seq_event_dup(client->pool, event, &cell, !blocking || atomic,
2019 ++ file, mutexp);
2020 + if (err < 0)
2021 + return err;
2022 +
2023 +@@ -1026,12 +1028,11 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf,
2024 + return -ENXIO;
2025 +
2026 + /* allocate the pool now if the pool is not allocated yet */
2027 ++ mutex_lock(&client->ioctl_mutex);
2028 + if (client->pool->size > 0 && !snd_seq_write_pool_allocated(client)) {
2029 +- mutex_lock(&client->ioctl_mutex);
2030 + err = snd_seq_pool_init(client->pool);
2031 +- mutex_unlock(&client->ioctl_mutex);
2032 + if (err < 0)
2033 +- return -ENOMEM;
2034 ++ goto out;
2035 + }
2036 +
2037 + /* only process whole events */
2038 +@@ -1082,7 +1083,7 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf,
2039 + /* ok, enqueue it */
2040 + err = snd_seq_client_enqueue_event(client, &event, file,
2041 + !(file->f_flags & O_NONBLOCK),
2042 +- 0, 0);
2043 ++ 0, 0, &client->ioctl_mutex);
2044 + if (err < 0)
2045 + break;
2046 +
2047 +@@ -1093,6 +1094,8 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf,
2048 + written += len;
2049 + }
2050 +
2051 ++ out:
2052 ++ mutex_unlock(&client->ioctl_mutex);
2053 + return written ? written : err;
2054 + }
2055 +
2056 +@@ -1924,6 +1927,9 @@ static int snd_seq_ioctl_set_client_pool(struct snd_seq_client *client,
2057 + (! snd_seq_write_pool_allocated(client) ||
2058 + info.output_pool != client->pool->size)) {
2059 + if (snd_seq_write_pool_allocated(client)) {
2060 ++ /* is the pool in use? */
2061 ++ if (atomic_read(&client->pool->counter))
2062 ++ return -EBUSY;
2063 + /* remove all existing cells */
2064 + snd_seq_pool_mark_closing(client->pool);
2065 + snd_seq_queue_client_leave_cells(client->number);
2066 +@@ -2347,7 +2353,8 @@ static int kernel_client_enqueue(int client, struct snd_seq_event *ev,
2067 + if (! cptr->accept_output)
2068 + result = -EPERM;
2069 + else /* send it */
2070 +- result = snd_seq_client_enqueue_event(cptr, ev, file, blocking, atomic, hop);
2071 ++ result = snd_seq_client_enqueue_event(cptr, ev, file, blocking,
2072 ++ atomic, hop, NULL);
2073 +
2074 + snd_seq_client_unlock(cptr);
2075 + return result;
2076 +diff --git a/sound/core/seq/seq_fifo.c b/sound/core/seq/seq_fifo.c
2077 +index 3490d21ab9e7..9acbed1ac982 100644
2078 +--- a/sound/core/seq/seq_fifo.c
2079 ++++ b/sound/core/seq/seq_fifo.c
2080 +@@ -123,7 +123,7 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f,
2081 + return -EINVAL;
2082 +
2083 + snd_use_lock_use(&f->use_lock);
2084 +- err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL); /* always non-blocking */
2085 ++ err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL, NULL); /* always non-blocking */
2086 + if (err < 0) {
2087 + if ((err == -ENOMEM) || (err == -EAGAIN))
2088 + atomic_inc(&f->overflow);
2089 +diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c
2090 +index 5847c4475bf3..4c8cbcd89887 100644
2091 +--- a/sound/core/seq/seq_memory.c
2092 ++++ b/sound/core/seq/seq_memory.c
2093 +@@ -221,7 +221,8 @@ void snd_seq_cell_free(struct snd_seq_event_cell * cell)
2094 + */
2095 + static int snd_seq_cell_alloc(struct snd_seq_pool *pool,
2096 + struct snd_seq_event_cell **cellp,
2097 +- int nonblock, struct file *file)
2098 ++ int nonblock, struct file *file,
2099 ++ struct mutex *mutexp)
2100 + {
2101 + struct snd_seq_event_cell *cell;
2102 + unsigned long flags;
2103 +@@ -245,7 +246,11 @@ static int snd_seq_cell_alloc(struct snd_seq_pool *pool,
2104 + set_current_state(TASK_INTERRUPTIBLE);
2105 + add_wait_queue(&pool->output_sleep, &wait);
2106 + spin_unlock_irq(&pool->lock);
2107 ++ if (mutexp)
2108 ++ mutex_unlock(mutexp);
2109 + schedule();
2110 ++ if (mutexp)
2111 ++ mutex_lock(mutexp);
2112 + spin_lock_irq(&pool->lock);
2113 + remove_wait_queue(&pool->output_sleep, &wait);
2114 + /* interrupted? */
2115 +@@ -288,7 +293,7 @@ __error:
2116 + */
2117 + int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event,
2118 + struct snd_seq_event_cell **cellp, int nonblock,
2119 +- struct file *file)
2120 ++ struct file *file, struct mutex *mutexp)
2121 + {
2122 + int ncells, err;
2123 + unsigned int extlen;
2124 +@@ -305,7 +310,7 @@ int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event,
2125 + if (ncells >= pool->total_elements)
2126 + return -ENOMEM;
2127 +
2128 +- err = snd_seq_cell_alloc(pool, &cell, nonblock, file);
2129 ++ err = snd_seq_cell_alloc(pool, &cell, nonblock, file, mutexp);
2130 + if (err < 0)
2131 + return err;
2132 +
2133 +@@ -331,7 +336,8 @@ int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event,
2134 + int size = sizeof(struct snd_seq_event);
2135 + if (len < size)
2136 + size = len;
2137 +- err = snd_seq_cell_alloc(pool, &tmp, nonblock, file);
2138 ++ err = snd_seq_cell_alloc(pool, &tmp, nonblock, file,
2139 ++ mutexp);
2140 + if (err < 0)
2141 + goto __error;
2142 + if (cell->event.data.ext.ptr == NULL)
2143 +diff --git a/sound/core/seq/seq_memory.h b/sound/core/seq/seq_memory.h
2144 +index 32f959c17786..3abe306c394a 100644
2145 +--- a/sound/core/seq/seq_memory.h
2146 ++++ b/sound/core/seq/seq_memory.h
2147 +@@ -66,7 +66,8 @@ struct snd_seq_pool {
2148 + void snd_seq_cell_free(struct snd_seq_event_cell *cell);
2149 +
2150 + int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event,
2151 +- struct snd_seq_event_cell **cellp, int nonblock, struct file *file);
2152 ++ struct snd_seq_event_cell **cellp, int nonblock,
2153 ++ struct file *file, struct mutex *mutexp);
2154 +
2155 + /* return number of unused (free) cells */
2156 + static inline int snd_seq_unused_cells(struct snd_seq_pool *pool)
2157 +diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
2158 +index c92b7ba344ef..9fae1d248318 100644
2159 +--- a/sound/pci/hda/patch_conexant.c
2160 ++++ b/sound/pci/hda/patch_conexant.c
2161 +@@ -849,6 +849,8 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
2162 + SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_ASPIRE_DMIC),
2163 + SND_PCI_QUIRK(0x1025, 0x054f, "Acer Aspire 4830T", CXT_FIXUP_ASPIRE_DMIC),
2164 + SND_PCI_QUIRK(0x103c, 0x8079, "HP EliteBook 840 G3", CXT_FIXUP_HP_DOCK),
2165 ++ SND_PCI_QUIRK(0x103c, 0x807C, "HP EliteBook 820 G3", CXT_FIXUP_HP_DOCK),
2166 ++ SND_PCI_QUIRK(0x103c, 0x80FD, "HP ProBook 640 G2", CXT_FIXUP_HP_DOCK),
2167 + SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE),
2168 + SND_PCI_QUIRK(0x103c, 0x8115, "HP Z1 Gen3", CXT_FIXUP_HP_GATE_MIC),
2169 + SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN),
2170 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
2171 +index b302d056e5d3..11305a4baf7b 100644
2172 +--- a/sound/pci/hda/patch_realtek.c
2173 ++++ b/sound/pci/hda/patch_realtek.c
2174 +@@ -4722,6 +4722,16 @@ static void alc298_fixup_speaker_volume(struct hda_codec *codec,
2175 + }
2176 + }
2177 +
2178 ++/* disable DAC3 (0x06) selection on NID 0x17 as it has no volume amp control */
2179 ++static void alc295_fixup_disable_dac3(struct hda_codec *codec,
2180 ++ const struct hda_fixup *fix, int action)
2181 ++{
2182 ++ if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2183 ++ hda_nid_t conn[2] = { 0x02, 0x03 };
2184 ++ snd_hda_override_conn_list(codec, 0x17, 2, conn);
2185 ++ }
2186 ++}
2187 ++
2188 + /* Hook to update amp GPIO4 for automute */
2189 + static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
2190 + struct hda_jack_callback *jack)
2191 +@@ -4871,6 +4881,7 @@ enum {
2192 + ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
2193 + ALC255_FIXUP_DELL_SPK_NOISE,
2194 + ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
2195 ++ ALC295_FIXUP_DISABLE_DAC3,
2196 + ALC280_FIXUP_HP_HEADSET_MIC,
2197 + ALC221_FIXUP_HP_FRONT_MIC,
2198 + ALC292_FIXUP_TPT460,
2199 +@@ -5560,6 +5571,10 @@ static const struct hda_fixup alc269_fixups[] = {
2200 + .chained = true,
2201 + .chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
2202 + },
2203 ++ [ALC295_FIXUP_DISABLE_DAC3] = {
2204 ++ .type = HDA_FIXUP_FUNC,
2205 ++ .v.func = alc295_fixup_disable_dac3,
2206 ++ },
2207 + [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
2208 + .type = HDA_FIXUP_PINS,
2209 + .v.pins = (const struct hda_pintbl[]) {
2210 +@@ -5617,6 +5632,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
2211 + SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
2212 + SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
2213 + SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
2214 ++ SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3),
2215 + SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
2216 + SND_PCI_QUIRK(0x1028, 0x082a, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
2217 + SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
2218
2219 diff --git a/1122_linux-4.4.123.patch b/1122_linux-4.4.123.patch
2220 new file mode 100644
2221 index 0000000..6d1e7d8
2222 --- /dev/null
2223 +++ b/1122_linux-4.4.123.patch
2224 @@ -0,0 +1,3500 @@
2225 +diff --git a/Makefile b/Makefile
2226 +index 3eb21d269b42..cbcc04da790a 100644
2227 +--- a/Makefile
2228 ++++ b/Makefile
2229 +@@ -1,6 +1,6 @@
2230 + VERSION = 4
2231 + PATCHLEVEL = 4
2232 +-SUBLEVEL = 122
2233 ++SUBLEVEL = 123
2234 + EXTRAVERSION =
2235 + NAME = Blurry Fish Butt
2236 +
2237 +diff --git a/arch/arm/boot/dts/am335x-pepper.dts b/arch/arm/boot/dts/am335x-pepper.dts
2238 +index 7106114c7464..2dbe13a3d89b 100644
2239 +--- a/arch/arm/boot/dts/am335x-pepper.dts
2240 ++++ b/arch/arm/boot/dts/am335x-pepper.dts
2241 +@@ -139,7 +139,7 @@
2242 + &audio_codec {
2243 + status = "okay";
2244 +
2245 +- gpio-reset = <&gpio1 16 GPIO_ACTIVE_LOW>;
2246 ++ reset-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>;
2247 + AVDD-supply = <&ldo3_reg>;
2248 + IOVDD-supply = <&ldo3_reg>;
2249 + DRVDD-supply = <&ldo3_reg>;
2250 +diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts
2251 +index 40a474c4374b..4c52358734ef 100644
2252 +--- a/arch/arm/boot/dts/exynos4412-trats2.dts
2253 ++++ b/arch/arm/boot/dts/exynos4412-trats2.dts
2254 +@@ -359,7 +359,7 @@
2255 + reg = <0>;
2256 + vdd3-supply = <&lcd_vdd3_reg>;
2257 + vci-supply = <&ldo25_reg>;
2258 +- reset-gpios = <&gpy4 5 GPIO_ACTIVE_HIGH>;
2259 ++ reset-gpios = <&gpf2 1 GPIO_ACTIVE_HIGH>;
2260 + power-on-delay= <50>;
2261 + reset-delay = <100>;
2262 + init-delay = <100>;
2263 +diff --git a/arch/arm/boot/dts/logicpd-torpedo-som.dtsi b/arch/arm/boot/dts/logicpd-torpedo-som.dtsi
2264 +index 80f6c786a37e..e05670423d8b 100644
2265 +--- a/arch/arm/boot/dts/logicpd-torpedo-som.dtsi
2266 ++++ b/arch/arm/boot/dts/logicpd-torpedo-som.dtsi
2267 +@@ -90,6 +90,8 @@
2268 + };
2269 +
2270 + &i2c1 {
2271 ++ pinctrl-names = "default";
2272 ++ pinctrl-0 = <&i2c1_pins>;
2273 + clock-frequency = <2600000>;
2274 +
2275 + twl: twl@48 {
2276 +@@ -137,6 +139,12 @@
2277 + OMAP3_CORE1_IOPAD(0x218e, PIN_OUTPUT | MUX_MODE4) /* mcbsp1_fsr.gpio_157 */
2278 + >;
2279 + };
2280 ++ i2c1_pins: pinmux_i2c1_pins {
2281 ++ pinctrl-single,pins = <
2282 ++ OMAP3_CORE1_IOPAD(0x21ba, PIN_INPUT | MUX_MODE0) /* i2c1_scl.i2c1_scl */
2283 ++ OMAP3_CORE1_IOPAD(0x21bc, PIN_INPUT | MUX_MODE0) /* i2c1_sda.i2c1_sda */
2284 ++ >;
2285 ++ };
2286 + };
2287 +
2288 + &omap3_pmx_core2 {
2289 +diff --git a/arch/arm/boot/dts/moxart-uc7112lx.dts b/arch/arm/boot/dts/moxart-uc7112lx.dts
2290 +index 10d088df0c35..4a962a26482d 100644
2291 +--- a/arch/arm/boot/dts/moxart-uc7112lx.dts
2292 ++++ b/arch/arm/boot/dts/moxart-uc7112lx.dts
2293 +@@ -6,7 +6,7 @@
2294 + */
2295 +
2296 + /dts-v1/;
2297 +-/include/ "moxart.dtsi"
2298 ++#include "moxart.dtsi"
2299 +
2300 + / {
2301 + model = "MOXA UC-7112-LX";
2302 +diff --git a/arch/arm/boot/dts/moxart.dtsi b/arch/arm/boot/dts/moxart.dtsi
2303 +index 1fd27ed65a01..64f2f44235d0 100644
2304 +--- a/arch/arm/boot/dts/moxart.dtsi
2305 ++++ b/arch/arm/boot/dts/moxart.dtsi
2306 +@@ -6,6 +6,7 @@
2307 + */
2308 +
2309 + /include/ "skeleton.dtsi"
2310 ++#include <dt-bindings/interrupt-controller/irq.h>
2311 +
2312 + / {
2313 + compatible = "moxa,moxart";
2314 +@@ -36,8 +37,8 @@
2315 + ranges;
2316 +
2317 + intc: interrupt-controller@98800000 {
2318 +- compatible = "moxa,moxart-ic";
2319 +- reg = <0x98800000 0x38>;
2320 ++ compatible = "moxa,moxart-ic", "faraday,ftintc010";
2321 ++ reg = <0x98800000 0x100>;
2322 + interrupt-controller;
2323 + #interrupt-cells = <2>;
2324 + interrupt-mask = <0x00080000>;
2325 +@@ -59,7 +60,7 @@
2326 + timer: timer@98400000 {
2327 + compatible = "moxa,moxart-timer";
2328 + reg = <0x98400000 0x42>;
2329 +- interrupts = <19 1>;
2330 ++ interrupts = <19 IRQ_TYPE_EDGE_FALLING>;
2331 + clocks = <&clk_apb>;
2332 + };
2333 +
2334 +@@ -80,7 +81,7 @@
2335 + dma: dma@90500000 {
2336 + compatible = "moxa,moxart-dma";
2337 + reg = <0x90500080 0x40>;
2338 +- interrupts = <24 0>;
2339 ++ interrupts = <24 IRQ_TYPE_LEVEL_HIGH>;
2340 + #dma-cells = <1>;
2341 + };
2342 +
2343 +@@ -93,7 +94,7 @@
2344 + sdhci: sdhci@98e00000 {
2345 + compatible = "moxa,moxart-sdhci";
2346 + reg = <0x98e00000 0x5C>;
2347 +- interrupts = <5 0>;
2348 ++ interrupts = <5 IRQ_TYPE_LEVEL_HIGH>;
2349 + clocks = <&clk_apb>;
2350 + dmas = <&dma 5>,
2351 + <&dma 5>;
2352 +@@ -120,7 +121,7 @@
2353 + mac0: mac@90900000 {
2354 + compatible = "moxa,moxart-mac";
2355 + reg = <0x90900000 0x90>;
2356 +- interrupts = <25 0>;
2357 ++ interrupts = <25 IRQ_TYPE_LEVEL_HIGH>;
2358 + phy-handle = <&ethphy0>;
2359 + phy-mode = "mii";
2360 + status = "disabled";
2361 +@@ -129,7 +130,7 @@
2362 + mac1: mac@92000000 {
2363 + compatible = "moxa,moxart-mac";
2364 + reg = <0x92000000 0x90>;
2365 +- interrupts = <27 0>;
2366 ++ interrupts = <27 IRQ_TYPE_LEVEL_HIGH>;
2367 + phy-handle = <&ethphy1>;
2368 + phy-mode = "mii";
2369 + status = "disabled";
2370 +@@ -138,7 +139,7 @@
2371 + uart0: uart@98200000 {
2372 + compatible = "ns16550a";
2373 + reg = <0x98200000 0x20>;
2374 +- interrupts = <31 8>;
2375 ++ interrupts = <31 IRQ_TYPE_LEVEL_HIGH>;
2376 + reg-shift = <2>;
2377 + reg-io-width = <4>;
2378 + clock-frequency = <14745600>;
2379 +diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
2380 +index 27cd4abfc74d..731860314ab5 100644
2381 +--- a/arch/arm/boot/dts/omap3-n900.dts
2382 ++++ b/arch/arm/boot/dts/omap3-n900.dts
2383 +@@ -488,7 +488,7 @@
2384 + tlv320aic3x: tlv320aic3x@18 {
2385 + compatible = "ti,tlv320aic3x";
2386 + reg = <0x18>;
2387 +- gpio-reset = <&gpio2 28 GPIO_ACTIVE_HIGH>; /* 60 */
2388 ++ reset-gpios = <&gpio2 28 GPIO_ACTIVE_LOW>; /* 60 */
2389 + ai3x-gpio-func = <
2390 + 0 /* AIC3X_GPIO1_FUNC_DISABLED */
2391 + 5 /* AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT */
2392 +@@ -505,7 +505,7 @@
2393 + tlv320aic3x_aux: tlv320aic3x@19 {
2394 + compatible = "ti,tlv320aic3x";
2395 + reg = <0x19>;
2396 +- gpio-reset = <&gpio2 28 GPIO_ACTIVE_HIGH>; /* 60 */
2397 ++ reset-gpios = <&gpio2 28 GPIO_ACTIVE_LOW>; /* 60 */
2398 +
2399 + AVDD-supply = <&vmmc2>;
2400 + DRVDD-supply = <&vmmc2>;
2401 +diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
2402 +index 7b39d8fae61e..bd83a61f724f 100644
2403 +--- a/arch/arm/boot/dts/r8a7790.dtsi
2404 ++++ b/arch/arm/boot/dts/r8a7790.dtsi
2405 +@@ -1360,8 +1360,11 @@
2406 + compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks";
2407 + reg = <0 0xe6150998 0 4>, <0 0xe61509a8 0 4>;
2408 + clocks = <&p_clk>,
2409 +- <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>,
2410 +- <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>,
2411 ++ <&mstp10_clks R8A7790_CLK_SSI_ALL>, <&mstp10_clks R8A7790_CLK_SSI_ALL>,
2412 ++ <&mstp10_clks R8A7790_CLK_SSI_ALL>, <&mstp10_clks R8A7790_CLK_SSI_ALL>,
2413 ++ <&mstp10_clks R8A7790_CLK_SSI_ALL>, <&mstp10_clks R8A7790_CLK_SSI_ALL>,
2414 ++ <&mstp10_clks R8A7790_CLK_SSI_ALL>, <&mstp10_clks R8A7790_CLK_SSI_ALL>,
2415 ++ <&mstp10_clks R8A7790_CLK_SSI_ALL>, <&mstp10_clks R8A7790_CLK_SSI_ALL>,
2416 + <&p_clk>,
2417 + <&mstp10_clks R8A7790_CLK_SCU_ALL>, <&mstp10_clks R8A7790_CLK_SCU_ALL>,
2418 + <&mstp10_clks R8A7790_CLK_SCU_ALL>, <&mstp10_clks R8A7790_CLK_SCU_ALL>,
2419 +diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts
2420 +index fc44ea361a4b..62eae315af1f 100644
2421 +--- a/arch/arm/boot/dts/r8a7791-koelsch.dts
2422 ++++ b/arch/arm/boot/dts/r8a7791-koelsch.dts
2423 +@@ -280,7 +280,7 @@
2424 + x2_clk: x2-clock {
2425 + compatible = "fixed-clock";
2426 + #clock-cells = <0>;
2427 +- clock-frequency = <148500000>;
2428 ++ clock-frequency = <74250000>;
2429 + };
2430 +
2431 + x13_clk: x13-clock {
2432 +diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
2433 +index 328f48bd15e7..d2585a4c6098 100644
2434 +--- a/arch/arm/boot/dts/r8a7791.dtsi
2435 ++++ b/arch/arm/boot/dts/r8a7791.dtsi
2436 +@@ -1374,8 +1374,11 @@
2437 + compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks";
2438 + reg = <0 0xe6150998 0 4>, <0 0xe61509a8 0 4>;
2439 + clocks = <&p_clk>,
2440 +- <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>,
2441 +- <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>,
2442 ++ <&mstp10_clks R8A7791_CLK_SSI_ALL>, <&mstp10_clks R8A7791_CLK_SSI_ALL>,
2443 ++ <&mstp10_clks R8A7791_CLK_SSI_ALL>, <&mstp10_clks R8A7791_CLK_SSI_ALL>,
2444 ++ <&mstp10_clks R8A7791_CLK_SSI_ALL>, <&mstp10_clks R8A7791_CLK_SSI_ALL>,
2445 ++ <&mstp10_clks R8A7791_CLK_SSI_ALL>, <&mstp10_clks R8A7791_CLK_SSI_ALL>,
2446 ++ <&mstp10_clks R8A7791_CLK_SSI_ALL>, <&mstp10_clks R8A7791_CLK_SSI_ALL>,
2447 + <&p_clk>,
2448 + <&mstp10_clks R8A7791_CLK_SCU_ALL>, <&mstp10_clks R8A7791_CLK_SCU_ALL>,
2449 + <&mstp10_clks R8A7791_CLK_SCU_ALL>, <&mstp10_clks R8A7791_CLK_SCU_ALL>,
2450 +diff --git a/arch/mips/kernel/mips-r2-to-r6-emul.c b/arch/mips/kernel/mips-r2-to-r6-emul.c
2451 +index e3384065f5e7..cbe0f025856d 100644
2452 +--- a/arch/mips/kernel/mips-r2-to-r6-emul.c
2453 ++++ b/arch/mips/kernel/mips-r2-to-r6-emul.c
2454 +@@ -1097,10 +1097,20 @@ repeat:
2455 + }
2456 + break;
2457 +
2458 +- case beql_op:
2459 +- case bnel_op:
2460 + case blezl_op:
2461 + case bgtzl_op:
2462 ++ /*
2463 ++ * For BLEZL and BGTZL, rt field must be set to 0. If this
2464 ++ * is not the case, this may be an encoding of a MIPS R6
2465 ++ * instruction, so return to CPU execution if this occurs
2466 ++ */
2467 ++ if (MIPSInst_RT(inst)) {
2468 ++ err = SIGILL;
2469 ++ break;
2470 ++ }
2471 ++ /* fall through */
2472 ++ case beql_op:
2473 ++ case bnel_op:
2474 + if (delay_slot(regs)) {
2475 + err = SIGILL;
2476 + break;
2477 +@@ -2330,6 +2340,8 @@ static int mipsr2_stats_clear_show(struct seq_file *s, void *unused)
2478 + __this_cpu_write((mipsr2bremustats).bgezl, 0);
2479 + __this_cpu_write((mipsr2bremustats).bltzll, 0);
2480 + __this_cpu_write((mipsr2bremustats).bgezll, 0);
2481 ++ __this_cpu_write((mipsr2bremustats).bltzall, 0);
2482 ++ __this_cpu_write((mipsr2bremustats).bgezall, 0);
2483 + __this_cpu_write((mipsr2bremustats).bltzal, 0);
2484 + __this_cpu_write((mipsr2bremustats).bgezal, 0);
2485 + __this_cpu_write((mipsr2bremustats).beql, 0);
2486 +diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c
2487 +index 1a8c96035716..c0c1e9529dbd 100644
2488 +--- a/arch/mips/net/bpf_jit.c
2489 ++++ b/arch/mips/net/bpf_jit.c
2490 +@@ -527,7 +527,8 @@ static void save_bpf_jit_regs(struct jit_ctx *ctx, unsigned offset)
2491 + u32 sflags, tmp_flags;
2492 +
2493 + /* Adjust the stack pointer */
2494 +- emit_stack_offset(-align_sp(offset), ctx);
2495 ++ if (offset)
2496 ++ emit_stack_offset(-align_sp(offset), ctx);
2497 +
2498 + tmp_flags = sflags = ctx->flags >> SEEN_SREG_SFT;
2499 + /* sflags is essentially a bitmap */
2500 +@@ -579,7 +580,8 @@ static void restore_bpf_jit_regs(struct jit_ctx *ctx,
2501 + emit_load_stack_reg(r_ra, r_sp, real_off, ctx);
2502 +
2503 + /* Restore the sp and discard the scrach memory */
2504 +- emit_stack_offset(align_sp(offset), ctx);
2505 ++ if (offset)
2506 ++ emit_stack_offset(align_sp(offset), ctx);
2507 + }
2508 +
2509 + static unsigned int get_stack_depth(struct jit_ctx *ctx)
2510 +@@ -626,8 +628,14 @@ static void build_prologue(struct jit_ctx *ctx)
2511 + if (ctx->flags & SEEN_X)
2512 + emit_jit_reg_move(r_X, r_zero, ctx);
2513 +
2514 +- /* Do not leak kernel data to userspace */
2515 +- if (bpf_needs_clear_a(&ctx->skf->insns[0]))
2516 ++ /*
2517 ++ * Do not leak kernel data to userspace, we only need to clear
2518 ++ * r_A if it is ever used. In fact if it is never used, we
2519 ++ * will not save/restore it, so clearing it in this case would
2520 ++ * corrupt the state of the caller.
2521 ++ */
2522 ++ if (bpf_needs_clear_a(&ctx->skf->insns[0]) &&
2523 ++ (ctx->flags & SEEN_A))
2524 + emit_jit_reg_move(r_A, r_zero, ctx);
2525 + }
2526 +
2527 +diff --git a/arch/mips/net/bpf_jit_asm.S b/arch/mips/net/bpf_jit_asm.S
2528 +index 5d2e0c8d29c0..88a2075305d1 100644
2529 +--- a/arch/mips/net/bpf_jit_asm.S
2530 ++++ b/arch/mips/net/bpf_jit_asm.S
2531 +@@ -90,18 +90,14 @@ FEXPORT(sk_load_half_positive)
2532 + is_offset_in_header(2, half)
2533 + /* Offset within header boundaries */
2534 + PTR_ADDU t1, $r_skb_data, offset
2535 +- .set reorder
2536 +- lh $r_A, 0(t1)
2537 +- .set noreorder
2538 ++ lhu $r_A, 0(t1)
2539 + #ifdef CONFIG_CPU_LITTLE_ENDIAN
2540 + # if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
2541 +- wsbh t0, $r_A
2542 +- seh $r_A, t0
2543 ++ wsbh $r_A, $r_A
2544 + # else
2545 +- sll t0, $r_A, 24
2546 +- andi t1, $r_A, 0xff00
2547 +- sra t0, t0, 16
2548 +- srl t1, t1, 8
2549 ++ sll t0, $r_A, 8
2550 ++ srl t1, $r_A, 8
2551 ++ andi t0, t0, 0xff00
2552 + or $r_A, t0, t1
2553 + # endif
2554 + #endif
2555 +@@ -115,7 +111,7 @@ FEXPORT(sk_load_byte_positive)
2556 + is_offset_in_header(1, byte)
2557 + /* Offset within header boundaries */
2558 + PTR_ADDU t1, $r_skb_data, offset
2559 +- lb $r_A, 0(t1)
2560 ++ lbu $r_A, 0(t1)
2561 + jr $r_ra
2562 + move $r_ret, zero
2563 + END(sk_load_byte)
2564 +@@ -139,6 +135,11 @@ FEXPORT(sk_load_byte_positive)
2565 + * (void *to) is returned in r_s0
2566 + *
2567 + */
2568 ++#ifdef CONFIG_CPU_LITTLE_ENDIAN
2569 ++#define DS_OFFSET(SIZE) (4 * SZREG)
2570 ++#else
2571 ++#define DS_OFFSET(SIZE) ((4 * SZREG) + (4 - SIZE))
2572 ++#endif
2573 + #define bpf_slow_path_common(SIZE) \
2574 + /* Quick check. Are we within reasonable boundaries? */ \
2575 + LONG_ADDIU $r_s1, $r_skb_len, -SIZE; \
2576 +@@ -150,7 +151,7 @@ FEXPORT(sk_load_byte_positive)
2577 + PTR_LA t0, skb_copy_bits; \
2578 + PTR_S $r_ra, (5 * SZREG)($r_sp); \
2579 + /* Assign low slot to a2 */ \
2580 +- move a2, $r_sp; \
2581 ++ PTR_ADDIU a2, $r_sp, DS_OFFSET(SIZE); \
2582 + jalr t0; \
2583 + /* Reset our destination slot (DS but it's ok) */ \
2584 + INT_S zero, (4 * SZREG)($r_sp); \
2585 +diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
2586 +index a67c6d781c52..d154e333f76b 100644
2587 +--- a/arch/powerpc/mm/fault.c
2588 ++++ b/arch/powerpc/mm/fault.c
2589 +@@ -294,7 +294,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
2590 + * can result in fault, which will cause a deadlock when called with
2591 + * mmap_sem held
2592 + */
2593 +- if (user_mode(regs))
2594 ++ if (!is_exec && user_mode(regs))
2595 + store_update_sp = store_updates_sp(regs);
2596 +
2597 + if (user_mode(regs))
2598 +diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
2599 +index 99d293ea2b49..565e24e9ddf2 100644
2600 +--- a/arch/x86/kernel/kprobes/core.c
2601 ++++ b/arch/x86/kernel/kprobes/core.c
2602 +@@ -196,6 +196,8 @@ retry:
2603 + return (opcode != 0x62 && opcode != 0x67);
2604 + case 0x70:
2605 + return 0; /* can't boost conditional jump */
2606 ++ case 0x90:
2607 ++ return opcode != 0x9a; /* can't boost call far */
2608 + case 0xc0:
2609 + /* can't boost software-interruptions */
2610 + return (0xc1 < opcode && opcode < 0xcc) || opcode == 0xcf;
2611 +@@ -404,6 +406,8 @@ static int arch_copy_kprobe(struct kprobe *p)
2612 + {
2613 + int ret;
2614 +
2615 ++ set_memory_rw((unsigned long)p->ainsn.insn & PAGE_MASK, 1);
2616 ++
2617 + /* Copy an instruction with recovering if other optprobe modifies it.*/
2618 + ret = __copy_instruction(p->ainsn.insn, p->addr);
2619 + if (!ret)
2620 +@@ -418,6 +422,8 @@ static int arch_copy_kprobe(struct kprobe *p)
2621 + else
2622 + p->ainsn.boostable = -1;
2623 +
2624 ++ set_memory_ro((unsigned long)p->ainsn.insn & PAGE_MASK, 1);
2625 ++
2626 + /* Check whether the instruction modifies Interrupt Flag or not */
2627 + p->ainsn.if_modifier = is_IF_modifier(p->ainsn.insn);
2628 +
2629 +diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
2630 +index ea8e2b846101..7aba9d6475a5 100644
2631 +--- a/arch/x86/kernel/kprobes/opt.c
2632 ++++ b/arch/x86/kernel/kprobes/opt.c
2633 +@@ -370,6 +370,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
2634 + }
2635 +
2636 + buf = (u8 *)op->optinsn.insn;
2637 ++ set_memory_rw((unsigned long)buf & PAGE_MASK, 1);
2638 +
2639 + /* Copy instructions into the out-of-line buffer */
2640 + ret = copy_optimized_instructions(buf + TMPL_END_IDX, op->kp.addr);
2641 +@@ -392,6 +393,8 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
2642 + synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
2643 + (u8 *)op->kp.addr + op->optinsn.size);
2644 +
2645 ++ set_memory_ro((unsigned long)buf & PAGE_MASK, 1);
2646 ++
2647 + flush_icache_range((unsigned long) buf,
2648 + (unsigned long) buf + TMPL_END_IDX +
2649 + op->optinsn.size + RELATIVEJUMP_SIZE);
2650 +diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
2651 +index 510e80da7de4..af57736a0309 100644
2652 +--- a/arch/x86/kernel/vm86_32.c
2653 ++++ b/arch/x86/kernel/vm86_32.c
2654 +@@ -715,7 +715,8 @@ void handle_vm86_fault(struct kernel_vm86_regs *regs, long error_code)
2655 + return;
2656 +
2657 + check_vip:
2658 +- if (VEFLAGS & X86_EFLAGS_VIP) {
2659 ++ if ((VEFLAGS & (X86_EFLAGS_VIP | X86_EFLAGS_VIF)) ==
2660 ++ (X86_EFLAGS_VIP | X86_EFLAGS_VIF)) {
2661 + save_v86_state(regs, VM86_STI);
2662 + return;
2663 + }
2664 +diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
2665 +index e830c71a1323..e0a34b0d381e 100644
2666 +--- a/arch/x86/mm/fault.c
2667 ++++ b/arch/x86/mm/fault.c
2668 +@@ -287,7 +287,7 @@ static noinline int vmalloc_fault(unsigned long address)
2669 + if (!pmd_k)
2670 + return -1;
2671 +
2672 +- if (pmd_huge(*pmd_k))
2673 ++ if (pmd_large(*pmd_k))
2674 + return 0;
2675 +
2676 + pte_k = pte_offset_kernel(pmd_k, address);
2677 +@@ -407,7 +407,7 @@ static noinline int vmalloc_fault(unsigned long address)
2678 + if (pud_none(*pud) || pud_pfn(*pud) != pud_pfn(*pud_ref))
2679 + BUG();
2680 +
2681 +- if (pud_huge(*pud))
2682 ++ if (pud_large(*pud))
2683 + return 0;
2684 +
2685 + pmd = pmd_offset(pud, address);
2686 +@@ -418,7 +418,7 @@ static noinline int vmalloc_fault(unsigned long address)
2687 + if (pmd_none(*pmd) || pmd_pfn(*pmd) != pmd_pfn(*pmd_ref))
2688 + BUG();
2689 +
2690 +- if (pmd_huge(*pmd))
2691 ++ if (pmd_large(*pmd))
2692 + return 0;
2693 +
2694 + pte_ref = pte_offset_kernel(pmd_ref, address);
2695 +diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
2696 +index 8161090a1970..46ba2402c8f9 100644
2697 +--- a/block/blk-cgroup.c
2698 ++++ b/block/blk-cgroup.c
2699 +@@ -1078,10 +1078,8 @@ int blkcg_init_queue(struct request_queue *q)
2700 + if (preloaded)
2701 + radix_tree_preload_end();
2702 +
2703 +- if (IS_ERR(blkg)) {
2704 +- blkg_free(new_blkg);
2705 ++ if (IS_ERR(blkg))
2706 + return PTR_ERR(blkg);
2707 +- }
2708 +
2709 + q->root_blkg = blkg;
2710 + q->root_rl.blkg = blkg;
2711 +diff --git a/block/blk-throttle.c b/block/blk-throttle.c
2712 +index 2149a1ddbacf..17bdd6b55beb 100644
2713 +--- a/block/blk-throttle.c
2714 ++++ b/block/blk-throttle.c
2715 +@@ -505,6 +505,17 @@ static void throtl_dequeue_tg(struct throtl_grp *tg)
2716 + static void throtl_schedule_pending_timer(struct throtl_service_queue *sq,
2717 + unsigned long expires)
2718 + {
2719 ++ unsigned long max_expire = jiffies + 8 * throtl_slice;
2720 ++
2721 ++ /*
2722 ++ * Since we are adjusting the throttle limit dynamically, the sleep
2723 ++ * time calculated according to previous limit might be invalid. It's
2724 ++ * possible the cgroup sleep time is very long and no other cgroups
2725 ++ * have IO running so notify the limit changes. Make sure the cgroup
2726 ++ * doesn't sleep too long to avoid the missed notification.
2727 ++ */
2728 ++ if (time_after(expires, max_expire))
2729 ++ expires = max_expire;
2730 + mod_timer(&sq->pending_timer, expires);
2731 + throtl_log(sq, "schedule timer. delay=%lu jiffies=%lu",
2732 + expires - jiffies, jiffies);
2733 +diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
2734 +index 1341a94cc779..76afc841232c 100644
2735 +--- a/drivers/char/agp/intel-gtt.c
2736 ++++ b/drivers/char/agp/intel-gtt.c
2737 +@@ -859,6 +859,8 @@ void intel_gtt_insert_sg_entries(struct sg_table *st,
2738 + }
2739 + }
2740 + wmb();
2741 ++ if (intel_private.driver->chipset_flush)
2742 ++ intel_private.driver->chipset_flush();
2743 + }
2744 + EXPORT_SYMBOL(intel_gtt_insert_sg_entries);
2745 +
2746 +diff --git a/drivers/clk/qcom/gcc-msm8916.c b/drivers/clk/qcom/gcc-msm8916.c
2747 +index 2e7f03d50f4e..95a4dd290f35 100644
2748 +--- a/drivers/clk/qcom/gcc-msm8916.c
2749 ++++ b/drivers/clk/qcom/gcc-msm8916.c
2750 +@@ -1437,6 +1437,7 @@ static const struct freq_tbl ftbl_codec_clk[] = {
2751 +
2752 + static struct clk_rcg2 codec_digcodec_clk_src = {
2753 + .cmd_rcgr = 0x1c09c,
2754 ++ .mnd_width = 8,
2755 + .hid_width = 5,
2756 + .parent_map = gcc_xo_gpll1_emclk_sleep_map,
2757 + .freq_tbl = ftbl_codec_clk,
2758 +diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
2759 +index ebed319657e7..c0fb6f12f547 100644
2760 +--- a/drivers/cpufreq/cpufreq.c
2761 ++++ b/drivers/cpufreq/cpufreq.c
2762 +@@ -551,6 +551,8 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
2763 + *governor = t;
2764 + err = 0;
2765 + }
2766 ++ if (t && !try_module_get(t->owner))
2767 ++ t = NULL;
2768 +
2769 + mutex_unlock(&cpufreq_governor_mutex);
2770 + }
2771 +@@ -669,6 +671,10 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
2772 + return -EINVAL;
2773 +
2774 + ret = cpufreq_set_policy(policy, &new_policy);
2775 ++
2776 ++ if (new_policy.governor)
2777 ++ module_put(new_policy.governor->owner);
2778 ++
2779 + return ret ? ret : count;
2780 + }
2781 +
2782 +diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
2783 +index 0f6fd42f55ca..f8d740a6740d 100644
2784 +--- a/drivers/dma/imx-sdma.c
2785 ++++ b/drivers/dma/imx-sdma.c
2786 +@@ -911,6 +911,21 @@ static int sdma_disable_channel(struct dma_chan *chan)
2787 + return 0;
2788 + }
2789 +
2790 ++static int sdma_disable_channel_with_delay(struct dma_chan *chan)
2791 ++{
2792 ++ sdma_disable_channel(chan);
2793 ++
2794 ++ /*
2795 ++ * According to NXP R&D team a delay of one BD SDMA cost time
2796 ++ * (maximum is 1ms) should be added after disable of the channel
2797 ++ * bit, to ensure SDMA core has really been stopped after SDMA
2798 ++ * clients call .device_terminate_all.
2799 ++ */
2800 ++ mdelay(1);
2801 ++
2802 ++ return 0;
2803 ++}
2804 ++
2805 + static void sdma_set_watermarklevel_for_p2p(struct sdma_channel *sdmac)
2806 + {
2807 + struct sdma_engine *sdma = sdmac->sdma;
2808 +@@ -1793,7 +1808,7 @@ static int sdma_probe(struct platform_device *pdev)
2809 + sdma->dma_device.device_prep_slave_sg = sdma_prep_slave_sg;
2810 + sdma->dma_device.device_prep_dma_cyclic = sdma_prep_dma_cyclic;
2811 + sdma->dma_device.device_config = sdma_config;
2812 +- sdma->dma_device.device_terminate_all = sdma_disable_channel;
2813 ++ sdma->dma_device.device_terminate_all = sdma_disable_channel_with_delay;
2814 + sdma->dma_device.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
2815 + sdma->dma_device.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
2816 + sdma->dma_device.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
2817 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
2818 +index 6470c9aa1351..1f0e6ede120c 100644
2819 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
2820 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
2821 +@@ -69,25 +69,18 @@ void amdgpu_connector_hotplug(struct drm_connector *connector)
2822 + /* don't do anything if sink is not display port, i.e.,
2823 + * passive dp->(dvi|hdmi) adaptor
2824 + */
2825 +- if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) {
2826 +- int saved_dpms = connector->dpms;
2827 +- /* Only turn off the display if it's physically disconnected */
2828 +- if (!amdgpu_display_hpd_sense(adev, amdgpu_connector->hpd.hpd)) {
2829 +- drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
2830 +- } else if (amdgpu_atombios_dp_needs_link_train(amdgpu_connector)) {
2831 +- /* Don't try to start link training before we
2832 +- * have the dpcd */
2833 +- if (amdgpu_atombios_dp_get_dpcd(amdgpu_connector))
2834 +- return;
2835 +-
2836 +- /* set it to OFF so that drm_helper_connector_dpms()
2837 +- * won't return immediately since the current state
2838 +- * is ON at this point.
2839 +- */
2840 +- connector->dpms = DRM_MODE_DPMS_OFF;
2841 +- drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
2842 +- }
2843 +- connector->dpms = saved_dpms;
2844 ++ if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT &&
2845 ++ amdgpu_display_hpd_sense(adev, amdgpu_connector->hpd.hpd) &&
2846 ++ amdgpu_atombios_dp_needs_link_train(amdgpu_connector)) {
2847 ++ /* Don't start link training before we have the DPCD */
2848 ++ if (amdgpu_atombios_dp_get_dpcd(amdgpu_connector))
2849 ++ return;
2850 ++
2851 ++ /* Turn the connector off and back on immediately, which
2852 ++ * will trigger link training
2853 ++ */
2854 ++ drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
2855 ++ drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
2856 + }
2857 + }
2858 + }
2859 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
2860 +index 82903ca78529..c555781685ea 100644
2861 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
2862 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
2863 +@@ -560,6 +560,12 @@ amdgpu_user_framebuffer_create(struct drm_device *dev,
2864 + return ERR_PTR(-ENOENT);
2865 + }
2866 +
2867 ++ /* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
2868 ++ if (obj->import_attach) {
2869 ++ DRM_DEBUG_KMS("Cannot create framebuffer from imported dma_buf\n");
2870 ++ return ERR_PTR(-EINVAL);
2871 ++ }
2872 ++
2873 + amdgpu_fb = kzalloc(sizeof(*amdgpu_fb), GFP_KERNEL);
2874 + if (amdgpu_fb == NULL) {
2875 + drm_gem_object_unreference_unlocked(obj);
2876 +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
2877 +index 74909e72a009..2acbd43f9a53 100644
2878 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
2879 ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
2880 +@@ -519,11 +519,17 @@ static ssize_t sysprops_show(struct kobject *kobj, struct attribute *attr,
2881 + return ret;
2882 + }
2883 +
2884 ++static void kfd_topology_kobj_release(struct kobject *kobj)
2885 ++{
2886 ++ kfree(kobj);
2887 ++}
2888 ++
2889 + static const struct sysfs_ops sysprops_ops = {
2890 + .show = sysprops_show,
2891 + };
2892 +
2893 + static struct kobj_type sysprops_type = {
2894 ++ .release = kfd_topology_kobj_release,
2895 + .sysfs_ops = &sysprops_ops,
2896 + };
2897 +
2898 +@@ -559,6 +565,7 @@ static const struct sysfs_ops iolink_ops = {
2899 + };
2900 +
2901 + static struct kobj_type iolink_type = {
2902 ++ .release = kfd_topology_kobj_release,
2903 + .sysfs_ops = &iolink_ops,
2904 + };
2905 +
2906 +@@ -586,6 +593,7 @@ static const struct sysfs_ops mem_ops = {
2907 + };
2908 +
2909 + static struct kobj_type mem_type = {
2910 ++ .release = kfd_topology_kobj_release,
2911 + .sysfs_ops = &mem_ops,
2912 + };
2913 +
2914 +@@ -625,6 +633,7 @@ static const struct sysfs_ops cache_ops = {
2915 + };
2916 +
2917 + static struct kobj_type cache_type = {
2918 ++ .release = kfd_topology_kobj_release,
2919 + .sysfs_ops = &cache_ops,
2920 + };
2921 +
2922 +@@ -747,6 +756,7 @@ static const struct sysfs_ops node_ops = {
2923 + };
2924 +
2925 + static struct kobj_type node_type = {
2926 ++ .release = kfd_topology_kobj_release,
2927 + .sysfs_ops = &node_ops,
2928 + };
2929 +
2930 +diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
2931 +index c641ed9470e1..724f7cf52253 100644
2932 +--- a/drivers/gpu/drm/drm_edid.c
2933 ++++ b/drivers/gpu/drm/drm_edid.c
2934 +@@ -3219,8 +3219,7 @@ monitor_name(struct detailed_timing *t, void *data)
2935 + * @edid: EDID to parse
2936 + *
2937 + * Fill the ELD (EDID-Like Data) buffer for passing to the audio driver. The
2938 +- * Conn_Type, HDCP and Port_ID ELD fields are left for the graphics driver to
2939 +- * fill in.
2940 ++ * HDCP and Port_ID ELD fields are left for the graphics driver to fill in.
2941 + */
2942 + void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
2943 + {
2944 +@@ -3293,6 +3292,12 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
2945 + }
2946 + eld[5] |= sad_count << 4;
2947 +
2948 ++ if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
2949 ++ connector->connector_type == DRM_MODE_CONNECTOR_eDP)
2950 ++ eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_CONN_TYPE_DP;
2951 ++ else
2952 ++ eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_CONN_TYPE_HDMI;
2953 ++
2954 + eld[DRM_ELD_BASELINE_ELD_LEN] =
2955 + DIV_ROUND_UP(drm_eld_calc_baseline_block_size(eld), 4);
2956 +
2957 +diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
2958 +index 8090989185b2..4ddbc49125cd 100644
2959 +--- a/drivers/gpu/drm/drm_irq.c
2960 ++++ b/drivers/gpu/drm/drm_irq.c
2961 +@@ -1271,9 +1271,9 @@ void drm_vblank_put(struct drm_device *dev, unsigned int pipe)
2962 + if (atomic_dec_and_test(&vblank->refcount)) {
2963 + if (drm_vblank_offdelay == 0)
2964 + return;
2965 +- else if (dev->vblank_disable_immediate || drm_vblank_offdelay < 0)
2966 ++ else if (drm_vblank_offdelay < 0)
2967 + vblank_disable_fn((unsigned long)vblank);
2968 +- else
2969 ++ else if (!dev->vblank_disable_immediate)
2970 + mod_timer(&vblank->disable_timer,
2971 + jiffies + ((drm_vblank_offdelay * HZ)/1000));
2972 + }
2973 +@@ -1902,6 +1902,16 @@ bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe)
2974 + wake_up(&vblank->queue);
2975 + drm_handle_vblank_events(dev, pipe);
2976 +
2977 ++ /* With instant-off, we defer disabling the interrupt until after
2978 ++ * we finish processing the following vblank. The disable has to
2979 ++ * be last (after drm_handle_vblank_events) so that the timestamp
2980 ++ * is always accurate.
2981 ++ */
2982 ++ if (dev->vblank_disable_immediate &&
2983 ++ drm_vblank_offdelay > 0 &&
2984 ++ !atomic_read(&vblank->refcount))
2985 ++ vblank_disable_fn((unsigned long)vblank);
2986 ++
2987 + spin_unlock_irqrestore(&dev->event_lock, irqflags);
2988 +
2989 + return true;
2990 +diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
2991 +index c4a552637c93..3ff7689835dc 100644
2992 +--- a/drivers/gpu/drm/qxl/qxl_fb.c
2993 ++++ b/drivers/gpu/drm/qxl/qxl_fb.c
2994 +@@ -494,9 +494,11 @@ static const struct drm_fb_helper_funcs qxl_fb_helper_funcs = {
2995 +
2996 + int qxl_fbdev_init(struct qxl_device *qdev)
2997 + {
2998 ++ int ret = 0;
2999 ++
3000 ++#ifdef CONFIG_DRM_FBDEV_EMULATION
3001 + struct qxl_fbdev *qfbdev;
3002 + int bpp_sel = 32; /* TODO: parameter from somewhere? */
3003 +- int ret;
3004 +
3005 + qfbdev = kzalloc(sizeof(struct qxl_fbdev), GFP_KERNEL);
3006 + if (!qfbdev)
3007 +@@ -531,6 +533,8 @@ fini:
3008 + drm_fb_helper_fini(&qfbdev->helper);
3009 + free:
3010 + kfree(qfbdev);
3011 ++#endif
3012 ++
3013 + return ret;
3014 + }
3015 +
3016 +@@ -546,6 +550,9 @@ void qxl_fbdev_fini(struct qxl_device *qdev)
3017 +
3018 + void qxl_fbdev_set_suspend(struct qxl_device *qdev, int state)
3019 + {
3020 ++ if (!qdev->mode_info.qfbdev)
3021 ++ return;
3022 ++
3023 + drm_fb_helper_set_suspend(&qdev->mode_info.qfbdev->helper, state);
3024 + }
3025 +
3026 +diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
3027 +index 3645b223aa37..446d99062306 100644
3028 +--- a/drivers/gpu/drm/radeon/radeon_display.c
3029 ++++ b/drivers/gpu/drm/radeon/radeon_display.c
3030 +@@ -1374,6 +1374,12 @@ radeon_user_framebuffer_create(struct drm_device *dev,
3031 + return ERR_PTR(-ENOENT);
3032 + }
3033 +
3034 ++ /* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
3035 ++ if (obj->import_attach) {
3036 ++ DRM_DEBUG_KMS("Cannot create framebuffer from imported dma_buf\n");
3037 ++ return ERR_PTR(-EINVAL);
3038 ++ }
3039 ++
3040 + radeon_fb = kzalloc(sizeof(*radeon_fb), GFP_KERNEL);
3041 + if (radeon_fb == NULL) {
3042 + drm_gem_object_unreference_unlocked(obj);
3043 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
3044 +index d2d93959b119..aec6e9eef489 100644
3045 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
3046 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
3047 +@@ -433,7 +433,7 @@ static int vmw_fb_kms_detach(struct vmw_fb_par *par,
3048 + set.y = 0;
3049 + set.mode = NULL;
3050 + set.fb = NULL;
3051 +- set.num_connectors = 1;
3052 ++ set.num_connectors = 0;
3053 + set.connectors = &par->con;
3054 + ret = drm_mode_set_config_internal(&set);
3055 + if (ret) {
3056 +@@ -821,7 +821,9 @@ int vmw_fb_off(struct vmw_private *vmw_priv)
3057 + flush_delayed_work(&par->local_work);
3058 +
3059 + mutex_lock(&par->bo_mutex);
3060 ++ drm_modeset_lock_all(vmw_priv->dev);
3061 + (void) vmw_fb_kms_detach(par, true, false);
3062 ++ drm_modeset_unlock_all(vmw_priv->dev);
3063 + mutex_unlock(&par->bo_mutex);
3064 +
3065 + return 0;
3066 +diff --git a/drivers/hid/hid-elo.c b/drivers/hid/hid-elo.c
3067 +index 0cd4f7216239..5eea6fe0d7bd 100644
3068 +--- a/drivers/hid/hid-elo.c
3069 ++++ b/drivers/hid/hid-elo.c
3070 +@@ -42,6 +42,12 @@ static int elo_input_configured(struct hid_device *hdev,
3071 + {
3072 + struct input_dev *input = hidinput->input;
3073 +
3074 ++ /*
3075 ++ * ELO devices have one Button usage in GenDesk field, which makes
3076 ++ * hid-input map it to BTN_LEFT; that confuses userspace, which then
3077 ++ * considers the device to be a mouse/touchpad instead of touchscreen.
3078 ++ */
3079 ++ clear_bit(BTN_LEFT, input->keybit);
3080 + set_bit(BTN_TOUCH, input->keybit);
3081 + set_bit(ABS_PRESSURE, input->absbit);
3082 + input_set_abs_params(input, ABS_PRESSURE, 0, 256, 0, 0);
3083 +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
3084 +index 2ba6bf69b7d0..53e54855c366 100644
3085 +--- a/drivers/hid/hid-input.c
3086 ++++ b/drivers/hid/hid-input.c
3087 +@@ -1128,18 +1128,26 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
3088 +
3089 + /*
3090 + * Ignore out-of-range values as per HID specification,
3091 +- * section 5.10 and 6.2.25.
3092 ++ * section 5.10 and 6.2.25, when NULL state bit is present.
3093 ++ * When it's not, clamp the value to match Microsoft's input
3094 ++ * driver as mentioned in "Required HID usages for digitizers":
3095 ++ * https://msdn.microsoft.com/en-us/library/windows/hardware/dn672278(v=vs.85).asp
3096 + *
3097 + * The logical_minimum < logical_maximum check is done so that we
3098 + * don't unintentionally discard values sent by devices which
3099 + * don't specify logical min and max.
3100 + */
3101 + if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
3102 +- (field->logical_minimum < field->logical_maximum) &&
3103 +- (value < field->logical_minimum ||
3104 +- value > field->logical_maximum)) {
3105 +- dbg_hid("Ignoring out-of-range value %x\n", value);
3106 +- return;
3107 ++ (field->logical_minimum < field->logical_maximum)) {
3108 ++ if (field->flags & HID_MAIN_ITEM_NULL_STATE &&
3109 ++ (value < field->logical_minimum ||
3110 ++ value > field->logical_maximum)) {
3111 ++ dbg_hid("Ignoring out-of-range value %x\n", value);
3112 ++ return;
3113 ++ }
3114 ++ value = clamp(value,
3115 ++ field->logical_minimum,
3116 ++ field->logical_maximum);
3117 + }
3118 +
3119 + /*
3120 +diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
3121 +index 188af4c89f40..18477dd1e243 100644
3122 +--- a/drivers/hwmon/pmbus/adm1275.c
3123 ++++ b/drivers/hwmon/pmbus/adm1275.c
3124 +@@ -95,8 +95,8 @@ static const struct coefficients adm1075_coefficients[] = {
3125 + [0] = { 27169, 0, -1 }, /* voltage */
3126 + [1] = { 806, 20475, -1 }, /* current, irange25 */
3127 + [2] = { 404, 20475, -1 }, /* current, irange50 */
3128 +- [3] = { 0, -1, 8549 }, /* power, irange25 */
3129 +- [4] = { 0, -1, 4279 }, /* power, irange50 */
3130 ++ [3] = { 8549, 0, -1 }, /* power, irange25 */
3131 ++ [4] = { 4279, 0, -1 }, /* power, irange50 */
3132 + };
3133 +
3134 + static const struct coefficients adm1275_coefficients[] = {
3135 +diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
3136 +index b0973617826f..7d2bb1549608 100644
3137 +--- a/drivers/hwtracing/coresight/of_coresight.c
3138 ++++ b/drivers/hwtracing/coresight/of_coresight.c
3139 +@@ -150,7 +150,7 @@ struct coresight_platform_data *of_get_coresight_platform_data(
3140 + continue;
3141 +
3142 + /* The local out port number */
3143 +- pdata->outports[i] = endpoint.id;
3144 ++ pdata->outports[i] = endpoint.port;
3145 +
3146 + /*
3147 + * Get a handle on the remote port and parent
3148 +diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c
3149 +index 5a5778729e37..76bb51309a78 100644
3150 +--- a/drivers/input/keyboard/qt1070.c
3151 ++++ b/drivers/input/keyboard/qt1070.c
3152 +@@ -274,9 +274,18 @@ static const struct i2c_device_id qt1070_id[] = {
3153 + };
3154 + MODULE_DEVICE_TABLE(i2c, qt1070_id);
3155 +
3156 ++#ifdef CONFIG_OF
3157 ++static const struct of_device_id qt1070_of_match[] = {
3158 ++ { .compatible = "qt1070", },
3159 ++ { },
3160 ++};
3161 ++MODULE_DEVICE_TABLE(of, qt1070_of_match);
3162 ++#endif
3163 ++
3164 + static struct i2c_driver qt1070_driver = {
3165 + .driver = {
3166 + .name = "qt1070",
3167 ++ .of_match_table = of_match_ptr(qt1070_of_match),
3168 + .pm = &qt1070_pm_ops,
3169 + },
3170 + .id_table = qt1070_id,
3171 +diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
3172 +index 5d0cd51c6f41..a4b7b4c3d27b 100644
3173 +--- a/drivers/input/touchscreen/tsc2007.c
3174 ++++ b/drivers/input/touchscreen/tsc2007.c
3175 +@@ -455,6 +455,14 @@ static int tsc2007_probe(struct i2c_client *client,
3176 +
3177 + tsc2007_stop(ts);
3178 +
3179 ++ /* power down the chip (TSC2007_SETUP does not ACK on I2C) */
3180 ++ err = tsc2007_xfer(ts, PWRDOWN);
3181 ++ if (err < 0) {
3182 ++ dev_err(&client->dev,
3183 ++ "Failed to setup chip: %d\n", err);
3184 ++ return err; /* usually, chip does not respond */
3185 ++ }
3186 ++
3187 + err = input_register_device(input_dev);
3188 + if (err) {
3189 + dev_err(&client->dev,
3190 +diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
3191 +index fa0adef32bd6..62739766b60b 100644
3192 +--- a/drivers/iommu/iova.c
3193 ++++ b/drivers/iommu/iova.c
3194 +@@ -126,7 +126,7 @@ static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
3195 + break; /* found a free slot */
3196 + }
3197 + adjust_limit_pfn:
3198 +- limit_pfn = curr_iova->pfn_lo - 1;
3199 ++ limit_pfn = curr_iova->pfn_lo ? (curr_iova->pfn_lo - 1) : 0;
3200 + move_left:
3201 + prev = curr;
3202 + curr = rb_prev(curr);
3203 +diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
3204 +index c5f1757ac61d..82e00e3ad0e0 100644
3205 +--- a/drivers/irqchip/irq-gic-v3-its.c
3206 ++++ b/drivers/irqchip/irq-gic-v3-its.c
3207 +@@ -663,7 +663,7 @@ static struct irq_chip its_irq_chip = {
3208 + * This gives us (((1UL << id_bits) - 8192) >> 5) possible allocations.
3209 + */
3210 + #define IRQS_PER_CHUNK_SHIFT 5
3211 +-#define IRQS_PER_CHUNK (1 << IRQS_PER_CHUNK_SHIFT)
3212 ++#define IRQS_PER_CHUNK (1UL << IRQS_PER_CHUNK_SHIFT)
3213 +
3214 + static unsigned long *lpi_bitmap;
3215 + static u32 lpi_chunks;
3216 +@@ -1168,11 +1168,10 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
3217 +
3218 + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
3219 + /*
3220 +- * At least one bit of EventID is being used, hence a minimum
3221 +- * of two entries. No, the architecture doesn't let you
3222 +- * express an ITT with a single entry.
3223 ++ * We allocate at least one chunk worth of LPIs bet device,
3224 ++ * and thus that many ITEs. The device may require less though.
3225 + */
3226 +- nr_ites = max(2UL, roundup_pow_of_two(nvecs));
3227 ++ nr_ites = max(IRQS_PER_CHUNK, roundup_pow_of_two(nvecs));
3228 + sz = nr_ites * its->ite_size;
3229 + sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1;
3230 + itt = kzalloc(sz, GFP_KERNEL);
3231 +diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
3232 +index 86ab6d14d782..ca968c3f25c7 100644
3233 +--- a/drivers/md/raid5.c
3234 ++++ b/drivers/md/raid5.c
3235 +@@ -3372,9 +3372,20 @@ static int fetch_block(struct stripe_head *sh, struct stripe_head_state *s,
3236 + BUG_ON(test_bit(R5_Wantcompute, &dev->flags));
3237 + BUG_ON(test_bit(R5_Wantread, &dev->flags));
3238 + BUG_ON(sh->batch_head);
3239 ++
3240 ++ /*
3241 ++ * In the raid6 case if the only non-uptodate disk is P
3242 ++ * then we already trusted P to compute the other failed
3243 ++ * drives. It is safe to compute rather than re-read P.
3244 ++ * In other cases we only compute blocks from failed
3245 ++ * devices, otherwise check/repair might fail to detect
3246 ++ * a real inconsistency.
3247 ++ */
3248 ++
3249 + if ((s->uptodate == disks - 1) &&
3250 ++ ((sh->qd_idx >= 0 && sh->pd_idx == disk_idx) ||
3251 + (s->failed && (disk_idx == s->failed_num[0] ||
3252 +- disk_idx == s->failed_num[1]))) {
3253 ++ disk_idx == s->failed_num[1])))) {
3254 + /* have disk failed, and we're requested to fetch it;
3255 + * do compute it
3256 + */
3257 +diff --git a/drivers/media/i2c/soc_camera/ov6650.c b/drivers/media/i2c/soc_camera/ov6650.c
3258 +index 1f8af1ee8352..1e4783b51a35 100644
3259 +--- a/drivers/media/i2c/soc_camera/ov6650.c
3260 ++++ b/drivers/media/i2c/soc_camera/ov6650.c
3261 +@@ -1033,7 +1033,7 @@ static int ov6650_probe(struct i2c_client *client,
3262 + priv->code = MEDIA_BUS_FMT_YUYV8_2X8;
3263 + priv->colorspace = V4L2_COLORSPACE_JPEG;
3264 +
3265 +- priv->clk = v4l2_clk_get(&client->dev, "mclk");
3266 ++ priv->clk = v4l2_clk_get(&client->dev, NULL);
3267 + if (IS_ERR(priv->clk)) {
3268 + ret = PTR_ERR(priv->clk);
3269 + goto eclkget;
3270 +diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2.c b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
3271 +index f7ce493b1fee..a0b61e88c838 100644
3272 +--- a/drivers/media/pci/solo6x10/solo6x10-v4l2.c
3273 ++++ b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
3274 +@@ -342,6 +342,17 @@ static void solo_stop_streaming(struct vb2_queue *q)
3275 + struct solo_dev *solo_dev = vb2_get_drv_priv(q);
3276 +
3277 + solo_stop_thread(solo_dev);
3278 ++
3279 ++ spin_lock(&solo_dev->slock);
3280 ++ while (!list_empty(&solo_dev->vidq_active)) {
3281 ++ struct solo_vb2_buf *buf = list_entry(
3282 ++ solo_dev->vidq_active.next,
3283 ++ struct solo_vb2_buf, list);
3284 ++
3285 ++ list_del(&buf->list);
3286 ++ vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
3287 ++ }
3288 ++ spin_unlock(&solo_dev->slock);
3289 + INIT_LIST_HEAD(&solo_dev->vidq_active);
3290 + }
3291 +
3292 +diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c
3293 +index 9caea8344547..d793c630f1dd 100644
3294 +--- a/drivers/media/usb/cpia2/cpia2_v4l.c
3295 ++++ b/drivers/media/usb/cpia2/cpia2_v4l.c
3296 +@@ -812,7 +812,7 @@ static int cpia2_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
3297 + struct camera_data *cam = video_drvdata(file);
3298 +
3299 + if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
3300 +- buf->index > cam->num_frames)
3301 ++ buf->index >= cam->num_frames)
3302 + return -EINVAL;
3303 +
3304 + buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer;
3305 +@@ -863,7 +863,7 @@ static int cpia2_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
3306 +
3307 + if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
3308 + buf->memory != V4L2_MEMORY_MMAP ||
3309 +- buf->index > cam->num_frames)
3310 ++ buf->index >= cam->num_frames)
3311 + return -EINVAL;
3312 +
3313 + DBG("QBUF #%d\n", buf->index);
3314 +diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
3315 +index cc91f7b3d90c..eb29113e0bac 100644
3316 +--- a/drivers/misc/enclosure.c
3317 ++++ b/drivers/misc/enclosure.c
3318 +@@ -148,7 +148,7 @@ enclosure_register(struct device *dev, const char *name, int components,
3319 + for (i = 0; i < components; i++) {
3320 + edev->component[i].number = -1;
3321 + edev->component[i].slot = -1;
3322 +- edev->component[i].power_status = 1;
3323 ++ edev->component[i].power_status = -1;
3324 + }
3325 +
3326 + mutex_lock(&container_list_lock);
3327 +@@ -600,6 +600,11 @@ static ssize_t get_component_power_status(struct device *cdev,
3328 +
3329 + if (edev->cb->get_power_status)
3330 + edev->cb->get_power_status(edev, ecomp);
3331 ++
3332 ++ /* If still uninitialized, the callback failed or does not exist. */
3333 ++ if (ecomp->power_status == -1)
3334 ++ return (edev->cb->get_power_status) ? -EIO : -ENOTTY;
3335 ++
3336 + return snprintf(buf, 40, "%s\n", ecomp->power_status ? "on" : "off");
3337 + }
3338 +
3339 +diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
3340 +index 27864c0863ef..8406f346b0be 100644
3341 +--- a/drivers/mtd/nand/nand_base.c
3342 ++++ b/drivers/mtd/nand/nand_base.c
3343 +@@ -626,7 +626,8 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,
3344 + chip->cmd_ctrl(mtd, readcmd, ctrl);
3345 + ctrl &= ~NAND_CTRL_CHANGE;
3346 + }
3347 +- chip->cmd_ctrl(mtd, command, ctrl);
3348 ++ if (command != NAND_CMD_NONE)
3349 ++ chip->cmd_ctrl(mtd, command, ctrl);
3350 +
3351 + /* Address cycle, when necessary */
3352 + ctrl = NAND_CTRL_ALE | NAND_CTRL_CHANGE;
3353 +@@ -655,6 +656,7 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,
3354 + */
3355 + switch (command) {
3356 +
3357 ++ case NAND_CMD_NONE:
3358 + case NAND_CMD_PAGEPROG:
3359 + case NAND_CMD_ERASE1:
3360 + case NAND_CMD_ERASE2:
3361 +@@ -717,7 +719,9 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
3362 + }
3363 +
3364 + /* Command latch cycle */
3365 +- chip->cmd_ctrl(mtd, command, NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE);
3366 ++ if (command != NAND_CMD_NONE)
3367 ++ chip->cmd_ctrl(mtd, command,
3368 ++ NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE);
3369 +
3370 + if (column != -1 || page_addr != -1) {
3371 + int ctrl = NAND_CTRL_CHANGE | NAND_NCE | NAND_ALE;
3372 +@@ -750,6 +754,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
3373 + */
3374 + switch (command) {
3375 +
3376 ++ case NAND_CMD_NONE:
3377 + case NAND_CMD_CACHEDPROG:
3378 + case NAND_CMD_PAGEPROG:
3379 + case NAND_CMD_ERASE1:
3380 +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
3381 +index 2cb34b0f3856..eadccf498589 100644
3382 +--- a/drivers/net/bonding/bond_main.c
3383 ++++ b/drivers/net/bonding/bond_main.c
3384 +@@ -3276,12 +3276,17 @@ static void bond_fold_stats(struct rtnl_link_stats64 *_res,
3385 + for (i = 0; i < sizeof(*_res) / sizeof(u64); i++) {
3386 + u64 nv = new[i];
3387 + u64 ov = old[i];
3388 ++ s64 delta = nv - ov;
3389 +
3390 + /* detects if this particular field is 32bit only */
3391 + if (((nv | ov) >> 32) == 0)
3392 +- res[i] += (u32)nv - (u32)ov;
3393 +- else
3394 +- res[i] += nv - ov;
3395 ++ delta = (s64)(s32)((u32)nv - (u32)ov);
3396 ++
3397 ++ /* filter anomalies, some drivers reset their stats
3398 ++ * at down/up events.
3399 ++ */
3400 ++ if (delta > 0)
3401 ++ res[i] += delta;
3402 + }
3403 + }
3404 +
3405 +diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
3406 +index c31e691d11fc..e8d31640058d 100644
3407 +--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
3408 ++++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
3409 +@@ -604,6 +604,7 @@ static void xgene_enet_cle_bypass(struct xgene_enet_pdata *pdata,
3410 + xgene_enet_rd_csr(pdata, CLE_BYPASS_REG0_0_ADDR, &cb);
3411 + cb |= CFG_CLE_BYPASS_EN0;
3412 + CFG_CLE_IP_PROTOCOL0_SET(&cb, 3);
3413 ++ CFG_CLE_IP_HDR_LEN_SET(&cb, 0);
3414 + xgene_enet_wr_csr(pdata, CLE_BYPASS_REG0_0_ADDR, cb);
3415 +
3416 + xgene_enet_rd_csr(pdata, CLE_BYPASS_REG1_0_ADDR, &cb);
3417 +diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
3418 +index c153a1dc5ff7..480312105964 100644
3419 +--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
3420 ++++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
3421 +@@ -147,6 +147,7 @@ enum xgene_enet_rm {
3422 + #define CFG_RXCLK_MUXSEL0_SET(dst, val) xgene_set_bits(dst, val, 26, 3)
3423 +
3424 + #define CFG_CLE_IP_PROTOCOL0_SET(dst, val) xgene_set_bits(dst, val, 16, 2)
3425 ++#define CFG_CLE_IP_HDR_LEN_SET(dst, val) xgene_set_bits(dst, val, 8, 5)
3426 + #define CFG_CLE_DSTQID0_SET(dst, val) xgene_set_bits(dst, val, 0, 12)
3427 + #define CFG_CLE_FPSEL0_SET(dst, val) xgene_set_bits(dst, val, 16, 4)
3428 + #define CFG_MACMODE_SET(dst, val) xgene_set_bits(dst, val, 18, 2)
3429 +diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
3430 +index 6d0c5d5eea6d..58c0fccdd8cb 100644
3431 +--- a/drivers/net/ethernet/faraday/ftgmac100.c
3432 ++++ b/drivers/net/ethernet/faraday/ftgmac100.c
3433 +@@ -28,6 +28,7 @@
3434 + #include <linux/io.h>
3435 + #include <linux/module.h>
3436 + #include <linux/netdevice.h>
3437 ++#include <linux/of.h>
3438 + #include <linux/phy.h>
3439 + #include <linux/platform_device.h>
3440 + #include <net/ip.h>
3441 +diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
3442 +index 2ce0eba5e040..38431b49020f 100644
3443 +--- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
3444 ++++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
3445 +@@ -983,7 +983,7 @@ static void fm10k_self_test(struct net_device *dev,
3446 +
3447 + memset(data, 0, sizeof(*data) * FM10K_TEST_LEN);
3448 +
3449 +- if (FM10K_REMOVED(hw)) {
3450 ++ if (FM10K_REMOVED(hw->hw_addr)) {
3451 + netif_err(interface, drv, dev,
3452 + "Interface removed - test blocked\n");
3453 + eth_test->flags |= ETH_TEST_FL_FAILED;
3454 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
3455 +index 488a50d59dca..3da1f206ff84 100644
3456 +--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
3457 ++++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
3458 +@@ -1073,6 +1073,11 @@ static int i40e_get_eeprom_len(struct net_device *netdev)
3459 + struct i40e_hw *hw = &np->vsi->back->hw;
3460 + u32 val;
3461 +
3462 ++#define X722_EEPROM_SCOPE_LIMIT 0x5B9FFF
3463 ++ if (hw->mac.type == I40E_MAC_X722) {
3464 ++ val = X722_EEPROM_SCOPE_LIMIT + 1;
3465 ++ return val;
3466 ++ }
3467 + val = (rd32(hw, I40E_GLPCI_LBARCTRL)
3468 + & I40E_GLPCI_LBARCTRL_FL_SIZE_MASK)
3469 + >> I40E_GLPCI_LBARCTRL_FL_SIZE_SHIFT;
3470 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
3471 +index 6100cdd9ad13..dd4e6ea9e0e1 100644
3472 +--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c
3473 ++++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
3474 +@@ -292,14 +292,14 @@ i40e_status i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
3475 + {
3476 + enum i40e_status_code ret_code = 0;
3477 +
3478 +- if (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE) {
3479 +- ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
3480 +- if (!ret_code) {
3481 ++ ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
3482 ++ if (!ret_code) {
3483 ++ if (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE) {
3484 + ret_code = i40e_read_nvm_word_aq(hw, offset, data);
3485 +- i40e_release_nvm(hw);
3486 ++ } else {
3487 ++ ret_code = i40e_read_nvm_word_srctl(hw, offset, data);
3488 + }
3489 +- } else {
3490 +- ret_code = i40e_read_nvm_word_srctl(hw, offset, data);
3491 ++ i40e_release_nvm(hw);
3492 + }
3493 + return ret_code;
3494 + }
3495 +diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
3496 +index 8aecea0d5dbf..142015af43db 100644
3497 +--- a/drivers/net/ipvlan/ipvlan_core.c
3498 ++++ b/drivers/net/ipvlan/ipvlan_core.c
3499 +@@ -282,6 +282,10 @@ static int ipvlan_rcv_frame(struct ipvl_addr *addr, struct sk_buff **pskb,
3500 + if (dev_forward_skb(ipvlan->dev, skb) == NET_RX_SUCCESS)
3501 + success = true;
3502 + } else {
3503 ++ if (!ether_addr_equal_64bits(eth_hdr(skb)->h_dest,
3504 ++ ipvlan->phy_dev->dev_addr))
3505 ++ skb->pkt_type = PACKET_OTHERHOST;
3506 ++
3507 + ret = RX_HANDLER_ANOTHER;
3508 + success = true;
3509 + }
3510 +diff --git a/drivers/net/veth.c b/drivers/net/veth.c
3511 +index ba21d072be31..6b4cc1c2e6b4 100644
3512 +--- a/drivers/net/veth.c
3513 ++++ b/drivers/net/veth.c
3514 +@@ -399,6 +399,9 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
3515 + if (ifmp && (dev->ifindex != 0))
3516 + peer->ifindex = ifmp->ifi_index;
3517 +
3518 ++ peer->gso_max_size = dev->gso_max_size;
3519 ++ peer->gso_max_segs = dev->gso_max_segs;
3520 ++
3521 + err = register_netdevice(peer);
3522 + put_net(net);
3523 + net = NULL;
3524 +diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
3525 +index dab3bf6649e6..e4ff1e45c02e 100644
3526 +--- a/drivers/net/vxlan.c
3527 ++++ b/drivers/net/vxlan.c
3528 +@@ -2834,6 +2834,11 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
3529 + needed_headroom = lowerdev->hard_header_len;
3530 + }
3531 +
3532 ++ if (lowerdev) {
3533 ++ dev->gso_max_size = lowerdev->gso_max_size;
3534 ++ dev->gso_max_segs = lowerdev->gso_max_segs;
3535 ++ }
3536 ++
3537 + if (conf->mtu) {
3538 + err = __vxlan_change_mtu(dev, lowerdev, dst, conf->mtu, false);
3539 + if (err)
3540 +diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
3541 +index 1a88a24ffeac..30c357567054 100644
3542 +--- a/drivers/net/wireless/ath/ath10k/debug.c
3543 ++++ b/drivers/net/wireless/ath/ath10k/debug.c
3544 +@@ -1892,6 +1892,15 @@ static ssize_t ath10k_write_simulate_radar(struct file *file,
3545 + size_t count, loff_t *ppos)
3546 + {
3547 + struct ath10k *ar = file->private_data;
3548 ++ struct ath10k_vif *arvif;
3549 ++
3550 ++ /* Just check for for the first vif alone, as all the vifs will be
3551 ++ * sharing the same channel and if the channel is disabled, all the
3552 ++ * vifs will share the same 'is_started' state.
3553 ++ */
3554 ++ arvif = list_first_entry(&ar->arvifs, typeof(*arvif), list);
3555 ++ if (!arvif->is_started)
3556 ++ return -EINVAL;
3557 +
3558 + ieee80211_radar_detected(ar->hw);
3559 +
3560 +diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
3561 +index bed8d89fe3a0..09e14ce85dd0 100644
3562 +--- a/drivers/net/wireless/ath/ath10k/mac.c
3563 ++++ b/drivers/net/wireless/ath/ath10k/mac.c
3564 +@@ -5497,6 +5497,16 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
3565 + "mac vdev %d peer delete %pM (sta gone)\n",
3566 + arvif->vdev_id, sta->addr);
3567 +
3568 ++ if (sta->tdls) {
3569 ++ ret = ath10k_mac_tdls_peer_update(ar, arvif->vdev_id,
3570 ++ sta,
3571 ++ WMI_TDLS_PEER_STATE_TEARDOWN);
3572 ++ if (ret)
3573 ++ ath10k_warn(ar, "failed to update tdls peer state for %pM state %d: %i\n",
3574 ++ sta->addr,
3575 ++ WMI_TDLS_PEER_STATE_TEARDOWN, ret);
3576 ++ }
3577 ++
3578 + ret = ath10k_peer_delete(ar, arvif->vdev_id, sta->addr);
3579 + if (ret)
3580 + ath10k_warn(ar, "failed to delete peer %pM for vdev %d: %i\n",
3581 +@@ -6427,7 +6437,7 @@ ath10k_mac_update_rx_channel(struct ath10k *ar,
3582 + lockdep_assert_held(&ar->data_lock);
3583 +
3584 + WARN_ON(ctx && vifs);
3585 +- WARN_ON(vifs && n_vifs != 1);
3586 ++ WARN_ON(vifs && !n_vifs);
3587 +
3588 + /* FIXME: Sort of an optimization and a workaround. Peers and vifs are
3589 + * on a linked list now. Doing a lookup peer -> vif -> chanctx for each
3590 +diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
3591 +index 72a4ef709577..a8b2553e8988 100644
3592 +--- a/drivers/net/wireless/ath/ath10k/wmi.h
3593 ++++ b/drivers/net/wireless/ath/ath10k/wmi.h
3594 +@@ -4826,7 +4826,8 @@ enum wmi_10_4_vdev_param {
3595 + #define WMI_VDEV_PARAM_TXBF_MU_TX_BFER BIT(3)
3596 +
3597 + #define WMI_TXBF_STS_CAP_OFFSET_LSB 4
3598 +-#define WMI_TXBF_STS_CAP_OFFSET_MASK 0xf0
3599 ++#define WMI_TXBF_STS_CAP_OFFSET_MASK 0x70
3600 ++#define WMI_TXBF_CONF_IMPLICIT_BF BIT(7)
3601 + #define WMI_BF_SOUND_DIM_OFFSET_LSB 8
3602 + #define WMI_BF_SOUND_DIM_OFFSET_MASK 0xf00
3603 +
3604 +diff --git a/drivers/net/wireless/ath/wil6210/main.c b/drivers/net/wireless/ath/wil6210/main.c
3605 +index 85bca557a339..f09fafaaaf1a 100644
3606 +--- a/drivers/net/wireless/ath/wil6210/main.c
3607 ++++ b/drivers/net/wireless/ath/wil6210/main.c
3608 +@@ -125,9 +125,15 @@ void wil_memcpy_fromio_32(void *dst, const volatile void __iomem *src,
3609 + u32 *d = dst;
3610 + const volatile u32 __iomem *s = src;
3611 +
3612 +- /* size_t is unsigned, if (count%4 != 0) it will wrap */
3613 +- for (count += 4; count > 4; count -= 4)
3614 ++ for (; count >= 4; count -= 4)
3615 + *d++ = __raw_readl(s++);
3616 ++
3617 ++ if (unlikely(count)) {
3618 ++ /* count can be 1..3 */
3619 ++ u32 tmp = __raw_readl(s);
3620 ++
3621 ++ memcpy(d, &tmp, count);
3622 ++ }
3623 + }
3624 +
3625 + void wil_memcpy_toio_32(volatile void __iomem *dst, const void *src,
3626 +@@ -136,8 +142,16 @@ void wil_memcpy_toio_32(volatile void __iomem *dst, const void *src,
3627 + volatile u32 __iomem *d = dst;
3628 + const u32 *s = src;
3629 +
3630 +- for (count += 4; count > 4; count -= 4)
3631 ++ for (; count >= 4; count -= 4)
3632 + __raw_writel(*s++, d++);
3633 ++
3634 ++ if (unlikely(count)) {
3635 ++ /* count can be 1..3 */
3636 ++ u32 tmp = 0;
3637 ++
3638 ++ memcpy(&tmp, s, count);
3639 ++ __raw_writel(tmp, d);
3640 ++ }
3641 + }
3642 +
3643 + static void wil_disconnect_cid(struct wil6210_priv *wil, int cid,
3644 +diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
3645 +index f877fbc7d7af..8a9164da6c50 100644
3646 +--- a/drivers/net/wireless/mac80211_hwsim.c
3647 ++++ b/drivers/net/wireless/mac80211_hwsim.c
3648 +@@ -699,16 +699,21 @@ static int hwsim_fops_ps_write(void *dat, u64 val)
3649 + val != PS_MANUAL_POLL)
3650 + return -EINVAL;
3651 +
3652 +- old_ps = data->ps;
3653 +- data->ps = val;
3654 +-
3655 +- local_bh_disable();
3656 + if (val == PS_MANUAL_POLL) {
3657 ++ if (data->ps != PS_ENABLED)
3658 ++ return -EINVAL;
3659 ++ local_bh_disable();
3660 + ieee80211_iterate_active_interfaces_atomic(
3661 + data->hw, IEEE80211_IFACE_ITER_NORMAL,
3662 + hwsim_send_ps_poll, data);
3663 +- data->ps_poll_pending = true;
3664 +- } else if (old_ps == PS_DISABLED && val != PS_DISABLED) {
3665 ++ local_bh_enable();
3666 ++ return 0;
3667 ++ }
3668 ++ old_ps = data->ps;
3669 ++ data->ps = val;
3670 ++
3671 ++ local_bh_disable();
3672 ++ if (old_ps == PS_DISABLED && val != PS_DISABLED) {
3673 + ieee80211_iterate_active_interfaces_atomic(
3674 + data->hw, IEEE80211_IFACE_ITER_NORMAL,
3675 + hwsim_send_nullfunc_ps, data);
3676 +diff --git a/drivers/nfc/nfcmrvl/fw_dnld.c b/drivers/nfc/nfcmrvl/fw_dnld.c
3677 +index af62c4c854f3..b4f31dad40d6 100644
3678 +--- a/drivers/nfc/nfcmrvl/fw_dnld.c
3679 ++++ b/drivers/nfc/nfcmrvl/fw_dnld.c
3680 +@@ -17,7 +17,7 @@
3681 + */
3682 +
3683 + #include <linux/module.h>
3684 +-#include <linux/unaligned/access_ok.h>
3685 ++#include <asm/unaligned.h>
3686 + #include <linux/firmware.h>
3687 + #include <linux/nfc.h>
3688 + #include <net/nfc/nci.h>
3689 +diff --git a/drivers/nfc/nfcmrvl/spi.c b/drivers/nfc/nfcmrvl/spi.c
3690 +index a7faa0bcc01e..fc8e78a29d77 100644
3691 +--- a/drivers/nfc/nfcmrvl/spi.c
3692 ++++ b/drivers/nfc/nfcmrvl/spi.c
3693 +@@ -96,10 +96,9 @@ static int nfcmrvl_spi_nci_send(struct nfcmrvl_private *priv,
3694 + /* Send the SPI packet */
3695 + err = nci_spi_send(drv_data->nci_spi, &drv_data->handshake_completion,
3696 + skb);
3697 +- if (err != 0) {
3698 ++ if (err)
3699 + nfc_err(priv->dev, "spi_send failed %d", err);
3700 +- kfree_skb(skb);
3701 +- }
3702 ++
3703 + return err;
3704 + }
3705 +
3706 +diff --git a/drivers/of/device.c b/drivers/of/device.c
3707 +index 97a280d50d6d..7c509bff9295 100644
3708 +--- a/drivers/of/device.c
3709 ++++ b/drivers/of/device.c
3710 +@@ -223,7 +223,7 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
3711 + str[i] = '_';
3712 + }
3713 +
3714 +- return tsize;
3715 ++ return repend;
3716 + }
3717 + EXPORT_SYMBOL_GPL(of_device_get_modalias);
3718 +
3719 +diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
3720 +index 32bd8ab79d53..5e42b5f2f565 100644
3721 +--- a/drivers/pci/pci-driver.c
3722 ++++ b/drivers/pci/pci-driver.c
3723 +@@ -463,8 +463,6 @@ static void pci_device_shutdown(struct device *dev)
3724 +
3725 + if (drv && drv->shutdown)
3726 + drv->shutdown(pci_dev);
3727 +- pci_msi_shutdown(pci_dev);
3728 +- pci_msix_shutdown(pci_dev);
3729 +
3730 + #ifdef CONFIG_KEXEC_CORE
3731 + /*
3732 +diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c
3733 +index 8af1f900ea65..1ba58fb6f796 100644
3734 +--- a/drivers/perf/arm_pmu.c
3735 ++++ b/drivers/perf/arm_pmu.c
3736 +@@ -321,10 +321,16 @@ validate_group(struct perf_event *event)
3737 + return 0;
3738 + }
3739 +
3740 ++static struct arm_pmu_platdata *armpmu_get_platdata(struct arm_pmu *armpmu)
3741 ++{
3742 ++ struct platform_device *pdev = armpmu->plat_device;
3743 ++
3744 ++ return pdev ? dev_get_platdata(&pdev->dev) : NULL;
3745 ++}
3746 ++
3747 + static irqreturn_t armpmu_dispatch_irq(int irq, void *dev)
3748 + {
3749 + struct arm_pmu *armpmu;
3750 +- struct platform_device *plat_device;
3751 + struct arm_pmu_platdata *plat;
3752 + int ret;
3753 + u64 start_clock, finish_clock;
3754 +@@ -336,8 +342,8 @@ static irqreturn_t armpmu_dispatch_irq(int irq, void *dev)
3755 + * dereference.
3756 + */
3757 + armpmu = *(void **)dev;
3758 +- plat_device = armpmu->plat_device;
3759 +- plat = dev_get_platdata(&plat_device->dev);
3760 ++
3761 ++ plat = armpmu_get_platdata(armpmu);
3762 +
3763 + start_clock = sched_clock();
3764 + if (plat && plat->handle_irq)
3765 +diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
3766 +index d4de0607b502..3039fb762893 100644
3767 +--- a/drivers/pwm/pwm-tegra.c
3768 ++++ b/drivers/pwm/pwm-tegra.c
3769 +@@ -69,6 +69,7 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
3770 + struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip);
3771 + unsigned long long c;
3772 + unsigned long rate, hz;
3773 ++ unsigned long long ns100 = NSEC_PER_SEC;
3774 + u32 val = 0;
3775 + int err;
3776 +
3777 +@@ -87,9 +88,11 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
3778 + * cycles at the PWM clock rate will take period_ns nanoseconds.
3779 + */
3780 + rate = clk_get_rate(pc->clk) >> PWM_DUTY_WIDTH;
3781 +- hz = NSEC_PER_SEC / period_ns;
3782 +
3783 +- rate = (rate + (hz / 2)) / hz;
3784 ++ /* Consider precision in PWM_SCALE_WIDTH rate calculation */
3785 ++ ns100 *= 100;
3786 ++ hz = DIV_ROUND_CLOSEST_ULL(ns100, period_ns);
3787 ++ rate = DIV_ROUND_CLOSEST(rate * 100, hz);
3788 +
3789 + /*
3790 + * Since the actual PWM divider is the register's frequency divider
3791 +diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
3792 +index 7a58128a0000..2f61d8cd5882 100644
3793 +--- a/drivers/scsi/ipr.c
3794 ++++ b/drivers/scsi/ipr.c
3795 +@@ -835,8 +835,10 @@ static void ipr_sata_eh_done(struct ipr_cmnd *ipr_cmd)
3796 +
3797 + qc->err_mask |= AC_ERR_OTHER;
3798 + sata_port->ioasa.status |= ATA_BUSY;
3799 +- list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
3800 + ata_qc_complete(qc);
3801 ++ if (ipr_cmd->eh_comp)
3802 ++ complete(ipr_cmd->eh_comp);
3803 ++ list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
3804 + }
3805 +
3806 + /**
3807 +@@ -5864,8 +5866,10 @@ static void ipr_erp_done(struct ipr_cmnd *ipr_cmd)
3808 + res->in_erp = 0;
3809 + }
3810 + scsi_dma_unmap(ipr_cmd->scsi_cmd);
3811 +- list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
3812 + scsi_cmd->scsi_done(scsi_cmd);
3813 ++ if (ipr_cmd->eh_comp)
3814 ++ complete(ipr_cmd->eh_comp);
3815 ++ list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
3816 + }
3817 +
3818 + /**
3819 +@@ -6255,8 +6259,10 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg,
3820 + }
3821 +
3822 + scsi_dma_unmap(ipr_cmd->scsi_cmd);
3823 +- list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
3824 + scsi_cmd->scsi_done(scsi_cmd);
3825 ++ if (ipr_cmd->eh_comp)
3826 ++ complete(ipr_cmd->eh_comp);
3827 ++ list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
3828 + }
3829 +
3830 + /**
3831 +@@ -6282,8 +6288,10 @@ static void ipr_scsi_done(struct ipr_cmnd *ipr_cmd)
3832 + scsi_dma_unmap(scsi_cmd);
3833 +
3834 + spin_lock_irqsave(ipr_cmd->hrrq->lock, lock_flags);
3835 +- list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
3836 + scsi_cmd->scsi_done(scsi_cmd);
3837 ++ if (ipr_cmd->eh_comp)
3838 ++ complete(ipr_cmd->eh_comp);
3839 ++ list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
3840 + spin_unlock_irqrestore(ipr_cmd->hrrq->lock, lock_flags);
3841 + } else {
3842 + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
3843 +diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
3844 +index 60720e5b1ebc..6b61b09b3226 100644
3845 +--- a/drivers/scsi/scsi_devinfo.c
3846 ++++ b/drivers/scsi/scsi_devinfo.c
3847 +@@ -180,7 +180,7 @@ static struct {
3848 + {"HITACHI", "6586-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
3849 + {"HITACHI", "6588-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
3850 + {"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN}, /* HP VA7400 */
3851 +- {"HP", "OPEN-", "*", BLIST_REPORTLUN2}, /* HP XP Arrays */
3852 ++ {"HP", "OPEN-", "*", BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES}, /* HP XP Arrays */
3853 + {"HP", "NetRAID-4M", NULL, BLIST_FORCELUN},
3854 + {"HP", "HSV100", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD},
3855 + {"HP", "C1557A", NULL, BLIST_FORCELUN},
3856 +@@ -589,17 +589,12 @@ int scsi_get_device_flags_keyed(struct scsi_device *sdev,
3857 + int key)
3858 + {
3859 + struct scsi_dev_info_list *devinfo;
3860 +- int err;
3861 +
3862 + devinfo = scsi_dev_info_list_find(vendor, model, key);
3863 + if (!IS_ERR(devinfo))
3864 + return devinfo->flags;
3865 +
3866 +- err = PTR_ERR(devinfo);
3867 +- if (err != -ENOENT)
3868 +- return err;
3869 +-
3870 +- /* nothing found, return nothing */
3871 ++ /* key or device not found: return nothing */
3872 + if (key != SCSI_DEVINFO_GLOBAL)
3873 + return 0;
3874 +
3875 +diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
3876 +index 4d655b568269..5711d58f9e81 100644
3877 +--- a/drivers/scsi/scsi_dh.c
3878 ++++ b/drivers/scsi/scsi_dh.c
3879 +@@ -56,10 +56,13 @@ static const struct scsi_dh_blist scsi_dh_blist[] = {
3880 + {"IBM", "1815", "rdac", },
3881 + {"IBM", "1818", "rdac", },
3882 + {"IBM", "3526", "rdac", },
3883 ++ {"IBM", "3542", "rdac", },
3884 ++ {"IBM", "3552", "rdac", },
3885 + {"SGI", "TP9", "rdac", },
3886 + {"SGI", "IS", "rdac", },
3887 +- {"STK", "OPENstorage D280", "rdac", },
3888 ++ {"STK", "OPENstorage", "rdac", },
3889 + {"STK", "FLEXLINE 380", "rdac", },
3890 ++ {"STK", "BladeCtlr", "rdac", },
3891 + {"SUN", "CSM", "rdac", },
3892 + {"SUN", "LCSM100", "rdac", },
3893 + {"SUN", "STK6580_6780", "rdac", },
3894 +diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
3895 +index 044d06410d4c..01168acc864d 100644
3896 +--- a/drivers/scsi/ses.c
3897 ++++ b/drivers/scsi/ses.c
3898 +@@ -546,7 +546,6 @@ static void ses_enclosure_data_process(struct enclosure_device *edev,
3899 + ecomp = &edev->component[components++];
3900 +
3901 + if (!IS_ERR(ecomp)) {
3902 +- ses_get_power_status(edev, ecomp);
3903 + if (addl_desc_ptr)
3904 + ses_process_descriptor(
3905 + ecomp,
3906 +diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
3907 +index 0f0ff75755e0..4b43effbf4fc 100644
3908 +--- a/drivers/scsi/sg.c
3909 ++++ b/drivers/scsi/sg.c
3910 +@@ -535,6 +535,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
3911 + } else
3912 + count = (old_hdr->result == 0) ? 0 : -EIO;
3913 + sg_finish_rem_req(srp);
3914 ++ sg_remove_request(sfp, srp);
3915 + retval = count;
3916 + free_old_hdr:
3917 + kfree(old_hdr);
3918 +@@ -575,6 +576,7 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp)
3919 + }
3920 + err_out:
3921 + err2 = sg_finish_rem_req(srp);
3922 ++ sg_remove_request(sfp, srp);
3923 + return err ? : err2 ? : count;
3924 + }
3925 +
3926 +@@ -674,18 +676,14 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
3927 + * is a non-zero input_size, so emit a warning.
3928 + */
3929 + if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV) {
3930 +- static char cmd[TASK_COMM_LEN];
3931 +- if (strcmp(current->comm, cmd)) {
3932 +- printk_ratelimited(KERN_WARNING
3933 +- "sg_write: data in/out %d/%d bytes "
3934 +- "for SCSI command 0x%x-- guessing "
3935 +- "data in;\n program %s not setting "
3936 +- "count and/or reply_len properly\n",
3937 +- old_hdr.reply_len - (int)SZ_SG_HEADER,
3938 +- input_size, (unsigned int) cmnd[0],
3939 +- current->comm);
3940 +- strcpy(cmd, current->comm);
3941 +- }
3942 ++ printk_ratelimited(KERN_WARNING
3943 ++ "sg_write: data in/out %d/%d bytes "
3944 ++ "for SCSI command 0x%x-- guessing "
3945 ++ "data in;\n program %s not setting "
3946 ++ "count and/or reply_len properly\n",
3947 ++ old_hdr.reply_len - (int)SZ_SG_HEADER,
3948 ++ input_size, (unsigned int) cmnd[0],
3949 ++ current->comm);
3950 + }
3951 + k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
3952 + return (k < 0) ? k : count;
3953 +@@ -784,11 +782,15 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
3954 + "sg_common_write: scsi opcode=0x%02x, cmd_size=%d\n",
3955 + (int) cmnd[0], (int) hp->cmd_len));
3956 +
3957 ++ if (hp->dxfer_len >= SZ_256M)
3958 ++ return -EINVAL;
3959 ++
3960 + k = sg_start_req(srp, cmnd);
3961 + if (k) {
3962 + SCSI_LOG_TIMEOUT(1, sg_printk(KERN_INFO, sfp->parentdp,
3963 + "sg_common_write: start_req err=%d\n", k));
3964 + sg_finish_rem_req(srp);
3965 ++ sg_remove_request(sfp, srp);
3966 + return k; /* probably out of space --> ENOMEM */
3967 + }
3968 + if (atomic_read(&sdp->detaching)) {
3969 +@@ -801,6 +803,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
3970 + }
3971 +
3972 + sg_finish_rem_req(srp);
3973 ++ sg_remove_request(sfp, srp);
3974 + return -ENODEV;
3975 + }
3976 +
3977 +@@ -1290,6 +1293,7 @@ sg_rq_end_io_usercontext(struct work_struct *work)
3978 + struct sg_fd *sfp = srp->parentfp;
3979 +
3980 + sg_finish_rem_req(srp);
3981 ++ sg_remove_request(sfp, srp);
3982 + kref_put(&sfp->f_ref, sg_remove_sfp);
3983 + }
3984 +
3985 +@@ -1834,8 +1838,6 @@ sg_finish_rem_req(Sg_request *srp)
3986 + else
3987 + sg_remove_scat(sfp, req_schp);
3988 +
3989 +- sg_remove_request(sfp, srp);
3990 +-
3991 + return ret;
3992 + }
3993 +
3994 +@@ -2182,12 +2184,17 @@ sg_remove_sfp_usercontext(struct work_struct *work)
3995 + struct sg_fd *sfp = container_of(work, struct sg_fd, ew.work);
3996 + struct sg_device *sdp = sfp->parentdp;
3997 + Sg_request *srp;
3998 ++ unsigned long iflags;
3999 +
4000 + /* Cleanup any responses which were never read(). */
4001 ++ write_lock_irqsave(&sfp->rq_list_lock, iflags);
4002 + while (!list_empty(&sfp->rq_list)) {
4003 + srp = list_first_entry(&sfp->rq_list, Sg_request, entry);
4004 + sg_finish_rem_req(srp);
4005 ++ list_del(&srp->entry);
4006 ++ srp->parentfp = NULL;
4007 + }
4008 ++ write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
4009 +
4010 + if (sfp->reserve.bufflen > 0) {
4011 + SCSI_LOG_TIMEOUT(6, sg_printk(KERN_INFO, sdp,
4012 +diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
4013 +index ed8283e7397a..83b53cd956aa 100644
4014 +--- a/drivers/spi/spi-omap2-mcspi.c
4015 ++++ b/drivers/spi/spi-omap2-mcspi.c
4016 +@@ -457,6 +457,8 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
4017 + int elements = 0;
4018 + int word_len, element_count;
4019 + struct omap2_mcspi_cs *cs = spi->controller_state;
4020 ++ void __iomem *chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
4021 ++
4022 + mcspi = spi_master_get_devdata(spi->master);
4023 + mcspi_dma = &mcspi->dma_channels[spi->chip_select];
4024 + count = xfer->len;
4025 +@@ -517,8 +519,8 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
4026 + if (l & OMAP2_MCSPI_CHCONF_TURBO) {
4027 + elements--;
4028 +
4029 +- if (likely(mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHSTAT0)
4030 +- & OMAP2_MCSPI_CHSTAT_RXS)) {
4031 ++ if (!mcspi_wait_for_reg_bit(chstat_reg,
4032 ++ OMAP2_MCSPI_CHSTAT_RXS)) {
4033 + u32 w;
4034 +
4035 + w = mcspi_read_cs_reg(spi, OMAP2_MCSPI_RX0);
4036 +@@ -536,8 +538,7 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
4037 + return count;
4038 + }
4039 + }
4040 +- if (likely(mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHSTAT0)
4041 +- & OMAP2_MCSPI_CHSTAT_RXS)) {
4042 ++ if (!mcspi_wait_for_reg_bit(chstat_reg, OMAP2_MCSPI_CHSTAT_RXS)) {
4043 + u32 w;
4044 +
4045 + w = mcspi_read_cs_reg(spi, OMAP2_MCSPI_RX0);
4046 +diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
4047 +index e77add01b0e9..48888ab630c2 100644
4048 +--- a/drivers/spi/spi-sun6i.c
4049 ++++ b/drivers/spi/spi-sun6i.c
4050 +@@ -457,7 +457,7 @@ err_free_master:
4051 +
4052 + static int sun6i_spi_remove(struct platform_device *pdev)
4053 + {
4054 +- pm_runtime_disable(&pdev->dev);
4055 ++ pm_runtime_force_suspend(&pdev->dev);
4056 +
4057 + return 0;
4058 + }
4059 +diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
4060 +index fdfeb42b2b8f..06ef26872462 100644
4061 +--- a/drivers/staging/speakup/kobjects.c
4062 ++++ b/drivers/staging/speakup/kobjects.c
4063 +@@ -831,7 +831,9 @@ static ssize_t message_show(struct kobject *kobj,
4064 + struct msg_group_t *group = spk_find_msg_group(attr->attr.name);
4065 + unsigned long flags;
4066 +
4067 +- BUG_ON(!group);
4068 ++ if (WARN_ON(!group))
4069 ++ return -EINVAL;
4070 ++
4071 + spin_lock_irqsave(&speakup_info.spinlock, flags);
4072 + retval = message_show_helper(buf, group->start, group->end);
4073 + spin_unlock_irqrestore(&speakup_info.spinlock, flags);
4074 +@@ -843,7 +845,9 @@ static ssize_t message_store(struct kobject *kobj, struct kobj_attribute *attr,
4075 + {
4076 + struct msg_group_t *group = spk_find_msg_group(attr->attr.name);
4077 +
4078 +- BUG_ON(!group);
4079 ++ if (WARN_ON(!group))
4080 ++ return -EINVAL;
4081 ++
4082 + return message_store_helper(buf, count, group);
4083 + }
4084 +
4085 +diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
4086 +index dbbe72c7e255..f78353ddeea5 100644
4087 +--- a/drivers/staging/wilc1000/host_interface.c
4088 ++++ b/drivers/staging/wilc1000/host_interface.c
4089 +@@ -2179,6 +2179,8 @@ static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
4090 + wid.type = WID_STR;
4091 + wid.size = ETH_ALEN;
4092 + wid.val = kmalloc(wid.size, GFP_KERNEL);
4093 ++ if (!wid.val)
4094 ++ return -ENOMEM;
4095 +
4096 + stamac = wid.val;
4097 + memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
4098 +diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
4099 +index 571c21727ff9..88bd950665fa 100644
4100 +--- a/drivers/usb/dwc2/hcd.c
4101 ++++ b/drivers/usb/dwc2/hcd.c
4102 +@@ -1385,6 +1385,7 @@ static void dwc2_conn_id_status_change(struct work_struct *work)
4103 + dwc2_core_init(hsotg, false, -1);
4104 + dwc2_enable_global_interrupts(hsotg);
4105 + spin_lock_irqsave(&hsotg->lock, flags);
4106 ++ dwc2_hsotg_disconnect(hsotg);
4107 + dwc2_hsotg_core_init_disconnected(hsotg, false);
4108 + spin_unlock_irqrestore(&hsotg->lock, flags);
4109 + dwc2_hsotg_core_connect(hsotg);
4110 +diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
4111 +index ccb9c213cc9f..e9bd8d4abca0 100644
4112 +--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
4113 ++++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
4114 +@@ -475,7 +475,7 @@ static int bdc_probe(struct platform_device *pdev)
4115 + bdc->dev = dev;
4116 + dev_dbg(bdc->dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
4117 +
4118 +- temp = bdc_readl(bdc->regs, BDC_BDCSC);
4119 ++ temp = bdc_readl(bdc->regs, BDC_BDCCAP1);
4120 + if ((temp & BDC_P64) &&
4121 + !dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
4122 + dev_dbg(bdc->dev, "Using 64-bit address\n");
4123 +diff --git a/drivers/usb/gadget/udc/bdc/bdc_pci.c b/drivers/usb/gadget/udc/bdc/bdc_pci.c
4124 +index 02968842b359..708e36f530d8 100644
4125 +--- a/drivers/usb/gadget/udc/bdc/bdc_pci.c
4126 ++++ b/drivers/usb/gadget/udc/bdc/bdc_pci.c
4127 +@@ -82,6 +82,7 @@ static int bdc_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
4128 + if (ret) {
4129 + dev_err(&pci->dev,
4130 + "couldn't add resources to bdc device\n");
4131 ++ platform_device_put(bdc);
4132 + return ret;
4133 + }
4134 +
4135 +diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
4136 +index 8080a11947b7..eb876ed96861 100644
4137 +--- a/drivers/usb/gadget/udc/dummy_hcd.c
4138 ++++ b/drivers/usb/gadget/udc/dummy_hcd.c
4139 +@@ -2105,16 +2105,13 @@ static int dummy_hub_control(
4140 + }
4141 + break;
4142 + case USB_PORT_FEAT_POWER:
4143 +- if (hcd->speed == HCD_USB3) {
4144 +- if (dum_hcd->port_status & USB_PORT_STAT_POWER)
4145 +- dev_dbg(dummy_dev(dum_hcd),
4146 +- "power-off\n");
4147 +- } else
4148 +- if (dum_hcd->port_status &
4149 +- USB_SS_PORT_STAT_POWER)
4150 +- dev_dbg(dummy_dev(dum_hcd),
4151 +- "power-off\n");
4152 +- /* FALLS THROUGH */
4153 ++ dev_dbg(dummy_dev(dum_hcd), "power-off\n");
4154 ++ if (hcd->speed == HCD_USB3)
4155 ++ dum_hcd->port_status &= ~USB_SS_PORT_STAT_POWER;
4156 ++ else
4157 ++ dum_hcd->port_status &= ~USB_PORT_STAT_POWER;
4158 ++ set_link_state(dum_hcd);
4159 ++ break;
4160 + default:
4161 + dum_hcd->port_status &= ~(1 << wValue);
4162 + set_link_state(dum_hcd);
4163 +@@ -2285,14 +2282,13 @@ static int dummy_hub_control(
4164 + if ((dum_hcd->port_status &
4165 + USB_SS_PORT_STAT_POWER) != 0) {
4166 + dum_hcd->port_status |= (1 << wValue);
4167 +- set_link_state(dum_hcd);
4168 + }
4169 + } else
4170 + if ((dum_hcd->port_status &
4171 + USB_PORT_STAT_POWER) != 0) {
4172 + dum_hcd->port_status |= (1 << wValue);
4173 +- set_link_state(dum_hcd);
4174 + }
4175 ++ set_link_state(dum_hcd);
4176 + }
4177 + break;
4178 + case GetPortErrorCount:
4179 +diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
4180 +index 9362424c2340..924b3d6c3e9b 100644
4181 +--- a/drivers/video/fbdev/amba-clcd.c
4182 ++++ b/drivers/video/fbdev/amba-clcd.c
4183 +@@ -759,8 +759,8 @@ static int clcdfb_of_dma_setup(struct clcd_fb *fb)
4184 + if (err)
4185 + return err;
4186 +
4187 +- framesize = fb->panel->mode.xres * fb->panel->mode.yres *
4188 +- fb->panel->bpp / 8;
4189 ++ framesize = PAGE_ALIGN(fb->panel->mode.xres * fb->panel->mode.yres *
4190 ++ fb->panel->bpp / 8);
4191 + fb->fb.screen_base = dma_alloc_coherent(&fb->dev->dev, framesize,
4192 + &dma, GFP_KERNEL);
4193 + if (!fb->fb.screen_base)
4194 +diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
4195 +index 162689227a23..b73520aaf697 100644
4196 +--- a/drivers/video/hdmi.c
4197 ++++ b/drivers/video/hdmi.c
4198 +@@ -321,6 +321,17 @@ int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame)
4199 + }
4200 + EXPORT_SYMBOL(hdmi_vendor_infoframe_init);
4201 +
4202 ++static int hdmi_vendor_infoframe_length(const struct hdmi_vendor_infoframe *frame)
4203 ++{
4204 ++ /* for side by side (half) we also need to provide 3D_Ext_Data */
4205 ++ if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
4206 ++ return 6;
4207 ++ else if (frame->vic != 0 || frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
4208 ++ return 5;
4209 ++ else
4210 ++ return 4;
4211 ++}
4212 ++
4213 + /**
4214 + * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary buffer
4215 + * @frame: HDMI infoframe
4216 +@@ -341,19 +352,11 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
4217 + u8 *ptr = buffer;
4218 + size_t length;
4219 +
4220 +- /* empty info frame */
4221 +- if (frame->vic == 0 && frame->s3d_struct == HDMI_3D_STRUCTURE_INVALID)
4222 +- return -EINVAL;
4223 +-
4224 + /* only one of those can be supplied */
4225 + if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
4226 + return -EINVAL;
4227 +
4228 +- /* for side by side (half) we also need to provide 3D_Ext_Data */
4229 +- if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
4230 +- frame->length = 6;
4231 +- else
4232 +- frame->length = 5;
4233 ++ frame->length = hdmi_vendor_infoframe_length(frame);
4234 +
4235 + length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
4236 +
4237 +@@ -372,14 +375,16 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
4238 + ptr[5] = 0x0c;
4239 + ptr[6] = 0x00;
4240 +
4241 +- if (frame->vic) {
4242 +- ptr[7] = 0x1 << 5; /* video format */
4243 +- ptr[8] = frame->vic;
4244 +- } else {
4245 ++ if (frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) {
4246 + ptr[7] = 0x2 << 5; /* video format */
4247 + ptr[8] = (frame->s3d_struct & 0xf) << 4;
4248 + if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
4249 + ptr[9] = (frame->s3d_ext_data & 0xf) << 4;
4250 ++ } else if (frame->vic) {
4251 ++ ptr[7] = 0x1 << 5; /* video format */
4252 ++ ptr[8] = frame->vic;
4253 ++ } else {
4254 ++ ptr[7] = 0x0 << 5; /* video format */
4255 + }
4256 +
4257 + hdmi_infoframe_set_checksum(buffer, length);
4258 +@@ -1161,7 +1166,7 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
4259 +
4260 + if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
4261 + ptr[1] != 1 ||
4262 +- (ptr[2] != 5 && ptr[2] != 6))
4263 ++ (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
4264 + return -EINVAL;
4265 +
4266 + length = ptr[2];
4267 +@@ -1189,16 +1194,22 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
4268 +
4269 + hvf->length = length;
4270 +
4271 +- if (hdmi_video_format == 0x1) {
4272 +- hvf->vic = ptr[4];
4273 +- } else if (hdmi_video_format == 0x2) {
4274 ++ if (hdmi_video_format == 0x2) {
4275 ++ if (length != 5 && length != 6)
4276 ++ return -EINVAL;
4277 + hvf->s3d_struct = ptr[4] >> 4;
4278 + if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) {
4279 +- if (length == 6)
4280 +- hvf->s3d_ext_data = ptr[5] >> 4;
4281 +- else
4282 ++ if (length != 6)
4283 + return -EINVAL;
4284 ++ hvf->s3d_ext_data = ptr[5] >> 4;
4285 + }
4286 ++ } else if (hdmi_video_format == 0x1) {
4287 ++ if (length != 5)
4288 ++ return -EINVAL;
4289 ++ hvf->vic = ptr[4];
4290 ++ } else {
4291 ++ if (length != 4)
4292 ++ return -EINVAL;
4293 + }
4294 +
4295 + return 0;
4296 +diff --git a/fs/aio.c b/fs/aio.c
4297 +index fe4f49212b99..88ede4a84ce0 100644
4298 +--- a/fs/aio.c
4299 ++++ b/fs/aio.c
4300 +@@ -68,9 +68,9 @@ struct aio_ring {
4301 + #define AIO_RING_PAGES 8
4302 +
4303 + struct kioctx_table {
4304 +- struct rcu_head rcu;
4305 +- unsigned nr;
4306 +- struct kioctx *table[];
4307 ++ struct rcu_head rcu;
4308 ++ unsigned nr;
4309 ++ struct kioctx __rcu *table[];
4310 + };
4311 +
4312 + struct kioctx_cpu {
4313 +@@ -115,7 +115,8 @@ struct kioctx {
4314 + struct page **ring_pages;
4315 + long nr_pages;
4316 +
4317 +- struct work_struct free_work;
4318 ++ struct rcu_head free_rcu;
4319 ++ struct work_struct free_work; /* see free_ioctx() */
4320 +
4321 + /*
4322 + * signals when all in-flight requests are done
4323 +@@ -326,7 +327,7 @@ static int aio_ring_mremap(struct vm_area_struct *vma)
4324 + for (i = 0; i < table->nr; i++) {
4325 + struct kioctx *ctx;
4326 +
4327 +- ctx = table->table[i];
4328 ++ ctx = rcu_dereference(table->table[i]);
4329 + if (ctx && ctx->aio_ring_file == file) {
4330 + if (!atomic_read(&ctx->dead)) {
4331 + ctx->user_id = ctx->mmap_base = vma->vm_start;
4332 +@@ -573,6 +574,12 @@ static int kiocb_cancel(struct aio_kiocb *kiocb)
4333 + return cancel(&kiocb->common);
4334 + }
4335 +
4336 ++/*
4337 ++ * free_ioctx() should be RCU delayed to synchronize against the RCU
4338 ++ * protected lookup_ioctx() and also needs process context to call
4339 ++ * aio_free_ring(), so the double bouncing through kioctx->free_rcu and
4340 ++ * ->free_work.
4341 ++ */
4342 + static void free_ioctx(struct work_struct *work)
4343 + {
4344 + struct kioctx *ctx = container_of(work, struct kioctx, free_work);
4345 +@@ -586,6 +593,14 @@ static void free_ioctx(struct work_struct *work)
4346 + kmem_cache_free(kioctx_cachep, ctx);
4347 + }
4348 +
4349 ++static void free_ioctx_rcufn(struct rcu_head *head)
4350 ++{
4351 ++ struct kioctx *ctx = container_of(head, struct kioctx, free_rcu);
4352 ++
4353 ++ INIT_WORK(&ctx->free_work, free_ioctx);
4354 ++ schedule_work(&ctx->free_work);
4355 ++}
4356 ++
4357 + static void free_ioctx_reqs(struct percpu_ref *ref)
4358 + {
4359 + struct kioctx *ctx = container_of(ref, struct kioctx, reqs);
4360 +@@ -594,8 +609,8 @@ static void free_ioctx_reqs(struct percpu_ref *ref)
4361 + if (ctx->rq_wait && atomic_dec_and_test(&ctx->rq_wait->count))
4362 + complete(&ctx->rq_wait->comp);
4363 +
4364 +- INIT_WORK(&ctx->free_work, free_ioctx);
4365 +- schedule_work(&ctx->free_work);
4366 ++ /* Synchronize against RCU protected table->table[] dereferences */
4367 ++ call_rcu(&ctx->free_rcu, free_ioctx_rcufn);
4368 + }
4369 +
4370 + /*
4371 +@@ -636,9 +651,9 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
4372 + while (1) {
4373 + if (table)
4374 + for (i = 0; i < table->nr; i++)
4375 +- if (!table->table[i]) {
4376 ++ if (!rcu_access_pointer(table->table[i])) {
4377 + ctx->id = i;
4378 +- table->table[i] = ctx;
4379 ++ rcu_assign_pointer(table->table[i], ctx);
4380 + spin_unlock(&mm->ioctx_lock);
4381 +
4382 + /* While kioctx setup is in progress,
4383 +@@ -813,11 +828,11 @@ static int kill_ioctx(struct mm_struct *mm, struct kioctx *ctx,
4384 + }
4385 +
4386 + table = rcu_dereference_raw(mm->ioctx_table);
4387 +- WARN_ON(ctx != table->table[ctx->id]);
4388 +- table->table[ctx->id] = NULL;
4389 ++ WARN_ON(ctx != rcu_access_pointer(table->table[ctx->id]));
4390 ++ RCU_INIT_POINTER(table->table[ctx->id], NULL);
4391 + spin_unlock(&mm->ioctx_lock);
4392 +
4393 +- /* percpu_ref_kill() will do the necessary call_rcu() */
4394 ++ /* free_ioctx_reqs() will do the necessary RCU synchronization */
4395 + wake_up_all(&ctx->wait);
4396 +
4397 + /*
4398 +@@ -859,7 +874,8 @@ void exit_aio(struct mm_struct *mm)
4399 +
4400 + skipped = 0;
4401 + for (i = 0; i < table->nr; ++i) {
4402 +- struct kioctx *ctx = table->table[i];
4403 ++ struct kioctx *ctx =
4404 ++ rcu_dereference_protected(table->table[i], true);
4405 +
4406 + if (!ctx) {
4407 + skipped++;
4408 +@@ -1048,7 +1064,7 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id)
4409 + if (!table || id >= table->nr)
4410 + goto out;
4411 +
4412 +- ctx = table->table[id];
4413 ++ ctx = rcu_dereference(table->table[id]);
4414 + if (ctx && ctx->user_id == ctx_id) {
4415 + percpu_ref_get(&ctx->users);
4416 + ret = ctx;
4417 +diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
4418 +index 600c67ef8a03..6d874b1cd53c 100644
4419 +--- a/fs/btrfs/volumes.c
4420 ++++ b/fs/btrfs/volumes.c
4421 +@@ -568,6 +568,7 @@ void btrfs_free_stale_device(struct btrfs_device *cur_dev)
4422 + btrfs_sysfs_remove_fsid(fs_devs);
4423 + list_del(&fs_devs->list);
4424 + free_fs_devices(fs_devs);
4425 ++ break;
4426 + } else {
4427 + fs_devs->num_devices--;
4428 + list_del(&dev->dev_list);
4429 +@@ -4638,10 +4639,13 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
4430 + if (devs_max && ndevs > devs_max)
4431 + ndevs = devs_max;
4432 + /*
4433 +- * the primary goal is to maximize the number of stripes, so use as many
4434 +- * devices as possible, even if the stripes are not maximum sized.
4435 ++ * The primary goal is to maximize the number of stripes, so use as
4436 ++ * many devices as possible, even if the stripes are not maximum sized.
4437 ++ *
4438 ++ * The DUP profile stores more than one stripe per device, the
4439 ++ * max_avail is the total size so we have to adjust.
4440 + */
4441 +- stripe_size = devices_info[ndevs-1].max_avail;
4442 ++ stripe_size = div_u64(devices_info[ndevs - 1].max_avail, dev_stripes);
4443 + num_stripes = ndevs * dev_stripes;
4444 +
4445 + /*
4446 +@@ -4681,8 +4685,6 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
4447 + stripe_size = devices_info[ndevs-1].max_avail;
4448 + }
4449 +
4450 +- stripe_size = div_u64(stripe_size, dev_stripes);
4451 +-
4452 + /* align to BTRFS_STRIPE_LEN */
4453 + stripe_size = div_u64(stripe_size, raid_stripe_len);
4454 + stripe_size *= raid_stripe_len;
4455 +diff --git a/fs/dcache.c b/fs/dcache.c
4456 +index 3ed642e0a0c2..751a0d88f049 100644
4457 +--- a/fs/dcache.c
4458 ++++ b/fs/dcache.c
4459 +@@ -634,11 +634,16 @@ again:
4460 + spin_unlock(&parent->d_lock);
4461 + goto again;
4462 + }
4463 +- rcu_read_unlock();
4464 +- if (parent != dentry)
4465 ++ if (parent != dentry) {
4466 + spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
4467 +- else
4468 ++ if (unlikely(dentry->d_lockref.count < 0)) {
4469 ++ spin_unlock(&parent->d_lock);
4470 ++ parent = NULL;
4471 ++ }
4472 ++ } else {
4473 + parent = NULL;
4474 ++ }
4475 ++ rcu_read_unlock();
4476 + return parent;
4477 + }
4478 +
4479 +diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
4480 +index fedbf67a0842..928b9e046d8a 100644
4481 +--- a/fs/f2fs/gc.c
4482 ++++ b/fs/f2fs/gc.c
4483 +@@ -522,8 +522,10 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
4484 + get_node_info(sbi, nid, dni);
4485 +
4486 + if (sum->version != dni->version) {
4487 +- f2fs_put_page(node_page, 1);
4488 +- return false;
4489 ++ f2fs_msg(sbi->sb, KERN_WARNING,
4490 ++ "%s: valid data with mismatched node version.",
4491 ++ __func__);
4492 ++ set_sbi_flag(sbi, SBI_NEED_FSCK);
4493 + }
4494 +
4495 + *nofs = ofs_of_node(node_page);
4496 +diff --git a/fs/namei.c b/fs/namei.c
4497 +index 844da20232b9..0fcad42e4d3e 100644
4498 +--- a/fs/namei.c
4499 ++++ b/fs/namei.c
4500 +@@ -570,9 +570,10 @@ static int __nd_alloc_stack(struct nameidata *nd)
4501 + static bool path_connected(const struct path *path)
4502 + {
4503 + struct vfsmount *mnt = path->mnt;
4504 ++ struct super_block *sb = mnt->mnt_sb;
4505 +
4506 +- /* Only bind mounts can have disconnected paths */
4507 +- if (mnt->mnt_root == mnt->mnt_sb->s_root)
4508 ++ /* Bind mounts and multi-root filesystems can have disconnected paths */
4509 ++ if (!(sb->s_iflags & SB_I_MULTIROOT) && (mnt->mnt_root == sb->s_root))
4510 + return true;
4511 +
4512 + return is_subdir(path->dentry, mnt->mnt_root);
4513 +diff --git a/fs/nfs/super.c b/fs/nfs/super.c
4514 +index 3149f7e58d6f..62f358f67764 100644
4515 +--- a/fs/nfs/super.c
4516 ++++ b/fs/nfs/super.c
4517 +@@ -2581,6 +2581,8 @@ struct dentry *nfs_fs_mount_common(struct nfs_server *server,
4518 + /* initial superblock/root creation */
4519 + mount_info->fill_super(s, mount_info);
4520 + nfs_get_cache_cookie(s, mount_info->parsed, mount_info->cloned);
4521 ++ if (!(server->flags & NFS_MOUNT_UNSHARED))
4522 ++ s->s_iflags |= SB_I_MULTIROOT;
4523 + }
4524 +
4525 + mntroot = nfs_get_root(s, mount_info->mntfh, dev_name);
4526 +diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
4527 +index 9d6486d416a3..a72097b625ef 100644
4528 +--- a/fs/reiserfs/journal.c
4529 ++++ b/fs/reiserfs/journal.c
4530 +@@ -1961,7 +1961,7 @@ static int do_journal_release(struct reiserfs_transaction_handle *th,
4531 + * will be requeued because superblock is being shutdown and doesn't
4532 + * have MS_ACTIVE set.
4533 + */
4534 +- cancel_delayed_work_sync(&REISERFS_SB(sb)->old_work);
4535 ++ reiserfs_cancel_old_flush(sb);
4536 + /* wait for all commits to finish */
4537 + cancel_delayed_work_sync(&SB_JOURNAL(sb)->j_work);
4538 +
4539 +diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
4540 +index 5dcf3ab83886..6ca00471afbf 100644
4541 +--- a/fs/reiserfs/reiserfs.h
4542 ++++ b/fs/reiserfs/reiserfs.h
4543 +@@ -2948,6 +2948,7 @@ int reiserfs_allocate_list_bitmaps(struct super_block *s,
4544 + struct reiserfs_list_bitmap *, unsigned int);
4545 +
4546 + void reiserfs_schedule_old_flush(struct super_block *s);
4547 ++void reiserfs_cancel_old_flush(struct super_block *s);
4548 + void add_save_link(struct reiserfs_transaction_handle *th,
4549 + struct inode *inode, int truncate);
4550 + int remove_save_link(struct inode *inode, int truncate);
4551 +diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
4552 +index f9f3be50081a..ee095246da4e 100644
4553 +--- a/fs/reiserfs/super.c
4554 ++++ b/fs/reiserfs/super.c
4555 +@@ -90,7 +90,9 @@ static void flush_old_commits(struct work_struct *work)
4556 + s = sbi->s_journal->j_work_sb;
4557 +
4558 + spin_lock(&sbi->old_work_lock);
4559 +- sbi->work_queued = 0;
4560 ++ /* Avoid clobbering the cancel state... */
4561 ++ if (sbi->work_queued == 1)
4562 ++ sbi->work_queued = 0;
4563 + spin_unlock(&sbi->old_work_lock);
4564 +
4565 + reiserfs_sync_fs(s, 1);
4566 +@@ -117,21 +119,22 @@ void reiserfs_schedule_old_flush(struct super_block *s)
4567 + spin_unlock(&sbi->old_work_lock);
4568 + }
4569 +
4570 +-static void cancel_old_flush(struct super_block *s)
4571 ++void reiserfs_cancel_old_flush(struct super_block *s)
4572 + {
4573 + struct reiserfs_sb_info *sbi = REISERFS_SB(s);
4574 +
4575 +- cancel_delayed_work_sync(&REISERFS_SB(s)->old_work);
4576 + spin_lock(&sbi->old_work_lock);
4577 +- sbi->work_queued = 0;
4578 ++ /* Make sure no new flushes will be queued */
4579 ++ sbi->work_queued = 2;
4580 + spin_unlock(&sbi->old_work_lock);
4581 ++ cancel_delayed_work_sync(&REISERFS_SB(s)->old_work);
4582 + }
4583 +
4584 + static int reiserfs_freeze(struct super_block *s)
4585 + {
4586 + struct reiserfs_transaction_handle th;
4587 +
4588 +- cancel_old_flush(s);
4589 ++ reiserfs_cancel_old_flush(s);
4590 +
4591 + reiserfs_write_lock(s);
4592 + if (!(s->s_flags & MS_RDONLY)) {
4593 +@@ -152,7 +155,13 @@ static int reiserfs_freeze(struct super_block *s)
4594 +
4595 + static int reiserfs_unfreeze(struct super_block *s)
4596 + {
4597 ++ struct reiserfs_sb_info *sbi = REISERFS_SB(s);
4598 ++
4599 + reiserfs_allow_writes(s);
4600 ++ spin_lock(&sbi->old_work_lock);
4601 ++ /* Allow old_work to run again */
4602 ++ sbi->work_queued = 0;
4603 ++ spin_unlock(&sbi->old_work_lock);
4604 + return 0;
4605 + }
4606 +
4607 +@@ -2187,7 +2196,7 @@ error_unlocked:
4608 + if (sbi->commit_wq)
4609 + destroy_workqueue(sbi->commit_wq);
4610 +
4611 +- cancel_delayed_work_sync(&REISERFS_SB(s)->old_work);
4612 ++ reiserfs_cancel_old_flush(s);
4613 +
4614 + reiserfs_free_bitmap_cache(s);
4615 + if (SB_BUFFER_WITH_SB(s))
4616 +diff --git a/include/linux/fs.h b/include/linux/fs.h
4617 +index f746a59fcc88..da79e9d66e5b 100644
4618 +--- a/include/linux/fs.h
4619 ++++ b/include/linux/fs.h
4620 +@@ -1295,6 +1295,7 @@ struct mm_struct;
4621 + /* sb->s_iflags */
4622 + #define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */
4623 + #define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */
4624 ++#define SB_I_MULTIROOT 0x00000008 /* Multiple roots to the dentry tree */
4625 +
4626 + /* Possible states of 'frozen' field */
4627 + enum {
4628 +diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
4629 +index fbfadba81c5a..771774e13f10 100644
4630 +--- a/include/linux/pagemap.h
4631 ++++ b/include/linux/pagemap.h
4632 +@@ -153,7 +153,7 @@ static inline int page_cache_get_speculative(struct page *page)
4633 +
4634 + #ifdef CONFIG_TINY_RCU
4635 + # ifdef CONFIG_PREEMPT_COUNT
4636 +- VM_BUG_ON(!in_atomic());
4637 ++ VM_BUG_ON(!in_atomic() && !irqs_disabled());
4638 + # endif
4639 + /*
4640 + * Preempt must be disabled here - we rely on rcu_read_lock doing
4641 +@@ -191,7 +191,7 @@ static inline int page_cache_add_speculative(struct page *page, int count)
4642 +
4643 + #if !defined(CONFIG_SMP) && defined(CONFIG_TREE_RCU)
4644 + # ifdef CONFIG_PREEMPT_COUNT
4645 +- VM_BUG_ON(!in_atomic());
4646 ++ VM_BUG_ON(!in_atomic() && !irqs_disabled());
4647 + # endif
4648 + VM_BUG_ON_PAGE(page_count(page) == 0, page);
4649 + atomic_add(count, &page->_count);
4650 +diff --git a/include/linux/platform_data/isl9305.h b/include/linux/platform_data/isl9305.h
4651 +index 1419133fa69e..4ac1a070af0a 100644
4652 +--- a/include/linux/platform_data/isl9305.h
4653 ++++ b/include/linux/platform_data/isl9305.h
4654 +@@ -24,7 +24,7 @@
4655 + struct regulator_init_data;
4656 +
4657 + struct isl9305_pdata {
4658 +- struct regulator_init_data *init_data[ISL9305_MAX_REGULATOR];
4659 ++ struct regulator_init_data *init_data[ISL9305_MAX_REGULATOR + 1];
4660 + };
4661 +
4662 + #endif
4663 +diff --git a/include/net/tcp.h b/include/net/tcp.h
4664 +index cecb0e0eff06..a3696b778757 100644
4665 +--- a/include/net/tcp.h
4666 ++++ b/include/net/tcp.h
4667 +@@ -1199,9 +1199,11 @@ void tcp_select_initial_window(int __space, __u32 mss, __u32 *rcv_wnd,
4668 +
4669 + static inline int tcp_win_from_space(int space)
4670 + {
4671 +- return sysctl_tcp_adv_win_scale<=0 ?
4672 +- (space>>(-sysctl_tcp_adv_win_scale)) :
4673 +- space - (space>>sysctl_tcp_adv_win_scale);
4674 ++ int tcp_adv_win_scale = sysctl_tcp_adv_win_scale;
4675 ++
4676 ++ return tcp_adv_win_scale <= 0 ?
4677 ++ (space>>(-tcp_adv_win_scale)) :
4678 ++ space - (space>>tcp_adv_win_scale);
4679 + }
4680 +
4681 + /* Note: caller must be prepared to deal with negative returns */
4682 +diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
4683 +index c14003840bc5..79e3c21a35d0 100644
4684 +--- a/kernel/bpf/verifier.c
4685 ++++ b/kernel/bpf/verifier.c
4686 +@@ -1135,7 +1135,8 @@ static int check_alu_op(struct verifier_env *env, struct bpf_insn *insn)
4687 + regs[insn->dst_reg].type = UNKNOWN_VALUE;
4688 + regs[insn->dst_reg].map_ptr = NULL;
4689 + }
4690 +- } else {
4691 ++ } else if (BPF_CLASS(insn->code) == BPF_ALU64 ||
4692 ++ insn->imm >= 0) {
4693 + /* case: R = imm
4694 + * remember the value we stored into this reg
4695 + */
4696 +diff --git a/kernel/printk/braille.c b/kernel/printk/braille.c
4697 +index d5760c42f042..61d41ca41844 100644
4698 +--- a/kernel/printk/braille.c
4699 ++++ b/kernel/printk/braille.c
4700 +@@ -2,12 +2,13 @@
4701 +
4702 + #include <linux/kernel.h>
4703 + #include <linux/console.h>
4704 ++#include <linux/errno.h>
4705 + #include <linux/string.h>
4706 +
4707 + #include "console_cmdline.h"
4708 + #include "braille.h"
4709 +
4710 +-char *_braille_console_setup(char **str, char **brl_options)
4711 ++int _braille_console_setup(char **str, char **brl_options)
4712 + {
4713 + if (!strncmp(*str, "brl,", 4)) {
4714 + *brl_options = "";
4715 +@@ -15,14 +16,14 @@ char *_braille_console_setup(char **str, char **brl_options)
4716 + } else if (!strncmp(*str, "brl=", 4)) {
4717 + *brl_options = *str + 4;
4718 + *str = strchr(*brl_options, ',');
4719 +- if (!*str)
4720 ++ if (!*str) {
4721 + pr_err("need port name after brl=\n");
4722 +- else
4723 +- *((*str)++) = 0;
4724 +- } else
4725 +- return NULL;
4726 ++ return -EINVAL;
4727 ++ }
4728 ++ *((*str)++) = 0;
4729 ++ }
4730 +
4731 +- return *str;
4732 ++ return 0;
4733 + }
4734 +
4735 + int
4736 +diff --git a/kernel/printk/braille.h b/kernel/printk/braille.h
4737 +index 769d771145c8..749a6756843a 100644
4738 +--- a/kernel/printk/braille.h
4739 ++++ b/kernel/printk/braille.h
4740 +@@ -9,7 +9,14 @@ braille_set_options(struct console_cmdline *c, char *brl_options)
4741 + c->brl_options = brl_options;
4742 + }
4743 +
4744 +-char *
4745 ++/*
4746 ++ * Setup console according to braille options.
4747 ++ * Return -EINVAL on syntax error, 0 on success (or no braille option was
4748 ++ * actually given).
4749 ++ * Modifies str to point to the serial options
4750 ++ * Sets brl_options to the parsed braille options.
4751 ++ */
4752 ++int
4753 + _braille_console_setup(char **str, char **brl_options);
4754 +
4755 + int
4756 +@@ -25,10 +32,10 @@ braille_set_options(struct console_cmdline *c, char *brl_options)
4757 + {
4758 + }
4759 +
4760 +-static inline char *
4761 ++static inline int
4762 + _braille_console_setup(char **str, char **brl_options)
4763 + {
4764 +- return NULL;
4765 ++ return 0;
4766 + }
4767 +
4768 + static inline int
4769 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
4770 +index c5b1c62623cf..65ed3501c2ca 100644
4771 +--- a/kernel/sched/core.c
4772 ++++ b/kernel/sched/core.c
4773 +@@ -601,7 +601,8 @@ void resched_cpu(int cpu)
4774 + unsigned long flags;
4775 +
4776 + raw_spin_lock_irqsave(&rq->lock, flags);
4777 +- resched_curr(rq);
4778 ++ if (cpu_online(cpu) || cpu == smp_processor_id())
4779 ++ resched_curr(rq);
4780 + raw_spin_unlock_irqrestore(&rq->lock, flags);
4781 + }
4782 +
4783 +diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
4784 +index e0b5169aeac4..2ef31c93e195 100644
4785 +--- a/kernel/sched/rt.c
4786 ++++ b/kernel/sched/rt.c
4787 +@@ -2144,7 +2144,7 @@ static void switched_to_rt(struct rq *rq, struct task_struct *p)
4788 + if (p->nr_cpus_allowed > 1 && rq->rt.overloaded)
4789 + queue_push_tasks(rq);
4790 + #endif /* CONFIG_SMP */
4791 +- if (p->prio < rq->curr->prio)
4792 ++ if (p->prio < rq->curr->prio && cpu_online(cpu_of(rq)))
4793 + resched_curr(rq);
4794 + }
4795 + }
4796 +diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
4797 +index a26036d37a38..382b159d8592 100644
4798 +--- a/kernel/time/sched_clock.c
4799 ++++ b/kernel/time/sched_clock.c
4800 +@@ -205,6 +205,11 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate)
4801 +
4802 + update_clock_read_data(&rd);
4803 +
4804 ++ if (sched_clock_timer.function != NULL) {
4805 ++ /* update timeout for clock wrap */
4806 ++ hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL);
4807 ++ }
4808 ++
4809 + r = rate;
4810 + if (r >= 4000000) {
4811 + r /= 1000000;
4812 +diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
4813 +index ba7d8b288bb3..ef4f16e81283 100644
4814 +--- a/kernel/time/timer_list.c
4815 ++++ b/kernel/time/timer_list.c
4816 +@@ -16,6 +16,7 @@
4817 + #include <linux/sched.h>
4818 + #include <linux/seq_file.h>
4819 + #include <linux/kallsyms.h>
4820 ++#include <linux/nmi.h>
4821 +
4822 + #include <asm/uaccess.h>
4823 +
4824 +@@ -96,6 +97,9 @@ print_active_timers(struct seq_file *m, struct hrtimer_clock_base *base,
4825 +
4826 + next_one:
4827 + i = 0;
4828 ++
4829 ++ touch_nmi_watchdog();
4830 ++
4831 + raw_spin_lock_irqsave(&base->cpu_base->lock, flags);
4832 +
4833 + curr = timerqueue_getnext(&base->active);
4834 +@@ -207,6 +211,8 @@ print_tickdevice(struct seq_file *m, struct tick_device *td, int cpu)
4835 + {
4836 + struct clock_event_device *dev = td->evtdev;
4837 +
4838 ++ touch_nmi_watchdog();
4839 ++
4840 + SEQ_printf(m, "Tick Device: mode: %d\n", td->mode);
4841 + if (cpu < 0)
4842 + SEQ_printf(m, "Broadcast device\n");
4843 +diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
4844 +index ca4dc9031073..89da689b6433 100644
4845 +--- a/net/8021q/vlan_dev.c
4846 ++++ b/net/8021q/vlan_dev.c
4847 +@@ -559,8 +559,7 @@ static int vlan_dev_init(struct net_device *dev)
4848 + NETIF_F_HIGHDMA | NETIF_F_SCTP_CSUM |
4849 + NETIF_F_ALL_FCOE;
4850 +
4851 +- dev->features |= real_dev->vlan_features | NETIF_F_LLTX |
4852 +- NETIF_F_GSO_SOFTWARE;
4853 ++ dev->features |= dev->hw_features | NETIF_F_LLTX;
4854 + dev->gso_max_size = real_dev->gso_max_size;
4855 + if (dev->features & NETIF_F_VLAN_FEATURES)
4856 + netdev_warn(real_dev, "VLAN features are set incorrectly. Q-in-Q configurations may not work correctly.\n");
4857 +diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
4858 +index f5d2fe5e31cc..c5208136e3fc 100644
4859 +--- a/net/batman-adv/bridge_loop_avoidance.c
4860 ++++ b/net/batman-adv/bridge_loop_avoidance.c
4861 +@@ -1603,10 +1603,22 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
4862 + /* if yes, the client has roamed and we have
4863 + * to unclaim it.
4864 + */
4865 +- batadv_handle_unclaim(bat_priv, primary_if,
4866 +- primary_if->net_dev->dev_addr,
4867 +- ethhdr->h_source, vid);
4868 +- goto allow;
4869 ++ if (batadv_has_timed_out(claim->lasttime, 100)) {
4870 ++ /* only unclaim if the last claim entry is
4871 ++ * older than 100 ms to make sure we really
4872 ++ * have a roaming client here.
4873 ++ */
4874 ++ batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_tx(): Roaming client %pM detected. Unclaim it.\n",
4875 ++ ethhdr->h_source);
4876 ++ batadv_handle_unclaim(bat_priv, primary_if,
4877 ++ primary_if->net_dev->dev_addr,
4878 ++ ethhdr->h_source, vid);
4879 ++ goto allow;
4880 ++ } else {
4881 ++ batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_tx(): Race for claim %pM detected. Drop packet.\n",
4882 ++ ethhdr->h_source);
4883 ++ goto handled;
4884 ++ }
4885 + }
4886 +
4887 + /* check if it is a multicast/broadcast frame */
4888 +diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
4889 +index bcb0a1b64556..58588a610b05 100644
4890 +--- a/net/mac80211/iface.c
4891 ++++ b/net/mac80211/iface.c
4892 +@@ -1441,7 +1441,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
4893 + break;
4894 + case NL80211_IFTYPE_UNSPECIFIED:
4895 + case NUM_NL80211_IFTYPES:
4896 +- BUG();
4897 ++ WARN_ON(1);
4898 + break;
4899 + }
4900 +
4901 +diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c
4902 +index eeb3eb3ea9eb..024d6cf342c5 100644
4903 +--- a/net/sched/act_csum.c
4904 ++++ b/net/sched/act_csum.c
4905 +@@ -175,6 +175,9 @@ static int tcf_csum_ipv4_tcp(struct sk_buff *skb,
4906 + struct tcphdr *tcph;
4907 + const struct iphdr *iph;
4908 +
4909 ++ if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
4910 ++ return 1;
4911 ++
4912 + tcph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*tcph));
4913 + if (tcph == NULL)
4914 + return 0;
4915 +@@ -196,6 +199,9 @@ static int tcf_csum_ipv6_tcp(struct sk_buff *skb,
4916 + struct tcphdr *tcph;
4917 + const struct ipv6hdr *ip6h;
4918 +
4919 ++ if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
4920 ++ return 1;
4921 ++
4922 + tcph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*tcph));
4923 + if (tcph == NULL)
4924 + return 0;
4925 +@@ -219,6 +225,9 @@ static int tcf_csum_ipv4_udp(struct sk_buff *skb,
4926 + const struct iphdr *iph;
4927 + u16 ul;
4928 +
4929 ++ if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
4930 ++ return 1;
4931 ++
4932 + /*
4933 + * Support both UDP and UDPLITE checksum algorithms, Don't use
4934 + * udph->len to get the real length without any protocol check,
4935 +@@ -272,6 +281,9 @@ static int tcf_csum_ipv6_udp(struct sk_buff *skb,
4936 + const struct ipv6hdr *ip6h;
4937 + u16 ul;
4938 +
4939 ++ if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
4940 ++ return 1;
4941 ++
4942 + /*
4943 + * Support both UDP and UDPLITE checksum algorithms, Don't use
4944 + * udph->len to get the real length without any protocol check,
4945 +diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
4946 +index 4b09a9eaa35f..d95cb69460f0 100644
4947 +--- a/net/xfrm/xfrm_policy.c
4948 ++++ b/net/xfrm/xfrm_policy.c
4949 +@@ -1313,7 +1313,7 @@ EXPORT_SYMBOL(xfrm_policy_delete);
4950 +
4951 + int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol)
4952 + {
4953 +- struct net *net = xp_net(pol);
4954 ++ struct net *net = sock_net(sk);
4955 + struct xfrm_policy *old_pol;
4956 +
4957 + #ifdef CONFIG_XFRM_SUB_POLICY
4958 +diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
4959 +index 9895a8c56d8c..96d664e198bf 100644
4960 +--- a/net/xfrm/xfrm_state.c
4961 ++++ b/net/xfrm/xfrm_state.c
4962 +@@ -1845,6 +1845,13 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
4963 + struct xfrm_mgr *km;
4964 + struct xfrm_policy *pol = NULL;
4965 +
4966 ++ if (!optval && !optlen) {
4967 ++ xfrm_sk_policy_insert(sk, XFRM_POLICY_IN, NULL);
4968 ++ xfrm_sk_policy_insert(sk, XFRM_POLICY_OUT, NULL);
4969 ++ __sk_dst_reset(sk);
4970 ++ return 0;
4971 ++ }
4972 ++
4973 + if (optlen <= 0 || optlen > PAGE_SIZE)
4974 + return -EMSGSIZE;
4975 +
4976 +diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
4977 +index dec607c17b64..6dc4ce47580f 100644
4978 +--- a/security/apparmor/lsm.c
4979 ++++ b/security/apparmor/lsm.c
4980 +@@ -722,7 +722,7 @@ module_param_named(logsyscall, aa_g_logsyscall, aabool, S_IRUSR | S_IWUSR);
4981 +
4982 + /* Maximum pathname length before accesses will start getting rejected */
4983 + unsigned int aa_g_path_max = 2 * PATH_MAX;
4984 +-module_param_named(path_max, aa_g_path_max, aauint, S_IRUSR | S_IWUSR);
4985 ++module_param_named(path_max, aa_g_path_max, aauint, S_IRUSR);
4986 +
4987 + /* Determines how paranoid loading of policy is and how much verification
4988 + * on the loaded policy is done.
4989 +diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
4990 +index 19014293f927..8da7c91b725d 100644
4991 +--- a/security/integrity/ima/ima_appraise.c
4992 ++++ b/security/integrity/ima/ima_appraise.c
4993 +@@ -206,7 +206,8 @@ int ima_appraise_measurement(int func, struct integrity_iint_cache *iint,
4994 + if (opened & FILE_CREATED)
4995 + iint->flags |= IMA_NEW_FILE;
4996 + if ((iint->flags & IMA_NEW_FILE) &&
4997 +- !(iint->flags & IMA_DIGSIG_REQUIRED))
4998 ++ (!(iint->flags & IMA_DIGSIG_REQUIRED) ||
4999 ++ (inode->i_size == 0)))
5000 + status = INTEGRITY_PASS;
5001 + goto out;
5002 + }
5003 +diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
5004 +index 3f370eb494d1..4c7db967b7bb 100644
5005 +--- a/security/selinux/hooks.c
5006 ++++ b/security/selinux/hooks.c
5007 +@@ -4124,10 +4124,18 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
5008 + u32 sid, node_perm;
5009 +
5010 + if (family == PF_INET) {
5011 ++ if (addrlen < sizeof(struct sockaddr_in)) {
5012 ++ err = -EINVAL;
5013 ++ goto out;
5014 ++ }
5015 + addr4 = (struct sockaddr_in *)address;
5016 + snum = ntohs(addr4->sin_port);
5017 + addrp = (char *)&addr4->sin_addr.s_addr;
5018 + } else {
5019 ++ if (addrlen < SIN6_LEN_RFC2133) {
5020 ++ err = -EINVAL;
5021 ++ goto out;
5022 ++ }
5023 + addr6 = (struct sockaddr_in6 *)address;
5024 + snum = ntohs(addr6->sin6_port);
5025 + addrp = (char *)&addr6->sin6_addr.s6_addr;
5026 +diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
5027 +index 494b7b533366..daa1feac66bf 100644
5028 +--- a/sound/core/oss/pcm_oss.c
5029 ++++ b/sound/core/oss/pcm_oss.c
5030 +@@ -1814,10 +1814,9 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
5031 + return -ENOMEM;
5032 + _snd_pcm_hw_params_any(params);
5033 + err = snd_pcm_hw_refine(substream, params);
5034 +- format_mask = *hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
5035 +- kfree(params);
5036 + if (err < 0)
5037 +- return err;
5038 ++ goto error;
5039 ++ format_mask = *hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
5040 + for (fmt = 0; fmt < 32; ++fmt) {
5041 + if (snd_mask_test(&format_mask, fmt)) {
5042 + int f = snd_pcm_oss_format_to(fmt);
5043 +@@ -1825,7 +1824,10 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
5044 + formats |= f;
5045 + }
5046 + }
5047 +- return formats;
5048 ++
5049 ++ error:
5050 ++ kfree(params);
5051 ++ return err < 0 ? err : formats;
5052 + }
5053 +
5054 + static int snd_pcm_oss_set_format(struct snd_pcm_oss_file *pcm_oss_file, int format)
5055 +diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
5056 +index 94fd3df2cf21..73ee8476584d 100644
5057 +--- a/sound/core/seq/seq_clientmgr.c
5058 ++++ b/sound/core/seq/seq_clientmgr.c
5059 +@@ -270,12 +270,12 @@ static int seq_free_client1(struct snd_seq_client *client)
5060 +
5061 + if (!client)
5062 + return 0;
5063 +- snd_seq_delete_all_ports(client);
5064 +- snd_seq_queue_client_leave(client->number);
5065 + spin_lock_irqsave(&clients_lock, flags);
5066 + clienttablock[client->number] = 1;
5067 + clienttab[client->number] = NULL;
5068 + spin_unlock_irqrestore(&clients_lock, flags);
5069 ++ snd_seq_delete_all_ports(client);
5070 ++ snd_seq_queue_client_leave(client->number);
5071 + snd_use_lock_sync(&client->use_lock);
5072 + snd_seq_queue_client_termination(client->number);
5073 + if (client->pool)
5074 +diff --git a/sound/core/seq/seq_prioq.c b/sound/core/seq/seq_prioq.c
5075 +index bc1c8488fc2a..2bc6759e4adc 100644
5076 +--- a/sound/core/seq/seq_prioq.c
5077 ++++ b/sound/core/seq/seq_prioq.c
5078 +@@ -87,7 +87,7 @@ void snd_seq_prioq_delete(struct snd_seq_prioq **fifo)
5079 + if (f->cells > 0) {
5080 + /* drain prioQ */
5081 + while (f->cells > 0)
5082 +- snd_seq_cell_free(snd_seq_prioq_cell_out(f));
5083 ++ snd_seq_cell_free(snd_seq_prioq_cell_out(f, NULL));
5084 + }
5085 +
5086 + kfree(f);
5087 +@@ -214,8 +214,18 @@ int snd_seq_prioq_cell_in(struct snd_seq_prioq * f,
5088 + return 0;
5089 + }
5090 +
5091 ++/* return 1 if the current time >= event timestamp */
5092 ++static int event_is_ready(struct snd_seq_event *ev, void *current_time)
5093 ++{
5094 ++ if ((ev->flags & SNDRV_SEQ_TIME_STAMP_MASK) == SNDRV_SEQ_TIME_STAMP_TICK)
5095 ++ return snd_seq_compare_tick_time(current_time, &ev->time.tick);
5096 ++ else
5097 ++ return snd_seq_compare_real_time(current_time, &ev->time.time);
5098 ++}
5099 ++
5100 + /* dequeue cell from prioq */
5101 +-struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f)
5102 ++struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f,
5103 ++ void *current_time)
5104 + {
5105 + struct snd_seq_event_cell *cell;
5106 + unsigned long flags;
5107 +@@ -227,6 +237,8 @@ struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f)
5108 + spin_lock_irqsave(&f->lock, flags);
5109 +
5110 + cell = f->head;
5111 ++ if (cell && current_time && !event_is_ready(&cell->event, current_time))
5112 ++ cell = NULL;
5113 + if (cell) {
5114 + f->head = cell->next;
5115 +
5116 +@@ -252,18 +264,6 @@ int snd_seq_prioq_avail(struct snd_seq_prioq * f)
5117 + return f->cells;
5118 + }
5119 +
5120 +-
5121 +-/* peek at cell at the head of the prioq */
5122 +-struct snd_seq_event_cell *snd_seq_prioq_cell_peek(struct snd_seq_prioq * f)
5123 +-{
5124 +- if (f == NULL) {
5125 +- pr_debug("ALSA: seq: snd_seq_prioq_cell_in() called with NULL prioq\n");
5126 +- return NULL;
5127 +- }
5128 +- return f->head;
5129 +-}
5130 +-
5131 +-
5132 + static inline int prioq_match(struct snd_seq_event_cell *cell,
5133 + int client, int timestamp)
5134 + {
5135 +diff --git a/sound/core/seq/seq_prioq.h b/sound/core/seq/seq_prioq.h
5136 +index d38bb78d9345..2c315ca10fc4 100644
5137 +--- a/sound/core/seq/seq_prioq.h
5138 ++++ b/sound/core/seq/seq_prioq.h
5139 +@@ -44,14 +44,12 @@ void snd_seq_prioq_delete(struct snd_seq_prioq **fifo);
5140 + int snd_seq_prioq_cell_in(struct snd_seq_prioq *f, struct snd_seq_event_cell *cell);
5141 +
5142 + /* dequeue cell from prioq */
5143 +-struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f);
5144 ++struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f,
5145 ++ void *current_time);
5146 +
5147 + /* return number of events available in prioq */
5148 + int snd_seq_prioq_avail(struct snd_seq_prioq *f);
5149 +
5150 +-/* peek at cell at the head of the prioq */
5151 +-struct snd_seq_event_cell *snd_seq_prioq_cell_peek(struct snd_seq_prioq *f);
5152 +-
5153 + /* client left queue */
5154 + void snd_seq_prioq_leave(struct snd_seq_prioq *f, int client, int timestamp);
5155 +
5156 +diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c
5157 +index 79e0c5604ef8..1a6dc4ff44a6 100644
5158 +--- a/sound/core/seq/seq_queue.c
5159 ++++ b/sound/core/seq/seq_queue.c
5160 +@@ -277,30 +277,20 @@ void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop)
5161 +
5162 + __again:
5163 + /* Process tick queue... */
5164 +- while ((cell = snd_seq_prioq_cell_peek(q->tickq)) != NULL) {
5165 +- if (snd_seq_compare_tick_time(&q->timer->tick.cur_tick,
5166 +- &cell->event.time.tick)) {
5167 +- cell = snd_seq_prioq_cell_out(q->tickq);
5168 +- if (cell)
5169 +- snd_seq_dispatch_event(cell, atomic, hop);
5170 +- } else {
5171 +- /* event remains in the queue */
5172 ++ for (;;) {
5173 ++ cell = snd_seq_prioq_cell_out(q->tickq,
5174 ++ &q->timer->tick.cur_tick);
5175 ++ if (!cell)
5176 + break;
5177 +- }
5178 ++ snd_seq_dispatch_event(cell, atomic, hop);
5179 + }
5180 +
5181 +-
5182 + /* Process time queue... */
5183 +- while ((cell = snd_seq_prioq_cell_peek(q->timeq)) != NULL) {
5184 +- if (snd_seq_compare_real_time(&q->timer->cur_time,
5185 +- &cell->event.time.time)) {
5186 +- cell = snd_seq_prioq_cell_out(q->timeq);
5187 +- if (cell)
5188 +- snd_seq_dispatch_event(cell, atomic, hop);
5189 +- } else {
5190 +- /* event remains in the queue */
5191 ++ for (;;) {
5192 ++ cell = snd_seq_prioq_cell_out(q->timeq, &q->timer->cur_time);
5193 ++ if (!cell)
5194 + break;
5195 +- }
5196 ++ snd_seq_dispatch_event(cell, atomic, hop);
5197 + }
5198 +
5199 + /* free lock */
5200 +diff --git a/sound/firewire/digi00x/amdtp-dot.c b/sound/firewire/digi00x/amdtp-dot.c
5201 +index b02a5e8cad44..30e4925bf6b0 100644
5202 +--- a/sound/firewire/digi00x/amdtp-dot.c
5203 ++++ b/sound/firewire/digi00x/amdtp-dot.c
5204 +@@ -28,6 +28,9 @@
5205 + */
5206 + #define MAX_MIDI_RX_BLOCKS 8
5207 +
5208 ++/* 3 = MAX(DOT_MIDI_IN_PORTS, DOT_MIDI_OUT_PORTS) + 1. */
5209 ++#define MAX_MIDI_PORTS 3
5210 ++
5211 + /*
5212 + * The double-oh-three algorithm was discovered by Robin Gareus and Damien
5213 + * Zammit in 2012, with reverse-engineering for Digi 003 Rack.
5214 +@@ -42,10 +45,8 @@ struct amdtp_dot {
5215 + unsigned int pcm_channels;
5216 + struct dot_state state;
5217 +
5218 +- unsigned int midi_ports;
5219 +- /* 2 = MAX(DOT_MIDI_IN_PORTS, DOT_MIDI_OUT_PORTS) */
5220 +- struct snd_rawmidi_substream *midi[2];
5221 +- int midi_fifo_used[2];
5222 ++ struct snd_rawmidi_substream *midi[MAX_MIDI_PORTS];
5223 ++ int midi_fifo_used[MAX_MIDI_PORTS];
5224 + int midi_fifo_limit;
5225 +
5226 + void (*transfer_samples)(struct amdtp_stream *s,
5227 +@@ -124,8 +125,8 @@ int amdtp_dot_set_parameters(struct amdtp_stream *s, unsigned int rate,
5228 + return -EBUSY;
5229 +
5230 + /*
5231 +- * A first data channel is for MIDI conformant data channel, the rest is
5232 +- * Multi Bit Linear Audio data channel.
5233 ++ * A first data channel is for MIDI messages, the rest is Multi Bit
5234 ++ * Linear Audio data channel.
5235 + */
5236 + err = amdtp_stream_set_parameters(s, rate, pcm_channels + 1);
5237 + if (err < 0)
5238 +@@ -135,11 +136,6 @@ int amdtp_dot_set_parameters(struct amdtp_stream *s, unsigned int rate,
5239 +
5240 + p->pcm_channels = pcm_channels;
5241 +
5242 +- if (s->direction == AMDTP_IN_STREAM)
5243 +- p->midi_ports = DOT_MIDI_IN_PORTS;
5244 +- else
5245 +- p->midi_ports = DOT_MIDI_OUT_PORTS;
5246 +-
5247 + /*
5248 + * We do not know the actual MIDI FIFO size of most devices. Just
5249 + * assume two bytes, i.e., one byte can be received over the bus while
5250 +@@ -281,13 +277,25 @@ static void write_midi_messages(struct amdtp_stream *s, __be32 *buffer,
5251 + b = (u8 *)&buffer[0];
5252 +
5253 + len = 0;
5254 +- if (port < p->midi_ports &&
5255 ++ if (port < MAX_MIDI_PORTS &&
5256 + midi_ratelimit_per_packet(s, port) &&
5257 + p->midi[port] != NULL)
5258 + len = snd_rawmidi_transmit(p->midi[port], b + 1, 2);
5259 +
5260 + if (len > 0) {
5261 +- b[3] = (0x10 << port) | len;
5262 ++ /*
5263 ++ * Upper 4 bits of LSB represent port number.
5264 ++ * - 0000b: physical MIDI port 1.
5265 ++ * - 0010b: physical MIDI port 2.
5266 ++ * - 1110b: console MIDI port.
5267 ++ */
5268 ++ if (port == 2)
5269 ++ b[3] = 0xe0;
5270 ++ else if (port == 1)
5271 ++ b[3] = 0x20;
5272 ++ else
5273 ++ b[3] = 0x00;
5274 ++ b[3] |= len;
5275 + midi_use_bytes(s, port, len);
5276 + } else {
5277 + b[1] = 0;
5278 +@@ -309,11 +317,22 @@ static void read_midi_messages(struct amdtp_stream *s, __be32 *buffer,
5279 +
5280 + for (f = 0; f < data_blocks; f++) {
5281 + b = (u8 *)&buffer[0];
5282 +- port = b[3] >> 4;
5283 +- len = b[3] & 0x0f;
5284 +
5285 +- if (port < p->midi_ports && p->midi[port] && len > 0)
5286 +- snd_rawmidi_receive(p->midi[port], b + 1, len);
5287 ++ len = b[3] & 0x0f;
5288 ++ if (len > 0) {
5289 ++ /*
5290 ++ * Upper 4 bits of LSB represent port number.
5291 ++ * - 0000b: physical MIDI port 1. Use port 0.
5292 ++ * - 1110b: console MIDI port. Use port 2.
5293 ++ */
5294 ++ if (b[3] >> 4 > 0)
5295 ++ port = 2;
5296 ++ else
5297 ++ port = 0;
5298 ++
5299 ++ if (port < MAX_MIDI_PORTS && p->midi[port])
5300 ++ snd_rawmidi_receive(p->midi[port], b + 1, len);
5301 ++ }
5302 +
5303 + buffer += s->data_block_quadlets;
5304 + }
5305 +@@ -364,7 +383,7 @@ void amdtp_dot_midi_trigger(struct amdtp_stream *s, unsigned int port,
5306 + {
5307 + struct amdtp_dot *p = s->protocol;
5308 +
5309 +- if (port < p->midi_ports)
5310 ++ if (port < MAX_MIDI_PORTS)
5311 + ACCESS_ONCE(p->midi[port]) = midi;
5312 + }
5313 +
5314 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
5315 +index e2212830df0c..fbd00821e326 100644
5316 +--- a/sound/pci/hda/hda_intel.c
5317 ++++ b/sound/pci/hda/hda_intel.c
5318 +@@ -179,11 +179,15 @@ static const struct kernel_param_ops param_ops_xint = {
5319 + };
5320 + #define param_check_xint param_check_int
5321 +
5322 +-static int power_save = -1;
5323 ++static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
5324 + module_param(power_save, xint, 0644);
5325 + MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
5326 + "(in second, 0 = disable).");
5327 +
5328 ++static bool pm_blacklist = true;
5329 ++module_param(pm_blacklist, bool, 0644);
5330 ++MODULE_PARM_DESC(pm_blacklist, "Enable power-management blacklist");
5331 ++
5332 + /* reset the HD-audio controller in power save mode.
5333 + * this may give more power-saving, but will take longer time to
5334 + * wake up.
5335 +@@ -2164,10 +2168,9 @@ static int azx_probe_continue(struct azx *chip)
5336 +
5337 + val = power_save;
5338 + #ifdef CONFIG_PM
5339 +- if (val == -1) {
5340 ++ if (pm_blacklist) {
5341 + const struct snd_pci_quirk *q;
5342 +
5343 +- val = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
5344 + q = snd_pci_quirk_lookup(chip->pci, power_save_blacklist);
5345 + if (q && val) {
5346 + dev_info(chip->card->dev, "device %04x:%04x is on the power_save blacklist, forcing power_save to 0\n",
5347 +diff --git a/sound/soc/nuc900/nuc900-ac97.c b/sound/soc/nuc900/nuc900-ac97.c
5348 +index b6615affe571..fde974d52bb2 100644
5349 +--- a/sound/soc/nuc900/nuc900-ac97.c
5350 ++++ b/sound/soc/nuc900/nuc900-ac97.c
5351 +@@ -67,7 +67,7 @@ static unsigned short nuc900_ac97_read(struct snd_ac97 *ac97,
5352 +
5353 + /* polling the AC_R_FINISH */
5354 + while (!(AUDIO_READ(nuc900_audio->mmio + ACTL_ACCON) & AC_R_FINISH)
5355 +- && timeout--)
5356 ++ && --timeout)
5357 + mdelay(1);
5358 +
5359 + if (!timeout) {
5360 +@@ -121,7 +121,7 @@ static void nuc900_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
5361 +
5362 + /* polling the AC_W_FINISH */
5363 + while ((AUDIO_READ(nuc900_audio->mmio + ACTL_ACCON) & AC_W_FINISH)
5364 +- && timeout--)
5365 ++ && --timeout)
5366 + mdelay(1);
5367 +
5368 + if (!timeout)
5369 +diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
5370 +index 38aae96267c9..a001331a53c1 100644
5371 +--- a/sound/soc/sh/rcar/ssi.c
5372 ++++ b/sound/soc/sh/rcar/ssi.c
5373 +@@ -142,6 +142,15 @@ static int rsnd_ssi_master_clk_start(struct rsnd_ssi *ssi,
5374 + */
5375 + for (j = 0; j < ARRAY_SIZE(ssi_clk_mul_table); j++) {
5376 +
5377 ++ /*
5378 ++ * It will set SSIWSR.CONT here, but SSICR.CKDV = 000
5379 ++ * with it is not allowed. (SSIWSR.WS_MODE with
5380 ++ * SSICR.CKDV = 000 is not allowed either).
5381 ++ * Skip it. See SSICR.CKDV
5382 ++ */
5383 ++ if (j == 0)
5384 ++ continue;
5385 ++
5386 + /*
5387 + * this driver is assuming that
5388 + * system word is 64fs (= 2 x 32bit)
5389 +diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
5390 +index 132afc97676c..9d4ac90ca87e 100644
5391 +--- a/tools/perf/builtin-probe.c
5392 ++++ b/tools/perf/builtin-probe.c
5393 +@@ -405,9 +405,9 @@ static int perf_del_probe_events(struct strfilter *filter)
5394 + }
5395 +
5396 + if (ret == -ENOENT && ret2 == -ENOENT)
5397 +- pr_debug("\"%s\" does not hit any event.\n", str);
5398 +- /* Note that this is silently ignored */
5399 +- ret = 0;
5400 ++ pr_warning("\"%s\" does not hit any event.\n", str);
5401 ++ else
5402 ++ ret = 0;
5403 +
5404 + error:
5405 + if (kfd >= 0)
5406 +diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
5407 +index 26cba64345e3..46af9dde11e2 100644
5408 +--- a/tools/perf/util/event.c
5409 ++++ b/tools/perf/util/event.c
5410 +@@ -234,8 +234,8 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
5411 + if (machine__is_default_guest(machine))
5412 + return 0;
5413 +
5414 +- snprintf(filename, sizeof(filename), "%s/proc/%d/maps",
5415 +- machine->root_dir, pid);
5416 ++ snprintf(filename, sizeof(filename), "%s/proc/%d/task/%d/maps",
5417 ++ machine->root_dir, pid, pid);
5418 +
5419 + fp = fopen(filename, "r");
5420 + if (fp == NULL) {
5421 +diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
5422 +index b1b9e2385f4b..5e58149c4df2 100644
5423 +--- a/tools/perf/util/ordered-events.c
5424 ++++ b/tools/perf/util/ordered-events.c
5425 +@@ -79,7 +79,7 @@ static union perf_event *dup_event(struct ordered_events *oe,
5426 +
5427 + static void free_dup_event(struct ordered_events *oe, union perf_event *event)
5428 + {
5429 +- if (oe->copy_on_queue) {
5430 ++ if (event && oe->copy_on_queue) {
5431 + oe->cur_alloc_size -= event->header.size;
5432 + free(event);
5433 + }
5434 +@@ -150,6 +150,7 @@ void ordered_events__delete(struct ordered_events *oe, struct ordered_event *eve
5435 + list_move(&event->list, &oe->cache);
5436 + oe->nr_events--;
5437 + free_dup_event(oe, event->event);
5438 ++ event->event = NULL;
5439 + }
5440 +
5441 + int ordered_events__queue(struct ordered_events *oe, union perf_event *event,
5442 +diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
5443 +index 468de95bc8bb..0ae4f73dc8eb 100644
5444 +--- a/tools/perf/util/session.c
5445 ++++ b/tools/perf/util/session.c
5446 +@@ -135,8 +135,14 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
5447 + if (perf_session__open(session) < 0)
5448 + goto out_close;
5449 +
5450 +- perf_session__set_id_hdr_size(session);
5451 +- perf_session__set_comm_exec(session);
5452 ++ /*
5453 ++ * set session attributes that are present in perf.data
5454 ++ * but not in pipe-mode.
5455 ++ */
5456 ++ if (!file->is_pipe) {
5457 ++ perf_session__set_id_hdr_size(session);
5458 ++ perf_session__set_comm_exec(session);
5459 ++ }
5460 + }
5461 + } else {
5462 + session->machines.host.env = &perf_env;
5463 +@@ -151,7 +157,11 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
5464 + pr_warning("Cannot read kernel map\n");
5465 + }
5466 +
5467 +- if (tool && tool->ordering_requires_timestamps &&
5468 ++ /*
5469 ++ * In pipe-mode, evlist is empty until PERF_RECORD_HEADER_ATTR is
5470 ++ * processed, so perf_evlist__sample_id_all is not meaningful here.
5471 ++ */
5472 ++ if ((!file || !file->is_pipe) && tool && tool->ordering_requires_timestamps &&
5473 + tool->ordered_events && !perf_evlist__sample_id_all(session->evlist)) {
5474 + dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n");
5475 + tool->ordered_events = false;
5476 +@@ -1437,6 +1447,7 @@ static int __perf_session__process_pipe_events(struct perf_session *session)
5477 + buf = malloc(cur_size);
5478 + if (!buf)
5479 + return -errno;
5480 ++ ordered_events__set_copy_on_queue(oe, true);
5481 + more:
5482 + event = buf;
5483 + err = readn(fd, event, sizeof(struct perf_event_header));
5484 +diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
5485 +index 2d8ccd4d9e1b..87312056f75d 100644
5486 +--- a/tools/perf/util/sort.c
5487 ++++ b/tools/perf/util/sort.c
5488 +@@ -604,6 +604,9 @@ static int hist_entry__mispredict_snprintf(struct hist_entry *he, char *bf,
5489 + static int64_t
5490 + sort__cycles_cmp(struct hist_entry *left, struct hist_entry *right)
5491 + {
5492 ++ if (!left->branch_info || !right->branch_info)
5493 ++ return cmp_null(left->branch_info, right->branch_info);
5494 ++
5495 + return left->branch_info->flags.cycles -
5496 + right->branch_info->flags.cycles;
5497 + }
5498 +@@ -611,6 +614,8 @@ sort__cycles_cmp(struct hist_entry *left, struct hist_entry *right)
5499 + static int hist_entry__cycles_snprintf(struct hist_entry *he, char *bf,
5500 + size_t size, unsigned int width)
5501 + {
5502 ++ if (!he->branch_info)
5503 ++ return scnprintf(bf, size, "%-.*s", width, "N/A");
5504 + if (he->branch_info->flags.cycles == 0)
5505 + return repsep_snprintf(bf, size, "%-*s", width, "-");
5506 + return repsep_snprintf(bf, size, "%-*hd", width,
5507 +diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh
5508 +index 856a1f327b3f..61f9b1dbbd9b 100755
5509 +--- a/tools/testing/selftests/firmware/fw_filesystem.sh
5510 ++++ b/tools/testing/selftests/firmware/fw_filesystem.sh
5511 +@@ -28,7 +28,10 @@ test_finish()
5512 + if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
5513 + echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout
5514 + fi
5515 +- echo -n "$OLD_PATH" >/sys/module/firmware_class/parameters/path
5516 ++ if [ "$OLD_FWPATH" = "" ]; then
5517 ++ OLD_FWPATH=" "
5518 ++ fi
5519 ++ echo -n "$OLD_FWPATH" >/sys/module/firmware_class/parameters/path
5520 + rm -f "$FW"
5521 + rmdir "$FWPATH"
5522 + }
5523 +diff --git a/tools/testing/selftests/rcutorture/bin/configinit.sh b/tools/testing/selftests/rcutorture/bin/configinit.sh
5524 +index 3f81a1095206..50a6371b2b2e 100755
5525 +--- a/tools/testing/selftests/rcutorture/bin/configinit.sh
5526 ++++ b/tools/testing/selftests/rcutorture/bin/configinit.sh
5527 +@@ -51,7 +51,7 @@ then
5528 + mkdir $builddir
5529 + fi
5530 + else
5531 +- echo Bad build directory: \"$builddir\"
5532 ++ echo Bad build directory: \"$buildloc\"
5533 + exit 2
5534 + fi
5535 + fi
5536 +diff --git a/tools/testing/selftests/x86/entry_from_vm86.c b/tools/testing/selftests/x86/entry_from_vm86.c
5537 +index d075ea0e5ca1..ade443a88421 100644
5538 +--- a/tools/testing/selftests/x86/entry_from_vm86.c
5539 ++++ b/tools/testing/selftests/x86/entry_from_vm86.c
5540 +@@ -95,6 +95,31 @@ asm (
5541 + "int3\n\t"
5542 + "vmcode_int80:\n\t"
5543 + "int $0x80\n\t"
5544 ++ "vmcode_popf_hlt:\n\t"
5545 ++ "push %ax\n\t"
5546 ++ "popf\n\t"
5547 ++ "hlt\n\t"
5548 ++ "vmcode_umip:\n\t"
5549 ++ /* addressing via displacements */
5550 ++ "smsw (2052)\n\t"
5551 ++ "sidt (2054)\n\t"
5552 ++ "sgdt (2060)\n\t"
5553 ++ /* addressing via registers */
5554 ++ "mov $2066, %bx\n\t"
5555 ++ "smsw (%bx)\n\t"
5556 ++ "mov $2068, %bx\n\t"
5557 ++ "sidt (%bx)\n\t"
5558 ++ "mov $2074, %bx\n\t"
5559 ++ "sgdt (%bx)\n\t"
5560 ++ /* register operands, only for smsw */
5561 ++ "smsw %ax\n\t"
5562 ++ "mov %ax, (2080)\n\t"
5563 ++ "int3\n\t"
5564 ++ "vmcode_umip_str:\n\t"
5565 ++ "str %eax\n\t"
5566 ++ "vmcode_umip_sldt:\n\t"
5567 ++ "sldt %eax\n\t"
5568 ++ "int3\n\t"
5569 + ".size vmcode, . - vmcode\n\t"
5570 + "end_vmcode:\n\t"
5571 + ".code32\n\t"
5572 +@@ -103,7 +128,8 @@ asm (
5573 +
5574 + extern unsigned char vmcode[], end_vmcode[];
5575 + extern unsigned char vmcode_bound[], vmcode_sysenter[], vmcode_syscall[],
5576 +- vmcode_sti[], vmcode_int3[], vmcode_int80[];
5577 ++ vmcode_sti[], vmcode_int3[], vmcode_int80[], vmcode_popf_hlt[],
5578 ++ vmcode_umip[], vmcode_umip_str[], vmcode_umip_sldt[];
5579 +
5580 + /* Returns false if the test was skipped. */
5581 + static bool do_test(struct vm86plus_struct *v86, unsigned long eip,
5582 +@@ -153,13 +179,75 @@ static bool do_test(struct vm86plus_struct *v86, unsigned long eip,
5583 + (VM86_TYPE(ret) == rettype && VM86_ARG(ret) == retarg)) {
5584 + printf("[OK]\tReturned correctly\n");
5585 + } else {
5586 +- printf("[FAIL]\tIncorrect return reason\n");
5587 ++ printf("[FAIL]\tIncorrect return reason (started at eip = 0x%lx, ended at eip = 0x%lx)\n", eip, v86->regs.eip);
5588 + nerrs++;
5589 + }
5590 +
5591 + return true;
5592 + }
5593 +
5594 ++void do_umip_tests(struct vm86plus_struct *vm86, unsigned char *test_mem)
5595 ++{
5596 ++ struct table_desc {
5597 ++ unsigned short limit;
5598 ++ unsigned long base;
5599 ++ } __attribute__((packed));
5600 ++
5601 ++ /* Initialize variables with arbitrary values */
5602 ++ struct table_desc gdt1 = { .base = 0x3c3c3c3c, .limit = 0x9999 };
5603 ++ struct table_desc gdt2 = { .base = 0x1a1a1a1a, .limit = 0xaeae };
5604 ++ struct table_desc idt1 = { .base = 0x7b7b7b7b, .limit = 0xf1f1 };
5605 ++ struct table_desc idt2 = { .base = 0x89898989, .limit = 0x1313 };
5606 ++ unsigned short msw1 = 0x1414, msw2 = 0x2525, msw3 = 3737;
5607 ++
5608 ++ /* UMIP -- exit with INT3 unless kernel emulation did not trap #GP */
5609 ++ do_test(vm86, vmcode_umip - vmcode, VM86_TRAP, 3, "UMIP tests");
5610 ++
5611 ++ /* Results from displacement-only addressing */
5612 ++ msw1 = *(unsigned short *)(test_mem + 2052);
5613 ++ memcpy(&idt1, test_mem + 2054, sizeof(idt1));
5614 ++ memcpy(&gdt1, test_mem + 2060, sizeof(gdt1));
5615 ++
5616 ++ /* Results from register-indirect addressing */
5617 ++ msw2 = *(unsigned short *)(test_mem + 2066);
5618 ++ memcpy(&idt2, test_mem + 2068, sizeof(idt2));
5619 ++ memcpy(&gdt2, test_mem + 2074, sizeof(gdt2));
5620 ++
5621 ++ /* Results when using register operands */
5622 ++ msw3 = *(unsigned short *)(test_mem + 2080);
5623 ++
5624 ++ printf("[INFO]\tResult from SMSW:[0x%04x]\n", msw1);
5625 ++ printf("[INFO]\tResult from SIDT: limit[0x%04x]base[0x%08lx]\n",
5626 ++ idt1.limit, idt1.base);
5627 ++ printf("[INFO]\tResult from SGDT: limit[0x%04x]base[0x%08lx]\n",
5628 ++ gdt1.limit, gdt1.base);
5629 ++
5630 ++ if (msw1 != msw2 || msw1 != msw3)
5631 ++ printf("[FAIL]\tAll the results of SMSW should be the same.\n");
5632 ++ else
5633 ++ printf("[PASS]\tAll the results from SMSW are identical.\n");
5634 ++
5635 ++ if (memcmp(&gdt1, &gdt2, sizeof(gdt1)))
5636 ++ printf("[FAIL]\tAll the results of SGDT should be the same.\n");
5637 ++ else
5638 ++ printf("[PASS]\tAll the results from SGDT are identical.\n");
5639 ++
5640 ++ if (memcmp(&idt1, &idt2, sizeof(idt1)))
5641 ++ printf("[FAIL]\tAll the results of SIDT should be the same.\n");
5642 ++ else
5643 ++ printf("[PASS]\tAll the results from SIDT are identical.\n");
5644 ++
5645 ++ sethandler(SIGILL, sighandler, 0);
5646 ++ do_test(vm86, vmcode_umip_str - vmcode, VM86_SIGNAL, 0,
5647 ++ "STR instruction");
5648 ++ clearhandler(SIGILL);
5649 ++
5650 ++ sethandler(SIGILL, sighandler, 0);
5651 ++ do_test(vm86, vmcode_umip_sldt - vmcode, VM86_SIGNAL, 0,
5652 ++ "SLDT instruction");
5653 ++ clearhandler(SIGILL);
5654 ++}
5655 ++
5656 + int main(void)
5657 + {
5658 + struct vm86plus_struct v86;
5659 +@@ -180,6 +268,9 @@ int main(void)
5660 + v86.regs.ds = load_addr / 16;
5661 + v86.regs.es = load_addr / 16;
5662 +
5663 ++ /* Use the end of the page as our stack. */
5664 ++ v86.regs.esp = 4096;
5665 ++
5666 + assert((v86.regs.cs & 3) == 0); /* Looks like RPL = 0 */
5667 +
5668 + /* #BR -- should deliver SIG??? */
5669 +@@ -211,6 +302,23 @@ int main(void)
5670 + v86.regs.eflags &= ~X86_EFLAGS_IF;
5671 + do_test(&v86, vmcode_sti - vmcode, VM86_STI, 0, "STI with VIP set");
5672 +
5673 ++ /* POPF with VIP set but IF clear: should not trap */
5674 ++ v86.regs.eflags = X86_EFLAGS_VIP;
5675 ++ v86.regs.eax = 0;
5676 ++ do_test(&v86, vmcode_popf_hlt - vmcode, VM86_UNKNOWN, 0, "POPF with VIP set and IF clear");
5677 ++
5678 ++ /* POPF with VIP set and IF set: should trap */
5679 ++ v86.regs.eflags = X86_EFLAGS_VIP;
5680 ++ v86.regs.eax = X86_EFLAGS_IF;
5681 ++ do_test(&v86, vmcode_popf_hlt - vmcode, VM86_STI, 0, "POPF with VIP and IF set");
5682 ++
5683 ++ /* POPF with VIP clear and IF set: should not trap */
5684 ++ v86.regs.eflags = 0;
5685 ++ v86.regs.eax = X86_EFLAGS_IF;
5686 ++ do_test(&v86, vmcode_popf_hlt - vmcode, VM86_UNKNOWN, 0, "POPF with VIP clear and IF set");
5687 ++
5688 ++ v86.regs.eflags = 0;
5689 ++
5690 + /* INT3 -- should cause #BP */
5691 + do_test(&v86, vmcode_int3 - vmcode, VM86_TRAP, 3, "INT3");
5692 +
5693 +@@ -218,6 +326,9 @@ int main(void)
5694 + v86.regs.eax = (unsigned int)-1;
5695 + do_test(&v86, vmcode_int80 - vmcode, VM86_INTx, 0x80, "int80");
5696 +
5697 ++ /* UMIP -- should exit with INTx 0x80 unless UMIP was not disabled */
5698 ++ do_umip_tests(&v86, addr);
5699 ++
5700 + /* Execute a null pointer */
5701 + v86.regs.cs = 0;
5702 + v86.regs.ss = 0;
5703 +@@ -231,7 +342,7 @@ int main(void)
5704 + clearhandler(SIGSEGV);
5705 +
5706 + /* Make sure nothing explodes if we fork. */
5707 +- if (fork() > 0)
5708 ++ if (fork() == 0)
5709 + return 0;
5710 +
5711 + return (nerrs == 0 ? 0 : 1);
5712 +diff --git a/tools/usb/usbip/src/usbipd.c b/tools/usb/usbip/src/usbipd.c
5713 +index 2a7cd2b8d966..8c5b0faba229 100644
5714 +--- a/tools/usb/usbip/src/usbipd.c
5715 ++++ b/tools/usb/usbip/src/usbipd.c
5716 +@@ -451,7 +451,7 @@ static void set_signal(void)
5717 + sigaction(SIGTERM, &act, NULL);
5718 + sigaction(SIGINT, &act, NULL);
5719 + act.sa_handler = SIG_IGN;
5720 +- sigaction(SIGCLD, &act, NULL);
5721 ++ sigaction(SIGCHLD, &act, NULL);
5722 + }
5723 +
5724 + static const char *pid_file;