OSDN Git Service

minigbm: add GBM_BO_USE_SW_{READ,WRITE}_{OFTEN,RARELY} usage flags
authorShirish S <shirish.s@amd.com>
Fri, 13 Oct 2017 04:24:03 +0000 (09:54 +0530)
committerchrome-bot <chrome-bot@chromium.org>
Thu, 16 Nov 2017 21:52:03 +0000 (13:52 -0800)
Need for these flags has arisen because buffer's allocated
BO_USE_SCANOUT flag is not mmapable in amd, whereas going further
for ensuring atomictity related operations are functional, one
needs buffer to be mmap'd.

These flags shall be used to strike balance in enabling
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED on amd and mmap X-tiled buffers
on Intel platforms.

BUG=b:65297611, chromium:777706
TEST=On Kahlee,
     UI comes up.
     GLMark2 & GLbench autotests show no performance regression
     atomictest -t multiplanes passes
     WebGL Aquarium

Change-Id: I582452d331f4a05106939447784a76eba06d13c2
Reviewed-on: https://chromium-review.googlesource.com/758618
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
gbm.h
gbm_helpers.c

diff --git a/gbm.h b/gbm.h
index a58aadb..da993c2 100644 (file)
--- a/gbm.h
+++ b/gbm.h
@@ -236,7 +236,8 @@ enum gbm_bo_flags {
     * Buffer is guaranteed to be laid out linearly in memory. That is, the
     * buffer is laid out as an array with 'height' blocks, each block with
     * length 'stride'. Each stride is in the same order as the rows of the
-    * buffer.
+    * buffer. This is intended to be used with buffers that will be accessed
+    * via dma-buf mmap().
     */
    GBM_BO_USE_LINEAR    = (1 << 4),
    /**
@@ -255,6 +256,15 @@ enum gbm_bo_flags {
     * Buffer inaccessible to unprivileged users.
     */
    GBM_BO_USE_PROTECTED = (1 << 8),
+   /**
+    * These flags specify the frequency of software access. These flags do not
+    * guarantee the buffer is linear, but do guarantee gbm_bo_map(..) will
+    * present a linear view.
+    */
+   GBM_BO_USE_SW_READ_OFTEN = (1 << 9),
+   GBM_BO_USE_SW_READ_RARELY = (1 << 10),
+   GBM_BO_USE_SW_WRITE_OFTEN = (1 << 11),
+   GBM_BO_USE_SW_WRITE_RARELY = (1 << 12),
 };
 
 int
index c22233a..2683669 100644 (file)
@@ -32,6 +32,14 @@ uint64_t gbm_convert_usage(uint32_t usage)
                use_flags |= BO_USE_CAMERA_READ;
        if (usage & GBM_BO_USE_PROTECTED)
                use_flags |= BO_USE_PROTECTED;
+       if (usage & GBM_BO_USE_SW_READ_OFTEN)
+               use_flags |= BO_USE_SW_READ_OFTEN;
+       if (usage & GBM_BO_USE_SW_READ_RARELY)
+               use_flags |= BO_USE_SW_READ_RARELY;
+       if (usage & GBM_BO_USE_SW_WRITE_OFTEN)
+               use_flags |= BO_USE_SW_WRITE_OFTEN;
+       if (usage & GBM_BO_USE_SW_WRITE_RARELY)
+               use_flags |= BO_USE_SW_WRITE_RARELY;
 
        return use_flags;
 }