Skip to contentSkip to conversation

ALSA fixes for non-coherent ppc32 again

DISCUSSION Gerhard Pircher 3 participants 13 messages Jun 21, 2009 – Jul 9, 2009 PowerPC

lore
Share & tools
lore
#0 lore raw

Hi,

Takashi Iwai posted patches to make ALSA work on non-coherent PPC32 systems (almost exactly) a year ago. See here:
http://www.nabble.com/-PATCH-0-3--ALSA-fixes-for-non-coherent-ppc32-to17980027.html#a17980027

As far as I can see these patches never went upstream. Where there any objections or did we just forget about them? It would be cool, if the patches could be merged now, as at least two platforms need this bugfix (namely Sam440 and AmigaOne).

Thanks!

Gerhard

Signature · 2 lines
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
#1 lore raw
Quoted 10 lines · Gerhard Pircher

Hi,

Takashi Iwai posted patches to make ALSA work on non-coherent PPC32 systems (almost exactly) a year ago. See here:
http://www.nabble.com/-PATCH-0-3--ALSA-fixes-for-non-coherent-ppc32-to17980027.html#a17980027

As far as I can see these patches never went upstream. Where there any objections or did we just forget about them? It would be cool, if the patches could be merged now, as at least two platforms need this bugfix (namely Sam440 and AmigaOne).

I definitely forgot about those... But I'm fine with what Takashi did for now, I can always make the powerpc helper for dma_mmap_coherent() smarter later on if necessary.

Cheers,
Ben.

#2 lore raw

At Mon, 22 Jun 2009 08:34:38 +1000,

Quoted 8 lines · Benjamin Herrenschmidt
Quoted 6 lines · Gerhard Pircher

Hi,

Takashi Iwai posted patches to make ALSA work on non-coherent PPC32 systems (almost exactly) a year ago. See here:
http://www.nabble.com/-PATCH-0-3--ALSA-fixes-for-non-coherent-ppc32-to17980027.html#a17980027

Quoted 6 lines
Quoted 4 lines

As far as I can see these patches never went upstream. Where there any objections or did we just forget about them? It would be cool, if the patches could be merged now, as at least two platforms need this bugfix (namely Sam440 and AmigaOne).

I definitely forgot about those...

Me, too, almost... :)

Quoted 3 lines

But I'm fine with what Takashi did
for now, I can always make the powerpc helper for dma_mmap_coherent() smarter later on if necessary.

I updated the patch series for 2.6.31, including sparc32, parisc, mips and sh support. The patches are 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

The old patches for 2.6.30 is found at history/dma-fix-2.6.30 branch there, too.

For merging to the upstream, we'll need definitely discussions on linux-arch ML or so, as once James Bottomley suggested. I'll try to make it up once after the merge window.

But, it'd be helpful if someone can test the patches above beforehand, of course :)

thanks,

Takashi

#3 lore raw

-------- Original-Nachricht --------

Quoted 17 lines

Datum: Mon, 22 Jun 2009 09:12:35 +0200
Von: Takashi Iwai <[email protected]>
An: Benjamin Herrenschmidt <[email protected]>
CC: Gerhard Pircher <[email protected]>, [email protected]
Betreff: Re: ALSA fixes for non-coherent ppc32 again

At Mon, 22 Jun 2009 08:34:38 +1000,

Quoted 9 lines · Benjamin Herrenschmidt
Quoted 7 lines · Gerhard Pircher

Hi,

Takashi Iwai posted patches to make ALSA work on non-coherent PPC32 systems (almost exactly) a year ago. See here:

http://www.nabble.com/-PATCH-0-3--ALSA-fixes-for-non-coherent-ppc32-to17980027.html#a17980027

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

As far as I can see these patches never went upstream. Where there any objections or did we just forget about them? It would be cool, if the patches could be merged now, as at least two platforms need this bugfix (namely Sam440 and AmigaOne).

I definitely forgot about those...

Me, too, almost... :)

:)

Quoted 9 lines
Quoted 3 lines

But I'm fine with what Takashi did
for now, I can always make the powerpc helper for dma_mmap_coherent() smarter later on if necessary.

I updated the patch series for 2.6.31, including sparc32, parisc, mips and sh support. The patches are 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

Thanks!

Quoted 10 lines

The old patches for 2.6.30 is found at history/dma-fix-2.6.30 branch there, too.

For merging to the upstream, we'll need definitely discussions on linux-arch ML or so, as once James Bottomley suggested. I'll try to make it up once after the merge window.

But, it'd be helpful if someone can test the patches above beforehand, of course :)

Sure, I'll give it a try until tomorrow.

Gerhard

Signature · 2 lines
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
#4 lore raw
In reply to Takashi Iwai

-------- Original-Nachricht --------

Quoted 8 lines

Datum: Mon, 22 Jun 2009 09:12:35 +0200
Von: Takashi Iwai <[email protected]>
An: Benjamin Herrenschmidt <[email protected]>
CC: Gerhard Pircher <[email protected]>, [email protected]
Betreff: Re: ALSA fixes for non-coherent ppc32 again

But, it'd be helpful if someone can test the patches above beforehand, of course :)

Okay, I checked out your test/dma-fix branch and reformatted your
dma_mmap_coherent for powerpc patch ( http://www.nabble.com/-PATCH-0-3--ALSA-fixes-for-non-coherent-ppc32-to17980027.html#a17980027 ) to adapt it for dma_mapping_ops (please take a look at the patch below).
I also had to change "def_bool n" to "def_bool y" for SND_NONCOHERENT_DMA
to actually enable it.

Unfortunately the build process stops with these error messages here (but compiles fine, if SND_COHERENT_DMA is not selected):

CC [M] sound/core/memalloc.o
CC [M] sound/core/sgbuf.o
sound/core/sgbuf.c: In function ‘snd_free_sgbuf_pages’:
sound/core/sgbuf.c:46: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:47: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:48: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:50: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:51: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:52: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:56: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:57: error: dereferencing pointer to incomplete type sound/core/sgbuf.c: In function ‘snd_malloc_sgbuf_pages’:
sound/core/sgbuf.c:78: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:81: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:82: error: implicit declaration of function ‘snd_sgbuf_aligned_pages’ sound/core/sgbuf.c:83: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:84: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:84: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:87: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:88: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:91: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:103: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:107: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:112: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:113: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:115: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:116: error: increment of pointer to unknown structure sound/core/sgbuf.c:116: error: arithmetic on pointer to an incomplete type sound/core/sgbuf.c:121: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:127: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:128: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:128: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:132: error: dereferencing pointer to incomplete type

I also tried to compile it with the orginal dma_mmap_coherent for powerpc patch, but that doesn't make a difference.

As the next step I applied the reformatted dma_mmap_coherent patch and the following patches from your test/dma-fix branch to a 2.6.30-rc8 branch:
- ALSA: Remove old DMA-mmap code from arm/devdma.c
- ALSA: Fix SG-buffer DMA with non-coherent architectures
- ALSA: Fix mapping of DMA buffers

This one compiled fine, but ALSA didn't work. No kernel oops, just the sound of silence. :)

Any idea what's wrong here or if I did something wrong?

Thanks!

Gerhard

---
 arch/powerpc/include/asm/dma-mapping.h |   14 ++++++++++++++
 arch/powerpc/kernel/dma.c              |   21 +++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/dma-mapping.h +14 -0
index 3d9e887..6fbeafe 100644
@@ -89,6 +89,8 @@ struct dma_mapping_ops {
                 struct dma_attrs *attrs);
     int        (*addr_needs_map)(struct device *dev, dma_addr_t addr,
                 size_t size);
+    int        (*mmap_coherent)(struct device *dev, struct vm_area_struct *vma,
+                void *cpu_addr, dma_addr_t handle, size_t size);
 #ifdef CONFIG_PPC_NEED_DMA_SYNC_OPS
     void            (*sync_single_range_for_cpu)(struct device *hwdev,
                 dma_addr_t dma_handle, unsigned long offset,
@@ -301,6 +303,18 @@ static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
     dma_unmap_sg_attrs(dev, sg, nhwentries, direction, NULL);
 }
 
+static inline int dma_mmap_coherent(struct device *dev,
+                    struct vm_area_struct *vma,
+                    void *cpu_addr, dma_addr_t handle,
+                    size_t size)
+{
+    struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+
+    BUG_ON(!dma_ops);
+
+    return dma_ops->mmap_coherent(dev, vma, cpu_addr, handle, size);
+}
+
 #ifdef CONFIG_PPC_NEED_DMA_SYNC_OPS
 static inline void dma_sync_single_for_cpu(struct device *dev,
         dma_addr_t dma_handle, size_t size,
arch/powerpc/kernel/dma.c +21 -0
index 20a60d6..7ff3772 100644
@@ -120,6 +120,26 @@ static inline void dma_direct_unmap_page(struct device *dev,
 {
 }
 
+/*
+ * A helper to mmap the pages allocated via dma_alloc_coherent()
+ */
+static inline int dma_direct_mmap_coherent(struct device *dev,
+                       struct vm_area_struct *vma,
+                       void *cpu_addr, dma_addr_t handle,
+                       size_t size)
+{
+    struct page *pg;
+
+#ifdef CONFIG_NOT_COHERENT_CACHE
+    /* I'm too lazy and can't stop using bus_to_virt() here... */
+    cpu_addr = bus_to_virt(handle);
+#endif
+    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);
+}
+
 #ifdef CONFIG_NOT_COHERENT_CACHE
 static inline void dma_direct_sync_sg(struct device *dev,
         struct scatterlist *sgl, int nents,
@@ -148,6 +168,7 @@ struct dma_mapping_ops dma_direct_ops = {
     .dma_supported    = dma_direct_dma_supported,
     .map_page    = dma_direct_map_page,
     .unmap_page    = dma_direct_unmap_page,
+    .mmap_coherent    = dma_direct_mmap_coherent,
 #ifdef CONFIG_NOT_COHERENT_CACHE
     .sync_single_range_for_cpu     = dma_direct_sync_single_range,
     .sync_single_range_for_device     = dma_direct_sync_single_range,
Signature · 4 lines
1.5.6.5
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
#5 lore raw

-------- Original-Nachricht --------

Quoted 71 lines

Datum: Tue, 23 Jun 2009 10:55:54 +0200
Von: "Gerhard Pircher" <[email protected]>
An: Takashi Iwai <[email protected]>, [email protected]
CC: [email protected]
Betreff: Re: ALSA fixes for non-coherent ppc32 again

-------- Original-Nachricht --------

Quoted 8 lines

Datum: Mon, 22 Jun 2009 09:12:35 +0200
Von: Takashi Iwai <[email protected]>
An: Benjamin Herrenschmidt <[email protected]>
CC: Gerhard Pircher <[email protected]>, [email protected]
Betreff: Re: ALSA fixes for non-coherent ppc32 again

But, it'd be helpful if someone can test the patches above beforehand, of course :)

Okay, I checked out your test/dma-fix branch and reformatted your dma_mmap_coherent for powerpc patch (
http://www.nabble.com/-PATCH-0-3--ALSA-fixes-for-non-coherent-ppc32-to17980027.html#a17980027 ) to adapt it for dma_mapping_ops (please take a look at the patch below).
I also had to change "def_bool n" to "def_bool y" for SND_NONCOHERENT_DMA
to actually enable it.

Unfortunately the build process stops with these error messages here (but compiles fine, if SND_COHERENT_DMA is not selected):

CC [M] sound/core/memalloc.o
CC [M] sound/core/sgbuf.o
sound/core/sgbuf.c: In function ‘snd_free_sgbuf_pages’:
sound/core/sgbuf.c:46: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:47: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:48: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:50: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:51: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:52: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:56: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:57: error: dereferencing pointer to incomplete type sound/core/sgbuf.c: In function ‘snd_malloc_sgbuf_pages’:
sound/core/sgbuf.c:78: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:81: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:82: error: implicit declaration of function ‘snd_sgbuf_aligned_pages’
sound/core/sgbuf.c:83: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:84: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:84: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:87: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:88: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:91: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:103: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:107: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:112: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:113: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:115: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:116: error: increment of pointer to unknown structure sound/core/sgbuf.c:116: error: arithmetic on pointer to an incomplete type sound/core/sgbuf.c:121: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:127: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:128: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:128: error: dereferencing pointer to incomplete type sound/core/sgbuf.c:132: error: dereferencing pointer to incomplete type

I also tried to compile it with the orginal dma_mmap_coherent for powerpc patch, but that doesn't make a difference.

As the next step I applied the reformatted dma_mmap_coherent patch and the following patches from your test/dma-fix branch to a 2.6.30-rc8 branch:
- ALSA: Remove old DMA-mmap code from arm/devdma.c
- ALSA: Fix SG-buffer DMA with non-coherent architectures
- ALSA: Fix mapping of DMA buffers

Quoted 2 lines

This one compiled fine, but ALSA didn't work. No kernel oops, just the sound of silence. :)

Okay, that's wrong. I somehow messed up the .config file. It doesn't compile, too.

Gerhard

Signature · 2 lines
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
#6 lore raw

-------- Original-Nachricht --------

Quoted 8 lines

Datum: Tue, 23 Jun 2009 23:42:24 +0200
Von: "Gerhard Pircher" <[email protected]>
An: [email protected], [email protected]
CC: [email protected]
Betreff: Re: ALSA fixes for non-coherent ppc32 again

Okay, that's wrong. I somehow messed up the .config file. It doesn't compile, too.

I got it to compile now and it seems to work fine. I overlooked a typo in sound/core/Makefile first (ifndef CONFIG_SND_NONCOHERNT_DMA.)

                                                        ^

I vote for a merge, if the config option and the typo is fixed. Ben, should I resend a properly formatted patch for the dma_mmap_coherent implementation or can we take the patch I already sent?

Thanks!

Gerhard

Signature · 2 lines
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
#7 lore raw

At Wed, 24 Jun 2009 10:46:01 +0200,

Quoted 9 lines · Gerhard Pircher

-------- Original-Nachricht --------

Quoted 5 lines

Datum: Tue, 23 Jun 2009 23:42:24 +0200
Von: "Gerhard Pircher" <[email protected]>
An: [email protected], [email protected]
CC: [email protected]
Betreff: Re: ALSA fixes for non-coherent ppc32 again

Quoted 4 lines
Quoted 2 lines

Okay, that's wrong. I somehow messed up the .config file. It doesn't compile, too.

I got it to compile now and it seems to work fine. I overlooked a typo in sound/core/Makefile first (ifndef CONFIG_SND_NONCOHERNT_DMA.)

Gah, thanks, fixed now on the git tree too.

Takashi

#8 lore raw

-------- Original-Nachricht --------

Quoted 17 lines

Datum: Wed, 24 Jun 2009 11:47:13 +0200
Von: Takashi Iwai <[email protected]>
An: "Gerhard Pircher" <[email protected]>
CC: [email protected], [email protected]
Betreff: Re: ALSA fixes for non-coherent ppc32 again

At Wed, 24 Jun 2009 10:46:01 +0200,

Quoted 9 lines · Gerhard Pircher

-------- Original-Nachricht --------

Quoted 5 lines

Datum: Tue, 23 Jun 2009 23:42:24 +0200
Von: "Gerhard Pircher" <[email protected]>
An: [email protected], [email protected]
CC: [email protected]
Betreff: Re: ALSA fixes for non-coherent ppc32 again

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Okay, that's wrong. I somehow messed up the .config file. It doesn't compile, too.

I got it to compile now and it seems to work fine. I overlooked a typo in sound/core/Makefile first (ifndef CONFIG_SND_NONCOHERNT_DMA.)

Gah, thanks, fixed now on the git tree too.

The Kconfig option still needs to be fixed, otherwise SND_COHERENT_DMA isn't selected for my "PPC32 && NOT_COHERENT_CACHE" machine.

config SND_NONCOHERENT_DMA
def_bool n <-- should be "y" depends on (PPC32 && NOT_COHERENT_CACHE)...

BTW: Can you put me on CC: please, if you bring up this topic on linux-arch or so?

Gerhard

Signature · 2 lines
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
#10 lore raw
In reply to Benjamin Herrenschmidt
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 6 lines · Gerhard Pircher

Hi,

Takashi Iwai posted patches to make ALSA work on non-coherent PPC32 systems (almost exactly) a year ago. See here:
http://www.nabble.com/-PATCH-0-3--ALSA-fixes-for-non-coherent-ppc32-to17980027.html#a17980027

Quoted 8 lines
Quoted 4 lines

As far as I can see these patches never went upstream. Where there any objections or did we just forget about them? It would be cool, if the patches could be merged now, as at least two platforms need this bugfix (namely Sam440 and AmigaOne).

I definitely forgot about those... But I'm fine with what Takashi did for now, I can always make the powerpc helper for dma_mmap_coherent() smarter later on if necessary.

BTW. Can you guys send a "final" patch for adding mmap_coherent to powerpc ? Please make so that the dma_mmap_coherent() function doesn't explose if dma_ops->mmap_coherent is NULL though (either fail gracefully or fallback to some standard mmap).

Note that we probably need to add the virtual address too. IE. On platforms with an iommu, we cannot easily go back from the dma_addr_t to the memory address, it's easier to do that from the virtual address in fact.

Cheers,
Ben.

#11 lore raw

At Wed, 08 Jul 2009 13:01:50 +1000,

Quoted 8 lines · Benjamin Herrenschmidt

=20

Quoted 6 lines · Benjamin Herrenschmidt
Quoted 5 lines · Gerhard Pircher

Hi,
=20
Takashi Iwai posted patches to make ALSA work on non-coherent PPC32 systems (almost exactly) a year ago. See here:
http://www.nabble.com/-PATCH-0-3--ALSA-fixes-for-non-coherent-ppc32-t=

o17980027.html#a17980027

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

=20
As far as I can see these patches never went upstream. Where there any objections or did we just forget about them? It would be cool, if the patches could be merged now, as at least two platforms need this bugf=

ix

Quoted 10 lines
Quoted 5 lines
Quoted 1 line

(namely Sam440 and AmigaOne).

=20
I definitely forgot about those... But I'm fine with what Takashi did for now, I can always make the powerpc helper for dma_mmap_coherent() smarter later on if necessary.

=20
BTW. Can you guys send a "final" patch for adding mmap_coherent to powerpc ? Please make so that the dma_mmap_coherent() function doesn't explose if dma_ops->mmap_coherent is NULL though (either fail gracefully or fallback to some standard mmap).

The attached is the revised patch. It falls backs to the standard mmap.

The whole patch series are found in test/dma-fix branch of sound git tree below:
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git test/dm=
a-fix

I had no time to play cross-build yet, so it'd be helpful if someone can test it...
(BTW, any good minimal gcc and binutils package for kernel builds for
PPC32?)

Quoted 4 lines

Note that we probably need to add the virtual address too. IE. On platforms with an iommu, we cannot easily go back from the dma_addr_t to the memory address, it's easier to do that from the virtual address in fact.

Yes, the virtual address is passed as well. Which parameter to be used is just a matter of arch-specific implementation.

thanks,

Takashi

=3D=3D=3D
=46rom a8cb7ed04595785d902d3ad20ba2fe5ccbe31690 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Wed, 8 Jul 2009 11:35:56 +0200
Subject: [PATCH] powerpc: implement dma_mmap_coherent()

A lazy version of dma_mmap_coherent() implementation for powerpc. The standard mmap is used as a fallback.

---
 arch/powerpc/include/asm/dma-mapping.h |   22 ++++++++++++++++++++++
 arch/powerpc/kernel/dma.c              |   21 +++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)
arch/powerpc/include/= renamed from arch/powerpc/include/asm/dma-mapping.h +0 -0

asm/dma-mapping.h
index b44aaab..030a4b1 100644

arch/powerpc/include/asm/dma-mapping.h +4 -0
@@ -105,6 +105,10 @@ struct dma_mapping_ops {
 				struct scatterlist *sg, int nelems,
 				enum dma_data_direction direction);
 #endif
+	int		(*mmap_coherent)(struct device *hwdev,
+					 struct vm_area_struct *vma,
+					 void *cpu_addr, dma_addr_t dma_handle,
+					 size_t size);
 };

=20
/*
@@ -415,6 +419,24 @@ static inline void dma_sync_single_range_for_device(st= ruct device *dev,
}
#endif
=20
+#define ARCH_HAS_DMA_MMAP_COHERENT
+static inline int dma_mmap_coherent(struct device *dev,

+				    struct vm_area_struct *vma,
+				    void *cpu_addr, dma_addr_t dma_handle,
+				    size_t size)

+{
+ struct dma_mapping_ops *dma_ops =3D get_dma_ops(dev);
+
+ BUG_ON(!dma_ops);
+
+ if (dma_ops->mmap_coherent)
+ return dma_ops->mmap_coherent(dev, vma, cpu_addr, dma_handle,
+ size);
+ else
+ return dma_direct_ops.mmap_coherent(dev, vma, cpu_addr,
+ dma_handle, size);
+}
+
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_add=
r)
{
#ifdef CONFIG_PPC64

arch/powerpc/kernel/dma.c +0 -0
index 20a60d6..d11db99 100644
@@ -140,6 +140,26 @@ static inline void dma_direct_sync_single_range(struct=
 device *dev,
 }
 #endif

=20
+static int dma_direct_mmap_coherent(struct device *dev,

+				    struct vm_area_struct *vma,
+				    void *cpu_addr, dma_addr_t dma_handle,
+				    size_t size)

+{
+ unsigned long pfn;
+#ifdef CONFIG_NOT_COHERENT_CACHE
+ dma_handle -=3D get_dma_direct_offset(dev);
+ /* assume dma_handle set via pfn_to_phys() in
+ * mm/dma-noncoherent.c
+ */
+ pfn =3D dma_handle >> PAGE_SHIFT;
+#else
+ pfn =3D page_to_pfn(virt_to_page(cpu_addr));
+#endif
+ vma->vm_page_prot =3D pgprot_noncached(vma->vm_page_prot);
+ return remap_pfn_range(vma, vma->vm_start, pfn + vma->vm_pgoff,
+ size, vma->vm_page_prot);
+}
+
struct dma_mapping_ops dma_direct_ops =3D {
.alloc_coherent =3D dma_direct_alloc_coherent,
.free_coherent =3D dma_direct_free_coherent,
@@ -154,5 +174,6 @@ struct dma_mapping_ops dma_direct_ops =3D {
.sync_sg_for_cpu =3D dma_direct_sync_sg,
.sync_sg_for_device =3D dma_direct_sync_sg,
#endif
+ .mmap_coherent =3D dma_direct_mmap_coherent,
};
EXPORT_SYMBOL(dma_direct_ops);
--=20
1.6.3.2

#9 lore raw
In reply to Gerhard Pircher

At Fri, 26 Jun 2009 15:14:54 +0200,

Quoted 25 lines · Gerhard Pircher

-------- Original-Nachricht --------

Quoted 22 lines

Datum: Wed, 24 Jun 2009 11:47:13 +0200
Von: Takashi Iwai <[email protected]>
An: "Gerhard Pircher" <[email protected]>
CC: [email protected], [email protected]
Betreff: Re: ALSA fixes for non-coherent ppc32 again

At Wed, 24 Jun 2009 10:46:01 +0200,

Quoted 13 lines · Gerhard Pircher

-------- Original-Nachricht --------

Quoted 8 lines

Datum: Tue, 23 Jun 2009 23:42:24 +0200
Von: "Gerhard Pircher" <[email protected]>
An: [email protected], [email protected]
CC: [email protected]
Betreff: Re: ALSA fixes for non-coherent ppc32 again

Okay, that's wrong. I somehow messed up the .config file. It doesn't compile, too.

I got it to compile now and it seems to work fine. I overlooked a typo in sound/core/Makefile first (ifndef CONFIG_SND_NONCOHERNT_DMA.)

Quoted 8 lines
Quoted 1 line

Gah, thanks, fixed now on the git tree too.

The Kconfig option still needs to be fixed, otherwise SND_COHERENT_DMA isn't selected for my "PPC32 && NOT_COHERENT_CACHE" machine.

config SND_NONCOHERENT_DMA
def_bool n <-- should be "y" depends on (PPC32 && NOT_COHERENT_CACHE)...

Thanks. I changed the patch rather to add a define instead of Kconfig so that it can detect more easily.

Quoted 2 lines

BTW: Can you put me on CC: please, if you bring up this topic on linux-arch or so?

Sure.
Hopefully I can bring up the stuff in this week...

Takashi

#12 lore raw
In reply to Takashi Iwai

-------- Original-Nachricht --------

Quoted 40 lines

Datum: Wed, 08 Jul 2009 16:13:10 +0200
Von: Takashi Iwai <[email protected]>
An: Benjamin Herrenschmidt <[email protected]>
CC: Gerhard Pircher <[email protected]>, [email protected]
Betreff: Re: ALSA fixes for non-coherent ppc32 again

At Wed, 08 Jul 2009 13:01:50 +1000,

Quoted 15 lines · Benjamin Herrenschmidt
Quoted 13 lines · Benjamin Herrenschmidt
Quoted 11 lines · Gerhard Pircher

Hi,

Takashi Iwai posted patches to make ALSA work on non-coherent PPC32 systems (almost exactly) a year ago. See here:

http://www.nabble.com/-PATCH-0-3--ALSA-fixes-for-non-coherent-ppc32-to17980027.html#a17980027

As far as I can see these patches never went upstream. Where there any objections or did we just forget about them? It would be cool, if the patches could be merged now, as at least two platforms need this bugfix (namely Sam440 and AmigaOne).

Quoted 8 lines
Quoted 3 lines

I definitely forgot about those... But I'm fine with what Takashi did for now, I can always make the powerpc helper for dma_mmap_coherent() smarter later on if necessary.

BTW. Can you guys send a "final" patch for adding mmap_coherent to powerpc ? Please make so that the dma_mmap_coherent() function doesn't explose if dma_ops->mmap_coherent is NULL though (either fail gracefully or fallback to some standard mmap).

The attached is the revised patch. It falls backs to the standard mmap.

The whole patch series are found in test/dma-fix branch of sound git tree below:
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git
test/dma-fix

Quoted 4 lines

I had no time to play cross-build yet, so it'd be helpful if someone can test it...
(BTW, any good minimal gcc and binutils package for kernel builds for
PPC32?)

Okay, I cross-build it on a x86 machine and tested it on my AmigaOne with the VIA686 onboard sound and a Soundblaster 5.1. It worked fine after I applied the "ALSA: Fix SG-buffer DMA with non-coherent architectures" patch.

Thanks!

Gerhard

Signature · 2 lines
Neu: GMX Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate
für nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02