linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
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 5/7] media: mediatek: vcodec: store source vb2 buffer
Date: Tue, 27 Aug 2024 02:50:03 +0000	[thread overview]
Message-ID: <9f6d7408e78fe74bb96983004f9ee00a2467e95d.camel@mediatek.com> (raw)
In-Reply-To: <20240823141454.vvtbkkj5qm4pmpfr@basti-XPS-13-9310>

Hi Sebastian,

Thanks for your suggestion.
On Fri, 2024-08-23 at 16:14 +0200, Sebastian Fricke wrote:
> Hey Yunfei,
> 
> On 07.08.2024 16:24, Yunfei Dong wrote:
> > Store the current vb2 buffer when lat need to decode again.
> > Then lat work can get the same vb2 buffer directly next time.
> 
> I would reword this with:
> 
> Store the current source buffer in the specific data for the IC. When
> the LAT needs to retry a decode it can pick that buffer directly.
> 
> ---
> 
> Additionally, this is not a good commit description as you just say
> what
> you do, but you don't say WHY this needs to happen, why is it
> necessary?
> What does it improve, is this a preparation patch for another, a fix
> for
> something or an improvement of performance?
> 
> 
> more below...
> 
> > 
> > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> > ---
> > .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h      |  2 ++
> > .../vcodec/decoder/mtk_vcodec_dec_stateless.c         | 11
> > ++++++++---
> > 2 files changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git
> > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv
> > .h
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv
> > .h
> > index 1fabe8c5b7a4..0817be73f8e0 100644
> > ---
> > a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv
> > .h
> > +++
> > b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv
> > .h
> > @@ -155,6 +155,7 @@ struct mtk_vcodec_dec_pdata {
> >  * @last_decoded_picinfo: pic information get from latest decode
> >  * @empty_flush_buf: a fake size-0 capture buffer that indicates
> > flush. Used
> >  *		     for stateful decoder.
> > + * @last_vb2_v4l2_src: the backup of current source buffer.
> 
> I think last is confusing in this context especially as there is for
> example in the m2m_ctx:
>   * @last_src_buf: indicate the last source buffer for draining
>   * @next_buf_last: next capture queud buffer will be tagged as last
> or:
>   * v4l2_m2m_last_buf() - return last buffer from the list of ready
> buffers
> 
> I think a better name would be:
> 
>   * @cur_src_buf: current source buffer with the bitstream data for
> the latest decode
> 
> >  * @is_flushing: set to true if flushing is in progress.
> >  *
> >  * @current_codec: current set input codec, in V4L2 pixel format
> > @@ -201,6 +202,7 @@ struct mtk_vcodec_dec_ctx {
> > 	struct work_struct decode_work;
> > 	struct vdec_pic_info last_decoded_picinfo;
> > 	struct v4l2_m2m_buffer empty_flush_buf;
> > +	struct vb2_v4l2_buffer *last_vb2_v4l2_src;
> 
> Likewise here:
> 
> struct vb2_v4l2_buffer *cur_src_buf;
> 
> > 	bool is_flushing;
> > 
> > 	u32 current_codec;
> > 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 2a7e4fe24ed3..8aa379872ddc 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
> > @@ -320,7 +320,7 @@ static void mtk_vdec_worker(struct work_struct
> > *work)
> > 	struct mtk_vcodec_dec_ctx *ctx =
> > 		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;
> > +	struct vb2_v4l2_buffer *vb2_v4l2_src = ctx->last_vb2_v4l2_src;
> 
> And here:
> 
> struct vb2_v4l2_buffer *vb2_v4l2_src = ctx->cur_src_buf;
> 
> > 	struct vb2_buffer *vb2_src;
> > 	struct mtk_vcodec_mem *bs_src;
> > 	struct mtk_video_dec_buf *dec_buf_src;
> > @@ -329,7 +329,7 @@ static void mtk_vdec_worker(struct work_struct
> > *work)
> > 	bool res_chg = false;
> > 	int ret;
> > 
> > -	vb2_v4l2_src = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
> > +	vb2_v4l2_src = vb2_v4l2_src ? vb2_v4l2_src :
> > v4l2_m2m_next_src_buf(ctx->m2m_ctx);
> 
> Please add a comment above this line that explains why this search
> can
> be made, explaining why this buffer is still valid in this call and
> when
> we pick the next source buffer.
> 

As the commit wrote, if the driver need to decoder again, need to use
the last remove source buffer to decode again, not to get one new.

Regards,
Yunfei Dong
> Regards,
> Sebastian Fricke
> 
> > 	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);
> > @@ -383,8 +383,13 @@ static void mtk_vdec_worker(struct work_struct
> > *work)
> > 			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)
> > +		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;
> > +		}
> > +
> > 		v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
> > 	}
> > }
> > -- 
> > 2.46.0
> > 
> > 
> 
> 

  parent reply	other threads:[~2024-08-27  3:02 UTC|newest]

Thread overview: 14+ 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-07  8:24 ` [PATCH v4 3/7] media: mediatek: vcodec: flush decoder before " Yunfei Dong
     [not found]   ` <20240822161145.jv7i45wlajcxpazw@basti-XPS-13-9310>
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
     [not found]   ` <20240823124023.uhypfcixfsget26q@basti-XPS-13-9310>
2024-08-27  2:47     ` Yunfei Dong (董云飞)
2024-08-07  8:24 ` [PATCH v4 5/7] media: mediatek: vcodec: store source " Yunfei Dong
     [not found]   ` <20240823141454.vvtbkkj5qm4pmpfr@basti-XPS-13-9310>
2024-08-27  2:50     ` Yunfei Dong (董云飞) [this message]
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
     [not found]   ` <20240823152338.n7i7cnvolvke2hqp@basti-XPS-13-9310>
2024-08-27  2:56     ` Yunfei Dong (董云飞)
2024-08-07  8:24 ` [PATCH v4 7/7] media: mediatek: vcodec: remove media request checking Yunfei Dong
     [not found] ` <be4baa6313d16ed52245347d866dd878049a12a0.camel@collabora.com>
2024-08-15 12:58   ` [PATCH v4 0/7] media: mediatek: vcodec: fix v4l2_ctrl_request_complete fail Yunfei Dong (董云飞)
     [not found] ` <20240823154523.fucqvc4cnqk5jrlg@basti-XPS-13-9310>
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=9f6d7408e78fe74bb96983004f9ee00a2467e95d.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;
as well as URLs for NNTP newsgroup(s).