Repository navigation
soc: apple: aop: Share sensor on-demand streaming helper and fix 1 Hz idle race - #179
Conversation
6522c2e to
267fb2f
Compare
|
Updated (
|
|
Thanks @grierj, this looks good: one shared streaming helper instead of four copies, and the slow-polling race fixed. The locking checks out. Before we merge, could you do a quick check on your J207? This rewrites four drivers, and the PR only mentions a clean build. Reading each of the four AOP sensors once (accelerometer, gyroscope, compass, barometer) plus one buffer start/stop on one of them would be enough, ideally with a read at 1 Hz. Please paste the output or the dmesg here. We'll merge as soon as you confirm. One small non-blocking note: the commit message says the idle delay is "max(3 s, ...)", but the code (and the PR description) use max(2 s, 2 periods + 1 s). If you're touching the branch anyway, feel free to fix the message; if not, that's fine. |
… idle race All four AOP IIO sensor drivers (accel, gyro, compass, pressure) carried identical copies of the on-demand streaming state machine: start/stop property sequencing, idle delayed_work, waiter tracking, sample-ready synchronization, and interval updates. Extract this state machine into a shared struct apple_aop_stream helper in drivers/soc/apple/aop.c and include/linux/soc/apple/aop.h, and switch the four IIO drivers to use it. While consolidating, fix four edge cases in the streaming helper: - Scale the idle stop delay to at least two sample periods plus one full second (max(2 s, 2 * interval + 1 s)) and track an authoritative idle_deadline under stream->lock so a 1 Hz sysfs poller cannot race with an idle stop and an already-queued idle worker cannot stop a freshly rearmed stream. - Keep waiters counted across the sample copy via sample_get/sample_put so a concurrent buffer disable cannot clear have_sample before read_raw copies the sample, and refresh the wait deadline if a slower rate is programmed while waiting. - Synchronize IIO buffer delivery with a dedicated push_lock/push_enabled gate opened in postenable and closed/drained in predisable, instead of relying on unsynchronized iio_buffer_enabled() during reconfiguration. - Preserve confirmed firmware state if a start/rate-change or stop property write fails. Assisted-by: LLM Signed-off-by: Grier Johnson <grier@scooterfarm.com>
267fb2f to
7d8c080
Compare
|
Merged, thank you Grier! One shared streaming helper instead of four copies, and the 1 Hz race is gone: really nice cleanup. What we changed on the branch: only the commit message, where the idle delay now reads max(2 s, 2 * interval + 1 s), matching the code and your PR description. The code is exactly yours. It reaches the nightly once orchard takes the new kernel. A quick report from your J207 after that (each sensor read once, a buffer start and stop) would be very welcome. |
Follow-up to #171 addressing both review notes:
struct apple_aop_stream): Move the duplicated interval/start/stop/idle-work/wait state machine fromapple_aop_accel,apple_aop_gyro,apple_aop_compass, andapple_aop_pressureintodrivers/soc/apple/aop.candinclude/linux/soc/apple/aop.h(-318net lines), keeping all four IIO drivers in step.waitersand cancelidle_workwhileapple_aop_stream_ensure_sample()is waiting for a sample, arming the idle stop only after the wait finishes (and preventingbuffer_disable()from stopping the stream out from under an in-flight read).max(2000 ms, 2 * period + 1000 ms)(3 s at 1 Hz) and refresh it when the sampling frequency changes while streaming.Built cleanly for
apple-16kwith zero warnings viaorchard build --device j207 --kernel-tree.Assisted-by: LLM