From 0c110427c7c154ae285a26dcee0f870f48841451 Mon Sep 17 00:00:00 2001 From: Rohith Kollalsi Date: Mon, 18 Oct 2021 23:19:29 +0530 Subject: [PATCH] usb: pd: Process request message as soon as it is received Below mentioned is the sequence of operations done during a pr swap. During the issue scenario, the sleep time of 26 ms is almost coinciding between src_send_capabilities and snk_select_capabilities. Due to this sink side is not able to receive accept from the source for the message request sent. Hence, it does a hard reset. State changes during working scenario. Source Sink SRC_Startup SNK_Startup SRC_Send_Capabilities sleeps for 26ms then entertains req from snk SNK_Evaluate_Capability SNK_Select_Capability send message request to src expects accept in 26ms or else does hard reset Message request received from snk SRC_Negotiate_Capability Send message accept SNK_Transition_Sink SRC_Ready SNK_READY Below is the issue scenario Source Sink SRC_Startup SNK_Startup SRC_Send_Capabilities sleeps for 26ms then entertains req from snk SNK_Evaluate_Capability SNK_Select_Capability send message request to src expects accept in 26ms or else does hard reset Message request received from snk during this 26ms sleep, hence it could not send accept Perform hard reset as accept not received within 26ms Fix this by processing the request message immediately after it is received. This makes sure that request message sent from another end is processed quickly, so that it doesn't cause other end to send a hard reset. Change-Id: I7ffc0772df9300f6e56bbb4e4ad9aa3f15b10b8a Signed-off-by: Rohith Kollalsi --- drivers/usb/pd/policy_engine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/pd/policy_engine.c b/drivers/usb/pd/policy_engine.c index 2b118f71748a..99f271551ecc 100644 --- a/drivers/usb/pd/policy_engine.c +++ b/drivers/usb/pd/policy_engine.c @@ -3623,8 +3623,10 @@ sm_done: spin_unlock_irqrestore(&pd->rx_lock, flags); /* requeue if there are any new/pending RX messages */ - if (!ret && !pd->sm_queued) + if (!ret) { + usbpd_dbg(&pd->dev, "Requeuing new/pending RX messages\n"); kick_sm(pd, 0); + } if (!pd->sm_queued) pm_relax(&pd->dev);