[PATCH v2] riscv: Move virtio scan to board_late_init()

2024-03-28 Thread Łukasz Stelmach
When virtio_init() gets called from board_init() PCI isn't ready. Thus,
virtio-over-PCI (e.g. network interfaces) devices can't be detected and
used without additional `virtio scan` scan in the shell or a script.

Signed-off-by: Łukasz Stelmach 
---
Changes since v1:
 - remove virtio_init() call from board_init()
 - select BOARD_LATE_INIT for TARGET_QEMU_VIRT

 arch/riscv/Kconfig  |  1 +
 board/emulation/qemu-riscv/qemu-riscv.c | 12 ++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index ac52c5e6daf..c5c2e8a9c9d 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -22,6 +22,7 @@ config TARGET_OPENPITON_RISCV64
 
 config TARGET_QEMU_VIRT
bool "Support QEMU Virt Board"
+   select BOARD_LATE_INIT
 
 config TARGET_SIFIVE_UNLEASHED
bool "Support SiFive Unleashed Board"
diff --git a/board/emulation/qemu-riscv/qemu-riscv.c 
b/board/emulation/qemu-riscv/qemu-riscv.c
index 181abbbf97d..173245b40e3 100644
--- a/board/emulation/qemu-riscv/qemu-riscv.c
+++ b/board/emulation/qemu-riscv/qemu-riscv.c
@@ -31,12 +31,6 @@ int is_flash_available(void)
 
 int board_init(void)
 {
-   /*
-* Make sure virtio bus is enumerated so that peripherals
-* on the virtio bus can be discovered by their drivers
-*/
-   virtio_init();
-
return 0;
 }
 
@@ -46,6 +40,12 @@ int board_late_init(void)
if (CONFIG_IS_ENABLED(USB_KEYBOARD))
usb_init();
 
+   /*
+* Make sure virtio bus is enumerated so that peripherals
+* on the virtio bus can be discovered by their drivers
+*/
+   virtio_init();
+
return 0;
 }
 
-- 
2.39.2



[PATCH] riscv: Repeat virtio scan

2024-02-19 Thread Łukasz Stelmach
The first time virtio_init() gets called from board_init() PCI isn't
ready. Thus any virtio-over-PCI (e.g. network interfaces) devices can't
be detected and used without additional `virtio scan` scan in the shell
or a script.

Signed-off-by: Łukasz Stelmach 
---
The patch works for my but:

a) maybe virtio_init() should called only from board_init() the same
   way as on ARM?

b) can a repeated virtio_init() break already detected/initialized
   devices?

 board/emulation/qemu-riscv/qemu-riscv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/board/emulation/qemu-riscv/qemu-riscv.c 
b/board/emulation/qemu-riscv/qemu-riscv.c
index 181abbbf97d..567b9dc6170 100644
--- a/board/emulation/qemu-riscv/qemu-riscv.c
+++ b/board/emulation/qemu-riscv/qemu-riscv.c
@@ -46,6 +46,9 @@ int board_late_init(void)
if (CONFIG_IS_ENABLED(USB_KEYBOARD))
usb_init();
 
+   /* Repeat virtio scan to detect PCI attached virtio devices. */
+   virtio_init();
+
return 0;
 }
 
-- 
2.39.2



[PATCH] setexpr: Silence some diagnostic messages

2023-08-24 Thread Łukasz Stelmach
Neither successful match nor lack thereof should be considered an
extraordinary situation. Thus, neither require printing a message.

Signed-off-by: Łukasz Stelmach 
---
 cmd/setexpr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmd/setexpr.c b/cmd/setexpr.c
index 4d671e7ef1..233471f6cb 100644
--- a/cmd/setexpr.c
+++ b/cmd/setexpr.c
@@ -215,7 +215,7 @@ int setexpr_regex_sub(char *data, uint data_size, char 
*nbuf, uint nbuf_size,
 
if (res == 0) {
if (loop == 0) {
-   printf("%s: No match\n", data);
+   debug("%s: No match\n", data);
return 1;
} else {
break;
@@ -359,7 +359,7 @@ static int regex_sub_var(const char *name, const char *r, 
const char *s,
if (ret)
return 1;
 
-   printf("%s=%s\n", name, data);
+   debug("%s=%s\n", name, data);
 
return env_set(name, data);
 }
-- 
2.39.2