include/linux/dma-mapping.h
Source file repositories/reference/linux-study-clean/include/linux/dma-mapping.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/dma-mapping.h- Extension
.h- Size
- 27161 bytes
- Lines
- 798
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/err.hlinux/dma-direction.hlinux/scatterlist.hlinux/bug.hlinux/cache.h
Detected Declarations
struct dma_iova_statefunction dma_iova_sizefunction debug_dma_mapping_errorfunction dma_map_page_attrsfunction dma_unmap_page_attrsfunction dma_unmap_physfunction dma_unmap_sg_attrsfunction dma_map_resourcefunction dma_unmap_resourcefunction dma_free_attrsfunction dmam_free_coherentfunction dma_mmap_attrsfunction dma_can_mmapfunction dma_pci_p2pdma_supportedfunction dma_set_maskfunction dma_set_coherent_maskfunction dma_get_required_maskfunction dma_addressing_limitedfunction dma_max_mapping_sizefunction dma_opt_mapping_sizefunction dma_get_merge_boundaryfunction dma_free_noncontiguousfunction dma_vunmap_noncontiguousfunction dma_use_iovafunction dma_use_iovafunction dma_iova_try_allocfunction dma_iova_freefunction dma_iova_linkfunction dma_iova_unlinkfunction dma_dev_need_syncfunction dma_sync_single_for_cpufunction dma_sync_single_for_devicefunction dma_sync_sg_for_cpufunction dma_sync_sg_for_devicefunction dma_need_syncfunction dma_dev_need_syncfunction dma_sync_single_for_cpufunction dma_need_unmapfunction dma_free_noncoherentfunction dma_map_single_attrsfunction dma_unmap_single_attrsfunction dma_sync_single_range_for_cpufunction dma_sync_single_range_for_devicefunction dma_unmap_sgtablefunction dma_sync_sgtable_for_devicefunction dma_unmap_sgtablefunction dma_free_coherentfunction dma_get_mask
Annotated Snippet
struct dma_iova_state {
dma_addr_t addr;
u64 __size;
};
/*
* Use the high bit to mark if we used swiotlb for one or more ranges.
*/
#define DMA_IOVA_USE_SWIOTLB (1ULL << 63)
static inline size_t dma_iova_size(struct dma_iova_state *state)
{
/* Casting is needed for 32-bits systems */
return (size_t)(state->__size & ~DMA_IOVA_USE_SWIOTLB);
}
#ifdef CONFIG_DMA_API_DEBUG
void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
void debug_dma_map_single(struct device *dev, const void *addr,
unsigned long len);
#else
static inline void debug_dma_mapping_error(struct device *dev,
dma_addr_t dma_addr)
{
}
static inline void debug_dma_map_single(struct device *dev, const void *addr,
unsigned long len)
{
}
#endif /* CONFIG_DMA_API_DEBUG */
#ifdef CONFIG_HAS_DMA
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
debug_dma_mapping_error(dev, dma_addr);
if (unlikely(dma_addr == DMA_MAPPING_ERROR))
return -ENOMEM;
return 0;
}
dma_addr_t dma_map_page_attrs(struct device *dev, struct page *page,
size_t offset, size_t size, enum dma_data_direction dir,
unsigned long attrs);
void dma_unmap_page_attrs(struct device *dev, dma_addr_t addr, size_t size,
enum dma_data_direction dir, unsigned long attrs);
dma_addr_t dma_map_phys(struct device *dev, phys_addr_t phys, size_t size,
enum dma_data_direction dir, unsigned long attrs);
void dma_unmap_phys(struct device *dev, dma_addr_t addr, size_t size,
enum dma_data_direction dir, unsigned long attrs);
unsigned int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir, unsigned long attrs);
void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir,
unsigned long attrs);
int dma_map_sgtable(struct device *dev, struct sg_table *sgt,
enum dma_data_direction dir, unsigned long attrs);
dma_addr_t dma_map_resource(struct device *dev, phys_addr_t phys_addr,
size_t size, enum dma_data_direction dir, unsigned long attrs);
void dma_unmap_resource(struct device *dev, dma_addr_t addr, size_t size,
enum dma_data_direction dir, unsigned long attrs);
void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t flag, unsigned long attrs);
void dma_free_attrs(struct device *dev, size_t size, void *cpu_addr,
dma_addr_t dma_handle, unsigned long attrs);
void *dmam_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t gfp, unsigned long attrs);
void dmam_free_coherent(struct device *dev, size_t size, void *vaddr,
dma_addr_t dma_handle);
int dma_get_sgtable_attrs(struct device *dev, struct sg_table *sgt,
void *cpu_addr, dma_addr_t dma_addr, size_t size,
unsigned long attrs);
int dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
void *cpu_addr, dma_addr_t dma_addr, size_t size,
unsigned long attrs);
bool dma_can_mmap(struct device *dev);
bool dma_pci_p2pdma_supported(struct device *dev);
int dma_set_mask(struct device *dev, u64 mask);
int dma_set_coherent_mask(struct device *dev, u64 mask);
u64 dma_get_required_mask(struct device *dev);
bool dma_addressing_limited(struct device *dev);
size_t dma_max_mapping_size(struct device *dev);
size_t dma_opt_mapping_size(struct device *dev);
unsigned long dma_get_merge_boundary(struct device *dev);
struct sg_table *dma_alloc_noncontiguous(struct device *dev, size_t size,
enum dma_data_direction dir, gfp_t gfp, unsigned long attrs);
void dma_free_noncontiguous(struct device *dev, size_t size,
struct sg_table *sgt, enum dma_data_direction dir);
void *dma_vmap_noncontiguous(struct device *dev, size_t size,
struct sg_table *sgt);
Annotation
- Immediate include surface: `linux/device.h`, `linux/err.h`, `linux/dma-direction.h`, `linux/scatterlist.h`, `linux/bug.h`, `linux/cache.h`.
- Detected declarations: `struct dma_iova_state`, `function dma_iova_size`, `function debug_dma_mapping_error`, `function dma_map_page_attrs`, `function dma_unmap_page_attrs`, `function dma_unmap_phys`, `function dma_unmap_sg_attrs`, `function dma_map_resource`, `function dma_unmap_resource`, `function dma_free_attrs`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.