public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Microblaze early console support
@ 2011-04-04 16:30 Michal Simek
  2011-04-04 16:30 ` [PATCH] microblaze: Get early printk console earlier Michal Simek
  2011-04-04 17:21 ` Microblaze early console support Michal Simek
  0 siblings, 2 replies; 3+ messages in thread
From: Michal Simek @ 2011-04-04 16:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: john.williams

Hi,

I have one question about early console support on MMU kernel.
When do you register an early console and what TLB mapping you use?

For Microblaze I registered it before main memory is setup that's why I was
hardcoded TLB 63 to 1:1 mapping (virt addr = phys addr). 
It is output only for early_printk messages but I would like to use it 
as boot console. There are only some messages that's why TLB 63 was released
later on.
That is the current state.

I have added CON_BOOT flag and register early console by register_console function
and I allocate TLB 63 for it. But unfortunately I haven't found any function 
in unregister_console which is called for unregistering to help me to release TLB 63
when early console is not used. Is there any way how to do it?

>From our experiment in past there is performance degression when kernel can't use
a TLB that's why I tried to find out a way to release TLB 63.
This is the reason why I would like to know your opinion if my style is correct 
or not.
I created new remap_early_printk function which does ioremap for console space.
This function is called from setup_arch when memory is setup. Then early mapping of TLB 63
is automatically released and can be used for Linux purpose.
Is it correct design how to do it?

How do you handle it in your arch? Do you register early console before memory initialization
is done?

You can also look at my patch I have done.

Thanks for your suggestions,
Michal



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] microblaze: Get early printk console earlier
  2011-04-04 16:30 Microblaze early console support Michal Simek
@ 2011-04-04 16:30 ` Michal Simek
  2011-04-04 17:21 ` Microblaze early console support Michal Simek
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2011-04-04 16:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: john.williams, Michal Simek

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>
---
 arch/microblaze/include/asm/setup.h   |    1 +
 arch/microblaze/kernel/early_printk.c |   17 +++++++++++++----
 arch/microblaze/kernel/setup.c        |    5 +++++
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h
index 8f39689..904e5ef 100644
--- a/arch/microblaze/include/asm/setup.h
+++ b/arch/microblaze/include/asm/setup.h
@@ -23,6 +23,7 @@ extern char cmd_line[COMMAND_LINE_SIZE];
 void early_printk(const char *fmt, ...);
 
 int setup_early_printk(char *opt);
+void remap_early_printk(void);
 void disable_early_printk(void);
 
 #if defined(CONFIG_EARLY_PRINTK)
diff --git a/arch/microblaze/kernel/early_printk.c b/arch/microblaze/kernel/early_printk.c
index c3616a0..1c11191 100644
--- a/arch/microblaze/kernel/early_printk.c
+++ b/arch/microblaze/kernel/early_printk.c
@@ -60,7 +60,7 @@ static void early_printk_uartlite_write(struct console *unused,
 static struct console early_serial_uartlite_console = {
 	.name = "earlyser",
 	.write = early_printk_uartlite_write,
-	.flags = CON_PRINTBUFFER,
+	.flags = CON_PRINTBUFFER | CON_BOOT,
 	.index = -1,
 };
 #endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */
@@ -104,7 +104,7 @@ static void early_printk_uart16550_write(struct console *unused,
 static struct console early_serial_uart16550_console = {
 	.name = "earlyser",
 	.write = early_printk_uart16550_write,
-	.flags = CON_PRINTBUFFER,
+	.flags = CON_PRINTBUFFER | CON_BOOT,
 	.index = -1,
 };
 #endif /* CONFIG_SERIAL_8250_CONSOLE */
@@ -141,7 +141,7 @@ int __init setup_early_printk(char *opt)
 		early_printk("early_printk_console is enabled at 0x%08x\n",
 							base_addr);
 
-		/* register_console(early_console); */
+		register_console(early_console);
 
 		return 0;
 	}
@@ -160,7 +160,7 @@ int __init setup_early_printk(char *opt)
 		early_printk("early_printk_console is enabled at 0x%08x\n",
 							base_addr);
 
-		/* register_console(early_console); */
+		register_console(early_console);
 
 		return 0;
 	}
@@ -169,6 +169,15 @@ int __init setup_early_printk(char *opt)
 	return 1;
 }
 
+/* Remap early console to virtual address and do not allocate one TLB
+ * only for early console because of performance degression */
+void remap_early_printk(void)
+{
+	printk("early_printk_console remaping from 0x%x to ", base_addr);
+	base_addr = (u32) ioremap(base_addr, PAGE_SIZE);
+	printk("0x%x\n", base_addr);
+}
+
 void __init disable_early_printk(void)
 {
 	if (!early_console_initialized || !early_console)
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c
index 8e2c09b..0e654a1 100644
--- a/arch/microblaze/kernel/setup.c
+++ b/arch/microblaze/kernel/setup.c
@@ -59,6 +59,11 @@ void __init setup_arch(char **cmdline_p)
 
 	setup_memory();
 
+#ifdef CONFIG_EARLY_PRINTK
+	/* remap early console to virtual address */
+	remap_early_printk();
+#endif
+
 	xilinx_pci_init();
 
 #if defined(CONFIG_SELFMOD_INTC) || defined(CONFIG_SELFMOD_TIMER)
-- 
1.5.5.6


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: Microblaze early console support
  2011-04-04 16:30 Microblaze early console support Michal Simek
  2011-04-04 16:30 ` [PATCH] microblaze: Get early printk console earlier Michal Simek
@ 2011-04-04 17:21 ` Michal Simek
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2011-04-04 17:21 UTC (permalink / raw)
  To: Michal Simek
  Cc: linux-kernel, john.williams, Russell King, Ralf Baechle,
	Ingo Molnar, Alan Cox, linux-serial, Arnd Bergmann

resent.

M

Michal Simek wrote:
> Hi,
> 
> I have one question about early console support on MMU kernel.
> When do you register an early console and what TLB mapping you use?
> 
> For Microblaze I registered it before main memory is setup that's why I was
> hardcoded TLB 63 to 1:1 mapping (virt addr = phys addr). 
> It is output only for early_printk messages but I would like to use it 
> as boot console. There are only some messages that's why TLB 63 was released
> later on.
> That is the current state.
> 
> I have added CON_BOOT flag and register early console by register_console function
> and I allocate TLB 63 for it. But unfortunately I haven't found any function 
> in unregister_console which is called for unregistering to help me to release TLB 63
> when early console is not used. Is there any way how to do it?
> 
> From our experiment in past there is performance degression when kernel can't use
> a TLB that's why I tried to find out a way to release TLB 63.
> This is the reason why I would like to know your opinion if my style is correct 
> or not.
> I created new remap_early_printk function which does ioremap for console space.
> This function is called from setup_arch when memory is setup. Then early mapping of TLB 63
> is automatically released and can be used for Linux purpose.
> Is it correct design how to do it?
> 
> How do you handle it in your arch? Do you register early console before memory initialization
> is done?
> 
> You can also look at my patch I have done.
> 
> Thanks for your suggestions,
> Michal

-- 
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-04-04 17:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-04 16:30 Microblaze early console support Michal Simek
2011-04-04 16:30 ` [PATCH] microblaze: Get early printk console earlier Michal Simek
2011-04-04 17:21 ` Microblaze early console support Michal Simek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox