Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp321993pxb; Wed, 11 Nov 2020 04:44:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyIsJyU16emj8xat0rkmuV//y/AxxhLcEuWSafAhU2wBQhd+S3BtM9BVxFfFYaxnMEWaFdN X-Received: by 2002:a17:906:5a8b:: with SMTP id l11mr19326093ejq.99.1605098691394; Wed, 11 Nov 2020 04:44:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605098691; cv=none; d=google.com; s=arc-20160816; b=vUcfB1TaT3Ffh8N3yAwOK/lMeZSv2zDsQYX0N2bZQ8AfRIHwbVan2lp8aelp8lhM4x 6+TqZrGEz1H7WrftYwpqTDehny9XQb3SUBOzQ7nkIrPgb8Un8ST1YO+B0UbtC/e6nDSH Y5BEmx/N3RdwWXsYyyVy5e9Bxhs1MQRyb4vnDd6BYZk9vB2MKnwJ5m0Qdw9DIBS/z2uY o0U+iVJvwjQ1A1mrxzeoyG179JMyD82kHZ0BZt+EM/86a9xklTivG32jrCBQLAHU7VXm mSO9NPB3qlqtsGw7P1hMNp2lgPWej6T5/Wwu5itUFWejjXq8nnxStqWly356oqg0NUL1 HONA== 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=hL6WGheZAHjjxRWG/mhVZRCJUE2b3pBWaHVVM1RPBYA=; b=Txglc/oRfMb61SQsqJvC3o1LJPaarQNmGC2B4fcBjqHe5BeJdf9pFuZHGljLDzXXP2 EvnImKaYpW9mwdzAIYl0WUa27VDJgohX8b/fB89uooMoXozuWH2Ep0ahwwoAUJ1RgrQS /Xf6/pTLmuSxz9IfMsHFc1Gp2Fq1YCuSmCca9vwy5ZbF3/5rvHriyeJFqh+ImrZNf4RN RyROBXFaDgbnCGK+UIWAw1xSQxJfeOayL2ehfAhOJlDzj0pT13nhFvy5F9f3cRD9l/TU qXOmB0NV100zeBK1U44e9IJe2Mmo+fksfvpa541ugwsOIFo6hr8JyFOIMacK3pJ6SJ1q LbEA== 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 w26si1380225edt.596.2020.11.11.04.44.27; Wed, 11 Nov 2020 04:44:51 -0800 (PST) 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 S1726625AbgKKMmF (ORCPT + 99 others); Wed, 11 Nov 2020 07:42:05 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:35284 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726992AbgKKMl7 (ORCPT ); Wed, 11 Nov 2020 07:41:59 -0500 X-UUID: 16aaee729bf843a4905f83eb6dd2a0c0-20201111 X-UUID: 16aaee729bf843a4905f83eb6dd2a0c0-20201111 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1997926858; Wed, 11 Nov 2020 20:41:56 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 11 Nov 2020 20:41:53 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 11 Nov 2020 20:41:53 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Rob Herring , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , , Greg Kroah-Hartman , Subject: [PATCH v4 22/24] iommu/mediatek: Adjust the structure Date: Wed, 11 Nov 2020 20:38:36 +0800 Message-ID: <20201111123838.15682-23-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201111123838.15682-1-yong.wu@mediatek.com> References: <20201111123838.15682-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 Add "struct mtk_iommu_data *" in the "struct mtk_iommu_domain", reduce the call mtk_iommu_get_m4u_data(). No functional change. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index d9a66b2d55e9..355052a98b14 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -125,6 +125,7 @@ struct mtk_iommu_domain { struct io_pgtable_cfg cfg; struct io_pgtable_ops *iop; + struct mtk_iommu_data *data; struct iommu_domain domain; }; @@ -352,7 +353,7 @@ static void mtk_iommu_config(struct mtk_iommu_data *data, static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom) { - struct mtk_iommu_data *data = mtk_iommu_get_m4u_data(); + struct mtk_iommu_data *data = dom->data; /* Use the exist domain as there is only one m4u pgtable here. */ if (data->m4u_dom) { @@ -401,6 +402,7 @@ static struct iommu_domain *mtk_iommu_domain_alloc(unsigned type) if (iommu_get_dma_cookie(&dom->domain)) goto free_dom; + dom->data = data; if (mtk_iommu_domain_finalise(dom)) goto put_dma_cookie; @@ -473,10 +475,9 @@ static int mtk_iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot, gfp_t gfp) { struct mtk_iommu_domain *dom = to_mtk_domain(domain); - struct mtk_iommu_data *data = mtk_iommu_get_m4u_data(); /* The "4GB mode" M4U physically can not use the lower remap of Dram. */ - if (data->enable_4GB) + if (dom->data->enable_4GB) paddr |= BIT_ULL(32); /* Synchronize with the tlb_lock */ @@ -494,31 +495,32 @@ static size_t mtk_iommu_unmap(struct iommu_domain *domain, static void mtk_iommu_flush_iotlb_all(struct iommu_domain *domain) { - mtk_iommu_tlb_flush_all(mtk_iommu_get_m4u_data()); + struct mtk_iommu_domain *dom = to_mtk_domain(domain); + + mtk_iommu_tlb_flush_all(dom->data); } static void mtk_iommu_iotlb_sync(struct iommu_domain *domain, struct iommu_iotlb_gather *gather) { - struct mtk_iommu_data *data = mtk_iommu_get_m4u_data(); + struct mtk_iommu_domain *dom = to_mtk_domain(domain); size_t length = gather->end - gather->start; if (gather->start == ULONG_MAX) return; mtk_iommu_tlb_flush_range_sync(gather->start, length, gather->pgsize, - data); + dom->data); } static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova) { struct mtk_iommu_domain *dom = to_mtk_domain(domain); - struct mtk_iommu_data *data = mtk_iommu_get_m4u_data(); phys_addr_t pa; pa = dom->iop->iova_to_phys(dom->iop, iova); - if (data->enable_4GB && pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE) + if (dom->data->enable_4GB && pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE) pa &= ~BIT_ULL(32); return pa; -- 2.18.0