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: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
055bbe2df9
commit
c1a7898d65
|
@ -684,24 +684,38 @@ 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);
|
||||||
&buf_list);
|
const u8 *data = region->data;
|
||||||
if (!buf) {
|
|
||||||
adsp_err(dsp, "Out of memory\n");
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto out_fw;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = regmap_raw_write_async(regmap, reg, buf->buf,
|
while (remain > 0) {
|
||||||
le32_to_cpu(region->len));
|
if (remain < PAGE_SIZE)
|
||||||
if (ret != 0) {
|
to_write = remain;
|
||||||
adsp_err(dsp,
|
|
||||||
"%s.%d: Failed to write %d bytes at %d in %s: %d\n",
|
buf = wm_adsp_buf_alloc(data,
|
||||||
file, regions,
|
to_write,
|
||||||
le32_to_cpu(region->len), offset,
|
&buf_list);
|
||||||
region_name, ret);
|
if (!buf) {
|
||||||
goto out_fw;
|
adsp_err(dsp, "Out of memory\n");
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto out_fw;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = regmap_raw_write_async(regmap, reg,
|
||||||
|
buf->buf,
|
||||||
|
to_write);
|
||||||
|
if (ret != 0) {
|
||||||
|
adsp_err(dsp,
|
||||||
|
"%s.%d: Failed to write %d bytes at %d in %s: %d\n",
|
||||||
|
file, regions,
|
||||||
|
to_write, offset,
|
||||||
|
region_name, ret);
|
||||||
|
goto out_fw;
|
||||||
|
}
|
||||||
|
|
||||||
|
data += to_write;
|
||||||
|
reg += to_write / 2;
|
||||||
|
remain -= to_write;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue