Skip to contentSkip to conversation

ipu3-cio2: Check receved the size against payload size, not buffer size

PATCH Superseded Sakari Ailus 3 participants 4 messages Oct 13, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sakari Ailus

author maintainer
#0 lore raw

PATCH 1/1 ipu3-cio2: Check receved the size against payload size, not buffer size

Compare the received size of the payload size, not the allocated size of the buffer that is page aligned. This way also images that aren't aligned to page size are not warned about.

Also wrap a line over 80 characters.

---
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +5 -4
index 51c4dd6a8f9a..dffcc74acb7e 100644
@@ -571,10 +571,11 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan)
 			b->vbb.vb2_buf.timestamp = ns;
 			b->vbb.field = V4L2_FIELD_NONE;
 			b->vbb.sequence = atomic_read(&q->frame_sequence);
-			if (b->vbb.vb2_buf.planes[0].length != bytes)
-				dev_warn(dev, "buffer length is %d received %d\n",
-					 b->vbb.vb2_buf.planes[0].length,
-					 bytes);
+			if (vb2_get_plane_payload(&b->vbb.vb2_buf, 0) != bytes)
+				dev_warn(dev,
+					 "payload length is %lu received %u\n",
+					 vb2_get_plane_payload(&b->vbb.vb2_buf,
+							       0), bytes);
 			vb2_buffer_done(&b->vbb.vb2_buf, VB2_BUF_STATE_DONE);
 		}
 		atomic_inc(&q->frame_sequence);
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Sakari,

Thank you for the patch.

s/receved the/the received/ in the subject line

Quoted 17 lines · Sakari Ailus

Compare the received size of the payload size, not the allocated size of the buffer that is page aligned. This way also images that aren't aligned to page size are not warned about.

Also wrap a line over 80 characters.

---
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +0 -0
index 51c4dd6a8f9a..dffcc74acb7e 100644

drivers/media/pci/intel/ipu3/ipu3-cio2.c static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan) · line 576

Quoted 10 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c +3 -4
@@ -571,10 +571,11 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan)
 			b->vbb.vb2_buf.timestamp = ns;
 			b->vbb.field = V4L2_FIELD_NONE;
 			b->vbb.sequence = atomic_read(&q->frame_sequence);
-			if (b->vbb.vb2_buf.planes[0].length != bytes)
-				dev_warn(dev, "buffer length is %d received %d\n",
-					 b->vbb.vb2_buf.planes[0].length,
-					 bytes);
+			if (vb2_get_plane_payload(&b->vbb.vb2_buf, 0) != bytes)
+				dev_warn(dev,
+					 "payload length is %lu received %u\n",

Maybe ""payload length %lu != received %u\n" ? Or at least a comma after %lu.

drivers/media/pci/intel/ipu3/ipu3-cio2.c static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan) · line 578

Quoted 2 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c +2 -0
+					 vb2_get_plane_payload(&b->vbb.vb2_buf,
+							       0), bytes);

I would store vb2_get_plane_payload(&b->vbb.vb2_buf, 0) in a local variable to make this look a bit nicer.

Tests are ongoing.

Quoted 3 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c +0 -0
 			vb2_buffer_done(&b->vbb.vb2_buf, VB2_BUF_STATE_DONE);
 		}
 		atomic_inc(&q->frame_sequence);
Signature · 3 lines
Regards,

Laurent Pinchart
Tested-by on v1 1/1
#2 lore raw
In reply to Sakari Ailus

Hi Sakari,

Thanks for the patch !

Quoted 8 lines · Sakari Ailus

Compare the received size of the payload size, not the allocated size of the buffer that is page aligned. This way also images that aren't aligned to page size are not warned about.

Also wrap a line over 80 characters.

author maintainer
#3 lore raw
Quoted 9 lines · Jean-Michel Hautbois

Hi Sakari,

Thanks for the patch !

Quoted 4 lines · Sakari Ailus

Compare the received size of the payload size, not the allocated size of the buffer that is page aligned. This way also images that aren't aligned to page size are not warned about.

Quoted 6 lines
Quoted 4 lines

Also wrap a line over 80 characters.

Merci, Jean-Michel!

Signature · 1 line
Sakari Ailus