Skip to content

Commit

Permalink
ASoC: intel: Use kvzalloc() for suspend buffers
Browse files Browse the repository at this point in the history
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>
Signed-off-by: youling257 <youling257@gmail.com>
  • Loading branch information
tiwai authored and youling257 committed Jul 11, 2017
1 parent 4fefd1c commit 21c2de4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
22 changes: 11 additions & 11 deletions sound/soc/intel/atom/sst/sst.c
Expand Up @@ -499,23 +499,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;
Expand All @@ -530,11 +530,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;
Expand Down Expand Up @@ -562,10 +562,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);
Expand Down
8 changes: 4 additions & 4 deletions sound/soc/intel/atom/sst/sst.h
Expand Up @@ -338,10 +338,10 @@ struct sst_shim_regs64 {
};

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() */
};

/**
Expand Down

0 comments on commit 21c2de4

Please sign in to comment.