Skip to content

Commit cdeb4a6

Browse files
jannaumarcan
authored andcommitted
iommu: Parse translated reserved regions
These regions are setup by the boot loader and require an iommu to translate arbitray physical to device VA mappings. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent c645317 commit cdeb4a6

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

drivers/iommu/dma-iommu.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,13 @@ static int iova_reserve_iommu_regions(struct device *dev,
500500
if (region->type == IOMMU_RESV_SW_MSI)
501501
continue;
502502

503-
lo = iova_pfn(iovad, region->start);
504-
hi = iova_pfn(iovad, region->start + region->length - 1);
503+
if (region->type == IOMMU_RESV_TRANSLATED) {
504+
lo = iova_pfn(iovad, region->dva);
505+
hi = iova_pfn(iovad, region->dva + region->length - 1);
506+
} else {
507+
lo = iova_pfn(iovad, region->start);
508+
hi = iova_pfn(iovad, region->start + region->length - 1);
509+
}
505510
reserve_iova(iovad, lo, hi);
506511

507512
if (region->type == IOMMU_RESV_MSI)

drivers/iommu/of_iommu.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ iommu_resv_region_get_type(struct device *dev,
168168
if (start == phys->start && end == phys->end)
169169
return IOMMU_RESV_DIRECT;
170170

171-
dev_warn(dev, "treating non-direct mapping [%pr] -> [%pap-%pap] as reservation\n", &phys,
172-
&start, &end);
173-
return IOMMU_RESV_RESERVED;
171+
return IOMMU_RESV_TRANSLATED;
174172
}
175173

176174
/**
@@ -234,8 +232,13 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list)
234232
maps = of_translate_dma_region(np, maps, &iova, &length);
235233
type = iommu_resv_region_get_type(dev, &phys, iova, length);
236234

237-
region = iommu_alloc_resv_region(iova, length, prot, type,
235+
if (type == IOMMU_RESV_TRANSLATED)
236+
region = iommu_alloc_resv_region_tr(phys.start, iova, length, prot, type,
237+
GFP_KERNEL);
238+
else
239+
region = iommu_alloc_resv_region(iova, length, prot, type,
238240
GFP_KERNEL);
241+
239242
if (region)
240243
list_add_tail(&region->list, list);
241244
}

0 commit comments

Comments
 (0)