-
Notifications
You must be signed in to change notification settings - Fork 8.1k
ICM45686: Streaming Performance Improvements #94832
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
ICM45686: Streaming Performance Improvements #94832
Conversation
|
It might be better to expand on it and perhapse add an additional API |
Makes sense. I'll unify with common APIs before marking as ready for review. |
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.
icm45686: stream: Only enable GPIO interrupts when stream is active
Otherwise a lot of spurious callbacks may trigger shortly after
rebooting.
This looks related to #96246
when FIFO_CONFIG0 is configured to stream mode,
01: Stream mode - Frames are overwritten when the FIFO full condition is
reached.
and FIFO_WR_WM_GT_TH
is set to 1 in FIFO_CONFIG2 you will get an interrupt every time a frame is written to the fifo if you are over the watermark threshold.
This occurring during init is because the fifo is full and not being emptied or reset yet.
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.
The problem is that when the application boots-up it has not configured the IMU yet and it has no knowledge or control on its state prior to the reset. For that reason, the right choice IMO is to not have the GPIO INT enabled until it matters (e.g: when a stream submission is requested).
Whether that comes from an interrupt due to a greater-than or exactly equals to the FIFO WM seems orthogonal to the problem.
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.
If you disable interrupts and read the fifo but due to system latency you do not re enable before the next equals wm threshold is hit you will never get another interrupt. So having the driver be greater-equals with irq disabled or equals with irq always on are mutually exclusive.
FYI - Picking this back up |
After looking at the reg-map API, I notice rtio_read_regs_async() does not match the needs for this driver. Since other sensor drivers also follow this same pattern, I'll follow-up with a separate PR to unify them. |
1398df1
to
d9e6f10
Compare
Similar pattern applied to other in-tree sensor drivers, where preparing a set of SQEs for writing/reading on registers is a recurrent syntax. Signed-off-by: Luis Ubieda <[email protected]>
In order to allow the error-handling scheme to take action, instead of crashing when asserts are enabled. Now possible since we have RTIO error handling for streaming mode. Signed-off-by: Luis Ubieda <[email protected]>
In order to simplify code-logic. Signed-off-by: Luis Ubieda <[email protected]>
Not handled otherwise. Signed-off-by: Luis Ubieda <[email protected]>
In order to detect when events are being missed. Signed-off-by: Luis Ubieda <[email protected]>
As it's not required, so we rather spare the cycles. Signed-off-by: Luis Ubieda <[email protected]>
10d5071
to
d59b736
Compare
Since the driver knows how many samples it wants (because of the watermark threshold), stick to that per event in order to facilitate batches of N number of samples. Signed-off-by: Luis Ubieda <[email protected]>
By introducing three states: Off -> On -> Busy -> (Offf) This allows us to more clearly guard on-going events and detect overlapping triggers. Signed-off-by: Luis Ubieda <[email protected]>
To handle streaming under stress scenario. Signed-off-by: Luis Ubieda <[email protected]>
Otherwise a lot of spurious callbacks may trigger shortly after rebooting. Signed-off-by: Luis Ubieda <[email protected]>
Process all in one callback, in order to reduce latency. The following changes have been done: - Process FIFO read-out and/or Data-ready in GPIO callback. - FIFO Full is handled on completion if needed. - Omit fifo-count fetching, to optimize cycles. The watermark count is the number of samples we're going for. Signed-off-by: Luis Ubieda <[email protected]>
Multi-shot request should re-enable it shortly. Signed-off-by: Luis Ubieda <[email protected]>
d59b736
to
f455e0c
Compare
@anthony289478 your comments have been addressed. Please revisit |
|
I will be able to test this earliest October 15 as I am on vacation. |
Ok - since your NACK was about the p4wq issue which is not present in upstream/zephyr (see #92462). I suggest dismissing it and letting the regular review process kick-in. |
I do not see an option to dismiss the request for changes. In fact, none of my comments have the "resolve conversation" button. |
@anthony289478 PTAL here: |
|
Dismissing NACK since Anthony is not able to do so.
@ubieda Am I missing something or is this definition wrong for its usage?
This was correct on the original commit but was reverted on the rebase from d59b736 to f455e0c Current main definition: zephyr/drivers/sensor/tdk/icm45686/icm45686_stream.c Lines 89 to 90 in 91c57f1
Current main usage:
|
@anthony289478 you're right - I just revisited the ICM45686 driver and there's a couple fixes in #97564. I tested on MCXN947 and it seems to work OK again. Thanks for reporting it. |
Various performance improvements after stress-testing driver: 2X instances, running at 3200-Hz ODR, results at 800-Hz (4 results every 1.25-ms).