Skip to content

Commit 2c73676

Browse files
ickledanvet
authored andcommitted
drm/i915: Hold struct_mutex for per-file stats in debugfs/i915_gem_object
As we walk the obj->vma_list in per_file_stats(), we need to hold struct_mutex to prevent alteration of that list. Fixes: 1d2ac40 ("drm: Protect dev->filelist with its own mutex") Fixes: c84455b ("drm/i915: Move debug only per-request pid tracking from request to ctx") Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101460 Signed-off-by: Chris Wilson <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Joonas Lahtinen <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Tvrtko Ursulin <[email protected]> (cherry picked from commit 0caf81b) Signed-off-by: Daniel Vetter <[email protected]>
1 parent d8462d0 commit 2c73676

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/gpu/drm/i915/i915_debugfs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ static int per_file_stats(int id, void *ptr, void *data)
292292
struct file_stats *stats = data;
293293
struct i915_vma *vma;
294294

295+
lockdep_assert_held(&obj->base.dev->struct_mutex);
296+
295297
stats->count++;
296298
stats->total += obj->base.size;
297299
if (!obj->bind_count)
@@ -476,6 +478,8 @@ static int i915_gem_object_info(struct seq_file *m, void *data)
476478
struct drm_i915_gem_request *request;
477479
struct task_struct *task;
478480

481+
mutex_lock(&dev->struct_mutex);
482+
479483
memset(&stats, 0, sizeof(stats));
480484
stats.file_priv = file->driver_priv;
481485
spin_lock(&file->table_lock);
@@ -487,7 +491,6 @@ static int i915_gem_object_info(struct seq_file *m, void *data)
487491
* still alive (e.g. get_pid(current) => fork() => exit()).
488492
* Therefore, we need to protect this ->comm access using RCU.
489493
*/
490-
mutex_lock(&dev->struct_mutex);
491494
request = list_first_entry_or_null(&file_priv->mm.request_list,
492495
struct drm_i915_gem_request,
493496
client_link);
@@ -497,6 +500,7 @@ static int i915_gem_object_info(struct seq_file *m, void *data)
497500
PIDTYPE_PID);
498501
print_file_stats(m, task ? task->comm : "<unknown>", stats);
499502
rcu_read_unlock();
503+
500504
mutex_unlock(&dev->struct_mutex);
501505
}
502506
mutex_unlock(&dev->filelist_mutex);

0 commit comments

Comments
 (0)