Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp815410pxb; Thu, 9 Sep 2021 12:42:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8CWAdiQll67gqCo9mTYmoEtQ5L9VWksMxQ4yA0Y1Cp4losExj8F0xi/lTU5Ovj/Ba8WV3 X-Received: by 2002:a92:c9cd:: with SMTP id k13mr3403263ilq.169.1631216560525; Thu, 09 Sep 2021 12:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631216560; cv=none; d=google.com; s=arc-20160816; b=nCbh1Oeo3KTCKUh+0+bjg5Xiir2l9g9YgvLCr252MLe1BNOpBDY5h8i+d73A9ZUM7/ EHafMJsPMrMpP922fZY6Co86PC5rUZXloO4U9wEIxWx3jBWb9ag3s1TMsP36l3sWKrCk RSYMrvbq4d7Nre7QexxR2H/yTlM4AgzAcT4DgpGSjt18qQuHdOrQrmY5kGdYQQ1m8F9J zMOxkThFu8mCmx5f26bM+CVsh96TOdGae3YndPCIOebnc0geaeWBhlcaguuKn5nXnklf bLb+iCfiyPGtRiLzXHj9KdCKNlK6HS/EVZ9YMrW3j/hHp4kckH4vOHftjG3907XSu6OT AjaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=omHK5HDlzER183cyZkTKOzYYGUkHjw3w9hbfK4BYqz0=; b=X0WnS5Si60IFGf9IOHOSW22Mx1aL3fp1rUH85WsUB7s4r89vYyfXukY0ce4fE+//co p5ADW4HRs6P7GqDKvZN754GIhy7IThB9vRG3zk5hxd/JipHt17IHsRF1kW/qOTDT7XkN W2LUoMW1KPp91b2mptBQOzyRej8QbABh0wPaFbfGoesR0ADWhpD3qS233W9LGoimm+B7 Q9S5vZxtNHUJJG0NlmTMUgGgRaHxGx7nXKs+VICuYTCQf9oaadLYEOvHDVEDyG+SDpBA 5QbgWvnJHgnLSGZJE67QwmfqK9G2dnNXx19BTxy5mORDJYr2HuKq+eHQYlNB7K4t7mnD WFZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b=m1cL1vnB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a125si2469186jaa.90.2021.09.09.12.42.19; Thu, 09 Sep 2021 12:42:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b=m1cL1vnB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343682AbhIITmE (ORCPT + 99 others); Thu, 9 Sep 2021 15:42:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344398AbhIITmC (ORCPT ); Thu, 9 Sep 2021 15:42:02 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 129BFC061760 for ; Thu, 9 Sep 2021 12:40:40 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id a22so3818732iok.12 for ; Thu, 09 Sep 2021 12:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ndufresne-ca.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=omHK5HDlzER183cyZkTKOzYYGUkHjw3w9hbfK4BYqz0=; b=m1cL1vnBIh5hnME0fLf/03QSDVpxtl/TeC8w1p53SYW3s3nbsQPmBzZNswhGPCD2cL uLw1epWGDYSTZ5MpekGlW6RbfG4AwAVq18FYKH6S3cgvisBWC9LtJfPjY/20E+SrmE6O JkQC+qtWTyOXOmnFd+Zg/hoJ6zJN+jDJYBaa9zvwgkx4fDYJTeFUbbMX0/WQBPgOPKoe /aogc93dSPCcoi8508bkUXFv+MP86oB72+wZoMiZSx7lhumVGBO6WnDgzNGy+TC6TTaJ b0IrQ3QY7P1K1l7nrievNvoAPSgnNtEf+rI4ft3P3fV+TmisPIHPcO3uANjijPWY927g T9vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=omHK5HDlzER183cyZkTKOzYYGUkHjw3w9hbfK4BYqz0=; b=lYfwZ0Yv1o7CNir8FjHdku/q5Z1OF2zwrGNntj/FPZsMduB1QoeLwULWSdAtJerTfR K4RiKkVpGV8nsc/MtcC2YBDrqfdIS6vxtkGRxBAo+1nqCs7TNRR5fy5TXKWlimrfbjvv hno7qlpUrN3RCzc4BzwdAEEtM4dQTUWwdoBXFLdWjPatcItsDur0OJYX5obtLE7tiR0b TcPo9heoXGg/jSy6OKd957OjZhFX9wzgKkNEhhsEP9I34uDHbABqaEGQxLlwsPoNCAIe L946PReE2WpE8yOyb737Q+ws710OTib/pwC1vdM9njyLnQIJ09j7ebf5IEyFRTjTKRpb U2Iw== X-Gm-Message-State: AOAM53031EhMzvQGM4sqca9CRbjqu4to+DnyKo/Tw+x+9ycwtRupfuQX WjPcMgNlCNfeZwVcUWUPERkaWw== X-Received: by 2002:a02:85c2:: with SMTP id d60mr1313582jai.85.1631216439428; Thu, 09 Sep 2021 12:40:39 -0700 (PDT) Received: from nicolas-tpx395.localdomain (mtl.collabora.ca. [66.171.169.34]) by smtp.gmail.com with ESMTPSA id m26sm1333222ioj.54.2021.09.09.12.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 12:40:38 -0700 (PDT) Message-ID: <868c17e24e0789838871167b008baf81b9876ef7.camel@ndufresne.ca> Subject: Re: [EXT] Re: [PATCH v8 03/15] media:Add v4l2 buf flag codec data. From: Nicolas Dufresne To: Ming Qian , "mchehab@kernel.org" , "shawnguo@kernel.org" , "robh+dt@kernel.org" , "s.hauer@pengutronix.de" Cc: "hverkuil-cisco@xs4all.nl" , "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , Aisheng Dong , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Date: Thu, 09 Sep 2021 15:40:36 -0400 In-Reply-To: References: <7ef1840137417c33f5ef7ca611c90fc274926851.1631002447.git.ming.qian@nxp.com> <79cdfe0af999f574642314289e1734df5e2032eb.camel@ndufresne.ca> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le jeudi 09 septembre 2021 à 02:20 +0000, Ming Qian a écrit : > > -----Original Message----- > > From: Nicolas Dufresne [mailto:nicolas@ndufresne.ca] > > Sent: Wednesday, September 8, 2021 9:15 PM > > To: Ming Qian ; mchehab@kernel.org; > > shawnguo@kernel.org; robh+dt@kernel.org; s.hauer@pengutronix.de > > Cc: hverkuil-cisco@xs4all.nl; kernel@pengutronix.de; festevam@gmail.com; > > dl-linux-imx ; Aisheng Dong ; > > linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; > > devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org > > Subject: [EXT] Re: [PATCH v8 03/15] media:Add v4l2 buf flag codec data. > > > > Caution: EXT Email > > > > Hi Ming, > > > > thanks for the patch. I'm doing a first pass review of the new APIs you are > > introducing. > > > > Le mardi 07 septembre 2021 à 17:49 +0800, Ming Qian a écrit : > > > In some decoing scenarios, application may queue a buffer that only > > > contains codec config data, and the driver needs to know whether is it > > > a frame or not. > > > So we add a buf flag to tell this case. > > > > > > Signed-off-by: Ming Qian > > > Signed-off-by: Shijie Qin > > > Signed-off-by: Zhou Peng > > > --- > > >  Documentation/userspace-api/media/v4l/buffer.rst | 7 +++++++ > > >  include/uapi/linux/videodev2.h | 1 + > > >  2 files changed, 8 insertions(+) > > > > > > diff --git a/Documentation/userspace-api/media/v4l/buffer.rst > > > b/Documentation/userspace-api/media/v4l/buffer.rst > > > index e991ba73d873..11013bcf8a41 100644 > > > --- a/Documentation/userspace-api/media/v4l/buffer.rst > > > +++ b/Documentation/userspace-api/media/v4l/buffer.rst > > > @@ -607,6 +607,13 @@ Buffer Flags > > >       the format. Any subsequent call to the > > >       :ref:`VIDIOC_DQBUF ` ioctl will not block anymore, > > >       but return an ``EPIPE`` error code. > > > + * .. _`V4L2-BUF-FLAG-CODECCONFIG`: > > > + > > > + - ``V4L2_BUF_FLAG_CODECCONFIG`` > > > + - 0x00200000 > > > + - The buffer only contains codec config data, eg. sps and pps. > > > + Applications can set this bit when ``type`` refers to an output > > > + stream, this flag is usually used by v4l2 decoder. > > > > Currently, the bottom line is that all decoders needs a frame or field > > accompanied with the headers (only Annex B. being defined and supported for > > now). Decoders can be more flexible (and some are). The documentation here > > is not clear enough, remember that we must not break compatibility. > > > > I think you have to clarify the intention. This flag exist in OMX and have > > been > > source of confusion and inter-operability since the start. > > > > - If this flag is entirely optional, and is just an optimization, then > > adding it this > > way is fine, but the documentation should be updated. > > > > - If this flag is required only when the header is split, then this flag > > need to be > > accompanied with a V4L2_BUF_CAP_SUPPORTS_SPLIT_CODECCONFIG (or > > similar name, shorter could be nice). This is so that userspace can detect > > if that > > feature is supported or not. > > > > - If having split codecconfig is strictly needed for your driver, then this > > flag is > > not the proper solution. The only solution I'd see for that, would be to use > > something else then V4L2_PIX_FMT_H264 so that existing userspace are not > > tricked into trying to use your driver the wrong way. I think such header > > could > > make sense with H264_NO_SC (though not super clear what this is exactly, > > it's > > not really used), or a clearer new format H264_AVCC/AVCC3 > > Hi Nicolas, > >     This flag is optional, and in fact, our driver doesn't want to receive a > splited header, > It's best that every buffer contains a frame. >     But in some case, the client may enqueue some buffer that only contains > the header data without any frame data. > And our driver need to know this case, for this type of buffer, we have two > cases to handle. >     1. ignore the timestamp. > 2. the amphion decoder needs a ring buffer for decoding, driver will > copy the coded data to the ring buffer, and update the write pointer, then > pass a frame count to firmware, firmware will use the frame count to determine > whether starting decoding a frame or not, if the frame count is incorrect, it > may led to vpu hang. So for this type of buffer, we won't increase the frame > count. > >     The flag is required only when the header is split, I agree with you that > it's better to add a capability flag. Actually our driver doesn't want meet > this case, but this situation does exist in some applications, I add this flag > to help handle it. >     Currently we meet this case in android platform. Thanks, that clarify were this comes from. Perhaps you could drop this from your initial patchset, and we can handle this separatly ? I remain a bit worried about the possible VPU hang, as the door is still wide open to DoS on this HW from random streams. Have you considered raising this issue to Amphion ? Perhaps there is a different way you could deal with partial frames ? > > > > > >      * .. _`V4L2-BUF-FLAG-REQUEST-FD`: > > > > > >        - ``V4L2_BUF_FLAG_REQUEST_FD`` > > > diff --git a/include/uapi/linux/videodev2.h > > > b/include/uapi/linux/videodev2.h index 167c0e40ec06..5bb0682b4a23 > > > 100644 > > > --- a/include/uapi/linux/videodev2.h > > > +++ b/include/uapi/linux/videodev2.h > > > @@ -1119,6 +1119,7 @@ static inline __u64 v4l2_timeval_to_ns(const > > struct timeval *tv) > > >  #define V4L2_BUF_FLAG_TSTAMP_SRC_SOE 0x00010000 > > >  /* mem2mem encoder/decoder */ > > >  #define V4L2_BUF_FLAG_LAST 0x00100000 > > > +#define V4L2_BUF_FLAG_CODECCONFIG 0x00200000 > > >  /* request_fd is valid */ > > >  #define V4L2_BUF_FLAG_REQUEST_FD 0x00800000 > > > > > >