Skip to content

Commit 645b87c

Browse files
YongWu-HFjoergroedel
authored andcommitted
iommu/mediatek: Fix 2 HW sharing pgtable issue
In the commit 4f956c9 ("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. Fix this for the sharing pgtable case. Only affect mt2712 which is the only SoC that share pgtable currently. Fixes: 4f956c9 ("iommu/mediatek: Move domain_finalise into attach_device") Signed-off-by: Yong Wu <yong.wu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Link: https://lore.kernel.org/r/20220503071427.2285-5-yong.wu@mediatek.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 2d555a3 commit 645b87c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/iommu/mtk_iommu.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ static void mtk_iommu_domain_free(struct iommu_domain *domain)
446446
static int mtk_iommu_attach_device(struct iommu_domain *domain,
447447
struct device *dev)
448448
{
449-
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
449+
struct mtk_iommu_data *data = dev_iommu_priv_get(dev), *frstdata;
450450
struct mtk_iommu_domain *dom = to_mtk_domain(domain);
451451
struct device *m4udev = data->dev;
452452
int ret, domid;
@@ -456,7 +456,10 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,
456456
return domid;
457457

458458
if (!dom->data) {
459-
if (mtk_iommu_domain_finalise(dom, data, domid))
459+
/* Data is in the frstdata in sharing pgtable case. */
460+
frstdata = mtk_iommu_get_m4u_data();
461+
462+
if (mtk_iommu_domain_finalise(dom, frstdata, domid))
460463
return -ENODEV;
461464
dom->data = data;
462465
}

0 commit comments

Comments
 (0)