From patchwork Sun Nov 22 07:53:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 547290 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 758DC1402DD for ; Sun, 22 Nov 2015 18:59:25 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b=HWP2VcMx; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751405AbbKVHyw (ORCPT ); Sun, 22 Nov 2015 02:54:52 -0500 Received: from mail-lf0-f47.google.com ([209.85.215.47]:33253 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751458AbbKVHxy (ORCPT ); Sun, 22 Nov 2015 02:53:54 -0500 Received: by lfaz4 with SMTP id z4so91270634lfa.0 for ; Sat, 21 Nov 2015 23:53:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sX75iJup/9ZxFtR0bFdLLYTQYh0TJNKOnY0DeHIF5EE=; b=HWP2VcMxrh/+oZXqpdJxv1nFf+UW8K+37lrMy4GG7ZR8YZAMdP5llfTXzcD3qli5mb gLZ7uk1vjasBFyez2wcLaAItvcv5ZnLqON1xLas54zvM/mwPatVqW0zZdgSOHsin4A6c 3jR2047IywxYVFTyyEtDSZKwkKY1lyJgEJQdkRey03FaYx1pVUucrgRSdosxPgP0XgiD JArlUJAD6r7PbVT78f90QJu25sdyhoF7tgh02Mi00DywuEgvCaPDalTJSBWUiu5X4yGV M/b2FQX2/mwHESz6EHtxNrsL9okekuZeRpm95dt5ht2jBhn30lerXDtXHPWrt7lvlDQ3 tqsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sX75iJup/9ZxFtR0bFdLLYTQYh0TJNKOnY0DeHIF5EE=; b=WnP5MkKRCqNOP9+zEQWBefIptQb1YNohO7wanke1L5GmbIIqicMg4nP6hrWl1cdmFq WUKptbK1sFoMJN0Ap/prcFgYMSxfkKnM7vShPyFhs09/gEdOMZwCNME0aT+TbktkEoln DFyMr7sdlaaTx+/4RezGfERqqiP5KHrJN5/Doadmr4/kBLkLOFXam7jmPsneeUGKF6u2 H7DoadOejKPjGkDonIkeRoxh8Zcom+GLde7Rptbp5FP6YbOMi4uSauPUlONlddRQ/J1H h2sstuZqVJreCOeeohJWgljZbcrL+FYvlws3nt6fuidSxoBl83BPT07cEE/Ro634oha8 wIXA== X-Gm-Message-State: ALoCoQlhOd+BcoeOI7BIqVXaKHFTUJs2j0ZRFd1BHIEUdfbB2LOF7miVlDOkQldNG0qMbTdQHJhA X-Received: by 10.25.7.8 with SMTP id 8mr3766328lfh.111.1448178833164; Sat, 21 Nov 2015 23:53:53 -0800 (PST) Received: from enkidu.semihalf.local (cardhu.semihalf.com. [213.17.239.108]) by smtp.gmail.com with ESMTPSA id y79sm1010840lfd.45.2015.11.21.23.53.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Nov 2015 23:53:52 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Cc: davem@davemloft.net, linux@arm.linux.org.uk, sebastian.hesselbarth@gmail.com, andrew@lunn.ch, jason@lakedaemon.net, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, simon.guinot@sequanux.org, nadavh@marvell.com, alior@marvell.com, xswang@marvell.com, myair@marvell.com, nitroshift@yahoo.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com Subject: [PATCH 04/13] net: mvneta: enable suspend/resume support Date: Sun, 22 Nov 2015 08:53:50 +0100 Message-Id: <1448178839-3541-5-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1448178839-3541-1-git-send-email-mw@semihalf.com> References: <1448178839-3541-1-git-send-email-mw@semihalf.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This commit introduces suspend/resume routines used for both in 'standby' and 'mem' modes. For the latter, in which registers' contents are lost, following steps are performed: * in suspend - update port statistics and, if interface is running, detach netif, clean the queues, disable cpu notifier, shutdown interface and reset port's link status; * in resume, for all interfaces, set default configuration of the port and MBUS windows; * in resume, in case the interface is running, enable accepting packets in legacy parser, power up the port, register cpu notifier and attach netif. Signed-off-by: Marcin Wojtas --- drivers/net/ethernet/marvell/mvneta.c | 70 +++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index d12b8c6..f079b13 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -3442,6 +3442,72 @@ static int mvneta_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int mvneta_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct net_device *dev = platform_get_drvdata(pdev); + struct mvneta_port *pp = netdev_priv(dev); + + mvneta_ethtool_update_stats(pp); + + if (!netif_running(dev)) + return 0; + + netif_device_detach(dev); + + mvneta_stop_dev(pp); + unregister_cpu_notifier(&pp->cpu_notifier); + mvneta_cleanup_rxqs(pp); + mvneta_cleanup_txqs(pp); + + /* Reset link status */ + pp->link = 0; + pp->duplex = -1; + pp->speed = 0; + + return 0; +} + +static int mvneta_resume(struct platform_device *pdev) +{ + const struct mbus_dram_target_info *dram_target_info; + struct net_device *dev = platform_get_drvdata(pdev); + struct mvneta_port *pp = netdev_priv(dev); + int ret; + + mvneta_defaults_set(pp); + mvneta_port_power_up(pp, pp->phy_interface); + + dram_target_info = mv_mbus_dram_info(); + if (dram_target_info) + mvneta_conf_mbus_windows(pp, dram_target_info); + + if (!netif_running(dev)) + return 0; + + ret = mvneta_setup_rxqs(pp); + if (ret) { + netdev_err(dev, "unable to setup rxqs after resume\n"); + return ret; + } + + ret = mvneta_setup_txqs(pp); + if (ret) { + netdev_err(dev, "unable to setup txqs after resume\n"); + return ret; + } + + mvneta_set_rx_mode(dev); + mvneta_percpu_elect(pp); + register_cpu_notifier(&pp->cpu_notifier); + mvneta_start_dev(pp); + + netif_device_attach(dev); + + return 0; +} +#endif /* CONFIG_PM_SLEEP */ + static const struct of_device_id mvneta_match[] = { { .compatible = "marvell,armada-370-neta" }, { .compatible = "marvell,armada-xp-neta" }, @@ -3452,6 +3518,10 @@ MODULE_DEVICE_TABLE(of, mvneta_match); static struct platform_driver mvneta_driver = { .probe = mvneta_probe, .remove = mvneta_remove, +#ifdef CONFIG_PM_SLEEP + .suspend = mvneta_suspend, + .resume = mvneta_resume, +#endif .driver = { .name = MVNETA_DRIVER_NAME, .of_match_table = mvneta_match,