Skip to contentSkip to conversation

hantro: Format IOCTLs compliance fixes

PATCH In review Ricardo Ribalda 2 participants 5 messages Jan 11, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hantro: Format IOCTLs compliance fixes

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

---
 drivers/staging/media/hantro/hantro_v4l2.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/staging/media/hantro/hantro_v4l2.c +5 -0
index b668a82d40ad..9b384fbffc93 100644
@@ -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;
 }
 
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
#1 lore raw

Hi Ricardo,

Quoted 28 lines · 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

---
 drivers/staging/media/hantro/hantro_v4l2.c | 5 +++++

 1 file changed, 5 insertions(+)
drivers/staging/media/hantro/hantro_v4l2.c +1 -0
index b668a82d40ad..9b384fbffc93 100644
@@ -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;

drivers/staging/media/hantro/hantro_v4l2.c +0 -0
@@ -293,6 +294,10 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx,
                         pix_mp->width * pix_mp->height * fmt->max_depth;
         }
Quoted 5 lines


+       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

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#2 lore raw

Hi Ezequiel

Quoted 33 lines · Ezequiel Garcia

Hi Ricardo,

Quoted 29 lines · 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

---
 drivers/staging/media/hantro/hantro_v4l2.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/staging/media/hantro/hantro_v4l2.c +1 -0
index b668a82d40ad..9b384fbffc93 100644
@@ -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;
        }
 
Quoted 7 lines

drivers/staging/media/hantro/hantro_v4l2.c static int hantro_try_fmt(const struct hantro_ctx *ctx, · line 300

Quoted 4 lines
drivers/staging/media/hantro/hantro_v4l2.c +4 -0
+       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,

Quoted 4 lines

Thanks,
Ezequiel

Signature · 6 lines
Ricardo Ribalda

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
#3 lore raw

Hi Ezequiel

Quoted 45 lines · Ricardo Ribalda

Hi Ezequiel

Quoted 33 lines · Ezequiel Garcia

Hi Ricardo,

Quoted 29 lines · 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

---
 drivers/staging/media/hantro/hantro_v4l2.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/staging/media/hantro/hantro_v4l2.c +1 -0
index b668a82d40ad..9b384fbffc93 100644
@@ -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;
        }
 
Quoted 7 lines

drivers/staging/media/hantro/hantro_v4l2.c static int hantro_try_fmt(const struct hantro_ctx *ctx, · line 300

Quoted 4 lines
drivers/staging/media/hantro/hantro_v4l2.c +4 -0
+       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().

Quoted 1 line

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.

Quoted 43 lines

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,

Quoted 4 lines

Thanks,
Ezequiel

--
Ricardo Ribalda

Signature · 6 lines
Ricardo Ribalda

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
#4 lore raw
Quoted 48 lines · Ricardo Ribalda

Hi Ezequiel

Quoted 45 lines · Ricardo Ribalda

Hi Ezequiel

Quoted 40 lines · Ezequiel Garcia

Hi Ricardo,

Quoted 26 lines · 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

---
 drivers/staging/media/hantro/hantro_v4l2.c | 5 +++++

 1 file changed, 5 insertions(+)
drivers/staging/media/hantro/hantro_v4l2.c +1 -0
index b668a82d40ad..9b384fbffc93 100644
@@ -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;
 

drivers/staging/media/hantro/hantro_v4l2.c static int hantro_try_fmt(const struct hantro_ctx *ctx, · line 300

Quoted 7 lines
drivers/staging/media/hantro/hantro_v4l2.c +4 -0
@@ -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().

Quoted 5 lines
Quoted 1 line

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.

Quoted 2 lines

The grep it is still valid though. We can remove all the memsets in the drivers.

That would be very nice indeed.

Thanks,
Ezequiel

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip