Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp500284pxb; Thu, 17 Feb 2022 08:28:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIz2eaOcSJNYMRbsxzNPG3d0QEf1Hq5O8zFCQv/2Qm5UbI32o0plmK219dDmUPEC2VAv7F X-Received: by 2002:a17:90b:3509:b0:1b8:aaea:a82e with SMTP id ls9-20020a17090b350900b001b8aaeaa82emr7982247pjb.109.1645115308066; Thu, 17 Feb 2022 08:28:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645115308; cv=none; d=google.com; s=arc-20160816; b=P4f4AKZaX+4adjm7sUAUoEq14kNRXbGtwKqaIdzRMxzD6fBuXsuGlwUUebTl84xCbX gJk4MZpo8GCvhiTciUZ3Y+6KptVhPnnfgkf4r+ToBK4WwvBvaFbRYltULIH+oJw2s57L dMJv5+eHI5iiUFvV9VZN5fhwCgO55uDCFzDsYLEEdnRP6Bn/JqaZ7oLemTlevlaT5KBF qRCJn1RfHsyg3FWUdcy5s61ZuqeXKW8Dj+WxoTL22SZeOayxdJBC8gFE47r6t65fuHk9 c6MJYkuPAbgXnJkABOQLqXPDhrmTEQ45n/yDCTrnRHwwKojqZX05mCEAUAad2GJtoTHg HO9Q== 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=7Dm8/9xh+wmDmQBhMFT43NJgXO5tbOXeBqNcPHzywpk=; b=IqOvvvOE5fDHtigfrauGlL0RV/GVyZARnypmx0eKUm8zVm72SA0BgBGa/J4jnnZ0LW SPIgJfMy0YbgXxtuH0FOx8qh4ua6MCEeE7+XdyxTo5ZcSKCc/xfrskELVQVBAaYOEqeX EPvv6jFYvKxwltzBh+vit606RRbLbP5w5p5ADfiETRko13ZtTR7Ekoh+YkP5iEQwzVEU R3VHAwsS2ZNYSHsNk4BnG3qPqgyWOBbVdHJ9IqRf+s5sD4i3wTPbr/QRMYZNKuogZ8vr pxuhWTezUM/nXgCNRIu4pUHzaf45vpJfNmQXlnCtXG6dQWw3SiSQAnNADDebaRxHLTgI bfXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ndufresne-ca.20210112.gappssmtp.com header.s=20210112 header.b=ZICFIWA9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6si138271pfj.19.2022.02.17.08.28.12; Thu, 17 Feb 2022 08:28:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ndufresne-ca.20210112.gappssmtp.com header.s=20210112 header.b=ZICFIWA9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242001AbiBQOoQ (ORCPT + 99 others); Thu, 17 Feb 2022 09:44:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232351AbiBQOoP (ORCPT ); Thu, 17 Feb 2022 09:44:15 -0500 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB345207FF3 for ; Thu, 17 Feb 2022 06:44:00 -0800 (PST) Received: by mail-qk1-x734.google.com with SMTP id q4so3512964qki.11 for ; Thu, 17 Feb 2022 06:44:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ndufresne-ca.20210112.gappssmtp.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=7Dm8/9xh+wmDmQBhMFT43NJgXO5tbOXeBqNcPHzywpk=; b=ZICFIWA9Sbi45aOvx4dcDKut/wdPr6VMVnR4U4cb/kJNSc5ETL1ImhYOA8svydp4va RzN0pqQOm5Dq4JA7d4pON7G9eyLMCXEsZuWHjnT9Fj9mCm+TUeulRj9lF2p9y2RbrWcw Zdpbnbp0nBhk0+kYOrKKXdR396nWX9LG40kL5OO0Sx5HRmFULTOjGINNiVDkIXxd4+xP TOWJ3oYmeQRu60z0DluHgDjZgUZAXTPIUOGK3h/aHozSzMAyMRLTYmepfzaIg3ggnHGr dP2iJfjIiPWmJy73uFUWoYnY+wyUm1t2ktREy2fqVLd/EgvXbdq9nYV+GFUVOklwgQKe rgsw== 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=7Dm8/9xh+wmDmQBhMFT43NJgXO5tbOXeBqNcPHzywpk=; b=b+rgCkwfRi0q5MqhMXCP0IRSEHszMNHqqwG5+ZBX0yD149QlL5Xb1GqKIE+7gRXRHF zD6jIValmlLJ/fdIvHFsJMHndgWvLCUKk9Z5fo5SD7G+q0+6SjuTQIzE1T2ekEaDafNR LWLJUJuYR91UyDAo0PE8UreXTjhBvkvGJCoQl2IdPMXqWSFawdfvAit5iNRMv3VlF+vR rqV0Z8zzGu2SIKwnH/aOkeHFmVnUqLJWYdfHps4lo0F9lIVJvyGuqIwzYStSKdb+dI6e lGg0CuTrcr8FFjyVyjm+/mh1Yqso0++XMueguagtGIcZOP0U1aYi/hwet5bROX2hP89U /gCQ== X-Gm-Message-State: AOAM531FPt9ALF/dzGJY78U1Z0VbOxuYK+MekzPwq4meFDSMtU++eQD1 Qqe87puLfbcV/Ki47O/Vs0fKCg== X-Received: by 2002:ae9:edc6:0:b0:60c:8807:712f with SMTP id c189-20020ae9edc6000000b0060c8807712fmr1821761qkg.14.1645109039947; Thu, 17 Feb 2022 06:43:59 -0800 (PST) Received: from nicolas-tpx395.localdomain (173-246-12-168.qc.cable.ebox.net. [173.246.12.168]) by smtp.gmail.com with ESMTPSA id h19sm13099450qtx.12.2022.02.17.06.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 06:43:59 -0800 (PST) Message-ID: <20a43338009164be793abb9fedd002f2e4c9a293.camel@ndufresne.ca> Subject: Re: [PATCH v6, 06/15] media: mtk-vcodec: Refactor get and put capture buffer flow From: Nicolas Dufresne To: "yunfei.dong@mediatek.com" , Alexandre Courbot , Hans Verkuil , Tzung-Bi Shih , Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Tomasz Figa Cc: George Sun , Xiaoyong Lu , Hsin-Yi Wang , Fritz Koenig , Dafna Hirschfeld , Benjamin Gaignard , Daniel Vetter , dri-devel , Irui Wang , AngeloGioacchino Del Regno , Steve Cho , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, srv_heupstream@mediatek.com, linux-mediatek@lists.infradead.org, Project_Global_Chrome_Upstream_Group@mediatek.com Date: Thu, 17 Feb 2022 09:43:54 -0500 In-Reply-To: <353328c24f92a0690c8461a9b18c62166b769a40.camel@mediatek.com> References: <20220122035316.18179-1-yunfei.dong@mediatek.com> <20220122035316.18179-7-yunfei.dong@mediatek.com> <353328c24f92a0690c8461a9b18c62166b769a40.camel@mediatek.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.3 (3.42.3-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, 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: X-Mailing-List: linux-kernel@vger.kernel.org Le jeudi 17 février 2022 à 17:03 +0800, yunfei.dong@mediatek.com a écrit : > > > - ret = vdec_if_decode(ctx, bs_src, dst_buf, &res_chg); > > > + ret = vdec_if_decode(ctx, bs_src, NULL, &res_chg); > > >    if (ret) { > > >    mtk_v4l2_err(" <===[%d], src_buf[%d] sz=0x%zx pts=%llu > > > vdec_if_decode() ret=%d res_chg=%d===>", > > >         ctx->id, vb2_src->index, bs_src->size, > > > @@ -220,12 +266,9 @@ static void mtk_vdec_worker(struct work_struct > > > *work) > > >    } > > >    } > > >   > > > - mtk_vdec_stateless_set_dst_payload(ctx, dst_buf); > > > - > > > - v4l2_m2m_buf_done_and_job_finish(dev->m2m_dev_dec, ctx- > > > > m2m_ctx, > > > - ret ? VB2_BUF_STATE_ERROR : > > > VB2_BUF_STATE_DONE); > > > - > > > + mtk_vdec_stateless_out_to_done(ctx, bs_src, ret); > > > > v4l2_m2m_buf_done_and_job_finish() was specially crafted to prevent > > developer > > from implementing the signalling of the request at the wrong moment. > > This patch > > broke this strict ordering. The relevant comment in the helper > > function: > > > > > As we discussed in chat, please help to check whether it's possible to > let lat and core decode in parallel. Thanks, Benjamin is looking into that. For the mailing list here, here's some prior art for a similar problem found by downstream RPi4 HEVC driver developer. The general problem here is that we don't want to signal the request until the decode have complete, yet we want to pick and run second (concurrent job) so that parallel decoding is made possible. For RPi4 it is not multi-core, but the decoding is split in 2 stages, and the decoder run both stages concurrently, which basically means, we need to be able to run two jobs at the same time whenever possible. https://github.com/raspberrypi/linux/commit/964be1d20e2f1335915a6bf8c82a3199bfddf8ac This introduce media_request_pin/unpin, but being able to pin a request and not have it bound to any other object lifetime anymore seems a bit error prone in comparison to the current restrictions. Comments welcome ! > > I will continue to fix h264 issue. Thanks. > > Thanks for your help. > > Best Regards, > Yunfei Dong