From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85A0B10E444 for ; Wed, 21 Jun 2023 11:40:40 +0000 (UTC) Message-ID: <230f8664-1546-c74e-8afc-5fa57359e8f8@intel.com> Date: Wed, 21 Jun 2023 17:10:00 +0530 Content-Language: en-US To: Anshuman Gupta , References: <20230615083216.1861288-1-anshuman.gupta@intel.com> <20230615083216.1861288-2-anshuman.gupta@intel.com> From: "Nilawar, Badal" In-Reply-To: <20230615083216.1861288-2-anshuman.gupta@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Subject: Re: [igt-dev] [PATCH i-g-t 1/2] lib/igt_aux: Disable console suspend for suspend test List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: On 15-06-2023 14:02, Anshuman Gupta wrote: > 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] > > Signed-off-by: Anshuman Gupta Looks good to me. Reviewed-by: Badal Nilawar > --- > lib/igt_aux.c | 34 ++++++++++++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) > > diff --git a/lib/igt_aux.c b/lib/igt_aux.c > index 672d7d4b0..425a1f911 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 false > > static const char *suspend_state_name[] = { > [SUSPEND_STATE_FREEZE] = "freeze", > @@ -899,6 +903,35 @@ 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); > +} > + > +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"); > + 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); > + } > + > + close(sysfs_fd); > +} > + > /** > * igt_system_suspend_autoresume: > * @state: an #igt_suspend_state, the target suspend state > @@ -937,6 +970,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();