Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752588AbdCOHX2 (ORCPT ); Wed, 15 Mar 2017 03:23:28 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:39280 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751642AbdCOHX0 (ORCPT ); Wed, 15 Mar 2017 03:23:26 -0400 Date: Wed, 15 Mar 2017 15:18:43 +0800 From: Jisheng Zhang To: Jane Li CC: , , Subject: Re: [PATCH] net: mvneta: support suspend and resume Message-ID: <20170315151843.258f214f@xhacker> In-Reply-To: <1489561714-2368-1-git-send-email-jiel@marvell.com> References: <1489561714-2368-1-git-send-email-jiel@marvell.com> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-15_02:,, signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703150057 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2321 Lines: 84 Hi Jane, On Wed, 15 Mar 2017 15:08:34 +0800 Jane Li wrote: > Add basic support for handling suspend and resume. > > Signed-off-by: Jane Li > --- > drivers/net/ethernet/marvell/mvneta.c | 44 +++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c > index 61dd446..4f16342 100644 > --- a/drivers/net/ethernet/marvell/mvneta.c > +++ b/drivers/net/ethernet/marvell/mvneta.c > @@ -4405,6 +4405,49 @@ static int mvneta_remove(struct platform_device *pdev) > return 0; > } > > +#ifdef CONFIG_PM_SLEEP > +static int mvneta_suspend(struct device *device) > +{ > + struct net_device *dev = dev_get_drvdata(device); > + struct mvneta_port *pp = netdev_priv(dev); > + > + if (netif_running(dev)) > + mvneta_stop(dev); > + netif_device_detach(dev); > + clk_disable_unprepare(pp->clk_bus); > + clk_disable_unprepare(pp->clk); > + return 0; > +} > + > +static int mvneta_resume(struct device *device) > +{ > + struct net_device *dev = dev_get_drvdata(device); > + struct mvneta_port *pp = netdev_priv(dev); > + int err; > + > + clk_prepare_enable(pp->clk); > + clk_prepare_enable(pp->clk_bus); we may miss the necessary registers setting in mvneta_bm_port_init() and mvneta_conf_mbus_windows(). those registers also need to be restored. > + mvneta_defaults_set(pp); before restore the default setting, is it safer to mvneta_port_disable()? Thanks, Jisheng > + err = mvneta_port_power_up(pp, pp->phy_interface); > + if (err < 0) { > + dev_err(device, "can't power up port\n"); > + return err; > + } > + > + if (pp->use_inband_status) > + mvneta_fixed_link_update(pp, dev->phydev); > + > + netif_device_attach(dev); > + if (netif_running(dev)) > + mvneta_open(dev); > + return 0; > +} > +#endif > + > +static const struct dev_pm_ops mvneta_pm_ops = { > + SET_LATE_SYSTEM_SLEEP_PM_OPS(mvneta_suspend, mvneta_resume) > +}; > + > static const struct of_device_id mvneta_match[] = { > { .compatible = "marvell,armada-370-neta" }, > { .compatible = "marvell,armada-xp-neta" }, > @@ -4419,6 +4462,7 @@ static int mvneta_remove(struct platform_device *pdev) > .driver = { > .name = MVNETA_DRIVER_NAME, > .of_match_table = mvneta_match, > + .pm = &mvneta_pm_ops, > }, > }; >