Skip to content

Commit a23aa04

Browse files
JohnsPonyPaolo Abeni
authored and
Paolo Abeni
committed
net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls
We found the following dmesg calltrace when testing the GMAC NIC notebook: [9.448656] ------------[ cut here ]------------ [9.448658] Unbalanced IRQ 43 wake disable [9.448673] WARNING: CPU: 3 PID: 1083 at kernel/irq/manage.c:688 irq_set_irq_wake+0xe0/0x128 [9.448717] CPU: 3 PID: 1083 Comm: ethtool Tainted: G O 4.19 #1 [9.448773] ... [9.448774] Call Trace: [9.448781] [<9000000000209b5c>] show_stack+0x34/0x140 [9.448788] [<9000000000d52700>] dump_stack+0x98/0xd0 [9.448794] [<9000000000228610>] __warn+0xa8/0x120 [9.448797] [<9000000000d2fb60>] report_bug+0x98/0x130 [9.448800] [<900000000020a418>] do_bp+0x248/0x2f0 [9.448805] [<90000000002035f4>] handle_bp_int+0x4c/0x78 [9.448808] [<900000000029ea40>] irq_set_irq_wake+0xe0/0x128 [9.448813] [<9000000000a96a7c>] stmmac_set_wol+0x134/0x150 [9.448819] [<9000000000be6ed0>] dev_ethtool+0x1368/0x2440 [9.448824] [<9000000000c08350>] dev_ioctl+0x1f8/0x3e0 [9.448827] [<9000000000bb2a34>] sock_ioctl+0x2a4/0x450 [9.448832] [<900000000046f044>] do_vfs_ioctl+0xa4/0x738 [9.448834] [<900000000046f778>] ksys_ioctl+0xa0/0xe8 [9.448837] [<900000000046f7d8>] sys_ioctl+0x18/0x28 [9.448840] [<9000000000211ab4>] syscall_common+0x20/0x34 [9.448842] ---[ end trace 40c18d9aec863c3e ]--- Multiple disable_irq_wake() calls will keep decreasing the IRQ wake_depth, When wake_depth is 0, calling disable_irq_wake() again, will report the above calltrace. Due to the need to appear in pairs, we cannot call disable_irq_wake() without calling enable_irq_wake(). Fix this by making sure there are no unbalanced disable_irq_wake() calls. Fixes: 3172d3a ("stmmac: support wake up irq from external sources (v3)") Signed-off-by: Qiang Ma <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 915805b commit a23aa04

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ struct stmmac_priv {
267267
u32 msg_enable;
268268
int wolopts;
269269
int wol_irq;
270+
bool wol_irq_disabled;
270271
int clk_csr;
271272
struct timer_list eee_ctrl_timer;
272273
int lpi_irq;

drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,10 +832,16 @@ static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
832832
if (wol->wolopts) {
833833
pr_info("stmmac: wakeup enable\n");
834834
device_set_wakeup_enable(priv->device, 1);
835-
enable_irq_wake(priv->wol_irq);
835+
/* Avoid unbalanced enable_irq_wake calls */
836+
if (priv->wol_irq_disabled)
837+
enable_irq_wake(priv->wol_irq);
838+
priv->wol_irq_disabled = false;
836839
} else {
837840
device_set_wakeup_enable(priv->device, 0);
838-
disable_irq_wake(priv->wol_irq);
841+
/* Avoid unbalanced disable_irq_wake calls */
842+
if (!priv->wol_irq_disabled)
843+
disable_irq_wake(priv->wol_irq);
844+
priv->wol_irq_disabled = true;
839845
}
840846

841847
mutex_lock(&priv->lock);

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3628,6 +3628,7 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
36283628
/* Request the Wake IRQ in case of another line
36293629
* is used for WoL
36303630
*/
3631+
priv->wol_irq_disabled = true;
36313632
if (priv->wol_irq > 0 && priv->wol_irq != dev->irq) {
36323633
int_name = priv->int_name_wol;
36333634
sprintf(int_name, "%s:%s", dev->name, "wol");

0 commit comments

Comments
 (0)