Skip to content

Commit 30e439a

Browse files
YsuOSgregkh
authored andcommitted
drm/virtio: fix deadlock in display_info_cb by removing hotplug from dequeue worker
[ Upstream commit d1b894c ] A probe-time deadlock can occur between the dequeue worker and drm_client_register(). During probe, drm_client_register() holds clientlist_mutex and calls the fbdev hotplug callback, which triggers an atomic commit that ends up sleeping in virtio_gpu_queue_ctrl_sgs() waiting for virtqueue space. The dequeue worker that would free that space calls virtio_gpu_cmd_get_display_info_cb(), which invokes drm_kms_helper_hotplug_event() -> drm_client_dev_hotplug(), attempting to acquire the same clientlist_mutex. Since wake_up() is only called after the resp_cb loop, the probe thread is never woken and both threads deadlock. Fix this by removing the hotplug notification from virtio_gpu_cmd_get_display_info_cb(). The display data (outputs[i].info) is still updated synchronously in the callback. For the init path, drm_client_register() already fires an initial hotplug when the client is registered, which picks up the connector state updated by display_info_cb. For the runtime config_changed path, add a wait_event_timeout() in config_changed_work_func() so that display_info_cb updates the connector data before the hotplug notification is sent. Also replace drm_helper_hpd_irq_event() with drm_kms_helper_hotplug_event() since virtio-gpu never calls drm_kms_helper_poll_init() and thus drm_helper_hpd_irq_event() always returns false without doing anything. Fixes: 27655b9 ("drm/client: Send hotplug event after registering a client") Closes: https://syzkaller.appspot.com/bug?id=d6dd6f86d3aaf7eebe7406e45c1c6e549453f224 Closes: https://syzkaller.appspot.com/bug?id=908bd910da5dd79b88de4cf7baf376cc873a922e Suggested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Link: https://patch.msgid.link/20260713-virtiogpu_syzbot-v2-1-2958fa37d46d@redhat.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a715cf4 commit 30e439a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/gpu/drm/virtio/virtgpu_kms.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ static void virtio_gpu_config_changed_work_func(struct work_struct *work)
4848
virtio_gpu_cmd_get_edids(vgdev);
4949
virtio_gpu_cmd_get_display_info(vgdev);
5050
virtio_gpu_notify(vgdev);
51-
drm_helper_hpd_irq_event(vgdev->ddev);
51+
wait_event_timeout(vgdev->resp_wq,
52+
!vgdev->display_info_pending,
53+
5 * HZ);
54+
drm_kms_helper_hotplug_event(vgdev->ddev);
5255
}
5356
events_clear |= VIRTIO_GPU_EVENT_DISPLAY;
5457
}

drivers/gpu/drm/virtio/virtgpu_vq.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,6 @@ static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,
669669
vgdev->display_info_pending = false;
670670
spin_unlock(&vgdev->display_info_lock);
671671
wake_up(&vgdev->resp_wq);
672-
673-
if (!drm_helper_hpd_irq_event(vgdev->ddev))
674-
drm_kms_helper_hotplug_event(vgdev->ddev);
675672
}
676673

677674
static void virtio_gpu_cmd_get_capset_info_cb(struct virtio_gpu_device *vgdev,

0 commit comments

Comments
 (0)