mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Pandey, Radhey Shyam" <radheys@amd.com>
To: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>,
	linux-edac@vger.kernel.org
Cc: git@amd.com, shubhrajyoti.datta@gmail.com, michal.simek@amd.com,
	Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Rob Herring <robh@kernel.org>, Conor Dooley <conor+dt@kernel.org>,
	Borislav Petkov <bp@alien8.de>, Tony Luck <tony.luck@intel.com>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 12/12] EDAC/versalnet: Make get_ddr_config() return errors
Date: Tue, 24 Nov 2026 14:26:49 +0530	[thread overview]
Message-ID: <b1036e45-dfd3-42b8-bec5-34c59447a25f@amd.com> (raw)
In-Reply-To: <20261118142213.100581-13-shubhrajyoti.datta@amd.com>

On 11/18/2026 7:50 PM, Shubhrajyoti Datta wrote:
> get_ddr_config() invokes cdx_mcdi_rpc() but ignores its return value,
> and proceeds even if the cdx_mcdi_rpc returned errors. Also it

Nit - cdx_mcdi_rpc()

> copies the data out of the response buffer without checking that
> the firmware actually returned that much data.
> 
> Make get_ddr_config() return an int: propagate cdx_mcdi_rpc()'s
> return code on failure, and return -EIO if the response is shorter
> than expected. Update mc_probe() to check the return value and bail
> out through the existing error path on failure.
> 
> Fixes: d5fe2fec6c40 ("EDAC: Add a driver for the AMD Versal NET DDR controller")
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
> ---
> 
> Changes in v2:
> New patch added to bailout if the cdx_mcdi_rpc fails.
> 
>   drivers/edac/versalnet_edac.c | 21 +++++++++++++++------
>   1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c
> index c2025f5744cc..ac6e926a1918 100644
> --- a/drivers/edac/versalnet_edac.c
> +++ b/drivers/edac/versalnet_edac.c
> @@ -587,7 +587,7 @@ static const struct cdx_mcdi_ops mcdi_ops = {
>   	.mcdi_request = mcdi_request,
>   };
>   
> -static void get_ddr_config(u32 index, u32 *buffer, struct cdx_mcdi *amd_mcdi)
> +static int get_ddr_config(u32 index, u32 *buffer, struct cdx_mcdi *amd_mcdi)
>   {
>   	size_t outlen;
>   	int ret;
> @@ -599,9 +599,15 @@ static void get_ddr_config(u32 index, u32 *buffer, struct cdx_mcdi *amd_mcdi)
>   
>   	ret = cdx_mcdi_rpc(amd_mcdi, MC_CMD_EDAC_GET_DDR_CONFIG, inbuf, sizeof(inbuf),
>   			   outbuf, sizeof(outbuf), &outlen);
> -	if (!ret)
> -		memcpy(buffer, MCDI_PTR(outbuf, GET_DDR_CONFIG),
> -		       (ADEC_NUM * 4));
> +	if (ret)
> +		return ret;
> +
> +	if (outlen < MC_CMD_GET_DDR_CONFIG_OFST + ADEC_NUM * 4)

I think better to use sizeof(outbuf).

> +		return -EIO;
> +
> +	memcpy(buffer, MCDI_PTR(outbuf, GET_DDR_CONFIG), (ADEC_NUM * 4));
> +
> +	return 0;
>   }
>   
>   static int setup_mcdi(struct mc_priv *mc_priv)
> @@ -1043,8 +1049,11 @@ static int mc_probe(struct platform_device *pdev)
>   
>   	priv->mcdi->r5_rproc = rp;
>   
> -	for (i = 0; i < priv->num_ctrl; i++)
> -		get_ddr_config(i, &priv->adec[ADEC_NUM * i], priv->mcdi);
> +	for (i = 0; i < priv->num_ctrl; i++) {
> +		rc = get_ddr_config(i, &priv->adec[ADEC_NUM * i], priv->mcdi);

To be consistent: Every other failure in mc_probe() logs error message.
Inform user this failure as well.

> +		if (rc)
> +			goto err_init;
> +	}
>   
>   	rc = init_versalnet(priv);
>   	if (rc)


      reply	other threads:[~2026-11-24  8:57 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 14:20 [PATCH v2 00/12] EDAC/versalnet: Fix error handling, teardown, and robustness Shubhrajyoti Datta
2026-11-18 14:20 ` [PATCH v2 01/12] EDAC/versalnet: Fix device_register() error handling in init_one_mc() Shubhrajyoti Datta
2026-11-20 13:38   ` Pandey, Radhey Shyam
2026-11-24  1:56   ` Borislav Petkov
2026-11-18 14:20 ` [PATCH v2 02/12] EDAC/versalnet: Use designated initializer for rpmsg_channel_info Shubhrajyoti Datta
2026-11-20 13:39   ` Pandey, Radhey Shyam
2026-11-24  2:19   ` Borislav Petkov
2026-11-18 14:20 ` [PATCH v2 03/12] EDAC/versalnet: Fix use-after-free in remove_one_mc() Shubhrajyoti Datta
2026-11-24  3:16   ` Borislav Petkov
2026-11-18 14:20 ` [PATCH v2 04/12] EDAC/versalnet: Add bounds validation in rpmsg_cb() Shubhrajyoti Datta
2026-11-20 15:43   ` Pandey, Radhey Shyam
2026-11-18 14:20 ` [PATCH v2 05/12] EDAC/versalnet: Make dwidth per-controller Shubhrajyoti Datta
2026-11-20 16:54   ` Pandey, Radhey Shyam
2026-11-18 14:20 ` [PATCH v2 06/12] EDAC/versalnet: Wait for RPMsg endpoint initialization Shubhrajyoti Datta
2026-11-21 15:28   ` Pandey, Radhey Shyam
2026-11-18 14:20 ` [PATCH v2 07/12] EDAC/versalnet: Initialize MCDI before RPMsg registration Shubhrajyoti Datta
2026-11-21 15:33   ` Pandey, Radhey Shyam
2026-11-18 14:20 ` [PATCH v2 08/12] EDAC/versalnet: Guard against NULL drvdata in rpmsg_cb() Shubhrajyoti Datta
2026-11-23 17:36   ` Pandey, Radhey Shyam
2026-11-18 14:20 ` [PATCH v2 09/12] EDAC/versalnet: Move platform_set_drvdata() to mc_probe() Shubhrajyoti Datta
2026-11-18 14:20 ` [PATCH v2 10/12] dt-bindings: memory: xlnx,versal-net-ddrmc5: Add amd,num-ctrl property Shubhrajyoti Datta
2026-11-24  5:00   ` Pandey, Radhey Shyam
2026-11-24  6:35   ` Krzysztof Kozlowski
2026-11-18 14:20 ` [PATCH v2 11/12] EDAC/versalnet: use device tree property for number of controllers Shubhrajyoti Datta
2026-11-24  5:50   ` Pandey, Radhey Shyam
2026-11-18 14:20 ` [PATCH v2 12/12] EDAC/versalnet: Make get_ddr_config() return errors Shubhrajyoti Datta
2026-11-24  8:56   ` Pandey, Radhey Shyam [this message]

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=b1036e45-dfd3-42b8-bec5-34c59447a25f@amd.com \
    --to=radheys@amd.com \
    --cc=bp@alien8.de \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=git@amd.com \
    --cc=krzk@kernel.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=robh@kernel.org \
    --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 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®