[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <604a46db-b912-4b78-620e-1b1ba38fa130@xs4all.nl>
Date: Tue, 11 Sep 2018 10:48:30 +0200
From: Hans Verkuil <hverkuil@...all.nl>
To: Alexandre Courbot <acourbot@...omium.org>
Cc: Tomasz Figa <tfiga@...omium.org>,
Paul Kocialkowski <paul.kocialkowski@...tlin.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Pawel Osciak <posciak@...omium.org>,
Linux Media Mailing List <linux-media@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH] media: docs-rst: Document m2m stateless video decoder
interface
On 09/11/18 10:40, Alexandre Courbot wrote:
>> I am not sure whether this should be documented, but there are some additional
>> restrictions w.r.t. reference frames:
>>
>> Since decoders need access to the decoded reference frames there are some corner
>> cases that need to be checked:
>>
>> 1) V4L2_MEMORY_USERPTR cannot be used for the capture queue: the driver does not
>> know when a malloced but dequeued buffer is freed, so the reference frame
>> could suddenly be gone.
>
> It it is confirmed that we cannot use USERPTR buffers as CAPTURE then
> this probably needs to be documented. I wonder if there isn't a way to
> avoid this by having vb2 keep a reference to the pages in such a way
> that they would not be recycled after after userspace calls free() on
> the buffer. Is that possible with user-allocated memory?
vb2 keeps a reference while the buffer is queued, but that reference is
released once the buffer is dequeued. Correctly, IMHO. If you provide
USERPTR, than userspace is responsible for the memory. Changing this
would require changing the API, since USERPTR has always worked like
this.
>
> Not that I think that forbidding USERPTR buffers in this scenario
> would be a big problem.
I think it is perfectly OK to forbid this. Ideally I would like to have
some test in v4l2-compliance or (even better) v4l2-mem2mem.c for this,
but it is actually not that easy to identify drivers like this.
Suggestions for this on a postcard...
>
>>
>> 2) V4L2_MEMORY_DMABUF can be used, but drivers should check that the dma buffer is
>> still available AND increase the dmabuf refcount while it is used by the HW.
>
> Yeah, with DMABUF the above problem can easily be avoided at least.
>
>>
>> 3) What to do if userspace has requeued a buffer containing a reference frame,
>> and you want to decode a B/P-frame that refers to that buffer? We need to
>> check against that: I think that when you queue a capture buffer whose index
>> is used in a pending request as a reference frame, than that should fail with
>> an error. And trying to queue a request referring to a buffer that has been
>> requeued should also fail.
>>
>> We might need to add some support for this in v4l2-mem2mem.c or vb2.
>
> Sounds good, and we should document this as well.
>
Right. And test it!
Regards,
Hans
Powered by blists - more mailing lists