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.

CMEMK Error: Failed to request_mem_region

Expert 1920 points

When I try to load cmemk.ko module, it errors saying,

[ 365.654621] CMEMK module: built on Jun 11 2015 at 18:47:18
[ 365.660443] Reference Linux version 3.14.31
[ 365.666279] CMEMK Error: Failed to request_mem_region(0x99000000, 0x4000000)

I am not getting the Kernel memory overlap error and I have some memory reserved for dsp cma. This is from my dmesg output,

[ 0.000000] Reserved memory: created CMA memory pool at 0x0000000095800000, size 56 MiB
[ 0.000000] Reserved memory: initialized node ipu2_cma@95800000, compatible id shared-dma-pool
[ 0.000000] Reserved memory: created CMA memory pool at 0x0000000099000000, size 64 MiB
[ 0.000000] Reserved memory: initialized node dsp1_cma@99000000, compatible id shared-dma-pool
[ 0.000000] Reserved memory: created CMA memory pool at 0x000000009d000000, size 32 MiB
[ 0.000000] Reserved memory: initialized node ipu1_cma@9d000000, compatible id shared-dma-pool
[ 0.000000] Reserved memory: created CMA memory pool at 0x000000009f000000, size 8 MiB
[ 0.000000] Reserved memory: initialized node dsp2_cma@9f000000, compatible id shared-dma-pool
[ 0.000000] cma: CMA: reserved 64 MiB at ab800000
[ 0.000000] Memory policy: Data cache writealloc

------

------

[ 0.000000] Kernel command line: console=ttyO7,115200n8 elevator=noop bootconf=main bootdev=0:1 confdev=0:2 fixrtc omapdrm.num_crtc=2 consoleblank=0 drm.universal_planes=1 cma=64M

-------

-------

[ 0.285681] platform 40800000.dsp: assigned reserved memory node dsp1_cma@99000000
[ 0.298248] platform 41000000.dsp: assigned reserved memory node dsp2_cma@9f000000


Any ideas on what is going on? Am I missing something here?

 

Thanks!

 

 

  • Hi,
    What is your processor and SDK version ?
  • It is a dra7xx processor and I am using meta-ti repo recipes to build. cmem version is 4.10.00.01.
  • Girish Tummala said:
    [ 365.666279] CMEMK Error: Failed to request_mem_region(0x99000000, 0x4000000)

    Girish Tummala said:
    [ 0.000000] Reserved memory: created CMA memory pool at 0x0000000099000000, size 64 MiB
    [ 0.000000] Reserved memory: initialized node dsp1_cma@99000000, compatible id shared-dma-pool

    CMEM must be given memory that is completely unused by the kernel or any kernel component.  The CMA memory being reserved for the remote processors is exclusively for use by remoteproc, for the purpose of loading the remote core's code and data sections.

    The memory overlap check is not present in this version of CMEM.  It was broken as it was, and CMEM can rely on the kernel error as you're seeing above.

    Since you're using a 3.14 kernel and CMEM 4.10, you can reserve the memory in the device tree if you so desire.  You can also configure CMEM in the device tree, and have that configuration reference the reserved memory directly.  This is the easiest approach, and allows the cmemk.ko command line to be minimal (just 'modprobe cmemk' would do the trick, and it would find its configuration in the device tree).  Take a look at comments in <linuxutils>/include/ti/cmem.h, at the section starting with:
     * Block and pool specification using Device Tree (DT)
     * ---------------------------------------------------

    Regards,

    - Rob

  • Rob,
    I configured CMEM in device tree and now I am able to initialize CMEM and see all the allocated pools in /proc/cmem.
    Thanks for pointing me to cmem.h file.

    I have some more questions regarding how to make use of CMEM to send a buffer across from host to DSP.
    I am looking at the sample test file apitest.c to allocate a buffer on the host(ARM) side.
    This is what I am planning to do in my code on Linux side,
    -> allocate a buffer from the pool using CMEM_alloc2() function
    -> get the physical address of the buffer using CMEM_getPhys() fn
    -> send the physical address to DSP using MessageQ

    On the DSP side, I am not sure how the DSP can use the Physical address to read the buffer. Can DSP read the physical address directly? Or Do I need to make sure DSP RTOS has CMEM support as well, so that it can use some form of memory map features of CMEM?

    Thanks!
  • Girish Tummala said:
    This is what I am planning to do in my code on Linux side,
    -> allocate a buffer from the pool using CMEM_alloc2() function
    -> get the physical address of the buffer using CMEM_getPhys() fn
    -> send the physical address to DSP using MessageQ

    Those above steps are just fine.

    Girish Tummala said:
    On the DSP side, I am not sure how the DSP can use the Physical address to read the buffer. Can DSP read the physical address directly? Or Do I need to make sure DSP RTOS has CMEM support as well, so that it can use some form of memory map features of CMEM?

    The DSP development environment doesn't have any CMEM APIs or support.

    You should create a resource table DEVMEM entry that covers the physical block that you reserved for CMEM.  You can then call Resource_physToVirt(phys addr) to get the virtual address that you can use to access the buffer.  Here's an example entry:

        #define DSP_MEM_IOBUFS          0x80000000       // This is the virtual address, can be anywhere of your choosing
        #define PHYS_MEM_IOBUFS         0xBA300000       // This must match the base of the reserved physical block
        #define DSP_MEM_IOBUFS_SIZE     (SZ_1M * 90)     // This must match the size of the reserved physical block

        {
            TYPE_DEVMEM,
            DSP_MEM_IOBUFS, PHYS_MEM_IOBUFS,
            DSP_MEM_IOBUFS_SIZE, 0, 0, "DSP_MEM_IOBUFS",
        },

    The above entry is actually taken from the file <ipc>/packages/ti/ipc/remoteproc/rsc_table_vayu_dsp.h, which you might be using for your builds.  You should use this existing entry (and modify the #define values) so that you don't have to change other places in this file that need to be changed when you add an *additional* entry (such as number-of-entries and structure offsets, etc.).

    Here's a wiki page that shows how to use a custom resource table: http://processors.wiki.ti.com/index.php/IPC_Resource_customTable

    Then, in your application code:

        Int ret;
        UInt32 pa;
        UInt32 va;
        UInt32 *data_from_host;


             `retrieve pa from MessageQ msg`;

        ret = Resource_physToVirt(pa, &va);
        if (ret == Resource_S_SUCCESS) {
            data_from_host = va;    // you can map any data type here, I've chosen an array of UInt32, but could be a struct *
            x = data_from_host[0];
            y = data_from_host[1];
            ...
        }

    Regards,

    - Rob

     

  • Rob,
    Could you let me know how is CMEM module is different from the existing dsp1_cma_pool and dsp2_cma_pool?
    Does CMEM module have any special features?

    -Girish
  • Girish,

    Girish Tummala said:
    Could you let me know how is CMEM module is different from the existing dsp1_cma_pool and dsp2_cma_pool?

    CMEM has nothing to do with those remoteproc-owned CMA regions.  They are exclusively for remoteproc code/data loading.

    Girish Tummala said:
    Does CMEM module have any special features?

    Can you be more specific with your question about CMEM features?  CMEM is a contiguous memory allocator with a user-level API for accessing it, and associated features for handling this memory.  It has nothing to do with remoteproc, other than they both can allocate from CMA memory (but deal with completely separate memory blocks).

    Regards,

    - Rob