Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp928462pxb; Wed, 6 Apr 2022 04:33:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHckGuN5IBy7ig7ryNenoMsMlFU5tdJ+A953ahgWGYDO/DM0ZeSV0ITgTdbofOuOUqV2/P X-Received: by 2002:a05:6a00:15c6:b0:4fa:aaec:ef42 with SMTP id o6-20020a056a0015c600b004faaaecef42mr8417456pfu.74.1649244811264; Wed, 06 Apr 2022 04:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649244811; cv=none; d=google.com; s=arc-20160816; b=BHjHvCcR1jmePiXwomKcHa0hJOZT3nPUJ+VZVdiv9jyIO4QA/D5jdSxMgy7xhLuGjy TUxDQsYcl0YJnMGfFCUQeR3T8dND9Fmt+qdV+tloAHqcL61Ctzv+rA0xpKPe9QVxKHFK 2j8+G5/k90z2GDkFBEI6PsNJp454xcHdp8dhdaXfEEVCuyFFYPLiDlBSGI9gnYmQKN8l EKF+UNPt8XyRfX9Z1hckh5E5PCWEUOj7ISTJT+s0K0CmEj8T0Ns2SW37RGZfju8Tp08p 1v7ie0sSYFPIOi7T2ral3gmyGgdXfEtiXZndJRbGXg+Q30suIzxpKLyIptBnRPkm/6Om iR8g== 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=7pTx845finb2uHlCwy8Wd3DQtD+Cm5rWE2LGsaO1SxE=; b=G4yIz33lNYhe3DMp93taQEqf5W0j/QN7NT59Aj8zjM1Bi6RyyEF/EMMEKaGJjzbvpw 4MkhgtQIOhyC3iNRj2rP9DKlZSFnzxHbQDPr8srGdQdOHa7WDEMs4GVbn9WuCYvt1z8U 9Bzl0lP97ab/iS0SH4ijC1Cwuz5wcc2OfADM4k+/3xQrSqr29GxhGdDIFGWfxdG8umIU 4ACMUI4tUT74FB0yJHXbJSFqNqdMYKjS7DSNuC+jLAEurVGswBvAMGSIOQeuLf6nm2xb TZRT0Sxed2PD2HU4nTs8fbjZGwoau32Uzjmxy7TnEeQssuguMAZQIXrf4aOrxRHss7Bt aioQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gFBhlCpp; 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 p7-20020a1709028a8700b0015605a57d10si14309290plo.523.2022.04.06.04.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:33:31 -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=gFBhlCpp; 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 E54C161092B; Wed, 6 Apr 2022 02:55:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388492AbiDEVyf (ORCPT + 99 others); Tue, 5 Apr 2022 17:54:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350057AbiDEJwg (ORCPT ); Tue, 5 Apr 2022 05:52:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFF68443CC; Tue, 5 Apr 2022 02:50:38 -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 63B90B818F3; Tue, 5 Apr 2022 09:50:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0F66C385A2; Tue, 5 Apr 2022 09:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152236; bh=GMssu4zTZHeD6W3nJa/GiVI/GBxjrQZSODh9S6qxuN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gFBhlCppI8Su5JNip8CFWOEw6mq7w+oTMmXvwQFey+xL+7cLm+H9ZX3dl7C5lkXQ0 C8oYJbAQmok7pxoL4JS7kXh/hNJXgEo6g6GuNMSasYj6zwL++BzrM4pKG/oD9KC8oI x7QYn1xMdktY6WN2N6jbpyy6lxBorqX9B7Ow4zOw= 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.15 666/913] net: phy: broadcom: Fix brcm_fet_config_init() Date: Tue, 5 Apr 2022 09:28:48 +0200 Message-Id: <20220405070359.799471807@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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 db26ff8ce7db..b330efb98209 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 @@ -553,6 +554,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