diff mbox

[3/3] usb: typec: ucsi: Fix for incorrect status data issue

Message ID 20180621134319.32133-4-heikki.krogerus@linux.intel.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Heikki Krogerus June 21, 2018, 1:43 p.m. UTC
According to UCSI Specification, Connector Change Event only
means a change in the Connector Status and Operation Mode
fields of the STATUS data structure. So any other change
should create another event.

Unfortunately on some platforms the firmware acting as PPM
(platform policy manager - usually embedded controller
firmware) still does not report any other status changes if
there is a connector change event. So if the connector power
or data role was changed when a device was plugged to the
connector, the driver does not get any indication about
that. The port will show wrong roles if that happens.

To fix the issue, always checking the data and power role
together with a connector change event.

Fixes: c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/typec/ucsi/ucsi.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Greg Kroah-Hartman June 25, 2018, 12:37 p.m. UTC | #1
On Thu, Jun 21, 2018 at 04:43:19PM +0300, Heikki Krogerus wrote:
> According to UCSI Specification, Connector Change Event only
> means a change in the Connector Status and Operation Mode
> fields of the STATUS data structure. So any other change
> should create another event.
> 
> Unfortunately on some platforms the firmware acting as PPM
> (platform policy manager - usually embedded controller
> firmware) still does not report any other status changes if
> there is a connector change event. So if the connector power
> or data role was changed when a device was plugged to the
> connector, the driver does not get any indication about
> that. The port will show wrong roles if that happens.
> 
> To fix the issue, always checking the data and power role
> together with a connector change event.
> 
> Fixes: c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---

No stable kernel marking for this? odd...

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Heikki Krogerus June 25, 2018, 2:48 p.m. UTC | #2
On Mon, Jun 25, 2018 at 08:37:25PM +0800, Greg Kroah-Hartman wrote:
> On Thu, Jun 21, 2018 at 04:43:19PM +0300, Heikki Krogerus wrote:
> > According to UCSI Specification, Connector Change Event only
> > means a change in the Connector Status and Operation Mode
> > fields of the STATUS data structure. So any other change
> > should create another event.
> > 
> > Unfortunately on some platforms the firmware acting as PPM
> > (platform policy manager - usually embedded controller
> > firmware) still does not report any other status changes if
> > there is a connector change event. So if the connector power
> > or data role was changed when a device was plugged to the
> > connector, the driver does not get any indication about
> > that. The port will show wrong roles if that happens.
> > 
> > To fix the issue, always checking the data and power role
> > together with a connector change event.
> > 
> > Fixes: c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
> > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > ---
> 
> No stable kernel marking for this? odd...

I forgot to put it there. Sorry.

I noticed you picked this patch already, but can I still resend it?


Thanks,
Greg Kroah-Hartman June 25, 2018, 2:54 p.m. UTC | #3
On Mon, Jun 25, 2018 at 05:48:05PM +0300, Heikki Krogerus wrote:
> On Mon, Jun 25, 2018 at 08:37:25PM +0800, Greg Kroah-Hartman wrote:
> > On Thu, Jun 21, 2018 at 04:43:19PM +0300, Heikki Krogerus wrote:
> > > According to UCSI Specification, Connector Change Event only
> > > means a change in the Connector Status and Operation Mode
> > > fields of the STATUS data structure. So any other change
> > > should create another event.
> > > 
> > > Unfortunately on some platforms the firmware acting as PPM
> > > (platform policy manager - usually embedded controller
> > > firmware) still does not report any other status changes if
> > > there is a connector change event. So if the connector power
> > > or data role was changed when a device was plugged to the
> > > connector, the driver does not get any indication about
> > > that. The port will show wrong roles if that happens.
> > > 
> > > To fix the issue, always checking the data and power role
> > > together with a connector change event.
> > > 
> > > Fixes: c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
> > > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > > ---
> > 
> > No stable kernel marking for this? odd...
> 
> I forgot to put it there. Sorry.
> 
> I noticed you picked this patch already, but can I still resend it?

I already added that tag :)

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Heikki Krogerus June 26, 2018, 8:09 a.m. UTC | #4
On Mon, Jun 25, 2018 at 10:54:27PM +0800, Greg Kroah-Hartman wrote:
> On Mon, Jun 25, 2018 at 05:48:05PM +0300, Heikki Krogerus wrote:
> > On Mon, Jun 25, 2018 at 08:37:25PM +0800, Greg Kroah-Hartman wrote:
> > > On Thu, Jun 21, 2018 at 04:43:19PM +0300, Heikki Krogerus wrote:
> > > > According to UCSI Specification, Connector Change Event only
> > > > means a change in the Connector Status and Operation Mode
> > > > fields of the STATUS data structure. So any other change
> > > > should create another event.
> > > > 
> > > > Unfortunately on some platforms the firmware acting as PPM
> > > > (platform policy manager - usually embedded controller
> > > > firmware) still does not report any other status changes if
> > > > there is a connector change event. So if the connector power
> > > > or data role was changed when a device was plugged to the
> > > > connector, the driver does not get any indication about
> > > > that. The port will show wrong roles if that happens.
> > > > 
> > > > To fix the issue, always checking the data and power role
> > > > together with a connector change event.
> > > > 
> > > > Fixes: c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
> > > > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > > > ---
> > > 
> > > No stable kernel marking for this? odd...
> > 
> > I forgot to put it there. Sorry.
> > 
> > I noticed you picked this patch already, but can I still resend it?
> 
> I already added that tag :)

OK :-). Thanks Greg!

Br,
diff mbox

Patch

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index bd5cca5632b3..8d0a6fe748bd 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -350,6 +350,19 @@  static void ucsi_connector_change(struct work_struct *work)
 	}
 
 	if (con->status.change & UCSI_CONSTAT_CONNECT_CHANGE) {
+		typec_set_pwr_role(con->port, con->status.pwr_dir);
+
+		switch (con->status.partner_type) {
+		case UCSI_CONSTAT_PARTNER_TYPE_UFP:
+			typec_set_data_role(con->port, TYPEC_HOST);
+			break;
+		case UCSI_CONSTAT_PARTNER_TYPE_DFP:
+			typec_set_data_role(con->port, TYPEC_DEVICE);
+			break;
+		default:
+			break;
+		}
+
 		if (con->status.connected)
 			ucsi_register_partner(con);
 		else