From patchwork Wed Sep 20 19:27:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13393349 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 6B353C04FEE for ; Wed, 20 Sep 2023 19:30:16 +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=u0qMTJOS7uCMCqBPHJvPAH+Av3bhn6VJFFNV+4xjr2Y=; b=CE8YgjTWop2d+D u7laVHoiVQR3VdkhJMB6ZE+7Vks8mSsdgpVL6ExhOEZWazl1v3fMpMkj6do87Bs/F0XONpze1ahtd vldG7DxIsQW66nsbnQlSDw9TwuruOhpVrw75zUDMbLimZLwWUW5RIOCgbGRWHD86ENCAAi4PZV/p8 /NNiKPEolU3W28XXGRNASSOWVpCrp4rO9iWQx0ek+8DJ/yifFrYW+9xBV7rrA6kCjEbUU2MruhyEl CbAA8w3SVLw9cEqXitsfjdxfiX+iVGCNEIwEBFCsnYLcv3qIvXduKrUo6x9tJRh2McMR577FBvwal CPSD7g7DVh1eE7zVLa2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qj2tU-00413A-0M; Wed, 20 Sep 2023 19:29:52 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qj2sq-0040YJ-2c for linux-arm-kernel@lists.infradead.org; Wed, 20 Sep 2023 19:29:14 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-50300141a64so449201e87.0 for ; Wed, 20 Sep 2023 12:29:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695238151; x=1695842951; 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=ruI/DsrXUPHPt+yo4IDD0wOJzQ+cTuT8XaOYtD4sKFA=; b=EbH75EGrU85IyE4XQqvxvzkblrIUwJDJeWkE3nZM2yIiqca8CBS5LwFnR8QwindVeb h09Vy7HMzKpnOX5UHCUMaN8kzHDx00l5RnAyynHMxlPe+lm+MKxT5s7gFZxnQdJe+uBO rJcITyyOhf/wT+RpgPobquSX3t0aeAW99GuYShW9dyLugJPOm6XlqftfVotrBUjxFJkz Kp8q4o/Z4uzTmX9UQRYQYEWBF4RmqBYRYiJc+CSbqIJNFnVxpoBzYWhtr/siqFUWCm9m KUqcYpOA2Y/VtxNnIs4uvn//ipLm0X+MMAF93d+TOR+GrGiW1V8Hv7CihrPtOsyTC094 pS2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695238151; x=1695842951; 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=ruI/DsrXUPHPt+yo4IDD0wOJzQ+cTuT8XaOYtD4sKFA=; b=uVFViPhJUMdF3fyZWHwb/PcUCeyna2FD1R3qNlWg1BjeW2JvUEcuZzmSPsjgofUWOq QryHka9xcAEMREsSJ9P5EzOLXeaZ4agL1tpiq7C3MC2WETcXoyj5N+P7rHAgXkc8oiZy 6hziUjyYdz+gG78/C5HKvthAt9tWYEYdNhMOM+tYrzGB2rMYZ66menJp2Sqzscv62mXN PezvvHunL2YPDFJ9SRqlizND3IIDBPlKzgqBRmwuJ7b5WlAV3lI0yudbX3Aqz0myDrb7 6BKcyNOffF0E/cHd4mITEuGh2dGGlKl8xx4Vn66B45O2mOWHk6GFpPLnW5C2x5hfrm+G XUXA== X-Gm-Message-State: AOJu0Yx1oolPY+wpaMxrxoKkLhJubhOTzvvxpjuoyPnq5UvRRSoSLo3i yTWw/w88f1AGuYrQ2czf8u8= X-Google-Smtp-Source: AGHT+IGNZjm+wfCwzWQAszOVACunejknYU5hlY3VaoId/Y1DBikEzHrl+fcXMYzw4TlI07AA56CvxQ== X-Received: by 2002:a05:6512:3f1:b0:500:91ac:c0b5 with SMTP id n17-20020a05651203f100b0050091acc0b5mr2883240lfq.30.1695238151186; Wed, 20 Sep 2023 12:29:11 -0700 (PDT) Received: from localhost ([178.176.86.251]) by smtp.gmail.com with ESMTPSA id z23-20020ac25df7000000b004fdde1db756sm2808772lfq.26.2023.09.20.12.29.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:29:10 -0700 (PDT) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 15/18] EDAC/synopsys: Add HIF/SDRAM mapping debugfs node Date: Wed, 20 Sep 2023 22:27:00 +0300 Message-ID: <20230920192806.29960-16-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230920192806.29960-1-fancer.lancer@gmail.com> References: <20230920192806.29960-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_122912_864951_9527AD81 X-CRM114-Status: GOOD ( 20.04 ) 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 available address mapping is about to be utilized for the erroneous SDRAM address decode, before adding such functionality it will be useful to have a way to get an info regarding the most complicated part of the address translation - HIF/SDRAM mapping table just in case something gets wrong in the implemented translation procedures. So add the DebugFS node which on read returns the HIF/SDRAM mapping table in the hexdump-like manner: first line contains the HIF address bit position units, first column contains the HIF address bit position tens, the line and column intersections have the SDRAM dimension (row/column/bank/etc) and a bit position used to encode the corresponding HIF address bit. Note DW uMCTL2 DDRC IP-core doesn't have a parameter to set the HIF address width. So the maximum value (60 bits) of the UMCTL2_A_ADDRW synthesize parameter [1] is utilized as the maximum HIF address width. That parameter defines the controller ports address bus width and in case if the DQ bus width equals to eight bytes defines the HIF address width too. So its upper constraints is fully applicable in this case. [1] DesignWare® Cores Enhanced Universal DDR Memory Controller (uMCTL2) Databook, Version 3.91a, October 2020, p.515 Signed-off-by: Serge Semin --- drivers/edac/synopsys_edac.c | 82 ++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index a359018c261c..6b8949c66eef 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -156,6 +156,7 @@ /* DDRC address mapping parameters */ #define DDR_ADDRMAP_NREGS 12 +#define DDR_MAX_HIF_WIDTH 60 #define DDR_MAX_ROW_WIDTH 18 #define DDR_MAX_COL_WIDTH 14 #define DDR_MAX_BANK_WIDTH 3 @@ -1324,6 +1325,84 @@ static int snps_ddrc_info_show(struct seq_file *s, void *data) DEFINE_SHOW_ATTRIBUTE(snps_ddrc_info); +static u8 snps_find_sdram_dim(struct snps_edac_priv *priv, u8 hif, char *dim) +{ + struct snps_hif_sdram_map *map = &priv->hif_sdram_map; + int i; + + for (i = 0; i < DDR_MAX_ROW_WIDTH; i++) { + if (map->row[i] == hif) { + *dim = 'r'; + return i; + } + } + + for (i = 0; i < DDR_MAX_COL_WIDTH; i++) { + if (map->col[i] == hif) { + *dim = 'c'; + return i; + } + } + + for (i = 0; i < DDR_MAX_BANK_WIDTH; i++) { + if (map->bank[i] == hif) { + *dim = 'b'; + return i; + } + } + + for (i = 0; i < DDR_MAX_BANKGRP_WIDTH; i++) { + if (map->bankgrp[i] == hif) { + *dim = 'g'; + return i; + } + } + + for (i = 0; i < DDR_MAX_RANK_WIDTH; i++) { + if (map->rank[i] == hif) { + *dim = 'a'; + return i; + } + } + + return DDR_ADDRMAP_UNUSED; +} + +static int snps_hif_sdram_map_show(struct seq_file *s, void *data) +{ + struct mem_ctl_info *mci = s->private; + struct snps_edac_priv *priv = mci->pvt_info; + char dim, buf[SNPS_DBGFS_BUF_LEN]; + const int line_len = 10; + u8 bit; + int i; + + seq_printf(s, "%3s", ""); + for (i = 0; i < line_len; i++) + seq_printf(s, " %02d ", i); + + for (i = 0; i < DDR_MAX_HIF_WIDTH; i++) { + if (i % line_len == 0) + seq_printf(s, "\n%02d ", i); + + bit = snps_find_sdram_dim(priv, i, &dim); + + if (bit != DDR_ADDRMAP_UNUSED) + scnprintf(buf, SNPS_DBGFS_BUF_LEN, "%c%hhu", dim, bit); + else + scnprintf(buf, SNPS_DBGFS_BUF_LEN, "--"); + + seq_printf(s, "%3s ", buf); + } + seq_putc(s, '\n'); + + seq_puts(s, "r - row, c - column, b - bank, g - bank group, a - rank\n"); + + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(snps_hif_sdram_map); + /** * snps_data_poison_setup - Update poison registers. * @priv: DDR memory controller private instance data. @@ -1443,6 +1522,9 @@ static void snps_create_debugfs_nodes(struct mem_ctl_info *mci) edac_debugfs_create_file("ddrc_info", 0400, mci->debugfs, mci, &snps_ddrc_info_fops); + edac_debugfs_create_file("hif_sdram_map", 0400, mci->debugfs, mci, + &snps_hif_sdram_map_fops); + edac_debugfs_create_file("inject_data_error", 0600, mci->debugfs, mci, &snps_inject_data_error);