From: jrossi@linux.ibm.com
To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com,
mjrosato@linux.ibm.com
Cc: farman@linux.ibm.com, jrossi@linux.ibm.com, zycai@linux.ibm.com
Subject: [PATCH v2 6/8] pc-bios/s390-ccw: Add support for virtio-scsi-pci IPL
Date: Tue, 11 Aug 2026 10:46:27 -0400 [thread overview]
Message-ID: <20260811144629.866641-7-jrossi@linux.ibm.com> (raw)
In-Reply-To: <20260811144629.866641-1-jrossi@linux.ibm.com>
From: Jared Rossi <jrossi@linux.ibm.com>
Read virtio-pci configuration and configure virt-queue for scsi devices.
Signed-off-by: Jared Rossi <jrossi@linux.ibm.com>
---
pc-bios/s390-ccw/main.c | 3 ++-
pc-bios/s390-ccw/virtio-pci.c | 30 ++++++++++++++++++++++++++++++
pc-bios/s390-ccw/virtio-scsi.c | 12 +++++++++++-
3 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
index 63692260a4..50f455324e 100644
--- a/pc-bios/s390-ccw/main.c
+++ b/pc-bios/s390-ccw/main.c
@@ -269,6 +269,7 @@ static bool find_boot_device(void)
}
break;
case S390_IPL_TYPE_PCI:
+ vdev->scsi_device_selected = false;
found = find_fid(iplb.pci.fid);
break;
default:
@@ -329,13 +330,13 @@ static void ipl_pci_device(void)
{
VDev *vdev = virtio_get_device();
vdev->is_cdrom = false;
- vdev->scsi_device_selected = false;
if (virtio_pci_setup_device()) {
return;
}
switch (vdev->dev_type) {
+ case VIRTIO_ID_SCSI:
case VIRTIO_ID_BLOCK:
if (virtio_setup() == 0) {
zipl_load(); /* only return on error */
diff --git a/pc-bios/s390-ccw/virtio-pci.c b/pc-bios/s390-ccw/virtio-pci.c
index 231ab6e04d..277c3ea68d 100644
--- a/pc-bios/s390-ccw/virtio-pci.c
+++ b/pc-bios/s390-ccw/virtio-pci.c
@@ -52,6 +52,10 @@ void virtio_pci_id2type(VDev *vdev, uint16_t device_id)
case 0x1001:
vdev->dev_type = VIRTIO_ID_BLOCK;
break;
+ case 0x1048:
+ case 0x1004:
+ vdev->dev_type = VIRTIO_ID_SCSI;
+ break;
default:
vdev->dev_type = 0;
}
@@ -199,6 +203,26 @@ static int virtio_pci_get_blk_config(void)
return rc;
}
+static int virtio_pci_get_scsi_config(void)
+{
+ VirtioScsiConfig *cfg = &virtio_get_device()->config.scsi;
+ int rc = vpci_read_flex(d_cap.off, d_cap.bar, cfg, sizeof(VirtioScsiConfig));
+
+ /* all fields of scsi config must be byte swapped */
+ cfg->num_queues = bswap32(cfg->num_queues);
+ cfg->seg_max = bswap32(cfg->seg_max);
+ cfg->max_sectors = bswap32(cfg->max_sectors);
+ cfg->cmd_per_lun = bswap32(cfg->cmd_per_lun);
+ cfg->event_info_size = bswap32(cfg->event_info_size);
+ cfg->sense_size = bswap32(cfg->sense_size);
+ cfg->cdb_size = bswap32(cfg->cdb_size);
+ cfg->max_channel = bswap16(cfg->max_channel);
+ cfg->max_target = bswap16(cfg->max_target);
+ cfg->max_lun = bswap32(cfg->max_lun);
+
+ return rc;
+}
+
static int virtio_pci_negotiate(void)
{
int i, rc;
@@ -330,6 +354,7 @@ bool virtio_pci_is_supported(VDev *vdev)
if (vdev->vendor_id == PCI_VENDOR_VIRTIO) {
switch (vdev->dev_type) {
case VIRTIO_ID_BLOCK:
+ case VIRTIO_ID_SCSI:
return true;
default:
return false;
@@ -384,6 +409,11 @@ int virtio_pci_setup(VDev *vdev)
vdev->cmd_vr_idx = 0;
virtio_pci_get_blk_config();
break;
+ case VIRTIO_ID_SCSI:
+ vdev->nr_vqs = 3;
+ vdev->cmd_vr_idx = 2;
+ virtio_pci_get_scsi_config();
+ break;
default:
puts("Unsupported virtio device");
return -ENODEV;
diff --git a/pc-bios/s390-ccw/virtio-scsi.c b/pc-bios/s390-ccw/virtio-scsi.c
index 9ea00c6fe6..095d7ac430 100644
--- a/pc-bios/s390-ccw/virtio-scsi.c
+++ b/pc-bios/s390-ccw/virtio-scsi.c
@@ -16,6 +16,7 @@
#include "scsi.h"
#include "virtio-scsi.h"
#include "virtio-ccw.h"
+#include "virtio-pci.h"
#include "s390-time.h"
#include "helper.h"
@@ -479,7 +480,16 @@ static int virtio_scsi_setup(VDev *vdev)
int virtio_scsi_setup_device(VDev *vdev)
{
- virtio_ccw_setup(vdev);
+ switch (vdev->ipl_type) {
+ case S390_IPL_TYPE_CCW:
+ virtio_ccw_setup(vdev);
+ break;
+ case S390_IPL_TYPE_PCI:
+ virtio_pci_setup(vdev);
+ break;
+ default:
+ return 1;
+ }
if (vdev->config.scsi.sense_size != VIRTIO_SCSI_SENSE_SIZE) {
puts("Config: sense size mismatch");
--
2.54.0
next prev parent reply other threads:[~2026-08-11 14:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 14:46 [PATCH v2 0/8] s390x: Add support for virtio-scsi-pci boot device jrossi
2026-08-11 14:46 ` [PATCH v2 1/8] pc-bios/s390-ccw: Check if a PCI function is already enabled before trying to enable it jrossi
2026-08-11 14:46 ` [PATCH v2 2/8] hw/s390x/ipl: Fix incorrect PCI IPL block length constant jrossi
2026-08-11 14:46 ` [PATCH v2 3/8] s390x/ipl: Add PCI and bus fields to iplBlockQemuScsi jrossi
2026-08-11 14:46 ` [PATCH v2 4/8] pc-bios/s390-ccw: Use bus specific IPL_TYPE directly for scsi IPL jrossi
2026-08-11 14:46 ` [PATCH v2 5/8] pc-bios/s390-ccw: Abstract virtio_run() for generic use jrossi
2026-08-11 14:46 ` jrossi [this message]
2026-08-11 14:46 ` [PATCH v2 7/8] s390x: Find scsi-pci boot device and build IPLB jrossi
2026-08-11 14:46 ` [PATCH v2 8/8] tests/qtest: Add s390x PCI SCSI fallback test to cdrom-test.c jrossi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260811144629.866641-7-jrossi@linux.ibm.com \
--to=jrossi@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=farman@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=zycai@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.