All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Takashi Iwai <tiwai@suse.de>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-mips@linux-mips.org, alsa-devel@alsa-project.org,
	Wu Zhangjin <wuzhangjin@gmail.com>,
	linux-kernel@vger.kernel.org, Wu Zhangjin <wuzj@lemote.com>
Subject: Re: [PATCH] MIPS: Fixups of ALSA memory maps
Date: Mon, 16 Nov 2009 18:43:24 +0100	[thread overview]
Message-ID: <20091116174324.GA17748@linux-mips.org> (raw)
In-Reply-To: <s5hd43iiebt.wl%tiwai@suse.de>

On Mon, Nov 16, 2009 at 06:12:22PM +0100, Takashi Iwai wrote:

> Actually, this has been a looong-standing problem.
> I have a series of patches to fix these issues, but it's more
> intensively involved with dma_*() functions.
> 
> The patches can be found in test/dma-fix branch of sound GIT tree.
>   git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git test/dma-fix
> 
> This basically adds dma_mmap_coherent() function to feasible
> architectures, which is already implemented for ARM, so far.

Cool - but needs a little further tweaking to work right.  That's a
solution which will use uncached accesses on all MIPS systems.

IP27/IP35-family machines will explode when you try that.  Eventually the
cache coherency logic will notice that cache, directory caches and memory
have become inconsistent and bombard the CPU with a bunch of nasty
exceptions.

For cache-coherent machines otoh it's a big waste of performance.

int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
                      void *cpu_addr, dma_addr_t handle, size_t size)
{
        struct page *pg;

	if (!plat_device_is_coherent(dev))
		vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
        cpu_addr = (void *)dma_addr_to_virt(handle);
        pg = virt_to_page(cpu_addr);

        return remap_pfn_range(vma, vma->vm_start,
                               page_to_pfn(pg) + vma->vm_pgoff,
                               size, vma->vm_page_prot);
}
EXPORT_SYMBOL(dma_mmap_coherent);

Thomas - you're the IP28 specialist.  Would the plat_device_is_coherent()
above have to become a cpu_is_noncoherent_r10000() call?  Any further
nasties?

  Ralf

WARNING: multiple messages have this Message-ID (diff)
From: Ralf Baechle <ralf@linux-mips.org>
To: Takashi Iwai <tiwai@suse.de>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Wu Zhangjin <wuzhangjin@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>,
	alsa-devel@alsa-project.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, Wu Zhangjin <wuzj@lemote.com>
Subject: Re: [PATCH] MIPS: Fixups of ALSA memory maps
Date: Mon, 16 Nov 2009 18:43:24 +0100	[thread overview]
Message-ID: <20091116174324.GA17748@linux-mips.org> (raw)
In-Reply-To: <s5hd43iiebt.wl%tiwai@suse.de>

On Mon, Nov 16, 2009 at 06:12:22PM +0100, Takashi Iwai wrote:

> Actually, this has been a looong-standing problem.
> I have a series of patches to fix these issues, but it's more
> intensively involved with dma_*() functions.
> 
> The patches can be found in test/dma-fix branch of sound GIT tree.
>   git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git test/dma-fix
> 
> This basically adds dma_mmap_coherent() function to feasible
> architectures, which is already implemented for ARM, so far.

Cool - but needs a little further tweaking to work right.  That's a
solution which will use uncached accesses on all MIPS systems.

IP27/IP35-family machines will explode when you try that.  Eventually the
cache coherency logic will notice that cache, directory caches and memory
have become inconsistent and bombard the CPU with a bunch of nasty
exceptions.

For cache-coherent machines otoh it's a big waste of performance.

int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
                      void *cpu_addr, dma_addr_t handle, size_t size)
{
        struct page *pg;

	if (!plat_device_is_coherent(dev))
		vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
        cpu_addr = (void *)dma_addr_to_virt(handle);
        pg = virt_to_page(cpu_addr);

        return remap_pfn_range(vma, vma->vm_start,
                               page_to_pfn(pg) + vma->vm_pgoff,
                               size, vma->vm_page_prot);
}
EXPORT_SYMBOL(dma_mmap_coherent);

Thomas - you're the IP28 specialist.  Would the plat_device_is_coherent()
above have to become a cpu_is_noncoherent_r10000() call?  Any further
nasties?

  Ralf

  reply	other threads:[~2009-11-16 17:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-16 16:48 [PATCH] MIPS: Fixups of ALSA memory maps Wu Zhangjin
2009-11-16 17:06 ` Ralf Baechle
2009-11-16 17:06   ` Ralf Baechle
2009-11-16 17:14   ` Takashi Iwai
2009-11-16 17:14     ` Takashi Iwai
2009-11-17 13:50     ` Ralf Baechle
2009-11-17 13:50       ` Ralf Baechle
2009-11-16 17:12 ` Takashi Iwai
2009-11-16 17:12   ` Takashi Iwai
2009-11-16 17:43   ` Ralf Baechle [this message]
2009-11-16 17:43     ` Ralf Baechle
2009-11-17  9:29     ` Takashi Iwai
2009-11-17  9:29       ` Takashi Iwai
2009-11-18 14:20       ` Ralf Baechle
2009-11-18 14:20         ` Ralf Baechle
2009-11-18 17:47         ` Takashi Iwai
2009-11-18 17:47           ` Takashi Iwai
2009-11-21 12:31           ` Wu Zhangjin
2009-11-23  8:56             ` Takashi Iwai
2009-11-23  8:56               ` Takashi Iwai
2009-11-23 12:36               ` Ralf Baechle
2009-11-23 12:36                 ` Ralf Baechle
2009-11-26 14:51                 ` Takashi Iwai
2009-11-26 14:51                   ` Takashi Iwai

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=20091116174324.GA17748@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=tiwai@suse.de \
    --cc=tsbogend@alpha.franken.de \
    --cc=wuzhangjin@gmail.com \
    --cc=wuzj@lemote.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.