From nobody Mon Nov 10 12:49:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1556199186; cv=none; d=zoho.com; s=zohoarc; b=L43FqcHfYFmETwSOgm0Sl21X0/BScZlSGf/tezpJk/ZTNRuX8RZJw3zoFB/8rdH22k/5PYbjgLyLc36ZUxP15S//XCXQBT+NRnI+UdWuSQQPrhjviXxN9+YSSv7OxXR+YzTUnvlB2nzJq8MXgzw79VZwVdSsaD8jWT7Nx6U5NbE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556199186; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=BlpGZIwlNYMMxw2iujfW+ixCw63bvwWr1aZO3uH7aTQ=; b=JWClDxjr885qHmJ5u4+NJ33uNq2yVKO4SSZQhOTgATbAuor6ACgm7qdVhkFB3kz9SXOljo7qe/Romm0ZgH1LbdFOn4A+zi1a8QLna6DGnFzz0ML3sXG7/PQQBWtEYh7oP+5G1XO6sNmSG25E8jZvhuXj+ScRgDaK+qwHI40yVjc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15561991869021007.6665820963099; Thu, 25 Apr 2019 06:33:06 -0700 (PDT) Received: from localhost ([127.0.0.1]:57242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJeUp-0003zp-U8 for importer@patchew.org; Thu, 25 Apr 2019 09:33:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJeKD-0003V4-Ir for qemu-devel@nongnu.org; Thu, 25 Apr 2019 09:22:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJeKC-0003pr-Cl for qemu-devel@nongnu.org; Thu, 25 Apr 2019 09:22:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41164) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hJeKC-0003pN-4h; Thu, 25 Apr 2019 09:22:04 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64BDC3084039; Thu, 25 Apr 2019 13:22:03 +0000 (UTC) Received: from localhost (dhcp-192-187.str.redhat.com [10.33.192.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C9805D70A; Thu, 25 Apr 2019 13:22:02 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Thu, 25 Apr 2019 15:21:27 +0200 Message-Id: <20190425132134.2839-13-cohuck@redhat.com> In-Reply-To: <20190425132134.2839-1-cohuck@redhat.com> References: <20190425132134.2839-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Apr 2019 13:22:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 12/19] s390-bios: Refactor virtio to run channel programs via cio X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Jason J. Herne" , qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Jason J. Herne" 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 Reviewed-by: Cornelia Huck Acked-by: Thomas Huth Message-Id: <1554388475-18329-13-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth --- 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" =20 #define VRING_WAIT_REPLY_TIMEOUT 30 =20 @@ -89,33 +90,20 @@ int drain_irqs(SubChannelId schid) } } =20 -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 =3D {}; - CmdOrb orb =3D {}; - int r; - - enable_subchannel(vdev->schid); - - /* start subchannel command */ - orb.fmt =3D 1; - orb.cpa =3D (u32)(long)&ccw; - orb.lpm =3D 0x80; =20 ccw.cmd_code =3D cmd; ccw.cda =3D (long)ptr; ccw.count =3D len; =20 - r =3D 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 =3D drain_irqs(vdev->schid); + if (sli) { + ccw.flags |=3D CCW_FLAG_SLI; } - return r; + + enable_subchannel(vdev->schid); + return do_cio(vdev->schid, vdev->senseid.cu_type, ptr2u32(&ccw), CCW_F= MT1); } =20 static void vring_init(VRing *vr, VqInfo *info) @@ -257,7 +245,7 @@ void virtio_setup_ccw(VDev *vdev) vdev->config.blk.blk_size =3D 0; /* mark "illegal" - setup started... = */ vdev->guessed_disk_nature =3D VIRTIO_GDN_NONE; =20 - run_ccw(vdev, CCW_CMD_VDEV_RESET, NULL, 0); + run_ccw(vdev, CCW_CMD_VDEV_RESET, NULL, 0, false); =20 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) = =3D=3D 0, - "Could not get block device configuration"); + IPL_assert( + run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size, false) = =3D=3D 0, + "Could not get block device configuration"); =20 /* Feature negotiation */ for (i =3D 0; i < ARRAY_SIZE(vdev->guest_features); i++) { feats.features =3D 0; feats.index =3D i; - rc =3D run_ccw(vdev, CCW_CMD_READ_FEAT, &feats, sizeof(feats)); + rc =3D run_ccw(vdev, CCW_CMD_READ_FEAT, &feats, sizeof(feats), fal= se); IPL_assert(rc =3D=3D 0, "Could not get features bits"); vdev->guest_features[i] &=3D bswap32(feats.features); feats.features =3D bswap32(vdev->guest_features[i]); - rc =3D run_ccw(vdev, CCW_CMD_WRITE_FEAT, &feats, sizeof(feats)); + rc =3D run_ccw(vdev, CCW_CMD_WRITE_FEAT, &feats, sizeof(feats), fa= lse); IPL_assert(rc =3D=3D 0, "Could not set features bits"); } =20 @@ -306,16 +295,17 @@ void virtio_setup_ccw(VDev *vdev) }; =20 IPL_assert( - run_ccw(vdev, CCW_CMD_READ_VQ_CONF, &config, sizeof(config)) = =3D=3D 0, + run_ccw(vdev, CCW_CMD_READ_VQ_CONF, &config, sizeof(config), f= alse) =3D=3D 0, "Could not get block device VQ configuration"); info.num =3D config.num; vring_init(&vdev->vrings[i], &info); vdev->vrings[i].schid =3D vdev->schid; - IPL_assert(run_ccw(vdev, CCW_CMD_SET_VQ, &info, sizeof(info)) =3D= =3D 0, - "Cannot set VQ info"); + IPL_assert( + run_ccw(vdev, CCW_CMD_SET_VQ, &info, sizeof(info), false) =3D= =3D 0, + "Cannot set VQ info"); } IPL_assert( - run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status)) =3D= =3D 0, + run_ccw(vdev, CCW_CMD_WRITE_STATUS, &status, sizeof(status), false= ) =3D=3D 0, "Could not write status to host"); } =20 @@ -323,8 +313,15 @@ bool virtio_is_supported(SubChannelId schid) { vdev.schid =3D schid; memset(&vdev.senseid, 0, sizeof(vdev.senseid)); - /* run sense id command */ - if (run_ccw(&vdev, CCW_CMD_SENSE_ID, &vdev.senseid, sizeof(vdev.sensei= d))) { + + /* + * 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.sensei= d), + true)) { return false; } if (vdev.senseid.cu_type =3D=3D 0x3832) { --=20 2.17.2