* [PATCH] cpuidle: riscv-sbi: Fix CPU_PM_CPU_IDLE_ENTER_xyz() macro usage
@ 2022-07-18 8:45 Anup Patel
2022-07-18 17:27 ` Andrew Jones
2022-08-29 2:59 ` Anup Patel
0 siblings, 2 replies; 5+ messages in thread
From: Anup Patel @ 2022-07-18 8:45 UTC (permalink / raw)
To: Rafael J . Wysocki, Daniel Lezcano
Cc: Palmer Dabbelt, Paul Walmsley, Ulf Hansson, Atish Patra,
Alistair Francis, Anup Patel, linux-pm, linux-riscv,
linux-kernel, Anup Patel
Currently, we are using CPU_PM_CPU_IDLE_ENTER_PARAM() for all SBI HSM
suspend types so retentive suspend types are also treated non-retentive
and kernel will do redundant additional work for these states.
The BIT[31] of SBI HSM suspend types allows us to differentiate between
retentive and non-retentive suspend types so we should use this BIT
to call appropriate CPU_PM_CPU_IDLE_ENTER_xyz() macro.
Fixes: 6abf32f1d9c5 ("cpuidle: Add RISC-V SBI CPU idle driver")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
drivers/cpuidle/cpuidle-riscv-sbi.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c
index 1151e5e2ba82..33c92fec4365 100644
--- a/drivers/cpuidle/cpuidle-riscv-sbi.c
+++ b/drivers/cpuidle/cpuidle-riscv-sbi.c
@@ -97,8 +97,13 @@ static int sbi_cpuidle_enter_state(struct cpuidle_device *dev,
struct cpuidle_driver *drv, int idx)
{
u32 *states = __this_cpu_read(sbi_cpuidle_data.states);
+ u32 state = states[idx];
- return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, states[idx]);
+ if (state & SBI_HSM_SUSP_NON_RET_BIT)
+ return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, state);
+ else
+ return CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM(sbi_suspend,
+ idx, state);
}
static int __sbi_enter_domain_idle_state(struct cpuidle_device *dev,
--
2.34.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] cpuidle: riscv-sbi: Fix CPU_PM_CPU_IDLE_ENTER_xyz() macro usage
2022-07-18 8:45 [PATCH] cpuidle: riscv-sbi: Fix CPU_PM_CPU_IDLE_ENTER_xyz() macro usage Anup Patel
@ 2022-07-18 17:27 ` Andrew Jones
2022-08-29 2:59 ` Anup Patel
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Jones @ 2022-07-18 17:27 UTC (permalink / raw)
To: Anup Patel
Cc: Rafael J . Wysocki, Daniel Lezcano, Palmer Dabbelt,
Paul Walmsley, Ulf Hansson, Atish Patra, Alistair Francis,
Anup Patel, linux-pm, linux-riscv, linux-kernel
On Mon, Jul 18, 2022 at 02:15:53PM +0530, Anup Patel wrote:
> Currently, we are using CPU_PM_CPU_IDLE_ENTER_PARAM() for all SBI HSM
> suspend types so retentive suspend types are also treated non-retentive
> and kernel will do redundant additional work for these states.
>
> The BIT[31] of SBI HSM suspend types allows us to differentiate between
> retentive and non-retentive suspend types so we should use this BIT
> to call appropriate CPU_PM_CPU_IDLE_ENTER_xyz() macro.
>
> Fixes: 6abf32f1d9c5 ("cpuidle: Add RISC-V SBI CPU idle driver")
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> ---
> drivers/cpuidle/cpuidle-riscv-sbi.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c
> index 1151e5e2ba82..33c92fec4365 100644
> --- a/drivers/cpuidle/cpuidle-riscv-sbi.c
> +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c
> @@ -97,8 +97,13 @@ static int sbi_cpuidle_enter_state(struct cpuidle_device *dev,
> struct cpuidle_driver *drv, int idx)
> {
> u32 *states = __this_cpu_read(sbi_cpuidle_data.states);
> + u32 state = states[idx];
>
> - return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, states[idx]);
> + if (state & SBI_HSM_SUSP_NON_RET_BIT)
> + return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, state);
> + else
> + return CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM(sbi_suspend,
> + idx, state);
> }
>
> static int __sbi_enter_domain_idle_state(struct cpuidle_device *dev,
> --
> 2.34.1
>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cpuidle: riscv-sbi: Fix CPU_PM_CPU_IDLE_ENTER_xyz() macro usage
2022-07-18 8:45 [PATCH] cpuidle: riscv-sbi: Fix CPU_PM_CPU_IDLE_ENTER_xyz() macro usage Anup Patel
2022-07-18 17:27 ` Andrew Jones
@ 2022-08-29 2:59 ` Anup Patel
2022-09-22 17:07 ` Palmer Dabbelt
1 sibling, 1 reply; 5+ messages in thread
From: Anup Patel @ 2022-08-29 2:59 UTC (permalink / raw)
To: Palmer Dabbelt
Cc: Rafael J . Wysocki, Daniel Lezcano, Paul Walmsley, Ulf Hansson,
Atish Patra, Alistair Francis, linux-pm, linux-riscv,
linux-kernel, Anup Patel
Hi Palmer,
On Mon, Jul 18, 2022 at 2:16 PM Anup Patel <apatel@ventanamicro.com> wrote:
>
> Currently, we are using CPU_PM_CPU_IDLE_ENTER_PARAM() for all SBI HSM
> suspend types so retentive suspend types are also treated non-retentive
> and kernel will do redundant additional work for these states.
>
> The BIT[31] of SBI HSM suspend types allows us to differentiate between
> retentive and non-retentive suspend types so we should use this BIT
> to call appropriate CPU_PM_CPU_IDLE_ENTER_xyz() macro.
>
> Fixes: 6abf32f1d9c5 ("cpuidle: Add RISC-V SBI CPU idle driver")
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Can you please take this patch through the RISC-V tree ?
Regards,
Anup
> ---
> drivers/cpuidle/cpuidle-riscv-sbi.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c
> index 1151e5e2ba82..33c92fec4365 100644
> --- a/drivers/cpuidle/cpuidle-riscv-sbi.c
> +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c
> @@ -97,8 +97,13 @@ static int sbi_cpuidle_enter_state(struct cpuidle_device *dev,
> struct cpuidle_driver *drv, int idx)
> {
> u32 *states = __this_cpu_read(sbi_cpuidle_data.states);
> + u32 state = states[idx];
>
> - return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, states[idx]);
> + if (state & SBI_HSM_SUSP_NON_RET_BIT)
> + return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, state);
> + else
> + return CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM(sbi_suspend,
> + idx, state);
> }
>
> static int __sbi_enter_domain_idle_state(struct cpuidle_device *dev,
> --
> 2.34.1
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cpuidle: riscv-sbi: Fix CPU_PM_CPU_IDLE_ENTER_xyz() macro usage
2022-08-29 2:59 ` Anup Patel
@ 2022-09-22 17:07 ` Palmer Dabbelt
2022-09-23 10:55 ` Palmer Dabbelt
0 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2022-09-22 17:07 UTC (permalink / raw)
To: anup
Cc: rafael, daniel.lezcano, Paul Walmsley, ulf.hansson, atishp,
Alistair Francis, linux-pm, linux-riscv, linux-kernel, apatel
On Sun, 28 Aug 2022 19:59:45 PDT (-0700), anup@brainfault.org wrote:
> Hi Palmer,
>
> On Mon, Jul 18, 2022 at 2:16 PM Anup Patel <apatel@ventanamicro.com> wrote:
>>
>> Currently, we are using CPU_PM_CPU_IDLE_ENTER_PARAM() for all SBI HSM
>> suspend types so retentive suspend types are also treated non-retentive
>> and kernel will do redundant additional work for these states.
>>
>> The BIT[31] of SBI HSM suspend types allows us to differentiate between
>> retentive and non-retentive suspend types so we should use this BIT
>> to call appropriate CPU_PM_CPU_IDLE_ENTER_xyz() macro.
>>
>> Fixes: 6abf32f1d9c5 ("cpuidle: Add RISC-V SBI CPU idle driver")
>> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
>
> Can you please take this patch through the RISC-V tree ?
Sorry I missed this, I didn't realize you wanted me to merge it. It's
on fixes.
>
> Regards,
> Anup
>
>> ---
>> drivers/cpuidle/cpuidle-riscv-sbi.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c
>> index 1151e5e2ba82..33c92fec4365 100644
>> --- a/drivers/cpuidle/cpuidle-riscv-sbi.c
>> +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c
>> @@ -97,8 +97,13 @@ static int sbi_cpuidle_enter_state(struct cpuidle_device *dev,
>> struct cpuidle_driver *drv, int idx)
>> {
>> u32 *states = __this_cpu_read(sbi_cpuidle_data.states);
>> + u32 state = states[idx];
>>
>> - return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, states[idx]);
>> + if (state & SBI_HSM_SUSP_NON_RET_BIT)
>> + return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, state);
>> + else
>> + return CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM(sbi_suspend,
>> + idx, state);
>> }
>>
>> static int __sbi_enter_domain_idle_state(struct cpuidle_device *dev,
>> --
>> 2.34.1
>>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cpuidle: riscv-sbi: Fix CPU_PM_CPU_IDLE_ENTER_xyz() macro usage
2022-09-22 17:07 ` Palmer Dabbelt
@ 2022-09-23 10:55 ` Palmer Dabbelt
0 siblings, 0 replies; 5+ messages in thread
From: Palmer Dabbelt @ 2022-09-23 10:55 UTC (permalink / raw)
To: anup
Cc: rafael, daniel.lezcano, Paul Walmsley, ulf.hansson, atishp,
Alistair Francis, linux-pm, linux-riscv, linux-kernel, apatel
On Thu, 22 Sep 2022 10:07:46 PDT (-0700), Palmer Dabbelt wrote:
> On Sun, 28 Aug 2022 19:59:45 PDT (-0700), anup@brainfault.org wrote:
>> Hi Palmer,
>>
>> On Mon, Jul 18, 2022 at 2:16 PM Anup Patel <apatel@ventanamicro.com> wrote:
>>>
>>> Currently, we are using CPU_PM_CPU_IDLE_ENTER_PARAM() for all SBI HSM
>>> suspend types so retentive suspend types are also treated non-retentive
>>> and kernel will do redundant additional work for these states.
>>>
>>> The BIT[31] of SBI HSM suspend types allows us to differentiate between
>>> retentive and non-retentive suspend types so we should use this BIT
>>> to call appropriate CPU_PM_CPU_IDLE_ENTER_xyz() macro.
>>>
>>> Fixes: 6abf32f1d9c5 ("cpuidle: Add RISC-V SBI CPU idle driver")
>>> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
>>
>> Can you please take this patch through the RISC-V tree ?
>
> Sorry I missed this, I didn't realize you wanted me to merge it. It's
> on fixes.
Actually from reading this again, it's not really a fix: the kernel is
correct without this change, it's just going to save/restore when it
doesn't need to. So I'm queuing this into for-next instead.
>
>>
>> Regards,
>> Anup
>>
>>> ---
>>> drivers/cpuidle/cpuidle-riscv-sbi.c | 7 ++++++-
>>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c
>>> index 1151e5e2ba82..33c92fec4365 100644
>>> --- a/drivers/cpuidle/cpuidle-riscv-sbi.c
>>> +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c
>>> @@ -97,8 +97,13 @@ static int sbi_cpuidle_enter_state(struct cpuidle_device *dev,
>>> struct cpuidle_driver *drv, int idx)
>>> {
>>> u32 *states = __this_cpu_read(sbi_cpuidle_data.states);
>>> + u32 state = states[idx];
>>>
>>> - return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, states[idx]);
>>> + if (state & SBI_HSM_SUSP_NON_RET_BIT)
>>> + return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, state);
>>> + else
>>> + return CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM(sbi_suspend,
>>> + idx, state);
>>> }
>>>
>>> static int __sbi_enter_domain_idle_state(struct cpuidle_device *dev,
>>> --
>>> 2.34.1
>>>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-23 10:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18 8:45 [PATCH] cpuidle: riscv-sbi: Fix CPU_PM_CPU_IDLE_ENTER_xyz() macro usage Anup Patel
2022-07-18 17:27 ` Andrew Jones
2022-08-29 2:59 ` Anup Patel
2022-09-22 17:07 ` Palmer Dabbelt
2022-09-23 10:55 ` Palmer Dabbelt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).