All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nas Chung" <nas.chung@chipsnmedia.com>
Cc: devicetree@vger.kernel.org, imx@lists.linux.dev, robh@kernel.org,
	conor+dt@kernel.org, Frank.Li@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v8 04/11] media: chips-media: wave6: Add Wave6 decoder firmware interface
Date: Thu, 19 Nov 2026 09:22:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-222819@kernel.org> (raw)
In-Reply-To: <c246cbe7fe5fdd1affbce30b8c7f7d2987fd308f.1795075580.git.nas.chung@chipsnmedia.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] media: wave6: unset disp_pic_width/height in
  wave6_vpu_dec_get_output_info()
- [Low] media: wave6: invalid W6_RET_DEC_BS_RD_PTR read in
  wave6_vpu_dec_get_rd_ptr()
- [Low] media: wave6: ctu_size 2-bit bitfield truncates
  DEC_PIC_TYPE_CTU_SIZE to 0
--

commit 4430346b0188df2bacf518d95646056af3905289
Author: Nas Chung <nas.chung@chipsnmedia.com>

media: chips-media: wave6: Add Wave6 decoder firmware interface

This commit adds the firmware and register interface layer for the
Chips&Media Wave6 video decoder, covering instance management, sequence
initialization, buffer registration, and picture decoding.

> diff --git a/drivers/media/platform/chips-media/wave6/wave6-hw.c b/drivers/media/platform/chips-media/wave6/wave6-hw.c
> index fcf5be294ef5a..872a540df0218 100644
> --- a/drivers/media/platform/chips-media/wave6/wave6-hw.c
> +++ b/drivers/media/platform/chips-media/wave6/wave6-hw.c
[ ... ]
> @@ -179,3 +276,659 @@ int wave6_vpu_get_version(struct vpu_core_device *core)
[ ... ]
> +int wave6_vpu_dec_get_output_info(struct vpu_instance *inst, struct dec_output_info *info)
> +{
[ ... ]
> +	reg_val = vpu_read_reg_relaxed(inst->dev, W6_RET_DEC_PIC_SIZE);
> +	info->dec_pic_width = DEC_PIC_SIZE_WIDTH(reg_val);
> +	info->dec_pic_height = DEC_PIC_SIZE_HEIGHT(reg_val);
> +
> +	info->rd_ptr = wave6_vpu_dec_get_rd_ptr(inst);
> +	info->wr_ptr = p_dec_info->stream_wr_ptr;
> +	info->byte_pos_frame_start = vpu_read_reg_relaxed(inst->dev, W6_RET_DEC_AU_START_POS);
> +	info->byte_pos_frame_end = vpu_read_reg_relaxed(inst->dev, W6_RET_DEC_AU_END_POS);
> +	info->stream_end = vpu_read_reg_relaxed(inst->dev, W6_RET_DEC_STREAM_END);
> +	info->notification_flags = vpu_read_reg_relaxed(inst->dev, W6_RET_DEC_NOTIFICATION);
> +	info->last_frame_in_au = vpu_read_reg_relaxed(inst->dev, W6_RET_DEC_LAST_FRAME_FLAG);
> +
> +	reg_val = vpu_read_reg_relaxed(inst->dev, W6_RET_DEC_TIMESTAMP_LOW);
> +	info->timestamp = vpu_read_reg_relaxed(inst->dev, W6_RET_DEC_TIMESTAMP_HIGH);
> +	info->timestamp = (info->timestamp << 32) | reg_val;
> +
> +	if (decoded_idx >= 0 && decoded_idx < WAVE6_MAX_FBS)
> +		p_dec_info->dec_out_info[decoded_idx].decoded_poc = info->decoded_poc;
> +
> +	if (disp_idx >= 0 && disp_idx < WAVE6_MAX_FBS) {
> +		info->display_poc = p_dec_info->dec_out_info[disp_idx].decoded_poc;
> +		info->disp_pic_width = p_dec_info->dec_out_info[disp_idx].dec_pic_width;
> +		info->disp_pic_height = p_dec_info->dec_out_info[disp_idx].dec_pic_height;
> +	}
> +
> +	info->sequence_no = p_dec_info->seq_info.sequence_no;
> +	if (decoded_idx >= 0 && decoded_idx < WAVE6_MAX_FBS)
> +		p_dec_info->dec_out_info[decoded_idx] = *info;

[Severity: Low]
When a frame is decoded and displayed in the same step (disp_idx ==
decoded_idx), such as on the initial IDR frame or with zero reorder delay,
does reading disp_pic_width and disp_pic_height from
p_dec_info->dec_out_info[disp_idx] before p_dec_info->dec_out_info[decoded_idx]
is updated leave them set to 0 or stale dimensions from an earlier frame?

> diff --git a/drivers/media/platform/chips-media/wave6/wave6-vpuapi.c b/drivers/media/platform/chips-media/wave6/wave6-vpuapi.c
> new file mode 100644
> index 0000000000000..c8d1138334b31
> --- /dev/null
> +++ b/drivers/media/platform/chips-media/wave6/wave6-vpuapi.c
> @@ -0,0 +1,202 @@
[ ... ]
> +int wave6_vpu_dec_complete_seq_init(struct vpu_instance *inst,
> +				    struct dec_seq_info *info)
> +{
> +	struct dec_info *p_dec_info = &inst->codec_info->dec_info;
> +	int ret;
> +
> +	guard(mutex)(&inst->dev->hw_lock);
> +
> +	ret = wave6_vpu_dec_get_seq_info(inst, info);
> +	if (!ret)
> +		p_dec_info->seq_info_obtained = true;
> +
> +	info->rd_ptr = wave6_vpu_dec_get_rd_ptr(inst);
> +	info->wr_ptr = p_dec_info->stream_wr_ptr;
> +
> +	p_dec_info->seq_info = *info;
> +
> +	return ret;
> +}
[ ... ]
> +void wave6_vpu_dec_get_bitstream_buffer(struct vpu_instance *inst,
> +					dma_addr_t *p_rd_ptr,
> +					dma_addr_t *p_wr_ptr)
> +{
> +	struct dec_info *p_dec_info = &inst->codec_info->dec_info;
> +	dma_addr_t rd_ptr;
> +	dma_addr_t wr_ptr;
> +
> +	guard(mutex)(&inst->dev->hw_lock);
> +
> +	rd_ptr = wave6_vpu_dec_get_rd_ptr(inst);
> +	wr_ptr = p_dec_info->stream_wr_ptr;
> +
> +	if (p_rd_ptr)
> +		*p_rd_ptr = rd_ptr;
> +	if (p_wr_ptr)
> +		*p_wr_ptr = wr_ptr;
> +}

[Severity: Low]
Can wave6_vpu_dec_get_rd_ptr() return an unrelated register value when
called outside a W6_QUERY_OPT_GET_RESULT query?

W6_RET_DEC_BS_RD_PTR (offset 0x30C) shares its register offset with
command registers such as W6_CMD_DEC_SET_DISP_Y_BASE and
W6_CMD_DEC_PIC_SEC_AXI, and wave6_vpu_dec_get_rd_ptr() reads it directly
without issuing a query command:

drivers/media/platform/chips-media/wave6/wave6-hw.c:wave6_vpu_dec_get_rd_ptr() {
	lockdep_assert_held(&inst->dev->hw_lock);

	return vpu_read_reg(inst->dev, W6_RET_DEC_BS_RD_PTR);
}

Calling wave6_vpu_dec_get_rd_ptr() in wave6_vpu_dec_get_bitstream_buffer(),
or in wave6_vpu_dec_complete_seq_init() when wave6_vpu_dec_get_seq_info()
fails (which also overwrites p_dec_info->seq_info on error), reads
whatever value was last written to 0x30C by a previous command.

> diff --git a/drivers/media/platform/chips-media/wave6/wave6-vpuapi.h b/drivers/media/platform/chips-media/wave6/wave6-vpuapi.h
> index 62dd4969afafc..7d6a734f64b43 100644
> --- a/drivers/media/platform/chips-media/wave6/wave6-vpuapi.h
> +++ b/drivers/media/platform/chips-media/wave6/wave6-vpuapi.h
[ ... ]
> @@ -208,12 +248,116 @@ struct instance_buffer {
[ ... ]
> +struct dec_output_info {
[ ... ]
> +	u32 release_disp_frame_num: 5;
> +	u32 disp_frame_num: 5;
> +	u32 ctu_size: 2;

[Severity: Low]
Does the 2-bit ctu_size bitfield truncate DEC_PIC_TYPE_CTU_SIZE() to 0?

wave6_vpu_dec_get_output_info() assigns info->ctu_size from
DEC_PIC_TYPE_CTU_SIZE(reg_val), which evaluates to (16 << FIELD_GET(GENMASK(11, 10), (x)))
and produces 16, 32, 64, or 128, none of which fit in a 2-bit bitfield.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795075577.git.nas.chung@chipsnmedia.com?part=4

  reply	other threads:[~2026-11-19  9:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  8:59 [PATCH v8 00/11] Add support for Wave6 video codec driver Nas Chung
2026-11-19  8:59 ` [PATCH v8 01/11] dt-bindings: media: nxp: Add Wave6 video codec device Nas Chung
2026-11-19  8:59 ` [PATCH v8 02/11] media: chips-media: wave6: Add Wave6 control driver Nas Chung
2026-11-19  9:26   ` sashiko-bot
2026-11-19 19:36     ` Frank Li
2026-11-19 20:07   ` Frank Li
2026-11-20  8:58     ` Nas Chung
2026-11-19  8:59 ` [PATCH v8 03/11] media: chips-media: wave6: Add Wave6 core driver Nas Chung
2026-11-19  9:32   ` sashiko-bot
2026-11-19 20:27   ` Frank Li
2026-11-20  8:49     ` Nas Chung
2026-11-19  8:59 ` [PATCH v8 04/11] media: chips-media: wave6: Add Wave6 decoder firmware interface Nas Chung
2026-11-19  9:22   ` sashiko-bot [this message]
2026-11-19 20:37   ` Frank Li
2026-11-20  8:35     ` Nas Chung
2026-11-19  8:59 ` [PATCH v8 05/11] media: chips-media: wave6: Add Wave6 m2m decoder Nas Chung
2026-11-19  9:31   ` sashiko-bot
2026-11-19  9:00 ` [PATCH v8 06/11] media: chips-media: wave6: Add Wave6 encoder firmware interface Nas Chung
2026-11-19  9:10   ` sashiko-bot
2026-11-19  9:00 ` [PATCH v8 07/11] media: chips-media: wave6: Add Wave6 m2m encoder Nas Chung
2026-11-19  9:35   ` sashiko-bot
2026-11-19  9:00 ` [PATCH v8 08/11] media: chips-media: wave6: Add trace and debugfs Nas Chung
2026-11-19  9:14   ` sashiko-bot
2026-11-19  9:00 ` [PATCH v8 09/11] media: chips-media: wave6: Add performance profiling Nas Chung
2026-11-19  9:20   ` sashiko-bot
2026-11-19 20:56   ` Frank Li
2026-11-19  9:00 ` [PATCH v8 10/11] media: chips-media: wave6: Add Wave6 thermal cooling device Nas Chung
2026-11-19  9:21   ` sashiko-bot
2026-11-19 21:03   ` Frank Li
2026-11-20  4:34     ` Nas Chung
2026-11-19  9:00 ` [PATCH v8 11/11] arm64: dts: freescale: imx95: Add video codec node Nas Chung
2026-11-19  9:37   ` sashiko-bot
2026-11-19 21:05   ` Frank Li
2026-11-20  4:32     ` Nas Chung

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=sashiko-outbox-222819@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=media-ci@linuxtv.org \
    --cc=nas.chung@chipsnmedia.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.