Skip to contentSkip to conversation

lib/igt_kms: Fix igt_display_drop_events() to work as intended

PATCH In review Maarten Lankhorst 3 participants 5 messages Feb 15, 2018 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/igt_kms: Fix igt_display_drop_events() to work as intended

Short reads don't work, you either read the whole event or nothing at all, so follow the recommendations in the documentation and allocate a buffer of 4096 bytes for the event, if we capture multiple events read them all.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104538

---
 lib/igt_kms.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
lib/igt_kms.c +12 -8
index 11f23fcaaa81..5a5df61c5856 100644
@@ -3228,14 +3228,18 @@ int igt_display_drop_events(igt_display_t *display)
 	};
 
 	while (poll(&pfd, 1, 0) > 0) {
-		struct drm_event ev;
-		char buf[128];
-
-		read(display->drm_fd, &ev, sizeof(ev));
-		igt_info("Dropping event type %u length %u\n", ev.type, ev.length);
-		igt_assert(ev.length <= sizeof(buf));
-		read(display->drm_fd, buf, ev.length);
-		ret++;
+		char buf[4096];
+		ssize_t retval;
+		struct drm_event *ev = (struct drm_event *)buf;
+
+		retval = read(display->drm_fd, &buf, sizeof(buf));
+		igt_assert_lt(0, retval);
+
+		for (int i = 0; i < retval; i += ev->length, ev = (struct drm_event *)&buf[i]) {
+			igt_info("Dropping event type %u length %u\n", ev->type, ev->length);
+			igt_assert(ev->length + i <= sizeof(buf));
+			ret++;
+		}
 	}
 
 	return ret;
Signature · 6 lines
2.16.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Reviewed-by on v1 1/1
#1 lore raw

Quoting Maarten Lankhorst (2018-02-15 11:49:17)

Quoted 18 lines

Short reads don't work, you either read the whole event or nothing at all, so follow the recommendations in the documentation and allocate a buffer of 4096 bytes for the event, if we capture multiple events read them all.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104538

---
 lib/igt_kms.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
lib/igt_kms.c +0 -0
index 11f23fcaaa81..5a5df61c5856 100644

lib/igt_kms.c int igt_display_drop_events(igt_display_t *display) · line 3237

Quoted 10 lines
lib/igt_kms.c +0 -7
@@ -3228,14 +3228,18 @@ int igt_display_drop_events(igt_display_t *display)
        };
 
        while (poll(&pfd, 1, 0) > 0) {
-               struct drm_event ev;
-               char buf[128];
-
-               read(display->drm_fd, &ev, sizeof(ev));
-               igt_info("Dropping event type %u length %u\n", ev.type, ev.length);
-               igt_assert(ev.length <= sizeof(buf));
-               read(display->drm_fd, buf, ev.length);

Fwiw ^ that was the bug.

lib/igt_kms.c int igt_display_drop_events(igt_display_t *display) · line 3238

Quoted 9 lines
lib/igt_kms.c +8 -1
-               ret++;
+               char buf[4096];
+               ssize_t retval;
+               struct drm_event *ev = (struct drm_event *)buf;
+
+               retval = read(display->drm_fd, &buf, sizeof(buf));
+               igt_assert_lt(0, retval);
+
+               for (int i = 0; i < retval; i += ev->length, ev = (struct drm_event *)&buf[i]) {

struct drm_event *ev = (struct drm_event *)(buf +i);

gets rid of the other two struct drm_event ev assignments

-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#2 lore raw

Op 15-02-18 om 13:03 schreef Chris Wilson:

Quoted 42 lines

Quoting Maarten Lankhorst (2018-02-15 11:49:17)

Quoted 18 lines

Short reads don't work, you either read the whole event or nothing at all, so follow the recommendations in the documentation and allocate a buffer of 4096 bytes for the event, if we capture multiple events read them all.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104538

---
 lib/igt_kms.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
lib/igt_kms.c +0 -0
index 11f23fcaaa81..5a5df61c5856 100644

lib/igt_kms.c int igt_display_drop_events(igt_display_t *display) · line 3237

Quoted 10 lines
lib/igt_kms.c +0 -7
@@ -3228,14 +3228,18 @@ int igt_display_drop_events(igt_display_t *display)
        };
 
        while (poll(&pfd, 1, 0) > 0) {
-               struct drm_event ev;
-               char buf[128];
-
-               read(display->drm_fd, &ev, sizeof(ev));
-               igt_info("Dropping event type %u length %u\n", ev.type, ev.length);
-               igt_assert(ev.length <= sizeof(buf));
-               read(display->drm_fd, buf, ev.length);

Fwiw ^ that was the bug.

lib/igt_kms.c int igt_display_drop_events(igt_display_t *display) · line 3238

Quoted 9 lines
lib/igt_kms.c +8 -1
-               ret++;
+               char buf[4096];
+               ssize_t retval;
+               struct drm_event *ev = (struct drm_event *)buf;
+
+               retval = read(display->drm_fd, &buf, sizeof(buf));
+               igt_assert_lt(0, retval);
+
+               for (int i = 0; i < retval; i += ev->length, ev = (struct drm_event *)&buf[i]) {

struct drm_event *ev = (struct drm_event *)(buf +i);

Quoted 4 lines

gets rid of the other two struct drm_event ev assignments

-Chris

Pushed with that change, thanks.

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for lib/igt_kms: Fix igt_display_drop_events() to work as intended

In reply to Maarten Lankhorst
== Series Details ==

== Series Details ==

Series: lib/igt_kms: Fix igt_display_drop_events() to work as intended
URL : https://patchwork.freedesktop.org/series/38353/
State : success

== Summary ==

IGT patchset tested on top of latest successful build 0a700e095b2a47e99081b7bffce1e737863e0136 igt/gem_exec_fence: Test that the in-fence is not overwritten

with latest DRM-Tip kernel build CI_DRM_3777
bd16af128e78 drm-tip: 2018y-02m-15d-00h-22m-40s UTC integration manifest

No testlist changes.

Test prime_vgem:

        Subgroup basic-fence-flip:
                pass       -> FAIL       (fi-ilk-650) fdo#104008

fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:419s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:427s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:375s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:494s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:288s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:481s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:488s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:475s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:463s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:582s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:419s
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:285s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:514s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:396s
fi-ilk-650       total:288  pass:227  dwarn:0   dfail:0   fail:1   skip:60  time:415s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:460s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:459s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:496s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:452s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:501s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:592s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:429s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:507s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:526s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:495s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:484s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:418s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:433s
fi-snb-2520m     total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:527s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:402s

Blacklisted hosts:
fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:476s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_924/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#4 lore raw

[igt-dev] ✗ Fi.CI.IGT: failure for lib/igt_kms: Fix igt_display_drop_events() to work as intended

In reply to Maarten Lankhorst
== Series Details ==

== Series Details ==

Series: lib/igt_kms: Fix igt_display_drop_events() to work as intended
URL : https://patchwork.freedesktop.org/series/38353/
State : failure

== Summary ==

Test perf:

        Subgroup oa-exponents:
                pass       -> FAIL       (shard-apl) fdo#102254
        Subgroup enable-disable:
                fail       -> PASS       (shard-apl) fdo#103715
Test gem_exec_suspend:
        Subgroup basic-s4:
                fail       -> SKIP       (shard-snb) fdo#103375
        Subgroup basic-s3:
                skip       -> PASS       (shard-snb) fdo#103880
Test kms_universal_plane:
        Subgroup cursor-fb-leak-pipe-b:
                pass       -> FAIL       (shard-snb)
Test kms_sysfs_edid_timing:
                pass       -> WARN       (shard-apl) fdo#100047
Test kms_rotation_crc:
        Subgroup sprite-rotation-180:
                pass       -> FAIL       (shard-snb) fdo#103925

fdo#102254 https://bugs.freedesktop.org/show_bug.cgi?id=102254
fdo#103715 https://bugs.freedesktop.org/show_bug.cgi?id=103715
fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375
fdo#103880 https://bugs.freedesktop.org/show_bug.cgi?id=103880
fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925

shard-apl        total:3356 pass:1741 dwarn:1   dfail:0   fail:21  skip:1591 time:14125s
shard-hsw        total:3427 pass:1759 dwarn:1   dfail:0   fail:10  skip:1656 time:14566s
shard-snb        total:3427 pass:1347 dwarn:1   dfail:0   fail:11  skip:2068 time:7744s

Blacklisted hosts:
shard-kbl total:3405 pass:1885 dwarn:1 dfail:0 fail:22 skip:1495 time:10467s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_924/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev