Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp730523pxb; Thu, 21 Oct 2021 08:25:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh9rXbJ+3ivLAa2FWlBPeS0MvY2Go4RiaEhrM7Hm9ZXmAXJCQ1wOFFwkqzox7GXMy5Mhsv X-Received: by 2002:a63:ef58:: with SMTP id c24mr4853321pgk.299.1634829924121; Thu, 21 Oct 2021 08:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634829924; cv=none; d=google.com; s=arc-20160816; b=dLmOeMTYqu+6jBZtiWAMuz3A+EsOT0c41SyaUfoqtqA9lXRaZpfcAN9ce+v+PCmntd ZeUA9+nVnIj0hQ9RyE80mKxyhq8zRZZsafH79KkAwZ3/4yEEJUfB3HyCtX1otZP0pArQ 0NElI9xgSLn83euEEo0MSAA6/EnT7nLFEtN5pG/iVrH7kfkpvhM9gKRw+/i2iolEAP+v oKk0CxMbrKS109Ry0V4nIl16FBnvvLXV2ghhbXrVVr2rouiiykmaqdPKTUiCOXg4hHxd +pH9WPfh6kN2IBxSokMi/vl7MjWSKluO5FO3zYbnr8tfZAgU3SIGYXVFMJBuwW6E4Wz3 ifYQ== 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=UjzL5IT9oscSWd5cGZj5JMb5Z95F8fJs2wvedapJfQc=; b=dl4qdaTzGb5nWzp7YRO6N9cVC7SEd/UeJ0p4Mv/umkPEoCFbF0CQITxPn9XaCoMrS5 tH93rqsS8LpbIhtjqUD8m46rcDxzcfv8+PlRe4YdJBr5kS/yMpf7w953/kR6MJTeDE3j 6mM2IU0ipiVZx4JynKQz3vKYA6N2THQNk9Kw5MorfX+uhFWHH7noSWA2XCCzLNdRSd7a nCTEo6V97eKPdKovdUeLrrN/Zx/LwqHD7tWWqopsLA4vJ+Fe5pfTUxOQc57Ftj4ZMlUB 5iozjwSmIKO4fouzREN6IvwIdR+VFUZ/1ZdhRC7KfWj90SdYrPJYMvritU6wCSq1jHNm 8ebg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=S9OaIy84; 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 n13si10227292plh.370.2021.10.21.08.25.10; Thu, 21 Oct 2021 08:25:24 -0700 (PDT) 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=S9OaIy84; 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 S231933AbhJUP00 (ORCPT + 99 others); Thu, 21 Oct 2021 11:26:26 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57722 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231949AbhJUP0R (ORCPT ); Thu, 21 Oct 2021 11:26:17 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19LEBMdj003711; Thu, 21 Oct 2021 11:23:55 -0400 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=UjzL5IT9oscSWd5cGZj5JMb5Z95F8fJs2wvedapJfQc=; b=S9OaIy84jUU+46+sCF010mOLugYqKO+BCUPBRKv14tlP/ODO85sBw6Ar0mLSD0HrvaJ7 /H4cLvEJMkxfSDDRt1077JUhrk43W+WX3B16Ch0+O1PNEdbbfhtYWh4eaVJdgYusegm1 d1VijbSOQTBmht8a3BpFgvMHVeGwFUDoHs4NPssg6Uc8XhoMaZCLYwt+v8gnwjwR5ibC W84qC5XKanBbjM8MmMf6l7xmatrIMuMLrKHkZklSA4f7I68e8U0KbzhS2nveSuZigHAc P3D10L6hPPg35WDDxbisSVH/P0RNUjSAcZ9ba0h2+kmq07Zx97LapIwIpjsH2XZ7M9eI wQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bu8kkksa5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Oct 2021 11:23:55 -0400 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 19LFJG0E010601; Thu, 21 Oct 2021 11:23:54 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bu8kkks9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Oct 2021 11:23:54 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 19LF47VX011122; Thu, 21 Oct 2021 15:23:53 GMT Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma03wdc.us.ibm.com with ESMTP id 3bt4st18dc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Oct 2021 15:23:53 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19LFNqvj36962664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 15:23:52 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7963DBE05D; Thu, 21 Oct 2021 15:23:52 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DE429BE061; Thu, 21 Oct 2021 15:23:49 +0000 (GMT) Received: from cpe-172-100-181-211.stny.res.rr.com.com (unknown [9.160.98.118]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 21 Oct 2021 15:23:49 +0000 (GMT) From: Tony Krowiak To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: jjherne@linux.ibm.com, 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, Tony Krowiak Subject: [PATCH v17 02/15] s390/vfio-ap: use new AP bus interface to search for queue devices Date: Thu, 21 Oct 2021 11:23:19 -0400 Message-Id: <20211021152332.70455-3-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021152332.70455-1-akrowiak@linux.ibm.com> References: <20211021152332.70455-1-akrowiak@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: pX1oti3Tt5i8CnabncTxV88lUVGY5YMT X-Proofpoint-GUID: pNwyOrjhPlYjK56ym30Pw7V8UIWJZJpm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-21_04,2021-10-21_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 mlxscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110210079 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch refactors the vfio_ap device driver to use the AP bus's ap_get_qdev() function to retrieve the vfio_ap_queue struct containing information about a queue that is bound to the vfio_ap device driver. The bus's ap_get_qdev() function retrieves the queue device from a hashtable keyed by APQN. This is much more efficient than looping over the list of devices attached to the AP bus by several orders of magnitude. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic Reviewed-by: Jason J. Herne --- drivers/s390/crypto/vfio_ap_ops.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 02275d246b39..7a9d1b04ecd4 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -28,13 +28,6 @@ static int vfio_ap_mdev_reset_queues(struct ap_matrix_mdev *matrix_mdev); static struct vfio_ap_queue *vfio_ap_find_queue(int apqn); static const struct vfio_device_ops vfio_ap_matrix_dev_ops; -static int match_apqn(struct device *dev, const void *data) -{ - struct vfio_ap_queue *q = dev_get_drvdata(dev); - - return (q->apqn == *(int *)(data)) ? 1 : 0; -} - /** * vfio_ap_get_queue - retrieve a queue with a specific APQN from a list * @matrix_mdev: the associated mediated matrix @@ -1183,15 +1176,17 @@ static int vfio_ap_mdev_group_notifier(struct notifier_block *nb, static struct vfio_ap_queue *vfio_ap_find_queue(int apqn) { - struct device *dev; + struct ap_queue *queue; 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); - put_device(dev); - } + queue = ap_get_qdev(apqn); + if (!queue) + return NULL; + + if (queue->ap_dev.device.driver == &matrix_dev->vfio_ap_drv->driver) + q = dev_get_drvdata(&queue->ap_dev.device); + + put_device(&queue->ap_dev.device); return q; } -- 2.31.1