netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, linux-kernel@vger.kernel.org, mxs@sbrk.org,
	arno@natisbad.org, stsp@users.sourceforge.net,
	devicetree@vger.kernel.org, thomas.petazzoni@free-electrons.com,
	Stas Sergeev <stsp@list.ru>,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net v5 2/4] net: phy: fixed_phy: handle link-down case
Date: Mon, 20 Jul 2015 17:49:56 -0700	[thread overview]
Message-ID: <1437439798-12622-3-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1437439798-12622-1-git-send-email-f.fainelli@gmail.com>

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

  parent reply	other threads:[~2015-07-21  0:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
     [not found] ` <1437439798-12622-1-git-send-email-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-07-21 23:13   ` David Miller

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=1437439798-12622-3-git-send-email-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=arno@natisbad.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mxs@sbrk.org \
    --cc=netdev@vger.kernel.org \
    --cc=stsp@list.ru \
    --cc=stsp@users.sourceforge.net \
    --cc=thomas.petazzoni@free-electrons.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).