All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pandey, Radhey Shyam" <radheys@amd.com>
To: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>,
	linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org
Cc: git@amd.com, shubhrajyoti.datta@gmail.com,
	Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>,
	Borislav Petkov <bp@alien8.de>, Tony Luck <tony.luck@intel.com>,
	Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
Subject: Re: [PATCH v3 2/7] EDAC/versalnet: Make dwidth per-controller
Date: Mon, 30 Nov 2026 11:44:50 +0530	[thread overview]
Message-ID: <44eae8d6-b74d-4b61-9389-e4a54bcb76ac@amd.com> (raw)
In-Reply-To: <20261127163853.3563991-3-shubhrajyoti.datta@amd.com>

On 11/27/2026 9:59 PM, Shubhrajyoti Datta wrote:
> Currently dwidth is a single scalar in mc_priv, so each call to
> init_one_mc() overwrites the previous controller's value.
> 
> Fix this by converting dwidth to a per-controller array and passing
> the device type directly to mc_init() from the detected dtype.
> This also updates the DIMM device type reported in EDAC.
> 
> Fixes: d5fe2fec6c40 ("EDAC: Add a driver for the AMD Versal NET DDR controller")
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
> ---

This patch as is fine, but sashiko points to a preexisting issue in this 
review. I think reordering 9/9 to second patch would auto fix this.

This problem wasn't introduced by this patch, but the slots left
unpopulated by init_one_mc() are still unhandled.
init_one_mc() returns 0 early for a DEV_UNKNOWN controller:
     if (dt == DEV_UNKNOWN)
         return 0;

Similarly, in remove_one_mc():
     mci = priv->mci[i];
     dev = mci->pdev;
Can this dereference NULL mci on removal for a skipped slot?

> 
> Changes in v3:
> Updated the description to dtype
> Update the memory allocation in edac_mc_alloc as pvt info is not used
> 
> Changes in v2:
> https://sashiko.dev/#/patchset/20260724171945.2812749-1-shubhrajyoti.datta%40amd.com
> New patch to fix shashiko review comment "this is a pre-existing
> issue, but is the per-controller width overwriting the shared
> state for all controllers?".
> 
>   drivers/edac/versalnet_edac.c | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c
> index 405d994303c7..8decaba19048 100644
> --- a/drivers/edac/versalnet_edac.c
> +++ b/drivers/edac/versalnet_edac.c
> @@ -140,7 +140,7 @@ struct ecc_status {
>    * @stat:		ECC status information.
>    * @error_id:		The error id.
>    * @error_level:	The error level.
> - * @dwidth:		Width of data bus excluding ECC bits.
> + * @dwidth:		Per-controller width of data bus excluding ECC bits.

Nit - data bus width

>    * @part_len:		The support of the message received.
>    * @regs:		The registers sent on the rpmsg.
>    * @adec:		Address decode registers.
> @@ -153,7 +153,7 @@ struct mc_priv {
>   	struct ecc_status stat;
>   	u32 error_id;
>   	u32 error_level;
> -	u32 dwidth;
> +	enum dev_type dwidth[NUM_CONTROLLERS];
>   	u32 part_len;
>   	u32 regs[REG_MAX];
>   	u32 adec[ADEC_MAX];
> @@ -399,7 +399,7 @@ static unsigned long convert_to_physical(struct mc_priv *priv,
>   	else
>   		ilc_base_ctrl_add = ilcmem_base - low_mem_offset;
>   
> -	if (priv->dwidth == DEV_X16) {
> +	if (priv->dwidth[controller] == DEV_X16) {
>   		blk = err_addr / MC5_X16_SIZE;
>   		rsh_req_addr = (blk << 8) + ilc_base_ctrl_add;
>   		err_addr = rsh_req_addr * interleave * 2;
> @@ -473,9 +473,9 @@ static void handle_error(struct mc_priv  *priv, struct ecc_status *stat,
>   	}
>   }
>   
> -static void mc_init(struct mem_ctl_info *mci, struct device *dev)
> +static void mc_init(struct mem_ctl_info *mci, struct device *dev,
> +		    enum dev_type dtype)
>   {
> -	struct mc_priv *priv = mci->pvt_info;
>   	struct csrow_info *csi;
>   	struct dimm_info *dimm;
>   	u32 row;
> @@ -501,7 +501,7 @@ static void mc_init(struct mem_ctl_info *mci, struct device *dev)
>   			dimm->edac_mode = EDAC_SECDED;
>   			dimm->mtype = MEM_DDR5;
>   			dimm->grain = MC5_ERR_GRAIN;
> -			dimm->dtype = priv->dwidth;
> +			dimm->dtype = dtype;
>   		}
>   	}
>   }
> @@ -846,7 +846,7 @@ static int init_one_mc(struct mc_priv *priv, struct platform_device *pdev, int i
>   	if (rc)
>   		goto err_put_dev;
>   
> -	mci = edac_mc_alloc(i, ARRAY_SIZE(layers), layers, sizeof(struct mc_priv));
> +	mci = edac_mc_alloc(i, ARRAY_SIZE(layers), layers, 0);
>   	if (!mci) {
>   		edac_printk(KERN_ERR, EDAC_MC, "Failed memory allocation for MC%d\n", i);
>   		rc = -ENOMEM;
> @@ -854,7 +854,7 @@ static int init_one_mc(struct mc_priv *priv, struct platform_device *pdev, int i
>   	}
>   
>   	mci->pdev = dev;
> -	mc_init(mci, dev);
> +	mc_init(mci, dev, dt);
>   
>   	rc = edac_mc_add_mc(mci);
>   	if (rc) {
> @@ -863,7 +863,7 @@ static int init_one_mc(struct mc_priv *priv, struct platform_device *pdev, int i
>   	}
>   
>   	priv->mci[i] = mci;
> -	priv->dwidth = dt;
> +	priv->dwidth[i] = dt;
>   
>   	platform_set_drvdata(pdev, priv);
>   


  reply	other threads:[~2026-11-30  6:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 16:29 [PATCH v3 0/7] EDAC/versalnet: Fix error handling, teardown, and robustness Shubhrajyoti Datta
2026-11-27 16:29 ` [PATCH v3 1/7] EDAC/versalnet: Add bounds validation in rpmsg_cb() Shubhrajyoti Datta
2026-11-30  6:05   ` Pandey, Radhey Shyam
2026-11-27 16:29 ` [PATCH v3 2/7] EDAC/versalnet: Make dwidth per-controller Shubhrajyoti Datta
2026-11-30  6:14   ` Pandey, Radhey Shyam [this message]
2026-11-27 16:29 ` [PATCH v3 3/7] EDAC/versalnet: Wait for RPMsg endpoint initialization Shubhrajyoti Datta
2026-11-27 16:51   ` Shubhrajyoti Datta
2026-11-27 16:29 ` [PATCH v3 4/7] EDAC/versalnet: Guard against NULL drvdata in rpmsg_cb() Shubhrajyoti Datta
2026-11-27 16:29 ` [PATCH v3 5/7] EDAC/versalnet: Make get_ddr_config() return errors Shubhrajyoti Datta
2026-11-27 16:29 ` [PATCH v3 6/7] EDAC/versalnet: fix the remove controller crash Shubhrajyoti Datta
2026-11-27 16:29 ` [PATCH v3 7/7] EDAC/versalnet: Move platform_set_drvdata() to mc_probe() Shubhrajyoti Datta
2026-11-30  6:49 ` [PATCH v3 0/7] EDAC/versalnet: Fix error handling, teardown, and robustness Pandey, Radhey Shyam

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=44eae8d6-b74d-4b61-9389-e4a54bcb76ac@amd.com \
    --to=radheys@amd.com \
    --cc=bp@alien8.de \
    --cc=git@amd.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=sai.krishna.potthuri@amd.com \
    --cc=shubhrajyoti.datta@amd.com \
    --cc=shubhrajyoti.datta@gmail.com \
    --cc=tony.luck@intel.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 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.