drivers/dma/uniphier-xdmac.c
Source file repositories/reference/linux-study-clean/drivers/dma/uniphier-xdmac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/uniphier-xdmac.c- Extension
.c- Size
- 16394 bytes
- Lines
- 617
- Domain
- Driver Families
- Bucket
- drivers/dma
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/bitops.hlinux/bitfield.hlinux/iopoll.hlinux/module.hlinux/of.hlinux/of_dma.hlinux/platform_device.hlinux/slab.hdmaengine.hvirt-dma.h
Detected Declarations
struct uniphier_xdmac_desc_nodestruct uniphier_xdmac_descstruct uniphier_xdmac_chanstruct uniphier_xdmac_devicefunction to_uniphier_xdmac_chanfunction to_uniphier_xdmac_descfunction uniphier_xdmac_next_descfunction uniphier_xdmac_chan_startfunction uniphier_xdmac_chan_stopfunction uniphier_xdmac_startfunction uniphier_xdmac_chan_irqfunction uniphier_xdmac_irq_handlerfunction uniphier_xdmac_free_chan_resourcesfunction uniphier_xdmac_prep_dma_memcpyfunction uniphier_xdmac_prep_slave_sgfunction for_each_sgfunction uniphier_xdmac_slave_configfunction uniphier_xdmac_terminate_allfunction uniphier_xdmac_synchronizefunction uniphier_xdmac_issue_pendingfunction uniphier_xdmac_desc_freefunction uniphier_xdmac_chan_initfunction uniphier_xdmac_probefunction uniphier_xdmac_remove
Annotated Snippet
struct uniphier_xdmac_desc_node {
dma_addr_t src;
dma_addr_t dst;
u32 burst_size;
u32 nr_burst;
};
struct uniphier_xdmac_desc {
struct virt_dma_desc vd;
unsigned int nr_node;
unsigned int cur_node;
enum dma_transfer_direction dir;
struct uniphier_xdmac_desc_node nodes[] __counted_by(nr_node);
};
struct uniphier_xdmac_chan {
struct virt_dma_chan vc;
struct uniphier_xdmac_device *xdev;
struct uniphier_xdmac_desc *xd;
void __iomem *reg_ch_base;
struct dma_slave_config sconfig;
int id;
unsigned int req_factor;
};
struct uniphier_xdmac_device {
struct dma_device ddev;
void __iomem *reg_base;
int nr_chans;
struct uniphier_xdmac_chan channels[] __counted_by(nr_chans);
};
static struct uniphier_xdmac_chan *
to_uniphier_xdmac_chan(struct virt_dma_chan *vc)
{
return container_of(vc, struct uniphier_xdmac_chan, vc);
}
static struct uniphier_xdmac_desc *
to_uniphier_xdmac_desc(struct virt_dma_desc *vd)
{
return container_of(vd, struct uniphier_xdmac_desc, vd);
}
/* xc->vc.lock must be held by caller */
static struct uniphier_xdmac_desc *
uniphier_xdmac_next_desc(struct uniphier_xdmac_chan *xc)
{
struct virt_dma_desc *vd;
vd = vchan_next_desc(&xc->vc);
if (!vd)
return NULL;
list_del(&vd->node);
return to_uniphier_xdmac_desc(vd);
}
/* xc->vc.lock must be held by caller */
static void uniphier_xdmac_chan_start(struct uniphier_xdmac_chan *xc,
struct uniphier_xdmac_desc *xd)
{
u32 src_mode, src_width;
u32 dst_mode, dst_width;
dma_addr_t src_addr, dst_addr;
u32 val, its, tnum;
enum dma_slave_buswidth buswidth;
src_addr = xd->nodes[xd->cur_node].src;
dst_addr = xd->nodes[xd->cur_node].dst;
its = xd->nodes[xd->cur_node].burst_size;
tnum = xd->nodes[xd->cur_node].nr_burst;
/*
* The width of MEM side must be 4 or 8 bytes, that does not
* affect that of DEV side and transfer size.
*/
if (xd->dir == DMA_DEV_TO_MEM) {
src_mode = XDMAC_SADM_SAM_FIXED;
buswidth = xc->sconfig.src_addr_width;
} else {
src_mode = XDMAC_SADM_SAM_INC;
buswidth = DMA_SLAVE_BUSWIDTH_8_BYTES;
}
src_width = FIELD_PREP(XDMAC_SADM_STW_MASK, __ffs(buswidth));
if (xd->dir == DMA_MEM_TO_DEV) {
dst_mode = XDMAC_DADM_DAM_FIXED;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/bitfield.h`, `linux/iopoll.h`, `linux/module.h`, `linux/of.h`, `linux/of_dma.h`, `linux/platform_device.h`, `linux/slab.h`.
- Detected declarations: `struct uniphier_xdmac_desc_node`, `struct uniphier_xdmac_desc`, `struct uniphier_xdmac_chan`, `struct uniphier_xdmac_device`, `function to_uniphier_xdmac_chan`, `function to_uniphier_xdmac_desc`, `function uniphier_xdmac_next_desc`, `function uniphier_xdmac_chan_start`, `function uniphier_xdmac_chan_stop`, `function uniphier_xdmac_start`.
- Atlas domain: Driver Families / drivers/dma.
- Implementation status: source implementation candidate.
- 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.