net: bcmgenet: power management related fixes
Subsystems (3)
cover net: bcmgenet: power management related fixes
Hi David,
These two patches fixes issues seen while testing power management on platforms using the GENET driver.
First patch fixes an issue with the PHY state machine queuing work after resume since we are not properly detached from it.
Second patch fixes an issue with GENET interfaces that were not properly restored to a working state after a S3 suspend/resume cycle.
Thanks!
Florian Fainelli (2):
net: bcmgenet: connect and disconnect from the PHY state machine
net: bcmgenet: apply MII configuration in bcmgenet_open()
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 11 ++++++++++- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 3 ++- drivers/net/ethernet/broadcom/genet/bcmmii.c | 9 +++++---- 3 files changed, 17 insertions(+), 6 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 net: bcmgenet: connect and disconnect from the PHY state machine
phy_disconnect() is the only way to guarantee that we are not going to schedule more work on the PHY state machine workqueue for that particular PHY device.
This fixes an issue where a network interface was suspended prior to a system suspend/resume cycle and would then be resumed as part of mdio_bus_resume(), since the GENET interface clocks would have been disabled, this basically resulted in bus errors to appear since we are invoking the GENET driver adjust_link() callback.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 6 ++++++ drivers/net/ethernet/broadcom/genet/bcmgenet.h | 1 + drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +6 -0
@@ -2140,6 +2140,9 @@ static int bcmgenet_open(struct net_device *dev) goto err_irq0; } +phy_connect_direct (dev, priv->phydev, bcmgenet_mii_setup, + priv->phy_interface); +bcmgenet_netif_start (dev);return 0 ;
@@ -2184,6 +2187,9 @@ static int bcmgenet_close(struct net_device *dev)bcmgenet_netif_stop (dev); +/* Really kill the PHY state machine and disconnect from it */ +phy_disconnect (priv->phydev); +/* Disable MAC receive */ umac_enable_set (priv,CMD_RX_EN , false);
drivers/net/ethernet/broadcom/genet/bcmgenet.h +1 -0
@@ -620,6 +620,7 @@ int bcmgenet_mii_init(struct net_device *dev);int bcmgenet_mii_config (struct net_device *dev);void bcmgenet_mii_exit (struct net_device *dev);void bcmgenet_mii_reset (struct net_device *dev); +void bcmgenet_mii_setup (struct net_device *dev);/* Wake-on-LAN routines */ void bcmgenet_get_wol (struct net_device *dev,struct ethtool_wolinfo *wol);
drivers/net/ethernet/broadcom/genet/bcmmii.c +1 -1
@@ -77,7 +77,7 @@ static int bcmgenet_mii_write(struct mii_bus *bus, int phy_id,/* setup netdev link state when PHY link status change and * update UMAC and RGMII block when link up */ -static void bcmgenet_mii_setup (struct net_device *dev) +void bcmgenet_mii_setup (struct net_device *dev) {struct bcmgenet_priv *priv =netdev_priv (dev);struct phy_device *phydev = priv->phydev;
Signature · 1 line
1.9.1
PATCH 2/2 net: bcmgenet: apply MII configuration in bcmgenet_open()
In reply to Florian FainelliIn case an interface has been brought down before entering S3, and then brought up out of S3, all the initialization done during bcmgenet_probe() by bcmgenet_mii_init() calling bcmgenet_mii_config() is just lost since register contents are restored to their reset values.
Re-apply this configuration anytime we call bcmgenet_open() to make sure our port multiplexer is properly configured to match the PHY interface.
Since we are now calling bcmgenet_mii_config() everytime bcmgenet_open() is called, make sure we only print the message during initialization time not to pollute the console.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 5 ++++- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 2 +- drivers/net/ethernet/broadcom/genet/bcmmii.c | 7 ++++--- 3 files changed, 9 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +4 -1
@@ -2140,6 +2140,9 @@ static int bcmgenet_open(struct net_device *dev) goto err_irq0; } +/* Re-configure the port multiplexer towards the PHY device */ +bcmgenet_mii_config (priv->dev, false); +phy_connect_direct (dev, priv->phydev, bcmgenet_mii_setup, priv->phy_interface);
@@ -2691,7 +2694,7 @@ static int bcmgenet_resume(struct device *d)phy_init_hw (priv->phydev);/* Speed settings must be restored */ -bcmgenet_mii_config (priv->dev); +bcmgenet_mii_config (priv->dev, false);/* disable ethernet MAC while updating its registers */ umac_enable_set (priv,CMD_TX_EN |CMD_RX_EN , false);
drivers/net/ethernet/broadcom/genet/bcmgenet.h +1 -1
@@ -617,7 +617,7 @@ GENET_IO_MACRO(rbuf, GENET_RBUF_OFF);/* MDIO routines */ int bcmgenet_mii_init (struct net_device *dev); -int bcmgenet_mii_config (struct net_device *dev); +int bcmgenet_mii_config (struct net_device *dev,bool init);void bcmgenet_mii_exit (struct net_device *dev);void bcmgenet_mii_reset (struct net_device *dev);void bcmgenet_mii_setup (struct net_device *dev);
drivers/net/ethernet/broadcom/genet/bcmmii.c +4 -3
@@ -211,7 +211,7 @@ static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv)bcmgenet_sys_writel (priv, reg,SYS_PORT_CTRL ); } -int bcmgenet_mii_config (struct net_device *dev) +int bcmgenet_mii_config (struct net_device *dev,bool init) {struct bcmgenet_priv *priv =netdev_priv (dev);struct phy_device *phydev = priv->phydev;
@@ -298,7 +298,8 @@ int bcmgenet_mii_config(struct net_device *dev)return -EINVAL ; } -dev_info (kdev,"configuring instance for %s\n" , phy_name); +if (init) +dev_info (kdev,"configuring instance for %s\n" , phy_name);return 0 ; }
@@ -350,7 +351,7 @@ static int bcmgenet_mii_probe(struct net_device *dev)* PHY speed which is needed for bcmgenet_mii_config() to configure * things appropriately. */ - ret =bcmgenet_mii_config (dev); + ret =bcmgenet_mii_config (dev, true);if (ret) {phy_disconnect (priv->phydev);return ret;
Signature · 1 line
1.9.1
David Miller
maintainerFrom: Florian Fainelli <[email protected]>
Date: Mon, 10 Nov 2014 18:06:19 -0800
Quoted 8 lines
These two patches fixes issues seen while testing power management on platforms using the GENET driver.
First patch fixes an issue with the PHY state machine queuing work after resume since we are not properly detached from it.
Second patch fixes an issue with GENET interfaces that were not properly restored to a working state after a S3 suspend/resume cycle.
Series applied, thanks.