[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220914162815.1954866-3-pierre.gondois@arm.com>
Date: Wed, 14 Sep 2022 18:28:15 +0200
From: Pierre Gondois <pierre.gondois@....com>
To: linux-kernel@...r.kernel.org
Cc: Pierre Gondois <pierre.gondois@....com>,
Daniel Lezcano <daniel.lezcano@...nel.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Abhyuday Godhasara <abhyuday.godhasara@...inx.com>,
Michal Simek <michal.simek@...inx.com>,
linux-pm@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: [PATCH 2/2] powercap/drivers/dtpm: Save cpuhp dynamic state
Requesting a CPUHP_AP_ONLINE_DYN cpuhp state reserves a state
among the range [CPUHP_AP_ONLINE_DYN:CPUHP_AP_ONLINE_DYN_END].
The reserved state must be saved in order to remove it later.
Cf. __cpuhp_setup_state_cpuslocked() documentation:
Return:
On success:
Positive state number if @state is CPUHP_AP_ONLINE_DYN;
0 for all other states
Signed-off-by: Pierre Gondois <pierre.gondois@....com>
---
drivers/powercap/dtpm_cpu.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c
index f5eced0842b3..1dfbfe54d3bf 100644
--- a/drivers/powercap/dtpm_cpu.c
+++ b/drivers/powercap/dtpm_cpu.c
@@ -33,6 +33,7 @@ struct dtpm_cpu {
};
static DEFINE_PER_CPU(struct dtpm_cpu *, dtpm_per_cpu);
+static int cpuhp_dtpm_cpu_online_state;
static struct dtpm_cpu *to_dtpm_cpu(struct dtpm *dtpm)
{
@@ -296,12 +297,16 @@ static int dtpm_cpu_init(void)
if (ret < 0)
return ret;
+ cpuhp_dtpm_cpu_online_state = ret;
return 0;
}
static void dtpm_cpu_exit(void)
{
- cpuhp_remove_state_nocalls(CPUHP_AP_ONLINE_DYN);
+ if (cpuhp_dtpm_cpu_online_state > 0) {
+ cpuhp_remove_state_nocalls(cpuhp_dtpm_cpu_online_state);
+ cpuhp_dtpm_cpu_online_state = 0;
+ }
cpuhp_remove_state_nocalls(CPUHP_AP_DTPM_CPU_DEAD);
}
--
2.25.1
Powered by blists - more mailing lists