]> git.karo-electronics.de Git - karo-tx-linux.git/commit
drm: Hold the mutex when dropping the last GEM reference (v2)
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 30 Sep 2010 08:10:26 +0000 (09:10 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 29 Oct 2010 04:51:31 +0000 (21:51 -0700)
commit9b909fc8c3e8e04d012c20f38de2d57aedfc16a0
tree249fd9d562f936181da2ec6cdd14f7ca8cd73da6
parentac9f371955a1d6ce27b1464a86137b4cdb0f43d8
drm: Hold the mutex when dropping the last GEM reference (v2)

commit 39b4d07aa3583ceefe73622841303a0a3e942ca1 upstream.

In order to be fully threadsafe we need to check that the drm_gem_object
refcount is still 0 after acquiring the mutex in order to call the free
function. Otherwise, we may encounter scenarios like:

Thread A:                                        Thread B:
drm_gem_close
unreference_unlocked
kref_put                                         mutex_lock
...                                              i915_gem_evict
...                                              kref_get -> BUG
...                                              i915_gem_unbind
...                                              kref_put
...                                              i915_gem_object_free
...                                              mutex_unlock
mutex_lock
i915_gem_object_free -> BUG
i915_gem_object_unbind
kfree
mutex_unlock

Note that no driver is currently using the free_unlocked vfunc and it is
scheduled for removal, hasten that process.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=30454
Reported-and-Tested-by: Magnus Kessler <Magnus.Kessler@gmx.net>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/gpu/drm/drm_gem.c
include/drm/drmP.h