Message ID | 20190111103510.20564-1-chris@chris-wilson.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [i-g-t] i915/hangman: Read a dummy byte to check sysfs existence | expand |
On 11/01/2019 10:35, Chris Wilson wrote: > sysfs doesn't give the driver an open() callback, so we can only report > the unavailability of HW on the first read; so check read() after checking > open(). > > Fixes: 93f0ad4b835e ("i915/hangman: Skip if disabled by the kernel") > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > --- > tests/i915/hangman.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/tests/i915/hangman.c b/tests/i915/hangman.c > index ffbd0b057..5f63bfc4b 100644 > --- a/tests/i915/hangman.c > +++ b/tests/i915/hangman.c > @@ -45,14 +45,20 @@ static int sysfs = -1; > > static bool has_error_state(int dir) > { > + bool result; > int fd; > > fd = openat(dir, "error", O_RDONLY); > if (fd < 0) > return false; > > + if (read(fd, &result, sizeof(result)) < 0) > + result = false; > + else > + result = true; > + > close(fd); > - return true; > + return result; > } > > static void assert_entry(const char *s, bool expect) > Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Regards, Tvrtko
diff --git a/tests/i915/hangman.c b/tests/i915/hangman.c index ffbd0b057..5f63bfc4b 100644 --- a/tests/i915/hangman.c +++ b/tests/i915/hangman.c @@ -45,14 +45,20 @@ static int sysfs = -1; static bool has_error_state(int dir) { + bool result; int fd; fd = openat(dir, "error", O_RDONLY); if (fd < 0) return false; + if (read(fd, &result, sizeof(result)) < 0) + result = false; + else + result = true; + close(fd); - return true; + return result; } static void assert_entry(const char *s, bool expect)
sysfs doesn't give the driver an open() callback, so we can only report the unavailability of HW on the first read; so check read() after checking open(). Fixes: 93f0ad4b835e ("i915/hangman: Skip if disabled by the kernel") Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> --- tests/i915/hangman.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)