From nobody Fri Apr 3 16:14:02 2026 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.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 776D63E3D83 for ; Tue, 24 Mar 2026 10:30:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774348223; cv=none; b=hF63gTiywogQ7ZjcMi3eqe1u1FL3UcTW9SyPFNWpKxIeGXTZzNC2Ho0FL46ENc0Y/gaViQjCrT81Ujn+80S+YHf6i03siByT1OTCNCe1xYNXa4ivrd69wdOXOdN0G/ajhsQA4PUoAfmC3QfR3AlAivY0BVcgvBh5zg2iVzrA8zQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774348223; c=relaxed/simple; bh=qmvn95qLYi5zD/L9ziLnVeERZqUjiU0m9oMXTSssOxk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=G0Ks2l01hXdhfmSy73JYe8W5/wlrwm/Defs3MLr7pb0nXvy1DJsXp45nuePGiUwuIAd0cWrEIuK31Gbj8r5NnEqtDa6mq6q0HWdEcGBcLX0uLfkvpPeiSeZjPDbiwYSA7aTWPubToMTwWYZSpG6fc1hGi3QUZ+ZVdOh91l6678c= 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=NWkxjUCx; arc=none smtp.client-ip=209.85.208.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="NWkxjUCx" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-668d41905a4so5978838a12.0 for ; Tue, 24 Mar 2026 03:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1774348218; x=1774953018; 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=KJ5B9EsEVAtAKUbh3SIdMjXFUTqdrORMXqDWfN2cV3k=; b=NWkxjUCxEo0Wp6N8/JGTSoR2kVyB1LwvkSIk8He9g/jMAcwLAflHid8S8nqaqVyhFz 6kPQsb1JZUmAEHeZEuUQLoAy7J8n1+Dq/IXLBzg4jKESSpWhKsmTyDCVyg2SA7/HCnRk MauLX6OyZjJKTVX295BWIzSUIuYnR4BHGffSI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774348218; x=1774953018; 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=KJ5B9EsEVAtAKUbh3SIdMjXFUTqdrORMXqDWfN2cV3k=; b=mYmRCTKMEeGWuumy/e8dsSrEN/s9730x8Hgxjqc/7+6fDBrMK0HL99EywEHGhbW7Ex RELwz1BKmpwjSmUDxLHgzMp/0GX3+AfGqRFMOy3O37V7mf3ZY7id8Xgz4a8agCacvowd LVY+NC4JJelIZMpVfPLoGfeCYPdf4dsyUVqN5C90h+7JQ0U2b3CDLsfXpZP0DO+vDOL6 hLOzKcYx2oZFilxnufsulFobRDatTBmom1oPoph7Pt7dt7PMPiVOUDj88daPtOR0cD9D 8ZM6yGYY2yFQSQWj5XQh47gpK+lIQ83ewzWlzHvNuqBHvd1FqAx+czdFCaxbi86B+ppb KYnQ== X-Forwarded-Encrypted: i=1; AJvYcCVtEnywqcG1kZfO3tZWd+UG1ZERf9TLYppMMBU6F5W56Tam6qBHIV5kDvGagfZzj4tJR2NgL4NmTkWJGqY=@vger.kernel.org X-Gm-Message-State: AOJu0YxbCywxUkBVJsC+h8CJH/ga5k2mH4EZuXR3kVuBk63OzJoS9ykx UFwjt87bbo3lgqML3jd3CzHmXBl1I3KFC54M/WEwXiTeru2arroWYS+CsHV69eBlrA== X-Gm-Gg: ATEYQzyK4Q4vYTjqhPrD0Gq2GcojMnjs7efOQB/0qogspQ07J70Ruz5z4JM6I4lVvaE eLbhCQbeScPNuw18at7GnhONhkURvI7ab/m1dcUenjONHGUmTOe46/qqc+dSecdEuthReJfUroR a13lev40t5BwWgSDl8WlIrUz1Ot6q0ITnHiRG8K+rdgt32zZ61IL30PQuMS/Zn3rlRKU+/+2A0P qNte+azMJoEDno2/5GiRl6Y4Yp3PKja0ilMhOcLSfdVrd1q0AKAiLlgF1Ew21aTJYmK68EWkYTv 230NEiuBv4FTmqGbQVPc2WArP7+uPwG0XOcv7HclGb9tLW2xOH4KZY3hvI5rcZNJuLRvdYwVfcY 1GailzDu2FmSMV/VHeDvFTpQIWBltyEZYsgmifKiYj9lFsfHwFFkK0fJVQjdMmbKPsMDuLkGbwG VYkZgBrtZOjq5F9RJuHzQnRlnfWPebASoKTmM/FHQFykxkbZKC9tMYSXaDnd3Q3WH+PCItugklG 7TvU1gh7juk5Zq1xZ/Fhc0= X-Received: by 2002:a17:906:b74d:b0:b96:f329:e66 with SMTP id a640c23a62f3a-b982f39b31dmr905699266b.51.1774348218439; Tue, 24 Mar 2026 03:30:18 -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-b98416ac27asm496819666b.59.2026.03.24.03.30.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 03:30:17 -0700 (PDT) From: Andrei Kuchynski To: Heikki Krogerus , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Andrei Kuchynski , stable@vger.kernel.org, Madhu M Subject: [PATCH v2] usb: typec: thunderbolt: Set enter_vdo during initialization Date: Tue, 24 Mar 2026 10:30:12 +0000 Message-ID: <20260324103012.1417616-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(). Cc: stable@vger.kernel.org Fixes: 100e25738659 ("usb: typec: Add driver for Thunderbolt 3 Alternate Mo= de") Tested-by: Madhu M Signed-off-by: Andrei Kuchynski Reviewed-by: Heikki Krogerus Reviewed-by: Benson Leung --- Changes in V2: - Marked as a Fix 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