From patchwork Thu Apr 21 08:15:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashish Mhetre X-Patchwork-Id: 12821294 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 D8E8DC433FE for ; Thu, 21 Apr 2022 08:17:57 +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=a/TcJqu5wNZQ5FzG09XaN3vkUgQiYARhD4c3f062Ntk=; b=bbOmqq+lA1IWtf k77FiDNMt8I8yWJCe1B2zecga57p+TwVrXjleCLIKRLuUh7ADwClpfdelft3XHO1WMs7nrP/4Oxe9 5WTTUrdgkpgvI3MSowkB2xS1g1D/mQzcGhWAoXGfMMlnyD3SnrtBC4nDAagjAuI/TVgdeEDfJITC+ rx6pvJLJu5zenrN1rhtXLDp7C+asOwUECTCrkP1MG7HFKECLqxsXO4ByDJE819jxgMKa2qj88ek3o 01KsvXMh2EjVO+7nlJIG/+kmqM8r4S3GY/gqol3z+2gyFNs7JPrKt3cgltBJ0BQvhmQQm3ATuvedc +T0qGLkWcQf7w8FSPvSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhRzG-00CNXf-Kq; Thu, 21 Apr 2022 08:16:28 +0000 Received: from mail-dm6nam11on20630.outbound.protection.outlook.com ([2a01:111:f400:7eaa::630] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhRyP-00CNCC-ME for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 08:15:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HEzqmHz120kC0FDJR/ic1P0KDXnc3kL/Qepu/x/nELypoP/zOVAaxjq5MNk1BK5DO/EVOpN5inVisdbMicsPTDlF9HQVgwamA9xud3pWD3Vq0RSP774tRzmjestrRfevC1op87GxGXRdD9XHscYMsOEBI7z/B/764bt8wj6CP+uTslk0va4BXLNF+1Y1MgptOmEHkAzsqohDZ478en0V4reGCJ835K7WL7olYDmKigRmHJnLHsL8uFAoZmN9TD+h8TUpVH+HXyT0I0USu+NfezqRuxrP53wnPR0oSr6YBXaddAIEZJ4EEpSCAd83XBXBu/D5W539PqupnZipmKvOpg== 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=B43xn0XriVShkZc3gHBGqcwtiLj4diWTnChKvsTKsME=; b=aZJgNEKJcdC3uTuYz0GNahA30dlA9nO+KjI4AhxwLW+uo8weVKoOhi4JKItZrV3ZjQYEsd+u9KB4r4lVvlfF5ajPPdRV5FWl9JuPu8T2DsS+bZCTmL1FU23nAEvbK46ODWQKxGp8chNjeGVg4VUctlpmE1d9Of6CUL4ZqNMAS6jbSyJYuitTaxKznkZCF95gq4A68WMoPcaNq6IBQm6PUEsGh5kdlcILYCAMGuOUZnWMFjWI8qyu2R45RcWASVHh387rcSUBeoBWWADFUmRE5m5V85Ex0zDmCiftjAxTQrGSblPbx+IF10anxO5OU8s5CGJjByS83an2NZQr6e/UnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=lists.infradead.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 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=B43xn0XriVShkZc3gHBGqcwtiLj4diWTnChKvsTKsME=; b=CAeWxcVltkC9cHbyYP8NdowEUJ7Rf12HR1T5zbpnIBY4CiOLLkDqTH5JJn67yqGJ86dp0PdUpyi3g/tD0xco7K52NA7TSAtCfGZ6rms6Sk+ISKNUIwxI+GeYtDjeCAGpex5zRFjUKdiQihZDdY47bJsnCuph6+uWkyU/C5wU0or4x347egvBxfdUjgu2tw2uDNBimhlAzvF9LsyRNvrUkG3ziXRbx7qbuYk/0VrWWQ6U98d7zEMl9YwE4yENT8gGXa/b3R9KvOq9jyyerIrkpFasYG+jpFqRnPP3goBzYtRyiCNQlc8Vd91j5mpMIxxuQVSu/jVLon7a7wgdtG/bfw== Received: from MW4PR04CA0088.namprd04.prod.outlook.com (2603:10b6:303:6b::33) by MN0PR12MB5737.namprd12.prod.outlook.com (2603:10b6:208:370::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Thu, 21 Apr 2022 08:15:29 +0000 Received: from CO1NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6b:cafe::62) by MW4PR04CA0088.outlook.office365.com (2603:10b6:303:6b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14 via Frontend Transport; Thu, 21 Apr 2022 08:15:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) 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 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT026.mail.protection.outlook.com (10.13.175.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5186.14 via Frontend Transport; Thu, 21 Apr 2022 08:15:28 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Thu, 21 Apr 2022 08:15:28 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.986.22; Thu, 21 Apr 2022 01:15:27 -0700 Received: from amhetre.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.22 via Frontend Transport; Thu, 21 Apr 2022 01:15:23 -0700 From: Ashish Mhetre To: , , , , , , , , , CC: , , Ashish Mhetre , Pritesh Raithatha Subject: [Patch v2] iommu: arm-smmu: disable large page mappings for Nvidia arm-smmu Date: Thu, 21 Apr 2022 13:45:04 +0530 Message-ID: <20220421081504.24678-1-amhetre@nvidia.com> X-Mailer: git-send-email 2.17.1 X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f229e9ca-aa37-440e-28d8-08da236f18b2 X-MS-TrafficTypeDiagnostic: MN0PR12MB5737:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vNNbKsEoceNrD9EzmMl77KYLYgJbrqFuLOMhAUIt6SV4WE8rjStTfwSQbzFg2cG6DKoUktfonkIwj7bdEYmJ8rp64pPUFgkTb3ui/4ictjBYb3liW4kwPQ/c4LQmRP4d3jRRvJG18YgIH/7m2D2TyP9BMeYyf/23x9MKi5bVVkI/KgHnKc0CCDsI4aQ3qMOewB6Qv6AU4kMl0tF6fIpLW8w0+AUZ1NcJJ4tzWqwRhAYbpCEsutdsbFO+A6k7aUIaVDg80ds/1AgwtIC8iARS6HDxTo/ds7Onog7fXwB0xKLrvFK7HxXkA6RUdIdkxy5EPXZ1UubLbQYlsZkBqh+6UDIe66gAcBulew/GKjF9YaZgUj3MLh6WLxhGquBEPonBUuPm7saMKK/8hEESATTYtQDFyi5bWT2UNOe17YfgjM9tCh7iN0kBTNF23EDQQujz35jzKb+pvaorB0Fyto48744sxnBk1rUfVPwLUy2P+0eBI4kAO+o7vMYlAYqNS9XMryrXqfK7sftKo2Mx8FKa1Suz8gI+WcETEDRzl/OzQ5v60XY9Cr/pzrBaWAW77wYd1dM5wnPuUGD2oQdGoM7Q0NTnEyzQ1DNgLuHqk+9IqohuYdR9YHZo5PNwVrPZ/VnkgaWfpebw4t5LzbbZQ8zxENJwgx2xzF7LoQZdSu9RcV7jHAFQstTFhHOcpdM+I56ehSMsCPXWBTYfFrbjBasXl8odLVqeUJzJtwe/fz65IPIOblO1XBJjBX+MMZnYyxoOpHaqANDu25IgjsxI2nfzLg== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(70586007)(70206006)(8936002)(110136005)(4326008)(8676002)(508600001)(921005)(356005)(82310400005)(36756003)(40460700003)(83380400001)(81166007)(36860700001)(54906003)(86362001)(5660300002)(107886003)(47076005)(186003)(2616005)(1076003)(426003)(336012)(2906002)(26005)(6666004)(7696005)(316002)(2101003)(83996005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2022 08:15:28.7923 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f229e9ca-aa37-440e-28d8-08da236f18b2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5737 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220421_011533_791603_CB20B4F6 X-CRM114-Status: GOOD ( 13.01 ) 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 Tegra194 and Tegra234 SoCs have the erratum that causes walk cache entries to not be invalidated correctly. The problem is that the walk cache index generated for IOVA is not same across translation and invalidation requests. This is leading to page faults when PMD entry is released during unmap and populated with new PTE table during subsequent map request. Disabling large page mappings avoids the release of PMD entry and avoid translations seeing stale PMD entry in walk cache. Fix this by limiting the page mappings to PAGE_SIZE for Tegra194 and Tegra234 devices. This is recommended fix from Tegra hardware design team. Co-developed-by: Pritesh Raithatha Signed-off-by: Pritesh Raithatha Signed-off-by: Ashish Mhetre Acked-by: Robin Murphy Reviewed-by: Krishna Reddy Reviewed-by: Jon Hunter --- Changes in v2: - Using init_context() to override pgsize_bitmap instead of new function drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c index 01e9b50b10a1..87bf522b9d2e 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c @@ -258,6 +258,34 @@ static void nvidia_smmu_probe_finalize(struct arm_smmu_device *smmu, struct devi dev_name(dev), err); } +static int nvidia_smmu_init_context(struct arm_smmu_domain *smmu_domain, + struct io_pgtable_cfg *pgtbl_cfg, + struct device *dev) +{ + struct arm_smmu_device *smmu = smmu_domain->smmu; + const struct device_node *np = smmu->dev->of_node; + + /* + * Tegra194 and Tegra234 SoCs have the erratum that causes walk cache + * entries to not be invalidated correctly. The problem is that the walk + * cache index generated for IOVA is not same across translation and + * invalidation requests. This is leading to page faults when PMD entry + * is released during unmap and populated with new PTE table during + * subsequent map request. Disabling large page mappings avoids the + * release of PMD entry and avoid translations seeing stale PMD entry in + * walk cache. + * Fix this by limiting the page mappings to PAGE_SIZE on Tegra194 and + * Tegra234. + */ + if (of_device_is_compatible(np, "nvidia,tegra234-smmu") || + of_device_is_compatible(np, "nvidia,tegra194-smmu")) { + smmu->pgsize_bitmap = PAGE_SIZE; + pgtbl_cfg->pgsize_bitmap = smmu->pgsize_bitmap; + } + + return 0; +} + static const struct arm_smmu_impl nvidia_smmu_impl = { .read_reg = nvidia_smmu_read_reg, .write_reg = nvidia_smmu_write_reg, @@ -268,10 +296,12 @@ static const struct arm_smmu_impl nvidia_smmu_impl = { .global_fault = nvidia_smmu_global_fault, .context_fault = nvidia_smmu_context_fault, .probe_finalize = nvidia_smmu_probe_finalize, + .init_context = nvidia_smmu_init_context, }; static const struct arm_smmu_impl nvidia_smmu_single_impl = { .probe_finalize = nvidia_smmu_probe_finalize, + .init_context = nvidia_smmu_init_context, }; struct arm_smmu_device *nvidia_smmu_impl_init(struct arm_smmu_device *smmu)