mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 15:29:16 +00:00
iommu: Introduce a callback to struct iommu_resv_region
A callback is introduced to struct iommu_resv_region to free memory allocations associated with the reserved region. This will be useful when we introduce support for IORT RMR based reserved regions. Reviewed-by: Christoph Hellwig <hch@lst.de> Tested-by: Steven Price <steven.price@arm.com> Tested-by: Laurentiu Tudor <laurentiu.tudor@nxp.com> Tested-by: Hanjun Guo <guohanjun@huawei.com> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Acked-by: Robin Murphy <robin.murphy@arm.com> Link: https://lore.kernel.org/r/20220615101044.1972-2-shameerali.kolothum.thodi@huawei.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
ac9a5d522b
commit
3b7e2482f9
@ -2590,16 +2590,22 @@ void iommu_put_resv_regions(struct device *dev, struct list_head *list)
|
|||||||
* @list: reserved region list for device
|
* @list: reserved region list for device
|
||||||
*
|
*
|
||||||
* IOMMU drivers can use this to implement their .put_resv_regions() callback
|
* IOMMU drivers can use this to implement their .put_resv_regions() callback
|
||||||
* for simple reservations. Memory allocated for each reserved region will be
|
* for simple reservations. If a per region callback is provided that will be
|
||||||
* freed. If an IOMMU driver allocates additional resources per region, it is
|
* used to free all memory allocations associated with the reserved region or
|
||||||
* going to have to implement a custom callback.
|
* else just free up the memory for the regions. If an IOMMU driver allocates
|
||||||
|
* additional resources per region, it is going to have to implement a custom
|
||||||
|
* callback.
|
||||||
*/
|
*/
|
||||||
void generic_iommu_put_resv_regions(struct device *dev, struct list_head *list)
|
void generic_iommu_put_resv_regions(struct device *dev, struct list_head *list)
|
||||||
{
|
{
|
||||||
struct iommu_resv_region *entry, *next;
|
struct iommu_resv_region *entry, *next;
|
||||||
|
|
||||||
list_for_each_entry_safe(entry, next, list, list)
|
list_for_each_entry_safe(entry, next, list, list) {
|
||||||
kfree(entry);
|
if (entry->free)
|
||||||
|
entry->free(dev, entry);
|
||||||
|
else
|
||||||
|
kfree(entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(generic_iommu_put_resv_regions);
|
EXPORT_SYMBOL(generic_iommu_put_resv_regions);
|
||||||
|
|
||||||
|
@ -135,6 +135,7 @@ enum iommu_resv_type {
|
|||||||
* @length: Length of the region in bytes
|
* @length: Length of the region in bytes
|
||||||
* @prot: IOMMU Protection flags (READ/WRITE/...)
|
* @prot: IOMMU Protection flags (READ/WRITE/...)
|
||||||
* @type: Type of the reserved region
|
* @type: Type of the reserved region
|
||||||
|
* @free: Callback to free associated memory allocations
|
||||||
*/
|
*/
|
||||||
struct iommu_resv_region {
|
struct iommu_resv_region {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
@ -142,6 +143,7 @@ struct iommu_resv_region {
|
|||||||
size_t length;
|
size_t length;
|
||||||
int prot;
|
int prot;
|
||||||
enum iommu_resv_type type;
|
enum iommu_resv_type type;
|
||||||
|
void (*free)(struct device *dev, struct iommu_resv_region *region);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user