@@ -488,6 +488,52 @@ int gem_engine_property_printf(int i915, const char *engine, const char *attr,
return ret;
}
+/* Ensure fast hang detection */
+void gem_engine_properties_configure(int fd, struct gem_engine_properties *params)
+{
+ int ret;
+ struct gem_engine_properties write = *params;
+
+ ret = gem_engine_property_scanf(fd, write.engine->name,
+ "heartbeat_interval_ms",
+ "%d", ¶ms->heartbeat_interval);
+ igt_assert_eq(ret, 1);
+
+ ret = gem_engine_property_printf(fd, write.engine->name,
+ "heartbeat_interval_ms", "%d",
+ write.heartbeat_interval);
+ igt_assert_lt(0, ret);
+
+ if (gem_scheduler_has_preemption(fd)) {
+ ret = gem_engine_property_scanf(fd, write.engine->name,
+ "preempt_timeout_ms",
+ "%d", ¶ms->preempt_timeout);
+ igt_assert_eq(ret, 1);
+
+ ret = gem_engine_property_printf(fd, write.engine->name,
+ "preempt_timeout_ms", "%d",
+ write.preempt_timeout);
+ igt_assert_lt(0, ret);
+ }
+}
+
+void gem_engine_properties_restore(int fd, const struct gem_engine_properties *saved)
+{
+ int ret;
+
+ ret = gem_engine_property_printf(fd, saved->engine->name,
+ "heartbeat_interval_ms", "%d",
+ saved->heartbeat_interval);
+ igt_assert_lt(0, ret);
+
+ if (gem_scheduler_has_preemption(fd)) {
+ ret = gem_engine_property_printf(fd, saved->engine->name,
+ "preempt_timeout_ms", "%d",
+ saved->preempt_timeout);
+ igt_assert_lt(0, ret);
+ }
+}
+
uint32_t gem_engine_mmio_base(int i915, const char *engine)
{
unsigned int mmio = 0;
@@ -115,6 +115,15 @@ struct intel_execution_engine2 gem_eb_flags_to_engine(unsigned int flags);
((e__) = intel_get_current_physical_engine(&i__##e__)); \
intel_next_engine(&i__##e__))
+struct gem_engine_properties {
+ const struct intel_execution_engine2 *engine;
+ int preempt_timeout;
+ int heartbeat_interval;
+};
+
+void gem_engine_properties_configure(int fd, struct gem_engine_properties *params);
+void gem_engine_properties_restore(int fd, const struct gem_engine_properties *saved);
+
__attribute__((format(scanf, 4, 5)))
int gem_engine_property_scanf(int i915, const char *engine, const char *attr,
const char *fmt, ...);