Skip to contentSkip to conversation

Prepare for running ACPI on !x86 and !ia64

PATCH Superseded Hanjun Guo 3 participants 9 messages Feb 8, 2014 – Feb 18, 2014

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Hanjun Guo

author
#0 lore raw

v2 cover Prepare for running ACPI on !x86 and !ia64

Some of the ACPI code is arch-dependent and make the code can't be compiled on !x86 or !ia64, the first two patches just do some rework on the idle_boot_override and _PDC related stuff to make the ACPI code more arch-independent.

The third patch just introduce map_gic_id() for ACPI processor core followed by the ACPI 5.0 spec.

I have compiled the kernel successfully after appling this patch set on x86 and ia64.

Changes for v2:
a) add #if defined(CONFIG_X86) || defined(CONFIG_IA64) for idle_boot_override related code;
b) Rebased on 3.14-rc1.

Changes since the RFC version:
a) Remove the RFC tag;
b) Move idle_boot_override out of the arch directory suggested by Alan;
c) Make these 3 patches as a separate patch set since there are not not related to the ARM/ARM64 platform.

Hanjun Guo (3):
ACPI / idle: Make idle_boot_override depend on x86 and ia64 ACPI / processor_core: Rework _PDC related stuff to make it more
arch-independent
ACPI: Introduce map_gic_id() to get apic id from MADT or _MAT method

 arch/ia64/include/asm/acpi.h  |    5 +--
 arch/ia64/kernel/acpi.c       |   17 +++++++++
 arch/x86/include/asm/acpi.h   |   19 +--------
 arch/x86/kernel/acpi/cstate.c |   31 +++++++++++++++
 drivers/acpi/processor_core.c |   85 ++++++++++++++++++++++++-----------------
 5 files changed, 99 insertions(+), 58 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v2 1/3 ACPI / idle: Make idle_boot_override depend on x86 and ia64

idle_boot_override depends on x86 and ia64 now, and we can not foresee it will be used on ARM or ARM64,so move the code into CONFIG_X86 and CONFIG_IA64 #ifdefs to make processor_core.c can be compiled on ARM64.

---
 drivers/acpi/processor_core.c |   40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)
drivers/acpi/processor_core.c +22 -18
index 46583d7..01b2656 100644
@@ -19,24 +19,6 @@
 #define _COMPONENT		ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("processor_core");
 
-static int __init set_no_mwait(const struct dmi_system_id *id)
-{
-	printk(KERN_NOTICE PREFIX "%s detected - "
-		"disabling mwait for CPU C-states\n", id->ident);
-	boot_option_idle_override = IDLE_NOMWAIT;
-	return 0;
-}
-
-static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
-	{
-	set_no_mwait, "Extensa 5220", {
-	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
-	DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-	DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
-	DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
-	{},
-};
-
 static int map_lapic_id(struct acpi_subtable_header *entry,
 		 u32 acpi_id, int *apic_id)
 {
@@ -379,13 +361,35 @@ early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
 	return AE_OK;
 }
 
+#if defined(CONFIG_X86) || defined(CONFIG_IA64)
+static int __init set_no_mwait(const struct dmi_system_id *id)
+{
+	printk(KERN_NOTICE PREFIX "%s detected - "
+		"disabling mwait for CPU C-states\n", id->ident);
+	boot_option_idle_override = IDLE_NOMWAIT;
+	return 0;
+}
+
+static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
+	{
+	set_no_mwait, "Extensa 5220", {
+	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
+	DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+	DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
+	DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
+	{},
+};
+#endif
+
 void __init acpi_early_processor_set_pdc(void)
 {
+#if defined(CONFIG_X86) || defined(CONFIG_IA64)
 	/*
 	 * Check whether the system is DMI table. If yes, OSPM
 	 * should not use mwait for CPU-states.
 	 */
 	dmi_check_system(processor_idle_dmi_table);
+#endif
 
 	acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
 			    ACPI_UINT32_MAX,
Signature · 1 line
1.7.9.5
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] ACPI / idle: Make idle_boot_override depend on x86 and ia64

2014-02-08 Hanjun Guo <[email protected]>:

Quoted 5 lines

idle_boot_override depends on x86 and ia64 now, and we can not foresee it will be used on ARM or ARM64,so move the code into CONFIG_X86 and CONFIG_IA64 #ifdefs to make processor_core.c can be compiled on ARM64.

Quoted 77 lines
---
 drivers/acpi/processor_core.c |   40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)
drivers/acpi/processor_core.c +22 -19
index 46583d7..01b2656 100644
@@ -19,24 +19,6 @@
 #define _COMPONENT             ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("processor_core");
 
-static int __init set_no_mwait(const struct dmi_system_id *id)
-{
-       printk(KERN_NOTICE PREFIX "%s detected - "
-               "disabling mwait for CPU C-states\n", id->ident);
-       boot_option_idle_override = IDLE_NOMWAIT;
-       return 0;
-}
-
-static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
-       {
-       set_no_mwait, "Extensa 5220", {
-       DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
-       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-       DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
-       DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
-       {},
-};
-
 static int map_lapic_id(struct acpi_subtable_header *entry,
                 u32 acpi_id, int *apic_id)
 {
@@ -379,13 +361,35 @@ early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
        return AE_OK;
 }
 
+#if defined(CONFIG_X86) || defined(CONFIG_IA64)
+static int __init set_no_mwait(const struct dmi_system_id *id)
+{
+       printk(KERN_NOTICE PREFIX "%s detected - "
+               "disabling mwait for CPU C-states\n", id->ident);
+       boot_option_idle_override = IDLE_NOMWAIT;
+       return 0;
+}
+
+static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
+       {
+       set_no_mwait, "Extensa 5220", {
+       DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
+       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+       DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
+       DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
+       {},
+};
+#endif
+
 void __init acpi_early_processor_set_pdc(void)
 {
+#if defined(CONFIG_X86) || defined(CONFIG_IA64)
        /*
         * Check whether the system is DMI table. If yes, OSPM
         * should not use mwait for CPU-states.
         */
        dmi_check_system(processor_idle_dmi_table);
+#endif
 
        acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
                            ACPI_UINT32_MAX,
--

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Best regards
Tianyu Lan
#3 lore raw

Re: [PATCH v2 1/3] ACPI / idle: Make idle_boot_override depend on x86 and ia64

In reply to Hanjun Guo
Quoted 62 lines · Hanjun Guo

idle_boot_override depends on x86 and ia64 now, and we can not foresee it will be used on ARM or ARM64,so move the code into CONFIG_X86 and CONFIG_IA64 #ifdefs to make processor_core.c can be compiled on ARM64.

---
 drivers/acpi/processor_core.c |   40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)
drivers/acpi/processor_core.c +19 -18
index 46583d7..01b2656 100644
@@ -19,24 +19,6 @@
 #define _COMPONENT		ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("processor_core");
 
-static int __init set_no_mwait(const struct dmi_system_id *id)
-{
-	printk(KERN_NOTICE PREFIX "%s detected - "
-		"disabling mwait for CPU C-states\n", id->ident);
-	boot_option_idle_override = IDLE_NOMWAIT;
-	return 0;
-}
-
-static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
-	{
-	set_no_mwait, "Extensa 5220", {
-	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
-	DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-	DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
-	DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
-	{},
-};
-
 static int map_lapic_id(struct acpi_subtable_header *entry,
 		 u32 acpi_id, int *apic_id)
 {
@@ -379,13 +361,35 @@ early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
 	return AE_OK;
 }
 
+#if defined(CONFIG_X86) || defined(CONFIG_IA64)
+static int __init set_no_mwait(const struct dmi_system_id *id)
+{
+	printk(KERN_NOTICE PREFIX "%s detected - "
+		"disabling mwait for CPU C-states\n", id->ident);
+	boot_option_idle_override = IDLE_NOMWAIT;
+	return 0;
+}
+
+static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
+	{
+	set_no_mwait, "Extensa 5220", {
+	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
+	DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+	DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
+	DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
+	{},
+};
+#endif

drivers/acpi/processor_core.c early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv) · line 392

Quoted 10 lines
drivers/acpi/processor_core.c +3 -0
+
 void __init acpi_early_processor_set_pdc(void)
 {
+#if defined(CONFIG_X86) || defined(CONFIG_IA64)
 	/*
 	 * Check whether the system is DMI table. If yes, OSPM
 	 * should not use mwait for CPU-states.
 	 */
 	dmi_check_system(processor_idle_dmi_table);
+#endif

Please define processor_dmi_check() under the #if above and an empty static inline counterpart of it for the case when the #if condition is not satisfied. Then just call processor_dmi_check() here without the #if block in the body of the function.

There is a general rule to avoid preprocessor directives in function bodies.

Quoted 4 lines
drivers/acpi/processor_core.c +0 -0
 	acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
 			    ACPI_UINT32_MAX,
 
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author
#4 lore raw

Re: [PATCH v2 1/3] ACPI / idle: Make idle_boot_override depend on x86 and ia64

Quoted 79 lines · Rafael J. Wysocki
Quoted 62 lines · Hanjun Guo

idle_boot_override depends on x86 and ia64 now, and we can not foresee it will be used on ARM or ARM64,so move the code into CONFIG_X86 and CONFIG_IA64 #ifdefs to make processor_core.c can be compiled on ARM64.

---
 drivers/acpi/processor_core.c |   40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)
drivers/acpi/processor_core.c +19 -18
index 46583d7..01b2656 100644
@@ -19,24 +19,6 @@
 #define _COMPONENT		ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("processor_core");
 
-static int __init set_no_mwait(const struct dmi_system_id *id)
-{
-	printk(KERN_NOTICE PREFIX "%s detected - "
-		"disabling mwait for CPU C-states\n", id->ident);
-	boot_option_idle_override = IDLE_NOMWAIT;
-	return 0;
-}
-
-static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
-	{
-	set_no_mwait, "Extensa 5220", {
-	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
-	DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-	DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
-	DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
-	{},
-};
-
 static int map_lapic_id(struct acpi_subtable_header *entry,
 		 u32 acpi_id, int *apic_id)
 {
@@ -379,13 +361,35 @@ early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
 	return AE_OK;
 }
 
+#if defined(CONFIG_X86) || defined(CONFIG_IA64)
+static int __init set_no_mwait(const struct dmi_system_id *id)
+{
+	printk(KERN_NOTICE PREFIX "%s detected - "
+		"disabling mwait for CPU C-states\n", id->ident);
+	boot_option_idle_override = IDLE_NOMWAIT;
+	return 0;
+}
+
+static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
+	{
+	set_no_mwait, "Extensa 5220", {
+	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
+	DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+	DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
+	DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
+	{},
+};
+#endif

drivers/acpi/processor_core.c early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv) · line 392

Quoted 10 lines
drivers/acpi/processor_core.c +3 -0
+
 void __init acpi_early_processor_set_pdc(void)
 {
+#if defined(CONFIG_X86) || defined(CONFIG_IA64)
 	/*
 	 * Check whether the system is DMI table. If yes, OSPM
 	 * should not use mwait for CPU-states.
 	 */
 	dmi_check_system(processor_idle_dmi_table);
+#endif

Please define processor_dmi_check() under the #if above and an empty static inline counterpart of it for the case when the #if condition is not satisfied. Then just call processor_dmi_check() here without the #if block in the body of the function.

Quoted 1 line

There is a general rule to avoid preprocessor directives in function bodies.

Ok,will update soon, thanks for the comments.

Thanks
Hanjun

author
#5 lore raw

PATCH v2 2/3 ACPI / processor_core: Rework _PDC related stuff to make it more arch-independent

In reply to Hanjun Guo

_PDC related stuff in processor_core.c is little bit X86/IA64 dependent, rework the code to make it more arch-independent, no functional change in this patch.

---
 arch/ia64/include/asm/acpi.h  |    5 +----
 arch/ia64/kernel/acpi.c       |   17 +++++++++++++++++
 arch/x86/include/asm/acpi.h   |   19 +------------------
 arch/x86/kernel/acpi/cstate.c |   31 +++++++++++++++++++++++++++++++
 drivers/acpi/processor_core.c |   19 +------------------
 5 files changed, 51 insertions(+), 40 deletions(-)
arch/ia64/include/asm/acpi.h +1 -4
index d651102..d2b8b9d 100644
@@ -152,10 +152,7 @@ extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
 #endif
 
 static inline bool arch_has_acpi_pdc(void) { return true; }
-static inline void arch_acpi_set_pdc_bits(u32 *buf)
-{
-	buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
-}
+extern void arch_acpi_set_pdc_bits(u32 *buf);
 
 #define acpi_unlazy_tlb(x)
 
arch/ia64/kernel/acpi.c +17 -0
index 07d209c..d71f64a 100644
@@ -1014,3 +1014,20 @@ EXPORT_SYMBOL(acpi_unregister_ioapic);
  * TBD when when IA64 starts to support suspend...
  */
 int acpi_suspend_lowlevel(void) { return 0; }
+
+void arch_acpi_set_pdc_bits(u32 *buf)
+{
+	/* Enable coordination with firmware's _TSD info */
+	buf[2] |= ACPI_PDC_SMP_T_SWCOORD;
+	if (boot_option_idle_override == IDLE_NOMWAIT) {
+		/*
+		 * If mwait is disabled for CPU C-states, the C2C3_FFH access
+		 * mode will be disabled in the parameter of _PDC object.
+		 * Of course C1_FFH access mode will also be disabled.
+		 */
+		buf[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
+
+	}
+
+	buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
+}
arch/x86/include/asm/acpi.h +1 -18
index c8c1e70..e9f71bc 100644
@@ -147,24 +147,7 @@ static inline bool arch_has_acpi_pdc(void)
 		c->x86_vendor == X86_VENDOR_CENTAUR);
 }
 
-static inline void arch_acpi_set_pdc_bits(u32 *buf)
-{
-	struct cpuinfo_x86 *c = &cpu_data(0);
-
-	buf[2] |= ACPI_PDC_C_CAPABILITY_SMP;
-
-	if (cpu_has(c, X86_FEATURE_EST))
-		buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
-
-	if (cpu_has(c, X86_FEATURE_ACPI))
-		buf[2] |= ACPI_PDC_T_FFH;
-
-	/*
-	 * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
-	 */
-	if (!cpu_has(c, X86_FEATURE_MWAIT))
-		buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
-}
+extern void arch_acpi_set_pdc_bits(u32 *buf);
 
 #else /* !CONFIG_ACPI */
 
arch/x86/kernel/acpi/cstate.c +31 -0
index e69182f..aa9aed9 100644
@@ -16,6 +16,37 @@
 #include <asm/mwait.h>
 #include <asm/special_insns.h>
 
+void arch_acpi_set_pdc_bits(u32 *buf)
+{
+	struct cpuinfo_x86 *c = &cpu_data(0);
+
+	/* Enable coordination with firmware's _TSD info */
+	buf[2] |= ACPI_PDC_SMP_T_SWCOORD;
+	if (boot_option_idle_override == IDLE_NOMWAIT) {
+		/*
+		 * If mwait is disabled for CPU C-states, the C2C3_FFH access
+		 * mode will be disabled in the parameter of _PDC object.
+		 * Of course C1_FFH access mode will also be disabled.
+		 */
+		buf[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
+
+	}
+
+	buf[2] |= ACPI_PDC_C_CAPABILITY_SMP;
+
+	if (cpu_has(c, X86_FEATURE_EST))
+		buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
+
+	if (cpu_has(c, X86_FEATURE_ACPI))
+		buf[2] |= ACPI_PDC_T_FFH;
+
+	/*
+	 * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
+	 */
+	if (!cpu_has(c, X86_FEATURE_MWAIT))
+		buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
+}
+
 /*
  * Initialize bm_flags based on the CPU cache properties
  * On SMP it depends on cache configuration
drivers/acpi/processor_core.c +1 -18
index 01b2656..31a4281 100644
@@ -255,9 +255,6 @@ static void acpi_set_pdc_bits(u32 *buf)
 	buf[0] = ACPI_PDC_REVISION_ID;
 	buf[1] = 1;
 
-	/* Enable coordination with firmware's _TSD info */
-	buf[2] = ACPI_PDC_SMP_T_SWCOORD;
-
 	/* Twiddle arch-specific bits needed for _PDC */
 	arch_acpi_set_pdc_bits(buf);
 }
@@ -282,7 +279,7 @@ static struct acpi_object_list *acpi_processor_alloc_pdc(void)
 		return NULL;
 	}
 
-	buf = kmalloc(12, GFP_KERNEL);
+	buf = kzalloc(12, GFP_KERNEL);
 	if (!buf) {
 		printk(KERN_ERR "Memory allocation error\n");
 		kfree(obj);
@@ -310,20 +307,6 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
 {
 	acpi_status status = AE_OK;
 
-	if (boot_option_idle_override == IDLE_NOMWAIT) {
-		/*
-		 * If mwait is disabled for CPU C-states, the C2C3_FFH access
-		 * mode will be disabled in the parameter of _PDC object.
-		 * Of course C1_FFH access mode will also be disabled.
-		 */
-		union acpi_object *obj;
-		u32 *buffer = NULL;
-
-		obj = pdc_in->pointer;
-		buffer = (u32 *)(obj->buffer.pointer);
-		buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
-
-	}
 	status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL);
 
 	if (ACPI_FAILURE(status))
Signature · 1 line
1.7.9.5
#6 lore raw

Re: [PATCH v2 2/3] ACPI / processor_core: Rework _PDC related stuff to make it more arch-independent

2014-02-08 21:10 GMT+08:00 Hanjun Guo <[email protected]>:

Quoted 35 lines

_PDC related stuff in processor_core.c is little bit X86/IA64 dependent, rework the code to make it more arch-independent, no functional change in this patch.

---
 arch/ia64/include/asm/acpi.h  |    5 +----
 arch/ia64/kernel/acpi.c       |   17 +++++++++++++++++
 arch/x86/include/asm/acpi.h   |   19 +------------------
 arch/x86/kernel/acpi/cstate.c |   31 +++++++++++++++++++++++++++++++
 drivers/acpi/processor_core.c |   19 +------------------
 5 files changed, 51 insertions(+), 40 deletions(-)
arch/ia64/include/asm/acpi.h +1 -4
index d651102..d2b8b9d 100644
@@ -152,10 +152,7 @@ extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
 #endif
 
 static inline bool arch_has_acpi_pdc(void) { return true; }
-static inline void arch_acpi_set_pdc_bits(u32 *buf)
-{
-       buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
-}
+extern void arch_acpi_set_pdc_bits(u32 *buf);
 
 #define acpi_unlazy_tlb(x)
 
arch/ia64/kernel/acpi.c +0 -0
index 07d209c..d71f64a 100644

arch/ia64/kernel/acpi.c EXPORT_SYMBOL(acpi_unregister_ioapic); · line 1021

Quoted 8 lines
arch/ia64/kernel/acpi.c +5 -0
@@ -1014,3 +1014,20 @@ EXPORT_SYMBOL(acpi_unregister_ioapic);
  * TBD when when IA64 starts to support suspend...
  */
 int acpi_suspend_lowlevel(void) { return 0; }
+
+void arch_acpi_set_pdc_bits(u32 *buf)
+{
+       /* Enable coordination with firmware's _TSD info */
+       buf[2] |= ACPI_PDC_SMP_T_SWCOORD;

Hi Hanjun:
You can write like this.
buf[2] |= ACPI_PDC_SMP_T_SWCOORD | ACPI_PDC_EST_CAPABILITY_SMP;

Quoted 57 lines
arch/ia64/kernel/acpi.c +12 -0
+       if (boot_option_idle_override == IDLE_NOMWAIT) {
+               /*
+                * If mwait is disabled for CPU C-states, the C2C3_FFH access
+                * mode will be disabled in the parameter of _PDC object.
+                * Of course C1_FFH access mode will also be disabled.
+                */
+               buf[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
+
+       }
+
+       buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
+}
arch/x86/include/asm/acpi.h +1 -18
index c8c1e70..e9f71bc 100644
@@ -147,24 +147,7 @@ static inline bool arch_has_acpi_pdc(void)
                c->x86_vendor == X86_VENDOR_CENTAUR);
 }
 
-static inline void arch_acpi_set_pdc_bits(u32 *buf)
-{
-       struct cpuinfo_x86 *c = &cpu_data(0);
-
-       buf[2] |= ACPI_PDC_C_CAPABILITY_SMP;
-
-       if (cpu_has(c, X86_FEATURE_EST))
-               buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
-
-       if (cpu_has(c, X86_FEATURE_ACPI))
-               buf[2] |= ACPI_PDC_T_FFH;
-
-       /*
-        * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
-        */
-       if (!cpu_has(c, X86_FEATURE_MWAIT))
-               buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
-}
+extern void arch_acpi_set_pdc_bits(u32 *buf);
 
 #else /* !CONFIG_ACPI */
 
arch/x86/kernel/acpi/cstate.c +7 -0
index e69182f..aa9aed9 100644
@@ -16,6 +16,37 @@
 #include <asm/mwait.h>
 #include <asm/special_insns.h>
 
+void arch_acpi_set_pdc_bits(u32 *buf)
+{
+       struct cpuinfo_x86 *c = &cpu_data(0);
+
+       /* Enable coordination with firmware's _TSD info */
+       buf[2] |= ACPI_PDC_SMP_T_SWCOORD;
+       if (boot_option_idle_override == IDLE_NOMWAIT) {

arch/x86/kernel/acpi/cstate.c line 35

Quoted 10 lines
arch/x86/kernel/acpi/cstate.c +10 -0
+               /*
+                * If mwait is disabled for CPU C-states, the C2C3_FFH access
+                * mode will be disabled in the parameter of _PDC object.
+                * Of course C1_FFH access mode will also be disabled.
+                */
+               buf[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
+
+       }
+
+       buf[2] |= ACPI_PDC_C_CAPABILITY_SMP;

This is not right. ACPI_PDC_C_CAPABILITY_SMP contians ACPI_PDC_C_C1_FFH and ACPI_PDC_C_C2C3_FFH. boot_option_idle_override is meaningless here.

You should keep original order and put the check at last.

Quoted 68 lines
arch/x86/kernel/acpi/cstate.c +14 -0
+
+       if (cpu_has(c, X86_FEATURE_EST))
+               buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
+
+       if (cpu_has(c, X86_FEATURE_ACPI))
+               buf[2] |= ACPI_PDC_T_FFH;
+
+       /*
+        * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
+        */
+       if (!cpu_has(c, X86_FEATURE_MWAIT))
+               buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
+}
+
 /*
  * Initialize bm_flags based on the CPU cache properties
  * On SMP it depends on cache configuration
drivers/acpi/processor_core.c +1 -19
index 01b2656..31a4281 100644
@@ -255,9 +255,6 @@ static void acpi_set_pdc_bits(u32 *buf)
        buf[0] = ACPI_PDC_REVISION_ID;
        buf[1] = 1;
 
-       /* Enable coordination with firmware's _TSD info */
-       buf[2] = ACPI_PDC_SMP_T_SWCOORD;
-
        /* Twiddle arch-specific bits needed for _PDC */
        arch_acpi_set_pdc_bits(buf);
 }
@@ -282,7 +279,7 @@ static struct acpi_object_list *acpi_processor_alloc_pdc(void)
                return NULL;
        }
 
-       buf = kmalloc(12, GFP_KERNEL);
+       buf = kzalloc(12, GFP_KERNEL);
        if (!buf) {
                printk(KERN_ERR "Memory allocation error\n");
                kfree(obj);
@@ -310,20 +307,6 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
 {
        acpi_status status = AE_OK;
 
-       if (boot_option_idle_override == IDLE_NOMWAIT) {
-               /*
-                * If mwait is disabled for CPU C-states, the C2C3_FFH access
-                * mode will be disabled in the parameter of _PDC object.
-                * Of course C1_FFH access mode will also be disabled.
-                */
-               union acpi_object *obj;
-               u32 *buffer = NULL;
-
-               obj = pdc_in->pointer;
-               buffer = (u32 *)(obj->buffer.pointer);
-               buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
-
-       }
        status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL);
 
        if (ACPI_FAILURE(status))
--

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Best regards
Tianyu Lan
author
#7 lore raw

Re: [PATCH v2 2/3] ACPI / processor_core: Rework _PDC related stuff to make it more arch-independent

Hi Tianyu,

Quoted 31 lines · Lan Tianyu

2014-02-08 21:10 GMT+08:00 Hanjun Guo <[email protected]>:

Quoted 30 lines

_PDC related stuff in processor_core.c is little bit X86/IA64 dependent, rework the code to make it more arch-independent, no functional change in this patch.

---
  arch/ia64/include/asm/acpi.h  |    5 +----
  arch/ia64/kernel/acpi.c       |   17 +++++++++++++++++
  arch/x86/include/asm/acpi.h   |   19 +------------------
  arch/x86/kernel/acpi/cstate.c |   31 +++++++++++++++++++++++++++++++
  drivers/acpi/processor_core.c |   19 +------------------
  5 files changed, 51 insertions(+), 40 deletions(-)
arch/ia64/include/asm/acpi.h +1 -4
index d651102..d2b8b9d 100644
@@ -152,10 +152,7 @@ extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
  #endif
 
  static inline bool arch_has_acpi_pdc(void) { return true; }
-static inline void arch_acpi_set_pdc_bits(u32 *buf)
-{
-       buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
-}
+extern void arch_acpi_set_pdc_bits(u32 *buf);
 
  #define acpi_unlazy_tlb(x)
 
Quoted 16 lines

arch/ia64/kernel/acpi.c EXPORT_SYMBOL(acpi_unregister_ioapic); · line 1021

Quoted 13 lines
arch/ia64/kernel/acpi.c +5 -0
index 07d209c..d71f64a 100644
@@ -1014,3 +1014,20 @@ EXPORT_SYMBOL(acpi_unregister_ioapic);
   * TBD when when IA64 starts to support suspend...
   */
  int acpi_suspend_lowlevel(void) { return 0; }
+
+void arch_acpi_set_pdc_bits(u32 *buf)
+{
+       /* Enable coordination with firmware's _TSD info */
+       buf[2] |= ACPI_PDC_SMP_T_SWCOORD;

Hi Hanjun:
You can write like this.
buf[2] |= ACPI_PDC_SMP_T_SWCOORD | ACPI_PDC_EST_CAPABILITY_SMP;

Thanks for the suggestion, will update it.

Quoted 71 lines
Quoted 58 lines
arch/ia64/kernel/acpi.c +12 -0
+       if (boot_option_idle_override == IDLE_NOMWAIT) {
+               /*
+                * If mwait is disabled for CPU C-states, the C2C3_FFH access
+                * mode will be disabled in the parameter of _PDC object.
+                * Of course C1_FFH access mode will also be disabled.
+                */
+               buf[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
+
+       }
+
+       buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
+}
arch/x86/include/asm/acpi.h +1 -18
index c8c1e70..e9f71bc 100644
@@ -147,24 +147,7 @@ static inline bool arch_has_acpi_pdc(void)
                 c->x86_vendor == X86_VENDOR_CENTAUR);
  }
 
-static inline void arch_acpi_set_pdc_bits(u32 *buf)
-{
-       struct cpuinfo_x86 *c = &cpu_data(0);
-
-       buf[2] |= ACPI_PDC_C_CAPABILITY_SMP;
-
-       if (cpu_has(c, X86_FEATURE_EST))
-               buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
-
-       if (cpu_has(c, X86_FEATURE_ACPI))
-               buf[2] |= ACPI_PDC_T_FFH;
-
-       /*
-        * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
-        */
-       if (!cpu_has(c, X86_FEATURE_MWAIT))
-               buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
-}
+extern void arch_acpi_set_pdc_bits(u32 *buf);
 
  #else /* !CONFIG_ACPI */
 
arch/x86/kernel/acpi/cstate.c +7 -0
index e69182f..aa9aed9 100644
@@ -16,6 +16,37 @@
  #include <asm/mwait.h>
  #include <asm/special_insns.h>
 
+void arch_acpi_set_pdc_bits(u32 *buf)
+{
+       struct cpuinfo_x86 *c = &cpu_data(0);
+
+       /* Enable coordination with firmware's _TSD info */
+       buf[2] |= ACPI_PDC_SMP_T_SWCOORD;
+       if (boot_option_idle_override == IDLE_NOMWAIT) {

arch/x86/kernel/acpi/cstate.c line 35

Quoted 10 lines
arch/x86/kernel/acpi/cstate.c +10 -0
+               /*
+                * If mwait is disabled for CPU C-states, the C2C3_FFH access
+                * mode will be disabled in the parameter of _PDC object.
+                * Of course C1_FFH access mode will also be disabled.
+                */
+               buf[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
+
+       }
+
+       buf[2] |= ACPI_PDC_C_CAPABILITY_SMP;

This is not right. ACPI_PDC_C_CAPABILITY_SMP contians ACPI_PDC_C_C1_FFH and ACPI_PDC_C_C2C3_FFH. boot_option_idle_override is meaningless here.

Quoted 1 line

You should keep original order and put the check at last.

Good catch! I will update this patch, thanks for your review :)

Best regards
Hanjun
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#8 lore raw

PATCH v2 3/3 ACPI: Introduce map_gic_id() to get apic id from MADT or _MAT method

In reply to Hanjun Guo

Get apic id from MADT or _MAT method is not implemented on arm/arm64, and ACPI 5.0 introduces GIC Structure for it, so this patch introduces map_gic_id() to get apic id followed the ACPI 5.0 spec.

---
 drivers/acpi/processor_core.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/acpi/processor_core.c +26 -0
index 31a4281..5a50f03 100644
@@ -71,6 +71,27 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
 	return 0;
 }
 
+static int map_gic_id(struct acpi_subtable_header *entry,
+		int device_declaration, u32 acpi_id, int *apic_id)
+{
+	struct acpi_madt_generic_interrupt *gic =
+		(struct acpi_madt_generic_interrupt *)entry;
+
+	if (!(gic->flags & ACPI_MADT_ENABLED))
+		return -ENODEV;
+
+	/* In the GIC interrupt model, logical processors are
+	 * required to have a Processor Device object in the DSDT,
+	 * so we should check device_declaration here
+	 */
+	if (device_declaration && (gic->uid == acpi_id)) {
+		*apic_id = gic->gic_id;
+		return 0;
+	}
+
+	return -EINVAL;
+}
+
 static int map_madt_entry(int type, u32 acpi_id)
 {
 	unsigned long madt_end, entry;
@@ -106,6 +127,9 @@ static int map_madt_entry(int type, u32 acpi_id)
 		} else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
 			if (!map_lsapic_id(header, type, acpi_id, &apic_id))
 				break;
+		} else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
+			if (!map_gic_id(header, type, acpi_id, &apic_id))
+				break;
 		}
 		entry += header->length;
 	}
@@ -136,6 +160,8 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
 		map_lapic_id(header, acpi_id, &apic_id);
 	} else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
 		map_lsapic_id(header, type, acpi_id, &apic_id);
+	} else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
+		map_gic_id(header, type, acpi_id, &apic_id);
 	}
 
 exit:
Signature · 1 line
1.7.9.5