From patchwork Mon Dec 16 09:59:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Lin Guay X-Patchwork-Id: 13911638 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EDB67E7717F for ; Tue, 17 Dec 2024 10:55:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6CB8210E90F; Tue, 17 Dec 2024 10:55:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=fb.com header.i=@fb.com header.b="Unc6/rem"; dkim-atps=neutral Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9583910E573 for ; Mon, 16 Dec 2024 10:06:49 +0000 (UTC) Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BG3qqQW028463 for ; Mon, 16 Dec 2024 01:59:56 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=facebook; bh=f 0d7e7vgSwFquFJynHv37WoE8Ih8RaPc8Rz59bR6mwY=; b=Unc6/remm63njyGu+ jvXAH/eC6QlxeDqvT4mzSWtw5al3moX2Llllk0Aovi9s7cewco6JGQgL4GQNu7qs 0B7JdPrcB6JWWhGbQT/ZqcuRx4OU4SuUOWsraHjPpJ19aN3QlCxGbgB7o9EWD+NA w2DmC2vtNGVJ5R8JurvBo7I2nE= Received: from maileast.thefacebook.com ([163.114.135.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 43jcpkhb6h-17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 Dec 2024 01:59:55 -0800 (PST) Received: from twshared40462.17.frc2.facebook.com (2620:10d:c0a8:1c::1b) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Mon, 16 Dec 2024 09:59:39 +0000 Received: by devvm12370.nha0.facebook.com (Postfix, from userid 624418) id C682310A1F701; Mon, 16 Dec 2024 01:59:27 -0800 (PST) From: Wei Lin Guay To: , , , CC: , , , , , Wei Lin Guay Subject: [PATCH 1/4] vfio: Add vfio_device_get() Date: Mon, 16 Dec 2024 01:59:15 -0800 Message-ID: <20241216095920.237117-2-wguay@fb.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216095920.237117-1-wguay@fb.com> References: <20241216095920.237117-1-wguay@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: aikO79U--S_BjegXrK1SCHvAKM-7Ex_S X-Proofpoint-ORIG-GUID: aikO79U--S_BjegXrK1SCHvAKM-7Ex_S X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-05_03,2024-10-04_01,2024-09-30_01 X-Mailman-Approved-At: Tue, 17 Dec 2024 10:55:20 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Jason Gunthorpe Summary: To increment a reference the caller already holds. Export vfio_device_put() to pair with it. Signed-off-by: Jason Gunthorpe Signed-off-by: Wei Lin Guay Reviewed-by: Dag Moxnes Reviewed-by: Keith Busch Reviewed-by: Nic Viljoen --- drivers/vfio/vfio_main.c | 1 + include/linux/vfio.h | 6 ++++++ 2 files changed, 7 insertions(+) -- 2.43.5 diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index a5a62d9d963f..7e318e15abd5 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -171,6 +171,7 @@ void vfio_device_put_registration(struct vfio_device *device) if (refcount_dec_and_test(&device->refcount)) complete(&device->comp); } +EXPORT_SYMBOL_GPL(vfio_device_put_registration); bool vfio_device_try_get_registration(struct vfio_device *device) { diff --git a/include/linux/vfio.h b/include/linux/vfio.h index 000a6cab2d31..d7c790be4bbc 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -279,6 +279,12 @@ static inline void vfio_put_device(struct vfio_device *device) int vfio_register_group_dev(struct vfio_device *device); int vfio_register_emulated_iommu_dev(struct vfio_device *device); void vfio_unregister_group_dev(struct vfio_device *device); +void vfio_device_put_registration(struct vfio_device *device); + +static inline void vfio_device_get(struct vfio_device *device) +{ + refcount_inc(&device->refcount); +} int vfio_assign_device_set(struct vfio_device *device, void *set_id); unsigned int vfio_device_set_open_count(struct vfio_device_set *dev_set);