From: Hans Verkuil <hverkuil@xs4all.nl>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com,
teemux.tuominen@intel.com
Subject: Re: [RFC v2 1/4] v4l: return POLLERR on V4L2 sub-devices if no events are subscribed
Date: Wed, 02 Oct 2013 16:05:26 +0200 [thread overview]
Message-ID: <524C2826.6030902@xs4all.nl> (raw)
In-Reply-To: <1380721516-488-2-git-send-email-sakari.ailus@linux.intel.com>
On 10/02/13 15:45, Sakari Ailus wrote:
> From: Teemu Tuominen <teemux.tuominen@intel.com>
>
> Add check and return POLLERR from subdev_poll() in case of no events
> subscribed and wakeup once the last event subscription is removed.
>
> This change is essentially done to add possibility to wakeup polling
> with concurrent unsubscribe.
>
> Signed-off-by: Teemu Tuominen <teemux.tuominen@intel.com>
>
> Move the check after calling poll_wait(). Otherwise it's possible that we go
> to sleep without getting notified if the subscription went away between the
> two.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Tested-by: Teemu Tuominen <teemux.tuominen@intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Regards,
Hans
> ---
> drivers/media/v4l2-core/v4l2-event.c | 15 +++++++++++++++
> drivers/media/v4l2-core/v4l2-subdev.c | 3 +++
> include/media/v4l2-event.h | 1 +
> 3 files changed, 19 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-event.c b/drivers/media/v4l2-core/v4l2-event.c
> index 86dcb54..b53897e 100644
> --- a/drivers/media/v4l2-core/v4l2-event.c
> +++ b/drivers/media/v4l2-core/v4l2-event.c
> @@ -107,6 +107,19 @@ static struct v4l2_subscribed_event *v4l2_event_subscribed(
> return NULL;
> }
>
> +bool v4l2_event_has_subscribed(struct v4l2_fh *fh)
> +{
> + unsigned long flags;
> + bool rval;
> +
> + spin_lock_irqsave(&fh->vdev->fh_lock, flags);
> + rval = !list_empty(&fh->subscribed);
> + spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
> +
> + return rval;
> +}
> +EXPORT_SYMBOL(v4l2_event_has_subscribed);
> +
> static void __v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *ev,
> const struct timespec *ts)
> {
> @@ -299,6 +312,8 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
> fh->navailable--;
> }
> list_del(&sev->list);
> + if (list_empty(&fh->subscribed))
> + wake_up_all(&fh->wait);
> }
>
> spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index 996c248..7d72389 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -382,6 +382,9 @@ static unsigned int subdev_poll(struct file *file, poll_table *wait)
> if (v4l2_event_pending(fh))
> return POLLPRI;
>
> + if (!v4l2_event_has_subscribed(fh))
> + return POLLERR | POLLPRI;
> +
> return 0;
> }
>
> diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h
> index be05d01..a9ca2b5 100644
> --- a/include/media/v4l2-event.h
> +++ b/include/media/v4l2-event.h
> @@ -121,6 +121,7 @@ struct v4l2_subscribed_event {
>
> int v4l2_event_dequeue(struct v4l2_fh *fh, struct v4l2_event *event,
> int nonblocking);
> +bool v4l2_event_has_subscribed(struct v4l2_fh *fh);
> void v4l2_event_queue(struct video_device *vdev, const struct v4l2_event *ev);
> void v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *ev);
> int v4l2_event_pending(struct v4l2_fh *fh);
>
next prev parent reply other threads:[~2013-10-02 14:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-02 13:45 [RFC v2 0/4] Sakari Ailus
2013-10-02 13:45 ` [RFC v2 1/4] v4l: return POLLERR on V4L2 sub-devices if no events are subscribed Sakari Ailus
2013-10-02 14:05 ` Hans Verkuil [this message]
2013-10-02 13:45 ` [RFC v2 2/4] v4l: vb2: Only poll for events if the user is interested in them Sakari Ailus
2013-10-02 14:07 ` Hans Verkuil
2013-10-02 13:45 ` [RFC v2 3/4] v4l: vb2: Return POLLERR when polling for events and none are subscribed Sakari Ailus
2013-10-02 13:59 ` Hans Verkuil
2013-10-02 14:21 ` Sakari Ailus
2013-10-02 13:45 ` [RFC v2 4/4] v4l: events: Don't sleep in dequeue if " Sakari Ailus
2013-10-02 14:04 ` Hans Verkuil
2013-10-02 14:18 ` Sakari Ailus
2013-10-02 14:37 ` Hans Verkuil
2013-10-02 14:45 ` Sakari Ailus
2013-10-03 9:29 ` Hans Verkuil
2013-10-02 14:49 ` Sakari Ailus
2013-10-03 9:49 ` Hans Verkuil
2013-10-02 18:12 ` Laurent Pinchart
2013-10-02 20:23 ` Sakari Ailus
2013-10-02 14:00 ` [RFC v2 0/4] Hans Verkuil
2013-10-02 18:15 ` Laurent Pinchart
2013-10-02 20:22 ` Sakari Ailus
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=524C2826.6030902@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=teemux.tuominen@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.