Skip to content

Commit cfadbb9

Browse files
avpatelpalmer-dabbelt
authored andcommitted
cpuidle: riscv-sbi: Fix CPU_PM_CPU_IDLE_ENTER_xyz() macro usage
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: 6abf32f ("cpuidle: Add RISC-V SBI CPU idle driver") Signed-off-by: Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20220718084553.2056169-1-apatel@ventanamicro.com/ Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 096b52f commit cfadbb9

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/cpuidle/cpuidle-riscv-sbi.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,13 @@ static int sbi_cpuidle_enter_state(struct cpuidle_device *dev,
9797
struct cpuidle_driver *drv, int idx)
9898
{
9999
u32 *states = __this_cpu_read(sbi_cpuidle_data.states);
100+
u32 state = states[idx];
100101

101-
return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, states[idx]);
102+
if (state & SBI_HSM_SUSP_NON_RET_BIT)
103+
return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, state);
104+
else
105+
return CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM(sbi_suspend,
106+
idx, state);
102107
}
103108

104109
static int __sbi_enter_domain_idle_state(struct cpuidle_device *dev,

0 commit comments

Comments
 (0)