Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp89328rwn; Wed, 7 Sep 2022 12:59:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR6nnSxRnHcZdGaJU0pIwddCB35ocreR77fY3KQm2Ctki9TbglFQSoHb+ZFJ4bf4pMj04Y4T X-Received: by 2002:a17:907:9812:b0:742:2865:eca8 with SMTP id ji18-20020a170907981200b007422865eca8mr3317727ejc.537.1662580763760; Wed, 07 Sep 2022 12:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662580763; cv=none; d=google.com; s=arc-20160816; b=wC4tx6yte0Fy13aDMY5BWWHYwqGxbBmCdGBcxlHvLI0T5UKvrXfmClkmHyIZ4qEtMD V7xZhkHkCoVzVKBzVDnF5/sL8fdWEz3u2b0JZhhfEXH2RnOaiZj3vCA98ANb6hUninnc E16VSO88fKBoYs5sBcmHXomhiVftOlIxTtNI7by7LZmlZQdsGnj2FiSo4ysQ5Mz7UwVJ JRIWFtAGgLdJ1l+Y7eui6m00TQ0ZcHVbI4Zkj0J81GFeCeqAoURoHoWpRZGbjxf3WuDa HPPQsdEy4SbJI+j6SRrRUi52VDYh+L0e8WttXtviwNbsvgJSzDwob6aiwmzDjxWMFov9 Ursw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:reply-to:user-agent :mime-version:date:message-id:dkim-signature; bh=mpAWAgyga4+TA9fA5HlAdMkYKlmLpnYSbT76a8Tb7hY=; b=E3xr3nNyStvUF7q9AKQ7H4YNS/TmmGI+DHOnl3jd5GsgiI4yIMJrASrK1/LqzkFerj NljhpB8DYrS3JVj1iGSa1BK6W/heBZTbbO+c2U3ZVo07KSdg4tW7yiEA1VSuQqGCIHnr SXBw2wYsfIT/vk21pewtsL64oU10K79NBGs4rGGWCssc4pvPby3Rv8kCRnfCW0zFNej5 AzQLLzQZXdzK6uXprM/3KrS2qcfhjHcQ3/mbDKQ+fiVJ8Hs13mTwUi4oCmpPIiZybFAz +HN6iL+2xQh4gedrW3WCHa7c7pn8di3G/FOlBPL2X27GTsVtYmG3OsF+8B2CyO3OgtBk 8M+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X7VmqUeO; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cb20-20020a170906a45400b007417e9a2c71si270001ejb.352.2022.09.07.12.58.58; Wed, 07 Sep 2022 12:59:23 -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=@redhat.com header.s=mimecast20190719 header.b=X7VmqUeO; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229911AbiIGTgT (ORCPT + 99 others); Wed, 7 Sep 2022 15:36:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbiIGTgQ (ORCPT ); Wed, 7 Sep 2022 15:36:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F4E6BC83B for ; Wed, 7 Sep 2022 12:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662579359; h=from:from:reply-to: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=mpAWAgyga4+TA9fA5HlAdMkYKlmLpnYSbT76a8Tb7hY=; b=X7VmqUeONFeA2CIb2q5RE0hmnroKBExrcY3NpTiV5Cs/UQzsqX4MABfFrn1kjREvATQoTG iaT2BshRDKEykYCl7UIICGGDzGBz8AGm/eXrmuThLwqIbkmR+zG3Wf2PZhzqtp5SA+BgNd a/QnTHbhoKpIGhyRoLjQIyId1Ay+37k= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-571-fpbF_hiyNGGhjPYZHAVt-Q-1; Wed, 07 Sep 2022 15:35:58 -0400 X-MC-Unique: fpbF_hiyNGGhjPYZHAVt-Q-1 Received: by mail-wr1-f71.google.com with SMTP id s1-20020adf9781000000b002286cd81376so3336932wrb.22 for ; Wed, 07 Sep 2022 12:35:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=mpAWAgyga4+TA9fA5HlAdMkYKlmLpnYSbT76a8Tb7hY=; b=x8cnhYDrb6hdlVrV6H07XuufJlxpHN6MkG7Y/6/eORbF6DugAunqibe1nsvo3DtydF Cv5Lzs1LpvQgG+zylksVuY6CS4VaL40tD4F+LXxfRh90cYIzgoFnH2jX0UgpdWh05zAX tnunmZ1d3cQvrsBVpVA5qW8celcVeIHb2hC7+4GBf6/UQ5orPyRFTY9WVpzLa56OivVA 4EzZrncq39EECBe9IiC5HOpU3eM3de4sy10X40D717ETedWC1QUsqDDVWjKTOD0w9azG nndlustQSQ8KzM9elhBCl7WyRy49zStAo+J9Ex5wGUuqaLhVGW+TtRSV1KxYBi4QUULo PCPQ== X-Gm-Message-State: ACgBeo3Y5ijZFv1gM0MI7viCfBKrqWsZSnH9iGWJu15EpVIHUffKsWP7 VPC4RXjgAZXzt6SYpjgapgoIeONJZX2vxDZsUEFjA4xxvKTyGQGb4g9/ilKjp16d3xc/M0beulp /LUQ5167s9F5potnIHFCGtZ5J X-Received: by 2002:a5d:6c62:0:b0:222:cda4:e09e with SMTP id r2-20020a5d6c62000000b00222cda4e09emr3050004wrz.449.1662579356972; Wed, 07 Sep 2022 12:35:56 -0700 (PDT) X-Received: by 2002:a5d:6c62:0:b0:222:cda4:e09e with SMTP id r2-20020a5d6c62000000b00222cda4e09emr3049984wrz.449.1662579356689; Wed, 07 Sep 2022 12:35:56 -0700 (PDT) Received: from ?IPV6:2a01:e0a:59e:9d80:527b:9dff:feef:3874? ([2a01:e0a:59e:9d80:527b:9dff:feef:3874]) by smtp.gmail.com with ESMTPSA id w4-20020adfee44000000b0022863c18b93sm14810197wro.13.2022.09.07.12.35.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Sep 2022 12:35:55 -0700 (PDT) Message-ID: <2ed84b0f-5d60-919f-06a4-a5ede2f98ce5@redhat.com> Date: Wed, 7 Sep 2022 21:35:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Reply-To: eric.auger@redhat.com Subject: Re: [PATCH v2 14/15] vfio: Rename vfio_device_put() and vfio_device_try_get() Content-Language: en-US To: Kevin Tian , 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 , 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 References: <20220901143747.32858-1-kevin.tian@intel.com> <20220901143747.32858-15-kevin.tian@intel.com> From: Eric Auger In-Reply-To: <20220901143747.32858-15-kevin.tian@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,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 On 9/1/22 16:37, Kevin Tian wrote: > 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 Eric > --- > 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); > } > > -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, > > 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; > } > @@ -671,7 +672,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); > @@ -730,7 +731,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; > } > @@ -750,7 +751,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) > @@ -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; > } > > @@ -1461,7 +1462,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; > }