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

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