Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Gupta, Anshuman" <anshuman.gupta@intel.com>
To: "Bhatt, Jigar" <jigar.bhatt@intel.com>,
	"igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>
Cc: "Varide, Nischal" <nischal.varide@intel.com>,
	"Shankar, Uma" <uma.shankar@intel.com>,
	"Sharma, Swati2" <swati2.sharma@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t v5 2/2] tests/i915/i915_pm_dc: Fix DC9 test
Date: Fri, 24 Sep 2021 09:44:20 +0000	[thread overview]
Message-ID: <3b2c72a7d5694100bcd84f674d94fb3d@intel.com> (raw)
In-Reply-To: <20210924082202.1891208-3-jigar.bhatt@intel.com>



> -----Original Message-----
> From: Bhatt, Jigar <jigar.bhatt@intel.com>
> Sent: Friday, September 24, 2021 1:52 PM
> To: igt-dev@lists.freedesktop.org
> Cc: Bhatt, Jigar <jigar.bhatt@intel.com>; Gupta, Anshuman
> <anshuman.gupta@intel.com>; Varide, Nischal <nischal.varide@intel.com>;
> Shankar, Uma <uma.shankar@intel.com>; Sharma, Swati2
> <swati2.sharma@intel.com>
> Subject: [PATCH i-g-t v5 2/2] tests/i915/i915_pm_dc: Fix DC9 test
> 
> Fixing DC9 test with reading prev_dc counter(DC5/DC6), comparing to actual
> counter values.
> Dumping i915_pm_runtime_status debugfs incase of failure.
> While executing test, it require to disable the kms connector polling to avoid
> runtime resume.
> This would require to save and restore the kms connector poll state.
> 
> V1: Reading previous DC counter
> prev_dc = read_dc_counter(dc_target) before the dpms_off().
> 
> V2: Bit cleaner code.[Imre]
> dump the i915_pm_runtime_status debugfs file in case of test
> failure.[Anshuman]
> 
> V3: Disabling the polling during DC9 test “echo 0 >
> /sys/module/drm_kms_helper/parameters/poll”.[Anshuman]
> 
> V4: Passing right fd to igt_sysfs_get_boolean() function, moving save and get
> part of polling to setup_dc9_dpms().
> 
> V5: Use macro for "/sys/module/drm_kms_helper/parameters/poll".
> Add igt_require when opening sysfs.
> Add igt_install_exit_handler(reset_kms_poll) so it will restore actual sysfs kms
> polling status.[Anshuman]
> 
> V6: Using if() condition instead of
> igt_require((sysfs_fd = open(KMS_POLL_PATH, O_WRONLY)) >= 0) [Petri]
> 
> Signed-off-by: Jigar Bhatt <jigar.bhatt@intel.com>
> ---
>  tests/i915/i915_pm_dc.c | 54 ++++++++++++++++++++++++++++++-----------
>  1 file changed, 40 insertions(+), 14 deletions(-)
> 
> diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c index
> 04acf839..bec6bf24 100644
> --- a/tests/i915/i915_pm_dc.c
> +++ b/tests/i915/i915_pm_dc.c
> @@ -40,6 +40,11 @@
>  #define CHECK_DC3CO	(1 << 2)
> 
>  #define PWR_DOMAIN_INFO "i915_power_domain_info"
> +#define RPM_STATUS "i915_runtime_pm_status"
> +#define KMS_POLL_PATH "/sys/module/drm_kms_helper/parameters/poll"
Make this KMS_HELPER "/sys/module/drm_kms_helper/parameters/ " for opening
The sys_fd and then use it in igt_sysfs_get_boolean() along with "poll", attribute
as per the API doc.

> +#define KMS_POLL_DISABLE 0
> +
> +bool kms_poll_saved_state;
> 
>  typedef struct {
>  	double r, g, b;
> @@ -393,23 +398,35 @@ static bool support_dc6(int debugfs_fd)
>  	return strstr(buf, "DC5 -> DC6 count");  }
> 
> -static bool check_dc9(uint32_t debugfs_fd, int prev_dc, bool dc6_supported,
> int seconds)
> +static bool dc9_wait_entry(uint32_t debugfs_fd, int dc_target, int
> +prev_dc, int seconds)
>  {
>  	/*
>  	 * since we do not have DC9 counter,
>  	 * so we rely on dc5/dc6 counter reset to check if display engine was in
> DC9.
>  	 */
> -	return igt_wait(dc6_supported ? read_dc_counter(debugfs_fd,
> CHECK_DC6) <
> -			prev_dc : read_dc_counter(debugfs_fd, CHECK_DC5) <
> +	return igt_wait(read_dc_counter(debugfs_fd, dc_target) >
>  			prev_dc, seconds, 100);
>  }
> 
> -static void setup_dc9_dpms(data_t *data, int prev_dc, bool dc6_supported)
> +static void check_dc9(data_t *data, int dc_target, int prev_dc)
>  {
> +	igt_assert_f(dc9_wait_entry(data->debugfs_fd, dc_target, prev_dc,
> 3000),
> +			"DC9 state is not achieved\n%s:\n%s\n", RPM_STATUS,
> +			data->debugfs_dump = igt_sysfs_get(data-
> >debugfs_fd, RPM_STATUS)); }
> +
> +static void setup_dc9_dpms(data_t *data, int dc_target) {
> +	int prev_dc, sysfs_fd;
> +
> +	igt_require((sysfs_fd = open(KMS_POLL_PATH, O_WRONLY)) >= 0);
	This file is being opened for read/write , so open flag should be O_RDWR.
	Br,
	Anshuman Gupta.
> +	kms_poll_saved_state = igt_sysfs_get_boolean(sysfs_fd,
> KMS_POLL_PATH);
> +	igt_sysfs_set_boolean(sysfs_fd, KMS_POLL_PATH,
> KMS_POLL_DISABLE);
> +	close(sysfs_fd);
> +	prev_dc = read_dc_counter(data->debugfs_fd, dc_target);
>  	setup_dc_dpms(data);
>  	dpms_off(data);
> -	igt_skip_on_f(!(igt_wait(dc6_supported ? read_dc_counter(data-
> >debugfs_fd, CHECK_DC6) >
> -				prev_dc : read_dc_counter(data->debugfs_fd,
> CHECK_DC5) >
> +	igt_skip_on_f(!(igt_wait(read_dc_counter(data->debugfs_fd, dc_target)
> +>
>  				prev_dc, 3000, 100)), "Unable to enters shallow
> DC states\n");
>  	dpms_on(data);
>  	cleanup_dc_dpms(data);
> @@ -417,20 +434,28 @@ static void setup_dc9_dpms(data_t *data, int
> prev_dc, bool dc6_supported)
> 
>  static void test_dc9_dpms(data_t *data)  {
> -	bool dc6_supported;
> +	int prev_dc, dc_target;
> 
>  	require_dc_counter(data->debugfs_fd, CHECK_DC5);
> -	dc6_supported = support_dc6(data->debugfs_fd);
> -	setup_dc9_dpms(data, dc6_supported ? read_dc_counter(data-
> >debugfs_fd, CHECK_DC6) :
> -			read_dc_counter(data->debugfs_fd, CHECK_DC5),
> dc6_supported);
> +	dc_target = support_dc6(data->debugfs_fd) ? CHECK_DC6 :
> CHECK_DC5;
> +	setup_dc9_dpms(data, dc_target);
> +	prev_dc = read_dc_counter(data->debugfs_fd, dc_target);
>  	dpms_off(data);
> -	igt_assert_f(check_dc9(data->debugfs_fd, dc6_supported ?
> -				read_dc_counter(data->debugfs_fd,
> CHECK_DC6) :
> -				read_dc_counter(data->debugfs_fd,
> CHECK_DC5),
> -				dc6_supported, 3000), "Not in DC9\n");
> +	check_dc9(data, dc_target, prev_dc);
>  	dpms_on(data);
>  }
> 
> +static void kms_poll_state_restore(int sig) {
> +	int sysfs_fd;
> +
> +	sysfs_fd = open(KMS_POLL_PATH, O_WRONLY);
> +	if (sysfs_fd >= 0) {
> +		igt_sysfs_set_boolean(sysfs_fd, KMS_POLL_PATH,
> kms_poll_saved_state);
> +		close(sysfs_fd);
> +	}
> +}
> +
>  IGT_TEST_DESCRIPTION("These tests validate Display Power DC states");  int
> main(int argc, char *argv[])  { @@ -453,6 +478,7 @@ int main(int argc, char
> *argv[])
>  		data.msr_fd = open("/dev/cpu/0/msr", O_RDONLY);
>  		igt_assert_f(data.msr_fd >= 0,
>  			     "Can't open /dev/cpu/0/msr.\n");
> +		igt_install_exit_handler(kms_poll_state_restore);
>  	}
> 
>  	igt_describe("In this test we make sure that system enters DC3CO "
> --
> 2.25.1


  reply	other threads:[~2021-09-24  9:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24  8:22 [igt-dev] [PATCH i-g-t v5 0/2] tests/i915/i915_pm_dc: Refactoring pwr_dmn_info to debugfs_dump and fix DC9-dpms test Jigar Bhatt
2021-09-24  8:22 ` [igt-dev] [PATCH i-g-t v5 1/2] tests/i915/i915_pm_dc: Refactoring pwr_dmn_info to debugfs_dump Jigar Bhatt
2021-09-24  8:22 ` [igt-dev] [PATCH i-g-t v5 2/2] tests/i915/i915_pm_dc: Fix DC9 test Jigar Bhatt
2021-09-24  9:44   ` Gupta, Anshuman [this message]
2021-09-24  9:11 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/i915/i915_pm_dc: Refactoring pwr_dmn_info to debugfs_dump and fix DC9-dpms test Patchwork
2021-09-24 10:40 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2021-09-23 12:38 [igt-dev] [PATCH i-g-t v4 0/2] tests/i915/i915_pm_dc: Refactoring pwr_dmn_info to debugfs_dump and fix DC9 test Jigar Bhatt
2021-09-24  8:14 ` [igt-dev] [PATCH i-g-t v5 " Jigar Bhatt
2021-09-24  8:14   ` [igt-dev] [PATCH i-g-t v5 2/2] tests/i915/i915_pm_dc: Fix " Jigar Bhatt

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=3b2c72a7d5694100bcd84f674d94fb3d@intel.com \
    --to=anshuman.gupta@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jigar.bhatt@intel.com \
    --cc=nischal.varide@intel.com \
    --cc=swati2.sharma@intel.com \
    --cc=uma.shankar@intel.com \
    /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