STRUCT DMA_DEVICE(9)
π struct dma_device(9) π
okay bestie, so you've stumbled into the Kernel API Manual page for struct dma_device(9) and honestly? slay. this is the struct that describes the entity supplying DMA services β like, the whole DMA controller's little ID card. it's a big one, so grab a snack π.
β¨ NAME β¨
struct dma_device β the info on the entity supplying DMA services π«Ά
πΈ SYNOPSIS πΈ
here's the whole struct, no cap, every single line:
struct dma_device {
struct kref ref;
unsigned int chancnt;
unsigned int privatecnt;
struct list_head channels;
struct list_head global_node;
struct dma_filter filter;
dma_cap_mask_t cap_mask;
enum dma_desc_metadata_mode desc_metadata_modes;
unsigned short max_xor;
unsigned short max_pq;
enum dmaengine_alignment copy_align;
enum dmaengine_alignment xor_align;
enum dmaengine_alignment pq_align;
enum dmaengine_alignment fill_align;
#define DMA_HAS_PQ_CONTINUE (1 << 15);
int dev_id;
struct device *dev;
struct module *owner;
struct ida chan_ida;
u32 src_addr_widths;
u32 dst_addr_widths;
u32 directions;
u32 min_burst;
u32 max_burst;
u32 max_sg_burst;
bool descriptor_reuse;
enum dma_residue_granularity residue_granularity;
int (*device_alloc_chan_resources)(struct dma_chan *chan);
int (*device_router_config)(struct dma_chan *chan);
void (*device_free_chan_resources)(struct dma_chan *chan);
struct dma_async_tx_descriptor *(*device_prep_dma_memcpy)( struct
dma_chan *chan, dma_addr_t dst, dma_addr_t src, size_t len, unsigned
long flags);
struct dma_async_tx_descriptor *(*device_prep_dma_xor)( struct
dma_chan *chan, dma_addr_t dst, dma_addr_t *src, unsigned int src_cnt,
size_t len, unsigned long flags);
struct dma_async_tx_descriptor *(*device_prep_dma_xor_val)( struct
dma_chan *chan, dma_addr_t *src, unsigned int src_cnt, size_t len, enum
sum_check_flags *result, unsigned long flags);
struct dma_async_tx_descriptor *(*device_prep_dma_pq)( struct
dma_chan *chan, dma_addr_t *dst, dma_addr_t *src, unsigned int src_cnt,
const unsigned char *scf, size_t len, unsigned long flags);
struct dma_async_tx_descriptor *(*device_prep_dma_pq_val)( struct
dma_chan *chan, dma_addr_t *pq, dma_addr_t *src, unsigned int src_cnt,
const unsigned char *scf, size_t len, enum sum_check_flags *pqres,
unsigned long flags);
struct dma_async_tx_descriptor *(*device_prep_dma_memset)( struct
dma_chan *chan, dma_addr_t dest, int value, size_t len, unsigned long
flags);
struct dma_async_tx_descriptor *(*device_prep_dma_memset_sg)( struct
dma_chan *chan, struct scatterlist *sg, unsigned int nents, int value,
unsigned long flags);
struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)( struct
dma_chan *chan, unsigned long flags);
struct dma_async_tx_descriptor *(*device_prep_peripheral_dma_vec)(
struct dma_chan *chan, const struct dma_vec *vecs, size_t nents, enum
dma_transfer_direction direction, unsigned long flags);
struct dma_async_tx_descriptor *(*device_prep_slave_sg)( struct
dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum
dma_transfer_direction direction, unsigned long flags, void *context);
struct dma_async_tx_descriptor *(*device_prep_config_sg)( struct
dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum
dma_transfer_direction direction, unsigned long flags, struct
dma_slave_config *config);
struct dma_async_tx_descriptor *(*device_prep_dma_cyclic)( struct
dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, size_t period_len,
enum dma_transfer_direction direction, unsigned long flags);
struct dma_async_tx_descriptor *(*device_prep_interleaved_dma)(
struct dma_chan *chan, struct dma_interleaved_template *xt, unsigned
long flags);
void (*device_caps)(struct dma_chan *chan, struct dma_slave_caps
*caps);
int (*device_config)(struct dma_chan *chan, struct dma_slave_config
*config);
int (*device_pause)(struct dma_chan *chan);
int (*device_resume)(struct dma_chan *chan);
int (*device_terminate_all)(struct dma_chan *chan);
void (*device_synchronize)(struct dma_chan *chan);
enum dma_status (*device_tx_status)(struct dma_chan *chan,
dma_cookie_t cookie, struct dma_tx_state *txstate);
void (*device_issue_pending)(struct dma_chan *chan);
void (*device_release)(struct dma_device *dev);
void (*dbg_summary_show)(struct seq_file *s, struct dma_device
*dev);
struct dentry *dbg_dev_root;
};
π Members π
okay this is the part where we go field by field, and yes there are a LOT of them. it's giving "main character energy" for like thirty bullet points straight. let's go π
π the bookkeeping girlies
refβ a reference is taken and put every time a channel is allocated or freed. basically the popularity counter π₯chancntβ how many DMA channels are supported, periodt.privatecntβ how many DMA channels are requested bydma_request_channel.channelsβ the list ofstruct dma_chan. the whole squad.global_nodeβ thelist_headfor the globaldma_device_list.filterβ the info for the device/slave to filter function/param mapping.cap_maskβ one or moredma_capabilityflags. like a little badge collection β¨desc_metadata_modesβ the metadata modes supported by the DMA device.dev_idβ a unique device ID. no two controllers share, iykyk.devβ thestruct devicereference for the dma mapping api.ownerβ owner module, and it's automatically set based on the provideddevπͺchan_idaβ a unique channel ID.
π₯ the capability counts & alignments
max_xorβ maximum number of xor sources,0if there's no capability.max_pqβ maximum number of PQ sources and PQ-continue capability.copy_alignβ the alignment shift for memcpy operations.xor_alignβ the alignment shift for xor operations.pq_alignβ the alignment shift for pq operations.fill_alignβ the alignment shift for memset operations.
π¦ the address / direction / burst zone
src_addr_widthsβ a bit mask of the src addr widths the device supports. the width is specified in bytes, so like, for a device supporting a width of4the mask should haveBIT(4)set. lowkey important, don't fumble that πdst_addr_widthsβ a bit mask of the dst addr widths the device supports.directionsβ a bit mask of the slave directions the device supports. and this is the fun one: since theenum dma_transfer_directionis not defined as a bit flag for each type, the dma controller should setBIT(<TYPE>)and the same should be checked by the controller as well. consistency is the vibe check bestie.min_burstβ min burst capability per-transfer.max_burstβ max burst capability per-transfer.max_sg_burstβ the max number of SG list entries executed in a single burst DMA transaction with no software intervention for reinitialization. a zero value means unlimited number of entries πdescriptor_reuseβ a submitted transfer can be resubmitted after completion.residue_granularityβ the granularity of the transfer residue reported bytx_status.
π the resource-management callbacks
device_alloc_chan_resourcesβ allocate resources and return the number of allocated descriptors.device_router_configβ optional callback for DMA router configuration.device_free_chan_resourcesβ release the DMA channel's resources.
π the prep callbacks (the big group, stay with me)
device_prep_dma_memcpyβ prepares a memcpy operation.device_prep_dma_xorβ prepares a xor operation.device_prep_dma_xor_valβ prepares a xor validation operation.device_prep_dma_pqβ prepares a pq operation.device_prep_dma_pq_valβ prepares a pqzero_sum operation.device_prep_dma_memsetβ prepares a memset operation.device_prep_dma_memset_sgβ prepares a memset operation over a scatter list.device_prep_dma_interruptβ prepares an end of chain interrupt operation.device_prep_peripheral_dma_vecβ prepares a scatter-gather DMA transfer, where the address and size of each segment is located in one entry of thedma_vecarray. cute and efficient fr fr.device_prep_slave_sgβ prepares a slave dma operation.device_prep_config_sgβ prepares a slave DMA operation withdma_slave_config.device_prep_dma_cyclicβ prepare a cyclic dma operation suitable for audio π§ the function takes a buffer of sizebuf_len, and the callback function will be called afterperiod_lenbytes have been transferred. loop girlie behavior.device_prep_interleaved_dmaβ Transfer expression in a generic way.
πΈ the control-plane callbacks
device_capsβ may be used to override the generic DMA slave capabilities with per-channel specific ones.device_configβ pushes a new configuration to a channel, returns0or an error code.device_pauseβ pauses any transfer happening on a channel. returns0or an error code.device_resumeβ resumes any transfer on a channel previously paused. returns0or an error code.device_terminate_allβ aborts all transfers on a channel. returns0or an error code.device_synchronizeβ synchronizes the termination of a transfers to the current context.device_tx_statusβ poll for transaction completion. the optionaltxstateparameter can be supplied with a pointer to get astructwith auxiliary transfer status information, otherwise the call will just return a simple status code. pick your fighter πdevice_issue_pendingβ push pending transactions to hardware. the "go go go" button π₯
π§ the teardown & debug bits
device_releaseβ called sometime afterdma_async_device_unregisteris called and there are no further references to this structure. this must be implemented to free resources β however, many existing drivers do not, and are therefore not safe to unbind while in use. bestie. read that twice π that's a real hazard, not a vibe.dbg_summary_showβ optional routine to show contents in debugfs; the default code will be used when this is omitted, but custom code can show extra, controller specific information.dbg_dev_rootβ the root folder in debugfs for this device.
heads up bestie, there's more of this page coming β don't close the tab π
β¨ SEE ALSO β¨
okay bestie, this is the part where we hand you the whole friend group π«Ά every single one of these lives in the kernel file ./include/linux/dmaengine.h, and they're all in section 9, so you already know the vibe. go say hi:
dma_cookie_t(9)β the cookie type, yes it's literally called a cookie, we love a whimsical naming moment πͺenum dma_status(9)β the status enum, your vibe check for a transferenum dma_transaction_type(9)β the enum of transaction typesenum dma_transfer_direction(9)β the direction enum, which way the data's goingstruct data_chunk(9)β the data chunk structstruct dma_interleaved_template(9)β the interleaved template struct, fancystruct dma_vec(9)β the dma vec structenum dma_ctrl_flags(9)β the control flags enumenum sum_check_bits(9)β the sum check bits enumenum sum_check_flags(9)β the sum check flags enumenum dma_desc_metadata_mode(9)β the descriptor metadata mode enumstruct dma_chan_percpu(9)β the per-cpu channel structstruct dma_router(9)β the router structstruct dma_chan(9)β the channel struct itself, main character energy πstruct dma_chan_dev(9)β the channel device structenum dma_slave_buswidth(9)β the slave bus width enumstruct dma_slave_config(9)β the slave config structenum dma_residue_granularity(9)β the residue granularity enumstruct dma_slave_caps(9)β the slave caps structdma_filter_fn(9)β the filter function typestruct dma_async_tx_descriptor(9)β the async tx descriptor struct, absolute iconstruct dma_tx_state(9)β the tx state structenum dmaengine_alignment(9)β the dmaengine alignment enumstruct dma_slave_map(9)β the slave map structstruct dma_filter(9)β the filter structdmaengine_prep_peripheral_dma_vec(9)β preps a peripheral dma vecdmaengine_prep_config_sg_safe(9)β the sg-safe prep config calldmaengine_prep_config_single_safe(9)β the single-safe prep config calldmaengine_prep_dma_memset(9)β preps a dma memset, yes that's a thingdmaengine_terminate_all(9)β terminates all of it πdmaengine_terminate_async(9)β the async terminatedmaengine_synchronize(9)β synchronizes, get in sync bestiedmaengine_terminate_sync(9)β the sync terminatedma_async_issue_pending(9)β issues the pending async workdma_async_is_tx_complete(9)β asks "is the tx complete?" π₯dma_async_is_complete(9)β asks "is it complete?" π₯
ngl that's a whole lotta pages but they're all right there in ./include/linux/dmaengine.h, so likeβ¦ one tab and you're set π
and that's the whole manual page, bestie β periodt π this one came out of the tree at ./include/linux, dated October 2026, and it's filed under struct dma_device(9). go forth and DMA responsibly, mwah πβ¨π¦
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms