summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/selftests/mock_request.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-02-23 07:44:18 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2017-02-23 14:50:42 +0000
commit591c0fb85d1c351d28334fb249bf1faaafcf326b (patch)
tree9a6efa9e1d1726bfe173051706d5daa9c49e5496 /drivers/gpu/drm/i915/selftests/mock_request.c
parentd6a2289d9d6b3ea47514cf29fed56340fb8fec7e (diff)
downloadblackbird-obmc-linux-591c0fb85d1c351d28334fb249bf1faaafcf326b.tar.gz
blackbird-obmc-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.c19
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;
+}
OpenPOWER on IntegriCloud