On 11/12/25 03:44, Yiwei Zhang wrote:
...
>>> Friendly ping. My early comments here might have been missed ; )
>>
>> I indeed missed that first part of the comment, thanks.
>>
>> Could you please give a code sample of your suggestion?
>>
>> The `if (f->ring_idx >= 0)` is a sanity-check for that we're not getting
>> a fence that has ring_idx without a set RING_IDX flag. All other fences
>> are processed by that fence-handling loop.
>>
>> --
>> Best regards,
>> Dmitry
> 
> QEMU creates ctx0 fences without seeing the RING_IDX flag, and I think
> that sanity check is a bit redundant. So I was suggesting below for
> simplicity:
> 
> diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
> index ccba1d8ee4..12c1e1764c 100644
> --- a/hw/display/virtio-gpu-virgl.c
> +++ b/hw/display/virtio-gpu-virgl.c
> @@ -1117,9 +1117,6 @@ static void virtio_gpu_virgl_async_fence_bh(void 
> *opaque)
>                  if (cmd->cmd_hdr.ctx_id != f->ctx_id) {
>                      continue;
>                  }
> -            } else if (f->ring_idx >= 0) {
> -                /* ctx0 GL-query fences don't have ring info */
> -                continue;
>              }
>              virtio_gpu_ctrl_response_nodata(g, cmd, 
> VIRTIO_GPU_RESP_OK_NODATA);
>              QTAILQ_REMOVE(&g->fenceq, cmd, next);
> @@ -1137,7 +1134,7 @@ static void virtio_gpu_virgl_async_fence_bh(void 
> *opaque)
> 
>  static void
>  virtio_gpu_virgl_push_async_fence(VirtIOGPU *g, uint32_t ctx_id,
> -                                  int64_t ring_idx, uint64_t fence_id)
> +                                  uint32_t ring_idx, uint64_t fence_id)
>  {
>      struct virtio_gpu_virgl_context_fence *f;
>      VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
> @@ -1156,7 +1153,7 @@ static void virgl_write_async_fence(void
> *opaque, uint32_t fence)
>  {
>      VirtIOGPU *g = opaque;
> 
> -    virtio_gpu_virgl_push_async_fence(g, 0, -1, fence);
> +    virtio_gpu_virgl_push_async_fence(g, 0, UINT32_MAX, fence);
>  }
> 
>  static void virgl_write_async_context_fence(void *opaque, uint32_t ctx_id,
> diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
> index a4963508a4..cd576c9e0d 100644
> --- a/include/hw/virtio/virtio-gpu.h
> +++ b/include/hw/virtio/virtio-gpu.h
> @@ -238,7 +238,7 @@ struct VirtIOGPUClass {
> 
>  struct virtio_gpu_virgl_context_fence {
>      uint32_t ctx_id;
> -    int64_t ring_idx;
> +    uint32_t ring_idx;
>      uint64_t fence_id;
>      QSLIST_ENTRY(virtio_gpu_virgl_context_fence) next;
>  };

Should work, thanks.

-- 
Best regards,
Dmitry

Reply via email to