From nobody Sun Apr 5 13:20:01 2026 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 538FE3DA5BB for ; Tue, 24 Mar 2026 09:02:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774342953; cv=none; b=Yj6Nm9g7VrNsCL56M0HskRJhPsvTwUYhoxN4JuGMhKpDeGiTl9B0wbmWbyeAtaMUlY7lFVblGpoFTpXXbTPzF+4BBmwZnCXRCjqOR9VCrqzEkiRUkNPu66fzgiQwmf0kXlkK7skgtTOKrVzvIcfVTaPE7EMVXxiLF7nlYgsh15o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774342953; c=relaxed/simple; bh=aTm6Xu1isAhzPk4bIIK5Y2FaiAaAFekgp6c80IYWzes=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=oXTQg5PDjmAlSLhHmnAyaeQT8VBVSCME194bo91vNxss70aAw5qDSGMbj+fje70b3JQM63tGYjZT9rEqi/YXYu0d/YnNMYkQ3MAkbBKTSaFvIPBL4+y2Yz4m7+5xLMZWoVEbMCEu+sQQ4TCE9qltCqvUjW/snazpK63Fp6pFIRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=HYuAeZCF; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="HYuAeZCF" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-b97f9587e6eso696670866b.3 for ; Tue, 24 Mar 2026 02:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1774342949; x=1774947749; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OtkRrxgSSdlkWo4XCyDaok2JSx4EdzvQO1vwg8DFaWA=; b=HYuAeZCFZK2+MwVc9bcDsdxVWAJJm/v8C/l0583lWJ9kgY9bWbgEi2Y+Ii0gVq0hsg wJ6gEifrHVb0sTHnt2W65ODrJvw/aZFCHdmxRTeFdsuBAdMgeTSq8LLVkFvZXcvqtC7v U1braR5X0DdzqYYm9weoWhIRbCTDij8d0I5k8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774342949; x=1774947749; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OtkRrxgSSdlkWo4XCyDaok2JSx4EdzvQO1vwg8DFaWA=; b=AL1rXztH4yvkpfPk+Q8cAqqK0d7468Nua+I6XevuWjsg3bPeal3z5/VzJqZUqj7RdD L0o8kndd5GuTApdNpu0LZkkNFGUSEFTdvbrltYBQBrUaxq7YhO9tIy4ujzIhYA6zughx 6tINRYnxH6hJ1TN8vWrSkinuGdEURIuzF3u/IjN8vuo2vY2LVXFe+aWQMTG/BEugg9GE 6NpAjN4+czdxSWU0A9ZUHwLF30W2DZEPF3OPmOE2pY0NVeGeMZKKxETinSCJ0F1GZsyE eDBX9kE/rtp58ogRvEsmyJxMnGR0ltDBNnHSVoM47dyDlfP0qzzMpBM9mCJImaZmqGd4 tEZA== X-Forwarded-Encrypted: i=1; AJvYcCXeXrQYZulfOlpa7aCVFToNPiDViutATa0cJGbhdBwSUOhrwOLe1RvkF/qVmlZa2mZsh+3IZCUQPkNtaZY=@vger.kernel.org X-Gm-Message-State: AOJu0YwwfVpcQc9piHhDnNQiC9UGKqVrYbMBeqoVCc1o4demi18HEAoH VIjTfh1p5FDWczZLDdMmEkMIVgiBfBmujQSjgFolOAlB/w1FLiCcgw+dKeTIRFIl+g== X-Gm-Gg: ATEYQzyo1tvREYlUfs5vMof66gDGeCAOUynVGaGzuTtzVaRRjV493l2eMiZAufSi6q/ vAyL1b/Ssenlo4Mr9jRiv/NnxWSDk6apysFcE6ctTOyNk1iGqw/KPiLx4ifGEReKGQcRYeSsJAA wJBOoPeUUoGTycoDhZYLJX70JOvxdbrUTmd6N0XjvDabcWPXg3fI3544AmqXeMPPviZP1Q0GIS9 HSQGOj6mAefm/xJikeQMGNQbGVNido1XK+MC2vGr/1yxQeu9wmaGpeey4wIwPmnblLPRv2Y5Cjh SCkpGapSpdWb0yETPXJh/F+2VrIhoysh3DWUVsmDQoRCfWefgGup00V5EfyRCcG52dxZuKL706G dsU16rf7m2irWWoOJ3lIaA6CdJ50CGSGPIjp3u8ppeyAFO/lgGgML9QuAlGkozPKfpWhu9ymnpJ xwYeNGhwe/y5I0h0Ipc4Bir2jQEfQ1LL8caOMBqY6Y9MEr+JSE4ybtR2xQUyS3KDCjnbg0+4jCa fSvpDdqSO1G85cpxRm+CX9WnnnYdh6tuw== X-Received: by 2002:a17:907:8b89:b0:b97:b6ef:fc94 with SMTP id a640c23a62f3a-b982f20d5acmr990094766b.19.1774342949204; Tue, 24 Mar 2026 02:02:29 -0700 (PDT) Received: from akuchynski.c.googlers.com.com (218.127.147.34.bc.googleusercontent.com. [34.147.127.218]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b983365a1adsm604873166b.45.2026.03.24.02.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 02:02:28 -0700 (PDT) From: Andrei Kuchynski To: Heikki Krogerus , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Andrei Kuchynski , Madhu M Subject: [PATCH] usb: typec: thunderbolt: Set enter_vdo during initialization Date: Tue, 24 Mar 2026 09:02:23 +0000 Message-ID: <20260324090223.919832-1-akuchynski@chromium.org> X-Mailer: git-send-email 2.53.0.983.g0bb29b3bc5-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In the current implementation, if a cable's alternate mode enter operation is not supported, the tbt->plug[TYPEC_PLUG_SOP_P] pointer is cleared by the time tbt_enter_mode() is called. This prevents the driver from identifying the cable's VDO. As a result, the Thunderbolt connection falls back to the default TBT_CABLE_USB3_PASSIVE speed, even if the cable supports higher speeds. To ensure the correct VDO value is used during mode entry, calculate and store the enter_vdo earlier during the initialization phase in tbt_ready(). Tested-by: Madhu M Signed-off-by: Andrei Kuchynski Reviewed-by: Heikki Krogerus --- drivers/usb/typec/altmodes/thunderbolt.c | 44 ++++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/usb/typec/altmodes/thunderbolt.c b/drivers/usb/typec/a= ltmodes/thunderbolt.c index c4c5da6154da9..32250b94262a9 100644 --- a/drivers/usb/typec/altmodes/thunderbolt.c +++ b/drivers/usb/typec/altmodes/thunderbolt.c @@ -39,28 +39,7 @@ static bool tbt_ready(struct typec_altmode *alt); =20 static int tbt_enter_mode(struct tbt_altmode *tbt) { - struct typec_altmode *plug =3D tbt->plug[TYPEC_PLUG_SOP_P]; - u32 vdo; - - vdo =3D tbt->alt->vdo & (TBT_VENDOR_SPECIFIC_B0 | TBT_VENDOR_SPECIFIC_B1); - vdo |=3D tbt->alt->vdo & TBT_INTEL_SPECIFIC_B0; - vdo |=3D TBT_MODE; - - if (plug) { - if (typec_cable_is_active(tbt->cable)) - vdo |=3D TBT_ENTER_MODE_ACTIVE_CABLE; - - vdo |=3D TBT_ENTER_MODE_CABLE_SPEED(TBT_CABLE_SPEED(plug->vdo)); - vdo |=3D plug->vdo & TBT_CABLE_ROUNDED; - vdo |=3D plug->vdo & TBT_CABLE_OPTICAL; - vdo |=3D plug->vdo & TBT_CABLE_RETIMER; - vdo |=3D plug->vdo & TBT_CABLE_LINK_TRAINING; - } else { - vdo |=3D TBT_ENTER_MODE_CABLE_SPEED(TBT_CABLE_USB3_PASSIVE); - } - - tbt->enter_vdo =3D vdo; - return typec_altmode_enter(tbt->alt, &vdo); + return typec_altmode_enter(tbt->alt, &tbt->enter_vdo); } =20 static void tbt_altmode_work(struct work_struct *work) @@ -337,6 +316,7 @@ static bool tbt_ready(struct typec_altmode *alt) { struct tbt_altmode *tbt =3D typec_altmode_get_drvdata(alt); struct typec_altmode *plug; + u32 vdo; =20 if (tbt->cable) return true; @@ -364,6 +344,26 @@ static bool tbt_ready(struct typec_altmode *alt) tbt->plug[i] =3D plug; } =20 + vdo =3D tbt->alt->vdo & (TBT_VENDOR_SPECIFIC_B0 | TBT_VENDOR_SPECIFIC_B1); + vdo |=3D tbt->alt->vdo & TBT_INTEL_SPECIFIC_B0; + vdo |=3D TBT_MODE; + plug =3D tbt->plug[TYPEC_PLUG_SOP_P]; + + if (plug) { + if (typec_cable_is_active(tbt->cable)) + vdo |=3D TBT_ENTER_MODE_ACTIVE_CABLE; + + vdo |=3D TBT_ENTER_MODE_CABLE_SPEED(TBT_CABLE_SPEED(plug->vdo)); + vdo |=3D plug->vdo & TBT_CABLE_ROUNDED; + vdo |=3D plug->vdo & TBT_CABLE_OPTICAL; + vdo |=3D plug->vdo & TBT_CABLE_RETIMER; + vdo |=3D plug->vdo & TBT_CABLE_LINK_TRAINING; + } else { + vdo |=3D TBT_ENTER_MODE_CABLE_SPEED(TBT_CABLE_USB3_PASSIVE); + } + + tbt->enter_vdo =3D vdo; + return true; } =20 --=20 2.53.0.983.g0bb29b3bc5-goog