Skip to contentSkip to conversation

vb2: fix a regression in poll() behavior for output,streams

PATCH In review Hans Verkuil 2 participants 2 messages Oct 29, 2015 – Oct 30, 2015 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vb2: fix a regression in poll() behavior for output,streams

In the 3.17 kernel the poll() behavior changed for output streams:
as long as not all buffers were queued up poll() would return that userspace can write. This is fine for the write() call, but when using stream I/O this changed the behavior since the expectation was that it would wait for buffers to become available for dequeuing.

This patch only enables the check whether you can queue buffers for file I/O only, and skips it for stream I/O.

---
Note: This patch should be applied to stable for 3.17 and up.

 drivers/media/v4l2-core/videobuf2-v4l2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/videobuf2-v4l2.c +3 -3
index dda525b..3ca8a2e 100644
@@ -860,10 +860,10 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 		return res | POLLERR;
 
 	/*
-	 * For output streams you can write as long as there are fewer buffers
-	 * queued than there are buffers available.
+	 * For output streams you can call write() as long as there are fewer
+	 * buffers queued than there are buffers available.
 	 */
-	if (q->is_output && q->queued_count < q->num_buffers)
+	if (q->is_output && q->fileio && q->queued_count < q->num_buffers)
 		return res | POLLOUT | POLLWRNORM;
 
 	if (list_empty(&q->done_list)) {
Signature · 1 line
2.6.1
Acked-by on v1 1/1
#1 lore raw

Hi Hans,

Quoted 10 lines · On Thursday 29 October 2015 14:02:06 Hans Verkuil wrote:

In the 3.17 kernel the poll() behavior changed for output streams:
as long as not all buffers were queued up poll() would return that userspace can write. This is fine for the write() call, but when using stream I/O this changed the behavior since the expectation was that it would wait for buffers to become available for dequeuing.

This patch only enables the check whether you can queue buffers for file I/O only, and skips it for stream I/O.

Thank you for the patch, it's really appreciated.

I'll be able to test it when going back home, but there's no need to wait for me to push this upstream.

Quoted 2 lines

---
Note: This patch should be applied to stable for 3.17 and up.

(although the documentation states it should be "# 3.17.x-" but git log thinks otherwise)

Quoted 21 lines
 drivers/media/v4l2-core/videobuf2-v4l2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/media/v4l2-core/videobuf2-v4l2.c index dda525b..3ca8a2e 100644

drivers/media/v4l2-core/videobuf2-v4l2.c +3 -3
@@ -860,10 +860,10 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file
 *file, poll_table *wait) return res | POLLERR;
 
 	/*
-	 * For output streams you can write as long as there are fewer buffers
-	 * queued than there are buffers available.
+	 * For output streams you can call write() as long as there are fewer
+	 * buffers queued than there are buffers available.
 	 */
-	if (q->is_output && q->queued_count < q->num_buffers)
+	if (q->is_output && q->fileio && q->queued_count < q->num_buffers)
 		return res | POLLOUT | POLLWRNORM;
 
 	if (list_empty(&q->done_list)) {
Signature · 3 lines
Regards,

Laurent Pinchart