Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3050724rwe; Mon, 29 Aug 2022 05:09:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR7gJyoUm7yxRjwPIzd+pUznIjdXc2mayNKoqvkgx2LhRCNyX0+KCGHqW4yNdLjGJuo0Dn7+ X-Received: by 2002:a17:907:2e19:b0:730:acf0:4924 with SMTP id ig25-20020a1709072e1900b00730acf04924mr13107818ejc.629.1661774987146; Mon, 29 Aug 2022 05:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661774987; cv=none; d=google.com; s=arc-20160816; b=sSjZxL/W6R09JAWhEP/25TqkJSyvY8dYM3W8A3gz0L9SsGjk3p0fxsJu/yTZR5FsMt 8zQnO2ywvJO33LSebMnebjmBV9q2fZcHNdhN4ir8Eq3deJkCtkEFD2HuL4iUpX0rrrVq MfmqkD/gBI0jIiVqyBw+PuM3u7UiGTfwkEHyFDP+Q8IKJlmU1TlJd5dWLJKOa+1OjMbt AiHMRpPJ0cAkePSnwMmaqGTiNhBgK2H1bGJ+DMSC6WhnWJSxk+9CSvbNrqzBWAgdVEqy vMnXU7YLxPt8cS/Z/zKuEb3bkgbzllcnT5st1kIb+WmX2A7WIry2nZmsCA27NQX9QDZ+ HgfQ== 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=ynlL6i83wo8dAogAbV2cNGOE0bGGyaXs9kK4gPLDsQY=; b=x4FAlp57osXVhE0aBHy6XvE/WsGTuDIvQI04yCwOcn7z/twpUtT8K+sL7OY8I+FfQY YEXkdU5QxKWw7b66zKSqaw6bz3iKIXrO/znfzgxUIiyBuh6VgSTMkix4m9kuZoFN90rS rdLOWU5ImPcLXgGfGb26rCeQsVXHdEouX+Lkm4fudppcVIuMa1350aLyMfVBp4tbd+B9 P/WAAqczLsfOrLYS2cx8KoSTTtTN0lllqnC28q2jFv67b7j2zgh39++1/OZdQDz5Wltw ryGkNyoXMzXv+1xcjLs3vcxgzpY+6wfgHMU91ge63W+eUKdtXboi+td+HAHNm3SMdzJx lVJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GJlF8mUx; 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 e12-20020a056402190c00b00445f21c2b32si8256484edz.132.2022.08.29.05.09.21; Mon, 29 Aug 2022 05:09:47 -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=GJlF8mUx; 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 S232545AbiH2LcK (ORCPT + 99 others); Mon, 29 Aug 2022 07:32:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232682AbiH2L3h (ORCPT ); Mon, 29 Aug 2022 07:29:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E274E7A500; Mon, 29 Aug 2022 04:18:00 -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 5666061244; Mon, 29 Aug 2022 11:16:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30A1DC433C1; Mon, 29 Aug 2022 11:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771762; bh=WTVeAV7tZnRbkyjCffIL6VZA8oSDf9wCxoNB9vdIiAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GJlF8mUxWzRXAWm+itcdgnWtMSqPFTGYhV8DYO/1jLRRuAiWmaCkRXRd1qpCGIUIa s/tCt38Tff7WyT0LFGIJjvkgTSuBMSJDHfPvcL9B8RAvSkdEdKzgpxZeT5icbBVxV7 X9Plwa/Qbi9qv0S1XN7T0SlJ+IUqowLVMDwBTgBE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qi Duan , Jerome Brunet , Heiner Kallweit , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.19 090/158] net: stmmac: work around sporadic tx issue on link-up Date: Mon, 29 Aug 2022 12:59:00 +0200 Message-Id: <20220829105812.843290760@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105808.828227973@linuxfoundation.org> References: <20220829105808.828227973@linuxfoundation.org> User-Agent: quilt/0.67 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: Heiner Kallweit [ Upstream commit a3a57bf07de23fe1ff779e0fdf710aa581c3ff73 ] This is a follow-up to the discussion in [0]. It seems to me that at least the IP version used on Amlogic SoC's sometimes has a problem if register MAC_CTRL_REG is written whilst the chip is still processing a previous write. But that's just a guess. Adding a delay between two writes to this register helps, but we can also simply omit the offending second write. This patch uses the second approach and is based on a suggestion from Qi Duan. Benefit of this approach is that we can save few register writes, also on not affected chip versions. [0] https://www.spinics.net/lists/netdev/msg831526.html Fixes: bfab27a146ed ("stmmac: add the experimental PCI support") Suggested-by: Qi Duan Suggested-by: Jerome Brunet Signed-off-by: Heiner Kallweit Link: https://lore.kernel.org/r/e99857ce-bd90-5093-ca8c-8cd480b5a0a2@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c | 8 ++++++-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c index caa4bfc4c1d62..9b6138b117766 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c @@ -258,14 +258,18 @@ EXPORT_SYMBOL_GPL(stmmac_set_mac_addr); /* Enable disable MAC RX/TX */ void stmmac_set_mac(void __iomem *ioaddr, bool enable) { - u32 value = readl(ioaddr + MAC_CTRL_REG); + u32 old_val, value; + + old_val = readl(ioaddr + MAC_CTRL_REG); + value = old_val; if (enable) value |= MAC_ENABLE_RX | MAC_ENABLE_TX; else value &= ~(MAC_ENABLE_TX | MAC_ENABLE_RX); - writel(value, ioaddr + MAC_CTRL_REG); + if (value != old_val) + writel(value, ioaddr + MAC_CTRL_REG); } void stmmac_get_mac_addr(void __iomem *ioaddr, unsigned char *addr, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index c5f33630e7718..78f11dabca056 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -983,10 +983,10 @@ static void stmmac_mac_link_up(struct phylink_config *config, bool tx_pause, bool rx_pause) { struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); - u32 ctrl; + u32 old_ctrl, ctrl; - ctrl = readl(priv->ioaddr + MAC_CTRL_REG); - ctrl &= ~priv->hw->link.speed_mask; + old_ctrl = readl(priv->ioaddr + MAC_CTRL_REG); + ctrl = old_ctrl & ~priv->hw->link.speed_mask; if (interface == PHY_INTERFACE_MODE_USXGMII) { switch (speed) { @@ -1061,7 +1061,8 @@ static void stmmac_mac_link_up(struct phylink_config *config, if (tx_pause && rx_pause) stmmac_mac_flow_ctrl(priv, duplex); - writel(ctrl, priv->ioaddr + MAC_CTRL_REG); + if (ctrl != old_ctrl) + writel(ctrl, priv->ioaddr + MAC_CTRL_REG); stmmac_mac_set(priv, priv->ioaddr, true); if (phy && priv->dma_cap.eee) { -- 2.35.1