Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp43806lfe; Fri, 15 Apr 2022 18:35:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwN0bEaQ/vSMorNAlidirmRAVR+jt8rb82cbZTIL6VuN+a/n3chAa4XVyyQGFBXjKqfibYx X-Received: by 2002:a17:90b:3ec6:b0:1cb:2a03:ec8d with SMTP id rm6-20020a17090b3ec600b001cb2a03ec8dmr1667844pjb.79.1650072939821; Fri, 15 Apr 2022 18:35:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650072939; cv=none; d=google.com; s=arc-20160816; b=p1/wGk7rIgeMomW6d0P4Ybh3r4nwmgN+1qgK7VOe2nFMCPnEuo7P7Q1mUoB3cxi9Cf /EBnaH5YEGm+GD5GMShRGEHkTkPnMhsTmy75/23xUxl/tUQD9v53HjUkyNJMB/0JwE0G AZXqNXt/oHqga2N9FLNHs3yN9YdzkmcUWq6T5enmME6QJXCfOJasU8sTroMZkcweAAaM KsXkhj9In4VlGSrtSjezkdqfToZ0slQQ9svxPbXPFGRTi+pGPelK2sDrZt12qxLK5nN0 nApi78JATMlN1Fmm2y78rnoFl54LPpH9Qv98N/AaoQTUq23/n24cYUNSN0UboP4L64xH h94Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tyF08E4+rFHmhb2z3LEBmmV0HluyXdglH/nyQTVQtPI=; b=o4bY3lAiryqoRCVB6E5bgxf7icCEI6+MBbBhaHnRqX7dKnxWV7OvZFqw6nkD4i9OVM IYpw+tNwMwiEZF7TlEByt4MBIrhwz5BujQJZzb95c2hbOBuTWO2LBA/dhFcu5q3J5/Q7 jKZbYlGxYbQApX3ritBBceI/+Raw9uY+7WSbFRHV448RWOvCWWz9S5XrIz88NnT24QPs ReV5uDAK3ukYZ4gHlhE8ZuIQLtjYkevzmBH1+yK4CGgA+KmpOiVHesnGI6Kc8xqWYYaf 4f0O8YIqwnzJ7107OD6o9r4gfeTGNFlDAMxDao8vx3mjRbg5vpns9ptYKF2iFPyEgnp2 iKFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vc3J98ex; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r17-20020a170902be1100b00153bc4c0a7fsi2476230pls.593.2022.04.15.18.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:35:39 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vc3J98ex; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A701B15B983; Fri, 15 Apr 2022 18:02:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346059AbiDNNz3 (ORCPT + 99 others); Thu, 14 Apr 2022 09:55:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245465AbiDNN27 (ORCPT ); Thu, 14 Apr 2022 09:28:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B07313F74; Thu, 14 Apr 2022 06:22:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 24FFAB82987; Thu, 14 Apr 2022 13:22:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6888AC385A1; Thu, 14 Apr 2022 13:22:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649942572; bh=MhbVDkR2xA2otRvtCUnVfjn/M07uTiXjhK6YPmb0k9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vc3J98ex1CIDLg0E9oTv4EylhluJFrdNURBUZcgnLwea8eU0j3kTGZI5TctIe09Ls 156n1FyWtDMSSfdXxOuMVSd8jrNTsaGJZhGwgHrbXCiHFcQJXk0VpnCyohcMWbLGg+ hoPWwk2zp03czDSuR9yBXnZUw4lE3gLr+m/rZi9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.19 183/338] net: phy: broadcom: Fix brcm_fet_config_init() Date: Thu, 14 Apr 2022 15:11:26 +0200 Message-Id: <20220414110844.107724712@linuxfoundation.org> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220414110838.883074566@linuxfoundation.org> References: <20220414110838.883074566@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Fainelli [ Upstream commit bf8bfc4336f7a34e48b3bbd19b1542bf085bdc3d ] A Broadcom AC201 PHY (same entry as 5241) would be flagged by the Broadcom UniMAC MDIO controller as not completing the turn around properly since the PHY expects 65 MDC clock cycles to complete a write cycle, and the MDIO controller was only sending 64 MDC clock cycles as determined by looking at a scope shot. This would make the subsequent read fail with the UniMAC MDIO controller command field having MDIO_READ_FAIL set and we would abort the brcm_fet_config_init() function and thus not probe the PHY at all. After issuing a software reset, wait for at least 1ms which is well above the 1us reset delay advertised by the datasheet and issue a dummy read to let the PHY turn around the line properly. This read specifically ignores -EIO which would be returned by MDIO controllers checking for the line being turned around. If we have a genuine reaad failure, the next read of the interrupt status register would pick it up anyway. Fixes: d7a2ed9248a3 ("broadcom: Add AC131 phy support") Signed-off-by: Florian Fainelli Link: https://lore.kernel.org/r/20220324232438.1156812-1-f.fainelli@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/phy/broadcom.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c index e86ea105c802..94622d119abc 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c @@ -15,6 +15,7 @@ */ #include "bcm-phy-lib.h" +#include #include #include #include @@ -462,6 +463,26 @@ static int brcm_fet_config_init(struct phy_device *phydev) if (err < 0) return err; + /* The datasheet indicates the PHY needs up to 1us to complete a reset, + * build some slack here. + */ + usleep_range(1000, 2000); + + /* The PHY requires 65 MDC clock cycles to complete a write operation + * and turnaround the line properly. + * + * We ignore -EIO here as the MDIO controller (e.g.: mdio-bcm-unimac) + * may flag the lack of turn-around as a read failure. This is + * particularly true with this combination since the MDIO controller + * only used 64 MDC cycles. This is not a critical failure in this + * specific case and it has no functional impact otherwise, so we let + * that one go through. If there is a genuine bus error, the next read + * of MII_BRCM_FET_INTREG will error out. + */ + err = phy_read(phydev, MII_BMCR); + if (err < 0 && err != -EIO) + return err; + reg = phy_read(phydev, MII_BRCM_FET_INTREG); if (reg < 0) return reg; -- 2.34.1