Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kyrie Wu" <kyrie.wu@mediatek.com>, devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v19 12/13] media: mediatek: jpeg: add jpeg compatible
Date: Mon, 16 Nov 2026 02:04:27 +0000	[thread overview]
Message-ID: <sashiko-outbox-216062@kernel.org> (raw)
In-Reply-To: <20261116013402.1273016-13-kyrie.wu@mediatek.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] media: mediatek: jpeg: bad 34-bit stall address in
  mtk_jpeg_set_enc_dst()
--

commit 2178cb0abdb84f47ce9c6cd9ebe6e4f64b01196b
Author: Kyrie Wu <kyrie.wu@mediatek.com>

media: mediatek: jpeg: add jpeg compatible

This commit adds MT8196 device tree compatible strings and driver variant
data for the MediaTek multi-core JPEG encoder and decoder.

> diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
> index 1a289e4487930..b38feef2dcbd4 100644
> --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
> +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
> @@ -1963,6 +1963,20 @@ static struct mtk_jpeg_variant mtk8195_jpegenc_drvdata = {
>  	.jpeg_worker = mtk_jpegenc_worker,
>  };
>  
> +static struct mtk_jpeg_variant mtk8196_jpegenc_drvdata = {
> +	.formats = mtk_jpeg_enc_formats,
> +	.num_formats = MTK_JPEG_ENC_NUM_FORMATS,
> +	.qops = &mtk_jpeg_enc_qops,
> +	.m2m_ops = &mtk_jpeg_multicore_enc_m2m_ops,
> +	.dev_name = "mtk-jpeg-enc",
> +	.ioctl_ops = &mtk_jpeg_enc_ioctl_ops,
> +	.out_q_default_fourcc = V4L2_PIX_FMT_YUYV,
> +	.cap_q_default_fourcc = V4L2_PIX_FMT_JPEG,
> +	.multi_core = true,
> +	.jpeg_worker = mtk_jpegenc_worker,
> +	.support_34bit = true,
> +};

[Severity: High]
Does enabling support_34bit with mtk_jpegenc_worker() program a corrupted
upper stall address into JPEG_ENC_STALL_ADDR0_EXT?

mtk_jpegenc_worker() calls mtk_jpeg_set_enc_dst(), which adds the buffer
byte size directly to the 2-bit upper address extension instead of
extracting the upper bits of dma_addr + size:

drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c:mtk_jpeg_set_enc_dst() {
    ...
	if (support_34bit) {
		addr_ext = FIELD_PREP(MTK_JPEG_ADDR_MASK, upper_32_bits(dma_addr));
		writel(addr_ext, base + JPEG_ENC_DEST_ADDR0_EXT);
		writel(addr_ext + size, base + JPEG_ENC_STALL_ADDR0_EXT);
	}
}

Because size is page-aligned, any carry across a 4 GiB boundary in
dma_addr + size is lost from bits [1:0] while upper bits of size are
written into the register, corrupting the 34-bit destination end boundary
used to stall DMA writes when the encoded bitstream overflows the buffer.
Should JPEG_ENC_STALL_ADDR0_EXT be programmed with
FIELD_PREP(MTK_JPEG_ADDR_MASK, upper_32_bits(dma_addr + size))?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116013402.1273016-1-kyrie.wu@mediatek.com?part=12

  reply	other threads:[~2026-11-16  2:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  1:33 [PATCH v19 00/13] media: mediatek: jpeg: add MT8196 JPEG support Kyrie Wu
2026-11-16  1:33 ` [PATCH v19 01/13] media: mediatek: jpeg: fix jpeg cores' amounts setting Kyrie Wu
2026-11-16  1:48   ` sashiko-bot
2026-11-16  1:33 ` [PATCH v19 02/13] media: mediatek: jpeg: fix jpeg buffer payload size setting Kyrie Wu
2026-11-16  1:33 ` [PATCH v19 03/13] media: mediatek: jpeg: fix buffer structure size and layout Kyrie Wu
2026-11-16  1:33 ` [PATCH v19 04/13] media: mediatek: jpeg: Fix buffer completion on multi-core streaming stop Kyrie Wu
2026-11-16  1:33 ` [PATCH v19 05/13] media: mediatek: jpeg: Fix multi-core clk suspend and resume setting Kyrie Wu
2026-11-16  2:03   ` sashiko-bot
2026-11-16  1:33 ` [PATCH v19 06/13] media: mediatek: jpeg: fix buffer state update timing Kyrie Wu
2026-11-16  1:52   ` sashiko-bot
2026-11-16  1:33 ` [PATCH v19 07/13] media: mediatek: jpeg: fix resolution change event handling in decoder Kyrie Wu
2026-11-16  1:55   ` sashiko-bot
2026-11-16  1:33 ` [PATCH v19 08/13] media: mediatek: jpeg: fix remove buffer removal timing for multi-core Kyrie Wu
2026-11-16  1:33 ` [PATCH v19 09/13] dt-bindings: soc: mediatek: Add MT8196 JPEG SMMU Kyrie Wu
2026-11-16  1:52   ` sashiko-bot
2026-11-16  1:33 ` [PATCH v19 10/13] media: dt-bindings: mediatek,jpeg: Add mediatek, mt8196-jpgdec compatible Kyrie Wu
2026-11-16  1:33 ` [PATCH v19 11/13] media: dt-bindings: mediatek,jpeg: Add mediatek, mt8196-jpgenc compatible Kyrie Wu
2026-11-16  1:33 ` [PATCH v19 12/13] media: mediatek: jpeg: add jpeg compatible Kyrie Wu
2026-11-16  2:04   ` sashiko-bot [this message]
2026-11-16  1:33 ` [PATCH v19 13/13] media: mediatek: jpeg: add jpeg smmu sid setting Kyrie Wu
2026-11-16  2:04   ` sashiko-bot

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-216062@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kyrie.wu@mediatek.com \
    --cc=media-ci@linuxtv.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox