From patchwork Wed Sep 20 19:56:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13393392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 901D1C04FF8 for ; Wed, 20 Sep 2023 19:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NOjc49VpM+49IX/tJ6BCjknIjZ4fYiuDUmM2SeUimiU=; b=AHTRHMRp6h6LTS CUhlYy+ToVkFfWv1WJmhStdCOCQ9qvxFIo0iJ/qdr+PFLQS3N3rLm5wJV1KG0nzVT5xJkLtzAZ0+R 5EUN9HPDLWVHMSr+p9vxtSHTJRSoSUDw/jIz/J2wMlokAgGM4AJw+6nNbid08I7mUyXC0iaulmeAS XiQhGLyKtRs8TwYP6+HCaIXlevbFqCqmsiyZh4PAdy2Zi2IO2L47xRxIBUoHu3qLgf2BXlu993B56 D6gdMCB2jfbvGkmGoXe9vcUEk60fQciaYvFt5ZdODDD45G8AohJqwnE6UkNPtOuGdBmtg6OarhWY6 yqazzGLRCjevniClAyDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qj3Ky-0044ik-03; Wed, 20 Sep 2023 19:58:16 +0000 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qj3Kt-0044fN-0V for linux-arm-kernel@lists.infradead.org; Wed, 20 Sep 2023 19:58:12 +0000 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2c0179f9043so2896571fa.1 for ; Wed, 20 Sep 2023 12:58:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695239889; x=1695844689; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mRfHOWyS91vzVwejPj0vpq+g8xJCLUmXQ16geMum0B4=; b=Jfmxt8OXzWFf9ArA4qWkJU+cY3pash+jr5EgE4m38Fd80aEwTClfkIJ9DPk5mbnEvv NGjHLH5F8RFuwvzBRf3+TSYWbew1vmyw5kPltXCsr86QHvk3+VLWJoMKrI92DSAgbvi3 wFBP8KUNq4UZxknrRF097quVZR+m9Cx6PPOtITQNBblGXHLIbscxFmCpEMf5pL3xprF9 8Rpls9tZJZbZY21iNEO80KUR9ujC5mI1pBC7k7YB/aVY4Y9LlUpZuTxKKha+wzcBCO1S F1Qa1fpHiSg9nsRmBcO1Wlnl1Bd9tgBe/Y2byNoD5/wjJkR/mHHNl+V0yOhDtjJCW0sm rvuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695239889; x=1695844689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mRfHOWyS91vzVwejPj0vpq+g8xJCLUmXQ16geMum0B4=; b=T3fif/+TpFS5glH/aLdHYWMYc2wU+eubiZSIRiEIASBGog5Q4vFfUjdjVD4gWTkQ4j ziwE0DXcspcMA9JeJGe72sl5fpPJsu4KWW3jltCoIgcptnFQyfvZUmMcvShZt2gvhb+V 2ysw9Kvs0XRKOwPwWCYNuwbQLgDo34GkShLDUZrX/fcjHprD+Tii7/gvtmy2Jpgu+AaW 7cmHHYVllzpiXKvBD09BSU0kW9O0sHL9rnqtaTDIooyXPUw1T6uAN7KkwknC/uvX7D0Z i+vp1U1R+uCpW6u4Oetve47iv5sd1vu4Gq+nACZGnwdtM3hyE2mQOSmMY2Fn0QwcgO4W Wa2Q== X-Gm-Message-State: AOJu0YwUBi77MNfXvQinAEIdPVGoNBELT4MYvxHf6QDInlfhibhhTuY2 zBBWFXViZT1vUw82041lVHQ= X-Google-Smtp-Source: AGHT+IEhkeWO5iqHVcZbgwdbs2SL/BUg1QSfo+mbevfgbf8qk8U9vY+ktIQYS1YUrsCWQZJH8B2YQw== X-Received: by 2002:a2e:96d5:0:b0:2bf:e9e8:de23 with SMTP id d21-20020a2e96d5000000b002bfe9e8de23mr3254452ljj.16.1695239889401; Wed, 20 Sep 2023 12:58:09 -0700 (PDT) Received: from localhost ([83.149.21.16]) by smtp.gmail.com with ESMTPSA id t15-20020a2e780f000000b002c02e57c72bsm821321ljc.140.2023.09.20.12.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:58:08 -0700 (PDT) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , Rob Herring , Krzysztof Kozlowski Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 06/13] EDAC/synopsys: Add data poisoning disable support Date: Wed, 20 Sep 2023 22:56:37 +0300 Message-ID: <20230920195720.32047-7-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230920195720.32047-1-fancer.lancer@gmail.com> References: <20230920195720.32047-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230920_125811_206996_75A9F200 X-CRM114-Status: GOOD ( 21.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Even though being a pure-debug feature currently the data poison can't be disabled once it has been initialized and enabled. Irrespective to the way the feature has been implemented it doesn't seem right since the system may print false ECC errors in case if the poisoned address is accessed by the kernel or by the user-space applications. It's possible since the poisoned address isn't reserved in any kernel mm subsystems. Even though that doesn't seem right either at least it's tolerable since the ECC data poison is supposed to be utilized in the framework of the EDAC driver debugging, but having the feature non-switchable can't be justified that easy especially seeing it's not that hard to implement. So in order to have the ECC data poison switchable define three possible values acceptable by the "inject_data_poison" DebugFS node: 1. "CE" - emit correctable error (as before). 2. "UE" - emit uncorrectable error (used to be any non-"CE" value). 3. Any other value - disable data poison feature. Note the macros describing the data poison-related fields of the ECC_CFG0 register need to be redefined in a way so they would be used to separately switch the feature on/off and to select the type of the ECC error. As a result the suggest solution turns into a proper ECC_CFG0 CSRs fields setup based on the value written to the "inject_data_poison" DebugFS node. Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 90640b2f877a..3735c784fac9 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -123,6 +123,10 @@ #define ECC_CFG0_DIS_SCRUB BIT(4) #define ECC_CFG0_MODE_MASK GENMASK(2, 0) +/* ECC CFG1 register definitions */ +#define ECC_CFG1_POISON_BIT BIT(1) +#define ECC_CFG1_POISON_EN BIT(0) + /* ECC status register definitions */ #define ECC_STAT_UE_MASK GENMASK(23, 16) #define ECC_STAT_CE_MASK GENMASK(15, 8) @@ -154,10 +158,6 @@ #define ECC_POISON1_BANK_MASK GENMASK(26, 24) #define ECC_POISON1_ROW_MASK GENMASK(17, 0) -/* DDRC ECC CE & UE poison mask */ -#define ECC_CEPOISON_MASK GENMASK(1, 0) -#define ECC_UEPOISON_MASK BIT(0) - /* DDRC address mapping parameters */ #define DDR_ADDRMAP_NREGS 12 @@ -1787,10 +1787,14 @@ static ssize_t snps_inject_data_poison_read(struct file *filep, char __user *ubu int pos; regval = readl(priv->baseaddr + ECC_CFG1_OFST); - errstr = FIELD_GET(ECC_CEPOISON_MASK, regval) == ECC_CEPOISON_MASK ? - "Correctable Error" : "UnCorrectable Error"; + if (!(regval & ECC_CFG1_POISON_EN)) + errstr = "Off"; + else if (regval & ECC_CFG1_POISON_BIT) + errstr = "CE"; + else + errstr = "UE"; - pos = scnprintf(buf, sizeof(buf), "Data Poisoning: %s\n\r", errstr); + pos = scnprintf(buf, sizeof(buf), "%s\n", errstr); return simple_read_from_buffer(ubuf, size, offp, buf, pos); } @@ -1801,6 +1805,7 @@ static ssize_t snps_inject_data_poison_write(struct file *filep, const char __us struct mem_ctl_info *mci = filep->private_data; struct snps_edac_priv *priv = mci->pvt_info; char buf[SNPS_DBGFS_BUF_LEN]; + u32 regval; int rc; rc = simple_write_to_buffer(buf, sizeof(buf), offp, ubuf, size); @@ -1808,10 +1813,16 @@ static ssize_t snps_inject_data_poison_write(struct file *filep, const char __us return rc; writel(0, priv->baseaddr + DDR_SWCTL); + + regval = readl(priv->baseaddr + ECC_CFG1_OFST); if (strncmp(buf, "CE", 2) == 0) - writel(ECC_CEPOISON_MASK, priv->baseaddr + ECC_CFG1_OFST); + regval |= ECC_CFG1_POISON_BIT | ECC_CFG1_POISON_EN; + else if (strncmp(buf, "UE", 2) == 0) + regval = (regval & ~ECC_CFG1_POISON_BIT) | ECC_CFG1_POISON_EN; else - writel(ECC_UEPOISON_MASK, priv->baseaddr + ECC_CFG1_OFST); + regval &= ~ECC_CFG1_POISON_EN; + writel(regval, priv->baseaddr + ECC_CFG1_OFST); + writel(1, priv->baseaddr + DDR_SWCTL); return size;