usb: pd: ensure source hard reset is handled timely

When in source mode if a hard reset is received just before or
while usbpd_sm() is in the middle of trying to send an outgoing
message, the signal handling would get delayed due waiting for
the PD PHY to complete retrying and failing both the message as
well as the subsequent Soft_Reset message. Instead, treat the
incoming hard reset with priority try to bail out of further
attempts to send a message so that we can immeidately re-queue and
process the hard reset on the next usbpd_sm() invocation.

In case the TX attempt still manages to win the race, this will
cause delay that affects our tPSHardReset (25-35ms) required time
resulting in VBUS getting turned off too late. Handle this by
keeping track of when the hard reset signal arrived so that
we can schedule SRC_TRANSITION_TO_DEFAULT within this window.

Also promote the error message when a hard reset is received
from KERN_DEBUG to KERN_ERR, as this is abnormal enough
to deserve printing to the kernel log with higher priority.

Change-Id: Ie503f7b776022067ec3a4788d5229ec508b9c55f
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2 files changed