Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Paul Louvel" <paul.louvel@bootlin.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	wsa+renesas@sang-engineering.com
Subject: Re: [PATCH v8 2/3] EDAC/cadence: Add Cadence DDR EDAC driver
Date: Wed, 18 Nov 2026 10:37:48 +0000	[thread overview]
Message-ID: <sashiko-outbox-220720@kernel.org> (raw)
In-Reply-To: <20261118-paul-v7-3-rc1-edac-v8-2-ed791084cc19@bootlin.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] EDAC/cadence: cdns_setup_mc() reports SECDED mode when ECC is
  disabled
- [Medium] EDAC/cadence: missing memory base PFN offset in
  cdns_mc_err_handler()
--

commit 75a0021a276efa3f6b0c9a800bd2617eb0141dff
Author: Paul Louvel <paul.louvel@bootlin.com>

EDAC/cadence: Add Cadence DDR EDAC driver

This commit adds an EDAC driver for the Cadence DDR memory controller on
Renesas RZ/N1x SoCs, supporting SECDED error reporting, software
scrubbing, and debugfs error injection.

> diff --git a/drivers/edac/cadence_edac.c b/drivers/edac/cadence_edac.c
> new file mode 100644
> index 0000000000000..a3b72116ba129
> --- /dev/null
> +++ b/drivers/edac/cadence_edac.c
[ ... ]
> +static irqreturn_t cdns_mc_err_handler(int irq, void *dev_id)
> +{
> +	struct mem_ctl_info *mci = dev_id;
> +	struct mc_priv *priv = mci->pvt_info;
> +	u32 status, err_addr, syndrome, reg;
> +
> +	status = readl(priv->io_base + CDNS_ECC_INT_STAT);
> +	if (!status)
> +		return IRQ_NONE;
> +
> +	/*
> +	 * Hardware is not exposing how many CE / UE occurred since last ACK in
> +	 * case of multiple errors. Always set the error count to 1.
> +	 */
> +
> +	if (status & (CDNS_ECC_INT_STAT_UE | CDNS_ECC_INT_STAT_MULTIPLE_UE)) {
> +		reg = readl(priv->io_base + CDNS_ECC_U_ERR_STAT);
> +		syndrome = CDNS_ECC_ERR_STAT_GET_SYNDROME(reg);
> +
> +		err_addr = readl(priv->io_base + CDNS_ECC_U_ERR_ADDR);
> +
> +		edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, err_addr >> PAGE_SHIFT,
> +				     err_addr & ~PAGE_MASK, syndrome, 0, 0, -1, mci->ctl_name, "");
> +	}
> +
> +	if (status & (CDNS_ECC_INT_STAT_CE | CDNS_ECC_INT_STAT_MULTIPLE_CE)) {
> +		reg = readl(priv->io_base + CDNS_ECC_C_ERR_STAT);
> +		syndrome = CDNS_ECC_ERR_STAT_GET_SYNDROME(reg);
> +
> +		err_addr = readl(priv->io_base + CDNS_ECC_C_ERR_ADDR);
> +
> +		edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, err_addr >> PAGE_SHIFT,
> +				     err_addr & ~PAGE_MASK, syndrome, 0, 0, -1, mci->ctl_name, "");
> +	}

[Severity: Medium]
Does passing err_addr >> PAGE_SHIFT directly to edac_mc_handle_error()
miss the physical memory base offset?

On Renesas RZ/N1 (r9a06g032), system DDR starts at physical address
0x80000000, while the Cadence/Denali controller logs 0-based DRAM offsets
in CDNS_ECC_U_ERR_ADDR and CDNS_ECC_C_ERR_ADDR.  cdns_setup_mc() fetches
the /memory resource into res and enables SCRUB_SW_SRC, but discards
res.start and leaves mci->ctl_page_to_phys unset.  Without adding
PHYS_PFN(res.start), edac_mc_handle_error() reports a 0-based PFN and
edac_mc_scrub_block() fails pfn_valid(), silently skipping software ECC
scrubbing.

[ ... ]
> +	reg = readl(priv->io_base + CDNS_ECC_STAT);
> +	if (!CDNS_ECC_STAT_IS_ENABLED(reg))
> +		mci->edac_cap = EDAC_FLAG_NONE;
> +	else
> +		mci->edac_cap = EDAC_FLAG_SECDED;
> +
> +	mci->mtype_cap = MEM_FLAG_DDR2 | MEM_FLAG_DDR3;
> +	mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
> +	mci->mod_name = pdev->dev.driver->name;
> +	mci->ctl_name = "cdns-ddr-ctrl";
> +	mci->dev_name = dev_name(&pdev->dev);
> +	mci->scrub_mode = SCRUB_SW_SRC;
> +
> +	dimm = *mci->dimms;
> +	dimm->nr_pages = PFN_UP(mem_sz);
> +	dimm->grain = 4;
> +	dimm->edac_mode = EDAC_SECDED;

[Severity: Medium]
Should cdns_setup_mc() set dimm->edac_mode to EDAC_SECDED and continue
probing when CDNS_ECC_STAT_IS_ENABLED(reg) is false?

When the bootloader has not enabled ECC, mci->edac_cap is set to
EDAC_FLAG_NONE, but dimm->edac_mode is still hardcoded to EDAC_SECDED.
Because EDAC sysfs exposes dimm->edac_mode via dimm_edac_mode, userspace
monitoring tools will see SECDED reported as active while the driver also
requests the ECC interrupt, unmasks CDNS_ECC_INT_EDAC, and exposes debugfs
error injection on a controller with ECC disabled.  Failing probe with
-ENODEV (as documented in Kconfig that ECC must be configured by the
bootloader) or setting dimm->edac_mode = EDAC_NONE would avoid reporting
active ECC.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-paul-v7-3-rc1-edac-v8-0-ed791084cc19@bootlin.com?part=2

  reply	other threads:[~2026-11-18 10:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 10:05 [PATCH v8 0/3] Add Renesas RZ/N1x EDAC driver Paul Louvel
2026-11-18 10:05 ` [PATCH v8 1/3] dt-bindings: edac: cdns,ddr-edac: add Cadence DDR EDAC Paul Louvel
2026-11-18 10:05 ` [PATCH v8 2/3] EDAC/cadence: Add Cadence DDR EDAC driver Paul Louvel
2026-11-18 10:37   ` sashiko-bot [this message]
2026-11-18 10:05 ` [PATCH v8 3/3] ARM: dts: renesas: r9a06g032: add EDAC node Paul Louvel
2026-11-18 10:27   ` Wolfram Sang
2026-11-18 10:25 ` [PATCH v8 0/3] Add Renesas RZ/N1x EDAC driver Wolfram Sang

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-220720@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=paul.louvel@bootlin.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox