From patchwork Thu Jan 25 23:57:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13531901 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 4FC45C47DDF for ; Thu, 25 Jan 2024 23:58:08 +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: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=IDxeIwa3/XbgTYHBHsVy9Fh/Ra+XE9uszB46baDoAdw=; b=G2MUhIfZk5bwBN xNz1Jxr200mpcbbFkelML22YMMgXR0vck6+i8vJsVHy5iQUi+ZHJRJuKUXRilnTWWx/XXP5rvSi1X 0QQVzMStWH6mupdNZlpyYoKE6251OMd634xZA22oNJpY7U3kqPCTGsPTiEUQiLCSdtbCOmG8fZpzR cNY4WjVLUaKwokXPKrYulr8naz1R/iMDKxb6Quez3fi55ZfW9uNjOj9aayxHtR3klEYtmmJ629L94 hxfTO8Gg+gw5OkxwF5kuPvX8+Y59CDhgMhgOM7k2pQinP7R3M5NLyIsKkcuxdKpzpXPb7b5j38EdG vreGVhWGNa8lqCgaQfhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT9bZ-00000002XLc-21G4; Thu, 25 Jan 2024 23:57:57 +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 1rT9bM-00000002XD8-1M7O for linux-arm-kernel@lists.infradead.org; Thu, 25 Jan 2024 23:57:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MaeARnS5HmBYyiKM/3zRknW/VMWIhDd8PaHBxQN0dNfv+S8jZ0zSKpFAs85CirPf4W2dO4GxG+TFBCm8/oc1er05EJOyZ3S9im7ESmzfNnxfyG7OP8rnt81k4RedqlGbvcTywWSi7+ADPPg5kdVvd62iUgD23EouKTvBrHD1ENErLjopx3YlGRt14JNFxVs6aNFKTRmwoVx3lkZc/RMXAtL6N+oUg3JVOFw95B1vCCM7VGSC7qP+lLIuKm2JHbyBNgQTYda0oOkdBwt9KyH3ejOWuzp/GfzwKmmpssCGzjESzUqndAEqOsj+6fVApLL6UoKGowZE1jdSIgDBW1qMeA== 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=T12PIwERlMo7T8nGB+bo6L7ogb91OoG9qKs8EBtnOM0=; b=QC1G71JcQeVh2QXnzpmjhjRcW2kupNzECu8prmPECozCcuKFM9OhGvORbPu//C+zy5/wVwE2mzyw0UhXRa9xR8aozRnnmdOapnWJIcMlVZRaiYr5RnOuXs2OOSibMrIWikwD5kRstQ7BERAxWLY7ZN0c1iKiH8SSjMZr8D0HoSQ02PXjAgi5GprMXBEw2VZdIIh5CMl+fPZTORKZKLzCV53OrobrBYJYGM1wr/h1NOAmDF4detLi6z2+3QuRWcY8hMedBmvac38HhtI3WXf+Qs++aKL8lomuuglwG7nI0O8Wrdh1LKdioWrE+BYadgjaxYrwwwkygB5QyCMQzHNHWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=T12PIwERlMo7T8nGB+bo6L7ogb91OoG9qKs8EBtnOM0=; b=ZGhLZyoq4KeUN+My8Wy1DJi8H5wuJCR6Tr+vc0/DuYZ4HuiRsXm6eN4K+JIcEC+QT0Y4s1rOM/hRNuz9F8e3SFAMafhNHeZE9pCRE/uLdJTM2U4Ub70eqDxJtU9Xj+CzlV8TvUnU1wTUDArrOkrlWLETvg/+YqyHQ6xP/k6WD8+DHMqTSZDaWZyaKmp8GIkjocDfpqelfAMWtNV44YBexWXbpb3EjYz8BX1qDh529SDWCr429eCuNhJk17Figi5b1pGNiwyWkhzb/TOkFoWD9zNiPdDNlPohRjGi2yYbSZ64KxxbJubhapK8AYCMi4pLtvlQPjvYewVNwVmAz/lL2A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SN7PR12MB7881.namprd12.prod.outlook.com (2603:10b6:806:34a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Thu, 25 Jan 2024 23:57:32 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873%6]) with mapi id 15.20.7228.022; Thu, 25 Jan 2024 23:57:31 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Moritz Fischer , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameer Kolothum Subject: [PATCH v4 03/16] iommu/arm-smmu-v3: Move arm_smmu_rmr_install_bypass_ste() Date: Thu, 25 Jan 2024 19:57:13 -0400 Message-ID: <3-v4-c93b774edcc4+42d2b-smmuv3_newapi_p1_jgg@nvidia.com> In-Reply-To: <0-v4-c93b774edcc4+42d2b-smmuv3_newapi_p1_jgg@nvidia.com> References: X-ClientProxiedBy: SN4PR0501CA0038.namprd05.prod.outlook.com (2603:10b6:803:41::15) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SN7PR12MB7881:EE_ X-MS-Office365-Filtering-Correlation-Id: bb67fefe-ea0b-4a7a-7332-08dc1e0162f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mxV6lMrNpVIq5BVNnaNU8gDAcUOsDscuSblPtWNWE2GtInkRgBjQJLytskF23uK+k3rMVDevNMLSbjad81I6+tkPnUf2k+tZKuVpz9UyzPf26g1C6M7SmE0MIHTHII/y8a4VQZ8WEJskm6vH3ZwcYBUaROnSoTJHsY/DbARPIA8WRu/Ce5TeIaaeOsDbDABaLEKCRAYM91Rrd6nT980RSnfkucf7oJxjEk9GqHs0Yr+VKhYzIp3yyMgQ3Rf2SlwaZnvoQaZ0NCjbmwGjnW1/COGFPtBiicpecQseRWervBgN72TjDazMZh9wZ84X7Aeb9khN6OJ2lGoNvv5s/05yX0QGUGPqpY1OIcyxgXNZ2ye5PDo2YQTaKYMyVi2d0vwuF8duddb/Ty+RmwBSWAOs94y+25EJvPR5FsqDEHBQNTPdK6Kvwr+FVSm7x2O39KWv9XNtqelcZFcbiFnXiu2KQs1kL28ltXxTwULOWQzfFmiAVJ+ibuznfGVsIiToVfQ11yiuEDC4//U3IXpRdTxgT5rjHWYhRkmS3Ti+hn1JIs40tVLmOX2uiZHE13vdekt65PtRSeRX5yKdoWzw75zkeWDrcEPze455QmfgKn75Q/8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(136003)(396003)(346002)(39860400002)(366004)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(83380400001)(36756003)(66556008)(86362001)(54906003)(110136005)(66946007)(66476007)(26005)(38100700002)(6512007)(2906002)(2616005)(7416002)(478600001)(6666004)(41300700001)(6506007)(6486002)(5660300002)(316002)(8676002)(4326008)(8936002)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CPpmfON/zgDqvstTJbSyPm2vzfXbOxfwIzZDusCpz+BmdW8jHI3CRF0WU4DSCW9XRZ51MRTzairpus1fDrJGMnoqFRjxFqemTBAHzHcTMDuijkH0Mk7md71XBjWJJ+fZOvuo/kSYfXYL+PPr/WldJVgdMToW3acCJX/mYM9vuJuKdk95GIUpsSgXt3A/hx93M3xJ+I2bbgzZ8XubSfwgSkIGeDgnHvIsCzvUivyyLcgreLtcRNFchygfu4hv6ORfojftPSi3/cU1xl0kn5LPvgV6dsTQflCOd6gmCF0ry/Dso3ne3LvE0hOzGH6dtj7xkOJ3dDQxkORNVWXs0toC/TM3tvKKRPwc+5DdAWpAngXpwruPrF4oAa/2yVW6pXtr3Rn7qjVwg2MvzENUOAEPYL6s9ZPB81tTw6YhzvkWGtLbQOAjJapv/PDI/e3uczgQjozBOUfK/Lsx24QnrwKXNLfacNFrNgKpGjO80hFAKDK7fcYSsvy35y30scahh8KAUvxRPQens5Efdx5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Org: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb67fefe-ea0b-4a7a-7332-08dc1e0162f6 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2024 23:57:28.4902 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: I8iesmqBIo5BWWBaUCVV+q3+6PKjXJInJo7coXua5m0EX90cON4Zhtdohh8Walwd X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7881 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240125_155744_488603_2BDA868F X-CRM114-Status: GOOD ( 12.51 ) 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 Logically arm_smmu_init_strtab_linear() is the function that allocates and populates the stream table with the initial value of the STEs. After this function returns the stream table should be fully ready. arm_smmu_rmr_install_bypass_ste() adjusts the initial stream table to force any SIDs that the FW says have IOMMU_RESV_DIRECT to use bypass. This ensures there is no disruption to the identity mapping during boot. Put arm_smmu_rmr_install_bypass_ste() into arm_smmu_init_strtab_linear(), it already executes immediately after arm_smmu_init_strtab_linear(). No functional change intended. Reviewed-by: Michael Shavit Reviewed-by: Nicolin Chen Tested-by: Shameer Kolothum Tested-by: Nicolin Chen Tested-by: Moritz Fischer Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 38bcb4ed1fccc1..df8fc7b87a7907 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -102,6 +102,8 @@ static struct arm_smmu_option_prop arm_smmu_options[] = { { 0, NULL}, }; +static void arm_smmu_rmr_install_bypass_ste(struct arm_smmu_device *smmu); + static void parse_driver_options(struct arm_smmu_device *smmu) { int i = 0; @@ -3250,6 +3252,9 @@ static int arm_smmu_init_strtab_linear(struct arm_smmu_device *smmu) cfg->strtab_base_cfg = reg; arm_smmu_init_bypass_stes(strtab, cfg->num_l1_ents); + + /* Check for RMRs and install bypass STEs if any */ + arm_smmu_rmr_install_bypass_ste(smmu); return 0; } @@ -4063,9 +4068,6 @@ static int arm_smmu_device_probe(struct platform_device *pdev) /* Record our private device structure */ platform_set_drvdata(pdev, smmu); - /* Check for RMRs and install bypass STEs if any */ - arm_smmu_rmr_install_bypass_ste(smmu); - /* Reset the device */ ret = arm_smmu_device_reset(smmu, bypass); if (ret)