Linux-RISC-V Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/3] RISC-V SBI earlycon
@ 2018-12-04 13:55 Anup Patel
  2018-12-04 13:55 ` [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support Anup Patel
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Anup Patel @ 2018-12-04 13:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Palmer Dabbelt, Albert Ou
  Cc: Rob Herring, Anup Patel, linux-kernel, Christoph Hellwig,
	Atish Patra, linux-serial, linux-riscv

This patchset adds RISC-V SBI earlycon and removes RISC-V EARLY_PRINTK.

We should use earlycon over existing EARLY_PRINTK for SBI console because:
1. It's a more generic way of implementing early console for debugging
2. Current RISC-V EARLY_PRINTK is a compile-time option whereas earlycon
   is enabled at run-time via kernel parameters.
3. To use earlycon with SBI, we have to pass "earlycon=sbi" in kernel
   parameters. If earlycon kernel parameter is not provided then kernel
   boots much faster which is very useful in real-world RISC-V deployments.

The patchset is tested on QEMU virt machine. It is based on Linux-4.20-rc5
and can be found at riscv_earlycon_v1 branch of:
https://github.com/avpatel/linux.git

Anup Patel (3):
  tty/serial: Add RISC-V SBI earlycon support
  RISC-V: defconfig: Enable RISC-V SBI earlycon support
  RISC-V: Remove EARLY_PRINTK support

 arch/riscv/Kconfig.debug                |  2 --
 arch/riscv/configs/defconfig            |  1 +
 arch/riscv/kernel/setup.c               | 28 -------------------------
 drivers/tty/serial/Kconfig              | 12 +++++++++++
 drivers/tty/serial/Makefile             |  1 +
 drivers/tty/serial/earlycon-riscv-sbi.c | 28 +++++++++++++++++++++++++
 6 files changed, 42 insertions(+), 30 deletions(-)
 create mode 100644 drivers/tty/serial/earlycon-riscv-sbi.c

-- 
2.17.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support
  2018-12-04 13:55 [PATCH 0/3] RISC-V SBI earlycon Anup Patel
@ 2018-12-04 13:55 ` Anup Patel
  2018-12-05  9:58   ` Greg Kroah-Hartman
                     ` (2 more replies)
  2018-12-04 13:55 ` [PATCH 2/3] RISC-V: defconfig: Enable RISC-V SBI earlycon support Anup Patel
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 20+ messages in thread
From: Anup Patel @ 2018-12-04 13:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Palmer Dabbelt, Albert Ou
  Cc: Rob Herring, Anup Patel, linux-kernel, Christoph Hellwig,
	Atish Patra, linux-serial, linux-riscv

In RISC-V, the M-mode runtime firmware provide SBI calls for
debug prints. This patch adds earlycon support using RISC-V
SBI console calls. To enable it, just pass "earlycon=sbi" in
kernel parameters.

Signed-off-by: Anup Patel <anup@brainfault.org>
---
 drivers/tty/serial/Kconfig              | 12 +++++++++++
 drivers/tty/serial/Makefile             |  1 +
 drivers/tty/serial/earlycon-riscv-sbi.c | 28 +++++++++++++++++++++++++
 3 files changed, 41 insertions(+)
 create mode 100644 drivers/tty/serial/earlycon-riscv-sbi.c

diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 32886c304641..287bb41ac814 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -85,6 +85,18 @@ config SERIAL_EARLYCON_ARM_SEMIHOST
 	  with "earlycon=smh" on the kernel command line. The console is
 	  enabled when early_param is processed.
 
+config SERIAL_EARLYCON_RISCV_SBI
+	bool "Early console using RISC-V SBI"
+	depends on RISCV
+	select SERIAL_CORE
+	select SERIAL_CORE_CONSOLE
+	select SERIAL_EARLYCON
+	help
+	  Support for early debug console using RISC-V SBI. This enables
+	  the console before standard serial driver is probed. This is enabled
+	  with "earlycon=sbi" on the kernel command line. The console is
+	  enabled when early_param is processed.
+
 config SERIAL_SB1250_DUART
 	tristate "BCM1xxx on-chip DUART serial support"
 	depends on SIBYTE_SB1xxx_SOC=y
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index daac675612df..3ce26ce08616 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_SERIAL_CORE) += serial_core.o
 
 obj-$(CONFIG_SERIAL_EARLYCON) += earlycon.o
 obj-$(CONFIG_SERIAL_EARLYCON_ARM_SEMIHOST) += earlycon-arm-semihost.o
+obj-$(CONFIG_SERIAL_EARLYCON_RISCV_SBI) += earlycon-riscv-sbi.o
 
 # These Sparc drivers have to appear before others such as 8250
 # which share ttySx minor node space.  Otherwise console device
diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c
new file mode 100644
index 000000000000..e1a551aae336
--- /dev/null
+++ b/drivers/tty/serial/earlycon-riscv-sbi.c
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * RISC-V SBI based earlycon
+ *
+ * Copyright (C) 2018 Anup Patel <anup@brainfault.org>
+ */
+#include <linux/kernel.h>
+#include <linux/console.h>
+#include <linux/init.h>
+#include <linux/serial_core.h>
+#include <asm/sbi.h>
+
+static void sbi_console_write(struct console *con,
+			      const char *s, unsigned int n)
+{
+	int i;
+
+	for (i = 0; i < n; ++i)
+		sbi_console_putchar(s[i]);
+}
+
+static int __init early_sbi_setup(struct earlycon_device *device,
+				  const char *opt)
+{
+	device->con->write = sbi_console_write;
+	return 0;
+}
+EARLYCON_DECLARE(sbi, early_sbi_setup);
-- 
2.17.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH 2/3] RISC-V: defconfig: Enable RISC-V SBI earlycon support
  2018-12-04 13:55 [PATCH 0/3] RISC-V SBI earlycon Anup Patel
  2018-12-04 13:55 ` [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support Anup Patel
@ 2018-12-04 13:55 ` Anup Patel
  2018-12-07 18:30   ` Palmer Dabbelt
  2018-12-04 13:55 ` [PATCH 3/3] RISC-V: Remove EARLY_PRINTK support Anup Patel
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 20+ messages in thread
From: Anup Patel @ 2018-12-04 13:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Palmer Dabbelt, Albert Ou
  Cc: Rob Herring, Anup Patel, linux-kernel, Christoph Hellwig,
	Atish Patra, linux-serial, linux-riscv

This patch enables RISC-V SBI earlycon support in default defconfig
so that we can use "earlycon=sbi" in kernel parameters for early
debug prints.

Signed-off-by: Anup Patel <anup@brainfault.org>
---
 arch/riscv/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig
index ef4f15df9adf..f399659d3b8d 100644
--- a/arch/riscv/configs/defconfig
+++ b/arch/riscv/configs/defconfig
@@ -46,6 +46,7 @@ CONFIG_INPUT_MOUSEDEV=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_SERIAL_EARLYCON_RISCV_SBI=y
 CONFIG_HVC_RISCV_SBI=y
 # CONFIG_PTP_1588_CLOCK is not set
 CONFIG_DRM=y
-- 
2.17.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH 3/3] RISC-V: Remove EARLY_PRINTK support
  2018-12-04 13:55 [PATCH 0/3] RISC-V SBI earlycon Anup Patel
  2018-12-04 13:55 ` [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support Anup Patel
  2018-12-04 13:55 ` [PATCH 2/3] RISC-V: defconfig: Enable RISC-V SBI earlycon support Anup Patel
@ 2018-12-04 13:55 ` Anup Patel
  2018-12-07 18:30   ` Palmer Dabbelt
  2018-12-07 18:30 ` [PATCH 0/3] RISC-V SBI earlycon Palmer Dabbelt
  2019-03-25 16:23 ` Andreas Schwab
  4 siblings, 1 reply; 20+ messages in thread
From: Anup Patel @ 2018-12-04 13:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Palmer Dabbelt, Albert Ou
  Cc: Rob Herring, Anup Patel, linux-kernel, Christoph Hellwig,
	Atish Patra, linux-serial, linux-riscv

The EARLY_PRINTK using SBI console calls is not required
any more because we now have RISC-V SBI support in generic
earlycon framework.

Signed-off-by: Anup Patel <anup@brainfault.org>
---
 arch/riscv/Kconfig.debug  |  2 --
 arch/riscv/kernel/setup.c | 28 ----------------------------
 2 files changed, 30 deletions(-)

diff --git a/arch/riscv/Kconfig.debug b/arch/riscv/Kconfig.debug
index c5a72f17c469..e69de29bb2d1 100644
--- a/arch/riscv/Kconfig.debug
+++ b/arch/riscv/Kconfig.debug
@@ -1,2 +0,0 @@
-config EARLY_PRINTK
-	def_bool y
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 2c290e6aaa6e..fc8006a042eb 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -35,31 +35,9 @@
 #include <asm/sections.h>
 #include <asm/pgtable.h>
 #include <asm/smp.h>
-#include <asm/sbi.h>
 #include <asm/tlbflush.h>
 #include <asm/thread_info.h>
 
-#ifdef CONFIG_EARLY_PRINTK
-static void sbi_console_write(struct console *co, const char *buf,
-			      unsigned int n)
-{
-	int i;
-
-	for (i = 0; i < n; ++i) {
-		if (buf[i] == '\n')
-			sbi_console_putchar('\r');
-		sbi_console_putchar(buf[i]);
-	}
-}
-
-struct console riscv_sbi_early_console_dev __initdata = {
-	.name	= "early",
-	.write	= sbi_console_write,
-	.flags	= CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
-	.index	= -1
-};
-#endif
-
 #ifdef CONFIG_DUMMY_CONSOLE
 struct screen_info screen_info = {
 	.orig_video_lines	= 30,
@@ -219,12 +197,6 @@ static void __init setup_bootmem(void)
 
 void __init setup_arch(char **cmdline_p)
 {
-#if defined(CONFIG_EARLY_PRINTK)
-       if (likely(early_console == NULL)) {
-               early_console = &riscv_sbi_early_console_dev;
-               register_console(early_console);
-       }
-#endif
 	*cmdline_p = boot_command_line;
 
 	parse_early_param();
-- 
2.17.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support
  2018-12-04 13:55 ` [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support Anup Patel
@ 2018-12-05  9:58   ` Greg Kroah-Hartman
  2018-12-07 18:45     ` Palmer Dabbelt
  2018-12-07 18:30   ` Palmer Dabbelt
  2019-01-10 14:07   ` [PATCH] tty/serial: emit CR before NL in RISC-V SBL console Andreas Schwab
  2 siblings, 1 reply; 20+ messages in thread
From: Greg Kroah-Hartman @ 2018-12-05  9:58 UTC (permalink / raw)
  To: Anup Patel
  Cc: Rob Herring, Albert Ou, Palmer Dabbelt, linux-kernel,
	Christoph Hellwig, Atish Patra, linux-serial, Jiri Slaby,
	linux-riscv

On Tue, Dec 04, 2018 at 07:25:05PM +0530, Anup Patel wrote:
> In RISC-V, the M-mode runtime firmware provide SBI calls for
> debug prints. This patch adds earlycon support using RISC-V
> SBI console calls. To enable it, just pass "earlycon=sbi" in
> kernel parameters.
> 
> Signed-off-by: Anup Patel <anup@brainfault.org>

This makes more sense to take through the riscv tree, so feel free to
add:

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

to it and take it that way.

thanks,

greg k-h

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support
  2018-12-04 13:55 ` [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support Anup Patel
  2018-12-05  9:58   ` Greg Kroah-Hartman
@ 2018-12-07 18:30   ` Palmer Dabbelt
  2019-01-10 14:07   ` [PATCH] tty/serial: emit CR before NL in RISC-V SBL console Andreas Schwab
  2 siblings, 0 replies; 20+ messages in thread
From: Palmer Dabbelt @ 2018-12-07 18:30 UTC (permalink / raw)
  To: anup
  Cc: robh, aou, Greg KH, anup, linux-kernel, Christoph Hellwig,
	atish.patra, linux-serial, jslaby, linux-riscv

On Tue, 04 Dec 2018 05:55:05 PST (-0800), anup@brainfault.org wrote:
> In RISC-V, the M-mode runtime firmware provide SBI calls for
> debug prints. This patch adds earlycon support using RISC-V
> SBI console calls. To enable it, just pass "earlycon=sbi" in
> kernel parameters.
>
> Signed-off-by: Anup Patel <anup@brainfault.org>
> ---
>  drivers/tty/serial/Kconfig              | 12 +++++++++++
>  drivers/tty/serial/Makefile             |  1 +
>  drivers/tty/serial/earlycon-riscv-sbi.c | 28 +++++++++++++++++++++++++
>  3 files changed, 41 insertions(+)
>  create mode 100644 drivers/tty/serial/earlycon-riscv-sbi.c
>
> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> index 32886c304641..287bb41ac814 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -85,6 +85,18 @@ config SERIAL_EARLYCON_ARM_SEMIHOST
>  	  with "earlycon=smh" on the kernel command line. The console is
>  	  enabled when early_param is processed.
>
> +config SERIAL_EARLYCON_RISCV_SBI
> +	bool "Early console using RISC-V SBI"
> +	depends on RISCV
> +	select SERIAL_CORE
> +	select SERIAL_CORE_CONSOLE
> +	select SERIAL_EARLYCON
> +	help
> +	  Support for early debug console using RISC-V SBI. This enables
> +	  the console before standard serial driver is probed. This is enabled
> +	  with "earlycon=sbi" on the kernel command line. The console is
> +	  enabled when early_param is processed.
> +
>  config SERIAL_SB1250_DUART
>  	tristate "BCM1xxx on-chip DUART serial support"
>  	depends on SIBYTE_SB1xxx_SOC=y
> diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
> index daac675612df..3ce26ce08616 100644
> --- a/drivers/tty/serial/Makefile
> +++ b/drivers/tty/serial/Makefile
> @@ -7,6 +7,7 @@ obj-$(CONFIG_SERIAL_CORE) += serial_core.o
>
>  obj-$(CONFIG_SERIAL_EARLYCON) += earlycon.o
>  obj-$(CONFIG_SERIAL_EARLYCON_ARM_SEMIHOST) += earlycon-arm-semihost.o
> +obj-$(CONFIG_SERIAL_EARLYCON_RISCV_SBI) += earlycon-riscv-sbi.o
>
>  # These Sparc drivers have to appear before others such as 8250
>  # which share ttySx minor node space.  Otherwise console device
> diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c
> new file mode 100644
> index 000000000000..e1a551aae336
> --- /dev/null
> +++ b/drivers/tty/serial/earlycon-riscv-sbi.c
> @@ -0,0 +1,28 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * RISC-V SBI based earlycon
> + *
> + * Copyright (C) 2018 Anup Patel <anup@brainfault.org>
> + */
> +#include <linux/kernel.h>
> +#include <linux/console.h>
> +#include <linux/init.h>
> +#include <linux/serial_core.h>
> +#include <asm/sbi.h>
> +
> +static void sbi_console_write(struct console *con,
> +			      const char *s, unsigned int n)
> +{
> +	int i;
> +
> +	for (i = 0; i < n; ++i)
> +		sbi_console_putchar(s[i]);
> +}
> +
> +static int __init early_sbi_setup(struct earlycon_device *device,
> +				  const char *opt)
> +{
> +	device->con->write = sbi_console_write;
> +	return 0;
> +}
> +EARLYCON_DECLARE(sbi, early_sbi_setup);

Reviewed-by: Palmer Dabbelt <palmer@sifive.com>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 2/3] RISC-V: defconfig: Enable RISC-V SBI earlycon support
  2018-12-04 13:55 ` [PATCH 2/3] RISC-V: defconfig: Enable RISC-V SBI earlycon support Anup Patel
@ 2018-12-07 18:30   ` Palmer Dabbelt
  0 siblings, 0 replies; 20+ messages in thread
From: Palmer Dabbelt @ 2018-12-07 18:30 UTC (permalink / raw)
  To: anup
  Cc: robh, aou, Greg KH, anup, linux-kernel, Christoph Hellwig,
	atish.patra, linux-serial, jslaby, linux-riscv

On Tue, 04 Dec 2018 05:55:06 PST (-0800), anup@brainfault.org wrote:
> This patch enables RISC-V SBI earlycon support in default defconfig
> so that we can use "earlycon=sbi" in kernel parameters for early
> debug prints.
>
> Signed-off-by: Anup Patel <anup@brainfault.org>
> ---
>  arch/riscv/configs/defconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig
> index ef4f15df9adf..f399659d3b8d 100644
> --- a/arch/riscv/configs/defconfig
> +++ b/arch/riscv/configs/defconfig
> @@ -46,6 +46,7 @@ CONFIG_INPUT_MOUSEDEV=y
>  CONFIG_SERIAL_8250=y
>  CONFIG_SERIAL_8250_CONSOLE=y
>  CONFIG_SERIAL_OF_PLATFORM=y
> +CONFIG_SERIAL_EARLYCON_RISCV_SBI=y
>  CONFIG_HVC_RISCV_SBI=y
>  # CONFIG_PTP_1588_CLOCK is not set
>  CONFIG_DRM=y

Reviewed-by: Palmer Dabbelt <palmer@sifive.com>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 3/3] RISC-V: Remove EARLY_PRINTK support
  2018-12-04 13:55 ` [PATCH 3/3] RISC-V: Remove EARLY_PRINTK support Anup Patel
@ 2018-12-07 18:30   ` Palmer Dabbelt
  0 siblings, 0 replies; 20+ messages in thread
From: Palmer Dabbelt @ 2018-12-07 18:30 UTC (permalink / raw)
  To: anup
  Cc: robh, aou, Greg KH, anup, linux-kernel, Christoph Hellwig,
	atish.patra, linux-serial, jslaby, linux-riscv

On Tue, 04 Dec 2018 05:55:07 PST (-0800), anup@brainfault.org wrote:
> The EARLY_PRINTK using SBI console calls is not required
> any more because we now have RISC-V SBI support in generic
> earlycon framework.
>
> Signed-off-by: Anup Patel <anup@brainfault.org>
> ---
>  arch/riscv/Kconfig.debug  |  2 --
>  arch/riscv/kernel/setup.c | 28 ----------------------------
>  2 files changed, 30 deletions(-)
>
> diff --git a/arch/riscv/Kconfig.debug b/arch/riscv/Kconfig.debug
> index c5a72f17c469..e69de29bb2d1 100644
> --- a/arch/riscv/Kconfig.debug
> +++ b/arch/riscv/Kconfig.debug
> @@ -1,2 +0,0 @@
> -config EARLY_PRINTK
> -	def_bool y
> diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
> index 2c290e6aaa6e..fc8006a042eb 100644
> --- a/arch/riscv/kernel/setup.c
> +++ b/arch/riscv/kernel/setup.c
> @@ -35,31 +35,9 @@
>  #include <asm/sections.h>
>  #include <asm/pgtable.h>
>  #include <asm/smp.h>
> -#include <asm/sbi.h>
>  #include <asm/tlbflush.h>
>  #include <asm/thread_info.h>
>
> -#ifdef CONFIG_EARLY_PRINTK
> -static void sbi_console_write(struct console *co, const char *buf,
> -			      unsigned int n)
> -{
> -	int i;
> -
> -	for (i = 0; i < n; ++i) {
> -		if (buf[i] == '\n')
> -			sbi_console_putchar('\r');
> -		sbi_console_putchar(buf[i]);
> -	}
> -}
> -
> -struct console riscv_sbi_early_console_dev __initdata = {
> -	.name	= "early",
> -	.write	= sbi_console_write,
> -	.flags	= CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
> -	.index	= -1
> -};
> -#endif
> -
>  #ifdef CONFIG_DUMMY_CONSOLE
>  struct screen_info screen_info = {
>  	.orig_video_lines	= 30,
> @@ -219,12 +197,6 @@ static void __init setup_bootmem(void)
>
>  void __init setup_arch(char **cmdline_p)
>  {
> -#if defined(CONFIG_EARLY_PRINTK)
> -       if (likely(early_console == NULL)) {
> -               early_console = &riscv_sbi_early_console_dev;
> -               register_console(early_console);
> -       }
> -#endif
>  	*cmdline_p = boot_command_line;
>
>  	parse_early_param();

Reviewed-by: Palmer Dabbelt <palmer@sifive.com>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 0/3] RISC-V SBI earlycon
  2018-12-04 13:55 [PATCH 0/3] RISC-V SBI earlycon Anup Patel
                   ` (2 preceding siblings ...)
  2018-12-04 13:55 ` [PATCH 3/3] RISC-V: Remove EARLY_PRINTK support Anup Patel
@ 2018-12-07 18:30 ` Palmer Dabbelt
  2019-03-25 16:23 ` Andreas Schwab
  4 siblings, 0 replies; 20+ messages in thread
From: Palmer Dabbelt @ 2018-12-07 18:30 UTC (permalink / raw)
  To: anup, Greg KH
  Cc: robh, aou, anup, linux-kernel, Christoph Hellwig, atish.patra,
	linux-serial, jslaby, linux-riscv

On Tue, 04 Dec 2018 05:55:04 PST (-0800), anup@brainfault.org wrote:
> This patchset adds RISC-V SBI earlycon and removes RISC-V EARLY_PRINTK.
>
> We should use earlycon over existing EARLY_PRINTK for SBI console because:
> 1. It's a more generic way of implementing early console for debugging
> 2. Current RISC-V EARLY_PRINTK is a compile-time option whereas earlycon
>    is enabled at run-time via kernel parameters.
> 3. To use earlycon with SBI, we have to pass "earlycon=sbi" in kernel
>    parameters. If earlycon kernel parameter is not provided then kernel
>    boots much faster which is very useful in real-world RISC-V deployments.
>
> The patchset is tested on QEMU virt machine. It is based on Linux-4.20-rc5
> and can be found at riscv_earlycon_v1 branch of:
> https://github.com/avpatel/linux.git
>
> Anup Patel (3):
>   tty/serial: Add RISC-V SBI earlycon support
>   RISC-V: defconfig: Enable RISC-V SBI earlycon support
>   RISC-V: Remove EARLY_PRINTK support
>
>  arch/riscv/Kconfig.debug                |  2 --
>  arch/riscv/configs/defconfig            |  1 +
>  arch/riscv/kernel/setup.c               | 28 -------------------------
>  drivers/tty/serial/Kconfig              | 12 +++++++++++
>  drivers/tty/serial/Makefile             |  1 +
>  drivers/tty/serial/earlycon-riscv-sbi.c | 28 +++++++++++++++++++++++++
>  6 files changed, 42 insertions(+), 30 deletions(-)
>  create mode 100644 drivers/tty/serial/earlycon-riscv-sbi.c

I'm adding these to my for-next.

Thanks!

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support
  2018-12-05  9:58   ` Greg Kroah-Hartman
@ 2018-12-07 18:45     ` Palmer Dabbelt
  0 siblings, 0 replies; 20+ messages in thread
From: Palmer Dabbelt @ 2018-12-07 18:45 UTC (permalink / raw)
  To: Greg KH
  Cc: robh, aou, anup, linux-kernel, Christoph Hellwig, atish.patra,
	linux-serial, jslaby, linux-riscv

On Wed, 05 Dec 2018 01:58:46 PST (-0800), Greg KH wrote:
> On Tue, Dec 04, 2018 at 07:25:05PM +0530, Anup Patel wrote:
>> In RISC-V, the M-mode runtime firmware provide SBI calls for
>> debug prints. This patch adds earlycon support using RISC-V
>> SBI console calls. To enable it, just pass "earlycon=sbi" in
>> kernel parameters.
>>
>> Signed-off-by: Anup Patel <anup@brainfault.org>
>
> This makes more sense to take through the riscv tree, so feel free to
> add:
>
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> to it and take it that way.

It should be in my for-next now.

Thanks!

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH] tty/serial: emit CR before NL in RISC-V SBL console
  2018-12-04 13:55 ` [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support Anup Patel
  2018-12-05  9:58   ` Greg Kroah-Hartman
  2018-12-07 18:30   ` Palmer Dabbelt
@ 2019-01-10 14:07   ` Andreas Schwab
  2019-01-10 15:16     ` Anup Patel
  2 siblings, 1 reply; 20+ messages in thread
From: Andreas Schwab @ 2019-01-10 14:07 UTC (permalink / raw)
  To: Anup Patel
  Cc: Rob Herring, Albert Ou, Greg Kroah-Hartman, Palmer Dabbelt,
	linux-kernel, Christoph Hellwig, Atish Patra, linux-serial,
	Jiri Slaby, linux-riscv

Signed-off-by: Andreas Schwab <schwab@suse.de>
---
 drivers/tty/serial/earlycon-riscv-sbi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c
index e1a551aae3..9c51b945b5 100644
--- a/drivers/tty/serial/earlycon-riscv-sbi.c
+++ b/drivers/tty/serial/earlycon-riscv-sbi.c
@@ -15,8 +15,11 @@ static void sbi_console_write(struct console *con,
 {
 	int i;
 
-	for (i = 0; i < n; ++i)
+	for (i = 0; i < n; ++i) {
+		if (s[i] == '\n')
+			sbi_console_putchar('\r');
 		sbi_console_putchar(s[i]);
+	}
 }
 
 static int __init early_sbi_setup(struct earlycon_device *device,
-- 
2.20.1

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] tty/serial: emit CR before NL in RISC-V SBL console
  2019-01-10 14:07   ` [PATCH] tty/serial: emit CR before NL in RISC-V SBL console Andreas Schwab
@ 2019-01-10 15:16     ` Anup Patel
  2019-01-10 15:26       ` Andreas Schwab
  0 siblings, 1 reply; 20+ messages in thread
From: Anup Patel @ 2019-01-10 15:16 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Rob Herring, Albert Ou, Greg Kroah-Hartman, Palmer Dabbelt,
	linux-kernel@vger.kernel.org List, Christoph Hellwig,
	Atish Patra, linux-serial, Jiri Slaby, linux-riscv

On Thu, Jan 10, 2019 at 7:37 PM Andreas Schwab <schwab@suse.de> wrote:
>
> Signed-off-by: Andreas Schwab <schwab@suse.de>
> ---
>  drivers/tty/serial/earlycon-riscv-sbi.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c
> index e1a551aae3..9c51b945b5 100644
> --- a/drivers/tty/serial/earlycon-riscv-sbi.c
> +++ b/drivers/tty/serial/earlycon-riscv-sbi.c
> @@ -15,8 +15,11 @@ static void sbi_console_write(struct console *con,
>  {
>         int i;
>
> -       for (i = 0; i < n; ++i)
> +       for (i = 0; i < n; ++i) {
> +               if (s[i] == '\n')
> +                       sbi_console_putchar('\r');

Instead of doing '\n' handling here, we should do it in BBL or
OpenSBI (i.e. SBI runtime firmware) otherwise all users of
SBI_CONSOLE_PUTCHAR (namely, Linux, FreeBSD,
FreeRTOS, U-Boot S-mode, etc) will endup having '\n'
handling.

Currently, the BBL does not handle it but we have already
handled this in upcoming OpenSBI.

The SBI_CONSOLE_PUTCHAR is comparable to ARM
semihosting early prints (refer, tty/serial/earlycon-arm-semihost.c).
Even in ARM semihosting early prints the '\n' is not explicitly
handled.

Regards,
Anup

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] tty/serial: emit CR before NL in RISC-V SBL console
  2019-01-10 15:16     ` Anup Patel
@ 2019-01-10 15:26       ` Andreas Schwab
  2019-01-10 16:17         ` Anup Patel
  0 siblings, 1 reply; 20+ messages in thread
From: Andreas Schwab @ 2019-01-10 15:26 UTC (permalink / raw)
  To: Anup Patel
  Cc: Rob Herring, Albert Ou, Greg Kroah-Hartman, Palmer Dabbelt,
	linux-kernel@vger.kernel.org List, Christoph Hellwig,
	Atish Patra, linux-serial, Jiri Slaby, linux-riscv

On Jan 10 2019, Anup Patel <anup@brainfault.org> wrote:

> Instead of doing '\n' handling here, we should do it in BBL or
> OpenSBI (i.e. SBI runtime firmware) otherwise all users of
> SBI_CONSOLE_PUTCHAR (namely, Linux, FreeBSD,
> FreeRTOS, U-Boot S-mode, etc) will endup having '\n'
> handling.

I don't think the serial driver should do NLCR handling on its own,
without being instructed by the tty layer.  Since the earlycon does not
have a tty layer, it needs to handle it explicitly.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] tty/serial: emit CR before NL in RISC-V SBL console
  2019-01-10 15:26       ` Andreas Schwab
@ 2019-01-10 16:17         ` Anup Patel
  2019-01-10 17:11           ` [PATCH] tty/serial: use uart_console_write in the RISC-V SBL early console Andreas Schwab
  2019-01-10 20:54           ` [PATCH] tty/serial: emit CR before NL in RISC-V SBL console Palmer Dabbelt
  0 siblings, 2 replies; 20+ messages in thread
From: Anup Patel @ 2019-01-10 16:17 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Rob Herring, Albert Ou, Greg Kroah-Hartman, Palmer Dabbelt,
	linux-kernel@vger.kernel.org List, Christoph Hellwig,
	Atish Patra, linux-serial, Jiri Slaby, linux-riscv

On Thu, Jan 10, 2019 at 8:56 PM Andreas Schwab <schwab@suse.de> wrote:
>
> On Jan 10 2019, Anup Patel <anup@brainfault.org> wrote:
>
> > Instead of doing '\n' handling here, we should do it in BBL or
> > OpenSBI (i.e. SBI runtime firmware) otherwise all users of
> > SBI_CONSOLE_PUTCHAR (namely, Linux, FreeBSD,
> > FreeRTOS, U-Boot S-mode, etc) will endup having '\n'
> > handling.
>
> I don't think the serial driver should do NLCR handling on its own,
> without being instructed by the tty layer.  Since the earlycon does not
> have a tty layer, it needs to handle it explicitly.

I tried to investigate more. What you suggest is correct
but we should use uart_console_write() API.

Instead of explicitly doing NLCR here, we should do
something as follows:

static void sbi_putc(struct uart_port *port, int c)
{
    sbi_console_putchar(c);
}

static void sbi_console_write(struct console *con,
                                               const char *s, unsigned n)
{
    struct earlycon_device *dev = con->data;
    uart_console_write(&dev->port, s, n, sbi_putc);
}

The uart_console_write() does the NLCR handling.

Regards,
Anup

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH] tty/serial: use uart_console_write in the RISC-V SBL early console
  2019-01-10 16:17         ` Anup Patel
@ 2019-01-10 17:11           ` Andreas Schwab
  2019-01-11 11:13             ` Anup Patel
  2019-01-15 13:59             ` Christoph Hellwig
  2019-01-10 20:54           ` [PATCH] tty/serial: emit CR before NL in RISC-V SBL console Palmer Dabbelt
  1 sibling, 2 replies; 20+ messages in thread
From: Andreas Schwab @ 2019-01-10 17:11 UTC (permalink / raw)
  To: Anup Patel
  Cc: Rob Herring, Albert Ou, Greg Kroah-Hartman, Palmer Dabbelt,
	linux-kernel@vger.kernel.org List, Christoph Hellwig,
	Atish Patra, linux-serial, Jiri Slaby, linux-riscv

This enables proper NLCR processing.

Suggested-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Andreas Schwab <schwab@suse.de>
---
 drivers/tty/serial/earlycon-riscv-sbi.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c
index e1a551aae3..ce81523c31 100644
--- a/drivers/tty/serial/earlycon-riscv-sbi.c
+++ b/drivers/tty/serial/earlycon-riscv-sbi.c
@@ -10,13 +10,16 @@
 #include <linux/serial_core.h>
 #include <asm/sbi.h>
 
-static void sbi_console_write(struct console *con,
-			      const char *s, unsigned int n)
+static void sbi_putc(struct uart_port *port, int c)
 {
-	int i;
+	sbi_console_putchar(c);
+}
 
-	for (i = 0; i < n; ++i)
-		sbi_console_putchar(s[i]);
+static void sbi_console_write(struct console *con,
+			      const char *s, unsigned n)
+{
+	struct earlycon_device *dev = con->data;
+	uart_console_write(&dev->port, s, n, sbi_putc);
 }
 
 static int __init early_sbi_setup(struct earlycon_device *device,
-- 
2.20.1

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] tty/serial: emit CR before NL in RISC-V SBL console
  2019-01-10 16:17         ` Anup Patel
  2019-01-10 17:11           ` [PATCH] tty/serial: use uart_console_write in the RISC-V SBL early console Andreas Schwab
@ 2019-01-10 20:54           ` Palmer Dabbelt
  1 sibling, 0 replies; 20+ messages in thread
From: Palmer Dabbelt @ 2019-01-10 20:54 UTC (permalink / raw)
  To: schwab, anup
  Cc: robh, aou, Greg KH, linux-kernel, Christoph Hellwig, atish.patra,
	linux-serial, jslaby, linux-riscv

On Thu, 10 Jan 2019 07:26:46 PST (-0800), schwab@suse.de wrote:
> On Jan 10 2019, Anup Patel <anup@brainfault.org> wrote:
>
>> Instead of doing '\n' handling here, we should do it in BBL or
>> OpenSBI (i.e. SBI runtime firmware) otherwise all users of
>> SBI_CONSOLE_PUTCHAR (namely, Linux, FreeBSD,
>> FreeRTOS, U-Boot S-mode, etc) will endup having '\n'
>> handling.
>
> I don't think the serial driver should do NLCR handling on its own,
> without being instructed by the tty layer.  Since the earlycon does not
> have a tty layer, it needs to handle it explicitly.

I think it's best if we have the SBI interfaces be defined to be bit-exact.  It
does mean that everyone who uses the interfaces needs to do this handling, but
I think that's actually a feature because it'll be subtly different everywhere.

This also has the advantage of being compatible with what we currently do in
BBL and what we current expect in Linux everywhere but this earlycon driver
(and will do assuming we merge this patch).

On Thu, 10 Jan 2019 08:17:07 PST (-0800), anup@brainfault.org wrote:
> On Thu, Jan 10, 2019 at 8:56 PM Andreas Schwab <schwab@suse.de> wrote:
>>
>> On Jan 10 2019, Anup Patel <anup@brainfault.org> wrote:
>>
>> > Instead of doing '\n' handling here, we should do it in BBL or
>> > OpenSBI (i.e. SBI runtime firmware) otherwise all users of
>> > SBI_CONSOLE_PUTCHAR (namely, Linux, FreeBSD,
>> > FreeRTOS, U-Boot S-mode, etc) will endup having '\n'
>> > handling.
>>
>> I don't think the serial driver should do NLCR handling on its own,
>> without being instructed by the tty layer.  Since the earlycon does not
>> have a tty layer, it needs to handle it explicitly.
>
> I tried to investigate more. What you suggest is correct
> but we should use uart_console_write() API.
>
> Instead of explicitly doing NLCR here, we should do
> something as follows:
>
> static void sbi_putc(struct uart_port *port, int c)
> {
>     sbi_console_putchar(c);
> }
>
> static void sbi_console_write(struct console *con,
>                                                const char *s, unsigned n)
> {
>     struct earlycon_device *dev = con->data;
>     uart_console_write(&dev->port, s, n, sbi_putc);
> }
>
> The uart_console_write() does the NLCR handling.

That does look cleaner.  I'll expect a v2 :)

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] tty/serial: use uart_console_write in the RISC-V SBL early console
  2019-01-10 17:11           ` [PATCH] tty/serial: use uart_console_write in the RISC-V SBL early console Andreas Schwab
@ 2019-01-11 11:13             ` Anup Patel
  2019-01-23 23:58               ` Palmer Dabbelt
  2019-01-15 13:59             ` Christoph Hellwig
  1 sibling, 1 reply; 20+ messages in thread
From: Anup Patel @ 2019-01-11 11:13 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Rob Herring, Albert Ou, Greg Kroah-Hartman, Palmer Dabbelt,
	linux-kernel@vger.kernel.org List, Christoph Hellwig,
	Atish Patra, linux-serial, Jiri Slaby, linux-riscv

On Thu, Jan 10, 2019 at 10:41 PM Andreas Schwab <schwab@suse.de> wrote:
>
> This enables proper NLCR processing.
>
> Suggested-by: Anup Patel <anup@brainfault.org>
> Signed-off-by: Andreas Schwab <schwab@suse.de>
> ---
>  drivers/tty/serial/earlycon-riscv-sbi.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c
> index e1a551aae3..ce81523c31 100644
> --- a/drivers/tty/serial/earlycon-riscv-sbi.c
> +++ b/drivers/tty/serial/earlycon-riscv-sbi.c
> @@ -10,13 +10,16 @@
>  #include <linux/serial_core.h>
>  #include <asm/sbi.h>
>
> -static void sbi_console_write(struct console *con,
> -                             const char *s, unsigned int n)
> +static void sbi_putc(struct uart_port *port, int c)
>  {
> -       int i;
> +       sbi_console_putchar(c);
> +}
>
> -       for (i = 0; i < n; ++i)
> -               sbi_console_putchar(s[i]);
> +static void sbi_console_write(struct console *con,
> +                             const char *s, unsigned n)
> +{
> +       struct earlycon_device *dev = con->data;
> +       uart_console_write(&dev->port, s, n, sbi_putc);
>  }
>
>  static int __init early_sbi_setup(struct earlycon_device *device,
> --
> 2.20.1
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."

Looks good to me.

Reviewed-by: Anup Patel <anup@brainfault.org>

Regards,
Anup

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] tty/serial: use uart_console_write in the RISC-V SBL early console
  2019-01-10 17:11           ` [PATCH] tty/serial: use uart_console_write in the RISC-V SBL early console Andreas Schwab
  2019-01-11 11:13             ` Anup Patel
@ 2019-01-15 13:59             ` Christoph Hellwig
  1 sibling, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2019-01-15 13:59 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Rob Herring, Albert Ou, Anup Patel, Palmer Dabbelt,
	linux-kernel@vger.kernel.org List, Christoph Hellwig,
	Atish Patra, linux-serial, Greg Kroah-Hartman, Jiri Slaby,
	linux-riscv

On Thu, Jan 10, 2019 at 06:11:39PM +0100, Andreas Schwab wrote:
> This enables proper NLCR processing.
> 
> Suggested-by: Anup Patel <anup@brainfault.org>
> Signed-off-by: Andreas Schwab <schwab@suse.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] tty/serial: use uart_console_write in the RISC-V SBL early console
  2019-01-11 11:13             ` Anup Patel
@ 2019-01-23 23:58               ` Palmer Dabbelt
  0 siblings, 0 replies; 20+ messages in thread
From: Palmer Dabbelt @ 2019-01-23 23:58 UTC (permalink / raw)
  To: anup
  Cc: robh, aou, Greg KH, schwab, linux-kernel, Christoph Hellwig,
	atish.patra, linux-serial, jslaby, linux-riscv

On Fri, 11 Jan 2019 03:13:30 PST (-0800), anup@brainfault.org wrote:
> On Thu, Jan 10, 2019 at 10:41 PM Andreas Schwab <schwab@suse.de> wrote:
>>
>> This enables proper NLCR processing.
>>
>> Suggested-by: Anup Patel <anup@brainfault.org>
>> Signed-off-by: Andreas Schwab <schwab@suse.de>
>> ---
>>  drivers/tty/serial/earlycon-riscv-sbi.c | 13 ++++++++-----
>>  1 file changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c
>> index e1a551aae3..ce81523c31 100644
>> --- a/drivers/tty/serial/earlycon-riscv-sbi.c
>> +++ b/drivers/tty/serial/earlycon-riscv-sbi.c
>> @@ -10,13 +10,16 @@
>>  #include <linux/serial_core.h>
>>  #include <asm/sbi.h>
>>
>> -static void sbi_console_write(struct console *con,
>> -                             const char *s, unsigned int n)
>> +static void sbi_putc(struct uart_port *port, int c)
>>  {
>> -       int i;
>> +       sbi_console_putchar(c);
>> +}
>>
>> -       for (i = 0; i < n; ++i)
>> -               sbi_console_putchar(s[i]);
>> +static void sbi_console_write(struct console *con,
>> +                             const char *s, unsigned n)
>> +{
>> +       struct earlycon_device *dev = con->data;
>> +       uart_console_write(&dev->port, s, n, sbi_putc);
>>  }
>>
>>  static int __init early_sbi_setup(struct earlycon_device *device,
>> --
>> 2.20.1
>>
>> --
>> Andreas Schwab, SUSE Labs, schwab@suse.de
>> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
>> "And now for something completely different."
>
> Looks good to me.
>
> Reviewed-by: Anup Patel <anup@brainfault.org>
>
> Regards,
> Anup

Thanks.  I'm going to include this in my next PR, as it's pretty self contained 
and is necessary to actually use this sanely.

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 0/3] RISC-V SBI earlycon
  2018-12-04 13:55 [PATCH 0/3] RISC-V SBI earlycon Anup Patel
                   ` (3 preceding siblings ...)
  2018-12-07 18:30 ` [PATCH 0/3] RISC-V SBI earlycon Palmer Dabbelt
@ 2019-03-25 16:23 ` Andreas Schwab
  4 siblings, 0 replies; 20+ messages in thread
From: Andreas Schwab @ 2019-03-25 16:23 UTC (permalink / raw)
  To: Anup Patel
  Cc: Rob Herring, Albert Ou, Greg Kroah-Hartman, Palmer Dabbelt,
	linux-kernel, Christoph Hellwig, Atish Patra, linux-serial,
	Jiri Slaby, linux-riscv

On Dez 04 2018, Anup Patel <anup@brainfault.org> wrote:

> This patchset adds RISC-V SBI earlycon and removes RISC-V EARLY_PRINTK.
>
> We should use earlycon over existing EARLY_PRINTK for SBI console because:
> 1. It's a more generic way of implementing early console for debugging
> 2. Current RISC-V EARLY_PRINTK is a compile-time option whereas earlycon
>    is enabled at run-time via kernel parameters.
> 3. To use earlycon with SBI, we have to pass "earlycon=sbi" in kernel
>    parameters. If earlycon kernel parameter is not provided then kernel
>    boots much faster which is very useful in real-world RISC-V deployments.

Why doesn't this earlycon disable itself when the real console kicks in?

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, back to index

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-04 13:55 [PATCH 0/3] RISC-V SBI earlycon Anup Patel
2018-12-04 13:55 ` [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support Anup Patel
2018-12-05  9:58   ` Greg Kroah-Hartman
2018-12-07 18:45     ` Palmer Dabbelt
2018-12-07 18:30   ` Palmer Dabbelt
2019-01-10 14:07   ` [PATCH] tty/serial: emit CR before NL in RISC-V SBL console Andreas Schwab
2019-01-10 15:16     ` Anup Patel
2019-01-10 15:26       ` Andreas Schwab
2019-01-10 16:17         ` Anup Patel
2019-01-10 17:11           ` [PATCH] tty/serial: use uart_console_write in the RISC-V SBL early console Andreas Schwab
2019-01-11 11:13             ` Anup Patel
2019-01-23 23:58               ` Palmer Dabbelt
2019-01-15 13:59             ` Christoph Hellwig
2019-01-10 20:54           ` [PATCH] tty/serial: emit CR before NL in RISC-V SBL console Palmer Dabbelt
2018-12-04 13:55 ` [PATCH 2/3] RISC-V: defconfig: Enable RISC-V SBI earlycon support Anup Patel
2018-12-07 18:30   ` Palmer Dabbelt
2018-12-04 13:55 ` [PATCH 3/3] RISC-V: Remove EARLY_PRINTK support Anup Patel
2018-12-07 18:30   ` Palmer Dabbelt
2018-12-07 18:30 ` [PATCH 0/3] RISC-V SBI earlycon Palmer Dabbelt
2019-03-25 16:23 ` Andreas Schwab

Linux-RISC-V Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-riscv/0 linux-riscv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-riscv linux-riscv/ https://lore.kernel.org/linux-riscv \
		linux-riscv@lists.infradead.org infradead-linux-riscv@archiver.kernel.org
	public-inbox-index linux-riscv

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-riscv


AGPL code for this site: git clone https://public-inbox.org/ public-inbox