Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] usb: typec: Find a Type-C partner after a warm reboot on the Orange Pi 5
@ 2026-11-26  9:19 Arun Iyengar via B4 Relay
  2026-11-26  9:19 ` [PATCH v3 1/2] usb: typec: tcpm: Don't cut a pending state delay short on a re-queue Arun Iyengar via B4 Relay
  2026-11-26  9:19 ` [PATCH v3 2/2] usb: typec: fusb302: Toggle with the default Rp current Arun Iyengar via B4 Relay
  0 siblings, 2 replies; 5+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-26  9:19 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman,
	Guenter Roeck, Heiko Stuebner
  Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-rockchip,
	Arun Iyengar, stable

After a warm reboot, an Orange Pi 5 (FUSB302) often did not find a
USB-C to DisplayPort cable that stayed plugged in; only a replug
brought DisplayPort back. Two causes:

  1. tcpm: a re-queue at port registration cut the 100 ms
     ErrorRecovery after PORT_RESET to 6 us.
  2. fusb302: the chip never found this cable while toggling with
     Rp 3.0A.

Tested on an Orange Pi 5 with a USB-C DisplayPort monitor: DP alt mode
on 16/16 warm reboots. Not tested: other TCPCs, ports without PD.

Developed with Claude (Anthropic), which wrote the code and the commit
messages. I reviewed every change.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Changes in v3:
- Patch 2: Cc stable (Heikki Krogerus)
- Code comments dropped, shorter messages, no functional change
- Link to v2: https://patch.msgid.link/20261112-tcpm-attach-reboot-v2-0-b4bc6ca83490@gmail.com

---
Arun Iyengar (2):
      usb: typec: tcpm: Don't cut a pending state delay short on a re-queue
      usb: typec: fusb302: Toggle with the default Rp current

 drivers/usb/typec/tcpm/fusb302.c | 12 ++++++++++--
 drivers/usb/typec/tcpm/tcpm.c    |  5 +++++
 2 files changed, 15 insertions(+), 2 deletions(-)
---
base-commit: 90d6263e867be7089b3d3323bef8d2accd327c77
change-id: 20261110-tcpm-attach-reboot-d93d5f36403b

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/2] usb: typec: tcpm: Don't cut a pending state delay short on a re-queue
  2026-11-26  9:19 [PATCH v3 0/2] usb: typec: Find a Type-C partner after a warm reboot on the Orange Pi 5 Arun Iyengar via B4 Relay
@ 2026-11-26  9:19 ` Arun Iyengar via B4 Relay
  2026-11-30 13:47   ` Heikki Krogerus
  2026-11-26  9:19 ` [PATCH v3 2/2] usb: typec: fusb302: Toggle with the default Rp current Arun Iyengar via B4 Relay
  1 sibling, 1 reply; 5+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-26  9:19 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman,
	Guenter Roeck, Heiko Stuebner
  Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-rockchip,
	Arun Iyengar, stable

From: Arun Iyengar <aiyengar1990@gmail.com>

A re-queue while the work runs applies a pending delayed state at once
(the 100 ms ErrorRecovery took 6 us). Re-arm the timer for the time left.

Fixes: 3ed8e1c2ac99 ("usb: typec: tcpm: Migrate workqueue to RT priority for processing events")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 51e5c72799f2..565073b4ca93 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -6572,6 +6572,11 @@ static void tcpm_state_machine_work(struct kthread_work *work)
 
 	/* If we were queued due to a delayed state change, update it now */
 	if (port->delayed_state) {
+		if (ktime_after(port->delayed_runtime, ktime_get())) {
+			hrtimer_start(&port->state_machine_timer,
+				      port->delayed_runtime, HRTIMER_MODE_ABS);
+			goto done;
+		}
 		tcpm_log(port, "state change %s -> %s [delayed %ld ms]",
 			 tcpm_states[port->state],
 			 tcpm_states[port->delayed_state], port->delay_ms);

-- 
2.55.0




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/2] usb: typec: fusb302: Toggle with the default Rp current
  2026-11-26  9:19 [PATCH v3 0/2] usb: typec: Find a Type-C partner after a warm reboot on the Orange Pi 5 Arun Iyengar via B4 Relay
  2026-11-26  9:19 ` [PATCH v3 1/2] usb: typec: tcpm: Don't cut a pending state delay short on a re-queue Arun Iyengar via B4 Relay
@ 2026-11-26  9:19 ` Arun Iyengar via B4 Relay
  2026-11-30 13:50   ` Heikki Krogerus
  1 sibling, 1 reply; 5+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-26  9:19 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman,
	Guenter Roeck, Heiko Stuebner
  Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-rockchip,
	Arun Iyengar, stable

From: Arun Iyengar <aiyengar1990@gmail.com>

The FUSB302 does not detect some sinks while toggling with Rp 3.0A.
Toggle with the default current and set the requested one on attach.

Fixes: c034a43e72dd ("staging: typec: Fairchild FUSB302 Type-c chip driver")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/usb/typec/tcpm/fusb302.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
index 83bd287dadc7..64d02cc0ecae 100644
--- a/drivers/usb/typec/tcpm/fusb302.c
+++ b/drivers/usb/typec/tcpm/fusb302.c
@@ -97,6 +97,7 @@ struct fusb302_chip {
 	/* chip status */
 	enum toggling_mode toggling_mode;
 	enum src_current_status src_current_status;
+	enum src_current_status toggling_src_current;
 	bool intr_togdone;
 	bool intr_bc_lvl;
 	bool intr_comp_chng;
@@ -942,10 +943,11 @@ static int tcpm_start_toggling(struct tcpc_dev *dev,
 	}
 
 	mutex_lock(&chip->lock);
-	ret = fusb302_set_src_current(chip, cc_src_current[cc]);
+	chip->toggling_src_current = cc_src_current[cc];
+	ret = fusb302_set_src_current(chip, SRC_CURRENT_DEFAULT);
 	if (ret < 0) {
 		fusb302_log(chip, "unable to set src current %s, ret=%d",
-			    typec_cc_status_name[cc], ret);
+			    typec_cc_status_name[TYPEC_CC_RP_DEF], ret);
 		goto done;
 	}
 	ret = fusb302_set_toggling(chip, mode);
@@ -1357,6 +1359,12 @@ static int fusb302_handle_togdone_src(struct fusb302_chip *chip,
 			    typec_cc_status_name[cc2]);
 		return fusb302_set_toggling(chip, toggling_mode);
 	}
+	ret = fusb302_set_src_current(chip, chip->toggling_src_current);
+	if (ret < 0) {
+		fusb302_log(chip, "cannot set src current, ret=%d", ret);
+		return ret;
+	}
+	rd_mda = rd_mda_value[chip->src_current_status];
 	/* set polarity and pull_up, pull_down */
 	ret = fusb302_set_cc_polarity_and_pull(chip, cc_polarity, true, false);
 	if (ret < 0) {

-- 
2.55.0




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 1/2] usb: typec: tcpm: Don't cut a pending state delay short on a re-queue
  2026-11-26  9:19 ` [PATCH v3 1/2] usb: typec: tcpm: Don't cut a pending state delay short on a re-queue Arun Iyengar via B4 Relay
@ 2026-11-30 13:47   ` Heikki Krogerus
  0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2026-11-30 13:47 UTC (permalink / raw)
  To: aiyengar1990
  Cc: Badhri Jagan Sridharan, Greg Kroah-Hartman, Guenter Roeck,
	Heiko Stuebner, linux-usb, linux-kernel, linux-arm-kernel,
	linux-rockchip, stable

On Thu, Nov 26, 2026 at 09:19:21AM +0000, Arun Iyengar via B4 Relay wrote:
> From: Arun Iyengar <aiyengar1990@gmail.com>
> 
> A re-queue while the work runs applies a pending delayed state at once
> (the 100 ms ErrorRecovery took 6 us). Re-arm the timer for the time left.
> 
> Fixes: 3ed8e1c2ac99 ("usb: typec: tcpm: Migrate workqueue to RT priority for processing events")
> Cc: stable@vger.kernel.org
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 51e5c72799f2..565073b4ca93 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -6572,6 +6572,11 @@ static void tcpm_state_machine_work(struct kthread_work *work)
>  
>  	/* If we were queued due to a delayed state change, update it now */
>  	if (port->delayed_state) {
> +		if (ktime_after(port->delayed_runtime, ktime_get())) {
> +			hrtimer_start(&port->state_machine_timer,
> +				      port->delayed_runtime, HRTIMER_MODE_ABS);
> +			goto done;
> +		}
>  		tcpm_log(port, "state change %s -> %s [delayed %ld ms]",
>  			 tcpm_states[port->state],
>  			 tcpm_states[port->delayed_state], port->delay_ms);
> 
> -- 
> 2.55.0
> 
> 

-- 
heikki


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 2/2] usb: typec: fusb302: Toggle with the default Rp current
  2026-11-26  9:19 ` [PATCH v3 2/2] usb: typec: fusb302: Toggle with the default Rp current Arun Iyengar via B4 Relay
@ 2026-11-30 13:50   ` Heikki Krogerus
  0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2026-11-30 13:50 UTC (permalink / raw)
  To: aiyengar1990
  Cc: Badhri Jagan Sridharan, Greg Kroah-Hartman, Guenter Roeck,
	Heiko Stuebner, linux-usb, linux-kernel, linux-arm-kernel,
	linux-rockchip, stable

On Thu, Nov 26, 2026 at 09:19:22AM +0000, Arun Iyengar via B4 Relay wrote:
> From: Arun Iyengar <aiyengar1990@gmail.com>
> 
> The FUSB302 does not detect some sinks while toggling with Rp 3.0A.
> Toggle with the default current and set the requested one on attach.
> 
> Fixes: c034a43e72dd ("staging: typec: Fairchild FUSB302 Type-c chip driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm/fusb302.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
> index 83bd287dadc7..64d02cc0ecae 100644
> --- a/drivers/usb/typec/tcpm/fusb302.c
> +++ b/drivers/usb/typec/tcpm/fusb302.c
> @@ -97,6 +97,7 @@ struct fusb302_chip {
>  	/* chip status */
>  	enum toggling_mode toggling_mode;
>  	enum src_current_status src_current_status;
> +	enum src_current_status toggling_src_current;
>  	bool intr_togdone;
>  	bool intr_bc_lvl;
>  	bool intr_comp_chng;
> @@ -942,10 +943,11 @@ static int tcpm_start_toggling(struct tcpc_dev *dev,
>  	}
>  
>  	mutex_lock(&chip->lock);
> -	ret = fusb302_set_src_current(chip, cc_src_current[cc]);
> +	chip->toggling_src_current = cc_src_current[cc];
> +	ret = fusb302_set_src_current(chip, SRC_CURRENT_DEFAULT);
>  	if (ret < 0) {
>  		fusb302_log(chip, "unable to set src current %s, ret=%d",
> -			    typec_cc_status_name[cc], ret);
> +			    typec_cc_status_name[TYPEC_CC_RP_DEF], ret);
>  		goto done;
>  	}
>  	ret = fusb302_set_toggling(chip, mode);
> @@ -1357,6 +1359,12 @@ static int fusb302_handle_togdone_src(struct fusb302_chip *chip,
>  			    typec_cc_status_name[cc2]);
>  		return fusb302_set_toggling(chip, toggling_mode);
>  	}
> +	ret = fusb302_set_src_current(chip, chip->toggling_src_current);
> +	if (ret < 0) {
> +		fusb302_log(chip, "cannot set src current, ret=%d", ret);
> +		return ret;
> +	}
> +	rd_mda = rd_mda_value[chip->src_current_status];
>  	/* set polarity and pull_up, pull_down */
>  	ret = fusb302_set_cc_polarity_and_pull(chip, cc_polarity, true, false);
>  	if (ret < 0) {
> 
> -- 
> 2.55.0
> 
> 

-- 
heikki


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-30 14:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  9:19 [PATCH v3 0/2] usb: typec: Find a Type-C partner after a warm reboot on the Orange Pi 5 Arun Iyengar via B4 Relay
2026-11-26  9:19 ` [PATCH v3 1/2] usb: typec: tcpm: Don't cut a pending state delay short on a re-queue Arun Iyengar via B4 Relay
2026-11-30 13:47   ` Heikki Krogerus
2026-11-26  9:19 ` [PATCH v3 2/2] usb: typec: fusb302: Toggle with the default Rp current Arun Iyengar via B4 Relay
2026-11-30 13:50   ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox