virtio: Add debugging of driver features and device type

When a device type is not supported by U-Boot it is silently ignored.
Add some debugging for this.

Also show the driver features to provide a fuller picture of feature
negotiation.

Series-to: concept
Cover-letter:
virtio: Add support for virtio-scsi
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.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-07-01 08:59:22 -06:00
parent 9a6d610a34
commit 33d80a2b25

View File

@@ -227,8 +227,8 @@ static int virtio_uclass_post_probe(struct udevice *udev)
name = virtio_drv_name[uc_priv->device];
if (!name) {
debug("(%s): underlying virtio device driver unavailable\n",
udev->name);
debug("(%s): underlying virtio device driver (type %#x) unavailable\n",
udev->name, uc_priv->device);
return 0;
}
@@ -307,6 +307,7 @@ static int virtio_uclass_child_pre_probe(struct udevice *vdev)
WARN_ON(f >= 64);
driver_features |= (1ULL << f);
}
log_debug("driver_features %016llx\n", driver_features);
/* Some drivers have a separate feature table for virtio v1.0 */
if (uc_priv->feature_table_legacy) {