Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751350AbdCPDmD (ORCPT ); Wed, 15 Mar 2017 23:42:03 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:49528 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751055AbdCPDmC (ORCPT ); Wed, 15 Mar 2017 23:42:02 -0400 Date: Thu, 16 Mar 2017 11:37:36 +0800 From: Jisheng Zhang To: Jane Li CC: , , Subject: Re: [PATCH v2] net: mvneta: support suspend and resume Message-ID: <20170316113736.68d842f3@xhacker> In-Reply-To: <1489634350-36991-1-git-send-email-jiel@marvell.com> References: <1489634350-36991-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-16_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=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703160027 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3555 Lines: 109 On Thu, 16 Mar 2017 11:19:10 +0800 Jane Li wrote: > Add basic support for handling suspend and resume. > > Signed-off-by: Jane Li > --- > Since v1: > - add mvneta_conf_mbus_windows() and mvneta_bm_port_init() in mvneta_resume() > > drivers/net/ethernet/marvell/mvneta.c | 62 ++++++++++++++++++++++++++++++++--- > 1 file changed, 58 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c > index 61dd446..250017b 100644 > --- a/drivers/net/ethernet/marvell/mvneta.c > +++ b/drivers/net/ethernet/marvell/mvneta.c > @@ -431,6 +431,7 @@ struct mvneta_port { > /* Flags for special SoC configurations */ > bool neta_armada3700; > u16 rx_offset_correction; > + const struct mbus_dram_target_info *dram_target_info; > }; > > /* The mvneta_tx_desc and mvneta_rx_desc structures describe the > @@ -4118,7 +4119,6 @@ static int mvneta_port_power_up(struct mvneta_port *pp, int phy_mode) > /* Device initialization routine */ > static int mvneta_probe(struct platform_device *pdev) > { > - const struct mbus_dram_target_info *dram_target_info; > struct resource *res; > struct device_node *dn = pdev->dev.of_node; > struct device_node *phy_node; > @@ -4267,13 +4267,13 @@ static int mvneta_probe(struct platform_device *pdev) > > pp->tx_csum_limit = tx_csum_limit; > > - dram_target_info = mv_mbus_dram_info(); > + pp->dram_target_info = mv_mbus_dram_info(); > /* Armada3700 requires setting default configuration of Mbus > * windows, however without using filled mbus_dram_target_info > * structure. > */ > - if (dram_target_info || pp->neta_armada3700) > - mvneta_conf_mbus_windows(pp, dram_target_info); > + if (pp->dram_target_info || pp->neta_armada3700) > + mvneta_conf_mbus_windows(pp, pp->dram_target_info); > > pp->tx_ring_size = MVNETA_MAX_TXD; > pp->rx_ring_size = MVNETA_MAX_RXD; > @@ -4405,6 +4405,59 @@ 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 platform_device *pdev = to_platform_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); > + if (pp->dram_target_info || pp->neta_armada3700) > + mvneta_conf_mbus_windows(pp, pp->dram_target_info); > + if (pp->bm_priv) { > + err = mvneta_bm_port_init(pdev, pp); > + if (err < 0) { > + dev_info(&pdev->dev, "use SW buffer management\n"); > + pp->bm_priv = NULL; > + } > + } > + mvneta_defaults_set(pp); > + 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) > +}; we could make use of SIMPLE_DEV_PM_OPS to simplify the code Thanks