From patchwork Fri Nov 18 07:20:51 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: 22155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp43442wrr; Thu, 17 Nov 2022 23:24:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf5evPsjcASQVlWnAO0Ewm89ThN12hzjgLkqnZKvuynsUguuv452r9IpwrPl4L8/505LvcIP X-Received: by 2002:a05:6402:1399:b0:461:53b0:2ac0 with SMTP id b25-20020a056402139900b0046153b02ac0mr4959729edv.153.1668756251177; Thu, 17 Nov 2022 23:24:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668756251; cv=none; d=google.com; s=arc-20160816; b=CcMtSWc4jOFuvS79N44rlJeIIowIQgX08ue1wDGsL8udOBIGY90h/+gRMZ7uuvLT2e Vmcd5xiLGW5BJSdF++9h2BkLFADHWHS7iCOJIjJw3K8TN28ABBl3mmwu2CBrQYebSHar zj8rfm2hT70xuFx6FDCn8mEE23UgsSBJe3WigmsAWMoKbGjplxUXr8ZGAchr3CmU0QK7 KSqNPzdPLdXMbhKxn1JJGe+aZl4RfAFru/OUO0U+U/Qq3OxSX+fCvMvqku/edLfDTwvl MyR2iwO2tNqsGyaQq5+ZPX/tUgbSx0Y0fn7mBm4ocs3x0EBgb1ngSvQ3i8F7gWRm4P/k LqTw== 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=CtGm/2GYMYyV+89Ll8qilqFXbdu8bP1KZZzs6ORfzPY=; b=a7EPP0SGL7Ztw4K+7NkGQcarkVo3DYKnC+GJwMQEl3KXwS3Td4isT3GEPc1VJ5FOMI Y7ttufqCPXzAcw0uFZSiRSolqp0sbrT77ENbG411gvH+gvZnQkqtPDzox3Csyq+34yrW 2DLP7QuEgURNxaQJMfNDNN7w7c18YszJseERI/HDSYaVS7EtRwJR5RTzfcey7ueYp9Nj KJieQ5pp0eKgS9hT2KzDJhQTZbukZglzYDhViAiAwu7hHlKeuis6KKd4VvJtIECIR3pC SmWjff1470zXwua7jXSxVxUZms/jDpQGOM3lyoLceK79/qX3O0umbh5BxePkADa+No6Z EKUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FQWvikmS; 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 xg12-20020a170907320c00b007aeff3b0b17si2749594ejb.674.2022.11.17.23.23.46; Thu, 17 Nov 2022 23:24:11 -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=FQWvikmS; 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 S241143AbiKRHVf (ORCPT + 99 others); Fri, 18 Nov 2022 02:21:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233999AbiKRHVd (ORCPT ); Fri, 18 Nov 2022 02:21:33 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B15187CB85; Thu, 17 Nov 2022 23:21:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668756092; x=1700292092; h=from:to:cc:subject:date:message-id; bh=yVx7b9riDY5Xky/FC/Uq65fzL5vq5lBWcvMLLJea91s=; b=FQWvikmSQBeBEH5OnHHkHMhKxjAYW724jyrpLBGzqGuTvsYx6fxgfr8p vAxE9bSPuFUdclGn6l1E7ww9e3XQ6SmnNePp8rgaobwFBIBN6iLFDLOii 4PvVfojwcXrB59zipRPal94eAcQMwu8E8zz18+GGRZnkmJMK6+LAC0tox PM6Z7ZYuLNNyJ+zpbf9azmw1C24sP3b8QO/tCEZ5uCWjSddUNDEtGov/k a998U6BwXy/UXno+1QWkzAqKZ4lXU7G6w4S5Ua9g9JYZlaxiGlDqhzNOm hxqFiNwHVOpYnPHts9adC8xz+O3+4nuC1VhiVGv+75RFUXbxvkanC3Y5x A==; X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="339912044" X-IronPort-AV: E=Sophos;i="5.96,173,1665471600"; d="scan'208";a="339912044" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 23:21:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="782550203" X-IronPort-AV: E=Sophos;i="5.96,173,1665471600"; d="scan'208";a="782550203" Received: from p12ill01gohweish.png.intel.com ([10.88.229.16]) by fmsmga001.fm.intel.com with ESMTP; 17 Nov 2022 23:21:28 -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] net: stmmac: Set MAC's flow control register to reflect current settings Date: Fri, 18 Nov 2022 15:20:51 +0800 Message-Id: <20221118072051.31313-1-wei.sheng.goh@intel.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-4.1 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_HI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749817754889407515?= X-GMAIL-MSGID: =?utf-8?q?1749817754889407515?= 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 --- 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 if (!rx_pause && !tx_pause) + priv->flow_ctrl = FLOW_OFF; + + stmmac_mac_flow_ctrl(priv, duplex); if (ctrl != old_ctrl) writel(ctrl, priv->ioaddr + MAC_CTRL_REG);