Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp493320pxf; Wed, 31 Mar 2021 08:26:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNAxxzC7whdkeQoW8n0+SO28CPX8cjYr195P6JQ7ATpOhlIw4+c6pvpnTvgvyti/PwEwR0 X-Received: by 2002:a17:907:75c2:: with SMTP id jl2mr4191433ejc.334.1617204416766; Wed, 31 Mar 2021 08:26:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617204416; cv=none; d=google.com; s=arc-20160816; b=ICbHY7mqoKGoDdOX+VrHnuTZyW6FreL9d48fp0eOFeAZYHXFqT1xhezFXaQr3Q775l 5BntuHRqbkjy+WOoPYctAfQAWd1zq1vYuxpA2YDFV8X1+F6+Yp5/gRZlnUZvg7g+y3CX RFarbPLyt3IC1XOF7t9MV3VI7SxcPAg8bA9uGf6g6XcvE68ce9oDgBgY7azKV58o+oEP pTeuCc8ejL5Ol7HQdYCllLhrPGaZnCiU9dhsLEi3yQE2J/N62bbbla3Wtoq3D6c78ny7 OxK0Di5ocFOo8LDqekcJOqehbkdCHj+BoYCxOGzLLhtmqdiu66yUTxzTvpm3bwwSZ5ck q0Uw== 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=HBoofbeX3zUsh9dh6XYHoFZF0e/Ij0l4DGGqJchRjbU=; b=FeVdNS7n23/ZKN8u2ljuq+nxyIuMecw4EXm9BDEIw36/YKSHL58piHPdkLlzgDakWL iGHflxODyY6ITG584bawij0tfXEbbGRAuY6Bre+ymzI2wgzDBwO5QoAMxprpC7y7OiBa pWUd2McWIUpYfV7gTn/baxAJI3JweFmf3nJzhCeVejcqWfBGtZmFaeYYHwaFkgWes/j7 7cBGmh4BpIdHRk9yauge56CAsEMvww/4RyA19pBXc4GMcCYqMRF88kYD7R1fJ/bCGQar +IHDImdEgAWsMIlvq89vAXAs/hoEc/SZr3XSOF3Sii1+RR5xsSiAja7qM/1eFQRwFc+X O9BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=e55w6rZD; 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 g21si1835250edu.536.2021.03.31.08.26.34; Wed, 31 Mar 2021 08:26:56 -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=e55w6rZD; 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 S236348AbhCaPXe (ORCPT + 99 others); Wed, 31 Mar 2021 11:23:34 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:27124 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236260AbhCaPXX (ORCPT ); Wed, 31 Mar 2021 11:23:23 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12VF3I7m031125; Wed, 31 Mar 2021 11:23:21 -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=HBoofbeX3zUsh9dh6XYHoFZF0e/Ij0l4DGGqJchRjbU=; b=e55w6rZDaWQND+v6RzlKGJC6msrQlSH+ZZh2HSh+6v6kcl0gkfiQNYsCv6Jag21U6K/b QjpyK2MKnSSJTaH//ItGEQUY48qZ75EIzcDWUYt9yzNDTWQy0atX7uT6JPuTbq3PWcxy XZQ8TGBGpEVa8DwDT0d2Q4y7idqtOvCsN2QzMcABroFOlb/ukkftDcevOPx5XGjhO66i O4V6exSnWjb94XsUgGX0Geg7rsFvv2dovAnDPK0QsciAWc/D5Ip0h4e2rgRogNwcYgpn fB3lB8vWPzrpQ71l3HHmv5WmfBvDxDHHiKNE8sJkLzZPVukASMif9KA8cxG7Q/CSC5Ih mA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 37mu4u9d6j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Mar 2021 11:23:21 -0400 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 12VF4HIA036673; Wed, 31 Mar 2021 11:23:21 -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 37mu4u9d60-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Mar 2021 11:23:20 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12VF29dM011972; Wed, 31 Mar 2021 15:23:20 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 37maawfd7a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Mar 2021 15:23:20 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 12VFNGH430736680 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Mar 2021 15:23:16 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0F1B6E054; Wed, 31 Mar 2021 15:23:16 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA19D6E04C; Wed, 31 Mar 2021 15:23:14 +0000 (GMT) Received: from cpe-66-24-58-13.stny.res.rr.com.com (unknown [9.85.146.149]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 31 Mar 2021 15:23:14 +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, frankja@linux.ibm.com, david@redhat.com, hca@linux.ibm.com, gor@linux.ibm.com, Tony Krowiak Subject: [PATCH v14 03/13] s390/vfio-ap: move probe and remove callbacks to vfio_ap_ops.c Date: Wed, 31 Mar 2021 11:22:46 -0400 Message-Id: <20210331152256.28129-4-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20210331152256.28129-1-akrowiak@linux.ibm.com> References: <20210331152256.28129-1-akrowiak@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: yPeZGqqcUkxoR929F1ZTtR6ymVnU98qV X-Proofpoint-GUID: _Y6PYtb7Ik4ObYLSIVN6u3eo0O4PTc4I X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-31_06:2021-03-31,2021-03-31 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 mlxscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103300000 definitions=main-2103310107 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's move the probe and remove callbacks into the vfio_ap_ops.c file to keep all code related to managing queues in a single file. This way, all functions related to queue management can be removed from the vfio_ap_private.h header file defining the public interfaces for the vfio_ap device driver. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_drv.c | 41 ++------------------------- drivers/s390/crypto/vfio_ap_ops.c | 28 ++++++++++++++++++ drivers/s390/crypto/vfio_ap_private.h | 5 ++-- 3 files changed, 33 insertions(+), 41 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c index 7dc72cb718b0..73bd073fd5d3 100644 --- a/drivers/s390/crypto/vfio_ap_drv.c +++ b/drivers/s390/crypto/vfio_ap_drv.c @@ -43,43 +43,6 @@ static struct ap_device_id ap_queue_ids[] = { MODULE_DEVICE_TABLE(vfio_ap, ap_queue_ids); -/** - * vfio_ap_queue_dev_probe: - * - * Allocate a vfio_ap_queue structure and associate it - * with the device as driver_data. - */ -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; -} - -/** - * vfio_ap_queue_dev_remove: - * - * Takes the matrix lock to avoid actions on this device while removing - * Free the associated vfio_ap_queue structure - */ -static void vfio_ap_queue_dev_remove(struct ap_device *apdev) -{ - struct vfio_ap_queue *q; - - mutex_lock(&matrix_dev->lock); - q = dev_get_drvdata(&apdev->device); - vfio_ap_mdev_reset_queue(q, 1); - dev_set_drvdata(&apdev->device, NULL); - kfree(q); - mutex_unlock(&matrix_dev->lock); -} - static void vfio_ap_matrix_dev_release(struct device *dev) { struct ap_matrix_dev *matrix_dev = dev_get_drvdata(dev); @@ -182,8 +145,8 @@ static int __init vfio_ap_init(void) return ret; memset(&vfio_ap_drv, 0, sizeof(vfio_ap_drv)); - vfio_ap_drv.probe = vfio_ap_queue_dev_probe; - vfio_ap_drv.remove = vfio_ap_queue_dev_remove; + vfio_ap_drv.probe = vfio_ap_mdev_probe_queue; + vfio_ap_drv.remove = vfio_ap_mdev_remove_queue; vfio_ap_drv.ids = ap_queue_ids; ret = ap_driver_register(&vfio_ap_drv, THIS_MODULE, VFIO_AP_DRV_NAME); diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 128a66d57305..c630abac81d0 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -1446,3 +1446,31 @@ void vfio_ap_mdev_unregister(void) { mdev_unregister_device(&matrix_dev->device); } + +int vfio_ap_mdev_probe_queue(struct ap_device *apdev) +{ + struct vfio_ap_queue *q; + + q = kzalloc(sizeof(*q), GFP_KERNEL); + if (!q) + return -ENOMEM; + mutex_lock(&matrix_dev->lock); + q->apqn = to_ap_queue(&apdev->device)->qid; + q->saved_isc = VFIO_AP_ISC_INVALID; + dev_set_drvdata(&apdev->device, q); + mutex_unlock(&matrix_dev->lock); + + return 0; +} + +void vfio_ap_mdev_remove_queue(struct ap_device *apdev) +{ + struct vfio_ap_queue *q; + + mutex_lock(&matrix_dev->lock); + q = dev_get_drvdata(&apdev->device); + vfio_ap_mdev_reset_queue(q, 1); + dev_set_drvdata(&apdev->device, NULL); + kfree(q); + mutex_unlock(&matrix_dev->lock); +} diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h index f82a6396acae..3ca2da62bdee 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -100,7 +100,8 @@ struct vfio_ap_queue { int vfio_ap_mdev_register(void); void vfio_ap_mdev_unregister(void); -int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q, - unsigned int retry); + +int vfio_ap_mdev_probe_queue(struct ap_device *queue); +void vfio_ap_mdev_remove_queue(struct ap_device *queue); #endif /* _VFIO_AP_PRIVATE_H_ */ -- 2.21.3