All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFCv4 PATCH 0/6]: add poll_requested_events() function
@ 2011-09-29  7:44 Hans Verkuil
  2011-09-29  7:44 ` [RFCv4 PATCH 1/6] poll: " Hans Verkuil
  2011-10-05  7:47 ` [RFCv4 PATCH 0/6]: add poll_requested_events() function Hans Verkuil
  0 siblings, 2 replies; 10+ messages in thread
From: Hans Verkuil @ 2011-09-29  7:44 UTC (permalink / raw)
  To: linux-media
  Cc: linux-kernel, linux-fsdevel, viro, Jonathan Corbet, Andrew Morton

This is the fourth version of this patch series, incorporating the comments
from Andrew Morton: I've split up the multiple-assignment line and added a
comment explaining the purpose of the new function in poll.h.

It's also rebased to the current staging/for_v3.2 branch of the linux-media
tree.

There are no other changes compared to the RFCv3 patches.

I'd very much like to get an Acked-by (or additional comments) from Al or
Andrew! This patch series really should go into v3.2 which is getting close.

Normally I would have posted this v4 3 weeks ago, but due to Real Life
interference in the past few weeks I was unable to. But I'm back, and this is
currently the highest priority for me.

Regards,

	Hans


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [RFCv4 PATCH 1/6] poll: add poll_requested_events() function
  2011-09-29  7:44 [RFCv4 PATCH 0/6]: add poll_requested_events() function Hans Verkuil
@ 2011-09-29  7:44 ` Hans Verkuil
  2011-09-29  7:44   ` [RFCv4 PATCH 2/6] ivtv: only start streaming in poll() if polling for input Hans Verkuil
                     ` (4 more replies)
  2011-10-05  7:47 ` [RFCv4 PATCH 0/6]: add poll_requested_events() function Hans Verkuil
  1 sibling, 5 replies; 10+ messages in thread
From: Hans Verkuil @ 2011-09-29  7:44 UTC (permalink / raw)
  To: linux-media
  Cc: linux-kernel, linux-fsdevel, viro, Jonathan Corbet,
	Andrew Morton, Hans Verkuil

In some cases the poll() implementation in a driver has to do different
things depending on the events the caller wants to poll for. An example is
when a driver needs to start a DMA engine if the caller polls for POLLIN,
but doesn't want to do that if POLLIN is not requested but instead only
POLLOUT or POLLPRI is requested. This is something that can happen in the
video4linux subsystem.

Unfortunately, the current epoll/poll/select implementation doesn't provide
that information reliably. The poll_table_struct does have it: it has a key
field with the event mask. But once a poll() call matches one or more bits
of that mask any following poll() calls are passed a NULL poll_table_struct
pointer.

The solution is to set the qproc field to NULL in poll_table_struct once
poll() matches the events, not the poll_table_struct pointer itself. That
way drivers can obtain the mask through a new poll_requested_events inline.

The poll_table_struct can still be NULL since some kernel code calls it
internally (netfs_state_poll() in ./drivers/staging/pohmelfs/netfs.h). In
that case poll_requested_events() returns ~0 (i.e. all events).

Since eventpoll always leaves the key field at ~0 instead of using the
requested events mask, that source was changed as well to properly fill in
the key field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Jonathan Corbet <corbet@lwn.net>
---
 fs/eventpoll.c       |   18 +++++++++++++++---
 fs/select.c          |   38 +++++++++++++++++---------------------
 include/linux/poll.h |   13 ++++++++++++-
 3 files changed, 44 insertions(+), 25 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index fe047d96..fc32717 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -650,9 +650,12 @@ static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head,
 			       void *priv)
 {
 	struct epitem *epi, *tmp;
+	poll_table pt;
 
+	init_poll_funcptr(&pt, NULL);
 	list_for_each_entry_safe(epi, tmp, head, rdllink) {
-		if (epi->ffd.file->f_op->poll(epi->ffd.file, NULL) &
+		pt.key = epi->event.events;
+		if (epi->ffd.file->f_op->poll(epi->ffd.file, &pt) &
 		    epi->event.events)
 			return POLLIN | POLLRDNORM;
 		else {
@@ -946,6 +949,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
 	/* Initialize the poll table using the queue callback */
 	epq.epi = epi;
 	init_poll_funcptr(&epq.pt, ep_ptable_queue_proc);
+	epq.pt.key = event->events;
 
 	/*
 	 * Attach the item to the poll hooks and get current event bits.
@@ -1027,6 +1031,9 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even
 {
 	int pwake = 0;
 	unsigned int revents;
+	poll_table pt;
+
+	init_poll_funcptr(&pt, NULL);
 
 	/*
 	 * Set the new event interest mask before calling f_op->poll();
@@ -1034,13 +1041,14 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even
 	 * f_op->poll() call and the new event set registering.
 	 */
 	epi->event.events = event->events;
+	pt.key = event->events;
 	epi->event.data = event->data; /* protected by mtx */
 
 	/*
 	 * Get current event bits. We can safely use the file* here because
 	 * its usage count has been increased by the caller of this function.
 	 */
-	revents = epi->ffd.file->f_op->poll(epi->ffd.file, NULL);
+	revents = epi->ffd.file->f_op->poll(epi->ffd.file, &pt);
 
 	/*
 	 * If the item is "hot" and it is not registered inside the ready
@@ -1075,6 +1083,9 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head,
 	unsigned int revents;
 	struct epitem *epi;
 	struct epoll_event __user *uevent;
+	poll_table pt;
+
+	init_poll_funcptr(&pt, NULL);
 
 	/*
 	 * We can loop without lock because we are passed a task private list.
@@ -1087,7 +1098,8 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head,
 
 		list_del_init(&epi->rdllink);
 
-		revents = epi->ffd.file->f_op->poll(epi->ffd.file, NULL) &
+		pt.key = epi->event.events;
+		revents = epi->ffd.file->f_op->poll(epi->ffd.file, &pt) &
 			epi->event.events;
 
 		/*
diff --git a/fs/select.c b/fs/select.c
index d33418f..b6765cf 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -386,13 +386,11 @@ get_max:
 static inline void wait_key_set(poll_table *wait, unsigned long in,
 				unsigned long out, unsigned long bit)
 {
-	if (wait) {
-		wait->key = POLLEX_SET;
-		if (in & bit)
-			wait->key |= POLLIN_SET;
-		if (out & bit)
-			wait->key |= POLLOUT_SET;
-	}
+	wait->key = POLLEX_SET;
+	if (in & bit)
+		wait->key |= POLLIN_SET;
+	if (out & bit)
+		wait->key |= POLLOUT_SET;
 }
 
 int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
@@ -414,7 +412,7 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
 	poll_initwait(&table);
 	wait = &table.pt;
 	if (end_time && !end_time->tv_sec && !end_time->tv_nsec) {
-		wait = NULL;
+		wait->qproc = NULL;
 		timed_out = 1;
 	}
 
@@ -459,17 +457,17 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
 					if ((mask & POLLIN_SET) && (in & bit)) {
 						res_in |= bit;
 						retval++;
-						wait = NULL;
+						wait->qproc = NULL;
 					}
 					if ((mask & POLLOUT_SET) && (out & bit)) {
 						res_out |= bit;
 						retval++;
-						wait = NULL;
+						wait->qproc = NULL;
 					}
 					if ((mask & POLLEX_SET) && (ex & bit)) {
 						res_ex |= bit;
 						retval++;
-						wait = NULL;
+						wait->qproc = NULL;
 					}
 				}
 			}
@@ -481,7 +479,7 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
 				*rexp = res_ex;
 			cond_resched();
 		}
-		wait = NULL;
+		wait->qproc = NULL;
 		if (retval || timed_out || signal_pending(current))
 			break;
 		if (table.error) {
@@ -720,7 +718,7 @@ struct poll_list {
  * interested in events matching the pollfd->events mask, and the result
  * matching that mask is both recorded in pollfd->revents and returned. The
  * pwait poll_table will be used by the fd-provided poll handler for waiting,
- * if non-NULL.
+ * if pwait->qproc is non-NULL.
  */
 static inline unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait)
 {
@@ -738,9 +736,7 @@ static inline unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait)
 		if (file != NULL) {
 			mask = DEFAULT_POLLMASK;
 			if (file->f_op && file->f_op->poll) {
-				if (pwait)
-					pwait->key = pollfd->events |
-							POLLERR | POLLHUP;
+				pwait->key = pollfd->events | POLLERR | POLLHUP;
 				mask = file->f_op->poll(file, pwait);
 			}
 			/* Mask out unneeded events. */
@@ -763,7 +759,7 @@ static int do_poll(unsigned int nfds,  struct poll_list *list,
 
 	/* Optimise the no-wait case */
 	if (end_time && !end_time->tv_sec && !end_time->tv_nsec) {
-		pt = NULL;
+		pt->qproc = NULL;
 		timed_out = 1;
 	}
 
@@ -781,22 +777,22 @@ static int do_poll(unsigned int nfds,  struct poll_list *list,
 			for (; pfd != pfd_end; pfd++) {
 				/*
 				 * Fish for events. If we found one, record it
-				 * and kill the poll_table, so we don't
+				 * and kill poll_table->qproc, so we don't
 				 * needlessly register any other waiters after
 				 * this. They'll get immediately deregistered
 				 * when we break out and return.
 				 */
 				if (do_pollfd(pfd, pt)) {
 					count++;
-					pt = NULL;
+					pt->qproc = NULL;
 				}
 			}
 		}
 		/*
 		 * All waiters have already been registered, so don't provide
-		 * a poll_table to them on the next loop iteration.
+		 * a poll_table->qproc to them on the next loop iteration.
 		 */
-		pt = NULL;
+		pt->qproc = NULL;
 		if (!count) {
 			count = wait->error;
 			if (signal_pending(current))
diff --git a/include/linux/poll.h b/include/linux/poll.h
index cf40010..1e22d4c 100644
--- a/include/linux/poll.h
+++ b/include/linux/poll.h
@@ -39,10 +39,21 @@ typedef struct poll_table_struct {
 
 static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
 {
-	if (p && wait_address)
+	if (p && p->qproc && wait_address)
 		p->qproc(filp, wait_address, p);
 }
 
+/*
+ * Return the set of events that the application wants to poll for.
+ * This is useful for drivers that need to know whether a DMA transfer has
+ * to be started implicitly on poll(). You typically only want to do that
+ * if the application is actually polling for POLLIN and/or POLLOUT.
+ */
+static inline unsigned long poll_requested_events(const poll_table *p)
+{
+	return p ? p->key : ~0UL;
+}
+
 static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
 {
 	pt->qproc = qproc;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFCv4 PATCH 2/6] ivtv: only start streaming in poll() if polling for input.
  2011-09-29  7:44 ` [RFCv4 PATCH 1/6] poll: " Hans Verkuil
@ 2011-09-29  7:44   ` Hans Verkuil
  2011-10-02 12:13     ` Andy Walls
  2011-09-29  7:44   ` [RFCv4 PATCH 3/6] videobuf2: only start streaming in poll() if so requested by the poll mask Hans Verkuil
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Hans Verkuil @ 2011-09-29  7:44 UTC (permalink / raw)
  To: linux-media
  Cc: linux-kernel, linux-fsdevel, viro, Jonathan Corbet,
	Andrew Morton, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/video/ivtv/ivtv-fileops.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 38f0522..a931ecf 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -744,8 +744,9 @@ unsigned int ivtv_v4l2_dec_poll(struct file *filp, poll_table *wait)
 	return res;
 }
 
-unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table * wait)
+unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table *wait)
 {
+	unsigned long req_events = poll_requested_events(wait);
 	struct ivtv_open_id *id = fh2id(filp->private_data);
 	struct ivtv *itv = id->itv;
 	struct ivtv_stream *s = &itv->streams[id->type];
@@ -753,7 +754,8 @@ unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table * wait)
 	unsigned res = 0;
 
 	/* Start a capture if there is none */
-	if (!eof && !test_bit(IVTV_F_S_STREAMING, &s->s_flags)) {
+	if (!eof && !test_bit(IVTV_F_S_STREAMING, &s->s_flags) &&
+			(req_events & (POLLIN | POLLRDNORM))) {
 		int rc;
 
 		mutex_lock(&itv->serialize_lock);
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFCv4 PATCH 3/6] videobuf2: only start streaming in poll() if so requested by the poll mask.
  2011-09-29  7:44 ` [RFCv4 PATCH 1/6] poll: " Hans Verkuil
  2011-09-29  7:44   ` [RFCv4 PATCH 2/6] ivtv: only start streaming in poll() if polling for input Hans Verkuil
@ 2011-09-29  7:44   ` Hans Verkuil
  2011-09-29  7:44   ` [RFCv4 PATCH 4/6] videobuf: " Hans Verkuil
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2011-09-29  7:44 UTC (permalink / raw)
  To: linux-media
  Cc: linux-kernel, linux-fsdevel, viro, Jonathan Corbet,
	Andrew Morton, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/video/videobuf2-core.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c
index 6687ac3..a921638 100644
--- a/drivers/media/video/videobuf2-core.c
+++ b/drivers/media/video/videobuf2-core.c
@@ -1368,6 +1368,7 @@ static int __vb2_cleanup_fileio(struct vb2_queue *q);
  */
 unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 {
+	unsigned long req_events = poll_requested_events(wait);
 	unsigned long flags;
 	unsigned int ret;
 	struct vb2_buffer *vb = NULL;
@@ -1376,12 +1377,14 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 	 * Start file I/O emulator only if streaming API has not been used yet.
 	 */
 	if (q->num_buffers == 0 && q->fileio == NULL) {
-		if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ)) {
+		if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ) &&
+				(req_events & (POLLIN | POLLRDNORM))) {
 			ret = __vb2_init_fileio(q, 1);
 			if (ret)
 				return POLLERR;
 		}
-		if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE)) {
+		if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE) &&
+				(req_events & (POLLOUT | POLLWRNORM))) {
 			ret = __vb2_init_fileio(q, 0);
 			if (ret)
 				return POLLERR;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFCv4 PATCH 4/6] videobuf: only start streaming in poll() if so requested by the poll mask.
  2011-09-29  7:44 ` [RFCv4 PATCH 1/6] poll: " Hans Verkuil
  2011-09-29  7:44   ` [RFCv4 PATCH 2/6] ivtv: only start streaming in poll() if polling for input Hans Verkuil
  2011-09-29  7:44   ` [RFCv4 PATCH 3/6] videobuf2: only start streaming in poll() if so requested by the poll mask Hans Verkuil
@ 2011-09-29  7:44   ` Hans Verkuil
  2011-09-29  7:44   ` [RFCv4 PATCH 5/6] videobuf2-core: also test for pending events Hans Verkuil
  2011-09-29  7:44   ` [RFCv4 PATCH 6/6] vivi: let vb2_poll handle events Hans Verkuil
  4 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2011-09-29  7:44 UTC (permalink / raw)
  To: linux-media
  Cc: linux-kernel, linux-fsdevel, viro, Jonathan Corbet,
	Andrew Morton, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/video/videobuf-core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c
index de4fa4e..ffdf59c 100644
--- a/drivers/media/video/videobuf-core.c
+++ b/drivers/media/video/videobuf-core.c
@@ -1129,6 +1129,7 @@ unsigned int videobuf_poll_stream(struct file *file,
 				  struct videobuf_queue *q,
 				  poll_table *wait)
 {
+	unsigned long req_events = poll_requested_events(wait);
 	struct videobuf_buffer *buf = NULL;
 	unsigned int rc = 0;
 
@@ -1137,7 +1138,7 @@ unsigned int videobuf_poll_stream(struct file *file,
 		if (!list_empty(&q->stream))
 			buf = list_entry(q->stream.next,
 					 struct videobuf_buffer, stream);
-	} else {
+	} else if (req_events & (POLLIN | POLLRDNORM)) {
 		if (!q->reading)
 			__videobuf_read_start(q);
 		if (!q->reading) {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFCv4 PATCH 5/6] videobuf2-core: also test for pending events.
  2011-09-29  7:44 ` [RFCv4 PATCH 1/6] poll: " Hans Verkuil
                     ` (2 preceding siblings ...)
  2011-09-29  7:44   ` [RFCv4 PATCH 4/6] videobuf: " Hans Verkuil
@ 2011-09-29  7:44   ` Hans Verkuil
  2011-09-29  7:44   ` [RFCv4 PATCH 6/6] vivi: let vb2_poll handle events Hans Verkuil
  4 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2011-09-29  7:44 UTC (permalink / raw)
  To: linux-media
  Cc: linux-kernel, linux-fsdevel, viro, Jonathan Corbet,
	Andrew Morton, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/video/videobuf2-core.c |   41 +++++++++++++++++++++++----------
 1 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c
index a921638..7674220 100644
--- a/drivers/media/video/videobuf2-core.c
+++ b/drivers/media/video/videobuf2-core.c
@@ -19,6 +19,9 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 
+#include <media/v4l2-dev.h>
+#include <media/v4l2-fh.h>
+#include <media/v4l2-event.h>
 #include <media/videobuf2-core.h>
 
 static int debug;
@@ -1363,15 +1366,28 @@ static int __vb2_cleanup_fileio(struct vb2_queue *q);
  * For OUTPUT queues, if a buffer is ready to be dequeued, the file descriptor
  * will be reported as available for writing.
  *
+ * If the driver uses struct v4l2_fh, then vb2_poll() will also check for any
+ * pending events.
+ *
  * The return values from this function are intended to be directly returned
  * from poll handler in driver.
  */
 unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 {
+	struct video_device *vfd = video_devdata(file);
 	unsigned long req_events = poll_requested_events(wait);
-	unsigned long flags;
-	unsigned int ret;
 	struct vb2_buffer *vb = NULL;
+	unsigned int res = 0;
+	unsigned long flags;
+
+	if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
+		struct v4l2_fh *fh = file->private_data;
+
+		if (v4l2_event_pending(fh))
+			res = POLLPRI;
+		else if (req_events & POLLPRI)
+			poll_wait(file, &fh->wait, wait);
+	}
 
 	/*
 	 * Start file I/O emulator only if streaming API has not been used yet.
@@ -1379,19 +1395,17 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 	if (q->num_buffers == 0 && q->fileio == NULL) {
 		if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ) &&
 				(req_events & (POLLIN | POLLRDNORM))) {
-			ret = __vb2_init_fileio(q, 1);
-			if (ret)
-				return POLLERR;
+			if (__vb2_init_fileio(q, 1))
+				return res | POLLERR;
 		}
 		if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE) &&
 				(req_events & (POLLOUT | POLLWRNORM))) {
-			ret = __vb2_init_fileio(q, 0);
-			if (ret)
-				return POLLERR;
+			if (__vb2_init_fileio(q, 0))
+				return res | POLLERR;
 			/*
 			 * Write to OUTPUT queue can be done immediately.
 			 */
-			return POLLOUT | POLLWRNORM;
+			return res | POLLOUT | POLLWRNORM;
 		}
 	}
 
@@ -1399,7 +1413,7 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 	 * There is nothing to wait for if no buffers have already been queued.
 	 */
 	if (list_empty(&q->queued_list))
-		return POLLERR;
+		return res | POLLERR;
 
 	poll_wait(file, &q->done_wq, wait);
 
@@ -1414,10 +1428,11 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 
 	if (vb && (vb->state == VB2_BUF_STATE_DONE
 			|| vb->state == VB2_BUF_STATE_ERROR)) {
-		return (V4L2_TYPE_IS_OUTPUT(q->type)) ? POLLOUT | POLLWRNORM :
-			POLLIN | POLLRDNORM;
+		return (V4L2_TYPE_IS_OUTPUT(q->type)) ?
+				res | POLLOUT | POLLWRNORM :
+				res | POLLIN | POLLRDNORM;
 	}
-	return 0;
+	return res;
 }
 EXPORT_SYMBOL_GPL(vb2_poll);
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFCv4 PATCH 6/6] vivi: let vb2_poll handle events.
  2011-09-29  7:44 ` [RFCv4 PATCH 1/6] poll: " Hans Verkuil
                     ` (3 preceding siblings ...)
  2011-09-29  7:44   ` [RFCv4 PATCH 5/6] videobuf2-core: also test for pending events Hans Verkuil
@ 2011-09-29  7:44   ` Hans Verkuil
  4 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2011-09-29  7:44 UTC (permalink / raw)
  To: linux-media
  Cc: linux-kernel, linux-fsdevel, viro, Jonathan Corbet,
	Andrew Morton, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

The vb2_poll function now tests for events and sets POLLPRI accordingly.
So there it is no longer necessary to test for it in the vivi driver.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/video/vivi.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 7cf94c0..c25787d 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -1057,17 +1057,10 @@ static unsigned int
 vivi_poll(struct file *file, struct poll_table_struct *wait)
 {
 	struct vivi_dev *dev = video_drvdata(file);
-	struct v4l2_fh *fh = file->private_data;
 	struct vb2_queue *q = &dev->vb_vidq;
-	unsigned int res;
 
 	dprintk(dev, 1, "%s\n", __func__);
-	res = vb2_poll(q, file, wait);
-	if (v4l2_event_pending(fh))
-		res |= POLLPRI;
-	else
-		poll_wait(file, &fh->wait, wait);
-	return res;
+	return vb2_poll(q, file, wait);
 }
 
 static int vivi_close(struct file *file)
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [RFCv4 PATCH 2/6] ivtv: only start streaming in poll() if polling for input.
  2011-09-29  7:44   ` [RFCv4 PATCH 2/6] ivtv: only start streaming in poll() if polling for input Hans Verkuil
@ 2011-10-02 12:13     ` Andy Walls
  0 siblings, 0 replies; 10+ messages in thread
From: Andy Walls @ 2011-10-02 12:13 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: linux-media, linux-kernel, linux-fsdevel, viro, Jonathan Corbet,
	Andrew Morton, Hans Verkuil

On Thu, 2011-09-29 at 09:44 +0200, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

FWIW:

Acked-by: Andy Walls <awalls@md.metrocast.net>

-Andy


> ---
>  drivers/media/video/ivtv/ivtv-fileops.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
> index 38f0522..a931ecf 100644
> --- a/drivers/media/video/ivtv/ivtv-fileops.c
> +++ b/drivers/media/video/ivtv/ivtv-fileops.c
> @@ -744,8 +744,9 @@ unsigned int ivtv_v4l2_dec_poll(struct file *filp, poll_table *wait)
>  	return res;
>  }
>  
> -unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table * wait)
> +unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table *wait)
>  {
> +	unsigned long req_events = poll_requested_events(wait);
>  	struct ivtv_open_id *id = fh2id(filp->private_data);
>  	struct ivtv *itv = id->itv;
>  	struct ivtv_stream *s = &itv->streams[id->type];
> @@ -753,7 +754,8 @@ unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table * wait)
>  	unsigned res = 0;
>  
>  	/* Start a capture if there is none */
> -	if (!eof && !test_bit(IVTV_F_S_STREAMING, &s->s_flags)) {
> +	if (!eof && !test_bit(IVTV_F_S_STREAMING, &s->s_flags) &&
> +			(req_events & (POLLIN | POLLRDNORM))) {
>  		int rc;
>  
>  		mutex_lock(&itv->serialize_lock);



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFCv4 PATCH 0/6]: add poll_requested_events() function
  2011-09-29  7:44 [RFCv4 PATCH 0/6]: add poll_requested_events() function Hans Verkuil
  2011-09-29  7:44 ` [RFCv4 PATCH 1/6] poll: " Hans Verkuil
@ 2011-10-05  7:47 ` Hans Verkuil
  2011-10-05 21:01   ` Andrew Morton
  1 sibling, 1 reply; 10+ messages in thread
From: Hans Verkuil @ 2011-10-05  7:47 UTC (permalink / raw)
  To: viro, Andrew Morton
  Cc: linux-media, linux-kernel, linux-fsdevel, Jonathan Corbet,
	Mauro Carvalho Chehab

On Thursday 29 September 2011 09:44:06 Hans Verkuil wrote:
> This is the fourth version of this patch series, incorporating the comments
> from Andrew Morton: I've split up the multiple-assignment line and added a
> comment explaining the purpose of the new function in poll.h.
> 
> It's also rebased to the current staging/for_v3.2 branch of the linux-media
> tree.
> 
> There are no other changes compared to the RFCv3 patches.
> 
> I'd very much like to get an Acked-by (or additional comments) from Al or
> Andrew! This patch series really should go into v3.2 which is getting
> close.
> 
> Normally I would have posted this v4 3 weeks ago, but due to Real Life
> interference in the past few weeks I was unable to. But I'm back, and this
> is currently the highest priority for me.

This is becoming annoying. Andrew, Al, can one of you please Ack this patch or 
review it? We *really* need this enhancement for our v4l drivers. I've been 
asking for an ack (or review) for ages and for the most part I got radio 
silence. Jon Corbet has already reviewed the code in early July (!), so I 
don't see why this is taking so long.

Mauro needs an ack from one of you before he can merge it.

Regards,

	Hans

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFCv4 PATCH 0/6]: add poll_requested_events() function
  2011-10-05  7:47 ` [RFCv4 PATCH 0/6]: add poll_requested_events() function Hans Verkuil
@ 2011-10-05 21:01   ` Andrew Morton
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2011-10-05 21:01 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: viro, linux-media, linux-kernel, linux-fsdevel, Jonathan Corbet,
	Mauro Carvalho Chehab

On Wed, 5 Oct 2011 09:47:09 +0200
Hans Verkuil <hverkuil@xs4all.nl> wrote:

> On Thursday 29 September 2011 09:44:06 Hans Verkuil wrote:
> > This is the fourth version of this patch series, incorporating the comments
> > from Andrew Morton: I've split up the multiple-assignment line and added a
> > comment explaining the purpose of the new function in poll.h.
> > 
> > It's also rebased to the current staging/for_v3.2 branch of the linux-media
> > tree.
> > 
> > There are no other changes compared to the RFCv3 patches.
> > 
> > I'd very much like to get an Acked-by (or additional comments) from Al or
> > Andrew! This patch series really should go into v3.2 which is getting
> > close.
> > 
> > Normally I would have posted this v4 3 weeks ago, but due to Real Life
> > interference in the past few weeks I was unable to. But I'm back, and this
> > is currently the highest priority for me.
> 
> This is becoming annoying. Andrew, Al, can one of you please Ack this patch or 
> review it? We *really* need this enhancement for our v4l drivers. I've been 
> asking for an ack (or review) for ages and for the most part I got radio 
> silence. Jon Corbet has already reviewed the code in early July (!), so I 
> don't see why this is taking so long.
> 
> Mauro needs an ack from one of you before he can merge it.
> 

It looks OK to me, but obviously it would be better if Al were to go
through it also.  If he doesn't then there isn't a lot we can do about
it - I suggest that you proceed with the plan to merge it into -rc1.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-10-05 21:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-29  7:44 [RFCv4 PATCH 0/6]: add poll_requested_events() function Hans Verkuil
2011-09-29  7:44 ` [RFCv4 PATCH 1/6] poll: " Hans Verkuil
2011-09-29  7:44   ` [RFCv4 PATCH 2/6] ivtv: only start streaming in poll() if polling for input Hans Verkuil
2011-10-02 12:13     ` Andy Walls
2011-09-29  7:44   ` [RFCv4 PATCH 3/6] videobuf2: only start streaming in poll() if so requested by the poll mask Hans Verkuil
2011-09-29  7:44   ` [RFCv4 PATCH 4/6] videobuf: " Hans Verkuil
2011-09-29  7:44   ` [RFCv4 PATCH 5/6] videobuf2-core: also test for pending events Hans Verkuil
2011-09-29  7:44   ` [RFCv4 PATCH 6/6] vivi: let vb2_poll handle events Hans Verkuil
2011-10-05  7:47 ` [RFCv4 PATCH 0/6]: add poll_requested_events() function Hans Verkuil
2011-10-05 21:01   ` Andrew Morton

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.