diff mbox

[v2,4/6] ARM: firmware: add prepare_idle() operation

Message ID 1391747706-1847-5-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
Some firmwares do not put the CPU into idle mode themselves, but still
need to be informed that the CPU is about to enter idle mode before this
happens. Add a prepare_idle() operation to the firmware_ops structure to
handle such cases.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 arch/arm/include/asm/firmware.h | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Tomasz Figa Feb. 13, 2014, 11:01 a.m. UTC | #1
Hi Alexandre,

On 07.02.2014 05:35, Alexandre Courbot wrote:
> Some firmwares do not put the CPU into idle mode themselves, but still
> need to be informed that the CPU is about to enter idle mode before this
> happens. Add a prepare_idle() operation to the firmware_ops structure to
> handle such cases.
>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
>   arch/arm/include/asm/firmware.h | 4 ++++
>   1 file changed, 4 insertions(+)

I wonder if .do_idle() couldn't simply return an appropriate error code 
to let the upper layer know that it should proceed with normal CPU idle 
activation, while still letting the firmware know that the CPU is going 
to idle.

Best regards,
Tomasz
Stephen Warren Feb. 13, 2014, 4:37 p.m. UTC | #2
On 02/13/2014 04:01 AM, Tomasz Figa wrote:
> Hi Alexandre,
> 
> On 07.02.2014 05:35, Alexandre Courbot wrote:
>> Some firmwares do not put the CPU into idle mode themselves, but still
>> need to be informed that the CPU is about to enter idle mode before this
>> happens. Add a prepare_idle() operation to the firmware_ops structure to
>> handle such cases.
>>
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>> ---
>>   arch/arm/include/asm/firmware.h | 4 ++++
>>   1 file changed, 4 insertions(+)
> 
> I wonder if .do_idle() couldn't simply return an appropriate error code
> to let the upper layer know that it should proceed with normal CPU idle
> activation, while still letting the firmware know that the CPU is going
> to idle.

That seems to disagree with the naming of the operation, and the
semantics I assume it has, though. It seems clearer to add an explicit
separate op for this.
Alexandre Courbot Feb. 14, 2014, 5:16 a.m. UTC | #3
On 02/13/2014 08:01 PM, Tomasz Figa wrote:
> Hi Alexandre,
>
> On 07.02.2014 05:35, Alexandre Courbot wrote:
>> Some firmwares do not put the CPU into idle mode themselves, but still
>> need to be informed that the CPU is about to enter idle mode before this
>> happens. Add a prepare_idle() operation to the firmware_ops structure to
>> handle such cases.
>>
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>> ---
>>    arch/arm/include/asm/firmware.h | 4 ++++
>>    1 file changed, 4 insertions(+)
>
> I wonder if .do_idle() couldn't simply return an appropriate error code
> to let the upper layer know that it should proceed with normal CPU idle
> activation, while still letting the firmware know that the CPU is going
> to idle.

In our particular case I agree it would be enough to use do_idle() to 
let the firmware know about the operation and have it return -ENOSYS so 
the kernel actually performs it. I'm afraid this might not fulfill all 
needs though (e.g. one can imagine a firmware where the OS needs to take 
action between the notification and the actual shutdown), and as Stephen 
pointed out that would make the name of the function ambiguous at best. 
I'd rather keep it the current way for clarity.
Tomasz Figa Feb. 14, 2014, 10:42 a.m. UTC | #4
On 14.02.2014 06:16, Alexandre Courbot wrote:
> On 02/13/2014 08:01 PM, Tomasz Figa wrote:
>> Hi Alexandre,
>>
>> On 07.02.2014 05:35, Alexandre Courbot wrote:
>>> Some firmwares do not put the CPU into idle mode themselves, but still
>>> need to be informed that the CPU is about to enter idle mode before this
>>> happens. Add a prepare_idle() operation to the firmware_ops structure to
>>> handle such cases.
>>>
>>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>>> ---
>>>    arch/arm/include/asm/firmware.h | 4 ++++
>>>    1 file changed, 4 insertions(+)
>>
>> I wonder if .do_idle() couldn't simply return an appropriate error code
>> to let the upper layer know that it should proceed with normal CPU idle
>> activation, while still letting the firmware know that the CPU is going
>> to idle.
>
> In our particular case I agree it would be enough to use do_idle() to
> let the firmware know about the operation and have it return -ENOSYS so
> the kernel actually performs it. I'm afraid this might not fulfill all
> needs though (e.g. one can imagine a firmware where the OS needs to take
> action between the notification and the actual shutdown), and as Stephen
> pointed out that would make the name of the function ambiguous at best.
> I'd rather keep it the current way for clarity.
>

OK. I'm not strongly against this, just wanted some more thought on 
this, so please move on.

Best regards,
Tomasz
diff mbox

Patch

diff --git a/arch/arm/include/asm/firmware.h b/arch/arm/include/asm/firmware.h
index 15631300c238..2c9f10df7568 100644
--- a/arch/arm/include/asm/firmware.h
+++ b/arch/arm/include/asm/firmware.h
@@ -22,6 +22,10 @@ 
  */
 struct firmware_ops {
 	/*
+	 * Inform the firmware we intend to enter CPU idle mode
+	 */
+	int (*prepare_idle)(void);
+	/*
 	 * Enters CPU idle mode
 	 */
 	int (*do_idle)(void);