[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <b8944e9cab8eb959d888ae80add6f2a686159ba2.1751541962.git.viresh.kumar@linaro.org>
Date: Thu, 3 Jul 2025 17:01:02 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Viresh Kumar <viresh.kumar@...aro.org>,
"Chen, Jian Jun" <jian.jun.chen@...el.com>,
Andi Shyti <andi.shyti@...nel.org>
Cc: Vincent Guittot <vincent.guittot@...aro.org>,
linux-i2c@...r.kernel.org,
virtualization@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: [PATCH] i2c: virtio: Avoid hang by using interruptible completion wait
The current implementation uses wait_for_completion(), which can cause
the caller to hang indefinitely if the transfer never completes.
Switch to wait_for_completion_interruptible() so that the operation can
be interrupted by signals.
Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
---
drivers/i2c/busses/i2c-virtio.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-virtio.c b/drivers/i2c/busses/i2c-virtio.c
index 2a351f961b89..c8c40ff9765d 100644
--- a/drivers/i2c/busses/i2c-virtio.c
+++ b/drivers/i2c/busses/i2c-virtio.c
@@ -116,15 +116,16 @@ static int virtio_i2c_complete_reqs(struct virtqueue *vq,
for (i = 0; i < num; i++) {
struct virtio_i2c_req *req = &reqs[i];
- wait_for_completion(&req->completion);
-
- if (!failed && req->in_hdr.status != VIRTIO_I2C_MSG_OK)
- failed = true;
+ if (!failed) {
+ if (wait_for_completion_interruptible(&req->completion))
+ failed = true;
+ else if (req->in_hdr.status != VIRTIO_I2C_MSG_OK)
+ failed = true;
+ else
+ j++;
+ }
i2c_put_dma_safe_msg_buf(reqs[i].buf, &msgs[i], !failed);
-
- if (!failed)
- j++;
}
return j;
--
2.31.1.272.g89b43f80a514
Powered by blists - more mailing lists