Skip to content

Commit e5b5234

Browse files
eaugerwildea01
authored andcommitted
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: Eric Auger <eric.auger@redhat.com> Acked-by: Robin Murphy <robin.murphy@arm.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>
1 parent fdbe574 commit e5b5234

File tree

3 files changed

+36
-35
lines changed

3 files changed

+36
-35
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,8 +3161,8 @@ static bool amd_iommu_capable(enum iommu_cap cap)
31613161
return false;
31623162
}
31633163

3164-
static void amd_iommu_get_dm_regions(struct device *dev,
3165-
struct list_head *head)
3164+
static void amd_iommu_get_resv_regions(struct device *dev,
3165+
struct list_head *head)
31663166
{
31673167
struct unity_map_entry *entry;
31683168
int devid;
@@ -3172,7 +3172,7 @@ static void amd_iommu_get_dm_regions(struct device *dev,
31723172
return;
31733173

31743174
list_for_each_entry(entry, &amd_iommu_unity_map, list) {
3175-
struct iommu_dm_region *region;
3175+
struct iommu_resv_region *region;
31763176

31773177
if (devid < entry->devid_start || devid > entry->devid_end)
31783178
continue;
@@ -3195,18 +3195,18 @@ static void amd_iommu_get_dm_regions(struct device *dev,
31953195
}
31963196
}
31973197

3198-
static void amd_iommu_put_dm_regions(struct device *dev,
3198+
static void amd_iommu_put_resv_regions(struct device *dev,
31993199
struct list_head *head)
32003200
{
3201-
struct iommu_dm_region *entry, *next;
3201+
struct iommu_resv_region *entry, *next;
32023202

32033203
list_for_each_entry_safe(entry, next, head, list)
32043204
kfree(entry);
32053205
}
32063206

3207-
static void amd_iommu_apply_dm_region(struct device *dev,
3207+
static void amd_iommu_apply_resv_region(struct device *dev,
32083208
struct iommu_domain *domain,
3209-
struct iommu_dm_region *region)
3209+
struct iommu_resv_region *region)
32103210
{
32113211
struct dma_ops_domain *dma_dom = to_dma_ops_domain(to_pdomain(domain));
32123212
unsigned long start, end;
@@ -3230,9 +3230,9 @@ static const struct iommu_ops amd_iommu_ops = {
32303230
.add_device = amd_iommu_add_device,
32313231
.remove_device = amd_iommu_remove_device,
32323232
.device_group = amd_iommu_device_group,
3233-
.get_dm_regions = amd_iommu_get_dm_regions,
3234-
.put_dm_regions = amd_iommu_put_dm_regions,
3235-
.apply_dm_region = amd_iommu_apply_dm_region,
3233+
.get_resv_regions = amd_iommu_get_resv_regions,
3234+
.put_resv_regions = amd_iommu_put_resv_regions,
3235+
.apply_resv_region = amd_iommu_apply_resv_region,
32363236
.pgsize_bitmap = AMD_IOMMU_PGSIZES,
32373237
};
32383238

drivers/iommu/iommu.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group,
318318
struct device *dev)
319319
{
320320
struct iommu_domain *domain = group->default_domain;
321-
struct iommu_dm_region *entry;
321+
struct iommu_resv_region *entry;
322322
struct list_head mappings;
323323
unsigned long pg_size;
324324
int ret = 0;
@@ -331,14 +331,14 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group,
331331
pg_size = 1UL << __ffs(domain->pgsize_bitmap);
332332
INIT_LIST_HEAD(&mappings);
333333

334-
iommu_get_dm_regions(dev, &mappings);
334+
iommu_get_resv_regions(dev, &mappings);
335335

336336
/* We need to consider overlapping regions for different devices */
337337
list_for_each_entry(entry, &mappings, list) {
338338
dma_addr_t start, end, addr;
339339

340-
if (domain->ops->apply_dm_region)
341-
domain->ops->apply_dm_region(dev, domain, entry);
340+
if (domain->ops->apply_resv_region)
341+
domain->ops->apply_resv_region(dev, domain, entry);
342342

343343
start = ALIGN(entry->start, pg_size);
344344
end = ALIGN(entry->start + entry->length, pg_size);
@@ -358,7 +358,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group,
358358
}
359359

360360
out:
361-
iommu_put_dm_regions(dev, &mappings);
361+
iommu_put_resv_regions(dev, &mappings);
362362

363363
return ret;
364364
}
@@ -1559,20 +1559,20 @@ int iommu_domain_set_attr(struct iommu_domain *domain,
15591559
}
15601560
EXPORT_SYMBOL_GPL(iommu_domain_set_attr);
15611561

1562-
void iommu_get_dm_regions(struct device *dev, struct list_head *list)
1562+
void iommu_get_resv_regions(struct device *dev, struct list_head *list)
15631563
{
15641564
const struct iommu_ops *ops = dev->bus->iommu_ops;
15651565

1566-
if (ops && ops->get_dm_regions)
1567-
ops->get_dm_regions(dev, list);
1566+
if (ops && ops->get_resv_regions)
1567+
ops->get_resv_regions(dev, list);
15681568
}
15691569

1570-
void iommu_put_dm_regions(struct device *dev, struct list_head *list)
1570+
void iommu_put_resv_regions(struct device *dev, struct list_head *list)
15711571
{
15721572
const struct iommu_ops *ops = dev->bus->iommu_ops;
15731573

1574-
if (ops && ops->put_dm_regions)
1575-
ops->put_dm_regions(dev, list);
1574+
if (ops && ops->put_resv_regions)
1575+
ops->put_resv_regions(dev, list);
15761576
}
15771577

15781578
/* Request that a device is direct mapped by the IOMMU */

include/linux/iommu.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ enum iommu_attr {
118118
};
119119

120120
/**
121-
* struct iommu_dm_region - descriptor for a direct mapped memory region
121+
* struct iommu_resv_region - descriptor for a reserved memory region
122122
* @list: Linked list pointers
123123
* @start: System physical start address of the region
124124
* @length: Length of the region in bytes
125125
* @prot: IOMMU Protection flags (READ/WRITE/...)
126126
*/
127-
struct iommu_dm_region {
127+
struct iommu_resv_region {
128128
struct list_head list;
129129
phys_addr_t start;
130130
size_t length;
@@ -150,9 +150,9 @@ struct iommu_dm_region {
150150
* @device_group: find iommu group for a particular device
151151
* @domain_get_attr: Query domain attributes
152152
* @domain_set_attr: Change domain attributes
153-
* @get_dm_regions: Request list of direct mapping requirements for a device
154-
* @put_dm_regions: Free list of direct mapping requirements for a device
155-
* @apply_dm_region: Temporary helper call-back for iova reserved ranges
153+
* @get_resv_regions: Request list of reserved regions for a device
154+
* @put_resv_regions: Free list of reserved regions for a device
155+
* @apply_resv_region: Temporary helper call-back for iova reserved ranges
156156
* @domain_window_enable: Configure and enable a particular window for a domain
157157
* @domain_window_disable: Disable a particular window for a domain
158158
* @domain_set_windows: Set the number of windows for a domain
@@ -184,11 +184,12 @@ struct iommu_ops {
184184
int (*domain_set_attr)(struct iommu_domain *domain,
185185
enum iommu_attr attr, void *data);
186186

187-
/* Request/Free a list of direct mapping requirements for a device */
188-
void (*get_dm_regions)(struct device *dev, struct list_head *list);
189-
void (*put_dm_regions)(struct device *dev, struct list_head *list);
190-
void (*apply_dm_region)(struct device *dev, struct iommu_domain *domain,
191-
struct iommu_dm_region *region);
187+
/* Request/Free a list of reserved regions for a device */
188+
void (*get_resv_regions)(struct device *dev, struct list_head *list);
189+
void (*put_resv_regions)(struct device *dev, struct list_head *list);
190+
void (*apply_resv_region)(struct device *dev,
191+
struct iommu_domain *domain,
192+
struct iommu_resv_region *region);
192193

193194
/* Window handling functions */
194195
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
233234
extern void iommu_set_fault_handler(struct iommu_domain *domain,
234235
iommu_fault_handler_t handler, void *token);
235236

236-
extern void iommu_get_dm_regions(struct device *dev, struct list_head *list);
237-
extern void iommu_put_dm_regions(struct device *dev, struct list_head *list);
237+
extern void iommu_get_resv_regions(struct device *dev, struct list_head *list);
238+
extern void iommu_put_resv_regions(struct device *dev, struct list_head *list);
238239
extern int iommu_request_dm_for_dev(struct device *dev);
239240

240241
extern int iommu_attach_group(struct iommu_domain *domain,
@@ -443,12 +444,12 @@ static inline void iommu_set_fault_handler(struct iommu_domain *domain,
443444
{
444445
}
445446

446-
static inline void iommu_get_dm_regions(struct device *dev,
447+
static inline void iommu_get_resv_regions(struct device *dev,
447448
struct list_head *list)
448449
{
449450
}
450451

451-
static inline void iommu_put_dm_regions(struct device *dev,
452+
static inline void iommu_put_resv_regions(struct device *dev,
452453
struct list_head *list)
453454
{
454455
}

0 commit comments

Comments
 (0)