Article View: linux.kernel.netdev
Article #24452[PATCH net v9 4/5] net: phy: run a postponed PHY interrupt handler directly on resume
From: Igor Velkov via B4 Relay
Date: Mon, 30 Nov 2026 07:04
Date: Mon, 30 Nov 2026 07:04
140 lines
16839 bytes
16839 bytes
From: Igor Velkov <iav@iav.lv>
mdio_bus_phy_resume_irq() reruns a postponed interrupt with
irq_wake_thread(). A PHY interrupt behind a nested threaded interrupt
controller, such as an I2C or SPI GPIO expander, has no interrupt
thread, so irq_wake_thread() does nothing and the postponed interrupt
is lost: the PHY keeps its status latched and its INT line asserted.
For a PHY that the MDIO bus suspended, mdio_bus_phy_resume() calls
phy_init_hw() before the rerun, and config_intr() there acknowledges
the latched status in drivers such as realtek. A PHY that the bus did
not suspend, as with Wake-on-LAN enabled, gets no phy_init_hw() and
loses the interrupt today. A later patch brings PHYs with MAC-managed
PM under postponing, and stmmac, for one, does not call phy_init_hw()
on resume.
Call the PHY driver's handler from mdio_bus_phy_resume_irq(), as
phy_interrupt() does, but only for a PHY that has its interrupt
requested: on a shared line irq_rerun outlives phy_free_interrupt(),
and the handler would run on a PHY that no longer uses the line.
Hold irq_pm_lock across the call and around phy_disable_interrupts()
in phy_free_interrupt(), so that the free waits for the handler, as
free_irq() waits for the thread.
The interrupts flag does not tell whether the interrupt is requested:
some drivers, such as dp83867 and micrel, set it in their resume
callbacks. Add irq_requested for that; only phy_request_interrupt() and
phy_free_interrupt() write it, under irq_pm_lock held across
request_threaded_irq() and free_irq().
Fixes: 1758bde2e4aa ("net: phy: Don't trigger state machine while in suspend")
Signed-off-by: Igor Velkov <iav@iav.lv>
---
drivers/net/phy/phy.c | 8 +++++---
drivers/net/phy/phy_device.c | 13 ++++++++++---
include/linux/phy.h | 7 +++++--
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index b91723867892..6dce49f01d2b 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1488,11 +1488,13 @@ void phy_request_interrupt(struct phy_device *phydev)
mutex_lock(&phydev->irq_pm_lock);
if (phydev->irq_rerun && !irq_has_action(phydev->irq_rerun_line))
phydev->irq_rerun = false;
- mutex_unlock(&phydev->irq_pm_lock);
err = request_threaded_irq(phydev->irq, NULL, phy_interrupt,
IRQF_ONESHOT | IRQF_SHARED,
phydev_name(phydev), phydev);
+ phydev->irq_requested = !err;
+ mutex_unlock(&phydev->irq_pm_lock);
+
if (err) {
phydev_warn(phydev, "Error %d requesting IRQ %d, falling back to polling\n",
err, phydev->irq);
@@ -1516,10 +1518,10 @@ EXPORT_SYMBOL(phy_request_interrupt);
*/
void phy_free_interrupt(struct phy_device *phydev)
{
- phy_disable_interrupts(phydev);
-
mutex_lock(&phydev->irq_pm_lock);
+ phy_disable_interrupts(phydev);
free_irq(phydev->irq, phydev);
+ phydev->irq_requested = false;
/* free_irq() shuts down a line left without users and the next request
* resets its depth; mdio_bus_phy_resume_irq() enables a shared line.
*/
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 2d2058c29f30..16b398794486 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -355,12 +355,19 @@ static __maybe_unused void mdio_bus_phy_resume_irq(struct phy_device *phydev)
mutex_lock(&phydev->irq_pm_lock);
if (phy_interrupt_is_valid(phydev))
synchronize_irq(phydev->irq);
- /* The PHY may have fallen back to polling since it disabled the line */
+ /* The PHY may have fallen back to polling since it disabled the line,
+ * or freed its interrupt while another user keeps the line.
+ */
if (phydev->irq_rerun) {
phydev->irq_rerun = false;
enable_irq(phydev->irq_rerun_line);
- if (phydev->irq == phydev->irq_rerun_line)
- irq_wake_thread(phydev->irq, phydev);
+ /* A nested threaded line has no thread; we run the handler */
+ if (phydev->irq == phydev->irq_rerun_line &&
+ phydev->irq_requested) {
+ mutex_lock(&phydev->lock);
+ phydev->drv->handle_interrupt(phydev);
+ mutex_unlock(&phydev->lock);
+ }
}
mutex_unlock(&phydev->irq_pm_lock);
}
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 42004e45fb3a..23d88cfa858b 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -653,6 +653,7 @@ struct phy_oatc14_sqi_capability {
* handling shall be postponed until PHY has resumed
* @irq_rerun: Set by the postponed interrupt that disabled the line
* @irq_rerun_line: The line the postponed interrupt disabled
+ * @irq_requested: Set while the PHY has its interrupt requested
* @default_timestamp: Flag indicating whether we are using the phy
* timestamp as the default one
* @interface: enum phy_interface_t value
@@ -677,6 +678,7 @@ struct phy_oatc14_sqi_capability {
* @lock: Mutex for serialization access to PHY
* @irq_pm_lock: Held by the PM callbacks, and by the requesting and freeing
* of the interrupt where they test and clear @irq_rerun;
+ * protects @irq_requested; taken before @lock;
* phy_interrupt() never takes it
* @state_queue: Work queue for state machine
* @link_down_events: Number of times link was lost
@@ -735,6 +737,7 @@ struct phy_device {
bool irq_suspended;
bool irq_rerun;
int irq_rerun_line;
+ bool irq_requested;
unsigned default_timestamp:1;
@@ -812,8 +815,8 @@ struct phy_device {
struct delayed_work state_queue;
struct mutex lock;
- /* Held where the PM callbacks and the requesting and freeing of the
- * interrupt test and clear irq_rerun
+ /* Protects irq_requested; held where the PM callbacks and the interrupt
+ * request and free paths test and clear irq_rerun
*/
struct mutex irq_pm_lock;
--
2.43.0
Technical Details
Message-ID:
<20261130-b4-phylib-mac-pm-irq-v3-v9-4-7b9c3c9ac9f7@iav.lv>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373958-linux-kernel-netdev=dewy.ruReferences:
<20261130-b4-phylib-mac-pm-irq-v3-v9-0-7b9c3c9ac9f7@iav.lv>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373958-linux-kernel-netdev=dewy.ru From: devnull+iav.iav.lv@kernel.org (Igor Velkov via B4 Relay) Newsgroups: linux.kernel.netdev Subject: [PATCH net v9 4/5] net: phy: run a postponed PHY interrupt handler directly on resume Date: Mon, 30 Nov 2026 07:04:38 +0000 Organization: Usenet Network Message-ID: <20261130-b4-phylib-mac-pm-irq-v3-v9-4-7b9c3c9ac9f7@iav.lv> References: <20261130-b4-phylib-mac-pm-irq-v3-v9-0-7b9c3c9ac9f7@iav.lv> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1361555"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:L8DxhoCYQlzlXSwrOg/GJGOYKwY= sha256:nu87y9fLaE6KlDwfYii3+Gf7LoW/oMihMzNZ/xKK7JA= sha1:tj7R0BkarK1Kz0o+AjD3CyL59cw= sha256:wAECYeRaV49YWTN7D9cNqXSWczbk5Kj2jR3/K2fXYF4= 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 E3341125FC5; Mon, 30 Nov 2026 10:05:33 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[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 85103lTRe9f9; Mon, 30 Nov 2026 10:05:30 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373958-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 68D46125FC7; Mon, 30 Nov 2026 10:05:22 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id EDD2326D70; Mon, 30 Nov 2026 07:05:11 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796022308; b=KWPqNHfjJbaoKenWzfxnvgiyIjAzRozGt5PPxcIKwuTFczF/Npi/RCaiounWoHPVKw56 BFHNK7n1WCioKlOc1FIFxLmbm38hHlCrFanx2mpdFsYjJeDS3iFsXKiJox7GAqu65cX+i xGE5366EK4DwfRNqGzrKQ1SoHAUGe8oNa9hRQae4AbbOEJlwaLFrQzKla9FKSoN2OodgF 4qu/lFISxEBstlEitPP1DYqoPmRMYICUB3mO/eUdpBOXil86zkZwZ7/kS0jZ3yC0Dd2UN YpQqOzDXzkOa8Tnr26nB22nO5njxH4IlU5DN3lIEX7MbusWTpVEL2kTlomBqncN881Q== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796022308; h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date: Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=6qycfNdsjX4QLBwgQfMQ4alQxFVNkc/BlhUz6Alxg1k=; b=YmtL9+Ly5PdK6ubEmSjb0l4ygtHloKcq/mOmxtteF+Ce95LfyF/MJu/vPOXJfwIAGsvk riisDdF+dIXlNYVBbhhnJmDT/+3AZUqoXLpHUGlj/2e1WZnhEoLfLXWEoV7JdD/YAFeGq B+Oo9hi2Js4/mTqEx4lDYPWkLkrFicJeExyV5Pa+wC+tHiIK7DFEAumlyxp5e3dzt8dM6 05Q9TGhFhWDRj6o8AEgw6ifrxWRaQzMuIm7TKqvB5eMK66aLNr1NgQPkGbek7lLaQV53F ZTKBkB1IN75qnTjTxF48t5IqTKomEFlTdwHZhr0oEcDSpQAdHyr3oz6bgk3ShecAEQA== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eRG8VQRj; 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 A113A606A339; Mon, 30 Nov 2026 07:05:08 +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=eRG8VQRj X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796022302; b=e9L8t/AZa92dXJ5Ndx5OHNZe67WRgE8nfQqtP2ldnpXXVSZtt+yDjCjaGLEdeFhxHu/t LqtvoL5NlmrwxGbBWYqCB5FLa82PHr7bg3LFWE9vqsmaBliEuhafgSmFmJNAl2glOVX5u XupP0MhG4YBkbT6pMICE4l8PMgyIcA6B2m2qrNx8GKCggNZJbHVQQpdh8icVO4CWMxLWf /Tfb6nJZvErDywzF9E6LGkshhfvKOIDMtYd4SJ22maOeCqkeX7FUnXrDU1MpZKC0H4veN CKFnsAQAxw2NYT7pm/faX9mCsOdWXjE5FpnRu8VmyGQfqYA3SqCghlfkDJ5J/Kv8zKA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796022302; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=6qycfNdsjX4QLBwgQfMQ4alQxFVNkc/BlhUz6Alxg1k=; b=p2VLcbJLs0kIVAysO3P+p7FR3GkGuvut9b8yYakS0E3/DMBb41GlfLpRK/8UGg9i5V3F BlBgo+AlHFXT9SDytHP4Plr1nBplXgakQtA4+kuEMNW7RMdHf4aEWkGw5OfRtLfY2FpXt PzeqktkCBa5Mj5tg1TNNUmn49OTNdROUpBGAtY3YB/3dgwyvcn/KJTna8/TJzRpQRHBuZ LhPy19bVSfc8ufO7n6Y59ecMKzETuhZbAAVXqm9kRRZ88EYweoIs1gnOruzknPEVcHE0u FFGwoGDvwAz583gZ74o2NJM6i2Zgz4iHBGt31OLmSW3OkEKzBLadv7zIWuE+fR3v4Lg== 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=eRG8VQRj; arc=pass header.oldest-pass=0 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 B92D4606A329; Mon, 30 Nov 2026 07:05:02 +0000 (UTC) X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796022302; b=azXKnN3CjzGEbwuu6EWL2ZC763HVHsLRIajQk5YRAobV5TWqhQMnb9dBtjXLv2sA0mvp 5rfXSEt8wvYJ8k1oyj6Ey2MUrIsYBPN+9PMavqpNy48h5QZ3Fypqs+INdKEqHD7uyEmie /CQIruhEHwFHYUD9cQVUKupEkmXXVRUMnQ02ycXNJlNElO72+WvXMFidCHooRWR1BHB7M 2hC7KMYsPI8EL5rRiEGfxlb6XGjcOhruyRqe6neT2yMkNYdq4pW/mfG0cwhuQhVEanRNC n4Tb5QDvU9pgBkfUfW8ShONqFqzjX4hFcBpN7PZb6mv9SbNPmQbtKHmmmhuT8P32Fkg== X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796022302; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=6qycfNdsjX4QLBwgQfMQ4alQxFVNkc/BlhUz6Alxg1k=; b=DuhZKYF0PUL98yHgtEw/XeA5DyP5Dt6/7K+/POGvD7aN7orelKUr33ITkF4fPda5PESk HfdbdOlQ93p501bfnHoYhi5q9VcE9VSQ3CjB3fUIYKi8FzaNpRIU4A6le/JAMeBJ1vir+ UCoql3VDLvAclpu0XQBB2SYWiCMSJe6/5ak1H2HB9u5+AAoE0K88MwWT1KvFr6GPUuvPv rzicP4vJyBeV8nG99JLYcX6efHSGXEo9XUMuLaFVPGzsD6nLddi0xF06rTwkZzYhqBV86 wSlq0GawI3Yp/EylpcafwOxbsZImMLZf2kRx3WjYwV0A9gL1R1RG3Tzu/3GJqyc9jJA== X-ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 9F2BB1F0089A; Mon, 30 Nov 2026 07:04:45 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796022302; bh=6qycfNdsjX4QLBwgQfMQ4alQxFVNkc/BlhUz6Alxg1k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=eRG8VQRjHK3I82i7NGSPDdtNpK6R5qVYGxfey9YSmvKOvxDiOwh+CfrrS3r9ezbgJ XN5zcJFmL80UV8hluPR4qTVwQDcAW0VlCGofH0BWHpDpRu29Tw/Gfqn2OpvtsdC2zz HCCNl9rtUUkqBtCU3tbvyyTMn2tTjIKuH+o3ui7jnRsQGDC4BqpurXqUa5HWYFef9s yTucjOLeNkwuFfqMxXI0+3nFP+zKVZY3NNcruChHDqTinLmihV3D4r8oAvI1uCMdOa NAnQhvMAptSZxyBQIpRmrMchLmdl3f2PUCx/agWRjAxeAjPPmnO9rpL4FJCm6uqbEa ExJfO0CE0fzXA== X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 2C0344E741; Mon, 30 Nov 2026 07:04:45 +0000 (UTC) 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 X-In-Reply-To: <20261130-b4-phylib-mac-pm-irq-v3-v9-0-7b9c3c9ac9f7@iav.lv> X-Cc: Thomas Gleixner <tglx@kernel.org>, linux-pm@vger.kernel.org, Maxime Chevallier <maxime.chevallier@bootlin.com>, Lukas Wunner <lukas@wunner.de>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>, Wei Fang <wei.fang@nxp.com>, Niklas Söderlund <niklas.soderlund@ragnatech.se>, Paul Barker <paul@pbarker.dev>, Florian Fainelli <florian.fainelli@broadcom.com>, Doug Berger <opendmb@gmail.com>, Thangaraj Samynathan <Thangaraj.S@microchip.com>, Shenwei Wang <shenwei.wang@nxp.com>, Haoning Cheng <Haoning.CHENG@cn.bosch.com>, Willem de Bruijn <willemb@google.com>, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Igor Velkov <iav@iav.lv> X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5865; i=iav@iav.lv; h=from:subject:message-id; bh=MvhLGwGvovpP43emQOP3KZ/BIaSG3tp9dOOwD/EbBj4=; b=owGbwMvMwCVmNH1q96v4SmbG02pJDNm8ClztruJX5gkuZPlYysO97sw9l5438+UvrF/Vbn35R ufmP5vMOkpZGMS4GGTFFFkmHNK4lbHk6l9/D/MHMHNYmUCGMHBxCsBEnpUzMpxj8rY023Hi1LTq Au19s+cc0jRkkuQ7b3Rk75Ft4k02We8Y/me8eaO5zN/64XT3N2G3d78/svW+6PHOSxN6nb49UlO v/coFAA== X-Developer-Key: i=iav@iav.lv; a=openpgp; fpr=90C228DA68A4D5FD4F4837E03297958BEA5F7903 X-Endpoint-Received: by B4 Relay for iav@iav.lv/default with auth_id=1060 X-Original-From: Igor Velkov <iav@iav.lv> X-Reply-To: iav@iav.lv