All of lore.kernel.org
 help / color / mirror / Atom feed
From: jrossi@linux.ibm.com
To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com
Cc: jjherne@linux.ibm.com, farman@linux.ibm.com,
	mjrosato@linux.ibm.com, jrossi@linux.ibm.com,
	zycai@linux.ibm.com
Subject: [PATCH 5/6] s390x: Enable IPL from Virtio PCI SCSI devices
Date: Mon,  4 May 2026 18:16:12 -0400	[thread overview]
Message-ID: <20260504221613.826825-6-jrossi@linux.ibm.com> (raw)
In-Reply-To: <20260504221613.826825-1-jrossi@linux.ibm.com>

From: Jared Rossi <jrossi@linux.ibm.com>

Detect PCI SCSI boot devices and build an IPLB for them.

Signed-off-by: Jared Rossi <jrossi@linux.ibm.com>
---
 hw/s390x/ipl.c      | 36 ++++++++++++++++++++++++++++++++++++
 target/s390x/diag.c |  3 ++-
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 402f5dbd7e..1ed1afe4c4 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -400,6 +400,7 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype)
 }
 
 #define PCI_DEVTYPE_VIRTIO       0x05
+#define PCI_DEVTYPE_SCSI         0x06
 
 static S390PCIBusDevice *s390_get_pci_device(DeviceState *dev_st, int *devtype)
 {
@@ -415,6 +416,26 @@ static S390PCIBusDevice *s390_get_pci_device(DeviceState *dev_st, int *devtype)
             if (pbdev) {
                 tmp_dt = PCI_DEVTYPE_VIRTIO;
             }
+        } else {
+            SCSIDevice *sd = (SCSIDevice *)
+                object_dynamic_cast(OBJECT(dev_st), TYPE_SCSI_DEVICE);
+            if (sd) {
+                SCSIBus *sbus = scsi_bus_from_device(sd);
+                VirtIODevice *vdev = (VirtIODevice *)
+                    object_dynamic_cast(OBJECT(sbus->qbus.parent),
+                                                TYPE_VIRTIO_DEVICE);
+                if (vdev) {
+                    pci_dev = (PCIDevice *)
+                        object_dynamic_cast(OBJECT(qdev_get_parent_bus(DEVICE(vdev))->parent),
+                                            TYPE_PCI_DEVICE);
+                    if (pci_dev) {
+                        pbdev = s390_pci_find_dev_by_pci(s390_get_phb(), pci_dev);
+                        if (pbdev) {
+                            tmp_dt = PCI_DEVTYPE_SCSI;
+                        }
+                    }
+                }
+            }
         }
     }
     if (devtype) {
@@ -523,6 +544,21 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb)
         }
 
         switch (devtype) {
+        case PCI_DEVTYPE_SCSI:
+            sd = SCSI_DEVICE(dev_st);
+            scsi_lp = object_property_get_str(OBJECT(sd), "loadparm", NULL);
+            if (scsi_lp && strlen(scsi_lp) > 0) {
+                lp = scsi_lp;
+            }
+            iplb->len = cpu_to_be32(S390_IPLB_MIN_QEMU_SCSI_LEN);
+            iplb->blk0_len =
+                cpu_to_be32(S390_IPLB_MIN_QEMU_SCSI_LEN - S390_IPLB_HEADER_LEN);
+            iplb->pbt = S390_IPL_TYPE_PCI_SCSI;
+            iplb->pci_scsi.lun = cpu_to_be32(sd->lun);
+            iplb->pci_scsi.target = cpu_to_be16(sd->id);
+            iplb->len = S390_IPLB_MIN_PCI_LEN;
+            iplb->pci.fid = cpu_to_be32(pbdev->fid);
+            break;
         case PCI_DEVTYPE_VIRTIO:
             iplb->len = cpu_to_be32(S390_IPLB_MIN_PCI_LEN);
             iplb->pbt = S390_IPL_TYPE_PCI;
diff --git a/target/s390x/diag.c b/target/s390x/diag.c
index 06bdb2bbc8..319a2c9f4c 100644
--- a/target/s390x/diag.c
+++ b/target/s390x/diag.c
@@ -133,7 +133,8 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)
 
         valid = subcode == DIAG308_PV_SET ? iplb_valid_pv(iplb) : iplb_valid(iplb);
         if (!valid) {
-            if (subcode == DIAG308_SET && iplb->pbt == S390_IPL_TYPE_CCW_SCSI) {
+            if (subcode == DIAG308_SET && (iplb->pbt == S390_IPL_TYPE_CCW_SCSI ||
+                                           iplb->pbt == S390_IPL_TYPE_PCI_SCSI)) {
                 s390_rebuild_iplb(iplb->devno, iplb);
                 s390_ipl_update_diag308(iplb);
                 env->regs[r1 + 1] = DIAG_308_RC_OK;
-- 
2.52.0



  parent reply	other threads:[~2026-05-04 22:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-04 22:16 [PATCH 0/6] s390x: Add support for virtio-scsi-pci boot device jrossi
2026-05-04 22:16 ` [PATCH 1/6] s390x: Rename SCSI IPL type to indicate CCW bus jrossi
2026-05-08 16:53   ` Eric Farman
2026-05-04 22:16 ` [PATCH 2/5] pc-bios/s390-ccw: Add per-queue notification offset for multi-queue virtio configurations jrossi
2026-05-06 18:20   ` Zhuoying Cai
2026-05-07 13:26     ` Jared Rossi
2026-05-08 17:23   ` Eric Farman
2026-05-12 16:21     ` Jared Rossi
2026-05-04 22:16 ` [PATCH 3/6] pc-bios/s390-ccw: Rename Virtio CCW run function for generic use jrossi
2026-05-08 17:26   ` Eric Farman
2026-05-04 22:16 ` [PATCH 4/6] s390x: Introduce PCI SCSI IPLB and boot type jrossi
2026-05-09  1:16   ` Eric Farman
2026-05-12 16:13     ` Jared Rossi
2026-05-04 22:16 ` jrossi [this message]
2026-05-04 22:16 ` [PATCH 6/6] 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=20260504221613.826825-6-jrossi@linux.ibm.com \
    --to=jrossi@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=jjherne@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.