[PATCH] iommu/mediatek: Track first resume with a dedicated boolean flag
Chen-Yu Tsai
wenst at chromium.org
Tue Oct 27 21:16:50 PDT 2026
In mtk_iommu_runtime_resume(), the driver checks `!reg->wr_len_ctrl` to
detect the initial runtime resume before mtk_iommu_runtime_suspend() has
saved the hardware registers.
As described in commit 35c1b48d27da ("iommu/mediatek: Add
REG_MMU_WR_LEN_CTRL register definition"), `REG_MMU_WR_LEN_CTRL` has a
non-zero hardware reset default (containing the default write command
threshold and throttle-disable bits) and mtk_iommu_hw_init() only clears
`F_MMU_WR_THROT_DIS_MASK`. While checking `!reg->wr_len_ctrl` therefore
works in practice, relying on an implicit hardware register default to
track runtime PM state is obscure and easy to misread.
Add a dedicated `has_resumed` flag to `struct mtk_iommu_data` to track
whether the first runtime resume has completed directly.
Signed-off-by: Chen-Yu Tsai <wenst at chromium.org>
---
drivers/iommu/mtk_iommu.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index b52e16b06760..3be1edd30861 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -260,6 +260,7 @@ struct mtk_iommu_data {
struct mtk_iommu_suspend_reg reg;
struct iommu_group *m4u_group[MTK_IOMMU_GROUP_MAX];
bool enable_4GB;
+ bool has_resumed;
struct iommu_device iommu;
const struct mtk_iommu_plat_data *plat_data;
@@ -1529,8 +1530,10 @@ static int __maybe_unused mtk_iommu_runtime_resume(struct device *dev)
* Uppon first resume, only enable the clk and return, since the values of the
* registers are not yet set.
*/
- if (!reg->wr_len_ctrl)
+ if (!data->has_resumed) {
+ data->has_resumed = true;
return 0;
+ }
base = data->bank[i].base;
writel_relaxed(reg->wr_len_ctrl, base + REG_MMU_WR_LEN_CTRL);
--
2.56.0.307.g5fe7bd680c-goog
More information about the Linux-mediatek
mailing list