Hello everybody,

I am working with a pciE FPGA card and i am trying to write to memory
mapped memory as fast as possible. If I generate a sequence of
successive write commands, nothing gets written.

I was not sure if there is a problem with the fpga pcie IP core, so I
decided to buy a LPT port pcie card (based on AX99100 chip) and test it. I
tried the same test again and the result is the same - nothing gets
written. The registers seem to have just one byte writable, but I think
this is not crucial here.

Does anybody have an idea how I should write an array of data to a pcie
card as fast as possible? I did try to add a delay in between and that
helped, but this added a lot of delay and I am not sure how close to the
limitation is that.

Please find my code and the result (on LPT port card) below.
Regards
Klemen

code snippet
---------------
  pci_device.ptr_bar0 = rtapi_pci_ioremap_bar(dev, 0);
  rtapi_print_msg(RTAPI_MSG_INFO, "lptPortdriver: bar 0 mapped to %p\n",
pci_device.ptr_bar0);

  pci_device.ptr_bar2 = rtapi_pci_ioremap_bar(dev, 2);
  rtapi_print_msg(RTAPI_MSG_INFO, "pciLedTest_wb: bar 2 mapped to %p\n",
pci_device.ptr_bar2);
  rtapi_print_msg(RTAPI_MSG_INFO, "\n\n");



  rtapi_print("max_delay_avaliable = %ld ns\n", rtapi_delay_max());

  rtapi_print_msg(RTAPI_MSG_INFO, "lptPortdriver - test1: write to led
register\n");
  t1 = rtapi_get_time(); // returns time in ns
  *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0000) = 0x11111111; nanosleep
(&ts_dtLong, NULL);
  *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0004) = 0x22222222;
  t2 = rtapi_get_time(); // returns time in ns
  rtapi_print_msg(RTAPI_MSG_INFO, "lptPortDriver read32: offset 0x0000:
%08x.\n", *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0000) );
  rtapi_print_msg(RTAPI_MSG_INFO, "lptPortDriver read32: offset 0x0004:
%08x.\n", *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0004) );


  rtapi_print_msg(RTAPI_MSG_INFO, "lptPortdriver - test2: write to led
register\n");
  t3 = rtapi_get_time(); // returns time in ns
  *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0000) = 0x33333333; rtapi_delay(1);
  *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0004) = 0x44444444;
  t4 = rtapi_get_time(); // returns time in ns
  rtapi_print_msg(RTAPI_MSG_INFO, "lptPortDriver read32: offset 0x0000:
%08x.\n", *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0000) );
  rtapi_print_msg(RTAPI_MSG_INFO, "lptPortDriver read32: offset 0x0004:
%08x.\n", *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0004) );


  rtapi_print_msg(RTAPI_MSG_INFO, "lptPortdriver - test3: write to led
register\n");
  t5 = rtapi_get_time(); // returns time in ns
  *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0000) = 0x55555555;
  *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0004) = 0x66666666;
  t6 = rtapi_get_time(); // returns time in ns
  rtapi_print_msg(RTAPI_MSG_INFO, "lptPortDriver read32: offset 0x0000:
%08x.\n", *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0000) );
  rtapi_print_msg(RTAPI_MSG_INFO, "lptPortDriver read32: offset 0x0004:
%08x.\n", *(rtapi_u32*)(pci_device.ptr_bar2 + 0x0004) );


  tdiff1 = t2 - t1;
  tdiff2 = t4 - t3;
  tdiff3 = t6 - t5;
  rtapi_print("nanosleep  Tdiff1 = %ld ns\n", tdiff1);
  rtapi_print("rtapidelay Tdiff2 = %ld ns\n", tdiff2);
  rtapi_print("rtapidelay Tdiff3 = %ld ns\n", tdiff3);


output
---------------
RTAPI_PCI: Map BAR 0
Failed to remap MMIO 0 of PCI device 0000:05:00.2: No such device
lptPortdriver: bar 0 mapped to (nil)
RTAPI_PCI: Map BAR 2
pciLedTest_wb: bar 2 mapped to 0x7f2d4b2bd000
max_delay_avaliable = 10000 ns
lptPortdriver - test1: write to led register
lptPortDriver read32: offset 0x0000: 00000011.
lptPortDriver read32: offset 0x0004: 00000022.
lptPortdriver - test2: write to led register
lptPortDriver read32: offset 0x0000: 00000033.
lptPortDriver read32: offset 0x0004: 00000044.
lptPortdriver - test3: write to led register
lptPortDriver read32: offset 0x0000: 00000033.
lptPortDriver read32: offset 0x0004: 00000044.
nanosleep  Tdiff1 = 100054728 ns
rtapidelay Tdiff2 = 55561 ns
rtapidelay Tdiff3 = 38 ns

_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to