From mboxrd@z Thu Jan 1 00:00:00 1970 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 BB1F0CE7B1D for ; Fri, 6 Sep 2024 14:45:05 +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:In-Reply-To: Content-Type:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WTnHjf0eu+420y5ALFehvk3+p0Y83kCi7OAzUGXIkOc=; b=mFktsQMSbMsRXHc2YJpCXApaL7 xexMuo+teDsa643UMflttlDXnY1KnF4cX2cothHOEpu5Fhv0L/clDd9tSy1EUgKHULsOLmtHwI0uN 8oN84NSChfiZ2R4dAQpX74azB45AB6PZvZ8m0g3NT9NX3DztKSqD7sjt9dx8R7qUzAZPsfVLtCpqr rLKdQANII0LYFXJNIRyCwshgIJZ8nv784HSxGzePudGbqdNe06GC/Njp70SLNl6Y53u73uTYd/CBi b/mgIyG4ZpMkWnfN0pbPttw5rzKzfI8TLJpSGAp4m/FLufaDmTUNL4groSIErCkS4ZoV1AOANFUq1 r2RSUIuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smaCj-0000000CasJ-1E2P; Fri, 06 Sep 2024 14:44:53 +0000 Received: from mail-bn7nam10on20625.outbound.protection.outlook.com ([2a01:111:f403:2009::625] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sma8f-0000000CZuk-2RqU for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 14:40:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Tlp5lK4nxFDiIjaXnST7YrV81h+xcZqKTLF6QKsfnvTHLCaBRMmfVV9EIvvn7hx7rcemz9qVNSinx4fbQmHNLhniVVXPr5zgoRmbhHjpvtMrHNotq1UEMjs/QJoGY3fBo0egAK5rbVC0jM5wcMKKZYsok1QSEVAotsWeSVmqwVhGHY2SmJZaZ8ZrCrRa0vpYKTW1kEUEqG9tcNzod11BlIFj1bHbf2EIaCgYj0b6b/9nIK2FKQln79jYbjcc01m+XxX6uEEj7Q1bQJLIB4zYwOH8ZM32+Al0tzGNgN+ucRGqqIedKzNXNXv9Q1m0RqOici5PtfXV2YZc9nzjLRjD1g== 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=WTnHjf0eu+420y5ALFehvk3+p0Y83kCi7OAzUGXIkOc=; b=ZPeLNW4JpwwP6Xw+Y85eEZkGTf3SfCI8NeY4lX3A9lJH2hERgvXrl6PHE2pAEweD5QCe2VgWphJRqvjBlObXW1echaDUC3ZPHO3oBTI/McxBklUsdSKcqexYecDWQL4S05BpRb61JPbHY8eyCIhayaTk3y+H7EHUhvIoV1n0BLZiy0svUGnuS1WglP/elGIEqu3mXPiaT3p+ZgMVcLdo1oO2Ylice/ypsue/VZieZ6T1o549QzLtR9vfUwwqNfu+645w15qLlL7Wq4ot0xu2IHSuO3eGhiNVHpuHwNwwSED9id+KNnRi0H96l5zU+cQQw2bXvLjffPbKRfIBAf0few== 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=WTnHjf0eu+420y5ALFehvk3+p0Y83kCi7OAzUGXIkOc=; b=hsGPfQkD8+22csfLDwZEa5WxpELKE93aVZPKbTwspwy3j9hfNZtlVQdokYsyVl6wTJx1vJOh0naNYYkxWt4sxXNDxWJ+1vszQHgEP7UYKnLiTHnY/TQ+VUl6c2ZKDtfIeYwlfqDRVjoI5f4qGeE4jsfsnIOqVq+9hGCxdmC09bKudrL/dyrq23IbIfYS06pXYl5ZNbBz92YoYxu/xtnCB7vcdBxsMnGYPzQk9sph/AEXQ6aBY6nC/VMj1gJL5YAnL3uh/tdJsGICmT2rsSauTXoVGYBujvD/FkQT4oKUREW15DgLCfpYXaXw8PiOdX6hh5uuvTH5rdijLuTKqlxi9A== 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 IA1PR12MB6306.namprd12.prod.outlook.com (2603:10b6:208:3e6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Fri, 6 Sep 2024 14:40:22 +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.7918.024; Fri, 6 Sep 2024 14:40:22 +0000 Date: Fri, 6 Sep 2024 11:40:20 -0300 From: Jason Gunthorpe To: Will Deacon Cc: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Ryan Roberts , Mostafa Saleh Subject: Re: [PATCH v3 2/9] iommu/arm-smmu-v3: Add arm_smmu_strtab_l1/2_idx() Message-ID: <20240906144020.GI1358970@nvidia.com> References: <0-v3-9fef8cdc2ff6+150d1-smmuv3_tidy_jgg@nvidia.com> <2-v3-9fef8cdc2ff6+150d1-smmuv3_tidy_jgg@nvidia.com> <20240906131818.GA16959@willie-the-truck> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240906131818.GA16959@willie-the-truck> X-ClientProxiedBy: MN2PR19CA0005.namprd19.prod.outlook.com (2603:10b6:208:178::18) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|IA1PR12MB6306:EE_ X-MS-Office365-Filtering-Correlation-Id: c088926c-c93e-41b4-27ab-08dcce81d635 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?fUbTGT2EVb4VX4im9XROtm79A/AUSaHujs3qhuqYqw738Q07XFogk6hzqJzs?= =?us-ascii?Q?jMObyxP6o/CvfZShtPBDgOOTxIG8/J0bPKjWc4hjstpNyC30ZSX0KdpOJ1kE?= =?us-ascii?Q?/E0r22/DD8fyzXyof1KWvFnKxbweUt7EB/G6HakpEQTDTwe4tXPqxPccBJZv?= =?us-ascii?Q?UBYhEoMpC4yuXZ7aCnV782ZGVg/w0eKY0hqy/JG13wkeNkwcAAd/dDheBUjW?= =?us-ascii?Q?lY1S51Gl6fRayuPpfTiy7ri0kpndxKPYwkLYFU7JkK4mCNkIOoLsWyMHdaaa?= =?us-ascii?Q?NTqp+mbRasHb717iZPVB0VXw1X1olxvIE0XzKvDmDtOdUq2IxpsRCBs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10L+CB2jjCoJJ3F002T6bkOXc013r?= =?us-ascii?Q?Jc2hytzlz+lsiiiT8gK8RQxsc0GJ30WBon01fPGEvhB2isoe2w+vRtIdK80L?= =?us-ascii?Q?ElkEj64Zjpd/4qN0SorzAxk/pwZ7peWBdOSsCbqLECxZlQ=3D=3D?= 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)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ZklrMdk3tZIX0Ipv1Ah+6LU/oh5hnAqB+a3wAI8iJYmN6+WjTlN+yemz+Y97?= =?us-ascii?Q?/hZT2zacWvp4vstl5JIuGpdWVveKKw6gnQWhAuw+DLH+jN19agz49P0iL1W+?= =?us-ascii?Q?ayG88ee6d6veItCkJijxW0Epvj2HyAKbJ9shOebk4VSebFoUNVzkn2kJbKEK?= =?us-ascii?Q?cZQ0zIt1vVP3VP0mrQsIrFbfobqrxokuewdoUf3Yxv+xCbsWZhCdfgZXHcvO?= =?us-ascii?Q?wkut9uriZFC18q2gsn1UbAzp1mQvToxDPUDPNxColo/g4c41Bgo2rPSe+y/U?= =?us-ascii?Q?9Z3VpsYvoD2XioVORzozNNHYyDI3npWQgAmBAGIC2b6DqoLsSemeHIsrh0Bk?= =?us-ascii?Q?B9OdmNz0jZyXxUaU9mTQfwIReiBDcuS7Zcthc1GORVPl1ByTByy5NjaYCPr1?= =?us-ascii?Q?AqPf+72jShE4raz9mI5t/QYgEbJ4c1WxyBd59bi9py4af75vMPMsj0uoszCb?= =?us-ascii?Q?eGBdm5t3xKxfLO3C45NxlQIiswSNvAxejcMZgQRfmJsmNWP9Suj2wuq/jSTZ?= =?us-ascii?Q?oH1MQZ8mBo02dzHsXJe5mIucIBU0M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ascii?Q?rWd0W95Nj8qWuhhV9ElPZo11Dsu/CRde7HFdKA6Pok88sCJemgULyP/IdqfD?= =?us-ascii?Q?2or3ifX0afv92spYIjvXRzuaPIyQ0DB16TbAbjZbsMeW0WfUKs8mnQ0iD0+1?= =?us-ascii?Q?APWiAeT2ay2gghnKmfaHZ32ySgQ1w/dbExghh8/A?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c088926c-c93e-41b4-27ab-08dcce81d635 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB7763.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 14:40:22.1154 (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: 4nmaG+os46FUUdAlIFdB99P7s27eIQ8VZT6JGhh8pAV+BfrFGqUm4PQhe23eI9hg X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6306 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_074041_691514_6702D03A X-CRM114-Status: GOOD ( 27.38 ) 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 On Fri, Sep 06, 2024 at 02:18:18PM +0100, Will Deacon wrote: > On Tue, Aug 06, 2024 at 08:31:16PM -0300, Jason Gunthorpe wrote: > > Don't open code the calculations of the indexes for each level, provide > > two functions to do that math and call them in all the places. Update all > > the places computing indexes. > > > > Calculate the L1 table size directly based on the max required index from > > the cap. Remove STRTAB_L1_SZ_SHIFT in favour of STRTAB_NUM_L2_STES. > > > > Use STRTAB_NUM_L2_STES to replace remaining open coded 1 << STRTAB_SPLIT. > > > > Tested-by: Nicolin Chen > > Reviewed-by: Nicolin Chen > > Signed-off-by: Jason Gunthorpe > > --- > > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 51 +++++++++------------ > > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 14 +++++- > > 2 files changed, 35 insertions(+), 30 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 b80f3359a8d12b..a695e5f8fc2880 100644 > > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > > @@ -1670,20 +1670,17 @@ static void arm_smmu_init_initial_stes(struct arm_smmu_ste *strtab, > > > > static int arm_smmu_init_l2_strtab(struct arm_smmu_device *smmu, u32 sid) > > { > > - size_t size; > > - void *strtab; > > dma_addr_t l2ptr_dma; > > struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg; > > - struct arm_smmu_strtab_l1_desc *desc = &cfg->l1_desc[sid >> STRTAB_SPLIT]; > > + struct arm_smmu_strtab_l1_desc *desc = > > + &cfg->l1_desc[arm_smmu_strtab_l1_idx(sid)]; > > > > if (desc->l2ptr) > > return 0; > > > > - size = 1 << (STRTAB_SPLIT + ilog2(STRTAB_STE_DWORDS) + 3); > > - strtab = &cfg->strtab[(sid >> STRTAB_SPLIT) * STRTAB_L1_DESC_DWORDS]; > > - > > - desc->l2ptr = dmam_alloc_coherent(smmu->dev, size, &l2ptr_dma, > > - GFP_KERNEL); > > + desc->l2ptr = dmam_alloc_coherent( > > + smmu->dev, STRTAB_NUM_L2_STES * sizeof(struct arm_smmu_ste), > > + &l2ptr_dma, GFP_KERNEL); > > Since this series is mainly about clean-up, please can you be consistent > with the indentation style that the driver currently uses for multi-line > function invocations? Honestly, I don't know what that style is.. I try to stick with a common style from clang-format using the checked-in specs. I touch so many drivers and so many subsystems it is a big ask to memorize everyone's little preferences and adjust things. I feel there is no way I could do that reliably.. Still, if you have some specific things that really bother you then please let me know them? I can make an effort, and/or you can adjust them when applying? For instance I have already been mindful to try to keep the vertical alignment in some places. I'm guessing you are looking at aligning the argument wrap to the ( ? To explain - clang-format has a heuristic for this. If the code formats nicely it will align to the (. For instance this proposed change to fit into 80 cols: - cd_table->cdtab = dmam_alloc_coherent(smmu->dev, l1size, &cd_table->cdtab_dma, - GFP_KERNEL); + cd_table->cdtab = dmam_alloc_coherent(smmu->dev, l1size, + &cd_table->cdtab_dma, GFP_KERNEL); However, the hunk you clipped above doesn't fit nicely because the argument 'STRTAB_NUM_L2_STES * sizeof(struct arm_smmu_ste)' would push past the 80 col limit if aligned to the (. Rather than break an argument in the middle of an expression, or go past 80 cols, it switches to one tab and keeps the argument expression together on one line. So, which alternative is your preference? > I applied the whole series, It seems not? Thanks, Jason