aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2015-05-28 12:41:33 -0400
committerJoerg Roedel <jroedel@suse.de>2015-06-09 02:55:23 -0400
commita1015c2b99b94cf521603b41debf167114031456 (patch)
tree9d088f6fd69a45acd0d5c40031845561f6d06064
parent2c1296d92ac0367364bcb73a43c12a0bdfbfee75 (diff)
iommu: Introduce direct mapped region handling
Add two new functions to the IOMMU-API to allow the IOMMU drivers to export the requirements for direct mapped regions per device. This is useful for exporting the information in Intel VT-d's RMRR entries or AMD-Vi's unity mappings. Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r--drivers/iommu/iommu.c16
-rw-r--r--include/linux/iommu.h31
2 files changed, 47 insertions, 0 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index a0a38bd2668b..6b8d6e7771e1 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1469,3 +1469,19 @@ int iommu_domain_set_attr(struct iommu_domain *domain,
1469 return ret; 1469 return ret;
1470} 1470}
1471EXPORT_SYMBOL_GPL(iommu_domain_set_attr); 1471EXPORT_SYMBOL_GPL(iommu_domain_set_attr);
1472
1473void iommu_get_dm_regions(struct device *dev, struct list_head *list)
1474{
1475 const struct iommu_ops *ops = dev->bus->iommu_ops;
1476
1477 if (ops && ops->get_dm_regions)
1478 ops->get_dm_regions(dev, list);
1479}
1480
1481void iommu_put_dm_regions(struct device *dev, struct list_head *list)
1482{
1483 const struct iommu_ops *ops = dev->bus->iommu_ops;
1484
1485 if (ops && ops->put_dm_regions)
1486 ops->put_dm_regions(dev, list);
1487}
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 683a1c4b15e7..689499904166 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -114,6 +114,20 @@ enum iommu_attr {
114 DOMAIN_ATTR_MAX, 114 DOMAIN_ATTR_MAX,
115}; 115};
116 116
117/**
118 * struct iommu_dm_region - descriptor for a direct mapped memory region
119 * @list: Linked list pointers
120 * @start: System physical start address of the region
121 * @length: Length of the region in bytes
122 * @prot: IOMMU Protection flags (READ/WRITE/...)
123 */
124struct iommu_dm_region {
125 struct list_head list;
126 phys_addr_t start;
127 size_t length;
128 int prot;
129};
130
117#ifdef CONFIG_IOMMU_API 131#ifdef CONFIG_IOMMU_API
118 132
119/** 133/**
@@ -159,6 +173,10 @@ struct iommu_ops {
159 int (*domain_set_attr)(struct iommu_domain *domain, 173 int (*domain_set_attr)(struct iommu_domain *domain,
160 enum iommu_attr attr, void *data); 174 enum iommu_attr attr, void *data);
161 175
176 /* Request/Free a list of direct mapping requirements for a device */
177 void (*get_dm_regions)(struct device *dev, struct list_head *list);
178 void (*put_dm_regions)(struct device *dev, struct list_head *list);
179
162 /* Window handling functions */ 180 /* Window handling functions */
163 int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr, 181 int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr,
164 phys_addr_t paddr, u64 size, int prot); 182 phys_addr_t paddr, u64 size, int prot);
@@ -205,6 +223,9 @@ extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t io
205extern void iommu_set_fault_handler(struct iommu_domain *domain, 223extern void iommu_set_fault_handler(struct iommu_domain *domain,
206 iommu_fault_handler_t handler, void *token); 224 iommu_fault_handler_t handler, void *token);
207 225
226extern void iommu_get_dm_regions(struct device *dev, struct list_head *list);
227extern void iommu_put_dm_regions(struct device *dev, struct list_head *list);
228
208extern int iommu_attach_group(struct iommu_domain *domain, 229extern int iommu_attach_group(struct iommu_domain *domain,
209 struct iommu_group *group); 230 struct iommu_group *group);
210extern void iommu_detach_group(struct iommu_domain *domain, 231extern void iommu_detach_group(struct iommu_domain *domain,
@@ -379,6 +400,16 @@ static inline void iommu_set_fault_handler(struct iommu_domain *domain,
379{ 400{
380} 401}
381 402
403static inline void iommu_get_dm_regions(struct device *dev,
404 struct list_head *list)
405{
406}
407
408static inline void iommu_put_dm_regions(struct device *dev,
409 struct list_head *list)
410{
411}
412
382static inline int iommu_attach_group(struct iommu_domain *domain, 413static inline int iommu_attach_group(struct iommu_domain *domain,
383 struct iommu_group *group) 414 struct iommu_group *group)
384{ 415{