@@ -347,13 +347,35 @@ EXPORT_SYMBOL(gen_pool_alloc_algo);
347347 * Return: virtual address of the allocated memory, or %NULL on failure
348348 */
349349void * gen_pool_dma_alloc (struct gen_pool * pool , size_t size , dma_addr_t * dma )
350+ {
351+ return gen_pool_dma_alloc_algo (pool , size , dma , pool -> algo , pool -> data );
352+ }
353+ EXPORT_SYMBOL (gen_pool_dma_alloc );
354+
355+ /**
356+ * gen_pool_dma_alloc_algo - allocate special memory from the pool for DMA
357+ * usage with the given pool algorithm
358+ * @pool: pool to allocate from
359+ * @size: number of bytes to allocate from the pool
360+ * @dma: DMA-view physical address return value. Use %NULL if unneeded.
361+ * @algo: algorithm passed from caller
362+ * @data: data passed to algorithm
363+ *
364+ * Allocate the requested number of bytes from the specified pool. Uses the
365+ * given pool allocation function. Can not be used in NMI handler on
366+ * architectures without NMI-safe cmpxchg implementation.
367+ *
368+ * Return: virtual address of the allocated memory, or %NULL on failure
369+ */
370+ void * gen_pool_dma_alloc_algo (struct gen_pool * pool , size_t size ,
371+ dma_addr_t * dma , genpool_algo_t algo , void * data )
350372{
351373 unsigned long vaddr ;
352374
353375 if (!pool )
354376 return NULL ;
355377
356- vaddr = gen_pool_alloc (pool , size );
378+ vaddr = gen_pool_alloc_algo (pool , size , algo , data );
357379 if (!vaddr )
358380 return NULL ;
359381
@@ -362,7 +384,31 @@ void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size, dma_addr_t *dma)
362384
363385 return (void * )vaddr ;
364386}
365- EXPORT_SYMBOL (gen_pool_dma_alloc );
387+ EXPORT_SYMBOL (gen_pool_dma_alloc_algo );
388+
389+ /**
390+ * gen_pool_dma_alloc_align - allocate special memory from the pool for DMA
391+ * usage with the given alignment
392+ * @pool: pool to allocate from
393+ * @size: number of bytes to allocate from the pool
394+ * @dma: DMA-view physical address return value. Use %NULL if unneeded.
395+ * @align: alignment in bytes for starting address
396+ *
397+ * Allocate the requested number bytes from the specified pool, with the given
398+ * alignment restriction. Can not be used in NMI handler on architectures
399+ * without NMI-safe cmpxchg implementation.
400+ *
401+ * Return: virtual address of the allocated memory, or %NULL on failure
402+ */
403+ void * gen_pool_dma_alloc_align (struct gen_pool * pool , size_t size ,
404+ dma_addr_t * dma , int align )
405+ {
406+ struct genpool_data_align data = { .align = align };
407+
408+ return gen_pool_dma_alloc_algo (pool , size , dma ,
409+ gen_pool_first_fit_align , & data );
410+ }
411+ EXPORT_SYMBOL (gen_pool_dma_alloc_align );
366412
367413/**
368414 * gen_pool_dma_zalloc - allocate special zeroed memory from the pool for
@@ -380,14 +426,60 @@ EXPORT_SYMBOL(gen_pool_dma_alloc);
380426 */
381427void * gen_pool_dma_zalloc (struct gen_pool * pool , size_t size , dma_addr_t * dma )
382428{
383- void * vaddr = gen_pool_dma_alloc (pool , size , dma );
429+ return gen_pool_dma_zalloc_algo (pool , size , dma , pool -> algo , pool -> data );
430+ }
431+ EXPORT_SYMBOL (gen_pool_dma_zalloc );
432+
433+ /**
434+ * gen_pool_dma_zalloc_algo - allocate special zeroed memory from the pool for
435+ * DMA usage with the given pool algorithm
436+ * @pool: pool to allocate from
437+ * @size: number of bytes to allocate from the pool
438+ * @dma: DMA-view physical address return value. Use %NULL if unneeded.
439+ * @algo: algorithm passed from caller
440+ * @data: data passed to algorithm
441+ *
442+ * Allocate the requested number of zeroed bytes from the specified pool. Uses
443+ * the given pool allocation function. Can not be used in NMI handler on
444+ * architectures without NMI-safe cmpxchg implementation.
445+ *
446+ * Return: virtual address of the allocated zeroed memory, or %NULL on failure
447+ */
448+ void * gen_pool_dma_zalloc_algo (struct gen_pool * pool , size_t size ,
449+ dma_addr_t * dma , genpool_algo_t algo , void * data )
450+ {
451+ void * vaddr = gen_pool_dma_alloc_algo (pool , size , dma , algo , data );
384452
385453 if (vaddr )
386454 memset (vaddr , 0 , size );
387455
388456 return vaddr ;
389457}
390- EXPORT_SYMBOL (gen_pool_dma_zalloc );
458+ EXPORT_SYMBOL (gen_pool_dma_zalloc_algo );
459+
460+ /**
461+ * gen_pool_dma_zalloc_align - allocate special zeroed memory from the pool for
462+ * DMA usage with the given alignment
463+ * @pool: pool to allocate from
464+ * @size: number of bytes to allocate from the pool
465+ * @dma: DMA-view physical address return value. Use %NULL if unneeded.
466+ * @align: alignment in bytes for starting address
467+ *
468+ * Allocate the requested number of zeroed bytes from the specified pool,
469+ * with the given alignment restriction. Can not be used in NMI handler on
470+ * architectures without NMI-safe cmpxchg implementation.
471+ *
472+ * Return: virtual address of the allocated zeroed memory, or %NULL on failure
473+ */
474+ void * gen_pool_dma_zalloc_align (struct gen_pool * pool , size_t size ,
475+ dma_addr_t * dma , int align )
476+ {
477+ struct genpool_data_align data = { .align = align };
478+
479+ return gen_pool_dma_zalloc_algo (pool , size , dma ,
480+ gen_pool_first_fit_align , & data );
481+ }
482+ EXPORT_SYMBOL (gen_pool_dma_zalloc_align );
391483
392484/**
393485 * gen_pool_free - free allocated special memory back to the pool
0 commit comments