At Tue, 13 Apr 2004 17:22:52 +0100,
holborn wrote:
> 
> On Martes 13 Abril 2004 16:27, Takashi Iwai wrote:
> > At Tue, 13 Apr 2004 12:37:10 +0100,
> >
> 
> >
> > well, it means that your machine has really no RAM available for the
> > soundfont.  on 2.4 kernel (or older ALSA version), the driver
> > allocated the pages in atomic, so it doesn't go to sleep.
> > on 2.6 and current ALSA, the page allocation is done with GFP_KERNEL,
> > so it may sleep until the page is available.  it can take a long time
> > but must not be infinitely long.
> >
> > could you check whether the "page allocation failure" message already
> > appeared when sfxload hangs up?
> > does the message appears once or many times?
> >
> >
> 
> Hi ... the message appears after reboot command ... 
> I have load this soundfonts for years :-)
> No problems to load the soundfont in kernel 2.6.4 alsa 1.0.2c but still no 
> load in 2.6.5, i checked in two machines gentoo and Debian .. 
> 
> 
> I made the sfxload after booting ... 
> 
> 
> free command after login is:
> 
> Mem total 515728    used 37940    free 477788   ----> in kernel 2.6.5
> Mem total 515728    used 38916    free 476824   ----> in kernel 2.6.4

hmm, then it shouldn't fail.  
i guess the attached patch fixes the problem.  please give a try.


Takashi
Index: alsa-kernel/core/memalloc.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/core/memalloc.c,v
retrieving revision 1.30
diff -u -r1.30 memalloc.c
--- alsa-kernel/core/memalloc.c 7 Apr 2004 17:49:39 -0000       1.30
+++ alsa-kernel/core/memalloc.c 13 Apr 2004 16:58:05 -0000
@@ -137,14 +137,17 @@
                                         dma_addr_t *dma_handle, int flags)
 {
        void *ret;
-       u64 dma_mask;
+       u64 dma_mask, coherent_dma_mask;
 
        if (dev == NULL || !dev->dma_mask)
                return dma_alloc_coherent(dev, size, dma_handle, flags);
        dma_mask = *dev->dma_mask;
+       coherent_dma_mask = dev->coherent_dma_mask;
        *dev->dma_mask = 0xffffffff;    /* do without masking */
+       dev->coherent_dma_mask = 0xffffffff;    /* do without masking */
        ret = dma_alloc_coherent(dev, size, dma_handle, flags);
        *dev->dma_mask = dma_mask;      /* restore */
+       dev->coherent_dma_mask = coherent_dma_mask;     /* restore */
        if (ret) {
                /* obtained address is out of range? */
                if (((unsigned long)*dma_handle + size - 1) & ~dma_mask) {
@@ -154,8 +157,12 @@
                }
        } else {
                /* wish to success now with the proper mask... */
-               if (dma_mask != 0xffffffffUL)
+               if (dma_mask != 0xffffffffUL) {
+                       /* allocation with GFP_ATOMIC to avoid the long stall */
+                       flags &= ~GFP_KERNEL;
+                       flags |= GFP_ATOMIC;
                        ret = dma_alloc_coherent(dev, size, dma_handle, flags);
+               }
        }
        return ret;
 }

Reply via email to