cpuidle: psci: Fixup execution order when entering a domain idle state
Subsystems (2)
PATCH 1/1 cpuidle: psci: Fixup execution order when entering a domain idle state
Moving forward, platforms are going to need to execute specific "last-man" operations before a domain idle state can be entered. In one way or the other, these operations needs to be triggered while walking the hierarchical topology via runtime PM and genpd, as it's at that point the last-man becomes known.
Moreover, executing last-man operations needs to be done after the CPU PM notifications are sent through cpu_pm_enter(), as otherwise it's likely that some notifications would fail. Therefore, let's re-order the sequence in psci_enter_domain_idle_state(), so cpu_pm_enter() gets called prior pm_runtime_put_sync().
--- drivers/cpuidle/cpuidle-psci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/cpuidle/cpuidle-psci.c +7 -1
@@ -58,6 +58,10 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev,u32 state;int ret; + ret =cpu_pm_enter (); +if (ret) +return -1 ; +/* Do runtime PM to manage a hierarchical CPU toplogy. */ pm_runtime_put_sync_suspend (pd_dev);
@@ -65,10 +69,12 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev,if (!state) state = states[idx]; - ret =psci_enter_state (idx, state); + ret =psci_cpu_suspend_enter (state) ?-1 : idx;pm_runtime_get_sync (pd_dev); +cpu_pm_exit (); +/* Clear the domain state to start fresh when back from idle. */ psci_set_domain_state (0 );return ret;
Signature · 1 line
2.20.1
Rafael J. Wysocki
maintainerQuoted 13 lines · Ulf Hansson
Moving forward, platforms are going to need to execute specific "last-man" operations before a domain idle state can be entered. In one way or the other, these operations needs to be triggered while walking the hierarchical topology via runtime PM and genpd, as it's at that point the last-man becomes known.
Moreover, executing last-man operations needs to be done after the CPU PM notifications are sent through
cpu_pm_enter(), as otherwise it's likely that some notifications would fail. Therefore, let's re-order the sequence inpsci_enter_domain_idle_state(), socpu_pm_enter()gets called priorpm_runtime_put_sync().
Quoted 3 lines
Fixes ce85aef570df ("cpuidle: psci: Manage runtime PM in the idle path")Reported-by Lina Iyer <[email protected]>Signed-off-by Ulf Hansson <[email protected]>
I can pick this up provided an ACK from a maintainer of this driver.
Quoted 36 lines
--- drivers/cpuidle/cpuidle-psci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/cpuidle/cpuidle-psci.c +7
-2@@ -58,6 +58,10 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev,u32 state;int ret; + ret =cpu_pm_enter (); +if (ret) +return -1 ; +/* Do runtime PM to manage a hierarchical CPU toplogy. */ pm_runtime_put_sync_suspend (pd_dev);@@ -65,10 +69,12 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev,if (!state) state = states[idx]; - ret =psci_enter_state (idx, state); + ret =psci_cpu_suspend_enter (state) ?-1 : idx;pm_runtime_get_sync (pd_dev); +cpu_pm_exit (); +/* Clear the domain state to start fresh when back from idle. */ psci_set_domain_state (0 );return ret; --2.20.1
Quoted 2 lines · Ulf Hansson
Moving forward, platforms are going to need to execute specific "last-man" operations before a domain idle state can be entered.
I need to dig the thread details, but I remember commenting on one of the similar discussion. It was something to do with voting which wasn't necessary at all. I am interested in the details here.
Quoted 10 lines
In one way or the other, these operations needs to be triggered while walking the hierarchical topology via runtime PM and genpd, as it's at that point the last-man becomes known.
Moreover, executing last-man operations needs to be done after the CPU PM notifications are sent through
cpu_pm_enter(), as otherwise it's likely that some notifications would fail. Therefore, let's re-order the sequence inpsci_enter_domain_idle_state(), socpu_pm_enter()gets called priorpm_runtime_put_sync().
More details on why notifications fail ?
Quoted 12 lines
Fixes ce85aef570df ("cpuidle: psci: Manage runtime PM in the idle path")Reported-by Lina Iyer <[email protected]>Signed-off-by Ulf Hansson <[email protected]>--- drivers/cpuidle/cpuidle-psci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/cpuidle/cpuidle-psci.c +0
-0
drivers/cpuidle/cpuidle-psci.c static int psci_enter_domain_idle_state(struct cpuidle_device *dev, · line 64
Quoted 7 lines
drivers/cpuidle/cpuidle-psci.c +4
-0@@ -58,6 +58,10 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev,u32 state;int ret; + ret =cpu_pm_enter (); +if (ret) +return -1 ; +
This change is ignoring the retention case psci_enter_state handles and this may affect performance by doing unnecessary save/restore.
Signature · 2 lines
Regards, Sudeep
Quoted 13 lines · Sudeep Holla
Quoted 2 lines · Ulf Hansson
Moving forward, platforms are going to need to execute specific "last-man" operations before a domain idle state can be entered.
I need to dig the thread details, but I remember commenting on one of the similar discussion. It was something to do with voting which wasn't necessary at all. I am interested in the details here.
Quoted 4 lines
In one way or the other, these operations needs to be triggered while walking the hierarchical topology via runtime PM and genpd, as it's at that point the last-man becomes known.
Quoted 8 lines
Quoted 6 lines
Moreover, executing last-man operations needs to be done after the CPU PM notifications are sent through
cpu_pm_enter(), as otherwise it's likely that some notifications would fail. Therefore, let's re-order the sequence inpsci_enter_domain_idle_state(), socpu_pm_enter()gets called priorpm_runtime_put_sync().More details on why notifications fail ?
Well, at this moment this is more of a hypothetical issue as there is no last-man notification sent/used yet.
However, typically we would call cpu_cluster_pm_enter() in the path as when the psci_pd_power_off() is called (for psci PM domains), when a valid domain state has been found.
This means, we would violate the cpu_cluster_pm_enter() API, as it's clearly stated in its corresponding function header, that cpu_pm_enter() needs to be called first (and that's also how others are currently using it).
Note that, I am currently exploring whether we shall call cpu_cluster_pm_enter|exit() at all, or whether we can use some other new genpd mechanism to accomplish the similar thing.
Quoted 16 lines
Quoted 16 lines
Fixes ce85aef570df ("cpuidle: psci: Manage runtime PM in the idle path")Reported-by Lina Iyer <[email protected]>Signed-off-by Ulf Hansson <[email protected]>--- drivers/cpuidle/cpuidle-psci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/cpuidle/cpuidle-psci.c +0
-0@@ -58,6 +58,10 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev,u32 state;int ret;
Quoted 7 lines
drivers/cpuidle/cpuidle-psci.c static int psci_enter_domain_idle_state(struct cpuidle_device *dev, · line 64
Quoted 4 lines
drivers/cpuidle/cpuidle-psci.c +4
-0+ ret =cpu_pm_enter (); +if (ret) +return -1 ; +This change is ignoring the retention case
psci_enter_statehandles and this may affect performance by doing unnecessary save/restore.
This was already the case before. CPU_PM_CPU_IDLE_ENTER_PARAM() ends up always setting "is_retention" to 0, when __CPU_PM_CPU_IDLE_ENTER() is called.
Kind regards
Uffe
Quoted 21 lines · Ulf Hansson
Quoted 20 lines · Sudeep Holla
Quoted 2 lines · Ulf Hansson
Moving forward, platforms are going to need to execute specific "last-man" operations before a domain idle state can be entered.
I need to dig the thread details, but I remember commenting on one of the similar discussion. It was something to do with voting which wasn't necessary at all. I am interested in the details here.
Quoted 10 lines
In one way or the other, these operations needs to be triggered while walking the hierarchical topology via runtime PM and genpd, as it's at that point the last-man becomes known.
Moreover, executing last-man operations needs to be done after the CPU PM notifications are sent through
cpu_pm_enter(), as otherwise it's likely that some notifications would fail. Therefore, let's re-order the sequence inpsci_enter_domain_idle_state(), socpu_pm_enter()gets called priorpm_runtime_put_sync().
Quoted 5 lines
Quoted 1 line
More details on why notifications fail ?
Well, at this moment this is more of a hypothetical issue as there is no last-man notification sent/used yet.
Ah OK.
Quoted 4 lines
However, typically we would call
cpu_cluster_pm_enter()in the path as when thepsci_pd_power_off()is called (for psci PM domains), when a valid domain state has been found.
Please don't use cpu_cluster_pm_enter. I thought the whole idea of genpd will remove the notion of cluster and we will never need to use cpu_cluster_pm_*
Quoted 5 lines
This means, we would violate the
cpu_cluster_pm_enter()API, as it's clearly stated in its corresponding function header, thatcpu_pm_enter()needs to be called first (and that's also how others are currently using it).
Ah so, it was just for use of cpu_cluster_pm_* which I would like to avoid. That was one of the motivation for using genpd I thought.
Quoted 4 lines
Note that, I am currently exploring whether we shall call cpu_cluster_pm_enter|exit() at all, or whether we can use some other new genpd mechanism to accomplish the similar thing.
Good, you do think so.
Quoted 24 lines
Quoted 16 lines
Quoted 16 lines
Fixes ce85aef570df ("cpuidle: psci: Manage runtime PM in the idle path")Reported-by Lina Iyer <[email protected]>Signed-off-by Ulf Hansson <[email protected]>--- drivers/cpuidle/cpuidle-psci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/cpuidle/cpuidle-psci.c +0
-0@@ -58,6 +58,10 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev,u32 state;int ret;Quoted 7 lines
drivers/cpuidle/cpuidle-psci.c static int psci_enter_domain_idle_state(struct cpuidle_device *dev, · line 64
Quoted 4 lines
drivers/cpuidle/cpuidle-psci.c +4
-0+ ret =cpu_pm_enter (); +if (ret) +return -1 ; +This change is ignoring the retention case
psci_enter_statehandles and this may affect performance by doing unnecessary save/restore.
Quoted 4 lines
This was already the case before.
CPU_PM_CPU_IDLE_ENTER_PARAM()ends up always setting "is_retention" to 0, when__CPU_PM_CPU_IDLE_ENTER()is called.
Ah OK, I recall now, sorry for the noise.
--
Regards,
Sudeep
Quoted 49 lines · Sudeep Holla
Quoted 21 lines · Ulf Hansson
Quoted 20 lines · Sudeep Holla
Quoted 2 lines · Ulf Hansson
Moving forward, platforms are going to need to execute specific "last-man" operations before a domain idle state can be entered.
I need to dig the thread details, but I remember commenting on one of the similar discussion. It was something to do with voting which wasn't necessary at all. I am interested in the details here.
Quoted 10 lines
In one way or the other, these operations needs to be triggered while walking the hierarchical topology via runtime PM and genpd, as it's at that point the last-man becomes known.
Moreover, executing last-man operations needs to be done after the CPU PM notifications are sent through
cpu_pm_enter(), as otherwise it's likely that some notifications would fail. Therefore, let's re-order the sequence inpsci_enter_domain_idle_state(), socpu_pm_enter()gets called priorpm_runtime_put_sync().Quoted 5 lines
Quoted 1 line
More details on why notifications fail ?
Well, at this moment this is more of a hypothetical issue as there is no last-man notification sent/used yet.
Ah OK.
Quoted 4 lines
However, typically we would call
cpu_cluster_pm_enter()in the path as when thepsci_pd_power_off()is called (for psci PM domains), when a valid domain state has been found.Please don't use
cpu_cluster_pm_enter. I thought the whole idea of genpd will remove the notion of cluster and we will never need to use cpu_cluster_pm_*Quoted 5 lines
This means, we would violate the
cpu_cluster_pm_enter()API, as it's clearly stated in its corresponding function header, thatcpu_pm_enter()needs to be called first (and that's also how others are currently using it).Ah so, it was just for use of cpu_cluster_pm_* which I would like to avoid. That was one of the motivation for using genpd I thought.
Quoted 6 lines
Quoted 4 lines
Note that, I am currently exploring whether we shall call cpu_cluster_pm_enter|exit() at all, or whether we can use some other new genpd mechanism to accomplish the similar thing.
Good, you do think so.
Okay, let's see where things go. I will keep you posted.
Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 13 lines
Fixes ce85aef570df ("cpuidle: psci: Manage runtime PM in the idle path")Reported-by Lina Iyer <[email protected]>Signed-off-by Ulf Hansson <[email protected]>--- drivers/cpuidle/cpuidle-psci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/cpuidle/cpuidle-psci.c +0
-0drivers/cpuidle/cpuidle-psci.c static int psci_enter_domain_idle_state(struct cpuidle_device *dev, · line 64
Quoted 7 lines
drivers/cpuidle/cpuidle-psci.c +4
-0@@ -58,6 +58,10 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev,u32 state;int ret; + ret =cpu_pm_enter (); +if (ret) +return -1 ; +This change is ignoring the retention case
psci_enter_statehandles and this may affect performance by doing unnecessary save/restore.
Quoted 6 lines
Quoted 4 lines
This was already the case before.
CPU_PM_CPU_IDLE_ENTER_PARAM()ends up always setting "is_retention" to 0, when__CPU_PM_CPU_IDLE_ENTER()is called.Ah OK, I recall now, sorry for the noise.
No worries, thanks for reviewing.
That said, are you fine with Rafel queuing this then?
Kind regards
Uffe
Sudeep Holla
Acked-byQuoted 3 lines · Ulf Hansson
No worries, thanks for reviewing.
You are welcome.
Quoted 2 lines
That said, are you fine with Rafel queuing this then?
I am fine with that. However I told if you need fixes tags as there are no users of the notification yet in the kernel. Though this is trivial, but do we need this backported to stable kernel. I don't have strong opinion and leave it to you and Rafael.
--
Regards,
Sudeep
Quoted 8 lines · Sudeep Holla
Quoted 3 lines · Ulf Hansson
No worries, thanks for reviewing.
You are welcome.
Quoted 7 lines
Quoted 2 lines
That said, are you fine with Rafel queuing this then?
I am fine with that. However I told if you need fixes tags as there are no users of the notification yet in the kernel. Though this is trivial, but do we need this backported to stable kernel. I don't have strong opinion and leave it to you and Rafael.
I wanted to add the fixes tag, to make it obvious that there is an error being fixed.
On the other hand, no need to tag this for stable, nor to need to send it as fix for 5.7,
Quoted 2 lines
Acked-by Sudeep Holla <[email protected]>
Thanks!
Kind regards
Uffe
Quoted 17 lines · Ulf Hansson
Quoted 8 lines · Sudeep Holla
Quoted 3 lines · Ulf Hansson
No worries, thanks for reviewing.
You are welcome.
Quoted 7 lines
Quoted 2 lines
That said, are you fine with Rafel queuing this then?
I am fine with that. However I told if you need fixes tags as there are no users of the notification yet in the kernel. Though this is trivial, but do we need this backported to stable kernel. I don't have strong opinion and leave it to you and Rafael.
Quoted 6 lines
I wanted to add the fixes tag, to make it obvious that there is an error being fixed.
On the other hand, no need to tag this for stable, nor to need to send it as fix for 5.7,
Sometimes bots pick up patches for stable based on Fixes tag, hence I thought of mentioning that.
Signature · 2 lines
Regards, Sudeep
Rafael J. Wysocki
maintainerQuoted 21 lines · Ulf Hansson
Quoted 8 lines · Sudeep Holla
Quoted 3 lines · Ulf Hansson
No worries, thanks for reviewing.
You are welcome.
Quoted 7 lines
Quoted 2 lines
That said, are you fine with Rafel queuing this then?
I am fine with that. However I told if you need fixes tags as there are no users of the notification yet in the kernel. Though this is trivial, but do we need this backported to stable kernel. I don't have strong opinion and leave it to you and Rafael.
I wanted to add the fixes tag, to make it obvious that there is an error being fixed.
Quoted 7 lines
On the other hand, no need to tag this for stable, nor to need to send it as fix for 5.7,
Quoted 2 lines
Acked-by Sudeep Holla <[email protected]>Thanks!
So applied as 5.8 material, thanks!