Clean up all mapping information resources whenever a buffer is unmapped. Signed-off-by: Ohad Ben-Cohen <ohad@xxxxxxxxxx> --- If you want, you can also reach me at < ohadb at ti dot com >. drivers/dsp/bridge/rmgr/proc.c | 43 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/drivers/dsp/bridge/rmgr/proc.c b/drivers/dsp/bridge/rmgr/proc.c index b03232f..ebb11b1 100644 --- a/drivers/dsp/bridge/rmgr/proc.c +++ b/drivers/dsp/bridge/rmgr/proc.c @@ -169,6 +169,46 @@ static struct memory_map_info *add_mapping_info(struct proc_object *pr_obj, return map_info; } +static int match_exact_map_info(struct memory_map_info *map_info, + u32 dsp_addr, u32 size) +{ + return map_info->dsp_addr == dsp_addr && + map_info->size == size; +} + +static void remove_mapping_information(struct proc_object *pr_obj, + u32 dsp_addr, u32 size) +{ + struct memory_map_info *map_info; + struct list_head *iter; + + pr_debug("%s: looking for virt 0x%x size 0x%x\n", __func__, + dsp_addr, size); + + spin_lock(&pr_obj->maps_lock); + list_for_each(iter, &pr_obj->maps) { + map_info = list_entry(iter, struct memory_map_info, node); + pr_debug("%s: candidate: mpu_addr 0x%x virt 0x%x size 0x%x\n", + __func__, + map_info->mpu_addr, + map_info->dsp_addr, + map_info->size); + + if (match_exact_map_info(map_info, dsp_addr, size)) { + pr_debug("%s: match, deleting map info\n", __func__); + list_del(&map_info->node); + kfree(map_info->pages); + kfree(map_info); + goto out; + } + pr_debug("%s: candidate didn't match\n", __func__); + } + + pr_err("%s: failed to find given map info\n", __func__); +out: + spin_unlock(&pr_obj->maps_lock); +} + /* * ======== proc_attach ======== * Purpose: @@ -1508,6 +1548,9 @@ dsp_status proc_un_map(void *hprocessor, void *map_addr, status = (*p_proc_object->intf_fxns->pfn_brd_mem_un_map) (p_proc_object->hwmd_context, va_align, size_align); } + + remove_mapping_information(p_proc_object, va_align, size_align); + mutex_unlock(&proc_lock); if (DSP_FAILED(status)) goto func_end; -- 1.6.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html