drivers/dma/k3dma.c
Source file repositories/reference/linux-study-clean/drivers/dma/k3dma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/k3dma.c- Extension
.c- Size
- 25140 bytes
- Lines
- 1033
- 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/sched.hlinux/device.hlinux/dma-mapping.hlinux/dmapool.hlinux/dmaengine.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/slab.hlinux/spinlock.hlinux/of.hlinux/clk.hlinux/of_dma.hvirt-dma.h
Detected Declarations
struct k3_desc_hwstruct k3_dma_desc_swstruct k3_dma_phystruct k3_dma_chanstruct k3_dma_phystruct k3_dma_devstruct k3dma_soc_datafunction k3_dma_pause_dmafunction k3_dma_terminate_chanfunction k3_dma_set_descfunction k3_dma_get_curr_cntfunction k3_dma_get_curr_llifunction k3_dma_get_chan_statfunction k3_dma_enable_dmafunction k3_dma_int_handlerfunction k3_dma_start_txdfunction k3_dma_taskletfunction k3_dma_free_chan_resourcesfunction k3_dma_tx_statusfunction k3_dma_issue_pendingfunction k3_dma_fill_descfunction for_each_sgfunction k3_dma_prep_dma_cyclicfunction k3_dma_configfunction k3_dma_config_writefunction k3_dma_free_descfunction k3_dma_terminate_allfunction k3_dma_synchronizefunction k3_dma_transfer_pausefunction k3_dma_transfer_resumefunction k3_dma_probefunction k3_dma_removefunction list_for_each_entry_safefunction k3_dma_suspend_devfunction k3_dma_resume_dev
Annotated Snippet
struct k3_desc_hw {
u32 lli;
u32 reserved[3];
u32 count;
u32 saddr;
u32 daddr;
u32 config;
} __aligned(32);
struct k3_dma_desc_sw {
struct virt_dma_desc vd;
dma_addr_t desc_hw_lli;
size_t desc_num;
size_t size;
struct k3_desc_hw *desc_hw;
};
struct k3_dma_phy;
struct k3_dma_chan {
u32 ccfg;
struct virt_dma_chan vc;
struct k3_dma_phy *phy;
struct list_head node;
dma_addr_t dev_addr;
enum dma_status status;
bool cyclic;
struct dma_slave_config slave_config;
};
struct k3_dma_phy {
u32 idx;
void __iomem *base;
struct k3_dma_chan *vchan;
struct k3_dma_desc_sw *ds_run;
struct k3_dma_desc_sw *ds_done;
};
struct k3_dma_dev {
struct dma_device slave;
void __iomem *base;
struct tasklet_struct task;
spinlock_t lock;
struct list_head chan_pending;
struct k3_dma_phy *phy;
struct k3_dma_chan *chans;
struct clk *clk;
struct dma_pool *pool;
u32 dma_channels;
u32 dma_requests;
u32 dma_channel_mask;
unsigned int irq;
};
#define K3_FLAG_NOCLK BIT(1)
struct k3dma_soc_data {
unsigned long flags;
};
#define to_k3_dma(dmadev) container_of(dmadev, struct k3_dma_dev, slave)
static int k3_dma_config_write(struct dma_chan *chan,
enum dma_transfer_direction dir,
struct dma_slave_config *cfg);
static struct k3_dma_chan *to_k3_chan(struct dma_chan *chan)
{
return container_of(chan, struct k3_dma_chan, vc.chan);
}
static void k3_dma_pause_dma(struct k3_dma_phy *phy, bool on)
{
u32 val = 0;
if (on) {
val = readl_relaxed(phy->base + CX_CFG);
val |= CX_CFG_EN;
writel_relaxed(val, phy->base + CX_CFG);
} else {
val = readl_relaxed(phy->base + CX_CFG);
val &= ~CX_CFG_EN;
writel_relaxed(val, phy->base + CX_CFG);
}
}
static void k3_dma_terminate_chan(struct k3_dma_phy *phy, struct k3_dma_dev *d)
{
Annotation
- Immediate include surface: `linux/sched.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/dmapool.h`, `linux/dmaengine.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`.
- Detected declarations: `struct k3_desc_hw`, `struct k3_dma_desc_sw`, `struct k3_dma_phy`, `struct k3_dma_chan`, `struct k3_dma_phy`, `struct k3_dma_dev`, `struct k3dma_soc_data`, `function k3_dma_pause_dma`, `function k3_dma_terminate_chan`, `function k3_dma_set_desc`.
- 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.