Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp529411pxb; Thu, 12 Aug 2021 23:59:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxGkSfO6vgSvZEva5HHTiYPGsfwxjAOaN6tXHGIRK55U5Dv8mqErinSd6v2hQ4xCcbIF0Y X-Received: by 2002:a05:6402:31bc:: with SMTP id dj28mr1212941edb.143.1628837970509; Thu, 12 Aug 2021 23:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628837970; cv=none; d=google.com; s=arc-20160816; b=lZg+JJUNx6aUGMIhSXAaYHUMwmFJdt+PfFZrL3TPAnQVB3fR4WVm5Ymjb25h6hLd3m +iwgZsKwobAznWVUbOa2Fa7Nuqgc1IBVqggVaxWU1z67JgysixCUMV+7ZhvSH4cD998p xQNkT++HgqIFF9uXxD0yBD2Cy78e7wuGelI/fDWEZIC1KO7WXwYlliC84gIwW9FhIkcW VfnZdi9qf1TDtZJzL3h2wlntuvyP1inyg85RTTrF4POeIzQmIP8J+91t88V2f4R15XFR DCuSkX4H56OgDcF3zyeIWuNhLEYvKliQXRwt9foeoZjPRMA37EsmGbiK3mHCgMGTcs2e KnIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ulDQgHw8PYumSb79ejiCSn4hgWbzyWL9WYimyyl1nxk=; b=yTLGD/ZHoUFskI394sNQy0g9KQgWCTs6Ek9ZwRK6qeCPzlkkYA/g9/feYgK9DEp3xf fKXdSP8H1AZMwvv9NNE/kiOqgX7u+Fn74yLDZfBaoG1EPO2WzzjcWBAMG/zjOnYjENMx zFmEq/tZDuvQjbOKeOKuJqjAFuLsFm6dFFLpkLXqy72NqZX9dZJlZx5rQHigCIe1sCZa XjTqg4l+WUZEOq6bwz7bY9ukLUxXNhmvEc44SYNYZuovSnCs5LpI4GtK/DZa79d2hf3V JZC4NFEUygl/k0ryXOjK2wZBPOt/r+2sXwSy1CenzcZKB4MHdFVYVbE06SRmiLUSMyQ1 Q3zw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s5si807097ejd.706.2021.08.12.23.59.07; Thu, 12 Aug 2021 23:59:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239198AbhHMG5f (ORCPT + 99 others); Fri, 13 Aug 2021 02:57:35 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:35340 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S239060AbhHMG5e (ORCPT ); Fri, 13 Aug 2021 02:57:34 -0400 X-UUID: 8fe53ecca5ec4299a855fde4bd5a9cd5-20210813 X-UUID: 8fe53ecca5ec4299a855fde4bd5a9cd5-20210813 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 433459281; Fri, 13 Aug 2021 14:57:05 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 13 Aug 2021 14:57:03 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 13 Aug 2021 14:57:02 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , Matthias Brugger , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v2 25/29] iommu/mediatek: Change the domid to iova_region_id Date: Fri, 13 Aug 2021 14:53:20 +0800 Message-ID: <20210813065324.29220-26-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210813065324.29220-1-yong.wu@mediatek.com> References: <20210813065324.29220-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prepare for adding bankid, also no functional change. In the previous SoC, each a iova_region is a domain; In the multi-banks case, each a bank is a domain; then the original function name "mtk_iommu_get_domain_id" is not proper. the name "iova_region_id" should be proper. this patch only rename the domid to iova_region_id. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 46 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 5b9891b2be6c..29b9ab528774 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -358,8 +358,8 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id) return IRQ_HANDLED; } -static int mtk_iommu_get_domain_id(struct device *dev, - const struct mtk_iommu_plat_data *plat_data) +static int mtk_iommu_get_iova_region_id(struct device *dev, + const struct mtk_iommu_plat_data *plat_data) { const struct mtk_iommu_iova_region *rgn = plat_data->iova_region; const struct bus_dma_region *dma_rgn = dev->dma_range_map; @@ -389,7 +389,7 @@ static int mtk_iommu_get_domain_id(struct device *dev, } static int mtk_iommu_config(struct mtk_iommu_data *data, struct device *dev, - bool enable, unsigned int domid) + bool enable, unsigned int regionid) { struct mtk_smi_larb_iommu *larb_mmu; unsigned int larbid, portid; @@ -405,12 +405,12 @@ static int mtk_iommu_config(struct mtk_iommu_data *data, struct device *dev, if (MTK_IOMMU_IS_TYPE(data->plat_data, MTK_IOMMU_TYPE_MM)) { larb_mmu = &data->larb_imu[larbid]; - region = data->plat_data->iova_region + domid; + region = data->plat_data->iova_region + regionid; larb_mmu->bank[portid] = upper_32_bits(region->iova_base); - dev_dbg(dev, "%s iommu for larb(%s) port %d dom %d bank %d.\n", + dev_dbg(dev, "%s iommu for larb(%s) port %d region %d rgn-bank %d.\n", enable ? "enable" : "disable", dev_name(larb_mmu->dev), - portid, domid, larb_mmu->bank[portid]); + portid, regionid, larb_mmu->bank[portid]); if (enable) larb_mmu->mmu |= MTK_SMI_MMU_EN(portid); @@ -437,7 +437,7 @@ static int mtk_iommu_config(struct mtk_iommu_data *data, struct device *dev, static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom, struct mtk_iommu_data *data, - unsigned int domid) + unsigned int region_id) { const struct mtk_iommu_iova_region *region; struct mtk_iommu_domain *m4u_dom; @@ -476,7 +476,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom, update_iova_region: /* Update the iova region for this domain */ - region = data->plat_data->iova_region + domid; + region = data->plat_data->iova_region + region_id; dom->domain.geometry.aperture_start = region->iova_base; dom->domain.geometry.aperture_end = region->iova_base + region->size - 1; dom->domain.geometry.force_aperture = true; @@ -517,18 +517,18 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, struct mtk_iommu_bank_data *bank; struct device *m4udev = data->dev; unsigned int bankid = 0; - int ret, domid; + int ret, region_id; - domid = mtk_iommu_get_domain_id(dev, data->plat_data); - if (domid < 0) - return domid; + region_id = mtk_iommu_get_iova_region_id(dev, data->plat_data); + if (region_id < 0) + return region_id; bank = &data->bank[bankid]; if (!dom->bank) { /* Data is in the frstdata in sharing pgtable case. */ frstdata = mtk_iommu_get_frst_data(hw_list); - if (mtk_iommu_domain_finalise(dom, frstdata, domid)) + if (mtk_iommu_domain_finalise(dom, frstdata, region_id)) return -ENODEV; dom->bank = bank; } @@ -550,7 +550,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, pm_runtime_put(m4udev); } - return mtk_iommu_config(data, dev, true, domid); + return mtk_iommu_config(data, dev, true, region_id); } static void mtk_iommu_detach_device(struct iommu_domain *domain, @@ -653,21 +653,21 @@ static struct iommu_group *mtk_iommu_device_group(struct device *dev) struct mtk_iommu_data *c_data = dev_iommu_priv_get(dev), *data; struct list_head *hw_list = c_data->hw_list; struct iommu_group *group; - int domid; + int regionid; data = mtk_iommu_get_frst_data(hw_list); if (!data) return ERR_PTR(-ENODEV); - domid = mtk_iommu_get_domain_id(dev, data->plat_data); - if (domid < 0) - return ERR_PTR(domid); + regionid = mtk_iommu_get_iova_region_id(dev, data->plat_data); + if (regionid < 0) + return ERR_PTR(regionid); - group = data->m4u_group[domid]; + group = data->m4u_group[regionid]; if (!group) { group = iommu_group_alloc(); if (!IS_ERR(group)) - data->m4u_group[domid] = group; + data->m4u_group[regionid] = group; } else { iommu_group_ref_get(group); } @@ -700,14 +700,14 @@ static void mtk_iommu_get_resv_regions(struct device *dev, struct list_head *head) { struct mtk_iommu_data *data = dev_iommu_priv_get(dev); - unsigned int domid = mtk_iommu_get_domain_id(dev, data->plat_data), i; + unsigned int regionid = mtk_iommu_get_iova_region_id(dev, data->plat_data), i; const struct mtk_iommu_iova_region *resv, *curdom; struct iommu_resv_region *region; int prot = IOMMU_WRITE | IOMMU_READ; - if ((int)domid < 0) + if ((int)regionid < 0) return; - curdom = data->plat_data->iova_region + domid; + curdom = data->plat_data->iova_region + regionid; for (i = 0; i < data->plat_data->iova_region_nr; i++) { resv = data->plat_data->iova_region + i; -- 2.18.0