drivers: adc: esp32: fix oneshot read hang with wi-fi power save - #117346
Open
sylvioalves wants to merge 2 commits into
Open
drivers: adc: esp32: fix oneshot read hang with wi-fi power save#117346sylvioalves wants to merge 2 commits into
sylvioalves wants to merge 2 commits into
Conversation
The oneshot read path touched the analog calibration registers and started conversions without holding the analog i2c master clock. On SoCs where that clock is root gated it is shared with the Wi-Fi modem, so the first modem sleep cycle gated it and the conversion polling never returned. Hold the reference counted analog clock across channel setup, calibration load and conversion, and propagate a conversion failure as -ETIMEDOUT so callers can retry when the shared analog hardware is temporarily powered down by modem sleep. The completion wait bound is adjustable through the new ADC_ESP32_CONVERSION_TIMEOUT_US option. Assisted-by: Claude:opus-4-8 Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The continuous acquisition path programs the analog calibration registers and runs the shared front-end without holding the analog i2c master clock, the same gap the oneshot path had. Hold the reference counted clock from controller start until stop so the acquisition does not depend on another user keeping that clock enabled. Assisted-by: Claude:opus-4-8 Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
zephyrbot
requested review from
LucasTambor,
ZhaoxiangJin,
anangl,
jsbatch,
marekmatej,
raffarost,
tmedicci,
uLipe and
wmrsouza
August 25, 2026 19:30
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.
When Wi-Fi power saving is enabled, adc_read() can hang forever because the ADC shares an analog clock with the Wi-Fi modem and the hal waits for the conversion result in a loop with no timeout. While the modem sleeps the conversion can never finish.
The driver now holds the analog clock while reading and the hal wait is bounded, so instead of hanging the read returns ETIMEDOUT and the application can simply retry. The timeout is configurable through ADC_ESP32_CONVERSION_TIMEOUT_US.
Fixes #117247