@@ -778,16 +778,16 @@ is_downstream_to_pci_bridge(struct device *dev, struct device *bridge)
778
778
return false;
779
779
}
780
780
781
- static struct intel_iommu * device_to_iommu (struct device * dev , u8 * bus , u8 * devfn )
781
+ struct intel_iommu * device_to_iommu (struct device * dev , u8 * bus , u8 * devfn )
782
782
{
783
783
struct dmar_drhd_unit * drhd = NULL ;
784
+ struct pci_dev * pdev = NULL ;
784
785
struct intel_iommu * iommu ;
785
786
struct device * tmp ;
786
- struct pci_dev * pdev = NULL ;
787
787
u16 segment = 0 ;
788
788
int i ;
789
789
790
- if (iommu_dummy (dev ))
790
+ if (! dev || iommu_dummy (dev ))
791
791
return NULL ;
792
792
793
793
if (dev_is_pci (dev )) {
@@ -818,8 +818,10 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
818
818
if (pdev && pdev -> is_virtfn )
819
819
goto got_pdev ;
820
820
821
- * bus = drhd -> devices [i ].bus ;
822
- * devfn = drhd -> devices [i ].devfn ;
821
+ if (bus && devfn ) {
822
+ * bus = drhd -> devices [i ].bus ;
823
+ * devfn = drhd -> devices [i ].devfn ;
824
+ }
823
825
goto out ;
824
826
}
825
827
@@ -829,8 +831,10 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
829
831
830
832
if (pdev && drhd -> include_all ) {
831
833
got_pdev :
832
- * bus = pdev -> bus -> number ;
833
- * devfn = pdev -> devfn ;
834
+ if (bus && devfn ) {
835
+ * bus = pdev -> bus -> number ;
836
+ * devfn = pdev -> devfn ;
837
+ }
834
838
goto out ;
835
839
}
836
840
}
@@ -5146,11 +5150,10 @@ static int aux_domain_add_dev(struct dmar_domain *domain,
5146
5150
struct device * dev )
5147
5151
{
5148
5152
int ret ;
5149
- u8 bus , devfn ;
5150
5153
unsigned long flags ;
5151
5154
struct intel_iommu * iommu ;
5152
5155
5153
- iommu = device_to_iommu (dev , & bus , & devfn );
5156
+ iommu = device_to_iommu (dev , NULL , NULL );
5154
5157
if (!iommu )
5155
5158
return - ENODEV ;
5156
5159
@@ -5236,9 +5239,8 @@ static int prepare_domain_attach_device(struct iommu_domain *domain,
5236
5239
struct dmar_domain * dmar_domain = to_dmar_domain (domain );
5237
5240
struct intel_iommu * iommu ;
5238
5241
int addr_width ;
5239
- u8 bus , devfn ;
5240
5242
5241
- iommu = device_to_iommu (dev , & bus , & devfn );
5243
+ iommu = device_to_iommu (dev , NULL , NULL );
5242
5244
if (!iommu )
5243
5245
return - ENODEV ;
5244
5246
@@ -5668,9 +5670,8 @@ static bool intel_iommu_capable(enum iommu_cap cap)
5668
5670
static struct iommu_device * intel_iommu_probe_device (struct device * dev )
5669
5671
{
5670
5672
struct intel_iommu * iommu ;
5671
- u8 bus , devfn ;
5672
5673
5673
- iommu = device_to_iommu (dev , & bus , & devfn );
5674
+ iommu = device_to_iommu (dev , NULL , NULL );
5674
5675
if (!iommu )
5675
5676
return ERR_PTR (- ENODEV );
5676
5677
@@ -5683,9 +5684,8 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
5683
5684
static void intel_iommu_release_device (struct device * dev )
5684
5685
{
5685
5686
struct intel_iommu * iommu ;
5686
- u8 bus , devfn ;
5687
5687
5688
- iommu = device_to_iommu (dev , & bus , & devfn );
5688
+ iommu = device_to_iommu (dev , NULL , NULL );
5689
5689
if (!iommu )
5690
5690
return ;
5691
5691
@@ -5835,37 +5835,14 @@ static struct iommu_group *intel_iommu_device_group(struct device *dev)
5835
5835
return generic_device_group (dev );
5836
5836
}
5837
5837
5838
- #ifdef CONFIG_INTEL_IOMMU_SVM
5839
- struct intel_iommu * intel_svm_device_to_iommu (struct device * dev )
5840
- {
5841
- struct intel_iommu * iommu ;
5842
- u8 bus , devfn ;
5843
-
5844
- if (iommu_dummy (dev )) {
5845
- dev_warn (dev ,
5846
- "No IOMMU translation for device; cannot enable SVM\n" );
5847
- return NULL ;
5848
- }
5849
-
5850
- iommu = device_to_iommu (dev , & bus , & devfn );
5851
- if ((!iommu )) {
5852
- dev_err (dev , "No IOMMU for device; cannot enable SVM\n" );
5853
- return NULL ;
5854
- }
5855
-
5856
- return iommu ;
5857
- }
5858
- #endif /* CONFIG_INTEL_IOMMU_SVM */
5859
-
5860
5838
static int intel_iommu_enable_auxd (struct device * dev )
5861
5839
{
5862
5840
struct device_domain_info * info ;
5863
5841
struct intel_iommu * iommu ;
5864
5842
unsigned long flags ;
5865
- u8 bus , devfn ;
5866
5843
int ret ;
5867
5844
5868
- iommu = device_to_iommu (dev , & bus , & devfn );
5845
+ iommu = device_to_iommu (dev , NULL , NULL );
5869
5846
if (!iommu || dmar_disabled )
5870
5847
return - EINVAL ;
5871
5848
0 commit comments