From patchwork Fri Feb 17 14:54:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 58630 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp929942wrn; Fri, 17 Feb 2023 06:57:42 -0800 (PST) X-Google-Smtp-Source: AK7set9AV1K17AHpzSxLpZADwJhL4bbXcYLOBCCodUxFJVuLlOYhT9rs52js209ChyyIUeiWPF5y X-Received: by 2002:a17:90b:4d0b:b0:233:b849:7e79 with SMTP id mw11-20020a17090b4d0b00b00233b8497e79mr285922pjb.4.1676645861910; Fri, 17 Feb 2023 06:57:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676645861; cv=none; d=google.com; s=arc-20160816; b=qIHLuVv+Tlmv1CZ07CUZhx9gT8I3FXfujmXfBEWVcEUPofTcdTqtSqmoh0mGLSw2k+ Xz7lcebBRi6sdHvoW0V4fCPFM36HPLZ41qGzbUADup6Dhn7g764UWU0WGKEV8gcsptS2 hoRwoB2CSgdIAD1FY8hx37aQhKaSr86mcsMlju2j/k0X9PiGG+BqPkpmjxVUICPeCkA3 X/tvtoumNjpY34ZhbcZCZbWFskTC/dFxqiwTB49zU/PW+MG6/qfBrCzm7Q1GGIZn9eDv uIDfmtG/WNkhaa0Dj2Xa/I5Ij3F55cnWq195nOR/saj8eBmTe2HVk5tzCepTm+vqLzNR xUUA== 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=xWJSPUQ/ENcoZoHscirG1tZkEFyMREWZQ/utdM5A1K0=; b=GJo3mnx5Q5rgB/B5spKgVtkEdntalxna9bj0IDYToWjncLhdDT5p2wSzyrsJsBPS38 6AfAtzdURHa/H/tFidZX11eC8yIBSPTHzTsVCUNBXsotlm5rZsT8uYvQjM7zYVN8rz6F e2Yza/xhhitYqhJdUk6phcQ980Bzq4lo+yQZLPfeVz+wxQoWsvcmzZQF1fgyZD1NAKgH I8Y8GlsV8hq5DQKTUqS97rWwLRCDLJ4rixQjuBj4IOyp05wRQXt1sN14mK0YW0sm+miI 6CS+DF9aWagTV43z5tgtf7Eg/OLx+COZUBjsB6pG8OxbivBZzsQMgWacZW5SGHziFCm1 F2TA== 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 fw24-20020a17090b129800b00233ba274e24si152657pjb.6.2023.02.17.06.57.30; Fri, 17 Feb 2023 06:57:41 -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 S230055AbjBQO4u (ORCPT + 99 others); Fri, 17 Feb 2023 09:56:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230089AbjBQO4j (ORCPT ); Fri, 17 Feb 2023 09:56:39 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AEDE6EF33; Fri, 17 Feb 2023 06:56:13 -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 1pT29j-0005LU-1H; Fri, 17 Feb 2023 15:56:11 +0100 Date: Fri, 17 Feb 2023 14:54:36 +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 v8 08/12] net: ethernet: mtk_eth_soc: fix RX data corruption issue Message-ID: <727665d3548ebaa711596b612e16b8281cf1601a.1676645204.git.daniel@makrotopia.org> 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?1758090611511651591?= X-GMAIL-MSGID: =?utf-8?q?1758090611511651591?= 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 030d87c42bd4..ed32a511adc3 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 142def8629c8..529c95c481b7 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)