[PATCH 03/24] iommu/mediatek: Fix 2 HW sharing pgtable issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the this commit 4f956c97d26b ("iommu/mediatek: Move domain_finalise
into attach_device"), I overlooked the sharing pgtable case.
After that commit, the "data" in the mtk_iommu_domain_finalise always is
the data of the current IOMMU HW, If it's sharing pgtable case, here is
not right. This patch fix this. In sharing pgable case, we will loop the
list to find if there already is the exist domain.

this only affect mt2712 which is the only SoC that sharing pgtable.

Fixes: 4f956c97d26b ("iommu/mediatek: Move domain_finalise into attach_device")
Signed-off-by: Chao Hao <chao.hao@xxxxxxxxxxxx>
Signed-off-by: Yong Wu <yong.wu@xxxxxxxxxxxx>
---
 drivers/iommu/mtk_iommu.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index e06b8a0e2b56..013dbcc87d49 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -390,12 +390,19 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom,
 				     unsigned int domid)
 {
 	const struct mtk_iommu_iova_region *region;
+	struct mtk_iommu_data *tmpdata;
 
-	/* Use the exist domain as there is only one pgtable here. */
-	if (data->m4u_dom) {
-		dom->iop = data->m4u_dom->iop;
-		dom->cfg = data->m4u_dom->cfg;
-		dom->domain.pgsize_bitmap = data->m4u_dom->cfg.pgsize_bitmap;
+	/*
+	 * Loop to find if there is already the exist domain.
+	 * Use it when 2 iommu HWs share the pgtable.
+	 */
+	for_each_m4u(tmpdata) {
+		if (!tmpdata->m4u_dom)
+			continue;
+
+		dom->iop = tmpdata->m4u_dom->iop;
+		dom->cfg = tmpdata->m4u_dom->cfg;
+		dom->domain.pgsize_bitmap = tmpdata->m4u_dom->cfg.pgsize_bitmap;
 		goto update_iova_region;
 	}
 
-- 
2.18.0




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux