diff mbox series

[RFC,4/5] drm/cma-helper: account memory used by CMA GEM objects

Message ID 20220909111640.3789791-5-l.stach@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series GEM buffer memory tracking | expand

Commit Message

Lucas Stach Sept. 9, 2022, 11:16 a.m. UTC
CMA buffer are pinned into system memory as soon as they are allocated
and will only disappear when they are freed.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/gpu/drm/drm_gem_cma_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
index 42abee9a0f4f..f0c4e7e6cc33 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -162,6 +162,8 @@  struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
 		goto error;
 	}
 
+	drm_gem_add_resident(&cma_obj->base);
+
 	return cma_obj;
 
 error:
@@ -230,6 +232,8 @@  void drm_gem_cma_free(struct drm_gem_cma_object *cma_obj)
 	struct drm_gem_object *gem_obj = &cma_obj->base;
 	struct iosys_map map = IOSYS_MAP_INIT_VADDR(cma_obj->vaddr);
 
+	drm_gem_dec_resident(gem_obj);
+
 	if (gem_obj->import_attach) {
 		if (cma_obj->vaddr)
 			dma_buf_vunmap(gem_obj->import_attach->dmabuf, &map);