
From: Simon Glass <sjg@chromium.org> It is often possible to use virtio-blk for block devices, but it is less flexible than SCSI. SCSI provides a means to probe for multiple disks through the same interface. It also supports hotplug and other features. This series adds a simple virtio-scsi driver for use with QEMU. The new driver creates a SCSI bus when the virtio buses are scanned. That can be scanned in turn, using 'scsi scan', to find the available virtio disks. For this to work, quite a few minor updates are needed in the SCSI implementation: - Increase the buffer sizes for commands and sense buffer - Fix off-by-one error when scanning for devices - Use REPORT LUN to determine what LUNs are present for a target - Clean up some open-coded constants - Make use of a struct to decode the IDENTIFY response - Clean up of the confusing and error-prone SCSI read/write functions - Add support for using a scsi disk to the build-qemu/efi scripts When a SCSI disk is inaccessible (e.g. the LUN is wrong), this is seldom reported as an error. For example 'part list' does not say 'read error' but 'unsupported partition type'. Probing the block device results in each partition-type driver reading blocks, none of which reports the error. So an attempt is made here to clean this up, so that bad LUNs show an error. Another clean-up is to show partition numbers in hex with 'part list', since the current approach conflicts with the 'part' command. Some additional x86 debugging is added for the jump from SPL to U-Boot proper, since this can be confusing when it fails in QEMU. With all of the above, virtio-scsi can be used on qemu-x86_64 for loading an OS and associated files, including with standard boot. Simon Glass (26): x86: Show jump address in SPL when debugging x86: Add some info on the memory map scripts: Move root-disk processing to helper scripts: Support a root disk connected via virtio-scsi part: Detect errors when reading partition tables part: Show partition numbers in hex scsi: Expand the maximum buffer sizes scsi: Add a constant for the tempbuff size scsi: Fix off-by-one error when scanning scsi: Use hex in block-device names scsi: Use REPORT LUNS to scan the correct number of LUNs scsi: Provide some response flags scsi: Use a struct to decode the inquiry response scsi: Rename block_dev and dev_desc to desc scsi: Create a function to add command and LUN to the ccb scsi: Only add the LUN to the command if needed scsi: Check SCSI spec version for LUN handling scsi: Tidy up error returns for read/write scsi: Use a variable for the number of blocks to process scsi: Reorder the local variables scsi: Use mapmem functions scsi: Move loop counters down next to the loop scsi: Adjust loop counters once in the loop virtio: Bring in the virtio_scsi header virtio: Add support for virtio-scsi virtio: Add debugging of driver features and device type arch/x86/lib/spl.c | 8 +- disk/part.c | 28 ++- disk/part_amiga.c | 2 +- disk/part_dos.c | 15 +- disk/part_efi.c | 20 +- disk/part_iso.c | 18 +- disk/part_mac.c | 16 +- doc/arch/x86/x86.rst | 17 ++ drivers/block/blk-uclass.c | 3 +- drivers/block/ide.c | 3 +- drivers/scsi/scsi.c | 348 +++++++++++++++++++++------------ drivers/virtio/Kconfig | 12 ++ drivers/virtio/Makefile | 1 + drivers/virtio/virtio-uclass.c | 6 +- drivers/virtio/virtio_scsi.c | 249 +++++++++++++++++++++++ drivers/virtio/virtio_scsi.h | 175 +++++++++++++++++ include/blk.h | 1 + include/dt-bindings/virtio.h | 1 + include/part.h | 15 +- include/scsi.h | 24 ++- include/virtio.h | 1 + scripts/build-efi | 9 - scripts/build-qemu | 11 +- scripts/build_helper.py | 19 ++ 24 files changed, 817 insertions(+), 185 deletions(-) create mode 100644 drivers/virtio/virtio_scsi.c create mode 100644 drivers/virtio/virtio_scsi.h -- 2.43.0 base-commit: 08a84c7cc73841f24dcdebe876b1aad7c8058890 branch: qeme