From patchwork Tue Feb 7 14:22:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 53927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp4039627dyf; Tue, 7 Feb 2023 06:27:03 -0800 (PST) X-Google-Smtp-Source: AK7set+D4aO1CxU9EKYzuimi5qU+AXxJAROdyVSyV5iBL8cB1IJ7j4hfS/867uqzgZY6atNL63r+ X-Received: by 2002:a17:906:3ec1:b0:88f:87f0:c919 with SMTP id d1-20020a1709063ec100b0088f87f0c919mr3739731ejj.64.1675780023144; Tue, 07 Feb 2023 06:27:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675780023; cv=none; d=google.com; s=arc-20160816; b=ZleVqlWJ22xyOOeQJPe85J1DY5xedClLhzQ4fMsNS/Nj8ygANukWnVhnHB7kgUI7EU tEQfbn4qaNAe1hKpHHBbMLNgY44/Qnxgf86utaMgfGW0ea1ffb1MSJ7bEMqdWghI2OyQ Gq/DLioi4SAFxAzUAb8npDaPqasqvthU5HJ6x5xkuuzhx+9KG3XgWZGf4sREcFdK739m ePHVyXGMRkUBvN3L1vILswRA0nl5QPFDR/l6YKsvJ1kYVyeprVJls71KsNObe6EiAweT i/aUC2b3oMcIsZ2YgZ9FiaXkWBSuMB0IrEgDys3bkKYzw1gywraO1lbIlgYxofSRQhRM +yEg== 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=lTYv9hXZTEjQH4UwLuttEayuF1LPwg3YsvyplzQfcwI=; b=hKbT3gHRxOe1ZmypcjIcGWznQaiYVknwUeIPI/dgfI5Nn4eCBLaK5fqYiKEdH8cKs2 cw4Tq8nj/1gOTlIDczEF4kTVKBZWrZveH4ODK4oVgNb+u9SL+iWtOcQQnriiSLNZ2nVp imCCA+vJxvbbV2Xl+7YCB6zrgy4lSUJaYh9LEJMLF3xGlotmlk+0olWzcpVmup+sqfLl j35K8hiVRdZEmRq6Rzy7um+9zxpU0HdnZx7tKEokLH0z0LD7A+oXrqTE8CnrquROfghm 4iv5Qo7Z9B6ONb+eF+5uDshikUnZ5o7LmquBPfCNq4Du4lP+NUn3SSLpKIxb6/dJ4j2n hElQ== 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 29-20020a17090600dd00b008aabf978cf5si141079eji.137.2023.02.07.06.26.39; Tue, 07 Feb 2023 06:27:03 -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 S232501AbjBGOYH (ORCPT + 99 others); Tue, 7 Feb 2023 09:24:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232317AbjBGOYG (ORCPT ); Tue, 7 Feb 2023 09:24:06 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8D1FD51E; Tue, 7 Feb 2023 06:24:03 -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 1pPOt5-0002BK-1j; Tue, 07 Feb 2023 15:23:59 +0100 Date: Tue, 7 Feb 2023 14:22:22 +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 v2 07/11] net: ethernet: mtk_eth_soc: fix RX data corruption issue Message-ID: <70b6ae254cc3afcce4e36efc9078eb363f027b39.1675779094.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?1757182713664826399?= X-GMAIL-MSGID: =?utf-8?q?1757182713664826399?= 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 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 4ee582e39c12..aabbf0337589 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)