From: "Yunfei Dong (董云飞)" <Yunfei.Dong@mediatek.com>
To: "sebastian.fricke@collabora.com" <sebastian.fricke@collabora.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"frkoenig@chromium.org" <frkoenig@chromium.org>,
"stevecho@chromium.org" <stevecho@chromium.org>,
"nhebert@chromium.org" <nhebert@chromium.org>,
"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"nicolas.dufresne@collabora.com" <nicolas.dufresne@collabora.com>,
"daniel.almeida@collabora.com" <daniel.almeida@collabora.com>,
"daniel@ffwll.ch" <daniel@ffwll.ch>,
Project_Global_Chrome_Upstream_Group
<Project_Global_Chrome_Upstream_Group@mediatek.com>,
"benjamin.gaignard@collabora.com"
<benjamin.gaignard@collabora.com>,
"hverkuil-cisco@xs4all.nl" <hverkuil-cisco@xs4all.nl>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"hsinyi@chromium.org" <hsinyi@chromium.org>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>,
"nfraprado@collabora.com" <nfraprado@collabora.com>
Subject: Re: [PATCH v4 6/7] media: mediatek: vcodec: replace v4l2_m2m_next_src_buf with v4l2_m2m_src_buf_remove
Date: Tue, 27 Aug 2024 02:56:31 +0000 [thread overview]
Message-ID: <1e2735b83877c1ecd9c3eb1c9dc32408fc276544.camel@mediatek.com> (raw)
In-Reply-To: <20240823152338.n7i7cnvolvke2hqp@basti-XPS-13-9310>
Hi Sebastian,
Thanks for your suggestion.
On Fri, 2024-08-23 at 17:23 +0200, Sebastian Fricke wrote:
> Hey Yunfei,
>
> On 07.08.2024 16:24, Yunfei Dong wrote:
> > There isn't lock to protect source buffer when get next src buffer,
> > if the source buffer is removed for some unknown reason before lat
> > work queue execute done, will lead to remove source buffer or
> > buffer
> > done error.
>
> This is really hard to understand, can try wording this a bit
> clearer?
> Stuff like: if the source buffer is removed ... will lead to remove
> source buffer, just leaves me scratching my head.
> And there is a spinlock in the m2m framework in `v4l2_m2m_next_buf`
> so I
> suppose you mean something else when you say that there is no lock to
> protect the source buffer?
>
> You might not know all reasons but for this commit description you
> should at least know one reason. Please highlight a case how this can
> happen, so that you can justify the change.
>
> >
> > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> > ---
> > .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 30 +++++++++++++---
> > ---
> > 1 file changed, 21 insertions(+), 9 deletions(-)
> >
> > diff --git
> > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > index 8aa379872ddc..3dba3549000a 100644
> > ---
> > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > +++
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_sta
> > teless.c
> > @@ -321,6 +321,7 @@ static void mtk_vdec_worker(struct work_struct
> > *work)
> > container_of(work, struct mtk_vcodec_dec_ctx,
> > decode_work);
> > struct mtk_vcodec_dec_dev *dev = ctx->dev;
> > struct vb2_v4l2_buffer *vb2_v4l2_src = ctx->last_vb2_v4l2_src;
> > + struct vb2_v4l2_buffer *vb2_v4l2_dst;
> > struct vb2_buffer *vb2_src;
> > struct mtk_vcodec_mem *bs_src;
> > struct mtk_video_dec_buf *dec_buf_src;
> > @@ -329,7 +330,7 @@ static void mtk_vdec_worker(struct work_struct
> > *work)
> > bool res_chg = false;
> > int ret;
> >
> > - vb2_v4l2_src = vb2_v4l2_src ? vb2_v4l2_src :
> > v4l2_m2m_next_src_buf(ctx->m2m_ctx);
> > + vb2_v4l2_src = vb2_v4l2_src ? vb2_v4l2_src :
> > v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> > if (!vb2_v4l2_src) {
> > v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
> > mtk_v4l2_vdec_dbg(1, ctx, "[%d] no available source
> > buffer", ctx->id);
> > @@ -381,17 +382,28 @@ static void mtk_vdec_worker(struct
> > work_struct *work)
> > ctx->current_codec == V4L2_PIX_FMT_VP8_FRAME) {
> > if (src_buf_req)
> > v4l2_ctrl_request_complete(src_buf_req, &ctx-
> > >ctrl_hdl);
> > - v4l2_m2m_buf_done_and_job_finish(dev->m2m_dev_dec, ctx-
> > >m2m_ctx, state);
> > - } else {
> > - if (ret != -EAGAIN) {
> > - v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> > - ctx->last_vb2_v4l2_src = NULL;
> > - } else {
> > - ctx->last_vb2_v4l2_src = vb2_v4l2_src;
> > - }
> > + vb2_v4l2_dst = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
> > + v4l2_m2m_buf_done(vb2_v4l2_dst, state);
> > + v4l2_m2m_buf_done(vb2_v4l2_src, state);
>
> This is another case where you just remove again completely what you
> have added in the previous patch.
>
> >
> > v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
> > + return;
> > }
> > +
> > + /* If each codec return -EAGAIN to decode again, need to backup
> > current source
> > + * buffer, then the driver will get this buffer next time.
>
> I would reword this like:
>
> /* Store the current source buffer for the next attempt to
> decode,
> * if this decode returned -EAGAIN */
>
> > + *
> > + * If each codec decode error, must to set buffer done with
> > error status for
> > + * this buffer have been removed from ready list.
> > + */
> > + ctx->last_vb2_v4l2_src = (ret != -EAGAIN) ? NULL :
> > vb2_v4l2_src;
>
> Okay and here you add the same thing again as in the previous patch
> but
> differently, this collection of commits feels more and more to me
> like a
> work in progress. Please make sure in the future that each commit
> does
> one job and does it completely.
> It is not only confussing but also makes it hard to read the changes
> as
> the bigger picture is missing in these tiny commits.
>
> Please try to combine the patches where possible.
>
Path 5/7 is used to store the source buffer.
path 6/7 is used to handle decoder again when decoder error.
I will check whether it's possible to combine patch 5 and 6 together.
Best Regards,
Yunfei Dong
> Regards,
> Sebastian Fricke
>
> > + if (ret && ret != -EAGAIN) {
> > + if (src_buf_req)
> > + v4l2_ctrl_request_complete(src_buf_req, &ctx-
> > >ctrl_hdl);
> > + v4l2_m2m_buf_done(vb2_v4l2_src, state);
> > + }
> > +
> > + v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
> > }
> >
> > static void vb2ops_vdec_stateless_buf_queue(struct vb2_buffer *vb)
> > --
> > 2.46.0
> >
> >
next prev parent reply other threads:[~2024-08-27 2:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-07 8:24 [PATCH v4 0/7] media: mediatek: vcodec: fix v4l2_ctrl_request_complete fail Yunfei Dong
2024-08-07 8:24 ` [PATCH v4 1/7] media: mediatek: vcodec: setting request complete before buffer done Yunfei Dong
2024-08-07 8:24 ` [PATCH v4 2/7] media: mediatek: vcodec: change flush decode order when stream off Yunfei Dong
2024-08-22 15:32 ` Sebastian Fricke
2024-08-07 8:24 ` [PATCH v4 3/7] media: mediatek: vcodec: flush decoder before " Yunfei Dong
2024-08-22 16:11 ` Sebastian Fricke
2024-08-27 2:42 ` Yunfei Dong (董云飞)
2024-08-07 8:24 ` [PATCH v4 4/7] media: mediatek: vcodec: using input information to get vb2 buffer Yunfei Dong
2024-08-23 12:40 ` Sebastian Fricke
2024-08-27 2:47 ` Yunfei Dong (董云飞)
2024-08-07 8:24 ` [PATCH v4 5/7] media: mediatek: vcodec: store source " Yunfei Dong
2024-08-23 14:14 ` Sebastian Fricke
2024-08-27 2:50 ` Yunfei Dong (董云飞)
2024-08-07 8:24 ` [PATCH v4 6/7] media: mediatek: vcodec: replace v4l2_m2m_next_src_buf with v4l2_m2m_src_buf_remove Yunfei Dong
2024-08-23 15:23 ` Sebastian Fricke
2024-08-27 2:56 ` Yunfei Dong (董云飞) [this message]
2024-08-07 8:24 ` [PATCH v4 7/7] media: mediatek: vcodec: remove media request checking Yunfei Dong
2024-08-07 13:08 ` [PATCH v4 0/7] media: mediatek: vcodec: fix v4l2_ctrl_request_complete fail Nicolas Dufresne
2024-08-15 12:58 ` Yunfei Dong (董云飞)
2024-08-23 15:45 ` Sebastian Fricke
2024-08-27 2:58 ` Yunfei Dong (董云飞)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1e2735b83877c1ecd9c3eb1c9dc32408fc276544.camel@mediatek.com \
--to=yunfei.dong@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=benjamin.gaignard@collabora.com \
--cc=daniel.almeida@collabora.com \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=frkoenig@chromium.org \
--cc=hsinyi@chromium.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=nfraprado@collabora.com \
--cc=nhebert@chromium.org \
--cc=nicolas.dufresne@collabora.com \
--cc=sebastian.fricke@collabora.com \
--cc=stevecho@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®