linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vb2: fix a regression in poll() behavior for output,streams
@ 2015-10-29  5:02 Hans Verkuil
  2015-10-30 15:03 ` Laurent Pinchart
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2015-10-29  5:02 UTC (permalink / raw)
  To: linux-media, Laurent Pinchart, Pawel Osciak

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.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
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(-)

diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c
index dda525b..3ca8a2e 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -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)) {
-- 
2.6.1


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

* Re: [PATCH] vb2: fix a regression in poll() behavior for output,streams
  2015-10-29  5:02 [PATCH] vb2: fix a regression in poll() behavior for output,streams Hans Verkuil
@ 2015-10-30 15:03 ` Laurent Pinchart
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2015-10-30 15:03 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Pawel Osciak

Hi Hans,

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.
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

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

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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

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

Cc: stable@vger.kernel.org # 3.17+

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

>  drivers/media/v4l2-core/videobuf2-v4l2.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c
> b/drivers/media/v4l2-core/videobuf2-v4l2.c index dda525b..3ca8a2e 100644
> --- a/drivers/media/v4l2-core/videobuf2-v4l2.c
> +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
> @@ -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)) {

-- 
Regards,

Laurent Pinchart


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

end of thread, other threads:[~2015-10-30 15:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-29  5:02 [PATCH] vb2: fix a regression in poll() behavior for output,streams Hans Verkuil
2015-10-30 15:03 ` Laurent Pinchart

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).