summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-07-30 15:13:33 +0200
committerJaroslav Kysela <perex@perex.cz>2008-08-25 09:57:19 +0200
commit4e184f8fc06411f35fdcf4b9bc6187c857bf7214 (patch)
tree74f1f96924be27827777d4bed5b31bf9f5f52bd4
parent77a23f2695bb2de0cd74599400dc55109c531b72 (diff)
downloadlinux-4e184f8fc06411f35fdcf4b9bc6187c857bf7214.tar.bz2
ALSA: Fix allocation size calculation in snd_dma_alloc_pages_fallback()
snd_dma_alloc_pages_fallback() always tries to reduce the size in a half, but it's not good when the given size isn't a power-of-two. Check it first then try to align. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--sound/core/memalloc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index f0c3b1d6da81..a7b46ec72f32 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -277,11 +277,16 @@ int snd_dma_alloc_pages_fallback(int type, struct device *device, size_t size,
int err;
while ((err = snd_dma_alloc_pages(type, device, size, dmab)) < 0) {
+ size_t aligned_size;
if (err != -ENOMEM)
return err;
- size >>= 1;
if (size <= PAGE_SIZE)
return -ENOMEM;
+ aligned_size = PAGE_SIZE << get_order(size);
+ if (size != aligned_size)
+ size = aligned_size;
+ else
+ size >>= 1;
}
if (! dmab->area)
return -ENOMEM;