From patchwork Wed Jan 31 02:08:28 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: 194431 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1622307dyb; Tue, 30 Jan 2024 18:09:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmh996I7MELuvNUavfzklbIhqguvYo6VkGEyiFHUwcm2zKBR5WC8GiO2rhMrrcLNhj2vR2 X-Received: by 2002:a67:c789:0:b0:46b:a19:1817 with SMTP id t9-20020a67c789000000b0046b0a191817mr185123vsk.23.1706666984723; Tue, 30 Jan 2024 18:09:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706666984; cv=pass; d=google.com; s=arc-20160816; b=qcfNJzKqf7eLc34uJxCAIBwjBv74FQ1GPWqLj8g48uO4bgntFCmafRg/F+Og7vCgI6 CyIvw5eBSutdpFAfuB/gPZjWBA8a2CRXcOToGZ9BC8CawhWGTS54WUwTa6Lz9anlGWBs 64Us47KPWgiCzjBtpCaGNoAkLQK0hc78jXs0PSYWIJ0aQb/M8Z1o/IFNFtD+vE3qboLr X0Ilg3n+jzcuzaU+dcwjmDsIUhcd2yggecCl8PtrYetL9W8e92J/71xOxhccQokrmxjQ hkdIFhrOKmGzYBaxyfq0WWMeA0WFS3cntAdItK4tHAGBkj/lMCsZ9aD0aIiNmnba0STS BoOA== 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=m5ziEuRnoVlXg4S8CY5z7sELD8XyCqrMJK05Jy8oNqg=; fh=+/Zl6GJ/0JxveJ1kkUAB2+Hiagz8eAnddEHLBvep+ZQ=; b=g7FMZIV2ZqaRwGsVNAu+f/xkYZaoZOB3aQAlKjCNyhIbXCZeFMPs8VBa464PA5effb 9Flkq+iiHISGPMgZo3pogcw7aNXF+7uAuBFrdFFrQKMGx1EHRqP0molbarPgQqASnpjw HADOR8ie3yX4pB1+YH+IV/p92JFo/Qp09F+rcsDTWDUw/5d6GoFyJLAcyJYC0bDzd72E poZTYSZ15UoxqvCiSgI+sdsj+btlAUqmncQqlpRC54geyZU9VHqiTIjyncuD6YdB2Urr APye88lgvoNtdhWd8Di8E0JxNF277pwgP+jO2/1ApVIUZxicyX4925CtwQEBk/rA4ZW6 2jkQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=R48xoE97; 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-45624-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45624-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCU2iOgP0JulYwavj6wItrgJZsQWlHREZqjkiQ4ZOZA6uLE63jwDVW2s+S8dNPZPlgIn49P31BSNyu8NCdrcojK48dy13A== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g3-20020a0562140ac300b0068c4f4888d7si6075885qvi.369.2024.01.30.18.09.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 18:09:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45624-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=R48xoE97; 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-45624-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45624-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 73FDD1C227EE for ; Wed, 31 Jan 2024 02:09:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2D4563B3; Wed, 31 Jan 2024 02:09:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R48xoE97" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 C9A775224; Wed, 31 Jan 2024 02:09:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706666959; cv=none; b=cTDDmFiF+q8RJJhTEL3/pg7mfAedbESY0akVZbn6J0W2eqQ/y5po3vcKFNXZuOgfK2baPJ8hACsArtNgzBz8Rd8IoruLC6QJSNFWgM+Gkgd9ApBHshBL3W9HTjVhyqGRtl22wKpqbXVLgnN/bieShDi+pF6utRhypbvgWAga6J4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706666959; c=relaxed/simple; bh=NX4QafmTk7b1WtlBIQHr7YGkouGItPFkB5CuFFckds4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=TXGqiEB0zOiBGQ1oDXEYspjz5t+CmDkpsrur0+onsFQzfmyKar2n3wnEssVyvrsxc9YgmlW44HrajAGfj+8lFYRjpA1o3RNYx53UMIy/istV5kxt9FWNnetsdTr/glHWzF72903zgOVZCnePOmzcOAVYWFVLMBMQp8d281xSdpw= 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=R48xoE97; arc=none smtp.client-ip=209.85.214.177 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-pl1-f177.google.com with SMTP id d9443c01a7336-1d74045c463so26643555ad.3; Tue, 30 Jan 2024 18:09:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706666957; x=1707271757; 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=m5ziEuRnoVlXg4S8CY5z7sELD8XyCqrMJK05Jy8oNqg=; b=R48xoE97oO67g8gO3B2UY66UxFltmCQEwr8RtPqAy++Pvc2KABy4BCjqUPV5GPP4cE w+0iYc+T6TdXF/ykj6ZSoFnQzxKUtXU1/f9Q+w5AShxB2FYkQnKZ58BE8IscXkj5EeYa kTDOLGH7SpWOZmyTFIMmog2AWM4/jA3GCbLjcgmvrJ6bBaSw+n6O1KXJz9IpzGBWl7ul 2dl01AbMCOe1pmLs2tbJXaJLQz2AZXqmV5YhckgAVWko9moiduzU/QSi7EgJv5xnB9Gy mVq5nV6ShgL7/9mCH4tE7WhmCjqVInXBH2Ckud8wmZGpYtrtUEgPgolGt4FIPIcnp9tA ESTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706666957; x=1707271757; 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=m5ziEuRnoVlXg4S8CY5z7sELD8XyCqrMJK05Jy8oNqg=; b=tGbOWUZ2KETCsvzQHZGaNJjb8dJAv90PCcCVBv+HQuuE6dYkv578QR3gkbB8IKzTJ8 xoi80EvMMhKl+EbFE5+4mHVcXj3O1nJaEUHV3HHu2H4v519zj0shOn3PN4LMLp6VxRRf xxil/sWZbedXAoJcpcHliACb6ij2xXIo2SAQN2QKP1QAVxIquZ+C19z0N7SMix1nUU12 03KgsfxrklbWCeM6icH8wZGXtoJhmuJC+t2D9uWRrpFdqA+afpPxcGdSiayFCwGM/7zv 6YOQoloZC4NBB3GQSyGu+3nR/MyUgg/mkSC/s6RR/K1dM6gomzd7iFg9zXkGMoUsz3jK E2UA== X-Gm-Message-State: AOJu0YzlrIGpiiLDvraKCjaD/kFsFJ/w+CCmXEzg62P0f+u38Tjfh38e TQiL03FBRKpuEfQ9J3rD54gaVchm0Ct3hlmgEtJYQrby4r807nRg X-Received: by 2002:a17:902:e5c8:b0:1d8:ef9e:b436 with SMTP id u8-20020a170902e5c800b001d8ef9eb436mr510122plf.22.1706666956903; Tue, 30 Jan 2024 18:09:16 -0800 (PST) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id ld7-20020a170902fac700b001d92f2129dasm9918plb.233.2024.01.30.18.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 18:09:16 -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 v3] net: stmmac: xgmac: fix handling of DPP safety error for DMA channels Date: Wed, 31 Jan 2024 10:08:28 +0800 Message-Id: <20240131020828.2007741-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: 1789570040249252260 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 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_DDPP_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_DDPP_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,