Commit Graph

26 Commits (35b317bec511b4a5f87a637bf78b6d1d635c617d)

Author SHA1 Message Date
Linus Torvalds 71460af58f Revert "[media] V4L: videobuf, don't use dma addr as physical"
This reverts commit 35d9f510b6.

Quoth Jiri Slaby:
 "It fixes mmap when IOMMU is used on x86 only, but breaks architectures
  like ARM or PPC where virt_to_phys(dma_alloc_coherent) doesn't work.
  We need there dma_mmap_coherent or similar (the trickery what
  snd_pcm_default_mmap does but in some saner way).  But this cannot be
  done at this phase."

Requested-by: Jiri Slaby <jslaby@suse.cz>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-04-19 10:54:44 -07:00
Jiri Slaby 35d9f510b6 [media] V4L: videobuf, don't use dma addr as physical
mem->dma_handle is a dma address obtained by dma_alloc_coherent which
needn't be a physical address in presence of IOMMU, as
a hardware IOMMU can (and most likely) will return a bus address where
physical != bus address.

So ensure we are remapping (remap_pfn_range) the right page in
__videobuf_mmap_mapper by using virt_to_phys(mem->vaddr) and not
mem->dma_handle.

While at it, use PFN_DOWN instead of explicit shift.

[mchehab@redhat.com: Fix compilation breakage due to the lack of a comma]
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-03-22 06:51:54 -03:00
Pawel Osciak d639609061 [media] v4l: videobuf: remove unused is_userptr variable
Remove unused is_userptr variable from videobuf-dma-contig.

Signed-off-by: Pawel Osciak <p.osciak@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-10-21 07:55:56 -02:00
Hans Verkuil 08bff03ed6 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>
2010-10-21 01:06:14 -02:00
Hans Verkuil 9739768788 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>
2010-10-21 01:06:14 -02:00
Pawel Osciak b2b476f53a V4L/DVB: v4l: videobuf: prevent passing a NULL to dma_free_coherent()
When a driver that uses videobuf-dma-contig is used with the USERPTR
memory access method a kernel oops might happen: a NULL address may be
passed to dma_free_coherent(). This happens when an application calls
REQBUFS and then exits without queuing any buffers. This patch fixes
that bug.

Signed-off-by: Pawel Osciak <p.osciak@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-09-30 07:22:22 -03:00
Laurent Pinchart 959794ddc0 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>
2010-08-02 15:23:09 -03:00
Pawel Osciak 33c38283f0 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>
2010-08-02 15:20:47 -03:00
Guennadi Liakhovetski f35f1bb8fc V4L/DVB: videobuf-dma-contig.c: simplify pointer dereference
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-05-19 12:58:01 -03:00
Hans Verkuil 0b62b73778 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>
2010-05-19 12:57:54 -03:00
Hans Verkuil 37111039c9 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>
2010-05-19 12:57:53 -03:00
Hans Verkuil 037c75eb14 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>
2010-05-19 12:57:52 -03:00
Hans Verkuil a4cf4cac29 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>
2010-05-19 12:57:51 -03:00
Hans Verkuil 53aaf07637 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>
2010-05-19 12:57:50 -03:00
Tejun Heo 5a0e3ad6af include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files.  percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed.  Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability.  As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

  http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
  only the necessary includes are there.  ie. if only gfp is used,
  gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
  blocks and try to put the new include such that its order conforms
  to its surrounding.  It's put in the include block which contains
  core kernel includes, in the same order that the rest are ordered -
  alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
  doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
  because the file doesn't have fitting include block), it prints out
  an error message indicating which .h file needs to be added to the
  file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
   over 4000 files, deleting around 700 includes and adding ~480 gfp.h
   and ~3000 slab.h inclusions.  The script emitted errors for ~400
   files.

2. Each error was manually checked.  Some didn't need the inclusion,
   some needed manual addition while adding it to implementation .h or
   embedding .c file was more appropriate for others.  This step added
   inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
   from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
   e.g. lib/decompress_*.c used malloc/free() wrappers around slab
   APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
   editing them as sprinkling gfp.h and slab.h inclusions around .h
   files could easily lead to inclusion dependency hell.  Most gfp.h
   inclusion directives were ignored as stuff from gfp.h was usually
   wildly available and often used in preprocessor macros.  Each
   slab.h inclusion directive was examined and added manually as
   necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
   were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
   distributed build env didn't work with gcov compiles) and a few
   more options had to be turned off depending on archs to make things
   build (like ipr on powerpc/64 which failed due to missing writeq).

   * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
   * powerpc and powerpc64 SMP allmodconfig
   * sparc and sparc64 SMP allmodconfig
   * ia64 SMP allmodconfig
   * s390 SMP allmodconfig
   * alpha SMP allmodconfig
   * um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
   a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-30 22:02:32 +09:00
Muralidharan Karicheri 31bedfa506 V4L/DVB (13598): videobuf_dma_contig_user_get() for non-aligned offsets
If a USERPTR address that is not aligned to page boundary is passed to the
videobuf_dma_contig_user_get() function, it saves a page aligned address to
the dma_handle. This is not correct. This issue is observed when using USERPTR
IO machism for buffer exchange.

Updates from last version:-

Adding offset for size calculation as per comment from Magnus Damm. This
ensures the last page is also included for checking if memory is
contiguous.

Signed-off-by: Muralidharan Karicheri <m-karicheri2@ti.com>
Acked-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-12-16 00:18:34 -02:00
Jonathan Corbet 38a54f35a0 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>
2009-12-05 18:41:35 -02:00
Guennadi Liakhovetski f39c1ab3c3 V4L/DVB (13343): v4l: add more missing linux/sched.h includes
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-11-26 19:38:02 -02:00
Alexey Dobriyan f0f37e2f77 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>
2009-09-27 11:39:25 -07:00
Linus Torvalds 0dd5198672 Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (425 commits)
  V4L/DVB (11870): gspca - main: VIDIOC_ENUM_FRAMESIZES ioctl added.
  V4L/DVB (12004): poll method lose race condition
  V4L/DVB (11894): flexcop-pci: dmesg visible names broken
  V4L/DVB (11892): Siano: smsendian - declare function as extern
  V4L/DVB (11891): Siano: smscore - bind the GPIO SMS protocol
  V4L/DVB (11890): Siano: smscore - remove redundant code
  V4L/DVB (11889): Siano: smsdvb - add DVB v3 events
  V4L/DVB (11888): Siano: smsusb - remove redundant ifdef
  V4L/DVB (11887): Siano: smscards - add board (target) events
  V4L/DVB (11886): Siano: smscore - fix some new GPIO definitions names
  V4L/DVB (11885): Siano: Add new GPIO management interface
  V4L/DVB (11884): Siano: smssdio - revert to stand alone module
  V4L/DVB (11883): Siano: cards - add two additional (USB) devices
  V4L/DVB (11824): Siano: smsusb - change exit func debug msg
  V4L/DVB (11823): Siano: smsusb - fix typo in module description
  V4L/DVB (11822): Siano: smscore - bug fix at get_device_mode
  V4L/DVB (11821): Siano: smscore - fix isdb-t firmware name
  V4L/DVB (11820): Siano: smscore - fix byte ordering bug
  V4L/DVB (11819): Siano: smscore - fix get_common_buffer bug
  V4L/DVB (11818): Siano: smscards - assign gpio to HPG targets
  ...
2009-06-16 21:15:42 -07:00
Magnus Damm 720b17e759 videobuf-dma-contig: zero copy USERPTR support
Since videobuf-dma-contig is designed to handle physically contiguous
memory, this patch modifies the videobuf-dma-contig code to only accept a
user space pointer to physically contiguous memory.  For now only
VM_PFNMAP vmas are supported, so forget hotplug.

On SuperH Mobile we use this with our sh_mobile_ceu_camera driver together
with various multimedia accelerator blocks that are exported to user space
using UIO.  The UIO kernel code exports physically contiguous memory to
user space and lets the user space application mmap() this memory and pass
a pointer using the USERPTR interface for V4L2 zero copy operation.

With this approach we support zero copy capture, hardware scaling and
various forms of hardware encoding and decoding.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-06-16 19:47:40 -07:00
Magnus Damm c9adb4314f V4L/DVB (11731): buf-dma-contig: remove sync operation
Remove the videobuf-dma-contig sync operation. Sync is only needed
for noncoherent buffers, and since videobuf-dma-contig is built on
coherent memory allocators the memory is by definition always in sync.

Reported-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Reviewed-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-06-16 18:20:57 -03:00
Magnus Damm d4db588ccc V4L/DVB (10304): buf-dma-contig: fix USERPTR free handling
This patch fixes a free-without-alloc bug for V4L2_MEMORY_USERPTR
video buffers.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-03-30 12:42:27 -03:00
Guennadi Liakhovetski c60f2b5c1d V4L/DVB (8425): v4l: fix checkpatch errors introduced by recent commits
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2008-07-23 08:09:21 -03:00
Hans Verkuil f19ad39014 V4L/DVB (8411): videobuf-dma-contig.c: fix 64-bit build for pre-2.6.24 kernels
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2008-07-20 07:29:22 -03:00
Magnus Damm 2cc45cf25a V4L/DVB (8341): videobuf: Add physically contiguous queue code V3
This is V3 of the physically contiguous videobuf queues patch.
Useful for hardware such as the SuperH Mobile CEU which doesn't
support scatter gatter bus mastering.

Since it may be difficult to allocate large chunks of physically
contiguous memory after some uptime due to fragmentation, this code
allocates memory using dma_alloc_coherent(). Architectures supporting
dma_declare_coherent_memory() can easily avoid fragmentation issues
by using dma_declare_coherent_memory() to force dma_alloc_coherent()
to allocate from a certain pre-allocated memory area.

 Changes since V2
  - use dma_handle for physical address
  - use "scatter gather" instead of "scatter gatter"

 Changes since V1:
  - use dev_err() instead of pr_err()
  - remember size in struct videobuf_dma_contig_memory
  - keep struct videobuf_dma_contig_memory in .c file
  - let videobuf_to_dma_contig() return dma_addr_t
  - implement __videobuf_sync()
  - return statements, white space and other minor fixes

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>
2008-07-20 07:25:37 -03:00