Skip to content

Commit f96d12f

Browse files
committed
iommu/dart: Use separate iommu_ops for DARTs w/o bypass
These DARTs do not support identity mappings so use a struct iommu_ops without default identity domain. Since commit 3bc0102 ("iommu: apple-dart: Allow mismatched bypass support") groups with mismatched bypass support are supported so the check for bypass support in apple_dart_attach_dev_identity() has to stay. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 59b0fbc commit f96d12f

1 file changed

Lines changed: 35 additions & 18 deletions

File tree

drivers/iommu/apple-dart.c

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,11 @@ static int apple_dart_def_domain_type(struct device *dev)
10061006
return 0;
10071007
}
10081008

1009+
static int apple_dart_def_domain_type_dma(struct device *dev)
1010+
{
1011+
return IOMMU_DOMAIN_DMA;
1012+
}
1013+
10091014
#ifndef CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
10101015
/* Keep things compiling when CONFIG_PCI_APPLE isn't selected */
10111016
#define CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR 0
@@ -1031,27 +1036,36 @@ static void apple_dart_get_resv_regions(struct device *dev,
10311036
iommu_dma_get_resv_regions(dev, head);
10321037
}
10331038

1039+
#define APPLE_DART_IOMMU_COMMON_OPS() \
1040+
.domain_alloc_paging = apple_dart_domain_alloc_paging, \
1041+
.probe_device = apple_dart_probe_device, \
1042+
.release_device = apple_dart_release_device, \
1043+
.device_group = apple_dart_device_group, \
1044+
.of_xlate = apple_dart_of_xlate, \
1045+
.get_resv_regions = apple_dart_get_resv_regions, \
1046+
.owner = THIS_MODULE, \
1047+
.default_domain_ops = &(const struct iommu_domain_ops) { \
1048+
.attach_dev = apple_dart_attach_dev_paging, \
1049+
.map_pages = apple_dart_map_pages, \
1050+
.unmap_pages = apple_dart_unmap_pages, \
1051+
.flush_iotlb_all = apple_dart_flush_iotlb_all, \
1052+
.iotlb_sync = apple_dart_iotlb_sync, \
1053+
.iotlb_sync_map = apple_dart_iotlb_sync_map, \
1054+
.iova_to_phys = apple_dart_iova_to_phys, \
1055+
.free = apple_dart_domain_free, \
1056+
}
1057+
10341058
static const struct iommu_ops apple_dart_iommu_ops = {
10351059
.identity_domain = &apple_dart_identity_domain,
10361060
.blocked_domain = &apple_dart_blocked_domain,
1037-
.domain_alloc_paging = apple_dart_domain_alloc_paging,
1038-
.probe_device = apple_dart_probe_device,
1039-
.release_device = apple_dart_release_device,
1040-
.device_group = apple_dart_device_group,
1041-
.of_xlate = apple_dart_of_xlate,
10421061
.def_domain_type = apple_dart_def_domain_type,
1043-
.get_resv_regions = apple_dart_get_resv_regions,
1044-
.owner = THIS_MODULE,
1045-
.default_domain_ops = &(const struct iommu_domain_ops) {
1046-
.attach_dev = apple_dart_attach_dev_paging,
1047-
.map_pages = apple_dart_map_pages,
1048-
.unmap_pages = apple_dart_unmap_pages,
1049-
.flush_iotlb_all = apple_dart_flush_iotlb_all,
1050-
.iotlb_sync = apple_dart_iotlb_sync,
1051-
.iotlb_sync_map = apple_dart_iotlb_sync_map,
1052-
.iova_to_phys = apple_dart_iova_to_phys,
1053-
.free = apple_dart_domain_free,
1054-
}
1062+
APPLE_DART_IOMMU_COMMON_OPS()
1063+
};
1064+
1065+
static const struct iommu_ops apple_dart_iommu_no_bypass_ops = {
1066+
.blocked_domain = &apple_dart_blocked_domain,
1067+
.def_domain_type = apple_dart_def_domain_type_dma,
1068+
APPLE_DART_IOMMU_COMMON_OPS()
10551069
};
10561070

10571071
static irqreturn_t apple_dart_t8020_irq(int irq, void *dev)
@@ -1257,7 +1271,10 @@ static int apple_dart_probe(struct platform_device *pdev)
12571271
if (ret)
12581272
goto err_free_irq;
12591273

1260-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
1274+
if (!dart->supports_bypass)
1275+
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_no_bypass_ops, dev);
1276+
else
1277+
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
12611278
if (ret)
12621279
goto err_sysfs_remove;
12631280

0 commit comments

Comments
 (0)