[igt-dev] [PATCH i-g-t v6 1/4] igt/i915/i915_pm_lpsp enable pm_lpsp for platforms till Gen11.

Anshuman Gupta anshuman.gupta at intel.com
Thu May 30 12:21:28 UTC 2019


Enabling i915_pm_lpsp igt tests for all platforms till Gen11.
Earlier these test were enabled only on haswell and broadwell
platforms.

v2: Removed global no_lpsp_pw_idx. [Animesh]
    Check only state value for power well. [Animesh]
    Adding igt_wait of 1 second as sometimes screens_disabled
    test fails because AUDIO power domain was having non-zero
    power domain reference count.[Imre]
    Dumping i915_pm_runtime_status and i915_power_domain_info
    in case test fails.[Imre]
v3: Having igt_wait() to check lpsp_enabled() only to the part
    of test affected by delayed audio codec disabling.
v4: Simplification of power well mask. [Animesh]

Cc: imre.deak at intel.com
Signed-off-by: Anshuman Gupta <anshuman.gupta at intel.com>
---
 tests/i915/i915_pm_lpsp.c | 82 ++++++++++++++++++++++++++++++---------
 1 file changed, 64 insertions(+), 18 deletions(-)

diff --git a/tests/i915/i915_pm_lpsp.c b/tests/i915/i915_pm_lpsp.c
index b319dbe9..5885ed5f 100644
--- a/tests/i915/i915_pm_lpsp.c
+++ b/tests/i915/i915_pm_lpsp.c
@@ -30,26 +30,62 @@
 #include <fcntl.h>
 #include <unistd.h>
 
+#include "igt_sysfs.h"
+
+#define   SKL_PW_CTL_PW_2_MASK                  (0x1 << 30)
+#define   ICL_PW_CTL_PW_3_MASK                  (0x1 << 4)
+
+#define DUMP_DBGFS(file1, file2, fd)			\
+	"%s:\n%s\n%s:\n%s\n", file1,			\
+	igt_sysfs_get(fd, file1), file2,		\
+	igt_sysfs_get(fd, file2)			\
 
 static bool supports_lpsp(uint32_t devid)
 {
-	return IS_HASWELL(devid) || IS_BROADWELL(devid);
+	return IS_HASWELL(devid) || IS_BROADWELL(devid)
+				 || AT_LEAST_GEN(devid, 9);
+}
+
+static uint32_t get_no_lpsp_pw_mask(uint32_t devid)
+{
+	uint32_t no_lpsp_pw_mask;
+
+	if (IS_HASWELL(devid) || IS_BROADWELL(devid))
+		no_lpsp_pw_mask = HSW_PWR_WELL_STATE_ENABLED;
+	else if (IS_GEN(devid, 11))
+		no_lpsp_pw_mask = ICL_PW_CTL_PW_3_MASK;
+	else if (AT_LEAST_GEN(devid, 9))
+		no_lpsp_pw_mask = SKL_PW_CTL_PW_2_MASK;
+	else
+		no_lpsp_pw_mask = 0;
+
+	return no_lpsp_pw_mask;
 }
 
-static bool lpsp_is_enabled(int drm_fd)
+static bool lpsp_is_enabled(uint32_t devid)
 {
-	uint32_t val;
+	uint32_t val, mask, pw_mask;
+
+	mask = get_no_lpsp_pw_mask(devid);
+	igt_require(mask > 0);
 
 	val = INREG(HSW_PWR_WELL_CTL2);
-	return !(val & HSW_PWR_WELL_STATE_ENABLED);
+	return !(val & mask);
 }
 
 /* The LPSP mode is all about an enabled pipe, but we expect to also be in the
  * low power mode when no pipes are enabled, so do this check anyway. */
-static void screens_disabled_subtest(int drm_fd, drmModeResPtr drm_res)
+static void screens_disabled_subtest(int drm_fd, drmModeResPtr drm_res,
+				     uint32_t devid, int fd)
 {
 	kmstest_unset_all_crtcs(drm_fd, drm_res);
-	igt_assert(lpsp_is_enabled(drm_fd));
+
+	/* Some times delayed audio codec disabling causes to fail the test.
+	 * Using igt_wait to check lpsp after drm_mode_setcrtc().
+	 */
+	igt_assert_f(igt_wait(lpsp_is_enabled(devid), 1000, 100),
+		     DUMP_DBGFS("i915_runtime_pm_status",
+				"i915_power_domain_info", fd));
 }
 
 static uint32_t create_fb(int drm_fd, int width, int height)
@@ -62,7 +98,7 @@ static uint32_t create_fb(int drm_fd, int width, int height)
 
 static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
 			drmModeConnectorPtr *drm_connectors, uint32_t devid,
-			bool use_panel_fitter)
+			bool use_panel_fitter, int fd)
 {
 	int i, rc;
 	uint32_t crtc_id = 0, buffer_id = 0;
@@ -133,16 +169,18 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
 
 	if (use_panel_fitter) {
 		if (IS_HASWELL(devid))
-			igt_assert(!lpsp_is_enabled(drm_fd));
+			igt_assert(!lpsp_is_enabled(devid));
 		else
-			igt_assert(lpsp_is_enabled(drm_fd));
+			igt_assert(lpsp_is_enabled(devid));
 	} else {
-		igt_assert(lpsp_is_enabled(drm_fd));
+		igt_assert_f(lpsp_is_enabled(devid),
+			     DUMP_DBGFS("i915_runtime_pm_status",
+					"i915_power_domain_info", fd));
 	}
 }
 
-static void non_edp_subtest(int drm_fd, drmModeResPtr drm_res,
-			    drmModeConnectorPtr *drm_connectors)
+static void non_edp_subtest(int drm_fd, drmModeResPtr drm_res, uint32_t devid,
+			    drmModeConnectorPtr *drm_connectors, int fd)
 {
 	int i, rc;
 	uint32_t crtc_id = 0, buffer_id = 0;
@@ -177,8 +215,9 @@ static void non_edp_subtest(int drm_fd, drmModeResPtr drm_res,
 	rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0,
 			    &connector->connector_id, 1, mode);
 	igt_assert_eq(rc, 0);
-
-	igt_assert(!lpsp_is_enabled(drm_fd));
+	igt_assert_f(!lpsp_is_enabled(devid),
+		     DUMP_DBGFS("i915_runtime_pm_status",
+				"i915_power_domain_info", fd));
 }
 
 #define MAX_CONNECTORS 32
@@ -190,6 +229,8 @@ drmModeConnectorPtr drm_connectors[MAX_CONNECTORS];
 
 igt_main
 {
+	int debugfs;
+
 	igt_fixture {
 		int i;
 
@@ -212,17 +253,22 @@ igt_main
 
 		intel_register_access_init(intel_get_pci_device(), 0, drm_fd);
 
+		igt_require(get_no_lpsp_pw_mask(devid) > 0);
 		kmstest_set_vt_graphics_mode();
+		debugfs = igt_debugfs_dir(drm_fd);
 	}
 
 	igt_subtest("screens-disabled")
-		screens_disabled_subtest(drm_fd, drm_res);
+		screens_disabled_subtest(drm_fd, drm_res, devid, debugfs);
 	igt_subtest("edp-native")
-		edp_subtest(drm_fd, drm_res, drm_connectors, devid, false);
+		edp_subtest(drm_fd, drm_res, drm_connectors, devid, false,
+			    debugfs);
 	igt_subtest("edp-panel-fitter")
-		edp_subtest(drm_fd, drm_res, drm_connectors, devid, true);
+		edp_subtest(drm_fd, drm_res, drm_connectors, devid, true,
+			    debugfs);
 	igt_subtest("non-edp")
-		non_edp_subtest(drm_fd, drm_res, drm_connectors);
+		non_edp_subtest(drm_fd, drm_res, devid, drm_connectors,
+				debugfs);
 
 	igt_fixture {
 		int i;
-- 
2.21.0



More information about the igt-dev mailing list