All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Pawel MOLL <pawel.moll@st.com>
Cc: alsa-devel@alsa-project.org, linux-sh@vger.kernel.org
Subject: Re: [alsa-devel] Audio buffer mmap-ing on sh arch vs. cache	aliasing	problem
Date: Fri, 26 Sep 2008 12:04:23 +0200	[thread overview]
Message-ID: <s5hbpybcjfc.wl%tiwai@suse.de> (raw)
In-Reply-To: <1222354553.28498.30.camel@bri1004.bri.st.com>

At Thu, 25 Sep 2008 15:55:53 +0100,
Pawel MOLL wrote:
> 
> > One thing we can try is a patch like below.  But, I'm not sure whether
> > this is correct over all architectures, too.  At best, a generic API
> > would be helpful for such a thing...
> > +	area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
> 
> Well, it's not enough, because the kernel mapping of buffer is still
> cached... A hack below does the job, but it is not nice as well...

Yeah, that's not sexy, but maybe the only working case right now
(better with arch-specific ifdefs).

IIRC, a similar buffer handling (via vmalloc) is used in video
drivers.  I suppose they don't work as well, right?
DRM driver uses __vmalloc() with PAGE_KERNEL_NOCACHE, but it's only
for PPC32 non-coherent.


Takashi


> 
> Cheers
> 
> Paweł
> 
> diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
> index 59b29cd..304f9e5 100644
> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -3159,6 +3159,9 @@ static struct vm_operations_struct snd_pcm_vm_ops_data =
>  static int snd_pcm_default_mmap(struct snd_pcm_substream *substream,
>                                 struct vm_area_struct *area)
>  {
> +#ifdef pgprot_noncached
> +       area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
> +#endif
>         area->vm_ops = &snd_pcm_vm_ops_data;
>         area->vm_private_data = substream;
>         area->vm_flags |= VM_RESERVED;
> diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
> index 7bd5852..c98a4ec 100644
> --- a/sound/usb/usbaudio.c
> +++ b/sound/usb/usbaudio.c
> @@ -714,7 +714,8 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t s
>                         return 0; /* already large enough */
>                 vfree(runtime->dma_area);
>         }
> -       runtime->dma_area = vmalloc(size);
> +       runtime->dma_area = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM,
> +                       PAGE_KERNEL_NOCACHE);
>         if (! runtime->dma_area)
>                 return -ENOMEM;
>         runtime->dma_bytes = size;
> 

WARNING: multiple messages have this Message-ID (diff)
From: Takashi Iwai <tiwai@suse.de>
To: Pawel MOLL <pawel.moll@st.com>
Cc: alsa-devel@alsa-project.org, linux-sh@vger.kernel.org
Subject: Re: [alsa-devel] Audio buffer mmap-ing on sh arch vs. cache	aliasing	problem
Date: Fri, 26 Sep 2008 10:04:23 +0000	[thread overview]
Message-ID: <s5hbpybcjfc.wl%tiwai@suse.de> (raw)
In-Reply-To: <1222354553.28498.30.camel@bri1004.bri.st.com>

At Thu, 25 Sep 2008 15:55:53 +0100,
Pawel MOLL wrote:
> 
> > One thing we can try is a patch like below.  But, I'm not sure whether
> > this is correct over all architectures, too.  At best, a generic API
> > would be helpful for such a thing...
> > +	area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
> 
> Well, it's not enough, because the kernel mapping of buffer is still
> cached... A hack below does the job, but it is not nice as well...

Yeah, that's not sexy, but maybe the only working case right now
(better with arch-specific ifdefs).

IIRC, a similar buffer handling (via vmalloc) is used in video
drivers.  I suppose they don't work as well, right?
DRM driver uses __vmalloc() with PAGE_KERNEL_NOCACHE, but it's only
for PPC32 non-coherent.


Takashi


> 
> Cheers
> 
> Paweł
> 
> diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
> index 59b29cd..304f9e5 100644
> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -3159,6 +3159,9 @@ static struct vm_operations_struct snd_pcm_vm_ops_data >  static int snd_pcm_default_mmap(struct snd_pcm_substream *substream,
>                                 struct vm_area_struct *area)
>  {
> +#ifdef pgprot_noncached
> +       area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
> +#endif
>         area->vm_ops = &snd_pcm_vm_ops_data;
>         area->vm_private_data = substream;
>         area->vm_flags |= VM_RESERVED;
> diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
> index 7bd5852..c98a4ec 100644
> --- a/sound/usb/usbaudio.c
> +++ b/sound/usb/usbaudio.c
> @@ -714,7 +714,8 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t s
>                         return 0; /* already large enough */
>                 vfree(runtime->dma_area);
>         }
> -       runtime->dma_area = vmalloc(size);
> +       runtime->dma_area = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM,
> +                       PAGE_KERNEL_NOCACHE);
>         if (! runtime->dma_area)
>                 return -ENOMEM;
>         runtime->dma_bytes = size;
> 

  reply	other threads:[~2008-09-26 10:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-04 11:23 Audio buffer mmap-ing on sh arch vs. cache aliasing problem Pawel MOLL
2008-09-04 11:23 ` Pawel MOLL
2008-09-16 18:18 ` [alsa-devel] " Takashi Iwai
2008-09-16 18:18   ` Takashi Iwai
2008-09-21  1:13   ` Paul Mundt
2008-09-21  1:13     ` Paul Mundt
2008-09-25 14:55   ` Pawel MOLL
2008-09-25 14:55     ` [alsa-devel] Audio buffer mmap-ing on sh arch vs. cache Pawel MOLL
2008-09-26 10:04     ` Takashi Iwai [this message]
2008-09-26 10:04       ` [alsa-devel] Audio buffer mmap-ing on sh arch vs. cache aliasing problem Takashi Iwai
2008-09-26 10:30       ` Paul Mundt
2008-09-26 10:30         ` [alsa-devel] " Paul Mundt
2008-09-26 11:04         ` Takashi Iwai
2008-09-26 11:04           ` Takashi Iwai
2008-09-26 11:25         ` Pawel MOLL
2008-09-26 11:25           ` [alsa-devel] Audio buffer mmap-ing on sh arch vs Pawel MOLL
2008-09-26 12:38           ` Audio buffer mmap-ing on sh arch vs. cache aliasing problem Takashi Iwai
2008-09-26 12:38             ` [alsa-devel] " Takashi Iwai
2010-01-15  0:04       ` Paul Mundt
2010-01-15  0:04         ` Paul Mundt
2010-01-16 10:05         ` Takashi Iwai
2010-01-16 10:05           ` Takashi Iwai
2010-01-16 10:20           ` Paul Mundt
2010-01-16 10:20             ` Paul Mundt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hbpybcjfc.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=pawel.moll@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.