Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1174795ybz; Thu, 16 Apr 2020 04:25:55 -0700 (PDT) X-Google-Smtp-Source: APiQypIulEeY//Pxe+LEztiInV2rHa9LHXhv3dXEMlRrZngtkrr+SiJxIyEv+bw9WuZdKgX5Tq4I X-Received: by 2002:a17:906:496:: with SMTP id f22mr9106820eja.311.1587036355804; Thu, 16 Apr 2020 04:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587036355; cv=none; d=google.com; s=arc-20160816; b=DRNQhF2rk/xOszNvNs8gGfSRnFwH2/X33ZIxkUQaA38QZmHgBbxks/zdXb7Fax2wZZ WKcRHpo4eS6I9XJeZayNhURwGJgAAtfzX890XxFhcvZF5mOpS9nivJJp7xTIg0eL0Bmf Ip3vyliLJXpAm60LZcEWOVJV0M1B/+bWi6xE81qOIn8P4qlRmgxt7sax9ca0dJZjXuuN OPqyrWhmIP3Ot/rm3H/j5mRP7v4itGMOMW7iN8qTEw8OP6nkfEbdkAqN6hHaLkhAoW9a fdxlBIAPtQ8GmU93fIW+TY+KqiA1oeek8Ya65Hhi6VaXsxkU+htdD67ii4EG9g0hTj8a u3Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=/can4Mo5wcD8VxSmCD4glckN/kBnBrb4gDabEOaSwyw=; b=uIRAlgQqGfAUTce+AS9HjRRrJiUNF88ejIPXX0HWg08p11jLFZofT/KTRnGYCjJnIR UXPESxCYUy2GBUw3CzmKyd0cuUus9sPuAEMQ3HgQhmqfSnWDwevToda7YCaYJNy6c5Rb 1uMyU/CVjw3PejpmDl3rilIc0Mi5nF9bME5GMNLEuTySqAjGIXNGRDzcT/Kqb7LXzLDY gsAPfUYBALtSqbrblr1foEM4Fqgog9kfOkrKJwbsEQ606HBQp3zfd2KTs/Jr9utDpRdg DZJKQqMzw1eefOQD+klKmqs+TmSCH9+cBqseTpTcpNAOyDXTieT97BU7POxJ90TuQb14 +ZVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eH2ppfHN; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si1202535ejs.396.2020.04.16.04.25.32; Thu, 16 Apr 2020 04:25:55 -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=@redhat.com header.s=mimecast20190719 header.b=eH2ppfHN; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2632945AbgDPLVB (ORCPT + 99 others); Thu, 16 Apr 2020 07:21:01 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:31714 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2632881AbgDPLT2 (ORCPT ); Thu, 16 Apr 2020 07:19:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587035939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/can4Mo5wcD8VxSmCD4glckN/kBnBrb4gDabEOaSwyw=; b=eH2ppfHNwikK8p9wtPS0CfhoygOl3XuBCy5WHxc9K1dcK4rQTS9reV3tIC6YbJtAYioo75 +gJgXxuufZFRS7BbatwFhWcz3lWSgeq7gVJ4x3TYm7G9bHjRIOcyAe58rPUqZfMXEC8sMi u8KeQQGidqb0+MtrZ0W57hPZbSE3N+8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-140-i6e1aPlgPd6TuQe7djFNRw-1; Thu, 16 Apr 2020 07:18:55 -0400 X-MC-Unique: i6e1aPlgPd6TuQe7djFNRw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7FD0F149C3; Thu, 16 Apr 2020 11:18:53 +0000 (UTC) Received: from gondolin (ovpn-112-234.ams2.redhat.com [10.36.112.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D7FD5D9E2; Thu, 16 Apr 2020 11:18:48 +0000 (UTC) Date: Thu, 16 Apr 2020 13:18:45 +0200 From: Cornelia Huck 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 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> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; > +}