All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Cc: linux-media <linux-media@vger.kernel.org>,
	Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: Question about videobuf2 with 0 buffers
Date: Tue, 07 Jan 2014 14:21:52 +0100	[thread overview]
Message-ID: <52CBFF70.6010604@xs4all.nl> (raw)
In-Reply-To: <CAPybu_0fyzj45rhia71Qq+5QOps0EeuRNqcXDDo+D0HW7Exwdw@mail.gmail.com>

On 01/07/2014 02:09 PM, Ricardo Ribalda Delgado wrote:
> Hello
> 
>   White testing a driver I have stepped into some strange behaviour
> and I want to know if it is a feature or a bug.
> 
>    I am using yavta to test the system and I run this command:
> 
> yavta /dev/video0 -c -n 0
> 
> to start a capture with 0 buffers (Even if I dont know where this can be useful)
> 
> And I have found out that:
> 
> 1) If the user does a streamon() and then  close() the descriptor,
> streamoff is not called, this is because he has never been set as
> owner of the queue. (on vb2_fop_release, queue_release is only called
> if the owns the queue)
> 
> Is this expected? Shouldn't we leave the stream stopped?

No, this is a bug. vb2_internal_streamon() misses a check if q->num_buffers > 0.
If no buffers have been requested, then STREAMON should return -EINVAL.

So streamon() should never be able to start.

Note that calling REQBUFS with count == 0 will work: it will free any allocated
buffers and just return 0.

> 
> I propose to set vdev->queue->owner to the current vdev on streamon if
> it does not have an owner.
> 
> Or in vb2_fop_release set check for :
> if (!vdev->queue->owner || file->private_data == vdev->queue->owner)
> instead of
> if (file->private_data == vdev->queue->owner)
> 
> Shall I post a patch?

Yes, please, but for the real bug :-) Make sure to do a git pull, a bunch
of vb2 patches have just been merged.

> 
> 2) the queue_setup handler of the driver is not called, this could be
> expected, since it is commented on the code.
> /*
> * In case of REQBUFS(0) return immediately without calling
> * driver's queue_setup() callback and allocating resources.
> */
> But I find it strange, the driver could be doing some initialization there...

No, reqbufs(0) is used to free buffers. And it actually can also be used
to check with memory models are supported by the driver.

So reqbufs(0) doesn't setup anything, instead it frees things and releases
the current filehandle from being the owner.

Hope this helps,

	Hans

      reply	other threads:[~2014-01-07 13:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07 13:09 Question about videobuf2 with 0 buffers Ricardo Ribalda Delgado
2014-01-07 13:21 ` Hans Verkuil [this message]

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=52CBFF70.6010604@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=ricardo.ribalda@gmail.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.