type-c-service: Implement hard reset flow#729
type-c-service: Implement hard reset flow#729RobertZ2011 wants to merge 1 commit intoOpenDevicePartnership:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds handling for PD hard reset status events in the Type-C service wrapper so the power policy and HW path are driven to a safer state when a hard reset occurs.
Changes:
- Detect
pd_hard_resetinprocess_port_status_changed. - When in
ConnectedConsumer, disable the sink path and notify the power policy device by disconnecting.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if connected_consumer.disconnect().await.is_err() { | ||
| error!( | ||
| "Port{}: Error disconnecting from ConnectedConsumer after PD hard reset", | ||
| global_port_id.0 |
There was a problem hiding this comment.
The disconnect error is logged without the underlying error value (disconnect().await.is_err()), which makes diagnosing hard-reset issues difficult. Capture the Err(e) and include e in the log (and keep the PdError::Failed return if you still want to fail the whole event processing).
| if connected_consumer.disconnect().await.is_err() { | |
| error!( | |
| "Port{}: Error disconnecting from ConnectedConsumer after PD hard reset", | |
| global_port_id.0 | |
| if let Err(e) = connected_consumer.disconnect().await { | |
| error!( | |
| "Port{}: Error disconnecting from ConnectedConsumer after PD hard reset: {:?}", | |
| global_port_id.0, | |
| e |
| if status_event.pd_hard_reset() { | ||
| info!("Port{}: PD hard reset", global_port_id.0); | ||
| if let Ok(connected_consumer) = power.try_device_action::<action::ConnectedConsumer>().await { | ||
| info!("Port{}: Disabling sink path due to PD hard reset", global_port_id.0); | ||
| controller.enable_sink_path(local_port_id, false).await?; | ||
| if connected_consumer.disconnect().await.is_err() { | ||
| error!( | ||
| "Port{}: Error disconnecting from ConnectedConsumer after PD hard reset", | ||
| global_port_id.0 | ||
| ); | ||
| return PdError::Failed.into(); | ||
| } | ||
| } |
There was a problem hiding this comment.
The PD hard reset handler only attempts recovery when the power device is in ConnectedConsumer. A hard reset can also occur while the policy state is ConnectedProvider, which would leave the power policy thinking it is still connected/providing even though the PD contract has been reset. Consider also handling ConnectedProvider here (e.g., transition the power device back to Idle via a disconnect()), and apply any required hardware-path changes for that mode if applicable.
No description provided.