lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 13 Sep 2018 10:51:08 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc:     Badhri Jagan Sridharan <badhri@...gle.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] typec: tcpm: Do not disconnect link for self powered
 devices

On Thu, Sep 13, 2018 at 04:24:08PM +0300, Heikki Krogerus wrote:
> +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 <Badhri@...gle.com>
> > ---
> >  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);
> > 

Maybe I am missing something, but
		tcpm_set_roles(port, port->self_powered,
			       TYPEC_SINK, TYPEC_DEVICE);
should accomplish the same (assuming the flag is moved to tcpm_port).

Does the code at SRC_HARD_RESET_VBUS_OFF: also have to be changed,
or only SNK_HARD_RESET_SINK_OFF: ? In other words, does this only
apply if the port is a sink, or also if is is source ?

Guenter

> >  		/*
> >  		 * 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ