From patchwork Mon Aug 22 19:14:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 12951300 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 DBEB5C28D13 for ; Mon, 22 Aug 2022 19:40:38 +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=lFgHk2GAXKYkMczcUrlQ38S5MmLCnqXj9xHE6ndT1jg=; b=YDGMq83d+SgN97 GCJA8w8o2vRRJ//DyG1Gxji+FybDCbWUewn1D647L6by4Cpn0toirA91Lweq4XzfAIiZbJuAWoa8c P3Uo9VAX1jp1p3/14JEqP90n0LMpH/erYs0Q9ByxlECIHbF+ucKltuwMOU3s1EaSGv7joL4sfRChS 5xbWkrm8MgNJ7P+h6BOCwWZ8q+dCZdMkVKX2cN9THs3rNran/jWEBj9Mzz2GvjJHarH7BmmfZyTpF ClgGWFSCiXRjqqhug3sNGbOHq3zR+bj6jXSwVEapB+YfCc9L/w1wDQHgpjF3S/2bGWhQ/wceu+6tk 7Lw3nGgNig1fxsjLmJlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQDGU-00E8dW-G0; Mon, 22 Aug 2022 19:39:15 +0000 Received: from mail.baikalelectronics.com ([87.245.175.230]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQCss-00Dvjf-9q for linux-arm-kernel@lists.infradead.org; Mon, 22 Aug 2022 19:14:52 +0000 Received: from mail (mail.baikal.int [192.168.51.25]) by mail.baikalelectronics.com (Postfix) with ESMTP id 0CDDBDAD; Mon, 22 Aug 2022 22:17:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.com 0CDDBDAD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1661195870; bh=kpRHN29U1DttBVDwy7emXYhRqJj3KzrSFf1idcg+CP4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=jYC2mlb2pxEhhWnTUAECBQ3M0wLfdoZeld3CH9TGI/hsPrVqBSdZ9raeNBfi5fwoE 3g6L+YtjLtzL75TAa0gPWpJ6cLFkvwtvChcDp1zugODpx1o8/vskjQF4ziwwv2MiUt 97yPZMTSZ1K5fvXeGxApubeOzrKp2smiBhexgwh4= 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:14:35 +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 , , , Subject: [PATCH 10/18] EDAC/synopsys: Get corrected bit position Date: Mon, 22 Aug 2022 22:14:19 +0300 Message-ID: <20220822191427.27969-11-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220822191427.27969-1-Sergey.Semin@baikalelectronics.ru> References: <20220822191427.27969-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220822_121450_887950_480BBD70 X-CRM114-Status: GOOD ( 14.46 ) 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 Since the DQ-bus width is now available in the driver we can use it to calculate the bit-position corrected by the ECC engine. It can be done based on the offsets provided in the table [1]. Using info from that table let's introduce a new inline method snps_get_bitpos() which would provide the actual CE bit-position based on the value read from the ECCSTAT.corrected_bit_num field and the DQ-bus width. The method will be called if a corrected error is detected. [1] DesignWare® Cores Enhanced Universal DDR Memory Controller (uMCTL2) Databook, Version 3.91a, October 2020, p.426-427 Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index af34a83dc1ef..5a116c9ebeda 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -357,6 +358,27 @@ struct snps_edac_priv { #endif }; +/** + * snps_get_bitpos - Get DQ-bus corrected bit position. + * @bitnum: Bit number retrieved from the ECCSTAT.corrected_bit_num field. + * @dq_width: Controller DQ-bus width. + * + * Return: actual corrected DQ-bus bit position starting from 0. + */ +static inline u32 snps_get_bitpos(u32 bitnum, enum snps_dq_width dq_width) +{ + /* ecc[0] bit */ + if (bitnum == 0) + return BITS_PER_BYTE << dq_width; + + /* ecc[1:x] bit */ + if (is_power_of_2(bitnum)) + return (BITS_PER_BYTE << dq_width) + ilog2(bitnum) + 1; + + /* data[0:y] bit */ + return bitnum - ilog2(bitnum) - 2; +} + /** * snps_get_error_info - Get the current ECC error info. * @priv: DDR memory controller private instance data. @@ -385,6 +407,8 @@ static int snps_get_error_info(struct snps_edac_priv *priv) if (!p->ce_cnt) goto ue_err; + p->ceinfo.bitpos = snps_get_bitpos(p->ceinfo.bitpos, priv->info.dq_width); + regval = readl(base + ECC_CEADDR0_OFST); p->ceinfo.row = FIELD_GET(ECC_CEADDR0_ROW_MASK, regval);