Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions type-c-service/src/wrapper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,22 @@ where
.get_power_device(local_port_id)
.ok_or(Error::Pd(PdError::InvalidPort))?;
trace!("Port{} status events: {:#?}", global_port_id.0, status_event);

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
Comment on lines +253 to +256
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.
);
return PdError::Failed.into();
}
}
Comment on lines +248 to +260
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.
}

if status_event.plug_inserted_or_removed() {
self.process_plug_event(controller, power, local_port_id, &status)
.await?;
Expand Down