From c72dcf02e12596455bf989ff68b740eedd769c11 Mon Sep 17 00:00:00 2001 From: Badhri Jagan Sridharan Date: Tue, 24 Nov 2020 18:07:03 -0800 Subject: [PATCH] FROMGIT: usb: typec: tcpm: Disregard vbus off while in PR_SWAP_SNK_SRC_SOURCE_ON During PR_SWAP sequence, when TCPM is waiting in PR_SWAP_SNK_SRC_SOURCE_ON for the vbus source to ramp up, TCPM would prematurely exit PR_SWAP_SNK_SRC_SOURCE_ON and transition to SNK_UNATTACHED state when a vbus off notification is received. This should not be the case as vbus can still be off while in PR_SWAP_SNK_SRC_SOURCE_ON and the vbus source has PD_T_NEWSRC to ramp up. Bug: 168555244 Reviewed-by: Guenter Roeck Signed-off-by: Badhri Jagan Sridharan Link: https://lore.kernel.org/r/20201125020703.1604979-1-badhri@google.com Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 3f461fba1f8f07d1a93c6489136b44c7300bb016 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next) Signed-off-by: Greg Kroah-Hartman Change-Id: I598c75bcca2d2b878897036f8a8dd6a1fc1d6fa3 --- drivers/usb/typec/tcpm/tcpm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 7756b9d115a5..f3fe384f3897 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -4264,6 +4264,14 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) /* Do nothing, expected */ break; + case PR_SWAP_SNK_SRC_SOURCE_ON: + /* + * Do nothing when vbus off notification is received. + * TCPM can wait for PD_T_NEWSRC in PR_SWAP_SNK_SRC_SOURCE_ON + * for the vbus source to ramp up. + */ + break; + case PORT_RESET_WAIT_OFF: tcpm_set_state(port, tcpm_default_state(port), 0); break;