netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Ioana Ciornei <ioana.ciornei@nxp.com>,
	davem@davemloft.net, netdev@vger.kernel.org,
	laurentiu.tudor@nxp.com, f.fainelli@gmail.com
Subject: Re: [PATCH net-next 3/4] dpaa2-eth: add MAC/PHY support through phylink
Date: Tue, 22 Oct 2019 17:24:28 +0100	[thread overview]
Message-ID: <20191022162428.GX25745@shell.armlinux.org.uk> (raw)
In-Reply-To: <20191022010649.GI16084@lunn.ch>

On Tue, Oct 22, 2019 at 03:06:49AM +0200, Andrew Lunn wrote:
> Hi Ioana
> 
> > +static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
> > +{
> > +	struct fsl_mc_device *dpni_dev, *dpmac_dev;
> > +	struct dpaa2_mac *mac;
> > +	int err;
> > +
> > +	dpni_dev = to_fsl_mc_device(priv->net_dev->dev.parent);
> > +	dpmac_dev = fsl_mc_get_endpoint(dpni_dev);
> > +	if (!dpmac_dev || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type)
> > +		return 0;
> > +
> > +	if (dpaa2_mac_is_type_fixed(dpmac_dev, priv->mc_io))
> > +		return 0;
> > +
> > +	mac = kzalloc(sizeof(struct dpaa2_mac), GFP_KERNEL);
> > +	if (!mac)
> > +		return -ENOMEM;
> > +
> > +	mac->mc_dev = dpmac_dev;
> > +	mac->mc_io = priv->mc_io;
> > +	mac->net_dev = priv->net_dev;
> > +
> > +	err = dpaa2_mac_connect(mac);
> > +	if (err) {
> > +		netdev_err(priv->net_dev, "Error connecting to the MAC endpoint\n");
> > +		kfree(mac);
> > +		return err;
> > +	}
> > +	priv->mac = mac;
> > +
> > +	return 0;
> > +}
> > +
> > +static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv)
> > +{
> > +	if (!priv->mac)
> > +		return;
> > +
> > +	rtnl_lock();
> > +	dpaa2_mac_disconnect(priv->mac);
> > +	kfree(priv->mac);
> > +	priv->mac = NULL;
> > +	rtnl_unlock();
> > +}
> 
> dpaa2_eth_connect_mac() does not take the rtnl lock.
> dpaa2_eth_disconnect_mac() does. This asymmetry makes me think
> something is wrong. But it could be correct....

The way the driver is written, it's fine.

dpaa2_eth_connect_mac() is called prior to the netdev being registered.
At that point, nothing is published.

dpaa2_eth_disconnect_mac() is called _prior_ to the netdev being
unregistered, so there could be live accesses happening to the phy
and phylink.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

  parent reply	other threads:[~2019-10-22 16:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21 22:50 [PATCH net-next 0/4] dpaa2-eth: add MAC/PHY support through phylink Ioana Ciornei
2019-10-21 22:50 ` [PATCH net-next 1/4] dpaa2-eth: update the TX frame queues on DPNI_IRQ_EVENT_ENDPOINT_CHANGED Ioana Ciornei
2019-10-21 22:50 ` [PATCH net-next 2/4] bus: fsl-mc: add the fsl_mc_get_endpoint function Ioana Ciornei
2019-10-21 23:13   ` Andrew Lunn
2019-10-22  9:47     ` Ioana Ciornei
2019-10-21 22:50 ` [PATCH net-next 3/4] dpaa2-eth: add MAC/PHY support through phylink Ioana Ciornei
2019-10-22  1:06   ` Andrew Lunn
2019-10-22 12:08     ` Ioana Ciornei
2019-10-22 16:24     ` Russell King - ARM Linux admin [this message]
2019-10-22  7:36   ` kbuild test robot
2019-10-22 10:39   ` Russell King - ARM Linux admin
2019-10-22 10:52     ` Ioana Ciornei
2019-10-21 22:50 ` [PATCH net-next 4/4] net: documentation: add docs for MAC/PHY support in DPAA2 Ioana Ciornei
2019-10-22  8:14   ` Russell King - ARM Linux admin
2019-10-22  9:41     ` Ioana Ciornei
2019-10-22  9:49       ` Russell King - ARM Linux admin
2019-10-22 10:03         ` Ioana Ciornei

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=20191022162428.GX25745@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=laurentiu.tudor@nxp.com \
    --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).