summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2002-11-02 23:56:38 -0800
committerLinus Torvalds <torvalds@penguin.transmeta.com>2002-11-02 23:56:38 -0800
commit74bf528d68d17812be666a2b3ce3059cc34cb76a (patch)
treec47a8f0aadadad61afce00e6f4bf90ce12e8c4f6
parent7333261f2f6e23b0fc66280d0951765644de1938 (diff)
[PATCH] Sun-3 DVMA debugging
Add Sun-3 DVMA debugging code (currently disabled, from Sam Creasey)
-rw-r--r--arch/m68k/sun3/sun3dvma.c79
1 files changed, 78 insertions, 1 deletions
diff --git a/arch/m68k/sun3/sun3dvma.c b/arch/m68k/sun3/sun3dvma.c
index 71b9ace15b6d..a14b1c0d5b11 100644
--- a/arch/m68k/sun3/sun3dvma.c
+++ b/arch/m68k/sun3/sun3dvma.c
@@ -14,6 +14,8 @@
#include <asm/pgtable.h>
#include <asm/dvma.h>
+#undef DVMA_DEBUG
+
#ifdef CONFIG_SUN3X
extern void dvma_unmap_iommu(unsigned long baddr, int len);
#else
@@ -22,6 +24,10 @@ static inline void dvma_unmap_iommu(unsigned long a, int b)
}
#endif
+#ifdef CONFIG_SUN3
+extern void sun3_dvma_init(void);
+#endif
+
unsigned long iommu_use[IOMMU_TOTAL_ENTRIES];
#define dvma_index(baddr) ((baddr - DVMA_START) >> DVMA_PAGE_SHIFT)
@@ -39,6 +45,60 @@ static struct list_head hole_list;
static struct list_head hole_cache;
static struct hole initholes[64];
+#ifdef DVMA_DEBUG
+
+static unsigned long dvma_allocs = 0;
+static unsigned long dvma_frees = 0;
+static unsigned long long dvma_alloc_bytes = 0;
+static unsigned long long dvma_free_bytes = 0;
+
+static void print_use(void)
+{
+
+ int i;
+ int j = 0;
+
+ printk("dvma entry usage:\n");
+
+ for(i = 0; i < IOMMU_TOTAL_ENTRIES; i++) {
+ if(!iommu_use[i])
+ continue;
+
+ j++;
+
+ printk("dvma entry: %08lx len %08lx\n",
+ ( i << DVMA_PAGE_SHIFT) + DVMA_START,
+ iommu_use[i]);
+ }
+
+ printk("%d entries in use total\n", j);
+
+ printk("allocation/free calls: %lu/%lu\n", dvma_allocs, dvma_frees);
+ printk("allocation/free bytes: %Lx/%Lx\n", dvma_alloc_bytes,
+ dvma_free_bytes);
+}
+
+static void print_holes(struct list_head *holes)
+{
+
+ struct list_head *cur;
+ struct hole *hole;
+
+ printk("listing dvma holes\n");
+ list_for_each(cur, holes) {
+ hole = list_entry(cur, struct hole, list);
+
+ if((hole->start == 0) && (hole->end == 0) && (hole->size == 0))
+ continue;
+
+ printk("hole: start %08lx end %08lx size %08lx\n", hole->start, hole->end, hole->size);
+ }
+
+ printk("end of hole listing...\n");
+
+}
+#endif DVMA_DEBUG
+
static inline int refill(void)
{
@@ -93,7 +153,11 @@ static inline unsigned long get_baddr(int len, unsigned long align)
struct hole *hole;
if(list_empty(&hole_list)) {
- printk("out of dvma holes!\n");
+#ifdef DVMA_DEBUG
+ printk("out of dvma holes! (printing hole cache)\n");
+ print_holes(&hole_cache);
+ print_use();
+#endif
BUG();
}
@@ -111,11 +175,19 @@ static inline unsigned long get_baddr(int len, unsigned long align)
hole->end -= newlen;
hole->size -= newlen;
dvma_entry_use(hole->end) = newlen;
+#ifdef DVMA_DEBUG
+ dvma_allocs++;
+ dvma_alloc_bytes += newlen;
+#endif
return hole->end;
} else if(hole->size == newlen) {
list_del(&(hole->list));
list_add(&(hole->list), &hole_cache);
dvma_entry_use(hole->start) = newlen;
+#ifdef DVMA_DEBUG
+ dvma_allocs++;
+ dvma_alloc_bytes += newlen;
+#endif
return hole->start;
}
@@ -140,6 +212,11 @@ static inline int free_baddr(unsigned long baddr)
baddr &= DVMA_PAGE_MASK;
dvma_unmap_iommu(baddr, len);
+#ifdef DVMA_DEBUG
+ dvma_frees++;
+ dvma_free_bytes += len;
+#endif
+
list_for_each(cur, &hole_list) {
hole = list_entry(cur, struct hole, list);