x86: early_ioremap(), debugging

add early_ioremap() debug printouts via the early_ioremap_debug
boot option.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/arch/x86/mm/ioremap_32.c b/arch/x86/mm/ioremap_32.c
index 4bcd5e0..30855c4 100644
--- a/arch/x86/mm/ioremap_32.c
+++ b/arch/x86/mm/ioremap_32.c
@@ -208,6 +208,17 @@
 }
 EXPORT_SYMBOL(iounmap);
 
+
+int __initdata early_ioremap_debug;
+
+static int __init early_ioremap_debug_setup(char *str)
+{
+	early_ioremap_debug = 1;
+
+	return 1;
+}
+__setup("early_ioremap_debug", early_ioremap_debug_setup);
+
 static __initdata int after_paging_init;
 static __initdata unsigned long bm_pte[1024]
 				__attribute__((aligned(PAGE_SIZE)));
@@ -226,6 +237,9 @@
 {
 	unsigned long *pgd;
 
+	if (early_ioremap_debug)
+		printk("early_ioremap_init()\n");
+
 	pgd = early_ioremap_pgd(fix_to_virt(FIX_BTMAP_BEGIN));
 	*pgd = __pa(bm_pte) | _PAGE_TABLE;
 	memset(bm_pte, 0, sizeof(bm_pte));
@@ -236,6 +250,9 @@
 {
 	unsigned long *pgd;
 
+	if (early_ioremap_debug)
+		printk("early_ioremap_clear()\n");
+
 	pgd = early_ioremap_pgd(fix_to_virt(FIX_BTMAP_BEGIN));
 	*pgd = 0;
 	__flush_tlb_all();
@@ -303,6 +320,11 @@
 	WARN_ON(system_state != SYSTEM_BOOTING);
 
 	nesting = early_ioremap_nested;
+	if (early_ioremap_debug) {
+		printk("early_ioremap(%08lx, %08lx) [%d] => ",
+				phys_addr, size, nesting);
+		dump_stack();
+	}
 
 	/* Don't allow wraparound or zero size */
 	last_addr = phys_addr + size - 1;
@@ -343,6 +365,8 @@
 		--idx;
 		--nrpages;
 	}
+	if (early_ioremap_debug)
+		printk(KERN_CONT "%08lx + %08lx\n", offset, fix_to_virt(idx0));
 
 	return (void*) (offset + fix_to_virt(idx0));
 }
@@ -358,6 +382,11 @@
 	nesting = --early_ioremap_nested;
 	WARN_ON(nesting < 0);
 
+	if (early_ioremap_debug) {
+		printk("early_iounmap(%p, %08lx) [%d]\n", addr, size, nesting);
+		dump_stack();
+	}
+
 	virt_addr = (unsigned long)addr;
 	if (virt_addr < fix_to_virt(FIX_BTMAP_BEGIN)) {
 		WARN_ON(1);