drm/ttm: make ttm_mem_type_manager_func debug more usfull
Subsystems (8)
PATCH 1/7 drm/ttm: make ttm_mem_type_manager_func debug more usfull
From: Christian König <[email protected]>
Provide the drm printer directly instead of just the callback.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 7 +++---- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 7 +++---- drivers/gpu/drm/nouveau/nouveau_ttm.c | 6 ++++-- drivers/gpu/drm/ttm/ttm_bo.c | 3 ++- drivers/gpu/drm/ttm/ttm_bo_manager.c | 5 ++--- drivers/gpu/drm/virtio/virtgpu_ttm.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 4 ++-- include/drm/ttm/ttm_bo_driver.h | 5 +++-- 8 files changed, 20 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +3 -4
@@ -253,18 +253,17 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,* amdgpu_gtt_mgr_debug - dump VRAM table * * @man: TTM memory type manager -* @prefix: text prefix +* @printer: DRM printer to use * * Dump the table content using printk. */ static void amdgpu_gtt_mgr_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) {struct amdgpu_gtt_mgr *mgr = man->priv; -struct drm_printer p =drm_debug_printer (prefix);spin_lock (&mgr->lock); -drm_mm_print (&mgr->mm, &p); +drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); }
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +3 -4
@@ -204,18 +204,17 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,* amdgpu_vram_mgr_debug - dump VRAM table * * @man: TTM memory type manager -* @prefix: text prefix +* @printer: DRM printer to use * * Dump the table content using printk. */ static void amdgpu_vram_mgr_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) {struct amdgpu_vram_mgr *mgr = man->priv; -struct drm_printer p =drm_debug_printer (prefix);spin_lock (&mgr->lock); -drm_mm_print (&mgr->mm, &p); +drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); }
drivers/gpu/drm/nouveau/nouveau_ttm.c +4 -2
@@ -179,7 +179,8 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, }static void -nouveau_gart_manager_debug (struct ttm_mem_type_manager *man,const char *prefix) +nouveau_gart_manager_debug (struct ttm_mem_type_manager *man, +struct drm_printer *printer) { }
@@ -252,7 +253,8 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man, }static void -nv04_gart_manager_debug (struct ttm_mem_type_manager *man,const char *prefix) +nv04_gart_manager_debug (struct ttm_mem_type_manager *man, +struct drm_printer *printer) { }
drivers/gpu/drm/ttm/ttm_bo.c +2 -1
@@ -70,6 +70,7 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,static void ttm_mem_type_debug (struct ttm_bo_device *bdev,int mem_type) {struct ttm_mem_type_manager *man = &bdev->man[mem_type]; +struct drm_printer p =drm_debug_printer (TTM_PFX );pr_err (" has_type: %d\n" , man->has_type);pr_err (" use_type: %d\n" , man->use_type);
@@ -79,7 +80,7 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type)pr_err (" available_caching: 0x%08X\n" , man->available_caching);pr_err (" default_caching: 0x%08X\n" , man->default_caching);if (mem_type !=TTM_PL_SYSTEM ) - (*man->func->debug)(man,TTM_PFX ); + (*man->func->debug)(man, &p); } static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
drivers/gpu/drm/ttm/ttm_bo_manager.c +2 -3
@@ -136,13 +136,12 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) }static void ttm_bo_man_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) {struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; -struct drm_printer p =drm_debug_printer (prefix);spin_lock (&rman->lock); -drm_mm_print (&rman->mm, &p); +drm_mm_print (&rman->mm, printer);spin_unlock (&rman->lock); }
drivers/gpu/drm/virtio/virtgpu_ttm.c +1 -1
@@ -192,7 +192,7 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) }static void ttm_bo_man_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) { }
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +2 -2
@@ -157,9 +157,9 @@ static int vmw_gmrid_man_takedown(struct ttm_mem_type_manager *man) }static void vmw_gmrid_man_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) { -pr_info ("%s: No debug info available for the GMR id manager\n" , prefix); +drm_printf (printer,"No debug info available for the GMR id manager\n" ); }const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
include/drm/ttm/ttm_bo_driver.h +3 -2
@@ -228,13 +228,14 @@ struct ttm_mem_type_manager_func {* struct ttm_mem_type_manager member debug * * @man: Pointer to a memory type manager. -* @prefix: Prefix to be used in printout to identify the caller. +* @printer: Prefix to be used in printout to identify the caller. * * This function is called to print out the state of the memory * type manager to aid debugging of out-of-memory conditions. * It may not be called from within atomic context. */ -void (*debug)(struct ttm_mem_type_manager *man,const char *prefix); +void (*debug)(struct ttm_mem_type_manager *man, +struct drm_printer *printer); };/**
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1502120903-24080-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
PATCH 2/7 drm/qxl: fix incorrect use of the lru_lock
From: Christian König <[email protected]>
The BO manager has its own lock and doesn't use the lru_lock.
--- drivers/gpu/drm/qxl/qxl_ttm.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/qxl/qxl_ttm.c +4 -9
@@ -454,15 +454,10 @@ void qxl_ttm_fini(struct qxl_device *qdev)static int qxl_mm_dump_table (struct seq_file *m,void *data) {struct drm_info_node *node = (struct drm_info_node *)m->private; -struct drm_mm *mm = (struct drm_mm *)node->info_ent->data; -struct drm_device *dev = node->minor->dev; -struct qxl_device *rdev = dev->dev_private; -struct ttm_bo_global *glob = rdev->mman.bdev.glob; +struct ttm_mem_type_manager *man = node->info_ent->data;struct drm_printer p =drm_seq_file_printer (m); -spin_lock (&glob->lru_lock); -drm_mm_print (mm, &p); -spin_unlock (&glob->lru_lock); + man->func->debug (man, &p);return 0 ; }#endif
@@ -483,9 +478,9 @@ int qxl_ttm_debugfs_init(struct qxl_device *qdev) qxl_mem_types_list[i].show = &qxl_mm_dump_table; qxl_mem_types_list[i].driver_features =0 ;if (i ==0 ) - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM ].priv; + qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_VRAM ];else - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV ].priv; + qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_PRIV ]; }return qxl_debugfs_add_files (qdev, qxl_mem_types_list, i);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/7] drm/qxl: fix incorrect use of the lru_lock
Hi guys,
can I get an rb or at least an Acked-by for that one?
The code was obviously copied over from radeon where it wasn't correct in the first place.
Thanks,
Christian.
Am 07.08.2017 um 17:48 schrieb Christian König:
Quoted 33 lines
From: Christian König <[email protected]>
The BO manager has its own lock and doesn't use the
lru_lock.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/qxl/qxl_ttm.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)drivers/gpu/drm/qxl/qxl_ttm.c +2
-7@@ -454,15 +454,10 @@ void qxl_ttm_fini(struct qxl_device *qdev)static int qxl_mm_dump_table (struct seq_file *m,void *data) {struct drm_info_node *node = (struct drm_info_node *)m->private; -struct drm_mm *mm = (struct drm_mm *)node->info_ent->data; -struct drm_device *dev = node->minor->dev; -struct qxl_device *rdev = dev->dev_private; -struct ttm_bo_global *glob = rdev->mman.bdev.glob; +struct ttm_mem_type_manager *man = node->info_ent->data;struct drm_printer p =drm_seq_file_printer (m); -spin_lock (&glob->lru_lock); -drm_mm_print (mm, &p); -spin_unlock (&glob->lru_lock); + man->func->debug (man, &p);return 0 ; }#endif @@ -483,9 +478,9 @@ int qxl_ttm_debugfs_init(struct qxl_device *qdev) qxl_mem_types_list[i].show = &qxl_mm_dump_table;
drivers/gpu/drm/qxl/qxl_ttm.c int qxl_ttm_debugfs_init(struct qxl_device *qdev) · line 486
Quoted 10 lines
drivers/gpu/drm/qxl/qxl_ttm.c +2
-2qxl_mem_types_list[i].driver_features =0 ;if (i ==0 ) - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM ].priv; + qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_VRAM ];else - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV ].priv; + qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_PRIV ]; }return qxl_debugfs_add_files (qdev, qxl_mem_types_list, i);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): cddfe54f-2234-5427-f69d-7c379b6b8264-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 2/7] drm/qxl: fix incorrect use of the lru_lock
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]>
Sent: Tuesday, August 8, 2017 4:14:46 PM
To: [email protected]; [email protected]; Dave Airlie; Gerd Hoffmann
Subject: Re: [PATCH 2/7] drm/qxl: fix incorrect use of the lru_lock
Hi guys,
can I get an rb or at least an Acked-by for that one?
The code was obviously copied over from radeon where it wasn't correct in the first place.
Thanks,
Christian.
Am 07.08.2017 um 17:48 schrieb Christian König:
Quoted 33 lines
From: Christian König <[email protected]>
The BO manager has its own lock and doesn't use the
lru_lock.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/qxl/qxl_ttm.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)drivers/gpu/drm/qxl/qxl_ttm.c +2
-7@@ -454,15 +454,10 @@ void qxl_ttm_fini(struct qxl_device *qdev)static int qxl_mm_dump_table (struct seq_file *m,void *data) {struct drm_info_node *node = (struct drm_info_node *)m->private; -struct drm_mm *mm = (struct drm_mm *)node->info_ent->data; -struct drm_device *dev = node->minor->dev; -struct qxl_device *rdev = dev->dev_private; -struct ttm_bo_global *glob = rdev->mman.bdev.glob; +struct ttm_mem_type_manager *man = node->info_ent->data;struct drm_printer p =drm_seq_file_printer (m); -spin_lock (&glob->lru_lock); -drm_mm_print (mm, &p); -spin_unlock (&glob->lru_lock); + man->func->debug (man, &p);return 0 ; }#endif @@ -483,9 +478,9 @@ int qxl_ttm_debugfs_init(struct qxl_device *qdev) qxl_mem_types_list[i].show = &qxl_mm_dump_table;
drivers/gpu/drm/qxl/qxl_ttm.c int qxl_ttm_debugfs_init(struct qxl_device *qdev) · line 486
Quoted 10 lines
drivers/gpu/drm/qxl/qxl_ttm.c +2
-2qxl_mem_types_list[i].driver_features =0 ;if (i ==0 ) - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM ].priv; + qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_VRAM ];else - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV ].priv; + qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_PRIV ]; }return qxl_debugfs_add_files (qdev, qxl_mem_types_list, i);
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/7 drm/radeon: fix incorrect use of the lru_lock
In reply to a message not in the archiveFrom: Christian König <[email protected]>
The BO manager has its own lock and doesn't use the lru_lock.
--- drivers/gpu/drm/radeon/radeon_ttm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +4 -6
@@ -1030,19 +1030,17 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)static int radeon_mm_dump_table (struct seq_file *m,void *data) {struct drm_info_node *node = (struct drm_info_node *)m->private; -unsigned ttm_pl = *(int *)node->info_ent->data; +unsigned ttm_pl = *(int *)node->info_ent->data;struct drm_device *dev = node->minor->dev;struct radeon_device *rdev = dev->dev_private; -struct drm_mm *mm = (struct drm_mm *)rdev->mman.bdev.man[ttm_pl].priv; -struct ttm_bo_global *glob = rdev->mman.bdev.glob; +struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[ttm_pl];struct drm_printer p =drm_seq_file_printer (m); -spin_lock (&glob->lru_lock); -drm_mm_print (mm, &p); -spin_unlock (&glob->lru_lock); + man->func->debug (man, &p);return 0 ; } +static int ttm_pl_vram =TTM_PL_VRAM ;static int ttm_pl_tt =TTM_PL_TT ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/7 drm/amdgpu: fix incorrect use of the lru_lock
In reply to a message not in the archiveFrom: Christian König <[email protected]>
The BO manager has its own lock and doesn't use the lru_lock.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -5
@@ -1605,13 +1605,10 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *data)unsigned ttm_pl = *(int *)node->info_ent->data;struct drm_device *dev = node->minor->dev;struct amdgpu_device *adev = dev->dev_private; -struct drm_mm *mm = (struct drm_mm *)adev->mman.bdev.man[ttm_pl].priv; -struct ttm_bo_global *glob = adev->mman.bdev.glob; +struct ttm_mem_type_manager *man = &adev->mman.bdev.man[ttm_pl];struct drm_printer p =drm_seq_file_printer (m); -spin_lock (&glob->lru_lock); -drm_mm_print (mm, &p); -spin_unlock (&glob->lru_lock); + man->func->debug (man, &p);switch (ttm_pl) {case TTM_PL_VRAM : seq_printf(m, "man size:%llu pages, ram usage:%lluMB, vis usage:%lluMB\n",
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/7 drm/amdgpu: move debug print into the MM managers
In reply to a message not in the archiveFrom: Christian König <[email protected]>
Instead of the separate switch/case in the calling function.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 14 +++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 ------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 6 ++++++ 3 files changed, 11 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +5 -9
@@ -153,15 +153,6 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,return r; } -void amdgpu_gtt_mgr_print (struct seq_file *m,struct ttm_mem_type_manager *man) -{ -struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev); -struct amdgpu_gtt_mgr *mgr = man->priv; - -seq_printf (m,"man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n" , - man->size, mgr->available, (u64 )atomic64_read (&adev->gtt_usage) >>20 ); - -}/** * amdgpu_gtt_mgr_new - allocate a new node *
@@ -260,11 +251,16 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,static void amdgpu_gtt_mgr_debug (struct ttm_mem_type_manager *man,struct drm_printer *printer) { +struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev);struct amdgpu_gtt_mgr *mgr = man->priv;spin_lock (&mgr->lock);drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); + +drm_printf (printer,"man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n" , + man->size, mgr->available, + (u64 )atomic64_read (&adev->gtt_usage) >>20 ); }const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = {
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -13
@@ -1597,8 +1597,6 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,#if defined(CONFIG_DEBUG_FS ) -extern void amdgpu_gtt_mgr_print (struct seq_file *m,struct ttm_mem_type_manager - *man);static int amdgpu_mm_dump_table (struct seq_file *m,void *data) {struct drm_info_node *node = (struct drm_info_node *)m->private;
@@ -1609,17 +1607,6 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *data)struct drm_printer p =drm_seq_file_printer (m); man->func->debug (man, &p); -switch (ttm_pl) { -case TTM_PL_VRAM : -seq_printf (m,"man size:%llu pages, ram usage:%lluMB, vis usage:%lluMB\n" , - adev->mman.bdev.man[ttm_pl].size, - (u64 )atomic64_read (&adev->vram_usage) >>20 , - (u64 )atomic64_read (&adev->vram_vis_usage) >>20 ); -break ; -case TTM_PL_TT : -amdgpu_gtt_mgr_print (m, &adev->mman.bdev.man[TTM_PL_TT ]); -break ; - }return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +6 -0
@@ -211,11 +211,17 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,static void amdgpu_vram_mgr_debug (struct ttm_mem_type_manager *man,struct drm_printer *printer) { +struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev);struct amdgpu_vram_mgr *mgr = man->priv;spin_lock (&mgr->lock);drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); + +drm_printf (printer,"man size:%llu pages, ram usage:%lluMB, vis usage:%lluMB\n" , + adev->mman.bdev.man[TTM_PL_VRAM ].size, + (u64 )atomic64_read (&adev->vram_usage) >>20 , + (u64 )atomic64_read (&adev->vram_vis_usage) >>20 ); }const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = {
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/7 drm/amdgpu: move gtt usage tracking into the gtt manager
In reply to a message not in the archiveFrom: Christian König <[email protected]>
It doesn't make much sense to count those numbers twice.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 18 +++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 5 +++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 1 + 5 files changed, 19 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
@@ -1486,7 +1486,6 @@ struct amdgpu_device {struct amdgpu_wb wb;atomic64_t vram_usage;atomic64_t vram_vis_usage; -atomic64_t gtt_usage;atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic64_t num_vram_cpu_page_faults;
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +15 -3
@@ -241,6 +241,20 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man, }/** +* amdgpu_gtt_mgr_usage - return usage of GTT domain +* +* @man: TTM memory type manager +* +* Return how many bytes are used in the GTT domain +*/ +uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man) +{ +struct amdgpu_gtt_mgr *mgr = man->priv; + +return (u64)(man->size -READ_ONCE (mgr->available)) *PAGE_SIZE ; +} + +/** * amdgpu_gtt_mgr_debug - dump VRAM table * * @man: TTM memory type manager
@@ -251,7 +265,6 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,static void amdgpu_gtt_mgr_debug (struct ttm_mem_type_manager *man,struct drm_printer *printer) { -struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev);struct amdgpu_gtt_mgr *mgr = man->priv;spin_lock (&mgr->lock);
@@ -259,8 +272,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,spin_unlock (&mgr->lock);drm_printf (printer,"man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n" , - man->size, mgr->available, - (u64 )atomic64_read (&adev->gtt_usage) >>20 ); + man->size, mgr->available,amdgpu_gtt_mgr_usage (man) >>20 ); }const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = {
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -2
@@ -461,7 +461,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file ui64 =atomic64_read (&adev->vram_vis_usage);return copy_to_user (out, &ui64,min (size,8u )) ? -EFAULT :0 ;case AMDGPU_INFO_GTT_USAGE : - ui64 =atomic64_read (&adev->gtt_usage); + ui64 =amdgpu_gtt_mgr_usage (&adev->mman.bdev.man[TTM_PL_TT ]);return copy_to_user (out, &ui64,min (size,8u )) ? -EFAULT :0 ;case AMDGPU_INFO_GDS_CONFIG : {struct drm_amdgpu_info_gds gds_info;
@@ -514,7 +514,8 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file mem.gtt.total_heap_size *=PAGE_SIZE ; mem.gtt.usable_heap_size = mem.gtt.total_heap_size - adev->gart_pin_size; - mem.gtt.heap_usage =atomic64_read (&adev->gtt_usage); + mem.gtt.heap_usage = +amdgpu_gtt_mgr_usage (&adev->mman.bdev.man[TTM_PL_TT ]); mem.gtt.max_allocation = mem.gtt.usable_heap_size *3 /4 ; return copy_to_user(out, &mem,
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -2
@@ -62,7 +62,6 @@ static void amdgpu_update_memory_usage(struct amdgpu_device *adev,if (new_mem) {switch (new_mem->mem_type) {case TTM_PL_TT : -atomic64_add (new_mem->size, &adev->gtt_usage);break ;case TTM_PL_VRAM :atomic64_add (new_mem->size, &adev->vram_usage);
@@ -75,7 +74,6 @@ static void amdgpu_update_memory_usage(struct amdgpu_device *adev,if (old_mem) {switch (old_mem->mem_type) {case TTM_PL_TT : -atomic64_sub (old_mem->size, &adev->gtt_usage);break ;case TTM_PL_VRAM :atomic64_sub (old_mem->size, &adev->vram_usage);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -0
@@ -66,6 +66,7 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,struct ttm_buffer_object *tbo, const struct ttm_place *place, struct ttm_mem_reg *mem); +uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man); int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset, uint64_t dst_offset, uint32_t byte_count,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/7 drm/amdgpu: move vram usage tracking into the vram manager
In reply to a message not in the archiveFrom: Christian König <[email protected]>
Looks like a better place for this.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 - drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 9 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 50 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 64 ++++++++++++++++++++++++++-- 6 files changed, 71 insertions(+), 62 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -2
@@ -1484,8 +1484,6 @@ struct amdgpu_device {struct amdgpu_mman mman;struct amdgpu_vram_scratch vram_scratch;struct amdgpu_wb wb; -atomic64_t vram_usage; -atomic64_t vram_vis_usage;atomic64_t num_bytes_moved;atomic64_t num_evictions;atomic64_t num_vram_cpu_page_faults;
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +3 -2
@@ -243,7 +243,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev, } total_vram = adev->mc.real_vram_size - adev->vram_pin_size; - used_vram =atomic64_read (&adev->vram_usage); + used_vram =amdgpu_vram_mgr_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]); free_vram = used_vram >= total_vram ?0 : total_vram - used_vram;spin_lock (&adev->mm_stats.lock);
@@ -289,7 +289,8 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,/* Do the same for visible VRAM if half of it is free */ if (adev->mc.visible_vram_size < adev->mc.real_vram_size) {u64 total_vis_vram = adev->mc.visible_vram_size; -u64 used_vis_vram =atomic64_read (&adev->vram_vis_usage); +u64 used_vis_vram = +amdgpu_vram_mgr_vis_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]);if (used_vis_vram < total_vis_vram) {u64 free_vis_vram = total_vis_vram - used_vis_vram;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5 -4
@@ -455,10 +455,10 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file ui64 =atomic64_read (&adev->num_vram_cpu_page_faults);return copy_to_user (out, &ui64,min (size,8u )) ? -EFAULT :0 ;case AMDGPU_INFO_VRAM_USAGE : - ui64 =atomic64_read (&adev->vram_usage); + ui64 =amdgpu_vram_mgr_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]);return copy_to_user (out, &ui64,min (size,8u )) ? -EFAULT :0 ;case AMDGPU_INFO_VIS_VRAM_USAGE : - ui64 =atomic64_read (&adev->vram_vis_usage); + ui64 =amdgpu_vram_mgr_vis_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]);return copy_to_user (out, &ui64,min (size,8u )) ? -EFAULT :0 ;case AMDGPU_INFO_GTT_USAGE : ui64 =amdgpu_gtt_mgr_usage (&adev->mman.bdev.man[TTM_PL_TT ]);
@@ -497,7 +497,8 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file mem.vram.total_heap_size = adev->mc.real_vram_size; mem.vram.usable_heap_size = adev->mc.real_vram_size - adev->vram_pin_size; - mem.vram.heap_usage =atomic64_read (&adev->vram_usage); + mem.vram.heap_usage = +amdgpu_vram_mgr_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]); mem.vram.max_allocation = mem.vram.usable_heap_size *3 /4 ; mem.cpu_accessible_vram.total_heap_size =
@@ -506,7 +507,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file adev->mc.visible_vram_size - (adev->vram_pin_size - adev->invisible_pin_size); mem.cpu_accessible_vram.heap_usage = -atomic64_read (&adev->vram_vis_usage); +amdgpu_vram_mgr_vis_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]); mem.cpu_accessible_vram.max_allocation = mem.cpu_accessible_vram.usable_heap_size *3 /4 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -50
68 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3 -0
@@ -68,6 +68,9 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem);uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man); +uint64_t amdgpu_vram_mgr_usage (struct ttm_mem_type_manager *man); +uint64_t amdgpu_vram_mgr_vis_usage (struct ttm_mem_type_manager *man); + int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset, uint64_t dst_offset, uint32_t byte_count, struct reservation_object *resv,
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +60 -4
118 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Somehow those two patches didn't ended up on dri-devel.
So forwarding manually,
Christian.
Am 07.08.2017 um 17:48 schrieb Christian König:
Quoted 173 lines
From: Christian König <[email protected]>
Provide the drm printer directly instead of just the callback.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 7 +++---- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 7 +++---- drivers/gpu/drm/nouveau/nouveau_ttm.c | 6 ++++-- drivers/gpu/drm/ttm/ttm_bo.c | 3 ++- drivers/gpu/drm/ttm/ttm_bo_manager.c | 5 ++--- drivers/gpu/drm/virtio/virtgpu_ttm.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 4 ++-- include/drm/ttm/ttm_bo_driver.h | 5 +++-- 8 files changed, 20 insertions(+), 19 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +3
-4@@ -253,18 +253,17 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,* amdgpu_gtt_mgr_debug - dump VRAM table * * @man: TTM memory type manager -* @prefix: text prefix +* @printer: DRM printer to use * * Dump the table content using printk. */ static void amdgpu_gtt_mgr_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) {struct amdgpu_gtt_mgr *mgr = man->priv; -struct drm_printer p =drm_debug_printer (prefix);spin_lock (&mgr->lock); -drm_mm_print (&mgr->mm, &p); +drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); }drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +3
-4@@ -204,18 +204,17 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,* amdgpu_vram_mgr_debug - dump VRAM table * * @man: TTM memory type manager -* @prefix: text prefix +* @printer: DRM printer to use * * Dump the table content using printk. */ static void amdgpu_vram_mgr_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) {struct amdgpu_vram_mgr *mgr = man->priv; -struct drm_printer p =drm_debug_printer (prefix);spin_lock (&mgr->lock); -drm_mm_print (&mgr->mm, &p); +drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); }drivers/gpu/drm/nouveau/nouveau_ttm.c +4
-2@@ -179,7 +179,8 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, }static void -nouveau_gart_manager_debug (struct ttm_mem_type_manager *man,const char *prefix) +nouveau_gart_manager_debug (struct ttm_mem_type_manager *man, +struct drm_printer *printer) { }@@ -252,7 +253,8 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man, }static void -nv04_gart_manager_debug (struct ttm_mem_type_manager *man,const char *prefix) +nv04_gart_manager_debug (struct ttm_mem_type_manager *man, +struct drm_printer *printer) { }drivers/gpu/drm/ttm/ttm_bo.c +2
-1@@ -70,6 +70,7 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,static void ttm_mem_type_debug (struct ttm_bo_device *bdev,int mem_type) {struct ttm_mem_type_manager *man = &bdev->man[mem_type]; +struct drm_printer p =drm_debug_printer (TTM_PFX );pr_err (" has_type: %d\n" , man->has_type);pr_err (" use_type: %d\n" , man->use_type);@@ -79,7 +80,7 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type)pr_err (" available_caching: 0x%08X\n" , man->available_caching);pr_err (" default_caching: 0x%08X\n" , man->default_caching);if (mem_type !=TTM_PL_SYSTEM ) - (*man->func->debug)(man,TTM_PFX ); + (*man->func->debug)(man, &p); } static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,drivers/gpu/drm/ttm/ttm_bo_manager.c +2
-3@@ -136,13 +136,12 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) }static void ttm_bo_man_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) {struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; -struct drm_printer p =drm_debug_printer (prefix);spin_lock (&rman->lock); -drm_mm_print (&rman->mm, &p); +drm_mm_print (&rman->mm, printer);spin_unlock (&rman->lock); }drivers/gpu/drm/virtio/virtgpu_ttm.c +1
-1@@ -192,7 +192,7 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) }static void ttm_bo_man_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) { }drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +2
-2@@ -157,9 +157,9 @@ static int vmw_gmrid_man_takedown(struct ttm_mem_type_manager *man) }static void vmw_gmrid_man_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) { -pr_info ("%s: No debug info available for the GMR id manager\n" , prefix); +drm_printf (printer,"No debug info available for the GMR id manager\n" ); }const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {include/drm/ttm/ttm_bo_driver.h +1
-1@@ -228,13 +228,14 @@ struct ttm_mem_type_manager_func {* struct ttm_mem_type_manager member debug * * @man: Pointer to a memory type manager. -* @prefix: Prefix to be used in printout to identify the caller. +* @printer: Prefix to be used in printout to identify the caller. *
include/drm/ttm/ttm_bo_driver.h struct ttm_mem_type_manager_func { · line 241
Quoted 10 lines
include/drm/ttm/ttm_bo_driver.h +2
-1* This function is called to print out the state of the memory * type manager to aid debugging of out-of-memory conditions. * It may not be called from within atomic context. */ -void (*debug)(struct ttm_mem_type_manager *man,const char *prefix); +void (*debug)(struct ttm_mem_type_manager *man, +struct drm_printer *printer); };/**
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Somehow those two patches didn't ended up on dri-devel.
So forwarding manually,
Christian.
Am 07.08.2017 um 17:48 schrieb Christian König:
Quoted 173 lines
From: Christian König <[email protected]>
Provide the drm printer directly instead of just the callback.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 7 +++---- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 7 +++---- drivers/gpu/drm/nouveau/nouveau_ttm.c | 6 ++++-- drivers/gpu/drm/ttm/ttm_bo.c | 3 ++- drivers/gpu/drm/ttm/ttm_bo_manager.c | 5 ++--- drivers/gpu/drm/virtio/virtgpu_ttm.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 4 ++-- include/drm/ttm/ttm_bo_driver.h | 5 +++-- 8 files changed, 20 insertions(+), 19 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +3
-4@@ -253,18 +253,17 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,* amdgpu_gtt_mgr_debug - dump VRAM table * * @man: TTM memory type manager -* @prefix: text prefix +* @printer: DRM printer to use * * Dump the table content using printk. */ static void amdgpu_gtt_mgr_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) {struct amdgpu_gtt_mgr *mgr = man->priv; -struct drm_printer p =drm_debug_printer (prefix);spin_lock (&mgr->lock); -drm_mm_print (&mgr->mm, &p); +drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); }drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +3
-4@@ -204,18 +204,17 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,* amdgpu_vram_mgr_debug - dump VRAM table * * @man: TTM memory type manager -* @prefix: text prefix +* @printer: DRM printer to use * * Dump the table content using printk. */ static void amdgpu_vram_mgr_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) {struct amdgpu_vram_mgr *mgr = man->priv; -struct drm_printer p =drm_debug_printer (prefix);spin_lock (&mgr->lock); -drm_mm_print (&mgr->mm, &p); +drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); }drivers/gpu/drm/nouveau/nouveau_ttm.c +4
-2@@ -179,7 +179,8 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, }static void -nouveau_gart_manager_debug (struct ttm_mem_type_manager *man,const char *prefix) +nouveau_gart_manager_debug (struct ttm_mem_type_manager *man, +struct drm_printer *printer) { }@@ -252,7 +253,8 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man, }static void -nv04_gart_manager_debug (struct ttm_mem_type_manager *man,const char *prefix) +nv04_gart_manager_debug (struct ttm_mem_type_manager *man, +struct drm_printer *printer) { }drivers/gpu/drm/ttm/ttm_bo.c +2
-1@@ -70,6 +70,7 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,static void ttm_mem_type_debug (struct ttm_bo_device *bdev,int mem_type) {struct ttm_mem_type_manager *man = &bdev->man[mem_type]; +struct drm_printer p =drm_debug_printer (TTM_PFX );pr_err (" has_type: %d\n" , man->has_type);pr_err (" use_type: %d\n" , man->use_type);@@ -79,7 +80,7 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type)pr_err (" available_caching: 0x%08X\n" , man->available_caching);pr_err (" default_caching: 0x%08X\n" , man->default_caching);if (mem_type !=TTM_PL_SYSTEM ) - (*man->func->debug)(man,TTM_PFX ); + (*man->func->debug)(man, &p); } static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,drivers/gpu/drm/ttm/ttm_bo_manager.c +2
-3@@ -136,13 +136,12 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) }static void ttm_bo_man_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) {struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; -struct drm_printer p =drm_debug_printer (prefix);spin_lock (&rman->lock); -drm_mm_print (&rman->mm, &p); +drm_mm_print (&rman->mm, printer);spin_unlock (&rman->lock); }drivers/gpu/drm/virtio/virtgpu_ttm.c +1
-1@@ -192,7 +192,7 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) }static void ttm_bo_man_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) { }drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +2
-2@@ -157,9 +157,9 @@ static int vmw_gmrid_man_takedown(struct ttm_mem_type_manager *man) }static void vmw_gmrid_man_debug (struct ttm_mem_type_manager *man, -const char *prefix) +struct drm_printer *printer) { -pr_info ("%s: No debug info available for the GMR id manager\n" , prefix); +drm_printf (printer,"No debug info available for the GMR id manager\n" ); }const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {include/drm/ttm/ttm_bo_driver.h +1
-1@@ -228,13 +228,14 @@ struct ttm_mem_type_manager_func {* struct ttm_mem_type_manager member debug * * @man: Pointer to a memory type manager. -* @prefix: Prefix to be used in printout to identify the caller. +* @printer: Prefix to be used in printout to identify the caller. *
include/drm/ttm/ttm_bo_driver.h struct ttm_mem_type_manager_func { · line 241
Quoted 10 lines
include/drm/ttm/ttm_bo_driver.h +2
-1* This function is called to print out the state of the memory * type manager to aid debugging of out-of-memory conditions. * It may not be called from within atomic context. */ -void (*debug)(struct ttm_mem_type_manager *man,const char *prefix); +void (*debug)(struct ttm_mem_type_manager *man, +struct drm_printer *printer); };/**
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel