Skip to content

Commit faa3abb

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 5892b71 commit faa3abb

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

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

590595
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
@@ -178,9 +178,7 @@ iommu_resv_region_get_type(struct device *dev,
178178
if (start == phys->start && end == phys->end)
179179
return IOMMU_RESV_DIRECT;
180180

181-
dev_warn(dev, "treating non-direct mapping [%pr] -> [%pap-%pap] as reservation\n", phys,
182-
&start, &end);
183-
return IOMMU_RESV_RESERVED;
181+
return IOMMU_RESV_TRANSLATED;
184182
}
185183

186184
/**
@@ -251,8 +249,13 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list)
251249
}
252250
type = iommu_resv_region_get_type(dev, &phys, iova, length);
253251

254-
region = iommu_alloc_resv_region(iova, length, prot, type,
252+
if (type == IOMMU_RESV_TRANSLATED)
253+
region = iommu_alloc_resv_region_tr(phys.start, iova, length, prot, type,
254+
GFP_KERNEL);
255+
else
256+
region = iommu_alloc_resv_region(iova, length, prot, type,
255257
GFP_KERNEL);
258+
256259
if (region)
257260
list_add_tail(&region->list, list);
258261
}

0 commit comments

Comments
 (0)