@@ -659,11 +659,7 @@ static int apple_dart_attach_dev(struct iommu_domain *domain,
659
659
struct apple_dart_master_cfg * cfg = dev_iommu_priv_get (dev );
660
660
struct apple_dart_domain * dart_domain = to_dart_domain (domain );
661
661
662
- if (cfg -> stream_maps [0 ].dart -> force_bypass &&
663
- domain -> type != IOMMU_DOMAIN_IDENTITY )
664
- return - EINVAL ;
665
- if (!cfg -> stream_maps [0 ].dart -> supports_bypass &&
666
- domain -> type == IOMMU_DOMAIN_IDENTITY )
662
+ if (cfg -> stream_maps [0 ].dart -> force_bypass )
667
663
return - EINVAL ;
668
664
669
665
ret = apple_dart_finalize_domain (domain , cfg );
@@ -684,15 +680,35 @@ static int apple_dart_attach_dev(struct iommu_domain *domain,
684
680
for_each_stream_map (i , cfg , stream_map )
685
681
apple_dart_hw_disable_dma (stream_map );
686
682
break ;
687
- case IOMMU_DOMAIN_IDENTITY :
688
- for_each_stream_map (i , cfg , stream_map )
689
- apple_dart_hw_enable_bypass (stream_map );
690
- break ;
691
683
}
692
684
693
685
return ret ;
694
686
}
695
687
688
+ static int apple_dart_attach_dev_identity (struct iommu_domain * domain ,
689
+ struct device * dev )
690
+ {
691
+ struct apple_dart_master_cfg * cfg = dev_iommu_priv_get (dev );
692
+ struct apple_dart_stream_map * stream_map ;
693
+ int i ;
694
+
695
+ if (!cfg -> stream_maps [0 ].dart -> supports_bypass )
696
+ return - EINVAL ;
697
+
698
+ for_each_stream_map (i , cfg , stream_map )
699
+ apple_dart_hw_enable_bypass (stream_map );
700
+ return 0 ;
701
+ }
702
+
703
+ static const struct iommu_domain_ops apple_dart_identity_ops = {
704
+ .attach_dev = apple_dart_attach_dev_identity ,
705
+ };
706
+
707
+ static struct iommu_domain apple_dart_identity_domain = {
708
+ .type = IOMMU_DOMAIN_IDENTITY ,
709
+ .ops = & apple_dart_identity_ops ,
710
+ };
711
+
696
712
static struct iommu_device * apple_dart_probe_device (struct device * dev )
697
713
{
698
714
struct apple_dart_master_cfg * cfg = dev_iommu_priv_get (dev );
@@ -723,7 +739,7 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type)
723
739
struct apple_dart_domain * dart_domain ;
724
740
725
741
if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED &&
726
- type != IOMMU_DOMAIN_IDENTITY && type != IOMMU_DOMAIN_BLOCKED )
742
+ type != IOMMU_DOMAIN_BLOCKED )
727
743
return NULL ;
728
744
729
745
dart_domain = kzalloc (sizeof (* dart_domain ), GFP_KERNEL );
@@ -733,7 +749,7 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type)
733
749
mutex_init (& dart_domain -> init_lock );
734
750
735
751
/* no need to allocate pgtbl_ops or do any other finalization steps */
736
- if (type == IOMMU_DOMAIN_IDENTITY || type == IOMMU_DOMAIN_BLOCKED )
752
+ if (type == IOMMU_DOMAIN_BLOCKED )
737
753
dart_domain -> finalized = true;
738
754
739
755
return & dart_domain -> domain ;
@@ -948,6 +964,7 @@ static void apple_dart_get_resv_regions(struct device *dev,
948
964
}
949
965
950
966
static const struct iommu_ops apple_dart_iommu_ops = {
967
+ .identity_domain = & apple_dart_identity_domain ,
951
968
.domain_alloc = apple_dart_domain_alloc ,
952
969
.probe_device = apple_dart_probe_device ,
953
970
.release_device = apple_dart_release_device ,
0 commit comments