Skip to contentSkip to conversation

ACPI / x86: boot: Not all platforms require acpi_reduced_hw_init()

PATCH In review Andy Shevchenko 2 participants 4 messages Feb 20, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 ACPI / x86: boot: Not all platforms require acpi_reduced_hw_init()

Some platforms might take care of legacy devices on theirs own. Due to this, export acpi_reduced_hw_init() and put it into struct x86_init_acpi.

While doing this, rename acpi_reduced_hw_init() to acpi_reduced_hw_early_init() to show the stage at which it's called.

---

- re-done based on patches from Juergen Gross
- supposed to go via tip tree (x86/boot branch)
- tested on ASuS T100ta (HW reduced) and Intel Broxton based platforms

 arch/x86/include/asm/acpi.h     |  4 ++++
 arch/x86/include/asm/x86_init.h |  2 ++
 arch/x86/kernel/acpi/boot.c     | 21 ++++++++++-----------
 arch/x86/kernel/x86_init.c      |  2 ++
 4 files changed, 18 insertions(+), 11 deletions(-)
arch/x86/include/asm/acpi.h +4 -0
index 6609dd7289b5..f3f86be35fc5 100644
@@ -140,6 +140,8 @@ static inline u64 acpi_arch_get_root_pointer(void)
 	return x86_init.acpi.get_root_pointer();
 }
 
+void acpi_reduced_hw_early_init(void);
+
 #else /* !CONFIG_ACPI */
 
 #define acpi_lapic 0
@@ -149,6 +151,8 @@ static inline void acpi_noirq_set(void) { }
 static inline void acpi_disable_pci(void) { }
 static inline void disable_acpi(void) { }
 
+static inline void acpi_reduced_hw_early_init(void) { }
+
 #endif /* !CONFIG_ACPI */
 
 #define ARCH_HAS_POWER_INIT	1
arch/x86/include/asm/x86_init.h +2 -0
index 5ffa116ddb08..199e15bd3ec5 100644
@@ -133,9 +133,11 @@ struct x86_hyper_init {
 /**
  * struct x86_init_acpi - x86 ACPI init functions
  * @get_root_pointer:		get RSDP address
+ * @reduced_hw_early_init:	hardware reduced platform early init
  */
 struct x86_init_acpi {
 	u64 (*get_root_pointer)(void);
+	void (*reduced_hw_early_init)(void);
 };
 
 /**
arch/x86/kernel/acpi/boot.c +10 -11
index d3deae23e584..02acf1c58d3a 100644
@@ -1378,17 +1378,15 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
  *
  * We initialize the Hardware-reduced ACPI model here:
  */
-static void __init acpi_reduced_hw_init(void)
+void __init acpi_reduced_hw_early_init(void)
 {
-	if (acpi_gbl_reduced_hardware) {
-		/*
-		 * Override x86_init functions and bypass legacy pic
-		 * in Hardware-reduced ACPI mode
-		 */
-		x86_init.timers.timer_init	= x86_init_noop;
-		x86_init.irqs.pre_vector_init	= x86_init_noop;
-		legacy_pic			= &null_legacy_pic;
-	}
+	/*
+	 * Override x86_init functions and bypass legacy pic
+	 * in Hardware-reduced ACPI mode.
+	 */
+	x86_init.timers.timer_init	= x86_init_noop;
+	x86_init.irqs.pre_vector_init	= x86_init_noop;
+	legacy_pic			= &null_legacy_pic;
 }
 
 /*
@@ -1593,7 +1591,8 @@ int __init early_acpi_boot_init(void)
 	/*
 	 * Hardware-reduced ACPI mode initialization:
 	 */
-	acpi_reduced_hw_init();
+	if (acpi_gbl_reduced_hardware)
+		x86_init.acpi.reduced_hw_early_init();
 
 	return 0;
 }
arch/x86/kernel/x86_init.c +2 -0
index 32c288ebf870..8fd63640e764 100644
@@ -8,6 +8,7 @@
 #include <linux/export.h>
 #include <linux/pci.h>
 
+#include <asm/acpi.h>
 #include <asm/bios_ebda.h>
 #include <asm/paravirt.h>
 #include <asm/pci_x86.h>
@@ -95,6 +96,7 @@ struct x86_init_ops x86_init __initdata = {
 
 	.acpi = {
 		.get_root_pointer	= u64_x86_init_noop,
+		.reduced_hw_early_init	= acpi_reduced_hw_early_init,
 	},
 };
 
Signature · 1 line
2.15.1
#1 lore raw

PATCH v4 2/2 x86/platform/intel-mid: Add special handling of ACPI HW reduced platforms

When switching to ACPI HW reduced platforms we still want to initialize timers. Override x86_init.acpi.reduced_hw_init to achieve that.

---
 arch/x86/platform/intel-mid/intel-mid.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/platform/intel-mid/intel-mid.c +6 -0
index 2c67bae6bb53..c556f1e8936e 100644
@@ -199,6 +199,12 @@ void __init x86_intel_mid_early_setup(void)
 
 	legacy_pic = &null_legacy_pic;
 
+	/*
+	 * Do nothing for now as everything needed done in
+	 * x86_intel_mid_early_setup() below.
+	 */
+	x86_init.acpi.reduced_hw_early_init = x86_init_noop;
+
 	pm_power_off = intel_mid_power_off;
 	machine_ops.emergency_restart  = intel_mid_reboot;
 
Signature · 1 line
2.15.1
#2 lore raw
In reply to Andy Shevchenko
Quoted 2 lines · Andy Shevchenko

Some platforms might take care of legacy devices on theirs own. Due to this, export acpi_reduced_hw_init() and put it into struct x86_init_acpi.

IMO this completely doesn't explain what really happens here.

You basically want to provide your own versions of x86_init.timers.timer_init, x86_init.irqs.pre_vector_init and legacy_pic on some HW-reduced platforms AFAICS, so you make it possible for the platform to provide its own variant of acpi_reduced_hw_init().

I would say something like this:

"Some ACPI hawdware-reduced platforms need to initialize certain devices defined by the ACPI hardware specification even though in principle those devices should not be present in an ACPI hawdware-reduced platform. To allow that to happen, make it possible to override the generic x86_init callbacks and provide a custom legacy_pic value, add a new ->reduced_hw_early_init() callback to struct x86_init_acpi and make acpi_reduced_hw_init() use it."

And I would retain acpi_reduced_hw_init(), but ->

Quoted 59 lines

While doing this, rename acpi_reduced_hw_init() to acpi_reduced_hw_early_init() to show the stage at which it's called.

---

- re-done based on patches from Juergen Gross
- supposed to go via tip tree (x86/boot branch)
- tested on ASuS T100ta (HW reduced) and Intel Broxton based platforms

 arch/x86/include/asm/acpi.h     |  4 ++++
 arch/x86/include/asm/x86_init.h |  2 ++
 arch/x86/kernel/acpi/boot.c     | 21 ++++++++++-----------
 arch/x86/kernel/x86_init.c      |  2 ++
 4 files changed, 18 insertions(+), 11 deletions(-)
arch/x86/include/asm/acpi.h +4 -0
index 6609dd7289b5..f3f86be35fc5 100644
@@ -140,6 +140,8 @@ static inline u64 acpi_arch_get_root_pointer(void)
        return x86_init.acpi.get_root_pointer();
 }
 
+void acpi_reduced_hw_early_init(void);
+
 #else /* !CONFIG_ACPI */
 
 #define acpi_lapic 0
@@ -149,6 +151,8 @@ static inline void acpi_noirq_set(void) { }
 static inline void acpi_disable_pci(void) { }
 static inline void disable_acpi(void) { }
 
+static inline void acpi_reduced_hw_early_init(void) { }
+
 #endif /* !CONFIG_ACPI */
 
 #define ARCH_HAS_POWER_INIT    1
arch/x86/include/asm/x86_init.h +2 -0
index 5ffa116ddb08..199e15bd3ec5 100644
@@ -133,9 +133,11 @@ struct x86_hyper_init {
 /**
  * struct x86_init_acpi - x86 ACPI init functions
  * @get_root_pointer:          get RSDP address
+ * @reduced_hw_early_init:     hardware reduced platform early init
  */
 struct x86_init_acpi {
        u64 (*get_root_pointer)(void);
+       void (*reduced_hw_early_init)(void);
 };
 
 /**
arch/x86/kernel/acpi/boot.c +0 -0
index d3deae23e584..02acf1c58d3a 100644

arch/x86/kernel/acpi/boot.c static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d) · line 1381

Quoted 5 lines
arch/x86/kernel/acpi/boot.c +1 -1
@@ -1378,17 +1378,15 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
  *
  * We initialize the Hardware-reduced ACPI model here:
  */
-static void __init acpi_reduced_hw_init(void)
+void __init acpi_reduced_hw_early_init(void)

-> I would call this acpi_generic_reduced_hw_init() and ->>

Quoted 21 lines
arch/x86/kernel/acpi/boot.c +7 -9
 {
-       if (acpi_gbl_reduced_hardware) {
-               /*
-                * Override x86_init functions and bypass legacy pic
-                * in Hardware-reduced ACPI mode
-                */
-               x86_init.timers.timer_init      = x86_init_noop;
-               x86_init.irqs.pre_vector_init   = x86_init_noop;
-               legacy_pic                      = &null_legacy_pic;
-       }
+       /*
+        * Override x86_init functions and bypass legacy pic
+        * in Hardware-reduced ACPI mode.
+        */
+       x86_init.timers.timer_init      = x86_init_noop;
+       x86_init.irqs.pre_vector_init   = x86_init_noop;
+       legacy_pic                      = &null_legacy_pic;
 }
 
 /*

arch/x86/kernel/acpi/boot.c int __init early_acpi_boot_init(void) · line 1595

Quoted 6 lines
arch/x86/kernel/acpi/boot.c +2 -1
@@ -1593,7 +1591,8 @@ int __init early_acpi_boot_init(void)
        /*
         * Hardware-reduced ACPI mode initialization:
         */
-       acpi_reduced_hw_init();
+       if (acpi_gbl_reduced_hardware)
+               x86_init.acpi.reduced_hw_early_init();

->> I would put the two lines above into acpi_reduced_hw_init().

Quoted 24 lines
arch/x86/kernel/acpi/boot.c +0 -0
        return 0;
 }
arch/x86/kernel/x86_init.c +2 -1
index 32c288ebf870..8fd63640e764 100644
@@ -8,6 +8,7 @@
 #include <linux/export.h>
 #include <linux/pci.h>
 
+#include <asm/acpi.h>
 #include <asm/bios_ebda.h>
 #include <asm/paravirt.h>
 #include <asm/pci_x86.h>
@@ -95,6 +96,7 @@ struct x86_init_ops x86_init __initdata = {
 
        .acpi = {
                .get_root_pointer       = u64_x86_init_noop,
+               .reduced_hw_early_init  = acpi_reduced_hw_early_init,
        },
 };
 
--
#3 lore raw
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines · Andy Shevchenko

Some platforms might take care of legacy devices on theirs own. Due to this,
export acpi_reduced_hw_init() and put it into struct x86_init_acpi.

Quoted 7 lines

IMO this completely doesn't explain what really happens here.

You basically want to provide your own versions of x86_init.timers.timer_init, x86_init.irqs.pre_vector_init and legacy_pic on some HW-reduced platforms AFAICS, so you make it possible for the platform to provide its own variant of acpi_reduced_hw_init().

In this particular case only timers matter, though in general you are right.

Quoted 9 lines

I would say something like this:

"Some ACPI hawdware-reduced platforms need to initialize certain devices defined by the ACPI hardware specification even though in principle those devices should not be present in an ACPI hawdware-reduced platform. To allow that to happen, make it possible to override the generic x86_init callbacks and provide a custom legacy_pic value, add a new ->reduced_hw_early_init() callback to struct x86_init_acpi and make acpi_reduced_hw_init() use it."

Thanks for review! I will use your suggestions in the next version.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy