* [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support
@ 2026-11-30 7:24 Ryan Chen
2026-11-30 7:24 ` [PATCH v7 01/10] EDAC/aspeed: Stop keeping driver state in global variables Ryan Chen
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Ryan Chen @ 2026-11-30 7:24 UTC (permalink / raw)
To: Stefan Schaeckeler, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Joel Stanley, Andrew Jeffery, Borislav Petkov,
Tony Luck, Billy Tsai
Cc: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
linux-edac, Ryan Chen
Add ECC error reporting for the Aspeed AST2700 to the aspeed_edac
driver.
The AST2700 memory controller reports ECC errors much like the older
Aspeed chips, but its registers are laid out differently, it has
separate registers to read, clear and mask its interrupts, and it uses
DDR4 or DDR5 memory.
This series is based on the edac-drivers-aspeed branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git, which already
has v5 patches 1-5.
Patches 1-3 prepare the driver: they drop the global variables and the
regmap, and put the differences between chips in a table. Patch 4 stops
unlocking the interrupt control register on the AST2600, which doesn't
need it. Patches 5-8 prepare for the way the AST2700 handles interrupts
and reports error addresses. Patch 9 adds the AST2700. Patch 10 is
Stefan's step-down patch, changed to keep the entry with me as its
reviewer.
Claude, an AI coding assistant, was used in developing patches 1-9. It
drafted parts of the code and of the commit messages. I reviewed every
change and tested the series on AST2600 and AST2700 hardware; the
results are below the --- line in patches 4 and 9.
Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
Changes in v7:
- Split the three driver patches of v6 into nine, one change each.
- Patch 4 is new: v6 changed the AST2600 unlock as part of the chip
table patch.
- Patch 8 is new: v6 disabled the interrupts before requesting the
line as part of the chip table and AST2700 patches.
- Rewrite the commit messages in plain English and give only the
reason for each change.
- Move test results out of the commit messages to below the --- line.
- Drop the aspeed_ prefix from the static functions. aspeed_probe() and
aspeed_remove() keep theirs, like the probe and remove functions of
the other EDAC drivers.
- Link to v6: https://lore.kernel.org/r/20261117-edac-v6-0-a2a747b95c3f@aspeedtech.com
Changes in v6:
- Rebase onto the edac-drivers-aspeed branch of bp.git and drop the five
v5 patches applied there (v5 patches 1-5). v5 patches 6-9 are now
patches 1-4.
- Patch 1: use a spinlock_t rather than a raw_spinlock_t for the
register lock, as regmap did; the interrupt handler is not
IRQF_NO_THREAD. Patches 2 and 3 follow.
- Patch 1: drop the __guarded_by() annotations and the context analysis
opt-in, and assign the register base in probe without taking the
lock, so aspeed_probe() no longer mixes scoped_guard() with goto
unwinding.
- Link to v5: https://lore.kernel.org/r/20261007-edac-v5-0-5c31fc5df4cf@aspeedtech.com
Changes in v5:
- v5 patch 2: register the ECC interrupt with request_irq() instead of
devm_request_irq() followed by an explicit free, and keep the
interrupt number alongside the driver's other state so
aspeed_remove() does not have to call platform_get_irq() again.
- Link to v4: https://lore.kernel.org/r/20260930-edac-v4-0-c2e526f3ed79@aspeedtech.com
Changes in v4:
- Put the bug fixes first: the two fixes became v4 patches 1 and 2, the
cleanups v4 patches 3 and 4, and the bindings patch moved to v4
patch 5 ahead of the AST2700 work.
- Explain in v4 patch 1 where the grain value comes from, rather than
the warning it silences.
- Drop the Cc: stable tags from the two fixes. Neither meets the bar in
Documentation/process/stable-kernel-rules.rst; the Fixes: tags stay.
- Merge Stefan's step-down patch into v4 patch 9 (now patch 4),
keeping the MAINTAINERS entry alive with a reviewer instead of
removing it.
- Link to v3: https://lore.kernel.org/r/20260916-edac-v3-0-23e9ed2fbdf9@aspeedtech.com
Changes in v3:
- Establish the AST2700 interrupt mask in the driver rather than
deriving it from the register's contents: ast2700_set_irq() now
writes the mask outright, masking every source and unmasking only
the ECC ones, and the mask is established before the interrupt is
requested.
- New patch: add myself as a reviewer for the driver in MAINTAINERS.
- Tested on an AST2600 with CONFIG_PROVE_LOCKING=y; injected correctable
errors are reported from the interrupt handler with no lockdep reports.
- Link to v2: https://lore.kernel.org/r/20260824-edac-v2-0-c8d8bb693586@aspeedtech.com
Changes in v2:
- New patch (v5 patch 2, now applied): free the ECC interrupt before
the mem_ctl_info in aspeed_remove(). The interrupt is requested with
devm_request_irq() and is only released after .remove() has returned,
so edac_mc_free() could free the handler's context while the handler
was still running on another CPU.
- Acquire the register lock with the irqsave variant in init_csrows() and
in aspeed_probe(). The interrupt handler takes the same lock in hardirq
context.
- Move the dev_dbg() of the interrupt status register out of the
raw_spinlock critical section in the interrupt handler.
- Opt aspeed_edac.o into context analysis in drivers/edac/Makefile. The
check is opt-in per object, so without it the __guarded_by() annotation
added by the same patch was never actually verified.
- Return IRQ_NONE from ast2700_dramc_isr() when no ECC interrupt status
bit is set; the handler clears only the ECC bits, so unconditionally
claiming the interrupt could livelock the level-triggered line.
- Tested v2 on both AST2600 and AST2700 by injecting a correctable
error with the memory controller's ECC error injection; each is
reported as a CE with the expected failure address.
- Link to v1: https://lore.kernel.org/r/20260812-edac-v1-0-03992edea297@aspeedtech.com
---
Ryan Chen (9):
EDAC/aspeed: Stop keeping driver state in global variables
EDAC/aspeed: Replace regmap with direct register access
EDAC/aspeed: Put the differences between chips in a table
EDAC/aspeed: Don't unlock the interrupt control register on AST2600
EDAC/aspeed: Let each chip provide its own interrupt handling
EDAC/aspeed: Allow reporting an error without an address
EDAC/aspeed: Allow error addresses above 4 GiB
EDAC/aspeed: Disable interrupts before requesting the interrupt line
EDAC/aspeed: Add AST2700 support
Stefan M Schaeckeler (1):
MAINTAINERS: Step down as Aspeed AST2500 EDAC driver maintainer
CREDITS | 8 +
.../bindings/edac/aspeed,ast2400-sdram-edac.yaml | 2 +-
MAINTAINERS | 2 +-
drivers/edac/aspeed_edac.c | 308 ++++++++++++++-------
4 files changed, 224 insertions(+), 96 deletions(-)
---
base-commit: 65d0a904696bae7e99a2c6eef61d4df03bac025f
change-id: 20260625-edac-8e960e02e7f7
Best regards,
--
Ryan Chen <ryan_chen@aspeedtech.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 01/10] EDAC/aspeed: Stop keeping driver state in global variables
2026-11-30 7:24 [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
@ 2026-11-30 7:24 ` Ryan Chen
2026-11-30 7:24 ` [PATCH v7 02/10] EDAC/aspeed: Replace regmap with direct register access Ryan Chen
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Ryan Chen @ 2026-11-30 7:24 UTC (permalink / raw)
To: Stefan Schaeckeler, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Joel Stanley, Andrew Jeffery, Borislav Petkov,
Tony Luck, Billy Tsai
Cc: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
linux-edac, Ryan Chen
The register map and the interrupt number are global variables. The
following changes need to keep more state for the device, such as a
lock and the chip type, and adding more globals for that is not the
right way.
Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
drivers/edac/aspeed_edac.c | 50 ++++++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 19 deletions(-)
diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
index 610da8aa2a22..f0db0a221ce0 100644
--- a/drivers/edac/aspeed_edac.c
+++ b/drivers/edac/aspeed_edac.c
@@ -30,8 +30,10 @@
#define ASPEED_MCR_INTR_CTRL_CNT_UNREC GENMASK(15, 12)
#define ASPEED_MCR_INTR_CTRL_ENABLE (BIT(0) | BIT(1))
-static struct regmap *aspeed_regmap;
-static int aspeed_irq;
+struct aspeed_edac {
+ struct regmap *regmap;
+ int irq;
+};
static int regmap_reg_write(void *context, unsigned int reg, unsigned int val)
{
@@ -147,11 +149,12 @@ static void count_un_rec(struct mem_ctl_info *mci, u8 un_rec_cnt,
static irqreturn_t mcr_isr(int irq, void *arg)
{
struct mem_ctl_info *mci = arg;
+ struct aspeed_edac *priv = mci->pvt_info;
u32 rec_addr, un_rec_addr;
u32 reg50, reg5c, reg58;
u8 rec_cnt, un_rec_cnt;
- regmap_read(aspeed_regmap, ASPEED_MCR_INTR_CTRL, ®50);
+ regmap_read(priv->regmap, ASPEED_MCR_INTR_CTRL, ®50);
dev_dbg(mci->pdev, "received edac interrupt w/ mcr register 50: 0x%x\n",
reg50);
@@ -162,18 +165,18 @@ static irqreturn_t mcr_isr(int irq, void *arg)
dev_dbg(mci->pdev, "%d recoverable interrupts and %d unrecoverable interrupts\n",
rec_cnt, un_rec_cnt);
- regmap_read(aspeed_regmap, ASPEED_MCR_ADDR_UNREC, ®58);
+ regmap_read(priv->regmap, ASPEED_MCR_ADDR_UNREC, ®58);
un_rec_addr = reg58;
- regmap_read(aspeed_regmap, ASPEED_MCR_ADDR_REC, ®5c);
+ regmap_read(priv->regmap, ASPEED_MCR_ADDR_REC, ®5c);
rec_addr = reg5c;
/* clear interrupt flags and error counters: */
- regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL,
+ regmap_update_bits(priv->regmap, ASPEED_MCR_INTR_CTRL,
ASPEED_MCR_INTR_CTRL_CLEAR,
ASPEED_MCR_INTR_CTRL_CLEAR);
- regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL,
+ regmap_update_bits(priv->regmap, ASPEED_MCR_INTR_CTRL,
ASPEED_MCR_INTR_CTRL_CLEAR, 0);
/* process recoverable and unrecoverable errors */
@@ -183,7 +186,7 @@ static irqreturn_t mcr_isr(int irq, void *arg)
if (!rec_cnt && !un_rec_cnt)
dev_dbg(mci->pdev, "received edac interrupt, but did not find any ECC counters\n");
- regmap_read(aspeed_regmap, ASPEED_MCR_INTR_CTRL, ®50);
+ regmap_read(priv->regmap, ASPEED_MCR_INTR_CTRL, ®50);
dev_dbg(mci->pdev, "edac interrupt handled. mcr reg 50 is now: 0x%x\n",
reg50);
@@ -192,6 +195,8 @@ static irqreturn_t mcr_isr(int irq, void *arg)
static int config_irq(void *ctx, struct platform_device *pdev)
{
+ struct mem_ctl_info *mci = ctx;
+ struct aspeed_edac *priv = mci->pvt_info;
int irq;
int rc;
@@ -205,10 +210,10 @@ static int config_irq(void *ctx, struct platform_device *pdev)
if (rc)
return rc;
- aspeed_irq = irq;
+ priv->irq = irq;
/* enable interrupts */
- regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL,
+ regmap_update_bits(priv->regmap, ASPEED_MCR_INTR_CTRL,
ASPEED_MCR_INTR_CTRL_ENABLE,
ASPEED_MCR_INTR_CTRL_ENABLE);
@@ -217,6 +222,7 @@ static int config_irq(void *ctx, struct platform_device *pdev)
static int init_csrows(struct mem_ctl_info *mci)
{
+ struct aspeed_edac *priv = mci->pvt_info;
struct csrow_info *csrow = mci->csrows[0];
u32 nr_pages, dram_type;
struct dimm_info *dimm;
@@ -248,7 +254,7 @@ static int init_csrows(struct mem_ctl_info *mci)
nr_pages = resource_size(&r) >> PAGE_SHIFT;
csrow->last_page = csrow->first_page + nr_pages - 1;
- regmap_read(aspeed_regmap, ASPEED_MCR_CONF, ®04);
+ regmap_read(priv->regmap, ASPEED_MCR_CONF, ®04);
dram_type = (reg04 & ASPEED_MCR_CONF_DRAM_TYPE) ? MEM_DDR4 : MEM_DDR3;
dimm = csrow->channels[0]->dimm;
@@ -267,7 +273,9 @@ static int aspeed_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct edac_mc_layer layers[2];
+ struct aspeed_edac *priv;
struct mem_ctl_info *mci;
+ struct regmap *regmap;
void __iomem *regs;
u32 reg04;
int rc;
@@ -276,13 +284,13 @@ static int aspeed_probe(struct platform_device *pdev)
if (IS_ERR(regs))
return PTR_ERR(regs);
- aspeed_regmap = devm_regmap_init(dev, NULL, (__force void *)regs,
- &aspeed_regmap_config);
- if (IS_ERR(aspeed_regmap))
- return PTR_ERR(aspeed_regmap);
+ regmap = devm_regmap_init(dev, NULL, (__force void *)regs,
+ &aspeed_regmap_config);
+ if (IS_ERR(regmap))
+ return PTR_ERR(regmap);
/* bail out if ECC mode is not configured */
- regmap_read(aspeed_regmap, ASPEED_MCR_CONF, ®04);
+ regmap_read(regmap, ASPEED_MCR_CONF, ®04);
if (!(reg04 & ASPEED_MCR_CONF_ECC)) {
dev_err(&pdev->dev, "ECC mode is not configured in u-boot\n");
return -EPERM;
@@ -298,10 +306,13 @@ static int aspeed_probe(struct platform_device *pdev)
layers[1].size = 1;
layers[1].is_virt_csrow = false;
- mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, 0);
+ mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers, sizeof(*priv));
if (!mci)
return -ENOMEM;
+ priv = mci->pvt_info;
+ priv->regmap = regmap;
+
mci->pdev = &pdev->dev;
mci->mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4;
mci->edac_ctl_cap = EDAC_FLAG_SECDED;
@@ -346,12 +357,13 @@ static int aspeed_probe(struct platform_device *pdev)
static void aspeed_remove(struct platform_device *pdev)
{
struct mem_ctl_info *mci = platform_get_drvdata(pdev);
+ struct aspeed_edac *priv = mci->pvt_info;
/* disable interrupts */
- regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL,
+ regmap_update_bits(priv->regmap, ASPEED_MCR_INTR_CTRL,
ASPEED_MCR_INTR_CTRL_ENABLE, 0);
- free_irq(aspeed_irq, mci);
+ free_irq(priv->irq, mci);
/* free resources */
edac_mc_del_mc(&pdev->dev);
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 02/10] EDAC/aspeed: Replace regmap with direct register access
2026-11-30 7:24 [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
2026-11-30 7:24 ` [PATCH v7 01/10] EDAC/aspeed: Stop keeping driver state in global variables Ryan Chen
@ 2026-11-30 7:24 ` Ryan Chen
2026-11-30 7:24 ` [PATCH v7 03/10] EDAC/aspeed: Put the differences between chips in a table Ryan Chen
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Ryan Chen @ 2026-11-30 7:24 UTC (permalink / raw)
To: Stefan Schaeckeler, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Joel Stanley, Andrew Jeffery, Borislav Petkov,
Tony Luck, Billy Tsai
Cc: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
linux-edac, Ryan Chen
The regmap doesn't do anything the driver couldn't do itself: it has no
cache, nothing else uses it, and the driver supplies its own read and
write functions anyway.
Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
drivers/edac/aspeed_edac.c | 99 ++++++++++++++++------------------------------
1 file changed, 33 insertions(+), 66 deletions(-)
diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
index f0db0a221ce0..5bc5630b6c50 100644
--- a/drivers/edac/aspeed_edac.c
+++ b/drivers/edac/aspeed_edac.c
@@ -10,7 +10,7 @@
#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
-#include <linux/regmap.h>
+#include <linux/spinlock.h>
#include "edac_module.h"
#define DRV_NAME "aspeed-edac"
@@ -20,7 +20,6 @@
#define ASPEED_MCR_INTR_CTRL 0x50 /* interrupt control/status register */
#define ASPEED_MCR_ADDR_UNREC 0x58 /* address of first un-recoverable error */
#define ASPEED_MCR_ADDR_REC 0x5c /* address of last recoverable error */
-#define ASPEED_MCR_LAST ASPEED_MCR_ADDR_REC
#define ASPEED_MCR_PROT_PASSWD 0xfc600309
#define ASPEED_MCR_CONF_DRAM_TYPE BIT(4)
@@ -31,58 +30,34 @@
#define ASPEED_MCR_INTR_CTRL_ENABLE (BIT(0) | BIT(1))
struct aspeed_edac {
- struct regmap *regmap;
+ void __iomem *regs;
+ /* serializes register updates */
+ spinlock_t lock;
int irq;
};
-static int regmap_reg_write(void *context, unsigned int reg, unsigned int val)
+static void mcr_update_bits(struct aspeed_edac *priv, u32 reg, u32 mask,
+ u32 val)
{
- void __iomem *regs = (void __iomem *)context;
+ unsigned long flags;
+ u32 tmp;
- /* enable write to MCR register set */
- writel(ASPEED_MCR_PROT_PASSWD, regs + ASPEED_MCR_PROT);
+ spin_lock_irqsave(&priv->lock, flags);
- writel(val, regs + reg);
+ tmp = readl(priv->regs + reg);
+ tmp = (tmp & ~mask) | (val & mask);
- /* disable write to MCR register set */
- writel(~ASPEED_MCR_PROT_PASSWD, regs + ASPEED_MCR_PROT);
-
- return 0;
-}
-
-static int regmap_reg_read(void *context, unsigned int reg, unsigned int *val)
-{
- void __iomem *regs = (void __iomem *)context;
+ /* enable write to MCR register set */
+ writel(ASPEED_MCR_PROT_PASSWD, priv->regs + ASPEED_MCR_PROT);
- *val = readl(regs + reg);
+ writel(tmp, priv->regs + reg);
- return 0;
-}
+ /* disable write to MCR register set */
+ writel(~ASPEED_MCR_PROT_PASSWD, priv->regs + ASPEED_MCR_PROT);
-static bool regmap_is_volatile(struct device *dev, unsigned int reg)
-{
- switch (reg) {
- case ASPEED_MCR_PROT:
- case ASPEED_MCR_INTR_CTRL:
- case ASPEED_MCR_ADDR_UNREC:
- case ASPEED_MCR_ADDR_REC:
- return true;
- default:
- return false;
- }
+ spin_unlock_irqrestore(&priv->lock, flags);
}
-static const struct regmap_config aspeed_regmap_config = {
- .reg_bits = 32,
- .val_bits = 32,
- .reg_stride = 4,
- .max_register = ASPEED_MCR_LAST,
- .reg_write = regmap_reg_write,
- .reg_read = regmap_reg_read,
- .volatile_reg = regmap_is_volatile,
- .fast_io = true,
-};
-
static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr)
{
struct csrow_info *csrow = mci->csrows[0];
@@ -154,7 +129,7 @@ static irqreturn_t mcr_isr(int irq, void *arg)
u32 reg50, reg5c, reg58;
u8 rec_cnt, un_rec_cnt;
- regmap_read(priv->regmap, ASPEED_MCR_INTR_CTRL, ®50);
+ reg50 = readl(priv->regs + ASPEED_MCR_INTR_CTRL);
dev_dbg(mci->pdev, "received edac interrupt w/ mcr register 50: 0x%x\n",
reg50);
@@ -165,19 +140,18 @@ static irqreturn_t mcr_isr(int irq, void *arg)
dev_dbg(mci->pdev, "%d recoverable interrupts and %d unrecoverable interrupts\n",
rec_cnt, un_rec_cnt);
- regmap_read(priv->regmap, ASPEED_MCR_ADDR_UNREC, ®58);
+ reg58 = readl(priv->regs + ASPEED_MCR_ADDR_UNREC);
un_rec_addr = reg58;
- regmap_read(priv->regmap, ASPEED_MCR_ADDR_REC, ®5c);
+ reg5c = readl(priv->regs + ASPEED_MCR_ADDR_REC);
rec_addr = reg5c;
/* clear interrupt flags and error counters: */
- regmap_update_bits(priv->regmap, ASPEED_MCR_INTR_CTRL,
- ASPEED_MCR_INTR_CTRL_CLEAR,
- ASPEED_MCR_INTR_CTRL_CLEAR);
+ mcr_update_bits(priv, ASPEED_MCR_INTR_CTRL,
+ ASPEED_MCR_INTR_CTRL_CLEAR, ASPEED_MCR_INTR_CTRL_CLEAR);
- regmap_update_bits(priv->regmap, ASPEED_MCR_INTR_CTRL,
- ASPEED_MCR_INTR_CTRL_CLEAR, 0);
+ mcr_update_bits(priv, ASPEED_MCR_INTR_CTRL,
+ ASPEED_MCR_INTR_CTRL_CLEAR, 0);
/* process recoverable and unrecoverable errors */
count_rec(mci, rec_cnt, rec_addr);
@@ -186,7 +160,7 @@ static irqreturn_t mcr_isr(int irq, void *arg)
if (!rec_cnt && !un_rec_cnt)
dev_dbg(mci->pdev, "received edac interrupt, but did not find any ECC counters\n");
- regmap_read(priv->regmap, ASPEED_MCR_INTR_CTRL, ®50);
+ reg50 = readl(priv->regs + ASPEED_MCR_INTR_CTRL);
dev_dbg(mci->pdev, "edac interrupt handled. mcr reg 50 is now: 0x%x\n",
reg50);
@@ -213,9 +187,8 @@ static int config_irq(void *ctx, struct platform_device *pdev)
priv->irq = irq;
/* enable interrupts */
- regmap_update_bits(priv->regmap, ASPEED_MCR_INTR_CTRL,
- ASPEED_MCR_INTR_CTRL_ENABLE,
- ASPEED_MCR_INTR_CTRL_ENABLE);
+ mcr_update_bits(priv, ASPEED_MCR_INTR_CTRL, ASPEED_MCR_INTR_CTRL_ENABLE,
+ ASPEED_MCR_INTR_CTRL_ENABLE);
return 0;
}
@@ -254,7 +227,7 @@ static int init_csrows(struct mem_ctl_info *mci)
nr_pages = resource_size(&r) >> PAGE_SHIFT;
csrow->last_page = csrow->first_page + nr_pages - 1;
- regmap_read(priv->regmap, ASPEED_MCR_CONF, ®04);
+ reg04 = readl(priv->regs + ASPEED_MCR_CONF);
dram_type = (reg04 & ASPEED_MCR_CONF_DRAM_TYPE) ? MEM_DDR4 : MEM_DDR3;
dimm = csrow->channels[0]->dimm;
@@ -271,11 +244,9 @@ static int init_csrows(struct mem_ctl_info *mci)
static int aspeed_probe(struct platform_device *pdev)
{
- struct device *dev = &pdev->dev;
struct edac_mc_layer layers[2];
struct aspeed_edac *priv;
struct mem_ctl_info *mci;
- struct regmap *regmap;
void __iomem *regs;
u32 reg04;
int rc;
@@ -284,13 +255,8 @@ static int aspeed_probe(struct platform_device *pdev)
if (IS_ERR(regs))
return PTR_ERR(regs);
- regmap = devm_regmap_init(dev, NULL, (__force void *)regs,
- &aspeed_regmap_config);
- if (IS_ERR(regmap))
- return PTR_ERR(regmap);
-
/* bail out if ECC mode is not configured */
- regmap_read(regmap, ASPEED_MCR_CONF, ®04);
+ reg04 = readl(regs + ASPEED_MCR_CONF);
if (!(reg04 & ASPEED_MCR_CONF_ECC)) {
dev_err(&pdev->dev, "ECC mode is not configured in u-boot\n");
return -EPERM;
@@ -311,7 +277,8 @@ static int aspeed_probe(struct platform_device *pdev)
return -ENOMEM;
priv = mci->pvt_info;
- priv->regmap = regmap;
+ priv->regs = regs;
+ spin_lock_init(&priv->lock);
mci->pdev = &pdev->dev;
mci->mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4;
@@ -360,8 +327,8 @@ static void aspeed_remove(struct platform_device *pdev)
struct aspeed_edac *priv = mci->pvt_info;
/* disable interrupts */
- regmap_update_bits(priv->regmap, ASPEED_MCR_INTR_CTRL,
- ASPEED_MCR_INTR_CTRL_ENABLE, 0);
+ mcr_update_bits(priv, ASPEED_MCR_INTR_CTRL,
+ ASPEED_MCR_INTR_CTRL_ENABLE, 0);
free_irq(priv->irq, mci);
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 03/10] EDAC/aspeed: Put the differences between chips in a table
2026-11-30 7:24 [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
2026-11-30 7:24 ` [PATCH v7 01/10] EDAC/aspeed: Stop keeping driver state in global variables Ryan Chen
2026-11-30 7:24 ` [PATCH v7 02/10] EDAC/aspeed: Replace regmap with direct register access Ryan Chen
@ 2026-11-30 7:24 ` Ryan Chen
2026-11-30 7:24 ` [PATCH v7 04/10] EDAC/aspeed: Don't unlock the interrupt control register on AST2600 Ryan Chen
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Ryan Chen @ 2026-11-30 7:24 UTC (permalink / raw)
To: Stefan Schaeckeler, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Joel Stanley, Andrew Jeffery, Borislav Petkov,
Tony Luck, Billy Tsai
Cc: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
linux-edac, Ryan Chen
Prepare for the AST2700, which has its ECC enable and DRAM type bits in
a different register and supports DDR4 and DDR5 instead of DDR3 and
DDR4. With these in a table, it only needs one more entry.
Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
drivers/edac/aspeed_edac.c | 45 +++++++++++++++++++++++++++++++++++----------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
index 5bc5630b6c50..f4ef9430258a 100644
--- a/drivers/edac/aspeed_edac.c
+++ b/drivers/edac/aspeed_edac.c
@@ -8,6 +8,7 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
@@ -29,7 +30,16 @@
#define ASPEED_MCR_INTR_CTRL_CNT_UNREC GENMASK(15, 12)
#define ASPEED_MCR_INTR_CTRL_ENABLE (BIT(0) | BIT(1))
+struct aspeed_edac_chip {
+ u32 conf_reg;
+ u32 conf_ecc;
+ u32 conf_dram_type;
+ enum mem_type dram_type[2];
+ unsigned long mtype_cap;
+};
+
struct aspeed_edac {
+ const struct aspeed_edac_chip *chip;
void __iomem *regs;
/* serializes register updates */
spinlock_t lock;
@@ -196,12 +206,13 @@ static int config_irq(void *ctx, struct platform_device *pdev)
static int init_csrows(struct mem_ctl_info *mci)
{
struct aspeed_edac *priv = mci->pvt_info;
+ const struct aspeed_edac_chip *chip = priv->chip;
struct csrow_info *csrow = mci->csrows[0];
u32 nr_pages, dram_type;
struct dimm_info *dimm;
struct device_node *np;
struct resource r;
- u32 reg04;
+ u32 conf;
int rc;
/* retrieve info about physical memory from device tree */
@@ -227,8 +238,8 @@ static int init_csrows(struct mem_ctl_info *mci)
nr_pages = resource_size(&r) >> PAGE_SHIFT;
csrow->last_page = csrow->first_page + nr_pages - 1;
- reg04 = readl(priv->regs + ASPEED_MCR_CONF);
- dram_type = (reg04 & ASPEED_MCR_CONF_DRAM_TYPE) ? MEM_DDR4 : MEM_DDR3;
+ conf = readl(priv->regs + chip->conf_reg);
+ dram_type = chip->dram_type[!!(conf & chip->conf_dram_type)];
dimm = csrow->channels[0]->dimm;
dimm->mtype = dram_type;
@@ -244,20 +255,25 @@ static int init_csrows(struct mem_ctl_info *mci)
static int aspeed_probe(struct platform_device *pdev)
{
+ const struct aspeed_edac_chip *chip;
struct edac_mc_layer layers[2];
struct aspeed_edac *priv;
struct mem_ctl_info *mci;
void __iomem *regs;
- u32 reg04;
+ u32 conf;
int rc;
+ chip = of_device_get_match_data(&pdev->dev);
+ if (!chip)
+ return -ENODEV;
+
regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(regs))
return PTR_ERR(regs);
/* bail out if ECC mode is not configured */
- reg04 = readl(regs + ASPEED_MCR_CONF);
- if (!(reg04 & ASPEED_MCR_CONF_ECC)) {
+ conf = readl(regs + chip->conf_reg);
+ if (!(conf & chip->conf_ecc)) {
dev_err(&pdev->dev, "ECC mode is not configured in u-boot\n");
return -EPERM;
}
@@ -277,11 +293,12 @@ static int aspeed_probe(struct platform_device *pdev)
return -ENOMEM;
priv = mci->pvt_info;
+ priv->chip = chip;
priv->regs = regs;
spin_lock_init(&priv->lock);
mci->pdev = &pdev->dev;
- mci->mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4;
+ mci->mtype_cap = chip->mtype_cap;
mci->edac_ctl_cap = EDAC_FLAG_SECDED;
mci->edac_cap = EDAC_FLAG_SECDED;
mci->scrub_cap = SCRUB_FLAG_HW_SRC;
@@ -337,10 +354,18 @@ static void aspeed_remove(struct platform_device *pdev)
edac_mc_free(mci);
}
+static const struct aspeed_edac_chip ast2400_edac = {
+ .conf_reg = ASPEED_MCR_CONF,
+ .conf_ecc = ASPEED_MCR_CONF_ECC,
+ .conf_dram_type = ASPEED_MCR_CONF_DRAM_TYPE,
+ .dram_type = { MEM_DDR3, MEM_DDR4 },
+ .mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4,
+};
+
static const struct of_device_id aspeed_of_match[] = {
- { .compatible = "aspeed,ast2400-sdram-edac" },
- { .compatible = "aspeed,ast2500-sdram-edac" },
- { .compatible = "aspeed,ast2600-sdram-edac" },
+ { .compatible = "aspeed,ast2400-sdram-edac", .data = &ast2400_edac },
+ { .compatible = "aspeed,ast2500-sdram-edac", .data = &ast2400_edac },
+ { .compatible = "aspeed,ast2600-sdram-edac", .data = &ast2400_edac },
{},
};
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 04/10] EDAC/aspeed: Don't unlock the interrupt control register on AST2600
2026-11-30 7:24 [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
` (2 preceding siblings ...)
2026-11-30 7:24 ` [PATCH v7 03/10] EDAC/aspeed: Put the differences between chips in a table Ryan Chen
@ 2026-11-30 7:24 ` Ryan Chen
2026-11-30 7:24 ` [PATCH v7 05/10] EDAC/aspeed: Let each chip provide its own interrupt handling Ryan Chen
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Ryan Chen @ 2026-11-30 7:24 UTC (permalink / raw)
To: Stefan Schaeckeler, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Joel Stanley, Andrew Jeffery, Borislav Petkov,
Tony Luck, Billy Tsai
Cc: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
linux-edac, Ryan Chen
On the AST2600 the interrupt control register can be written without
the unlock key. Unlocking also makes the rest of the memory controller
settings writable, so skip it where it isn't needed.
Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
Tested on an AST2600 by injecting a correctable error with the memory
controller's error injection:
# mw 1e6e0000 fc600309; mw 1e6e00b0 81
EDAC MC0: 1 CE address(es) not available on mc#0csrow#0channel#0 (csrow:0 channel:0 page:0x0 offset:0x0 grain:16 syndrome:0x0)
EDAC MC0: 1 CE on mc#0csrow#0channel#0 (csrow:0 channel:0 page:0xb2b2f offset:0x180 grain:16 syndrome:0x0)
---
drivers/edac/aspeed_edac.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
index f4ef9430258a..e3158265dde8 100644
--- a/drivers/edac/aspeed_edac.c
+++ b/drivers/edac/aspeed_edac.c
@@ -36,6 +36,7 @@ struct aspeed_edac_chip {
u32 conf_dram_type;
enum mem_type dram_type[2];
unsigned long mtype_cap;
+ bool intr_ctrl_locked;
};
struct aspeed_edac {
@@ -58,12 +59,14 @@ static void mcr_update_bits(struct aspeed_edac *priv, u32 reg, u32 mask,
tmp = (tmp & ~mask) | (val & mask);
/* enable write to MCR register set */
- writel(ASPEED_MCR_PROT_PASSWD, priv->regs + ASPEED_MCR_PROT);
+ if (priv->chip->intr_ctrl_locked)
+ writel(ASPEED_MCR_PROT_PASSWD, priv->regs + ASPEED_MCR_PROT);
writel(tmp, priv->regs + reg);
/* disable write to MCR register set */
- writel(~ASPEED_MCR_PROT_PASSWD, priv->regs + ASPEED_MCR_PROT);
+ if (priv->chip->intr_ctrl_locked)
+ writel(~ASPEED_MCR_PROT_PASSWD, priv->regs + ASPEED_MCR_PROT);
spin_unlock_irqrestore(&priv->lock, flags);
}
@@ -360,12 +363,21 @@ static const struct aspeed_edac_chip ast2400_edac = {
.conf_dram_type = ASPEED_MCR_CONF_DRAM_TYPE,
.dram_type = { MEM_DDR3, MEM_DDR4 },
.mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4,
+ .intr_ctrl_locked = true,
+};
+
+static const struct aspeed_edac_chip ast2600_edac = {
+ .conf_reg = ASPEED_MCR_CONF,
+ .conf_ecc = ASPEED_MCR_CONF_ECC,
+ .conf_dram_type = ASPEED_MCR_CONF_DRAM_TYPE,
+ .dram_type = { MEM_DDR3, MEM_DDR4 },
+ .mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4,
};
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 = &ast2400_edac },
+ { .compatible = "aspeed,ast2600-sdram-edac", .data = &ast2600_edac },
{},
};
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 05/10] EDAC/aspeed: Let each chip provide its own interrupt handling
2026-11-30 7:24 [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
` (3 preceding siblings ...)
2026-11-30 7:24 ` [PATCH v7 04/10] EDAC/aspeed: Don't unlock the interrupt control register on AST2600 Ryan Chen
@ 2026-11-30 7:24 ` Ryan Chen
2026-11-30 7:24 ` [PATCH v7 06/10] EDAC/aspeed: Allow reporting an error without an address Ryan Chen
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Ryan Chen @ 2026-11-30 7:24 UTC (permalink / raw)
To: Stefan Schaeckeler, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Joel Stanley, Andrew Jeffery, Borislav Petkov,
Tony Luck, Billy Tsai
Cc: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
linux-edac, Ryan Chen
Prepare for the AST2700, which has separate registers to read, clear
and mask its interrupts, so it can't share the interrupt handler or the
code that enables the interrupt with the older chips.
Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
drivers/edac/aspeed_edac.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
index e3158265dde8..5858a15ddfac 100644
--- a/drivers/edac/aspeed_edac.c
+++ b/drivers/edac/aspeed_edac.c
@@ -30,6 +30,8 @@
#define ASPEED_MCR_INTR_CTRL_CNT_UNREC GENMASK(15, 12)
#define ASPEED_MCR_INTR_CTRL_ENABLE (BIT(0) | BIT(1))
+struct aspeed_edac;
+
struct aspeed_edac_chip {
u32 conf_reg;
u32 conf_ecc;
@@ -37,6 +39,8 @@ struct aspeed_edac_chip {
enum mem_type dram_type[2];
unsigned long mtype_cap;
bool intr_ctrl_locked;
+ irqreturn_t (*isr)(int irq, void *arg);
+ void (*set_irq)(struct aspeed_edac *priv, bool enable);
};
struct aspeed_edac {
@@ -180,6 +184,12 @@ static irqreturn_t mcr_isr(int irq, void *arg)
return IRQ_HANDLED;
}
+static void mcr_set_irq(struct aspeed_edac *priv, bool enable)
+{
+ mcr_update_bits(priv, ASPEED_MCR_INTR_CTRL, ASPEED_MCR_INTR_CTRL_ENABLE,
+ enable ? ASPEED_MCR_INTR_CTRL_ENABLE : 0);
+}
+
static int config_irq(void *ctx, struct platform_device *pdev)
{
struct mem_ctl_info *mci = ctx;
@@ -193,15 +203,15 @@ static int config_irq(void *ctx, struct platform_device *pdev)
if (irq < 0)
return irq;
- rc = request_irq(irq, mcr_isr, IRQF_TRIGGER_HIGH, DRV_NAME, ctx);
+ rc = request_irq(irq, priv->chip->isr, IRQF_TRIGGER_HIGH, DRV_NAME,
+ ctx);
if (rc)
return rc;
priv->irq = irq;
/* enable interrupts */
- mcr_update_bits(priv, ASPEED_MCR_INTR_CTRL, ASPEED_MCR_INTR_CTRL_ENABLE,
- ASPEED_MCR_INTR_CTRL_ENABLE);
+ priv->chip->set_irq(priv, true);
return 0;
}
@@ -347,8 +357,7 @@ static void aspeed_remove(struct platform_device *pdev)
struct aspeed_edac *priv = mci->pvt_info;
/* disable interrupts */
- mcr_update_bits(priv, ASPEED_MCR_INTR_CTRL,
- ASPEED_MCR_INTR_CTRL_ENABLE, 0);
+ priv->chip->set_irq(priv, false);
free_irq(priv->irq, mci);
@@ -364,6 +373,8 @@ static const struct aspeed_edac_chip ast2400_edac = {
.dram_type = { MEM_DDR3, MEM_DDR4 },
.mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4,
.intr_ctrl_locked = true,
+ .isr = mcr_isr,
+ .set_irq = mcr_set_irq,
};
static const struct aspeed_edac_chip ast2600_edac = {
@@ -372,6 +383,8 @@ static const struct aspeed_edac_chip ast2600_edac = {
.conf_dram_type = ASPEED_MCR_CONF_DRAM_TYPE,
.dram_type = { MEM_DDR3, MEM_DDR4 },
.mtype_cap = MEM_FLAG_DDR3 | MEM_FLAG_DDR4,
+ .isr = mcr_isr,
+ .set_irq = mcr_set_irq,
};
static const struct of_device_id aspeed_of_match[] = {
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 06/10] EDAC/aspeed: Allow reporting an error without an address
2026-11-30 7:24 [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
` (4 preceding siblings ...)
2026-11-30 7:24 ` [PATCH v7 05/10] EDAC/aspeed: Let each chip provide its own interrupt handling Ryan Chen
@ 2026-11-30 7:24 ` Ryan Chen
2026-11-30 7:24 ` [PATCH v7 07/10] EDAC/aspeed: Allow error addresses above 4 GiB Ryan Chen
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Ryan Chen @ 2026-11-30 7:24 UTC (permalink / raw)
To: Stefan Schaeckeler, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Joel Stanley, Andrew Jeffery, Borislav Petkov,
Tony Luck, Billy Tsai
Cc: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
linux-edac, Ryan Chen
Prepare for the AST2700, which has only one failure address register
for both corrected and uncorrected errors. When both happen at once,
one of them has to be reported without an address.
Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
drivers/edac/aspeed_edac.c | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
index 5858a15ddfac..85179e229543 100644
--- a/drivers/edac/aspeed_edac.c
+++ b/drivers/edac/aspeed_edac.c
@@ -75,7 +75,8 @@ static void mcr_update_bits(struct aspeed_edac *priv, u32 reg, u32 mask,
spin_unlock_irqrestore(&priv->lock, flags);
}
-static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr)
+static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr,
+ bool have_addr)
{
struct csrow_info *csrow = mci->csrows[0];
u32 page, offset, syndrome;
@@ -85,16 +86,20 @@ static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr)
/* report first few errors (if there are) */
/* note: no addresses are recorded */
- if (rec_cnt > 1) {
+ if (rec_cnt > 1 || !have_addr) {
/* page, offset and syndrome are not available */
page = 0;
offset = 0;
syndrome = 0;
- edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, rec_cnt-1,
+ edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci,
+ have_addr ? rec_cnt - 1 : rec_cnt,
page, offset, syndrome, 0, 0, -1,
"address(es) not available", "");
}
+ if (!have_addr)
+ return;
+
/* report last error */
/* note: rec_addr is the last recoverable error addr */
page = rec_addr >> PAGE_SHIFT;
@@ -107,7 +112,7 @@ static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr)
}
static void count_un_rec(struct mem_ctl_info *mci, u8 un_rec_cnt,
- u32 un_rec_addr)
+ u32 un_rec_addr, bool have_addr)
{
struct csrow_info *csrow = mci->csrows[0];
u32 page, offset, syndrome;
@@ -117,22 +122,25 @@ static void count_un_rec(struct mem_ctl_info *mci, u8 un_rec_cnt,
/* report 1. error */
/* note: un_rec_addr is the first unrecoverable error addr */
- page = un_rec_addr >> PAGE_SHIFT;
- offset = un_rec_addr & ~PAGE_MASK;
- /* syndrome is not available */
- syndrome = 0;
- edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
- csrow->first_page + page, offset, syndrome,
- 0, 0, -1, "", "");
+ if (have_addr) {
+ page = un_rec_addr >> PAGE_SHIFT;
+ offset = un_rec_addr & ~PAGE_MASK;
+ /* syndrome is not available */
+ syndrome = 0;
+ edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
+ csrow->first_page + page, offset, syndrome,
+ 0, 0, -1, "", "");
+ }
/* report further errors (if there are) */
/* note: no addresses are recorded */
- if (un_rec_cnt > 1) {
+ if (un_rec_cnt > 1 || !have_addr) {
/* page, offset and syndrome are not available */
page = 0;
offset = 0;
syndrome = 0;
- edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, un_rec_cnt-1,
+ edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci,
+ have_addr ? un_rec_cnt - 1 : un_rec_cnt,
page, offset, syndrome, 0, 0, -1,
"address(es) not available", "");
}
@@ -171,8 +179,8 @@ static irqreturn_t mcr_isr(int irq, void *arg)
ASPEED_MCR_INTR_CTRL_CLEAR, 0);
/* process recoverable and unrecoverable errors */
- count_rec(mci, rec_cnt, rec_addr);
- count_un_rec(mci, un_rec_cnt, un_rec_addr);
+ count_rec(mci, rec_cnt, rec_addr, true);
+ count_un_rec(mci, un_rec_cnt, un_rec_addr, true);
if (!rec_cnt && !un_rec_cnt)
dev_dbg(mci->pdev, "received edac interrupt, but did not find any ECC counters\n");
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 07/10] EDAC/aspeed: Allow error addresses above 4 GiB
2026-11-30 7:24 [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
` (5 preceding siblings ...)
2026-11-30 7:24 ` [PATCH v7 06/10] EDAC/aspeed: Allow reporting an error without an address Ryan Chen
@ 2026-11-30 7:24 ` Ryan Chen
2026-11-30 7:24 ` [PATCH v7 08/10] EDAC/aspeed: Disable interrupts before requesting the interrupt line Ryan Chen
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Ryan Chen @ 2026-11-30 7:24 UTC (permalink / raw)
To: Stefan Schaeckeler, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Joel Stanley, Andrew Jeffery, Borislav Petkov,
Tony Luck, Billy Tsai
Cc: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
linux-edac, Ryan Chen
Prepare for the AST2700, which can report failure addresses above
4 GiB. They don't fit in 32 bits.
Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
drivers/edac/aspeed_edac.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
index 85179e229543..f397e8bdbda5 100644
--- a/drivers/edac/aspeed_edac.c
+++ b/drivers/edac/aspeed_edac.c
@@ -75,11 +75,11 @@ static void mcr_update_bits(struct aspeed_edac *priv, u32 reg, u32 mask,
spin_unlock_irqrestore(&priv->lock, flags);
}
-static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr,
- bool have_addr)
+static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt,
+ phys_addr_t rec_addr, bool have_addr)
{
struct csrow_info *csrow = mci->csrows[0];
- u32 page, offset, syndrome;
+ unsigned long page, offset, syndrome;
if (!rec_cnt)
return;
@@ -112,10 +112,10 @@ static void count_rec(struct mem_ctl_info *mci, u8 rec_cnt, u32 rec_addr,
}
static void count_un_rec(struct mem_ctl_info *mci, u8 un_rec_cnt,
- u32 un_rec_addr, bool have_addr)
+ phys_addr_t un_rec_addr, bool have_addr)
{
struct csrow_info *csrow = mci->csrows[0];
- u32 page, offset, syndrome;
+ unsigned long page, offset, syndrome;
if (!un_rec_cnt)
return;
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 08/10] EDAC/aspeed: Disable interrupts before requesting the interrupt line
2026-11-30 7:24 [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
` (6 preceding siblings ...)
2026-11-30 7:24 ` [PATCH v7 07/10] EDAC/aspeed: Allow error addresses above 4 GiB Ryan Chen
@ 2026-11-30 7:24 ` Ryan Chen
2026-11-30 7:24 ` [PATCH v7 09/10] EDAC/aspeed: Add AST2700 support Ryan Chen
2026-11-30 7:24 ` [PATCH v7 10/10] MAINTAINERS: Step down as Aspeed AST2500 EDAC driver maintainer Ryan Chen
9 siblings, 0 replies; 11+ messages in thread
From: Ryan Chen @ 2026-11-30 7:24 UTC (permalink / raw)
To: Stefan Schaeckeler, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Joel Stanley, Andrew Jeffery, Borislav Petkov,
Tony Luck, Billy Tsai
Cc: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
linux-edac, Ryan Chen
Prepare for the AST2700, whose interrupt line also carries memory
controller events the driver doesn't handle. They may already be
enabled when the driver loads, so turn them off before the handler is
installed.
Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
drivers/edac/aspeed_edac.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
index f397e8bdbda5..36599ddf589a 100644
--- a/drivers/edac/aspeed_edac.c
+++ b/drivers/edac/aspeed_edac.c
@@ -211,6 +211,9 @@ static int config_irq(void *ctx, struct platform_device *pdev)
if (irq < 0)
return irq;
+ /* keep interrupts off until the handler is in place */
+ priv->chip->set_irq(priv, false);
+
rc = request_irq(irq, priv->chip->isr, IRQF_TRIGGER_HIGH, DRV_NAME,
ctx);
if (rc)
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 09/10] EDAC/aspeed: Add AST2700 support
2026-11-30 7:24 [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
` (7 preceding siblings ...)
2026-11-30 7:24 ` [PATCH v7 08/10] EDAC/aspeed: Disable interrupts before requesting the interrupt line Ryan Chen
@ 2026-11-30 7:24 ` Ryan Chen
2026-11-30 7:24 ` [PATCH v7 10/10] MAINTAINERS: Step down as Aspeed AST2500 EDAC driver maintainer Ryan Chen
9 siblings, 0 replies; 11+ messages in thread
From: Ryan Chen @ 2026-11-30 7:24 UTC (permalink / raw)
To: Stefan Schaeckeler, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Joel Stanley, Andrew Jeffery, Borislav Petkov,
Tony Luck, Billy Tsai
Cc: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
linux-edac, Ryan Chen
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 <ryan_chen@aspeedtech.com>
---
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 <linux/bitfield.h>
#include <linux/edac.h>
#include <linux/init.h>
#include <linux/interrupt.h>
@@ -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
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 10/10] MAINTAINERS: Step down as Aspeed AST2500 EDAC driver maintainer
2026-11-30 7:24 [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
` (8 preceding siblings ...)
2026-11-30 7:24 ` [PATCH v7 09/10] EDAC/aspeed: Add AST2700 support Ryan Chen
@ 2026-11-30 7:24 ` Ryan Chen
9 siblings, 0 replies; 11+ messages in thread
From: Ryan Chen @ 2026-11-30 7:24 UTC (permalink / raw)
To: Stefan Schaeckeler, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Joel Stanley, Andrew Jeffery, Borislav Petkov,
Tony Luck, Billy Tsai
Cc: devicetree, linux-arm-kernel, linux-aspeed, linux-kernel,
linux-edac, Ryan Chen
From: Stefan M Schaeckeler <sschaeck@cisco.com>
I am stepping down as a maintainer for drivers/edac/aspeed_edac.c and
Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml
Move my entry from the MAINTAINERS file to CREDITS to reflect my past
contributions.
[ ryan: keep the EDAC-AST2500 entry and list myself as its reviewer
rather than removing it, and take over the binding's maintainers
field ]
Signed-off-by: Stefan M Schaeckeler <sschaeck@cisco.com>
Link: https://lore.kernel.org/r/20260920225846.4039017-1-sschaeck@cisco.com
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
Changes in v5:
- Also hand over the maintainers field inside the binding, which
get_maintainer.pl reads directly for .yaml files.
Changes in v4:
- Merge Stefan's step-down patch into this one, keeping the MAINTAINERS
entry alive with a reviewer instead of removing it.
Changes in v3:
- New patch.
---
CREDITS | 8 ++++++++
.../devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml | 2 +-
MAINTAINERS | 2 +-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/CREDITS b/CREDITS
index c6c7b173b064..855062c309fe 100644
--- a/CREDITS
+++ b/CREDITS
@@ -3696,6 +3696,14 @@ D: I2O kernel layer (config, block, core, pci, net). I2O disk support for LILO
D: XScale (IOP, IXP) porting and other random ARM bits
S: Portland, OR
+N: Stefan Schaeckeler
+E: sschaeck@cisco.com
+E: schaecsn@gmx.net
+D: Author and initial maintainer of the Aspeed AST2500 EDAC driver
+S: 2253 Anna Dr.
+S: Santa Clara, CA 95050
+S: USA
+
N: Eric Schenk
E: Eric.Schenk@dna.lth.se
D: Random kernel debugging.
diff --git a/Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml b/Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml
index 685b6815f293..971d4c862fe7 100644
--- a/Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml
+++ b/Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Aspeed BMC SoC SDRAM EDAC controller
maintainers:
- - Stefan Schaeckeler <sschaeck@cisco.com>
+ - Ryan Chen <ryan_chen@aspeedtech.com>
description: >
The Aspeed BMC SoCs support DDR memory with and without ECC (error
diff --git a/MAINTAINERS b/MAINTAINERS
index 93abbb315065..323b2f90536d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9607,7 +9607,7 @@ F: Documentation/devicetree/bindings/memory-controllers/marvell,mvebu-sdram-cont
F: drivers/edac/armada_xp_*
EDAC-AST2500
-M: Stefan Schaeckeler <sschaeck@cisco.com>
+R: Ryan Chen <ryan_chen@aspeedtech.com>
S: Supported
F: Documentation/devicetree/bindings/edac/aspeed,ast2400-sdram-edac.yaml
F: drivers/edac/aspeed_edac.c
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-30 7:25 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 7:24 [PATCH v7 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
2026-11-30 7:24 ` [PATCH v7 01/10] EDAC/aspeed: Stop keeping driver state in global variables Ryan Chen
2026-11-30 7:24 ` [PATCH v7 02/10] EDAC/aspeed: Replace regmap with direct register access Ryan Chen
2026-11-30 7:24 ` [PATCH v7 03/10] EDAC/aspeed: Put the differences between chips in a table Ryan Chen
2026-11-30 7:24 ` [PATCH v7 04/10] EDAC/aspeed: Don't unlock the interrupt control register on AST2600 Ryan Chen
2026-11-30 7:24 ` [PATCH v7 05/10] EDAC/aspeed: Let each chip provide its own interrupt handling Ryan Chen
2026-11-30 7:24 ` [PATCH v7 06/10] EDAC/aspeed: Allow reporting an error without an address Ryan Chen
2026-11-30 7:24 ` [PATCH v7 07/10] EDAC/aspeed: Allow error addresses above 4 GiB Ryan Chen
2026-11-30 7:24 ` [PATCH v7 08/10] EDAC/aspeed: Disable interrupts before requesting the interrupt line Ryan Chen
2026-11-30 7:24 ` [PATCH v7 09/10] EDAC/aspeed: Add AST2700 support Ryan Chen
2026-11-30 7:24 ` [PATCH v7 10/10] MAINTAINERS: Step down as Aspeed AST2500 EDAC driver maintainer Ryan Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®