Article View: linux.kernel.netdev
Article #16895Re: [PATCH net-next v21 01/13] phylink: Add phylink_mac_interrupt
From: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 02:06
Date: Mon, 16 Nov 2026 02:06
120 lines
12416 bytes
12416 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] phylink_mac_interrupt() (drivers/net/phy/phylink.c:1629-1637)
is meant to be called from interrupt context.
--
phylink: Add phylink_mac_interrupt
This adds an exported helper, phylink_mac_interrupt(), that MAC drivers
can call from interrupt context. It forwards a link-change interrupt seen
by the MAC to phylib by calling phy_mac_interrupt() on the attached PHY.
Drivers can then skip polling the PHY.
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index e885da1c28311..a87eaa2f3db5b 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -1616,6 +1616,26 @@ static bool phylink_link_is_up(struct phylink *pl)
> return pl->netdev ? netif_carrier_ok(pl->netdev) : pl->old_link_state;
> }
>
> +/**
> + * phylink_mac_interrupt() - wrapper for phy_mac_interrupt()
> + * @pl: a pointer to a &struct phylink returned from phylink_create()
> + *
> + * Passes a link-change interrupt received by the MAC to phylib.
> + * This function may be called in interrupt context, and therefore cannot take
> + * a mutex. However, it is safe to assume that the reference to phy does not
> + * disappear during the call, as only an SFP module may be unplugged to make a
> + * PHY disappear. SFP modules however do not support interrupts.
> + */
> +void phylink_mac_interrupt(struct phylink *pl)
> +{
> + struct phy_device *phy;
> +
> + phy = pl->phydev;
> + if (phy)
> + phy_mac_interrupt(phy);
[Severity: Medium]
Does the lifetime argument in the kernel-doc above hold?
pl->phydev is read here with a plain load. No lock, RCU or reference is
taken. Every writer, phylink_bringup_phy() and phylink_disconnect_phy(),
changes it while holding phydev_mutex, phy->lock and state_mutex. KCSAN
would likely report this as a data race.
The pointer is then used by phy_mac_interrupt()->phy_trigger_machine(),
which calls mod_delayed_work() on phy->state_queue.
phylink_disconnect_phy() is not specific to SFP. It does not wait for a
phylink_mac_interrupt() call that is already running:
drivers/net/phy/phylink.c:phylink_disconnect_phy() {
...
pl->phydev = NULL;
...
if (phy) {
flush_work(&pl->resolve);
phy_disconnect(phy);
}
}
phy_disconnect() goes through phy_stop_machine(), which calls
cancel_delayed_work_sync(&phydev->state_queue). Then phy_detach() drops
the attach reference.
Suppose an IRQ loaded the old pointer before pl->phydev was cleared. Can
it then queue state_queue again after the cancel, on a PHY that has
already been stopped and detached?
The SFP part of the argument may not hold either. SFP module PHYs are
also stored in pl->phydev, via
phylink_sfp_connect_phy()->phylink_bringup_phy(), and
phylink_mac_interrupt() does not check phy->is_on_sfp_module.
The interrupt comes from the MAC, not from the SFP PHY. Removing a module
is just the kind of event that makes a MAC or PCS report a link change.
When the module is removed, sfp_sm_phy_detach() does:
sfp_remove_phy(sfp->sfp_bus);
phy_device_remove(sfp->mod_phy);
phy_device_free(sfp->mod_phy);
Here sfp_remove_phy() ends up in
phylink_sfp_disconnect_phy()->phylink_disconnect_phy().
If a MAC hardirq has already loaded the old pl->phydev, could
mod_delayed_work() run on a phy_device that has already been freed?
The only caller in this series, ax88179a_status(), looks safe.
usbnet_stop() kills the status URB before ->unbind() calls
phylink_disconnect_phy(). The concern is the contract of the exported
API. The kernel-doc says the call is safe and does not tell callers to
mask and synchronize the MAC interrupt before phylink_disconnect_phy() or
PHY teardown.
Should the kernel-doc state that requirement, or should
phylink_mac_interrupt() protect the pl->phydev pointer itself?
> +}
> +EXPORT_SYMBOL_GPL(phylink_mac_interrupt);
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261114-ax88179a-v21-0-c2d34410bcbe%40birger-koblitz.de
Technical Details
Message-ID:
<179479481209.3136.3578602024095855268@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363986-linux-kernel-netdev=dewy.ruReferences:
<20261114-ax88179a-v21-1-c2d34410bcbe@birger-koblitz.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363986-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v21 01/13] phylink: Add phylink_mac_interrupt Date: Mon, 16 Nov 2026 02:06:52 +0000 Organization: Usenet Network Message-ID: <179479481209.3136.3578602024095855268@kernel.org> References: <20261114-ax88179a-v21-1-c2d34410bcbe@birger-koblitz.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1956034"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:bnS7FvR2D/YX4MwRIcsfNMSoZlo= sha256:ZBNrdvatE5gmCfY1eITFVN6CN3ffp6MUbEsr+Mk9qnQ= sha1:CAHTwuOCgK9TIikcSRhBzVnVvXs= sha256:7n0ce0ePJ9Ggf6EJ5SxzFi9XSmLhPuYik8xTkPV2MaQ= 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 99BC9114AF3; Mon, 16 Nov 2026 05:07:17 +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 QmvJ4_2CQ_ki; Mon, 16 Nov 2026 05:07:09 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363986-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 54E1E114017; Mon, 16 Nov 2026 05:06:58 +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 19A3C317AB; Mon, 16 Nov 2026 02:06:56 +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=1794794815; b=A5shTXBI53il4Bpdiwtet9+t98CmPibKw1dszUY6MLm50tGHOJUvnN+reEW24ROPp+29 4Qkxmdwh78/dS+BU5GBbPlYMGNuSULHR2YQOLDMGFZ/1wKU5a89kb6NF0mMR6r/0I42oI bfYYuvM0zi/1YLeCXg0NRjgfM1B0ZJ49N4ui8lEjj8VWWQYw8LVboU8R97bI1lVtorsjn GEXFhpTOM+FNmpuLnEFv00LvucN/tdnevcs6axNL1tT+V1RCnjOwoaFCbWfPOh2O+0SHs yceQlngkBtaJFrRbo3zVKsdEnQ/PeeELCHxAdLMKc7RdJg/GQOmXmPV8Tza9LcsHq0w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794794815; 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=AyN9oXLJLPfu4KohfU23gdr6R758HYP5wTMLtnJg4oM=; b=KB+p0hVSryAe72QRFuqyg6MpSTnI+wDKrR5fMpCaYGENap7116oX7cpY0MfT9PTEUp7O +xf3a3NxVv/8QyLH+HytVuEu4+zaIsqY/NYlHxQgfB5ca609x1iCeHh3ds1RgdhSKkLIG de8IDQw1z6f4tkLTSaPAckrtqabc1doXJiCk+RmzgQRWdRSvZSJrdzSQUvb4NoSQHjCfb 4NxZcFhxoMYr8P96qVvPSiKCfVOvWZVhh0EEZjvz/tuknk7h/DJuBKgmDKHQ3XxDuQ3tw pxCL7gQXqHFDW26F3ltV1pTRQ58BRU6Hi3LrX5M7dfsa5+E4HKsVDRAG6xtd4A571jQ== 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=YsdU2VCy; 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 ED564606A336; Mon, 16 Nov 2026 02:06:54 +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=YsdU2VCy 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=1794794814; b=2ZmT/hwu4IRE8/iDkEKM7VReo8CFAstToH26GzhxPYjJrDmBj5Yc4e5VhmXSYQ03+21n Ahw4NSIg+JiKlQcdyB2jB41xangTc/N+CWxlkMYtcj7lDhnY/SCfgcKdS4GVsFnr67Gsh VUioa0/nmlsqGLf1P1ZfZf9sGVVze6rt4p2DQlvXgtNy73g3Y0QX6MA7kMARFK7cp5+OW NLRpvUSGysNrJYo+pkEkJLIPkG10tjzt6iFlEFgl5vNY/a8MCXTCJ45NRRj24gAgnACCG dC/PrY2HHy/qyYXApxca0I3xqm2CPaHFjMohNwy5j398tlC7JRLyR96pyP1msK8HvBw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794794814; 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=AyN9oXLJLPfu4KohfU23gdr6R758HYP5wTMLtnJg4oM=; b=B4KYMJQ7NAuLx3lUxC4ouenjDr0PqWE7xyYKgo8MqAUOXBLX1w79q06dH1TVWh0i5RiH h9bLf0BNVMvYtHEJAKCbeTToLuIwOE2vdtlLL1P3jtnj8++yVlUXCt5LvpZWL9Nt64SNO YdO1TaJl+fLgRM7pmGcsu1N6lZjiHR4V5vs3+vuAc2KeeJ8s3bw/6oDPjLYtdbA5lxpzE CxcXw1VGx/qMbT1RoESyonrQuYFc2rbeZhXOngm5AvNyghF7lB0TaZazG3exLiL4EVSRi TVYCwlKeuHTpuOuJtP/8++Aprublj/PkbDraLQXn+SFxmztWCrOQAjHtBxgduU9R34g== 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=YsdU2VCy; 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 17ECD606A32C; Mon, 16 Nov 2026 02:06:53 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CFEB1F000C4; Mon, 16 Nov 2026 02:06:52 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794794813; bh=AyN9oXLJLPfu4KohfU23gdr6R758HYP5wTMLtnJg4oM=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=YsdU2VCyTnH9kd1vgtOrBKt0ITGI+JRBPI+lG4V5Ec3ZYDtW+I3dBo+PiDPBmc1j5 sgg6vhj3l0V4sREkxH96mIQt0pe/Ux4/PYhXru0qz0opFsFqQvhD+FLu1suut6mF8j 9GAjfsvCjXco9lB+Ja3A8oIYiwKS31XSSa4CG2n1SShGxUqeV0B5g5XY09MLxIpNHL 7a54fmMB23BaJT6pyHNjzk0hCCgYqWER/8kHYFR6Gnv2u+gnc7ye9trEeBf84bPJxd uKlE5lGu1RE1yrv+u6+VBSqDlHBVtVnmplKFGyW/LrLlCD/3oLAE3Z8bwGYUppb8kx fcGnuglm0dyOw== X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com, chenhuacai@kernel.org, kernel@xen0n.name, edumazet@kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, neuromoments@gmail.com, beganovic.emir@gmail.com X-In-Reply-To: <20261114-ax88179a-v21-1-c2d34410bcbe@birger-koblitz.de> 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