Skip to content

Commit 37850e3

Browse files
ffainellidavem330
authored andcommitted
net: bcmgenet: Fix early link interrupt enabling
Link interrupts are enabled in init_umac(), which is too early for us to process them since we do not yet have a valid PHY device pointer. On BCM7425 chips for instance, we will crash calling phy_mac_interrupt() because phydev is NULL. Fix this by moving the link interrupts enabling in bcmgenet_netif_start(), under a specific function: bcmgenet_link_intr_enable() and while at it, update the comments surrounding the code. Fixes: 6cc8e6d ("net: bcmgenet: Delay PHY initialization to bcmgenet_open()") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent afc050d commit 37850e3

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,24 @@ static void bcmgenet_intr_disable(struct bcmgenet_priv *priv)
16831683
bcmgenet_intrl2_1_writel(priv, 0, INTRL2_CPU_MASK_CLEAR);
16841684
}
16851685

1686+
static void bcmgenet_link_intr_enable(struct bcmgenet_priv *priv)
1687+
{
1688+
u32 int0_enable = 0;
1689+
1690+
/* Monitor cable plug/unplugged event for internal PHY, external PHY
1691+
* and MoCA PHY
1692+
*/
1693+
if (priv->internal_phy) {
1694+
int0_enable |= UMAC_IRQ_LINK_EVENT;
1695+
} else if (priv->ext_phy) {
1696+
int0_enable |= UMAC_IRQ_LINK_EVENT;
1697+
} else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
1698+
if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET)
1699+
int0_enable |= UMAC_IRQ_LINK_EVENT;
1700+
}
1701+
bcmgenet_intrl2_0_writel(priv, int0_enable, INTRL2_CPU_MASK_CLEAR);
1702+
}
1703+
16861704
static int init_umac(struct bcmgenet_priv *priv)
16871705
{
16881706
struct device *kdev = &priv->pdev->dev;
@@ -1723,15 +1741,8 @@ static int init_umac(struct bcmgenet_priv *priv)
17231741
/* Enable Tx default queue 16 interrupts */
17241742
int0_enable |= UMAC_IRQ_TXDMA_DONE;
17251743

1726-
/* Monitor cable plug/unplugged event for internal PHY */
1727-
if (priv->internal_phy) {
1728-
int0_enable |= UMAC_IRQ_LINK_EVENT;
1729-
} else if (priv->ext_phy) {
1730-
int0_enable |= UMAC_IRQ_LINK_EVENT;
1731-
} else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
1732-
if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET)
1733-
int0_enable |= UMAC_IRQ_LINK_EVENT;
1734-
1744+
/* Configure backpressure vectors for MoCA */
1745+
if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
17351746
reg = bcmgenet_bp_mc_get(priv);
17361747
reg |= BIT(priv->hw_params->bp_in_en_shift);
17371748

@@ -2645,6 +2656,9 @@ static void bcmgenet_netif_start(struct net_device *dev)
26452656

26462657
netif_tx_start_all_queues(dev);
26472658

2659+
/* Monitor link interrupts now */
2660+
bcmgenet_link_intr_enable(priv);
2661+
26482662
phy_start(priv->phydev);
26492663
}
26502664

0 commit comments

Comments
 (0)