Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp940264pxb; Wed, 6 Apr 2022 04:54:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv9nO0ByraGn01GQwLb6M9/f/iqFrnHG64Nt3E6f8lL7fNbwdQe4F0MsSQ44g1GtxIcO2m X-Received: by 2002:a05:6a00:23d1:b0:4fb:228a:e9df with SMTP id g17-20020a056a0023d100b004fb228ae9dfmr8360299pfc.31.1649246080790; Wed, 06 Apr 2022 04:54:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649246080; cv=none; d=google.com; s=arc-20160816; b=RjDIRdtYoc1A3TjhZzvpla7wJKb8oVYXEo/hVfiRWw34nAw2nJ+2Mmh1Vh4Nvs5Mkj S1Rnc1GG0DFbbnC/nk5eiJnS7CpVONNUTKSNr5Ybfu9s7GVd1tGQfyoyUYm08mCrvwaJ xSqqbKeRp1Bl8TvELhHaxw3lVXG6FRlRFmSX0NyFxKWsSAXb6mNFzm8pbV8YMynKRURv QucSSOhlbOGfGrPhY6QSKH9KDrtpAKtjYMHIzyHOThr+RxXaKToJa13absW+1GY0H/wm RHuzvxbCiOte28mm9U9FKEiicZMZPmoPq5nplLj/6nygUaLEL9ZuaW26XCbt6Y+nviyX w7Ow== 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=AafWMtrb1I7XLn6seGkHLfn+H1hRIU8Z21BYvKQSPrc=; b=Fs0d0L9Dmza0VVUDjgrzUUlzPXMAa0f4GZSn9sweYlporMuL0OJFC+92VHsIyF+n8A o2U5rf6zcyRR8U0skYgGjY7pZHe3H9qxVt6JBMnEv5XJQSvEWKL3JnORReFl1y3qXjPP KftoH/KBGzPFDSKOJG52YTXd8Orh8sty2WRrBuFJnw+GZ3yVEfeyWqvgNyNzPUDMnoN9 5Ja0BuZpLhHa5IWUe0FPKMKtrFcLfyNB4+Ayx1f81hvgJ58fJySYlfgdQrde1742l+5F aGWGxIFqgcc8xEIeiqyvBuE3xSvJjHpcWz5hG9L4i44vknbzGGcIgyqKp7bWI3SNScgJ Vvpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H9bWDgew; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id nu16-20020a17090b1b1000b001ca84546104si5186269pjb.27.2022.04.06.04.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:54:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H9bWDgew; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7EFC1646646; Wed, 6 Apr 2022 03:15:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1584238AbiDEX6F (ORCPT + 99 others); Tue, 5 Apr 2022 19:58:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242415AbiDEKfX (ORCPT ); Tue, 5 Apr 2022 06:35:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5171C50E0A; Tue, 5 Apr 2022 03:20: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 dfw.source.kernel.org (Postfix) with ESMTPS id DF7CF617CC; Tue, 5 Apr 2022 10:20:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1A9AC385A0; Tue, 5 Apr 2022 10:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649154054; bh=VZA5HgkvbvVbAegIgIjNJx8G0dOWI970jWFfCQLUCcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H9bWDgewV89kJz7btB45wcKuNaF7ZuEJ1dOcldFVRmgIPlAIXby+y5u5878B+nm4z LCeg0gfvi8upnw8+m0v2ru5Pa4XdSjdlsOKBj707kywgHYCbsRwmCaj7UdLWLITz0v JbVWmRFPblo6oiGZAddilQI86io7rk1F2Zxwi4Zo= 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.10 440/599] net: phy: broadcom: Fix brcm_fet_config_init() Date: Tue, 5 Apr 2022 09:32:14 +0200 Message-Id: <20220405070311.925954655@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070258.802373272@linuxfoundation.org> References: <20220405070258.802373272@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 644861366d54..0cde17bd743f 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 @@ -622,6 +623,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