lib/igt_sysfs: Let igt_sysfs_read|write return -errno
PATCH v2 1/1 lib/igt_sysfs: Let igt_sysfs_read|write return -errno
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)
--- lib/igt_sysfs.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-)
lib/igt_sysfs.c +21 -23
@@ -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' )
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Michal Wajdeczko (2017-12-07 16:52:46)
Quoted 10 lines
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 <[email protected]>Cc Chris Wilson <[email protected]>Cc Joonas Lahtinen <[email protected]>
Just tests/drv_hangman.c needs to fixed to useigt_require(sysfs >= 0);
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 8 lines · Chris Wilson
Quoting Michal Wajdeczko (2017-12-07 16:52:46)
Quoted 7 lines
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)
Quoted 7 lines
Quoted 3 lines
Signed-off-by Michal Wajdeczko <[email protected]>Cc Chris Wilson <[email protected]>Cc Joonas Lahtinen <[email protected]>Reviewed-by Chris Wilson <[email protected]>Just
tests/drv_hangman.cneeds to fixed to useigt_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
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 12 lines · Daniel Vetter
Quoted 11 lines · Chris Wilson
Quoting Michal Wajdeczko (2017-12-07 16:52:46)
Quoted 10 lines
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 <[email protected]>Cc Chris Wilson <[email protected]>Cc Joonas Lahtinen <[email protected]>
Quoted 7 lines
Quoted 4 lines
Reviewed-by Chris Wilson <[email protected]>Just
tests/drv_hangman.cneeds to fixed to useigt_require(sysfs >= 0);Isn't the usual igt pattern that
igt_foonever fails, and__igt_foogives 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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Chris Wilson (2017-12-07 16:59:36)
Quoted 5 lines
Quoting Michal Wajdeczko (2017-12-07 16:52:46)
Quoted 4 lines
In some cases debugfs or sysfs may return errors that we want to check. Return -errno from helper functions to make asserts easier.
Quoted 7 lines
Quoted 6 lines
v2: don't forget about EOF ret=0 (Chris)
small re-write (Michal)Signed-off-by Michal Wajdeczko <[email protected]>Cc Chris Wilson <[email protected]>Cc Joonas Lahtinen <[email protected]>Reviewed-by Chris Wilson <[email protected]>
And pushed.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for lib/igt_sysfs: Let igt_sysfs_read|write return -errno (rev2)
In reply to Michal Wajdeczko== Series Details ==
== 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_3476fb6aa7cd0d6b 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#103713fdo#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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.IGT: failure for lib/igt_sysfs: Let igt_sysfs_read|write return -errno (rev2)
In reply to Michal Wajdeczko== Series Details ==
== 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 +1fdo#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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx