From: sashiko-bot@kernel.org
To: "Kyrie Wu" <kyrie.wu@mediatek.com>
Cc: robh@kernel.org, linux-media@vger.kernel.org,
conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v5 08/14] media: mediatek: vcodec: clean xpc status
Date: Wed, 03 Jun 2026 08:54:47 +0000 [thread overview]
Message-ID: <20260603085447.8F55C1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260603084045.17488-9-kyrie.wu@mediatek.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The newly introduced `mtk_vdec_hw_clean_xpc` function performs non-atomic read-modify-write (RMW) operations on a shared hardware register from concurrent interrupt handlers without any locking, leading to potential state corruption and lost XPC clean pulses.
- [Low] Type confusion in enum usage for indexing main_dev->reg_base.
--
commit 6d6918cc2e35280ad95cd095aa0042f4f69bdfc5
Author: Yunfei Dong <yunfei.dong@mediatek.com>
media: mediatek: vcodec: clean xpc status
This commit adds functionality to clean the XPC status upon receiving a
decoder hardware interrupt for the MT8196 platform.
> diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c
> index 881d5de41e050..e4e527fe54dcb 100644
> --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c
> +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_hw.c
> @@ -61,6 +61,31 @@ static int mtk_vdec_hw_prob_done(struct mtk_vcodec_dec_dev *vdec_dev)
> return 0;
> }
>
> +static void mtk_vdec_hw_write_reg_mask(void __iomem *reg_base, u32 reg_offset, u32 val, u32 mask)
> +{
> + void __iomem *reg_addr = reg_base + reg_offset;
> + u32 reg_val;
> +
> + reg_val = readl(reg_addr);
> + reg_val &= ~mask;
> + reg_val |= (val & mask);
> + writel(reg_val, reg_addr);
> +}
[Severity: High]
Since LAT0 and CORE hardware subdevices share the same parent device register
space and have separate interrupt lines, can their interrupt handlers race
here?
If both execute concurrently on different CPUs and call
mtk_vdec_hw_write_reg_mask(), could the unsynchronized read-modify-write
sequence cause one CPU to overwrite and lose the XPC clean pulse from the
other?
Does this sequence need a lock to protect the shared register state?
> +
> +static void mtk_vdec_hw_clean_xpc(struct mtk_vdec_hw_dev *dev)
> +{
> + u32 val, mask, addr = VDEC_XPC_CLEAN_ADDR;
[ ... ]
> @@ -166,6 +193,7 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev)
> subdev_dev->hw_idx = hw_idx;
> subdev_dev->main_dev = main_dev;
> subdev_dev->reg_base[VDEC_HW_SYS] = main_dev->reg_base[VDEC_HW_SYS];
> + subdev_dev->reg_base[VDEC_HW_XPC] = main_dev->reg_base[VDEC_HW_MISC];
[Severity: Low]
Is the index VDEC_HW_MISC correct for main_dev->reg_base?
It appears main_dev->reg_base is typically indexed by enum mtk_hw_reg_idx
(like VDEC_MISC), while VDEC_HW_MISC belongs to enum mtk_vdec_hw_reg_idx.
Even though both currently evaluate to 1 and map correctly, could this cause
issues or point to the wrong hardware registers if the enums drift apart in
future updates?
> set_bit(subdev_dev->hw_idx, main_dev->subdev_bitmap);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260603084045.17488-1-kyrie.wu@mediatek.com?part=8
next prev parent reply other threads:[~2026-06-03 8:54 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 8:40 [PATCH v5 00/14] media: mediatek: vcodec: support video decoder in mt8196 Kyrie Wu
2026-06-03 8:40 ` [PATCH v5 01/14] media: mediatek: vcodec: support vcp architecture Kyrie Wu
2026-06-03 8:40 ` [PATCH v5 02/14] media: mediatek: vcodec: add driver to support vcp Kyrie Wu
2026-06-03 8:58 ` sashiko-bot
2026-06-03 8:40 ` [PATCH v5 03/14] media: mediatek: vcodec: add driver to support vcp encoder Kyrie Wu
2026-06-03 11:01 ` sashiko-bot
2026-06-03 8:40 ` [PATCH v5 04/14] media: mediatek: vcodec: get different firmware ipi id Kyrie Wu
2026-06-03 8:40 ` [PATCH v5 05/14] media: mediatek: vcodec: get share memory address Kyrie Wu
2026-06-03 8:59 ` sashiko-bot
2026-06-03 8:40 ` [PATCH v5 06/14] media: mediatek: vcodec: define MT8196 vcodec levels Kyrie Wu
2026-06-03 8:51 ` sashiko-bot
2026-06-03 8:40 ` [PATCH v5 07/14] media: mediatek: vcodec: support 36bit iova address Kyrie Wu
2026-06-03 8:52 ` sashiko-bot
2026-06-03 8:40 ` [PATCH v5 08/14] media: mediatek: vcodec: clean xpc status Kyrie Wu
2026-06-03 8:54 ` sashiko-bot [this message]
2026-06-03 8:40 ` [PATCH v5 09/14] media: mediatek: vcodec: add debug information Kyrie Wu
2026-06-03 8:54 ` sashiko-bot
2026-06-03 8:40 ` [PATCH v5 10/14] media: mediatek: vcodec: send share memory address to vcp Kyrie Wu
2026-06-03 11:09 ` sashiko-bot
2026-06-03 8:40 ` [PATCH v5 11/14] dt-bindings: media: mediatek: vcodec: add decoder dt-bindings for mt8196 Kyrie Wu
2026-06-03 9:03 ` sashiko-bot
2026-06-03 8:40 ` [PATCH v5 12/14] media: mediatek: vcodec: add decoder compatible to support mt8196 Kyrie Wu
2026-06-03 8:59 ` sashiko-bot
2026-06-03 8:40 ` [PATCH v5 13/14] media: mediatek: decoder: fill av1 buffer size with picinfo Kyrie Wu
2026-06-03 9:07 ` sashiko-bot
2026-06-03 8:40 ` [PATCH v5 14/14] media: mediatek: decoder: support av1 extend vsi Kyrie Wu
2026-06-03 9:10 ` 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=20260603085447.8F55C1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kyrie.wu@mediatek.com \
--cc=linux-media@vger.kernel.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