linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support
@ 2020-11-13 20:24 Utkarsh Patel
  2020-11-13 20:24 ` [PATCH v2 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support Utkarsh Patel
                   ` (8 more replies)
  0 siblings, 9 replies; 28+ messages in thread
From: Utkarsh Patel @ 2020-11-13 20:24 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

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 v2:
- Removed the fixes tag as there is no functional implication from patches
  1/8, 2/8 and 4/8.

Utkarsh Patel (8):
  usb: typec: Correct the bit values for the Thunderbolt
    rounded/non-rounded cable support
  platform/chrome: cros_ec_typec: Correct the Thunderbolt
    rounded/non-rounded cable support
  usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits
  usb: typec: Remove one bit support for the Thunderbolt
    rounded/non-rounded cable
  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 | 17 +++++++++++++----
 drivers/usb/typec/mux/intel_pmc_mux.c   | 21 ++++++++++++++++++---
 include/linux/usb/typec.h               |  8 ++------
 include/linux/usb/typec_tbt.h           |  6 +++++-
 4 files changed, 38 insertions(+), 14 deletions(-)

-- 
2.17.1


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

* [PATCH v2 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support
  2020-11-13 20:24 [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
@ 2020-11-13 20:24 ` Utkarsh Patel
  2020-11-17 10:43   ` Heikki Krogerus
  2020-11-13 20:24 ` [PATCH v2 2/8] platform/chrome: cros_ec_typec: Correct " Utkarsh Patel
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Utkarsh Patel @ 2020-11-13 20:24 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

Rounded and non-rounded Thunderbolt cables are represented by two bits as
per USB Type-C Connector specification v2.0 section F.2.6.
Corrected that in the Thunderbolt 3 cable discover mode VDO.

Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

--
Changes in v2:
- Removed the fixes tag as there is no functional implication.
--
---
 include/linux/usb/typec_tbt.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
index 47c2d501ddce..aad648d14bb3 100644
--- a/include/linux/usb/typec_tbt.h
+++ b/include/linux/usb/typec_tbt.h
@@ -40,11 +40,16 @@ struct typec_thunderbolt_data {
 #define   TBT_CABLE_USB3_PASSIVE	2
 #define   TBT_CABLE_10_AND_20GBPS	3
 #define TBT_CABLE_ROUNDED		BIT(19)
+#define TBT_CABLE_ROUNDED_SUPPORT(_vdo_) \
+					(((_vdo_) & GENMASK(20, 19)) >> 19)
+#define   TBT_GEN3_NON_ROUNDED                 0
+#define   TBT_GEN3_GEN4_ROUNDED_NON_ROUNDED    1
 #define TBT_CABLE_OPTICAL		BIT(21)
 #define TBT_CABLE_RETIMER		BIT(22)
 #define TBT_CABLE_LINK_TRAINING		BIT(23)
 
 #define TBT_SET_CABLE_SPEED(_s_)	(((_s_) & GENMASK(2, 0)) << 16)
+#define TBT_SET_CABLE_ROUNDED(_g_)	(((_g_) & GENMASK(1, 0)) << 19)
 
 /* TBT3 Device Enter Mode VDO bits */
 #define TBT_ENTER_MODE_CABLE_SPEED(s)	TBT_SET_CABLE_SPEED(s)
-- 
2.17.1


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

* [PATCH v2 2/8] platform/chrome: cros_ec_typec: Correct the Thunderbolt rounded/non-rounded cable support
  2020-11-13 20:24 [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
  2020-11-13 20:24 ` [PATCH v2 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support Utkarsh Patel
@ 2020-11-13 20:24 ` Utkarsh Patel
  2020-11-17 10:44   ` Heikki Krogerus
  2020-11-17 10:49   ` Enric Balletbo i Serra
  2020-11-13 20:24 ` [PATCH v2 3/8] usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits Utkarsh Patel
                   ` (6 subsequent siblings)
  8 siblings, 2 replies; 28+ messages in thread
From: Utkarsh Patel @ 2020-11-13 20:24 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

Thunderbolt rounded/non-rounded cable support is two bits value. Correcting
it as per the Thunderbolt 3 cable discover mode VDO changes done in the
Thunderbolt 3 alternate mode header.

Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
--
Changes in v2:
- Removed the fixes tag as there is no functional implication.
--
---
 drivers/platform/chrome/cros_ec_typec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 31be31161350..8111ed1fc574 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -438,8 +438,7 @@ static int cros_typec_enable_tbt(struct cros_typec_data *typec,
 	if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
 		data.cable_mode |= TBT_CABLE_LINK_TRAINING;
 
-	if (pd_ctrl->cable_gen)
-		data.cable_mode |= TBT_CABLE_ROUNDED;
+	data.cable_mode |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
 
 	/* Enter Mode VDO */
 	data.enter_vdo = TBT_SET_CABLE_SPEED(pd_ctrl->cable_speed);
-- 
2.17.1


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

* [PATCH v2 3/8] usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits
  2020-11-13 20:24 [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
  2020-11-13 20:24 ` [PATCH v2 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support Utkarsh Patel
  2020-11-13 20:24 ` [PATCH v2 2/8] platform/chrome: cros_ec_typec: Correct " Utkarsh Patel
@ 2020-11-13 20:24 ` Utkarsh Patel
  2020-11-17 10:45   ` Heikki Krogerus
  2020-11-13 20:24 ` [PATCH v2 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable Utkarsh Patel
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Utkarsh Patel @ 2020-11-13 20:24 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

Thunderbolt cable generation bits received as a part of Thunderbolt 3 cable
discover mode VDO needs to be configured for Thunderbolt rounded and
non-rounded cable support in the Thunderbolt alternate mode.

Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

--
Changes in v2:
- No change.
--
---
 drivers/usb/typec/mux/intel_pmc_mux.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index d7f63b74c6b1..aa3211f1c4c3 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -256,6 +256,7 @@ static int
 pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)
 {
 	struct typec_thunderbolt_data *data = state->data;
+	u8 cable_rounded = TBT_CABLE_ROUNDED_SUPPORT(data->cable_mode);
 	u8 cable_speed = TBT_CABLE_SPEED(data->cable_mode);
 	struct altmode_req req = { };
 
@@ -284,6 +285,8 @@ pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)
 
 	req.mode_data |= PMC_USB_ALTMODE_CABLE_SPD(cable_speed);
 
+	req.mode_data |= PMC_USB_ALTMODE_TBT_GEN(cable_rounded);
+
 	return pmc_usb_command(port, (void *)&req, sizeof(req));
 }
 
-- 
2.17.1


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

* [PATCH v2 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable
  2020-11-13 20:24 [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
                   ` (2 preceding siblings ...)
  2020-11-13 20:24 ` [PATCH v2 3/8] usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits Utkarsh Patel
@ 2020-11-13 20:24 ` Utkarsh Patel
  2020-11-17 10:46   ` Heikki Krogerus
  2020-11-13 20:25 ` [PATCH v2 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message Utkarsh Patel
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Utkarsh Patel @ 2020-11-13 20:24 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

Two bits support for the Thunderbolt rounded/non-rounded cable has been
added to the header file.
Hence, removing unused TBT_CABLE_ROUNDED definition from the header file.

Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

--
changes in v2:
- Removed the fixes tag as there is no functional implication.
--
---
 include/linux/usb/typec_tbt.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
index aad648d14bb3..63dd44b72e0c 100644
--- a/include/linux/usb/typec_tbt.h
+++ b/include/linux/usb/typec_tbt.h
@@ -39,7 +39,6 @@ struct typec_thunderbolt_data {
 #define   TBT_CABLE_USB3_GEN1		1
 #define   TBT_CABLE_USB3_PASSIVE	2
 #define   TBT_CABLE_10_AND_20GBPS	3
-#define TBT_CABLE_ROUNDED		BIT(19)
 #define TBT_CABLE_ROUNDED_SUPPORT(_vdo_) \
 					(((_vdo_) & GENMASK(20, 19)) >> 19)
 #define   TBT_GEN3_NON_ROUNDED                 0
-- 
2.17.1


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

* [PATCH v2 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message
  2020-11-13 20:24 [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
                   ` (3 preceding siblings ...)
  2020-11-13 20:24 ` [PATCH v2 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable Utkarsh Patel
@ 2020-11-13 20:25 ` Utkarsh Patel
  2020-11-17 12:09   ` Heikki Krogerus
  2020-11-17 21:16   ` Prashant Malani
  2020-11-13 20:25 ` [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode Utkarsh Patel
                   ` (3 subsequent siblings)
  8 siblings, 2 replies; 28+ messages in thread
From: Utkarsh Patel @ 2020-11-13 20:25 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

USB4 also uses same cable properties as Thunderbolt 3 so use Thunderbolt 3
cable discover mode VDO to fill details such as active cable plug link
training and cable rounded support.

Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

--
Changes in v2:
- No change.
--
---
 include/linux/usb/typec.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index 6be558045942..d91e09d9d91c 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -75,6 +75,7 @@ enum typec_orientation {
 /*
  * struct enter_usb_data - Enter_USB Message details
  * @eudo: Enter_USB Data Object
+ * @tbt_cable_vdo: TBT3 Cable Discover Mode Response
  * @active_link_training: Active Cable Plug Link Training
  *
  * @active_link_training is a flag that should be set with uni-directional SBRX
@@ -83,6 +84,7 @@ enum typec_orientation {
  */
 struct enter_usb_data {
 	u32			eudo;
+	u32			tbt_cable_vdo;
 	unsigned char		active_link_training:1;
 };
 
-- 
2.17.1


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

* [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode
  2020-11-13 20:24 [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
                   ` (4 preceding siblings ...)
  2020-11-13 20:25 ` [PATCH v2 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message Utkarsh Patel
@ 2020-11-13 20:25 ` Utkarsh Patel
  2020-11-17 10:49   ` Enric Balletbo i Serra
                     ` (2 more replies)
  2020-11-13 20:25 ` [PATCH v2 7/8] usb: typec: intel_pmc_mux: Configure active cable properties for USB4 Utkarsh Patel
                   ` (2 subsequent siblings)
  8 siblings, 3 replies; 28+ messages in thread
From: Utkarsh Patel @ 2020-11-13 20:25 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

Configure Thunderbolt3/USB4 cable generation value by filing Thunderbolt 3
cable discover mode VDO to support rounded and non-rounded Thunderbolt3/
USB4 cables.
While we are here use Thunderbolt 3 cable discover mode VDO to fill active
cable plug link training value.

Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

--
Changes in v2:
- No change.
--
---
 drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 8111ed1fc574..b7416e82c3b3 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -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);
+	/*
+	 * This driver does not have access to the identity information or
+	 * capabilities of the cable, so we don't know is it a real USB4 or
+	 * TBT3 cable. Therefore pretending that it's always TBT3 cable by
+	 * filling the TBT3 Cable VDO.
+	 */
+	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;
-- 
2.17.1


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

* [PATCH v2 7/8] usb: typec: intel_pmc_mux: Configure active cable properties for USB4
  2020-11-13 20:24 [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
                   ` (5 preceding siblings ...)
  2020-11-13 20:25 ` [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode Utkarsh Patel
@ 2020-11-13 20:25 ` Utkarsh Patel
  2020-11-17 12:21   ` Heikki Krogerus
  2020-11-13 20:25 ` [PATCH v2 8/8] usb: typec: Remove active_link_training variable from Enter_USB message Utkarsh Patel
  2020-11-18 11:54 ` [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Greg KH
  8 siblings, 1 reply; 28+ messages in thread
From: Utkarsh Patel @ 2020-11-13 20:25 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, Utkarsh Patel

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

Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

--
Changes in v2:
- No change.
--
---
 drivers/usb/typec/mux/intel_pmc_mux.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index aa3211f1c4c3..61feb358aad3 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -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,20 @@ 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;
 	}
 
-- 
2.17.1


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

* [PATCH v2 8/8] usb: typec: Remove active_link_training variable from Enter_USB message
  2020-11-13 20:24 [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
                   ` (6 preceding siblings ...)
  2020-11-13 20:25 ` [PATCH v2 7/8] usb: typec: intel_pmc_mux: Configure active cable properties for USB4 Utkarsh Patel
@ 2020-11-13 20:25 ` Utkarsh Patel
  2020-11-17 12:22   ` Heikki Krogerus
  2020-11-18 11:54 ` [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Greg KH
  8 siblings, 1 reply; 28+ messages in thread
From: Utkarsh Patel @ 2020-11-13 20:25 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh, 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.

Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

--
Changes in v2:
- No change.
--
---
 include/linux/usb/typec.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index d91e09d9d91c..4a9608a15ac1 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -76,16 +76,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
- * @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;
 };
 
 /*
-- 
2.17.1


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

* Re: [PATCH v2 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support
  2020-11-13 20:24 ` [PATCH v2 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support Utkarsh Patel
@ 2020-11-17 10:43   ` Heikki Krogerus
  0 siblings, 0 replies; 28+ messages in thread
From: Heikki Krogerus @ 2020-11-17 10:43 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh

On Fri, Nov 13, 2020 at 12:24:56PM -0800, Utkarsh Patel wrote:
> Rounded and non-rounded Thunderbolt cables are represented by two bits as
> per USB Type-C Connector specification v2.0 section F.2.6.
> Corrected that in the Thunderbolt 3 cable discover mode VDO.
> 
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

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

> --
> Changes in v2:
> - Removed the fixes tag as there is no functional implication.
> --
> ---
>  include/linux/usb/typec_tbt.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
> index 47c2d501ddce..aad648d14bb3 100644
> --- a/include/linux/usb/typec_tbt.h
> +++ b/include/linux/usb/typec_tbt.h
> @@ -40,11 +40,16 @@ struct typec_thunderbolt_data {
>  #define   TBT_CABLE_USB3_PASSIVE	2
>  #define   TBT_CABLE_10_AND_20GBPS	3
>  #define TBT_CABLE_ROUNDED		BIT(19)
> +#define TBT_CABLE_ROUNDED_SUPPORT(_vdo_) \
> +					(((_vdo_) & GENMASK(20, 19)) >> 19)
> +#define   TBT_GEN3_NON_ROUNDED                 0
> +#define   TBT_GEN3_GEN4_ROUNDED_NON_ROUNDED    1
>  #define TBT_CABLE_OPTICAL		BIT(21)
>  #define TBT_CABLE_RETIMER		BIT(22)
>  #define TBT_CABLE_LINK_TRAINING		BIT(23)
>  
>  #define TBT_SET_CABLE_SPEED(_s_)	(((_s_) & GENMASK(2, 0)) << 16)
> +#define TBT_SET_CABLE_ROUNDED(_g_)	(((_g_) & GENMASK(1, 0)) << 19)
>  
>  /* TBT3 Device Enter Mode VDO bits */
>  #define TBT_ENTER_MODE_CABLE_SPEED(s)	TBT_SET_CABLE_SPEED(s)

thanks,

-- 
heikki

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

* Re: [PATCH v2 2/8] platform/chrome: cros_ec_typec: Correct the Thunderbolt rounded/non-rounded cable support
  2020-11-13 20:24 ` [PATCH v2 2/8] platform/chrome: cros_ec_typec: Correct " Utkarsh Patel
@ 2020-11-17 10:44   ` Heikki Krogerus
  2020-11-17 10:49   ` Enric Balletbo i Serra
  1 sibling, 0 replies; 28+ messages in thread
From: Heikki Krogerus @ 2020-11-17 10:44 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh

On Fri, Nov 13, 2020 at 12:24:57PM -0800, Utkarsh Patel wrote:
> Thunderbolt rounded/non-rounded cable support is two bits value. Correcting
> it as per the Thunderbolt 3 cable discover mode VDO changes done in the
> Thunderbolt 3 alternate mode header.
> 
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

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

> --
> Changes in v2:
> - Removed the fixes tag as there is no functional implication.
> --
> ---
>  drivers/platform/chrome/cros_ec_typec.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 31be31161350..8111ed1fc574 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -438,8 +438,7 @@ static int cros_typec_enable_tbt(struct cros_typec_data *typec,
>  	if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
>  		data.cable_mode |= TBT_CABLE_LINK_TRAINING;
>  
> -	if (pd_ctrl->cable_gen)
> -		data.cable_mode |= TBT_CABLE_ROUNDED;
> +	data.cable_mode |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
>  
>  	/* Enter Mode VDO */
>  	data.enter_vdo = TBT_SET_CABLE_SPEED(pd_ctrl->cable_speed);
> -- 
> 2.17.1

thanks,

-- 
heikki

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

* Re: [PATCH v2 3/8] usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits
  2020-11-13 20:24 ` [PATCH v2 3/8] usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits Utkarsh Patel
@ 2020-11-17 10:45   ` Heikki Krogerus
  0 siblings, 0 replies; 28+ messages in thread
From: Heikki Krogerus @ 2020-11-17 10:45 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh

On Fri, Nov 13, 2020 at 12:24:58PM -0800, Utkarsh Patel wrote:
> Thunderbolt cable generation bits received as a part of Thunderbolt 3 cable
> discover mode VDO needs to be configured for Thunderbolt rounded and
> non-rounded cable support in the Thunderbolt alternate mode.
> 
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

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

> --
> Changes in v2:
> - No change.
> --
> ---
>  drivers/usb/typec/mux/intel_pmc_mux.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
> index d7f63b74c6b1..aa3211f1c4c3 100644
> --- a/drivers/usb/typec/mux/intel_pmc_mux.c
> +++ b/drivers/usb/typec/mux/intel_pmc_mux.c
> @@ -256,6 +256,7 @@ static int
>  pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)
>  {
>  	struct typec_thunderbolt_data *data = state->data;
> +	u8 cable_rounded = TBT_CABLE_ROUNDED_SUPPORT(data->cable_mode);
>  	u8 cable_speed = TBT_CABLE_SPEED(data->cable_mode);
>  	struct altmode_req req = { };
>  
> @@ -284,6 +285,8 @@ pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)
>  
>  	req.mode_data |= PMC_USB_ALTMODE_CABLE_SPD(cable_speed);
>  
> +	req.mode_data |= PMC_USB_ALTMODE_TBT_GEN(cable_rounded);
> +
>  	return pmc_usb_command(port, (void *)&req, sizeof(req));
>  }
>  
> -- 
> 2.17.1

-- 
heikki

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

* Re: [PATCH v2 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable
  2020-11-13 20:24 ` [PATCH v2 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable Utkarsh Patel
@ 2020-11-17 10:46   ` Heikki Krogerus
  0 siblings, 0 replies; 28+ messages in thread
From: Heikki Krogerus @ 2020-11-17 10:46 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh

On Fri, Nov 13, 2020 at 12:24:59PM -0800, Utkarsh Patel wrote:
> Two bits support for the Thunderbolt rounded/non-rounded cable has been
> added to the header file.
> Hence, removing unused TBT_CABLE_ROUNDED definition from the header file.
> 
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

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

> --
> changes in v2:
> - Removed the fixes tag as there is no functional implication.
> --
> ---
>  include/linux/usb/typec_tbt.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
> index aad648d14bb3..63dd44b72e0c 100644
> --- a/include/linux/usb/typec_tbt.h
> +++ b/include/linux/usb/typec_tbt.h
> @@ -39,7 +39,6 @@ struct typec_thunderbolt_data {
>  #define   TBT_CABLE_USB3_GEN1		1
>  #define   TBT_CABLE_USB3_PASSIVE	2
>  #define   TBT_CABLE_10_AND_20GBPS	3
> -#define TBT_CABLE_ROUNDED		BIT(19)
>  #define TBT_CABLE_ROUNDED_SUPPORT(_vdo_) \
>  					(((_vdo_) & GENMASK(20, 19)) >> 19)
>  #define   TBT_GEN3_NON_ROUNDED                 0
> -- 
> 2.17.1

thanks,

-- 
heikki

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

* Re: [PATCH v2 2/8] platform/chrome: cros_ec_typec: Correct the Thunderbolt rounded/non-rounded cable support
  2020-11-13 20:24 ` [PATCH v2 2/8] platform/chrome: cros_ec_typec: Correct " Utkarsh Patel
  2020-11-17 10:44   ` Heikki Krogerus
@ 2020-11-17 10:49   ` Enric Balletbo i Serra
  1 sibling, 0 replies; 28+ messages in thread
From: Enric Balletbo i Serra @ 2020-11-17 10:49 UTC (permalink / raw)
  To: Utkarsh Patel, linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, rajmohan.mani, azhar.shaikh



On 13/11/20 21:24, Utkarsh Patel wrote:
> Thunderbolt rounded/non-rounded cable support is two bits value. Correcting
> it as per the Thunderbolt 3 cable discover mode VDO changes done in the
> Thunderbolt 3 alternate mode header.
> 
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

> --
> Changes in v2:
> - Removed the fixes tag as there is no functional implication.
> --
> ---
>  drivers/platform/chrome/cros_ec_typec.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 31be31161350..8111ed1fc574 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -438,8 +438,7 @@ static int cros_typec_enable_tbt(struct cros_typec_data *typec,
>  	if (pd_ctrl->control_flags & USB_PD_CTRL_ACTIVE_LINK_UNIDIR)
>  		data.cable_mode |= TBT_CABLE_LINK_TRAINING;
>  
> -	if (pd_ctrl->cable_gen)
> -		data.cable_mode |= TBT_CABLE_ROUNDED;
> +	data.cable_mode |= TBT_SET_CABLE_ROUNDED(pd_ctrl->cable_gen);
>  
>  	/* Enter Mode VDO */
>  	data.enter_vdo = TBT_SET_CABLE_SPEED(pd_ctrl->cable_speed);
> 

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

* Re: [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode
  2020-11-13 20:25 ` [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode Utkarsh Patel
@ 2020-11-17 10:49   ` Enric Balletbo i Serra
  2020-11-17 12:10   ` Heikki Krogerus
  2020-11-17 18:19   ` Prashant Malani
  2 siblings, 0 replies; 28+ messages in thread
From: Enric Balletbo i Serra @ 2020-11-17 10:49 UTC (permalink / raw)
  To: Utkarsh Patel, linux-kernel, linux-usb
  Cc: heikki.krogerus, pmalani, rajmohan.mani, azhar.shaikh



On 13/11/20 21:25, Utkarsh Patel wrote:
> Configure Thunderbolt3/USB4 cable generation value by filing Thunderbolt 3
> cable discover mode VDO to support rounded and non-rounded Thunderbolt3/
> USB4 cables.
> While we are here use Thunderbolt 3 cable discover mode VDO to fill active
> cable plug link training value.
> 
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

> 
> --
> Changes in v2:
> - No change.
> --
> ---
>  drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 8111ed1fc574..b7416e82c3b3 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -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);
> +	/*
> +	 * This driver does not have access to the identity information or
> +	 * capabilities of the cable, so we don't know is it a real USB4 or
> +	 * TBT3 cable. Therefore pretending that it's always TBT3 cable by
> +	 * filling the TBT3 Cable VDO.
> +	 */
> +	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;
> 

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

* Re: [PATCH v2 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message
  2020-11-13 20:25 ` [PATCH v2 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message Utkarsh Patel
@ 2020-11-17 12:09   ` Heikki Krogerus
  2020-11-17 23:28     ` Patel, Utkarsh H
  2020-11-17 21:16   ` Prashant Malani
  1 sibling, 1 reply; 28+ messages in thread
From: Heikki Krogerus @ 2020-11-17 12:09 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh

On Fri, Nov 13, 2020 at 12:25:00PM -0800, Utkarsh Patel wrote:
> USB4 also uses same cable properties as Thunderbolt 3 so use Thunderbolt 3
> cable discover mode VDO to fill details such as active cable plug link
> training and cable rounded support.

I'm sorry, but I think that has to be explained better. We only need
the Thunderbolt 3 properties when we create the USB4 connection with
Thunderbolt 3 cables. With USB4 cables that information is simply not
available. Claiming that USB4 uses the same properties in general is
not true.

> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> --
> Changes in v2:
> - No change.
> --
> ---
>  include/linux/usb/typec.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> index 6be558045942..d91e09d9d91c 100644
> --- a/include/linux/usb/typec.h
> +++ b/include/linux/usb/typec.h
> @@ -75,6 +75,7 @@ enum typec_orientation {
>  /*
>   * struct enter_usb_data - Enter_USB Message details
>   * @eudo: Enter_USB Data Object
> + * @tbt_cable_vdo: TBT3 Cable Discover Mode Response
>   * @active_link_training: Active Cable Plug Link Training
>   *
>   * @active_link_training is a flag that should be set with uni-directional SBRX

Please also explain the same here with a short comment. So basically,
if the USB4 connection is created using TBT3 cable, then we need to
supply also the TBT3 Cable VDO as part of this data. But if USB4
cable is used, then that member should not be filled at all.

> @@ -83,6 +84,7 @@ enum typec_orientation {
>   */
>  struct enter_usb_data {
>  	u32			eudo;
> +	u32			tbt_cable_vdo;
>  	unsigned char		active_link_training:1;
>  };

thanks,

-- 
heikki

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

* Re: [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode
  2020-11-13 20:25 ` [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode Utkarsh Patel
  2020-11-17 10:49   ` Enric Balletbo i Serra
@ 2020-11-17 12:10   ` Heikki Krogerus
  2020-11-17 18:19   ` Prashant Malani
  2 siblings, 0 replies; 28+ messages in thread
From: Heikki Krogerus @ 2020-11-17 12:10 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh

On Fri, Nov 13, 2020 at 12:25:01PM -0800, Utkarsh Patel wrote:
> Configure Thunderbolt3/USB4 cable generation value by filing Thunderbolt 3
> cable discover mode VDO to support rounded and non-rounded Thunderbolt3/
> USB4 cables.
> While we are here use Thunderbolt 3 cable discover mode VDO to fill active
> cable plug link training value.
> 
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

FWIW:

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

> --
> Changes in v2:
> - No change.
> --
> ---
>  drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 8111ed1fc574..b7416e82c3b3 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -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);
> +	/*
> +	 * This driver does not have access to the identity information or
> +	 * capabilities of the cable, so we don't know is it a real USB4 or
> +	 * TBT3 cable. Therefore pretending that it's always TBT3 cable by
> +	 * filling the TBT3 Cable VDO.
> +	 */
> +	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;
> -- 
> 2.17.1

-- 
heikki

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

* Re: [PATCH v2 7/8] usb: typec: intel_pmc_mux: Configure active cable properties for USB4
  2020-11-13 20:25 ` [PATCH v2 7/8] usb: typec: intel_pmc_mux: Configure active cable properties for USB4 Utkarsh Patel
@ 2020-11-17 12:21   ` Heikki Krogerus
  2020-11-17 22:37     ` Patel, Utkarsh H
  0 siblings, 1 reply; 28+ messages in thread
From: Heikki Krogerus @ 2020-11-17 12:21 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh

On Fri, Nov 13, 2020 at 12:25:02PM -0800, Utkarsh Patel wrote:
> Value received as a part of Thunderbolt 3 cable discover mode VDO needs
> to be configured in the USB4 mode for the Thunderbolt rounded support and
> active cable plug link training.
> 
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> 
> --
> Changes in v2:
> - No change.
> --
> ---
>  drivers/usb/typec/mux/intel_pmc_mux.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
> index aa3211f1c4c3..61feb358aad3 100644
> --- a/drivers/usb/typec/mux/intel_pmc_mux.c
> +++ b/drivers/usb/typec/mux/intel_pmc_mux.c
> @@ -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,20 @@ 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);

No need for the newline:

			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;
>  	}

thanks,

-- 
heikki

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

* Re: [PATCH v2 8/8] usb: typec: Remove active_link_training variable from Enter_USB message
  2020-11-13 20:25 ` [PATCH v2 8/8] usb: typec: Remove active_link_training variable from Enter_USB message Utkarsh Patel
@ 2020-11-17 12:22   ` Heikki Krogerus
  0 siblings, 0 replies; 28+ messages in thread
From: Heikki Krogerus @ 2020-11-17 12:22 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, rajmohan.mani,
	azhar.shaikh

On Fri, Nov 13, 2020 at 12:25:03PM -0800, Utkarsh Patel wrote:
> 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.
> 
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>

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

> --
> Changes in v2:
> - No change.
> --
> ---
>  include/linux/usb/typec.h | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> index d91e09d9d91c..4a9608a15ac1 100644
> --- a/include/linux/usb/typec.h
> +++ b/include/linux/usb/typec.h
> @@ -76,16 +76,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
> - * @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;
>  };
>  
>  /*
> -- 
> 2.17.1

thanks,

-- 
heikki

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

* Re: [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode
  2020-11-13 20:25 ` [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode Utkarsh Patel
  2020-11-17 10:49   ` Enric Balletbo i Serra
  2020-11-17 12:10   ` Heikki Krogerus
@ 2020-11-17 18:19   ` Prashant Malani
  2020-11-18  1:06     ` Prashant Malani
  2 siblings, 1 reply; 28+ messages in thread
From: Prashant Malani @ 2020-11-17 18:19 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, heikki.krogerus, enric.balletbo,
	rajmohan.mani, azhar.shaikh

Hi Utkarsh,

On Fri, Nov 13, 2020 at 12:25:01PM -0800, Utkarsh Patel wrote:
> Configure Thunderbolt3/USB4 cable generation value by filing Thunderbolt 3
> cable discover mode VDO to support rounded and non-rounded Thunderbolt3/
> USB4 cables.
> While we are here use Thunderbolt 3 cable discover mode VDO to fill active
> cable plug link training value.
> 
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> 
> --
> Changes in v2:
> - No change.
> --
> ---
>  drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 8111ed1fc574..b7416e82c3b3 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -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);
> +	/*
> +	 * This driver does not have access to the identity information or
> +	 * capabilities of the cable, so we don't know is it a real USB4 or
> +	 * TBT3 cable. Therefore pretending that it's always TBT3 cable by
> +	 * filling the TBT3 Cable VDO.
> +	 */
> +	data.tbt_cable_vdo = TBT_MODE;

Is it safe to be making this assumption unconditionally? It might work for
Intel Mux agent but is it guaranteed to be safe for any other future
mux implementation? In other words, what if a "true" USB4 cable is
connected which doesn't have the Thunderbolt SVID alt mode?

(Pre-fetching some alternatives in case the answer is no)

You might want to check with the Cros EC team if you can repurpose a bit of
the "reserved" field for specifying whether the cable is TBT or not.

Either that or see if there is a way to determine from the pd_ctrl->cable_speed
whether the cable is actually TBT or not.

Failing all the above, perhaps you'll have to wait for the PD discovery stuff
to make it's way through review and use that (note that there may be
timing issues between the Mux update event and PD discovery complete
event reaching the port driver).

Best regards,

-Prashant

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

* Re: [PATCH v2 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message
  2020-11-13 20:25 ` [PATCH v2 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message Utkarsh Patel
  2020-11-17 12:09   ` Heikki Krogerus
@ 2020-11-17 21:16   ` Prashant Malani
  2020-11-18  0:44     ` Prashant Malani
  1 sibling, 1 reply; 28+ messages in thread
From: Prashant Malani @ 2020-11-17 21:16 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, heikki.krogerus, enric.balletbo,
	rajmohan.mani, azhar.shaikh

Hi Utkarsh,

On Fri, Nov 13, 2020 at 12:25:00PM -0800, Utkarsh Patel wrote:
> USB4 also uses same cable properties as Thunderbolt 3 so use Thunderbolt 3
> cable discover mode VDO to fill details such as active cable plug link
> training and cable rounded support.
> 
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> 
> --
> Changes in v2:
> - No change.
> --
> ---
>  include/linux/usb/typec.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> index 6be558045942..d91e09d9d91c 100644
> --- a/include/linux/usb/typec.h
> +++ b/include/linux/usb/typec.h
> @@ -75,6 +75,7 @@ enum typec_orientation {
>  /*
>   * struct enter_usb_data - Enter_USB Message details
>   * @eudo: Enter_USB Data Object
> + * @tbt_cable_vdo: TBT3 Cable Discover Mode Response
>   * @active_link_training: Active Cable Plug Link Training
>   *
>   * @active_link_training is a flag that should be set with uni-directional SBRX
> @@ -83,6 +84,7 @@ enum typec_orientation {
>   */
>  struct enter_usb_data {
>  	u32			eudo;
> +	u32			tbt_cable_vdo;

Can we instead just include a field for the rounded cable support property
, similar to what was done for active_link_training? That way this gets decoupled
from whether a TBT VDO was present in the cable or not

>  	unsigned char		active_link_training:1;
>  };
>  
> -- 
> 2.17.1
> 

Best regards,

-Prashant

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

* RE: [PATCH v2 7/8] usb: typec: intel_pmc_mux: Configure active cable properties for USB4
  2020-11-17 12:21   ` Heikki Krogerus
@ 2020-11-17 22:37     ` Patel, Utkarsh H
  0 siblings, 0 replies; 28+ messages in thread
From: Patel, Utkarsh H @ 2020-11-17 22:37 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, Mani, Rajmohan,
	Shaikh, Azhar

Hi Heikki,

> -----Original Message-----
> From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Sent: Tuesday, November 17, 2020 4:22 AM
> To: Patel, Utkarsh H <utkarsh.h.patel@intel.com>
> Cc: linux-kernel@vger.kernel.org; linux-usb@vger.kernel.org;
> pmalani@chromium.org; enric.balletbo@collabora.com; Mani, Rajmohan
> <rajmohan.mani@intel.com>; Shaikh, Azhar <azhar.shaikh@intel.com>
> Subject: Re: [PATCH v2 7/8] usb: typec: intel_pmc_mux: Configure active cable
> properties for USB4
> 
> On Fri, Nov 13, 2020 at 12:25:02PM -0800, Utkarsh Patel wrote:
> > Value received as a part of Thunderbolt 3 cable discover mode VDO
> > needs to be configured in the USB4 mode for the Thunderbolt rounded
> > support and active cable plug link training.
> >
> > Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> >
> > --
> > Changes in v2:
> > - No change.
> > --
> > ---
> >  drivers/usb/typec/mux/intel_pmc_mux.c | 18 +++++++++++++++---
> >  1 file changed, 15 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c
> > b/drivers/usb/typec/mux/intel_pmc_mux.c
> > index aa3211f1c4c3..61feb358aad3 100644
> > --- a/drivers/usb/typec/mux/intel_pmc_mux.c
> > +++ b/drivers/usb/typec/mux/intel_pmc_mux.c
> > @@ -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,20 @@ 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);
> 
> No need for the newline:

Ack

> 
> 			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;
> >  	}
> 
> thanks,
> 
> --
> Heikki

Sincerely,
Utkarsh Patel.

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

* RE: [PATCH v2 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message
  2020-11-17 12:09   ` Heikki Krogerus
@ 2020-11-17 23:28     ` Patel, Utkarsh H
  0 siblings, 0 replies; 28+ messages in thread
From: Patel, Utkarsh H @ 2020-11-17 23:28 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: linux-kernel, linux-usb, pmalani, enric.balletbo, Mani, Rajmohan,
	Shaikh, Azhar

Hi Heikki,

> -----Original Message-----
> From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Sent: Tuesday, November 17, 2020 4:10 AM
> To: Patel, Utkarsh H <utkarsh.h.patel@intel.com>
> Cc: linux-kernel@vger.kernel.org; linux-usb@vger.kernel.org;
> pmalani@chromium.org; enric.balletbo@collabora.com; Mani, Rajmohan
> <rajmohan.mani@intel.com>; Shaikh, Azhar <azhar.shaikh@intel.com>
> Subject: Re: [PATCH v2 5/8] usb: typec: Use Thunderbolt 3 cable discover
> mode VDO in Enter_USB message
> 
> On Fri, Nov 13, 2020 at 12:25:00PM -0800, Utkarsh Patel wrote:
> > USB4 also uses same cable properties as Thunderbolt 3 so use
> > Thunderbolt 3 cable discover mode VDO to fill details such as active
> > cable plug link training and cable rounded support.
> 
> I'm sorry, but I think that has to be explained better. We only need the
> Thunderbolt 3 properties when we create the USB4 connection with
> Thunderbolt 3 cables. With USB4 cables that information is simply not
> available. Claiming that USB4 uses the same properties in general is not true.

Ack. I will change the commit message.  

> 
> > Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> > --
> > Changes in v2:
> > - No change.
> > --
> > ---
> >  include/linux/usb/typec.h | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> > index 6be558045942..d91e09d9d91c 100644
> > --- a/include/linux/usb/typec.h
> > +++ b/include/linux/usb/typec.h
> > @@ -75,6 +75,7 @@ enum typec_orientation {
> >  /*
> >   * struct enter_usb_data - Enter_USB Message details
> >   * @eudo: Enter_USB Data Object
> > + * @tbt_cable_vdo: TBT3 Cable Discover Mode Response
> >   * @active_link_training: Active Cable Plug Link Training
> >   *
> >   * @active_link_training is a flag that should be set with
> > uni-directional SBRX
> 
> Please also explain the same here with a short comment. So basically, if the
> USB4 connection is created using TBT3 cable, then we need to supply also the
> TBT3 Cable VDO as part of this data. But if USB4 cable is used, then that
> member should not be filled at all.

Ack. 

> 
> > @@ -83,6 +84,7 @@ enum typec_orientation {
> >   */
> >  struct enter_usb_data {
> >  	u32			eudo;
> > +	u32			tbt_cable_vdo;
> >  	unsigned char		active_link_training:1;
> >  };
> 
> thanks,
> 
> --
> Heikki

Sincerely,
Utkarsh Patel. 

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

* Re: [PATCH v2 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message
  2020-11-17 21:16   ` Prashant Malani
@ 2020-11-18  0:44     ` Prashant Malani
  0 siblings, 0 replies; 28+ messages in thread
From: Prashant Malani @ 2020-11-18  0:44 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: Linux Kernel Mailing List, open list:USB NETWORKING DRIVERS,
	Heikki Krogerus, Enric Balletbo i Serra, Rajmohan Mani,
	Azhar Shaikh

On Tue, Nov 17, 2020 at 1:16 PM Prashant Malani <pmalani@chromium.org> wrote:
>
> Hi Utkarsh,
>
> On Fri, Nov 13, 2020 at 12:25:00PM -0800, Utkarsh Patel wrote:
> > USB4 also uses same cable properties as Thunderbolt 3 so use Thunderbolt 3
> > cable discover mode VDO to fill details such as active cable plug link
> > training and cable rounded support.

On digging into the Cros EC code further, sounds like active cable
link training and cable rounded are necessarily only part of
cables that have a TBT cable VDO, so sounds like the approach in the
patch is fine.

Sorry for the noise.

Best regards,

-Prashant

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

* Re: [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode
  2020-11-17 18:19   ` Prashant Malani
@ 2020-11-18  1:06     ` Prashant Malani
  2020-11-18  4:07       ` Patel, Utkarsh H
  0 siblings, 1 reply; 28+ messages in thread
From: Prashant Malani @ 2020-11-18  1:06 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: Linux Kernel Mailing List, open list:USB NETWORKING DRIVERS,
	Heikki Krogerus, Enric Balletbo i Serra, Rajmohan Mani,
	Azhar Shaikh



On Tue, Nov 17, 2020 at 10:19 AM Prashant Malani <pmalani@chromium.org> wrote:
>
> Hi Utkarsh,
>
> On Fri, Nov 13, 2020 at 12:25:01PM -0800, Utkarsh Patel wrote:
> > Configure Thunderbolt3/USB4 cable generation value by filing Thunderbolt 3
> > cable discover mode VDO to support rounded and non-rounded Thunderbolt3/
> > USB4 cables.
> > While we are here use Thunderbolt 3 cable discover mode VDO to fill active
> > cable plug link training value.
> >
> > Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> >
> > --
> > Changes in v2:
> > - No change.
> > --
> > ---
> >  drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
> >  1 file changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> > index 8111ed1fc574..b7416e82c3b3 100644
> > --- a/drivers/platform/chrome/cros_ec_typec.c
> > +++ b/drivers/platform/chrome/cros_ec_typec.c
> > @@ -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);
> > +     /*
> > +      * This driver does not have access to the identity information or
> > +      * capabilities of the cable, so we don't know is it a real USB4 or
> > +      * TBT3 cable. Therefore pretending that it's always TBT3 cable by
> > +      * filling the TBT3 Cable VDO.
> > +      */
> > +     data.tbt_cable_vdo = TBT_MODE;
>
> Is it safe to be making this assumption unconditionally? It might work for
> Intel Mux agent but is it guaranteed to be safe for any other future
> mux implementation? In other words, what if a "true" USB4 cable is
> connected which doesn't have the Thunderbolt SVID alt mode?

I dug into this a bit more and can maybe articulate my concern better:

Is there a situation where both of the following are true ? :
- Cable type = EUDO_CABLE_TYPE_OPTICAL or EUDO_CABLE_TYPE_RE_TIMER
- No TBT_CABLE_LINK_TRAINING or TBT_CABLE_ROUNDED_SUPPORT defined (both
  these are 0).

If both the above are true, then in Patch 7/8, wouldn't we never hit the
else condition (labeled "Active USB cable") and therefore not set the
mode_data correctly?

>
> (Pre-fetching some alternatives in case the answer is no)
>
> You might want to check with the Cros EC team if you can repurpose a bit of
> the "reserved" field for specifying whether the cable is TBT or not.
>
> Either that or see if there is a way to determine from the pd_ctrl->cable_speed
> whether the cable is actually TBT or not.

It seems link cable_gen and USB_PD_CTRL_ACTIVE_LINK_UNIDIR are
reasonable proxies for whether the cable has TBT support, so perhaps
we should only set tbt_cable_vdo = TBT_MODE if either of those are
non-zero?

WDYT?

Best regards,

-Prashant

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

* RE: [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode
  2020-11-18  1:06     ` Prashant Malani
@ 2020-11-18  4:07       ` Patel, Utkarsh H
  0 siblings, 0 replies; 28+ messages in thread
From: Patel, Utkarsh H @ 2020-11-18  4:07 UTC (permalink / raw)
  To: Prashant Malani
  Cc: Linux Kernel Mailing List, open list:USB NETWORKING DRIVERS,
	Heikki Krogerus, Enric Balletbo i Serra, Mani, Rajmohan, Shaikh,
	Azhar

Hi Prashant,

Thank you for the review and feedback. 

> On Tue, Nov 17, 2020 at 10:19 AM Prashant Malani <pmalani@chromium.org>
> wrote:
> >
> > Hi Utkarsh,
> >
> > On Fri, Nov 13, 2020 at 12:25:01PM -0800, Utkarsh Patel wrote:
> > > Configure Thunderbolt3/USB4 cable generation value by filing
> > > Thunderbolt 3 cable discover mode VDO to support rounded and
> > > non-rounded Thunderbolt3/
> > > USB4 cables.
> > > While we are here use Thunderbolt 3 cable discover mode VDO to fill
> > > active cable plug link training value.
> > >
> > > Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > > Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> > >
> > > --
> > > Changes in v2:
> > > - No change.
> > > --
> > > ---
> > >  drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++--
> > >  1 file changed, 12 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/platform/chrome/cros_ec_typec.c
> > > b/drivers/platform/chrome/cros_ec_typec.c
> > > index 8111ed1fc574..b7416e82c3b3 100644
> > > --- a/drivers/platform/chrome/cros_ec_typec.c
> > > +++ b/drivers/platform/chrome/cros_ec_typec.c
> > > @@ -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);
> > > +     /*
> > > +      * This driver does not have access to the identity information or
> > > +      * capabilities of the cable, so we don't know is it a real USB4 or
> > > +      * TBT3 cable. Therefore pretending that it's always TBT3 cable by
> > > +      * filling the TBT3 Cable VDO.
> > > +      */
> > > +     data.tbt_cable_vdo = TBT_MODE;
> >
> > Is it safe to be making this assumption unconditionally? It might work
> > for Intel Mux agent but is it guaranteed to be safe for any other
> > future mux implementation? In other words, what if a "true" USB4 cable
> > is connected which doesn't have the Thunderbolt SVID alt mode?
> 
> I dug into this a bit more and can maybe articulate my concern better:
> 
> Is there a situation where both of the following are true ? :
> - Cable type = EUDO_CABLE_TYPE_OPTICAL or EUDO_CABLE_TYPE_RE_TIMER
> - No TBT_CABLE_LINK_TRAINING or TBT_CABLE_ROUNDED_SUPPORT defined
> (both
>   these are 0).

No, not in the case of USB4. 

> 
> If both the above are true, then in Patch 7/8, wouldn't we never hit the else
> condition (labeled "Active USB cable") and therefore not set the mode_data
> correctly?
> 
> >
> > (Pre-fetching some alternatives in case the answer is no)
> >
> > You might want to check with the Cros EC team if you can repurpose a
> > bit of the "reserved" field for specifying whether the cable is TBT or not.
> >
> > Either that or see if there is a way to determine from the
> > pd_ctrl->cable_speed whether the cable is actually TBT or not.
> 
> It seems link cable_gen and USB_PD_CTRL_ACTIVE_LINK_UNIDIR are
> reasonable proxies for whether the cable has TBT support, so perhaps we
> should only set tbt_cable_vdo = TBT_MODE if either of those are non-zero?
> 
> WDYT?

Since we do not have these information available with USB4 cables, we can use them to check for TBT support and then set tbt_cable_vdo. 

> 
> Best regards,
> 
> -Prashant

Sincerely,
Utkarsh Patel. 

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

* Re: [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support
  2020-11-13 20:24 [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
                   ` (7 preceding siblings ...)
  2020-11-13 20:25 ` [PATCH v2 8/8] usb: typec: Remove active_link_training variable from Enter_USB message Utkarsh Patel
@ 2020-11-18 11:54 ` Greg KH
  2020-11-18 22:02   ` Patel, Utkarsh H
  8 siblings, 1 reply; 28+ messages in thread
From: Greg KH @ 2020-11-18 11:54 UTC (permalink / raw)
  To: Utkarsh Patel
  Cc: linux-kernel, linux-usb, heikki.krogerus, pmalani,
	enric.balletbo, rajmohan.mani, azhar.shaikh

On Fri, Nov 13, 2020 at 12:24:55PM -0800, Utkarsh Patel wrote:
> 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 v2:
> - Removed the fixes tag as there is no functional implication from patches
>   1/8, 2/8 and 4/8.

I've queued up the first 4 patches of this series.  Feel free to redo
the rest and resend.

thanks,

greg k-h

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

* RE: [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support
  2020-11-18 11:54 ` [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Greg KH
@ 2020-11-18 22:02   ` Patel, Utkarsh H
  0 siblings, 0 replies; 28+ messages in thread
From: Patel, Utkarsh H @ 2020-11-18 22:02 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel, linux-usb, heikki.krogerus, pmalani,
	enric.balletbo, Mani, Rajmohan, Shaikh, Azhar

Hi Greg,

> -----Original Message-----
> From: Greg KH <gregkh@linuxfoundation.org>
> Sent: Wednesday, November 18, 2020 3:55 AM
> To: Patel, Utkarsh H <utkarsh.h.patel@intel.com>
> Cc: linux-kernel@vger.kernel.org; linux-usb@vger.kernel.org;
> heikki.krogerus@linux.intel.com; pmalani@chromium.org;
> enric.balletbo@collabora.com; Mani, Rajmohan <rajmohan.mani@intel.com>;
> Shaikh, Azhar <azhar.shaikh@intel.com>
> Subject: Re: [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active
> cable plug link training support
> 
> On Fri, Nov 13, 2020 at 12:24:55PM -0800, Utkarsh Patel wrote:
> > 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 v2:
> > - Removed the fixes tag as there is no functional implication from patches
> >   1/8, 2/8 and 4/8.
> 
> I've queued up the first 4 patches of this series.  Feel free to redo the rest and
> resend.

Thank you. I will send v3 with the rest of the patches. 

> 
> thanks,
> 
> greg k-h

Sincerely,
Utkarsh Patel.

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

end of thread, other threads:[~2020-11-18 22:02 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 20:24 [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Utkarsh Patel
2020-11-13 20:24 ` [PATCH v2 1/8] usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support Utkarsh Patel
2020-11-17 10:43   ` Heikki Krogerus
2020-11-13 20:24 ` [PATCH v2 2/8] platform/chrome: cros_ec_typec: Correct " Utkarsh Patel
2020-11-17 10:44   ` Heikki Krogerus
2020-11-17 10:49   ` Enric Balletbo i Serra
2020-11-13 20:24 ` [PATCH v2 3/8] usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits Utkarsh Patel
2020-11-17 10:45   ` Heikki Krogerus
2020-11-13 20:24 ` [PATCH v2 4/8] usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable Utkarsh Patel
2020-11-17 10:46   ` Heikki Krogerus
2020-11-13 20:25 ` [PATCH v2 5/8] usb: typec: Use Thunderbolt 3 cable discover mode VDO in Enter_USB message Utkarsh Patel
2020-11-17 12:09   ` Heikki Krogerus
2020-11-17 23:28     ` Patel, Utkarsh H
2020-11-17 21:16   ` Prashant Malani
2020-11-18  0:44     ` Prashant Malani
2020-11-13 20:25 ` [PATCH v2 6/8] platform/chrome: cros_ec_typec: Use Thunderbolt 3 cable discover mode VDO in USB4 mode Utkarsh Patel
2020-11-17 10:49   ` Enric Balletbo i Serra
2020-11-17 12:10   ` Heikki Krogerus
2020-11-17 18:19   ` Prashant Malani
2020-11-18  1:06     ` Prashant Malani
2020-11-18  4:07       ` Patel, Utkarsh H
2020-11-13 20:25 ` [PATCH v2 7/8] usb: typec: intel_pmc_mux: Configure active cable properties for USB4 Utkarsh Patel
2020-11-17 12:21   ` Heikki Krogerus
2020-11-17 22:37     ` Patel, Utkarsh H
2020-11-13 20:25 ` [PATCH v2 8/8] usb: typec: Remove active_link_training variable from Enter_USB message Utkarsh Patel
2020-11-17 12:22   ` Heikki Krogerus
2020-11-18 11:54 ` [PATCH v2 0/8] Thunderbolt3/USB4 cable rounded and active cable plug link training support Greg KH
2020-11-18 22:02   ` Patel, Utkarsh H

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).