@@ -805,24 +805,8 @@ static int ipmmu_of_xlate(struct device *dev,
805
805
static int ipmmu_init_arm_mapping (struct device * dev )
806
806
{
807
807
struct ipmmu_vmsa_device * mmu = to_ipmmu (dev );
808
- struct iommu_group * group ;
809
808
int ret ;
810
809
811
- /* Create a device group and add the device to it. */
812
- group = iommu_group_alloc ();
813
- if (IS_ERR (group )) {
814
- dev_err (dev , "Failed to allocate IOMMU group\n" );
815
- return PTR_ERR (group );
816
- }
817
-
818
- ret = iommu_group_add_device (group , dev );
819
- iommu_group_put (group );
820
-
821
- if (ret < 0 ) {
822
- dev_err (dev , "Failed to add device to IPMMU group\n" );
823
- return ret ;
824
- }
825
-
826
810
/*
827
811
* Create the ARM mapping, used by the ARM DMA mapping core to allocate
828
812
* VAs. This will allocate a corresponding IOMMU domain.
@@ -856,48 +840,39 @@ static int ipmmu_init_arm_mapping(struct device *dev)
856
840
return 0 ;
857
841
858
842
error :
859
- iommu_group_remove_device (dev );
860
843
if (mmu -> mapping )
861
844
arm_iommu_release_mapping (mmu -> mapping );
862
845
863
846
return ret ;
864
847
}
865
848
866
- static int ipmmu_add_device (struct device * dev )
849
+ static struct iommu_device * ipmmu_probe_device (struct device * dev )
867
850
{
868
851
struct ipmmu_vmsa_device * mmu = to_ipmmu (dev );
869
- struct iommu_group * group ;
870
- int ret ;
871
852
872
853
/*
873
854
* Only let through devices that have been verified in xlate()
874
855
*/
875
856
if (!mmu )
876
- return - ENODEV ;
857
+ return ERR_PTR ( - ENODEV ) ;
877
858
878
- if (IS_ENABLED (CONFIG_ARM ) && !IS_ENABLED (CONFIG_IOMMU_DMA )) {
879
- ret = ipmmu_init_arm_mapping (dev );
880
- if (ret )
881
- return ret ;
882
- } else {
883
- group = iommu_group_get_for_dev (dev );
884
- if (IS_ERR (group ))
885
- return PTR_ERR (group );
859
+ return & mmu -> iommu ;
860
+ }
886
861
887
- iommu_group_put (group );
888
- }
862
+ static void ipmmu_probe_finalize (struct device * dev )
863
+ {
864
+ int ret = 0 ;
889
865
890
- iommu_device_link (& mmu -> iommu , dev );
891
- return 0 ;
866
+ if (IS_ENABLED (CONFIG_ARM ) && !IS_ENABLED (CONFIG_IOMMU_DMA ))
867
+ ret = ipmmu_init_arm_mapping (dev );
868
+
869
+ if (ret )
870
+ dev_err (dev , "Can't create IOMMU mapping - DMA-OPS will not work\n" );
892
871
}
893
872
894
- static void ipmmu_remove_device (struct device * dev )
873
+ static void ipmmu_release_device (struct device * dev )
895
874
{
896
- struct ipmmu_vmsa_device * mmu = to_ipmmu (dev );
897
-
898
- iommu_device_unlink (& mmu -> iommu , dev );
899
875
arm_iommu_detach_device (dev );
900
- iommu_group_remove_device (dev );
901
876
}
902
877
903
878
static struct iommu_group * ipmmu_find_group (struct device * dev )
@@ -925,9 +900,14 @@ static const struct iommu_ops ipmmu_ops = {
925
900
.flush_iotlb_all = ipmmu_flush_iotlb_all ,
926
901
.iotlb_sync = ipmmu_iotlb_sync ,
927
902
.iova_to_phys = ipmmu_iova_to_phys ,
928
- .add_device = ipmmu_add_device ,
929
- .remove_device = ipmmu_remove_device ,
903
+ .probe_device = ipmmu_probe_device ,
904
+ .release_device = ipmmu_release_device ,
905
+ .probe_finalize = ipmmu_probe_finalize ,
906
+ #if defined(CONFIG_ARM ) && !defined (CONFIG_IOMMU_DMA )
907
+ .device_group = generic_device_group ,
908
+ #else
930
909
.device_group = ipmmu_find_group ,
910
+ #endif
931
911
.pgsize_bitmap = SZ_1G | SZ_2M | SZ_4K ,
932
912
.of_xlate = ipmmu_of_xlate ,
933
913
};
0 commit comments