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.

CMEM stub not compiling

I just downloaded the most recent LinuxUtils (4.00.02.11) from TIs website. I opened up the src directory and started following the directions from the README within it. It says that I need to add a stub into the linux kernel tree. I added the .c files and added the obj-y += cmem/ to the kmake tree. I also added the includes file to include/linux. Then it says I need to add a reserve function to the MACHINE_START struct. I added that to the struct like so:

DT_MACHINE_START(KEYSTONE2, "KeyStone2")
    KEYSTONE_MACHINE_DEFS
    .smp        = smp_ops(keystone_smp_ops),
    .handle_irq    = gic_handle_irq,
    .dt_compat    = keystone2_match,
    .timer        = &keystone2_timer,
    .reserve    = cmem_reserve_cma,
#ifdef CONFIG_ZONE_DMA
    .dma_zone_size    = SZ_2G,
#endif
MACHINE_END

As you can see I am using a Keystone II and am using the 3.8.4 src code from the git repo and compiling it with keystone2_defconfig configuration.

I assume I also needed to add the header file to the keystone.c file with the MACHINE_START struct. The problem is that the .h file does not define a function called cmem_reserve_cma, causing the kernel not to compile. Is this just poor documentation updating due to edits in the CMEM module, or am I just missing something?

  • Bill said:
    It says that I need to add a stub into the linux kernel tree.

    FYI, you need the stub *only* if you want to use CMEM-specific CMA pools for allocation.  The "standard" CMEM usage is without the stub.

    Without the stub you can do normal CMEM pool and heap allocations from the carveout (specified with phys_start/phys_end on cmemk.ko insmod/modprobe command line), as well as allocations from the global CMA pool (by specifiying CMEM_CMABLOCKID as the 'block' parameter).

    Bill said:
    The problem is that the .h file does not define a function called cmem_reserve_cma, causing the kernel not to compile. Is this just poor documentation updating due to edits in the CMEM module, or am I just missing something?

    Yup, this step is missing in the docs and the header file is missing the declaration.  You can simply add your own declaration in the file in which you use cmem_reserve_cma (in keystone.c):
        extern void cmem_reserve_cma(void);

    Regards,

    - Rob