- drm_gem_private_object_init(..) increases the total memory counter. * All GEM objects (whether allocated or imported) seem to begin there. * If there's a better place/method, please do let me know. - drm_gem_object_free(..) decreases the total memory counter. Signed-off-by: Gurchetan Singh <gurchetansingh@xxxxxxxxxxxx> --- drivers/gpu/drm/drm_gem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 24a719b79400..528d7b29dccf 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -213,6 +213,7 @@ void drm_gem_private_object_init(struct drm_device *dev, obj->resv = &obj->_resv; drm_vma_node_reset(&obj->vma_node); + drm_gem_trace_gpu_mem_total(dev, obj->size, false); } EXPORT_SYMBOL(drm_gem_private_object_init); @@ -1015,6 +1016,10 @@ drm_gem_object_free(struct kref *kref) struct drm_gem_object *obj = container_of(kref, struct drm_gem_object, refcount); + struct drm_device *dev = obj->dev; + + drm_gem_trace_gpu_mem_total(dev, -obj->size, false); + if (WARN_ON(!obj->funcs->free)) return; -- 2.25.1