From patchwork Wed Sep 20 19:56:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13393390 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 D56C5C04FFA for ; Wed, 20 Sep 2023 19:58:24 +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=zLqW5Oe7BNDZCgtIEjlUA2MBaAr6dXVGs9plPgMRmdY=; b=ZaCNkHHqmnsexh 3x+eA2WHcdSq07BWJc17MZvaoJw2iNX6079RRDw3GS4oC4dPejA7uT+VXaKTkVMmvTDf/hU8V9KEf qubZfsFOim2SlWNvU9ZDqnQi2QHjg6kUQF0AtNE64PahIKfuK2cHKceloIXc17FTUt3IUOeYt7PDe 5UTlxoMIar+8ZP8SEBqNC0RyhnkXDtm9nzs+644IFZtKYoK3cD/0A4OrQRN2+1dy0C3/bgkKpRb/d Zk3hMkYO/dQ8aiIJ/RTVtBMdz9s0ZPe4aB7ptLVDUbZqB0ZREJEs89zYlJML9z2Aob844CYHpOsbG PyIuYSGxmRXBFz8O3TsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qj3Kk-0044al-29; Wed, 20 Sep 2023 19:58:02 +0000 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qj3Kh-0044Z5-2Y for linux-arm-kernel@lists.infradead.org; Wed, 20 Sep 2023 19:58:01 +0000 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2c00c0f11b2so3021311fa.1 for ; Wed, 20 Sep 2023 12:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695239878; x=1695844678; 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=CSjOv/gy0GrWM9KNB610Bni0nvt6VKfuUzLES6DifmE=; b=UX1dl1kL7xkq1GbF3o6e7ampFfCcXXwHTUbP1aLz7SfkAPY6he1elHe5RTtWlcYNFg d3KHyFVREm3YIJ3fnTF3iKK6nlVw9DTuxH6nj6vPk6ruAfp2xodX4P1JZbCexjYHUgev UI14MpGsvM4t1XbkwJmnqs7Usb0so394Xraji62rG2p0LyTanW5clcQGS1zRyBvKmAGs QnI6LDc7IVyvaLbPrNfQKqjXmabtuJzfT1/U1i/aoRshHW4spgXGjmu41441fs261/IL g1dTfmus83jkR/mE5kEQbasc55ByJQDvvHisvxu95s2bA5r5+WVp/Z3fuwDowuripZRk tIhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695239878; x=1695844678; 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=CSjOv/gy0GrWM9KNB610Bni0nvt6VKfuUzLES6DifmE=; b=DzMaUMnZ/AOo06u31yz/YcXjj9eF81d9EyIYSxYQmZTdXnyNh7ne4dPGPhVgY49oF0 ErqozXsqBc+/9aLcjyo2POpeg06oLzN/KjMzmlslk6Rv7qlgClkSV/9iQvKO5bU08Ubi LrTAaqssr7JNfOOfT3n2Z7tc/srb3xcm8iwk5jlkz68wMLrJgxavknEbPjqr4EphcdX0 na5rZm9fasVtAO5xhxCgwgCSAKLONf7GlyZ+YAksFOFGOam5ZqZnWOwbEsHvoWuxysKb vjezfdh8MOwWcBpei6Bgfj4lKHGUKkZnlcf1Xh9npa3ZQlVYTrZOZgiNGgyI48Tpjpa/ zQDQ== X-Gm-Message-State: AOJu0Yya3bwIF28RDAhT6fXW6csaAT3UkVlzYDcibQQxuIPUSdk80BmV srV3c5zqujUFKYcyvpqwzHg= X-Google-Smtp-Source: AGHT+IEM94ueN6ISp1Uin8pGHj3TNnHZWOhr2rpB5ApTgb37ngBAYvDDoCEgLObR9kad0OEHMZH5nQ== X-Received: by 2002:a2e:9111:0:b0:2bc:d09c:853a with SMTP id m17-20020a2e9111000000b002bcd09c853amr3288500ljg.6.1695239877975; Wed, 20 Sep 2023 12:57:57 -0700 (PDT) Received: from localhost ([85.140.6.205]) by smtp.gmail.com with ESMTPSA id s29-20020a05651c049d00b002c128e4524dsm158821ljc.116.2023.09.20.12.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:57:57 -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 04/13] EDAC/synopsys: Add optional ECC Scrub support Date: Wed, 20 Sep 2023 22:56:35 +0300 Message-ID: <20230920195720.32047-5-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_125759_903966_BC809107 X-CRM114-Status: GOOD ( 21.48 ) 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 DW uMCTL2 DDRC ECC has a so called ECC Scrub feature in case if an single-bit error is detected. The scrub is executed as a new RMW operation to the location that resulted in a single-bit error thus fixing the ECC code preserved in the SDRAM. But that feature not only optional, but also runtime switchable. So there can be platforms with DW uMCTL2 DDRC not supporting hardware-base scrub. In those cases the single-bit errors will still be detected but won't be fixed until the next SDRAM write commands to the erroneous location. Since the ECC Scrub feature availability is detectable by means of the ECCCFG0.dis_scrub flag state use it to tune the MCI core up so one would automatically execute the platform-specific scrubbing to the affected SDRAM location. It's now possible to be done since the DW uMCTL2 DDRC driver supports the actual system address reported to the MCI core. The only thing left to do is to auto-detect the ECC Scrub feature availability and set the mem_ctl.info.scrub_mode mode with SCRUB_SW_SRC if the feature is unavailable. The rest will be done by the MCI core when the single-bit errors happen. Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 001553f3849a..4ee39d6809cc 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -32,6 +32,7 @@ #define SNPS_EDAC_MOD_VER "1" /* DDR capabilities */ +#define SNPS_CAP_ECC_SCRUB BIT(0) #define SNPS_CAP_ZYNQMP BIT(31) /* Synopsys uMCTL2 DDR controller registers that are relevant to ECC */ @@ -119,6 +120,7 @@ #define DDR_MSTR_MEM_DDR2 0 /* ECC CFG0 register definitions */ +#define ECC_CFG0_DIS_SCRUB BIT(4) #define ECC_CFG0_MODE_MASK GENMASK(2, 0) /* ECC status register definitions */ @@ -1014,6 +1016,10 @@ static int snps_get_ddrc_info(struct snps_edac_priv *priv) return -ENXIO; } + /* Assume HW-src scrub is always available if it isn't disabled */ + if (!(regval & ECC_CFG0_DIS_SCRUB)) + priv->info.caps |= SNPS_CAP_ECC_SCRUB; + /* Auto-detect the basic HIF/SDRAM bus parameters */ regval = readl(priv->baseaddr + DDR_MSTR_OFST); @@ -1490,8 +1496,14 @@ static struct mem_ctl_info *snps_mc_create(struct snps_edac_priv *priv) MEM_FLAG_DDR3 | MEM_FLAG_LPDDR3 | MEM_FLAG_DDR4 | MEM_FLAG_LPDDR4; mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; - mci->scrub_cap = SCRUB_FLAG_HW_SRC; - mci->scrub_mode = SCRUB_NONE; + + if (priv->info.caps & SNPS_CAP_ECC_SCRUB) { + mci->scrub_mode = SCRUB_HW_SRC; + mci->scrub_cap = SCRUB_FLAG_HW_SRC; + } else { + mci->scrub_mode = SCRUB_SW_SRC; + mci->scrub_cap = SCRUB_FLAG_SW_SRC; + } mci->edac_cap = EDAC_FLAG_SECDED; mci->ctl_name = "snps_umctl2_ddrc"; @@ -1584,6 +1596,8 @@ static int snps_ddrc_info_show(struct seq_file *s, void *data) seq_puts(s, "Caps:"); if (priv->info.caps) { + if (priv->info.caps & SNPS_CAP_ECC_SCRUB) + seq_puts(s, " +Scrub"); if (priv->info.caps & SNPS_CAP_ZYNQMP) seq_puts(s, " +ZynqMP"); } else {