Skip to content

drivers: sensor: afbr_s50: reinitialize the device to recover from errors - #117406

Open
bperseghetti wants to merge 1 commit into
zephyrproject-rtos:mainfrom
CogniPilot:pr-deps-afbr-recovery
Open

drivers: sensor: afbr_s50: reinitialize the device to recover from errors#117406
bperseghetti wants to merge 1 commit into
zephyrproject-rtos:mainfrom
CogniPilot:pr-deps-afbr-recovery

Conversation

@bperseghetti

@bperseghetti bperseghetti commented Aug 26, 2026

Copy link
Copy Markdown
Member

Stopping and restarting the measurement timer does not bring the AFBR-S50 back once it reports an error: the data stream stays dead until the board is rebooted. The blocking stop call was also issued for every data-ready trigger seen while the device was in error, delaying the evaluation that frees the internal buffer and holding the device in the failed state.

Track the error and the recovery as explicit states, stop once per error occurrence, and recover by tearing the Argus handle down and reinitializing it through a sequence shared with initial bring-up, restoring the stream in place. The reinitialization runs on the RTIO work queue and is bounded: after a capped number of consecutive failures, with growing backoff, the submission is failed with -EIO so a detached or dead device cannot spin the work queue forever.

Builds on the evaluation-error fixes merged in #116085 and recovers the errors they surface without operator intervention.

Validated on NXP MCXN947 hardware over LPSPI.

Dependencies: #117396 (the probe read must succeed and the allocator must be correctly sized before Argus_CreateHandle runs in the recovery path).

…device

Stopping and restarting the measurement timer does not bring the device
back once it reports an error: the data stream stays dead until the
board is rebooted. Argus_StopMeasurementTimer() also blocks, and it was
called for every data-ready trigger seen while the device was in error,
delaying the data evaluation that frees the internal buffer and holding
the device in the failed state.

Track the error and the recovery as explicit states so the stop is done
once per error occurrence and an in-progress recovery is distinguishable
from a new failure. Recover by tearing the Argus handle down and
initializing it again through a shared reinitialization sequence, which
restores the stream in place. The initialization and configuration steps
that afbr_s50_init open-coded are factored into that shared sequence so
the recovery path and the initial bring-up run the same code.

The reinitialization runs on the RTIO work queue and is bounded: after a
capped number of consecutive failures, with a growing backoff between
attempts, the submission is failed with -EIO instead of retrying
forever, so a detached or dead device cannot spin the work queue.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants