@@ -518,6 +518,59 @@ static void run_tests(unsigned mode)
intel_register_access_fini();
}
+static unsigned int readit(const char *path)
+{
+ unsigned int ret = 0;
+ int scanned = 0;
+ FILE *file;
+
+ file = fopen(path, "r");
+ igt_assert(file);
+ scanned = fscanf(file, "%u", &ret);
+ igt_assert_eq(scanned, 1);
+
+ fclose(file);
+
+ return ret;
+}
+
+static int read_rc6_residency(void)
+{
+ unsigned int residency;
+ const int device = drm_get_card();
+ static const char path_format[] =
+ "/sys/class/drm/card%d/power/rc6_residency_ms";
+ char path[sizeof(path_format)];
+ int ret;
+
+ ret = snprintf(path, sizeof(path)-1, path_format, device);
+
+ igt_assert_neq(ret, -1);
+ residency = readit(path);
+
+ return residency;
+}
+
+static void context_rc6_test(void)
+{
+ int fd = drm_open_driver(DRIVER_INTEL);
+ int res_ms;
+ uint32_t ctx_id = gem_context_create(fd);
+
+ igt_debug("RC6 Context Test\n");
+ check_control_registers(fd, I915_EXEC_RENDER, ctx_id, false);
+ check_l3cc_registers(fd, I915_EXEC_RENDER, ctx_id, false);
+
+ res_ms = read_rc6_residency();
+ sleep(3);
+ igt_assert_neq(res_ms, read_rc6_residency());
+
+ check_control_registers(fd, I915_EXEC_RENDER, ctx_id, false);
+ check_l3cc_registers(fd, I915_EXEC_RENDER, ctx_id, false);
+ close(fd);
+}
+
+
static void test_requirements(void)
{
int fd = drm_open_driver_master(DRIVER_INTEL);
@@ -537,6 +590,9 @@ igt_main
igt_subtest("mocs-settings")
run_tests(NONE);
+ igt_subtest("mocs-rc6")
+ context_rc6_test();
+
igt_subtest("mocs-reset")
run_tests(RESET);