From nobody Fri Dec 19 13:11:13 2025 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (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 D2A0622DA1D; Wed, 21 May 2025 02:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747794220; cv=none; b=DaEvJd+7bVzNRHkhxRZmwVMp4qwCrQJDxV+kEU0nsKDdqcwGuur5FZFlR9PLM9BVtOgTRHu8WSRF/seykM8aobVCXNoPLA/zPvjqZCT64jMUTd6Gy5KfmHwmggAkaApexvc+CbnXpRohwUOTHX2y6bqwoy8mf87RUcwxr3wyBO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747794220; c=relaxed/simple; bh=pWzwjgQ2f/53kmF5n7c7UlKrqztnmqHU0+OyfCWG1ss=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TCk8hwWpiPllTS1r/T65KmQtLSP9R9LWMqr7KMGH0+bs3lg1UPf5R0xX1X8lR/zgiTIPlWOZrkgSHqI5NAYISFXcsPcxoeFDI7PVeI2ZhTUC8fpWiXLaYvx67TSrwfcMgBs4LGWG9BDdSiYNBbVzdoBI2Uk/cKSTBrRytFM/+wg= 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=kUk9Wa5l; arc=none smtp.client-ip=210.61.82.184 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="kUk9Wa5l" X-UUID: 970435cc35ea11f082f7f7ac98dee637-20250521 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=MafHlrK67o/d3FGCy1u+Y7qasnBcS5mIW6WlhV/wvWA=; b=kUk9Wa5l26iTVZ6RIBVx6T8BDLK+IM+soOE/A8FL0wNl3jKlGHdqbunb5eIaYFW2rFZz9ifadvxhVz57iu+MtOFpOz2fZsxb0Rtsty0PLNNHB8/SNex18PwYOig3PIvNazOHh1sc7nFzNZwu5LwQVZNuIAIt0vwO7/1wGWcr9nc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.2.1,REQID:c2748ec8-b98c-4102-92a6-1237a5329b7b,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:0ef645f,CLOUDID:ee11ef58-eac4-4b21-88a4-d582445d304a,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 970435cc35ea11f082f7f7ac98dee637-20250521 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1235859604; Wed, 21 May 2025 10:23:32 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.39; Wed, 21 May 2025 10:23:22 +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.1258.39 via Frontend Transport; Wed, 21 May 2025 10:23:29 +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 v4 06/12] media: mediatek: jpeg: refactor jpeg buffer payload setting Date: Wed, 21 May 2025 10:23:16 +0800 Message-ID: <20250521022322.27576-7-kyrie.wu@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20250521022322.27576-1-kyrie.wu@mediatek.com> References: <20250521022322.27576-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. for multi-core jpegdec: core0: |<-------- decoding buffer0 and resolution changed to smaller core1: |<-------- decoding buffer1 core0: |<- handling resolution changing core0: |<- vb2_set_plane_payload 2. the payload size is changed on the step of set format. Because core1 is running and streaming has not been stopped, the format cannot be set again, resulting in no change in the payload size. 3. at this time, the payload size is bigger than buffer length, it will print a warnning call trace 4. set payload size must less than buffer length Signed-off-by: Kyrie Wu --- .../platform/mediatek/jpeg/mtk_jpeg_core.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers= /media/platform/mediatek/jpeg/mtk_jpeg_core.c index 0074d1edb534..52d59bb5c9ad 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -720,10 +720,22 @@ static int mtk_jpeg_buf_prepare(struct vb2_buffer *vb) plane_fmt =3D q_data->pix_mp.plane_fmt[i]; if (ctx->enable_exif && q_data->fmt->fourcc =3D=3D V4L2_PIX_FMT_JPEG) - vb2_set_plane_payload(vb, i, plane_fmt.sizeimage + - MTK_JPEG_MAX_EXIF_SIZE); + if (vb->planes[i].length > (plane_fmt.sizeimage + + MTK_JPEG_MAX_EXIF_SIZE)) + vb2_set_plane_payload(vb, i, + plane_fmt.sizeimage + + MTK_JPEG_MAX_EXIF_SIZE); + else + vb2_set_plane_payload(vb, i, + vb->planes[i].length); + else - vb2_set_plane_payload(vb, i, plane_fmt.sizeimage); + if (vb->planes[i].length > plane_fmt.sizeimage) + vb2_set_plane_payload(vb, i, + plane_fmt.sizeimage); + else + vb2_set_plane_payload(vb, i, + vb->planes[i].length); } =20 return 0; --=20 2.46.0