netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dsa: slave: Fix autoneg for phys on switch MDIO bus
@ 2014-11-05 18:47 Andrew Lunn
  2014-11-05 20:53 ` Florian Fainelli
  2014-11-06 20:06 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Lunn @ 2014-11-05 18:47 UTC (permalink / raw)
  To: davem, f.fainelli; +Cc: netdev, Andrew Lunn

When the ports phys are connected to the switches internal MDIO bus,
we need to connect the phy to the slave netdev, otherwise
auto-negotiation etc, does not work.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---

Hi Florian

Is this the right fix?

What i found is that ports on mv88E6171 we coming up as 10/half.  If i
forced a renegotiation with ethtool -r lan0, the phy would then goto
1000/full.

The code for phys on internal switch MDIO buses never connect the phy
to the device, only phys listed in DT get connected via
of_phy_connect(). By connecting the phy, the state machine is active
and does an autoneg when the slave interface is opened.

net/dsa/slave.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 6d1817449c36..ab03e00ffe8f 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -489,11 +489,14 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
 	/* We could not connect to a designated PHY, so use the switch internal
 	 * MDIO bus instead
 	 */
-	if (!p->phy)
+	if (!p->phy) {
 		p->phy = ds->slave_mii_bus->phy_map[p->port];
-	else
+		phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
+				   p->phy_interface);
+	} else {
 		pr_info("attached PHY at address %d [%s]\n",
 			p->phy->addr, p->phy->drv->name);
+	}
 }
 
 int dsa_slave_suspend(struct net_device *slave_dev)
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: dsa: slave: Fix autoneg for phys on switch MDIO bus
  2014-11-05 18:47 [PATCH] net: dsa: slave: Fix autoneg for phys on switch MDIO bus Andrew Lunn
@ 2014-11-05 20:53 ` Florian Fainelli
  2014-11-06 20:06 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2014-11-05 20:53 UTC (permalink / raw)
  To: Andrew Lunn, davem; +Cc: netdev

On 11/05/2014 10:47 AM, Andrew Lunn wrote:
> When the ports phys are connected to the switches internal MDIO bus,
> we need to connect the phy to the slave netdev, otherwise
> auto-negotiation etc, does not work.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
> 
> Hi Florian
> 
> Is this the right fix?
> 
> What i found is that ports on mv88E6171 we coming up as 10/half.  If i
> forced a renegotiation with ethtool -r lan0, the phy would then goto
> 1000/full.
> 
> The code for phys on internal switch MDIO buses never connect the phy
> to the device, only phys listed in DT get connected via
> of_phy_connect(). By connecting the phy, the state machine is active
> and does an autoneg when the slave interface is opened.

This looks fine to me, I think we might want to revisit/nuke the code at
the end of dsa_slave_create since it:

- is racy: netif_carrier_off() is called before register_netdev()
- is double racy: we should be bound to a PHY before calling
register_netdev() otherwise there could be MDIO accesses done to that
PHY without an actual PHY being registered

> 
> net/dsa/slave.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 6d1817449c36..ab03e00ffe8f 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -489,11 +489,14 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
>  	/* We could not connect to a designated PHY, so use the switch internal
>  	 * MDIO bus instead
>  	 */
> -	if (!p->phy)
> +	if (!p->phy) {
>  		p->phy = ds->slave_mii_bus->phy_map[p->port];
> -	else
> +		phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
> +				   p->phy_interface);
> +	} else {
>  		pr_info("attached PHY at address %d [%s]\n",
>  			p->phy->addr, p->phy->drv->name);
> +	}
>  }
>  
>  int dsa_slave_suspend(struct net_device *slave_dev)
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: dsa: slave: Fix autoneg for phys on switch MDIO bus
  2014-11-05 18:47 [PATCH] net: dsa: slave: Fix autoneg for phys on switch MDIO bus Andrew Lunn
  2014-11-05 20:53 ` Florian Fainelli
@ 2014-11-06 20:06 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-11-06 20:06 UTC (permalink / raw)
  To: andrew; +Cc: f.fainelli, netdev

From: Andrew Lunn <andrew@lunn.ch>
Date: Wed,  5 Nov 2014 19:47:28 +0100

> When the ports phys are connected to the switches internal MDIO bus,
> we need to connect the phy to the slave netdev, otherwise
> auto-negotiation etc, does not work.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Applied, thanks Andrew.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-06 20:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-05 18:47 [PATCH] net: dsa: slave: Fix autoneg for phys on switch MDIO bus Andrew Lunn
2014-11-05 20:53 ` Florian Fainelli
2014-11-06 20:06 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).