]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: stmmac: use core wake IRQ support
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Fri, 15 Aug 2025 11:32:10 +0000 (12:32 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 19 Aug 2025 01:10:12 +0000 (18:10 -0700)
The PM core provides management of wake IRQs along side setting the
device wake enable state. In order to use this, we need to register
the interrupt used to wakeup the system using devm_pm_set_wake_irq()
or dev_pm_set_wake_irq(). The core will then enable or disable IRQ
wake state on this interrupt as appropriate, depending on the
device_set_wakeup_enable() state. device_set_wakeup_enable() does not
care about having balanced enable/disable calls.

Make use of this functionality, rather than explicitly managing the
IRQ enable state in the set_wol() ethtool op. This removes the IRQ
wake state management from stmmac.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/E1umsfK-008vKj-Pw@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac.h
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index bf95f03dd33f5b8fc74a234afb672e8a3369f603..b16b8aeeb58366dff68b376d1812f7bc6681ad85 100644 (file)
@@ -289,7 +289,6 @@ struct stmmac_priv {
        u32 msg_enable;
        int wolopts;
        int wol_irq;
-       bool wol_irq_disabled;
        int clk_csr;
        struct timer_list eee_ctrl_timer;
        int lpi_irq;
index 58542b72cc0152cf1afacee2896365c5b85df500..39fa1ec92f82f911c1d7cd720b914383446a1391 100644 (file)
@@ -815,19 +815,7 @@ static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
                return ret;
        }
 
-       if (wol->wolopts) {
-               device_set_wakeup_enable(priv->device, 1);
-               /* Avoid unbalanced enable_irq_wake calls */
-               if (priv->wol_irq_disabled)
-                       enable_irq_wake(priv->wol_irq);
-               priv->wol_irq_disabled = false;
-       } else {
-               device_set_wakeup_enable(priv->device, 0);
-               /* Avoid unbalanced disable_irq_wake calls */
-               if (!priv->wol_irq_disabled)
-                       disable_irq_wake(priv->wol_irq);
-               priv->wol_irq_disabled = true;
-       }
+       device_set_wakeup_enable(priv->device, !!wol->wolopts);
 
        mutex_lock(&priv->lock);
        priv->wolopts = wol->wolopts;
index cff75367311e617f1bf046f5fdd95765c12a9216..db0433d0ce401845ecefbc7dc19a993bb6027ca1 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/prefetch.h>
 #include <linux/pinctrl/consumer.h>
 #ifdef CONFIG_DEBUG_FS
@@ -3724,7 +3725,6 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
        /* Request the Wake IRQ in case of another line
         * is used for WoL
         */
-       priv->wol_irq_disabled = true;
        if (priv->wol_irq > 0 && priv->wol_irq != dev->irq) {
                int_name = priv->int_name_wol;
                sprintf(int_name, "%s:%s", dev->name, "wol");
@@ -3885,7 +3885,6 @@ static int stmmac_request_irq_single(struct net_device *dev)
        /* Request the Wake IRQ in case of another line
         * is used for WoL
         */
-       priv->wol_irq_disabled = true;
        if (priv->wol_irq > 0 && priv->wol_irq != dev->irq) {
                ret = request_irq(priv->wol_irq, stmmac_interrupt,
                                  IRQF_SHARED, dev->name, dev);
@@ -7277,6 +7276,7 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
        if (priv->plat->pmt) {
                dev_info(priv->device, "Wake-Up On Lan supported\n");
                device_set_wakeup_capable(priv->device, 1);
+               devm_pm_set_wake_irq(priv->device, priv->wol_irq);
        }
 
        if (priv->dma_cap.tsoen)