-
Notifications
You must be signed in to change notification settings - Fork 7.6k
disk: sdmmc: support L4 series with shared DMA channel #91491
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
base: main
Are you sure you want to change the base?
Conversation
24e216c
to
7c577e5
Compare
Code has been tested on a custom STM32L451RE design, successfully writing, reading-back and erasing a random block, returning to low power idle when done. |
tests/drivers/disk/disk_access/boards/stm32l496g_disco_stm32l496xx.overlay
Outdated
Show resolved
Hide resolved
c2f92fe
to
a0e4540
Compare
@etienne-lms can you revisit? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main issue (IIUC) is all occurrences of #ifdef STM32_SDMMC_USE_DMA_SHARED
to replace with #if STM32_SDMMC_USE_DMA_SHARED
in drivers/disk/sdmmc_stm32.c.
(edited: sorry for this late feedback)
struct sdmmc_dma_stream *dma_tx = &priv->dma_tx; | ||
struct sdmmc_dma_stream *dma_rx = &priv->dma_rx; | ||
|
||
ret = dma_stop(dma_tx->dev, dma_tx->channel); | ||
__ASSERT(ret == 0, "TX DMA channel index corrupted"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless asserting the return value in debug build mode is always sufficient, i think it would be worth:
int ret = 0;
(...)
if (dma_stop(dma_tx->dev, dma_tx->channel) != 0) {
LOG_ERR("Failed to stop tx DMA transmission");
ret = -EIO;
}
HAL_DMA_DeInit(&priv->dma_tx_handle);
if (dma_stop(dma_xx->dev, dma_rx->channel) != 0) {
LOG_ERR("Failed to stop rx DMA transmission");
ret = -EIO;
}
HAL_DMA_DeInit(&priv->dma_rx_handle);
#endif
return ret;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an assertion because there is no code path that results in an error through that function unless RAM is corrupted.
if (id >= config->max_streams) {
return -EINVAL;
}
if (stream->hal_override) {
stream->busy = false;
return 0;
}
If ID is invalid in the normal case the setup functions will already error out with log messages.
If we're trying to protect against RAM corruption, there are many other problems...
Update the driver to support DMA operations on L4 series devices, with a shared DMA channel. Split channels do not work on these chips, since there is no dedicated TX and RX channels on the DMA, so configuring two channels with SDMMC as the peripheral results in a non-functional configuration. Fixes zephyrproject-rtos#91216. Signed-off-by: Jordan Yates <jordan@embeint.com>
Ensure that the shared DMA variant of the STM SDMMC driver is compiled in CI. Signed-off-by: Jordan Yates <jordan@embeint.com>
a0e4540
to
52f5de4
Compare
|
Update the driver to support DMA operations on L4 series devices, with
a shared DMA channel. Split channels do not work on these chips, since
there is no dedicated TX and RX channels on the DMA, so configuring two
channels with SDMMC as the peripheral results in a non-functional
configuration.
Fixes #91216.