aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/videobuf-vmalloc.c
Commit message (Collapse)AuthorAge
* V4L/DVB: videobuf: add ext_lock argument to the queue init functionsHans Verkuil2010-10-20
| | | | | | | | | 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-20
| | | | | | | | | | | | | 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: Rename vmalloc fields to vaddrLaurent Pinchart2010-08-02
| | | | | | | | | 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-02
| | | | | | | 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: rename videobuf_alloc to videobuf_alloc_vbPawel Osciak2010-08-02
| | | | | | | | | | | | 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: videobuf-vmalloc: remove __videobuf_sync()Mauro Carvalho Chehab2010-05-19
| | | | | | | | videobuf-core checks if .sync ops is defined before calling. So, we don't need a do-nothing function. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: v4l videobuf: add videobuf_buffer *buf as argument to mmap_mapperHans Verkuil2010-05-19
| | | | | | | | | | | | 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-19
| | | | | | | | | | 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-19
| | | | | | | | | 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-19
| | | | | | | | | | 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-19
| | | | | | | | | | | 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-17
| | | | | | | | 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-26
| | | | | Signed-off-by: Pawel Osciak <p.osciak@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (13417): Fix videobuf_queue_vmalloc_init() prototypeJonathan Corbet2009-12-05
| | | | | | | | | | | For whatever reason, the device structure pointer to videobuf_queue_vmalloc_init is typed "void *", even though it's passed right through to videobuf_queue_core_init(), which expects a struct device pointer. The other videobuf implementations use struct device *; I think vmalloc should too. Signed-off-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (13377): make struct videobuf_queue_ops constantJonathan Corbet2009-12-05
| | | | | | | | | | 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>
* const: mark struct vm_struct_operationsAlexey Dobriyan2009-09-27
| | | | | | | | | | | * 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 (10305): videobuf-vmalloc: Fix: videobuf memory were never freedMauro Carvalho Chehab2009-03-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | videobuf_vmalloc_free() is never freeing the video buffer memory. Due to that, after multiple open/closes, user can suffer a panic: Kernel BUG at mm/slab.c:2650 invalid opcode: 0000 [1] SMP last sysfs file: /class/video4linux/video0/dev CPU 4 Modules linked in: vivi(U) videodev(U) v4l1_compat(U) v4l2_compat_ioctl32(U) videobuf_vmalloc(U) videobuf_core(U) ipv6 xfrm_nalgo autofs4 vmnet(U) vmblock(U) vmci(U) vmmon(U) ip_conntrack_netbios_ns ipt_REJECT xt_state ip_conntrack nfnetlink xt_tcpudp iptable_filter ip_tables x_tables cpufreq_ondemand dm_mirror dm_log dm_multipath scsi_dh dm_mod video backlight sbs i2c_ec button battery asus_acpi acpi_memhotplug ac lp testmgr_cipher testmgr aead crypto_blkcipher crypto_algapi crypto_api arc4 snd_hda_intel nvidia(PFU) snd_seq_dummy snd_seq_oss snd_seq_midi_event rt73usb crc_itu_t snd_seq snd_seq_device snd_pcm_oss snd_mixer_oss tg3 sr_mod snd_pcm snd_timer snd_page_alloc snd_hwdep pcspkr rt2500usb cdrom rt2x00usb rt2x00lib libphy snd parport_pc soundcore shpchp serio_raw i2c_i801 i5400_edac parport ata_piix sg mac80211 edac_mc i2c_core cfg80211 ahci libata sd_mod scsi_mod ext3 jbd uhci_hcd ohci_hcd ehci_hcd Pid: 6215, comm: v4l-stress-buff Tainted: PF 2.6.18-118.el5 #1 RIP: 0010:[<ffffffff80017506>] [<ffffffff80017506>] cache_grow+0x1e/0x395 RSP: 0018:ffff810128a35d28 EFLAGS: 00010006 RAX: 0000000000000000 RBX: 00000000000080d0 RCX: 00000000ffffffff RDX: 0000000000000000 RSI: 00000000000080d0 RDI: ffff8101042d8340 RBP: ffff8101042ce5e0 R08: ffff81012fc1e8c0 R09: ffff8101042eac00 R10: 0000000000000000 R11: ffffffff882a5139 R12: ffff8101042d8340 R13: ffff8101042ce5c0 R14: 0000000000000000 R15: ffff8101042d8340 FS: 0000000000000000(0000) GS:ffff81012fc24d40(0063) knlGS:00000000f7f706c0 CS: 0010 DS: 002b ES: 002b CR0: 000000008005003b CR2: 00000000f7f9a000 CR3: 0000000117ad0000 CR4: 00000000000006e0 Process v4l-stress-buff (pid: 6215, threadinfo ffff810128a34000, task ffff810128fcb820) Stack: ffffc20012a39000 0000004415173ff8 ffff810000011c10 000280d200000000 0000000000000002 00000000ffffffff ffff8101042ce5e0 ffff81012fc1e8c0 ffff8101042ce5c0 000000000000000c ffff8101042d8340 ffffffff8005bdde Call Trace: [<ffffffff8005bdde>] cache_alloc_refill+0x136/0x186 [<ffffffff800d7822>] kmem_cache_alloc_node+0x98/0xb2 [<ffffffff800cda1f>] __vmalloc_area_node+0x62/0x153 [<ffffffff800cdd65>] vmalloc_user+0x15/0x50 [<ffffffff882a521f>] :videobuf_vmalloc:__videobuf_iolock+0xe6/0x155 [<ffffffff8838f958>] :vivi:buffer_prepare+0xb9/0xe6 [<ffffffff882981f3>] :videobuf_core:__videobuf_read_start+0xa2/0x10f [<ffffffff882983e6>] :videobuf_core:videobuf_read_stream+0x9c/0x1f3 [<ffffffff8000b3f3>] vfs_read+0xcb/0x171 [<ffffffff80011967>] sys_read+0x45/0x6e [<ffffffff8006149b>] sysenter_do_call+0x1b/0x67 Code: 0f 0b 68 af 1e 2a 80 c2 5a 0a f6 c7 20 0f 85 53 03 00 00 89 RIP [<ffffffff80017506>] cache_grow+0x1e/0x395 RSP <ffff810128a35d28> <0>Kernel panic - not syncing: Fatal exception Thanks to Douglas Schilling Landgraf <dougsland@gmail.com> for writing a stress tool for testing and to Robert Krakora <rob.krakora@messagenetsystems.com> to trace the code and discover the point where the bug were happening. Thanks also to Magnus Damm <damm@igel.co.jp> that provided us a fix for a similar bug on videobuf-dma-contig. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (8525): fix a few assorted spelling mistakes.Hans Verkuil2008-07-27
| | | | | Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (8340): videobuf: Fix gather spellingMagnus Damm2008-07-20
| | | | | | | | 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 (7566): videobuf-dvb: allow its usage with videobuf-vmallocMauro Carvalho Chehab2008-04-24
| | | | | | | | 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 (7561): videobuf-vmalloc: stop streaming before unmapMauro Carvalho Chehab2008-04-24
| | | | | | | Before the patch, there were a risk of freeing and unmapping userspace memory, while there were pending requests. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7553): videobuf-vmalloc: fix STREAMOFF/STREAMONMauro Carvalho Chehab2008-04-24
| | | | | | | | | | | | | | There were a small bug on videobuf-vmalloc that were preventing STREAMOFF to work. The issue is that vmalloc'ed mmaped memory should only be freed after being sure that there aren't any mmap usage. Otherwise, the memory remap will stop working, and the userspace won't receive any frames. This bug were affecting some userspace applications, like tvtime. After this patch, tvtime started to work again with the drivers that use videobuf-vmalloc. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7552): videbuf-vmalloc: Corrects mmap codeMauro Carvalho Chehab2008-04-24
| | | | | | | | | | | | | | | | | | | | | | There were some bugs on videobuf-vmalloc. Basically, remap were called with a wrong parameter. Due to that, a later remap were needed, generating the need of some hacks on videobuf-vmalloc and videobuf-core. This patch fixes the remap and removes the hacks. TODO: - V4L2_MEMORY_USERPTR is not implemented yet. This method should be properly implemented, in order to work with a few userspace applications. - The driver also doesn't implement V4L2_MEMORY_OVERLAY. This method is used only by a few applications, and are becaming obsolete, due to the increment of cpu performance. So, most apps prefer to retrieve data to an internal buffer, doing some processing like de-interlacing. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7518): media/video/ replace remaining __FUNCTION__ occurrencesHarvey Harrison2008-04-24
| | | | | | | | __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 (7489): videobuf-vmalloc.c: Remove buf_release from videobuf_vm_closeBrandon Philips2008-04-24
| | | | | | | | | Remove the buf_release on vm_close because it will lead to a buffer being released multiple times since all buffers are already freed under the two possible cases: device close or STREAMOFF. Signed-off-by: Brandon Philips <bphilips@suse.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7237): Convert videobuf-dma-sg to generic DMA APIGuennadi Liakhovetski2008-04-24
| | | | | | | | | 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-24
| | | | | | | | - 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 (7150): [v4l] convert videbuf_vmalloc_memory to videobuf_vmalloc_memoryBrandon Philips2008-02-18
| | | | | Signed-off-by: Brandon Philips <bphilips@suse.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7121): Renames videobuf lock to vb_lockMauro Carvalho Chehab2008-02-18
| | | | | | | 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 (6688): V4L: fix copy and paste error in dprintk for videobuf-vmalloc.cBrandon Philips2008-01-25
| | | | | Signed-off-by: Brandon Philips <bphilips@suse.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6751): V4L: Memory leak! Fix count in videobuf-vmalloc mmapBrandon Philips2007-12-11
| | | | | | | | | | | | | This is pretty serious bug. map->count is never initialized after the call to kmalloc making the count start at some random trash value. The end result is leaking videobufs. Also, fix up the debug statements to print unsigned values. Pushed to http://ifup.org/hg/v4l-dvb too Signed-off-by: Brandon Philips <bphilips@suse.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* v4l: copy_to_user() is not a good method nameAl Viro2007-10-13
| | | | | | | | 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-09
| | | | | | | | | | | 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 (6266): videobuf cleanup: mmap check is common to all videobuf. Make ↵Mauro Carvalho Chehab2007-10-09
| | | | | | | | 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 (6263): Fix buffer release codeMauro Carvalho Chehab2007-10-09
| | | | | | Release code should happen before the cleaning of map variable. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6262): An allocation error message were being printed as a debug msgMauro Carvalho Chehab2007-10-09
| | | | Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6261): Cleans mem->vmalloc after vfreeMauro Carvalho Chehab2007-10-09
| | | | Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6254): Add videobuf-vmallocMauro Carvalho Chehab2007-10-09
Adds a newer videobuf-vmalloc module. This module uses the same videobuf controls, but implements memory allocation based on vmalloc methods. With this method, an USB driver can use video-buf, without needing to request memory from the DMA-safe area. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>