Skip to contentSkip to conversation

Revert "usb: typec: tcpm: fix cc role at port reset"

PATCH Superseded Badhri Jagan Sridharan 3 participants 5 messages Jan 17, 2024 – Jan 23, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Badhri Jagan Sridharan

author maintainer
#0 lore raw

PATCH 1/1 Revert "usb: typec: tcpm: fix cc role at port reset"

This reverts commit 1e35f074399dece73d5df11847d4a0d7a6f49434.

Given that ERROR_RECOVERY calls into PORT_RESET for Hi-Zing the CC pins, setting CC pins to default state during PORT_RESET breaks error recovery.

4.5.2.2.2.1 ErrorRecovery State Requirements
The port shall not drive VBUS or VCONN, and shall present a high-impedance to ground (above zOPEN) on its CC1 and CC2 pins.

Hi-Zing the CC pins is the inteded behavior for PORT_RESET. CC pins are set to default state after tErrorRecovery in PORT_RESET_WAIT_OFF.

4.5.2.2.2.2 Exiting From ErrorRecovery State
A Sink shall transition to Unattached.SNK after tErrorRecovery. A Source shall transition to Unattached.SRC after tErrorRecovery.

Fixes 1e35f074399d ("usb: typec: tcpm: fix cc role at port reset")
---
 drivers/usb/typec/tcpm/tcpm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +1 -2
index 5945e3a2b0f7..9d410718eaf4 100644
@@ -4876,8 +4876,7 @@ static void run_state_machine(struct tcpm_port *port)
 		break;
 	case PORT_RESET:
 		tcpm_reset_port(port);
-		tcpm_set_cc(port, tcpm_default_state(port) == SNK_UNATTACHED ?
-			    TYPEC_CC_RD : tcpm_rp_cc(port));
+		tcpm_set_cc(port, TYPEC_CC_OPEN);
 		tcpm_set_state(port, PORT_RESET_WAIT_OFF,
 			       PD_T_ERROR_RECOVERY);
 		break;

base-commit: 933bb7b878ddd0f8c094db45551a7daddf806e00

Signature · 1 line
2.43.0.429.g432eaa2c6b-goog
#1 lore raw
FYI: kernel test robot notices the stable kernel rule is not satisfied.

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH v1] Revert "usb: typec: tcpm: fix cc role at port reset"

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#2 lore raw
In reply to Badhri Jagan Sridharan

Hi all,

Please ignore this patch as I sent a V2 which fixes the commit message.

Thanks,
Badhri

Quoted 45 lines · Badhri Jagan Sridharan

This reverts commit 1e35f074399dece73d5df11847d4a0d7a6f49434.

Given that ERROR_RECOVERY calls into PORT_RESET for Hi-Zing the CC pins, setting CC pins to default state during PORT_RESET breaks error recovery.

4.5.2.2.2.1 ErrorRecovery State Requirements
The port shall not drive VBUS or VCONN, and shall present a high-impedance to ground (above zOPEN) on its CC1 and CC2 pins.

Hi-Zing the CC pins is the inteded behavior for PORT_RESET. CC pins are set to default state after tErrorRecovery in PORT_RESET_WAIT_OFF.

4.5.2.2.2.2 Exiting From ErrorRecovery State
A Sink shall transition to Unattached.SNK after tErrorRecovery. A Source shall transition to Unattached.SRC after tErrorRecovery.

Fixes 1e35f074399d ("usb: typec: tcpm: fix cc role at port reset")
---
 drivers/usb/typec/tcpm/tcpm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +1 -2
index 5945e3a2b0f7..9d410718eaf4 100644
@@ -4876,8 +4876,7 @@ static void run_state_machine(struct tcpm_port *port)
                break;
        case PORT_RESET:
                tcpm_reset_port(port);
-               tcpm_set_cc(port, tcpm_default_state(port) == SNK_UNATTACHED ?
-                           TYPEC_CC_RD : tcpm_rp_cc(port));
+               tcpm_set_cc(port, TYPEC_CC_OPEN);
                tcpm_set_state(port, PORT_RESET_WAIT_OFF,
                               PD_T_ERROR_RECOVERY);
                break;

base-commit: 933bb7b878ddd0f8c094db45551a7daddf806e00 --
2.43.0.429.g432eaa2c6b-goog

#3 lore raw
In reply to Badhri Jagan Sridharan

This will break operation of batteryless devices relying on a USB Type-C port for their power needs, as the port reset upon controller initialization will cause power to be cut to the device, resulting in a boot loop.
Devices using the FUSB302C port controller are especially severely affected, as upon losing power, this controller can retain CC states for a very long time (potentially forever if some parasitic source of power is present), requiring a full mechanical disconnect-reconnect cycle before the device receives power again.

While the USB Type C specification does require this behavior, I would consider this an oversight in the standard (perhaps left over from when USB Power Delivery was still going to be USB Battery Charging 2.0).

Badhri Jagan Sridharan <[email protected]> ezt írta (időpont: 2024. jan. 17., Sze, 12:38):

Quoted 46 lines

This reverts commit 1e35f074399dece73d5df11847d4a0d7a6f49434.

Given that ERROR_RECOVERY calls into PORT_RESET for Hi-Zing the CC pins, setting CC pins to default state during PORT_RESET breaks error recovery.

4.5.2.2.2.1 ErrorRecovery State Requirements
The port shall not drive VBUS or VCONN, and shall present a high-impedance to ground (above zOPEN) on its CC1 and CC2 pins.

Hi-Zing the CC pins is the inteded behavior for PORT_RESET. CC pins are set to default state after tErrorRecovery in PORT_RESET_WAIT_OFF.

4.5.2.2.2.2 Exiting From ErrorRecovery State
A Sink shall transition to Unattached.SNK after tErrorRecovery. A Source shall transition to Unattached.SRC after tErrorRecovery.

Fixes 1e35f074399d ("usb: typec: tcpm: fix cc role at port reset")
---
 drivers/usb/typec/tcpm/tcpm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +1 -2
index 5945e3a2b0f7..9d410718eaf4 100644
@@ -4876,8 +4876,7 @@ static void run_state_machine(struct tcpm_port *port)
                break;
        case PORT_RESET:
                tcpm_reset_port(port);
-               tcpm_set_cc(port, tcpm_default_state(port) == SNK_UNATTACHED ?
-                           TYPEC_CC_RD : tcpm_rp_cc(port));
+               tcpm_set_cc(port, TYPEC_CC_OPEN);
                tcpm_set_state(port, PORT_RESET_WAIT_OFF,
                               PD_T_ERROR_RECOVERY);
                break;

base-commit: 933bb7b878ddd0f8c094db45551a7daddf806e00 --
2.43.0.429.g432eaa2c6b-goog

author maintainer
#4 lore raw

Hi Gabor,

While HI-Zing CC pins disrupts power for batteryless devices, not Hi-Zing CC pins would prevent clean error recovery for self powered devices.
Hi-Zing CC pins would make the port partner recognize it as disconnect and will result in bringup the connection back cleanly.

How about leveraging "self-powered" device tree property and Hi-Zing CC pins only when using "self-powered" ?

Regards,
Badhri

Quoted 64 lines · Gábor Stefanik

This will break operation of batteryless devices relying on a USB Type-C port for their power needs, as the port reset upon controller initialization will cause power to be cut to the device, resulting in a boot loop.
Devices using the FUSB302C port controller are especially severely affected, as upon losing power, this controller can retain CC states for a very long time (potentially forever if some parasitic source of power is present), requiring a full mechanical disconnect-reconnect cycle before the device receives power again.

While the USB Type C specification does require this behavior, I would consider this an oversight in the standard (perhaps left over from when USB Power Delivery was still going to be USB Battery Charging 2.0).

Badhri Jagan Sridharan <[email protected]> ezt írta (időpont: 2024. jan. 17., Sze, 12:38):

Quoted 46 lines

This reverts commit 1e35f074399dece73d5df11847d4a0d7a6f49434.

Given that ERROR_RECOVERY calls into PORT_RESET for Hi-Zing the CC pins, setting CC pins to default state during PORT_RESET breaks error recovery.

4.5.2.2.2.1 ErrorRecovery State Requirements
The port shall not drive VBUS or VCONN, and shall present a high-impedance to ground (above zOPEN) on its CC1 and CC2 pins.

Hi-Zing the CC pins is the inteded behavior for PORT_RESET. CC pins are set to default state after tErrorRecovery in PORT_RESET_WAIT_OFF.

4.5.2.2.2.2 Exiting From ErrorRecovery State
A Sink shall transition to Unattached.SNK after tErrorRecovery. A Source shall transition to Unattached.SRC after tErrorRecovery.

Fixes 1e35f074399d ("usb: typec: tcpm: fix cc role at port reset")
---
 drivers/usb/typec/tcpm/tcpm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +1 -2
index 5945e3a2b0f7..9d410718eaf4 100644
@@ -4876,8 +4876,7 @@ static void run_state_machine(struct tcpm_port *port)
                break;
        case PORT_RESET:
                tcpm_reset_port(port);
-               tcpm_set_cc(port, tcpm_default_state(port) == SNK_UNATTACHED ?
-                           TYPEC_CC_RD : tcpm_rp_cc(port));
+               tcpm_set_cc(port, TYPEC_CC_OPEN);
                tcpm_set_state(port, PORT_RESET_WAIT_OFF,
                               PD_T_ERROR_RECOVERY);
                break;

base-commit: 933bb7b878ddd0f8c094db45551a7daddf806e00 --
2.43.0.429.g432eaa2c6b-goog