The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
To: ptsm@linux.microsoft.com, jassisinghbrar@gmail.com,
	michal.simek@amd.com, tanmay.shah@amd.com,
	saeed.nowshadi@amd.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	ssengar@linux.microsoft.com, tgopinath@linux.microsoft.com,
	srivatsa@csail.mit.edu, tejas.patel@xilinx.com,
	rajan.vaja@xilinx.com, abhyuday.godhasara@xilinx.com,
	gregkh@linuxfoundation.org
Subject: [PATCH v2 2/2] soc: xilinx: Fix event manager CPU hotplug state cleanup
Date: Mon, 30 Nov 2026 01:45:13 -0800	[thread overview]
Message-ID: <20261130094513.2454356-3-ptsm@linux.microsoft.com> (raw)
In-Reply-To: <20261130094513.2454356-1-ptsm@linux.microsoft.com>

On driver removal, the event manager removes the CPUHP_AP_ONLINE_DYN
CPU hotplug state instead of its actual state. This can leave the event
manager callbacks dangling. Use the actual CPU hotplug state during
driver removal.

Hotplug registration failures are also ignored, allowing probe to
succeed without the callbacks needed to enable event interrupts on
CPUs brought online later.

This is found by code inspection.

Fixes: c7fdb2404f66 ("drivers: soc: xilinx: add xilinx event management driver")
Cc: stable@vger.kernel.org
Signed-off-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
Reviewed-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
---
 drivers/soc/xilinx/xlnx_event_manager.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/xilinx/xlnx_event_manager.c b/drivers/soc/xilinx/xlnx_event_manager.c
index f733dc42b3b1..e09a315b65a6 100644
--- a/drivers/soc/xilinx/xlnx_event_manager.c
+++ b/drivers/soc/xilinx/xlnx_event_manager.c
@@ -24,6 +24,7 @@ static DEFINE_PER_CPU_READ_MOSTLY(int, dummy_cpu_number);
 
 static int virq_sgi;
 static int event_manager_availability = -EACCES;
+static enum cpuhp_state hp_state;
 
 /* SGI number used for Event management driver */
 #define XLNX_EVENT_SGI_NUM	(15)
@@ -625,8 +626,6 @@ static int xlnx_event_init_sgi(struct platform_device *pdev)
 
 static void xlnx_event_cleanup_sgi(struct platform_device *pdev)
 {
-	cpuhp_remove_state(CPUHP_AP_ONLINE_DYN);
-
 	on_each_cpu(xlnx_disable_percpu_irq, NULL, 1);
 
 	irq_clear_status_flags(virq_sgi, IRQ_PER_CPU);
@@ -660,8 +659,14 @@ 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",
-			  xlnx_event_cpuhp_start, xlnx_event_cpuhp_down);
+	hp_state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
+				     "soc/event:starting",
+				     xlnx_event_cpuhp_start,
+				     xlnx_event_cpuhp_down);
+	if (hp_state < 0) {
+		xlnx_event_cleanup_sgi(pdev);
+		return hp_state;
+	}
 
 	ret = zynqmp_pm_register_sgi(sgi_num, 0);
 	if (ret) {
@@ -670,6 +675,7 @@ static int xlnx_event_manager_probe(struct platform_device *pdev)
 		else
 			dev_err(&pdev->dev, "SGI %d registration failed, err %d\n", sgi_num, ret);
 
+		cpuhp_remove_state(hp_state);
 		xlnx_event_cleanup_sgi(pdev);
 		return ret;
 	}
@@ -704,6 +710,7 @@ static void xlnx_event_manager_remove(struct platform_device *pdev)
 	if (ret)
 		dev_err(&pdev->dev, "SGI unregistration over TF-A failed with %d\n", ret);
 
+	cpuhp_remove_state(hp_state);
 	xlnx_event_cleanup_sgi(pdev);
 
 	event_manager_availability = -EACCES;
-- 
2.49.0


      parent reply	other threads:[~2026-11-30  9:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  9:45 [PATCH v2 0/2] Fix CPU hotplug state cleanup in Xilinx drivers Prasanna Kumar T S M
2026-11-30  9:45 ` [PATCH v2 1/2] mailbox: zynqmp-ipi: Fix CPU hotplug state cleanup Prasanna Kumar T S M
2026-11-30  9:45 ` Prasanna Kumar T S M [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130094513.2454356-3-ptsm@linux.microsoft.com \
    --to=ptsm@linux.microsoft.com \
    --cc=abhyuday.godhasara@xilinx.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=rajan.vaja@xilinx.com \
    --cc=saeed.nowshadi@amd.com \
    --cc=srivatsa@csail.mit.edu \
    --cc=ssengar@linux.microsoft.com \
    --cc=tanmay.shah@amd.com \
    --cc=tejas.patel@xilinx.com \
    --cc=tgopinath@linux.microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox