From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.13 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796386631; b=a/DqXZwKH5mPW5WxPne/PMBMSnVYQQYUjl3NO6LCqPFkB4cdhxG/YHIQbkzqZ7vMJhYA /ILFg6RutQFqnsw5MW+0PIgl1CxB1gaeqVxLAhdWloVaRgMg1LA8U+xAKo30gKmwY/nJX 8FD7/dzpNNXVbD4jCmNtqlp8gd9q2cIzopJDgoxhQ4gEzRDjNq6z896vKUQcnCDq/+7O/ fCzRSV0uhA6laRrBZ5yVeRMzLgAd9iZ8gS6+W7U8QxHG6gMHSZvY3gHquhpDbd15BQ3aT j5EJwTR8Ilf3+dfAFvEPgHpRrQQDAxX5KXQQWCsoqQXwRXaRYxLBoo85e5nLtfe5A3w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386631; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Received:Date:From:To: Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=y9t56FiDr0f93P6txqIcOVg8toWF6AIXyF1Mu6+Waps=; b=3cETVfrQBavB7qNG8uR2FLBNW34xSR121OwR0O/94G2yR0Do54o2k7YCSv8fzoG+FfMf pGuI3uGvTRr8RUr+B8M+ybvJpBwHodW8jHL9o+iUcdRJrc5QmdrE46cVZaJK//zkcE3O6 d7JRjYKtIqD7vkJVX2L1QyWep60Tib8PSjyZ8IOcJYfG9hZp0cjNG9Sk71jKbik5ncYq8 ncBSZudhYAHPgc4l2IdVYI3mpj3q1nXXC6Fhuz2WikjowmoLlgn2rl7vN5O8MQ2o2OZDT N83Ts0DcQ4LdiXQBOt6bAhZR3rcPaV8E8MZ8IQCOM2ERIQehSvpsp3IdguPOA1O+/dw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=VO9fL4vT; arc=none smtp.remote-ip=192.198.163.13 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A93C7606A322; Fri, 4 Dec 2026 12:17:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A93C7606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=VO9fL4vT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796386631; x=1827922631; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=y9t56FiDr0f93P6txqIcOVg8toWF6AIXyF1Mu6+Waps=; b=VO9fL4vTRKejSGNK0ftp3e1n9eBO6pq1UN6TXdK1babwqO1+J6bwbk0C HMAtnyK2BhTo4tx+Gss6gbQuwwZstvc0jZ+K9r3sjn36OKnLKYZDdQvaE BfNt14h4GOqZXDVTQhjyY7taRwO7mTHh53u4qTM+TkvypGtWYNdMnROoJ ZLaVgMjSEp7u//5cD2O7GI4H6jqcpuozGgxHZo3RWivaNj/bKtqZ8l8rh rDLZpO5D/vPlzWP0+7pcUzMtQ90hIqlQlQHnHfzHckr/MZz55o/rTdZuS HNcWe4iHaFaON5ogdDN/DHGAkyaO7MuxqZyta+2+Jg1Id/5lDjDtP7xHF A==; X-CSE-ConnectionGUID: mPpmaScyRky5kplFfYTmgw== X-CSE-MsgGUID: d0eqpazJRv+gGSmcrYtryA== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5340065" X-IronPort-AV: E=Sophos;i="6.29,78,1794902400"; d="scan'208";a="5340065" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 04:17:10 -0800 X-CSE-ConnectionGUID: j6dLM/t+RjKs3qx2mYilCQ== X-CSE-MsgGUID: K0cADTsNQp2tm8qeNl4jcw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,78,1794902400"; d="scan'208";a="14074617" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa002.jf.intel.com with ESMTP; 04 Dec 2026 04:17:08 -0800 Received: by black.igk.intel.com (Postfix, from userid 1008) id 03CA298; Fri, 04 Dec 2026 13:17:07 +0100 (CET) Date: Fri, 4 Dec 2026 13:17:06 +0100 From: Heikki Krogerus To: iasnezhkov@gmail.com Cc: gregkh@linuxfoundation.org, linux@roeck-us.net, badhri@google.com, shufan_lee@richtek.com, linux-usb@vger.kernel.org, phone-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] usb: typec: tcpm: restart DRP toggling on Ra/Open in TOGGLING Message-ID: References: <20261130222659.37286-1-iasnezhkov@gmail.com> X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261130222659.37286-1-iasnezhkov@gmail.com> On Mon, Nov 30, 2026 at 10:26:59PM +0000, Ilia Snezhkov via B4 Relay wrote: > From: Ilia Snezhkov > > When a DRP port using a TCPCI controller such as RT1711H/RT1715 or its > ETEK ET7303/ET7304 compatible silicon is connected via an e-marked > USB-C cable (for example to a USB-C PD charger whose own port is > temporarily open), the TCPC can stop DRP toggling during its Rp phase > upon detecting a single Ra pull-down, reporting CC_STATUS with > LOOKING4CONNECTION=0, CONNECTRESULT=0 (Rp), and (Ra, Open) or (Open, Ra). > > In _tcpm_cc_change(), case TOGGLING only transitions out of TOGGLING > for source (Rd), sink (Rp), audio accessory (Ra+Ra), and debug accessory > (Rd+Rd / Rp+Rp) states. (Ra, Open) and (Open, Ra) fall through with no > state change and no call to tcpm_start_toggling(). Because the TCPC has > already exited hardware toggling, the port remains stuck presenting > static Rp: PD chargers never see Rd and never source VBUS, and > subsequent USB host connections fail to enumerate until another > TCPC_CMD_LOOK4CONNECTION command is issued. (fusb302 already avoids this > internally by restarting toggling in fusb302_handle_togdone_src() on > unexpected CC states.) > > In _tcpm_cc_change(), under port->lock, when port->state is TOGGLING > on a TYPEC_PORT_DRP port and the reported CC state is (Ra, Open) or > (Open, Ra), restart DRP toggling starting in Rd via > tcpm_start_toggling(port, TYPEC_CC_RD). Starting the next cycle in Rd > lets an attached PD source detect Rd and apply VBUS instead of > immediately re-triggering Rp+Ra. If tcpm_start_toggling() fails (for > example on a transient bus error), fall back to SNK_UNATTACHED so the > state machine does not remain stuck in TOGGLING with hardware toggling > stopped. > > Per TCPCI Rev 2.0 Table 4-15, while LOOKING4CONNECTION=1 the CC1/CC2 > fields report Open/Open (00b), never Ra, so (Ra, Open) and (Open, Ra) > cannot false-trigger while a TCPCI controller is still toggling. > > The wedged (Ra, Open) failure mode was observed on an MT6789 smartphone > using an ETEK ET7303 TCPC (RT1711H/RT1715 compatible) with Anker and > Apple USB-C PD chargers over e-marked C-to-C cables. > > Fixes: f0690a25a140 ("staging: typec: USB Type-C Port Manager (tcpm)") > Cc: stable@vger.kernel.org > Signed-off-by: Ilia Snezhkov LGTM. But I hope Badhri has time to check this. FWIW: Acked-by: Heikki Krogerus > --- > Changes in v2: > - Move recovery from rt1711h_irq() in tcpci_rt1711h.c into > _tcpm_cc_change() case TOGGLING in tcpm.c, serializing all TCPC writes > under port->lock via tcpm_start_toggling(port, TYPEC_CC_RD). > - Fall back to SNK_UNATTACHED if tcpm_start_toggling() fails. > - Update Fixes tag to f0690a25a140 and add stable@vger.kernel.org to Cc > (per Heikki Krogerus). > > v1 (withdrawn): > https://lore.kernel.org/r/20261126003308.48940-1-iasnezhkov@gmail.com > > Testing note: > - Regression-tested on an MT6789 smartphone with ETEK ET7303/RT1715 > (tcpci_rt1711h without driver-local recovery) across 10 USB-C > PD/PPS, Type-C, and USB host attach/detach cycles in both > orientations with no regressions. > - The wedged CC_STATUS=0x01 (LOOKING4CONNECTION=0, Rp, Ra/Open) > failure mode was directly captured in ET7303 I2C registers on the > same board. > > Found and drafted with an AI coding assistant. > > drivers/usb/typec/tcpm/tcpm.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > index bf7fd63..91a7296 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -6624,6 +6624,14 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1, > tcpm_set_state(port, SRC_ATTACH_WAIT, 0); > else if (tcpm_port_is_debug_sink(port) || tcpm_port_is_sink(port)) > tcpm_set_state(port, SNK_ATTACH_WAIT, 0); > + else if (port->port_type == TYPEC_PORT_DRP && > + ((port->cc1 == TYPEC_CC_RA && > + port->cc2 == TYPEC_CC_OPEN) || > + (port->cc1 == TYPEC_CC_OPEN && > + port->cc2 == TYPEC_CC_RA))) { > + if (!tcpm_start_toggling(port, TYPEC_CC_RD)) > + tcpm_set_state(port, SNK_UNATTACHED, 0); > + } > break; > case CHECK_CONTAMINANT: > /* Wait for Toggling to be resumed */ > -- > 2.54.0 (Apple Git-157) > > -- heikki