linux/drivers/gpu/drm/i915/selftests/lib_sw_fence.h
Chris Wilson 214707fc2c drm/i915/selftests: Wrap a timer into a i915_sw_fence
For some selftests, we want to issue requests but delay them going to
hardware. Furthermore, we don't want those requests to block
indefinitely (or else we may hang the driver and block testing) so we
want to employ a timeout. So naturally we want a fence that is
automatically signaled by a timer.

v2: Add kselftests.
v3: Limit the API available to selftests; there isn't an overwhelming
reason to export it universally.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171012125726.14736-2-chris@chris-wilson.co.uk
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2017-10-12 21:06:26 +01:00

43 lines
962 B
C

/*
* lib_sw_fence.h - library routines for testing N:M synchronisation points
*
* Copyright (C) 2017 Intel Corporation
*
* This file is released under the GPLv2.
*
*/
#ifndef _LIB_SW_FENCE_H_
#define _LIB_SW_FENCE_H_
#include <linux/timer.h>
#include "../i915_sw_fence.h"
#ifdef CONFIG_LOCKDEP
#define onstack_fence_init(fence) \
do { \
static struct lock_class_key __key; \
\
__onstack_fence_init((fence), #fence, &__key); \
} while (0)
#else
#define onstack_fence_init(fence) \
__onstack_fence_init((fence), NULL, NULL)
#endif
void __onstack_fence_init(struct i915_sw_fence *fence,
const char *name,
struct lock_class_key *key);
void onstack_fence_fini(struct i915_sw_fence *fence);
struct timed_fence {
struct i915_sw_fence fence;
struct timer_list timer;
};
void timed_fence_init(struct timed_fence *tf, unsigned long expires);
void timed_fence_fini(struct timed_fence *tf);
#endif /* _LIB_SW_FENCE_H_ */