๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24848

Re: [PATCH net-next v23 07/15] net: sfp: support deferred module insertion

#24848
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 23:47
135 lines
12567 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The new deferral only covers a PCS dependency that is missing
  when module_insert() runs.

--

net: sfp: support deferred module insertion

This lets an upstream device defer SFP module insertion. If its
module_insert() callback returns -EAGAIN, the module stays in
SFP_MOD_WAITDEV. A new sfp_upstream_retry_module() helper lets the
upstream retry the insertion once the missing dependency (e.g. a PCS
provider) has registered.

> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 915156743701b..e5ddd62318bf9 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c

[ ... ]

> @@ -2830,6 +2836,8 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event)
>  		/* Report the module insertion to the upstream device */
>  		err = sfp_module_insert(sfp->sfp_bus, &sfp->id,
>  					sfp->quirk);
> +		if (err == -EAGAIN)
> +			break;
>  		if (err < 0) {
>  			sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0);
>  			break;

[ ... ]

> @@ -3091,6 +3099,14 @@ static void sfp_stop(struct sfp *sfp)
>  	sfp_sm_event(sfp, SFP_E_DEV_DOWN);
>  }
>
> +static void sfp_retry_module(struct sfp *sfp)
> +{
> +	mutex_lock(&sfp->sm_mutex);
> +	if (sfp->sm_mod_state == SFP_MOD_WAITDEV)
> +		__sfp_sm_event(sfp, SFP_E_UPSTREAM_RETRY);
> +	mutex_unlock(&sfp->sm_mutex);
> +}

[Severity: Medium]
Does this retry cover modules that have may_have_phy set?

sfp_retry_module() only acts while sm_mod_state is SFP_MOD_WAITDEV. The
only way to stay in that state is for sfp_module_insert() in
sfp_sm_module() to return -EAGAIN.

Copper modules have may_have_phy set. These are e1000_base_t modules, or
modules with the 10G/5G/2.5GBASE-T extended compliance codes that
sfp_module_parse_may_have_phy() checks for. For them,
phylink_sfp_module_insert() returns before any PCS-dependent
configuration:

drivers/net/phy/phylink.c:phylink_sfp_module_insert() {
    ...
	/* If this module may have a PHY connecting later, defer until later */
	if (pl->sfp_may_have_phy)
		return 0;
    ...
}

So the module moves to SFP_MOD_PRESENT, and the PCS dependency is only
checked later in sfp_sm_main().

If the PCS provider has not registered yet, both paths there seem to end
in SFP_S_FAIL.

When a PHY is found:

  sfp_sm_probe_for_phy()->sfp_add_phy()->phylink_sfp_connect_phy()
    ->phylink_sfp_config_phy()

This fails because the host interface (e.g. SGMII) is not yet in
pl->supported_interfaces.

When no PHY is found:

  sfp_module_start()->phylink_sfp_module_start()
    ->phylink_sfp_config_optical()

This returns -EINVAL with "no common interface modes".

Both failures lead here:

drivers/net/phy/sfp.c:sfp_sm_main() {
    ...
		} else if (ret) {
			sfp_sm_next(sfp, SFP_S_FAIL, 0);
			break;
		}
		if (sfp_module_start(sfp->sfp_bus)) {
			sfp_sm_next(sfp, SFP_S_FAIL, 0);
			break;
		}
    ...
}

Later, when the provider registers, this chain runs:

  phylink_update_pcs()->phylink_sfp_retry_module()
    ->sfp_upstream_retry_module()->sfp_retry_module()

sfp_retry_module() then sees sm_mod_state == SFP_MOD_PRESENT and does
nothing.

Would the link then stay down until the module is re-plugged, or the
interface is cycled with ifdown/ifup?

The later patch in this series, "net: phylink: support late PCS provider
attach", only returns -EAGAIN when !caps->may_have_phy. So the rest of
the series doesn't seem to cover this case either.

The commit message starts with a general description ("when the
upstream device needs a dependency that is not yet available"). Only the
last sentence narrows it to optical SFPs. If leaving out copper and
may_have_phy modules is intended, could the commit message say so?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129230558.612526-1-ansuelsmth%40gmail.com
Technical Details
Message-ID: <179608246397.3146.5781345525320123745@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374533-linux-kernel-netdev=dewy.ru
References: <20261129230558.612526-8-ansuelsmth@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374533-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v23 07/15] net: sfp: support deferred module insertion
Date: Mon, 30 Nov 2026 23:47:43 +0000
Organization: Usenet Network
Message-ID: <179608246397.3146.5781345525320123745@kernel.org>
References: <20261129230558.612526-8-ansuelsmth@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1568729"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:PsNuDmg3EZuGxvMskoWWUAjT1rk= sha256:+EjwnMAYoT0XoRT7YZ4UpQmsJbMqM1wQJ0XUwN1u5gY=
	sha1:+IUw6UeXB/eU8oQmjgdel0Wmt7s= sha256:CCCK+p1tRWl0Cyn6kxzZ8fyWINlJNx2UyHxjEAIMNxY=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 7B0C9126017; Tue,  1 Dec 2026 02:48:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id kxBNEoVNUA0J;
	Tue,  1 Dec 2026 02:48:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374533-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id C5D4C12600C; Tue,  1 Dec 2026 02:48:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 8E1362F733; Mon, 30 Nov 2026 23:47:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796082467;
	b=2HzZfs6vBuP2uro68Sv40tZItNKlWCy3dlnNWpKbi9bPQhxaxx4p9UalZ6rxyasqLXJI
	 pslzEBPbOYEMH99yLNIS6HBW6YeaVmIGYyhWTo1AjJq7YaLUZdpY6AlzQS8wJau97ILJ5
	 UJaP1XfzT5ekFjYImMXK8iuKOGtoLHDLRwgmr9DJ9Pk/B4PU2OGzYdd5VqYI/IOkT4GIA
	 h3LvGGDQ39gKXazJ9BcOybtoXL6JZs8Iw0cRFRJWbqEukxXHq+aldSxbaAK1K4/VOblPE
	 Q08X6X+3o6KpM/MTjGOEPru/c8/RbRBwgxDmMKX+DrBAE0NzU/xrIoOq1dLHQgSj1Nw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796082467;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=/WvmnCByCv1C4yL+BFhS2LMig2WFt6p3YwVu2gMwJxc=;
	b=E2u9fPmrgMvPDKAg7TKcGPQs+2j3UAsPudfObz9xPs2sPOF5VdfwzB0VX4QZEaYCIf0o
	 VGFufa/N9prRVj+je3Vn3u2ZcARTzLvolSGneBaA5SawdAZs44faPTKyOyxTIiW3a9PNY
	 +Q9NvQJv1TpP2dNLjFVOgy4zZPOCtyKYGTS+IE1sTeanokXtzlhCnIbDfGDYPa70Zmb0B
	 BPY1RdUXpIoB37UksoeGGuoHc4qnY5B0zCQJDt85mS1oQowFa591DPKsihTaMZJL0zGYS
	 FfdVtCrRpjAl8eXUCjc9hfen4rYmzlD90oHBLoRlwtzx08lHbZUcUd5hWaqHupFK8TA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Am7cVxMI;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 46522606A336;
	Mon, 30 Nov 2026 23:47:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Am7cVxMI
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796082466;
	b=QZ4BD/lujNFmGNJG4IWb7Uu4oFkMYfB0PNvKWtlSzCsjhkrN2KSqsYzkY8qP2N2PZsUI
	 3LSjek56wleRVhJtzRUhkaSU+WWvy0oOq9y0YhB33edyiWUeZj69srtQPAzf9Y+XH/zTG
	 GrGgDdGbRDNb6TzEfTOaQpW+7QYU8A1SziJnxditmJ6GIXsS5IssjaU9uKkPudHZh73G3
	 2dO12wU90CweEntWYcVNfi6+98X36n5Otp2xpD+A4B6Ikb87zzlQ7II/DVCcFbHawN0I2
	 SVObY1OKv08nPtyxjKNFeFzo6G6MQ525ZndfVrXn9PwzZp0/vuLpPuQ9EK/qBHZwW7Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796082466;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=/WvmnCByCv1C4yL+BFhS2LMig2WFt6p3YwVu2gMwJxc=;
	b=xiW0iYYkSxFGTjuTMq7d6BZSjuFPeW3jNVfYIgnOQAgvJ7PetmORW3w1qQodvXXb1F92
	 xRDIGl1B9cCRWt0vCVm8urxbGS5/Ex9C2YfMBgDtEc+e5uOYPl7GwKCle7DsEzWYRt1/s
	 jN+h/iQ1duznBbIyrL1kE+lmtwVw8lEH/2U2F3I6hJo6C7ntACF3HMt5rZJLM1ToEMgVt
	 HmqOoze4qate9BMSmWwGcwE8OPxeSO7wGt9QlriXeD/zUIEpi847LmNhOMt5Jw0kGN6aN
	 ckPO6GEu7mI5YRDB/FACqHNdgEAUHPUXHuJNzBDtfNIEyBIRc9MoPLqEbPcEoffrswA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Am7cVxMI;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6595D606A33A;
	Mon, 30 Nov 2026 23:47:46 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B64B1F00924;
	Mon, 30 Nov 2026 23:47:44 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796082466;
	bh=/WvmnCByCv1C4yL+BFhS2LMig2WFt6p3YwVu2gMwJxc=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Am7cVxMIBWFXzbcSqmxeZdoaLZZ6iyhCw31Dee/1DIA8ImPCCjlnAzFWClDOX0DbV
	 dwtzOPMHvXI7nXgzA/Ns3NZuOkix4MYJ53amG7STK4wlhX6A7o7ubiEuk69x+ImeSz
	 acD/zTyzqC5LCFLn73AaGf3n01LhZ2pUilwTWMMQsCr2cOvKHdKNP21ifAQr1BUNwU
	 fs4yUlM7ChLHUgsT63n/Wqby3Udc+OV2Y/fm6l9lpb4Npbk12JeLAgGmfBHYdAd8dU
	 gTasKaP7o8wcIKTZrsTxoQY0I1xkJm8N9jYWGYd4RFuXxCS9KzhpenY6uQjYYFwFpq
	 8P/6/S7zECegQ==
X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
 conor+dt@kernel.org, willemb@google.com, horms@kernel.org, corbet@lwn.net,
 skhan@linuxfoundation.org, rdunlap@infradead.org, lorenzo@kernel.org,
 hkallweit1@gmail.com, linux@armlinux.org.uk, maxime.chevallier@bootlin.com,
 p.zabel@pengutronix.de, nathan@kernel.org, ndesaulniers@google.com,
 morbo@google.com, justinstitt@google.com, rmk+kernel@armlinux.org.uk,
 netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
 linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
 linux-mediatek@lists.infradead.org, llvm@lists.linux.dev,
 zhengping.zhang@airoha.com
X-In-Reply-To: <20261129230558.612526-8-ansuelsmth@gmail.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list