Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp172428pxu; Thu, 22 Oct 2020 19:28:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+/867uvpXwKM4HfNN7OvRIRnVppg4tTSpXUeY3Sdxx5m+BYMEpzMxd3DY+9yCsMIrLcLu X-Received: by 2002:a05:6402:1d82:: with SMTP id dk2mr165281edb.299.1603420123709; Thu, 22 Oct 2020 19:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603420123; cv=none; d=google.com; s=arc-20160816; b=MW9dlBg44NDTEw70E+e4qLbPd/6Aq2KGP3vZb1w5KaVgdreCHkeamUM9RfFSeXW2iw rwH6ySXyg6cS/VEKkHnxOBa9qAdxsgRlbk5ZT/0x8KcJOLn8pHDLMYxQmWUn7Ud7GLdQ XHyNLdeN2PYPqAxKnKRDG7KJ8QzAksTYVBQZf/d89NTDW7Js8kj8uV52vOAsprzBJzUC Ic/JBNCl8B+JScJpUZ76kPch8CKm+ApvxreSq/UCfBaD5rxETZo2u9TEjO8rAWd/8Dk6 gN1W5guzAlvHcjlKZci3c/YA6sJGJMLPMjExPP3oyMl47DSnRqa4Q29caWSDHaSWbDBY i75A== 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=p+4VwF18wVgZ9LefIkeRRTJLWxgu0aKc0xXTLqp2BEM=; b=G4sdlpgU3DEkM7HuYUfUIeWWhPpJcA4mbyJuaWQNOJSBWwpL8i/5zsgljw01Dq2vjA hy1SOUBD8Qwos7pCTAHmwudmRa/fRnPMpi/PgWdhUkgNn5eP1DwisIhfBjp1DBjVoogG SwoXWh/OUukkATGkpCJa29a/7E75VVLuqg7IR6V/BDLVIz2VpYKXqfFoYXdF7w44YDu7 svnvU4QOSSaPqeULGa5jZ8657PDzpg9K0CX/VUsEsUsDXQ0ngsJI45Xb9/p7Duvnt7qI Hmm4abbdyxfTY0INmycGIERGg5LANUM+0BZGE5dxD73jOwqO7pOGh6ttYbVSch32fAf3 vzeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=WfSC+7CE; 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 u17si1987812edd.286.2020.10.22.19.27.59; Thu, 22 Oct 2020 19:28:43 -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=WfSC+7CE; 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 S2902338AbgJVRMb (ORCPT + 99 others); Thu, 22 Oct 2020 13:12:31 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:28978 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2506063AbgJVRMa (ORCPT ); Thu, 22 Oct 2020 13:12:30 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09MH2LfH145306; Thu, 22 Oct 2020 13:12:27 -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=p+4VwF18wVgZ9LefIkeRRTJLWxgu0aKc0xXTLqp2BEM=; b=WfSC+7CEEYXqR/asZeB46ihJWGJNwopUe4ZZFkFrpcloueHqJbcl23TjIR+ddSazHufG Z/ilGDNfyyZB5Vn1G8lykPqeMX2YKKnaQrErozNYUmcawGtesGviTMrz7I7DBVyUll8w Y9eo3A35ct485IlSkLHypNDd2pcn/ypOfQSyLIlNZwF6UzzQnVci6RN56febGwdtmhFP ydz1oGq/Z3UFM2JdhQzJjgetlXlufIrZdOsvRAsnTzWGVwK3CJ7f/9LkYXQHc9VkxUmB wT1uhx8u6+AXn4BkT2zAvtoS1odQt33fMkcyG95FTQUamk7TXmcXO7ywSgSIAMgRKMOl vg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 34bd0rjkkj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Oct 2020 13:12:27 -0400 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 09MH9W6Z190009; Thu, 22 Oct 2020 13:12:27 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com with ESMTP id 34bd0rjkkd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Oct 2020 13:12:27 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09MHCD3w000582; Thu, 22 Oct 2020 17:12:26 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma02dal.us.ibm.com with ESMTP id 347r89vdqc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Oct 2020 17:12:26 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 09MHCHQo40108436 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Oct 2020 17:12:17 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8F6978067; Thu, 22 Oct 2020 17:12:22 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 108CB7805F; Thu, 22 Oct 2020 17:12:21 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.170.177]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 22 Oct 2020 17:12:20 +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 v11 02/14] 390/vfio-ap: use new AP bus interface to search for queue devices Date: Thu, 22 Oct 2020 13:11:57 -0400 Message-Id: <20201022171209.19494-3-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20201022171209.19494-1-akrowiak@linux.ibm.com> References: <20201022171209.19494-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.235,18.0.737 definitions=2020-10-22_12:2020-10-20,2020-10-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 impostorscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010220108 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 --- drivers/s390/crypto/vfio_ap_ops.c | 35 +++++++++++++------------------ 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index c471832f0a30..049b97d7444c 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -26,43 +26,36 @@ static int vfio_ap_mdev_reset_queues(struct mdev_device *mdev); -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 + * vfio_ap_get_queue: Retrieve a queue with a specific APQN. * @matrix_mdev: the associated mediated matrix * @apqn: The queue APQN * - * Retrieve a queue with a specific APQN from the list of the - * devices of the vfio_ap_drv. - * Verify that the APID and the APQI are set in the matrix. + * Retrieve a queue with a specific APQN from the AP queue devices attached to + * the AP bus. * - * Returns the pointer to the associated vfio_ap_queue + * Returns the pointer to the vfio_ap_queue with the specified APQN, or NULL. */ static struct vfio_ap_queue *vfio_ap_get_queue( struct ap_matrix_mdev *matrix_mdev, - int apqn) + unsigned long apqn) { - struct vfio_ap_queue *q; - struct device *dev; + struct ap_queue *queue; + struct vfio_ap_queue *q = NULL; 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) + queue = ap_get_qdev(apqn); + if (!queue) return NULL; - q = dev_get_drvdata(dev); - q->matrix_mdev = matrix_mdev; - put_device(dev); + + 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.21.1