Skip to content

Commit adee669

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 05d5010 commit adee669

1 file changed

Lines changed: 21 additions & 43 deletions

File tree

drivers/iommu/apple-dart.c

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,15 +1154,12 @@ static int apple_dart_def_domain_type(struct device *dev)
11541154
return IOMMU_DOMAIN_IDENTITY;
11551155
if (!cfg->supports_bypass)
11561156
return IOMMU_DOMAIN_DMA;
1157+
if (cfg->locked)
1158+
return IOMMU_DOMAIN_DMA;
11571159

11581160
return 0;
11591161
}
11601162

1161-
static int apple_dart_def_domain_type_dma(struct device *dev)
1162-
{
1163-
return IOMMU_DOMAIN_DMA;
1164-
}
1165-
11661163
#ifndef CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
11671164
/* Keep things compiling when CONFIG_PCI_APPLE isn't selected */
11681165
#define CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR 0
@@ -1188,42 +1185,28 @@ static void apple_dart_get_resv_regions(struct device *dev,
11881185
iommu_dma_get_resv_regions(dev, head);
11891186
}
11901187

1191-
#define APPLE_DART_IOMMU_COMMON_OPS() \
1192-
.domain_alloc_paging = apple_dart_domain_alloc_paging, \
1193-
.probe_device = apple_dart_probe_device, \
1194-
.release_device = apple_dart_release_device, \
1195-
.device_group = apple_dart_device_group, \
1196-
.of_xlate = apple_dart_of_xlate, \
1197-
.get_resv_regions = apple_dart_get_resv_regions, \
1198-
.pgsize_bitmap = -1UL, /* Restricted during dart probe */ \
1199-
.owner = THIS_MODULE, \
1200-
.default_domain_ops = &(const struct iommu_domain_ops) { \
1201-
.attach_dev = apple_dart_attach_dev_paging, \
1202-
.map_pages = apple_dart_map_pages, \
1203-
.unmap_pages = apple_dart_unmap_pages, \
1204-
.flush_iotlb_all = apple_dart_flush_iotlb_all, \
1205-
.iotlb_sync = apple_dart_iotlb_sync, \
1206-
.iotlb_sync_map = apple_dart_iotlb_sync_map, \
1207-
.iova_to_phys = apple_dart_iova_to_phys, \
1208-
.free = apple_dart_domain_free, \
1209-
}
1210-
12111188
static const struct iommu_ops apple_dart_iommu_ops = {
12121189
.identity_domain = &apple_dart_identity_domain,
12131190
.blocked_domain = &apple_dart_blocked_domain,
12141191
.def_domain_type = apple_dart_def_domain_type,
1215-
APPLE_DART_IOMMU_COMMON_OPS()
1216-
};
1217-
1218-
static const struct iommu_ops apple_dart_iommu_no_bypass_ops = {
1219-
.blocked_domain = &apple_dart_blocked_domain,
1220-
.def_domain_type = apple_dart_def_domain_type_dma,
1221-
APPLE_DART_IOMMU_COMMON_OPS()
1222-
};
1223-
1224-
static const struct iommu_ops apple_dart_iommu_locked_ops = {
1225-
.def_domain_type = apple_dart_def_domain_type_dma,
1226-
APPLE_DART_IOMMU_COMMON_OPS()
1192+
.domain_alloc_paging = apple_dart_domain_alloc_paging,
1193+
.probe_device = apple_dart_probe_device,
1194+
.release_device = apple_dart_release_device,
1195+
.device_group = apple_dart_device_group,
1196+
.of_xlate = apple_dart_of_xlate,
1197+
.get_resv_regions = apple_dart_get_resv_regions,
1198+
.pgsize_bitmap = -1UL, /* Restricted during dart probe */
1199+
.owner = THIS_MODULE,
1200+
.default_domain_ops = &(const struct iommu_domain_ops) {
1201+
.attach_dev = apple_dart_attach_dev_paging,
1202+
.map_pages = apple_dart_map_pages,
1203+
.unmap_pages = apple_dart_unmap_pages,
1204+
.flush_iotlb_all = apple_dart_flush_iotlb_all,
1205+
.iotlb_sync = apple_dart_iotlb_sync,
1206+
.iotlb_sync_map = apple_dart_iotlb_sync_map,
1207+
.iova_to_phys = apple_dart_iova_to_phys,
1208+
.free = apple_dart_domain_free,
1209+
}
12271210
};
12281211

12291212
static irqreturn_t apple_dart_t8020_irq(int irq, void *dev)
@@ -1438,12 +1421,7 @@ static int apple_dart_probe(struct platform_device *pdev)
14381421
if (ret)
14391422
goto err_free_irq;
14401423

1441-
if (dart->locked)
1442-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_locked_ops, dev);
1443-
else if (!dart->supports_bypass)
1444-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_no_bypass_ops, dev);
1445-
else
1446-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
1424+
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
14471425
if (ret)
14481426
goto err_sysfs_remove;
14491427

0 commit comments

Comments
 (0)