drivers: Intel: hda-dma: DMA buffer address should be correctly aligned

Add check for DMA buffer address alignment to hda_dma_set_config().
Wrongly aligned DMA buffer does not work correctly.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
This commit is contained in:
Jyri Sarha 2022-02-08 15:45:56 +02:00 committed by Liam Girdwood
parent c11562b00a
commit 5afc494671
1 changed files with 9 additions and 1 deletions

View File

@ -818,12 +818,20 @@ static int hda_dma_set_config(struct dma_chan_data *channel,
/* buffer size must be multiple of hda dma burst size */
if (buffer_bytes % HDA_DMA_BUFFER_ALIGNMENT) {
tr_err(&hdma_tr, "hda-dmac: %d chan %d - buffer not DMA aligned 0x%x",
tr_err(&hdma_tr, "hda-dmac: %d chan %d - buffer size not DMA aligned 0x%x",
dma->plat_data.id,
channel->index, buffer_bytes);
ret = -EINVAL;
goto out;
}
/* buffer base address must be correctly aligned */
if (buffer_addr % HDA_DMA_BUFFER_ADDRESS_ALIGNMENT) {
tr_err(&hdma_tr, "hda-dmac: %d chan %d - buffer address not DMA aligned 0x%x",
dma->plat_data.id,
channel->index, buffer_addr);
ret = -EINVAL;
goto out;
}
hda_chan = dma_chan_get_data(channel);
hda_chan->period_bytes = period_bytes;
hda_chan->buffer_bytes = buffer_bytes;