drivers/dma/xilinx/xdma.c
Source file repositories/reference/linux-study-clean/drivers/dma/xilinx/xdma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/xilinx/xdma.c- Extension
.c- Size
- 35077 bytes
- Lines
- 1322
- Domain
- Driver Families
- Bucket
- drivers/dma
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/mod_devicetable.hlinux/bitfield.hlinux/dmapool.hlinux/regmap.hlinux/dmaengine.hlinux/dma/amd_xdma.hlinux/platform_device.hlinux/platform_data/amd_xdma.hlinux/dma-mapping.hlinux/pci.h../virt-dma.hxdma-regs.h
Detected Declarations
struct xdma_desc_blockstruct xdma_chanstruct xdma_descstruct xdma_devicefunction xdma_link_sg_desc_blocksfunction xdma_link_cyclic_desc_blocksfunction xdma_channel_initfunction xdma_free_descfunction xdma_alloc_descfunction xdma_xfer_startfunction xdma_xfer_stopfunction xdma_alloc_channelsfunction xdma_issue_pendingfunction xdma_terminate_allfunction xdma_synchronizefunction xdma_fill_descsfunction xdma_prep_device_sgfunction xdma_prep_dma_cyclicfunction xdma_prep_interleaved_dmafunction xdma_device_configfunction xdma_free_chan_resourcesfunction xdma_alloc_chan_resourcesfunction xdma_tx_statusfunction xdma_channel_isrfunction xdma_irq_finifunction xdma_set_vector_regfunction xdma_irq_initfunction xdma_filter_fnfunction xdma_disable_user_irqfunction xdma_enable_user_irqfunction xdma_get_user_irqfunction xdma_removefunction xdma_probeexport xdma_disable_user_irqexport xdma_enable_user_irqexport xdma_get_user_irq
Annotated Snippet
struct xdma_desc_block {
void *virt_addr;
dma_addr_t dma_addr;
};
/**
* struct xdma_chan - Driver specific DMA channel structure
* @vchan: Virtual channel
* @xdev_hdl: Pointer to DMA device structure
* @base: Offset of channel registers
* @desc_pool: Descriptor pool
* @busy: Busy flag of the channel
* @dir: Transferring direction of the channel
* @cfg: Transferring config of the channel
* @irq: IRQ assigned to the channel
* @last_interrupt: task for comppleting last interrupt
* @stop_requested: stop request flag
*/
struct xdma_chan {
struct virt_dma_chan vchan;
void *xdev_hdl;
u32 base;
struct dma_pool *desc_pool;
bool busy;
enum dma_transfer_direction dir;
struct dma_slave_config cfg;
u32 irq;
struct completion last_interrupt;
bool stop_requested;
};
/**
* struct xdma_desc - DMA desc structure
* @vdesc: Virtual DMA descriptor
* @chan: DMA channel pointer
* @dir: Transferring direction of the request
* @desc_blocks: Hardware descriptor blocks
* @dblk_num: Number of hardware descriptor blocks
* @desc_num: Number of hardware descriptors
* @completed_desc_num: Completed hardware descriptors
* @cyclic: Cyclic transfer vs. scatter-gather
* @interleaved_dma: Interleaved DMA transfer
* @periods: Number of periods in the cyclic transfer
* @period_size: Size of a period in bytes in cyclic transfers
* @frames_left: Number of frames left in interleaved DMA transfer
* @error: tx error flag
*/
struct xdma_desc {
struct virt_dma_desc vdesc;
struct xdma_chan *chan;
enum dma_transfer_direction dir;
struct xdma_desc_block *desc_blocks;
u32 dblk_num;
u32 desc_num;
u32 completed_desc_num;
bool cyclic;
bool interleaved_dma;
u32 periods;
u32 period_size;
u32 frames_left;
bool error;
};
#define XDMA_DEV_STATUS_REG_DMA BIT(0)
#define XDMA_DEV_STATUS_INIT_MSIX BIT(1)
/**
* struct xdma_device - DMA device structure
* @pdev: Platform device pointer
* @dma_dev: DMA device structure
* @rmap: MMIO regmap for DMA registers
* @h2c_chans: Host to Card channels
* @c2h_chans: Card to Host channels
* @h2c_chan_num: Number of H2C channels
* @c2h_chan_num: Number of C2H channels
* @irq_start: Start IRQ assigned to device
* @irq_num: Number of IRQ assigned to device
* @status: Initialization status
*/
struct xdma_device {
struct platform_device *pdev;
struct dma_device dma_dev;
struct regmap *rmap;
struct xdma_chan *h2c_chans;
struct xdma_chan *c2h_chans;
u32 h2c_chan_num;
u32 c2h_chan_num;
u32 irq_start;
u32 irq_num;
u32 status;
Annotation
- Immediate include surface: `linux/mod_devicetable.h`, `linux/bitfield.h`, `linux/dmapool.h`, `linux/regmap.h`, `linux/dmaengine.h`, `linux/dma/amd_xdma.h`, `linux/platform_device.h`, `linux/platform_data/amd_xdma.h`.
- Detected declarations: `struct xdma_desc_block`, `struct xdma_chan`, `struct xdma_desc`, `struct xdma_device`, `function xdma_link_sg_desc_blocks`, `function xdma_link_cyclic_desc_blocks`, `function xdma_channel_init`, `function xdma_free_desc`, `function xdma_alloc_desc`, `function xdma_xfer_start`.
- Atlas domain: Driver Families / drivers/dma.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.