Skip to content

Commit 71d8056

Browse files
RanWang1broonie
authored andcommitted
spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts
Given the case that bootloader(such as UEFI)'s FSPI driver might not handle all interrupts before loading kernel, those legacy interrupts would assert immidiately once kernel's FSPI driver enable them. Further, if it was FSPI_INTR_IPCMDDONE, the irq handler nxp_fspi_irq_handler() would call complete(&f->c) to notify others. However, f->c might not be initialized yet at that time, then cause kernel panic. Of cause, we should fix this issue within bootloader. But it would be better to have this pacth to make dirver more robust (by clearing all interrupt status bits before enabling interrupts). Suggested-by: Han Xu <han.xu@nxp.com> Signed-off-by: Ran Wang <ran.wang_1@nxp.com> Link: https://lore.kernel.org/r/20201123025715.14635-1-ran.wang_1@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4fae3a5 commit 71d8056

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/spi/spi-nxp-fspi.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ static int nxp_fspi_probe(struct platform_device *pdev)
10011001
struct resource *res;
10021002
struct nxp_fspi *f;
10031003
int ret;
1004+
u32 reg;
10041005

10051006
ctlr = spi_alloc_master(&pdev->dev, sizeof(*f));
10061007
if (!ctlr)
@@ -1032,6 +1033,12 @@ static int nxp_fspi_probe(struct platform_device *pdev)
10321033
goto err_put_ctrl;
10331034
}
10341035

1036+
/* Clear potential interrupts */
1037+
reg = fspi_readl(f, f->iobase + FSPI_INTR);
1038+
if (reg)
1039+
fspi_writel(f, reg, f->iobase + FSPI_INTR);
1040+
1041+
10351042
/* find the resources - controller memory mapped space */
10361043
if (is_acpi_node(f->dev->fwnode))
10371044
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);

0 commit comments

Comments
 (0)