aboutsummaryrefslogtreecommitdiff
path: root/slof
diff options
context:
space:
mode:
authorMichael Roth <mdroth@linux.vnet.ibm.com>2017-03-08 01:53:36 -0600
committerAlexey Kardashevskiy <aik@ozlabs.ru>2017-03-09 12:17:29 +1100
commit1903174472f8800caf50c959b304501b4c01153c (patch)
tree810b3f9143c72ffa566c3159e8f1f44a42eaf91a /slof
parent66d250ef0fd06bb88b7399b9563b5008201f2d63 (diff)
downloadSLOF-1903174472f8800caf50c959b304501b4c01153c.zip
SLOF-1903174472f8800caf50c959b304501b4c01153c.tar.gz
SLOF-1903174472f8800caf50c959b304501b4c01153c.tar.bz2
pci: force minimum mem bar alignment of 64K for board-qemu
This is needed to ensure VFIO passthrough devices are able to offload MMIO accesses to KVM. Cc: Segher Boessenkool <segher@kernel.crashing.org> Cc: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Cc: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'slof')
-rw-r--r--slof/engine.in1
-rw-r--r--slof/fs/pci-properties.fs38
-rw-r--r--slof/fs/pci-scan.fs3
3 files changed, 34 insertions, 8 deletions
diff --git a/slof/engine.in b/slof/engine.in
index 0344a38..549e409 100644
--- a/slof/engine.in
+++ b/slof/engine.in
@@ -145,6 +145,7 @@ col(D2/ >R U2/ R@ LIT(8*CELLSIZE-1) LSHIFT OR R> 2/)
col(NEGATE 0 SWAP -)
col(ABS DUP 0< 0BRANCH(1) NEGATE)
col(MAX 2DUP < 0BRANCH(1) SWAP DROP)
+col(UMAX 2DUP U< 0BRANCH(1) SWAP DROP)
col(MIN 2DUP > 0BRANCH(1) SWAP DROP)
col(U* *)
col(1+ 1 +)
diff --git a/slof/fs/pci-properties.fs b/slof/fs/pci-properties.fs
index 7faa714..e6fd843 100644
--- a/slof/fs/pci-properties.fs
+++ b/slof/fs/pci-properties.fs
@@ -91,17 +91,37 @@
\ ***************************************************************************************
\ align the current mem and set var to next mem
\ align with a size of 0 returns 0 !!!
-: assign-var ( size var -- al-mem )
- 2dup @ \ ( size var size cur-mem ) read current free mem
- swap #aligned \ ( size var al-mem ) align the mem to the size
- dup 2swap -rot + \ ( al-mem var new-mem ) add size to aligned mem
- swap ! \ ( al-mem ) set variable to new mem
+: assign-var-align ( size align var -- al-mem )
+ dup >r @ \ ( size align cur-mem )
+ swap #aligned \ ( size al-mem )
+ tuck + \ ( al-mem new-mem )
+ r> ! \ ( al-mem )
+;
+
+: assign-var-min-align ( size min-align var -- al-mem )
+ >r over umax \ ( size align )
+ r> assign-var-align \ ( al-mem )
;
\ set bar to current free mem ( in variable ) and set variable to next free mem
: assign-bar-value32 ( bar size var -- 4 )
over IF \ IF size > 0
- assign-var \ | ( bar al-mem ) set variable to next mem
+ >r \ | ( bar size )
+ pci-mem-bar-min-align \ | ( bar size min-align )
+ r> assign-var-min-align \ | ( bar al-mem ) set variable to next mem
+ swap rtas-config-l! \ | ( -- ) set the bar to al-mem
+ ELSE \ ELSE
+ 2drop drop \ | clear stack
+ THEN \ FI
+ 4 \ size of the base-address-register
+;
+
+\ set bar to current free mem ( in variable ) and set variable to next free mem
+: assign-io-bar-value32 ( bar size var -- 4 )
+ over IF \ IF size > 0
+ >r \ | ( bar size )
+ dup \ | ( bar size size-align )
+ r> assign-var-align \ | ( bar al-mem ) set variable to next mem
swap rtas-config-l! \ | ( -- ) set the bar to al-mem
ELSE \ ELSE
2drop drop \ | clear stack
@@ -112,7 +132,9 @@
\ set bar to current free mem ( in variable ) and set variable to next free mem
: assign-bar-value64 ( bar size var -- 8 )
over IF \ IF size > 0
- assign-var \ | ( bar al-mem ) set variable to next mem
+ >r \ | ( bar size )
+ pci-mem-bar-min-align \ | ( bar size min-align )
+ r> assign-var-min-align \ | ( bar al-mem ) set variable to next mem
swap \ | ( al-mem addr ) calc config-addr of this bar
2dup rtas-config-l! \ | ( al-mem addr ) set the Lower part of the bar to al-mem
4 + swap 20 rshift \ | ( al-mem>>32 addr ) prepare the upper part of the al-mem
@@ -163,7 +185,7 @@
: assign-io-bar ( bar-addr -- 4 )
dup pci-bar-size-io \ fetch size
pci-next-io \ var to change
- assign-bar-value32 \ and set it all
+ assign-io-bar-value32 \ and set it all
;
\ Setup an Expansion ROM bar
diff --git a/slof/fs/pci-scan.fs b/slof/fs/pci-scan.fs
index a528c8e..bd8cc0d 100644
--- a/slof/fs/pci-scan.fs
+++ b/slof/fs/pci-scan.fs
@@ -24,6 +24,9 @@ VARIABLE pci-max-io
VARIABLE pci-next-mem64 \ prefetchable 64-bit memory mapped
VARIABLE pci-max-mem64
+\ 0 to default to natural alignment
+0 VALUE pci-mem-bar-min-align
+
\ Counter of busses found
0 VALUE pci-bus-number
\ Counter of devices found