From patchwork Thu Feb 9 23:33: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: 55138 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp637454wrn; Thu, 9 Feb 2023 15:37:08 -0800 (PST) X-Google-Smtp-Source: AK7set+0Z5+mf4dyneYrWCgjhWn5i4gb/5QtQrARz6X+2pf4SiL/433rz8Px9OFaPkw7fTJtByWP X-Received: by 2002:a05:6a20:e189:b0:bf:58d1:ce97 with SMTP id ks9-20020a056a20e18900b000bf58d1ce97mr3485910pzb.22.1675985828208; Thu, 09 Feb 2023 15:37:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675985828; cv=none; d=google.com; s=arc-20160816; b=0da0esx2g/Nv3F9oPOxtSfTGO6w5GcDFZnzqFqPL+H7JaWIDxgMiJwKum5Cu958ihs Xt9l/M7Mon2K8xo5MIu2GjDuVWlOROhAJ5BEkbNAWXq3YyxRzEBbEhGLc6kP2TRQFU5K SZo3UiIduBAVfaQFu97tXQWnUhOdwYRF4vC39TddardTxDNiBz3+uBXfYU9g3qxsUrb3 4NeZvSsQD8FwTA1oXJmye+1U692FEUypJcdiPbVYo7Xgn2mDQRSJYeBl2WjRLb2GceU3 GjQ4iDFgRoK47PWzNR7/xl6XvzeEkJZKszOZMacuu7wpjB7t7g1NkXMj1v3tjlUb094u PFrQ== 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=IZOy/GaTidy39O2ypyDvdkvsDriO6jHrWJGNWchaH1I=; b=oCASYQBJl6+bZjXffWniId0Cg9Vsabs/jM4y1Jxq811IlkB+rbPNHG/RGXWLl6RoI5 hVYIYsE2UGOZ0OO/zAhgyigAKRtIDqKqz9tr4Pcyb7I+jZnFegDbuNMkUCuTw3ngnbHx sg6U2qSslwUx/DZTWOcOFjQnTVXJSz5ITanO0hsQ5BPX33xJTt0RHqxQx1FlKJZAJCgV fqtqs2Y2w2FTkMfK+r1SeArgQlzDP0zqg7s6M0qxmtkQtm32p8zRN/PV2gPQu0sMRCXs OGF4IEnNHe/bdIqBrrf4hcON8rj3kZE4K3px9SmrA7GvT3XwwIdu4+O3khM5j0JW5Nhu 6ShA== 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 136-20020a63028e000000b004fb1d2064fbsi3007024pgc.651.2023.02.09.15.36.55; Thu, 09 Feb 2023 15:37:08 -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 S230428AbjBIXfx (ORCPT + 99 others); Thu, 9 Feb 2023 18:35:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231194AbjBIXf2 (ORCPT ); Thu, 9 Feb 2023 18:35:28 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D5E26D8EE; Thu, 9 Feb 2023 15:35:00 -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 1pQGRN-0002Ig-1V; Fri, 10 Feb 2023 00:34:57 +0100 Date: Thu, 9 Feb 2023 23:33: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 Cc: Jianhui Zhao , =?iso-8859-1?q?Bj=F8rn?= Mork Subject: [PATCH v3 08/12] net: ethernet: mtk_eth_soc: fix RX data corruption issue Message-ID: <6d2dd59aa56238dd3afebedd8c131bcd988a8f91.1675984550.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?1757398515925765089?= X-GMAIL-MSGID: =?utf-8?q?1757398515925765089?= Also set bit 12 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] Unfortunately the meaning of bit 12 is not documented in datasheets or vendor code. [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 | 2 +- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + 2 files changed, 2 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..fa61eefe0a61 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -615,7 +615,7 @@ static int mtk_mac_finish(struct phylink_config *config, unsigned int mode, /* Setup gmac */ 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 | + mcr_new |= MAC_MCR_IPG_CFG | MAC_MCR_BIT_12 | MAC_MCR_FORCE_MODE | MAC_MCR_BACKOFF_EN | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_LINK; /* Only update control register when needed! */ diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 142def8629c8..084d07c96c04 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_BIT_12 BIT(12) #define MAC_MCR_BACKOFF_EN BIT(9) #define MAC_MCR_BACKPR_EN BIT(8) #define MAC_MCR_FORCE_RX_FC BIT(5)