History log of /drivers/media/video/videobuf-vmalloc.c
Revision Date Author Comments
08bff03ed697a583612b62a6ac566bd5bce98012 20-Sep-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: videobuf: add ext_lock argument to the queue init functions

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>
97397687886aa8ecd4ec603fab9e70e970c11597 20-Sep-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: videobuf: prepare to make locking optional in videobuf

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>
bb6dbe74806a17bcec8396c57ca7fd9a889e3b27 11-May-2010 Laurent Pinchart <laurent.pinchart@ideasonboard.com> V4L/DVB: videobuf: Rename vmalloc fields to vaddr

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>
959794ddc05ab6fbcd458bc093e7f0b92633d052 11-May-2010 Laurent Pinchart <laurent.pinchart@ideasonboard.com> V4L/DVB: videobuf: Remove videobuf_mapping start and end fields

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>
33c38283f03d8ea0358229fc03c1beebe67aed0e 11-May-2010 Pawel Osciak <p.osciak@samsung.com> V4L/DVB: videobuf: rename videobuf_alloc to videobuf_alloc_vb

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>
c06b062bea411f616b0890d502044c7871d5332f 05-May-2010 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB: videobuf-vmalloc: remove __videobuf_sync()

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>
0b62b73778554cd47480ea465f0b255cc63b4336 28-Mar-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: v4l videobuf: add videobuf_buffer *buf as argument to mmap_mapper

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>
37111039c9521c751ce0597c129fe6d45ba72818 28-Mar-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: v4l videobuf: move video_copy_to_user and copy_stream to core

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>
037c75eb14cd6adb837f81f0c2b2a52c31c91e69 28-Mar-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: v4l videobuf: rename .vmalloc to .vaddr

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>
a4cf4cac2979a828e7cd0a3cd02d7a5308a44a7f 28-Mar-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: v4l videobuf: use struct videobuf_buffer * instead of void * for 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>
53aaf07637baae8f53c33b803bbc96047d8da1c4 28-Mar-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: v4l videobuf: remove mmap_free callback

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>
7a02264ca9ec5409e22b9d41f32b431d08eadbce 17-Mar-2010 Pawel Osciak <p.osciak@samsung.com> V4L/DVB: v4l: videobuf: code cleanup

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>
bee527f97963ece5e3f6e6587402197af889865b 22-Feb-2010 Pawel Osciak <p.osciak@samsung.com> V4L/DVB: videobuf: add missing checks for kzalloc returning NULL

Signed-off-by: Pawel Osciak <p.osciak@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
f8b0bca1a7ea8479490bcc06835ccbf590ba2c4e 23-Nov-2009 Jonathan Corbet <corbet@lwn.net> V4L/DVB (13417): Fix videobuf_queue_vmalloc_init() prototype

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>
38a54f35a0a90c0b62b111dd4de24248b22616b9 17-Nov-2009 Jonathan Corbet <corbet@lwn.net> V4L/DVB (13377): make struct videobuf_queue_ops constant

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>
f0f37e2f77731b3473fa6bd5ee53255d9a9cdb40 27-Sep-2009 Alexey Dobriyan <adobriyan@gmail.com> const: mark struct vm_struct_operations

* 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>
5993a663a96df53f14d9e71abc27bcbd442317df 24-Jan-2009 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB (10305): videobuf-vmalloc: Fix: videobuf memory were never freed

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>
de1e575db21a341b77b296af7dd87f163ebf6020 26-Jul-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (8525): fix a few assorted spelling mistakes.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
5d6aaf50e2986d3289d16fc2859c490c66a1be63 17-Jul-2008 Magnus Damm <magnus.damm@gmail.com> V4L/DVB (8340): videobuf: Fix gather spelling

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>
59d3448995a4c0ca98cbe82f6dac9460323377c1 13-Apr-2008 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (7566): videobuf-dvb: allow its usage with videobuf-vmalloc

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>
aa9479ed508d78dcd06479dc6274c9b02d1398df 13-Apr-2008 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (7561): videobuf-vmalloc: stop streaming before unmap

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>
aaea56afc31345e7b0456ebb01586ba627ecd0f8 13-Apr-2008 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (7553): videobuf-vmalloc: fix STREAMOFF/STREAMON

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>
968ced78a53509a996708a14e8b9269d1dc6a61c 13-Apr-2008 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (7552): videbuf-vmalloc: Corrects mmap code

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>
7e28adb2497f6b873516163e2d29210c11777613 09-Apr-2008 Harvey Harrison <harvey.harrison@gmail.com> V4L/DVB (7518): media/video/ replace remaining __FUNCTION__ occurrences

__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>
cbcb565f74cf01d680f83af531490bb2c5375af0 02-Apr-2008 Brandon Philips <brandon@ifup.org> V4L/DVB (7489): videobuf-vmalloc.c: Remove buf_release from videobuf_vm_close

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>
0705135e59f8503e4dade4b3580fed77b1743b7c 22-Apr-2008 Guennadi Liakhovetski <g.liakhovetski@pengutronix.de> V4L/DVB (7237): Convert videobuf-dma-sg to generic DMA API

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>
ff699e6bd02eb1c6d02c7c2b576c2ee6caab201c 22-Apr-2008 Douglas Schilling Landgraf <dougsland@gmail.com> V4L/DVB (7094): static memory

- 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>
384b835aed8acf341d99969b58d27434685bdd3d 05-Feb-2008 Brandon Philips <bphilips@suse.de> V4L/DVB (7150): [v4l] convert videbuf_vmalloc_memory to videobuf_vmalloc_memory

Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
64f9477f95bf5d4ba49dc3988d47a15bc06bb5da 31-Jan-2008 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (7121): Renames videobuf lock to vb_lock

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>
493977f016f2ff52fdca38d031c7211b4da658fd 01-Dec-2007 Brandon Philips <bphilips@suse.de> V4L/DVB (6688): V4L: fix copy and paste error in dprintk for videobuf-vmalloc.c

Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
0b29669c065f60501e7289e1950fa2a618962358 09-Dec-2007 Brandon Philips <bphilips@suse.de> V4L/DVB (6751): V4L: Memory leak! Fix count in videobuf-vmalloc mmap

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>
13bcd5d0e21e3ca726965371ada8ff6c64af288f 13-Oct-2007 Al Viro <viro@ftp.linux.org.uk> v4l: copy_to_user() is not a good method name

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>
d4cae5a50021271b9ef4e5e39e71e177d12fa8cb 08-Oct-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6292): videobuf_core init always require callback implementation

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>
851c0c96b2212f48fe51afc1589541b5eae3a544 27-Sep-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6266): videobuf cleanup: mmap check is common to all videobuf. Make 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>
123f8ef64e3996e06a930756b6b2cdede4b18da0 07-Sep-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6263): Fix buffer release code

Release code should happen before the cleaning of map variable.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
e78dcf55520769471c66024b13df7e9e592436f4 07-Sep-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6262): An allocation error message were being printed as a debug msg

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
c520a4970c7e5f18275ef935372e56eabd6d0e44 06-Sep-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6261): Cleans mem->vmalloc after vfree

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
87b9ad070cf76c0f1e8cf836f7eb86e9ac94e34a 03-Aug-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6254): Add videobuf-vmalloc

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>