Hi Sander,
        Could you please help to test attached patch? It works
on native but I have no Xen environment at hand.
Thanks!
Gerry

On 2014/12/19 21:16, Sander Eikelenboom wrote:
> Hi,
> 
> When running under Xen, ACPI powerbutton events don't work anymore, 
> there is no reaction when pressing the powerbutton.
> 
> On baremetal everything works fine, acpid gets the event and the 
> machine powers down perfectly. The machine is an Intel NUC.
>  
> Bisection has lead to:
> 
> b81975eade8c6495f3c4d6746d22bdc95f617777 is the first bad commit
> commit b81975eade8c6495f3c4d6746d22bdc95f617777
> Author: Jiang Liu <jiang....@linux.intel.com>
> Date:   Mon Jun 9 16:20:11 2014 +0800
> 
>     x86, irq: Clean up irqdomain transition code
> 
>     Now we have completely switched to irqdomain, so clean up transition code
>     in IOAPIC drivers.
> 
>     Signed-off-by: Jiang Liu <jiang....@linux.intel.com>
>     Cc: Konrad Rzeszutek Wilk <konrad.w...@oracle.com>
>     Cc: Tony Luck <tony.l...@intel.com>
>     Cc: Joerg Roedel <j...@8bytes.org>
>     Cc: Paul Gortmaker <paul.gortma...@windriver.com>
>     Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
>     Cc: Benjamin Herrenschmidt <b...@kernel.crashing.org>
>     Cc: Grant Likely <grant.lik...@linaro.org>
>     Cc: Rafael J. Wysocki <r...@rjwysocki.net>
>     Cc: Bjorn Helgaas <bhelg...@google.com>
>     Cc: Randy Dunlap <rdun...@infradead.org>
>     Cc: Yinghai Lu <ying...@kernel.org>
>     Link: 
> http://lkml.kernel.org/r/1402302011-23642-43-git-send-email-jiang....@linux.intel.com
>     Signed-off-by: Thomas Gleixner <t...@linutronix.de>
> 
> Reverting this specific commit on linux-tip (3.19-mw) gets things working 
> again under Xen.
> Kernel .config is attached.
> 
> --
> Sander
> 
>From a6928b3c93a5119c79b8a7aec953579c87d2a4cc Mon Sep 17 00:00:00 2001
From: Jiang Liu <jiang....@linux.intel.com>
Date: Fri, 19 Dec 2014 22:33:56 +0800
Subject: [PATCH] x86/apic: Fix xen failure caused by commit b81975eade8c

Commit b81975eade8c "x86, irq: Clean up irqdomain transition code"
breaks Xen because xen_smp_prepare_cpus() doesn't call setup_IO_APIC()
so mp_map_pin_to_irq() fails at the very beginning.

Signed-off-by: Jiang Liu <jiang....@linux.intel.com>
---
 arch/x86/include/asm/hw_irq.h        |    2 +-
 arch/x86/include/asm/smpboot_hooks.h |    6 +++---
 arch/x86/kernel/apic/apic.c          |    6 +++---
 arch/x86/kernel/apic/io_apic.c       |   32 +++++++++++++++-----------------
 arch/x86/xen/smp.c                   |    3 +++
 5 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
index 4615906d83df..0c6530dfd817 100644
--- a/arch/x86/include/asm/hw_irq.h
+++ b/arch/x86/include/asm/hw_irq.h
@@ -98,7 +98,7 @@ extern void trace_call_function_single_interrupt(void);
 #define IO_APIC_IRQ(x) (((x) >= NR_IRQS_LEGACY) || ((1<<(x)) & io_apic_irqs))
 extern unsigned long io_apic_irqs;
 
-extern void setup_IO_APIC(void);
+extern void setup_IO_APIC(bool xen_smp);
 extern void disable_IO_APIC(void);
 
 struct io_apic_irq_attr {
diff --git a/arch/x86/include/asm/smpboot_hooks.h b/arch/x86/include/asm/smpboot_hooks.h
index 0da7409f0bec..76e5731b03cb 100644
--- a/arch/x86/include/asm/smpboot_hooks.h
+++ b/arch/x86/include/asm/smpboot_hooks.h
@@ -52,9 +52,9 @@ static inline void __init smpboot_setup_io_apic(void)
 	 * Here we can be sure that there is an IO-APIC in the system. Let's
 	 * go and set it up:
 	 */
-	if (!skip_ioapic_setup && nr_ioapics)
-		setup_IO_APIC();
-	else {
+	if (!skip_ioapic_setup && nr_ioapics) {
+		setup_IO_APIC(false);
+	} else {
 		nr_ioapics = 0;
 	}
 #endif
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index ba6cc041edb1..33ba1f97abea 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1912,9 +1912,9 @@ int __init APIC_init_uniprocessor(void)
 	bsp_end_local_APIC_setup();
 
 #ifdef CONFIG_X86_IO_APIC
-	if (smp_found_config && !skip_ioapic_setup && nr_ioapics)
-		setup_IO_APIC();
-	else {
+	if (smp_found_config && !skip_ioapic_setup && nr_ioapics) {
+		setup_IO_APIC(false);
+	} else {
 		nr_ioapics = 0;
 	}
 #endif
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index a6745e756729..5879ac58c3b6 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -2965,31 +2965,29 @@ static int mp_irqdomain_create(int ioapic)
 	return 0;
 }
 
-void __init setup_IO_APIC(void)
+void __init setup_IO_APIC(bool xen_smp)
 {
 	int ioapic;
 
-	/*
-	 * calling enable_IO_APIC() is moved to setup_local_APIC for BP
-	 */
-	io_apic_irqs = nr_legacy_irqs() ? ~PIC_IRQS : ~0UL;
+	if (!xen_smp) {
+		apic_printk(APIC_VERBOSE, "ENABLING IO-APIC IRQs\n");
+		io_apic_irqs = nr_legacy_irqs() ? ~PIC_IRQS : ~0UL;
+
+		/* Set up IO-APIC IRQ routing. */
+		x86_init.mpparse.setup_ioapic_ids();
+		sync_Arb_IDs();
+	}
 
-	apic_printk(APIC_VERBOSE, "ENABLING IO-APIC IRQs\n");
 	for_each_ioapic(ioapic)
 		BUG_ON(mp_irqdomain_create(ioapic));
-
-	/*
-         * Set up IO-APIC IRQ routing.
-         */
-	x86_init.mpparse.setup_ioapic_ids();
-
-	sync_Arb_IDs();
 	setup_IO_APIC_irqs();
-	init_IO_APIC_traps();
-	if (nr_legacy_irqs())
-		check_timer();
-
 	ioapic_initialized = 1;
+
+	if (!xen_smp) {
+		init_IO_APIC_traps();
+		if (nr_legacy_irqs())
+			check_timer();
+	}
 }
 
 /*
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 4c071aeb8417..7eb0283901fa 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -326,7 +326,10 @@ static void __init xen_smp_prepare_cpus(unsigned int max_cpus)
 
 		xen_raw_printk(m);
 		panic(m);
+	} else {
+		setup_IO_APIC(true);
 	}
+
 	xen_init_lock_cpu(0);
 
 	smp_store_boot_cpu_info();
-- 
1.7.10.4

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to