Re: [PATCH] [0/13] General DMA zone rework

From: Luiz Fernando N. Capitulino
Date: Tue Mar 11 2008 - 15:36:43 EST


Em Tue, 11 Mar 2008 19:49:26 +0100
Andi Kleen <andi@xxxxxxxxxxxxxx> escreveu:

| > | Oops. Thanks. I'll double check that. mask allocator indeed doesn't
| > | handle __GFP_COMP and nobody should be passing that into dma_alloc_coherent
| > | anyways. But the bug you got was for the small size wasn't it?
| >
| > No, it triggers the BUG_ON() which checks the gfp, not the one
| > which checks MASK_MIN_SIZE.
|
| I see. I misdiagnosed your original problem then. But fixing the
| size < 16 bytes case was a good idea anyways, someone else would
| have triggered that.

I see.

| Can you perhaps send me a complete patch fixing that for sound and the
| __GFP_COMP with description and Signed-off-by etc.? I can add it to my
| patchkit then and you would be correctly attributed. Otherwise I can do it
| myself too if you prefer. I'll also do a grep over the tree for other
| such bogus __GFP_COMP users. That was an issue I hadn't considered before.

Here are you (passed minimal tests).

------
ALSA: Convert snd_malloc_dev_pages() to the mask allocator

The mask allocator do not handle the __GFP_COMP flag and
will BUG_ON() if that flag is passed to it.

Also, we should pass the allocation size in bytes to
dma_alloc_coherent().

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@xxxxxxxxxxxxxxx>

Index: linux-2.6.24/sound/core/memalloc.c
===================================================================
--- linux-2.6.24.orig/sound/core/memalloc.c
+++ linux-2.6.24/sound/core/memalloc.c
@@ -210,20 +210,17 @@ void snd_free_pages(void *ptr, size_t si
/* allocate the coherent DMA pages */
static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *dma)
{
- int pg;
void *res;
gfp_t gfp_flags;

snd_assert(size > 0, return NULL);
snd_assert(dma != NULL, return NULL);
- pg = get_order(size);
gfp_flags = GFP_KERNEL
- | __GFP_COMP /* compound page lets parts be mapped */
| __GFP_NORETRY /* don't trigger OOM-killer */
| __GFP_NOWARN; /* no stack trace print - this call is non-critical */
- res = dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags);
+ res = dma_alloc_coherent(dev, size, dma, gfp_flags);
if (res != NULL)
- inc_snd_pages(pg);
+ inc_snd_pages(get_order(size));

return res;
}



--
Luiz Fernando N. Capitulino
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/