Skip to content

Commit 35c1b48

Browse files
Chao Haojoergroedel
authored andcommitted
iommu/mediatek: Add REG_MMU_WR_LEN_CTRL register definition
Some platforms(ex: mt6779) need to improve performance by setting REG_MMU_WR_LEN_CTRL register. And we can use WR_THROT_EN macro to control whether we need to set the register. If the register uses default value, iommu will send command to EMI without restriction, when the number of commands become more and more, it will drop the EMI performance. So when more than ten_commands(default value) don't be handled for EMI, iommu will stop send command to EMI for keeping EMI's performace by enabling write throttling mechanism(bit[5][21]=0) in MMU_WR_LEN_CTRL register. Signed-off-by: Chao Hao <[email protected]> Reviewed-by: Matthias Brugger <[email protected]> Cc: Matthias Brugger <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 37276e0 commit 35c1b48

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

drivers/iommu/mtk_iommu.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
#define F_MMU_STANDARD_AXI_MODE_MASK (BIT(3) | BIT(19))
4747

4848
#define REG_MMU_DCM_DIS 0x050
49+
#define REG_MMU_WR_LEN_CTRL 0x054
50+
#define F_MMU_WR_THROT_DIS_MASK (BIT(5) | BIT(21))
4951

5052
#define REG_MMU_CTRL_REG 0x110
5153
#define F_MMU_TF_PROT_TO_PROGRAM_ADDR (2 << 4)
@@ -112,6 +114,7 @@
112114
#define RESET_AXI BIT(3)
113115
#define OUT_ORDER_WR_EN BIT(4)
114116
#define HAS_SUB_COMM BIT(5)
117+
#define WR_THROT_EN BIT(6)
115118

116119
#define MTK_IOMMU_HAS_FLAG(pdata, _x) \
117120
((((pdata)->flags) & (_x)) == (_x))
@@ -593,6 +596,12 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
593596
writel_relaxed(regval, data->base + REG_MMU_VLD_PA_RNG);
594597
}
595598
writel_relaxed(0, data->base + REG_MMU_DCM_DIS);
599+
if (MTK_IOMMU_HAS_FLAG(data->plat_data, WR_THROT_EN)) {
600+
/* write command throttling mode */
601+
regval = readl_relaxed(data->base + REG_MMU_WR_LEN_CTRL);
602+
regval &= ~F_MMU_WR_THROT_DIS_MASK;
603+
writel_relaxed(regval, data->base + REG_MMU_WR_LEN_CTRL);
604+
}
596605

597606
if (MTK_IOMMU_HAS_FLAG(data->plat_data, RESET_AXI)) {
598607
/* The register is called STANDARD_AXI_MODE in this case */
@@ -747,6 +756,7 @@ static int __maybe_unused mtk_iommu_suspend(struct device *dev)
747756
struct mtk_iommu_suspend_reg *reg = &data->reg;
748757
void __iomem *base = data->base;
749758

759+
reg->wr_len_ctrl = readl_relaxed(base + REG_MMU_WR_LEN_CTRL);
750760
reg->misc_ctrl = readl_relaxed(base + REG_MMU_MISC_CTRL);
751761
reg->dcm_dis = readl_relaxed(base + REG_MMU_DCM_DIS);
752762
reg->ctrl_reg = readl_relaxed(base + REG_MMU_CTRL_REG);
@@ -771,6 +781,7 @@ static int __maybe_unused mtk_iommu_resume(struct device *dev)
771781
dev_err(data->dev, "Failed to enable clk(%d) in resume\n", ret);
772782
return ret;
773783
}
784+
writel_relaxed(reg->wr_len_ctrl, base + REG_MMU_WR_LEN_CTRL);
774785
writel_relaxed(reg->misc_ctrl, base + REG_MMU_MISC_CTRL);
775786
writel_relaxed(reg->dcm_dis, base + REG_MMU_DCM_DIS);
776787
writel_relaxed(reg->ctrl_reg, base + REG_MMU_CTRL_REG);

drivers/iommu/mtk_iommu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct mtk_iommu_suspend_reg {
3131
u32 int_main_control;
3232
u32 ivrp_paddr;
3333
u32 vld_pa_rng;
34+
u32 wr_len_ctrl;
3435
};
3536

3637
enum mtk_iommu_plat {

0 commit comments

Comments
 (0)