* [PATCH] spi: sunplus: handle signal interruption in transfer wait
@ 2026-08-20 12:58 Andrew Gaylard
0 siblings, 0 replies; only message in thread
From: Andrew Gaylard @ 2026-08-20 12:58 UTC (permalink / raw)
To: linux-spi; +Cc: lhjeff911, broonie, linux-arm-kernel, Andrew Gaylard
wait_for_completion_interruptible_timeout() returns -ERESTARTSYS when
interrupted by a signal, 0 on timeout, and positive on success. The
previous check was:
if (!wait_for_completion_interruptible_timeout(...))
SIGKILL caused the interrupted path to fall through as if the transfer
succeeded. The loop then re-entered mutex_lock() on the next
iteration, which is TASK_UNINTERRUPTIBLE. The process could not be
killed while blocked there.
Check ret <= 0 and return -EINTR for the interrupted case so the process
can exit promptly on SIGKILL.
Signed-off-by: Andrew Gaylard <ag@ffroot.co.za>
---
drivers/spi/spi-sunplus-sp7021.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-sunplus-sp7021.c b/drivers/spi/spi-sunplus-sp7021.c
index d78f48bc2b0a..607fc01c4207 100644
--- a/drivers/spi/spi-sunplus-sp7021.c
+++ b/drivers/spi/spi-sunplus-sp7021.c
@@ -338,10 +338,15 @@ static int sp7021_spi_host_transfer_one(struct spi_controller *ctlr, struct spi_
SP7021_SPI_START_FD;
writel(reg_temp, pspim->m_base + SP7021_SPI_STATUS_REG);
- if (!wait_for_completion_interruptible_timeout(&pspim->isr_done, timeout)) {
- dev_err(&spi->dev, "wait_for_completion err\n");
- mutex_unlock(&pspim->buf_lock);
- return -ETIMEDOUT;
+ {
+ long ret = wait_for_completion_interruptible_timeout(
+ &pspim->isr_done, timeout);
+ if (ret <= 0) {
+ dev_err(&spi->dev, ret == 0 ? "SPI transfer timeout\n"
+ : "SPI transfer interrupted\n");
+ mutex_unlock(&pspim->buf_lock);
+ return ret == 0 ? -ETIMEDOUT : -EINTR;
+ }
}
reg_temp = readl(pspim->m_base + SP7021_SPI_STATUS_REG);
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-20 12:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-20 12:58 [PATCH] spi: sunplus: handle signal interruption in transfer wait Andrew Gaylard
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.