linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts
@ 2020-11-23  2:57 Ran Wang
  2020-11-23 15:46 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Ran Wang @ 2020-11-23  2:57 UTC (permalink / raw)
  To: Han Xu, Ashish Kumar, Yogesh Gaur, Mark Brown
  Cc: linux-spi, linux-kernel, Ran Wang

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>
---
 drivers/spi/spi-nxp-fspi.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
index 0d41406..ab90356 100644
--- a/drivers/spi/spi-nxp-fspi.c
+++ b/drivers/spi/spi-nxp-fspi.c
@@ -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);
-- 
2.7.4


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

* Re: [PATCH] spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts
  2020-11-23  2:57 [PATCH] spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts Ran Wang
@ 2020-11-23 15:46 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2020-11-23 15:46 UTC (permalink / raw)
  To: Ashish Kumar, Yogesh Gaur, Han Xu, Ran Wang; +Cc: linux-spi, linux-kernel

On Mon, 23 Nov 2020 10:57:15 +0800, Ran Wang wrote:
> 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts
      commit: 71d80563b0760a411cd90a3680536f5d887fff6b

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

end of thread, other threads:[~2020-11-23 15:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-23  2:57 [PATCH] spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts Ran Wang
2020-11-23 15:46 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).