Skip to content

Commit

Permalink
usb: typec: intel_pmc_mux: Avoid connect request on disconnect
Browse files Browse the repository at this point in the history
When pmc_usb_mux_set() is invoked when a device is disconnected, a valid
scenario is for state->alt == NULL and state->mode == TYPEC_STATE_USB.

In such cases, if a pmc_usb_disconnect() has already been issued (from
either pmc_usb_set_orientation() when orientation ==
TYPEC_ORIENTATION_NONE, or pmc_usb_set_role() when role ==
USB_ROLE_NONE), a pmc_usb_connect() will be issued despite no peripheral
being present.

This confuses the PMC and leads to all subsequent PMC IPC requests
returning errors due to timeout.

To prevent this, return early if the port orientation or role is already
set to none.

Cc: Benson Leung <bleung@chromium.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Rajmohan Mani <rajmohan.mani@intel.com>
Fixes: f3c1c41 ("usb: typec: intel_pmc_mux: Add support for USB4")
Signed-off-by: Prashant Malani <pmalani@chromium.org>
Link: https://lore.kernel.org/r/20200709002441.1309189-1-pmalani@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Prashant Malani authored and Greg Kroah-Hartman committed Jul 21, 2020
1 parent b1b6bed commit 658027a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/usb/typec/mux/intel_pmc_mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ pmc_usb_mux_set(struct typec_mux *mux, struct typec_mux_state *state)
{
struct pmc_usb_port *port = typec_mux_get_drvdata(mux);

if (port->orientation == TYPEC_ORIENTATION_NONE || port->role == USB_ROLE_NONE)
return 0;

if (state->mode == TYPEC_STATE_SAFE)
return pmc_usb_mux_safe_state(port);
if (state->mode == TYPEC_STATE_USB)
Expand Down

0 comments on commit 658027a

Please sign in to comment.