ASoC: intel: Use kvzalloc() for suspend buffers
authorTakashi Iwai <tiwai@suse.de>
Fri, 16 Jun 2017 09:20:29 +0000 (11:20 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 16 Jun 2017 10:26:36 +0000 (11:26 +0100)
Intel SST driver allocates lots of pages at suspend for saving the
firmware states, and this may occasionally lead to the allocation
error due to the high order, ending up with the suspend failure.

Use kvzalloc() so that it can fall back to vmalloc() gracefully.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/atom/sst/sst.c
sound/soc/intel/atom/sst/sst.h

index 5ee92257ca850eb79088bbdbae25b1ca1aa9f48f..8afdff457579fe9062089fcb6d364cd2185f45ee 100644 (file)
@@ -464,23 +464,23 @@ static int intel_sst_suspend(struct device *dev)
        fw_save = kzalloc(sizeof(*fw_save), GFP_KERNEL);
        if (!fw_save)
                return -ENOMEM;
-       fw_save->iram = kzalloc(ctx->iram_end - ctx->iram_base, GFP_KERNEL);
+       fw_save->iram = kvzalloc(ctx->iram_end - ctx->iram_base, GFP_KERNEL);
        if (!fw_save->iram) {
                ret = -ENOMEM;
                goto iram;
        }
-       fw_save->dram = kzalloc(ctx->dram_end - ctx->dram_base, GFP_KERNEL);
+       fw_save->dram = kvzalloc(ctx->dram_end - ctx->dram_base, GFP_KERNEL);
        if (!fw_save->dram) {
                ret = -ENOMEM;
                goto dram;
        }
-       fw_save->sram = kzalloc(SST_MAILBOX_SIZE, GFP_KERNEL);
+       fw_save->sram = kvzalloc(SST_MAILBOX_SIZE, GFP_KERNEL);
        if (!fw_save->sram) {
                ret = -ENOMEM;
                goto sram;
        }
 
-       fw_save->ddr = kzalloc(ctx->ddr_end - ctx->ddr_base, GFP_KERNEL);
+       fw_save->ddr = kvzalloc(ctx->ddr_end - ctx->ddr_base, GFP_KERNEL);
        if (!fw_save->ddr) {
                ret = -ENOMEM;
                goto ddr;
@@ -495,11 +495,11 @@ static int intel_sst_suspend(struct device *dev)
        ctx->ops->reset(ctx);
        return 0;
 ddr:
-       kfree(fw_save->sram);
+       kvfree(fw_save->sram);
 sram:
-       kfree(fw_save->dram);
+       kvfree(fw_save->dram);
 dram:
-       kfree(fw_save->iram);
+       kvfree(fw_save->iram);
 iram:
        kfree(fw_save);
        return ret;
@@ -527,10 +527,10 @@ static int intel_sst_resume(struct device *dev)
        memcpy32_toio(ctx->mailbox, fw_save->sram, SST_MAILBOX_SIZE);
        memcpy32_toio(ctx->ddr, fw_save->ddr, ctx->ddr_end - ctx->ddr_base);
 
-       kfree(fw_save->sram);
-       kfree(fw_save->dram);
-       kfree(fw_save->iram);
-       kfree(fw_save->ddr);
+       kvfree(fw_save->sram);
+       kvfree(fw_save->dram);
+       kvfree(fw_save->iram);
+       kvfree(fw_save->ddr);
        kfree(fw_save);
 
        block = sst_create_block(ctx, 0, FW_DWNL_ID);
index 1693befa455a78e49caea26dccef04c50ee57a5c..e02e2b4cc08f0e657be5096fce99aa3d003db96d 100644 (file)
@@ -318,10 +318,10 @@ struct sst_ipc_reg {
 };
 
 struct sst_fw_save {
-       void *iram;
-       void *dram;
-       void *sram;
-       void *ddr;
+       void *iram;     /* allocated via kvmalloc() */
+       void *dram;     /* allocated via kvmalloc() */
+       void *sram;     /* allocated via kvmalloc() */
+       void *ddr;      /* allocated via kvmalloc() */
 };
 
 /**