From patchwork Wed Feb 23 08:09:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 12756555 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33F0FC433F5 for ; Wed, 23 Feb 2022 08:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238889AbiBWIJx (ORCPT ); Wed, 23 Feb 2022 03:09:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238866AbiBWIJw (ORCPT ); Wed, 23 Feb 2022 03:09:52 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFA626D961 for ; Wed, 23 Feb 2022 00:09:25 -0800 (PST) Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nMmiC-0000N4-8D; Wed, 23 Feb 2022 09:09:24 +0100 Received: from sha by dude02.hi.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1nMmiB-00FjwE-Dh; Wed, 23 Feb 2022 09:09:23 +0100 From: Sascha Hauer To: netdev@vger.kernel.org Cc: Joakim Zhang , "David S . Miller" , kernel@pengutronix.de, Ahmad Fatoum , Sascha Hauer Subject: [PATCH] net: fec: ethtool: fix unbalanced IRQ wake disable Date: Wed, 23 Feb 2022 09:09:18 +0100 Message-Id: <20220223080918.3751233-1-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ahmad Fatoum Userspace can trigger a kernel warning by using the ethtool ioctls to disable WoL, when it was not enabled before: $ ethtool -s eth0 wol d ; ethtool -s eth0 wol d Unbalanced IRQ 54 wake disable WARNING: CPU: 2 PID: 17532 at kernel/irq/manage.c:900 irq_set_irq_wake+0x108/0x148 This is because fec_enet_set_wol happily calls disable_irq_wake, even if the wake IRQ is already disabled. Looking at other drivers, like lpc_eth, suggests the way to go is to do wake IRQ enabling/disabling in the suspend/resume callbacks. Doing so avoids the warning at no loss of functionality. This only affects userspace with older ethtool versions. Newer ones use netlink and disabling before enabling will be refused before reaching the driver. Fixes: de40ed31b3c5 ("net: fec: add Wake-on-LAN support") Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- drivers/net/ethernet/freescale/fec_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 796133de527e4..44a0c89d76dd6 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -4055,6 +4055,9 @@ static int __maybe_unused fec_suspend(struct device *dev) struct net_device *ndev = dev_get_drvdata(dev); struct fec_enet_private *fep = netdev_priv(ndev); + if (device_may_wakeup(&ndev->dev) && fep->wake_irq > 0) + enable_irq_wake(fep->wake_irq); + rtnl_lock(); if (netif_running(ndev)) { if (fep->wol_flag & FEC_WOL_FLAG_ENABLE) @@ -4137,6 +4140,9 @@ static int __maybe_unused fec_resume(struct device *dev) } rtnl_unlock(); + if (device_may_wakeup(&ndev->dev) && fep->wake_irq > 0) + disable_irq_wake(fep->wake_irq); + return 0; failed_clk: