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

HI, I want to set the CMEMK with this settings,

cmemk.ko phys_start=0x84c00000 phys_end=0x88000000 pools=8x4667200

but is already running and I can't stop it

# lsmod                                                                        
dm365mmap 1712 0 - Live 0xbf01b000                                             
edmak 12273 2 - Live 0xbf013000                                                
irqk 6014 2 - Live 0xbf00c000                                                  
cmemk 20486 2 - Live 0xbf000000                                                
# rmmod cmemk                                                                  
rmmod: remove 'cmemk': Resource temporarily unavailable

 

what can I do?

  • Does some application have /dev/cmem open when you try to rmmod cmemk?

    I have never seen this error, so my question is just a guess.

    Regards,

    - Rob

  • How can I find out what application is using cmem also what would be the correct way to put those settings on the  loadmodule-rc

    this the settings I want to use:

    cmemk.ko phys_start=0x84c00000 phys_end=0x88000000 pools=8x46672

    and this is from loadmodule-rc

    load () {
        modprobe cmemk phys_start=0x83C00000 phys_end=0x88000000 allowOverlap=1 phys_start_1=0x00001000 phys_end_1=0x00008000 pools_1=1x28672 useHeapIfPoolUnavailable=1

     

    because I just replaced the numbers and I get this error

    CMEMK Error: Failed to find a pool which fits 3133440

     Thanks,

     

     

     

  • Andre16038 said:
    How can I find out what application is using cmem

    I'm not sure how to find out what application has /dev/cmem open.  Perhaps there is some Linux tool that would list processes that have particular /dev device drivers open?

    There is the /proc/cmem file that prints out the status of all CMEMK buffers, such as free and busy blocks.  Could you try:
        % cat /proc/cmem
    and see if there are busy buffers?

    If there are busy buffers, that's a clue that some process has /dev/cmem open, but it won't tell you which one.

    Andre16038 said:

    this the settings I want to use:

    cmemk.ko phys_start=0x84c00000 phys_end=0x88000000 pools=8x46672

    and this is from loadmodule-rc

    load () {
        modprobe cmemk phys_start=0x83C00000 phys_end=0x88000000 allowOverlap=1 phys_start_1=0x00001000 phys_end_1=0x00008000 pools_1=1x28672 useHeapIfPoolUnavailable=1

    Is something preventing you from modifying loadmodule-rc directly?  That would seem the right thing to do to modify your settings.

    Regards,

    - Rob

     

  • Thanks Rob yes there is free buffer

    # cat /proc/cmem                                                               
                                                                                   
    Block 1: Pool 0: 1 bufs size 28672 (28672 requested)                           
                                                                                   
    Pool 0 busy bufs:                                                              
    id 0: phys addr 0x1000 (noncached)                                             
                                                                                   
    Pool -1053794753 free bufs: 

    but when I change the loadmodule-rc to this

    load () {
        modprobe cmemk phys_start=0x84c00000 phys_end=0x88000000 pools=8x46672 allowOverlap=1 phys_start_1=0x00001000 phys_end_1=0x00008000 pools_1=1x28672 useHeapIfPoolUnavailable=1

    I get this error

    CMEMK Error: Failed to find a pool which fits 3133440

     

    Regards,

    Andre


  • Andre16038 said:
    # cat /proc/cmem                                                               
                                                                                   
    Block 1: Pool 0: 1 bufs size 28672 (28672 requested)                           
                                                                                   
    Pool 0 busy bufs:                                                              
    id 0: phys addr 0x1000 (noncached)

    Some application is currently running that is holding the CMEM buffer @ 0x1000.  Probably something started up automatically during boot.

    Andre16038 said:

    but when I change the loadmodule-rc to this

    load () {
        modprobe cmemk phys_start=0x84c00000 phys_end=0x88000000 pools=8x46672 allowOverlap=1 phys_start_1=0x00001000 phys_end_1=0x00008000 pools_1=1x28672 useHeapIfPoolUnavailable=1

    I get this error

    CMEMK Error: Failed to find a pool which fits 3133440

    This basically indicates that your system's CMEM buffer needs can't be satisfied when you reduce the CMEM memory block by 0x01000000.  If you can't somehow reduce the demands of the application, there's not a whole lot that can be done - the apps need that much CMEM memory.

    Regards,

    - Rob

     

  • Sorry still confuse about this how the loadmodule-rc should be so I can load this program:

     

    root@dm368-evm:/usr/share/ti/linux-driver-examples/imp-prev-rsz# ./capture_prev_
    rsz_onthe_fly_bayer_mew -i1 -m4 -h60                                           
    input_std_params: name = V4L2_STCMEMK Error: ALLOC: invalid pool (-2) passed.  
    D_720P_30                                                                      
    input_std_params: output size = 1280 * 720                                     
    calling cmem utilities for allocating frame buffers                            
    Allocating capture buffers :buf size = 4149248                                 
    CMEM Error: allocPool: ioctl CMEM_IOCALLOC failed from pool -2: -1             
    Failed to allocate cmem buffer                                                 
    Unable to Allocate user buffers                                                
    root@dm368-evm:/usr/share/ti/linux-driver-examples/imp-prev-rsz#

     

    this is the DVSDK 4 the only change I did is this :

    load () {
        modprobe cmemk phys_start=0x84c00000 phys_end=0x88000000 pools=8x46672 allowOverlap=1 phys_start_1=0x00001000 phys_end_1=0x00008000 pools_1=1x28672 useHeapIfPoolUnavailable=1

     

    the capture_prev_rsz_onthe_fly_bayer_mew program only works, if I dont make changes on the loadmodule-rc and I run this lines

    rmmod cmemk.ko

    insmod cmemk.ko phys_start=0x84c00000 phys_end=0x88000000 pools=8x46672

    How can I set the loadmodule-rc to work with out having to remove and load the cmemk manually?

     

  • Andre16038 said:
    CMEMK Error: ALLOC: invalid pool (-2) passed. 

    This error is coming from the CMEM kernel module.  The only way I can forsee this error being generated is if someone is:
        - calling poolid=CMEM_getPool() (or CMEM_getPool2()) followed by CMEM_allocPool(poolid) without checking if pool < 0, and
        - insmod'ing cmemk.ko with useHeapIfPoolUnavailable=1

    cmemk.ko will return a poolid of -2 to indicate that there is no pool-based buffer available to satisfy the requested size *BUT* there is sufficient room in the CMEM heap for the requested size *AND* the system has been instructed to allow this heap-fallback by setting useHeapIfPoolUnavailable=1.  If there is no useHeapIfPoolUnavailable=1 and no sufficiently-sized pool buffer available, cmemk.ko will return -1 for the poolid.

    Perhaps the code calling CMEM_getPool() is checking only for poolid==-1 for failure.  It should be checking poolid < 0 and not call CMEM_allocPool() if so.

    Andre16038 said:
    How can I set the loadmodule-rc to work with out having to remove and load the cmemk manually?

    The loadmodule-rc file contains the cmemk.ko configuration that conforms to the needs of the SDK.  But since it's your system, you can configure cmemk.ko according to your needs.  I'm not sure what you're asking here, but modprobe is just a different way than insmod to dynamically insert kernel modules.  Change loadmodules-rc to use the same params as your manually-invoked insmod, except using modprobe instead.

    You need to be careful, however.  The phys_start_1/phys_end_1/pools_1 config is there for a reason - some codecs need this block of on-chip memory configured into blockid 1 of cmemk.ko.  And the useHeapIfPoolUnavailable=1 is probably needed since you're configuring only 8 buffers of size 46672 out of a memory block of size 54 MB or so, which means that there is a big fat heap to satisfy most allocations and this heap should be used when pool-based allocations have used up all the 8 pool-based buffers.  useHeapIfPoolUnavailable=1 allows pool-based allocations to fallback to a heap-based allocation.

    You say that the app works when you don't configure useHeapIfPoolUnavailable=1, but I suspect that not having that just prevents the poolid=-2 error and you will quickly run out of pool buffers, or won't have any pool buffers for the big allocations.

    Regards,

    - Rob

  • Robert Tivy said:

    This error is coming from the CMEM kernel module.  The only way I can forsee this error being generated is if someone is:
        - calling poolid=CMEM_getPool() (or CMEM_getPool2()) followed by CMEM_allocPool(poolid) without checking if pool < 0, and
        - insmod'ing cmemk.ko with useHeapIfPoolUnavailable=1

    I need to amend the above statement with one additional point...

    This error might also happen because you have a mismatch between your cmemk.ko kernel module and your cmem.av5T user library.  You need to use the two components from the very same Linux Utils release.  Please check that.  If this is the case, your cmemk.ko would be from a version newer than your cmem.av5T user library.

    Regards,

    - Rob

  • Thanks Rob but my question is how, (what configuration) I can put in the loadmodule-rc so I dont have to type it like this(just the CMEMK part, because everything that I have done didn't work so I though I'm doing something wrong),

    dm368-evm login: root                                                          
    root@dm368-evm:~# cd /lib/modules/2.6.32.17-davinci1/kernel/drivers/dsp/
    root@dm368-evm:/lib/modules/2.6.32.17-davinci1/kernel/drivers/dsp# rmmod cmemk.k
    o                                                                              
    cmemk unregistered                                                             
    root@dm368-evm:/lib/modules/2.6.32.17-davinci1/kernel/drivers/dsp# insmod cmemk.
    ko phys_start=0x84c00000 phys_end=0x88000000 pools=8x4667200                   
    CMEMK module: built on Mar 24 2011 at 16:58:03                                 
      Reference Linux version 2.6.32                                               
      File /sdk/build/DVSDK_4_02/4_02_00_06/arago-install/arago-tmp/work/dm368-evm-c
    allocated heap buffer 0xc8000000 of size 0x1060000                             
    cmemk initialized                                                              
    root@dm368-evm:/lib/modules/2.6.32.17-davinci1/kernel/drivers/dsp# cd /usr/share
    /ti/linux-driver-examples/imp-prev-rsz/                                        
    root@dm368-evm:/usr/share/ti/linux-driver-examples/imp-prev-rsz# ./capture_prev_
    rsz_onthe_fly_bayer_mew -i1 -m4 -h60                                           
    input_std_params: name = V4L2_STD_720P_30                                      
    input_std_params: outdavinci_resizer davinci_resizer.2: RSZ_G_CONFIG:0:1:124   
    put size = 1280 * 720                                                          
    calling cmem utilities fodavinci_previewer davinci_previewer.2: ipipe_set_previg
    r allocating frame buffers                                                     
    Allodavinci_previewer davinci_previewer.2: ipipe_set_preview_config            
    cating capture buffers :buf size = 4149248                                     
    Got 0x405d8000 from CMEM, phy = 0x87718000                                     
    Got 0x40a4c000 from CMEM, phy = 0x872a4000                                     
    Got 0x40ec0000 from CMEM, phy = 0x86e30000                                     
    Got 0x41334000 from CMEM, phy = 0x869bc000                                     
    opening resize device                                                          
    Successfully set mode to single shot in resizer

     

     

     

  • Earlier you said this is the code in loadmodules-rc:
        modprobe cmemk phys_start=0x83C00000 phys_end=0x88000000 allowOverlap=1 phys_start_1=0x00001000 phys_end_1=0x00008000 pools_1=1x28672 useHeapIfPoolUnavailable=1

    And now you want to use this CMEM configuration:

    Andre16038 said:
    insmod cmemk.ko phys_start=0x84c00000 phys_end=0x88000000 pools=8x4667200 

    Just replace the "modprobe ..." parameters with your insmod parameters, so loadmodules-rc ends up with this line:
        modprobe cmemk.ko phys_start=0x84c00000 phys_end=0x88000000 pools=8x4667200 

    modprobe is similar to insmod, but more capable.  insmod needs an explicit specification of the .ko file location, whereas modprobe can "find" the correct one if it's been properly placed in the /lib/modules/... directory tree.  In your (or, the SDK's) case, looks like you have cmemk.ko in
        /lib/modules/2.6.32.17-davinci1/kernel/drivers/dsp

    Is there an SDK forum where you could ask about this issue?  I don't know SDKs (or DVSDKs or EZSDKs) but I know CMEM.

    Regards,

    - Rob

     

  • Rob I though the CMEMK configurations would be as easy as you said, just replacing the lines, but even after I did that , it did not work, thats why I though I did the configurations of the CMEMK wrong, this is the original loadmodule-rc, with this configurations I can run rmmod and insmod CMEMK,

    load () {
        modprobe cmemk phys_start=0x83C00000 phys_end=0x88000000 allowOverlap=1 phys_start_1=0x00001000 phys_end_1=0x00008000 pools_1=1x28672 useHeapIfPoolUnavailable=1


    But I want to load the settings on the CMEMK automaticly so I did this like you said:

    load () {
        modprobe cmemk phys_start=0x84c00000 phys_end=0x88000000 pools=8x46672 allowOverlap=1 phys_start_1=0x00001000 phys_end_1=0x00008000 pools_1=1x28672 useHeapIfPoolUnavailable=1

    but it does not seem to work, because when I do that the capture program should run same as it did before when I did it manually but I get this error:

    root@dm368-evm:/usr/share/ti/linux-driver-examples/imp-prev-rsz# ./capture_prev_
    rsz_onthe_fly_bayer_mew -i1 -m4 -h60                                           
    input_std_paramsCMEMK Error: ALLOC: invalid pool (0) passed.                   
    : name = V4L2_STD_720P_30                                                      
    input_std_params: output size = 1280 * 720                                     
    calling cmem utilities for allocating frame buffers                            
    CMEM Error: allocPool: ioctl CMEM_IOCALLOC failed from pool 0: -1              
    Failed to allocate cmem pool                                                   
    Unable to Allocate user buffers 

    and if I run the CMEMK configurations manually by rmmod and insmod it works, my questions is why the configurations I did on the loadmodule-rc does not take effect did I do them wrong?

     

    Regards,

    Andre

  • I'm not familiar with the loadmodule-rc script so I can't really comment on its impact on your system.

    Andre16038 said:
    paramsCMEMK Error: ALLOC: invalid pool (0) passed.

    This error happens when there is no pool 0.  Even though you have modified loadmodules-rc to configure pool=8x46672 (which should become pool 0) you're getting this, so I can only assume that your modification in loadmodules-rc is not taking effect.

    You can do "% cat /proc/cmem" to see what your CMEM configuration is.  It will show all pool buffers (but nothing about the heap), both free and busy.  If you're configuring 8x46672 in pool 0 then you will see that.

    I don't know your system so I don't know where cmemk gets installed.  It feels like you have multiple places that cmemk gets installed and that you haven't identified the place that is actually taking effect  You could put some "% echo modprobe cmemk..." in your loadmodules-rc, just before the cmemk command, to see if it is actually running.

    Regards,

    - Rob