Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2757139rwa; Mon, 22 Aug 2022 13:11:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR4y6kUyKFI6MbmBUhOG0/r6hiizBcDNvUW9BokBI9pgmDiSZfojoDJOXX+iozcKji2/Q8PK X-Received: by 2002:aa7:ce10:0:b0:446:a17d:5358 with SMTP id d16-20020aa7ce10000000b00446a17d5358mr663494edv.49.1661199073109; Mon, 22 Aug 2022 13:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661199073; cv=none; d=google.com; s=arc-20160816; b=s+dWXui5HSmFsqfpE5rmhKkR3wMhsYL2IZZ786A+/MvCgDWJ5CGg7H9CTeC8RCDwWM MT+qLJ2vysYLHp5VQr0KaAYmX/xGBLKT6wDoor5GE+H8oyDbTBINClQlDwyqA6kA+Ofv ptSgcUw8tLdn5A4cYW95z1Ryu+Mq2zaqmsmpAtEzAQ2sl7mpreRCldQrJWzEp1nLjF7A 2Yn4/eocUJTk9sSWRD8cco8qSu6uGLluwK66kO3LxiYWfbzlRrSNUHJwxOWAfjUuUtsb Wi/5Gwjhwwno9LHH+E800bnWCmhGqmaHZY5s61GhH0hEdHtlyX7pq/JExzbbzcfYsFtP NTNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=vGDzPPboDDzeWQHOsdZSQJzQCZZGhH5NjkNxhCEEYhw=; b=qtR16setABG6byM5EcqKhwBrHxTA6qjr4Hs2W25UybS3G+uU76Fmh3j+KlH0Y/XaYk KITak49DUYOq/GabVI7OUuHB460g8nB7YOKhrmhzwl6E11PdwmMZJEUQYuwcv+SnKeYh hooVSOUWAQksZFStr1Ml/Et+Y7nq+jITglvXB0svn6pkVRTI+S5TkBAiwsv7q4up8MbC DIFDF8FWREXnXPEg7+h/JJaHy5v/qtd5a66aicgDI9Sz8hu5yso8e8QGmeFNE95eYOIv bb2PpU4pShKmI65qcbUGOuoZC7YHl6ada0PM8Jzyp+4+eKgo4dhDoNArLw28u0un4l0w PVKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=CgvUDRQi; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd39-20020a17090762a700b00731110cfdb8si11167126ejc.934.2022.08.22.13.10.47; Mon, 22 Aug 2022 13:11:13 -0700 (PDT) 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; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=CgvUDRQi; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236900AbiHVTVy (ORCPT + 99 others); Mon, 22 Aug 2022 15:21:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238696AbiHVTU5 (ORCPT ); Mon, 22 Aug 2022 15:20:57 -0400 Received: from mail.baikalelectronics.com (mail.baikalelectronics.com [87.245.175.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 92C8F13D35; Mon, 22 Aug 2022 12:20:26 -0700 (PDT) Received: from mail (mail.baikal.int [192.168.51.25]) by mail.baikalelectronics.com (Postfix) with ESMTP id D8C49DA8; Mon, 22 Aug 2022 22:23:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.com D8C49DA8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1661196213; bh=vGDzPPboDDzeWQHOsdZSQJzQCZZGhH5NjkNxhCEEYhw=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=CgvUDRQiqZUhU8TqDbgjKfWOZkBJFboNyIbn1ukSJEtMdfROnASrWQG/+aCUKTncT qQIwsWgQTVcu5OStH3qVvsdmWg9OzL5yWc0tQCibDhZW1MO458DvYJK2buShOqD4kd jlfgB7j2PCzb5kht4va7XVE87FbAEmUMK5pND+/4= Received: from localhost (192.168.168.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 22 Aug 2022 22:20:19 +0300 From: Serge Semin To: Michal Simek , Borislav Petkov , Mauro Carvalho Chehab , Tony Luck , James Morse , Robert Richter CC: Serge Semin , Serge Semin , Alexey Malahov , Michail Ivanov , Pavel Parkhomenko , Punnaiah Choudary Kalluri , Manish Narani , Dinh Nguyen , Rob Herring , Krzysztof Kozlowski , , , , Subject: [PATCH 06/13] EDAC/synopsys: Add data poisoning disable support Date: Mon, 22 Aug 2022 22:19:49 +0300 Message-ID: <20220822191957.28546-7-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220822191957.28546-1-Sergey.Semin@baikalelectronics.ru> References: <20220822191957.28546-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_PERMERROR 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 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 unswitchable 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 we suggest to 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 we have to redefine the macros describing the data poison-related fields of the ECC_CFG0 register 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 05201f5a284e..028a9ad70d49 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -118,6 +118,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) @@ -157,10 +161,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 @@ -1781,10 +1781,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); } @@ -1795,6 +1799,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); @@ -1802,10 +1807,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; -- 2.35.1