Skip to content

Commit 8bbe13f

Browse files
YongWu-HFjoergroedel
authored andcommitted
iommu/mediatek-v1: Add def_domain_type
The MediaTek V1 IOMMU is arm32 whose default domain type is IOMMU_DOMAIN_UNMANAGED. Add this to satisfy the bus_iommu_probe to enter "probe_finalize". The iommu framework will create a iommu domain for each a device. But all the devices share a iommu domain here, thus we skip all the other domains in the "attach_device" except the domain we create internally with arm_iommu_create_mapping. Also a minor change: in the attach_device, "data" always is not null. Remove "if (!data) return". Signed-off-by: Yong Wu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 5df362a commit 8bbe13f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/iommu/mtk_iommu_v1.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,13 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,
265265
{
266266
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
267267
struct mtk_iommu_domain *dom = to_mtk_domain(domain);
268+
struct dma_iommu_mapping *mtk_mapping;
268269
int ret;
269270

270-
if (!data)
271-
return -ENODEV;
271+
/* Only allow the domain created internally. */
272+
mtk_mapping = data->dev->archdata.iommu;
273+
if (mtk_mapping->domain != domain)
274+
return 0;
272275

273276
if (!data->m4u_dom) {
274277
data->m4u_dom = dom;
@@ -288,9 +291,6 @@ static void mtk_iommu_detach_device(struct iommu_domain *domain,
288291
{
289292
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
290293

291-
if (!data)
292-
return;
293-
294294
mtk_iommu_config(data, dev, false);
295295
}
296296

@@ -416,6 +416,11 @@ static int mtk_iommu_create_mapping(struct device *dev,
416416
return 0;
417417
}
418418

419+
static int mtk_iommu_def_domain_type(struct device *dev)
420+
{
421+
return IOMMU_DOMAIN_UNMANAGED;
422+
}
423+
419424
static struct iommu_device *mtk_iommu_probe_device(struct device *dev)
420425
{
421426
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
@@ -525,6 +530,7 @@ static const struct iommu_ops mtk_iommu_ops = {
525530
.probe_device = mtk_iommu_probe_device,
526531
.probe_finalize = mtk_iommu_probe_finalize,
527532
.release_device = mtk_iommu_release_device,
533+
.def_domain_type = mtk_iommu_def_domain_type,
528534
.device_group = generic_device_group,
529535
.pgsize_bitmap = ~0UL << MT2701_IOMMU_PAGE_SHIFT,
530536
};

0 commit comments

Comments
 (0)