Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3384195imm; Mon, 8 Oct 2018 03:09:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV61rxzjwgU64NuwG1mvjoC7XsOYigY3rViJ1NJOLzmtRdFuKG1Qgv8clFdD3Xtq4bg9rZKS8 X-Received: by 2002:a62:3995:: with SMTP id u21-v6mr24544100pfj.116.1538993355965; Mon, 08 Oct 2018 03:09:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538993355; cv=none; d=google.com; s=arc-20160816; b=yb29WGJGKwvx0eoamXg29YUVaSsgdOAf9aDc3Aipp9kTj9HgYo5GW9K9NV6i05M0Qc wcwIf+NmzGma3Tu84PP+2ua+iNURmpGgDHeX37KhUXc/d0nA3Je/KeSIhWDUBhuaWUj2 03YHXYL/L+YM6Jen3aiF0K8ZwxqWj0z9SvIwnFG2OeHXmXe/NaLpYLHfbzdd9PraMFoE Je7OK74EPeifM0NatvZGgA9OLF6N9H/q0CjWjO8yrhjROvxfmZTGce9m+zPzWZNLZbCS JWvEL1zOKjKwmzosTiNDtksigu0o4MawN9s8I6LFfuknFl491AJLYFenuX5YNbZa7J0Y dPRQ== 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=V41Ez5SXVatIHehXtkOKf+iPk/e8lEnlmbhRsI5qJwQ=; b=YY7qllUltwWbJcduaKat8fEhxp3lZ7mNbYFBNJh9fw5KfiCu5o7eihNNU8cHnsPmXT BCBffsUnQns/Mz2pmVshWh1e2HfA10eddk4lX5oeIbXPAweX00x4HLYYBBb3oU4Mf0A4 zRX6EBu09nexvrIZpZon7iovT+ZlMjM+wejoHxT5lPceQq5qusHn0U0UwCYjDjKQLTYs nYNaPb3ay0exqMyxk6ZSiv1m87rHtqH9W0hvN0JN15ByLAk7NRPM6UuXsK+LIJF8Qjjy FIusLYNeX45d9dU192WqYWuqUDwk6xvTBcIM9Zvt5HWyYUA93v78xUJ8TsgTI0P53JdR x8vg== 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 go3si17385162plb.266.2018.10.08.03.09.01; Mon, 08 Oct 2018 03:09:15 -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 S1727658AbeJHRSJ (ORCPT + 99 others); Mon, 8 Oct 2018 13:18:09 -0400 Received: from lb1-smtp-cloud9.xs4all.net ([194.109.24.22]:38722 "EHLO lb1-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbeJHRSJ (ORCPT ); Mon, 8 Oct 2018 13:18:09 -0400 Received: from [192.168.2.10] ([212.251.195.8]) by smtp-cloud9.xs4all.net with ESMTPA id 9SRPgLSKkSskC9SRSgfo7b; Mon, 08 Oct 2018 12:07:11 +0200 Subject: Re: [RFC PATCH] media: docs-rst: Document m2m stateless video decoder interface To: Tomasz Figa Cc: Alexandre Courbot , Paul Kocialkowski , Mauro Carvalho Chehab , Pawel Osciak , Linux Media Mailing List , Linux Kernel Mailing List References: <20180831074743.235010-1-acourbot@chromium.org> <604a46db-b912-4b78-620e-1b1ba38fa130@xs4all.nl> From: Hans Verkuil Message-ID: <3cd8e2f0-d9c1-6907-d16b-d3c6699c9ef8@xs4all.nl> Date: Mon, 8 Oct 2018 12:07:07 +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: MS4wfNAxquIzA7cZ3tn0fzN9rBt3jCQYlWMS6EWXme12TvrCg1NBglqxdQZTYh8LBcA0U99zhMWvLiQy9XLeKEkXD0tt3sm3hm2MBC1XMH1m2n7HAcO9VLn0 VVDwMPFjSXXeyaLQdQ89bgkTVA10RgA2YC6oqWbUXN1KqWG93wReFFaV/gRul5k/jeo8s2t77W++QSVUFI13niAYAYuVQoOUlMKIZWEzlY302AD9eLdk4lA3 yPFe80puYk57UC6mQgELwx6n3p/hHS9IR++wg3+HWfTLyrnUBczftny1+hlBLMbx4TLbpRZ3aWb9Z1dJstW06ZNb8G4m/2qJwp+O771G5cJvjrQppCVsnFiA H4S1JK36uH5msLjGKU5W16s7dupUITfx0/ZqZCRqRGGsbIKyTHM= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/03/2018 12:10 PM, Tomasz Figa wrote: > On Tue, Sep 11, 2018 at 5:48 PM Hans Verkuil wrote: >> >> 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. > > That would be a userspace bug wouldn't it? The next try to get user > pages would fail in that case and we could just fail such decode > request, couldn't we? > > (Personally I'm not a big fan of USERPTR, though.) Yes, just don't support USERPTR for drivers like this. USERPTR just doesn't make sense. > >> >>> >>> 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. Perhaps an error is overkill, but I think a warning should be issued. And trying to queue a request referring to a buffer that has been requeued should also fail. I don't think this is right, this is likely a valid case. Regards, Hans >>>> >>>> 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! > > I'm not convinced that we should be enforcing this. Moreover, > requeuing a buffer containing a reference frame for a pending request > is not bound to be an error. It might be a legit case when the same > entry in the reference list is replaced with a different key frame > decoded into the same buffer as the reference list entry pointed until > now. > > Best regards, > Tomasz >