Skip to content

Commit e721a45

Browse files
committed
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>
1 parent 95ce618 commit e721a45

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

‎arch/microblaze/include/asm/setup.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extern char cmd_line[COMMAND_LINE_SIZE];
2323
void early_printk(const char *fmt, ...);
2424

2525
int setup_early_printk(char *opt);
26+
void remap_early_printk(void);
2627
void disable_early_printk(void);
2728

2829
#if defined(CONFIG_EARLY_PRINTK)

‎arch/microblaze/kernel/early_printk.c‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static void early_printk_uartlite_write(struct console *unused,
6060
static struct console early_serial_uartlite_console = {
6161
.name = "earlyser",
6262
.write = early_printk_uartlite_write,
63-
.flags = CON_PRINTBUFFER,
63+
.flags = CON_PRINTBUFFER | CON_BOOT,
6464
.index = -1,
6565
};
6666
#endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */
@@ -104,7 +104,7 @@ static void early_printk_uart16550_write(struct console *unused,
104104
static struct console early_serial_uart16550_console = {
105105
.name = "earlyser",
106106
.write = early_printk_uart16550_write,
107-
.flags = CON_PRINTBUFFER,
107+
.flags = CON_PRINTBUFFER | CON_BOOT,
108108
.index = -1,
109109
};
110110
#endif /* CONFIG_SERIAL_8250_CONSOLE */
@@ -141,7 +141,7 @@ int __init setup_early_printk(char *opt)
141141
early_printk("early_printk_console is enabled at 0x%08x\n",
142142
base_addr);
143143

144-
/* register_console(early_console); */
144+
register_console(early_console);
145145

146146
return 0;
147147
}
@@ -160,7 +160,7 @@ int __init setup_early_printk(char *opt)
160160
early_printk("early_printk_console is enabled at 0x%08x\n",
161161
base_addr);
162162

163-
/* register_console(early_console); */
163+
register_console(early_console);
164164

165165
return 0;
166166
}
@@ -169,6 +169,18 @@ int __init setup_early_printk(char *opt)
169169
return 1;
170170
}
171171

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);
182+
}
183+
172184
void __init disable_early_printk(void)
173185
{
174186
if (!early_console_initialized || !early_console)

‎arch/microblaze/kernel/setup.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ void __init setup_arch(char **cmdline_p)
5959

6060
setup_memory();
6161

62+
#ifdef CONFIG_EARLY_PRINTK
63+
/* remap early console to virtual address */
64+
remap_early_printk();
65+
#endif
66+
6267
xilinx_pci_init();
6368

6469
#if defined(CONFIG_SELFMOD_INTC) || defined(CONFIG_SELFMOD_TIMER)

0 commit comments

Comments
 (0)