ACPI / processor_idle: Add ACPI v6.0 LPI support
v10 cover ACPI / processor_idle: Add ACPI v6.0 LPI support
ACPI 6.0 introduced LPI(Low Power Idle) states that provides an alternate method to describe processor idle states. It extends the specification to allow the expression of idle states like C-states selectable by the OSPM when a processor goes idle, but may affect more than one processor, and may affect other system components.
LPI extensions leverages the processor container device(again introduced in ACPI 6.0) allowing to express which parts of the system are affected by a given LPI state. It defines the local power states for each node in a hierarchical processor topology. The OSPM can use _LPI object to select a local power state for each level of processor hierarchy in the system. They used to produce a composite power state request that is presented to the platform by the OSPM.
Since multiple processors affect the idle state for any non-leaf hierarchy node, coordination of idle state requests between the processors is required. ACPI supports two different coordination schemes: Platform coordinated and OS initiated.
This series aims at providing basic and initial support for platform coordinated LPI states.
v9[9]->v10:
- Incorporated all the review comments from Rafael
- Mainly removed allocation of memory for all the levels in the hierarchy and remove the recursion in flatten_lpi_tree logic
v8[8]->v9:
- Split the psci and arm64 changes into separate patches as suggested by Lorenzo and added his ACKs
- Renamed CPU_IDLE_ENTER_WRAPPED to CPU_PM_CPU_IDLE_ENTER
v7[7]->v8:
- Replaced HAVE_GENERIC_CPUIDLE_ENTER with CPU_IDLE_ENTER_WRAPPED macro, which is more cleaner and definately less confusing :) (Thanks to Rafael for the suggestion)
v6[6]->v7:
- Removed cpuidle-arm.h and introduced HAVE_GENERIC_CPUIDLE_ENTER and move the common code to cpuidle_generic_enter{,_state}
- Factored out common code between psci_{dt,acpi}_cpu_init_idle
v5[5]->v6:
- Added support for autopromotable state by not flattening them
- Moved arm_enter_idle_state to cpuidle-arm.h as it can be reused in ARM64 backend for ACPI LPI
- Other review comments(mainly for ARM64 from Lorenzo)
- Dropped support for skipping PM notifier as it needs to be fixed in GICv3 code(will be done separately)
v4[4]->v5:
- Addressed all the comments from Rafael
- Added support for retention mode(Prashant)
- Handled acpi_processor_get_power_info return value correctly(Vikas)
- Dropped __init from arm_cpuidle_init
- Merged psci prepartory patch into arm64 lpi support
v3[3]->v4:
- Dropped the preparatory patches that are merged already
- Added ARM64 arch specific callback implementations
- Addressed most of the review comments from Rafael
v2[2]->v3:
- rebased against v4.4-rc3
- fixed couple of issues reported by Prashanth and review comments from Ashwin
v1[1]->v2[2]:
- Fixed support for ACPI0010 processor container
- moved sleep state code out of processor_idle
Code is also available @[9]
Regards,
Sudeep
[1] http://marc.info/?l=linux-acpi&m=143871041601132&w=2
[2] http://marc.info/?l=linux-acpi&m=144241209800788&w=2
[3] http://marc.info/?l=linux-acpi&m=144906557814813&w=2
[4] http://marc.info/?l=linux-acpi&m=146106902731359&w=2
[5] http://marc.info/?l=linux-acpi&m=146298107608349&w=2
[6] http://marc.info/?l=linux-acpi&m=146591573516602&w=2
[7] http://marc.info/?l=linux-acpi&m=146712226917361&w=2
[8] http://marc.info/?l=linux-acpi&m=146791146605094&w=2
[9] http://marc.info/?l=linux-arm-kernel&m=146799779029061&w=2
[10] git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git for_review/arm64_lpi
Sudeep Holla (7):
ACPI / processor_idle: introduce ACPI_PROCESSOR_CSTATE ACPI / processor_idle: Add support for Low Power Idle(LPI) states
arm64: cpuidle: drop __init section marker to arm_cpuidle_init
cpuidle: introduce CPU_PM_CPU_IDLE_ENTER macro for ARM{32,64}
drivers: firmware: psci: initialise idle states using ACPI LPI
arm64: add support for ACPI Low Power Idle(LPI)
ACPI : enable ACPI_PROCESSOR_IDLE on ARM64
arch/arm64/kernel/cpuidle.c | 20 +- drivers/acpi/Kconfig | 6 +- drivers/acpi/bus.c | 14 +- drivers/acpi/processor_driver.c | 2 +- drivers/acpi/processor_idle.c | 538 ++++++++++++++++++++++++++++++++++------ drivers/cpuidle/cpuidle-arm.c | 26 +- drivers/firmware/psci.c | 66 ++++- include/acpi/processor.h | 26 +- include/linux/acpi.h | 4 + include/linux/cpuidle.h | 18 ++ 10 files changed, 605 insertions(+), 115 deletions(-)
Signature · 1 line
2.7.4
PATCH v10 1/7 ACPI / processor_idle: introduce ACPI_PROCESSOR_CSTATE
ACPI 6.0 adds a new method to specify the CPU idle states(C-states) called Low Power Idle(LPI) states. Since new architectures like ARM64 use only LPIs, introduce ACPI_PROCESSOR_CSTATE to encapsulate all the code supporting the old style C-states(_CST).
This patch will help to extend the processor_idle module to support LPI.
--- drivers/acpi/Kconfig | 4 +++ drivers/acpi/processor_idle.c | 80 ++++++++++++++++++++++++++++--------------- include/acpi/processor.h | 2 +- 3 files changed, 58 insertions(+), 28 deletions(-)
drivers/acpi/Kconfig +4 -0
@@ -213,6 +213,10 @@ config ACPI_CPU_FREQ_PSS bool select THERMAL +config ACPI_PROCESSOR_CSTATE + def_bool y + depends on IA64 || X86 + config ACPI_PROCESSOR_IDLE bool select CPU_IDLE
drivers/acpi/processor_idle.c +53 -27
111 lines not on this page · raw message
include/acpi/processor.h +1 -1
@@ -242,7 +242,7 @@ extern int acpi_processor_get_performance_info(struct acpi_processor *pr); DECLARE_PER_CPU(struct acpi_processor *, processors);extern struct acpi_processor_errata errata; -#ifdef ARCH_HAS_POWER_INIT +#if defined(ARCH_HAS_POWER_INIT ) && defined(CONFIG_ACPI_PROCESSOR_CSTATE )void acpi_processor_power_init_bm_check (struct acpi_processor_flags *flags,unsigned int cpu); int acpi_processor_ffh_cstate_probe(unsigned int cpu,
Signature · 1 line
2.7.4
PATCH v10 2/7 ACPI / processor_idle: Add support for Low Power Idle(LPI) states
In reply to Sudeep HollaACPI 6.0 introduced an optional object _LPI that provides an alternate method to describe Low Power Idle states. It defines the local power states for each node in a hierarchical processor topology. The OSPM can use _LPI object to select a local power state for each level of processor hierarchy in the system. They used to produce a composite power state request that is presented to the platform by the OSPM.
Since multiple processors affect the idle state for any non-leaf hierarchy node, coordination of idle state requests between the processors is required. ACPI supports two different coordination schemes: Platform coordinated and OS initiated.
This patch adds initial support for Platform coordination scheme of LPI.
--- drivers/acpi/bus.c | 14 +- drivers/acpi/processor_driver.c | 2 +- drivers/acpi/processor_idle.c | 462 +++++++++++++++++++++++++++++++++++----- include/acpi/processor.h | 24 ++- include/linux/acpi.h | 4 + 5 files changed, 446 insertions(+), 60 deletions(-)
drivers/acpi/bus.c +13 -1
@@ -302,6 +302,14 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)EXPORT_SYMBOL (acpi_run_osc);bool osc_sb_apei_support_acked; + +/* +* ACPI 6.0 Section 8.4.4.2 Idle State Coordination +* OSPM supports platform coordinated low power idle(LPI) states +*/ +bool osc_pc_lpi_support_confirmed; +EXPORT_SYMBOL_GPL (osc_pc_lpi_support_confirmed); +static u8 sb_uuid_str[] ="0811B06E-4A27-44F9-8D60-3CBBC22E7B48" ;static void acpi_bus_osc_support (void ) {
@@ -322,6 +330,7 @@ static void acpi_bus_osc_support(void) capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_PPC_OST_SUPPORT ; capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_HOTPLUG_OST_SUPPORT ; + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_PCLPI_SUPPORT ;if (!ghes_disable) capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_APEI_SUPPORT ;
@@ -329,9 +338,12 @@ static void acpi_bus_osc_support(void)return ;if (ACPI_SUCCESS (acpi_run_osc (handle, &context))) {u32 *capbuf_ret = context.ret.pointer; -if (context.ret.length >OSC_SUPPORT_DWORD ) +if (context.ret.length >OSC_SUPPORT_DWORD ) { osc_sb_apei_support_acked = capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_APEI_SUPPORT ; + osc_pc_lpi_support_confirmed = + capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_PCLPI_SUPPORT ; + }kfree (context.ret.pointer); }/* do we need to check other returned cap? Sounds no */
drivers/acpi/processor_driver.c +1 -1
@@ -90,7 +90,7 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) pr->performance_platform_limit);break ;case ACPI_PROCESSOR_NOTIFY_POWER : -acpi_processor_cst_has_changed (pr); +acpi_processor_power_state_has_changed (pr);acpi_bus_generate_netlink_event (device->pnp.device_class,dev_name (&device->dev), event,0 );break ;
drivers/acpi/processor_idle.c +407 -55
558 lines not on this page · raw message
include/acpi/processor.h +21 -3
@@ -39,6 +39,7 @@#define ACPI_CSTATE_SYSTEMIO 0#define ACPI_CSTATE_FFH 1#define ACPI_CSTATE_HALT 2 +#define ACPI_CSTATE_INTEGER 3#define ACPI_CX_DESC_LEN 32
@@ -67,9 +68,25 @@ struct acpi_processor_cx {char desc[ACPI_CX_DESC_LEN ]; }; +struct acpi_lpi_state { +u32 min_residency; +u32 wake_latency;/* worst case */ +u32 flags; +u32 arch_flags; +u32 res_cnt_freq; +u32 enable_parent_state; +u64 address; +u8 index; +u8 entry_method; +char desc[ACPI_CX_DESC_LEN ]; +}; +struct acpi_processor_power {int count; -struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER ]; +union { +struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER ]; +struct acpi_lpi_state lpi_states[ACPI_PROCESSOR_MAX_POWER ]; + };int timer_broadcast_on_state; };
@@ -189,6 +206,7 @@ struct acpi_processor_flags { u8 bm_control:1; u8 bm_check:1; u8 has_cst:1; + u8 has_lpi:1; u8 power_setup_done:1; u8 bm_rld_set:1; u8 need_hotplug_init:1;
@@ -371,7 +389,7 @@ extern struct cpuidle_driver acpi_idle_driver;#ifdef CONFIG_ACPI_PROCESSOR_IDLE int acpi_processor_power_init (struct acpi_processor *pr);int acpi_processor_power_exit (struct acpi_processor *pr); -int acpi_processor_cst_has_changed (struct acpi_processor *pr); +int acpi_processor_power_state_has_changed (struct acpi_processor *pr);int acpi_processor_hotplug (struct acpi_processor *pr);#else static inline int acpi_processor_power_init (struct acpi_processor *pr)
@@ -384,7 +402,7 @@ static inline int acpi_processor_power_exit(struct acpi_processor *pr)return -ENODEV ; } -static inline int acpi_processor_cst_has_changed (struct acpi_processor *pr) +static inline int acpi_processor_power_state_has_changed (struct acpi_processor *pr) {return -ENODEV ; }
include/linux/acpi.h +4 -0
@@ -444,8 +444,12 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);#define OSC_SB_HOTPLUG_OST_SUPPORT 0x00000008#define OSC_SB_APEI_SUPPORT 0x00000010#define OSC_SB_CPC_SUPPORT 0x00000020 +#define OSC_SB_CPCV2_SUPPORT 0x00000040 +#define OSC_SB_PCLPI_SUPPORT 0x00000080 +#define OSC_SB_OSLPI_SUPPORT 0x00000100extern bool osc_sb_apei_support_acked; +extern bool osc_pc_lpi_support_confirmed;/* PCI Host Bridge _OSC: Capabilities DWORD 2: Support Field */ #define OSC_PCI_EXT_CONFIG_SUPPORT 0x00000001
Signature · 1 line
2.7.4
Re: [PATCH v10 2/7] ACPI / processor_idle: Add support for Low Power Idle(LPI) states
Quoted 24 lines · Sudeep Holla
ACPI 6.0 introduced an optional object
_LPIthat provides an alternate method to describe Low Power Idle states. It defines the local power states for each node in a hierarchical processor topology. The OSPM can use_LPIobject to select a local power state for each level of processor hierarchy in the system. They used to produce a composite power state request that is presented to the platform by the OSPM.Since multiple processors affect the idle state for any non-leaf hierarchy node, coordination of idle state requests between the processors is required. ACPI supports two different coordination schemes: Platform coordinated and OS initiated.
This patch adds initial support for Platform coordination scheme of LPI.
Cc "Rafael J. Wysocki" <[email protected]>Signed-off-by Sudeep Holla <[email protected]>--- drivers/acpi/bus.c | 14 +- drivers/acpi/processor_driver.c | 2 +- drivers/acpi/processor_idle.c | 462 +++++++++++++++++++++++++++++++++++----- include/acpi/processor.h | 24 ++- include/linux/acpi.h | 4 + 5 files changed, 446 insertions(+), 60 deletions(-)
[cut]
Quoted 14 lines
drivers/acpi/processor_idle.c +14
-0+static int acpi_processor_get_lpi_info (struct acpi_processor *pr) +{ +int ret, i; +acpi_status status; +acpi_handle handle = pr->handle, pr_ahandle; +struct acpi_device *d =NULL ; +struct acpi_lpi_states_array info[2 ], *tmp, *prev, *curr; + +if (!osc_pc_lpi_support_confirmed) +return -EOPNOTSUPP ; + +if (!acpi_has_method (handle,"_LPI" )) +return -EINVAL ; +
drivers/acpi/processor_idle.c static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr, · line 1176
Quoted 10 lines
drivers/acpi/processor_idle.c +10
-0+ flat_state_cnt =0 ; + prev = &info[0 ]; + curr = &info[1 ]; + handle = pr->handle; + ret =acpi_processor_evaluate_lpi (handle, prev); +if (ret) +return ret; +flatten_lpi_states (pr, prev,NULL ); + +while (ACPI_SUCCESS (status =acpi_get_parent (handle, &pr_ahandle))) {
I should have mentioned that earlier, but forgot, sorry about that.
Assignments under while () etc are generally discouraged as (a) error-prone and (b) confusing to static analysis tools.
So I'd do
status = acpi_get_parent(handle, &pr_ahandle);
while (ACPI_SUCCESS(status)) {Quoted 8 lines
drivers/acpi/processor_idle.c +8
-0+acpi_bus_get_device (pr_ahandle, &d); + handle = pr_ahandle; + +if (strcmp (acpi_device_hid (d),ACPI_PROCESSOR_CONTAINER_HID )) +break ; + +/* can be optional ? */ +if (!acpi_has_method (handle,"_LPI" ))
drivers/acpi/processor_idle.c static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr, · line 1194
Quoted 10 lines
drivers/acpi/processor_idle.c +10
-0+break ; + + ret =acpi_processor_evaluate_lpi (handle, curr); +if (ret) +break ; + +/* flatten all the LPI states in this level of hierarchy */ +flatten_lpi_states (pr, curr, prev); + + tmp = prev, prev = curr, curr = tmp;
status = acpi_get_parent(handle, &pr_ahandle);
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +
Apart from this the patch looks OK to me, so please only update this one and I'll queue up the series.
Thanks,
Rafael
Re: [PATCH v10 2/7] ACPI / processor_idle: Add support for Low Power Idle(LPI) states
Quoted 55 lines · Rafael J. Wysocki
Quoted 24 lines · Sudeep Holla
ACPI 6.0 introduced an optional object
_LPIthat provides an alternate method to describe Low Power Idle states. It defines the local power states for each node in a hierarchical processor topology. The OSPM can use_LPIobject to select a local power state for each level of processor hierarchy in the system. They used to produce a composite power state request that is presented to the platform by the OSPM.Since multiple processors affect the idle state for any non-leaf hierarchy node, coordination of idle state requests between the processors is required. ACPI supports two different coordination schemes: Platform coordinated and OS initiated.
This patch adds initial support for Platform coordination scheme of LPI.
Cc "Rafael J. Wysocki" <[email protected]>Signed-off-by Sudeep Holla <[email protected]>--- drivers/acpi/bus.c | 14 +- drivers/acpi/processor_driver.c | 2 +- drivers/acpi/processor_idle.c | 462 +++++++++++++++++++++++++++++++++++----- include/acpi/processor.h | 24 ++- include/linux/acpi.h | 4 + 5 files changed, 446 insertions(+), 60 deletions(-)[cut]
Quoted 14 lines
(quoted diff) +14
-0+static int acpi_processor_get_lpi_info(struct acpi_processor *pr) +{ + int ret, i; + acpi_status status; + acpi_handle handle = pr->handle, pr_ahandle; + struct acpi_device *d = NULL; + struct acpi_lpi_states_array info[2], *tmp, *prev, *curr; + + if (!osc_pc_lpi_support_confirmed) + return -EOPNOTSUPP; + + if (!acpi_has_method(handle, "_LPI")) + return -EINVAL; +Review
Quoted 10 lines
(quoted diff) +10
-0+ flat_state_cnt = 0; + prev = &info[0]; + curr = &info[1]; + handle = pr->handle; + ret = acpi_processor_evaluate_lpi(handle, prev); + if (ret) + return ret; + flatten_lpi_states(pr, prev, NULL); + + while (ACPI_SUCCESS(status = acpi_get_parent(handle, &pr_ahandle))) {I should have mentioned that earlier, but forgot, sorry about that.
Quoted 8 lines
Assignments under while () etc are generally discouraged as (a) error-prone and (b) confusing to static analysis tools.
So I'd do
status = acpi_get_parent(handle, &pr_ahandle); while (ACPI_SUCCESS(status)) {
Sure, will update accordingly.
Quoted 21 lines
Quoted 8 lines
(quoted diff) +8
-0+ acpi_bus_get_device(pr_ahandle, &d); + handle = pr_ahandle; + + if (strcmp(acpi_device_hid(d), ACPI_PROCESSOR_CONTAINER_HID)) + break; + + /* can be optional ? */ + if (!acpi_has_method(handle, "_LPI"))Review
Quoted 10 lines
(quoted diff) +10
-0+ break; + + ret = acpi_processor_evaluate_lpi(handle, curr); + if (ret) + break; + + /* flatten all the LPI states in this level of hierarchy */ + flatten_lpi_states(pr, curr, prev); + + tmp = prev, prev = curr, curr = tmp;status = acpi_get_parent(handle, &pr_ahandle);
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +
OK
Quoted 3 lines
Apart from this the patch looks OK to me, so please only update this one and I'll queue up the series.
Thanks, will do it shortly.
Also I found a bug in my testing creating some fake tables to test this non-recursive logic. I have missed a pointer update in the inner loop. I will include the below one liner in the update.
-->8
drivers/acpi/processor_idle.c +0 -0
@@ -1142,6 +1142,7 @@ static int flatten_lpi_states(struct
acpi_processor *pr,
combine_lpi_states(p, t, flpi)) {
stash_composite_state(curr_level, flpi);
flat_state_cnt++;
+ flpi++;
}
}
}Signature · 2 lines
Regards, Sudeep
PATCH v10 2/7 ACPI / processor_idle: Add support for Low Power Idle(LPI) states
In reply to Sudeep HollaACPI 6.0 introduced an optional object _LPI that provides an alternate method to describe Low Power Idle states. It defines the local power states for each node in a hierarchical processor topology. The OSPM can use _LPI object to select a local power state for each level of processor hierarchy in the system. They used to produce a composite power state request that is presented to the platform by the OSPM.
Since multiple processors affect the idle state for any non-leaf hierarchy node, coordination of idle state requests between the processors is required. ACPI supports two different coordination schemes: Platform coordinated and OS initiated.
This patch adds initial support for Platform coordination scheme of LPI.
--- drivers/acpi/bus.c | 14 +- drivers/acpi/processor_driver.c | 2 +- drivers/acpi/processor_idle.c | 466 +++++++++++++++++++++++++++++++++++----- include/acpi/processor.h | 24 ++- include/linux/acpi.h | 4 + 5 files changed, 450 insertions(+), 60 deletions(-)
Updates:
- Fixed the missing pointer update in the inner loop.
- Removed assignments under while () as suggested.
drivers/acpi/bus.c +13 -1
@@ -302,6 +302,14 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)EXPORT_SYMBOL (acpi_run_osc);bool osc_sb_apei_support_acked; + +/* +* ACPI 6.0 Section 8.4.4.2 Idle State Coordination +* OSPM supports platform coordinated low power idle(LPI) states +*/ +bool osc_pc_lpi_support_confirmed; +EXPORT_SYMBOL_GPL (osc_pc_lpi_support_confirmed); +static u8 sb_uuid_str[] ="0811B06E-4A27-44F9-8D60-3CBBC22E7B48" ;static void acpi_bus_osc_support (void ) {
@@ -322,6 +330,7 @@ static void acpi_bus_osc_support(void) capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_PPC_OST_SUPPORT ; capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_HOTPLUG_OST_SUPPORT ; + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_PCLPI_SUPPORT ;if (!ghes_disable) capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_APEI_SUPPORT ;
@@ -329,9 +338,12 @@ static void acpi_bus_osc_support(void)return ;if (ACPI_SUCCESS (acpi_run_osc (handle, &context))) {u32 *capbuf_ret = context.ret.pointer; -if (context.ret.length >OSC_SUPPORT_DWORD ) +if (context.ret.length >OSC_SUPPORT_DWORD ) { osc_sb_apei_support_acked = capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_APEI_SUPPORT ; + osc_pc_lpi_support_confirmed = + capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_PCLPI_SUPPORT ; + }kfree (context.ret.pointer); }/* do we need to check other returned cap? Sounds no */
drivers/acpi/processor_driver.c +1 -1
@@ -90,7 +90,7 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) pr->performance_platform_limit);break ;case ACPI_PROCESSOR_NOTIFY_POWER : -acpi_processor_cst_has_changed (pr); +acpi_processor_power_state_has_changed (pr);acpi_bus_generate_netlink_event (device->pnp.device_class,dev_name (&device->dev), event,0 );break ;
drivers/acpi/processor_idle.c +411 -55
562 lines not on this page · raw message
include/acpi/processor.h +21 -3
@@ -39,6 +39,7 @@#define ACPI_CSTATE_SYSTEMIO 0#define ACPI_CSTATE_FFH 1#define ACPI_CSTATE_HALT 2 +#define ACPI_CSTATE_INTEGER 3#define ACPI_CX_DESC_LEN 32
@@ -67,9 +68,25 @@ struct acpi_processor_cx {char desc[ACPI_CX_DESC_LEN ]; }; +struct acpi_lpi_state { +u32 min_residency; +u32 wake_latency;/* worst case */ +u32 flags; +u32 arch_flags; +u32 res_cnt_freq; +u32 enable_parent_state; +u64 address; +u8 index; +u8 entry_method; +char desc[ACPI_CX_DESC_LEN ]; +}; +struct acpi_processor_power {int count; -struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER ]; +union { +struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER ]; +struct acpi_lpi_state lpi_states[ACPI_PROCESSOR_MAX_POWER ]; + };int timer_broadcast_on_state; };
@@ -189,6 +206,7 @@ struct acpi_processor_flags { u8 bm_control:1; u8 bm_check:1; u8 has_cst:1; + u8 has_lpi:1; u8 power_setup_done:1; u8 bm_rld_set:1; u8 need_hotplug_init:1;
@@ -371,7 +389,7 @@ extern struct cpuidle_driver acpi_idle_driver;#ifdef CONFIG_ACPI_PROCESSOR_IDLE int acpi_processor_power_init (struct acpi_processor *pr);int acpi_processor_power_exit (struct acpi_processor *pr); -int acpi_processor_cst_has_changed (struct acpi_processor *pr); +int acpi_processor_power_state_has_changed (struct acpi_processor *pr);int acpi_processor_hotplug (struct acpi_processor *pr);#else static inline int acpi_processor_power_init (struct acpi_processor *pr)
@@ -384,7 +402,7 @@ static inline int acpi_processor_power_exit(struct acpi_processor *pr)return -ENODEV ; } -static inline int acpi_processor_cst_has_changed (struct acpi_processor *pr) +static inline int acpi_processor_power_state_has_changed (struct acpi_processor *pr) {return -ENODEV ; }
include/linux/acpi.h +4 -0
@@ -444,8 +444,12 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);#define OSC_SB_HOTPLUG_OST_SUPPORT 0x00000008#define OSC_SB_APEI_SUPPORT 0x00000010#define OSC_SB_CPC_SUPPORT 0x00000020 +#define OSC_SB_CPCV2_SUPPORT 0x00000040 +#define OSC_SB_PCLPI_SUPPORT 0x00000080 +#define OSC_SB_OSLPI_SUPPORT 0x00000100extern bool osc_sb_apei_support_acked; +extern bool osc_pc_lpi_support_confirmed;/* PCI Host Bridge _OSC: Capabilities DWORD 2: Support Field */ #define OSC_PCI_EXT_CONFIG_SUPPORT 0x00000001
Signature · 1 line
2.7.4
PATCH v10 3/7 arm64: cpuidle: drop __init section marker to arm_cpuidle_init
In reply to Sudeep HollaCommit ea389daa7fd9 ("arm64: cpuidle: add __init section marker to arm_cpuidle_init") added the __init annotation to arm_cpuidle_init as it was not needed after booting which was correct at that time.
However with the introduction of ACPI LPI support, this will be used from cpuhotplug path in ACPI processor driver.
This patch drops the __init annotation from arm_cpuidle_init to avoid the following warning:
WARNING: vmlinux.o(.text+0x113c8): Section mismatch in reference from the
function acpi_processor_ffh_lpi_probe() to the function .init.text:arm_cpuidle_init()
The function acpi_processor_ffh_lpi_probe() references
the function __init arm_cpuidle_init().
This is often because acpi_processor_ffh_lpi_probe lacks a __init annotation or the annotation of arm_cpuidle_init is wrong.
--- arch/arm64/kernel/cpuidle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/cpuidle.c +1 -1
@@ -15,7 +15,7 @@#include <asm/cpuidle.h> #include <asm/cpu_ops.h> -int __init arm_cpuidle_init (unsigned int cpu) +int arm_cpuidle_init (unsigned int cpu) {int ret = -EOPNOTSUPP ;
Signature · 1 line
2.7.4
PATCH v10 4/7 cpuidle: introduce CPU_PM_CPU_IDLE_ENTER macro for ARM{32,64}
In reply to Sudeep HollaThe function arm_enter_idle_state is exactly the same in both generic ARM{32,64} CPUIdle driver and will be the same even on ARM64 backend for ACPI processor idle driver. So we can unify it and move it to a common place by introducing CPU_PM_CPU_IDLE_ENTER macro that can be used in all places avoiding duplication.
This is in preparation of reuse of the generic cpuidle entry function for ACPI LPI support on ARM64.
--- drivers/cpuidle/cpuidle-arm.c | 26 ++++++-------------------- include/linux/cpuidle.h | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 20 deletions(-)
drivers/cpuidle/cpuidle-arm.c +6 -20
@@ -36,26 +36,12 @@static int arm_enter_idle_state (struct cpuidle_device *dev,struct cpuidle_driver *drv,int idx) { -int ret; - -if (!idx) { -cpu_do_idle (); -return idx; - } - - ret =cpu_pm_enter (); -if (!ret) { -/* -* Pass idle state index to cpu_suspend which in turn will -* call the CPU ops suspend protocol with idle index as a -* parameter. -*/ - ret =arm_cpuidle_suspend (idx); - -cpu_pm_exit (); - } - -return ret ?-1 : idx; +/* +* Pass idle state index to arm_cpuidle_suspend which in turn +* will call the CPU ops suspend protocol with idle index as a +* parameter. +*/ +return CPU_PM_CPU_IDLE_ENTER (arm_cpuidle_suspend, idx); }static struct cpuidle_driver arm_idle_driver = {
include/linux/cpuidle.h +18 -0
@@ -252,4 +252,22 @@ static inline int cpuidle_register_governor(struct cpuidle_governor *gov)#define CPUIDLE_DRIVER_STATE_START 0#endif +#define CPU_PM_CPU_IDLE_ENTER (low_level_idle_enter, idx) \ +({ \ + int __ret; \ + \ + if (!idx) { \ + cpu_do_idle(); \ + return idx; \ + } \ + \ + __ret = cpu_pm_enter(); \ + if (!__ret) { \ + __ret = low_level_idle_enter(idx); \ + cpu_pm_exit(); \ + } \ + \ + __ret ? -1 : idx; \ +}) +#endif /* _LINUX_CPUIDLE_H */
Signature · 1 line
2.7.4
PATCH v10 5/7 drivers: firmware: psci: initialise idle states using ACPI LPI
In reply to Sudeep HollaThis patch adds support for initialisation of PSCI CPUIdle states from Low Power Idle(_LPI) entries in the ACPI tables when acpi is enabled.
--- drivers/firmware/psci.c | 66 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 7 deletions(-)
drivers/firmware/psci.c +59 -7
@@ -13,6 +13,7 @@#define pr_fmt (fmt) "psci: " fmt +#include <linux/acpi.h> #include <linux/arm-smccc.h> #include <linux/cpuidle.h> #include <linux/errno.h>
@@ -256,13 +257,6 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu)u32 *psci_states;struct device_node *state_node; -/* -* If the PSCI cpu_suspend function hook has not been initialized -* idle states must not be enabled, so bail out -*/ -if (!psci_ops.cpu_suspend) -return -EOPNOTSUPP ; -/* Count idle states */ while ((state_node =of_parse_phandle (cpu_node,"cpu-idle-states" , count))) {
@@ -310,11 +304,69 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu)return ret; } +#ifdef CONFIG_ACPI +#include <acpi/processor.h> + +static int __maybe_unused psci_acpi_cpu_init_idle (unsigned int cpu) +{ +int i, count; +u32 *psci_states; +struct acpi_lpi_state *lpi; +struct acpi_processor *pr =per_cpu (processors, cpu); + +if (unlikely (!pr || !pr->flags.has_lpi)) +return -EINVAL ; + + count = pr->power.count -1 ; +if (count <=0 ) +return -ENODEV ; + + psci_states =kcalloc (count,sizeof (*psci_states),GFP_KERNEL ); +if (!psci_states) +return -ENOMEM ; + +for (i =0 ; i < count; i++) { +u32 state; + + lpi = &pr->power.lpi_states[i +1 ]; +/* +* Only bits[31:0] represent a PSCI power_state while +* bits[63:32] must be 0x0 as per ARM ACPI FFH Specification +*/ + state = lpi->address; +if (!psci_power_state_is_valid (state)) { +pr_warn ("Invalid PSCI power state %#x\n" , state); +kfree (psci_states); +return -EINVAL ; + } + psci_states[i] = state; + } +/* Idle states parsed correctly, initialize per-cpu pointer */ +per_cpu (psci_power_state, cpu) = psci_states; +return 0 ; +} +#else +static int __maybe_unused psci_acpi_cpu_init_idle (unsigned int cpu) +{ +return -EINVAL ; +} +#endif +int psci_cpu_init_idle (unsigned int cpu) {struct device_node *cpu_node;int ret; +/* +* If the PSCI cpu_suspend function hook has not been initialized +* idle states must not be enabled, so bail out +*/ +if (!psci_ops.cpu_suspend) +return -EOPNOTSUPP ; + +if (!acpi_disabled) +return psci_acpi_cpu_init_idle (cpu); + cpu_node =of_get_cpu_node (cpu,NULL );if (!cpu_node)return -ENODEV ;
Signature · 1 line
2.7.4
PATCH v10 6/7 arm64: add support for ACPI Low Power Idle(LPI)
In reply to Sudeep HollaThis patch adds appropriate callbacks to support ACPI Low Power Idle (LPI) on ARM64.
--- arch/arm64/kernel/cpuidle.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/arm64/kernel/cpuidle.c +18 -0
@@ -9,6 +9,9 @@* published by the Free Software Foundation. */ +#include <linux/acpi.h> +#include <linux/cpuidle.h> +#include <linux/cpu_pm.h> #include <linux/of.h> #include <linux/of_device.h>
@@ -39,3 +42,18 @@ int arm_cpuidle_suspend(int index)return cpu_ops[cpu]->cpu_suspend (index); } + +#ifdef CONFIG_ACPI + +#include <acpi/processor.h> + +int acpi_processor_ffh_lpi_probe (unsigned int cpu) +{ +return arm_cpuidle_init (cpu); +} + +int acpi_processor_ffh_lpi_enter (struct acpi_lpi_state *lpi) +{ +return CPU_PM_CPU_IDLE_ENTER (arm_cpuidle_suspend, lpi->index); +} +#endif
Signature · 1 line
2.7.4
PATCH v10 7/7 ACPI : enable ACPI_PROCESSOR_IDLE on ARM64
In reply to Sudeep HollaNow that ACPI processor idle driver supports LPI(Low Power Idle), lets enable ACPI_PROCESSOR_IDLE for ARM64 too.
This patch just removes the IA64 and X86 dependency on ACPI_PROCESSOR_IDLE
--- drivers/acpi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/Kconfig +1 -1
@@ -238,7 +238,7 @@ config ACPI_CPPC_LIB config ACPI_PROCESSOR tristate "Processor" depends on X86 || IA64 || ARM64 - select ACPI_PROCESSOR_IDLE if X86 || IA64 + select ACPI_PROCESSOR_IDLE select ACPI_CPU_FREQ_PSS if X86 || IA64 default y help
Signature · 1 line
2.7.4
Re: [PATCH v10 7/7] ACPI : enable ACPI_PROCESSOR_IDLE on ARM64
Hi Sudeep,
Quoted 17 lines · Sudeep Holla
Now that ACPI processor idle driver supports LPI(Low Power Idle), lets enable
ACPI_PROCESSOR_IDLEfor ARM64 too.This patch just removes the IA64 and X86 dependency on
ACPI_PROCESSOR_IDLECc "Rafael J. Wysocki" <[email protected]>Signed-off-by Sudeep Holla <[email protected]>--- drivers/acpi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/acpi/Kconfig +0
-0
drivers/acpi/Kconfig config ACPI_CPPC_LIB · line 244
Quoted 8 lines
drivers/acpi/Kconfig +1
-1@@ -238,7 +238,7 @@ config ACPI_CPPC_LIB config ACPI_PROCESSOR tristate "Processor" depends on X86 || IA64 || ARM64 - select ACPI_PROCESSOR_IDLE if X86 || IA64 + select ACPI_PROCESSOR_IDLE select ACPI_CPU_FREQ_PSS if X86 || IA64 default y help
This causes a boot hang on QDF2432. cpuidle.off=1 works around the problem. I understand you're working on a fix to the problem in GICv3 code. If there's anything I can do to help, please let me know.
Thanks,
Christopher Covington
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH v10 7/7] ACPI : enable ACPI_PROCESSOR_IDLE on ARM64
Quoted 24 lines · Christopher Covington
Hi Sudeep,
Quoted 21 lines · Sudeep Holla
Now that ACPI processor idle driver supports LPI(Low Power Idle), lets enable
ACPI_PROCESSOR_IDLEfor ARM64 too.This patch just removes the IA64 and X86 dependency on
ACPI_PROCESSOR_IDLECc "Rafael J. Wysocki" <[email protected]>Signed-off-by Sudeep Holla <[email protected]>--- drivers/acpi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/acpi/Kconfig +1
-1@@ -238,7 +238,7 @@ config ACPI_CPPC_LIB config ACPI_PROCESSOR tristate "Processor" depends on X86 || IA64 || ARM64 - select ACPI_PROCESSOR_IDLE if X86 || IA64 + select ACPI_PROCESSOR_IDLE
Quoted 8 lines
drivers/acpi/Kconfig config ACPI_CPPC_LIB · line 244
Quoted 4 lines
drivers/acpi/Kconfig +0
-0select ACPI_CPU_FREQ_PSS if X86 || IA64 default y helpThis causes a boot hang on QDF2432. cpuidle.off=1 works around the problem. I understand you're working on a fix to the problem in GICv3 code. If there's anything I can do to help, please let me know.
Sorry for the late response, I was away. Yes it's to do with GICv3 and retention states. I exchanged mails with QCOM guys in private. To summarize:
We don't need any additional support in Linux to support that. Infact we need to remove disabling the redistributor in the powerdown path. PSCI implementation also do the same for Group0(aka secure/EL3 interrupts) and we currently do that for Group1(aka EL1N interrupts) in Linux. The plan was to move that to EL3 code, to align with GICv2 code.
Hence the changes in Linux is just removal of the GICv3 PM notifier partially. I will need to check with Trusted Firmware team and do some testing before I post that change. I will plan to do that later this week.
Signature · 2 lines
Regards, Sudeep
Re: [PATCH v10 7/7] ACPI : enable ACPI_PROCESSOR_IDLE on ARM64
Hi Sudeep,
Quoted 46 lines · Sudeep Holla
Quoted 25 lines · Christopher Covington
Hi Sudeep,
Quoted 22 lines · Sudeep Holla
Now that ACPI processor idle driver supports LPI(Low Power Idle), lets enable
ACPI_PROCESSOR_IDLEfor ARM64 too.This patch just removes the IA64 and X86 dependency on
ACPI_PROCESSOR_IDLECc "Rafael J. Wysocki" <[email protected]>Signed-off-by Sudeep Holla <[email protected]>--- drivers/acpi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/acpi/Kconfig +1
-1@@ -238,7 +238,7 @@ config ACPI_CPPC_LIB config ACPI_PROCESSOR tristate "Processor" depends on X86 || IA64 || ARM64 - select ACPI_PROCESSOR_IDLE if X86 || IA64 + select ACPI_PROCESSOR_IDLEQuoted 8 lines
drivers/acpi/Kconfig config ACPI_CPPC_LIB · line 244
Quoted 4 lines
drivers/acpi/Kconfig +0
-0select ACPI_CPU_FREQ_PSS if X86 || IA64 default y helpThis causes a boot hang on QDF2432. cpuidle.off=1 works around the problem. I understand you're working on a fix to the problem in GICv3 code. If there's anything I can do to help, please let me know.
Sorry for the late response, I was away. Yes it's to do with GICv3 and retention states. I exchanged mails with QCOM guys in private. To summarize:
We don't need any additional support in Linux to support that. Infact we need to remove disabling the redistributor in the powerdown path. PSCI implementation also do the same for Group0(aka secure/EL3 interrupts) and we currently do that for Group1(aka EL1N interrupts) in Linux. The plan was to move that to EL3 code, to align with GICv2 code.
Quoted 3 lines
Hence the changes in Linux is just removal of the GICv3 PM notifier partially. I will need to check with Trusted Firmware team and do some testing before I post that change. I will plan to do that later this week.
Have you been able to make progress on the fix? If there's anything we can do to help, please let us know. If the fix is going to take a while, would it be appropriate to revert the Kconfig change until it is in place?
Thanks,
Christopher Covington
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH v10 7/7] ACPI : enable ACPI_PROCESSOR_IDLE on ARM64
Hi Christopher,
Quoted 49 lines · Christopher Covington
Hi Sudeep,
Quoted 46 lines · Sudeep Holla
Quoted 25 lines · Christopher Covington
Hi Sudeep,
Quoted 22 lines · Sudeep Holla
Now that ACPI processor idle driver supports LPI(Low Power Idle), lets enable
ACPI_PROCESSOR_IDLEfor ARM64 too.This patch just removes the IA64 and X86 dependency on
ACPI_PROCESSOR_IDLECc "Rafael J. Wysocki" <[email protected]>Signed-off-by Sudeep Holla <[email protected]>--- drivers/acpi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/acpi/Kconfig +1
-1@@ -238,7 +238,7 @@ config ACPI_CPPC_LIB config ACPI_PROCESSOR tristate "Processor" depends on X86 || IA64 || ARM64 - select ACPI_PROCESSOR_IDLE if X86 || IA64 + select ACPI_PROCESSOR_IDLEQuoted 8 lines
drivers/acpi/Kconfig config ACPI_CPPC_LIB · line 244
Quoted 4 lines
drivers/acpi/Kconfig +0
-0select ACPI_CPU_FREQ_PSS if X86 || IA64 default y helpThis causes a boot hang on QDF2432. cpuidle.off=1 works around the problem. I understand you're working on a fix to the problem in GICv3 code. If there's anything I can do to help, please let me know.
Sorry for the late response, I was away. Yes it's to do with GICv3 and retention states. I exchanged mails with QCOM guys in private. To summarize:
We don't need any additional support in Linux to support that. Infact we need to remove disabling the redistributor in the powerdown path. PSCI implementation also do the same for Group0(aka secure/EL3 interrupts) and we currently do that for Group1(aka EL1N interrupts) in Linux. The plan was to move that to EL3 code, to align with GICv2 code.
Quoted 8 lines
Quoted 3 lines
Hence the changes in Linux is just removal of the GICv3 PM notifier partially. I will need to check with Trusted Firmware team and do some testing before I post that change. I will plan to do that later this week.
Have you been able to make progress on the fix? If there's anything we can do to help, please let us know. If the fix is going to take a while, would it be appropriate to revert the
Kconfigchange until it is in place?
Thanks for the remainder. Yes I will post this week, I posted arm trusted firmware patch first and was waiting it to be pulled.
Signature · 2 lines
Regards, Sudeep