drivers/dma/sun4i-dma.c
Source file repositories/reference/linux-study-clean/drivers/dma/sun4i-dma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/sun4i-dma.c- Extension
.c- Size
- 40882 bytes
- Lines
- 1431
- 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/bitmap.hlinux/bitops.hlinux/clk.hlinux/dma-mapping.hlinux/dmaengine.hlinux/dmapool.hlinux/interrupt.hlinux/module.hlinux/of_dma.hlinux/of_device.hlinux/platform_device.hlinux/reset.hlinux/slab.hlinux/spinlock.hvirt-dma.h
Detected Declarations
struct sun4i_dma_configstruct sun4i_dma_pchanstruct sun4i_dma_vchanstruct sun4i_dma_promisestruct sun4i_dma_contractstruct sun4i_dma_devfunction set_dst_data_width_a10function set_src_data_width_a10function set_dst_data_width_f1c100sfunction set_src_data_width_f1c100sfunction convert_burst_a10function convert_burst_f1c100sfunction convert_buswidthfunction sun4i_dma_free_chan_resourcesfunction release_pchanfunction configure_pchanfunction set_pchan_interruptfunction __execute_vchan_pendingfunction sanitize_configfunction generate_ndma_promisefunction generate_ddma_promisefunction get_next_cyclic_promisefunction sun4i_dma_free_contractfunction sun4i_dma_prep_dma_memcpyfunction sun4i_dma_prep_dma_cyclicfunction periodsfunction sun4i_dma_prep_slave_sgfunction for_each_sgfunction sun4i_dma_terminate_allfunction sun4i_dma_configfunction sun4i_dma_tx_statusfunction sun4i_dma_issue_pendingfunction sun4i_dma_interruptfunction for_each_set_bitfunction interruptfunction sun4i_dma_probefunction sun4i_dma_remove
Annotated Snippet
struct sun4i_dma_config {
u32 ndma_nr_max_channels;
u32 ndma_nr_max_vchans;
u32 ddma_nr_max_channels;
u32 ddma_nr_max_vchans;
u32 dma_nr_max_channels;
void (*set_dst_data_width)(u32 *p_cfg, s8 data_width);
void (*set_src_data_width)(u32 *p_cfg, s8 data_width);
int (*convert_burst)(u32 maxburst);
u8 ndma_drq_sdram;
u8 ddma_drq_sdram;
u8 max_burst;
bool has_reset;
};
struct sun4i_dma_pchan {
/* Register base of channel */
void __iomem *base;
/* vchan currently being serviced */
struct sun4i_dma_vchan *vchan;
/* Is this a dedicated pchan? */
int is_dedicated;
};
struct sun4i_dma_vchan {
struct virt_dma_chan vc;
struct dma_slave_config cfg;
struct sun4i_dma_pchan *pchan;
struct sun4i_dma_promise *processing;
struct sun4i_dma_contract *contract;
u8 endpoint;
int is_dedicated;
};
struct sun4i_dma_promise {
u32 cfg;
u32 para;
dma_addr_t src;
dma_addr_t dst;
size_t len;
struct list_head list;
};
/* A contract is a set of promises */
struct sun4i_dma_contract {
struct virt_dma_desc vd;
struct list_head demands;
struct list_head completed_demands;
bool is_cyclic : 1;
bool use_half_int : 1;
};
struct sun4i_dma_dev {
unsigned long *pchans_used;
struct dma_device slave;
struct sun4i_dma_pchan *pchans;
struct sun4i_dma_vchan *vchans;
void __iomem *base;
struct clk *clk;
int irq;
spinlock_t lock;
const struct sun4i_dma_config *cfg;
struct reset_control *rst;
};
static struct sun4i_dma_dev *to_sun4i_dma_dev(struct dma_device *dev)
{
return container_of(dev, struct sun4i_dma_dev, slave);
}
static struct sun4i_dma_vchan *to_sun4i_dma_vchan(struct dma_chan *chan)
{
return container_of(chan, struct sun4i_dma_vchan, vc.chan);
}
static struct sun4i_dma_contract *to_sun4i_dma_contract(struct virt_dma_desc *vd)
{
return container_of(vd, struct sun4i_dma_contract, vd);
}
static struct device *chan2dev(struct dma_chan *chan)
{
return &chan->dev->device;
}
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/bitops.h`, `linux/clk.h`, `linux/dma-mapping.h`, `linux/dmaengine.h`, `linux/dmapool.h`, `linux/interrupt.h`, `linux/module.h`.
- Detected declarations: `struct sun4i_dma_config`, `struct sun4i_dma_pchan`, `struct sun4i_dma_vchan`, `struct sun4i_dma_promise`, `struct sun4i_dma_contract`, `struct sun4i_dma_dev`, `function set_dst_data_width_a10`, `function set_src_data_width_a10`, `function set_dst_data_width_f1c100s`, `function set_src_data_width_f1c100s`.
- 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.