diff mbox series

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

Message ID 20211021031027.537-9-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_import_dev increases the per-device import memory
  counter

  * Most drivers use it.

  * drivers that have a (*gem_prime_import) callback will need
    additional changes, which can be done if everyone likes the
    overall RFC.

- drm_prime_gem_destroy decreases the per-device import memory
  counter.

  * All drivers seem to use it?

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

Patch

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 1afcae0c4038..c2057b7a63b4 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -955,6 +955,7 @@  struct drm_gem_object *drm_gem_prime_import_dev(struct drm_device *dev,
 
 	obj->import_attach = attach;
 	obj->resv = dma_buf->resv;
+	drm_gem_trace_gpu_mem_total(dev, obj->size, true);
 
 	return obj;
 
@@ -1055,6 +1056,7 @@  void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg)
 	struct dma_buf_attachment *attach;
 	struct dma_buf *dma_buf;
 
+	drm_gem_trace_gpu_mem_total(obj->dev, -obj->size, true);
 	attach = obj->import_attach;
 	if (sg)
 		dma_buf_unmap_attachment(attach, sg, DMA_BIDIRECTIONAL);