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 9D3BBC10F16 for ; Sat, 27 Apr 2024 19:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DGlztaNHIdA9BKvxPUO8kDIpRsDC0sS+FHCiQo7P52Q=; b=qskKMOUkbUSHRt IlWD3mfgOZLoOAjK/FzDt3hlBUaj29wJ/GcXbFqrDjB3ycROpt8NQI2SPxF2s+awpCEd/S1o/iJI0 v9PGOPb1seK293Bfvnti03VB6JKiCtLbHiDkU9PusCZS1b8CS5v3SUXC47pGnp3WQkMrfIVGIu2zG /qrYx0R/cNglfYz1ROvPhOIbSsOM2AbWQPGkXfAJxB6umqwAyzQg/JxHtGGdIc1w5W2/QjvolMud/ WQJPtX6p2srzrzeSv1VgE73kP90cxVGQOCKsjWwY4BRnMUTzCT6ZRMWRHBFT8XNTxBwXgtze8ZPaS BALZLV/HElmfdtNAqD5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0noc-0000000G33z-158p; Sat, 27 Apr 2024 19:34:30 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0noZ-0000000G31c-1GFY for linux-arm-kernel@lists.infradead.org; Sat, 27 Apr 2024 19:34:29 +0000 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-57258c90899so2890804a12.1 for ; Sat, 27 Apr 2024 12:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714246463; x=1714851263; darn=lists.infradead.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=MID+B2Bh0mPzhxqGE2XrI56q0o17m4WOrXDwuiavZWE=; b=ip3z+1JFXN502ti28cWaepn0FWXNgb2MxXiC8odTcQybUJaiI7UhHCwDEQVHG9PzJk 22DMvv3nEIw+bV+wZ7a5r+wWKRJuVu0WM+P1qFyBMfpxBA7pUpiJiMZzmgNlSOLvzOMP lJVQGaQw2NIaSWTaoVnhdxv7V4ZOC8kaDZTgFtK/+n2Sf3EG8maiCMZyK7OLp86nsDpq m9jzaR1re7IOQSPvoXIfV51BmBMhysJWQeMU/VP6ldFGlluCajrG+N1qy5HlwRj8BnaP Wrv/uxq5HbQ5RJdHzyi8VYuM4jNDtcXrlEpWRNCmfqxbURpKalujvkLMA4pixhdCg3GL vrYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714246463; x=1714851263; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MID+B2Bh0mPzhxqGE2XrI56q0o17m4WOrXDwuiavZWE=; b=nMRBQ+zNaIjVLt4vqt8c2Im1jNC17EY0HeREacb206POCNd8/CIj7FxBYsRoByx5cK KCedWLQ32zKc4J4qRGnBZU0eYi7j8H9ZWUt7wBvwh1Is9aUx/qxmw2W1xiDcC6rWqGp1 miEXI8ei4WFe/Z6c7EOu/Up+A2dfjsxjCuaZYQpa7xjyGTHoQ0mlumNGOLSIsWc3nkLF HA22AJ7D/hnlom3iFTAEQN3xL6sXOk9eZ2fSXRg48PkvGIux1hI5suz9IcIvkCk56avl kDUTuc9fzWfFoxZJFpeVaKH/eMEj8ie1hxYc0yjoA8v1kyDCw2W6vW7+A+IIhO61y2DR 8XGg== X-Forwarded-Encrypted: i=1; AJvYcCWtXFFo9ZSKXi/1aGvuItRp4iQoj934qzrHKc+pd5pRgOn2vlb1xJCivl8cQkL2xSmpFjZhHGqyPcHFhLNNCc5Yn28X2t3/jDoZ3j3SjmFquxWXW5k= X-Gm-Message-State: AOJu0Yw3jERlWpMPHR+Vedag6j6E9QWQF7pL2AZmHOAHPfl6C0sME+NI TQWFAm4clN1Yj78WayJ6RJNZpC9AOxfXCdTn/yw7WohT2hUYdafs X-Google-Smtp-Source: AGHT+IG/+0HhEESs3V8kj/gUbOejKncVMqRiapoTCEkni1SKI4YWML67WBni9YKqx8XUV0QnprhVkQ== X-Received: by 2002:a50:f614:0:b0:572:3f71:161f with SMTP id c20-20020a50f614000000b005723f71161fmr2906356edn.12.1714246462776; Sat, 27 Apr 2024 12:34:22 -0700 (PDT) Received: from ?IPV6:2a01:c23:c403:ad00:c9fe:f0c4:b80:4a0a? (dynamic-2a01-0c23-c403-ad00-c9fe-f0c4-0b80-4a0a.c23.pool.telefonica.de. [2a01:c23:c403:ad00:c9fe:f0c4:b80:4a0a]) by smtp.googlemail.com with ESMTPSA id l11-20020a50cbcb000000b0057030326144sm11310255edi.47.2024.04.27.12.34.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Apr 2024 12:34:22 -0700 (PDT) Message-ID: Date: Sat, 27 Apr 2024 21:34:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next] net: phy: phy_link_topology: Handle NULL topologies To: Maxime Chevallier 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?Q?K=C3=B6ry_Maincent?= , Jesse Brandeburg , =?UTF-8?Q?Marek_Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?UTF-8?Q?Nicol=C3=B2_Veronese?= , Simon Horman , mwojtas@chromium.org, Nathan Chancellor , Antoine Tenart References: <20240412104615.3779632-1-maxime.chevallier@bootlin.com> <20240412152335.751a8dbb@device-28.home> Content-Language: en-US From: Heiner Kallweit Autocrypt: addr=hkallweit1@gmail.com; keydata= xsFNBF/0ZFUBEAC0eZyktSE7ZNO1SFXL6cQ4i4g6Ah3mOUIXSB4pCY5kQ6OLKHh0FlOD5/5/ sY7IoIouzOjyFdFPnz4Bl3927ClT567hUJJ+SNaFEiJ9vadI6vZm2gcY4ExdIevYHWe1msJF MVE4yNwdS+UsPeCF/6CQQTzHc+n7DomE7fjJD5J1hOJjqz2XWe71fTvYXzxCFLwXXbBiqDC9 dNqOe5odPsa4TsWZ09T33g5n2nzTJs4Zw8fCy8rLqix/raVsqr8fw5qM66MVtdmEljFaJ9N8 /W56qGCp+H8Igk/F7CjlbWXiOlKHA25mPTmbVp7VlFsvsmMokr/imQr+0nXtmvYVaKEUwY2g 86IU6RAOuA8E0J5bD/BeyZdMyVEtX1kT404UJZekFytJZrDZetwxM/cAH+1fMx4z751WJmxQ J7mIXSPuDfeJhRDt9sGM6aRVfXbZt+wBogxyXepmnlv9K4A13z9DVLdKLrYUiu9/5QEl6fgI kPaXlAZmJsQfoKbmPqCHVRYj1lpQtDM/2/BO6gHASflWUHzwmBVZbS/XRs64uJO8CB3+V3fa cIivllReueGCMsHh6/8wgPAyopXOWOxbLsZ291fmZqIR0L5Y6b2HvdFN1Xhc+YrQ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92W1uf1EcdXXIrx1acg21 H/0Z53okMykVs3a8tECPHIxnre2UxKdTbCEkjkR4V6JyplTS47oWMw3zyI7zkaadfzVFBxk2 lo/Tny+FX1Azea3Ce7oOnRUEZtWSsUidtIjmL8YUQFZYm+JUIgfRmSpMFq8JP4VH43GXpB/S OCrl+/xujzvoUBFV/cHKjEQYBxo+MaiQa1U54ykM2W4DnHb1UiEf5xDkFd4= In-Reply-To: <20240412152335.751a8dbb@device-28.home> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240427_123427_407814_E166A4BB X-CRM114-Status: GOOD ( 25.94 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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? > 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; >> > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel