drm/i915/fence: Avoid del_timer_sync() from inside a timer
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 11 Sep 2017 08:41:26 +0000 (09:41 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 19 Sep 2017 12:06:21 +0000 (13:06 +0100)
commit81c0ed21aa91230ab6c0de945155aa5c0626d001
tree29e6b323814e56a77bec1c09845f68a678fdfc54
parentf46f156ea7704a40577800c3df63b599121a87ec
drm/i915/fence: Avoid del_timer_sync() from inside a timer

A fence may be signaled from any context, including from inside a timer.
One example is timer_i915_sw_fence_wake() which is used to provide a
safety-net when waiting on an external fence. If the external fence is
not signaled within a timely fashion, we signal our fence on its behalf,
and so we then may process subsequent fences in the chain from within
that timer context.

Given that dma_i915_sw_fence_wake() may be from inside a timer, we cannot
then use del_timer_sync() as that requires the timer lock for itself. To
circumvent this, while trying to keep the signal propagation as low
latency as possible, move the completion into a worker and use a bit of
atomic switheroo to serialise the timer-callback and the dma-callback.

Testcase: igt/gem_eio/in-flight-external
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20170911084135.22903-3-chris@chris-wilson.co.uk
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
drivers/gpu/drm/i915/Kconfig
drivers/gpu/drm/i915/i915_sw_fence.c