[RFC PATCH 5/5] drm/etnaviv: account memory used by GEM buffers

Lucas Stach l.stach at pengutronix.de
Fri Sep 9 11:16:40 UTC 2022


Etnaviv GEM buffers are pinned into memory as soon as we allocate
the pages backing the object and only disappear when freeing the
GEM object as there is no shrinker hooked up for unused buffers.

Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index cc386f8a7116..bf3d75b8e154 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -67,6 +67,8 @@ static int etnaviv_gem_shmem_get_pages(struct etnaviv_gem_object *etnaviv_obj)
 
 	etnaviv_obj->pages = p;
 
+	drm_gem_add_resident(&etnaviv_obj->base);
+
 	return 0;
 }
 
@@ -79,6 +81,7 @@ static void put_pages(struct etnaviv_gem_object *etnaviv_obj)
 		etnaviv_obj->sgt = NULL;
 	}
 	if (etnaviv_obj->pages) {
+		drm_gem_dec_resident(&etnaviv_obj->base);
 		drm_gem_put_pages(&etnaviv_obj->base, etnaviv_obj->pages,
 				  true, false);
 
-- 
2.30.2



More information about the dri-devel mailing list