]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
usb: typec: tcpm: print error on hard reset
authorSebastian Reichel <sebastian.reichel@collabora.com>
Thu, 23 May 2024 17:12:29 +0000 (19:12 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 4 Jun 2024 13:43:26 +0000 (15:43 +0200)
A USB-C hard reset involves removing the voltage from VBUS for some
time. So basically it has the same effect as removing the USB-C plug
for a short moment. If the machine is powered from the USB-C port and
does not have a fallback supply (e.g. a battery), this will result in
a full machine reset due to power loss.

Ideally we want to avoid triggering a hard reset on these boards. A
non-working USB-C port is probably better than unplanned reboots. But
boards with a backup supply should do the hard reset to get everything
working again.

In theory it would be enough to check the self_powered property, but
it seems the property might not be configured consistently enough in
system firmwares.

So let's start with just printing an error message when a hard reset is
triggered on systems we expect to be affected. This at least makes
debugging issues on affected systems easier without impacting unaffected
systems too much.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20240523171645.223225-1-sebastian.reichel@collabora.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/tcpm/tcpm.c

index 297136a7aa260f29fefbb10153451053c07f7f72..bac6866617c84c257e441f754111e2cbd582dfbc 100644 (file)
@@ -5208,6 +5208,8 @@ static void run_state_machine(struct tcpm_port *port)
        case HARD_RESET_SEND:
                if (port->ams != NONE_AMS)
                        tcpm_ams_finish(port);
+               if (!port->self_powered && port->port_type == TYPEC_PORT_SNK)
+                       dev_err(port->dev, "Initiating hard-reset, which might result in machine power-loss.\n");
                /*
                 * State machine will be directed to HARD_RESET_START,
                 * thus set upcoming_state to INVALID_STATE.