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

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