Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3944784iog; Tue, 21 Jun 2022 08:55:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tdj4Tk5656PHgtHkojSPdzqeTLsgJHnNR/GC+Mg72rSln3Q1jgmHnCV85BZySnmhxSvvqg X-Received: by 2002:a05:6402:2548:b0:42d:dd95:5bfe with SMTP id l8-20020a056402254800b0042ddd955bfemr36307576edb.285.1655826915838; Tue, 21 Jun 2022 08:55:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655826915; cv=none; d=google.com; s=arc-20160816; b=uSx7ZCFFt8LYAzSIjqQ0dpgfF+fWQZxrSNCcoh1M61Wfw6jj1mIU2qm+ou4GOvyGh3 APLjU459NuCQZC6GJiMexZVzuMBdiKBluJWnyK/WBBsyG9XbRxEC0Wx/oBmK+O03ATQ/ d3nGiKH/+PW83zFL0c5kAaEOS6MZajvBgCdff5C3vCQl/5f/1RBsjPfhLamrmWzlKREC Dvrlamo3OYLCl+bmCdWy1VFf573ZKHcATs0L03XPSGt2uP5gT0zbOL0H4jR85bR6EZdz rpOT8xCSbEEj395/89z0V3axlxGHwyGJDY1nrSdhzmEwEW1YEZajUFXKsoCB57AmDWDm vVtg== 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=9ufwWA6D7EtUGlDh2z6x4Ee4U5xAzPPVpeBAnpXH2qY=; b=CD5LslPXpiJsENsakwOkzx6KR6rEGGg/7+Pc5H8ptZTMSs9Ok/0GrOkuQrdkrG3wkf DsZE0MaRS01/k6+n9EH/SQ2qCrj7pxkNY0+WWEiW2BuDgm9fiNNJnjxATixSYRvD3+JV rLatdDAMbmXhIprXc+aZnZMbCrqFpntfbJ3BBTNSscujHMrUsygy6klrPgFBsxODU5uJ 7S8qJ/Y7VsMIMFXTmd5XT0et4kXeWyHhMFonHCRi/y13rgBUU5nRyPx9Nm1aKrkT8zoB ETRVxhNK0fdSVF05oo08z8EXm7h1j+Ve2eCRqkDK3wyHaYyh4wegQRq7tmbcaSUp/JOh BBvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=NE7koLwG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170906854b00b006fe9a0289d5si18383201ejy.885.2022.06.21.08.54.50; Tue, 21 Jun 2022 08:55:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=NE7koLwG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1352812AbiFUPvo (ORCPT + 99 others); Tue, 21 Jun 2022 11:51:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350955AbiFUPvm (ORCPT ); Tue, 21 Jun 2022 11:51:42 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05AA72C67C; Tue, 21 Jun 2022 08:51:42 -0700 (PDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25LFgcM6030333; Tue, 21 Jun 2022 15:51:40 GMT 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=9ufwWA6D7EtUGlDh2z6x4Ee4U5xAzPPVpeBAnpXH2qY=; b=NE7koLwG6L8iX9ScjpVg6DcqO1Bte1I/+hTgeEwQgH8q1X1nq4DlC+q+LRHv926QVyXp 36G4niWnvopo2j0KR92+PFmxtUbtn7VwThhdWV3b4HGr3qHZQe98SekjKlO1l8rxAHeT AZEeRvsPkOaRwDYx24Aqh7KzcL170BAf7QiX9RJTET/WmNDXFM4G+VfFEArepVZu6vX3 ygFvEkTkqdXVgNsQ3YekFRHPRnzJYtF03NKoHVXOALS06vwtuDhAdejW8QMKMCFpYTyK fJ+jOl0yJxJdWfzUbd0+cPPPM0nqfuzcVncsPiBbbqwWeYxVG4ku/kMs41quCcxeHhkq 1w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gugvag81k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Jun 2022 15:51:40 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25LFh4Kq031571; Tue, 21 Jun 2022 15:51:39 GMT Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gugvag817-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Jun 2022 15:51:39 +0000 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25LFZtYU005552; Tue, 21 Jun 2022 15:51:38 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma04dal.us.ibm.com with ESMTP id 3gs6b9t4ww-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Jun 2022 15:51:38 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25LFpbEr21168458 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Jun 2022 15:51:37 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 22068136053; Tue, 21 Jun 2022 15:51:37 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1FC1313604F; Tue, 21 Jun 2022 15:51:36 +0000 (GMT) Received: from li-fed795cc-2ab6-11b2-a85c-f0946e4a8dff.ibm.com.com (unknown [9.160.18.227]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 21 Jun 2022 15:51:36 +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 Subject: [PATCH v20 01/20] s390/vfio-ap: use new AP bus interface to search for queue devices Date: Tue, 21 Jun 2022 11:51:15 -0400 Message-Id: <20220621155134.1932383-2-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220621155134.1932383-1-akrowiak@linux.ibm.com> References: <20220621155134.1932383-1-akrowiak@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: SmXBxGpnp6QFPyGFnCYIATvihZ7oQocm X-Proofpoint-ORIG-GUID: o5NcJIXkW8Il32L6anCX5z7VK7HEPp3v X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-21_08,2022-06-21_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 lowpriorityscore=0 suspectscore=0 phishscore=0 malwarescore=0 impostorscore=0 bulkscore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206210066 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 a7d2a95796d3..634e23ae8912 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -30,13 +30,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 @@ -1286,15 +1279,17 @@ static void vfio_ap_mdev_unset_kvm(struct ap_matrix_mdev *matrix_mdev) 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.35.3