Received: by 2002:a05:7412:8d08:b0:f9:2d0a:d759 with SMTP id bj8csp222518rdb; Sun, 17 Dec 2023 08:57:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJW+UTdESctcQxyRk/8osgzRHpRxFzYh2e8OAXO5t/Qmg3ZH7rjxMP8fxDcpTVCbx4bdDR X-Received: by 2002:a50:9355:0:b0:552:e1e1:e648 with SMTP id n21-20020a509355000000b00552e1e1e648mr2489989eda.69.1702832279785; Sun, 17 Dec 2023 08:57:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702832279; cv=none; d=google.com; s=arc-20160816; b=EWl+yFMmno2av4A+Rob7KDu7Wof0Pdi4D/TlA/ZESTTUxGuOrGhFSHNm6Fpm+K8u42 R94eMYfJYB9cX/Q/MIrvf7+LQ06d1cCpnPbMi40zs7wkiCBxtDNLN7vcXuhJC5jkzHRC 2HxQszkDIqN8ogyVr2yXHhEhFllS1vDRSRtUyL/QSd12BDwgDAF8hfo+HDo+oTz1V/OG WMgFUFbvdPz+GgyamYcxzLX9rGzg0vbmlNNla5i3F/K0leIHqKkBZAv+ZnOEsd1Iq67I MPpA2GqGM9SbPxMTy1Se4qbcfIgcLrN68vXohYBw8Ed7nMqV0jrm14fiHjDrqZZgXT6B APqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gQ4VXb6aTdqcaOkXb5g9GnK1Q/37tTNEjG1RRH6Dcn0=; fh=xQSXq0S/gu05fa38xoZxishsEdDGfWx9YiVyEjB1qDY=; b=D/I9avdh7bFQ5Vy3qL2uyga2XUqZ+wtDsGpLmvr8TvKny5fUK9beF7xeASjcEk9evZ Laxk//C2JG9NDZapvo/fkWiQdvxC9JLIg6QcQVT3HpyoM3sS8/agG+awSri+P+Qw9lWZ yrWfEuEG2z63rQnDIDclRQ9bVPwnjIqulrmxJmnuXwtHv9ARikRrPSyeUrePzS6p11MP uegaCCt22cln84lvO11Afp6Yj57jUoSsDKFmZKR/mj6oFdNv2YA9dueuuAL10dg+il/f 0th7M3PEkUSnwKrK0tSxObNLWIsn6e6kSO3XkS/H5O1V2UwvCexmmXFpNd0C3FQwXmCF m78w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=EaKGOjUm; spf=pass (google.com: domain of linux-kernel+bounces-2690-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2690-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l11-20020a056402254b00b0054bf6c62e5asi9339444edb.419.2023.12.17.08.57.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 08:57:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2690-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=EaKGOjUm; spf=pass (google.com: domain of linux-kernel+bounces-2690-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2690-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8B4DA1F22AFE for ; Sun, 17 Dec 2023 16:57:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82D2F4642C; Sun, 17 Dec 2023 16:57:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="EaKGOjUm" X-Original-To: linux-kernel@vger.kernel.org Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1DDE47F5E; Sun, 17 Dec 2023 16:57:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch 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=gQ4VXb6aTdqcaOkXb5g9GnK1Q/37tTNEjG1RRH6Dcn0=; b=EaKGOjUm/Lmqo4HWwoN5DYsu9V cR4Xv0Rpt0TZSVgkRoBB0REzy+MCPnFok4MnDE8pQtr9mZg4X/9EiSk7WJwhTVBWa7xpRImVdEwLq pT63WDfGl9guNcHF3SexzzyXxp/ccpD6BIefUN0W9Tjt6ptTHf5t/hp1oUUSEvoyagM8=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1rEuRy-003A5K-R1; Sun, 17 Dec 2023 17:57:10 +0100 Date: Sun, 17 Dec 2023 17:57:10 +0100 From: Andrew Lunn To: Vladimir Oltean Cc: Maxime Chevallier , davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , =?iso-8859-1?Q?K=F6ry?= Maincent , Jesse Brandeburg , Jonathan Corbet , Marek =?iso-8859-1?Q?Beh=FAn?= , Piergiorgio Beruto , Oleksij Rempel , =?iso-8859-1?Q?Nicol=F2?= Veronese Subject: Re: [PATCH net-next v4 01/13] net: phy: Introduce ethernet link topology representation Message-ID: References: <20231215171237.1152563-1-maxime.chevallier@bootlin.com> <20231215171237.1152563-1-maxime.chevallier@bootlin.com> <20231215171237.1152563-2-maxime.chevallier@bootlin.com> <20231215171237.1152563-2-maxime.chevallier@bootlin.com> <20231215214523.ntk5kec32mb5vqjs@skbuf> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231215214523.ntk5kec32mb5vqjs@skbuf> On Fri, Dec 15, 2023 at 11:45:23PM +0200, Vladimir Oltean wrote: > On Fri, Dec 15, 2023 at 06:12:23PM +0100, Maxime Chevallier wrote: > > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > > index d8e9335d415c..89daaccc9276 100644 > > --- a/drivers/net/phy/phy_device.c > > +++ b/drivers/net/phy/phy_device.c > > @@ -1491,6 +1500,11 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, > > > > if (phydev->sfp_bus_attached) > > dev->sfp_bus = phydev->sfp_bus; > > + > > + err = phy_link_topo_add_phy(&dev->link_topo, phydev, > > + PHY_UPSTREAM_MAC, dev); > > + if (err) > > + goto error; > > } > > > > /* Some Ethernet drivers try to connect to a PHY device before > > @@ -1816,6 +1830,7 @@ void phy_detach(struct phy_device *phydev) > > if (dev) { > > phydev->attached_dev->phydev = NULL; > > phydev->attached_dev = NULL; > > + phy_link_topo_del_phy(&dev->link_topo, phydev); > > } > > phydev->phylink = NULL; > > > > diff --git a/drivers/net/phy/phy_link_topology.c b/drivers/net/phy/phy_link_topology.c > > new file mode 100644 > > index 000000000000..22f6372d002c > > --- /dev/null > > +++ b/drivers/net/phy/phy_link_topology.c > > +int phy_link_topo_add_phy(struct phy_link_topology *topo, > > + struct phy_device *phy, > > + enum phy_upstream upt, void *upstream) > > +{ > > + struct phy_device_node *pdn; > > + int ret; > > + > > + /* Protects phy and upstream */ > > + ASSERT_RTNL(); > > Something to think for the PHY library maintainers. This is probably > the first time when the rtnl_lock() requirement is asserted at > phy_attach_direct() time. There are two use cases here for plain MAC drivers. 1) phy_attach_direct() is called from probe. RTNL is normally not held, the driver would have to take it before making the call. 2) phy_attach_direct() is called from ndo_open. In that case, __dev_open() has a ASSERT_RTNL() so we can assume RTNL has been taken. So i don't think we can assume RTNL is held, but it might be held. We need a better understanding what is being protected here. Andrew