drivers/dma/mediatek/mtk-hsdma.c
Source file repositories/reference/linux-study-clean/drivers/dma/mediatek/mtk-hsdma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/mediatek/mtk-hsdma.c- Extension
.c- Size
- 28910 bytes
- Lines
- 1052
- 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/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_hsdma_pdescstruct mtk_hsdma_vdescstruct mtk_hsdma_cbstruct mtk_hsdma_ringstruct mtk_hsdma_pchanstruct mtk_hsdma_vchanstruct mtk_hsdma_socstruct mtk_hsdma_deviceenum mtk_hsdma_vdesc_flagfunction mtk_dma_readfunction mtk_dma_writefunction mtk_dma_rmwfunction mtk_dma_setfunction mtk_dma_clrfunction mtk_hsdma_vdesc_freefunction mtk_hsdma_busy_waitfunction mtk_hsdma_alloc_pchanfunction mtk_hsdma_free_pchanfunction mtk_hsdma_issue_pending_vdescfunction mtk_hsdma_issue_vchan_pendingfunction list_for_each_entry_safefunction mtk_hsdma_free_rooms_in_ringfunction mtk_hsdma_irqfunction mtk_hsdma_tx_statusfunction mtk_hsdma_issue_pendingfunction mtk_hsdma_prep_dma_memcpyfunction mtk_hsdma_free_inactive_descfunction mtk_hsdma_free_active_descfunction mtk_hsdma_terminate_allfunction mtk_hsdma_alloc_chan_resourcesfunction mtk_hsdma_free_chan_resourcesfunction mtk_hsdma_hw_initfunction mtk_hsdma_hw_deinitfunction mtk_hsdma_probefunction mtk_hsdma_remove
Annotated Snippet
struct mtk_hsdma_pdesc {
__le32 desc1;
__le32 desc2;
__le32 desc3;
__le32 desc4;
} __packed __aligned(4);
/**
* struct mtk_hsdma_vdesc - This is the struct holding info describing virtual
* descriptor (VD)
* @vd: An instance for struct virt_dma_desc
* @len: The total data size device wants to move
* @residue: The remaining data size device will move
* @dest: The destination address device wants to move to
* @src: The source address device wants to move from
*/
struct mtk_hsdma_vdesc {
struct virt_dma_desc vd;
size_t len;
size_t residue;
dma_addr_t dest;
dma_addr_t src;
};
/**
* struct mtk_hsdma_cb - This is the struct holding extra info required for RX
* ring to know what relevant VD the PD is being
* mapped to.
* @vd: Pointer to the relevant VD.
* @flag: Flag indicating what action should be taken when VD
* is completed.
*/
struct mtk_hsdma_cb {
struct virt_dma_desc *vd;
enum mtk_hsdma_vdesc_flag flag;
};
/**
* struct mtk_hsdma_ring - This struct holds info describing underlying ring
* space
* @txd: The descriptor TX ring which describes DMA source
* information
* @rxd: The descriptor RX ring which describes DMA
* destination information
* @cb: The extra information pointed at by RX ring
* @tphys: The physical addr of TX ring
* @rphys: The physical addr of RX ring
* @cur_tptr: Pointer to the next free descriptor used by the host
* @cur_rptr: Pointer to the last done descriptor by the device
*/
struct mtk_hsdma_ring {
struct mtk_hsdma_pdesc *txd;
struct mtk_hsdma_pdesc *rxd;
struct mtk_hsdma_cb *cb;
dma_addr_t tphys;
dma_addr_t rphys;
u16 cur_tptr;
u16 cur_rptr;
};
/**
* struct mtk_hsdma_pchan - This is the struct holding info describing physical
* channel (PC)
* @ring: An instance for the underlying ring
* @sz_ring: Total size allocated for the ring
* @nr_free: Total number of free rooms in the ring. It would
* be accessed and updated frequently between IRQ
* context and user context to reflect whether ring
* can accept requests from VD.
*/
struct mtk_hsdma_pchan {
struct mtk_hsdma_ring ring;
size_t sz_ring;
atomic_t nr_free;
};
/**
* struct mtk_hsdma_vchan - This is the struct holding info describing virtual
* channel (VC)
* @vc: An instance for struct virt_dma_chan
* @issue_completion: The wait for all issued descriptors completited
* @issue_synchronize: Bool indicating channel synchronization starts
* @desc_hw_processing: List those descriptors the hardware is processing,
* which is protected by vc.lock
*/
struct mtk_hsdma_vchan {
struct virt_dma_chan vc;
struct completion issue_completion;
bool issue_synchronize;
struct list_head desc_hw_processing;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/iopoll.h`, `linux/list.h`, `linux/module.h`.
- Detected declarations: `struct mtk_hsdma_pdesc`, `struct mtk_hsdma_vdesc`, `struct mtk_hsdma_cb`, `struct mtk_hsdma_ring`, `struct mtk_hsdma_pchan`, `struct mtk_hsdma_vchan`, `struct mtk_hsdma_soc`, `struct mtk_hsdma_device`, `enum mtk_hsdma_vdesc_flag`, `function mtk_dma_read`.
- 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.