Commit c1a7898d authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: wm_adsp: Split firmware load into smaller chunks

The firmware files can be quite large and allocating the whole firmware
a single DMA safe buffer can be problematic if the system is under a
high memory load. Ease the requirements slightly by writing the firmware
out in page sized chunks.
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 055bbe2d
...@@ -684,8 +684,16 @@ static int wm_adsp_load(struct wm_adsp *dsp) ...@@ -684,8 +684,16 @@ static int wm_adsp_load(struct wm_adsp *dsp)
} }
if (reg) { if (reg) {
buf = wm_adsp_buf_alloc(region->data, size_t to_write = PAGE_SIZE;
le32_to_cpu(region->len), size_t remain = le32_to_cpu(region->len);
const u8 *data = region->data;
while (remain > 0) {
if (remain < PAGE_SIZE)
to_write = remain;
buf = wm_adsp_buf_alloc(data,
to_write,
&buf_list); &buf_list);
if (!buf) { if (!buf) {
adsp_err(dsp, "Out of memory\n"); adsp_err(dsp, "Out of memory\n");
...@@ -693,16 +701,22 @@ static int wm_adsp_load(struct wm_adsp *dsp) ...@@ -693,16 +701,22 @@ static int wm_adsp_load(struct wm_adsp *dsp)
goto out_fw; goto out_fw;
} }
ret = regmap_raw_write_async(regmap, reg, buf->buf, ret = regmap_raw_write_async(regmap, reg,
le32_to_cpu(region->len)); buf->buf,
to_write);
if (ret != 0) { if (ret != 0) {
adsp_err(dsp, adsp_err(dsp,
"%s.%d: Failed to write %d bytes at %d in %s: %d\n", "%s.%d: Failed to write %d bytes at %d in %s: %d\n",
file, regions, file, regions,
le32_to_cpu(region->len), offset, to_write, offset,
region_name, ret); region_name, ret);
goto out_fw; goto out_fw;
} }
data += to_write;
reg += to_write / 2;
remain -= to_write;
}
} }
pos += le32_to_cpu(region->len) + sizeof(*region); pos += le32_to_cpu(region->len) + sizeof(*region);
......
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