From patchwork Tue Feb 21 11:42:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 59895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1815197wrn; Tue, 21 Feb 2023 03:44:33 -0800 (PST) X-Google-Smtp-Source: AK7set+YNCGIiSsFguR6nHQmDKVEwGNnl33RKDLo3NE3DlPTkmA5WYpaT5eV00moKZM9tm37BCsB X-Received: by 2002:a17:906:e294:b0:8b1:7b54:a013 with SMTP id gg20-20020a170906e29400b008b17b54a013mr13078724ejb.57.1676979873244; Tue, 21 Feb 2023 03:44:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676979873; cv=none; d=google.com; s=arc-20160816; b=TnZZfR5D96CVptdXNZuZXR9mZTu6gnUx+sdany0RkqOli7lpP/wA6mF+dCuAuFZNH4 H3Qopm0ZSWLT0mGY5YWuM6QcRrffo5Ftg+f2kVKEpnAbNZo7wJFwtBrYjJvo8mp+egX3 df/5jUU0cpw+UJX+aEPybdTqxqZm86ukWvUIRtrRbclR0AZVUsbn3VWDaYj1khzdC1n/ f+SB4XeyXqHQ3dWrkHUnzs1GaKHsy0xTbP1yH5cBc6KV7zq5JnC4cL/8C+OnOPcjS+Wc zsfQLU9BiSWDTa934/wfJ2B2bAXQKzCLuYZYLbWUnaYtNgsFTdVPZlEDKk5CTVRzKy+/ eYnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=xWlhkkROj8vERphsF7a+jhL2mecP1JhwwrKz2E+NPBo=; b=IZvr4YXAXz3Dd3CDITNKi+nm3O9c1Y4AA477Hxv5B3inz7kM1seOUauChkJGJuqxNv ejb/tZuGtYSX7lOyTQHq7CIVaYoBzAM28Ueb8rNiM0nvNRmlhAq4VDp3Q6O3ztcU5fJL ggr/3jLAXalRQybUUMPxWVeJBqPNCVzm7xZAn8Q1Sk3Yynz4erzu5NjI7fsAD5jy7CuW hNG8cCWcPVhAMjKEbh7xC4WM74K4Xh6vMHuMmxXo4zZimdyMtNBB0s0bsnU4921araoH lIXfkyGpEP2sIyVZ4cyOpbVNDmlciO7IL0zoPgXBtGBjphG+kGGF4wMDFS+0X+/XfRNF +/3w== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vz12-20020a17090704cc00b008d9f600f9e4si4071865ejb.702.2023.02.21.03.43.40; Tue, 21 Feb 2023 03:44:33 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234322AbjBULnE (ORCPT + 99 others); Tue, 21 Feb 2023 06:43:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234350AbjBULmw (ORCPT ); Tue, 21 Feb 2023 06:42:52 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83A4F1E5D9; Tue, 21 Feb 2023 03:42:23 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pUR2K-0001QA-2F; Tue, 21 Feb 2023 12:42:21 +0100 Date: Tue, 21 Feb 2023 11:42:16 +0000 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Russell King , Heiner Kallweit , Lorenzo Bianconi , Mark Lee , John Crispin , Felix Fietkau , AngeloGioacchino Del Regno , Matthias Brugger , DENG Qingfang , Landen Chao , Sean Wang , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Vladimir Oltean , Florian Fainelli , Andrew Lunn Cc: Jianhui Zhao , =?iso-8859-1?q?Bj=F8rn?= Mork Subject: [PATCH net-next v10 08/12] net: ethernet: mtk_eth_soc: fix RX data corruption issue Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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?1758440847278525588?= X-GMAIL-MSGID: =?utf-8?q?1758440847278525588?= Also set bit 12 which disabled the RX FIDO clear function when setting up MAC MCR, as MediaTek SDK did the same change stating: "If without this patch, kernel might receive invalid packets that are corrupted by GMAC."[1] This fixes issues with <= 1G speed where we could previously observe about 30% packet loss while the bad packet counter was increasing. [1]: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/d8a2975939a12686c4a95c40db21efdc3f821f63 Tested-by: Bjørn Mork Signed-off-by: Daniel Golle --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 ++- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 030d87c42bd42..ed32a511adc30 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -616,7 +616,8 @@ static int mtk_mac_finish(struct phylink_config *config, unsigned int mode, mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); mcr_new = mcr_cur; mcr_new |= MAC_MCR_IPG_CFG | MAC_MCR_FORCE_MODE | - MAC_MCR_BACKOFF_EN | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_LINK; + MAC_MCR_BACKOFF_EN | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_LINK | + MAC_MCR_RX_FIFO_CLR_DIS; /* Only update control register when needed! */ if (mcr_new != mcr_cur) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 142def8629c82..529c95c481b73 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -404,6 +404,7 @@ #define MAC_MCR_FORCE_MODE BIT(15) #define MAC_MCR_TX_EN BIT(14) #define MAC_MCR_RX_EN BIT(13) +#define MAC_MCR_RX_FIFO_CLR_DIS BIT(12) #define MAC_MCR_BACKOFF_EN BIT(9) #define MAC_MCR_BACKPR_EN BIT(8) #define MAC_MCR_FORCE_RX_FC BIT(5)