From: Chia-I Wu Date: Wed, 5 Feb 2020 18:19:52 +0000 (-0800) Subject: drm/virtio: move the check for vqs_ready earlier X-Git-Tag: v5.15~303^2~28^2~3554 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c900b2a45cd333e45e9c2a83c7bbd50177433e87;p=platform%2Fkernel%2Flinux-starfive.git drm/virtio: move the check for vqs_ready earlier When vqs_ready is false, vq should be considered invalid and we should not check vq->num_free. After this change, a fenced command queued before the vqs are ready will have fence id 0 and will be considered done. Signed-off-by: Chia-I Wu Link: http://patchwork.freedesktop.org/patch/msgid/20200205181955.202485-9-olvaffe@gmail.com Signed-off-by: Gerd Hoffmann --- diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 2db35f3..aa25e87 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -333,6 +333,14 @@ static bool virtio_gpu_queue_ctrl_sgs(struct virtio_gpu_device *vgdev, again: spin_lock(&vgdev->ctrlq.qlock); + if (!vgdev->vqs_ready) { + spin_unlock(&vgdev->ctrlq.qlock); + + if (fence && vbuf->objs) + virtio_gpu_array_unlock_resv(vbuf->objs); + return notify; + } + if (vq->num_free < elemcnt) { spin_unlock(&vgdev->ctrlq.qlock); wait_event(vgdev->ctrlq.ack_queue, vq->num_free >= elemcnt); @@ -351,11 +359,6 @@ again: } } - if (!vgdev->vqs_ready) { - spin_unlock(&vgdev->ctrlq.qlock); - return notify; - } - ret = virtqueue_add_sgs(vq, sgs, outcnt, incnt, vbuf, GFP_ATOMIC); WARN_ON(ret);