* [PATCH] hantro: Format IOCTLs compliance fixes @ 2021-01-11 11:35 Ricardo Ribalda 2021-01-11 11:48 ` Ezequiel Garcia 0 siblings, 1 reply; 5+ messages in thread From: Ricardo Ribalda @ 2021-01-11 11:35 UTC (permalink / raw) To: Ezequiel Garcia, Philipp Zabel, Mauro Carvalho Chehab, Greg Kroah-Hartman, linux-media, linux-rockchip, devel, linux-kernel Cc: Ricardo Ribalda Clear the reserved fields. Fixes: fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed test VIDIOC_TRY_FMT: FAIL fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed test VIDIOC_S_FMT: FAIL Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/staging/media/hantro/hantro_v4l2.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c index b668a82d40ad..9b384fbffc93 100644 --- a/drivers/staging/media/hantro/hantro_v4l2.c +++ b/drivers/staging/media/hantro/hantro_v4l2.c @@ -239,6 +239,7 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, const struct hantro_fmt *fmt, *vpu_fmt; bool capture = V4L2_TYPE_IS_CAPTURE(type); bool coded; + int i; coded = capture == ctx->is_encoder; @@ -293,6 +294,10 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, pix_mp->width * pix_mp->height * fmt->max_depth; } + for (i = 0; i < pix_mp->num_planes; i++) + memset(pix_mp->plane_fmt[i].reserved, 0, + sizeof(pix_mp->plane_fmt[i].reserved)); + return 0; } -- 2.30.0.284.gd98b1dd5eaa7-goog ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] hantro: Format IOCTLs compliance fixes 2021-01-11 11:35 [PATCH] hantro: Format IOCTLs compliance fixes Ricardo Ribalda @ 2021-01-11 11:48 ` Ezequiel Garcia 2021-01-11 11:55 ` Ricardo Ribalda 0 siblings, 1 reply; 5+ messages in thread From: Ezequiel Garcia @ 2021-01-11 11:48 UTC (permalink / raw) To: Ricardo Ribalda, Philipp Zabel, Mauro Carvalho Chehab, Greg Kroah-Hartman, linux-media, linux-rockchip, devel, linux-kernel Hi Ricardo, On Mon, 2021-01-11 at 12:35 +0100, Ricardo Ribalda wrote: > Clear the reserved fields. > > Fixes: > fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed > test VIDIOC_TRY_FMT: FAIL > fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed > test VIDIOC_S_FMT: FAIL > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/staging/media/hantro/hantro_v4l2.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c > index b668a82d40ad..9b384fbffc93 100644 > --- a/drivers/staging/media/hantro/hantro_v4l2.c > +++ b/drivers/staging/media/hantro/hantro_v4l2.c > @@ -239,6 +239,7 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, > const struct hantro_fmt *fmt, *vpu_fmt; > bool capture = V4L2_TYPE_IS_CAPTURE(type); > bool coded; > + int i; > > coded = capture == ctx->is_encoder; > > @@ -293,6 +294,10 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, > pix_mp->width * pix_mp->height * fmt->max_depth; > } > > + for (i = 0; i < pix_mp->num_planes; i++) > + memset(pix_mp->plane_fmt[i].reserved, 0, > + sizeof(pix_mp->plane_fmt[i].reserved)); > + This looks like something that should be handled at the core, probably in drivers/media/v4l2-core/v4l2-ioctl.c::v4l_try_fmt(). Thanks, Ezequiel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hantro: Format IOCTLs compliance fixes 2021-01-11 11:48 ` Ezequiel Garcia @ 2021-01-11 11:55 ` Ricardo Ribalda 2021-01-11 12:22 ` Ricardo Ribalda 0 siblings, 1 reply; 5+ messages in thread From: Ricardo Ribalda @ 2021-01-11 11:55 UTC (permalink / raw) To: Ezequiel Garcia Cc: Philipp Zabel, Mauro Carvalho Chehab, Greg Kroah-Hartman, Linux Media Mailing List, linux-rockchip, devel, Linux Kernel Mailing List Hi Ezequiel On Mon, Jan 11, 2021 at 12:48 PM Ezequiel Garcia <ezequiel@collabora.com> wrote: > > Hi Ricardo, > > On Mon, 2021-01-11 at 12:35 +0100, Ricardo Ribalda wrote: > > Clear the reserved fields. > > > > Fixes: > > fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed > > test VIDIOC_TRY_FMT: FAIL > > fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed > > test VIDIOC_S_FMT: FAIL > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > --- > > drivers/staging/media/hantro/hantro_v4l2.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c > > index b668a82d40ad..9b384fbffc93 100644 > > --- a/drivers/staging/media/hantro/hantro_v4l2.c > > +++ b/drivers/staging/media/hantro/hantro_v4l2.c > > @@ -239,6 +239,7 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, > > const struct hantro_fmt *fmt, *vpu_fmt; > > bool capture = V4L2_TYPE_IS_CAPTURE(type); > > bool coded; > > + int i; > > > > coded = capture == ctx->is_encoder; > > > > @@ -293,6 +294,10 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, > > pix_mp->width * pix_mp->height * fmt->max_depth; > > } > > > > + for (i = 0; i < pix_mp->num_planes; i++) > > + memset(pix_mp->plane_fmt[i].reserved, 0, > > + sizeof(pix_mp->plane_fmt[i].reserved)); > > + > > This looks like something that should be handled at the core, > probably in drivers/media/v4l2-core/v4l2-ioctl.c::v4l_try_fmt(). The core does clear the reserved field from v4l2_pix_format_mplane, but not the reserved field for every plane. I can try to add it to the core as well. At least these drivers have code duplication: git grep reserved | grep memset | grep plane_fmt drivers/media/pci/intel/ipu3/ipu3-cio2.c: memset(mpix->plane_fmt[0].reserved, 0, drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c: memset(pix_mp->plane_fmt[i].reserved, 0, drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c: memset(&(pix_fmt_mp->plane_fmt[i].reserved[0]), 0x0, drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c: memset(&(pix_fmt_mp->plane_fmt[i].reserved[0]), 0x0, drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c: memset(&(pix->plane_fmt[i].reserved[0]), 0x0, drivers/media/platform/rcar_fdp1.c: memset(pix->plane_fmt[i].reserved, 0, drivers/media/platform/rcar_fdp1.c: memset(pix->plane_fmt[2].reserved, 0, drivers/media/platform/rcar_jpu.c: memset(pix->plane_fmt[0].reserved, 0, drivers/media/platform/rcar_jpu.c: memset(pix->plane_fmt[i].reserved, 0, drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c: memset(pix->plane_fmt[i].reserved, 0, drivers/media/platform/ti-vpe/vpe.c: memset(plane_fmt->reserved, 0, sizeof(plane_fmt->reserved)); drivers/media/test-drivers/vicodec/vicodec-core.c: memset(pix_mp->plane_fmt[0].reserved, 0, drivers/staging/media/hantro/hantro_v4l2.c: memset(pix_mp->plane_fmt[i].reserved, 0, drivers/staging/media/ipu3/ipu3-v4l2.c: memset(pixm->plane_fmt[0].reserved, 0, > > Thanks, > Ezequiel > -- Ricardo Ribalda ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hantro: Format IOCTLs compliance fixes 2021-01-11 11:55 ` Ricardo Ribalda @ 2021-01-11 12:22 ` Ricardo Ribalda 2021-01-11 12:24 ` Ezequiel Garcia 0 siblings, 1 reply; 5+ messages in thread From: Ricardo Ribalda @ 2021-01-11 12:22 UTC (permalink / raw) To: Ezequiel Garcia Cc: Philipp Zabel, Mauro Carvalho Chehab, Greg Kroah-Hartman, Linux Media Mailing List, linux-rockchip, devel, Linux Kernel Mailing List Hi Ezequiel On Mon, Jan 11, 2021 at 12:55 PM Ricardo Ribalda <ribalda@chromium.org> wrote: > > Hi Ezequiel > > On Mon, Jan 11, 2021 at 12:48 PM Ezequiel Garcia <ezequiel@collabora.com> wrote: > > > > Hi Ricardo, > > > > On Mon, 2021-01-11 at 12:35 +0100, Ricardo Ribalda wrote: > > > Clear the reserved fields. > > > > > > Fixes: > > > fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed > > > test VIDIOC_TRY_FMT: FAIL > > > fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed > > > test VIDIOC_S_FMT: FAIL > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > --- > > > drivers/staging/media/hantro/hantro_v4l2.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c > > > index b668a82d40ad..9b384fbffc93 100644 > > > --- a/drivers/staging/media/hantro/hantro_v4l2.c > > > +++ b/drivers/staging/media/hantro/hantro_v4l2.c > > > @@ -239,6 +239,7 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, > > > const struct hantro_fmt *fmt, *vpu_fmt; > > > bool capture = V4L2_TYPE_IS_CAPTURE(type); > > > bool coded; > > > + int i; > > > > > > coded = capture == ctx->is_encoder; > > > > > > @@ -293,6 +294,10 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, > > > pix_mp->width * pix_mp->height * fmt->max_depth; > > > } > > > > > > + for (i = 0; i < pix_mp->num_planes; i++) > > > + memset(pix_mp->plane_fmt[i].reserved, 0, > > > + sizeof(pix_mp->plane_fmt[i].reserved)); > > > + > > > > This looks like something that should be handled at the core, > > probably in drivers/media/v4l2-core/v4l2-ioctl.c::v4l_try_fmt(). > > The core does clear the reserved field from v4l2_pix_format_mplane, My bad, It is also clearing the per plane reserved field. I was testing in an old kernel. The grep it is still valid though. We can remove all the memsets in the drivers. > but not the reserved field for every plane. I can try to add it to the > core as well. At least these drivers have code duplication: > > git grep reserved | grep memset | grep plane_fmt > drivers/media/pci/intel/ipu3/ipu3-cio2.c: > memset(mpix->plane_fmt[0].reserved, 0, > drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c: > memset(pix_mp->plane_fmt[i].reserved, 0, > drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c: > memset(&(pix_fmt_mp->plane_fmt[i].reserved[0]), 0x0, > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c: > memset(&(pix_fmt_mp->plane_fmt[i].reserved[0]), 0x0, > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c: > memset(&(pix->plane_fmt[i].reserved[0]), 0x0, > drivers/media/platform/rcar_fdp1.c: > memset(pix->plane_fmt[i].reserved, 0, > drivers/media/platform/rcar_fdp1.c: > memset(pix->plane_fmt[2].reserved, 0, > drivers/media/platform/rcar_jpu.c: > memset(pix->plane_fmt[0].reserved, 0, > drivers/media/platform/rcar_jpu.c: > memset(pix->plane_fmt[i].reserved, 0, > drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c: > memset(pix->plane_fmt[i].reserved, 0, > drivers/media/platform/ti-vpe/vpe.c: > memset(plane_fmt->reserved, 0, sizeof(plane_fmt->reserved)); > drivers/media/test-drivers/vicodec/vicodec-core.c: > memset(pix_mp->plane_fmt[0].reserved, 0, > drivers/staging/media/hantro/hantro_v4l2.c: > memset(pix_mp->plane_fmt[i].reserved, 0, > drivers/staging/media/ipu3/ipu3-v4l2.c: memset(pixm->plane_fmt[0].reserved, 0, > > > > > Thanks, > > Ezequiel > > > > > -- > Ricardo Ribalda -- Ricardo Ribalda ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hantro: Format IOCTLs compliance fixes 2021-01-11 12:22 ` Ricardo Ribalda @ 2021-01-11 12:24 ` Ezequiel Garcia 0 siblings, 0 replies; 5+ messages in thread From: Ezequiel Garcia @ 2021-01-11 12:24 UTC (permalink / raw) To: Ricardo Ribalda Cc: Philipp Zabel, Mauro Carvalho Chehab, Greg Kroah-Hartman, Linux Media Mailing List, linux-rockchip, devel, Linux Kernel Mailing List On Mon, 2021-01-11 at 13:22 +0100, Ricardo Ribalda wrote: > Hi Ezequiel > > On Mon, Jan 11, 2021 at 12:55 PM Ricardo Ribalda <ribalda@chromium.org> wrote: > > > > Hi Ezequiel > > > > On Mon, Jan 11, 2021 at 12:48 PM Ezequiel Garcia <ezequiel@collabora.com> wrote: > > > > > > Hi Ricardo, > > > > > > On Mon, 2021-01-11 at 12:35 +0100, Ricardo Ribalda wrote: > > > > Clear the reserved fields. > > > > > > > > Fixes: > > > > fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed > > > > test VIDIOC_TRY_FMT: FAIL > > > > fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed > > > > test VIDIOC_S_FMT: FAIL > > > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > > --- > > > > drivers/staging/media/hantro/hantro_v4l2.c | 5 +++++ > > > > 1 file changed, 5 insertions(+) > > > > > > > > diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c > > > > index b668a82d40ad..9b384fbffc93 100644 > > > > --- a/drivers/staging/media/hantro/hantro_v4l2.c > > > > +++ b/drivers/staging/media/hantro/hantro_v4l2.c > > > > @@ -239,6 +239,7 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, > > > > const struct hantro_fmt *fmt, *vpu_fmt; > > > > bool capture = V4L2_TYPE_IS_CAPTURE(type); > > > > bool coded; > > > > + int i; > > > > > > > > coded = capture == ctx->is_encoder; > > > > > > > > @@ -293,6 +294,10 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, > > > > pix_mp->width * pix_mp->height * fmt->max_depth; > > > > } > > > > > > > > + for (i = 0; i < pix_mp->num_planes; i++) > > > > + memset(pix_mp->plane_fmt[i].reserved, 0, > > > > + sizeof(pix_mp->plane_fmt[i].reserved)); > > > > + > > > > > > This looks like something that should be handled at the core, > > > probably in drivers/media/v4l2-core/v4l2-ioctl.c::v4l_try_fmt(). > > > > The core does clear the reserved field from v4l2_pix_format_mplane, > > My bad, It is also clearing the per plane reserved field. I was > testing in an old kernel. > OK, cool. > The grep it is still valid though. We can remove all the memsets in the drivers. > That would be very nice indeed. Thanks, Ezequiel ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-11 12:26 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-01-11 11:35 [PATCH] hantro: Format IOCTLs compliance fixes Ricardo Ribalda 2021-01-11 11:48 ` Ezequiel Garcia 2021-01-11 11:55 ` Ricardo Ribalda 2021-01-11 12:22 ` Ricardo Ribalda 2021-01-11 12:24 ` Ezequiel Garcia
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).