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:
@@ -220,26 +220,6 @@ struct etna_bo *etna_bo_ref(struct etna_bo *bo)
|
|||||||
return 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 */
|
/* import a buffer object from DRI2 name */
|
||||||
struct etna_bo *etna_bo_from_name(struct etna_device *dev,
|
struct etna_bo *etna_bo_from_name(struct etna_device *dev,
|
||||||
uint32_t name)
|
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)
|
void *etna_bo_map(struct etna_bo *bo)
|
||||||
{
|
{
|
||||||
if (!bo->map) {
|
if (!bo->map) {
|
||||||
if (!bo->offset) {
|
int ret;
|
||||||
get_buffer_info(bo);
|
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,
|
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) {
|
if (bo->map == MAP_FAILED) {
|
||||||
ERROR_MSG("mmap failed: %s", strerror(errno));
|
ERROR_MSG("mmap failed: %s", strerror(errno));
|
||||||
bo->map = NULL;
|
bo->map = NULL;
|
||||||
|
@@ -109,7 +109,6 @@ struct etna_bo {
|
|||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t name; /* flink global handle (DRI2 name) */
|
uint32_t name; /* flink global handle (DRI2 name) */
|
||||||
uint64_t offset; /* offset to mmap() */
|
|
||||||
uint32_t va; /* GPU virtual address */
|
uint32_t va; /* GPU virtual address */
|
||||||
int refcnt;
|
int refcnt;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user