@@ -1002,6 +1002,11 @@ static int apple_dart_def_domain_type(struct device *dev)
10021002 return 0 ;
10031003}
10041004
1005+ static int apple_dart_def_domain_type_dma (struct device * dev )
1006+ {
1007+ return IOMMU_DOMAIN_DMA ;
1008+ }
1009+
10051010#ifndef CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
10061011/* Keep things compiling when CONFIG_PCI_APPLE isn't selected */
10071012#define CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR 0
@@ -1027,28 +1032,37 @@ static void apple_dart_get_resv_regions(struct device *dev,
10271032 iommu_dma_get_resv_regions (dev , head );
10281033}
10291034
1035+ #define APPLE_DART_IOMMU_COMMON_OPS () \
1036+ .domain_alloc_paging = apple_dart_domain_alloc_paging, \
1037+ .probe_device = apple_dart_probe_device, \
1038+ .release_device = apple_dart_release_device, \
1039+ .device_group = apple_dart_device_group, \
1040+ .of_xlate = apple_dart_of_xlate, \
1041+ .get_resv_regions = apple_dart_get_resv_regions, \
1042+ .pgsize_bitmap = -1UL, /* Restricted during dart probe */ \
1043+ .owner = THIS_MODULE, \
1044+ .default_domain_ops = &(const struct iommu_domain_ops) { \
1045+ .attach_dev = apple_dart_attach_dev_paging, \
1046+ .map_pages = apple_dart_map_pages, \
1047+ .unmap_pages = apple_dart_unmap_pages, \
1048+ .flush_iotlb_all = apple_dart_flush_iotlb_all, \
1049+ .iotlb_sync = apple_dart_iotlb_sync, \
1050+ .iotlb_sync_map = apple_dart_iotlb_sync_map, \
1051+ .iova_to_phys = apple_dart_iova_to_phys, \
1052+ .free = apple_dart_domain_free, \
1053+ }
1054+
10301055static const struct iommu_ops apple_dart_iommu_ops = {
10311056 .identity_domain = & apple_dart_identity_domain ,
10321057 .blocked_domain = & apple_dart_blocked_domain ,
1033- .domain_alloc_paging = apple_dart_domain_alloc_paging ,
1034- .probe_device = apple_dart_probe_device ,
1035- .release_device = apple_dart_release_device ,
1036- .device_group = apple_dart_device_group ,
1037- .of_xlate = apple_dart_of_xlate ,
10381058 .def_domain_type = apple_dart_def_domain_type ,
1039- .get_resv_regions = apple_dart_get_resv_regions ,
1040- .pgsize_bitmap = -1UL , /* Restricted during dart probe */
1041- .owner = THIS_MODULE ,
1042- .default_domain_ops = & (const struct iommu_domain_ops ) {
1043- .attach_dev = apple_dart_attach_dev_paging ,
1044- .map_pages = apple_dart_map_pages ,
1045- .unmap_pages = apple_dart_unmap_pages ,
1046- .flush_iotlb_all = apple_dart_flush_iotlb_all ,
1047- .iotlb_sync = apple_dart_iotlb_sync ,
1048- .iotlb_sync_map = apple_dart_iotlb_sync_map ,
1049- .iova_to_phys = apple_dart_iova_to_phys ,
1050- .free = apple_dart_domain_free ,
1051- }
1059+ APPLE_DART_IOMMU_COMMON_OPS ()
1060+ };
1061+
1062+ static const struct iommu_ops apple_dart_iommu_no_bypass_ops = {
1063+ .blocked_domain = & apple_dart_blocked_domain ,
1064+ .def_domain_type = apple_dart_def_domain_type_dma ,
1065+ APPLE_DART_IOMMU_COMMON_OPS ()
10521066};
10531067
10541068static irqreturn_t apple_dart_t8020_irq (int irq , void * dev )
@@ -1255,7 +1269,10 @@ static int apple_dart_probe(struct platform_device *pdev)
12551269 if (ret )
12561270 goto err_free_irq ;
12571271
1258- ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_ops , dev );
1272+ if (!dart -> supports_bypass )
1273+ ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_no_bypass_ops , dev );
1274+ else
1275+ ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_ops , dev );
12591276 if (ret )
12601277 goto err_sysfs_remove ;
12611278
0 commit comments