Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp684343pxb; Tue, 5 Apr 2022 18:41:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUTRozl6RxaON8IXeIytWDYhKefW0GuQlQ31oXt+KA/PuF0V6gQaebARXZrvFXuqFUMILS X-Received: by 2002:a05:6402:2794:b0:419:2ea9:7de3 with SMTP id b20-20020a056402279400b004192ea97de3mr6369466ede.169.1649209296757; Tue, 05 Apr 2022 18:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649209296; cv=none; d=google.com; s=arc-20160816; b=cNVIEZZA66IINbUQiZRwyLF0kH/pG1GTAjCjY/oR0dombaOFQFvK/9tJVBPwJeZ0R/ UI2jUKrnIcTaGpujd74GSr9xgngAsfOGKX4cRZ+0nGowSS+nggD0DSheK8XeMcAXbEiE wKGomBNLUvhzMEh6eGnqSglLnjo4s0q4WJNhQ1bYpwGs1Xy/HOtjvxwusai+Zoaq/tIO h4uw2PVTdpMis5WpWUMUtV6Q9ZsVo/UJlF6+2mHZUXMR3Q+tBPvhE4HFxkl//KKEB31P P4396Q83j0DhzM23DOQ6Ls/NCFRbKP7vmn1pZQq4gejvpHVCxuZBIi1bhLV+RF/T7omd aRMQ== 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=NwFjbcm2E1il4kMozq9cm2Iw4bTB8WvEOYFmBvojazs=; b=gykGQje6k4piCveXQc2zl/Mdg7Gdq8TvKXNiTdIdzQlERYCzMk256ALZUqJsOKF33z EmaVgQrVvRVUz0J+RWNrP3h7Wi0A0tWwdGFzzrIjwITywgCQ6/5Owq93KegTcuL02QsT Dm8T+LmgCfU9WaCVh/UZ6MxVjiKzqfVVOuU3QGOQwDFzdZfrzrK0p8z76Y77PQooY0mo 4jYqxZsKiWiokXaUR7uHjKLoxf9zZBn90nVr0FwTXssSl/tFHHbI1dPVIg9ONNkP1SFJ +58txuruC9bJDoXgK5C2rDJUfK+NVsI9TR6a79EIxlf0ku0/zlFNfDi+ao2WJyVS66R3 Q/Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f69BunrH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y16-20020a056402271000b00418c2b5bd62si15990758edd.68.2022.04.05.18.41.08; Tue, 05 Apr 2022 18:41:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f69BunrH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346123AbiDEJo3 (ORCPT + 99 others); Tue, 5 Apr 2022 05:44:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239557AbiDEIUO (ORCPT ); Tue, 5 Apr 2022 04:20:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1B5221AD; Tue, 5 Apr 2022 01:16:09 -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 5EC63B81BAC; Tue, 5 Apr 2022 08:16:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3748C385A1; Tue, 5 Apr 2022 08:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649146567; bh=kIr5JhcaLshk79hym1GPm/MZv8EVmOacLbwDOQPyUlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f69BunrHFl3tM9/ukbZXt6dQeCuVy4hPL8c23sTfJyokubWk+uZXv9YK52ABHcFZQ NFQvHf3ZmgkAjWTXrVlJFE5drC04ash+2zvHW/WYqyf7OepSt1hTuw//zytenOGfOe HP7gCtpjQ0dKPtmGUFm9szf2o4HhFojgKmiOdGTA= 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 5.17 0811/1126] net: phy: broadcom: Fix brcm_fet_config_init() Date: Tue, 5 Apr 2022 09:25:58 +0200 Message-Id: <20220405070431.371012514@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 3c683e0e40e9..e36809aa6d30 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c @@ -11,6 +11,7 @@ */ #include "bcm-phy-lib.h" +#include #include #include #include @@ -602,6 +603,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