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
Subject: [igt-dev] [PATCH i-g-t] lib: disable console suspend for suspend test
Date: Wed,  1 Mar 2023 18:14:30 +0530	[thread overview]
Message-ID: <20230301124430.186193-1-anshuman.gupta@intel.com> (raw)

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.

Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 lib/igt_aux.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 15e304407f..e1260c1e88 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -694,6 +694,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 0
 
 static const char *suspend_state_name[] = {
 	[SUSPEND_STATE_FREEZE] = "freeze",
@@ -899,6 +903,19 @@ static bool is_mem_sleep_state_supported(int power_dir, enum igt_mem_sleep state
 	return str;
 }
 
+static void __igt_aux_console_suspend_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_system_suspend_autoresume:
  * @state: an #igt_suspend_state, the target suspend state
@@ -923,10 +940,15 @@ static bool is_mem_sleep_state_supported(int power_dir, enum igt_mem_sleep state
 void igt_system_suspend_autoresume(enum igt_suspend_state state,
 				   enum igt_suspend_test test)
 {
-	int power_dir;
+	int power_dir, sysfs_fd;
 	enum igt_suspend_test orig_test;
 	enum igt_mem_sleep orig_mem_sleep = MEM_SLEEP_NONE;
 
+	igt_require((sysfs_fd = open(SYSFS_MODULE_PRINTK, O_RDONLY)) >= 0);
+	__console_suspend_saved_state = igt_sysfs_get_boolean(sysfs_fd, "console_suspend");
+	igt_sysfs_set_boolean(sysfs_fd, "console_suspend", CONSOLE_SUSPEND_DISABLE);
+	igt_install_exit_handler(__igt_aux_console_suspend_restore_exit_handler);
+
 	igt_require((power_dir = open("/sys/power", O_RDONLY)) >= 0);
 	igt_require(is_state_supported(power_dir, state));
 	igt_require(test == SUSPEND_TEST_NONE ||
@@ -958,7 +980,9 @@ void igt_system_suspend_autoresume(enum igt_suspend_state state,
 		set_mem_sleep(power_dir, orig_mem_sleep);
 
 	set_suspend_test(power_dir, orig_test);
+	igt_sysfs_set_boolean(sysfs_fd, "console_suspend", __console_suspend_saved_state);
 	close(power_dir);
+	close(sysfs_fd);
 }
 
 static int original_autoresume_delay;
-- 
2.25.1

             reply	other threads:[~2023-03-01 12:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01 12:44 Anshuman Gupta [this message]
2023-03-01 14:56 ` [igt-dev] ✓ Fi.CI.BAT: success for lib: disable console suspend for suspend test Patchwork
2023-03-02 15:38 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-03-02 23:51 ` [igt-dev] [PATCH i-g-t] " Dixit, Ashutosh
2023-03-08 16:20   ` Kamil Konieczny

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=20230301124430.186193-1-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