Skip to content

Commit a30b739

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 c3200b8 commit a30b739

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

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

188186
/**
@@ -253,8 +251,13 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list)
253251
}
254252
type = iommu_resv_region_get_type(dev, &phys, iova, length);
255253

256-
region = iommu_alloc_resv_region(iova, length, prot, type,
254+
if (type == IOMMU_RESV_TRANSLATED)
255+
region = iommu_alloc_resv_region_tr(phys.start, iova, length, prot, type,
256+
GFP_KERNEL);
257+
else
258+
region = iommu_alloc_resv_region(iova, length, prot, type,
257259
GFP_KERNEL);
260+
258261
if (region)
259262
list_add_tail(&region->list, list);
260263
}

0 commit comments

Comments
 (0)