@@ -957,6 +957,11 @@ static int apple_dart_def_domain_type(struct device *dev)
957957 return 0 ;
958958}
959959
960+ static int apple_dart_def_domain_type_dma (struct device * dev )
961+ {
962+ return IOMMU_DOMAIN_DMA ;
963+ }
964+
960965#ifndef CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
961966/* Keep things compiling when CONFIG_PCI_APPLE isn't selected */
962967#define CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR 0
@@ -982,28 +987,37 @@ static void apple_dart_get_resv_regions(struct device *dev,
982987 iommu_dma_get_resv_regions (dev , head );
983988}
984989
990+ #define APPLE_DART_IOMMU_COMMON_OPS () \
991+ .domain_alloc_paging = apple_dart_domain_alloc_paging, \
992+ .probe_device = apple_dart_probe_device, \
993+ .release_device = apple_dart_release_device, \
994+ .device_group = apple_dart_device_group, \
995+ .of_xlate = apple_dart_of_xlate, \
996+ .get_resv_regions = apple_dart_get_resv_regions, \
997+ .pgsize_bitmap = -1UL, /* Restricted during dart probe */ \
998+ .owner = THIS_MODULE, \
999+ .default_domain_ops = &(const struct iommu_domain_ops) { \
1000+ .attach_dev = apple_dart_attach_dev_paging, \
1001+ .map_pages = apple_dart_map_pages, \
1002+ .unmap_pages = apple_dart_unmap_pages, \
1003+ .flush_iotlb_all = apple_dart_flush_iotlb_all, \
1004+ .iotlb_sync = apple_dart_iotlb_sync, \
1005+ .iotlb_sync_map = apple_dart_iotlb_sync_map, \
1006+ .iova_to_phys = apple_dart_iova_to_phys, \
1007+ .free = apple_dart_domain_free, \
1008+ }
1009+
9851010static const struct iommu_ops apple_dart_iommu_ops = {
9861011 .identity_domain = & apple_dart_identity_domain ,
9871012 .blocked_domain = & apple_dart_blocked_domain ,
988- .domain_alloc_paging = apple_dart_domain_alloc_paging ,
989- .probe_device = apple_dart_probe_device ,
990- .release_device = apple_dart_release_device ,
991- .device_group = apple_dart_device_group ,
992- .of_xlate = apple_dart_of_xlate ,
9931013 .def_domain_type = apple_dart_def_domain_type ,
994- .get_resv_regions = apple_dart_get_resv_regions ,
995- .pgsize_bitmap = -1UL , /* Restricted during dart probe */
996- .owner = THIS_MODULE ,
997- .default_domain_ops = & (const struct iommu_domain_ops ) {
998- .attach_dev = apple_dart_attach_dev_paging ,
999- .map_pages = apple_dart_map_pages ,
1000- .unmap_pages = apple_dart_unmap_pages ,
1001- .flush_iotlb_all = apple_dart_flush_iotlb_all ,
1002- .iotlb_sync = apple_dart_iotlb_sync ,
1003- .iotlb_sync_map = apple_dart_iotlb_sync_map ,
1004- .iova_to_phys = apple_dart_iova_to_phys ,
1005- .free = apple_dart_domain_free ,
1006- }
1014+ APPLE_DART_IOMMU_COMMON_OPS ()
1015+ };
1016+
1017+ static const struct iommu_ops apple_dart_iommu_no_bypass_ops = {
1018+ .blocked_domain = & apple_dart_blocked_domain ,
1019+ .def_domain_type = apple_dart_def_domain_type_dma ,
1020+ APPLE_DART_IOMMU_COMMON_OPS ()
10071021};
10081022
10091023static irqreturn_t apple_dart_t8020_irq (int irq , void * dev )
@@ -1165,7 +1179,10 @@ static int apple_dart_probe(struct platform_device *pdev)
11651179 if (ret )
11661180 goto err_free_irq ;
11671181
1168- ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_ops , dev );
1182+ if (!dart -> supports_bypass )
1183+ ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_no_bypass_ops , dev );
1184+ else
1185+ ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_ops , dev );
11691186 if (ret )
11701187 goto err_sysfs_remove ;
11711188
0 commit comments