From patchwork Tue Aug 6 23:31:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13755478 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 E837CC52D6F for ; Tue, 6 Aug 2024 23:33:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=SIkmjguZ6M+290NsPr+CxlE9c9SVlmRF/icXTrdLbh0=; b=3Fj3OA2AS/3m7vL1kiO3nLpaK6 RcN8hEsadC0JXx+hBOphxpyNa5552vBfSPsIVrS2C9g8g+i/9H5GGR7sSC7fqrEBTAC9/EpzaAYWK YfwG4TC5s24hR3OuWCjg6X69et6VVRfGV/TRBZUnwVczMU4f5AI5hKYLi61qRrBRO5FyaGnPywiRJ Zk+Bf5w75GvH3HBl79kKFaSRZgjJSUWCAOug4RlG4AJWgQOmXBd9JKuixEpApFWNA2NCJbrsvEZpR 72aXRYoEOKWezca1MsWmr/8gQ/2Cy1TVdTM2wVTwfHNfU99npMmlE0A2SMz8fMl0PYqrnoP0iiecH zmrCf+hQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbTgC-00000003K0g-1gpt; Tue, 06 Aug 2024 23:33:24 +0000 Received: from mail-dm6nam10on2062c.outbound.protection.outlook.com ([2a01:111:f400:7e88::62c] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbTec-00000003Jdz-0WaU for linux-arm-kernel@lists.infradead.org; Tue, 06 Aug 2024 23:31:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Hmjar+T33BWpoyKA+EncoZmDDQy1RlMLqLe2JAhKIACYdLbsuaPSVUktty6GKHewRGSk3ebKqcrCJm8tHCGgyXHq2s1ZIV2MrA4vH7F/6DI63LIyjJukasxRDXFejjtLXUWjL53u6i2A3FTrpwF3VHjpf/Geay3H8CJPsTjrsaFmZDVMiRdZmDfLAQ3uroKwa7AlOflLzoTU9sR6x0tDVb63GpgIO74my+NZvSG/BHwHhG/fWBjxn75Jiya8nAmb5dlNIYOX5ZXxGtK4BxhmT76jX7H3cntrPgarVy1UDMN2dF+FoqKcu1Dt0cSsRH4TI48kLbzz8EsnqYPpQ3f4RA== 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=SIkmjguZ6M+290NsPr+CxlE9c9SVlmRF/icXTrdLbh0=; b=hAjMQU1ajaCULbb9zxCj7P97aFSkGolzkGZn5HyU36PYU2Zgeg6GCZL4S9hzfCffwyFkygMV4TjMfMbPU1twJDUFfo3cyqOsPr3zO1BrOWQK8GstC8CK06VPeQVfAjYhO1AxXs9WS60x7MRo4IAl8zD4z2lqDAW4OMQoS1vT9mg+eUa2OOwV69SOp0F4YsG9RJr4ON4Vc3HpJ1BHbqI4URx3MQH+RQ4o7qQ6+/H5qNZPsjEtcaNccsf1goeI2A+4Pv4OEiAGYBN881yOi9KBQLBBfoYQxSk9+j6LPOqFs/x2ja8owzlW26mXLRno8HsJHYjjJCqK8KOQMULIP1vBiw== 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=SIkmjguZ6M+290NsPr+CxlE9c9SVlmRF/icXTrdLbh0=; b=OiMTT27lwiZfZybvKEP4TfmXPxXh3i00KVgSqmDTUWUEJ19AFXwY0F0UGT6WisC0FSgPn9ekmt+DioFLNDYsRG9shl6hogJKLGqIrZcEOQ6N4t3NeXNxbVq7T0I4kDm+4dH7kPd38woQSrGutFe0Db0qNh2tBx4t/7CI1el4bGwK9+pCtQziSTboYoK7bAE29M3g6Zd1NvOZ6Lgph5oBWoqxeUTzi6a5QOAGb/Qv5sUwQhCiw4gT4DC3oIhEkDOMiJHw5dAYkzjHrCUst7v00YaIGX4emNiOmyZ9q/Ch7MKjj+ExbDYzZPGprwV67y7wmDDgo8DXzV+iqdn8z/PEDQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) by PH0PR12MB7839.namprd12.prod.outlook.com (2603:10b6:510:286::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.23; Tue, 6 Aug 2024 23:31:31 +0000 Received: from CH3PR12MB7763.namprd12.prod.outlook.com ([fe80::8b63:dd80:c182:4ce8]) by CH3PR12MB7763.namprd12.prod.outlook.com ([fe80::8b63:dd80:c182:4ce8%3]) with mapi id 15.20.7849.008; Tue, 6 Aug 2024 23:31:31 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Ryan Roberts , Mostafa Saleh Subject: [PATCH v3 0/9] Tidy some minor things in the stream table/cd table area Date: Tue, 6 Aug 2024 20:31:14 -0300 Message-ID: <0-v3-9fef8cdc2ff6+150d1-smmuv3_tidy_jgg@nvidia.com> X-ClientProxiedBy: BN9PR03CA0574.namprd03.prod.outlook.com (2603:10b6:408:10d::9) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|PH0PR12MB7839:EE_ X-MS-Office365-Filtering-Correlation-Id: e8928eff-a7bc-4ede-3dde-08dcb66fe391 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: 6rK6C8dA5LfGk3SsI0omIsjwndtrInORAG7DlLQWR6vM/MZpWCaIHrbIKiLyQROwbc3rlsIiYs3HtXhSKZN/oEUk1lqxQI+ui0nrKBz2NqMm8p2SU5ErTmbOG5tnAAz68joCexhYglBO+zUlGszdTi9UuCh3gSzCkrioa4ad2x7TZzVeMLE4KrC9pNZxzL8oHLmgOTNnQBJ54ZVkeeoQkL3et5EQtH2E7qptH+dRlCNinu2uPGcFk3pLbBQzj/3G2QCdQejO/i3qdrkYX3hJCMySbTvWppSFmR2PMZ2VV71hbdlJzXmet/5LCuDOIwnJxDkr/LuNc+htLSqogOzLB4tg1JPzWTNfJUmUEeniiYbvuZl+FFIxvThpN72mxfG8hG2dxJ+Xma6uAqr2YJmJHC1bzRoxDsDo3d0LlzA41ZZmr6iGLLsSfcq865yOwIgB1nNRynPae4wtR9qW7jkQXW3ntnluNiOyHIj7414+pO3cKtRVKCiJcEXh8gvy6vzi1Go4d+gHbAcjry797pp5vrlpqDEDCuof4w3ucLz1mjy5xFqeYgRL6wdcar66qf2k1OfBx303tTmfo02iaYeGM2Bg4nnEF8gk0yUbj6TMEYOYtVjDMMzvNUEJqIzpOvN59MhCB/sC1xmbiNxouJn/7/3vfpA1DPEdKTZACbf1IU/qrN0mabr0/taRfTv9rTZMil/Sxti/2G+YKHRmU/Ch7hBZou5dC4EXZVMQLb9/IHbTSorciA7U08cij61rE+DeqYIe8gYbsr5avM2sDP26RSXMyaO8GnwD01AMnZZDThu5QhdGVkXABvMfiK7HvgYDpDb2478u4JcDn39meNn5IEByra/0j1ofPUF6q+ZxNM6iysTSDlbMwci42DBVEKOd3nlj8D511+muK3N6KZIEcTbRhMLINlsMdqslmPDQwS0aY+v9Bs+xGkbWZxL6eV8t38W55kOGS4fbvxn40EA/y3caQo1F7kMEEJhoK+5P3Tr3SfeK0Tg1FeL4xkNa2bZezuQi6AAOZNY27AOgqb8aXmY8+apeopSMeNpsTmdg7ApD6s6iStQQiR2hnNDG2NIM2grZQZnCFgSWGfv4Mp2CgY2uFwk8tTmzBHpZc+CDT5DOnSUmAK96b6JrfaliJZNhYcS0P0w/wSbMZjuxhRdMf+0MTBcJeTQ/O+QesKRIbULmmFwTseQcFW75vWS4bMIyvFX1i7YLBtATlV6F4cWkbSuyIy1SkR3hG9Rq4aoih1oV3Sc+UNZdx5QUSjSD5W0+j4XcGdY4ARuUCCNwp46q51gU6lKIlUnOAU02vA0rQAB+v5kKkUtAkJof2yZIlVNo1B7N3rCJyZU8zX7xsvkHDAK/ONTqNe+x66uC90f426w= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR12MB7763.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-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sTt82ji5JQLKL2RB4RyF3V6IwCDFtyiN9xi5/w7EjBeDfXVzoo2AClt6I3ix4+UiP7S+ubr3eWQeIk3hm4ZaVi7ITYLPL5AfhXNrhRRxLshoZ3n3gVikMC3NOYzn0Q3tClc6xBPO+8gnV21cAraTgGO/g9vQM4mDIl9GECAHqILVgoXYelmC+OqMctOZo/EpeyEAfw/u2snEyzwn6RVBnyNj44srFrdhCQp/Vnn7Np6z2KPKQszPGwXAfOwkvLjvgR8gLWzOYwXArzgI/3sg+Jdc7jkpBZBZfGMRVIOq4rNRZBjQjFxyAg0Te5w5X/v5Cb4mkrQqgTZ2FW8fsEbl/cGrOSMYTKuY0E9AJ37eh2qVz9GclK91TYFeGe/TVaAm8d3L8Roklh7lDNR1pGAYeiDnJpZpx6r3m9SNC2G9Z5L5q/07jp/ci/830+uXkJxdcEAkHJ2xskM13Ebf1M9azi/SenXdlohqZtb1ZY2OscgrePrChXFVwof78rFbddbQkOFaQLA0hGs= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8928eff-a7bc-4ede-3dde-08dcb66fe391 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB7763.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 23:31:25.6211 (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: a2MaAq6c+3yOnTYnuKuMyFaNOKAw9yNtxl94TxbCJMEiFjri55ZugrB0ojo8AMaf X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7839 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240806_163146_196181_E078140F X-CRM114-Status: GOOD ( 12.54 ) 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 Will pointed out that two places referring to the CD/STE struct did not get the new types. While auditing this code a few more oddities were noticed. Based on a feedback from Mostafa and Nicolin a few more things were fixed up too - Use types for all the HW structures everywhere even for the L1 descriptors that are just a single 8 bytes. This helps with clarity of what everthing is pointing at - Use indexing helpers for the STE/CD two level calculations - Use sizeof(struct X) instead of open coded math on constants. The sizeof naturally follows the type of the related variable in almost all cases - Remove redundant dma_addr_t's and save some memory - Remove redundant devm usage - Use the modern rbtree API Parts of this have been sitting in my tree for a while now, it grew a bit since v1, but nothing is particularly profound here. Enough is merged now that they can be cleanly based and are seperate from my other series. v3: - Rebase to v6.11-rc2 - Preserve the "2-level strtab only covers %u/%u bits of SID" without change - Vertically align some of the constants - Use u32 for the type of the index and sid - Fix missing * in le64_to_cpu() in interior patch - Bring back accidently lost "Use the new rb tree helpers" patch v2: https://lore.kernel.org/r/0-v2-318ed5f6983b+198f-smmuv3_tidy_jgg@nvidia.com - Add a patch to add structs for the L1/L2 HW layouts and use their sizeof and type instead of constants and generic __le64 *. - Add a patch for L1/L2 indexing helpers for clarity - Reorder patches - Redo the union layout in the cfg for both cases - Fully remove some more defines v1: https://lore.kernel.org/r/0-v1-1b720dce51d1+4f44-smmuv3_tidy_jgg@nvidia.com Jason Gunthorpe (9): iommu/arm-smmu-v3: Use the new rb tree helpers iommu/arm-smmu-v3: Add arm_smmu_strtab_l1/2_idx() iommu/arm-smmu-v3: Add types for each level of the 2 level stream table iommu/arm-smmu-v3: Reorganize struct arm_smmu_strtab_cfg iommu/arm-smmu-v3: Remove strtab_base/cfg iommu/arm-smmu-v3: Do not use devm for the cd table allocations iommu/arm-smmu-v3: Shrink the cdtab l1_desc array iommu/arm-smmu-v3: Add types for each level of the CD table iommu/arm-smmu-v3: Reorganize struct arm_smmu_ctx_desc_cfg drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 355 +++++++++----------- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 100 ++++-- 2 files changed, 232 insertions(+), 223 deletions(-) base-commit: de9c2c66ad8e787abec7c9d7eff4f8c3cdd28aed