minigbm: Use dmabuf inode as unique buffer id instead of handle

Handle has some limits and can't be used as unique buffer ID on systems
where display controller can scanout from CMA but GPU can work with both
CMA and VRAM.

Such systems have DRM/KMS and DRM/GPU drivers separated.
GBM frontend is always expecting handle for DRM/KMS driver.
In such system any attempt of importing the buffer with more
than 1 contiguous chunk into DRM/KMS driver will fail.

Using dma-buf inode as unique buffer ID is a common practice for
a last several years starting from [this kernel patch][1].

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed63bb1d1f8469586006a9ca63c42344401aa2ab
Change-Id: Ic3a69010d5da2f866a2252fc7e9eb29d67f8e1ed
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
This commit is contained in:
Roman Stratiienko 2022-10-02 17:14:06 +03:00 committed by Brendan Szymanski
parent cce8dc57df
commit 4f7758ffa1
6 changed files with 40 additions and 16 deletions

View file

@ -1097,7 +1097,7 @@ static int virgl_bo_invalidate(struct bo *bo, struct mapping *mapping)
if (params[param_resource_blob].value && (bo->meta.tiling & VIRTGPU_BLOB_FLAG_USE_MAPPABLE))
return 0;
xfer.bo_handle = mapping->vma->handle;
xfer.bo_handle = bo->handle.u32;
if (mapping->rect.x || mapping->rect.y) {
/*
@ -1151,7 +1151,7 @@ static int virgl_bo_invalidate(struct bo *bo, struct mapping *mapping)
// The transfer needs to complete before invalidate returns so that any host changes
// are visible and to ensure the host doesn't overwrite subsequent guest changes.
// TODO(b/136733358): Support returning fences from transfers
waitcmd.handle = mapping->vma->handle;
waitcmd.handle = bo->handle.u32;
ret = drmIoctl(bo->drv->fd, DRM_IOCTL_VIRTGPU_WAIT, &waitcmd);
if (ret) {
drv_loge("DRM_IOCTL_VIRTGPU_WAIT failed with %s\n", strerror(errno));
@ -1179,7 +1179,7 @@ static int virgl_bo_flush(struct bo *bo, struct mapping *mapping)
if (params[param_resource_blob].value && (bo->meta.tiling & VIRTGPU_BLOB_FLAG_USE_MAPPABLE))
return 0;
xfer.bo_handle = mapping->vma->handle;
xfer.bo_handle = bo->handle.u32;
if (mapping->rect.x || mapping->rect.y) {
/*
@ -1229,7 +1229,7 @@ static int virgl_bo_flush(struct bo *bo, struct mapping *mapping)
// buffer, we need to wait for the transfer to complete for consistency.
// TODO(b/136733358): Support returning fences from transfers
if (bo->meta.use_flags & BO_USE_NON_GPU_HW) {
waitcmd.handle = mapping->vma->handle;
waitcmd.handle = bo->handle.u32;
ret = drmIoctl(bo->drv->fd, DRM_IOCTL_VIRTGPU_WAIT, &waitcmd);
if (ret) {