drivers/dma/mv_xor.c
Source file repositories/reference/linux-study-clean/drivers/dma/mv_xor.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/mv_xor.c- Extension
.c- Size
- 38256 bytes
- Lines
- 1480
- 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/init.hlinux/slab.hlinux/delay.hlinux/dma-mapping.hlinux/spinlock.hlinux/interrupt.hlinux/platform_device.hlinux/property.hlinux/memory.hlinux/clk.hlinux/of.hlinux/of_irq.hlinux/irqdomain.hlinux/cpumask.hlinux/platform_data/dma-mv_xor.hdmaengine.hmv_xor.h
Detected Declarations
enum mv_xor_typeenum mv_xor_modefunction mv_desc_initfunction mv_desc_set_modefunction mv_desc_set_next_descfunction mv_desc_set_src_addrfunction mv_chan_get_current_descfunction mv_chan_set_next_descriptorfunction mv_chan_unmask_interruptsfunction mv_chan_get_intr_causefunction mv_chan_clear_eoc_causefunction mv_chan_clear_err_statusfunction mv_chan_set_modefunction mv_chan_activatefunction mv_chan_is_busyfunction mv_chan_start_new_chainfunction mv_desc_run_tx_complete_actionsfunction mv_chan_clean_completed_slotsfunction mv_desc_clean_slotfunction mv_chan_slot_cleanupfunction list_for_each_entry_safefunction mv_xor_taskletfunction mv_chan_alloc_slotfunction mv_xor_tx_submitfunction mv_xor_alloc_chan_resourcesfunction mv_xor_add_io_winfunction mv_xor_prep_dma_xorfunction mv_xor_prep_dma_memcpyfunction mv_xor_prep_dma_interruptfunction mv_xor_free_chan_resourcesfunction list_for_each_entry_safefunction mv_xor_statusfunction mv_chan_dump_regsfunction mv_chan_err_interrupt_handlerfunction mv_xor_interrupt_handlerfunction mv_xor_issue_pendingfunction mv_chan_memcpy_self_testfunction mv_chan_xor_self_testfunction mv_xor_channel_removefunction list_for_each_entry_safefunction mv_xor_channel_addfunction mv_xor_conf_mbus_windowsfunction mv_xor_conf_mbus_windows_a3700function mv_xor_suspendfunction mv_xor_resumefunction mv_xor_probefunction for_each_child_of_node_scoped
Annotated Snippet
if (async_tx_test_ack(&iter->async_tx)) {
list_move_tail(&iter->node, &mv_chan->free_slots);
if (!list_empty(&iter->sg_tx_list)) {
list_splice_tail_init(&iter->sg_tx_list,
&mv_chan->free_slots);
}
}
}
return 0;
}
static int
mv_desc_clean_slot(struct mv_xor_desc_slot *desc,
struct mv_xor_chan *mv_chan)
{
dev_dbg(mv_chan_to_devp(mv_chan), "%s %d: desc %p flags %d\n",
__func__, __LINE__, desc, desc->async_tx.flags);
/* the client is allowed to attach dependent operations
* until 'ack' is set
*/
if (!async_tx_test_ack(&desc->async_tx)) {
/* move this slot to the completed_slots */
list_move_tail(&desc->node, &mv_chan->completed_slots);
if (!list_empty(&desc->sg_tx_list)) {
list_splice_tail_init(&desc->sg_tx_list,
&mv_chan->completed_slots);
}
} else {
list_move_tail(&desc->node, &mv_chan->free_slots);
if (!list_empty(&desc->sg_tx_list)) {
list_splice_tail_init(&desc->sg_tx_list,
&mv_chan->free_slots);
}
}
return 0;
}
/* This function must be called with the mv_xor_chan spinlock held */
static void mv_chan_slot_cleanup(struct mv_xor_chan *mv_chan)
{
struct mv_xor_desc_slot *iter, *_iter;
dma_cookie_t cookie = 0;
int busy = mv_chan_is_busy(mv_chan);
u32 current_desc = mv_chan_get_current_desc(mv_chan);
int current_cleaned = 0;
struct mv_xor_desc *hw_desc;
dev_dbg(mv_chan_to_devp(mv_chan), "%s %d\n", __func__, __LINE__);
dev_dbg(mv_chan_to_devp(mv_chan), "current_desc %x\n", current_desc);
mv_chan_clean_completed_slots(mv_chan);
/* free completed slots from the chain starting with
* the oldest descriptor
*/
list_for_each_entry_safe(iter, _iter, &mv_chan->chain,
node) {
/* clean finished descriptors */
hw_desc = iter->hw_desc;
if (hw_desc->status & XOR_DESC_SUCCESS) {
cookie = mv_desc_run_tx_complete_actions(iter, mv_chan,
cookie);
/* done processing desc, clean slot */
mv_desc_clean_slot(iter, mv_chan);
/* break if we did cleaned the current */
if (iter->async_tx.phys == current_desc) {
current_cleaned = 1;
break;
}
} else {
if (iter->async_tx.phys == current_desc) {
current_cleaned = 0;
break;
}
}
}
if ((busy == 0) && !list_empty(&mv_chan->chain)) {
if (current_cleaned) {
/*
* current descriptor cleaned and removed, run
* from list head
*/
iter = list_entry(mv_chan->chain.next,
struct mv_xor_desc_slot,
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/spinlock.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/property.h`.
- Detected declarations: `enum mv_xor_type`, `enum mv_xor_mode`, `function mv_desc_init`, `function mv_desc_set_mode`, `function mv_desc_set_next_desc`, `function mv_desc_set_src_addr`, `function mv_chan_get_current_desc`, `function mv_chan_set_next_descriptor`, `function mv_chan_unmask_interrupts`, `function mv_chan_get_intr_cause`.
- 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.