From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41990 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2632877AbgDPLTU (ORCPT ); Thu, 16 Apr 2020 07:19:20 -0400 Date: Thu, 16 Apr 2020 13:18:45 +0200 From: Cornelia Huck Subject: Re: [PATCH v7 04/15] s390/vfio-ap: implement in-use callback for vfio_ap driver Message-ID: <20200416131845.3ef6b3b5.cohuck@redhat.com> In-Reply-To: <20200407192015.19887-5-akrowiak@linux.ibm.com> References: <20200407192015.19887-1-akrowiak@linux.ibm.com> <20200407192015.19887-5-akrowiak@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-s390-owner@vger.kernel.org List-ID: To: Tony Krowiak Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, freude@linux.ibm.com, borntraeger@de.ibm.com, mjrosato@linux.ibm.com, pmorel@linux.ibm.com, pasic@linux.ibm.com, alex.williamson@redhat.com, kwankhede@nvidia.com, jjherne@linux.ibm.com, fiuczy@linux.ibm.com On Tue, 7 Apr 2020 15:20:04 -0400 Tony Krowiak wrote: > Let's implement the callback to indicate when an APQN > is in use by the vfio_ap device driver. The callback is > invoked whenever a change to the apmask or aqmask would > result in one or more queue devices being removed from the driver. The > vfio_ap device driver will indicate a resource is in use > if the APQN of any of the queue devices to be removed are assigned to > any of the matrix mdevs under the driver's control. > > Signed-off-by: Tony Krowiak > --- > drivers/s390/crypto/vfio_ap_drv.c | 1 + > drivers/s390/crypto/vfio_ap_ops.c | 47 +++++++++++++++++---------- > drivers/s390/crypto/vfio_ap_private.h | 2 ++ > 3 files changed, 33 insertions(+), 17 deletions(-) > @@ -1369,3 +1371,14 @@ void vfio_ap_mdev_remove_queue(struct ap_queue *queue) > kfree(q); > mutex_unlock(&matrix_dev->lock); > } > + > +bool vfio_ap_mdev_resource_in_use(unsigned long *apm, unsigned long *aqm) > +{ > + bool in_use; > + > + mutex_lock(&matrix_dev->lock); > + in_use = vfio_ap_mdev_verify_no_sharing(NULL, apm, aqm) ? true : false; Maybe in_use = !!vfio_ap_mdev_verify_no_sharing(NULL, apm, aqm); ? > + mutex_unlock(&matrix_dev->lock); > + > + return in_use; > +}