usb: pd: Ensure disconnect is processed when hard reset in progress
When hard reset is in progress, the pd state machine restarts
from PE_UNKNOWN state. If a Type-C disconnect notification
is received during the same time, the current_pr is set to
PR_NONE. Because of this we bail out of the usbpd_sm
assuming it is in disconnected state even though the
disconnect was not processed.
Fix this by validating the current_dr as well to confirm
that the state machine is actually in disconnected state.
Change-Id: Iea59a857c6826f65fef8b0c9a8ee6e2488683864
Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org>
diff --git a/drivers/usb/pd/policy_engine.c b/drivers/usb/pd/policy_engine.c
index 10d11ac..1a95910 100644
--- a/drivers/usb/pd/policy_engine.c
+++ b/drivers/usb/pd/policy_engine.c
@@ -2101,7 +2101,8 @@ static void usbpd_sm(struct work_struct *w)
/* Disconnect? */
if (pd->current_pr == PR_NONE) {
- if (pd->current_state == PE_UNKNOWN)
+ if (pd->current_state == PE_UNKNOWN &&
+ pd->current_dr == DR_NONE)
goto sm_done;
if (pd->vconn_enabled) {