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: Asynchronous Real-Time I/O #44999

Merged
merged 4 commits into from
Jun 28, 2022
Merged

Conversation

teburd
Copy link
Collaborator

@teburd teburd commented Apr 20, 2022

Enabling the usage of asynchronous I/O with interrupt or DMA driven transfers across multiple devices with an io_uring like API.

The docs are the most helpful starting place
https://github.com/teburd/zephyr/blob/rtio_next/doc/services/rtio/index.rst

Enhancements moved to Issue #46658

This is an experimental API and subsystem and it is useful now but will require improvements and refinements to cover the expected use cases.

@teburd teburd added area: DMA Direct Memory Access RFC Request For Comments: want input from the community labels Apr 20, 2022
@github-actions github-actions bot added area: API Changes to public APIs area: Documentation area: Tests Issues related to a particular existing or missing test labels Apr 20, 2022
@teburd teburd changed the title Asynchronous Real-time I/O RTIO: Asynchronous Real-Time I/O Apr 20, 2022
@teburd teburd changed the title RTIO: Asynchronous Real-Time I/O RFC: RTIO, Asynchronous Real-Time I/O Apr 20, 2022
@teburd teburd changed the title RFC: RTIO, Asynchronous Real-Time I/O rtio: Asynchronous Real-Time I/O Apr 20, 2022
@teburd teburd force-pushed the rtio_next branch 3 times, most recently from ecf6a3d to 266e543 Compare April 21, 2022 03:33
@teburd teburd force-pushed the rtio_next branch 2 times, most recently from 00d44ac to 60ef0be Compare April 21, 2022 18:05
@teburd teburd requested a review from gmarull April 21, 2022 22:45
@teburd teburd force-pushed the rtio_next branch 3 times, most recently from 86a44d5 to 3f9243b Compare April 26, 2022 00:03
@zephyrbot zephyrbot requested a review from utzig June 17, 2022 15:36
@teburd teburd removed the RFC Request For Comments: want input from the community label Jun 17, 2022
@teburd teburd added this to the v3.2.0 milestone Jun 17, 2022
@teburd teburd removed area: Kernel area: DMA Direct Memory Access labels Jun 17, 2022
nashif
nashif previously approved these changes Jun 23, 2022
nashif
nashif previously approved these changes Jun 23, 2022
@teburd teburd dismissed mbolivar-nordic’s stale review June 23, 2022 20:12

Requested change fixed

@teburd teburd force-pushed the rtio_next branch 2 times, most recently from 9ef9122 to 91a63c1 Compare June 24, 2022 13:42
teburd added 2 commits June 24, 2022 08:45
A DMA friendly Stream API for zephyr. Based on ideas from io_uring
and iio, a queue based API for I/O operations.

Provides a pair of fixed length ringbuffer backed queues for submitting
I/O requests and recieving I/O completions. The requests may be chained
together to ensure the next operation does not start until the current
one is complete.

Requests target an abstract rtio_iodev which is expected to wrap all
the hardware particulars of how to perform the operation. For example
with a SPI bus device, a description of what a read, and write mean
can be decided by the iodev wrapping a particular device
hanging off of a SPI controller.

The queue pair are submitted to an executor which may be a simple
inplace looping executor done in the callers execution context
(thread/stack) but other executors are expected. A threadpool executor
might for example allow for concurrent request chains to execute in
parallel. A DMA executor, in conjunction with DMA aware iodevs
would allow for hardware offloading of operations going so far as to
schedule with priority using hardware arbitration.

Both the iodev and executor are definable by a particular
SoC, meaning they can work in conjuction to perform IO operations
using a particular DMA controller or methodology if desired.

The application decides entirely how large the queues are, where
the buffers to read/write come from (some executors
may have particular demands!), and which executor to submit
requests to.

Signed-off-by: Tom Burdick <[email protected]>
Schedules I/O chains in the same order as they arrive providing a fixed
amount of concurrency. The low memory cost comes at the cost of some
computational cost that is likely to be acceptable with small amounts
of concurrency.

The code cost is about 4x higher than the simple linear executor
which isn't entirely unexpected as the logic requirements are quite a bit
more than doing the next thing in the queue.

Signed-off-by: Tom Burdick <[email protected]>
MaureenHelm and others added 2 commits June 24, 2022 11:58
Adds a new sample application that demonstrates using the RTIO subsystem
to read periodic sensor data directly into buffers allocated by the
application, asynchronously process batches of data with an algorithm,
and recycle buffers back for reading additional sensor data.

The sensor iodev in this application is an timer-driven device that
executes one read request per timer period. It doesn't actually send any
transactions to a real I2C/SPI bus or read any real data into the
application-provided buffers. This timer-driven behavior mimics how a
real sensor periodically triggers a GPIO interrupt when new data is
ready.

The sensor iodev currently uses an internal message queue to store
pending requests from the time they are submitted until the next timer
expiration. At least one pending request needs to be stored by the iodev
to ensure that it has a buffer available to read data into. However,
any more than that should probably be handled by the application, since
it's the application that determines how often it can submit new
requests and therefore how deep the queue needs to be.

The sensor iodev is implemented to support multiple instances with
devicetree, but additional work remains to enable and use more than one
in the application.

Tested on native_posix and frdm_k64f.

Signed-off-by: Maureen Helm <[email protected]>
Notes that the API is currently experimental, and is targetting
being added initially for 3.2.

Signed-off-by: Tom Burdick <[email protected]>
@teburd teburd requested review from mbolivar-nordic, nashif and nordic-krch and removed request for nashif June 27, 2022 13:59
@laurenmurphyx64 laurenmurphyx64 self-requested a review June 28, 2022 14:04
@nashif nashif merged commit 215bfa2 into zephyrproject-rtos:main Jun 28, 2022
@teburd teburd deleted the rtio_next branch June 28, 2022 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: Documentation area: Tests Issues related to a particular existing or missing test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants