How to use memory allocated by dma_alloc_coherent() in cuda

I am developing a pcie driver in Jetson Tx2.
I want to use DMA memory allocated by dma_alloc_coherent() in cuda.

https://forums.developer.nvidia.com/t/how-to-access-dma-alloc-coherent-memory-from-cuda/79377

https://forums.developer.nvidia.com/t/can-memory-allocated-by-dma-alloc-coherent-be-accessed-by-cuda-gpu-on-tx1/74332

I checked these two posts, but couldn’t find the answer.

Is there a way to directly use DMA memory allocated by dma_alloc_coherent() without using cudaMemcpy in CUDA?

Hi,

There is a nvidia_p2p_get_pages API but it is only available for Xavier device:
https://docs.nvidia.com/cuda/gpudirect-rdma/index.html#porting-to-jetson

Thanks.

I do not have jetson xavier.
Is there any possible way in jetson tx2?

Hi,

Sorry that this function is only available for Xavier device.

Thanks.

Hi AastaLLL, please can you help me

I have a Xavier AGX (with C5 configured in PCIe EndPoint mode) connected to an x86 host (Root-Complex). How can I use

int nvidia_p2p_get_pages(u64 virtual_address, u64 length, struct nvidia_p2p_page_table **page_table, void (*free_callback)(void *data), void *data);

on the Xavier in order to access (in my CUDA kernel) the virtual address returned by "dma_alloc_coherent() "? The first parameter of “nvidia_p2p_get_pages” can be the pointer returned by "dma_alloc_coherent() "?

Note: I use dma_alloc_coherent() in the “pci_epf_nv_test” driver to allocate 512M

Thanks

Hi RokiaDiarr,

Please help to open a new topic for your issue. Thanks