From nobody Sat Apr 20 00:40:49 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515640084739346.5716227163616; Wed, 10 Jan 2018 19:08:04 -0800 (PST) Received: from localhost ([::1]:34141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZTDn-0006oK-Tt for importer@patchew.org; Wed, 10 Jan 2018 22:08:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZTB3-0004lf-4G for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZTB2-0002w1-4a for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:13 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZTB1-0002vH-TD for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:12 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0B34JDW040322 for ; Wed, 10 Jan 2018 22:05:11 -0500 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fdxxqsm9p-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 10 Jan 2018 22:05:10 -0500 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Jan 2018 20:05:10 -0700 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 10 Jan 2018 20:05:06 -0700 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0B356k0197104; Wed, 10 Jan 2018 20:05:06 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F302C6037; Wed, 10 Jan 2018 20:05:06 -0700 (MST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 2DBAEC6042; Wed, 10 Jan 2018 20:05:04 -0700 (MST) From: Dong Jia Shi To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-s390x@nongnu.org Date: Thu, 11 Jan 2018 04:04:55 +0100 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180111030459.33757-1-bjsdjshi@linux.vnet.ibm.com> References: <20180111030459.33757-1-bjsdjshi@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011103-0008-0000-0000-000009271F2A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008357; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00973252; UDB=6.00493123; IPR=6.00753202; BA=6.00005772; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018971; XFM=3.00000015; UTC=2018-01-11 03:05:09 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011103-0009-0000-0000-0000457FEF3D Message-Id: <20180111030459.33757-2-bjsdjshi@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-11_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801110036 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [RFC PATCH 1/5] vfio: linux-headers update for vfio-ccw 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: borntraeger@de.ibm.com, bjsdjshi@linux.vnet.ibm.com, cohuck@redhat.com, pmorel@linux.vnet.ibm.com, pasic@linux.vnet.ibm.com 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" This is a placeholder for a linux-headers update. Signed-off-by: Dong Jia Shi --- linux-headers/linux/vfio.h | 2 ++ linux-headers/linux/vfio_ccw.h | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index 4312e961ff..24d85be022 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -457,11 +457,13 @@ enum { =20 enum { VFIO_CCW_CONFIG_REGION_INDEX, + VFIO_CCW_SCHIB_REGION_INDEX, VFIO_CCW_NUM_REGIONS }; =20 enum { VFIO_CCW_IO_IRQ_INDEX, + VFIO_CCW_CHP_IRQ_INDEX, VFIO_CCW_NUM_IRQS }; =20 diff --git a/linux-headers/linux/vfio_ccw.h b/linux-headers/linux/vfio_ccw.h index 5bf96c3812..4944dd946e 100644 --- a/linux-headers/linux/vfio_ccw.h +++ b/linux-headers/linux/vfio_ccw.h @@ -22,4 +22,10 @@ struct ccw_io_region { __u32 ret_code; } __attribute__((packed)); =20 +struct ccw_schib_region { + __u8 cc; +#define SCHIB_AREA_SIZE 52 + __u8 schib_area[SCHIB_AREA_SIZE]; +} __attribute__((packed)); + #endif --=20 2.13.5 From nobody Sat Apr 20 00:40:49 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515640250272927.0934825130615; Wed, 10 Jan 2018 19:10:50 -0800 (PST) Received: from localhost ([::1]:34180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZTGT-0000oa-Dw for importer@patchew.org; Wed, 10 Jan 2018 22:10:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZTB8-0004th-CR for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZTB6-000313-C7 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:18 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54026) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZTB5-0002yc-Hn for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:15 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0B34DiZ061209 for ; Wed, 10 Jan 2018 22:05:13 -0500 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fduc6sqpe-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 10 Jan 2018 22:05:12 -0500 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Jan 2018 20:05:11 -0700 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 10 Jan 2018 20:05:09 -0700 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0B359wN8323578; Wed, 10 Jan 2018 20:05:09 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2666EC604A; Wed, 10 Jan 2018 20:05:09 -0700 (MST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 4E291C6047; Wed, 10 Jan 2018 20:05:07 -0700 (MST) From: Dong Jia Shi To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-s390x@nongnu.org Date: Thu, 11 Jan 2018 04:04:56 +0100 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180111030459.33757-1-bjsdjshi@linux.vnet.ibm.com> References: <20180111030459.33757-1-bjsdjshi@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011103-0028-0000-0000-000008F8C150 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008357; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00973252; UDB=6.00493124; IPR=6.00753202; MB=3.00018971; MTD=3.00000008; XFM=3.00000015; UTC=2018-01-11 03:05:11 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011103-0029-0000-0000-00003915E449 Message-Id: <20180111030459.33757-3-bjsdjshi@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-11_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801110036 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [RFC PATCH 2/5] vfio/ccw: get schib region info 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: borntraeger@de.ibm.com, bjsdjshi@linux.vnet.ibm.com, cohuck@redhat.com, pmorel@linux.vnet.ibm.com, pasic@linux.vnet.ibm.com 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" vfio-ccw provides an MMIO region for store subchannel information. We fetch this information via ioctls here, then we can use it to update schib for virtual subchannels later on. While we are at it, also modify the comment and error message for the config region a bit, to make these unified with the schib likeness. Signed-off-by: Dong Jia Shi --- hw/vfio/ccw.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 16713f2c52..e673695509 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -32,6 +32,10 @@ typedef struct VFIOCCWDevice { uint64_t io_region_offset; struct ccw_io_region *io_region; EventNotifier io_notifier; + + uint64_t schib_region_size; + uint64_t schib_region_offset; + struct ccw_schib_region *schib_region; } VFIOCCWDevice; =20 static void vfio_ccw_compute_needs_reset(VFIODevice *vdev) @@ -268,9 +272,10 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, = Error **errp) return; } =20 + /* Get I/O region info. */ ret =3D vfio_get_region_info(vdev, VFIO_CCW_CONFIG_REGION_INDEX, &info= ); if (ret) { - error_setg_errno(errp, -ret, "vfio: Error getting config info"); + error_setg_errno(errp, -ret, "vfio: Error getting config region in= fo"); return; } =20 @@ -283,13 +288,30 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev,= Error **errp) =20 vcdev->io_region_offset =3D info->offset; vcdev->io_region =3D g_malloc0(info->size); + g_free(info); =20 + /* Get SCHIB region info. */ + ret =3D vfio_get_region_info(vdev, VFIO_CCW_SCHIB_REGION_INDEX, &info); + if (ret) { + error_setg_errno(errp, -ret, "vfio: Error getting schib region inf= o"); + return; + } + + vcdev->schib_region_size =3D info->size; + if (sizeof(*vcdev->schib_region) !=3D vcdev->schib_region_size) { + error_setg(errp, "vfio: Unexpected size of the schib region"); + g_free(info); + return; + } + vcdev->schib_region_offset =3D info->offset; + vcdev->schib_region =3D g_malloc0(info->size); g_free(info); } =20 static void vfio_ccw_put_region(VFIOCCWDevice *vcdev) { g_free(vcdev->io_region); + g_free(vcdev->schib_region); } =20 static void vfio_put_device(VFIOCCWDevice *vcdev) --=20 2.13.5 From nobody Sat Apr 20 00:40:49 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515640185622453.23297356732235; Wed, 10 Jan 2018 19:09:45 -0800 (PST) Received: from localhost ([::1]:34170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZTFQ-0008Ix-OP for importer@patchew.org; Wed, 10 Jan 2018 22:09:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZTBB-0004z3-By for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZTB6-00031E-Cm for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:21 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41764 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZTB6-0002zw-0T for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:16 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0B34ExJ088668 for ; Wed, 10 Jan 2018 22:05:15 -0500 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fdy5ah9rd-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 10 Jan 2018 22:05:15 -0500 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Jan 2018 20:05:14 -0700 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 10 Jan 2018 20:05:12 -0700 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0B35BLH61800488; Wed, 10 Jan 2018 20:05:12 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3336AC6053; Wed, 10 Jan 2018 20:05:12 -0700 (MST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 655A6C603E; Wed, 10 Jan 2018 20:05:10 -0700 (MST) From: Dong Jia Shi To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-s390x@nongnu.org Date: Thu, 11 Jan 2018 04:04:57 +0100 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180111030459.33757-1-bjsdjshi@linux.vnet.ibm.com> References: <20180111030459.33757-1-bjsdjshi@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011103-0020-0000-0000-00000D492D67 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008357; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00973252; UDB=6.00493124; IPR=6.00753202; BA=6.00005772; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018971; XFM=3.00000015; UTC=2018-01-11 03:05:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011103-0021-0000-0000-00005FA397F2 Message-Id: <20180111030459.33757-4-bjsdjshi@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-11_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801110036 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [RFC PATCH 3/5] vfio/ccw: get irq info and set up handler for chp irq 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: borntraeger@de.ibm.com, bjsdjshi@linux.vnet.ibm.com, cohuck@redhat.com, pmorel@linux.vnet.ibm.com, pasic@linux.vnet.ibm.com 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" vfio-ccw now resorts to the eventfd mechanism to communicate with userland for channel path related event. To get notification of the channel path event, userland basically needs to: 1. check the chp irq capability via issuing VFIO_DEVICE_GET_IRQ_INFO ioctl with VFIO_CCW_CHP_IRQ_INDEX. 2. register an event notifier to get an eventfd fd. 3. register the eventfd for chp irq to kernel via VFIO_DEVICE_SET_IRQS ioctl. This work introduces vfio_ccw_chp_notifier_handler(), and refactors vfio_ccw_(un)register_event_notifier() to do the above. Based on this, future work could read channel path information out once got the eventfd signal, and do further process. Signed-off-by: Dong Jia Shi --- hw/vfio/ccw.c | 92 +++++++++++++++++++++++++++++++++++++++++++++----------= ---- 1 file changed, 70 insertions(+), 22 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index e673695509..d812cecfe0 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -36,6 +36,8 @@ typedef struct VFIOCCWDevice { uint64_t schib_region_size; uint64_t schib_region_offset; struct ccw_schib_region *schib_region; + + EventNotifier chp_notifier; } VFIOCCWDevice; =20 static void vfio_ccw_compute_needs_reset(VFIODevice *vdev) @@ -172,33 +174,56 @@ read_err: css_inject_io_interrupt(sch); } =20 -static void vfio_ccw_register_io_notifier(VFIOCCWDevice *vcdev, Error **er= rp) +static void vfio_ccw_chp_notifier_handler(void *opaque) +{ + VFIOCCWDevice *vcdev =3D opaque; + + if (!event_notifier_test_and_clear(&vcdev->chp_notifier)) { + return; + } + + /* TODO: further process on path informaion. */ +} + +static void vfio_ccw_register_event_notifier(VFIOCCWDevice *vcdev, int irq, + Error **errp) { VFIODevice *vdev =3D &vcdev->vdev; struct vfio_irq_info *irq_info; struct vfio_irq_set *irq_set; size_t argsz; int32_t *pfd; - - if (vdev->num_irqs < VFIO_CCW_IO_IRQ_INDEX + 1) { - error_setg(errp, "vfio: unexpected number of io irqs %u", - vdev->num_irqs); + EventNotifier *notifier; + IOHandler *fd_read; + + switch (irq) { + case VFIO_CCW_IO_IRQ_INDEX: + notifier =3D &vcdev->io_notifier; + fd_read =3D vfio_ccw_io_notifier_handler; + break; + case VFIO_CCW_CHP_IRQ_INDEX: + notifier =3D &vcdev->chp_notifier; + fd_read =3D vfio_ccw_chp_notifier_handler; + break; + default: + error_setg(errp, "vfio: Unsupported device irq(%d) fd: %m", irq); return; } =20 argsz =3D sizeof(*irq_info); irq_info =3D g_malloc0(argsz); - irq_info->index =3D VFIO_CCW_IO_IRQ_INDEX; + irq_info->index =3D irq; irq_info->argsz =3D argsz; if (ioctl(vdev->fd, VFIO_DEVICE_GET_IRQ_INFO, irq_info) < 0 || irq_info->count < 1) { - error_setg_errno(errp, errno, "vfio: Error getting irq info"); + error_setg_errno(errp, errno, "vfio: Error getting irq(%d) info", = irq); goto out_free_info; } =20 - if (event_notifier_init(&vcdev->io_notifier, 0)) { + if (event_notifier_init(notifier, 0)) { error_setg_errno(errp, errno, - "vfio: Unable to init event notifier for IO"); + "vfio: Unable to init event notifier for irq(%d)", + irq); goto out_free_info; } =20 @@ -207,17 +232,18 @@ static void vfio_ccw_register_io_notifier(VFIOCCWDevi= ce *vcdev, Error **errp) irq_set->argsz =3D argsz; irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER; - irq_set->index =3D VFIO_CCW_IO_IRQ_INDEX; + irq_set->index =3D irq; irq_set->start =3D 0; irq_set->count =3D 1; pfd =3D (int32_t *) &irq_set->data; =20 - *pfd =3D event_notifier_get_fd(&vcdev->io_notifier); - qemu_set_fd_handler(*pfd, vfio_ccw_io_notifier_handler, NULL, vcdev); + *pfd =3D event_notifier_get_fd(notifier); + qemu_set_fd_handler(*pfd, fd_read, NULL, vcdev); if (ioctl(vdev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) { - error_setg(errp, "vfio: Failed to set up io notification"); + error_setg(errp, "vfio: Failed to set up notification for irq(%d)", + irq); qemu_set_fd_handler(*pfd, NULL, NULL, vcdev); - event_notifier_cleanup(&vcdev->io_notifier); + event_notifier_cleanup(notifier); } =20 g_free(irq_set); @@ -226,30 +252,42 @@ out_free_info: g_free(irq_info); } =20 -static void vfio_ccw_unregister_io_notifier(VFIOCCWDevice *vcdev) +static void vfio_ccw_unregister_event_notifier(VFIOCCWDevice *vcdev, int i= rq) { struct vfio_irq_set *irq_set; size_t argsz; int32_t *pfd; + EventNotifier *notifier; + + switch (irq) { + case VFIO_CCW_IO_IRQ_INDEX: + notifier =3D &vcdev->io_notifier; + break; + case VFIO_CCW_CHP_IRQ_INDEX: + notifier =3D &vcdev->chp_notifier; + break; + default: + error_report("vfio: Unsupported device irq(%d) fd: %m", irq); + return; + } =20 argsz =3D sizeof(*irq_set) + sizeof(*pfd); irq_set =3D g_malloc0(argsz); irq_set->argsz =3D argsz; irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER; - irq_set->index =3D VFIO_CCW_IO_IRQ_INDEX; + irq_set->index =3D irq; irq_set->start =3D 0; irq_set->count =3D 1; pfd =3D (int32_t *) &irq_set->data; *pfd =3D -1; =20 if (ioctl(vcdev->vdev.fd, VFIO_DEVICE_SET_IRQS, irq_set)) { - error_report("vfio: Failed to de-assign device io fd: %m"); + error_report("vfio: Failed to de-assign device irq(%d) fd: %m", ir= q); } =20 - qemu_set_fd_handler(event_notifier_get_fd(&vcdev->io_notifier), - NULL, NULL, vcdev); - event_notifier_cleanup(&vcdev->io_notifier); + qemu_set_fd_handler(event_notifier_get_fd(notifier), NULL, NULL, vcdev= ); + event_notifier_cleanup(notifier); =20 g_free(irq_set); } @@ -272,6 +310,11 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, = Error **errp) return; } =20 + if (vdev->num_irqs < VFIO_CCW_IO_IRQ_INDEX + 1) { + error_setg(errp, "vfio: Unexpected number of irqs %u", vdev->num_i= rqs); + return; + } + /* Get I/O region info. */ ret =3D vfio_get_region_info(vdev, VFIO_CCW_CONFIG_REGION_INDEX, &info= ); if (ret) { @@ -392,7 +435,11 @@ static void vfio_ccw_realize(DeviceState *dev, Error *= *errp) goto out_region_err; } =20 - vfio_ccw_register_io_notifier(vcdev, &err); + vfio_ccw_register_event_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX, &err); + if (err) { + goto out_notifier_err; + } + vfio_ccw_register_event_notifier(vcdev, VFIO_CCW_CHP_IRQ_INDEX, &err); if (err) { goto out_notifier_err; } @@ -421,7 +468,8 @@ static void vfio_ccw_unrealize(DeviceState *dev, Error = **errp) S390CCWDeviceClass *cdc =3D S390_CCW_DEVICE_GET_CLASS(cdev); VFIOGroup *group =3D vcdev->vdev.group; =20 - vfio_ccw_unregister_io_notifier(vcdev); + vfio_ccw_unregister_event_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX); + vfio_ccw_unregister_event_notifier(vcdev, VFIO_CCW_CHP_IRQ_INDEX); vfio_ccw_put_region(vcdev); vfio_put_device(vcdev); vfio_put_group(group); --=20 2.13.5 From nobody Sat Apr 20 00:40:49 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515640313316468.0549944651224; Wed, 10 Jan 2018 19:11:53 -0800 (PST) Received: from localhost ([::1]:34463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZTHU-00022t-Ek for importer@patchew.org; Wed, 10 Jan 2018 22:11:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZTBG-00052F-BM for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZTBC-00038k-MX for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:26 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39810 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZTBC-00038J-Fz for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:22 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0B34NTA023457 for ; Wed, 10 Jan 2018 22:05:20 -0500 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fdx9ubctu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 10 Jan 2018 22:05:20 -0500 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Jan 2018 20:05:19 -0700 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 10 Jan 2018 20:05:15 -0700 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0B35FaX11927832; Wed, 10 Jan 2018 20:05:15 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54252C6037; Wed, 10 Jan 2018 20:05:15 -0700 (MST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 7C14DC6042; Wed, 10 Jan 2018 20:05:13 -0700 (MST) From: Dong Jia Shi To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-s390x@nongnu.org Date: Thu, 11 Jan 2018 04:04:58 +0100 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180111030459.33757-1-bjsdjshi@linux.vnet.ibm.com> References: <20180111030459.33757-1-bjsdjshi@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011103-0012-0000-0000-0000159529E2 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008357; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00973252; UDB=6.00493124; IPR=6.00753202; BA=6.00005772; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018971; XFM=3.00000015; UTC=2018-01-11 03:05:17 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011103-0013-0000-0000-0000510230C3 Message-Id: <20180111030459.33757-5-bjsdjshi@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-11_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801110036 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [RFC PATCH 4/5] vfio/ccw: update subchanel information block lazily 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: borntraeger@de.ibm.com, bjsdjshi@linux.vnet.ibm.com, cohuck@redhat.com, pmorel@linux.vnet.ibm.com, pasic@linux.vnet.ibm.com 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" We want to sync up channel path related information between the physical device and the virtual device. Thus here we read out subchannel information block from the schib region, and update the virtual sbuchannel information block. Since the kernel side will signal userland once it has channel path information update, we only do update if we were signaled. We sets scsw.pno and pmcw.pnom to indicate path related event for a guest. This is a bit lazy, but it works. Signed-off-by: Dong Jia Shi --- hw/s390x/css.c | 14 +++++++++-- hw/s390x/s390-ccw.c | 12 +++++++++ hw/vfio/ccw.c | 59 +++++++++++++++++++++++++++++++++++++++++= +++- include/hw/s390x/css.h | 3 ++- include/hw/s390x/s390-ccw.h | 1 + target/s390x/ioinst.c | 3 +-- 6 files changed, 86 insertions(+), 6 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 1c526fd7e2..c1ec83f08f 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1297,11 +1297,16 @@ static void copy_schib_to_guest(SCHIB *dest, const = SCHIB *src) } } =20 -int css_do_stsch(SubchDev *sch, SCHIB *schib) +IOInstEnding css_do_stsch(SubchDev *sch, SCHIB *schib) { + if (sch->update_schib && + (sch->update_schib(sch) !=3D IOINST_CC_EXPECTED)) { + return IOINST_CC_NOT_OPERATIONAL; + } + /* Use current status. */ copy_schib_to_guest(schib, &sch->curr_status); - return 0; + return IOINST_CC_EXPECTED; } =20 static void copy_pmcw_from_guest(PMCW *dest, const PMCW *src) @@ -1586,6 +1591,11 @@ int css_do_tsch_get_irb(SubchDev *sch, IRB *target_i= rb, int *irb_len) uint16_t stctl; IRB irb; =20 + if (sch->update_schib && + (sch->update_schib(sch) !=3D IOINST_CC_EXPECTED)) { + return IOINST_CC_NOT_OPERATIONAL; + } + if (~(p->flags) & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA)) { return 3; } diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c index 4a9d4d2534..491697137c 100644 --- a/hw/s390x/s390-ccw.c +++ b/hw/s390x/s390-ccw.c @@ -28,6 +28,17 @@ IOInstEnding s390_ccw_cmd_request(SubchDev *sch) return cdc->handle_request(sch); } =20 +static IOInstEnding s390_ccw_update_schib(SubchDev *sch) +{ + S390CCWDeviceClass *cdc =3D S390_CCW_DEVICE_GET_CLASS(sch->driver_data= ); + + if (!cdc->update_schib) { + /* g_assert_not_reached()? */ + return IOINST_CC_NOT_OPERATIONAL; + } + return cdc->update_schib(sch); +} + static void s390_ccw_get_dev_info(S390CCWDevice *cdev, char *sysfsdev, Error **errp) @@ -83,6 +94,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *s= ysfsdev, Error **errp) } sch->driver_data =3D cdev; sch->do_subchannel_work =3D do_subchannel_work_passthrough; + sch->update_schib =3D s390_ccw_update_schib; =20 ccw_dev->sch =3D sch; ret =3D css_sch_build_schib(sch, &cdev->hostid); diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index d812cecfe0..0eca3453af 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -33,6 +33,7 @@ typedef struct VFIOCCWDevice { struct ccw_io_region *io_region; EventNotifier io_notifier; =20 + bool schib_need_update; uint64_t schib_region_size; uint64_t schib_region_offset; struct ccw_schib_region *schib_region; @@ -97,6 +98,57 @@ again: } } =20 +static IOInstEnding vfio_ccw_update_schib(SubchDev *sch) +{ + + S390CCWDevice *cdev =3D sch->driver_data; + VFIOCCWDevice *vcdev =3D DO_UPCAST(VFIOCCWDevice, cdev, cdev); + struct ccw_schib_region *region =3D vcdev->schib_region; + PMCW *p =3D &sch->curr_status.pmcw; + SCSW *s =3D &sch->curr_status.scsw; + SCHIB *schib; + int size; + int i; + + /* + * If there is no update that interested us since last read, + * we do not read then. + */ + if (!vcdev->schib_need_update) { + return IOINST_CC_EXPECTED; + } + vcdev->schib_need_update =3D false; + + /* Read schib region, and update schib for virtual subchannel. */ + size =3D pread(vcdev->vdev.fd, region, vcdev->schib_region_size, + vcdev->schib_region_offset); + if (size !=3D vcdev->schib_region_size) { + return IOINST_CC_NOT_OPERATIONAL; + } + if (region->cc) { + g_assert(region->cc =3D=3D IOINST_CC_NOT_OPERATIONAL); + return region->cc; + } + + schib =3D (SCHIB *)region->schib_area; + + /* Path mask. */ + p->pim =3D schib->pmcw.pim; + p->pam =3D schib->pmcw.pam; + p->pom =3D schib->pmcw.pom; + + /* We use PNO and PNOM to indicate path related events. */ + p->pnom =3D ~schib->pmcw.pam; + s->flags |=3D SCSW_FLAGS_MASK_PNO; + + /* Chp id. */ + for (i =3D 0; i < ARRAY_SIZE(p->chpid); i++) { + p->chpid[i] =3D schib->pmcw.chpid[i]; + } + + return region->cc; +} + static void vfio_ccw_reset(DeviceState *dev) { CcwDevice *ccw_dev =3D DO_UPCAST(CcwDevice, parent_obj, dev); @@ -182,7 +234,9 @@ static void vfio_ccw_chp_notifier_handler(void *opaque) return; } =20 - /* TODO: further process on path informaion. */ + vcdev->schib_need_update =3D true; + + /* TODO: Generate channel path crw? */ } =20 static void vfio_ccw_register_event_notifier(VFIOCCWDevice *vcdev, int irq, @@ -444,6 +498,8 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) goto out_notifier_err; } =20 + vcdev->schib_need_update =3D true; + return; =20 out_notifier_err: @@ -503,6 +559,7 @@ static void vfio_ccw_class_init(ObjectClass *klass, voi= d *data) dc->reset =3D vfio_ccw_reset; =20 cdc->handle_request =3D vfio_ccw_handle_request; + cdc->update_schib =3D vfio_ccw_update_schib; } =20 static const TypeInfo vfio_ccw_info =3D { diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index 35facb47d2..bcb433af4a 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -137,6 +137,7 @@ struct SubchDev { int (*ccw_cb) (SubchDev *, CCW1); void (*disable_cb)(SubchDev *); IOInstEnding (*do_subchannel_work) (SubchDev *); + IOInstEnding (*update_schib) (SubchDev *); SenseId id; void *driver_data; }; @@ -237,7 +238,7 @@ SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint= 8_t ssid, uint16_t schid); bool css_subch_visible(SubchDev *sch); void css_conditional_io_interrupt(SubchDev *sch); -int css_do_stsch(SubchDev *sch, SCHIB *schib); +IOInstEnding css_do_stsch(SubchDev *sch, SCHIB *schib); bool css_schid_final(int m, uint8_t cssid, uint8_t ssid, uint16_t schid); IOInstEnding css_do_msch(SubchDev *sch, const SCHIB *schib); IOInstEnding css_do_xsch(SubchDev *sch); diff --git a/include/hw/s390x/s390-ccw.h b/include/hw/s390x/s390-ccw.h index 7d15a1a5d4..96e6a00e3e 100644 --- a/include/hw/s390x/s390-ccw.h +++ b/include/hw/s390x/s390-ccw.h @@ -34,6 +34,7 @@ typedef struct S390CCWDeviceClass { void (*realize)(S390CCWDevice *dev, char *sysfsdev, Error **errp); void (*unrealize)(S390CCWDevice *dev, Error **errp); IOInstEnding (*handle_request) (SubchDev *sch); + IOInstEnding (*update_schib) (SubchDev *); } S390CCWDeviceClass; =20 #endif diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index 83c164a168..2c841bb66f 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -257,8 +257,7 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, u= int32_t ipb, sch =3D css_find_subch(m, cssid, ssid, schid); if (sch) { if (css_subch_visible(sch)) { - css_do_stsch(sch, &schib); - cc =3D 0; + cc =3D css_do_stsch(sch, &schib); } else { /* Indicate no more subchannels in this css/ss */ cc =3D 3; --=20 2.13.5 From nobody Sat Apr 20 00:40:49 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515640403335239.772095259063; Wed, 10 Jan 2018 19:13:23 -0800 (PST) Received: from localhost ([::1]:34537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZTIj-0002uo-2k for importer@patchew.org; Wed, 10 Jan 2018 22:13:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZTBK-00057O-OV for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZTBE-0003AC-O4 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:30 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40244) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZTBE-00039J-3Q for qemu-devel@nongnu.org; Wed, 10 Jan 2018 22:05:24 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0B34KFu040381 for ; Wed, 10 Jan 2018 22:05:23 -0500 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fdxxqsmhx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 10 Jan 2018 22:05:22 -0500 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Jan 2018 20:05:22 -0700 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 10 Jan 2018 20:05:19 -0700 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0B35Iof65339506; Wed, 10 Jan 2018 20:05:18 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6AB42C6042; Wed, 10 Jan 2018 20:05:18 -0700 (MST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 930CDC603E; Wed, 10 Jan 2018 20:05:16 -0700 (MST) From: Dong Jia Shi To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-s390x@nongnu.org Date: Thu, 11 Jan 2018 04:04:59 +0100 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180111030459.33757-1-bjsdjshi@linux.vnet.ibm.com> References: <20180111030459.33757-1-bjsdjshi@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011103-0008-0000-0000-000009271F37 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008357; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00973252; UDB=6.00493123; IPR=6.00753202; BA=6.00005772; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018971; XFM=3.00000015; UTC=2018-01-11 03:05:21 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011103-0009-0000-0000-0000457FEF6C Message-Id: <20180111030459.33757-6-bjsdjshi@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-11_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801110036 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [RFC PATCH 5/5] vfio/ccw: build schib with real schib information 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: borntraeger@de.ibm.com, bjsdjshi@linux.vnet.ibm.com, cohuck@redhat.com, pmorel@linux.vnet.ibm.com, pasic@linux.vnet.ibm.com 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 current implementation grabs chpids and path masks from sysfs to build the schib and chp for the virtual subchannels. Since now vfio-ccw provides a schib region for store subchannel information. Let's leverage it to get the chipids and the masks, and serve the virtual subchannels. While we are at it, touch one line of the comment around by adding white space to make it aligned. Signed-off-by: Dong Jia Shi --- hw/s390x/css.c | 83 ++++-------------------------------------= ---- hw/s390x/s390-ccw.c | 20 +++++++---- hw/vfio/ccw.c | 28 +++++++++------ include/hw/s390x/s390-ccw.h | 3 +- 4 files changed, 39 insertions(+), 95 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index c1ec83f08f..b9bc489e55 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -2417,72 +2417,6 @@ SubchDev *css_create_sch(CssDevId bus_id, bool squas= h_mcss, Error **errp) return sch; } =20 -static int css_sch_get_chpids(SubchDev *sch, CssDevId *dev_id) -{ - char *fid_path; - FILE *fd; - uint32_t chpid[8]; - int i; - PMCW *p =3D &sch->curr_status.pmcw; - - fid_path =3D g_strdup_printf("/sys/bus/css/devices/%x.%x.%04x/chpids", - dev_id->cssid, dev_id->ssid, dev_id->devid); - fd =3D fopen(fid_path, "r"); - if (fd =3D=3D NULL) { - error_report("%s: open %s failed", __func__, fid_path); - g_free(fid_path); - return -EINVAL; - } - - if (fscanf(fd, "%x %x %x %x %x %x %x %x", - &chpid[0], &chpid[1], &chpid[2], &chpid[3], - &chpid[4], &chpid[5], &chpid[6], &chpid[7]) !=3D 8) { - fclose(fd); - g_free(fid_path); - return -EINVAL; - } - - for (i =3D 0; i < ARRAY_SIZE(p->chpid); i++) { - p->chpid[i] =3D chpid[i]; - } - - fclose(fd); - g_free(fid_path); - - return 0; -} - -static int css_sch_get_path_masks(SubchDev *sch, CssDevId *dev_id) -{ - char *fid_path; - FILE *fd; - uint32_t pim, pam, pom; - PMCW *p =3D &sch->curr_status.pmcw; - - fid_path =3D g_strdup_printf("/sys/bus/css/devices/%x.%x.%04x/pimpampo= m", - dev_id->cssid, dev_id->ssid, dev_id->devid); - fd =3D fopen(fid_path, "r"); - if (fd =3D=3D NULL) { - error_report("%s: open %s failed", __func__, fid_path); - g_free(fid_path); - return -EINVAL; - } - - if (fscanf(fd, "%x %x %x", &pim, &pam, &pom) !=3D 3) { - fclose(fd); - g_free(fid_path); - return -EINVAL; - } - - p->pim =3D pim; - p->pam =3D pam; - p->pom =3D pom; - fclose(fd); - g_free(fid_path); - - return 0; -} - static int css_sch_get_chpid_type(uint8_t chpid, uint32_t *type, CssDevId *dev_id) { @@ -2529,19 +2463,14 @@ int css_sch_build_schib(SubchDev *sch, CssDevId *de= v_id) /* We are dealing with I/O subchannels only. */ p->devno =3D sch->devno; =20 - /* Grab path mask from sysfs. */ - ret =3D css_sch_get_path_masks(sch, dev_id); - if (ret) { - return ret; - } - - /* Grab chpids from sysfs. */ - ret =3D css_sch_get_chpids(sch, dev_id); - if (ret) { - return ret; + /* Read schib from the physical device. */ + /* g_assert(sch->update_schib !=3D NULL) ? */ + if (sch->update_schib && + (sch->update_schib(sch) !=3D IOINST_CC_EXPECTED)) { + return -ENODEV; } =20 - /* Build chpid type. */ + /* Build chpid type. */ for (i =3D 0; i < ARRAY_SIZE(p->chpid); i++) { if (p->chpid[i] && !css->chpids[p->chpid[i]].in_use) { ret =3D css_sch_get_chpid_type(p->chpid[i], &type, dev_id); diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c index 491697137c..f658b87131 100644 --- a/hw/s390x/s390-ccw.c +++ b/hw/s390x/s390-ccw.c @@ -72,7 +72,18 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev, cdev->hostid.valid =3D true; } =20 -static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **= errp) +static void s390_ccw_pre_realize(S390CCWDevice *cdev, char *sysfsdev, + Error **errp) +{ + Error *err =3D NULL; + + s390_ccw_get_dev_info(cdev, sysfsdev, &err); + if (err) { + error_propagate(errp, err); + } +} + +static void s390_ccw_realize(S390CCWDevice *cdev, Error **errp) { CcwDevice *ccw_dev =3D CCW_DEVICE(cdev); CCWDeviceClass *ck =3D CCW_DEVICE_GET_CLASS(ccw_dev); @@ -83,11 +94,6 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *= sysfsdev, Error **errp) int ret; Error *err =3D NULL; =20 - s390_ccw_get_dev_info(cdev, sysfsdev, &err); - if (err) { - goto out_err_propagate; - } - sch =3D css_create_sch(ccw_dev->devno, cbus->squash_mcss, &err); if (!sch) { goto out_mdevid_free; @@ -119,7 +125,6 @@ out_err: g_free(sch); out_mdevid_free: g_free(cdev->mdevid); -out_err_propagate: error_propagate(errp, err); } =20 @@ -143,6 +148,7 @@ static void s390_ccw_class_init(ObjectClass *klass, voi= d *data) S390CCWDeviceClass *cdc =3D S390_CCW_DEVICE_CLASS(klass); =20 dc->bus_type =3D TYPE_VIRTUAL_CSS_BUS; + cdc->pre_realize =3D s390_ccw_pre_realize; cdc->realize =3D s390_ccw_realize; cdc->unrealize =3D s390_ccw_unrealize; } diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 0eca3453af..549ef3f8ed 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -146,6 +146,8 @@ static IOInstEnding vfio_ccw_update_schib(SubchDev *sch) p->chpid[i] =3D schib->pmcw.chpid[i]; } =20 + /* TODO: add chpid? */ + return region->cc; } =20 @@ -454,9 +456,8 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) S390CCWDeviceClass *cdc =3D S390_CCW_DEVICE_GET_CLASS(cdev); Error *err =3D NULL; =20 - /* Call the class init function for subchannel. */ - if (cdc->realize) { - cdc->realize(cdev, vcdev->vdev.sysfsdev, &err); + if (cdc->pre_realize) { + cdc->pre_realize(cdev, vcdev->vdev.sysfsdev, &err); if (err) { goto out_err_propagate; } @@ -464,7 +465,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) =20 group =3D vfio_ccw_get_group(cdev, &err); if (!group) { - goto out_group_err; + goto out_err_propagate; } =20 vcdev->vdev.ops =3D &vfio_ccw_ops; @@ -491,27 +492,34 @@ static void vfio_ccw_realize(DeviceState *dev, Error = **errp) =20 vfio_ccw_register_event_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX, &err); if (err) { - goto out_notifier_err; + goto out_io_notifier_err; } vfio_ccw_register_event_notifier(vcdev, VFIO_CCW_CHP_IRQ_INDEX, &err); if (err) { - goto out_notifier_err; + goto out_chp_notifier_err; } =20 vcdev->schib_need_update =3D true; + /* Call the class init function for subchannel. */ + if (cdc->realize) { + cdc->realize(cdev, &err); + if (err) { + goto out_notifier_err; + } + } =20 return; =20 out_notifier_err: + vfio_ccw_unregister_event_notifier(vcdev, VFIO_CCW_CHP_IRQ_INDEX); +out_chp_notifier_err: + vfio_ccw_unregister_event_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX); +out_io_notifier_err: vfio_ccw_put_region(vcdev); out_region_err: vfio_put_device(vcdev); out_device_err: vfio_put_group(group); -out_group_err: - if (cdc->unrealize) { - cdc->unrealize(cdev, NULL); - } out_err_propagate: error_propagate(errp, err); } diff --git a/include/hw/s390x/s390-ccw.h b/include/hw/s390x/s390-ccw.h index 96e6a00e3e..3bbf31dd00 100644 --- a/include/hw/s390x/s390-ccw.h +++ b/include/hw/s390x/s390-ccw.h @@ -31,7 +31,8 @@ typedef struct S390CCWDevice { =20 typedef struct S390CCWDeviceClass { CCWDeviceClass parent_class; - void (*realize)(S390CCWDevice *dev, char *sysfsdev, Error **errp); + void (*pre_realize)(S390CCWDevice *dev, char *sysfsdev, Error **errp); + void (*realize)(S390CCWDevice *dev, Error **errp); void (*unrealize)(S390CCWDevice *dev, Error **errp); IOInstEnding (*handle_request) (SubchDev *sch); IOInstEnding (*update_schib) (SubchDev *); --=20 2.13.5