Messages in this thread Patch in this message | | | From | Jacob Pan <> | Subject | [PATCH v3 2/5] iommu/sva: Move PASID helpers to sva code | Date | Thu, 16 Feb 2023 15:59:48 -0800 |
| |
Preparing to remove IOASID infrastructure, PASID management will be under SVA code.
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> --- drivers/iommu/iommu-sva.c | 19 +++++++++++++++++++ include/linux/sched/mm.h | 22 +++------------------- 2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c index 24bf9b2b58aa..a3ee258936f0 100644 --- a/drivers/iommu/iommu-sva.c +++ b/drivers/iommu/iommu-sva.c @@ -71,6 +71,25 @@ struct mm_struct *iommu_sva_find(ioasid_t pasid) } EXPORT_SYMBOL_GPL(iommu_sva_find); +void mm_pasid_init(struct mm_struct *mm) +{ + mm->pasid = INVALID_IOASID; +} + +/* Associate a PASID with an mm_struct: */ +void mm_pasid_set(struct mm_struct *mm, u32 pasid) +{ + mm->pasid = pasid; +} + +void mm_pasid_drop(struct mm_struct *mm) +{ + if (pasid_valid(mm->pasid)) { + ioasid_free(mm->pasid); + mm->pasid = INVALID_IOASID; + } +} + /** * iommu_sva_bind_device() - Bind a process address space to a device * @dev: the device diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 2a243616f222..c488c7241102 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -8,7 +8,6 @@ #include <linux/mm_types.h> #include <linux/gfp.h> #include <linux/sync_core.h> -#include <linux/ioasid.h> /* * Routines for handling mm_structs @@ -452,24 +451,9 @@ static inline void membarrier_update_current_mm(struct mm_struct *next_mm) #endif #ifdef CONFIG_IOMMU_SVA -static inline void mm_pasid_init(struct mm_struct *mm) -{ - mm->pasid = INVALID_IOASID; -} - -/* Associate a PASID with an mm_struct: */ -static inline void mm_pasid_set(struct mm_struct *mm, u32 pasid) -{ - mm->pasid = pasid; -} - -static inline void mm_pasid_drop(struct mm_struct *mm) -{ - if (pasid_valid(mm->pasid)) { - ioasid_free(mm->pasid); - mm->pasid = INVALID_IOASID; - } -} +void mm_pasid_init(struct mm_struct *mm); +void mm_pasid_set(struct mm_struct *mm, u32 pasid); +void mm_pasid_drop(struct mm_struct *mm); #else static inline void mm_pasid_init(struct mm_struct *mm) {} static inline void mm_pasid_set(struct mm_struct *mm, u32 pasid) {} -- 2.25.1
| |