From: sashiko-bot@kernel.org
To: "Pratyush Yadav" <pratyush@kernel.org>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Richard Weinberger" <richard@nod.at>,
"Takahiro Kuwano" <takahiro.kuwano@infineon.com>,
"Paul Cercueil" <paul.cercueil@bootlin.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Mark Brown" <broonie@kernel.org>,
"Michael Walle" <mwalle@kernel.org>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>
Cc: "Tanmay Jagdale" <tanmay@marvell.com>,
"Tony Luck" <tony.luck@intel.com>, "Kees Cook" <kees@kernel.org>,
linux-spi@vger.kernel.org,
"Guilherme G . Piccoli" <gpiccoli@igalia.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/5] spi: cadence-xspi: Add irq-less support
Date: Mon, 05 Oct 2026 08:24:05 +0000 [thread overview]
Message-ID: <20261005082405.D18B81F00898@smtp.kernel.org> (raw)
In-Reply-To: <20261005081141.33688-4-paul.cercueil@bootlin.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] spi: cadence-xspi: unhandled interrupt storm in polling mode
- [High] spi: cadence-xspi: SDMA W1C trigger bit not cleared in polling mode
--
commit 85002136114ad45055d6ac972dbcbdf8c8e3d6b2
Author: Tanmay Jagdale <tanmay@marvell.com>
spi: cadence-xspi: Add irq-less support
This commit makes the interrupt line optional. If an interrupt is not
provided, the driver resorts to polling registers. It modifies
cdns_xspi_send_stig_command() and probe functions to handle environments
without a dedicated IRQ.
> diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
> index 39c868a5b171c..7cf52bcb05df6 100644
> --- a/drivers/spi/spi-cadence-xspi.c
> +++ b/drivers/spi/spi-cadence-xspi.c
> @@ -365,6 +365,30 @@ static int cdns_xspi_wait_for_controller_idle(struct cdns_xspi_dev *cdns_xspi)
[ ... ]
> +static bool cdns_xspi_is_sdma_ready(struct cdns_xspi_dev *cdns_xspi, bool sleep)
> +{
> + u32 ctrl_stat;
> +
> + return !readl_relaxed_poll_timeout
> + (cdns_xspi->iobase + CDNS_XSPI_INTR_STATUS_REG,
> + ctrl_stat,
> + (ctrl_stat & CDNS_XSPI_SDMA_TRIGGER),
> + sleep ? MRVL_XSPI_POLL_DELAY_US : 0,
> + sleep ? MRVL_XSPI_POLL_TIMEOUT_US : 0);
> +}
[Severity: High]
Does this leave the W1C (Write-1-to-Clear) trigger bit set?
It appears CDNS_XSPI_INTR_STATUS_REG is a latching W1C register (as seen in
cdns_xspi_irq_handler() which reads and writes back to clear latched events).
In polling mode (when irq < 0), this function only reads the register. For
base Cadence hardware, cdns_xspi_set_interrupts() doesn't clear this either.
Could this cause the CDNS_XSPI_SDMA_TRIGGER bit to remain permanently set
after the first SDMA transfer, leading subsequent transfers to falsely see a
ready state and potentially access memory prematurely?
[ ... ]
> @@ -562,16 +586,25 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi,
>
> cdns_xspi_trigger_command(cdns_xspi, cmd_regs);
>
> - wait_for_completion(&cdns_xspi->sdma_complete);
> - if (cdns_xspi->sdma_error) {
> - cdns_xspi->set_interrupts_handler(cdns_xspi, false);
> + if (cdns_xspi->irq >= 0) {
> + wait_for_completion(&cdns_xspi->sdma_complete);
> + if (cdns_xspi->sdma_error) {
> + cdns_xspi->set_interrupts_handler(cdns_xspi, false);
> + return -EIO;
> + }
> + } else if (!cdns_xspi_is_sdma_ready(cdns_xspi, true)) {
> return -EIO;
> }
> +
> cdns_xspi->sdma_handler(cdns_xspi);
> }
>
> - wait_for_completion(&cdns_xspi->cmd_complete);
> - cdns_xspi->set_interrupts_handler(cdns_xspi, false);
> + if (cdns_xspi->irq >= 0) {
> + wait_for_completion(&cdns_xspi->cmd_complete);
> + cdns_xspi->set_interrupts_handler(cdns_xspi, false);
> + } else if (!cdns_xspi_is_stig_ready(cdns_xspi, true)) {
> + return -EIO;
> + }
[Severity: High]
Does this leave hardware interrupts permanently unmasked in polling mode?
At the start of cdns_xspi_send_stig_command(), interrupts are unmasked
unconditionally:
cdns_xspi->set_interrupts_handler(cdns_xspi, true);
However, when irq < 0, the corresponding teardown call:
cdns_xspi->set_interrupts_handler(cdns_xspi, false);
is skipped because it is guarded by if (cdns_xspi->irq >= 0).
If the physical IRQ line is connected or shared, could this cause the
controller to assert it indefinitely, triggering an unhandled interrupt storm
that forces the kernel to disable the IRQ line?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261005081141.33688-1-paul.cercueil@bootlin.com?part=3
next prev parent reply other threads:[~2026-10-05 8:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 8:11 [PATCH 0/5] spi: Add support for panic mem writes Paul Cercueil
2026-10-05 8:11 ` [PATCH 1/5] spi: spi-mem: " Paul Cercueil
2026-10-05 8:24 ` sashiko-bot
2026-10-05 8:11 ` [PATCH 2/5] mtd: spi-nor: Add support for panic writes Paul Cercueil
2026-10-05 8:23 ` sashiko-bot
2026-10-05 8:11 ` [PATCH 3/5] spi: cadence-xspi: Add irq-less support Paul Cercueil
2026-10-05 8:24 ` sashiko-bot [this message]
2026-10-05 8:11 ` [PATCH 4/5] spi: cadence-xspi: Don't use infinite timeout in register poll Paul Cercueil
2026-10-05 8:21 ` sashiko-bot
2026-10-05 8:11 ` [PATCH 5/5] spi: cadence-xspi: Add support for panic writes Paul Cercueil
2026-10-05 8:26 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261005082405.D18B81F00898@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=broonie@kernel.org \
--cc=gpiccoli@igalia.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=mwalle@kernel.org \
--cc=paul.cercueil@bootlin.com \
--cc=pratyush@kernel.org \
--cc=richard@nod.at \
--cc=sashiko-reviews@lists.linux.dev \
--cc=takahiro.kuwano@infineon.com \
--cc=tanmay@marvell.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tony.luck@intel.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®