drivers/dma/mediatek/mtk-cqdma.c
Source file repositories/reference/linux-study-clean/drivers/dma/mediatek/mtk-cqdma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/mediatek/mtk-cqdma.c- Extension
.c- Size
- 24694 bytes
- Lines
- 934
- 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/clk.hlinux/dmaengine.hlinux/dma-mapping.hlinux/err.hlinux/iopoll.hlinux/interrupt.hlinux/list.hlinux/module.hlinux/of.hlinux/of_dma.hlinux/platform_device.hlinux/pm_runtime.hlinux/refcount.hlinux/slab.h../virt-dma.h
Detected Declarations
struct mtk_cqdma_vdescstruct mtk_cqdma_pchanstruct mtk_cqdma_vchanstruct mtk_cqdma_devicefunction mtk_dma_readfunction mtk_dma_writefunction mtk_dma_rmwfunction mtk_dma_setfunction mtk_dma_clrfunction mtk_cqdma_vdesc_freefunction mtk_cqdma_poll_engine_donefunction mtk_cqdma_hard_resetfunction mtk_cqdma_startfunction mtk_cqdma_issue_vchan_pendingfunction list_for_each_entry_safefunction mtk_cqdma_is_vchan_activefunction mtk_cqdma_tasklet_cbfunction mtk_cqdma_irqfunction list_for_each_entryfunction mtk_cqdma_tx_statusfunction mtk_cqdma_issue_pendingfunction mtk_cqdma_prep_dma_memcpyfunction mtk_cqdma_free_inactive_descfunction mtk_cqdma_free_active_descfunction mtk_cqdma_terminate_allfunction mtk_cqdma_alloc_chan_resourcesfunction mtk_cqdma_free_chan_resourcesfunction mtk_cqdma_hw_initfunction mtk_cqdma_hw_deinitfunction mtk_cqdma_probefunction mtk_cqdma_remove
Annotated Snippet
struct mtk_cqdma_vdesc {
struct virt_dma_desc vd;
size_t len;
size_t residue;
dma_addr_t dest;
dma_addr_t src;
struct dma_chan *ch;
struct list_head node;
struct mtk_cqdma_vdesc *parent;
};
/**
* struct mtk_cqdma_pchan - The struct holding info describing physical
* channel (PC)
* @queue: Queue for the PDs issued to this PC
* @base: The mapped register I/O base of this PC
* @irq: The IRQ that this PC are using
* @refcnt: Track how many VCs are using this PC
* @tasklet: Tasklet for this PC
* @lock: Lock protect agaisting multiple VCs access PC
*/
struct mtk_cqdma_pchan {
struct list_head queue;
void __iomem *base;
u32 irq;
refcount_t refcnt;
struct tasklet_struct tasklet;
/* lock to protect PC */
spinlock_t lock;
};
/**
* struct mtk_cqdma_vchan - The struct holding info describing virtual
* channel (VC)
* @vc: An instance for struct virt_dma_chan
* @pc: The pointer to the underlying PC
* @issue_completion: The wait for all issued descriptors completited
* @issue_synchronize: Bool indicating channel synchronization starts
*/
struct mtk_cqdma_vchan {
struct virt_dma_chan vc;
struct mtk_cqdma_pchan *pc;
struct completion issue_completion;
bool issue_synchronize;
};
/**
* struct mtk_cqdma_device - The struct holding info describing CQDMA
* device
* @ddev: An instance for struct dma_device
* @clk: The clock that device internal is using
* @dma_requests: The number of VCs the device supports to
* @dma_channels: The number of PCs the device supports to
* @vc: The pointer to all available VCs
* @pc: The pointer to all the underlying PCs
*/
struct mtk_cqdma_device {
struct dma_device ddev;
struct clk *clk;
u32 dma_requests;
u32 dma_channels;
struct mtk_cqdma_vchan *vc;
struct mtk_cqdma_pchan **pc;
};
static struct mtk_cqdma_device *to_cqdma_dev(struct dma_chan *chan)
{
return container_of(chan->device, struct mtk_cqdma_device, ddev);
}
static struct mtk_cqdma_vchan *to_cqdma_vchan(struct dma_chan *chan)
{
return container_of(chan, struct mtk_cqdma_vchan, vc.chan);
}
static struct mtk_cqdma_vdesc *to_cqdma_vdesc(struct virt_dma_desc *vd)
{
return container_of(vd, struct mtk_cqdma_vdesc, vd);
}
static struct device *cqdma2dev(struct mtk_cqdma_device *cqdma)
{
return cqdma->ddev.dev;
}
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/iopoll.h`, `linux/interrupt.h`, `linux/list.h`.
- Detected declarations: `struct mtk_cqdma_vdesc`, `struct mtk_cqdma_pchan`, `struct mtk_cqdma_vchan`, `struct mtk_cqdma_device`, `function mtk_dma_read`, `function mtk_dma_write`, `function mtk_dma_rmw`, `function mtk_dma_set`, `function mtk_dma_clr`, `function mtk_cqdma_vdesc_free`.
- 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.