From: "Aakarsh Jain/Aakarsh Jain" <aakarsh.jain@samsung.com>
To: "'Hans Verkuil'" <hverkuil-cisco@xs4all.nl>,
<linux-arm-kernel@lists.infradead.org>,
<linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <m.szyprowski@samsung.com>, <andrzej.hajda@intel.com>,
<mchehab@kernel.org>, <krzysztof.kozlowski+dt@linaro.org>,
<linux-samsung-soc@vger.kernel.org>, <gost.dev@samsung.com>,
<aswani.reddy@samsung.com>, <pankaj.dubey@samsung.com>
Subject: RE: [PATCH] media: s5p-mfc: Corrected NV12M/NV21M plane-sizes
Date: Wed, 26 Feb 2025 15:55:16 +0530 [thread overview]
Message-ID: <000001db8838$bc466e00$34d34a00$@samsung.com> (raw)
In-Reply-To: <c09e7819-a7d9-432f-baab-732e81b3f489@xs4all.nl>
Hi Hans,
-----Original Message-----
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Sent: 11 October 2024 18:17
To: Aakarsh Jain <aakarsh.jain@samsung.com>; linux-arm-kernel@lists.infradead.org; linux-media@vger.kernel.org; linux-kernel@vger.kernel.org
Cc: m.szyprowski@samsung.com; andrzej.hajda@intel.com; mchehab@kernel.org; krzysztof.kozlowski+dt@linaro.org; linux-samsung-soc@vger.kernel.org; gost.dev@samsung.com; aswani.reddy@samsung.com; pankaj.dubey@samsung.com
Subject: Re: [PATCH] media: s5p-mfc: Corrected NV12M/NV21M plane-sizes
On 06/08/2024 13:57, Aakarsh Jain wrote:
> There is a possibility of getting page fault if the overall buffer
> size is not aligned to 256bytes. Since MFC does read operation only
> and it won't corrupt the data values even if it reads the extra bytes.
> Corrected luma and chroma plane sizes for V4L2_PIX_FMT_NV12M and
> V4L2_PIX_FMT_NV21M pixel format.
>
> Signed-off-by: Aakarsh Jain <aakarsh.jain@samsung.com>
> ---
> .../media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> index 73f7af674c01..03c957221fc4 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> @@ -498,8 +498,8 @@ static void s5p_mfc_dec_calc_dpb_size_v6(struct s5p_mfc_ctx *ctx)
> case V4L2_PIX_FMT_NV21M:
> ctx->stride[0] = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN_V6);
> ctx->stride[1] = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN_V6);
> - ctx->luma_size = calc_plane(ctx->stride[0], ctx->img_height);
> - ctx->chroma_size = calc_plane(ctx->stride[1], (ctx->img_height / 2));
> + ctx->luma_size = calc_plane(ctx->img_width, ctx->img_height);
> + ctx->chroma_size = calc_plane(ctx->img_width, (ctx->img_height >>
> +1));
I don't really understand why this is changed. Looking at the implementation of calc_plane and the various #define values that are used here and in calc_plane, the number should be the same.
I think the original code makes more sense.
okay.
If I missed something, let me know.
> break;
> case V4L2_PIX_FMT_YUV420M:
> case V4L2_PIX_FMT_YVU420M:
> @@ -539,9 +539,11 @@ static void s5p_mfc_dec_calc_dpb_size_v6(struct
> s5p_mfc_ctx *ctx) static void s5p_mfc_enc_calc_src_size_v6(struct
> s5p_mfc_ctx *ctx) {
> unsigned int mb_width, mb_height;
> + unsigned int default_size;
>
> mb_width = MB_WIDTH(ctx->img_width);
> mb_height = MB_HEIGHT(ctx->img_height);
> + default_size = (mb_width * mb_height) * 256;
>
> if (IS_MFCV12(ctx->dev)) {
> switch (ctx->src_fmt->fourcc) {
> @@ -549,8 +551,8 @@ static void s5p_mfc_enc_calc_src_size_v6(struct s5p_mfc_ctx *ctx)
> case V4L2_PIX_FMT_NV21M:
> ctx->stride[0] = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN_V6);
> ctx->stride[1] = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN_V6);
> - ctx->luma_size = ctx->stride[0] * ALIGN(ctx->img_height, 16);
> - ctx->chroma_size = ctx->stride[0] * ALIGN(ctx->img_height / 2, 16);
> + ctx->luma_size = ALIGN(default_size, 256);
> + ctx->chroma_size = ALIGN(default_size / 2, 256);
Isn't this effectively the same as doing:
ctx->luma_size = ALIGN(ctx->luma_size, 256);
ctx->chroma_size = ALIGN(ctx->chroma_size, 256);
I.e., the bug is that these sizes are not rounded up to a multiple of 256, so just add that, rather than changing code elsewhere.
I might be wrong, but this seems a much simpler solution.
sure Hans. Will address in v2.
Thanks for review.
Regards,
Hans
> break;
> case V4L2_PIX_FMT_YUV420M:
> case V4L2_PIX_FMT_YVU420M:
prev parent reply other threads:[~2025-02-27 3:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240806120911epcas5p1b0defc027a7f03ee9bf5f21036d3ae5e@epcas5p1.samsung.com>
2024-08-06 11:57 ` [PATCH] media: s5p-mfc: Corrected NV12M/NV21M plane-sizes Aakarsh Jain
2024-08-06 14:37 ` Nicolas Dufresne
2024-08-07 11:53 ` Aakarsh Jain
2024-08-26 9:13 ` Aakarsh Jain
2024-10-11 12:46 ` Hans Verkuil
2025-02-26 10:25 ` Aakarsh Jain/Aakarsh Jain [this message]
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='000001db8838$bc466e00$34d34a00$@samsung.com' \
--to=aakarsh.jain@samsung.com \
--cc=andrzej.hajda@intel.com \
--cc=aswani.reddy@samsung.com \
--cc=gost.dev@samsung.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=pankaj.dubey@samsung.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;
as well as URLs for NNTP newsgroup(s).