Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3249017pxb; Tue, 20 Apr 2021 04:12:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyes/nhidtjWW0xjemkOjVljkoeXio13G3ihxjSYgAYMqom5dYjeMkJ6rOoR1Wd4nPl6wdl X-Received: by 2002:a63:df09:: with SMTP id u9mr9397555pgg.112.1618917157921; Tue, 20 Apr 2021 04:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618917157; cv=none; d=google.com; s=arc-20160816; b=N4TIWClcIumwB0rMFLPJAgUc6RByGKr7zN/u4fGNKcAdiEVT8JGqty0ZSZPOcE2axK q4lbOyPaz4nq40DHIPLoN8TGXP0WCyHK4CqDrBb01yS87ePW6pnTnclXk/L+KJFm9Mjz fmX8w/u/CUNY86zHvopha0ldHmvgWKS5duPtpeY6PNFcKp/IK/qe0CGfQoVxP+9JpbCq FHe70wYYyy/vL1wM5huJjqqBp6EOWWfpsTdlMD2N7JJg3eZVOZ+l/jqUsDSUGhfrPBVo s8B3KXHqK6xUmF7uhm09Jd0PFQqw4ep5LWV7swFMizs5jEIQzuFFSc3DO4jFzBAKFDjg m5jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=rjtqSOEqm6ZUj7mOHnoTE0CWjTR9WXv5TiepWP/7rDM=; b=XKXmMwZpw6IbuePtapQNzRegj0S7lrYVxj7N+4rfCMVAOBVEyngN3i9MqDY9tcaqjb kZcX4Ay7SVIlnPYF+H5QYlDd4mOvostS+RtBGjn6RfkkMWEjp9W7/gSZbHNR7ytJLbHk zGYYfKWLvx2KLOUDty0n2bBgLbIs+4LiRcjGRMCwFKkfsqlTc0ktxbRG6J8aLOQ9wfja a2typ0VGjPVZQ5Z+aqZj4P2M72K2t/a0kWH+v+UFTearXqPeq0Z2QuPmdpHNM6+84lga YseiGNH4u/uGnmz88ESD9NapvYRk+5Ed6UPOeGFNEm7Vlv92901QhQCYldbnLLKuERPx i8Zw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si21057816plt.228.2021.04.20.04.12.25; Tue, 20 Apr 2021 04:12:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231688AbhDTLML (ORCPT + 99 others); Tue, 20 Apr 2021 07:12:11 -0400 Received: from perseus.uberspace.de ([95.143.172.134]:57840 "EHLO perseus.uberspace.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231388AbhDTLMK (ORCPT ); Tue, 20 Apr 2021 07:12:10 -0400 X-Greylist: delayed 401 seconds by postgrey-1.27 at vger.kernel.org; Tue, 20 Apr 2021 07:12:09 EDT Received: (qmail 15708 invoked from network); 20 Apr 2021 11:04:55 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by perseus.uberspace.de with SMTP; 20 Apr 2021 11:04:55 -0000 Subject: Re: [PATCH net-next v2] net: phy: at803x: fix probe error if copper page is selected To: Michael Walle , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski References: <20210420102929.13505-1-michael@walle.cc> From: David Bauer Message-ID: Date: Tue, 20 Apr 2021 13:04:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <20210420102929.13505-1-michael@walle.cc> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 4/20/21 12:29 PM, Michael Walle wrote: > The commit c329e5afb42f ("net: phy: at803x: select correct page on > config init") selects the copper page during probe. This fails if the > copper page was already selected. In this case, the value of the copper > page (which is 1) is propagated through phy_restore_page() and is > finally returned for at803x_probe(). Fix it, by just using the > at803x_page_write() directly. Ouch, i didn't spot that. Thanks for taking care. > > Also in case of an error, the regulator is not disabled and leads to a > WARN_ON() when the probe fails. This couldn't happen before, because > at803x_parse_dt() was the last call in at803x_probe(). It is hard to > see, that the parse_dt() actually enables the regulator. Thus move the > regulator_enable() to the probe function and undo it in case of an > error. > > Fixes: c329e5afb42f ("net: phy: at803x: select correct page on config init") > Signed-off-by: Michael Walle Reviewed-by: David Bauer Best David > --- > Changes since v1: > - take the bus lock > > drivers/net/phy/at803x.c | 23 +++++++++++++++++------ > 1 file changed, 17 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c > index e0f56850edc5..32af52dd5aed 100644 > --- a/drivers/net/phy/at803x.c > +++ b/drivers/net/phy/at803x.c > @@ -554,10 +554,6 @@ static int at803x_parse_dt(struct phy_device *phydev) > phydev_err(phydev, "failed to get VDDIO regulator\n"); > return PTR_ERR(priv->vddio); > } > - > - ret = regulator_enable(priv->vddio); > - if (ret < 0) > - return ret; > } > > return 0; > @@ -579,15 +575,30 @@ static int at803x_probe(struct phy_device *phydev) > if (ret) > return ret; > > + if (priv->vddio) { > + ret = regulator_enable(priv->vddio); > + if (ret < 0) > + return ret; > + } > + > /* Some bootloaders leave the fiber page selected. > * Switch to the copper page, as otherwise we read > * the PHY capabilities from the fiber side. > */ > if (at803x_match_phy_id(phydev, ATH8031_PHY_ID)) { > - ret = phy_select_page(phydev, AT803X_PAGE_COPPER); > - ret = phy_restore_page(phydev, AT803X_PAGE_COPPER, ret); > + phy_lock_mdio_bus(phydev); > + ret = at803x_write_page(phydev, AT803X_PAGE_COPPER); > + phy_unlock_mdio_bus(phydev); > + if (ret) > + goto err; > } > > + return 0; > + > +err: > + if (priv->vddio) > + regulator_disable(priv->vddio); > + > return ret; > } > >