[PATCH v2] pci: fix interrupt-map for bridges

Alexey Kardashevskiy aik at ozlabs.ru
Tue Sep 24 17:22:14 EST 2013


The previous scheme always put 0 as a parent slot#. However it is
not always the case and QEMU's PCI bridge does not support putting
device at slot#0 as it claims SHPC support for hotplug.

This modifies the interrups map to let the linux guest resolve XICS
global interrupt number correctly.

Signed-off-by: Alexey Kardashevskiy <aik at ozlabs.ru>
---
Changes:
v2:
* removed redundand r-stack push-pop

---

This is the example of working system:

[root at erif_root pci at 1]# lspci
0001:00:01.0 PCI bridge: Red Hat, Inc. Device 0001
0001:01:02.0 PCI bridge: Red Hat, Inc. Device 0001
0001:01:03.0 PCI bridge: Red Hat, Inc. Device 0001
0001:02:01.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (Copper) (rev 06)
0001:02:02.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (Copper) (rev 06)
0001:03:01.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (Copper) (rev 06)
0001:03:02.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (Copper) (rev 06)
[root at erif_root pci at 1]# pwd
/proc/device-tree/pci at 80000002000000f/pci at 1
[root at erif_root pci at 1]# hexdump -e '9/4 "%08x "' -e '"\n"' i*map
00001000 00000000 00000000 00000001 3e57f7e0 00000800 00000000 00000000 00000003
00001000 00000000 00000000 00000002 3e57f7e0 00000800 00000000 00000000 00000000
00001000 00000000 00000000 00000003 3e57f7e0 00000800 00000000 00000000 00000001
00001000 00000000 00000000 00000004 3e57f7e0 00000800 00000000 00000000 00000002
00001800 00000000 00000000 00000001 3e57f7e0 00000800 00000000 00000000 00000000
00001800 00000000 00000000 00000002 3e57f7e0 00000800 00000000 00000000 00000001
00001800 00000000 00000000 00000003 3e57f7e0 00000800 00000000 00000000 00000002
00001800 00000000 00000000 00000004 3e57f7e0 00000800 00000000 00000000 00000003
[root at erif_root pci at 1]# cd pci at 2/
[root at erif_root pci at 2]# hexdump -e '9/4 "%08x "' -e '"\n"' i*map
00000800 00000000 00000000 00000001 3e5a86f0 00001000 00000000 00000000 00000002
00000800 00000000 00000000 00000002 3e5a86f0 00001000 00000000 00000000 00000003
00000800 00000000 00000000 00000003 3e5a86f0 00001000 00000000 00000000 00000000
00000800 00000000 00000000 00000004 3e5a86f0 00001000 00000000 00000000 00000001
00001000 00000000 00000000 00000001 3e5a86f0 00001000 00000000 00000000 00000003
00001000 00000000 00000000 00000002 3e5a86f0 00001000 00000000 00000000 00000000
00001000 00000000 00000000 00000003 3e5a86f0 00001000 00000000 00000000 00000001
00001000 00000000 00000000 00000004 3e5a86f0 00001000 00000000 00000000 00000002
[root at erif_root pci at 2]# cd ethernet@
ethernet at 1/ ethernet at 2/
[root at erif_root pci at 2]# cd ethernet at 1/
[root at erif_root ethernet at 1]# lsprop reg
reg              00020800 00000000 00000000 00000000 00000000
		 02020810 00000000 00000000 00000000 00020000
 		 02020814 00000000 00000000 00000000 00020000
 		 01020818 00000000 00000000 00000000 00000020
 		 02020830 00000000 00000000 00000000 00020000
[root at erif_root ethernet at 1]# lsprop interrupts
interrupts       00000002
---
 board-qemu/slof/pci-interrupts.fs | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/board-qemu/slof/pci-interrupts.fs b/board-qemu/slof/pci-interrupts.fs
index a12d7bb..e11b779 100644
--- a/board-qemu/slof/pci-interrupts.fs
+++ b/board-qemu/slof/pci-interrupts.fs
@@ -1,17 +1,26 @@
 
 : pci-gen-irq-map-one ( prop-addr prop-len slot pin -- prop-addr prop-len )
-        2dup + 4 mod                                        ( prop-addr prop-len slot pin parentpin )
+        2dup + 4 mod                ( prop-addr prop-len slot pin parentpin )
+        >r >r                       ( prop-addr prop-len slot R: swizzledpin pin )
+
+        \ Child slot#
+        B lshift encode-int+        ( prop-addr prop-len R: swizzledpin pin )
+        \ Child 64bit BAR (not really used)
+        0 encode-64+
+        \ Chile pin#
+        r> encode-int+              ( prop-addr prop-len R: swizzledpin )
+
+        \ Parent phandle
+        get-parent encode-int+
+
+        \ Parent slot#
         get-node >space
-        pci-addr2dev + 1- 4 mod 1+  \ do swizzling          ( prop-addr prop-len slot pin swizzledpin )
-        >r >r >r                                            ( prop-addr prop-len R: swizzledpin pin slot )
-
-        r> B lshift encode-int+
-        0 encode-64+                \ device slot           ( prop-addr prop-len R: swizzledpin pin )
-        r> encode-int+              \ device pin            ( prop-addr prop-len R: swizzledpin )
-
-        get-parent encode-int+      \ parent phandle
-        0 encode-int+ 0 encode-64+  \ parent slot
-        r> encode-int+              \ parent swizzled pin   ( prop-addr prop-len R: )
+        pci-addr2dev B lshift       ( prop-addr prop-len parent-slot R: swizzledpin )
+        encode-int+
+        \ Parent 64bit BAR (not really used)
+        0 encode-64+
+        \ Parent pin
+        r> encode-int+              ( prop-addr prop-len R: )
 ;
 
 : pci-gen-irq-entry ( prop-addr prop-len config-addr -- prop-addr prop-len )
-- 
1.8.4.rc4



More information about the Linuxppc-dev mailing list