diff mbox

[v2,6/6] ARM: tegra: cpuidle: use firmware for power down

Message ID 1391747706-1847-7-git-send-email-acourbot@nvidia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexandre Courbot Feb. 7, 2014, 4:35 a.m. UTC
Attempt to invoke the prepare_idle() and do_idle() firmware calls
to power down a CPU so an underlying firmware gets informed of
the idle operation and performs it by itself if designed in such a way.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 arch/arm/mach-tegra/cpuidle-tegra114.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Olof Johansson Feb. 12, 2014, 1:36 a.m. UTC | #1
On Fri, Feb 07, 2014 at 01:35:06PM +0900, Alexandre Courbot wrote:
> Attempt to invoke the prepare_idle() and do_idle() firmware calls
> to power down a CPU so an underlying firmware gets informed of
> the idle operation and performs it by itself if designed in such a way.
> 
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
>  arch/arm/mach-tegra/cpuidle-tegra114.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c
> index e0b87300243d..558067ddc186 100644
> --- a/arch/arm/mach-tegra/cpuidle-tegra114.c
> +++ b/arch/arm/mach-tegra/cpuidle-tegra114.c
> @@ -19,6 +19,7 @@
>  #include <linux/cpuidle.h>
>  #include <linux/cpu_pm.h>
>  #include <linux/clockchips.h>
> +#include <asm/firmware.h>
>  
>  #include <asm/cpuidle.h>
>  #include <asm/suspend.h>
> @@ -45,7 +46,15 @@ static int tegra114_idle_power_down(struct cpuidle_device *dev,
>  
>  	clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu);
>  
> -	cpu_suspend(0, tegra30_sleep_cpu_secondary_finish);
> +	call_firmware_op(prepare_idle);
> +
> +	switch (call_firmware_op(do_idle)) {
> +	case -ENOSYS:
> +		cpu_suspend(0, tegra30_sleep_cpu_secondary_finish);
> +		break;
> +	default:
> +		break;

Do you expect other cases down the road? If not, this is a simple if instead:

	/* Only call cpu_suspend if TF didn't handle the pre-suspend logic */
	if (call_firmware_op(do_idle) == -ENOSYS)
		cpu_suspend(....);


-Olof
Alexandre Courbot Feb. 12, 2014, 1:56 a.m. UTC | #2
On 02/12/2014 10:36 AM, Olof Johansson wrote:
> On Fri, Feb 07, 2014 at 01:35:06PM +0900, Alexandre Courbot wrote:
>> Attempt to invoke the prepare_idle() and do_idle() firmware calls
>> to power down a CPU so an underlying firmware gets informed of
>> the idle operation and performs it by itself if designed in such a way.
>>
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>> ---
>>   arch/arm/mach-tegra/cpuidle-tegra114.c | 11 ++++++++++-
>>   1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c
>> index e0b87300243d..558067ddc186 100644
>> --- a/arch/arm/mach-tegra/cpuidle-tegra114.c
>> +++ b/arch/arm/mach-tegra/cpuidle-tegra114.c
>> @@ -19,6 +19,7 @@
>>   #include <linux/cpuidle.h>
>>   #include <linux/cpu_pm.h>
>>   #include <linux/clockchips.h>
>> +#include <asm/firmware.h>
>>
>>   #include <asm/cpuidle.h>
>>   #include <asm/suspend.h>
>> @@ -45,7 +46,15 @@ static int tegra114_idle_power_down(struct cpuidle_device *dev,
>>
>>   	clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu);
>>
>> -	cpu_suspend(0, tegra30_sleep_cpu_secondary_finish);
>> +	call_firmware_op(prepare_idle);
>> +
>> +	switch (call_firmware_op(do_idle)) {
>> +	case -ENOSYS:
>> +		cpu_suspend(0, tegra30_sleep_cpu_secondary_finish);
>> +		break;
>> +	default:
>> +		break;
>
> Do you expect other cases down the road? If not, this is a simple if instead:
>
> 	/* Only call cpu_suspend if TF didn't handle the pre-suspend logic */
> 	if (call_firmware_op(do_idle) == -ENOSYS)
> 		cpu_suspend(....);

I might have been overdoing it indeed. Let me submit a v3 just for this 
one patch.

Thanks!
Alex.
diff mbox

Patch

diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c
index e0b87300243d..558067ddc186 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra114.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra114.c
@@ -19,6 +19,7 @@ 
 #include <linux/cpuidle.h>
 #include <linux/cpu_pm.h>
 #include <linux/clockchips.h>
+#include <asm/firmware.h>
 
 #include <asm/cpuidle.h>
 #include <asm/suspend.h>
@@ -45,7 +46,15 @@  static int tegra114_idle_power_down(struct cpuidle_device *dev,
 
 	clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu);
 
-	cpu_suspend(0, tegra30_sleep_cpu_secondary_finish);
+	call_firmware_op(prepare_idle);
+
+	switch (call_firmware_op(do_idle)) {
+	case -ENOSYS:
+		cpu_suspend(0, tegra30_sleep_cpu_secondary_finish);
+		break;
+	default:
+		break;
+	}
 
 	clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu);