Skip to contentSkip to conversation

iommu: Make iommu_sva_domain_alloc() static

PATCH Applied Lu Baolu 5 participants 7 messages May 28, 2024 – Jun 13, 2024 IOMMU

lore
Share & tools
lore

Lu Baolu

author
#0 lore raw

PATCH 1/1 iommu: Make iommu_sva_domain_alloc() static

iommu_sva_domain_alloc() is only called in iommu-sva.c, hence make it static.

On the other hand, iommu_sva_domain_alloc() should not return NULL anymore after commit <80af5a452024> ("iommu: Add ops->domain_alloc_sva()"), the removal of inline code avoids potential confusion.

Fixes 80af5a452024 ("iommu: Add ops->domain_alloc_sva()")
---
 include/linux/iommu.h     | 8 --------
 drivers/iommu/iommu-sva.c | 6 ++++--
 2 files changed, 4 insertions(+), 10 deletions(-)
include/linux/iommu.h +0 -8
index 7bc8dff7cf6d..5cdd3d41b87b 100644
@@ -1527,8 +1527,6 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev,
 					struct mm_struct *mm);
 void iommu_sva_unbind_device(struct iommu_sva *handle);
 u32 iommu_sva_get_pasid(struct iommu_sva *handle);
-struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
-					    struct mm_struct *mm);
 #else
 static inline struct iommu_sva *
 iommu_sva_bind_device(struct device *dev, struct mm_struct *mm)
@@ -1553,12 +1551,6 @@ static inline u32 mm_get_enqcmd_pasid(struct mm_struct *mm)
 }
 
 static inline void mm_pasid_drop(struct mm_struct *mm) {}
-
-static inline struct iommu_domain *
-iommu_sva_domain_alloc(struct device *dev, struct mm_struct *mm)
-{
-	return NULL;
-}
 #endif /* CONFIG_IOMMU_SVA */
 
 #ifdef CONFIG_IOMMU_IOPF
drivers/iommu/iommu-sva.c +4 -2
index 18a35e798b72..25e581299226 100644
@@ -10,6 +10,8 @@
 #include "iommu-priv.h"
 
 static DEFINE_MUTEX(iommu_sva_lock);
+static struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
+						   struct mm_struct *mm);
 
 /* Allocate a PASID for the mm within range (inclusive) */
 static struct iommu_mm_data *iommu_alloc_mm_data(struct mm_struct *mm, struct device *dev)
@@ -277,8 +279,8 @@ static int iommu_sva_iopf_handler(struct iopf_group *group)
 	return 0;
 }
 
-struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
-					    struct mm_struct *mm)
+static struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
+						   struct mm_struct *mm)
 {
 	const struct iommu_ops *ops = dev_iommu_ops(dev);
 	struct iommu_domain *domain;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines

From: Lu Baolu <[email protected]>
Sent: Tuesday, May 28, 2024 12:55 PM

iommu_sva_domain_alloc() is only called in iommu-sva.c, hence make it static.

Quoted 7 lines

On the other hand, iommu_sva_domain_alloc() should not return NULL anymore
after commit <80af5a452024> ("iommu: Add ops->domain_alloc_sva()"), the removal of inline code avoids potential confusion.

Fixes 80af5a452024 ("iommu: Add ops->domain_alloc_sva()")
#2 lore raw
In reply to Lu Baolu

Hi Lu,

Quoted 45 lines · Lu Baolu

iommu_sva_domain_alloc() is only called in iommu-sva.c, hence make it static.

On the other hand, iommu_sva_domain_alloc() should not return NULL anymore after commit <80af5a452024> ("iommu: Add ops->domain_alloc_sva()"), the removal of inline code avoids potential confusion.

Fixes 80af5a452024 ("iommu: Add ops->domain_alloc_sva()")
---
 include/linux/iommu.h     | 8 --------
 drivers/iommu/iommu-sva.c | 6 ++++--
 2 files changed, 4 insertions(+), 10 deletions(-)
include/linux/iommu.h +0 -8
index 7bc8dff7cf6d..5cdd3d41b87b 100644
@@ -1527,8 +1527,6 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev,
 					struct mm_struct *mm);
 void iommu_sva_unbind_device(struct iommu_sva *handle);
 u32 iommu_sva_get_pasid(struct iommu_sva *handle);
-struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
-					    struct mm_struct *mm);
 #else
 static inline struct iommu_sva *
 iommu_sva_bind_device(struct device *dev, struct mm_struct *mm)
@@ -1553,12 +1551,6 @@ static inline u32 mm_get_enqcmd_pasid(struct mm_struct *mm)
 }
 
 static inline void mm_pasid_drop(struct mm_struct *mm) {}
-
-static inline struct iommu_domain *
-iommu_sva_domain_alloc(struct device *dev, struct mm_struct *mm)
-{
-	return NULL;
-}
 #endif /* CONFIG_IOMMU_SVA */
 
 #ifdef CONFIG_IOMMU_IOPF
drivers/iommu/iommu-sva.c +0 -0
index 18a35e798b72..25e581299226 100644

drivers/iommu/iommu-sva.c line 14

Quoted 5 lines
drivers/iommu/iommu-sva.c +2 -0
@@ -10,6 +10,8 @@
 #include "iommu-priv.h"
 
 static DEFINE_MUTEX(iommu_sva_lock);
+static struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
+						   struct mm_struct *mm);

If we move move iommu_sva_domain_alloc() before iommu_sva_bind_device() then we can avoid this forward declaration.

-Vasant

author
#3 lore raw
Quoted 48 lines · Vasant Hegde
Quoted 47 lines · Lu Baolu

iommu_sva_domain_alloc() is only called in iommu-sva.c, hence make it static.

On the other hand, iommu_sva_domain_alloc() should not return NULL anymore after commit <80af5a452024> ("iommu: Add ops->domain_alloc_sva()"), the removal of inline code avoids potential confusion.

Fixes 80af5a452024 ("iommu: Add ops->domain_alloc_sva()")
---
  include/linux/iommu.h     | 8 --------
  drivers/iommu/iommu-sva.c | 6 ++++--
  2 files changed, 4 insertions(+), 10 deletions(-)
include/linux/iommu.h +0 -8
index 7bc8dff7cf6d..5cdd3d41b87b 100644
@@ -1527,8 +1527,6 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev,
  					struct mm_struct *mm);
  void iommu_sva_unbind_device(struct iommu_sva *handle);
  u32 iommu_sva_get_pasid(struct iommu_sva *handle);
-struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
-					    struct mm_struct *mm);
  #else
  static inline struct iommu_sva *
  iommu_sva_bind_device(struct device *dev, struct mm_struct *mm)
@@ -1553,12 +1551,6 @@ static inline u32 mm_get_enqcmd_pasid(struct mm_struct *mm)
  }
 
  static inline void mm_pasid_drop(struct mm_struct *mm) {}
-
-static inline struct iommu_domain *
-iommu_sva_domain_alloc(struct device *dev, struct mm_struct *mm)
-{
-	return NULL;
-}
  #endif /* CONFIG_IOMMU_SVA */
 
  #ifdef CONFIG_IOMMU_IOPF
drivers/iommu/iommu-sva.c +0 -0
index 18a35e798b72..25e581299226 100644
@@ -10,6 +10,8 @@
  #include "iommu-priv.h"
 
Quoted 5 lines

drivers/iommu/iommu-sva.c line 14

Quoted 3 lines
drivers/iommu/iommu-sva.c +2 -0
  static DEFINE_MUTEX(iommu_sva_lock);
+static struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
+						   struct mm_struct *mm);

If we move move iommu_sva_domain_alloc() before iommu_sva_bind_device() then we can avoid this forward declaration.

Yeah, but that means moving 144 lines of code. That's why I went with this approach

Best regards,
baolu

#4 lore raw
Quoted 54 lines · Baolu Lu
Quoted 44 lines · Vasant Hegde
Quoted 43 lines · Lu Baolu

iommu_sva_domain_alloc() is only called in iommu-sva.c, hence make it static.

On the other hand, iommu_sva_domain_alloc() should not return NULL anymore after commit <80af5a452024> ("iommu: Add ops->domain_alloc_sva()"), the removal of inline code avoids potential confusion.

Fixes 80af5a452024 ("iommu: Add ops->domain_alloc_sva()")

---
  include/linux/iommu.h     | 8 --------
  drivers/iommu/iommu-sva.c | 6 ++++--

  2 files changed, 4 insertions(+), 10 deletions(-)
include/linux/iommu.h +0 -2
index 7bc8dff7cf6d..5cdd3d41b87b 100644
@@ -1527,8 +1527,6 @@ struct iommu_sva *iommu_sva_bind_device(struct device
 *dev,
                       struct mm_struct *mm);
   void iommu_sva_unbind_device(struct iommu_sva *handle);
   u32 iommu_sva_get_pasid(struct iommu_sva *handle);
-struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
-                        struct mm_struct *mm);
   #else

  static inline struct iommu_sva * iommu_sva_bind_device(struct device *dev, struct mm_struct *mm)

include/linux/iommu.h +0 -6
@@ -1553,12 +1551,6 @@ static inline u32 mm_get_enqcmd_pasid(struct mm_struct
 *mm)
   }
     static inline void mm_pasid_drop(struct mm_struct *mm) {}
-
-static inline struct iommu_domain *
-iommu_sva_domain_alloc(struct device *dev, struct mm_struct *mm)
-{
-    return NULL;
-}
   #endif /* CONFIG_IOMMU_SVA */
     #ifdef CONFIG_IOMMU_IOPF
drivers/iommu/iommu-sva.c +0 -1
index 18a35e798b72..25e581299226 100644
--- a/drivers/iommu/iommu-sva.c
Quoted 8 lines

drivers/iommu/iommu-sva.c line 13

Quoted 6 lines

+++ b/drivers/iommu/iommu-sva.c

drivers/iommu/iommu-sva.c +2 -0
@@ -10,6 +10,8 @@
   #include "iommu-priv.h"
     static DEFINE_MUTEX(iommu_sva_lock);
+static struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
+                           struct mm_struct *mm);

If we move move iommu_sva_domain_alloc() before iommu_sva_bind_device() then we can avoid this forward declaration.

Quoted 2 lines

Yeah, but that means moving 144 lines of code. That's why I went with this approach

Ah right. I didn't realized we have 'iopf_handler' in iommu_sva_domain_alloc().

-Vasant

Reviewed-by on v1 1/1
#5 lore raw
In reply to Lu Baolu
Quoted 7 lines · Lu Baolu

iommu_sva_domain_alloc() is only called in iommu-sva.c, hence make it static.

On the other hand, iommu_sva_domain_alloc() should not return NULL anymore after commit <80af5a452024> ("iommu: Add ops->domain_alloc_sva()"), the removal of inline code avoids potential confusion.

Quoted 6 lines
Fixes 80af5a452024 ("iommu: Add ops->domain_alloc_sva()")
---
 include/linux/iommu.h     | 8 --------
 drivers/iommu/iommu-sva.c | 6 ++++--
 2 files changed, 4 insertions(+), 10 deletions(-)

Jason

maintainer Applied
#6 lore raw
In reply to Lu Baolu
Quoted 7 lines · Lu Baolu

iommu_sva_domain_alloc() is only called in iommu-sva.c, hence make it static.

On the other hand, iommu_sva_domain_alloc() should not return NULL anymore after commit <80af5a452024> ("iommu: Add ops->domain_alloc_sva()"), the removal of inline code avoids potential confusion.

Quoted 6 lines
Fixes 80af5a452024 ("iommu: Add ops->domain_alloc_sva()")
---
 include/linux/iommu.h     | 8 --------
 drivers/iommu/iommu-sva.c | 6 ++++--
 2 files changed, 4 insertions(+), 10 deletions(-)

Applied, thanks.