]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915: Do not overwrite the request with zero on reallocation
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 9 Aug 2016 08:23:34 +0000 (09:23 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 9 Aug 2016 09:17:27 +0000 (10:17 +0100)
commit89d27d09764d78373a9cdee1378c8bce900181e6
treeaf5bd302e9c84a020ad5aa4de421bf6075ef80b1
parent0d6d96a175f6fe76d815ccc08110039a66e70b74
drm/i915: Do not overwrite the request with zero on reallocation

When using RCU lookup for the request, commit 3695f0bffa8f ("drm/i915:
Enable lockless lookup of request tracking via RCU"), we acknowledge that
we may race with another thread that could have reallocated the request.
In order for the first thread not to blow up, the second thread must not
clear the request completed before overwriting it. In the RCU lookup, we
allow for the engine/seqno to be replaced but we do not allow for it to
be zeroed.

The choice we make is to either add extra checking to the RCU lookup, or
embrace the inherent races (as intended). It is more complicated as we
need to manually clear everything we depend upon being zero initialised,
but we benefit from not emiting the memset() to clear the entire
frequently allocated structure (that memset turns up in throughput
profiles). And at the same time, the lookup remains flexible for future
adjustments.

v2: Old style LRC requires another variable to be initialize. (The
danger inherent in not zeroing everything.)
v3: request->batch also needs to be cleared
v4: signaling.tsk is no long used unset, but pid still exists

Fixes: 3695f0bffa8f ("drm/i915: Enable lockless lookup of request...")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: "Goel, Akash" <akash.goel@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1470731014-6894-2-git-send-email-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem_request.c
drivers/gpu/drm/i915/i915_gem_request.h