From nobody Wed Oct 29 20:26:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525881043303494.7750937945341; Wed, 9 May 2018 08:50:43 -0700 (PDT) Received: from localhost ([::1]:57194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRMV-0002vL-Ev for importer@patchew.org; Wed, 09 May 2018 11:50:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRKQ-0000af-2X for qemu-devel@nongnu.org; Wed, 09 May 2018 11:48:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGRKN-000678-Kk for qemu-devel@nongnu.org; Wed, 09 May 2018 11:48:30 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39972 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fGRKN-000660-Fa; Wed, 09 May 2018 11:48:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83C2C818F6F2; Wed, 9 May 2018 15:48:26 +0000 (UTC) Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E66A2166BAD; Wed, 9 May 2018 15:48:26 +0000 (UTC) From: Cornelia Huck To: Dong Jia Shi , Halil Pasic , Pierre Morel Date: Wed, 9 May 2018 17:48:21 +0200 Message-Id: <20180509154822.23510-2-cohuck@redhat.com> In-Reply-To: <20180509154822.23510-1-cohuck@redhat.com> References: <20180509154822.23510-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 09 May 2018 15:48:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 09 May 2018 15:48:26 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'cohuck@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH RFC 1/2] s390/cio: export hsch to modules 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: linux-s390@vger.kernel.org, kvm@vger.kernel.org, Cornelia Huck , linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, qemu-s390x@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The vfio-ccw code will need this, and it matches treatment of ssch and csch. Signed-off-by: Cornelia Huck Reviewed-by: Pierre Morel --- drivers/s390/cio/ioasm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/s390/cio/ioasm.c b/drivers/s390/cio/ioasm.c index 14d328338ce2..08eb10283b18 100644 --- a/drivers/s390/cio/ioasm.c +++ b/drivers/s390/cio/ioasm.c @@ -233,6 +233,7 @@ int hsch(struct subchannel_id schid) =20 return ccode; } +EXPORT_SYMBOL(hsch); =20 static inline int __xsch(struct subchannel_id schid) { --=20 2.14.3 From nobody Wed Oct 29 20:26:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525881224035581.9514036636422; Wed, 9 May 2018 08:53:44 -0700 (PDT) Received: from localhost ([::1]:57212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRPO-0005NL-OE for importer@patchew.org; Wed, 09 May 2018 11:53:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRKQ-0000b3-KF for qemu-devel@nongnu.org; Wed, 09 May 2018 11:48:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGRKP-0006Aj-6c for qemu-devel@nongnu.org; Wed, 09 May 2018 11:48:30 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48540 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fGRKO-00068w-Uo; Wed, 09 May 2018 11:48:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D1CF4059FE2; Wed, 9 May 2018 15:48:28 +0000 (UTC) Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BAE3D10B2B47; Wed, 9 May 2018 15:48:27 +0000 (UTC) From: Cornelia Huck To: Dong Jia Shi , Halil Pasic , Pierre Morel Date: Wed, 9 May 2018 17:48:22 +0200 Message-Id: <20180509154822.23510-3-cohuck@redhat.com> In-Reply-To: <20180509154822.23510-1-cohuck@redhat.com> References: <20180509154822.23510-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 09 May 2018 15:48:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 09 May 2018 15:48:28 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'cohuck@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH RFC 2/2] vfio-ccw: support for halt/clear subchannel 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: linux-s390@vger.kernel.org, kvm@vger.kernel.org, Cornelia Huck , linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, qemu-s390x@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently, vfio-ccw only relays start subchannel requests to the real hardware, which is enough in many cases but falls short e.g. during error recovery. Fortunately, it is easy to add support for halt and clear subchannel requests to the existing infrastructure. User space can detect support for halt/clear subchannel easily, as we always returned -EOPNOTSUPP before and therefore we do not need any capability to make this support discoverable. Signed-off-by: Cornelia Huck --- drivers/s390/cio/vfio_ccw_drv.c | 10 ++++- drivers/s390/cio/vfio_ccw_fsm.c | 94 ++++++++++++++++++++++++++++++++++++-= ---- 2 files changed, 92 insertions(+), 12 deletions(-) diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_dr= v.c index ea6a2d0b2894..6212d577117f 100644 --- a/drivers/s390/cio/vfio_ccw_drv.c +++ b/drivers/s390/cio/vfio_ccw_drv.c @@ -76,8 +76,14 @@ static void vfio_ccw_sch_io_todo(struct work_struct *wor= k) irb =3D &private->irb; =20 if (scsw_is_solicited(&irb->scsw)) { - cp_update_scsw(&private->cp, &irb->scsw); - cp_free(&private->cp); + /* + * For the start function, we need to update based on the + * channel program. Nothing needs to be done for halt/clear. + */ + if (scsw_fctl(&irb->scsw) & SCSW_FCTL_START_FUNC) { + cp_update_scsw(&private->cp, &irb->scsw); + cp_free(&private->cp); + } } memcpy(private->io_region.irb_area, irb, sizeof(*irb)); =20 diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fs= m.c index 3c800642134e..94cae2984c35 100644 --- a/drivers/s390/cio/vfio_ccw_fsm.c +++ b/drivers/s390/cio/vfio_ccw_fsm.c @@ -3,8 +3,10 @@ * Finite state machine for vfio-ccw device handling * * Copyright IBM Corp. 2017 + * Copyright Red Hat, Inc. 2018 * * Author(s): Dong Jia Shi + * Cornelia Huck */ =20 #include @@ -65,6 +67,70 @@ static int fsm_io_helper(struct vfio_ccw_private *privat= e) return ret; } =20 +static int fsm_halt_helper(struct vfio_ccw_private *private) +{ + struct subchannel *sch; + int ccode; + unsigned long flags; + int ret; + + sch =3D private->sch; + + spin_lock_irqsave(sch->lock, flags); + private->state =3D VFIO_CCW_STATE_BUSY; + + /* Issue "Halt Subchannel" */ + ccode =3D hsch(sch->schid); + + switch (ccode) { + case 0: + /* + * Initialize device status information + */ + sch->schib.scsw.cmd.actl |=3D SCSW_ACTL_HALT_PEND; + ret =3D 0; + break; + case 1: /* Status pending */ + case 2: /* Busy */ + ret =3D -EBUSY; + break; + default: /* Device not operational */ + ret =3D -ENODEV; + } + spin_unlock_irqrestore(sch->lock, flags); + return ret; +} + +static int fsm_clear_helper(struct vfio_ccw_private *private) +{ + struct subchannel *sch; + int ccode; + unsigned long flags; + int ret; + + sch =3D private->sch; + + spin_lock_irqsave(sch->lock, flags); + private->state =3D VFIO_CCW_STATE_BUSY; + + /* Issue "Clear Subchannel" */ + ccode =3D csch(sch->schid); + + switch (ccode) { + case 0: + /* + * Initialize device status information + */ + sch->schib.scsw.cmd.actl |=3D SCSW_ACTL_CLEAR_PEND; + ret =3D 0; + break; + default: /* Device not operational */ + ret =3D -ENODEV; + } + spin_unlock_irqrestore(sch->lock, flags); + return ret; +} + static void fsm_notoper(struct vfio_ccw_private *private, enum vfio_ccw_event event) { @@ -126,7 +192,24 @@ static void fsm_io_request(struct vfio_ccw_private *pr= ivate, =20 memcpy(scsw, io_region->scsw_area, sizeof(*scsw)); =20 - if (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) { + /* + * Start processing with the clear function, then halt, then start. + * We may still be start pending when the caller wants to clean + * up things via halt/clear. + */ + if (scsw->cmd.fctl & SCSW_FCTL_CLEAR_FUNC) { + /* issue clear and wait for interupt */ + io_region->ret_code =3D fsm_clear_helper(private); + if (io_region->ret_code) + goto err_out; + return; + } else if (scsw->cmd.fctl & SCSW_FCTL_HALT_FUNC) { + /* issue halt and wait for interrupt */ + io_region->ret_code =3D fsm_halt_helper(private); + if (io_region->ret_code) + goto err_out; + return; + } else if (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) { orb =3D (union orb *)io_region->orb_area; =20 /* Don't try to build a cp if transport mode is specified. */ @@ -152,16 +235,7 @@ static void fsm_io_request(struct vfio_ccw_private *pr= ivate, goto err_out; } return; - } else if (scsw->cmd.fctl & SCSW_FCTL_HALT_FUNC) { - /* XXX: Handle halt. */ - io_region->ret_code =3D -EOPNOTSUPP; - goto err_out; - } else if (scsw->cmd.fctl & SCSW_FCTL_CLEAR_FUNC) { - /* XXX: Handle clear. */ - io_region->ret_code =3D -EOPNOTSUPP; - goto err_out; } - err_out: private->state =3D VFIO_CCW_STATE_IDLE; } --=20 2.14.3