ASoC: Intel: Skylake: Fix cleanup of dma buffer
authorJeeja KP <jeeja.kp@intel.com>
Fri, 13 Nov 2015 13:52:08 +0000 (19:22 +0530)
committerMark Brown <broonie@kernel.org>
Wed, 18 Nov 2015 18:46:36 +0000 (18:46 +0000)
During firmware download, dma buffers are allocated in prepare
and never freed on clean up. This patch frees the allocated dma
buffer in cldma controller clean up.

Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/skylake/skl-sst-cldma.c
sound/soc/intel/skylake/skl-sst.c

index 44748ba98da29fcc1c8018181982a20d7e782ec7..4ddabe30b62a94083da5b7b8cde7bbfe4dc49934 100644 (file)
@@ -137,6 +137,11 @@ static void skl_cldma_cleanup(struct sst_dsp  *ctx)
 
        sst_dsp_shim_write(ctx, SKL_ADSP_REG_CL_SD_CBL, 0);
        sst_dsp_shim_write(ctx, SKL_ADSP_REG_CL_SD_LVI, 0);
+
+       if (&ctx->cl_dev.dmab_data)
+               ctx->dsp_ops.free_dma_buf(ctx->dev, &ctx->cl_dev.dmab_data);
+       if (&ctx->cl_dev.dmab_bdl)
+               ctx->dsp_ops.free_dma_buf(ctx->dev, &ctx->cl_dev.dmab_bdl);
 }
 
 static int skl_cldma_wait_interruptible(struct sst_dsp *ctx)
index 0c5039f2bd09a7890398e5daaa7bd232ed39e2e3..51f07f0e4735b63e9d5c86e61875d836b55ae3c2 100644 (file)
@@ -115,27 +115,28 @@ static int skl_load_base_firmware(struct sst_dsp *ctx)
                dev_err(ctx->dev,
                        "Timeout waiting for ROM init done, reg:0x%x\n", reg);
                ret = -EIO;
-               goto skl_load_base_firmware_failed;
+               goto transfer_firmware_failed;
        }
 
        ret = skl_transfer_firmware(ctx, ctx->fw->data, ctx->fw->size);
        if (ret < 0) {
                dev_err(ctx->dev, "Transfer firmware failed%d\n", ret);
-               goto skl_load_base_firmware_failed;
+               goto transfer_firmware_failed;
        } else {
                ret = wait_event_timeout(skl->boot_wait, skl->boot_complete,
                                        msecs_to_jiffies(SKL_IPC_BOOT_MSECS));
                if (ret == 0) {
                        dev_err(ctx->dev, "DSP boot failed, FW Ready timed-out\n");
                        ret = -EIO;
-                       goto skl_load_base_firmware_failed;
+                       goto transfer_firmware_failed;
                }
 
                dev_dbg(ctx->dev, "Download firmware successful%d\n", ret);
                skl_dsp_set_state_locked(ctx, SKL_DSP_RUNNING);
        }
        return 0;
-
+transfer_firmware_failed:
+       ctx->cl_dev.ops.cl_cleanup_controller(ctx);
 skl_load_base_firmware_failed:
        skl_dsp_disable_core(ctx);
        release_firmware(ctx->fw);
@@ -277,7 +278,6 @@ EXPORT_SYMBOL_GPL(skl_sst_dsp_init);
 void skl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx)
 {
        skl_ipc_free(&ctx->ipc);
-       ctx->dsp->cl_dev.ops.cl_cleanup_controller(ctx->dsp);
        ctx->dsp->ops->free(ctx->dsp);
 }
 EXPORT_SYMBOL_GPL(skl_sst_dsp_cleanup);