Commit e5b5234a authored by Eric Auger's avatar Eric Auger Committed by Will Deacon

iommu: Rename iommu_dm_regions into iommu_resv_regions

We want to extend the callbacks used for dm regions and
use them for reserved regions. Reserved regions can be
- directly mapped regions
- regions that cannot be iommu mapped (PCI host bridge windows, ...)
- MSI regions (because they belong to another address space or because
  they are not translated by the IOMMU and need special handling)

So let's rename the struct and also the callbacks.
Signed-off-by: default avatarEric Auger <eric.auger@redhat.com>
Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
Reviewed-by: default avatarTomasz Nowicki <tomasz.nowicki@caviumnetworks.com>
Tested-by: default avatarTomasz Nowicki <tomasz.nowicki@caviumnetworks.com>
Tested-by: default avatarBharat Bhushan <bharat.bhushan@nxp.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent fdbe574e
...@@ -3161,8 +3161,8 @@ static bool amd_iommu_capable(enum iommu_cap cap) ...@@ -3161,8 +3161,8 @@ static bool amd_iommu_capable(enum iommu_cap cap)
return false; return false;
} }
static void amd_iommu_get_dm_regions(struct device *dev, static void amd_iommu_get_resv_regions(struct device *dev,
struct list_head *head) struct list_head *head)
{ {
struct unity_map_entry *entry; struct unity_map_entry *entry;
int devid; int devid;
...@@ -3172,7 +3172,7 @@ static void amd_iommu_get_dm_regions(struct device *dev, ...@@ -3172,7 +3172,7 @@ static void amd_iommu_get_dm_regions(struct device *dev,
return; return;
list_for_each_entry(entry, &amd_iommu_unity_map, list) { list_for_each_entry(entry, &amd_iommu_unity_map, list) {
struct iommu_dm_region *region; struct iommu_resv_region *region;
if (devid < entry->devid_start || devid > entry->devid_end) if (devid < entry->devid_start || devid > entry->devid_end)
continue; continue;
...@@ -3195,18 +3195,18 @@ static void amd_iommu_get_dm_regions(struct device *dev, ...@@ -3195,18 +3195,18 @@ static void amd_iommu_get_dm_regions(struct device *dev,
} }
} }
static void amd_iommu_put_dm_regions(struct device *dev, static void amd_iommu_put_resv_regions(struct device *dev,
struct list_head *head) struct list_head *head)
{ {
struct iommu_dm_region *entry, *next; struct iommu_resv_region *entry, *next;
list_for_each_entry_safe(entry, next, head, list) list_for_each_entry_safe(entry, next, head, list)
kfree(entry); kfree(entry);
} }
static void amd_iommu_apply_dm_region(struct device *dev, static void amd_iommu_apply_resv_region(struct device *dev,
struct iommu_domain *domain, struct iommu_domain *domain,
struct iommu_dm_region *region) struct iommu_resv_region *region)
{ {
struct dma_ops_domain *dma_dom = to_dma_ops_domain(to_pdomain(domain)); struct dma_ops_domain *dma_dom = to_dma_ops_domain(to_pdomain(domain));
unsigned long start, end; unsigned long start, end;
...@@ -3230,9 +3230,9 @@ static const struct iommu_ops amd_iommu_ops = { ...@@ -3230,9 +3230,9 @@ static const struct iommu_ops amd_iommu_ops = {
.add_device = amd_iommu_add_device, .add_device = amd_iommu_add_device,
.remove_device = amd_iommu_remove_device, .remove_device = amd_iommu_remove_device,
.device_group = amd_iommu_device_group, .device_group = amd_iommu_device_group,
.get_dm_regions = amd_iommu_get_dm_regions, .get_resv_regions = amd_iommu_get_resv_regions,
.put_dm_regions = amd_iommu_put_dm_regions, .put_resv_regions = amd_iommu_put_resv_regions,
.apply_dm_region = amd_iommu_apply_dm_region, .apply_resv_region = amd_iommu_apply_resv_region,
.pgsize_bitmap = AMD_IOMMU_PGSIZES, .pgsize_bitmap = AMD_IOMMU_PGSIZES,
}; };
......
...@@ -318,7 +318,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, ...@@ -318,7 +318,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group,
struct device *dev) struct device *dev)
{ {
struct iommu_domain *domain = group->default_domain; struct iommu_domain *domain = group->default_domain;
struct iommu_dm_region *entry; struct iommu_resv_region *entry;
struct list_head mappings; struct list_head mappings;
unsigned long pg_size; unsigned long pg_size;
int ret = 0; int ret = 0;
...@@ -331,14 +331,14 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, ...@@ -331,14 +331,14 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group,
pg_size = 1UL << __ffs(domain->pgsize_bitmap); pg_size = 1UL << __ffs(domain->pgsize_bitmap);
INIT_LIST_HEAD(&mappings); INIT_LIST_HEAD(&mappings);
iommu_get_dm_regions(dev, &mappings); iommu_get_resv_regions(dev, &mappings);
/* We need to consider overlapping regions for different devices */ /* We need to consider overlapping regions for different devices */
list_for_each_entry(entry, &mappings, list) { list_for_each_entry(entry, &mappings, list) {
dma_addr_t start, end, addr; dma_addr_t start, end, addr;
if (domain->ops->apply_dm_region) if (domain->ops->apply_resv_region)
domain->ops->apply_dm_region(dev, domain, entry); domain->ops->apply_resv_region(dev, domain, entry);
start = ALIGN(entry->start, pg_size); start = ALIGN(entry->start, pg_size);
end = ALIGN(entry->start + entry->length, pg_size); end = ALIGN(entry->start + entry->length, pg_size);
...@@ -358,7 +358,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, ...@@ -358,7 +358,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group,
} }
out: out:
iommu_put_dm_regions(dev, &mappings); iommu_put_resv_regions(dev, &mappings);
return ret; return ret;
} }
...@@ -1559,20 +1559,20 @@ int iommu_domain_set_attr(struct iommu_domain *domain, ...@@ -1559,20 +1559,20 @@ int iommu_domain_set_attr(struct iommu_domain *domain,
} }
EXPORT_SYMBOL_GPL(iommu_domain_set_attr); EXPORT_SYMBOL_GPL(iommu_domain_set_attr);
void iommu_get_dm_regions(struct device *dev, struct list_head *list) void iommu_get_resv_regions(struct device *dev, struct list_head *list)
{ {
const struct iommu_ops *ops = dev->bus->iommu_ops; const struct iommu_ops *ops = dev->bus->iommu_ops;
if (ops && ops->get_dm_regions) if (ops && ops->get_resv_regions)
ops->get_dm_regions(dev, list); ops->get_resv_regions(dev, list);
} }
void iommu_put_dm_regions(struct device *dev, struct list_head *list) void iommu_put_resv_regions(struct device *dev, struct list_head *list)
{ {
const struct iommu_ops *ops = dev->bus->iommu_ops; const struct iommu_ops *ops = dev->bus->iommu_ops;
if (ops && ops->put_dm_regions) if (ops && ops->put_resv_regions)
ops->put_dm_regions(dev, list); ops->put_resv_regions(dev, list);
} }
/* Request that a device is direct mapped by the IOMMU */ /* Request that a device is direct mapped by the IOMMU */
......
...@@ -118,13 +118,13 @@ enum iommu_attr { ...@@ -118,13 +118,13 @@ enum iommu_attr {
}; };
/** /**
* struct iommu_dm_region - descriptor for a direct mapped memory region * struct iommu_resv_region - descriptor for a reserved memory region
* @list: Linked list pointers * @list: Linked list pointers
* @start: System physical start address of the region * @start: System physical start address of the region
* @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/...)
*/ */
struct iommu_dm_region { struct iommu_resv_region {
struct list_head list; struct list_head list;
phys_addr_t start; phys_addr_t start;
size_t length; size_t length;
...@@ -150,9 +150,9 @@ struct iommu_dm_region { ...@@ -150,9 +150,9 @@ struct iommu_dm_region {
* @device_group: find iommu group for a particular device * @device_group: find iommu group for a particular device
* @domain_get_attr: Query domain attributes * @domain_get_attr: Query domain attributes
* @domain_set_attr: Change domain attributes * @domain_set_attr: Change domain attributes
* @get_dm_regions: Request list of direct mapping requirements for a device * @get_resv_regions: Request list of reserved regions for a device
* @put_dm_regions: Free list of direct mapping requirements for a device * @put_resv_regions: Free list of reserved regions for a device
* @apply_dm_region: Temporary helper call-back for iova reserved ranges * @apply_resv_region: Temporary helper call-back for iova reserved ranges
* @domain_window_enable: Configure and enable a particular window for a domain * @domain_window_enable: Configure and enable a particular window for a domain
* @domain_window_disable: Disable a particular window for a domain * @domain_window_disable: Disable a particular window for a domain
* @domain_set_windows: Set the number of windows for a domain * @domain_set_windows: Set the number of windows for a domain
...@@ -184,11 +184,12 @@ struct iommu_ops { ...@@ -184,11 +184,12 @@ struct iommu_ops {
int (*domain_set_attr)(struct iommu_domain *domain, int (*domain_set_attr)(struct iommu_domain *domain,
enum iommu_attr attr, void *data); enum iommu_attr attr, void *data);
/* Request/Free a list of direct mapping requirements for a device */ /* Request/Free a list of reserved regions for a device */
void (*get_dm_regions)(struct device *dev, struct list_head *list); void (*get_resv_regions)(struct device *dev, struct list_head *list);
void (*put_dm_regions)(struct device *dev, struct list_head *list); void (*put_resv_regions)(struct device *dev, struct list_head *list);
void (*apply_dm_region)(struct device *dev, struct iommu_domain *domain, void (*apply_resv_region)(struct device *dev,
struct iommu_dm_region *region); struct iommu_domain *domain,
struct iommu_resv_region *region);
/* Window handling functions */ /* Window handling functions */
int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr, int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr,
...@@ -233,8 +234,8 @@ extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t io ...@@ -233,8 +234,8 @@ extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t io
extern void iommu_set_fault_handler(struct iommu_domain *domain, extern void iommu_set_fault_handler(struct iommu_domain *domain,
iommu_fault_handler_t handler, void *token); iommu_fault_handler_t handler, void *token);
extern void iommu_get_dm_regions(struct device *dev, struct list_head *list); extern void iommu_get_resv_regions(struct device *dev, struct list_head *list);
extern void iommu_put_dm_regions(struct device *dev, struct list_head *list); extern void iommu_put_resv_regions(struct device *dev, struct list_head *list);
extern int iommu_request_dm_for_dev(struct device *dev); extern int iommu_request_dm_for_dev(struct device *dev);
extern int iommu_attach_group(struct iommu_domain *domain, extern int iommu_attach_group(struct iommu_domain *domain,
...@@ -443,12 +444,12 @@ static inline void iommu_set_fault_handler(struct iommu_domain *domain, ...@@ -443,12 +444,12 @@ static inline void iommu_set_fault_handler(struct iommu_domain *domain,
{ {
} }
static inline void iommu_get_dm_regions(struct device *dev, static inline void iommu_get_resv_regions(struct device *dev,
struct list_head *list) struct list_head *list)
{ {
} }
static inline void iommu_put_dm_regions(struct device *dev, static inline void iommu_put_resv_regions(struct device *dev,
struct list_head *list) struct list_head *list)
{ {
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment