@@ -277,6 +277,9 @@ struct apple_dart_domain {
277
277
* @streams: streams for this device
278
278
*/
279
279
struct apple_dart_master_cfg {
280
+ /* Intersection of DART capabilitles */
281
+ u32 supports_bypass : 1 ;
282
+
280
283
struct apple_dart_stream_map stream_maps [MAX_DARTS_PER_DEVICE ];
281
284
};
282
285
@@ -684,7 +687,7 @@ static int apple_dart_attach_dev_identity(struct iommu_domain *domain,
684
687
struct apple_dart_stream_map * stream_map ;
685
688
int i ;
686
689
687
- if (!cfg -> stream_maps [ 0 ]. dart -> supports_bypass )
690
+ if (!cfg -> supports_bypass )
688
691
return - EINVAL ;
689
692
690
693
for_each_stream_map (i , cfg , stream_map )
@@ -792,20 +795,24 @@ static int apple_dart_of_xlate(struct device *dev,
792
795
return - EINVAL ;
793
796
sid = args -> args [0 ];
794
797
795
- if (!cfg )
798
+ if (!cfg ) {
796
799
cfg = kzalloc (sizeof (* cfg ), GFP_KERNEL );
800
+
801
+ /* Will be ANDed with DART capabilities */
802
+ cfg -> supports_bypass = true;
803
+ }
797
804
if (!cfg )
798
805
return - ENOMEM ;
799
806
dev_iommu_priv_set (dev , cfg );
800
807
801
808
cfg_dart = cfg -> stream_maps [0 ].dart ;
802
809
if (cfg_dart ) {
803
- if (cfg_dart -> supports_bypass != dart -> supports_bypass )
804
- return - EINVAL ;
805
810
if (cfg_dart -> pgsize != dart -> pgsize )
806
811
return - EINVAL ;
807
812
}
808
813
814
+ cfg -> supports_bypass &= dart -> supports_bypass ;
815
+
809
816
for (i = 0 ; i < MAX_DARTS_PER_DEVICE ; ++ i ) {
810
817
if (cfg -> stream_maps [i ].dart == dart ) {
811
818
set_bit (sid , cfg -> stream_maps [i ].sidmap );
@@ -945,7 +952,7 @@ static int apple_dart_def_domain_type(struct device *dev)
945
952
946
953
if (cfg -> stream_maps [0 ].dart -> pgsize > PAGE_SIZE )
947
954
return IOMMU_DOMAIN_IDENTITY ;
948
- if (!cfg -> stream_maps [ 0 ]. dart -> supports_bypass )
955
+ if (!cfg -> supports_bypass )
949
956
return IOMMU_DOMAIN_DMA ;
950
957
951
958
return 0 ;
0 commit comments