Commit 08500c43 authored by Yong Wu's avatar Yong Wu Committed by Will Deacon

iommu/mediatek: Adjust the structure

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: default avatarYong Wu <yong.wu@mediatek.com>
Reviewed-by: default avatarTomasz Figa <tfiga@chromium.org>
Link: https://lore.kernel.org/r/20210111111914.22211-24-yong.wu@mediatek.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
parent ef0f0986
...@@ -126,6 +126,7 @@ struct mtk_iommu_domain { ...@@ -126,6 +126,7 @@ struct mtk_iommu_domain {
struct io_pgtable_cfg cfg; struct io_pgtable_cfg cfg;
struct io_pgtable_ops *iop; struct io_pgtable_ops *iop;
struct mtk_iommu_data *data;
struct iommu_domain domain; struct iommu_domain domain;
}; };
...@@ -351,6 +352,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom) ...@@ -351,6 +352,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom)
return -EINVAL; return -EINVAL;
} }
dom->data = data;
/* Update our support page sizes bitmap */ /* Update our support page sizes bitmap */
dom->domain.pgsize_bitmap = dom->cfg.pgsize_bitmap; dom->domain.pgsize_bitmap = dom->cfg.pgsize_bitmap;
return 0; return 0;
...@@ -442,10 +444,9 @@ static int mtk_iommu_map(struct iommu_domain *domain, unsigned long iova, ...@@ -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) phys_addr_t paddr, size_t size, int prot, gfp_t gfp)
{ {
struct mtk_iommu_domain *dom = to_mtk_domain(domain); 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. */ /* 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); paddr |= BIT_ULL(32);
/* Synchronize with the tlb_lock */ /* Synchronize with the tlb_lock */
...@@ -468,36 +469,37 @@ static size_t mtk_iommu_unmap(struct iommu_domain *domain, ...@@ -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) 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, static void mtk_iommu_iotlb_sync(struct iommu_domain *domain,
struct iommu_iotlb_gather *gather) 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; size_t length = gather->end - gather->start + 1;
mtk_iommu_tlb_flush_range_sync(gather->start, length, gather->pgsize, 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, static void mtk_iommu_sync_map(struct iommu_domain *domain, unsigned long iova,
size_t size) 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, static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,
dma_addr_t iova) dma_addr_t iova)
{ {
struct mtk_iommu_domain *dom = to_mtk_domain(domain); struct mtk_iommu_domain *dom = to_mtk_domain(domain);
struct mtk_iommu_data *data = mtk_iommu_get_m4u_data();
phys_addr_t pa; phys_addr_t pa;
pa = dom->iop->iova_to_phys(dom->iop, iova); 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); pa &= ~BIT_ULL(32);
return pa; return pa;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment