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 209F7CE7B09 for ; Fri, 6 Sep 2024 13:19:41 +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:In-Reply-To:Content-Type: MIME-Version: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=VuPwTU/27UOON1ONTzBtL9alWm/q+fqngcVJ18dqXNY=; b=KYvwU6Sw1wdIgnuZp5E1HeA6+T xFVOTjzk1iVTH4T1xkZj837oRd+/lXy7RIEakxavPYbgeakSJyQtx5AJaFbGr+BYx3jVUN47CfJV6 Gn5Eti8a4viyPJb7TR5MafjDBTXxdj3IKiAEDeg6Wrr6RXITiJZ7lCAB7BoJJSgXfSW1k7wzyYi3a SK1Iul862okU++833VwI01evi5xBU/AgKNmFg56eLNgOlTMq7K/Thli2KOU/KQOz16VxVvvGRwyZ4 OZ2nNLh7CdZxWXz2KcmfaP8eATcBJ11y/7KW3yOzZh+LmLQShpvFkTwvFDXfT4+2v2NG2NYTXyE9x +L0EeTjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smYs2-0000000CJfr-03fP; Fri, 06 Sep 2024 13:19:26 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smYr3-0000000CJZX-0QSf for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 13:18:26 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F40475C53AA; Fri, 6 Sep 2024 13:18:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50FD6C4CEC4; Fri, 6 Sep 2024 13:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725628704; bh=UV7AeImDlAj/Nwu2dy05FVBBdDBkx3fFbJyDrO+5LC8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FpmHjSDgm+77T40+tsAbosjA78FZ/fQJdHeYBeXkcJJJmUfvRb+D1/OhfR551dh70 ZGT6eIaSHp473R7saEZwWOLfAXFAgEYLejSz98u69G/HlutLC7xXYV082iCtCiiitl kGtAJ6slDjYhlgbLhjAAV8o5FMT1s2VSxPw7u4VuaNfCSr387jVSNtdYku0jIx/OAf lpysEFYCsXQILsUViOf8NBv34VNxrFTvgBAmBpN8ZuCqwNwCDo2JucnGvHgk8g8ZIX lO/OdBJGybHlC0+119jQpEPhvTh0W/J1m/wSpzFEy6DhG6BuEKQmW6ZdMefVeOrBls glJ4eDnRadg+Q== Date: Fri, 6 Sep 2024 14:18:18 +0100 From: Will Deacon To: Jason Gunthorpe 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: <20240906131818.GA16959@willie-the-truck> References: <0-v3-9fef8cdc2ff6+150d1-smmuv3_tidy_jgg@nvidia.com> <2-v3-9fef8cdc2ff6+150d1-smmuv3_tidy_jgg@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2-v3-9fef8cdc2ff6+150d1-smmuv3_tidy_jgg@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_061825_255852_E11DA8A1 X-CRM114-Status: GOOD ( 21.28 ) 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 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? I applied the whole series, but I struggled looking at the resulting code (of course, there's no "right" way, but the driver is written with whatever I'm used to so I'd really like to keep the consistency). Will