From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759140Ab0CMMwu (ORCPT ); Sat, 13 Mar 2010 07:52:50 -0500 Received: from www84.your-server.de ([213.133.104.84]:45133 "EHLO www84.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757441Ab0CMMws (ORCPT ); Sat, 13 Mar 2010 07:52:48 -0500 Subject: [PATCH] fix PHY polling system blocking From: Stefani Seibold To: linux-kernel , netdev@vger.kernel.org Content-Type: text/plain; charset="ISO-8859-15" Date: Sat, 13 Mar 2010 13:53:10 +0100 Message-ID: <1268484790.6339.37.camel@wall-e> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3.1 Content-Transfer-Encoding: 7bit X-Authenticated-Sender: stefani@seibold.net Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fix the PHY poller, which can block the whole system. PHY access are normaly not very fast, since there are serial attached. For PHY chips without interrupts, the status of the ethernet will be polled every 2 sec. The poll function will read some register of the MII PHY. The time between the sending the MII_READ_COMMAND and receiving the result could be very long (>100us). For example: On a Freescale PPC 834x this result in a delay of 450 us due the slow communication with the PHY chip. The time between the sending the MII_READ_COMMAND and receiving the result is more the 100 us on this controller. The patch modifies the poller a lit bit. Only a link status state change will result in a successive detection of the connection type. The poll cycle on the other hand will be increased to one every seconds. All in all this patch will prevent a blocking of f.e nearly 400 us every two seconds of the whole system on a PPC 834x. There is not real drawback, only the detection of a connection type change without unplugging the cable will not work. But this is more an esoteric use case. The patch is against kernel 2.6.33. Please merge it. Signed-off-by: Stefani Seibold --- phy.c | 5 ++--- phy_device.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff -u -N -r -p linux-2.6.33.orig/drivers/net/phy/phy.c linux-2.6.33/drivers/net/phy/phy.c --- linux-2.6.33.orig/drivers/net/phy/phy.c 2010-02-24 19:52:17.000000000 +0100 +++ linux-2.6.33/drivers/net/phy/phy.c 2010-02-28 22:53:14.725464101 +0100 @@ -871,9 +871,8 @@ void phy_state_machine(struct work_struc case PHY_RUNNING: /* Only register a CHANGE if we are * polling */ - if (PHY_POLL == phydev->irq) - phydev->state = PHY_CHANGELINK; - break; + if (PHY_POLL != phydev->irq) + break; case PHY_CHANGELINK: err = phy_read_status(phydev); diff -u -N -r -p linux-2.6.33.orig/drivers/net/phy/phy_device.c linux-2.6.33/drivers/net/phy/phy_device.c --- linux-2.6.33.orig/drivers/net/phy/phy_device.c 2010-02-24 19:52:17.000000000 +0100 +++ linux-2.6.33/drivers/net/phy/phy_device.c 2010-02-28 22:53:14.726464145 +0100 @@ -161,7 +161,7 @@ struct phy_device* phy_device_create(str dev->speed = 0; dev->duplex = -1; dev->pause = dev->asym_pause = 0; - dev->link = 1; + dev->link = 0; dev->interface = PHY_INTERFACE_MODE_GMII; dev->autoneg = AUTONEG_ENABLE; @@ -694,10 +694,15 @@ int genphy_update_link(struct phy_device if (status < 0) return status; - if ((status & BMSR_LSTATUS) == 0) + if ((status & BMSR_LSTATUS) == 0) { + if (phydev->link == 0) + return 1; phydev->link = 0; - else + } else { + if (phydev->link == 1) + return 1; phydev->link = 1; + } return 0; }