-
Notifications
You must be signed in to change notification settings - Fork 30
Add reset generation tracking and cache invalidation for DS5 sensors #381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -474,6 +474,7 @@ struct ds5 { | |||||||||||||
| int is_depth, is_y8, is_rgb, is_imu; | ||||||||||||||
| bool metadata_enabled; | ||||||||||||||
| int aggregated; | ||||||||||||||
| int reset_gen; | ||||||||||||||
| u16 fw_version; | ||||||||||||||
| u16 fw_build; | ||||||||||||||
| #ifdef CONFIG_VIDEO_D4XX_SERDES | ||||||||||||||
|
|
@@ -492,6 +493,8 @@ struct ds5_counters { | |||||||||||||
| unsigned int n_ctrl; | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
|
||||||||||||||
| /* Global reset generation counter incremented on each hardware reset. | |
| * Each ds5 device instance tracks this to detect resets and invalidate | |
| * any cached configuration that may no longer be valid. | |
| */ |
Copilot
AI
Feb 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The global atomic counter ds5_reset_gen is shared across all DS5 device instances. When one device is reset, the counter increments, causing all other device instances to invalidate their caches on their next configure call, even though they weren't reset. This could lead to unnecessary cache invalidations and configuration writes for devices that haven't been reset. Consider making the reset generation counter per-device (non-static) or using a different synchronization mechanism if multiple DS5 devices can be present in the system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not relevant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reset_gen is shared between the instances ?
Copilot
AI
Feb 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The debug log includes sensor pointer address which may not be very useful for debugging. Consider logging the sensor name (sensor->sd.name) instead to make the debug output more meaningful.
| dev_dbg(&state->client->dev, "sensor %p: dt_value=0x%x, cached_dt_value=0x%x, cached_fps_value=%u, framerate=%u\n", | |
| sensor, dt_value, sensor->cached_dt_value, sensor->cached_fps_value, sensor->config.framerate); | |
| dev_dbg(&state->client->dev, "sensor %s: dt_value=0x%x, cached_dt_value=0x%x, cached_fps_value=%u, framerate=%u\n", | |
| sensor->sd.name, dt_value, sensor->cached_dt_value, sensor->cached_fps_value, sensor->config.framerate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
Copilot
AI
Feb 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cache clearing for SERDES (lines 2255-2273) happens before the reset generation counter is incremented (line 2292). This creates a window where the cache is cleared but the reset generation hasn't been updated yet. If another thread calls ds5_configure during this window, it may not detect the reset and could attempt to use or update the already-cleared cache values. Consider incrementing the reset generation counter before clearing the cache to ensure proper synchronization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reset_gen field should have a comment explaining its purpose, such as "Generation counter for tracking hardware resets; compared against global ds5_reset_gen to detect when device has been reset and cache needs invalidation."