drivers/dma/dw/core.c
Source file repositories/reference/linux-study-clean/drivers/dma/dw/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/dw/core.c- Extension
.c- Size
- 37039 bytes
- Lines
- 1407
- Domain
- Driver Families
- Bucket
- drivers/dma
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/delay.hlinux/dmaengine.hlinux/dma-mapping.hlinux/dmapool.hlinux/err.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/log2.hlinux/mm.hlinux/module.hlinux/slab.hlinux/pm_runtime.h../dmaengine.hinternal.h
Detected Declarations
function Copyrightfunction dwc_tx_submitfunction dwc_desc_putfunction list_for_each_entry_safefunction dwc_initializefunction dwc_dump_chan_regsfunction dwc_chan_disablefunction dwc_do_single_blockfunction dwc_dostartfunction dwc_dostart_first_queuedfunction dwc_descriptor_completefunction dwc_complete_allfunction dwc_get_sentfunction dwc_scan_descriptorsfunction list_for_each_entry_safefunction list_for_each_entryfunction dwc_dump_llifunction dwc_handle_errorfunction dw_dma_taskletfunction dw_dma_interruptfunction dwc_prep_dma_memcpyfunction dwc_prep_slave_sgfunction for_each_sgfunction for_each_sgfunction dw_dma_filterfunction dwc_verify_maxburstfunction dwc_verify_p_buswidthfunction dwc_verify_m_buswidthfunction dwc_configfunction dwc_chan_pausefunction dwc_pausefunction dwc_chan_resumefunction dwc_resumefunction dwc_terminate_allfunction dwc_get_residue_and_statusfunction dwc_tx_statusfunction dwc_issue_pendingfunction do_dw_dma_offfunction do_dw_dma_onfunction dwc_alloc_chan_resourcesfunction dwc_free_chan_resourcesfunction dwc_capsfunction do_dma_probefunction do_dma_removefunction list_for_each_entry_safefunction do_dw_dma_disablefunction do_dw_dma_enableexport dw_dma_filter
Annotated Snippet
if (was_soft_llp) {
dev_err(chan2dev(&dwc->chan),
"BUG: Attempted to start new LLP transfer inside ongoing one\n");
return;
}
dwc_initialize(dwc);
first->residue = first->total_len;
dwc->tx_node_active = &first->tx_list;
/* Submit first block */
dwc_do_single_block(dwc, first);
return;
}
dwc_initialize(dwc);
channel_writel(dwc, LLP, first->txd.phys | lms);
channel_writel(dwc, CTL_LO, DWC_CTLL_LLP_D_EN | DWC_CTLL_LLP_S_EN);
channel_writel(dwc, CTL_HI, 0);
channel_set_bit(dw, CH_EN, dwc->mask);
}
static void dwc_dostart_first_queued(struct dw_dma_chan *dwc)
{
struct dw_desc *desc;
if (list_empty(&dwc->queue))
return;
list_move(dwc->queue.next, &dwc->active_list);
desc = dwc_first_active(dwc);
dev_vdbg(chan2dev(&dwc->chan), "%s: started %u\n", __func__, desc->txd.cookie);
dwc_dostart(dwc, desc);
}
/*----------------------------------------------------------------------*/
static void
dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc,
bool callback_required)
{
struct dma_async_tx_descriptor *txd = &desc->txd;
struct dw_desc *child;
unsigned long flags;
struct dmaengine_desc_callback cb;
dev_vdbg(chan2dev(&dwc->chan), "descriptor %u complete\n", txd->cookie);
spin_lock_irqsave(&dwc->lock, flags);
dma_cookie_complete(txd);
if (callback_required)
dmaengine_desc_get_callback(txd, &cb);
else
memset(&cb, 0, sizeof(cb));
/* async_tx_ack */
list_for_each_entry(child, &desc->tx_list, desc_node)
async_tx_ack(&child->txd);
async_tx_ack(&desc->txd);
dwc_desc_put(dwc, desc);
spin_unlock_irqrestore(&dwc->lock, flags);
dmaengine_desc_callback_invoke(&cb, NULL);
}
static void dwc_complete_all(struct dw_dma *dw, struct dw_dma_chan *dwc)
{
struct dw_desc *desc, *_desc;
LIST_HEAD(list);
unsigned long flags;
spin_lock_irqsave(&dwc->lock, flags);
if (dma_readl(dw, CH_EN) & dwc->mask) {
dev_err(chan2dev(&dwc->chan),
"BUG: XFER bit set, but channel not idle!\n");
/* Try to continue after resetting the channel... */
dwc_chan_disable(dw, dwc);
}
/*
* Submit queued descriptors ASAP, i.e. before we go through
* the completed ones.
*/
list_splice_init(&dwc->active_list, &list);
dwc_dostart_first_queued(dwc);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/delay.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/dmapool.h`, `linux/err.h`, `linux/init.h`, `linux/interrupt.h`.
- Detected declarations: `function Copyright`, `function dwc_tx_submit`, `function dwc_desc_put`, `function list_for_each_entry_safe`, `function dwc_initialize`, `function dwc_dump_chan_regs`, `function dwc_chan_disable`, `function dwc_do_single_block`, `function dwc_dostart`, `function dwc_dostart_first_queued`.
- Atlas domain: Driver Families / drivers/dma.
- Implementation status: integration 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.