diff options
| author | Joerg Roedel <jroedel@suse.de> | 2015-05-28 18:41:33 +0200 |
|---|---|---|
| committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-22 11:15:09 -0700 |
| commit | ef3a0f2227741c4bfeb91b03b64349feb5a1bd53 (patch) | |
| tree | c5efc318ad84b401ad97afd522d59bdebf5c7e44 | |
| parent | 2944c708c952d0a4af0c1173485300ab15500d97 (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.
Change-Id: Iab55341a8526084a5110dc5a2d4448fd46e3296a
Signed-off-by: Joerg Roedel <jroedel@suse.de>
[pdaly@codeaurora.org Resolve minor conflicts]
| -rw-r--r-- | drivers/iommu/iommu.c | 16 | ||||
| -rw-r--r-- | include/linux/iommu.h | 31 |
2 files changed, 47 insertions, 0 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index ad0371b6b2e3..74fabfa8222f 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1570,3 +1570,19 @@ int iommu_dma_supported(struct iommu_domain *domain, struct device *dev, return domain->ops->dma_supported(domain, dev, mask); return 0; } + +void iommu_get_dm_regions(struct device *dev, struct list_head *list) +{ + const struct iommu_ops *ops = dev->bus->iommu_ops; + + if (ops && ops->get_dm_regions) + ops->get_dm_regions(dev, list); +} + +void iommu_put_dm_regions(struct device *dev, struct list_head *list) +{ + const struct iommu_ops *ops = dev->bus->iommu_ops; + + if (ops && ops->put_dm_regions) + ops->put_dm_regions(dev, list); +} diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 29dc5c2c9b8e..3ceee4600d52 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -131,6 +131,20 @@ enum iommu_attr { extern struct dentry *iommu_debugfs_top; +/** + * struct iommu_dm_region - descriptor for a direct mapped memory region + * @list: Linked list pointers + * @start: System physical start address of the region + * @length: Length of the region in bytes + * @prot: IOMMU Protection flags (READ/WRITE/...) + */ +struct iommu_dm_region { + struct list_head list; + phys_addr_t start; + size_t length; + int prot; +}; + #ifdef CONFIG_IOMMU_API /** @@ -182,6 +196,10 @@ struct iommu_ops { int (*domain_set_attr)(struct iommu_domain *domain, enum iommu_attr attr, void *data); + /* Request/Free a list of direct mapping requirements for a device */ + void (*get_dm_regions)(struct device *dev, struct list_head *list); + void (*put_dm_regions)(struct device *dev, struct list_head *list); + /* Window handling functions */ int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr, phys_addr_t paddr, u64 size, int prot); @@ -245,6 +263,9 @@ extern unsigned long iommu_reg_read(struct iommu_domain *domain, extern void iommu_reg_write(struct iommu_domain *domain, unsigned long offset, unsigned long val); +extern void iommu_get_dm_regions(struct device *dev, struct list_head *list); +extern void iommu_put_dm_regions(struct device *dev, struct list_head *list); + extern int iommu_attach_group(struct iommu_domain *domain, struct iommu_group *group); extern void iommu_detach_group(struct iommu_domain *domain, @@ -454,6 +475,16 @@ static inline void iommu_reg_write(struct iommu_domain *domain, { } +static inline void iommu_get_dm_regions(struct device *dev, + struct list_head *list) +{ +} + +static inline void iommu_put_dm_regions(struct device *dev, + struct list_head *list) +{ +} + static inline int iommu_attach_group(struct iommu_domain *domain, struct iommu_group *group) { |
