Skip to content

Commit f9f41e3

Browse files
committed
Merge branch 'macb-WOL-fixes'
Nicolas Ferre says: ==================== net: macb: Wake-on-Lan magic packet fixes and GEM handling Here is a split series to fix WoL magic-packet on the current macb driver. Only fixes in this one based on current net/master. Changes in v5: - Addressed the error code returned by phylink_ethtool_set_wol() as suggested by Russell. If PHY handles WoL, MAC doesn't stay in the way. - Removed Florian's tag on 3/5 because of the above changes. - Correct the "Fixes" tag on 1/5. Changes in v4: - Pure bug fix series for 'net'. GEM addition and MACB update removed: will be sent later. Changes in v3: - Revert some of the v2 changes done in macb_resume(). Now the resume function supports in-depth re-configuration of the controller in order to deal with deeper sleep states. Basically as it was before changes introduced by this series - Tested for non-regression with our deeper Power Management mode which cuts power to the controller completely Changes in v2: - Add patch 4/7 ("net: macb: fix macb_suspend() by removing call to netif_carrier_off()") needed for keeping phy state consistent - Add patch 5/7 ("net: macb: fix call to pm_runtime in the suspend/resume functions") that prevent putting the macb in runtime pm suspend mode when WoL is used - Collect review tags on 3 first patches from Florian: Thanks! - Review of macb_resume() function - Addition of pm_wakeup_event() in both MACB and GEM WoL IRQ handlers ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents c8b1d74 + 6c8f85c commit f9f41e3

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,21 +2821,27 @@ static void macb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
28212821
{
28222822
struct macb *bp = netdev_priv(netdev);
28232823

2824-
wol->supported = 0;
2825-
wol->wolopts = 0;
2826-
2827-
if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET)
2824+
if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) {
28282825
phylink_ethtool_get_wol(bp->phylink, wol);
2826+
wol->supported |= WAKE_MAGIC;
2827+
2828+
if (bp->wol & MACB_WOL_ENABLED)
2829+
wol->wolopts |= WAKE_MAGIC;
2830+
}
28292831
}
28302832

28312833
static int macb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
28322834
{
28332835
struct macb *bp = netdev_priv(netdev);
28342836
int ret;
28352837

2838+
/* Pass the order to phylink layer */
28362839
ret = phylink_ethtool_set_wol(bp->phylink, wol);
2837-
if (!ret)
2838-
return 0;
2840+
/* Don't manage WoL on MAC if handled by the PHY
2841+
* or if there's a failure in talking to the PHY
2842+
*/
2843+
if (!ret || ret != -EOPNOTSUPP)
2844+
return ret;
28392845

28402846
if (!(bp->wol & MACB_WOL_HAS_MAGIC_PACKET) ||
28412847
(wol->wolopts & ~WAKE_MAGIC))
@@ -4422,7 +4428,7 @@ static int macb_probe(struct platform_device *pdev)
44224428
bp->wol = 0;
44234429
if (of_get_property(np, "magic-packet", NULL))
44244430
bp->wol |= MACB_WOL_HAS_MAGIC_PACKET;
4425-
device_init_wakeup(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET);
4431+
device_set_wakeup_capable(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET);
44264432

44274433
spin_lock_init(&bp->lock);
44284434

@@ -4598,10 +4604,10 @@ static int __maybe_unused macb_suspend(struct device *dev)
45984604
bp->pm_data.scrt2 = gem_readl_n(bp, ETHT, SCRT2_ETHT);
45994605
}
46004606

4601-
netif_carrier_off(netdev);
46024607
if (bp->ptp_info)
46034608
bp->ptp_info->ptp_remove(netdev);
4604-
pm_runtime_force_suspend(dev);
4609+
if (!device_may_wakeup(dev))
4610+
pm_runtime_force_suspend(dev);
46054611

46064612
return 0;
46074613
}
@@ -4616,7 +4622,8 @@ static int __maybe_unused macb_resume(struct device *dev)
46164622
if (!netif_running(netdev))
46174623
return 0;
46184624

4619-
pm_runtime_force_resume(dev);
4625+
if (!device_may_wakeup(dev))
4626+
pm_runtime_force_resume(dev);
46204627

46214628
if (bp->wol & MACB_WOL_ENABLED) {
46224629
macb_writel(bp, IDR, MACB_BIT(WOL));
@@ -4654,7 +4661,7 @@ static int __maybe_unused macb_runtime_suspend(struct device *dev)
46544661
struct net_device *netdev = dev_get_drvdata(dev);
46554662
struct macb *bp = netdev_priv(netdev);
46564663

4657-
if (!(device_may_wakeup(&bp->dev->dev))) {
4664+
if (!(device_may_wakeup(dev))) {
46584665
clk_disable_unprepare(bp->tx_clk);
46594666
clk_disable_unprepare(bp->hclk);
46604667
clk_disable_unprepare(bp->pclk);
@@ -4670,7 +4677,7 @@ static int __maybe_unused macb_runtime_resume(struct device *dev)
46704677
struct net_device *netdev = dev_get_drvdata(dev);
46714678
struct macb *bp = netdev_priv(netdev);
46724679

4673-
if (!(device_may_wakeup(&bp->dev->dev))) {
4680+
if (!(device_may_wakeup(dev))) {
46744681
clk_prepare_enable(bp->pclk);
46754682
clk_prepare_enable(bp->hclk);
46764683
clk_prepare_enable(bp->tx_clk);

0 commit comments

Comments
 (0)