@@ -38,6 +38,7 @@
#include "drmtest.h"
#include "igt_pm.h"
#include "igt_aux.h"
+#include "igt_sysfs.h"
/**
* SECTION:igt_pm
@@ -577,6 +578,60 @@ bool igt_setup_runtime_pm(void)
return true;
}
+bool igt_disable_runtime_pm(void)
+{
+ int fd;
+ ssize_t size;
+ char buf[6];
+
+ if (pm_status_fd < 0) {
+ fd = open(POWER_DIR "/autosuspend_delay_ms", O_RDWR);
+ if (fd < 0)
+ return false;
+
+ size = read(fd, __igt_pm_runtime_autosuspend,
+ sizeof(__igt_pm_runtime_autosuspend));
+
+ if (size <= 0) {
+ close(fd);
+ return false;
+ }
+
+ strchomp(__igt_pm_runtime_autosuspend);
+ igt_install_exit_handler(__igt_pm_runtime_exit_handler);
+ close(fd);
+ }
+
+ /* We know we support runtime PM, let's try to disable it now. */
+ fd = open(POWER_DIR "/control", O_RDWR);
+ igt_assert_f(fd >= 0, "Can't open " POWER_DIR "/control\n");
+
+ if (pm_status_fd < 0) {
+ igt_assert(read(fd, __igt_pm_runtime_control,
+ sizeof(__igt_pm_runtime_control)) > 0);
+ strchomp(__igt_pm_runtime_control);
+
+ igt_debug("Saved runtime power management as '%s' and '%s'\n",
+ __igt_pm_runtime_autosuspend, __igt_pm_runtime_control);
+ }
+
+ size = write(fd, "on\n", 3);
+ igt_assert(size == 3);
+ lseek(fd, 0, SEEK_SET);
+ size = read(fd, buf, ARRAY_SIZE(buf));
+ igt_assert(size == 3);
+ igt_assert(strncmp(buf, "on\n", 3) == 0);
+ close(fd);
+
+ if (pm_status_fd < 0) {
+ pm_status_fd = open(POWER_DIR "/runtime_status", O_RDONLY);
+ igt_assert_f(pm_status_fd >= 0,
+ "Can't open " POWER_DIR "/runtime_status\n");
+ }
+
+ return true;
+}
+
/**
* igt_get_runtime_pm_status:
*
@@ -620,3 +675,30 @@ bool igt_wait_for_pm_status(enum igt_runtime_pm_status status)
{
return igt_wait(igt_get_runtime_pm_status() == status, 10000, 100);
}
+
+/**
+ * dmc_loaded:
+ * @debugfs: fd to the debugfs dir.
+
+ * Check whether DMC FW is loaded or not. DMC FW is require for few Display C
+ * states like DC5 and DC6. FW does the Context Save and Restore during Display
+ * C States entry and exit.
+ *
+ * Returns:
+ * True if DMC FW is loaded otherwise false.
+ */
+bool igt_pm_dmc_loaded(int debugfs)
+{
+ igt_require(debugfs != -1);
+ char buf[15];
+ int len;
+
+ len = igt_sysfs_read(debugfs, "i915_dmc_info", buf, sizeof(buf) - 1);
+ if (len < 0)
+ return true; /* no CSR support, no DMC requirement */
+
+ buf[len] = '\0';
+
+ igt_info("DMC: %s\n", buf);
+ return strstr(buf, "fw loaded: yes");
+}
@@ -47,8 +47,10 @@ enum igt_runtime_pm_status {
};
bool igt_setup_runtime_pm(void);
+bool igt_disable_runtime_pm(void);
void igt_restore_runtime_pm(void);
enum igt_runtime_pm_status igt_get_runtime_pm_status(void);
bool igt_wait_for_pm_status(enum igt_runtime_pm_status status);
+bool igt_pm_dmc_loaded(int debugfs);
#endif /* IGT_PM_H */
@@ -710,21 +710,6 @@ static void setup_pc8(void)
has_pc8 = true;
}
-static bool dmc_loaded(void)
-{
- char buf[15];
- int len;
-
- len = igt_sysfs_read(debugfs, "i915_dmc_info", buf, sizeof(buf) - 1);
- if (len < 0)
- return true; /* no CSR support, no DMC requirement */
-
- buf[len] = '\0';
-
- igt_info("DMC: %s\n", buf);
- return strstr(buf, "fw loaded: yes");
-}
-
static void dump_file(int dir, const char *filename)
{
char *contents;
@@ -761,7 +746,7 @@ static bool setup_environment(void)
igt_info("Runtime PM support: %d\n", has_runtime_pm);
igt_info("PC8 residency support: %d\n", has_pc8);
igt_require(has_runtime_pm);
- igt_require(dmc_loaded());
+ igt_require(igt_pm_dmc_loaded(debugfs));
out:
disable_all_screens(&ms_data);