lkml.org 
[lkml]   [2018]   [Oct]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 4/4] net: macb: Add support for suspend/resume with full power down
Date


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;
> }
>
\
 
 \ /
  Last update: 2018-10-31 17:11    [W:0.183 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site