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.

Custom PCI Express device and it's driver

Hi, All!

1) I have a custom board based on DM816x.

2) On board I have 512MB DDR3 connected to EMIF1 and FPGA device connected to the processor via PCI Express bus.

3) I wrote driver for FPGA device (porting it from my x86 version). In driver I get memory buffers with dma_alloc_coherent(...) function, and I can allocate only less or equal 4MB of DMA memory, but I need much more memory.

Please tell me:

- How I can increase amount of DMA memory? (change PCI memory map or something else, I can not use allocation at boot time)

- How I can share allocated (dma_alloc_coherent or __get_free_pages) DMA memory between ARM and DSP processors? (May be this is impossible)

- Maybe there are ready solutions of the problem?

Thank you for all.

  • You might look at CMEM in the Linux Utils product.

    This is included in EZSDK releases, in case you have one of those handy.  But it's also available independently.

    Chris

  • Hi, Chris!

    Thank you for your reply. I read some documentation (and looked into the code, but not deep) and I can't find some information:

    1) How cmemk.ko communicate with DSP processor? How DSP get information about physical addresses of my buffers?

    2) How I must use cmemk.ko with my driver. cmemk.ko suppose standalone using, or may be I can add several function from cmemk.ko code into my driver? (I need service interrupt from my device, and need own PCI driver)

    3) Or I must use cmemk.ko only for memory allocation, and after getting buffers I need programmed my device to perform DMA transfer with addresses returned from cmemk.ko? (Don't allocate any memory in my driver)

    Thank you.

    P.S. Sorry for my English.

  • idle said:
    1) How cmemk.ko communicate with DSP processor? How DSP get information about physical addresses of my buffers?

    CMEM is independent of the DSP - it runs completely on the Linux OS.  However it's commonly used to allocate physically contiguous buffers (which the DSP needs).  Apps simply pass a pointer to that memory to the DSP - typically with something like SysLink's MessageQ, but you can use whatever mechanism to pass that pointer you want.

    Note that in user mode, CMEM returns virtual pointers so the app can directly access that memory.  When passing a pointer to the DSP, you can use the CMEM_getPhys() API to get the physical address which the DSP can use.

    idle said:
    2) How I must use cmemk.ko with my driver. cmemk.ko suppose standalone using, or may be I can add several function from cmemk.ko code into my driver? (I need service interrupt from my device, and need own PCI driver)

    CMEM is typically used by user-mode apps, but if you want to directly call the kernel APIs from your kernel driver, you can.  I'm not sure of the logistics of setting that up, but I'm guessing it probably involves exporting the necessary symbols from the CMEM driver and ensuring the CMEM driver is loaded before your driver(?).

    idle said:
    3) Or I must use cmemk.ko only for memory allocation, and after getting buffers I need programmed my device to perform DMA transfer with addresses returned from cmemk.ko? (Don't allocate any memory in my driver)

    This is the common use case.  An application acquires memory from CMEM (typically in user mode) and gives that memory to 1) drivers that need it, like your PCI driver, and/or 2) other cores that need it, like the DSP.

    Chris

  • Hi, Chris!

    Thank you for your detailed answer. This is useful information for me.