From: Vladimir Oltean <olteanv@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: David Miller <davem@davemloft.net>,
netdev <netdev@vger.kernel.org>,
Florian Fainelli <f.fainelli@gmail.com>,
Russell King <rmk+kernel@arm.linux.org.uk>,
Ioana Ciornei <ioana.ciornei@nxp.com>
Subject: Re: [PATCH net] net: dsa: Don't instantiate phylink for CPU/DSA ports unless needed
Date: Thu, 12 Mar 2020 02:24:08 +0200 [thread overview]
Message-ID: <CA+h21hr63Jc-EfDhxS91W5s6gXLavz+datD1c9CKD6cKJ4PYFQ@mail.gmail.com> (raw)
In-Reply-To: <20200311152424.18067-1-andrew@lunn.ch>
On Wed, 11 Mar 2020 at 17:24, Andrew Lunn <andrew@lunn.ch> wrote:
>
> 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>
> ---
No regressions on ocelot/felix and sja1105, which have no .adjust_link
and do have fixed-link for the CPU port.
> net/dsa/port.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/net/dsa/port.c b/net/dsa/port.c
> index ed7dabb57985..ec13dc666788 100644
> --- a/net/dsa/port.c
> +++ b/net/dsa/port.c
> @@ -648,9 +648,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");
> @@ -665,11 +670,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;
> }
>
> --
> 2.25.1
>
Thanks,
-Vladimir
next prev parent reply other threads:[~2020-03-12 0:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 15:24 [PATCH net] net: dsa: Don't instantiate phylink for CPU/DSA ports unless needed Andrew Lunn
2020-03-12 0:24 ` Vladimir Oltean [this message]
2020-03-12 6:46 ` David Miller
2020-03-31 12:57 ` 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=CA+h21hr63Jc-EfDhxS91W5s6gXLavz+datD1c9CKD6cKJ4PYFQ@mail.gmail.com \
--to=olteanv@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=ioana.ciornei@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=rmk+kernel@arm.linux.org.uk \
/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).