All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
@ 2019-02-10 20:17 ` Lukas Auer
  0 siblings, 0 replies; 21+ messages in thread
From: Lukas Auer @ 2019-02-10 20:17 UTC (permalink / raw)
  To: qemu-devel, qemu-riscv
  Cc: Lukas Auer, Alistair Francis, Palmer Dabbelt, Michael Clark,
	Bastian Koppelmann, Sagar Karandikar

Re-add the previous compatible string "riscv-virtio-soc" to the soc
device tree node to allow U-Boot and Linux to bind machine-specific
drivers to it. The current compatible string "simple-bus" is retained.

This is required by U-Boot to bind devices early, as part of the
pre-relocation driver model.

Fixes: 53f54508dae6("hw/riscv/virtio: Set the soc device tree node as a
simple-bus")
Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
---

 hw/riscv/virt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 3e8b19c668..c53bb905ff 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -157,6 +157,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
     char *nodename;
     uint32_t plic_phandle, phandle = 1;
     int i;
+    const char soc_compat[] = "riscv-virtio-soc\0simple-bus";
 
     fdt = s->fdt = create_device_tree(&s->fdt_size);
     if (!fdt) {
@@ -171,7 +172,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
 
     qemu_fdt_add_subnode(fdt, "/soc");
     qemu_fdt_setprop(fdt, "/soc", "ranges", NULL, 0);
-    qemu_fdt_setprop_string(fdt, "/soc", "compatible", "simple-bus");
+    qemu_fdt_setprop(fdt, "/soc", "compatible", soc_compat, sizeof(soc_compat));
     qemu_fdt_setprop_cell(fdt, "/soc", "#size-cells", 0x2);
     qemu_fdt_setprop_cell(fdt, "/soc", "#address-cells", 0x2);
 
-- 
2.20.1

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

* [Qemu-riscv] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
@ 2019-02-10 20:17 ` Lukas Auer
  0 siblings, 0 replies; 21+ messages in thread
From: Lukas Auer @ 2019-02-10 20:17 UTC (permalink / raw)
  To: qemu-devel, qemu-riscv
  Cc: Lukas Auer, Alistair Francis, Palmer Dabbelt, Michael Clark,
	Bastian Koppelmann, Sagar Karandikar

Re-add the previous compatible string "riscv-virtio-soc" to the soc
device tree node to allow U-Boot and Linux to bind machine-specific
drivers to it. The current compatible string "simple-bus" is retained.

This is required by U-Boot to bind devices early, as part of the
pre-relocation driver model.

Fixes: 53f54508dae6("hw/riscv/virtio: Set the soc device tree node as a
simple-bus")
Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
---

 hw/riscv/virt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 3e8b19c668..c53bb905ff 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -157,6 +157,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
     char *nodename;
     uint32_t plic_phandle, phandle = 1;
     int i;
+    const char soc_compat[] = "riscv-virtio-soc\0simple-bus";
 
     fdt = s->fdt = create_device_tree(&s->fdt_size);
     if (!fdt) {
@@ -171,7 +172,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
 
     qemu_fdt_add_subnode(fdt, "/soc");
     qemu_fdt_setprop(fdt, "/soc", "ranges", NULL, 0);
-    qemu_fdt_setprop_string(fdt, "/soc", "compatible", "simple-bus");
+    qemu_fdt_setprop(fdt, "/soc", "compatible", soc_compat, sizeof(soc_compat));
     qemu_fdt_setprop_cell(fdt, "/soc", "#size-cells", 0x2);
     qemu_fdt_setprop_cell(fdt, "/soc", "#address-cells", 0x2);
 
-- 
2.20.1



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

* Re: [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-02-10 20:17 ` [Qemu-riscv] " Lukas Auer
@ 2019-02-11 23:43   ` Alistair Francis
  -1 siblings, 0 replies; 21+ messages in thread
From: Alistair Francis @ 2019-02-11 23:43 UTC (permalink / raw)
  To: Lukas Auer
  Cc: qemu-devel@nongnu.org Developers, open list:RISC-V,
	Sagar Karandikar, Bastian Koppelmann, Palmer Dabbelt,
	Michael Clark, Alistair Francis

On Sun, Feb 10, 2019 at 2:12 PM Lukas Auer
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Re-add the previous compatible string "riscv-virtio-soc" to the soc
> device tree node to allow U-Boot and Linux to bind machine-specific
> drivers to it. The current compatible string "simple-bus" is retained.
>
> This is required by U-Boot to bind devices early, as part of the
> pre-relocation driver model.
>
> Fixes: 53f54508dae6("hw/riscv/virtio: Set the soc device tree node as a
> simple-bus")
> Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>

This looks fine to me.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>
>  hw/riscv/virt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index 3e8b19c668..c53bb905ff 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -157,6 +157,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
>      char *nodename;
>      uint32_t plic_phandle, phandle = 1;
>      int i;
> +    const char soc_compat[] = "riscv-virtio-soc\0simple-bus";
>
>      fdt = s->fdt = create_device_tree(&s->fdt_size);
>      if (!fdt) {
> @@ -171,7 +172,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
>
>      qemu_fdt_add_subnode(fdt, "/soc");
>      qemu_fdt_setprop(fdt, "/soc", "ranges", NULL, 0);
> -    qemu_fdt_setprop_string(fdt, "/soc", "compatible", "simple-bus");
> +    qemu_fdt_setprop(fdt, "/soc", "compatible", soc_compat, sizeof(soc_compat));
>      qemu_fdt_setprop_cell(fdt, "/soc", "#size-cells", 0x2);
>      qemu_fdt_setprop_cell(fdt, "/soc", "#address-cells", 0x2);
>
> --
> 2.20.1
>
>

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

* Re: [Qemu-riscv] [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
@ 2019-02-11 23:43   ` Alistair Francis
  0 siblings, 0 replies; 21+ messages in thread
From: Alistair Francis @ 2019-02-11 23:43 UTC (permalink / raw)
  To: Lukas Auer
  Cc: qemu-devel@nongnu.org Developers, open list:RISC-V,
	Sagar Karandikar, Bastian Koppelmann, Palmer Dabbelt,
	Michael Clark, Alistair Francis

On Sun, Feb 10, 2019 at 2:12 PM Lukas Auer
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Re-add the previous compatible string "riscv-virtio-soc" to the soc
> device tree node to allow U-Boot and Linux to bind machine-specific
> drivers to it. The current compatible string "simple-bus" is retained.
>
> This is required by U-Boot to bind devices early, as part of the
> pre-relocation driver model.
>
> Fixes: 53f54508dae6("hw/riscv/virtio: Set the soc device tree node as a
> simple-bus")
> Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>

This looks fine to me.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>
>  hw/riscv/virt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index 3e8b19c668..c53bb905ff 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -157,6 +157,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
>      char *nodename;
>      uint32_t plic_phandle, phandle = 1;
>      int i;
> +    const char soc_compat[] = "riscv-virtio-soc\0simple-bus";
>
>      fdt = s->fdt = create_device_tree(&s->fdt_size);
>      if (!fdt) {
> @@ -171,7 +172,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
>
>      qemu_fdt_add_subnode(fdt, "/soc");
>      qemu_fdt_setprop(fdt, "/soc", "ranges", NULL, 0);
> -    qemu_fdt_setprop_string(fdt, "/soc", "compatible", "simple-bus");
> +    qemu_fdt_setprop(fdt, "/soc", "compatible", soc_compat, sizeof(soc_compat));
>      qemu_fdt_setprop_cell(fdt, "/soc", "#size-cells", 0x2);
>      qemu_fdt_setprop_cell(fdt, "/soc", "#address-cells", 0x2);
>
> --
> 2.20.1
>
>


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

* Re: [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-02-10 20:17 ` [Qemu-riscv] " Lukas Auer
@ 2019-03-10  1:07   ` Bin Meng
  -1 siblings, 0 replies; 21+ messages in thread
From: Bin Meng @ 2019-03-10  1:07 UTC (permalink / raw)
  To: Lukas Auer
  Cc: qemu-devel, qemu-riscv, Sagar Karandikar, Bastian Koppelmann,
	Palmer Dabbelt, Michael Clark, Alistair Francis

Hi Lukas,

On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Re-add the previous compatible string "riscv-virtio-soc" to the soc
> device tree node to allow U-Boot and Linux to bind machine-specific
> drivers to it. The current compatible string "simple-bus" is retained.
>
> This is required by U-Boot to bind devices early, as part of the
> pre-relocation driver model.
>

I see no problem with U-Boot working with current compatible string
"simple-bus". In fact I had planned to remove the compatible string
"riscv-virtio-soc" in U-Boot but did not get time to work on it.

> Fixes: 53f54508dae6("hw/riscv/virtio: Set the soc device tree node as a
> simple-bus")
> Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> ---
>
>  hw/riscv/virt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>

Regards,
Bin

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

* Re: [Qemu-riscv] [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
@ 2019-03-10  1:07   ` Bin Meng
  0 siblings, 0 replies; 21+ messages in thread
From: Bin Meng @ 2019-03-10  1:07 UTC (permalink / raw)
  To: Lukas Auer
  Cc: qemu-devel, qemu-riscv, Sagar Karandikar, Bastian Koppelmann,
	Palmer Dabbelt, Michael Clark, Alistair Francis

Hi Lukas,

On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Re-add the previous compatible string "riscv-virtio-soc" to the soc
> device tree node to allow U-Boot and Linux to bind machine-specific
> drivers to it. The current compatible string "simple-bus" is retained.
>
> This is required by U-Boot to bind devices early, as part of the
> pre-relocation driver model.
>

I see no problem with U-Boot working with current compatible string
"simple-bus". In fact I had planned to remove the compatible string
"riscv-virtio-soc" in U-Boot but did not get time to work on it.

> Fixes: 53f54508dae6("hw/riscv/virtio: Set the soc device tree node as a
> simple-bus")
> Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> ---
>
>  hw/riscv/virt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>

Regards,
Bin


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

* Re: [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-03-10  1:07   ` [Qemu-riscv] " Bin Meng
@ 2019-03-10 13:44     ` Auer, Lukas
  -1 siblings, 0 replies; 21+ messages in thread
From: Auer, Lukas @ 2019-03-10 13:44 UTC (permalink / raw)
  To: bmeng.cn
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, mjc, sagark, Alistair.Francis

Hi Bin,

On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> <lukas.auer@aisec.fraunhofer.de> wrote:
> > Re-add the previous compatible string "riscv-virtio-soc" to the soc
> > device tree node to allow U-Boot and Linux to bind machine-specific
> > drivers to it. The current compatible string "simple-bus" is
> > retained.
> > 
> > This is required by U-Boot to bind devices early, as part of the
> > pre-relocation driver model.
> > 
> 
> I see no problem with U-Boot working with current compatible string
> "simple-bus". In fact I had planned to remove the compatible string
> "riscv-virtio-soc" in U-Boot but did not get time to work on it.
> 

It is only required if U-Boot is running in machine-mode. For
relocation it needs to use the CLINT driver to send appropriate IPIs to
the other harts. To be able to probe the driver, the device and its
parent device tree node (soc) must therefore be available in the pre-
relocation device model.
This patch was the easiest way I could think of for achieving this. It
could be that there is a better way of solving this.

Thanks,
Lukas

> > Fixes: 53f54508dae6("hw/riscv/virtio: Set the soc device tree node
> > as a
> > simple-bus")
> > Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> > ---
> > 
> >  hw/riscv/virt.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> 
> Regards,
> Bin

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

* Re: [Qemu-riscv] [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
@ 2019-03-10 13:44     ` Auer, Lukas
  0 siblings, 0 replies; 21+ messages in thread
From: Auer, Lukas @ 2019-03-10 13:44 UTC (permalink / raw)
  To: bmeng.cn
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, mjc, sagark, Alistair.Francis

Hi Bin,

On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> <lukas.auer@aisec.fraunhofer.de> wrote:
> > Re-add the previous compatible string "riscv-virtio-soc" to the soc
> > device tree node to allow U-Boot and Linux to bind machine-specific
> > drivers to it. The current compatible string "simple-bus" is
> > retained.
> > 
> > This is required by U-Boot to bind devices early, as part of the
> > pre-relocation driver model.
> > 
> 
> I see no problem with U-Boot working with current compatible string
> "simple-bus". In fact I had planned to remove the compatible string
> "riscv-virtio-soc" in U-Boot but did not get time to work on it.
> 

It is only required if U-Boot is running in machine-mode. For
relocation it needs to use the CLINT driver to send appropriate IPIs to
the other harts. To be able to probe the driver, the device and its
parent device tree node (soc) must therefore be available in the pre-
relocation device model.
This patch was the easiest way I could think of for achieving this. It
could be that there is a better way of solving this.

Thanks,
Lukas

> > Fixes: 53f54508dae6("hw/riscv/virtio: Set the soc device tree node
> > as a
> > simple-bus")
> > Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> > ---
> > 
> >  hw/riscv/virt.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> 
> Regards,
> Bin

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

* Re: [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-03-10 13:44     ` [Qemu-riscv] " Auer, Lukas
@ 2019-03-10 14:57       ` Bin Meng
  -1 siblings, 0 replies; 21+ messages in thread
From: Bin Meng @ 2019-03-10 14:57 UTC (permalink / raw)
  To: Auer, Lukas
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, mjc, sagark, Alistair.Francis

Hi Lukas,

On Sun, Mar 10, 2019 at 9:44 PM Auer, Lukas
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> > Hi Lukas,
> >
> > On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > Re-add the previous compatible string "riscv-virtio-soc" to the soc
> > > device tree node to allow U-Boot and Linux to bind machine-specific
> > > drivers to it. The current compatible string "simple-bus" is
> > > retained.
> > >
> > > This is required by U-Boot to bind devices early, as part of the
> > > pre-relocation driver model.
> > >
> >
> > I see no problem with U-Boot working with current compatible string
> > "simple-bus". In fact I had planned to remove the compatible string
> > "riscv-virtio-soc" in U-Boot but did not get time to work on it.
> >
>
> It is only required if U-Boot is running in machine-mode. For
> relocation it needs to use the CLINT driver to send appropriate IPIs to
> the other harts. To be able to probe the driver, the device and its
> parent device tree node (soc) must therefore be available in the pre-
> relocation device model.
> This patch was the easiest way I could think of for achieving this. It
> could be that there is a better way of solving this.
>

I tested your SMP U-Boot series in both M-mode and S-mode, using a 4
core 'virt' target. Works fine. I am using QEMU 3.1.0 so it is
"simple-bus".

Regards,
Bin

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

* Re: [Qemu-riscv] [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
@ 2019-03-10 14:57       ` Bin Meng
  0 siblings, 0 replies; 21+ messages in thread
From: Bin Meng @ 2019-03-10 14:57 UTC (permalink / raw)
  To: Auer, Lukas
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, mjc, sagark, Alistair.Francis

Hi Lukas,

On Sun, Mar 10, 2019 at 9:44 PM Auer, Lukas
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> > Hi Lukas,
> >
> > On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > Re-add the previous compatible string "riscv-virtio-soc" to the soc
> > > device tree node to allow U-Boot and Linux to bind machine-specific
> > > drivers to it. The current compatible string "simple-bus" is
> > > retained.
> > >
> > > This is required by U-Boot to bind devices early, as part of the
> > > pre-relocation driver model.
> > >
> >
> > I see no problem with U-Boot working with current compatible string
> > "simple-bus". In fact I had planned to remove the compatible string
> > "riscv-virtio-soc" in U-Boot but did not get time to work on it.
> >
>
> It is only required if U-Boot is running in machine-mode. For
> relocation it needs to use the CLINT driver to send appropriate IPIs to
> the other harts. To be able to probe the driver, the device and its
> parent device tree node (soc) must therefore be available in the pre-
> relocation device model.
> This patch was the easiest way I could think of for achieving this. It
> could be that there is a better way of solving this.
>

I tested your SMP U-Boot series in both M-mode and S-mode, using a 4
core 'virt' target. Works fine. I am using QEMU 3.1.0 so it is
"simple-bus".

Regards,
Bin


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

* Re: [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-03-10 14:57       ` [Qemu-riscv] " Bin Meng
@ 2019-03-10 18:03         ` Auer, Lukas
  -1 siblings, 0 replies; 21+ messages in thread
From: Auer, Lukas @ 2019-03-10 18:03 UTC (permalink / raw)
  To: bmeng.cn
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, mjc, sagark, Alistair.Francis

Hi Bin,

On Sun, 2019-03-10 at 22:57 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Sun, Mar 10, 2019 at 9:44 PM Auer, Lukas
> <lukas.auer@aisec.fraunhofer.de> wrote:
> > Hi Bin,
> > 
> > On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> > > Hi Lukas,
> > > 
> > > On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > Re-add the previous compatible string "riscv-virtio-soc" to the
> > > > soc
> > > > device tree node to allow U-Boot and Linux to bind machine-
> > > > specific
> > > > drivers to it. The current compatible string "simple-bus" is
> > > > retained.
> > > > 
> > > > This is required by U-Boot to bind devices early, as part of
> > > > the
> > > > pre-relocation driver model.
> > > > 
> > > 
> > > I see no problem with U-Boot working with current compatible
> > > string
> > > "simple-bus". In fact I had planned to remove the compatible
> > > string
> > > "riscv-virtio-soc" in U-Boot but did not get time to work on it.
> > > 
> > 
> > It is only required if U-Boot is running in machine-mode. For
> > relocation it needs to use the CLINT driver to send appropriate
> > IPIs to
> > the other harts. To be able to probe the driver, the device and its
> > parent device tree node (soc) must therefore be available in the
> > pre-
> > relocation device model.
> > This patch was the easiest way I could think of for achieving this.
> > It
> > could be that there is a better way of solving this.
> > 
> 
> I tested your SMP U-Boot series in both M-mode and S-mode, using a 4
> core 'virt' target. Works fine. I am using QEMU 3.1.0 so it is
> "simple-bus".
> 

That is actually my fault, it should not work.
What is happening is that U-Boot fails to relocate the secondary harts,
because the CLINT driver cannot get the memory address of the CLINT
device. This error is currently silently ignored.
The secondary harts are still waiting to receive IPIs, so booting Linux
works fine, because U-Boot can now send IPIs. This will however break
if U-Boot overwrites the code the secondary harts are running, which
could happen when loading an image.

I will update my SMP U-Boot series to print a warning if sending an IPI
fails.

Thanks,
Lukas

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

* Re: [Qemu-riscv] [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
@ 2019-03-10 18:03         ` Auer, Lukas
  0 siblings, 0 replies; 21+ messages in thread
From: Auer, Lukas @ 2019-03-10 18:03 UTC (permalink / raw)
  To: bmeng.cn
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, mjc, sagark, Alistair.Francis

Hi Bin,

On Sun, 2019-03-10 at 22:57 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Sun, Mar 10, 2019 at 9:44 PM Auer, Lukas
> <lukas.auer@aisec.fraunhofer.de> wrote:
> > Hi Bin,
> > 
> > On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> > > Hi Lukas,
> > > 
> > > On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > Re-add the previous compatible string "riscv-virtio-soc" to the
> > > > soc
> > > > device tree node to allow U-Boot and Linux to bind machine-
> > > > specific
> > > > drivers to it. The current compatible string "simple-bus" is
> > > > retained.
> > > > 
> > > > This is required by U-Boot to bind devices early, as part of
> > > > the
> > > > pre-relocation driver model.
> > > > 
> > > 
> > > I see no problem with U-Boot working with current compatible
> > > string
> > > "simple-bus". In fact I had planned to remove the compatible
> > > string
> > > "riscv-virtio-soc" in U-Boot but did not get time to work on it.
> > > 
> > 
> > It is only required if U-Boot is running in machine-mode. For
> > relocation it needs to use the CLINT driver to send appropriate
> > IPIs to
> > the other harts. To be able to probe the driver, the device and its
> > parent device tree node (soc) must therefore be available in the
> > pre-
> > relocation device model.
> > This patch was the easiest way I could think of for achieving this.
> > It
> > could be that there is a better way of solving this.
> > 
> 
> I tested your SMP U-Boot series in both M-mode and S-mode, using a 4
> core 'virt' target. Works fine. I am using QEMU 3.1.0 so it is
> "simple-bus".
> 

That is actually my fault, it should not work.
What is happening is that U-Boot fails to relocate the secondary harts,
because the CLINT driver cannot get the memory address of the CLINT
device. This error is currently silently ignored.
The secondary harts are still waiting to receive IPIs, so booting Linux
works fine, because U-Boot can now send IPIs. This will however break
if U-Boot overwrites the code the secondary harts are running, which
could happen when loading an image.

I will update my SMP U-Boot series to print a warning if sending an IPI
fails.

Thanks,
Lukas

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

* Re: [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-03-10 18:03         ` [Qemu-riscv] " Auer, Lukas
@ 2019-03-11 15:28           ` Bin Meng
  -1 siblings, 0 replies; 21+ messages in thread
From: Bin Meng @ 2019-03-11 15:28 UTC (permalink / raw)
  To: Auer, Lukas
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, sagark, Alistair.Francis

Hi Lukas,

On Mon, Mar 11, 2019 at 2:03 AM Auer, Lukas
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Sun, 2019-03-10 at 22:57 +0800, Bin Meng wrote:
> > Hi Lukas,
> >
> > On Sun, Mar 10, 2019 at 9:44 PM Auer, Lukas
> > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > Hi Bin,
> > >
> > > On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> > > > Hi Lukas,
> > > >
> > > > On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > Re-add the previous compatible string "riscv-virtio-soc" to the
> > > > > soc
> > > > > device tree node to allow U-Boot and Linux to bind machine-
> > > > > specific
> > > > > drivers to it. The current compatible string "simple-bus" is
> > > > > retained.
> > > > >
> > > > > This is required by U-Boot to bind devices early, as part of
> > > > > the
> > > > > pre-relocation driver model.
> > > > >
> > > >
> > > > I see no problem with U-Boot working with current compatible
> > > > string
> > > > "simple-bus". In fact I had planned to remove the compatible
> > > > string
> > > > "riscv-virtio-soc" in U-Boot but did not get time to work on it.
> > > >
> > >
> > > It is only required if U-Boot is running in machine-mode. For
> > > relocation it needs to use the CLINT driver to send appropriate
> > > IPIs to
> > > the other harts. To be able to probe the driver, the device and its
> > > parent device tree node (soc) must therefore be available in the
> > > pre-
> > > relocation device model.
> > > This patch was the easiest way I could think of for achieving this.
> > > It
> > > could be that there is a better way of solving this.
> > >
> >
> > I tested your SMP U-Boot series in both M-mode and S-mode, using a 4
> > core 'virt' target. Works fine. I am using QEMU 3.1.0 so it is
> > "simple-bus".
> >
>
> That is actually my fault, it should not work.
> What is happening is that U-Boot fails to relocate the secondary harts,
> because the CLINT driver cannot get the memory address of the CLINT
> device. This error is currently silently ignored.

I still don't understand. Why does the CLINT driver fail to get the
memory address? U-Boot has been supporting "simpile-bus" for a long
time. It was because QEMU 3.0.0 generated the /soc node with
"riscv-virtio-soc" compatible string, U-Boot was taught to treat such
compatible string as a "simple-bus" too (that was the U-Boot commit
27dc2c130e29)

> The secondary harts are still waiting to receive IPIs, so booting Linux
> works fine, because U-Boot can now send IPIs. This will however break
> if U-Boot overwrites the code the secondary harts are running, which
> could happen when loading an image.
>
> I will update my SMP U-Boot series to print a warning if sending an IPI
> fails.
>

Regards,
Bin

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

* Re: [Qemu-riscv] [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
@ 2019-03-11 15:28           ` Bin Meng
  0 siblings, 0 replies; 21+ messages in thread
From: Bin Meng @ 2019-03-11 15:28 UTC (permalink / raw)
  To: Auer, Lukas
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, sagark, Alistair.Francis

Hi Lukas,

On Mon, Mar 11, 2019 at 2:03 AM Auer, Lukas
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Sun, 2019-03-10 at 22:57 +0800, Bin Meng wrote:
> > Hi Lukas,
> >
> > On Sun, Mar 10, 2019 at 9:44 PM Auer, Lukas
> > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > Hi Bin,
> > >
> > > On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> > > > Hi Lukas,
> > > >
> > > > On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > Re-add the previous compatible string "riscv-virtio-soc" to the
> > > > > soc
> > > > > device tree node to allow U-Boot and Linux to bind machine-
> > > > > specific
> > > > > drivers to it. The current compatible string "simple-bus" is
> > > > > retained.
> > > > >
> > > > > This is required by U-Boot to bind devices early, as part of
> > > > > the
> > > > > pre-relocation driver model.
> > > > >
> > > >
> > > > I see no problem with U-Boot working with current compatible
> > > > string
> > > > "simple-bus". In fact I had planned to remove the compatible
> > > > string
> > > > "riscv-virtio-soc" in U-Boot but did not get time to work on it.
> > > >
> > >
> > > It is only required if U-Boot is running in machine-mode. For
> > > relocation it needs to use the CLINT driver to send appropriate
> > > IPIs to
> > > the other harts. To be able to probe the driver, the device and its
> > > parent device tree node (soc) must therefore be available in the
> > > pre-
> > > relocation device model.
> > > This patch was the easiest way I could think of for achieving this.
> > > It
> > > could be that there is a better way of solving this.
> > >
> >
> > I tested your SMP U-Boot series in both M-mode and S-mode, using a 4
> > core 'virt' target. Works fine. I am using QEMU 3.1.0 so it is
> > "simple-bus".
> >
>
> That is actually my fault, it should not work.
> What is happening is that U-Boot fails to relocate the secondary harts,
> because the CLINT driver cannot get the memory address of the CLINT
> device. This error is currently silently ignored.

I still don't understand. Why does the CLINT driver fail to get the
memory address? U-Boot has been supporting "simpile-bus" for a long
time. It was because QEMU 3.0.0 generated the /soc node with
"riscv-virtio-soc" compatible string, U-Boot was taught to treat such
compatible string as a "simple-bus" too (that was the U-Boot commit
27dc2c130e29)

> The secondary harts are still waiting to receive IPIs, so booting Linux
> works fine, because U-Boot can now send IPIs. This will however break
> if U-Boot overwrites the code the secondary harts are running, which
> could happen when loading an image.
>
> I will update my SMP U-Boot series to print a warning if sending an IPI
> fails.
>

Regards,
Bin


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

* Re: [Qemu-riscv] [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-03-11 15:28           ` [Qemu-riscv] " Bin Meng
  (?)
@ 2019-03-12 14:39           ` Auer, Lukas
  2019-03-13  1:51             ` Bin Meng
  -1 siblings, 1 reply; 21+ messages in thread
From: Auer, Lukas @ 2019-03-12 14:39 UTC (permalink / raw)
  To: bmeng.cn
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, sagark, Alistair.Francis

Hi Bin,

On Mon, 2019-03-11 at 23:28 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Mon, Mar 11, 2019 at 2:03 AM Auer, Lukas
> <lukas.auer@aisec.fraunhofer.de> wrote:
> > Hi Bin,
> > 
> > On Sun, 2019-03-10 at 22:57 +0800, Bin Meng wrote:
> > > Hi Lukas,
> > > 
> > > On Sun, Mar 10, 2019 at 9:44 PM Auer, Lukas
> > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > Hi Bin,
> > > > 
> > > > On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> > > > > Hi Lukas,
> > > > > 
> > > > > On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> > > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > > Re-add the previous compatible string "riscv-virtio-soc" to
> > > > > > the
> > > > > > soc
> > > > > > device tree node to allow U-Boot and Linux to bind machine-
> > > > > > specific
> > > > > > drivers to it. The current compatible string "simple-bus"
> > > > > > is
> > > > > > retained.
> > > > > > 
> > > > > > This is required by U-Boot to bind devices early, as part
> > > > > > of
> > > > > > the
> > > > > > pre-relocation driver model.
> > > > > > 
> > > > > 
> > > > > I see no problem with U-Boot working with current compatible
> > > > > string
> > > > > "simple-bus". In fact I had planned to remove the compatible
> > > > > string
> > > > > "riscv-virtio-soc" in U-Boot but did not get time to work on
> > > > > it.
> > > > > 
> > > > 
> > > > It is only required if U-Boot is running in machine-mode. For
> > > > relocation it needs to use the CLINT driver to send appropriate
> > > > IPIs to
> > > > the other harts. To be able to probe the driver, the device and
> > > > its
> > > > parent device tree node (soc) must therefore be available in
> > > > the
> > > > pre-
> > > > relocation device model.
> > > > This patch was the easiest way I could think of for achieving
> > > > this.
> > > > It
> > > > could be that there is a better way of solving this.
> > > > 
> > > 
> > > I tested your SMP U-Boot series in both M-mode and S-mode, using
> > > a 4
> > > core 'virt' target. Works fine. I am using QEMU 3.1.0 so it is
> > > "simple-bus".
> > > 
> > 
> > That is actually my fault, it should not work.
> > What is happening is that U-Boot fails to relocate the secondary
> > harts,
> > because the CLINT driver cannot get the memory address of the CLINT
> > device. This error is currently silently ignored.
> 
> I still don't understand. Why does the CLINT driver fail to get the
> memory address? U-Boot has been supporting "simpile-bus" for a long
> time. It was because QEMU 3.0.0 generated the /soc node with
> "riscv-virtio-soc" compatible string, U-Boot was taught to treat such
> compatible string as a "simple-bus" too (that was the U-Boot commit
> 27dc2c130e29)

That's correct. The problem with the default simple-bus U-Boot driver
is that it does not have the DM_FLAG_PRE_RELOC flag set. The /soc and
/soc/clint nodes are therefore not available before relocation, meaning
that IPIs cannot be sent to relocate the secondary harts.

Thanks,
Lukas

> 
> > The secondary harts are still waiting to receive IPIs, so booting
> > Linux
> > works fine, because U-Boot can now send IPIs. This will however
> > break
> > if U-Boot overwrites the code the secondary harts are running,
> > which
> > could happen when loading an image.
> > 
> > I will update my SMP U-Boot series to print a warning if sending an
> > IPI
> > fails.
> > 
> 
> Regards,
> Bin

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

* Re: [Qemu-riscv] [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-03-12 14:39           ` Auer, Lukas
@ 2019-03-13  1:51             ` Bin Meng
  2019-03-14 21:01               ` Auer, Lukas
  0 siblings, 1 reply; 21+ messages in thread
From: Bin Meng @ 2019-03-13  1:51 UTC (permalink / raw)
  To: Auer, Lukas
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, sagark, Alistair.Francis

Hi Lukas,

On Tue, Mar 12, 2019 at 10:39 PM Auer, Lukas
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Mon, 2019-03-11 at 23:28 +0800, Bin Meng wrote:
> > Hi Lukas,
> >
> > On Mon, Mar 11, 2019 at 2:03 AM Auer, Lukas
> > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > Hi Bin,
> > >
> > > On Sun, 2019-03-10 at 22:57 +0800, Bin Meng wrote:
> > > > Hi Lukas,
> > > >
> > > > On Sun, Mar 10, 2019 at 9:44 PM Auer, Lukas
> > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > Hi Bin,
> > > > >
> > > > > On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> > > > > > Hi Lukas,
> > > > > >
> > > > > > On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> > > > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > > > Re-add the previous compatible string "riscv-virtio-soc" to
> > > > > > > the
> > > > > > > soc
> > > > > > > device tree node to allow U-Boot and Linux to bind machine-
> > > > > > > specific
> > > > > > > drivers to it. The current compatible string "simple-bus"
> > > > > > > is
> > > > > > > retained.
> > > > > > >
> > > > > > > This is required by U-Boot to bind devices early, as part
> > > > > > > of
> > > > > > > the
> > > > > > > pre-relocation driver model.
> > > > > > >
> > > > > >
> > > > > > I see no problem with U-Boot working with current compatible
> > > > > > string
> > > > > > "simple-bus". In fact I had planned to remove the compatible
> > > > > > string
> > > > > > "riscv-virtio-soc" in U-Boot but did not get time to work on
> > > > > > it.
> > > > > >
> > > > >
> > > > > It is only required if U-Boot is running in machine-mode. For
> > > > > relocation it needs to use the CLINT driver to send appropriate
> > > > > IPIs to
> > > > > the other harts. To be able to probe the driver, the device and
> > > > > its
> > > > > parent device tree node (soc) must therefore be available in
> > > > > the
> > > > > pre-
> > > > > relocation device model.
> > > > > This patch was the easiest way I could think of for achieving
> > > > > this.
> > > > > It
> > > > > could be that there is a better way of solving this.
> > > > >
> > > >
> > > > I tested your SMP U-Boot series in both M-mode and S-mode, using
> > > > a 4
> > > > core 'virt' target. Works fine. I am using QEMU 3.1.0 so it is
> > > > "simple-bus".
> > > >
> > >
> > > That is actually my fault, it should not work.
> > > What is happening is that U-Boot fails to relocate the secondary
> > > harts,
> > > because the CLINT driver cannot get the memory address of the CLINT
> > > device. This error is currently silently ignored.
> >
> > I still don't understand. Why does the CLINT driver fail to get the
> > memory address? U-Boot has been supporting "simpile-bus" for a long
> > time. It was because QEMU 3.0.0 generated the /soc node with
> > "riscv-virtio-soc" compatible string, U-Boot was taught to treat such
> > compatible string as a "simple-bus" too (that was the U-Boot commit
> > 27dc2c130e29)
>
> That's correct. The problem with the default simple-bus U-Boot driver
> is that it does not have the DM_FLAG_PRE_RELOC flag set. The /soc and
> /soc/clint nodes are therefore not available before relocation, meaning
> that IPIs cannot be sent to relocate the secondary harts.
>

Thanks for the clarifications. Now I see the problem. But I think we
should fix U-Boot "simple-bus" driver instead. As seen on FU540 or
likely other hardware, QEMU generates the "simple-bus" compatible
string for the /soc node, as well as the DT provided by the hardware.

Regards,
Bin


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

* Re: [Qemu-riscv] [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-03-13  1:51             ` Bin Meng
@ 2019-03-14 21:01               ` Auer, Lukas
  2019-03-15  1:54                 ` Bin Meng
  0 siblings, 1 reply; 21+ messages in thread
From: Auer, Lukas @ 2019-03-14 21:01 UTC (permalink / raw)
  To: bmeng.cn
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, sagark, Alistair.Francis

Hi Bin,

On Wed, 2019-03-13 at 09:51 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Tue, Mar 12, 2019 at 10:39 PM Auer, Lukas
> <lukas.auer@aisec.fraunhofer.de> wrote:
> > Hi Bin,
> > 
> > On Mon, 2019-03-11 at 23:28 +0800, Bin Meng wrote:
> > > Hi Lukas,
> > > 
> > > On Mon, Mar 11, 2019 at 2:03 AM Auer, Lukas
> > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > Hi Bin,
> > > > 
> > > > On Sun, 2019-03-10 at 22:57 +0800, Bin Meng wrote:
> > > > > Hi Lukas,
> > > > > 
> > > > > On Sun, Mar 10, 2019 at 9:44 PM Auer, Lukas
> > > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > > Hi Bin,
> > > > > > 
> > > > > > On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> > > > > > > Hi Lukas,
> > > > > > > 
> > > > > > > On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> > > > > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > > > > Re-add the previous compatible string "riscv-virtio-
> > > > > > > > soc" to
> > > > > > > > the
> > > > > > > > soc
> > > > > > > > device tree node to allow U-Boot and Linux to bind
> > > > > > > > machine-
> > > > > > > > specific
> > > > > > > > drivers to it. The current compatible string "simple-
> > > > > > > > bus"
> > > > > > > > is
> > > > > > > > retained.
> > > > > > > > 
> > > > > > > > This is required by U-Boot to bind devices early, as
> > > > > > > > part
> > > > > > > > of
> > > > > > > > the
> > > > > > > > pre-relocation driver model.
> > > > > > > > 
> > > > > > > 
> > > > > > > I see no problem with U-Boot working with current
> > > > > > > compatible
> > > > > > > string
> > > > > > > "simple-bus". In fact I had planned to remove the
> > > > > > > compatible
> > > > > > > string
> > > > > > > "riscv-virtio-soc" in U-Boot but did not get time to work
> > > > > > > on
> > > > > > > it.
> > > > > > > 
> > > > > > 
> > > > > > It is only required if U-Boot is running in machine-mode.
> > > > > > For
> > > > > > relocation it needs to use the CLINT driver to send
> > > > > > appropriate
> > > > > > IPIs to
> > > > > > the other harts. To be able to probe the driver, the device
> > > > > > and
> > > > > > its
> > > > > > parent device tree node (soc) must therefore be available
> > > > > > in
> > > > > > the
> > > > > > pre-
> > > > > > relocation device model.
> > > > > > This patch was the easiest way I could think of for
> > > > > > achieving
> > > > > > this.
> > > > > > It
> > > > > > could be that there is a better way of solving this.
> > > > > > 
> > > > > 
> > > > > I tested your SMP U-Boot series in both M-mode and S-mode,
> > > > > using
> > > > > a 4
> > > > > core 'virt' target. Works fine. I am using QEMU 3.1.0 so it
> > > > > is
> > > > > "simple-bus".
> > > > > 
> > > > 
> > > > That is actually my fault, it should not work.
> > > > What is happening is that U-Boot fails to relocate the
> > > > secondary
> > > > harts,
> > > > because the CLINT driver cannot get the memory address of the
> > > > CLINT
> > > > device. This error is currently silently ignored.
> > > 
> > > I still don't understand. Why does the CLINT driver fail to get
> > > the
> > > memory address? U-Boot has been supporting "simpile-bus" for a
> > > long
> > > time. It was because QEMU 3.0.0 generated the /soc node with
> > > "riscv-virtio-soc" compatible string, U-Boot was taught to treat
> > > such
> > > compatible string as a "simple-bus" too (that was the U-Boot
> > > commit
> > > 27dc2c130e29)
> > 
> > That's correct. The problem with the default simple-bus U-Boot
> > driver
> > is that it does not have the DM_FLAG_PRE_RELOC flag set. The /soc
> > and
> > /soc/clint nodes are therefore not available before relocation,
> > meaning
> > that IPIs cannot be sent to relocate the secondary harts.
> > 
> 
> Thanks for the clarifications. Now I see the problem. But I think we
> should fix U-Boot "simple-bus" driver instead. As seen on FU540 or
> likely other hardware, QEMU generates the "simple-bus" compatible
> string for the /soc node, as well as the DT provided by the hardware.
> 

That makes sense, I can send a patch to set the DM_FLAG_PRE_RELOC flag
in the simple-bus U-Boot driver. I think it's best to send it
separately from the SMP patch series, since it could affect other
boards and it's a bit late in the release cycle. What do you think?

This patch can be dropped then.

Thanks,
Lukas

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

* Re: [Qemu-riscv] [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-03-14 21:01               ` Auer, Lukas
@ 2019-03-15  1:54                 ` Bin Meng
  2019-03-17 18:57                   ` Auer, Lukas
  0 siblings, 1 reply; 21+ messages in thread
From: Bin Meng @ 2019-03-15  1:54 UTC (permalink / raw)
  To: Auer, Lukas
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, sagark, Alistair.Francis

Hi Lukas,

On Fri, Mar 15, 2019 at 5:01 AM Auer, Lukas
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Wed, 2019-03-13 at 09:51 +0800, Bin Meng wrote:
> > Hi Lukas,
> >
> > On Tue, Mar 12, 2019 at 10:39 PM Auer, Lukas
> > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > Hi Bin,
> > >
> > > On Mon, 2019-03-11 at 23:28 +0800, Bin Meng wrote:
> > > > Hi Lukas,
> > > >
> > > > On Mon, Mar 11, 2019 at 2:03 AM Auer, Lukas
> > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > Hi Bin,
> > > > >
> > > > > On Sun, 2019-03-10 at 22:57 +0800, Bin Meng wrote:
> > > > > > Hi Lukas,
> > > > > >
> > > > > > On Sun, Mar 10, 2019 at 9:44 PM Auer, Lukas
> > > > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > > > Hi Bin,
> > > > > > >
> > > > > > > On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> > > > > > > > Hi Lukas,
> > > > > > > >
> > > > > > > > On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> > > > > > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > > > > > Re-add the previous compatible string "riscv-virtio-
> > > > > > > > > soc" to
> > > > > > > > > the
> > > > > > > > > soc
> > > > > > > > > device tree node to allow U-Boot and Linux to bind
> > > > > > > > > machine-
> > > > > > > > > specific
> > > > > > > > > drivers to it. The current compatible string "simple-
> > > > > > > > > bus"
> > > > > > > > > is
> > > > > > > > > retained.
> > > > > > > > >
> > > > > > > > > This is required by U-Boot to bind devices early, as
> > > > > > > > > part
> > > > > > > > > of
> > > > > > > > > the
> > > > > > > > > pre-relocation driver model.
> > > > > > > > >
> > > > > > > >
> > > > > > > > I see no problem with U-Boot working with current
> > > > > > > > compatible
> > > > > > > > string
> > > > > > > > "simple-bus". In fact I had planned to remove the
> > > > > > > > compatible
> > > > > > > > string
> > > > > > > > "riscv-virtio-soc" in U-Boot but did not get time to work
> > > > > > > > on
> > > > > > > > it.
> > > > > > > >
> > > > > > >
> > > > > > > It is only required if U-Boot is running in machine-mode.
> > > > > > > For
> > > > > > > relocation it needs to use the CLINT driver to send
> > > > > > > appropriate
> > > > > > > IPIs to
> > > > > > > the other harts. To be able to probe the driver, the device
> > > > > > > and
> > > > > > > its
> > > > > > > parent device tree node (soc) must therefore be available
> > > > > > > in
> > > > > > > the
> > > > > > > pre-
> > > > > > > relocation device model.
> > > > > > > This patch was the easiest way I could think of for
> > > > > > > achieving
> > > > > > > this.
> > > > > > > It
> > > > > > > could be that there is a better way of solving this.
> > > > > > >
> > > > > >
> > > > > > I tested your SMP U-Boot series in both M-mode and S-mode,
> > > > > > using
> > > > > > a 4
> > > > > > core 'virt' target. Works fine. I am using QEMU 3.1.0 so it
> > > > > > is
> > > > > > "simple-bus".
> > > > > >
> > > > >
> > > > > That is actually my fault, it should not work.
> > > > > What is happening is that U-Boot fails to relocate the
> > > > > secondary
> > > > > harts,
> > > > > because the CLINT driver cannot get the memory address of the
> > > > > CLINT
> > > > > device. This error is currently silently ignored.
> > > >
> > > > I still don't understand. Why does the CLINT driver fail to get
> > > > the
> > > > memory address? U-Boot has been supporting "simpile-bus" for a
> > > > long
> > > > time. It was because QEMU 3.0.0 generated the /soc node with
> > > > "riscv-virtio-soc" compatible string, U-Boot was taught to treat
> > > > such
> > > > compatible string as a "simple-bus" too (that was the U-Boot
> > > > commit
> > > > 27dc2c130e29)
> > >
> > > That's correct. The problem with the default simple-bus U-Boot
> > > driver
> > > is that it does not have the DM_FLAG_PRE_RELOC flag set. The /soc
> > > and
> > > /soc/clint nodes are therefore not available before relocation,
> > > meaning
> > > that IPIs cannot be sent to relocate the secondary harts.
> > >
> >
> > Thanks for the clarifications. Now I see the problem. But I think we
> > should fix U-Boot "simple-bus" driver instead. As seen on FU540 or
> > likely other hardware, QEMU generates the "simple-bus" compatible
> > string for the /soc node, as well as the DT provided by the hardware.
> >
>
> That makes sense, I can send a patch to set the DM_FLAG_PRE_RELOC flag
> in the simple-bus U-Boot driver. I think it's best to send it
> separately from the SMP patch series, since it could affect other
> boards and it's a bit late in the release cycle. What do you think?
>

Yes, agreed that the "simple-bus" driver changes should be next U-Boot
release. We should try to get the U-Boot SMP series in the v2019.04
release.

> This patch can be dropped then.
>

Regards,
Bin


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

* Re: [Qemu-riscv] [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-03-15  1:54                 ` Bin Meng
@ 2019-03-17 18:57                   ` Auer, Lukas
  0 siblings, 0 replies; 21+ messages in thread
From: Auer, Lukas @ 2019-03-17 18:57 UTC (permalink / raw)
  To: bmeng.cn
  Cc: palmer, qemu-riscv, qemu-devel, kbastian, sagark, Alistair.Francis

Hi Bin,

On Fri, 2019-03-15 at 09:54 +0800, Bin Meng wrote:
> Hi Lukas,
> 
> On Fri, Mar 15, 2019 at 5:01 AM Auer, Lukas
> <lukas.auer@aisec.fraunhofer.de> wrote:
> > Hi Bin,
> > 
> > On Wed, 2019-03-13 at 09:51 +0800, Bin Meng wrote:
> > > Hi Lukas,
> > > 
> > > On Tue, Mar 12, 2019 at 10:39 PM Auer, Lukas
> > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > Hi Bin,
> > > > 
> > > > On Mon, 2019-03-11 at 23:28 +0800, Bin Meng wrote:
> > > > > Hi Lukas,
> > > > > 
> > > > > On Mon, Mar 11, 2019 at 2:03 AM Auer, Lukas
> > > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > > Hi Bin,
> > > > > > 
> > > > > > On Sun, 2019-03-10 at 22:57 +0800, Bin Meng wrote:
> > > > > > > Hi Lukas,
> > > > > > > 
> > > > > > > On Sun, Mar 10, 2019 at 9:44 PM Auer, Lukas
> > > > > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > > > > Hi Bin,
> > > > > > > > 
> > > > > > > > On Sun, 2019-03-10 at 09:07 +0800, Bin Meng wrote:
> > > > > > > > > Hi Lukas,
> > > > > > > > > 
> > > > > > > > > On Mon, Feb 11, 2019 at 6:13 AM Lukas Auer
> > > > > > > > > <lukas.auer@aisec.fraunhofer.de> wrote:
> > > > > > > > > > Re-add the previous compatible string "riscv-
> > > > > > > > > > virtio-
> > > > > > > > > > soc" to
> > > > > > > > > > the
> > > > > > > > > > soc
> > > > > > > > > > device tree node to allow U-Boot and Linux to bind
> > > > > > > > > > machine-
> > > > > > > > > > specific
> > > > > > > > > > drivers to it. The current compatible string
> > > > > > > > > > "simple-
> > > > > > > > > > bus"
> > > > > > > > > > is
> > > > > > > > > > retained.
> > > > > > > > > > 
> > > > > > > > > > This is required by U-Boot to bind devices early,
> > > > > > > > > > as
> > > > > > > > > > part
> > > > > > > > > > of
> > > > > > > > > > the
> > > > > > > > > > pre-relocation driver model.
> > > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > I see no problem with U-Boot working with current
> > > > > > > > > compatible
> > > > > > > > > string
> > > > > > > > > "simple-bus". In fact I had planned to remove the
> > > > > > > > > compatible
> > > > > > > > > string
> > > > > > > > > "riscv-virtio-soc" in U-Boot but did not get time to
> > > > > > > > > work
> > > > > > > > > on
> > > > > > > > > it.
> > > > > > > > > 
> > > > > > > > 
> > > > > > > > It is only required if U-Boot is running in machine-
> > > > > > > > mode.
> > > > > > > > For
> > > > > > > > relocation it needs to use the CLINT driver to send
> > > > > > > > appropriate
> > > > > > > > IPIs to
> > > > > > > > the other harts. To be able to probe the driver, the
> > > > > > > > device
> > > > > > > > and
> > > > > > > > its
> > > > > > > > parent device tree node (soc) must therefore be
> > > > > > > > available
> > > > > > > > in
> > > > > > > > the
> > > > > > > > pre-
> > > > > > > > relocation device model.
> > > > > > > > This patch was the easiest way I could think of for
> > > > > > > > achieving
> > > > > > > > this.
> > > > > > > > It
> > > > > > > > could be that there is a better way of solving this.
> > > > > > > > 
> > > > > > > 
> > > > > > > I tested your SMP U-Boot series in both M-mode and S-
> > > > > > > mode,
> > > > > > > using
> > > > > > > a 4
> > > > > > > core 'virt' target. Works fine. I am using QEMU 3.1.0 so
> > > > > > > it
> > > > > > > is
> > > > > > > "simple-bus".
> > > > > > > 
> > > > > > 
> > > > > > That is actually my fault, it should not work.
> > > > > > What is happening is that U-Boot fails to relocate the
> > > > > > secondary
> > > > > > harts,
> > > > > > because the CLINT driver cannot get the memory address of
> > > > > > the
> > > > > > CLINT
> > > > > > device. This error is currently silently ignored.
> > > > > 
> > > > > I still don't understand. Why does the CLINT driver fail to
> > > > > get
> > > > > the
> > > > > memory address? U-Boot has been supporting "simpile-bus" for
> > > > > a
> > > > > long
> > > > > time. It was because QEMU 3.0.0 generated the /soc node with
> > > > > "riscv-virtio-soc" compatible string, U-Boot was taught to
> > > > > treat
> > > > > such
> > > > > compatible string as a "simple-bus" too (that was the U-Boot
> > > > > commit
> > > > > 27dc2c130e29)
> > > > 
> > > > That's correct. The problem with the default simple-bus U-Boot
> > > > driver
> > > > is that it does not have the DM_FLAG_PRE_RELOC flag set. The
> > > > /soc
> > > > and
> > > > /soc/clint nodes are therefore not available before relocation,
> > > > meaning
> > > > that IPIs cannot be sent to relocate the secondary harts.
> > > > 
> > > 
> > > Thanks for the clarifications. Now I see the problem. But I think
> > > we
> > > should fix U-Boot "simple-bus" driver instead. As seen on FU540
> > > or
> > > likely other hardware, QEMU generates the "simple-bus" compatible
> > > string for the /soc node, as well as the DT provided by the
> > > hardware.
> > > 
> > 
> > That makes sense, I can send a patch to set the DM_FLAG_PRE_RELOC
> > flag
> > in the simple-bus U-Boot driver. I think it's best to send it
> > separately from the SMP patch series, since it could affect other
> > boards and it's a bit late in the release cycle. What do you think?
> > 
> 
> Yes, agreed that the "simple-bus" driver changes should be next U-
> Boot
> release. We should try to get the U-Boot SMP series in the v2019.04
> release.
> 

Yes definitely, I have just sent version 3 of the series. I hope it is
ready to go into mainline now.

Thanks,
Lukas

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

* Re: [Qemu-riscv] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-02-10 20:17 ` [Qemu-riscv] " Lukas Auer
                   ` (2 preceding siblings ...)
  (?)
@ 2019-03-19 12:19 ` Palmer Dabbelt
  2019-03-19 12:32   ` Auer, Lukas
  -1 siblings, 1 reply; 21+ messages in thread
From: Palmer Dabbelt @ 2019-03-19 12:19 UTC (permalink / raw)
  To: lukas.auer
  Cc: qemu-devel, qemu-riscv, lukas.auer, Alistair Francis, mjc,
	Bastian Koppelmann, sagark

On Sun, 10 Feb 2019 12:17:26 PST (-0800), lukas.auer@aisec.fraunhofer.de wrote:
> Re-add the previous compatible string "riscv-virtio-soc" to the soc
> device tree node to allow U-Boot and Linux to bind machine-specific
> drivers to it. The current compatible string "simple-bus" is retained.
>
> This is required by U-Boot to bind devices early, as part of the
> pre-relocation driver model.
>
> Fixes: 53f54508dae6("hw/riscv/virtio: Set the soc device tree node as a
> simple-bus")
> Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>

I still had this at the top of my patch queue, but from looking at the thread 
it appears the resolution here is to drop this in favor of generic support.  
LMK if I missed something.

> ---
>
>  hw/riscv/virt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index 3e8b19c668..c53bb905ff 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -157,6 +157,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
>      char *nodename;
>      uint32_t plic_phandle, phandle = 1;
>      int i;
> +    const char soc_compat[] = "riscv-virtio-soc\0simple-bus";
>
>      fdt = s->fdt = create_device_tree(&s->fdt_size);
>      if (!fdt) {
> @@ -171,7 +172,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
>
>      qemu_fdt_add_subnode(fdt, "/soc");
>      qemu_fdt_setprop(fdt, "/soc", "ranges", NULL, 0);
> -    qemu_fdt_setprop_string(fdt, "/soc", "compatible", "simple-bus");
> +    qemu_fdt_setprop(fdt, "/soc", "compatible", soc_compat, sizeof(soc_compat));
>      qemu_fdt_setprop_cell(fdt, "/soc", "#size-cells", 0x2);
>      qemu_fdt_setprop_cell(fdt, "/soc", "#address-cells", 0x2);


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

* Re: [Qemu-riscv] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node
  2019-03-19 12:19 ` [Qemu-riscv] " Palmer Dabbelt
@ 2019-03-19 12:32   ` Auer, Lukas
  0 siblings, 0 replies; 21+ messages in thread
From: Auer, Lukas @ 2019-03-19 12:32 UTC (permalink / raw)
  To: palmer; +Cc: qemu-riscv, qemu-devel, kbastian, mjc, Alistair.Francis, sagark

On Tue, 2019-03-19 at 05:19 -0700, Palmer Dabbelt wrote:
> On Sun, 10 Feb 2019 12:17:26 PST (-0800), 
> lukas.auer@aisec.fraunhofer.de wrote:
> > Re-add the previous compatible string "riscv-virtio-soc" to the soc
> > device tree node to allow U-Boot and Linux to bind machine-specific
> > drivers to it. The current compatible string "simple-bus" is
> > retained.
> > 
> > This is required by U-Boot to bind devices early, as part of the
> > pre-relocation driver model.
> > 
> > Fixes: 53f54508dae6("hw/riscv/virtio: Set the soc device tree node
> > as a
> > simple-bus")
> > Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> 
> I still had this at the top of my patch queue, but from looking at
> the thread 
> it appears the resolution here is to drop this in favor of generic
> support.  
> LMK if I missed something.

Yes, you are right. We are going to fix this from the U-Boot side, so
this patch can be dropped.

Thanks,
Lukas

> 
> > ---
> > 
> >  hw/riscv/virt.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> > index 3e8b19c668..c53bb905ff 100644
> > --- a/hw/riscv/virt.c
> > +++ b/hw/riscv/virt.c
> > @@ -157,6 +157,7 @@ static void *create_fdt(RISCVVirtState *s,
> > const struct MemmapEntry *memmap,
> >      char *nodename;
> >      uint32_t plic_phandle, phandle = 1;
> >      int i;
> > +    const char soc_compat[] = "riscv-virtio-soc\0simple-bus";
> > 
> >      fdt = s->fdt = create_device_tree(&s->fdt_size);
> >      if (!fdt) {
> > @@ -171,7 +172,7 @@ static void *create_fdt(RISCVVirtState *s,
> > const struct MemmapEntry *memmap,
> > 
> >      qemu_fdt_add_subnode(fdt, "/soc");
> >      qemu_fdt_setprop(fdt, "/soc", "ranges", NULL, 0);
> > -    qemu_fdt_setprop_string(fdt, "/soc", "compatible", "simple-
> > bus");
> > +    qemu_fdt_setprop(fdt, "/soc", "compatible", soc_compat,
> > sizeof(soc_compat));
> >      qemu_fdt_setprop_cell(fdt, "/soc", "#size-cells", 0x2);
> >      qemu_fdt_setprop_cell(fdt, "/soc", "#address-cells", 0x2);

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

end of thread, other threads:[~2019-03-19 12:33 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-10 20:17 [Qemu-devel] [PATCH] hw/riscv/virt: re-add machine-specific compatible string to /soc/ node Lukas Auer
2019-02-10 20:17 ` [Qemu-riscv] " Lukas Auer
2019-02-11 23:43 ` [Qemu-devel] " Alistair Francis
2019-02-11 23:43   ` [Qemu-riscv] " Alistair Francis
2019-03-10  1:07 ` Bin Meng
2019-03-10  1:07   ` [Qemu-riscv] " Bin Meng
2019-03-10 13:44   ` Auer, Lukas
2019-03-10 13:44     ` [Qemu-riscv] " Auer, Lukas
2019-03-10 14:57     ` Bin Meng
2019-03-10 14:57       ` [Qemu-riscv] " Bin Meng
2019-03-10 18:03       ` Auer, Lukas
2019-03-10 18:03         ` [Qemu-riscv] " Auer, Lukas
2019-03-11 15:28         ` Bin Meng
2019-03-11 15:28           ` [Qemu-riscv] " Bin Meng
2019-03-12 14:39           ` Auer, Lukas
2019-03-13  1:51             ` Bin Meng
2019-03-14 21:01               ` Auer, Lukas
2019-03-15  1:54                 ` Bin Meng
2019-03-17 18:57                   ` Auer, Lukas
2019-03-19 12:19 ` [Qemu-riscv] " Palmer Dabbelt
2019-03-19 12:32   ` Auer, Lukas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.