From nobody Tue Dec 16 01:57:07 2025 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AC7330F938; Tue, 2 Dec 2025 09:48:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764668898; cv=none; b=lzcuiJ06Kzy9VPVCkUJx+QkL/aNZwmb630MgXNdm6Kfkm72pqRhnZbJpj/y+2Qff5Ocp0ZeG0+LO095PidaSvBroIuuV4usSpXoNdlQ4esMriU0TWWMigRBfvInxAw++dbI0zPBK7/dK527/e6Ij5PIMa0wtLSGa9NIOLusDkxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764668898; c=relaxed/simple; bh=DUD+IG20g8nBszI9RxMqAx00g5pguJIOzHrEekSkUUU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aJUWCb7HYcCI5P5+mIp+cLk6AMDwNFH8onTFQBJLsFUVN0uRUuYhY7ga5s5xRdIhuZAkCFQCkfuRtqjFEAF4sLyXh03Iqfd3n+IhRxU7f8ljgOUqDc1i8eRPrTCc10MV4JOU7Ti0xuR3lQ7HOglreb/KPRXoF088VbvC1j9PgGk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=U5HN5oAS; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="U5HN5oAS" X-UUID: 02b14856cf6411f0b2bf0b349165d6e0-20251202 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:To:From; bh=ViQArR1ogSjKsas39yr97vtLVmmd76w4W76GCjYsi14=; b=U5HN5oASaum6Xelr55LeKUmsZnwWvpC94gZvBDBhwP3BpTP9mXpZ/vKioCWYVqNQhEWKz9pn+SuPERbBj8Pe9ET4L+iCN6uAXWEV+oR6E8cNpOH4ciqz2iLny1uBFM6bsNxBAW0tOqtwy3Jp8goMn9P/57FJQoEurYU80pP1u6o=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.6,REQID:30191727-d274-4a69-a9f4-4e262b8681d6,IP:0,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:0 X-CID-META: VersionHash:a9d874c,CLOUDID:544bbca9-6421-45b1-b8b8-e73e3dc9a90f,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|836|888|898,TC:-5,Content: 0|15|50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:nil,COL:0,OS I:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 02b14856cf6411f0b2bf0b349165d6e0-20251202 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 355303269; Tue, 02 Dec 2025 17:48:09 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.26; Tue, 2 Dec 2025 17:48:08 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1748.26 via Frontend Transport; Tue, 2 Dec 2025 17:48:07 +0800 From: Kyrie Wu To: Hans Verkuil , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Kyrie Wu , , , , , Subject: [PATCH v11 07/12] media: mediatek: jpeg: fix decoding resolution change operation Date: Tue, 2 Dec 2025 17:47:55 +0800 Message-ID: <20251202094800.6140-8-kyrie.wu@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20251202094800.6140-1-kyrie.wu@mediatek.com> References: <20251202094800.6140-1-kyrie.wu@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Content-Type: text/plain; charset="utf-8" 1.add a judgement for src buffer to avoid kernel crash in the stop streaming function; 2.When a resolution changing occurs, it needs to set new resolution parameter immediately and then report this event. Otherwise, if the original software process is maintained, the resolution change event is reported firstly, the CPU is dispatched to the app to process the event, and the driver does not set a new resolution, which will cause parameter errors. 3.After a resolution change occurred, decoding should not continue, needs to wait until new buffers are ready and the state machine changed. Fixes: dedc21500334 ("media: mtk-jpegdec: add jpeg decode worker interface") Signed-off-by: Kyrie Wu --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers= /media/platform/mediatek/jpeg/mtk_jpeg_core.c index 5ffaee4dcd19..9233bbfe2d97 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -887,7 +887,8 @@ static void mtk_jpeg_dec_stop_streaming(struct vb2_queu= e *q) =20 vb =3D v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); src_buf =3D mtk_jpeg_vb2_to_srcbuf(&vb->vb2_buf); - mtk_jpeg_set_queue_data(ctx, &src_buf->dec_param); + if (!IS_ERR_OR_NULL(src_buf)) + mtk_jpeg_set_queue_data(ctx, &src_buf->dec_param); ctx->state =3D MTK_JPEG_RUNNING; } else if (V4L2_TYPE_IS_OUTPUT(q->type)) { ctx->state =3D MTK_JPEG_INIT; @@ -1749,11 +1750,15 @@ static void mtk_jpegdec_worker(struct work_struct *= work) =20 if (mtk_jpeg_check_resolution_change(ctx, &jpeg_src_buf->dec_param)) { - mtk_jpeg_queue_src_chg_event(ctx); + mtk_jpeg_set_queue_data(ctx, &jpeg_src_buf->dec_param); ctx->state =3D MTK_JPEG_SOURCE_CHANGE; + mtk_jpeg_queue_src_chg_event(ctx); goto getbuf_fail; } =20 + if (ctx->state =3D=3D MTK_JPEG_SOURCE_CHANGE) + goto getbuf_fail; + mtk_jpegdec_set_hw_param(ctx, hw_id, src_buf, dst_buf); ret =3D pm_runtime_resume_and_get(comp_jpeg[hw_id]->dev); if (ret < 0) { --=20 2.45.2