drivers: sensor: afbr_s50: reinitialize the device to recover from errors - #117406
Open
bperseghetti wants to merge 1 commit into
Open
drivers: sensor: afbr_s50: reinitialize the device to recover from errors#117406bperseghetti wants to merge 1 commit into
bperseghetti wants to merge 1 commit into
Conversation
…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>
zephyrbot
requested review from
MaureenHelm,
asemjonovs,
avisconti,
jeppenodgaard,
teburd,
tristan-google,
ubieda and
yperess
August 26, 2026 03:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).