On Mon, Feb 15, 2010 at 04:35:08PM +0100, Ameya Palande wrote:
> DSP_RSV_OBJECT is introduced to track reserved memory accounting information.
> This will allow us to do proper cleanup for memory reserved using
> PROC_ReserveMemory().
>
> Signed-off-by: Ameya Palande <[email protected]>
> ---
[...]
> diff --git a/drivers/dsp/bridge/rmgr/proc.c b/drivers/dsp/bridge/rmgr/proc.c
> index 2ccbc9b..74c22cd 100644
> --- a/drivers/dsp/bridge/rmgr/proc.c
> +++ b/drivers/dsp/bridge/rmgr/proc.c
> @@ -1430,7 +1430,7 @@ func_end:
> * Reserve a virtually contiguous region of DSP address space.
> */
> DSP_STATUS PROC_ReserveMemory(DSP_HPROCESSOR hProcessor, u32 ulSize,
> - void **ppRsvAddr)
> + void **ppRsvAddr, struct PROCESS_CONTEXT *pr_ctxt)
> {
> struct DMM_OBJECT *hDmmMgr;
> DSP_STATUS status = DSP_SOK;
> @@ -1450,8 +1450,21 @@ DSP_STATUS PROC_ReserveMemory(DSP_HPROCESSOR
> hProcessor, u32 ulSize,
> if (DSP_FAILED(status)) {
> GT_1trace(PROC_DebugMask, GT_7CLASS, "PROC_ReserveMemory: "
> "Failed to get DMM Mgr handle: 0x%x\n", status);
> - } else
> + } else {
> status = DMM_ReserveMemory(hDmmMgr, ulSize, (u32 *)ppRsvAddr);
> + if (status == DSP_SOK) {
More indentattion?
Can't we have instead:
if (status != DSP_SOK)
goto err:
> + struct DMM_RSV_OBJECT *rsv_obj =
> + kmalloc(sizeof(struct DMM_RSV_OBJECT),
> + GFP_KERNEL);
> + if (rsv_obj) {
> + rsv_obj->dsp_reserved_addr = (u32) *ppRsvAddr;
> + spin_lock(&pr_ctxt->dmm_rsv_list_lock);
> + list_add(&rsv_obj->link,
> + &pr_ctxt->dmm_rsv_list);
> + spin_unlock(&pr_ctxt->dmm_rsv_list_lock);
> + }
> + }
> + }
>
> GT_1trace(PROC_DebugMask, GT_ENTER, "Leaving PROC_ReserveMemory [0x%x]",
> status);
> @@ -1704,7 +1717,8 @@ func_end:
> * Purpose:
> * Frees a previously reserved region of DSP address space.
> */
> -DSP_STATUS PROC_UnReserveMemory(DSP_HPROCESSOR hProcessor, void *pRsvAddr)
> +DSP_STATUS PROC_UnReserveMemory(DSP_HPROCESSOR hProcessor, void *pRsvAddr,
> + struct PROCESS_CONTEXT *pr_ctxt, int cleanup)
> {
> struct DMM_OBJECT *hDmmMgr;
> DSP_STATUS status = DSP_SOK;
> @@ -1720,12 +1734,32 @@ DSP_STATUS PROC_UnReserveMemory(DSP_HPROCESSOR
> hProcessor, void *pRsvAddr)
> goto func_end;
> }
> status = DMM_GetHandle(pProcObject, &hDmmMgr);
> - if (DSP_FAILED(status))
> + if (DSP_FAILED(status)) {
> GT_1trace(PROC_DebugMask, GT_7CLASS,
> "PROC_UnReserveMemory: Failed to get DMM Mgr "
> "handle: 0x%x\n", status);
> - else
> + } else {
> status = DMM_UnReserveMemory(hDmmMgr, (u32) pRsvAddr);
> + /*
> + * cleanup flag handles the special case when this function
> + * is called while doing clenaup from
> + * DRV_RemoveAllDMMResElements
> + */
> + if (status == DSP_SOK && cleanup) {
Ditto here, although maybe the label should be 'leave' instead.
> + struct DMM_RSV_OBJECT *temp, *rsv_obj;
> + spin_lock(&pr_ctxt->dmm_rsv_list_lock);
> + list_for_each_entry_safe(rsv_obj, temp,
> + &pr_ctxt->dmm_rsv_list, link) {
> + if (rsv_obj->dsp_reserved_addr ==
> + (u32)pRsvAddr) {
> + list_del(&rsv_obj->link);
> + kfree(rsv_obj);
> + break;
> + }
> + }
> + spin_unlock(&pr_ctxt->dmm_rsv_list_lock);
> + }
> + }
>
> GT_1trace(PROC_DebugMask, GT_ENTER,
> "Leaving PROC_UnReserveMemory [0x%x]",
> --
Cheers.
--
Felipe Contreras
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html