Skip to content

type-c-service: Implement hard reset flow#729

Draft
RobertZ2011 wants to merge 1 commit intoOpenDevicePartnership:mainfrom
RobertZ2011:type-c-hard-reset
Draft

type-c-service: Implement hard reset flow#729
RobertZ2011 wants to merge 1 commit intoOpenDevicePartnership:mainfrom
RobertZ2011:type-c-hard-reset

Conversation

@RobertZ2011
Copy link
Contributor

No description provided.

@RobertZ2011 RobertZ2011 self-assigned this Feb 23, 2026
Copilot AI review requested due to automatic review settings February 23, 2026 17:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_reset in process_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.

Comment on lines +253 to +256
if connected_consumer.disconnect().await.is_err() {
error!(
"Port{}: Error disconnecting from ConnectedConsumer after PD hard reset",
global_port_id.0
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +248 to +260
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();
}
}
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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.

2 participants