Skip to content

Commit 2a46b6d

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 a457b8d commit 2a46b6d

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
@@ -1163,15 +1163,12 @@ static int apple_dart_def_domain_type(struct device *dev)
11631163
return IOMMU_DOMAIN_IDENTITY;
11641164
if (!cfg->supports_bypass)
11651165
return IOMMU_DOMAIN_DMA;
1166+
if (cfg->locked)
1167+
return IOMMU_DOMAIN_DMA;
11661168

11671169
return 0;
11681170
}
11691171

1170-
static int apple_dart_def_domain_type_dma(struct device *dev)
1171-
{
1172-
return IOMMU_DOMAIN_DMA;
1173-
}
1174-
11751172
#ifndef CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
11761173
/* Keep things compiling when CONFIG_PCI_APPLE isn't selected */
11771174
#define CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR 0
@@ -1197,41 +1194,27 @@ static void apple_dart_get_resv_regions(struct device *dev,
11971194
iommu_dma_get_resv_regions(dev, head);
11981195
}
11991196

1200-
#define APPLE_DART_IOMMU_COMMON_OPS() \
1201-
.domain_alloc_paging = apple_dart_domain_alloc_paging, \
1202-
.probe_device = apple_dart_probe_device, \
1203-
.release_device = apple_dart_release_device, \
1204-
.device_group = apple_dart_device_group, \
1205-
.of_xlate = apple_dart_of_xlate, \
1206-
.get_resv_regions = apple_dart_get_resv_regions, \
1207-
.owner = THIS_MODULE, \
1208-
.default_domain_ops = &(const struct iommu_domain_ops) { \
1209-
.attach_dev = apple_dart_attach_dev_paging, \
1210-
.map_pages = apple_dart_map_pages, \
1211-
.unmap_pages = apple_dart_unmap_pages, \
1212-
.flush_iotlb_all = apple_dart_flush_iotlb_all, \
1213-
.iotlb_sync = apple_dart_iotlb_sync, \
1214-
.iotlb_sync_map = apple_dart_iotlb_sync_map, \
1215-
.iova_to_phys = apple_dart_iova_to_phys, \
1216-
.free = apple_dart_domain_free, \
1217-
}
1218-
12191197
static const struct iommu_ops apple_dart_iommu_ops = {
12201198
.identity_domain = &apple_dart_identity_domain,
12211199
.blocked_domain = &apple_dart_blocked_domain,
12221200
.def_domain_type = apple_dart_def_domain_type,
1223-
APPLE_DART_IOMMU_COMMON_OPS()
1224-
};
1225-
1226-
static const struct iommu_ops apple_dart_iommu_no_bypass_ops = {
1227-
.blocked_domain = &apple_dart_blocked_domain,
1228-
.def_domain_type = apple_dart_def_domain_type_dma,
1229-
APPLE_DART_IOMMU_COMMON_OPS()
1230-
};
1231-
1232-
static const struct iommu_ops apple_dart_iommu_locked_ops = {
1233-
.def_domain_type = apple_dart_def_domain_type_dma,
1234-
APPLE_DART_IOMMU_COMMON_OPS()
1201+
.domain_alloc_paging = apple_dart_domain_alloc_paging,
1202+
.probe_device = apple_dart_probe_device,
1203+
.release_device = apple_dart_release_device,
1204+
.device_group = apple_dart_device_group,
1205+
.of_xlate = apple_dart_of_xlate,
1206+
.get_resv_regions = apple_dart_get_resv_regions,
1207+
.owner = THIS_MODULE,
1208+
.default_domain_ops = &(const struct iommu_domain_ops) {
1209+
.attach_dev = apple_dart_attach_dev_paging,
1210+
.map_pages = apple_dart_map_pages,
1211+
.unmap_pages = apple_dart_unmap_pages,
1212+
.flush_iotlb_all = apple_dart_flush_iotlb_all,
1213+
.iotlb_sync = apple_dart_iotlb_sync,
1214+
.iotlb_sync_map = apple_dart_iotlb_sync_map,
1215+
.iova_to_phys = apple_dart_iova_to_phys,
1216+
.free = apple_dart_domain_free,
1217+
}
12351218
};
12361219

12371220
static irqreturn_t apple_dart_t8020_irq(int irq, void *dev)
@@ -1445,12 +1428,7 @@ static int apple_dart_probe(struct platform_device *pdev)
14451428
if (ret)
14461429
goto err_free_irq;
14471430

1448-
if (dart->locked)
1449-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_locked_ops, dev);
1450-
else if (!dart->supports_bypass)
1451-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_no_bypass_ops, dev);
1452-
else
1453-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
1431+
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
14541432
if (ret)
14551433
goto err_sysfs_remove;
14561434

0 commit comments

Comments
 (0)