Skip to content

Conversation

@teburd
Copy link
Contributor

@teburd teburd commented Mar 2, 2023

Adds the ability to mark submissions as being transactional which has the unique semantics of allowing multiple receive/send type operations to be viewed by the submitted to iodev as a single unit of work to do.

This is needed for SPI where a sequence of reads/writes with chip select are part of a transaction.

@teburd teburd force-pushed the rtio_iodev_transact branch 4 times, most recently from e4124f9 to 0193165 Compare March 3, 2023 18:45
@teburd teburd marked this pull request as ready for review March 3, 2023 19:50
@teburd teburd force-pushed the rtio_iodev_transact branch from 0193165 to 886dbd0 Compare March 6, 2023 17:41
yperess
yperess previously approved these changes Mar 16, 2023
Copy link
Contributor

@yperess yperess left a comment

Choose a reason for hiding this comment

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

Now that I understand this a bit better I'm happy to approve :)

teburd added 4 commits March 17, 2023 09:19
Tests were failing when the sqe was allocated on the stack for some
architectures. Initialization of variables on the stack is not guaranteed
to be zeroed like static data. This caused undefined behavior.

Secondly if the sqe is recycled and had a flag set, there would
unexpected behavior as well.

Signed-off-by: Tom Burdick <[email protected]>
Race was possible though very unlikely between the atomic cas
and queue push/pop operations. The outcome of the race had it shown up
would have been a submission not worked on due to the timer never being
started. A small critical section fixes this and clarifies where the single
conumer part of the mpsc queue comes in despite there being multiple
contexts which may enter that section.

Signed-off-by: Tom Burdick <[email protected]>
The test suites have grown to cover different units really and having
them in one file was becoming a bit much to scroll around in.
Coincidentally found a accidental reuse of a define between the spsc and
mpsc tests.

Signed-off-by: Tom Burdick <[email protected]>
Transactional submissions treat a sequence of sqes as a single atomic
submission given to a single iodev and expect as a reply a single
completion.

This is useful for scatter gather like APIs that exist in Zephyr already
for I2C and SPI.

Signed-off-by: Tom Burdick <[email protected]>
teburd added 4 commits March 17, 2023 11:00
The pending_sqe logic to track where in the ring queue the concurrent
executor had left off was slightly flawed. It didn't account for starting
all sqes in the queue and ending back up at the beginning.

Instead track the last SQE in the queue, from which the next one in the
queue will the one to start next.

If we happen to sweep the last known SQE in the queue, reset it to NULL
so the next time prepare is called we start at the beginning of the queue
again.

Signed-off-by: Tom Burdick <[email protected]>
C++ requires casting void * as the implicit cast isn't enough and
the C++ sample app fails to build without duplicating type information
here. Do that, and wrap it in extern C allowing the C++ to include
rtio_mpsc.h directly or indirectly.

Signed-off-by: Tom Burdick <[email protected]>
Ability to cancel all pending requests in the queue turns out to be
useful and shareable.

Signed-off-by: Tom Burdick <[email protected]>
When the consume semaphore is enabled always give and take from the
semaphore. It's expected that rtio_cqe_consume and rtio_cqe_consume_block
will be used exclusively rather than directly poking at the SPSC queues.

Signed-off-by: Tom Burdick <[email protected]>
@teburd teburd force-pushed the rtio_iodev_transact branch from 3670287 to 5eafe25 Compare March 17, 2023 16:34
@teburd
Copy link
Contributor Author

teburd commented Mar 17, 2023

Includes a stack of bug fixes now so CI hopefully remains happy

Copy link
Contributor

@yperess yperess left a comment

Choose a reason for hiding this comment

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

Verified locally

@MaureenHelm MaureenHelm merged commit 2d1375f into zephyrproject-rtos:main Mar 17, 2023
@teburd teburd deleted the rtio_iodev_transact branch March 17, 2023 17:51
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.

4 participants