All of lore.kernel.org
 help / color / mirror / Atom feed
* ALSA on MIPS platform
@ 2006-01-25 14:50 Atsushi Nemoto
  2006-01-25 19:03 ` Takashi Iwai
  0 siblings, 1 reply; 41+ messages in thread
From: Atsushi Nemoto @ 2006-01-25 14:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: tbm, t.sailer, perex, ralf

Hi.  I'm using PCI Sound cards on MIPS platform which has noncoherent
DMA.  There are some issues in ALSA for these platform.

(This topic comes from linux-mips ML.
http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=20060124030725.GA14063%40deprecation.cyrius.com)


1. virt_to_page vs. dma_alloc_coherent problem.

ALSA uses virt_to_page() to get 'struct page' for DMA area which was
allocated using dma_alloc_coherent().  On MIPS with
CONFIG_DMA_NONCOHERENT, typically physical address range
0x0-0x1fffffff are mapped to 0x8000000-0x9fffffff with cached and
mapped to 0xa0000000-0xbfffffff with uncached.  If we got physical
address 0x01000000 for DMA, the virtual address is 0xa1000000.  On the
other hand, virt_to_page() expects normal(cached) virtual address.  So
we can use virt_to_page() with kmalloc() or dma_alloc_noncoherent(),
but not with dma_alloc_coherent().

Here is some fragments from kernel code.  You can see what I mean exactly.

/* from include/asm-mips/mach-generic/spaces.h */
#define CAC_BASE		0x80000000
#define UNCAC_BASE		0xa0000000
#define PAGE_OFFSET		0x80000000UL
/* from include/asm-mips/page.h */
#define __pa(x)			((unsigned long) (x) - PAGE_OFFSET)
#define __va(x)			((void *)((unsigned long) (x) + PAGE_OFFSET))
#define pfn_to_page(pfn)	(mem_map + (pfn))
#define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
#define UNCAC_ADDR(addr)	((addr) - PAGE_OFFSET + UNCAC_BASE)
#define CAC_ADDR(addr)		((addr) - UNCAC_BASE + PAGE_OFFSET)
/* from arch/mips/mm/dma-noncoherent.c */
void *dma_alloc_coherent(struct device *dev, size_t size,
	dma_addr_t * dma_handle, gfp_t gfp)
{
	void *ret;

	ret = dma_alloc_noncoherent(dev, size, dma_handle, gfp);
	if (ret) {
		dma_cache_wback_inv((unsigned long) ret, size);
		ret = UNCAC_ADDR(ret);
	}

	return ret;
}

How do we fix this?

A.  hack sound/core/memalloc.c, pcm_native.c, sgbuf.c

something like:
#if defined(__mips__) && defined(CONFIG_DMA_NONCOHERENT)
		mark_pages(virt_to_page(CAC_ADDR(res)), pg); /* should be dma_to_page() */
#else
		mark_pages(virt_to_page(res), pg); /* should be dma_to_page() */
#endif

It's ugly.

B.  fix mips virt_to_page()

#define TO_PHYS_MASK 0x1fffffff
#define virt_to_page(kaddr)	pfn_to_page(((kaddr) & TO_PHYS_MASK) >> PAGE_SHIFT)

a bit slower.  MIPS need one instruction to create 0x80000000
constant, two instruction for 0x1fffffff.  There are many usage of
virt_to_page() in mm/slab.c so its performance might be important.

C.  introduce dma_to_page() which returns struct page * for dma_addr_t.

The comment in ALSA code (/* should be dma_to_page() */) mean this?

For MIPS, it would be:
#define dma_to_page(addr) pfn_to_page((addr) >> PAGE_SHIFT)
But I do not know for other platform.


Which is preferred, or is there other good way?


2. mmapping DMA area.

As described above, DMA area is uncached on those platform.  So mmap
should ensure user programs do not cache these area.
snd_pcm_default_mmap() is used for mmapping the DMA area but its
vm_page_prot is not configured as uncached.  On the other hand,
snd_pcm_lib_mmap_iomem() do it using pgprot_noncached().

snd_pcm_default_mmap() should do same thing for those MIPS platform.

static int snd_pcm_default_mmap(struct snd_pcm_substream *substream,
				struct vm_area_struct *area)
{
#if defined(__mips__) && defined(CONFIG_DMA_NONCOHERENT)
	area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
#endif
	area->vm_ops = &snd_pcm_vm_ops_data;

Is this a right fix?  Are there any platform which have same problem?


---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-25 14:50 Atsushi Nemoto
@ 2006-01-25 19:03 ` Takashi Iwai
  2006-01-26 15:29   ` Atsushi Nemoto
  0 siblings, 1 reply; 41+ messages in thread
From: Takashi Iwai @ 2006-01-25 19:03 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-kernel, tbm, t.sailer, perex, ralf

At Wed, 25 Jan 2006 23:50:07 +0900 (JST),
Atsushi Nemoto wrote:
> 
> Hi.  I'm using PCI Sound cards on MIPS platform which has noncoherent
> DMA.  There are some issues in ALSA for these platform.
> 
> (This topic comes from linux-mips ML.
> http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=20060124030725.GA14063%40deprecation.cyrius.com)
> 
> 
> 1. virt_to_page vs. dma_alloc_coherent problem.
> 
> ALSA uses virt_to_page() to get 'struct page' for DMA area which was
> allocated using dma_alloc_coherent().  On MIPS with
> CONFIG_DMA_NONCOHERENT, typically physical address range
> 0x0-0x1fffffff are mapped to 0x8000000-0x9fffffff with cached and
> mapped to 0xa0000000-0xbfffffff with uncached.  If we got physical
> address 0x01000000 for DMA, the virtual address is 0xa1000000.  On the
> other hand, virt_to_page() expects normal(cached) virtual address.  So
> we can use virt_to_page() with kmalloc() or dma_alloc_noncoherent(),
> but not with dma_alloc_coherent().
> 
> Here is some fragments from kernel code.  You can see what I mean exactly.
> 
> /* from include/asm-mips/mach-generic/spaces.h */
> #define CAC_BASE		0x80000000
> #define UNCAC_BASE		0xa0000000
> #define PAGE_OFFSET		0x80000000UL
> /* from include/asm-mips/page.h */
> #define __pa(x)			((unsigned long) (x) - PAGE_OFFSET)
> #define __va(x)			((void *)((unsigned long) (x) + PAGE_OFFSET))
> #define pfn_to_page(pfn)	(mem_map + (pfn))
> #define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
> #define UNCAC_ADDR(addr)	((addr) - PAGE_OFFSET + UNCAC_BASE)
> #define CAC_ADDR(addr)		((addr) - UNCAC_BASE + PAGE_OFFSET)
> /* from arch/mips/mm/dma-noncoherent.c */
> void *dma_alloc_coherent(struct device *dev, size_t size,
> 	dma_addr_t * dma_handle, gfp_t gfp)
> {
> 	void *ret;
> 
> 	ret = dma_alloc_noncoherent(dev, size, dma_handle, gfp);
> 	if (ret) {
> 		dma_cache_wback_inv((unsigned long) ret, size);
> 		ret = UNCAC_ADDR(ret);
> 	}
> 
> 	return ret;
> }
> 
> How do we fix this?
> 
> A.  hack sound/core/memalloc.c, pcm_native.c, sgbuf.c
> 
> something like:
> #if defined(__mips__) && defined(CONFIG_DMA_NONCOHERENT)
> 		mark_pages(virt_to_page(CAC_ADDR(res)), pg); /* should be dma_to_page() */
> #else
> 		mark_pages(virt_to_page(res), pg); /* should be dma_to_page() */
> #endif
> 
> It's ugly.
> 
> B.  fix mips virt_to_page()
> 
> #define TO_PHYS_MASK 0x1fffffff
> #define virt_to_page(kaddr)	pfn_to_page(((kaddr) & TO_PHYS_MASK) >> PAGE_SHIFT)
> 
> a bit slower.  MIPS need one instruction to create 0x80000000
> constant, two instruction for 0x1fffffff.  There are many usage of
> virt_to_page() in mm/slab.c so its performance might be important.
> 
> C.  introduce dma_to_page() which returns struct page * for dma_addr_t.
> 
> The comment in ALSA code (/* should be dma_to_page() */) mean this?
> 
> For MIPS, it would be:
> #define dma_to_page(addr) pfn_to_page((addr) >> PAGE_SHIFT)
> But I do not know for other platform.
> 
> 
> Which is preferred, or is there other good way?
> 
> 
> 2. mmapping DMA area.
> 
> As described above, DMA area is uncached on those platform.  So mmap
> should ensure user programs do not cache these area.
> snd_pcm_default_mmap() is used for mmapping the DMA area but its
> vm_page_prot is not configured as uncached.  On the other hand,
> snd_pcm_lib_mmap_iomem() do it using pgprot_noncached().
> 
> snd_pcm_default_mmap() should do same thing for those MIPS platform.
> 
> static int snd_pcm_default_mmap(struct snd_pcm_substream *substream,
> 				struct vm_area_struct *area)
> {
> #if defined(__mips__) && defined(CONFIG_DMA_NONCOHERENT)
> 	area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
> #endif
> 	area->vm_ops = &snd_pcm_vm_ops_data;
> 
> Is this a right fix?  Are there any platform which have same problem?

The right fix is, IMO, to port dma_mmap_coherent() to all archs.
Currently, it's only on ARM.


Takashi

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-25 19:03 ` Takashi Iwai
@ 2006-01-26 15:29   ` Atsushi Nemoto
  2006-01-26 16:02     ` Takashi Iwai
  0 siblings, 1 reply; 41+ messages in thread
From: Atsushi Nemoto @ 2006-01-26 15:29 UTC (permalink / raw)
  To: tiwai; +Cc: linux-kernel, tbm, t.sailer, perex, ralf

>>>>> On Wed, 25 Jan 2006 20:03:13 +0100, Takashi Iwai <tiwai@suse.de> said:

tiwai> The right fix is, IMO, to port dma_mmap_coherent() to all
tiwai> archs.  Currently, it's only on ARM.

Thanks.  Is this solve both issue #1 and #2 ?

The most part of issue #1 will vanish if NEED_RESERVE_PAGES was
defined, and currently only ARM define this.  ARM defines
NEED_RESERVE_PAGES because it has dma_mmap_coherent(), right?

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-26 15:29   ` Atsushi Nemoto
@ 2006-01-26 16:02     ` Takashi Iwai
  2006-01-26 19:19       ` Hugh Dickins
  2006-01-27 15:45       ` Atsushi Nemoto
  0 siblings, 2 replies; 41+ messages in thread
From: Takashi Iwai @ 2006-01-26 16:02 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-kernel, tbm, t.sailer, perex, ralf

At Fri, 27 Jan 2006 00:29:25 +0900 (JST),
Atsushi Nemoto wrote:
> 
> >>>>> On Wed, 25 Jan 2006 20:03:13 +0100, Takashi Iwai <tiwai@suse.de> said:
> 
> tiwai> The right fix is, IMO, to port dma_mmap_coherent() to all
> tiwai> archs.  Currently, it's only on ARM.
> 
> Thanks.  Is this solve both issue #1 and #2 ?
 
Yes.  In theory, dma_alloc_coherent() and dma_mmap_coherent() should
cover all the magic each arch requires.

> The most part of issue #1 will vanish if NEED_RESERVE_PAGES was
> defined, and currently only ARM define this.  ARM defines
> NEED_RESERVE_PAGES because it has dma_mmap_coherent(), right?

Well, the whole page-reserve kludge should disappear anyway in near
future.  Right now it's in the process.

The memory allocation stuff in ALSA is being largely rewritten on my
local tree, but it's not released yet.  One reason is to wait for the
finish of page-reserve removals, and another reason is that I've had
little time to tidy them up :)

--
Takashi Iwai <tiwai@suse.de>		ALSA Developer - www.alsa-project.org

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-26 16:02     ` Takashi Iwai
@ 2006-01-26 19:19       ` Hugh Dickins
  2006-01-27 15:45       ` Atsushi Nemoto
  1 sibling, 0 replies; 41+ messages in thread
From: Hugh Dickins @ 2006-01-26 19:19 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Atsushi Nemoto, linux-kernel, tbm, t.sailer, perex, ralf

On Thu, 26 Jan 2006, Takashi Iwai wrote:
> At Fri, 27 Jan 2006 00:29:25 +0900 (JST),
> Atsushi Nemoto wrote:
> 
> > The most part of issue #1 will vanish if NEED_RESERVE_PAGES was
> > defined, and currently only ARM define this.  ARM defines
> > NEED_RESERVE_PAGES because it has dma_mmap_coherent(), right?
> 
> Well, the whole page-reserve kludge should disappear anyway in near
> future.  Right now it's in the process.

Yes, mark_pages() and unmark_pages() can just be removed as soon as
you like.

I didn't reply to the original posting because I noticed they're not
all of the virt_to_page()s in sound/core, and sometimes a part-answer
distracts someone more competent from responding with the full answer.

And I'm in no hurry to remove these PageReserved traces myself, since
it's not a bad idea to hold on to the bad_page cross-checking for a
release or two.

Hugh

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-26 16:02     ` Takashi Iwai
  2006-01-26 19:19       ` Hugh Dickins
@ 2006-01-27 15:45       ` Atsushi Nemoto
  2006-01-27 15:49         ` Martin Michlmayr
  2006-01-27 15:57         ` Takashi Iwai
  1 sibling, 2 replies; 41+ messages in thread
From: Atsushi Nemoto @ 2006-01-27 15:45 UTC (permalink / raw)
  To: hugh; +Cc: tiwai, linux-kernel, tbm, t.sailer, perex, ralf

>>>>> On Thu, 26 Jan 2006 19:19:22 +0000 (GMT), Hugh Dickins <hugh@veritas.com> said:

>> Well, the whole page-reserve kludge should disappear anyway in near
>> future.  Right now it's in the process.

hugh> Yes, mark_pages() and unmark_pages() can just be removed as soon
hugh> as you like.

When I tried undefining NEED_RESERVE_PAGES for MIPS on 2.6.13,
something did not work (I can not remember details...).  But it seems
things have been changed in 2.6.15.  I'll try again.  Thanks.

hugh> I didn't reply to the original posting because I noticed they're
hugh> not all of the virt_to_page()s in sound/core, and sometimes a
hugh> part-answer distracts someone more competent from responding
hugh> with the full answer.

Yes, there is still virt_to_page() in snd_pcm_mmap_data_nopage() and
snd_malloc_sgbuf_pages().  If dma_mmap_coherent() was ported, former
might disappear but latter might not.  So it seems virt_to_page()
issue still remains...

>>>>> On Thu, 26 Jan 2006 17:02:53 +0100, Takashi Iwai <tiwai@suse.de> said:

tiwai> The memory allocation stuff in ALSA is being largely rewritten
tiwai> on my local tree, but it's not released yet.  One reason is to
tiwai> wait for the finish of page-reserve removals, and another
tiwai> reason is that I've had little time to tidy them up :)

OK, I'll wait.  Thank you very much.

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-27 15:45       ` Atsushi Nemoto
@ 2006-01-27 15:49         ` Martin Michlmayr
  2006-01-27 16:01           ` Takashi Iwai
  2006-01-27 15:57         ` Takashi Iwai
  1 sibling, 1 reply; 41+ messages in thread
From: Martin Michlmayr @ 2006-01-27 15:49 UTC (permalink / raw)
  To: hugh, tiwai, linux-kernel, t.sailer, perex, ralf

> tiwai> The memory allocation stuff in ALSA is being largely rewritten
> tiwai> on my local tree, but it's not released yet.  One reason is to
> tiwai> wait for the finish of page-reserve removals, and another
> tiwai> reason is that I've had little time to tidy them up :)

Do you have a rough idea when this may happen?
-- 
Martin Michlmayr
http://www.cyrius.com/

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-27 15:45       ` Atsushi Nemoto
  2006-01-27 15:49         ` Martin Michlmayr
@ 2006-01-27 15:57         ` Takashi Iwai
  2006-01-30  9:56           ` Atsushi Nemoto
  1 sibling, 1 reply; 41+ messages in thread
From: Takashi Iwai @ 2006-01-27 15:57 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: hugh, linux-kernel, tbm, t.sailer, perex, ralf

At Sat, 28 Jan 2006 00:45:40 +0900 (JST),
Atsushi Nemoto wrote:
> 
> >>>>> On Thu, 26 Jan 2006 19:19:22 +0000 (GMT), Hugh Dickins <hugh@veritas.com> said:
> 
> >> Well, the whole page-reserve kludge should disappear anyway in near
> >> future.  Right now it's in the process.
> 
> hugh> Yes, mark_pages() and unmark_pages() can just be removed as soon
> hugh> as you like.
> 
> When I tried undefining NEED_RESERVE_PAGES for MIPS on 2.6.13,
> something did not work (I can not remember details...).  But it seems
> things have been changed in 2.6.15.  I'll try again.  Thanks.

Yes, it was changed pretty much.

> hugh> I didn't reply to the original posting because I noticed they're
> hugh> not all of the virt_to_page()s in sound/core, and sometimes a
> hugh> part-answer distracts someone more competent from responding
> hugh> with the full answer.
> 
> Yes, there is still virt_to_page() in snd_pcm_mmap_data_nopage() and
> snd_malloc_sgbuf_pages().  If dma_mmap_coherent() was ported, former
> might disappear but latter might not.  So it seems virt_to_page()
> issue still remains...

In theory, you can call dma_mmap_coherent() on each page obtained via
dma_alloc_coherent() in the case of sg-buffer.  It should work without
much overhead on most of archs, but ones like sparc32 may have
problems because each alloc_coherent call results in another
allocation a resource struct (if I understand the code correctly).

So, I rewrote the code to use the normal get_page() + map/sync.
Hopefully this works for archs with non-coherent mm...


Takashi

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-27 15:49         ` Martin Michlmayr
@ 2006-01-27 16:01           ` Takashi Iwai
  0 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2006-01-27 16:01 UTC (permalink / raw)
  To: Martin Michlmayr; +Cc: hugh, linux-kernel, t.sailer, perex, ralf

At Fri, 27 Jan 2006 15:49:28 +0000,
Martin Michlmayr wrote:
> 
> > tiwai> The memory allocation stuff in ALSA is being largely rewritten
> > tiwai> on my local tree, but it's not released yet.  One reason is to
> > tiwai> wait for the finish of page-reserve removals, and another
> > tiwai> reason is that I've had little time to tidy them up :)
> 
> Do you have a rough idea when this may happen?

Hard to promise...  Hopefully I can start working seriously again on
this issue in February.


Takashi

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-27 15:57         ` Takashi Iwai
@ 2006-01-30  9:56           ` Atsushi Nemoto
  2006-01-30 10:18             ` Takashi Iwai
  0 siblings, 1 reply; 41+ messages in thread
From: Atsushi Nemoto @ 2006-01-30  9:56 UTC (permalink / raw)
  To: tiwai; +Cc: hugh, linux-kernel, tbm, t.sailer, perex, ralf

>>>>> On Fri, 27 Jan 2006 16:57:49 +0100, Takashi Iwai <tiwai@suse.de> said:
hugh> Yes, mark_pages() and unmark_pages() can just be removed as soon
hugh> as you like.

>> When I tried undefining NEED_RESERVE_PAGES for MIPS on 2.6.13,
>> something did not work (I can not remember details...).  But it seems
>> things have been changed in 2.6.15.  I'll try again.  Thanks.

tiwai> Yes, it was changed pretty much.

I undefined NEED_RESERVE_PAGES on 2.6.15 and it seems OK on MIPS.
Thank you.

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-30  9:56           ` Atsushi Nemoto
@ 2006-01-30 10:18             ` Takashi Iwai
  2006-01-30 10:38               ` Atsushi Nemoto
                                 ` (2 more replies)
  0 siblings, 3 replies; 41+ messages in thread
From: Takashi Iwai @ 2006-01-30 10:18 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: hugh, linux-kernel, tbm, t.sailer, perex, ralf

At Mon, 30 Jan 2006 18:56:08 +0900 (JST),
Atsushi Nemoto wrote:
> 
> >>>>> On Fri, 27 Jan 2006 16:57:49 +0100, Takashi Iwai <tiwai@suse.de> said:
> hugh> Yes, mark_pages() and unmark_pages() can just be removed as soon
> hugh> as you like.
> 
> >> When I tried undefining NEED_RESERVE_PAGES for MIPS on 2.6.13,
> >> something did not work (I can not remember details...).  But it seems
> >> things have been changed in 2.6.15.  I'll try again.  Thanks.
> 
> tiwai> Yes, it was changed pretty much.
> 
> I undefined NEED_RESERVE_PAGES on 2.6.15 and it seems OK on MIPS.
> Thank you.

Well, as Hugu pointed out, that page reservation plays no longer any
role.  The patch below should work too on 2.6.15 or later.


Takashi


--- linux/sound/core/memalloc.c	23 Jan 2006 15:53:15 -0000	1.52
+++ linux/sound/core/memalloc.c	30 Jan 2006 10:16:31 -0000
@@ -141,10 +141,6 @@
 
 #endif /* arch */
 
-#if ! defined(__arm__)
-#define NEED_RESERVE_PAGES
-#endif
-
 /*
  *
  *  Generic memory allocators
@@ -163,20 +159,6 @@
 	snd_allocated_pages -= 1 << order;
 }
 
-static void mark_pages(struct page *page, int order)
-{
-	struct page *last_page = page + (1 << order);
-	while (page < last_page)
-		SetPageReserved(page++);
-}
-
-static void unmark_pages(struct page *page, int order)
-{
-	struct page *last_page = page + (1 << order);
-	while (page < last_page)
-		ClearPageReserved(page++);
-}
-
 /**
  * snd_malloc_pages - allocate pages with the given size
  * @size: the size to allocate in bytes
@@ -195,10 +177,8 @@
 	snd_assert(gfp_flags != 0, return NULL);
 	gfp_flags |= __GFP_COMP;	/* compound page lets parts be mapped */
 	pg = get_order(size);
-	if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL) {
-		mark_pages(virt_to_page(res), pg);
+	if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL)
 		inc_snd_pages(pg);
-	}
 	return res;
 }
 
@@ -217,7 +197,6 @@
 		return;
 	pg = get_order(size);
 	dec_snd_pages(pg);
-	unmark_pages(virt_to_page(ptr), pg);
 	free_pages((unsigned long) ptr, pg);
 }
 
@@ -242,12 +221,8 @@
 		| __GFP_NORETRY /* don't trigger OOM-killer */
 		| __GFP_NOWARN; /* no stack trace print - this call is non-critical */
 	res = dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags);
-	if (res != NULL) {
-#ifdef NEED_RESERVE_PAGES
-		mark_pages(virt_to_page(res), pg); /* should be dma_to_page() */
-#endif
+	if (res != NULL)
 		inc_snd_pages(pg);
-	}
 
 	return res;
 }
@@ -262,9 +237,6 @@
 		return;
 	pg = get_order(size);
 	dec_snd_pages(pg);
-#ifdef NEED_RESERVE_PAGES
-	unmark_pages(virt_to_page(ptr), pg); /* should be dma_to_page() */
-#endif
 	dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma);
 }
 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-30 10:18             ` Takashi Iwai
@ 2006-01-30 10:38               ` Atsushi Nemoto
  2006-01-30 12:25               ` Ralf Baechle
  2006-01-30 15:46               ` Martin Michlmayr
  2 siblings, 0 replies; 41+ messages in thread
From: Atsushi Nemoto @ 2006-01-30 10:38 UTC (permalink / raw)
  To: tiwai; +Cc: hugh, linux-kernel, tbm, t.sailer, perex, ralf

>>>>> On Mon, 30 Jan 2006 11:18:54 +0100, Takashi Iwai <tiwai@suse.de> said:
tiwai> Well, as Hugu pointed out, that page reservation plays no longer any
tiwai> role.  The patch below should work too on 2.6.15 or later.

The patch works for me.  Thank you.

Acked-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-30 10:18             ` Takashi Iwai
  2006-01-30 10:38               ` Atsushi Nemoto
@ 2006-01-30 12:25               ` Ralf Baechle
  2006-01-30 15:46               ` Martin Michlmayr
  2 siblings, 0 replies; 41+ messages in thread
From: Ralf Baechle @ 2006-01-30 12:25 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Atsushi Nemoto, hugh, linux-kernel, tbm, t.sailer, perex

On Mon, Jan 30, 2006 at 11:18:54AM +0100, Takashi Iwai wrote:

> > I undefined NEED_RESERVE_PAGES on 2.6.15 and it seems OK on MIPS.
> > Thank you.
> 
> Well, as Hugu pointed out, that page reservation plays no longer any
> role.  The patch below should work too on 2.6.15 or later.

That resolves the portability issues with the assumption on the return
value of dma_alloc_coherent(), thanks.

Acked-by: Ralf Baechle <ralf@linux-mips.org>

  Ralf

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-30 10:18             ` Takashi Iwai
  2006-01-30 10:38               ` Atsushi Nemoto
  2006-01-30 12:25               ` Ralf Baechle
@ 2006-01-30 15:46               ` Martin Michlmayr
  2006-01-30 15:52                 ` Takashi Iwai
  2 siblings, 1 reply; 41+ messages in thread
From: Martin Michlmayr @ 2006-01-30 15:46 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Atsushi Nemoto, hugh, linux-kernel, t.sailer, perex, ralf

* Takashi Iwai <tiwai@suse.de> [2006-01-30 11:18]:
> Well, as Hugu pointed out, that page reservation plays no longer any
> role.  The patch below should work too on 2.6.15 or later.

It doesn't solve the problem I have, those "wait source ready timeout
0x1410 [0x8c8c8c8c]" messages on a Cobalt Qube2 with a 64-bit MIPS
kernel.


Detecting hardware: de4x5 via82cxxx es1371 usb_uhci
de4x5 disabled in configuration.
Skipping unavailable/built-in via82cxxx module.
Skipping unavailable/built-in es1371 module.
Loading uhci_hcd module.
usbcore: registered new driver usbfs
usbcore: registered new driver hub
USB Universal Host Controller Interface driver v2.3
uhci_hcd 0000:00:09.2: Found HC with no IRQ.  Check BIOS/PCI 0000:00:09.2 setup!
uhci_hcd 0000:00:09.2: init 0000:00:09.2 fail, -19
Running 0dns-down to make sure resolv.conf is ok...done.
Setting up networking...done.
Starting hotplug subsystem:
   pci     
     uhci-hcd: already loaded
wait source ready timeout 0x1410 [0x8c8c8c8c]  <- repeated 180 times
AC'97 0 analog subsections not ready
wait source ready timeout 0x1410 [0x8c8c8c8c] <- repeated 453 times
     snd-ens1371: loaded successfully
   pci      [success]
   usb     
   usb      [success]
   isapnp  
   isapnp   [success]
   ide     
   ide      [success]
   input   
   input    [success]
   scsi    
   scsi     [success]
done.
Setting up IP spoofing protection: rp_filter.
Configuring network interfaces...done.
Starting portmap daemon: portmap.

-- 
Martin Michlmayr
http://www.cyrius.com/

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2006-01-30 15:46               ` Martin Michlmayr
@ 2006-01-30 15:52                 ` Takashi Iwai
  0 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2006-01-30 15:52 UTC (permalink / raw)
  To: Martin Michlmayr
  Cc: Atsushi Nemoto, hugh, linux-kernel, t.sailer, perex, ralf

At Mon, 30 Jan 2006 15:46:17 +0000,
Martin Michlmayr wrote:
> 
> * Takashi Iwai <tiwai@suse.de> [2006-01-30 11:18]:
> > Well, as Hugu pointed out, that page reservation plays no longer any
> > role.  The patch below should work too on 2.6.15 or later.
> 
> It doesn't solve the problem I have, those "wait source ready timeout
> 0x1410 [0x8c8c8c8c]" messages on a Cobalt Qube2 with a 64-bit MIPS
> kernel.

Of course not.  Your problem is totally irrelevant with the page
allocation stuff we discussed.


> wait source ready timeout 0x1410 [0x8c8c8c8c]  <- repeated 180 times
> AC'97 0 analog subsections not ready
> wait source ready timeout 0x1410 [0x8c8c8c8c] <- repeated 453 times
>      snd-ens1371: loaded successfully

The messages above imply that the h/w access doesn't work properly,
e.g. the wrong PCI resource assignment or the insufficient
initialization.


Takashi

^ permalink raw reply	[flat|nested] 41+ messages in thread

* ALSA on MIPS platform
@ 2007-08-01  7:56 Songmao Tian
  2007-08-02 14:56 ` Atsushi Nemoto
  0 siblings, 1 reply; 41+ messages in thread
From: Songmao Tian @ 2007-08-01  7:56 UTC (permalink / raw)
  To: alsa-devel, linux-mips

Hi,
    In 
http://www.linux-mips.org/archives/linux-mips/2007-04/msg00114.html, 
Atsushi Nemoto pointed out the problem is discussed before, the thread 
can be found at http://lkml.org/lkml/2006/1/25/117. Thanks Atsushi Nemoto:)
    The problem is clear:
1. dma_alloc_noncoherent() return a non-cached address, and 
virt_to_page() need a cached logical addr (Have I named it right?)
2. mmaped dam buffer should be non-cached.

We have a ugly patch, but we want to solve the problem cleanly, so can 
anyone show me the way?

Regards,
Tian

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 59b29cd..fd0aa66 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3138,7 +3138,11 @@ static struct page 
*snd_pcm_mmap_data_nopage(struct vm_area_struct *area,
             return NOPAGE_OOM; /* XXX: is this really due to OOM? */
     } else {
         vaddr = runtime->dma_area + offset;
+#if defined(__mips__) && defined(CONFIG_DMA_NONCOHERENT)
+        page = virt_to_page(CAC_ADDR(vaddr));
+#else
         page = virt_to_page(vaddr);
+#endif
     }
     get_page(page);
     if (type)
@@ -3254,6 +3258,11 @@ static int snd_pcm_mmap(struct file *file, struct 
vm_area_struct *area)
     substream = pcm_file->substream;
     snd_assert(substream != NULL, return -ENXIO);
 
+#if defined(__mips__) && defined(CONFIG_DMA_NONCOHERENT)
+    /* all mmap using uncached mode */
+    area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
+#endif
+
     offset = area->vm_pgoff << PAGE_SHIFT;
     switch (offset) {
     case SNDRV_PCM_MMAP_OFFSET_STATUS:
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
index cefd228..2251e70 100644
--- a/sound/core/sgbuf.c
+++ b/sound/core/sgbuf.c
@@ -91,12 +91,21 @@ void *snd_malloc_sgbuf_pages(struct device *device,
         }
         sgbuf->table[i].buf = tmpb.area;
         sgbuf->table[i].addr = tmpb.addr;
+#if defined(__mips__) && defined(CONFIG_DMA_NONCOHERENT)
+        sgbuf->page_table[i] = virt_to_page(CAC_ADDR(tmpb.area));
+#else
         sgbuf->page_table[i] = virt_to_page(tmpb.area);
+#endif
         sgbuf->pages++;
     }
 
     sgbuf->size = size;
+#if defined(__mips__) && defined(CONFIG_DMA_NONCOHERENT)
+    /* maybe we should use uncached accelerated mode */
+    dmab->area = vmap(sgbuf->page_table, sgbuf->pages, VM_MAP, 
pgprot_noncached(PAGE_KERNEL));
+#else
     dmab->area = vmap(sgbuf->page_table, sgbuf->pages, VM_MAP, 
PAGE_KERNEL);
+#endif
     if (! dmab->area)
         goto _failed;
     return dmab->area;

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-01  7:56 ALSA on MIPS platform Songmao Tian
@ 2007-08-02 14:56 ` Atsushi Nemoto
  2007-08-03 13:50     ` Songmao Tian
  0 siblings, 1 reply; 41+ messages in thread
From: Atsushi Nemoto @ 2007-08-02 14:56 UTC (permalink / raw)
  To: tiansm; +Cc: alsa-devel, linux-mips

On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
>     The problem is clear:
> 1. dma_alloc_noncoherent() return a non-cached address, and 
> virt_to_page() need a cached logical addr (Have I named it right?)
> 2. mmaped dam buffer should be non-cached.
> 
> We have a ugly patch, but we want to solve the problem cleanly, so can 
> anyone show me the way?

virt_to_page() is used in many place in mm so making it robust might
affect performance.  IMHO virt_to_page() seems too low-level as DMA
API.

If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
address returned by dma_xxx APIs was defined, MIPS can implement it
appropriately.

And then pgprot_noncached issues still exist...

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-02 14:56 ` Atsushi Nemoto
@ 2007-08-03 13:50     ` Songmao Tian
  0 siblings, 0 replies; 41+ messages in thread
From: Songmao Tian @ 2007-08-03 13:50 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips, alsa-devel, Dajie Tan, greg

Atsushi Nemoto wrote:
> On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
>   
>>     The problem is clear:
>> 1. dma_alloc_noncoherent() return a non-cached address, and 
>> virt_to_page() need a cached logical addr (Have I named it right?)
>> 2. mmaped dam buffer should be non-cached.
>>
>> We have a ugly patch, but we want to solve the problem cleanly, so can 
>> anyone show me the way?
>>     
>
> virt_to_page() is used in many place in mm so making it robust might
> affect performance.  IMHO virt_to_page() seems too low-level as DMA
> API.
>
> If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
> address returned by dma_xxx APIs was defined, MIPS can implement it
> appropriately.
>
> And then pgprot_noncached issues still exist...
>
> ---
> Atsushi Nemoto
>
>
>
>   

I agree, and I am investigating to implement a dma_map_coherent, but It 
seems dma_map_coherent doesn't solve all the problem and will change a 
lot of code:(


dma_virt_to_page can be something like this.

diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index b92dd8c..d2ead8a 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -181,6 +181,8 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 #define virt_to_page(kaddr)    pfn_to_page(PFN_DOWN(virt_to_phys(kaddr)))
 #define virt_addr_valid(kaddr)    pfn_valid(PFN_DOWN(virt_to_phys(kaddr)))
 
+#define dma_virt_to_page(dma_addr) 
pfn_to_page(PFN_DOWN(virt_to_phys(CAC_ADDR(kaddr))))
+
 #define VM_DATA_DEFAULT_FLAGS    (VM_READ | VM_WRITE | VM_EXEC | \
                  VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 655094d..5e694dd 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -39,6 +39,10 @@ extern int sysctl_legacy_va_layout;
 #include <asm/pgtable.h>
 #include <asm/processor.h>
 
+#ifndef dma_virt_to_page
+#define dma_virt_to_page virt_to_page
+#endif
+
 #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
 
 /*
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
index cefd228..8b29bfd 100644
--- a/sound/core/sgbuf.c
+++ b/sound/core/sgbuf.c
@@ -91,7 +91,7 @@ void *snd_malloc_sgbuf_pages(struct device *device,
         }
         sgbuf->table[i].buf = tmpb.area;
         sgbuf->table[i].addr = tmpb.addr;
-        sgbuf->page_table[i] = virt_to_page(tmpb.area);
+        sgbuf->page_table[i] = dma_virt_to_page(tmpb.area);
         sgbuf->pages++;
     }

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
@ 2007-08-03 13:50     ` Songmao Tian
  0 siblings, 0 replies; 41+ messages in thread
From: Songmao Tian @ 2007-08-03 13:50 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: alsa-devel, linux-mips, greg, Dajie Tan

Atsushi Nemoto wrote:
> On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
>   
>>     The problem is clear:
>> 1. dma_alloc_noncoherent() return a non-cached address, and 
>> virt_to_page() need a cached logical addr (Have I named it right?)
>> 2. mmaped dam buffer should be non-cached.
>>
>> We have a ugly patch, but we want to solve the problem cleanly, so can 
>> anyone show me the way?
>>     
>
> virt_to_page() is used in many place in mm so making it robust might
> affect performance.  IMHO virt_to_page() seems too low-level as DMA
> API.
>
> If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
> address returned by dma_xxx APIs was defined, MIPS can implement it
> appropriately.
>
> And then pgprot_noncached issues still exist...
>
> ---
> Atsushi Nemoto
>
>
>
>   

I agree, and I am investigating to implement a dma_map_coherent, but It 
seems dma_map_coherent doesn't solve all the problem and will change a 
lot of code:(


dma_virt_to_page can be something like this.

diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index b92dd8c..d2ead8a 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -181,6 +181,8 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 #define virt_to_page(kaddr)    pfn_to_page(PFN_DOWN(virt_to_phys(kaddr)))
 #define virt_addr_valid(kaddr)    pfn_valid(PFN_DOWN(virt_to_phys(kaddr)))
 
+#define dma_virt_to_page(dma_addr) 
pfn_to_page(PFN_DOWN(virt_to_phys(CAC_ADDR(kaddr))))
+
 #define VM_DATA_DEFAULT_FLAGS    (VM_READ | VM_WRITE | VM_EXEC | \
                  VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 655094d..5e694dd 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -39,6 +39,10 @@ extern int sysctl_legacy_va_layout;
 #include <asm/pgtable.h>
 #include <asm/processor.h>
 
+#ifndef dma_virt_to_page
+#define dma_virt_to_page virt_to_page
+#endif
+
 #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
 
 /*
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
index cefd228..8b29bfd 100644
--- a/sound/core/sgbuf.c
+++ b/sound/core/sgbuf.c
@@ -91,7 +91,7 @@ void *snd_malloc_sgbuf_pages(struct device *device,
         }
         sgbuf->table[i].buf = tmpb.area;
         sgbuf->table[i].addr = tmpb.addr;
-        sgbuf->page_table[i] = virt_to_page(tmpb.area);
+        sgbuf->page_table[i] = dma_virt_to_page(tmpb.area);
         sgbuf->pages++;
     }
 

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-03 13:50     ` Songmao Tian
@ 2007-08-03 13:59       ` Takashi Iwai
  -1 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2007-08-03 13:59 UTC (permalink / raw)
  To: Songmao Tian; +Cc: linux-mips, Atsushi Nemoto, alsa-devel, Dajie Tan, greg

At Fri, 03 Aug 2007 21:50:36 +0800,
Songmao Tian wrote:
> 
> Atsushi Nemoto wrote:
> > On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
> >   
> >>     The problem is clear:
> >> 1. dma_alloc_noncoherent() return a non-cached address, and 
> >> virt_to_page() need a cached logical addr (Have I named it right?)
> >> 2. mmaped dam buffer should be non-cached.
> >>
> >> We have a ugly patch, but we want to solve the problem cleanly, so can 
> >> anyone show me the way?
> >>     
> >
> > virt_to_page() is used in many place in mm so making it robust might
> > affect performance.  IMHO virt_to_page() seems too low-level as DMA
> > API.
> >
> > If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
> > address returned by dma_xxx APIs was defined, MIPS can implement it
> > appropriately.
> >
> > And then pgprot_noncached issues still exist...
> >
> > ---
> > Atsushi Nemoto
> >
> >
> >
> >   
> 
> I agree, and I am investigating to implement a dma_map_coherent, but It 
> seems dma_map_coherent doesn't solve all the problem and will change a 
> lot of code:(

It won't be that much.  You'll need to change snd_pcm_default_mmap()
in sound/core/pcm_native.c to call dma_mmap_coherent() directly
instead of nopage ops.  But, this won't work with SG-buffers, which
requires some more additional works.


Takashi

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [alsa-devel] ALSA on MIPS platform
@ 2007-08-03 13:59       ` Takashi Iwai
  0 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2007-08-03 13:59 UTC (permalink / raw)
  To: Songmao Tian; +Cc: Atsushi Nemoto, linux-mips, alsa-devel, Dajie Tan, greg

At Fri, 03 Aug 2007 21:50:36 +0800,
Songmao Tian wrote:
> 
> Atsushi Nemoto wrote:
> > On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
> >   
> >>     The problem is clear:
> >> 1. dma_alloc_noncoherent() return a non-cached address, and 
> >> virt_to_page() need a cached logical addr (Have I named it right?)
> >> 2. mmaped dam buffer should be non-cached.
> >>
> >> We have a ugly patch, but we want to solve the problem cleanly, so can 
> >> anyone show me the way?
> >>     
> >
> > virt_to_page() is used in many place in mm so making it robust might
> > affect performance.  IMHO virt_to_page() seems too low-level as DMA
> > API.
> >
> > If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
> > address returned by dma_xxx APIs was defined, MIPS can implement it
> > appropriately.
> >
> > And then pgprot_noncached issues still exist...
> >
> > ---
> > Atsushi Nemoto
> >
> >
> >
> >   
> 
> I agree, and I am investigating to implement a dma_map_coherent, but It 
> seems dma_map_coherent doesn't solve all the problem and will change a 
> lot of code:(

It won't be that much.  You'll need to change snd_pcm_default_mmap()
in sound/core/pcm_native.c to call dma_mmap_coherent() directly
instead of nopage ops.  But, this won't work with SG-buffers, which
requires some more additional works.


Takashi

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-03 13:59       ` [alsa-devel] " Takashi Iwai
@ 2007-08-03 15:57         ` Songmao Tian
  -1 siblings, 0 replies; 41+ messages in thread
From: Songmao Tian @ 2007-08-03 15:57 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: linux-mips, Atsushi Nemoto, alsa-devel, Dajie Tan, greg

Takashi Iwai wrote:
> At Fri, 03 Aug 2007 21:50:36 +0800,
> Songmao Tian wrote:
>   
>> Atsushi Nemoto wrote:
>>     
>>> On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
>>>   
>>>       
>>>>     The problem is clear:
>>>> 1. dma_alloc_noncoherent() return a non-cached address, and 
>>>> virt_to_page() need a cached logical addr (Have I named it right?)
>>>> 2. mmaped dam buffer should be non-cached.
>>>>
>>>> We have a ugly patch, but we want to solve the problem cleanly, so can 
>>>> anyone show me the way?
>>>>     
>>>>         
>>> virt_to_page() is used in many place in mm so making it robust might
>>> affect performance.  IMHO virt_to_page() seems too low-level as DMA
>>> API.
>>>
>>> If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
>>> address returned by dma_xxx APIs was defined, MIPS can implement it
>>> appropriately.
>>>
>>> And then pgprot_noncached issues still exist...
>>>
>>> ---
>>> Atsushi Nemoto
>>>
>>>
>>>
>>>   
>>>       
>> I agree, and I am investigating to implement a dma_map_coherent, but It 
>> seems dma_map_coherent doesn't solve all the problem and will change a 
>> lot of code:(
>>     
>
> It won't be that much.  You'll need to change snd_pcm_default_mmap()
> in sound/core/pcm_native.c to call dma_mmap_coherent() directly
> instead of nopage ops.  But, this won't work with SG-buffers, which
> requires some more additional works.
>
>
> Takashi
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
>
>   
I have no idea if the patch can work, the idea is not very clear now.
And I use vt686b ac97 sound driver, the driver use sgbuf, so I will 
write a test program tomorrow. Good sleep...:)

And if any of you can take some time look into the patch, and give some 
review will be appreciated:)

diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 76903c7..f088a6b 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -369,3 +369,23 @@ void dma_cache_sync(struct device *dev, void 
*vaddr, size_t size,
 }
 
 EXPORT_SYMBOL(dma_cache_sync);
+
+static int dma_mmap(struct device *dev, struct vm_area_struct *vma,
+            void *cpu_addr, dma_addr_t dma_addr, size_t size)
+{
+    if (remap_pfn_range(vma, vma->vm_start,
+                  PFN_DOWN(virt_to_phys(CAC_ADDR(cpu_addr))) + 
vma->vm_pgoff,
+                  vma->vm_end - vma->vm_start,
+                  vma->vm_page_prot))
+        return -EAGAIN;
+    return 0;
+}
+
+int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
+              void *cpu_addr, dma_addr_t dma_addr, size_t size)
+{
+    vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+    return dma_mmap(dev, vma, cpu_addr, dma_addr, size);
+}
+EXPORT_SYMBOL(dma_mmap_coherent);
+
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 59b29cd..af82a3b 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3152,6 +3152,8 @@ static struct vm_operations_struct 
snd_pcm_vm_ops_data =
     .close =    snd_pcm_mmap_data_close,
     .nopage =    snd_pcm_mmap_data_nopage,
 };
+int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
+              void *cpu_addr, dma_addr_t dma_addr, size_t size);
 
 /*
  * mmap the DMA buffer on RAM
@@ -3159,9 +3161,10 @@ 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)
 {
-    area->vm_ops = &snd_pcm_vm_ops_data;
+    struct snd_pcm_runtime *runtime = substream->runtime;
     area->vm_private_data = substream;
-    area->vm_flags |= VM_RESERVED;
+    dma_mmap_coherent(NULL, area, runtime->dma_area,
+            runtime->dma_addr, runtime->dma_bytes);
     atomic_inc(&substream->mmap_count);
     return 0;
 }

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: [alsa-devel] ALSA on MIPS platform
@ 2007-08-03 15:57         ` Songmao Tian
  0 siblings, 0 replies; 41+ messages in thread
From: Songmao Tian @ 2007-08-03 15:57 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: linux-mips, Atsushi Nemoto, alsa-devel, Dajie Tan, greg

Takashi Iwai wrote:
> At Fri, 03 Aug 2007 21:50:36 +0800,
> Songmao Tian wrote:
>   
>> Atsushi Nemoto wrote:
>>     
>>> On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
>>>   
>>>       
>>>>     The problem is clear:
>>>> 1. dma_alloc_noncoherent() return a non-cached address, and 
>>>> virt_to_page() need a cached logical addr (Have I named it right?)
>>>> 2. mmaped dam buffer should be non-cached.
>>>>
>>>> We have a ugly patch, but we want to solve the problem cleanly, so can 
>>>> anyone show me the way?
>>>>     
>>>>         
>>> virt_to_page() is used in many place in mm so making it robust might
>>> affect performance.  IMHO virt_to_page() seems too low-level as DMA
>>> API.
>>>
>>> If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
>>> address returned by dma_xxx APIs was defined, MIPS can implement it
>>> appropriately.
>>>
>>> And then pgprot_noncached issues still exist...
>>>
>>> ---
>>> Atsushi Nemoto
>>>
>>>
>>>
>>>   
>>>       
>> I agree, and I am investigating to implement a dma_map_coherent, but It 
>> seems dma_map_coherent doesn't solve all the problem and will change a 
>> lot of code:(
>>     
>
> It won't be that much.  You'll need to change snd_pcm_default_mmap()
> in sound/core/pcm_native.c to call dma_mmap_coherent() directly
> instead of nopage ops.  But, this won't work with SG-buffers, which
> requires some more additional works.
>
>
> Takashi
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
>
>   
I have no idea if the patch can work, the idea is not very clear now.
And I use vt686b ac97 sound driver, the driver use sgbuf, so I will 
write a test program tomorrow. Good sleep...:)

And if any of you can take some time look into the patch, and give some 
review will be appreciated:)

diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 76903c7..f088a6b 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -369,3 +369,23 @@ void dma_cache_sync(struct device *dev, void 
*vaddr, size_t size,
 }
 
 EXPORT_SYMBOL(dma_cache_sync);
+
+static int dma_mmap(struct device *dev, struct vm_area_struct *vma,
+            void *cpu_addr, dma_addr_t dma_addr, size_t size)
+{
+    if (remap_pfn_range(vma, vma->vm_start,
+                  PFN_DOWN(virt_to_phys(CAC_ADDR(cpu_addr))) + 
vma->vm_pgoff,
+                  vma->vm_end - vma->vm_start,
+                  vma->vm_page_prot))
+        return -EAGAIN;
+    return 0;
+}
+
+int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
+              void *cpu_addr, dma_addr_t dma_addr, size_t size)
+{
+    vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+    return dma_mmap(dev, vma, cpu_addr, dma_addr, size);
+}
+EXPORT_SYMBOL(dma_mmap_coherent);
+
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 59b29cd..af82a3b 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3152,6 +3152,8 @@ static struct vm_operations_struct 
snd_pcm_vm_ops_data =
     .close =    snd_pcm_mmap_data_close,
     .nopage =    snd_pcm_mmap_data_nopage,
 };
+int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
+              void *cpu_addr, dma_addr_t dma_addr, size_t size);
 
 /*
  * mmap the DMA buffer on RAM
@@ -3159,9 +3161,10 @@ 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)
 {
-    area->vm_ops = &snd_pcm_vm_ops_data;
+    struct snd_pcm_runtime *runtime = substream->runtime;
     area->vm_private_data = substream;
-    area->vm_flags |= VM_RESERVED;
+    dma_mmap_coherent(NULL, area, runtime->dma_area,
+            runtime->dma_addr, runtime->dma_bytes);
     atomic_inc(&substream->mmap_count);
     return 0;
 }

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-03 15:57         ` [alsa-devel] " Songmao Tian
@ 2007-08-06 12:17           ` Takashi Iwai
  -1 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2007-08-06 12:17 UTC (permalink / raw)
  To: Songmao Tian; +Cc: linux-mips, Atsushi Nemoto, alsa-devel, Dajie Tan, greg

At Fri, 03 Aug 2007 23:57:07 +0800,
Songmao Tian wrote:
> 
> Takashi Iwai wrote:
> > At Fri, 03 Aug 2007 21:50:36 +0800,
> > Songmao Tian wrote:
> >   
> >> Atsushi Nemoto wrote:
> >>     
> >>> On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
> >>>   
> >>>       
> >>>>     The problem is clear:
> >>>> 1. dma_alloc_noncoherent() return a non-cached address, and 
> >>>> virt_to_page() need a cached logical addr (Have I named it right?)
> >>>> 2. mmaped dam buffer should be non-cached.
> >>>>
> >>>> We have a ugly patch, but we want to solve the problem cleanly, so can 
> >>>> anyone show me the way?
> >>>>     
> >>>>         
> >>> virt_to_page() is used in many place in mm so making it robust might
> >>> affect performance.  IMHO virt_to_page() seems too low-level as DMA
> >>> API.
> >>>
> >>> If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
> >>> address returned by dma_xxx APIs was defined, MIPS can implement it
> >>> appropriately.
> >>>
> >>> And then pgprot_noncached issues still exist...
> >>>
> >>> ---
> >>> Atsushi Nemoto
> >>>
> >>>
> >>>
> >>>   
> >>>       
> >> I agree, and I am investigating to implement a dma_map_coherent, but It 
> >> seems dma_map_coherent doesn't solve all the problem and will change a 
> >> lot of code:(
> >>     
> >
> > It won't be that much.  You'll need to change snd_pcm_default_mmap()
> > in sound/core/pcm_native.c to call dma_mmap_coherent() directly
> > instead of nopage ops.  But, this won't work with SG-buffers, which
> > requires some more additional works.
> >
> >
> > Takashi
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> >
> >
> >   
> I have no idea if the patch can work, the idea is not very clear now.
> And I use vt686b ac97 sound driver, the driver use sgbuf, so I will 
> write a test program tomorrow. Good sleep...:)

Ah, that's a bad luck.  Then your patch won't work as it is.
We'll need another function for SG-buffer, that calls
dma_mmap_coherent() for each page found in the given buffer.


Takashi

> And if any of you can take some time look into the patch, and give some 
> review will be appreciated:)
> 
> diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
> index 76903c7..f088a6b 100644
> --- a/arch/mips/mm/dma-default.c
> +++ b/arch/mips/mm/dma-default.c
> @@ -369,3 +369,23 @@ void dma_cache_sync(struct device *dev, void 
> *vaddr, size_t size,
>  }
>  
>  EXPORT_SYMBOL(dma_cache_sync);
> +
> +static int dma_mmap(struct device *dev, struct vm_area_struct *vma,
> +            void *cpu_addr, dma_addr_t dma_addr, size_t size)
> +{
> +    if (remap_pfn_range(vma, vma->vm_start,
> +                  PFN_DOWN(virt_to_phys(CAC_ADDR(cpu_addr))) + 
> vma->vm_pgoff,
> +                  vma->vm_end - vma->vm_start,
> +                  vma->vm_page_prot))
> +        return -EAGAIN;
> +    return 0;
> +}
> +
> +int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
> +              void *cpu_addr, dma_addr_t dma_addr, size_t size)
> +{
> +    vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
> +    return dma_mmap(dev, vma, cpu_addr, dma_addr, size);
> +}
> +EXPORT_SYMBOL(dma_mmap_coherent);
> +
> diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
> index 59b29cd..af82a3b 100644
> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -3152,6 +3152,8 @@ static struct vm_operations_struct 
> snd_pcm_vm_ops_data =
>      .close =    snd_pcm_mmap_data_close,
>      .nopage =    snd_pcm_mmap_data_nopage,
>  };
> +int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
> +              void *cpu_addr, dma_addr_t dma_addr, size_t size);
>  
>  /*
>   * mmap the DMA buffer on RAM
> @@ -3159,9 +3161,10 @@ 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)
>  {
> -    area->vm_ops = &snd_pcm_vm_ops_data;
> +    struct snd_pcm_runtime *runtime = substream->runtime;
>      area->vm_private_data = substream;
> -    area->vm_flags |= VM_RESERVED;
> +    dma_mmap_coherent(NULL, area, runtime->dma_area,
> +            runtime->dma_addr, runtime->dma_bytes);
>      atomic_inc(&substream->mmap_count);
>      return 0;
>  }
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [alsa-devel] ALSA on MIPS platform
@ 2007-08-06 12:17           ` Takashi Iwai
  0 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2007-08-06 12:17 UTC (permalink / raw)
  To: Songmao Tian; +Cc: linux-mips, Atsushi Nemoto, alsa-devel, Dajie Tan, greg

At Fri, 03 Aug 2007 23:57:07 +0800,
Songmao Tian wrote:
> 
> Takashi Iwai wrote:
> > At Fri, 03 Aug 2007 21:50:36 +0800,
> > Songmao Tian wrote:
> >   
> >> Atsushi Nemoto wrote:
> >>     
> >>> On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
> >>>   
> >>>       
> >>>>     The problem is clear:
> >>>> 1. dma_alloc_noncoherent() return a non-cached address, and 
> >>>> virt_to_page() need a cached logical addr (Have I named it right?)
> >>>> 2. mmaped dam buffer should be non-cached.
> >>>>
> >>>> We have a ugly patch, but we want to solve the problem cleanly, so can 
> >>>> anyone show me the way?
> >>>>     
> >>>>         
> >>> virt_to_page() is used in many place in mm so making it robust might
> >>> affect performance.  IMHO virt_to_page() seems too low-level as DMA
> >>> API.
> >>>
> >>> If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
> >>> address returned by dma_xxx APIs was defined, MIPS can implement it
> >>> appropriately.
> >>>
> >>> And then pgprot_noncached issues still exist...
> >>>
> >>> ---
> >>> Atsushi Nemoto
> >>>
> >>>
> >>>
> >>>   
> >>>       
> >> I agree, and I am investigating to implement a dma_map_coherent, but It 
> >> seems dma_map_coherent doesn't solve all the problem and will change a 
> >> lot of code:(
> >>     
> >
> > It won't be that much.  You'll need to change snd_pcm_default_mmap()
> > in sound/core/pcm_native.c to call dma_mmap_coherent() directly
> > instead of nopage ops.  But, this won't work with SG-buffers, which
> > requires some more additional works.
> >
> >
> > Takashi
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> >
> >
> >   
> I have no idea if the patch can work, the idea is not very clear now.
> And I use vt686b ac97 sound driver, the driver use sgbuf, so I will 
> write a test program tomorrow. Good sleep...:)

Ah, that's a bad luck.  Then your patch won't work as it is.
We'll need another function for SG-buffer, that calls
dma_mmap_coherent() for each page found in the given buffer.


Takashi

> And if any of you can take some time look into the patch, and give some 
> review will be appreciated:)
> 
> diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
> index 76903c7..f088a6b 100644
> --- a/arch/mips/mm/dma-default.c
> +++ b/arch/mips/mm/dma-default.c
> @@ -369,3 +369,23 @@ void dma_cache_sync(struct device *dev, void 
> *vaddr, size_t size,
>  }
>  
>  EXPORT_SYMBOL(dma_cache_sync);
> +
> +static int dma_mmap(struct device *dev, struct vm_area_struct *vma,
> +            void *cpu_addr, dma_addr_t dma_addr, size_t size)
> +{
> +    if (remap_pfn_range(vma, vma->vm_start,
> +                  PFN_DOWN(virt_to_phys(CAC_ADDR(cpu_addr))) + 
> vma->vm_pgoff,
> +                  vma->vm_end - vma->vm_start,
> +                  vma->vm_page_prot))
> +        return -EAGAIN;
> +    return 0;
> +}
> +
> +int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
> +              void *cpu_addr, dma_addr_t dma_addr, size_t size)
> +{
> +    vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
> +    return dma_mmap(dev, vma, cpu_addr, dma_addr, size);
> +}
> +EXPORT_SYMBOL(dma_mmap_coherent);
> +
> diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
> index 59b29cd..af82a3b 100644
> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -3152,6 +3152,8 @@ static struct vm_operations_struct 
> snd_pcm_vm_ops_data =
>      .close =    snd_pcm_mmap_data_close,
>      .nopage =    snd_pcm_mmap_data_nopage,
>  };
> +int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
> +              void *cpu_addr, dma_addr_t dma_addr, size_t size);
>  
>  /*
>   * mmap the DMA buffer on RAM
> @@ -3159,9 +3161,10 @@ 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)
>  {
> -    area->vm_ops = &snd_pcm_vm_ops_data;
> +    struct snd_pcm_runtime *runtime = substream->runtime;
>      area->vm_private_data = substream;
> -    area->vm_flags |= VM_RESERVED;
> +    dma_mmap_coherent(NULL, area, runtime->dma_area,
> +            runtime->dma_addr, runtime->dma_bytes);
>      atomic_inc(&substream->mmap_count);
>      return 0;
>  }
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-03 13:50     ` Songmao Tian
  (?)
  (?)
@ 2007-08-07  5:53     ` Dajie Tan
  2007-08-07  6:18       ` Dajie Tan
  -1 siblings, 1 reply; 41+ messages in thread
From: Dajie Tan @ 2007-08-07  5:53 UTC (permalink / raw)
  To: Songmao Tian
  Cc: linux-mips, alsa-devel, Ralf, Atsushi Nemoto, Takashi Iwai, greg

I think this problem can be solved by revising the __pa macro like this:

--- a/include/asm-mips/page.h      2007-08-07 09:45:00.000000000 +0800
+++ b/include/asm-mips/page.h     2007-08-07 09:46:59.000000000 +0800
@@ -150,7 +150,7 @@
 })
 #else
 #define __pa(x)
         \
-    ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
+    (((unsigned long)(x) & 0x1fffffff) + PHYS_OFFSET)
 #endif

So, the virt_to_page can accept all cached or uncached address.


Tan

2007/8/3, Songmao Tian <tiansm@lemote.com>:
> Atsushi Nemoto wrote:
> > On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
> >
> >>     The problem is clear:
> >> 1. dma_alloc_noncoherent() return a non-cached address, and
> >> virt_to_page() need a cached logical addr (Have I named it right?)
> >> 2. mmaped dam buffer should be non-cached.
> >>
> >> We have a ugly patch, but we want to solve the problem cleanly, so can
> >> anyone show me the way?
> >>
> >
> > virt_to_page() is used in many place in mm so making it robust might
> > affect performance.  IMHO virt_to_page() seems too low-level as DMA
> > API.
> >
> > If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
> > address returned by dma_xxx APIs was defined, MIPS can implement it
> > appropriately.
> >
> > And then pgprot_noncached issues still exist...
> >
> > ---
> > Atsushi Nemoto
> >
> >
> >
> >
>
> I agree, and I am investigating to implement a dma_map_coherent, but It
> seems dma_map_coherent doesn't solve all the problem and will change a
> lot of code:(
>
>
> dma_virt_to_page can be something like this.
>
> diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
> index b92dd8c..d2ead8a 100644
> --- a/include/asm-mips/page.h
> +++ b/include/asm-mips/page.h
> @@ -181,6 +181,8 @@ typedef struct { unsigned long pgprot; } pgprot_t;
>  #define virt_to_page(kaddr)    pfn_to_page(PFN_DOWN(virt_to_phys(kaddr)))
>  #define virt_addr_valid(kaddr)    pfn_valid(PFN_DOWN(virt_to_phys(kaddr)))
>
> +#define dma_virt_to_page(dma_addr)
> pfn_to_page(PFN_DOWN(virt_to_phys(CAC_ADDR(kaddr))))
> +
>  #define VM_DATA_DEFAULT_FLAGS    (VM_READ | VM_WRITE | VM_EXEC | \
>                   VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 655094d..5e694dd 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -39,6 +39,10 @@ extern int sysctl_legacy_va_layout;
>  #include <asm/pgtable.h>
>  #include <asm/processor.h>
>
> +#ifndef dma_virt_to_page
> +#define dma_virt_to_page virt_to_page
> +#endif
> +
>  #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
>
>  /*
> diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
> index cefd228..8b29bfd 100644
> --- a/sound/core/sgbuf.c
> +++ b/sound/core/sgbuf.c
> @@ -91,7 +91,7 @@ void *snd_malloc_sgbuf_pages(struct device *device,
>          }
>          sgbuf->table[i].buf = tmpb.area;
>          sgbuf->table[i].addr = tmpb.addr;
> -        sgbuf->page_table[i] = virt_to_page(tmpb.area);
> +        sgbuf->page_table[i] = dma_virt_to_page(tmpb.area);
>          sgbuf->pages++;
>      }
>
>

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-07  5:53     ` Dajie Tan
@ 2007-08-07  6:18       ` Dajie Tan
  2007-08-07 14:01         ` Atsushi Nemoto
  0 siblings, 1 reply; 41+ messages in thread
From: Dajie Tan @ 2007-08-07  6:18 UTC (permalink / raw)
  To: Songmao Tian
  Cc: linux-mips, alsa-devel, Ralf, Atsushi Nemoto, Takashi Iwai, greg

Sorry, that aim at 2.6.18.

In the latest kernel:

--- a/include/asm-mips/io.h     2007-08-07 10:18:03.000000000 +0800
+++ b/include/asm-mips/io.h     2007-08-07 10:18:56.000000000 +0800
@@ -116,7 +116,7 @@
  */
 static inline unsigned long virt_to_phys(volatile const void *address)
 {
-       return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
+       return ((unsigned long)address & 0x1fffffff) + PHYS_OFFSET;
 }

I think virt_to_phys or __pa should accept kseg1 address.

Tan

2007/8/7, Dajie Tan <jiankemeng@gmail.com>:
> I think this problem can be solved by revising the __pa macro like this:
>
> --- a/include/asm-mips/page.h      2007-08-07 09:45:00.000000000 +0800
> +++ b/include/asm-mips/page.h     2007-08-07 09:46:59.000000000 +0800
> @@ -150,7 +150,7 @@
>  })
>  #else
>  #define __pa(x)
>          \
> -    ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
> +    (((unsigned long)(x) & 0x1fffffff) + PHYS_OFFSET)
>  #endif
>
> So, the virt_to_page can accept all cached or uncached address.
>
>
> Tan
>
> 2007/8/3, Songmao Tian <tiansm@lemote.com>:
> > Atsushi Nemoto wrote:
> > > On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
> > >
> > >>     The problem is clear:
> > >> 1. dma_alloc_noncoherent() return a non-cached address, and
> > >> virt_to_page() need a cached logical addr (Have I named it right?)
> > >> 2. mmaped dam buffer should be non-cached.
> > >>
> > >> We have a ugly patch, but we want to solve the problem cleanly, so can
> > >> anyone show me the way?
> > >>
> > >
> > > virt_to_page() is used in many place in mm so making it robust might
> > > affect performance.  IMHO virt_to_page() seems too low-level as DMA
> > > API.
> > >
> > > If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
> > > address returned by dma_xxx APIs was defined, MIPS can implement it
> > > appropriately.
> > >
> > > And then pgprot_noncached issues still exist...
> > >
> > > ---
> > > Atsushi Nemoto
> > >
> > >
> > >
> > >
> >
> > I agree, and I am investigating to implement a dma_map_coherent, but It
> > seems dma_map_coherent doesn't solve all the problem and will change a
> > lot of code:(
> >
> >
> > dma_virt_to_page can be something like this.
> >
> > diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
> > index b92dd8c..d2ead8a 100644
> > --- a/include/asm-mips/page.h
> > +++ b/include/asm-mips/page.h
> > @@ -181,6 +181,8 @@ typedef struct { unsigned long pgprot; } pgprot_t;
> >  #define virt_to_page(kaddr)    pfn_to_page(PFN_DOWN(virt_to_phys(kaddr)))
> >  #define virt_addr_valid(kaddr)    pfn_valid(PFN_DOWN(virt_to_phys(kaddr)))
> >
> > +#define dma_virt_to_page(dma_addr)
> > pfn_to_page(PFN_DOWN(virt_to_phys(CAC_ADDR(kaddr))))
> > +
> >  #define VM_DATA_DEFAULT_FLAGS    (VM_READ | VM_WRITE | VM_EXEC | \
> >                   VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
> >
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index 655094d..5e694dd 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -39,6 +39,10 @@ extern int sysctl_legacy_va_layout;
> >  #include <asm/pgtable.h>
> >  #include <asm/processor.h>
> >
> > +#ifndef dma_virt_to_page
> > +#define dma_virt_to_page virt_to_page
> > +#endif
> > +
> >  #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
> >
> >  /*
> > diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
> > index cefd228..8b29bfd 100644
> > --- a/sound/core/sgbuf.c
> > +++ b/sound/core/sgbuf.c
> > @@ -91,7 +91,7 @@ void *snd_malloc_sgbuf_pages(struct device *device,
> >          }
> >          sgbuf->table[i].buf = tmpb.area;
> >          sgbuf->table[i].addr = tmpb.addr;
> > -        sgbuf->page_table[i] = virt_to_page(tmpb.area);
> > +        sgbuf->page_table[i] = dma_virt_to_page(tmpb.area);
> >          sgbuf->pages++;
> >      }
> >
> >
>


-- 
为天地立心
为生民立命
为往圣继绝学
为万世开太平

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-07  6:18       ` Dajie Tan
@ 2007-08-07 14:01         ` Atsushi Nemoto
  2007-08-07 17:54             ` Ralf Baechle
  2007-08-08  0:40             ` [alsa-devel] " Songmao Tian
  0 siblings, 2 replies; 41+ messages in thread
From: Atsushi Nemoto @ 2007-08-07 14:01 UTC (permalink / raw)
  To: jiankemeng; +Cc: tiansm, linux-mips, alsa-devel, ralf, tiwai, greg

On Tue, 7 Aug 2007 10:18:04 +0400, "Dajie Tan" <jiankemeng@gmail.com> wrote:
>  static inline unsigned long virt_to_phys(volatile const void *address)
>  {
> -       return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
> +       return ((unsigned long)address & 0x1fffffff) + PHYS_OFFSET;
>  }

This makes virt_to_phys() a bit slower, and more importantly, breaks
64-bit kernel.

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-07 14:01         ` Atsushi Nemoto
@ 2007-08-07 17:54             ` Ralf Baechle
  2007-08-08  0:40             ` [alsa-devel] " Songmao Tian
  1 sibling, 0 replies; 41+ messages in thread
From: Ralf Baechle @ 2007-08-07 17:54 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips, alsa-devel, tiwai, greg, tiansm, jiankemeng

On Tue, Aug 07, 2007 at 11:01:57PM +0900, Atsushi Nemoto wrote:

> On Tue, 7 Aug 2007 10:18:04 +0400, "Dajie Tan" <jiankemeng@gmail.com> wrote:
> >  static inline unsigned long virt_to_phys(volatile const void *address)
> >  {
> > -       return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
> > +       return ((unsigned long)address & 0x1fffffff) + PHYS_OFFSET;
> >  }
> 
> This makes virt_to_phys() a bit slower, and more importantly, breaks
> 64-bit kernel.

It's ALSA that is doing funny things here so there is no point in fixing
the arch code to work for ALSA.

  Ralf

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
@ 2007-08-07 17:54             ` Ralf Baechle
  0 siblings, 0 replies; 41+ messages in thread
From: Ralf Baechle @ 2007-08-07 17:54 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: jiankemeng, tiansm, linux-mips, alsa-devel, tiwai, greg

On Tue, Aug 07, 2007 at 11:01:57PM +0900, Atsushi Nemoto wrote:

> On Tue, 7 Aug 2007 10:18:04 +0400, "Dajie Tan" <jiankemeng@gmail.com> wrote:
> >  static inline unsigned long virt_to_phys(volatile const void *address)
> >  {
> > -       return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
> > +       return ((unsigned long)address & 0x1fffffff) + PHYS_OFFSET;
> >  }
> 
> This makes virt_to_phys() a bit slower, and more importantly, breaks
> 64-bit kernel.

It's ALSA that is doing funny things here so there is no point in fixing
the arch code to work for ALSA.

  Ralf

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-07 17:54             ` Ralf Baechle
@ 2007-08-07 18:41               ` Takashi Iwai
  -1 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2007-08-07 18:41 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, alsa-devel, greg, Atsushi Nemoto, tiansm, jiankemeng

At Tue, 7 Aug 2007 18:54:02 +0100,
Ralf Baechle wrote:
> 
> On Tue, Aug 07, 2007 at 11:01:57PM +0900, Atsushi Nemoto wrote:
> 
> > On Tue, 7 Aug 2007 10:18:04 +0400, "Dajie Tan" <jiankemeng@gmail.com> wrote:
> > >  static inline unsigned long virt_to_phys(volatile const void *address)
> > >  {
> > > -       return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
> > > +       return ((unsigned long)address & 0x1fffffff) + PHYS_OFFSET;
> > >  }
> > 
> > This makes virt_to_phys() a bit slower, and more importantly, breaks
> > 64-bit kernel.
> 
> It's ALSA that is doing funny things here so there is no point in fixing
> the arch code to work for ALSA.

Yep, but OTOH, the arch code doesn't provide a proper standard way to
mmap the pages allocated via dma_alloc_coherent().  That's the missing
piece, especially on mips and sparc.  ARM has already one.

My wish is implementing dma_mmap_coherent() on all architectures, so
that the driver can use it safely without messy ifdefs.


Takashi

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
@ 2007-08-07 18:41               ` Takashi Iwai
  0 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2007-08-07 18:41 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Atsushi Nemoto, jiankemeng, tiansm, linux-mips, alsa-devel, greg

At Tue, 7 Aug 2007 18:54:02 +0100,
Ralf Baechle wrote:
> 
> On Tue, Aug 07, 2007 at 11:01:57PM +0900, Atsushi Nemoto wrote:
> 
> > On Tue, 7 Aug 2007 10:18:04 +0400, "Dajie Tan" <jiankemeng@gmail.com> wrote:
> > >  static inline unsigned long virt_to_phys(volatile const void *address)
> > >  {
> > > -       return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
> > > +       return ((unsigned long)address & 0x1fffffff) + PHYS_OFFSET;
> > >  }
> > 
> > This makes virt_to_phys() a bit slower, and more importantly, breaks
> > 64-bit kernel.
> 
> It's ALSA that is doing funny things here so there is no point in fixing
> the arch code to work for ALSA.

Yep, but OTOH, the arch code doesn't provide a proper standard way to
mmap the pages allocated via dma_alloc_coherent().  That's the missing
piece, especially on mips and sparc.  ARM has already one.

My wish is implementing dma_mmap_coherent() on all architectures, so
that the driver can use it safely without messy ifdefs.


Takashi

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-07 14:01         ` Atsushi Nemoto
@ 2007-08-08  0:40             ` Songmao Tian
  2007-08-08  0:40             ` [alsa-devel] " Songmao Tian
  1 sibling, 0 replies; 41+ messages in thread
From: Songmao Tian @ 2007-08-08  0:40 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips, alsa-devel, tiwai, greg, ralf, jiankemeng

Atsushi Nemoto wrote:
> On Tue, 7 Aug 2007 10:18:04 +0400, "Dajie Tan" <jiankemeng@gmail.com> wrote:
>   
>>  static inline unsigned long virt_to_phys(volatile const void *address)
>>  {
>> -       return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
>> +       return ((unsigned long)address & 0x1fffffff) + PHYS_OFFSET;
>>  }
>>     
>
> This makes virt_to_phys() a bit slower, and more importantly, breaks
> 64-bit kernel.
>   

I have tried this way, and disassemble result show 32-bit kernel add 
only one instruction.
But I don't really insist on this patch, for it doesn't resolve some 
driver code requirement.
> ---
> Atsushi Nemoto
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
>
>   

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [alsa-devel] ALSA on MIPS platform
@ 2007-08-08  0:40             ` Songmao Tian
  0 siblings, 0 replies; 41+ messages in thread
From: Songmao Tian @ 2007-08-08  0:40 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: jiankemeng, linux-mips, alsa-devel, tiwai, greg, ralf

Atsushi Nemoto wrote:
> On Tue, 7 Aug 2007 10:18:04 +0400, "Dajie Tan" <jiankemeng@gmail.com> wrote:
>   
>>  static inline unsigned long virt_to_phys(volatile const void *address)
>>  {
>> -       return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
>> +       return ((unsigned long)address & 0x1fffffff) + PHYS_OFFSET;
>>  }
>>     
>
> This makes virt_to_phys() a bit slower, and more importantly, breaks
> 64-bit kernel.
>   

I have tried this way, and disassemble result show 32-bit kernel add 
only one instruction.
But I don't really insist on this patch, for it doesn't resolve some 
driver code requirement.
> ---
> Atsushi Nemoto
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
>
>   

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-07 18:41               ` Takashi Iwai
@ 2007-08-08 11:58                 ` Ralf Baechle
  -1 siblings, 0 replies; 41+ messages in thread
From: Ralf Baechle @ 2007-08-08 11:58 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: linux-mips, alsa-devel, greg, Atsushi Nemoto, tiansm, jiankemeng

On Tue, Aug 07, 2007 at 08:41:10PM +0200, Takashi Iwai wrote:

> > It's ALSA that is doing funny things here so there is no point in fixing
> > the arch code to work for ALSA.
> 
> Yep, but OTOH, the arch code doesn't provide a proper standard way to
> mmap the pages allocated via dma_alloc_coherent().  That's the missing
> piece, especially on mips and sparc.  ARM has already one.
> 
> My wish is implementing dma_mmap_coherent() on all architectures, so
> that the driver can use it safely without messy ifdefs.

Adding dma_mmap_coherent has been proposed in 2004 but the discussion for
some reason went nowhere because it apparently isn't implementable on
PARISC due to cache synonyms - on MIPS we'd solve those issues where they
exist by using uncached or writethrough mappings, as apropriate.

  Ralf

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
@ 2007-08-08 11:58                 ` Ralf Baechle
  0 siblings, 0 replies; 41+ messages in thread
From: Ralf Baechle @ 2007-08-08 11:58 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Atsushi Nemoto, jiankemeng, tiansm, linux-mips, alsa-devel, greg

On Tue, Aug 07, 2007 at 08:41:10PM +0200, Takashi Iwai wrote:

> > It's ALSA that is doing funny things here so there is no point in fixing
> > the arch code to work for ALSA.
> 
> Yep, but OTOH, the arch code doesn't provide a proper standard way to
> mmap the pages allocated via dma_alloc_coherent().  That's the missing
> piece, especially on mips and sparc.  ARM has already one.
> 
> My wish is implementing dma_mmap_coherent() on all architectures, so
> that the driver can use it safely without messy ifdefs.

Adding dma_mmap_coherent has been proposed in 2004 but the discussion for
some reason went nowhere because it apparently isn't implementable on
PARISC due to cache synonyms - on MIPS we'd solve those issues where they
exist by using uncached or writethrough mappings, as apropriate.

  Ralf

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-08 11:58                 ` Ralf Baechle
  (?)
@ 2007-08-08 12:40                 ` Maciej W. Rozycki
  -1 siblings, 0 replies; 41+ messages in thread
From: Maciej W. Rozycki @ 2007-08-08 12:40 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Takashi Iwai, Atsushi Nemoto, jiankemeng, tiansm, linux-mips,
	alsa-devel, greg

On Wed, 8 Aug 2007, Ralf Baechle wrote:

> > Yep, but OTOH, the arch code doesn't provide a proper standard way to
> > mmap the pages allocated via dma_alloc_coherent().  That's the missing
> > piece, especially on mips and sparc.  ARM has already one.
> > 
> > My wish is implementing dma_mmap_coherent() on all architectures, so
> > that the driver can use it safely without messy ifdefs.
> 
> Adding dma_mmap_coherent has been proposed in 2004 but the discussion for
> some reason went nowhere because it apparently isn't implementable on
> PARISC due to cache synonyms - on MIPS we'd solve those issues where they
> exist by using uncached or writethrough mappings, as apropriate.

 Hmm, why should everybody suffer from some limitation of some peculiar 
architecture?  I would suggest to let them find an architecture-specific 
way of addressing the problem -- they surely have a good control over 
their own code and can implement a workaround that would not impede all 
the others.

 Ralf, do you have an idea about what their issue exactly is?

  Maciej

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-08 11:58                 ` Ralf Baechle
@ 2007-08-08 12:57                   ` Takashi Iwai
  -1 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2007-08-08 12:57 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, alsa-devel, greg, Atsushi Nemoto, tiansm, jiankemeng

At Wed, 8 Aug 2007 12:58:52 +0100,
Ralf Baechle wrote:
> 
> On Tue, Aug 07, 2007 at 08:41:10PM +0200, Takashi Iwai wrote:
> 
> > > It's ALSA that is doing funny things here so there is no point in fixing
> > > the arch code to work for ALSA.
> > 
> > Yep, but OTOH, the arch code doesn't provide a proper standard way to
> > mmap the pages allocated via dma_alloc_coherent().  That's the missing
> > piece, especially on mips and sparc.  ARM has already one.
> > 
> > My wish is implementing dma_mmap_coherent() on all architectures, so
> > that the driver can use it safely without messy ifdefs.
> 
> Adding dma_mmap_coherent has been proposed in 2004 but the discussion for
> some reason went nowhere because it apparently isn't implementable on
> PARISC due to cache synonyms - on MIPS we'd solve those issues where they
> exist by using uncached or writethrough mappings, as apropriate.

Actually, if it cannot be implemented (or not yet implemented
properly) on some architectures, it's fine.  Then we can simply drop
the mmap support just for such an architecture.  I suppose an inlined
dma_mmap_coherent() that always returns an error, just like the
earlier version of asm-generic/dma-mapping-broken.h, would work well.

But, currently, the driver has no idea which architecture is OK and
which not, and which method to choose.  That is where we got stuck.


Takashi

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
@ 2007-08-08 12:57                   ` Takashi Iwai
  0 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2007-08-08 12:57 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Atsushi Nemoto, jiankemeng, tiansm, linux-mips, alsa-devel, greg

At Wed, 8 Aug 2007 12:58:52 +0100,
Ralf Baechle wrote:
> 
> On Tue, Aug 07, 2007 at 08:41:10PM +0200, Takashi Iwai wrote:
> 
> > > It's ALSA that is doing funny things here so there is no point in fixing
> > > the arch code to work for ALSA.
> > 
> > Yep, but OTOH, the arch code doesn't provide a proper standard way to
> > mmap the pages allocated via dma_alloc_coherent().  That's the missing
> > piece, especially on mips and sparc.  ARM has already one.
> > 
> > My wish is implementing dma_mmap_coherent() on all architectures, so
> > that the driver can use it safely without messy ifdefs.
> 
> Adding dma_mmap_coherent has been proposed in 2004 but the discussion for
> some reason went nowhere because it apparently isn't implementable on
> PARISC due to cache synonyms - on MIPS we'd solve those issues where they
> exist by using uncached or writethrough mappings, as apropriate.

Actually, if it cannot be implemented (or not yet implemented
properly) on some architectures, it's fine.  Then we can simply drop
the mmap support just for such an architecture.  I suppose an inlined
dma_mmap_coherent() that always returns an error, just like the
earlier version of asm-generic/dma-mapping-broken.h, would work well.

But, currently, the driver has no idea which architecture is OK and
which not, and which method to choose.  That is where we got stuck.


Takashi

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
  2007-08-07 17:54             ` Ralf Baechle
@ 2007-08-09  1:24               ` Songmao Tian
  -1 siblings, 0 replies; 41+ messages in thread
From: Songmao Tian @ 2007-08-09  1:24 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, alsa-devel, tiwai, greg, Atsushi Nemoto, jiankemeng

Ralf Baechle wrote:
> On Tue, Aug 07, 2007 at 11:01:57PM +0900, Atsushi Nemoto wrote:
>
>   
>> On Tue, 7 Aug 2007 10:18:04 +0400, "Dajie Tan" <jiankemeng@gmail.com> wrote:
>>     
>>>  static inline unsigned long virt_to_phys(volatile const void *address)
>>>  {
>>> -       return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
>>> +       return ((unsigned long)address & 0x1fffffff) + PHYS_OFFSET;
>>>  }
>>>       
>> This makes virt_to_phys() a bit slower, and more importantly, breaks
>> 64-bit kernel.
>>     
>
> It's ALSA that is doing funny things here so there is no point in fixing
> the arch code to work for ALSA.
>
>   Ralf
>
>
>   
arm has made a dma_mmap_coherent, but I don't quite understand the code 
and I am not sure the situation is the same.


Tian

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: ALSA on MIPS platform
@ 2007-08-09  1:24               ` Songmao Tian
  0 siblings, 0 replies; 41+ messages in thread
From: Songmao Tian @ 2007-08-09  1:24 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Atsushi Nemoto, jiankemeng, linux-mips, alsa-devel, tiwai, greg

Ralf Baechle wrote:
> On Tue, Aug 07, 2007 at 11:01:57PM +0900, Atsushi Nemoto wrote:
>
>   
>> On Tue, 7 Aug 2007 10:18:04 +0400, "Dajie Tan" <jiankemeng@gmail.com> wrote:
>>     
>>>  static inline unsigned long virt_to_phys(volatile const void *address)
>>>  {
>>> -       return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
>>> +       return ((unsigned long)address & 0x1fffffff) + PHYS_OFFSET;
>>>  }
>>>       
>> This makes virt_to_phys() a bit slower, and more importantly, breaks
>> 64-bit kernel.
>>     
>
> It's ALSA that is doing funny things here so there is no point in fixing
> the arch code to work for ALSA.
>
>   Ralf
>
>
>   
arm has made a dma_mmap_coherent, but I don't quite understand the code 
and I am not sure the situation is the same.


Tian

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2007-08-09  1:26 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-01  7:56 ALSA on MIPS platform Songmao Tian
2007-08-02 14:56 ` Atsushi Nemoto
2007-08-03 13:50   ` Songmao Tian
2007-08-03 13:50     ` Songmao Tian
2007-08-03 13:59     ` Takashi Iwai
2007-08-03 13:59       ` [alsa-devel] " Takashi Iwai
2007-08-03 15:57       ` Songmao Tian
2007-08-03 15:57         ` [alsa-devel] " Songmao Tian
2007-08-06 12:17         ` Takashi Iwai
2007-08-06 12:17           ` [alsa-devel] " Takashi Iwai
2007-08-07  5:53     ` Dajie Tan
2007-08-07  6:18       ` Dajie Tan
2007-08-07 14:01         ` Atsushi Nemoto
2007-08-07 17:54           ` Ralf Baechle
2007-08-07 17:54             ` Ralf Baechle
2007-08-07 18:41             ` Takashi Iwai
2007-08-07 18:41               ` Takashi Iwai
2007-08-08 11:58               ` Ralf Baechle
2007-08-08 11:58                 ` Ralf Baechle
2007-08-08 12:40                 ` Maciej W. Rozycki
2007-08-08 12:57                 ` Takashi Iwai
2007-08-08 12:57                   ` Takashi Iwai
2007-08-09  1:24             ` Songmao Tian
2007-08-09  1:24               ` Songmao Tian
2007-08-08  0:40           ` Songmao Tian
2007-08-08  0:40             ` [alsa-devel] " Songmao Tian
  -- strict thread matches above, loose matches on Subject: below --
2006-01-25 14:50 Atsushi Nemoto
2006-01-25 19:03 ` Takashi Iwai
2006-01-26 15:29   ` Atsushi Nemoto
2006-01-26 16:02     ` Takashi Iwai
2006-01-26 19:19       ` Hugh Dickins
2006-01-27 15:45       ` Atsushi Nemoto
2006-01-27 15:49         ` Martin Michlmayr
2006-01-27 16:01           ` Takashi Iwai
2006-01-27 15:57         ` Takashi Iwai
2006-01-30  9:56           ` Atsushi Nemoto
2006-01-30 10:18             ` Takashi Iwai
2006-01-30 10:38               ` Atsushi Nemoto
2006-01-30 12:25               ` Ralf Baechle
2006-01-30 15:46               ` Martin Michlmayr
2006-01-30 15:52                 ` Takashi Iwai

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.