linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested
@ 2015-07-21  0:49 Florian Fainelli
  2015-07-21  0:49 ` [PATCH net v5 1/4] net: dsa: bcm_sf2: Do not override speed settings Florian Fainelli
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Florian Fainelli @ 2015-07-21  0:49 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-kernel, mxs, arno, stsp, devicetree,
	thomas.petazzoni, Florian Fainelli

Hi all,

Changes in v5:

- removed an invalid use of the link_update callback in the SF2 driver
  was appeared after merging "net: phy: fixed_phy: handle link-down case"

- reworded the commit message for patch 2 to make it clear what it fixes and
  why this is required

Initial cover letter from Stas:

Hello.

Currently the link status auto-negotiation is enabled
for any SGMII link with fixed-link DT binding.
The regression was reported:
https://lkml.org/lkml/2015/7/8/865
Apparently not all HW that implements SGMII protocol, generates the
inband status for the auto-negotiation to work.
More details here:
https://lkml.org/lkml/2015/7/10/206

The following patches reverts to the old behavior by default,
which is to not enable the auto-negotiation for fixed-link.
The new DT property is added that allows to explicitly request
the auto-negotiation.

Florian Fainelli (1):
  net: dsa: bcm_sf2: Do not override speed settings

Stas Sergeev (3):
  net: phy: fixed_phy: handle link-down case
  of_mdio: add new DT property 'managed' to specify the PHY management
    type
  mvneta: use inband status only when explicitly enabled

 Documentation/devicetree/bindings/net/ethernet.txt |  4 ++++
 drivers/net/dsa/bcm_sf2.c                          | 18 +-----------------
 drivers/net/ethernet/marvell/mvneta.c              |  9 +++++----
 drivers/net/phy/fixed_phy.c                        |  8 +++++---
 drivers/of/of_mdio.c                               | 19 +++++++++++++++++--
 5 files changed, 32 insertions(+), 26 deletions(-)

-- 
2.1.0


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

* [PATCH net v5 1/4] net: dsa: bcm_sf2: Do not override speed settings
  2015-07-21  0:49 [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested Florian Fainelli
@ 2015-07-21  0:49 ` Florian Fainelli
  2015-07-21  0:49 ` [PATCH net v5 2/4] net: phy: fixed_phy: handle link-down case Florian Fainelli
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2015-07-21  0:49 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-kernel, mxs, arno, stsp, devicetree,
	thomas.petazzoni, Florian Fainelli

The SF2 driver currently overrides speed settings for its port
configured using a fixed PHY, this is both unnecessary and incorrect,
because we keep feedback to the hardware parameters that we read from
the PHY device, which in the case of a fixed PHY cannot possibly change
speed.

This is a required change to allow the fixed PHY code to allow
registering a PHY with a link configured as DOWN by default and avoid
some sort of circular dependency where we require the link_update
callback to run to program the hardware, and we then utilize the fixed
PHY parameters to program the hardware with the same settings.

Fixes: 246d7f773c13 ("net: dsa: add Broadcom SF2 switch driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/bcm_sf2.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 972982f8bea7..3297604f8216 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -890,15 +890,11 @@ static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port,
 					 struct fixed_phy_status *status)
 {
 	struct bcm_sf2_priv *priv = ds_to_priv(ds);
-	u32 duplex, pause, speed;
+	u32 duplex, pause;
 	u32 reg;
 
 	duplex = core_readl(priv, CORE_DUPSTS);
 	pause = core_readl(priv, CORE_PAUSESTS);
-	speed = core_readl(priv, CORE_SPDSTS);
-
-	speed >>= (port * SPDSTS_SHIFT);
-	speed &= SPDSTS_MASK;
 
 	status->link = 0;
 
@@ -933,18 +929,6 @@ static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port,
 		reg &= ~LINK_STS;
 	core_writel(priv, reg, CORE_STS_OVERRIDE_GMIIP_PORT(port));
 
-	switch (speed) {
-	case SPDSTS_10:
-		status->speed = SPEED_10;
-		break;
-	case SPDSTS_100:
-		status->speed = SPEED_100;
-		break;
-	case SPDSTS_1000:
-		status->speed = SPEED_1000;
-		break;
-	}
-
 	if ((pause & (1 << port)) &&
 	    (pause & (1 << (port + PAUSESTS_TX_PAUSE_SHIFT)))) {
 		status->asym_pause = 1;
-- 
2.1.0


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

* [PATCH net v5 2/4] net: phy: fixed_phy: handle link-down case
  2015-07-21  0:49 [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested Florian Fainelli
  2015-07-21  0:49 ` [PATCH net v5 1/4] net: dsa: bcm_sf2: Do not override speed settings Florian Fainelli
@ 2015-07-21  0:49 ` Florian Fainelli
  2015-07-21  0:49 ` [PATCH net v5 3/4] of_mdio: add new DT property 'managed' to specify the PHY management type Florian Fainelli
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2015-07-21  0:49 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-kernel, mxs, arno, stsp, devicetree,
	thomas.petazzoni, Stas Sergeev, Florian Fainelli

From: Stas Sergeev <stsp@list.ru>

fixed_phy_register() currently hardcodes the fixed PHY link to 1, and
expects to find a "speed" parameter to provide correct information
towards the fixed PHY consumer.

In a subsequent change, where we allow "managed" (e.g: (RS)GMII in-band
status auto-negotiation) fixed PHYs, none of these parameters can be
provided since they will be auto-negotiated, hence, we just provide a
zero-initialized fixed_phy_status to fixed_phy_register() which makes it
fail when we call fixed_phy_update_regs() since status.speed = 0 which
makes us hit the "default" label and error out.

Without this change, we would also see potentially inconsistent
speed/duplex parameters for fixed PHYs when the link is DOWN.

CC: netdev@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
[florian: add more background to why this is correct and desirable]
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/fixed_phy.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index 1960b46add65..479b93f9581c 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -52,6 +52,10 @@ static int fixed_phy_update_regs(struct fixed_phy *fp)
 	u16 lpagb = 0;
 	u16 lpa = 0;
 
+	if (!fp->status.link)
+		goto done;
+	bmsr |= BMSR_LSTATUS | BMSR_ANEGCOMPLETE;
+
 	if (fp->status.duplex) {
 		bmcr |= BMCR_FULLDPLX;
 
@@ -96,15 +100,13 @@ static int fixed_phy_update_regs(struct fixed_phy *fp)
 		}
 	}
 
-	if (fp->status.link)
-		bmsr |= BMSR_LSTATUS | BMSR_ANEGCOMPLETE;
-
 	if (fp->status.pause)
 		lpa |= LPA_PAUSE_CAP;
 
 	if (fp->status.asym_pause)
 		lpa |= LPA_PAUSE_ASYM;
 
+done:
 	fp->regs[MII_PHYSID1] = 0;
 	fp->regs[MII_PHYSID2] = 0;
 
-- 
2.1.0


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

* [PATCH net v5 3/4] of_mdio: add new DT property 'managed' to specify the PHY management type
  2015-07-21  0:49 [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested Florian Fainelli
  2015-07-21  0:49 ` [PATCH net v5 1/4] net: dsa: bcm_sf2: Do not override speed settings Florian Fainelli
  2015-07-21  0:49 ` [PATCH net v5 2/4] net: phy: fixed_phy: handle link-down case Florian Fainelli
@ 2015-07-21  0:49 ` Florian Fainelli
  2015-07-21  0:49 ` [PATCH net v5 4/4] mvneta: use inband status only when explicitly enabled Florian Fainelli
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2015-07-21  0:49 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-kernel, mxs, arno, stsp, devicetree,
	thomas.petazzoni, Stas Sergeev, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Florian Fainelli,
	Grant Likely

From: Stas Sergeev <stsp@list.ru>

Currently the PHY management type is selected by the MAC driver arbitrary.
The decision is based on the presence of the "fixed-link" node and on a
will of the driver's authors.
This caused a regression recently, when mvneta driver suddenly started
to use the in-band status for auto-negotiation on fixed links.
It appears the auto-negotiation may not work when expected by the MAC driver.
Sebastien Rannou explains:
<< Yes, I confirm that my HW does not generate an in-band status. AFAIK, it's
a PHY that aggregates 4xSGMIIs to 1xQSGMII ; the MAC side of the PHY (with
inband status) is connected to the switch through QSGMII, and in this context
we are on the media side of the PHY. >>
https://lkml.org/lkml/2015/7/10/206

This patch introduces the new string property 'managed' that allows
the user to set the management type explicitly.
The supported values are:
"auto" - default. Uses either MDIO or nothing, depending on the presence
of the fixed-link node
"in-band-status" - use in-band status

Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>

CC: Rob Herring <robh+dt@kernel.org>
CC: Pawel Moll <pawel.moll@arm.com>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Ian Campbell <ijc+devicetree@hellion.org.uk>
CC: Kumar Gala <galak@codeaurora.org>
CC: Florian Fainelli <f.fainelli@gmail.com>
CC: Grant Likely <grant.likely@linaro.org>
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: netdev@vger.kernel.org
---
 Documentation/devicetree/bindings/net/ethernet.txt |  4 ++++
 drivers/of/of_mdio.c                               | 19 +++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt
index 41b3f3f864e8..5d88f37480b6 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -25,7 +25,11 @@ The following properties are common to the Ethernet controllers:
   flow control thresholds.
 - tx-fifo-depth: the size of the controller's transmit fifo in bytes. This
   is used for components that can have configurable fifo sizes.
+- managed: string, specifies the PHY management type. Supported values are:
+  "auto", "in-band-status". "auto" is the default, it usess MDIO for
+  management if fixed-link is not specified.
 
 Child nodes of the Ethernet controller are typically the individual PHY devices
 connected via the MDIO bus (sometimes the MDIO bus controller is separate).
 They are described in the phy.txt file in this same directory.
+For non-MDIO PHY management see fixed-link.txt.
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index fdc60db60829..7c8c23cc6896 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -266,7 +266,8 @@ EXPORT_SYMBOL(of_phy_attach);
 bool of_phy_is_fixed_link(struct device_node *np)
 {
 	struct device_node *dn;
-	int len;
+	int len, err;
+	const char *managed;
 
 	/* New binding */
 	dn = of_get_child_by_name(np, "fixed-link");
@@ -275,6 +276,10 @@ bool of_phy_is_fixed_link(struct device_node *np)
 		return true;
 	}
 
+	err = of_property_read_string(np, "managed", &managed);
+	if (err == 0 && strcmp(managed, "auto") != 0)
+		return true;
+
 	/* Old binding */
 	if (of_get_property(np, "fixed-link", &len) &&
 	    len == (5 * sizeof(__be32)))
@@ -289,8 +294,18 @@ int of_phy_register_fixed_link(struct device_node *np)
 	struct fixed_phy_status status = {};
 	struct device_node *fixed_link_node;
 	const __be32 *fixed_link_prop;
-	int len;
+	int len, err;
 	struct phy_device *phy;
+	const char *managed;
+
+	err = of_property_read_string(np, "managed", &managed);
+	if (err == 0) {
+		if (strcmp(managed, "in-band-status") == 0) {
+			/* status is zeroed, namely its .link member */
+			phy = fixed_phy_register(PHY_POLL, &status, np);
+			return IS_ERR(phy) ? PTR_ERR(phy) : 0;
+		}
+	}
 
 	/* New binding */
 	fixed_link_node = of_get_child_by_name(np, "fixed-link");
-- 
2.1.0


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

* [PATCH net v5 4/4] mvneta: use inband status only when explicitly enabled
  2015-07-21  0:49 [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested Florian Fainelli
                   ` (2 preceding siblings ...)
  2015-07-21  0:49 ` [PATCH net v5 3/4] of_mdio: add new DT property 'managed' to specify the PHY management type Florian Fainelli
@ 2015-07-21  0:49 ` Florian Fainelli
  2015-07-21 11:17 ` [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested Stas Sergeev
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2015-07-21  0:49 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-kernel, mxs, arno, stsp, devicetree,
	thomas.petazzoni, Stas Sergeev

From: Stas Sergeev <stsp@list.ru>

The commit 898b2970e2c9 ("mvneta: implement SGMII-based in-band link state
signaling") implemented the link parameters auto-negotiation unconditionally.
Unfortunately it appears that some HW that implements SGMII protocol,
doesn't generate the inband status, so it is not possible to auto-negotiate
anything with such HW.

This patch enables the auto-negotiation only if explicitly requested with
the 'managed' DT property.

This patch fixes the following regression:
https://lkml.org/lkml/2015/7/8/865

Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>

CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
CC: netdev@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/marvell/mvneta.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 370e20ed224c..e4fb172d91a6 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3029,8 +3029,8 @@ static int mvneta_probe(struct platform_device *pdev)
 	const char *dt_mac_addr;
 	char hw_mac_addr[ETH_ALEN];
 	const char *mac_from;
+	const char *managed;
 	int phy_mode;
-	int fixed_phy = 0;
 	int err;
 
 	/* Our multiqueue support is not complete, so for now, only
@@ -3064,7 +3064,6 @@ static int mvneta_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "cannot register fixed PHY\n");
 			goto err_free_irq;
 		}
-		fixed_phy = 1;
 
 		/* In the case of a fixed PHY, the DT node associated
 		 * to the PHY is the Ethernet MAC DT node.
@@ -3088,8 +3087,10 @@ static int mvneta_probe(struct platform_device *pdev)
 	pp = netdev_priv(dev);
 	pp->phy_node = phy_node;
 	pp->phy_interface = phy_mode;
-	pp->use_inband_status = (phy_mode == PHY_INTERFACE_MODE_SGMII) &&
-				fixed_phy;
+
+	err = of_property_read_string(dn, "managed", &managed);
+	pp->use_inband_status = (err == 0 &&
+				 strcmp(managed, "in-band-status") == 0);
 
 	pp->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(pp->clk)) {
-- 
2.1.0


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

* Re: [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested
  2015-07-21  0:49 [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested Florian Fainelli
                   ` (3 preceding siblings ...)
  2015-07-21  0:49 ` [PATCH net v5 4/4] mvneta: use inband status only when explicitly enabled Florian Fainelli
@ 2015-07-21 11:17 ` Stas Sergeev
  2015-07-21 20:18 ` Arnaud Ebalard
  2015-07-21 23:13 ` David Miller
  6 siblings, 0 replies; 8+ messages in thread
From: Stas Sergeev @ 2015-07-21 11:17 UTC (permalink / raw)
  To: Florian Fainelli, netdev
  Cc: davem, linux-kernel, mxs, arno, stsp, devicetree, thomas.petazzoni

21.07.2015 03:49, Florian Fainelli пишет:
> Hi all,
>
> Changes in v5:
>
> - removed an invalid use of the link_update callback in the SF2 driver
>    was appeared after merging "net: phy: fixed_phy: handle link-down case"
Thanks for bringing this forward!
For the future, perhaps it will make sense to also
teach phylib to never read link status (including speed)
when link is down. Will help to narrow more of such problems.

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

* Re: [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested
  2015-07-21  0:49 [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested Florian Fainelli
                   ` (4 preceding siblings ...)
  2015-07-21 11:17 ` [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested Stas Sergeev
@ 2015-07-21 20:18 ` Arnaud Ebalard
  2015-07-21 23:13 ` David Miller
  6 siblings, 0 replies; 8+ messages in thread
From: Arnaud Ebalard @ 2015-07-21 20:18 UTC (permalink / raw)
  To: Florian Fainelli, stsp
  Cc: netdev, davem, linux-kernel, mxs, devicetree, thomas.petazzoni

Hi guys,

Florian Fainelli <f.fainelli@gmail.com> writes:

> Changes in v5:
>
> - removed an invalid use of the link_update callback in the SF2 driver
>   was appeared after merging "net: phy: fixed_phy: handle link-down case"
>
> - reworded the commit message for patch 2 to make it clear what it fixes and
>   why this is required
>
> Initial cover letter from Stas:
>
> Hello.
>
> Currently the link status auto-negotiation is enabled
> for any SGMII link with fixed-link DT binding.
> The regression was reported:
> https://lkml.org/lkml/2015/7/8/865
> Apparently not all HW that implements SGMII protocol, generates the
> inband status for the auto-negotiation to work.
> More details here:
> https://lkml.org/lkml/2015/7/10/206
>
> The following patches reverts to the old behavior by default,
> which is to not enable the auto-negotiation for fixed-link.
> The new DT property is added that allows to explicitly request
> the auto-negotiation.

FWIW, I tested this v5 series on mirabox (2 mvneta interfaces using
RGMII); both interfaces still work as expected, i.e. no regression
on my side.

a+

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

* Re: [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested
  2015-07-21  0:49 [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested Florian Fainelli
                   ` (5 preceding siblings ...)
  2015-07-21 20:18 ` Arnaud Ebalard
@ 2015-07-21 23:13 ` David Miller
  6 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2015-07-21 23:13 UTC (permalink / raw)
  To: f.fainelli
  Cc: netdev, linux-kernel, mxs, arno, stsp, devicetree, thomas.petazzoni

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon, 20 Jul 2015 17:49:54 -0700

> Changes in v5:
> 
> - removed an invalid use of the link_update callback in the SF2 driver
>   was appeared after merging "net: phy: fixed_phy: handle link-down case"
> 
> - reworded the commit message for patch 2 to make it clear what it fixes and
>   why this is required

Series applied, thanks Florian.

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

end of thread, other threads:[~2015-07-21 23:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-21  0:49 [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested Florian Fainelli
2015-07-21  0:49 ` [PATCH net v5 1/4] net: dsa: bcm_sf2: Do not override speed settings Florian Fainelli
2015-07-21  0:49 ` [PATCH net v5 2/4] net: phy: fixed_phy: handle link-down case Florian Fainelli
2015-07-21  0:49 ` [PATCH net v5 3/4] of_mdio: add new DT property 'managed' to specify the PHY management type Florian Fainelli
2015-07-21  0:49 ` [PATCH net v5 4/4] mvneta: use inband status only when explicitly enabled Florian Fainelli
2015-07-21 11:17 ` [PATCH net v5 0/4] net: enable inband link state negotiation only when explicitly requested Stas Sergeev
2015-07-21 20:18 ` Arnaud Ebalard
2015-07-21 23:13 ` 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).