From patchwork Wed Nov 23 09:15:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Goh, Wei Sheng" X-Patchwork-Id: 24812 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2679687wrr; Wed, 23 Nov 2022 01:17:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5MLWnaluLrBWlXjVQdyyo60nmcBa+XIRi87dHlISU0DHHbvMYWAWl2tRjSv3jmLRq/B61Z X-Received: by 2002:a17:902:6505:b0:172:7a15:9a61 with SMTP id b5-20020a170902650500b001727a159a61mr11067101plk.71.1669195050637; Wed, 23 Nov 2022 01:17:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669195050; cv=none; d=google.com; s=arc-20160816; b=OpraeeUnNzYX+7Rm7ep3gyqWQGyfGn8DerG12SYHH3O9SvFc0vUYGP9vavxf6jHCct Hgr9qEX+lWo564hGNQgJ4rUEJFpE/HqbJ3SRWInpbHm09TITQNu2X4apUfWTY6ICiuZb EOhISn0D5v9PKKFrgZmXkTJdmwLzoKeGy4KkFYdyz2ASyhLv72PXqbVgZCrjaof+KPvG JknPFwMlsKlXN1D7woXFDsc3yabzDugfGb7UmxhqD/dGpCI5MHaaSxHCU/PknPIVs1U3 FCEuj3UKxfMsdY7yPIc83jjF8coO1dfSdNIPev+KJD2puqamheNfeuzAfBtyunfn7Y1r gHjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=cW8KOKtS4pYlknwT7aaHuAZHYC5UtSC/oWU/b65v7XA=; b=vb4d+xT2CTPYzf8Z+HKNKcQ8K4jwyH+89QtyxepH3wulxp6uX/8xu+o5TD6oLyu+cA iys4iyC9gy1QEsWmd6FcV5HA4MS63tvTRb6kZi09HOn1SCnUaU7v/WC1Fe0+4Km4IHzW IZVkPzGAYesbXUgEKinq2b5K+8l7eEAQyKGkh7mtzEppHEyT1RIjgQk7MDDxMAK058d0 tGbOn4k7MxsfBRJ6QII7jMuNhQoerG2+D+SZb9bPNv9Htg1GKH85MupuTkQT+dVq8Q51 7Wpif+trvq2QZ68Gsntg3yLEyMz2avYmipgEn0GufdLGi5Ing3yKXmgUeNaMzYcYk4vr wE9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lFE32huP; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n4-20020a17090ac68400b001faf9ba369fsi1241631pjt.164.2022.11.23.01.17.16; Wed, 23 Nov 2022 01:17:30 -0800 (PST) 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=@intel.com header.s=Intel header.b=lFE32huP; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237319AbiKWJRF (ORCPT + 99 others); Wed, 23 Nov 2022 04:17:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237309AbiKWJQr (ORCPT ); Wed, 23 Nov 2022 04:16:47 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BEAD10B410; Wed, 23 Nov 2022 01:16:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669194977; x=1700730977; h=from:to:cc:subject:date:message-id; bh=W3JPMcfxADxcaQcKNXuih5D3EZGPzDYcLZU7qgIXdnw=; b=lFE32huPZns4grkjukiTZap3TFXDgR7xHxg6beK8Vy+fng3OLQ3SXaRB FQhEETH+Rb+5HniKzQDiRQmfSFclicsSZgA8pBJxF6DEWse5S4DtX3TYa 1MU61t0bevtozXrI40mFcqNkMry/EIBeL8yrbR+/nsNrmS0kjIkvsFWt3 /8CtvOLrkIxAJ/AjKEx7cw8AH9WTDLWRVS81cZQImx4yoogLc7ZciuSQ4 uBRC4WKvecJ8IsEIwGps0UPAjjN/v7nrsJx9RkyMVyNhy/IUzc+P4jyKx ix3TMGiK3X5ZX8svIlLbZaail2+6zaaT2BMkayhqCrHky4VrNqgBU2B8M w==; X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="315174364" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="315174364" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 01:16:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="672805025" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="672805025" Received: from p12ill01gohweish.png.intel.com ([10.88.229.16]) by orsmga008.jf.intel.com with ESMTP; 23 Nov 2022 01:16:10 -0800 From: "Goh, Wei Sheng" To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ong Boon Leong , Voon Wei Feng , Tan Tee Min , Ahmad Tarmizi Noor Azura , Looi Hong Aun , Goh Wei Sheng Subject: [PATCH net v3] net: stmmac: Set MAC's flow control register to reflect current settings Date: Wed, 23 Nov 2022 17:15:29 +0800 Message-Id: <20221123091529.22018-1-wei.sheng.goh@intel.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-1.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750277869470501173?= X-GMAIL-MSGID: =?utf-8?q?1750277869470501173?= Currently, pause frame register GMAC_RX_FLOW_CTRL_RFE is not updated correctly when 'ethtool -A autoneg off rx off tx off' command is issued. This fix ensures the flow control change is reflected directly in the GMAC_RX_FLOW_CTRL_RFE register. Fixes: 46f69ded988d ("net: stmmac: Use resolved link config in mac_link_up()") Cc: # 5.10.x Signed-off-by: Goh, Wei Sheng Signed-off-by: Noor Azura Ahmad Tarmizi Reviewed-by: Andrew Lunn --- V2 -> V3: Removed value assign for 'flow' in else statement based on review comments V1 -> V2: Removed needless condition based on review comments drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index c25bfecb4a2d..369db308b1dd 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -748,6 +748,8 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, if (fc & FLOW_RX) { pr_debug("\tReceive Flow-Control ON\n"); flow |= GMAC_RX_FLOW_CTRL_RFE; + } else { + pr_debug("\tReceive Flow-Control OFF\n"); } writel(flow, ioaddr + GMAC_RX_FLOW_CTRL); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 8273e6a175c8..ab7f48f32f5b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1061,8 +1061,16 @@ static void stmmac_mac_link_up(struct phylink_config *config, ctrl |= priv->hw->link.duplex; /* Flow Control operation */ - if (tx_pause && rx_pause) - stmmac_mac_flow_ctrl(priv, duplex); + if (rx_pause && tx_pause) + priv->flow_ctrl = FLOW_AUTO; + else if (rx_pause && !tx_pause) + priv->flow_ctrl = FLOW_RX; + else if (!rx_pause && tx_pause) + priv->flow_ctrl = FLOW_TX; + else + priv->flow_ctrl = FLOW_OFF; + + stmmac_mac_flow_ctrl(priv, duplex); if (ctrl != old_ctrl) writel(ctrl, priv->ioaddr + MAC_CTRL_REG);