From 355b156a78aa17211b77730dade28f02b64752a1 Mon Sep 17 00:00:00 2001 From: Shirish S Date: Fri, 13 Oct 2017 09:54:03 +0530 Subject: [PATCH] minigbm: add GBM_BO_USE_SW_{READ,WRITE}_{OFTEN,RARELY} usage flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested-by: Gurchetan Singh Reviewed-by: Stéphane Marchesin --- gbm.h | 12 +++++++++++- gbm_helpers.c | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gbm.h b/gbm.h index a58aadb..da993c2 100644 --- 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 diff --git a/gbm_helpers.c b/gbm_helpers.c index c22233a..2683669 100644 --- a/gbm_helpers.c +++ b/gbm_helpers.c @@ -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; }