[PATCH] pci: fix interrupt-map for bridges
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 a...@ozlabs.ru --- This is the example of working system: [root@erif_root pci@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@erif_root pci@1]# pwd /proc/device-tree/pci@800200f/pci@1 [root@erif_root pci@1]# hexdump -e '9/4 %08x ' -e '\n' i*map 1000 0001 3e57f7e0 0800 0003 1000 0002 3e57f7e0 0800 1000 0003 3e57f7e0 0800 0001 1000 0004 3e57f7e0 0800 0002 1800 0001 3e57f7e0 0800 1800 0002 3e57f7e0 0800 0001 1800 0003 3e57f7e0 0800 0002 1800 0004 3e57f7e0 0800 0003 [root@erif_root pci@1]# cd pci@2/ [root@erif_root pci@2]# hexdump -e '9/4 %08x ' -e '\n' i*map 0800 0001 3e5a86f0 1000 0002 0800 0002 3e5a86f0 1000 0003 0800 0003 3e5a86f0 1000 0800 0004 3e5a86f0 1000 0001 1000 0001 3e5a86f0 1000 0003 1000 0002 3e5a86f0 1000 1000 0003 3e5a86f0 1000 0001 1000 0004 3e5a86f0 1000 0002 [root@erif_root pci@2]# cd ethernet@ ethernet@1/ ethernet@2/ [root@erif_root pci@2]# cd ethernet@1/ [root@erif_root ethernet@1]# lsprop reg reg 00020800 02020810 0002 02020814 0002 01020818 0020 02020830 0002 [root@erif_root ethernet@1]# lsprop interrupts interrupts 0002 --- 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..62785a7 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 r( prop-addr prop-len R: swizzledpin pin slot ) + +\ Child slot# +r 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
Re: [PATCH] pci: fix interrupt-map for bridges
Alexey Kardashevskiy a...@ozlabs.ru writes: 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 a...@ozlabs.ru --- This is the example of working system: [root@erif_root pci@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@erif_root pci@1]# pwd /proc/device-tree/pci@800200f/pci@1 [root@erif_root pci@1]# hexdump -e '9/4 %08x ' -e '\n' i*map 1000 0001 3e57f7e0 0800 0003 1000 0002 3e57f7e0 0800 1000 0003 3e57f7e0 0800 0001 1000 0004 3e57f7e0 0800 0002 1800 0001 3e57f7e0 0800 1800 0002 3e57f7e0 0800 0001 1800 0003 3e57f7e0 0800 0002 1800 0004 3e57f7e0 0800 0003 [root@erif_root pci@1]# cd pci@2/ [root@erif_root pci@2]# hexdump -e '9/4 %08x ' -e '\n' i*map 0800 0001 3e5a86f0 1000 0002 0800 0002 3e5a86f0 1000 0003 0800 0003 3e5a86f0 1000 0800 0004 3e5a86f0 1000 0001 1000 0001 3e5a86f0 1000 0003 1000 0002 3e5a86f0 1000 1000 0003 3e5a86f0 1000 0001 1000 0004 3e5a86f0 1000 0002 [root@erif_root pci@2]# cd ethernet@ ethernet@1/ ethernet@2/ [root@erif_root pci@2]# cd ethernet@1/ [root@erif_root ethernet@1]# lsprop reg reg 00020800 02020810 0002 02020814 0002 01020818 0020 02020830 0002 [root@erif_root ethernet@1]# lsprop interrupts interrupts 0002 --- 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..62785a7 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 r( prop-addr prop-len R: swizzledpin pin slot ) + +\ Child slot# +r B lshift encode-int+ ( prop-addr prop-len R: swizzledpin pin ) Redundant push to the R-Stack, can just be 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 -