Skip to content

Commit dfdaa3f

Browse files
danvetgregkh
authored andcommitted
drm/mm: fix dump table BUG
commit 3a359f0 upstream. In commit 9e8944a Author: Chris Wilson <chris@chris-wilson.co.uk> Date: Thu Nov 15 11:32:17 2012 +0000 drm: Introduce an iterator over holes in the drm_mm range manager helpers and iterators for hole handling have been introduced with some debug BUG_ONs sprinkled over. Unfortunately this broke the mm dumper which unconditionally tried to compute the size of the very first hole. While at it unify the code a bit with the hole dumping in the loop. v2: Extract a hole dump helper. Reported-by: Christopher Harvey <charvey@matrox.com> Cc: Christopher Harvey <charvey@matrox.com> Cc: Dave Airlie <airlied@redhat.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 70386b7 commit dfdaa3f

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

‎drivers/gpu/drm/drm_mm.c‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -755,33 +755,35 @@ void drm_mm_debug_table(struct drm_mm *mm, const char *prefix)
755755
EXPORT_SYMBOL(drm_mm_debug_table);
756756

757757
#if defined(CONFIG_DEBUG_FS)
758-
int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm)
758+
static unsigned long drm_mm_dump_hole(struct seq_file *m, struct drm_mm_node *entry)
759759
{
760-
struct drm_mm_node *entry;
761-
unsigned long total_used = 0, total_free = 0, total = 0;
762760
unsigned long hole_start, hole_end, hole_size;
763761

764-
hole_start = drm_mm_hole_node_start(&mm->head_node);
765-
hole_end = drm_mm_hole_node_end(&mm->head_node);
766-
hole_size = hole_end - hole_start;
767-
if (hole_size)
762+
if (entry->hole_follows) {
763+
hole_start = drm_mm_hole_node_start(entry);
764+
hole_end = drm_mm_hole_node_end(entry);
765+
hole_size = hole_end - hole_start;
768766
seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n",
769767
hole_start, hole_end, hole_size);
770-
total_free += hole_size;
768+
return hole_size;
769+
}
770+
771+
return 0;
772+
}
773+
774+
int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm)
775+
{
776+
struct drm_mm_node *entry;
777+
unsigned long total_used = 0, total_free = 0, total = 0;
778+
779+
total_free += drm_mm_dump_hole(m, &mm->head_node);
771780

772781
drm_mm_for_each_node(entry, mm) {
773782
seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: used\n",
774783
entry->start, entry->start + entry->size,
775784
entry->size);
776785
total_used += entry->size;
777-
if (entry->hole_follows) {
778-
hole_start = drm_mm_hole_node_start(entry);
779-
hole_end = drm_mm_hole_node_end(entry);
780-
hole_size = hole_end - hole_start;
781-
seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n",
782-
hole_start, hole_end, hole_size);
783-
total_free += hole_size;
784-
}
786+
total_free += drm_mm_dump_hole(m, entry);
785787
}
786788
total = total_free + total_used;
787789

0 commit comments

Comments
 (0)