Skip to content

Commit b3a5dfd

Browse files
vivekkreddykraxel
authored andcommitted
virtio-gpu: Add gl_flushed callback
Adding this callback provides a way to resume the processing of cmds in fenceq and cmdq that were not processed because the UI was waiting on a fence and blocked cmd processing. Cc: Gerd Hoffmann <[email protected]> Reviewed-by: Gerd Hoffmann <[email protected]> Signed-off-by: Vivek Kasireddy <[email protected]> Message-Id: <[email protected]> Signed-off-by: Gerd Hoffmann <[email protected]>
1 parent ab971f8 commit b3a5dfd

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

hw/display/virtio-gpu.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,8 +985,10 @@ void virtio_gpu_simple_process_cmd(VirtIOGPU *g,
985985
break;
986986
}
987987
if (!cmd->finished) {
988-
virtio_gpu_ctrl_response_nodata(g, cmd, cmd->error ? cmd->error :
989-
VIRTIO_GPU_RESP_OK_NODATA);
988+
if (!g->parent_obj.renderer_blocked) {
989+
virtio_gpu_ctrl_response_nodata(g, cmd, cmd->error ? cmd->error :
990+
VIRTIO_GPU_RESP_OK_NODATA);
991+
}
990992
}
991993
}
992994

@@ -1042,6 +1044,30 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g)
10421044
g->processing_cmdq = false;
10431045
}
10441046

1047+
static void virtio_gpu_process_fenceq(VirtIOGPU *g)
1048+
{
1049+
struct virtio_gpu_ctrl_command *cmd, *tmp;
1050+
1051+
QTAILQ_FOREACH_SAFE(cmd, &g->fenceq, next, tmp) {
1052+
trace_virtio_gpu_fence_resp(cmd->cmd_hdr.fence_id);
1053+
virtio_gpu_ctrl_response_nodata(g, cmd, VIRTIO_GPU_RESP_OK_NODATA);
1054+
QTAILQ_REMOVE(&g->fenceq, cmd, next);
1055+
g_free(cmd);
1056+
g->inflight--;
1057+
if (virtio_gpu_stats_enabled(g->parent_obj.conf)) {
1058+
fprintf(stderr, "inflight: %3d (-)\r", g->inflight);
1059+
}
1060+
}
1061+
}
1062+
1063+
static void virtio_gpu_handle_gl_flushed(VirtIOGPUBase *b)
1064+
{
1065+
VirtIOGPU *g = container_of(b, VirtIOGPU, parent_obj);
1066+
1067+
virtio_gpu_process_fenceq(g);
1068+
virtio_gpu_process_cmdq(g);
1069+
}
1070+
10451071
static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
10461072
{
10471073
VirtIOGPU *g = VIRTIO_GPU(vdev);
@@ -1400,10 +1426,12 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
14001426
DeviceClass *dc = DEVICE_CLASS(klass);
14011427
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
14021428
VirtIOGPUClass *vgc = VIRTIO_GPU_CLASS(klass);
1429+
VirtIOGPUBaseClass *vgbc = &vgc->parent;
14031430

14041431
vgc->handle_ctrl = virtio_gpu_handle_ctrl;
14051432
vgc->process_cmd = virtio_gpu_simple_process_cmd;
14061433
vgc->update_cursor_data = virtio_gpu_update_cursor_data;
1434+
vgbc->gl_flushed = virtio_gpu_handle_gl_flushed;
14071435

14081436
vdc->realize = virtio_gpu_device_realize;
14091437
vdc->reset = virtio_gpu_reset;

0 commit comments

Comments
 (0)