From nobody Wed Oct 29 11:37:27 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 1525881253226601.7552491337975; Wed, 9 May 2018 08:54:13 -0700 (PDT) Received: from localhost ([::1]:57215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRPs-0005kX-G1 for importer@patchew.org; Wed, 09 May 2018 11:54:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRLA-0001MH-Dr for qemu-devel@nongnu.org; Wed, 09 May 2018 11:49:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGRL8-0007YY-S4 for qemu-devel@nongnu.org; Wed, 09 May 2018 11:49:16 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40260 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 1fGRL8-0007Wc-M1; Wed, 09 May 2018 11:49:14 -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 2254777067; Wed, 9 May 2018 15:49:14 +0000 (UTC) Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D1F7E2166BAD; Wed, 9 May 2018 15:49:13 +0000 (UTC) From: Cornelia Huck To: Dong Jia Shi , Halil Pasic , Pierre Morel Date: Wed, 9 May 2018 17:49:09 +0200 Message-Id: <20180509154910.23578-2-cohuck@redhat.com> In-Reply-To: <20180509154910.23578-1-cohuck@redhat.com> References: <20180509154910.23578-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.1]); Wed, 09 May 2018 15:49:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 09 May 2018 15:49:14 +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] vfio-ccw: forward halt/clear to device if supported 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 initial version of vfio-ccw did not support forwarding of the halt or clear functions to the device, and we had to emulate them instead. For versions of the vfio-ccw kernel implementation that indeed do support halt/clear (by indicating them in the fctl of the scsw in the io_region), we can simply start making use of it. If the kernel does not support handling halt/clear, fall back to emulation. Signed-off-by: Cornelia Huck --- hw/s390x/css.c | 32 ++++++++++++++++++++++++++++---- hw/vfio/ccw.c | 11 +++++++++-- include/hw/s390x/css.h | 10 +++++++--- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 301bf1772f..b6727d0607 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1180,6 +1180,16 @@ static void sch_handle_start_func_virtual(SubchDev *= sch) =20 } =20 +static IOInstEnding sch_handle_clear_func_passthrough(SubchDev *sch) +{ + return s390_ccw_cmd_request(sch); +} + +static IOInstEnding sch_handle_halt_func_passthrough(SubchDev *sch) +{ + return s390_ccw_cmd_request(sch); +} + static IOInstEnding sch_handle_start_func_passthrough(SubchDev *sch) { =20 @@ -1233,13 +1243,27 @@ IOInstEnding do_subchannel_work_virtual(SubchDev *s= ch) IOInstEnding do_subchannel_work_passthrough(SubchDev *sch) { SCSW *s =3D &sch->curr_status.scsw; + static bool no_halt_clear; =20 + /* if the kernel does not support halt/clear, fall back to emulation */ if (s->ctrl & SCSW_FCTL_CLEAR_FUNC) { - /* TODO: Clear handling */ - sch_handle_clear_func(sch); + if (no_halt_clear) { + sch_handle_clear_func(sch); + } else { + if (sch_handle_clear_func_passthrough(sch) =3D=3D IOINST_OPNOT= SUPP) { + no_halt_clear =3D true; + sch_handle_halt_func(sch); + } + } } else if (s->ctrl & SCSW_FCTL_HALT_FUNC) { - /* TODO: Halt handling */ - sch_handle_halt_func(sch); + if (no_halt_clear) { + sch_handle_halt_func(sch); + } else { + if (sch_handle_halt_func_passthrough(sch) =3D=3D IOINST_OPNOTS= UPP) { + no_halt_clear =3D true; + sch_handle_halt_func(sch); + } + } } else if (s->ctrl & SCSW_FCTL_START_FUNC) { return sch_handle_start_func_passthrough(sch); } diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index e67392c5f9..247901ae41 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -60,6 +60,7 @@ static IOInstEnding vfio_ccw_handle_request(SubchDev *sch) =20 memset(region, 0, sizeof(*region)); =20 + /* orb is only valid for ssch, but does not hurt for other functions */ memcpy(region->orb_area, &sch->orb, sizeof(ORB)); memcpy(region->scsw_area, &sch->curr_status.scsw, sizeof(SCSW)); =20 @@ -70,8 +71,12 @@ again: if (errno =3D=3D EAGAIN) { goto again; } - error_report("vfio-ccw: wirte I/O region failed with errno=3D%d", = errno); - ret =3D -errno; + /* handle not supported operations like halt/clear on older kernel= s */ + if (ret !=3D -EOPNOTSUPP) { + error_report("vfio-ccw: write I/O region failed with errno=3D%= d", + errno); + ret =3D -errno; + } } else { ret =3D region->ret_code; } @@ -83,6 +88,8 @@ again: case -ENODEV: case -EACCES: return IOINST_CC_NOT_OPERATIONAL; + case -EOPNOTSUPP: + return IOINST_OPNOTSUPP; case -EFAULT: default: sch_gen_unit_exception(sch); diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index 35facb47d2..e33f26882b 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -100,9 +100,11 @@ typedef struct CcwDataStream { } CcwDataStream; =20 /* - * IO instructions conclude according to this. Currently we have only - * cc codes. Valid values are 0, 1, 2, 3 and the generic semantic for + * IO instructions conclude according to this. One class of values are + * cc codes: Valid values are 0, 1, 2, 3 and the generic semantic for * IO instructions is described briefly. For more details consult the PoP. + * Additionally, other endings may occur due to internal processing errors + * like lack of support for an operation. */ typedef enum IOInstEnding { /* produced expected result */ @@ -112,7 +114,9 @@ typedef enum IOInstEnding { /* inst. ineffective because busy with previously initiated function */ IOINST_CC_BUSY =3D 2, /* inst. ineffective because not operational */ - IOINST_CC_NOT_OPERATIONAL =3D 3 + IOINST_CC_NOT_OPERATIONAL =3D 3, + /* internal: operation not supported */ + IOINST_OPNOTSUPP =3D 4 } IOInstEnding; =20 typedef struct SubchDev SubchDev; --=20 2.14.3 From nobody Wed Oct 29 11:37:27 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 1525881380583536.3811249623868; Wed, 9 May 2018 08:56:20 -0700 (PDT) Received: from localhost ([::1]:57239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRRz-0000NJ-SQ for importer@patchew.org; Wed, 09 May 2018 11:56:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRLB-0001Pt-EB for qemu-devel@nongnu.org; Wed, 09 May 2018 11:49:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGRLA-0007ag-Bw for qemu-devel@nongnu.org; Wed, 09 May 2018 11:49:17 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39998 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 1fGRLA-0007Zq-5p; Wed, 09 May 2018 11:49:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CD9281A8B72; Wed, 9 May 2018 15:49:15 +0000 (UTC) Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 590D92023456; Wed, 9 May 2018 15:49:15 +0000 (UTC) From: Cornelia Huck To: Dong Jia Shi , Halil Pasic , Pierre Morel Date: Wed, 9 May 2018 17:49:10 +0200 Message-Id: <20180509154910.23578-3-cohuck@redhat.com> In-Reply-To: <20180509154910.23578-1-cohuck@redhat.com> References: <20180509154910.23578-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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:49:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 09 May 2018 15:49:15 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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] s390/css: add some tracing for pass-through handling 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" ...so we can get more easily an idea whether halt/clear is sent to the device or emulated. Signed-off-by: Cornelia Huck --- hw/s390x/css.c | 6 ++++++ hw/s390x/trace-events | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index b6727d0607..b6f3421380 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1182,11 +1182,13 @@ static void sch_handle_start_func_virtual(SubchDev = *sch) =20 static IOInstEnding sch_handle_clear_func_passthrough(SubchDev *sch) { + trace_css_handle_clear_pt(sch->cssid, sch->ssid, sch->schid); return s390_ccw_cmd_request(sch); } =20 static IOInstEnding sch_handle_halt_func_passthrough(SubchDev *sch) { + trace_css_handle_halt_pt(sch->cssid, sch->ssid, sch->schid); return s390_ccw_cmd_request(sch); } =20 @@ -1197,6 +1199,8 @@ static IOInstEnding sch_handle_start_func_passthrough= (SubchDev *sch) SCSW *s =3D &sch->curr_status.scsw; =20 ORB *orb =3D &sch->orb; + + trace_css_handle_start_pt(sch->cssid, sch->ssid, sch->schid); if (!(s->ctrl & SCSW_ACTL_SUSP)) { assert(orb !=3D NULL); p->intparm =3D orb->intparm; @@ -1252,6 +1256,7 @@ IOInstEnding do_subchannel_work_passthrough(SubchDev = *sch) } else { if (sch_handle_clear_func_passthrough(sch) =3D=3D IOINST_OPNOT= SUPP) { no_halt_clear =3D true; + trace_css_no_haltclear_pt(); sch_handle_halt_func(sch); } } @@ -1260,6 +1265,7 @@ IOInstEnding do_subchannel_work_passthrough(SubchDev = *sch) sch_handle_halt_func(sch); } else { if (sch_handle_halt_func_passthrough(sch) =3D=3D IOINST_OPNOTS= UPP) { + trace_css_no_haltclear_pt(); no_halt_clear =3D true; sch_handle_halt_func(sch); } diff --git a/hw/s390x/trace-events b/hw/s390x/trace-events index 0d3622ec6f..d4fd1b9da6 100644 --- a/hw/s390x/trace-events +++ b/hw/s390x/trace-events @@ -9,6 +9,10 @@ css_assign_subch(const char *do_assign, uint8_t cssid, uin= t8_t ssid, uint16_t sc css_io_interrupt(int cssid, int ssid, int schid, uint32_t intparm, uint8_t= isc, const char *conditional) "CSS: I/O interrupt on sch %x.%x.%04x (intpa= rm 0x%08x, isc 0x%x) %s" css_adapter_interrupt(uint8_t isc) "CSS: adapter I/O interrupt (isc 0x%x)" css_do_sic(uint16_t mode, uint8_t isc) "CSS: set interruption mode 0x%x on= isc 0x%x" +css_handle_clear_pt(int cssid, int ssid, int schid) "CSS: handling clear f= unction for pass-through subchannel %x.%x.%04x" +css_handle_halt_pt(int cssid, int ssid, int schid) "CSS: handling halt fun= ction for pass-through subchannel %x.%x.%04x" +css_handle_start_pt(int cssid, int ssid, int schid) "CSS: handling start f= unction for pass-through subchannel %x.%x.%04x" +css_no_haltclear_pt(void) "CSS: no kernel support for halt/clear function = passthrough handling, falling back to emulation" =20 # hw/s390x/virtio-ccw.c virtio_ccw_interpret_ccw(int cssid, int ssid, int schid, int cmd_code) "VI= RTIO-CCW: %x.%x.%04x: interpret command 0x%x" --=20 2.14.3