All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: "Gupta, Anshuman" <anshuman.gupta@intel.com>
Cc: "igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>
Subject: Re: [igt-dev] [PATCH i-g-t] lib/igt_aux: Check suspend state support directly.
Date: Wed, 3 Aug 2022 12:02:35 -0400	[thread overview]
Message-ID: <YuqcG1EgKu6JG8L3@intel.com> (raw)
In-Reply-To: <CY5PR11MB6211DE00EB74B1E0466255A9959C9@CY5PR11MB6211.namprd11.prod.outlook.com>

On Wed, Aug 03, 2022 at 09:59:01AM +0000, Gupta, Anshuman wrote:
> 
> 
> > -----Original Message-----
> > From: Vivi, Rodrigo <rodrigo.vivi@intel.com>
> > Sent: Monday, August 1, 2022 11:41 PM
> > To: igt-dev@lists.freedesktop.org
> > Cc: Vivi, Rodrigo <rodrigo.vivi@intel.com>; Gupta, Anshuman
> > <anshuman.gupta@intel.com>
> > Subject: [PATCH i-g-t] lib/igt_aux: Check suspend state support directly.
> > 
> > Let's simplify the suspend state check directly by using its name instead of using
> > a mask style. This will allow us to introduce a new state cleanly.
> > 
> > v2: remove accidental fprintf
> > 
> > Cc: Anshuman Gupta <anshuman.gupta@intel.com>
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>[Gupta, Anshuman] .
> Reviewed-by: Anshuman Gupta <anshuman.gupta@intel.com>

pushed, thanks for the reviews.

> > ---
> >  lib/igt_aux.c | 28 ++++++++++------------------
> >  1 file changed, 10 insertions(+), 18 deletions(-)
> > 
> > diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 6cdda077..805550d1 100644
> > --- a/lib/igt_aux.c
> > +++ b/lib/igt_aux.c
> > @@ -815,29 +815,21 @@ static void suspend_via_sysfs(int power_dir, enum
> > igt_suspend_state state)
> >  				 suspend_state_name[state]));
> >  }
> > 
> > -static uint32_t get_supported_suspend_states(int power_dir)
> > +static bool is_state_supported(int power_dir, enum igt_suspend_state
> > +state)
> >  {
> > +	const char *str;
> >  	char *states;
> > -	char *state_name;
> > -	uint32_t state_mask;
> > 
> >  	igt_assert((states = igt_sysfs_get(power_dir, "state")));
> > -	state_mask = 0;
> > -	for (state_name = strtok(states, " "); state_name;
> > -	     state_name = strtok(NULL, " ")) {
> > -		enum igt_suspend_state state;
> > -
> > -		for (state = SUSPEND_STATE_FREEZE; state <
> > SUSPEND_STATE_NUM;
> > -		     state++)
> > -			if (strcmp(state_name, suspend_state_name[state]) ==
> > 0)
> > -				break;
> > -		igt_assert(state < SUSPEND_STATE_NUM);
> > -		state_mask |= 1 << state;
> > -	}
> > 
> > -	free(states);
> > +	str = strstr(states, suspend_state_name[state]);
> > 
> > -	return state_mask;
> > +	if (!str)
> > +		igt_info("State %s not supported.\nSupported States: %s\n",
> > +			 suspend_state_name[state], states);
> > +
> > +	free(states);
> > +	return str;
> >  }
> > 
> >  /**
> > @@ -868,7 +860,7 @@ void igt_system_suspend_autoresume(enum
> > igt_suspend_state state,
> >  	enum igt_suspend_test orig_test;
> > 
> >  	igt_require((power_dir = open("/sys/power", O_RDONLY)) >= 0);
> > -	igt_require(get_supported_suspend_states(power_dir) & (1 << state));
> > +	igt_require(is_state_supported(power_dir, state));
> >  	igt_require(test == SUSPEND_TEST_NONE ||
> >  		    faccessat(power_dir, "pm_test", R_OK | W_OK, 0) == 0);
> > 
> > --
> > 2.35.3
> 

  reply	other threads:[~2022-08-03 16:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01 18:01 [igt-dev] [PATCH i-g-t 1/5] lib/igt_aux: Let's use the official mem_sleep names Rodrigo Vivi
2022-08-01 18:01 ` [igt-dev] [PATCH i-g-t 2/5] tests/i915/i915_suspend: Be more specific on the S3 mem_sleep requirement Rodrigo Vivi
2022-08-01 18:01 ` [igt-dev] [PATCH i-g-t 3/5] lib/igt_aux: Check suspend state support directly Rodrigo Vivi
2022-08-01 18:10   ` [igt-dev] [PATCH i-g-t] " Rodrigo Vivi
2022-08-03  9:59     ` Gupta, Anshuman
2022-08-03 16:02       ` Rodrigo Vivi [this message]
2022-08-01 18:01 ` [igt-dev] [PATCH i-g-t 4/5] lib/igt_aux: Introduce the ability to force S3 suspend state Rodrigo Vivi
2022-08-01 18:01 ` [igt-dev] [PATCH i-g-t 5/5] test/i915/i915_suspend: Use SUSPEND_STATE_S3 to enforce S3 Rodrigo Vivi
2022-08-01 19:31 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/5] lib/igt_aux: Let's use the official mem_sleep names (rev2) Patchwork
2022-08-02  4:45 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2022-08-05 18:49 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_aux: Let's use the official mem_sleep names Dixit, Ashutosh

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=YuqcG1EgKu6JG8L3@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.