Commit 75bd9086 authored by Takashi Iwai's avatar Takashi Iwai Committed by Mark Brown

ASoC: intel: Use kvzalloc() for suspend buffers

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: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent ad7fb5a3
...@@ -464,23 +464,23 @@ static int intel_sst_suspend(struct device *dev) ...@@ -464,23 +464,23 @@ static int intel_sst_suspend(struct device *dev)
fw_save = kzalloc(sizeof(*fw_save), GFP_KERNEL); fw_save = kzalloc(sizeof(*fw_save), GFP_KERNEL);
if (!fw_save) if (!fw_save)
return -ENOMEM; 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) { if (!fw_save->iram) {
ret = -ENOMEM; ret = -ENOMEM;
goto iram; 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) { if (!fw_save->dram) {
ret = -ENOMEM; ret = -ENOMEM;
goto dram; goto dram;
} }
fw_save->sram = kzalloc(SST_MAILBOX_SIZE, GFP_KERNEL); fw_save->sram = kvzalloc(SST_MAILBOX_SIZE, GFP_KERNEL);
if (!fw_save->sram) { if (!fw_save->sram) {
ret = -ENOMEM; ret = -ENOMEM;
goto sram; 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) { if (!fw_save->ddr) {
ret = -ENOMEM; ret = -ENOMEM;
goto ddr; goto ddr;
...@@ -495,11 +495,11 @@ static int intel_sst_suspend(struct device *dev) ...@@ -495,11 +495,11 @@ static int intel_sst_suspend(struct device *dev)
ctx->ops->reset(ctx); ctx->ops->reset(ctx);
return 0; return 0;
ddr: ddr:
kfree(fw_save->sram); kvfree(fw_save->sram);
sram: sram:
kfree(fw_save->dram); kvfree(fw_save->dram);
dram: dram:
kfree(fw_save->iram); kvfree(fw_save->iram);
iram: iram:
kfree(fw_save); kfree(fw_save);
return ret; return ret;
...@@ -527,10 +527,10 @@ static int intel_sst_resume(struct device *dev) ...@@ -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->mailbox, fw_save->sram, SST_MAILBOX_SIZE);
memcpy32_toio(ctx->ddr, fw_save->ddr, ctx->ddr_end - ctx->ddr_base); memcpy32_toio(ctx->ddr, fw_save->ddr, ctx->ddr_end - ctx->ddr_base);
kfree(fw_save->sram); kvfree(fw_save->sram);
kfree(fw_save->dram); kvfree(fw_save->dram);
kfree(fw_save->iram); kvfree(fw_save->iram);
kfree(fw_save->ddr); kvfree(fw_save->ddr);
kfree(fw_save); kfree(fw_save);
block = sst_create_block(ctx, 0, FW_DWNL_ID); block = sst_create_block(ctx, 0, FW_DWNL_ID);
......
...@@ -318,10 +318,10 @@ struct sst_ipc_reg { ...@@ -318,10 +318,10 @@ struct sst_ipc_reg {
}; };
struct sst_fw_save { struct sst_fw_save {
void *iram; void *iram; /* allocated via kvmalloc() */
void *dram; void *dram; /* allocated via kvmalloc() */
void *sram; void *sram; /* allocated via kvmalloc() */
void *ddr; void *ddr; /* allocated via kvmalloc() */
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment