Skip to content

Commit 1ee147e

Browse files
Harini Tgregkh
authored andcommitted
mailbox: zynqmp-ipi: Fix SGI cleanup on unbind
[ Upstream commit bb160e7 ] The driver incorrectly determines SGI vs SPI interrupts by checking IRQ number < 16, which fails with dynamic IRQ allocation. During unbind, this causes improper SGI cleanup leading to kernel crash. Add explicit irq_type field to pdata for reliable identification of SGI interrupts (type-2) and only clean up SGI resources when appropriate. Fixes: 6ffb163 ("mailbox: zynqmp: handle SGI for shared IPI") Signed-off-by: Harini T <harini.t@amd.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent cd0cbf2 commit 1ee147e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/mailbox/zynqmp-ipi-mailbox.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
#define DST_BIT_POS 9U
6363
#define SRC_BITMASK GENMASK(11, 8)
6464

65-
#define MAX_SGI 16
65+
/* Macro to represent SGI type for IPI IRQs */
66+
#define IPI_IRQ_TYPE_SGI 2
6667

6768
/*
6869
* Module parameters
@@ -121,6 +122,7 @@ struct zynqmp_ipi_mbox {
121122
* @dev: device pointer corresponding to the Xilinx ZynqMP
122123
* IPI agent
123124
* @irq: IPI agent interrupt ID
125+
* @irq_type: IPI SGI or SPI IRQ type
124126
* @method: IPI SMC or HVC is going to be used
125127
* @local_id: local IPI agent ID
126128
* @virq_sgi: IRQ number mapped to SGI
@@ -130,6 +132,7 @@ struct zynqmp_ipi_mbox {
130132
struct zynqmp_ipi_pdata {
131133
struct device *dev;
132134
int irq;
135+
unsigned int irq_type;
133136
unsigned int method;
134137
u32 local_id;
135138
int virq_sgi;
@@ -887,7 +890,7 @@ static void zynqmp_ipi_free_mboxes(struct zynqmp_ipi_pdata *pdata)
887890
struct zynqmp_ipi_mbox *ipi_mbox;
888891
int i;
889892

890-
if (pdata->irq < MAX_SGI)
893+
if (pdata->irq_type == IPI_IRQ_TYPE_SGI)
891894
xlnx_mbox_cleanup_sgi(pdata);
892895

893896
i = pdata->num_mboxes - 1;
@@ -956,14 +959,16 @@ static int zynqmp_ipi_probe(struct platform_device *pdev)
956959
dev_err(dev, "failed to parse interrupts\n");
957960
goto free_mbox_dev;
958961
}
959-
ret = out_irq.args[1];
962+
963+
/* Use interrupt type to distinguish SGI and SPI interrupts */
964+
pdata->irq_type = out_irq.args[0];
960965

961966
/*
962967
* If Interrupt number is in SGI range, then request SGI else request
963968
* IPI system IRQ.
964969
*/
965-
if (ret < MAX_SGI) {
966-
pdata->irq = ret;
970+
if (pdata->irq_type == IPI_IRQ_TYPE_SGI) {
971+
pdata->irq = out_irq.args[1];
967972
ret = xlnx_mbox_init_sgi(pdev, pdata->irq, pdata);
968973
if (ret)
969974
goto free_mbox_dev;

0 commit comments

Comments
 (0)