cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
christine1225
Adventurer
Adventurer
2,179 Views
Registered: ‎07-10-2015

IS pcie linux linux driver xdma-core.c kernel function read and write block?

The driver is so completed and big!!

I modify the dma_to_device.c

 

X8 lane

stream fifo 250MHz 256bit ------>stream convert width 100MHz 64bit

 

1000 times transfer , each 1920*1080*3 bytes, it spends 0.4s!!!!

 

so I think there's something odd happened!

 

0 Kudos
1 Reply
ubenevides
Adventurer
Adventurer
1,825 Views
Registered: ‎09-22-2016

 

@christine1225

 

I diff'ed your code against the original dma_to_device.c 

 

1. you are allocating size*count when you are just using "size". 

 

rc = write(fpga_fd, buffer, size);

 

It would make sense if you did something like this

 

rc = write( fpga_fd, &buffer[size*i], size );

 

But as i is unbounded this would eventually blow in your code 

 

2. Why are you doing usleep(5)?

 

3. you increment "i" in between taking clocks but what will happen is that you will start the clock when say i=1000 but then you will increment i - will become say 1001 and the next clock_gettime() will only execute when i=1999. This is a  bug in your code.

 

Try this instead:

 

while(1)  {
    rc = clock_gettime(CLOCK_MONOTONIC, &ts_start);
    rc = write(fpga_fd, &buffer[i*size], size);

    assert(rc == size);

    rc = clock_gettime(CLOCK_MONOTONIC, &ts_end);

 

    i+=1;

    if(i == 1000)  {
        timespec_sub(&ts_end, &ts_start);
        /* display passed time, a bit less accurate but side-effects are accounted for */
        printf("i=%d CLOCK_MONOTONIC %ld.%09ld seconds for 100transfer \n",i, ts_end.tv_sec, ts_end.tv_nsec);

        i = 0;
    }