From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793213044; b=ayKfPcQTmNsadCno83oqxUJ2cbfKmhH1SuDJbWPYvkxBpQl6qTXV1sNpL23IOdsvxg9Q pWrnspsrK4e7yM6msG9L/5DKfExFNJ5chOjDHm76lY5SlwFqdJZzOPVPcyPW4vnZdBPtD H720aBSMXLTTN3tRyU8DvqmuGUgR3jk278m4r0X+xo4B/1tp01TnZu/l8gOouzoYi4V3Y 1Ow3wRtsOY/ZFW1MeLtl9CAU2cqfgrDUarnvYVwNUD62SXsel+yoqYNSZoaPBh+1EKPSu EOJmWMt4WlVoCooctpKCR+B1uOYcaAoS/9S7ahRWVR691QH1lQHp8z72oUPMrkI0p1Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793213044; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=4GQf4YIUf8BmkUBaNjBTlb4QT22emzEeb5rxcw5her0=; b=J4O4StEmGVMKpUr87gF7QRt/0UE37k8kGLDaLkPQ06XEf6d9lm8dCwIhEgLLSNu9Rxyu EnJ5GffrjnO4tDej02wbEI0ANpZ9aei5em1HxsLEBod91Ln8wHS/gyJuTYz7UJ7EPlysm Sp7E14OyKjLdYLY02ZLbHCneadfYKEQHL7LnY3h8w1/NG2BudZiatXlS6f/1B2D5MXLXY +HaR5nQRa0LCeYnCjHZr9XJ9XO4/hhERpg4yehxcsDFnKqzM7/Q7oKIV9Y9/qvH4f0NvZ puLkEV2rFbbo1YKg5ULOvgAoLUJtrk/FlDEhG45mvuEXsllLUhiTDFE3ZH0HNWzf3WQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=teVAiVSO; arc=none 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 4E7BC606A321; Wed, 28 Oct 2026 18:44:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=teVAiVSO Received: by smtp.kernel.org (Postfix) with ESMTPSA id A14B41F01825; Wed, 28 Oct 2026 18:44:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793213044; bh=4GQf4YIUf8BmkUBaNjBTlb4QT22emzEeb5rxcw5her0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=teVAiVSOGvLp4c34mLoow2h5T1li6mlb3niqCXTznjKzCgUDTlDqLDID7iEGWP8hD KecCEIOC+5JOZ1/jBmAIme96vG9Dd6gczfeSH0nxW7lPkVGTUQcFhM4aU9vsWEnzyd Nnj4NVyi2FiCxzvg0kpPi5QEMZT9RIr6nqA4TOq8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Xu Yang , Heikki Krogerus , Amit Sunil Dhamne , Sasha Levin Subject: [PATCH 6.1 0367/1887] usb: typec: tcpm: fix debug accessory mode detection for sink ports Date: Wed, 28 Oct 2026 17:41:03 +0100 Message-ID: <20261028170507.585355608@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170459.200466217@linuxfoundation.org> References: <20261028170459.200466217@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xu Yang [ Upstream commit f6ec9bb4acc7182b25a793ad094a764e1cb819a7 ] The port in debug accessory mode can be either a source or sink. The previous tcpm_port_is_debug() function only checked for source port. Commit 8db73e6a42b6 ("usb: typec: tcpm: allow sink (ufp) to toggle into accessory mode debug") changed the detection logic to support both roles, but left some logic in _tcpm_cc_change() unchanged, This causes the state machine to transition to an incorrect state when operating as a sink in debug accessory mode. Log as below: [ 978.637541] CC1: 0 -> 5, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected] [ 978.637567] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS] [ 978.637596] pending state change SRC_ATTACH_WAIT -> DEBUG_ACC_ATTACHED @ 180 ms [rev1 NONE_AMS] [ 978.647098] CC1: 5 -> 0, CC2: 5 -> 5 [state SRC_ATTACH_WAIT, polarity 0, connected] [ 978.647115] state change SRC_ATTACH_WAIT -> SRC_ATTACH_WAIT [rev1 NONE_AMS] It should go to SNK_ATTACH_WAIT instead of SRC_ATTACH_WAIT state. To fix this, add tcpm_port_is_debug_source() and tcpm_port_is_debug_sink() helper to explicitly identify the power mode in debug accessory mode. Update the state transition logic in _tcpm_cc_change() to ensure the state machine transitions comply with Type-C specification. Also update the logic in run_state_machine() to keep consistency. Fixes: 8db73e6a42b6 ("usb: typec: tcpm: allow sink (ufp) to toggle into accessory mode debug") Cc: stable Signed-off-by: Xu Yang Acked-by: Heikki Krogerus Reviewed-by: Amit Sunil Dhamne Link: https://patch.msgid.link/20260424074009.2979266-1-xu.yang_2@nxp.com Signed-off-by: Greg Kroah-Hartman [Backport to 6.12: This tree lacks 8db73e6a42b6 and the associated sink debug-accessory state-machine support. Retain only the source-debug macro extraction and source-side call-site updates. Keep tcpm_port_is_debug() source-only and omit the sink-debug macro and all sink/audio attachment transitions introduced by the upstream dependency. This preserves existing detection and state transitions while providing tcpm_port_is_debug_source() for cd3b9cea675b ("usb: typec: tcpm: constrain TCPM_SOURCING_VBUS event handling"). No functions are added.] Stable-dep-of: cd3b9cea675b ("usb: typec: tcpm: constrain TCPM_SOURCING_VBUS event handling") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -522,9 +522,12 @@ static const char * const pd_rev[] = { (tcpm_cc_is_source((port)->cc2) && \ !tcpm_cc_is_source((port)->cc1))) -#define tcpm_port_is_debug(port) \ +#define tcpm_port_is_debug_source(port) \ (tcpm_cc_is_source((port)->cc1) && tcpm_cc_is_source((port)->cc2)) +#define tcpm_port_is_debug(port) \ + tcpm_port_is_debug_source(port) + #define tcpm_port_is_audio(port) \ (tcpm_cc_is_audio((port)->cc1) && tcpm_cc_is_audio((port)->cc2)) @@ -4023,7 +4026,7 @@ static void run_state_machine(struct tcp tcpm_set_state(port, SNK_UNATTACHED, PD_T_DRP_SNK); break; case SRC_ATTACH_WAIT: - if (tcpm_port_is_debug(port)) + if (tcpm_port_is_debug_source(port)) tcpm_set_state(port, DEBUG_ACC_ATTACHED, PD_T_CC_DEBOUNCE); else if (tcpm_port_is_audio(port)) @@ -5035,7 +5038,7 @@ static void _tcpm_cc_change(struct tcpm_ switch (port->state) { case TOGGLING: - if (tcpm_port_is_debug(port) || tcpm_port_is_audio(port) || + if (tcpm_port_is_debug_source(port) || tcpm_port_is_audio(port) || tcpm_port_is_source(port)) tcpm_set_state(port, SRC_ATTACH_WAIT, 0); else if (tcpm_port_is_sink(port)) @@ -5043,7 +5046,7 @@ static void _tcpm_cc_change(struct tcpm_ break; case SRC_UNATTACHED: case ACC_UNATTACHED: - if (tcpm_port_is_debug(port) || tcpm_port_is_audio(port) || + if (tcpm_port_is_debug_source(port) || tcpm_port_is_audio(port) || tcpm_port_is_source(port)) tcpm_set_state(port, SRC_ATTACH_WAIT, 0); break;