Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp531785rdb; Tue, 16 Jan 2024 07:52:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfIhB2nYmtoTbIkzDMvkdXVgJng7+ytERt1qFXn90lr7FEHpKZd/6OSPmhCz9WFwSa1E3k X-Received: by 2002:a05:6a21:188:b0:199:9542:3e06 with SMTP id le8-20020a056a21018800b0019995423e06mr3997237pzb.109.1705420373275; Tue, 16 Jan 2024 07:52:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705420373; cv=none; d=google.com; s=arc-20160816; b=q1fA+S2mwbKKfKCDqVVAxXl7y9rzkL4104YNDuYwGFi5WUMxEprT3ej3cYYMNJ7LU2 uFdbSeR5n0FPyq5+7YFF+/UlOTXxxQG0q4IUgb0jQWG0fb4YtAHFVZYj8QktzQvCjh69 7BXPBp8CJ4i04fiisWJ0/dURv6CffYXK8HiVJkoekCRR7pOOkavewD+EgToCxNZniYWg QCrMCoLuDSKZOiDmyDn3GL+sHRXfBw9eXw9X/woadEFnpDpvojLU3nEAKQd1dkUovlVw GryZnvk99dynK4QSZejvxRhxP3q4pjVyCJU6HmnZ4xTmTQWCGCFJm6dhdOV1kDlPbZQU AWtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=V+9qO6GTu5GzFzd8upGXWknyAYPEv0bjopJXo1SZMVk=; fh=6FdS3W70/1YFqmUmvOTaD/swwQIXuQLGRpsX0Lk0P68=; b=V2VuJyd3j1yNqbPz3zcpY1DRpAq5HO4HQyPggCoVMk3dEcFvb/dWRr5Jv3QaiSq19j SfgbyInPWvfK/shm3a/JU5gvyHW+eg8mn1Jw+vibtVVeX1KkUlYJ4tvZKtRjfgozg7fZ bGgWX2XQUifcj+p827BVJ1qbL/ysgnSsRAH+fmI4w06HQ1EswCDb6VZb1o3T/SQyBJzH 46Wq8+sFhc6nNKgXp5WjYxce18AC1t/urtUqrwY2pvt4dW6YgnNonR1ERbNLVRzE2XsT PKQgTA3xmiksSTcmEI8F9eZpIEDtnukaa5a2dCIT07Pnpcux3YgVtZy4K+cuyTRNVJnE M0fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hnzk7Flw; spf=pass (google.com: domain of linux-kernel+bounces-27543-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27543-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id lw9-20020a17090b180900b0028e89a05c4fsi665943pjb.163.2024.01.16.07.52.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 07:52:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27543-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hnzk7Flw; spf=pass (google.com: domain of linux-kernel+bounces-27543-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27543-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EB98B283EED for ; Tue, 16 Jan 2024 15:52:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58BFE1C69E; Tue, 16 Jan 2024 15:52:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Hnzk7Flw" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 782B21C687; Tue, 16 Jan 2024 15:52:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 896D0C433C7; Tue, 16 Jan 2024 15:52:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705420363; bh=WA+DndfELZlI9Jy+t+vI+2scK3h8QnZ8iilcAX3rtic=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Hnzk7Flw7UjtpN06RU4Q6p2dyS4lVjYLsHvF4Mf0M+XAJCDwx5K0wKu01pets7K+X eILdnFfdIQhMyk4Sr5qSGJttNqab3rwO1f+9WYI4K63yoQajM8j9HV6G1TAulftBni PMVFhsAp/JoXEmpAtcw3HihvfAJQXJJkDf2+YnqlnTsHHG4/N5ImsmVWss/0pwZU6H YfQtNA/eDjWW5D8mcAm/vXi9G/hj9AN98xUusLI0wsvVleBM/oGSAmLN/9BagKmimP 4r6k9TOPAEMddQzwCjCvgBWIC9tXeDTM0O2VmN8ukbhkpovyJ3KfXQ2wzcW1A5c1Ex /iP8VJ9wBJUaQ== Date: Tue, 16 Jan 2024 15:52:37 +0000 From: Simon Horman To: Qiang Ma Cc: alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, Florian Fainelli , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: stmmac: ethtool: Fixed calltrace caused by unbalanced disable_irq_wake calls Message-ID: <20240116155237.GA588419@kernel.org> References: <20240112021249.24598-1-maqianga@uniontech.com> <20240115134238.GA430968@kernel.org> <8553142D466DD03F+20240116135734.53fb4c6e@john-PC> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8553142D466DD03F+20240116135734.53fb4c6e@john-PC> On Tue, Jan 16, 2024 at 01:57:34PM +0800, Qiang Ma wrote: > On Mon, 15 Jan 2024 13:42:38 +0000 > Simon Horman wrote: > > > + Florian Fainelli > > > > 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 > > > > 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 > > > > [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 Date: Fri Oct 10 10:51:54 > 2014 -0700 > > net: systemport: avoid unbalanced enable_irq_wake calls > > commit 083731a8fbe71d83fc908adf137dc98ee352f280 > Author: Florian Fainelli > 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.