From: Cornelia Huck <cohuck@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
"Jason J. Herne" <jjherne@linux.ibm.com>,
Thomas Huth <thuth@redhat.com>
Subject: [Qemu-devel] [PULL 12/19] s390-bios: Refactor virtio to run channel programs via cio
Date: Thu, 25 Apr 2019 15:21:27 +0200 [thread overview]
Message-ID: <20190425132134.2839-13-cohuck@redhat.com> (raw)
In-Reply-To: <20190425132134.2839-1-cohuck@redhat.com>
From: "Jason J. Herne" <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>
Message-Id: <1554388475-18329-13-git-send-email-jjherne@linux.ibm.com>
Signed-off-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 aa9da7253fb2..35278eaee13d 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.17.2
WARNING: multiple messages have this Message-ID (diff)
From: Cornelia Huck <cohuck@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Jason J. Herne" <jjherne@linux.ibm.com>,
qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
Thomas Huth <thuth@redhat.com>
Subject: [Qemu-devel] [PULL 12/19] s390-bios: Refactor virtio to run channel programs via cio
Date: Thu, 25 Apr 2019 15:21:27 +0200 [thread overview]
Message-ID: <20190425132134.2839-13-cohuck@redhat.com> (raw)
Message-ID: <20190425132127.8rsfYNHYTUom6bxuMoQUtqogspFcn5Hdvsu8i60IODs@z> (raw)
In-Reply-To: <20190425132134.2839-1-cohuck@redhat.com>
From: "Jason J. Herne" <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>
Message-Id: <1554388475-18329-13-git-send-email-jjherne@linux.ibm.com>
Signed-off-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 aa9da7253fb2..35278eaee13d 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.17.2
next prev parent reply other threads:[~2019-04-25 13:22 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-25 13:21 [Qemu-devel] [PULL 00/19] first batch of s390x patches for 4.1 Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 01/19] s390 vfio-ccw: Add bootindex property and IPLB data Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-30 16:54 ` Peter Maydell
2019-04-30 16:54 ` Peter Maydell
2019-04-30 20:30 ` Eduardo Habkost
2019-04-30 20:30 ` Eduardo Habkost
2019-05-02 15:48 ` Cornelia Huck
2019-05-02 15:48 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 02/19] s390-bios: decouple cio setup from virtio Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 03/19] s390-bios: decouple common boot logic " Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 04/19] s390-bios: Clean up cio.h Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 05/19] s390-bios: Decouple channel i/o logic from virtio Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 06/19] s390-bios: Map low core memory Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 07/19] s390-bios: ptr2u32 and u32toptr Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 08/19] s390-bios: Support for running format-0/1 channel programs Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 09/19] s390-bios: cio error handling Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 10/19] s390-bios: Extend find_dev() for non-virtio devices Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 11/19] s390-bios: Factor finding boot device out of virtio code path Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck [this message]
2019-04-25 13:21 ` [Qemu-devel] [PULL 12/19] s390-bios: Refactor virtio to run channel programs via cio Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 13/19] s390-bios: Use control unit type to determine boot method Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 14/19] s390-bios: Add channel command codes/structs needed for dasd-ipl Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 15/19] s390-bios: Support booting from real dasd device Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 16/19] s390-bios: Use control unit type to find bootable devices Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 17/19] pc-bios/s390: Update firmware images Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 18/19] s390x/kvm: Configure page size after memory has actually been initialized Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-25 13:21 ` [Qemu-devel] [PULL 19/19] exec: Introduce qemu_maxrampagesize() and rename qemu_getrampagesize() Cornelia Huck
2019-04-25 13:21 ` Cornelia Huck
2019-04-26 13:29 ` [Qemu-devel] [PULL 00/19] first batch of s390x patches for 4.1 Peter Maydell
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=20190425132134.2839-13-cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=jjherne@linux.ibm.com \
--cc=peter.maydell@linaro.org \
--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.