Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c8cb58e authored by Thierry Reding's avatar Thierry Reding
Browse files

drm/tegra: gem: Use iommu_map_sg()



The iommu_map_sg() function is now available in the IOMMU API, so drop
the open-coded variant.

Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent f4c5cf88
Loading
Loading
Loading
Loading
+2 −32
Original line number Diff line number Diff line
@@ -92,36 +92,6 @@ static const struct host1x_bo_ops tegra_bo_ops = {
	.kunmap = tegra_bo_kunmap,
};

/*
 * A generic iommu_map_sg() function is being reviewed and will hopefully be
 * merged soon. At that point this function can be dropped in favour of the
 * one provided by the IOMMU API.
 */
static ssize_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
			      struct scatterlist *sg, unsigned int nents,
			      int prot)
{
	struct scatterlist *s;
	size_t offset = 0;
	unsigned int i;
	int err;

	for_each_sg(sg, s, nents, i) {
		phys_addr_t phys = page_to_phys(sg_page(s));
		size_t length = s->offset + s->length;

		err = iommu_map(domain, iova + offset, phys, length, prot);
		if (err < 0) {
			iommu_unmap(domain, iova, offset);
			return err;
		}

		offset += length;
	}

	return offset;
}

static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)
{
	int prot = IOMMU_READ | IOMMU_WRITE;
@@ -144,7 +114,7 @@ static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)

	bo->paddr = bo->mm->start;

	err = __iommu_map_sg(tegra->domain, bo->paddr, bo->sgt->sgl,
	err = iommu_map_sg(tegra->domain, bo->paddr, bo->sgt->sgl,
			   bo->sgt->nents, prot);
	if (err < 0) {
		dev_err(tegra->drm->dev, "failed to map buffer: %zd\n", err);