aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/tegra/gem.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2017-05-04 21:47:01 -0400
committerDave Airlie <airlied@redhat.com>2017-05-04 21:47:01 -0400
commit644b4930bf7e2adeffbe842e1097f7933c6a9158 (patch)
treedcb9e56d30af9b590c511f89b0b6815dd67321e6 /drivers/gpu/drm/tegra/gem.c
parent8b03d1ed2c43a2ba5ef3381322ee4515b97381bf (diff)
parentb0d36daa0ab54714e05164f6e21d22f974a5eec1 (diff)
Merge tag 'drm/tegra/for-4.12-rc1' of git://anongit.freedesktop.org/tegra/linux into drm-next
drm/tegra: Changes for v4.12-rc1 This contains various fixes to the host1x driver as well as a plug for a leak of kernel pointers to userspace. A fairly big addition this time around is the Video Image Composer (VIC) support that can be used to accelerate some 2D and image compositing operations. Furthermore the driver now supports FB modifiers, so we no longer rely on a custom IOCTL to set those. Finally this contains a few preparatory patches for Tegra186 support which unfortunately didn't quite make it this time, but will hopefully be ready for v4.13. * tag 'drm/tegra/for-4.12-rc1' of git://anongit.freedesktop.org/tegra/linux: gpu: host1x: Fix host1x driver shutdown gpu: host1x: Support module reset gpu: host1x: Sort includes alphabetically drm/tegra: Add VIC support dt-bindings: Add bindings for the Tegra VIC drm/tegra: Add falcon helper library drm/tegra: Add Tegra DRM allocation API drm/tegra: Add tiling FB modifiers drm/tegra: Don't leak kernel pointer to userspace drm/tegra: Protect IOMMU operations by mutex drm/tegra: Enable IOVA API when IOMMU support is enabled gpu: host1x: Add IOMMU support gpu: host1x: Fix potential out-of-bounds access iommu/iova: Fix compile error with CONFIG_IOMMU_IOVA=m iommu: Add dummy implementations for !IOMMU_IOVA MAINTAINERS: Add related headers to IOMMU section iommu/iova: Consolidate code for adding new node to iovad domain rbtree
Diffstat (limited to 'drivers/gpu/drm/tegra/gem.c')
-rw-r--r--drivers/gpu/drm/tegra/gem.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index 8672f5d2f237..424569b53e57 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -128,12 +128,14 @@ static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)
128 if (!bo->mm) 128 if (!bo->mm)
129 return -ENOMEM; 129 return -ENOMEM;
130 130
131 mutex_lock(&tegra->mm_lock);
132
131 err = drm_mm_insert_node_generic(&tegra->mm, 133 err = drm_mm_insert_node_generic(&tegra->mm,
132 bo->mm, bo->gem.size, PAGE_SIZE, 0, 0); 134 bo->mm, bo->gem.size, PAGE_SIZE, 0, 0);
133 if (err < 0) { 135 if (err < 0) {
134 dev_err(tegra->drm->dev, "out of I/O virtual memory: %zd\n", 136 dev_err(tegra->drm->dev, "out of I/O virtual memory: %zd\n",
135 err); 137 err);
136 goto free; 138 goto unlock;
137 } 139 }
138 140
139 bo->paddr = bo->mm->start; 141 bo->paddr = bo->mm->start;
@@ -147,11 +149,14 @@ static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)
147 149
148 bo->size = err; 150 bo->size = err;
149 151
152 mutex_unlock(&tegra->mm_lock);
153
150 return 0; 154 return 0;
151 155
152remove: 156remove:
153 drm_mm_remove_node(bo->mm); 157 drm_mm_remove_node(bo->mm);
154free: 158unlock:
159 mutex_unlock(&tegra->mm_lock);
155 kfree(bo->mm); 160 kfree(bo->mm);
156 return err; 161 return err;
157} 162}
@@ -161,8 +166,11 @@ static int tegra_bo_iommu_unmap(struct tegra_drm *tegra, struct tegra_bo *bo)
161 if (!bo->mm) 166 if (!bo->mm)
162 return 0; 167 return 0;
163 168
169 mutex_lock(&tegra->mm_lock);
164 iommu_unmap(tegra->domain, bo->paddr, bo->size); 170 iommu_unmap(tegra->domain, bo->paddr, bo->size);
165 drm_mm_remove_node(bo->mm); 171 drm_mm_remove_node(bo->mm);
172 mutex_unlock(&tegra->mm_lock);
173
166 kfree(bo->mm); 174 kfree(bo->mm);
167 175
168 return 0; 176 return 0;