drivers/dma/sh/rcar-dmac.c
Source file repositories/reference/linux-study-clean/drivers/dma/sh/rcar-dmac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/sh/rcar-dmac.c- Extension
.c- Size
- 56232 bytes
- Lines
- 2045
- 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/delay.hlinux/dma-mapping.hlinux/dmaengine.hlinux/interrupt.hlinux/list.hlinux/module.hlinux/mutex.hlinux/of.hlinux/of_dma.hlinux/of_platform.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hlinux/spinlock.h../dmaengine.h
Detected Declarations
struct rcar_dmac_xfer_chunkstruct rcar_dmac_hw_descstruct rcar_dmac_descstruct rcar_dmac_desc_pagestruct rcar_dmac_chan_slavestruct rcar_dmac_chan_mapstruct rcar_dmac_chanstruct rcar_dmacstruct rcar_dmac_of_datafunction rcar_dmac_writefunction rcar_dmac_readfunction rcar_dmac_chan_readfunction rcar_dmac_chan_writefunction rcar_dmac_chan_clearfunction rcar_dmac_chan_clear_allfunction rcar_dmac_chan_is_busyfunction rcar_dmac_chan_start_xferfunction rcar_dmac_initfunction rcar_dmac_tx_submitfunction rcar_dmac_desc_allocfunction rcar_dmac_desc_putfunction rcar_dmac_desc_recycle_ackedfunction list_for_each_entry_safefunction rcar_dmac_xfer_chunk_allocfunction rcar_dmac_xfer_chunk_getfunction rcar_dmac_realloc_hwdescfunction rcar_dmac_fill_hwdescfunction list_for_each_entryfunction rcar_dmac_chcr_de_barrierfunction rcar_dmac_clear_chcr_defunction rcar_dmac_chan_haltfunction rcar_dmac_chan_reinitfunction list_for_each_entry_safefunction rcar_dmac_stop_all_chanfunction rcar_dmac_chan_pausefunction rcar_dmac_chan_configure_descfunction publicfunction rcar_dmac_alloc_chan_resourcesfunction rcar_dmac_free_chan_resourcesfunction list_for_each_entry_safefunction rcar_dmac_prep_dma_memcpyfunction rcar_dmac_map_slave_addrfunction rcar_dmac_prep_slave_sgfunction rcar_dmac_prep_dma_cyclicfunction rcar_dmac_device_configfunction rcar_dmac_chan_terminate_allfunction rcar_dmac_chan_get_residuefunction rcar_dmac_isr_channel_thread
Annotated Snippet
struct rcar_dmac_xfer_chunk {
struct list_head node;
dma_addr_t src_addr;
dma_addr_t dst_addr;
u32 size;
};
/*
* struct rcar_dmac_hw_desc - Hardware descriptor for a transfer chunk
* @sar: value of the SAR register (source address)
* @dar: value of the DAR register (destination address)
* @tcr: value of the TCR register (transfer count)
*/
struct rcar_dmac_hw_desc {
u32 sar;
u32 dar;
u32 tcr;
u32 reserved;
} __attribute__((__packed__));
/*
* struct rcar_dmac_desc - R-Car Gen2 DMA Transfer Descriptor
* @async_tx: base DMA asynchronous transaction descriptor
* @direction: direction of the DMA transfer
* @xfer_shift: log2 of the transfer size
* @chcr: value of the channel configuration register for this transfer
* @node: entry in the channel's descriptors lists
* @chunks: list of transfer chunks for this transfer
* @running: the transfer chunk being currently processed
* @nchunks: number of transfer chunks for this transfer
* @hwdescs.use: whether the transfer descriptor uses hardware descriptors
* @hwdescs.mem: hardware descriptors memory for the transfer
* @hwdescs.dma: device address of the hardware descriptors memory
* @hwdescs.size: size of the hardware descriptors in bytes
* @size: transfer size in bytes
* @cyclic: when set indicates that the DMA transfer is cyclic
*/
struct rcar_dmac_desc {
struct dma_async_tx_descriptor async_tx;
enum dma_transfer_direction direction;
unsigned int xfer_shift;
u32 chcr;
struct list_head node;
struct list_head chunks;
struct rcar_dmac_xfer_chunk *running;
unsigned int nchunks;
struct {
bool use;
struct rcar_dmac_hw_desc *mem;
dma_addr_t dma;
size_t size;
} hwdescs;
unsigned int size;
bool cyclic;
};
#define to_rcar_dmac_desc(d) container_of(d, struct rcar_dmac_desc, async_tx)
/*
* struct rcar_dmac_desc_page - One page worth of descriptors
* @node: entry in the channel's pages list
* @descs: array of DMA descriptors
* @chunks: array of transfer chunk descriptors
*/
struct rcar_dmac_desc_page {
struct list_head node;
union {
DECLARE_FLEX_ARRAY(struct rcar_dmac_desc, descs);
DECLARE_FLEX_ARRAY(struct rcar_dmac_xfer_chunk, chunks);
};
};
#define RCAR_DMAC_DESCS_PER_PAGE \
((PAGE_SIZE - offsetof(struct rcar_dmac_desc_page, descs)) / \
sizeof(struct rcar_dmac_desc))
#define RCAR_DMAC_XFER_CHUNKS_PER_PAGE \
((PAGE_SIZE - offsetof(struct rcar_dmac_desc_page, chunks)) / \
sizeof(struct rcar_dmac_xfer_chunk))
/*
* struct rcar_dmac_chan_slave - Slave configuration
* @slave_addr: slave memory address
* @xfer_size: size (in bytes) of hardware transfers
*/
struct rcar_dmac_chan_slave {
Annotation
- Immediate include surface: `linux/delay.h`, `linux/dma-mapping.h`, `linux/dmaengine.h`, `linux/interrupt.h`, `linux/list.h`, `linux/module.h`, `linux/mutex.h`, `linux/of.h`.
- Detected declarations: `struct rcar_dmac_xfer_chunk`, `struct rcar_dmac_hw_desc`, `struct rcar_dmac_desc`, `struct rcar_dmac_desc_page`, `struct rcar_dmac_chan_slave`, `struct rcar_dmac_chan_map`, `struct rcar_dmac_chan`, `struct rcar_dmac`, `struct rcar_dmac_of_data`, `function rcar_dmac_write`.
- 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.