From patchwork Fri Jun 19 18:47:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 1313302 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=joFKgenJ; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49pSVl3Ht7z9sVX for ; Sat, 20 Jun 2020 04:48:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436723AbgFSSsK (ORCPT ); Fri, 19 Jun 2020 14:48:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436712AbgFSSsI (ORCPT ); Fri, 19 Jun 2020 14:48:08 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7C6EC06174E; Fri, 19 Jun 2020 11:48:07 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id r9so9339881wmh.2; Fri, 19 Jun 2020 11:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3Whs9U2dRSpE/yNJ0hr4nOfl15DSo7ufbKnlcVibON0=; b=joFKgenJRDWLWoYPYWpZbACMvmmtHjzFTkJO26jbPB9oEUUDXakyuHH4RslDWv0kTA 0RYTjJ4QxfK87fa9LHzx0W34y0Nf4/wC3AkmlXVXycMJnpTyWNQytrWaa1nn3gus2dQq Sv34LyTBKbf++QYd0XxmyWa9+1l5cjEd8hVS2Dj8/en9q8BOYVvqhCZ9ddOnWXMyo6N4 2cQMgjnNcmZejQyxelvzqE0WZWB3sZWQ8BX+fg6Xkf9VThDp9TRU+xg89DpanGDFQtYR NbZu3Yab11Ueu7U6mTuQ8OZxVSRKCdjpgzK6eg3T/lu9edH8AjKi2T6qgh4lB/DIZrpj tz8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3Whs9U2dRSpE/yNJ0hr4nOfl15DSo7ufbKnlcVibON0=; b=tndOXzmfNWL2auRpF2vnDjqXKpr345ROrwa3XPnES8l2JbikEgD5sdrzFvjDpyi2D0 yHFtziYzKqIhZK9KV72belZ99UoGU7l/NgRkg+cr6lx4suUkh6jVXT10nZHelFFhieit NGkr/PLlEn8Q1WVnMDw7kxGmNrMt0xjOR3umFw5EGukrcHBJWGY2zKiKUPXh8xgEh0T6 GsgeVTNAC/SJF3/cXv8n7EOxmD2BS143wif3b/+YIske2BYbZfIIeEZ/BdNcO+W3Q7oA kaQVEj0B7W5TTGzQ1FGDH6J5JlLjyyivaHG2gE8Y5+gz+Wshi+Vj3Mg2itcl26NariMT 5ogg== X-Gm-Message-State: AOAM53228VWZhO5alemD7KVKJasVX9Q0k+Wr7uYZWZlDD+829dNdkJJW W2xeNXWYtOFJn7ltseIXQxZLc6nq X-Google-Smtp-Source: ABdhPJwA4vEG2fwJzEOu1QDvZNpPXDY0gUgNGWH2NXKjcens+gwoTzLZMN8JAF5I3KrCNbFbE4+/sQ== X-Received: by 2002:a7b:c0c8:: with SMTP id s8mr5315469wmh.134.1592592485614; Fri, 19 Jun 2020 11:48:05 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id l17sm7283143wmi.3.2020.06.19.11.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 11:48:05 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Rob Herring , Frank Rowand , Dajun Jin , Alexandre Belloni , linux-kernel@vger.kernel.org (open list), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE) Subject: [PATCH net v2 2/2] net: phy: Check harder for errors in get_phy_id() Date: Fri, 19 Jun 2020 11:47:47 -0700 Message-Id: <20200619184747.16606-3-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200619184747.16606-1-f.fainelli@gmail.com> References: <20200619184747.16606-1-f.fainelli@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit 02a6efcab675 ("net: phy: allow scanning busses with missing phys") added a special condition to return -ENODEV in case -ENODEV or -EIO was returned from the first read of the MII_PHYSID1 register. In case the MDIO bus data line pull-up is not strong enough, the MDIO bus controller will not flag this as a read error. This can happen when a pluggable daughter card is not connected and weak internal pull-ups are used (since that is the only option, otherwise the pins are floating). The second read of MII_PHYSID2 will be correctly flagged an error though, but now we will return -EIO which will be treated as a hard error, thus preventing MDIO bus scanning loops to continue succesfully. Apply the same logic to both register reads, thus allowing the scanning logic to proceed. Fixes: 02a6efcab675 ("net: phy: allow scanning busses with missing phys") Reviewed-by: Andrew Lunn Signed-off-by: Florian Fainelli --- drivers/net/phy/phy_device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 04946de74fa0..85ba95b598b5 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -794,8 +794,10 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id, /* Grab the bits from PHYIR2, and put them in the lower half */ phy_reg = mdiobus_read(bus, addr, MII_PHYSID2); - if (phy_reg < 0) - return -EIO; + if (phy_reg < 0) { + /* returning -ENODEV doesn't stop bus scanning */ + return (phy_reg == -EIO || phy_reg == -ENODEV) ? -ENODEV : -EIO; + } *phy_id |= phy_reg;