Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xen/acpi-processor: fix enabling interrupts on syscore_resume

syscore->resume() callback is expected to do not enable interrupts,
it generates warning like below otherwise:

[ 9386.365390] WARNING: CPU: 0 PID: 6733 at drivers/base/syscore.c:104 syscore_resume+0x9a/0xe0()
[ 9386.365403] Interrupts enabled after xen_acpi_processor_resume+0x0/0x34 [xen_acpi_processor]
...
[ 9386.365429] Call Trace:
[ 9386.365434] [<ffffffff81667a8b>] dump_stack+0x45/0x56
[ 9386.365437] [<ffffffff8106921d>] warn_slowpath_common+0x7d/0xa0
[ 9386.365439] [<ffffffff8106928c>] warn_slowpath_fmt+0x4c/0x50
[ 9386.365442] [<ffffffffa0261bb0>] ? xen_upload_processor_pm_data+0x300/0x300 [xen_acpi_processor]
[ 9386.365443] [<ffffffff814055fa>] syscore_resume+0x9a/0xe0
[ 9386.365445] [<ffffffff810aef42>] suspend_devices_and_enter+0x402/0x470
[ 9386.365447] [<ffffffff810af128>] pm_suspend+0x178/0x260

On xen_acpi_processor_resume() we call various procedures, which are
non atomic and can enable interrupts. To prevent the issue introduce
separate resume notify called after we enable interrupts on resume
and before we call other drivers resume callbacks.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

authored by

Stanislaw Gruszka and committed by
David Vrabel
cd979883 1429d46d

+28 -7
+16
drivers/xen/manage.c
··· 46 46 void (*post)(int cancelled); 47 47 }; 48 48 49 + static RAW_NOTIFIER_HEAD(xen_resume_notifier); 50 + 51 + void xen_resume_notifier_register(struct notifier_block *nb) 52 + { 53 + raw_notifier_chain_register(&xen_resume_notifier, nb); 54 + } 55 + EXPORT_SYMBOL_GPL(xen_resume_notifier_register); 56 + 57 + void xen_resume_notifier_unregister(struct notifier_block *nb) 58 + { 59 + raw_notifier_chain_unregister(&xen_resume_notifier, nb); 60 + } 61 + EXPORT_SYMBOL_GPL(xen_resume_notifier_unregister); 62 + 49 63 #ifdef CONFIG_HIBERNATE_CALLBACKS 50 64 static void xen_hvm_post_suspend(int cancelled) 51 65 { ··· 165 151 } 166 152 167 153 err = stop_machine(xen_suspend, &si, cpumask_of(0)); 154 + 155 + raw_notifier_call_chain(&xen_resume_notifier, 0, NULL); 168 156 169 157 dpm_resume_start(si.cancelled ? PMSG_THAW : PMSG_RESTORE); 170 158
+8 -7
drivers/xen/xen-acpi-processor.c
··· 27 27 #include <linux/init.h> 28 28 #include <linux/module.h> 29 29 #include <linux/types.h> 30 - #include <linux/syscore_ops.h> 31 30 #include <linux/acpi.h> 32 31 #include <acpi/processor.h> 33 32 #include <xen/xen.h> 33 + #include <xen/xen-ops.h> 34 34 #include <xen/interface/platform.h> 35 35 #include <asm/xen/hypercall.h> 36 36 ··· 495 495 return rc; 496 496 } 497 497 498 - static void xen_acpi_processor_resume(void) 498 + static int xen_acpi_processor_resume(struct notifier_block *nb, 499 + unsigned long action, void *data) 499 500 { 500 501 bitmap_zero(acpi_ids_done, nr_acpi_bits); 501 - xen_upload_processor_pm_data(); 502 + return xen_upload_processor_pm_data(); 502 503 } 503 504 504 - static struct syscore_ops xap_syscore_ops = { 505 - .resume = xen_acpi_processor_resume, 505 + struct notifier_block xen_acpi_processor_resume_nb = { 506 + .notifier_call = xen_acpi_processor_resume, 506 507 }; 507 508 508 509 static int __init xen_acpi_processor_init(void) ··· 556 555 if (rc) 557 556 goto err_unregister; 558 557 559 - register_syscore_ops(&xap_syscore_ops); 558 + xen_resume_notifier_register(&xen_acpi_processor_resume_nb); 560 559 561 560 return 0; 562 561 err_unregister: ··· 575 574 { 576 575 int i; 577 576 578 - unregister_syscore_ops(&xap_syscore_ops); 577 + xen_resume_notifier_unregister(&xen_acpi_processor_resume_nb); 579 578 kfree(acpi_ids_done); 580 579 kfree(acpi_id_present); 581 580 kfree(acpi_id_cst_present);
+4
include/xen/xen-ops.h
··· 2 2 #define INCLUDE_XEN_OPS_H 3 3 4 4 #include <linux/percpu.h> 5 + #include <linux/notifier.h> 5 6 #include <asm/xen/interface.h> 6 7 7 8 DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu); ··· 16 15 17 16 void xen_timer_resume(void); 18 17 void xen_arch_resume(void); 18 + 19 + void xen_resume_notifier_register(struct notifier_block *nb); 20 + void xen_resume_notifier_unregister(struct notifier_block *nb); 19 21 20 22 int xen_setup_shutdown_event(void); 21 23