Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp694751imm; Thu, 13 Sep 2018 06:26:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZYQTUqcN61E4GiAchiHQtS6m4ogIvkBIuBDWB7kqOBfrqznqlf5aO+ApTSWKD2pNVXJeXu X-Received: by 2002:a17:902:d90a:: with SMTP id c10-v6mr7344140plz.35.1536845213900; Thu, 13 Sep 2018 06:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536845213; cv=none; d=google.com; s=arc-20160816; b=VYBick7uRyukzbJhQ87XFLf+Q2Fu5N7h1uXxJPHjFwL/j+c1iaxoatfkbdO1xYFuZj Ew6zZmbzF95UnRP+vGu9QaD2kMtA1JGaGCPkpnyWNz0BQssdJDNVlcuMmPibsnkV9Kw3 dWiDlsafp3xtEdzyRtea6aa+z5UO1T3PHYdUNUc3OQHQsxqT95RNfjH3J4w+9tY8LNtm SNzkOUMrvz+omWprSdHFI0QdEXP8ykcvRViPr6gmOZTtBhmBdQMNPkzRnoFjXQ2vwkq1 6Xe3vaA9aXDk5d+Z8kQIiv2upcOehppsZW+Og6F0rnKRjoYgCqHIKjKEUldzo+DJRV8R b23g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=pANepyN26ogMKlMPX2oNp6wpWVoTegSRTrHGZhJV6II=; b=ncBNJ6JJk0xQQyC5KQaG2E43PIBtaLZmKm3UV/jA7TgL0uJbKRY7scsgKxkXCwNCOB QxCBpjnuh+oF5lHvj39NyyWuUV9LIGMLsbs86Swrmw+ROSPQH/GoTPdy7oNTD16lhYhI j7sJ3Xq+RkZQEBiJjRXQBL3BhlUmNf8WBBW/O9BelOwZZdH6DZeV/SDRG8r0/6tYI4u5 OhJ/9YXnuSTDPQ+EjcKCc3mTg6/2tOW+jGzXMyaEPX5jUxdbJwNKlYMau6d+sSU4bKup Be7noHkBAo7+cx93Yafx0Klztzs9a3MIFdoCmIp6RYxzRDTqygibHQoEFPEqYN2UaFv9 N20g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4-v6si4090026pll.384.2018.09.13.06.26.28; Thu, 13 Sep 2018 06:26:53 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727332AbeIMSd4 (ORCPT + 99 others); Thu, 13 Sep 2018 14:33:56 -0400 Received: from mga05.intel.com ([192.55.52.43]:43688 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbeIMSd4 (ORCPT ); Thu, 13 Sep 2018 14:33:56 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Sep 2018 06:24:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,369,1531810800"; d="scan'208";a="89700336" Received: from kuha.fi.intel.com ([10.237.72.189]) by fmsmga001.fm.intel.com with SMTP; 13 Sep 2018 06:24:09 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Thu, 13 Sep 2018 16:24:08 +0300 Date: Thu, 13 Sep 2018 16:24:08 +0300 From: Heikki Krogerus To: Badhri Jagan Sridharan , Guenter Roeck Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] typec: tcpm: Do not disconnect link for self powered devices Message-ID: <20180913132408.GC19329@kuha.fi.intel.com> References: <20180913021113.18150-1-badhri@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180913021113.18150-1-badhri@google.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Guenter On Wed, Sep 12, 2018 at 07:11:12PM -0700, Badhri Jagan Sridharan wrote: > During HARD_RESET the data link is disconnected. > For self powered device, the spec is advising against doing that. > > >From USB_PD_R3_0 > 7.1.5 Response to Hard Resets > Device operation during and after a Hard Reset is defined as follows: > Self-powered devices Should Not disconnect from USB during a Hard Reset > (see Section 9.1.2). > Bus powered devices will disconnect from USB during a Hard Reset due to the > loss of their power source. > > Tackle this by letting TCPM know whether the device is self or bus powered. > > This overcomes unnecessary port disconnections from hard reset. > Also, speeds up the enumeration time when connected to Type-A ports. > > Signed-off-by: Badhri Jagan Sridharan > --- > drivers/usb/typec/tcpm.c | 6 +++++- > include/linux/usb/tcpm.h | 1 + > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c > index 4f1f4215f3d6..a4e0c027a2a9 100644 > --- a/drivers/usb/typec/tcpm.c > +++ b/drivers/usb/typec/tcpm.c > @@ -3270,7 +3270,11 @@ static void run_state_machine(struct tcpm_port *port) > memset(&port->pps_data, 0, sizeof(port->pps_data)); > tcpm_set_vconn(port, false); > tcpm_set_charge(port, false); > - tcpm_set_roles(port, false, TYPEC_SINK, TYPEC_DEVICE); > + > + if (port->tcpc->config->self_powered) Add a member for that flag to the struct tcpm_port, and check that here instead. I'll explain why below. > + tcpm_set_roles(port, true, TYPEC_SINK, TYPEC_DEVICE); > + else > + tcpm_set_roles(port, false, TYPEC_SINK, TYPEC_DEVICE); > > /* > * VBUS may or may not toggle, depending on the adapter. > * If it doesn't toggle, transition to SNK_HARD_RESET_SINK_ON > diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h > index 7e7fbfb84e8e..50c74a77db55 100644 > --- a/include/linux/usb/tcpm.h > +++ b/include/linux/usb/tcpm.h > @@ -89,6 +89,7 @@ struct tcpc_config { > enum typec_port_data data; > enum typec_role default_role; > bool try_role_hw; /* try.{src,snk} implemented in hardware */ > + bool self_powered; /* port belongs to a self powered device */ I'm not sure we should add any more members to that structure, but maybe it's not a problem for now. We can't quite yet get rid of that structure. You do need to introduce a new device property already. Then read the value for that new member you added to struct tcpm_port in tcpm_fw_get_caps() and in tcpm_copy_caps(). Thanks, -- heikki