Skip to content

Commit

Permalink
virtio-gpu: move virgl process_cmd
Browse files Browse the repository at this point in the history
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20210430113547.1816178-1-kraxel@redhat.com
Message-Id: <20210430113547.1816178-9-kraxel@redhat.com>
  • Loading branch information
kraxel committed May 10, 2021
1 parent 3e48b7a commit 2f47691
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
11 changes: 11 additions & 0 deletions hw/display/virtio-gpu-gl.c
Expand Up @@ -23,6 +23,16 @@
#include "hw/virtio/virtio-gpu-pixman.h"
#include "hw/qdev-properties.h"

static void virtio_gpu_gl_process_cmd(VirtIOGPU *g,
struct virtio_gpu_ctrl_command *cmd)
{
if (g->parent_obj.use_virgl_renderer) {
virtio_gpu_virgl_process_cmd(g, cmd);
return;
}
virtio_gpu_simple_process_cmd(g, cmd);
}

static void virtio_gpu_gl_flushed(VirtIOGPUBase *b)
{
VirtIOGPU *g = VIRTIO_GPU(b);
Expand Down Expand Up @@ -116,6 +126,7 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data)

vbc->gl_flushed = virtio_gpu_gl_flushed;
vgc->handle_ctrl = virtio_gpu_gl_handle_ctrl;
vgc->process_cmd = virtio_gpu_gl_process_cmd;

vdc->realize = virtio_gpu_gl_device_realize;
vdc->reset = virtio_gpu_gl_reset;
Expand Down
9 changes: 5 additions & 4 deletions hw/display/virtio-gpu.c
Expand Up @@ -763,8 +763,8 @@ virtio_gpu_resource_detach_backing(VirtIOGPU *g,
virtio_gpu_cleanup_mapping(g, res);
}

static void virtio_gpu_simple_process_cmd(VirtIOGPU *g,
struct virtio_gpu_ctrl_command *cmd)
void virtio_gpu_simple_process_cmd(VirtIOGPU *g,
struct virtio_gpu_ctrl_command *cmd)
{
VIRTIO_GPU_FILL_CMD(cmd->cmd_hdr);
virtio_gpu_ctrl_hdr_bswap(&cmd->cmd_hdr);
Expand Down Expand Up @@ -822,6 +822,7 @@ static void virtio_gpu_handle_cursor_cb(VirtIODevice *vdev, VirtQueue *vq)
void virtio_gpu_process_cmdq(VirtIOGPU *g)
{
struct virtio_gpu_ctrl_command *cmd;
VirtIOGPUClass *vgc = VIRTIO_GPU_GET_CLASS(g);

if (g->processing_cmdq) {
return;
Expand All @@ -835,8 +836,7 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g)
}

/* process command */
VIRGL(g, virtio_gpu_virgl_process_cmd, virtio_gpu_simple_process_cmd,
g, cmd);
vgc->process_cmd(g, cmd);

QTAILQ_REMOVE(&g->cmdq, cmd, next);
if (virtio_gpu_stats_enabled(g->parent_obj.conf)) {
Expand Down Expand Up @@ -1205,6 +1205,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
VirtIOGPUClass *vgc = VIRTIO_GPU_CLASS(klass);

vgc->handle_ctrl = virtio_gpu_handle_ctrl;
vgc->process_cmd = virtio_gpu_simple_process_cmd;

vdc->realize = virtio_gpu_device_realize;
vdc->reset = virtio_gpu_reset;
Expand Down
2 changes: 2 additions & 0 deletions include/hw/virtio/virtio-gpu.h
Expand Up @@ -170,6 +170,7 @@ struct VirtIOGPUClass {
VirtIOGPUBaseClass parent;

void (*handle_ctrl)(VirtIODevice *vdev, VirtQueue *vq);
void (*process_cmd)(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd);
};

struct VirtIOGPUGL {
Expand Down Expand Up @@ -229,6 +230,7 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g,
void virtio_gpu_process_cmdq(VirtIOGPU *g);
void virtio_gpu_device_realize(DeviceState *qdev, Error **errp);
void virtio_gpu_reset(VirtIODevice *vdev);
void virtio_gpu_simple_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd);

/* virtio-gpu-3d.c */
void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
Expand Down

0 comments on commit 2f47691

Please sign in to comment.