* [kvm-unit-tests PATCH v2] riscv: Allow SBI_CONSOLE with no uart in device tree
@ 2025-06-13 15:03 Jesse Taube
2025-06-13 16:27 ` Andrew Jones
2025-07-02 14:46 ` Andrew Jones
0 siblings, 2 replies; 3+ messages in thread
From: Jesse Taube @ 2025-06-13 15:03 UTC (permalink / raw)
To: kvm, kvm-riscv, linux-kselftest
Cc: Atish Patra, Anup Patel, Palmer Dabbelt, Clément Léger,
Himanshu Chauhan, Charlie Jenkins, Jesse Taube, Andrew Jones
When CONFIG_SBI_CONSOLE is enabled and there is no uart defined in the
device tree kvm-unit-tests fails to start.
Only abort when uart is not found in device tree if SBI_CONSOLE is false
Signed-off-by: Jesse Taube <jesse@rivosinc.com>
---
lib/riscv/io.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/lib/riscv/io.c b/lib/riscv/io.c
index fb40adb7..e64e9253 100644
--- a/lib/riscv/io.c
+++ b/lib/riscv/io.c
@@ -30,7 +30,6 @@ static u32 uart0_reg_width = 1;
static u32 uart0_reg_shift;
static struct spinlock uart_lock;
-#ifndef CONFIG_SBI_CONSOLE
static u32 uart0_read(u32 num)
{
u32 offset = num << uart0_reg_shift;
@@ -54,7 +53,6 @@ static void uart0_write(u32 num, u32 val)
else
writel(val, uart0_base + offset);
}
-#endif
static void uart0_init_fdt(void)
{
@@ -73,11 +71,16 @@ static void uart0_init_fdt(void)
break;
}
+#ifdef CONFIG_SBI_CONSOLE
+ uart0_base = NULL;
+ return;
+#else
if (ret) {
printf("%s: Compatible uart not found in the device tree, aborting...\n",
__func__);
abort();
}
+#endif
} else {
const fdt32_t *val;
int len;
@@ -116,8 +119,8 @@ void io_init(void)
}
}
-#ifdef CONFIG_SBI_CONSOLE
-void puts(const char *s)
+void sbi_puts(const char *s);
+void sbi_puts(const char *s)
{
phys_addr_t addr = virt_to_phys((void *)s);
unsigned long hi = upper_32_bits(addr);
@@ -127,9 +130,11 @@ void puts(const char *s)
sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRITE, strlen(s), lo, hi, 0, 0, 0);
spin_unlock(&uart_lock);
}
-#else
-void puts(const char *s)
+
+void uart0_puts(const char *s);
+void uart0_puts(const char *s)
{
+ assert(uart0_base);
spin_lock(&uart_lock);
while (*s) {
while (!(uart0_read(UART_LSR_OFFSET) & UART_LSR_THRE))
@@ -138,7 +143,15 @@ void puts(const char *s)
}
spin_unlock(&uart_lock);
}
+
+void puts(const char *s)
+{
+#ifdef CONFIG_SBI_CONSOLE
+ sbi_puts(s);
+#else
+ uart0_puts(s);
#endif
+}
/*
* Defining halt to take 'code' as an argument guarantees that it will
--
2.43.0
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [kvm-unit-tests PATCH v2] riscv: Allow SBI_CONSOLE with no uart in device tree
2025-06-13 15:03 [kvm-unit-tests PATCH v2] riscv: Allow SBI_CONSOLE with no uart in device tree Jesse Taube
@ 2025-06-13 16:27 ` Andrew Jones
2025-07-02 14:46 ` Andrew Jones
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Jones @ 2025-06-13 16:27 UTC (permalink / raw)
To: Jesse Taube
Cc: kvm, kvm-riscv, linux-kselftest, Atish Patra, Anup Patel,
Palmer Dabbelt, Clément Léger, Himanshu Chauhan,
Charlie Jenkins
On Fri, Jun 13, 2025 at 08:03:13AM -0700, Jesse Taube wrote:
> When CONFIG_SBI_CONSOLE is enabled and there is no uart defined in the
> device tree kvm-unit-tests fails to start.
>
> Only abort when uart is not found in device tree if SBI_CONSOLE is false
>
> Signed-off-by: Jesse Taube <jesse@rivosinc.com>
> ---
> lib/riscv/io.c | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>
Applied to riscv/sbi
https://gitlab.com/jones-drew/kvm-unit-tests/-/commits/riscv/sbi
Thanks,
drew
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [kvm-unit-tests PATCH v2] riscv: Allow SBI_CONSOLE with no uart in device tree
2025-06-13 15:03 [kvm-unit-tests PATCH v2] riscv: Allow SBI_CONSOLE with no uart in device tree Jesse Taube
2025-06-13 16:27 ` Andrew Jones
@ 2025-07-02 14:46 ` Andrew Jones
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Jones @ 2025-07-02 14:46 UTC (permalink / raw)
To: Jesse Taube
Cc: kvm, kvm-riscv, linux-kselftest, Atish Patra, Anup Patel,
Palmer Dabbelt, Clément Léger, Himanshu Chauhan,
Charlie Jenkins
On Fri, Jun 13, 2025 at 08:03:13AM -0700, Jesse Taube wrote:
> When CONFIG_SBI_CONSOLE is enabled and there is no uart defined in the
> device tree kvm-unit-tests fails to start.
>
> Only abort when uart is not found in device tree if SBI_CONSOLE is false
>
> Signed-off-by: Jesse Taube <jesse@rivosinc.com>
> ---
> lib/riscv/io.c | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>
Merged. Thanks
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-02 16:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-13 15:03 [kvm-unit-tests PATCH v2] riscv: Allow SBI_CONSOLE with no uart in device tree Jesse Taube
2025-06-13 16:27 ` Andrew Jones
2025-07-02 14:46 ` Andrew Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).