🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5809

Re: [PATCH net] net: emac: release DT PHY resources on teardown

#5809
From: Andrew Lunn
Date: Wed, 21 Oct 2026 01:05
44 lines
9295 bytes
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
Technical Details
Message-ID: <59c8f008-9ca0-4620-9a54-e73da131ab6c@lunn.ch>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349679-linux-kernel-netdev=dewy.ru
References: <20261020223002.1749284-1-rosenp@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349679-linux-kernel-netdev=dewy.ru
From: andrew@lunn.ch (Andrew Lunn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: emac: release DT PHY resources on teardown
Date: Wed, 21 Oct 2026 03:05:26 +0200
Organization: Usenet Network
Message-ID: <59c8f008-9ca0-4620-9a54-e73da131ab6c@lunn.ch>
References: <20261020223002.1749284-1-rosenp@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="4007667"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:NE/aGdlRtgNhiVjY9sH+2fcjwxo= sha256:AoU63zYYcG8Bok6VIN/jedv65BZDNAzD+cgJaxWyWz8=
	sha1:rt3b3WWkNheyJxa6r7QK5Fi9sQA= sha256:624Tq9ssuErbUaS1c7vpJuD9V8xKFv9ziiqVMmz6gnQ=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 4EC18110EC4; Wed, 21 Oct 2026 04:07:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=lunn.ch
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id nknkTBVC05re;
	Wed, 21 Oct 2026 04:07:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-349679-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=lunn.ch
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id C6ACB110E4E; Wed, 21 Oct 2026 04:07:30 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 244DF3B416; Wed, 21 Oct 2026 01:05:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792544741;
	b=MPGnC/S/oMgeXtph9vL0ONd3RFc1qA+3V0M9t3UsyxdnigqjIOsbsbuJoITRoqSCQjuZ
	 pDaOIJH9MGITfAXNe07DaZ5Geg1KprpMtIEa1AXZ5J2mby0Ir2O/hF6oJlShut/yCD9T6
	 Xb6zyNDwZLVeQmXxhustXaSGGT7D01yljvNbgIVQ72TJ3N7Bk/KhfnZP6GWMSlLNkHO76
	 Ehe3b5IKBMA5Q23YUa0S4L0Dph4ft8dTSvceKfIByGVfrMfk3eqQUD8F9r3981Yo2mm0P
	 7aiFX6XLJ+j1MwUPcGISEHhzpVaz/uiS+0S9UPJMdvGzajmx61AtYWpSfLCbW9RWKmw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792544741;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date:
	 From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=yzjZW+qTIi0ilDpmbfqEu+IvND2R58m4+1/2tiefcE0=;
	b=RRozee9s4vL6NlDSGNG3leNUWn9tqKGDw+nz8m+3GrysqKuHQQNVVLmkg6EXm0KVr7ig
	 rkmxc9plte2CwIFKZd8TH2opJfX/IPXv2XfhiYZR5BcGO/wsfcICm2zBZ/uYqdthuBO7u
	 ICvqjxG0z14OX/Y4MxSit5OrtYq4VA07sun1aZ9U9Bt9z5QG4bTMu4stPjJW+Y4Ur5Nje
	 PQBoxoLcZTzICaxHgTIGfy4JelikKRDVWSlGcHaiulU8nAbHyMeanY9DwtKnA2lGhpaJd
	 PAZcXIpeM5yT+NLtrxOqpaCEfG0abVx6+Gz9cgntRri6+24yvSYvsOcF1ets1X3qGpQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=pass header.from=lunn.ch;
	spf=pass smtp.mailfrom=lunn.ch;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A11D606A325;
	Wed, 21 Oct 2026 01:05:36 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=156.67.10.101
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792544735;
	b=L2s0PTu3ZWZrtLoVJMOqMKFz6dmUql06n0wG6GKJUPZYET/TY2EnEPGbMwe3kkhuUDSZ
	 1amrdGiuS/jW6y65d+tZvtHqxFi78T+rLMoM27dSRcr5UTQXAcLWBS9DoQ100fjpCFQzI
	 EjRnrVQ4gleAg8A4aeOsfIO3H7BzUDI6y7++8Et/FIBIxRMaQe9z4zx6H6XG2zLLggyXy
	 EiBsUfWIK+EdoHrrTuXJ5Ra42crDoZc2PzXikwIzzn1bDKzQ8bVXYIRDgdsNV16/t4YW6
	 fAsH3ToItJU2hTY2euxyGZhwFB4d9jfN+V/nXXTHlp5jvhIN0wSNaVA/Rbq2lsCAYPg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792544735;
	h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject:
	 Message-ID:References:MIME-Version:Content-Type:Content-Disposition:
	 In-Reply-To;
	bh=yzjZW+qTIi0ilDpmbfqEu+IvND2R58m4+1/2tiefcE0=;
	b=FVh9kL8uk9daFaKpq1yL4Ic1/7ajtPgm72fuxFptRSwFWRrVYnnbMAdhojNP+iga3X4o
	 JlROXqZsQT02iPFSrgs7eZLOWWvDKDOYoErEoEbjJFALlKTD/ay7YEQ52zpJtWF4mcuEk
	 G7fmSfQQLrwFXBlyTrHLjlPz9YC5AFBDgj1QDLF9LH8ZKN6msylaOLZFN7kXwiVv8nO+Y
	 Z/69RaeQdLha/1dg3UqSpq7eN+u1tqozruPf+KRd+9bYM9IfG1Jy6tYWGwL1Crsfsv55+
	 F8SCHH+eQLlNlE3e+VvzjJXj8Zbofu6ZiZRY+zLitmUhFSYTNV/q1dN1SeBOVmu0m4w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=lunn.ch;
	spf=pass smtp.mailfrom=lunn.ch;
	dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=IPx3XyZn;
	arc=none smtp.remote-ip=156.67.10.101
X-Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 240D7606A319;
	Wed, 21 Oct 2026 01:05:35 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 240D7606A319
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch;
	s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version:
	References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject:
	Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:
	Content-ID:Content-Description:Content-Disposition:In-Reply-To:References;
	bh=yzjZW+qTIi0ilDpmbfqEu+IvND2R58m4+1/2tiefcE0=; b=IPx3XyZncTgKcilragBIPzdckV
	dsEQcCuka/dbWro/Xth8Ygzo7JpJhxIa5YjSXQosibFqYezE5nm6j6xDUMZOsUHHlNOJR+VzI0QL/
	CzxGEMQzfC0po06/v4Sbuu3Y3AaQIohT/nmgaG5Ya265J36JULfg45on69Ot5AuTgZIY=;
X-Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2)
	(envelope-from <andrew@lunn.ch>)
	id 1xJKli-00Bx1E-Bo; Wed, 21 Oct 2026 03:05:26 +0200
X-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>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261020223002.1749284-1-rosenp@gmail.com>