For the Jetson TX1 I try to allocate DMA memory for a PCIe Network card and map into user space.
My procedure is working on x86/amd64 and even on L4T 24.1 (Kernel 3.10.96) but not on the latest L4T 28.2 (Kernel 4.4.38).
In my mmap function everything seems to work:
pVa = dma_alloc_coherent(&pDevDesc->pPcidev->dev, len, &dmaAddr, GFP_KERNEL); memset(pVa, 0, len); vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); remap_pfn_range(vma, vma->vm_start, dmaAddr >> PAGE_SHIFT, len, vma->vm_page_prot) *((u32 *) pVa) = (u32) dmaAddr; PRINTK("mmap: mapped DMA memory, Phys:0x%p KVirt:0x%p UVirt:0x%p Size:0x%x\n",(void *)(unsigned long)dmaAddr, (void *)pVa, (void *)vma->vm_start, len); // => mmap: mapped DMA memory, Phys:0x0000000080000000 KVirt:0xffffff800cf7d000 UVirt:0x0000007fb79a0000 Size:0x81000
In the application I get memory from the mmap-function but it is not the same as in the kernel object.
It’s not memset to zero and the physical address I wrote in first 4 Byte is missing.
When I continue and start using the memory, the Ubuntu freezes and on the screen appears a strange pattern.
Is this a Bug or is this caused by the SMMU?
Is there a way to handle this without customizing the Kernel?
Do you have any suggestion how I should proceed?