1
2
3
4
5
6
7#ifndef IGT_WEDGE_ME_H
8#define IGT_WEDGE_ME_H
9
10#include <linux/workqueue.h>
11
12#include "../i915_gem.h"
13
14struct drm_i915_private;
15
16struct igt_wedge_me {
17 struct delayed_work work;
18 struct drm_i915_private *i915;
19 const char *name;
20};
21
22static void __igt_wedge_me(struct work_struct *work)
23{
24 struct igt_wedge_me *w = container_of(work, typeof(*w), work.work);
25
26 pr_err("%s timed out, cancelling test.\n", w->name);
27
28 GEM_TRACE("%s timed out.\n", w->name);
29 GEM_TRACE_DUMP();
30
31 i915_gem_set_wedged(w->i915);
32}
33
34static void __igt_init_wedge(struct igt_wedge_me *w,
35 struct drm_i915_private *i915,
36 long timeout,
37 const char *name)
38{
39 w->i915 = i915;
40 w->name = name;
41
42 INIT_DELAYED_WORK_ONSTACK(&w->work, __igt_wedge_me);
43 schedule_delayed_work(&w->work, timeout);
44}
45
46static void __igt_fini_wedge(struct igt_wedge_me *w)
47{
48 cancel_delayed_work_sync(&w->work);
49 destroy_delayed_work_on_stack(&w->work);
50 w->i915 = NULL;
51}
52
53#define igt_wedge_on_timeout(W, DEV, TIMEOUT) \
54 for (__igt_init_wedge((W), (DEV), (TIMEOUT), __func__); \
55 (W)->i915; \
56 __igt_fini_wedge((W)))
57
58#endif
59