28 Jul, 2011
1 commit
-
On function videobuf_pages_to_sg the statement sg_set_page(&sglist[0],
pages[0], PAGE_SIZE - offset, offset) will fail if size is less than
PAGE_SIZE.Signed-off-by: Newson Edouard
Signed-off-by: Mauro Carvalho Chehab
29 Dec, 2010
3 commits
-
Signed-off-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab -
Signed-off-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab -
Signed-off-by: Joe Perches
Signed-off-by: Mauro Carvalho Chehab
21 Oct, 2010
4 commits
-
As pointed by Laurent:
I think min_t(size_t, PAGE_SIZE, size) is the preferred way.
Thanks-to: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
drivers/media/video/videobuf-dma-sg.c: In function ‘videobuf_pages_to_sg’:
drivers/media/video/videobuf-dma-sg.c:119: warning: comparison of distinct pointer types lacks a cast
drivers/media/video/videobuf-dma-sg.c:120: warning: comparison of distinct pointer types lacks a castSigned-off-by: Mauro Carvalho Chehab
-
Add an ext_lock argument to the videobuf init functions. This allows
drivers to pass the vdev->lock pointer (or any other externally held lock)
to videobuf. For now all drivers just pass NULL.Signed-off-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab -
Currently videobuf uses the vb_lock mutex to lock its data structures.
But this locking will (optionally) move into the v4l2 core, which means
that in that case vb_lock shouldn't be used since the external lock is already
held.Prepare for this by adding a pointer to such an external mutex and
don't lock if that pointer is set.Signed-off-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab
28 Sep, 2010
1 commit
-
This fixes a nasty memory corruption bug when using userptr I/O.
The function videobuf_pages_to_sg() sets up the scatter-gather list for the
DMA transfer to the userspace pages. The first transfer is setup correctly
(the size is set to PAGE_SIZE - offset), but all other transfers have size
PAGE_SIZE. This is wrong for the last transfer which may be less than PAGE_SIZE.Most, if not all, drivers will program the boards DMA engine correctly, i.e.
even though the size in the last sg element is wrong, they will do their
own size calculations and make sure the right amount is DMA-ed, and so seemingly
prevent memory corruption.However, behind the scenes the dynamic DMA mapping support (in lib/swiotlb.c)
may create bounce buffers if the memory pages are not in DMA-able memory.
This happens for example on a 64-bit linux with a board that only supports
32-bit DMA.These bounce buffers DO use the information in the sg list to determine the
size. So while the DMA engine transfers the correct amount of data, when the
data is 'bounced' back too much is copied, causing buffer overwrites.The fix is simple: calculate and set the correct size for the last sg list
element.Signed-off-by: Hans Verkuil
Cc: stable@kernel.org
Signed-off-by: Mauro Carvalho Chehab
03 Aug, 2010
5 commits
-
The videobuf_dmabuf and videobuf_vmalloc_memory fields have a vmalloc
field to store the kernel virtual address of vmalloc'ed buffers. Rename
the field to vaddr.Signed-off-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
The fields are assigned but never used, remove them.
Signed-off-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
Those functions are only called inside videobuf-dma-sg.c, make them
static.Signed-off-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
Instead of creating dirty wrappers around videobuf_dma_map/unmap that
create a dummy videobuf_queue structure, modify videobuf_dma_map/unmap
to take a device pointer argument and use it directly. The
videobuf_sg_dma_map/unmap then become unused and can be removed.Signed-off-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
These functions allocate videobuf_buffer structures only. Renaming in order
to prevent confusion with functions allocating actual video buffer memory.Rename the functions in videobuf-core.h videobuf-dma-sg.c as well.
Signed-off-by: Pawel Osciak
Signed-off-by: Laurent Pinchart
Signed-off-by: Kyungmin Park
Signed-off-by: Mauro Carvalho Chehab
19 May, 2010
8 commits
-
videobuf_pages_to_sg() and videobuf_vmalloc_to_sg() happen to create
a scatterlist element for every page. However, this is not true for
bus addresses, so other functions shouldn't rely on the length of the
scatter list being equal to nr_pages.Signed-off-by: Mauro Carvalho Chehab
-
While analyzing one of the videobuf patches, I noticed that
videobuf_dma_sync is only used internally inside videobuf-dma-sg.
So, let's remove this function, merging the code at __videobuf_dma_sync()Signed-off-by: Mauro Carvalho Chehab
-
drivers/media/video/videobuf-dma-sg.c: In function ‘__videobuf_mmap_mapper’:
drivers/media/video/videobuf-dma-sg.c:557: warning: ‘size’ may be used uninitialized in this functionThe condition where size is floating should never happen, due to the paranoia check,
but a future change at the logic might break it. So, let's just set size to zero and
use it for the paranoia check.Signed-off-by: Mauro Carvalho Chehab
-
mmap_mapper should operate on a buffer, not on a complete queue. So let
the videobuf-core find the correct buffer instead of duplicating that
code in each mmap_mapper implementation.The dma-sg implementation has backwards compatibility code for handling
the V4L1_COMPAT layer. This code is now under the v4L1_COMPAT config option.Signed-off-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab -
The video_copy_to_user and copy_stream ops are almost identical for all
videobuf memtype variants. All that is needed is to use the new vaddr
op and these functions can be moved into the core, ensuring we have just
one single implementation instead of three.Signed-off-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab -
Rename the .vmalloc op in struct videobuf_qtype_ops to .vaddr. This op returns
the virtual kernel address of a buffer. vaddr is a lot less confusing than
vmalloc since this callback does do any allocations.Signed-off-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab -
videobuf_alloc() returned a void *. Change to struct videobuf_buffer *
to get better type checking.Signed-off-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab -
Remove the mmap_free callback from struct videobuf_qtype_ops.
All implementations of this callback do the same trivial check: return
-EBUSY if any buffer is mmapped. That can also be tested in the
videobuf core.Signed-off-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab
18 May, 2010
1 commit
-
Make videobuf pass checkpatch; minor code cleanups.
Signed-off-by: Pawel Osciak
Reviewed-by: Kyungmin Park
Signed-off-by: Mauro Carvalho Chehab
27 Feb, 2010
1 commit
-
Signed-off-by: Pawel Osciak
Signed-off-by: Mauro Carvalho Chehab
06 Dec, 2009
2 commits
-
The videobuf_queue_ops function vector is not declared constant, but
there's no need for the videobuf layer to ever change it. Make it const
so that videobuf users can make their operations const without warnings.Signed-off-by: Jonathan Corbet
Signed-off-by: Andrew Morton
Signed-off-by: Mauro Carvalho Chehab -
When the image size (bytesperline*height) is not multiple
of PAGE_SIZE, v4l2 rounded the required buffer size to
be multiple of PAGE_SIZE. This prevented user space
to store images directly into userptr buffers which were
not multiple of PAGE_SIZE. This constraint is removed.The start address is still assumed to be required
page-aligned, ie., when v4l2 allocates mmap buffers,
the offset between different buffers is page-aligned.Signed-off-by: Tuukka Toivonen
Signed-off-by: Mauro Carvalho Chehab
12 Oct, 2009
1 commit
-
After m68k's task_thread_info() doesn't refer to current,
it's possible to remove sched.h from interrupt.h and not break m68k!
Many thanks to Heiko Carstens for allowing this.Signed-off-by: Alexey Dobriyan
28 Sep, 2009
1 commit
-
* mark struct vm_area_struct::vm_ops as const
* mark vm_ops in AGP codeBut leave TTM code alone, something is fishy there with global vm_ops
being used.Signed-off-by: Alexey Dobriyan
Signed-off-by: Linus Torvalds
17 Jun, 2009
2 commits
-
it is better return -ENOMEM than -EIO
Signed-off-by: Figo.zhang
Signed-off-by: Douglas Schilling Landgraf
Signed-off-by: Mauro Carvalho Chehab -
Change kmalloc()/kfree() to vmalloc()/vfree() for sglist allocation
during videobuf_dma_map() and videobuf_dma_unmap()High resolution sensors might require too many contiguous pages
to be allocated for sglist by kmalloc() during videobuf_dma_map()
(i.e. 256Kib for 8MP sensor).
In such situations, kmalloc() could face some problem to find the
required free memory. vmalloc() is a safer solution instead, as the
allocated memory does not need to be contiguous.Signed-off-by: David Cohen
Signed-off-by: Mauro Carvalho Chehab
08 Jan, 2009
1 commit
-
Not all architectures provide clear_user_page(), but clear_user_highpage()
is available everywhere at least via the compatibility inline function.Is this the "trivial patch" that's required for these two drivers?
Signed-off-by: Guennadi Liakhovetski
Signed-off-by: Mauro Carvalho Chehab
20 Jul, 2008
2 commits
-
Use "scatter gather" instead of "scatter gatter".
Signed-off-by: Magnus Damm
Signed-off-by: Guennadi Liakhovetski
Signed-off-by: Mauro Carvalho Chehab -
1) Remove a useless initialisation of 'i'
2) Avoid clearing the memory allocated twice (once in 'kcalloc', once
in 'sg_init_table')3) Remove a test that can never trigger. The function returns NULL in
such a case, so we know that at this point 'pages[0]' != NULLSigned-off-by: Christophe Jaillet
Signed-off-by: Andrew Morton
Signed-off-by: Mauro Carvalho Chehab
25 Apr, 2008
7 commits
-
videobuf-dvb were still using a function that were videobuf-dma-sg
dependent. This patch creates a generic handler for this function. This
way, videobuf-dvb can now work with all videobuf implementations.Signed-off-by: Mauro Carvalho Chehab
-
Signed-off-by: Mauro Carvalho Chehab
-
__FUNCTION__ is gcc-specific, use __func__
Signed-off-by: Harvey Harrison
Signed-off-by: Michael Krufky
Signed-off-by: Mauro Carvalho Chehab -
…backwards compatibility
Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org> -
Removed warning message:
- videobuf-dma-sg.c: In function 'videobuf_dma_unmap':
- videobuf-dma-sg.c:281: warning: unused variable 'dev'Signed-off-by: Douglas Schilling Landgraf
Signed-off-by: Mauro Carvalho Chehab -
videobuf-dma-sg does not need to depend on PCI. Switch it to using generic
DMA API, convert all affected drivers, relax Kconfig restriction, improve
compile-time type checking, fix some Coding Style violations while at it.Signed-off-by: Guennadi Liakhovetski
Signed-off-by: Mauro Carvalho Chehab -
- Static memory is always initialized with 0.
- Replaced in some cases C99 comments for /* */Signed-off-by: Douglas Schilling Landgraf
Signed-off-by: Mauro Carvalho Chehab