freedreno/drm/virtio: Flush before CREATE_BLOB
The RESOURCE_CREATE_BLOB ioctl can carry a ccmd payload, similarly to EXECBUF. But we need to preserve the order of buffered execbuf cmds which haven't been flushed to the guest kernel yet, rather than let the CREATE_BLOB payload jump to the head of the queue. Otherwise, for ex, the host could see the guest requesting an iova that has not yet been (from it's perspective) released. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20961>
This commit is contained in:
@@ -415,8 +415,10 @@ virtio_bo_new(struct fd_device *dev, uint32_t size, uint32_t flags)
|
||||
}
|
||||
|
||||
simple_mtx_lock(&virtio_dev->eb_lock);
|
||||
if (args.cmd)
|
||||
if (args.cmd) {
|
||||
virtio_execbuf_flush_locked(dev);
|
||||
req.hdr.seqno = ++virtio_dev->next_seqno;
|
||||
}
|
||||
ret = virtio_ioctl(dev->fd, VIRTGPU_RESOURCE_CREATE_BLOB, &args);
|
||||
simple_mtx_unlock(&virtio_dev->eb_lock);
|
||||
if (ret)
|
||||
|
@@ -329,6 +329,14 @@ virtio_execbuf_flush(struct fd_device *dev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
virtio_execbuf_flush_locked(struct fd_device *dev)
|
||||
{
|
||||
struct virtio_device *virtio_dev = to_virtio_device(dev);
|
||||
simple_mtx_assert_locked(&virtio_dev->eb_lock);
|
||||
return execbuf_flush_locked(dev, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
virtio_execbuf(struct fd_device *dev, struct msm_ccmd_req *req, bool sync)
|
||||
{
|
||||
|
@@ -185,6 +185,7 @@ int virtio_execbuf_fenced(struct fd_device *dev, struct msm_ccmd_req *req,
|
||||
uint32_t *handles, uint32_t num_handles,
|
||||
int in_fence_fd, int *out_fence_fd, int ring_idx);
|
||||
int virtio_execbuf_flush(struct fd_device *dev);
|
||||
int virtio_execbuf_flush_locked(struct fd_device *dev);
|
||||
int virtio_execbuf(struct fd_device *dev, struct msm_ccmd_req *req, bool sync);
|
||||
void virtio_host_sync(struct fd_device *dev, const struct msm_ccmd_req *req);
|
||||
int virtio_simple_ioctl(struct fd_device *dev, unsigned cmd, void *req);
|
||||
|
Reference in New Issue
Block a user