Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silabs siwx91x dma driver scatter gather feature and other fixes/improvements #87383

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

smalae
Copy link
Contributor

@smalae smalae commented Mar 20, 2025

  1. Corrected the burst length processing to be handled in bytes
    for the siwx917 DMA drivers.
  2. Removed overlay and configuration files associated with the
    chan_blen_transfer test application. The chan_blen_transfer
    test application attempted to use 8 and 16 byte bursts, which
    are not supported by the siwx91x UDMA.
  3. Refactored the driver code to ensure compatibility with the dma_context API.
  4. Added chan_filter API which allows the assignment of desired DMA channels.
  5. Updated the driver to ensure that each DMA channel can properly
    assign and handle individual callbacks.
  6. Enable scatter-gather transfer support

smalae added 2 commits March 20, 2025 11:15
1. Corrected the burst length processing to be handled in bytes
   for the siwx917 DMA drivers.
2. Removed overlay and configuration files associated with the
   chan_blen_transfer test application. The chan_blen_transfer
   test application attempted to use 8 and 16 byte bursts, which
   are not supported by the siwx91x UDMA.

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
Refactored the driver code to ensure compatibility with the
dma_context API, improving maintainability and consistency
with other DMA drivers in the Zephyr project.

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
ARG_UNUSED(dev);

if (filter_param != NULL) {
if ((int)*((int *)filter_param) == channel) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need to cast filter_param twice: return (*(int *)filter_param == channel);.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return false;
}
}
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the prototype declare a bool, prefer return false;.

BTW, you can handle exception first and remove a level of indentation:

	if (!filter_param) {
		return false;
	}
	[...]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

status = siwx91x_channel_config(dev, udma_handle, channel, config);
if (config->head_block->next_block != NULL) {
/* Configure DMA for a Scatter-Gather transfer */
status = siwx91x_sg_config(dev, udma_handle, channel, config);
Copy link
Contributor

Choose a reason for hiding this comment

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

We have to check somewhere if the caller set complete_callback_en and returns an error on this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handled the check

/* Configure DMA for a Scatter-Gather transfer */
status = siwx91x_sg_config(dev, udma_handle, channel, config);
} else {
status = siwx91x_channel_config(dev, udma_handle, channel, config);
Copy link
Contributor

Choose a reason for hiding this comment

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

siwx91x_channel_config() and siwx91x_sg_config() are "sibling" functions. I would try reflect this link in their names. eg. siwx91x_direct_chan_config()/siwx91x_sg_chan_config(), siwx91x_chan_cfg_contiguous()/siwx91x_chan_cfg_sg(), ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the names accordingly

@@ -33,6 +36,7 @@ enum {
struct dma_siwx91x_channel_info {
dma_callback_t dma_callback; /* User callback */
void *cb_data; /* User callback data */
uint32_t sg_desc_addr_info; /* Scatter-Gather table start address */
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe sg_desc_addr_info should be a RSI_UDMA_DESC_T *.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Updated the type.

@smalae smalae force-pushed the silabs_siwx91x_dma_driver_SG_feature_and_fixes branch from 2c25fc7 to 1646510 Compare March 20, 2025 09:48
smalae added 3 commits March 20, 2025 15:24
This new API allows the assignment of desired DMA channels for
peripheral transfers, enhancing flexibility and control over DMA
operations.

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
Updated the driver to ensure that each DMA channel can properly
assign and handle individual callbacks.

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
Implement support for scatter-gather DMA transfers in the siwx917 driver.
This enhancement allows the driver to handle multiple non-contiguous memory
buffers in a single DMA transaction

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
@smalae smalae force-pushed the silabs_siwx91x_dma_driver_SG_feature_and_fixes branch from 1646510 to 7fd8b45 Compare March 20, 2025 09:54
@jerome-pouiller
Copy link
Contributor

@nordicjm, I believe your comment has been fixed.

Copy link
Collaborator

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

Kconfig part OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: DMA Direct Memory Access platform: Silabs Silicon Labs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants