From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796077633; b=KkoQS3b18B9XwR1fTMkVltQYxBOJIjmaAKMOYjUOkH7jn+9CM32XZ2Yo7NSzmoiLYyak nfjHHad/hKNreBmE6vWLhPvLn6S2J7xhYyUpE1oZsdJGWWcH1+vP51/oklg55fYD9Xfst ROrxRw17Op4dFMaD516zrh7CS/vdhWsIf2G9VOzmlB4gqfiEZ6T0ZMvoeu2K7vtvQFJfN AMmhgjCHcPMrU+qdMRnrl/8ViwtAQAPI9UTUNLvtNkPNaZ97elqszCUrcDUQ6OajFujVf WPs5JuMf8HB5KpPs6swa0pcZaskaCk+LcnxgX3bEYriytMQi/9qKWOEkpxxjXNmxJcA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796077633; h=Received:DKIM-Signature:Received:From:To:Cc:Subject:Date:Message-Id: MIME-Version:Content-Type:X-Mailer:X-Developer-Signature: X-Developer-Key:X-Endpoint-Received:X-Original-From:Reply-To: Content-Transfer-Encoding; bh=nX1XaJ/MZdHiwxueZNmwVU0tfBKIlu6euKoQ3y+HQVQ=; b=HRQxAeEV/eiNBZEgNCTp9JY/t8NtDEUYT76ow/ugpWPWg9Z1duPzVlFcHaQEv70NDtIc OnDrzgzPmKSptqDN/yA61rn+rzt0Y8z0Gu57uvhzWYlDyubJqj70ilF+VItK7Qbt/3Gfv 9f1d9ZjFOq05QucYci4FkD+plkeR/pZsZI18sL+ZB3nez67fDwdxX1uUZOYjZ5srNj8w/ HTEbHS19ciDvjYG+tLAgNyxT59hLZf2CZ8rqaiBg6gRF/Fc7ljAoKiorL0/tczgOtival fJqQzCSsa98gU0x4TBFBy+G+z2ofKlSV0AOsFYD1rSBwutVhytxxmeMOZd70VnYho8Q== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fe5EkThd; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AAFD606A336; Mon, 30 Nov 2026 22:27:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fe5EkThd Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796077632; b=l1KSxo+w4D5Nvs4zvqQYj98F/tQ2YbAYJGfg2X9YA9DWcUYr/AClpdXLUVKX7KCUFu+D vxdrrR/mG/gwsVYnQuaao1SZOXaO5eKJM5P1WvasqZq94ZwRJYtYvoTe+XylpNOjYKObc j45C4EFCyE2gBRGIFZ9mQUFYL+IOpJnD7G4MCNHLZlc61rRgLUwQTBrZzKplhG+CCdiBh Fr1aTw0+j5A59zgJUXwBjXDlsnGJBNamwFdWoljs02lUUdCZmvh2iIpV/X4+4CCYytKXs UN7T+79/P1SKLUwRK42S2omSXY7ikDCoCFPDhG/1/W4X/0ZJ/KBBlGHqH/udz0zBm8g== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796077632; h=DKIM-Signature:Received:From:To:Cc:Subject:Date:Message-Id: MIME-Version:Content-Type:X-Mailer:X-Developer-Signature: X-Developer-Key:X-Endpoint-Received:X-Original-From:Reply-To: Content-Transfer-Encoding; bh=nX1XaJ/MZdHiwxueZNmwVU0tfBKIlu6euKoQ3y+HQVQ=; b=cGsHIe9KhGl6QeXHFe40pdN88GsUQOhjTre8ksOObc2LNYuDWeEmGsqG3ovh+yBxKhl/ BZDrDahH75dGq6o96xy5+XrBDspwbLSJfs+QURmhdW9xjw7WZBrIncxEdshQsAhUrM79O 0GH+m4tOAaty+bc0s9ypnD2/jarUZXpzfeSBqNkdyE/a1L9LfwmBiAFh28hgA2CLnR2vr iybHASTTSMXZ5phm/1Tk+ZjrFpo4XUF2GsHg553uUHzK2xcGjPxkLHWa+UZQnw4u1Q8sh KfE6SD5WgFSmWLGjECTDacjZADPS0DcD7totxAWdkpvQs4RvXmLbBBxSFtajCLD9EMQ== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 7281B1F0089B; Mon, 30 Nov 2026 22:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796077632; bh=nX1XaJ/MZdHiwxueZNmwVU0tfBKIlu6euKoQ3y+HQVQ=; h=From:To:Cc:Subject:Date:Reply-To; b=fe5EkThdfKNgDxP26Xoop74pEQHOuAQo7Z2jUPgPdL20quRH05PKWw8/Su91mRL+F PmYvFjugHnMC5oF4dDvUC8DQY4/DbHD0I7Ra9FgRKeDJuA5AuaH0thHP+Gce98oz+5 4QK5wnStyPGIGOxRbfj5zTv+j5J8NMDtKEGDe5xfTmSyPD12maowEO9vWGHQvBRgtv 6baVOJIagYouailhuVt91cTpLW7KjPeHtuACqcTfb0CE/PQwX19kPuQe+xvQ1QrUUX a538BxT0IVYEvO7F+lUtokRZJfyZpnKqZhcaQgXixvStYjiYj42NPGu3CnJitYFtWB h5gvXxn+IwVWA== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 05BA24EA0E; Mon, 30 Nov 2026 22:27:00 +0000 (UTC) From: Ilia Snezhkov via B4 Relay To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, linux@roeck-us.net Cc: badhri@google.com, shufan_lee@richtek.com, linux-usb@vger.kernel.org, phone-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] usb: typec: tcpm: restart DRP toggling on Ra/Open in TOGGLING Date: Mon, 30 Nov 2026 22:26:59 +0000 Message-Id: <20261130222659.37286-1-iasnezhkov@gmail.com> X-Mailing-List: linux-kernel@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="utf-8" X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796077619; l=4051; i=iasnezhkov@gmail.com; s=mindone2026; h=from:subject:message-id; bh=9Z8nBwuB1zW4ozK+k2wk3A0sClbSTvQ1HSrJdcMNBjs=; b=KcOHes/v53ASlZxtQry+gvbOGB6jSGrUfLtQHsFKK7U3Kp+v4WU1BP4ZhWGHmzzYSKKFWz8uj aH7dNNsBDRdAlqONEorKTIEJa8I+57kTyyxxdlXPTrKgUuofrASGhMH X-Developer-Key: i=iasnezhkov@gmail.com; a=ed25519; pk=hQgXfiWi4ukk2jh4BHu1vRVhg9BUivo//AFp50AKMag= X-Endpoint-Received: by B4 Relay for iasnezhkov@gmail.com/mindone2026 with auth_id=1643 X-Original-From: Ilia Snezhkov Reply-To: iasnezhkov@gmail.com Content-Transfer-Encoding: 7bit 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 --- 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)