From patchwork Tue Oct 22 00:19:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 837694 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2082.outbound.protection.outlook.com [40.107.236.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E69A14A18; Tue, 22 Oct 2024 00:20:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729556422; cv=fail; b=SjAj4b4X45/thMag1EdJswHCQemTJNBm+Wnh6AomkxKWyYed/rGVoVH6u6KfC+spkexd/ZQEcdLQ8slc8L5BlLnofde9xb+I8uEko5X3B+SlI9WdXe/aaVgzZSoJ19URonFRAkEr7lRDXIGgolBTUrXNkHByXgAqNACjNNY13rs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729556422; c=relaxed/simple; bh=z67RZ/1Qpw88A5yOnrP4tXY2nkV9jbGx5ncLE0sIC2k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IDoMcKykz1oLvS7j4TBEMK5RNQC30eV6GLRJiKob7/FvrZ4s7b7lTO1wXDC5wIiX3DAaOEtLkj8h6QgrOSAXzjqVKT+xEzlkZIBc9QiUBMm78h8OhRyCkyV1MZbRyJC/xp4dXb7SdvuIfKLSuexpIZ7BNMDAGBVT9uIMNk5Apxk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=oD3jqmF7; arc=fail smtp.client-ip=40.107.236.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="oD3jqmF7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eqM1T5Q6oNtRMzu67sSxpp/iQrX3RHxaoHjGTtUl3UJRWYUdD9LUkKsfKY5Xs4NfQCMyo14rOQldyrJSOxqYF9rD7aVZi98vwJolSODiVOgEB6uLQOFCnfzekstW/SsOrzIZ84fLyhzwHFUQby0dScuuuqo00H1rr3LpYOzUAzvL2b+QNST9ypfk8Lnbj8l9/cubYtINpG7Xh1momGg9vvGTDEOulRTR3y0cy6BWBhipjoU89SVs7192ZihUxihlA30UnabJFbXnwmHfZY12j/9TKVRyq0p52rNqCq+Km1JawgBj0EjGt3JPUmFH5SkZSgdjYVSEKmC4NwwFejm48A== 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=4+EkijV/Aru8LUJiN5jaZmLE0ssCHKJJ2dO4w4rK4Is=; b=UtHzNosE/Cvv1z9flnkg8LvsR21eXm4g67MxSmNklkoFi5sfnnb8TXU4brzdGHvsAZ9s4Lipi5l2hXcEoyGeANxo77WUbxewbuXyyMrtCzd3w/nqyhkFKuhKWvRHapH05n03E6TNt7wmEsasu5VvvNjCG85Crwwv43OedVLpurUMXjkyFMtLgKxYDDKEG9UH8aJDpi/8lVapxsZ6NXNWIJ7wz7RT/l3bfqk1L21h9s2k1Vil1ekor9yJLbqqmTY6zc48K4nwztT5UYwQfmlCCFQM5oJHVui7wFMoxMXM3PiDXk1/exPALWGAyreoYxHs47rs162LkyYkNrPN3+NO8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=amd.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=4+EkijV/Aru8LUJiN5jaZmLE0ssCHKJJ2dO4w4rK4Is=; b=oD3jqmF7RDzoIi1QU4zNrdeiBrFYHxTFrHJHApsCzbmBfwKbMm7iu2HOPpWu0L51/UaMJBJDcGBqxrrmwLaLsc6+iMhZbL1YgPi0Q2lQa+oclB7OeUUAwre9re3gfGMrJPdhO6f3juuKsdPX9hw6rynnY6TE+T4JnIC2gu5zYQI2JzNgYalYyfDwDeO9smGLnsyut9Os7ZdKGLPVx5qk95qnP/aJ8uv/rXbP+ul7H3qefhP1Ta+aj72EK0DdVejE+GcDIiZQA3KAynUhnDdOPlIOUEsWxZgJW9o15j1jbpZhLj0tKmmbLsTEtzAS1gs0aiGmRyP+tN5jltsZiHO+qQ== Received: from BN0PR03CA0001.namprd03.prod.outlook.com (2603:10b6:408:e6::6) by MN2PR12MB4319.namprd12.prod.outlook.com (2603:10b6:208:1dc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 00:20:15 +0000 Received: from BL02EPF0001A106.namprd05.prod.outlook.com (2603:10b6:408:e6:cafe::40) by BN0PR03CA0001.outlook.office365.com (2603:10b6:408:e6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Tue, 22 Oct 2024 00:20:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL02EPF0001A106.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 00:20:14 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 21 Oct 2024 17:20:01 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 21 Oct 2024 17:20:01 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 21 Oct 2024 17:20:00 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 01/11] iommufd: Move struct iommufd_object to public iommufd header Date: Mon, 21 Oct 2024 17:19:23 -0700 Message-ID: <1452c535a2e6a6c61f38fa752132db7e88b55770.1729553811.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A106:EE_|MN2PR12MB4319:EE_ X-MS-Office365-Filtering-Correlation-Id: e59aa6a1-d663-4e67-de90-08dcf22f4d05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: hpIUxeYF5jwicsz0KhY1nomIP3+SlR/jn0VMNDYDOIOmxiGws2GGB8XEd+M+u6v4JMMzfvzCIKlc861mcesuGn52XBE0na9/ONQPG/vXG3XqNfT1VmY50yX2gR8GMUwmMtAPgEmLhl+Gg15t1D8huJLa2DznLobz7KUAvMs431gE9nTqch2abYaYUj+1McR7QROqRxPl5vtWic31yHMRhGSvMAtGf8pVx0gZh/ht5SoZQdgPs8TkUcSK+FNrvwjcUZ1h+D6UvPHFF6AjwNfVmfI3rbfGFRVZZ1EV6xe4hQndJ8P2To5M6CCLXCR6fO0OHbwTXKOrp7o/FbNOfTyQ6FwV+n3WrSPyOx+05nyexB+LD4zv8W9V6xoMYg2iMgCISJMBaFv2LxWLzlrc4J65CDyDJd195P/lLcJkbLD1YLvqwETwQqoIfeXSIsf8CSZxDcO/c5CiFE77FI0iQtgvEP7KLO5uG3XL3Y+XqxpMVEvQETngdA8SSm32AKqMWDXObzykQdoclli/KefHmEXWh4C1T6wlvvj//T8VusJh3rLM5thHDhKzezRBRFp4zv2Fd8ISDO/5J/9BbRL7+HEhlScTpO4XCszrVXZzapM7iuJ6A2tXBnB1Tn1FDOLAIPbsL09eMftHkS6e4GbtRAXdxZ2PcfML6S0IOF7Kh8M7K1Eyg6Pxv2uQty4ruwYlW0mQ+MANa8i0ov3YHTNvo3eyCvBbgBj5xkcqZkvDuuMW7W1a/3MhdcotnJ/J622DEdatHpspcEapyVCKw1XUUU0e/baD21pEoj+9IMZw0L6GvUsBWWMJKZI/nMQzNEZUHOrv3GWGCIiiyOoSsYUp4FQ+BUueTqnipNf96C4R52uAIXd0zUfVu4X2e8oews3lZWvc+aNkv5xr+iRQ1jNmsO/NlsJPQO38mlmlRCG8IEaRHVPg0irKgTSmH9ucjohA78gCiKzJMvI4YrXR2uP4sgXS9Ml5b9tvKI7EWCyoZuELl7I3qyIHa7Z0aVpZSCun3hd0zU88jmXqtRokD+ftirnQ9NRuyv8L8A4cJKmxoRm4W4gdumn/HbuXHVbsDIBreXG77W5tf6PjkCkwazwdzirm1c7BlwHxZWqYs9exnqKvrLXnOVsn3v7rSNmP3qNgEDt6GzZ+7dbmhdGQiKmLGB08KwicElT85niYfxwKXUX0uwIdht1asbKSkbAPHSAXfsaxXP2KngdNwmAKMFUCsPG9msk0IhRjBltS3TidDkLVu4CzlbTB3zra7kMp/r44jXFyJLfq7skAwhBPnQuq9E7MF9NEtmH3pYJmOWORUXe9ppYGC7EE0i55n+YmJzqh+8x6XXrDox9f69uOryU1+0IQn6mseTyk8UyjqosCfkjFkRvOOBekyD0p0zmrTLcFjju3ODE+UtYMYVpze4iKAbBhAw== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 00:20:14.7351 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e59aa6a1-d663-4e67-de90-08dcf22f4d05 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A106.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4319 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 and enum iommufd_object_type from the core-level private header to the public iommufd header. Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen Reviewed-by: Kevin Tian --- drivers/iommu/iommufd/iommufd_private.h | 25 +------------------------ include/linux/iommufd.h | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h index f1d865e6fab6..1bb8c0aaecd1 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 @@ -122,29 +122,6 @@ static inline int iommufd_ucmd_respond(struct iommufd_ucmd *ucmd, return 0; } -enum iommufd_object_type { - IOMMUFD_OBJ_NONE, - IOMMUFD_OBJ_ANY = IOMMUFD_OBJ_NONE, - IOMMUFD_OBJ_DEVICE, - IOMMUFD_OBJ_HWPT_PAGING, - IOMMUFD_OBJ_HWPT_NESTED, - IOMMUFD_OBJ_IOAS, - IOMMUFD_OBJ_ACCESS, - IOMMUFD_OBJ_FAULT, -#ifdef CONFIG_IOMMUFD_TEST - IOMMUFD_OBJ_SELFTEST, -#endif - 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..22948dd03d67 100644 --- a/include/linux/iommufd.h +++ b/include/linux/iommufd.h @@ -8,6 +8,7 @@ #include #include +#include #include struct device; @@ -18,6 +19,29 @@ struct iommufd_ctx; struct iommufd_device; struct page; +enum iommufd_object_type { + IOMMUFD_OBJ_NONE, + IOMMUFD_OBJ_ANY = IOMMUFD_OBJ_NONE, + IOMMUFD_OBJ_DEVICE, + IOMMUFD_OBJ_HWPT_PAGING, + IOMMUFD_OBJ_HWPT_NESTED, + IOMMUFD_OBJ_IOAS, + IOMMUFD_OBJ_ACCESS, + IOMMUFD_OBJ_FAULT, +#ifdef CONFIG_IOMMUFD_TEST + IOMMUFD_OBJ_SELFTEST, +#endif + 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; +}; + struct iommufd_device *iommufd_device_bind(struct iommufd_ctx *ictx, struct device *dev, u32 *id); void iommufd_device_unbind(struct iommufd_device *idev);