* [PATCH] spi: xilinx: let transfers timeout in case of no IRQ
@ 2026-06-10 22:28 Vadim Fedorenko
2026-06-11 8:13 ` Michal Simek
2026-06-11 13:48 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2026-06-10 22:28 UTC (permalink / raw)
To: Mark Brown, Michal Simek; +Cc: linux-spi, Vadim Fedorenko
In case of failed HW the driver may not see an interrupt and will stuck
in waiting forever. We can avoid such situation by timing out of
transfers if the interrupt is not seen in a reasonable time.
This problem can be found on unload of ptp_ocp driver for TimeCard which
uses Xilinx SPI AXI and SPI-NOR flash memory. During tear-down process
spi-nor drivers send soft reset command which is not triggering an
interrupt stalling the unload process completely.
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
---
drivers/spi/spi-xilinx.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index 9f065d4e27d1..471936a7bb75 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -285,7 +285,11 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
if (use_irq) {
xspi->write_fn(cr, xspi->regs + XSPI_CR_OFFSET);
- wait_for_completion(&xspi->done);
+ if (!wait_for_completion_timeout(&xspi->done, secs_to_jiffies(1))) {
+ dev_err(&spi->dev, "SPI transfer timed out\n");
+ xspi_init_hw(xspi);
+ return -ETIMEDOUT;
+ }
/* A transmit has just completed. Process received data
* and check for more data to transmit. Always inhibit
* the transmitter while the Isr refills the transmit
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] spi: xilinx: let transfers timeout in case of no IRQ
2026-06-10 22:28 [PATCH] spi: xilinx: let transfers timeout in case of no IRQ Vadim Fedorenko
@ 2026-06-11 8:13 ` Michal Simek
2026-06-11 13:48 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2026-06-11 8:13 UTC (permalink / raw)
To: Vadim Fedorenko, Mark Brown; +Cc: linux-spi
On 6/11/26 00:28, Vadim Fedorenko wrote:
> In case of failed HW the driver may not see an interrupt and will stuck
will be stuck/will get stuck
> in waiting forever. We can avoid such situation by timing out of
Imperative mood please.
> transfers if the interrupt is not seen in a reasonable time.
>
> This problem can be found on unload of ptp_ocp driver for TimeCard which
> uses Xilinx SPI AXI and SPI-NOR flash memory. During tear-down process
> spi-nor drivers send soft reset command which is not triggering an
> interrupt stalling the unload process completely.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> ---
> drivers/spi/spi-xilinx.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
> index 9f065d4e27d1..471936a7bb75 100644
> --- a/drivers/spi/spi-xilinx.c
> +++ b/drivers/spi/spi-xilinx.c
> @@ -285,7 +285,11 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
>
> if (use_irq) {
> xspi->write_fn(cr, xspi->regs + XSPI_CR_OFFSET);
> - wait_for_completion(&xspi->done);
> + if (!wait_for_completion_timeout(&xspi->done, secs_to_jiffies(1))) {
> + dev_err(&spi->dev, "SPI transfer timed out\n");
> + xspi_init_hw(xspi);
> + return -ETIMEDOUT;
> + }
> /* A transmit has just completed. Process received data
> * and check for more data to transmit. Always inhibit
> * the transmitter while the Isr refills the transmit
With changes in commit message feel free to add my
Acked-by: Michal Simek <michal.simek@amd.com>
Thanks,
Michal
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] spi: xilinx: let transfers timeout in case of no IRQ
2026-06-10 22:28 [PATCH] spi: xilinx: let transfers timeout in case of no IRQ Vadim Fedorenko
2026-06-11 8:13 ` Michal Simek
@ 2026-06-11 13:48 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-06-11 13:48 UTC (permalink / raw)
To: Michal Simek, Vadim Fedorenko; +Cc: linux-spi
On Wed, 10 Jun 2026 22:28:43 +0000, Vadim Fedorenko wrote:
> spi: xilinx: let transfers timeout in case of no IRQ
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.2
Thanks!
[1/1] spi: xilinx: let transfers timeout in case of no IRQ
https://git.kernel.org/broonie/spi/c/0f95264f49ac
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] 3+ messages in thread
end of thread, other threads:[~2026-06-11 18:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-10 22:28 [PATCH] spi: xilinx: let transfers timeout in case of no IRQ Vadim Fedorenko
2026-06-11 8:13 ` Michal Simek
2026-06-11 13:48 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox