Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

microblaze: Get early printk console earlier

1. Register early console as standard console
2. Enable CON_BOOT console flag to ensure auto-unregistering by the kernel
3. remap_early_printk function remap physical console baseaddr to virtual space

Usage specific function for console remap is done after memory initialization
with IRQ turn off that's why there is not necessary to protect it.

The reason for remapping is that the kernel use TLB 63 for 1:1 address mapping
to be able to use console in very early boot-up phase. But allocating one TLB
just for console caused performance degression that's why ioremaps create new
mapping and TLB 63 is automatically released and ready to use.

Signed-off-by: Michal Simek <monstr@monstr.eu>
CC: Russell King <linux@arm.linux.org.uk>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Ingo Molnar <mingo@redhat.com>
CC: Alan Cox <alan@linux.intel.com>
CC: <linux-serial@vger.kernel.org>
CC: Arnd Bergmann <arnd@arndb.de>

+22 -4
+1
arch/microblaze/include/asm/setup.h
··· 23 23 void early_printk(const char *fmt, ...); 24 24 25 25 int setup_early_printk(char *opt); 26 + void remap_early_printk(void); 26 27 void disable_early_printk(void); 27 28 28 29 #if defined(CONFIG_EARLY_PRINTK)
+16 -4
arch/microblaze/kernel/early_printk.c
··· 60 60 static struct console early_serial_uartlite_console = { 61 61 .name = "earlyser", 62 62 .write = early_printk_uartlite_write, 63 - .flags = CON_PRINTBUFFER, 63 + .flags = CON_PRINTBUFFER | CON_BOOT, 64 64 .index = -1, 65 65 }; 66 66 #endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */ ··· 104 104 static struct console early_serial_uart16550_console = { 105 105 .name = "earlyser", 106 106 .write = early_printk_uart16550_write, 107 - .flags = CON_PRINTBUFFER, 107 + .flags = CON_PRINTBUFFER | CON_BOOT, 108 108 .index = -1, 109 109 }; 110 110 #endif /* CONFIG_SERIAL_8250_CONSOLE */ ··· 141 141 early_printk("early_printk_console is enabled at 0x%08x\n", 142 142 base_addr); 143 143 144 - /* register_console(early_console); */ 144 + register_console(early_console); 145 145 146 146 return 0; 147 147 } ··· 160 160 early_printk("early_printk_console is enabled at 0x%08x\n", 161 161 base_addr); 162 162 163 - /* register_console(early_console); */ 163 + register_console(early_console); 164 164 165 165 return 0; 166 166 } 167 167 #endif /* CONFIG_SERIAL_8250_CONSOLE */ 168 168 169 169 return 1; 170 + } 171 + 172 + /* Remap early console to virtual address and do not allocate one TLB 173 + * only for early console because of performance degression */ 174 + void __init remap_early_printk(void) 175 + { 176 + if (!early_console_initialized || !early_console) 177 + return; 178 + printk(KERN_INFO "early_printk_console remaping from 0x%x to ", 179 + base_addr); 180 + base_addr = (u32) ioremap(base_addr, PAGE_SIZE); 181 + printk(KERN_CONT "0x%x\n", base_addr); 170 182 } 171 183 172 184 void __init disable_early_printk(void)
+5
arch/microblaze/kernel/setup.c
··· 59 59 60 60 setup_memory(); 61 61 62 + #ifdef CONFIG_EARLY_PRINTK 63 + /* remap early console to virtual address */ 64 + remap_early_printk(); 65 + #endif 66 + 62 67 xilinx_pci_init(); 63 68 64 69 #if defined(CONFIG_SELFMOD_INTC) || defined(CONFIG_SELFMOD_TIMER)