提交 a76fefab 编写于 作者: M Mark Brown

ASoC: wm_adsp: Ensure that block writes are from DMA aligned addresses

Otherwise we won't run correctly on systems that require this for larger
data transfers.
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 d1c3ed66
...@@ -169,6 +169,7 @@ static int wm_adsp_load(struct wm_adsp *dsp) ...@@ -169,6 +169,7 @@ static int wm_adsp_load(struct wm_adsp *dsp)
const struct wm_adsp_region *mem; const struct wm_adsp_region *mem;
const char *region_name; const char *region_name;
char *file, *text; char *file, *text;
void *buf;
unsigned int reg; unsigned int reg;
int regions = 0; int regions = 0;
int ret, offset, type, sizes; int ret, offset, type, sizes;
...@@ -322,8 +323,18 @@ static int wm_adsp_load(struct wm_adsp *dsp) ...@@ -322,8 +323,18 @@ static int wm_adsp_load(struct wm_adsp *dsp)
} }
if (reg) { if (reg) {
ret = regmap_raw_write(regmap, reg, region->data, buf = kmemdup(region->data, le32_to_cpu(region->len),
GFP_KERNEL);
if (!buf) {
adsp_err(dsp, "Out of memory\n");
return -ENOMEM;
}
ret = regmap_raw_write(regmap, reg, buf,
le32_to_cpu(region->len)); le32_to_cpu(region->len));
kfree(buf);
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",
...@@ -359,6 +370,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp) ...@@ -359,6 +370,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
const char *region_name; const char *region_name;
int ret, pos, blocks, type, offset, reg; int ret, pos, blocks, type, offset, reg;
char *file; char *file;
void *buf;
file = kzalloc(PAGE_SIZE, GFP_KERNEL); file = kzalloc(PAGE_SIZE, GFP_KERNEL);
if (file == NULL) if (file == NULL)
...@@ -426,6 +438,13 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp) ...@@ -426,6 +438,13 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
} }
if (reg) { if (reg) {
buf = kmemdup(blk->data, le32_to_cpu(blk->len),
GFP_KERNEL);
if (!buf) {
adsp_err(dsp, "Out of memory\n");
return -ENOMEM;
}
ret = regmap_raw_write(regmap, reg, blk->data, ret = regmap_raw_write(regmap, reg, blk->data,
le32_to_cpu(blk->len)); le32_to_cpu(blk->len));
if (ret != 0) { if (ret != 0) {
...@@ -433,6 +452,8 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp) ...@@ -433,6 +452,8 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
"%s.%d: Failed to write to %x in %s\n", "%s.%d: Failed to write to %x in %s\n",
file, blocks, reg, region_name); file, blocks, reg, region_name);
} }
kfree(buf);
} }
pos += le32_to_cpu(blk->len) + sizeof(*blk); pos += le32_to_cpu(blk->len) + sizeof(*blk);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册