[PATCH 1/2] driver: soc: xilinx: Save cpuhp dynamic state

Pierre Gondois pierre.gondois at arm.com
Wed Sep 14 09:28:14 PDT 2022


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 at 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




More information about the linux-arm-kernel mailing list