aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2016-09-01 08:48:33 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-09-19 05:22:08 -0400
commitd9a1f0b4eb6080dc42bb6373ab9abb0314cea41e (patch)
treee30f04ac27771cc64af6c1e2de9386742b90d0ae /drivers/gpu/drm
parent75ae95a75d640129fc4aff412c6ecc057142a149 (diff)
drm: use drm_file to tag vm-bos
Rather than using "struct file*", use "struct drm_file*" as tag VM tag for BOs. This will pave the way for "struct drm_file*" without any "struct file*" back-pointer. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20160901124837.680-3-dh.herrmann@gmail.com
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c3
-rw-r--r--drivers/gpu/drm/ast/ast_ttm.c3
-rw-r--r--drivers/gpu/drm/bochs/bochs_mm.c3
-rw-r--r--drivers/gpu/drm/cirrus/cirrus_ttm.c3
-rw-r--r--drivers/gpu/drm/drm_gem.c8
-rw-r--r--drivers/gpu/drm/drm_vma_manager.c40
-rw-r--r--drivers/gpu/drm/mgag200/mgag200_ttm.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c3
-rw-r--r--drivers/gpu/drm/qxl/qxl_ttm.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_ttm.c3
10 files changed, 40 insertions, 32 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 5447973483ec..e36bfc47dceb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -226,7 +226,8 @@ static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp)
226 226
227 if (amdgpu_ttm_tt_get_usermm(bo->ttm)) 227 if (amdgpu_ttm_tt_get_usermm(bo->ttm))
228 return -EPERM; 228 return -EPERM;
229 return drm_vma_node_verify_access(&rbo->gem_base.vma_node, filp); 229 return drm_vma_node_verify_access(&rbo->gem_base.vma_node,
230 filp->private_data);
230} 231}
231 232
232static void amdgpu_move_null(struct ttm_buffer_object *bo, 233static void amdgpu_move_null(struct ttm_buffer_object *bo,
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index b29a41218fc9..608df4c90520 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -150,7 +150,8 @@ static int ast_bo_verify_access(struct ttm_buffer_object *bo, struct file *filp)
150{ 150{
151 struct ast_bo *astbo = ast_bo(bo); 151 struct ast_bo *astbo = ast_bo(bo);
152 152
153 return drm_vma_node_verify_access(&astbo->gem.vma_node, filp); 153 return drm_vma_node_verify_access(&astbo->gem.vma_node,
154 filp->private_data);
154} 155}
155 156
156static int ast_ttm_io_mem_reserve(struct ttm_bo_device *bdev, 157static int ast_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index 5c5638a777a1..269cfca9ca06 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -128,7 +128,8 @@ static int bochs_bo_verify_access(struct ttm_buffer_object *bo,
128{ 128{
129 struct bochs_bo *bochsbo = bochs_bo(bo); 129 struct bochs_bo *bochsbo = bochs_bo(bo);
130 130
131 return drm_vma_node_verify_access(&bochsbo->gem.vma_node, filp); 131 return drm_vma_node_verify_access(&bochsbo->gem.vma_node,
132 filp->private_data);
132} 133}
133 134
134static int bochs_ttm_io_mem_reserve(struct ttm_bo_device *bdev, 135static int bochs_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index 1cc9ee607128..bb2438dd8733 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -150,7 +150,8 @@ static int cirrus_bo_verify_access(struct ttm_buffer_object *bo, struct file *fi
150{ 150{
151 struct cirrus_bo *cirrusbo = cirrus_bo(bo); 151 struct cirrus_bo *cirrusbo = cirrus_bo(bo);
152 152
153 return drm_vma_node_verify_access(&cirrusbo->gem.vma_node, filp); 153 return drm_vma_node_verify_access(&cirrusbo->gem.vma_node,
154 filp->private_data);
154} 155}
155 156
156static int cirrus_ttm_io_mem_reserve(struct ttm_bo_device *bdev, 157static int cirrus_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 9134ae134667..465bacd0a630 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -257,7 +257,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
257 257
258 if (drm_core_check_feature(dev, DRIVER_PRIME)) 258 if (drm_core_check_feature(dev, DRIVER_PRIME))
259 drm_gem_remove_prime_handles(obj, file_priv); 259 drm_gem_remove_prime_handles(obj, file_priv);
260 drm_vma_node_revoke(&obj->vma_node, file_priv->filp); 260 drm_vma_node_revoke(&obj->vma_node, file_priv);
261 261
262 if (dev->driver->gem_close_object) 262 if (dev->driver->gem_close_object)
263 dev->driver->gem_close_object(obj, file_priv); 263 dev->driver->gem_close_object(obj, file_priv);
@@ -372,7 +372,7 @@ drm_gem_handle_create_tail(struct drm_file *file_priv,
372 372
373 handle = ret; 373 handle = ret;
374 374
375 ret = drm_vma_node_allow(&obj->vma_node, file_priv->filp); 375 ret = drm_vma_node_allow(&obj->vma_node, file_priv);
376 if (ret) 376 if (ret)
377 goto err_remove; 377 goto err_remove;
378 378
@@ -386,7 +386,7 @@ drm_gem_handle_create_tail(struct drm_file *file_priv,
386 return 0; 386 return 0;
387 387
388err_revoke: 388err_revoke:
389 drm_vma_node_revoke(&obj->vma_node, file_priv->filp); 389 drm_vma_node_revoke(&obj->vma_node, file_priv);
390err_remove: 390err_remove:
391 spin_lock(&file_priv->table_lock); 391 spin_lock(&file_priv->table_lock);
392 idr_remove(&file_priv->object_idr, handle); 392 idr_remove(&file_priv->object_idr, handle);
@@ -991,7 +991,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
991 if (!obj) 991 if (!obj)
992 return -EINVAL; 992 return -EINVAL;
993 993
994 if (!drm_vma_node_is_allowed(node, filp)) { 994 if (!drm_vma_node_is_allowed(node, priv)) {
995 drm_gem_object_unreference_unlocked(obj); 995 drm_gem_object_unreference_unlocked(obj);
996 return -EACCES; 996 return -EACCES;
997 } 997 }
diff --git a/drivers/gpu/drm/drm_vma_manager.c b/drivers/gpu/drm/drm_vma_manager.c
index 0aef432679f9..20cc33d1bfc1 100644
--- a/drivers/gpu/drm/drm_vma_manager.c
+++ b/drivers/gpu/drm/drm_vma_manager.c
@@ -25,7 +25,6 @@
25#include <drm/drmP.h> 25#include <drm/drmP.h>
26#include <drm/drm_mm.h> 26#include <drm/drm_mm.h>
27#include <drm/drm_vma_manager.h> 27#include <drm/drm_vma_manager.h>
28#include <linux/fs.h>
29#include <linux/mm.h> 28#include <linux/mm.h>
30#include <linux/module.h> 29#include <linux/module.h>
31#include <linux/rbtree.h> 30#include <linux/rbtree.h>
@@ -252,9 +251,9 @@ EXPORT_SYMBOL(drm_vma_offset_remove);
252/** 251/**
253 * drm_vma_node_allow - Add open-file to list of allowed users 252 * drm_vma_node_allow - Add open-file to list of allowed users
254 * @node: Node to modify 253 * @node: Node to modify
255 * @filp: Open file to add 254 * @tag: Tag of file to remove
256 * 255 *
257 * Add @filp to the list of allowed open-files for this node. If @filp is 256 * Add @tag to the list of allowed open-files for this node. If @tag is
258 * already on this list, the ref-count is incremented. 257 * already on this list, the ref-count is incremented.
259 * 258 *
260 * The list of allowed-users is preserved across drm_vma_offset_add() and 259 * The list of allowed-users is preserved across drm_vma_offset_add() and
@@ -269,7 +268,7 @@ EXPORT_SYMBOL(drm_vma_offset_remove);
269 * RETURNS: 268 * RETURNS:
270 * 0 on success, negative error code on internal failure (out-of-mem) 269 * 0 on success, negative error code on internal failure (out-of-mem)
271 */ 270 */
272int drm_vma_node_allow(struct drm_vma_offset_node *node, struct file *filp) 271int drm_vma_node_allow(struct drm_vma_offset_node *node, struct drm_file *tag)
273{ 272{
274 struct rb_node **iter; 273 struct rb_node **iter;
275 struct rb_node *parent = NULL; 274 struct rb_node *parent = NULL;
@@ -290,10 +289,10 @@ int drm_vma_node_allow(struct drm_vma_offset_node *node, struct file *filp)
290 parent = *iter; 289 parent = *iter;
291 entry = rb_entry(*iter, struct drm_vma_offset_file, vm_rb); 290 entry = rb_entry(*iter, struct drm_vma_offset_file, vm_rb);
292 291
293 if (filp == entry->vm_filp) { 292 if (tag == entry->vm_tag) {
294 entry->vm_count++; 293 entry->vm_count++;
295 goto unlock; 294 goto unlock;
296 } else if (filp > entry->vm_filp) { 295 } else if (tag > entry->vm_tag) {
297 iter = &(*iter)->rb_right; 296 iter = &(*iter)->rb_right;
298 } else { 297 } else {
299 iter = &(*iter)->rb_left; 298 iter = &(*iter)->rb_left;
@@ -305,7 +304,7 @@ int drm_vma_node_allow(struct drm_vma_offset_node *node, struct file *filp)
305 goto unlock; 304 goto unlock;
306 } 305 }
307 306
308 new->vm_filp = filp; 307 new->vm_tag = tag;
309 new->vm_count = 1; 308 new->vm_count = 1;
310 rb_link_node(&new->vm_rb, parent, iter); 309 rb_link_node(&new->vm_rb, parent, iter);
311 rb_insert_color(&new->vm_rb, &node->vm_files); 310 rb_insert_color(&new->vm_rb, &node->vm_files);
@@ -321,17 +320,18 @@ EXPORT_SYMBOL(drm_vma_node_allow);
321/** 320/**
322 * drm_vma_node_revoke - Remove open-file from list of allowed users 321 * drm_vma_node_revoke - Remove open-file from list of allowed users
323 * @node: Node to modify 322 * @node: Node to modify
324 * @filp: Open file to remove 323 * @tag: Tag of file to remove
325 * 324 *
326 * Decrement the ref-count of @filp in the list of allowed open-files on @node. 325 * Decrement the ref-count of @tag in the list of allowed open-files on @node.
327 * If the ref-count drops to zero, remove @filp from the list. You must call 326 * If the ref-count drops to zero, remove @tag from the list. You must call
328 * this once for every drm_vma_node_allow() on @filp. 327 * this once for every drm_vma_node_allow() on @tag.
329 * 328 *
330 * This is locked against concurrent access internally. 329 * This is locked against concurrent access internally.
331 * 330 *
332 * If @filp is not on the list, nothing is done. 331 * If @tag is not on the list, nothing is done.
333 */ 332 */
334void drm_vma_node_revoke(struct drm_vma_offset_node *node, struct file *filp) 333void drm_vma_node_revoke(struct drm_vma_offset_node *node,
334 struct drm_file *tag)
335{ 335{
336 struct drm_vma_offset_file *entry; 336 struct drm_vma_offset_file *entry;
337 struct rb_node *iter; 337 struct rb_node *iter;
@@ -341,13 +341,13 @@ void drm_vma_node_revoke(struct drm_vma_offset_node *node, struct file *filp)
341 iter = node->vm_files.rb_node; 341 iter = node->vm_files.rb_node;
342 while (likely(iter)) { 342 while (likely(iter)) {
343 entry = rb_entry(iter, struct drm_vma_offset_file, vm_rb); 343 entry = rb_entry(iter, struct drm_vma_offset_file, vm_rb);
344 if (filp == entry->vm_filp) { 344 if (tag == entry->vm_tag) {
345 if (!--entry->vm_count) { 345 if (!--entry->vm_count) {
346 rb_erase(&entry->vm_rb, &node->vm_files); 346 rb_erase(&entry->vm_rb, &node->vm_files);
347 kfree(entry); 347 kfree(entry);
348 } 348 }
349 break; 349 break;
350 } else if (filp > entry->vm_filp) { 350 } else if (tag > entry->vm_tag) {
351 iter = iter->rb_right; 351 iter = iter->rb_right;
352 } else { 352 } else {
353 iter = iter->rb_left; 353 iter = iter->rb_left;
@@ -361,9 +361,9 @@ EXPORT_SYMBOL(drm_vma_node_revoke);
361/** 361/**
362 * drm_vma_node_is_allowed - Check whether an open-file is granted access 362 * drm_vma_node_is_allowed - Check whether an open-file is granted access
363 * @node: Node to check 363 * @node: Node to check
364 * @filp: Open-file to check for 364 * @tag: Tag of file to remove
365 * 365 *
366 * Search the list in @node whether @filp is currently on the list of allowed 366 * Search the list in @node whether @tag is currently on the list of allowed
367 * open-files (see drm_vma_node_allow()). 367 * open-files (see drm_vma_node_allow()).
368 * 368 *
369 * This is locked against concurrent access internally. 369 * This is locked against concurrent access internally.
@@ -372,7 +372,7 @@ EXPORT_SYMBOL(drm_vma_node_revoke);
372 * true iff @filp is on the list 372 * true iff @filp is on the list
373 */ 373 */
374bool drm_vma_node_is_allowed(struct drm_vma_offset_node *node, 374bool drm_vma_node_is_allowed(struct drm_vma_offset_node *node,
375 struct file *filp) 375 struct drm_file *tag)
376{ 376{
377 struct drm_vma_offset_file *entry; 377 struct drm_vma_offset_file *entry;
378 struct rb_node *iter; 378 struct rb_node *iter;
@@ -382,9 +382,9 @@ bool drm_vma_node_is_allowed(struct drm_vma_offset_node *node,
382 iter = node->vm_files.rb_node; 382 iter = node->vm_files.rb_node;
383 while (likely(iter)) { 383 while (likely(iter)) {
384 entry = rb_entry(iter, struct drm_vma_offset_file, vm_rb); 384 entry = rb_entry(iter, struct drm_vma_offset_file, vm_rb);
385 if (filp == entry->vm_filp) 385 if (tag == entry->vm_tag)
386 break; 386 break;
387 else if (filp > entry->vm_filp) 387 else if (tag > entry->vm_tag)
388 iter = iter->rb_right; 388 iter = iter->rb_right;
389 else 389 else
390 iter = iter->rb_left; 390 iter = iter->rb_left;
diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index 68268e55d595..919b35f2ad24 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -150,7 +150,8 @@ static int mgag200_bo_verify_access(struct ttm_buffer_object *bo, struct file *f
150{ 150{
151 struct mgag200_bo *mgabo = mgag200_bo(bo); 151 struct mgag200_bo *mgabo = mgag200_bo(bo);
152 152
153 return drm_vma_node_verify_access(&mgabo->gem.vma_node, filp); 153 return drm_vma_node_verify_access(&mgabo->gem.vma_node,
154 filp->private_data);
154} 155}
155 156
156static int mgag200_ttm_io_mem_reserve(struct ttm_bo_device *bdev, 157static int mgag200_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 8ab9ce5089fe..66f31c3eb8ba 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1315,7 +1315,8 @@ nouveau_bo_verify_access(struct ttm_buffer_object *bo, struct file *filp)
1315{ 1315{
1316 struct nouveau_bo *nvbo = nouveau_bo(bo); 1316 struct nouveau_bo *nvbo = nouveau_bo(bo);
1317 1317
1318 return drm_vma_node_verify_access(&nvbo->gem.vma_node, filp); 1318 return drm_vma_node_verify_access(&nvbo->gem.vma_node,
1319 filp->private_data);
1319} 1320}
1320 1321
1321static int 1322static int
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 6a22de045cb5..b2fe2f8e6ae9 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -210,7 +210,8 @@ static int qxl_verify_access(struct ttm_buffer_object *bo, struct file *filp)
210{ 210{
211 struct qxl_bo *qbo = to_qxl_bo(bo); 211 struct qxl_bo *qbo = to_qxl_bo(bo);
212 212
213 return drm_vma_node_verify_access(&qbo->gem_base.vma_node, filp); 213 return drm_vma_node_verify_access(&qbo->gem_base.vma_node,
214 filp->private_data);
214} 215}
215 216
216static int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev, 217static int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 93414aca60d6..27ee0ab0e1a7 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -237,7 +237,8 @@ static int radeon_verify_access(struct ttm_buffer_object *bo, struct file *filp)
237 237
238 if (radeon_ttm_tt_has_userptr(bo->ttm)) 238 if (radeon_ttm_tt_has_userptr(bo->ttm))
239 return -EPERM; 239 return -EPERM;
240 return drm_vma_node_verify_access(&rbo->gem_base.vma_node, filp); 240 return drm_vma_node_verify_access(&rbo->gem_base.vma_node,
241 filp->private_data);
241} 242}
242 243
243static void radeon_move_null(struct ttm_buffer_object *bo, 244static void radeon_move_null(struct ttm_buffer_object *bo,