Skip to content

Commit

Permalink
drm/v3d: Expose memory stats through fdinfo
Browse files Browse the repository at this point in the history
Use the common DRM function `drm_show_memory_stats()` to expose standard
fdinfo memory stats.

V3D exposes global GPU memory stats through debugfs. Those stats will be
preserved while the DRM subsystem doesn't have a standard solution to
expose global GPU stats.

Signed-off-by: Maíra Canal <[email protected]>
Reviewed-by: Tvrtko Ursulin <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
mairacanal committed Jul 13, 2024
1 parent c48abf0 commit 0b91c6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/gpu/drm/v3d/v3d_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
#include "v3d_drv.h"
#include "uapi/drm/v3d_drm.h"

static enum drm_gem_object_status v3d_gem_status(struct drm_gem_object *obj)
{
struct v3d_bo *bo = to_v3d_bo(obj);
enum drm_gem_object_status res = 0;

if (bo->base.pages)
res |= DRM_GEM_OBJECT_RESIDENT;

return res;
}

/* Called DRM core on the last userspace/kernel unreference of the
* BO.
*/
Expand Down Expand Up @@ -63,6 +74,7 @@ static const struct drm_gem_object_funcs v3d_gem_funcs = {
.vmap = drm_gem_shmem_object_vmap,
.vunmap = drm_gem_shmem_object_vunmap,
.mmap = drm_gem_shmem_object_mmap,
.status = v3d_gem_status,
.vm_ops = &drm_gem_shmem_vm_ops,
};

Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/v3d/v3d_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ static void v3d_show_fdinfo(struct drm_printer *p, struct drm_file *file)
drm_printf(p, "v3d-jobs-%s: \t%llu jobs\n",
v3d_queue_to_string(queue), jobs_completed);
}

drm_show_memory_stats(p, file);
}

static const struct file_operations v3d_drm_fops = {
Expand Down

0 comments on commit 0b91c6d

Please sign in to comment.