Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp131973lql; Fri, 12 Apr 2024 06:08:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW14mM0bcQh2OZv3ygYTtJMtPJuMkcjB1tLG4NgDQCxLrvQznH9TKDF4TQGFgl0eXp9eI03gyqf4GKKck4QEaMEVmg33+OVGrfqW2a0vA== X-Google-Smtp-Source: AGHT+IH4TAmViZvUFj2h5k+Os64W2VKInwVe9LViA+UGcmtFV7InSv+wLYhah9RCIMN4465Jk+Hf X-Received: by 2002:ac8:574e:0:b0:431:824e:8e48 with SMTP id 14-20020ac8574e000000b00431824e8e48mr3674568qtx.9.1712927293770; Fri, 12 Apr 2024 06:08:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712927293; cv=pass; d=google.com; s=arc-20160816; b=pMuwLI/iKOwECzISXAPGQeOs7yKJ0liTZ6Fmw53dE+w+SXhQ5nrk2c9nerCSfqMPUr I+rNbvoSS1F0kLcwzZR3I+01McNHfnKc+zA5+rUb9ju3Gof03p9PxNPfMp0dRcZ3ITpv A5qzgzjU3ztu5KV1Y7HeklQenfenR4446F7gMKJnq8yv50YxsuRAiEr4NB9orbXxeVCu ZIpBqvClpJUmlT4MT4zesMjXBPQ5qQjCZe6uDeurHWnJa0E23a9QuxJ/etI/J05dUNS3 ozNCbgyNviYlnrbxSCtnDUBfAYiFW+iHapr6voMFkO5OSCulJwStPTGsWH05iNRmCec0 CqnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=9rn/zc6s/zD/8BUl/7+phShce3NbGsIX6yyn+LNAZyA=; fh=mtw6bW177t05bJnCUs0KL88Vvph8cR9ARIwK2/ZuR1o=; b=ZHsFxOASc0zP3of7alA2YuDc8mp+3Q1oQQKGOjLqkwWxlPExyju4t+rxAWW1pBZ4O6 Ieuv/i2dI6C8sURi8AuSu3fAj/rOB/vyIJuX7pjITNh+by330TqCmDNuHZkZZKnJusCd gnwRTCGm2JUAGgkwBUOHIncsaxKkde80wyQYLEWJOgzlAzTJIcJkkbE5D15HN+B5oglZ HUNoMTQfCS17b4k8QPoDrU7atJSDFjLo+jcitQihs4KwNp5Ne5We/JWrgKM/51Hj/RR4 C5rociDrlGPcO+YDqb2xyPkWhpUexsuw3DBrjEl/S6yxJPYHhyEineWKQbuZXacZL68K ufAw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=U93WBI7m; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-142690-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142690-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x20-20020ac85f14000000b00434d7878552si3672970qta.117.2024.04.12.06.08.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 06:08:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142690-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=U93WBI7m; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-142690-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142690-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6F5391C215DE for ; Fri, 12 Apr 2024 13:08:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C8A35F575; Fri, 12 Apr 2024 13:07:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U93WBI7m" Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E66460DDC; Fri, 12 Apr 2024 13:07:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712927274; cv=none; b=umWwgQCj+bRpIbFTOw7P+QF4KUj7hSCpc6UZ6ayg9fPczSJ+c0xUCNwRSvVPemy0/1H1QAkIi7BYik8Y0JXY2hWOmDKe5liMtjtwB1wywO2SHtdKJHd/9+2NMkBx3MkGvOHnxsWn7FjNHIhCehHJfD3HrPNSBD811lC24BiFVm0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712927274; c=relaxed/simple; bh=yrqKrLmM3Q4f6JFITmelRkHTdb26DS6Td14OmBR76YQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=skXd6oHn9FjGYE6K6OWTRreMZnu+8k6kh8XeNFuX9s8lJa1kaU942aJHnCNFbcefNrfiMyGA0fYsS0v2jmSyIpSJWDj7OW1UrrSSfn8sT518QwdGpZCYC/cHDe4Ns4b4XeoSuJsyaZsscO1G5eorTaMi6i6qP96mTR8UvYcNG58= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=U93WBI7m; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a4715991c32so111338066b.1; Fri, 12 Apr 2024 06:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712927269; x=1713532069; darn=vger.kernel.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=9rn/zc6s/zD/8BUl/7+phShce3NbGsIX6yyn+LNAZyA=; b=U93WBI7mNRbjELWYGbT4wNSk+pOz7gOQX1pDnvJ0hT8FXm3QXT2M5nrnQYh05FNP3w rbHjzoz0lTXWEX3304bgtXeOymN/OOOKtm0syU/Sm7oh2D3IKzFJzj2Q4JKlseqjp7tA t6nMH+zXzlNe5agI1ADlBxgRhtqaF6gizswQu4wgI6bLnkkH7HsE5dqt1y3dh3s9di99 obdcSJH22rDULwgqyjoZyE2Y8QSUDaCDTG5h7TvdVXxPRuxKJj71rsX0Jg5KVAWK6lQL cKcVU3pdJXBYzTEeph2JT9cmiMsYSuTXb5BvZu23C1yNLVu6S4hlEVkCT0GNhDlC+19W OCYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712927269; x=1713532069; 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=9rn/zc6s/zD/8BUl/7+phShce3NbGsIX6yyn+LNAZyA=; b=PXBBZERuPXvj6McOHAQtwIyFzIpghN5iollQjqV9+KdA6u0VssPuXo9wKyD+iroGaE L5TquS7YT5x4t+S4IokxWn3HCII1x/fhKX7dotC5x/K+P78Prmt7kxQs941TspncPDq5 y3eNMMD11JrubBWsKKqqyjnuSP1yJ2geuLnHVVAo3j6ODekJPHvCXDndWGDEITh3XFRt Gy9f3fNQJYOEeSTRDOK9MvTmeQ5IUbZDkYPIZlVTFqQm4DbuGZCR5I+AYzeVPRayDyjm 938ZuTL+0+6NXRzrwNbI/J8yMwqv5N1ysUdwLBkCSOPU6eBqp29/murrgjhmM7mp8DFc unZA== X-Forwarded-Encrypted: i=1; AJvYcCWm+HhYAQRFtGWVM2ajyHH/owv4ufpXio2YYOr4N+8wraxUMcn2El1nyI6xwnIedyUCPo+Xc2zkUqeFGqzhdBF1jamLHfa6PDTTbQzL X-Gm-Message-State: AOJu0YxzE0mGhI5asnryV1aFrXMEMfM2UPWy4DnFA1XR4Jkl95Eh5I3o 1ie2Xvec5XX6L/FxoVScBljfF8BrEOyjVbJyGRKoTs7ZVApGzWmD X-Received: by 2002:a17:906:3a85:b0:a51:fa56:4fc7 with SMTP id y5-20020a1709063a8500b00a51fa564fc7mr1614361ejd.21.1712927269211; Fri, 12 Apr 2024 06:07:49 -0700 (PDT) Received: from ?IPV6:2a01:c22:7a91:3c00:8c19:da9e:a091:c46c? (dynamic-2a01-0c22-7a91-3c00-8c19-da9e-a091-c46c.c22.pool.telefonica.de. [2a01:c22:7a91:3c00:8c19:da9e:a091:c46c]) by smtp.googlemail.com with ESMTPSA id ga31-20020a1709070c1f00b00a4e24d259edsm1786441ejc.167.2024.04.12.06.07.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Apr 2024 06:07:48 -0700 (PDT) Message-ID: Date: Fri, 12 Apr 2024 15:07:46 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next] net: phy: phy_link_topology: Handle NULL topologies To: Maxime Chevallier , davem@davemloft.net Cc: 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 References: <20240412104615.3779632-1-maxime.chevallier@bootlin.com> 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/BeyZdMyVEtX1kT404UJZekF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/2k3YPEJPv+yJf90MbYyQSbkTwZhrsokjQEaIfjrIk3 rQRjTve/J62WIO28IbY/mENuGgWehRlTAbhC4BLTZ5uYS0YMQCR7v9UGMWdNWXFyrOB6PjSu Trn9MsPoUc8qI72mVpxEXQDLlrd2ijEWm7Nrf52YMD7hL6rXXuis7R6zY8WnnBhW0uCfhajx q+KuARXC0sDLztcjaS3ayXonpoCPZep2Bd5xqE4Ln8/COCslP7E92W1uf1EcdXXIrx1acg21 H/0Z53okMykVs3a8tECPHIxnre2UxKdTbCEkjkR4V6JyplTS47oWMw3zyI7zkaadfzVFBxk2 lo/Tny+FX1Azea3Ce7oOnRUEZtWSsUidtIjmL8YUQFZYm+JUIgfRmSpMFq8JP4VH43GXpB/S OCrl+/xujzvoUBFV/cHKjEQYBxo+MaiQa1U54ykM2W4DnHb1UiEf5xDkFd4= In-Reply-To: <20240412104615.3779632-1-maxime.chevallier@bootlin.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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? 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. > 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;