diff options
author | Felipe Contreras <felipe.contreras@gmail.com> | 2010-11-10 12:09:22 -0600 |
---|---|---|
committer | Omar Ramirez Luna <omar.ramirez@ti.com> | 2010-11-10 18:34:42 -0600 |
commit | a28903501cb7f7b1ad52c1e981aed2738ae7c434 (patch) | |
tree | abcaea6c4d6c772cb07e7081ec39e71f6e0912ca /drivers/staging/tidspbridge/rmgr/proc.c | |
parent | 2fa28a5182869968a388d34f8d809aa07a0d4046 (diff) | |
download | op-kernel-dev-a28903501cb7f7b1ad52c1e981aed2738ae7c434.zip op-kernel-dev-a28903501cb7f7b1ad52c1e981aed2738ae7c434.tar.gz |
Revert "staging: tidspbridge - remove reserved memory clean up"
This reverts commit db348ca36e5881cd1d2e5caa6eee7d0237d07a3d.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
Diffstat (limited to 'drivers/staging/tidspbridge/rmgr/proc.c')
-rw-r--r-- | drivers/staging/tidspbridge/rmgr/proc.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c index e5fec57..59c946b 100644 --- a/drivers/staging/tidspbridge/rmgr/proc.c +++ b/drivers/staging/tidspbridge/rmgr/proc.c @@ -1515,6 +1515,7 @@ int proc_reserve_memory(void *hprocessor, u32 ul_size, struct dmm_object *dmm_mgr; int status = 0; struct proc_object *p_proc_object = (struct proc_object *)hprocessor; + struct dmm_rsv_object *rsv_obj; if (!p_proc_object) { status = -EFAULT; @@ -1528,6 +1529,22 @@ int proc_reserve_memory(void *hprocessor, u32 ul_size, } status = dmm_reserve_memory(dmm_mgr, ul_size, (u32 *) pp_rsv_addr); + if (status != 0) + goto func_end; + + /* + * A successful reserve should be followed by insertion of rsv_obj + * into dmm_rsv_list, so that reserved memory resource tracking + * remains uptodate + */ + rsv_obj = kmalloc(sizeof(struct dmm_rsv_object), GFP_KERNEL); + if (rsv_obj) { + rsv_obj->dsp_reserved_addr = (u32) *pp_rsv_addr; + spin_lock(&pr_ctxt->dmm_rsv_lock); + list_add(&rsv_obj->link, &pr_ctxt->dmm_rsv_list); + spin_unlock(&pr_ctxt->dmm_rsv_lock); + } + func_end: dev_dbg(bridge, "%s: hprocessor: 0x%p ul_size: 0x%x pp_rsv_addr: 0x%p " "status 0x%x\n", __func__, hprocessor, @@ -1739,6 +1756,7 @@ int proc_un_reserve_memory(void *hprocessor, void *prsv_addr, struct dmm_object *dmm_mgr; int status = 0; struct proc_object *p_proc_object = (struct proc_object *)hprocessor; + struct dmm_rsv_object *rsv_obj; if (!p_proc_object) { status = -EFAULT; @@ -1752,6 +1770,24 @@ int proc_un_reserve_memory(void *hprocessor, void *prsv_addr, } status = dmm_un_reserve_memory(dmm_mgr, (u32) prsv_addr); + if (status != 0) + goto func_end; + + /* + * A successful unreserve should be followed by removal of rsv_obj + * from dmm_rsv_list, so that reserved memory resource tracking + * remains uptodate + */ + spin_lock(&pr_ctxt->dmm_rsv_lock); + list_for_each_entry(rsv_obj, &pr_ctxt->dmm_rsv_list, link) { + if (rsv_obj->dsp_reserved_addr == (u32) prsv_addr) { + list_del(&rsv_obj->link); + kfree(rsv_obj); + break; + } + } + spin_unlock(&pr_ctxt->dmm_rsv_lock); + func_end: dev_dbg(bridge, "%s: hprocessor: 0x%p prsv_addr: 0x%p status: 0x%x\n", __func__, hprocessor, prsv_addr, status); |