diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2017-02-23 07:44:18 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2017-02-23 14:50:42 +0000 |
commit | 591c0fb85d1c351d28334fb249bf1faaafcf326b (patch) | |
tree | 9a6efa9e1d1726bfe173051706d5daa9c49e5496 /drivers/gpu/drm/i915/selftests/mock_request.c | |
parent | d6a2289d9d6b3ea47514cf29fed56340fb8fec7e (diff) | |
download | kernel_replicant_linux-591c0fb85d1c351d28334fb249bf1faaafcf326b.tar.gz kernel_replicant_linux-591c0fb85d1c351d28334fb249bf1faaafcf326b.tar.bz2 kernel_replicant_linux-591c0fb85d1c351d28334fb249bf1faaafcf326b.zip |
drm/i915: Exercise request cancellation using a mock selftest
Add a mock selftest to preempt a request and check that we cancel it,
requeue the request and then complete its execution.
v2: Error leaks no more.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/20170223074422.4125-13-chris@chris-wilson.co.uk
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'drivers/gpu/drm/i915/selftests/mock_request.c')
-rw-r--r-- | drivers/gpu/drm/i915/selftests/mock_request.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/selftests/mock_request.c b/drivers/gpu/drm/i915/selftests/mock_request.c index e23242d1b88a..0e8d2e7f8c70 100644 --- a/drivers/gpu/drm/i915/selftests/mock_request.c +++ b/drivers/gpu/drm/i915/selftests/mock_request.c @@ -22,6 +22,7 @@ * */ +#include "mock_engine.h" #include "mock_request.h" struct drm_i915_gem_request * @@ -42,3 +43,21 @@ mock_request(struct intel_engine_cs *engine, return &mock->base; } + +bool mock_cancel_request(struct drm_i915_gem_request *request) +{ + struct mock_request *mock = container_of(request, typeof(*mock), base); + struct mock_engine *engine = + container_of(request->engine, typeof(*engine), base); + bool was_queued; + + spin_lock_irq(&engine->hw_lock); + was_queued = !list_empty(&mock->link); + list_del_init(&mock->link); + spin_unlock_irq(&engine->hw_lock); + + if (was_queued) + i915_gem_request_unsubmit(request); + + return was_queued; +} |