From cdb498acb4ffe458b3c5813d825c5faaddd4c419 Mon Sep 17 00:00:00 2001 From: Ramesh Babu K V Date: Wed, 4 Apr 2012 14:00:41 +0530 Subject: [PATCH] hdmi-audio:mark the alsa ring buffer memory as uncached BZ: 29792 When mmap method of driver is called, driver remaps the buffers to user space using remap_pfn_range(). However this doesn't guaranteed to mark the pages as non-cacheble. As per Documentation/x86/pat.txt, if RAM region is mmap'ed then in addition remap_pfn_range() we need to use set_memory_uc() for marking pages as uncacheble. Change-Id: I0152bb0cea1d0aef4b2eca9f82e59d932b1939a6 Signed-off-by: Ramesh Babu K V Reviewed-on: http://android.intel.com:8080/42472 Reviewed-by: Abdullah, Omair M Reviewed-by: Vinnakota, Lakshmi N Reviewed-by: Gupta, ArvindX K Reviewed-by: Hibare, PramodX Tested-by: Hibare, PramodX Reviewed-by: buildbot Tested-by: buildbot --- sound/drivers/intel_mid_hdmi/intel_mid_hdmi_audio.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sound/drivers/intel_mid_hdmi/intel_mid_hdmi_audio.c b/sound/drivers/intel_mid_hdmi/intel_mid_hdmi_audio.c index 64481bc..637fb5c 100644 --- a/sound/drivers/intel_mid_hdmi/intel_mid_hdmi_audio.c +++ b/sound/drivers/intel_mid_hdmi/intel_mid_hdmi_audio.c @@ -692,8 +692,8 @@ static int snd_intelhad_close(struct snd_pcm_substream *substream) static int snd_intelhad_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { - int retval; - u32 buf_size; + unsigned long addr; + int pages, buf_size, retval; BUG_ON(!hw_params); @@ -708,6 +708,14 @@ static int snd_intelhad_hw_params(struct snd_pcm_substream *substream, if (retval < 0) return retval; pr_debug("%s:allocated memory = %d\n", __func__, buf_size); + /* mark the pages as uncached region */ + addr = (unsigned long) substream->runtime->dma_area; + pages = (substream->runtime->dma_bytes + PAGE_SIZE - 1) / PAGE_SIZE; + retval = set_memory_uc(addr, pages); + if (retval) { + pr_err("set_memory_uc failed.Error:%d\n", retval); + return retval; + } memset(substream->runtime->dma_area, 0, buf_size); return retval; @@ -724,7 +732,15 @@ static int snd_intelhad_hw_params(struct snd_pcm_substream *substream, */ static int snd_intelhad_hw_free(struct snd_pcm_substream *substream) { + unsigned long addr; + u32 pages; + pr_debug("snd_intelhad_hw_free called\n"); + + /* mark back the pages as cached/writeback region before the free */ + addr = (unsigned long) substream->runtime->dma_area; + pages = (substream->runtime->dma_bytes + PAGE_SIZE - 1) / PAGE_SIZE; + set_memory_wb(addr, pages); return snd_pcm_lib_free_pages(substream); } @@ -1053,6 +1069,7 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer( static int snd_intelhad_pcm_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma) { + pr_debug("entry with prot:%s\n", __func__); vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); return remap_pfn_range(vma, vma->vm_start, -- 2.7.4