fix(cardwired): on monitor event, re-apply the persisted mode, replace change uevent to add/remove - #180
fix(cardwired): on monitor event, re-apply the persisted mode, replace change uevent to add/remove#180luytan wants to merge 8 commits into
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe daemon centralizes desktop parsing, emits desktop-aware add/remove DRM uevents during GPU transitions, restores persisted display modes, and limits immediate DRM reconciliation to change events. It also filters zbus messages below warning level. ChangesDesktop-aware GPU display flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant GPU_interface
participant send_drm_uevent
participant monitor_display
participant CardwireModeState
GPU_interface->>send_drm_uevent: Send UdevAction::Add or UdevAction::Remove
send_drm_uevent-->>monitor_display: Emit add/remove DRM event
monitor_display->>CardwireModeState: Read persisted mode
CardwireModeState-->>monitor_display: Return persisted mode
monitor_display->>monitor_display: Queue change events for reconciliation
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/cardwire-daemon/src/interface/gpu.rs (1)
97-109: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winRelease the eBPF blocker write lock before the DRM uevent write.
By the runes, Lines 103 and 147 await a sysfs operation while
blockerstill holds the shared write lock. A slow driver delaysgpu_blockedand all other block or unblock operations. Drop the guard after inode updates and beforesend_drm_uevent.Proposed fix
for inode in inodes { blocker.block_inode(inode, value).into_fdo()?; } + drop(blocker); if let Err(err) = send_drm_uevent(*self.device.card(), UdevAction::Remove).await { @@ for inode in inodes.iter() { blocker.unblock_inode(*inode, self.id).into_fdo()?; } + drop(blocker); + if let Err(err) = send_drm_uevent(*self.device.card(), UdevAction::Add).await {Also applies to: 142-152
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/cardwire-daemon/src/interface/gpu.rs` around lines 97 - 109, Release the blocker write guard after completing the inode updates and before awaiting send_drm_uevent in both affected block and unblock paths. Ensure the blocker guard is dropped before the DRM uevent operation while preserving the existing error handling and inode-update behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/cardwire-daemon/src/core/gpu/display.rs`:
- Around line 169-182: Update the desktop handling around Desktop::from_str so
unrecognized desktop values continue into the remove operation instead of
returning early. Preserve the existing no-op exclusively for Desktop::Gnome,
while allowing Desktop::from_str returning None and recognized non-GNOME
desktops to emit the existing "remove\n" event.
---
Outside diff comments:
In `@crates/cardwire-daemon/src/interface/gpu.rs`:
- Around line 97-109: Release the blocker write guard after completing the inode
updates and before awaiting send_drm_uevent in both affected block and unblock
paths. Ensure the blocker guard is dropped before the DRM uevent operation while
preserving the existing error handling and inode-update behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 6380e208-6d75-4b1c-a915-74ea2492a418
📒 Files selected for processing (9)
crates/cardwire-daemon/src/analyzer/dynamic_analysis.rscrates/cardwire-daemon/src/core/desktop.rscrates/cardwire-daemon/src/core/gpu/display.rscrates/cardwire-daemon/src/core/gpu/mod.rscrates/cardwire-daemon/src/core/mod.rscrates/cardwire-daemon/src/daemon.rscrates/cardwire-daemon/src/interface/gpu.rscrates/cardwire-daemon/src/interface/mode.rscrates/cardwire-daemon/src/tasks/monitor_display.rs
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/cardwire-daemon/src/interface/gpu.rs (1)
102-108: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winAdd a per-GPU transition lock, wizard.
block_gpuandunblock_gpualso run directly fromModeInterface::apply_modeandmonitor_display::reconcile_gpu; zbus dispatch does not serialize these paths. Sinceself.blockeris released beforesend_drm_uevent, anAddwrite can overtake a pendingRemovewrite. Serialize the blocker update and uevent with a separate per-GPU lock. Keepself.blockerunlocked during filesystem I/O.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/cardwire-daemon/src/interface/gpu.rs` around lines 102 - 108, Introduce a separate per-GPU transition lock covering the blocker state update and the subsequent DRM uevent in the relevant block/unblock transition flow. Ensure all callers, including ModeInterface::apply_mode and monitor_display::reconcile_gpu, use this lock so Add and Remove events cannot overtake each other, while releasing self.blocker before performing filesystem I/O.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@crates/cardwire-daemon/src/interface/gpu.rs`:
- Around line 102-108: Introduce a separate per-GPU transition lock covering the
blocker state update and the subsequent DRM uevent in the relevant block/unblock
transition flow. Ensure all callers, including ModeInterface::apply_mode and
monitor_display::reconcile_gpu, use this lock so Add and Remove events cannot
overtake each other, while releasing self.blocker before performing filesystem
I/O.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c6b81391-b586-4d46-a09b-72abb0bcb9b6
📒 Files selected for processing (1)
crates/cardwire-daemon/src/interface/gpu.rs
Description
This PR fixes issues with the auto switch on monitor event:
TODO
Checklist: