2024-03-26 20:41:54

by Jiaxun Yang

[permalink] [raw]
Subject: [PATCH v2 3/9] MIPS: debug: Hook up DEBUG_LL with early printk

Output earlyprintk to low-level debug functions when it's
available.

DEBUG_LL takes priority over platform earlyprintk because
people must know what are they doing when they are trying
to enable DEBUG_LL.

Signed-off-by: Jiaxun Yang <[email protected]>
---
arch/mips/Kconfig.debug | 2 +-
arch/mips/kernel/early_printk.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
index 892e31804982..6ef42edc7d67 100644
--- a/arch/mips/Kconfig.debug
+++ b/arch/mips/Kconfig.debug
@@ -2,7 +2,7 @@

config EARLY_PRINTK
bool "Early printk" if EXPERT
- depends on SYS_HAS_EARLY_PRINTK
+ depends on SYS_HAS_EARLY_PRINTK || DEBUG_LL
default y
help
This option enables special console drivers which allow the kernel
diff --git a/arch/mips/kernel/early_printk.c b/arch/mips/kernel/early_printk.c
index 4a1647ddfbd9..c3f3b0a930f0 100644
--- a/arch/mips/kernel/early_printk.c
+++ b/arch/mips/kernel/early_printk.c
@@ -14,6 +14,24 @@

#include <asm/setup.h>

+#ifdef CONFIG_DEBUG_LL
+extern void printascii(const char *);
+
+static void early_console_write(struct console *con, const char *s, unsigned n)
+{
+ char buf[128];
+
+ while (n) {
+ unsigned int l = min(n, sizeof(buf)-1);
+
+ memcpy(buf, s, l);
+ buf[l] = 0;
+ s += l;
+ n -= l;
+ printascii(buf);
+ }
+}
+#else
static void early_console_write(struct console *con, const char *s, unsigned n)
{
while (n-- && *s) {
@@ -23,6 +41,7 @@ static void early_console_write(struct console *con, const char *s, unsigned n)
s++;
}
}
+#endif

static struct console early_console_prom = {
.name = "early",

--
2.34.1



2024-04-08 06:47:36

by Philippe Mathieu-Daudé

[permalink] [raw]
Subject: Re: [PATCH v2 3/9] MIPS: debug: Hook up DEBUG_LL with early printk

On 26/3/24 21:35, Jiaxun Yang wrote:
> Output earlyprintk to low-level debug functions when it's
> available.
>
> DEBUG_LL takes priority over platform earlyprintk because
> people must know what are they doing when they are trying
> to enable DEBUG_LL.
>
> Signed-off-by: Jiaxun Yang <[email protected]>
> ---
> arch/mips/Kconfig.debug | 2 +-
> arch/mips/kernel/early_printk.c | 19 +++++++++++++++++++
> 2 files changed, 20 insertions(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>