From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB3D8606A325 for ; Mon, 30 Nov 2026 07:27:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=3/oDi1O6 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:CC:To:In-Reply-To:References :Message-ID:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=sO7HkT1jGYtdkCPR+m09ZfoJY5o65qz1eiLvufjeo18=; b=3/oDi1O6QVYPUv brIh/CsKyU9VjJ1CmTzWLTZcxZ9fLQ3fF8kdJQyDKn580letozM+L6akwHEny+zK1utsSaNS1OoFB 8+VMnTHh/ZhSjJMW5Dx7yeysOYF7f2crZfCgLsbBAj2B54M/R4DSybmxPh4bbLnA2UL9mq2OIXwPj tJjqWLyuUk0kEtEa7YaEnShLV+38Ki8ZS7FZQ3jlnvpVnYdbB41bhavUplXnAoLPWz9I38RVBMU4K okcO8J+O1lcOFivEEvfpu5OY7fHOv/80RiMj5kpWk3xolciNiKRvGdC3WhJ98mzIVAv66a4fBOtfa 4H3c66b0+D+FdWsNhb1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXvms-00000003ZTA-0ARu; Mon, 30 Nov 2026 07:26:58 +0000 Received: from mail.aspeedtech.com ([211.20.114.72] helo=twmbx01.aspeedtech.com) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXvlE-00000003Ybq-0e7t for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2026 07:25:19 +0000 Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.39; Mon, 30 Nov 2026 15:24:47 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.39 via Frontend Transport; Mon, 30 Nov 2026 15:24:47 +0800 From: Ryan Chen Date: Mon, 30 Nov 2026 15:24:36 +0800 Subject: [PATCH v7 09/10] EDAC/aspeed: Add AST2700 support X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20261130-edac-v7-9-3aaf6d243f07@aspeedtech.com> References: <20261130-edac-v7-0-3aaf6d243f07@aspeedtech.com> In-Reply-To: <20261130-edac-v7-0-3aaf6d243f07@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck , Billy Tsai CC: , , , , , Ryan Chen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796023486; l=4677; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=T9fOz2P6inJZBO+U+YaQ/2tCGigIPsWOQUq1Zh4xL+Y=; b=8pOVPN3EbE4ejvSHEBLrCGcXxYiNQZc2z97nT/NyOjEIUHxFQb29+Uwt/mp7iixCxmU18HEPL rT9fmqOp1jrBcsBUDvYWSUyPsWB0yFtVYuwqhDVdo0Kwb+hrgQSuoUI X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261129_232516_233393_2F0F2B19 X-CRM114-Status: GOOD ( 19.05 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Add support for the memory controller in the Aspeed AST2700. When corrected and uncorrected errors are pending at the same time, give the failure address to the uncorrected ones, since they matter more. Unmask only the ECC interrupts and mask everything else, rather than trust whatever mask was left set, since the driver doesn't handle the other events on that line. Signed-off-by: Ryan Chen --- Tested on an AST2700 by injecting a correctable error with the memory controller's error injection; the failure address is above 4 GiB: # mw 12c00000 1688a8a8; mw 12c00080 31 EDAC MC0: 1 CE on mc#0csrow#0channel#0 (csrow:0 channel:0 page:0x40ac10 offset:0xb10 grain:16 syndrome:0x0) --- drivers/edac/aspeed_edac.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c index 36599ddf589a..ff92f36e0297 100644 --- a/drivers/edac/aspeed_edac.c +++ b/drivers/edac/aspeed_edac.c @@ -3,6 +3,7 @@ * Copyright 2018, 2019 Cisco Systems */ +#include #include #include #include @@ -30,6 +31,22 @@ #define ASPEED_MCR_INTR_CTRL_CNT_UNREC GENMASK(15, 12) #define ASPEED_MCR_INTR_CTRL_ENABLE (BIT(0) | BIT(1)) +#define AST2700_INT_STS 0x04 +#define AST2700_INT_CLR 0x08 +#define AST2700_INT_MASK 0x0c +#define AST2700_INT_ECC_RECOVERABLE BIT(5) +#define AST2700_INT_ECC_UNRECOVERABLE BIT(4) +#define AST2700_INT_ECC (AST2700_INT_ECC_RECOVERABLE | \ + AST2700_INT_ECC_UNRECOVERABLE) +#define AST2700_INT_ALL GENMASK(16, 0) +#define AST2700_MCFG 0x10 +#define AST2700_MCFG_ECC BIT(6) +#define AST2700_MCFG_DRAM_TYPE BIT(0) /* 0=DDR4, 1=DDR5 */ +#define AST2700_ECC_STS 0x78 +#define AST2700_ECC_REC_CNT GENMASK(15, 8) +#define AST2700_ECC_UNREC_CNT GENMASK(7, 0) +#define AST2700_ECC_FAIL_ADDR 0x7c + struct aspeed_edac; struct aspeed_edac_chip { @@ -198,6 +215,58 @@ static void mcr_set_irq(struct aspeed_edac *priv, bool enable) enable ? ASPEED_MCR_INTR_CTRL_ENABLE : 0); } +static irqreturn_t ast2700_isr(int irq, void *arg) +{ + struct mem_ctl_info *mci = arg; + struct aspeed_edac *priv = mci->pvt_info; + u32 int_sts, ecc_sts, fail_addr; + u8 rec_cnt, un_rec_cnt; + phys_addr_t addr; + + int_sts = readl(priv->regs + AST2700_INT_STS); + if (!(int_sts & AST2700_INT_ECC)) + return IRQ_NONE; + + ecc_sts = readl(priv->regs + AST2700_ECC_STS); + fail_addr = readl(priv->regs + AST2700_ECC_FAIL_ADDR); + + /* clear only the ECC interrupts */ + writel(int_sts & AST2700_INT_ECC, priv->regs + AST2700_INT_CLR); + + rec_cnt = FIELD_GET(AST2700_ECC_REC_CNT, ecc_sts); + un_rec_cnt = FIELD_GET(AST2700_ECC_UNREC_CNT, ecc_sts); + + /* the register holds address bits [35:4], in units of 16 bytes */ + addr = (phys_addr_t)fail_addr << 4; + + /* + * Only the address of the latest failure is recorded, shared by both + * error types. When both occurred, attribute it to the uncorrectable + * errors and report the corrected ones without an address. + */ + if (un_rec_cnt) { + count_un_rec(mci, un_rec_cnt, addr, true); + count_rec(mci, rec_cnt, 0, false); + } else if (rec_cnt) { + count_rec(mci, rec_cnt, addr, true); + } else { + dev_dbg_ratelimited(mci->pdev, "received interrupt with no ECC counters set\n"); + } + + return IRQ_HANDLED; +} + +static void ast2700_set_irq(struct aspeed_edac *priv, bool enable) +{ + u32 val = AST2700_INT_ALL; + + /* interrupts are enabled by clearing their mask bits */ + if (enable) + val &= ~AST2700_INT_ECC; + + writel(val, priv->regs + AST2700_INT_MASK); +} + static int config_irq(void *ctx, struct platform_device *pdev) { struct mem_ctl_info *mci = ctx; @@ -398,10 +467,21 @@ static const struct aspeed_edac_chip ast2600_edac = { .set_irq = mcr_set_irq, }; +static const struct aspeed_edac_chip ast2700_edac = { + .conf_reg = AST2700_MCFG, + .conf_ecc = AST2700_MCFG_ECC, + .conf_dram_type = AST2700_MCFG_DRAM_TYPE, + .dram_type = { MEM_DDR4, MEM_DDR5 }, + .mtype_cap = MEM_FLAG_DDR4 | MEM_FLAG_DDR5, + .isr = ast2700_isr, + .set_irq = ast2700_set_irq, +}; + static const struct of_device_id aspeed_of_match[] = { { .compatible = "aspeed,ast2400-sdram-edac", .data = &ast2400_edac }, { .compatible = "aspeed,ast2500-sdram-edac", .data = &ast2400_edac }, { .compatible = "aspeed,ast2600-sdram-edac", .data = &ast2600_edac }, + { .compatible = "aspeed,ast2700-sdram-edac", .data = &ast2700_edac }, {}, }; -- 2.34.1