-
Notifications
You must be signed in to change notification settings - Fork 8.2k
rtio: SPI support #56125
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: SPI support #56125
Conversation
4dde6b2 to
d71d98b
Compare
|
Hi @teburd , I was looking and I think this model seems to be very intrusive for me at first. Consider that I'm very green on RTIO and maybe I'm lacking in knowledge too. Questions: 2- Did you considered define a API with focus on DMA? I mean, create universal mechanism that all drivers can consume specific DMA APIs, for instance, pass linked lists. So, when someone implement the peripheral driver the RTIO can be just used it if there is DMA available and API have DMA implementation. In this case, with linked lists it is possible to implement at least batch mode and ping pong and you don't need to change RTIO API for I2C and SPI if driver can direct consume linked lists. Keep in mind that since you are experimenting it could be good have a dedicated SPI driver at this moment. This will help with the experiment phase without break driver for current users. When we confirm that it is fine we can merge versions. |
|
@nandojve thank you for taking a look! Responses inline
I can understand and appreciate the apprehension to mix what is marked here as an experimental feature, which it is only until it starts being used, which I don't think will take long. I'm happy to split this into spi_sam.c (existing driver) and spi_sam_rtio.c the driver in this PR with the SPI_RTIO feature enabled if helpful in moving quickly.
In a way this is exactly an struct rtio_iodev is, its an API that provides the single asynchronous submit function, associated with some data. The associated mpsc queue probably should be moved into something like struct rtio_iodev_context much like spi_context, and its something I intend on doing after this.
I agree! As mentioned, if it makes it easier to experiment without disturbing existing SAM users I'm all for having two C files, spi_sam.c and spi_sam_rtio.c. Let me know if that's what you'd like to see. Or I guess another possibility would be to layer these things, maybe that's what you are getting at. spi_sam_rtio.c implements a simple API for RTIO only, and spi_sam.c calls to it to provide the existing SPI API when its enabled. Maybe this is what you meant in a way and I've misunderstood? I haven't considered that option much but it could be interesting to try! |
When sending small buffers out it makes sense to copy rather than reference to avoid having to keep the small buffer around for the lifetime of the write request. Adjusts the op numbers to always be +1 from the previously defined op id making it easier to re-arrange if needed in the future. Signed-off-by: Tom Burdick <[email protected]>
2d06b78 to
ca0ecd3
Compare
Adds a callback op to RTIO enabling C logic to be interspersed with I/O operations. This is not safe from userspace but allowable in kernel space. Signed-off-by: Tom Burdick <[email protected]>
Adds the transceive op which is needed for full SPI support. Notably in RTIO transceive is expected to be a balanced buffer pair of the same length and have non-null tx/rx bufs. Signed-off-by: Tom Burdick <[email protected]>
pdgendt
left a comment
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.
LGTM, some compliance fixes needed though.
Provides a macro and submit API for SPI drivers to support RTIO. A copy function enables compatibility with the existing blocking API and very easily the existing async API as well. Signed-off-by: Tom Burdick <[email protected]>
Implements the SPI RTIO API. Refactors many of the internal transfer functions to work on simple types to allow for both the RTIO and existing SPI API functions to co-exist. Removes the unneeded shift_master specialization. Either a polling or DMA transfer flow is used when used with RTIO as all operations are normalized. When SPI_RTIO is enabled the spi_transceive blocking call translates the request into an RTIO transaction placed in the queue of transactions the device is meant to do. Signed-off-by: Tom Burdick <[email protected]>
Adds the equivalent spi loopback tests using RTIO and a testplan that uses it. Adds a tdk robokit1 overlay to enable the NOCACHE option so that DMA transfers correctly work. Signed-off-by: Tom Burdick <[email protected]>
Supporting SPI using a direct mapping of the possible read/write/transceives to RTIO requests
Opens the possibility up of having truly async spi where any number of contexts may submit transactions from any call context without blocking, such as a sensor fifo triggered gpio interrupt as shown in #55383
Related #22494 for SPI
Related #22498 for SPI
Enables finally resolving #1387 in a nice way
Test results running on the tdk robokit