From patchwork Thu Nov 29 08:06:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 152368 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2086781ljp; Thu, 29 Nov 2018 00:06:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/VD1yYr810yfV64IJ0gxKKQe/xHnYDZ5huLX0vgaciwWvlJmw+pPzLByNPr1K00Fwr3b6Jy X-Received: by 2002:a63:e001:: with SMTP id e1mr402790pgh.39.1543478809453; Thu, 29 Nov 2018 00:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543478809; cv=none; d=google.com; s=arc-20160816; b=UylPwkvFLudfrogxGyji718YmDAam9GtetVA5EqFlXK8+uYk9OJfG3wSZhz5reZ5Nv je5a+5KdY/ye+SMmCps6qk1pYjuJ/oHm84adKJFPnZneiyx5tXkvtC60oqWO8l7vjUEr qqjBdcd8nYH/T40GcKfIly25ZV6fqYSGSvqqjxMkJ1a65H26VTKoDykcWc+1+3CLYikp hxvUfhlfszzc5myfksDp9w14yBFuzCDaC6RraVHCKjoH30U+KhmFdffM31BFENF7rFJd Bnu00pg/mwsttMyY0lxKKDcu0caGdl9lY8jYRIcwgeLXnaExxnlsDPjdVYe9+7G1SSTP D/5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ob9D1j/+EVh7pN+Qds04yIdvTZNgJ08hRzgpvbm5vLU=; b=vmskbEY6kmJQ3/nFyPQ+w4H8m9ZML4CIR59EcIB0hmf2uwB2G3oQAGIEFT/lzMnVN4 z8Gv/RfUxrSXVlMykCX64GRhm/6zjL9ok2lHtRFZZK3o5+aMAng/Y3MVKYnVJ8Xx13fR vNoRw0MXEF73qqCKx7AM6dKozCQxtxI/UfAtUWJjaHfCaWvBhEB+58zAkvFVhwhqPLZi CAYROCntMXb5yFU5wFTSQYtu4sTzJ3bPAzT3pSNQJGJoZlku9De+wnR8i1+JAEfSva2G xoupirCF1zTNGmiiShWPkQ4KGrvZrcwj0kZlN73VSqWdtahKFq+6plWxe7dRha+2SKsr /jiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f65si1573192pfb.194.2018.11.29.00.06.49; Thu, 29 Nov 2018 00:06:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727602AbeK2TLR (ORCPT + 32 others); Thu, 29 Nov 2018 14:11:17 -0500 Received: from mx.socionext.com ([202.248.49.38]:4095 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbeK2TLQ (ORCPT ); Thu, 29 Nov 2018 14:11:16 -0500 Received: from unknown (HELO kinkan-ex.css.socionext.com) ([172.31.9.52]) by mx.socionext.com with ESMTP; 29 Nov 2018 17:06:45 +0900 Received: from mail.mfilter.local (m-filter-2 [10.213.24.62]) by kinkan-ex.css.socionext.com (Postfix) with ESMTP id 23488180BCB; Thu, 29 Nov 2018 17:06:45 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Thu, 29 Nov 2018 17:06:45 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id DCB0F1A03A2; Thu, 29 Nov 2018 17:06:44 +0900 (JST) From: Kunihiko Hayashi To: "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi Subject: [PATCH net-next 1/3] net: ethernet: ave: Add suspend/resume support Date: Thu, 29 Nov 2018 17:06:31 +0900 Message-Id: <1543478793-13719-2-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543478793-13719-1-git-send-email-hayashi.kunihiko@socionext.com> References: <1543478793-13719-1-git-send-email-hayashi.kunihiko@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch introduces suspend and resume functions to ave driver. Signed-off-by: Kunihiko Hayashi --- drivers/net/ethernet/socionext/sni_ave.c | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c index 6732f5c..64115b1 100644 --- a/drivers/net/ethernet/socionext/sni_ave.c +++ b/drivers/net/ethernet/socionext/sni_ave.c @@ -1734,6 +1734,49 @@ static int ave_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int ave_suspend(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct ave_private *priv = netdev_priv(ndev); + int ret = 0; + + if (netif_running(ndev)) { + ret = ave_stop(ndev); + netif_device_detach(ndev); + } + + return ret; +} + +static int ave_resume(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct ave_private *priv = netdev_priv(ndev); + int ret = 0; + + ave_global_reset(ndev); + + if (ndev->phydev) { + ret = phy_resume(ndev->phydev); + if (ret) + return ret; + } + + if (netif_running(ndev)) { + ret = ave_open(ndev); + netif_device_attach(ndev); + } + + return ret; +} + +static SIMPLE_DEV_PM_OPS(ave_pm_ops, ave_suspend, ave_resume); +#define AVE_PM_OPS (&ave_pm_ops) +#else +#define AVE_PM_OPS NULL +#endif + static int ave_pro4_get_pinmode(struct ave_private *priv, phy_interface_t phy_mode, u32 arg) { @@ -1908,6 +1951,7 @@ static struct platform_driver ave_driver = { .remove = ave_remove, .driver = { .name = "ave", + .pm = AVE_PM_OPS, .of_match_table = of_ave_match, }, }; From patchwork Thu Nov 29 08:06:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 152369 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2086787ljp; Thu, 29 Nov 2018 00:06:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/XQgm2E9huo7AB4RPZFaFBrX6Z2DvMwL7vmQQPOVi245XbT6uIRo3zvLHmKX2vACwfzG8hh X-Received: by 2002:a63:f901:: with SMTP id h1mr419099pgi.154.1543478809786; Thu, 29 Nov 2018 00:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543478809; cv=none; d=google.com; s=arc-20160816; b=n0kNUxhyadt71I2VHXImA0X+NOifD3UtnAviIDmLn27h7K3l206wAw9NGonIoGt7oH c0BvlhRBItLDRPSyjelPgPkx3cZuwv+3uA4ZCpTFVp9PEUWcINnnhS7s9ZGXX68dMmF3 jd+pcHq5++VVRCdbxhZAd8aBfQv+RvdMOWsdL/rTSoF4LPNZxorNSrj0L/rJCl5GxEwI C80+5rwE390Kf08I57VtePhVllGRc/TjmcFMNLTW9V1IkD6kDkao2W+Ff3ME90/GYp1g TuSJ+Cu+owozOZDQuMoo4mTAJGElHeKXak7F18zthxS7EjB/E0B5BYO/e7zVoc8FzwC5 Bgng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=P7MErgPO1kK6Vbfug1blnhwCr2p9n8BQHaO8/wvwEtk=; b=bbIZ6S64XXL5lAju4DlK97YCW04s2mmzDaq1z48hSPUeeLWMIDecEazhyCjpvz8wWd dUHtBEetWo9WOrNJpQ5I7Lo6zNjJUBhEBK7YOM7jr2FUxumUiE/QCuuhLUTa/kjopsxg OWpxDU2hPqNK2qf026U9EcGuHwVC3aNnyReXQqda6Dnu9swMGUxTBmmZ1L7vLSCCBIf3 en3gfUG56JaartPgbuWaZ5hjEJVmASAJ3L8l/vFmdFGzYm2jGEov8Gej8+HCLyF4UHpu lKafzVzMmuMQiNXBbP/Nrxwxr42cffcTDaqB0BG2ZtVMaIigtkvZ88TccgNH7Ds6JW/q u68w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f65si1573192pfb.194.2018.11.29.00.06.49; Thu, 29 Nov 2018 00:06:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727698AbeK2TLS (ORCPT + 32 others); Thu, 29 Nov 2018 14:11:18 -0500 Received: from mx.socionext.com ([202.248.49.38]:4099 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726587AbeK2TLR (ORCPT ); Thu, 29 Nov 2018 14:11:17 -0500 Received: from unknown (HELO kinkan-ex.css.socionext.com) ([172.31.9.52]) by mx.socionext.com with ESMTP; 29 Nov 2018 17:06:46 +0900 Received: from mail.mfilter.local (m-filter-2 [10.213.24.62]) by kinkan-ex.css.socionext.com (Postfix) with ESMTP id 2B3C3180BCB; Thu, 29 Nov 2018 17:06:46 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Thu, 29 Nov 2018 17:06:46 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id C6D111A03A2; Thu, 29 Nov 2018 17:06:45 +0900 (JST) From: Kunihiko Hayashi To: "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi Subject: [PATCH net-next 2/3] net: ethernet: ave: Set initial wol state to disabled Date: Thu, 29 Nov 2018 17:06:32 +0900 Message-Id: <1543478793-13719-3-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543478793-13719-1-git-send-email-hayashi.kunihiko@socionext.com> References: <1543478793-13719-1-git-send-email-hayashi.kunihiko@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If wol state of phy hardware is enabled after reset, phy_ethtool_get_wol() returns that wol.wolopts is true. However, since net_device.wol_enabled is zero and this doesn't apply wol state until calling ethtool_set_wol(), so mdio_bus_phy_may_suspend() returns true, that is, it's in a state where phy can suspend even though wol state is enabled. In this inconsistency, phy_suspend() returns -EBUSY, and at last, suspend sequence fails with the following message: dpm_run_callback(): mdio_bus_phy_suspend+0x0/0x58 returns -16 PM: Device 65000000.ethernet-ffffffff:01 failed to suspend: error -16 PM: Some devices failed to suspend, or early wake event detected In order to fix the above issue, this patch forces to set initial wol state to disabled as default. Signed-off-by: Kunihiko Hayashi --- drivers/net/ethernet/socionext/sni_ave.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c index 64115b1..ac96fb9 100644 --- a/drivers/net/ethernet/socionext/sni_ave.c +++ b/drivers/net/ethernet/socionext/sni_ave.c @@ -1208,9 +1208,13 @@ static int ave_init(struct net_device *ndev) priv->phydev = phydev; - phy_ethtool_get_wol(phydev, &wol); + ave_ethtool_get_wol(ndev, &wol); device_set_wakeup_capable(&ndev->dev, !!wol.supported); + /* set wol initial state disabled */ + wol.wolopts = 0; + ave_ethtool_set_wol(ndev, &wol); + if (!phy_interface_is_rgmii(phydev)) phy_set_max_speed(phydev, SPEED_100); From patchwork Thu Nov 29 08:06:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 152370 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2086836ljp; Thu, 29 Nov 2018 00:06:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/XigxFyIYb4/92P7NYlCtzgfp4ftgI2c3hl3ByyUY7DCM1Wi+DjLTPx9dD1dr0RSN20g7dJ X-Received: by 2002:a63:fe48:: with SMTP id x8mr398677pgj.261.1543478813318; Thu, 29 Nov 2018 00:06:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543478813; cv=none; d=google.com; s=arc-20160816; b=xh7sYz+MFGjeDEnYbtDK2kLU8N7b73doaLUjZXgLRK6x2Hv6noVAZa2TvuXL2C67Ex IcBJlm4xXBWkg48o0qvoo7/LvocvoZ4iCwObQMXlDBFpNeCtqekwNkAHRHAfb3u6+Gi1 hQcmirRkdwhb71hcLYq7A5cqgDmM1s6HhKnEoOLvqMKD3pLL0oSQVi8txQRmqSVathMr xTufTpTpjaOWii65UmUdwGknDEh2fb5tJl5KaIrGoN0CYCE5IVU5dRtVReBWBrFxR9Td xBzM5VDk0ERJ++fQWW7kJ+FIeNny3upKHl7+e9MCpeX1YlaLi9TntL69d+6fW+8FAfiF 4YYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=MBxYjwzV0QdBHIQV/sRW1xDtbSnDVui4puWNvX6jg/s=; b=OmBz0pxf44kthkufAv05cXt3mslFbLPKf5MoHFOjZTyHG5HNUSZXh+L8bFpjKS4iQ0 inX+dGzMgdXdlvceIm0ck6lyX0lps8znTYGHfetPGYYh9eRKzOI7f7U9/RXRm1qI0qSK caOe9EyAlsl/99fydKmRSocT/xWD6xeAnGlyiFf9evdfjaZFVtBoefUhs6oQqpw8jziB GdQclXg6Um1A8W9DvNYscEo06thRNsuxTv5WlnoINOros7gY9XqhJz2pFcIuOBzLGykS tchxJmX2D485gStHHTRTYaLtkViQPP4kXLkUEhtsYkGsUaKQNH7DXcF50P6MvpieBmrc +wUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g26si1348457pfi.184.2018.11.29.00.06.52; Thu, 29 Nov 2018 00:06:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbeK2TLT (ORCPT + 32 others); Thu, 29 Nov 2018 14:11:19 -0500 Received: from mx.socionext.com ([202.248.49.38]:4094 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbeK2TLS (ORCPT ); Thu, 29 Nov 2018 14:11:18 -0500 Received: from unknown (HELO iyokan-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 29 Nov 2018 17:06:47 +0900 Received: from mail.mfilter.local (m-filter-2 [10.213.24.62]) by iyokan-ex.css.socionext.com (Postfix) with ESMTP id 5C01060062; Thu, 29 Nov 2018 17:06:47 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Thu, 29 Nov 2018 17:06:47 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id BD2511A03A2; Thu, 29 Nov 2018 17:06:46 +0900 (JST) From: Kunihiko Hayashi To: "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi Subject: [PATCH net-next 3/3] net: ethernet: ave: Preserve wol state in suspend/resume sequence Date: Thu, 29 Nov 2018 17:06:33 +0900 Message-Id: <1543478793-13719-4-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543478793-13719-1-git-send-email-hayashi.kunihiko@socionext.com> References: <1543478793-13719-1-git-send-email-hayashi.kunihiko@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the wol state forces to be initialized after reset, the state should be preserved in suspend/resume sequence. Signed-off-by: Kunihiko Hayashi --- drivers/net/ethernet/socionext/sni_ave.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c index ac96fb9..8c1e120 100644 --- a/drivers/net/ethernet/socionext/sni_ave.c +++ b/drivers/net/ethernet/socionext/sni_ave.c @@ -261,6 +261,7 @@ struct ave_private { struct regmap *regmap; unsigned int pinmode_mask; unsigned int pinmode_val; + u32 wolopts; /* stats */ struct ave_stats stats_rx; @@ -1741,6 +1742,7 @@ static int ave_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int ave_suspend(struct device *dev) { + struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; struct net_device *ndev = dev_get_drvdata(dev); struct ave_private *priv = netdev_priv(ndev); int ret = 0; @@ -1750,17 +1752,25 @@ static int ave_suspend(struct device *dev) netif_device_detach(ndev); } + ave_ethtool_get_wol(ndev, &wol); + priv->wolopts = wol.wolopts; + return ret; } static int ave_resume(struct device *dev) { + struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; struct net_device *ndev = dev_get_drvdata(dev); struct ave_private *priv = netdev_priv(ndev); int ret = 0; ave_global_reset(ndev); + ave_ethtool_get_wol(ndev, &wol); + wol.wolopts = priv->wolopts; + ave_ethtool_set_wol(ndev, &wol); + if (ndev->phydev) { ret = phy_resume(ndev->phydev); if (ret)