vcsm: VideoCore shared memory service for BCM2835
authorTim Gover <tgover@broadcom.com>
Tue, 22 Jul 2014 14:41:04 +0000 (15:41 +0100)
committerpopcornmix <popcornmix@gmail.com>
Mon, 13 May 2019 23:07:54 +0000 (00:07 +0100)
commit26e7fd6d20349dd82bddeb759fbc86bfccaeaa38
treeef531d56b2d1fa21c4336f9073cb9a932d609d30
parent270ce1368cf61c4db24e08d6db448397f9d8ce25
vcsm: VideoCore shared memory service for BCM2835

Add experimental support for the VideoCore shared memory service.
This allows user processes to allocate memory from VideoCore's
GPU relocatable heap and mmap the buffers. Additionally, the memory
handles can passed to other VideoCore services such as MMAL, OpenMax
and DispmanX

TODO
* This driver was originally released for BCM28155 which has a different
  cache architecture to BCM2835. Consequently, in this release only
  uncached mappings are supported. However, there's no fundamental
  reason which cached mappings cannot be support or BCM2835
* More refactoring is required to remove the typedefs.
* Re-enable the some of the commented out debug-fs statistics which were
  disabled when migrating code from proc-fs.
* There's a lot of code to support sharing of VCSM in order to support
  Android. This could probably done more cleanly or perhaps just
  removed.

Signed-off-by: Tim Gover <timgover@gmail.com>
config: Disable VC_SM for now to fix hang with cutdown kernel

vcsm: Use boolean as it cannot be built as module

On building the bcm_vc_sm as a module we get the following error:

v7_dma_flush_range and do_munmap are undefined in vc-sm.ko.

Fix by making it not an option to build as module

vcsm: Add ioctl for custom cache flushing

vc-sm: Move headers out of arch directory

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
vcsm: Treat EBUSY as success rather than SIGBUS

Currently if two cores access the same page concurrently one will return VM_FAULT_NOPAGE
and the other VM_FAULT_SIGBUS crashing the user code.

Also report when mapping fails.

Signed-off-by: popcornmix <popcornmix@gmail.com>
vcsm: Provide new ioctl to clean/invalidate a 2D block

vcsm: Convert to loading via device tree.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
VCSM: New option to import a DMABUF for VPU use

Takes a dmabuf, and then calls over to the VPU to wrap
it into a suitable handle.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
vcsm: fix multi-platform build

vcsm: add macros for cache functions

vcsm: use dma APIs for cache functions

* Will handle multi-platform builds

vcsm: Fix up macros to avoid breaking numbers used by existing apps

vcsm: Define cache operation constants in user header

Without this change, users have to use raw values (1, 2, 3) to specify
cache operation.

Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
vcsm: Support for finding user/vc handle in memory pool

vmcs_sm_{usr,vc}_handle_from_pid_and_address() were failing to find
handle if specified user pointer is not exactly the one that the memory
locking call returned even if the pointer is in range of map/resource.
So fixed the functions to match the range.

Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
vcsm: Unify cache manipulating functions

Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
vcsm: Fix obscure conditions

Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
vcsm: Fix memory leaking on clean_invalid2 ioctl handler

Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
vcsm: Describe the use of cache operation constants

Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
vcsm: Fix obscure conditions again

Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
vcsm: Add no-op cache operation constant

Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
vcsm: Revert to do page-table-walk-based cache manipulating on some ioctl calls

On FLUSH, INVALID, CLEAN_INVALID ioctl calls, cache operations based on
page table walk were used in case that the buffer of the cache is not
pinned.  So reverted to do page-table-based cache manipulating.

Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
vcsm: Define cache operation constants in user header

Without this change, users have to use raw values (1, 2, 3) to specify
cache operation.

Signed-off-by: Sugizaki Yukimasa <i.can.speak.c.and.basic@gmail.com>
drivers/char/Kconfig
drivers/char/Makefile
drivers/char/broadcom/Kconfig
drivers/char/broadcom/Makefile
drivers/char/broadcom/vc_sm/Makefile [new file with mode: 0644]
drivers/char/broadcom/vc_sm/vc_sm_defs.h [new file with mode: 0644]
drivers/char/broadcom/vc_sm/vc_sm_knl.h [new file with mode: 0644]
drivers/char/broadcom/vc_sm/vc_vchi_sm.c [new file with mode: 0644]
drivers/char/broadcom/vc_sm/vc_vchi_sm.h [new file with mode: 0644]
drivers/char/broadcom/vc_sm/vmcs_sm.c [new file with mode: 0644]
include/linux/broadcom/vmcs_sm_ioctl.h [new file with mode: 0644]