Skip to content

Commit

Permalink
iommu/amd: Implement apply_dm_region call-back
Browse files Browse the repository at this point in the history
It is used to reserve the dm-regions in the iova-tree.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Joerg Roedel committed Jul 13, 2016
1 parent 81cd07b commit 8d54d6c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions drivers/iommu/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3385,6 +3385,20 @@ static void amd_iommu_put_dm_regions(struct device *dev,
kfree(entry);
}

static void amd_iommu_apply_dm_region(struct device *dev,
struct iommu_domain *domain,
struct iommu_dm_region *region)
{
struct protection_domain *pdomain = to_pdomain(domain);
struct dma_ops_domain *dma_dom = pdomain->priv;
unsigned long start, end;

start = IOVA_PFN(region->start);
end = IOVA_PFN(region->start + region->length);

WARN_ON_ONCE(reserve_iova(&dma_dom->iovad, start, end) == NULL);
}

static const struct iommu_ops amd_iommu_ops = {
.capable = amd_iommu_capable,
.domain_alloc = amd_iommu_domain_alloc,
Expand All @@ -3400,6 +3414,7 @@ static const struct iommu_ops amd_iommu_ops = {
.device_group = amd_iommu_device_group,
.get_dm_regions = amd_iommu_get_dm_regions,
.put_dm_regions = amd_iommu_put_dm_regions,
.apply_dm_region = amd_iommu_apply_dm_region,
.pgsize_bitmap = AMD_IOMMU_PGSIZES,
};

Expand Down

0 comments on commit 8d54d6c

Please sign in to comment.