2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* include/linux/dmapool.h
|
|
|
|
*
|
|
|
|
* Allocation pools for DMAable (coherent) memory.
|
|
|
|
*
|
|
|
|
* This file is licensed under the terms of the GNU General Public
|
|
|
|
* License version 2. This program is licensed "as is" without any
|
|
|
|
* warranty of any kind, whether express or implied.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LINUX_DMAPOOL_H
|
|
|
|
#define LINUX_DMAPOOL_H
|
|
|
|
|
2015-05-01 17:46:15 +07:00
|
|
|
#include <linux/scatterlist.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/io.h>
|
|
|
|
|
2015-04-08 04:26:44 +07:00
|
|
|
struct device;
|
|
|
|
|
2018-03-16 20:25:43 +07:00
|
|
|
#ifdef CONFIG_HAS_DMA
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
struct dma_pool *dma_pool_create(const char *name, struct device *dev,
|
|
|
|
size_t size, size_t align, size_t allocation);
|
|
|
|
|
|
|
|
void dma_pool_destroy(struct dma_pool *pool);
|
|
|
|
|
2005-10-07 13:46:04 +07:00
|
|
|
void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
|
2005-09-10 14:26:49 +07:00
|
|
|
dma_addr_t *handle);
|
2005-04-17 05:20:36 +07:00
|
|
|
void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr);
|
|
|
|
|
devres: device resource management
Implement device resource management, in short, devres. A device
driver can allocate arbirary size of devres data which is associated
with a release function. On driver detach, release function is
invoked on the devres data, then, devres data is freed.
devreses are typed by associated release functions. Some devreses are
better represented by single instance of the type while others need
multiple instances sharing the same release function. Both usages are
supported.
devreses can be grouped using devres group such that a device driver
can easily release acquired resources halfway through initialization
or selectively release resources (e.g. resources for port 1 out of 4
ports).
This patch adds devres core including documentation and the following
managed interfaces.
* alloc/free : devm_kzalloc(), devm_kzfree()
* IO region : devm_request_region(), devm_release_region()
* IRQ : devm_request_irq(), devm_free_irq()
* DMA : dmam_alloc_coherent(), dmam_free_coherent(),
dmam_declare_coherent_memory(), dmam_pool_create(),
dmam_pool_destroy()
* PCI : pcim_enable_device(), pcim_pin_device(), pci_is_managed()
* iomap : devm_ioport_map(), devm_ioport_unmap(), devm_ioremap(),
devm_ioremap_nocache(), devm_iounmap(), pcim_iomap_table(),
pcim_iomap(), pcim_iounmap()
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-01-20 14:00:26 +07:00
|
|
|
/*
|
|
|
|
* Managed DMA pool
|
|
|
|
*/
|
|
|
|
struct dma_pool *dmam_pool_create(const char *name, struct device *dev,
|
|
|
|
size_t size, size_t align, size_t allocation);
|
|
|
|
void dmam_pool_destroy(struct dma_pool *pool);
|
|
|
|
|
2018-03-16 20:25:43 +07:00
|
|
|
#else /* !CONFIG_HAS_DMA */
|
|
|
|
static inline struct dma_pool *dma_pool_create(const char *name,
|
|
|
|
struct device *dev, size_t size, size_t align, size_t allocation)
|
|
|
|
{ return NULL; }
|
|
|
|
static inline void dma_pool_destroy(struct dma_pool *pool) { }
|
|
|
|
static inline void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
|
|
|
|
dma_addr_t *handle) { return NULL; }
|
|
|
|
static inline void dma_pool_free(struct dma_pool *pool, void *vaddr,
|
|
|
|
dma_addr_t addr) { }
|
|
|
|
static inline struct dma_pool *dmam_pool_create(const char *name,
|
|
|
|
struct device *dev, size_t size, size_t align, size_t allocation)
|
|
|
|
{ return NULL; }
|
|
|
|
static inline void dmam_pool_destroy(struct dma_pool *pool) { }
|
|
|
|
#endif /* !CONFIG_HAS_DMA */
|
|
|
|
|
|
|
|
static inline void *dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags,
|
|
|
|
dma_addr_t *handle)
|
|
|
|
{
|
|
|
|
return dma_pool_alloc(pool, mem_flags | __GFP_ZERO, handle);
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif
|
|
|
|
|