Skip to contentSkip to conversation

usb: typec: tcpm: PSSourceOffTimer timeout in PR_Swap enters ERROR_RECOVERY

PATCH Superseded joswang 4 participants 7 messages Feb 9, 2025 – Feb 13, 2025

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

joswang

author
#0 lore raw

PATCH 1/1 usb: typec: tcpm: PSSourceOffTimer timeout in PR_Swap enters ERROR_RECOVERY

From: Jos Wang <[email protected]>

As PD2.0 spec ("6.5.6.2 PSSourceOffTimer"),the PSSourceOffTimer is used by the Policy Engine in Dual-Role Power device that is currently acting as a Sink to timeout on a PS_RDY Message during a Power Role Swap sequence. This condition leads to a Hard Reset for USB Type-A and Type-B Plugs and Error Recovery for Type-C plugs and return to USB Default Operation.

Therefore, after PSSourceOffTimer timeout, the tcpm state machine should switch from PR_SWAP_SNK_SRC_SINK_OFF to ERROR_RECOVERY. This can also solve the test items in the USB power delivery compliance test:
TEST.PD.PROT.SNK.12 PR_Swap – PSSourceOffTimer Timeout

[1] https://usb.org/document-library/usb-power-delivery-compliance-test-specification-0/USB_PD3_CTS_Q4_2025_OR.zip

Fixes f0690a25a140 ("staging: typec: USB Type-C Port Manager (tcpm)")
---
 drivers/usb/typec/tcpm/tcpm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +1 -2
index 47be450d2be3..6bf1a22c785a 100644
@@ -5591,8 +5591,7 @@ static void run_state_machine(struct tcpm_port *port)
 		tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB,
 						       port->pps_data.active, 0);
 		tcpm_set_charge(port, false);
-		tcpm_set_state(port, hard_reset_state(port),
-			       port->timings.ps_src_off_time);
+		tcpm_set_state(port, ERROR_RECOVERY, port->timings.ps_src_off_time);
 		break;
 	case PR_SWAP_SNK_SRC_SOURCE_ON:
 		tcpm_enable_auto_vbus_discharge(port, true);
Signature · 1 line
2.17.1
Tested-by on v1 1/1
#1 lore raw
Quoted 14 lines · joswang

From: Jos Wang <[email protected]>

As PD2.0 spec ("6.5.6.2 PSSourceOffTimer"),the PSSourceOffTimer is used by the Policy Engine in Dual-Role Power device that is currently acting as a Sink to timeout on a PS_RDY Message during a Power Role Swap sequence. This condition leads to a Hard Reset for USB Type-A and Type-B Plugs and Error Recovery for Type-C plugs and return to USB Default Operation.

Therefore, after PSSourceOffTimer timeout, the tcpm state machine should switch from PR_SWAP_SNK_SRC_SINK_OFF to ERROR_RECOVERY. This can also solve the test items in the USB power delivery compliance test:
TEST.PD.PROT.SNK.12 PR_Swap – PSSourceOffTimer Timeout

Quoted 6 lines

[1] https://usb.org/document-library/usb-power-delivery-compliance-test-specification-0/USB_PD3_CTS_Q4_2025_OR.zip

Fixes f0690a25a140 ("staging: typec: USB Type-C Port Manager (tcpm)")

Regards,

Amit

Quoted 18 lines
---
  drivers/usb/typec/tcpm/tcpm.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +1 -2
index 47be450d2be3..6bf1a22c785a 100644
@@ -5591,8 +5591,7 @@ static void run_state_machine(struct tcpm_port *port)
  		tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB,
  						       port->pps_data.active, 0);
  		tcpm_set_charge(port, false);
-		tcpm_set_state(port, hard_reset_state(port),
-			       port->timings.ps_src_off_time);
+		tcpm_set_state(port, ERROR_RECOVERY, port->timings.ps_src_off_time);
  		break;
  	case PR_SWAP_SNK_SRC_SOURCE_ON:
  		tcpm_enable_auto_vbus_discharge(port, true);
#2 lore raw
Quoted 4 lines · Amit Sunil Dhamne
Quoted 1 line · joswang

From: Jos Wang <[email protected]>

nit: From https://elixir.bootlin.com/linux/v6.13.1/source/Documentation/process/submitting-patches.rst#L619

- A ``from`` line specifying the patch author, followed by an empty line (only needed if the person sending the patch is not the author).

Given that you are the author, wondering why do you have an explicit "From:" ?

Quoted 2 lines
Quoted 2 lines

As PD2.0 spec ("6.5.6.2 PSSourceOffTimer"),the PSSourceOffTimer is

nit: https://elixir.bootlin.com/linux/v6.13.1/source/Documentation/process/submitting-patches.rst#L619

- The body of the explanation, line wrapped at 75 columns, which will be copied to the permanent changelog to describe this patch.

Quoted 10 lines
Quoted 10 lines

used by the Policy Engine in Dual-Role Power device that is currently acting as a Sink to timeout on a PS_RDY Message during a Power Role Swap sequence. This condition leads to a Hard Reset for USB Type-A and Type-B Plugs and Error Recovery for Type-C plugs and return to USB Default Operation.

Therefore, after PSSourceOffTimer timeout, the tcpm state machine should switch from PR_SWAP_SNK_SRC_SINK_OFF to ERROR_RECOVERY. This can also solve the test items in the USB power delivery compliance test:
TEST.PD.PROT.SNK.12 PR_Swap – PSSourceOffTimer Timeout

Thanks for fixing this !

Quoted 6 lines
Quoted 6 lines

[1] https://usb.org/document-library/usb-power-delivery-compliance-test-specification-0/USB_PD3_CTS_Q4_2025_OR.zip

Fixes f0690a25a140 ("staging: typec: USB Type-C Port Manager (tcpm)")

nit: Empty line not needed here.

Quoted 29 lines
Quoted 1 line

Regards,

Amit

Quoted 18 lines
---
  drivers/usb/typec/tcpm/tcpm.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +1 -2
index 47be450d2be3..6bf1a22c785a 100644
@@ -5591,8 +5591,7 @@ static void run_state_machine(struct tcpm_port *port)
              tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB,
                                                     port->pps_data.active, 0);
              tcpm_set_charge(port, false);
-             tcpm_set_state(port, hard_reset_state(port),
-                            port->timings.ps_src_off_time);
+             tcpm_set_state(port, ERROR_RECOVERY, port->timings.ps_src_off_time);
              break;
      case PR_SWAP_SNK_SRC_SOURCE_ON:
              tcpm_enable_auto_vbus_discharge(port, true);
author
#3 lore raw
Quoted 4 lines · Badhri Jagan Sridharan
Quoted 2 lines · Amit Sunil Dhamne
Quoted 9 lines
Quoted 2 lines · joswang
Quoted 1 line

From: Jos Wang <[email protected]>

nit: From https://elixir.bootlin.com/linux/v6.13.1/source/Documentation/process/submitting-patches.rst#L619

- A ``from`` line specifying the patch author, followed by an empty line (only needed if the person sending the patch is not the author).

Given that you are the author, wondering why do you have an explicit "From:" ?

Hello, thank you for your help in reviewing the code.
My company email address is [email protected], and my personal gmail email address is [email protected], which is used to send patches. Do you suggest deleting the "From:" line?
I am considering deleting the "From:" line, whether the author and Signed-off-by in the patch need to be changed to "[email protected]".

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

As PD2.0 spec ("6.5.6.2 PSSourceOffTimer"),the PSSourceOffTimer is

nit: https://elixir.bootlin.com/linux/v6.13.1/source/Documentation/process/submitting-patches.rst#L619

- The body of the explanation, line wrapped at 75 columns, which will be copied to the permanent changelog to describe this patch.

"As PD2.0 spec ("6.5.6.2 PSSourceOffTimer"),the PSSourceOffTimer is" This sentence doesn’t exceed 75 chars, right?

Quoted 15 lines
Quoted 11 lines
Quoted 11 lines

used by the Policy Engine in Dual-Role Power device that is currently acting as a Sink to timeout on a PS_RDY Message during a Power Role Swap sequence. This condition leads to a Hard Reset for USB Type-A and Type-B Plugs and Error Recovery for Type-C plugs and return to USB Default Operation.

Therefore, after PSSourceOffTimer timeout, the tcpm state machine should switch from PR_SWAP_SNK_SRC_SINK_OFF to ERROR_RECOVERY. This can also solve the test items in the USB power delivery compliance test:
TEST.PD.PROT.SNK.12 PR_Swap – PSSourceOffTimer Timeout

Thanks for fixing this !

Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

[1] https://usb.org/document-library/usb-power-delivery-compliance-test-specification-0/USB_PD3_CTS_Q4_2025_OR.zip

Fixes f0690a25a140 ("staging: typec: USB Type-C Port Manager (tcpm)")

nit: Empty line not needed here.

Modifications for the next version

Quoted 29 lines
Quoted 29 lines
Quoted 1 line

Regards,

Amit

Quoted 18 lines
---
  drivers/usb/typec/tcpm/tcpm.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +1 -2
index 47be450d2be3..6bf1a22c785a 100644
@@ -5591,8 +5591,7 @@ static void run_state_machine(struct tcpm_port *port)
              tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB,
                                                     port->pps_data.active, 0);
              tcpm_set_charge(port, false);
-             tcpm_set_state(port, hard_reset_state(port),
-                            port->timings.ps_src_off_time);
+             tcpm_set_state(port, ERROR_RECOVERY, port->timings.ps_src_off_time);
              break;
      case PR_SWAP_SNK_SRC_SOURCE_ON:
              tcpm_enable_auto_vbus_discharge(port, true);
#4 lore raw
Quoted 16 lines · Jos Wang
Quoted 4 lines · Badhri Jagan Sridharan
Quoted 2 lines · Amit Sunil Dhamne
Quoted 9 lines
Quoted 2 lines · joswang
Quoted 1 line

From: Jos Wang <[email protected]>

nit: From https://elixir.bootlin.com/linux/v6.13.1/source/Documentation/process/submitting-patches.rst#L619

- A ``from`` line specifying the patch author, followed by an empty line (only needed if the person sending the patch is not the author).

Given that you are the author, wondering why do you have an explicit "From:" ?

Quoted 7 lines

Hello, thank you for your help in reviewing the code.
My company email address is [email protected], and my personal gmail email address is [email protected], which is used to send patches. Do you suggest deleting the "From:" line?
I am considering deleting the "From:" line, whether the author and Signed-off-by in the patch need to be changed to "[email protected]".

Yes, changing signed-off to [email protected] will remove the need for "From:".
Go ahead with it if it makes sense on your side.

Quoted 10 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

As PD2.0 spec ("6.5.6.2 PSSourceOffTimer"),the PSSourceOffTimer is

nit: https://elixir.bootlin.com/linux/v6.13.1/source/Documentation/process/submitting-patches.rst#L619

- The body of the explanation, line wrapped at 75 columns, which will be copied to the permanent changelog to describe this patch.

"As PD2.0 spec ("6.5.6.2 PSSourceOffTimer"),the PSSourceOffTimer is" This sentence doesn’t exceed 75 chars, right?

Apparently, It actually needs to be wrapped around 75 columns, not too early either.

Thanks,
Badhri

Quoted 53 lines
Quoted 15 lines
Quoted 11 lines
Quoted 11 lines

used by the Policy Engine in Dual-Role Power device that is currently acting as a Sink to timeout on a PS_RDY Message during a Power Role Swap sequence. This condition leads to a Hard Reset for USB Type-A and Type-B Plugs and Error Recovery for Type-C plugs and return to USB Default Operation.

Therefore, after PSSourceOffTimer timeout, the tcpm state machine should switch from PR_SWAP_SNK_SRC_SINK_OFF to ERROR_RECOVERY. This can also solve the test items in the USB power delivery compliance test:
TEST.PD.PROT.SNK.12 PR_Swap – PSSourceOffTimer Timeout

Thanks for fixing this !

Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

[1] https://usb.org/document-library/usb-power-delivery-compliance-test-specification-0/USB_PD3_CTS_Q4_2025_OR.zip

Fixes f0690a25a140 ("staging: typec: USB Type-C Port Manager (tcpm)")

nit: Empty line not needed here.

Modifications for the next version

Quoted 29 lines
Quoted 29 lines
Quoted 1 line

Regards,

Amit

Quoted 18 lines
---
  drivers/usb/typec/tcpm/tcpm.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +1 -2
index 47be450d2be3..6bf1a22c785a 100644
@@ -5591,8 +5591,7 @@ static void run_state_machine(struct tcpm_port *port)
              tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB,
                                                     port->pps_data.active, 0);
              tcpm_set_charge(port, false);
-             tcpm_set_state(port, hard_reset_state(port),
-                            port->timings.ps_src_off_time);
+             tcpm_set_state(port, ERROR_RECOVERY, port->timings.ps_src_off_time);
              break;
      case PR_SWAP_SNK_SRC_SOURCE_ON:
              tcpm_enable_auto_vbus_discharge(port, true);
maintainer
#5 lore raw
Quoted 25 lines · Badhri Jagan Sridharan
Quoted 16 lines · Jos Wang
Quoted 4 lines · Badhri Jagan Sridharan
Quoted 2 lines · Amit Sunil Dhamne
Quoted 9 lines
Quoted 2 lines · joswang
Quoted 1 line

From: Jos Wang <[email protected]>

nit: From https://elixir.bootlin.com/linux/v6.13.1/source/Documentation/process/submitting-patches.rst#L619

- A ``from`` line specifying the patch author, followed by an empty line (only needed if the person sending the patch is not the author).

Given that you are the author, wondering why do you have an explicit "From:" ?

Quoted 7 lines

Hello, thank you for your help in reviewing the code.
My company email address is [email protected], and my personal gmail email address is [email protected], which is used to send patches. Do you suggest deleting the "From:" line?
I am considering deleting the "From:" line, whether the author and Signed-off-by in the patch need to be changed to "[email protected]".

Quoted 3 lines

Yes, changing signed-off to [email protected] will remove the need for "From:".
Go ahead with it if it makes sense on your side.

No, what was done here originally is correct, please do not ask people to not actually follow the correct procedure.

Jos, thank you, there is nothing wrong with the way you sent this.

thanks,

greg k-h

author
#6 lore raw
Quoted 31 lines · Greg KH
Quoted 25 lines · Badhri Jagan Sridharan
Quoted 16 lines · Jos Wang
Quoted 4 lines · Badhri Jagan Sridharan
Quoted 2 lines · Amit Sunil Dhamne
Quoted 9 lines
Quoted 2 lines · joswang
Quoted 1 line

From: Jos Wang <[email protected]>

nit: From https://elixir.bootlin.com/linux/v6.13.1/source/Documentation/process/submitting-patches.rst#L619

- A ``from`` line specifying the patch author, followed by an empty line (only needed if the person sending the patch is not the author).

Given that you are the author, wondering why do you have an explicit "From:" ?

Quoted 7 lines

Hello, thank you for your help in reviewing the code.
My company email address is [email protected], and my personal gmail email address is [email protected], which is used to send patches. Do you suggest deleting the "From:" line?
I am considering deleting the "From:" line, whether the author and Signed-off-by in the patch need to be changed to "[email protected]".

Quoted 3 lines

Yes, changing signed-off to [email protected] will remove the need for "From:".
Go ahead with it if it makes sense on your side.

Quoted 8 lines

No, what was done here originally is correct, please do not ask people to not actually follow the correct procedure.

Jos, thank you, there is nothing wrong with the way you sent this.

thanks,

greg k-h

Thanks,I will submit the v2 version patch soon.

Thanks,

Jos