summaryrefslogtreecommitdiffstats
path: root/drivers/media/video/videobuf-dma-sg.c
Commit message (Collapse)AuthorAgeFilesLines
* [media] videobuf-dma-sg: Use min_t(size_t, PAGE_SIZE ..)Mauro Carvalho Chehab2010-10-211-2/+2
| | | | | | | | | As pointed by Laurent: I think min_t(size_t, PAGE_SIZE, size) is the preferred way. Thanks-to: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: videobuf-dma-sg: Fix a warning due to the usage of min(PAGE_SIZE, arg)Mauro Carvalho Chehab2010-10-211-2/+2
| | | | | | | | 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 cast Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: videobuf: add ext_lock argument to the queue init functionsHans Verkuil2010-10-211-2/+3
| | | | | | | | | 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 <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: videobuf: prepare to make locking optional in videobufHans Verkuil2010-10-211-2/+2
| | | | | | | | | | | | | 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 <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: videobuf-dma-sg: set correct size in last sg elementHans Verkuil2010-09-271-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <hans.verkuil@tandberg.com> Cc: stable@kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: videobuf: Rename vmalloc fields to vaddrLaurent Pinchart2010-08-021-9/+9
| | | | | | | | | 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 <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: videobuf: Remove videobuf_mapping start and end fieldsLaurent Pinchart2010-08-021-2/+0
| | | | | | | The fields are assigned but never used, remove them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: videobuf: Don't export videobuf_(vmalloc|pages)_to_sgLaurent Pinchart2010-08-021-4/+14
| | | | | | | | Those functions are only called inside videobuf-dma-sg.c, make them static. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: videobuf: Remove the videobuf_sg_dma_map/unmap functionsLaurent Pinchart2010-08-021-27/+5
| | | | | | | | | | 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 <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: videobuf: rename videobuf_alloc to videobuf_alloc_vbPawel Osciak2010-08-021-3/+3
| | | | | | | | | | | | 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 <p.osciak@samsung.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: buf-dma-sg.c: don't assume nr_pages == sglenArnout Vandecappelle2010-05-191-2/+2
| | | | | | | | | 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 <mchehab@redhat.com>
* V4L/DVB: videobuf-dma-sg: remove external function videobuf_dma_sync()Mauro Carvalho Chehab2010-05-191-13/+7
| | | | | | | | 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 <mchehab@redhat.com>
* V4L/DVB: videobuf-dma-sg: Avoid using a wrong sizeMauro Carvalho Chehab2010-05-191-2/+2
| | | | | | | | | | | 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 function The 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 <mchehab@redhat.com>
* V4L/DVB: v4l videobuf: add videobuf_buffer *buf as argument to mmap_mapperHans Verkuil2010-05-191-36/+33
| | | | | | | | | | | | 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 <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: v4l videobuf: move video_copy_to_user and copy_stream to coreHans Verkuil2010-05-191-49/+0
| | | | | | | | | | 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 <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: v4l videobuf: rename .vmalloc to .vaddrHans Verkuil2010-05-191-2/+2
| | | | | | | | | 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 <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: v4l videobuf: use struct videobuf_buffer * instead of void * for ↵Hans Verkuil2010-05-191-1/+1
| | | | | | | | | | videobuf_alloc videobuf_alloc() returned a void *. Change to struct videobuf_buffer * to get better type checking. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: v4l videobuf: remove mmap_free callbackHans Verkuil2010-05-191-15/+0
| | | | | | | | | | | 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 <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: v4l: videobuf: code cleanupPawel Osciak2010-05-181-136/+140
| | | | | | | | Make videobuf pass checkpatch; minor code cleanups. Signed-off-by: Pawel Osciak <p.osciak@samsung.com> Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: videobuf: add missing checks for kzalloc returning NULLPawel Osciak2010-02-261-0/+2
| | | | | Signed-off-by: Pawel Osciak <p.osciak@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (13377): make struct videobuf_queue_ops constantJonathan Corbet2009-12-051-1/+1
| | | | | | | | | | 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 <corbet@lwn.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (13165): videobuf do not force buffer size to be multiple of PAGE_SIZETuukka Toivonen2009-12-051-2/+2
| | | | | | | | | | | | | | | 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 <tuukka.o.toivonen@nokia.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* headers: remove sched.h from interrupt.hAlexey Dobriyan2009-10-111-0/+1
| | | | | | | | 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 <adobriyan@gmail.com>
* const: mark struct vm_struct_operationsAlexey Dobriyan2009-09-271-1/+1
| | | | | | | | | | | * mark struct vm_area_struct::vm_ops as const * mark vm_ops in AGP code But leave TTM code alone, something is fishy there with global vm_ops being used. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* V4L/DVB (11953): videobuf-dma-sg: return -ENOMEM if vmalloc failsFigo.zhang2009-06-161-1/+1
| | | | | | | | it is better return -ENOMEM than -EIO Signed-off-by: Figo.zhang <figo1802@gmail.com> Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (11840): change kmalloc to vmalloc for sglist allocation in ↵Cohen David.A2009-06-161-8/+9
| | | | | | | | | | | | | | | | | videobuf_dma_map/unmap 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 <david.cohen@nokia.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (10176a): Switch remaining clear_user_page users over to ↵Guennadi Liakhovetski2009-01-071-2/+1
| | | | | | | | | | | | clear_user_highpage 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 <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (8340): videobuf: Fix gather spellingMagnus Damm2008-07-201-1/+1
| | | | | | | | Use "scatter gather" instead of "scatter gatter". Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (8252): buf-dma-sg.c: avoid clearing memory twiceChristophe Jaillet2008-07-201-4/+2
| | | | | | | | | | | | | | 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]' != NULL Signed-off-by: Christophe Jaillet <jaillet.christophe@wanadoo.fr> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7566): videobuf-dvb: allow its usage with videobuf-vmallocMauro Carvalho Chehab2008-04-241-0/+11
| | | | | | | | 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 <mchehab@infradead.org>
* V4L/DVB (7554): videobuf-dma-sg: Remove unused flagMauro Carvalho Chehab2008-04-241-4/+0
| | | | Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7518): media/video/ replace remaining __FUNCTION__ occurrencesHarvey Harrison2008-04-241-2/+2
| | | | | | | | __FUNCTION__ is gcc-specific, use __func__ Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7494): videobuf-dma-sg.c: Avoid NULL dereference and add comment ↵Brandon Philips2008-04-241-1/+15
| | | | | | | about backwards compatibility Signed-off-by: Brandon Philips <bphilips@suse.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7283): videobuf-dma-sg: Remove unused variableDouglas Schilling Landgraf2008-04-241-2/+0
| | | | | | | | | | 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 <dougsland@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7237): Convert videobuf-dma-sg to generic DMA APIGuennadi Liakhovetski2008-04-241-58/+59
| | | | | | | | | 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 <g.liakhovetski@pengutronix.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7094): static memoryDouglas Schilling Landgraf2008-04-241-1/+1
| | | | | | | | - Static memory is always initialized with 0. - Replaced in some cases C99 comments for /* */ Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7121): Renames videobuf lock to vb_lockMauro Carvalho Chehab2008-02-181-2/+2
| | | | | | | This helps to identify where vb_lock is being used, and find missusages of the locks. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6749): v4l-nopage-fixAndrew Morton2008-01-251-1/+2
| | | | | | | | | dont just copy-and-paste stuff. (compile-tested this time) Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6748): Subject: v4l: nopageNick Piggin2008-01-251-12/+8
| | | | | | | | | Convert v4l from nopage to fault. Remove redundant vma range checks. Signed-off-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* SG: Change sg_set_page() to take length and offset argumentJens Axboe2007-10-241-7/+3
| | | | | | | | | | Most drivers need to set length and offset as well, so may as well fold those three lines into one. Add sg_assign_page() for those two locations that only needed to set the page, where the offset/length is set outside of the function context. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
* [PATCH] Fix breakage after SG cleanupsRalf Baechle2007-10-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | Commits 58b053e4ce9d2fc3023645c1b96e537c72aa8d9a ("Update arch/ to use sg helpers") 45711f1af6eff1a6d010703b4862e0d2b9afd056 ("[SG] Update drivers to use sg helpers") fa05f1286be25a8ce915c5dd492aea61126b3f33 ("Update net/ to use sg helpers") converted many files to use the scatter gather helpers without ensuring that the necessary headerfile <linux/scatterlist> is included. This happened to work for ia64, powerpc, sparc64 and x86 because they happened to drag in that file via their <asm/dma-mapping.h>. On most of the others this probably broke. Instead of increasing the header file spider web I choose to include <linux/scatterlist.h> directly into the affectes files. Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* [SG] Update drivers to use sg helpersJens Axboe2007-10-221-3/+5
| | | | Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
* v4l: copy_to_user() is not a good method nameAl Viro2007-10-131-1/+1
| | | | | | | | Breaks on any target that has copy_to_user() defined as a non-trivial macro. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* V4L/DVB (6292): videobuf_core init always require callback implementationMauro Carvalho Chehab2007-10-101-2/+2
| | | | | | | | | | | In the past, videobuf_queue_init were used to initialize PCI DMA videobuffers. This patch renames it, to avoid confusion with the previous kernel API, doing: s/videobuf_queue_init/void videobuf_queue_core_init/ Also, the operations is now part of the function parameter. The function will also add a test if this is defined, otherwise producing BUG. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6290): remove videobuf_set_pci_opsMauro Carvalho Chehab2007-10-101-58/+4
| | | | | | | | | | Before the videobuf redesign, a procedure for re-using videobuf without PCI scatter/gather where provided by changing the pci-dependent operations by other operations. With the newer approach, those methods are obsolete and can safelly be removed. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6268): V4L: Fix a lock inversion in generic videobuf codeMaxim Levitsky2007-10-101-5/+27
| | | | | | | | | | | | | | | | | | | videobuf_qbuf takes q->lock, and then calls q->ops->buf_prepare which by design in all drivers calls videobuf_iolock which calls videobuf_dma_init_user and this takes current->mm->mmap_sem on the other hand if user calls mumap from other thread, sys_munmap takes current->mm->mmap_sem and videobuf_vm_close takes q->lock Since this can occur only for V4L2_MEMORY_MMAP buffers, take current->mm->mmap_sem in qbuf, before q->lock, and don't take current->mm->mmap_sem videobuf_dma_init_user for those buffers Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com> http://thread.gmane.org/gmane.comp.video.video4linux/34978/focus=34981 Reviewed-by: Ricardo Cerqueira <v4l@cerqueira.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6266): videobuf cleanup: mmap check is common to all videobuf. Make ↵Mauro Carvalho Chehab2007-10-101-19/+5
| | | | | | | | it at core Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org> http://thread.gmane.org/gmane.comp.video.video4linux/34978/focus=34981 Reviewed-by: Ricardo Cerqueira <v4l@cerqueira.org>
* V4L/DVB (6251): Replace video-buf to a more generic approachMauro Carvalho Chehab2007-10-091-0/+772
video-buf currently does two different tasks: - Manages video buffers with a common code that allows implementing all the V4L2 different modes of buffering; - Controls memory allocations While the first task is generic, the second were written to support PCI DMA Scatter/Gather needs. The original approach can't even work for those video capture hardware that don't support scatter/gather. I did one approach to make it more generic. While the approach worked fine for vivi driver, it were not generic enough to handle USB needs. This patch creates two different modules, one containing the generic video buffer handling (videobuf-core) and another with PCI DMA S/G. After this patch, it would be simpler to write an USB video-buf and a non-SG DMA module. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org> http://thread.gmane.org/gmane.comp.video.video4linux/34978/focus=34981 Reviewed-by: Ricardo Cerqueira <v4l@cerqueira.org>
OpenPOWER on IntegriCloud