From: Anshuman Gupta <anshuman.gupta@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v6 3/4] DEBUG: invoke powertop and pmc ltr_ignore when pc8 tests fails.
Date: Fri, 26 Apr 2019 23:15:25 +0530 [thread overview]
Message-ID: <1556300726-20254-4-git-send-email-anshuman.gupta@intel.com> (raw)
In-Reply-To: <1556300726-20254-1-git-send-email-anshuman.gupta@intel.com>
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@intel.com>
---
tests/i915/i915_pm_rpm.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 136 insertions(+), 1 deletion(-)
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index bd13d21..804e80f 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -100,6 +100,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 {
@@ -777,6 +808,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];
@@ -804,6 +898,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)
@@ -821,6 +923,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);
@@ -866,11 +969,43 @@ 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(TIME_OUT_SEC_30),
+ passed = pc8_plus_residency_changed(TIME_OUT_SEC_30);
+
+ /* Try With powertop --auto-tune */
+ if (!passed) {
+ igt_info("pc8+ residencies before powertop --auto-tune\n");
+ pmc_dump_file(pmc_debugfs, "package_cstate_show");
+ igt_require(setup_powertop());
+ passed = pc8_plus_residency_changed(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");
+ }
+ }
+ /* Try after ignoreing ltr */
+ if (!passed) {
+ pmc_dump_file(pmc_debugfs, "ltr_show");
+ for (i = 0; i <= max_ltr; i++) {
+ pmc_ignore_ltr(i);
+ passed = pc8_plus_residency_changed(TIME_OUT_SEC_10);
+ if (passed) {
+ igt_info("pc8+ residencies subtest passed "
+ "after ignoring %s ltr\n", pch_ip[i]);
+ break;
+ }
+ }
+ }
+ igt_assert_f(passed,
"Machine is not reaching PC8+ states, please check its "
"configuration.\n");
--
2.7.4
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-04-26 17:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-26 17:45 [igt-dev] [PATCH i-g-t v6 0/4] Enabling PC8+ residency for all GEN9+ platforms v6 Anshuman Gupta
2019-04-26 17:45 ` [igt-dev] [PATCH i-g-t v6 1/4] tests/i915/i915_pm_rpm: Enable PC8+ residency test for all Gen9+ Anshuman Gupta
2019-05-03 10:46 ` Ramalingam C
2019-04-26 17:45 ` [igt-dev] [PATCH i-g-t v6 2/4] tests/i915/i915_pm_rpm: modeset-pc8-residency-stress Anshuman Gupta
2019-04-26 17:59 ` Ville Syrjälä
2019-04-27 6:35 ` Gupta, Anshuman
2019-05-03 10:51 ` Ramalingam C
2019-04-26 17:45 ` Anshuman Gupta [this message]
2019-04-26 17:45 ` [igt-dev] [PATCH i-g-t v6 4/4] DO_NOT_MERGE: adding i915_pm_rpm pc8 subtest to fast feedback list Anshuman Gupta
2019-04-26 18:43 ` [igt-dev] ✗ Fi.CI.BAT: failure for Enabling PC8+ residency for all GEN9+ platforms (rev6) Patchwork
2019-04-29 5:18 ` Gupta, Anshuman
2019-04-29 11:13 ` Peres, Martin
2019-04-29 11:10 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2019-04-29 14:09 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1556300726-20254-4-git-send-email-anshuman.gupta@intel.com \
--to=anshuman.gupta@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox