From patchwork Fri Feb 3 07:02:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 52334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp686834wrn; Thu, 2 Feb 2023 23:09:20 -0800 (PST) X-Google-Smtp-Source: AK7set9txOd/vU2mD40Sb3Z+4fdj+3ZlrLiui2YQ1iDSGw3SYD8Oif4NGLjOUCKQgGNJDaZJu5vr X-Received: by 2002:a17:906:22d4:b0:883:b70b:c04e with SMTP id q20-20020a17090622d400b00883b70bc04emr8748012eja.60.1675408160765; Thu, 02 Feb 2023 23:09:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675408160; cv=none; d=google.com; s=arc-20160816; b=0Ogt+Yzrxpr5bSbpnqU3felWXVwkGTZrgGyXeUGlf/TX7vNtzt2Uq6W2j8fie42LWs ngzETGvQXnkeSPJwi5uYFS1Y7/ccNGIefZjDzN0j06uAXTNcrsoz7PX80LBC/Yg6B5Ro sceOVmy2SDHkvYH2bzsLIP/pKrhYIzDgEhAMNf/9mB4RTZKw6Jl/x0m9ZGD+FxJHqkA2 jpndHb4//6jqN/UPrm7lgdVusE9u8qB36mzPlR+WgqKmJwCEqgPHdsbPZv3zhZRFFt7Q qfitHyG/N8X6YG/FzCyHzdKE9qClvOhRil4Xe4z0rAmLhGuxpkX2HvbesvIZLG9sk9/p Ngmg== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Jlf4hobLyHbU0/3M0ScrKJ/4XN3z6Nk+WdjQzYU/2bI=; b=lYrvzuMFspdwhu+AqeP4dfLav/j5eyjwV79b+m6/HpDvv2Jw3DFJCahqn+ey88y0Y+ jKypIOkzRKApTqqxq8rnxC65Z/5xtf0cYNENqc0//HWfDAKU8UIeNgfMUbar2T5gk3eM Q+q6njrf6vNHWV+ea4wd8snpJ4TNM3yWNp5H3csYs3FAYNBLYMJFFq5wGy4J7GIZQgeX ox40moWxoWo0Fyd/0Vjc72+2/eUu0r2X6A2K/6Ny7DLYj9OJTOwGxiOaaxefb99c3Ebo H2O+9o/3Vy6+0zcIbLBoYRtF8zIQleVM6ulQEcOCqX268lc/jZFrAUye3PJhiOQUfqtv zdpQ== 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 r5-20020a170906a20500b008784bf181ebsi2246804ejy.147.2023.02.02.23.08.56; Thu, 02 Feb 2023 23:09:20 -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 S232149AbjBCHEm (ORCPT + 99 others); Fri, 3 Feb 2023 02:04:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231579AbjBCHEk (ORCPT ); Fri, 3 Feb 2023 02:04:40 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85A152A17A; Thu, 2 Feb 2023 23:04:10 -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 1pNq7E-0000rX-35; Fri, 03 Feb 2023 08:04:09 +0100 Date: Fri, 3 Feb 2023 07:02:28 +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 5/9] net: ethernet: mtk_eth_soc: fix RX data corruption issue Message-ID: <96c628df0991104d255e6d4696988686387bc2ef.1675407169.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?1756792787279450530?= X-GMAIL-MSGID: =?utf-8?q?1756792787279450530?= 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] [1]: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/d8a2975939a12686c4a95c40db21efdc3f821f63 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 9050423821dc..f09cd6a132c9 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 d39717582a85..20d8ea20f164 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -402,6 +402,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)