Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp702605pxb; Tue, 5 Apr 2022 19:27:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzE1pCfrk2uptSRZiTdJzYwfllenzDMs3hyfQzfn+ovBa3dxv1tL28ZDShBSSffAcgHqxnd X-Received: by 2002:a17:906:b6c7:b0:6db:2e14:875 with SMTP id ec7-20020a170906b6c700b006db2e140875mr6249369ejb.737.1649212028798; Tue, 05 Apr 2022 19:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649212028; cv=none; d=google.com; s=arc-20160816; b=zU15tHs9uXcegcYN8hio8H/38DHsdnG40wlro+dFXOIJNZ1XlCCtlvmQ8Wuw0MT6Tr Uj9xt1pgfAXFFtYtFLxKqG4V1mKg3hJEeZ3jbHmPkLyadYVPod/8nxX5gHfrgk6/viiK y6zgQhlXEceZmwA6lFljgwm82cjE5oaWuXn2x0tjE9Hdig22G/JaaPcESW9xb7Vw16h9 l6OH9eoKVU4pxm/Cx5B4xEv188oKT4uCPYFhxWmDXDxclazsnTplgPESx/51rdne4OCC EiLSpQQJiHYZWvYMWw3EgpL+MsetQtQUCKpFhkUkthxUlO+uVZL4QIGiv1ij+4pPzaMY g4cg== 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=NXeNSLqdyjnBPEwRe0VvGWKI4tKahTGF9t6MeulrL7VGJdoZVUsXOok36qjS+LvIlH NWLRHLq2gnNhnOcjC4xlnt6o3wTa0IDmHZ1/5lon2BIgxdbUIehZ20BZokn0M+3arDRV Djnzin/MBWQFMfs3SoDsullo+vg999/cVpKpK3KLNBwWx8Q4U6f1uk6DOcPI1M4kDbjZ F+csHtRBhxOvfVTb0yPgqFMVJazs99WhZqqx0ho9tdyq15Gluj0kM2HV5SJKm+F8a7tC RWpZUZJaxc5vB7Nu/DZe1XoK2bacpv0Tv6HxzNYx9glHrVcLutgSenjTVkl2eA4A0kIO Qw+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YU1OXer4; 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 s12-20020a17090699cc00b006e11e057cf8si10577501ejn.270.2022.04.05.19.26.44; Tue, 05 Apr 2022 19:27:08 -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=YU1OXer4; 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 S1358792AbiDENJk (ORCPT + 99 others); Tue, 5 Apr 2022 09:09:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344165AbiDEJS2 (ORCPT ); Tue, 5 Apr 2022 05:18:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55662606C0; Tue, 5 Apr 2022 02:04:53 -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 E5DD161572; Tue, 5 Apr 2022 09:04:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE6F8C385A1; Tue, 5 Apr 2022 09:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149492; bh=kIr5JhcaLshk79hym1GPm/MZv8EVmOacLbwDOQPyUlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YU1OXer4PjbVBkpGfuh98qFDg4HAbwEInPkS2fEIzv0rVyzRLkPTmPKnzRI9cFt9U 1yaxRofXcLF3YiBGbc+AZ+hPpl5DEiYszoUUjqNMxSHnI0WqQP6oo/xG1kJG+GdNrb PuMUAUb4P0t6yNYsyWbOeP6OiSuGrbzA9xs2yNPk= 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.16 0734/1017] net: phy: broadcom: Fix brcm_fet_config_init() Date: Tue, 5 Apr 2022 09:27:27 +0200 Message-Id: <20220405070416.053898753@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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