diff mbox

pci-phb: Set pci-max-mem64 to the correct value

Message ID 1493354067-13034-1-git-send-email-thuth@redhat.com
State Superseded
Headers show

Commit Message

Thomas Huth April 28, 2017, 4:34 a.m. UTC
When running QEMU with a virtio device attached to a PCI bridge,
SLOF currently fails to initialize the device correctly. For example,
with the following command line:

 qemu-system-ppc64 -nographic -nodefaults -serial mon:stdio \
               -device pci-bridge,bus=pci.0,id=b1,chassis_nr=1 \
               -device virtio-net-pci,netdev=n1,bus=b1 -netdev user,id=n1

SLOF prints this error message during its PCI scan:

 Device does not support virtio 1.0 0
 virtio-net-open failedexiting

This happens because the virtio driver code can not access the
memory region of the device, because the bridge is configured
in the wrong way. The problem is that SLOF currently sets the
pci-max-mem64 variable to the size of the 64-bit PCI address space,
but it should be set to the end address of the 64-bit space instead.
The pci-max-mem64 is used for the memory limit register of the PCI
bridge (see pci-bridge-set-mem-base) during PCI scan, and using
a wrong value here blocks all memory accesses to the devices behind
the bridge.
So fix this issue by calculating the pci-max-mem64 value correctly.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 board-qemu/slof/pci-phb.fs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Nikunj A Dadhania April 28, 2017, 5:04 a.m. UTC | #1
Thomas Huth <thuth@redhat.com> writes:

> When running QEMU with a virtio device attached to a PCI bridge,
> SLOF currently fails to initialize the device correctly. For example,
> with the following command line:
>
>  qemu-system-ppc64 -nographic -nodefaults -serial mon:stdio \
>                -device pci-bridge,bus=pci.0,id=b1,chassis_nr=1 \
>                -device virtio-net-pci,netdev=n1,bus=b1 -netdev user,id=n1
>
> SLOF prints this error message during its PCI scan:
>
>  Device does not support virtio 1.0 0
>  virtio-net-open failedexiting
>
> This happens because the virtio driver code can not access the
> memory region of the device, because the bridge is configured
> in the wrong way. The problem is that SLOF currently sets the
> pci-max-mem64 variable to the size of the 64-bit PCI address space,
> but it should be set to the end address of the 64-bit space instead.
> The pci-max-mem64 is used for the memory limit register of the PCI
> bridge (see pci-bridge-set-mem-base) during PCI scan, and using
> a wrong value here blocks all memory accesses to the devices behind
> the bridge.
> So fix this issue by calculating the pci-max-mem64 value correctly.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>

> ---
>  board-qemu/slof/pci-phb.fs | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/board-qemu/slof/pci-phb.fs b/board-qemu/slof/pci-phb.fs
> index fc2341c..6dfb2e6 100644
> --- a/board-qemu/slof/pci-phb.fs
> +++ b/board-qemu/slof/pci-phb.fs
> @@ -261,9 +261,9 @@ setup-puid
>              r> + pci-max-mmio !                 \ calc max MMIO address
>           ENDOF
>           3000000 OF                             \ 64-bit memory space?
> -	    decode-64 pci-next-mem64 !
> -	    decode-64 drop                      \ Forget the parent address
> -	    decode-64 pci-max-mem64 !
> +            decode-64 dup >r pci-next-mem64 !
> +            decode-64 drop                      \ Forget the parent address
> +            decode-64 r> + pci-max-mem64 !
>           ENDOF
>        ENDCASE
>     REPEAT
> -- 
> 1.8.3.1
Alexey Kardashevskiy April 28, 2017, 5:55 a.m. UTC | #2
On Fri, 28 Apr 2017 06:34:27 +0200
Thomas Huth <thuth@redhat.com> wrote:

> When running QEMU with a virtio device attached to a PCI bridge,
> SLOF currently fails to initialize the device correctly. For example,
> with the following command line:
> 
>  qemu-system-ppc64 -nographic -nodefaults -serial mon:stdio \
>                -device pci-bridge,bus=pci.0,id=b1,chassis_nr=1 \
>                -device virtio-net-pci,netdev=n1,bus=b1 -netdev
> user,id=n1
> 
> SLOF prints this error message during its PCI scan:
> 
>  Device does not support virtio 1.0 0
>  virtio-net-open failedexiting
> 
> This happens because the virtio driver code can not access the
> memory region of the device, because the bridge is configured
> in the wrong way.
>
> The problem is that SLOF currently sets the
> pci-max-mem64 variable to the size of the 64-bit PCI address space,
> but it should be set to the end address of the 64-bit space instead.
> The pci-max-mem64 is used for the memory limit register of the PCI
> bridge (see pci-bridge-set-mem-base) during PCI scan, and using
> a wrong value here blocks all memory accesses to the devices behind
> the bridge.
> So fix this issue by calculating the pci-max-mem64 value correctly.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>


Thanks, applied, will push soon.

> ---
>  board-qemu/slof/pci-phb.fs | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/board-qemu/slof/pci-phb.fs b/board-qemu/slof/pci-phb.fs
> index fc2341c..6dfb2e6 100644
> --- a/board-qemu/slof/pci-phb.fs
> +++ b/board-qemu/slof/pci-phb.fs
> @@ -261,9 +261,9 @@ setup-puid
>              r> + pci-max-mmio !                 \ calc max MMIO
>              r> address  
>           ENDOF
>           3000000 OF                             \ 64-bit memory
> space?
> -	    decode-64 pci-next-mem64 !
> -	    decode-64 drop                      \ Forget the parent
> address
> -	    decode-64 pci-max-mem64 !
> +            decode-64 dup >r pci-next-mem64 !
> +            decode-64 drop                      \ Forget the parent
> address
> +            decode-64 r> + pci-max-mem64 !
>           ENDOF
>        ENDCASE
>     REPEAT



--
Alexey
diff mbox

Patch

diff --git a/board-qemu/slof/pci-phb.fs b/board-qemu/slof/pci-phb.fs
index fc2341c..6dfb2e6 100644
--- a/board-qemu/slof/pci-phb.fs
+++ b/board-qemu/slof/pci-phb.fs
@@ -261,9 +261,9 @@  setup-puid
             r> + pci-max-mmio !                 \ calc max MMIO address
          ENDOF
          3000000 OF                             \ 64-bit memory space?
-	    decode-64 pci-next-mem64 !
-	    decode-64 drop                      \ Forget the parent address
-	    decode-64 pci-max-mem64 !
+            decode-64 dup >r pci-next-mem64 !
+            decode-64 drop                      \ Forget the parent address
+            decode-64 r> + pci-max-mem64 !
          ENDOF
       ENDCASE
    REPEAT