This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

The mmap function have some problem in DM816X

Expert 2990 points

Hi

I find a problem about mmap function in ti816x board.

I writen a char driver. In order to improve  the performance

I use the mmap function and this is the realization.

int pci_ep_mmap(struct file *file,struct vm_area_struct *vma)
{
    unsigned int mem_start;
    unsigned int mem_length;
    
    int ret = -EAGAIN;
    mem_length = vma->vm_end - vma->vm_start;
    mem_start = (u32)vma->vm_pgoff << PAGE_SHIFT;
    
    printk(KERN_INFO "Mapping %02x bytes from address %02x\n",

    mem_length,mem_start);
    vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
    vma->vm_flags    |= VM_RESERVED | VM_IO;
    ret = io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
                        vma->vm_end - vma->vm_start,
                        vma->vm_page_prot);
    return ret;
}
I used the kzalloc() to allocate the memory which would be mapped to the

userspace. In the userspace,The application use the memset() function

or memcpy() function to operate the return value of mmap.

To my disapporintment,It is too to slowly to believe it.

The speed of reading(I use the memcpy)

and writting(memset) the mapped memory is about 40MB/s.

So I changed to DM6467T and it's the same code with ti816x.

However ,This times the speed can  get to 350MB/s.

And then I inplemented the same testing in x86 pc 

and the performance is the best,which can get to 1.5GByte.

So I'm very surprised to this phenomenon.

As far as I know, The DM8168 is much better than DM6467T.

Who can help me to solve this problem.

My DM816x's PSP version is 04.04.00.01.
 

Quan

  • Try removing the pgprot_noncached line of your code and I bet your speeds will rocket.

    Also, you will never get 350MB/s using memcpy for "large" amounts of memory (assuming the memory you are copying to PCIe is no already in cache). Your DM6467T must be using EDMA to achieve that.

    Ralph

  • The speeds can rocket after removing the pgprot_noncached line.

    But It would lead to data inconsistencies,when using edma to handle data;

    And the speed of read is only 300MB,however the write of speed can get to 1.5GB/s

    In DM6467T ,I am sure the copying speed is 350MB,and have the  pgprot_noncached

    line ,and no EDMA.  please see the below code.

    Code

    buffer = (char *)mmap(0,0x400000,
                              PROT_READ | PROT_WRITE,
                              MAP_SHARED,fd,0x8c000000);
        if( MAP_FAILED == buffer )
            err_print("mmap");
       

    count = 1024;
        while( count--) {
            memset(tbuffer,91,0x400000);
            //printf("count =%d\n",count);
        }
        munmap(buffer,0x400000);