All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lyude Paul <lyude@redhat.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
	IGT development <igt-dev@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Keith Packard <keithp@keithp.com>
Subject: Re: [igt-dev] [PATCH i-g-t] tests/kms_lease: exercise uevent
Date: Wed, 20 Feb 2019 18:42:43 -0500	[thread overview]
Message-ID: <4bdd729f01344fd16a6cc3af6e4468acf7a4109d.camel@redhat.com> (raw)
In-Reply-To: <20190220211739.3881-1-daniel.vetter@ffwll.ch>

On Wed, 2019-02-20 at 22:17 +0100, Daniel Vetter wrote:
> And make sure we get the LEASE=1 value, indicating a lessee change.
> 
> v2: Apparently netlink reading can leak EAGAIN out through
> udev_monitor_receive_device. No idea what's going on there, so let's
> wrap some duct tape around it.
> 
> v3: Lyude reported that we might get a few udev events on startup of
> the test. Drain those first.
> 
> v4: Use the igt hotplug library functions, they already take care of
> all the uevent special cases.
> 
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Keith Packard <keithp@keithp.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  lib/igt_kms.c     | 42 +++++++++++++++++++++++++++++++-----------
>  lib/igt_kms.h     |  2 ++
>  tests/kms_lease.c | 36 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 69 insertions(+), 11 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 85a911e11060..8f0b79d7727b 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -4019,16 +4019,8 @@ struct udev_monitor *igt_watch_hotplug(void)
>  	return mon;
>  }
>  
> -/**
> - * igt_hotplug_detected:
> - * @mon: A udev monitor initialized with #igt_watch_hotplug
> - * @timeout_secs: How long to wait for a hotplug event to occur.
> - *
> - * Assert that a hotplug event was received since we last checked the
> monitor.
> - *
> - * Returns: true if a sysfs hotplug event was received, false if we timed
> out
> - */
> -bool igt_hotplug_detected(struct udev_monitor *mon, int timeout_secs)
> +static bool event_detected(struct udev_monitor *mon, int timeout_secs,
> +			   const char *property)
>  {
>  	struct udev_device *dev;
>  	const char *hotplug_val;
> @@ -4046,7 +4038,7 @@ bool igt_hotplug_detected(struct udev_monitor *mon,
> int timeout_secs)
>  	while (!hotplug_received && poll(&fd, 1, timeout_secs * 1000)) {
>  		dev = udev_monitor_receive_device(mon);
>  
> -		hotplug_val = udev_device_get_property_value(dev, "HOTPLUG");
> +		hotplug_val = udev_device_get_property_value(dev, property);
>  		if (hotplug_val && atoi(hotplug_val) == 1)
>  			hotplug_received = true;
>  
> @@ -4056,6 +4048,34 @@ bool igt_hotplug_detected(struct udev_monitor *mon,
> int timeout_secs)
>  	return hotplug_received;
>  }
>  
> +/**
> + * igt_hotplug_detected:
> + * @mon: A udev monitor initialized with #igt_watch_hotplug
> + * @timeout_secs: How long to wait for a hotplug event to occur.
> + *
> + * Assert that a hotplug event was received since we last checked the
> monitor.
> + *
> + * Returns: true if a sysfs hotplug event was received, false if we timed
> out
> + */
> +bool igt_hotplug_detected(struct udev_monitor *mon, int timeout_secs)
> +{
> +	return event_detected(mon, timeout_secs, "HOTPLUG");
> +}
> +
> +/**
> + * igt_lease_change_detected:
> + * @mon: A udev monitor initialized with #igt_watch_hotplug
> + * @timeout_secs: How long to wait for a lease change event to occur.
> + *
> + * Assert that a lease change event was received since we last checked the
> monitor.
> + *
> + * Returns: true if a sysfs lease change event was received, false if we
> timed out
> + */
> +bool igt_lease_change_detected(struct udev_monitor *mon, int timeout_secs)
> +{
> +	return event_detected(mon, timeout_secs, "LEASE");
> +}
> +
>  /**
>   * igt_flush_hotplugs:
>   * @mon: A udev monitor initialized with #igt_watch_hotplug
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 679d4e84fab8..5755b160d13e 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -749,6 +749,8 @@ const unsigned char* igt_kms_get_alt_edid(void);
>  struct udev_monitor *igt_watch_hotplug(void);
>  bool igt_hotplug_detected(struct udev_monitor *mon,
>  			  int timeout_secs);
> +bool igt_lease_change_detected(struct udev_monitor *mon,
> +			       int timeout_secs);
>  void igt_flush_hotplugs(struct udev_monitor *mon);
>  void igt_cleanup_hotplug(struct udev_monitor *mon);
>  
> diff --git a/tests/kms_lease.c b/tests/kms_lease.c
> index d082a7988eaa..600f6779561d 100644
> --- a/tests/kms_lease.c
> +++ b/tests/kms_lease.c
> @@ -40,6 +40,8 @@
>  #include <sys/time.h>
>  #include <sys/wait.h>
>  
> +#include <libudev.h>
> +
>  #include <drm.h>
>  
>  IGT_TEST_DESCRIPTION("Test of CreateLease.");
> @@ -976,6 +978,37 @@ static void implicit_plane_lease(data_t *data)
>  	drmSetClientCap(data->master.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
>  }
>  
> +static void lease_uevent(data_t *data)
> +{
> +	int lease_fd;
> +	struct local_drm_mode_list_lessees mll;
> +	struct udev_monitor *uevent_monitor;
> +
> +	uevent_monitor = igt_watch_hotplug();
> +
> +	igt_flush_hotplugs(uevent_monitor);
Shouldn't we rename
igt_watch_hotplug()/igt_flush_hotplugs()/igt_cleanup_hotplug()/etc. as well to
reflect that these are used for more then udev hotplug events now?

Otherwise, looks good to me

> +
> +	lease_fd = create_simple_lease(data->master.fd, data);
> +
> +	igt_assert(!igt_lease_change_detected(uevent_monitor, 1));
> +
> +	mll.pad = 0;
> +	mll.count_lessees = 0;
> +	mll.lessees_ptr = 0;
> +	igt_assert_eq(list_lessees(data->master.fd, &mll), 0);
> +	igt_assert_eq(mll.count_lessees, 1);
> +
> +	close(lease_fd);
> +
> +	igt_assert(igt_lease_change_detected(uevent_monitor, 1));
> +
> +	mll.lessees_ptr = 0;
> +	igt_assert_eq(list_lessees(data->master.fd, &mll), 0);
> +	igt_assert_eq(mll.count_lessees, 0);
> +
> +	igt_cleanup_hotplug(uevent_monitor);
> +}
> +
>  igt_main
>  {
>  	data_t data;
> @@ -1023,4 +1056,7 @@ igt_main
>  
>  	igt_subtest("implicit-plane-lease")
>  		implicit_plane_lease(&data);
> +
> +	igt_subtest("lease-uevent")
> +		lease_uevent(&data);
>  }
-- 
Cheers,
	Lyude Paul

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-02-20 23:42 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20 16:25 [igt-dev] [PATCH i-g-t 1/9] tests/kms_lease: Add invalid planes tests Daniel Vetter
2019-02-20 16:25 ` [igt-dev] [PATCH i-g-t 2/9] tests/kms_lease: Run on simulation Daniel Vetter
2019-03-14  9:29   ` Boris Brezillon
2019-02-20 16:25 ` [igt-dev] [PATCH i-g-t 3/9] tests/kms_lease: invalid corner-cases for create-lease ioctl Daniel Vetter
2019-02-20 20:43   ` Lyude Paul
2019-02-20 21:20     ` Daniel Vetter
2019-02-20 21:23   ` [igt-dev] [PATCH i-g-t] " Daniel Vetter
2019-02-21  3:08   ` [igt-dev] [PATCH i-g-t 3/9] " Keith Packard
2019-02-21  9:16     ` Daniel Vetter
2019-02-20 16:25 ` [igt-dev] [PATCH i-g-t 4/9] tests/kms_release: invalid checks for revoke-lease ioctl Daniel Vetter
2019-03-14  9:35   ` Boris Brezillon
2019-02-20 16:25 ` [igt-dev] [PATCH i-g-t 5/9] tests/kms_lease: validate the possible_crtcs filtering Daniel Vetter
2019-02-20 16:25 ` [igt-dev] [PATCH i-g-t 6/9] tests/kms_lease: Test drop/set_master interactions Daniel Vetter
2019-02-20 16:25 ` [igt-dev] [PATCH i-g-t 7/9] tests/kms_lease: multimaster testcase Daniel Vetter
2019-02-20 16:25 ` [igt-dev] [PATCH i-g-t 8/9] tests/kms_lease: validate implicitly added planes Daniel Vetter
2019-02-20 16:25 ` [igt-dev] [PATCH i-g-t 9/9] tests/kms_lease: exercise uevent Daniel Vetter
2019-02-20 20:33   ` [igt-dev] [PATCH i-g-t] " Daniel Vetter
2019-02-20 22:25     ` Lyude Paul
2019-02-20 23:33       ` Daniel Vetter
2019-02-20 23:34         ` Lyude Paul
2019-02-20 21:01   ` Daniel Vetter
2019-02-20 21:17   ` Daniel Vetter
2019-02-20 23:42     ` Lyude Paul [this message]
2019-02-20 23:48       ` Daniel Vetter
2019-02-21  0:16         ` Lyude Paul
2019-02-20 17:00 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/9] tests/kms_lease: Add invalid planes tests Patchwork
2019-02-20 19:51 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2019-02-20 20:42   ` Daniel Vetter
2019-02-20 21:11 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/9] tests/kms_lease: Add invalid planes tests (rev2) Patchwork
2019-02-20 21:51 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/9] tests/kms_lease: Add invalid planes tests (rev3) Patchwork
2019-02-20 22:02 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/9] tests/kms_lease: Add invalid planes tests (rev5) Patchwork
2019-02-20 22:26 ` [igt-dev] [PATCH i-g-t 1/9] tests/kms_lease: Add invalid planes tests Lyude Paul
2019-02-21  1:25 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,1/9] tests/kms_lease: Add invalid planes tests (rev2) Patchwork
2019-02-21  1:52 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,1/9] tests/kms_lease: Add invalid planes tests (rev3) Patchwork
2019-02-21  2:57 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,1/9] tests/kms_lease: Add invalid planes tests (rev5) Patchwork
2019-02-21 12:57 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/9] tests/kms_lease: Add invalid planes tests (rev6) Patchwork
2019-02-21 18:24 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2019-02-21 19:28 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/9] tests/kms_lease: Add invalid planes tests (rev7) Patchwork
2019-02-22  8:00 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2019-02-22 10:50 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/9] tests/kms_lease: Add invalid planes tests (rev8) Patchwork
2019-02-22 20:23 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-03-14  9:26 ` [igt-dev] [PATCH i-g-t 1/9] tests/kms_lease: Add invalid planes tests Boris Brezillon

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=4bdd729f01344fd16a6cc3af6e4468acf7a4109d.camel@redhat.com \
    --to=lyude@redhat.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=keithp@keithp.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.