[RFC PATCH 5/8] drm: start using drm_gem_trace_gpu_mem_instance

Gurchetan Singh gurchetansingh at chromium.org
Thu Oct 21 03:10:24 UTC 2021


- drm_gem_handle_create_tail(..) increases the per instance
  memory counter.

- drm_gem_object_release_handle(..) decreases the per instance
  memory counter.

Signed-off-by: Gurchetan Singh <gurchetansingh at chromium.org>
---
 drivers/gpu/drm/drm_gem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 528d7b29dccf..6f70419f2c90 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -298,6 +298,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
 {
 	struct drm_file *file_priv = data;
 	struct drm_gem_object *obj = ptr;
+	struct drm_device *dev = file_priv->minor->dev;
 
 	if (obj->funcs->close)
 		obj->funcs->close(obj, file_priv);
@@ -305,6 +306,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
 	drm_gem_remove_prime_handles(obj, file_priv);
 	drm_vma_node_revoke(&obj->vma_node, file_priv);
 
+	drm_gem_trace_gpu_mem_instance(dev, file_priv, -obj->size, false);
 	drm_gem_object_handle_put_unlocked(obj);
 
 	return 0;
@@ -447,6 +449,7 @@ drm_gem_handle_create_tail(struct drm_file *file_priv,
 			goto err_revoke;
 	}
 
+	drm_gem_trace_gpu_mem_instance(dev, file_priv, obj->size, false);
 	*handlep = handle;
 	return 0;
 
-- 
2.25.1



More information about the dri-devel mailing list