Index: dvsdk_2_00_00/dvsdk_2_00_00_22/linuxutils_2_23_01/packages/ti/sdo/linuxutils/cmem/src/interface/cmem.c =================================================================== --- dvsdk_2_00_00.orig/dvsdk_2_00_00_22/linuxutils_2_23_01/packages/ti/sdo/linuxutils/cmem/src/interface/cmem.c 2009-11-12 08:50:11.945906430 -0600 +++ dvsdk_2_00_00/dvsdk_2_00_00_22/linuxutils_2_23_01/packages/ti/sdo/linuxutils/cmem/src/interface/cmem.c 2009-11-12 08:51:22.133832889 -0600 @@ -588,7 +588,7 @@ *pphys_base = block.get_block_outparams.physp; *psize = block.get_block_outparams.size; - __D("getVersion: exiting, ioctl CMEM_IOCGETBLOCK succeeded, " + __D("getBlock: exiting, ioctl CMEM_IOCGETBLOCK succeeded, " "returning *pphys_base=0x%lx, *psize=0x%x\n", *pphys_base, *psize); return 0; @@ -633,6 +633,6 @@ } /* - * @(#) ti.sdo.linuxutils.cmem; 2, 2, 0,104; 4-20-2009 11:43:31; /db/atree/library/trees/linuxutils/linuxutils-d06x/src/ + * @(#) ti.sdo.linuxutils.cmem; 2, 2, 0,115; 6-11-2009 17:57:44; /db/atree/library/trees/linuxutils/linuxutils-e02x/src/ */ Index: dvsdk_2_00_00/dvsdk_2_00_00_22/linuxutils_2_23_01/packages/ti/sdo/linuxutils/cmem/src/interface/cmem.h =================================================================== --- dvsdk_2_00_00.orig/dvsdk_2_00_00_22/linuxutils_2_23_01/packages/ti/sdo/linuxutils/cmem/src/interface/cmem.h 2009-11-12 08:50:11.969956144 -0600 +++ dvsdk_2_00_00/dvsdk_2_00_00_22/linuxutils_2_23_01/packages/ti/sdo/linuxutils/cmem/src/interface/cmem.h 2009-11-12 08:51:36.917971311 -0600 @@ -48,6 +48,9 @@ * - pools must be specified using decimal format (for both number and * size), since using hexadecimal format would visually clutter the * specification due to the use of "x" as a token separator + * - it's possible to insmod cmemk.ko without specifying any memory blocks, + * in which case CMEM_getPhys() and CMEM_cache*() APIs can still be + * utilized by an application. * * This particular command creates 2 pools. The first pool is created with 4 * buffers of size 30000 bytes and the second pool is created with 2 buffers @@ -98,18 +101,19 @@ * pool allocations. If more heap space is needed than is available after pool * allocations, you must reduce the amount of CMEM memory granted to the pools. * - * Buffer allocation is tracked at the process level by way of a 'process - * registration' list. The initial allocator of a buffer (the process that + * Buffer allocation is tracked at the file descriptor level by way of a + * 'registration' list. The initial allocator of a buffer (the process that * calls CMEM_alloc()) is automatically added to the registration list, * and further processes can become registered for the same buffer by way * of the CMEM_registerAlloc() API (and unregister with the * CMEM_unregister() API). This registration list for each buffer * allows for buffer ownership tracking and cleanup on a - * per-process basis, so that when a process exits or dies without having - * explicitly freed/unregistered its buffers, they get automatically - * unregistered (and freed when no more registered processes exist). Only - * when the last registered process frees a buffer (either explictily, or - * by auto-cleanup) does a buffer actually get freed back to the kernel module. + * per-file-descriptor basis, so that when a process exits or dies without + * having explicitly freed/unregistered its buffers, they get automatically + * unregistered (and freed when no more registered file descriptors exist). + * Only when the last registered file descriptor frees a buffer (either + * explictily, or by auto-cleanup) does a buffer actually get freed back to + * the kernel module. * * Since the CMEM interface library doesn't use the GT tracing facility, there * is one configuration option available for the CMEM module to control @@ -577,6 +581,6 @@ #endif /* - * @(#) ti.sdo.linuxutils.cmem; 2, 2, 0,104; 4-20-2009 11:43:31; /db/atree/library/trees/linuxutils/linuxutils-d06x/src/ + * @(#) ti.sdo.linuxutils.cmem; 2, 2, 0,115; 6-11-2009 17:57:44; /db/atree/library/trees/linuxutils/linuxutils-e02x/src/ */ Index: dvsdk_2_00_00/dvsdk_2_00_00_22/linuxutils_2_23_01/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.c =================================================================== --- dvsdk_2_00_00.orig/dvsdk_2_00_00_22/linuxutils_2_23_01/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.c 2009-11-12 08:50:03.701785121 -0600 +++ dvsdk_2_00_00/dvsdk_2_00_00_22/linuxutils_2_23_01/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.c 2009-11-12 08:52:11.845785577 -0600 @@ -208,7 +208,8 @@ typedef struct registered_user { struct list_head element; - struct task_struct *user; +// struct task_struct *user; + struct file *filp; } registered_user; pool_object p_objs[NBLOCKS][MAX_POOLS]; @@ -1183,7 +1184,8 @@ list_add_tail(&entry->element, busylistp); user = kmalloc(sizeof(struct registered_user), GFP_KERNEL); - user->user = current; +// user->user = current; + user->filp = filp; list_add(&user->element, &entry->users); up(&cmem_mutex); @@ -1254,7 +1256,8 @@ list_add(e, busylistp); user = kmalloc(sizeof(struct registered_user), GFP_KERNEL); - user->user = current; +// user->user = current; + user->filp = filp; list_add(&user->element, &entry->users); up(&cmem_mutex); @@ -1317,10 +1320,10 @@ unext = u->next; user = list_entry(u, struct registered_user, element); - if (user->user == current) { - __D("FREE%s%s: Removing process %p from user list of buffer %#lx...\n", + if (user->filp == filp) { + __D("FREE%s%s: Removing file %p from user list of buffer %#lx...\n", cmd & CMEM_HEAP ? "HEAP" : "", - cmd & CMEM_PHYS ? "PHYS" : "", current, physp); + cmd & CMEM_PHYS ? "PHYS" : "", filp, physp); list_del(u); kfree(user); @@ -1645,7 +1648,8 @@ * the list multiple times (every time IOCREGUSER is called). */ user = kmalloc(sizeof(struct registered_user), GFP_KERNEL); - user->user = current; +// user->user = current; + user->filp = filp; list_add(&user->element, &entry->users); } @@ -1774,9 +1778,9 @@ user = list_entry(u, struct registered_user, element); - if (last_close || user->user == current) { - __D("Removing process %p from user list of buffer %#lx...\n", - user->user, entry->physp); + if (last_close || user->filp == filp) { + __D("Removing file %p from user list of buffer %#lx...\n", + user->filp, entry->physp); list_del(u); kfree(user); @@ -1876,11 +1880,6 @@ } /* cut-and-paste above as part of adding support for more than 2 blocks */ - if (!phys_start || !phys_end) { - __E("Pysical start and end addresses not supplied\n"); - return -EINVAL; - } - cmem_major = register_chrdev(0, "cmem", &cmem_fxns); if (cmem_major < 0) { @@ -1929,6 +1928,19 @@ for (bi = 0; bi < NBLOCKS; bi++) { + if (bi == 0 && (!phys_start || !phys_end)) { + if (pools[0]) { + __E("pools specified: must specify both phys_start and phys_end, exiting...\n"); + err = -EINVAL; + goto fail_after_create; + } + else { + printk(KERN_INFO "no physical memory specified, continuing " + "with no memory allocation capability...\n"); + + break; + } + } /* cut-and-paste below as part of adding support for more than 2 blocks */ if (bi == 1 && (!phys_start_1 || !phys_end_1)) { break; @@ -2177,8 +2189,8 @@ user = list_entry(u, struct registered_user, element); - __D("Removing process %p from user list of buffer %#lx...\n", - user->user, entry->physp); + __D("Removing file %p from user list of buffer %#lx...\n", + user->filp, entry->physp); list_del(u); kfree(user); @@ -2204,8 +2216,8 @@ user = list_entry(u, struct registered_user, element); - __D("Removing process %p from user list of buffer %#lx...\n", - user->user, entry->physp); + __D("Removing file %p from user list of buffer %#lx...\n", + user->filp, entry->physp); list_del(u); kfree(user); @@ -2363,6 +2375,6 @@ "); /* - * @(#) ti.sdo.linuxutils.cmem; 2, 2, 0,104; 4-20-2009 11:43:31; /db/atree/library/trees/linuxutils/linuxutils-d06x/src/ + * @(#) ti.sdo.linuxutils.cmem; 2, 2, 0,115; 6-11-2009 17:57:46; /db/atree/library/trees/linuxutils/linuxutils-e02x/src/ */