* [PATCH i-g-t v2] lib/igt_sysfs: Let igt_sysfs_read|write return -errno
@ 2017-12-07 16:52 Michal Wajdeczko
2017-12-07 16:59 ` Chris Wilson
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Michal Wajdeczko @ 2017-12-07 16:52 UTC (permalink / raw)
To: intel-gfx
In some cases debugfs or sysfs may return errors that we
want to check. Return -errno from helper functions to make
asserts easier.
v2: don't forget about EOF ret=0 (Chris)
small re-write (Michal)
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
lib/igt_sysfs.c | 44 +++++++++++++++++++++-----------------------
1 file changed, 21 insertions(+), 23 deletions(-)
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index e7c67da..842a136 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -54,36 +54,34 @@
static int readN(int fd, char *buf, int len)
{
- int total = 0;
+ int ret, total = 0;
do {
- int ret = read(fd, buf + total, len - total);
- if (ret < 0 && (errno == EINTR || errno == EAGAIN))
+ ret = read(fd, buf + total, len - total);
+ if (ret < 0)
+ ret = -errno;
+ if (ret == -EINTR || ret == -EAGAIN)
continue;
-
if (ret <= 0)
- return total ?: ret;
-
+ break;
total += ret;
- if (total == len)
- return total;
- } while (1);
+ } while (total != len);
+ return total ?: ret;
}
static int writeN(int fd, const char *buf, int len)
{
- int total = 0;
+ int ret, total = 0;
do {
- int ret = write(fd, buf + total, len - total);
- if (ret < 0 && (errno == EINTR || errno == EAGAIN))
+ ret = write(fd, buf + total, len - total);
+ if (ret < 0)
+ ret = -errno;
+ if (ret == -EINTR || ret == -EAGAIN)
continue;
-
if (ret <= 0)
- return total ?: ret;
-
+ break;
total += ret;
- if (total == len)
- return total;
- } while (1);
+ } while (total != len);
+ return total ?: ret;
}
/**
@@ -238,7 +236,7 @@ int igt_sysfs_open_parameters(int device)
* This writes @len bytes from @data to the sysfs file.
*
* Returns:
- * The number of bytes written, or -1 on error.
+ * The number of bytes written, or -errno on error.
*/
int igt_sysfs_write(int dir, const char *attr, const void *data, int len)
{
@@ -246,7 +244,7 @@ int igt_sysfs_write(int dir, const char *attr, const void *data, int len)
fd = openat(dir, attr, O_WRONLY);
if (fd < 0)
- return false;
+ return -errno;
len = writeN(fd, data, len);
close(fd);
@@ -264,7 +262,7 @@ int igt_sysfs_write(int dir, const char *attr, const void *data, int len)
* This reads @len bytes from the sysfs file to @data
*
* Returns:
- * The length read, -1 on failure.
+ * The length read, -errno on failure.
*/
int igt_sysfs_read(int dir, const char *attr, void *data, int len)
{
@@ -272,7 +270,7 @@ int igt_sysfs_read(int dir, const char *attr, void *data, int len)
fd = openat(dir, attr, O_RDONLY);
if (fd < 0)
- return false;
+ return -errno;
len = readN(fd, data, len);
close(fd);
@@ -338,7 +336,7 @@ char *igt_sysfs_get(int dir, const char *attr)
rem = len - offset - 1;
}
- if (ret != -1)
+ if (ret > 0)
offset += ret;
buf[offset] = '\0';
while (offset > 0 && buf[offset-1] == '\n')
--
2.7.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH i-g-t v2] lib/igt_sysfs: Let igt_sysfs_read|write return -errno
2017-12-07 16:52 [PATCH i-g-t v2] lib/igt_sysfs: Let igt_sysfs_read|write return -errno Michal Wajdeczko
@ 2017-12-07 16:59 ` Chris Wilson
2017-12-07 21:00 ` Daniel Vetter
2017-12-15 11:28 ` Chris Wilson
2017-12-07 19:26 ` ✓ Fi.CI.BAT: success for lib/igt_sysfs: Let igt_sysfs_read|write return -errno (rev2) Patchwork
2017-12-07 23:00 ` ✗ Fi.CI.IGT: failure " Patchwork
2 siblings, 2 replies; 7+ messages in thread
From: Chris Wilson @ 2017-12-07 16:59 UTC (permalink / raw)
To: Michal Wajdeczko, intel-gfx
Quoting Michal Wajdeczko (2017-12-07 16:52:46)
> In some cases debugfs or sysfs may return errors that we
> want to check. Return -errno from helper functions to make
> asserts easier.
>
> v2: don't forget about EOF ret=0 (Chris)
> small re-write (Michal)
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Just tests/drv_hangman.c needs to fixed to use
igt_require(sysfs >= 0);
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH i-g-t v2] lib/igt_sysfs: Let igt_sysfs_read|write return -errno
2017-12-07 16:59 ` Chris Wilson
@ 2017-12-07 21:00 ` Daniel Vetter
2017-12-13 14:16 ` Michal Wajdeczko
2017-12-15 11:28 ` Chris Wilson
1 sibling, 1 reply; 7+ messages in thread
From: Daniel Vetter @ 2017-12-07 21:00 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
On Thu, Dec 07, 2017 at 04:59:36PM +0000, Chris Wilson wrote:
> Quoting Michal Wajdeczko (2017-12-07 16:52:46)
> > In some cases debugfs or sysfs may return errors that we
> > want to check. Return -errno from helper functions to make
> > asserts easier.
> >
> > v2: don't forget about EOF ret=0 (Chris)
> > small re-write (Michal)
> >
> > Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>
> Just tests/drv_hangman.c needs to fixed to use
> igt_require(sysfs >= 0);
Isn't the usual igt pattern that igt_foo never fails, and __igt_foo gives
you the error code? But I guess we can do that later on in follow-ups.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH i-g-t v2] lib/igt_sysfs: Let igt_sysfs_read|write return -errno
2017-12-07 21:00 ` Daniel Vetter
@ 2017-12-13 14:16 ` Michal Wajdeczko
0 siblings, 0 replies; 7+ messages in thread
From: Michal Wajdeczko @ 2017-12-13 14:16 UTC (permalink / raw)
To: Chris Wilson, Daniel Vetter; +Cc: intel-gfx
On Thu, 07 Dec 2017 22:00:48 +0100, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Thu, Dec 07, 2017 at 04:59:36PM +0000, Chris Wilson wrote:
>> Quoting Michal Wajdeczko (2017-12-07 16:52:46)
>> > In some cases debugfs or sysfs may return errors that we
>> > want to check. Return -errno from helper functions to make
>> > asserts easier.
>> >
>> > v2: don't forget about EOF ret=0 (Chris)
>> > small re-write (Michal)
>> >
>> > Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>>
>> Just tests/drv_hangman.c needs to fixed to use
>> igt_require(sysfs >= 0);
>
> Isn't the usual igt pattern that igt_foo never fails, and __igt_foo gives
> you the error code? But I guess we can do that later on in follow-ups.
I'm not sure that this pattern is applicable here as igt_sysfs_read() was
already returning some data or error indicator. The only change is that
now we return len/-errno (instead len/-1)
Michal
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH i-g-t v2] lib/igt_sysfs: Let igt_sysfs_read|write return -errno
2017-12-07 16:59 ` Chris Wilson
2017-12-07 21:00 ` Daniel Vetter
@ 2017-12-15 11:28 ` Chris Wilson
1 sibling, 0 replies; 7+ messages in thread
From: Chris Wilson @ 2017-12-15 11:28 UTC (permalink / raw)
To: Michal Wajdeczko, intel-gfx
Quoting Chris Wilson (2017-12-07 16:59:36)
> Quoting Michal Wajdeczko (2017-12-07 16:52:46)
> > In some cases debugfs or sysfs may return errors that we
> > want to check. Return -errno from helper functions to make
> > asserts easier.
> >
> > v2: don't forget about EOF ret=0 (Chris)
> > small re-write (Michal)
> >
> > Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
And pushed.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* ✓ Fi.CI.BAT: success for lib/igt_sysfs: Let igt_sysfs_read|write return -errno (rev2)
2017-12-07 16:52 [PATCH i-g-t v2] lib/igt_sysfs: Let igt_sysfs_read|write return -errno Michal Wajdeczko
2017-12-07 16:59 ` Chris Wilson
@ 2017-12-07 19:26 ` Patchwork
2017-12-07 23:00 ` ✗ Fi.CI.IGT: failure " Patchwork
2 siblings, 0 replies; 7+ messages in thread
From: Patchwork @ 2017-12-07 19:26 UTC (permalink / raw)
To: Michal Wajdeczko; +Cc: intel-gfx
== Series Details ==
Series: lib/igt_sysfs: Let igt_sysfs_read|write return -errno (rev2)
URL : https://patchwork.freedesktop.org/series/34989/
State : success
== Summary ==
IGT patchset tested on top of latest successful build
2fc64acf8a4465d5eab3d6cfec9b3c1b5df30d73 igt/perf_pmu: Tweak wait_for_rc6, yet again
with latest DRM-Tip kernel build CI_DRM_3476
fb6aa7cd0d6b drm-tip: 2017y-12m-07d-17h-43m-29s UTC integration manifest
No testlist changes.
Test debugfs_test:
Subgroup read_all_entries:
dmesg-fail -> DMESG-WARN (fi-elk-e7500) fdo#103989
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
pass -> INCOMPLETE (fi-snb-2520m) fdo#103713
fdo#103989 https://bugs.freedesktop.org/show_bug.cgi?id=103989
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fi-bdw-5557u total:288 pass:267 dwarn:0 dfail:0 fail:0 skip:21 time:444s
fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:386s
fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:521s
fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:283s
fi-bxt-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:510s
fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:508s
fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:490s
fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:476s
fi-elk-e7500 total:224 pass:163 dwarn:15 dfail:0 fail:0 skip:45
fi-gdg-551 total:288 pass:178 dwarn:1 dfail:0 fail:1 skip:108 time:272s
fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:542s
fi-hsw-4770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:360s
fi-hsw-4770r total:288 pass:224 dwarn:0 dfail:0 fail:0 skip:64 time:269s
fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:395s
fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:485s
fi-ivb-3770 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:454s
fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:491s
fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:527s
fi-kbl-7567u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:481s
fi-kbl-r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:532s
fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:588s
fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:456s
fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:547s
fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:572s
fi-skl-6700k total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:523s
fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:499s
fi-skl-gvtdvm total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:449s
fi-snb-2520m total:245 pass:211 dwarn:0 dfail:0 fail:0 skip:33
fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:417s
Blacklisted hosts:
fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:614s
fi-cnl-y total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:655s
fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:494s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_617/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread* ✗ Fi.CI.IGT: failure for lib/igt_sysfs: Let igt_sysfs_read|write return -errno (rev2)
2017-12-07 16:52 [PATCH i-g-t v2] lib/igt_sysfs: Let igt_sysfs_read|write return -errno Michal Wajdeczko
2017-12-07 16:59 ` Chris Wilson
2017-12-07 19:26 ` ✓ Fi.CI.BAT: success for lib/igt_sysfs: Let igt_sysfs_read|write return -errno (rev2) Patchwork
@ 2017-12-07 23:00 ` Patchwork
2 siblings, 0 replies; 7+ messages in thread
From: Patchwork @ 2017-12-07 23:00 UTC (permalink / raw)
To: Michal Wajdeczko; +Cc: intel-gfx
== Series Details ==
Series: lib/igt_sysfs: Let igt_sysfs_read|write return -errno (rev2)
URL : https://patchwork.freedesktop.org/series/34989/
State : failure
== Summary ==
Test kms_pipe_crc_basic:
Subgroup read-crc-pipe-b:
incomplete -> PASS (shard-hsw)
Test prime_mmap_coherency:
Subgroup read:
pass -> INCOMPLETE (shard-hsw)
Test kms_flip:
Subgroup flip-vs-panning:
incomplete -> PASS (shard-hsw)
Subgroup flip-vs-modeset-vs-hang:
pass -> DMESG-WARN (shard-snb)
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-offscren-pri-shrfb-draw-blt:
fail -> PASS (shard-snb) fdo#101623 +1
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
shard-hsw total:2670 pass:1533 dwarn:1 dfail:0 fail:9 skip:1126 time:9238s
shard-snb total:2679 pass:1306 dwarn:2 dfail:0 fail:13 skip:1358 time:8164s
Blacklisted hosts:
shard-apl total:2679 pass:1679 dwarn:1 dfail:0 fail:22 skip:977 time:13738s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_617/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-12-15 11:28 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-07 16:52 [PATCH i-g-t v2] lib/igt_sysfs: Let igt_sysfs_read|write return -errno Michal Wajdeczko
2017-12-07 16:59 ` Chris Wilson
2017-12-07 21:00 ` Daniel Vetter
2017-12-13 14:16 ` Michal Wajdeczko
2017-12-15 11:28 ` Chris Wilson
2017-12-07 19:26 ` ✓ Fi.CI.BAT: success for lib/igt_sysfs: Let igt_sysfs_read|write return -errno (rev2) Patchwork
2017-12-07 23:00 ` ✗ Fi.CI.IGT: failure " Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox