OSDN Git Service

virtgpu: improve blob support on ARCVM
authorDavid Stevens <stevensd@chromium.org>
Thu, 10 Sep 2020 01:50:26 +0000 (10:50 +0900)
committerCommit Bot <commit-bot@chromium.org>
Thu, 17 Sep 2020 01:13:16 +0000 (01:13 +0000)
This change expands the types of buffers which use blob allocation, to
cover decoder/encoder bitstream buffers. It also adds tiling to the
exported buffer metadata, so that flush/invalidate are properly skipped
on imported blob buffers.

BUG=None
TEST=tast run ARCVM-DUT arc.VideoDecodeAccel.*

Change-Id: I460f4448db9e1bd2f7458f3180c4e92ff3b3d74f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2400839
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>

cros_gralloc/cros_gralloc_driver.cc
cros_gralloc/cros_gralloc_handle.h
drv.h
helpers.c
virtio_gpu.c

index a7174d7..ab7c654 100644 (file)
@@ -217,6 +217,7 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto
        hnd->width = drv_bo_get_width(bo);
        hnd->height = drv_bo_get_height(bo);
        hnd->format = drv_bo_get_format(bo);
+       hnd->tiling = bo->meta.tiling;
        hnd->format_modifier = drv_bo_get_plane_format_modifier(bo, 0);
        hnd->use_flags = descriptor->use_flags;
        bytes_per_pixel = drv_bytes_per_pixel_from_format(hnd->format, 0);
@@ -271,6 +272,7 @@ int32_t cros_gralloc_driver::retain(buffer_handle_t handle)
                struct bo *bo;
                struct drv_import_fd_data data;
                data.format = hnd->format;
+               data.tiling = hnd->tiling;
 
                data.width = hnd->width;
                data.height = hnd->height;
@@ -503,4 +505,4 @@ void cros_gralloc_driver::for_each_handle(
        for (const auto &pair : handles_) {
                function(pair.first);
        }
-}
\ No newline at end of file
+}
index d2e1607..b5525d1 100644 (file)
@@ -31,6 +31,7 @@ struct cros_gralloc_handle {
        uint32_t width;
        uint32_t height;
        uint32_t format; /* DRM format */
+       uint32_t tiling;
        uint64_t format_modifier;
        uint64_t use_flags; /* Buffer creation flags */
        uint32_t magic;
diff --git a/drv.h b/drv.h
index f19f9de..4a47b76 100644 (file)
--- a/drv.h
+++ b/drv.h
@@ -89,6 +89,7 @@ struct drv_import_fd_data {
        uint32_t width;
        uint32_t height;
        uint32_t format;
+       uint32_t tiling;
        uint64_t use_flags;
 };
 
index 17b1765..1b5c2a8 100644 (file)
--- a/helpers.c
+++ b/helpers.c
@@ -451,6 +451,7 @@ int drv_prime_bo_import(struct bo *bo, struct drv_import_fd_data *data)
 
                bo->handles[plane].u32 = prime_handle.handle;
        }
+       bo->meta.tiling = data->tiling;
 
        return 0;
 }
index 38d0249..f9c13f4 100644 (file)
@@ -687,10 +687,15 @@ static int virtio_gpu_bo_create_blob(struct driver *drv, struct bo *bo)
        uint32_t cmd[VIRGL_PIPE_RES_CREATE_SIZE + 1] = { 0 };
        struct drm_virtgpu_resource_create_blob drm_rc_blob = { 0 };
 
+       uint32_t blob_flags = VIRTGPU_BLOB_FLAG_USE_MAPPABLE | VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
+       if (bo->meta.use_flags & BO_USE_NON_GPU_HW) {
+               blob_flags |= VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE;
+       }
+
        stride = drv_stride_from_format(bo->meta.format, bo->meta.width, 0);
        drv_bo_from_format(bo, stride, bo->meta.height, bo->meta.format);
        bo->meta.total_size = ALIGN(bo->meta.total_size, PAGE_SIZE);
-       bo->meta.tiling = VIRTGPU_BLOB_FLAG_USE_MAPPABLE | VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
+       bo->meta.tiling = blob_flags;
 
        cmd[0] = VIRGL_CMD0(VIRGL_CCMD_PIPE_RESOURCE_CREATE, 0, VIRGL_PIPE_RES_CREATE_SIZE);
        cmd[VIRGL_PIPE_RES_CREATE_TARGET] = PIPE_TEXTURE_2D;
@@ -704,7 +709,7 @@ static int virtio_gpu_bo_create_blob(struct driver *drv, struct bo *bo)
        drm_rc_blob.cmd_size = 4 * (VIRGL_PIPE_RES_CREATE_SIZE + 1);
        drm_rc_blob.size = bo->meta.total_size;
        drm_rc_blob.blob_mem = VIRTGPU_BLOB_MEM_HOST3D;
-       drm_rc_blob.blob_flags = VIRTGPU_BLOB_FLAG_USE_MAPPABLE | VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
+       drm_rc_blob.blob_flags = blob_flags;
 
        ret = drmIoctl(drv->fd, DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB, &drm_rc_blob);
        if (ret < 0) {
@@ -731,16 +736,16 @@ static bool should_use_blob(struct driver *drv, uint32_t format, uint64_t use_fl
        if (!priv->host_gbm_enabled)
                return false;
 
-       // Focus on SW read/write apps for now
-       if (use_flags & (BO_USE_RENDERING | BO_USE_HW_VIDEO_ENCODER | BO_USE_HW_VIDEO_DECODER))
+       // Focus on non-GPU apps for now
+       if (use_flags & (BO_USE_RENDERING | BO_USE_TEXTURE))
                return false;
 
        // Simple, strictly defined formats for now
-       if (format != DRM_FORMAT_YVU420_ANDROID || format != DRM_FORMAT_R8)
+       if (format != DRM_FORMAT_YVU420_ANDROID && format != DRM_FORMAT_R8)
                return false;
 
-       if (use_flags & (BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | BO_USE_LINEAR |
-                        BO_USE_CAMERA_WRITE | BO_USE_CAMERA_READ))
+       if (use_flags &
+           (BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | BO_USE_LINEAR | BO_USE_NON_GPU_HW))
                return true;
 
        return false;