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