xtensa/esp32s3: fix esp32s3_cam uninit/stop_capture bugs#18663
Closed
JianyuWang0623 wants to merge 1 commit intoapache:masterfrom
Closed
xtensa/esp32s3: fix esp32s3_cam uninit/stop_capture bugs#18663JianyuWang0623 wants to merge 1 commit intoapache:masterfrom
JianyuWang0623 wants to merge 1 commit intoapache:masterfrom
Conversation
Fix several issues in the ESP32-S3 CAM driver: - stop_capture: reset DMA channel, CAM module and AFIFO under spinlock to fully quiesce hardware before returning. Clear pending VSYNC interrupt to prevent stale ISR firing. - uninit: reset CAM/AFIFO before releasing DMA to prevent in-flight transfers after channel detach. Use esp_teardown_irq with correct peripheral ID (ESP32S3_PERIPH_LCD_CAM) instead of irq_detach which corrupts the shared IRQ mapping table. Mask interrupts and clear pending flags under spinlock before detaching handler. - uninit: preserve XCLK output so the sensor remains accessible via I2C for subsequent re-initialization. - set_buf/uninit: track driver-allocated vs user-provided frame buffers with fb_allocated flag to prevent double-free when using V4L2 USERPTR mode. Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
b7fa524 to
f3bb266
Compare
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.
Summary
Fix several issues in the ESP32-S3 CAM driver that cause heap corruption, IRQ mapping corruption, and stale DMA writes when using the camera example app with V4L2 USERPTR mode.
Changes
stop_capture: reset DMA channel, CAM module and AFIFO under spinlock to fully quiesce hardware before returning. Clear pending VSYNC interrupt to prevent stale ISR firing.
uninit: reset CAM/AFIFO before releasing DMA to prevent in-flight transfers after channel detach. Use
esp_teardown_irqwith correct peripheral ID (ESP32S3_PERIPH_LCD_CAM) instead ofirq_detachwhich corrupts the shared IRQ mapping table. Mask interrupts and clear pending flags under spinlock before detaching handler.uninit: preserve XCLK output so the sensor remains accessible via I2C for subsequent re-initialization.
set_buf/uninit: track driver-allocated vs user-provided frame buffers with
fb_allocatedflag to prevent double-free when using V4L2 USERPTR mode.Impact
mm_delayfreeduring camera app cleanupTesting
Tested on lckfb-szpi-esp32s3 (ESP32-S3 + GC0308 sensor):
Related PR
apps-side fix: apache/nuttx-apps#3446