From patchwork Wed Oct 9 16:38:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 13828817 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 374EECEE32D for ; Wed, 9 Oct 2024 16:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MRke0kQkqsrccmcWScj2DUzADwLkGpQ8YcQrRjbTI+A=; b=znyEAtxw2B0iWEqEnpIkavzG3+ kKJvpfG9Tn55UajfqB11ch3VxRLq0V6Fk84bvE3V8mV06tTtsdKI18/j/E+w6qsmki/jAdq6HdSyN H1/sVqwBPJE3+LtUVRsTNYPhdQgIRLKngJFXrZ+tdiqgvji3fZyDA+gMceJmjGMFT2E4ig4QLim06 Ft5F3e4IpIL0aI44YeYp6k07rJJsRN7v/y56S7u0clFel7OTvv48zEHPEcMib/84XknVguNmmjF25 dPS8TvlPjKqfD4d6V0QKC0hnCM2BbeBKgKFGorsJzWMv9aedepjckNaO7ySVcpM2S67RuNlVa9OPp bM4TkkrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syZwb-0000000A4m1-065F; Wed, 09 Oct 2024 16:53:49 +0000 Received: from mail-bn8nam11on2062d.outbound.protection.outlook.com ([2a01:111:f403:2414::62d] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syZiH-0000000A0ME-2MR9 for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2024 16:39:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pErKY2qc29AsYLV1/5U7gfi24qPQ/mt9K/FjX4vZxJ2rcA2qwoxKdbn64+MIeJi4jnGjKsDwLKxwOBYWzwyOTGsvf8yLgwMi61c+YZt5p3P9YBWJ1WUHWqNlD4o+jp4ZLKKRGx8nqv/2BgBVixMisVSENtwX0+Iw4E/tV0qsqbBzrMdzWOt8BSOIYEY/VAOXdM7CKhjXWcRnkAjJd96LUZOp4VpcEXJXXeXpup6QF3uD87J69hbQ5QwphIiv4hW8vuSPHhXWmTMkOZNP6Nz1gzid6ija4Dr//qvaUd7vTFqyphDNmGprMu4yKoFBHFJgtni+i7Q6bZ7iacfvHadmOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MRke0kQkqsrccmcWScj2DUzADwLkGpQ8YcQrRjbTI+A=; b=GHDkkU6ND7oY90s8bR0oK0HGMeGN9IzOzg/AYH9x9q9zHQVqpOtlp5x1vJ5Ce4i1ixzxEu63k4xE9iXqLh94t/sE2mf6w6SqLzu7CcWKKQqSRGFPFrTPvqa9XD6bpL0JdLcxaUe/M2tLDiRJ/kS4LKtPqPkwn+zD49NqbwS26buRzdbQrfjTbU59LePqE3Mn9PYm0nG1l1ywACVZqG+kskWObuFBJm9B0aqypeueCOY7NUNUlMntZd7qx93g8Usazsp28g6uhXuX8qoJEhKaqHucnUgBXpch+WaIxaxe6/9G6/DC0gqirFbS4dXw3ZeNzquOXeCUxMO3SGoDaPQhlw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MRke0kQkqsrccmcWScj2DUzADwLkGpQ8YcQrRjbTI+A=; b=JebU7lX+jcPKOXbbkxRJ8JCj9SbY3+ARsdXxa3QJJ4jdhkA0juDKFyM4vewdbz77X49FljqjGQvlX/+XS00LaIdbnLv6Z6wu5ur23xIMs3CAK359H5qXy4jMdmrg3yCjKpUzTuy8PguNqg5lz2ZfUy+Bba14uEDKRuGA2A6SLbHs+BEfLftHXTdGpGliyT1GPcFxazr8NEuGTp68BweU3NzNb5lW61pV6kG6vBe7HLlBZoDGVGgBb4/a7aDcm3FQ29v1bClxFoAJqnFwrXNROmcT9/W/pLgo5QGICfKvYxSdUp8QUKzI0yIrg6Gd5g93wGl0wl1+ej9bOPC2VzT+mg== Received: from SN6PR08CA0016.namprd08.prod.outlook.com (2603:10b6:805:66::29) by DS0PR12MB6629.namprd12.prod.outlook.com (2603:10b6:8:d3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 16:38:48 +0000 Received: from SA2PEPF00003F67.namprd04.prod.outlook.com (2603:10b6:805:66:cafe::e) by SN6PR08CA0016.outlook.office365.com (2603:10b6:805:66::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 16:38:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SA2PEPF00003F67.mail.protection.outlook.com (10.167.248.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 16:38:48 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 9 Oct 2024 09:38:41 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 9 Oct 2024 09:38:41 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 9 Oct 2024 09:38:40 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 01/11] iommufd: Move struct iommufd_object to public iommufd header Date: Wed, 9 Oct 2024 09:38:01 -0700 Message-ID: <9277a0c4058e49f821f8219d1ba4179b74aafbd9.1728491453.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F67:EE_|DS0PR12MB6629:EE_ X-MS-Office365-Filtering-Correlation-Id: a40144fe-3a43-4b22-60a5-08dce880d9b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: +OOB0H2igzsQhzQMigz7MTqjvqdMX+TpNPvQoSgl0GzP9Q7SzXt1btGYNXdlvIbczLACXp8LU8EXSbkGOODmUdkqgosQQP4abLoS4Ad+lCM2PABQntMUwmY8d770BDXHM4gOjVIsk21BftRiqZ94A67PLKjELBF3g1o0jAioTnuN1MPL3OvXlV+TxC41Z5BrY4lg6jzfl/y7Y4VXf106Gn5ogLlyiichGwg1tTa4H0rZJBDTPcguSpK+H9jQ35ugw0fFiADewzq7NqJ2jNDFRfHD3rErQsILsaOqUmIQHpkNy+JlorFN16BGUxWCRzMTrXOAibbSwgZVfCf5an+5jxP3kuqhKKLsCbk24cJYYFLKBWjOTLcR/ocg/sf5VoDlbd7qTQp9Yb9i2eii0QdZnuMza8n4mTLtdIPkLfnK6Bay1ywKxTvXuo10UGqr/CxxyLoCZljk8ffTMQEwPUDfzLpfIVvvEK5EukaSqOfr1/aYV35xX4j65P76um82jU3Qa31Dlwh6UjTmqgIkBea8gynxBpRVQn8ny+J+2NQH3628myUE9lSzb1BYmd3nS1W/GQVqu5/cNMLLWfpGJ/RWvnLmjIwi0c2ttIm0boi00kux40f1x75IKVJifqs2iqeLsmiAhFxwzw+HEUgXqlPECgDvLcsv4QVVgsh7gDx1H9UxDnBKRZdwiSvx5Yz0GRqzrbNVYM/lGMYNyfj31VhFhomwfQJ54ygzNZecs5jwe01+6UiAGTwgl4/tpOxrrd+fVSpM2UwzIejgjm4mIeZ4+2gW3Z0k5dV2yvdNf+RHbcbJZhk95uqcV4paaq1Ho3XfmlwKTKt0LAP5FhpKsNKKaNti6Wsf0uxD3f+rWJR10kRc4kN8JMfTrmr9FkDyWSBNdK6CxG0iDz/uElGPJNKLEJFPud4OTNtItdbU3+S5WadF1k9fMr6T+4szvsR+gka3I3b2nUnWdyNJNYGEi0twPUYL8uncJpzQKtClsNba2spsdr8clBXowGcxAyIzJaIHlu6YlKi3Eer1Pl26xH5EmPz/yPAD76aVNY08cS9IGJKsAElucBgeaJXaUY62yUnDkBIl5DoBr927lCuthPxgPuKAyV6v8PkvV3ct4Y1B5exTsKWKmYYwQ/ySZVHZrVyJ6uOggSaUUCCc1WnOZCMoCUEG8k12gFrgj49jYF1b+Bp++utJIxrchJXiKwbxrlOkjyT8UrLDfKXwtXbvAAJoakoMgAOJGVLoNhktPHmM3CUIilUiUnG+stflz+C7G3b7WEG50nmT4l9wmb9b3LUiQbuu68EuEjoPTgJmm4YlD4L2plxDdxhOKdKqJM786/VMKrBzM4wN/gL1IiBvygrnykapfxbdFuYcPUxJ/JJJTYprXeZpCcLMF7BLAU3iSLDl X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230040)(7416014)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 16:38:48.4871 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a40144fe-3a43-4b22-60a5-08dce880d9b8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F67.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6629 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_093901_738282_C045814D X-CRM114-Status: GOOD ( 12.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Prepare for an embedded structure design for driver-level iommufd_viommu objects: // include/linux/iommufd.h struct iommufd_viommu { struct iommufd_object obj; .... }; // Some IOMMU driver struct iommu_driver_viommu { struct iommufd_viommu core; .... }; It has to expose struct iommufd_object from core-level private header to the public iommufd header. Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 10 +--------- include/linux/iommufd.h | 9 +++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h index f1d865e6fab6..7221f81ae211 100644 --- a/drivers/iommu/iommufd/iommufd_private.h +++ b/drivers/iommu/iommufd/iommufd_private.h @@ -5,8 +5,8 @@ #define __IOMMUFD_PRIVATE_H #include +#include #include -#include #include #include #include @@ -137,14 +137,6 @@ enum iommufd_object_type { IOMMUFD_OBJ_MAX, }; -/* Base struct for all objects with a userspace ID handle. */ -struct iommufd_object { - refcount_t shortterm_users; - refcount_t users; - enum iommufd_object_type type; - unsigned int id; -}; - static inline bool iommufd_lock_obj(struct iommufd_object *obj) { if (!refcount_inc_not_zero(&obj->users)) diff --git a/include/linux/iommufd.h b/include/linux/iommufd.h index 30f832a60ccb..6b9d46981870 100644 --- a/include/linux/iommufd.h +++ b/include/linux/iommufd.h @@ -8,6 +8,7 @@ #include #include +#include #include struct device; @@ -18,6 +19,14 @@ struct iommufd_ctx; struct iommufd_device; struct page; +/* Base struct for all objects with a userspace ID handle. */ +struct iommufd_object { + refcount_t shortterm_users; + refcount_t users; + unsigned int type; /* enum iommufd_object_type in iommufd_private.h */ + unsigned int id; +}; + struct iommufd_device *iommufd_device_bind(struct iommufd_ctx *ictx, struct device *dev, u32 *id); void iommufd_device_unbind(struct iommufd_device *idev);