From 5afc494671450459be73d62a41b8da2930cc5a35 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 8 Feb 2022 15:45:56 +0200 Subject: [PATCH] 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 --- src/drivers/intel/hda/hda-dma.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/drivers/intel/hda/hda-dma.c b/src/drivers/intel/hda/hda-dma.c index 7edb93279..8aa6461f7 100644 --- a/src/drivers/intel/hda/hda-dma.c +++ b/src/drivers/intel/hda/hda-dma.c @@ -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;