@@ -779,7 +779,7 @@ static inline bool iort_iommu_driver_enabled(u8 type)
779779static struct acpi_iort_node * iort_get_msi_resv_iommu (struct device * dev )
780780{
781781 struct acpi_iort_node * iommu ;
782- struct iommu_fwspec * fwspec = dev -> iommu_fwspec ;
782+ struct iommu_fwspec * fwspec = dev_iommu_fwspec_get ( dev ) ;
783783
784784 iommu = iort_get_iort_node (fwspec -> iommu_fwnode );
785785
@@ -794,9 +794,10 @@ static struct acpi_iort_node *iort_get_msi_resv_iommu(struct device *dev)
794794 return NULL ;
795795}
796796
797- static inline const struct iommu_ops * iort_fwspec_iommu_ops (
798- struct iommu_fwspec * fwspec )
797+ static inline const struct iommu_ops * iort_fwspec_iommu_ops (struct device * dev )
799798{
799+ struct iommu_fwspec * fwspec = dev_iommu_fwspec_get (dev );
800+
800801 return (fwspec && fwspec -> ops ) ? fwspec -> ops : NULL ;
801802}
802803
@@ -805,8 +806,8 @@ static inline int iort_add_device_replay(const struct iommu_ops *ops,
805806{
806807 int err = 0 ;
807808
808- if (ops -> add_device && dev -> bus && !dev -> iommu_group )
809- err = ops -> add_device (dev );
809+ if (dev -> bus && !device_iommu_mapped ( dev ) )
810+ err = iommu_probe_device (dev );
810811
811812 return err ;
812813}
@@ -824,6 +825,7 @@ static inline int iort_add_device_replay(const struct iommu_ops *ops,
824825 */
825826int iort_iommu_msi_get_resv_regions (struct device * dev , struct list_head * head )
826827{
828+ struct iommu_fwspec * fwspec = dev_iommu_fwspec_get (dev );
827829 struct acpi_iort_its_group * its ;
828830 struct acpi_iort_node * iommu_node , * its_node = NULL ;
829831 int i , resv = 0 ;
@@ -841,9 +843,9 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)
841843 * a given PCI or named component may map IDs to.
842844 */
843845
844- for (i = 0 ; i < dev -> iommu_fwspec -> num_ids ; i ++ ) {
846+ for (i = 0 ; i < fwspec -> num_ids ; i ++ ) {
845847 its_node = iort_node_map_id (iommu_node ,
846- dev -> iommu_fwspec -> ids [i ],
848+ fwspec -> ids [i ],
847849 NULL , IORT_MSI_TYPE );
848850 if (its_node )
849851 break ;
@@ -874,8 +876,7 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)
874876 return (resv == its -> its_count ) ? resv : - ENODEV ;
875877}
876878#else
877- static inline const struct iommu_ops * iort_fwspec_iommu_ops (
878- struct iommu_fwspec * fwspec )
879+ static inline const struct iommu_ops * iort_fwspec_iommu_ops (struct device * dev );
879880{ return NULL ; }
880881static inline int iort_add_device_replay (const struct iommu_ops * ops ,
881882 struct device * dev )
@@ -1045,7 +1046,7 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev)
10451046 * If we already translated the fwspec there
10461047 * is nothing left to do, return the iommu_ops.
10471048 */
1048- ops = iort_fwspec_iommu_ops (dev -> iommu_fwspec );
1049+ ops = iort_fwspec_iommu_ops (dev );
10491050 if (ops )
10501051 return ops ;
10511052
@@ -1084,7 +1085,7 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev)
10841085 * add_device callback for dev, replay it to get things in order.
10851086 */
10861087 if (!err ) {
1087- ops = iort_fwspec_iommu_ops (dev -> iommu_fwspec );
1088+ ops = iort_fwspec_iommu_ops (dev );
10881089 err = iort_add_device_replay (ops , dev );
10891090 }
10901091
0 commit comments