Skip to content

Commit d9a1f0b

Browse files
David Herrmanndanvet
authored andcommitted
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
1 parent 75ae95a commit d9a1f0b

11 files changed

Lines changed: 51 additions & 41 deletions

File tree

‎drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp)
226226

227227
if (amdgpu_ttm_tt_get_usermm(bo->ttm))
228228
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);
230231
}
231232

232233
static void amdgpu_move_null(struct ttm_buffer_object *bo,

‎drivers/gpu/drm/ast/ast_ttm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ static int ast_bo_verify_access(struct ttm_buffer_object *bo, struct file *filp)
150150
{
151151
struct ast_bo *astbo = ast_bo(bo);
152152

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);
154155
}
155156

156157
static int ast_ttm_io_mem_reserve(struct ttm_bo_device *bdev,

‎drivers/gpu/drm/bochs/bochs_mm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ static int bochs_bo_verify_access(struct ttm_buffer_object *bo,
128128
{
129129
struct bochs_bo *bochsbo = bochs_bo(bo);
130130

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);
132133
}
133134

134135
static int bochs_ttm_io_mem_reserve(struct ttm_bo_device *bdev,

‎drivers/gpu/drm/cirrus/cirrus_ttm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ static int cirrus_bo_verify_access(struct ttm_buffer_object *bo, struct file *fi
150150
{
151151
struct cirrus_bo *cirrusbo = cirrus_bo(bo);
152152

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);
154155
}
155156

156157
static int cirrus_ttm_io_mem_reserve(struct ttm_bo_device *bdev,

‎drivers/gpu/drm/drm_gem.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
257257

258258
if (drm_core_check_feature(dev, DRIVER_PRIME))
259259
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);
261261

262262
if (dev->driver->gem_close_object)
263263
dev->driver->gem_close_object(obj, file_priv);
@@ -372,7 +372,7 @@ drm_gem_handle_create_tail(struct drm_file *file_priv,
372372

373373
handle = ret;
374374

375-
ret = drm_vma_node_allow(&obj->vma_node, file_priv->filp);
375+
ret = drm_vma_node_allow(&obj->vma_node, file_priv);
376376
if (ret)
377377
goto err_remove;
378378

@@ -386,7 +386,7 @@ drm_gem_handle_create_tail(struct drm_file *file_priv,
386386
return 0;
387387

388388
err_revoke:
389-
drm_vma_node_revoke(&obj->vma_node, file_priv->filp);
389+
drm_vma_node_revoke(&obj->vma_node, file_priv);
390390
err_remove:
391391
spin_lock(&file_priv->table_lock);
392392
idr_remove(&file_priv->object_idr, handle);
@@ -991,7 +991,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
991991
if (!obj)
992992
return -EINVAL;
993993

994-
if (!drm_vma_node_is_allowed(node, filp)) {
994+
if (!drm_vma_node_is_allowed(node, priv)) {
995995
drm_gem_object_unreference_unlocked(obj);
996996
return -EACCES;
997997
}

‎drivers/gpu/drm/drm_vma_manager.c‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <drm/drmP.h>
2626
#include <drm/drm_mm.h>
2727
#include <drm/drm_vma_manager.h>
28-
#include <linux/fs.h>
2928
#include <linux/mm.h>
3029
#include <linux/module.h>
3130
#include <linux/rbtree.h>
@@ -252,9 +251,9 @@ EXPORT_SYMBOL(drm_vma_offset_remove);
252251
/**
253252
* drm_vma_node_allow - Add open-file to list of allowed users
254253
* @node: Node to modify
255-
* @filp: Open file to add
254+
* @tag: Tag of file to remove
256255
*
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
258257
* already on this list, the ref-count is incremented.
259258
*
260259
* The list of allowed-users is preserved across drm_vma_offset_add() and
@@ -269,7 +268,7 @@ EXPORT_SYMBOL(drm_vma_offset_remove);
269268
* RETURNS:
270269
* 0 on success, negative error code on internal failure (out-of-mem)
271270
*/
272-
int drm_vma_node_allow(struct drm_vma_offset_node *node, struct file *filp)
271+
int drm_vma_node_allow(struct drm_vma_offset_node *node, struct drm_file *tag)
273272
{
274273
struct rb_node **iter;
275274
struct rb_node *parent = NULL;
@@ -290,10 +289,10 @@ int drm_vma_node_allow(struct drm_vma_offset_node *node, struct file *filp)
290289
parent = *iter;
291290
entry = rb_entry(*iter, struct drm_vma_offset_file, vm_rb);
292291

293-
if (filp == entry->vm_filp) {
292+
if (tag == entry->vm_tag) {
294293
entry->vm_count++;
295294
goto unlock;
296-
} else if (filp > entry->vm_filp) {
295+
} else if (tag > entry->vm_tag) {
297296
iter = &(*iter)->rb_right;
298297
} else {
299298
iter = &(*iter)->rb_left;
@@ -305,7 +304,7 @@ int drm_vma_node_allow(struct drm_vma_offset_node *node, struct file *filp)
305304
goto unlock;
306305
}
307306

308-
new->vm_filp = filp;
307+
new->vm_tag = tag;
309308
new->vm_count = 1;
310309
rb_link_node(&new->vm_rb, parent, iter);
311310
rb_insert_color(&new->vm_rb, &node->vm_files);
@@ -321,17 +320,18 @@ EXPORT_SYMBOL(drm_vma_node_allow);
321320
/**
322321
* drm_vma_node_revoke - Remove open-file from list of allowed users
323322
* @node: Node to modify
324-
* @filp: Open file to remove
323+
* @tag: Tag of file to remove
325324
*
326-
* Decrement the ref-count of @filp 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
328-
* this once for every drm_vma_node_allow() on @filp.
325+
* Decrement the ref-count of @tag in the list of allowed open-files on @node.
326+
* If the ref-count drops to zero, remove @tag from the list. You must call
327+
* this once for every drm_vma_node_allow() on @tag.
329328
*
330329
* This is locked against concurrent access internally.
331330
*
332-
* If @filp is not on the list, nothing is done.
331+
* If @tag is not on the list, nothing is done.
333332
*/
334-
void drm_vma_node_revoke(struct drm_vma_offset_node *node, struct file *filp)
333+
void drm_vma_node_revoke(struct drm_vma_offset_node *node,
334+
struct drm_file *tag)
335335
{
336336
struct drm_vma_offset_file *entry;
337337
struct rb_node *iter;
@@ -341,13 +341,13 @@ void drm_vma_node_revoke(struct drm_vma_offset_node *node, struct file *filp)
341341
iter = node->vm_files.rb_node;
342342
while (likely(iter)) {
343343
entry = rb_entry(iter, struct drm_vma_offset_file, vm_rb);
344-
if (filp == entry->vm_filp) {
344+
if (tag == entry->vm_tag) {
345345
if (!--entry->vm_count) {
346346
rb_erase(&entry->vm_rb, &node->vm_files);
347347
kfree(entry);
348348
}
349349
break;
350-
} else if (filp > entry->vm_filp) {
350+
} else if (tag > entry->vm_tag) {
351351
iter = iter->rb_right;
352352
} else {
353353
iter = iter->rb_left;
@@ -361,9 +361,9 @@ EXPORT_SYMBOL(drm_vma_node_revoke);
361361
/**
362362
* drm_vma_node_is_allowed - Check whether an open-file is granted access
363363
* @node: Node to check
364-
* @filp: Open-file to check for
364+
* @tag: Tag of file to remove
365365
*
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
367367
* open-files (see drm_vma_node_allow()).
368368
*
369369
* This is locked against concurrent access internally.
@@ -372,7 +372,7 @@ EXPORT_SYMBOL(drm_vma_node_revoke);
372372
* true iff @filp is on the list
373373
*/
374374
bool drm_vma_node_is_allowed(struct drm_vma_offset_node *node,
375-
struct file *filp)
375+
struct drm_file *tag)
376376
{
377377
struct drm_vma_offset_file *entry;
378378
struct rb_node *iter;
@@ -382,9 +382,9 @@ bool drm_vma_node_is_allowed(struct drm_vma_offset_node *node,
382382
iter = node->vm_files.rb_node;
383383
while (likely(iter)) {
384384
entry = rb_entry(iter, struct drm_vma_offset_file, vm_rb);
385-
if (filp == entry->vm_filp)
385+
if (tag == entry->vm_tag)
386386
break;
387-
else if (filp > entry->vm_filp)
387+
else if (tag > entry->vm_tag)
388388
iter = iter->rb_right;
389389
else
390390
iter = iter->rb_left;

‎drivers/gpu/drm/mgag200/mgag200_ttm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ static int mgag200_bo_verify_access(struct ttm_buffer_object *bo, struct file *f
150150
{
151151
struct mgag200_bo *mgabo = mgag200_bo(bo);
152152

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);
154155
}
155156

156157
static int mgag200_ttm_io_mem_reserve(struct ttm_bo_device *bdev,

‎drivers/gpu/drm/nouveau/nouveau_bo.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,8 @@ nouveau_bo_verify_access(struct ttm_buffer_object *bo, struct file *filp)
13151315
{
13161316
struct nouveau_bo *nvbo = nouveau_bo(bo);
13171317

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);
13191320
}
13201321

13211322
static int

‎drivers/gpu/drm/qxl/qxl_ttm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ static int qxl_verify_access(struct ttm_buffer_object *bo, struct file *filp)
210210
{
211211
struct qxl_bo *qbo = to_qxl_bo(bo);
212212

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);
214215
}
215216

216217
static int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,

‎drivers/gpu/drm/radeon/radeon_ttm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ static int radeon_verify_access(struct ttm_buffer_object *bo, struct file *filp)
237237

238238
if (radeon_ttm_tt_has_userptr(bo->ttm))
239239
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);
241242
}
242243

243244
static void radeon_move_null(struct ttm_buffer_object *bo,

0 commit comments

Comments
 (0)