yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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