samples: drivers: dma: add dma_scatter_gather sample#628
samples: drivers: dma: add dma_scatter_gather sample#628CijaSathish-AlifSemi wants to merge 1 commit intoalifsemi:mainfrom
Conversation
samples/drivers/dma_scatter_gather/snippets/alif-dma/alif_b1_dk_rtss_he.overlay
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Adds a new Zephyr sample to exercise PL330 scatter-gather (block chaining) in a memory-to-memory DMA transfer on Alif platforms.
Changes:
- Introduces a DMA scatter-gather test application that chains 3 DMA blocks and verifies results.
- Adds an
alif-dmasnippet with board-specific overlays to provide atest-dmaalias and enable the chosen DMA instance. - Adds standard sample metadata/build files (CMake, prj.conf, README, sample.yaml).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| samples/drivers/dma_scatter_gather/src/main.c | Implements the scatter-gather DMA test logic, callback, and buffer verification. |
| samples/drivers/dma_scatter_gather/snippets/alif-dma/snippet.yml | Provides snippet configuration to apply the right overlay per Alif board/variant. |
| samples/drivers/dma_scatter_gather/snippets/alif-dma/*.overlay | Adds test-dma alias and enables the selected DMA controller instance. |
| samples/drivers/dma_scatter_gather/sample.yaml | Registers the sample as a Twister test. |
| samples/drivers/dma_scatter_gather/prj.conf | Enables DMA + PL330 and logging/console settings for the sample. |
| samples/drivers/dma_scatter_gather/README.rst | Documents purpose, build command, and expected output. |
| samples/drivers/dma_scatter_gather/CMakeLists.txt | Builds the sample app source. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
557a109 to
813991f
Compare
|
@petrih-alifsemi addressed all the changes. Please check..thanks |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /* Setup test data */ | ||
| fill_buffer(src1, BLOCK1_SIZE, 0xA0); | ||
| fill_buffer(src2, BLOCK2_SIZE, 0xB0); | ||
| fill_buffer(src3, BLOCK3_SIZE, 0xC0); | ||
| clear_buffers(); | ||
|
|
There was a problem hiding this comment.
On targets with data cache enabled, this sample can report mismatches because the DMA engine may read stale source data and the CPU may read stale destination data. Consider adding cache maintenance around the transfer (e.g., under CONFIG_DCACHE: flush/invalidate src buffers and the dma_block_config array before dma_start, and invalidate dst buffers after completion before memcmp), and include the appropriate cache header.
| struct dma_config dma_cfg = { | ||
| .channel_direction = MEMORY_TO_MEMORY, | ||
| .source_data_size = 4, | ||
| .dest_data_size = 4, | ||
| .source_burst_length = 1, | ||
| .dest_burst_length = 1, /* burst=1 keeps alignment simple for this test */ | ||
| .dma_slot = 0, | ||
| .block_count = 3, | ||
| .head_block = head_block, | ||
| .dma_callback = dma_callback, | ||
| .user_data = NULL, | ||
| }; | ||
|
|
There was a problem hiding this comment.
dma_cfg.block_count is hard-coded to 3; since the blocks are already in a fixed-size array in this sample, using ARRAY_SIZE(blocks) (or an equivalent constant derived from the array) would keep the configuration consistent if the number of blocks changes later.
| struct dma_config dma_cfg = { | |
| .channel_direction = MEMORY_TO_MEMORY, | |
| .source_data_size = 4, | |
| .dest_data_size = 4, | |
| .source_burst_length = 1, | |
| .dest_burst_length = 1, /* burst=1 keeps alignment simple for this test */ | |
| .dma_slot = 0, | |
| .block_count = 3, | |
| .head_block = head_block, | |
| .dma_callback = dma_callback, | |
| .user_data = NULL, | |
| }; | |
| struct dma_block_config *blk; | |
| uint32_t block_count = 0U; | |
| struct dma_config dma_cfg = { 0 }; | |
| /* Count the number of scatter-gather blocks starting from head_block */ | |
| for (blk = head_block; blk != NULL; blk = blk->next_block) { | |
| block_count++; | |
| } | |
| dma_cfg.channel_direction = MEMORY_TO_MEMORY; | |
| dma_cfg.source_data_size = 4; | |
| dma_cfg.dest_data_size = 4; | |
| dma_cfg.source_burst_length = 1; | |
| dma_cfg.dest_burst_length = 1; /* burst=1 keeps alignment simple for this test */ | |
| dma_cfg.dma_slot = 0; | |
| dma_cfg.block_count = block_count; | |
| dma_cfg.head_block = head_block; | |
| dma_cfg.dma_callback = dma_callback; | |
| dma_cfg.user_data = NULL; |
|
Is this related to alifsemi/zephyr_alif#442? |
Yes |
petrih-alifsemi
left a comment
There was a problem hiding this comment.
West update is needed
813991f to
263fcdd
Compare
263fcdd to
bae7700
Compare
|
@petrih-alifsemi |
VeijoPesonen
left a comment
There was a problem hiding this comment.
Requires manifest update. Otherwise looks good to me.
bae7700 to
3fb9e7b
Compare
Add memory-to-memory scatter-gather DMA test application for Alif Ensemble and Balletto devices. Tests block chaining support added to the PL330 DMA driver. Signed-off-by: Cija Sathishkumar <cija.sathishkumar@alifsemi.com>
3fb9e7b to
be86c3f
Compare
Add memory-to-memory scatter-gather DMA test application for Alif Ensemble and Balletto devices. Tests block chaining support added to the PL330 DMA driver.
Depends : alifsemi/zephyr_alif#442