[SLOF] [PATCH] pci: walk through the PCI DT in reverse order

Greg Kurz gkurz at linux.vnet.ibm.com
Fri Nov 27 03:34:01 AEDT 2015


With the same set of devices, if QEMU does not do the PCI Enumeration (old
QEMU that doesn't set the qemu,phb-enumerated property), we get:

Populating /pci at 800000020000000
 Adapters on 0800000020000000
                     00 0800 (D) : 1af4 1000    virtio [ net ]
                     00 1000 (D) : 106b 003f    serial bus [ usb-ohci ]
                     00 1800 (D) : 1af4 1003    communication-controller*
                     00 2000 (D) : 1af4 1001    virtio [ block ]
                     00 2800 (D) : 1af4 1001    virtio [ block ]
                     00 3000 (D) : 1af4 1001    virtio [ block ]
                     00 3800 (D) : 1af4 1002    unknown-legacy-device*

but in the case of a newer QEMU, when SLOF walks through the DT, we get:

Populating /pci at 800000020000000
                     00 3800 (D) : 1af4 1002    unknown-legacy-device*
                     00 3000 (D) : 1af4 1001    virtio [ block ]
                     00 2800 (D) : 1af4 1001    virtio [ block ]
                     00 2000 (D) : 1af4 1001    virtio [ block ]
                     00 1800 (D) : 1af4 1003    communication-controller*
                     00 1000 (D) : 106b 003f    serial bus [ usb-ohci ]
                     00 0800 (D) : 1af4 1000    virtio [ net ]

This is a confusing behaviour change for users. This patch fixes that: we
push all the child nodes to the stack and configure them in reverse order.

Fixes: be9b2fa44c73201518aec2431137b4b2d4924945
Signed-off-by: Greg Kurz <gkurz at linux.vnet.ibm.com>
---
 board-qemu/slof/pci-phb.fs |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/board-qemu/slof/pci-phb.fs b/board-qemu/slof/pci-phb.fs
index a8fb7ca5e233..a1f86022cfe2 100644
--- a/board-qemu/slof/pci-phb.fs
+++ b/board-qemu/slof/pci-phb.fs
@@ -287,10 +287,18 @@ setup-puid
 
     get-node child ?dup 0= IF EXIT THEN    \ get and check if we have children
     0 to pci-device-slots                  \ reset slot array to unpoppulated
+    0 swap                                 \ terminator to end walk
     BEGIN
         dup                                \ Continue as long as there are children
     WHILE
-        dup set-node                       \ Set child node as current node
+        dup
+        peer
+    REPEAT drop
+
+    BEGIN                                  \ walk in reverse order
+        dup
+    WHILE
+        set-node                           \ Set child node as current node
         my-space pci-set-slot              \ set the slot bit
         my-space pci-htype@                \ read HEADER-Type
         7f and                             \ Mask bit 7 - multifunction device
@@ -299,7 +307,6 @@ setup-puid
             1 OF my-space pci-bridge-setup ENDOF  \ | set up the bridge
             dup OF my-space pci-htype@ pci-out ENDOF
         ENDCASE
-        peer
     REPEAT drop
     get-parent set-node
 ;



More information about the SLOF mailing list