ALSA update broke Sparc
Each platform uses a different number of arguments for io_remap_page_range(), so you can't just blindly call it from generic code.
However, sound/core/pcm_native.c is doing exactly that.
The reason each platform takes a different number of args is that the "unsigned long" base address argument is only 32-bits on 32-bit platforms yet on some of such platforms I/O and physical memory addresses are larger than 32-bits.
Sparc and Sparc64 use a "space" argument to provide this upper 32-bits of information.
Also, what this PCM mmap'ing code is trying to do
is take I/O addresses and remap them into the process address space. pci_resource_start() values are not necessarily suitable for passing around as physical addresses. These things are well defined when used with ioremap() but that is it. I don't know if we've defined it such that passing these into io_remap_page_range() can be expected to work.
In fact, because of the sparc 32-bit issue, I know it won't work. You'll need to have the full resource structure available, as that's where we hide the upper 32-bits of the physical address on sparc32.
This is really non-portable, what the PCM code is doing. I would suggest, for the time being, to pass resources around and then have an arch-defined macro which takes the resource pointer and makes the appropriate io_remap_page_range() call.
Can I make a small formal request of the ALSA folks? Can you at least setup a cross-compiler to make sure your ALSA merges don't explode on sparc64? As it stands, 1 out of every 2 ALSA merges breaks the build on that platform.
Quoted 4 lines · David S. Miller
Can I make a small formal request of the ALSA folks? Can you at least setup a cross-compiler to make sure your ALSA merges don't explode on sparc64? As it stands, 1 out of every 2 ALSA merges breaks the build on that platform.
This is only one such small case. There's also the case of mmaping DMA buffers into userspace...
Signature · 4 lines
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial coreAt Fri, 27 Aug 2004 18:36:46 -0700,
Quoted 7 lines · David S. Miller
Each platform uses a different number of arguments for
io_remap_page_range(), so you can't just blindly call it from generic code.However,
sound/core/pcm_native.cis doing exactly that.
Argh, sorry about that. My ignorance.
Quoted 8 lines
The reason each platform takes a different number of args is that the "unsigned long" base address argument is only 32-bits on 32-bit platforms yet on some of such platforms I/O and physical memory addresses are larger than 32-bits.
Sparc and Sparc64 use a "space" argument to provide this upper 32-bits of information.
I'll fix this anyway - but, doesn't it make sense to change the argument type to more reasonable one for 64bit architectures (as wli posted)?
Quoted 14 lines
Also, what this PCM mmap'ing code is trying to do
is take I/O addresses and remap them into the process address space.pci_resource_start()values are not necessarily suitable for passing around as physical addresses. These things are well defined when used withioremap()but that is it. I don't know if we've defined it such that passing these intoio_remap_page_range()can be expected to work.In fact, because of the sparc 32-bit issue, I know it won't work. You'll need to have the full resource structure available, as that's where we hide the upper 32-bits of the physical address on sparc32.
Quoted 5 lines
This is really non-portable, what the PCM code is doing. I would suggest, for the time being, to pass resources around and then have an arch-defined macro which takes the resource pointer and makes the appropriate
io_remap_page_range()call.
Calling io_remap_page_range() in the PCM layer is provided only for certain PCI drivers such as nm256, so disabling this isn't a problem in general. Indeed, this feature should be disabled for architectures like sparc.
Or even better, as Russell King suggested before, we can hide arch-specific things by creating a generic mmap method for struct device. I see that sparc already has pci_mmap_page_range() for a similar purpose.
Quoted 4 lines
Can I make a small formal request of the ALSA folks? Can you at least setup a cross-compiler to make sure your ALSA merges don't explode on sparc64? As it stands, 1 out of every 2 ALSA merges breaks the build on that platform.
I'll try to set up.
--
Takashi Iwai <[email protected]> ALSA Developer - www.alsa-project.org
At Mon, 30 Aug 2004 12:26:30 +0200,
Quoted 7 lines · I wrote:
Quoted 5 lines
Can I make a small formal request of the ALSA folks? Can you at least setup a cross-compiler to make sure your ALSA merges don't explode on sparc64? As it stands, 1 out of every 2 ALSA merges breaks the build on that platform.
I'll try to set up.
Although I still couldn't set up the sparc cross-compile environment, I fixed/updated the ALSA pcm layer.
David, could you try the attached patch? With this, the problematic part will be disabled on sparc (it won't work on every architecture, anyway).
thanks,
Takashi
sound/core/pcm.c +3 -0
@@ -1050,6 +1050,9 @@EXPORT_SYMBOL (snd_pcm_playback_poll);EXPORT_SYMBOL (snd_pcm_capture_poll);EXPORT_SYMBOL (snd_pcm_mmap_data); +#if SNDRV_PCM_INFO_MMAP_IOMEM +EXPORT_SYMBOL (snd_pcm_lib_mmap_iomem); +#endif /* pcm_misc.c */ EXPORT_SYMBOL (snd_pcm_format_signed);EXPORT_SYMBOL (snd_pcm_format_unsigned);
sound/core/pcm_native.c +76 -24
147 lines not on this page · raw message
include/sound/asound.h +0 -1
@@ -275,7 +275,6 @@#define SNDRV_PCM_INFO_HALF_DUPLEX 0x00100000/* only half duplex */ #define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000/* playback and capture stream are somewhat correlated */ #define SNDRV_PCM_INFO_SYNC_START 0x00400000/* pcm support some kind of sync go */ -#define SNDRV_PCM_INFO_MMAP_IOMEM 0x01000000/* mmap on IO memory */ enum sndrv_pcm_state {SNDRV_PCM_STATE_OPEN =0 ,/* stream is open */
include/sound/pcm.h +23 -0
@@ -97,6 +97,7 @@int (*silence)(snd_pcm_substream_t *substream,int channel,snd_pcm_uframes_t pos,snd_pcm_uframes_t count);struct page *(*page)(snd_pcm_substream_t *substream,unsigned long offset); +int (*mmap)(snd_pcm_substream_t *substream,struct vm_area_struct *vma);int (*ack)(snd_pcm_substream_t *substream); } snd_pcm_ops_t;
@@ -938,6 +939,28 @@#define snd_pcm_sgbuf_get_addr (sgbuf,ofs) snd_sgbuf_get_addr(sgbuf,ofs)struct page *snd_pcm_sgbuf_ops_page (snd_pcm_substream_t *substream,unsigned long offset); +/* handle mmap counter - PCM mmap callback should handle this counter properly */ +static inline void snd_pcm_mmap_data_open (struct vm_area_struct *area) +{ +snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data; +atomic_inc (&substream->runtime->mmap_count); +} + +static inline void snd_pcm_mmap_data_close (struct vm_area_struct *area) +{ +snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data; +atomic_dec (&substream->runtime->mmap_count); +} + +/* mmap for io-memory area */ +#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__alpha__) +#define SNDRV_PCM_INFO_MMAP_IOMEM SNDRV_PCM_INFO_MMAP +int snd_pcm_lib_mmap_iomem (snd_pcm_substream_t *substream,struct vm_area_struct *area); +#else +#define SNDRV_PCM_INFO_MMAP 0 +#define snd_pcm_lib_mmap_iomem NULL +#endif +static inline void snd_pcm_limit_isa_dma_size (int dma,size_t *max) { *max = dma <4 ?64 *1024 :128 *1024 ;
sound/pci/rme32.c +6 -4
@@ -331,9 +331,8 @@* SPDIF I/O capabilites (half-duplex mode) */ static snd_pcm_hardware_t snd_rme32_spdif_info = { - .info = (SNDRV_PCM_INFO_MMAP | + .info = (SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_MMAP_VALID | -SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_PAUSE |SNDRV_PCM_INFO_SYNC_START ),
@@ -359,9 +358,8 @@*/ static snd_pcm_hardware_t snd_rme32_adat_info = { - .info = (SNDRV_PCM_INFO_MMAP | + .info = (SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_MMAP_VALID | -SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_PAUSE |SNDRV_PCM_INFO_SYNC_START ),
@@ -1246,6 +1244,7 @@ .pointer = snd_rme32_playback_pointer, .copy = snd_rme32_playback_copy, .silence = snd_rme32_playback_silence, + .mmap = snd_pcm_lib_mmap_iomem, };static snd_pcm_ops_t snd_rme32_capture_spdif_ops = {
@@ -1258,6 +1257,7 @@ .trigger = snd_rme32_pcm_trigger, .pointer = snd_rme32_capture_pointer, .copy = snd_rme32_capture_copy, + .mmap = snd_pcm_lib_mmap_iomem, };static snd_pcm_ops_t snd_rme32_playback_adat_ops = {
@@ -1270,6 +1270,7 @@ .pointer = snd_rme32_playback_pointer, .copy = snd_rme32_playback_copy, .silence = snd_rme32_playback_silence, + .mmap = snd_pcm_lib_mmap_iomem, };static snd_pcm_ops_t snd_rme32_capture_adat_ops = {
@@ -1281,6 +1282,7 @@ .trigger = snd_rme32_pcm_trigger, .pointer = snd_rme32_capture_pointer, .copy = snd_rme32_capture_copy, + .mmap = snd_pcm_lib_mmap_iomem, };/* for fullduplex mode */
sound/pci/rme96.c +8 -8
@@ -383,9 +383,8 @@*/ static snd_pcm_hardware_t snd_rme96_playback_spdif_info = { - .info = (SNDRV_PCM_INFO_MMAP | + .info = (SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_MMAP_VALID | -SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_PAUSE ), .formats = (SNDRV_PCM_FMTBIT_S16_LE |
@@ -413,9 +412,8 @@*/ static snd_pcm_hardware_t snd_rme96_capture_spdif_info = { - .info = (SNDRV_PCM_INFO_MMAP | + .info = (SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_MMAP_VALID | -SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_PAUSE ), .formats = (SNDRV_PCM_FMTBIT_S16_LE |
@@ -443,9 +441,8 @@*/ static snd_pcm_hardware_t snd_rme96_playback_adat_info = { - .info = (SNDRV_PCM_INFO_MMAP | + .info = (SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_MMAP_VALID | -SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_PAUSE ), .formats = (SNDRV_PCM_FMTBIT_S16_LE |
@@ -469,9 +466,8 @@*/ static snd_pcm_hardware_t snd_rme96_capture_adat_info = { - .info = (SNDRV_PCM_INFO_MMAP | + .info = (SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_MMAP_VALID | -SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_PAUSE ), .formats = (SNDRV_PCM_FMTBIT_S16_LE |
@@ -1494,6 +1490,7 @@ .pointer = snd_rme96_playback_pointer, .copy = snd_rme96_playback_copy, .silence = snd_rme96_playback_silence, + .mmap = snd_pcm_lib_mmap_iomem, };static snd_pcm_ops_t snd_rme96_capture_spdif_ops = {
@@ -1505,6 +1502,7 @@ .trigger = snd_rme96_capture_trigger, .pointer = snd_rme96_capture_pointer, .copy = snd_rme96_capture_copy, + .mmap = snd_pcm_lib_mmap_iomem, };static snd_pcm_ops_t snd_rme96_playback_adat_ops = {
@@ -1517,6 +1515,7 @@ .pointer = snd_rme96_playback_pointer, .copy = snd_rme96_playback_copy, .silence = snd_rme96_playback_silence, + .mmap = snd_pcm_lib_mmap_iomem, };static snd_pcm_ops_t snd_rme96_capture_adat_ops = {
@@ -1528,6 +1527,7 @@ .trigger = snd_rme96_capture_trigger, .pointer = snd_rme96_capture_pointer, .copy = snd_rme96_capture_copy, + .mmap = snd_pcm_lib_mmap_iomem, }; static void
sound/pci/nm256/nm256.c +4 -4
@@ -742,8 +742,7 @@*/ static snd_pcm_hardware_t snd_nm256_playback = { - .info =SNDRV_PCM_INFO_MMAP |SNDRV_PCM_INFO_MMAP_VALID | -SNDRV_PCM_INFO_MMAP_IOMEM | + .info =SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_MMAP_VALID |SNDRV_PCM_INFO_INTERLEAVED |/*SNDRV_PCM_INFO_PAUSE |*/ SNDRV_PCM_INFO_RESUME ,
@@ -762,8 +761,7 @@static snd_pcm_hardware_t snd_nm256_capture = { - .info =SNDRV_PCM_INFO_MMAP |SNDRV_PCM_INFO_MMAP_VALID | -SNDRV_PCM_INFO_MMAP_IOMEM | + .info =SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_MMAP_VALID |SNDRV_PCM_INFO_INTERLEAVED |/*SNDRV_PCM_INFO_PAUSE |*/ SNDRV_PCM_INFO_RESUME ,
@@ -864,6 +862,7 @@ .copy = snd_nm256_playback_copy, .silence = snd_nm256_playback_silence, #endif + .mmap = snd_pcm_lib_mmap_iomem, }; static snd_pcm_ops_t snd_nm256_capture_ops = {
@@ -877,6 +876,7 @@#ifndef __i386__ .copy = snd_nm256_capture_copy, #endif + .mmap = snd_pcm_lib_mmap_iomem, }; static int __devinit
Quoted 1 line · On Tue, 31 Aug 2004 21:07:19 +0200 Takashi Iwai <[email protected]> wrote:
Although I still couldn't set up the sparc cross-compile environment,
There is a good one available somewhere, ask Andrew Morton for pointers, he uses it.
Quoted 5 lines
I fixed/updated the ALSA pcm layer.
David, could you try the attached patch? With this, the problematic part will be disabled on sparc (it won't work on every architecture, anyway).
Generates lots of warnings like this:
CC [M] drivers/i2c/chips/smsc47m1.o
In file included from sound/pci/au88x0/au88x0.h:26,
from sound/pci/au88x0/au8820.c:2:
include/sound/pcm.h:960:1: warning: "SNDRV_PCM_INFO_MMAP" redefined
In file included from include/sound/pcm.h:26,
from sound/pci/au88x0/au88x0.h:26,
from sound/pci/au88x0/au8820.c:2:include/sound/asound.h:264:1: warning: this is the location of the previous definition
At Tue, 31 Aug 2004 13:56:51 -0700,
Quoted 12 lines · David S. Miller
Quoted 5 lines · On Tue, 31 Aug 2004 21:07:19 +0200 Takashi Iwai <[email protected]> wrote:
I fixed/updated the ALSA pcm layer.
David, could you try the attached patch? With this, the problematic part will be disabled on sparc (it won't work on every architecture, anyway).
Generates lots of warnings like this:
Quoted 8 lines
CC [M]
drivers/i2c/chips/smsc47m1.o
In file included fromsound/pci/au88x0/au88x0.h:26,from sound/pci/au88x0/au8820.c:2: include/sound/pcm.h:960:1: warning: "SNDRV_PCM_INFO_MMAP" redefined In file included from include/sound/pcm.h:26, from sound/pci/au88x0/au88x0.h:26, from sound/pci/au88x0/au8820.c:2:
include/sound/asound.h:264:1: warning: this is the location of the previous definition
Sorry, a silly typo.
Takashi
include/sound/pcm.h renamed from include/sound/pcm.h-dist +1 -1
@@ -957,7 +957,7 @@ static inline void snd_pcm_mmap_data_clo#define SNDRV_PCM_INFO_MMAP_IOMEM SNDRV_PCM_INFO_MMAPint snd_pcm_lib_mmap_iomem (snd_pcm_substream_t *substream,struct vm_area_struct *area);#else -#define SNDRV_PCM_INFO_MMAP 0 +#define SNDRV_PCM_INFO_MMAP_IOMEM 0#define snd_pcm_lib_mmap_iomem NULL#endif
Also, please do not use __i386__ et al. ifdefs, use things like CONFIG_I386 and CONFIG_SPARC which are meant for this purpose.
At Tue, 31 Aug 2004 13:58:05 -0700,
Quoted 5 lines · David S. Miller
Also, please do not use
__i386__et al. ifdefs, use things likeCONFIG_I386andCONFIG_SPARCwhich are meant for this purpose.
Do we have CONFIG_I386?
At least, CONFIG_X86 is defined also for x86-64, so it's not unique. (For my patch it's ok since both are given, though.)
Takashi
Quoted 2 lines · Takashi Iwai
Although I still couldn't set up the sparc cross-compile environment,
The tarballs at http://developer.osdl.org/dev/plm/cross_compile/ work nicely.
At Tue, 31 Aug 2004 15:20:49 -0700,
Quoted 6 lines · Andrew Morton
Quoted 2 lines · Takashi Iwai
Although I still couldn't set up the sparc cross-compile environment,
The tarballs at http://developer.osdl.org/dev/plm/cross_compile/ work nicely.
Thanks! I'll try them.
(But maybe I'll have no time in these two weeks for conferences...)
Takashi