[RFC PATCH 05/15] drm/virtio: Handle virtio_device_ready() failure

From: Xie Yongji
Date: Mon May 17 2021 - 05:35:17 EST


Now virtio_device_ready() will return error if we get
invalid status. Let's handle this case on probe.

Signed-off-by: Xie Yongji <xieyongji@xxxxxxxxxxxxx>
---
drivers/gpu/drm/virtio/virtgpu_kms.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
index f3379059f324..eedbb4684db5 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -217,7 +217,11 @@ int virtio_gpu_init(struct drm_device *dev)
goto err_scanouts;
}

- virtio_device_ready(vgdev->vdev);
+ ret = virtio_device_ready(vgdev->vdev);
+ if (ret) {
+ DRM_ERROR("failed to enable virtio device\n");
+ goto err_device_ready;
+ }

if (num_capsets)
virtio_gpu_get_capsets(vgdev, num_capsets);
@@ -229,6 +233,8 @@ int virtio_gpu_init(struct drm_device *dev)
5 * HZ);
return 0;

+err_device_ready:
+ virtio_gpu_modeset_fini(vgdev);
err_scanouts:
virtio_gpu_free_vbufs(vgdev);
err_vbufs:
--
2.11.0