Skip to contentSkip to conversation

spi: sunplus: handle signal interruption in transfer wait

PATCH In review Andrew Gaylard 2 participants 2 messages Aug 20 – Sep 1

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: sunplus: handle signal interruption in transfer wait

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.

---
 drivers/spi/spi-sunplus-sp7021.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/spi/spi-sunplus-sp7021.c +9 -4
index d78f48bc2b0a..607fc01c4207 100644
@@ -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);
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 1 line · Andrew Gaylard

spi: sunplus: handle signal interruption in transfer wait

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.4

Thanks!

[1/1] spi: sunplus: handle signal interruption in transfer wait

      https://git.kernel.org/broonie/spi/c/7fe2098d612b

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