Skip to content

Commit 0348683

Browse files
committed
ALSA: memalloc: Don't align the size to power-of-two
The size passed to dma_alloc_coherent() doesn't have to be aligned with power-of-two, rather it should be the raw size. As a minor optimization, remove the size adjustment in the current code. Signed-off-by: Takashi Iwai <[email protected]>
1 parent b8e1315 commit 0348683

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

sound/core/memalloc.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,29 +84,24 @@ EXPORT_SYMBOL(snd_free_pages);
8484
/* allocate the coherent DMA pages */
8585
static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *dma)
8686
{
87-
int pg;
8887
gfp_t gfp_flags;
8988

9089
if (WARN_ON(!dma))
9190
return NULL;
92-
pg = get_order(size);
9391
gfp_flags = GFP_KERNEL
9492
| __GFP_COMP /* compound page lets parts be mapped */
9593
| __GFP_NORETRY /* don't trigger OOM-killer */
9694
| __GFP_NOWARN; /* no stack trace print - this call is non-critical */
97-
return dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags);
95+
return dma_alloc_coherent(dev, size, dma, gfp_flags);
9896
}
9997

10098
/* free the coherent DMA pages */
10199
static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr,
102100
dma_addr_t dma)
103101
{
104-
int pg;
105-
106102
if (ptr == NULL)
107103
return;
108-
pg = get_order(size);
109-
dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma);
104+
dma_free_coherent(dev, size, ptr, dma);
110105
}
111106

112107
#ifdef CONFIG_GENERIC_ALLOCATOR

0 commit comments

Comments
 (0)