drivers/dma/mpc512x_dma.c
Source file repositories/reference/linux-study-clean/drivers/dma/mpc512x_dma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/mpc512x_dma.c- Extension
.c- Size
- 30570 bytes
- Lines
- 1124
- 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/module.hlinux/dmaengine.hlinux/dma-mapping.hlinux/interrupt.hlinux/io.hlinux/slab.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/of_dma.hlinux/platform_device.hlinux/random.hdmaengine.h
Detected Declarations
struct mpc_dma_descstruct mpc_dma_chanstruct mpc_dmafunction mpc_dma_executefunction mpc_dma_irq_processfunction mpc_dma_irqfunction mpc_dma_process_completedfunction list_for_each_entryfunction mpc_dma_taskletfunction mpc_dma_tx_submitfunction mpc_dma_alloc_chan_resourcesfunction mpc_dma_free_chan_resourcesfunction mpc_dma_issue_pendingfunction mpc_dma_prep_memcpyfunction buswidth_to_dmatsizefunction mpc_dma_prep_slave_sgfunction for_each_sgfunction is_buswidth_validfunction mpc_dma_device_configfunction mpc_dma_device_terminate_allfunction mpc_dma_probefunction mpc_dma_remove
Annotated Snippet
struct mpc_dma_desc {
struct dma_async_tx_descriptor desc;
struct mpc_dma_tcd *tcd;
dma_addr_t tcd_paddr;
int error;
struct list_head node;
int will_access_peripheral;
};
struct mpc_dma_chan {
struct dma_chan chan;
struct list_head free;
struct list_head prepared;
struct list_head queued;
struct list_head active;
struct list_head completed;
struct mpc_dma_tcd *tcd;
dma_addr_t tcd_paddr;
/* Settings for access to peripheral FIFO */
dma_addr_t src_per_paddr;
u32 src_tcd_nunits;
u8 swidth;
dma_addr_t dst_per_paddr;
u32 dst_tcd_nunits;
u8 dwidth;
/* Lock for this structure */
spinlock_t lock;
};
struct mpc_dma {
struct dma_device dma;
struct tasklet_struct tasklet;
struct mpc_dma_chan channels[MPC_DMA_CHANNELS];
struct mpc_dma_regs __iomem *regs;
struct mpc_dma_tcd __iomem *tcd;
int irq;
int irq2;
uint error_status;
int is_mpc8308;
/* Lock for error_status field in this structure */
spinlock_t error_status_lock;
};
#define DRV_NAME "mpc512x_dma"
/* Convert struct dma_chan to struct mpc_dma_chan */
static inline struct mpc_dma_chan *dma_chan_to_mpc_dma_chan(struct dma_chan *c)
{
return container_of(c, struct mpc_dma_chan, chan);
}
/* Convert struct dma_chan to struct mpc_dma */
static inline struct mpc_dma *dma_chan_to_mpc_dma(struct dma_chan *c)
{
struct mpc_dma_chan *mchan = dma_chan_to_mpc_dma_chan(c);
return container_of(mchan, struct mpc_dma, channels[c->chan_id]);
}
/*
* Execute all queued DMA descriptors.
*
* Following requirements must be met while calling mpc_dma_execute():
* a) mchan->lock is acquired,
* b) mchan->active list is empty,
* c) mchan->queued list contains at least one entry.
*/
static void mpc_dma_execute(struct mpc_dma_chan *mchan)
{
struct mpc_dma *mdma = dma_chan_to_mpc_dma(&mchan->chan);
struct mpc_dma_desc *first = NULL;
struct mpc_dma_desc *prev = NULL;
struct mpc_dma_desc *mdesc;
int cid = mchan->chan.chan_id;
while (!list_empty(&mchan->queued)) {
mdesc = list_first_entry(&mchan->queued,
struct mpc_dma_desc, node);
/*
* Grab either several mem-to-mem transfer descriptors
* or one peripheral transfer descriptor,
* don't mix mem-to-mem and peripheral transfer descriptors
* within the same 'active' list.
*/
if (mdesc->will_access_peripheral) {
if (list_empty(&mchan->active))
list_move_tail(&mdesc->node, &mchan->active);
Annotation
- Immediate include surface: `linux/module.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/io.h`, `linux/slab.h`, `linux/of.h`, `linux/of_address.h`.
- Detected declarations: `struct mpc_dma_desc`, `struct mpc_dma_chan`, `struct mpc_dma`, `function mpc_dma_execute`, `function mpc_dma_irq_process`, `function mpc_dma_irq`, `function mpc_dma_process_completed`, `function list_for_each_entry`, `function mpc_dma_tasklet`, `function mpc_dma_tx_submit`.
- 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.