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]
Message-ID: <AM7PR04MB688500546D0FC4A64F0DA19DF8CE0@AM7PR04MB6885.eurprd04.prod.outlook.com>
Date:   Wed, 25 Mar 2020 03:08:46 +0000
From:   "Y.b. Lu" <yangbo.lu@....com>
To:     Richard Cochran <richardcochran@...il.com>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "David S . Miller" <davem@...emloft.net>,
        Vladimir Oltean <vladimir.oltean@....com>,
        Claudiu Manoil <claudiu.manoil@....com>,
        Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>
Subject: RE: [PATCH 6/6] ptp_ocelot: support 4 programmable pins

> -----Original Message-----
> From: Richard Cochran <richardcochran@...il.com>
> Sent: Tuesday, March 24, 2020 9:08 PM
> To: Y.b. Lu <yangbo.lu@....com>
> Cc: linux-kernel@...r.kernel.org; netdev@...r.kernel.org; David S . Miller
> <davem@...emloft.net>; Vladimir Oltean <vladimir.oltean@....com>;
> Claudiu Manoil <claudiu.manoil@....com>; Andrew Lunn <andrew@...n.ch>;
> Vivien Didelot <vivien.didelot@...il.com>; Florian Fainelli
> <f.fainelli@...il.com>; Alexandre Belloni <alexandre.belloni@...tlin.com>;
> Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>
> Subject: Re: [PATCH 6/6] ptp_ocelot: support 4 programmable pins
> 
> On Fri, Mar 20, 2020 at 06:37:26PM +0800, Yangbo Lu wrote:
> > +static int ocelot_ptp_enable(struct ptp_clock_info *ptp,
> > +			     struct ptp_clock_request *rq, int on)
> > +{
> > +	struct ocelot *ocelot = container_of(ptp, struct ocelot, ptp_info);
> > +	enum ocelot_ptp_pins ptp_pin;
> > +	struct timespec64 ts;
> > +	unsigned long flags;
> > +	int pin = -1;
> > +	u32 val;
> > +	s64 ns;
> > +
> > +	switch (rq->type) {
> > +	case PTP_CLK_REQ_PEROUT:
> > +		/* Reject requests with unsupported flags */
> > +		if (rq->perout.flags)
> > +			return -EOPNOTSUPP;
> > +
> > +		/*
> > +		 * TODO: support disabling function
> > +		 * When ptp_disable_pinfunc() is to disable function,
> > +		 * it has already held pincfg_mux.
> > +		 * However ptp_find_pin() in .enable() called also needs
> > +		 * to hold pincfg_mux.
> > +		 * This causes dead lock. So, just return for function
> > +		 * disabling, and this needs fix-up.
> 
> What dead lock?
> 
> When enable(PTP_CLK_REQ_PEROUT, on=0) is called, you don't need to
> call ptp_disable_pinfunc().  Just stop the periodic waveform
> generator.  The assignment of function to pin remains unchanged.

This happens when we try to change pin function through ptp_ioctl PTP_PIN_SETFUNC.
When software holds pincfg_mux and calls ptp_set_pinfunc, it will disable the function previous assigned and the current function of current pin calling ptp_disable_pinfunc.
The problem is the enable callback in ptp_disable_pinfunc may have to hold pincfg_mux for ptp_find_pin.

The calling should be like this,
ptp_set_pinfunc (hold pincfg_mux)
---> ptp_disable_pinfunc
   ---> .enable
      ---> ptp_find_pin (hold pincfg_mux)

Thanks.

> 
> > +		 */
> > +		if (!on)
> > +			break;
> > +
> > +		pin = ptp_find_pin(ocelot->ptp_clock, PTP_PF_PEROUT,
> > +				   rq->perout.index);
> > +		if (pin == 0)
> > +			ptp_pin = PTP_PIN_0;
> > +		else if (pin == 1)
> > +			ptp_pin = PTP_PIN_1;
> > +		else if (pin == 2)
> > +			ptp_pin = PTP_PIN_2;
> > +		else if (pin == 3)
> > +			ptp_pin = PTP_PIN_3;
> > +		else
> > +			return -EINVAL;
> 
> Return -EBUSY here instead.

Thanks. Will modify it in next version.

> 
> Thanks,
> Richard

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ