mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Claudiu Beznea <claudiu.beznea@microchip.com>
To: <nicolas.ferre@microchip.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<linux@armlinux.org.uk>, <andrew@lunn.ch>, <hkallweit1@gmail.com>
Cc: <sergiu.moga@microchip.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Claudiu Beznea <claudiu.beznea@microchip.com>
Subject: [PATCH v2 2/2] net: macb: use phylink_suspend()/phylink_resume()
Date: Mon, 12 Dec 2022 13:28:45 +0200	[thread overview]
Message-ID: <20221212112845.73290-3-claudiu.beznea@microchip.com> (raw)
In-Reply-To: <20221212112845.73290-1-claudiu.beznea@microchip.com>

Use phylink_suspend() and phylink_resume() for macb driver instead
of phylink_start()/phylink_stop(). This helps on fixing
commit bf0ad1893442 ("net: macb: Specify PHY PM management done by MAC").

Commit bf0ad1893442 ("net: macb: Specify PHY PM management done by MAC")
signals to PHY layer that the PHY PM management is done by the MAC driver
itself. In case this is done the mdio_bus_phy_suspend() and
mdio_bus_phy_resume() will return just at its beginning letting the MAC
driver to handle the PHY power management.

AT91 devices (e.g. SAMA7G5, SAMA5D2) has a special power saving mode
called backup and self-refresh where most of the SoCs parts are shutdown
on suspend and RAM is switched to self-refresh. The rail powering the
on-board ethernet PHY could also be closed.

For scenarios where backup and self-refresh is used the MACB driver needs
to re-initialize the PHY device itself when resuming. Otherwise there is
poor or missing connectivity (e.g. SAMA7G5-EK uses KSZ9131 in RGMII mode
which needs its DLL settings to satisfy RGMII timings). For this call
phylink_suspend()/phylink_resume() on suspend/resume path.

The patch has been tested on SAMA7G5EK (with KSZ9131 and KSZ8081 PHYs)
and SAM9X60EK (with KSZ8081 PHY) boards.

Fixes: bf0ad1893442 ("net: macb: Specify PHY PM management done by MAC")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---

This patch depends on patch 1/2 from this series. For proper backporting
to older kernel (in case this series is integrated as is) please add the
Depends-on tag on this patch after patch 1/2 is integrated in networking
tree.

Thank you,
Claudiu Beznea

 drivers/net/ethernet/cadence/macb_main.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 95667b979fab..bcd394093d1c 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -5142,9 +5142,13 @@ static int __maybe_unused macb_suspend(struct device *dev)
 		napi_disable(&queue->napi_tx);
 	}
 
-	if (!(bp->wol & MACB_WOL_ENABLED)) {
+	if (bp->wol & MACB_WOL_ENABLED) {
 		rtnl_lock();
-		phylink_stop(bp->phylink);
+		phylink_suspend(bp->phylink, true);
+		rtnl_unlock();
+	} else {
+		rtnl_lock();
+		phylink_suspend(bp->phylink, false);
 		phy_exit(bp->sgmii_phy);
 		rtnl_unlock();
 		spin_lock_irqsave(&bp->lock, flags);
@@ -5209,13 +5213,6 @@ static int __maybe_unused macb_resume(struct device *dev)
 		spin_unlock_irqrestore(&bp->lock, flags);
 
 		disable_irq_wake(bp->queues[0].irq);
-
-		/* Now make sure we disable phy before moving
-		 * to common restore path
-		 */
-		rtnl_lock();
-		phylink_stop(bp->phylink);
-		rtnl_unlock();
 	}
 
 	for (q = 0, queue = bp->queues; q < bp->num_queues;
@@ -5238,7 +5235,7 @@ static int __maybe_unused macb_resume(struct device *dev)
 	if (!device_may_wakeup(&bp->dev->dev))
 		phy_init(bp->sgmii_phy);
 
-	phylink_start(bp->phylink);
+	phylink_resume(bp->phylink);
 	rtnl_unlock();
 
 	netif_device_attach(netdev);
-- 
2.34.1


  parent reply	other threads:[~2022-12-12 11:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12 11:28 [PATCH v2 0/2] net: macb: fix connectivity after resume Claudiu Beznea
2022-12-12 11:28 ` [PATCH v2 1/2] net: phylink: init phydev on phylink_resume() Claudiu Beznea
2022-12-12 12:47   ` Russell King (Oracle)
2022-12-12 13:26     ` Claudiu.Beznea
2022-12-12 14:24       ` Russell King (Oracle)
2022-12-12 14:46         ` Claudiu.Beznea
2022-12-12 13:54   ` Vladimir Oltean
2022-12-12 15:20     ` Claudiu.Beznea
2022-12-12 11:28 ` Claudiu Beznea [this message]
2022-12-14  1:39 ` [PATCH v2 0/2] net: macb: fix connectivity after resume Jakub Kicinski

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=20221212112845.73290-3-claudiu.beznea@microchip.com \
    --to=claudiu.beznea@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=pabeni@redhat.com \
    --cc=sergiu.moga@microchip.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®