Skip to content

Commit a4ffa12

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 b1bee19 commit a4ffa12

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
@@ -191,9 +191,7 @@ iommu_resv_region_get_type(struct device *dev,
191191
if (start == phys->start && end == phys->end)
192192
return IOMMU_RESV_DIRECT;
193193

194-
dev_warn(dev, "treating non-direct mapping [%pr] -> [%pap-%pap] as reservation\n", &phys,
195-
&start, &end);
196-
return IOMMU_RESV_RESERVED;
194+
return IOMMU_RESV_TRANSLATED;
197195
}
198196

199197
/**
@@ -257,8 +255,13 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list)
257255
maps = of_translate_dma_region(np, maps, &iova, &length);
258256
type = iommu_resv_region_get_type(dev, &phys, iova, length);
259257

260-
region = iommu_alloc_resv_region(iova, length, prot, type,
258+
if (type == IOMMU_RESV_TRANSLATED)
259+
region = iommu_alloc_resv_region_tr(phys.start, iova, length, prot, type,
260+
GFP_KERNEL);
261+
else
262+
region = iommu_alloc_resv_region(iova, length, prot, type,
261263
GFP_KERNEL);
264+
262265
if (region)
263266
list_add_tail(&region->list, list);
264267
}

0 commit comments

Comments
 (0)