* [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task
@ 2026-05-12 8:59 Ryosuke Yasuoka
2026-05-12 8:59 ` syzbot
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Ryosuke Yasuoka @ 2026-05-12 8:59 UTC (permalink / raw)
To: David Airlie, Gerd Hoffmann, Dmitry Osipenko, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Simona Vetter
Cc: dri-devel, virtualization, linux-kernel,
syzbot+d6dd6f86d3aaf7eebe7406e45c1c6e549453f224,
syzbot+908bd910da5dd79b88de4cf7baf376cc873a922e, Ryosuke Yasuoka
virtio_gpu_queue_ctrl_sgs() and virtio_gpu_queue_cursor() use
wait_event() without timeout when waiting for virtqueue space. If the
host device stops processing commands, these waits block indefinitely.
Since callers may hold DRM locks, this can make the entire system
unresponsive.
Replace wait_event() with wait_event_timeout() using a 5-second timeout,
consistent with the existing timeout pattern in the driver. On timeout,
clean up and return -ENODEV, following the same error path as
drm_dev_enter() failure.
Reported-by: syzbot+d6dd6f86d3aaf7eebe7406e45c1c6e549453f224@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?id=d6dd6f86d3aaf7eebe7406e45c1c6e549453f224
Reported-by: syzbot+908bd910da5dd79b88de4cf7baf376cc873a922e@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?id=908bd910da5dd79b88de4cf7baf376cc873a922e
Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
---
drivers/gpu/drm/virtio/virtgpu_vq.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 67865810a2e7..05e816a0ae0b 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -396,7 +396,16 @@ static int virtio_gpu_queue_ctrl_sgs(struct virtio_gpu_device *vgdev,
if (vq->num_free < elemcnt) {
spin_unlock(&vgdev->ctrlq.qlock);
virtio_gpu_notify(vgdev);
- wait_event(vgdev->ctrlq.ack_queue, vq->num_free >= elemcnt);
+ if (!wait_event_timeout(vgdev->ctrlq.ack_queue,
+ vq->num_free >= elemcnt,
+ 5 * HZ)) {
+ /* The device did not respond */
+ if (fence && vbuf->objs)
+ virtio_gpu_array_unlock_resv(vbuf->objs);
+ free_vbuf(vgdev, vbuf);
+ drm_dev_exit(idx);
+ return -ENODEV;
+ }
goto again;
}
@@ -566,7 +575,14 @@ static void virtio_gpu_queue_cursor(struct virtio_gpu_device *vgdev,
ret = virtqueue_add_sgs(vq, sgs, outcnt, 0, vbuf, GFP_ATOMIC);
if (ret == -ENOSPC) {
spin_unlock(&vgdev->cursorq.qlock);
- wait_event(vgdev->cursorq.ack_queue, vq->num_free >= outcnt);
+ if (!wait_event_timeout(vgdev->cursorq.ack_queue,
+ vq->num_free >= outcnt,
+ 5 * HZ)) {
+ /* The device did not respond */
+ free_vbuf(vgdev, vbuf);
+ drm_dev_exit(idx);
+ return;
+ }
spin_lock(&vgdev->cursorq.qlock);
goto retry;
} else {
---
base-commit: 5d6919055dec134de3c40167a490f33c74c12581
change-id: 20260512-virtio-gpu_wait_event-e0cdf8675b7c
Best regards,
--
Ryosuke Yasuoka <ryasuoka@redhat.com>
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task
2026-05-12 8:59 [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task Ryosuke Yasuoka
2026-05-12 8:59 ` syzbot
@ 2026-05-12 8:59 ` syzbot
2026-05-13 21:40 ` Dmitry Osipenko
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2026-05-12 8:59 UTC (permalink / raw)
To: ryasuoka
Cc: airlied, dmitry.osipenko, dri-devel, gurchetansingh, kraxel,
linux-kernel, maarten.lankhorst, mripard, olvaffe, ryasuoka,
simona, tzimmermann, virtualization
> virtio_gpu_queue_ctrl_sgs() and virtio_gpu_queue_cursor() use
> wait_event() without timeout when waiting for virtqueue space. If the
> host device stops processing commands, these waits block indefinitely.
> Since callers may hold DRM locks, this can make the entire system
> unresponsive.
>
> Replace wait_event() with wait_event_timeout() using a 5-second timeout,
> consistent with the existing timeout pattern in the driver. On timeout,
> clean up and return -ENODEV, following the same error path as
> drm_dev_enter() failure.
>
> Reported-by: syzbot+d6dd6f86d3aaf7eebe7406e45c1c6e549453f224@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?id=d6dd6f86d3aaf7eebe7406e45c1c6e549453f224
> Reported-by: syzbot+908bd910da5dd79b88de4cf7baf376cc873a922e@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?id=908bd910da5dd79b88de4cf7baf376cc873a922e
> Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
> ---
> drivers/gpu/drm/virtio/virtgpu_vq.c | 20 ++++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> index 67865810a2e7..05e816a0ae0b 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -396,7 +396,16 @@ static int virtio_gpu_queue_ctrl_sgs(struct virtio_gpu_device *vgdev,
> if (vq->num_free < elemcnt) {
> spin_unlock(&vgdev->ctrlq.qlock);
> virtio_gpu_notify(vgdev);
> - wait_event(vgdev->ctrlq.ack_queue, vq->num_free >= elemcnt);
> + if (!wait_event_timeout(vgdev->ctrlq.ack_queue,
> + vq->num_free >= elemcnt,
> + 5 * HZ)) {
> + /* The device did not respond */
> + if (fence && vbuf->objs)
> + virtio_gpu_array_unlock_resv(vbuf->objs);
> + free_vbuf(vgdev, vbuf);
> + drm_dev_exit(idx);
> + return -ENODEV;
> + }
> goto again;
> }
>
> @@ -566,7 +575,14 @@ static void virtio_gpu_queue_cursor(struct virtio_gpu_device *vgdev,
> ret = virtqueue_add_sgs(vq, sgs, outcnt, 0, vbuf, GFP_ATOMIC);
> if (ret == -ENOSPC) {
> spin_unlock(&vgdev->cursorq.qlock);
> - wait_event(vgdev->cursorq.ack_queue, vq->num_free >= outcnt);
> + if (!wait_event_timeout(vgdev->cursorq.ack_queue,
> + vq->num_free >= outcnt,
> + 5 * HZ)) {
> + /* The device did not respond */
> + free_vbuf(vgdev, vbuf);
> + drm_dev_exit(idx);
> + return;
> + }
> spin_lock(&vgdev->cursorq.qlock);
> goto retry;
> } else {
>
> ---
> base-commit: 5d6919055dec134de3c40167a490f33c74c12581
> change-id: 20260512-virtio-gpu_wait_event-e0cdf8675b7c
>
> Best regards,
> --
> Ryosuke Yasuoka <ryasuoka@redhat.com>
>
I see the command but can't find the corresponding bug.
The email is sent to syzbot+HASH@syzkaller.appspotmail.com address
but the HASH does not correspond to any known bug.
Please double check the address.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task
2026-05-12 8:59 [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task Ryosuke Yasuoka
@ 2026-05-12 8:59 ` syzbot
2026-05-12 8:59 ` syzbot
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2026-05-12 8:59 UTC (permalink / raw)
To: ryasuoka
Cc: airlied, dmitry.osipenko, dri-devel, gurchetansingh, kraxel,
linux-kernel, maarten.lankhorst, mripard, olvaffe, ryasuoka,
simona, tzimmermann, virtualization
> virtio_gpu_queue_ctrl_sgs() and virtio_gpu_queue_cursor() use
> wait_event() without timeout when waiting for virtqueue space. If the
> host device stops processing commands, these waits block indefinitely.
> Since callers may hold DRM locks, this can make the entire system
> unresponsive.
>
> Replace wait_event() with wait_event_timeout() using a 5-second timeout,
> consistent with the existing timeout pattern in the driver. On timeout,
> clean up and return -ENODEV, following the same error path as
> drm_dev_enter() failure.
>
> Reported-by: syzbot+d6dd6f86d3aaf7eebe7406e45c1c6e549453f224@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?id=d6dd6f86d3aaf7eebe7406e45c1c6e549453f224
> Reported-by: syzbot+908bd910da5dd79b88de4cf7baf376cc873a922e@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?id=908bd910da5dd79b88de4cf7baf376cc873a922e
> Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
> ---
> drivers/gpu/drm/virtio/virtgpu_vq.c | 20 ++++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> index 67865810a2e7..05e816a0ae0b 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -396,7 +396,16 @@ static int virtio_gpu_queue_ctrl_sgs(struct virtio_gpu_device *vgdev,
> if (vq->num_free < elemcnt) {
> spin_unlock(&vgdev->ctrlq.qlock);
> virtio_gpu_notify(vgdev);
> - wait_event(vgdev->ctrlq.ack_queue, vq->num_free >= elemcnt);
> + if (!wait_event_timeout(vgdev->ctrlq.ack_queue,
> + vq->num_free >= elemcnt,
> + 5 * HZ)) {
> + /* The device did not respond */
> + if (fence && vbuf->objs)
> + virtio_gpu_array_unlock_resv(vbuf->objs);
> + free_vbuf(vgdev, vbuf);
> + drm_dev_exit(idx);
> + return -ENODEV;
> + }
> goto again;
> }
>
> @@ -566,7 +575,14 @@ static void virtio_gpu_queue_cursor(struct virtio_gpu_device *vgdev,
> ret = virtqueue_add_sgs(vq, sgs, outcnt, 0, vbuf, GFP_ATOMIC);
> if (ret == -ENOSPC) {
> spin_unlock(&vgdev->cursorq.qlock);
> - wait_event(vgdev->cursorq.ack_queue, vq->num_free >= outcnt);
> + if (!wait_event_timeout(vgdev->cursorq.ack_queue,
> + vq->num_free >= outcnt,
> + 5 * HZ)) {
> + /* The device did not respond */
> + free_vbuf(vgdev, vbuf);
> + drm_dev_exit(idx);
> + return;
> + }
> spin_lock(&vgdev->cursorq.qlock);
> goto retry;
> } else {
>
> ---
> base-commit: 5d6919055dec134de3c40167a490f33c74c12581
> change-id: 20260512-virtio-gpu_wait_event-e0cdf8675b7c
>
> Best regards,
> --
> Ryosuke Yasuoka <ryasuoka@redhat.com>
>
I see the command but can't find the corresponding bug.
The email is sent to syzbot+HASH@syzkaller.appspotmail.com address
but the HASH does not correspond to any known bug.
Please double check the address.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task
2026-05-12 8:59 [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task Ryosuke Yasuoka
2026-05-12 8:59 ` syzbot
2026-05-12 8:59 ` syzbot
@ 2026-05-13 21:40 ` Dmitry Osipenko
2026-05-13 21:41 ` syzbot
` (2 more replies)
2026-05-16 3:58 ` Claude review: " Claude Code Review Bot
2026-05-16 3:58 ` Claude Code Review Bot
4 siblings, 3 replies; 9+ messages in thread
From: Dmitry Osipenko @ 2026-05-13 21:40 UTC (permalink / raw)
To: Ryosuke Yasuoka, David Airlie, Gerd Hoffmann, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Simona Vetter
Cc: dri-devel, virtualization, linux-kernel,
syzbot+d6dd6f86d3aaf7eebe7406e45c1c6e549453f224,
syzbot+908bd910da5dd79b88de4cf7baf376cc873a922e
Hi,
On 5/12/26 11:59, Ryosuke Yasuoka wrote:
> virtio_gpu_queue_ctrl_sgs() and virtio_gpu_queue_cursor() use
> wait_event() without timeout when waiting for virtqueue space. If the
> host device stops processing commands, these waits block indefinitely.
> Since callers may hold DRM locks, this can make the entire system
> unresponsive.
>
> Replace wait_event() with wait_event_timeout() using a 5-second timeout,
> consistent with the existing timeout pattern in the driver. On timeout,
> clean up and return -ENODEV, following the same error path as
> drm_dev_enter() failure.
>
> Reported-by: syzbot+d6dd6f86d3aaf7eebe7406e45c1c6e549453f224@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?id=d6dd6f86d3aaf7eebe7406e45c1c6e549453f224
> Reported-by: syzbot+908bd910da5dd79b88de4cf7baf376cc873a922e@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?id=908bd910da5dd79b88de4cf7baf376cc873a922e
> Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
> ---
> drivers/gpu/drm/virtio/virtgpu_vq.c | 20 ++++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
If host stops processing commands, this is a problem on host side. Isn't it?
--
Best regards,
Dmitry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task
2026-05-13 21:40 ` Dmitry Osipenko
@ 2026-05-13 21:41 ` syzbot
2026-05-13 21:41 ` syzbot
2026-05-13 21:54 ` Dmitry Osipenko
2 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2026-05-13 21:41 UTC (permalink / raw)
To: dmitry.osipenko
Cc: airlied, dmitry.osipenko, dri-devel, gurchetansingh, kraxel,
linux-kernel, maarten.lankhorst, mripard, olvaffe, ryasuoka,
simona, tzimmermann, virtualization
> Hi,
>
> On 5/12/26 11:59, Ryosuke Yasuoka wrote:
>> virtio_gpu_queue_ctrl_sgs() and virtio_gpu_queue_cursor() use
>> wait_event() without timeout when waiting for virtqueue space. If the
>> host device stops processing commands, these waits block indefinitely.
>> Since callers may hold DRM locks, this can make the entire system
>> unresponsive.
>>
>> Replace wait_event() with wait_event_timeout() using a 5-second timeout,
>> consistent with the existing timeout pattern in the driver. On timeout,
>> clean up and return -ENODEV, following the same error path as
>> drm_dev_enter() failure.
>>
>> Reported-by: syzbot+d6dd6f86d3aaf7eebe7406e45c1c6e549453f224@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?id=d6dd6f86d3aaf7eebe7406e45c1c6e549453f224
>> Reported-by: syzbot+908bd910da5dd79b88de4cf7baf376cc873a922e@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?id=908bd910da5dd79b88de4cf7baf376cc873a922e
>> Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
>> ---
>> drivers/gpu/drm/virtio/virtgpu_vq.c | 20 ++++++++++++++++++--
>> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> If host stops processing commands, this is a problem on host side. Isn't it?
>
> --
> Best regards,
> Dmitry
I see the command but can't find the corresponding bug.
The email is sent to syzbot+HASH@syzkaller.appspotmail.com address
but the HASH does not correspond to any known bug.
Please double check the address.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task
2026-05-13 21:40 ` Dmitry Osipenko
2026-05-13 21:41 ` syzbot
@ 2026-05-13 21:41 ` syzbot
2026-05-13 21:54 ` Dmitry Osipenko
2 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2026-05-13 21:41 UTC (permalink / raw)
To: dmitry.osipenko
Cc: airlied, dmitry.osipenko, dri-devel, gurchetansingh, kraxel,
linux-kernel, maarten.lankhorst, mripard, olvaffe, ryasuoka,
simona, tzimmermann, virtualization
> Hi,
>
> On 5/12/26 11:59, Ryosuke Yasuoka wrote:
>> virtio_gpu_queue_ctrl_sgs() and virtio_gpu_queue_cursor() use
>> wait_event() without timeout when waiting for virtqueue space. If the
>> host device stops processing commands, these waits block indefinitely.
>> Since callers may hold DRM locks, this can make the entire system
>> unresponsive.
>>
>> Replace wait_event() with wait_event_timeout() using a 5-second timeout,
>> consistent with the existing timeout pattern in the driver. On timeout,
>> clean up and return -ENODEV, following the same error path as
>> drm_dev_enter() failure.
>>
>> Reported-by: syzbot+d6dd6f86d3aaf7eebe7406e45c1c6e549453f224@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?id=d6dd6f86d3aaf7eebe7406e45c1c6e549453f224
>> Reported-by: syzbot+908bd910da5dd79b88de4cf7baf376cc873a922e@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?id=908bd910da5dd79b88de4cf7baf376cc873a922e
>> Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
>> ---
>> drivers/gpu/drm/virtio/virtgpu_vq.c | 20 ++++++++++++++++++--
>> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> If host stops processing commands, this is a problem on host side. Isn't it?
>
> --
> Best regards,
> Dmitry
I see the command but can't find the corresponding bug.
The email is sent to syzbot+HASH@syzkaller.appspotmail.com address
but the HASH does not correspond to any known bug.
Please double check the address.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task
2026-05-13 21:40 ` Dmitry Osipenko
2026-05-13 21:41 ` syzbot
2026-05-13 21:41 ` syzbot
@ 2026-05-13 21:54 ` Dmitry Osipenko
2 siblings, 0 replies; 9+ messages in thread
From: Dmitry Osipenko @ 2026-05-13 21:54 UTC (permalink / raw)
To: Ryosuke Yasuoka, David Airlie, Gerd Hoffmann, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Simona Vetter
Cc: dri-devel, virtualization, linux-kernel
On 5/14/26 00:40, Dmitry Osipenko wrote:
> Hi,
>
> On 5/12/26 11:59, Ryosuke Yasuoka wrote:
>> virtio_gpu_queue_ctrl_sgs() and virtio_gpu_queue_cursor() use
>> wait_event() without timeout when waiting for virtqueue space. If the
>> host device stops processing commands, these waits block indefinitely.
>> Since callers may hold DRM locks, this can make the entire system
>> unresponsive.
>>
>> Replace wait_event() with wait_event_timeout() using a 5-second timeout,
>> consistent with the existing timeout pattern in the driver. On timeout,
>> clean up and return -ENODEV, following the same error path as
>> drm_dev_enter() failure.
>>
>> Reported-by: syzbot+d6dd6f86d3aaf7eebe7406e45c1c6e549453f224@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?id=d6dd6f86d3aaf7eebe7406e45c1c6e549453f224
>> Reported-by: syzbot+908bd910da5dd79b88de4cf7baf376cc873a922e@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?id=908bd910da5dd79b88de4cf7baf376cc873a922e
>> Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
>> ---
>> drivers/gpu/drm/virtio/virtgpu_vq.c | 20 ++++++++++++++++++--
>> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> If host stops processing commands, this is a problem on host side. Isn't it?
It may be acceptable to have wait_event_timeout() in a loop, printing
warnings about unresponsive host.
Don't think we can assume that 5 seconds is enough to say that host is
busted, unless spec says so.
There could be a driver module parameter, specifying the timeoout. This
will be acceptable as user takes responsibility for the special timeout
behaviour.
--
Best regards,
Dmitry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Claude review: drm/virtio: add timeout to virtqueue wait to avoid hung task
2026-05-12 8:59 [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task Ryosuke Yasuoka
` (2 preceding siblings ...)
2026-05-13 21:40 ` Dmitry Osipenko
@ 2026-05-16 3:58 ` Claude Code Review Bot
2026-05-16 3:58 ` Claude Code Review Bot
4 siblings, 0 replies; 9+ messages in thread
From: Claude Code Review Bot @ 2026-05-16 3:58 UTC (permalink / raw)
To: dri-devel-reviews
Overall Series Review
Subject: drm/virtio: add timeout to virtqueue wait to avoid hung task
Author: Ryosuke Yasuoka <ryasuoka@redhat.com>
Patches: 7
Reviewed: 2026-05-16T13:58:17.315172
---
This is a single patch addressing a real syzbot-reported hung task problem where `wait_event()` can block indefinitely in `virtio_gpu_queue_ctrl_sgs()` and `virtio_gpu_queue_cursor()` when the host stops processing commands. The approach — replacing `wait_event()` with `wait_event_timeout()` — is a reasonable direction, but the patch has several issues that need to be addressed before it's mergable.
**Key concerns:**
1. **The 5-second timeout is arbitrary and can trigger under legitimate load.** A busy virtio-gpu host might legitimately take more than 5 seconds to drain the queue under heavy load. This would cause spurious `-ENODEV` errors and dropped cursor updates in normal operation. The commit message says "consistent with the existing timeout pattern in the driver" but doesn't cite which existing timeout it refers to. A more robust approach might be to integrate with the device-level health checking (e.g., only bail out if the device has actually been unplugged/reset, or use a much longer timeout).
2. **The `goto again` placement after timeout is correct but subtle.** If `wait_event_timeout` returns non-zero (success), execution falls through to `goto again`, which re-acquires the lock and re-checks the condition. This is correct behavior — matching the original `wait_event` + `goto again` flow — but the diff placement makes it easy to misread.
3. **No logging on timeout.** When the timeout fires in `virtio_gpu_queue_ctrl_sgs`, the driver silently returns `-ENODEV`. There should be at least a `drm_err()` or `drm_dbg()` message so the failure is diagnosable — especially since this path could trigger spuriously.
---
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 9+ messages in thread
* Claude review: drm/virtio: add timeout to virtqueue wait to avoid hung task
2026-05-12 8:59 [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task Ryosuke Yasuoka
` (3 preceding siblings ...)
2026-05-16 3:58 ` Claude review: " Claude Code Review Bot
@ 2026-05-16 3:58 ` Claude Code Review Bot
4 siblings, 0 replies; 9+ messages in thread
From: Claude Code Review Bot @ 2026-05-16 3:58 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**virtio_gpu_queue_ctrl_sgs timeout path (lines 142–150 of the diff):**
```c
+ if (!wait_event_timeout(vgdev->ctrlq.ack_queue,
+ vq->num_free >= elemcnt,
+ 5 * HZ)) {
+ /* The device did not respond */
+ if (fence && vbuf->objs)
+ virtio_gpu_array_unlock_resv(vbuf->objs);
+ free_vbuf(vgdev, vbuf);
+ drm_dev_exit(idx);
+ return -ENODEV;
+ }
```
- **Cleanup is correct** — it mirrors the `drm_dev_enter()` failure path at lines 383–388 of the source. The fence has not been emitted yet at this point (that happens after the `goto again` loop succeeds), so not touching `fence` here is fine.
- **Missing error logging** — this is a significant event (device unresponsive for 5 seconds). At minimum a `drm_err(vgdev->ddev, "timed out waiting for ctrl virtqueue space\n")` should be emitted so the admin/developer can diagnose the failure.
- **`drm_dev_exit(idx)` is correct** — the function called `drm_dev_enter` earlier at line 383 and the timeout path needs to balance it.
**virtio_gpu_queue_cursor timeout path (lines 161–167 of the diff):**
```c
+ if (!wait_event_timeout(vgdev->cursorq.ack_queue,
+ vq->num_free >= outcnt,
+ 5 * HZ)) {
+ /* The device did not respond */
+ free_vbuf(vgdev, vbuf);
+ drm_dev_exit(idx);
+ return;
+ }
```
- **Cleanup mirrors the `drm_dev_enter` failure path** at line 555–557 of the source (`free_vbuf` + return). This is correct.
- **`drm_dev_exit(idx)` is correct** — balances the `drm_dev_enter` at line 555.
- **Same missing logging concern** — should log a message on timeout.
- **Silent cursor drop** — the cursor update is silently lost on timeout. The sole caller `virtio_gpu_cursor_ping()` at line 1305 doesn't check for errors (and can't, since the function returns void). This is acceptable for a cursor ping but still deserves a log message.
**General issues across both sites:**
- **Race with legitimate completion:** The 5-second window is a fixed wall-clock timeout. Under memory pressure or host CPU contention, a legitimate completion that arrives at 5.1 seconds would trigger a false `-ENODEV`. Consider whether the timeout should be longer (e.g., 30s) or whether `wait_event_interruptible_timeout` would be more appropriate so the wait can be interrupted by signals — though that introduces its own complexity.
- **No `WARN` or telemetry:** Other drivers that add device-timeout paths often include a `drm_err` or `WARN_ONCE` to make the failure visible. Silently returning `-ENODEV` makes debugging harder.
- **Commit message claims consistency with existing timeout but doesn't cite it.** The claim "consistent with the existing timeout pattern in the driver" should reference the specific code location for reviewer verification.
**Summary:** The patch addresses a real problem but needs (1) logging on the timeout paths, (2) justification for the 5-second value (and consideration of whether it's too short for legitimate workloads), and (3) the commit message should cite which "existing timeout pattern" it's referring to.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-05-16 3:58 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 8:59 [PATCH] drm/virtio: add timeout to virtqueue wait to avoid hung task Ryosuke Yasuoka
2026-05-12 8:59 ` syzbot
2026-05-12 8:59 ` syzbot
2026-05-13 21:40 ` Dmitry Osipenko
2026-05-13 21:41 ` syzbot
2026-05-13 21:41 ` syzbot
2026-05-13 21:54 ` Dmitry Osipenko
2026-05-16 3:58 ` Claude review: " Claude Code Review Bot
2026-05-16 3:58 ` Claude Code Review Bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox