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:   Tue, 6 Feb 2018 16:53:57 +0200
From:   Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To:     Adam Thomson <Adam.Thomson.Opensource@...semi.com>
Cc:     Guenter Roeck <linux@...ck-us.net>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Sebastian Reichel <sre@...nel.org>,
        Hans de Goede <hdegoede@...hat.com>,
        Yueyao Zhu <yueyao.zhu@...il.com>,
        Rui Miguel Silva <rmfrfs@...il.com>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Support Opensource <Support.Opensource@...semi.com>
Subject: Re: [PATCH v4 4/7] typec: tcpm: Add core support for sink side PPS

On Tue, Feb 06, 2018 at 02:33:08PM +0000, Adam Thomson wrote:
> On 30 January 2018 12:47, Heikki Krogerus wrote:
> 
> > > +static int tcpm_pps_set_op_curr(struct tcpm_port *port, u16 op_curr)
> > > +{
> > > +	unsigned int target_mw;
> > > +	int ret = 0;
> > > +
> > > +	mutex_lock(&port->swap_lock);
> > > +	mutex_lock(&port->lock);
> > > +
> > > +	if (!port->pps_data.active) {
> > > +		ret = -EOPNOTSUPP;
> > > +		goto port_unlock;
> > > +	}
> > > +
> > > +	if (port->state != SNK_READY) {
> > > +		ret = -EAGAIN;
> > > +		goto port_unlock;
> > > +	}
> > > +
> > > +	if (op_curr > port->pps_data.max_curr) {
> > > +		ret = -EINVAL;
> > > +		goto port_unlock;
> > > +	}
> > > +
> > > +	target_mw = (op_curr * port->pps_data.out_volt) / 1000;
> > > +	if (target_mw < port->operating_snk_mw) {
> > > +		ret = -EINVAL;
> > > +		goto port_unlock;
> > > +	}
> > > +
> > > +	reinit_completion(&port->pps_complete);
> > > +	port->pps_data.op_curr = op_curr;
> > > +	port->pps_status = 0;
> > > +	port->pps_pending = true;
> > > +	tcpm_set_state(port, SNK_NEGOTIATE_PPS_CAPABILITIES, 0);
> >
> > Why not just take the swap_lock here..
> 
> I believe this would result in deadlock. All of the existing uses of swap_lock
> acquire it first before the port->lock is then acquired (and vice-versa for
> unlock). We don't want the power role to change during this procedure, so we
> hold the swap_lock for the whole process. Have a look at tcpm_dr_set() and
> tcpm_pr_set() as examples of existing usage.

OK. Then I'm fine with this patch as well. FWIW:

Acked-by: Heikki Krogerus <heikki.krogerus@...ux.intel.com>

-- 
heikki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ