LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: <Claudiu.Beznea@microchip.com>
To: <harini.katakam@xilinx.com>, <Nicolas.Ferre@microchip.com>,
	<davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<michal.simek@xilinx.com>, <harinikatakamlinux@gmail.com>,
	<appanad@xilinx.com>
Subject: Re: [PATCH 4/4] net: macb: Add support for suspend/resume with full power down
Date: Wed, 31 Oct 2018 16:10:25 +0000	[thread overview]
Message-ID: <f69c428d-565e-cf8e-de53-45850f2625cf@microchip.com> (raw)
In-Reply-To: <1540957223-30984-5-git-send-email-harini.katakam@xilinx.com>



On 31.10.2018 05:40, Harini Katakam wrote:
> When macb device is suspended and system is powered down, the clocks
> are removed and hence macb should be closed gracefully and restored
> upon resume. This patch does the same by switching off the net device,
> suspending phy and performing necessary cleanup of interrupts and BDs.
> Upon resume, all these are reinitialized again.
> 
> Reset of macb device is done only when GEM is not a wake device.
> Even when gem is a wake device, tx queues can be stopped and ptp device
> can be closed (tsu clock will be disabled in pm_runtime_suspend) as
> wake event detection has no dependency on this.
> 
> Signed-off-by: Kedareswara rao Appana <appanad@xilinx.com>
> Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
> ---
> Notes:
> I was unable to do a full macb_close/open in this patch as suggested
> because it was freeing and allocating the full RX/TX buffers and
> this time consuming, also leading to a crash when done continuously
> in stress tests. 
> 
>  drivers/net/ethernet/cadence/macb_main.c | 38 ++++++++++++++++++++++++++++++--
>  1 file changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 09cb4bb..0d1acb4 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -4247,16 +4247,33 @@ static int __maybe_unused macb_suspend(struct device *dev)
>  	struct platform_device *pdev = to_platform_device(dev);
>  	struct net_device *netdev = platform_get_drvdata(pdev);
>  	struct macb *bp = netdev_priv(netdev);
> +	struct macb_queue *queue = bp->queues;
> +	unsigned long flags;
> +	unsigned int q;
> +
> +	if (!netif_running(netdev))
> +		return 0;
>  
> -	netif_carrier_off(netdev);
> -	netif_device_detach(netdev);
>  
>  	if (bp->wol & MACB_WOL_ENABLED) {
>  		macb_writel(bp, IER, MACB_BIT(WOL));
>  		macb_writel(bp, WOL, MACB_BIT(MAG));
>  		enable_irq_wake(bp->queues[0].irq);
> +		netif_device_detach(netdev);
> +	} else {
> +		netif_device_detach(netdev);
> +		for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
> +			napi_disable(&queue->napi);
> +		phy_stop(bp->phy_dev);

Hi Harini,

I applied these patches on net-next/master cloned from [1], updated this
moment, but I don't have a phy_dev member in struct macb. Maybe you wanted
to use netdev->phydev ?

Thank you,
Claudiu Beznea

[1] https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

> +		phy_suspend(bp->phy_dev);
> +		spin_lock_irqsave(&bp->lock, flags);
> +		macb_reset_hw(bp);
> +		spin_unlock_irqrestore(&bp->lock, flags);
>  	}
>  
> +	netif_carrier_off(netdev);
> +	if (bp->ptp_info)
> +		bp->ptp_info->ptp_remove(netdev);
>  	pm_runtime_force_suspend(dev);
>  
>  	return 0;
> @@ -4267,6 +4284,11 @@ static int __maybe_unused macb_resume(struct device *dev)
>  	struct platform_device *pdev = to_platform_device(dev);
>  	struct net_device *netdev = platform_get_drvdata(pdev);
>  	struct macb *bp = netdev_priv(netdev);
> +	struct macb_queue *queue = bp->queues;
> +	unsigned int q;
> +
> +	if (!netif_running(netdev))
> +		return 0;
>  
>  	pm_runtime_force_resume(dev);
>  
> @@ -4274,9 +4296,21 @@ static int __maybe_unused macb_resume(struct device *dev)
>  		macb_writel(bp, IDR, MACB_BIT(WOL));
>  		macb_writel(bp, WOL, 0);
>  		disable_irq_wake(bp->queues[0].irq);
> +	} else {
> +		macb_writel(bp, NCR, MACB_BIT(MPE));
> +		for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
> +			napi_enable(&queue->napi);
> +		phy_resume(bp->phy_dev);
> +		phy_init_hw(bp->phy_dev);
> +		phy_start(bp->phy_dev);
>  	}
>  
> +	bp->macbgem_ops.mog_init_rings(bp);
> +	macb_init_hw(bp);
> +	macb_set_rx_mode(netdev);
>  	netif_device_attach(netdev);
> +	if (bp->ptp_info)
> +		bp->ptp_info->ptp_init(netdev);
>  
>  	return 0;
>  }
> 

  parent reply	other threads:[~2018-10-31 16:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31  3:40 [PATCH 0/4] Macb power management support for ZynqMP Harini Katakam
2018-10-31  3:40 ` [PATCH 1/4] net: macb: Check MDIO state before read/write and use timeouts Harini Katakam
2018-10-31 13:48   ` Andrew Lunn
2018-10-31 13:50     ` Harini Katakam
2018-10-31  3:40 ` [PATCH 2/4] net: macb: Support clock management for tsu_clk Harini Katakam
2018-10-31  3:40 ` [PATCH 3/4] net: macb: Add pm runtime support Harini Katakam
2018-10-31 14:54   ` Andrew Lunn
2018-10-31 15:10     ` Harini Katakam
2018-10-31 15:47       ` Andrew Lunn
2018-10-31 15:50         ` Harini Katakam
2018-10-31  3:40 ` [PATCH 4/4] net: macb: Add support for suspend/resume with full power down Harini Katakam
2018-10-31 14:58   ` Andrew Lunn
2018-10-31 15:01     ` Harini Katakam
2018-10-31 16:10   ` Claudiu.Beznea [this message]
2018-10-31 16:56     ` Harini Katakam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f69c428d-565e-cf8e-de53-45850f2625cf@microchip.com \
    --to=claudiu.beznea@microchip.com \
    --cc=Nicolas.Ferre@microchip.com \
    --cc=appanad@xilinx.com \
    --cc=davem@davemloft.net \
    --cc=harini.katakam@xilinx.com \
    --cc=harinikatakamlinux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [PATCH 4/4] net: macb: Add support for suspend/resume with full power down' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).