diff options
author | Jordan Crouse <jcrouse@codeaurora.org> | 2018-11-07 23:35:52 +0100 |
---|---|---|
committer | Rob Clark <robdclark@gmail.com> | 2018-12-11 19:06:59 +0100 |
commit | 0815d7749a68527adabe2ac40d49f6fc0800eae5 (patch) | |
tree | c25b7564d054a0d176b280974eff796d9dbc88e0 /drivers/gpu/drm/msm/msm_gem.c | |
parent | drm/msm: Count how many times iova memory is pinned (diff) | |
download | linux-0815d7749a68527adabe2ac40d49f6fc0800eae5.tar.xz linux-0815d7749a68527adabe2ac40d49f6fc0800eae5.zip |
drm/msm: Add a name field for gem objects
For debugging purposes it is useful to assign descriptions
to buffers so that we know what they are used for. Add
a field to the buffer object and use that to name the various
kernel side allocations which ends up looking like like this
in /d/dri/X/gem:
flags id ref offset kaddr size madv name
00040000: I 0 ( 1) 00000000 0000000070b79eca 00004096 memptrs
vmas: [gpu: 01000000,mapped,inuse=1]
00020000: I 0 ( 1) 00000000 0000000031ed4074 00032768 ring0
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/msm/msm_gem.c')
-rw-r--r-- | drivers/gpu/drm/msm/msm_gem.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 3d46d931ba67..ee44b0f01e90 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -491,7 +491,7 @@ int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev, args->pitch = align_pitch(args->width, args->bpp); args->size = PAGE_ALIGN(args->pitch * args->height); return msm_gem_new_handle(dev, file, args->size, - MSM_BO_SCANOUT | MSM_BO_WC, &args->handle); + MSM_BO_SCANOUT | MSM_BO_WC, &args->handle, "dumb"); } int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev, @@ -794,7 +794,7 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m) obj->name, kref_read(&obj->refcount), off, msm_obj->vaddr); - seq_printf(m, " %08zu%9s\n", obj->size, madv); + seq_printf(m, " %08zu %9s %-32s\n", obj->size, madv, msm_obj->name); if (!list_empty(&msm_obj->vmas)) { @@ -833,7 +833,7 @@ void msm_gem_describe_objects(struct list_head *list, struct seq_file *m) int count = 0; size_t size = 0; - seq_puts(m, " flags id ref offset kaddr size madv\n"); + seq_puts(m, " flags id ref offset kaddr size madv name\n"); list_for_each_entry(msm_obj, list, mm_list) { struct drm_gem_object *obj = &msm_obj->base; seq_puts(m, " "); @@ -890,7 +890,8 @@ void msm_gem_free_object(struct drm_gem_object *obj) /* convenience method to construct a GEM buffer object, and userspace handle */ int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file, - uint32_t size, uint32_t flags, uint32_t *handle) + uint32_t size, uint32_t flags, uint32_t *handle, + char *name) { struct drm_gem_object *obj; int ret; @@ -900,6 +901,9 @@ int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file, if (IS_ERR(obj)) return PTR_ERR(obj); + if (name) + msm_gem_object_set_name(obj, "%s", name); + ret = drm_gem_handle_create(file, obj, handle); /* drop reference from allocate - handle holds it now */ @@ -1153,3 +1157,16 @@ void msm_gem_kernel_put(struct drm_gem_object *bo, else drm_gem_object_put_unlocked(bo); } + +void msm_gem_object_set_name(struct drm_gem_object *bo, const char *fmt, ...) +{ + struct msm_gem_object *msm_obj = to_msm_bo(bo); + va_list ap; + + if (!fmt) + return; + + va_start(ap, fmt); + vsnprintf(msm_obj->name, sizeof(msm_obj->name), fmt, ap); + va_end(ap); +} |