@@ -1006,6 +1006,11 @@ static int apple_dart_def_domain_type(struct device *dev)
10061006 return 0 ;
10071007}
10081008
1009+ static int apple_dart_def_domain_type_dma (struct device * dev )
1010+ {
1011+ return IOMMU_DOMAIN_DMA ;
1012+ }
1013+
10091014#ifndef CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR
10101015/* Keep things compiling when CONFIG_PCI_APPLE isn't selected */
10111016#define CONFIG_PCIE_APPLE_MSI_DOORBELL_ADDR 0
@@ -1031,27 +1036,36 @@ static void apple_dart_get_resv_regions(struct device *dev,
10311036 iommu_dma_get_resv_regions (dev , head );
10321037}
10331038
1039+ #define APPLE_DART_IOMMU_COMMON_OPS () \
1040+ .domain_alloc_paging = apple_dart_domain_alloc_paging, \
1041+ .probe_device = apple_dart_probe_device, \
1042+ .release_device = apple_dart_release_device, \
1043+ .device_group = apple_dart_device_group, \
1044+ .of_xlate = apple_dart_of_xlate, \
1045+ .get_resv_regions = apple_dart_get_resv_regions, \
1046+ .owner = THIS_MODULE, \
1047+ .default_domain_ops = &(const struct iommu_domain_ops) { \
1048+ .attach_dev = apple_dart_attach_dev_paging, \
1049+ .map_pages = apple_dart_map_pages, \
1050+ .unmap_pages = apple_dart_unmap_pages, \
1051+ .flush_iotlb_all = apple_dart_flush_iotlb_all, \
1052+ .iotlb_sync = apple_dart_iotlb_sync, \
1053+ .iotlb_sync_map = apple_dart_iotlb_sync_map, \
1054+ .iova_to_phys = apple_dart_iova_to_phys, \
1055+ .free = apple_dart_domain_free, \
1056+ }
1057+
10341058static const struct iommu_ops apple_dart_iommu_ops = {
10351059 .identity_domain = & apple_dart_identity_domain ,
10361060 .blocked_domain = & apple_dart_blocked_domain ,
1037- .domain_alloc_paging = apple_dart_domain_alloc_paging ,
1038- .probe_device = apple_dart_probe_device ,
1039- .release_device = apple_dart_release_device ,
1040- .device_group = apple_dart_device_group ,
1041- .of_xlate = apple_dart_of_xlate ,
10421061 .def_domain_type = apple_dart_def_domain_type ,
1043- .get_resv_regions = apple_dart_get_resv_regions ,
1044- .owner = THIS_MODULE ,
1045- .default_domain_ops = & (const struct iommu_domain_ops ) {
1046- .attach_dev = apple_dart_attach_dev_paging ,
1047- .map_pages = apple_dart_map_pages ,
1048- .unmap_pages = apple_dart_unmap_pages ,
1049- .flush_iotlb_all = apple_dart_flush_iotlb_all ,
1050- .iotlb_sync = apple_dart_iotlb_sync ,
1051- .iotlb_sync_map = apple_dart_iotlb_sync_map ,
1052- .iova_to_phys = apple_dart_iova_to_phys ,
1053- .free = apple_dart_domain_free ,
1054- }
1062+ APPLE_DART_IOMMU_COMMON_OPS ()
1063+ };
1064+
1065+ static const struct iommu_ops apple_dart_iommu_no_bypass_ops = {
1066+ .blocked_domain = & apple_dart_blocked_domain ,
1067+ .def_domain_type = apple_dart_def_domain_type_dma ,
1068+ APPLE_DART_IOMMU_COMMON_OPS ()
10551069};
10561070
10571071static irqreturn_t apple_dart_t8020_irq (int irq , void * dev )
@@ -1257,7 +1271,10 @@ static int apple_dart_probe(struct platform_device *pdev)
12571271 if (ret )
12581272 goto err_free_irq ;
12591273
1260- ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_ops , dev );
1274+ if (!dart -> supports_bypass )
1275+ ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_no_bypass_ops , dev );
1276+ else
1277+ ret = iommu_device_register (& dart -> iommu , & apple_dart_iommu_ops , dev );
12611278 if (ret )
12621279 goto err_sysfs_remove ;
12631280
0 commit comments