etnaviv: drm: don't cache mmap offset

The mmap offset is the only information we currently get from
DRM_ETNAVIV_GEM_INFO and there is no point in storing this
offset after the mapping has been established. Reduce the
shared mutable state on the etna_bo by inlining fetching the
offset into etna_bo_map.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14466>
This commit is contained in:
Lucas Stach 2022-01-06 21:38:43 +01:00 committed by Marge Bot
parent 8997b9579f
commit 5711329cbc
2 changed files with 10 additions and 25 deletions

View File

@ -220,26 +220,6 @@ struct etna_bo *etna_bo_ref(struct etna_bo *bo)
return bo;
}
/* get buffer info */
static int get_buffer_info(struct etna_bo *bo)
{
int ret;
struct drm_etnaviv_gem_info req = {
.handle = bo->handle,
};
ret = drmCommandWriteRead(bo->dev->fd, DRM_ETNAVIV_GEM_INFO,
&req, sizeof(req));
if (ret) {
return ret;
}
/* really all we need for now is mmap offset */
bo->offset = req.offset;
return 0;
}
/* import a buffer object from DRI2 name */
struct etna_bo *etna_bo_from_name(struct etna_device *dev,
uint32_t name)
@ -407,12 +387,18 @@ uint32_t etna_bo_gpu_va(struct etna_bo *bo)
void *etna_bo_map(struct etna_bo *bo)
{
if (!bo->map) {
if (!bo->offset) {
get_buffer_info(bo);
}
int ret;
struct drm_etnaviv_gem_info req = {
.handle = bo->handle,
};
ret = drmCommandWriteRead(bo->dev->fd, DRM_ETNAVIV_GEM_INFO,
&req, sizeof(req));
if (ret)
return NULL;
bo->map = os_mmap(0, bo->size, PROT_READ | PROT_WRITE,
MAP_SHARED, bo->dev->fd, bo->offset);
MAP_SHARED, bo->dev->fd, req.offset);
if (bo->map == MAP_FAILED) {
ERROR_MSG("mmap failed: %s", strerror(errno));
bo->map = NULL;

View File

@ -109,7 +109,6 @@ struct etna_bo {
uint32_t handle;
uint32_t flags;
uint32_t name; /* flink global handle (DRI2 name) */
uint64_t offset; /* offset to mmap() */
uint32_t va; /* GPU virtual address */
int refcnt;