aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2014-12-17 10:46:37 -0500
committerThierry Reding <treding@nvidia.com>2015-01-27 04:14:34 -0500
commit8c8cb58ed6429da3cd41c1b44770c7a4b1b33933 (patch)
tree0f233d6fee0881f71aac23eefedc4e33ebfc740f
parentf4c5cf88fbd50e4779042268947b2e2f90c20484 (diff)
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: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/gpu/drm/tegra/gem.c34
1 files changed, 2 insertions, 32 deletions
diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index 8777b7f75791..1ccde09d01c8 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -92,36 +92,6 @@ static const struct host1x_bo_ops tegra_bo_ops = {
92 .kunmap = tegra_bo_kunmap, 92 .kunmap = tegra_bo_kunmap,
93}; 93};
94 94
95/*
96 * A generic iommu_map_sg() function is being reviewed and will hopefully be
97 * merged soon. At that point this function can be dropped in favour of the
98 * one provided by the IOMMU API.
99 */
100static ssize_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
101 struct scatterlist *sg, unsigned int nents,
102 int prot)
103{
104 struct scatterlist *s;
105 size_t offset = 0;
106 unsigned int i;
107 int err;
108
109 for_each_sg(sg, s, nents, i) {
110 phys_addr_t phys = page_to_phys(sg_page(s));
111 size_t length = s->offset + s->length;
112
113 err = iommu_map(domain, iova + offset, phys, length, prot);
114 if (err < 0) {
115 iommu_unmap(domain, iova, offset);
116 return err;
117 }
118
119 offset += length;
120 }
121
122 return offset;
123}
124
125static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo) 95static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)
126{ 96{
127 int prot = IOMMU_READ | IOMMU_WRITE; 97 int prot = IOMMU_READ | IOMMU_WRITE;
@@ -144,8 +114,8 @@ static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)
144 114
145 bo->paddr = bo->mm->start; 115 bo->paddr = bo->mm->start;
146 116
147 err = __iommu_map_sg(tegra->domain, bo->paddr, bo->sgt->sgl, 117 err = iommu_map_sg(tegra->domain, bo->paddr, bo->sgt->sgl,
148 bo->sgt->nents, prot); 118 bo->sgt->nents, prot);
149 if (err < 0) { 119 if (err < 0) {
150 dev_err(tegra->drm->dev, "failed to map buffer: %zd\n", err); 120 dev_err(tegra->drm->dev, "failed to map buffer: %zd\n", err);
151 goto remove; 121 goto remove;