drivers/dma/mv_xor_v2.c
Source file repositories/reference/linux-study-clean/drivers/dma/mv_xor_v2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/mv_xor_v2.c- Extension
.c- Size
- 25867 bytes
- Lines
- 897
- 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/clk.hlinux/dma-mapping.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/msi.hlinux/of.hlinux/of_irq.hlinux/platform_device.hlinux/spinlock.hdmaengine.h
Detected Declarations
struct mv_xor_v2_descriptorstruct mv_xor_v2_devicestruct mv_xor_v2_sw_descfunction mv_xor_v2_set_data_buffersfunction mv_xor_v2_add_desc_to_desqfunction mv_xor_v2_free_desc_from_desqfunction mv_xor_v2_set_desc_sizefunction mv_xor_v2_enable_imsg_thrdfunction mv_xor_v2_interrupt_handlerfunction mv_xor_v2_tx_submitfunction mv_xor_v2_prep_sw_descfunction list_for_each_entryfunction mv_xor_v2_prep_dma_memcpyfunction mv_xor_v2_prep_dma_xorfunction mv_xor_v2_prep_dma_interruptfunction mv_xor_v2_issue_pendingfunction mv_xor_v2_get_pending_paramsfunction mv_xor_v2_taskletfunction mv_xor_v2_set_msi_msgfunction mv_xor_v2_descq_initfunction mv_xor_v2_suspendfunction mv_xor_v2_resumefunction mv_xor_v2_probefunction mv_xor_v2_remove
Annotated Snippet
struct mv_xor_v2_descriptor {
u16 desc_id;
u16 flags;
u32 crc32_result;
u32 desc_ctrl;
/* Definitions for desc_ctrl */
#define DESC_NUM_ACTIVE_D_BUF_SHIFT 22
#define DESC_OP_MODE_SHIFT 28
#define DESC_OP_MODE_NOP 0 /* Idle operation */
#define DESC_OP_MODE_MEMCPY 1 /* Pure-DMA operation */
#define DESC_OP_MODE_MEMSET 2 /* Mem-Fill operation */
#define DESC_OP_MODE_MEMINIT 3 /* Mem-Init operation */
#define DESC_OP_MODE_MEM_COMPARE 4 /* Mem-Compare operation */
#define DESC_OP_MODE_CRC32 5 /* CRC32 calculation */
#define DESC_OP_MODE_XOR 6 /* RAID5 (XOR) operation */
#define DESC_OP_MODE_RAID6 7 /* RAID6 P&Q-generation */
#define DESC_OP_MODE_RAID6_REC 8 /* RAID6 Recovery */
#define DESC_Q_BUFFER_ENABLE BIT(16)
#define DESC_P_BUFFER_ENABLE BIT(17)
#define DESC_IOD BIT(27)
u32 buff_size;
u32 fill_pattern_src_addr[4];
u32 data_buff_addr[MV_XOR_V2_DESC_BUFF_D_ADDR_SIZE];
u32 reserved[MV_XOR_V2_DESC_RESERVED_SIZE];
};
/**
* struct mv_xor_v2_device - implements a xor device
* @lock: lock for the engine
* @clk: reference to the 'core' clock
* @reg_clk: reference to the 'reg' clock
* @dma_base: memory mapped DMA register base
* @glob_base: memory mapped global register base
* @irq_tasklet: tasklet used for IRQ handling call-backs
* @free_sw_desc: linked list of free SW descriptors
* @dmadev: dma device
* @dmachan: dma channel
* @hw_desq: HW descriptors queue
* @hw_desq_virt: virtual address of DESCQ
* @sw_desq: SW descriptors queue
* @desc_size: HW descriptor size
* @npendings: number of pending descriptors (for which tx_submit has
* @hw_queue_idx: HW queue index
* @irq: The Linux interrupt number
* been called, but not yet issue_pending)
*/
struct mv_xor_v2_device {
spinlock_t lock;
void __iomem *dma_base;
void __iomem *glob_base;
struct clk *clk;
struct clk *reg_clk;
struct tasklet_struct irq_tasklet;
struct list_head free_sw_desc;
struct dma_device dmadev;
struct dma_chan dmachan;
dma_addr_t hw_desq;
struct mv_xor_v2_descriptor *hw_desq_virt;
struct mv_xor_v2_sw_desc *sw_desq;
int desc_size;
unsigned int npendings;
unsigned int hw_queue_idx;
unsigned int irq;
};
/**
* struct mv_xor_v2_sw_desc - implements a xor SW descriptor
* @idx: descriptor index
* @async_tx: support for the async_tx api
* @hw_desc: associated HW descriptor
* @free_list: node of the free SW descriprots list
*/
struct mv_xor_v2_sw_desc {
int idx;
struct dma_async_tx_descriptor async_tx;
struct mv_xor_v2_descriptor hw_desc;
struct list_head free_list;
};
/*
* Fill the data buffers to a HW descriptor
*/
static void mv_xor_v2_set_data_buffers(struct mv_xor_v2_device *xor_dev,
struct mv_xor_v2_descriptor *desc,
dma_addr_t src, int index)
{
int arr_index = ((index >> 1) * 3);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/msi.h`, `linux/of.h`, `linux/of_irq.h`.
- Detected declarations: `struct mv_xor_v2_descriptor`, `struct mv_xor_v2_device`, `struct mv_xor_v2_sw_desc`, `function mv_xor_v2_set_data_buffers`, `function mv_xor_v2_add_desc_to_desq`, `function mv_xor_v2_free_desc_from_desq`, `function mv_xor_v2_set_desc_size`, `function mv_xor_v2_enable_imsg_thrd`, `function mv_xor_v2_interrupt_handler`, `function mv_xor_v2_tx_submit`.
- 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.