drivers/dma/dmatest.c
Source file repositories/reference/linux-study-clean/drivers/dma/dmatest.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/dmatest.c- Extension
.c- Size
- 36499 bytes
- Lines
- 1377
- 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/err.hlinux/delay.hlinux/dma-mapping.hlinux/dmaengine.hlinux/freezer.hlinux/init.hlinux/kthread.hlinux/sched/task.hlinux/module.hlinux/moduleparam.hlinux/random.hlinux/slab.hlinux/wait.h
Detected Declarations
struct dmatest_paramsstruct dmatest_donestruct dmatest_datastruct dmatest_threadstruct dmatest_chanfunction is_threaded_test_runfunction list_for_each_entryfunction list_for_each_entryfunction is_threaded_test_pendingfunction list_for_each_entryfunction list_for_each_entryfunction dmatest_wait_getfunction dmatest_match_channelfunction dmatest_match_devicefunction dmatest_randomfunction gen_inv_idxfunction gen_src_valuefunction gen_dst_valuefunction dmatest_init_srcsfunction dmatest_init_dstsfunction dmatest_mismatchfunction dmatest_verifyfunction dmatest_callbackfunction min_oddfunction resultfunction dbg_resultfunction dmatest_persecfunction dmatest_KBsfunction __dmatest_free_test_datafunction dmatest_free_test_datafunction dmatest_alloc_test_datafunction kthread_stopfunction dmatest_cleanup_channelfunction list_for_each_entry_safefunction dmatest_add_threadsfunction dmatest_add_channelfunction filterfunction request_channelsfunction add_threaded_testfunction run_pending_testsfunction list_for_each_entryfunction list_for_each_entryfunction stop_threaded_testfunction list_for_each_entry_safefunction start_threaded_testsfunction dmatest_run_getfunction dmatest_run_setfunction dmatest_chan_set
Annotated Snippet
struct dmatest_params {
bool nobounce;
unsigned int buf_size;
char channel[20];
char device[32];
unsigned int threads_per_chan;
unsigned int max_channels;
unsigned int iterations;
unsigned int xor_sources;
unsigned int pq_sources;
int timeout;
bool noverify;
bool norandom;
int alignment;
unsigned int transfer_size;
bool polled;
};
/**
* struct dmatest_info - test information.
* @params: test parameters
* @channels: channels under test
* @nr_channels: number of channels under test
* @lock: access protection to the fields of this structure
* @did_init: module has been initialized completely
* @last_error: test has faced configuration issues
*/
static struct dmatest_info {
/* Test parameters */
struct dmatest_params params;
/* Internal state */
struct list_head channels;
unsigned int nr_channels;
int last_error;
struct mutex lock;
bool did_init;
} test_info = {
.channels = LIST_HEAD_INIT(test_info.channels),
.lock = __MUTEX_INITIALIZER(test_info.lock),
};
static int dmatest_run_set(const char *val, const struct kernel_param *kp);
static int dmatest_run_get(char *val, const struct kernel_param *kp);
static const struct kernel_param_ops run_ops = {
.set = dmatest_run_set,
.get = dmatest_run_get,
};
static bool dmatest_run;
module_param_cb(run, &run_ops, &dmatest_run, 0644);
MODULE_PARM_DESC(run, "Run the test (default: false)");
static int dmatest_chan_set(const char *val, const struct kernel_param *kp);
static int dmatest_chan_get(char *val, const struct kernel_param *kp);
static const struct kernel_param_ops multi_chan_ops = {
.set = dmatest_chan_set,
.get = dmatest_chan_get,
};
static char test_channel[20];
static struct kparam_string newchan_kps = {
.string = test_channel,
.maxlen = 20,
};
module_param_cb(channel, &multi_chan_ops, &newchan_kps, 0644);
MODULE_PARM_DESC(channel, "Bus ID of the channel to test (default: any)");
static int dmatest_test_list_get(char *val, const struct kernel_param *kp);
static const struct kernel_param_ops test_list_ops = {
.get = dmatest_test_list_get,
};
module_param_cb(test_list, &test_list_ops, NULL, 0444);
MODULE_PARM_DESC(test_list, "Print current test list");
/* Maximum amount of mismatched bytes in buffer to print */
#define MAX_ERROR_COUNT 32
/*
* Initialization patterns. All bytes in the source buffer has bit 7
* set, all bytes in the destination buffer has bit 7 cleared.
*
* Bit 6 is set for all bytes which are to be copied by the DMA
* engine. Bit 5 is set for all bytes which are to be overwritten by
* the DMA engine.
*
* The remaining bits are the inverse of a counter which increments by
* one for each byte address.
*/
#define PATTERN_SRC 0x80
#define PATTERN_DST 0x00
Annotation
- Immediate include surface: `linux/err.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/dmaengine.h`, `linux/freezer.h`, `linux/init.h`, `linux/kthread.h`, `linux/sched/task.h`.
- Detected declarations: `struct dmatest_params`, `struct dmatest_done`, `struct dmatest_data`, `struct dmatest_thread`, `struct dmatest_chan`, `function is_threaded_test_run`, `function list_for_each_entry`, `function list_for_each_entry`, `function is_threaded_test_pending`, `function list_for_each_entry`.
- 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.