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

RTIO: Add SPI default submit handler #77141

Merged

Conversation

ubieda
Copy link
Member

@ubieda ubieda commented Aug 16, 2024

Description

This PR adds a default implementation for the RTIO SPI iodev_submit, in which SPI transfers are executed.
This unlocks users to develop applications using RTIO-based APIs for SPI bus transfers by enabling suppor to drivers that do not yet have RTIO support.

Changes

  • Add default SPI RTIO implementation.
  • Add handler to all drivers that do not yet support RTIO natively.

Testing

Successfully Test SPI Loopback with targets using the default fallback implementation (with and without SPI RTIO enabled).

  • Nordic's nRF52840DK
west build -b nrf52840dk/nrf52840 tests/drivers/spi/spi_loopback -- -DCONFIG_SPI_RTIO=y
  • STMicro's Nucleo G0B1RE:
west build -b nucleo_g0b1re tests/drivers/spi/spi_loopback -- -DCONFIG_SPI_RTIO=y
  • ADI's MAX32655 Feather:
west build -b max32655fthr/max32655/m4 tests/drivers/spi/spi_loopback -- -DCONFIG_SPI_RTIO=y

Console output

*** Booting Zephyr OS build v3.7.0-1160-gd0�*** Booting Zephyr OS build v3.7.0-1160-gd0c1f9d62e47 ***
Running TESTSUITE spi_loopback
===================================================================
START - test_spi_loopback
I: SPI test on buffers TX/RX 0x20014300/0x200142e0, frame size = 8
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: Start half end
I: Passed
I: Start every 4
I: Passed
I: Start rx bigger than tx
I: Passed
I: Start complete large transfers
I: Passed
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: Start half end
I: Passed
I: Start every 4
I: Passed
I: Start rx bigger than tx
I: Passed
I: Start complete large transfers
I: Passed
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 1.345 seconds
===================================================================
TESTSUITE spi_loopback succeeded
Running TESTSUITE spi_loopback_rtio
===================================================================
START - test_spi_loopback_rtio
I: SPI test on buffers TX/RX 0x20010159/0x20015112
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: Start half end
I: Passed
I: Start every 4
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: Start half end
I: Passed
I: Start every 4
I: Passed
I: All tx/rx passed
 PASS - test_spi_loopback_rtio in 0.045 seconds
===================================================================
TESTSUITE spi_loopback_rtio succeeded

------ TESTSUITE SUMMARY START ------

SUITE PASS - 100.00% [spi_loopback]: pass = 1, fail = 0, skip = 0, total = 1 duration = 1.345 seconds
 - PASS - [spi_loopback.test_spi_loopback] duration = 1.345 seconds

SUITE PASS - 100.00% [spi_loopback_rtio]: pass = 1, fail = 0, skip = 0, total = 1 duration = 0.045 seconds
 - PASS - [spi_loopback_rtio.test_spi_loopback_rtio] duration = 0.045 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL

@ubieda ubieda changed the title spi: rtio: Add default/fallback implementation for iodev_submit spi: rtio: Add default handler for iodev_submit Aug 16, 2024
@ubieda ubieda changed the title spi: rtio: Add default handler for iodev_submit RTIO: Add SPI default submit handler Aug 16, 2024
@ubieda ubieda marked this pull request as ready for review August 16, 2024 06:27
drivers/spi/CMakeLists.txt Outdated Show resolved Hide resolved
include/zephyr/drivers/spi.h Outdated Show resolved Hide resolved
drivers/spi/spi_rtio_default.c Outdated Show resolved Hide resolved
@ubieda ubieda force-pushed the ubieda/spi-rtio-default-fallback branch from d0c1f9d to 8231133 Compare August 16, 2024 19:19
@ubieda ubieda requested a review from tbursztyka August 16, 2024 19:21
@RichardSWheatley RichardSWheatley requested review from AlessandroLuo and removed request for ChiHuaL August 19, 2024 15:12
@MaureenHelm MaureenHelm requested review from MaureenHelm and removed request for andy-liu-telink August 26, 2024 14:08
To allow being preempted by RTIO Workqueue in the SPI RTIO default
iodev_submit.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
To emulate SPI RTIO behavior for drivers that do not have native
support yet.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
So that all SPI drivers are compatible with RTIO APIs.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
@ubieda ubieda force-pushed the ubieda/spi-rtio-default-fallback branch from 8231133 to 461d967 Compare August 26, 2024 22:17
@ubieda
Copy link
Member Author

ubieda commented Aug 26, 2024

I've rebased to resolve conflicts. All change-reqs should be addressed now.

@tbursztyka @teburd can you take a look?

Copy link
Collaborator

@sylvioalves sylvioalves left a comment

Choose a reason for hiding this comment

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

Working properly on esp32-s3.

@ubieda
Copy link
Member Author

ubieda commented Sep 4, 2024

@tbursztyka could you take another look at this PR?

Copy link
Collaborator

@tbursztyka tbursztyka left a comment

Choose a reason for hiding this comment

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

yes, lgtm

@mmahadevan108 mmahadevan108 merged commit 64a038a into zephyrproject-rtos:main Sep 5, 2024
23 checks passed
@ubieda ubieda deleted the ubieda/spi-rtio-default-fallback branch September 5, 2024 16:45
@ubieda ubieda mentioned this pull request Sep 5, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants