usb_c: Properly handle Protocol Errors during DRS

From 8.3.3.4.2.1 PE_SNK_Send_Soft_Reset State, Error Recovery
should be performed if a Protocol Error happens during a Data
Role Swap.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
This commit is contained in:
Sam Hurst 2022-12-23 14:26:12 -08:00 committed by Carles Cufí
parent c27a3a31d3
commit 24e18d46f1

View file

@ -680,11 +680,16 @@ void pe_drs_send_swap_run(void *obj)
policy_notify(dev, (pe->data_role == TC_ROLE_UFP) ? DATA_ROLE_IS_UFP
: DATA_ROLE_IS_DFP);
} else {
/* Protocol Error */
policy_notify(dev, PROTOCOL_ERROR);
pe_send_soft_reset(dev, PD_PACKET_SOP);
/*
* A Protocol Error during a Data Role Swap when the
* DFP/UFP roles are changing shall directly trigger
* a Type-C Error Recovery.
*/
usbc_request(dev, REQUEST_TC_ERROR_RECOVERY);
return;
}
/* return to ready state */
pe_set_state(dev, PE_SNK_READY);
return;
} else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_DISCARDED)) {