drm/ttm: make ttm_mem_type_manager_func debug more useful
authorChristian König <christian.koenig@amd.com>
Mon, 7 Aug 2017 09:13:41 +0000 (11:13 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 17 Aug 2017 19:45:59 +0000 (15:45 -0400)
Provide the drm printer directly instead of just the callback.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
drivers/gpu/drm/nouveau/nouveau_ttm.c
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_bo_manager.c
drivers/gpu/drm/virtio/virtgpu_ttm.c
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
include/drm/ttm/ttm_bo_driver.h

index 5e6b90c6794f47317f25ab4e4f1142bacd58a06d..26818b0a0cc86a2612ad122bf265f43856ee113a 100644 (file)
@@ -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);
 }
 
index a2c59a08b2bd69919b23989feddff71a88855617..3f86b47984a088eccd9f2b9f53cc24788d53ade6 100644 (file)
@@ -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);
 }
 
index 999c35a25498f891be3d329ad2342484154f2d2a..b0ad7fcefcf5b6134fbd4d40c80b28cbf82976e5 100644 (file)
@@ -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)
 {
 }
 
index d3463ebc0b25cf22b421cbd0e62a7df46b7311d4..58e7fcea620e402d60a8df6b83adf676e04828a6 100644 (file)
@@ -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,
index 90a6c0b03afc522a64fd9c79e173981017b64f1d..a7c232dc39cba9bcbbd3ddd9c6d16957fa12cd8b 100644 (file)
@@ -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);
 }
 
index e695d74eaa9f08761eccf88ca3df2246f8c398c9..cd389c5eaef5b74aefd052bdaddc11a27b6d8f31 100644 (file)
@@ -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)
 {
 }
 
index d2b03d4a3c867d11a0167f3ff7ba85b246289b88..f2f9d88131f25ad37d0c018940627630030a4c26 100644 (file)
@@ -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 = {
index d30850e079361e6f2fa049e5c26e298a77769a89..5f821a9b3a1fa8110186c964a706805714a33966 100644 (file)
@@ -229,13 +229,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);
 };
 
 /**