Skip to content

Commit fd4d4f4

Browse files
committed
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 76c199e commit fd4d4f4

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
@@ -582,8 +582,13 @@ static int iova_reserve_iommu_regions(struct device *dev,
582582
if (region->type == IOMMU_RESV_SW_MSI)
583583
continue;
584584

585-
lo = iova_pfn(iovad, region->start);
586-
hi = iova_pfn(iovad, region->start + region->length - 1);
585+
if (region->type == IOMMU_RESV_TRANSLATED) {
586+
lo = iova_pfn(iovad, region->dva);
587+
hi = iova_pfn(iovad, region->dva + region->length - 1);
588+
} else {
589+
lo = iova_pfn(iovad, region->start);
590+
hi = iova_pfn(iovad, region->start + region->length - 1);
591+
}
587592
reserve_iova(iovad, lo, hi);
588593

589594
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
@@ -185,9 +185,7 @@ iommu_resv_region_get_type(struct device *dev,
185185
if (start == phys->start && end == phys->end)
186186
return IOMMU_RESV_DIRECT;
187187

188-
dev_warn(dev, "treating non-direct mapping [%pr] -> [%pap-%pap] as reservation\n", phys,
189-
&start, &end);
190-
return IOMMU_RESV_RESERVED;
188+
return IOMMU_RESV_TRANSLATED;
191189
}
192190

193191
/**
@@ -258,8 +256,13 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list)
258256
}
259257
type = iommu_resv_region_get_type(dev, &phys, iova, length);
260258

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

0 commit comments

Comments
 (0)