All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jason J. Herne" <jjherne@linux.ibm.com>
To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com,
	thuth@redhat.com, pasic@linux.ibm.com, alifm@linux.ibm.com,
	borntraeger@de.ibm.com
Subject: [Qemu-devel] [PATCH v6 12/16] s390-bios: Refactor virtio to run channel programs via cio
Date: Thu,  4 Apr 2019 10:34:31 -0400	[thread overview]
Message-ID: <1554388475-18329-13-git-send-email-jjherne@linux.ibm.com> (raw)
In-Reply-To: <1554388475-18329-1-git-send-email-jjherne@linux.ibm.com>

Now that we have a Channel I/O library let's modify virtio boot code to
make use of it for running channel programs.

Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Thomas Huth <thuth@redhat.com>
---
 pc-bios/s390-ccw/virtio.c | 57 ++++++++++++++++++++++-------------------------
 1 file changed, 27 insertions(+), 30 deletions(-)

diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index aa9da72..35278eae 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -14,6 +14,7 @@
 #include "virtio.h"
 #include "virtio-scsi.h"
 #include "bswap.h"
+#include "helper.h"
 
 #define VRING_WAIT_REPLY_TIMEOUT 30
 
@@ -89,33 +90,20 @@ int drain_irqs(SubChannelId schid)
     }
 }
 
-static int run_ccw(VDev *vdev, int cmd, void *ptr, int len)
+static int run_ccw(VDev *vdev, int cmd, void *ptr, int len, bool sli)
 {
     Ccw1 ccw = {};
-    CmdOrb orb = {};
-    int r;
-
-    enable_subchannel(vdev->schid);
-
-    /* start subchannel command */
-    orb.fmt = 1;
-    orb.cpa = (u32)(long)&ccw;
-    orb.lpm = 0x80;
 
     ccw.cmd_code = cmd;
     ccw.cda = (long)ptr;
     ccw.count = len;
 
-    r = ssch(vdev->schid, &orb);
-    /*
-     * XXX Wait until device is done processing the CCW. For now we can
-     *     assume that a simple tsch will have finished the CCW processing,
-     *     but the architecture allows for asynchronous operation
-     */
-    if (!r) {
-        r = drain_irqs(vdev->schid);
+    if (sli) {
+        ccw.flags |= CCW_FLAG_SLI;
     }
-    return r;
+
+    enable_subchannel(vdev->schid);
+    return do_cio(vdev->schid, vdev->senseid.cu_type, ptr2u32(&ccw), CCW_FMT1);
 }
 
 static void vring_init(VRing *vr, VqInfo *info)
@@ -257,7 +245,7 @@ void virtio_setup_ccw(VDev *vdev)
     vdev->config.blk.blk_size = 0; /* mark "illegal" - setup started... */
     vdev->guessed_disk_nature = VIRTIO_GDN_NONE;
 
-    run_ccw(vdev, CCW_CMD_VDEV_RESET, NULL, 0);
+    run_ccw(vdev, CCW_CMD_VDEV_RESET, NULL, 0, false);
 
     switch (vdev->senseid.cu_model) {
     case VIRTIO_ID_NET:
@@ -278,18 +266,19 @@ void virtio_setup_ccw(VDev *vdev)
     default:
         panic("Unsupported virtio device\n");
     }
-    IPL_assert(run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size) == 0,
-               "Could not get block device configuration");
+    IPL_assert(
+        run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size, false) == 0,
+       "Could not get block device configuration");
 
     /* Feature negotiation */
     for (i = 0; i < ARRAY_SIZE(vdev->guest_features); i++) {
         feats.features = 0;
         feats.index = i;
-        rc = run_ccw(vdev, CCW_CMD_READ_FEAT, &feats, sizeof(feats));
+        rc = run_ccw(vdev, CCW_CMD_READ_FEAT, &feats, sizeof(feats), false);
         IPL_assert(rc == 0, "Could not get features bits");
         vdev->guest_features[i] &= bswap32(feats.features);
         feats.features = bswap32(vdev->guest_features[i]);
-        rc = run_ccw(vdev, CCW_CMD_WRITE_FEAT, &feats, sizeof(feats));
+        rc = run_ccw(vdev, CCW_CMD_WRITE_FEAT, &feats, sizeof(feats), false);
         IPL_assert(rc == 0, "Could not set features bits");
     }
 
@@ -306,16 +295,17 @@ void virtio_setup_ccw(VDev *vdev)
         };
 
         IPL_assert(
-            run_ccw(vdev, CCW_CMD_READ_VQ_CONF, &config, sizeof(config)) == 0,
+            run_ccw(vdev, CCW_CMD_READ_VQ_CONF, &config, sizeof(config), false) == 0,
             "Could not get block device VQ configuration");
         info.num = config.num;
         vring_init(&vdev->vrings[i], &info);
         vdev->vrings[i].schid = vdev->schid;
-        IPL_assert(run_ccw(vdev, CCW_CMD_SET_VQ, &info, sizeof(info)) == 0,
-                   "Cannot set VQ info");
+        IPL_assert(
+            run_ccw(vdev, CCW_CMD_SET_VQ, &info, sizeof(info), false) == 0,
+            "Cannot set VQ info");
     }
     IPL_assert(
-        run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status)) == 0,
+        run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false) == 0,
         "Could not write status to host");
 }
 
@@ -323,8 +313,15 @@ bool virtio_is_supported(SubChannelId schid)
 {
     vdev.schid = schid;
     memset(&vdev.senseid, 0, sizeof(vdev.senseid));
-    /* run sense id command */
-    if (run_ccw(&vdev, CCW_CMD_SENSE_ID, &vdev.senseid, sizeof(vdev.senseid))) {
+
+    /*
+     * Run sense id command.
+     * The size of the senseid data differs between devices (notably,
+     * between virtio devices and dasds), so specify the largest possible
+     * size and suppress the incorrect length indication for smaller sizes.
+     */
+    if (run_ccw(&vdev, CCW_CMD_SENSE_ID, &vdev.senseid, sizeof(vdev.senseid),
+                true)) {
         return false;
     }
     if (vdev.senseid.cu_type == 0x3832) {
-- 
2.7.4

  parent reply	other threads:[~2019-04-04 14:35 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04 14:34 [Qemu-devel] [PATCH v6 00/16] s390: vfio-ccw dasd ipl support Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 01/16] s390 vfio-ccw: Add bootindex property and IPLB data Jason J. Herne
2019-04-12 10:38   ` Thomas Huth
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 02/16] s390-bios: decouple cio setup from virtio Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 03/16] s390-bios: decouple common boot logic " Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 04/16] s390-bios: Clean up cio.h Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 05/16] s390-bios: Decouple channel i/o logic from virtio Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 06/16] s390-bios: Map low core memory Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 07/16] s390-bios: ptr2u32 and u32toptr Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 08/16] s390-bios: Support for running format-0/1 channel programs Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 09/16] s390-bios: cio error handling Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 10/16] s390-bios: Extend find_dev() for non-virtio devices Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 11/16] s390-bios: Factor finding boot device out of virtio code path Jason J. Herne
2019-04-04 14:34 ` Jason J. Herne [this message]
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 13/16] s390-bios: Use control unit type to determine boot method Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 14/16] s390-bios: Add channel command codes/structs needed for dasd-ipl Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 15/16] s390-bios: Support booting from real dasd device Jason J. Herne
2019-04-04 14:34 ` [Qemu-devel] [PATCH v6 16/16] s390-bios: Use control unit type to find bootable devices Jason J. Herne
2019-04-05  5:55   ` Thomas Huth
2019-04-04 15:14 ` [Qemu-devel] [PATCH v6 00/16] s390: vfio-ccw dasd ipl support no-reply
2019-04-04 15:20 ` no-reply
2019-04-05  6:58 ` Thomas Huth
2019-04-05  7:52   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-04-05 13:11     ` Jason J. Herne
2019-04-05 13:26       ` Thomas Huth
2019-04-05 13:36         ` Cornelia Huck
2019-04-05 13:36           ` Cornelia Huck
2019-04-05 13:43         ` Jason J. Herne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1554388475-18329-13-git-send-email-jjherne@linux.ibm.com \
    --to=jjherne@linux.ibm.com \
    --cc=alifm@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.