Skip to content

Commit 15a01f4

Browse files
YongWu-HFjoergroedel
authored andcommitted
iommu/mediatek: Add mmu1 support
Normally the M4U HW connect EMI with smi. the diagram is like below: EMI | M4U | smi-common | ----------------- | | | | ... larb0 larb1 larb2 larb3 Actually there are 2 mmu cells in the M4U HW, like this diagram: EMI --------- | | mmu0 mmu1 <- M4U | | --------- | smi-common | ----------------- | | | | ... larb0 larb1 larb2 larb3 This patch add support for mmu1. In order to get better performance, we could adjust some larbs go to mmu1 while the others still go to mmu0. This is controlled by a SMI COMMON register SMI_BUS_SEL(0x220). mt2712, mt8173 and mt8183 M4U HW all have 2 mmu cells. the default value of that register is 0 which means all the larbs go to mmu0 defaultly. This is a preparing patch for adjusting SMI_BUS_SEL for mt8183. Signed-off-by: Yong Wu <[email protected]> Reviewed-by: Evan Green <[email protected]> Reviewed-by: Matthias Brugger <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 907ba6a commit 15a01f4

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

drivers/iommu/mtk_iommu.c

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,32 @@
6464
#define F_INT_CLR_BIT BIT(12)
6565

6666
#define REG_MMU_INT_MAIN_CONTROL 0x124
67-
#define F_INT_TRANSLATION_FAULT BIT(0)
68-
#define F_INT_MAIN_MULTI_HIT_FAULT BIT(1)
69-
#define F_INT_INVALID_PA_FAULT BIT(2)
70-
#define F_INT_ENTRY_REPLACEMENT_FAULT BIT(3)
71-
#define F_INT_TLB_MISS_FAULT BIT(4)
72-
#define F_INT_MISS_TRANSACTION_FIFO_FAULT BIT(5)
73-
#define F_INT_PRETETCH_TRANSATION_FIFO_FAULT BIT(6)
67+
/* mmu0 | mmu1 */
68+
#define F_INT_TRANSLATION_FAULT (BIT(0) | BIT(7))
69+
#define F_INT_MAIN_MULTI_HIT_FAULT (BIT(1) | BIT(8))
70+
#define F_INT_INVALID_PA_FAULT (BIT(2) | BIT(9))
71+
#define F_INT_ENTRY_REPLACEMENT_FAULT (BIT(3) | BIT(10))
72+
#define F_INT_TLB_MISS_FAULT (BIT(4) | BIT(11))
73+
#define F_INT_MISS_TRANSACTION_FIFO_FAULT (BIT(5) | BIT(12))
74+
#define F_INT_PRETETCH_TRANSATION_FIFO_FAULT (BIT(6) | BIT(13))
7475

7576
#define REG_MMU_CPE_DONE 0x12C
7677

7778
#define REG_MMU_FAULT_ST1 0x134
79+
#define F_REG_MMU0_FAULT_MASK GENMASK(6, 0)
80+
#define F_REG_MMU1_FAULT_MASK GENMASK(13, 7)
7881

79-
#define REG_MMU_FAULT_VA 0x13c
82+
#define REG_MMU0_FAULT_VA 0x13c
8083
#define F_MMU_FAULT_VA_WRITE_BIT BIT(1)
8184
#define F_MMU_FAULT_VA_LAYER_BIT BIT(0)
8285

83-
#define REG_MMU_INVLD_PA 0x140
84-
#define REG_MMU_INT_ID 0x150
85-
#define F_MMU0_INT_ID_LARB_ID(a) (((a) >> 7) & 0x7)
86-
#define F_MMU0_INT_ID_PORT_ID(a) (((a) >> 2) & 0x1f)
86+
#define REG_MMU0_INVLD_PA 0x140
87+
#define REG_MMU1_FAULT_VA 0x144
88+
#define REG_MMU1_INVLD_PA 0x148
89+
#define REG_MMU0_INT_ID 0x150
90+
#define REG_MMU1_INT_ID 0x154
91+
#define F_MMU_INT_ID_LARB_ID(a) (((a) >> 7) & 0x7)
92+
#define F_MMU_INT_ID_PORT_ID(a) (((a) >> 2) & 0x1f)
8793

8894
#define MTK_PROTECT_PA_ALIGN 128
8995

@@ -226,13 +232,19 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id)
226232

227233
/* Read error info from registers */
228234
int_state = readl_relaxed(data->base + REG_MMU_FAULT_ST1);
229-
fault_iova = readl_relaxed(data->base + REG_MMU_FAULT_VA);
235+
if (int_state & F_REG_MMU0_FAULT_MASK) {
236+
regval = readl_relaxed(data->base + REG_MMU0_INT_ID);
237+
fault_iova = readl_relaxed(data->base + REG_MMU0_FAULT_VA);
238+
fault_pa = readl_relaxed(data->base + REG_MMU0_INVLD_PA);
239+
} else {
240+
regval = readl_relaxed(data->base + REG_MMU1_INT_ID);
241+
fault_iova = readl_relaxed(data->base + REG_MMU1_FAULT_VA);
242+
fault_pa = readl_relaxed(data->base + REG_MMU1_INVLD_PA);
243+
}
230244
layer = fault_iova & F_MMU_FAULT_VA_LAYER_BIT;
231245
write = fault_iova & F_MMU_FAULT_VA_WRITE_BIT;
232-
fault_pa = readl_relaxed(data->base + REG_MMU_INVLD_PA);
233-
regval = readl_relaxed(data->base + REG_MMU_INT_ID);
234-
fault_larb = F_MMU0_INT_ID_LARB_ID(regval);
235-
fault_port = F_MMU0_INT_ID_PORT_ID(regval);
246+
fault_larb = F_MMU_INT_ID_LARB_ID(regval);
247+
fault_port = F_MMU_INT_ID_PORT_ID(regval);
236248

237249
fault_larb = data->plat_data->larbid_remap[fault_larb];
238250

0 commit comments

Comments
 (0)