2 * SPDX-License-Identifier: MIT
4 * Copyright © 2018 Intel Corporation
10 #include <linux/workqueue.h>
12 #include "../i915_gem.h"
14 struct drm_i915_private;
17 struct delayed_work work;
18 struct drm_i915_private *i915;
22 static void __igt_wedge_me(struct work_struct *work)
24 struct igt_wedge_me *w = container_of(work, typeof(*w), work.work);
26 pr_err("%s timed out, cancelling test.\n", w->name);
28 GEM_TRACE("%s timed out.\n", w->name);
31 i915_gem_set_wedged(w->i915);
34 static void __igt_init_wedge(struct igt_wedge_me *w,
35 struct drm_i915_private *i915,
42 INIT_DELAYED_WORK_ONSTACK(&w->work, __igt_wedge_me);
43 schedule_delayed_work(&w->work, timeout);
46 static void __igt_fini_wedge(struct igt_wedge_me *w)
48 cancel_delayed_work_sync(&w->work);
49 destroy_delayed_work_on_stack(&w->work);
53 #define igt_wedge_on_timeout(W, DEV, TIMEOUT) \
54 for (__igt_init_wedge((W), (DEV), (TIMEOUT), __func__); \
56 __igt_fini_wedge((W)))
58 #endif /* IGT_WEDGE_ME_H */