Skip to content

Refactor ds5 sensor configuration and streaming logic to improve stab… - #375

Merged
ymodlin merged 2 commits into
devfrom
fix-hw-reset-regression
Feb 22, 2026
Merged

Refactor ds5 sensor configuration and streaming logic to improve stab…#375
ymodlin merged 2 commits into
devfrom
fix-hw-reset-regression

Conversation

@Nikolai-L

Copy link
Copy Markdown
Contributor

…ility and error handling

@Nikolai-L
Nikolai-L requested a review from ymodlin February 22, 2026 10:10
Comment thread kernel/realsense/d4xx.c Outdated
@Nikolai-L
Nikolai-L marked this pull request as ready for review February 22, 2026 11:23
Copilot AI review requested due to automatic review settings February 22, 2026 11:23
@Nikolai-L
Nikolai-L force-pushed the fix-hw-reset-regression branch from 4f7d47d to daeed27 Compare February 22, 2026 11:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the DS5 sensor configuration and streaming logic for the D4XX RealSense camera driver to improve stability and error handling, particularly for SERDES (Serializer/Deserializer) pipeline management over GMSL links.

Changes:

  • Replaced boolean pipe_configured flag with PIPE_NOT_CONFIGURED constant for clearer pipe state tracking
  • Increased stream start/stop timeout from 700ms to 2000ms for better reliability under adverse conditions
  • Refactored ds5_mux_s_stream() with unified retry logic that properly handles firmware config rejections and streaming state transitions
  • Consolidated pipe cleanup in ds5_hw_reset_with_recovery() by introducing ds5_config_cache_clear() helper function

Reviewed changes

Copilot reviewed 1 out of 1 changed files in this pull request and generated 12 comments.

File Description
long-run.log Kernel diagnostic log showing errors being addressed (refcount issues, timeouts, capture failures)
kernel/realsense/d4xx.c Core driver changes: improved pipe state management, increased timeouts, refactored streaming logic with better error recovery

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kernel/realsense/d4xx.c
}
}
if (i >= DS5_START_MAX_COUNT) {
if (on == !(status & DS5_STATUS_STREAMING))

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'status' is used in the conditional check after the loop, but if the loop times out without a successful read, 'status' may be uninitialized. Initialize 'status' to a safe value (e.g., 0) before the loop to prevent undefined behavior.

Copilot uses AI. Check for mistakes.
Comment thread kernel/realsense/d4xx.c
Comment thread kernel/realsense/d4xx.c
Comment on lines +1786 to +1787
ret = -(ENOSR);
return ret;

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable 'ret' is assigned but its value is not used before being overwritten or returned. The assignment at line 1786 should be simplified to just 'return -ENOSR;' or the intermediate variable should be removed.

Suggested change
ret = -(ENOSR);
return ret;
return -ENOSR;

Copilot uses AI. Check for mistakes.
Comment thread kernel/realsense/d4xx.c
Comment thread kernel/realsense/d4xx.c
Comment thread kernel/realsense/d4xx.c
Comment thread kernel/realsense/d4xx.c
Comment thread kernel/realsense/d4xx.c
Comment thread kernel/realsense/d4xx.c
Comment thread kernel/realsense/d4xx.c
if (streaming == expected_streaming_state)
ts = jiffies;
for (timeout = ts + msecs_to_jiffies(DS5_START_MAX_TIME);
time_before(jiffies, timeout); msleep_range(i*DS5_START_POLL_TIME))

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop iterator variable 'i' is used in the sleep calculation but is never incremented in the first polling loop. This results in a busy-wait spin (zero sleep) until timeout. The loop should increment 'i' in the loop update expression or use a separate counter.

Suggested change
time_before(jiffies, timeout); msleep_range(i*DS5_START_POLL_TIME))
time_before(jiffies, timeout); i++, msleep_range(i * DS5_START_POLL_TIME))

Copilot uses AI. Check for mistakes.
@ymodlin
ymodlin force-pushed the fix-hw-reset-regression branch from daeed27 to 39b6b8e Compare February 22, 2026 12:49
@ymodlin
ymodlin merged commit b0946f5 into dev Feb 22, 2026
7 checks passed
@ymodlin
ymodlin deleted the fix-hw-reset-regression branch February 22, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants