Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2188679pxb; Mon, 11 Jan 2021 03:25:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJx52Jfe47Cu/Omk+KmNamrsHiqUVbDo8Iy7B0DGoKGyl/gLV01V8Nq7PAaLSsJN5Xt0UWuJ X-Received: by 2002:a17:906:5495:: with SMTP id r21mr10532033ejo.59.1610364345621; Mon, 11 Jan 2021 03:25:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610364345; cv=none; d=google.com; s=arc-20160816; b=ZyYbSblJyXvlqb5OqdurMXnGzsyjyARiVdIfXsXdv3WdSx4A2ojiWNfywSyVje2PLY +kYZ4wbdN4Shw2nnEh0CpFNndnwrWXlIi+DhGA93MsD5zwlyhTWcKGTa3BAb1oJHjoXC InPAjd2lYsfnJSNfw7pN8GXjFcXvqTNMQnE/4DBr80/M2jmR14dIDhU+1b9PVwzpx9rX 0tj7zdrogXR55dNPpkHAjcRSmbh2KJK+KnbNdpwJKy6QcrR1RCUkXfO+CjCf3CPaEyg8 5uGnyc8DFpQQu23bA1dZuKGm2fQyIQnGFLNgRZFxNwGONBj76+3eLWIH1Jkflmm8wEb+ fKOw== 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=YMiGdH/2pWKqXIoFx8AhcZnZBIT6nzJRaxVX8GWWTBk=; b=ZiZt7zh2ezagqL72e03aTpVC6W5W0RHlcwtVBCcj3Lm5GOn/HLQKskF6UuQs/JwRpy jJU2RuaBqZaLWZKPqTAXV4t33oGT+dHLr0uICF3RXI4Um4s2PMPkxtJe4amwZJC1HqDN 8OqAg77Co23BNEDkFqi5+1DDaRINLjiQnfVqeGj1oy/1t7L+ni6CRbmd7xkJndtKSz30 T2UCmsamndwfGnJJ8OywG/ndwRHaI1LO2I+C1TGfgSuNSYXoTnGxJ6f3SGcp3c0y+U/1 mkE+/IuhlJeYFcb0tCgx1JR+I6MBSYfLFUEgYsrcR053zHdCJ+zxQGT2fhkoeZjmU4Aq 6Fxw== 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 z14si6354631ejb.299.2021.01.11.03.25.22; Mon, 11 Jan 2021 03:25:45 -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 S1729961AbhAKLX1 (ORCPT + 99 others); Mon, 11 Jan 2021 06:23:27 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:60030 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729650AbhAKLX1 (ORCPT ); Mon, 11 Jan 2021 06:23:27 -0500 X-UUID: 63f5b0ea17d74a5197650fe61cd2cc22-20210111 X-UUID: 63f5b0ea17d74a5197650fe61cd2cc22-20210111 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] 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 1442642753; Mon, 11 Jan 2021 19:23:03 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 11 Jan 2021 19:23:02 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 11 Jan 2021 19:23:01 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , Matthias Brugger , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v6 23/33] iommu/mediatek: Adjust the structure Date: Mon, 11 Jan 2021 19:19:04 +0800 Message-ID: <20210111111914.22211-24-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210111111914.22211-1-yong.wu@mediatek.com> References: <20210111111914.22211-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 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index f3666b0d7577..f1941608ccb7 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -126,6 +126,7 @@ struct mtk_iommu_domain { struct io_pgtable_cfg cfg; struct io_pgtable_ops *iop; + struct mtk_iommu_data *data; struct iommu_domain domain; }; @@ -351,6 +352,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom) return -EINVAL; } + dom->data = data; /* Update our support page sizes bitmap */ dom->domain.pgsize_bitmap = dom->cfg.pgsize_bitmap; return 0; @@ -442,10 +444,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 */ @@ -468,36 +469,37 @@ 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 + 1; mtk_iommu_tlb_flush_range_sync(gather->start, length, gather->pgsize, - data); + dom->data); } static void mtk_iommu_sync_map(struct iommu_domain *domain, unsigned long iova, size_t size) { - struct mtk_iommu_data *data = mtk_iommu_get_m4u_data(); + struct mtk_iommu_domain *dom = to_mtk_domain(domain); - mtk_iommu_tlb_flush_range_sync(iova, size, size, data); + mtk_iommu_tlb_flush_range_sync(iova, size, size, 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