Share DMA buffers between processes

We are attempting to share DMA buffers between two separate processes, but can’t quite get it to work.

In the first process, we are creating a DMA buffer using NvBufferCreateEx(). Once the buffer has been created and filled with our data, we pass the file descriptor returned from NvBufferCreateEx() over to another process.

In the second process, we attempt to call NvBufferTransform() (with the file descriptor received from the first process as the src) to transform the buffer into different DMA buffer, but we get the following error:

nvbuf_utils: dmabuf_fd 102 mapped entry NOT found
nvbuf_utils: Can not get HW buffer from FD... Exiting...
NvBufferGetParams failed for src_dmabuf_fd
nvbuffer_transform Failed

So it seems NvBufferTransform() cannot find the DMA buffer for some reason.

Interestingly, if we don’t try to use NvBufferTransform() at all, and instead just use mmap on the file descriptor, we can access our data, so we know that the file descriptor passed to the second process is valid. But ultimately we want the data to remain in a DMA buffer, so we don’t really want to use mmap to access the data, which is why we want to use NvBufferTransform().

Are there anything wrong with this approach? Or are there any suggestions/examples/documentation on how to share DMA buffers between processes? Or anything else that could be going wrong here?

Hi,
We don’t support this case. The buffers can only be accessed in single process. If you need the data in another process, you would need to create another NvBuffer and copy the data.

Hi @DaneLLL, thanks for the response. Is this something that is planned for the future at all?

And what would you suggest as the best way to copy data between 2 processes? We are trying to avoid copying the data into CPU memory if possible.

Thanks for your input.

Hi,
We would suggest use EGLStream producer/consumer. Please check
Problems getting EGL Stream transferred to another process on same machine - #7 by DaneLLL