@@ -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,42 +1184,28 @@ 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- .pgsize_bitmap = -1UL, /* Restricted during dart probe */ \
1198- .owner = THIS_MODULE, \
1199- .default_domain_ops = &(const struct iommu_domain_ops) { \
1200- .attach_dev = apple_dart_attach_dev_paging, \
1201- .map_pages = apple_dart_map_pages, \
1202- .unmap_pages = apple_dart_unmap_pages, \
1203- .flush_iotlb_all = apple_dart_flush_iotlb_all, \
1204- .iotlb_sync = apple_dart_iotlb_sync, \
1205- .iotlb_sync_map = apple_dart_iotlb_sync_map, \
1206- .iova_to_phys = apple_dart_iova_to_phys, \
1207- .free = apple_dart_domain_free, \
1208- }
1209-
12101187static const struct iommu_ops apple_dart_iommu_ops = {
12111188 .identity_domain = & apple_dart_identity_domain ,
12121189 .blocked_domain = & apple_dart_blocked_domain ,
12131190 .def_domain_type = apple_dart_def_domain_type ,
1214- APPLE_DART_IOMMU_COMMON_OPS ()
1215- };
1216-
1217- static const struct iommu_ops apple_dart_iommu_no_bypass_ops = {
1218- .blocked_domain = & apple_dart_blocked_domain ,
1219- .def_domain_type = apple_dart_def_domain_type_dma ,
1220- APPLE_DART_IOMMU_COMMON_OPS ()
1221- };
1222-
1223- static const struct iommu_ops apple_dart_iommu_locked_ops = {
1224- .def_domain_type = apple_dart_def_domain_type_dma ,
1225- 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+ .pgsize_bitmap = -1UL , /* Restricted during dart probe */
1198+ .owner = THIS_MODULE ,
1199+ .default_domain_ops = & (const struct iommu_domain_ops ) {
1200+ .attach_dev = apple_dart_attach_dev_paging ,
1201+ .map_pages = apple_dart_map_pages ,
1202+ .unmap_pages = apple_dart_unmap_pages ,
1203+ .flush_iotlb_all = apple_dart_flush_iotlb_all ,
1204+ .iotlb_sync = apple_dart_iotlb_sync ,
1205+ .iotlb_sync_map = apple_dart_iotlb_sync_map ,
1206+ .iova_to_phys = apple_dart_iova_to_phys ,
1207+ .free = apple_dart_domain_free ,
1208+ }
12261209};
12271210
12281211static irqreturn_t apple_dart_t8020_irq (int irq , void * dev )
@@ -1437,12 +1420,7 @@ static int apple_dart_probe(struct platform_device *pdev)
14371420 if (ret )
14381421 goto err_free_irq ;
14391422
1440- if (dart -> locked )
1441- ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_locked_ops , dev );
1442- else if (!dart -> supports_bypass )
1443- ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_no_bypass_ops , dev );
1444- else
1445- ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_ops , dev );
1423+ ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_ops , dev );
14461424 if (ret )
14471425 goto err_sysfs_remove ;
14481426
0 commit comments