From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 2D3CF48AE33 for ; Tue, 9 Jun 2026 15:13:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781017998; cv=none; b=ZcSihZAyLDuA4eOMRzcWMGGf5JchkLK79hJc6g0N7vEDzNt2AubzEByS3y53FoLUgw+He7u7KzS9t3R0vvyLsShPiraK2m7FrELfLAJMbmKTM85Q70k+TvR5DbQblBKri3ZzB3I+TKIeS2fvesMua4RwBN4uy+hiXv5uTqDW6mM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781017998; c=relaxed/simple; bh=sK4fxc5PVlOZuMIeUsvJWB2WAm5QU6VKChsYszl2b8Q=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qyeVdxYGQxUgy53iNVnBCRtUXsgrJ9DQHmB7gNVpnE4kS/xVVmFRS27D8WVR61n9RtBdtznYFPlSx2CzuNdvPsX7N1hN/07INI8LQs9pHsz5g0zXvMlQ7np3edfgr4yDTNfY7X356sUUygX2yY3drIu/na0l5MyHqjzc3END7pY= 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=XCHf30Cz; arc=none smtp.client-ip=209.85.208.49 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XCHf30Cz" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-68d232ed3f9so9435394a12.0 for ; Tue, 09 Jun 2026 08:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781017990; x=1781622790; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jWYk8ZymB6kHUZKwCJ/zVXargC+wN9U6CkBM8YYghXU=; b=XCHf30CzFMmddwoUU6Pm5/FBpS1Vcs37XYCWExDanoz0lumoDmHH2alprpw+HCXoAw sad8+Tjdd8Sy/3uhQlaxkaBSF+CusgInJps4h8Bt63hQKZ7yGh+o/QD7POMadb3D51N5 9x6+3BKoyJtyhodKk7x+Ty27VmBtVlSC0VPRNxJUSNyYTRbkojkO6rEg6XkK9DthR77z ETpTiBXfrbH9d61Gx9LDk74Q1wYtV4W6T3uMZyzZVepnr5g1oNnas08l9gQaiY/4LvCt Fpm4fviK+3L2p0PEN89RqVy6XluyJ8wmzQYf4CLv6q37w9ycfEi1nFFPCd64FXaabtvG HWzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781017990; x=1781622790; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=jWYk8ZymB6kHUZKwCJ/zVXargC+wN9U6CkBM8YYghXU=; b=eoTVy5yhzl/QVLRfSupIm2PYHSFf1F4pka5a9eg5gAcej9xwNh3wrxOq04IsWBHtv/ 9BqXe112RacZtOjYNdAU5+tkwL8eqs6U3sUgmgDhIBKlmPEgQkXRHacLkKu3yEM56pT3 LhrGKih+aTmJQrX3GqDA0kbjT+4aVI9fkpSzy/mp2JpcOzRH/+RiUsQ3xdgUUuNNqRsD NeoZaOiBnJPaS2EuhESOs86+P9Cwk2/GvE0jv2fQRFGu0R60Uv/1QSnl3eVnoSRHSFtu YkXyd3xzIvaISFQT7pgQv+JkaS31/Ile9GuwNz3gOXecZPZAVAmXUMAjcVFarA8Q49zX pBuA== X-Forwarded-Encrypted: i=1; AFNElJ/sH5paCIlkeUI/1EKa4sVHbJDV4AsmuvaZ6SNHf0zcSLY9AYZyLPB4DYYPocsleOngvm5If+ooiK+UtSc=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4UbNSdR7AYU623NXA6+2Ny1XqG+B7IpPljJV0XDl9un24hVhG ydnwnLbT2tdfwdm4Qda7oA7t4tj6yl6zG+Jw23H/7P/7/Vx94IMf3KzM X-Gm-Gg: Acq92OEm5IZkoBYTPgWbxzkF95pkSo0PayzHXOIdOmvryxjTMekxK/E4FgCfDL/Y9rj MkMXvqXNtAnB58ygXFgciF+D3ZxNWC511QC1DQby/MRLpIIPT5iM5A5Z968Y7UvtdPge7fOIb7B 1exXRbNXkanIMh++m1+hxeWkCT/Tiy439uMeSHm9zDU+IaxBiw1aIHbQ7x72AXaht0Fo6qAuivm MLPE2D1zSTCwOsOBguqxRppDQXY6d6AGGOqOt51sTG96K/7m7Vl3Nb0aCqvYhgVQXxr7ZkfDj9V Qq+SvWFE/ZOsGzBZgPgVIXk29WnCVMSZJJtUmTAzWBRgCSgS0mIJo4xZoAV8NpuCh7LalBtaXil lPaUD9KPdnLhkXwbBFHZ9un9xDZyzNODjLNrqvzCAVU3/zivJnX1x/+b1TUQoG437pVvLkuqa7y jEtMXPQbEANsdT6mUog0aAmdY4b7gV7xF9 X-Received: by 2002:a17:907:989:b0:bed:25a6:1c89 with SMTP id a640c23a62f3a-bf373407e0amr1077762866b.25.1781017990067; Tue, 09 Jun 2026 08:13:10 -0700 (PDT) Received: from Ansuel-XPS24 ([2.195.136.12]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-bf0517721e5sm1073637866b.9.2026.06.09.08.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 08:13:09 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Simon Horman , Jonathan Corbet , Shuah Khan , Christian Marangi , Lorenzo Bianconi , Heiner Kallweit , Russell King , Saravana Kannan , Philipp Zabel , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, llvm@lists.linux.dev Subject: [PATCH net-next v6 03/12] net: phylink: add phylink_release_pcs() to externally release a PCS Date: Tue, 9 Jun 2026 17:11:59 +0200 Message-ID: <20260609151212.29469-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609151212.29469-1-ansuelsmth@gmail.com> References: <20260609151212.29469-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add phylink_release_pcs() to externally release a PCS from a phylink instance. This can be used to handle case when a single PCS needs to be removed and the phylink instance needs to be refreshed. On calling phylink_release_pcs(), the PCS will be removed from the phylink internal PCS list and the phylink supported_interfaces value is reparsed with the remaining PCS interfaces. Also a phylink resolve is triggered to handle the PCS removal. The flag force_major_config is set to make phylink resolve reconfigure the interface (even if it didn't change) is also added. This is needed to handle the special case when the current PCS used by phylink is removed and a major_config is needed to propagae the configuration change. With this option enabled we also force mac_config even if the PHY link is not up for the in-band case. Signed-off-by: Christian Marangi --- drivers/net/phy/phylink.c | 49 +++++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 2 ++ 2 files changed, 51 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 4d6ffda0cdd6..b45bee927300 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -923,6 +923,55 @@ static void phylink_resolve_an_pause(struct phylink_link_state *state) } } +/** + * phylink_release_pcs - Removes a PCS from the phylink PCS available list + * @pcs: a pointer to the phylink_pcs struct to be released + * + * This function release a PCS from the phylink PCS available list if + * actually in use. It also refreshes the supported interfaces of the + * phylink instance by copying the supported interfaces from the phylink + * conf and merging the supported interfaces of the remaining available PCS + * in the list and trigger a resolve. + */ +void phylink_release_pcs(struct phylink_pcs *pcs) +{ + struct phylink *pl; + + ASSERT_RTNL(); + + pl = pcs->phylink; + if (!pl) + return; + + list_del(&pcs->list); + pcs->phylink = NULL; + + /* Check if we are removing the PCS currently + * in use by phylink. If this is the case, + * force phylink resolve to reconfigure the interface + * mode and set the phylink PCS to NULL. + */ + if (pl->pcs == pcs) { + mutex_lock(&pl->state_mutex); + + pl->force_major_config = true; + pl->pcs = NULL; + + mutex_unlock(&pl->state_mutex); + } + + /* Refresh supported interfaces */ + phy_interface_copy(pl->supported_interfaces, + pl->config->supported_interfaces); + list_for_each_entry(pcs, &pl->pcs_list, list) + phy_interface_or(pl->supported_interfaces, + pl->supported_interfaces, + pcs->supported_interfaces); + + phylink_run_resolve(pl); +} +EXPORT_SYMBOL_GPL(phylink_release_pcs); + static unsigned int phylink_pcs_inband_caps(struct phylink_pcs *pcs, phy_interface_t interface) { diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 3387d308c4ad..b65f91c78d8c 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -751,6 +751,8 @@ void phylink_disconnect_phy(struct phylink *); int phylink_set_fixed_link(struct phylink *, const struct phylink_link_state *); +void phylink_release_pcs(struct phylink_pcs *pcs); + void phylink_mac_change(struct phylink *, bool up); void phylink_pcs_change(struct phylink_pcs *, bool up); -- 2.53.0