All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Paul Cercueil" <paul.cercueil@bootlin.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 2/4] spi: cadence-xspi: Add irq-less support
Date: Thu, 03 Dec 2026 09:36:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-247483@kernel.org> (raw)
In-Reply-To: <20261203091112.9449-3-paul.cercueil@bootlin.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] spi: cadence-xspi: stale SDMA status bits not cleared in
  IRQ-less mode
- [Medium] spi: cadence-xspi: SDMA errors during sdma_handler() missed
  without IRQ
--

commit 225aa14fe46b19e08b932b29be677c66a07c1404
Author: Tanmay Jagdale <tanmay@marvell.com>

spi: cadence-xspi: Add irq-less support

This commit makes the IRQ optional in the Cadence XSPI driver and falls
back to polling for STIG and SDMA completion when no interrupt line is
present.

> diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
> index d041f90321f6c..1738a5983f054 100644
> --- a/drivers/spi/spi-cadence-xspi.c
> +++ b/drivers/spi/spi-cadence-xspi.c

[ ... ]

> @@ -687,7 +690,8 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi,
>  
>  	reinit_completion(&cdns_xspi->cmd_complete);
>  	reinit_completion(&cdns_xspi->sdma_complete);
> -	cdns_xspi->set_interrupts_handler(cdns_xspi, true);
> +	if (cdns_xspi->irq >= 0)
> +		cdns_xspi->set_interrupts_handler(cdns_xspi, true);
>  	cdns_xspi->sdma_error = false;

[Severity: High]
Can stale CDNS_XSPI_SDMA_TRIGGER or CDNS_XSPI_SDMA_ERROR bits in
CDNS_XSPI_INTR_STATUS_REG be left latched here when running without an
IRQ?

Skipping set_interrupts_handler() leaves CDNS_XSPI_INTR_STATUS_REG
uncleared before triggering the command, so bits left over from firmware
or a prior timed-out transfer remain set.  cdns_xspi_is_sdma_ready()
polls that register directly and clears the bits only after matching them.

A stale CDNS_XSPI_SDMA_TRIGGER bit makes cdns_xspi_is_sdma_ready() return
early and run sdma_handler() with stale hardware direction and size
registers on the aliased in_buffer/out_buffer union, which can overwrite
a caller's TX buffer during a write op.

Clearing CDNS_XSPI_SDMA_TRIGGER | CDNS_XSPI_SDMA_ERROR in
CDNS_XSPI_INTR_STATUS_REG before triggering the command would prevent
stale status bits from being consumed.

> @@ -716,20 +720,29 @@ 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;
>  		}
>  		ret = cdns_xspi->sdma_handler(cdns_xspi);
>  		if (ret || cdns_xspi->sdma_error) {
> -			cdns_xspi->set_interrupts_handler(cdns_xspi, false);
> +			if (cdns_xspi->irq >= 0)
> +				cdns_xspi->set_interrupts_handler(cdns_xspi, false);
>  			return ret ?: -EIO;
>  		}

[Severity: Medium]
Will SDMA errors raised during sdma_handler() go undetected when
cdns_xspi->irq < 0?

cdns_xspi->sdma_error is only set by cdns_xspi_irq_handler(), which is
not registered in IRQ-less mode.  If hardware asserts
CDNS_XSPI_SDMA_ERROR while sdma_handler() is transferring data, the
check here misses it and the command can return success with partial data.

The bit also stays latched in CDNS_XSPI_INTR_STATUS_REG because
cdns_xspi_is_stig_ready() only polls CDNS_XSPI_CTRL_STATUS_REG, causing
the next data-phase STIG command to fail with -EIO.

Reading and clearing CDNS_XSPI_SDMA_ERROR from CDNS_XSPI_INTR_STATUS_REG
after sdma_handler() when cdns_xspi->irq < 0 would catch these errors.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203091112.9449-1-paul.cercueil@bootlin.com?part=2

  reply	other threads:[~2026-12-03  9:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  9:11 [PATCH v6 0/4] spi: cadence-xspi: Add support for panic mem writes Paul Cercueil
2026-12-03  9:11 ` [PATCH v6 1/4] spi: cadence-xspi: Handle SDMA errors in cdns_xspi_is_sdma_ready() Paul Cercueil
2026-12-03  9:28   ` sashiko-bot
2026-12-03  9:11 ` [PATCH v6 2/4] spi: cadence-xspi: Add irq-less support Paul Cercueil
2026-12-03  9:36   ` sashiko-bot [this message]
2026-12-03  9:11 ` [PATCH v6 3/4] spi: cadence-xspi: Add support for panic writes Paul Cercueil
2026-12-03  9:37   ` sashiko-bot
2026-12-03  9:11 ` [PATCH v6 4/4] spi: dt-bindings: cadence: Make XSPI's IRQ line optional Paul Cercueil
2026-12-03  9:20   ` sashiko-bot
2026-12-03 18:31   ` Rob Herring (Arm)

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=sashiko-outbox-247483@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=paul.cercueil@bootlin.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.