mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Rosen Penev <rosenp@gmail.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Christian Lamparter <chunkeey@googlemail.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] net: emac: release DT PHY resources on teardown
Date: Wed, 21 Oct 2026 03:05:26 +0200	[thread overview]
Message-ID: <59c8f008-9ca0-4620-9a54-e73da131ab6c@lunn.ch> (raw)
In-Reply-To: <20261020223002.1749284-1-rosenp@gmail.com>

On Tue, Oct 20, 2026 at 03:30:02PM -0700, Rosen Penev wrote:
> Disconnect PHYLIB PHYs and deregister fixed PHYs during both probe
> unwind and driver removal. Without this cleanup, unbinding a DT-based
> EMAC can leave its PHY attached to the freed netdev, while fixed-link
> instances retain their registered fixed PHY.

This driver is quite convoluted with its PHY handling.

Please split this into two, phy_disconnect() and
of_phy_deregister_fixed_link() and add better commit messages.

	if ((dev->phy_address == 0xffffffff && dev->phy_map == 0xffffffff) ||
	    of_phy_is_fixed_link(np)) {

		/* PHY-less configuration. */
		dev->phy.address = -1;
...
		if (of_phy_is_fixed_link(np)) {
			int res = emac_dt_mdio_probe(dev);

			if (res)
				return res;

			res = of_phy_register_fixed_link(np);

The logic here is more complex than 

> +	if (of_phy_is_fixed_link(np))
> +		of_phy_deregister_fixed_link(np);

So you need to explain in the commit message why it is correct.

> +static void emac_cleanup_phy(struct emac_instance *dev)
> +{
> +	struct device_node *np = dev->ofdev->dev.of_node;
> +
> +	if (dev->ndev->phydev && dev->phy.address >= 0)
> +		phy_disconnect(dev->ndev->phydev);

It is also not clear this is correct, since a fixed-link should be
connected to, yet a fixed link has dev->phy.address == -1?

	Andrew

  parent reply	other threads:[~2026-10-21  1:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 22:30 Rosen Penev
2026-10-20 22:33 ` netdev-bot+sinfo
2026-10-20 22:37   ` Rosen Penev
2026-10-21  0:51     ` Andrew Lunn
2026-10-21  1:05 ` Andrew Lunn [this message]
2026-10-21  3:11   ` Rosen Penev

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=59c8f008-9ca0-4620-9a54-e73da131ab6c@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=andrew+netdev@lunn.ch \
    --cc=chunkeey@googlemail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rosenp@gmail.com \
    /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

all inboxes | Powered by JetHome®