All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	igt-dev@lists.freedesktop.org
Cc: Jari Tahvanainen <jari.tahvanainen@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t] lib/igt_kms: Fix igt_display_drop_events() to work as intended
Date: Thu, 15 Feb 2018 12:03:25 +0000	[thread overview]
Message-ID: <151869620519.15373.15741320191098775618@mail.alporthouse.com> (raw)
In-Reply-To: <20180215114917.59382-1-maarten.lankhorst@linux.intel.com>

Quoting Maarten Lankhorst (2018-02-15 11:49:17)
> 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.
> 
> Cc: Jari Tahvanainen <jari.tahvanainen@intel.com>
> Reported-by: Jari Tahvanainen <jari.tahvanainen@intel.com>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104538
> ---
>  lib/igt_kms.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 11f23fcaaa81..5a5df61c5856 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -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.

> -               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

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2018-02-15 12:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-15 11:49 [igt-dev] [PATCH i-g-t] lib/igt_kms: Fix igt_display_drop_events() to work as intended Maarten Lankhorst
2018-02-15 12:03 ` Chris Wilson [this message]
2018-02-15 13:52   ` Maarten Lankhorst
2018-02-15 13:30 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-02-15 21:32 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

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=151869620519.15373.15741320191098775618@mail.alporthouse.com \
    --to=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jari.tahvanainen@intel.com \
    --cc=maarten.lankhorst@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.