Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Anshuman Gupta <anshuman.gupta@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: badal.nilawar@intel.com
Subject: [igt-dev] [PATCH i-g-t v5 1/2] lib/igt_aux: Disable console suspend for suspend test
Date: Wed, 28 Jun 2023 12:17:19 +0530	[thread overview]
Message-ID: <20230628064720.3969317-2-anshuman.gupta@intel.com> (raw)
In-Reply-To: <20230628064720.3969317-1-anshuman.gupta@intel.com>

We need no_console_suspend to be enable in order to dump the suspend
logs over serial console before attempting the suspend during
CI Execution.
Therefore disable the console_suspend using printk module parameters
while executing suspend test.

v2:
- Keep console_suspend restore only in exit handler. [Ashutosh]
- Don't skip the test on open error, while opening printk parameters,
  instead print warning. [Kmail]
v3:
- Fixed cosmetics and return value comment. [Ashutosh]
v4:
- Added igt_aux_enable_pm_suspend_dbg() function doc. [Kmail]

Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
Reviewed-by: Badal Nilawar <badal.nilawar@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 lib/igt_aux.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 386e257834..dca559384e 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -702,6 +702,10 @@ void igt_print_activity(void)
 }
 
 static int autoresume_delay;
+bool __console_suspend_saved_state;
+
+#define SYSFS_MODULE_PRINTK "/sys/module/printk/parameters/"
+#define CONSOLE_SUSPEND_DISABLE false
 
 static const char *suspend_state_name[] = {
 	[SUSPEND_STATE_FREEZE] = "freeze",
@@ -907,6 +911,45 @@ static bool is_mem_sleep_state_supported(int power_dir, enum igt_mem_sleep state
 	return str;
 }
 
+static void igt_aux_pm_suspend_dbg_restore_exit_handler(int sig)
+{
+	int sysfs_fd;
+
+	sysfs_fd = open(SYSFS_MODULE_PRINTK, O_RDONLY);
+	if (sysfs_fd < 0)
+		return;
+
+	igt_sysfs_set_boolean(sysfs_fd, "console_suspend", __console_suspend_saved_state);
+	close(sysfs_fd);
+}
+
+/**
+ * igt_aux_enable_pm_suspend_dbg:
+ *
+ * Enhance the System wide suspend/resume debugging by
+ * disabling console suspend. Disabling console suspend dump the suspend/resume
+ * logs over serial console. That will be useful to debug CI Suspend/Resume issues
+ * tagged with 'Incomplete' result.
+ */
+static void igt_aux_enable_pm_suspend_dbg(void)
+{
+	int sysfs_fd;
+
+	sysfs_fd = open(SYSFS_MODULE_PRINTK, O_RDONLY);
+	if (sysfs_fd > 0) {
+		__console_suspend_saved_state = igt_sysfs_get_boolean(sysfs_fd, "console_suspend");
+
+		if (!igt_sysfs_set_boolean(sysfs_fd, "console_suspend", CONSOLE_SUSPEND_DISABLE))
+			igt_warn("Unable to disable console suspend\n");
+
+		igt_install_exit_handler(igt_aux_pm_suspend_dbg_restore_exit_handler);
+	} else {
+		igt_warn("Unable to open printk parameters Err:%d\n", errno);
+	}
+
+	close(sysfs_fd);
+}
+
 /**
  * igt_system_suspend_autoresume:
  * @state: an #igt_suspend_state, the target suspend state
@@ -945,6 +988,7 @@ void igt_system_suspend_autoresume(enum igt_suspend_state state,
 		      "Suspend to disk requires swap space.\n");
 
 	orig_test = get_suspend_test(power_dir);
+	igt_aux_enable_pm_suspend_dbg();
 
 	if (state == SUSPEND_STATE_S3) {
 		orig_mem_sleep = get_mem_sleep();
-- 
2.25.1

  reply	other threads:[~2023-06-28  6:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28  6:47 [igt-dev] [PATCH i-g-t v5 0/2] PM Suspend debug Anshuman Gupta
2023-06-28  6:47 ` Anshuman Gupta [this message]
2023-06-28  6:47 ` [igt-dev] [PATCH i-g-t v5 2/2] lib/igt_aux: Enable PM Suspend dbg messages Anshuman Gupta
2023-06-28  7:43 ` [igt-dev] ✓ Fi.CI.BAT: success for PM Suspend debug (rev6) Patchwork
2023-06-30 10:43   ` Gupta, Anshuman
2023-06-28 19:51 ` [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=20230628064720.3969317-2-anshuman.gupta@intel.com \
    --to=anshuman.gupta@intel.com \
    --cc=badal.nilawar@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