Skip to content

Commit 7b7b294

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 5c0d0c0 commit 7b7b294

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
@@ -572,8 +572,13 @@ static int iova_reserve_iommu_regions(struct device *dev,
572572
if (region->type == IOMMU_RESV_SW_MSI)
573573
continue;
574574

575-
lo = iova_pfn(iovad, region->start);
576-
hi = iova_pfn(iovad, region->start + region->length - 1);
575+
if (region->type == IOMMU_RESV_TRANSLATED) {
576+
lo = iova_pfn(iovad, region->dva);
577+
hi = iova_pfn(iovad, region->dva + region->length - 1);
578+
} else {
579+
lo = iova_pfn(iovad, region->start);
580+
hi = iova_pfn(iovad, region->start + region->length - 1);
581+
}
577582
reserve_iova(iovad, lo, hi);
578583

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

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

197195
/**
@@ -262,8 +260,13 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list)
262260
}
263261
type = iommu_resv_region_get_type(dev, &phys, iova, length);
264262

265-
region = iommu_alloc_resv_region(iova, length, prot, type,
263+
if (type == IOMMU_RESV_TRANSLATED)
264+
region = iommu_alloc_resv_region_tr(phys.start, iova, length, prot, type,
265+
GFP_KERNEL);
266+
else
267+
region = iommu_alloc_resv_region(iova, length, prot, type,
266268
GFP_KERNEL);
269+
267270
if (region)
268271
list_add_tail(&region->list, list);
269272
}

0 commit comments

Comments
 (0)