Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5421367pxu; Tue, 22 Dec 2020 17:18:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+O15ioSFpUZVfthbXARisN8t+rUOsAu8h12dDAdgV7dvu+NNTj+yZah+ki8cSC8y8Sz6N X-Received: by 2002:aa7:db14:: with SMTP id t20mr22593525eds.158.1608686319683; Tue, 22 Dec 2020 17:18:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608686319; cv=none; d=google.com; s=arc-20160816; b=nHdR58FSpp8cKpbmJB3I13xUw0QgoLsdXup8lXZUXsLsNsbvU5Oc6d5a0TUEGHdczd vg0ynVnlHCd7lbbrFxt+RAM4lRO9kp+UDntuzcrv4CE5nzPV6jpJQrD0m/h5Jbl0OBFB TO0YiPtw4GPU/n/tkU4IyUJs+fmrZfA19T7LC8Mc0zswRfBq2VKggoSFKLaFTbCb+60b gZwpJho4ES5l7FcM7KGPyyC3Gtj6LWs8DR5hJ6bzIM4dNiRSDwlPjbvZnDgWl20Sqa+d c3OllBrQ4usT3MieJpDje1v/A0jeObjyZP2Fc8EXxULeHsFucDqddZh9DAQJcxfjLPZr 5cyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+ngy8I2TApZCZjtsqtT5PGphsT/pw1hgP6JcW0livEA=; b=r+vSkwfQ929tX2lc4Nj05ZbT4Ye/VaxKtrWtniyRUh3aFtr3xy/NE5ip4Xn1nyA99l ekq1Ny16uFUgVBqir0CAXXlDGgJWpcMb0wxVvKkhb30pdArmqSu3qyNEzO+Pt5RUcAZ6 dyej2zQtTARNm9KkH5Zb/6V3BuE/1kIYCZf7YzJda91RsibRSlUiMyVSE91cbWtZBq1K 1hapxBubT0bmFJf6QCbxkrGhlJMpbv3Aamy4wFfJkmfSSKMQWq8DW7326Ry85rsYWgR4 uATcc6c+jZpwncqbrZcrhlZ3qC3lcFRikBke90KEZoDK3x82P/giQHEuuYCFJJulSy5D J6AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=p+Ui5Qdf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox13si11328125ejb.70.2020.12.22.17.18.17; Tue, 22 Dec 2020 17:18:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=p+Ui5Qdf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726969AbgLWBRE (ORCPT + 99 others); Tue, 22 Dec 2020 20:17:04 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42248 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726934AbgLWBRD (ORCPT ); Tue, 22 Dec 2020 20:17:03 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0BN10YWS058573; Tue, 22 Dec 2020 20:16:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=+ngy8I2TApZCZjtsqtT5PGphsT/pw1hgP6JcW0livEA=; b=p+Ui5QdfWA9X4YPtGcffTEJ/U8iMAcYee8/yZRjAg4ZvxfwT0kfo0CCVOk7xHNeaQ3WU OU+eb1uUJP7MCn8JDsV6sUx+C2ZsdRAIfyY0EqA1FlJj64bRVl5oGrk/uuJTRY8gBkR1 aGvPCtUYcXppAhonigS70SPD9MR4ZQlkdDzecCBbTHBVGalk5SNSyYYAqnZ7YVgbEhPd lFCgKo51WFhjar7gO74Um0sAekIDP3vGoL7VUqKgM/NDmMx2+2lNPovnb/lpTgQ2ka2c C/kgQTICiKCeMPCkebZy/pn7Y0W8VTVELojpnFNR/FY3hZHuxEkc19OfLHOua4AuVMnw Tg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 35kua80yte-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 20:16:17 -0500 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0BN11NTH064574; Tue, 22 Dec 2020 20:16:17 -0500 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0b-001b2d01.pphosted.com with ESMTP id 35kua80yt8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Dec 2020 20:16:17 -0500 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0BN1CN8M023351; Wed, 23 Dec 2020 01:16:16 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma04wdc.us.ibm.com with ESMTP id 35k7wbf5k1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Dec 2020 01:16:16 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0BN1GF3Q22413706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Dec 2020 01:16:15 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 128A2112063; Wed, 23 Dec 2020 01:16:15 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4E31011206B; Wed, 23 Dec 2020 01:16:14 +0000 (GMT) Received: from cpe-66-24-58-13.stny.res.rr.com.com (unknown [9.85.193.150]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 23 Dec 2020 01:16:14 +0000 (GMT) From: Tony Krowiak To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: freude@linux.ibm.com, borntraeger@de.ibm.com, cohuck@redhat.com, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex.williamson@redhat.com, kwankhede@nvidia.com, fiuczy@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, hca@linux.ibm.com, gor@linux.ibm.com, Tony Krowiak Subject: [PATCH v13 02/15] s390/vfio-ap: No need to disable IRQ after queue reset Date: Tue, 22 Dec 2020 20:15:53 -0500 Message-Id: <20201223011606.5265-3-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20201223011606.5265-1-akrowiak@linux.ibm.com> References: <20201223011606.5265-1-akrowiak@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-22_13:2020-12-21,2020-12-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 adultscore=0 impostorscore=0 mlxscore=0 phishscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012230003 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The queues assigned to a matrix mediated device are currently reset when: * The VFIO_DEVICE_RESET ioctl is invoked * The mdev fd is closed by userspace (QEMU) * The mdev is removed from sysfs. Immediately after the reset of a queue, a call is made to disable interrupts for the queue. This is entirely unnecessary because the reset of a queue disables interrupts, so this will be removed. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_drv.c | 1 - drivers/s390/crypto/vfio_ap_ops.c | 40 +++++++++++++++++---------- drivers/s390/crypto/vfio_ap_private.h | 1 - 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c index be2520cc010b..ca18c91afec9 100644 --- a/drivers/s390/crypto/vfio_ap_drv.c +++ b/drivers/s390/crypto/vfio_ap_drv.c @@ -79,7 +79,6 @@ static void vfio_ap_queue_dev_remove(struct ap_device *apdev) apid = AP_QID_CARD(q->apqn); apqi = AP_QID_QUEUE(q->apqn); vfio_ap_mdev_reset_queue(apid, apqi, 1); - vfio_ap_irq_disable(q); kfree(q); mutex_unlock(&matrix_dev->lock); } diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 7339043906cf..052f61391ec7 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -25,6 +25,7 @@ #define VFIO_AP_MDEV_NAME_HWVIRT "VFIO AP Passthrough Device" static int vfio_ap_mdev_reset_queues(struct mdev_device *mdev); +static struct vfio_ap_queue *vfio_ap_find_queue(int apqn); static int match_apqn(struct device *dev, const void *data) { @@ -49,20 +50,15 @@ static struct vfio_ap_queue *vfio_ap_get_queue( int apqn) { struct vfio_ap_queue *q; - struct device *dev; if (!test_bit_inv(AP_QID_CARD(apqn), matrix_mdev->matrix.apm)) return NULL; if (!test_bit_inv(AP_QID_QUEUE(apqn), matrix_mdev->matrix.aqm)) return NULL; - dev = driver_find_device(&matrix_dev->vfio_ap_drv->driver, NULL, - &apqn, match_apqn); - if (!dev) - return NULL; - q = dev_get_drvdata(dev); - q->matrix_mdev = matrix_mdev; - put_device(dev); + q = vfio_ap_find_queue(apqn); + if (q) + q->matrix_mdev = matrix_mdev; return q; } @@ -1126,24 +1122,27 @@ static int vfio_ap_mdev_group_notifier(struct notifier_block *nb, return notify_rc; } -static void vfio_ap_irq_disable_apqn(int apqn) +static struct vfio_ap_queue *vfio_ap_find_queue(int apqn) { struct device *dev; - struct vfio_ap_queue *q; + struct vfio_ap_queue *q = NULL; dev = driver_find_device(&matrix_dev->vfio_ap_drv->driver, NULL, &apqn, match_apqn); if (dev) { q = dev_get_drvdata(dev); - vfio_ap_irq_disable(q); put_device(dev); } + + return q; } int vfio_ap_mdev_reset_queue(unsigned int apid, unsigned int apqi, unsigned int retry) { struct ap_queue_status status; + struct vfio_ap_queue *q; + int ret; int retry2 = 2; int apqn = AP_MKQID(apid, apqi); @@ -1156,18 +1155,32 @@ int vfio_ap_mdev_reset_queue(unsigned int apid, unsigned int apqi, status = ap_tapq(apqn, NULL); } WARN_ON_ONCE(retry2 <= 0); - return 0; + ret = 0; + goto free_aqic_resources; case AP_RESPONSE_RESET_IN_PROGRESS: case AP_RESPONSE_BUSY: msleep(20); break; default: /* things are really broken, give up */ - return -EIO; + ret = -EIO; + goto free_aqic_resources; } } while (retry--); return -EBUSY; + +free_aqic_resources: + /* + * In order to free the aqic resources, the queue must be linked to + * the matrix_mdev to which its APQN is assigned and the KVM pointer + * must be available. + */ + q = vfio_ap_find_queue(apqn); + if (q && q->matrix_mdev && q->matrix_mdev->kvm) + vfio_ap_free_aqic_resources(q); + + return ret; } static int vfio_ap_mdev_reset_queues(struct mdev_device *mdev) @@ -1189,7 +1202,6 @@ static int vfio_ap_mdev_reset_queues(struct mdev_device *mdev) */ if (ret) rc = ret; - vfio_ap_irq_disable_apqn(AP_MKQID(apid, apqi)); } } diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h index f46dde56b464..0db6fb3d56d5 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -100,5 +100,4 @@ struct vfio_ap_queue { #define VFIO_AP_ISC_INVALID 0xff unsigned char saved_isc; }; -struct ap_queue_status vfio_ap_irq_disable(struct vfio_ap_queue *q); #endif /* _VFIO_AP_PRIVATE_H_ */ -- 2.21.1