From patchwork Sat Aug 20 15:20:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12949733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F4FAC25B08 for ; Sat, 20 Aug 2022 15:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:From:Cc:To:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wswtOQKLDdsrGy/qIMPgLC6FzV4VzwTI27EFKJt2ez4=; b=cc647VDhV3LDCw OBp+2+qcTiAU/20/8tj6rKJGHuW9aaHA4wC8LXtujq5+1k5FfuniCVc8xr230QCCsBuzcN5K4w6Ml I03IPnx2RMvSK+EmrUjNq6A3j50PSDumE/Pu34fChZESnbWfzPWHK6+DZenz0Lpt+iDIkygOCbmjr rq+yWoR8GaoYSCmqAH9nlUHtBP/JQ01k+iGeX4H0lbyM8yxrSI8adcUbJnBnFqBVcDADdnFbqojO3 cNhBl5SVRuS+PjdvhhoevSeOpPwKEYSFsKtP92+PBZExNJVE8gIGWpsFjTQMgnoQuHzLm8Y7uF8zG Z8DO/gqiwYY+K0Fqtndw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPQHK-00Aqvr-QU; Sat, 20 Aug 2022 15:20:50 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPQHH-00Aquc-TF for linux-arm-kernel@lists.infradead.org; Sat, 20 Aug 2022 15:20:49 +0000 Received: by mail-ej1-x635.google.com with SMTP id io12so1674511ejc.2 for ; Sat, 20 Aug 2022 08:20:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc; bh=KuyThZ4UkZCoD1rqfy0175wV5oUpnVkfQljkGFt0qM4=; b=M/4oSsOKD1hzTM5+HlnLRoPjSK5Qy+hxCY5pZyE1SXm+pEgS2ashZFuf/ZKhEq/LF/ Il7sT9qUvflqN6QNmgKTu0ZmwCXt7clBEt+SX+VaeGLjge56gj7cbmbgarylpDyMHQDK flZ4Q0IhC68SbFO1D1Rpwb4e6n2++LR/sR1akX/RyNYTVfQWYO80gVSu5isCVCRArS8v jzOcVbH4xItQmQLvwg1WNLcDobsa6Hswfvds/PoFfGuL9ZAZKj58kg6egKLIEe89858z Ox+Yu7CiSZn8oH5Za2I/eIwY9Tvu8DmVKwYcBVhv+t9Tubcj1BowGmp2H/45YAnZ9qG4 vdUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc; bh=KuyThZ4UkZCoD1rqfy0175wV5oUpnVkfQljkGFt0qM4=; b=kTG8pBH9L3NFoOSfwOCFRhFtcSrxGRP0Rbw/fCvQ88iep5v7YrY3+dl3iebaH3cyVv eI/R1zE0Rher98rsCgCIr46k5/iKYjtN5hPYeg4nQvRtIndsj6Hufm0Zc6Bwy6+SjCYF PBzX2YTjDJgRCEsa5PCsGHyMGHM2idFmOigZ7pZsGQoeelC5fiRNDqD8cYmFQ02VsKHK UjR2K2FPrWjxMVM8PzR+0wQZ2PHIZ/nZ3ZLCCPtIffkC8RV+R3x2HsHaA8TFuYz/dvz/ lN8DBIF+jJl1uOoig/2JIwMTowmQxZrQqez+Cc7TAiEPATifXem+qgImfVazEGmKL9M+ 8G6w== X-Gm-Message-State: ACgBeo3tLt5/6uD+mWp43zBSe8S1PhrTZK/t+E8ry4NKNo9/t1eYQf9M Po7pPu8BQ+gpqpaOoI7w4wU= X-Google-Smtp-Source: AA6agR5IIE32z+hn3t8/jwzLboDkj1bBwiJDNQ4LJJoHL7vMUuppEjEnhle415CudsQZ9zcs3hbGCQ== X-Received: by 2002:a17:907:6d8a:b0:73b:d9e4:e628 with SMTP id sb10-20020a1709076d8a00b0073bd9e4e628mr7518175ejc.75.1661008844324; Sat, 20 Aug 2022 08:20:44 -0700 (PDT) Received: from ?IPV6:2a01:c23:c0bb:f700:3cb6:47a0:41b9:1531? (dynamic-2a01-0c23-c0bb-f700-3cb6-47a0-41b9-1531.c23.pool.telefonica.de. [2a01:c23:c0bb:f700:3cb6:47a0:41b9:1531]) by smtp.googlemail.com with ESMTPSA id s18-20020a1709062ed200b00722e50dab2csm3684220eji.109.2022.08.20.08.20.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 20 Aug 2022 08:20:43 -0700 (PDT) Message-ID: <72755b6b-f071-1c54-c2fd-5ea0376effe1@gmail.com> Date: Sat, 20 Aug 2022 17:20:37 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Content-Language: en-US To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: "netdev@vger.kernel.org" , "moderated list:ARM/STM32 ARCHITECTURE" , "linux-arm-kernel@lists.infradead.org" , Qi Duan , Da Xue , Jerome Brunet From: Heiner Kallweit Subject: [PATCH net] net: stmmac: work around sporadic tx issue on link-up X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220820_082047_999167_8A2647C5 X-CRM114-Status: GOOD ( 14.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. This patch doesn't apply cleanly before the commit marked as fixed. There's nothing wrong with this commit. [0] https://www.spinics.net/lists/netdev/msg831526.html Fixes: 11059740e616 ("net: pcs: xpcs: convert to phylink_pcs_ops") Suggested-by: Qi Duan Suggested-by: Jerome Brunet Signed-off-by: Heiner Kallweit --- 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 caa4bfc4c..9b6138b11 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 070b5ef16..592d29abc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -986,10 +986,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) { @@ -1064,7 +1064,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) {