Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1426938imm; Thu, 5 Jul 2018 23:14:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfrdvT5/1Ip9dj7KlOFh+LvwbC+EZNdsTL3eiRM18CNshIHKJwDq8kB88NV+KRZKuO2bkw6 X-Received: by 2002:a17:902:d692:: with SMTP id v18-v6mr9140070ply.59.1530857667645; Thu, 05 Jul 2018 23:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530857667; cv=none; d=google.com; s=arc-20160816; b=aFvrpBSmH2rqJ/Lyw0f1xQ5G6tCJggW6q2e7hqapg0ZDnu945C3qNe7AC7Fe8jE/R1 FLvGj1OEv79UENko7fxa8s/zU/aJr6gwxeP+OhHC7QJwjs7KzNONpt6g/TMrEgE6qYzR YQKeqbmdaq5uVFf4gcugGxDFtO+DFNSlS2hXIGpVRjz9048shi7mbz9RXc9xYtytTVpV WNdZYoHS1tvzxhNlYhh3PDxK7BwloW2qM8/oPzZh2n7TYjxWboQ/7dsZLgZBaUkLWNuZ fiM7QHbjtJxZzZX1H0r9L5R+yUoMw4TnpFEyw3SfXUNHVgyaViqEm6D+Y+UuGrzI/JTk lYag== 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=zAWPXfdWJhX56fP+hxZSM1Ggslhx/CjaNlOtms00bh8=; b=C7tLFhW7Mv5tIlNnp+BND/SrBSWyH//aDA/5SEs0UAOKR3X0dH6vEfWTlH2pcTZoFZ +4yT6u7QUUeDWIoWrbvtfHRDhLJuTaIbpu9i3X96yVsIDnggo+VL7Jwcl2nwNhVVlmGo +aEttcJNhvxyCIjXogh/1Uck4X0RYsSKl0bOs4L2vLcjKNxU+GvZPj76cc7pfrUdLpkv UQL+UpF408ZRt+5ULLl7Wv3KCz+h/4cEFTPEI1f9gIr5doUbN7Q9JCwaUa3+jFb7AieL ClF7Wa7rfrOV2y3JHmgad2kHvXJsUNIXM1RUyaN31vd+0wZEJQxtooiBtTBi+eWWUMfP Emow== 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 b7-v6si6715307pgq.564.2018.07.05.23.14.12; Thu, 05 Jul 2018 23:14:27 -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 S1754125AbeGFGMR (ORCPT + 99 others); Fri, 6 Jul 2018 02:12:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58804 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932625AbeGFFrn (ORCPT ); Fri, 6 Jul 2018 01:47:43 -0400 Received: from localhost (D57D388D.static.ziggozakelijk.nl [213.125.56.141]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0CC39C7F; Fri, 6 Jul 2018 05:47:41 +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.17 08/46] usb: typec: ucsi: Fix for incorrect status data issue Date: Fri, 6 Jul 2018 07:46:29 +0200 Message-Id: <20180706054525.000194329@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180706054524.595521988@linuxfoundation.org> References: <20180706054524.595521988@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.17-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 @@ -350,6 +350,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