Skip to content

samples: drivers: dma: add dma_scatter_gather sample#628

Open
CijaSathish-AlifSemi wants to merge 1 commit intoalifsemi:mainfrom
CijaSathish-AlifSemi:feature/pl330-scatter-gather
Open

samples: drivers: dma: add dma_scatter_gather sample#628
CijaSathish-AlifSemi wants to merge 1 commit intoalifsemi:mainfrom
CijaSathish-AlifSemi:feature/pl330-scatter-gather

Conversation

@CijaSathish-AlifSemi
Copy link
Copy Markdown
Contributor

@CijaSathish-AlifSemi CijaSathish-AlifSemi commented Mar 26, 2026

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-dma snippet with board-specific overlays to provide a test-dma alias 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.

@CijaSathish-AlifSemi CijaSathish-AlifSemi force-pushed the feature/pl330-scatter-gather branch 2 times, most recently from 557a109 to 813991f Compare March 30, 2026 19:16
@CijaSathish-AlifSemi
Copy link
Copy Markdown
Contributor Author

@petrih-alifsemi addressed all the changes. Please check..thanks

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +242 to +247
/* Setup test data */
fill_buffer(src1, BLOCK1_SIZE, 0xA0);
fill_buffer(src2, BLOCK2_SIZE, 0xB0);
fill_buffer(src3, BLOCK3_SIZE, 0xC0);
clear_buffers();

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +152 to +164
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,
};

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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;

Copilot uses AI. Check for mistakes.
@petrih-alifsemi
Copy link
Copy Markdown
Contributor

Is this related to alifsemi/zephyr_alif#442?

@sudhir-alifsemi sudhir-alifsemi added the do not merge Work in progress label Apr 1, 2026
@sudhir-alifsemi
Copy link
Copy Markdown
Contributor

Is this related to alifsemi/zephyr_alif#442?

Yes

Copy link
Copy Markdown
Contributor

@petrih-alifsemi petrih-alifsemi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

West update is needed

@CijaSathish-AlifSemi
Copy link
Copy Markdown
Contributor Author

@petrih-alifsemi
Once the driver PR is merged, I'll update west.yml to the new main revision (and CI should pass)

Copy link
Copy Markdown
Contributor

@VeijoPesonen VeijoPesonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires manifest update. Otherwise looks good to me.

@CijaSathish-AlifSemi CijaSathish-AlifSemi force-pushed the feature/pl330-scatter-gather branch from bae7700 to 3fb9e7b Compare April 2, 2026 17:09
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>
@CijaSathish-AlifSemi CijaSathish-AlifSemi force-pushed the feature/pl330-scatter-gather branch from 3fb9e7b to be86c3f Compare April 2, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants