Magellan Linux

Contents of /trunk/kernel-magellan/patches-4.8/0112-4.8.13-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2852 - (show annotations) (download)
Fri Jan 6 09:45:18 2017 UTC (7 years, 4 months ago) by niro
File size: 34958 byte(s)
-linux-4.8.13
1 diff --git a/Makefile b/Makefile
2 index 7b0c92f53169..b38abe9adef8 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 4
7 PATCHLEVEL = 8
8 -SUBLEVEL = 12
9 +SUBLEVEL = 13
10 EXTRAVERSION =
11 NAME = Psychotic Stoned Sheep
12
13 diff --git a/arch/arc/include/asm/delay.h b/arch/arc/include/asm/delay.h
14 index 08e7e2a16ac1..a36e8601114d 100644
15 --- a/arch/arc/include/asm/delay.h
16 +++ b/arch/arc/include/asm/delay.h
17 @@ -22,10 +22,11 @@
18 static inline void __delay(unsigned long loops)
19 {
20 __asm__ __volatile__(
21 - " lp 1f \n"
22 - " nop \n"
23 - "1: \n"
24 - : "+l"(loops));
25 + " mov lp_count, %0 \n"
26 + " lp 1f \n"
27 + " nop \n"
28 + "1: \n"
29 + : : "r"(loops));
30 }
31
32 extern void __bad_udelay(void);
33 diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
34 index 89eeb3720051..e94ca72b974e 100644
35 --- a/arch/arc/include/asm/pgtable.h
36 +++ b/arch/arc/include/asm/pgtable.h
37 @@ -280,7 +280,7 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep)
38
39 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
40 #define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot)
41 -#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
42 +#define pfn_pte(pfn, prot) __pte(__pfn_to_phys(pfn) | pgprot_val(prot))
43
44 /* Don't use virt_to_pfn for macros below: could cause truncations for PAE40*/
45 #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT)
46 diff --git a/arch/arm64/boot/dts/arm/juno-r1.dts b/arch/arm64/boot/dts/arm/juno-r1.dts
47 index 123a58b29cbd..f0b857d6d73c 100644
48 --- a/arch/arm64/boot/dts/arm/juno-r1.dts
49 +++ b/arch/arm64/boot/dts/arm/juno-r1.dts
50 @@ -76,7 +76,7 @@
51 compatible = "arm,idle-state";
52 arm,psci-suspend-param = <0x1010000>;
53 local-timer-stop;
54 - entry-latency-us = <300>;
55 + entry-latency-us = <400>;
56 exit-latency-us = <1200>;
57 min-residency-us = <2500>;
58 };
59 diff --git a/arch/arm64/boot/dts/arm/juno-r2.dts b/arch/arm64/boot/dts/arm/juno-r2.dts
60 index 007be826efce..26aaa6a7670f 100644
61 --- a/arch/arm64/boot/dts/arm/juno-r2.dts
62 +++ b/arch/arm64/boot/dts/arm/juno-r2.dts
63 @@ -76,7 +76,7 @@
64 compatible = "arm,idle-state";
65 arm,psci-suspend-param = <0x1010000>;
66 local-timer-stop;
67 - entry-latency-us = <300>;
68 + entry-latency-us = <400>;
69 exit-latency-us = <1200>;
70 min-residency-us = <2500>;
71 };
72 diff --git a/arch/arm64/boot/dts/arm/juno.dts b/arch/arm64/boot/dts/arm/juno.dts
73 index a7270eff6939..6e154d948a80 100644
74 --- a/arch/arm64/boot/dts/arm/juno.dts
75 +++ b/arch/arm64/boot/dts/arm/juno.dts
76 @@ -76,7 +76,7 @@
77 compatible = "arm,idle-state";
78 arm,psci-suspend-param = <0x1010000>;
79 local-timer-stop;
80 - entry-latency-us = <300>;
81 + entry-latency-us = <400>;
82 exit-latency-us = <1200>;
83 min-residency-us = <2500>;
84 };
85 diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
86 index 7099f26e3702..b96346b943b7 100644
87 --- a/arch/arm64/include/asm/cpufeature.h
88 +++ b/arch/arm64/include/asm/cpufeature.h
89 @@ -90,7 +90,7 @@ struct arm64_cpu_capabilities {
90 u16 capability;
91 int def_scope; /* default scope */
92 bool (*matches)(const struct arm64_cpu_capabilities *caps, int scope);
93 - void (*enable)(void *); /* Called on all active CPUs */
94 + int (*enable)(void *); /* Called on all active CPUs */
95 union {
96 struct { /* To be used for erratum handling only */
97 u32 midr_model;
98 diff --git a/arch/arm64/include/asm/exec.h b/arch/arm64/include/asm/exec.h
99 index db0563c23482..f7865dd9d868 100644
100 --- a/arch/arm64/include/asm/exec.h
101 +++ b/arch/arm64/include/asm/exec.h
102 @@ -18,6 +18,9 @@
103 #ifndef __ASM_EXEC_H
104 #define __ASM_EXEC_H
105
106 +#include <linux/sched.h>
107 +
108 extern unsigned long arch_align_stack(unsigned long sp);
109 +void uao_thread_switch(struct task_struct *next);
110
111 #endif /* __ASM_EXEC_H */
112 diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
113 index ace0a96e7d6e..3be0ab013e35 100644
114 --- a/arch/arm64/include/asm/processor.h
115 +++ b/arch/arm64/include/asm/processor.h
116 @@ -190,8 +190,8 @@ static inline void spin_lock_prefetch(const void *ptr)
117
118 #endif
119
120 -void cpu_enable_pan(void *__unused);
121 -void cpu_enable_uao(void *__unused);
122 -void cpu_enable_cache_maint_trap(void *__unused);
123 +int cpu_enable_pan(void *__unused);
124 +int cpu_enable_uao(void *__unused);
125 +int cpu_enable_cache_maint_trap(void *__unused);
126
127 #endif /* __ASM_PROCESSOR_H */
128 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
129 index 62272eac1352..94a0330f7ec9 100644
130 --- a/arch/arm64/kernel/cpufeature.c
131 +++ b/arch/arm64/kernel/cpufeature.c
132 @@ -19,7 +19,9 @@
133 #define pr_fmt(fmt) "CPU features: " fmt
134
135 #include <linux/bsearch.h>
136 +#include <linux/cpumask.h>
137 #include <linux/sort.h>
138 +#include <linux/stop_machine.h>
139 #include <linux/types.h>
140 #include <asm/cpu.h>
141 #include <asm/cpufeature.h>
142 @@ -936,7 +938,13 @@ void __init enable_cpu_capabilities(const struct arm64_cpu_capabilities *caps)
143 {
144 for (; caps->matches; caps++)
145 if (caps->enable && cpus_have_cap(caps->capability))
146 - on_each_cpu(caps->enable, NULL, true);
147 + /*
148 + * Use stop_machine() as it schedules the work allowing
149 + * us to modify PSTATE, instead of on_each_cpu() which
150 + * uses an IPI, giving us a PSTATE that disappears when
151 + * we return.
152 + */
153 + stop_machine(caps->enable, NULL, cpu_online_mask);
154 }
155
156 /*
157 diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
158 index 6cd2612236dc..9cc8667212a6 100644
159 --- a/arch/arm64/kernel/process.c
160 +++ b/arch/arm64/kernel/process.c
161 @@ -49,6 +49,7 @@
162 #include <asm/alternative.h>
163 #include <asm/compat.h>
164 #include <asm/cacheflush.h>
165 +#include <asm/exec.h>
166 #include <asm/fpsimd.h>
167 #include <asm/mmu_context.h>
168 #include <asm/processor.h>
169 @@ -303,7 +304,7 @@ static void tls_thread_switch(struct task_struct *next)
170 }
171
172 /* Restore the UAO state depending on next's addr_limit */
173 -static void uao_thread_switch(struct task_struct *next)
174 +void uao_thread_switch(struct task_struct *next)
175 {
176 if (IS_ENABLED(CONFIG_ARM64_UAO)) {
177 if (task_thread_info(next)->addr_limit == KERNEL_DS)
178 diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c
179 index b616e365cee3..23ddf5500b09 100644
180 --- a/arch/arm64/kernel/suspend.c
181 +++ b/arch/arm64/kernel/suspend.c
182 @@ -1,8 +1,11 @@
183 #include <linux/ftrace.h>
184 #include <linux/percpu.h>
185 #include <linux/slab.h>
186 +#include <asm/alternative.h>
187 #include <asm/cacheflush.h>
188 +#include <asm/cpufeature.h>
189 #include <asm/debug-monitors.h>
190 +#include <asm/exec.h>
191 #include <asm/pgtable.h>
192 #include <asm/memory.h>
193 #include <asm/mmu_context.h>
194 @@ -48,6 +51,14 @@ void notrace __cpu_suspend_exit(void)
195 set_my_cpu_offset(per_cpu_offset(smp_processor_id()));
196
197 /*
198 + * PSTATE was not saved over suspend/resume, re-enable any detected
199 + * features that might not have been set correctly.
200 + */
201 + asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,
202 + CONFIG_ARM64_PAN));
203 + uao_thread_switch(current);
204 +
205 + /*
206 * Restore HW breakpoint registers to sane values
207 * before debug exceptions are possibly reenabled
208 * through local_dbg_restore.
209 diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
210 index 771a01a7fbce..9595d3d9c3db 100644
211 --- a/arch/arm64/kernel/traps.c
212 +++ b/arch/arm64/kernel/traps.c
213 @@ -428,9 +428,10 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
214 force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0);
215 }
216
217 -void cpu_enable_cache_maint_trap(void *__unused)
218 +int cpu_enable_cache_maint_trap(void *__unused)
219 {
220 config_sctlr_el1(SCTLR_EL1_UCI, 0);
221 + return 0;
222 }
223
224 #define __user_cache_maint(insn, address, res) \
225 diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
226 index 05d2bd776c69..67506c3c5476 100644
227 --- a/arch/arm64/mm/fault.c
228 +++ b/arch/arm64/mm/fault.c
229 @@ -29,7 +29,9 @@
230 #include <linux/sched.h>
231 #include <linux/highmem.h>
232 #include <linux/perf_event.h>
233 +#include <linux/preempt.h>
234
235 +#include <asm/bug.h>
236 #include <asm/cpufeature.h>
237 #include <asm/exception.h>
238 #include <asm/debug-monitors.h>
239 @@ -671,9 +673,17 @@ asmlinkage int __exception do_debug_exception(unsigned long addr,
240 NOKPROBE_SYMBOL(do_debug_exception);
241
242 #ifdef CONFIG_ARM64_PAN
243 -void cpu_enable_pan(void *__unused)
244 +int cpu_enable_pan(void *__unused)
245 {
246 + /*
247 + * We modify PSTATE. This won't work from irq context as the PSTATE
248 + * is discarded once we return from the exception.
249 + */
250 + WARN_ON_ONCE(in_interrupt());
251 +
252 config_sctlr_el1(SCTLR_EL1_SPAN, 0);
253 + asm(SET_PSTATE_PAN(1));
254 + return 0;
255 }
256 #endif /* CONFIG_ARM64_PAN */
257
258 @@ -684,8 +694,9 @@ void cpu_enable_pan(void *__unused)
259 * We need to enable the feature at runtime (instead of adding it to
260 * PSR_MODE_EL1h) as the feature may not be implemented by the cpu.
261 */
262 -void cpu_enable_uao(void *__unused)
263 +int cpu_enable_uao(void *__unused)
264 {
265 asm(SET_PSTATE_UAO(1));
266 + return 0;
267 }
268 #endif /* CONFIG_ARM64_UAO */
269 diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
270 index d0efb5cb1b00..a4e070a51584 100644
271 --- a/arch/x86/events/core.c
272 +++ b/arch/x86/events/core.c
273 @@ -2344,7 +2344,7 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *ent
274 frame.next_frame = 0;
275 frame.return_address = 0;
276
277 - if (!access_ok(VERIFY_READ, fp, 8))
278 + if (!valid_user_frame(fp, sizeof(frame)))
279 break;
280
281 bytes = __copy_from_user_nmi(&frame.next_frame, fp, 4);
282 @@ -2354,9 +2354,6 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *ent
283 if (bytes != 0)
284 break;
285
286 - if (!valid_user_frame(fp, sizeof(frame)))
287 - break;
288 -
289 perf_callchain_store(entry, cs_base + frame.return_address);
290 fp = compat_ptr(ss_base + frame.next_frame);
291 }
292 @@ -2405,7 +2402,7 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs
293 frame.next_frame = NULL;
294 frame.return_address = 0;
295
296 - if (!access_ok(VERIFY_READ, fp, sizeof(*fp) * 2))
297 + if (!valid_user_frame(fp, sizeof(frame)))
298 break;
299
300 bytes = __copy_from_user_nmi(&frame.next_frame, fp, sizeof(*fp));
301 @@ -2415,9 +2412,6 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs
302 if (bytes != 0)
303 break;
304
305 - if (!valid_user_frame(fp, sizeof(frame)))
306 - break;
307 -
308 perf_callchain_store(entry, frame.return_address);
309 fp = (void __user *)frame.next_frame;
310 }
311 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
312 index e207b33e4ce9..1e007a93bdcc 100644
313 --- a/drivers/ata/libata-scsi.c
314 +++ b/drivers/ata/libata-scsi.c
315 @@ -1088,7 +1088,7 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
316 desc[1] = tf->command; /* status */
317 desc[2] = tf->device;
318 desc[3] = tf->nsect;
319 - desc[0] = 0;
320 + desc[7] = 0;
321 if (tf->flags & ATA_TFLAG_LBA48) {
322 desc[8] |= 0x80;
323 if (tf->hob_nsect)
324 diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
325 index 04365b17ee67..5163c8f918cb 100644
326 --- a/drivers/block/zram/zram_drv.c
327 +++ b/drivers/block/zram/zram_drv.c
328 @@ -1403,7 +1403,8 @@ static ssize_t hot_remove_store(struct class *class,
329 zram = idr_find(&zram_index_idr, dev_id);
330 if (zram) {
331 ret = zram_remove(zram);
332 - idr_remove(&zram_index_idr, dev_id);
333 + if (!ret)
334 + idr_remove(&zram_index_idr, dev_id);
335 } else {
336 ret = -ENODEV;
337 }
338 diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
339 index 838b22aa8b67..f2c9274b8bd5 100644
340 --- a/drivers/clk/sunxi/clk-sunxi.c
341 +++ b/drivers/clk/sunxi/clk-sunxi.c
342 @@ -373,7 +373,7 @@ static void sun4i_get_apb1_factors(struct factors_request *req)
343 else
344 calcp = 3;
345
346 - calcm = (req->parent_rate >> calcp) - 1;
347 + calcm = (div >> calcp) - 1;
348
349 req->rate = (req->parent_rate >> calcp) / (calcm + 1);
350 req->m = calcm;
351 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
352 index 10b5ddf2c588..1ed085f01a49 100644
353 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
354 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
355 @@ -33,6 +33,7 @@ struct amdgpu_atpx {
356
357 static struct amdgpu_atpx_priv {
358 bool atpx_detected;
359 + bool bridge_pm_usable;
360 /* handle for device - and atpx */
361 acpi_handle dhandle;
362 acpi_handle other_handle;
363 @@ -200,7 +201,11 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
364 atpx->is_hybrid = false;
365 if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
366 printk("ATPX Hybrid Graphics\n");
367 - atpx->functions.power_cntl = false;
368 + /*
369 + * Disable legacy PM methods only when pcie port PM is usable,
370 + * otherwise the device might fail to power off or power on.
371 + */
372 + atpx->functions.power_cntl = !amdgpu_atpx_priv.bridge_pm_usable;
373 atpx->is_hybrid = true;
374 }
375
376 @@ -546,17 +551,25 @@ static bool amdgpu_atpx_detect(void)
377 struct pci_dev *pdev = NULL;
378 bool has_atpx = false;
379 int vga_count = 0;
380 + bool d3_supported = false;
381 + struct pci_dev *parent_pdev;
382
383 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
384 vga_count++;
385
386 has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true);
387 +
388 + parent_pdev = pci_upstream_bridge(pdev);
389 + d3_supported |= parent_pdev && parent_pdev->bridge_d3;
390 }
391
392 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
393 vga_count++;
394
395 has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true);
396 +
397 + parent_pdev = pci_upstream_bridge(pdev);
398 + d3_supported |= parent_pdev && parent_pdev->bridge_d3;
399 }
400
401 if (has_atpx && vga_count == 2) {
402 @@ -564,6 +577,7 @@ static bool amdgpu_atpx_detect(void)
403 printk(KERN_INFO "vga_switcheroo: detected switching method %s handle\n",
404 acpi_method_name);
405 amdgpu_atpx_priv.atpx_detected = true;
406 + amdgpu_atpx_priv.bridge_pm_usable = d3_supported;
407 amdgpu_atpx_init();
408 return true;
409 }
410 diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
411 index a77ce9983f69..b8e3854a1f20 100644
412 --- a/drivers/gpu/drm/i915/i915_gem.c
413 +++ b/drivers/gpu/drm/i915/i915_gem.c
414 @@ -2540,7 +2540,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
415 page = shmem_read_mapping_page(mapping, i);
416 if (IS_ERR(page)) {
417 ret = PTR_ERR(page);
418 - goto err_pages;
419 + goto err_sg;
420 }
421 }
422 #ifdef CONFIG_SWIOTLB
423 @@ -2583,8 +2583,9 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
424
425 return 0;
426
427 -err_pages:
428 +err_sg:
429 sg_mark_end(sg);
430 +err_pages:
431 for_each_sgt_page(page, sgt_iter, st)
432 put_page(page);
433 sg_free_table(st);
434 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
435 index e26f88965c58..35d385d70d8e 100644
436 --- a/drivers/gpu/drm/i915/intel_display.c
437 +++ b/drivers/gpu/drm/i915/intel_display.c
438 @@ -11791,7 +11791,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
439 intel_crtc->reset_counter = i915_reset_counter(&dev_priv->gpu_error);
440 if (__i915_reset_in_progress_or_wedged(intel_crtc->reset_counter)) {
441 ret = -EIO;
442 - goto cleanup;
443 + goto unlock;
444 }
445
446 atomic_inc(&intel_crtc->unpin_work_count);
447 @@ -11877,6 +11877,7 @@ cleanup_pending:
448 if (!IS_ERR_OR_NULL(request))
449 i915_add_request_no_flush(request);
450 atomic_dec(&intel_crtc->unpin_work_count);
451 +unlock:
452 mutex_unlock(&dev->struct_mutex);
453 cleanup:
454 crtc->primary->fb = old_fb;
455 diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
456 index 8f62671fcfbf..54acfccee7eb 100644
457 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
458 +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
459 @@ -249,13 +249,6 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
460 if (irq < 0)
461 return irq;
462
463 - ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler,
464 - IRQF_TRIGGER_NONE, dev_name(dev), priv);
465 - if (ret < 0) {
466 - dev_err(dev, "Failed to request irq %d: %d\n", irq, ret);
467 - return ret;
468 - }
469 -
470 comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DISP_OVL);
471 if (comp_id < 0) {
472 dev_err(dev, "Failed to identify by alias: %d\n", comp_id);
473 @@ -271,6 +264,13 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
474
475 platform_set_drvdata(pdev, priv);
476
477 + ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler,
478 + IRQF_TRIGGER_NONE, dev_name(dev), priv);
479 + if (ret < 0) {
480 + dev_err(dev, "Failed to request irq %d: %d\n", irq, ret);
481 + return ret;
482 + }
483 +
484 ret = component_add(dev, &mtk_disp_ovl_component_ops);
485 if (ret)
486 dev_err(dev, "Failed to add component: %d\n", ret);
487 diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
488 index ddef0d494084..34b4ace5d75f 100644
489 --- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
490 +++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
491 @@ -33,6 +33,7 @@ struct radeon_atpx {
492
493 static struct radeon_atpx_priv {
494 bool atpx_detected;
495 + bool bridge_pm_usable;
496 /* handle for device - and atpx */
497 acpi_handle dhandle;
498 struct radeon_atpx atpx;
499 @@ -198,7 +199,11 @@ static int radeon_atpx_validate(struct radeon_atpx *atpx)
500 atpx->is_hybrid = false;
501 if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
502 printk("ATPX Hybrid Graphics\n");
503 - atpx->functions.power_cntl = false;
504 + /*
505 + * Disable legacy PM methods only when pcie port PM is usable,
506 + * otherwise the device might fail to power off or power on.
507 + */
508 + atpx->functions.power_cntl = !radeon_atpx_priv.bridge_pm_usable;
509 atpx->is_hybrid = true;
510 }
511
512 @@ -543,11 +548,16 @@ static bool radeon_atpx_detect(void)
513 struct pci_dev *pdev = NULL;
514 bool has_atpx = false;
515 int vga_count = 0;
516 + bool d3_supported = false;
517 + struct pci_dev *parent_pdev;
518
519 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
520 vga_count++;
521
522 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true);
523 +
524 + parent_pdev = pci_upstream_bridge(pdev);
525 + d3_supported |= parent_pdev && parent_pdev->bridge_d3;
526 }
527
528 /* some newer PX laptops mark the dGPU as a non-VGA display device */
529 @@ -555,6 +565,9 @@ static bool radeon_atpx_detect(void)
530 vga_count++;
531
532 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true);
533 +
534 + parent_pdev = pci_upstream_bridge(pdev);
535 + d3_supported |= parent_pdev && parent_pdev->bridge_d3;
536 }
537
538 if (has_atpx && vga_count == 2) {
539 @@ -562,6 +575,7 @@ static bool radeon_atpx_detect(void)
540 printk(KERN_INFO "vga_switcheroo: detected switching method %s handle\n",
541 acpi_method_name);
542 radeon_atpx_priv.atpx_detected = true;
543 + radeon_atpx_priv.bridge_pm_usable = d3_supported;
544 radeon_atpx_init();
545 return true;
546 }
547 diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
548 index 5784e20542a4..9f6203c8577c 100644
549 --- a/drivers/input/mouse/psmouse-base.c
550 +++ b/drivers/input/mouse/psmouse-base.c
551 @@ -1115,10 +1115,6 @@ static int psmouse_extensions(struct psmouse *psmouse,
552 if (psmouse_try_protocol(psmouse, PSMOUSE_TOUCHKIT_PS2,
553 &max_proto, set_properties, true))
554 return PSMOUSE_TOUCHKIT_PS2;
555 -
556 - if (psmouse_try_protocol(psmouse, PSMOUSE_BYD,
557 - &max_proto, set_properties, true))
558 - return PSMOUSE_BYD;
559 }
560
561 /*
562 diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
563 index a8ff969c95c2..cbc7dfae0a0e 100644
564 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
565 +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
566 @@ -2203,8 +2203,9 @@ done:
567 is_scanning_required = 1;
568 } else {
569 mwifiex_dbg(priv->adapter, MSG,
570 - "info: trying to associate to '%s' bssid %pM\n",
571 - (char *)req_ssid.ssid, bss->bssid);
572 + "info: trying to associate to '%.*s' bssid %pM\n",
573 + req_ssid.ssid_len, (char *)req_ssid.ssid,
574 + bss->bssid);
575 memcpy(&priv->cfg_bssid, bss->bssid, ETH_ALEN);
576 break;
577 }
578 @@ -2264,8 +2265,8 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
579 }
580
581 mwifiex_dbg(adapter, INFO,
582 - "info: Trying to associate to %s and bssid %pM\n",
583 - (char *)sme->ssid, sme->bssid);
584 + "info: Trying to associate to %.*s and bssid %pM\n",
585 + (int)sme->ssid_len, (char *)sme->ssid, sme->bssid);
586
587 if (!mwifiex_stop_bg_scan(priv))
588 cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy);
589 @@ -2398,8 +2399,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
590 }
591
592 mwifiex_dbg(priv->adapter, MSG,
593 - "info: trying to join to %s and bssid %pM\n",
594 - (char *)params->ssid, params->bssid);
595 + "info: trying to join to %.*s and bssid %pM\n",
596 + params->ssid_len, (char *)params->ssid, params->bssid);
597
598 mwifiex_set_ibss_params(priv, params);
599
600 diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c
601 index db553dc22c8e..2b6a59266689 100644
602 --- a/drivers/pci/pcie/aer/aer_inject.c
603 +++ b/drivers/pci/pcie/aer/aer_inject.c
604 @@ -307,20 +307,6 @@ out:
605 return 0;
606 }
607
608 -static struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
609 -{
610 - while (1) {
611 - if (!pci_is_pcie(dev))
612 - break;
613 - if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
614 - return dev;
615 - if (!dev->bus->self)
616 - break;
617 - dev = dev->bus->self;
618 - }
619 - return NULL;
620 -}
621 -
622 static int find_aer_device_iter(struct device *device, void *data)
623 {
624 struct pcie_device **result = data;
625 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
626 index 93f280df3428..f6eff4aaffd7 100644
627 --- a/drivers/pci/probe.c
628 +++ b/drivers/pci/probe.c
629 @@ -1439,6 +1439,21 @@ static void program_hpp_type1(struct pci_dev *dev, struct hpp_type1 *hpp)
630 dev_warn(&dev->dev, "PCI-X settings not supported\n");
631 }
632
633 +static bool pcie_root_rcb_set(struct pci_dev *dev)
634 +{
635 + struct pci_dev *rp = pcie_find_root_port(dev);
636 + u16 lnkctl;
637 +
638 + if (!rp)
639 + return false;
640 +
641 + pcie_capability_read_word(rp, PCI_EXP_LNKCTL, &lnkctl);
642 + if (lnkctl & PCI_EXP_LNKCTL_RCB)
643 + return true;
644 +
645 + return false;
646 +}
647 +
648 static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
649 {
650 int pos;
651 @@ -1468,9 +1483,20 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
652 ~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or);
653
654 /* Initialize Link Control Register */
655 - if (pcie_cap_has_lnkctl(dev))
656 + if (pcie_cap_has_lnkctl(dev)) {
657 +
658 + /*
659 + * If the Root Port supports Read Completion Boundary of
660 + * 128, set RCB to 128. Otherwise, clear it.
661 + */
662 + hpp->pci_exp_lnkctl_and |= PCI_EXP_LNKCTL_RCB;
663 + hpp->pci_exp_lnkctl_or &= ~PCI_EXP_LNKCTL_RCB;
664 + if (pcie_root_rcb_set(dev))
665 + hpp->pci_exp_lnkctl_or |= PCI_EXP_LNKCTL_RCB;
666 +
667 pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL,
668 ~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or);
669 + }
670
671 /* Find Advanced Error Reporting Enhanced Capability */
672 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
673 diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c
674 index 0296d8178ae2..a813239300c3 100644
675 --- a/drivers/pwm/sysfs.c
676 +++ b/drivers/pwm/sysfs.c
677 @@ -425,6 +425,8 @@ void pwmchip_sysfs_unexport_children(struct pwm_chip *chip)
678 if (test_bit(PWMF_EXPORTED, &pwm->flags))
679 pwm_unexport_child(parent, pwm);
680 }
681 +
682 + put_device(parent);
683 }
684
685 static int __init pwm_sysfs_init(void)
686 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
687 index 030d0023e1d2..5138a841ff4f 100644
688 --- a/drivers/scsi/hpsa.c
689 +++ b/drivers/scsi/hpsa.c
690 @@ -2007,7 +2007,7 @@ static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h,
691
692 static int hpsa_slave_alloc(struct scsi_device *sdev)
693 {
694 - struct hpsa_scsi_dev_t *sd;
695 + struct hpsa_scsi_dev_t *sd = NULL;
696 unsigned long flags;
697 struct ctlr_info *h;
698
699 @@ -2024,7 +2024,8 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
700 sd->target = sdev_id(sdev);
701 sd->lun = sdev->lun;
702 }
703 - } else
704 + }
705 + if (!sd)
706 sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
707 sdev_id(sdev), sdev->lun);
708
709 @@ -3805,6 +3806,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
710 sizeof(this_device->vendor));
711 memcpy(this_device->model, &inq_buff[16],
712 sizeof(this_device->model));
713 + this_device->rev = inq_buff[2];
714 memset(this_device->device_id, 0,
715 sizeof(this_device->device_id));
716 hpsa_get_device_id(h, scsi3addr, this_device->device_id, 8,
717 @@ -3887,10 +3889,14 @@ static void figure_bus_target_lun(struct ctlr_info *h,
718
719 if (!is_logical_dev_addr_mode(lunaddrbytes)) {
720 /* physical device, target and lun filled in later */
721 - if (is_hba_lunid(lunaddrbytes))
722 + if (is_hba_lunid(lunaddrbytes)) {
723 + int bus = HPSA_HBA_BUS;
724 +
725 + if (!device->rev)
726 + bus = HPSA_LEGACY_HBA_BUS;
727 hpsa_set_bus_target_lun(device,
728 - HPSA_HBA_BUS, 0, lunid & 0x3fff);
729 - else
730 + bus, 0, lunid & 0x3fff);
731 + } else
732 /* defer target, lun assignment for physical devices */
733 hpsa_set_bus_target_lun(device,
734 HPSA_PHYSICAL_DEVICE_BUS, -1, -1);
735 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
736 index a1487e67f7a1..9d45dde5747f 100644
737 --- a/drivers/scsi/hpsa.h
738 +++ b/drivers/scsi/hpsa.h
739 @@ -69,6 +69,7 @@ struct hpsa_scsi_dev_t {
740 u64 sas_address;
741 unsigned char vendor[8]; /* bytes 8-15 of inquiry data */
742 unsigned char model[16]; /* bytes 16-31 of inquiry data */
743 + unsigned char rev; /* byte 2 of inquiry data */
744 unsigned char raid_level; /* from inquiry page 0xC1 */
745 unsigned char volume_offline; /* discovered via TUR or VPD */
746 u16 queue_depth; /* max queue_depth for this device */
747 @@ -403,6 +404,7 @@ struct offline_device_entry {
748 #define HPSA_RAID_VOLUME_BUS 1
749 #define HPSA_EXTERNAL_RAID_VOLUME_BUS 2
750 #define HPSA_HBA_BUS 0
751 +#define HPSA_LEGACY_HBA_BUS 3
752
753 /*
754 Send the command to the hardware
755 diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
756 index 04ce7cfb6d1b..50c71678a156 100644
757 --- a/drivers/scsi/libfc/fc_lport.c
758 +++ b/drivers/scsi/libfc/fc_lport.c
759 @@ -308,7 +308,7 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost)
760 fc_stats = &lport->host_stats;
761 memset(fc_stats, 0, sizeof(struct fc_host_statistics));
762
763 - fc_stats->seconds_since_last_reset = (lport->boot_time - jiffies) / HZ;
764 + fc_stats->seconds_since_last_reset = (jiffies - lport->boot_time) / HZ;
765
766 for_each_possible_cpu(cpu) {
767 struct fc_stats *stats;
768 diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
769 index a78415d77434..78be4aee7064 100644
770 --- a/fs/overlayfs/super.c
771 +++ b/fs/overlayfs/super.c
772 @@ -329,11 +329,11 @@ static struct dentry *ovl_d_real(struct dentry *dentry,
773 if (!real)
774 goto bug;
775
776 + /* Handle recursion */
777 + real = d_real(real, inode, open_flags);
778 +
779 if (!inode || inode == d_inode(real))
780 return real;
781 -
782 - /* Handle recursion */
783 - return d_real(real, inode, open_flags);
784 bug:
785 WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry,
786 inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0);
787 diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
788 index 573c5a18908f..0a0b2d5148e1 100644
789 --- a/include/linux/compiler-gcc.h
790 +++ b/include/linux/compiler-gcc.h
791 @@ -256,7 +256,9 @@
792 #endif
793 #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP && !__CHECKER__ */
794
795 -#if GCC_VERSION >= 50000
796 +#if GCC_VERSION >= 70000
797 +#define KASAN_ABI_VERSION 5
798 +#elif GCC_VERSION >= 50000
799 #define KASAN_ABI_VERSION 4
800 #elif GCC_VERSION >= 40902
801 #define KASAN_ABI_VERSION 3
802 diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
803 index 01e84436cddf..d47cc4ab74ee 100644
804 --- a/include/linux/pagemap.h
805 +++ b/include/linux/pagemap.h
806 @@ -364,16 +364,13 @@ static inline struct page *read_mapping_page(struct address_space *mapping,
807 }
808
809 /*
810 - * Get the offset in PAGE_SIZE.
811 - * (TODO: hugepage should have ->index in PAGE_SIZE)
812 + * Get index of the page with in radix-tree
813 + * (TODO: remove once hugetlb pages will have ->index in PAGE_SIZE)
814 */
815 -static inline pgoff_t page_to_pgoff(struct page *page)
816 +static inline pgoff_t page_to_index(struct page *page)
817 {
818 pgoff_t pgoff;
819
820 - if (unlikely(PageHeadHuge(page)))
821 - return page->index << compound_order(page);
822 -
823 if (likely(!PageTransTail(page)))
824 return page->index;
825
826 @@ -387,6 +384,18 @@ static inline pgoff_t page_to_pgoff(struct page *page)
827 }
828
829 /*
830 + * Get the offset in PAGE_SIZE.
831 + * (TODO: hugepage should have ->index in PAGE_SIZE)
832 + */
833 +static inline pgoff_t page_to_pgoff(struct page *page)
834 +{
835 + if (unlikely(PageHeadHuge(page)))
836 + return page->index << compound_order(page);
837 +
838 + return page_to_index(page);
839 +}
840 +
841 +/*
842 * Return byte-offset into filesystem object for page.
843 */
844 static inline loff_t page_offset(struct page *page)
845 diff --git a/include/linux/pci.h b/include/linux/pci.h
846 index 0ab835965669..03f3df0888fe 100644
847 --- a/include/linux/pci.h
848 +++ b/include/linux/pci.h
849 @@ -1896,6 +1896,20 @@ static inline int pci_pcie_type(const struct pci_dev *dev)
850 return (pcie_caps_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4;
851 }
852
853 +static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
854 +{
855 + while (1) {
856 + if (!pci_is_pcie(dev))
857 + break;
858 + if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
859 + return dev;
860 + if (!dev->bus->self)
861 + break;
862 + dev = dev->bus->self;
863 + }
864 + return NULL;
865 +}
866 +
867 void pci_request_acs(void);
868 bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags);
869 bool pci_acs_path_enabled(struct pci_dev *start,
870 diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
871 index d6d071fc3c56..3af60ee69053 100644
872 --- a/include/uapi/linux/input-event-codes.h
873 +++ b/include/uapi/linux/input-event-codes.h
874 @@ -640,7 +640,7 @@
875 * Control a data application associated with the currently viewed channel,
876 * e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.)
877 */
878 -#define KEY_DATA 0x275
879 +#define KEY_DATA 0x277
880
881 #define BTN_TRIGGER_HAPPY 0x2c0
882 #define BTN_TRIGGER_HAPPY1 0x2c0
883 diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
884 index 0082fce402a0..85c5a883c6e3 100644
885 --- a/kernel/rcu/tree_plugin.h
886 +++ b/kernel/rcu/tree_plugin.h
887 @@ -2173,6 +2173,7 @@ static int rcu_nocb_kthread(void *arg)
888 cl++;
889 c++;
890 local_bh_enable();
891 + cond_resched_rcu_qs();
892 list = next;
893 }
894 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
895 diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
896 index e5c2181fee6f..03f4545b103d 100644
897 --- a/mm/kasan/kasan.h
898 +++ b/mm/kasan/kasan.h
899 @@ -53,6 +53,9 @@ struct kasan_global {
900 #if KASAN_ABI_VERSION >= 4
901 struct kasan_source_location *location;
902 #endif
903 +#if KASAN_ABI_VERSION >= 5
904 + char *odr_indicator;
905 +#endif
906 };
907
908 /**
909 diff --git a/mm/khugepaged.c b/mm/khugepaged.c
910 index 728d7790dc2d..87e1a7ca3846 100644
911 --- a/mm/khugepaged.c
912 +++ b/mm/khugepaged.c
913 @@ -103,6 +103,7 @@ static struct khugepaged_scan khugepaged_scan = {
914 .mm_head = LIST_HEAD_INIT(khugepaged_scan.mm_head),
915 };
916
917 +#ifdef CONFIG_SYSFS
918 static ssize_t scan_sleep_millisecs_show(struct kobject *kobj,
919 struct kobj_attribute *attr,
920 char *buf)
921 @@ -295,6 +296,7 @@ struct attribute_group khugepaged_attr_group = {
922 .attrs = khugepaged_attr,
923 .name = "khugepaged",
924 };
925 +#endif /* CONFIG_SYSFS */
926
927 #define VM_NO_KHUGEPAGED (VM_SPECIAL | VM_HUGETLB)
928
929 diff --git a/mm/mlock.c b/mm/mlock.c
930 index 14645be06e30..9c91acc0e328 100644
931 --- a/mm/mlock.c
932 +++ b/mm/mlock.c
933 @@ -190,10 +190,13 @@ unsigned int munlock_vma_page(struct page *page)
934 */
935 spin_lock_irq(zone_lru_lock(zone));
936
937 - nr_pages = hpage_nr_pages(page);
938 - if (!TestClearPageMlocked(page))
939 + if (!TestClearPageMlocked(page)) {
940 + /* Potentially, PTE-mapped THP: do not skip the rest PTEs */
941 + nr_pages = 1;
942 goto unlock_out;
943 + }
944
945 + nr_pages = hpage_nr_pages(page);
946 __mod_zone_page_state(zone, NR_MLOCK, -nr_pages);
947
948 if (__munlock_isolate_lru_page(page, true)) {
949 diff --git a/mm/truncate.c b/mm/truncate.c
950 index a01cce450a26..8d8c62d89e6d 100644
951 --- a/mm/truncate.c
952 +++ b/mm/truncate.c
953 @@ -283,7 +283,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
954
955 if (!trylock_page(page))
956 continue;
957 - WARN_ON(page_to_pgoff(page) != index);
958 + WARN_ON(page_to_index(page) != index);
959 if (PageWriteback(page)) {
960 unlock_page(page);
961 continue;
962 @@ -371,7 +371,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
963 }
964
965 lock_page(page);
966 - WARN_ON(page_to_pgoff(page) != index);
967 + WARN_ON(page_to_index(page) != index);
968 wait_on_page_writeback(page);
969 truncate_inode_page(mapping, page);
970 unlock_page(page);
971 @@ -492,7 +492,7 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
972 if (!trylock_page(page))
973 continue;
974
975 - WARN_ON(page_to_pgoff(page) != index);
976 + WARN_ON(page_to_index(page) != index);
977
978 /* Middle of THP: skip */
979 if (PageTransTail(page)) {
980 @@ -612,7 +612,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
981 }
982
983 lock_page(page);
984 - WARN_ON(page_to_pgoff(page) != index);
985 + WARN_ON(page_to_index(page) != index);
986 if (page->mapping != mapping) {
987 unlock_page(page);
988 continue;
989 diff --git a/mm/workingset.c b/mm/workingset.c
990 index 617475f529f4..fb1f9183d89a 100644
991 --- a/mm/workingset.c
992 +++ b/mm/workingset.c
993 @@ -348,7 +348,7 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
994 shadow_nodes = list_lru_shrink_count(&workingset_shadow_nodes, sc);
995 local_irq_enable();
996
997 - if (memcg_kmem_enabled()) {
998 + if (sc->memcg) {
999 pages = mem_cgroup_node_nr_lru_pages(sc->memcg, sc->nid,
1000 LRU_ALL_FILE);
1001 } else {
1002 diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c
1003 index 2333777f919d..8af1611b8ab2 100644
1004 --- a/net/batman-adv/tp_meter.c
1005 +++ b/net/batman-adv/tp_meter.c
1006 @@ -837,6 +837,7 @@ static int batadv_tp_send(void *arg)
1007 primary_if = batadv_primary_if_get_selected(bat_priv);
1008 if (unlikely(!primary_if)) {
1009 err = BATADV_TP_REASON_DST_UNREACHABLE;
1010 + tp_vars->reason = err;
1011 goto out;
1012 }
1013
1014 diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c
1015 index 0bf6709d1006..6fb4314cec49 100644
1016 --- a/virt/kvm/arm/vgic/vgic-v2.c
1017 +++ b/virt/kvm/arm/vgic/vgic-v2.c
1018 @@ -50,8 +50,10 @@ void vgic_v2_process_maintenance(struct kvm_vcpu *vcpu)
1019
1020 WARN_ON(cpuif->vgic_lr[lr] & GICH_LR_STATE);
1021
1022 - kvm_notify_acked_irq(vcpu->kvm, 0,
1023 - intid - VGIC_NR_PRIVATE_IRQS);
1024 + /* Only SPIs require notification */
1025 + if (vgic_valid_spi(vcpu->kvm, intid))
1026 + kvm_notify_acked_irq(vcpu->kvm, 0,
1027 + intid - VGIC_NR_PRIVATE_IRQS);
1028 }
1029 }
1030
1031 diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
1032 index 9f0dae397d9c..5c9f9745e6ca 100644
1033 --- a/virt/kvm/arm/vgic/vgic-v3.c
1034 +++ b/virt/kvm/arm/vgic/vgic-v3.c
1035 @@ -41,8 +41,10 @@ void vgic_v3_process_maintenance(struct kvm_vcpu *vcpu)
1036
1037 WARN_ON(cpuif->vgic_lr[lr] & ICH_LR_STATE);
1038
1039 - kvm_notify_acked_irq(vcpu->kvm, 0,
1040 - intid - VGIC_NR_PRIVATE_IRQS);
1041 + /* Only SPIs require notification */
1042 + if (vgic_valid_spi(vcpu->kvm, intid))
1043 + kvm_notify_acked_irq(vcpu->kvm, 0,
1044 + intid - VGIC_NR_PRIVATE_IRQS);
1045 }
1046
1047 /*
1048 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
1049 index 195078225aa5..690d15eaee05 100644
1050 --- a/virt/kvm/kvm_main.c
1051 +++ b/virt/kvm/kvm_main.c
1052 @@ -2852,10 +2852,10 @@ static int kvm_ioctl_create_device(struct kvm *kvm,
1053
1054 ret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC);
1055 if (ret < 0) {
1056 - ops->destroy(dev);
1057 mutex_lock(&kvm->lock);
1058 list_del(&dev->vm_node);
1059 mutex_unlock(&kvm->lock);
1060 + ops->destroy(dev);
1061 return ret;
1062 }
1063