Re: ALSA fixes for non-coherent archs (Re: [PATCH] Sam440ep support)
At Mon, 19 May 2008 19:23:10 +0200, Giuseppe Coviello wrote: On mer, 14/05/2008 14.26 +0200, Takashi Iwai wrote: [cut] OK, here is another patch for testing. Since I lost my old patch somewhere (and it's not worth to dig the archive), I wrote it up quickly from scratch. This version should cover both SG and non-SG buffers. It's against the latest git tree. The patch adds a hackish verison of dma_mmap_coherent() for some architectures in sound/core/pcm_native.c. I'm not sure whether this works. I just tested it on X86. It'd be appreciated if someone can test this. Also, this disables HDSPM driver for non-X86/IA64 since the driver has own copy and silence methods that are incompatible with the new SG-buffer data. And, yes, I know we need to clean up huge messes in ALSA memory handling routines. But, let's fix obvious bugs before starting a big rewrite... I've just tested this patch on the sam440ep and it works great (and sounds great, of course). I had also to make the following changes: Hmm, weird. cs4281 has no SG buffer at all, so basically it cannot work like that... FYI, the latest patches can be found on git://git.kernel.org/pub/scm/linux/kernel/tiwai/sound-unstable-2.6.git thanks, Takashi Signed-off-by: Giuseppe Coviello [EMAIL PROTECTED] diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 7556fd9..f5f208e 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -952,6 +952,9 @@ static struct snd_pcm_ops snd_cs4281_playback_ops = { .prepare = snd_cs4281_playback_prepare, .trigger = snd_cs4281_trigger, .pointer = snd_cs4281_pointer, + .copy = snd_pcm_sgbuf_ops_copy, + .silence = snd_pcm_sgbuf_ops_silence, + .page = snd_pcm_sgbuf_ops_page, }; static struct snd_pcm_ops snd_cs4281_capture_ops = { @@ -963,6 +966,8 @@ static struct snd_pcm_ops snd_cs4281_capture_ops = { .prepare = snd_cs4281_capture_prepare, .trigger = snd_cs4281_trigger, .pointer = snd_cs4281_pointer, + .copy = snd_pcm_sgbuf_ops_copy, + .page = snd_pcm_sgbuf_ops_page, }; static int __devinit snd_cs4281_pcm(struct cs4281 * chip, int device, ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: ALSA fixes for non-coherent archs (Re: [PATCH] Sam440ep support)
On mer, 14/05/2008 14.26 +0200, Takashi Iwai wrote: [cut] OK, here is another patch for testing. Since I lost my old patch somewhere (and it's not worth to dig the archive), I wrote it up quickly from scratch. This version should cover both SG and non-SG buffers. It's against the latest git tree. The patch adds a hackish verison of dma_mmap_coherent() for some architectures in sound/core/pcm_native.c. I'm not sure whether this works. I just tested it on X86. It'd be appreciated if someone can test this. Also, this disables HDSPM driver for non-X86/IA64 since the driver has own copy and silence methods that are incompatible with the new SG-buffer data. And, yes, I know we need to clean up huge messes in ALSA memory handling routines. But, let's fix obvious bugs before starting a big rewrite... I've just tested this patch on the sam440ep and it works great (and sounds great, of course). I had also to make the following changes: Signed-off-by: Giuseppe Coviello [EMAIL PROTECTED] diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 7556fd9..f5f208e 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -952,6 +952,9 @@ static struct snd_pcm_ops snd_cs4281_playback_ops = { .prepare = snd_cs4281_playback_prepare, .trigger = snd_cs4281_trigger, .pointer = snd_cs4281_pointer, + .copy = snd_pcm_sgbuf_ops_copy, + .silence = snd_pcm_sgbuf_ops_silence, + .page = snd_pcm_sgbuf_ops_page, }; static struct snd_pcm_ops snd_cs4281_capture_ops = { @@ -963,6 +966,8 @@ static struct snd_pcm_ops snd_cs4281_capture_ops = { .prepare = snd_cs4281_capture_prepare, .trigger = snd_cs4281_trigger, .pointer = snd_cs4281_pointer, + .copy = snd_pcm_sgbuf_ops_copy, + .page = snd_pcm_sgbuf_ops_page, }; static int __devinit snd_cs4281_pcm(struct cs4281 * chip, int device, ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
ALSA fixes for non-coherent archs (Re: [PATCH] Sam440ep support)
At Tue, 06 May 2008 11:16:22 +0200, Gerhard Pircher wrote: Original-Nachricht Datum: Tue, 06 May 2008 18:48:39 +1000 Von: Benjamin Herrenschmidt [EMAIL PROTECTED] An: Gerhard Pircher [EMAIL PROTECTED] CC: linuxppc-dev@ozlabs.org, Takashi Iwai [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] Betreff: Re: [PATCH] Sam440ep support On Tue, 2008-05-06 at 09:51 +0200, Gerhard Pircher wrote: Takashi Iwai posted a preliminary patch a long time ago. I tested it on my machine and it failed with non coherent scatter-gather DMA allocations (I guess almost all ALSA PCI drivers use SG DMA?). How does Alsa allocate such SG ? I can't answer this question. *ducked* :-) Takashi? FYI: I posted the results of the test with Takashi's dma_mmap_coherent patch here: http://ozlabs.org/pipermail/linuxppc-dev/2006-June/024078.html On the other side it looks like this problem does not only affect ALSA. As far as I can tell also some V4L(2) drivers have a problem with mmaping non coherent DMA allocations, but I'm not sure (it's a long time since I did some tests with video cards on my AmigaOne). Naturally I can do some tests, if you or Takashi come up with a new patch. OK, here is another patch for testing. Since I lost my old patch somewhere (and it's not worth to dig the archive), I wrote it up quickly from scratch. This version should cover both SG and non-SG buffers. It's against the latest git tree. The patch adds a hackish verison of dma_mmap_coherent() for some architectures in sound/core/pcm_native.c. I'm not sure whether this works. I just tested it on X86. It'd be appreciated if someone can test this. Also, this disables HDSPM driver for non-X86/IA64 since the driver has own copy and silence methods that are incompatible with the new SG-buffer data. And, yes, I know we need to clean up huge messes in ALSA memory handling routines. But, let's fix obvious bugs before starting a big rewrite... thanks, Takashi --- diff --git a/include/sound/memalloc.h b/include/sound/memalloc.h index ae2921d..ccf3dfa 100644 --- a/include/sound/memalloc.h +++ b/include/sound/memalloc.h @@ -62,6 +62,18 @@ struct snd_dma_buffer { void *private_data; /* private for allocator; don't touch */ }; +/* needs to use dma_mmap_coherent() for pages allocated via + * dma_alloc_coherent() + */ +#ifdef CONFIG_HAS_DMA +#if (defined(CONFIG_PPC32) !defined(CONFIG_CONFIG_NOT_COHERENT_CACHE)) || \ + defined(CONFIG_ARM) || \ + defined(CONFIG_MIPS) || \ + defined(CONFIG_PARISC) +#define SND_NEEDS_DMA_MMAP_COHERENT +#endif /* archs */ +#endif /* CONFIG_HAS_DMA */ + /* * Scatter-Gather generic device pages */ @@ -75,7 +87,9 @@ struct snd_sg_buf { int pages; /* allocated pages */ int tblsize;/* allocated table size */ struct snd_sg_page *table; /* address table */ +#ifndef SND_NEEDS_DMA_MMAP_COHERENT struct page **page_table; /* page table (for vmap/vunmap) */ +#endif struct device *dev; }; diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 51d58cc..2e68420 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -969,10 +969,25 @@ int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm, int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size); int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream); +/* + * SG-buffer + */ #define snd_pcm_substream_sgbuf(substream) ((substream)-runtime-dma_buffer_p-private_data) #define snd_pcm_sgbuf_pages(size) snd_sgbuf_aligned_pages(size) #define snd_pcm_sgbuf_get_addr(sgbuf,ofs) snd_sgbuf_get_addr(sgbuf,ofs) + +#ifdef SND_NEEDS_DMA_MMAP_COHERENT +int snd_pcm_sgbuf_ops_copy(struct snd_pcm_substream *substream, + int channel, snd_pcm_uframes_t pos, + void __user *buf, snd_pcm_uframes_t count); +int snd_pcm_sgbuf_ops_silence(struct snd_pcm_substream *substream, int channel, + snd_pcm_uframes_t pos, snd_pcm_uframes_t count); +#define snd_pcm_sgbuf_ops_page NULL +#else +#define snd_pcm_sgbuf_ops_copy NULL +#define snd_pcm_sgbuf_ops_silence NULL struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigned long offset); +#endif /* handle mmap counter - PCM mmap callback should handle this counter properly */ static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area) diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index ff07b4a..9e57032 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -306,6 +306,126 @@ int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm, EXPORT_SYMBOL(snd_pcm_lib_preallocate_pages_for_all); +#ifdef SND_NEEDS_DMA_MMAP_COHERENT +/* + * snd_pcm_sgbuf_ops_copy - copy callback for DMA SG-buffer + */ +int snd_pcm_sgbuf_ops_copy(struct snd_pcm_substream *substream, +
Re: ALSA fixes for non-coherent archs (Re: [PATCH] Sam440ep support)
Original-Nachricht Datum: Wed, 14 May 2008 14:26:53 +0200 Von: Takashi Iwai [EMAIL PROTECTED] An: Gerhard Pircher [EMAIL PROTECTED] CC: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], linuxppc-dev@ozlabs.org, [EMAIL PROTECTED] Betreff: ALSA fixes for non-coherent archs (Re: [PATCH] Sam440ep support) At Tue, 06 May 2008 11:16:22 +0200, Gerhard Pircher wrote: Naturally I can do some tests, if you or Takashi come up with a new patch. OK, here is another patch for testing. Since I lost my old patch somewhere (and it's not worth to dig the archive), I wrote it up quickly from scratch. This version should cover both SG and non-SG buffers. It's against the latest git tree. Thanks a lot! I'll test it tonight, if I can get the lastest kernel version running on my A1 (2.6.26-rc1 oopsed already on startup and Kumar's fixmap patch for highmem seems to break dma-noncoherent.c). regards, Gerhard -- 249 Spiele für nur 1 Preis. Die GMX Spieleflatrate schon ab 9,90 Euro. Neu: Asterix bei den Olympischen Spielen: http://flat.games.gmx.de ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: ALSA fixes for non-coherent archs (Re: [PATCH] Sam440ep support)
Original-Nachricht Datum: Wed, 14 May 2008 14:26:53 +0200 Von: Takashi Iwai [EMAIL PROTECTED] An: Gerhard Pircher [EMAIL PROTECTED] CC: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], linuxppc-dev@ozlabs.org, [EMAIL PROTECTED] Betreff: ALSA fixes for non-coherent archs (Re: [PATCH] Sam440ep support) At Tue, 06 May 2008 11:16:22 +0200, Gerhard Pircher wrote: Naturally I can do some tests, if you or Takashi come up with a new patch. OK, here is another patch for testing. Since I lost my old patch somewhere (and it's not worth to dig the archive), I wrote it up quickly from scratch. This version should cover both SG and non-SG buffers. It's against the latest git tree. The patch adds a hackish verison of dma_mmap_coherent() for some architectures in sound/core/pcm_native.c. I'm not sure whether this works. I just tested it on X86. It'd be appreciated if someone can test this. Also, this disables HDSPM driver for non-X86/IA64 since the driver has own copy and silence methods that are incompatible with the new SG-buffer data. And, yes, I know we need to clean up huge messes in ALSA memory handling routines. But, let's fix obvious bugs before starting a big rewrite... Okay, it seems to work fine so far. No lock-ups or kernel oopses. Tested with kernel v2.6.26-rc2 and a Soundblaster 5.1/EMU10k1 device (which was not working with the old patch) on my non cache coherent G4 system. Thanks again! Gerhard -- Pt! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: ALSA fixes for non-coherent archs (Re: [PATCH] Sam440ep support)
At Wed, 14 May 2008 23:01:10 +0200, Gerhard Pircher wrote: Original-Nachricht Datum: Wed, 14 May 2008 14:26:53 +0200 Von: Takashi Iwai [EMAIL PROTECTED] An: Gerhard Pircher [EMAIL PROTECTED] CC: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], linuxppc-dev@ozlabs.org, [EMAIL PROTECTED] Betreff: ALSA fixes for non-coherent archs (Re: [PATCH] Sam440ep support) At Tue, 06 May 2008 11:16:22 +0200, Gerhard Pircher wrote: Naturally I can do some tests, if you or Takashi come up with a new patch. OK, here is another patch for testing. Since I lost my old patch somewhere (and it's not worth to dig the archive), I wrote it up quickly from scratch. This version should cover both SG and non-SG buffers. It's against the latest git tree. The patch adds a hackish verison of dma_mmap_coherent() for some architectures in sound/core/pcm_native.c. I'm not sure whether this works. I just tested it on X86. It'd be appreciated if someone can test this. Also, this disables HDSPM driver for non-X86/IA64 since the driver has own copy and silence methods that are incompatible with the new SG-buffer data. And, yes, I know we need to clean up huge messes in ALSA memory handling routines. But, let's fix obvious bugs before starting a big rewrite... Okay, it seems to work fine so far. No lock-ups or kernel oopses. Tested with kernel v2.6.26-rc2 and a Soundblaster 5.1/EMU10k1 device (which was not working with the old patch) on my non cache coherent G4 system. Good to hear. The next step is to move dma_mmap_coherent() to arch/* directories... Takashi ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev