diff options
author | Christian König <christian.koenig@amd.com> | 2016-02-15 09:23:00 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-02-16 17:45:32 -0500 |
commit | 7ea235653328644b5ba8707e65484446a118e193 (patch) | |
tree | c1c7a7616f341038f10a47b80f2e85314708f491 /drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | |
parent | ebb36d19a0f71b246df9a15590e3b34256b0f1d8 (diff) |
drm/amdgpu: rework GEM info printing
Print BOs grouped per client.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 94 |
1 files changed, 61 insertions, 33 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index fae8bf7fcf1a..0a80febbc1b2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | |||
@@ -83,7 +83,6 @@ retry: | |||
83 | return r; | 83 | return r; |
84 | } | 84 | } |
85 | *obj = &robj->gem_base; | 85 | *obj = &robj->gem_base; |
86 | robj->pid = task_pid_nr(current); | ||
87 | 86 | ||
88 | mutex_lock(&adev->gem.mutex); | 87 | mutex_lock(&adev->gem.mutex); |
89 | list_add_tail(&robj->list, &adev->gem.objects); | 88 | list_add_tail(&robj->list, &adev->gem.objects); |
@@ -694,44 +693,73 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv, | |||
694 | } | 693 | } |
695 | 694 | ||
696 | #if defined(CONFIG_DEBUG_FS) | 695 | #if defined(CONFIG_DEBUG_FS) |
696 | static int amdgpu_debugfs_gem_bo_info(int id, void *ptr, void *data) | ||
697 | { | ||
698 | struct drm_gem_object *gobj = ptr; | ||
699 | struct amdgpu_bo *bo = gem_to_amdgpu_bo(gobj); | ||
700 | struct seq_file *m = data; | ||
701 | |||
702 | unsigned domain; | ||
703 | const char *placement; | ||
704 | unsigned pin_count; | ||
705 | |||
706 | domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); | ||
707 | switch (domain) { | ||
708 | case AMDGPU_GEM_DOMAIN_VRAM: | ||
709 | placement = "VRAM"; | ||
710 | break; | ||
711 | case AMDGPU_GEM_DOMAIN_GTT: | ||
712 | placement = " GTT"; | ||
713 | break; | ||
714 | case AMDGPU_GEM_DOMAIN_CPU: | ||
715 | default: | ||
716 | placement = " CPU"; | ||
717 | break; | ||
718 | } | ||
719 | seq_printf(m, "\t0x%08x: %12ld byte %s @ 0x%010Lx", | ||
720 | id, amdgpu_bo_size(bo), placement, | ||
721 | amdgpu_bo_gpu_offset(bo)); | ||
722 | |||
723 | pin_count = ACCESS_ONCE(bo->pin_count); | ||
724 | if (pin_count) | ||
725 | seq_printf(m, " pin count %d", pin_count); | ||
726 | seq_printf(m, "\n"); | ||
727 | |||
728 | return 0; | ||
729 | } | ||
730 | |||
697 | static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data) | 731 | static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data) |
698 | { | 732 | { |
699 | struct drm_info_node *node = (struct drm_info_node *)m->private; | 733 | struct drm_info_node *node = (struct drm_info_node *)m->private; |
700 | struct drm_device *dev = node->minor->dev; | 734 | struct drm_device *dev = node->minor->dev; |
701 | struct amdgpu_device *adev = dev->dev_private; | 735 | struct drm_file *file; |
702 | struct amdgpu_bo *rbo; | 736 | int r; |
703 | unsigned i = 0; | ||
704 | 737 | ||
705 | mutex_lock(&adev->gem.mutex); | 738 | r = mutex_lock_interruptible(&dev->struct_mutex); |
706 | list_for_each_entry(rbo, &adev->gem.objects, list) { | 739 | if (r) |
707 | unsigned pin_count; | 740 | return r; |
708 | unsigned domain; | 741 | |
709 | const char *placement; | 742 | list_for_each_entry(file, &dev->filelist, lhead) { |
710 | 743 | struct task_struct *task; | |
711 | domain = amdgpu_mem_type_to_domain(rbo->tbo.mem.mem_type); | 744 | |
712 | switch (domain) { | 745 | /* |
713 | case AMDGPU_GEM_DOMAIN_VRAM: | 746 | * Although we have a valid reference on file->pid, that does |
714 | placement = "VRAM"; | 747 | * not guarantee that the task_struct who called get_pid() is |
715 | break; | 748 | * still alive (e.g. get_pid(current) => fork() => exit()). |
716 | case AMDGPU_GEM_DOMAIN_GTT: | 749 | * Therefore, we need to protect this ->comm access using RCU. |
717 | placement = " GTT"; | 750 | */ |
718 | break; | 751 | rcu_read_lock(); |
719 | case AMDGPU_GEM_DOMAIN_CPU: | 752 | task = pid_task(file->pid, PIDTYPE_PID); |
720 | default: | 753 | seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid), |
721 | placement = " CPU"; | 754 | task ? task->comm : "<unknown>"); |
722 | break; | 755 | rcu_read_unlock(); |
723 | } | 756 | |
724 | seq_printf(m, "bo[0x%08x] %12ld %s @ 0x%010Lx pid %8d", | 757 | spin_lock(&file->table_lock); |
725 | i, amdgpu_bo_size(rbo), placement, | 758 | idr_for_each(&file->object_idr, amdgpu_debugfs_gem_bo_info, m); |
726 | amdgpu_bo_gpu_offset(rbo), rbo->pid); | 759 | spin_unlock(&file->table_lock); |
727 | |||
728 | pin_count = ACCESS_ONCE(rbo->pin_count); | ||
729 | if (pin_count) | ||
730 | seq_printf(m, " pin count %d", pin_count); | ||
731 | seq_printf(m, "\n"); | ||
732 | i++; | ||
733 | } | 760 | } |
734 | mutex_unlock(&adev->gem.mutex); | 761 | |
762 | mutex_unlock(&dev->struct_mutex); | ||
735 | return 0; | 763 | return 0; |
736 | } | 764 | } |
737 | 765 | ||