[SLOF] [PATCH] vio-vscsi: Support multiple channels / buses

Thomas Huth thuth at redhat.com
Thu Jan 10 04:05:48 AEDT 2019


The spapr-vscsi device of QEMU supports multiple channels (a.k.a. buses).
But when QEMU is started with a device on a bus > 0, SLOF fails to detect
the device, so that the boot fails. For example:

 qemu-system-ppc64 -nodefaults  -nographic -serial stdio -device spapr-vscsi \
  -blockdev driver=file,filename=/path/to/cdrom.iso,node-name=d1,read-only=on \
  -device scsi-cd,id=cd1,drive=d1,channel=6,scsi-id=5,lun=1

Thus SLOF should scan the various channels for bootable SCSI devices, too.
Since the common SLOF code for scanning SCSI devices has no meaning of
"channels" or "bus", we simply fake the bus ID to be part of the target
ID, so instead of supporting 64 targets = 64 devices, we now support
8 channel * 64 targets = 512 devices instead.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1663160
Signed-off-by: Thomas Huth <thuth at redhat.com>
---
 board-qemu/slof/vio-vscsi.fs | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/board-qemu/slof/vio-vscsi.fs b/board-qemu/slof/vio-vscsi.fs
index be11b69..9395148 100644
--- a/board-qemu/slof/vio-vscsi.fs
+++ b/board-qemu/slof/vio-vscsi.fs
@@ -481,14 +481,19 @@ TRUE VALUE first-time-init?
 \ SCSI scan at boot and child device support
 \ -----------------------------------------------------------
 
-\ We use SRP luns of the form 8000 | (bus << 8) | (id << 5) | lun
-\ in the top 16 bits of the 64-bit LUN
 : (set-target)
     to current-target
 ;
 
-: dev-generate-srplun ( target lun -- )
-    swap 8 << 8000 or or 30 <<
+\ We use SRP luns of the form 8000 | (target << 8) | (bus << 5) | lun
+\ in the top 16 bits of the 64-bit LUN (i.e. the "Logical unit addressing
+\ method" in SAM5). Since the generic scsi-probe code of SLOF does not
+\ really care about buses, we assume that the upper 3 bits of the "target"
+\ value are the "bus" field.
+: dev-generate-srplun ( bus+target lun -- srplun )
+    swap dup 1 >> e0 and      ( lun bus+target bus )
+    swap 3f and 8 <<          ( lun bus target )
+    8000 or or or 30 <<
 ;
 
 \ We obtain here a unit address on the stack, since our #address-cells
@@ -508,8 +513,9 @@ TRUE VALUE first-time-init?
 ;
 
 \ Report the amount of supported SCSI IDs - QEMU uses "max_target = 63"
+\ and "max_channel = 7", we combine both to 64 * 8 = 512 devices
 : dev-max-target ( -- #max-target )
-    40
+    200
 ;
 
 " scsi-probe-helpers.fs" included
-- 
1.8.3.1



More information about the SLOF mailing list