mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas@ndufresne.ca>
To: Runyu Xiao <runyu.xiao@seu.edu.cn>, tiffany.lin@mediatek.com
Cc: andrew-ct.chen@mediatek.com, yunfei.dong@mediatek.com,
	mchehab@kernel.org, 	matthias.bgg@gmail.com,
	angelogioacchino.delregno@collabora.com,
		linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	jianhao.xu@seu.edu.cn, 	stable@vger.kernel.org
Subject: Re: [PATCH] media: mediatek: vcodec: Initialize context lock before firmware setup
Date: Sun, 04 Oct 2026 07:17:43 -0400	[thread overview]
Message-ID: <8ea77a207f6f99d4f20610670e5f88fc56df3faa.camel@ndufresne.ca> (raw)
In-Reply-To: <20260830144827.2701887-1-runyu.xiao@seu.edu.cn>

[-- Attachment #1: Type: text/plain, Size: 1965 bytes --]

Hi,

Le dimanche 30 août 2026 à 22:48 +0800, Runyu Xiao a écrit :
> The VPU firmware setup registers a watchdog callback that accesses the
> encoder context lock. Initialize the lock before selecting the firmware
> implementation so the callback cannot observe an uninitialized lock during
> probe.
> 
> Fixes: afaaf3a0f647 ("media: mediatek: vcodec: adding lock to protect encoder context list")
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:GPT-5
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
> ---
>  .../media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
> index 4e4541b2f..e6cd3817a 100644
> --- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
> +++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
> @@ -255,6 +255,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>  
>  	INIT_LIST_HEAD(&dev->ctx_list);
>  	dev->plat_dev = pdev;
> +	spin_lock_init(&dev->dev_ctx_lock);

I'll have to reject this one for now since the theory of a callback taking the
lock while the probe is happening does not hold. The very first place the lock
will be taken is in _open() and that cannot happen before
video_register_device(), which is kept last. Please demonstrate what the issue
you are suggesting if you'd like to see this merged.

Nicolas

>  
>  	if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
>  				  &rproc_phandle)) {
> @@ -308,7 +309,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>  
>  	mutex_init(&dev->enc_mutex);
>  	mutex_init(&dev->dev_mutex);
> -	spin_lock_init(&dev->dev_ctx_lock);
>  	spin_lock_init(&dev->irqlock);
>  
>  	snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s",

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-10-04 11:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30 14:48 Runyu Xiao
2026-10-04 11:17 ` Nicolas Dufresne [this message]
2026-10-04 12:39   ` Runyu Xiao
2026-10-04 13:18     ` Nicolas Dufresne
2026-10-08 12:14 ` [PATCH v2] " Runyu Xiao

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=8ea77a207f6f99d4f20610670e5f88fc56df3faa.camel@ndufresne.ca \
    --to=nicolas@ndufresne.ca \
    --cc=andrew-ct.chen@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=runyu.xiao@seu.edu.cn \
    --cc=stable@vger.kernel.org \
    --cc=tiffany.lin@mediatek.com \
    --cc=yunfei.dong@mediatek.com \
    /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®