Skip to content

Commit b14d8b8

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 c4996c0 commit b14d8b8

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
@@ -1001,6 +1001,11 @@ static int apple_dart_def_domain_type(struct device *dev)
10011001
return 0;
10021002
}
10031003

1004+
static int apple_dart_def_domain_type_dma(struct device *dev)
1005+
{
1006+
return IOMMU_DOMAIN_DMA;
1007+
}
1008+
10041009
#ifndef CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
10051010
/* Keep things compiling when CONFIG_PCI_APPLE isn't selected */
10061011
#define CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR 0
@@ -1026,27 +1031,36 @@ static void apple_dart_get_resv_regions(struct device *dev,
10261031
iommu_dma_get_resv_regions(dev, head);
10271032
}
10281033

1034+
#define APPLE_DART_IOMMU_COMMON_OPS() \
1035+
.domain_alloc_paging = apple_dart_domain_alloc_paging, \
1036+
.probe_device = apple_dart_probe_device, \
1037+
.release_device = apple_dart_release_device, \
1038+
.device_group = apple_dart_device_group, \
1039+
.of_xlate = apple_dart_of_xlate, \
1040+
.get_resv_regions = apple_dart_get_resv_regions, \
1041+
.owner = THIS_MODULE, \
1042+
.default_domain_ops = &(const struct iommu_domain_ops) { \
1043+
.attach_dev = apple_dart_attach_dev_paging, \
1044+
.map_pages = apple_dart_map_pages, \
1045+
.unmap_pages = apple_dart_unmap_pages, \
1046+
.flush_iotlb_all = apple_dart_flush_iotlb_all, \
1047+
.iotlb_sync = apple_dart_iotlb_sync, \
1048+
.iotlb_sync_map = apple_dart_iotlb_sync_map, \
1049+
.iova_to_phys = apple_dart_iova_to_phys, \
1050+
.free = apple_dart_domain_free, \
1051+
}
1052+
10291053
static const struct iommu_ops apple_dart_iommu_ops = {
10301054
.identity_domain = &apple_dart_identity_domain,
10311055
.blocked_domain = &apple_dart_blocked_domain,
1032-
.domain_alloc_paging = apple_dart_domain_alloc_paging,
1033-
.probe_device = apple_dart_probe_device,
1034-
.release_device = apple_dart_release_device,
1035-
.device_group = apple_dart_device_group,
1036-
.of_xlate = apple_dart_of_xlate,
10371056
.def_domain_type = apple_dart_def_domain_type,
1038-
.get_resv_regions = apple_dart_get_resv_regions,
1039-
.owner = THIS_MODULE,
1040-
.default_domain_ops = &(const struct iommu_domain_ops) {
1041-
.attach_dev = apple_dart_attach_dev_paging,
1042-
.map_pages = apple_dart_map_pages,
1043-
.unmap_pages = apple_dart_unmap_pages,
1044-
.flush_iotlb_all = apple_dart_flush_iotlb_all,
1045-
.iotlb_sync = apple_dart_iotlb_sync,
1046-
.iotlb_sync_map = apple_dart_iotlb_sync_map,
1047-
.iova_to_phys = apple_dart_iova_to_phys,
1048-
.free = apple_dart_domain_free,
1049-
}
1057+
APPLE_DART_IOMMU_COMMON_OPS()
1058+
};
1059+
1060+
static const struct iommu_ops apple_dart_iommu_no_bypass_ops = {
1061+
.blocked_domain = &apple_dart_blocked_domain,
1062+
.def_domain_type = apple_dart_def_domain_type_dma,
1063+
APPLE_DART_IOMMU_COMMON_OPS()
10501064
};
10511065

10521066
static irqreturn_t apple_dart_t8020_irq(int irq, void *dev)
@@ -1252,7 +1266,10 @@ static int apple_dart_probe(struct platform_device *pdev)
12521266
if (ret)
12531267
goto err_free_irq;
12541268

1255-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
1269+
if (!dart->supports_bypass)
1270+
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_no_bypass_ops, dev);
1271+
else
1272+
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
12561273
if (ret)
12571274
goto err_sysfs_remove;
12581275

0 commit comments

Comments
 (0)