Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp504635pxb; Thu, 23 Sep 2021 05:06:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9lLBEyPRobaCzdBqX6+dAOQIIYFAv+pqrSbuxuU8pMjYo8dhaThk1ykUYLa2amnqDopuy X-Received: by 2002:a17:906:dbf0:: with SMTP id yd16mr4503594ejb.445.1632398782803; Thu, 23 Sep 2021 05:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632398782; cv=none; d=google.com; s=arc-20160816; b=pIuhvyn+pC/kG5jp0BFrNvC6U64lGMK4V9M1ja4POcQjjJq4Yzqscp/0u/D9dYCGWR Czo6j/5LNkPb63Ho33LP/0WsZXLU3JdidmgNVKwpp3ePinWltu0j6sqW9+xFrLXWBySU cHDlZ6AnVoszFgLPuWM2X5OM3/FqvjMFaSZ2Ni3TtNdm0bzee6KrY2ibDhggbhg6Luwp v2FyO9A0+d+CuruCgS+y0dkrnnpVj16uXIEWe1p+QnFzIDqoZxotM1d5qQ6SQkri0tSj iYp7Ir+x/cJ1A2aKzHxkmcwZwRa6RzxHr/i4mlhdOnEoSxulRZF783VcevDwDfJ3RMh3 AtfQ== 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=QMzJOxuN9i5HREMFvq5XBWfqcKLhN04AcnHen4PxkGg=; b=ij3dNP1y7bmPuEIOHhMXniZCFJcXXS03yE4kMOdhisj6CFAds2OPtfp0UAjdLL4e3r pj1p58SRCm4TMKIQriiujF6dXTEqC0rTsXswq7cyPPZis81sw5YWvQUkoduCuCSGH+/D 4dSVygMvJbIlfNcFy92uZ6KFuG2PQGeAwxuxMuxw/Ged1bzFb8VhB0y43NilCb+j4L7F DYBbFpcHMVkCZ+TONGMvQV88tM8cubPYiEF4LIna0togrYLooM4H6XwX/zEDGw3eVVxH wb7g34Eiye06ysgf8cdbrODvI2oqzcYhTtxhvSO+GdpFBjQqL7haWXey5XICUzOmLdOj bJVA== 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 co20si5808651edb.155.2021.09.23.05.05.57; Thu, 23 Sep 2021 05:06:22 -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 S240965AbhIWMFM (ORCPT + 99 others); Thu, 23 Sep 2021 08:05:12 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:55220 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S240764AbhIWME7 (ORCPT ); Thu, 23 Sep 2021 08:04:59 -0400 X-UUID: 528a6913d7024b8a95124eb34e0934f9-20210923 X-UUID: 528a6913d7024b8a95124eb34e0934f9-20210923 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 605618681; Thu, 23 Sep 2021 20:03:25 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 23 Sep 2021 20:03:24 +0800 Received: from localhost.localdomain (10.17.3.154) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 23 Sep 2021 20:03:23 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , Matthias Brugger , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Tomasz Figa , , , , , , , Hsin-Yi Wang , , , , , Subject: [PATCH v3 29/33] iommu/mediatek: Change the domid to iova_region_id Date: Thu, 23 Sep 2021 19:58:36 +0800 Message-ID: <20210923115840.17813-30-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210923115840.17813-1-yong.wu@mediatek.com> References: <20210923115840.17813-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. Use "iova_region_id" instead of "domain_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 4ad85469f68f..6e3f7b97f3f5 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -352,8 +352,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; @@ -383,7 +383,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; @@ -399,12 +399,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); @@ -430,7 +430,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; @@ -469,7 +469,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; @@ -504,18 +504,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; } @@ -537,7 +537,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, @@ -636,21 +636,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); } @@ -683,14 +683,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