2012-03-22 12:09:55 +08:00
|
|
|
|
|
|
|
: pci-gen-irq-map-one ( prop-addr prop-len slot pin -- prop-addr prop-len )
|
Fix bad interrupt pin numbering in interrupt-map property of PCI bridges
The legacy PCI interrupts in the device tree are enumerated from 1
to 4. However, the code in pci-gen-irq-map-one generates numbers
between 0 and 3 instead. This renders devices unusable by Linux
in case they should use IRQ 4. For example, when starting QEMU with
qemu-system-ppc64 ... \
-device pci-bridge,bus=pci.0,id=bridge1,chassis_nr=1,addr=0x6 \
-device virtio-balloon-pci,id=balloon0,bus=bridge1,addr=3
Linux can not use the balloon device since it is unable to determine
the right IRQ number in this case.
To fix this issue, we've simply got to make sure that the IRQ
numbers are in the range from 1 to 4 instead of 0 to 3.
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1366953
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-09-08 17:05:56 +08:00
|
|
|
2dup + 1- 3 and 1+ ( prop-addr prop-len slot pin parentpin )
|
2013-09-24 15:22:14 +08:00
|
|
|
>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 )
|
2012-03-22 12:09:55 +08:00
|
|
|
|
2013-09-24 15:22:14 +08:00
|
|
|
\ Parent phandle
|
|
|
|
get-parent encode-int+
|
2012-03-22 12:09:55 +08:00
|
|
|
|
2013-09-24 15:22:14 +08:00
|
|
|
\ Parent slot#
|
|
|
|
get-node >space
|
|
|
|
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: )
|
2012-03-22 12:09:55 +08:00
|
|
|
;
|
|
|
|
|
2012-01-10 19:39:42 +08:00
|
|
|
: pci-gen-irq-entry ( prop-addr prop-len config-addr -- prop-addr prop-len )
|
Allow PCI devices in PCI bridge slots greater than 4
PCI bridges can have up to 31 slots. If we limit the value
from pci-addr2dev with "modulo 4", all devices in slots 4
and higher won't work correctly since the interrupt-map
property then contains wrong values in this case. For
example, when QEMU is started with the following command
line, Linux is not able to use the balloon device:
qemu-system-ppc64 ... \
-device pci-bridge,bus=pci.0,id=bridge1,chassis_nr=1,addr=0x6 \
-device virtio-balloon-pci,id=balloon0,bus=bridge1,addr=5
To fix this issue, simply remove the bogus "4 mod" calculation.
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1366953
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-09-08 17:05:57 +08:00
|
|
|
pci-addr2dev ( prop-addr prop-len slot )
|
2012-03-22 12:09:55 +08:00
|
|
|
-rot ( slot prop-addr prop-len )
|
|
|
|
5 1 DO
|
|
|
|
2 pick i ( slot prop-addr prop-len slot pin )
|
|
|
|
pci-gen-irq-map-one
|
|
|
|
LOOP
|
|
|
|
rot drop
|
2012-01-10 19:39:42 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
: pci-set-irq-line ( config-addr -- )
|
|
|
|
drop
|
|
|
|
;
|