Skip to content

Commit bfed873

Browse files
YongWu-HFwilldeacon
authored andcommitted
iommu/mediatek: Support up to 34bit iova in tlb flush
If the iova is 34bit, the iova[32][33] is the bit0/1 in the tlb flush register. Add a new macro for this. In the macro, since (iova + size - 1) may be end with 0xfff, then the bit0/1 always is 1, thus add a mask. Signed-off-by: Yong Wu <yong.wu@mediatek.com> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Link: https://lore.kernel.org/r/20210111111914.22211-22-yong.wu@mediatek.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent c0b5758 commit bfed873

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

drivers/iommu/mtk_iommu.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ static const struct iommu_ops mtk_iommu_ops;
129129

130130
static int mtk_iommu_hw_init(const struct mtk_iommu_data *data);
131131

132+
#define MTK_IOMMU_TLB_ADDR(iova) ({ \
133+
dma_addr_t _addr = iova; \
134+
((lower_32_bits(_addr) & GENMASK(31, 12)) | upper_32_bits(_addr));\
135+
})
136+
132137
/*
133138
* In M4U 4GB mode, the physical address is remapped as below:
134139
*
@@ -213,8 +218,9 @@ static void mtk_iommu_tlb_flush_range_sync(unsigned long iova, size_t size,
213218
writel_relaxed(F_INVLD_EN1 | F_INVLD_EN0,
214219
data->base + data->plat_data->inv_sel_reg);
215220

216-
writel_relaxed(iova, data->base + REG_MMU_INVLD_START_A);
217-
writel_relaxed(iova + size - 1,
221+
writel_relaxed(MTK_IOMMU_TLB_ADDR(iova),
222+
data->base + REG_MMU_INVLD_START_A);
223+
writel_relaxed(MTK_IOMMU_TLB_ADDR(iova + size - 1),
218224
data->base + REG_MMU_INVLD_END_A);
219225
writel_relaxed(F_MMU_INV_RANGE,
220226
data->base + REG_MMU_INVALIDATE);

0 commit comments

Comments
 (0)