thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-pc-bios-s390-ccw-Split-virtio-scsi-code-from-virtio_.patch

586cba
From 2e38b4ec5c53b2b98539a70105d3046e1c452ab8 Mon Sep 17 00:00:00 2001
586cba
From: Thomas Huth <thuth@redhat.com>
586cba
Date: Fri, 8 Jul 2022 20:49:01 +0200
586cba
Subject: [PATCH 13/17] pc-bios/s390-ccw: Split virtio-scsi code from
586cba
 virtio_blk_setup_device()
586cba
586cba
RH-Author: Thomas Huth <thuth@redhat.com>
586cba
RH-MergeRequest: 106: pc-bios/s390-ccw: Fix boot from disks with 4k sectors that do not have the typical DASD geometry
586cba
RH-Commit: [8/10] f49c5fb77e05c9dc09ed9f037e37f6a461e4bba6 (thuth/qemu-kvm-cs9)
586cba
RH-Bugzilla: 2098077
586cba
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
586cba
RH-Acked-by: David Hildenbrand <david@redhat.com>
586cba
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
586cba
586cba
Bugzilla: http://bugzilla.redhat.com/2098077
586cba
586cba
commit cf30b7c4a9b2c64518be8037c2e6670aacdb00b9
586cba
Author: Thomas Huth <thuth@redhat.com>
586cba
Date:   Mon Jul 4 13:19:00 2022 +0200
586cba
586cba
    pc-bios/s390-ccw: Split virtio-scsi code from virtio_blk_setup_device()
586cba
586cba
    The next patch is going to add more virtio-block specific code to
586cba
    virtio_blk_setup_device(), and if the virtio-scsi code is also in
586cba
    there, this is more cumbersome. And the calling function virtio_setup()
586cba
    in main.c looks at the device type already anyway, so it's more
586cba
    logical to separate the virtio-scsi stuff into a new function in
586cba
    virtio-scsi.c instead.
586cba
586cba
    Message-Id: <20220704111903.62400-10-thuth@redhat.com>
586cba
    Reviewed-by: Eric Farman <farman@linux.ibm.com>
586cba
    Signed-off-by: Thomas Huth <thuth@redhat.com>
586cba
586cba
Signed-off-by: Thomas Huth <thuth@redhat.com>
586cba
---
586cba
 pc-bios/s390-ccw/main.c          | 24 +++++++++++++++++-------
586cba
 pc-bios/s390-ccw/virtio-blkdev.c | 20 ++------------------
586cba
 pc-bios/s390-ccw/virtio-scsi.c   | 19 ++++++++++++++++++-
586cba
 pc-bios/s390-ccw/virtio-scsi.h   |  2 +-
586cba
 4 files changed, 38 insertions(+), 27 deletions(-)
586cba
586cba
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
586cba
index 5d2b7ba94d..13e1d8fdf7 100644
586cba
--- a/pc-bios/s390-ccw/main.c
586cba
+++ b/pc-bios/s390-ccw/main.c
586cba
@@ -14,6 +14,7 @@
586cba
 #include "s390-ccw.h"
586cba
 #include "cio.h"
586cba
 #include "virtio.h"
586cba
+#include "virtio-scsi.h"
586cba
 #include "dasd-ipl.h"
586cba
 
586cba
 char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
586cba
@@ -218,6 +219,7 @@ static int virtio_setup(void)
586cba
 {
586cba
     VDev *vdev = virtio_get_device();
586cba
     QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS;
586cba
+    int ret;
586cba
 
586cba
     memcpy(&qipl, early_qipl, sizeof(QemuIplParameters));
586cba
 
586cba
@@ -225,18 +227,26 @@ static int virtio_setup(void)
586cba
         menu_setup();
586cba
     }
586cba
 
586cba
-    if (virtio_get_device_type() == VIRTIO_ID_NET) {
586cba
+    switch (vdev->senseid.cu_model) {
586cba
+    case VIRTIO_ID_NET:
586cba
         sclp_print("Network boot device detected\n");
586cba
         vdev->netboot_start_addr = qipl.netboot_start_addr;
586cba
-    } else {
586cba
-        int ret = virtio_blk_setup_device(blk_schid);
586cba
-        if (ret) {
586cba
-            return ret;
586cba
-        }
586cba
+        return 0;
586cba
+    case VIRTIO_ID_BLOCK:
586cba
+        ret = virtio_blk_setup_device(blk_schid);
586cba
+        break;
586cba
+    case VIRTIO_ID_SCSI:
586cba
+        ret = virtio_scsi_setup_device(blk_schid);
586cba
+        break;
586cba
+    default:
586cba
+        panic("\n! No IPL device available !\n");
586cba
+    }
586cba
+
586cba
+    if (!ret) {
586cba
         IPL_assert(virtio_ipl_disk_is_valid(), "No valid IPL device detected");
586cba
     }
586cba
 
586cba
-    return 0;
586cba
+    return ret;
586cba
 }
586cba
 
586cba
 static void ipl_boot_device(void)
586cba
diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
586cba
index db1f7f44aa..c175b66a47 100644
586cba
--- a/pc-bios/s390-ccw/virtio-blkdev.c
586cba
+++ b/pc-bios/s390-ccw/virtio-blkdev.c
586cba
@@ -222,27 +222,11 @@ uint64_t virtio_get_blocks(void)
586cba
 int virtio_blk_setup_device(SubChannelId schid)
586cba
 {
586cba
     VDev *vdev = virtio_get_device();
586cba
-    int ret = 0;
586cba
 
586cba
     vdev->schid = schid;
586cba
     virtio_setup_ccw(vdev);
586cba
 
586cba
-    switch (vdev->senseid.cu_model) {
586cba
-    case VIRTIO_ID_BLOCK:
586cba
-        sclp_print("Using virtio-blk.\n");
586cba
-        break;
586cba
-    case VIRTIO_ID_SCSI:
586cba
-        IPL_assert(vdev->config.scsi.sense_size == VIRTIO_SCSI_SENSE_SIZE,
586cba
-            "Config: sense size mismatch");
586cba
-        IPL_assert(vdev->config.scsi.cdb_size == VIRTIO_SCSI_CDB_SIZE,
586cba
-            "Config: CDB size mismatch");
586cba
+    sclp_print("Using virtio-blk.\n");
586cba
 
586cba
-        sclp_print("Using virtio-scsi.\n");
586cba
-        ret = virtio_scsi_setup(vdev);
586cba
-        break;
586cba
-    default:
586cba
-        panic("\n! No IPL device available !\n");
586cba
-    }
586cba
-
586cba
-    return ret;
586cba
+    return 0;
586cba
 }
586cba
diff --git a/pc-bios/s390-ccw/virtio-scsi.c b/pc-bios/s390-ccw/virtio-scsi.c
586cba
index 2c8d0f3097..3b7069270c 100644
586cba
--- a/pc-bios/s390-ccw/virtio-scsi.c
586cba
+++ b/pc-bios/s390-ccw/virtio-scsi.c
586cba
@@ -329,7 +329,7 @@ static void scsi_parse_capacity_report(void *data,
586cba
     }
586cba
 }
586cba
 
586cba
-int virtio_scsi_setup(VDev *vdev)
586cba
+static int virtio_scsi_setup(VDev *vdev)
586cba
 {
586cba
     int retry_test_unit_ready = 3;
586cba
     uint8_t data[256];
586cba
@@ -430,3 +430,20 @@ int virtio_scsi_setup(VDev *vdev)
586cba
 
586cba
     return 0;
586cba
 }
586cba
+
586cba
+int virtio_scsi_setup_device(SubChannelId schid)
586cba
+{
586cba
+    VDev *vdev = virtio_get_device();
586cba
+
586cba
+    vdev->schid = schid;
586cba
+    virtio_setup_ccw(vdev);
586cba
+
586cba
+    IPL_assert(vdev->config.scsi.sense_size == VIRTIO_SCSI_SENSE_SIZE,
586cba
+               "Config: sense size mismatch");
586cba
+    IPL_assert(vdev->config.scsi.cdb_size == VIRTIO_SCSI_CDB_SIZE,
586cba
+               "Config: CDB size mismatch");
586cba
+
586cba
+    sclp_print("Using virtio-scsi.\n");
586cba
+
586cba
+    return virtio_scsi_setup(vdev);
586cba
+}
586cba
diff --git a/pc-bios/s390-ccw/virtio-scsi.h b/pc-bios/s390-ccw/virtio-scsi.h
586cba
index 4b14c2c2f9..e6b6cd4815 100644
586cba
--- a/pc-bios/s390-ccw/virtio-scsi.h
586cba
+++ b/pc-bios/s390-ccw/virtio-scsi.h
586cba
@@ -67,8 +67,8 @@ static inline bool virtio_scsi_response_ok(const VirtioScsiCmdResp *r)
586cba
         return r->response == VIRTIO_SCSI_S_OK && r->status == CDB_STATUS_GOOD;
586cba
 }
586cba
 
586cba
-int virtio_scsi_setup(VDev *vdev);
586cba
 int virtio_scsi_read_many(VDev *vdev,
586cba
                           ulong sector, void *load_addr, int sec_num);
586cba
+int virtio_scsi_setup_device(SubChannelId schid);
586cba
 
586cba
 #endif /* VIRTIO_SCSI_H */
586cba
-- 
586cba
2.31.1
586cba