Skip to contentSkip to conversation

arm64: add support for uart earlyprintk

PATCH New Anup Patel 4 participants 12 messages Feb 28, 2013 arm64

lore
Share & tools
lore

Anup Patel

author
#0 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

---
 arch/arm64/kernel/early_printk.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/kernel/early_printk.c +16 -0
index 7e320a2..62953ed 100644
@@ -29,6 +29,21 @@ static void __iomem *early_base;
 static void (*printch)(char ch);
 
 /*
+ * UART (8250/16550) single character TX.
+ */
+static void uart_printch(char ch)
+{
+#define UART_LSR 	0x14
+#define UART_TX 	0x0
+
+	while (!(readl_relaxed(early_base + UART_LSR) & 0x20))
+		;
+	writeb_relaxed(ch, early_base + UART_TX);
+	while (!(readl_relaxed(early_base + UART_LSR) & 0x20))
+		;
+}
+
+/*
  * PL011 single character TX.
  */
 static void pl011_printch(char ch)
@@ -47,6 +62,7 @@ struct earlycon_match {
 
 static const struct earlycon_match earlycon_match[] __initconst = {
 	{ .name = "pl011", .printch = pl011_printch, },
+	{ .name = "uart", .printch = uart_printch, },
 	{}
 };
 
Signature · 9 lines
1.7.9.5

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, 
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. 
It is to be used solely for the purpose of furthering the parties' business relationship. 
All unauthorized review, use, disclosure or distribution is prohibited. 
If you are not the intended recipient, please contact the sender by reply e-mail 
and destroy all copies of the original message.
#1 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

On 28/02/13 11:01, Anup Patel wrote:

Hi Anup,

Quoted 1 line

A proper patch description would be nice.

Quoted 9 lines
---
 arch/arm64/kernel/early_printk.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/kernel/early_printk.c +0 -0
index 7e320a2..62953ed 100644

arch/arm64/kernel/early_printk.c static void __iomem *early_base; · line 37

Quoted 9 lines
arch/arm64/kernel/early_printk.c +6 -0
@@ -29,6 +29,21 @@ static void __iomem *early_base;
 static void (*printch)(char ch);
 
 /*
+ * UART (8250/16550) single character TX.
+ */
+static void uart_printch(char ch)
+{
+#define UART_LSR 	0x14
+#define UART_TX 	0x0

Please use the constants defined in include/uapi/linux/serial_reg.h, together with the proper shifts.

arch/arm64/kernel/early_printk.c static void __iomem *early_base; · line 40

Quoted 3 lines
arch/arm64/kernel/early_printk.c +3 -0
+
+	while (!(readl_relaxed(early_base + UART_LSR) & 0x20))
+		;

You may want to test both UART_LSR_TEMT and UART_LSR_THRE here.

arch/arm64/kernel/early_printk.c static void __iomem *early_base; · line 43

Quoted 3 lines
arch/arm64/kernel/early_printk.c +3 -0
+	writeb_relaxed(ch, early_base + UART_TX);
+	while (!(readl_relaxed(early_base + UART_LSR) & 0x20))
+		;

Why do you have to wait again here? It should be enough to do in only once when entering the function.

arch/arm64/kernel/early_printk.c struct earlycon_match { · line 65

Quoted 11 lines
arch/arm64/kernel/early_printk.c +4 -0
+}
+
+/*
  * PL011 single character TX.
  */
 static void pl011_printch(char ch)
@@ -47,6 +62,7 @@ struct earlycon_match {
 
 static const struct earlycon_match earlycon_match[] __initconst = {
 	{ .name = "pl011", .printch = pl011_printch, },
+	{ .name = "uart", .printch = uart_printch, },

"uart" is way too generic. pl011 is an UART too, and I suspect most of the backends that are going to be added here over time will be UARTs.

"uart8250" would be a possibility (and actually consistent with the rest of the kernel, see drivers/tty/serial/8250/8250_early.c.

Cheers,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
maintainer
#2 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

Quoted 16 lines · Marc Zyngier

arch/arm64/kernel/early_printk.c struct earlycon_match { · line 65

Quoted 11 lines · Anup Patel
arch/arm64/kernel/early_printk.c +4 -0
+}
+
+/*
  * PL011 single character TX.
  */
 static void pl011_printch(char ch)
@@ -47,6 +62,7 @@ struct earlycon_match {
 
 static const struct earlycon_match earlycon_match[] __initconst = {
 	{ .name = "pl011", .printch = pl011_printch, },
+	{ .name = "uart", .printch = uart_printch, },

"uart" is way too generic. pl011 is an UART too, and I suspect most of the backends that are going to be added here over time will be UARTs.

Quoted 2 lines

"uart8250" would be a possibility (and actually consistent with the rest of the kernel, see drivers/tty/serial/8250/8250_early.c.

I think it makes more sense to use the existing 8250_early.c driver. It has more features than the simple earlyprintk implementation in the 64-bit kernel (like parsing more parameters, initialising the UART). The only difference is that the early_param is called "earlycon".

Signature · 1 line
Catalin
#3 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

Quoted 17 lines · Catalin Marinas
Quoted 16 lines · Marc Zyngier

arch/arm64/kernel/early_printk.c struct earlycon_match { · line 65

Quoted 11 lines · Anup Patel
arch/arm64/kernel/early_printk.c +4 -0
+}
+
+/*
  * PL011 single character TX.
  */
 static void pl011_printch(char ch)
@@ -47,6 +62,7 @@ struct earlycon_match {
 
 static const struct earlycon_match earlycon_match[] __initconst = {
 	{ .name = "pl011", .printch = pl011_printch, },
+	{ .name = "uart", .printch = uart_printch, },

"uart" is way too generic. pl011 is an UART too, and I suspect most of the backends that are going to be added here over time will be UARTs.

Quoted 7 lines
Quoted 2 lines

"uart8250" would be a possibility (and actually consistent with the rest of the kernel, see drivers/tty/serial/8250/8250_early.c.

I think it makes more sense to use the existing 8250_early.c driver. It has more features than the simple earlyprintk implementation in the 64-bit kernel (like parsing more parameters, initialising the UART). The only difference is that the early_param is called "earlycon".

Indeed, this seems to be the best way, as it removes the need for this patch altogether.

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
author
#4 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

Quoted 21 lines · Marc Zyngier
Quoted 20 lines · Catalin Marinas
Quoted 18 lines · Marc Zyngier

arch/arm64/kernel/early_printk.c struct earlycon_match { · line 65

Quoted 11 lines · Anup Patel
arch/arm64/kernel/early_printk.c +4 -0
+}
+
+/*
  * PL011 single character TX.
  */
 static void pl011_printch(char ch)
@@ -47,6 +62,7 @@ struct earlycon_match {
 
 static const struct earlycon_match earlycon_match[] __initconst = {
    { .name = "pl011", .printch = pl011_printch, },
+   { .name = "uart", .printch = uart_printch, },

"uart" is way too generic. pl011 is an UART too, and I suspect most of the backends that are going to be added here over time will be UARTs.

"uart8250" would be a possibility (and actually consistent with the rest of the kernel, see drivers/tty/serial/8250/8250_early.c.

Quoted 7 lines
Quoted 4 lines

I think it makes more sense to use the existing 8250_early.c driver. It has more features than the simple earlyprintk implementation in the 64-bit kernel (like parsing more parameters, initialising the UART). The only difference is that the early_param is called "earlycon".

Indeed, this seems to be the best way, as it removes the need for this patch altogether.

The earlycon option does not seem to work on my ARM64 kernel because it uses ioremap_nocache() whereas ARM64 earlyprintk uses early_io_map()

I do agree that earlycon is more feature rich compared to ARM64 earlyprintk but I doubt whether 8250_early.c is generic enough to be usable on ARM64 kernel

The best part about ARM64 earlyprintk is that its very very simple and does not expect us to re-programme UART HW which is already programmed by the the bootloader.

IMHO, adding 8250 support in ARM64 earlyprintk would be very ARM64 specific and not
re-implementation of 8250_early.c

Quoted 5 lines
        M.

--
Jazz is not dead. It just smells funny...

Regards,
Anup
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

maintainer
#5 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

Quoted 27 lines · Anup Patel
Quoted 26 lines · Marc Zyngier
Quoted 24 lines · Catalin Marinas
Quoted 16 lines · Marc Zyngier

arch/arm64/kernel/early_printk.c struct earlycon_match { · line 65

Quoted 11 lines · Anup Patel
arch/arm64/kernel/early_printk.c +4 -0
+}
+
+/*
  * PL011 single character TX.
  */
 static void pl011_printch(char ch)
@@ -47,6 +62,7 @@ struct earlycon_match {
 
 static const struct earlycon_match earlycon_match[] __initconst = {
    { .name = "pl011", .printch = pl011_printch, },
+   { .name = "uart", .printch = uart_printch, },

"uart" is way too generic. pl011 is an UART too, and I suspect most of the backends that are going to be added here over time will be UARTs.

Quoted 2 lines

"uart8250" would be a possibility (and actually consistent with the rest of the kernel, see drivers/tty/serial/8250/8250_early.c.

I think it makes more sense to use the existing 8250_early.c driver. It has more features than the simple earlyprintk implementation in the 64-bit kernel (like parsing more parameters, initialising the UART). The only difference is that the early_param is called "earlycon".

Quoted 5 lines
Quoted 2 lines

Indeed, this seems to be the best way, as it removes the need for this patch altogether.

The earlycon option does not seem to work on my ARM64 kernel because it uses ioremap_nocache() whereas ARM64 earlyprintk uses early_io_map()

We try to get earlyprintk as early as possible and ioremap() isn't available yet, hence the arm64-specific early_io_map(). It looks like x86 has a CONFIG_FIX_EARLYCON_MEM to avoid the ioremap() issue but I wouldn't add yet another option for arm64.

So we can go with your arm64 patch, once you implement the feedback from Marc.

Signature · 1 line
Catalin
author
#6 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

Quoted 39 lines · Catalin Marinas
Quoted 27 lines · Anup Patel
Quoted 26 lines · Marc Zyngier
Quoted 24 lines · Catalin Marinas
Quoted 16 lines · Marc Zyngier

arch/arm64/kernel/early_printk.c struct earlycon_match { · line 65

Quoted 11 lines · Anup Patel
arch/arm64/kernel/early_printk.c +4 -0
+}
+
+/*
  * PL011 single character TX.
  */
 static void pl011_printch(char ch)
@@ -47,6 +62,7 @@ struct earlycon_match {
 
 static const struct earlycon_match earlycon_match[] __initconst = {
    { .name = "pl011", .printch = pl011_printch, },
+   { .name = "uart", .printch = uart_printch, },

"uart" is way too generic. pl011 is an UART too, and I suspect most of the backends that are going to be added here over time will be UARTs.

Quoted 2 lines

"uart8250" would be a possibility (and actually consistent with the rest of the kernel, see drivers/tty/serial/8250/8250_early.c.

I think it makes more sense to use the existing 8250_early.c driver. It has more features than the simple earlyprintk implementation in the 64-bit kernel (like parsing more parameters, initialising the UART). The only difference is that the early_param is called "earlycon".

Quoted 5 lines
Quoted 2 lines

Indeed, this seems to be the best way, as it removes the need for this patch altogether.

The earlycon option does not seem to work on my ARM64 kernel because it uses ioremap_nocache() whereas ARM64 earlyprintk uses early_io_map()

We try to get earlyprintk as early as possible and ioremap() isn't available yet, hence the arm64-specific early_io_map(). It looks like x86 has a CONFIG_FIX_EARLYCON_MEM to avoid the ioremap() issue but I wouldn't add yet another option for arm64.

Quoted 5 lines

So we can go with your arm64 patch, once you implement the feedback from Marc.

--
Catalin

Sure, I will incorporate Marc's comments and resend the patch with more appropriate
subject and description.

Regards,
Anup
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

author
#7 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

In reply to Marc Zyngier
Quoted 7 lines · Marc Zyngier

On 28/02/13 11:01, Anup Patel wrote:

Hi Anup,

Quoted 1 line

A proper patch description would be nice.

Oke will do.

Quoted 12 lines
Quoted 12 lines
---
 arch/arm64/kernel/early_printk.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/kernel/early_printk.c +0 -0
index 7e320a2..62953ed 100644
@@ -29,6 +29,21 @@ static void __iomem *early_base;
 static void (*printch)(char ch);
 
Quoted 10 lines

arch/arm64/kernel/early_printk.c static void __iomem *early_base; · line 37

Quoted 7 lines
arch/arm64/kernel/early_printk.c +6 -0
 /*
+ * UART (8250/16550) single character TX.
+ */
+static void uart_printch(char ch)
+{
+#define UART_LSR     0x14
+#define UART_TX      0x0

Please use the constants defined in include/uapi/linux/serial_reg.h, together with the proper shifts.

Yes, I am fine with reusing constants from serial_reg.h.
Its just that I did not want to include entire header for 2 register accesses.

Quoted 6 lines

arch/arm64/kernel/early_printk.c static void __iomem *early_base; · line 40

Quoted 4 lines
arch/arm64/kernel/early_printk.c +3 -0
+
+     while (!(readl_relaxed(early_base + UART_LSR) & 0x20))
+             ;

You may want to test both UART_LSR_TEMT and UART_LSR_THRE here.

We only need to check for empty space in Tx FIFO or Tx Holding Register hence a check on UART_LSR_THRE bit would suffice.
(For more info,
http://en.wikibooks.org/wiki/Serial_Programming/8250_UART_Programming)

Quoted 7 lines

arch/arm64/kernel/early_printk.c static void __iomem *early_base; · line 43

Quoted 4 lines
arch/arm64/kernel/early_printk.c +3 -0
+     writeb_relaxed(ch, early_base + UART_TX);
+     while (!(readl_relaxed(early_base + UART_LSR) & 0x20))
+             ;

Why do you have to wait again here? It should be enough to do in only once when entering the function.

Yes, the second loop seems to be redundant.
Its there because I tried to implement uart_printch() similar to pl011_printch().

Quoted 16 lines

arch/arm64/kernel/early_printk.c struct earlycon_match { · line 65

Quoted 12 lines
arch/arm64/kernel/early_printk.c +4 -0
+}
+
+/*
  * PL011 single character TX.
  */
 static void pl011_printch(char ch)
@@ -47,6 +62,7 @@ struct earlycon_match {
 
 static const struct earlycon_match earlycon_match[] __initconst = {
      { .name = "pl011", .printch = pl011_printch, },
+     { .name = "uart", .printch = uart_printch, },

"uart" is way too generic. pl011 is an UART too, and I suspect most of the backends that are going to be added here over time will be UARTs.

Quoted 2 lines

"uart8250" would be a possibility (and actually consistent with the rest of the kernel, see drivers/tty/serial/8250/8250_early.c.

Actually, I was thinking of having earlyprintk=8250. What say ?

Quoted 7 lines

Cheers,

        M.

--
Jazz is not dead. It just smells funny...

Regards,
Anup
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

#8 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

In reply to Anup Patel
Quoted 6 lines · Anup Patel
---
 arch/arm64/kernel/early_printk.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Quoted 8 lines

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

Is this patch confidential or GPL? You can't submit patches with a notice like this.

Rob

author
#9 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

Quoted 16 lines · Rob Herring
Quoted 6 lines · Anup Patel
---
 arch/arm64/kernel/early_printk.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Quoted 8 lines

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

Quoted 5 lines

Is this patch confidential or GPL? You can't submit patches with a notice like this.

Rob

No this patch is not confidential. I am sending this patch with appropriate permissions from APM.

Actually, we at APM cannot disable this footer (which is a default setting) so please ignore it.

Regards,
Anup
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

#10 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

Quoted 17 lines · Anup Patel
Quoted 16 lines · Rob Herring
Quoted 14 lines · Anup Patel
---
 arch/arm64/kernel/early_printk.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

Quoted 8 lines
Quoted 5 lines

Is this patch confidential or GPL? You can't submit patches with a notice like this.

Rob

No this patch is not confidential. I am sending this patch with appropriate permissions from APM.

The signature doesn't tell anyone that. There are several examples of the same thing:

http://www.mail-archive.com/linux-usb at vger.kernel.org/msg11135.html
https://lkml.org/lkml/2011/4/22/147

Of course, there's probably many examples with patches accepted anyway by less attentive maintainers.

Quoted 2 lines

Actually, we at APM cannot disable this footer (which is a default setting) so please ignore it.

Which is one reason why people don't use their corporate email.

Rob

Quoted 11 lines

Regards,
Anup
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

author
#11 lore raw

PATCH 1/1 arm64: add support for uart earlyprintk

Quoted 33 lines · Rob Herring
Quoted 17 lines · Anup Patel
Quoted 16 lines · Rob Herring
Quoted 14 lines · Anup Patel
---
 arch/arm64/kernel/early_printk.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

Quoted 8 lines
Quoted 5 lines

Is this patch confidential or GPL? You can't submit patches with a notice like this.

Rob

No this patch is not confidential. I am sending this patch with appropriate permissions from APM.

The signature doesn't tell anyone that. There are several examples of the same thing:

http://www.mail-archive.com/linux-usb at vger.kernel.org/msg11135.html
https://lkml.org/lkml/2011/4/22/147

Quoted 7 lines

Of course, there's probably many examples with patches accepted anyway by less attentive maintainers.

Quoted 2 lines

Actually, we at APM cannot disable this footer (which is a default setting) so please ignore it.

Which is one reason why people don't use their corporate email.

Let me try to use my personal email from next patch onwards if APM folks allow me to do that.

Quoted 15 lines

Rob

Quoted 11 lines

Regards,
Anup
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

Regards,
Anup Patel
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and contains information
that is confidential and proprietary to Applied Micro Circuits Corporation or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. All unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.