drm/i915: Embrace the race in busy-ioctl
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 16 Aug 2016 08:50:40 +0000 (09:50 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 16 Aug 2016 09:35:02 +0000 (10:35 +0100)
commit1255501d8681775d564de45742c6e82b7782b7f5
tree1996b7ec9f99f03678dc7a9a5fbf32114f588c2f
parent1544c42ed9904835cce14ec917e7678c92191614
drm/i915: Embrace the race in busy-ioctl

Daniel Vetter proposed a new challenge to the serialisation inside the
busy-ioctl that exposed a flaw that could result in us reporting the
wrong engine as being busy. If the request is reallocated as we test
its busyness and then reassigned to this object by another thread, we
would not notice that the test itself was incorrect.

We are faced with a choice of using __i915_gem_active_get_request_rcu()
to first acquire a reference to the request preventing the race, or to
acknowledge the race and accept the limitations upon the accuracy of the
busy flags. Note that we guarantee that we never falsely report the
object as idle (providing userspace itself doesn't race), and so the
most important use of the busy-ioctl and its guarantees are fulfilled.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471337440-16777-1-git-send-email-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem.c
include/uapi/drm/i915_drm.h