Message ID | 20230704040044.681850-2-randy.li@synaptics.com (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Hans Verkuil |
Headers |
Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from <linux-media-owner@vger.kernel.org>) id 1qGXER-00BcRV-Pb; Tue, 04 Jul 2023 04:01:40 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230349AbjGDEBa (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Tue, 4 Jul 2023 00:01:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjGDEB0 (ORCPT <rfc822;linux-media@vger.kernel.org>); Tue, 4 Jul 2023 00:01:26 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2051.outbound.protection.outlook.com [40.107.237.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90F18BD; Mon, 3 Jul 2023 21:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DRLCS80FmZ41R/YL/Qh4JKzgNvRpMe2l0H+4Tmaxh19MQPLJfnRZXkN+foCHBQI43sqvTNZSj0rh64FI7Z7BDwFUT0dLQ6LFufLwJ3y50RdKvPZERgD4yHmF9D2/zwyo+uUOcmydUI6+vKP9sGYaYkLZnCBrsCV/S9wjMkDRrogHhHETDw1jhBJgNS35BnEXJijnWqyJxKtbIoQy9H0OQ+F++1YMLeAuSFylh4eh6yMXyNrLnCMoXq+Axn+dNvfV6iUZG12xUsu5P1XGykFQsygkpxbtS2tH30G1w2HgJmrR61ojFprXkMlY8d6cchqKRKeZDmWhmXPYZKtsfL89cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NsMM36UqzhKEjKgE2pwo9jHkKFQeeJqCCp6Gh6EQJDg=; b=MOgpWnxITQAcDC6Q1ycMRN2vFLiBuUvMMYkV59YPmmA1qjpgN4axE8DwMKyX04BU0ril4PxQM5LdzjeUUZZRzy5fiRHBWaMtxG/iT+yaD2SzpJksOFW932DUa+oEHLZo6b0INdM6qoR3DvFgbe4X2I1bgvhgbD8sUs6Ux4axzHXDxLy5QWexzhWtmy0gfqGS3MbNMYnTRW3QJxKsvEtsDtSRvRteMs/6UtnvVujJf2FBGq2jMxR8xLfo6qpQKJp3i9RP6iwJk3Fzba51FYy/6ip5EIC4VUj0IidXFekmGH0B6hBDtUS56Rbaq+6ZZwW5E0KR3wvnD73DhDI4XPy+fg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NsMM36UqzhKEjKgE2pwo9jHkKFQeeJqCCp6Gh6EQJDg=; b=NMx2X7UpYvvAJ5/sJtLsAp99ZU4crk8Yy4cKN0E9OLP052ni1qpTzg/o8cGZNW/PmBwVI9xNKC9iADk0co+HrFmyzDlxTej+zK5BLCIFOagXe6aUAQ7IfA7+/21kfHNe6lC8qt5rgYcL9u5RGjmnZV7M3XIqRYZEWXQtu+r397M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=synaptics.com; Received: from DM6PR03MB5196.namprd03.prod.outlook.com (2603:10b6:5:24a::19) by CH3PR03MB7385.namprd03.prod.outlook.com (2603:10b6:610:19a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Tue, 4 Jul 2023 04:01:24 +0000 Received: from DM6PR03MB5196.namprd03.prod.outlook.com ([fe80::6882:b9c1:2b2d:998d]) by DM6PR03MB5196.namprd03.prod.outlook.com ([fe80::6882:b9c1:2b2d:998d%5]) with mapi id 15.20.6544.024; Tue, 4 Jul 2023 04:01:24 +0000 From: Hsia-Jun Li <randy.li@synaptics.com> To: linux-media@vger.kernel.org Cc: ayaka@soulik.info, hans.verkuil@cisco.com, tfiga@chromium.org, mchehab@kernel.org, laurent.pinchart@ideasonboard.com, hiroh@chromium.org, hverkuil@xs4all.nl, linux-kernel@vger.kernel.org, nicolas@ndufresne.ca Subject: [PATCH 1/2] [RESEND] media: v4l2-mem2mem: allow device run without buf Date: Tue, 4 Jul 2023 12:00:37 +0800 Message-ID: <20230704040044.681850-2-randy.li@synaptics.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230704040044.681850-1-randy.li@synaptics.com> References: <20230704040044.681850-1-randy.li@synaptics.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BYAPR01CA0041.prod.exchangelabs.com (2603:10b6:a03:94::18) To DM6PR03MB5196.namprd03.prod.outlook.com (2603:10b6:5:24a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR03MB5196:EE_|CH3PR03MB7385:EE_ X-MS-Office365-Filtering-Correlation-Id: b1a6df36-b3a4-467e-659c-08db7c435541 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cijH728WfPOr+C25UlKIftPHRp14FOtQi//uGPqyT/DG6+6czj+u/40b38tuR0ARBuc4e8uQPJjsqD8X5KxvYqA2BJOytcalch8fCs8U+FpOHh0Q8oyVev6SoerfTwPwy3nyFbcG2RIgK576lKZ2oxqBSfzFWW/AHnDVc8mMhqNWjw63mLnSG0eqW4T5QODgbqEPq395Ne5ly0pos1nlJyoi0I42AlKcD6JbZYgDq95hFH6fsn6putRmQWN/Agnb62GArnzcScbVhTP8sCsZc2syvJ6IHmNylYRan240NjoTSoo0iBV1zXTkmq4m9szgMWylF9MrvfuX6qMZtx+Sd6tau8GtiMeXYUi8bJ44dcS3YYwYQbt5V/j0PpdSAF3AbIsz7ywrU0uH3KHXjc+X8e/3Cgz1MJtUaa9pNAGUcGoOo/ZEGboeiJcxIOtcPVilD7UWYZnxIQB4C2BCNMQK3OzVuMlyupW0GBrCavn328V1Fjb1LL56TASdJ5i4nutXOGU+0LJYMW3Yw0EGEjQTaREruS/rSg20OfR1abBOMZmX+ub3ytPXmLIvVtI75CIB6GMqof6ifUrYtcHMPkm0+kHq5xQ80KtAkhdDKSUfI3VheJet88eE4w2uSJ8Nq1hK X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR03MB5196.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(366004)(396003)(376002)(136003)(451199021)(41300700001)(38100700002)(6666004)(38350700002)(52116002)(2616005)(83380400001)(6506007)(26005)(186003)(1076003)(6512007)(86362001)(6486002)(478600001)(316002)(2906002)(36756003)(66476007)(4326008)(66556008)(66946007)(8936002)(8676002)(6916009)(7416002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S9c2e0EKXRY/Iw5cgaTyKy18ftWo2zlqdDbVyfz3M8YqfVtdVBBfSmwmeH8/HPpkeLx9QrNfVpMQleixWE93dpmAGUDchETwh0xcuww7cmERmebmZoV5zzYhUcRVMidJryUKxKAD/vvMQvN7XWQxcxFM2mkv6nuZaB/JaG3ICmTqzrLpQKp1Csxgu/LYFiqpjDBOd6c5k+Tmgitr+zbjKT+qhwVYuvlhqdXRyr5MXzdjP6LVXG/FCIQ/SVQkuFgsTkn/tM5ktXB99nVI/n5w0qyFbTbQwMKo3Sv3SUhcja/s6rYYxC/bIDAJrVsQXgASs++zjG5BZ6OtJdgXCNCdLresSfVc8+MfIwW3fMo/G+KIVHs4dMvysyhJTBs45tZr0LYKLBwL9kvzaQnd3CiEdZTUiK2XnEO+4SmXUpAECqQYMR2XJ1KQvgiF07W9Je2ySj+fmcKAMH5hSwCb2zu94HPeePnZpq3iRcwJUBbFGSNQZiKnKIrB4CuWB3+1S6Okpm9MVe7vJxSWnCwFiiQpkH9shRqtFF1oy1NYT3z07RjliEX2Tw+EWRyqc92zjxpvr7fHICjjzxW3uGk6S9+GJsZGJ/8N9J4cISOjuYIl6Hgbc7qilgJsDHv/7P8xKUNzPwqJZkb/rarlq+LhFMeSaVTT2nXCaRTJ4mPG9b+6mSAmCiMPuoK0c5APfO6iPuIM9enVWW+EYOKK/zPJTznDHMmupzJUkEoWBvGLc6iQAr5AZ3+OnfgHpruXDBaQNKpwWiRR7+LjVHjqhDW82rAcbwapY/RZum3EKwdtv8H4tnHwT7GVPgMYEYGG3MCbrHv/Oj0Cm+6UjMt3Z/T690uX6qAK8bwXX/uC+GgyFTZlKRfbSUdBAPw0zctNYGfIh05rRfqZttJ0bOIfPVSZ5IBCN9r0Ls0qRxLU1Vf7brNphZtTKDC/AvgaoRy987BmecQ/XLPY2r6PL4Atfb1A/OXyYeQY/LCdWXZY+bENZxwMaPgaCbiAFH1YhjOiVdev4XJDHqTVG5auZsIRkUJP0nRJFL8klhbwAPlZUvfJU9xg0kxpKlvEHcdIn++o3by2lwbNKiRp+Ku+fjNbUrt04VjPsFgeso641lz8AhnYEN67t9TkaxmF3saSMsTfS/F7CCTPn0bYZJOhxGu7R9Dv64r7xOvfOmWfij9KPHu7ROLCy09xb7WlhxAzxgr0FhmKF67Epiim5/NhbentMT3qnIL3inL+15QVS9Rk20hPkUOJxeW2JCM+Z1Jkg6qPeHdBIs7G9rkbWFI8wW8ZhVKkJvC9lvzPs7usspR1ChWMr8SFJ/UxUyhBFFle9p/9qiF/l/Mspy3hyyy75qUrXJ46DwyeYJLWh4APBLD8GkAgjne8jZzk7wTh6pX95Ee37r8YKUgPKn3wvxJXZHeGvD7Zfn63JNuViXt/F832DC62QajHO6kuBzpwlO5dFUPEzXujw6PQHIkTsUj29Cc3JOlGprNMnU6IQbLBgIB8kpljWqN32fG8cyxH9u6d2wJ4pFkdlpMrDTo73T9gTFNNo5cc9nc74l3schN/+Ngurww93zBTcV3nRrq8Csd+CqkI3K0DUJCY X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1a6df36-b3a4-467e-659c-08db7c435541 X-MS-Exchange-CrossTenant-AuthSource: DM6PR03MB5196.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2023 04:01:24.0959 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zcO32NesmgHI7SYnS8QSsuPZVTl1cE2JgonlTCww6ZGFWmH/RcorOSFd+Oe6Z9W3RpvqmwZiwPFbgSnUNTmhGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR03MB7385 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.7 (----) X-LSpam-Report: No, score=-4.7 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_MED=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no |
Series |
Improve V4L2 M2M job scheduler
|
|
Commit Message
Hsia-Jun Li
July 4, 2023, 4 a.m. UTC
From: Randy Li <ayaka@soulik.info> For the decoder supports Dynamic Resolution Change, we don't need to allocate any CAPTURE or graphics buffer for them at inital CAPTURE setup step. We need to make the device run or we can't get those metadata. Signed-off-by: Randy Li <ayaka@soulik.info> --- drivers/media/v4l2-core/v4l2-mem2mem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Comments
Hi Randy, Le mardi 04 juillet 2023 à 12:00 +0800, Hsia-Jun Li a écrit : > From: Randy Li <ayaka@soulik.info> > > For the decoder supports Dynamic Resolution Change, > we don't need to allocate any CAPTURE or graphics buffer > for them at inital CAPTURE setup step. > > We need to make the device run or we can't get those > metadata. > > Signed-off-by: Randy Li <ayaka@soulik.info> > --- > drivers/media/v4l2-core/v4l2-mem2mem.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c > index 0cc30397fbad..c771aba42015 100644 > --- a/drivers/media/v4l2-core/v4l2-mem2mem.c > +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c > @@ -301,8 +301,9 @@ static void __v4l2_m2m_try_queue(struct v4l2_m2m_dev *m2m_dev, > > dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx); > > - if (!m2m_ctx->out_q_ctx.q.streaming > - || !m2m_ctx->cap_q_ctx.q.streaming) { > + if (!(m2m_ctx->out_q_ctx.q.streaming || m2m_ctx->out_q_ctx.buffered) > + || !(m2m_ctx->cap_q_ctx.q.streaming > + || m2m_ctx->cap_q_ctx.buffered)) { I have a two atches with similar goals in my wave5 tree. It will be easier to upstream with an actual user, though, I'm probably a month or two away from submitting this driver again. https://gitlab.collabora.com/chipsnmedia/kernel/-/commit/ac59eafd5076c4deb3bfe1fb85b3b776586ef3eb https://gitlab.collabora.com/chipsnmedia/kernel/-/commit/5de4fbe0abb20b8e8d862b654f93e3efeb1ef251 Sebastien and I authored this without giving it much thought, but we believe this massively simplify our handling of DRC (dynamic resolution change). The main difference, is that we added ignore_streaming to the ctx, so that drivers can opt-in the mode of operation. Thinking it would avoid any potential side effects in drivers that aren't prepared to that. We didn't want to tied it up to buffered, this is open to discussion of course, we do use buffered on both queues and use a slightly more advance job_ready function, that take into account our driver state. In short, Sebastien and I agree this small change is the right direction, we simply have a different implementation. I can send it as RFC if one believe its would be useful now (even without a user). > dprintk("Streaming needs to be on for both queues\n"); > return; > }
On Fri, Jul 07, 2023 at 03:14:23PM -0400, Nicolas Dufresne wrote: > Hi Randy, > > Le mardi 04 juillet 2023 à 12:00 +0800, Hsia-Jun Li a écrit : > > From: Randy Li <ayaka@soulik.info> > > > > For the decoder supports Dynamic Resolution Change, > > we don't need to allocate any CAPTURE or graphics buffer > > for them at inital CAPTURE setup step. > > > > We need to make the device run or we can't get those > > metadata. > > > > Signed-off-by: Randy Li <ayaka@soulik.info> > > --- > > drivers/media/v4l2-core/v4l2-mem2mem.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c > > index 0cc30397fbad..c771aba42015 100644 > > --- a/drivers/media/v4l2-core/v4l2-mem2mem.c > > +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c > > @@ -301,8 +301,9 @@ static void __v4l2_m2m_try_queue(struct v4l2_m2m_dev *m2m_dev, > > > > dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx); > > > > - if (!m2m_ctx->out_q_ctx.q.streaming > > - || !m2m_ctx->cap_q_ctx.q.streaming) { > > + if (!(m2m_ctx->out_q_ctx.q.streaming || m2m_ctx->out_q_ctx.buffered) > > + || !(m2m_ctx->cap_q_ctx.q.streaming > > + || m2m_ctx->cap_q_ctx.buffered)) { > > I have a two atches with similar goals in my wave5 tree. It will be easier to > upstream with an actual user, though, I'm probably a month or two away from > submitting this driver again. > > https://gitlab.collabora.com/chipsnmedia/kernel/-/commit/ac59eafd5076c4deb3bfe1fb85b3b776586ef3eb > https://gitlab.collabora.com/chipsnmedia/kernel/-/commit/5de4fbe0abb20b8e8d862b654f93e3efeb1ef251 > While I'm not going to NAK this series or those 2 patches if you send them, I'm not really convinced that adding more and more complexity to the mem2mem helpers is a good idea, especially since all of those seem to be only needed by stateful video decoders. The mem2mem framework started as a set of helpers to eliminate boiler plate from simple drivers that always get 1 CAPTURE and 1 OUTPUT buffer, run 1 processing job on them and then return both of the to the userspace and I think it should stay like this. I think we're strongly in need of a stateful video decoder framework that would actually address the exact problems that those have rather than bending something that wasn't designed with them in mind to work around the differences. Best regards, Tomasz > Sebastien and I authored this without giving it much thought, but we believe > this massively simplify our handling of DRC (dynamic resolution change). > > The main difference, is that we added ignore_streaming to the ctx, so that > drivers can opt-in the mode of operation. Thinking it would avoid any potential > side effects in drivers that aren't prepared to that. We didn't want to tied it > up to buffered, this is open to discussion of course, we do use buffered on both > queues and use a slightly more advance job_ready function, that take into > account our driver state. > > In short, Sebastien and I agree this small change is the right direction, we > simply have a different implementation. I can send it as RFC if one believe its > would be useful now (even without a user). > > > dprintk("Streaming needs to be on for both queues\n"); > > return; > > } >
Hey Tomasz, On 12.07.2023 09:31, Tomasz Figa wrote: >On Fri, Jul 07, 2023 at 03:14:23PM -0400, Nicolas Dufresne wrote: >> Hi Randy, >> >> Le mardi 04 juillet 2023 à 12:00 +0800, Hsia-Jun Li a écrit : >> > From: Randy Li <ayaka@soulik.info> >> > >> > For the decoder supports Dynamic Resolution Change, >> > we don't need to allocate any CAPTURE or graphics buffer >> > for them at inital CAPTURE setup step. >> > >> > We need to make the device run or we can't get those >> > metadata. >> > >> > Signed-off-by: Randy Li <ayaka@soulik.info> >> > --- >> > drivers/media/v4l2-core/v4l2-mem2mem.c | 5 +++-- >> > 1 file changed, 3 insertions(+), 2 deletions(-) >> > >> > diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c >> > index 0cc30397fbad..c771aba42015 100644 >> > --- a/drivers/media/v4l2-core/v4l2-mem2mem.c >> > +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c >> > @@ -301,8 +301,9 @@ static void __v4l2_m2m_try_queue(struct v4l2_m2m_dev *m2m_dev, >> > >> > dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx); >> > >> > - if (!m2m_ctx->out_q_ctx.q.streaming >> > - || !m2m_ctx->cap_q_ctx.q.streaming) { >> > + if (!(m2m_ctx->out_q_ctx.q.streaming || m2m_ctx->out_q_ctx.buffered) >> > + || !(m2m_ctx->cap_q_ctx.q.streaming >> > + || m2m_ctx->cap_q_ctx.buffered)) { >> >> I have a two atches with similar goals in my wave5 tree. It will be easier to >> upstream with an actual user, though, I'm probably a month or two away from >> submitting this driver again. >> >> https://gitlab.collabora.com/chipsnmedia/kernel/-/commit/ac59eafd5076c4deb3bfe1fb85b3b776586ef3eb >> https://gitlab.collabora.com/chipsnmedia/kernel/-/commit/5de4fbe0abb20b8e8d862b654f93e3efeb1ef251 >> > >While I'm not going to NAK this series or those 2 patches if you send >them, I'm not really convinced that adding more and more complexity to >the mem2mem helpers is a good idea, especially since all of those seem >to be only needed by stateful video decoders. > >The mem2mem framework started as a set of helpers to eliminate boiler >plate from simple drivers that always get 1 CAPTURE and 1 OUTPUT buffer, >run 1 processing job on them and then return both of the to the userspace >and I think it should stay like this. > >I think we're strongly in need of a stateful video decoder framework that >would actually address the exact problems that those have rather than >bending something that wasn't designed with them in mind to work around the >differences. Thanks for the feedback. I have recently discussed how we could approach creating a framework for the codecs side, with Hans Verkuil and Nicolas Dufresne. The first step we would have to do is come up with a list of requirements for that framework and expected future needs, maybe we can start a public discussion on the mailing list to generate a list like that. But all in all this endeavor will probably require quite a bit of time and effort, do you think we could modify M2M a bit for our use case and then when we are in the process of creating the new framework, we could maybe think about simplifying the M2M framework again? > >Best regards, >Tomasz Greetings, Sebastian > >> Sebastien and I authored this without giving it much thought, but we believe >> this massively simplify our handling of DRC (dynamic resolution change). >> >> The main difference, is that we added ignore_streaming to the ctx, so that >> drivers can opt-in the mode of operation. Thinking it would avoid any potential >> side effects in drivers that aren't prepared to that. We didn't want to tied it >> up to buffered, this is open to discussion of course, we do use buffered on both >> queues and use a slightly more advance job_ready function, that take into >> account our driver state. >> >> In short, Sebastien and I agree this small change is the right direction, we >> simply have a different implementation. I can send it as RFC if one believe its >> would be useful now (even without a user). >> >> > dprintk("Streaming needs to be on for both queues\n"); >> > return; >> > } >>
On Wed, Jul 12, 2023 at 6:44 PM Sebastian Fricke <sebastian.fricke@collabora.com> wrote: > > Hey Tomasz, > > On 12.07.2023 09:31, Tomasz Figa wrote: > >On Fri, Jul 07, 2023 at 03:14:23PM -0400, Nicolas Dufresne wrote: > >> Hi Randy, > >> > >> Le mardi 04 juillet 2023 à 12:00 +0800, Hsia-Jun Li a écrit : > >> > From: Randy Li <ayaka@soulik.info> > >> > > >> > For the decoder supports Dynamic Resolution Change, > >> > we don't need to allocate any CAPTURE or graphics buffer > >> > for them at inital CAPTURE setup step. > >> > > >> > We need to make the device run or we can't get those > >> > metadata. > >> > > >> > Signed-off-by: Randy Li <ayaka@soulik.info> > >> > --- > >> > drivers/media/v4l2-core/v4l2-mem2mem.c | 5 +++-- > >> > 1 file changed, 3 insertions(+), 2 deletions(-) > >> > > >> > diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c > >> > index 0cc30397fbad..c771aba42015 100644 > >> > --- a/drivers/media/v4l2-core/v4l2-mem2mem.c > >> > +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c > >> > @@ -301,8 +301,9 @@ static void __v4l2_m2m_try_queue(struct v4l2_m2m_dev *m2m_dev, > >> > > >> > dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx); > >> > > >> > - if (!m2m_ctx->out_q_ctx.q.streaming > >> > - || !m2m_ctx->cap_q_ctx.q.streaming) { > >> > + if (!(m2m_ctx->out_q_ctx.q.streaming || m2m_ctx->out_q_ctx.buffered) > >> > + || !(m2m_ctx->cap_q_ctx.q.streaming > >> > + || m2m_ctx->cap_q_ctx.buffered)) { > >> > >> I have a two atches with similar goals in my wave5 tree. It will be easier to > >> upstream with an actual user, though, I'm probably a month or two away from > >> submitting this driver again. > >> > >> https://gitlab.collabora.com/chipsnmedia/kernel/-/commit/ac59eafd5076c4deb3bfe1fb85b3b776586ef3eb > >> https://gitlab.collabora.com/chipsnmedia/kernel/-/commit/5de4fbe0abb20b8e8d862b654f93e3efeb1ef251 > >> > > > >While I'm not going to NAK this series or those 2 patches if you send > >them, I'm not really convinced that adding more and more complexity to > >the mem2mem helpers is a good idea, especially since all of those seem > >to be only needed by stateful video decoders. > > > >The mem2mem framework started as a set of helpers to eliminate boiler > >plate from simple drivers that always get 1 CAPTURE and 1 OUTPUT buffer, > >run 1 processing job on them and then return both of the to the userspace > >and I think it should stay like this. > > > >I think we're strongly in need of a stateful video decoder framework that > >would actually address the exact problems that those have rather than > >bending something that wasn't designed with them in mind to work around the > >differences. > > Thanks for the feedback. > > I have recently discussed how we could approach creating a framework for > the codecs side, with Hans Verkuil and Nicolas Dufresne. That's great to hear, thanks. :) > > The first step we would have to do is come up with a list of > requirements for that framework and expected future needs, maybe we can > start a public discussion on the mailing list to generate a list like > that. Makes sense. Let me CC some ChromeOS folks working on video codec drivers these days. > But all in all this endeavor will probably require quite a bit of time > and effort, do you think we could modify M2M a bit for our use case and > then when we are in the process of creating the new framework, we could > maybe think about simplifying the M2M framework again? Sure, as I said, I'm not NAKing this series. > > > > >Best regards, > >Tomasz > > Greetings, > Sebastian > > > > >> Sebastien and I authored this without giving it much thought, but we believe > >> this massively simplify our handling of DRC (dynamic resolution change). > >> > >> The main difference, is that we added ignore_streaming to the ctx, so that > >> drivers can opt-in the mode of operation. Thinking it would avoid any potential > >> side effects in drivers that aren't prepared to that. We didn't want to tied it > >> up to buffered, this is open to discussion of course, we do use buffered on both > >> queues and use a slightly more advance job_ready function, that take into > >> account our driver state. > >> > >> In short, Sebastien and I agree this small change is the right direction, we > >> simply have a different implementation. I can send it as RFC if one believe its > >> would be useful now (even without a user). > >> > >> > dprintk("Streaming needs to be on for both queues\n"); > >> > return; > >> > } > >>
Le mercredi 12 juillet 2023 à 09:31 +0000, Tomasz Figa a écrit : > On Fri, Jul 07, 2023 at 03:14:23PM -0400, Nicolas Dufresne wrote: > > Hi Randy, > > > > Le mardi 04 juillet 2023 à 12:00 +0800, Hsia-Jun Li a écrit : > > > From: Randy Li <ayaka@soulik.info> > > > > > > For the decoder supports Dynamic Resolution Change, > > > we don't need to allocate any CAPTURE or graphics buffer > > > for them at inital CAPTURE setup step. > > > > > > We need to make the device run or we can't get those > > > metadata. > > > > > > Signed-off-by: Randy Li <ayaka@soulik.info> > > > --- > > > drivers/media/v4l2-core/v4l2-mem2mem.c | 5 +++-- > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c > > > index 0cc30397fbad..c771aba42015 100644 > > > --- a/drivers/media/v4l2-core/v4l2-mem2mem.c > > > +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c > > > @@ -301,8 +301,9 @@ static void __v4l2_m2m_try_queue(struct v4l2_m2m_dev *m2m_dev, > > > > > > dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx); > > > > > > - if (!m2m_ctx->out_q_ctx.q.streaming > > > - || !m2m_ctx->cap_q_ctx.q.streaming) { > > > + if (!(m2m_ctx->out_q_ctx.q.streaming || m2m_ctx->out_q_ctx.buffered) > > > + || !(m2m_ctx->cap_q_ctx.q.streaming > > > + || m2m_ctx->cap_q_ctx.buffered)) { > > > > I have a two atches with similar goals in my wave5 tree. It will be easier to > > upstream with an actual user, though, I'm probably a month or two away from > > submitting this driver again. > > > > https://gitlab.collabora.com/chipsnmedia/kernel/-/commit/ac59eafd5076c4deb3bfe1fb85b3b776586ef3eb > > https://gitlab.collabora.com/chipsnmedia/kernel/-/commit/5de4fbe0abb20b8e8d862b654f93e3efeb1ef251 > > > > While I'm not going to NAK this series or those 2 patches if you send > them, I'm not really convinced that adding more and more complexity to > the mem2mem helpers is a good idea, especially since all of those seem > to be only needed by stateful video decoders. > > The mem2mem framework started as a set of helpers to eliminate boiler > plate from simple drivers that always get 1 CAPTURE and 1 OUTPUT buffer, > run 1 processing job on them and then return both of the to the userspace > and I think it should stay like this. Its a bit late to try and bring that argument. It should have been raised couple of years ago (before I even started helping with these CODEC). Now that all the newly written stately decoders uses this framework, it is logical to keep reducing the boiler plate for these too. In my opinion, the job_ready() callback, should have been a lot more flexible from the start. And allowing driver to make it more powerful does not really add that much complexity. Speaking of complexity, driving the output manually (outside of the job workqueue) during sequence initialization is a way more complex and risky then this. Finally, sticking with 1:1 pattern means encoder, detilers, image enhancement reducing framerate, etc. would all be unwelcome to use this. Which in short, means no one should even use this. > > I think we're strongly in need of a stateful video decoder framework that > would actually address the exact problems that those have rather than > bending something that wasn't designed with them in mind to work around the > differences. The bend is already there, of course I'd be happy to help with any new framework. Specially on modern stateless, were there is a need to do better scheduling. Just ping me if you have some effort starting, I don't currently have a budget or bandwidth to write new drivers or port existing drivers them on a newly written framework. Nicolas [...]
On 7/17/23 22:00, Nicolas Dufresne wrote: > CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe. > > > Le mercredi 12 juillet 2023 à 09:31 +0000, Tomasz Figa a écrit : >> On Fri, Jul 07, 2023 at 03:14:23PM -0400, Nicolas Dufresne wrote: >>> Hi Randy, >>> >>> Le mardi 04 juillet 2023 à 12:00 +0800, Hsia-Jun Li a écrit : >>>> From: Randy Li <ayaka@soulik.info> >>>> >>>> For the decoder supports Dynamic Resolution Change, >>>> we don't need to allocate any CAPTURE or graphics buffer >>>> for them at inital CAPTURE setup step. >>>> >>>> We need to make the device run or we can't get those >>>> metadata. >>>> >>>> Signed-off-by: Randy Li <ayaka@soulik.info> >>>> --- >>>> drivers/media/v4l2-core/v4l2-mem2mem.c | 5 +++-- >>>> 1 file changed, 3 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c >>>> index 0cc30397fbad..c771aba42015 100644 >>>> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c >>>> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c >>>> @@ -301,8 +301,9 @@ static void __v4l2_m2m_try_queue(struct v4l2_m2m_dev *m2m_dev, >>>> >>>> dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx); >>>> >>>> - if (!m2m_ctx->out_q_ctx.q.streaming >>>> - || !m2m_ctx->cap_q_ctx.q.streaming) { >>>> + if (!(m2m_ctx->out_q_ctx.q.streaming || m2m_ctx->out_q_ctx.buffered) >>>> + || !(m2m_ctx->cap_q_ctx.q.streaming >>>> + || m2m_ctx->cap_q_ctx.buffered)) { >>> >>> I have a two atches with similar goals in my wave5 tree. It will be easier to >>> upstream with an actual user, though, I'm probably a month or two away from >>> submitting this driver again. >>> >>> https://urldefense.proofpoint.com/v2/url?u=https-3A__gitlab.collabora.com_chipsnmedia_kernel_-2D_commit_ac59eafd5076c4deb3bfe1fb85b3b776586ef3eb&d=DwIFaQ&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=P4xb2_7biqBxD4LGGPrSV6j-jf3C3xlR7PXU-mLTeZE&m=9eWwqueFnh1yZHTW11j-syNVQvema7iBzNQeX1GKUQwXZ9pm6V4HDL_R2tIYKoOw&s=Ez5AyEYFIAJmC_k00IPO_ImzVdLZjr_veRq1bN4RSNg&e= >>> https://urldefense.proofpoint.com/v2/url?u=https-3A__gitlab.collabora.com_chipsnmedia_kernel_-2D_commit_5de4fbe0abb20b8e8d862b654f93e3efeb1ef251&d=DwIFaQ&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=P4xb2_7biqBxD4LGGPrSV6j-jf3C3xlR7PXU-mLTeZE&m=9eWwqueFnh1yZHTW11j-syNVQvema7iBzNQeX1GKUQwXZ9pm6V4HDL_R2tIYKoOw&s=tM81gjNe-bTjpjmidZ1sAhiodMh6npcVJNOhMCi1mPo&e= >>> >> >> While I'm not going to NAK this series or those 2 patches if you send >> them, I'm not really convinced that adding more and more complexity to >> the mem2mem helpers is a good idea, especially since all of those seem >> to be only needed by stateful video decoders. >> >> The mem2mem framework started as a set of helpers to eliminate boiler >> plate from simple drivers that always get 1 CAPTURE and 1 OUTPUT buffer, >> run 1 processing job on them and then return both of the to the userspace >> and I think it should stay like this. > > Its a bit late to try and bring that argument. It should have been raised couple > of years ago (before I even started helping with these CODEC). Now that all the > newly written stately decoders uses this framework, it is logical to keep > reducing the boiler plate for these too. In my opinion, the job_ready() > callback, should have been a lot more flexible from the start. And allowing > driver to make it more powerful does not really add that much complexity. > > Speaking of complexity, driving the output manually (outside of the job > workqueue) during sequence initialization is a way more complex and risky then > this. Finally, sticking with 1:1 pattern means encoder, detilers, image > enhancement reducing framerate, etc. would all be unwelcome to use this. Which > in short, means no one should even use this. > I think those things are m2m, but it would be hard to present in current m2m framework: 1. N:1 compositor(It may be implemented as a loop running 2:1 compositor). 2. AV1 film gain 3. HDR with dynamic meta data to SDR The video things fix for m2m model could be just a little less complex than ISP or camera pipeline. The only difference is just ISP won't have multiple contexts running at the same time. If we could design a model for the video encoder I think we could solve the most of problems. A video encoder would have: 1. input graphics buffer 2. reconstruction graphics buffer 3. motion vector cache buffer(optional) 4. coded bitstream output 5. encoding statistic report >> >> I think we're strongly in need of a stateful video decoder framework that >> would actually address the exact problems that those have rather than >> bending something that wasn't designed with them in mind to work around the >> differences. > > The bend is already there, of course I'd be happy to help with any new > framework. Specially on modern stateless, were there is a need to do better > scheduling. I didn't know the schedule problem about stateless codec, are they supposed to be in the job queue when the buffers that DPB requests are own by the driver and its registers are prepared except the trigger bit? Just ping me if you have some effort starting, I don't currently > have a budget or bandwidth to write new drivers or port existing drivers them on > a newly written framework. > > Nicolas > > > [...]
Le vendredi 21 juillet 2023 à 16:56 +0800, Hsia-Jun Li a écrit : > > On 7/17/23 22:00, Nicolas Dufresne wrote: > > CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe. > > > > > > Le mercredi 12 juillet 2023 à 09:31 +0000, Tomasz Figa a écrit : > > > On Fri, Jul 07, 2023 at 03:14:23PM -0400, Nicolas Dufresne wrote: > > > > Hi Randy, > > > > > > > > Le mardi 04 juillet 2023 à 12:00 +0800, Hsia-Jun Li a écrit : > > > > > From: Randy Li <ayaka@soulik.info> > > > > > > > > > > For the decoder supports Dynamic Resolution Change, > > > > > we don't need to allocate any CAPTURE or graphics buffer > > > > > for them at inital CAPTURE setup step. > > > > > > > > > > We need to make the device run or we can't get those > > > > > metadata. > > > > > > > > > > Signed-off-by: Randy Li <ayaka@soulik.info> > > > > > --- > > > > > drivers/media/v4l2-core/v4l2-mem2mem.c | 5 +++-- > > > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > > > > > diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c > > > > > index 0cc30397fbad..c771aba42015 100644 > > > > > --- a/drivers/media/v4l2-core/v4l2-mem2mem.c > > > > > +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c > > > > > @@ -301,8 +301,9 @@ static void __v4l2_m2m_try_queue(struct v4l2_m2m_dev *m2m_dev, > > > > > > > > > > dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx); > > > > > > > > > > - if (!m2m_ctx->out_q_ctx.q.streaming > > > > > - || !m2m_ctx->cap_q_ctx.q.streaming) { > > > > > + if (!(m2m_ctx->out_q_ctx.q.streaming || m2m_ctx->out_q_ctx.buffered) > > > > > + || !(m2m_ctx->cap_q_ctx.q.streaming > > > > > + || m2m_ctx->cap_q_ctx.buffered)) { > > > > > > > > I have a two atches with similar goals in my wave5 tree. It will be easier to > > > > upstream with an actual user, though, I'm probably a month or two away from > > > > submitting this driver again. > > > > > > > > https://urldefense.proofpoint.com/v2/url?u=https-3A__gitlab.collabora.com_chipsnmedia_kernel_-2D_commit_ac59eafd5076c4deb3bfe1fb85b3b776586ef3eb&d=DwIFaQ&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=P4xb2_7biqBxD4LGGPrSV6j-jf3C3xlR7PXU-mLTeZE&m=9eWwqueFnh1yZHTW11j-syNVQvema7iBzNQeX1GKUQwXZ9pm6V4HDL_R2tIYKoOw&s=Ez5AyEYFIAJmC_k00IPO_ImzVdLZjr_veRq1bN4RSNg&e= > > > > https://urldefense.proofpoint.com/v2/url?u=https-3A__gitlab.collabora.com_chipsnmedia_kernel_-2D_commit_5de4fbe0abb20b8e8d862b654f93e3efeb1ef251&d=DwIFaQ&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=P4xb2_7biqBxD4LGGPrSV6j-jf3C3xlR7PXU-mLTeZE&m=9eWwqueFnh1yZHTW11j-syNVQvema7iBzNQeX1GKUQwXZ9pm6V4HDL_R2tIYKoOw&s=tM81gjNe-bTjpjmidZ1sAhiodMh6npcVJNOhMCi1mPo&e= > > > > > > > > > > While I'm not going to NAK this series or those 2 patches if you send > > > them, I'm not really convinced that adding more and more complexity to > > > the mem2mem helpers is a good idea, especially since all of those seem > > > to be only needed by stateful video decoders. > > > > > > The mem2mem framework started as a set of helpers to eliminate boiler > > > plate from simple drivers that always get 1 CAPTURE and 1 OUTPUT buffer, > > > run 1 processing job on them and then return both of the to the userspace > > > and I think it should stay like this. > > > > Its a bit late to try and bring that argument. It should have been raised couple > > of years ago (before I even started helping with these CODEC). Now that all the > > newly written stately decoders uses this framework, it is logical to keep > > reducing the boiler plate for these too. In my opinion, the job_ready() > > callback, should have been a lot more flexible from the start. And allowing > > driver to make it more powerful does not really add that much complexity. > > > > Speaking of complexity, driving the output manually (outside of the job > > workqueue) during sequence initialization is a way more complex and risky then > > this. Finally, sticking with 1:1 pattern means encoder, detilers, image > > enhancement reducing framerate, etc. would all be unwelcome to use this. Which > > in short, means no one should even use this. > > > I think those things are m2m, but it would be hard to present in current > m2m framework: > 1. N:1 compositor(It may be implemented as a loop running 2:1 compositor). Correct, only SRC/DST/BG type of blitters can be supported for compositing, which is quite limiting. Currently there is no way to make an N:1 M2M, as M2M instances are implemented at the video node layer, and not at the MC layer. This is a entirely new subject and API design space to tackle (same goes for 1:N, like multi scalers, svc decoders etc.). > 2. AV1 film gain For AV1/HEVC film grain, it is handle similar to inline converters and scalers. The driver secretly allocate the reference frames, and post process into the user visible buffers. It breaks some assumption made by most protected memory setup though, as not all allocation is user driven, meaning the decoder needs to know if its secure or not. Secure memory is a also another API design space to tackle. > 3. HDR with dynamic meta data to SDR True, but easy to design around the stateless model. I'm not worried for these. > > The video things fix for m2m model could be just a little less complex > than ISP or camera pipeline. The only difference is just ISP won't have > multiple contexts running at the same time. I thought that having the kernel schedule ISP reprocessing jobs (which requires instances) would be nice. But this can only be solved after we have solved the N:N use cases of m2m (with multiple instances). > If we could design a model for the video encoder I think we could solve > the most of problems. > A video encoder would have: > 1. input graphics buffer > 2. reconstruction graphics buffer > 3. motion vector cache buffer(optional) > 4. coded bitstream output > 5. encoding statistic report > > > > > > I think we're strongly in need of a stateful video decoder framework that > > > would actually address the exact problems that those have rather than > > > bending something that wasn't designed with them in mind to work around the > > > differences. > > > > The bend is already there, of course I'd be happy to help with any new > > framework. Specially on modern stateless, were there is a need to do better > > scheduling. > I didn't know the schedule problem about stateless codec, are they > supposed to be in the job queue when the buffers that DPB requests are > own by the driver and its registers are prepared except the trigger bit? On RK3588 at least, decoder scheduling is going to be complex. There is an even number of cores, but when you need to decode 8K, you have to pair two cores (there is a specific set of cores that are to be paired with). We need a decent scheduling logic to ensure we don't starve 8K decoding session when there is multiple smaller resolution session on-going. On MTK, the entropy decoding (LAT) and the reconstruction (CORE) is split. MTK vcodec is using multiple workqueues to move jobs around, which is clearly expensive. Also, the life time of a job is not exactly easy to manage. On RPi HEVC (not upstream yet, but being worked on), the entropy decoding and reconstruction is done one the same core, but remains 2 concurrent operation. Does not impose a complex scheduling issue, but it raised the need for a way to fully utilize such HW. This is just some examples of complexity for which the current framework is not that helpful (even though, its not impossible either). > Just ping me if you have some effort starting, I don't currently > > have a budget or bandwidth to write new drivers or port existing drivers them on > > a newly written framework. > > > > Nicolas > > > > > > [...] >
On 2023/7/22 00:22, Nicolas Dufresne wrote: > Le vendredi 21 juillet 2023 à 16:56 +0800, Hsia-Jun Li a écrit : >> On 7/17/23 22:00, Nicolas Dufresne wrote: >>> CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe. >>> >>> >>> Le mercredi 12 juillet 2023 à 09:31 +0000, Tomasz Figa a écrit : >>>> On Fri, Jul 07, 2023 at 03:14:23PM -0400, Nicolas Dufresne wrote: >>>>> Hi Randy, >>>>> >>>>> Le mardi 04 juillet 2023 à 12:00 +0800, Hsia-Jun Li a écrit : >>>>>> From: Randy Li <ayaka@soulik.info> >>>>>> >>>>>> For the decoder supports Dynamic Resolution Change, >>>>>> we don't need to allocate any CAPTURE or graphics buffer >>>>>> for them at inital CAPTURE setup step. >>>>>> >>>>>> We need to make the device run or we can't get those >>>>>> metadata. >>>>>> >>>>>> Signed-off-by: Randy Li <ayaka@soulik.info> >>>>>> --- >>>>>> drivers/media/v4l2-core/v4l2-mem2mem.c | 5 +++-- >>>>>> 1 file changed, 3 insertions(+), 2 deletions(-) >>>>>> >>>>>> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c >>>>>> index 0cc30397fbad..c771aba42015 100644 >>>>>> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c >>>>>> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c >>>>>> @@ -301,8 +301,9 @@ static void __v4l2_m2m_try_queue(struct v4l2_m2m_dev *m2m_dev, >>>>>> >>>>>> dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx); >>>>>> >>>>>> - if (!m2m_ctx->out_q_ctx.q.streaming >>>>>> - || !m2m_ctx->cap_q_ctx.q.streaming) { >>>>>> + if (!(m2m_ctx->out_q_ctx.q.streaming || m2m_ctx->out_q_ctx.buffered) >>>>>> + || !(m2m_ctx->cap_q_ctx.q.streaming >>>>>> + || m2m_ctx->cap_q_ctx.buffered)) { >>>>> I have a two atches with similar goals in my wave5 tree. It will be easier to >>>>> upstream with an actual user, though, I'm probably a month or two away from >>>>> submitting this driver again. >>>>> >>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__gitlab.collabora.com_chipsnmedia_kernel_-2D_commit_ac59eafd5076c4deb3bfe1fb85b3b776586ef3eb&d=DwIFaQ&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=P4xb2_7biqBxD4LGGPrSV6j-jf3C3xlR7PXU-mLTeZE&m=9eWwqueFnh1yZHTW11j-syNVQvema7iBzNQeX1GKUQwXZ9pm6V4HDL_R2tIYKoOw&s=Ez5AyEYFIAJmC_k00IPO_ImzVdLZjr_veRq1bN4RSNg&e= >>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__gitlab.collabora.com_chipsnmedia_kernel_-2D_commit_5de4fbe0abb20b8e8d862b654f93e3efeb1ef251&d=DwIFaQ&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=P4xb2_7biqBxD4LGGPrSV6j-jf3C3xlR7PXU-mLTeZE&m=9eWwqueFnh1yZHTW11j-syNVQvema7iBzNQeX1GKUQwXZ9pm6V4HDL_R2tIYKoOw&s=tM81gjNe-bTjpjmidZ1sAhiodMh6npcVJNOhMCi1mPo&e= >>>>> >>>> While I'm not going to NAK this series or those 2 patches if you send >>>> them, I'm not really convinced that adding more and more complexity to >>>> the mem2mem helpers is a good idea, especially since all of those seem >>>> to be only needed by stateful video decoders. >>>> >>>> The mem2mem framework started as a set of helpers to eliminate boiler >>>> plate from simple drivers that always get 1 CAPTURE and 1 OUTPUT buffer, >>>> run 1 processing job on them and then return both of the to the userspace >>>> and I think it should stay like this. >>> Its a bit late to try and bring that argument. It should have been raised couple >>> of years ago (before I even started helping with these CODEC). Now that all the >>> newly written stately decoders uses this framework, it is logical to keep >>> reducing the boiler plate for these too. In my opinion, the job_ready() >>> callback, should have been a lot more flexible from the start. And allowing >>> driver to make it more powerful does not really add that much complexity. >>> >>> Speaking of complexity, driving the output manually (outside of the job >>> workqueue) during sequence initialization is a way more complex and risky then >>> this. Finally, sticking with 1:1 pattern means encoder, detilers, image >>> enhancement reducing framerate, etc. would all be unwelcome to use this. Which >>> in short, means no one should even use this. >>> >> I think those things are m2m, but it would be hard to present in current >> m2m framework: >> 1. N:1 compositor(It may be implemented as a loop running 2:1 compositor). > Correct, only SRC/DST/BG type of blitters can be supported for compositing, > which is quite limiting. Currently there is no way to make an N:1 M2M, as M2M > instances are implemented at the video node layer, and not at the MC layer. This > is a entirely new subject and API design space to tackle (same goes for 1:N, > like multi scalers, svc decoders etc.). SVC case is the one I mention in the talk, although the major problem may only happens to SVC-S. > >> 2. AV1 film gain > For AV1/HEVC film grain, it is handle similar to inline converters and scalers. I know a few decoders in the market didn't implement such feature in the its hardware, they rely on the other hardware. Actually, it would be better to let NPU do such job. > The driver secretly allocate the reference frames, and post process into the > user visible buffers. Hiding internal buffer is the worst case, frame buffer could be large. > It breaks some assumption made by most protected memory > setup though, as not all allocation is user driven, meaning the decoder needs to > know if its secure or not. Secure memory is a also another API design space to > tackle. > >> 3. HDR with dynamic meta data to SDR > True, but easy to design around the stateless model. I'm not worried for these. The current stateless API won't support DMA buffer for the metadata. > >> The video things fix for m2m model could be just a little less complex >> than ISP or camera pipeline. The only difference is just ISP won't have >> multiple contexts running at the same time. > I thought that having the kernel schedule ISP reprocessing jobs (which requires > instances) would be nice. But this can only be solved after we have solved the > N:N use cases of m2m (with multiple instances). > >> If we could design a model for the video encoder I think we could solve >> the most of problems. >> A video encoder would have: >> 1. input graphics buffer >> 2. reconstruction graphics buffer >> 3. motion vector cache buffer(optional) >> 4. coded bitstream output >> 5. encoding statistic report >>>> I think we're strongly in need of a stateful video decoder framework that >>>> would actually address the exact problems that those have rather than >>>> bending something that wasn't designed with them in mind to work around the >>>> differences. >>> The bend is already there, of course I'd be happy to help with any new >>> framework. Specially on modern stateless, were there is a need to do better >>> scheduling. >> I didn't know the schedule problem about stateless codec, are they >> supposed to be in the job queue when the buffers that DPB requests are >> own by the driver and its registers are prepared except the trigger bit? > On RK3588 at least, decoder scheduling is going to be complex. There is an even > number of cores, but when you need to decode 8K, you have to pair two cores > (there is a specific set of cores that are to be paired with). We need a decent How do two cores work parallel? Tiles ? But AV1 could do intra block copy. > scheduling logic to ensure we don't starve 8K decoding session when there is > multiple smaller resolution session on-going. > > On MTK, the entropy decoding (LAT) and the reconstruction (CORE) is split. MTK > vcodec is using multiple workqueues to move jobs around, which is clearly > expensive. Also, the life time of a job is not exactly easy to manage. This model sounds easy, LAT produces partial frame buffer with intra blocks and its motion vector buffer CORE complete the frame from the motion vector buffer and its reference buffers We just separately two hardware devices here. > > On RPi HEVC (not upstream yet, but being worked on), the entropy decoding and > reconstruction is done one the same core, but remains 2 concurrent operation. > Does not impose a complex scheduling issue, but it raised the need for a way to > fully utilize such HW. This sounds be more complex than MTK's case. It would be hard to measure the job length with entropy part and inter construction part. Although usually the later one would consume more memory bandwidth or hardware time. > > This is just some examples of complexity for which the current framework is not > that helpful (even though, its not impossible either). > >> Just ping me if you have some effort starting, I don't currently >>> have a budget or bandwidth to write new drivers or port existing drivers them on >>> a newly written framework. >>> >>> Nicolas >>> >>> >>> [...]
diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index 0cc30397fbad..c771aba42015 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -301,8 +301,9 @@ static void __v4l2_m2m_try_queue(struct v4l2_m2m_dev *m2m_dev, dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx); - if (!m2m_ctx->out_q_ctx.q.streaming - || !m2m_ctx->cap_q_ctx.q.streaming) { + if (!(m2m_ctx->out_q_ctx.q.streaming || m2m_ctx->out_q_ctx.buffered) + || !(m2m_ctx->cap_q_ctx.q.streaming + || m2m_ctx->cap_q_ctx.buffered)) { dprintk("Streaming needs to be on for both queues\n"); return; }