Hi Ben,
thanks for signaling this long-standing issue again.
At Tue, 06 May 2008 10:08:28 +1000,
Benjamin Herrenschmidt wrote:
Yep. And on MIPS, obviously.
This is a mmap of the data record to be shared in realtime with apps.
The app updates its data pointer (appl_ptr) on the mmapped buffer
while the driver updates the data (e.g. DMA position, called hwptr) on
the fly on the mmapped record. Due to its real-time nature, it has to
be coherent -- at least, it was a problem on ARM.
It's actually buggy. Should check more precisely.
IIRC, dma_mmap_coherent() cannot be implemented properly on some
architectures. This is no big problem for ALSA as long as it returns
an error or make it out via ifdef. But, the fact that this API cannot
be done for all archs discourage arch maintainers, and the idea faded
out again.
Agreed.
That'll be great. dma_mmap_coherent() and friends would be then
really helpful to solve this issue.
In principle, pgprot_*() isn't actually needed in the driver side at
all. We use pgprot_noncached() in one part, and it's for hacky way to
mmap the ioremapped pages. It's not available on all architectures,
and I'm not sure whether it works on all PPC models although it's
enabled right now: in include/sound/pcm.h,
/* mmap for io-memory area */
#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_ALPHA)
#define SNDRV_PCM_INFO_MMAP_IOMEM SNDRV_PCM_INFO_MMAP
int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_struct *area);
#else
#define SNDRV_PCM_INFO_MMAP_IOMEM 0
#define snd_pcm_lib_mmap_iomem NULL
#endif
Highly likely we need to fix this, too. In the easiest way, disable
this except for X86...
As a pragmatic solution, as you mentioned in the above, we can disable
or change the problematic code with ifdefs. At best, use
dma_mmap_coherent() if it's available. If not, and if the arch is
known to have not-simply-mappable DMA pages (like MIPS), we can simply
disable the mmap feature.
Once after we have dma_mmap_*() generally, we can clean up codes.
thanks,
Takashi
--