From patchwork Sat Apr 13 03:43:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 13628611 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 503D8C04FF6 for ; Sat, 13 Apr 2024 03:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=dkOqMU4UfpdU/mMsiVr6XXwlINzqToOUPfokTYDt3cY=; b=2SzYr3D1dt+svk Zca2lRmp4C9CWjNmc7LyAvexhcwgRnACrii971pUv47nTw0bbzm3pu5T+C+nc4SEv766OvsNVDtHs hRzqN7F/ECB2XwTMLIA79fbl5PX6fQzsIGO9EHMCcFxqyTUOEnCVhySXxM+9s0hDeXJnWaolAur3w 4VqSMExrnbrDtO3M2PPxscZNDpPDhovjSFBBJWEJv0uD2reBWlSV9byTDEiqAY+e6rQCNW8QXk42a JLkNBE7i8pu3Ll724boWjUwMMx7/hYl49FOXt+qE6DjMauTZqKTdPcEl2oz4C5PW83LxNMhaL/5MO /YmmlY+WwqRNIT6uP77Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvUJZ-00000002DpR-13in; Sat, 13 Apr 2024 03:44:29 +0000 Received: from mail-dm6nam12on20601.outbound.protection.outlook.com ([2a01:111:f403:2417::601] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvUJS-00000002DiV-3OaC for linux-arm-kernel@lists.infradead.org; Sat, 13 Apr 2024 03:44:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RQExnK/a4wyA4HgwtlZ9Bupon2mHv7on9W8PXmLhmZYIRuMJLAW/E7oQm7UVOgDL4zYhMCsjRnHKC471oc690JPmWdFg3xWQDbnHORIluRhl9ZcwX8i0qxtkmVaw1f3h/+WfjWr1k/9QRngItvMH/DCzJ/tzviKlIelcP8qaK4E8rMC+I2G24Ql3Xcf6y+w/481lSIgYDcU+Gy27dGy3/2sfK+llqI21CoZ3nGeiIcT/egdglsxIEQn/vkeqSpEW1AbEvh3q+XQfEp8GvZDAMRBe4KQlxouwvB5gbQbjv70wVDgmOoh+7RkvVoGZBQlWjpOeSmTm2Zm2klwTKU1TTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=dt1rdOyUNs4A0bwW1L/df6uNfsERDiK+VlzPccgW5cE=; b=DGYyfX/cAVON2W4cGVGymc52mg19mbfEuybO+DMbD9lDCXSbVGvU1/mzXDT1migtZPqfmOurNkyuY5B1JwZc7eJjYKev+s3p7fTyb556DEDcObjqNNjzW3TIChgg6l09kcP3Kshmu7U12PFTUCLX9WCH9fckgAgHyOGUzkBgQ2BYWGdpqqsm8hCqavrGkAitbeHPJnVx20ak/ioO0qhRQuia+eli7E8Tpiz9hW2z+D+7Nb/USdUkFXw7+1LQY86tp2AwHj8c5Tu56qaoDjKglXzVCxbYxT/qZ6rMlKj5HiKlXfNIMtmCkD49vWgpzu3lDEr1mlZucyPJeqGRciX9uQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=kernel.org 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=dt1rdOyUNs4A0bwW1L/df6uNfsERDiK+VlzPccgW5cE=; b=ufBrSK1ZOzPSRy9TPlIdGlqGtLSYpvz6tSvLnVjQW8oGTkcd99qlSgRsIDpwt06a5rbOB3V3OI/4A/ikE6pFu0IE1WACsUr2YTF94Udm/vo80oNU1j3xAWYyjk1ZiDBwH5nYwmlZt1BmE21XftGgr3w6W9XtdRlgh/LArqEB6eI80ACFZdFkulfQ5v11QHm7IH1X4ucRG1H14TJ5uJ3B0ExCpROPB878aUQ68ECSxD8mB2t5qACymrKicho59t9DxSufLmhEfyT2F2F3tzVYVx/4uvjjENF9zO7lZRycv9GveXX83kjc3VtfkdZmu5GnE8npiefxD0w/ilKJ6OLLwA== Received: from BL0PR02CA0016.namprd02.prod.outlook.com (2603:10b6:207:3c::29) by SA1PR12MB8141.namprd12.prod.outlook.com (2603:10b6:806:339::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Sat, 13 Apr 2024 03:44:04 +0000 Received: from BN3PEPF0000B06F.namprd21.prod.outlook.com (2603:10b6:207:3c:cafe::4c) by BL0PR02CA0016.outlook.office365.com (2603:10b6:207:3c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.19 via Frontend Transport; Sat, 13 Apr 2024 03:44:04 +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 BN3PEPF0000B06F.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.0 via Frontend Transport; Sat, 13 Apr 2024 03:44:04 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) 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.986.41; Fri, 12 Apr 2024 20:44:02 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 12 Apr 2024 20:44:01 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 12 Apr 2024 20:44:01 -0700 From: Nicolin Chen To: , CC: , , , , , , , , Subject: [PATCH v5 0/6] Add Tegra241 (Grace) CMDQV Support (part 1/2) Date: Fri, 12 Apr 2024 20:43:48 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06F:EE_|SA1PR12MB8141:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c7964de-1a27-430c-4d37-08dc5b6bf6ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fymSb9m7M5H2Te9kcdjFMzeWHITlzPzIQDoE9sZsJ8uuBZYnGbL3UcDmEMaKLAnr2Ft8eWbc+W/35c/0O+5YF/FaDknxU/K+B9Axx/eIeB1w1rzFDFkLCfB61L599D/b/+Y7bzf14/ASI8Yt8c4e2cfXvmR4bOzFYluEXUztn8eedeB7zY7Y+GCXw3RJBZKzHoesOGQ2iPI6GAuSsHTAlxmURZao/YBfoDAHjA8sJHjVbPIm8bcMGGhFkoENGVjRuRmISD+jPy97CgqEA7kI3aj2fb02XzRUYlHbi7ZCV3+Vq3AptLdq5qE2+oonA9jMELKDMzrb5tV619Wzh/vUU/Wd0F8NN3cg0Sy+ZCNJXSsFBtTy6D9toQ2uXiKxUgI1v/un2I+fdqQ3tklVwm/HMafuXGFJqHqa24fKvIsu9hqD6OZQuSuZ5UMp/Oe/JX9VRwDAN/0lqsMlJRRffe4CLNWBiRO6i9Bs9Hpc+iyr1DFdCUaQ2GgoNy+xBFSi7RWTrQ3j51CzFqDHTQozh6onlQpAd/vkdGay+9FdMFL6QDP2/wMpdoQ/ABu7SFdrtN35Y8G/Cih33EPmfNBB7A/ZAPUpYmCoKqkOSVogeqkU+0Z/f6becEv2aln5AuYeKrYYdw1o4WYXELxY7aIPw1f8KykDx48jNJgglBk1oW4S7f1QrVlO2Vwba4xmKxatg7T3Uw0b0PSObODcxVepYEaOQBxz/3y0a+5iBhenzYdBeF3mBPEtvxRfryj5pL4fIuc8mEDOyZmgDu2pJ8tK60PsZg== 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:(13230031)(1800799015)(36860700004)(82310400014)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2024 03:44:04.0333 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c7964de-1a27-430c-4d37-08dc5b6bf6ee 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: BN3PEPF0000B06F.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8141 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_204422_869096_6D4C5673 X-CRM114-Status: GOOD ( 18.12 ) 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 NVIDIA's Tegra241 (Grace) SoC has a CMDQ-Virtualization (CMDQV) hardware that extends standard ARM SMMUv3 to support multiple command queues with virtualization capabilities. Though this is similar to the ECMDQ in SMMU v3.3, CMDQV provides additional Virtual Interfaces (VINTFs) allowing VMs to have their own VINTFs and Virtual Command Queues (VCMDQs). The VCMDQs can only execute a limited set of commands, mainly invalidation commands when exclusively used by the VMs, compared to the standard SMMUv3 CMDQ. Thus, there are two parts of patch series to add its support: the basic in-kernel support as part 1, and the user-space support as part 2. The in-kernel support is to detect/configure the CMDQV hardware and then allocate a VINTF with some VCMDQs for the kernel/hypervisor to use. Like ECMDQ, CMDQV also allows the kernel to use multiple VCMDQs, giving some limited performance improvement: up to 20% reduction of TLB invalidation time was measured by a multi-threaded DMA unmap benchmark, compared to a single queue. The user-space support is to provide uAPIs (via IOMMUFD) for hypervisors in user space to passthrough VCMDQs to VMs, allowing these VMs to access the VCMDQs directly without trappings, i.e. no VM Exits. This gives huge performance improvements: 70% to 90% reductions of TLB invalidation time were measured by various DMA unmap tests running in a guest OS, compared to a nested SMMU CMDQ (with trappings). This is the part-1 series: - Preparatory changes to share the existing SMMU functions - A new CMDQV driver and extending the SMMUv3 driver to interact with the new driver - Limit the commands for a guest kernel. It's available on Github: https://github.com/nicolinc/iommufd/commits/vcmdq_in_kernel-v5 And the part-2 RFC series is also prepared and will be sent soon: https://github.com/nicolinc/iommufd/commits/vcmdq_user_space-rfc-v1/ Note that this in-kernel support isn't confined to host kernels running on Grace-powered servers, but is also used by guest kernels running on VMs virtualized on those servers. So, those VMs must install the driver, ideally before the part 2 is merged. So, later those servers would only need to upgrade their host kernels without bothering the VMs. Thank you! Changelog v5: * Improved print/mmio helpers * Added proper register reset routines * Reorganized init/deinit functions to share with VIOMMU callbacks in the upcoming part-2 user-space series (RFC) v4: https://lore.kernel.org/all/cover.1711690673.git.nicolinc@nvidia.com/ * Rebased on v6.9-rc1 * Renamed to "tegra241-cmdqv", following other Grace kernel patches * Added a set of print and MMIO helpers * Reworked the guest limitation patch v3: https://lore.kernel.org/all/20211119071959.16706-1-nicolinc@nvidia.com/ * Dropped VMID and mdev patches to redesign later based on IOMMUFD * Separated HYP_OWN part for guest support into a new patch * Added new preparatory changes v2: https://lore.kernel.org/all/20210831025923.15812-1-nicolinc@nvidia.com/ * Added mdev interface support for hypervisor and VMs * Added preparatory changes for mdev interface implementation * PATCH-12 Changed ->issue_cmdlist() to ->get_cmdq() for a better integration with recently merged ECMDQ-related changes v1: https://lore.kernel.org/all/20210723193140.9690-1-nicolinc@nvidia.com/ Nate Watterson (1): iommu/arm-smmu-v3: Add in-kernel support for NVIDIA Tegra241 (Grace) CMDQV Nicolin Chen (5): iommu/arm-smmu-v3: Add CS_NONE quirk iommu/arm-smmu-v3: Make arm_smmu_cmdq_init reusable iommu/arm-smmu-v3: Make __arm_smmu_cmdq_skip_err reusable iommu/arm-smmu-v3: Pass in cmdq pointer to arm_smmu_cmdq_issue_cmdlist() iommu/tegra241-cmdqv: Limit CMDs for guest owned VINTF MAINTAINERS | 1 + drivers/iommu/Kconfig | 12 + drivers/iommu/arm/arm-smmu-v3/Makefile | 1 + drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 74 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 46 + .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 845 ++++++++++++++++++ 6 files changed, 952 insertions(+), 27 deletions(-) create mode 100644 drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c