mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-31 14:02:05 -06:00
virtio-gpu: maintain command queue
We'll go take out the commands we receive out of the virt queue and put them into a linked list, to decouple virtio queue handling from actual command processing. Also move cmd processing to new virtio_gpu_handle_ctrl func, so we can easily kick it from different places. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
8d94c1ca53
commit
3eb769fd1c
2 changed files with 37 additions and 17 deletions
|
@ -755,6 +755,36 @@ static void virtio_gpu_handle_cursor_cb(VirtIODevice *vdev, VirtQueue *vq)
|
||||||
qemu_bh_schedule(g->cursor_bh);
|
qemu_bh_schedule(g->cursor_bh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void virtio_gpu_process_cmdq(VirtIOGPU *g)
|
||||||
|
{
|
||||||
|
struct virtio_gpu_ctrl_command *cmd;
|
||||||
|
|
||||||
|
while (!QTAILQ_EMPTY(&g->cmdq)) {
|
||||||
|
cmd = QTAILQ_FIRST(&g->cmdq);
|
||||||
|
|
||||||
|
/* process command */
|
||||||
|
VIRGL(g, virtio_gpu_virgl_process_cmd, virtio_gpu_simple_process_cmd,
|
||||||
|
g, cmd);
|
||||||
|
QTAILQ_REMOVE(&g->cmdq, cmd, next);
|
||||||
|
if (virtio_gpu_stats_enabled(g->conf)) {
|
||||||
|
g->stats.requests++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cmd->finished) {
|
||||||
|
QTAILQ_INSERT_TAIL(&g->fenceq, cmd, next);
|
||||||
|
g->inflight++;
|
||||||
|
if (virtio_gpu_stats_enabled(g->conf)) {
|
||||||
|
if (g->stats.max_inflight < g->inflight) {
|
||||||
|
g->stats.max_inflight = g->inflight;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "inflight: %3d (+)\r", g->inflight);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g_free(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
|
static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
|
||||||
{
|
{
|
||||||
VirtIOGPU *g = VIRTIO_GPU(vdev);
|
VirtIOGPU *g = VIRTIO_GPU(vdev);
|
||||||
|
@ -776,26 +806,14 @@ static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
|
||||||
cmd->vq = vq;
|
cmd->vq = vq;
|
||||||
cmd->error = 0;
|
cmd->error = 0;
|
||||||
cmd->finished = false;
|
cmd->finished = false;
|
||||||
if (virtio_gpu_stats_enabled(g->conf)) {
|
cmd->waiting = false;
|
||||||
g->stats.requests++;
|
QTAILQ_INSERT_TAIL(&g->cmdq, cmd, next);
|
||||||
}
|
cmd = g_new(struct virtio_gpu_ctrl_command, 1);
|
||||||
|
|
||||||
VIRGL(g, virtio_gpu_virgl_process_cmd, virtio_gpu_simple_process_cmd,
|
|
||||||
g, cmd);
|
|
||||||
if (!cmd->finished) {
|
|
||||||
QTAILQ_INSERT_TAIL(&g->fenceq, cmd, next);
|
|
||||||
g->inflight++;
|
|
||||||
if (virtio_gpu_stats_enabled(g->conf)) {
|
|
||||||
if (g->stats.max_inflight < g->inflight) {
|
|
||||||
g->stats.max_inflight = g->inflight;
|
|
||||||
}
|
|
||||||
fprintf(stderr, "inflight: %3d (+)\r", g->inflight);
|
|
||||||
}
|
|
||||||
cmd = g_new(struct virtio_gpu_ctrl_command, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
g_free(cmd);
|
g_free(cmd);
|
||||||
|
|
||||||
|
virtio_gpu_process_cmdq(g);
|
||||||
|
|
||||||
#ifdef CONFIG_VIRGL
|
#ifdef CONFIG_VIRGL
|
||||||
if (g->use_virgl_renderer) {
|
if (g->use_virgl_renderer) {
|
||||||
virtio_gpu_virgl_fence_poll(g);
|
virtio_gpu_virgl_fence_poll(g);
|
||||||
|
@ -921,6 +939,7 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
|
||||||
g->ctrl_bh = qemu_bh_new(virtio_gpu_ctrl_bh, g);
|
g->ctrl_bh = qemu_bh_new(virtio_gpu_ctrl_bh, g);
|
||||||
g->cursor_bh = qemu_bh_new(virtio_gpu_cursor_bh, g);
|
g->cursor_bh = qemu_bh_new(virtio_gpu_cursor_bh, g);
|
||||||
QTAILQ_INIT(&g->reslist);
|
QTAILQ_INIT(&g->reslist);
|
||||||
|
QTAILQ_INIT(&g->cmdq);
|
||||||
QTAILQ_INIT(&g->fenceq);
|
QTAILQ_INIT(&g->fenceq);
|
||||||
|
|
||||||
g->enabled_output_bitmask = 1;
|
g->enabled_output_bitmask = 1;
|
||||||
|
|
|
@ -94,6 +94,7 @@ typedef struct VirtIOGPU {
|
||||||
DeviceState *qdev;
|
DeviceState *qdev;
|
||||||
|
|
||||||
QTAILQ_HEAD(, virtio_gpu_simple_resource) reslist;
|
QTAILQ_HEAD(, virtio_gpu_simple_resource) reslist;
|
||||||
|
QTAILQ_HEAD(, virtio_gpu_ctrl_command) cmdq;
|
||||||
QTAILQ_HEAD(, virtio_gpu_ctrl_command) fenceq;
|
QTAILQ_HEAD(, virtio_gpu_ctrl_command) fenceq;
|
||||||
|
|
||||||
struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUT];
|
struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUT];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue