diff options
author | Eric Auger <eric.auger@redhat.com> | 2017-01-19 15:57:49 -0500 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2017-01-23 06:48:16 -0500 |
commit | 2b20cbba3390a55c511acba2f0f517dd27a528b2 (patch) | |
tree | f88d74a181db5f6d0b7c801c51ab18db26ab16ed | |
parent | d30ddcaa7b028049cdfee3a40248002d07b2bbf3 (diff) |
iommu: iommu_alloc_resv_region
Introduce a new helper serving the purpose to allocate a reserved
region. This will be used in iommu driver implementing reserved
region callbacks.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Tomasz Nowicki <tomasz.nowicki@caviumnetworks.com>
Tested-by: Tomasz Nowicki <tomasz.nowicki@caviumnetworks.com>
Tested-by: Bharat Bhushan <bharat.bhushan@nxp.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r-- | drivers/iommu/iommu.c | 18 | ||||
-rw-r--r-- | include/linux/iommu.h | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 1cee5c361c21..927878d0a612 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c | |||
@@ -1575,6 +1575,24 @@ void iommu_put_resv_regions(struct device *dev, struct list_head *list) | |||
1575 | ops->put_resv_regions(dev, list); | 1575 | ops->put_resv_regions(dev, list); |
1576 | } | 1576 | } |
1577 | 1577 | ||
1578 | struct iommu_resv_region *iommu_alloc_resv_region(phys_addr_t start, | ||
1579 | size_t length, | ||
1580 | int prot, int type) | ||
1581 | { | ||
1582 | struct iommu_resv_region *region; | ||
1583 | |||
1584 | region = kzalloc(sizeof(*region), GFP_KERNEL); | ||
1585 | if (!region) | ||
1586 | return NULL; | ||
1587 | |||
1588 | INIT_LIST_HEAD(®ion->list); | ||
1589 | region->start = start; | ||
1590 | region->length = length; | ||
1591 | region->prot = prot; | ||
1592 | region->type = type; | ||
1593 | return region; | ||
1594 | } | ||
1595 | |||
1578 | /* Request that a device is direct mapped by the IOMMU */ | 1596 | /* Request that a device is direct mapped by the IOMMU */ |
1579 | int iommu_request_dm_for_dev(struct device *dev) | 1597 | int iommu_request_dm_for_dev(struct device *dev) |
1580 | { | 1598 | { |
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 233a6bf093bf..f6bb55d3e606 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h | |||
@@ -244,6 +244,8 @@ extern void iommu_set_fault_handler(struct iommu_domain *domain, | |||
244 | extern void iommu_get_resv_regions(struct device *dev, struct list_head *list); | 244 | extern void iommu_get_resv_regions(struct device *dev, struct list_head *list); |
245 | extern void iommu_put_resv_regions(struct device *dev, struct list_head *list); | 245 | extern void iommu_put_resv_regions(struct device *dev, struct list_head *list); |
246 | extern int iommu_request_dm_for_dev(struct device *dev); | 246 | extern int iommu_request_dm_for_dev(struct device *dev); |
247 | extern struct iommu_resv_region * | ||
248 | iommu_alloc_resv_region(phys_addr_t start, size_t length, int prot, int type); | ||
247 | 249 | ||
248 | extern int iommu_attach_group(struct iommu_domain *domain, | 250 | extern int iommu_attach_group(struct iommu_domain *domain, |
249 | struct iommu_group *group); | 251 | struct iommu_group *group); |