linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls
@ 2024-01-12  2:12 Qiang Ma
  2024-01-15 13:42 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Qiang Ma @ 2024-01-12  2:12 UTC (permalink / raw)
  To: alexandre.torgue, joabreu, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Qiang Ma

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.

Signed-off-by: Qiang Ma <maqianga@uniontech.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h         |  1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 10 ++++++++--
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |  1 +
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index cd7a9768de5f..b8c93b881a65 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -255,6 +255,7 @@ 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;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index f628411ae4ae..9a4d9492a781 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -825,10 +825,16 @@ static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 	if (wol->wolopts) {
 		pr_info("stmmac: wakeup enable\n");
 		device_set_wakeup_enable(priv->device, 1);
-		enable_irq_wake(priv->wol_irq);
+		/* 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);
-		disable_irq_wake(priv->wol_irq);
+		/* Avoid unbalanced disable_irq_wake calls */
+		if (!priv->wol_irq_disabled)
+			disable_irq_wake(priv->wol_irq);
+		priv->wol_irq_disabled = true;
 	}
 
 	mutex_lock(&priv->lock);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 37e64283f910..baa396621ed8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3565,6 +3565,7 @@ 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");
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls
  2024-01-12  2:12 [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls Qiang Ma
@ 2024-01-15 13:42 ` Simon Horman
  2024-01-16  5:57   ` Qiang Ma
  2024-01-16  9:00 ` patchwork-bot+netdevbpf
  2024-01-16 22:27 ` Andrew Lunn
  2 siblings, 1 reply; 7+ messages in thread
From: Simon Horman @ 2024-01-15 13:42 UTC (permalink / raw)
  To: Qiang Ma
  Cc: alexandre.torgue, joabreu, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel, Florian Fainelli

+ Florian Fainelli <f.fainelli@gmail.com>

On Fri, Jan 12, 2024 at 10:12:49AM +0800, Qiang Ma wrote:
> 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.


Hi Qiang Ma,

This seems to be a fix, so I think it should be targeted at net:

	Subject: [PATCH net] ...

And have a fixes tag, perhaps:

	Fixes: 3172d3afa998 ("stmmac: support wake up irq from external sources (v3)")

I don't think there is a need to repost this patch because of the above,
but please keep it in mind for next time.

> Signed-off-by: Qiang Ma <maqianga@uniontech.com>

I see that the approach taken here is the same as that taken
by bcm_sysport_set_wol() to what seems to be a similar problem [1].
So the code change itself looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

[1] 61b423a8a0bd ("net: systemport: avoid unbalanced enable_irq_wake calls")
    https://git.kernel.org/torvalds/c/61b423a8a0bd

> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac.h         |  1 +
>  drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 10 ++++++++--
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |  1 +
>  3 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> index cd7a9768de5f..b8c93b881a65 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> @@ -255,6 +255,7 @@ 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;
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> index f628411ae4ae..9a4d9492a781 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> @@ -825,10 +825,16 @@ static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
>  	if (wol->wolopts) {
>  		pr_info("stmmac: wakeup enable\n");
>  		device_set_wakeup_enable(priv->device, 1);
> -		enable_irq_wake(priv->wol_irq);
> +		/* 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);
> -		disable_irq_wake(priv->wol_irq);
> +		/* Avoid unbalanced disable_irq_wake calls */
> +		if (!priv->wol_irq_disabled)
> +			disable_irq_wake(priv->wol_irq);
> +		priv->wol_irq_disabled = true;
>  	}
>  
>  	mutex_lock(&priv->lock);
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 37e64283f910..baa396621ed8 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3565,6 +3565,7 @@ 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");
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls
  2024-01-15 13:42 ` Simon Horman
@ 2024-01-16  5:57   ` Qiang Ma
  2024-01-16 15:52     ` Simon Horman
  0 siblings, 1 reply; 7+ messages in thread
From: Qiang Ma @ 2024-01-16  5:57 UTC (permalink / raw)
  To: Simon Horman, alexandre.torgue, joabreu, davem, edumazet, kuba,
	pabeni, mcoquelin.stm32, Florian Fainelli
  Cc: netdev, linux-arm-kernel, linux-kernel

On Mon, 15 Jan 2024 13:42:38 +0000
Simon Horman <horms@kernel.org> wrote:

> + Florian Fainelli <f.fainelli@gmail.com>
> 
> On Fri, Jan 12, 2024 at 10:12:49AM +0800, Qiang Ma wrote:
> > 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.  
> 
> 
> Hi Qiang Ma,
> 
> This seems to be a fix, so I think it should be targeted at net:
> 
> 	Subject: [PATCH net] ...
> 
> And have a fixes tag, perhaps:
> 
> 	Fixes: 3172d3afa998 ("stmmac: support wake up irq from
> external sources (v3)")
> 
> I don't think there is a need to repost this patch because of the
> above, but please keep it in mind for next time.
> 
> > Signed-off-by: Qiang Ma <maqianga@uniontech.com>  
> 
> I see that the approach taken here is the same as that taken
> by bcm_sysport_set_wol() to what seems to be a similar problem [1].
> So the code change itself looks good to me.
> 
> Reviewed-by: Simon Horman <horms@kernel.org>
> 
> [1] 61b423a8a0bd ("net: systemport: avoid unbalanced enable_irq_wake
> calls") https://git.kernel.org/torvalds/c/61b423a8a0bd
> 
> > ---
> >  drivers/net/ethernet/stmicro/stmmac/stmmac.h         |  1 +
> >  drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 10
> > ++++++++-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |
> > 1 + 3 files changed, 10 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> > b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index
> > cd7a9768de5f..b8c93b881a65 100644 ---
> > a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++
> > b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -255,6 +255,7 @@
> > 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;
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> > b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index
> > f628411ae4ae..9a4d9492a781 100644 ---
> > a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++
> > b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -825,10
> > +825,16 @@ static int stmmac_set_wol(struct net_device *dev, struct
> > ethtool_wolinfo *wol) if (wol->wolopts) { pr_info("stmmac: wakeup
> > enable\n"); device_set_wakeup_enable(priv->device, 1);
> > -		enable_irq_wake(priv->wol_irq);
> > +		/* 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);
> > -		disable_irq_wake(priv->wol_irq);
> > +		/* Avoid unbalanced disable_irq_wake calls */
> > +		if (!priv->wol_irq_disabled)
> > +			disable_irq_wake(priv->wol_irq);
> > +		priv->wol_irq_disabled = true;
> >  	}
> >  
> >  	mutex_lock(&priv->lock);
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index
> > 37e64283f910..baa396621ed8 100644 ---
> > a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++
> > b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3565,6
> > +3565,7 @@ 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");
> > -- 
> > 2.20.1
> >   
> 

Hi Simon Horman,

The latest code does not seem to see the stmmac driver to avoid
irq_wake call related fix committed, this fix is mainly for stmmac,
refer to the commit:

commit 61b423a8a0bd9aeaa046f9a24bed42e3a953a936 Author:
Florian Fainelli <f.fainelli@gmail.com> Date:   Fri Oct 10 10:51:54
2014 -0700

    net: systemport: avoid unbalanced enable_irq_wake calls

commit 083731a8fbe71d83fc908adf137dc98ee352f280
Author: Florian Fainelli <f.fainelli@gmail.com>
Date:   Fri Oct 10 10:51:53 2014 -0700

    net: bcmgenet: avoid unbalanced enable_irq_wake calls

Therefore, I think this submission is necessary at this time.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls
  2024-01-12  2:12 [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls Qiang Ma
  2024-01-15 13:42 ` Simon Horman
@ 2024-01-16  9:00 ` patchwork-bot+netdevbpf
  2024-01-16 22:27 ` Andrew Lunn
  2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-01-16  9:00 UTC (permalink / raw)
  To: Qiang Ma
  Cc: alexandre.torgue, joabreu, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Fri, 12 Jan 2024 10:12:49 +0800 you wrote:
> 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 ]---
> 
> [...]

Here is the summary with links:
  - net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls
    https://git.kernel.org/netdev/net/c/a23aa0404218

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls
  2024-01-16  5:57   ` Qiang Ma
@ 2024-01-16 15:52     ` Simon Horman
  0 siblings, 0 replies; 7+ messages in thread
From: Simon Horman @ 2024-01-16 15:52 UTC (permalink / raw)
  To: Qiang Ma
  Cc: alexandre.torgue, joabreu, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, Florian Fainelli, netdev, linux-arm-kernel,
	linux-kernel

On Tue, Jan 16, 2024 at 01:57:34PM +0800, Qiang Ma wrote:
> On Mon, 15 Jan 2024 13:42:38 +0000
> Simon Horman <horms@kernel.org> wrote:
> 
> > + Florian Fainelli <f.fainelli@gmail.com>
> > 
> > On Fri, Jan 12, 2024 at 10:12:49AM +0800, Qiang Ma wrote:
> > > 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.  
> > 
> > 
> > Hi Qiang Ma,
> > 
> > This seems to be a fix, so I think it should be targeted at net:
> > 
> > 	Subject: [PATCH net] ...
> > 
> > And have a fixes tag, perhaps:
> > 
> > 	Fixes: 3172d3afa998 ("stmmac: support wake up irq from
> > external sources (v3)")
> > 
> > I don't think there is a need to repost this patch because of the
> > above, but please keep it in mind for next time.
> > 
> > > Signed-off-by: Qiang Ma <maqianga@uniontech.com>  
> > 
> > I see that the approach taken here is the same as that taken
> > by bcm_sysport_set_wol() to what seems to be a similar problem [1].
> > So the code change itself looks good to me.
> > 
> > Reviewed-by: Simon Horman <horms@kernel.org>
> > 
> > [1] 61b423a8a0bd ("net: systemport: avoid unbalanced enable_irq_wake
> > calls") https://git.kernel.org/torvalds/c/61b423a8a0bd
> > 
> > > ---
> > >  drivers/net/ethernet/stmicro/stmmac/stmmac.h         |  1 +
> > >  drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 10
> > > ++++++++-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |
> > > 1 + 3 files changed, 10 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> > > b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index
> > > cd7a9768de5f..b8c93b881a65 100644 ---
> > > a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++
> > > b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -255,6 +255,7 @@
> > > 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;
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> > > b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index
> > > f628411ae4ae..9a4d9492a781 100644 ---
> > > a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++
> > > b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -825,10
> > > +825,16 @@ static int stmmac_set_wol(struct net_device *dev, struct
> > > ethtool_wolinfo *wol) if (wol->wolopts) { pr_info("stmmac: wakeup
> > > enable\n"); device_set_wakeup_enable(priv->device, 1);
> > > -		enable_irq_wake(priv->wol_irq);
> > > +		/* 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);
> > > -		disable_irq_wake(priv->wol_irq);
> > > +		/* Avoid unbalanced disable_irq_wake calls */
> > > +		if (!priv->wol_irq_disabled)
> > > +			disable_irq_wake(priv->wol_irq);
> > > +		priv->wol_irq_disabled = true;
> > >  	}
> > >  
> > >  	mutex_lock(&priv->lock);
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > > b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index
> > > 37e64283f910..baa396621ed8 100644 ---
> > > a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++
> > > b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3565,6
> > > +3565,7 @@ 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");
> > > -- 
> > > 2.20.1
> > >   
> > 
> 
> Hi Simon Horman,
> 
> The latest code does not seem to see the stmmac driver to avoid
> irq_wake call related fix committed, this fix is mainly for stmmac,
> refer to the commit:
> 
> commit 61b423a8a0bd9aeaa046f9a24bed42e3a953a936 Author:
> Florian Fainelli <f.fainelli@gmail.com> Date:   Fri Oct 10 10:51:54
> 2014 -0700
> 
>     net: systemport: avoid unbalanced enable_irq_wake calls
> 
> commit 083731a8fbe71d83fc908adf137dc98ee352f280
> Author: Florian Fainelli <f.fainelli@gmail.com>
> Date:   Fri Oct 10 10:51:53 2014 -0700
> 
>     net: bcmgenet: avoid unbalanced enable_irq_wake calls
> 
> Therefore, I think this submission is necessary at this time.

Yes, I agree.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls
  2024-01-12  2:12 [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls Qiang Ma
  2024-01-15 13:42 ` Simon Horman
  2024-01-16  9:00 ` patchwork-bot+netdevbpf
@ 2024-01-16 22:27 ` Andrew Lunn
  2024-01-17  7:17   ` Qiang Ma
  2 siblings, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2024-01-16 22:27 UTC (permalink / raw)
  To: Qiang Ma
  Cc: alexandre.torgue, joabreu, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel

On Fri, Jan 12, 2024 at 10:12:49AM +0800, Qiang Ma wrote:
> 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.

Just for my understanding. You trigger this by doing lots of

ethtool -s eth42 wol g

or similar without doing a matching

ethtool -s eth42 wol d

to disable wol?

Its a bit late now, but its good to give instructions how to reproduce
the issue in the commit message.

    Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls
  2024-01-16 22:27 ` Andrew Lunn
@ 2024-01-17  7:17   ` Qiang Ma
  0 siblings, 0 replies; 7+ messages in thread
From: Qiang Ma @ 2024-01-17  7:17 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: alexandre.torgue, joabreu, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel

On Tue, 16 Jan 2024 23:27:39 +0100
Andrew Lunn <andrew@lunn.ch> wrote:

> On Fri, Jan 12, 2024 at 10:12:49AM +0800, Qiang Ma wrote:
> > 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.  
> 
> Just for my understanding. You trigger this by doing lots of
> 
> ethtool -s eth42 wol g
> 
> or similar without doing a matching
> 
> ethtool -s eth42 wol d
> 
> to disable wol?
> 
> Its a bit late now, but its good to give instructions how to reproduce
> the issue in the commit message.
> 
>     Andrew
> 

yes, my environment has not call enable_irq_wake(), so calling
disable_irq_wake() directly through the "ethtool -s ethxx wol d"
command will cause this problem.

    Qiang Ma


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-01-17  7:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-12  2:12 [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls Qiang Ma
2024-01-15 13:42 ` Simon Horman
2024-01-16  5:57   ` Qiang Ma
2024-01-16 15:52     ` Simon Horman
2024-01-16  9:00 ` patchwork-bot+netdevbpf
2024-01-16 22:27 ` Andrew Lunn
2024-01-17  7:17   ` Qiang Ma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).