[igt-dev] [PATCH i-g-t v7 3/4] DEBUG: invoke powertop and pmc ltr_ignore when pc8 tests fails.

Anshuman Gupta anshuman.gupta at intel.com
Wed Jun 5 07:54:29 UTC 2019


When pc8_residency test fails, try pc8 residency subtest after
setting powertop --auto-tune and further try sub-test with
pmc ltr_ignore attributes.

Signed-off-by: Anshuman Gupta <anshuman.gupta at intel.com>
---
 tests/i915/i915_pm_rpm.c | 130 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 129 insertions(+), 1 deletion(-)

diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index 6ebbb30a..0c9a7890 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -99,6 +99,37 @@ int drm_fd, msr_fd, pc8_status_fd;
 int debugfs;
 bool has_runtime_pm, has_pc8, pc8_needs_screen_off;
 struct mode_set_data ms_data;
+int pmc_debugfs, max_ltr;
+bool pmc_loaded;
+
+#define ICL_MAX_LTR 20
+#define CNL_MAX_LTR 19
+#define SKL_MAX_LTR 17
+#define SIZE_PCH_IP_ARR 21
+
+const char *pch_ip[SIZE_PCH_IP_ARR] = {
+	"SOUTHPORT_A",
+	"SOUTHPORT_B",
+	"SATA",
+	"GIGABIT_ETHERNET",
+	"XHCI",
+	"Reserved",
+	"ME",
+	"EVA",
+	"SOUTHPORT_C",
+	"HD_AUDIO",
+	"CNV",
+	"LPSS",
+	"SOUTHPORT_D",
+	"SOUTHPORT_E",
+	"CAMERA",
+	"ESPI",
+	"SCC",
+	"ISH",
+	"UFSX2",
+	"EMMC",
+	"WIGIG"
+};
 
 /* Stuff used when creating FBs and mode setting. */
 struct mode_set_data {
@@ -776,6 +807,69 @@ static void setup_pc8(void)
 	has_pc8 = true;
 }
 
+static void pmc_ignore_ltr(int ip)
+{
+	char tmp[10];
+	int len, fd;
+
+	if (!pmc_loaded)
+		return;
+
+	len = snprintf(tmp, sizeof(tmp), "%d", ip);
+	fd = openat(pmc_debugfs, "ltr_ignore", O_WRONLY);
+	if (fd >= 0) {
+		igt_assert_eq(write(fd, tmp, len), len);
+		close(fd);
+	}
+}
+
+static bool setup_powertop(void)
+{
+	FILE *fp;
+	char tmp[512];
+
+	fp = popen("powertop --auto-tune", "r");
+	if (fp == NULL) {
+		igt_info("Failed to run powertop\n");
+		perror("popen");
+		return false;
+	}
+
+	while (fgets(tmp, sizeof(tmp), fp) != NULL)
+		igt_info("%s\n", tmp);
+
+	pclose(fp);
+	return true;
+}
+
+static bool setup_pmc(void)
+{
+	const char *debugfs_root;
+	char path[200];
+
+	/* Make sure our intel_pmc_core module is loaded. */
+	pmc_loaded = modprobe("intel_pmc_core") == 0;
+
+	if (!pmc_loaded) {
+		igt_info("intel_pmc_core module not loaded\n");
+		return;
+	}
+
+	if (IS_ICELAKE(ms_data.devid))
+		max_ltr = ICL_MAX_LTR;
+	else if (IS_CANNONLAKE(ms_data.devid))
+		max_ltr = CNL_MAX_LTR;
+	else if (AT_LEAST_GEN(ms_data.devid, 9) && !IS_BROXTON(ms_data.devid) &&
+		 !IS_GEMINILAKE(ms_data.devid))
+		max_ltr = SKL_MAX_LTR;
+
+	debugfs_root = igt_debugfs_mount();
+	igt_assert(debugfs_root);
+	snprintf(path, sizeof(path), "%s/pmc_core", debugfs_root);
+	pmc_debugfs = open(path, O_RDONLY);
+	igt_require(pmc_debugfs != -1);
+}
+
 static bool dmc_loaded(void)
 {
 	char buf[15];
@@ -803,6 +897,14 @@ static void dump_file(int dir, const char *filename)
 	free(contents);
 }
 
+static void pmc_dump_file(int fd, const char *file)
+{
+	if (!pmc_loaded)
+		return;
+
+	dump_file(fd, file);
+}
+
 static bool setup_environment(void)
 {
 	if (has_runtime_pm)
@@ -820,6 +922,7 @@ static bool setup_environment(void)
 	pm_data = igt_pm_enable_sata_link_power_management();
 
 	has_runtime_pm = igt_setup_runtime_pm();
+	setup_pmc();
 	setup_pc8();
 
 	igt_info("Runtime PM support: %d\n", has_runtime_pm);
@@ -865,11 +968,36 @@ static void basic_subtest(void)
 
 static void pc8_residency_subtest(void)
 {
+	bool passed;
+	int i;
 	igt_require(has_pc8);
 
 	/* Make sure PC8+ residencies move! */
 	disable_all_screens(&ms_data);
-	igt_assert_f(pc8_plus_residency_changed(30),
+	passed = pc8_plus_residency_changed(30);
+
+	/* Try With powertop --auto-tune */
+	if (!passed) {
+		igt_info("pc8+ residencies byyefore powertop --auto-tune\n");
+		pmc_dump_file(pmc_debugfs, "package_cstate_show");
+		igt_require(setup_powertop());
+		passed = pc8_plus_residency_changed(IGT_TIME_OUT_SEC_10);
+
+		if (!passed) {
+			igt_info("pc8+ residencies after powertop --auto-tune\n");
+			pmc_dump_file(pmc_debugfs, "package_cstate_show");
+		} else {
+			igt_info("pc8+ residencies subtest passed "
+				 "after running powertop --auto-tune\n");
+		}
+	}
+	/* dump ltr_show and pch_ip_power_gating_status */
+	igt_info("pch i/p latency tolerance reporting\n");
+	pmc_dump_file(pmc_debugfs, "ltr_show");
+	igt_info("pch i/p power gating status\n");
+	pmc_dump_file(pmc_debugfs, "pch_ip_power_gating_status");
+
+	igt_assert_f(passed,
 		     "Machine is not reaching PC8+ states, please check its "
 		     "configuration.\n");
 
-- 
2.21.0



More information about the igt-dev mailing list