From patchwork Tue Nov 22 06:39:35 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: 24168 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2041224wrr; Mon, 21 Nov 2022 22:48:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf6vvhfgONTCJ4oltjZcf+TkU6vF3R3MRFbJYaAJS1ZtNWpWDh35mpvkrhsMZhzWt5LlSDLU X-Received: by 2002:a17:906:6403:b0:7b2:9667:241e with SMTP id d3-20020a170906640300b007b29667241emr19009084ejm.115.1669099700317; Mon, 21 Nov 2022 22:48:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669099700; cv=none; d=google.com; s=arc-20160816; b=DOI5ZPzNvham7D+T3goRxatOxBiednL0N6MuL7yhQTKEBPJiu1N1MoQcL5ikTVhzg/ sdIEtaPYy35l+0amggZMRUfmqxA0XYeqO5eMHgEB6i64MUyodKujb4mwjIy4Vk2M/M/U 7GKXGydJpJz2fj2HeX1AYGWEXqI+/+uBPSQmfzoqfqPNSqMDSPmQTR6Y3Z+4K1cu5yZv NDDY7vTu8ZD7l83E7vrZutS9E+v7WpZHLJ+QXP56tdEyWQD5e018SCV/wJ7mxW4lSYG9 FZ3EXpzwYBafqSWxiV64t4d0nF+oVH0YX42CQsy89xQiMJJub3go0W4Ijd6wgr7Sco8F GZUw== 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=nGcbkgXeBxrBIWX9KXtlAc7TDyceuGwK6wZWXSjhlWM=; b=q3IPLxDDm9OAekyrsqdu3leqCTdSkGl7s/e+C2MTUMkP/es/55fjclDv03i+RFbmD8 Ppv+EEAQsLiADyn7H/MuvKkeFvGFiC67tgDWz3sRfcS5KclSosSERKEaZWzUzoQi4Lsd PUS8fouHT8LQLpVPHxZZyanbNQazcHwrVH/hmcoCk/modm9KuKG1Vp/gsYqjOJRnYPE3 Nta55xludVWgoRnyRJMtzTgUaXNb0IwFyZ58ZtzAYhf+tBKzeaniZrrrqgoecYIpNvzc npZjvgs+wdIb7IQR01HGR6cXTpBPQjBkJrJYyvkl1IU/4pgok9DNAI/iFZFGzow48zIH QMHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mdjWgp7D; 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 sb22-20020a1709076d9600b007a9c3366e9asi12711720ejc.716.2022.11.21.22.47.56; Mon, 21 Nov 2022 22:48:20 -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=mdjWgp7D; 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 S231967AbiKVGlb (ORCPT + 99 others); Tue, 22 Nov 2022 01:41:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiKVGla (ORCPT ); Tue, 22 Nov 2022 01:41:30 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 677E013E2A; Mon, 21 Nov 2022 22:41:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669099289; x=1700635289; h=from:to:cc:subject:date:message-id; bh=2QTFR6pA76qtLbEvHKg0kOdamheSUPyeYEN0H8o4nAg=; b=mdjWgp7DW/cDxDT3qvrhH8BCCZmbTn9hFmklAr27l/pUmy0Iryln+YLV /vNeBNSvxvb2pUwjUK34bYX6ZV0lpf7kuDWBnZyN4pOatIajqoO6KVgT0 Ys5/Hyfuw6RllAPDxfv01f/89LPV5vVfM32FWdCYeZfUrqsZZJ80XIl2T iq7I5GLFiWBfn1c8rsQ7Pd2XS2vHbfMbOz85fRLIcAe0Uq2e/9nyC6RV4 tagxOlOyN08WH6qANl7vGZiQApzowDKP+KhYp4jRvYtGzR/6o3MgQrFQr XdByk3zdFN9zd1fiwQcK2ZZtywxV2/T1Tgm6OtPTLt8ilEH/55Lpa1Zqy Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10538"; a="294136315" X-IronPort-AV: E=Sophos;i="5.96,183,1665471600"; d="scan'208";a="294136315" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Nov 2022 22:41:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10538"; a="766238292" X-IronPort-AV: E=Sophos;i="5.96,183,1665471600"; d="scan'208";a="766238292" Received: from p12ill01gohweish.png.intel.com ([10.88.229.16]) by orsmga004.jf.intel.com with ESMTP; 21 Nov 2022 22:41:24 -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 v2] net: stmmac: Set MAC's flow control register to reflect current settings Date: Tue, 22 Nov 2022 14:39:35 +0800 Message-Id: <20221122063935.6741-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,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?1750177887509402227?= X-GMAIL-MSGID: =?utf-8?q?1750177887509402227?= 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 --- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 3 +++ 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,9 @@ 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"); + flow &= ~GMAC_RX_FLOW_CTRL_RFE; } 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);