Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5c3714f authored by Daniel Vetter's avatar Daniel Vetter
Browse files

drm/mm: Convert to drm_printer



Including all drivers. I thought about keeping small compat functions
to avoid having to change all drivers. But I really like the
drm_printer idea, so figured spreading it more widely is a good thing.

v2: Review from Chris:
- Natural argument order and better name for drm_mm_print.
- show_mm() macro in the selftest.

Cc: Rob Clark <robdclark@gmail.com>
Cc: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jyri Sarha <jsarha@ti.com>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483009764-8281-1-git-send-email-daniel.vetter@ffwll.ch
parent 3d387d92
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -235,9 +235,10 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,
				  const char *prefix)
{
	struct amdgpu_gtt_mgr *mgr = man->priv;
	struct drm_printer p = drm_debug_printer(prefix);

	spin_lock(&mgr->lock);
	drm_mm_debug_table(&mgr->mm, prefix);
	drm_mm_print(&mgr->mm, &p);
	spin_unlock(&mgr->lock);
}

+3 −3
Original line number Diff line number Diff line
@@ -1482,18 +1482,18 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *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;
	int ret;
	struct ttm_bo_global *glob = adev->mman.bdev.glob;
	struct drm_printer p = drm_seq_file_printer(m);

	spin_lock(&glob->lru_lock);
	ret = drm_mm_dump_table(m, mm);
	drm_mm_print(mm, &p);
	spin_unlock(&glob->lru_lock);
	if (ttm_pl == 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);
	return ret;
	return 0;
}

static int ttm_pl_vram = TTM_PL_VRAM;
+2 −1
Original line number Diff line number Diff line
@@ -207,9 +207,10 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,
				  const char *prefix)
{
	struct amdgpu_vram_mgr *mgr = man->priv;
	struct drm_printer p = drm_debug_printer(prefix);

	spin_lock(&mgr->lock);
	drm_mm_debug_table(&mgr->mm, prefix);
	drm_mm_print(&mgr->mm, &p);
	spin_unlock(&mgr->lock);
}

+3 −3
Original line number Diff line number Diff line
@@ -19,13 +19,13 @@ static int armada_debugfs_gem_linear_show(struct seq_file *m, void *data)
	struct drm_info_node *node = m->private;
	struct drm_device *dev = node->minor->dev;
	struct armada_private *priv = dev->dev_private;
	int ret;
	struct drm_printer p = drm_seq_file_printer(m);

	mutex_lock(&priv->linear_lock);
	ret = drm_mm_dump_table(m, &priv->linear);
	drm_mm_dump_table(&p, &priv->linear);
	mutex_unlock(&priv->linear_lock);

	return ret;
	return 0;
}

static int armada_debugfs_reg_show(struct seq_file *m, void *data)
+11 −56
Original line number Diff line number Diff line
@@ -832,8 +832,7 @@ void drm_mm_takedown(struct drm_mm *mm)
}
EXPORT_SYMBOL(drm_mm_takedown);

static u64 drm_mm_debug_hole(const struct drm_mm_node *entry,
			     const char *prefix)
static u64 drm_mm_dump_hole(struct drm_printer *p, const struct drm_mm_node *entry)
{
	u64 hole_start, hole_end, hole_size;

@@ -841,7 +840,7 @@ static u64 drm_mm_debug_hole(const struct drm_mm_node *entry,
		hole_start = drm_mm_hole_node_start(entry);
		hole_end = drm_mm_hole_node_end(entry);
		hole_size = hole_end - hole_start;
		pr_debug("%s %#llx-%#llx: %llu: free\n", prefix, hole_start,
		drm_printf(p, "%#018llx-%#018llx: %llu: free\n", hole_start,
			   hole_end, hole_size);
		return hole_size;
	}
@@ -850,70 +849,26 @@ static u64 drm_mm_debug_hole(const struct drm_mm_node *entry,
}

/**
 * drm_mm_debug_table - dump allocator state to dmesg
 * @mm: drm_mm allocator to dump
 * @prefix: prefix to use for dumping to dmesg
 * drm_mm_print - print allocator state
 * @mm: drm_mm allocator to print
 * @p: DRM printer to use
 */
void drm_mm_debug_table(const struct drm_mm *mm, const char *prefix)
void drm_mm_print(const struct drm_mm *mm, struct drm_printer *p)
{
	const struct drm_mm_node *entry;
	u64 total_used = 0, total_free = 0, total = 0;

	total_free += drm_mm_debug_hole(&mm->head_node, prefix);
	total_free += drm_mm_dump_hole(p, &mm->head_node);

	drm_mm_for_each_node(entry, mm) {
		pr_debug("%s %#llx-%#llx: %llu: used\n", prefix, entry->start,
		drm_printf(p, "%#018llx-%#018llx: %llu: used\n", entry->start,
			   entry->start + entry->size, entry->size);
		total_used += entry->size;
		total_free += drm_mm_debug_hole(entry, prefix);
		total_free += drm_mm_dump_hole(p, entry);
	}
	total = total_free + total_used;

	pr_debug("%s total: %llu, used %llu free %llu\n", prefix, total,
	drm_printf(p, "total: %llu, used %llu free %llu\n", total,
		   total_used, total_free);
}
EXPORT_SYMBOL(drm_mm_debug_table);

#if defined(CONFIG_DEBUG_FS)
static u64 drm_mm_dump_hole(struct seq_file *m, const struct drm_mm_node *entry)
{
	u64 hole_start, hole_end, hole_size;

	if (entry->hole_follows) {
		hole_start = drm_mm_hole_node_start(entry);
		hole_end = drm_mm_hole_node_end(entry);
		hole_size = hole_end - hole_start;
		seq_printf(m, "%#018llx-%#018llx: %llu: free\n", hole_start,
			   hole_end, hole_size);
		return hole_size;
	}

	return 0;
}

/**
 * drm_mm_dump_table - dump allocator state to a seq_file
 * @m: seq_file to dump to
 * @mm: drm_mm allocator to dump
 */
int drm_mm_dump_table(struct seq_file *m, const struct drm_mm *mm)
{
	const struct drm_mm_node *entry;
	u64 total_used = 0, total_free = 0, total = 0;

	total_free += drm_mm_dump_hole(m, &mm->head_node);

	drm_mm_for_each_node(entry, mm) {
		seq_printf(m, "%#018llx-%#018llx: %llu: used\n", entry->start,
			   entry->start + entry->size, entry->size);
		total_used += entry->size;
		total_free += drm_mm_dump_hole(m, entry);
	}
	total = total_free + total_used;

	seq_printf(m, "total: %llu, used %llu free %llu\n", total,
		   total_used, total_free);
	return 0;
}
EXPORT_SYMBOL(drm_mm_dump_table);
#endif
EXPORT_SYMBOL(drm_mm_print);
Loading