diff mbox series

[RFC,7/8] drm: trace memory import per DRM file

Message ID 20211021031027.537-8-gurchetansingh@chromium.org (mailing list archive)
State New, archived
Headers show
Series GPU memory tracepoints | expand

Commit Message

Gurchetan Singh Oct. 21, 2021, 3:10 a.m. UTC
- drm_gem_prime_fd_to_handle increases the per-instance imported
  memory counter

- drm_gem_remove_prime_handles decreases the per-instance imported
  memory counter on non-fake imports.

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
---
 drivers/gpu/drm/drm_gem.c   | 3 +++
 drivers/gpu/drm/drm_prime.c | 2 ++
 2 files changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 7637be0ceb74..c07568ea8442 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -231,6 +231,9 @@  drm_gem_remove_prime_handles(struct drm_gem_object *obj, struct drm_file *filp)
 		drm_prime_remove_buf_handle_locked(&filp->prime,
 						   obj->dma_buf,
 						   &removed_real_import);
+		if (removed_real_import)
+			drm_gem_trace_gpu_mem_instance(dev, filp, -obj->size,
+						       true);
 	}
 	mutex_unlock(&filp->prime.lock);
 }
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 31f033ec8549..1afcae0c4038 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -349,6 +349,8 @@  int drm_gem_prime_fd_to_handle(struct drm_device *dev,
 
 	dma_buf_put(dma_buf);
 
+	drm_gem_trace_gpu_mem_instance(dev, file_priv, obj->size, true);
+
 	return 0;
 
 fail: