thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-s390-bios-Refactor-virtio-to-run-channel-programs-vi.patch

Pablo Greco e6a3ae
From 776fe22777dd348073449622797cfd9d12058f38 Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
Date: Mon, 14 Oct 2019 10:06:41 +0100
Pablo Greco e6a3ae
Subject: [PATCH 16/21] s390-bios: Refactor virtio to run channel programs via
Pablo Greco e6a3ae
 cio
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
Message-id: <20191014100645.22862-14-thuth@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 91793
Pablo Greco e6a3ae
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH v2 13/17] s390-bios: Refactor virtio to run channel programs via cio
Pablo Greco e6a3ae
Bugzilla: 1664376
Pablo Greco e6a3ae
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: David Hildenbrand <david@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
From: "Jason J. Herne" <jjherne@linux.ibm.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Now that we have a Channel I/O library let's modify virtio boot code to
Pablo Greco e6a3ae
make use of it for running channel programs.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
Pablo Greco e6a3ae
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
Acked-by: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
Message-Id: <1554388475-18329-13-git-send-email-jjherne@linux.ibm.com>
Pablo Greco e6a3ae
Signed-off-by: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit 9de6cbb152bee3917e58ad00633eddafb40d6678)
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 pc-bios/s390-ccw/virtio.c | 57 ++++++++++++++++++++++-------------------------
Pablo Greco e6a3ae
 1 file changed, 27 insertions(+), 30 deletions(-)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
Pablo Greco e6a3ae
index aa9da72..35278eae 100644
Pablo Greco e6a3ae
--- a/pc-bios/s390-ccw/virtio.c
Pablo Greco e6a3ae
+++ b/pc-bios/s390-ccw/virtio.c
Pablo Greco e6a3ae
@@ -14,6 +14,7 @@
Pablo Greco e6a3ae
 #include "virtio.h"
Pablo Greco e6a3ae
 #include "virtio-scsi.h"
Pablo Greco e6a3ae
 #include "bswap.h"
Pablo Greco e6a3ae
+#include "helper.h"
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
 #define VRING_WAIT_REPLY_TIMEOUT 30
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
@@ -89,33 +90,20 @@ int drain_irqs(SubChannelId schid)
Pablo Greco e6a3ae
     }
Pablo Greco e6a3ae
 }
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
-static int run_ccw(VDev *vdev, int cmd, void *ptr, int len)
Pablo Greco e6a3ae
+static int run_ccw(VDev *vdev, int cmd, void *ptr, int len, bool sli)
Pablo Greco e6a3ae
 {
Pablo Greco e6a3ae
     Ccw1 ccw = {};
Pablo Greco e6a3ae
-    CmdOrb orb = {};
Pablo Greco e6a3ae
-    int r;
Pablo Greco e6a3ae
-
Pablo Greco e6a3ae
-    enable_subchannel(vdev->schid);
Pablo Greco e6a3ae
-
Pablo Greco e6a3ae
-    /* start subchannel command */
Pablo Greco e6a3ae
-    orb.fmt = 1;
Pablo Greco e6a3ae
-    orb.cpa = (u32)(long)&ccw;
Pablo Greco e6a3ae
-    orb.lpm = 0x80;
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
     ccw.cmd_code = cmd;
Pablo Greco e6a3ae
     ccw.cda = (long)ptr;
Pablo Greco e6a3ae
     ccw.count = len;
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
-    r = ssch(vdev->schid, &orb;;
Pablo Greco e6a3ae
-    /*
Pablo Greco e6a3ae
-     * XXX Wait until device is done processing the CCW. For now we can
Pablo Greco e6a3ae
-     *     assume that a simple tsch will have finished the CCW processing,
Pablo Greco e6a3ae
-     *     but the architecture allows for asynchronous operation
Pablo Greco e6a3ae
-     */
Pablo Greco e6a3ae
-    if (!r) {
Pablo Greco e6a3ae
-        r = drain_irqs(vdev->schid);
Pablo Greco e6a3ae
+    if (sli) {
Pablo Greco e6a3ae
+        ccw.flags |= CCW_FLAG_SLI;
Pablo Greco e6a3ae
     }
Pablo Greco e6a3ae
-    return r;
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+    enable_subchannel(vdev->schid);
Pablo Greco e6a3ae
+    return do_cio(vdev->schid, vdev->senseid.cu_type, ptr2u32(&ccw), CCW_FMT1);
Pablo Greco e6a3ae
 }
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
 static void vring_init(VRing *vr, VqInfo *info)
Pablo Greco e6a3ae
@@ -257,7 +245,7 @@ void virtio_setup_ccw(VDev *vdev)
Pablo Greco e6a3ae
     vdev->config.blk.blk_size = 0; /* mark "illegal" - setup started... */
Pablo Greco e6a3ae
     vdev->guessed_disk_nature = VIRTIO_GDN_NONE;
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
-    run_ccw(vdev, CCW_CMD_VDEV_RESET, NULL, 0);
Pablo Greco e6a3ae
+    run_ccw(vdev, CCW_CMD_VDEV_RESET, NULL, 0, false);
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
     switch (vdev->senseid.cu_model) {
Pablo Greco e6a3ae
     case VIRTIO_ID_NET:
Pablo Greco e6a3ae
@@ -278,18 +266,19 @@ void virtio_setup_ccw(VDev *vdev)
Pablo Greco e6a3ae
     default:
Pablo Greco e6a3ae
         panic("Unsupported virtio device\n");
Pablo Greco e6a3ae
     }
Pablo Greco e6a3ae
-    IPL_assert(run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size) == 0,
Pablo Greco e6a3ae
-               "Could not get block device configuration");
Pablo Greco e6a3ae
+    IPL_assert(
Pablo Greco e6a3ae
+        run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size, false) == 0,
Pablo Greco e6a3ae
+       "Could not get block device configuration");
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
     /* Feature negotiation */
Pablo Greco e6a3ae
     for (i = 0; i < ARRAY_SIZE(vdev->guest_features); i++) {
Pablo Greco e6a3ae
         feats.features = 0;
Pablo Greco e6a3ae
         feats.index = i;
Pablo Greco e6a3ae
-        rc = run_ccw(vdev, CCW_CMD_READ_FEAT, &feats, sizeof(feats));
Pablo Greco e6a3ae
+        rc = run_ccw(vdev, CCW_CMD_READ_FEAT, &feats, sizeof(feats), false);
Pablo Greco e6a3ae
         IPL_assert(rc == 0, "Could not get features bits");
Pablo Greco e6a3ae
         vdev->guest_features[i] &= bswap32(feats.features);
Pablo Greco e6a3ae
         feats.features = bswap32(vdev->guest_features[i]);
Pablo Greco e6a3ae
-        rc = run_ccw(vdev, CCW_CMD_WRITE_FEAT, &feats, sizeof(feats));
Pablo Greco e6a3ae
+        rc = run_ccw(vdev, CCW_CMD_WRITE_FEAT, &feats, sizeof(feats), false);
Pablo Greco e6a3ae
         IPL_assert(rc == 0, "Could not set features bits");
Pablo Greco e6a3ae
     }
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
@@ -306,16 +295,17 @@ void virtio_setup_ccw(VDev *vdev)
Pablo Greco e6a3ae
         };
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
         IPL_assert(
Pablo Greco e6a3ae
-            run_ccw(vdev, CCW_CMD_READ_VQ_CONF, &config, sizeof(config)) == 0,
Pablo Greco e6a3ae
+            run_ccw(vdev, CCW_CMD_READ_VQ_CONF, &config, sizeof(config), false) == 0,
Pablo Greco e6a3ae
             "Could not get block device VQ configuration");
Pablo Greco e6a3ae
         info.num = config.num;
Pablo Greco e6a3ae
         vring_init(&vdev->vrings[i], &info;;
Pablo Greco e6a3ae
         vdev->vrings[i].schid = vdev->schid;
Pablo Greco e6a3ae
-        IPL_assert(run_ccw(vdev, CCW_CMD_SET_VQ, &info, sizeof(info)) == 0,
Pablo Greco e6a3ae
-                   "Cannot set VQ info");
Pablo Greco e6a3ae
+        IPL_assert(
Pablo Greco e6a3ae
+            run_ccw(vdev, CCW_CMD_SET_VQ, &info, sizeof(info), false) == 0,
Pablo Greco e6a3ae
+            "Cannot set VQ info");
Pablo Greco e6a3ae
     }
Pablo Greco e6a3ae
     IPL_assert(
Pablo Greco e6a3ae
-        run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status)) == 0,
Pablo Greco e6a3ae
+        run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false) == 0,
Pablo Greco e6a3ae
         "Could not write status to host");
Pablo Greco e6a3ae
 }
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
@@ -323,8 +313,15 @@ bool virtio_is_supported(SubChannelId schid)
Pablo Greco e6a3ae
 {
Pablo Greco e6a3ae
     vdev.schid = schid;
Pablo Greco e6a3ae
     memset(&vdev.senseid, 0, sizeof(vdev.senseid));
Pablo Greco e6a3ae
-    /* run sense id command */
Pablo Greco e6a3ae
-    if (run_ccw(&vdev, CCW_CMD_SENSE_ID, &vdev.senseid, sizeof(vdev.senseid))) {
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+    /*
Pablo Greco e6a3ae
+     * Run sense id command.
Pablo Greco e6a3ae
+     * The size of the senseid data differs between devices (notably,
Pablo Greco e6a3ae
+     * between virtio devices and dasds), so specify the largest possible
Pablo Greco e6a3ae
+     * size and suppress the incorrect length indication for smaller sizes.
Pablo Greco e6a3ae
+     */
Pablo Greco e6a3ae
+    if (run_ccw(&vdev, CCW_CMD_SENSE_ID, &vdev.senseid, sizeof(vdev.senseid),
Pablo Greco e6a3ae
+                true)) {
Pablo Greco e6a3ae
         return false;
Pablo Greco e6a3ae
     }
Pablo Greco e6a3ae
     if (vdev.senseid.cu_type == 0x3832) {
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae