Commit a0e57b28 authored by Chris Wilson's avatar Chris Wilson Committed by Sasha Levin

drm/i915: Check obj->vma_list under the struct_mutex

commit 6c31a614 upstream.

When we walk the list of vma, or even for protecting against concurrent
framebuffer creation, we must hold the struct_mutex or else a second
thread can corrupt the list as we walk it.

Fixes regression from
commit d7f46fc4
Author: Ben Widawsky <benjamin.widawsky@intel.com>
Date:   Fri Dec 6 14:10:55 2013 -0800

    drm/i915: Make pin count per VMA

References: https://bugs.freedesktop.org/show_bug.cgi?id=89085Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 914b78e8
...@@ -315,9 +315,10 @@ i915_gem_set_tiling(struct drm_device *dev, void *data, ...@@ -315,9 +315,10 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
return -EINVAL; return -EINVAL;
} }
mutex_lock(&dev->struct_mutex);
if (i915_gem_obj_is_pinned(obj) || obj->framebuffer_references) { if (i915_gem_obj_is_pinned(obj) || obj->framebuffer_references) {
drm_gem_object_unreference_unlocked(&obj->base); ret = -EBUSY;
return -EBUSY; goto err;
} }
if (args->tiling_mode == I915_TILING_NONE) { if (args->tiling_mode == I915_TILING_NONE) {
...@@ -349,7 +350,6 @@ i915_gem_set_tiling(struct drm_device *dev, void *data, ...@@ -349,7 +350,6 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
} }
} }
mutex_lock(&dev->struct_mutex);
if (args->tiling_mode != obj->tiling_mode || if (args->tiling_mode != obj->tiling_mode ||
args->stride != obj->stride) { args->stride != obj->stride) {
/* We need to rebind the object if its current allocation /* We need to rebind the object if its current allocation
...@@ -395,6 +395,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data, ...@@ -395,6 +395,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
obj->bit_17 = NULL; obj->bit_17 = NULL;
} }
err:
drm_gem_object_unreference(&obj->base); drm_gem_object_unreference(&obj->base);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment