Skip to content

Commit 585e58f

Browse files
YongWu-HFwilldeacon
authored andcommitted
iommu/mediatek: Add iova_region structure
Add a new structure for the iova_region. Each a region will be a independent iommu domain. For the previous SoC, there is single iova region(0~4G). For the SoC that need support multi-domains, there will be several regions. Signed-off-by: Yong Wu <[email protected]> Reviewed-by: Tomasz Figa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent b7875eb commit 585e58f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

drivers/iommu/mtk_iommu.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ static LIST_HEAD(m4ulist); /* List all the M4U HWs */
167167

168168
#define for_each_m4u(data) list_for_each_entry(data, &m4ulist, list)
169169

170+
struct mtk_iommu_iova_region {
171+
dma_addr_t iova_base;
172+
unsigned long long size;
173+
};
174+
175+
static const struct mtk_iommu_iova_region single_domain[] = {
176+
{.iova_base = 0, .size = SZ_4G},
177+
};
178+
170179
/*
171180
* There may be 1 or 2 M4U HWs, But we always expect they are in the same domain
172181
* for the performance.
@@ -901,20 +910,26 @@ static const struct mtk_iommu_plat_data mt2712_data = {
901910
.m4u_plat = M4U_MT2712,
902911
.flags = HAS_4GB_MODE | HAS_BCLK | HAS_VLD_PA_RNG,
903912
.inv_sel_reg = REG_MMU_INV_SEL_GEN1,
913+
.iova_region = single_domain,
914+
.iova_region_nr = ARRAY_SIZE(single_domain),
904915
.larbid_remap = {{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}},
905916
};
906917

907918
static const struct mtk_iommu_plat_data mt6779_data = {
908919
.m4u_plat = M4U_MT6779,
909920
.flags = HAS_SUB_COMM | OUT_ORDER_WR_EN | WR_THROT_EN,
910921
.inv_sel_reg = REG_MMU_INV_SEL_GEN2,
922+
.iova_region = single_domain,
923+
.iova_region_nr = ARRAY_SIZE(single_domain),
911924
.larbid_remap = {{0}, {1}, {2}, {3}, {5}, {7, 8}, {10}, {9}},
912925
};
913926

914927
static const struct mtk_iommu_plat_data mt8167_data = {
915928
.m4u_plat = M4U_MT8167,
916929
.flags = RESET_AXI | HAS_LEGACY_IVRP_PADDR,
917930
.inv_sel_reg = REG_MMU_INV_SEL_GEN1,
931+
.iova_region = single_domain,
932+
.iova_region_nr = ARRAY_SIZE(single_domain),
918933
.larbid_remap = {{0}, {1}, {2}}, /* Linear mapping. */
919934
};
920935

@@ -923,13 +938,17 @@ static const struct mtk_iommu_plat_data mt8173_data = {
923938
.flags = HAS_4GB_MODE | HAS_BCLK | RESET_AXI |
924939
HAS_LEGACY_IVRP_PADDR,
925940
.inv_sel_reg = REG_MMU_INV_SEL_GEN1,
941+
.iova_region = single_domain,
942+
.iova_region_nr = ARRAY_SIZE(single_domain),
926943
.larbid_remap = {{0}, {1}, {2}, {3}, {4}, {5}}, /* Linear mapping. */
927944
};
928945

929946
static const struct mtk_iommu_plat_data mt8183_data = {
930947
.m4u_plat = M4U_MT8183,
931948
.flags = RESET_AXI,
932949
.inv_sel_reg = REG_MMU_INV_SEL_GEN1,
950+
.iova_region = single_domain,
951+
.iova_region_nr = ARRAY_SIZE(single_domain),
933952
.larbid_remap = {{0}, {4}, {5}, {6}, {7}, {2}, {3}, {1}},
934953
};
935954

drivers/iommu/mtk_iommu.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@ enum mtk_iommu_plat {
4545
M4U_MT8183,
4646
};
4747

48+
struct mtk_iommu_iova_region;
49+
4850
struct mtk_iommu_plat_data {
4951
enum mtk_iommu_plat m4u_plat;
5052
u32 flags;
5153
u32 inv_sel_reg;
54+
55+
unsigned int iova_region_nr;
56+
const struct mtk_iommu_iova_region *iova_region;
5257
unsigned char larbid_remap[MTK_LARB_COM_MAX][MTK_LARB_SUBCOM_MAX];
5358
};
5459

0 commit comments

Comments
 (0)