Skip to content

Commit 30c2173

Browse files
vijendarmukundabroonie
authored andcommitted
ASoC: amd: acp3x: use dma address for acp3x dma driver
We shouldn't assume CPU physical address we get from page_to_phys() is same as DMA address we get from dma_alloc_coherent(). On x86_64, we won't run into any problem with the assumption when dma_ops is nommu_dma_ops. However, DMA address is IOVA when IOMMU is enabled. And it's most likely different from CPU physical address when AMD IOMMU is not in passthrough mode. This patch fixes page faults when IOMMU is enabled. Signed-off-by: Vijendar Mukunda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 8863905 commit 30c2173

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

sound/soc/amd/raven/acp3x-pcm-dma.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ struct i2s_stream_instance {
3131
u16 num_pages;
3232
u16 channels;
3333
u32 xfer_resolution;
34-
struct page *pg;
3534
u64 bytescount;
35+
dma_addr_t dma_addr;
3636
void __iomem *acp3x_base;
3737
};
3838

@@ -211,9 +211,8 @@ static irqreturn_t i2s_irq_handler(int irq, void *dev_id)
211211
static void config_acp3x_dma(struct i2s_stream_instance *rtd, int direction)
212212
{
213213
u16 page_idx;
214-
u64 addr;
215214
u32 low, high, val, acp_fifo_addr;
216-
struct page *pg = rtd->pg;
215+
dma_addr_t addr = rtd->dma_addr;
217216

218217
/* 8 scratch registers used to map one 64 bit address */
219218
if (direction == SNDRV_PCM_STREAM_PLAYBACK)
@@ -229,7 +228,6 @@ static void config_acp3x_dma(struct i2s_stream_instance *rtd, int direction)
229228

230229
for (page_idx = 0; page_idx < rtd->num_pages; page_idx++) {
231230
/* Load the low address of page int ACP SRAM through SRBM */
232-
addr = page_to_phys(pg);
233231
low = lower_32_bits(addr);
234232
high = upper_32_bits(addr);
235233

@@ -239,7 +237,7 @@ static void config_acp3x_dma(struct i2s_stream_instance *rtd, int direction)
239237
+ 4);
240238
/* Move to next physically contiguos page */
241239
val += 8;
242-
pg++;
240+
addr += PAGE_SIZE;
243241
}
244242

245243
if (direction == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -341,7 +339,6 @@ static int acp3x_dma_hw_params(struct snd_pcm_substream *substream,
341339
{
342340
int status;
343341
u64 size;
344-
struct page *pg;
345342
struct snd_pcm_runtime *runtime = substream->runtime;
346343
struct i2s_stream_instance *rtd = runtime->private_data;
347344

@@ -354,9 +351,8 @@ static int acp3x_dma_hw_params(struct snd_pcm_substream *substream,
354351
return status;
355352

356353
memset(substream->runtime->dma_area, 0, params_buffer_bytes(params));
357-
pg = virt_to_page(substream->dma_buffer.area);
358-
if (pg) {
359-
rtd->pg = pg;
354+
if (substream->dma_buffer.area) {
355+
rtd->dma_addr = substream->dma_buffer.addr;
360356
rtd->num_pages = (PAGE_ALIGN(size) >> PAGE_SHIFT);
361357
config_acp3x_dma(rtd, substream->stream);
362358
status = 0;

0 commit comments

Comments
 (0)