From nobody Thu Apr 9 16:14:55 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DF24ECAAD8 for ; Thu, 1 Sep 2022 07:22:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233820AbiIAHWp (ORCPT ); Thu, 1 Sep 2022 03:22:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233355AbiIAHWL (ORCPT ); Thu, 1 Sep 2022 03:22:11 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83AA8126925; Thu, 1 Sep 2022 00:20:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662016848; x=1693552848; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TXG/j07OriuoJ6RyVCBIyUhcBlilAokPO0tPCFm5g0M=; b=F78VLYXDpWhZ8XR1NDmkdEL0/mk6ikr4EmlWQUHjpYRx5kFJ++K2YrXv 3Z+lA/k41/+u1PPcX1tLlxa1JSQxzqKlHH1qJ3yuURp2wmD4OxxMXrlIz hlV+LeKChRJivaXVWKwWV8gjXhHy4awPE5Y8mMNdlLQSnqYbuyd/s2IwI efk+ioJOQhZF5SDkLetL5Q1aEbyqbKztfbN/X1CyORzG707dLL1iEvSTy ytWpIL09moFmbBHnXrsTBok9e5+g0MrR3HZlgQ7fOvdoV2CZNcS84X9ub 5RKOACJNLih5gE07egpSOysJ5kI9qAr9d3SZttH6BLLDKI/UEN0QZZSrq w==; X-IronPort-AV: E=McAfee;i="6500,9779,10456"; a="357356048" X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="357356048" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 00:19:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="673720786" Received: from sqa-gate.sh.intel.com (HELO michael.clx.dev.tsp.org) ([10.239.48.212]) by fmsmga008.fm.intel.com with ESMTP; 01 Sep 2022 00:19:33 -0700 From: Kevin Tian To: Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Eric Farman , Matthew Rosato , Halil Pasic , Vineeth Vijayan , Peter Oberparleiter , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Tony Krowiak , Jason Herne , Harald Freudenberger , Diana Craciun , Alex Williamson , Cornelia Huck , Longfang Liu , Shameer Kolothum , Jason Gunthorpe , Yishai Hadas , Kevin Tian , Eric Auger , Kirti Wankhede , Leon Romanovsky , Abhishek Sahu , intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org Cc: Yi Liu Subject: [PATCH v2 14/15] vfio: Rename vfio_device_put() and vfio_device_try_get() Date: Thu, 1 Sep 2022 22:37:46 +0800 Message-Id: <20220901143747.32858-15-kevin.tian@intel.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20220901143747.32858-1-kevin.tian@intel.com> References: <20220901143747.32858-1-kevin.tian@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" With the addition of vfio_put_device() now the names become confusing. vfio_put_device() is clear from object life cycle p.o.v given kref. vfio_device_put()/vfio_device_try_get() are helpers for tracking users on a registered device. Now rename them: - vfio_device_put() -> vfio_device_put_registration() - vfio_device_try_get() -> vfio_device_try_get_registration() Signed-off-by: Kevin Tian Reviewed-by: Jason Gunthorpe Reviewed-by: Eric Auger --- drivers/vfio/vfio_main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index 957d9f286550..bfa675d314ab 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -451,13 +451,13 @@ static void vfio_group_get(struct vfio_group *group) * Device objects - create, release, get, put, search */ /* Device reference always implies a group reference */ -static void vfio_device_put(struct vfio_device *device) +static void vfio_device_put_registration(struct vfio_device *device) { if (refcount_dec_and_test(&device->refcount)) complete(&device->comp); } =20 -static bool vfio_device_try_get(struct vfio_device *device) +static bool vfio_device_try_get_registration(struct vfio_device *device) { return refcount_inc_not_zero(&device->refcount); } @@ -469,7 +469,8 @@ static struct vfio_device *vfio_group_get_device(struct= vfio_group *group, =20 mutex_lock(&group->device_lock); list_for_each_entry(device, &group->device_list, group_next) { - if (device->dev =3D=3D dev && vfio_device_try_get(device)) { + if (device->dev =3D=3D dev && + vfio_device_try_get_registration(device)) { mutex_unlock(&group->device_lock); return device; } @@ -671,7 +672,7 @@ static int __vfio_register_dev(struct vfio_device *devi= ce, if (existing_device) { dev_WARN(device->dev, "Device already exists on group %d\n", iommu_group_id(group->iommu_group)); - vfio_device_put(existing_device); + vfio_device_put_registration(existing_device); if (group->type =3D=3D VFIO_NO_IOMMU || group->type =3D=3D VFIO_EMULATED_IOMMU) iommu_group_remove_device(device->dev); @@ -730,7 +731,7 @@ static struct vfio_device *vfio_device_get_from_name(st= ruct vfio_group *group, ret =3D !strcmp(dev_name(it->dev), buf); } =20 - if (ret && vfio_device_try_get(it)) { + if (ret && vfio_device_try_get_registration(it)) { device =3D it; break; } @@ -750,7 +751,7 @@ void vfio_unregister_group_dev(struct vfio_device *devi= ce) bool interrupted =3D false; long rc; =20 - vfio_device_put(device); + vfio_device_put_registration(device); rc =3D try_wait_for_completion(&device->comp); while (rc <=3D 0) { if (device->ops->request) @@ -1286,7 +1287,7 @@ static int vfio_group_get_device_fd(struct vfio_group= *group, char *buf) err_put_fdno: put_unused_fd(fdno); err_put_device: - vfio_device_put(device); + vfio_device_put_registration(device); return ret; } =20 @@ -1461,7 +1462,7 @@ static int vfio_device_fops_release(struct inode *ino= de, struct file *filep) =20 vfio_device_unassign_container(device); =20 - vfio_device_put(device); + vfio_device_put_registration(device); =20 return 0; } --=20 2.21.3