From patchwork Sat Feb 11 16:04:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 55847 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1567418wrn; Sat, 11 Feb 2023 08:37:43 -0800 (PST) X-Google-Smtp-Source: AK7set+8K7/nTHCfTDaPJGulNFCaKG1OnB9tMz8MNY9tNkj5OHMepT1C2WzbI6RN406L6Z8n4PiZ X-Received: by 2002:a17:907:7d93:b0:8af:33d2:787c with SMTP id oz19-20020a1709077d9300b008af33d2787cmr10753466ejc.13.1676133463133; Sat, 11 Feb 2023 08:37:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676133463; cv=none; d=google.com; s=arc-20160816; b=eEbA0n2mzs4AK85DHYV++sIAAR03RAi5FUxXkHyqqNmtRh2JHv2P4Xl6jkkC0cxepJ jsIYUOB1Ftr7v9DjjmGALCtZKCpM5Zqi5xujMvoqLTzAF1gzJJh2NjvJ7RwGMLXGEvaL cyQGwQl6Z1VTB1WsKHMSXjvHhXXFuI++kr18/fKC1H+ODEChDfKPHtzLDIttZu8lj36F 0Sk+E/UMqK1MMN9VyKVxqi9bNdmF5oXpffOcNoCqdG6IX//tKgqm0R9EqOgGxT3ihXWZ l4MKaaD6yYcAm2IKU2wB/68t+OCYR7D0QYIu+yTsbGy2CciMFZt+vydMYS1yzAYxFGyn 1ZvA== 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=XoqAvgryegCD9SEb96oXs7sYN4tmck2a+Qfli6dYbPY=; b=pKxli6pWkvRGqMpgu0Cq3w9nSFGlWn4zTiA0GOHZpjETnzwfR3+HYwp4bss6ey9V/b /pkpsIyaqJiVez70dRJCh3jXxwg3aBw51QiUZcn+2LUromGdjzFuhnmFvIJps17Y7gdp TfCcGk0g+bHWr93j4t/nccTKvj9DzK0Nymj+wtl681qXWyFTBWvzAfbsSn5Y/RAS8rFG elcDx/jePtRLke3FkRhPKSWsaBkAyz6fb6rxBa9YNH22A3ggdqof28CfZSSLqWmNlQiU RkNP47rKDgWo0OGbImdLC/I/xVclOb956REbIspFR1D3nXnzad0LHovzDnMUdfad2qtw fwng== 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 gc18-20020a1709072b1200b008af3fbf4aa0si7563987ejc.388.2023.02.11.08.37.19; Sat, 11 Feb 2023 08:37:43 -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 S229576AbjBKQG3 (ORCPT + 99 others); Sat, 11 Feb 2023 11:06:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbjBKQG2 (ORCPT ); Sat, 11 Feb 2023 11:06:28 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08D9C2E815; Sat, 11 Feb 2023 08:05:57 -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 1pQsNt-0004OH-2G; Sat, 11 Feb 2023 17:05:53 +0100 Date: Sat, 11 Feb 2023 16:04:18 +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 v5 08/12] net: ethernet: mtk_eth_soc: fix RX data corruption issue Message-ID: <70126fe0a57597872dd7727e91836854ff5094b7.1676128247.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?1757553322584528418?= X-GMAIL-MSGID: =?utf-8?q?1757553322584528418?= 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 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)