mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/5] Fix CPU hotplug and SGI cleanup in Xilinx drivers
@ 2026-12-04  5:04 Prasanna Kumar T S M
  2026-12-04  5:04 ` [PATCH v3 1/5] mailbox: zynqmp-ipi: Fix CPU hotplug state cleanup Prasanna Kumar T S M
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Prasanna Kumar T S M @ 2026-12-04  5:04 UTC (permalink / raw)
  To: ptsm, jassisinghbrar, michal.simek, tanmay.shah, saeed.nowshadi,
	linux-kernel, linux-arm-kernel, ssengar, tgopinath, srivatsa,
	jay.buddhabhatti, gregkh, radheys

Both the ZynqMP IPI mailbox driver and the Xilinx event management
driver register dynamic CPU hotplug callbacks using CPUHP_AP_ONLINE_DYN,
but discard the allocated state ID and later attempt to remove
CPUHP_AP_ONLINE_DYN directly. This leaves the actual callbacks dangling
after driver removal and ignores hotplug registration failures.

This series fixes CPU hotplug state tracking and SGI teardown in both
drivers.

Changes since v2:
- Return cpuhp_setup_state() error directly from xlnx_mbox_init_sgi()
  and leave SGI teardown to the caller, as discussed on v1.
- Split the request_percpu_irq() / unmapped virq_sgi cleanup fix into
  a separate patch.
- Add cleanup patches for both drivers to remove the now-redundant
  on_each_cpu(xlnx_disable_percpu_irq, ...) calls.

Link to v2: https://lore.kernel.org/lkml/20261130094513.2454356-1-ptsm@linux.microsoft.com/.

Prasanna Kumar T S M (5):
  mailbox: zynqmp-ipi: Fix CPU hotplug state cleanup
  mailbox: zynqmp-ipi: Fix SGI cleanup on request_percpu_irq() failure
  mailbox: zynqmp-ipi: Remove redundant percpu IRQ disable
  soc: xilinx: Fix event manager CPU hotplug state cleanup
  soc: xilinx: Remove redundant percpu IRQ disable

 drivers/mailbox/zynqmp-ipi-mailbox.c    | 35 ++++++++++++-------------
 drivers/soc/xilinx/xlnx_event_manager.c | 22 ++++++++--------
 2 files changed, 28 insertions(+), 29 deletions(-)

-- 
2.49.0


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

* [PATCH v3 1/5] mailbox: zynqmp-ipi: Fix CPU hotplug state cleanup
  2026-12-04  5:04 [PATCH v3 0/5] Fix CPU hotplug and SGI cleanup in Xilinx drivers Prasanna Kumar T S M
@ 2026-12-04  5:04 ` Prasanna Kumar T S M
  2026-12-04  5:04 ` [PATCH v3 2/5] mailbox: zynqmp-ipi: Fix SGI cleanup on request_percpu_irq() failure Prasanna Kumar T S M
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Prasanna Kumar T S M @ 2026-12-04  5:04 UTC (permalink / raw)
  To: ptsm, jassisinghbrar, michal.simek, tanmay.shah, saeed.nowshadi,
	linux-kernel, linux-arm-kernel, ssengar, tgopinath, srivatsa,
	jay.buddhabhatti, gregkh, radheys

On driver removal, the CPUHP_AP_ONLINE_DYN CPU hotplug state is removed
instead of its actual state. This can leave the mailbox driver 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 interrupts on CPUs
brought online later.

Fixes: 6ffb1635341b ("mailbox: zynqmp: handle SGI for shared IPI")
Cc: stable@vger.kernel.org
Signed-off-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
---
 drivers/mailbox/zynqmp-ipi-mailbox.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c
index 42d2583e44ca..179f361d04b3 100644
--- a/drivers/mailbox/zynqmp-ipi-mailbox.c
+++ b/drivers/mailbox/zynqmp-ipi-mailbox.c
@@ -126,6 +126,7 @@ struct zynqmp_ipi_mbox {
  * @method:               IPI SMC or HVC is going to be used
  * @local_id:             local IPI agent ID
  * @virq_sgi:             IRQ number mapped to SGI
+ * @hp_state:             CPU hotplug state for SGI callbacks
  * @num_mboxes:           number of mailboxes of this IPI agent
  * @ipi_mboxes:           IPI mailboxes of this IPI agent
  */
@@ -136,6 +137,7 @@ struct zynqmp_ipi_pdata {
 	unsigned int method;
 	u32 local_id;
 	int virq_sgi;
+	enum cpuhp_state hp_state;
 	int num_mboxes;
 	struct zynqmp_ipi_mbox ipi_mboxes[] __counted_by(num_mboxes);
 };
@@ -863,15 +865,20 @@ static int xlnx_mbox_init_sgi(struct platform_device *pdev,
 	irq_set_status_flags(pdata->virq_sgi, IRQ_PER_CPU);
 
 	/* Setup function for the CPU hot-plug cases */
-	cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mailbox/sgi:starting",
-			  xlnx_mbox_cpuhp_start, xlnx_mbox_cpuhp_down);
+	pdata->hp_state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
+					    "mailbox/sgi:starting",
+					    xlnx_mbox_cpuhp_start,
+					    xlnx_mbox_cpuhp_down);
+	if (pdata->hp_state < 0)
+		return pdata->hp_state;
 
-	return ret;
+	return 0;
 }
 
 static void xlnx_mbox_cleanup_sgi(struct zynqmp_ipi_pdata *pdata)
 {
-	cpuhp_remove_state(CPUHP_AP_ONLINE_DYN);
+	if (pdata->hp_state >= CPUHP_AP_ONLINE_DYN)
+		cpuhp_remove_state(pdata->hp_state);
 
 	on_each_cpu(xlnx_disable_percpu_irq, NULL, 1);
 
-- 
2.49.0


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

* [PATCH v3 2/5] mailbox: zynqmp-ipi: Fix SGI cleanup on request_percpu_irq() failure
  2026-12-04  5:04 [PATCH v3 0/5] Fix CPU hotplug and SGI cleanup in Xilinx drivers Prasanna Kumar T S M
  2026-12-04  5:04 ` [PATCH v3 1/5] mailbox: zynqmp-ipi: Fix CPU hotplug state cleanup Prasanna Kumar T S M
@ 2026-12-04  5:04 ` Prasanna Kumar T S M
  2026-12-04  5:04 ` [PATCH v3 3/5] mailbox: zynqmp-ipi: Remove redundant percpu IRQ disable Prasanna Kumar T S M
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Prasanna Kumar T S M @ 2026-12-04  5:04 UTC (permalink / raw)
  To: ptsm, jassisinghbrar, michal.simek, tanmay.shah, saeed.nowshadi,
	linux-kernel, linux-arm-kernel, ssengar, tgopinath, srivatsa,
	jay.buddhabhatti, gregkh, radheys

When xlnx_mbox_init_sgi() fails before or during request_percpu_irq(),
zynqmp_ipi_probe() still invokes xlnx_mbox_cleanup_sgi() through
zynqmp_ipi_free_mboxes(). This causes cleanup to run on an unmapped
virq_sgi or dispose the IRQ mapping a second time.

Clear virq_sgi after disposing the mapping on request_percpu_irq()
failure and teardown IRQ in xlnx_mbox_cleanup_sgi() only when virq_sgi
is valid.

Fixes: 6ffb1635341b ("mailbox: zynqmp: handle SGI for shared IPI")
Cc: stable@vger.kernel.org
Signed-off-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
---
 drivers/mailbox/zynqmp-ipi-mailbox.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c
index 179f361d04b3..b978f4e9f830 100644
--- a/drivers/mailbox/zynqmp-ipi-mailbox.c
+++ b/drivers/mailbox/zynqmp-ipi-mailbox.c
@@ -859,6 +859,7 @@ static int xlnx_mbox_init_sgi(struct platform_device *pdev,
 	WARN_ON(ret);
 	if (ret) {
 		irq_dispose_mapping(pdata->virq_sgi);
+		pdata->virq_sgi = 0;
 		return ret;
 	}
 
@@ -880,11 +881,13 @@ static void xlnx_mbox_cleanup_sgi(struct zynqmp_ipi_pdata *pdata)
 	if (pdata->hp_state >= CPUHP_AP_ONLINE_DYN)
 		cpuhp_remove_state(pdata->hp_state);
 
-	on_each_cpu(xlnx_disable_percpu_irq, NULL, 1);
+	if (pdata->virq_sgi) {
+		on_each_cpu(xlnx_disable_percpu_irq, NULL, 1);
 
-	irq_clear_status_flags(pdata->virq_sgi, IRQ_PER_CPU);
-	free_percpu_irq(pdata->virq_sgi, &per_cpu_pdata);
-	irq_dispose_mapping(pdata->virq_sgi);
+		irq_clear_status_flags(pdata->virq_sgi, IRQ_PER_CPU);
+		free_percpu_irq(pdata->virq_sgi, &per_cpu_pdata);
+		irq_dispose_mapping(pdata->virq_sgi);
+	}
 }
 
 /**
-- 
2.49.0


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

* [PATCH v3 3/5] mailbox: zynqmp-ipi: Remove redundant percpu IRQ disable
  2026-12-04  5:04 [PATCH v3 0/5] Fix CPU hotplug and SGI cleanup in Xilinx drivers Prasanna Kumar T S M
  2026-12-04  5:04 ` [PATCH v3 1/5] mailbox: zynqmp-ipi: Fix CPU hotplug state cleanup Prasanna Kumar T S M
  2026-12-04  5:04 ` [PATCH v3 2/5] mailbox: zynqmp-ipi: Fix SGI cleanup on request_percpu_irq() failure Prasanna Kumar T S M
@ 2026-12-04  5:04 ` Prasanna Kumar T S M
  2026-12-04  5:04 ` [PATCH v3 4/5] soc: xilinx: Fix event manager CPU hotplug state cleanup Prasanna Kumar T S M
  2026-12-04  5:04 ` [PATCH v3 5/5] soc: xilinx: Remove redundant percpu IRQ disable Prasanna Kumar T S M
  4 siblings, 0 replies; 6+ messages in thread
From: Prasanna Kumar T S M @ 2026-12-04  5:04 UTC (permalink / raw)
  To: ptsm, jassisinghbrar, michal.simek, tanmay.shah, saeed.nowshadi,
	linux-kernel, linux-arm-kernel, ssengar, tgopinath, srivatsa,
	jay.buddhabhatti, gregkh, radheys

Removing the registered CPU hotplug state already invokes the teardown
callback on every online CPU disabling the SGI percpu interrupt. The
additional on_each_cpu() is redundant, and on hotplug registration
failure it disables an interrupt that was never enabled.

Remove xlnx_disable_percpu_irq() and its on_each_cpu() call.

Signed-off-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
---
 drivers/mailbox/zynqmp-ipi-mailbox.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c
index b978f4e9f830..ccc1d2233cbe 100644
--- a/drivers/mailbox/zynqmp-ipi-mailbox.c
+++ b/drivers/mailbox/zynqmp-ipi-mailbox.c
@@ -799,15 +799,6 @@ static int xlnx_mbox_cpuhp_down(unsigned int cpu)
 	return 0;
 }
 
-static void xlnx_disable_percpu_irq(void *data)
-{
-	struct zynqmp_ipi_pdata *pdata;
-
-	pdata = *this_cpu_ptr(&per_cpu_pdata);
-
-	disable_percpu_irq(pdata->virq_sgi);
-}
-
 static int xlnx_mbox_init_sgi(struct platform_device *pdev,
 			      int sgi_num,
 			      struct zynqmp_ipi_pdata *pdata)
@@ -882,8 +873,6 @@ static void xlnx_mbox_cleanup_sgi(struct zynqmp_ipi_pdata *pdata)
 		cpuhp_remove_state(pdata->hp_state);
 
 	if (pdata->virq_sgi) {
-		on_each_cpu(xlnx_disable_percpu_irq, NULL, 1);
-
 		irq_clear_status_flags(pdata->virq_sgi, IRQ_PER_CPU);
 		free_percpu_irq(pdata->virq_sgi, &per_cpu_pdata);
 		irq_dispose_mapping(pdata->virq_sgi);
-- 
2.49.0


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

* [PATCH v3 4/5] soc: xilinx: Fix event manager CPU hotplug state cleanup
  2026-12-04  5:04 [PATCH v3 0/5] Fix CPU hotplug and SGI cleanup in Xilinx drivers Prasanna Kumar T S M
                   ` (2 preceding siblings ...)
  2026-12-04  5:04 ` [PATCH v3 3/5] mailbox: zynqmp-ipi: Remove redundant percpu IRQ disable Prasanna Kumar T S M
@ 2026-12-04  5:04 ` Prasanna Kumar T S M
  2026-12-04  5:04 ` [PATCH v3 5/5] soc: xilinx: Remove redundant percpu IRQ disable Prasanna Kumar T S M
  4 siblings, 0 replies; 6+ messages in thread
From: Prasanna Kumar T S M @ 2026-12-04  5:04 UTC (permalink / raw)
  To: ptsm, jassisinghbrar, michal.simek, tanmay.shah, saeed.nowshadi,
	linux-kernel, linux-arm-kernel, ssengar, tgopinath, srivatsa,
	jay.buddhabhatti, gregkh, radheys

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.

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>
Reviewed-by: Srivatsa S. Bhat (Microsoft) <srivatsa@csail.mit.edu>
---
 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


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

* [PATCH v3 5/5] soc: xilinx: Remove redundant percpu IRQ disable
  2026-12-04  5:04 [PATCH v3 0/5] Fix CPU hotplug and SGI cleanup in Xilinx drivers Prasanna Kumar T S M
                   ` (3 preceding siblings ...)
  2026-12-04  5:04 ` [PATCH v3 4/5] soc: xilinx: Fix event manager CPU hotplug state cleanup Prasanna Kumar T S M
@ 2026-12-04  5:04 ` Prasanna Kumar T S M
  4 siblings, 0 replies; 6+ messages in thread
From: Prasanna Kumar T S M @ 2026-12-04  5:04 UTC (permalink / raw)
  To: ptsm, jassisinghbrar, michal.simek, tanmay.shah, saeed.nowshadi,
	linux-kernel, linux-arm-kernel, ssengar, tgopinath, srivatsa,
	jay.buddhabhatti, gregkh, radheys

Removing the registered CPU hotplug state already invokes the teardown
callback on every online CPU disabling the SGI percpu interrupt. The
additional on_each_cpu() is redundant.

Remove xlnx_disable_percpu_irq() and its on_each_cpu() call.

Signed-off-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
---
 drivers/soc/xilinx/xlnx_event_manager.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/soc/xilinx/xlnx_event_manager.c b/drivers/soc/xilinx/xlnx_event_manager.c
index e09a315b65a6..42ec6149d870 100644
--- a/drivers/soc/xilinx/xlnx_event_manager.c
+++ b/drivers/soc/xilinx/xlnx_event_manager.c
@@ -565,11 +565,6 @@ static int xlnx_event_cpuhp_down(unsigned int cpu)
 	return 0;
 }
 
-static void xlnx_disable_percpu_irq(void *data)
-{
-	disable_percpu_irq(virq_sgi);
-}
-
 static int xlnx_event_init_sgi(struct platform_device *pdev)
 {
 	int ret = 0;
@@ -626,8 +621,6 @@ static int xlnx_event_init_sgi(struct platform_device *pdev)
 
 static void xlnx_event_cleanup_sgi(struct platform_device *pdev)
 {
-	on_each_cpu(xlnx_disable_percpu_irq, NULL, 1);
-
 	irq_clear_status_flags(virq_sgi, IRQ_PER_CPU);
 	free_percpu_irq(virq_sgi, &dummy_cpu_number);
 	irq_dispose_mapping(virq_sgi);
-- 
2.49.0


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

end of thread, other threads:[~2026-12-04  5:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-04  5:04 [PATCH v3 0/5] Fix CPU hotplug and SGI cleanup in Xilinx drivers Prasanna Kumar T S M
2026-12-04  5:04 ` [PATCH v3 1/5] mailbox: zynqmp-ipi: Fix CPU hotplug state cleanup Prasanna Kumar T S M
2026-12-04  5:04 ` [PATCH v3 2/5] mailbox: zynqmp-ipi: Fix SGI cleanup on request_percpu_irq() failure Prasanna Kumar T S M
2026-12-04  5:04 ` [PATCH v3 3/5] mailbox: zynqmp-ipi: Remove redundant percpu IRQ disable Prasanna Kumar T S M
2026-12-04  5:04 ` [PATCH v3 4/5] soc: xilinx: Fix event manager CPU hotplug state cleanup Prasanna Kumar T S M
2026-12-04  5:04 ` [PATCH v3 5/5] soc: xilinx: Remove redundant percpu IRQ disable Prasanna Kumar T S M

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®