Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3464870pxb; Mon, 4 Apr 2022 17:50:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU53hdeKKu2opCUg7Y7/qHwSaJTLpXLevvfkElI7lvZqcUpdMO9ujWUrnWpD90U5skI09c X-Received: by 2002:a17:902:f64e:b0:14d:20db:8478 with SMTP id m14-20020a170902f64e00b0014d20db8478mr936874plg.158.1649119833368; Mon, 04 Apr 2022 17:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649119833; cv=none; d=google.com; s=arc-20160816; b=X1PjhC/IcthSL84wCYz7MVQ/Sz4/sHkrfyJwSKLllcgOD1zlMjWdeOfSVD9Kf08HjL sVDRzSOQ/Gokuot/dZuwtOu91+vAmXuuJm/ecDnJWeVhMc9GCnVbF5DvAiszMYO3xFqJ Y6fIjiebLOJgIVGv+yPAtBoecmd7EjpM6GxvglpggN0NF8uZh6nwdRK3HSLksiPJeonG z33+fv5uFCZY6h5JzqRAXRUKrrUoTkDwznmN/BToMg+xe8qoNDsGw11sOwX4ZPiQLRxV LjqkFOuvRPhRaHAjUscAS+qKXS2UZhusLmGrvQtmXFUfKu8814cZXO4xZi1t6TX4PTk2 I1OA== 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=YFgdmtQKsfkRf1HFrsBOvS2obJzAxScf46opca7t9ew=; b=lCR9BwLKWyNO2Dw6rd8cgDp83pFBJVIl84ngg3gR0ig1Isoq+eJSFXdlcpLGSMQVx8 uToJbXcd2RFz9PiCQrfix/PuU94uq6BAvAZSjtbzvxcmqhwsbIOL50w2PGArrgITTrux Y7AMf3RuRCa8gs/ml5CayypAs8K+AIdgqwq2kGndp8WS7z1FDSMZJCUTLRqXwywQON8h 7oiyUQOzh1s3SrgjseXvZG+Nl//5JheWSnp99PQqU4og9BHORJuc1Yi+Rm2yB4UzqQzz gmiUWzTs0ZLQjYXsXzXSv9JwJkilKuVgIbIlYbXCjy3Y2dvVdtjEFsNptNp/CeFf2yhu Sz4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ay5AxOar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j9-20020a17090276c900b001549d3bcb48si10496377plt.582.2022.04.04.17.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 17:50:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ay5AxOar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F029AE4390; Mon, 4 Apr 2022 17:00:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236700AbiDDWxs (ORCPT + 99 others); Mon, 4 Apr 2022 18:53:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232565AbiDDWxc (ORCPT ); Mon, 4 Apr 2022 18:53:32 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98CF74B85B; Mon, 4 Apr 2022 15:11:51 -0700 (PDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 234K7fR4003068; Mon, 4 Apr 2022 22:11:49 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=YFgdmtQKsfkRf1HFrsBOvS2obJzAxScf46opca7t9ew=; b=ay5AxOar50TKZ3NwgwqtcloilEw7Tuh/AtaS6RE3N7oXTP1FiNlHBiaB8+CEanSeNRLj JKB2q1T6fxGgvEeBIPdoGdciiWJk9MCwq/8R0kaGHnQmTVd/x1pyBJCh6EBs4cA5c0CK zE8fKz1xqIP7YRcOorHUL19dnqbkJfDghJsdgzybxO3r1BVWwcug3qPMsyLmA9qdt9v/ 26XfAlO3brBf0k12X65ye5RvnvoNXrFMaEK+XCH+c3OfYp1xTI8O35Os4Mb1KCBAmh3o yR//dZJ/ebU0zsEDURrt29n2AVfrIaHprHpJiKRj0WswNYQUmkjtD6ZGV+tJ2ONZgzYh gA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f84gb8a3y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Apr 2022 22:11:49 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 234MAnRo024911; Mon, 4 Apr 2022 22:11:48 GMT Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f84gb8a3q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Apr 2022 22:11:48 +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 234Lr5eN014676; Mon, 4 Apr 2022 22:11:47 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma04dal.us.ibm.com with ESMTP id 3f6e49q9c4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Apr 2022 22:11:47 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 234MBkge14418204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Apr 2022 22:11:46 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A22E7805C; Mon, 4 Apr 2022 22:11:46 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 16F677805F; Mon, 4 Apr 2022 22:11:45 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.65.234.56]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 4 Apr 2022 22:11:44 +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 v19 01/20] s390/vfio-ap: use new AP bus interface to search for queue devices Date: Mon, 4 Apr 2022 18:10:20 -0400 Message-Id: <20220404221039.1272245-2-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220404221039.1272245-1-akrowiak@linux.ibm.com> References: <20220404221039.1272245-1-akrowiak@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: prtb5gOw6aSzoLml5YfE6CKZphXtWnOT X-Proofpoint-GUID: subbhr4WdoYivYpdBR8MIr4-f835hwgx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-04_09,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 malwarescore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204040123 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 6e08d04b605d..2227919fde13 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 @@ -1306,15 +1299,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