Skip to content

Commit 01867d8

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 23e4bc8 commit 01867d8

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
@@ -1011,6 +1011,11 @@ static int apple_dart_def_domain_type(struct device *dev)
10111011
return 0;
10121012
}
10131013

1014+
static int apple_dart_def_domain_type_dma(struct device *dev)
1015+
{
1016+
return IOMMU_DOMAIN_DMA;
1017+
}
1018+
10141019
#ifndef CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
10151020
/* Keep things compiling when CONFIG_PCI_APPLE isn't selected */
10161021
#define CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR 0
@@ -1036,27 +1041,36 @@ static void apple_dart_get_resv_regions(struct device *dev,
10361041
iommu_dma_get_resv_regions(dev, head);
10371042
}
10381043

1044+
#define APPLE_DART_IOMMU_COMMON_OPS() \
1045+
.domain_alloc_paging = apple_dart_domain_alloc_paging, \
1046+
.probe_device = apple_dart_probe_device, \
1047+
.release_device = apple_dart_release_device, \
1048+
.device_group = apple_dart_device_group, \
1049+
.of_xlate = apple_dart_of_xlate, \
1050+
.get_resv_regions = apple_dart_get_resv_regions, \
1051+
.owner = THIS_MODULE, \
1052+
.default_domain_ops = &(const struct iommu_domain_ops) { \
1053+
.attach_dev = apple_dart_attach_dev_paging, \
1054+
.map_pages = apple_dart_map_pages, \
1055+
.unmap_pages = apple_dart_unmap_pages, \
1056+
.flush_iotlb_all = apple_dart_flush_iotlb_all, \
1057+
.iotlb_sync = apple_dart_iotlb_sync, \
1058+
.iotlb_sync_map = apple_dart_iotlb_sync_map, \
1059+
.iova_to_phys = apple_dart_iova_to_phys, \
1060+
.free = apple_dart_domain_free, \
1061+
}
1062+
10391063
static const struct iommu_ops apple_dart_iommu_ops = {
10401064
.identity_domain = &apple_dart_identity_domain,
10411065
.blocked_domain = &apple_dart_blocked_domain,
1042-
.domain_alloc_paging = apple_dart_domain_alloc_paging,
1043-
.probe_device = apple_dart_probe_device,
1044-
.release_device = apple_dart_release_device,
1045-
.device_group = apple_dart_device_group,
1046-
.of_xlate = apple_dart_of_xlate,
10471066
.def_domain_type = apple_dart_def_domain_type,
1048-
.get_resv_regions = apple_dart_get_resv_regions,
1049-
.owner = THIS_MODULE,
1050-
.default_domain_ops = &(const struct iommu_domain_ops) {
1051-
.attach_dev = apple_dart_attach_dev_paging,
1052-
.map_pages = apple_dart_map_pages,
1053-
.unmap_pages = apple_dart_unmap_pages,
1054-
.flush_iotlb_all = apple_dart_flush_iotlb_all,
1055-
.iotlb_sync = apple_dart_iotlb_sync,
1056-
.iotlb_sync_map = apple_dart_iotlb_sync_map,
1057-
.iova_to_phys = apple_dart_iova_to_phys,
1058-
.free = apple_dart_domain_free,
1059-
}
1067+
APPLE_DART_IOMMU_COMMON_OPS()
1068+
};
1069+
1070+
static const struct iommu_ops apple_dart_iommu_no_bypass_ops = {
1071+
.blocked_domain = &apple_dart_blocked_domain,
1072+
.def_domain_type = apple_dart_def_domain_type_dma,
1073+
APPLE_DART_IOMMU_COMMON_OPS()
10601074
};
10611075

10621076
static irqreturn_t apple_dart_t8020_irq(int irq, void *dev)
@@ -1262,7 +1276,10 @@ static int apple_dart_probe(struct platform_device *pdev)
12621276
if (ret)
12631277
goto err_free_irq;
12641278

1265-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
1279+
if (!dart->supports_bypass)
1280+
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_no_bypass_ops, dev);
1281+
else
1282+
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
12661283
if (ret)
12671284
goto err_sysfs_remove;
12681285

0 commit comments

Comments
 (0)