staging: vc04_services: Add new vc-sm-cma driver
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Thu, 8 Oct 2020 17:49:52 +0000 (18:49 +0100)
committerDom Cobley <popcornmix@gmail.com>
Mon, 19 Feb 2024 11:33:05 +0000 (11:33 +0000)
commit0aa848ba15450c51dad4aab9380536ef1a6ba603
tree72213aa5692a2d514d72b2e87be726cba8939e44
parent2d7f81e4f77ea08ab1093df7b85a0e465e03fcd0
staging: vc04_services: Add new vc-sm-cma driver

Add Broadcom VideoCore Shared Memory support.

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.com>
staging: vcsm-cma: Fix memory leak from not detaching dmabuf

When importing there was a missing call to detach the buffer,
so each import leaked the sg table entry.

Actually the release process for both locally allocated and
imported buffers is identical, so fix them to both use the same
function.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
staging/vc-sm-cma: Avoid log spamming on Pi0/1 over cache alias.

Pi 0/1 use the 0x80000000 cache alias as the ARM also sees the world
through the VPU L2 cache.
vc-sm-cma was trying to ensure it was in an uncached alias (0xc), and
complaining on every allocation if it weren't. Reduce this logging.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
vc-sm-cma: Restore correct cache maintainance operations

We have been using the more expensive flush operations rather than
invalidate and clean since kernel rpi-5.9.y

These are exposed with:
52f1453513ba95084ab811a030032fe605b0cbe2 Re-expose some dmi APIs for use in VCSM

But I believe that commit was dropped when (non-cma) vc-sm was dropped,
and didn't get updated when the commit was restored

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
staging: vc04_services: Fix clang14 warning

Insert a break to fix a fallthrough warning from clang14. Since the
fallthrough was to another break, this is a cosmetic change.

See: https://github.com/raspberrypi/linux/issues/5078

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
vc04_services/vc-sm-cma: Handle upstream require vchiq_instance to be passed around

vc04_services/vc-sm-cma: Switch one-bit bitfields to bool

Clang 16 warns:

../drivers/staging/vc04_services/vc-sm-cma/vc_sm.c:816:19: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
        buffer->imported = 1;
                         ^ ~
../drivers/staging/vc04_services/vc-sm-cma/vc_sm.c:822:17: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
        buffer->in_use = 1;
                       ^ ~
2 warnings generated.

Signed-off-by: Alexander Winkowski <dereference23@outlook.com>
vc04_services: vcsm-cma: Detach from the correct dmabuf

Commit d3292daee319 ("dma-buf: Make locking consistent in dma_buf_detach()")
added checking that the same dmabuf for which dma_buf_attach
was called is passed into dma_buf_detach, which flagged up
that vcsm-cma was passing in the wrong dmabuf.

Correct this so that we don't get the WARN on every dma_buf
release.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
12 files changed:
drivers/staging/vc04_services/Kconfig
drivers/staging/vc04_services/Makefile
drivers/staging/vc04_services/include/linux/broadcom/vc_sm_cma_ioctl.h [new file with mode: 0644]
drivers/staging/vc04_services/vc-sm-cma/Kconfig [new file with mode: 0644]
drivers/staging/vc04_services/vc-sm-cma/Makefile [new file with mode: 0644]
drivers/staging/vc04_services/vc-sm-cma/TODO [new file with mode: 0644]
drivers/staging/vc04_services/vc-sm-cma/vc_sm.c [new file with mode: 0644]
drivers/staging/vc04_services/vc-sm-cma/vc_sm.h [new file with mode: 0644]
drivers/staging/vc04_services/vc-sm-cma/vc_sm_cma_vchi.c [new file with mode: 0644]
drivers/staging/vc04_services/vc-sm-cma/vc_sm_cma_vchi.h [new file with mode: 0644]
drivers/staging/vc04_services/vc-sm-cma/vc_sm_defs.h [new file with mode: 0644]
drivers/staging/vc04_services/vc-sm-cma/vc_sm_knl.h [new file with mode: 0644]