Mesa (main): etnaviv: drm: don't cache mmap offset
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Jul 3 17:49:44 UTC 2022
Module: Mesa
Branch: main
Commit: 5711329cbc037346ed759333294cb198e86bd772
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5711329cbc037346ed759333294cb198e86bd772
Author: Lucas Stach <l.stach at pengutronix.de>
Date: Thu Jan 6 21:38:43 2022 +0100
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 at pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14466>
---
src/etnaviv/drm/etnaviv_bo.c | 34 ++++++++++------------------------
src/etnaviv/drm/etnaviv_priv.h | 1 -
2 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/src/etnaviv/drm/etnaviv_bo.c b/src/etnaviv/drm/etnaviv_bo.c
index fc91990cf28..b0a3dfa6651 100644
--- a/src/etnaviv/drm/etnaviv_bo.c
+++ b/src/etnaviv/drm/etnaviv_bo.c
@@ -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;
diff --git a/src/etnaviv/drm/etnaviv_priv.h b/src/etnaviv/drm/etnaviv_priv.h
index 3cd380f2dc0..d9233a19519 100644
--- a/src/etnaviv/drm/etnaviv_priv.h
+++ b/src/etnaviv/drm/etnaviv_priv.h
@@ -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;
More information about the mesa-commit
mailing list