From patchwork Tue Jun 11 00:31:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13692723 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 21C05C27C4F for ; Tue, 11 Jun 2024 00:47:24 +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=RiV895gRBz1COGKgIYXBm+QZQs8xtH3ugheaU/pvo7c=; b=A/G1DJD+G2ndZS SAJk2UY8RKZzuFNK98BUnKb2Rrb0U4yfnVZUKXp2vae9jk85uv+Qo2gUOoUJAflYTlZUW2rcz+tjb eG1Hv9EjFRnaMp/SC6FmZtmW1/5GmYn/fleQx/f5VPJSFRdu6SIXg3fZBtOIP46PIr7FW2qUvrkk+ DQQ90kadDWUs1gLRJ79eX2SZYg+lu0oZB3cmrTNo6mY+JurKe84vc913P/WrgUDEo0qMMAbh5MPkO NMtV5c6vgqWRjrjd7u4ozwMvf0UUpBHQ0MHdEZJIv6INXXHQ3R9BX/b+abDs52R0ftb0B48d4itEt YD3Fim71DvozCzFnvGlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGpfL-000000070KU-33kF; Tue, 11 Jun 2024 00:47:11 +0000 Received: from mail-bn7nam10on20618.outbound.protection.outlook.com ([2a01:111:f403:2009::618] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGpfJ-000000070Jz-1qwD for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2024 00:47:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k4QQI0VhHV+N6Qe4QbEtcbEfWZewlfts7G4A7iVJNFt4ROLFTlBWMzT1Id8T1Hi4lTNZsgifpRFZ3K4SUe9W533lkKAhLbHCesRo6n/eeosj5jidCk7X5iOMCHB4rvejbUllCQCpf/JiujQmzkBUXOVO/yr8oiruZYTDay14IbcG9eBrn56jDqPiqpcHp2n9i3c/TfWw1dgoFBAXYnEQRFTYq1KireFIcgquSrd1ff4zeo9gYInkBrRaATenpjjBwEbPQdBCeRVJGRn2yUOtbRCIGVia0sFSRzQff8D5zyfIp/SRuYPH4xzb6nOotRbW2UfGsMRKnMZg8cYRy4HmIQ== 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=8QR5CUsKdnpOiQOoBhgT+z2GrpcAGiyJ4eHDEivZHiA=; b=G1aS7P57RWloKC4h6qcvSIKATP0jHxlm71HzGsEvLmahPKB4SEvhEIiqPTYhP+WrefncVSCfo4s7ic45+D7ObPm+KReYIa533vz9ySeDiLggLxI9TsC7mLfdCD318J/O+Fn2ZWg1Mt+90htmxCWvjl6Omjq/0s2pY1nfIpJ+kX8SQUoNAGKao4DOyKg/y38L1wvDZCMP1wmblQY9qmiYQA8YL5eBOL0cazJs+ZDpxqw9N0olR+xLAKit2htX0ciwiCLdhCybY/wL0V0hDzR+drTKLzJ/w42Q4uZtC72KPNgKnfr5/8QnLFq1aR3B1J8QdJ29UXQOTurPKv3rillz6A== 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=8QR5CUsKdnpOiQOoBhgT+z2GrpcAGiyJ4eHDEivZHiA=; b=jvOIzGjwSBmDxyJQTWDLuo8M+78Eyz33Oj+3Aqpw1ZEC9POJsQFSc9iz69LMxVrFRwZUC1z11XRxrtbfbJbWGWsbKqkIxEE/7Fcs6H4KzS+33/5elAkmikj3eJpbr0Ou1FQQVyYabDWO2RifDLY7AahPYW1/gMsgDeCiAVu53l07AMHdNwm3XQSMImKzTkoXjETEgnOoy9yUOw58Aci0OtjOYH4pufxJ9U44oDvkfWKcpb/v/dtxtb0Hmbh9ltgiAc2+GNEar0FTJbkSQWGVDkB/ft/5w/HTR/LzTReUDlE9CzYdv/tnhVr2zejuUWlbYsjKwQh51+Jl5jWSuC1tUA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by MN6PR12MB8565.namprd12.prod.outlook.com (2603:10b6:208:47d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Tue, 11 Jun 2024 00:31:27 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e%4]) with mapi id 15.20.7633.036; Tue, 11 Jun 2024 00:31:27 +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 v2 00/10] Tidy some minor things in the stream table/cd table area Date: Mon, 10 Jun 2024 21:31:09 -0300 Message-ID: <0-v2-318ed5f6983b+198f-smmuv3_tidy_jgg@nvidia.com> X-ClientProxiedBy: MN2PR16CA0061.namprd16.prod.outlook.com (2603:10b6:208:234::30) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|MN6PR12MB8565:EE_ X-MS-Office365-Filtering-Correlation-Id: 20f88929-6466-4974-c87a-08dc89add284 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|1800799015|366007; X-Microsoft-Antispam-Message-Info: RzTuJixEkUFaD5mzE07Mys9xMduZcrtijSgs5oiQa5qWYr88thqm3G07HdoQCNu/1g61o27H3+51ldYW4iQ2rFNq0+Ezteu8e7nS0/evJi5F3JOTBWwo5qK4LtueSpT5lcHseT81Qa7G/tIM6bJM16gQn1UKZSHEhml2PIcXnwpnz99n4+kIvIzU0q0Ek1iSRTt/H1Ql0d4H2ErV0RJUysowCEHGw3YWEopq5+o1J3eFgvpiVPK7l6n6z7jtFCwiYe/663HCPbRECW3+ggrmOhbFN6QxAI2zV/9iRlaoGhs+VqYGD3BCY1NZ9hZ8KXBYPjTer+h9luLiPT9D9rqMBXsazdOoNICKPAfaSOLequN2NOXafe2pFF9tlVqyt6jNrJ9r+PhxH/8sFVvvxrxFdC+wGKgOPTVlP2gWvttZm0o7/mp8FGL5VwNGb043xD1Zu3xpQB50IDhRc54LGBIfE1fPR8n/oF0wMjwGxuBGgoSLmbtW4oySSpgOcIXaP4ZDHzwJYlTV+P4KI3NxYpfe9G6sdGtpMuZD2pDg1MhYlljuyDC3/pT+QA4NN0QvXOEz9hGx2tKXX7k+lPDJk5MAPUTTEmq2xK9dKRmm61G6gqSHq7TtnuKXqSOIMlIZBtkKHpdBsl93HX5tFqNZY5ir6WL8MAqVdFerHSf+wFeBOMD+ywz+vVtBjErzkWnmACj91b0x5n0Vs20bRNbu5z18NOe5ntoa+J5PsTqrIoCUbphTkIHobPO2QzWNhxw6mCb72xb6a63TBMuVvoboZn5pQt5VZn4bLB6bvhhT2zX3GamSOuijpaSspE2u4IYGJQTN+pmVNqluhF7/rjy4GvkWyx9m307JikHhCVTQQeLPuDbope1VGYJInPYsxpc0spBXRaCg+6LkwbvjhbfmjdGGsibzdOhVOBIqB2dqj0HKHOMeOmiF9ovzfpj5QHGh2ck4gucYCopCW1IdgtkV/pfesbWgUrISLZP/S335aj40bkgXuW0sFlp33Lv2e2B8GS0O0TgrwH5puoJxbr9eLE5fkhxINb+z7zxYbLzL76wWW3WE4/lvL0Sv8/DMUrsBhysocZgSOcvZJlO2iF6BnwbV1oltNpwtMKIX0UlWj7ZBcuwtF4TMFs0zhZsgXTHIN/oka+JupqRMY50b/0fKJ6s8c5vkUPeG7G9sgzWIxg20b+oVYnvxi2U97te1JPcxVab5A1BGJNMW8e9v1TImW9BT56eTYpn4KK/h92+BenrSt7FzYPnMlOwnyBBAMaaLkgeIsv9AOu5KGMBHE93vxICdpG03bbnT5Rvqg5K7yKmzFsfqG1swZ5nU7UKYCp3kP0UN X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(1800799015)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JZIjBoDxZXknhnx3yFj/PmONkdGrnNXkBfHgbsn7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jzVKbkrN3w/B1IUvdKdiNw+rMM1AQWsgjtuU0IqVIVy3HvJu1QS1iDzvG+LnSJd1y/HrN5JxXr5tWVtCdnFH1nmr4RUTaBNEgUKZ+CzY8hOqUjBtVXbvh6QsmAhUsIW+TPH1RcJAt9OulICF8Di0xNSf3GpvC0QT0HQs+ii9+SGH8ZsOul4zDBoKq+WzItAw2eke7vTKooRo7aeO8swyQBSN1LNJ2VRf5xzAsFTDtSQbz80+hbA4CWGG3xthxEHHF4jVQdNe/x7J8rAp3SfBYXNCVz2ELnVEquswW+VXRalrMK/Bu4YcYzRfG2tHS4obLCsL2VboDP+NuecDf4V7gkoahDmVgulTvSX9Al7Tm4Bv56ZxJTMmTUhwhaPV/fPK2yujzDBDWzD1K/LgjDNsj9IIHrEJgdZ00GzBC3j12keJVuFa9fRrO2dd4= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20f88929-6466-4974-c87a-08dc89add284 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2024 00:31:24.0043 (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: SXgQDeq1DAPPCZF4tRzGRByZVOPZPEdGgQdsrx0t4d71I5MA7k9tFT2TX99UASQ5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8565 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240610_174709_875564_CBB7B2EA X-CRM114-Status: GOOD ( 11.25 ) 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. v2: - 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 (10): iommu/arm-smmu-v3: Do not zero the strtab twice iommu/arm-smmu-v3: Shrink the strtab l1_desc array 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 | 319 +++++++++----------- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 103 +++++-- 2 files changed, 211 insertions(+), 211 deletions(-) base-commit: b9f4172f83796c9f0b84e92c912732251bd79b57 Tested-by: Nicolin Chen