netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, Vivien Didelot <vivien.didelot@gmail.com>
Subject: Re: [PATCH net-next 0/10] net: dsa: improve serdes integration
Date: Fri, 6 Mar 2020 14:29:26 +0100	[thread overview]
Message-ID: <20200306132926.GA18310@lunn.ch> (raw)
In-Reply-To: <20200306103934.GF25745@shell.armlinux.org.uk>

> Unfortunately, that means that CPU and DSA ports without a fixed-link
> spec will stay down because phylink won't call mac_link_up() - so we're
> back to the poor integration of phylink for CPU and DSA ports problem.
> Even if phylink /were/ to call mac_link_up() for that situation,
> phylink has no information on the speed and duplex for such a port, so
> speed and duplex would be nonsense.
> 
> That conversion is very problematical.
> 
> I do have some patches that solve it by changing phylink, but it's
> quite a hack - the problem is detecting the uninitialised state in
> phylink_start(), which is really quite late.  You can find them in my
> "zii" branch:
> 
> net: dsa: mv88e6xxx: split out SPEED_MAX setting
> net: phylink/dsa: fix DSA and CPU links
> 
> So, I think we're back to... what do we do about the broken phylink
> integration for CPU and DSA ports.

Hi Russell

Here is what i have been playing with:

commit ea4c6b6ad0694a3cd857f504fb5e3a5887ffa062
Author: Andrew Lunn <andrew@lunn.ch>
Date:   Wed Feb 12 14:49:18 2020 -0600

    net: dsa: Don't instantiate phylink for CPU/DSA ports unless needed
    
    By default, DSA drivers should configure CPU and DSA ports to their
    maximum speed. In many configurations this is sufficient to make the
    link work.
    
    In some cases it is necessary to configure the link to run slower,
    e.g. because of limitations of the SoC it is connected to. Or back to
    back PHYs are used and the PHY needs to be driven in order to
    establish link. In this case, phylink is used.
    
    Only instantiate phylink if it is required. If there is no PHY, or no
    fixed link properties, phylink can upset a link which works in the
    default configuration.
    
    Fixes: 0e27921816ad ("net: dsa: Use PHYLINK for the CPU/DSA ports")
    Signed-off-by: Andrew Lunn <andrew@lunn.ch>

diff --git a/net/dsa/port.c b/net/dsa/port.c
index 9b54e5a76297..dc4da4dc44f5 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -629,9 +629,14 @@ static int dsa_port_phylink_register(struct dsa_port *dp)
 int dsa_port_link_register_of(struct dsa_port *dp)
 {
        struct dsa_switch *ds = dp->ds;
+       struct device_node *phy_np;
 
-       if (!ds->ops->adjust_link)
-               return dsa_port_phylink_register(dp);
+       if (!ds->ops->adjust_link) {
+               phy_np = of_parse_phandle(dp->dn, "phy-handle", 0);
+               if (of_phy_is_fixed_link(dp->dn) || phy_np)
+                       return dsa_port_phylink_register(dp);
+               return 0;
+       }
 
        dev_warn(ds->dev,
                 "Using legacy PHYLIB callbacks. Please migrate to PHYLINK!\n");
@@ -646,11 +651,12 @@ void dsa_port_link_unregister_of(struct dsa_port *dp)
 {
        struct dsa_switch *ds = dp->ds;
 
-       if (!ds->ops->adjust_link) {
+       if (!ds->ops->adjust_link && dp->pl) {
                rtnl_lock();
                phylink_disconnect_phy(dp->pl);
                rtnl_unlock();
                phylink_destroy(dp->pl);
+               dp->pl = NULL;
                return;
        }
 

If we go with this, we can assume we do know the speed, either from
fixed-link, or the PHY when it established the link.

There is maybe one use case not covered by my patch. A port might just
have a phy-mode property, e.g. 'rgmii-id', but no fixed link. I took a
quick look at the usual suspects in DT, and i didn't find an actual
example of this. And i also need to look at the code pre-phylink
integration to see if it was actually supported.

	    Andrew

  reply	other threads:[~2020-03-06 13:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05 12:41 [PATCH net-next 0/10] net: dsa: improve serdes integration Russell King - ARM Linux admin
2020-03-05 12:42 ` [PATCH net-next 01/10] net: mii: convert mii_lpa_to_ethtool_lpa_x() to linkmode variant Russell King
2020-03-05 12:42 ` [PATCH net-next 02/10] net: mii: add linkmode_adv_to_mii_adv_x() Russell King
2020-03-05 12:42 ` [PATCH net-next 03/10] net: dsa: warn if phylink_mac_link_state returns error Russell King
2020-03-05 12:42 ` [PATCH net-next 04/10] net: dsa: mv88e6xxx: use BMCR definitions for serdes control register Russell King
2020-03-05 12:42 ` [PATCH net-next 05/10] net: dsa: mv88e6xxx: configure interface settings in mac_config Russell King
2020-03-05 12:42 ` [PATCH net-next 06/10] net: dsa: mv88e6xxx: extend phylink to Serdes PHYs Russell King
2020-03-05 13:38   ` Marek Behun
2020-03-05 13:43     ` Russell King - ARM Linux admin
2020-03-05 12:42 ` [PATCH net-next 07/10] net: dsa: mv88e6xxx: fix Serdes link changes Russell King
2020-03-05 12:42 ` [PATCH net-next 08/10] net: dsa: mv88e6xxx: combine port_set_speed and port_set_duplex Russell King
2020-03-05 12:42 ` [PATCH net-next 09/10] net: dsa: mv88e6xxx: remove port_link_state functions Russell King
2020-03-05 12:42 ` [PATCH net-next 10/10] net: dsa: mv88e6xxx: use PHY_DETECT in mac_link_up/mac_link_down Russell King
2020-03-05 22:54 ` [PATCH net-next 0/10] net: dsa: improve serdes integration Andrew Lunn
2020-03-05 23:45   ` Russell King - ARM Linux admin
2020-03-06  0:27     ` Andrew Lunn
2020-03-06  1:13     ` Andrew Lunn
2020-03-06  3:57       ` Andrew Lunn
2020-03-06 10:39         ` Russell King - ARM Linux admin
2020-03-06 13:29           ` Andrew Lunn [this message]
2020-03-06 13:53           ` Marek Behun
2020-03-06 14:51             ` Andrew Lunn
2020-03-09  5:04 ` David Miller
2020-03-09  9:48   ` Russell King - ARM Linux admin
2020-03-09 12:40     ` Andrew Lunn
2020-03-09 12:50       ` Russell King - ARM Linux admin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200306132926.GA18310@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).