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 2/2] lib/igt_aux: Enable PM Suspend dbg messages
Date: Thu, 15 Jun 2023 14:02:16 +0530	[thread overview]
Message-ID: <20230615083216.1861288-3-anshuman.gupta@intel.com> (raw)
In-Reply-To: <20230615083216.1861288-1-anshuman.gupta@intel.com>

Enabling PM Suspend dbg messages by turning on
/sys/power/pm_debug_messages switch also adding an
exit handler provision to restore the
pm_debug_messagesvstate.

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

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 425a1f911..87c3933a5 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -695,6 +695,7 @@ void igt_print_activity(void)
 
 static int autoresume_delay;
 bool __console_suspend_saved_state;
+bool __pm_debug_messages_state;
 
 #define SYSFS_MODULE_PRINTK "/sys/module/printk/parameters/"
 #define CONSOLE_SUSPEND_DISABLE false
@@ -905,7 +906,7 @@ static bool is_mem_sleep_state_supported(int power_dir, enum igt_mem_sleep state
 
 static void igt_aux_pm_suspend_dbg_restore_exit_handler(int sig)
 {
-	int sysfs_fd;
+	int sysfs_fd, power_dir;
 
 	sysfs_fd = open(SYSFS_MODULE_PRINTK, O_RDONLY);
 
@@ -913,10 +914,19 @@ static void igt_aux_pm_suspend_dbg_restore_exit_handler(int sig)
 		return;
 
 	igt_sysfs_set_boolean(sysfs_fd, "console_suspend", __console_suspend_saved_state);
+	power_dir = open("/sys/power", O_RDONLY);
+
+	if (power_dir <  0)
+		return;
+
+	if (!faccessat(power_dir, "pm_debug_messages", R_OK |  W_OK, 0))
+		igt_sysfs_set_boolean(power_dir, "pm_debug_messages", __pm_debug_messages_state);
+
 	close(sysfs_fd);
+	close(power_dir);
 }
 
-static void igt_aux_enable_pm_suspend_dbg(void)
+static void igt_aux_enable_pm_suspend_dbg(int power_dir)
 {
 	int sysfs_fd;
 
@@ -924,11 +934,18 @@ static void igt_aux_enable_pm_suspend_dbg(void)
 	if (sysfs_fd > 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_pm_suspend_dbg_restore_exit_handler);
 	} else {
 		igt_warn("Unable to open printk parameters Err:%d\n", errno);
 	}
 
+	/* pm_debug_messages depends on  CONFIG_PM_SLEEP_DEBUG */
+	if (!faccessat(power_dir, "pm_debug_messages", R_OK |  W_OK, 0)) {
+		__pm_debug_messages_state = igt_sysfs_get_boolean(sysfs_fd, "pm_debug_messages");
+		igt_sysfs_set_boolean(power_dir, "pm_debug_messages", true);
+	}
+
+	igt_install_exit_handler(igt_aux_pm_suspend_dbg_restore_exit_handler);
+
 	close(sysfs_fd);
 }
 
@@ -970,7 +987,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();
+	igt_aux_enable_pm_suspend_dbg(power_dir);
 
 	if (state == SUSPEND_STATE_S3) {
 		orig_mem_sleep = get_mem_sleep();
-- 
2.25.1

  parent reply	other threads:[~2023-06-15  8:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-15  8:32 [igt-dev] [PATCH i-g-t 0/2] PM Suspend debug Anshuman Gupta
2023-06-15  8:32 ` [igt-dev] [PATCH i-g-t 1/2] lib/igt_aux: Disable console suspend for suspend test Anshuman Gupta
2023-06-21 11:40   ` Nilawar, Badal
2023-06-21 19:32   ` Dixit, Ashutosh
2023-06-15  8:32 ` Anshuman Gupta [this message]
2023-06-15 14:20   ` [igt-dev] [PATCH i-g-t 2/2] lib/igt_aux: Enable PM Suspend dbg messages Nilawar, Badal
2023-06-21  9:48   ` [igt-dev] [PATCH i-g-t v2 " Anshuman Gupta
2023-06-21 11:30     ` Nilawar, Badal
2023-06-15  9:36 ` [igt-dev] ✓ Fi.CI.BAT: success for PM Suspend debug Patchwork
2023-06-15 10:41 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-06-21 13:23 ` [igt-dev] ✓ Fi.CI.BAT: success for PM Suspend debug (rev2) Patchwork
2023-06-22  0:55 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20230615083216.1861288-3-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