dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
	DRI Development <dri-devel@lists.freedesktop.org>
Cc: Alex Deucher <alexander.deucher@amd.com>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: [REGRESSION] [PATCH 09/22] drm: Clean up pending events in the core
Date: Mon, 25 Jan 2016 15:45:13 +0100	[thread overview]
Message-ID: <56A634F9.7050408@linux.intel.com> (raw)
In-Reply-To: <1452548477-15905-10-git-send-email-daniel.vetter@ffwll.ch>

Hey,

Op 11-01-16 om 22:41 schreef Daniel Vetter:
> There's really no reason to not do so, instead of replicating this
> for every use-case and every driver. Now we can't just nuke the events,
> since that would still mean that all drm_event users would need to know
> when that has happened, since calling e.g. drm_send_event isn't allowed
> any more. Instead just unlink them from the file, and detect this case
> and handle it appropriately in all functions.
>
> v2: Adjust existing kerneldoc too.
>
> v3: Improve wording of the kerneldoc and split out vblank cleanup (Laurent).
>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Acked-by: Daniel Stone <daniels@collabora.com>
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This patch breaks kms_flip.basic-flip-vs-wf_vblank and probably other tests as well.
>  drivers/gpu/drm/drm_fops.c | 30 +++++++++++++++++++++++++++++-
>  include/drm/drmP.h         |  2 ++
>  2 files changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index d85af1b2a238..109903f5b68a 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -264,6 +264,7 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
>  	INIT_LIST_HEAD(&priv->fbs);
>  	mutex_init(&priv->fbs_lock);
>  	INIT_LIST_HEAD(&priv->blobs);
> +	INIT_LIST_HEAD(&priv->pending_event_list);
>  	INIT_LIST_HEAD(&priv->event_list);
>  	init_waitqueue_head(&priv->event_wait);
>  	priv->event_space = 4096; /* set aside 4k for event buffer */
> @@ -366,6 +367,13 @@ static void drm_events_release(struct drm_file *file_priv)
>  			v->base.destroy(&v->base);
>  		}
>  
> +	/* Unlink pending events */
> +	list_for_each_entry_safe(e, et, &file_priv->pending_event_list,
> +				 pending_link) {
> +		list_del(&e->pending_link);
> +		e->file_priv = NULL;
> +	}
> +
>  	/* Remove unconsumed events */
>  	list_for_each_entry_safe(e, et, &file_priv->event_list, link) {
>  		list_del(&e->link);
> @@ -712,6 +720,7 @@ int drm_event_reserve_init(struct drm_device *dev,
>  	file_priv->event_space -= e->length;
>  
>  	p->event = e;
> +	list_add(&p->pending_link, &file_priv->pending_event_list);
>  	p->file_priv = file_priv;
>  
>  	/* we *could* pass this in as arg, but everyone uses kfree: */
> @@ -736,7 +745,10 @@ void drm_event_cancel_free(struct drm_device *dev,
>  {
>  	unsigned long flags;
>  	spin_lock_irqsave(&dev->event_lock, flags);
> -	p->file_priv->event_space += p->event->length;
> +	if (p->file_priv) {
> +		p->file_priv->event_space += p->event->length;
> +		list_del(&p->pending_link);
> +	}
>  	spin_unlock_irqrestore(&dev->event_lock, flags);
>  	p->destroy(p);
>  }
> @@ -750,11 +762,22 @@ EXPORT_SYMBOL(drm_event_cancel_free);
>   * This function sends the event @e, initialized with drm_event_reserve_init(),
>   * to its associated userspace DRM file. Callers must already hold
>   * dev->event_lock, see drm_send_event() for the unlocked version.
> + *
> + * Note that the core will take care of unlinking and disarming events when the
> + * corresponding DRM file is closed. Drivers need not worry about whether the
> + * DRM file for this event still exists and can call this function upon
> + * completion of the asynchronous work unconditionally.
>   */
>  void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e)
>  {
>  	assert_spin_locked(&dev->event_lock);
>  
> +	if (!e->file_priv) {
> +		e->destroy(e);
> +		return;
> +	}
> +
> +	list_del(&e->pending_link);
>  	list_add_tail(&e->link,
>  		      &e->file_priv->event_list);
>  	wake_up_interruptible(&e->file_priv->event_wait);
> @@ -769,6 +792,11 @@ EXPORT_SYMBOL(drm_send_event_locked);
>   * This function sends the event @e, initialized with drm_event_reserve_init(),
>   * to its associated userspace DRM file. This function acquires dev->event_lock,
>   * see drm_send_event_locked() for callers which already hold this lock.
> + *
> + * Note that the core will take care of unlinking and disarming events when the
> + * corresponding DRM file is closed. Drivers need not worry about whether the
> + * DRM file for this event still exists and can call this function upon
> + * completion of the asynchronous work unconditionally.
>   */
>  void drm_send_event(struct drm_device *dev, struct drm_pending_event *e)
>  {
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index ae73abf5c2cf..3d78a7406d54 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -283,6 +283,7 @@ struct drm_ioctl_desc {
>  struct drm_pending_event {
>  	struct drm_event *event;
>  	struct list_head link;
> +	struct list_head pending_link;
>  	struct drm_file *file_priv;
>  	pid_t pid; /* pid of requester, no guarantee it's valid by the time
>  		      we deliver the event, for tracing only */
> @@ -346,6 +347,7 @@ struct drm_file {
>  	struct list_head blobs;
>  
>  	wait_queue_head_t event_wait;
> +	struct list_head pending_event_list;
>  	struct list_head event_list;
>  	int event_space;
>  

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-01-25 14:45 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11 21:40 [PATCH 00/22] drm_event cleanup, round 2 Daniel Vetter
2016-01-11 21:40 ` [PATCH 01/22] drm: kerneldoc for drm_fops.c Daniel Vetter
2016-01-11 21:40 ` [PATCH 02/22] drm: Add functions to setup/tear down drm_events Daniel Vetter
2016-01-14 18:46   ` Laurent Pinchart
2016-01-11 21:40 ` [PATCH 03/22] drm/exynos: Use the new event init/free functions Daniel Vetter
2016-01-11 21:40 ` [PATCH 04/22] drm/vmwgfx: " Daniel Vetter
2016-01-11 21:40 ` [PATCH 05/22] drm: Create drm_send_event helpers Daniel Vetter
2016-01-14 18:46   ` Laurent Pinchart
2016-01-11 21:41 ` [PATCH 06/22] drm/fsl: Remove preclose hook Daniel Vetter
2016-01-11 21:41 ` [PATCH 07/22] drm/armada: Remove NULL open/pre/postclose hooks Daniel Vetter
2016-01-12 11:51   ` Russell King - ARM Linux
2016-01-12 12:33     ` Daniel Vetter
2016-01-11 21:41 ` [PATCH 08/22] drm/gma500: Remove empty preclose hook Daniel Vetter
2016-01-12 10:11   ` Patrik Jakobsson
2016-01-11 21:41 ` [PATCH 09/22] drm: Clean up pending events in the core Daniel Vetter
2016-01-14 18:45   ` Laurent Pinchart
2016-01-25 14:45   ` Maarten Lankhorst [this message]
2016-01-11 21:41 ` [PATCH 10/22] drm: Nuke vblank event file cleanup code Daniel Vetter
2016-01-25  0:26   ` Laurent Pinchart
2016-01-11 21:41 ` [PATCH 11/22] drm/i915: Nuke intel_modeset_preclose Daniel Vetter
2016-01-11 21:41 ` [PATCH 12/22] drm/atmel: Nuke preclose Daniel Vetter
2016-01-13 14:56   ` Boris Brezillon
2016-01-11 21:41 ` [PATCH 13/22] drm/exynos: Remove event cancelling from postclose Daniel Vetter
2016-01-12  6:13   ` Inki Dae
2016-01-11 21:41 ` [PATCH 14/22] drm/imx: Unconfuse preclose logic Daniel Vetter
2016-01-12  8:57   ` Philipp Zabel
2016-01-11 21:41 ` [PATCH 15/22] drm/msm: Nuke preclose hooks Daniel Vetter
2016-01-11 21:41 ` [PATCH 16/22] drm/omap: Nuke close hooks Daniel Vetter
2016-01-12 14:09   ` Tomi Valkeinen
2016-01-13 11:00   ` Tomi Valkeinen
2016-01-13 11:05   ` [PATCH] " Daniel Vetter
2016-01-13 23:07     ` Laurent Pinchart
2016-01-11 21:41 ` [PATCH 17/22] drm/rcar: Nuke preclose hook Daniel Vetter
2016-01-11 21:41 ` [PATCH 18/22] drm/shmob: " Daniel Vetter
2016-01-11 21:41 ` [PATCH 19/22] drm/tegra: Stop cancelling page flip events Daniel Vetter
2016-01-13 14:03   ` Thierry Reding
2016-01-11 21:41 ` [PATCH 20/22] drm/tilcdc: Nuke preclose hook Daniel Vetter
2016-01-12 14:19   ` Tomi Valkeinen
2016-01-12 15:12     ` Daniel Vetter
2016-01-13 11:25       ` Tomi Valkeinen
2016-01-11 21:41 ` [PATCH 21/22] drm/vc4: " Daniel Vetter
2016-01-18 17:19   ` Eric Anholt
2016-01-11 21:41 ` [PATCH 22/22] drm/vmwgfx: " Daniel Vetter
2016-01-11 21:41 ` [PATCH] " Daniel Vetter
2016-01-25  7:50 ` [PATCH 00/22] drm_event cleanup, round 2 Daniel Vetter

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=56A634F9.7050408@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=alexander.deucher@amd.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).