drm/msm: Add memory stats to fdinfo
authorRob Clark <robdclark@chromium.org>
Wed, 24 May 2023 15:59:36 +0000 (08:59 -0700)
committerNeil Armstrong <neil.armstrong@linaro.org>
Wed, 24 May 2023 16:03:32 +0000 (18:03 +0200)
Use the new helper to export stats about memory usage.

v2: Drop unintended hunk
v3: Rebase

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230524155956.382440-7-robdclark@gmail.com
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_gem.c

index 02fd6093f9b0b25a16704b9df010ca8b5a8ae6cf..58264ff2c4b1987fea6d3c6c01cac3c4693f73aa 100644 (file)
@@ -1066,6 +1066,8 @@ static void msm_show_fdinfo(struct drm_printer *p, struct drm_file *file)
                return;
 
        msm_gpu_show_fdinfo(priv->gpu, file->driver_priv, p);
+
+       drm_show_memory_stats(p, file);
 }
 
 static const struct file_operations fops = {
index db6c4e281d75d06dc169c0e48d7c112413db682e..c32264234ea162c60add369a96e00d54240ca32b 100644 (file)
@@ -1096,6 +1096,20 @@ int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
        return ret;
 }
 
+static enum drm_gem_object_status msm_gem_status(struct drm_gem_object *obj)
+{
+       struct msm_gem_object *msm_obj = to_msm_bo(obj);
+       enum drm_gem_object_status status = 0;
+
+       if (msm_obj->pages)
+               status |= DRM_GEM_OBJECT_RESIDENT;
+
+       if (msm_obj->madv == MSM_MADV_DONTNEED)
+               status |= DRM_GEM_OBJECT_PURGEABLE;
+
+       return status;
+}
+
 static const struct vm_operations_struct vm_ops = {
        .fault = msm_gem_fault,
        .open = drm_gem_vm_open,
@@ -1110,6 +1124,7 @@ static const struct drm_gem_object_funcs msm_gem_object_funcs = {
        .vmap = msm_gem_prime_vmap,
        .vunmap = msm_gem_prime_vunmap,
        .mmap = msm_gem_object_mmap,
+       .status = msm_gem_status,
        .vm_ops = &vm_ops,
 };