include/linux/swiotlb.h
Source file repositories/reference/linux-study-clean/include/linux/swiotlb.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/swiotlb.h- Extension
.h- Size
- 9312 bytes
- Lines
- 309
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/dma-direction.hlinux/init.hlinux/types.hlinux/limits.hlinux/spinlock.hlinux/workqueue.h
Detected Declarations
struct devicestruct pagestruct scatterliststruct io_tlb_poolstruct io_tlb_memfunction swiotlb_find_poolfunction is_swiotlb_force_bouncefunction swiotlb_initfunction is_swiotlb_force_bouncefunction swiotlb_exitfunction is_swiotlb_allocatedfunction is_swiotlb_activefunction swiotlb_adjust_sizefunction default_swiotlb_limitfunction swiotlb_tbl_unmap_singlefunction swiotlb_sync_single_for_devicefunction swiotlb_sync_single_for_cpufunction is_swiotlb_for_allocfunction swiotlb_freefunction is_swiotlb_for_alloc
Annotated Snippet
struct io_tlb_pool {
phys_addr_t start;
phys_addr_t end;
void *vaddr;
unsigned long nslabs;
bool late_alloc;
unsigned int nareas;
unsigned int area_nslabs;
struct io_tlb_area *areas;
struct io_tlb_slot *slots;
#ifdef CONFIG_SWIOTLB_DYNAMIC
struct list_head node;
struct rcu_head rcu;
bool transient;
#endif
};
/**
* struct io_tlb_mem - Software IO TLB allocator
* @defpool: Default (initial) IO TLB memory pool descriptor.
* @pool: IO TLB memory pool descriptor (if not dynamic).
* @nslabs: Total number of IO TLB slabs in all pools.
* @debugfs: The dentry to debugfs.
* @force_bounce: %true if swiotlb bouncing is forced
* @for_alloc: %true if the pool is used for memory allocation
* @can_grow: %true if more pools can be allocated dynamically.
* @phys_limit: Maximum allowed physical address.
* @lock: Lock to synchronize changes to the list.
* @pools: List of IO TLB memory pool descriptors (if dynamic).
* @dyn_alloc: Dynamic IO TLB pool allocation work.
* @total_used: The total number of slots in the pool that are currently used
* across all areas. Used only for calculating used_hiwater in
* debugfs.
* @used_hiwater: The high water mark for total_used. Used only for reporting
* in debugfs.
* @transient_nslabs: The total number of slots in all transient pools that
* are currently used across all areas.
*/
struct io_tlb_mem {
struct io_tlb_pool defpool;
unsigned long nslabs;
struct dentry *debugfs;
bool force_bounce;
bool for_alloc;
#ifdef CONFIG_SWIOTLB_DYNAMIC
bool can_grow;
u64 phys_limit;
spinlock_t lock;
struct list_head pools;
struct work_struct dyn_alloc;
#endif
#ifdef CONFIG_DEBUG_FS
atomic_long_t total_used;
atomic_long_t used_hiwater;
atomic_long_t transient_nslabs;
#endif
};
struct io_tlb_pool *__swiotlb_find_pool(struct device *dev, phys_addr_t paddr);
/**
* swiotlb_find_pool() - find swiotlb pool to which a physical address belongs
* @dev: Device which has mapped the buffer.
* @paddr: Physical address within the DMA buffer.
*
* Find the swiotlb pool that @paddr points into.
*
* Return:
* * pool address if @paddr points into a bounce buffer
* * NULL if @paddr does not point into a bounce buffer. As such, this function
* can be used to determine if @paddr denotes a swiotlb bounce buffer.
*/
static inline struct io_tlb_pool *swiotlb_find_pool(struct device *dev,
phys_addr_t paddr)
{
struct io_tlb_mem *mem = dev->dma_io_tlb_mem;
if (!mem)
return NULL;
#ifdef CONFIG_SWIOTLB_DYNAMIC
/*
* All SWIOTLB buffer addresses must have been returned by
* swiotlb_tbl_map_single() and passed to a device driver.
* If a SWIOTLB address is checked on another CPU, then it was
* presumably loaded by the device driver from an unspecified private
* data structure. Make sure that this load is ordered before reading
* dev->dma_uses_io_tlb here and mem->pools in __swiotlb_find_pool().
*
* This barrier pairs with smp_mb() in swiotlb_find_slots().
Annotation
- Immediate include surface: `linux/device.h`, `linux/dma-direction.h`, `linux/init.h`, `linux/types.h`, `linux/limits.h`, `linux/spinlock.h`, `linux/workqueue.h`.
- Detected declarations: `struct device`, `struct page`, `struct scatterlist`, `struct io_tlb_pool`, `struct io_tlb_mem`, `function swiotlb_find_pool`, `function is_swiotlb_force_bounce`, `function swiotlb_init`, `function is_swiotlb_force_bounce`, `function swiotlb_exit`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.