diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-06-09 18:25:50 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-06-10 10:15:21 +0200 |
commit | a202bd1ad86d59c07f24f0a201c5ade320b51e30 (patch) | |
tree | 54a7ef6463fbc5e02033fd9c97d77b6a8c4df195 /sound/core/pcm_native.c | |
parent | 37af81c5998f4b0f23fb452cffa4b8a1c00ce95b (diff) | |
download | linux-a202bd1ad86d59c07f24f0a201c5ade320b51e30.tar.bz2 |
ALSA: core: Move mmap handler into memalloc ops
This patch moves the mmap handling code into the common memalloc
handler. It allows us to reduce the memory-type specific code in PCM
code gracefully.
Link: https://lore.kernel.org/r/20210609162551.7842-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/pcm_native.c')
-rw-r--r-- | sound/core/pcm_native.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 48d63dbb17ba..14e32825c339 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -3700,22 +3700,9 @@ int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *area) { area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; -#ifdef CONFIG_GENERIC_ALLOCATOR - if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_IRAM) { - area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); - return remap_pfn_range(area, area->vm_start, - substream->dma_buffer.addr >> PAGE_SHIFT, - area->vm_end - area->vm_start, area->vm_page_prot); - } -#endif /* CONFIG_GENERIC_ALLOCATOR */ - if (IS_ENABLED(CONFIG_HAS_DMA) && !substream->ops->page && - (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV || - substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_UC)) - return dma_mmap_coherent(substream->dma_buffer.dev.dev, - area, - substream->runtime->dma_area, - substream->runtime->dma_addr, - substream->runtime->dma_bytes); + if (!substream->ops->page && + !snd_dma_buffer_mmap(snd_pcm_get_dma_buf(substream), area)) + return 0; /* mmap with fault handler */ area->vm_ops = &snd_pcm_vm_ops_data_fault; return 0; |