]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts
authorRan Wang <ran.wang_1@nxp.com>
Mon, 23 Nov 2020 02:57:15 +0000 (10:57 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 23 Nov 2020 14:10:02 +0000 (14:10 +0000)
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>
drivers/spi/spi-nxp-fspi.c

index 0d41406c036deeb5e070b1c2ffbba26658390178..ab9035662717a3b0464bdefb6bb3ca4d10376401 100644 (file)
@@ -1001,6 +1001,7 @@ static int nxp_fspi_probe(struct platform_device *pdev)
        struct resource *res;
        struct nxp_fspi *f;
        int ret;
+       u32 reg;
 
        ctlr = spi_alloc_master(&pdev->dev, sizeof(*f));
        if (!ctlr)
@@ -1032,6 +1033,12 @@ static int nxp_fspi_probe(struct platform_device *pdev)
                goto err_put_ctrl;
        }
 
+       /* Clear potential interrupts */
+       reg = fspi_readl(f, f->iobase + FSPI_INTR);
+       if (reg)
+               fspi_writel(f, reg, f->iobase + FSPI_INTR);
+
+
        /* find the resources - controller memory mapped space */
        if (is_acpi_node(f->dev->fwnode))
                res = platform_get_resource(pdev, IORESOURCE_MEM, 1);