media: davinci: vpif: align the buffers size to page page size boundary
PATCH v2 1/1 media: davinci: vpif: align the buffers size to page page size boundary
From: Lad, Prabhakar <[email protected]>
with recent commit with id 068a0df76023926af958a336a78bef60468d2033 which adds add length check for mmap, the application were failing to mmap the buffers.
This patch aligns the the buffer size to page size boundary for both capture and display driver so the it pass the check.
---
Changes for v2:
1: Fixed a typo in commit message.
drivers/media/platform/davinci/vpif_capture.c | 1 + drivers/media/platform/davinci/vpif_display.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
drivers/media/platform/davinci/vpif_capture.c +1 -0
@@ -183,6 +183,7 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, *nbuffers = config_params.min_numbuffers; *nplanes =1 ; + size =PAGE_ALIGN (size); sizes[0 ] = size; alloc_ctxs[0 ] = common->alloc_ctx;
drivers/media/platform/davinci/vpif_display.c +1 -0
@@ -162,6 +162,7 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, *nbuffers = config_params.min_numbuffers; *nplanes =1 ; + size =PAGE_ALIGN (size); sizes[0 ] = size; alloc_ctxs[0 ] = common->alloc_ctx;return 0 ;
Signature · 1 line
1.7.4.1
Hi Hans,
Quoted 6 lines · Prabhakar lad
From: Lad, Prabhakar <[email protected]>
with recent commit with id
068a0df76023926af958a336a78bef60468d2033which adds add length check for mmap, the application were failing to mmap the buffers.
Quoted 8 lines
This patch aligns the the buffer size to page size boundary for both capture and display driver so the it pass the check.
Signed-off-by Lad, Prabhakar <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Hans Verkuil <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>---
Can you take this patch for v3.10 ?
Regards,
--Prabhakar
Hi Prabhakar,
(CC'ing Marek)
Quoted 27 lines · On Tuesday 16 April 2013 16:24:30 Prabhakar lad wrote:
From: Lad, Prabhakar <[email protected]>
with recent commit with id
068a0df76023926af958a336a78bef60468d2033which adds add length check for mmap, the application were failing to mmap the buffers.This patch aligns the the buffer size to page size boundary for both capture and display driver so the it pass the check.
Signed-off-by Lad, Prabhakar <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Hans Verkuil <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>---
Changes for v2:
1: Fixed a typo in commit message.drivers/media/platform/davinci/vpif_capture.c | 1 + drivers/media/platform/davinci/vpif_display.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/davinci/vpif_capture.cindex 5f98df1..25981d6 100644
drivers/media/platform/davinci/vpif_capture.c static int vpif_buffer_queue_setup(struct vb2_queue *vq, · line 186
Quoted 4 lines
drivers/media/platform/davinci/vpif_capture.c +1
-0@@ -183,6 +183,7 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, *nbuffers = config_params.min_numbuffers; *nplanes =1 ; + size =PAGE_ALIGN (size);
I wonder if that's the best fix.
The queue_setup operation is supposed to return the size required by the driver for each plane. Depending on the hardware requirements, that size might not be a multiple of the page size.
As we can't mmap() a fraction of a page, the allocated plane size needs to be rounded up to the next page boundary to allow mmap() support. The dma-contig and dma-sg allocators already do so in their alloc operation, but the vmalloc allocator doesn't.
The recent "media: vb2: add length check for mmap" patch verifies that the mmap() size requested by userspace doesn't exceed the buffer size. As the mmap() size is rounded up to the next page boundary the check will fail for buffer sizes that are not multiple of the page size.
Your fix will not result in overallocation (as the allocator already rounds the size up), but will prevent the driver from importing a buffer large enough for the hardware but not rounded up to the page size.
A better fix might be to round up the buffer size in the buffer size check at mmap() time, and fix the vmalloc allocator to round up the size. That the allocator, not drivers, is responsible for buffer size alignment should be documented in videobuf2-core.h.
Quoted 16 lines
drivers/media/platform/davinci/vpif_capture.c +0
-0sizes[0 ] = size; alloc_ctxs[0 ] = common->alloc_ctx;(quoted diff) +0
-0
b/drivers/media/platform/davinci/vpif_display.cindex 1b3fb5c..3414715 100644drivers/media/platform/davinci/vpif_display.c +1
-0@@ -162,6 +162,7 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, *nbuffers = config_params.min_numbuffers; *nplanes =1 ; + size =PAGE_ALIGN (size); sizes[0 ] = size; alloc_ctxs[0 ] = common->alloc_ctx;return 0 ;
Signature · 3 lines
Regards, Laurent Pinchart
Hi Marek,
Quoted 53 lines · Laurent Pinchart
Hi Prabhakar,
(CC'ing Marek)
Quoted 27 lines · On Tuesday 16 April 2013 16:24:30 Prabhakar lad wrote:
From: Lad, Prabhakar <[email protected]>
with recent commit with id
068a0df76023926af958a336a78bef60468d2033which adds add length check for mmap, the application were failing to mmap the buffers.This patch aligns the the buffer size to page size boundary for both capture and display driver so the it pass the check.
Signed-off-by Lad, Prabhakar <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Hans Verkuil <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>---
Changes for v2:
1: Fixed a typo in commit message.drivers/media/platform/davinci/vpif_capture.c | 1 + drivers/media/platform/davinci/vpif_display.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/davinci/vpif_capture.cindex 5f98df1..25981d6 100644drivers/media/platform/davinci/vpif_capture.c static int vpif_buffer_queue_setup(struct vb2_queue *vq, · line 186
Quoted 4 lines
drivers/media/platform/davinci/vpif_capture.c +1
-0@@ -183,6 +183,7 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, *nbuffers = config_params.min_numbuffers; *nplanes =1 ; + size =PAGE_ALIGN (size);I wonder if that's the best fix.
The
queue_setupoperation is supposed to return the size required by the driver for each plane. Depending on the hardware requirements, that size might not be a multiple of the page size.As we can't
mmap()a fraction of a page, the allocated plane size needs to be rounded up to the next page boundary to allowmmap()support. The dma-contig and dma-sg allocators already do so in their alloc operation, but the vmalloc allocator doesn't.The recent "media: vb2: add length check for mmap" patch verifies that the
mmap()size requested by userspace doesn't exceed the buffer size. As themmap()size is rounded up to the next page boundary the check will fail for buffer sizes that are not multiple of the page size.
Quoted 9 lines
Your fix will not result in overallocation (as the allocator already rounds the size up), but will prevent the driver from importing a buffer large enough for the hardware but not rounded up to the page size.
A better fix might be to round up the buffer size in the buffer size check at
mmap()time, and fix the vmalloc allocator to round up the size. That the allocator, not drivers, is responsible for buffer size alignment should be documented invideobuf2-core.h.
Do you plan to post a patch fixing it as per Laurent's suggestion ?
Regards,
--Prabhakar
Quoted 22 lines
Quoted 9 lines
drivers/media/platform/davinci/vpif_capture.c +0
-0sizes[0 ] = size; alloc_ctxs[0 ] = common->alloc_ctx;(quoted diff) +0
-0
b/drivers/media/platform/davinci/vpif_display.cindex 1b3fb5c..3414715 100644drivers/media/platform/davinci/vpif_display.c static int vpif_buffer_queue_setup(struct vb2_queue *vq, · line 168
Quoted 7 lines
drivers/media/platform/davinci/vpif_display.c +1
-0@@ -162,6 +162,7 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, *nbuffers = config_params.min_numbuffers; *nplanes =1 ; + size =PAGE_ALIGN (size); sizes[0 ] = size; alloc_ctxs[0 ] = common->alloc_ctx;return 0 ;--
Regards,Laurent Pinchart
Em Thu, 18 Apr 2013 10:17:14 +0530
Prabhakar Lad <[email protected]> escreveu:
Quoted 5 lines
Hi Marek,
Quoted 1 line · Laurent Pinchart
Hi Prabhakar,
...
Quoted 24 lines
Quoted 24 lines
Quoted 4 lines
*nbuffers = config_params.min_numbuffers;
*nplanes = 1;+ size =
PAGE_ALIGN(size);I wonder if that's the best fix.
Thequeue_setupoperation is supposed to return the size required by the driver for each plane. Depending on the hardware requirements, that size might not be a multiple of the page size.As we can't
mmap()a fraction of a page, the allocated plane size needs to be rounded up to the next page boundary to allowmmap()support. The dma-contig and dma-sg allocators already do so in their alloc operation, but the vmalloc allocator doesn't.The recent "media: vb2: add length check for mmap" patch verifies that the
mmap()size requested by userspace doesn't exceed the buffer size. As themmap()size is rounded up to the next page boundary the check will fail for buffer sizes that are not multiple of the page size.Your fix will not result in overallocation (as the allocator already rounds the size up), but will prevent the driver from importing a buffer large enough for the hardware but not rounded up to the page size.
Quoted 7 lines
Quoted 6 lines
A better fix might be to round up the buffer size in the buffer size check at
mmap()time, and fix the vmalloc allocator to round up the size. That the allocator, not drivers, is responsible for buffer size alignment should be documented invideobuf2-core.h.Do you plan to post a patch fixing it as per Laurent's suggestion ?
I agree with Laurent: page size roundup should be done at VB2 core code, for memory allocated there, and not at driver's level. Yet, looking at VB2 code, it already does page size align at __setup_offsets(), but it doesn't do if for the size field; just for the offset.
The adjusted size should be stored at the VB2 size field, and the check for buffer overflow, added on changeset 068a0df76023926af958a336a78bef60468d2033 should be kept.
IMO, it also makes sense to enforce that the USERPTR memory is multiple of the page size, as otherwise the DMA transfer may overwrite some area that is outside the allocated range. So, the size from USERPTR should be round down.
That change, however, will break userspace, as it uses the picture sizeimage to allocate the buffers. So, sizeimage needs to be PAGE_SIZE roundup before passing it to userspace.
Instead of modifying all drivers, the better seems to patch v4l_g_fmt() and v4l_try_fmt() to return a roundup value for sizeimage. As usual, uvcvideo requires a separate patch, because it doesn't use vidio_ioctl2.
Regards,
Mauro
Em Thu, 18 Apr 2013 08:21:21 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 56 lines
Em Thu, 18 Apr 2013 10:17:14 +0530
Prabhakar Lad <[email protected]> escreveu:Quoted 5 lines
Hi Marek,
Quoted 1 line · Laurent Pinchart
Hi Prabhakar,
...
Quoted 24 lines
Quoted 24 lines
Quoted 4 lines
*nbuffers = config_params.min_numbuffers;
*nplanes = 1;+ size =
PAGE_ALIGN(size);I wonder if that's the best fix.
Thequeue_setupoperation is supposed to return the size required by the driver for each plane. Depending on the hardware requirements, that size might not be a multiple of the page size.As we can't
mmap()a fraction of a page, the allocated plane size needs to be rounded up to the next page boundary to allowmmap()support. The dma-contig and dma-sg allocators already do so in their alloc operation, but the vmalloc allocator doesn't.The recent "media: vb2: add length check for mmap" patch verifies that the
mmap()size requested by userspace doesn't exceed the buffer size. As themmap()size is rounded up to the next page boundary the check will fail for buffer sizes that are not multiple of the page size.Your fix will not result in overallocation (as the allocator already rounds the size up), but will prevent the driver from importing a buffer large enough for the hardware but not rounded up to the page size.
Quoted 7 lines
Quoted 6 lines
A better fix might be to round up the buffer size in the buffer size check at
mmap()time, and fix the vmalloc allocator to round up the size. That the allocator, not drivers, is responsible for buffer size alignment should be documented invideobuf2-core.h.Do you plan to post a patch fixing it as per Laurent's suggestion ?
I agree with Laurent: page size roundup should be done at VB2 core code, for memory allocated there, and not at driver's level. Yet, looking at VB2 code, it already does page size align at
__setup_offsets(), but it doesn't do if for the size field; just for the offset.The adjusted size should be stored at the VB2 size field, and the check for buffer overflow, added on changeset
068a0df76023926af958a336a78bef60468d2033should be kept.IMO, it also makes sense to enforce that the USERPTR memory is multiple of the page size, as otherwise the DMA transfer may overwrite some area that is outside the allocated range. So, the size from USERPTR should be round down.
Quoted 7 lines
That change, however, will break userspace, as it uses the picture sizeimage to allocate the buffers. So, sizeimage needs to be
PAGE_SIZEroundup before passing it to userspace.Instead of modifying all drivers, the better seems to patch
v4l_g_fmt()andv4l_try_fmt()to return a roundup value for sizeimage. As usual, uvcvideo requires a separate patch, because it doesn't usevidio_ioctl2.
Hmm... PAGE_SIZE alignment is not needed on all places. It is needed only when DMA is done directly into the buffer, e. g. videobuf2-dma-contig and videobuf2-dma-sg.
It means that we'll need an extra function for the VB2 memory allocation drivers to do do the memory-dependent roundups, and a new ancillary function at VB2 core for the VB2 clients to call to round sizeimage if needed.
Regards,
Mauro
Hi Mauro,
Quoted 53 lines · On Thursday 18 April 2013 08:35:47 Mauro Carvalho Chehab wrote:
Em Thu, 18 Apr 2013 08:21:21 -0300 Mauro Carvalho Chehab escreveu:
Quoted 52 lines
Em Thu, 18 Apr 2013 10:17:14 +0530 Prabhakar Lad escreveu:
Quoted 2 lines · Laurent Pinchart
Quoted 1 line
Hi Prabhakar,
...
Quoted 26 lines
Quoted 26 lines
Quoted 5 lines
*nbuffers = config_params.min_numbuffers;
*nplanes = 1;+ size =
PAGE_ALIGN(size);I wonder if that's the best fix.
Thequeue_setupoperation is supposed to return the size required by the driver for each plane. Depending on the hardware requirements, that size might not be a multiple of the page size.As we can't
mmap()a fraction of a page, the allocated plane size needs to be rounded up to the next page boundary to allowmmap()support. The dma-contig and dma-sg allocators already do so in their alloc operation, but the vmalloc allocator doesn't.The recent "media: vb2: add length check for mmap" patch verifies that the
mmap()size requested by userspace doesn't exceed the buffer size. As themmap()size is rounded up to the next page boundary the check will fail for buffer sizes that are not multiple of the page size.Your fix will not result in overallocation (as the allocator already rounds the size up), but will prevent the driver from importing a buffer large enough for the hardware but not rounded up to the page size.
Quoted 6 lines
Quoted 4 lines
A better fix might be to round up the buffer size in the buffer size check at
mmap()time, and fix the vmalloc allocator to round up the size. That the allocator, not drivers, is responsible for buffer size alignment should be documented invideobuf2-core.h.Do you plan to post a patch fixing it as per Laurent's suggestion ?
I agree with Laurent: page size roundup should be done at VB2 core code, for memory allocated there, and not at driver's level. Yet, looking at VB2 code, it already does page size align at
__setup_offsets(), but it doesn't do if for the size field; just for the offset.The adjusted size should be stored at the VB2 size field, and the check for buffer overflow, added on changeset
068a0df76023926af958a336a78bef60468d2033should be kept.IMO, it also makes sense to enforce that the USERPTR memory is multiple of the page size, as otherwise the DMA transfer may overwrite some area that is outside the allocated range. So, the size from USERPTR should be round down.
I don't think that's needed. You can transfer a number of bytes not multiple of the page size using DMA. This is true for DMABUF as well, an imported buffer might have a size not aligned on a page boundary.
Quoted 8 lines
Quoted 7 lines
That change, however, will break userspace, as it uses the picture sizeimage to allocate the buffers. So, sizeimage needs to be
PAGE_SIZEroundup before passing it to userspace.Instead of modifying all drivers, the better seems to patch
v4l_g_fmt()andv4l_try_fmt()to return a roundup value for sizeimage. As usual, uvcvideo requires a separate patch, because it doesn't usevidio_ioctl2.
Quoted 8 lines
Hmm...
PAGE_SIZEalignment is not needed on all places. It is needed only when DMA is done directly into the buffer, e. g. videobuf2-dma-contig and videobuf2-dma-sg.It means that we'll need an extra function for the VB2 memory allocation drivers to do do the memory-dependent roundups, and a new ancillary function at VB2 core for the VB2 clients to call to round sizeimage if needed.
Can't we just round the size up at allocation time and when checking the size in mmap() ? That's a simple fix, local to vb2, and won't require new vb2 memops.
Signature · 3 lines
Regards, Laurent Pinchart
Em Thu, 18 Apr 2013 15:22:16 +0200
Laurent Pinchart <[email protected]> escreveu:
Quoted 52 lines
Hi Mauro,
Quoted 49 lines · On Thursday 18 April 2013 08:35:47 Mauro Carvalho Chehab wrote:
Em Thu, 18 Apr 2013 08:21:21 -0300 Mauro Carvalho Chehab escreveu:
Quoted 48 lines
Em Thu, 18 Apr 2013 10:17:14 +0530 Prabhakar Lad escreveu:
Quoted 2 lines · Laurent Pinchart
Quoted 1 line
Hi Prabhakar,
...
Quoted 26 lines
Quoted 26 lines
Quoted 5 lines
*nbuffers = config_params.min_numbuffers;
*nplanes = 1;+ size =
PAGE_ALIGN(size);I wonder if that's the best fix.
Thequeue_setupoperation is supposed to return the size required by the driver for each plane. Depending on the hardware requirements, that size might not be a multiple of the page size.As we can't
mmap()a fraction of a page, the allocated plane size needs to be rounded up to the next page boundary to allowmmap()support. The dma-contig and dma-sg allocators already do so in their alloc operation, but the vmalloc allocator doesn't.The recent "media: vb2: add length check for mmap" patch verifies that the
mmap()size requested by userspace doesn't exceed the buffer size. As themmap()size is rounded up to the next page boundary the check will fail for buffer sizes that are not multiple of the page size.Your fix will not result in overallocation (as the allocator already rounds the size up), but will prevent the driver from importing a buffer large enough for the hardware but not rounded up to the page size.
Quoted 6 lines
Quoted 4 lines
A better fix might be to round up the buffer size in the buffer size check at
mmap()time, and fix the vmalloc allocator to round up the size. That the allocator, not drivers, is responsible for buffer size alignment should be documented invideobuf2-core.h.Do you plan to post a patch fixing it as per Laurent's suggestion ?
I agree with Laurent: page size roundup should be done at VB2 core code, for memory allocated there, and not at driver's level. Yet, looking at VB2 code, it already does page size align at
__setup_offsets(), but it doesn't do if for the size field; just for the offset.The adjusted size should be stored at the VB2 size field, and the check for buffer overflow, added on changeset
068a0df76023926af958a336a78bef60468d2033should be kept.
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
IMO, it also makes sense to enforce that the USERPTR memory is multiple of the page size, as otherwise the DMA transfer may overwrite some area that is outside the allocated range. So, the size from USERPTR should be round down.
I don't think that's needed. You can transfer a number of bytes not multiple of the page size using DMA. This is true for DMABUF as well, an imported buffer might have a size not aligned on a page boundary.
Are you sure that, on all supported archs/buses, the DMA transfers are byte-aligned?
Quoted 12 lines
Quoted 12 lines
Quoted 7 lines
That change, however, will break userspace, as it uses the picture sizeimage to allocate the buffers. So, sizeimage needs to be
PAGE_SIZEroundup before passing it to userspace.Instead of modifying all drivers, the better seems to patch
v4l_g_fmt()andv4l_try_fmt()to return a roundup value for sizeimage. As usual, uvcvideo requires a separate patch, because it doesn't usevidio_ioctl2.Hmm...
PAGE_SIZEalignment is not needed on all places. It is needed only when DMA is done directly into the buffer, e. g. videobuf2-dma-contig and videobuf2-dma-sg.
Quoted 8 lines
Quoted 4 lines
It means that we'll need an extra function for the VB2 memory allocation drivers to do do the memory-dependent roundups, and a new ancillary function at VB2 core for the VB2 clients to call to round sizeimage if needed.
Can't we just round the size up at allocation time and when checking the size in
mmap()? That's a simple fix, local to vb2, and won't require new vb2 memops.
That's not needed for videobuf2-vmalloc. We shouldn't bloat the core VB2 with memops specific stuff. Ok, in this specific case, this is a simple trivial patch, so perhaps we could do it there.
Signature · 2 lines
Cheers, Mauro
Quoted 58 lines · On Thursday 18 April 2013 11:08:28 Mauro Carvalho Chehab wrote:
Em Thu, 18 Apr 2013 15:22:16 +0200 Laurent Pinchart escreveu:
Quoted 57 lines · On Thursday 18 April 2013 08:35:47 Mauro Carvalho Chehab wrote:
Quoted 55 lines
Em Thu, 18 Apr 2013 08:21:21 -0300 Mauro Carvalho Chehab escreveu:
Quoted 54 lines
Em Thu, 18 Apr 2013 10:17:14 +0530 Prabhakar Lad escreveu:
Quoted 2 lines · Laurent Pinchart
Quoted 1 line
Hi Prabhakar,
...
Quoted 27 lines
Quoted 27 lines
Quoted 5 lines
*nbuffers = config_params.min_numbuffers;
*nplanes = 1;+ size =
PAGE_ALIGN(size);I wonder if that's the best fix.
Thequeue_setupoperation is supposed to return the size required by the driver for each plane. Depending on the hardware requirements, that size might not be a multiple of the page size.As we can't
mmap()a fraction of a page, the allocated plane size needs to be rounded up to the next page boundary to allowmmap()support. The dma-contig and dma-sg allocators already do so in their alloc operation, but the vmalloc allocator doesn't.The recent "media: vb2: add length check for mmap" patch verifies that the
mmap()size requested by userspace doesn't exceed the buffer size. As themmap()size is rounded up to the next page boundary the check will fail for buffer sizes that are not multiple of the page size.Your fix will not result in overallocation (as the allocator already rounds the size up), but will prevent the driver from importing a buffer large enough for the hardware but not rounded up to the page size.
Quoted 6 lines
Quoted 4 lines
A better fix might be to round up the buffer size in the buffer size check at
mmap()time, and fix the vmalloc allocator to round up the size. That the allocator, not drivers, is responsible for buffer size alignment should be documented invideobuf2-core.h.Do you plan to post a patch fixing it as per Laurent's suggestion ?
I agree with Laurent: page size roundup should be done at VB2 core code, for memory allocated there, and not at driver's level. Yet, looking at VB2 code, it already does page size align at
__setup_offsets(), but it doesn't do if for the size field; just for the offset.The adjusted size should be stored at the VB2 size field, and the check for buffer overflow, added on changeset
068a0df76023926af958a336a78bef60468d2033should be kept.IMO, it also makes sense to enforce that the USERPTR memory is multiple of the page size, as otherwise the DMA transfer may overwrite some area that is outside the allocated range. So, the size from USERPTR should be round down.
Quoted 6 lines
Quoted 3 lines
I don't think that's needed. You can transfer a number of bytes not multiple of the page size using DMA. This is true for DMABUF as well, an imported buffer might have a size not aligned on a page boundary.
Are you sure that, on all supported archs/buses, the DMA transfers are byte-aligned?
They're most probably not byte-aligned, but they're not page-aligned either. That's something the driver should know, and that information will be passed throught the plane sizes by the queue_setup operation.
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 8 lines
That change, however, will break userspace, as it uses the picture sizeimage to allocate the buffers. So, sizeimage needs to be
PAGE_SIZEroundup before passing it to userspace.Instead of modifying all drivers, the better seems to patch
v4l_g_fmt()andv4l_try_fmt()to return a roundup value for sizeimage. As usual, uvcvideo requires a separate patch, because it doesn't usevidio_ioctl2.Hmm...
PAGE_SIZEalignment is not needed on all places. It is needed only when DMA is done directly into the buffer, e. g. videobuf2-dma- contig and videobuf2-dma-sg.It means that we'll need an extra function for the VB2 memory allocation drivers to do do the memory-dependent roundups, and a new ancillary function at VB2 core for the VB2 clients to call to round sizeimage if needed.
Quoted 5 lines
Quoted 3 lines
Can't we just round the size up at allocation time and when checking the size in
mmap()? That's a simple fix, local to vb2, and won't require new vb2 memops.That's not needed for videobuf2-vmalloc.
Yes it is, as mmap() works on a page basis. Every buffer that will be mmap()ed to userspace needs to be aligned to the page size.
Quoted 3 lines
We shouldn't bloat the core VB2 with memops specific stuff. Ok, in this specific case, this is a simple trivial patch, so perhaps we could do it there.
Signature · 3 lines
Regards, Laurent Pinchart
Hello.
Quoted 3 lines · Prabhakar lad
From: Lad, Prabhakar <[email protected]>
with recent commit with id
068a0df76023926af958a336a78bef60468d2033
Please also specify the summary line of that commit in parens (or however
you like).
Quoted 10 lines
which adds add length check for mmap, the application were failing to mmap the buffers.
This patch aligns the the buffer size to page size boundary for both capture and display driver so the it pass the check.
Signed-off-by Lad, Prabhakar <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Hans Verkuil <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>
WBR, Sergei