2021-02-05 19:57:08

by Mani, Rajmohan

[permalink] [raw]
Subject: [PATCH 0/2] Add support for Type-C mux events without port partners

There are cases, where support for Type-C mux events is needed, that
does not have port partners.
Enabling communication to a retimer connected to an USB4 port, when
no devices are attached, is a case that requires support for handling
Type-C mux events without port partners.

The following patches[1] are needed on top of the mainline kernel to be
able to verify these patches.

commit 8553a979fcd0 ("platform/chrome: cros_ec_typec: Send mux
configuration acknowledgment to EC")
commit ba8ce515454e ("platform/chrome: cros_ec_typec: Parameterize
cros_typec_cmds_supported()")
commit 156309096542 ("platform/chrome: cros_ec_typec: Register plug
altmodes")
commit f4edab68e101 ("platform/chrome: cros_ec_typec: Register SOP'
cable plug")
commit 599229763911 ("platform/chrome: cros_ec_typec: Set partner
num_altmodes")
commit 72d6e32bd85b ("platform/chrome: cros_ec_typec: Store cable plug
type")
commit 8b46a212ad11 ("platform/chrome: cros_ec_typec: Register cable")
commit c097f229b71e ("platform/chrome: cros_ec_typec: Rename discovery
struct")
commit 8fab2755191f ("platform/chrome: cros_ec_typec: Factor out PD
identity parsing")
commit a906f45d1480 ("platform/chrome: cros_ec_typec: Make disc_done
flag partner-only")

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/
linux.git/log/?h=cros-ec-typec-for-5.12

Rajmohan Mani (2):
platform/chrome: cros_ec_typec: Skip port partner check in
configure_mux()
platform/chrome: cros_ec_types: Support disconnect events without
partners

drivers/platform/chrome/cros_ec_typec.c | 27 ++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)

--
2.30.0


2021-02-05 19:59:56

by Mani, Rajmohan

[permalink] [raw]
Subject: [PATCH 2/2] platform/chrome: cros_ec_types: Support disconnect events without partners

There are certain scenarios, where a disconnect event might
occur on a Type-C port with no port partners. This is required
to enable communication to Burnside Bridge USB4 retimers.

Signed-off-by: Rajmohan Mani <[email protected]>
---
drivers/platform/chrome/cros_ec_typec.c | 26 ++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 3d8ff3f8a514..d89fe51b74b1 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -203,20 +203,26 @@ static void cros_typec_unregister_altmodes(struct cros_typec_data *typec, int po
}
}

-static void cros_typec_remove_partner(struct cros_typec_data *typec,
- int port_num)
+static int cros_typec_usb_disconnect_state(struct cros_typec_port *port)
{
- struct cros_typec_port *port = typec->ports[port_num];
-
- cros_typec_unregister_altmodes(typec, port_num, true);
-
port->state.alt = NULL;
port->state.mode = TYPEC_STATE_USB;
port->state.data = NULL;

usb_role_switch_set_role(port->role_sw, USB_ROLE_NONE);
typec_switch_set(port->ori_sw, TYPEC_ORIENTATION_NONE);
- typec_mux_set(port->mux, &port->state);
+
+ return typec_mux_set(port->mux, &port->state);
+}
+
+static void cros_typec_remove_partner(struct cros_typec_data *typec,
+ int port_num)
+{
+ struct cros_typec_port *port = typec->ports[port_num];
+
+ cros_typec_unregister_altmodes(typec, port_num, true);
+
+ cros_typec_usb_disconnect_state(port);

typec_unregister_partner(port->partner);
port->partner = NULL;
@@ -536,6 +542,11 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
enum typec_orientation orientation;
int ret;

+ if (mux_flags == USB_PD_MUX_NONE) {
+ ret = cros_typec_usb_disconnect_state(port);
+ goto mux_ack;
+ }
+
if (mux_flags & USB_PD_MUX_POLARITY_INVERTED)
orientation = TYPEC_ORIENTATION_REVERSE;
else
@@ -569,6 +580,7 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
mux_flags);
}

+mux_ack:
if (!typec->needs_mux_ack)
return ret;

--
2.30.0

2021-02-05 20:00:33

by Mani, Rajmohan

[permalink] [raw]
Subject: [PATCH 1/2] platform/chrome: cros_ec_typec: Skip port partner check in configure_mux()

For certain needs like updating the USB4 retimer firmware when no
device are connected, the Type-C ports require mux configuration,
to be able to communicate with the retimer. So removed the above
check to allow for mux configuration of Type-C ports, to enable
retimer communication.

Signed-off-by: Rajmohan Mani <[email protected]>
---
drivers/platform/chrome/cros_ec_typec.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index e724a5eaef1c..3d8ff3f8a514 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -536,9 +536,6 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
enum typec_orientation orientation;
int ret;

- if (!port->partner)
- return 0;
-
if (mux_flags & USB_PD_MUX_POLARITY_INVERTED)
orientation = TYPEC_ORIENTATION_REVERSE;
else
--
2.30.0

2021-02-05 20:09:09

by Prashant Malani

[permalink] [raw]
Subject: Re: [PATCH 2/2] platform/chrome: cros_ec_types: Support disconnect events without partners

Hi Raj,

On Fri, Feb 5, 2021 at 11:52 AM Rajmohan Mani <[email protected]> wrote:
>
> There are certain scenarios, where a disconnect event might
> occur on a Type-C port with no port partners. This is required
> to enable communication to Burnside Bridge USB4 retimers.
>
> Signed-off-by: Rajmohan Mani <[email protected]>
minor commit message nit (apologies for not spotting this earlier):

This patch alone doesn't add support for the "without partners" part
(that comes in the next patch).
This one purely adds support for disconnect events. So might be good
to update the commit message if possible.
But otherwise LGTM, so:

Reviewed-by: Prashant Malani <[email protected]>

2021-02-05 20:09:53

by Prashant Malani

[permalink] [raw]
Subject: Re: [PATCH 1/2] platform/chrome: cros_ec_typec: Skip port partner check in configure_mux()

Hi Raj,

On Fri, Feb 5, 2021 at 11:52 AM Rajmohan Mani <[email protected]> wrote:
>
> For certain needs like updating the USB4 retimer firmware when no
> device are connected, the Type-C ports require mux configuration,
> to be able to communicate with the retimer. So removed the above
> check to allow for mux configuration of Type-C ports, to enable
> retimer communication.
>
> Signed-off-by: Rajmohan Mani <[email protected]>
Reviewed-by: Prashant Malani <[email protected]>

> ---
> drivers/platform/chrome/cros_ec_typec.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index e724a5eaef1c..3d8ff3f8a514 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -536,9 +536,6 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
> enum typec_orientation orientation;
> int ret;
>
> - if (!port->partner)
> - return 0;
> -
> if (mux_flags & USB_PD_MUX_POLARITY_INVERTED)
> orientation = TYPEC_ORIENTATION_REVERSE;
> else
> --
> 2.30.0
>

2021-02-05 20:11:30

by Prashant Malani

[permalink] [raw]
Subject: Re: [PATCH 2/2] platform/chrome: cros_ec_types: Support disconnect events without partners

On Fri, Feb 5, 2021 at 12:05 PM Prashant Malani <[email protected]> wrote:
>
> Hi Raj,
>
> On Fri, Feb 5, 2021 at 11:52 AM Rajmohan Mani <[email protected]> wrote:
> >
> > There are certain scenarios, where a disconnect event might
> > occur on a Type-C port with no port partners. This is required
> > to enable communication to Burnside Bridge USB4 retimers.
> >
> > Signed-off-by: Rajmohan Mani <[email protected]>
> minor commit message nit (apologies for not spotting this earlier):
>
> This patch alone doesn't add support for the "without partners" part
> (that comes in the next patch).
> This one purely adds support for disconnect events. So might be good
> to update the commit message if possible.
Sorry, I just noticed that I interpreted the ordering of the patches
incorrectly, so this commit message is fine as is and I retract my
nit.

> But otherwise LGTM, so:
>
> Reviewed-by: Prashant Malani <[email protected]>

2021-02-06 02:50:09

by Mani, Rajmohan

[permalink] [raw]
Subject: RE: [PATCH 0/2] Add support for Type-C mux events without port partners

Hi Benson,

> Subject: Re: [PATCH 0/2] Add support for Type-C mux events without port
> partners
>
> Hi Rajmohan,
>
> On Fri, 5 Feb 2021 11:51:11 -0800, Rajmohan Mani wrote:
> > There are cases, where support for Type-C mux events is needed, that
> > does not have port partners.
> > Enabling communication to a retimer connected to an USB4 port, when no
> > devices are attached, is a case that requires support for handling
> > Type-C mux events without port partners.
> >
> > The following patches[1] are needed on top of the mainline kernel to
> > be able to verify these patches.
> >
> > [...]
>
> Applied, thanks!
>

Thanks for the quick review / follow up.

...

2021-02-06 03:25:22

by Benson Leung

[permalink] [raw]
Subject: Re: [PATCH 0/2] Add support for Type-C mux events without port partners

Hi Rajmohan,

On Fri, 5 Feb 2021 11:51:11 -0800, Rajmohan Mani wrote:
> There are cases, where support for Type-C mux events is needed, that
> does not have port partners.
> Enabling communication to a retimer connected to an USB4 port, when
> no devices are attached, is a case that requires support for handling
> Type-C mux events without port partners.
>
> The following patches[1] are needed on top of the mainline kernel to be
> able to verify these patches.
>
> [...]

Applied, thanks!

[1/2] platform/chrome: cros_ec_typec: Skip port partner check in configure_mux()
commit: 38f56061c892c237ad4ee733cf3981a84f6b6aea
[2/2] platform/chrome: cros_ec_types: Support disconnect events without partners
commit: b4b06c97729547d03a8f49c6774c8bd69150ea4d

Best regards,
--
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]


Attachments:
(No filename) (941.00 B)
signature.asc (235.00 B)
Download all attachments

2021-02-06 04:10:09

by Mani, Rajmohan

[permalink] [raw]
Subject: RE: [PATCH 1/2] platform/chrome: cros_ec_typec: Skip port partner check in configure_mux()

Hi Prashant,

> -----Original Message-----
> From: Prashant Malani <[email protected]>
> Sent: Friday, February 05, 2021 12:07 PM
> To: Mani, Rajmohan <[email protected]>
> Cc: Benson Leung <[email protected]>; Enric Balletbo i Serra
> <[email protected]>; Guenter Roeck <[email protected]>;
> Linux Kernel Mailing List <[email protected]>; Heikki Krogerus
> <[email protected]>
> Subject: Re: [PATCH 1/2] platform/chrome: cros_ec_typec: Skip port partner
> check in configure_mux()
>
> Hi Raj,
>
> On Fri, Feb 5, 2021 at 11:52 AM Rajmohan Mani
> <[email protected]> wrote:
> >
> > For certain needs like updating the USB4 retimer firmware when no
> > device are connected, the Type-C ports require mux configuration, to
> > be able to communicate with the retimer. So removed the above check to
> > allow for mux configuration of Type-C ports, to enable retimer
> > communication.
> >
> > Signed-off-by: Rajmohan Mani <[email protected]>
> Reviewed-by: Prashant Malani <[email protected]>
>

Thanks for the review of the patch series.

> > ---
> > drivers/platform/chrome/cros_ec_typec.c | 3 ---
> > 1 file changed, 3 deletions(-)
> >
> > diff --git a/drivers/platform/chrome/cros_ec_typec.c
> > b/drivers/platform/chrome/cros_ec_typec.c
> > index e724a5eaef1c..3d8ff3f8a514 100644
> > --- a/drivers/platform/chrome/cros_ec_typec.c
> > +++ b/drivers/platform/chrome/cros_ec_typec.c
> > @@ -536,9 +536,6 @@ static int cros_typec_configure_mux(struct
> cros_typec_data *typec, int port_num,
> > enum typec_orientation orientation;
> > int ret;
> >
> > - if (!port->partner)
> > - return 0;
> > -
> > if (mux_flags & USB_PD_MUX_POLARITY_INVERTED)
> > orientation = TYPEC_ORIENTATION_REVERSE;
> > else
> > --
> > 2.30.0
> >