Skip to content

Commit 451d85c

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: Intel: Skylake: Use SG allocation for SKL-based firmware load
Resign from ->alloc_dma_buf() and use snd_dma_alloc_pages() directly. For data i.e.: base firmware binary transfer, make use of SG allocation to better adapt to memory-limited environment. For BDL descriptor, given its small size this is not required. Signed-off-by: Cezary Rojewski <[email protected]> Tested-by: Lukasz Majczak <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 1711072 commit 451d85c

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

sound/soc/intel/skylake/skl-sst-cldma.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/io.h>
1212
#include <linux/mm.h>
1313
#include <linux/delay.h>
14+
#include <sound/hda_register.h>
1415
#include "../common/sst-dsp.h"
1516
#include "../common/sst-dsp-priv.h"
1617

@@ -79,21 +80,25 @@ static void skl_cldma_setup_bdle(struct sst_dsp *ctx,
7980
__le32 **bdlp, int size, int with_ioc)
8081
{
8182
__le32 *bdl = *bdlp;
83+
int remaining = ctx->cl_dev.bufsize;
84+
int offset = 0;
8285

8386
ctx->cl_dev.frags = 0;
84-
while (size > 0) {
85-
phys_addr_t addr = virt_to_phys(dmab_data->area +
86-
(ctx->cl_dev.frags * ctx->cl_dev.bufsize));
87+
while (remaining > 0) {
88+
phys_addr_t addr;
89+
int chunk;
8790

91+
addr = snd_sgbuf_get_addr(dmab_data, offset);
8892
bdl[0] = cpu_to_le32(lower_32_bits(addr));
8993
bdl[1] = cpu_to_le32(upper_32_bits(addr));
94+
chunk = snd_sgbuf_get_chunk_size(dmab_data, offset, size);
95+
bdl[2] = cpu_to_le32(chunk);
9096

91-
bdl[2] = cpu_to_le32(ctx->cl_dev.bufsize);
92-
93-
size -= ctx->cl_dev.bufsize;
94-
bdl[3] = (size || !with_ioc) ? 0 : cpu_to_le32(0x01);
97+
remaining -= chunk;
98+
bdl[3] = (remaining > 0) ? 0 : cpu_to_le32(0x01);
9599

96100
bdl += 4;
101+
offset += chunk;
97102
ctx->cl_dev.frags++;
98103
}
99104
}
@@ -338,15 +343,15 @@ int skl_cldma_prepare(struct sst_dsp *ctx)
338343
ctx->cl_dev.ops.cl_stop_dma = skl_cldma_stop;
339344

340345
/* Allocate buffer*/
341-
ret = ctx->dsp_ops.alloc_dma_buf(ctx->dev,
342-
&ctx->cl_dev.dmab_data, ctx->cl_dev.bufsize);
346+
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG, ctx->dev, ctx->cl_dev.bufsize,
347+
&ctx->cl_dev.dmab_data);
343348
if (ret < 0) {
344349
dev_err(ctx->dev, "Alloc buffer for base fw failed: %x\n", ret);
345350
return ret;
346351
}
352+
347353
/* Setup Code loader BDL */
348-
ret = ctx->dsp_ops.alloc_dma_buf(ctx->dev,
349-
&ctx->cl_dev.dmab_bdl, PAGE_SIZE);
354+
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, ctx->dev, BDL_SIZE, &ctx->cl_dev.dmab_bdl);
350355
if (ret < 0) {
351356
dev_err(ctx->dev, "Alloc buffer for blde failed: %x\n", ret);
352357
ctx->dsp_ops.free_dma_buf(ctx->dev, &ctx->cl_dev.dmab_data);

0 commit comments

Comments
 (0)