Skip to contentSkip to conversation

qemu: arm: Scan the pci bus in board_init

PATCH New Sughosh Ganu 4 participants 8 messages Dec 31, 2019 – Mar 14, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu: arm: Scan the pci bus in board_init

Scan the pci bus in board_init routine before scanning the virtio devices. This enumerates all the virtio devices, including devices found on the pci bus.

---
 board/emulation/qemu-arm/qemu-arm.c | 7 +++++++
 1 file changed, 7 insertions(+)
board/emulation/qemu-arm/qemu-arm.c +7 -0
index 4e18733..6c5335c 100644
@@ -63,6 +63,13 @@ struct mm_region *mem_map = qemu_arm64_mem_map;
 int board_init(void)
 {
 	/*
+	 * Scan the pci bus before calling virtio_init. This
+	 * enumerates all virtio devices, including devices
+	 * on the pci bus.
+	 */
+	pci_init();
+
+	/*
 	 * Make sure virtio bus is enumerated so that peripherals
 	 * on the virtio bus can be discovered by their drivers
 	 */
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 qemu: arm: Scan the pci bus in board_init

Quoted 10 lines · Sughosh Ganu

Scan the pci bus in board_init routine before scanning the virtio devices. This enumerates all the virtio devices, including devices found on the pci bus.

---
 board/emulation/qemu-arm/qemu-arm.c | 7 +++++++
 1 file changed, 7 insertions(+)
#2 lore raw

PATCH 1/1 qemu: arm: Scan the pci bus in board_init

In reply to Sughosh Ganu
Quoted 14 lines · Sughosh Ganu

Scan the pci bus in board_init routine before scanning the virtio devices. This enumerates all the virtio devices, including devices found on the pci bus.

---
 board/emulation/qemu-arm/qemu-arm.c | 7 +++++++
 1 file changed, 7 insertions(+)
board/emulation/qemu-arm/qemu-arm.c +0 -0
index 4e18733..6c5335c 100644

board/emulation/qemu-arm/qemu-arm.c struct mm_region *mem_map = qemu_arm64_mem_map; · line 68

Quoted 6 lines
board/emulation/qemu-arm/qemu-arm.c +3 -0
@@ -63,6 +63,13 @@ struct mm_region *mem_map = qemu_arm64_mem_map;
 int board_init(void)
 {
 	/*
+	 * Scan the pci bus before calling virtio_init. This
+	 * enumerates all virtio devices, including devices
+	 * on the pci bus.

The last sentence is easy to misunderstand. You surely do not mean that pci_init() would enumerate all virtio devices including mmio virtio devices.

I would suggest to rephrase it to "This enumerates all pci devices including virtio devices on the pci bus."

With the patch I no longer need to run virtio scan on qemu_arm64_defonfig before using the rng command supplied in patch

[PATCH 1/1] cmd: add rng command
https://lists.denx.de/pipermail/u-boot/2019-December/394539.html

Unfortunately you only considered the ARM architecture. We need a solution that works on all QEMU architectures (MIPS, RISC-V, X86, ARM).

How about eliminating board_init() for ARM and RISC-V and moving virtio_init() to common/board_r.c after initr_pci?

Best regards

Heinrich

Quoted 8 lines
board/emulation/qemu-arm/qemu-arm.c +4 -0
+	 */
+	pci_init();
+
+	/*
 	 * Make sure virtio bus is enumerated so that peripherals
 	 * on the virtio bus can be discovered by their drivers
 	 */
#3 lore raw

PATCH 1/1 qemu: arm: Scan the pci bus in board_init

CC Bin Meng

Quoted 54 lines · Heinrich Schuchardt
Quoted 14 lines · Sughosh Ganu

Scan the pci bus in board_init routine before scanning the virtio devices. This enumerates all the virtio devices, including devices found on the pci bus.

---
 board/emulation/qemu-arm/qemu-arm.c | 7 +++++++
 1 file changed, 7 insertions(+)
board/emulation/qemu-arm/qemu-arm.c +0 -0
index 4e18733..6c5335c 100644

board/emulation/qemu-arm/qemu-arm.c struct mm_region *mem_map = qemu_arm64_mem_map; · line 68

Quoted 6 lines
board/emulation/qemu-arm/qemu-arm.c +3 -0
@@ -63,6 +63,13 @@ struct mm_region *mem_map = qemu_arm64_mem_map;
 int board_init(void)
 {
 	/*
+	 * Scan the pci bus before calling virtio_init. This
+	 * enumerates all virtio devices, including devices
+	 * on the pci bus.

The last sentence is easy to misunderstand. You surely do not mean that pci_init() would enumerate all virtio devices including mmio virtio devices.

I would suggest to rephrase it to "This enumerates all pci devices including virtio devices on the pci bus."

With the patch I no longer need to run virtio scan on qemu_arm64_defonfig before using the rng command supplied in patch

[PATCH 1/1] cmd: add rng command
https://lists.denx.de/pipermail/u-boot/2019-December/394539.html

Unfortunately you only considered the ARM architecture. We need a solution that works on all QEMU architectures (MIPS, RISC-V, X86, ARM).

How about eliminating board_init() for ARM and RISC-V and moving virtio_init() to common/board_r.c after initr_pci?

Best regards

Heinrich

Quoted 8 lines
board/emulation/qemu-arm/qemu-arm.c +4 -0
+	 */
+	pci_init();
+
+	/*
 	 * Make sure virtio bus is enumerated so that peripherals
 	 * on the virtio bus can be discovered by their drivers
 	 */
#4 lore raw

PATCH 1/1 qemu: arm: Scan the pci bus in board_init

Quoted 31 lines · Heinrich Schuchardt

CC Bin Meng

Quoted 27 lines · Heinrich Schuchardt
Quoted 14 lines · Sughosh Ganu

Scan the pci bus in board_init routine before scanning the virtio devices. This enumerates all the virtio devices, including devices found on the pci bus.

---
 board/emulation/qemu-arm/qemu-arm.c | 7 +++++++
 1 file changed, 7 insertions(+)
board/emulation/qemu-arm/qemu-arm.c +0 -0
index 4e18733..6c5335c 100644

board/emulation/qemu-arm/qemu-arm.c struct mm_region *mem_map = qemu_arm64_mem_map; · line 68

Quoted 6 lines
board/emulation/qemu-arm/qemu-arm.c +3 -0
@@ -63,6 +63,13 @@ struct mm_region *mem_map = qemu_arm64_mem_map;
 int board_init(void)
 {
     /*
+     * Scan the pci bus before calling virtio_init. This
+     * enumerates all virtio devices, including devices
+     * on the pci bus.

The last sentence is easy to misunderstand. You surely do not mean that pci_init() would enumerate all virtio devices including mmio virtio devices.

I would suggest to rephrase it to "This enumerates all pci devices including virtio devices on the pci bus."

Sounds good.

Quoted 10 lines
Quoted 10 lines

With the patch I no longer need to run virtio scan on qemu_arm64_defonfig before using the rng command supplied in patch

[PATCH 1/1] cmd: add rng command
https://lists.denx.de/pipermail/u-boot/2019-December/394539.html

Unfortunately you only considered the ARM architecture. We need a solution that works on all QEMU architectures (MIPS, RISC-V, X86, ARM).

Agreed, sorry I missed that. Actually all the board_init() look similar so we should do the same.

Quoted 3 lines
Quoted 3 lines

How about eliminating board_init() for ARM and RISC-V and moving virtio_init() to common/board_r.c after initr_pci?

Or maybe we introduce a new driver model flag so that uclass drivers are automatically probed?

Regards,
Bin

#5 lore raw

PATCH 1/1 qemu: arm: Scan the pci bus in board_init

In reply to Heinrich Schuchardt
Quoted 27 lines · Heinrich Schuchardt

Review

Quoted 10 lines · Sughosh Ganu

Scan the pci bus in board_init routine before scanning the virtio devices. This enumerates all the virtio devices, including devices found on the pci bus.

---
 board/emulation/qemu-arm/qemu-arm.c | 7 +++++++
 1 file changed, 7 insertions(+)
(quoted diff) +0 -0

b/board/emulation/qemu-arm/qemu-arm.c

board/emulation/qemu-arm/qemu-arm.c struct mm_region *mem_map = qemu_arm64_mem_map; · line 68

Quoted 10 lines

index 4e18733..6c5335c 100644

board/emulation/qemu-arm/qemu-arm.c +3 -0
@@ -63,6 +63,13 @@ struct mm_region *mem_map = qemu_arm64_mem_map;
 int board_init(void)
 {
      /*
+      * Scan the pci bus before calling virtio_init. This
+      * enumerates all virtio devices, including devices
+      * on the pci bus.

The last sentence is easy to misunderstand. You surely do not mean that pci_init() would enumerate all virtio devices including mmio virtio devices.

Quoted 3 lines

I would suggest to rephrase it to "This enumerates all pci devices including virtio devices on the pci bus."

Ok.

Quoted 10 lines

With the patch I no longer need to run virtio scan on qemu_arm64_defonfig before using the rng command supplied in patch

[PATCH 1/1] cmd: add rng command
https://lists.denx.de/pipermail/u-boot/2019-December/394539.html

Unfortunately you only considered the ARM architecture. We need a solution that works on all QEMU architectures (MIPS, RISC-V, X86, ARM).

That is fine with me, but currently, only risc-v and arm architectures are calling virtio_init.

Quoted 4 lines

How about eliminating board_init() for ARM and RISC-V and moving virtio_init() to common/board_r.c after initr_pci?

That can be done, but currently, for some reason, initr_pci function calls pci_init only when CONFIG_DM_PCI is not defined. Not sure why that is the case, although initr_pci gets called after initr_dm.

-sughosh

#6 lore raw

PATCH 1/1 qemu: arm: Scan the pci bus in board_init

Quoted 57 lines · Sughosh Ganu

On Tue, 31 Dec 2019 at 20:38, Heinrich Schuchardt <[email protected] <mailto:[email protected]>> wrote:

On 12/31/19 2:31 PM, Sughosh Ganu wrote:
> Scan the pci bus in board_init routine before scanning the virtio > devices. This enumerates all the virtio devices, including devices > found on the pci bus.
>
> Signed-off-by: Sughosh Ganu <[email protected]
<mailto:[email protected]>>
> ---
>  board/emulation/qemu-arm/qemu-arm.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/board/emulation/qemu-arm/qemu-arm.c
b/board/emulation/qemu-arm/qemu-arm.c
> index 4e18733..6c5335c 100644
> --- a/board/emulation/qemu-arm/qemu-arm.c
> +++ b/board/emulation/qemu-arm/qemu-arm.c
> @@ -63,6 +63,13 @@ struct mm_region *mem_map = qemu_arm64_mem_map; >  int board_init(void)
>  {
>       /*
> +      * Scan the pci bus before calling virtio_init. This > +      * enumerates all virtio devices, including devices > +      * on the pci bus.

The last sentence is easy to misunderstand. You surely do not mean that pci_init() would enumerate all virtio devices including mmio virtio devices.

I would suggest to rephrase it to "This enumerates all pci devices including virtio devices on the pci bus."

Ok.

With the patch I no longer need to run virtio scan on qemu_arm64_defonfig before using the rng command supplied in patch

[PATCH 1/1] cmd: add rng command
https://lists.denx.de/pipermail/u-boot/2019-December/394539.html

Unfortunately you only considered the ARM architecture. We need a solution that works on all QEMU architectures (MIPS, RISC-V, X86, ARM).

That is fine with me, but currently, only risc-v and arm architectures are calling virtio_init.

How about eliminating board_init() for ARM and RISC-V and moving virtio_init() to common/board_r.c after initr_pci?

Quoted 5 lines

That can be done, but currently, for some reason, initr_pci function calls pci_init only when CONFIG_DM_PCI is not defined. Not sure why that is the case, although initr_pci gets called after initr_dm.

-sughosh

This dates back to Simon's commit ff3e077bd23c ("dm: pci: Add a uclass for PCI").

I hope that Simon can tell us why he chose not to call pci_init() if DM_PCI is defined.

Best regards

Heinrich

#7 lore raw

PATCH 1/1 qemu: arm: Scan the pci bus in board_init

Hi Heinrich,

Quoted 63 lines · Heinrich Schuchardt
Quoted 61 lines · Sughosh Ganu

On Tue, 31 Dec 2019 at 20:38, Heinrich Schuchardt <[email protected] <mailto:[email protected]>> wrote:

On 12/31/19 2:31 PM, Sughosh Ganu wrote:
> Scan the pci bus in board_init routine before scanning the virtio > devices. This enumerates all the virtio devices, including devices > found on the pci bus.
>
> Signed-off-by: Sughosh Ganu <[email protected]
<mailto:[email protected]>>
> ---
> board/emulation/qemu-arm/qemu-arm.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/board/emulation/qemu-arm/qemu-arm.c
b/board/emulation/qemu-arm/qemu-arm.c
> index 4e18733..6c5335c 100644
> --- a/board/emulation/qemu-arm/qemu-arm.c
> +++ b/board/emulation/qemu-arm/qemu-arm.c
> @@ -63,6 +63,13 @@ struct mm_region *mem_map = qemu_arm64_mem_map; > int board_init(void)
> {
> /*
> + * Scan the pci bus before calling virtio_init. This
> + * enumerates all virtio devices, including devices
> + * on the pci bus.

The last sentence is easy to misunderstand. You surely do not mean that pci_init() would enumerate all virtio devices including mmio virtio devices.

I would suggest to rephrase it to "This enumerates all pci devices including virtio devices on the pci bus."

Ok.

With the patch I no longer need to run virtio scan on qemu_arm64_defonfig before using the rng command supplied in patch

[PATCH 1/1] cmd: add rng command
https://lists.denx.de/pipermail/u-boot/2019-December/394539.html

Unfortunately you only considered the ARM architecture. We need a solution that works on all QEMU architectures (MIPS, RISC-V, X86, ARM).

That is fine with me, but currently, only risc-v and arm architectures are calling virtio_init.

How about eliminating board_init() for ARM and RISC-V and moving virtio_init() to common/board_r.c after initr_pci?

That can be done, but currently, for some reason, initr_pci function calls pci_init only when CONFIG_DM_PCI is not defined. Not sure why that is the case, although initr_pci gets called after initr_dm.

Quoted 7 lines
Quoted 1 line

-sughosh

This dates back to Simon's commit ff3e077bd23c ("dm: pci: Add a uclass for PCI").

I hope that Simon can tell us why he chose not to call pci_init() if DM_PCI is defined.

Driver model uses lazy init. We have discussed this before, and considered using a uclass flag to tell U-Boot that the uclass needs to be fully probed (i.e. probe all devices in that uclass, recursively).

But I'm not sure we got agreement. If you think it is a good idea you could send a patch. The only thing is that I think some platforms don't need PCI to boot so might not want this?

Regards,
Simon