diff mbox series

[v8,07/11] virtio-gpu: Support suspension of commands processing

Message ID 20240418190040.1110210-8-dmitry.osipenko@collabora.com (mailing list archive)
State New
Headers show
Series Support blob memory and venus on qemu | expand

Commit Message

Dmitry Osipenko April 18, 2024, 7 p.m. UTC
Add new "suspended" flag to virtio_gpu_ctrl_command telling cmd
processor that it should stop processing commands and retry again
next time until flag is unset.

Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
---
 hw/display/virtio-gpu-gl.c       | 1 +
 hw/display/virtio-gpu-rutabaga.c | 1 +
 hw/display/virtio-gpu-virgl.c    | 3 +++
 hw/display/virtio-gpu.c          | 5 +++++
 include/hw/virtio/virtio-gpu.h   | 1 +
 5 files changed, 11 insertions(+)

Comments

Akihiko Odaki April 19, 2024, 8:53 a.m. UTC | #1
On 2024/04/19 4:00, Dmitry Osipenko wrote:
> Add new "suspended" flag to virtio_gpu_ctrl_command telling cmd
> processor that it should stop processing commands and retry again
> next time until flag is unset.
> 
> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>

This flag shouldn't be added to virtio_gpu_ctrl_command. suspended is 
just !finished in virtio-gpu.c. Only virtio_gpu_virgl_process_cmd() 
needs the distinction of suspended and !finished so it is not 
appropriate to add this flag the common structure.

Regards,
Akihiko Odaki
Dmitry Osipenko April 24, 2024, 9:43 a.m. UTC | #2
On 4/19/24 11:53, Akihiko Odaki wrote:
> On 2024/04/19 4:00, Dmitry Osipenko wrote:
>> Add new "suspended" flag to virtio_gpu_ctrl_command telling cmd
>> processor that it should stop processing commands and retry again
>> next time until flag is unset.
>>
>> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> 
> This flag shouldn't be added to virtio_gpu_ctrl_command. suspended is
> just !finished in virtio-gpu.c. Only virtio_gpu_virgl_process_cmd()
> needs the distinction of suspended and !finished so it is not
> appropriate to add this flag the common structure.

The VIRTIO_GPU_FILL_CMD() macro returns void and this macro is used by
every function processing commands. Changing process_cmd() to return
bool will require to change all those functions. Not worthwhile to
change it, IMO.

The flag reflects the exact command status. The !finished + !suspended
means that command is fenced, i.e. these flags don't have exactly same
meaning.

I'd keep the flag if there are no better suggestions.
Akihiko Odaki April 27, 2024, 5:48 a.m. UTC | #3
On 2024/04/24 18:43, Dmitry Osipenko wrote:
> On 4/19/24 11:53, Akihiko Odaki wrote:
>> On 2024/04/19 4:00, Dmitry Osipenko wrote:
>>> Add new "suspended" flag to virtio_gpu_ctrl_command telling cmd
>>> processor that it should stop processing commands and retry again
>>> next time until flag is unset.
>>>
>>> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
>>
>> This flag shouldn't be added to virtio_gpu_ctrl_command. suspended is
>> just !finished in virtio-gpu.c. Only virtio_gpu_virgl_process_cmd()
>> needs the distinction of suspended and !finished so it is not
>> appropriate to add this flag the common structure.
> 
> The VIRTIO_GPU_FILL_CMD() macro returns void and this macro is used by
> every function processing commands. Changing process_cmd() to return
> bool will require to change all those functions. Not worthwhile to
> change it, IMO. >
> The flag reflects the exact command status. The !finished + !suspended
> means that command is fenced, i.e. these flags don't have exactly same
> meaning.

It is not necessary to change the signature of process_cmd(). You can 
just refer to !finished. No need to have the suspended flag.

> 
> I'd keep the flag if there are no better suggestions.
>
Dmitry Osipenko May 1, 2024, 7:02 p.m. UTC | #4
On 4/27/24 08:48, Akihiko Odaki wrote:
>>
>> The VIRTIO_GPU_FILL_CMD() macro returns void and this macro is used by
>> every function processing commands. Changing process_cmd() to return
>> bool will require to change all those functions. Not worthwhile to
>> change it, IMO. >
>> The flag reflects the exact command status. The !finished + !suspended
>> means that command is fenced, i.e. these flags don't have exactly same
>> meaning.
> 
> It is not necessary to change the signature of process_cmd(). You can
> just refer to !finished. No need to have the suspended flag.

Not sure what you're meaning. The !finished says that cmd is fenced,
this fenced command is added to the polling list and the fence is
checked periodically by the fence_poll timer, meanwhile next virgl
commands are executed in the same time.

This is completely different from the suspension where whole cmd
processing is blocked until command is resumed.
diff mbox series

Patch

diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index ba478124e2c2..a8892bcc5346 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -79,6 +79,7 @@  static void virtio_gpu_gl_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
         cmd->vq = vq;
         cmd->error = 0;
         cmd->finished = false;
+        cmd->suspended = false;
         QTAILQ_INSERT_TAIL(&g->cmdq, cmd, next);
         cmd = virtqueue_pop(vq, sizeof(struct virtio_gpu_ctrl_command));
     }
diff --git a/hw/display/virtio-gpu-rutabaga.c b/hw/display/virtio-gpu-rutabaga.c
index 17bf701a2163..b6e84d436fb2 100644
--- a/hw/display/virtio-gpu-rutabaga.c
+++ b/hw/display/virtio-gpu-rutabaga.c
@@ -1061,6 +1061,7 @@  static void virtio_gpu_rutabaga_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
         cmd->vq = vq;
         cmd->error = 0;
         cmd->finished = false;
+        cmd->suspended = false;
         QTAILQ_INSERT_TAIL(&g->cmdq, cmd, next);
         cmd = virtqueue_pop(vq, sizeof(struct virtio_gpu_ctrl_command));
     }
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index c2057b0c2147..bb9ee1eba9a0 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -670,6 +670,9 @@  void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
         break;
     }
 
+    if (cmd->suspended) {
+        return;
+    }
     if (cmd->finished) {
         return;
     }
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 1e57a53d346c..a1bd4d6914c4 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1054,6 +1054,10 @@  void virtio_gpu_process_cmdq(VirtIOGPU *g)
         /* process command */
         vgc->process_cmd(g, cmd);
 
+        if (cmd->suspended) {
+            break;
+        }
+
         QTAILQ_REMOVE(&g->cmdq, cmd, next);
         if (virtio_gpu_stats_enabled(g->parent_obj.conf)) {
             g->stats.requests++;
@@ -1113,6 +1117,7 @@  static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
         cmd->vq = vq;
         cmd->error = 0;
         cmd->finished = false;
+        cmd->suspended = false;
         QTAILQ_INSERT_TAIL(&g->cmdq, cmd, next);
         cmd = virtqueue_pop(vq, sizeof(struct virtio_gpu_ctrl_command));
     }
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 44c676c3ca4a..dc24360656ce 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -132,6 +132,7 @@  struct virtio_gpu_ctrl_command {
     struct virtio_gpu_ctrl_hdr cmd_hdr;
     uint32_t error;
     bool finished;
+    bool suspended;
     QTAILQ_ENTRY(virtio_gpu_ctrl_command) next;
 };