From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EFF01C27C53 for ; Sun, 16 Jun 2024 16:09:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nEcYSTIbPEKIGdfvYT2zer1/87igAAr4ZhpzWWwsRi4=; b=QNItDHHtWGU5fNrb/DlIp84vw4 QomLsIzT57PBqoUlmKdYU5NQwTJ4yI2YloNbO+kkTrjquQWPONab1MGCUU3MYvx/ovZGdbMALwYqU DdJoeXJRFximHmW2/wkdzYOv2FMYV2cVLq/XJ20O7H92o1DOFAGa0gbFgSmqJDOeIqJQvNhMx9DxK LjSScO0QRHYPKrmyB0KS/2CWZBXJ4cIg8gNL4t+U84OWMFF3Jb+EdK27fiIPxeC3uPzTnUlwmep8Y ZQ5NZCFBfeHNIXe0SxexrbQHRVhxXMXM/oF8EmLsoY56CDJuIJnemdaAIqSK6rBxuPKJfh6jqE0HP P6eikHOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sIsRp-00000007r82-03Jx; Sun, 16 Jun 2024 16:09:41 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sIsRk-00000007qmJ-10NM for linux-arm-kernel@lists.infradead.org; Sun, 16 Jun 2024 16:09:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nEcYSTIbPEKIGdfvYT2zer1/87igAAr4ZhpzWWwsRi4=; b=tNE7bAc1VDfe9maB6HuA3f+3FH n7Dcp/vmcbsiLl0yHtnLxwSj9ZeEBVDWyoIS4DBE+4x/QHE/12Gl5qHSPGxhBpcVZSgk0jApnH6JR y74zhZI95Xom+diPUXHJce1SBZdSAioyZnaR8ZdxJiMP7biDWghILyowLRUvepsonZtRRsM55eQm/ M/Ff9BDAAh23eSeyIfuf+5/06dy5xz1bRkUkqK7s2XPiSj7O1DHsfe2zH9b9n7AmtX7dadYpibiaF KT34sfYLsr8mGlwnY13eB5UzO4rThrf1qZWpRauife7neo+w6wwIn5g5Hx5WJCjwS9JDvlII2OkDL lpzcJvwQ==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:53962) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sIsPP-0004E8-0R; Sun, 16 Jun 2024 17:07:11 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sIsPM-00046m-OT; Sun, 16 Jun 2024 17:07:08 +0100 Date: Sun, 16 Jun 2024 17:07:08 +0100 From: "Russell King (Oracle)" To: Andrew Lunn Cc: Maxime Chevallier , Jakub Kicinski , davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Eric Dumazet , Paolo Abeni , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?iso-8859-1?Q?K=F6ry?= Maincent , Jesse Brandeburg , Marek =?iso-8859-1?Q?Beh=FAn?= , Piergiorgio Beruto , Oleksij Rempel , =?iso-8859-1?Q?Nicol=F2?= Veronese , Simon Horman , mwojtas@chromium.org, Nathan Chancellor , Antoine Tenart Subject: Re: [PATCH net-next v13 05/13] net: ethtool: Allow passing a phy index for some commands Message-ID: References: <20240607071836.911403-1-maxime.chevallier@bootlin.com> <20240607071836.911403-6-maxime.chevallier@bootlin.com> <20240613182613.5a11fca5@kernel.org> <20240616180231.338c2e6c@fedora> <9dbd5b23-c59d-4200-ab9c-f8a9d736fea6@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9dbd5b23-c59d-4200-ab9c-f8a9d736fea6@lunn.ch> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240616_090936_325213_CB7942A2 X-CRM114-Status: GOOD ( 22.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Jun 16, 2024 at 05:21:25PM +0200, Andrew Lunn wrote: > On Sun, Jun 16, 2024 at 06:02:31PM +0200, Maxime Chevallier wrote: > > Hello Jakub, > > > > On Thu, 13 Jun 2024 18:26:13 -0700 > > Jakub Kicinski wrote: > > > > > On Fri, 7 Jun 2024 09:18:18 +0200 Maxime Chevallier wrote: > > > > + if (tb[ETHTOOL_A_HEADER_PHY_INDEX]) { > > > > + struct nlattr *phy_id; > > > > + > > > > + phy_id = tb[ETHTOOL_A_HEADER_PHY_INDEX]; > > > > + phydev = phy_link_topo_get_phy(dev, > > > > + nla_get_u32(phy_id)); > > > > > > Sorry for potentially repeating question (please put the answer in the > > > commit message) - are phys guaranteed not to disappear, even if the > > > netdev gets closed? this has no rtnl protection > > > > I'll answer here so that people can correct me if I'm wrong, but I'll > > also add it in the commit logs as well (and possibly with some fixes > > depending on how this discussion goes) > > > > While a PHY can be attached to/detached from a netdevice at open/close, > > the phy_device itself will keep on living, as its lifetime is tied to > > the underlying mdio_device (however phy_attach/detach take a ref on the > > phy_device, preventing it from vanishing while it's attached to a > > netdev) > > It gets interesting with copper SFP. They contain a PHY, and that PHY > can physically disappear at any time. What i don't know is when the > logical representation of the PHY will disappear after the hotunplug > event. On a SFP module unplug, the following upstream device methods will be called in order: 1. link_down 2. module_stop 3. disconnect_phy At this point, the PHY device will be removed (phy_device_remove()) and freed (phy_device_free()), and shortly thereafter, the MDIO bus is unregistered and thus destroyed. In response to the above, phylink will, respectively for each method: 1. disable the netdev carrier and call mac_link_down() 2. call phy_stop() on the attached PHY 3. remove the PHY from phylink, and then call phy_disconnect(), disconnecting it from the netdev. Thus, when a SFP PHY is being removed, phylib will see in order the following calls: phy_disconnect() phy_device_remove() phy_device_free() Provided the topology linkage is removed on phy_disconnect() which disassociates the PHY from the netdev, SFP PHYs should be fine. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!