From patchwork Sat Feb 3 05:14:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Furong Xu <0x1207@gmail.com> X-Patchwork-Id: 196197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp858450dyc; Fri, 2 Feb 2024 21:26:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFW1qIpdILaQmvGH7rP463NDCM0neu3YLOw+y1S9bW8vhHFutksE1xhCOYrroNQzB3l6/2t X-Received: by 2002:a9d:6d87:0:b0:6dc:9cb:bd76 with SMTP id x7-20020a9d6d87000000b006dc09cbbd76mr4068109otp.4.1706938019689; Fri, 02 Feb 2024 21:26:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706938019; cv=pass; d=google.com; s=arc-20160816; b=CQH+71GaKvDtUIGpLFj+KOgSTkq89U/hYDt/cRpXkjKvdkT6nBBoIp7RMro+9nzXQI xhVNwTPfuvN4EQuOYF8vOtrZzoCq5v1NFBbSJsYjHOaifUxGWVE8cMibige1ylwSWCfI SU2g0VZoRsLuPeiUR6t/lzQbeCWHEBMkNxira/xOCxEalRuzR+YLCHNED7n3XBDvSgdH 0ZcRClcOpLGGCkeRhXgeiXgeugmOFgEG4k58Ez2Wwo+pJt3XdQeHS9JUtWUF9h130qq6 5rr40MGfb5/eawS5t7pUtrxW1uLKcDQypJS1XbESlOyippqIOmftiAMoqp7MJyOeVVUe ZtHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=h3LoOjm98tL5WXwbrdlM6AeAwrTcH5b9oPsvdNs4GLQ=; fh=Z7Of9crIFuqOxSFBVebCbGN26iZvDWdHtxwp/5mh13g=; b=RqEZoyQK/ZfSPtZiELkp2ePDsyqdh60FQUtAYVO9S9drzDb04+LEEqCb1NiXAV+2gH eeZ6WW8OsElqjOisL5jHMp4iJ8FxyzHWt50yT0GB9yUuHB0Gj1KFOXDCAG2m5N+AW+nk yY6ijs5hXsilDOaWu7Z2qFlvpp8f81QeUCFqGam6fYJxrk3Os+kpwkKDQIo6e183PmU2 B3S4LyII3pBlKmyQc9I7YDlzoUEEjcF2IZ/7VcVHcGElsXkfi4kd8qsNvr3V2CItlLQw +8b+F2d+9paICpikfZDuw9lTDejf+LCYLgKnYQPBRJR4zy8Bip7EIlX6ftzpcJIMsm9J mrVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Qe/IftEM"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-50933-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50933-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCVT7Xf/m+nACOO2uq+2bqm5LaINU9/Pev9wLBTI1q3WEES1M2u25yXtkWNOdw3i/eU00C2IauMMZndxPD/5PF+rjuD47A== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z7-20020a634c07000000b005d5434a5732si2558210pga.456.2024.02.02.21.26.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 21:26:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50933-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Qe/IftEM"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-50933-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50933-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id DD44AB24045 for ; Sat, 3 Feb 2024 05:15:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C4D8111B1; Sat, 3 Feb 2024 05:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Qe/IftEM" Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A335610A09; Sat, 3 Feb 2024 05:15:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706937316; cv=none; b=I66CjnDOyyLNmWso+onOosceBwJSDJoZq3Dvsw1XW2T0bdMXDFiUkYMQRLtyku3Tp/D8fpCFuiGG/KRzD3VDw+AyxxvFHvqtXYm4a96uQQb0hxcAIzO+2f/aDDCKkErFxT29xai0LiJPqLiuaUpPYaAxyEmteuO4KItQOIX0JW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706937316; c=relaxed/simple; bh=fPbOGXg77mkW7kyUJXKhTzJ1xw3ULkg9SC3yMUThOdc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=G3S2qKyz9bxFkcZGFjCsrh73MoNOsPGI1fgTzOAb//Oeic1pCMXksXRMfC+qR8oFM+x9UDaL1uTPNzZnjA8XI1OUpqOkYDaKvoxFUOugUYFyd3Z+aR1PFD+kodrpc9cdzj/qHgt5nw5KEnvcy2d+6pbuNO6I3tm9xpl+EvUvqpU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Qe/IftEM; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so2749572a12.1; Fri, 02 Feb 2024 21:15:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706937314; x=1707542114; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=h3LoOjm98tL5WXwbrdlM6AeAwrTcH5b9oPsvdNs4GLQ=; b=Qe/IftEMxSrdWNakb3xH42Jim9U3PsEOnUUxXvb1Ow4GiMzGpsxMcKc1vQM+eeINpo LW1hUxcFcSy2VJaoSnbv9t7bVEMFUjmDkiMm30l+y6wmHioiVuFJvxWBbGTcJmifjUqa ZO9/glvG8ohgUDFLDml2EfFshGjSsxSnhrW7n1rS4sHMCfRauHCaTsDB41BBQBqEcFiM WKlaFopOxYIVQZbeQhUMc5Izzi9X4w436z0DrI5JnkgdBZUFMw9kcgdyjDrYhy0N9F4H N3RfudHEsdHFHB1kn3rezTXFqCRZtdsFoOwm1+/yRao47bDeJ93goUyxIVQQc1bGBXsE vSWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706937314; x=1707542114; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=h3LoOjm98tL5WXwbrdlM6AeAwrTcH5b9oPsvdNs4GLQ=; b=d5FHxa48VoXib4my7127x8zgHukOIJfytZQtM7sL48WXLx7OTrB5pZA1Fwnr6tMld4 3PJWe9BA5sm1FzC9U0TJPAQaWGccyO33Xnll4G+RLG/F8l0aMRsk1WBieO4kgaOcVG6G 2b1qpbtriyoMnQGQiQ4n8wjsL76R5G4OI5zCHhb0dzzGIXZZfbqLMuefvXId+N9DyCpM wbUOPTaaJVg5AwfuUAXrDkulDVzxlQnJGml4QDPq0fm+usu4PhzVTlkljbSc1DCVEQxh cDB6zc9xIfk51rGszu1/oj/d6pMH+/RU2hrHKKKgGSUXOeP3pIVB7czbNCrDK/9vgvv8 /5iQ== X-Gm-Message-State: AOJu0Yx3qURVkERN3x5pkDlR+OejjXmgMPbWJvzgP2TtGvWuFylJux+7 ZLGkBBuNlCSyt9K9yu/vWe+gp4lDiL4ETytZhXTrDYcnsrzPyC9J X-Received: by 2002:a05:6a20:d045:b0:19c:6ce1:d62b with SMTP id hv5-20020a056a20d04500b0019c6ce1d62bmr5425326pzb.9.1706937313814; Fri, 02 Feb 2024 21:15:13 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCW9ZlMmLRvZqAZIKfYVt8wIf1hWyHEwVksGBn/sJCDsSEwkn3duMXTCzXzUsjCr5zXg3lg5jIJd3pgJN3vZT6Kv24gSwXt6Ir5t9DBDrPNNzl9ds/uhd8bsLWcG/jv6ei1omk9dtluYcvtCRhuDxl1TmSqR/e9yl/3duLEBW/4zFqeQR2vHzmDRDyV2jRDxYmYbIjnvc6/SKXnplPDjyeMRnWZGm7KwLYKqoc1pyJa8vnlT6ed+54PHfnnUGpdl7vOizBiNoZLuMGwOTW/rwrFmjAxip23k0bbzRa6XFX02AWi2IB1gRzUdaK6fL+nCnC3pCwwmg/bMXfo6EOroI2pO5lh7n9SktGAcYCfbhSl6yLeJgAxtPpdpMwUhhoXBwQSLkK+DTfCbsNC8vQ6LZb0ftPRPdIXetETbDTRbaLvEh7Yd51RIgQnChOuR0Ix61cbLc5JGryvmILGqXeYCanyE2mtgfUzcrEfSx9EF85rktPtSuf5sh427WKmu6rDrN7cr8DXXciBiSUy1q3bQFhILMbwe+1UprEU= Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id lw10-20020a056a00750a00b006d9aa6592d0sm2549206pfb.82.2024.02.02.21.15.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 21:15:13 -0800 (PST) From: Furong Xu <0x1207@gmail.com> To: "David S. Miller" , Alexandre Torgue , Jose Abreu , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Joao Pinto , Simon Horman , Serge Semin Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, xfr@outlook.com, rock.xu@nio.com, Furong Xu <0x1207@gmail.com> Subject: [PATCH net v4] net: stmmac: xgmac: fix handling of DPP safety error for DMA channels Date: Sat, 3 Feb 2024 13:14:39 +0800 Message-Id: <20240203051439.1127090-1-0x1207@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789570040249252260 X-GMAIL-MSGID: 1789854240566175816 Commit 56e58d6c8a56 ("net: stmmac: Implement Safety Features in XGMAC core") checks and reports safety errors, but leaves the Data Path Parity Errors for each channel in DMA unhandled at all, lead to a storm of interrupt. Fix it by checking and clearing the DMA_DPP_Interrupt_Status register. Fixes: 56e58d6c8a56 ("net: stmmac: Implement Safety Features in XGMAC core") Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Simon Horman Reviewed-by: Serge Semin --- Changes in v4: - fix a typo name of DDPP bit, thanks Serge Semin Changes in v3: - code style fix, thanks Paolo Abeni Changes in v2: - explicit enable Data Path Parity Protection - add new counters to stmmac_safety_stats - add detailed log --- drivers/net/ethernet/stmicro/stmmac/common.h | 1 + .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 3 + .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 57 ++++++++++++++++++- 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 721c1f8e892f..b4f60ab078d6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -216,6 +216,7 @@ struct stmmac_safety_stats { unsigned long mac_errors[32]; unsigned long mtl_errors[32]; unsigned long dma_errors[32]; + unsigned long dma_dpp_errors[32]; }; /* Number of fields in Safety Stats */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h index 207ff1799f2c..5c67a3f89f08 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -303,6 +303,8 @@ #define XGMAC_RXCEIE BIT(4) #define XGMAC_TXCEIE BIT(0) #define XGMAC_MTL_ECC_INT_STATUS 0x000010cc +#define XGMAC_MTL_DPP_CONTROL 0x000010e0 +#define XGMAC_DPP_DISABLE BIT(0) #define XGMAC_MTL_TXQ_OPMODE(x) (0x00001100 + (0x80 * (x))) #define XGMAC_TQS GENMASK(25, 16) #define XGMAC_TQS_SHIFT 16 @@ -385,6 +387,7 @@ #define XGMAC_DCEIE BIT(1) #define XGMAC_TCEIE BIT(0) #define XGMAC_DMA_ECC_INT_STATUS 0x0000306c +#define XGMAC_DMA_DPP_INT_STATUS 0x00003074 #define XGMAC_DMA_CH_CONTROL(x) (0x00003100 + (0x80 * (x))) #define XGMAC_SPH BIT(24) #define XGMAC_PBLx8 BIT(16) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index eb48211d9b0e..04d7c4dc2e35 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -830,6 +830,43 @@ static const struct dwxgmac3_error_desc dwxgmac3_dma_errors[32]= { { false, "UNKNOWN", "Unknown Error" }, /* 31 */ }; +static const char * const dpp_rx_err = "Read Rx Descriptor Parity checker Error"; +static const char * const dpp_tx_err = "Read Tx Descriptor Parity checker Error"; +static const struct dwxgmac3_error_desc dwxgmac3_dma_dpp_errors[32] = { + { true, "TDPES0", dpp_tx_err }, + { true, "TDPES1", dpp_tx_err }, + { true, "TDPES2", dpp_tx_err }, + { true, "TDPES3", dpp_tx_err }, + { true, "TDPES4", dpp_tx_err }, + { true, "TDPES5", dpp_tx_err }, + { true, "TDPES6", dpp_tx_err }, + { true, "TDPES7", dpp_tx_err }, + { true, "TDPES8", dpp_tx_err }, + { true, "TDPES9", dpp_tx_err }, + { true, "TDPES10", dpp_tx_err }, + { true, "TDPES11", dpp_tx_err }, + { true, "TDPES12", dpp_tx_err }, + { true, "TDPES13", dpp_tx_err }, + { true, "TDPES14", dpp_tx_err }, + { true, "TDPES15", dpp_tx_err }, + { true, "RDPES0", dpp_rx_err }, + { true, "RDPES1", dpp_rx_err }, + { true, "RDPES2", dpp_rx_err }, + { true, "RDPES3", dpp_rx_err }, + { true, "RDPES4", dpp_rx_err }, + { true, "RDPES5", dpp_rx_err }, + { true, "RDPES6", dpp_rx_err }, + { true, "RDPES7", dpp_rx_err }, + { true, "RDPES8", dpp_rx_err }, + { true, "RDPES9", dpp_rx_err }, + { true, "RDPES10", dpp_rx_err }, + { true, "RDPES11", dpp_rx_err }, + { true, "RDPES12", dpp_rx_err }, + { true, "RDPES13", dpp_rx_err }, + { true, "RDPES14", dpp_rx_err }, + { true, "RDPES15", dpp_rx_err }, +}; + static void dwxgmac3_handle_dma_err(struct net_device *ndev, void __iomem *ioaddr, bool correctable, struct stmmac_safety_stats *stats) @@ -841,6 +878,13 @@ static void dwxgmac3_handle_dma_err(struct net_device *ndev, dwxgmac3_log_error(ndev, value, correctable, "DMA", dwxgmac3_dma_errors, STAT_OFF(dma_errors), stats); + + value = readl(ioaddr + XGMAC_DMA_DPP_INT_STATUS); + writel(value, ioaddr + XGMAC_DMA_DPP_INT_STATUS); + + dwxgmac3_log_error(ndev, value, false, "DMA_DPP", + dwxgmac3_dma_dpp_errors, + STAT_OFF(dma_dpp_errors), stats); } static int @@ -881,6 +925,12 @@ dwxgmac3_safety_feat_config(void __iomem *ioaddr, unsigned int asp, value |= XGMAC_TMOUTEN; /* FSM Timeout Feature */ writel(value, ioaddr + XGMAC_MAC_FSM_CONTROL); + /* 5. Enable Data Path Parity Protection */ + value = readl(ioaddr + XGMAC_MTL_DPP_CONTROL); + /* already enabled by default, explicit enable it again */ + value &= ~XGMAC_DPP_DISABLE; + writel(value, ioaddr + XGMAC_MTL_DPP_CONTROL); + return 0; } @@ -914,7 +964,11 @@ static int dwxgmac3_safety_feat_irq_status(struct net_device *ndev, ret |= !corr; } - err = dma & (XGMAC_DEUIS | XGMAC_DECIS); + /* DMA_DPP_Interrupt_Status is indicated by MCSIS bit in + * DMA_Safety_Interrupt_Status, so we handle DMA Data Path + * Parity Errors here + */ + err = dma & (XGMAC_DEUIS | XGMAC_DECIS | XGMAC_MCSIS); corr = dma & XGMAC_DECIS; if (err) { dwxgmac3_handle_dma_err(ndev, ioaddr, corr, stats); @@ -930,6 +984,7 @@ static const struct dwxgmac3_error { { dwxgmac3_mac_errors }, { dwxgmac3_mtl_errors }, { dwxgmac3_dma_errors }, + { dwxgmac3_dma_dpp_errors }, }; static int dwxgmac3_safety_feat_dump(struct stmmac_safety_stats *stats,