minigbm: i915: Allow protected allocations
Allow allocations with BO_USE_PROTECTED. Moreover, disallow mapping of such BOs, as for GBM/Gralloc API callers it should not be mappable and considered as metadata alone, without usable content. BUG=b:64323695 TEST=emerge-eve arc-cros-gralloc Change-Id: I1dd1846a2042f97eee2fcc7581a91a60854e62cc Reviewed-on: https://chromium-review.googlesource.com/607808 Commit-Ready: Pawel Osciak <posciak@chromium.org> Tested-by: Pawel Osciak <posciak@chromium.org> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
parent
2d1877f041
commit
e0807b1eaa
4 changed files with 15 additions and 6 deletions
3
drv.c
3
drv.c
|
|
@ -396,6 +396,8 @@ void *drv_bo_map(struct bo *bo, uint32_t x, uint32_t y, uint32_t width, uint32_t
|
|||
assert(x + width <= drv_bo_get_width(bo));
|
||||
assert(y + height <= drv_bo_get_height(bo));
|
||||
assert(BO_MAP_READ_WRITE & map_flags);
|
||||
/* No CPU access for protected buffers. */
|
||||
assert(!(bo->use_flags & BO_USE_PROTECTED));
|
||||
|
||||
pthread_mutex_lock(&bo->drv->driver_lock);
|
||||
|
||||
|
|
@ -470,6 +472,7 @@ int drv_bo_flush(struct bo *bo, struct map_info *data)
|
|||
int ret = 0;
|
||||
assert(data);
|
||||
assert(data->refcount >= 0);
|
||||
assert(!(bo->use_flags & BO_USE_PROTECTED));
|
||||
|
||||
if (bo->drv->backend->bo_flush)
|
||||
ret = bo->drv->backend->bo_flush(bo, data);
|
||||
|
|
|
|||
12
drv_priv.h
12
drv_priv.h
|
|
@ -83,13 +83,13 @@ struct backend {
|
|||
};
|
||||
|
||||
// clang-format off
|
||||
#define BO_USE_RENDER_MASK BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_RENDERSCRIPT | \
|
||||
BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | \
|
||||
BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE
|
||||
#define BO_USE_RENDER_MASK BO_USE_LINEAR | BO_USE_PROTECTED | BO_USE_RENDERING | \
|
||||
BO_USE_RENDERSCRIPT | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | \
|
||||
BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE
|
||||
|
||||
#define BO_USE_TEXTURE_MASK BO_USE_LINEAR | BO_USE_RENDERSCRIPT | BO_USE_SW_READ_OFTEN | \
|
||||
BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | \
|
||||
BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE
|
||||
#define BO_USE_TEXTURE_MASK BO_USE_LINEAR | BO_USE_PROTECTED | BO_USE_RENDERSCRIPT | \
|
||||
BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | \
|
||||
BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE
|
||||
|
||||
#define LINEAR_METADATA (struct format_metadata) { 0, 1, DRM_FORMAT_MOD_NONE }
|
||||
// clang-format on
|
||||
|
|
|
|||
4
gbm.h
4
gbm.h
|
|
@ -251,6 +251,10 @@ enum gbm_bo_flags {
|
|||
* The buffer will be read from by a camera subsystem.
|
||||
*/
|
||||
GBM_BO_USE_CAMERA_READ = (1 << 7),
|
||||
/**
|
||||
* Buffer inaccessible to unprivileged users.
|
||||
*/
|
||||
GBM_BO_USE_PROTECTED = (1 << 8),
|
||||
};
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ uint64_t gbm_convert_usage(uint32_t usage)
|
|||
use_flags |= BO_USE_CAMERA_WRITE;
|
||||
if (usage & GBM_BO_USE_CAMERA_READ)
|
||||
use_flags |= BO_USE_CAMERA_READ;
|
||||
if (usage & GBM_BO_USE_PROTECTED)
|
||||
use_flags |= BO_USE_PROTECTED;
|
||||
|
||||
return use_flags;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue