All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tbt: Correct swapped TBT adapter type values
@ 2026-08-18 16:20 Sven Peter
  2026-08-19 10:34 ` Konrad Dybcio
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sven Peter @ 2026-08-18 16:20 UTC (permalink / raw)
  To: Benson Leung, Abhishek Pandit-Subedi, Jameson Thies,
	Andrei Kuchynski, Tzung-Bi Shih, Guenter Roeck, Bjorn Andersson,
	Konrad Dybcio, Heikki Krogerus, Greg Kroah-Hartman
  Cc: chrome-platform, linux-kernel, linux-arm-msm, linux-usb,
	Sven Peter

Table F-10 of the USB Type-C Cable and Connector Specification R2.5 on
page 412 defines bit 16 of the TBT3 Device Discover Mode VDO as 0 = TBT3
Adapter and 1 = TBT2 Legacy Adapter. Linux has those two swapped since
their original introduction in commit ca469c292edc ("usb: typec: Add
definitions for Thunderbolt 3 Alternate Mode").

ChromiumOS EC's include/usb_pd_tbt.h has them the correct way around
and references the USB Type-C ECN "Thunderbolt 3 Compatibility Updates"
as fixing an error where they were originally swapped which is presumably
where the wrong order originally came from.

I've also confirmed the correct mapping with an Apple Thunderbolt 3
to Thunderbolt 2 adapter which does set bit 16 in that VDO.

Swap the two values and update all users. Also rename the old defines
so that no user accidentally ends up with an inverted value.
No functional change.

Link: https://usb.org/document-library/usb-type-cr-cable-and-connector-specification-release-25
Link: https://chromium.googlesource.com/chromiumos/platform/ec/+/db93814b6e73c8545d23714fe0674c10814d901a/include/usb_pd_tbt.h#90
Signed-off-by: Sven Peter <sven@kernel.org>
---
I ran into this when bringing up thunderbolt for Apple Silicon SoCs and
was very confused why the condition for "tbt2 adapter" vs "tbt3 adapter"
seemed to be backwards.
I think the qcom pmic_glink_altmode.c actually has a bug there that was
hidden and/or caused by the wrong values: It used to always set
TBT_ADAPTER_TBT3 which sounds plausible but actually claims to be a
legacy TBT2 adapter on the wire. I don't have the hardware or know the
intention there though.
The other users look correct to me since they just pass the value
through.
---
 drivers/platform/chrome/cros_ec_typec.c | 2 +-
 drivers/soc/qcom/pmic_glink_altmode.c   | 2 +-
 drivers/usb/typec/mux/intel_pmc_mux.c   | 2 +-
 include/linux/usb/typec_tbt.h           | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index c0806c562bb9..79968edc16ed 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -586,7 +586,7 @@ static int cros_typec_enable_tbt(struct cros_typec_data *typec,
 	data.device_mode = TBT_MODE;
 
 	if (pd_ctrl->control_flags & USB_PD_CTRL_TBT_LEGACY_ADAPTER)
-		data.device_mode = TBT_SET_ADAPTER(TBT_ADAPTER_TBT3);
+		data.device_mode = TBT_SET_ADAPTER(TBT_ADAPTER_TYPE_TBT2_LEGACY);
 
 	/* Cable Discover Mode VDO */
 	data.cable_mode = TBT_MODE;
diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c
index 619bad2c27ee..8d4f54c160c5 100644
--- a/drivers/soc/qcom/pmic_glink_altmode.c
+++ b/drivers/soc/qcom/pmic_glink_altmode.c
@@ -215,7 +215,7 @@ static void pmic_glink_altmode_enable_tbt(struct pmic_glink_altmode *altmode,
 
 	/* Device Discover Mode VDO */
 	tbt_data.device_mode = TBT_MODE;
-	tbt_data.device_mode |= TBT_SET_ADAPTER(TBT_ADAPTER_TBT3);
+	tbt_data.device_mode |= TBT_SET_ADAPTER(TBT_ADAPTER_TYPE_TBT2_LEGACY);
 
 	/* Cable Discover Mode VDO */
 	tbt_data.cable_mode = TBT_MODE;
diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index 219a32da1348..b63114575a78 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -346,7 +346,7 @@ pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)
 	req.mode_data = (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT;
 	req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT;
 
-	if (TBT_ADAPTER(data->device_mode) == TBT_ADAPTER_TBT3)
+	if (TBT_ADAPTER(data->device_mode) == TBT_ADAPTER_TYPE_TBT2_LEGACY)
 		req.mode_data |= PMC_USB_ALTMODE_TBT_TYPE;
 
 	if (data->cable_mode & TBT_CABLE_OPTICAL)
diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
index 0b570f1b8bc8..7bdf3795ae50 100644
--- a/include/linux/usb/typec_tbt.h
+++ b/include/linux/usb/typec_tbt.h
@@ -27,8 +27,8 @@ struct typec_thunderbolt_data {
 /* TBT3 Device Discover Mode VDO bits */
 #define TBT_MODE			BIT(0)
 #define TBT_ADAPTER(_vdo_)		FIELD_GET(BIT(16), _vdo_)
-#define   TBT_ADAPTER_LEGACY		0
-#define   TBT_ADAPTER_TBT3		1
+#define   TBT_ADAPTER_TYPE_TBT3		0
+#define   TBT_ADAPTER_TYPE_TBT2_LEGACY	1
 #define TBT_INTEL_SPECIFIC_B0		BIT(26)
 #define TBT_VENDOR_SPECIFIC_B0		BIT(30)
 #define TBT_VENDOR_SPECIFIC_B1		BIT(31)

---
base-commit: 8d3ae59288f1e7d58d76558a6ee96d533bc5019f
change-id: 20260818-b4-tbt-legacy-fix-d6e71ac4bb6a

Best regards,
--  
Sven Peter <sven@kernel.org>



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: typec: tbt: Correct swapped TBT adapter type values
  2026-08-18 16:20 [PATCH] usb: typec: tbt: Correct swapped TBT adapter type values Sven Peter
@ 2026-08-19 10:34 ` Konrad Dybcio
  2026-08-24 11:11 ` Heikki Krogerus
  2026-08-26  6:21 ` Tzung-Bi Shih
  2 siblings, 0 replies; 5+ messages in thread
From: Konrad Dybcio @ 2026-08-19 10:34 UTC (permalink / raw)
  To: Sven Peter, Benson Leung, Abhishek Pandit-Subedi, Jameson Thies,
	Andrei Kuchynski, Tzung-Bi Shih, Guenter Roeck, Bjorn Andersson,
	Konrad Dybcio, Heikki Krogerus, Greg Kroah-Hartman
  Cc: chrome-platform, linux-kernel, linux-arm-msm, linux-usb

On 8/18/26 6:20 PM, Sven Peter wrote:
> Table F-10 of the USB Type-C Cable and Connector Specification R2.5 on
> page 412 defines bit 16 of the TBT3 Device Discover Mode VDO as 0 = TBT3
> Adapter and 1 = TBT2 Legacy Adapter. Linux has those two swapped since
> their original introduction in commit ca469c292edc ("usb: typec: Add
> definitions for Thunderbolt 3 Alternate Mode").
> 
> ChromiumOS EC's include/usb_pd_tbt.h has them the correct way around
> and references the USB Type-C ECN "Thunderbolt 3 Compatibility Updates"
> as fixing an error where they were originally swapped which is presumably
> where the wrong order originally came from.
> 
> I've also confirmed the correct mapping with an Apple Thunderbolt 3
> to Thunderbolt 2 adapter which does set bit 16 in that VDO.
> 
> Swap the two values and update all users. Also rename the old defines
> so that no user accidentally ends up with an inverted value.
> No functional change.
> 
> Link: https://usb.org/document-library/usb-type-cr-cable-and-connector-specification-release-25
> Link: https://chromium.googlesource.com/chromiumos/platform/ec/+/db93814b6e73c8545d23714fe0674c10814d901a/include/usb_pd_tbt.h#90
> Signed-off-by: Sven Peter <sven@kernel.org>
> ---
> I ran into this when bringing up thunderbolt for Apple Silicon SoCs and
> was very confused why the condition for "tbt2 adapter" vs "tbt3 adapter"
> seemed to be backwards.
> I think the qcom pmic_glink_altmode.c actually has a bug there that was
> hidden and/or caused by the wrong values: It used to always set
> TBT_ADAPTER_TBT3 which sounds plausible but actually claims to be a
> legacy TBT2 adapter on the wire. I don't have the hardware or know the
> intention there though.
> The other users look correct to me since they just pass the value
> through.

I ran into this in the past

https://lore.kernel.org/lkml/20250926-topic-tbt_header_bit_fix-v1-1-122238af5c82@oss.qualcomm.com/

where seems like back then I misinterpreted that the intel driver
doesn't need changes.

For the pg-altmode driver, looking at the FW interface I don't see
any info being passed to the OS regarding tbt2 vs 3, so we should
presumably always assume the latter (i.e. just fixing the header
is enough).

Konrad

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: typec: tbt: Correct swapped TBT adapter type values
  2026-08-18 16:20 [PATCH] usb: typec: tbt: Correct swapped TBT adapter type values Sven Peter
  2026-08-19 10:34 ` Konrad Dybcio
@ 2026-08-24 11:11 ` Heikki Krogerus
  2026-08-24 11:31   ` Sven Peter
  2026-08-26  6:21 ` Tzung-Bi Shih
  2 siblings, 1 reply; 5+ messages in thread
From: Heikki Krogerus @ 2026-08-24 11:11 UTC (permalink / raw)
  To: Sven Peter
  Cc: Benson Leung, Abhishek Pandit-Subedi, Jameson Thies,
	Andrei Kuchynski, Tzung-Bi Shih, Guenter Roeck, Bjorn Andersson,
	Konrad Dybcio, Greg Kroah-Hartman, chrome-platform, linux-kernel,
	linux-arm-msm, linux-usb

On Tue, Aug 18, 2026 at 06:20:03PM +0200, Sven Peter wrote:
> Table F-10 of the USB Type-C Cable and Connector Specification R2.5 on
> page 412 defines bit 16 of the TBT3 Device Discover Mode VDO as 0 = TBT3
> Adapter and 1 = TBT2 Legacy Adapter. Linux has those two swapped since
> their original introduction in commit ca469c292edc ("usb: typec: Add
> definitions for Thunderbolt 3 Alternate Mode").
> 
> ChromiumOS EC's include/usb_pd_tbt.h has them the correct way around
> and references the USB Type-C ECN "Thunderbolt 3 Compatibility Updates"
> as fixing an error where they were originally swapped which is presumably
> where the wrong order originally came from.
> 
> I've also confirmed the correct mapping with an Apple Thunderbolt 3
> to Thunderbolt 2 adapter which does set bit 16 in that VDO.
> 
> Swap the two values and update all users. Also rename the old defines
> so that no user accidentally ends up with an inverted value.
> No functional change.
> 
> Link: https://usb.org/document-library/usb-type-cr-cable-and-connector-specification-release-25
> Link: https://chromium.googlesource.com/chromiumos/platform/ec/+/db93814b6e73c8545d23714fe0674c10814d901a/include/usb_pd_tbt.h#90
> Signed-off-by: Sven Peter <sven@kernel.org>

Shouldn't this be marked as a fix?

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> I ran into this when bringing up thunderbolt for Apple Silicon SoCs and
> was very confused why the condition for "tbt2 adapter" vs "tbt3 adapter"
> seemed to be backwards.
> I think the qcom pmic_glink_altmode.c actually has a bug there that was
> hidden and/or caused by the wrong values: It used to always set
> TBT_ADAPTER_TBT3 which sounds plausible but actually claims to be a
> legacy TBT2 adapter on the wire. I don't have the hardware or know the
> intention there though.
> The other users look correct to me since they just pass the value
> through.
> ---
>  drivers/platform/chrome/cros_ec_typec.c | 2 +-
>  drivers/soc/qcom/pmic_glink_altmode.c   | 2 +-
>  drivers/usb/typec/mux/intel_pmc_mux.c   | 2 +-
>  include/linux/usb/typec_tbt.h           | 4 ++--
>  4 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index c0806c562bb9..79968edc16ed 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -586,7 +586,7 @@ static int cros_typec_enable_tbt(struct cros_typec_data *typec,
>  	data.device_mode = TBT_MODE;
>  
>  	if (pd_ctrl->control_flags & USB_PD_CTRL_TBT_LEGACY_ADAPTER)
> -		data.device_mode = TBT_SET_ADAPTER(TBT_ADAPTER_TBT3);
> +		data.device_mode = TBT_SET_ADAPTER(TBT_ADAPTER_TYPE_TBT2_LEGACY);
>  
>  	/* Cable Discover Mode VDO */
>  	data.cable_mode = TBT_MODE;
> diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c
> index 619bad2c27ee..8d4f54c160c5 100644
> --- a/drivers/soc/qcom/pmic_glink_altmode.c
> +++ b/drivers/soc/qcom/pmic_glink_altmode.c
> @@ -215,7 +215,7 @@ static void pmic_glink_altmode_enable_tbt(struct pmic_glink_altmode *altmode,
>  
>  	/* Device Discover Mode VDO */
>  	tbt_data.device_mode = TBT_MODE;
> -	tbt_data.device_mode |= TBT_SET_ADAPTER(TBT_ADAPTER_TBT3);
> +	tbt_data.device_mode |= TBT_SET_ADAPTER(TBT_ADAPTER_TYPE_TBT2_LEGACY);
>  
>  	/* Cable Discover Mode VDO */
>  	tbt_data.cable_mode = TBT_MODE;
> diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
> index 219a32da1348..b63114575a78 100644
> --- a/drivers/usb/typec/mux/intel_pmc_mux.c
> +++ b/drivers/usb/typec/mux/intel_pmc_mux.c
> @@ -346,7 +346,7 @@ pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)
>  	req.mode_data = (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT;
>  	req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT;
>  
> -	if (TBT_ADAPTER(data->device_mode) == TBT_ADAPTER_TBT3)
> +	if (TBT_ADAPTER(data->device_mode) == TBT_ADAPTER_TYPE_TBT2_LEGACY)
>  		req.mode_data |= PMC_USB_ALTMODE_TBT_TYPE;
>  
>  	if (data->cable_mode & TBT_CABLE_OPTICAL)
> diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
> index 0b570f1b8bc8..7bdf3795ae50 100644
> --- a/include/linux/usb/typec_tbt.h
> +++ b/include/linux/usb/typec_tbt.h
> @@ -27,8 +27,8 @@ struct typec_thunderbolt_data {
>  /* TBT3 Device Discover Mode VDO bits */
>  #define TBT_MODE			BIT(0)
>  #define TBT_ADAPTER(_vdo_)		FIELD_GET(BIT(16), _vdo_)
> -#define   TBT_ADAPTER_LEGACY		0
> -#define   TBT_ADAPTER_TBT3		1
> +#define   TBT_ADAPTER_TYPE_TBT3		0
> +#define   TBT_ADAPTER_TYPE_TBT2_LEGACY	1
>  #define TBT_INTEL_SPECIFIC_B0		BIT(26)
>  #define TBT_VENDOR_SPECIFIC_B0		BIT(30)
>  #define TBT_VENDOR_SPECIFIC_B1		BIT(31)
> 
> ---
> base-commit: 8d3ae59288f1e7d58d76558a6ee96d533bc5019f
> change-id: 20260818-b4-tbt-legacy-fix-d6e71ac4bb6a
> 
> Best regards,
> --  
> Sven Peter <sven@kernel.org>
> 

-- 
heikki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: typec: tbt: Correct swapped TBT adapter type values
  2026-08-24 11:11 ` Heikki Krogerus
@ 2026-08-24 11:31   ` Sven Peter
  0 siblings, 0 replies; 5+ messages in thread
From: Sven Peter @ 2026-08-24 11:31 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: Benson Leung, Abhishek Pandit-Subedi, Jameson Thies,
	Andrei Kuchynski, Tzung-Bi Shih, Guenter Roeck, Bjorn Andersson,
	Konrad Dybcio, Greg Kroah-Hartman, chrome-platform, linux-kernel,
	linux-arm-msm, linux-usb



On 8/24/26 13:11, Heikki Krogerus wrote:
> On Tue, Aug 18, 2026 at 06:20:03PM +0200, Sven Peter wrote:
>> Table F-10 of the USB Type-C Cable and Connector Specification R2.5 on
>> page 412 defines bit 16 of the TBT3 Device Discover Mode VDO as 0 = TBT3
>> Adapter and 1 = TBT2 Legacy Adapter. Linux has those two swapped since
>> their original introduction in commit ca469c292edc ("usb: typec: Add
>> definitions for Thunderbolt 3 Alternate Mode").
>>
>> ChromiumOS EC's include/usb_pd_tbt.h has them the correct way around
>> and references the USB Type-C ECN "Thunderbolt 3 Compatibility Updates"
>> as fixing an error where they were originally swapped which is presumably
>> where the wrong order originally came from.
>>
>> I've also confirmed the correct mapping with an Apple Thunderbolt 3
>> to Thunderbolt 2 adapter which does set bit 16 in that VDO.
>>
>> Swap the two values and update all users. Also rename the old defines
>> so that no user accidentally ends up with an inverted value.
>> No functional change.
>>
>> Link: https://usb.org/document-library/usb-type-cr-cable-and-connector-specification-release-25
>> Link: https://chromium.googlesource.com/chromiumos/platform/ec/+/db93814b6e73c8545d23714fe0674c10814d901a/include/usb_pd_tbt.h#90
>> Signed-off-by: Sven Peter <sven@kernel.org>
> Shouldn't this be marked as a fix?

I left it out deliberately together with Cc: stable because there's no 
functional change but I can just add it if you want to. The original 
commit is already in the message.
>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

Thanks!


Sven


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: typec: tbt: Correct swapped TBT adapter type values
  2026-08-18 16:20 [PATCH] usb: typec: tbt: Correct swapped TBT adapter type values Sven Peter
  2026-08-19 10:34 ` Konrad Dybcio
  2026-08-24 11:11 ` Heikki Krogerus
@ 2026-08-26  6:21 ` Tzung-Bi Shih
  2 siblings, 0 replies; 5+ messages in thread
From: Tzung-Bi Shih @ 2026-08-26  6:21 UTC (permalink / raw)
  To: Sven Peter
  Cc: Benson Leung, Abhishek Pandit-Subedi, Jameson Thies,
	Andrei Kuchynski, Guenter Roeck, Bjorn Andersson, Konrad Dybcio,
	Heikki Krogerus, Greg Kroah-Hartman, chrome-platform,
	linux-kernel, linux-arm-msm, linux-usb

On Tue, Aug 18, 2026 at 06:20:03PM +0200, Sven Peter wrote:
> Table F-10 of the USB Type-C Cable and Connector Specification R2.5 on
> page 412 defines bit 16 of the TBT3 Device Discover Mode VDO as 0 = TBT3
> Adapter and 1 = TBT2 Legacy Adapter. Linux has those two swapped since
> their original introduction in commit ca469c292edc ("usb: typec: Add
> definitions for Thunderbolt 3 Alternate Mode").
> 
> ChromiumOS EC's include/usb_pd_tbt.h has them the correct way around
> and references the USB Type-C ECN "Thunderbolt 3 Compatibility Updates"
> as fixing an error where they were originally swapped which is presumably
> where the wrong order originally came from.
> 
> I've also confirmed the correct mapping with an Apple Thunderbolt 3
> to Thunderbolt 2 adapter which does set bit 16 in that VDO.
> 
> Swap the two values and update all users. Also rename the old defines
> so that no user accidentally ends up with an inverted value.
> No functional change.
> 
> Link: https://usb.org/document-library/usb-type-cr-cable-and-connector-specification-release-25
> Link: https://chromium.googlesource.com/chromiumos/platform/ec/+/db93814b6e73c8545d23714fe0674c10814d901a/include/usb_pd_tbt.h#90
> Signed-off-by: Sven Peter <sven@kernel.org>
...
>  drivers/platform/chrome/cros_ec_typec.c | 2 +-

For cros_ec_typec.c,
Acked-by: Tzung-Bi Shih <tzungbi@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-26  6:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18 16:20 [PATCH] usb: typec: tbt: Correct swapped TBT adapter type values Sven Peter
2026-08-19 10:34 ` Konrad Dybcio
2026-08-24 11:11 ` Heikki Krogerus
2026-08-24 11:31   ` Sven Peter
2026-08-26  6:21 ` Tzung-Bi Shih

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.