dma-mapping updates for Linux 5.3
- move the USB special case that bounced DMA through a device
bar into the USB code instead of handling it in the common
DMA code (Laurentiu Tudor and Fredrik Noring)
- don't dip into the global CMA pool for single page allocations
(Nicolin Chen)
- fix a crash when allocating memory for the atomic pool failed
during boot (Florian Fainelli)
- move support for MIPS-style uncached segments to the common
code and use that for MIPS and nios2 (me)
- make support for DMA_ATTR_NON_CONSISTENT and
DMA_ATTR_NO_KERNEL_MAPPING generic (me)
- convert nds32 to the generic remapping allocator (me)
-----BEGIN PGP SIGNATURE-----
iQI/BAABCgApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAl0nPqgLHGhjaEBsc3Qu
ZGUACgkQD55TZVIEUYNj2hAAxIv2O3wv6V5xhzWwOVo8e/xW1ZLlGAF0/z92u0do
32Tm8jkdAGjZDnyxam7qisMSIjCNykpauQzVVxyUNBRSsn1V5t7KSaH3/OXCOVcr
x2VWBirxGO2BbRseaCBjIcA/2qna+VIDGFcNXCtf6rM00YUK6qaJzkMwBKQAeYcM
uJMJkaf8qaW4hygLJP8axXiGFdIJyFNLAlJ+ok6kYsJHHJNceOp0bo3CDa2mJBK9
IhraK2zVkyE5EQkQM5cE/Kw1ppPelUKUkHwjgM4wpz2b18WbLu11nKP0hmUcvKRQ
heY8xWiKxN0QTgS03ou7EVylyrSAE4dIKgzuA4VO32QCGsWypcAg4iU6s5TX6p9g
tZEW2ckE6wbmRdQPyKoDpZg299/eQjRHc4MAA1yinT8tFMokw2tk8Fq1FWyltwL1
8EiP5oNs2qUNvNgqUresl6/f6YOacFi1Q6IhgBVj6d6lyhMhlsHfW4w1XA1siv/I
6l4qJbLohYab6hY7i+mBOd8iG/KrAlr4P6admnv2jDchswbb5t2j+ABE9xv++PFi
u1HFqMlxqdWQaXGca2UeCUxUjkwO9N+kHpP+VRz+6D2b64dtCWSu8CN23sYXm2tO
ubWIlrQQZPhhMkoFg7XqKSTacd+ut+SXN9Nxsyv548ETV0l1xbiLRHIbhyoIESD5
RAI=
=01Fr
-----END PGP SIGNATURE-----
Merge tag 'dma-mapping-5.3' of git://git.infradead.org/users/hch/dma-mapping
Pull dma-mapping updates from Christoph Hellwig:
- move the USB special case that bounced DMA through a device bar into
the USB code instead of handling it in the common DMA code (Laurentiu
Tudor and Fredrik Noring)
- don't dip into the global CMA pool for single page allocations
(Nicolin Chen)
- fix a crash when allocating memory for the atomic pool failed during
boot (Florian Fainelli)
- move support for MIPS-style uncached segments to the common code and
use that for MIPS and nios2 (me)
- make support for DMA_ATTR_NON_CONSISTENT and
DMA_ATTR_NO_KERNEL_MAPPING generic (me)
- convert nds32 to the generic remapping allocator (me)
* tag 'dma-mapping-5.3' of git://git.infradead.org/users/hch/dma-mapping: (29 commits)
dma-mapping: mark dma_alloc_need_uncached as __always_inline
MIPS: only select ARCH_HAS_UNCACHED_SEGMENT for non-coherent platforms
usb: host: Fix excessive alignment restriction for local memory allocations
lib/genalloc.c: Add algorithm, align and zeroed family of DMA allocators
nios2: use the generic uncached segment support in dma-direct
nds32: use the generic remapping allocator for coherent DMA allocations
arc: use the generic remapping allocator for coherent DMA allocations
dma-direct: handle DMA_ATTR_NO_KERNEL_MAPPING in common code
dma-direct: handle DMA_ATTR_NON_CONSISTENT in common code
dma-mapping: add a dma_alloc_need_uncached helper
openrisc: remove the partial DMA_ATTR_NON_CONSISTENT support
arc: remove the partial DMA_ATTR_NON_CONSISTENT support
arm-nommu: remove the partial DMA_ATTR_NON_CONSISTENT support
ARM: dma-mapping: allow larger DMA mask than supported
dma-mapping: truncate dma masks to what dma_addr_t can hold
iommu/dma: Apply dma_{alloc,free}_contiguous functions
dma-remap: Avoid de-referencing NULL atomic_pool
MIPS: use the generic uncached segment support in dma-direct
dma-direct: provide generic support for uncached kernel segments
au1100fb: fix DMA API abuse
...
This commit is contained in:
commit
9e3a25dc99
41 changed files with 515 additions and 654 deletions
125
lib/genalloc.c
125
lib/genalloc.c
|
|
@ -327,21 +327,45 @@ EXPORT_SYMBOL(gen_pool_alloc_algo_owner);
|
|||
* gen_pool_dma_alloc - allocate special memory from the pool for DMA usage
|
||||
* @pool: pool to allocate from
|
||||
* @size: number of bytes to allocate from the pool
|
||||
* @dma: dma-view physical address return value. Use NULL if unneeded.
|
||||
* @dma: dma-view physical address return value. Use %NULL if unneeded.
|
||||
*
|
||||
* Allocate the requested number of bytes from the specified pool.
|
||||
* Uses the pool allocation function (with first-fit algorithm by default).
|
||||
* Can not be used in NMI handler on architectures without
|
||||
* NMI-safe cmpxchg implementation.
|
||||
*
|
||||
* Return: virtual address of the allocated memory, or %NULL on failure
|
||||
*/
|
||||
void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size, dma_addr_t *dma)
|
||||
{
|
||||
return gen_pool_dma_alloc_algo(pool, size, dma, pool->algo, pool->data);
|
||||
}
|
||||
EXPORT_SYMBOL(gen_pool_dma_alloc);
|
||||
|
||||
/**
|
||||
* gen_pool_dma_alloc_algo - allocate special memory from the pool for DMA
|
||||
* usage with the given pool algorithm
|
||||
* @pool: pool to allocate from
|
||||
* @size: number of bytes to allocate from the pool
|
||||
* @dma: DMA-view physical address return value. Use %NULL if unneeded.
|
||||
* @algo: algorithm passed from caller
|
||||
* @data: data passed to algorithm
|
||||
*
|
||||
* Allocate the requested number of bytes from the specified pool. Uses the
|
||||
* given pool allocation function. Can not be used in NMI handler on
|
||||
* architectures without NMI-safe cmpxchg implementation.
|
||||
*
|
||||
* Return: virtual address of the allocated memory, or %NULL on failure
|
||||
*/
|
||||
void *gen_pool_dma_alloc_algo(struct gen_pool *pool, size_t size,
|
||||
dma_addr_t *dma, genpool_algo_t algo, void *data)
|
||||
{
|
||||
unsigned long vaddr;
|
||||
|
||||
if (!pool)
|
||||
return NULL;
|
||||
|
||||
vaddr = gen_pool_alloc(pool, size);
|
||||
vaddr = gen_pool_alloc_algo(pool, size, algo, data);
|
||||
if (!vaddr)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -350,7 +374,102 @@ void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size, dma_addr_t *dma)
|
|||
|
||||
return (void *)vaddr;
|
||||
}
|
||||
EXPORT_SYMBOL(gen_pool_dma_alloc);
|
||||
EXPORT_SYMBOL(gen_pool_dma_alloc_algo);
|
||||
|
||||
/**
|
||||
* gen_pool_dma_alloc_align - allocate special memory from the pool for DMA
|
||||
* usage with the given alignment
|
||||
* @pool: pool to allocate from
|
||||
* @size: number of bytes to allocate from the pool
|
||||
* @dma: DMA-view physical address return value. Use %NULL if unneeded.
|
||||
* @align: alignment in bytes for starting address
|
||||
*
|
||||
* Allocate the requested number bytes from the specified pool, with the given
|
||||
* alignment restriction. Can not be used in NMI handler on architectures
|
||||
* without NMI-safe cmpxchg implementation.
|
||||
*
|
||||
* Return: virtual address of the allocated memory, or %NULL on failure
|
||||
*/
|
||||
void *gen_pool_dma_alloc_align(struct gen_pool *pool, size_t size,
|
||||
dma_addr_t *dma, int align)
|
||||
{
|
||||
struct genpool_data_align data = { .align = align };
|
||||
|
||||
return gen_pool_dma_alloc_algo(pool, size, dma,
|
||||
gen_pool_first_fit_align, &data);
|
||||
}
|
||||
EXPORT_SYMBOL(gen_pool_dma_alloc_align);
|
||||
|
||||
/**
|
||||
* gen_pool_dma_zalloc - allocate special zeroed memory from the pool for
|
||||
* DMA usage
|
||||
* @pool: pool to allocate from
|
||||
* @size: number of bytes to allocate from the pool
|
||||
* @dma: dma-view physical address return value. Use %NULL if unneeded.
|
||||
*
|
||||
* Allocate the requested number of zeroed bytes from the specified pool.
|
||||
* Uses the pool allocation function (with first-fit algorithm by default).
|
||||
* Can not be used in NMI handler on architectures without
|
||||
* NMI-safe cmpxchg implementation.
|
||||
*
|
||||
* Return: virtual address of the allocated zeroed memory, or %NULL on failure
|
||||
*/
|
||||
void *gen_pool_dma_zalloc(struct gen_pool *pool, size_t size, dma_addr_t *dma)
|
||||
{
|
||||
return gen_pool_dma_zalloc_algo(pool, size, dma, pool->algo, pool->data);
|
||||
}
|
||||
EXPORT_SYMBOL(gen_pool_dma_zalloc);
|
||||
|
||||
/**
|
||||
* gen_pool_dma_zalloc_algo - allocate special zeroed memory from the pool for
|
||||
* DMA usage with the given pool algorithm
|
||||
* @pool: pool to allocate from
|
||||
* @size: number of bytes to allocate from the pool
|
||||
* @dma: DMA-view physical address return value. Use %NULL if unneeded.
|
||||
* @algo: algorithm passed from caller
|
||||
* @data: data passed to algorithm
|
||||
*
|
||||
* Allocate the requested number of zeroed bytes from the specified pool. Uses
|
||||
* the given pool allocation function. Can not be used in NMI handler on
|
||||
* architectures without NMI-safe cmpxchg implementation.
|
||||
*
|
||||
* Return: virtual address of the allocated zeroed memory, or %NULL on failure
|
||||
*/
|
||||
void *gen_pool_dma_zalloc_algo(struct gen_pool *pool, size_t size,
|
||||
dma_addr_t *dma, genpool_algo_t algo, void *data)
|
||||
{
|
||||
void *vaddr = gen_pool_dma_alloc_algo(pool, size, dma, algo, data);
|
||||
|
||||
if (vaddr)
|
||||
memset(vaddr, 0, size);
|
||||
|
||||
return vaddr;
|
||||
}
|
||||
EXPORT_SYMBOL(gen_pool_dma_zalloc_algo);
|
||||
|
||||
/**
|
||||
* gen_pool_dma_zalloc_align - allocate special zeroed memory from the pool for
|
||||
* DMA usage with the given alignment
|
||||
* @pool: pool to allocate from
|
||||
* @size: number of bytes to allocate from the pool
|
||||
* @dma: DMA-view physical address return value. Use %NULL if unneeded.
|
||||
* @align: alignment in bytes for starting address
|
||||
*
|
||||
* Allocate the requested number of zeroed bytes from the specified pool,
|
||||
* with the given alignment restriction. Can not be used in NMI handler on
|
||||
* architectures without NMI-safe cmpxchg implementation.
|
||||
*
|
||||
* Return: virtual address of the allocated zeroed memory, or %NULL on failure
|
||||
*/
|
||||
void *gen_pool_dma_zalloc_align(struct gen_pool *pool, size_t size,
|
||||
dma_addr_t *dma, int align)
|
||||
{
|
||||
struct genpool_data_align data = { .align = align };
|
||||
|
||||
return gen_pool_dma_zalloc_algo(pool, size, dma,
|
||||
gen_pool_first_fit_align, &data);
|
||||
}
|
||||
EXPORT_SYMBOL(gen_pool_dma_zalloc_align);
|
||||
|
||||
/**
|
||||
* gen_pool_free - free allocated special memory back to the pool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue