netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ioana Ciornei <ioana.ciornei@nxp.com>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Laurentiu Tudor <laurentiu.tudor@nxp.com>,
	"andrew@lunn.ch" <andrew@lunn.ch>,
	"f.fainelli@gmail.com" <f.fainelli@gmail.com>
Subject: RE: [PATCH net-next v4 4/5] dpaa2-eth: add MAC/PHY support through phylink
Date: Tue, 19 Nov 2019 16:22:46 +0000	[thread overview]
Message-ID: <VI1PR0402MB2800DAE9E3951704B7F643FAE04C0@VI1PR0402MB2800.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20191117161351.GH1344@shell.armlinux.org.uk>

> Subject: Re: [PATCH net-next v4 4/5] dpaa2-eth: add MAC/PHY support
> through phylink
> 
> On Thu, Oct 31, 2019 at 01:18:31AM +0200, Ioana Ciornei wrote:
> > The dpaa2-eth driver now has support for connecting to its associated
> > PHY device found through standard OF bindings.
> >
> > This happens when the DPNI object (that the driver probes on) gets
> > connected to a DPMAC. When that happens, the device tree is looked up
> > by the DPMAC ID, and the associated PHY bindings are found.
> >
> > The old logic of handling the net device's link state by hand still
> > needs to be kept, as the DPNI can be connected to other devices on the
> > bus than a DPMAC: other DPNI, DPSW ports, etc. This logic is only
> > engaged when there is no DPMAC (and therefore no phylink instance)
> > attached.
> >
> > The MC firmware support multiple type of DPMAC links: TYPE_FIXED,
> > TYPE_PHY. The TYPE_FIXED mode does not require any DPMAC
> management
> > from Linux side, and as such, the driver will not handle such a DPMAC.
> >
> > Although PHYLINK typically handles SFP cages and in-band AN modes, for
> > the moment the driver only supports the RGMII interfaces found on the
> > LX2160A. Support for other modes will come later.
> >
> > Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> > Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> 
> ...
> 
> > @@ -3363,6 +3425,13 @@ static irqreturn_t dpni_irq0_handler_thread(int
> irq_num, void *arg)
> >  	if (status & DPNI_IRQ_EVENT_ENDPOINT_CHANGED) {
> >  		set_mac_addr(netdev_priv(net_dev));
> >  		update_tx_fqids(priv);
> > +
> > +		rtnl_lock();
> > +		if (priv->mac)
> > +			dpaa2_eth_disconnect_mac(priv);
> > +		else
> > +			dpaa2_eth_connect_mac(priv);
> > +		rtnl_unlock();
> 
> Sorry, but this locking is deadlock prone.
> 
> You're taking rtnl_lock().
> dpaa2_eth_connect_mac() calls dpaa2_mac_connect().
> dpaa2_mac_connect() calls phylink_create().
> phylink_create() calls phylink_register_sfp().
> phylink_register_sfp() calls sfp_bus_add_upstream().
> sfp_bus_add_upstream() calls rtnl_lock() *** DEADLOCK ***.

I recently discovered this also when working on adding support for SFPs.

> 
> Neither phylink_create() nor phylink_destroy() may be called holding the rtnl
> lock.
> 

Just to summarise:

* phylink_create() and phylink_destroy() should NOT be called with the rtnl lock held
* phylink_disconnect_phy() should be called with the lock
* depending on when the netdev is registered the phylink_of_phy_connect()
may be called with or without the rtnl lock

I'll have to move the lock and unlock around the actual _connect() and _disconnect_phy()
calls so that even the case where the DPMAC is connected at runtime
(the EVENT_ENDPOINT_CHANGED referred above) is treated correctly.

Thanks,
Ioana




  reply	other threads:[~2019-11-19 16:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30 23:18 [PATCH net-next v4 0/5] dpaa2-eth: add MAC/PHY support through phylink Ioana Ciornei
2019-10-30 23:18 ` [PATCH net-next v4 1/5] bus: fsl-mc: export device types present on the bus Ioana Ciornei
2019-10-30 23:18 ` [PATCH net-next v4 2/5] bus: fsl-mc: add the fsl_mc_get_endpoint function Ioana Ciornei
2019-11-17 19:42   ` Russell King - ARM Linux admin
2019-10-30 23:18 ` [PATCH net-next v4 3/5] dpaa2-eth: update the TX frame queues on DPNI_IRQ_EVENT_ENDPOINT_CHANGED Ioana Ciornei
2019-10-30 23:18 ` [PATCH net-next v4 4/5] dpaa2-eth: add MAC/PHY support through phylink Ioana Ciornei
2019-11-17 16:13   ` Russell King - ARM Linux admin
2019-11-19 16:22     ` Ioana Ciornei [this message]
2019-11-19 17:14       ` Russell King - ARM Linux admin
2019-11-19 17:49         ` Ioana Ciornei
2019-11-17 17:01   ` Russell King - ARM Linux admin
2019-10-30 23:18 ` [PATCH net-next v4 5/5] net: documentation: add docs for MAC/PHY support in DPAA2 Ioana Ciornei
2019-10-31 21:26 ` [PATCH net-next v4 0/5] dpaa2-eth: add MAC/PHY support through phylink David Miller
2019-11-17 16:04 ` Russell King - ARM Linux admin
2019-12-19 10:14   ` Russell King - ARM Linux admin
2019-12-19 14:19     ` Ioana Ciornei
2019-11-17 16:49 ` Russell King - ARM Linux admin
2019-11-22  0:06   ` Russell King - ARM Linux admin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR0402MB2800DAE9E3951704B7F643FAE04C0@VI1PR0402MB2800.eurprd04.prod.outlook.com \
    --to=ioana.ciornei@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=laurentiu.tudor@nxp.com \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).