From patchwork Tue Aug 8 17:12:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shavit X-Patchwork-Id: 132788 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2340726vqr; Tue, 8 Aug 2023 12:15:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsP+ADi/mU6bgtjmlQNS5X4SsSTGtn/B0EWstZIGxDVNZa2gVNlxQYvbTo/0joQoHiG330 X-Received: by 2002:a17:906:108:b0:99b:44aa:fae0 with SMTP id 8-20020a170906010800b0099b44aafae0mr387575eje.21.1691522106939; Tue, 08 Aug 2023 12:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691522106; cv=none; d=google.com; s=arc-20160816; b=kG6XXN+5uvUmQeMAYJi4MnO/dKWnLbGxkqINp191Q9Nzb2/1WEG8+u/SYYh2pU0WJs reRvEw41datGhlsq9TzWGnZn3KWyPUyO4iuYYrfWP4OrQzzd4UH81O+CkyDSMx3sj45C IHE0m8+pQGx/yVOSu91PMCyYhsUAn+STQ9D8ynYjXaUe+oONKWc2eH+G/gzESN72v6Ts o7XzzIzZytG9g7dgWzENEqRULRuJKCtbeFbmImjTis7j1SB6hUdhU/sjbuwCE4L2KOwX i05r8UXVxq2GzUIpR0fwZbbdD3AZAgnV2ADvuTVr4Uh0pNnSYheq1xPIbG6gFJp9RR64 6bJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=oeLSMOOGvL9cO3G8G5G5v8LLBetvrU+vq+cAagyUyl8=; fh=51loh+OS6vr0QdvTi7t7xEP2VSRDvSfeMVfkb8abBBs=; b=ZPOaJPQXHMym+0/WikmCYtZsap7iQOUT4YIzFInYVRO0/PeRpeExqVo1sIrISEljZx fzi7eVxq3Foxh48g/YKfNsbZZVccweBy12rB0TcOeB78l+8D3SAH3VNOeQNRiAryYJcD /VoiBCymPFghkkQfuCGpEV/KjVTTl7IhBybzEOzzUQGGyOntIj8gDEkA90UBwIUDHS4e C5DPMVVjGBQCHgB1eMIEGFpWnlMpbJpaI87QjrXSXGSrPHoLBGDlGtNRvCS2WblYhUO1 CAG1DpKiWMYPKSAma1rigPOFUyavSZbd5JUZ3DWIqGPLG//IJGyxu+8LtMIbJvC9mzpe DyiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=njzC62ov; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a170906178700b0099cb798de6esi5897971eje.135.2023.08.08.12.14.40; Tue, 08 Aug 2023 12:15:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=njzC62ov; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231573AbjHHS5X (ORCPT + 99 others); Tue, 8 Aug 2023 14:57:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231418AbjHHS4r (ORCPT ); Tue, 8 Aug 2023 14:56:47 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E2021D043 for ; Tue, 8 Aug 2023 10:15:37 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-585f254c41aso69438487b3.1 for ; Tue, 08 Aug 2023 10:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691514936; x=1692119736; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=oeLSMOOGvL9cO3G8G5G5v8LLBetvrU+vq+cAagyUyl8=; b=njzC62ovLLfM2KxOGhwyeZ8Qka978mzw0kBCsOl1hL2xkVyqyFT2ivyrjY+v4/5KHb RaSJFTGmWLuNpAev2OAHSfd+a5jG6kZGOQmRj7m/w1WAT129c9IIEkvP4K3f6ZQd7QTJ MPvs4HcDv4e7Hn52LQxS7zlw9T2pFmV5aps0z74KRuQmefy62CCE28TS2jmozF32gIfz 1A+TDvawajYrLI/KtknfJkDFhA8Qp/XP+zu8Ol76lj/TVXilNH6XTpQeIhqfBJCamaTf oLdQ/0LXTgdHc/8cbV0xNZgt7/vgYN9SKl6hgfrkyiXjvVTMTQ9BU+8NFAU96J3WjN4C fQMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691514936; x=1692119736; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oeLSMOOGvL9cO3G8G5G5v8LLBetvrU+vq+cAagyUyl8=; b=GxllE02Y387Lhqj19DRnHCSli7N1hXsRoiLBUmec9FhFRpRyPUmytHuEIU51Xl3ZDe 9LSTZ0If6CfCIkpWs7Xkv5goWHnXc8llEYtdcoddBICdtMHCO5U33nmdaZ2m7J7oENAd 2WyGNRE5gKA+0gZt+/0H0LAZRfdUVFljBrpEoPhP3nnIFrIWdBJk7/5vrJOrLYv+cwnC LZBYtr8q1OI7eUkhDkAyBuPAXzKQRMhMTiuM4V8xU+7mYBIX6dR3wgA6VnV6dJBe5ZOm oOGIilffNAlQClb8K4KC7ypAu8KB1MbtMxBry2axmShgEEtpcIKf9blE++ZvS0KzxMAY X4hA== X-Gm-Message-State: AOJu0Yw6yg4pJPbiRypSBssbrBmwDA8BfrMREJgfFth64bhMbS4m0WxG I0mB5TUZgxzkaslmnIwCGyD3ltkvSJVC X-Received: from mshavit.ntc.corp.google.com ([2401:fa00:95:20c:986a:71d7:3b1e:ac1d]) (user=mshavit job=sendgmr) by 2002:a81:ac66:0:b0:583:529d:1b9d with SMTP id z38-20020a81ac66000000b00583529d1b9dmr4111ywj.5.1691514936613; Tue, 08 Aug 2023 10:15:36 -0700 (PDT) Date: Wed, 9 Aug 2023 01:12:05 +0800 In-Reply-To: <20230808171446.2187795-1-mshavit@google.com> Mime-Version: 1.0 References: <20230808171446.2187795-1-mshavit@google.com> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog Message-ID: <20230809011204.v5.9.I5ee79793b444ddb933e8bc1eb7b77e728d7f8350@changeid> Subject: [PATCH v5 9/9] iommu/arm-smmu-v3: Rename cdcfg to cd_table From: Michael Shavit To: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: will@kernel.org, robin.murphy@arm.com, nicolinc@nvidia.com, jgg@nvidia.com, jean-philippe@linaro.org, Michael Shavit X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773689485132053627 X-GMAIL-MSGID: 1773689485132053627 cdcfg is a confusing name, especially given other variables with the cfg suffix in this driver. cd_table more clearly describes what is being operated on. Reviewed-by: Jason Gunthorpe Reviewed-by: Nicolin Chen Signed-off-by: Michael Shavit --- (no changes since v3) Changes in v3: - Commit message update Changes in v2: - New commit drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 66 ++++++++++----------- 1 file changed, 33 insertions(+), 33 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 488d12dd2d4aa..e29e548776c1d 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -1028,18 +1028,18 @@ static __le64 *arm_smmu_get_cd_ptr(struct arm_smmu_master *master, u32 ssid) unsigned int idx; struct arm_smmu_l1_ctx_desc *l1_desc; struct arm_smmu_device *smmu = master->smmu; - struct arm_smmu_ctx_desc_cfg *cdcfg = &master->cd_table; + struct arm_smmu_ctx_desc_cfg *cd_table = &master->cd_table; - if (!cdcfg->l1_desc) - return cdcfg->cdtab + ssid * CTXDESC_CD_DWORDS; + if (!cd_table->l1_desc) + return cd_table->cdtab + ssid * CTXDESC_CD_DWORDS; idx = ssid >> CTXDESC_SPLIT; - l1_desc = &cdcfg->l1_desc[idx]; + l1_desc = &cd_table->l1_desc[idx]; if (!l1_desc->l2ptr) { if (arm_smmu_alloc_cd_leaf_table(smmu, l1_desc)) return NULL; - l1ptr = cdcfg->cdtab + idx * CTXDESC_L1_DESC_DWORDS; + l1ptr = cd_table->cdtab + idx * CTXDESC_L1_DESC_DWORDS; arm_smmu_write_cd_l1_desc(l1ptr, l1_desc); /* An invalid L1CD can be cached */ arm_smmu_sync_cd(master, ssid, false); @@ -1134,33 +1134,33 @@ static int arm_smmu_alloc_cd_tables(struct arm_smmu_master *master) size_t l1size; size_t max_contexts; struct arm_smmu_device *smmu = master->smmu; - struct arm_smmu_ctx_desc_cfg *cdcfg = &master->cd_table; + struct arm_smmu_ctx_desc_cfg *cd_table = &master->cd_table; - cdcfg->stall_enabled = master->stall_enabled; - cdcfg->max_cds_bits = master->ssid_bits; - max_contexts = 1 << cdcfg->max_cds_bits; + cd_table->stall_enabled = master->stall_enabled; + cd_table->max_cds_bits = master->ssid_bits; + max_contexts = 1 << cd_table->max_cds_bits; if (!(smmu->features & ARM_SMMU_FEAT_2_LVL_CDTAB) || max_contexts <= CTXDESC_L2_ENTRIES) { - cdcfg->num_l1_ents = max_contexts; + cd_table->num_l1_ents = max_contexts; l1size = max_contexts * (CTXDESC_CD_DWORDS << 3); } else { - cdcfg->num_l1_ents = DIV_ROUND_UP(max_contexts, + cd_table->num_l1_ents = DIV_ROUND_UP(max_contexts, CTXDESC_L2_ENTRIES); - cdcfg->l1_desc = devm_kcalloc(smmu->dev, cdcfg->num_l1_ents, - sizeof(*cdcfg->l1_desc), + cd_table->l1_desc = devm_kcalloc(smmu->dev, cd_table->num_l1_ents, + sizeof(*cd_table->l1_desc), GFP_KERNEL); - if (!cdcfg->l1_desc) + if (!cd_table->l1_desc) return -ENOMEM; - l1size = cdcfg->num_l1_ents * (CTXDESC_L1_DESC_DWORDS << 3); + l1size = cd_table->num_l1_ents * (CTXDESC_L1_DESC_DWORDS << 3); } - cdcfg->cdtab = dmam_alloc_coherent(smmu->dev, l1size, &cdcfg->cdtab_dma, + cd_table->cdtab = dmam_alloc_coherent(smmu->dev, l1size, &cd_table->cdtab_dma, GFP_KERNEL); - if (!cdcfg->cdtab) { + if (!cd_table->cdtab) { dev_warn(smmu->dev, "failed to allocate context descriptor\n"); ret = -ENOMEM; goto err_free_l1; @@ -1169,9 +1169,9 @@ static int arm_smmu_alloc_cd_tables(struct arm_smmu_master *master) return 0; err_free_l1: - if (cdcfg->l1_desc) { - devm_kfree(smmu->dev, cdcfg->l1_desc); - cdcfg->l1_desc = NULL; + if (cd_table->l1_desc) { + devm_kfree(smmu->dev, cd_table->l1_desc); + cd_table->l1_desc = NULL; } return ret; } @@ -1181,30 +1181,30 @@ static void arm_smmu_free_cd_tables(struct arm_smmu_master *master) int i; size_t size, l1size; struct arm_smmu_device *smmu = master->smmu; - struct arm_smmu_ctx_desc_cfg *cdcfg = &master->cd_table; + struct arm_smmu_ctx_desc_cfg *cd_table = &master->cd_table; - if (cdcfg->l1_desc) { + if (cd_table->l1_desc) { size = CTXDESC_L2_ENTRIES * (CTXDESC_CD_DWORDS << 3); - for (i = 0; i < cdcfg->num_l1_ents; i++) { - if (!cdcfg->l1_desc[i].l2ptr) + for (i = 0; i < cd_table->num_l1_ents; i++) { + if (!cd_table->l1_desc[i].l2ptr) continue; dmam_free_coherent(smmu->dev, size, - cdcfg->l1_desc[i].l2ptr, - cdcfg->l1_desc[i].l2ptr_dma); + cd_table->l1_desc[i].l2ptr, + cd_table->l1_desc[i].l2ptr_dma); } - devm_kfree(smmu->dev, cdcfg->l1_desc); - cdcfg->l1_desc = NULL; + devm_kfree(smmu->dev, cd_table->l1_desc); + cd_table->l1_desc = NULL; - l1size = cdcfg->num_l1_ents * (CTXDESC_L1_DESC_DWORDS << 3); + l1size = cd_table->num_l1_ents * (CTXDESC_L1_DESC_DWORDS << 3); } else { - l1size = cdcfg->num_l1_ents * (CTXDESC_CD_DWORDS << 3); + l1size = cd_table->num_l1_ents * (CTXDESC_CD_DWORDS << 3); } - dmam_free_coherent(smmu->dev, l1size, cdcfg->cdtab, cdcfg->cdtab_dma); - cdcfg->cdtab_dma = 0; - cdcfg->cdtab = NULL; + dmam_free_coherent(smmu->dev, l1size, cd_table->cdtab, cd_table->cdtab_dma); + cd_table->cdtab_dma = 0; + cd_table->cdtab = NULL; } bool arm_smmu_free_asid(struct arm_smmu_ctx_desc *cd)