linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Save cpuhp dynamic state
@ 2022-09-14 16:28 Pierre Gondois
  2022-09-14 16:28 ` [PATCH 1/2] driver: soc: xilinx: " Pierre Gondois
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Pierre Gondois @ 2022-09-14 16:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: Pierre Gondois, Daniel Lezcano, Rafael J. Wysocki,
	Abhyuday Godhasara, Michal Simek, linux-pm, linux-arm-kernel

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

Indeed, the following:
  cpuhp_remove_state(CPUHP_AP_ONLINE_DYN);
removes the first dynamic states added to the cpuhp state machine.

Patches were tested as:
- powercap/drivers/dtpm: on a Juno-r2, using a late_initcall()
  to init and exit the dtpm framework.
- driver: soc: xilinx: the patch was only compile tested
  due to missing hardware.

Pierre Gondois (2):
  driver: soc: xilinx: Save cpuhp dynamic state
  powercap/drivers/dtpm: Save cpuhp dynamic state

 drivers/powercap/dtpm_cpu.c             |  7 ++++++-
 drivers/soc/xilinx/xlnx_event_manager.c | 12 ++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] driver: soc: xilinx: Save cpuhp dynamic state
  2022-09-14 16:28 [PATCH 0/2] Save cpuhp dynamic state Pierre Gondois
@ 2022-09-14 16:28 ` Pierre Gondois
  2022-09-14 16:28 ` [PATCH 2/2] powercap/drivers/dtpm: " Pierre Gondois
  2022-10-06  7:54 ` [PATCH 0/2] " Pierre Gondois
  2 siblings, 0 replies; 5+ messages in thread
From: Pierre Gondois @ 2022-09-14 16:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: Pierre Gondois, Daniel Lezcano, Rafael J. Wysocki,
	Abhyuday Godhasara, Michal Simek, linux-pm, linux-arm-kernel

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@arm.com>
---
 drivers/soc/xilinx/xlnx_event_manager.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/xilinx/xlnx_event_manager.c b/drivers/soc/xilinx/xlnx_event_manager.c
index 5dcb7665fe22..be67f74f3b5c 100644
--- a/drivers/soc/xilinx/xlnx_event_manager.c
+++ b/drivers/soc/xilinx/xlnx_event_manager.c
@@ -24,6 +24,8 @@ static DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number1);
 static int virq_sgi;
 static int event_manager_availability = -EACCES;
 
+static int cpuhp_event_state;
+
 /* SGI number used for Event management driver */
 #define XLNX_EVENT_SGI_NUM	(15)
 
@@ -609,7 +611,10 @@ static void xlnx_event_cleanup_sgi(struct platform_device *pdev)
 
 	per_cpu(cpu_number1, cpu) = cpu;
 
-	cpuhp_remove_state(CPUHP_AP_ONLINE_DYN);
+	if (cpuhp_event_state > 0) {
+		cpuhp_remove_state(cpuhp_event_state);
+		cpuhp_event_state = 0;
+	}
 
 	on_each_cpu(xlnx_disable_percpu_irq, NULL, 1);
 
@@ -644,8 +649,11 @@ static int xlnx_event_manager_probe(struct platform_device *pdev)
 	}
 
 	/* Setup function for the CPU hot-plug cases */
-	cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "soc/event:starting",
+	ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "soc/event:starting",
 			  xlnx_event_cpuhp_start, xlnx_event_cpuhp_down);
+	if (ret > 0)
+		cpuhp_event_state = ret;
+
 
 	ret = zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_REGISTER_SGI, sgi_num,
 				  0, NULL);
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] powercap/drivers/dtpm: Save cpuhp dynamic state
  2022-09-14 16:28 [PATCH 0/2] Save cpuhp dynamic state Pierre Gondois
  2022-09-14 16:28 ` [PATCH 1/2] driver: soc: xilinx: " Pierre Gondois
@ 2022-09-14 16:28 ` Pierre Gondois
  2022-10-06  7:54 ` [PATCH 0/2] " Pierre Gondois
  2 siblings, 0 replies; 5+ messages in thread
From: Pierre Gondois @ 2022-09-14 16:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: Pierre Gondois, Daniel Lezcano, Rafael J. Wysocki,
	Abhyuday Godhasara, Michal Simek, linux-pm, linux-arm-kernel

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@arm.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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Save cpuhp dynamic state
  2022-09-14 16:28 [PATCH 0/2] Save cpuhp dynamic state Pierre Gondois
  2022-09-14 16:28 ` [PATCH 1/2] driver: soc: xilinx: " Pierre Gondois
  2022-09-14 16:28 ` [PATCH 2/2] powercap/drivers/dtpm: " Pierre Gondois
@ 2022-10-06  7:54 ` Pierre Gondois
  2023-02-01 16:20   ` Pierre Gondois
  2 siblings, 1 reply; 5+ messages in thread
From: Pierre Gondois @ 2022-10-06  7:54 UTC (permalink / raw)
  To: linux-kernel
  Cc: Daniel Lezcano, Rafael J. Wysocki, Abhyuday Godhasara,
	Michal Simek, linux-pm, linux-arm-kernel

Hello,
Just a ping in case this was forgotten,

Regards,
Pierre

On 9/14/22 18:28, Pierre Gondois wrote:
> 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
> 
> Indeed, the following:
>    cpuhp_remove_state(CPUHP_AP_ONLINE_DYN);
> removes the first dynamic states added to the cpuhp state machine.
> 
> Patches were tested as:
> - powercap/drivers/dtpm: on a Juno-r2, using a late_initcall()
>    to init and exit the dtpm framework.
> - driver: soc: xilinx: the patch was only compile tested
>    due to missing hardware.
> 
> Pierre Gondois (2):
>    driver: soc: xilinx: Save cpuhp dynamic state
>    powercap/drivers/dtpm: Save cpuhp dynamic state
> 
>   drivers/powercap/dtpm_cpu.c             |  7 ++++++-
>   drivers/soc/xilinx/xlnx_event_manager.c | 12 ++++++++++--
>   2 files changed, 16 insertions(+), 3 deletions(-)
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Save cpuhp dynamic state
  2022-10-06  7:54 ` [PATCH 0/2] " Pierre Gondois
@ 2023-02-01 16:20   ` Pierre Gondois
  0 siblings, 0 replies; 5+ messages in thread
From: Pierre Gondois @ 2023-02-01 16:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Daniel Lezcano, Rafael J. Wysocki, Abhyuday Godhasara,
	Michal Simek, linux-pm, linux-arm-kernel

Hello Daniel, Abhyuday,
Another ping just in case,

Regards,
Pierre

On 10/6/22 09:54, Pierre Gondois wrote:
> Hello,
> Just a ping in case this was forgotten,
> 
> Regards,
> Pierre
> 
> On 9/14/22 18:28, Pierre Gondois wrote:
>> 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
>>
>> Indeed, the following:
>>     cpuhp_remove_state(CPUHP_AP_ONLINE_DYN);
>> removes the first dynamic states added to the cpuhp state machine.
>>
>> Patches were tested as:
>> - powercap/drivers/dtpm: on a Juno-r2, using a late_initcall()
>>     to init and exit the dtpm framework.
>> - driver: soc: xilinx: the patch was only compile tested
>>     due to missing hardware.
>>
>> Pierre Gondois (2):
>>     driver: soc: xilinx: Save cpuhp dynamic state
>>     powercap/drivers/dtpm: Save cpuhp dynamic state
>>
>>    drivers/powercap/dtpm_cpu.c             |  7 ++++++-
>>    drivers/soc/xilinx/xlnx_event_manager.c | 12 ++++++++++--
>>    2 files changed, 16 insertions(+), 3 deletions(-)
>>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-01 16:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 16:28 [PATCH 0/2] Save cpuhp dynamic state Pierre Gondois
2022-09-14 16:28 ` [PATCH 1/2] driver: soc: xilinx: " Pierre Gondois
2022-09-14 16:28 ` [PATCH 2/2] powercap/drivers/dtpm: " Pierre Gondois
2022-10-06  7:54 ` [PATCH 0/2] " Pierre Gondois
2023-02-01 16:20   ` Pierre Gondois

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).