From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755490AbdLUUSX (ORCPT ); Thu, 21 Dec 2017 15:18:23 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:27407 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753381AbdLUUSV (ORCPT ); Thu, 21 Dec 2017 15:18:21 -0500 Subject: Re: [PATCH] net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround To: Andrew Lunn CC: Florian Fainelli , , , Sekhar Nori References: <20171221004510.29715-1-grygorii.strashko@ti.com> <20171221092112.GD6683@lunn.ch> From: Grygorii Strashko Message-ID: <2955148a-71bb-6923-4c90-d05146e063de@ti.com> Date: Thu, 21 Dec 2017 14:18:09 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171221092112.GD6683@lunn.ch> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [128.247.59.147] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/21/2017 03:21 AM, Andrew Lunn wrote: > On Wed, Dec 20, 2017 at 06:45:10PM -0600, Grygorii Strashko wrote: >> Under some circumstances driver will perform PHY reset in >> ksz9031_read_status() to fix autoneg failure case (idle error count = >> 0xFF). When this happens ksz9031 will not detect link status change any >> more when connecting to Netgear 1G switch (link can be recovered sometimes by >> restarting netdevice "ifconfig down up"). Reproduced with TI am572x board >> equipped with ksz9031 PHY while connecting to Netgear 1G switch. >> >> Fix the issue by reconfiguring autonegotiation after PHY reset in >> ksz9031_read_status(). > > Hi Grygorii > > I can understand the fix. > > But i'm wondering if there is a better way to do this. Can you call > phy_stop() and phy_start(). You then get the core phy code doing the > same initialisation as what happened the first time. However, i know > this is not easy. _read_status() is being called from the middle of > the state machine, and trying to change the state of the state machine > at this point is problematic. It will not work. phy_state_machine()->mutex_lock(&phydev->lock);->phy_read_status()->phy_stop()->mutex_lock(&phydev->lock); at least as is. This is error recovery, which is, per my understanding, signalizing about hw or configuration issue. What i'm thinking about is - may be it'll be reasonable to add err message here: if ((regval & 0xFF) == 0xFF) { + dev_err_once(&phydev->mdio.dev, + "PHY reset due idle error count maxed out"); -- regards, -grygorii