From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: "Cannot allocate memory" problem with latest CVS Date: Mon, 28 Oct 2002 16:15:41 +0100 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <20021028132148.74586.qmail@web40607.mail.yahoo.com> Mime-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: multipart/mixed; boundary="Multipart_Mon_Oct_28_16:15:41_2002-1" Return-path: In-Reply-To: <20021028132148.74586.qmail@web40607.mail.yahoo.com> Errors-To: alsa-devel-admin@lists.sourceforge.net List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: To: Chris Rankin Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org --Multipart_Mon_Oct_28_16:15:41_2002-1 Content-Type: text/plain; charset=US-ASCII At Mon, 28 Oct 2002 13:21:48 +0000 (GMT), Chris Rankin wrote: > > Ouch. This means that this problem will always appear > eventually, and the only way to clear it is waiting > for Linux to free a large amount of cache memory. > Or I could reboot my machine. could you try the attached patch? as mentioned in my previous mail, this is really a hack, but if it works... > In the meantime, I have no PCM playback via my > SB-Live!. Is this a 2.4 or a SB-Live limitation? both :) Takashi --Multipart_Mon_Oct_28_16:15:41_2002-1 Content-Type: application/octet-stream Content-Disposition: attachment; filename="sgbuf-getpage.dif" Content-Transfer-Encoding: 7bit Index: alsa-kernel/core/pcm_sgbuf.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/core/pcm_sgbuf.c,v retrieving revision 1.7 diff -u -r1.7 pcm_sgbuf.c --- alsa-kernel/core/pcm_sgbuf.c 10 Sep 2002 10:20:00 -0000 1.7 +++ alsa-kernel/core/pcm_sgbuf.c 28 Oct 2002 14:35:43 -0000 @@ -128,7 +128,32 @@ while (sgbuf->pages < pages) { void *ptr; dma_addr_t addr; +#ifdef __i386__ + /* HACK! we try to allocate with GFP_KERNEL */ + unsigned long rmask; + if (sgbuf->pci) + rmask = ~(unsigned long)sgbuf->pci->dma_mask; + else + rmask = 0; + ptr = (void *)__get_free_pages(GFP_KERNEL, 1); + if (ptr) { + addr = virt_to_phys(ptr); + if (((unsigned long)addr + PAGE_SIZE - 1) & rmask) { + /* reallocate with the proper mask */ + free_pages((unsigned long)ptr, PAGE_SIZE); + ptr = (void *)__get_free_pages(GFP_KERNEL | GFP_DMA, 1); + if (ptr) + addr = virt_to_phys(ptr); + else + addr = 0; + } + } else + addr = 0; + if (ptr) + memset(ptr, 0, PAGE_SIZE); +#else ptr = snd_malloc_pci_pages(sgbuf->pci, PAGE_SIZE, &addr); +#endif if (! ptr) return -ENOMEM; sgbuf->table[sgbuf->pages].buf = ptr; --Multipart_Mon_Oct_28_16:15:41_2002-1-- ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf