Skip to contentSkip to conversation

net: bcmgenet: restore internal EPHY support

PATCH In review Doug Berger 3 participants 12 messages Oct 16, 2019 – Oct 31, 2019

Subsystems (5)
lore
Share & tools
lore

Doug Berger

author maintainer
#0 lore raw

cover net: bcmgenet: restore internal EPHY support

I managed to get my hands on an old BCM97435SVMB board to do some testing with the latest kernel and uncovered a number of things that managed to get broken over the years (some by me ;).

This commit set attempts to correct the errors I observed in my testing.

The first commit applies to all internal PHYs to restore proper reporting of link status when a link comes up.

The second commit restores the soft reset to the initialization of the older internal EPHYs used by 40nm Set-Top Box devices.

The third corrects a bug I introduced when removing excessive soft resets by altering the initialization sequence in a way that keeps the GENETv3 MAC interface happy.

Finally, I observed a number of issues when manually configuring the network interface of the older EPHYs that appear to be resolved by the fourth commit.

Doug Berger (4):
net: bcmgenet: don't set phydev->link from MAC
net: phy: bcm7xxx: define soft_reset for 40nm EPHY
net: bcmgenet: soft reset 40nm EPHYs before MAC init
net: bcmgenet: reset 40nm EPHY on energy detect

 drivers/net/ethernet/broadcom/genet/bcmgenet.c |  41 +++++----
 drivers/net/ethernet/broadcom/genet/bcmgenet.h |   2 +-
 drivers/net/ethernet/broadcom/genet/bcmmii.c   | 112 +++++++++++--------------
 drivers/net/phy/bcm7xxx.c                      |   1 +
 4 files changed, 79 insertions(+), 77 deletions(-)
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH 1/4 net: bcmgenet: don't set phydev->link from MAC

When commit 28b2e0d2cd13 ("net: phy: remove parameter new_link from phy_mac_interrupt()") removed the new_link parameter it set the phydev->link state from the MAC before invoking phy_mac_interrupt().

However, once commit 88d6272acaaa ("net: phy: avoid unneeded MDIO reads in genphy_read_status") was added this initialization prevents the proper determination of the connection parameters by the function genphy_read_status().

This commit removes that initialization to restore the proper functionality.

Fixes 88d6272acaaa ("net: phy: avoid unneeded MDIO reads in genphy_read_status")
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +1 -3
index 12cb77ef1081..10d68017ff6c 100644
@@ -2612,10 +2612,8 @@ static void bcmgenet_irq_task(struct work_struct *work)
 	spin_unlock_irq(&priv->lock);
 
 	/* Link UP/DOWN event */
-	if (status & UMAC_IRQ_LINK_EVENT) {
-		priv->dev->phydev->link = !!(status & UMAC_IRQ_LINK_UP);
+	if (status & UMAC_IRQ_LINK_EVENT)
 		phy_mac_interrupt(priv->dev->phydev);
-	}
 }
 
 /* bcmgenet_isr1: handle Rx and Tx priority queues */
Signature · 1 line
2.7.4
Acked-by on v1 1/4
#2 lore raw

Re: [PATCH net 1/4] net: bcmgenet: don't set phydev->link from MAC

Quoted 9 lines · Doug Berger

When commit 28b2e0d2cd13 ("net: phy: remove parameter new_link from phy_mac_interrupt()") removed the new_link parameter it set the phydev->link state from the MAC before invoking phy_mac_interrupt().

However, once commit 88d6272acaaa ("net: phy: avoid unneeded MDIO reads in genphy_read_status") was added this initialization prevents the proper determination of the connection parameters by the function genphy_read_status().

Quoted 5 lines

This commit removes that initialization to restore the proper functionality.

Fixes 88d6272acaaa ("net: phy: avoid unneeded MDIO reads in genphy_read_status")
Signature · 1 line
Florian
author maintainer
#3 lore raw

PATCH 2/4 net: phy: bcm7xxx: define soft_reset for 40nm EPHY

In reply to Doug Berger

The internal 40nm EPHYs use a "Workaround for putting the PHY in IDDQ mode." These PHYs require a soft reset to restore functionality after they are powered back up.

This commit defines the soft_reset function to use genphy_soft_reset during phy_init_hw to accommodate this.

Fixes 6e2d85ec0559 ("net: phy: Stop with excessive soft reset")
---
 drivers/net/phy/bcm7xxx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/phy/bcm7xxx.c +1 -0
index 8fc33867e524..af8eabe7a6d4 100644
@@ -572,6 +572,7 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev)
 	.name           = _name,					\
 	/* PHY_BASIC_FEATURES */					\
 	.flags          = PHY_IS_INTERNAL,				\
+	.soft_reset	= genphy_soft_reset,				\
 	.config_init    = bcm7xxx_config_init,				\
 	.suspend        = bcm7xxx_suspend,				\
 	.resume         = bcm7xxx_config_init,				\
Signature · 1 line
2.7.4
Acked-by on v1 2/4
#4 lore raw

Re: [PATCH net 2/4] net: phy: bcm7xxx: define soft_reset for 40nm EPHY

Quoted 9 lines · Doug Berger

The internal 40nm EPHYs use a "Workaround for putting the PHY in IDDQ mode." These PHYs require a soft reset to restore functionality after they are powered back up.

This commit defines the soft_reset function to use genphy_soft_reset during phy_init_hw to accommodate this.

Fixes 6e2d85ec0559 ("net: phy: Stop with excessive soft reset")
Signature · 1 line
Florian
author maintainer
#5 lore raw

PATCH 3/4 net: bcmgenet: soft reset 40nm EPHYs before MAC init

In reply to Doug Berger

It turns out that the "Workaround for putting the PHY in IDDQ mode" used by the internal EPHYs on 40nm Set-Top Box chips when powering down puts the interface to the GENET MAC in a state that can cause subsequent MAC resets to be incomplete.

Rather than restore the forced soft reset when powering up internal PHYs, this commit moves the invocation of phy_init_hw earlier in the MAC initialization sequence to just before the MAC reset in the open and resume functions. This allows the interface to be stable and allows the MAC resets to be successful.

The bcmgenet_mii_probe() function is split in two to accommodate this. The new function bcmgenet_mii_connect() handles the first half of the functionality before the MAC initialization, and the bcmgenet_mii_config() function is extended to provide the remaining PHY configuration following the MAC initialization.

Fixes 484bfa1507bf ("Revert "net: bcmgenet: Software reset EPHY after power on"")
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c |  28 ++++---
 drivers/net/ethernet/broadcom/genet/bcmgenet.h |   2 +-
 drivers/net/ethernet/broadcom/genet/bcmmii.c   | 112 +++++++++++--------------
 3 files changed, 69 insertions(+), 73 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +17 -11
index 10d68017ff6c..f0937c650e3c 100644
@@ -2872,6 +2872,12 @@ static int bcmgenet_open(struct net_device *dev)
 	if (priv->internal_phy)
 		bcmgenet_power_up(priv, GENET_POWER_PASSIVE);
 
+	ret = bcmgenet_mii_connect(dev);
+	if (ret) {
+		netdev_err(dev, "failed to connect to PHY\n");
+		goto err_clk_disable;
+	}
+
 	/* take MAC out of reset */
 	bcmgenet_umac_reset(priv);
 
@@ -2881,6 +2887,12 @@ static int bcmgenet_open(struct net_device *dev)
 	reg = bcmgenet_umac_readl(priv, UMAC_CMD);
 	priv->crc_fwd_en = !!(reg & CMD_CRC_FWD);
 
+	ret = bcmgenet_mii_config(dev, true);
+	if (ret) {
+		netdev_err(dev, "unsupported PHY\n");
+		goto err_disconnect_phy;
+	}
+
 	bcmgenet_set_hw_addr(priv, dev->dev_addr);
 
 	if (priv->internal_phy) {
@@ -2896,7 +2908,7 @@ static int bcmgenet_open(struct net_device *dev)
 	ret = bcmgenet_init_dma(priv);
 	if (ret) {
 		netdev_err(dev, "failed to initialize DMA\n");
-		goto err_clk_disable;
+		goto err_disconnect_phy;
 	}
 
 	/* Always enable ring 16 - descriptor ring */
@@ -2919,25 +2931,19 @@ static int bcmgenet_open(struct net_device *dev)
 		goto err_irq0;
 	}
 
-	ret = bcmgenet_mii_probe(dev);
-	if (ret) {
-		netdev_err(dev, "failed to connect to PHY\n");
-		goto err_irq1;
-	}
-
 	bcmgenet_netif_start(dev);
 
 	netif_tx_start_all_queues(dev);
 
 	return 0;
 
-err_irq1:
-	free_irq(priv->irq1, priv);
 err_irq0:
 	free_irq(priv->irq0, priv);
 err_fini_dma:
 	bcmgenet_dma_teardown(priv);
 	bcmgenet_fini_dma(priv);
+err_disconnect_phy:
+	phy_disconnect(dev->phydev);
 err_clk_disable:
 	if (priv->internal_phy)
 		bcmgenet_power_down(priv, GENET_POWER_PASSIVE);
@@ -3618,6 +3624,8 @@ static int bcmgenet_resume(struct device *d)
 	if (priv->internal_phy)
 		bcmgenet_power_up(priv, GENET_POWER_PASSIVE);
 
+	phy_init_hw(dev->phydev);
+
 	bcmgenet_umac_reset(priv);
 
 	init_umac(priv);
@@ -3626,8 +3634,6 @@ static int bcmgenet_resume(struct device *d)
 	if (priv->wolopts)
 		clk_disable_unprepare(priv->clk_wol);
 
-	phy_init_hw(dev->phydev);
-
 	/* Speed settings must be restored */
 	bcmgenet_mii_config(priv->dev, false);
 
drivers/net/ethernet/broadcom/genet/bcmgenet.h +1 -1
index dbc69d8fa05f..7fbf573d8d52 100644
@@ -720,8 +720,8 @@ GENET_IO_MACRO(rbuf, GENET_RBUF_OFF);
 
 /* MDIO routines */
 int bcmgenet_mii_init(struct net_device *dev);
+int bcmgenet_mii_connect(struct net_device *dev);
 int bcmgenet_mii_config(struct net_device *dev, bool init);
-int bcmgenet_mii_probe(struct net_device *dev);
 void bcmgenet_mii_exit(struct net_device *dev);
 void bcmgenet_phy_power_set(struct net_device *dev, bool enable);
 void bcmgenet_mii_setup(struct net_device *dev);
drivers/net/ethernet/broadcom/genet/bcmmii.c +51 -61

128 lines not on this page · raw message

Signature · 1 line
2.7.4
Acked-by on v1 3/4
#6 lore raw

Re: [PATCH net 3/4] net: bcmgenet: soft reset 40nm EPHYs before MAC init

Quoted 11 lines · Doug Berger

It turns out that the "Workaround for putting the PHY in IDDQ mode" used by the internal EPHYs on 40nm Set-Top Box chips when powering down puts the interface to the GENET MAC in a state that can cause subsequent MAC resets to be incomplete.

Rather than restore the forced soft reset when powering up internal PHYs, this commit moves the invocation of phy_init_hw earlier in the MAC initialization sequence to just before the MAC reset in the open and resume functions. This allows the interface to be stable and allows the MAC resets to be successful.

Quoted 8 lines

The bcmgenet_mii_probe() function is split in two to accommodate this. The new function bcmgenet_mii_connect() handles the first half of the functionality before the MAC initialization, and the bcmgenet_mii_config() function is extended to provide the remaining PHY configuration following the MAC initialization.

Fixes 484bfa1507bf ("Revert "net: bcmgenet: Software reset EPHY after power on"")

We will have to see how difficult it might be to back port towards stable trees of interest, hopefully not too difficult.

Signature · 1 line
Florian
author maintainer
#7 lore raw

Re: [PATCH net 3/4] net: bcmgenet: soft reset 40nm EPHYs before MAC init

Quoted 20 lines · Florian Fainelli
Quoted 17 lines · Doug Berger

It turns out that the "Workaround for putting the PHY in IDDQ mode" used by the internal EPHYs on 40nm Set-Top Box chips when powering down puts the interface to the GENET MAC in a state that can cause subsequent MAC resets to be incomplete.

Rather than restore the forced soft reset when powering up internal PHYs, this commit moves the invocation of phy_init_hw earlier in the MAC initialization sequence to just before the MAC reset in the open and resume functions. This allows the interface to be stable and allows the MAC resets to be successful.

The bcmgenet_mii_probe() function is split in two to accommodate this. The new function bcmgenet_mii_connect() handles the first half of the functionality before the MAC initialization, and the bcmgenet_mii_config() function is extended to provide the remaining PHY configuration following the MAC initialization.

Quoted 8 lines
Quoted 2 lines
Fixes 484bfa1507bf ("Revert "net: bcmgenet: Software reset EPHY after power on"")

We will have to see how difficult it might be to back port towards stable trees of interest, hopefully not too difficult.

There is more going on here with the MAC reset than this commit resolves and I am actively investigating a different approach that may include the reversion of this commit.

Therefore, I would recommend not spending effort attempting to backport this specific commit until I have submitted a more complete solution (hopefully in the near future :).

Sorry for any confusion this creates.
Doug

author maintainer
#8 lore raw

PATCH 4/4 net: bcmgenet: reset 40nm EPHY on energy detect

In reply to Doug Berger

The EPHY integrated into the 40nm Set-Top Box devices can falsely detect energy when connected to a disabled peer interface. When the peer interface is enabled the EPHY will detect and report the link as active, but on occasion may get into a state where it is not able to exchange data with the connected GENET MAC. This issue has not been observed when the link parameters are auto-negotiated; however, it has been observed with a manually configured link.

It has been empirically determined that issuing a soft reset to the EPHY when energy is detected prevents it from getting into this bad state.

Fixes 1c1008c793fa ("net: bcmgenet: add main driver file")
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +8 -1
index f0937c650e3c..0f138280315a 100644
@@ -2018,6 +2018,8 @@ static void bcmgenet_link_intr_enable(struct bcmgenet_priv *priv)
 	 */
 	if (priv->internal_phy) {
 		int0_enable |= UMAC_IRQ_LINK_EVENT;
+		if (GENET_IS_V1(priv) || GENET_IS_V2(priv) || GENET_IS_V3(priv))
+			int0_enable |= UMAC_IRQ_PHY_DET_R;
 	} else if (priv->ext_phy) {
 		int0_enable |= UMAC_IRQ_LINK_EVENT;
 	} else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
@@ -2611,9 +2613,14 @@ static void bcmgenet_irq_task(struct work_struct *work)
 	priv->irq0_stat = 0;
 	spin_unlock_irq(&priv->lock);
 
+	if (status & UMAC_IRQ_PHY_DET_R &&
+	    priv->dev->phydev->autoneg != AUTONEG_ENABLE)
+		phy_init_hw(priv->dev->phydev);
+
 	/* Link UP/DOWN event */
 	if (status & UMAC_IRQ_LINK_EVENT)
 		phy_mac_interrupt(priv->dev->phydev);
+
 }
 
 /* bcmgenet_isr1: handle Rx and Tx priority queues */
@@ -2708,7 +2715,7 @@ static irqreturn_t bcmgenet_isr0(int irq, void *dev_id)
 	}
 
 	/* all other interested interrupts handled in bottom half */
-	status &= UMAC_IRQ_LINK_EVENT;
+	status &= (UMAC_IRQ_LINK_EVENT | UMAC_IRQ_PHY_DET_R);
 	if (status) {
 		/* Save irq status for bottom-half processing. */
 		spin_lock_irqsave(&priv->lock, flags);
Signature · 1 line
2.7.4
Acked-by on v1 4/4
#9 lore raw

Re: [PATCH net 4/4] net: bcmgenet: reset 40nm EPHY on energy detect

Quoted 8 lines · Doug Berger

The EPHY integrated into the 40nm Set-Top Box devices can falsely detect energy when connected to a disabled peer interface. When the peer interface is enabled the EPHY will detect and report the link as active, but on occasion may get into a state where it is not able to exchange data with the connected GENET MAC. This issue has not been observed when the link parameters are auto-negotiated; however, it has been observed with a manually configured link.

Quoted 6 lines

It has been empirically determined that issuing a soft reset to the EPHY when energy is detected prevents it from getting into this bad state.

Fixes 1c1008c793fa ("net: bcmgenet: add main driver file")
Signature · 1 line
Florian
#10 lore raw
In reply to Doug Berger
Quoted 13 lines · Doug Berger

I managed to get my hands on an old BCM97435SVMB board to do some testing with the latest kernel and uncovered a number of things that managed to get broken over the years (some by me ;).

This commit set attempts to correct the errors I observed in my testing.

The first commit applies to all internal PHYs to restore proper reporting of link status when a link comes up.

The second commit restores the soft reset to the initialization of the older internal EPHYs used by 40nm Set-Top Box devices.

Quoted 7 lines

The third corrects a bug I introduced when removing excessive soft resets by altering the initialization sequence in a way that keeps the GENETv3 MAC interface happy.

Finally, I observed a number of issues when manually configuring the network interface of the older EPHYs that appear to be resolved by the fourth commit.

Thank you very much for addressing all of those problems!

Quoted 13 lines

Doug Berger (4):
net: bcmgenet: don't set phydev->link from MAC
net: phy: bcm7xxx: define soft_reset for 40nm EPHY
net: bcmgenet: soft reset 40nm EPHYs before MAC init
net: bcmgenet: reset 40nm EPHY on energy detect

 drivers/net/ethernet/broadcom/genet/bcmgenet.c |  41 +++++----
 drivers/net/ethernet/broadcom/genet/bcmgenet.h |   2 +-
 drivers/net/ethernet/broadcom/genet/bcmmii.c   | 112 +++++++++++--------------
 drivers/net/phy/bcm7xxx.c                      |   1 +
 4 files changed, 79 insertions(+), 77 deletions(-)
Signature · 1 line
Florian
maintainer
#11 lore raw
In reply to Doug Berger

From: Doug Berger <[email protected]>
Date: Wed, 16 Oct 2019 16:06:28 -0700

Quoted 13 lines

I managed to get my hands on an old BCM97435SVMB board to do some testing with the latest kernel and uncovered a number of things that managed to get broken over the years (some by me ;).

This commit set attempts to correct the errors I observed in my testing.

The first commit applies to all internal PHYs to restore proper reporting of link status when a link comes up.

The second commit restores the soft reset to the initialization of the older internal EPHYs used by 40nm Set-Top Box devices.

Quoted 7 lines

The third corrects a bug I introduced when removing excessive soft resets by altering the initialization sequence in a way that keeps the GENETv3 MAC interface happy.

Finally, I observed a number of issues when manually configuring the network interface of the older EPHYs that appear to be resolved by the fourth commit.

Series applied and queued up for -stable.

Thanks.