Skip to content

drivers: spi: stm32 spi driver supporting DMA in asynchronous mode #55302

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

Closed
wants to merge 2 commits into from

Conversation

FRASTM
Copy link
Collaborator

@FRASTM FRASTM commented Mar 1, 2023

add the support of the SPI asynchronous mode to the sm32 spi driver with DMA enabled or not
Enable this async mode when running the tests/drivers/spi/spi_loopback
and add the dma for spi transfer with overlay-stm32-spi-dma.conf
This is now the case hen the CONFIG_SPI_STM32_DMA is selected,

The SPI transfer is possible in ASYNC mode is possible CONFIG_SPI_ASYNC=y or not (CONFIG_SPI_ASYNC=n)
--> adding one more config to the tests/drivers/spi/spi_loopback for stm32 serie.

Add the b_l4s5i_iot01a disco kit to the list of supported boards

Fixes #55205

Signed-off-by: Francois Ramu [email protected]

@FRASTM FRASTM added area: SPI SPI bus platform: STM32 ST Micro STM32 labels Mar 1, 2023
@FRASTM
Copy link
Collaborator Author

FRASTM commented Mar 1, 2023

$ west build -p always -b b_l4s5i_iot01a -- -DOVERLAY_CONFIG="overlay-stm32-spi-dma.conf" tests/drivers/spi/spi_loopback/
--> RUN the the spi_async_call

*** Booting Zephyr OS build zephyr-v3.3.0-594-gaa6ae0d8af06 ***
Running TESTSUITE spi_loopback
===================================================================
START - test_spi_loopback
I: SPI test on buffers TX/RX 0x20000315/0x20000ab2
I: SPI test slow config
I: Start complete multiple
I: Passed
I: Start complete loop
I: Passed
I: Start null tx
I: Passed
I: Start half start
I: Passed
I: Skip half end
I: Skip every 4
I: Start async call
I: Passed
I: SPI test fast config
I: Start complete multiple
I: Passed
I: Start complete loop
I: Passed
I: Start null tx
I: Passed
I: Start half start
I: Passed
I: Skip half end
I: Skip every 4
I: Start async call
I: Passed
I: Start complete loop
I: Passed
I: Start complete loop
I: Passed
I: All tx/rx passed
 PASS - test_spi_loopback in 0.056 seconds
===================================================================
TESTSUITE spi_loopback succeeded

@FRASTM FRASTM force-pushed the spi_async_dma branch 2 times, most recently from 1e3db2b to ca86044 Compare March 2, 2023 10:57
@FRASTM FRASTM changed the title spi: stm32 support for asynchronous transfer using DMA spi: stm32 support for asynchronous transfer also when using DMA Mar 6, 2023
@FRASTM FRASTM marked this pull request as ready for review March 6, 2023 11:00
@FRASTM FRASTM requested a review from tbursztyka as a code owner March 6, 2023 11:00
@FRASTM FRASTM requested a review from erwango March 8, 2023 14:22
@niedzwiecki-dawid niedzwiecki-dawid self-requested a review March 22, 2023 08:04

if ((data->dma_tx.dma_dev != NULL)
&& (data->dma_rx.dma_dev != NULL)) {
return transceive_dma(dev, config, tx_bufs, rx_bufs,
Copy link
Member

Choose a reason for hiding this comment

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

The transceive_dma function calls wait_dma_rx_tx_done, so it waits for transfer to end, so it is not an asynchronous mode. It looks like, it is a synchronous mode with calling the callback at the end of transfer.

Copy link
Collaborator Author

@FRASTM FRASTM Mar 30, 2023

Choose a reason for hiding this comment

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

Ok, I am Changing the transceive_dma when the ASYNC mode is activated: behaves like the transceive() does.

@FRASTM FRASTM changed the title spi: stm32 support for asynchronous transfer also when using DMA drivers: spi: stm32 spi driver supporting DMA in asynchronous mode Mar 29, 2023
@FRASTM FRASTM force-pushed the spi_async_dma branch 4 times, most recently from 3145dfd to a39c45a Compare March 30, 2023 12:28
@FRASTM
Copy link
Collaborator Author

FRASTM commented Mar 30, 2023

rebase
and Using the extra_configs in the testcase.yaml to run on the stm32 boards (instead of .conf files)

@@ -747,6 +741,18 @@ static int transceive_dma(const struct device *dev,
/* This is turned off in spi_stm32_complete(). */
spi_stm32_cs_control(dev, true);

#if defined(CONFIG_SPI_STM32_INTERRUPT) || defined(CONFIG_SPI_ASYNC)
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to change behavior in config Interrup + DMA (SPI_ASYNC = n) ?
Isn't it sufficient to do defined(CONFIG_SPI_ASYNC) here ?

Copy link
Member

Choose a reason for hiding this comment

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

Do you use DMA in this case? It looks like transceive function in async mode without DMA.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you use DMA in this case? It looks like transceive function in async mode without DMA.

yes, if CONFIG_SPI_STM32_DMA=y

@@ -747,6 +741,18 @@ static int transceive_dma(const struct device *dev,
/* This is turned off in spi_stm32_complete(). */
spi_stm32_cs_control(dev, true);

#if defined(CONFIG_SPI_STM32_INTERRUPT) || defined(CONFIG_SPI_ASYNC)
Copy link
Member

Choose a reason for hiding this comment

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

Do you use DMA in this case? It looks like transceive function in async mode without DMA.

@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label May 31, 2023
@github-actions github-actions bot closed this Jun 14, 2023
@rmaciasdev
Copy link

@FRASTM Is there any further plan to merge these changes?

Acts the SPI asynchronous mode on the stm32 devices,
when DMA is activated or not for SPI transfer.

Signed-off-by: Francois Ramu <[email protected]>
@FRASTM FRASTM reopened this Jul 18, 2023
@zephyrbot zephyrbot requested a review from Desvauxm-st July 18, 2023 10:43
Add the overlay and config to run the spi loopback test
transfer with DMA and also in async mode with DMA
on any stm32 platform.
New target disco_l475_iot1

Signed-off-by: Francois Ramu <[email protected]>
@FRASTM
Copy link
Collaborator Author

FRASTM commented Jul 18, 2023

reopen and rebase

@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Sep 18, 2023
@github-actions github-actions bot closed this Oct 2, 2023
@Benni77
Copy link
Contributor

Benni77 commented Apr 3, 2024

Any news on this?

@ajarmouni-st
Copy link
Collaborator

Any news on this?

Hi @Benni77 check out #73855, although it is not ready yet to be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spi: stm32 support for asynchronous transfer using DMA
7 participants