Skip to content

Commit 0124a9e

Browse files
committed
iommu: apple-dart: Revert separate iommu_ops for locked/bypass DARTs
Since combination of DARTs with diverging locked and supports_bypass state have to be supported those DARTs have to share the same iommu_ops pointer (see iommu_fwspec_init()). Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 06f195b commit 0124a9e

1 file changed

Lines changed: 20 additions & 42 deletions

File tree

drivers/iommu/apple-dart.c

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,15 +1153,12 @@ static int apple_dart_def_domain_type(struct device *dev)
11531153
return IOMMU_DOMAIN_IDENTITY;
11541154
if (!cfg->supports_bypass)
11551155
return IOMMU_DOMAIN_DMA;
1156+
if (cfg->locked)
1157+
return IOMMU_DOMAIN_DMA;
11561158

11571159
return 0;
11581160
}
11591161

1160-
static int apple_dart_def_domain_type_dma(struct device *dev)
1161-
{
1162-
return IOMMU_DOMAIN_DMA;
1163-
}
1164-
11651162
#ifndef CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
11661163
/* Keep things compiling when CONFIG_PCI_APPLE isn't selected */
11671164
#define CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR 0
@@ -1187,41 +1184,27 @@ static void apple_dart_get_resv_regions(struct device *dev,
11871184
iommu_dma_get_resv_regions(dev, head);
11881185
}
11891186

1190-
#define APPLE_DART_IOMMU_COMMON_OPS() \
1191-
.domain_alloc_paging = apple_dart_domain_alloc_paging, \
1192-
.probe_device = apple_dart_probe_device, \
1193-
.release_device = apple_dart_release_device, \
1194-
.device_group = apple_dart_device_group, \
1195-
.of_xlate = apple_dart_of_xlate, \
1196-
.get_resv_regions = apple_dart_get_resv_regions, \
1197-
.owner = THIS_MODULE, \
1198-
.default_domain_ops = &(const struct iommu_domain_ops) { \
1199-
.attach_dev = apple_dart_attach_dev_paging, \
1200-
.map_pages = apple_dart_map_pages, \
1201-
.unmap_pages = apple_dart_unmap_pages, \
1202-
.flush_iotlb_all = apple_dart_flush_iotlb_all, \
1203-
.iotlb_sync = apple_dart_iotlb_sync, \
1204-
.iotlb_sync_map = apple_dart_iotlb_sync_map, \
1205-
.iova_to_phys = apple_dart_iova_to_phys, \
1206-
.free = apple_dart_domain_free, \
1207-
}
1208-
12091187
static const struct iommu_ops apple_dart_iommu_ops = {
12101188
.identity_domain = &apple_dart_identity_domain,
12111189
.blocked_domain = &apple_dart_blocked_domain,
12121190
.def_domain_type = apple_dart_def_domain_type,
1213-
APPLE_DART_IOMMU_COMMON_OPS()
1214-
};
1215-
1216-
static const struct iommu_ops apple_dart_iommu_no_bypass_ops = {
1217-
.blocked_domain = &apple_dart_blocked_domain,
1218-
.def_domain_type = apple_dart_def_domain_type_dma,
1219-
APPLE_DART_IOMMU_COMMON_OPS()
1220-
};
1221-
1222-
static const struct iommu_ops apple_dart_iommu_locked_ops = {
1223-
.def_domain_type = apple_dart_def_domain_type_dma,
1224-
APPLE_DART_IOMMU_COMMON_OPS()
1191+
.domain_alloc_paging = apple_dart_domain_alloc_paging,
1192+
.probe_device = apple_dart_probe_device,
1193+
.release_device = apple_dart_release_device,
1194+
.device_group = apple_dart_device_group,
1195+
.of_xlate = apple_dart_of_xlate,
1196+
.get_resv_regions = apple_dart_get_resv_regions,
1197+
.owner = THIS_MODULE,
1198+
.default_domain_ops = &(const struct iommu_domain_ops) {
1199+
.attach_dev = apple_dart_attach_dev_paging,
1200+
.map_pages = apple_dart_map_pages,
1201+
.unmap_pages = apple_dart_unmap_pages,
1202+
.flush_iotlb_all = apple_dart_flush_iotlb_all,
1203+
.iotlb_sync = apple_dart_iotlb_sync,
1204+
.iotlb_sync_map = apple_dart_iotlb_sync_map,
1205+
.iova_to_phys = apple_dart_iova_to_phys,
1206+
.free = apple_dart_domain_free,
1207+
}
12251208
};
12261209

12271210
static irqreturn_t apple_dart_t8020_irq(int irq, void *dev)
@@ -1435,12 +1418,7 @@ static int apple_dart_probe(struct platform_device *pdev)
14351418
if (ret)
14361419
goto err_free_irq;
14371420

1438-
if (dart->locked)
1439-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_locked_ops, dev);
1440-
else if (!dart->supports_bypass)
1441-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_no_bypass_ops, dev);
1442-
else
1443-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
1421+
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
14441422
if (ret)
14451423
goto err_sysfs_remove;
14461424

0 commit comments

Comments
 (0)