Skip to contentSkip to conversation

Thunderbolt3/USB4 cable rounded and active cable plug link training support

PATCH Superseded Utkarsh Patel 3 participants 16 messages Nov 19, 2020 – Nov 20, 2020

Subsystems (6)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Thunderbolt3/USB4 cable rounded and active cable plug link training support

This patch series adds the support for Thunderbolt3/USB4 rounded and non-rounded frequencies cables and fixes the active cable plug link training support.

Changes in v3:
- First four patches of this series have been queued by Greg to usb-testing branch. https://www.spinics.net/lists/linux-usb/msg204880.html
- Changed commit message and description in header file in patch 1/4.
- Added a check for Cable's TBT support in patch 2/4
- Moved TBT_CABLE_ROUNDED_SUPPORT assignment to same line in patch 3/4.
- Rebased and added Reviewed-by tag in patch 4/4.

Changes in v2:
- Removed the fixes tag as there is no functional implication from patches 1/8, 2/8 and 4/8.

Utkarsh Patel (4):
usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB
message
platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode
VDO in USB4 mode
usb: typec: intel_pmc_mux: Configure active cable properties for USB4
usb: typec: Remove active_link_training variable from Enter_USB
message

 drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
 drivers/usb/typec/mux/intel_pmc_mux.c   | 17 ++++++++++++++---
 include/linux/usb/typec.h               | 11 +++++------
 3 files changed, 31 insertions(+), 11 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/4 usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message

When Thunderbolt 3 cable is being used to create USB4 connection, use Thunderbolt 3 discover mode VDO to fill details such as active cable plug link training and cable rounded support.
With USB4 cables, these VDO members need not be filled.

--
Changes in v3:
- Changed the commit mesage to reflect why TBT3 VDO is being used.
- Added more details in the header file about the usage of TBT3 VDO.

Changes in v2:
- No change.
--

---
 include/linux/usb/typec.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/usb/typec.h +5 -0
index 6be558045942..25731ed863fa 100644
@@ -75,6 +75,10 @@ enum typec_orientation {
 /*
  * struct enter_usb_data - Enter_USB Message details
  * @eudo: Enter_USB Data Object
+ * @tbt_cable_vdo: TBT3 Cable Discover Mode Response
+ * @tbt_cable_vdo needs to be filled with details of active cable plug link
+ * training and cable rounded support when thunderbolt 3 cable is being used to
+ * create USB4 connection. Do not fill this in case of USB4 cable.
  * @active_link_training: Active Cable Plug Link Training
  *
  * @active_link_training is a flag that should be set with uni-directional SBRX
@@ -83,6 +87,7 @@ enum typec_orientation {
  */
 struct enter_usb_data {
 	u32			eudo;
+	u32			tbt_cable_vdo;
 	unsigned char		active_link_training:1;
 };
 
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH v3 1/4] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message

Quoted 25 lines · Utkarsh Patel

When Thunderbolt 3 cable is being used to create USB4 connection, use Thunderbolt 3 discover mode VDO to fill details such as active cable plug link training and cable rounded support.
With USB4 cables, these VDO members need not be filled.

--
Changes in v3:
- Changed the commit mesage to reflect why TBT3 VDO is being used.
- Added more details in the header file about the usage of TBT3 VDO.

Changes in v2:
- No change.
--

---
 include/linux/usb/typec.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/usb/typec.h +0 -0
index 6be558045942..25731ed863fa 100644

include/linux/usb/typec.h enum typec_orientation { · line 78

Quoted 4 lines
include/linux/usb/typec.h +1 -0
@@ -75,6 +75,10 @@ enum typec_orientation {
 /*
  * struct enter_usb_data - Enter_USB Message details
  * @eudo: Enter_USB Data Object
+ * @tbt_cable_vdo: TBT3 Cable Discover Mode Response

This is fine..

include/linux/usb/typec.h enum typec_orientation { · line 81

Quoted 3 lines
include/linux/usb/typec.h +3 -0
+ * @tbt_cable_vdo needs to be filled with details of active cable plug link
+ * training and cable rounded support when thunderbolt 3 cable is being used to
+ * create USB4 connection. Do not fill this in case of USB4 cable.

But this is not. The description of the member tells what the member contains, but it does not make sense to explain also how to use the member in the same place. Instead you should explain how to use the member in the description of the structure. So..

include/linux/usb/typec.h enum typec_orientation { · line 84

Quoted 3 lines
include/linux/usb/typec.h +0 -0
  * @active_link_training: Active Cable Plug Link Training
  *
  * @active_link_training is a flag that should be set with uni-directional SBRX

Put it here. That will make this much more readable.

thanks,

Signature · 1 line
heikki
#3 lore raw

Re: [PATCH v3 1/4] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message

Quoted 33 lines · Heikki Krogerus
Quoted 25 lines · Utkarsh Patel

When Thunderbolt 3 cable is being used to create USB4 connection, use Thunderbolt 3 discover mode VDO to fill details such as active cable plug link training and cable rounded support.
With USB4 cables, these VDO members need not be filled.

--
Changes in v3:
- Changed the commit mesage to reflect why TBT3 VDO is being used.
- Added more details in the header file about the usage of TBT3 VDO.

Changes in v2:
- No change.
--

---
 include/linux/usb/typec.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/usb/typec.h +0 -0
index 6be558045942..25731ed863fa 100644

include/linux/usb/typec.h enum typec_orientation { · line 78

Quoted 4 lines
include/linux/usb/typec.h +1 -0
@@ -75,6 +75,10 @@ enum typec_orientation {
 /*
  * struct enter_usb_data - Enter_USB Message details
  * @eudo: Enter_USB Data Object
+ * @tbt_cable_vdo: TBT3 Cable Discover Mode Response

This is fine..

Quoted 7 lines

include/linux/usb/typec.h enum typec_orientation { · line 81

Quoted 3 lines
include/linux/usb/typec.h +3 -0
+ * @tbt_cable_vdo needs to be filled with details of active cable plug link
+ * training and cable rounded support when thunderbolt 3 cable is being used to
+ * create USB4 connection. Do not fill this in case of USB4 cable.

But this is not. The description of the member tells what the member contains, but it does not make sense to explain also how to use the member in the same place.

Slightly tangential question here:

Is there a need to mention "active cable plug link training" and "cable rounded support" at all? Wouldn't it be sufficient to omit those in the description (in case some mux implementation wants to use the other fields of the VDO) ?

Quoted 14 lines

Instead you should explain how to use the
member in the description of the structure. So..

include/linux/usb/typec.h enum typec_orientation { · line 84

Quoted 3 lines
include/linux/usb/typec.h +0 -0
  * @active_link_training: Active Cable Plug Link Training
  *
  * @active_link_training is a flag that should be set with uni-directional SBRX

Put it here. That will make this much more readable.

thanks,

Signature · 1 line
heikki
maintainer
#4 lore raw

Re: [PATCH v3 1/4] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message

Quoted 42 lines · Prashant Malani
Quoted 33 lines · Heikki Krogerus
Quoted 25 lines · Utkarsh Patel

When Thunderbolt 3 cable is being used to create USB4 connection, use Thunderbolt 3 discover mode VDO to fill details such as active cable plug link training and cable rounded support.
With USB4 cables, these VDO members need not be filled.

--
Changes in v3:
- Changed the commit mesage to reflect why TBT3 VDO is being used.
- Added more details in the header file about the usage of TBT3 VDO.

Changes in v2:
- No change.
--

---
 include/linux/usb/typec.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/usb/typec.h +0 -0
index 6be558045942..25731ed863fa 100644

include/linux/usb/typec.h enum typec_orientation { · line 78

Quoted 4 lines
include/linux/usb/typec.h +1 -0
@@ -75,6 +75,10 @@ enum typec_orientation {
 /*
  * struct enter_usb_data - Enter_USB Message details
  * @eudo: Enter_USB Data Object
+ * @tbt_cable_vdo: TBT3 Cable Discover Mode Response

This is fine..

Quoted 7 lines

include/linux/usb/typec.h enum typec_orientation { · line 81

Quoted 3 lines
include/linux/usb/typec.h +3 -0
+ * @tbt_cable_vdo needs to be filled with details of active cable plug link
+ * training and cable rounded support when thunderbolt 3 cable is being used to
+ * create USB4 connection. Do not fill this in case of USB4 cable.

But this is not. The description of the member tells what the member contains, but it does not make sense to explain also how to use the member in the same place.

Quoted 6 lines

Slightly tangential question here:

Is there a need to mention "active cable plug link training" and "cable rounded support" at all? Wouldn't it be sufficient to omit those in the description (in case some mux implementation wants to use the other fields of the VDO) ?

No, I don't think so. I think it would be enough to just mention that we need the TBT3 Cable VDO only when the USB4 connection is created using TBT3 cables. And that's it.

Br,

Signature · 1 line
heikki
#5 lore raw

RE: [PATCH v3 1/4] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message

Hi Heikki and Prashant,

Thank you for the feedback.

Quoted 27 lines
Quoted 27 lines
Quoted 21 lines

include/linux/usb/typec.h enum typec_orientation { · line 78

Quoted 12 lines
 include/linux/usb/typec.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/usb/typec.h +1 -0
index 6be558045942..25731ed863fa 100644
@@ -75,6 +75,10 @@ enum typec_orientation {
 /*
  * struct enter_usb_data - Enter_USB Message details
  * @eudo: Enter_USB Data Object
+ * @tbt_cable_vdo: TBT3 Cable Discover Mode Response

This is fine..

include/linux/usb/typec.h enum typec_orientation { · line 83

Quoted 5 lines
include/linux/usb/typec.h +5 -0
+ * @tbt_cable_vdo needs to be filled with details of active cable
+ plug link
+ * training and cable rounded support when thunderbolt 3 cable is
+ being used to
+ * create USB4 connection. Do not fill this in case of USB4 cable.
Quoted 3 lines

But this is not. The description of the member tells what the member contains, but it does not make sense to explain also how to use the member in the same place.

Slightly tangential question here:

Quoted 8 lines
Quoted 4 lines

Is there a need to mention "active cable plug link training" and "cable rounded support" at all? Wouldn't it be sufficient to omit those in the description (in case some mux implementation wants to use the other fields of the VDO) ?

No, I don't think so. I think it would be enough to just mention that we need the TBT3 Cable VDO only when the USB4 connection is created using TBT3 cables. And that's it.

Ack.

Quoted 6 lines

Br,

--
Heikki

Sincerely,
Utkarsh Patel.

#6 lore raw

PATCH v3 2/4 platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode

In reply to Utkarsh Patel

Configure Thunderbolt 3 cable generation value by filling Thunderbolt 3 cable discover mode VDO to support rounded Thunderbolt 3 cables. While we are here use Thunderbolt 3 cable discover mode VDO to fill active cable plug link training value.

--
Changes in v3:
- Added a check for cable's TBT support before filling TBT3 discover mode VDO.

Changes in v2:
- No change.
--

---
 drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +12 -2
index 8111ed1fc574..68b17ee1d1ae 100644
@@ -514,8 +514,18 @@ static int cros_typec_enable_usb4(struct cros_typec_data *typec,
 	else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
 		data.eudo |= EUDO_CABLE_TYPE_RE_TIMER << EUDO_CABLE_TYPE_SHIFT;
 
-	data.active_link_training = !!(pd_ctrl->control_flags &
-				       USB_PD_CTRL_ACTIVE_LINK_UNIDIR);
+	/*
+	 * Filling TBT3 Cable VDO when TBT3 cable is being used to establish
+	 * USB4 connection.
+	 */
+	if (pd_ctrl->cable_gen) {
+		data.tbt_cable_vdo = TBT_MODE;
+
+		if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
+			data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;
+
+		data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
+	}
 
 	port->state.alt = NULL;
 	port->state.data = &data;
Signature · 1 line
2.17.1
#7 lore raw

Re: [PATCH v3 2/4] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode

Hi Utkarsh,

Quoted 32 lines · Utkarsh Patel

Configure Thunderbolt 3 cable generation value by filling Thunderbolt 3 cable discover mode VDO to support rounded Thunderbolt 3 cables. While we are here use Thunderbolt 3 cable discover mode VDO to fill active cable plug link training value.

--
Changes in v3:
- Added a check for cable's TBT support before filling TBT3 discover mode VDO.

Changes in v2:
- No change.
--

---
 drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +2 -2
index 8111ed1fc574..68b17ee1d1ae 100644
@@ -514,8 +514,18 @@ static int cros_typec_enable_usb4(struct cros_typec_data *typec,
 	else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
 		data.eudo |= EUDO_CABLE_TYPE_RE_TIMER << EUDO_CABLE_TYPE_SHIFT;
 
-	data.active_link_training = !!(pd_ctrl->control_flags &
-				       USB_PD_CTRL_ACTIVE_LINK_UNIDIR);
+	/*
+	 * Filling TBT3 Cable VDO when TBT3 cable is being used to establish

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct cros_typec_data *typec, · line 528

Quoted 10 lines
drivers/platform/chrome/cros_ec_typec.c +10 -0
+	 * USB4 connection.
+	 */
+	if (pd_ctrl->cable_gen) {
+		data.tbt_cable_vdo = TBT_MODE;
+
+		if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
+			data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;
+
+		data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
+	}

I think the following would decouple Rounded Support and Active Cable Link Training?:

	struct typec_thunderbolt_data data = {};
...
	if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
		data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;

	data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);

	if (data.tbt_cable_vdo)
		data.tbt_cable_vdo |= TBT_MODE;

Best regards,

-Prashant

#8 lore raw

RE: [PATCH v3 2/4] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode

Hi Prashant,

Quoted 56 lines

-----Original Message-----
From: Prashant Malani <[email protected]>
Sent: Thursday, November 19, 2020 12:09 AM
To: Patel, Utkarsh H <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Mani, Rajmohan <[email protected]>; Shaikh, Azhar <[email protected]>
Subject: Re: [PATCH v3 2/4] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode

Hi Utkarsh,

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct

Quoted 26 lines · Utkarsh Patel

Configure Thunderbolt 3 cable generation value by filling Thunderbolt 3 cable discover mode VDO to support rounded Thunderbolt 3 cables. While we are here use Thunderbolt 3 cable discover mode VDO to fill active cable plug link training value.

--
Changes in v3:
- Added a check for cable's TBT support before filling TBT3 discover mode VDO.

Changes in v2:
- No change.
--

---
 drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +0 -0
index 8111ed1fc574..68b17ee1d1ae 100644
@@ -514,8 +514,18 @@ static int cros_typec_enable_usb4(struct

cros_typec_data *typec,

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct · line 515

Quoted 2 lines
drivers/platform/chrome/cros_ec_typec.c +0 -0
 	else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
 		data.eudo |= EUDO_CABLE_TYPE_RE_TIMER <<

EUDO_CABLE_TYPE_SHIFT;

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct cros_typec_data *typec,

Quoted 11 lines
drivers/platform/chrome/cros_ec_typec.c +8 -2
-	data.active_link_training = !!(pd_ctrl->control_flags &
-				       USB_PD_CTRL_ACTIVE_LINK_UNIDIR);
+	/*
+	 * Filling TBT3 Cable VDO when TBT3 cable is being used to establish
+	 * USB4 connection.
+	 */
+	if (pd_ctrl->cable_gen) {
+		data.tbt_cable_vdo = TBT_MODE;
+
+		if (pd_ctrl->control_flags &

USB_PD_CTRL_ACTIVE_LINK_UNIDIR)

Quoted 8 lines

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct cros_typec_data *typec, · line 528

Quoted 5 lines
drivers/platform/chrome/cros_ec_typec.c +4 -0
+			data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;
+
+		data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl-
 cable_gen);
+	}

I think the following would decouple Rounded Support and Active Cable Link Training?:

Any reason you would want to decouple them?
As for the TBT3 active cable to create USB4 connection, it needs have rounded data rates.

Quoted 8 lines
	struct typec_thunderbolt_data data = {}; ...
	if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
		data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;

	data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl-

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct · line 529

Quoted 1 line
drivers/platform/chrome/cros_ec_typec.c +0 -0
 cable_gen);
Quoted 7 lines
	if (data.tbt_cable_vdo)
		data.tbt_cable_vdo |= TBT_MODE;

Best regards,

-Prashant

Sincerely,
Utkarsh Patel.

#9 lore raw

Re: [PATCH v3 2/4] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode

Hi Utkarsh,

Quoted 65 lines · Utkarsh H

Hi Prashant,

Quoted 62 lines

-----Original Message-----
From: Prashant Malani <[email protected]>
Sent: Thursday, November 19, 2020 12:09 AM
To: Patel, Utkarsh H <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Mani, Rajmohan <[email protected]>; Shaikh, Azhar <[email protected]>
Subject: Re: [PATCH v3 2/4] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode

Hi Utkarsh,

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct

Quoted 26 lines · Utkarsh Patel

Configure Thunderbolt 3 cable generation value by filling Thunderbolt 3 cable discover mode VDO to support rounded Thunderbolt 3 cables. While we are here use Thunderbolt 3 cable discover mode VDO to fill active cable plug link training value.

--
Changes in v3:
- Added a check for cable's TBT support before filling TBT3 discover mode VDO.

Changes in v2:
- No change.
--

---
 drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +0 -0
index 8111ed1fc574..68b17ee1d1ae 100644
@@ -514,8 +514,18 @@ static int cros_typec_enable_usb4(struct

cros_typec_data *typec,

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct · line 515

Quoted 2 lines
drivers/platform/chrome/cros_ec_typec.c +0 -0
    else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
            data.eudo |= EUDO_CABLE_TYPE_RE_TIMER <<

EUDO_CABLE_TYPE_SHIFT;

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct cros_typec_data *typec,

Quoted 11 lines
drivers/platform/chrome/cros_ec_typec.c +8 -2
-   data.active_link_training = !!(pd_ctrl->control_flags &
-                                  USB_PD_CTRL_ACTIVE_LINK_UNIDIR);
+   /*
+    * Filling TBT3 Cable VDO when TBT3 cable is being used to establish
+    * USB4 connection.
+    */
+   if (pd_ctrl->cable_gen) {
+           data.tbt_cable_vdo = TBT_MODE;
+
+           if (pd_ctrl->control_flags &

USB_PD_CTRL_ACTIVE_LINK_UNIDIR)

Quoted 5 lines
drivers/platform/chrome/cros_ec_typec.c +4 -0
+                   data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;
+
+           data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl-
 cable_gen);
+   }
Quoted 4 lines
Quoted 2 lines

I think the following would decouple Rounded Support and Active Cable Link Training?:

Any reason you would want to decouple them?

Is there anything in the spec that says Active Cable Link Training needs Rounded Cable support (or vice versa)?
If yes, could you kindly point me to the relevant portion in the spec that states this?

If no, then the two should be set independently based on the response from the Chrome EC.

FWIW, Table F-11 ( TBT3 Cable Discover Mode VDO Responses) from the USB Type-C Cable & Connector Spec (Rel 2.0) suggests
the two are independent bits although I don't have access to the TBT3 spec to confirm.

BR,

-Prashant

maintainer
#10 lore raw

Re: [PATCH v3 2/4] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode

In reply to Prashant Malani
Quoted 49 lines · Prashant Malani

Hi Utkarsh,

Quoted 32 lines · Utkarsh Patel

Configure Thunderbolt 3 cable generation value by filling Thunderbolt 3 cable discover mode VDO to support rounded Thunderbolt 3 cables. While we are here use Thunderbolt 3 cable discover mode VDO to fill active cable plug link training value.

--
Changes in v3:
- Added a check for cable's TBT support before filling TBT3 discover mode VDO.

Changes in v2:
- No change.
--

---
 drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +2 -2
index 8111ed1fc574..68b17ee1d1ae 100644
@@ -514,8 +514,18 @@ static int cros_typec_enable_usb4(struct cros_typec_data *typec,
 	else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
 		data.eudo |= EUDO_CABLE_TYPE_RE_TIMER << EUDO_CABLE_TYPE_SHIFT;
 
-	data.active_link_training = !!(pd_ctrl->control_flags &
-				       USB_PD_CTRL_ACTIVE_LINK_UNIDIR);
+	/*
+	 * Filling TBT3 Cable VDO when TBT3 cable is being used to establish

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct cros_typec_data *typec, · line 528

Quoted 10 lines
drivers/platform/chrome/cros_ec_typec.c +10 -0
+	 * USB4 connection.
+	 */
+	if (pd_ctrl->cable_gen) {
+		data.tbt_cable_vdo = TBT_MODE;
+
+		if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
+			data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;
+
+		data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
+	}

I think the following would decouple Rounded Support and Active Cable Link Training?:

Quoted 6 lines
	struct typec_thunderbolt_data data = {};
...
	if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
		data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;

	data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);

I agree with this. We should not modify the data that we actually have access to.

Quoted 2 lines
	if (data.tbt_cable_vdo)
		data.tbt_cable_vdo |= TBT_MODE;

That is wrong. If the LSRX communication is bi-directional, and/or the data rates are non-rounded, the cable has to be TBT3 cable. So I think what you would want is:

if (!data.tbt_cable_vdo)
data.tbt_cable_vdo = TBT_MODE;

But of course we can not do that either, because we have to set the TBT_MODE bit if there is any other data in tbt_cable_vdo (USB Type-C spec does not define any other valid values except 0x0001 = TBT_MODE for that field). Otherwise the mux driver should consider the data corrupted. So we would have to do this:

        if (pd_ctrl->cable_gen &&
            pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
                data.tbt_cable_vdo = 0; /* We assume USB4 cable */
        else

data.tbt_cable_vdo |= TBT_MODE; /* It is for sure TBT3 cable */

But I would not do that. TBT3 cable can also support unidirectional SBU communication and rounded data rates.

IMO safer bet for now would be to just claim that the cable is always TBT3 cable until we have access to information that can really tell us is the cable USB4 or TBT3.

But it's up to you guys.

Br,

Signature · 1 line
heikki
#11 lore raw

Re: [PATCH v3 2/4] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode

Quoted 60 lines · Heikki Krogerus
Quoted 49 lines · Prashant Malani

Hi Utkarsh,

Quoted 32 lines · Utkarsh Patel

Configure Thunderbolt 3 cable generation value by filling Thunderbolt 3 cable discover mode VDO to support rounded Thunderbolt 3 cables. While we are here use Thunderbolt 3 cable discover mode VDO to fill active cable plug link training value.

--
Changes in v3:
- Added a check for cable's TBT support before filling TBT3 discover mode VDO.

Changes in v2:
- No change.
--

---
 drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +2 -2
index 8111ed1fc574..68b17ee1d1ae 100644
@@ -514,8 +514,18 @@ static int cros_typec_enable_usb4(struct cros_typec_data *typec,
 	else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
 		data.eudo |= EUDO_CABLE_TYPE_RE_TIMER << EUDO_CABLE_TYPE_SHIFT;
 
-	data.active_link_training = !!(pd_ctrl->control_flags &
-				       USB_PD_CTRL_ACTIVE_LINK_UNIDIR);
+	/*
+	 * Filling TBT3 Cable VDO when TBT3 cable is being used to establish

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct cros_typec_data *typec, · line 528

Quoted 10 lines
drivers/platform/chrome/cros_ec_typec.c +10 -0
+	 * USB4 connection.
+	 */
+	if (pd_ctrl->cable_gen) {
+		data.tbt_cable_vdo = TBT_MODE;
+
+		if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
+			data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;
+
+		data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
+	}

I think the following would decouple Rounded Support and Active Cable Link Training?:

Quoted 6 lines
	struct typec_thunderbolt_data data = {};
...
	if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
		data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;

	data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);

I agree with this. We should not modify the data that we actually have access to.

Quoted 6 lines
Quoted 2 lines
	if (data.tbt_cable_vdo)
		data.tbt_cable_vdo |= TBT_MODE;

That is wrong. If the LSRX communication is bi-directional, and/or the data rates are non-rounded, the cable has to be TBT3 cable. So I think what you would want is:

Thanks for pointing this out, I didn't consider this case.

Quoted 14 lines

if (!data.tbt_cable_vdo)
data.tbt_cable_vdo = TBT_MODE;

But of course we can not do that either, because we have to set the TBT_MODE bit if there is any other data in tbt_cable_vdo (USB Type-C spec does not define any other valid values except 0x0001 = TBT_MODE for that field). Otherwise the mux driver should consider the data corrupted. So we would have to do this:

        if (pd_ctrl->cable_gen &&
            pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
                data.tbt_cable_vdo = 0; /* We assume USB4 cable */
        else
Quoted 8 lines

data.tbt_cable_vdo |= TBT_MODE; /* It is for sure TBT3 cable */

But I would not do that. TBT3 cable can also support unidirectional SBU communication and rounded data rates.

IMO safer bet for now would be to just claim that the cable is always TBT3 cable until we have access to information that can really tell us is the cable USB4 or TBT3.

Which brings us back to v1 of the patch :S

That still leaves my underlying concern that we'll be telling the Mux implementation that a TBT3 cable is connected when in fact it's a USB4 active cable.

How about we don't set the TBT_MODE bit at all ? IMO it's equally bad as setting it always, but with the additional advantage:

- USB4 active cable case : you are covered (since if we unilaterally set TBT_MODE then the Active USB4 cable case never gets executed in pmc_usb_mux_usb4() in drivers/usb/typec/mux/intel_pmc_mux.c Patch 3/4)

- Bidirectional LSRX non-rounded TBT: Still supported since the code path in the Intel Mux agent is the same.

I understand neither of the options are ideal, but WDYT?

BR,

-Prashant

#12 lore raw

Re: [PATCH v3 2/4] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode

Quoted 103 lines · Prashant Malani
Quoted 60 lines · Heikki Krogerus
Quoted 49 lines · Prashant Malani

Hi Utkarsh,

Quoted 32 lines · Utkarsh Patel

Configure Thunderbolt 3 cable generation value by filling Thunderbolt 3 cable discover mode VDO to support rounded Thunderbolt 3 cables. While we are here use Thunderbolt 3 cable discover mode VDO to fill active cable plug link training value.

--
Changes in v3:
- Added a check for cable's TBT support before filling TBT3 discover mode VDO.

Changes in v2:
- No change.
--

---
 drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +2 -2
index 8111ed1fc574..68b17ee1d1ae 100644
@@ -514,8 +514,18 @@ static int cros_typec_enable_usb4(struct cros_typec_data *typec,
  else if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_CABLE)
          data.eudo |= EUDO_CABLE_TYPE_RE_TIMER << EUDO_CABLE_TYPE_SHIFT;
 
- data.active_link_training = !!(pd_ctrl->control_flags &
-                                USB_PD_CTRL_ACTIVE_LINK_UNIDIR);
+ /*
+  * Filling TBT3 Cable VDO when TBT3 cable is being used to establish

drivers/platform/chrome/cros_ec_typec.c static int cros_typec_enable_usb4(struct cros_typec_data *typec, · line 528

Quoted 10 lines
drivers/platform/chrome/cros_ec_typec.c +10 -0
+  * USB4 connection.
+  */
+ if (pd_ctrl->cable_gen) {
+         data.tbt_cable_vdo = TBT_MODE;
+
+         if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
+                 data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;
+
+         data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
+ }

I think the following would decouple Rounded Support and Active Cable Link Training?:

Quoted 6 lines
    struct typec_thunderbolt_data data = {};
...
    if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
            data.tbt_cable_vdo |= TBT_CABLE_LINK_TRAINING;

    data.tbt_cable_vdo |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);

I agree with this. We should not modify the data that we actually have access to.

Quoted 6 lines
Quoted 2 lines
    if (data.tbt_cable_vdo)
            data.tbt_cable_vdo |= TBT_MODE;

That is wrong. If the LSRX communication is bi-directional, and/or the data rates are non-rounded, the cable has to be TBT3 cable. So I think what you would want is:

Thanks for pointing this out, I didn't consider this case.

Quoted 16 lines
      if (!data.tbt_cable_vdo)
              data.tbt_cable_vdo = TBT_MODE;

But of course we can not do that either, because we have to set the TBT_MODE bit if there is any other data in tbt_cable_vdo (USB Type-C spec does not define any other valid values except 0x0001 = TBT_MODE for that field). Otherwise the mux driver should consider the data corrupted. So we would have to do this:

        if (pd_ctrl->cable_gen &&
            pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
                data.tbt_cable_vdo = 0; /* We assume USB4 cable */
        else
              data.tbt_cable_vdo |= TBT_MODE; /* It is for sure TBT3 cable */
Quoted 6 lines

But I would not do that. TBT3 cable can also support unidirectional SBU communication and rounded data rates.

IMO safer bet for now would be to just claim that the cable is always TBT3 cable until we have access to information that can really tell us is the cable USB4 or TBT3.

Which brings us back to v1 of the patch :S

That still leaves my underlying concern that we'll be telling the Mux implementation that a TBT3 cable is connected when in fact it's a USB4 active cable.

How about we don't set the TBT_MODE bit at all ? IMO it's equally bad as setting it always, but with the additional advantage:

Quoted 6 lines

- USB4 active cable case : you are covered (since if we unilaterally set TBT_MODE then the Active USB4 cable case never gets executed in pmc_usb_mux_usb4() in drivers/usb/typec/mux/intel_pmc_mux.c Patch 3/4)

- Bidirectional LSRX non-rounded TBT: Still supported since the code path in the Intel Mux agent is the same.

Thinking about this a bit more, never setting TBT_MODE would mean that bidrectional LSRX non-rounded TBT would be treated the same as USB4 active cable in the mux agent
code, which is also incorrect (I think)

I need to think about this a bit more, but currently I don't have any solutions to offer.

maintainer
#13 lore raw

Re: [PATCH v3 2/4] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode

In reply to Prashant Malani

Hi Prashant,

Quoted 10 lines · Prashant Malani
Quoted 3 lines · Heikki Krogerus

IMO safer bet for now would be to just claim that the cable is always TBT3 cable until we have access to information that can really tell us is the cable USB4 or TBT3.

Which brings us back to v1 of the patch :S

That still leaves my underlying concern that we'll be telling the Mux implementation that a TBT3 cable is connected when in fact it's a USB4 active cable.

No matter what we do with these values, it does not change the fact that we do not know is the cable USB4 or TBT3 at the moment. What ever we do, we are guessing things.

Can you please explain your concern again? What can happen if we use USB4 cable but claim that it is TBT3 to the mux?

Quoted 1 line

How about we don't set the TBT_MODE bit at all ?

Let's not come up with values that are not defined in the spec for this field (or any other). Even though it is unlikely, we can not rule out the possibility that one day value of 0x0000 is defined for that field.

I'm strongly against this kind of "modifications". It would mean that the member tbt_cable_vdo does not actually contain TBT3 Cable VDO, but instead it has to be considered as driver or subsystem specific data.

Quoted 9 lines

IMO it's equally bad as setting it always, but with the additional advantage:

- USB4 active cable case : you are covered (since if we unilaterally set TBT_MODE then the Active USB4 cable case never gets executed in pmc_usb_mux_usb4() in drivers/usb/typec/mux/intel_pmc_mux.c Patch 3/4)

- Bidirectional LSRX non-rounded TBT: Still supported since the code path in the Intel Mux agent is the same.

This case will not work. The tbt_cable_vdo member is now 0, which to the mux driver means that the cable is USB4 cable (and that is what it really must mean to the mux driver - any mux driver). The mux driver will therefore enable unidirectional SBU communication even though it is actually bidirectional, and also rounded data rates even though the cable supports only non-rounded data rates.

Quoted 1 line

I understand neither of the options are ideal, but WDYT?

I may be missing something, but I'm still going to say that let's just claim that the cable is always TBT3 for now in this driver. That is the only safe bet that we have.

thanks,

Signature · 1 line
heikki
#14 lore raw

PATCH v3 3/4 usb: typec: intel_pmc_mux: Configure active cable properties for USB4

In reply to Utkarsh Patel

Value received as a part of Thunderbolt 3 cable discover mode VDO needs to be configured in the USB4 mode for the cable rounded support and active cable plug link training.

--
Changes in v3:
- Moved TBT_CABLE_ROUNDED_SUPPORT assignment to the same line.

Changes in v2:
- No change.
--

---
 drivers/usb/typec/mux/intel_pmc_mux.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/usb/typec/mux/intel_pmc_mux.c +14 -3
index aa3211f1c4c3..baf343b14682 100644
@@ -295,6 +295,7 @@ pmc_usb_mux_usb4(struct pmc_usb_port *port, struct typec_mux_state *state)
 {
 	struct enter_usb_data *data = state->data;
 	struct altmode_req req = { };
+	u8 cable_rounded;
 	u8 cable_speed;
 
 	if (IOM_PORT_ACTIVITY_IS(port->iom_status, TBT) ||
@@ -308,9 +309,6 @@ pmc_usb_mux_usb4(struct pmc_usb_port *port, struct typec_mux_state *state)
 	/* USB4 Mode */
 	req.mode_data = PMC_USB_ALTMODE_FORCE_LSR;
 
-	if (data->active_link_training)
-		req.mode_data |= PMC_USB_ALTMODE_ACTIVE_LINK;
-
 	req.mode_data |= (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT;
 	req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT;
 
@@ -322,6 +320,19 @@ pmc_usb_mux_usb4(struct pmc_usb_port *port, struct typec_mux_state *state)
 		fallthrough;
 	default:
 		req.mode_data |= PMC_USB_ALTMODE_ACTIVE_CABLE;
+
+		if (data->tbt_cable_vdo) {
+			/* Active Thunderbolt 3 cable */
+			if (data->tbt_cable_vdo & TBT_CABLE_LINK_TRAINING)
+				req.mode_data |= PMC_USB_ALTMODE_ACTIVE_LINK;
+
+			cable_rounded = TBT_CABLE_ROUNDED_SUPPORT(data->tbt_cable_vdo);
+			req.mode_data |= PMC_USB_ALTMODE_TBT_GEN(cable_rounded);
+		} else {
+			/* Active USB4 cable */
+			req.mode_data |= PMC_USB_ALTMODE_ACTIVE_LINK |
+				PMC_USB_ALTMODE_TBT_GEN(1);
+		}
 		break;
 	}
 
Signature · 1 line
2.17.1
#15 lore raw

PATCH v3 4/4 usb: typec: Remove active_link_training variable from Enter_USB message

In reply to Utkarsh Patel

Thunderbolt 3 cable discover mode VDO support has been added as part of Enter_USB message to fill details of active cable plug link training. Hence, removing unused variable active_link_training from Enter_USB message data structure.

--
Changes in v3:
- Rebased and Added Reviewed-by tag.

Changes in v2:
- No change.
--

---
 include/linux/usb/typec.h | 6 ------
 1 file changed, 6 deletions(-)
include/linux/usb/typec.h +0 -6
index 25731ed863fa..d26824a30ff9 100644
@@ -79,16 +79,10 @@ enum typec_orientation {
  * @tbt_cable_vdo needs to be filled with details of active cable plug link
  * training and cable rounded support when thunderbolt 3 cable is being used to
  * create USB4 connection. Do not fill this in case of USB4 cable.
- * @active_link_training: Active Cable Plug Link Training
- *
- * @active_link_training is a flag that should be set with uni-directional SBRX
- * communication, and left 0 with passive cables and with bi-directional SBRX
- * communication.
  */
 struct enter_usb_data {
 	u32			eudo;
 	u32			tbt_cable_vdo;
-	unsigned char		active_link_training:1;
 };
 
 /*
Signature · 1 line
2.17.1