Skip to content

Commit

Permalink
net: macb: do not disable MDIO bus at open/close time
Browse files Browse the repository at this point in the history
macb_reset_hw() is called from macb_close() and indirectly from
macb_open(). macb_reset_hw() zeroes the NCR register, including the MPE
(Management Port Enable) bit.

This will prevent accessing any other PHYs for other Ethernet MACs on
the MDIO bus, which remains registered at macb_reset_hw() time, until
macb_init_hw() is called from macb_open() which sets the MPE bit again.

I.e. currently the MDIO bus has a short disruption at open time and is
disabled at close time until the interface is opened again.

Fix that by only touching the RE and TE bits when enabling and disabling
RX/TX.

v2: Make macb_init_hw() NCR write a single statement.

Fixes: 6c36a70 ("macb: Use generic PHY layer")
Signed-off-by: Anssi Hannula <[email protected]>
Reviewed-by: Claudiu Beznea <[email protected]>
Tested-by: Claudiu Beznea <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
anssih authored and davem330 committed Aug 26, 2018
1 parent f7b9e8e commit 0da70f8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/net/ethernet/cadence/macb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2035,14 +2035,17 @@ static void macb_reset_hw(struct macb *bp)
{
struct macb_queue *queue;
unsigned int q;
u32 ctrl = macb_readl(bp, NCR);

/* Disable RX and TX (XXX: Should we halt the transmission
* more gracefully?)
*/
macb_writel(bp, NCR, 0);
ctrl &= ~(MACB_BIT(RE) | MACB_BIT(TE));

/* Clear the stats registers (XXX: Update stats first?) */
macb_writel(bp, NCR, MACB_BIT(CLRSTAT));
ctrl |= MACB_BIT(CLRSTAT);

macb_writel(bp, NCR, ctrl);

/* Clear all status flags */
macb_writel(bp, TSR, -1);
Expand Down Expand Up @@ -2230,7 +2233,7 @@ static void macb_init_hw(struct macb *bp)
}

/* Enable TX and RX */
macb_writel(bp, NCR, MACB_BIT(RE) | MACB_BIT(TE) | MACB_BIT(MPE));
macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(RE) | MACB_BIT(TE));
}

/* The hash address register is 64 bits long and takes up two
Expand Down

0 comments on commit 0da70f8

Please sign in to comment.