Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1423910rwn; Thu, 8 Sep 2022 20:19:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR4MX4hCUGcOfWX1qSyj+QgfLSc4BhuaQMeZQ2aYUAKrIvMKYzkVyIpvCCLFyeoN6b5Z6Vw/ X-Received: by 2002:a17:90b:4f89:b0:202:8e4a:addd with SMTP id qe9-20020a17090b4f8900b002028e4aadddmr315262pjb.131.1662693574706; Thu, 08 Sep 2022 20:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662693574; cv=none; d=google.com; s=arc-20160816; b=ejIvIGT9DoMQ8jgqFUEGQlUhg7ZJEv9609DeI4zDgE6Z6hptl5GMWt7A3TVYu9aZuQ uAW2+mz/4anifUMWMIh9uYrXuXSW3gm/r9IK7/t0J7Rolu/J1qQ5iVmVrQDSJLgON74l AluXdsk45lp3E9KHlV+6HF6r8eF0INPH3LB+/kIJFi67XDNpH92lP17XHbtw9E8Egj1e nO3pX+rAGO8uMryBATpz3ERGILRvupXE5s0BuWxxFlhTQLfBU0mb/et2PtK0Q+U3a0Yb HHR/gw1Rkgtq5CYXIdoLhvt9aVmBf1gEy7iUKl/H9mndp3+46VcYP5lE0CJfJK/a1rRx etfQ== 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=ID7gQAvDirBfM+1F4SLrgVJ+/n9yAz6DzSuQ/hdzQfY=; b=0Ppa41cO+dMWB+11ODJivCpn30M+vWXg6g70dmvwHZYRWyohGK63i8b2xuv/9YhlIK BTQlinNV/YDf42xC9RRxd5hXY2wWEieSuAU2kkWHHHG6gf4zAkD65KHbia292rJqr3Xc 1piFbfNlb3rhijb4D6C3y8jZo1xqu0QgKOtx+lUp/QZowyZYNru8qQcF1GO1Do1cDmBx mtTzO35k3bp/aDS3TuRtg/j2oZkRo4AoGBanxrF+ppZ6a5I9vQQj4JIVx15yN+I4alwb 1wPnG6ABJTGfPdRmm53VHP+FJN1mQSFzHi1YFb0enCwqL0Cj/zIXGz9CyDHLIw6nkXg9 8HWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mllIfdNS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a654c8a000000b004387adde4f9si555060pgt.91.2022.09.08.20.19.22; Thu, 08 Sep 2022 20:19:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mllIfdNS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbiIIDHw (ORCPT + 99 others); Thu, 8 Sep 2022 23:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbiIIDHM (ORCPT ); Thu, 8 Sep 2022 23:07:12 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C20E402E9; Thu, 8 Sep 2022 20:05: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=1662692751; x=1694228751; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oJ5SymJmzLe17tI+1YjGhf5nVnZnZY22ruGxdLktqXY=; b=mllIfdNS9qebo0bOi/mUWN1bdx7tsDswNyNYBsSfFo55zKOYyCL5o7Aa kDwWxCPc+ZZ+xC2+Shwq60+F4zIAk7YQ2bze+8vP6cDFB8tzbdM08UUfX ySnfVzq/tg3YqKW4dFuiWj7+OKJWpuhyfsxrUP2UYZHDeFeo8k25urWxb K2x6y8RsPbin9Z8FmRBgsoZX6HH3xZ5i4+WVEQJcFs6evIqDbx9/I3CyY +Ngn7emAKmFEtGBb5A5lB3/+xFduIj6kTnHpJ2yaLfOgojv8WOdUuaeNG LcVa3DljIl+dbKI7LwiAkk1rKJ8LKK+HIxyFUVg7j+Z/ucPx65oHtEbgN A==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="296118730" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="296118730" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 20:05:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="740909314" Received: from sqa-gate.sh.intel.com (HELO michael.clx.dev.tsp.org) ([10.239.48.212]) by orsmga004.jf.intel.com with ESMTP; 08 Sep 2022 20:05:36 -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 , Christoph Hellwig , 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 v3 14/15] vfio: Rename vfio_device_put() and vfio_device_try_get() Date: Fri, 9 Sep 2022 18:22:46 +0800 Message-Id: <20220909102247.67324-15-kevin.tian@intel.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20220909102247.67324-1-kevin.tian@intel.com> References: <20220909102247.67324-1-kevin.tian@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 5bc221730d7b..37cbd10f3faf 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -453,13 +453,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); } -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); } @@ -471,7 +471,8 @@ static struct vfio_device *vfio_group_get_device(struct vfio_group *group, mutex_lock(&group->device_lock); list_for_each_entry(device, &group->device_list, group_next) { - if (device->dev == dev && vfio_device_try_get(device)) { + if (device->dev == dev && + vfio_device_try_get_registration(device)) { mutex_unlock(&group->device_lock); return device; } @@ -673,7 +674,7 @@ static int __vfio_register_dev(struct vfio_device *device, 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 == VFIO_NO_IOMMU || group->type == VFIO_EMULATED_IOMMU) iommu_group_remove_device(device->dev); @@ -731,7 +732,7 @@ static struct vfio_device *vfio_device_get_from_name(struct vfio_group *group, ret = !strcmp(dev_name(it->dev), buf); } - if (ret && vfio_device_try_get(it)) { + if (ret && vfio_device_try_get_registration(it)) { device = it; break; } @@ -751,7 +752,7 @@ void vfio_unregister_group_dev(struct vfio_device *device) bool interrupted = false; long rc; - vfio_device_put(device); + vfio_device_put_registration(device); rc = try_wait_for_completion(&device->comp); while (rc <= 0) { if (device->ops->request) @@ -1311,7 +1312,7 @@ static int vfio_group_ioctl_get_device_fd(struct vfio_group *group, err_put_fdno: put_unused_fd(fdno); err_put_device: - vfio_device_put(device); + vfio_device_put_registration(device); return ret; } @@ -1493,7 +1494,7 @@ static int vfio_device_fops_release(struct inode *inode, struct file *filep) vfio_device_unassign_container(device); - vfio_device_put(device); + vfio_device_put_registration(device); return 0; } -- 2.21.3