Skip to contentSkip to conversation

media: mtk-vcodec: Remove extra area allocation in an input buffer on encoding

git:media_tree/master Tomasz Figa 3 participants 5 messages Nov 10, 2019 – Jun 25, 2020 1 message not in the archive Media (V4L/DVB)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Mauro and Hans,

Quoted 6 lines · Mauro Carvalho Chehab

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: mtk-vcodec: Remove extra area allocation in an input buffer on encoding
Author:  Hirokazu Honda <[email protected]>
Date:    Sun Nov 10 07:25:34 2019 +0100

I asked for some more testing on different platforms in my review reply and we got some offline signals that it might not work on some platforms, due to some hardware prefetch. (Would be better if that was reported to the mailing list instead.) We're trying to figure out the exact requirements here, because half of the frame doesn't sound like something reasonable. Let's hold off the patch for the time being.

Best regards,
Tomasz

Quoted 46 lines

MediaTek encoder allocates non pixel data area for an input buffer every plane. As the input buffer should be read-only, the driver should not write anything in the buffer. Therefore, the extra data should be unnecessary.

 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

---

drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +3 -6
index fd8de027e83e..6aad53d97d74 100644
@@ -332,14 +332,12 @@ static int vidioc_try_fmt(struct v4l2_format *f,
 
                pix_fmt_mp->num_planes = fmt->num_planes;
                pix_fmt_mp->plane_fmt[0].sizeimage =
-                               pix_fmt_mp->width * pix_fmt_mp->height +
-                               ((ALIGN(pix_fmt_mp->width, 16) * 2) * 16);
+                       pix_fmt_mp->width * pix_fmt_mp->height;
                pix_fmt_mp->plane_fmt[0].bytesperline = pix_fmt_mp->width;
 
                if (pix_fmt_mp->num_planes == 2) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2 +
-                               (ALIGN(pix_fmt_mp->width, 16) * 16);
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2;
                        pix_fmt_mp->plane_fmt[2].sizeimage = 0;
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                                        pix_fmt_mp->width;
@@ -347,8 +345,7 @@ static int vidioc_try_fmt(struct v4l2_format *f,
                } else if (pix_fmt_mp->num_planes == 3) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
                        pix_fmt_mp->plane_fmt[2].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4 +
-                               ((ALIGN(pix_fmt_mp->width, 16) / 2) * 16);
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4;
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                pix_fmt_mp->plane_fmt[2].bytesperline =
                                pix_fmt_mp->width / 2;
#2 lore raw
Quoted 11 lines · Tomasz Figa

Hi Mauro and Hans,

Quoted 6 lines · Mauro Carvalho Chehab

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: mtk-vcodec: Remove extra area allocation in an input buffer on encoding
Author:  Hirokazu Honda <[email protected]>
Date:    Sun Nov 10 07:25:34 2019 +0100
Quoted 6 lines

I asked for some more testing on different platforms in my review reply and we got some offline signals that it might not work on some platforms, due to some hardware prefetch. (Would be better if that was reported to the mailing list instead.) We're trying to figure out the exact requirements here, because half of the frame doesn't sound like something reasonable. Let's hold off the patch for the time being.

I'll repost my last pull request, including a revert of this patch.

The state of this patch in patchwork is changed back to New.

I'll wait for your feedback on what to do with this patch.

Regards,

Hans

Quoted 50 lines

Best regards,
Tomasz

Quoted 46 lines

MediaTek encoder allocates non pixel data area for an input buffer every plane. As the input buffer should be read-only, the driver should not write anything in the buffer. Therefore, the extra data should be unnecessary.

 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

---

drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +3 -6
index fd8de027e83e..6aad53d97d74 100644
@@ -332,14 +332,12 @@ static int vidioc_try_fmt(struct v4l2_format *f,
 
                pix_fmt_mp->num_planes = fmt->num_planes;
                pix_fmt_mp->plane_fmt[0].sizeimage =
-                               pix_fmt_mp->width * pix_fmt_mp->height +
-                               ((ALIGN(pix_fmt_mp->width, 16) * 2) * 16);
+                       pix_fmt_mp->width * pix_fmt_mp->height;
                pix_fmt_mp->plane_fmt[0].bytesperline = pix_fmt_mp->width;
 
                if (pix_fmt_mp->num_planes == 2) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2 +
-                               (ALIGN(pix_fmt_mp->width, 16) * 16);
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2;
                        pix_fmt_mp->plane_fmt[2].sizeimage = 0;
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                                        pix_fmt_mp->width;
@@ -347,8 +345,7 @@ static int vidioc_try_fmt(struct v4l2_format *f,
                } else if (pix_fmt_mp->num_planes == 3) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
                        pix_fmt_mp->plane_fmt[2].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4 +
-                               ((ALIGN(pix_fmt_mp->width, 16) / 2) * 16);
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4;
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                pix_fmt_mp->plane_fmt[2].bytesperline =
                                pix_fmt_mp->width / 2;
#3 lore raw

+Alexandre Courbot

Quoted 81 lines · Hans Verkuil
Quoted 11 lines · Tomasz Figa

Hi Mauro and Hans,

Quoted 6 lines · Mauro Carvalho Chehab

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: mtk-vcodec: Remove extra area allocation in an input buffer on encoding
Author:  Hirokazu Honda <[email protected]>
Date:    Sun Nov 10 07:25:34 2019 +0100
Quoted 6 lines

I asked for some more testing on different platforms in my review reply and we got some offline signals that it might not work on some platforms, due to some hardware prefetch. (Would be better if that was reported to the mailing list instead.) We're trying to figure out the exact requirements here, because half of the frame doesn't sound like something reasonable. Let's hold off the patch for the time being.

I'll repost my last pull request, including a revert of this patch.

The state of this patch in patchwork is changed back to New.

I'll wait for your feedback on what to do with this patch.

Regards,

Hans

Quoted 50 lines

Best regards,
Tomasz

Quoted 46 lines

MediaTek encoder allocates non pixel data area for an input buffer every plane. As the input buffer should be read-only, the driver should not write anything in the buffer. Therefore, the extra data should be unnecessary.

 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

---

drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +3 -6
index fd8de027e83e..6aad53d97d74 100644
@@ -332,14 +332,12 @@ static int vidioc_try_fmt(struct v4l2_format *f,
 
                pix_fmt_mp->num_planes = fmt->num_planes;
                pix_fmt_mp->plane_fmt[0].sizeimage =
-                               pix_fmt_mp->width * pix_fmt_mp->height +
-                               ((ALIGN(pix_fmt_mp->width, 16) * 2) * 16);
+                       pix_fmt_mp->width * pix_fmt_mp->height;
                pix_fmt_mp->plane_fmt[0].bytesperline = pix_fmt_mp->width;
 
                if (pix_fmt_mp->num_planes == 2) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2 +
-                               (ALIGN(pix_fmt_mp->width, 16) * 16);
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2;
                        pix_fmt_mp->plane_fmt[2].sizeimage = 0;
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                                        pix_fmt_mp->width;
@@ -347,8 +345,7 @@ static int vidioc_try_fmt(struct v4l2_format *f,
                } else if (pix_fmt_mp->num_planes == 3) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
                        pix_fmt_mp->plane_fmt[2].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4 +
-                               ((ALIGN(pix_fmt_mp->width, 16) / 2) * 16);
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4;
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                pix_fmt_mp->plane_fmt[2].bytesperline =
                                pix_fmt_mp->width / 2;
#4 lore raw

Hi Hans,

Quoted 29 lines · Tomasz Figa

+Alexandre Courbot

Quoted 25 lines · Hans Verkuil
Quoted 11 lines · Tomasz Figa

Hi Mauro and Hans,

Quoted 6 lines · Mauro Carvalho Chehab

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: mtk-vcodec: Remove extra area allocation in an input buffer on encoding
Author:  Hirokazu Honda <[email protected]>
Date:    Sun Nov 10 07:25:34 2019 +0100
Quoted 6 lines

I asked for some more testing on different platforms in my review reply and we got some offline signals that it might not work on some platforms, due to some hardware prefetch. (Would be better if that was reported to the mailing list instead.) We're trying to figure out the exact requirements here, because half of the frame doesn't sound like something reasonable. Let's hold off the patch for the time being.

I'll repost my last pull request, including a revert of this patch.

The state of this patch in patchwork is changed back to New.

I'll wait for your feedback on what to do with this patch.

Let's drop this patch indeed. Apparently some implementations of this hardware do read-ahead up to 32 lines, so the extra space is needed.

Best regards,
Tomasz

Quoted 56 lines
Quoted 56 lines

Regards,

Hans

Quoted 50 lines

Best regards,
Tomasz

Quoted 46 lines

MediaTek encoder allocates non pixel data area for an input buffer every plane. As the input buffer should be read-only, the driver should not write anything in the buffer. Therefore, the extra data should be unnecessary.

 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

---

drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +3 -6
index fd8de027e83e..6aad53d97d74 100644
@@ -332,14 +332,12 @@ static int vidioc_try_fmt(struct v4l2_format *f,
 
                pix_fmt_mp->num_planes = fmt->num_planes;
                pix_fmt_mp->plane_fmt[0].sizeimage =
-                               pix_fmt_mp->width * pix_fmt_mp->height +
-                               ((ALIGN(pix_fmt_mp->width, 16) * 2) * 16);
+                       pix_fmt_mp->width * pix_fmt_mp->height;
                pix_fmt_mp->plane_fmt[0].bytesperline = pix_fmt_mp->width;
 
                if (pix_fmt_mp->num_planes == 2) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2 +
-                               (ALIGN(pix_fmt_mp->width, 16) * 16);
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2;
                        pix_fmt_mp->plane_fmt[2].sizeimage = 0;
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                                        pix_fmt_mp->width;
@@ -347,8 +345,7 @@ static int vidioc_try_fmt(struct v4l2_format *f,
                } else if (pix_fmt_mp->num_planes == 3) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
                        pix_fmt_mp->plane_fmt[2].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4 +
-                               ((ALIGN(pix_fmt_mp->width, 16) / 2) * 16);
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4;
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                pix_fmt_mp->plane_fmt[2].bytesperline =
                                pix_fmt_mp->width / 2;
#5 lore raw
Quoted 28 lines · Tomasz Figa

Hi Hans,

Quoted 24 lines · Tomasz Figa

+Alexandre Courbot

Quoted 20 lines · Hans Verkuil
Quoted 17 lines · Tomasz Figa

Hi Mauro and Hans,

Quoted 6 lines · Mauro Carvalho Chehab

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: mtk-vcodec: Remove extra area allocation in an input buffer on encoding
Author:  Hirokazu Honda <[email protected]>
Date:    Sun Nov 10 07:25:34 2019 +0100

I asked for some more testing on different platforms in my review reply and we got some offline signals that it might not work on some platforms, due to some hardware prefetch. (Would be better if that was reported to the mailing list instead.) We're trying to figure out the exact requirements here, because half of the frame doesn't sound like something reasonable. Let's hold off the patch for the time being.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

I'll repost my last pull request, including a revert of this patch.

The state of this patch in patchwork is changed back to New.

I'll wait for your feedback on what to do with this patch.

Let's drop this patch indeed. Apparently some implementations of this hardware do read-ahead up to 32 lines, so the extra space is needed.

Sorry to revive this, but I see that this patch is currently merged:

Merged a first time in 3192b2ca79b3f72fbc0eab9cd95432e3c317ab0d, Reverted in dca6b3733a4a46e63603496f544ece8ace541fde Merged again in 81735ecb62f882853a37a8c157407ec4aed44fd0

Could that last merge be an error? As far as I know the final call was that hardware read-ahead required the initial alignment, and with the patch v4l2-compliance has one more failure on G_FMT.

The last merge came before Tomasz last email, and this patch is also not in the Chrome OS tree, so unless someone speaks up I will consider this should have been reverted and will do it in the next iteration of my mtk-vcodec encoder series.

Quoted 60 lines

Best regards,
Tomasz

Quoted 56 lines
Quoted 56 lines

Regards,

Hans

Quoted 50 lines

Best regards,
Tomasz

Quoted 46 lines

MediaTek encoder allocates non pixel data area for an input buffer every plane. As the input buffer should be read-only, the driver should not write anything in the buffer. Therefore, the extra data should be unnecessary.

 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

---

drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +3 -6
index fd8de027e83e..6aad53d97d74 100644
@@ -332,14 +332,12 @@ static int vidioc_try_fmt(struct v4l2_format *f,
 
                pix_fmt_mp->num_planes = fmt->num_planes;
                pix_fmt_mp->plane_fmt[0].sizeimage =
-                               pix_fmt_mp->width * pix_fmt_mp->height +
-                               ((ALIGN(pix_fmt_mp->width, 16) * 2) * 16);
+                       pix_fmt_mp->width * pix_fmt_mp->height;
                pix_fmt_mp->plane_fmt[0].bytesperline = pix_fmt_mp->width;
 
                if (pix_fmt_mp->num_planes == 2) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2 +
-                               (ALIGN(pix_fmt_mp->width, 16) * 16);
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 2;
                        pix_fmt_mp->plane_fmt[2].sizeimage = 0;
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                                        pix_fmt_mp->width;
@@ -347,8 +345,7 @@ static int vidioc_try_fmt(struct v4l2_format *f,
                } else if (pix_fmt_mp->num_planes == 3) {
                        pix_fmt_mp->plane_fmt[1].sizeimage =
                        pix_fmt_mp->plane_fmt[2].sizeimage =
-                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4 +
-                               ((ALIGN(pix_fmt_mp->width, 16) / 2) * 16);
+                               (pix_fmt_mp->width * pix_fmt_mp->height) / 4;
                        pix_fmt_mp->plane_fmt[1].bytesperline =
                                pix_fmt_mp->plane_fmt[2].bytesperline =
                                pix_fmt_mp->width / 2;