mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 05:24:12 +08:00
701fac4038
PASIDs are process-wide. It was attempted to use refcounted PASIDs to free them when the last thread drops the refcount. This turned out to be complex and error prone. Given the fact that the PASID space is 20 bits, which allows up to 1M processes to have a PASID associated concurrently, PASID resource exhaustion is not a realistic concern. Therefore, it was decided to simplify the approach and stick with lazy on demand PASID allocation, but drop the eager free approach and make an allocated PASID's lifetime bound to the lifetime of the process. Get rid of the refcounting mechanisms and replace/rename the interfaces to reflect this new approach. [ bp: Massage commit message. ] Suggested-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Jacob Pan <jacob.jun.pan@linux.intel.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Joerg Roedel <jroedel@suse.de> Link: https://lore.kernel.org/r/20220207230254.3342514-6-fenghua.yu@intel.com
68 lines
1.5 KiB
C
68 lines
1.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* SVA library for IOMMU drivers
|
|
*/
|
|
#ifndef _IOMMU_SVA_LIB_H
|
|
#define _IOMMU_SVA_LIB_H
|
|
|
|
#include <linux/ioasid.h>
|
|
#include <linux/mm_types.h>
|
|
|
|
int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t max);
|
|
struct mm_struct *iommu_sva_find(ioasid_t pasid);
|
|
|
|
/* I/O Page fault */
|
|
struct device;
|
|
struct iommu_fault;
|
|
struct iopf_queue;
|
|
|
|
#ifdef CONFIG_IOMMU_SVA
|
|
int iommu_queue_iopf(struct iommu_fault *fault, void *cookie);
|
|
|
|
int iopf_queue_add_device(struct iopf_queue *queue, struct device *dev);
|
|
int iopf_queue_remove_device(struct iopf_queue *queue,
|
|
struct device *dev);
|
|
int iopf_queue_flush_dev(struct device *dev);
|
|
struct iopf_queue *iopf_queue_alloc(const char *name);
|
|
void iopf_queue_free(struct iopf_queue *queue);
|
|
int iopf_queue_discard_partial(struct iopf_queue *queue);
|
|
|
|
#else /* CONFIG_IOMMU_SVA */
|
|
static inline int iommu_queue_iopf(struct iommu_fault *fault, void *cookie)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
|
|
static inline int iopf_queue_add_device(struct iopf_queue *queue,
|
|
struct device *dev)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
|
|
static inline int iopf_queue_remove_device(struct iopf_queue *queue,
|
|
struct device *dev)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
|
|
static inline int iopf_queue_flush_dev(struct device *dev)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
|
|
static inline struct iopf_queue *iopf_queue_alloc(const char *name)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline void iopf_queue_free(struct iopf_queue *queue)
|
|
{
|
|
}
|
|
|
|
static inline int iopf_queue_discard_partial(struct iopf_queue *queue)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
#endif /* CONFIG_IOMMU_SVA */
|
|
#endif /* _IOMMU_SVA_LIB_H */
|