From patchwork Wed May 6 11:37:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Ferre X-Patchwork-Id: 219791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40B1FC38A2A for ; Wed, 6 May 2020 11:42:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E4D120714 for ; Wed, 6 May 2020 11:42:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="esXWWGUo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727829AbgEFLl5 (ORCPT ); Wed, 6 May 2020 07:41:57 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:2166 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726734AbgEFLl4 (ORCPT ); Wed, 6 May 2020 07:41:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1588765316; x=1620301316; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Cg4BPRaGxfrS+/zj5AePP2N7TWIwyo2J9Tr/Whwu38k=; b=esXWWGUoYXKMhvWlD6oJSVv1dqgxj56qnjLhGPPXIUEWDEIOStLAwlSx Ryq/uWSASXfBBwByVbTbzsx5SasbJ0+MvN3loguImF6bPVqBKXGhEi87l 6q0unMlMlOxkYkWl7dhs9pqvp6a12kQSaZTwW43XU+AYMjoEKpwxtbRoz oH6PRkvpbbamyTftIK04CIqiHkIZbgqUPbdqFvDXdL/qy5smPRoqah2/y wcV9LKRvpeV3xocGxHw8Gyhu/Xvy7ihwum43LLFf/nzz27hZig8/vGulm wkhHh8EHuLKqEFTl3mZIpkBX0D030rh68lDeF0sk6AAv/u6HjjNvqmQPB Q==; IronPort-SDR: knYoS5+AmJ0w/4fuKWSH/HCpZ9HI9CXeWtZXpjH4z1cXRlc9VIIGG9MlTYO84n1IKNQtIwbFSe g2gPQVNq5lBkCVVvN/4AwplWkSpO5jaUbFlGZovKwm/wksU8RiP3GQcsBmMGAuY9pc8W0Q+Rpg SKJ61T0VB6ntzXnLFUQHlrmGOr74elIPn7r7UQEIfsDLxi7MoIZ78YaLo3Ek1UofO0qnz1dwlY 7OQpAOQ4wLrinSc4+5jwTdRIguY5Ez/JMqh+BqZ4x7jgUkY9A20CILE/nIpNnyHAnurfH+O2Uz wHU= X-IronPort-AV: E=Sophos;i="5.73,358,1583218800"; d="scan'208";a="74979852" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 06 May 2020 04:41:56 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 6 May 2020 04:41:55 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Wed, 6 May 2020 04:41:51 -0700 From: To: , , "Claudiu Beznea" , CC: , "David S. Miller" , Alexandre Belloni , , , Nicolas Ferre Subject: [PATCH v4 1/5] net: macb: fix wakeup test in runtime suspend/resume routines Date: Wed, 6 May 2020 13:37:37 +0200 Message-ID: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nicolas Ferre Use the proper struct device pointer to check if the wakeup flag and wakeup source are positioned. Use the one passed by function call which is equivalent to &bp->dev->dev.parent. It's preventing the trigger of a spurious interrupt in case the Wake-on-Lan feature is used. Fixes: bc1109d04c39 ("net: macb: Add pm runtime support") Signed-off-by: Nicolas Ferre Reviewed-by: Florian Fainelli Cc: Claudiu Beznea Cc: Harini Katakam --- drivers/net/ethernet/cadence/macb_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 36290a8e2a84..d11fae37d46b 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -4616,7 +4616,7 @@ static int __maybe_unused macb_runtime_suspend(struct device *dev) struct net_device *netdev = dev_get_drvdata(dev); struct macb *bp = netdev_priv(netdev); - if (!(device_may_wakeup(&bp->dev->dev))) { + if (!(device_may_wakeup(dev))) { clk_disable_unprepare(bp->tx_clk); clk_disable_unprepare(bp->hclk); clk_disable_unprepare(bp->pclk); @@ -4632,7 +4632,7 @@ static int __maybe_unused macb_runtime_resume(struct device *dev) struct net_device *netdev = dev_get_drvdata(dev); struct macb *bp = netdev_priv(netdev); - if (!(device_may_wakeup(&bp->dev->dev))) { + if (!(device_may_wakeup(dev))) { clk_prepare_enable(bp->pclk); clk_prepare_enable(bp->hclk); clk_prepare_enable(bp->tx_clk); From patchwork Wed May 6 11:37:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Ferre X-Patchwork-Id: 219790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C18EBC38A24 for ; Wed, 6 May 2020 11:42:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A233D20714 for ; Wed, 6 May 2020 11:42:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="E3W10Kq5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727960AbgEFLmH (ORCPT ); Wed, 6 May 2020 07:42:07 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:2196 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726734AbgEFLmF (ORCPT ); Wed, 6 May 2020 07:42:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1588765325; x=1620301325; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CnDfNyn7awnGdDhHf08Ujco+xu5QtOjUT5JuHd7ht7E=; b=E3W10Kq5Lk/j08oc9ZVzGp7npGXlt+JO+x4XvLZswfl1U8Hq17Yc6Kex 10aRA18VDW1+TR5s8Oyd5nFfaCNIG91r4U/LvrmYey5Xc4/BH/wE6XlFf tivaFM/5it5dci6T8AxAtHKfDKIT4NVSoMdtClyYFUz4+uw7cmvSrjZg3 srIbA090l6wJo6a1kiK25Aao+pgCsjWu9hY9LzpYTK7vlp0/h2s6eXa4M Hj3pjlF5wttN1HCAZ/17niw7/WR/OSz8mFS0iDfcDCRO7oeeCTxC2C3uu yShKkACeZR1VHqB6mVaxfjRlCZ50rU1+QE+96oDuUs95hViUllmeQZ5Ux Q==; IronPort-SDR: cJYnnUxg+4j0D7pSV03wjwCRrbdanfXhtfur+zVNRJw5J1IzyXxNIeUaoAYmW0E5aSe2BLPdKv FkV9+rvKgCzOwUsntDv+cdVxnyYbYMHFDKu8Qy1o9nhr0SODtlPq5nqP6dtm0FS4r4eR8Kry0t bwPw5UnXX0+wHTD+3E/jZg4fRvgax+JsqU3j7IffzKUEnztQ6QQtJXIjwEBjfApjmltD5szECM 2x/QVfCkrNzBp60esJyK6GCHl3aWW20H8ZntLRlqmwwwg+5mNFpFYpUfxV3zwTrt3FzQwnmQ5j hp8= X-IronPort-AV: E=Sophos;i="5.73,358,1583218800"; d="scan'208";a="74979879" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 06 May 2020 04:42:05 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 6 May 2020 04:42:03 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Wed, 6 May 2020 04:42:00 -0700 From: To: , , "Claudiu Beznea" , CC: , "David S. Miller" , Alexandre Belloni , , , Nicolas Ferre Subject: [PATCH v4 3/5] net: macb: fix macb_get/set_wol() when moving to phylink Date: Wed, 6 May 2020 13:37:39 +0200 Message-ID: <4aeebe901fde6db70a5ca12b10e793dd2ee6ce60.1588763703.git.nicolas.ferre@microchip.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nicolas Ferre Keep previous function goals and integrate phylink actions to them. phylink_ethtool_get_wol() is not enough to figure out if Ethernet driver supports Wake-on-Lan. Initialization of "supported" and "wolopts" members is done in phylink function, no need to keep them in calling function. phylink_ethtool_set_wol() return value is not enough to determine if WoL is enabled for the calling Ethernet driver. Call it first but don't rely on its return value as most of simple PHY drivers don't implement a set_wol() function. Fixes: 7897b071ac3b ("net: macb: convert to phylink") Signed-off-by: Nicolas Ferre Reviewed-by: Florian Fainelli Cc: Claudiu Beznea Cc: Harini Katakam Cc: Antoine Tenart --- drivers/net/ethernet/cadence/macb_main.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 53e81ab048ae..24c044dc7fa0 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -2817,21 +2817,23 @@ static void macb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { struct macb *bp = netdev_priv(netdev); - wol->supported = 0; - wol->wolopts = 0; - - if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) + if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) { phylink_ethtool_get_wol(bp->phylink, wol); + wol->supported |= WAKE_MAGIC; + + if (bp->wol & MACB_WOL_ENABLED) + wol->wolopts |= WAKE_MAGIC; + } } static int macb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { struct macb *bp = netdev_priv(netdev); - int ret; - ret = phylink_ethtool_set_wol(bp->phylink, wol); - if (!ret) - return 0; + /* Pass the order to phylink layer. + * Don't test return value as set_wol() is often not supported. + */ + phylink_ethtool_set_wol(bp->phylink, wol); if (!(bp->wol & MACB_WOL_HAS_MAGIC_PACKET) || (wol->wolopts & ~WAKE_MAGIC)) From patchwork Wed May 6 11:37:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Ferre X-Patchwork-Id: 219789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28F51C38A24 for ; Wed, 6 May 2020 11:42:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0434C20752 for ; Wed, 6 May 2020 11:42:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="qfr429Yk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728038AbgEFLmS (ORCPT ); Wed, 6 May 2020 07:42:18 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:59009 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726734AbgEFLmP (ORCPT ); Wed, 6 May 2020 07:42:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1588765335; x=1620301335; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rNIeyGDtU/ObatCtRK8/2BrcAEK4nBJLJd7TnqPJUmc=; b=qfr429YkEiv0TNHeWlt6l3wCC8YSTzrVqWSj3XJeU3PG1BzHFtkpTa8P saSUJzU2Y0jNRPJdX0FUZU9+UNa9f/PcAKcGzT5E1VJ8OLOtU/WIgoNxQ VRHp6S+l3eHrBE1Gz5YhkC3U31WsAHAwcqLoydT16BYLZOf4ACNyMDOCo gEcJpdAzjKsnFTTYIZQ0stA74kbFG3H8CIdIT7LwnyzLp6b8hPob6JHRl a9/k4MEraDcOZ8YcggeHQIuqYwlYBmLZdbdAK+a+JOpcDBI2oujBdFupz DgK6Xtn4+BqsbetaFnR1agK5/8CeW/0405q3jue2WgbbNXwHeZ76A0X8T g==; IronPort-SDR: Il0T3scwtTKFf3RazNpNV6QZOoRnf34El2f2q5I7L6wzLDqMeUHQE2D7gxrYQvMiChTk8QRa/U sIqWsbdvySFQaeRX77yPbI5rq91NNWjH0Jb6pMu095vjFrpWDIDh3XChqwT7QV3r49D4iFAwHM gozXyHi64oDnaioMCZnrwEO/uaZFnaqNDe7UWakhTJMAk2iHxRy4eTTyHd2YDm0GE3JRLmCPlq 1TYUCiWOkmr9+FGtz5lV9TT6lkctr1xZ7uSZapQ7u3OdZTys8eR3cilC5ejvqCaX+9zPLZXv3a X4k= X-IronPort-AV: E=Sophos;i="5.73,358,1583218800"; d="scan'208";a="72599461" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 06 May 2020 04:42:14 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 6 May 2020 04:42:13 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Wed, 6 May 2020 04:42:09 -0700 From: To: , , "Claudiu Beznea" , CC: , "David S. Miller" , Alexandre Belloni , , , Nicolas Ferre , Sergio Prado Subject: [PATCH v4 5/5] net: macb: fix call to pm_runtime in the suspend/resume functions Date: Wed, 6 May 2020 13:37:41 +0200 Message-ID: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nicolas Ferre The calls to pm_runtime_force_suspend/resume() functions are only relevant if the device is not configured to act as a WoL wakeup source. Add the device_may_wakeup() test before calling them. Fixes: 3e2a5e153906 ("net: macb: add wake-on-lan support via magic packet") Signed-off-by: Nicolas Ferre Reviewed-by: Florian Fainelli Cc: Claudiu Beznea Cc: Harini Katakam Cc: Sergio Prado --- Changes in v3: - remove the parenthesis around device_may_wakeup() Changes in v2: - new in v2 serries drivers/net/ethernet/cadence/macb_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index ebc57cd5d286..f01b9831b219 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -4564,7 +4564,8 @@ static int __maybe_unused macb_suspend(struct device *dev) if (bp->ptp_info) bp->ptp_info->ptp_remove(netdev); - pm_runtime_force_suspend(dev); + if (!device_may_wakeup(dev)) + pm_runtime_force_suspend(dev); return 0; } @@ -4579,7 +4580,8 @@ static int __maybe_unused macb_resume(struct device *dev) if (!netif_running(netdev)) return 0; - pm_runtime_force_resume(dev); + if (!device_may_wakeup(dev)) + pm_runtime_force_resume(dev); if (bp->wol & MACB_WOL_ENABLED) { macb_writel(bp, IDR, MACB_BIT(WOL));