From patchwork Wed Aug 7 19:00:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 817533 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) (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 CEF901428F3; Wed, 7 Aug 2024 19:00:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723057246; cv=fail; b=YVbyxGb+2yJr5v7bHGMal3p1aJL0PFbBKDOHrZo+LANhg2pRayNG9CFooeazMr+a2AEE1qrkJFxlbRBHYOteJv0MvYtg9KvPS1ShRBSumJuLxN4gqbTE8MgnUc144zIy9PMYNmSiLgXlTnR1p6q3GgzExBokXfgqy/fItsBl19M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723057246; c=relaxed/simple; bh=fEKkrY7YwhXWlFDLVUhbUmi18zOaTxltmSUYMlU1Hxw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TtDPxDMw+AO4HQhrC8/bT+qOh9z4NIMyf/NhtD8EB3wCgNxfCSL9CDmJXh4PLI29V7IAhecu6WvDJx3KZ68BMBpNy/vxcn4rAAuCR7JwIOQ7vpZlIepBnt5DiSU6q/rgdij6YVnqmzZtnzEGi3YsoHTD7cDf0fdfTrpgTAWyWK8= 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=ans0Plp1; arc=fail smtp.client-ip=40.107.244.57 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="ans0Plp1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bsyq5XSdxJ5e5mm154x6czVb+gqxkkcOCw0Ug7YFhTVkWDZtbDixJKVhGiGLmvoXjtlnEq0FdZzzagKwCuMzuUqEp95WdUFqN2gkINYnII5XMI5TuMLdd6eVPkWuG0LX/1LgXRNapNJWBXtz9+d4rQxg2pJoRFxSgeJvCCJYMkiQggSypwupxfwTJz8M/ABu9o3BTIFNqk0+f6i0vEwHBJsyz/PQ0GfDmySVd7lW5w1mjfwsyqdyoXgT8PDBvq86Ul98J1JUsrc1NFkMiEDLSZfeoM55gY1uq1hjh3+MZyVUbfU9IflXMo4jI1PlJFW3/z2cz1fYLPVBQuD2Gf5cgQ== 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=BRSIeP47Q5fSho8mxyLN4SSHM3LnVn9nduewZx/YizI=; b=j6N60P2Vn82/PmgEVX5BV92AVrNJPoLLFqHfZ9t35T5N57xEbW0V9j0STf917O3xyMuC6XvPD5T7yBAjpatqu1iiEHGlgkHLU06GGF51hgRW9D46S2ZuVF2VovI2aIUiJ/ruc6kZHAobeqF79LXMXRjM1lWE4nPkn34xU76g9qYUPU8J814b1wd6CCEwVsAhmYkvrj0t1BlNE83U1eijaxPOsX2qg8XALtqjSbsDAvOcZyAOu8rb8tGdzGJ5TRqpY/sKdixvtZ9uTfgnUVzal7R9OA3BkFLVO8FlSGr3MIeJvCp7DCiMKQu9Iaot1uH3AJgy0kGRFmEAY66y9z8zbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=BRSIeP47Q5fSho8mxyLN4SSHM3LnVn9nduewZx/YizI=; b=ans0Plp1sDLemW87aS6ru5ZdwsMvcYUlwES23AAHIN3HXIF5HXt0wQyaI4exqA4D0jOOsHu/EG7akKUZfKs8al1R0MyUdQEe14ZN+TUVqLj8zSip1BXBaiDQkL3+DVBKn4IndiOqIjzzy/IjVheNqj89rbbQzJvWz5mFrBlDiPnuMSpaaJuuRndv2Ihe/04dN1T7Dvcni+65Qfc2mSBGVhU+pKMShSBx6zc3XglBF9qAb/VAY9OEREWElp5IPLSnL27cMunKqaPUA3fh+0eXbQ3VH8usExMCTzQLGsbzmpxbo8oBpkqAcB4++w7fzZn1uQacl7QtczzGo9WYiO09QA== Received: from SN7P222CA0016.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:124::16) by MN2PR12MB4094.namprd12.prod.outlook.com (2603:10b6:208:15f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.13; Wed, 7 Aug 2024 19:00:38 +0000 Received: from SA2PEPF00001509.namprd04.prod.outlook.com (2603:10b6:806:124::4) by SN7P222CA0016.outlook.office365.com (2603:10b6:806:124::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.23 via Frontend Transport; Wed, 7 Aug 2024 19:00:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00001509.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.19 via Frontend Transport; Wed, 7 Aug 2024 19:00:37 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 7 Aug 2024 12:00:20 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 7 Aug 2024 12:00:19 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 7 Aug 2024 12:00:18 -0700 From: Nicolin Chen To: , , CC: , , , , , Subject: [PATCH v3 1/4] iommufd: Reorder include files Date: Wed, 7 Aug 2024 12:00:04 -0700 Message-ID: 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: SA2PEPF00001509:EE_|MN2PR12MB4094:EE_ X-MS-Office365-Filtering-Correlation-Id: 46ef7adc-0140-46b3-7f74-08dcb7133998 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: n4qBaasPna6N00AGP5R9OaVpl02gRoTh8EfVQgL/KMn2l2vnNVR9IVa8X3fLJgr6sSo2okqEKcmBeWbtf51v94jgW9hUgyDkbZ1V//xN6KexNAX7oyXcNX/HhzAOY1xPwEnVlOUyyuihclHx0eq1xWlnkFKgm7X3BO8RXTeUXsfBGSxoelTiMXwm+lJ0fwzSNGu9Nw705mt0dvFgbAnULdGaLSM5AtDniDmf3sLrCOZf4IgSmVp49NHnUNgvnnn9VAS6h5AjnZn+seT3fguv8zw0ddt7lur+scvxmI9qwcpnYQNpV8Fs96Q9kUi9fUCdbNhUzRwLw3bgc7gOTD/27FZQT9rE4GWWNDydNP/ZG221DIbp/qKtnSB3ymOhxt/yDQwTs3Riwcz21SrgExkFUqA9sn3tVmB17FSai1JJi0pjsJEBBTst07Pa6qUzz9eZW8ISxnwZpPtZ2RGiqVuF4ICVdypGwrkwzZ2b7xiJxXmFOqf7I3qsAbduqYPAR0d4XmBpaxr4bUpfjW7xgvjwKGtuhwSkGV6KiayMT0V0z7P6yywsfWzxnSM9umSHian4ooPILt121FWM9Xr4pZMpnhkJg37vCIk6RV1q9dacEU71q7aUOzeezKTqMNrYBQym8lx9FwA0Np2BLjI3yVXeiIab+6564ppHvbrwE2cuhAVLNth2DJC6Mo0ajRnV6JW5WKL0DzKkvVkrwx/tJRVzXuDG1yZkvUYe3P1Ic+k/VfUPw2Erp6MdzMFXQNQ3+M8difczfYtaGQKIcVynY9QPlifDz8msQlBQYgo9cMFiF7A6N47Ae9uXlXeW2Ti2iO+FOPofdyUpdZglEF0Se9ghId9H6DT2ZScCdjoKLKOzkBNJAuT+jRkjEmnQJgbl+X1JZLbNxXWxasv7molk8d4aH49FSKhUES782H3U5KqBA9m+MBpnDZid+TQf8vyd96fGVyZ3ST9dz5kMKEhNUTryQf0Kioz3IYch9b7CFtbqh9jZoJuhWoOYIvJy0bfLG5S5wmaLmLfauLfWuXNn8BiuF5zAXN9grkPEu91yze3NCPAVLHM6BzY4q97UYiLfkjqYgZLxWdg3IwcJbL0OFeK7BDpmrFO8KUikiGjAh/QcJD5NJtb+yZUO5MzpmTCT1GwVwBcz5P9LwIBvU0ABZxWfnevq68LoLPPk7YwepT3GuzuMIPz2lBIuflhX6hHLKofKqepHxbKfTApY8POCe4h9skrROFLbZ8yqaCn4E55Mb0UyqKvUH8PMurvCcR+3fdxPW7R69UTLwPZ1Ch1MBwq73bhxNGEL+lLZzypqdKPDGNdKQFSGD3DojcvT/1XvaTGmhslbQM4JhbcHyqwL9/GjrxNX4D0FoEf4CFNFUCCoMCOw12awN4HSS70vcmcmOnFp/yT9qmn9cv7mc4N3x1y1nzsfiSaa8U8UTDz3aLZzFE8aRopk8gAh6RMmDuSRF2kt X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2024 19:00:37.6918 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46ef7adc-0140-46b3-7f74-08dcb7133998 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001509.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4094 Reorder include files to alphabetic order to simplify maintenance, and separate local headers and global headers with a blank line. No functional change intended. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/device.c | 4 ++-- drivers/iommu/iommufd/fault.c | 4 ++-- drivers/iommu/iommufd/io_pagetable.c | 8 ++++---- drivers/iommu/iommufd/io_pagetable.h | 2 +- drivers/iommu/iommufd/ioas.c | 2 +- drivers/iommu/iommufd/iommufd_private.h | 9 +++++---- drivers/iommu/iommufd/iommufd_test.h | 2 +- drivers/iommu/iommufd/iova_bitmap.c | 2 +- drivers/iommu/iommufd/main.c | 8 ++++---- drivers/iommu/iommufd/pages.c | 10 +++++----- drivers/iommu/iommufd/selftest.c | 8 ++++---- include/linux/iommufd.h | 4 ++-- include/uapi/linux/iommufd.h | 2 +- 13 files changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c index bcbcd6d94062..5fd3dd420290 100644 --- a/drivers/iommu/iommufd/device.c +++ b/drivers/iommu/iommufd/device.c @@ -1,12 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES */ +#include #include #include -#include #include -#include "../iommu-priv.h" +#include "../iommu-priv.h" #include "io_pagetable.h" #include "iommufd_private.h" diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c index a643d5c7c535..df03411c8728 100644 --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -3,14 +3,14 @@ */ #define pr_fmt(fmt) "iommufd: " fmt +#include #include #include +#include #include #include -#include #include #include -#include #include #include "../iommu-priv.h" diff --git a/drivers/iommu/iommufd/io_pagetable.c b/drivers/iommu/iommufd/io_pagetable.c index 05fd9d3abf1b..bbbc8a044bcf 100644 --- a/drivers/iommu/iommufd/io_pagetable.c +++ b/drivers/iommu/iommufd/io_pagetable.c @@ -8,17 +8,17 @@ * The datastructure uses the iopt_pages to optimize the storage of the PFNs * between the domains and xarray. */ +#include +#include +#include #include #include -#include #include -#include #include -#include #include -#include "io_pagetable.h" #include "double_span.h" +#include "io_pagetable.h" struct iopt_pages_list { struct iopt_pages *pages; diff --git a/drivers/iommu/iommufd/io_pagetable.h b/drivers/iommu/iommufd/io_pagetable.h index 0ec3509b7e33..c61d74471684 100644 --- a/drivers/iommu/iommufd/io_pagetable.h +++ b/drivers/iommu/iommufd/io_pagetable.h @@ -6,8 +6,8 @@ #define __IO_PAGETABLE_H #include -#include #include +#include #include #include "iommufd_private.h" diff --git a/drivers/iommu/iommufd/ioas.c b/drivers/iommu/iommufd/ioas.c index 742248276548..82428e44a837 100644 --- a/drivers/iommu/iommufd/ioas.c +++ b/drivers/iommu/iommufd/ioas.c @@ -3,8 +3,8 @@ * Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES */ #include -#include #include +#include #include #include "io_pagetable.h" diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h index 0bfacaf40c05..5d3768d77099 100644 --- a/drivers/iommu/iommufd/iommufd_private.h +++ b/drivers/iommu/iommufd/iommufd_private.h @@ -4,13 +4,14 @@ #ifndef __IOMMUFD_PRIVATE_H #define __IOMMUFD_PRIVATE_H -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include + #include "../iommu-priv.h" struct iommu_domain; diff --git a/drivers/iommu/iommufd/iommufd_test.h b/drivers/iommu/iommufd/iommufd_test.h index acbbba1c6671..f4bc23a92f9a 100644 --- a/drivers/iommu/iommufd/iommufd_test.h +++ b/drivers/iommu/iommufd/iommufd_test.h @@ -4,8 +4,8 @@ #ifndef _UAPI_IOMMUFD_TEST_H #define _UAPI_IOMMUFD_TEST_H -#include #include +#include enum { IOMMU_TEST_OP_ADD_RESERVED = 1, diff --git a/drivers/iommu/iommufd/iova_bitmap.c b/drivers/iommu/iommufd/iova_bitmap.c index b9e964b1ad5c..d90b9e253412 100644 --- a/drivers/iommu/iommufd/iova_bitmap.c +++ b/drivers/iommu/iommufd/iova_bitmap.c @@ -3,10 +3,10 @@ * Copyright (c) 2022, Oracle and/or its affiliates. * Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */ +#include #include #include #include -#include #define BITS_PER_PAGE (PAGE_SIZE * BITS_PER_BYTE) diff --git a/drivers/iommu/iommufd/main.c b/drivers/iommu/iommufd/main.c index 83bbd7c5d160..b5f5d27ee963 100644 --- a/drivers/iommu/iommufd/main.c +++ b/drivers/iommu/iommufd/main.c @@ -8,15 +8,15 @@ */ #define pr_fmt(fmt) "iommufd: " fmt +#include #include #include -#include -#include +#include #include +#include #include -#include +#include #include -#include #include "io_pagetable.h" #include "iommufd_private.h" diff --git a/drivers/iommu/iommufd/pages.c b/drivers/iommu/iommufd/pages.c index 117f644a0c5b..93d806c9c073 100644 --- a/drivers/iommu/iommufd/pages.c +++ b/drivers/iommu/iommufd/pages.c @@ -45,16 +45,16 @@ * last_iova + 1 can overflow. An iopt_pages index will always be much less than * ULONG_MAX so last_index + 1 cannot overflow. */ +#include +#include +#include +#include #include #include -#include #include -#include -#include -#include -#include "io_pagetable.h" #include "double_span.h" +#include "io_pagetable.h" #ifndef CONFIG_IOMMUFD_TEST #define TEMP_MEMORY_LIMIT 65536 diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c index f95e32e29133..b60687f57bef 100644 --- a/drivers/iommu/iommufd/selftest.c +++ b/drivers/iommu/iommufd/selftest.c @@ -3,13 +3,13 @@ * * Kernel side components to support tools/testing/selftests/iommu */ -#include -#include -#include -#include #include #include +#include +#include #include +#include +#include #include #include "../iommu-priv.h" diff --git a/include/linux/iommufd.h b/include/linux/iommufd.h index ffc3a949f837..c2f2f6b9148e 100644 --- a/include/linux/iommufd.h +++ b/include/linux/iommufd.h @@ -6,9 +6,9 @@ #ifndef __LINUX_IOMMUFD_H #define __LINUX_IOMMUFD_H -#include -#include #include +#include +#include struct device; struct iommufd_device; diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index f2d1677ddec4..d42e0471156f 100644 --- a/include/uapi/linux/iommufd.h +++ b/include/uapi/linux/iommufd.h @@ -4,8 +4,8 @@ #ifndef _UAPI_IOMMUFD_H #define _UAPI_IOMMUFD_H -#include #include +#include #define IOMMUFD_TYPE (';') From patchwork Wed Aug 7 19:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 817839 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2046.outbound.protection.outlook.com [40.107.94.46]) (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 34DFF13FD69; Wed, 7 Aug 2024 19:00:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723057245; cv=fail; b=FPTSCEToLnqRIHtS9NisOvsdFQ3IizaCoR1lLOVC/nHc6fRh+ifVnyNzRC1bob6qBPmEqYTMAPjj074cguH+Ra38XpfKSv0AxZ8TxryDSwB3FXVWphW+vNsllRdnl+aH0sFEdrU2zpJlqxdXhhuFuaZT3kATkjkyhq8ZzEUoGH8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723057245; c=relaxed/simple; bh=1sW2DrqZEyek8n7fqPqwOatGzWYXGELID7WbIQYjARQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EB7XtBK8NlCZAe9dAES7VbcZ9/R9WIEWf6KEVATeXxbwz6M43rhWOQJh1qcBja5qIeN00HTih6NGbMtlq5mKvF7nqVzDxR2jyjdBWLNfevpiLyP5VnUYAvCP5FilU0urgfb5nQkfQX1JUPemxreIRTDnbTMnqR5gb5g+0DVJnv4= 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=dLzXK+3O; arc=fail smtp.client-ip=40.107.94.46 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="dLzXK+3O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bs736gIAS3i6p0VGUWbst6X4UmXyUAjbHoMBgcgC32bcuOqsABRYq9w1rfMiqKBk4FMsBA3sg+ji6V1xFNw6QKYFdwyFWIOWH4hj54SUJUPMpOM3/PCPO0NSZh/vapIgOmWZ/rY4m8lYB9nNieraNNE+VMW9u+yUxaNPSaJhULaWUwfK9fJVns4NW5t2Jlf1iHtDxaKbMsWMkIwVupVNajON0YGTYKnUzOKQegas2QU2k6p32NJq9l0TT3dP1/6+3IbA4LE6QVfXQ9ypLeM5IPeTd5CcKVGYTBAqYipqlBx9yKfd+ChRcrkx6Aa3AsO6TE5YqeU76neBCEfaFO7jDw== 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=Hj4m0tX1xLyV1bTSGYsOSOIOM0VT2LUs7Ewe7ekAIj0=; b=HDdlMBer67Uhkael0rpF1luUVMKgXNMDmvBtwKIFeo22wwBkih3ohcSDseP3feyFfSbYIZkolaozimCZwFCW+Ttu6NPgJr0sIdsBnsqRKP/WCJ2daGiHmsVFkRHxZ6j6BiLl6N8IoFd/7Kt6SeJqewcfwbh8QAc1S+XI4gFqB42iJXBoSH0Q/84iXA/CjXyDlM4TZ1vPTw9+0fBZHZB+ISz8gr3YYsGG/0O/k13gjLQ7DVVx5OipdVf7jZon/A4sqWAJQgxm4z1A0PGJux2tYFmlOg4VfyyIWm5I5Wc86kLz3qHTa1ypGqWt7rtOcocslumpLaXEAIbO6Ml5c9idUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=Hj4m0tX1xLyV1bTSGYsOSOIOM0VT2LUs7Ewe7ekAIj0=; b=dLzXK+3OjxqsJ1G+3yyk6FxCEgwc7NMyN7H8jZMqvkgD0268Z/IfU8wOUoR7d09Ux8rgy9EM6F/uKyJMpOMykzsQAfI31WvOMsr0aRqqx8ziSLoyqmC8z3QYJatUzHzKBU85pzPzX1lTLa28A0PV2Kcr9C1lZTsTdd8fwaZfJV3+DxzHGGgVc+qVoFeQsAjyZ9RDOy3trGxaRTIEuCIVYJOe8J1fs5sJqIwPKhDVItUaBrLbu5t9DH4qrFhiHHehieyXMW3hSvhuMt43qdXZyEw6RDCzULECi1HYzF79OoFokxSzsYap6wrKa/xox9Bd23YeEmv8W0YEDPdRSpHG4A== Received: from MW4P222CA0030.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::35) by CH3PR12MB8306.namprd12.prod.outlook.com (2603:10b6:610:12c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Wed, 7 Aug 2024 19:00:39 +0000 Received: from SJ1PEPF00001CE0.namprd05.prod.outlook.com (2603:10b6:303:114:cafe::aa) by MW4P222CA0030.outlook.office365.com (2603:10b6:303:114::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27 via Frontend Transport; Wed, 7 Aug 2024 19:00:39 +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 SJ1PEPF00001CE0.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Wed, 7 Aug 2024 19:00:39 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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; Wed, 7 Aug 2024 12:00:21 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 7 Aug 2024 12:00:20 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 7 Aug 2024 12:00:19 -0700 From: Nicolin Chen To: , , CC: , , , , , Subject: [PATCH v3 2/4] iommu/dma: Support MSIs through nested domains Date: Wed, 7 Aug 2024 12:00:05 -0700 Message-ID: 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: SJ1PEPF00001CE0:EE_|CH3PR12MB8306:EE_ X-MS-Office365-Filtering-Correlation-Id: e9349ec6-1396-48ea-69dc-08dcb7133a68 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: eWivJcjjzqjmdN2BhNKT7xdKOKrZcLS8UDM3dduUOU2gc4PBheNWSAJUavuFAdz/l/JTVtg8vehbJfooawNMKXkVynwWnd1zkuqdt5OYiaghKZifopmAPBp0mpEavj8xlklHV6wIOJ9AkEF/ccgO0F4Qt8zFYKb6juQp6lA7kxABwyKXaKrlYTecb8pP2ULJwygdZs752DQRiUgjofhHXdUZjPBMmzrxJR/SX84XM+ip8KPOb7etUeWm0AiYq27lMlbhJf1MylpMUfInLTvKe90rGTwm/bPmGtY9QGqPHOcRmjRVnQWNHG6tcMcUskYW0wyIZBXwgVC7D12hWDTsmq/MrKdL5zkK7PIIUOrPdiIe1lgcUXHz/555ElzbLirS1qyYTDoy4aJsYDOJ0cQ97HriV4MtMerCuprLLVAZw9SlVndGTxjRkrc4OsstDghoaNefb8icJMWbeai73jWTK6hqdNm5N1/3vF66fNvh1fj2Ng8m+OkKr13HF7xP1xH5VO5qvFc6SjEtvcdDs9yJVu9JdKD5iILLRjErWG1wCkggqacYUixtIhxmDRIvyJlBVF0B3f2K2kl1xPIpdWiY+kj/O8rNvC+hl1LWrj7KMrw0HJujjdTWYRPCZLPFE4uD8iIDaToxvMJzB/NMLprPez1U322RaJFlZt3TzPbFMJlJDITgrXzGpnX+kNSuknU9K2Hh37C/g5/YzeXTcTowGf5RV0Uffx8V09dC6+h/PJQzbbEctHfkRZFF28zgWKwMzPovjhv/b1VOju4OHffMSK+17HWujO8n4IGJd1piXE7A/lDRgH/bugGNCRwlxIqcYUhV/92BwC6OwuH8wl7wAEI8kSuOvwJNIZi9tYDKV+XwToGhMRZwkYzYN4OqgNQ/yBgZMGfsygBH1X9svcgdFclp+tGyyc3U1aS5wDyZrCTEX96m4ubgp3ukFP/MwfIex9HhfIPi9lZzpqxwY2+9EWd4f9m5Zj0x7s2/iXN0dG4zJmFHKeSbpUmKvJMUt8fvUrygYNGKreRt0JHCOZ6sIyGZcdHOI7T1TaDSYS0QompC0UKWUrAQBS+IOKXViR9SbxrJnshK0tKB7fnTMXVMLBMvlxMqZ+Mnsq3XFHyz3EL1GxxMJdYe5A6Jk+U2ex1vtoilDtpC9QtvdmfGQHN8KgFjHwYuxB8uGlOYfhcVLWLzGvUVRNIY6M9UKtMGblX0mdnkFamPIhod8d+OMbJCFoH+YKj7OztnVX7S6eDLU70mfsVh9hs/1l8nRZ+sdKecJu1wydVebzpLT1ob3GrTbucB15Cc4VB18YgKiFBNLacxr9qT5KULe6qi3jG35tciG2Ki1IzU6uYq5923De9HDXrZGgNi/RanXrS2Y+nS01Ae2RsPX+VGvu/INfv6E8dMXkFvp9m6LqQcRTf+v/ZopNxE9AyHEwTYwdFpoq82WuYGL7+xcbNpWEXBakCDf3q+ 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)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2024 19:00:39.1482 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e9349ec6-1396-48ea-69dc-08dcb7133a68 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: SJ1PEPF00001CE0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8306 From: Robin Murphy Currently, iommu-dma is the only place outside of IOMMUFD and drivers which might need to be aware of the stage 2 domain encapsulated within a nested domain. This would be still the RMR solution where we're using host-managed MSIs with an identity mapping at stage 1, where it is the underlying stage 2 domain which owns an MSI cookie and holds the corresponding dynamic mappings. Hook up the new op to resolve what we need from a nested domain. Signed-off-by: Robin Murphy Signed-off-by: Nicolin Chen --- drivers/iommu/dma-iommu.c | 18 ++++++++++++++++-- include/linux/iommu.h | 4 ++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 7b1dfa0665df..5b21be04e04a 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1799,6 +1799,20 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, return NULL; } +/* + * Nested domains may not have an MSI cookie or accept mappings, but they may + * be related to a domain which does, so we let them tell us what they need. + */ +static struct iommu_domain *iommu_dma_get_msi_mapping_domain(struct device *dev) +{ + struct iommu_domain *domain = iommu_get_domain_for_dev(dev); + + if (domain && domain->type == IOMMU_DOMAIN_NESTED && + domain->ops && domain->ops->get_msi_mapping_domain) + domain = domain->ops->get_msi_mapping_domain(domain); + return domain; +} + /** * iommu_dma_prepare_msi() - Map the MSI page in the IOMMU domain * @desc: MSI descriptor, will store the MSI page @@ -1809,7 +1823,7 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr) { struct device *dev = msi_desc_to_dev(desc); - struct iommu_domain *domain = iommu_get_domain_for_dev(dev); + struct iommu_domain *domain = iommu_dma_get_msi_mapping_domain(dev); struct iommu_dma_msi_page *msi_page; static DEFINE_MUTEX(msi_prepare_lock); /* see below */ @@ -1842,7 +1856,7 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr) void iommu_dma_compose_msi_msg(struct msi_desc *desc, struct msi_msg *msg) { struct device *dev = msi_desc_to_dev(desc); - const struct iommu_domain *domain = iommu_get_domain_for_dev(dev); + const struct iommu_domain *domain = iommu_dma_get_msi_mapping_domain(dev); const struct iommu_dma_msi_page *msi_page; msi_page = msi_desc_get_iommu_cookie(desc); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index b0323290cb6c..20a40fd6c4ba 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -684,6 +684,8 @@ struct iommu_ops { * specific mechanisms. * @set_pgtable_quirks: Set io page table quirks (IO_PGTABLE_QUIRK_*) * @free: Release the domain after use. + * @get_msi_mapping_domain: Return the related iommu_domain that should hold the + * MSI cookie and accept mapping(s). */ struct iommu_domain_ops { int (*attach_dev)(struct iommu_domain *domain, struct device *dev); @@ -713,6 +715,8 @@ struct iommu_domain_ops { unsigned long quirks); void (*free)(struct iommu_domain *domain); + struct iommu_domain * + (*get_msi_mapping_domain)(struct iommu_domain *domain); }; /** From patchwork Wed Aug 7 19:00:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 817838 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2051.outbound.protection.outlook.com [40.107.220.51]) (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 44215144D39; Wed, 7 Aug 2024 19:00:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723057252; cv=fail; b=e5mau/NYACLfb3MG2hHwelSJ3bGSv7EzSXERaMB+DxA/MOJckLUP4hp5FXZLEK/c7hUmtfv9AUNFqs883nvvvd8qYqIMjSEIC6r/IzHizCejH3RltjwkWMbLIAhwtgDWtgLo19kt6/0W/kwMlYtGxtnNO7GvFo+l15GogBpbytM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723057252; c=relaxed/simple; bh=22uuRlL9u8a7NekSfq8s4Hfwd/xI383yVclJxY10xLc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V+IOEHBSMyoslx3HpLwIyXpn9GToArn98rB1bR/l8w5S2jaGKz4oUJSOaEC5wMvg/u9KWnyPWs21p47B2+gIyLD7I44wlQRwDtYQop/gvlMHccvVp1uxX67G9jNQIjxnxtjiJ2bCoD7ou7+dqynAjB/oVeuQGoDQT84Dvz6Djik= 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=Y6TOY7jl; arc=fail smtp.client-ip=40.107.220.51 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="Y6TOY7jl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P9vWwsPzvcy3tYBlgWXoXPvtemUSRp8V3M6ujn/CKSzaX05NHNkoBO7mZKkGxS07uKuINr2kF5dQtPGQgzrMWArZpDP7JljYN6suN9fJzvaLN0nbVqIldKUHqR3e02/So7hTMPMqyV+eM7ao+GuP5CgTemFEquaCQhrfrrHQMNhls+OsFycX99/BIfSzxdl0EVIV4Gz9E+HS1IqGFWt+wKVx8cqcR9RkrwAXsyuTWoMBFRGRCmVlvECHzElAoDECNKsHlqyQBqMEKSAMMc5x5RTZkY7bPoktYI2KRhZxGcc5wW3sHLQuUstmOPwlyi3UY8TWwPxnr1PjmlbFBsVInw== 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=2sTOXZIMz1kQhRzXFPc88kMeugXEKpUnl8VdJXc+EDI=; b=BpgewvHn6PqlLeIZT1HFn/k5HPhATeGBWkEZ71RoTr+FppxcK2SoFNCXK9gvYWHHApr65TfwSiTYNjG9A3HeM7UwtdjgMklCMgE8BNMVFJJFY40euZydXx4h+X0U2tBuDR1VhpvTP8CfTTL5KUOesVCvu6uQVyjO1dK/1QQij4OL8K+bIPrxXY0l+4idaCz1cS7ICM5KzzIyW17uMW4Tbgzdq/nzln/bQtdLSMy6eXZSaVFG8GnFz8yQqOfe242gLlixpVg4lTVB/eHx1pkkYkBy3kMmc93Q+zDaEGzrCg0AA5weDNntMHHo0T+aqhOcn4Ho7wXm/PHOtZHHT/ZB9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=2sTOXZIMz1kQhRzXFPc88kMeugXEKpUnl8VdJXc+EDI=; b=Y6TOY7jlzaXgsJZGNaPEbUAeF7f41awpxo2wMdd51DIEdKHEXu8tv5o8vaP4rT8nGdvnNr9PsNfAwMozfqK+YQpXAXYJBj2CdxRRROeXW1EzyRCbB9CHTAdxZpmhpKycsuY8QmqPzF+z6434Ez9iCcCA9ezIt4VprZnCZ6KOkLRWeocupJwfVC/vdcv6qaQxpVP+SV/OwaQWCoSenV24VymCuot+MXAh6rve3vqvzC9AIIQxSNCCeixijNiGUkTSbP1zSkbNLsbVA6JhW7nxKVmeAeKEcCFRBe3vbV2O/+iwINX12S4KDNo38mddkJan8Vl68j3QctKyolFoHWXXIA== Received: from SA1P222CA0097.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:35e::24) by PH8PR12MB7445.namprd12.prod.outlook.com (2603:10b6:510:217::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Wed, 7 Aug 2024 19:00:42 +0000 Received: from SA2PEPF0000150A.namprd04.prod.outlook.com (2603:10b6:806:35e:cafe::9e) by SA1P222CA0097.outlook.office365.com (2603:10b6:806:35e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.23 via Frontend Transport; Wed, 7 Aug 2024 19:00:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF0000150A.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Wed, 7 Aug 2024 19:00:42 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 7 Aug 2024 12:00:22 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 7 Aug 2024 12:00:21 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 7 Aug 2024 12:00:21 -0700 From: Nicolin Chen To: , , CC: , , , , , Subject: [PATCH v3 3/4] iommufd/selftest: Add coverage for IOMMU_RESV_SW_MSI Date: Wed, 7 Aug 2024 12:00:06 -0700 Message-ID: <090f0d98be7a023448e34a6eaf499ec50f4680d1.1723056910.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: SA2PEPF0000150A:EE_|PH8PR12MB7445:EE_ X-MS-Office365-Filtering-Correlation-Id: 37637d37-c0da-4594-2b57-08dcb7133c84 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: 4YCMs/oC+SD8fGP42Jo8t9tAR998zvJn45w+914TiM6kZM/gAo5EdIrP/4D9qmYqYIvsbiAiWzt9g/5kZE9Fg2Msef+/vDUDqI2P25il0F8u7995DBLy9qjPv2Mn5ieq1S/c4/IuWCXFk0Vx7NfEl1mBbiOJrGYaUeJ3Z4PBGxCCaetgSOAvLToJRftn7TD2y8IyXm6EMKRogttXni1pqBRqvH7iVKPlU9I/cP1TUaVgqbR8+M+Xq0zvezIQYAsyGGhF0uM5hdo/SHBBhwcTizn+twqQ5cmPU6WQB9aVzScC6DdJGzEoZbvXfqfEGgZwv67CGpEzp/JPGEa5tuNyHNgdfABXIfddqo884DsT6ve4nyKiPXrrMUEPzlrVZRI8wklYoYabbjYqqi9ZlvoBZDWN9hEwsv/u2AlopHBob3flOT8FN/oB/sDZlD45FWzp8JHCUN179SwMixMhq/Cwp3iXxrTug02qSqaNlWFx4KESGeY9oHD37K5KTUBHhBCq81OgKGiTXHG0uSnypPzB1c4tKTIKSaGi/1ryDQG0wXaCOZBqxEEkr2gj/2AUuVWeu/+prpl6RTcaLgdZ3bPil+R4sKsKm03GuxuVlYv7EeAulSNhaeUCosvzQP+pljfLaXnCtaNv8OnTb0UsD8D4P2ixUfJNxejhq6f0EKZ/OHQ4M9inls0Ub4JtzpgdFN7shvgGTkItoNClBfRMDWEdWA0gdAX3gCY4gL09746uGnOACwyw2MMl3Aw4R4L9Hgm4zd56/NZqjK/wgXck1jp2VNbvqnTJnWj7vyaCub3pPiZ1AjgrOfBhAMuY+r0HHDe1iJy6Yfh6qaxta24Hs1KAMAK9xmnYSeUixVxlHzz3IAel84Kqe5TsZgZh9un4A9HQe/NinfNqLuPu81e3G/lIfxiC47N7WC/RePjt5UDusucl6yH4UUQ3WJ9hqOMRIkJnheJLhOhVNw2hJsK9g46NK72waF1eHw6jQ/xDky/04wU1tHM9zv5kWk8QBhbNOjqx2nKsbGpt8uMERmlVO8/p27xMsPpc8fc3YyBRmJB8uPYv8YLlgYMpSx1gVUQr+qKi0oD7PvFxkIgOZih8MWHe5JoXg9pUY6z7oUobwN3iDcLK9fQuMaw2y3V5K67H/GiOgxI+ug4wI6vhZRf/OOuBPoHczgxp2/gEISJ0nh2BvRaW1cqFEvaFPS/QAtsEO9uP8J/Oc27xiQRj8JRm6DwVdHJlSAlIZ4yN2Ukn19OkwALdSJXjFUbhrxdv3uOH8imx5Fs4TqPnnApuKB13kI2tnYPTd2xkgbjyfRUu16YU29DHcAwFHdE77s5VndYgWa8FHHahNJXzfgVKt/n3eGSlXhy916odUWEfJKBvCJHGWU2zCbAHYIqb20TkciRsViRDsnNGIVKp905J9dQaoz1Pk05lnEj08/Wys0CuMFON5SYCVk8FMPTaeMIDuJxzQgPB X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2024 19:00:42.6074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37637d37-c0da-4594-2b57-08dcb7133c84 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7445 Define an IOMMU_RESV_SW_MSI region (within the mock aperture) as the ARM SMMU drivers do. Implement the get_msi_mapping_domain nested domain op to allow dma-iommu to find the correct paging domain. Add a new IOMMU_TEST_OP_MD_CHECK_SW_MSI to loopback test the MSI mapping using public dma-iommu and iommu helpers. Note that iommu_fwspec_init is a must for iommu_dma_get_resv_regions(). Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 4 + drivers/iommu/iommufd/selftest.c | 84 +++++++++++++++++++ tools/testing/selftests/iommu/iommufd_utils.h | 9 ++ 3 files changed, 97 insertions(+) diff --git a/drivers/iommu/iommufd/iommufd_test.h b/drivers/iommu/iommufd/iommufd_test.h index f4bc23a92f9a..0bb30275a92f 100644 --- a/drivers/iommu/iommufd/iommufd_test.h +++ b/drivers/iommu/iommufd/iommufd_test.h @@ -23,6 +23,7 @@ enum { IOMMU_TEST_OP_DIRTY, IOMMU_TEST_OP_MD_CHECK_IOTLB, IOMMU_TEST_OP_TRIGGER_IOPF, + IOMMU_TEST_OP_MD_CHECK_SW_MSI, }; enum { @@ -135,6 +136,9 @@ struct iommu_test_cmd { __u32 perm; __u64 addr; } trigger_iopf; + struct { + __u32 stdev_id; + } check_sw_msi; }; __u32 last; }; diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c index b60687f57bef..642ae135ada9 100644 --- a/drivers/iommu/iommufd/selftest.c +++ b/drivers/iommu/iommufd/selftest.c @@ -7,11 +7,13 @@ #include #include #include +#include #include #include #include #include +#include "../dma-iommu.h" #include "../iommu-priv.h" #include "io_pagetable.h" #include "iommufd_private.h" @@ -539,6 +541,24 @@ static int mock_dev_disable_feat(struct device *dev, enum iommu_dev_features fea return 0; } +#define MSI_IOVA_BASE 0x80000000 +#define MSI_IOVA_LENGTH 0x100000 + +static void mock_dev_get_resv_regions(struct device *dev, + struct list_head *head) +{ + int prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO; + struct iommu_resv_region *region; + + region = iommu_alloc_resv_region(MSI_IOVA_BASE, MSI_IOVA_LENGTH, + prot, IOMMU_RESV_SW_MSI, GFP_KERNEL); + if (!region) + return; + + list_add_tail(®ion->list, head); + iommu_dma_get_resv_regions(dev, head); +} + static const struct iommu_ops mock_ops = { /* * IOMMU_DOMAIN_BLOCKED cannot be returned from def_domain_type() @@ -557,6 +577,7 @@ static const struct iommu_ops mock_ops = { .page_response = mock_domain_page_response, .dev_enable_feat = mock_dev_enable_feat, .dev_disable_feat = mock_dev_disable_feat, + .get_resv_regions = mock_dev_get_resv_regions, .user_pasid_table = true, .default_domain_ops = &(struct iommu_domain_ops){ @@ -625,10 +646,20 @@ mock_domain_cache_invalidate_user(struct iommu_domain *domain, return rc; } +static struct iommu_domain * +mock_domain_get_msi_mapping_domain(struct iommu_domain *domain) +{ + struct mock_iommu_domain_nested *mock_nested = + container_of(domain, struct mock_iommu_domain_nested, domain); + + return &mock_nested->parent->domain; +} + static struct iommu_domain_ops domain_nested_ops = { .free = mock_domain_free_nested, .attach_dev = mock_domain_nop_attach, .cache_invalidate_user = mock_domain_cache_invalidate_user, + .get_msi_mapping_domain = mock_domain_get_msi_mapping_domain, }; static inline struct iommufd_hw_pagetable * @@ -701,6 +732,7 @@ static struct mock_dev *mock_dev_create(unsigned long dev_flags) return ERR_PTR(-ENOMEM); device_initialize(&mdev->dev); + iommu_fwspec_init(&mdev->dev, NULL); mdev->flags = dev_flags; mdev->dev.release = mock_dev_release; mdev->dev.bus = &iommufd_mock_bus_type.bus; @@ -960,6 +992,55 @@ static int iommufd_test_md_check_iotlb(struct iommufd_ucmd *ucmd, return rc; } +#define MOCK_MSI_PAGE 0xbeef0000 +static int iommufd_test_md_check_sw_msi(struct iommufd_ucmd *ucmd, + u32 mockpt_id, u32 device_id) +{ + struct mock_iommu_domain_nested *mock_nested; + struct iommufd_hw_pagetable *hwpt; + struct iommufd_object *dev_obj; + struct mock_iommu_domain *mock; + struct selftest_obj *sobj; + struct msi_desc desc = {}; + int rc = 0; + + hwpt = get_md_pagetable(ucmd, mockpt_id, &mock); + if (IS_ERR(hwpt)) { + /* Try nested domain */ + hwpt = get_md_pagetable_nested(ucmd, mockpt_id, &mock_nested); + if (IS_ERR(hwpt)) + return PTR_ERR(hwpt); + mock = mock_nested->parent; + } + + dev_obj = + iommufd_get_object(ucmd->ictx, device_id, IOMMUFD_OBJ_SELFTEST); + if (IS_ERR(dev_obj)) { + rc = PTR_ERR(dev_obj); + goto out_put_hwpt; + } + + sobj = container_of(dev_obj, struct selftest_obj, obj); + if (sobj->type != TYPE_IDEV) { + rc = -EINVAL; + goto out_dev_obj; + } + + desc.dev = sobj->idev.idev->dev; + rc = iommu_dma_prepare_msi(&desc, MOCK_MSI_PAGE); + if (rc) + goto out_dev_obj; + + if (iommu_iova_to_phys(&mock->domain, MSI_IOVA_BASE) != MOCK_MSI_PAGE) + rc = -EINVAL; + +out_dev_obj: + iommufd_put_object(ucmd->ictx, dev_obj); +out_put_hwpt: + iommufd_put_object(ucmd->ictx, &hwpt->obj); + return rc; +} + struct selftest_access { struct iommufd_access *access; struct file *file; @@ -1470,6 +1551,9 @@ int iommufd_test(struct iommufd_ucmd *ucmd) return iommufd_test_md_check_iotlb(ucmd, cmd->id, cmd->check_iotlb.id, cmd->check_iotlb.iotlb); + case IOMMU_TEST_OP_MD_CHECK_SW_MSI: + return iommufd_test_md_check_sw_msi(ucmd, cmd->id, + cmd->check_sw_msi.stdev_id); case IOMMU_TEST_OP_CREATE_ACCESS: return iommufd_test_create_access(ucmd, cmd->id, cmd->create_access.flags); diff --git a/tools/testing/selftests/iommu/iommufd_utils.h b/tools/testing/selftests/iommu/iommufd_utils.h index 40f6f14ce136..bc4556a48d82 100644 --- a/tools/testing/selftests/iommu/iommufd_utils.h +++ b/tools/testing/selftests/iommu/iommufd_utils.h @@ -130,6 +130,13 @@ static int _test_cmd_mock_domain_flags(int fd, unsigned int ioas_id, static int _test_cmd_mock_domain_replace(int fd, __u32 stdev_id, __u32 pt_id, __u32 *hwpt_id) { + struct iommu_test_cmd sw_msi = { + .size = sizeof(sw_msi), + .op = IOMMU_TEST_OP_MD_CHECK_SW_MSI, + .check_sw_msi = { + .stdev_id = stdev_id, + }, + }; struct iommu_test_cmd cmd = { .size = sizeof(cmd), .op = IOMMU_TEST_OP_MOCK_DOMAIN_REPLACE, @@ -145,6 +152,8 @@ static int _test_cmd_mock_domain_replace(int fd, __u32 stdev_id, __u32 pt_id, return ret; if (hwpt_id) *hwpt_id = cmd.mock_domain_replace.pt_id; + sw_msi.id = cmd.mock_domain_replace.pt_id; + assert(ioctl(fd, IOMMU_TEST_CMD, &sw_msi) == 0); return 0; } From patchwork Wed Aug 7 19:00:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 817532 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2079.outbound.protection.outlook.com [40.107.220.79]) (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 E72CB145335; Wed, 7 Aug 2024 19:00:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723057252; cv=fail; b=oGq55/rkUXkxgrqA04EHAkpIMvIHLFmPA3IHrXdN+v9sjqYbdkWpGu9hjgtyIef/5rd3w31qAYuOxuLyxPjid+KczAY14KzamksqtrQct1cgbCWo2KT54/MSq7X3mp+S4XoU+NIAl7zkTB1OUCEtKr/AT020NkjJfQIN6fnclg0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723057252; c=relaxed/simple; bh=mOdlJH3zgODyGNLRyFziMxAWxK9msYElR4bNshC3wIA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fg4i3YAeiGaaIENA8ULLyBeaYoTAo4fWmsRdYWeCROoSBaSO8FplYGTc7RqnBxBYodGpK5UYO8GHPB4ADEyhb8A7zZkxjpJhqY6fmfXWPQ/RIP94HngN/nmkhHGJJr9sbpsAI40aGjhYxp/dwdMjGL81QSZ933uLCUOeW9uepkU= 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=o6q22eMd; arc=fail smtp.client-ip=40.107.220.79 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="o6q22eMd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UCK95E79lx7j1WotSX+8AYiOaJVv/ENPsrWWod99R0W627hMhVua5hKqpn9T6VTrD4TwAW1kjq7i3twY9l/lgOmk13qvBrABeECtqzVmLK8ajOhEHo0MsRB2TbFKztVZhIxaBVB0orhDVC9zPPE/gmZnoEON/8hf0IZTm6BG6PsmEtDCCXeFrIsrkFNt8O9OhXHZvVkolkxezLmHfHXQZOMcjIEaqG1VYDQm6qGkVUqQ8yQlD6MrtNejo7T2DwP/ByGasZ7Uy4RjNdpP5AxnImN/38TB4M5KE2nQY6MMG7DySJ7aWTKlp37s6iG1ZlsiNhNmZ8L7MYRN5h021330cQ== 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=oFbf211vCxHEKi8m4sGMuBWX+M4+7DN5KLI5+Fcdnec=; b=Y6yhRyhGpqk9yJOKmtUk1SCcOrPRB6dEg9E1fltRzWrUiVeJQY8uuSnHNGy73mUI9bcXII+03GqHPHFSwGvldwBf2qQHGUR9LJ+Ix7Mzn0uLk5Ch9+viHh+zu9YNm0WXgVtLvwd+NZVGWYLY5B1WnG9bf7afyw2d17vXnX/Q6WHPKh8dmPnXHALytV8JGYasYHtNCcUOiIqT8m5C2zMAQY20861SE6gtClu0Ohmy5AxDdwqyEGEICV4Bm33JhTQrfJAHYktOVF7mhdlEboOiMR+7FACBTwk/6ZiHXabLHcGIw7tG2Jg8VJYmAMiKmUwAM3Vd/9hP+XsH83Z8OvD29Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=oFbf211vCxHEKi8m4sGMuBWX+M4+7DN5KLI5+Fcdnec=; b=o6q22eMdQdyQYG7q/M2ghkvnNgIJwzuVE5kzno3XSlciuKcMyjEShwtLIZOHfdpBjJJB4Co1dQKicXFmZjaPZCHDk47+FbPl4iVghyr3MKNUExsKCrQvl51+qC4qjKuWGJ79E3k7Cth3zmjzDbCcjC1EC/B6mrqjv/iPErzsLo08nB2O198lI/aXdFtlc2f/zn+6/JYW/NDp7SVyrh5hh5HXVA4clAnW8y6G51zHR+GRLzeYr6xMcPC7Skt7wvIDmFlqDcha7MCOMHOghr6dLHQLoMR2j7afIAG4EevZIz4hc0A6WwqYVtA8pbCsVGtErhhoteux5aHFzI130TPrAQ== Received: from SJ0PR13CA0003.namprd13.prod.outlook.com (2603:10b6:a03:2c0::8) by MN0PR12MB6004.namprd12.prod.outlook.com (2603:10b6:208:380::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27; Wed, 7 Aug 2024 19:00:44 +0000 Received: from SJ1PEPF00001CDF.namprd05.prod.outlook.com (2603:10b6:a03:2c0:cafe::12) by SJ0PR13CA0003.outlook.office365.com (2603:10b6:a03:2c0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.11 via Frontend Transport; Wed, 7 Aug 2024 19:00:43 +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 SJ1PEPF00001CDF.mail.protection.outlook.com (10.167.242.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Wed, 7 Aug 2024 19:00:43 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Wed, 7 Aug 2024 12:00:23 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 7 Aug 2024 12:00:22 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 7 Aug 2024 12:00:22 -0700 From: Nicolin Chen To: , , CC: , , , , , Subject: [PATCH v3 4/4] iommu/arm-smmu-v3: Implement arm_smmu_get_msi_mapping_domain Date: Wed, 7 Aug 2024 12:00:07 -0700 Message-ID: <4fb65d188978955861cc3d3bf665ca83b8debb9b.1723056910.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: SJ1PEPF00001CDF:EE_|MN0PR12MB6004:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c785ad3-ef6c-4fad-b880-08dcb7133d32 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: yY99LwYhM+h3HkSUSYD6ZieTwEYNg8FvcGTti3hB38kpX0B6/vKXfj2u4O6Bsz0nEL6RWGBldcXBLBQ1zE7cEpI05Qi04ELkJharDgQ6aN0E6dz6lMQQNaabgqGTCF2SdU6q7NEZSLedUNLO6o6g+q2b8SRbNDvaiU7+1UwujdO4viUZj4ygJX8W/aMC11CNp7wSgkWOKttfOmbzcUrlVOuDNLjxR2kNQY7WjTpcts4h7WAGaQ3Y2UuTJ6HMQQSi2KbmMjm4ZrjGP5GxoAoLy3keDD5PyEZF5vIMxDJwpHfvKGzfsqa0NP9HEYlyXEICo1RIbedcA8kUCHuWBa1j4ovANdpYdjUsaov16ZwpVbIiBak9Ob4Q+NsJeO2N0FhoECCmYjIBMflMxmP7aOq/GLKgbmH1kaFEpmjF+cx2i+09ydb5KjDOCLjNm9dXPkKflbwZgt7Li82hDMOHllSw1bsaycYtEZ/m9o0mTsUJ1iM18yV5sKgwAwAqFTw4MNdfhtX31mtFfHfIRUxEKgRTzLo5K1fUUmzbOEB3APfoSkwbG9SdmRrtd7XN6DMX98CxXp7h0CVM9AkHmyFl30YCQ3zpIuF15GloQoigL+pdpnkbXNFQS41zp9wjTz8qpkAmfxwcZp7+AUmyIpA7fXcOE+roqUdAHCwLLI5i83watAm6JaYVHonc/5awBlp82ok+RKc4BTBsZ7EUD0uBtT00avKLfyGB45Q6fhViMkhj1kxqclLNZU6DLXLwYd8qPwQiK9W0ytgQ0RLbHmd6TvBh4TYPXKzDHWD7wRB3dhri94U26GII5k884KXwCg7H7AdrZ77tVATGVfS80GtPJEBffJ6vdzBi83TdMztgWM/gkIp6U2vNNyPGkBtXiZ+eVQSaruM6CHmUxfcNi9vrFUi9oIAxhWtF4rPHaJwso1J70qmWj75FLQd8dFZniGoBAubOUmlE1tnJ/CSgVUERSARn0VYfY3owEgv/BFKWKwM17+UWmZXmDxukzKsvwFH/PyRaKAHHGUDa7DknS/3gHYLY2nbHXXwzYep7hMiCAOpJ30zwiY//wR24soYBADacWdNwjSEOcjVmeBRKGbD27NezXWXvWDoZq+sRuwMxWxd7LXezWs9YrGgpmyoXC2F5ukfw/BWS7MC2c1QDnxMG0L0nbXzPr2/yORJUD1FOEI21jxt8b4A16nj1BAUlQXPTqP4UmFv323+4q6x9CJXFLW233YHu8X98hslWOWBlP+/E5/Mcwzvp+o+XjOHpBmLlZlMWemATKkOGFnG54KCtrgAQh4k7WGYLu1xIYIJX67azXs9aKmkOkyjHc+hDtlnC7DH0pnhgXdm8L1Y1hAl8D0YIscnvdxc7+EHYREKNi1nE0inEmQNCUOPnqBHGdaO681xJdPtbJu63hNPvnKGSkOPIGXlRQIUlPeTQ44DkKKdA9BaGMMDRFJCEnE9P7LBXn5+y 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)(36860700013)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2024 19:00:43.8451 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c785ad3-ef6c-4fad-b880-08dcb7133d32 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: SJ1PEPF00001CDF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6004 In a 1-stage translation setup, a device is attached to a paging domain. In a 2-stage translation setup, a device is attached to a nested domain, which does not have the mappings for the MSI page but only an s2_parent paging domain pointer that holds the mappings. Add arm_smmu_get_msi_mapping_domain in arm_smmu_nested_ops to return the correct paging domain. Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 24836f3269b3..3962d5a55519 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3305,10 +3305,20 @@ static int arm_smmu_cache_invalidate_user(struct iommu_domain *domain, return ret; } +static struct iommu_domain * +arm_smmu_get_msi_mapping_domain(struct iommu_domain *domain) +{ + struct arm_smmu_nested_domain *nested_domain = + container_of(domain, struct arm_smmu_nested_domain, domain); + + return &nested_domain->s2_parent->domain; +} + static const struct iommu_domain_ops arm_smmu_nested_ops = { .attach_dev = arm_smmu_attach_dev_nested, .free = arm_smmu_domain_nested_free, .cache_invalidate_user = arm_smmu_cache_invalidate_user, + .get_msi_mapping_domain = arm_smmu_get_msi_mapping_domain, }; static struct iommu_domain *