From patchwork Thu Oct 6 22:27:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Collins X-Patchwork-Id: 164282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 1FF54B6FD9 for ; Tue, 12 Jun 2012 09:05:54 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SeDgB-0004JE-Ek; Mon, 11 Jun 2012 23:05:47 +0000 Received: from mail-pz0-f49.google.com ([209.85.210.49]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SeDdH-0003hC-GB for kernel-team@lists.ubuntu.com; Mon, 11 Jun 2012 23:02:47 +0000 Received: by mail-pz0-f49.google.com with SMTP id m1so6348994dad.8 for ; Mon, 11 Jun 2012 16:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:in-reply-to:references:from:date:subject:to; bh=YhxPckknoXyPvirLlvc/K6r4qjIXMDL4oCOXjD239W0=; b=DlsjgOCJHUsnuGd78QByntVrwq9tRYvKtxLcGiC9rbovz5TwvQO2gX0IoqETdM1Jvp ZEGAcqCOug2sErkXQI02uJMHkLRLW4KeRt83mA42hn49zuhIQEc8GWVCzgq3Q2hj4g5T oT3e1BFuqz1LMhKJ4P97COvyUora+1XvCPxTIHBhSUb05o4dCDztIqw3Vdv+rqw5pFpy XjNxWqYCMt8y1+OUG6qJKftTSOQP31gyK81wuGH/SIghdq/wAUqcsgLTuAC5CRlSBPGl cJ/wYMb6bevdiWbPtXMm84Hcdzn20GuUgqHhUP0JvICtJixAtgpCkD8ZRRLbwlC4uGeA FqkQ== Received: by 10.68.194.6 with SMTP id hs6mr31831205pbc.133.1339455767072; Mon, 11 Jun 2012 16:02:47 -0700 (PDT) Received: from localhost (ip68-13-200-36.hr.hr.cox.net. [68.13.200.36]) by mx.google.com with ESMTPS id ns5sm1275729pbb.26.2012.06.11.16.02.44 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Jun 2012 16:02:46 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Mon, 11 Jun 2012 19:02:42 -0400 Message-Id: In-Reply-To: References: From: Madalin Bucur Date: Thu, 6 Oct 2011 22:27:36 +0000 Subject: [PATCH 21/27] UBUNTU: SAUCE: net/phy: abort genphy_read_status when link changes during speed and duplex reading To: kernel-team@lists.ubuntu.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com If the link changes during speed and duplex reading the values may be out of sync; abort the update if the link state changes during the read This patch is being maintained and will eventually be merged upstream by Freescale directly. The powerpc-e500mc flavour uses this. Signed-off-by: Madalin Bucur Signed-off-by: Ben Collins --- drivers/net/phy/phy_device.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index f53bc32..163e1e7 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -808,6 +808,16 @@ int genphy_read_status(struct phy_device *phydev) lpa &= adv; + err = phy_read(phydev, MII_BMSR); + + if (err < 0) + return err; + + /* if the link changed while reading speed and duplex + * abort the speed and duplex update */ + if (((err & BMSR_LSTATUS) == 0) != (phydev->link == 0)) + return 0; + phydev->speed = SPEED_10; phydev->duplex = DUPLEX_HALF; phydev->pause = phydev->asym_pause = 0;