Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp529933pxu; Fri, 4 Dec 2020 09:01:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDS9+hKUSf4YaIPYWE0FmCrnCSQUKr9hPyUSkDo246BYqQBNFqEoEVzxbwMYWaMb//ewDJ X-Received: by 2002:a17:906:2806:: with SMTP id r6mr7468672ejc.130.1607101312066; Fri, 04 Dec 2020 09:01:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607101312; cv=none; d=google.com; s=arc-20160816; b=rnkvkBLz7KsV7rhYcCoLS6WkA5DMGdFpaQvd/pWTQnY0TptEsFhLWPjAxrcps8i9Ud RUGjqE/0OTwvGi87q9LzDE5FwQc1VDfABhbW3pvoOKJ7917YRCBOfSSngVSFzWr2oxU4 aL9Z18nRW9FFcBpXDsKrymb69K9aFE1152a33PDEXXh5dBxqUVmdTDHmMX3mvcEtI/IE +OgyC0GPZttA/JCYsvhsnceLll6PWNdQ7ckCGF9D+Bv2FDaSz7gCE+UZ5URFZJE/njQB dyY54RMUj6AhwO2oUmPyk3n0TOH6EDzIIyuthV8k3WaZE+ZABRiGyEmEZe7tt1nCheJh PckA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=K9cetLY5VHmxVOjnn8LGSQwAKU9lzMgAchAJJ3SA9Z8=; b=atabKpZvH0N/2dr+n3LGWBBgKulWDiIpPZ37lWw3pMLReKb6uzadfpLtOjWj5Y6n4b NpVQAF0sfkf4AsOkbaDcz7yk7C2BHVMs1ef8SgHVBo2FaqZQligmDKrpNhHiaht6NrvN 5K1hBkcaK7GSGiEyjIgxLCfGJRi3NwUCYjMiv387Evrpm3l9YOGxTPMf/zKZOM6WfIKs IaSRngnzV6sosNm8iw0bQCtDLVoSJEDrr6ZA/AVpNwEEV04Vm3UWL0GwPiqGf+ukcOpr UiatuM2CFW1FaJeHnU1n2Bxa//gd50zHxubjRKwObZIjS6+Hv7RI9mFn2n9U5b8Hy/z3 OqPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XXCARmAa; 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 re10si1944736ejb.85.2020.12.04.09.01.18; Fri, 04 Dec 2020 09:01:52 -0800 (PST) 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=XXCARmAa; 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 S1730627AbgLDQ6v (ORCPT + 99 others); Fri, 4 Dec 2020 11:58:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24983 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbgLDQ6u (ORCPT ); Fri, 4 Dec 2020 11:58:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607101044; 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=K9cetLY5VHmxVOjnn8LGSQwAKU9lzMgAchAJJ3SA9Z8=; b=XXCARmAa28IPFNyqoPLsYj9SKVHSCAKgW+YCGQLeOvx6bLhK+eoGJfeDkPcdzm91HCJR0z 1ZtToPyHyR9dGvlyUO23DLmICy9o8h5+jMOYpHlicG1kGSXkxQShtN0SiM/1hwqz7MovC9 2cWYzdnxSofh0M9BDGFezunarf47QCc= 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-281-YsdNyHWKOzuxYdbSgPzENg-1; Fri, 04 Dec 2020 11:57:20 -0500 X-MC-Unique: YsdNyHWKOzuxYdbSgPzENg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CAD78C73A2; Fri, 4 Dec 2020 16:57:18 +0000 (UTC) Received: from gondolin (ovpn-113-97.ams2.redhat.com [10.36.113.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69C0860873; Fri, 4 Dec 2020 16:57:10 +0000 (UTC) Date: Fri, 4 Dec 2020 17:57:07 +0100 From: Cornelia Huck To: Tony Krowiak Cc: Halil Pasic , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, borntraeger@de.ibm.com, alex.williamson@redhat.com, kwankhede@nvidia.com, david@redhat.com Subject: Re: [PATCH] s390/vfio-ap: Clean up vfio_ap resources when KVM pointer invalidated Message-ID: <20201204175707.13f019cf.cohuck@redhat.com> In-Reply-To: References: <20201202234101.32169-1-akrowiak@linux.ibm.com> <20201203185514.54060568.pasic@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.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 4 Dec 2020 11:48:24 -0500 Tony Krowiak wrote: > On 12/3/20 12:55 PM, Halil Pasic wrote: > > On Wed, 2 Dec 2020 18:41:01 -0500 > > Tony Krowiak wrote: > > > >> The vfio_ap device driver registers a group notifier with VFIO when the > >> file descriptor for a VFIO mediated device for a KVM guest is opened to > >> receive notification that the KVM pointer is set (VFIO_GROUP_NOTIFY_SET_KVM > >> event). When the KVM pointer is set, the vfio_ap driver stashes the pointer > >> and calls the kvm_get_kvm() function to increment its reference counter. > >> When the notifier is called to make notification that the KVM pointer has > >> been set to NULL, the driver should clean up any resources associated with > >> the KVM pointer and decrement its reference counter. The current > >> implementation does not take care of this clean up. > >> > >> Signed-off-by: Tony Krowiak > > Do we need a Fixes tag? Do we need this backported? In my opinion > > this is necessary since the interrupt patches. > > I'll put in a fixes tag: > Fixes: 258287c994de (s390: vfio-ap: implement mediated device open callback) The canonical format would be Fixes: 258287c994de ("s390: vfio-ap: implement mediated device open callback") > > Yes, this should probably be backported. > > > > >> --- > >> drivers/s390/crypto/vfio_ap_ops.c | 21 +++++++++++++-------- > >> 1 file changed, 13 insertions(+), 8 deletions(-) > >> > >> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c > >> index e0bde8518745..eeb9c9130756 100644 > >> --- a/drivers/s390/crypto/vfio_ap_ops.c > >> +++ b/drivers/s390/crypto/vfio_ap_ops.c > >> @@ -1083,6 +1083,17 @@ static int vfio_ap_mdev_iommu_notifier(struct notifier_block *nb, > >> return NOTIFY_DONE; > >> } > >> > >> +static void vfio_ap_mdev_put_kvm(struct ap_matrix_mdev *matrix_mdev) > > I don't like the name. The function does more that put_kvm. Maybe > > something like _disconnect_kvm()? > Since the vfio_ap_mdev_set_kvm() function is called by the > notifier when the KVM pointer is set, how about: > > vfio_ap_mdev_unset_kvm() > > for when the KVM pointer is nullified? Sounds good to me.