Jetpack 3.3: dma_alloc_coherent with SMMU enabled


What is the right way to allocate a buffer that will be used for DMA from PCI device ?
I tried the following code:

dma_addr_t dma_handle;
int size=8192;
void *pVirt;
pVirt = dma_alloc_coherent (&, size, &dma_handle, GFP_KERNEL);

and got: pVirt = NULL.

This code runs upon ioctl request from user space.
Should I set the value of “dev” ? How ?
Can I use the above code without disabling SMMU in device tree ?

Thank you,

When the API that is registered for the probe gets called by the device driver sub-system, 'struct pci_dev *pdev) is passed to that API and ‘&pdev->dev’ can be passed to dma_alloc_coherent() API
You can this code for both with-SMMU and without-SMMU cases
FWIW, pVirt being NULL is not expected. It looks like there is some issue with the dev pointer you are passing to dma_alloc_coherent() API in your code. Please correct that.

Hi vidyas,

Thank you very much.

Best regards,