Skip to content

Commit f2ccffe

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 ef50e9a commit f2ccffe

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
@@ -1158,15 +1158,12 @@ static int apple_dart_def_domain_type(struct device *dev)
11581158
return IOMMU_DOMAIN_IDENTITY;
11591159
if (!cfg->supports_bypass)
11601160
return IOMMU_DOMAIN_DMA;
1161+
if (cfg->locked)
1162+
return IOMMU_DOMAIN_DMA;
11611163

11621164
return 0;
11631165
}
11641166

1165-
static int apple_dart_def_domain_type_dma(struct device *dev)
1166-
{
1167-
return IOMMU_DOMAIN_DMA;
1168-
}
1169-
11701167
#ifndef CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
11711168
/* Keep things compiling when CONFIG_PCI_APPLE isn't selected */
11721169
#define CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR 0
@@ -1192,41 +1189,27 @@ static void apple_dart_get_resv_regions(struct device *dev,
11921189
iommu_dma_get_resv_regions(dev, head);
11931190
}
11941191

1195-
#define APPLE_DART_IOMMU_COMMON_OPS() \
1196-
.domain_alloc_paging = apple_dart_domain_alloc_paging, \
1197-
.probe_device = apple_dart_probe_device, \
1198-
.release_device = apple_dart_release_device, \
1199-
.device_group = apple_dart_device_group, \
1200-
.of_xlate = apple_dart_of_xlate, \
1201-
.get_resv_regions = apple_dart_get_resv_regions, \
1202-
.owner = THIS_MODULE, \
1203-
.default_domain_ops = &(const struct iommu_domain_ops) { \
1204-
.attach_dev = apple_dart_attach_dev_paging, \
1205-
.map_pages = apple_dart_map_pages, \
1206-
.unmap_pages = apple_dart_unmap_pages, \
1207-
.flush_iotlb_all = apple_dart_flush_iotlb_all, \
1208-
.iotlb_sync = apple_dart_iotlb_sync, \
1209-
.iotlb_sync_map = apple_dart_iotlb_sync_map, \
1210-
.iova_to_phys = apple_dart_iova_to_phys, \
1211-
.free = apple_dart_domain_free, \
1212-
}
1213-
12141192
static const struct iommu_ops apple_dart_iommu_ops = {
12151193
.identity_domain = &apple_dart_identity_domain,
12161194
.blocked_domain = &apple_dart_blocked_domain,
12171195
.def_domain_type = apple_dart_def_domain_type,
1218-
APPLE_DART_IOMMU_COMMON_OPS()
1219-
};
1220-
1221-
static const struct iommu_ops apple_dart_iommu_no_bypass_ops = {
1222-
.blocked_domain = &apple_dart_blocked_domain,
1223-
.def_domain_type = apple_dart_def_domain_type_dma,
1224-
APPLE_DART_IOMMU_COMMON_OPS()
1225-
};
1226-
1227-
static const struct iommu_ops apple_dart_iommu_locked_ops = {
1228-
.def_domain_type = apple_dart_def_domain_type_dma,
1229-
APPLE_DART_IOMMU_COMMON_OPS()
1196+
.domain_alloc_paging = apple_dart_domain_alloc_paging,
1197+
.probe_device = apple_dart_probe_device,
1198+
.release_device = apple_dart_release_device,
1199+
.device_group = apple_dart_device_group,
1200+
.of_xlate = apple_dart_of_xlate,
1201+
.get_resv_regions = apple_dart_get_resv_regions,
1202+
.owner = THIS_MODULE,
1203+
.default_domain_ops = &(const struct iommu_domain_ops) {
1204+
.attach_dev = apple_dart_attach_dev_paging,
1205+
.map_pages = apple_dart_map_pages,
1206+
.unmap_pages = apple_dart_unmap_pages,
1207+
.flush_iotlb_all = apple_dart_flush_iotlb_all,
1208+
.iotlb_sync = apple_dart_iotlb_sync,
1209+
.iotlb_sync_map = apple_dart_iotlb_sync_map,
1210+
.iova_to_phys = apple_dart_iova_to_phys,
1211+
.free = apple_dart_domain_free,
1212+
}
12301213
};
12311214

12321215
static irqreturn_t apple_dart_t8020_irq(int irq, void *dev)
@@ -1440,12 +1423,7 @@ static int apple_dart_probe(struct platform_device *pdev)
14401423
if (ret)
14411424
goto err_free_irq;
14421425

1443-
if (dart->locked)
1444-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_locked_ops, dev);
1445-
else if (!dart->supports_bypass)
1446-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_no_bypass_ops, dev);
1447-
else
1448-
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
1426+
ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev);
14491427
if (ret)
14501428
goto err_sysfs_remove;
14511429

0 commit comments

Comments
 (0)