[RFC,1/6] iommu: Add two pasid helper functions
Commit Message
mm_get_pasid() is for getting mm pasid value and mm_set_pasid() is for
setting mm pasid value.
The motivation is to replace mm->pasid with an iommu private data
structure that is introduced in a later patch.
Signed-off-by: Tina Zhang <tina.zhang@intel.com>
---
arch/x86/kernel/traps.c | 2 +-
include/linux/iommu.h | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
@@ -678,7 +678,7 @@ static bool try_fixup_enqcmd_gp(void)
if (!mm_valid_pasid(current->mm))
return false;
- pasid = current->mm->pasid;
+ pasid = mm_get_pasid(current->mm);
/*
* Did this thread already have its PASID activated?
@@ -1174,6 +1174,15 @@ static inline bool mm_valid_pasid(struct mm_struct *mm)
{
return mm->pasid != IOMMU_PASID_INVALID;
}
+static inline u32 mm_get_pasid(struct mm_struct *mm)
+{
+ return mm->pasid;
+}
+
+static inline void mm_set_pasid(struct mm_struct *mm, u32 pasid)
+{
+ mm->pasid = pasid;
+}
void mm_pasid_drop(struct mm_struct *mm);
struct iommu_sva *iommu_sva_bind_device(struct device *dev,
struct mm_struct *mm);
@@ -1196,6 +1205,11 @@ static inline u32 iommu_sva_get_pasid(struct iommu_sva *handle)
}
static inline void mm_pasid_init(struct mm_struct *mm) {}
static inline bool mm_valid_pasid(struct mm_struct *mm) { return false; }
+static inline u32 mm_get_pasid(struct mm_struct *mm)
+{
+ return IOMMU_PASID_INVALID;
+}
+static inline void mm_set_pasid(struct mm_struct *mm, u32 pasid) {}
static inline void mm_pasid_drop(struct mm_struct *mm) {}
#endif /* CONFIG_IOMMU_SVA */