All of lore.kernel.org
 help / color / mirror / Atom feed
From: "José Roberto de Souza" <jose.souza@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Jeevan B <jeevan.b@intel.com>
Subject: [igt-dev] [PATCH i-g-t 2/2] tests/i915_pm_dc: Reuse the debugfs fd instead of opening and closing one each time
Date: Tue,  5 Nov 2019 10:17:38 -0800	[thread overview]
Message-ID: <20191105181738.6700-2-jose.souza@intel.com> (raw)
In-Reply-To: <20191105181738.6700-1-jose.souza@intel.com>

Each call to igt_debugfs_read() opens a file descriptor to debugfs,
calls igt_debugfs_simple_read() and then closes it.
So lets stop this waste of time and reuse the debugfs file descriptor
that we already have.

Cc: Jeevan B <jeevan.b@intel.com>
Cc: Anshuman Gupta <anshuman.gupta@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 tests/i915/i915_pm_dc.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/tests/i915/i915_pm_dc.c b/tests/i915/i915_pm_dc.c
index cce70a57..f7a3896b 100644
--- a/tests/i915/i915_pm_dc.c
+++ b/tests/i915/i915_pm_dc.c
@@ -196,12 +196,12 @@ static uint32_t get_dc_counter(char *dc_data)
 	return ret;
 }
 
-static uint32_t read_dc_counter(uint32_t drm_fd, int dc_flag)
+static uint32_t read_dc_counter(uint32_t debugfs_fd, int dc_flag)
 {
 	char buf[4096];
 	char *str;
 
-	igt_debugfs_read(drm_fd, "i915_dmc_info", buf);
+	igt_debugfs_simple_read(debugfs_fd, "i915_dmc_info", buf, sizeof(buf));
 
 	if (dc_flag & CHECK_DC5) {
 		str = strstr(buf, "DC3 -> DC5 count");
@@ -217,19 +217,19 @@ static uint32_t read_dc_counter(uint32_t drm_fd, int dc_flag)
 	return get_dc_counter(str);
 }
 
-static bool dc_state_wait_entry(int drm_fd, int dc_flag, int prev_dc_count)
+static bool dc_state_wait_entry(int debugfs_fd, int dc_flag, int prev_dc_count)
 {
-	return igt_wait(read_dc_counter(drm_fd, dc_flag) >
+	return igt_wait(read_dc_counter(debugfs_fd, dc_flag) >
 			prev_dc_count, 3000, 100);
 }
 
-static void check_dc_counter(int drm_fd, int dc_flag, uint32_t prev_dc_count)
+static void check_dc_counter(int debugfs_fd, int dc_flag, uint32_t prev_dc_count)
 {
 	char tmp[64];
 
 	snprintf(tmp, sizeof(tmp), "%s", dc_flag & CHECK_DC3CO ? "DC3CO" :
 		(dc_flag & CHECK_DC5 ? "DC5" : "DC6"));
-	igt_assert_f(dc_state_wait_entry(drm_fd, dc_flag, prev_dc_count),
+	igt_assert_f(dc_state_wait_entry(debugfs_fd, dc_flag, prev_dc_count),
 		     "%s state is not achieved\n", tmp);
 }
 
@@ -261,7 +261,8 @@ static void check_dc3co_with_videoplayback_like_load(data_t *data)
 	primary = igt_output_get_plane_type(data->output,
 					    DRM_PLANE_TYPE_PRIMARY);
 	igt_plane_set_fb(primary, NULL);
-	dc3co_prev_cnt = read_dc_counter(data->drm_fd, CHECK_DC3CO);
+	dc3co_prev_cnt = read_dc_counter(data->debugfs_fd, CHECK_DC3CO);
+
 	/* Calculate delay to generate idle frame in usec*/
 	delay = 1.5 * ((1000 * 1000) / data->mode->vrefresh);
 
@@ -275,7 +276,7 @@ static void check_dc3co_with_videoplayback_like_load(data_t *data)
 		usleep(delay);
 	}
 
-	check_dc_counter(data->drm_fd, CHECK_DC3CO, dc3co_prev_cnt);
+	check_dc_counter(data->debugfs_fd, CHECK_DC3CO, dc3co_prev_cnt);
 }
 
 static void require_dc_counter(int debugfs_fd, int dc_flag)
@@ -326,11 +327,11 @@ static void test_dc_state_psr(data_t *data, int dc_flag)
 	uint32_t dc_counter_before_psr;
 
 	require_dc_counter(data->debugfs_fd, dc_flag);
-	dc_counter_before_psr = read_dc_counter(data->drm_fd, dc_flag);
+	dc_counter_before_psr = read_dc_counter(data->debugfs_fd, dc_flag);
 	setup_output(data);
 	setup_primary(data);
 	igt_assert(psr_wait_entry(data->debugfs_fd, data->op_psr_mode));
-	check_dc_counter(data->drm_fd, dc_flag, dc_counter_before_psr);
+	check_dc_counter(data->debugfs_fd, dc_flag, dc_counter_before_psr);
 	cleanup_dc_psr(data);
 }
 
@@ -389,9 +390,9 @@ static void test_dc_state_dpms(data_t *data, int dc_flag)
 
 	require_dc_counter(data->debugfs_fd, dc_flag);
 	setup_dc_dpms(data);
-	dc_counter = read_dc_counter(data->drm_fd, dc_flag);
+	dc_counter = read_dc_counter(data->debugfs_fd, dc_flag);
 	dpms_off(data);
-	check_dc_counter(data->drm_fd, dc_flag, dc_counter);
+	check_dc_counter(data->debugfs_fd, dc_flag, dc_counter);
 	dpms_on(data);
 	cleanup_dc_dpms(data);
 }
-- 
2.24.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-11-05 18:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 18:17 [igt-dev] [PATCH i-g-t 1/2] tests/i915_pm_dc: Fix the requirement check José Roberto de Souza
2019-11-05 18:17 ` José Roberto de Souza [this message]
2019-11-05 19:13 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] " Patchwork
2019-11-06 14:10 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-11-08  7:53 ` [igt-dev] [PATCH i-g-t 1/2] " Arkadiusz Hiler

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=20191105181738.6700-2-jose.souza@intel.com \
    --to=jose.souza@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jeevan.b@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 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.