2020-11-06 15:50:48 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* SVA library for IOMMU drivers
|
|
|
|
*/
|
2022-10-31 00:59:17 +00:00
|
|
|
#ifndef _IOMMU_SVA_H
|
|
|
|
#define _IOMMU_SVA_H
|
2020-11-06 15:50:48 +00:00
|
|
|
|
|
|
|
#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);
|
|
|
|
|
2021-04-01 15:47:15 +00:00
|
|
|
/* I/O Page fault */
|
|
|
|
struct device;
|
|
|
|
struct iommu_fault;
|
|
|
|
struct iopf_queue;
|
|
|
|
|
2022-02-07 23:02:44 +00:00
|
|
|
#ifdef CONFIG_IOMMU_SVA
|
2021-04-01 15:47:15 +00:00
|
|
|
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);
|
2022-10-31 00:59:15 +00:00
|
|
|
enum iommu_page_response_code
|
|
|
|
iommu_sva_handle_iopf(struct iommu_fault *fault, void *data);
|
2021-04-01 15:47:15 +00:00
|
|
|
|
2022-02-07 23:02:44 +00:00
|
|
|
#else /* CONFIG_IOMMU_SVA */
|
2021-04-01 15:47:15 +00:00
|
|
|
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;
|
|
|
|
}
|
2022-10-31 00:59:15 +00:00
|
|
|
|
|
|
|
static inline enum iommu_page_response_code
|
|
|
|
iommu_sva_handle_iopf(struct iommu_fault *fault, void *data)
|
|
|
|
{
|
|
|
|
return IOMMU_PAGE_RESP_INVALID;
|
|
|
|
}
|
2022-02-07 23:02:44 +00:00
|
|
|
#endif /* CONFIG_IOMMU_SVA */
|
2022-10-31 00:59:17 +00:00
|
|
|
#endif /* _IOMMU_SVA_H */
|