lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
 <SA1PR12MB894766DFAD90E9DB15A3268F8174A@SA1PR12MB8947.namprd12.prod.outlook.com>
Date: Thu, 12 Jun 2025 11:42:13 +0000
From: "Datta, Shubhrajyoti" <shubhrajyoti.datta@....com>
To: Borislav Petkov <bp@...en8.de>
CC: "linux-arm-kernel@...ts.infradead.org"
	<linux-arm-kernel@...ts.infradead.org>, "linux-edac@...r.kernel.org"
	<linux-edac@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "git (AMD-Xilinx)" <git@....com>, "Simek,
 Michal" <michal.simek@....com>, Tony Luck <tony.luck@...el.com>, James Morse
	<james.morse@....com>, Mauro Carvalho Chehab <mchehab@...nel.org>, Robert
 Richter <rric@...nel.org>
Subject: RE: [PATCH] EDAC/synopsys: Clear the ecc counters at init

[AMD Official Use Only - AMD Internal Distribution Only]

> -----Original Message-----
> From: Borislav Petkov <bp@...en8.de>
> Sent: Wednesday, June 11, 2025 10:10 PM
> To: Datta, Shubhrajyoti <shubhrajyoti.datta@....com>
> Cc: linux-arm-kernel@...ts.infradead.org; linux-edac@...r.kernel.org; linux-
> kernel@...r.kernel.org; git (AMD-Xilinx) <git@....com>; Simek, Michal
> <michal.simek@....com>; Tony Luck <tony.luck@...el.com>; James Morse
> <james.morse@....com>; Mauro Carvalho Chehab <mchehab@...nel.org>;
> Robert Richter <rric@...nel.org>
> Subject: Re: [PATCH] EDAC/synopsys: Clear the ecc counters at init
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Wed, Jun 11, 2025 at 11:42:33AM +0000, Datta, Shubhrajyoti wrote:
> > However the registers for Zynqmp and Zynq is different to
> > differentiate Should the usage of quirk be fine code snippet below
>
> Right, please send a proper diff - it doesn't have to be tested yet and I'll finish
> massaging it.


Please find the diff below

drivers/edac/synopsys_edac.c | 87 ++++++++++++++----------------------
 1 file changed, 34 insertions(+), 53 deletions(-)

diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c
index 5ed32a3299c4..789ac21e8028 100644
--- a/drivers/edac/synopsys_edac.c
+++ b/drivers/edac/synopsys_edac.c
@@ -337,7 +337,6 @@ struct synps_edac_priv {
  * @get_error_info:    Get EDAC error info.
  * @get_mtype:         Get mtype.
  * @get_dtype:         Get dtype.
- * @get_ecc_state:     Get ECC state.
  * @get_mem_info:      Get EDAC memory info
  * @quirks:            To differentiate IPs.
  */
@@ -345,7 +344,6 @@ struct synps_platform_data {
        int (*get_error_info)(struct synps_edac_priv *priv);
        enum mem_type (*get_mtype)(const void __iomem *base);
        enum dev_type (*get_dtype)(const void __iomem *base);
-       bool (*get_ecc_state)(void __iomem *base);
 #ifdef CONFIG_EDAC_DEBUG
        u64 (*get_mem_info)(struct synps_edac_priv *priv);
 #endif
@@ -720,53 +718,38 @@ static enum dev_type zynqmp_get_dtype(const void __iomem *base)
        return dt;
 }

-/**
- * zynq_get_ecc_state - Return the controller ECC enable/disable status.
- * @base:      DDR memory controller base address.
- *
- * Get the ECC enable/disable status of the controller.
- *
- * Return: true if enabled, otherwise false.
- */
-static bool zynq_get_ecc_state(void __iomem *base)
-{
-       enum dev_type dt;
-       u32 ecctype;
-
-       dt = zynq_get_dtype(base);
-       if (dt == DEV_UNKNOWN)
-               return false;

-       ecctype = readl(base + SCRUB_OFST) & SCRUB_MODE_MASK;
-       if ((ecctype == SCRUB_MODE_SECDED) && (dt == DEV_X2))
-               return true;
-
-       return false;
-}
-
-/**
- * zynqmp_get_ecc_state - Return the controller ECC enable/disable status.
- * @base:      DDR memory controller base address.
- *
- * Get the ECC enable/disable status for the controller.
- *
- * Return: a ECC status boolean i.e true/false - enabled/disabled.
- */
-static bool zynqmp_get_ecc_state(void __iomem *base)
+static bool get_ecc_state(struct synps_edac_priv *priv)
 {
        enum dev_type dt;
-       u32 ecctype;
-
-       dt = zynqmp_get_dtype(base);
-       if (dt == DEV_UNKNOWN)
-               return false;
-
-       ecctype = readl(base + ECC_CFG0_OFST) & SCRUB_MODE_MASK;
-       if ((ecctype == SCRUB_MODE_SECDED) &&
-           ((dt == DEV_X2) || (dt == DEV_X4) || (dt == DEV_X8)))
-               return true;
-
-       return false;
+       u32 ecctype, clearval;
+
+       if (!priv->p_data->quirks) {
+               dt = zynq_get_dtype(priv->baseaddr);
+               if (dt == DEV_UNKNOWN)
+                       return false;
+
+               ecctype = readl(priv->baseaddr + SCRUB_OFST) & SCRUB_MODE_MASK;
+               if (ecctype == SCRUB_MODE_SECDED && dt == DEV_X2) {
+                       clearval = ECC_CTRL_CLR_CE_ERR | ECC_CTRL_CLR_UE_ERR;
+                       writel(clearval, priv->baseaddr + ECC_CTRL_OFST);
+                       writel(0x0, priv->baseaddr + ECC_CTRL_OFST);
+               }
+       } else {
+               dt = zynqmp_get_dtype(priv->baseaddr);
+               if (dt == DEV_UNKNOWN)
+                       return false;
+
+               ecctype = readl(priv->baseaddr + ECC_CFG0_OFST) & SCRUB_MODE_MASK;
+               if (ecctype == SCRUB_MODE_SECDED &&
+                   (dt == DEV_X2 || dt == DEV_X4 || dt == DEV_X8)) {
+                       clearval = readl(priv->baseaddr + ECC_CLR_OFST) |
+                       ECC_CTRL_CLR_CE_ERR | ECC_CTRL_CLR_CE_ERRCNT |
+                       ECC_CTRL_CLR_UE_ERR | ECC_CTRL_CLR_UE_ERRCNT;
+                       writel(clearval, priv->baseaddr + ECC_CLR_OFST);
+               }
+       }
+       return true;
 }

 /**
@@ -937,7 +920,6 @@ static const struct synps_platform_data zynq_edac_def = {
        .get_error_info = zynq_get_error_info,
        .get_mtype      = zynq_get_mtype,
        .get_dtype      = zynq_get_dtype,
-       .get_ecc_state  = zynq_get_ecc_state,
        .quirks         = 0,
 };

@@ -945,7 +927,6 @@ static const struct synps_platform_data zynqmp_edac_def = {
        .get_error_info = zynqmp_get_error_info,
        .get_mtype      = zynqmp_get_mtype,
        .get_dtype      = zynqmp_get_dtype,
-       .get_ecc_state  = zynqmp_get_ecc_state,
 #ifdef CONFIG_EDAC_DEBUG
        .get_mem_info   = zynqmp_get_mem_info,
 #endif
@@ -960,7 +941,6 @@ static const struct synps_platform_data synopsys_edac_def = {
        .get_error_info = zynqmp_get_error_info,
        .get_mtype      = zynqmp_get_mtype,
        .get_dtype      = zynqmp_get_dtype,
-       .get_ecc_state  = zynqmp_get_ecc_state,
        .quirks         = (DDR_ECC_INTR_SUPPORT | DDR_ECC_INTR_SELF_CLEAR
 #ifdef CONFIG_EDAC_DEBUG
                          | DDR_ECC_DATA_POISON_SUPPORT
@@ -1390,10 +1370,6 @@ static int mc_probe(struct platform_device *pdev)
        if (!p_data)
                return -ENODEV;

-       if (!p_data->get_ecc_state(baseaddr)) {
-               edac_printk(KERN_INFO, EDAC_MC, "ECC not enabled\n");
-               return -ENXIO;
-       }

        layers[0].type = EDAC_MC_LAYER_CHIP_SELECT;
        layers[0].size = SYNPS_EDAC_NR_CSROWS;
@@ -1413,6 +1389,11 @@ static int mc_probe(struct platform_device *pdev)
        priv = mci->pvt_info;
        priv->baseaddr = baseaddr;
        priv->p_data = p_data;
+       if (!get_ecc_state(priv)) {
+               edac_printk(KERN_INFO, EDAC_MC, "ECC not enabled\n");
+               goto free_edac_mc;
+       }
+
        spin_lock_init(&priv->reglock);

        mc_init(mci, pdev);
--
2.17.1


>
> Thx.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ