Add RSC power domain support
Subsystems (7)
v4 cover Add RSC power domain support
Changes in v4:
- Add change to allow hierarchical topology in PC mode
- Drop hierarchical domain idle states converter from v3
- Address Merge sc7180 dtsi change to add low power modes
Changes in v3:
- Address Rob's comment on dt property value
- Address Stephen's comments on rpmh-rsc driver change
- Include sc7180 cpuidle low power mode changes from [1]
- Include hierarchical domain idle states converter change from [2]
Changes in v2:
- Add Stephen's Reviewed-By to the first three patches
- Addressed Stephen's comments on fourth patch
- Include changes to connect rpmh domain to cpuidle and genpds
Resource State Coordinator (RSC) is responsible for powering off/lowering the requirements from CPU subsystem for the associated hardware like buses, clocks, and regulators when all CPUs and cluster is powered down.
RSC power domain uses last-man activities provided by genpd framework based on Ulf Hansoon's patch series[3], when the cluster of CPUs enter deepest idle states. As a part of domain poweroff, RSC can lower resource state requirements by flushing the cached sleep and wake state votes for resources.
[1] https://patchwork.kernel.org/patch/11218965
[2] https://patchwork.kernel.org/patch/10941671
[3] https://patchwork.kernel.org/project/linux-arm-msm/list/?series=222355
Maulik Shah (5):
drivers: qcom: rpmh: fix macro to accept NULL argument
drivers: qcom: rpmh: remove rpmh_flush export
dt-bindings: soc: qcom: Add RSC power domain specifier
drivers: qcom: rpmh-rsc: Add RSC power domain support
arm64: dts: qcom: sc7180: Add cpuidle low power states
Ulf Hansson (1):
drivers: firmware: psci: Allow hierarchical topology in PC mode
.../devicetree/bindings/soc/qcom/rpmh-rsc.txt | 9 ++ arch/arm64/boot/dts/qcom/sc7180.dtsi | 135 +++++++++++++++++++++ drivers/cpuidle/cpuidle-psci-domain.c | 32 +++-- drivers/cpuidle/cpuidle-psci.c | 34 +++--- drivers/soc/qcom/rpmh-internal.h | 3 + drivers/soc/qcom/rpmh-rsc.c | 81 +++++++++++++ drivers/soc/qcom/rpmh.c | 22 ++-- include/soc/qcom/rpmh.h | 5 - 8 files changed, 269 insertions(+), 52 deletions(-)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v4 1/6 drivers: qcom: rpmh: fix macro to accept NULL argument
Device argument matches with dev variable declared in RPMH message. Compiler reports error when the argument is NULL since the argument matches the name of the property. Rename dev argument to device to fix this.
--- drivers/soc/qcom/rpmh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/qcom/rpmh.c +2 -2
@@ -23,7 +23,7 @@#define RPMH_TIMEOUT_MS msecs_to_jiffies(10000) -#define DEFINE_RPMH_MSG_ONSTACK (dev, s, q, name) \ +#define DEFINE_RPMH_MSG_ONSTACK (device, s, q, name) \ struct rpmh_request name = { \ .msg = { \ .state = s, \
@@ -33,7 +33,7 @@ }, \ .cmd = { { 0 } }, \ .completion = q, \ - .dev = dev, \ + .dev = device, \ .needs_free = false, \ }
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v4 2/6 drivers: qcom: rpmh: remove rpmh_flush export
In reply to Maulik Shahrpmh_flush() was exported with the idea that an external entity operation during CPU idle would know when to flush the sleep and wake TCS. Since, this is not the case when defining a power domain for the RSC. Remove the function export and instead allow the function to be called internally.
--- drivers/soc/qcom/rpmh-internal.h | 1 + drivers/soc/qcom/rpmh.c | 18 ++++++++---------- include/soc/qcom/rpmh.h | 5 ----- 3 files changed, 9 insertions(+), 15 deletions(-)
drivers/soc/qcom/rpmh-internal.h +1 -0
@@ -110,5 +110,6 @@ int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv,int rpmh_rsc_invalidate (struct rsc_drv *drv);void rpmh_tx_done (const struct tcs_request *msg,int r); +int rpmh_flush (struct rpmh_ctrlr *ctrlr);#endif /* __RPM_INTERNAL_H__ */
drivers/soc/qcom/rpmh.c +8 -10
@@ -427,11 +427,10 @@ static int is_req_valid(struct cache_req *req) req->sleep_val != req->wake_val); } -static int send_single (const struct device *dev,enum rpmh_state state, +static int send_single (struct rpmh_ctrlr *ctrlr,enum rpmh_state state,u32 addr,u32 data) { -DEFINE_RPMH_MSG_ONSTACK (dev, state,NULL , rpm_msg); -struct rpmh_ctrlr *ctrlr =get_rpmh_ctrlr (dev); +DEFINE_RPMH_MSG_ONSTACK (NULL , state,NULL , rpm_msg);/* Wake sets are always complete and sleep sets are not */ rpm_msg.msg.wait_for_compl = (state ==RPMH_WAKE_ONLY_STATE );
@@ -445,7 +444,7 @@ static int send_single(const struct device *dev, enum rpmh_state state,/** * rpmh_flush: Flushes the buffered active and sleep sets to TCS * -* @dev: The device making the request +* @ctrlr: controller making request to flush cached data * * Return: -EBUSY if the controller is busy, probably waiting on a response * to a RPMH request sent earlier.
@@ -454,10 +453,9 @@ static int send_single(const struct device *dev, enum rpmh_state state,* that is powering down the entire system. Since no other RPMH API would be * executing at this time, it is safe to run lockless. */ -int rpmh_flush (const struct device *dev) +int rpmh_flush (struct rpmh_ctrlr *ctrlr) {struct cache_req *p; -struct rpmh_ctrlr *ctrlr =get_rpmh_ctrlr (dev);int ret;if (!ctrlr->dirty) {
@@ -480,11 +478,12 @@ int rpmh_flush(const struct device *dev) __func__, p->addr, p->sleep_val, p->wake_val);continue ; } - ret =send_single (dev,RPMH_SLEEP_STATE , p->addr, p->sleep_val); + ret =send_single (ctrlr,RPMH_SLEEP_STATE , p->addr, + p->sleep_val);if (ret)return ret; - ret =send_single (dev,RPMH_WAKE_ONLY_STATE , - p->addr, p->wake_val); + ret =send_single (ctrlr,RPMH_WAKE_ONLY_STATE , p->addr, + p->wake_val);if (ret)return ret; }
@@ -493,7 +492,6 @@ int rpmh_flush(const struct device *dev)return 0 ; } -EXPORT_SYMBOL (rpmh_flush);/** * rpmh_invalidate: Invalidate all sleep and active sets
include/soc/qcom/rpmh.h +0 -5
@@ -20,8 +20,6 @@ int rpmh_write_async(const struct device *dev, enum rpmh_state state,int rpmh_write_batch (const struct device *dev,enum rpmh_state state,const struct tcs_cmd *cmd,u32 *n); -int rpmh_flush (const struct device *dev); -int rpmh_invalidate (const struct device *dev);#else
@@ -40,9 +38,6 @@ static inline int rpmh_write_batch(const struct device *dev, const struct tcs_cmd *cmd, u32 *n) { return -ENODEV; } -static inline int rpmh_flush (const struct device *dev) -{return -ENODEV ; } -static inline int rpmh_invalidate (const struct device *dev) {return -ENODEV ; }
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v4 3/6 dt-bindings: soc: qcom: Add RSC power domain specifier
In reply to Maulik ShahIn addition to transmitting resource state requests to the remote processor, the RSC is responsible for powering off/lowering the requirements from CPUs subsystem for the associated hardware like buses, clocks, and regulators when all CPUs and cluster is powered down.
The power domain is configured to a low power state and when all the CPUs are powered down, the RSC can lower resource state requirements and power down the rails that power the CPUs.
Add PM domain specifier property for RSC controller.
--- Documentation/devicetree/bindings/soc/qcom/rpmh-rsc.txt | 9 +++++++++ 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/soc/qcom/rpmh-rsc.txt +9 -0
@@ -83,6 +83,14 @@ Properties: Value type: <string> Definition: Name for the RSC. The name would be used in trace logs. +- #power-domain-cells: + Usage: optional + Value type: <u32> + Definition: Must be 0. Number of cells in power domain specifier. + Optional for controllers that may be in 'solver' state + where they can be in autonomous mode executing low power + modes. + Drivers that want to use the RSC to communicate with RPMH must specify their bindings as child nodes of the RSC controllers they wish to communicate with.
@@ -112,6 +120,7 @@ TCS-OFFSET: 0xD00 <SLEEP_TCS 3>, <WAKE_TCS 3>, <CONTROL_TCS 1>; + #power-domain-cells = <0>; }; Example 2:
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH v4 3/6] dt-bindings: soc: qcom: Add RSC power domain specifier
Quoted 9 lines · Maulik Shah
In addition to transmitting resource state requests to the remote processor, the RSC is responsible for powering off/lowering the requirements from CPUs subsystem for the associated hardware like buses, clocks, and regulators when all CPUs and cluster is powered down.
The power domain is configured to a low power state and when all the CPUs are powered down, the RSC can lower resource state requirements and power down the rails that power the CPUs.
Quoted 9 lines
Add PM domain specifier property for RSC controller.
Signed-off-by Maulik Shah <[email protected]>Reviewed-by Stephen Boyd <[email protected]>--- Documentation/devicetree/bindings/soc/qcom/rpmh-rsc.txt | 9 +++++++++ 1 file changed, 9 insertions(+)
PATCH v4 4/6 drivers: qcom: rpmh-rsc: Add RSC power domain support
In reply to Maulik ShahAdd RSC power domain support. RSC is top level power domain in hireachical CPU LPM modes. Once the rsc domain is down flush all cached sleep and wake votes from controller.
--- drivers/soc/qcom/rpmh-internal.h | 2 + drivers/soc/qcom/rpmh-rsc.c | 81 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+)
drivers/soc/qcom/rpmh-internal.h +2 -0
@@ -8,6 +8,7 @@#define __RPM_INTERNAL_H__#include <linux/bitmap.h> +#include <linux/pm_domain.h> #include <soc/qcom/tcs.h> #define TCS_TYPE_NR 4
@@ -102,6 +103,7 @@ struct rsc_drv {DECLARE_BITMAP (tcs_in_use,MAX_TCS_NR );spinlock_t lock;struct rpmh_ctrlr client; +struct generic_pm_domain rsc_pd; };int rpmh_rsc_send_data (struct rsc_drv *drv,const struct tcs_request *msg);
drivers/soc/qcom/rpmh-rsc.c +81 -0
99 lines not on this page · raw message
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v4 5/6 drivers: firmware: psci: Allow hierarchical topology in PC mode
In reply to Maulik ShahFrom: Ulf Hansson <[email protected]>
If the hierarchical CPU topology is used, but the OS initiated mode isn't supported, we need to rely solely on the regular cpuidle framework to manage the idle state selection.
Remove current limitation of hierarchical topology to be used in OSI mode only.
--- drivers/cpuidle/cpuidle-psci-domain.c | 32 +++++++++++++++----------------- drivers/cpuidle/cpuidle-psci.c | 34 ++++++++++++++++------------------ 2 files changed, 31 insertions(+), 35 deletions(-)
drivers/cpuidle/cpuidle-psci-domain.c +15 -17
@@ -125,11 +125,14 @@ static int __init psci_pd_init(struct device_node *np)* Parse the domain idle states and let genpd manage the state selection * for those being compatible with "domain-idle-state". */ - ret =psci_pd_parse_states (np, &states, &state_count); -if (ret) - goto free_name; - pd->free_states = psci_pd_free_states; +if (psci_has_osi_support ()) { + ret =psci_pd_parse_states (np, &states, &state_count); +if (ret) + goto free_name; + pd->free_states = psci_pd_free_states; + } + pd->name =kbasename (pd->name); pd->power_off = psci_pd_power_off; pd->states = states;
@@ -236,10 +239,6 @@ static int __init psci_idle_init_domains(void)if (!np)return -ENODEV ; -/* Currently limit the hierarchical topology to be used in OSI mode. */ -if (!psci_has_osi_support ()) - goto out; -/* * Parse child nodes for the "#power-domain-cells" property and * initialize a genpd/genpd-of-provider pair when it's found.
@@ -265,14 +264,16 @@ static int __init psci_idle_init_domains(void) goto remove_pd;/* Try to enable OSI mode. */ - ret =psci_set_osi_mode (); -if (ret) { -pr_warn ("failed to enable OSI mode: %d\n" , ret); -psci_pd_remove_topology (np); - goto remove_pd; +if (psci_has_osi_support ()) { + ret =psci_set_osi_mode (); +if (ret) { +pr_warn ("failed to enable OSI mode: %d\n" , ret); +psci_pd_remove_topology (np); + goto remove_pd; + }else + osi_mode_enabled = true; } - osi_mode_enabled = true;of_node_put (np);pr_info ("Initialized CPU PM domain topology\n" );return pd_count;
@@ -293,9 +294,6 @@ struct device __init *psci_dt_attach_cpu(int cpu) {struct device *dev; -if (!osi_mode_enabled) -return NULL ; - dev =dev_pm_domain_attach_by_name (get_cpu_device (cpu),"psci" );if (IS_ERR_OR_NULL (dev))return dev;
drivers/cpuidle/cpuidle-psci.c +16 -18
@@ -193,24 +193,22 @@ static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, goto free_mem; } -/* Currently limit the hierarchical topology to be used in OSI mode. */ -if (psci_has_osi_support ()) { - data->dev =psci_dt_attach_cpu (cpu); -if (IS_ERR (data->dev)) { - ret =PTR_ERR (data->dev); - goto free_mem; - } - -/* -* Using the deepest state for the CPU to trigger a potential -* selection of a shared state for the domain, assumes the -* domain states are all deeper states. -*/ -if (data->dev) { - drv->states[state_count -1 ].enter = - psci_enter_domain_idle_state; - psci_cpuidle_use_cpuhp = true; - } + data->dev =psci_dt_attach_cpu (cpu); +if (IS_ERR (data->dev)) { + ret =PTR_ERR (data->dev); + goto free_mem; + } + +/* +* Using the deepest state for the CPU to trigger a potential +* selection of a shared state for the domain, assumes the +* domain states are all deeper states. +*/ + +if (data->dev) { + drv->states[state_count -1 ].enter = + psci_enter_domain_idle_state; + psci_cpuidle_use_cpuhp = true; }/* Idle states parsed correctly, store them in the per-cpu struct. */
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v4 6/6 arm64: dts: qcom: sc7180: Add cpuidle low power states
In reply to Maulik ShahAdd device bindings for cpuidle states for cpu devices.
--- arch/arm64/boot/dts/qcom/sc7180.dtsi | 135 +++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+)
arch/arm64/boot/dts/qcom/sc7180.dtsi +135 -0
@@ -86,6 +86,8 @@ compatible = "arm,armv8"; reg = <0x0 0x0>; enable-method = "psci"; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; next-level-cache = <&L2_0>; #cooling-cells = <2>; qcom,freq-domain = <&cpufreq_hw 0>;
@@ -103,6 +105,8 @@ compatible = "arm,armv8"; reg = <0x0 0x100>; enable-method = "psci"; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; next-level-cache = <&L2_100>; #cooling-cells = <2>; qcom,freq-domain = <&cpufreq_hw 0>;
@@ -117,6 +121,8 @@ compatible = "arm,armv8"; reg = <0x0 0x200>; enable-method = "psci"; + power-domains = <&CPU_PD2>; + power-domain-names = "psci"; next-level-cache = <&L2_200>; #cooling-cells = <2>; qcom,freq-domain = <&cpufreq_hw 0>;
@@ -131,6 +137,8 @@ compatible = "arm,armv8"; reg = <0x0 0x300>; enable-method = "psci"; + power-domains = <&CPU_PD3>; + power-domain-names = "psci"; next-level-cache = <&L2_300>; #cooling-cells = <2>; qcom,freq-domain = <&cpufreq_hw 0>;
@@ -145,6 +153,8 @@ compatible = "arm,armv8"; reg = <0x0 0x400>; enable-method = "psci"; + power-domains = <&CPU_PD4>; + power-domain-names = "psci"; next-level-cache = <&L2_400>; #cooling-cells = <2>; qcom,freq-domain = <&cpufreq_hw 0>;
@@ -159,6 +169,8 @@ compatible = "arm,armv8"; reg = <0x0 0x500>; enable-method = "psci"; + power-domains = <&CPU_PD5>; + power-domain-names = "psci"; next-level-cache = <&L2_500>; #cooling-cells = <2>; qcom,freq-domain = <&cpufreq_hw 0>;
@@ -173,6 +185,8 @@ compatible = "arm,armv8"; reg = <0x0 0x600>; enable-method = "psci"; + power-domains = <&CPU_PD6>; + power-domain-names = "psci"; next-level-cache = <&L2_600>; #cooling-cells = <2>; qcom,freq-domain = <&cpufreq_hw 1>;
@@ -187,6 +201,8 @@ compatible = "arm,armv8"; reg = <0x0 0x700>; enable-method = "psci"; + power-domains = <&CPU_PD7>; + power-domain-names = "psci"; next-level-cache = <&L2_700>; #cooling-cells = <2>; qcom,freq-domain = <&cpufreq_hw 1>;
@@ -195,6 +211,60 @@ next-level-cache = <&L3_0>; }; }; + + idle-states { + entry-method = "psci"; + + LITTLE_CPU_SLEEP_0: cpu-sleep-0-0 { + compatible = "arm,idle-state"; + idle-state-name = "little-power-down"; + arm,psci-suspend-param = <0x40000003>; + entry-latency-us = <549>; + exit-latency-us = <901>; + min-residency-us = <1774>; + local-timer-stop; + }; + + LITTLE_CPU_SLEEP_1: cpu-sleep-0-1 { + compatible = "arm,idle-state"; + idle-state-name = "little-rail-power-down"; + arm,psci-suspend-param = <0x40000004>; + entry-latency-us = <702>; + exit-latency-us = <915>; + min-residency-us = <4001>; + local-timer-stop; + }; + + BIG_CPU_SLEEP_0: cpu-sleep-1-0 { + compatible = "arm,idle-state"; + idle-state-name = "big-power-down"; + arm,psci-suspend-param = <0x40000003>; + entry-latency-us = <523>; + exit-latency-us = <1244>; + min-residency-us = <2207>; + local-timer-stop; + }; + + BIG_CPU_SLEEP_1: cpu-sleep-1-1 { + compatible = "arm,idle-state"; + idle-state-name = "big-rail-power-down"; + arm,psci-suspend-param = <0x40000004>; + entry-latency-us = <526>; + exit-latency-us = <1854>; + min-residency-us = <5555>; + local-timer-stop; + }; + + CLUSTER_SLEEP_0: cluster-sleep-0 { + compatible = "arm,idle-state"; + idle-state-name = "cluster-power-down"; + arm,psci-suspend-param = <0x40003444>; + entry-latency-us = <3263>; + exit-latency-us = <6562>; + min-residency-us = <9926>; + local-timer-stop; + }; + }; }; memory@80000000 {
@@ -297,6 +367,70 @@ psci { compatible = "arm,psci-1.0"; method = "smc"; + + CPU_PD0: cpu-pd0 { + #power-domain-cells = <0>; + power-domains = <&apps_rsc>; + domain-idle-states = <&LITTLE_CPU_SLEEP_0>, + <&LITTLE_CPU_SLEEP_1>, + <&CLUSTER_SLEEP_0>; + }; + + CPU_PD1: cpu-pd1 { + #power-domain-cells = <0>; + power-domains = <&apps_rsc>; + domain-idle-states = <&LITTLE_CPU_SLEEP_0>, + <&LITTLE_CPU_SLEEP_1>, + <&CLUSTER_SLEEP_0>; + }; + + CPU_PD2: cpu-pd2 { + #power-domain-cells = <0>; + power-domains = <&apps_rsc>; + domain-idle-states = <&LITTLE_CPU_SLEEP_0>, + <&LITTLE_CPU_SLEEP_1>, + <&CLUSTER_SLEEP_0>; + }; + + CPU_PD3: cpu-pd3 { + #power-domain-cells = <0>; + power-domains = <&apps_rsc>; + domain-idle-states = <&LITTLE_CPU_SLEEP_0>, + <&LITTLE_CPU_SLEEP_1>, + <&CLUSTER_SLEEP_0>; + }; + + CPU_PD4: cpu-pd4 { + #power-domain-cells = <0>; + power-domains = <&apps_rsc>; + domain-idle-states = <&LITTLE_CPU_SLEEP_0>, + <&LITTLE_CPU_SLEEP_1>, + <&CLUSTER_SLEEP_0>; + }; + + CPU_PD5: cpu-pd5 { + #power-domain-cells = <0>; + power-domains = <&apps_rsc>; + domain-idle-states = <&LITTLE_CPU_SLEEP_0>, + <&LITTLE_CPU_SLEEP_1>, + <&CLUSTER_SLEEP_0>; + }; + + CPU_PD6: cpu-pd6 { + #power-domain-cells = <0>; + power-domains = <&apps_rsc>; + domain-idle-states = <&BIG_CPU_SLEEP_0>, + <&BIG_CPU_SLEEP_1>, + <&CLUSTER_SLEEP_0>; + }; + + CPU_PD7: cpu-pd7 { + #power-domain-cells = <0>; + power-domains = <&apps_rsc>; + domain-idle-states = <&BIG_CPU_SLEEP_0>, + <&BIG_CPU_SLEEP_1>, + <&CLUSTER_SLEEP_0>; + }; }; soc: soc {
@@ -1417,6 +1551,7 @@ <SLEEP_TCS 3>, <WAKE_TCS 3>, <CONTROL_TCS 1>; + #power-domain-cells = <0>; rpmhcc: clock-controller { compatible = "qcom,sc7180-rpmh-clk";
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation