[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 03/20] vhost-user-gpu: use an extandable state enum for comman
From: |
marcandre . lureau |
Subject: |
[PATCH v2 03/20] vhost-user-gpu: use an extandable state enum for commands |
Date: |
Thu, 4 Feb 2021 14:52:15 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Introduce a pending state for commands which aren't finished yet, but
are being handled. See following patch.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
contrib/vhost-user-gpu/vugpu.h | 8 +++++++-
contrib/vhost-user-gpu/vhost-user-gpu.c | 8 ++++----
contrib/vhost-user-gpu/virgl.c | 2 +-
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/contrib/vhost-user-gpu/vugpu.h b/contrib/vhost-user-gpu/vugpu.h
index 86f3ac86aa..04d5615812 100644
--- a/contrib/vhost-user-gpu/vugpu.h
+++ b/contrib/vhost-user-gpu/vugpu.h
@@ -129,12 +129,18 @@ typedef struct VuGpu {
QTAILQ_HEAD(, virtio_gpu_ctrl_command) fenceq;
} VuGpu;
+enum {
+ VG_CMD_STATE_NEW,
+ VG_CMD_STATE_PENDING,
+ VG_CMD_STATE_FINISHED,
+};
+
struct virtio_gpu_ctrl_command {
VuVirtqElement elem;
VuVirtq *vq;
struct virtio_gpu_ctrl_hdr cmd_hdr;
uint32_t error;
- bool finished;
+ int state;
QTAILQ_ENTRY(virtio_gpu_ctrl_command) next;
};
diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c
b/contrib/vhost-user-gpu/vhost-user-gpu.c
index 85c16404fb..7dcc02966c 100644
--- a/contrib/vhost-user-gpu/vhost-user-gpu.c
+++ b/contrib/vhost-user-gpu/vhost-user-gpu.c
@@ -246,7 +246,7 @@ vg_ctrl_response(VuGpu *g,
}
vu_queue_push(&g->dev.parent, cmd->vq, &cmd->elem, s);
vu_queue_notify(&g->dev.parent, cmd->vq);
- cmd->finished = true;
+ cmd->state = VG_CMD_STATE_FINISHED;
}
void
@@ -800,7 +800,7 @@ vg_process_cmd(VuGpu *vg, struct virtio_gpu_ctrl_command
*cmd)
cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
break;
}
- if (!cmd->finished) {
+ if (cmd->state == VG_CMD_STATE_NEW) {
vg_ctrl_response_nodata(vg, cmd, cmd->error ? cmd->error :
VIRTIO_GPU_RESP_OK_NODATA);
}
@@ -825,7 +825,7 @@ vg_handle_ctrl(VuDev *dev, int qidx)
}
cmd->vq = vq;
cmd->error = 0;
- cmd->finished = false;
+ cmd->state = VG_CMD_STATE_NEW;
len = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num,
0, &cmd->cmd_hdr, sizeof(cmd->cmd_hdr));
@@ -844,7 +844,7 @@ vg_handle_ctrl(VuDev *dev, int qidx)
vg_process_cmd(vg, cmd);
}
- if (!cmd->finished) {
+ if (cmd->state != VG_CMD_STATE_FINISHED) {
QTAILQ_INSERT_TAIL(&vg->fenceq, cmd, next);
vg->inflight++;
} else {
diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c
index e647278052..8bb3c563d9 100644
--- a/contrib/vhost-user-gpu/virgl.c
+++ b/contrib/vhost-user-gpu/virgl.c
@@ -482,7 +482,7 @@ void vg_virgl_process_cmd(VuGpu *g, struct
virtio_gpu_ctrl_command *cmd)
break;
}
- if (cmd->finished) {
+ if (cmd->state != VG_CMD_STATE_NEW) {
return;
}
--
2.29.0
- [PATCH v2 00/20] Various vhost-user-gpu & UI fixes, marcandre . lureau, 2021/02/04
- [PATCH v2 01/20] vhost-user-gpu: check backend for EDID support, marcandre . lureau, 2021/02/04
- [PATCH v2 02/20] vhost-user-gpu: handle vhost-user-gpu features in a callback, marcandre . lureau, 2021/02/04
- [PATCH v2 03/20] vhost-user-gpu: use an extandable state enum for commands,
marcandre . lureau <=
- [PATCH v2 04/20] vhost-user-gpu: handle display-info in a callback, marcandre . lureau, 2021/02/04
- [PATCH v2 05/20] ui: remove extra #ifdef CONFIG_OPENGL, marcandre . lureau, 2021/02/04
- [PATCH v2 06/20] ui: remove gl_ctx_get_current, marcandre . lureau, 2021/02/04
- [PATCH v2 07/20] ui: add gd_gl_area_scanout_disable, marcandre . lureau, 2021/02/04
- [PATCH v2 08/20] ui: annotate DCLOps callback requirements, marcandre . lureau, 2021/02/04
- [PATCH v2 09/20] ui: remove console_has_gl_dmabuf(), marcandre . lureau, 2021/02/04
- [PATCH v2 10/20] vhost-user-gpu: add a configuration flag for dmabuf usage, marcandre . lureau, 2021/02/04
- [PATCH v2 11/20] ui: add an optional get_flags callback to GraphicHwOps, marcandre . lureau, 2021/02/04