提交 0cd76dd1 编写于 作者: J Joerg Roedel

iommu: Add domain-attribute handlers

This patch introduces an extension to the iommu-api to get
and set attributes for an iommu_domain. Two functions are
introduced for this:

	* iommu_domain_get_attr()
	* iommu_domain_set_attr()

These functions will be used to make the iommu-api suitable
for GART-like IOMMUs and to implement hardware-specifc
api-extensions.
Signed-off-by: NJoerg Roedel <joerg.roedel@amd.com>
上级 bd0a521e
...@@ -344,3 +344,23 @@ int iommu_device_group(struct device *dev, unsigned int *groupid) ...@@ -344,3 +344,23 @@ int iommu_device_group(struct device *dev, unsigned int *groupid)
return -ENODEV; return -ENODEV;
} }
EXPORT_SYMBOL_GPL(iommu_device_group); EXPORT_SYMBOL_GPL(iommu_device_group);
int iommu_domain_get_attr(struct iommu_domain *domain,
enum iommu_attr attr, void *data)
{
if (!domain->ops->domain_get_attr)
return -EINVAL;
return domain->ops->domain_get_attr(domain, attr, data);
}
EXPORT_SYMBOL_GPL(iommu_domain_get_attr);
int iommu_domain_set_attr(struct iommu_domain *domain,
enum iommu_attr attr, void *data)
{
if (!domain->ops->domain_set_attr)
return -EINVAL;
return domain->ops->domain_set_attr(domain, attr, data);
}
EXPORT_SYMBOL_GPL(iommu_domain_set_attr);
...@@ -47,6 +47,10 @@ struct iommu_domain { ...@@ -47,6 +47,10 @@ struct iommu_domain {
#define IOMMU_CAP_CACHE_COHERENCY 0x1 #define IOMMU_CAP_CACHE_COHERENCY 0x1
#define IOMMU_CAP_INTR_REMAP 0x2 /* isolates device intrs */ #define IOMMU_CAP_INTR_REMAP 0x2 /* isolates device intrs */
enum iommu_attr {
DOMAIN_ATTR_MAX,
};
#ifdef CONFIG_IOMMU_API #ifdef CONFIG_IOMMU_API
/** /**
...@@ -59,7 +63,8 @@ struct iommu_domain { ...@@ -59,7 +63,8 @@ struct iommu_domain {
* @unmap: unmap a physically contiguous memory region from an iommu domain * @unmap: unmap a physically contiguous memory region from an iommu domain
* @iova_to_phys: translate iova to physical address * @iova_to_phys: translate iova to physical address
* @domain_has_cap: domain capabilities query * @domain_has_cap: domain capabilities query
* @commit: commit iommu domain * @domain_get_attr: Query domain attributes
* @domain_set_attr: Change domain attributes
* @pgsize_bitmap: bitmap of supported page sizes * @pgsize_bitmap: bitmap of supported page sizes
*/ */
struct iommu_ops { struct iommu_ops {
...@@ -76,6 +81,10 @@ struct iommu_ops { ...@@ -76,6 +81,10 @@ struct iommu_ops {
int (*domain_has_cap)(struct iommu_domain *domain, int (*domain_has_cap)(struct iommu_domain *domain,
unsigned long cap); unsigned long cap);
int (*device_group)(struct device *dev, unsigned int *groupid); int (*device_group)(struct device *dev, unsigned int *groupid);
int (*domain_get_attr)(struct iommu_domain *domain,
enum iommu_attr attr, void *data);
int (*domain_set_attr)(struct iommu_domain *domain,
enum iommu_attr attr, void *data);
unsigned long pgsize_bitmap; unsigned long pgsize_bitmap;
}; };
...@@ -99,6 +108,11 @@ extern void iommu_set_fault_handler(struct iommu_domain *domain, ...@@ -99,6 +108,11 @@ extern void iommu_set_fault_handler(struct iommu_domain *domain,
iommu_fault_handler_t handler, void *token); iommu_fault_handler_t handler, void *token);
extern int iommu_device_group(struct device *dev, unsigned int *groupid); extern int iommu_device_group(struct device *dev, unsigned int *groupid);
extern int iommu_domain_get_attr(struct iommu_domain *domain, enum iommu_attr,
void *data);
extern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr,
void *data);
/** /**
* report_iommu_fault() - report about an IOMMU fault to the IOMMU framework * report_iommu_fault() - report about an IOMMU fault to the IOMMU framework
* @domain: the iommu domain where the fault has happened * @domain: the iommu domain where the fault has happened
...@@ -202,6 +216,18 @@ static inline int iommu_device_group(struct device *dev, unsigned int *groupid) ...@@ -202,6 +216,18 @@ static inline int iommu_device_group(struct device *dev, unsigned int *groupid)
return -ENODEV; return -ENODEV;
} }
static inline int iommu_domain_get_attr(struct iommu_domain *domain,
enum iommu_attr attr, void *data)
{
return -EINVAL;
}
static inline int iommu_domain_set_attr(struct iommu_domain *domain,
enum iommu_attr attr, void *data)
{
return -EINVAL;
}
#endif /* CONFIG_IOMMU_API */ #endif /* CONFIG_IOMMU_API */
#endif /* __LINUX_IOMMU_H */ #endif /* __LINUX_IOMMU_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册