All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ryan Chen" <ryan_chen@aspeedtech.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v8 09/10] EDAC/aspeed: Add AST2700 support
Date: Sat, 05 Dec 2026 01:10:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-250884@kernel.org> (raw)
In-Reply-To: <20261205-edac-v8-9-8a27981a6053@aspeedtech.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] edac: aspeed: AST2700 IRQ clear/counter mismatch in
  ast2700_irq_handler()
--

commit 1990ff4c873d797149e12eca773229e520b466dc
Author: Ryan Chen <ryan_chen@aspeedtech.com>

EDAC/aspeed: Add AST2700 support

This commit adds EDAC support for the Aspeed AST2700 memory controller,
including its interrupt handler, IRQ mask configuration, and device tree
match entry.

> diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
> index 4435820b20917..12c7d770afa6c 100644
> --- a/drivers/edac/aspeed_edac.c
> +++ b/drivers/edac/aspeed_edac.c

[ ... ]

> @@ -198,6 +215,58 @@ static void ast2400_set_irq(struct driver_priv *priv, bool enable)
>  			enable ? ASPEED_MCR_INTR_CTRL_ENABLE : 0);
>  }
>  
> +static irqreturn_t ast2700_irq_handler(int irq, void *arg)
> +{
> +	struct mem_ctl_info *mci = arg;
> +	struct driver_priv *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);

[Severity: Medium]
Can ast2700_irq_handler() double-count ECC errors or take a spurious
re-entry when the other error type arrives between reading AST2700_INT_STS
and AST2700_ECC_STS?

AST2700_INT_CLR only clears the bits sampled earlier in int_sts, while
both rec_cnt and un_rec_cnt from ecc_sts are reported unconditionally.
Because config_irq() requests the IRQ with IRQF_TRIGGER_HIGH, an
unacknowledged bit immediately re-triggers the handler:

CPU0 (<hardirq>)                   Memory controller
ast2700_irq_handler()
  readl(AST2700_INT_STS)
  /* only recoverable bit set */
                                   unrecoverable ECC error arrives
                                     sets unrecoverable bit & un_rec_cnt
  readl(AST2700_ECC_STS)
  /* sees rec_cnt & un_rec_cnt */
  writel(int_sts & ..., INT_CLR)
  /* clears only recoverable */
  count_un_rec() & count_rec()
  return IRQ_HANDLED
ast2700_irq_handler()              <-- re-enters, unrecoverable still set

If AST2700_INT_CLR resets the recoverable and unrecoverable counters
independently per bit, un_rec_cnt remains non-zero and is reported a
second time; if the counters clear jointly or on read, the second entry
is a spurious interrupt with zero counters.

Either gate reporting of rec_cnt and un_rec_cnt on their respective
int_sts bits, or include the corresponding clear bit in the
AST2700_INT_CLR write whenever a counter read from ecc_sts is non-zero.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-edac-v8-0-8a27981a6053@aspeedtech.com?part=9

  reply	other threads:[~2026-12-05  1:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  0:53 [PATCH v8 00/10] Add Aspeed AST2700 SDRAM EDAC support Ryan Chen
2026-12-05  0:53 ` [PATCH v8 01/10] EDAC/aspeed: Add a driver private struct Ryan Chen
2026-12-05  0:53 ` [PATCH v8 02/10] EDAC/aspeed: Replace regmap with direct register access Ryan Chen
2026-12-05  0:53 ` [PATCH v8 03/10] EDAC/aspeed: Put the differences between chips in a table Ryan Chen
2026-12-05  0:53 ` [PATCH v8 04/10] EDAC/aspeed: Don't unlock the interrupt control register on AST2600 Ryan Chen
2026-12-05  0:53 ` [PATCH v8 05/10] EDAC/aspeed: Let each chip provide its own interrupt handling Ryan Chen
2026-12-05  0:53 ` [PATCH v8 06/10] EDAC/aspeed: Allow reporting an error without an address Ryan Chen
2026-12-05  0:53 ` [PATCH v8 07/10] EDAC/aspeed: Allow error addresses above 4 GiB Ryan Chen
2026-12-05  0:53 ` [PATCH v8 08/10] EDAC/aspeed: Disable interrupts before requesting the interrupt line Ryan Chen
2026-12-05  0:53 ` [PATCH v8 09/10] EDAC/aspeed: Add AST2700 support Ryan Chen
2026-12-05  1:10   ` sashiko-bot [this message]
2026-12-05  0:53 ` [PATCH v8 10/10] MAINTAINERS: Step down as Aspeed AST2500 EDAC driver maintainer Ryan Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-250884@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=ryan_chen@aspeedtech.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.