From patchwork Sat Mar 4 13:43:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 64233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp930991wrd; Sat, 4 Mar 2023 05:53:30 -0800 (PST) X-Google-Smtp-Source: AK7set/Xy0DA4BxrgHLefJQVtymPOk8jPcrtLWkj6XlZ8VtCKS7KtIJTUHhPc1kkXY5Ht0wXEkX4 X-Received: by 2002:a17:907:1ca3:b0:8ea:2055:4f1b with SMTP id nb35-20020a1709071ca300b008ea20554f1bmr6846113ejc.24.1677938010429; Sat, 04 Mar 2023 05:53:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677938010; cv=none; d=google.com; s=arc-20160816; b=pwDUAMh/krijVroPTSuyHZo6RRomSCkUYusLz83ZUcDUMnjS2k1DRvAFJanEhEw7mS lqbDSgQj0REdUoEMm+mKj2EklpveCfSJd9pRUrhwvjaL9EHZC/yVDWK8POXGXS9PrT6Z AjMPhXtMhwCTKxRoqhck3/DnQqvfLVWRTeYpzYQ8od9cpNCjuNXGsuo0Nyxqaav53W0A VYxmE8i5wGHnyhpilE3fhO0fPhFuVYtQm+zTjvO3sILETvTKqx7flYhCf7Nbb2G65NEv fL9LW1ILAWGSXwbygpbSqvgAi7YQSUSeKeJzaj1p1gDcL3AXnTEoKxGM3jxC5Lx4f2Q1 mNBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-disposition :mime-version:message-id:subject:cc:to:from:date; bh=E3ekUcCxDIVZHb+kN5SOvoRv8WIK/AqJpIi4nY5LMB4=; b=gWiPU1dDRGeyIkWjx4/yF7yf7GLpjtQ9rmCVaUFiLSEd/AgXESfce7w2dzMoelFDOz nSMvZnZVOwljFOjKAo6myr3PUVOJhGUOFFuFpvjwJBeahPsFumFdbE4eLnNqjxpNjZDA o0H7N+gtXpIcYrx9inXCgwKZ4NtFgVlvdNLfjz4F6D0xqqhgNvln5A2qUnWWAaQacBl5 jNm6aBn+8oAz2i0QlKKSJwglaMIBxlKSKjP3RyeFdVFxnireVT1KV0RwJ5bFdPLt+PWZ y94f5Xc77WksZcorM5Bh3/vlqlqNogP5KkmCk5hoFJxc/Y1Qif4VZKXX4TP502+BQGID zbKw== 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 lb16-20020a170907785000b008c673be3440si1060082ejc.987.2023.03.04.05.53.07; Sat, 04 Mar 2023 05:53: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; 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 S229562AbjCDNpR (ORCPT + 99 others); Sat, 4 Mar 2023 08:45:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjCDNpP (ORCPT ); Sat, 4 Mar 2023 08:45:15 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 765AF18168; Sat, 4 Mar 2023 05:45:12 -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 1pYSC6-0006XR-1P; Sat, 04 Mar 2023 14:45:02 +0100 Date: Sat, 4 Mar 2023 13:43:20 +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 , Vladimir Oltean Cc: =?iso-8859-1?q?Bj=F8rn?= Mork Subject: [PATCH net] net: ethernet: mtk_eth_soc: fix RX data corruption issue Message-ID: <138da2735f92c8b6f8578ec2e5a794ee515b665f.1677937317.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Disposition: inline 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?1759445527074872170?= X-GMAIL-MSGID: =?utf-8?q?1759445527074872170?= Fix data corruption issue with SerDes connected PHYs operating at 1.25 Gbps speed where we could previously observe about 30% packet loss while the bad packet counter was increasing. As almost all boards with MediaTek MT7622 or MT7986 use either the MT7531 switch IC operating at 3.125Gbps SerDes rate or single-port PHYs using rate-adaptation to 2500Base-X mode, this issue only got exposed now when we started trying to use SFP modules operating with 1.25 Gbps with the BananaPi R3 board. The fix is to set bit 12 which disables the RX FIFO clear function when setting up MAC MCR, MediaTek SDK did the same change stating: "If without this patch, kernel might receive invalid packets that are corrupted by GMAC."[1] [1]: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/d8a2975939a12686c4a95c40db21efdc3f821f63 Fixes: 42c03844e93d ("net-next: mediatek: add support for MediaTek MT7622 SoC") Tested-by: Bjørn Mork Signed-off-by: Daniel Golle Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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(-) base-commit: 528125268588a18a2f257002af051b62b14bb282 diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 14be6ea51b88..3cb43623d3db 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 afc9d52e79bf..b65de174c3d9 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -397,6 +397,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)