Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3780389imm; Tue, 11 Sep 2018 01:50:52 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ+HPn2ycgBdP4qxAcdj/obxQcL0IzaypxqZdtbtYqJIx8pNCpRBU/AG/u4Yd00wqgAyjJK X-Received: by 2002:a17:902:163:: with SMTP id 90-v6mr25974208plb.322.1536655852604; Tue, 11 Sep 2018 01:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536655852; cv=none; d=google.com; s=arc-20160816; b=OnmiCB+OG1ELci3drFbJQzqEo+VptxmDgkIrz+YeWSrIuul455w3tB5w2Wrc5XZ+QW z3tcLL3jxuwv46R3OksyM73WBu9T6/60tVgNwxe9ANPkuyqH4PEX7cqxHKLE4yQAPNw7 LaaSdkoTkWxbOxt651indRrwVyePzJtVc64PQJUVYdSV+C9JNKfHqcyTVczRQy/WzxEG 1UesSbwk7GV4qu8ijyJ67twUSnZ+6uTi7hsStHaCbq6MMXprhrf0MoHRodEEHl0ky+qW s6b887UtZP83rnLKMvpLHe8wUJ+RktB5RK674qzhw8jgKaE8+Lz0UT7Muy6Ve7rxpoin mH+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=3sSBfqn0zw4kJ/nddokcsdjtLIkrv9we2UK3M0X0LOg=; b=Tr3wqt4OO6KxEB+TNqIjowQICYxYbiGbQsgOBmx5OxqBEB9NUznUXSn++HNUoqrxEC QzqIq7GNzr8dHB3k9LcYIpkmHOCe8bg7baJOXV7HB3ejLQFIRk+I7JNmRX5yp2UXhG8F 4iEnfyzrgEc3oQQaBF480EjISZP60S6ES/xgAoFIkbmqqwQIlIMY5m38NArg3pKFR3A8 wVeBnQitPMkOtzA3FHeAFW9KZJO45AayP/y6iuOuN7KlqN0EEcJtIvXrk18RWuWxykHW /r3TaT3oZSjeqJACyuXizN5Asn2p0z66xkP0ybhVmkoehMQSHP+87RZGDbUhqPpR/yyJ nB9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m61-v6si18924549plb.296.2018.09.11.01.50.36; Tue, 11 Sep 2018 01:50:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726992AbeIKNqy (ORCPT + 99 others); Tue, 11 Sep 2018 09:46:54 -0400 Received: from lb3-smtp-cloud8.xs4all.net ([194.109.24.29]:49515 "EHLO lb3-smtp-cloud8.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726804AbeIKNqy (ORCPT ); Tue, 11 Sep 2018 09:46:54 -0400 Received: from [IPv6:2001:420:44c1:2579:b9e5:7489:b855:62dc] ([IPv6:2001:420:44c1:2579:b9e5:7489:b855:62dc]) by smtp-cloud8.xs4all.net with ESMTPA id zeLWfIHvSxO9BzeLafOEqc; Tue, 11 Sep 2018 10:48:34 +0200 Subject: Re: [RFC PATCH] media: docs-rst: Document m2m stateless video decoder interface To: Alexandre Courbot Cc: Tomasz Figa , Paul Kocialkowski , Mauro Carvalho Chehab , Pawel Osciak , Linux Media Mailing List , LKML References: <20180831074743.235010-1-acourbot@chromium.org> From: Hans Verkuil Message-ID: <604a46db-b912-4b78-620e-1b1ba38fa130@xs4all.nl> Date: Tue, 11 Sep 2018 10:48:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfJh93DE2XSuNkuponYojTKQqcYOxqnLGy2SO/4ViTMw7tL5dL2tGtoccD/Ypi/W9KtvXi30hWlxrGps3XHJbSoXKPeeDUAXdH01gmCv+8pNWiYUF+zkU C0UgaZmpce3JfJPH/GrxnaD1urbDis2qM0b/NbpThYmCk0dDrd3MbcdvQsCX67wfBHsmTRg2txQPsaLPL8lz2LH47QnOu7zh5Fq+Ictk0nwvUnDsuAByhots H+JIBQ6xChIfbrkXT6A7JhBiPZz8hw2+RVn31uPRVtU41/lS58lti8eEHBH0bDPRbMciI/eE29o+MZZLZjdB3y3EWyvs16k6nCn6gTu/9nWQM7HY++Q57Q8o fYFmqn+D0SQQyv4Nlk3CXKIaDszwLucVJCBz1eINiCs/ikfNkB4fRx2t4s8BSdsrhAmr522xIzF2JUJ4U3NX9RxTS8JCmS1HFZzyQAWfFPB3rvtAl4dSjLDH QxvP/X8b63rGWrdRGi80qnGeaIXWsyXgca/NOw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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