From: Paul Cercueil <paul.cercueil@bootlin.com>
To: Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Kees Cook <kees@kernel.org>,
Tony Luck <tony.luck@intel.com>,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>
Cc: linux-spi@vger.kernel.org, devicetree@vger.kernel.org,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Sunil Kovvuri Goutham <sgoutham@marvell.com>,
Tanmay Jagdale <tanmay@marvell.com>,
Paul Cercueil <paul.cercueil@bootlin.com>
Subject: [PATCH v5 2/4] spi: cadence-xspi: Add irq-less support
Date: Wed, 2 Dec 2026 14:21:33 +0100 [thread overview]
Message-ID: <20261202132135.470814-3-paul.cercueil@bootlin.com> (raw)
In-Reply-To: <20261202132135.470814-1-paul.cercueil@bootlin.com>
From: Tanmay Jagdale <tanmay@marvell.com>
Make the interrupt line optional. If not provided, the driver will
instead resort to polling registers.
This can be useful in itself, but will be used later to support write on
kernel panic.
Note that in irq-less mode we use cdns_xspi_is_{sdma,stig}_ready() to
wait for the commands to complete. The old timeout value was way too low
to cover large transfers, so it was increased to 100 ms.
Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
Changelog:
v5:
- Use forward declarations for cdns_xspi_is_{sdma,stig}_ready()
instead of moving them.
- Increase MRVL_XSPI_POLL_TIMEOUT_US timeout value
v3-v4: No change
v2: Make sure we only enable interrupts if not using polling mode
---
drivers/spi/spi-cadence-xspi.c | 49 +++++++++++++++++++++++-----------
1 file changed, 33 insertions(+), 16 deletions(-)
diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index f5106df93355..4a5376e495c6 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -277,7 +277,7 @@
#define MRVL_XFER_QWORD_BYTECOUNT 8
#define MRVL_XFER_MAX_LEN (MRVL_XFER_QWORD_COUNT * MRVL_XFER_QWORD_BYTECOUNT)
-#define MRVL_XSPI_POLL_TIMEOUT_US 1000
+#define MRVL_XSPI_POLL_TIMEOUT_US 100000
#define MRVL_XSPI_POLL_DELAY_US 10
/* Macros for calculating data bits in generic command
@@ -365,6 +365,9 @@ struct cdns_xspi_dev {
int current_xfer_qword;
};
+static bool cdns_xspi_is_stig_ready(struct cdns_xspi_dev *cdns_xspi, bool sleep);
+static bool cdns_xspi_is_sdma_ready(struct cdns_xspi_dev *cdns_xspi, bool sleep);
+
static void cdns_xspi_dma_cleanup(void *data)
{
struct cdns_xspi_dev *cdns_xspi = data;
@@ -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;
memset(cmd_regs, 0, sizeof(cmd_regs));
@@ -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;
}
}
- 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;
+ }
cmd_status = cdns_xspi_check_command_status(cdns_xspi);
if (cmd_status)
@@ -1216,6 +1229,7 @@ static int cdns_xspi_prepare_transfer(int cs, int dir, int len, u32 *cmd_regs)
return 0;
}
+#endif /* CONFIG_64BIT */
static bool cdns_xspi_is_stig_ready(struct cdns_xspi_dev *cdns_xspi, bool sleep)
{
@@ -1254,6 +1268,7 @@ static bool cdns_xspi_is_sdma_ready(struct cdns_xspi_dev *cdns_xspi, bool sleep)
return true;
}
+#ifdef CONFIG_64BIT
static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
struct spi_message *m)
{
@@ -1506,15 +1521,17 @@ static int cdns_xspi_probe(struct platform_device *pdev)
}
#endif
- cdns_xspi->irq = platform_get_irq(pdev, 0);
- if (cdns_xspi->irq < 0)
- return -ENXIO;
+ cdns_xspi->irq = platform_get_irq_optional(pdev, 0);
+ if (cdns_xspi->irq < 0 && cdns_xspi->irq != -ENXIO)
+ return cdns_xspi->irq;
- ret = devm_request_irq(dev, cdns_xspi->irq, cdns_xspi_irq_handler,
- IRQF_SHARED, pdev->name, cdns_xspi);
- if (ret) {
- dev_err(dev, "Failed to request IRQ: %d\n", cdns_xspi->irq);
- return ret;
+ if (cdns_xspi->irq >= 0) {
+ ret = devm_request_irq(dev, cdns_xspi->irq, cdns_xspi_irq_handler,
+ IRQF_SHARED, pdev->name, cdns_xspi);
+ if (ret) {
+ dev_err(dev, "Failed to request IRQ: %d\n", cdns_xspi->irq);
+ return ret;
+ }
}
#ifdef CONFIG_64BIT
--
2.47.3
next prev parent reply other threads:[~2026-12-02 13:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 13:21 [PATCH v5 0/4] spi: cadence-xspi: Add support for panic mem writes Paul Cercueil
2026-12-02 13:21 ` [PATCH v5 1/4] spi: cadence-xspi: Handle SDMA errors in cdns_xspi_is_sdma_ready() Paul Cercueil
2026-12-02 13:27 ` sashiko-bot
2026-12-02 13:21 ` Paul Cercueil [this message]
2026-12-02 13:21 ` [PATCH v5 3/4] spi: cadence-xspi: Add support for panic writes Paul Cercueil
2026-12-02 13:21 ` [PATCH v5 4/4] spi: dt-bindings: cadence: Make XSPI's IRQ line optional Paul Cercueil
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=20261202132135.470814-3-paul.cercueil@bootlin.com \
--to=paul.cercueil@bootlin.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gpiccoli@igalia.com \
--cc=kees@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sgoutham@marvell.com \
--cc=tanmay@marvell.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tony.luck@intel.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