Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1419646imm; Thu, 5 Jul 2018 23:04:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc75dqqUBxgOy66+v8MgNjZxJJ/27dS2pTcv7e/oBmcGyJtaOAhoVCUjKjB+uLD6+OU4EQX X-Received: by 2002:a17:902:be18:: with SMTP id r24-v6mr7935246pls.268.1530857080788; Thu, 05 Jul 2018 23:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530857080; cv=none; d=google.com; s=arc-20160816; b=FUgYPQu8zCWwjIGz+iuUtr/+xMVp9wPKZDffLBdNpPpsPPGHrgU3ODCutOjhapVVsu sp+KBfeT7xMgei1UgZu5aTu97t+3mEm6fKaCcx3U4Z6udz4gh1SZoaE2iojTT3VmlxPx 1PqzuTToL1JDHU5WzOzX4zcJvn0+G9Zv8lpGiZmXO9UiU9mONyKDP5SzhRIJ8ByrD069 /K0tQs7LB0XYrT7UuVEgdGDnvbzC2OdQ1g38m5W2PsDXfSKV5syfU2OsZ5S81hi12y9g 6gGbJ4zgkzID2XOGS2M9dqlOq605DmRUHfC4y+8Ci8eOpRlczHOenA0njw18kR/yQnh8 n8pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=DrvMGtiyQJ4to2Kwm5Au82sixPQh3cLXKFSV+hLXyps=; b=bCX09pOIVtoBLPh9F426Ct3KuPG43KXoSVXcTqLIILvrToDC9PDo6IAnlapuIpYTyg rsN+mauZ/77StkuDQQV46uFzMUbZgggse9Z95ivOWlZ2fn82qzogDLfyKuiEegsr22ih VD8F5Ojma9ggKyLwnOJPZYIZJjcx5Wl9lOm0JgRmWP2/ZD9KRozw8tx/Z4YphRVA1yzl 15cIdMYNsgNafXZ9rEfDvcytfuKQOi2jFwpLqLA6G2/VIn9hOhnH+cC9vv5D/9oIwjtu bvJEkaBnILMR9MMj+gO9NZ+Ri2Ed6/sEq1yyrmQ5TrZIIkS6Go0raNHg6KskvSskV0d2 KKbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1-v6si7494919pld.40.2018.07.05.23.04.26; Thu, 05 Jul 2018 23:04:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933798AbeGFFuI (ORCPT + 99 others); Fri, 6 Jul 2018 01:50:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60458 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933138AbeGFFuG (ORCPT ); Fri, 6 Jul 2018 01:50:06 -0400 Received: from localhost (D57D388D.static.ziggozakelijk.nl [213.125.56.141]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 29864BC1; Fri, 6 Jul 2018 05:50:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heikki Krogerus Subject: [PATCH 4.14 07/61] usb: typec: ucsi: Fix for incorrect status data issue Date: Fri, 6 Jul 2018 07:46:31 +0200 Message-Id: <20180706054712.612999696@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180706054712.332416244@linuxfoundation.org> References: <20180706054712.332416244@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Heikki Krogerus commit 68816e16b4789f2d05e77b6dcb77564cf5d6a8d8 upstream. 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 Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/ucsi/ucsi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -346,6 +346,19 @@ static void ucsi_connector_change(struct } 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