From: Andrew Gaylard <ag@ffroot.co.za>
To: linux-spi@vger.kernel.org
Cc: lhjeff911@gmail.com, broonie@kernel.org,
linux-arm-kernel@lists.infradead.org,
Andrew Gaylard <ag@ffroot.co.za>
Subject: [PATCH] spi: sunplus: handle signal interruption in transfer wait
Date: Thu, 20 Aug 2026 14:58:35 +0200 [thread overview]
Message-ID: <20260820125835.1584270-1-ag@ffroot.co.za> (raw)
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
reply other threads:[~2026-08-20 12:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260820125835.1584270-1-ag@ffroot.co.za \
--to=ag@ffroot.co.za \
--cc=broonie@kernel.org \
--cc=lhjeff911@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
/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