ENUM DMA_DESC_METADATA_MODE(9)
πΈ enum dma_desc_metadata_mode(9) πΈ
okay so real talk, this one is from the Kernel API Manual and it's all about how a DMA descriptor handles its metadata bestie. lowkey important, highkey under-documented. let's get into it π
β¨ NAME β¨
enum dma_desc_metadata_mode β the per-descriptor metadata mode types that are supported, and btw @DESC_METADATA_CLIENT means the metadata buffer is allocated/provided by the client driver and it's attached (via the dmaengine_desc_attach_metadata() helper) to the descriptor. that's it, that's the vibe π«Ά
π SYNOPSIS π
enum dma_desc_metadata_mode {
DESC_METADATA_NONE ,
DESC_METADATA_CLIENT ,
DESC_METADATA_ENGINE
};
β Constants β
DESC_METADATA_NONEβ-- undescribed --(yes literally, the docs did not come through for us here π)DESC_METADATA_CLIENTβ-- undescribed --(same, no cap, that's what it says π)DESC_METADATA_ENGINEβ-- undescribed --(again π©·)
π¦ Description π¦
so if you're a client driver and you're interested in using this mode, here's the little routine you can follow, per the docs β¨
π DMA_MEM_TO_DEV / DEV_MEM_TO_MEM:
- prepare the descriptor (
dmaengine_prep_*), then construct the metadata in the client's buffer β yes both, in that order, don't @ me - use
dmaengine_desc_attach_metadatato attach the buffer to the descriptor - submit the transfer
π DMA_DEV_TO_MEM:
- prepare the descriptor (
dmaengine_prep_*) - use
dmaengine_desc_attach_metadatato attach the buffer to the descriptor - submit the transfer
- when the transfer is completed, the metadata should be available in the attached buffer π
then we got DESC_METADATA_ENGINE β in this one the metadata buffer is allocated/managed by the DMA driver. the client driver can ask for the pointer, the maximum size, and the currently used size of the metadata, and can directly update or read it. dmaengine_desc_get_metadata_ptr and dmaengine_desc_set_metadata_len are provided as helper functions for exactly this. iconic of them fr fr π
π Note π
β οΈ big one: the metadata area for the descriptor is no longer valid after the transfer has been completed (it's valid up to the point when the completion callback returns, if that's how you're using it). like, the window closes, bestie π
client drivers interested in using this mode can follow this lil recipe:
π DMA_MEM_TO_DEV / DEV_MEM_TO_MEM:
- prepare the descriptor (
dmaengine_prep_*) - use
dmaengine_desc_get_metadata_ptrto get the pointer to the engine's metadata area - update the metadata at the pointer
- use
dmaengine_desc_set_metadata_lento tell the DMA engine the amount of data the client has placed into the metadata buffer - submit the transfer
π DMA_DEV_TO_MEM:
- prepare the descriptor (
dmaengine_prep_*) - submit the transfer
- on transfer completion, use
dmaengine_desc_get_metadata_ptrto get the pointer to the engine's metadata area - Read out the metadata from the pointer (yes, Read with a capital R, we respect the original β¨)
π¨ Warning: the two modes are not compatible and clients must use one mode for a descriptor. one. not both. pick a lane π«Ά
π SEE ALSO π
kernel file ./include/linux/dmaengine.h, and also all of these cuties:
dma_cookie_t(9), enum dma_status(9), enum dma_transaction_type(9), enum dma_transfer_direction(9), struct data_chunk(9), struct dma_interleaved_template(9), struct dma_vec(9), enum dma_ctrl_flags(9), enum sum_check_bits(9), enum sum_check_flags(9), struct dma_chan_percpu(9), struct dma_router(9), struct dma_chan(9), struct dma_chan_dev(9), enum dma_slave_buswidth(9), struct dma_slave_config(9), enum dma_residue_granularity(9), struct dma_slave_caps(9), dma_filter_fn(9), struct dma_async_tx_descriptor(9), struct dma_tx_state(9), enum dmaengine_alignment(9), struct dma_slave_map(9), struct dma_filter(9), struct dma_device(9), dmaengine_prep_peripheral_dma_vec(9), dmaengine_prep_config_sg_safe(9), dmaengine_prep_config_single_safe(9), dmaengine_prep_dma_memset(9), dmaengine_terminate_all(9), dmaengine_terminate_async(9), dmaengine_synchronize(9), dmaengine_terminate_sync(9), dma_async_issue_pending(9), dma_async_is_tx_complete(9), dma_async_is_complete(9)
kisses from ./include/linux, dated October 2026, signed off as enum dma_desc_metadata_mode(9) β catch you in the next transfer, bestie π§ββοΈπ
π¦ 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