mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: mediatek: vcodec: Initialize context lock before firmware setup
@ 2026-08-30 14:48 Runyu Xiao
  2026-10-04 11:17 ` Nicolas Dufresne
  2026-10-08 12:14 ` [PATCH v2] " Runyu Xiao
  0 siblings, 2 replies; 5+ messages in thread
From: Runyu Xiao @ 2026-08-30 14:48 UTC (permalink / raw)
  To: tiffany.lin
  Cc: andrew-ct.chen, yunfei.dong, mchehab, matthias.bgg,
	angelogioacchino.delregno, linux-media, linux-kernel, runyu.xiao,
	jianhao.xu, stable

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);
 
 	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",
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-08 12:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-30 14:48 [PATCH] media: mediatek: vcodec: Initialize context lock before firmware setup Runyu Xiao
2026-10-04 11:17 ` Nicolas Dufresne
2026-10-04 12:39   ` Runyu Xiao
2026-10-04 13:18     ` Nicolas Dufresne
2026-10-08 12:14 ` [PATCH v2] " Runyu Xiao

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®