Skip to content

Commit df4c769

Browse files
6by9popcornmix
authored andcommitted
staging: vc04_services: Add new vc-sm-cma driver
This new driver allows contiguous memory blocks to be imported into the VideoCore VPU memory map, and manages the lifetime of those objects, only releasing the source dmabuf once the VPU has confirmed it has finished with it. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Correct DMA configuration. Now that VCHIQ is setting up the DMA configuration as our parent device, don't try to configure it during probe. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Use a void* pointer as the handle within the kernel The driver was using an unsigned int as the handle to the outside world, and doing a nasty cast to the struct dmabuf when handed it back. This breaks badly with a 64 bit kernel where the pointer doesn't fit in an unsigned int. Switch to using a void* within the kernel. Reality is that it is a struct dma_buf*, but advertising it as such to other drivers seems to encourage the use of it as such, and I'm not sure on the implications of that. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Fix up for 64bit builds There were a number of logging lines that were using inappropriate formatting under 64bit kernels. The kernel_id field passed to/from the VPU was being abused for storing the struct vc_sm_buffer *. This breaks with 64bit kernels, so change to using an IDR. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc_sm_cma: Remove erroneous misc_deregister Code from the misc /dev node was still present in bcm2835_vc_sm_cma_remove, which caused a NULL deref. Remove it. See raspberrypi#2885. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Remove the debugfs directory on remove Without removing that, reloading the driver fails. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Use devm_ allocs for sm_state. Use managed allocations for sm_state, removing reliance on manual management. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Don't fail if debugfs calls fail. Return codes from debugfs calls should never alter the flow of the main code. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Ensure mutex and idr are destroyed map_lock and kernelid_map are created in probe, but not released in release should the vcsm service not connect (eg running the cutdown firmware). Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Remove obsolete comment and make function static Removes obsolete comment about wanting to pass a function pointer into mmal-vchiq as we now do. As the function is passed as a function pointer, the function itself can be static. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Add in allocation for VPU requests. Module has to change from tristate to bool as all CMA functions are boolean. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Update TODO. The driver is already a platform driver, so that can be deleted from the TODO. There are no known issues that need to be resolved. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Add in userspace allocation API Replacing the functionality from the older vc-sm driver, add in a userspace API that allows allocation of buffers, and importing of dma-bufs. The driver hands out dma-buf fds, therefore much of the handling around lifespan and odd mmaps from the old driver goes away. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vcsm-cma: Add cache control ioctls The old driver allowed for direct cache manipulation and that was used by various clients. Replicate here. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vcsm-cma: Alter dev node permissions to 0666 Until the udev rules are updated, open up access to this node by default. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vcsm-cma: Drop logging level on messages in vc_sm_release_resource They weren't errors but were logged as such. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vcsm-cma: Fixup the alloc code handling of kernel_id The allocation code had been copied in from an old branch prior to having added the IDR for 64bit support. It was therefore pushing a pointer into the kernel_id field instead of an IDR handle, the lookup therefore failed, and we never released the buffer. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vcsm-cma: Remove cache manipulation ioctl from ARM64 The cache flushing ioctls are used by the Pi3 HEVC hw-assisted decoder as it needs finer grained flushing control than dma_ops allow. These cache calls are not present for ARM64, therefore disable them. We are not actively supporting 64bit kernels at present, and the use case of the HEVC decoder is fairly limited. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vcsm-cma: Rework to use dma APIs, not CMA Due to a misunderstanding of the DMA mapping APIs, I made the wrong decision on how to implement this. Rework to use dma_alloc_coherent instead of the CMA API. This also allows it to be built as a module easily. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc-sm-cma: Fix the few remaining coding style issues Fix a few minor checkpatch complaints to make the driver clean Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> staging: vc04_services: fix compiling in separate directory The vc04_services Makefiles do not respect the O=path argument correctly: include paths in CFLAGS are given relatively to object path, not source path. Compiling in a separate directory yields #include errors. Signed-off-by: Marek Behún <marek.behun@nic.cz> vc-sm-cma: Fix compatibility ioctl This code path hasn't been used previously. Fixed up after testing with kodi on 32-bit userland and 64-bit kernel Signed-off-by: popcornmix <popcornmix@gmail.com>
1 parent a374ec7 commit df4c769

14 files changed

Lines changed: 2892 additions & 3 deletions

File tree

‎drivers/staging/vc04_services/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ source "drivers/staging/vc04_services/bcm2835-audio/Kconfig"
2323

2424
source "drivers/staging/vc04_services/bcm2835-camera/Kconfig"
2525
source "drivers/staging/vc04_services/vchiq-mmal/Kconfig"
26+
source "drivers/staging/vc04_services/vc-sm-cma/Kconfig"
2627

2728
endif
2829

‎drivers/staging/vc04_services/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ vchiq-objs := \
1313
obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/
1414
obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-camera/
1515
obj-$(CONFIG_BCM2835_VCHIQ_MMAL) += vchiq-mmal/
16+
obj-$(CONFIG_BCM_VC_SM_CMA) += vc-sm-cma/
1617

1718
ccflags-y += -Idrivers/staging/vc04_services -D__VCCOREVER__=0x04000000
1819

‎drivers/staging/vc04_services/bcm2835-camera/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-v4l2.o
77

88
ccflags-y += \
99
-I $(srctree)/$(src)/.. \
10-
-Idrivers/staging/vc04_services \
11-
-Idrivers/staging/vc04_services/vchiq-mmal \
10+
-I$(srctree)/drivers/staging/vc04_services \
11+
-I$(srctree)/drivers/staging/vc04_services/vchiq-mmal \
1212
-D__VCCOREVER__=0x04000000
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
config BCM_VC_SM_CMA
2+
tristate "VideoCore Shared Memory (CMA) driver"
3+
depends on BCM2835_VCHIQ
4+
select RBTREE
5+
select DMA_SHARED_BUFFER
6+
help
7+
Say Y here to enable the shared memory interface that
8+
supports sharing dmabufs with VideoCore.
9+
This operates over the VCHIQ interface to a service
10+
running on VideoCore.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ccflags-y += -I$(srctree)/drivers/staging/vc04_services -I$(srctree)/drivers/staging/vc04_services/interface/vchi -I$(srctree)/drivers/staging/vc04_services/interface/vchiq_arm
2+
# -I"drivers/staging/android/ion/" -I"$(srctree)/fs/"
3+
ccflags-y += -D__VCCOREVER__=0
4+
5+
vc-sm-cma-$(CONFIG_BCM_VC_SM_CMA) := \
6+
vc_sm.o vc_sm_cma_vchi.o
7+
8+
obj-$(CONFIG_BCM_VC_SM_CMA) += vc-sm-cma.o
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No currently outstanding tasks except some clean-up.

0 commit comments

Comments
 (0)