Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Joerg Roedel <joerg.roedel@amd.com>

+47 -1
+20
drivers/iommu/iommu.c
··· 344 344 return -ENODEV; 345 345 } 346 346 EXPORT_SYMBOL_GPL(iommu_device_group); 347 + 348 + int iommu_domain_get_attr(struct iommu_domain *domain, 349 + enum iommu_attr attr, void *data) 350 + { 351 + if (!domain->ops->domain_get_attr) 352 + return -EINVAL; 353 + 354 + return domain->ops->domain_get_attr(domain, attr, data); 355 + } 356 + EXPORT_SYMBOL_GPL(iommu_domain_get_attr); 357 + 358 + int iommu_domain_set_attr(struct iommu_domain *domain, 359 + enum iommu_attr attr, void *data) 360 + { 361 + if (!domain->ops->domain_set_attr) 362 + return -EINVAL; 363 + 364 + return domain->ops->domain_set_attr(domain, attr, data); 365 + } 366 + EXPORT_SYMBOL_GPL(iommu_domain_set_attr);
+27 -1
include/linux/iommu.h
··· 47 47 #define IOMMU_CAP_CACHE_COHERENCY 0x1 48 48 #define IOMMU_CAP_INTR_REMAP 0x2 /* isolates device intrs */ 49 49 50 + enum iommu_attr { 51 + DOMAIN_ATTR_MAX, 52 + }; 53 + 50 54 #ifdef CONFIG_IOMMU_API 51 55 52 56 /** ··· 63 59 * @unmap: unmap a physically contiguous memory region from an iommu domain 64 60 * @iova_to_phys: translate iova to physical address 65 61 * @domain_has_cap: domain capabilities query 66 - * @commit: commit iommu domain 62 + * @domain_get_attr: Query domain attributes 63 + * @domain_set_attr: Change domain attributes 67 64 * @pgsize_bitmap: bitmap of supported page sizes 68 65 */ 69 66 struct iommu_ops { ··· 81 76 int (*domain_has_cap)(struct iommu_domain *domain, 82 77 unsigned long cap); 83 78 int (*device_group)(struct device *dev, unsigned int *groupid); 79 + int (*domain_get_attr)(struct iommu_domain *domain, 80 + enum iommu_attr attr, void *data); 81 + int (*domain_set_attr)(struct iommu_domain *domain, 82 + enum iommu_attr attr, void *data); 84 83 unsigned long pgsize_bitmap; 85 84 }; 86 85 ··· 107 98 extern void iommu_set_fault_handler(struct iommu_domain *domain, 108 99 iommu_fault_handler_t handler, void *token); 109 100 extern int iommu_device_group(struct device *dev, unsigned int *groupid); 101 + 102 + extern int iommu_domain_get_attr(struct iommu_domain *domain, enum iommu_attr, 103 + void *data); 104 + extern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr, 105 + void *data); 110 106 111 107 /** 112 108 * report_iommu_fault() - report about an IOMMU fault to the IOMMU framework ··· 214 200 static inline int iommu_device_group(struct device *dev, unsigned int *groupid) 215 201 { 216 202 return -ENODEV; 203 + } 204 + 205 + static inline int iommu_domain_get_attr(struct iommu_domain *domain, 206 + enum iommu_attr attr, void *data) 207 + { 208 + return -EINVAL; 209 + } 210 + 211 + static inline int iommu_domain_set_attr(struct iommu_domain *domain, 212 + enum iommu_attr attr, void *data) 213 + { 214 + return -EINVAL; 217 215 } 218 216 219 217 #endif /* CONFIG_IOMMU_API */