mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-29 07:34:06 +08:00
ASoC: wm_adsp: Fix dma-unsafe read of scratch registers
Stack memory isn't DMA-safe so it isn't safe to use either regmap_raw_read or regmap_bulk_read to read into stack memory. The two functions to read the scratch registers were using stack memory and regmap_raw_read. It's not worth allocating memory just for this trivial read, and it isn't time-critical. A simple regmap_read for each register is sufficient. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
16a8ee4c80
commit
20e00db2f5
@ -765,38 +765,41 @@ static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *mem,
|
|||||||
|
|
||||||
static void wm_adsp2_show_fw_status(struct wm_adsp *dsp)
|
static void wm_adsp2_show_fw_status(struct wm_adsp *dsp)
|
||||||
{
|
{
|
||||||
u16 scratch[4];
|
unsigned int scratch[4];
|
||||||
|
unsigned int addr = dsp->base + ADSP2_SCRATCH0;
|
||||||
|
unsigned int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = regmap_raw_read(dsp->regmap, dsp->base + ADSP2_SCRATCH0,
|
for (i = 0; i < ARRAY_SIZE(scratch); ++i) {
|
||||||
scratch, sizeof(scratch));
|
ret = regmap_read(dsp->regmap, addr + i, &scratch[i]);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
adsp_err(dsp, "Failed to read SCRATCH regs: %d\n", ret);
|
adsp_err(dsp, "Failed to read SCRATCH%u: %d\n", i, ret);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n",
|
adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n",
|
||||||
be16_to_cpu(scratch[0]),
|
scratch[0], scratch[1], scratch[2], scratch[3]);
|
||||||
be16_to_cpu(scratch[1]),
|
|
||||||
be16_to_cpu(scratch[2]),
|
|
||||||
be16_to_cpu(scratch[3]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wm_adsp2v2_show_fw_status(struct wm_adsp *dsp)
|
static void wm_adsp2v2_show_fw_status(struct wm_adsp *dsp)
|
||||||
{
|
{
|
||||||
u32 scratch[2];
|
unsigned int scratch[2];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = regmap_raw_read(dsp->regmap, dsp->base + ADSP2V2_SCRATCH0_1,
|
ret = regmap_read(dsp->regmap, dsp->base + ADSP2V2_SCRATCH0_1,
|
||||||
scratch, sizeof(scratch));
|
&scratch[0]);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
adsp_err(dsp, "Failed to read SCRATCH regs: %d\n", ret);
|
adsp_err(dsp, "Failed to read SCRATCH0_1: %d\n", ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scratch[0] = be32_to_cpu(scratch[0]);
|
ret = regmap_read(dsp->regmap, dsp->base + ADSP2V2_SCRATCH2_3,
|
||||||
scratch[1] = be32_to_cpu(scratch[1]);
|
&scratch[1]);
|
||||||
|
if (ret) {
|
||||||
|
adsp_err(dsp, "Failed to read SCRATCH2_3: %d\n", ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n",
|
adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n",
|
||||||
scratch[0] & 0xFFFF,
|
scratch[0] & 0xFFFF,
|
||||||
|
Loading…
Reference in New Issue
Block a user