diff options
author | kib <kib@FreeBSD.org> | 2013-03-05 09:07:58 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2013-03-05 09:07:58 +0000 |
commit | bffd962e28d842cb859c9967d37e61bb0310c9ab (patch) | |
tree | fc1f1479309b831821b72b4b511ffce9238575cc | |
parent | 74ea46d9eedeafa2223a3c26e4a4d085581516a0 (diff) | |
download | FreeBSD-src-bffd962e28d842cb859c9967d37e61bb0310c9ab.zip FreeBSD-src-bffd962e28d842cb859c9967d37e61bb0310c9ab.tar.gz |
Import the drm_mm_debug_table() function.
Sponsored by: The FreeBSD Foundation
MFC after: 1 month
-rw-r--r-- | sys/dev/drm2/drm_mm.c | 37 | ||||
-rw-r--r-- | sys/dev/drm2/drm_mm.h | 2 |
2 files changed, 39 insertions, 0 deletions
diff --git a/sys/dev/drm2/drm_mm.c b/sys/dev/drm2/drm_mm.c index cb35fc0..3617b05 100644 --- a/sys/dev/drm2/drm_mm.c +++ b/sys/dev/drm2/drm_mm.c @@ -561,3 +561,40 @@ void drm_mm_takedown(struct drm_mm * mm) KASSERT(mm->num_unused == 0, ("num_unused != 0")); } + +void drm_mm_debug_table(struct drm_mm *mm, const char *prefix) +{ + struct drm_mm_node *entry; + unsigned long total_used = 0, total_free = 0, total = 0; + unsigned long hole_start, hole_end, hole_size; + + hole_start = drm_mm_hole_node_start(&mm->head_node); + hole_end = drm_mm_hole_node_end(&mm->head_node); + hole_size = hole_end - hole_start; + if (hole_size) + printf("%s 0x%08lx-0x%08lx: %8lu: free\n", + prefix, hole_start, hole_end, + hole_size); + total_free += hole_size; + + drm_mm_for_each_node(entry, mm) { + printf("%s 0x%08lx-0x%08lx: %8lu: used\n", + prefix, entry->start, entry->start + entry->size, + entry->size); + total_used += entry->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; + printf("%s 0x%08lx-0x%08lx: %8lu: free\n", + prefix, hole_start, hole_end, + hole_size); + total_free += hole_size; + } + } + total = total_free + total_used; + + printf("%s total: %lu, used %lu free %lu\n", prefix, total, + total_used, total_free); +} diff --git a/sys/dev/drm2/drm_mm.h b/sys/dev/drm2/drm_mm.h index 7b173af..7150e24 100644 --- a/sys/dev/drm2/drm_mm.h +++ b/sys/dev/drm2/drm_mm.h @@ -182,4 +182,6 @@ void drm_mm_init_scan_with_range(struct drm_mm *mm, unsigned long size, int drm_mm_scan_add_block(struct drm_mm_node *node); int drm_mm_scan_remove_block(struct drm_mm_node *node); +void drm_mm_debug_table(struct drm_mm *mm, const char *prefix); + #endif |