public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: jeff.mcgee@intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 1/4] pm_rps: Use unbuffered I/O on sysfs files
Date: Fri, 10 Jan 2014 15:12:30 -0600	[thread overview]
Message-ID: <1389388353-29980-2-git-send-email-jeff.mcgee@intel.com> (raw)
In-Reply-To: <1389388353-29980-1-git-send-email-jeff.mcgee@intel.com>

From: Jeff McGee <jeff.mcgee@intel.com>

Bionic C library may not re-read a buffered, read-only file which
results in failure to monitor changes in gt_cur_freq_mhz.

Signed-off-by: Jeff McGee <jeff.mcgee@intel.com>
---
 tests/pm_rps.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tests/pm_rps.c b/tests/pm_rps.c
index e8affdb..9123451 100644
--- a/tests/pm_rps.c
+++ b/tests/pm_rps.c
@@ -22,6 +22,7 @@
  *
  * Authors:
  *    Ben Widawsky <ben@bwidawsk.net>
+ *    Jeff McGee <jeff.mcgee@intel.com>
  *
  */
 
@@ -66,7 +67,6 @@ static int readval(FILE *filp)
 	int val;
 	int scanned;
 
-	fflush(filp);
 	rewind(filp);
 	scanned = fscanf(filp, "%d", &val);
 	igt_assert(scanned == 1);
@@ -76,15 +76,11 @@ static int readval(FILE *filp)
 
 static int do_writeval(FILE *filp, int val, int lerrno)
 {
-	/* Must write twice to sysfs since the first one simply calculates the size and won't return the error */
 	int ret;
 	rewind(filp);
 	ret = fprintf(filp, "%d", val);
-	rewind(filp);
-	ret = fprintf(filp, "%d", val);
 	if (ret && lerrno)
 		igt_assert(errno = lerrno);
-	fflush(filp);
 	return ret;
 }
 #define writeval(filp, val) do_writeval(filp, val, 0)
@@ -146,6 +142,7 @@ igt_simple_main
 		igt_assert(ret != -1);
 		junk->filp = fopen(path, junk->mode);
 		igt_require(junk->filp);
+		setbuf(junk->filp, NULL);
 
 		val = readval(junk->filp);
 		igt_assert(val >= 0);
-- 
1.8.5.2

  reply	other threads:[~2014-01-10 21:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-10 21:12 Various fixes and updates to igt/pm_rps jeff.mcgee
2014-01-10 21:12 ` jeff.mcgee [this message]
2014-01-10 21:12 ` [PATCH 2/4] pm_rps: Assert that valid sysfs writes return success jeff.mcgee
2014-01-10 21:12 ` [PATCH 3/4] pm_rps: Fix test to target original min and max jeff.mcgee
2014-01-10 21:12 ` [PATCH 4/4] pm_rps: Use igt exit handler for restore jeff.mcgee
2014-01-10 21:33 ` Various fixes and updates to igt/pm_rps Daniel Vetter

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=1389388353-29980-2-git-send-email-jeff.mcgee@intel.com \
    --to=jeff.mcgee@intel.com \
    --cc=intel-gfx@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