From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05787C433E0 for ; Wed, 17 Jun 2020 12:04:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFD4F20CC7 for ; Wed, 17 Jun 2020 12:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726540AbgFQMEA (ORCPT ); Wed, 17 Jun 2020 08:04:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:23034 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbgFQMEA (ORCPT ); Wed, 17 Jun 2020 08:04:00 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05HC2Mmo164384; Wed, 17 Jun 2020 08:03:56 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 31q6hjvh2q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Jun 2020 08:03:56 -0400 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 05HC2L9P164249; Wed, 17 Jun 2020 08:03:56 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 31q6hjvh1j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Jun 2020 08:03:55 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05HBuEaE022230; Wed, 17 Jun 2020 12:03:54 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma01dal.us.ibm.com with ESMTP id 31q9v5yp9q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Jun 2020 12:03:54 +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 05HC2YLu25362754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jun 2020 12:02:34 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6EDCD78064; Wed, 17 Jun 2020 12:02:35 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46C247805F; Wed, 17 Jun 2020 12:02:34 +0000 (GMT) Received: from cpe-172-100-175-116.stny.res.rr.com (unknown [9.85.146.208]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 17 Jun 2020 12:02:34 +0000 (GMT) Subject: Re: [PATCH v8 02/16] s390/vfio-ap: use new AP bus interface to search for queue devices To: Christian Borntraeger , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: freude@linux.ibm.com, cohuck@redhat.com, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex.williamson@redhat.com, kwankhede@nvidia.com, fiuczy@linux.ibm.com References: <20200605214004.14270-1-akrowiak@linux.ibm.com> <20200605214004.14270-3-akrowiak@linux.ibm.com> <93492fa3-31f1-a551-4b26-e46bc277e351@de.ibm.com> From: Tony Krowiak Message-ID: Date: Wed, 17 Jun 2020 08:02:33 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <93492fa3-31f1-a551-4b26-e46bc277e351@de.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-17_03:2020-06-17,2020-06-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=3 spamscore=0 phishscore=0 impostorscore=0 cotscore=-2147483648 priorityscore=1501 clxscore=1015 malwarescore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006170091 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/16/20 11:45 AM, Christian Borntraeger wrote: > > On 05.06.20 23:39, Tony Krowiak wrote: >> This patch refactor's 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_drv.c | 27 ++------- >> drivers/s390/crypto/vfio_ap_ops.c | 82 +++++++++++++++------------ >> drivers/s390/crypto/vfio_ap_private.h | 8 ++- >> 3 files changed, 58 insertions(+), 59 deletions(-) >> >> diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c >> index be2520cc010b..59233cf7419d 100644 >> --- a/drivers/s390/crypto/vfio_ap_drv.c >> +++ b/drivers/s390/crypto/vfio_ap_drv.c >> @@ -51,15 +51,9 @@ MODULE_DEVICE_TABLE(vfio_ap, ap_queue_ids); >> */ >> static int vfio_ap_queue_dev_probe(struct ap_device *apdev) >> { >> - struct vfio_ap_queue *q; >> - >> - q = kzalloc(sizeof(*q), GFP_KERNEL); >> - if (!q) >> - return -ENOMEM; >> - dev_set_drvdata(&apdev->device, q); >> - q->apqn = to_ap_queue(&apdev->device)->qid; >> - q->saved_isc = VFIO_AP_ISC_INVALID; >> - return 0; >> + struct ap_queue *queue = to_ap_queue(&apdev->device); >> + >> + return vfio_ap_mdev_probe_queue(queue); >> } > Here we did not hold a mutex in the old code > [...] > >> +int vfio_ap_mdev_probe_queue(struct ap_queue *queue) >> +{ >> + struct vfio_ap_queue *q; >> + >> + q = kzalloc(sizeof(*q), GFP_KERNEL); >> + if (!q) >> + return -ENOMEM; >> + >> + mutex_lock(&matrix_dev->lock); >> + dev_set_drvdata(&queue->ap_dev.device, q); >> + q->apqn = queue->qid; >> + q->saved_isc = VFIO_AP_ISC_INVALID; >> + mutex_unlock(&matrix_dev->lock); >> + > here we do. Why do we need the matrix_dev->lock here? You are correct, we don't need it here; but, we will need it in a subsequent patch where we introduce linking the q to the matrix mdev to which it is assigned. Perhaps the locking should be introduced in that patch. >