Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1301377lqa; Mon, 29 Apr 2024 04:56:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmG7rYfUV+1iX2atDVUbvydyS5NwqC8WcQ42noFAfwJS0B37MPDIOrQcjhqhebwSpnX1wk8OtIkAEk6kHOXTxv4bbe8V4j1+pBBk0bVA== X-Google-Smtp-Source: AGHT+IFeC7mk89dy9+0ndUB+RSR/MYJbcsZ3+BT2UjkGIRz15fif1Hoox4YgoXx95D/DaNr/klmc X-Received: by 2002:a05:6a00:a01:b0:6f3:ead3:c287 with SMTP id p1-20020a056a000a0100b006f3ead3c287mr8363152pfh.0.1714391778886; Mon, 29 Apr 2024 04:56:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714391778; cv=pass; d=google.com; s=arc-20160816; b=b2v1dZe/AyAYllrnH21y/d5Bkpx9s0jO331g6g32ms4PwWEcQPlI97ymdsJfG0Uv3J s/NVMjO1zTnstb6QgWs7Yla29qPmfN+Pd0DYps4u5TJoX0kU3R7uGnmQqRsW22Y1ZUBU C9YoIVJTkij/ggwneDS4kCulPARI7bateCJ4WuJAuLBX6D1CQJRZo4+fH/bJQS9Brfka mM6EgvmPTzU9f1mndgU6h5divLp3SxWZ1x7AHOjTd18YqZEc/reaEJZC4vAZPJqYoL7r z0SNlUsaI11ik7sidMGrxbzmQKRwvfLweT7k58CyWoUgZCaZ7tN+5AmBJBJgvnjqQUGq CU8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=zVjiQz4+6eouGFpCfe3kaMY1C/HczOpHYg45IACIDrE=; fh=KRrIqt5hrCAYbKMDBTvch4I6V0TQ71fdtKatQB5VDiU=; b=C9913x1I+rIyWYZzB2x+RLQCrFtFsPj72MsA2E8Ep6MQPQ1zXZi475DOMsDk3QNNRA MCNw9VZ0vgG9PAGAb+1Hs29CczSMIqTDU+6pksnpS+vZ0YKNlsAS8kXo7MXFoqOiVDNk WDQKIooXQKBeIrBWNTBhOvU3j0gb95EUtjiU15W+5wJkSsyfDIHuytsofyFc/LV51cqM jZfNq7bILLHREds7TMSX4ExJJdH+zl3IvKXzHuLz6SS1Dx4ZoT65C4h5PtQ8HPyaVp1n m0ILAcbkA3S/OBcJUa86csE7Pag6O7ZomSIZXbgmY4K093luj1fHBB/W5S8VJ/Xwgp41 snyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=T1FzTGcp; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-162182-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q9-20020a056a00088900b006ea88c317f0si20020546pfj.53.2024.04.29.04.56.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 04:56:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162182-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=T1FzTGcp; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-162182-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7CC342826EB for ; Mon, 29 Apr 2024 11:56:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C51852F6E; Mon, 29 Apr 2024 11:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="T1FzTGcp" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 713E551C2C; Mon, 29 Apr 2024 11:55:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714391759; cv=none; b=CCoY7HRGosZYCdDWKF055i+cSIBzMEv+Ownrd6A0bugeKLXjH69UGZyBTX874Wca9hMDMNcSaVKopuwxNSjoj+Qhdb+zWdF6miw0J08LrnJojja+5dLzjPcF4jkRKe8GRm7sfOlMi879JyDe23Cl4Az1jDL4WcNcDyv6BOohaag= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714391759; c=relaxed/simple; bh=Rttk/sZ1q84cN4XbtTe/EhC3qBR6n5XjvSTc1yckR8A=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JJyj+etfaRM/5HfhszUnufG48GOsnaiKcnPvVwFWx9piuGMob1xC40ynRlQ8Z+d8RjKyTnDuhhSrn/Js1Zrd6Ucfu06oyDUDtc+PlLhtfTanTmN6NapUXpqoN4f8N6mR8t9/sWj9rfdG5Fl6F2q2klHYZ+U4EoEvm5ZpvOG8pB8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=T1FzTGcp; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 4353920007; Mon, 29 Apr 2024 11:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1714391747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zVjiQz4+6eouGFpCfe3kaMY1C/HczOpHYg45IACIDrE=; b=T1FzTGcpXo6qFjZOOhPVXy51vNt64OAwvwBr0PYKHGBWH7+aCu4WN5aH/6bf7tfJ72zdAA zqBFcdqxnt2xdUWXoVtN5fzfduBZ8eNAuAmFdFy4kewweHnMkczztNtQEmgNQwKqRCA4xm RI71/BN4bgcmRZhBiuRCYhmkALNS3VnPiSkGzbUf/aJEgz0kXOmTWVt7wgrhJgnnQ2fAGD GFonoGeqyB7Ob+L7VDSI0BTXQSTSxyHCCmXzgjpGwOtBmBbVGOZ7Nw80ODv4VxxdFQdNC3 fGS5En/VIH0nhmpLBdzYG1YywAPhU4o0YMjn1QBqujNIU3jDbnyG0EuEhtLJJw== Date: Mon, 29 Apr 2024 13:55:42 +0200 From: Maxime Chevallier To: Heiner Kallweit Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Vladimir Oltean , =?UTF-8?B?S8O2cnk=?= Maincent , Jesse Brandeburg , Marek =?UTF-8?B?QmVow7pu?= , Piergiorgio Beruto , Oleksij Rempel , =?UTF-8?B?Tmljb2zDsg==?= Veronese , Simon Horman , mwojtas@chromium.org, Nathan Chancellor , Antoine Tenart Subject: Re: [PATCH net-next] net: phy: phy_link_topology: Handle NULL topologies Message-ID: <20240429135542.73d039b2@device-28.home> In-Reply-To: References: <20240412104615.3779632-1-maxime.chevallier@bootlin.com> <20240412152335.751a8dbb@device-28.home> Organization: Bootlin X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-redhat-linux-gnu) 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-Transfer-Encoding: 7bit X-GND-Sasl: maxime.chevallier@bootlin.com Hello Heiner, On Sat, 27 Apr 2024 21:34:21 +0200 Heiner Kallweit wrote: > On 12.04.2024 15:23, Maxime Chevallier wrote: > > Hello Heiner, > > > > On Fri, 12 Apr 2024 15:07:46 +0200 > > Heiner Kallweit wrote: > > > >> On 12.04.2024 12:46, Maxime Chevallier wrote: > >>> In situations where phylib is a module, the topology can be NULL as it's > >>> not initialized at netdev creation. > >>> > >> > >> What we see here is a bigger drawback of IS_REACHABLE(). For phylib it's > >> false from net core, but true from r8169 driver. So topo_create is a stub, > >> but topo_add is not. IS_REACHABLE() hides dependencies. > >> > >> topo_create et al don't really use something from phylib. > >> Therefore, could/should it be moved to net core? > > > > That's a valid point, and a better solution indeed. > > > >> At least for topo_create this would resolve the dependency. > >> > >> We could also add a config symbol and the PHY topology an optional > >> extension of net core. > > > > That could be a thing indeed. It could be selected by phylib then, I > > don't see it being a user-controlled option, as this would make it very > > confusing for users to only be able to see when there are mutiple PHYs > > on the link when the relevant option is enabled (but I might be wrong). > > > AFAIK the issue still exists on net-next. Are you going to submit > an updated version? It still is indeed. I've been very busy last week unfortunately, I'll followup today though. Thanks for the patience, Maxime > > > Maxime > > > >> > >>> Allow passing a NULL topology pointer to phy_link_topo helpers. > >>> > >>> Signed-off-by: Maxime Chevallier > >>> Closes: https://lore.kernel.org/netdev/2e11b89d-100f-49e7-9c9a-834cc0b82f97@gmail.com/ > >>> Closes: https://lore.kernel.org/netdev/20240409201553.GA4124869@dev-arch.thelio-3990X/ > >>> --- > >>> > >>> Hi, > >>> > >>> This patch fixes a commit that is in net-next, hence the net-next tag and the > >>> lack of "Fixes" tag. > >>> > >>> Nathan, Heiner, can you confirm this solves what you're seeing ? > >>> > >>> I think we can improve on this solution by moving the topology init at > >>> the first PHY insertion and clearing it at netdev destruction. > >>> > >>> Maxime > >>> > >>> drivers/net/phy/phy_link_topology.c | 10 +++++++++- > >>> include/linux/phy_link_topology.h | 7 ++++++- > >>> 2 files changed, 15 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/drivers/net/phy/phy_link_topology.c b/drivers/net/phy/phy_link_topology.c > >>> index 985941c5c558..0f3973f07fac 100644 > >>> --- a/drivers/net/phy/phy_link_topology.c > >>> +++ b/drivers/net/phy/phy_link_topology.c > >>> @@ -42,6 +42,9 @@ int phy_link_topo_add_phy(struct phy_link_topology *topo, > >>> struct phy_device_node *pdn; > >>> int ret; > >>> > >>> + if (!topo) > >>> + return 0; > >>> + > >>> pdn = kzalloc(sizeof(*pdn), GFP_KERNEL); > >>> if (!pdn) > >>> return -ENOMEM; > >>> @@ -93,7 +96,12 @@ EXPORT_SYMBOL_GPL(phy_link_topo_add_phy); > >>> void phy_link_topo_del_phy(struct phy_link_topology *topo, > >>> struct phy_device *phy) > >>> { > >>> - struct phy_device_node *pdn = xa_erase(&topo->phys, phy->phyindex); > >>> + struct phy_device_node *pdn; > >>> + > >>> + if (!topo) > >>> + return; > >>> + > >>> + pdn = xa_erase(&topo->phys, phy->phyindex); > >>> > >>> /* We delete the PHY from the topology, however we don't re-set the > >>> * phy->phyindex field. If the PHY isn't gone, we can re-assign it the > >>> diff --git a/include/linux/phy_link_topology.h b/include/linux/phy_link_topology.h > >>> index 6b79feb607e7..21ca78127d0f 100644 > >>> --- a/include/linux/phy_link_topology.h > >>> +++ b/include/linux/phy_link_topology.h > >>> @@ -40,7 +40,12 @@ struct phy_link_topology { > >>> static inline struct phy_device * > >>> phy_link_topo_get_phy(struct phy_link_topology *topo, u32 phyindex) > >>> { > >>> - struct phy_device_node *pdn = xa_load(&topo->phys, phyindex); > >>> + struct phy_device_node *pdn; > >>> + > >>> + if (!topo) > >>> + return NULL; > >>> + > >>> + pdn = xa_load(&topo->phys, phyindex); > >>> > >>> if (pdn) > >>> return pdn->phy; > >> > > >