netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tommy Christensen <tommy.christensen@tpack.net>
To: Bogdan Costescu <Bogdan.Costescu@iwr.uni-heidelberg.de>
Cc: Jeff Garzik <jgarzik@pobox.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>,
	Netdev List <netdev@vger.kernel.org>
Subject: Re: [PATCH] 3c59x: read current link status from phy
Date: Fri, 09 Sep 2005 00:39:18 +0200	[thread overview]
Message-ID: <4320BD96.3060307@tpack.net> (raw)
In-Reply-To: <Pine.LNX.4.63.0509081713500.22954@dingo.iwr.uni-heidelberg.de>

[-- Attachment #1: Type: text/plain, Size: 984 bytes --]

Bogdan Costescu wrote:
> I now understood what the problem was, so I'll put it in words for 
> posterity: the Link Status bit of the MII Status register needs to be 
> read twice to first clear the error state (link bit=0) after which the 
> bit reports the actual value of the link. From the manual:

Yes, this is exactly the point.

> But I still don't agree with your solution: you are reading the Status 
> register twice in all cases, which is wrong. What you want is to read it 
> a second time only after the link was marked as down: a simple check if 
> bit 2 of the Status register is 0, in which case you issue the second 
> read. This still means that there will be 2 reads if the link remains 
> down, but at least there is only 1 read for the case where the link is 
> up and remains up.

I don't think this makes much of a difference in the big picture, but
you're certainly right: let's not waste more cycles than we have to.

Can we agree on the patch below?


-Tommy

[-- Attachment #2: 3c59x-carrier.patch --]
[-- Type: text/plain, Size: 806 bytes --]

[3c59x] Avoid blindly reading link status twice

In order to spare some I/O operations, be more intelligent about
when to read from the PHY.

Pointed out by Bogdan Costescu.

Signed-off-by: Tommy S. Christensen <tommy.christensen@tpack.net>


--- linux-2.6.13-git8/drivers/net/3c59x.c-orig	Fri Sep  9 00:05:49 2005
+++ linux-2.6.13-git8/drivers/net/3c59x.c	Fri Sep  9 00:13:55 2005
@@ -1889,7 +1889,9 @@ vortex_timer(unsigned long data)
 		{
 			spin_lock_bh(&vp->lock);
 			mii_status = mdio_read(dev, vp->phys[0], 1);
-			mii_status = mdio_read(dev, vp->phys[0], 1);
+			if (!(mii_status & BMSR_LSTATUS))
+				/* Re-read to get actual link status */
+				mii_status = mdio_read(dev, vp->phys[0], 1);
 			ok = 1;
 			if (vortex_debug > 2)
 				printk(KERN_DEBUG "%s: MII transceiver has status %4.4x.\n",

  parent reply	other threads:[~2005-09-08 22:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200509080125.j881PcL9015847@hera.kernel.org>
2005-09-08  1:49 ` [PATCH] 3c59x: read current link status from phy Jeff Garzik
2005-09-08 11:58   ` Bogdan Costescu
2005-09-08 13:05     ` Tommy Christensen
2005-09-08 13:35       ` Bogdan Costescu
2005-09-08 14:42         ` Tommy Christensen
2005-09-08 15:42           ` Bogdan Costescu
2005-09-08 18:56             ` Andy Fleming
2005-09-09 10:10               ` Bogdan Costescu
2005-09-09 18:08                 ` Andy Fleming
2005-09-08 22:39             ` Tommy Christensen [this message]
2005-09-08 22:41               ` Andrew Morton
2005-09-08 23:12                 ` Tommy Christensen
2005-09-09  0:01                   ` Jeff Garzik
2005-09-09  1:08               ` John W. Linville
2005-09-09  7:34                 ` Tommy Christensen
2005-09-09  7:44                   ` Andrew Morton
2005-09-09 11:35                     ` Neil Horman
2005-09-08 14:13   ` [PATCH] 3c59x: cleanup of mdio_read routines to use MII_* macros in include/linux/mii.h Neil Horman

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=4320BD96.3060307@tpack.net \
    --to=tommy.christensen@tpack.net \
    --cc=Bogdan.Costescu@iwr.uni-heidelberg.de \
    --cc=akpm@osdl.org \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).