[alsa-devel] ALSA 1.0.17rc2 release

Jaroslav Kysela perex at perex.cz
Tue Jun 17 16:24:43 CEST 2008


On Tue, 17 Jun 2008, Takashi Iwai wrote:

> At Tue, 17 Jun 2008 15:23:03 +0200 (CEST),
> Jaroslav Kysela wrote:
> > 
> > On Tue, 17 Jun 2008, Takashi Iwai wrote:
> > 
> > > At Tue, 17 Jun 2008 14:12:06 +0200 (CEST),
> > > Jaroslav Kysela wrote:
> > > > 
> > > > On Tue, 17 Jun 2008, Takashi Iwai wrote:
> > > > 
> > > > > At Tue, 17 Jun 2008 13:42:40 +0200 (CEST),
> > > > > Jaroslav Kysela wrote:
> > > > > > 
> > > > > > On Tue, 17 Jun 2008, Alan Horstmann wrote:
> > > > > > 
> > > > > > > I have just confirmed that pasting
> > > > > > > 
> > > > > > > 	#define GFP_DMA32	((__force gfp_t)0x04u)
> > > > > > > 
> > > > > > > into /alsa-kernel/pci/emu10k1/memory.c (not a correct fix -just taken from 
> > > > > > > 2.6.24 headers) enables build to complete.  So there should be no other 
> > > > > > > hidden issues.
> > > > > > 
> > > > > > Could you try attached patch (also pasted bellow)?
> > > > > 
> > > > > That's too overhead.  A simple #ifndef GFP_DMA32 would work.
> > > > > And, GFP_DMA32 isn't GFP_DMA.
> > > > 
> > > > But old kernels with dma_mask < 0xffffffff sets GFP_DMA flag for page 
> > > > allocation. So there's no regression.
> > > 
> > > GFP_DMA32 means to allocate from ZONE_DMA32 which was a part of
> > > ZONE_NORMAL.
> > 
> > Yes for 2.6, but 2.4 kernels do not have this flag. The function 
> > pci_alloc_consistent() was used before your patch "[ALSA] emu10k1 - 
> > simplify page allocation for synth" and pci_alloc_consistent() just uses 
> > GFP_DMA flag for page allocation when dma_mask < 32bit. So the result is 
> > same.
> 
> No.  pci_alloc_consistent() wasn't directly used, and there was
> already a hack for that in the memory allocator.

I missed it thanks. This patch should fix memory leak in 
pci/emu10k1/memory.c:

diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c
index 42943b4..759e29f 100644
--- a/sound/pci/emu10k1/memory.c
+++ b/sound/pci/emu10k1/memory.c
@@ -464,11 +464,17 @@ static int synth_alloc_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk
 		/* first try to allocate from <4GB zone */
 		struct page *p = alloc_page(GFP_KERNEL | GFP_DMA32 |
 					    __GFP_NOWARN);
-		if (!p || (page_to_pfn(p) & ~(emu->dma_mask >> PAGE_SHIFT)))
+		if (!p || (page_to_pfn(p) & ~(emu->dma_mask >> PAGE_SHIFT))) {
 			/* try to allocate from <16MB zone */
-			p = alloc_page(GFP_ATOMIC | GFP_DMA |
+			struct page *p1 =
+				alloc_page(GFP_ATOMIC | GFP_DMA |
 				       __GFP_NORETRY | /* no OOM-killer */
 				       __GFP_NOWARN);
+			/* free page outside dma_mask range */
+			if (p)
+				free_page((unsigned long)page_address(p));
+			p = p1;
+		}
 		if (!p) {
 			__synth_free_pages(emu, first_page, page - 1);
 			return -ENOMEM;

						Jaroslav

-----
Jaroslav Kysela <perex at perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.



More information about the Alsa-devel mailing list